Changes On Branch wip-gradle-modernization

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

Changes In Branch wip-gradle-modernization Excluding Merge-Ins

This is equivalent to a diff from 5ac5baac33 to 8f1816204b

2020-03-02
05:18
Merge wip-gradle-modernization branch into trunk. check-in: a5aaa48037 user: stephanie.gawroriski tags: trunk, x-date-202003
05:05
Correct MIME decoder test for Windows. Closed-Leaf check-in: 8f1816204b user: stephanie.gawroriski tags: wip-gradle-modernization
04:45
Make JUnit dir in Windows. check-in: 9457ff90e4 user: stephanie.gawroriski tags: wip-gradle-modernization
2020-02-15
08:03
Backup developer notes. check-in: 1b0f4e8f10 user: squirreljme tags: trunk
2020-02-14
00:19
Create new branch named "wip-gradle-modernization" check-in: e2ed788c2b user: stephanie.gawroriski tags: wip-gradle-modernization
2020-02-08
15:31
Update GitHub URL of repository and private key. check-in: 5ac5baac33 user: stephanie.gawroriski tags: trunk
2020-02-06
08:03
Backup developer notes. check-in: b1e504d827 user: squirreljme tags: trunk

Changes to .circleci/config.yml.

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

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216


217
218
219

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240

241
242
243
244
245
246
247
248
249
250

251
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
278
279
280
281
282
283
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


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






































-




-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
+




-
+
-

-
-
-
-
-
+
+
-
-
-
-
-
+
-
-

-
-
+
+
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+


-
-
+
-
-

-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-
-
+
+
+
+
+
-
-

-
+

-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+

-
-
+
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-

-
-
+
+

-
-
+
+

-
-
-
+
+
+
-
-
-
+
+
-
-
-
-
-

-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+





-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# DESCRIPTION: CircleCI Build Configuration

version: 2.1
executors:
  buildenv:
    docker:
      - image: circleci/openjdk:8-jdk
    working_directory: ~/squirreljme-build

orbs:
  win: circleci/windows@2.2.0

commands:
  initialize_buildenv:
    description: "Initializes the build environment"
    steps:
      - checkout:
          path: ~/squirreljme
      - run:
          name: Setup directories
          command: mkdir -p ~/squirreljme-build /tmp/summercoat /tmp/summercoat-test
      - run:
          name: Install build-essential
          command: sudo apt-get install --no-install-recommends -y build-essential || true
      - run:
          name: Install crossbuild-essential-powerpc
          command: sudo apt-get install --no-install-recommends -y crossbuild-essential-powerpc || true
      - run:
          name: Install crossbuild-essential-mips
          command: sudo apt-get install --no-install-recommends -y crossbuild-essential-mips || true
      - run:
          name: Install crossbuild-essential-mipsel
          command: sudo apt-get install --no-install-recommends -y crossbuild-essential-mipsel || true
      - run:
          name: Install qemu-user
          command: sudo apt-get install --no-install-recommends -y qemu-user || true
      - run:
          name: Install unzip
          command: sudo apt-get install --no-install-recommends -y unzip || true

jobs:
  build_javase_windows:
  build_windows:
    executor:
      name: win/default
      shell: cmd.exe
    steps:
      - checkout:
      - checkout
          path: c:\users\circleci\squirreljme
      - run:
          name: Make build directory
          command: mkdir c:\users\circleci\squirreljme-build
      - run:
          name: Go to build directory
          command: cd c:\users\circleci\squirreljme-build
          name: Gradle Build
          command: gradlew build --continue --parallel
      - run:
          name: Perform Shaded Java SE Build
          command: c:\users\circleci\squirreljme\build.cmd dist javase
  build_javase:
    executor: buildenv
          shell: cmd.exe
    steps:
      - initialize_buildenv
      - run:
          name: Shade JavaSE
          command: ~/squirreljme/build.sh dist javase
          name: Save test results
          command: |
  build_javame:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
            mkdir -p /c/users/circleci/test-results/junit
            /usr/bin/find . -type f -regex '.*/build/test-results/.*xml' -exec cp {} /c/users/circleci/test-results/junit/ \;
          when: always
          name: Shade JavaME
          command: ~/squirreljme/build.sh dist javame
  build_summercoatrom:
    executor: buildenv
    steps:
          shell: bash.exe
      - store_test_results:
      - initialize_buildenv
      - run:
          name: Building SummerCoat ROM
          command: ~/squirreljme/build.sh dist summercoatrom
      - run:
          name: UnZip SummerCoat ROM
          command: unzip -o squirreljme-summercoatrom.zip
      - run:
          name: Copy ROM file
          command: cp -v squirreljme.sqc /tmp/summercoat/squirreljme.sqc
      - persist_to_workspace:
          root: /tmp/summercoat
          paths:
            - squirreljme.sqc
          path: c:\users\circleci\test-results
      - store_artifacts:
  build_summercoatromtest:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
          name: Building SummerCoat Test ROM
          command: ~/squirreljme/build.sh dist summercoatrom-test
      - run:
          name: UnZip SummerCoat ROM
          command: unzip -o squirreljme-summercoatrom-test.zip
      - run:
          name: Copy ROM file
          command: cp -v squirreljme.sqc /tmp/summercoat-test/squirreljme.sqc
      - persist_to_workspace:
          root: /tmp/summercoat-test
          paths:
          path: c:\users\circleci\test-results
            - squirreljme.sqc
  tests_baseline:
  build_linux:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
      - checkout
          name: Clear old test results and snapshot
          command: rm -f bljut/baseline/results.xml baseline.nps
      - run:
          name: Create test directory
          command: mkdir -p bljut/baseline
          name: Gradle Build
          command: ./gradlew build --continue --parallel
      - run:
          name: Running Baseline Tests
          command: ~/squirreljme/utils-dev/hostedlaunch.sh tac-runner > bljut/baseline/results.xml
      - store_test_results:
          path: bljut
  tests_springcoat:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
          name: Clear old test results and snapshot
          command: rm -f spjut/springcoat/results.xml springcoat.nps
      - run:
          name: Create test directory
          command: mkdir -p spjut/springcoat
      - run:
          name: Running SpringCoat VM
          command: ~/squirreljme/build.sh launch -v springcoat -n springcoat.nps -Dcc.squirreljme.debug=false tac-runner > spjut/springcoat/results.xml
          no_output_timeout: 30m
      - store_test_results:
          path: spjut
      - store_artifacts:
          path: springcoat.nps
          destination: /nps/springcoat.nps
  tests_summercoat:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
          name: Clear old test results and snapshot
          command: rm -f sujut/summercoat/results.xml summercoat.nps
      - run:
          name: Create test directory
          command: mkdir -p sujut/summercoat
      - run:
          name: Running SummerCoat VM
          command: ~/squirreljme/build.sh launch -v summercoat -n summercoat.nps -Dcc.squirreljme.debug=false tac-runner > sujut/summercoat/results.xml
      - store_test_results:
          path: sujut
      - store_artifacts:
          path: summercoat.nps
          destination: /nps/summercoat.nps
  tests_summercoatrom:
    executor: buildenv
    steps:
      - initialize_buildenv
      - attach_workspace:
          at: /tmp/summercoat-test
      - run:
          name: Clear old test results and snapshot
          command: rm -f svjut/summercoatrom/results.xml summercoatrom.nps
      - run:
          name: Create test directory
          command: mkdir -p svjut/summercoatrom
      - run:
          name: Take SummerCoat Test ROM
          command: cp -v /tmp/summercoat-test/squirreljme.sqc .
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit/
            find . -type f -regex '.*/build/test-results/.*xml' -exec cp {} ~/test-results/junit/ \;
          when: always
          name: Running SummerCoat VM
          command: ~/squirreljme/build.sh launch -v summercoat -n summercoatrom.nps -Dcc.squirreljme.debug=false -Dcc.squirreljme.romfile=squirreljme.sqc tac-runner > svjut/summercoatrom/results.xml
      - store_test_results:
          path: svjut
          path: ~/test-results
      - store_artifacts:
          path: summercoatrom.nps
          path: ~/test-results/junit
          destination: /nps/summercoatrom.nps
  tests_ratufacoat_default:
    executor: buildenv
  build_macosx:
    steps:
      - initialize_buildenv
      - attach_workspace:
          at: /tmp/summercoat-test
      - run:
          name: Clear old test results and snapshot
          command: rm -f rdjut/ratufacoatdef/results.xml
      - run:
          name: Create test directory
          command: mkdir -p rdjut/ratufacoatdef
      - run:
          name: Take SummerCoat Test ROM
          command: cp -v /tmp/summercoat-test/squirreljme.sqc .
      - run:
          name: Cleaning RatufaCoat VM (Default)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile clean
      - run:
          name: Building RatufaCoat VM (Default)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile squirreljme-stdc
      - run:
          name: Running RatufaCoat VM (Default)
          command: ~/squirreljme/ratufacoat/squirreljme-stdc -Dcc.squirreljme.autolaunch=tac-runner > rdjut/ratufacoatdef/results.xml
      - store_test_results:
          path: rdjut
  tests_ratufacoat_ppc:
    executor: buildenv
    macos:
      xcode: 11.3.0
    steps:
      - initialize_buildenv
      - run:
      - checkout
          name: Halt if compiler not available
          command: if ! which powerpc-linux-gnu-gcc; then circleci-agent step halt; fi
      - attach_workspace:
          at: /tmp/summercoat-test
      - run:
          name: Clear old test results and snapshot
          command: rm -f rpjut/ratufacoatppc/results.xml
      - run:
          name: Create test directory
          command: mkdir -p rpjut/ratufacoatppc
      - run:
          name: Take SummerCoat Test ROM
          command: cp -v /tmp/summercoat-test/squirreljme.sqc .
      - run:
          name: Cleaning RatufaCoat VM (PowerPC)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile clean
      - run:
          name: Building RatufaCoat VM (PowerPC)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile squirreljme-stdc CC=powerpc-linux-gnu-gcc CFLAGS='-static -DSJME_BIG_ENDIAN'
      - run:
          name: Running RatufaCoat VM (PowerPC)
          name: Update Brew
          command: qemu-ppc ~/squirreljme/ratufacoat/squirreljme-stdc -Dcc.squirreljme.autolaunch=tac-runner > rpjut/ratufacoatppc/results.xml
      - store_test_results:
          path: rpjut
  tests_ratufacoat_mips:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
          name: Halt if compiler not available
          command: if ! which mips-linux-gnu-gcc; then circleci-agent step halt; fi
          command: brew update
      - attach_workspace:
          at: /tmp/summercoat-test
      - run:
          name: Clear old test results and snapshot
          command: rm -f rmjut/ratufacoatmips/results.xml
          name: Install Gradle and OpenJDK 11
          command: brew install gradle openjdk@11
      - run:
          name: Create test directory
          command: mkdir -p rmjut/ratufacoatmips
          name: Gradle Build
          command: ./gradlew build --continue --parallel
      - run:
          name: Take SummerCoat Test ROM
          command: cp -v /tmp/summercoat-test/squirreljme.sqc .
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit/
          name: Cleaning RatufaCoat VM (MIPS EB)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile clean
      - run:
            find . -type f -regex '.*/build/test-results/.*xml' -exec cp {} ~/test-results/junit/ \;
          when: always
          name: Building RatufaCoat VM (MIPS EB)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile squirreljme-stdc CC=mips-linux-gnu-gcc CFLAGS='-static -DSJME_BIG_ENDIAN'
      - run:
          name: Running RatufaCoat VM (MIPS EB)
          command: qemu-mips ~/squirreljme/ratufacoat/squirreljme-stdc -Dcc.squirreljme.autolaunch=tac-runner > rmjut/ratufacoatmips/results.xml
      - store_test_results:
          path: rmjut
          path: ~/test-results
  tests_ratufacoat_mipsel:
    executor: buildenv
    steps:
      - initialize_buildenv
      - run:
          name: Halt if compiler not available
          command: if ! which mipsel-linux-gnu-gcc; then circleci-agent step halt; fi
      - attach_workspace:
          at: /tmp/summercoat-test
      - run:
          name: Clear old test results and snapshot
          command: rm -f rnjut/ratufacoatmipsel/results.xml
      - run:
          name: Create test directory
          command: mkdir -p rnjut/ratufacoatmipsel
      - run:
          name: Take SummerCoat Test ROM
          command: cp -v /tmp/summercoat-test/squirreljme.sqc .
      - run:
          name: Cleaning RatufaCoat VM (MIPS EL)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile clean
      - run:
          name: Building RatufaCoat VM (MIPS EL)
          command: make -C ~/squirreljme/ratufacoat -f ~/squirreljme/ratufacoat/makefile squirreljme-stdc CC=mipsel-linux-gnu-gcc CFLAGS='-static -DSJME_LITTLE_ENDIAN'
      - run:
          name: Running RatufaCoat VM (MIPS EL)
          command: qemu-mipsel ~/squirreljme/ratufacoat/squirreljme-stdc -Dcc.squirreljme.autolaunch=tac-runner > rnjut/ratufacoatmipsel/results.xml
      - store_test_results:
          path: rnjut
      - store_artifacts:
          path: ~/test-results/junit

workflows:
  version: 2
  tests:
    jobs:
      - build_javase
      - build_javame
      - build_windows
      - build_linux
      - build_javase_windows:
          requires:
            - build_javase
      - build_macosx
      - tests_baseline:
          requires:
            - build_javase
      - build_summercoatrom:
          requires:
            - build_javase
            - build_javame
      - build_summercoatromtest:
          requires:
            - build_summercoatrom
      - tests_springcoat:
          requires:
            - build_javase
      - tests_summercoat:
          requires:
            - build_javase
      - tests_summercoatrom:
          requires:
            - build_summercoatromtest
      - tests_ratufacoat_default:
          requires:
            - build_summercoatromtest
      - tests_ratufacoat_ppc:
          requires:
            - build_summercoatromtest
      - tests_ratufacoat_mips:
          requires:
            - build_summercoatromtest
      - tests_ratufacoat_mipsel:
          requires:
            - build_summercoatromtest

Added .fossil-settings/binary-glob.


1
+
gradle/wrapper/gradle-wrapper.jar

Changes to .fossil-settings/ignore-glob.

56
57
58
59
60
61
62
63










64
65
66
67
68
69
70
71
72
73
74
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








+
+
+
+
+
+
+
+
+
+

-

-







*.a
*.prc
*.dll
*.exe
*.ttyrec
*.patch
*.diff

# Gradle building
.gradle
modules/build
modules/*/build
emulators/build
emulators/*/build
tools/build
tools/*/build
buildSrc/build

# Files which should be mime encoded
*.png
*.xcf
*.png
*.bmp
*.mid
*.midi
*.wav
*.aif
*.aiff
*.snd

Added .gitattributes.




1
2
3
+
+
+
# Do not automatically adjust line endings so that way the line-feeds are
# the same and consistent
* text=false

Added .github/workflows/build.yaml.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
name: Build
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
    - name: Build
      run: ./gradlew build --continue --parallel

Added .github/workflows/validate-gradle-wrapper.yaml.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
name: "Validate Gradle Wrapper"
on: [push, pull_request]

jobs:
  validation:
    name: "Validation"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: gradle/wrapper-validation-action@v1

Changes to .gitignore.

56
57
58
59
60
61
62
63










64
65
66
67
68
69
70
71
72
73
74
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








+
+
+
+
+
+
+
+
+
+

-

-







*.a
*.prc
*.dll
*.exe
*.ttyrec
*.patch
*.diff

# Gradle building
.gradle
modules/build
modules/*/build
emulators/build
emulators/*/build
tools/build
tools/*/build
buildSrc/build

# Files which should be mime encoded
*.png
*.xcf
*.png
*.bmp
*.mid
*.midi
*.wav
*.aif
*.aiff
*.snd

Added .idea/checkstyle-idea.xml.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CheckStyle-IDEA">
    <option name="configuration">
      <map>
        <entry key="checkstyle-version" value="8.29" />
        <entry key="copy-libs" value="false" />
        <entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
        <entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
        <entry key="location-2" value="LOCAL_FILE:$PROJECT_DIR$/config/checkstyle/checkstyle.xml:SquirrelJME" />
        <entry key="scan-before-checkin" value="false" />
        <entry key="scanscope" value="JavaOnlyWithTests" />
        <entry key="suppress-errors" value="true" />
      </map>
    </option>
  </component>
</project>

Added .idea/codeStyles/Project.xml.



































































































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<component name="ProjectCodeStyleConfiguration">
  <code_scheme name="Project" version="173">
    <option name="OTHER_INDENT_OPTIONS">
      <value>
        <option name="USE_TAB_CHARACTER" value="true" />
      </value>
    </option>
    <option name="LINE_SEPARATOR" value="&#10;" />
    <option name="RIGHT_MARGIN" value="79" />
    <DBN-PSQL>
      <case-options enabled="true">
        <option name="KEYWORD_CASE" value="lower" />
        <option name="FUNCTION_CASE" value="lower" />
        <option name="PARAMETER_CASE" value="lower" />
        <option name="DATATYPE_CASE" value="lower" />
        <option name="OBJECT_CASE" value="preserve" />
      </case-options>
      <formatting-settings enabled="false" />
    </DBN-PSQL>
    <DBN-SQL>
      <case-options enabled="true">
        <option name="KEYWORD_CASE" value="lower" />
        <option name="FUNCTION_CASE" value="lower" />
        <option name="PARAMETER_CASE" value="lower" />
        <option name="DATATYPE_CASE" value="lower" />
        <option name="OBJECT_CASE" value="preserve" />
      </case-options>
      <formatting-settings enabled="false">
        <option name="STATEMENT_SPACING" value="one_line" />
        <option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
        <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
      </formatting-settings>
    </DBN-SQL>
    <JavaCodeStyleSettings>
      <option name="PARAMETER_NAME_PREFIX" value="__" />
      <option name="TEST_NAME_PREFIX" value="Test" />
      <option name="TEST_NAME_SUFFIX" value="" />
      <option name="SUBCLASS_NAME_SUFFIX" value="" />
      <option name="GENERATE_FINAL_LOCALS" value="true" />
      <option name="REPLACE_NULL_CHECK" value="false" />
      <option name="REPLACE_SUM" value="false" />
      <option name="CLASS_NAMES_IN_JAVADOC" value="3" />
      <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
      <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
      <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
        <value />
      </option>
      <option name="IMPORT_LAYOUT_TABLE">
        <value>
          <package name="" withSubpackages="true" static="false" />
          <package name="" withSubpackages="true" static="true" />
        </value>
      </option>
      <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
      <option name="JD_PRESERVE_LINE_FEEDS" value="true" />
      <option name="JD_PARAM_DESCRIPTION_ON_NEW_LINE" value="true" />
    </JavaCodeStyleSettings>
    <codeStyleSettings language="Groovy">
      <indentOptions>
        <option name="CONTINUATION_INDENT_SIZE" value="4" />
        <option name="USE_TAB_CHARACTER" value="true" />
      </indentOptions>
    </codeStyleSettings>
    <codeStyleSettings language="JAVA">
      <option name="KEEP_LINE_BREAKS" value="false" />
      <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
      <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
      <option name="BLANK_LINES_BEFORE_PACKAGE" value="1" />
      <option name="BLANK_LINES_AROUND_FIELD" value="1" />
      <option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1" />
      <option name="BRACE_STYLE" value="2" />
      <option name="CLASS_BRACE_STYLE" value="2" />
      <option name="METHOD_BRACE_STYLE" value="2" />
      <option name="LAMBDA_BRACE_STYLE" value="3" />
      <option name="ELSE_ON_NEW_LINE" value="true" />
      <option name="CATCH_ON_NEW_LINE" value="true" />
      <option name="FINALLY_ON_NEW_LINE" value="true" />
      <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
      <option name="SPACE_AFTER_TYPE_CAST" value="false" />
      <option name="SPACE_BEFORE_CLASS_LBRACE" value="false" />
      <option name="SPACE_BEFORE_METHOD_LBRACE" value="false" />
      <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
      <option name="CALL_PARAMETERS_WRAP" value="1" />
      <option name="PREFER_PARAMETERS_WRAP" value="true" />
      <option name="METHOD_PARAMETERS_WRAP" value="1" />
      <option name="THROWS_LIST_WRAP" value="1" />
      <option name="EXTENDS_KEYWORD_WRAP" value="2" />
      <option name="THROWS_KEYWORD_WRAP" value="2" />
      <option name="METHOD_CALL_CHAIN_WRAP" value="1" />
      <option name="TERNARY_OPERATION_WRAP" value="1" />
      <option name="ASSIGNMENT_WRAP" value="1" />
      <option name="WRAP_COMMENTS" value="true" />
      <option name="WRAP_LONG_LINES" value="true" />
      <option name="WRAP_ON_TYPING" value="0" />
      <indentOptions>
        <option name="CONTINUATION_INDENT_SIZE" value="4" />
        <option name="USE_TAB_CHARACTER" value="true" />
        <option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
      </indentOptions>
      <arrangement>
        <groups />
        <rules>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PUBLIC>true</PUBLIC>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PROTECTED>true</PROTECTED>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PRIVATE>true</PRIVATE>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PUBLIC>true</PUBLIC>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PROTECTED>true</PROTECTED>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PRIVATE>true</PRIVATE>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PUBLIC>true</PUBLIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PROTECTED>true</PROTECTED>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <FINAL>true</FINAL>
                  <PRIVATE>true</PRIVATE>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PUBLIC>true</PUBLIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PROTECTED>true</PROTECTED>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <FIELD>true</FIELD>
                  <PRIVATE>true</PRIVATE>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
                  <STATIC>true</STATIC>
                </AND>
              </match>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
              </match>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <CONSTRUCTOR>true</CONSTRUCTOR>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <ABSTRACT>true</ABSTRACT>
                  <METHOD>true</METHOD>
                  <STATIC>false</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <ABSTRACT>false</ABSTRACT>
                  <METHOD>true</METHOD>
                  <PACKAGE_PRIVATE>false</PACKAGE_PRIVATE>
                  <PRIVATE>false</PRIVATE>
                  <STATIC>false</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <ABSTRACT>false</ABSTRACT>
                  <METHOD>true</METHOD>
                  <PACKAGE_PRIVATE>true</PACKAGE_PRIVATE>
                  <STATIC>false</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <ABSTRACT>false</ABSTRACT>
                  <METHOD>true</METHOD>
                  <PRIVATE>true</PRIVATE>
                  <STATIC>false</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <METHOD>true</METHOD>
                  <PUBLIC>true</PUBLIC>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <METHOD>true</METHOD>
                  <PRIVATE>true</PRIVATE>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <CLASS>true</CLASS>
                  <STATIC>false</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <AND>
                  <CLASS>true</CLASS>
                  <STATIC>true</STATIC>
                </AND>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <ENUM>true</ENUM>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
          <section>
            <rule>
              <match>
                <INTERFACE>true</INTERFACE>
              </match>
              <order>BY_NAME</order>
            </rule>
          </section>
        </rules>
      </arrangement>
    </codeStyleSettings>
    <codeStyleSettings language="Shell Script">
      <indentOptions>
        <option name="INDENT_SIZE" value="4" />
        <option name="TAB_SIZE" value="4" />
        <option name="USE_TAB_CHARACTER" value="true" />
      </indentOptions>
    </codeStyleSettings>
    <codeStyleSettings language="XML">
      <indentOptions>
        <option name="USE_TAB_CHARACTER" value="true" />
      </indentOptions>
    </codeStyleSettings>
  </code_scheme>
</component>

Added .idea/codeStyles/codeStyleConfig.xml.






1
2
3
4
5
+
+
+
+
+
<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
  </state>
</component>

Added .idea/compiler.xml.































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <bytecodeTargetLevel>
      <module name="squirreljme.emulators.emulator-runner.main" target="8" />
      <module name="squirreljme.emulators.emulator-runner.test" target="8" />
      <module name="squirreljme.main" target="1.7" />
      <module name="squirreljme.modules.all-vms.main" target="1.7" />
      <module name="squirreljme.modules.all-vms.test" target="1.7" />
      <module name="squirreljme.modules.build.main" target="1.7" />
      <module name="squirreljme.modules.build.test" target="1.7" />
      <module name="squirreljme.modules.cldc-compact.testFixtures" target="1.7" />
      <module name="squirreljme.modules.cldc.testFixtures" target="1.7" />
      <module name="squirreljme.modules.collections.testFixtures" target="1.7" />
      <module name="squirreljme.modules.common-vm-stubs.main" target="1.7" />
      <module name="squirreljme.modules.common-vm-stubs.test" target="1.7" />
      <module name="squirreljme.modules.common-vm.testFixtures" target="1.7" />
      <module name="squirreljme.modules.demo-hello.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-adc.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-atcmd.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-counter.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-dac.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-generic.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-gpio.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-i2cbus.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-mmio.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-modem.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-pwm.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-spibus.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-uart.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio-watchdog.testFixtures" target="1.7" />
      <module name="squirreljme.modules.dio.testFixtures" target="1.7" />
      <module name="squirreljme.modules.gcf.testFixtures" target="1.7" />
      <module name="squirreljme.modules.io.testFixtures" target="1.7" />
      <module name="squirreljme.modules.jblend-api.testFixtures" target="1.7" />
      <module name="squirreljme.modules.launcher.testFixtures" target="1.7" />
      <module name="squirreljme.modules.lcdui-demo.testFixtures" target="1.7" />
      <module name="squirreljme.modules.m3g.testFixtures" target="1.7" />
      <module name="squirreljme.modules.main" target="1.7" />
      <module name="squirreljme.modules.markdown-writer.testFixtures" target="1.7" />
      <module name="squirreljme.modules.media-api.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-cellular.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-concurrency.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-event.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-key.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-liblets.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-lui.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-midlet.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-power.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-provisioning.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-rms.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-securityframework.testFixtures" target="1.7" />
      <module name="squirreljme.modules.meep-swm.testFixtures" target="1.7" />
      <module name="squirreljme.modules.midp-lcdui.testFixtures" target="1.7" />
      <module name="squirreljme.modules.opengles.testFixtures" target="1.7" />
      <module name="squirreljme.modules.profile-meep.testFixtures" target="1.7" />
      <module name="squirreljme.modules.springcoat-vm.main" target="1.7" />
      <module name="squirreljme.modules.springcoat-vm.test" target="1.7" />
      <module name="squirreljme.modules.squirrel-quarrel.testFixtures" target="1.7" />
      <module name="squirreljme.modules.strings.testFixtures" target="1.7" />
      <module name="squirreljme.modules.summercoat-vm.main" target="1.7" />
      <module name="squirreljme.modules.summercoat-vm.test" target="1.7" />
      <module name="squirreljme.modules.supervisor.main" target="1.7" />
      <module name="squirreljme.modules.supervisor.test" target="1.7" />
      <module name="squirreljme.modules.supervisor.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tac-runner.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tac.testFixtures" target="1.7" />
      <module name="squirreljme.modules.test" target="1.7" />
      <module name="squirreljme.modules.tool-classfile.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-compiler.main" target="1.7" />
      <module name="squirreljme.modules.tool-compiler.test" target="1.7" />
      <module name="squirreljme.modules.tool-compiler.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-jarfile.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-jdwp.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-manifest-reader.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-manifest-writer.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-packfile.testFixtures" target="1.7" />
      <module name="squirreljme.modules.tool-profiler.main" target="1.7" />
      <module name="squirreljme.modules.tool-profiler.test" target="1.7" />
      <module name="squirreljme.modules.tool-profiler.testFixtures" target="1.7" />
      <module name="squirreljme.modules.vodafone-api.testFixtures" target="1.7" />
      <module name="squirreljme.modules.zip.testFixtures" target="1.7" />
      <module name="squirreljme.test" target="1.7" />
      <module name="squirreljme.tools.instruction-popcount.main" target="1.7" />
      <module name="squirreljme.tools.instruction-popcount.test" target="1.7" />
      <module name="squirreljme.tools.javap.main" target="1.7" />
      <module name="squirreljme.tools.javap.test" target="1.7" />
      <module name="squirreljme.tools.sxs.main" target="1.7" />
      <module name="squirreljme.tools.sxs.test" target="1.7" />
      <module name="squirreljme.utilities.main" target="1.7" />
      <module name="squirreljme.utilities.test" target="1.7" />
    </bytecodeTargetLevel>
  </component>
</project>

Added .idea/dictionaries/xer.xml.
















































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<component name="ProjectDictionaryState">
  <dictionary name="xer">
    <words>
      <w>accel</w>
      <w>backlight</w>
      <w>bootram</w>
      <w>cldc</w>
      <w>endianess</w>
      <w>fprintf</w>
      <w>gawroriski</w>
      <w>ioob</w>
      <w>jarray</w>
      <w>jboolean</w>
      <w>jbyte</w>
      <w>jchar</w>
      <w>jclass</w>
      <w>jdouble</w>
      <w>jfield</w>
      <w>jfloat</w>
      <w>jint</w>
      <w>jlong</w>
      <w>jme's</w>
      <w>jmethod</w>
      <w>jnicall</w>
      <w>jniexport</w>
      <w>jobject</w>
      <w>jshort</w>
      <w>jstring</w>
      <w>jthrowable</w>
      <w>jvalue</w>
      <w>jweak</w>
      <w>multiphasicapps</w>
      <w>narg</w>
      <w>phasic</w>
      <w>siii</w>
      <w>siiii</w>
      <w>siiiii</w>
      <w>siiiiii</w>
      <w>siiiiiii</w>
      <w>siiiiiiii</w>
      <w>squirreljme</w>
      <w>stdint</w>
      <w>targetting</w>
      <w>vtable</w>
    </words>
  </dictionary>
</component>

Added .idea/fileTemplates/includes/File Header.java.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

Added .idea/fileTemplates/internal/AnnotationType.java.













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#parse("File Header.java")

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

/**
 * Not Described
 *
 * @since ${YEAR}/${MONTH}/${DAY}
 */
public @interface ${NAME}
{
}

Added .idea/fileTemplates/internal/Class.java.













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#parse("File Header.java")

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end 

/**
 * Not Described
 *
 * @since ${YEAR}/${MONTH}/${DAY}
 */
public class ${NAME}
{
}

Added .idea/fileTemplates/internal/Enum.java.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#parse("File Header.java")

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

/**
 * Not Described
 *
 * @since ${YEAR}/${MONTH}/${DAY}
 */
public enum ${NAME}
{
	/** End. */
	;
}

Added .idea/fileTemplates/internal/Interface.java.













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
#parse("File Header.java")

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

/**
 * Not Described
 *
 * @since ${YEAR}/${MONTH}/${DAY}
 */
public interface ${NAME}
{
}

Added .idea/fileTemplates/internal/package-info.java.




1
2
3
+
+
+
#parse("File Header.java")

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

Added .idea/gradle.xml.


























































































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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleMigrationSettings" migrationVersion="1" />
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="delegatedBuild" value="true" />
        <option name="testRunner" value="GRADLE" />
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="gradleJvm" value="1.8" />
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/buildSrc" />
            <option value="$PROJECT_DIR$/emulators" />
            <option value="$PROJECT_DIR$/emulators/emulator-base" />
            <option value="$PROJECT_DIR$/emulators/springcoat-vm" />
            <option value="$PROJECT_DIR$/emulators/summercoat-vm" />
            <option value="$PROJECT_DIR$/modules" />
            <option value="$PROJECT_DIR$/modules/cldc" />
            <option value="$PROJECT_DIR$/modules/cldc-compact" />
            <option value="$PROJECT_DIR$/modules/collections" />
            <option value="$PROJECT_DIR$/modules/common-vm" />
            <option value="$PROJECT_DIR$/modules/demo-hello" />
            <option value="$PROJECT_DIR$/modules/dio" />
            <option value="$PROJECT_DIR$/modules/dio-adc" />
            <option value="$PROJECT_DIR$/modules/dio-atcmd" />
            <option value="$PROJECT_DIR$/modules/dio-counter" />
            <option value="$PROJECT_DIR$/modules/dio-dac" />
            <option value="$PROJECT_DIR$/modules/dio-generic" />
            <option value="$PROJECT_DIR$/modules/dio-gpio" />
            <option value="$PROJECT_DIR$/modules/dio-i2cbus" />
            <option value="$PROJECT_DIR$/modules/dio-mmio" />
            <option value="$PROJECT_DIR$/modules/dio-modem" />
            <option value="$PROJECT_DIR$/modules/dio-pwm" />
            <option value="$PROJECT_DIR$/modules/dio-spibus" />
            <option value="$PROJECT_DIR$/modules/dio-uart" />
            <option value="$PROJECT_DIR$/modules/dio-watchdog" />
            <option value="$PROJECT_DIR$/modules/gcf" />
            <option value="$PROJECT_DIR$/modules/io" />
            <option value="$PROJECT_DIR$/modules/jblend-api" />
            <option value="$PROJECT_DIR$/modules/launcher" />
            <option value="$PROJECT_DIR$/modules/lcdui-demo" />
            <option value="$PROJECT_DIR$/modules/m3g" />
            <option value="$PROJECT_DIR$/modules/markdown-writer" />
            <option value="$PROJECT_DIR$/modules/media-api" />
            <option value="$PROJECT_DIR$/modules/meep-cellular" />
            <option value="$PROJECT_DIR$/modules/meep-concurrency" />
            <option value="$PROJECT_DIR$/modules/meep-event" />
            <option value="$PROJECT_DIR$/modules/meep-key" />
            <option value="$PROJECT_DIR$/modules/meep-liblets" />
            <option value="$PROJECT_DIR$/modules/meep-lui" />
            <option value="$PROJECT_DIR$/modules/meep-midlet" />
            <option value="$PROJECT_DIR$/modules/meep-power" />
            <option value="$PROJECT_DIR$/modules/meep-provisioning" />
            <option value="$PROJECT_DIR$/modules/meep-rms" />
            <option value="$PROJECT_DIR$/modules/meep-securityframework" />
            <option value="$PROJECT_DIR$/modules/meep-swm" />
            <option value="$PROJECT_DIR$/modules/midp-lcdui" />
            <option value="$PROJECT_DIR$/modules/opengles" />
            <option value="$PROJECT_DIR$/modules/profile-meep" />
            <option value="$PROJECT_DIR$/modules/squirrel-quarrel" />
            <option value="$PROJECT_DIR$/modules/strings" />
            <option value="$PROJECT_DIR$/modules/tac" />
            <option value="$PROJECT_DIR$/modules/tac-runner" />
            <option value="$PROJECT_DIR$/modules/tool-classfile" />
            <option value="$PROJECT_DIR$/modules/tool-jarfile" />
            <option value="$PROJECT_DIR$/modules/tool-jdwp" />
            <option value="$PROJECT_DIR$/modules/tool-manifest-reader" />
            <option value="$PROJECT_DIR$/modules/tool-manifest-writer" />
            <option value="$PROJECT_DIR$/modules/tool-packfile" />
            <option value="$PROJECT_DIR$/modules/vodafone-api" />
            <option value="$PROJECT_DIR$/modules/zip" />
            <option value="$PROJECT_DIR$/tools" />
            <option value="$PROJECT_DIR$/tools/dump-class" />
            <option value="$PROJECT_DIR$/tools/dump-zip" />
            <option value="$PROJECT_DIR$/tools/pcf-to-sqf" />
            <option value="$PROJECT_DIR$/tools/sqf-to-c" />
            <option value="$PROJECT_DIR$/tools/txt-to-pbm" />
            <option value="$PROJECT_DIR$/tools/uudecode" />
          </set>
        </option>
        <option name="useAutoImport" value="true" />
        <option name="useQualifiedModuleNames" value="true" />
      </GradleProjectSettings>
    </option>
  </component>
</project>

Added .idea/inspectionProfiles/Project_Default.xml.































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<component name="InspectionProjectProfileManager">
  <profile version="1.0">
    <option name="myName" value="Project Default" />
    <inspection_tool class="AbstractClassWithOnlyOneDirectInheritor" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="AbstractMethodOverridesAbstractMethod" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreJavaDoc" value="true" />
    </inspection_tool>
    <inspection_tool class="Anonymous2MethodRef" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AnonymousClassComplexity" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_limit" value="3" />
    </inspection_tool>
    <inspection_tool class="AnonymousClassMethodCount" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_limit" value="1" />
    </inspection_tool>
    <inspection_tool class="AnonymousHasLambdaAlternative" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AnonymousInnerClass" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ArrayLengthInLoopCondition" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="AssertEqualsBetweenInconvertibleTypes" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AssignmentUsedAsCondition" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="BeforeClassOrAfterClassIsPublicStaticVoidNoArg" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="BeforeOrAfterIsPublicVoidNoArg" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="BooleanMethodNameMustStartWithQuestion" enabled="false" level="WEAK WARNING" enabled_by_default="false">
      <option name="ignoreBooleanMethods" value="false" />
      <option name="ignoreInAnnotationInterface" value="true" />
      <option name="onlyWarnOnBaseMethods" value="true" />
      <option name="questionString" value="add,are,can,check,contains,could,endsWith,equals,has,is,matches,must,put,remove,shall,should,startsWith,was,were,will,would" />
    </inspection_tool>
    <inspection_tool class="CheckForOutOfMemoryOnLargeArrayAllocation" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_limit" value="64" />
    </inspection_tool>
    <inspection_tool class="ClassComplexity" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_limit" value="80" />
    </inspection_tool>
    <inspection_tool class="ClassCoupling" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_includeJavaClasses" value="false" />
      <option name="m_includeLibraryClasses" value="false" />
      <option name="m_limit" value="15" />
    </inspection_tool>
    <inspection_tool class="ClassName" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="namePattern" value="(__)?[A-Z][A-Za-z\d]*(__)?" />
    </inspection_tool>
    <inspection_tool class="ClassNamePrefixedWithPackageName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="ClassNameSameAsAncestorName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="ClassWithOnlyPrivateConstructors" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CloneReturnsClassType" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CodeBlock2Expr" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ComparatorCombinators" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ComparisonOfShortAndChar" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ConfusingMainMethod" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="ConnectionResource" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ConstPropertyName" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="namePattern" value="_?[A-Z][_A-Z\d]*" />
    </inspection_tool>
    <inspection_tool class="ConstructorCount" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreDeprecatedConstructors" value="true" />
      <option name="m_limit" value="8" />
    </inspection_tool>
    <inspection_tool class="Convert2Diamond" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Convert2Lambda" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Convert2MethodRef" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Convert2streamapi" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="DollarSignInName" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="EmptyMethod" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="EXCLUDE_ANNOS">
        <value>
          <list size="0" />
        </value>
      </option>
      <option name="commentsAreContent" value="true" />
    </inspection_tool>
    <inspection_tool class="EnhancedSwitchBackwardMigration" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="EnhancedSwitchMigration" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ExceptionNameDoesntEndWithException" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="ExplicitArgumentCanBeLambda" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="ExtendsUtilityClass" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="FeatureEnvy" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreTestCases" value="false" />
    </inspection_tool>
    <inspection_tool class="FieldNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <extension name="ConstantNamingConvention" enabled="true">
        <option name="m_regex" value="_?[a-zA-Z][A-Z_\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
      <extension name="ConstantWithMutableFieldTypeNamingConvention" enabled="true">
        <option name="m_regex" value="_?[a-z][a-zA-z_]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
      <extension name="EnumeratedConstantNamingConvention" enabled="true">
        <option name="m_regex" value="[A-Z][A-Z_\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="40" />
      </extension>
      <extension name="InstanceVariableNamingConvention" enabled="true">
        <option name="m_regex" value="_?[a-z][a-zA-z_]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
      <extension name="StaticVariableNamingConvention" enabled="true">
        <option name="m_regex" value="_?[A-Z][A-Z_\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
    </inspection_tool>
    <inspection_tool class="Finalize" enabled="true" level="ERROR" enabled_by_default="true">
      <option name="ignoreTrivialFinalizers" value="false" />
    </inspection_tool>
    <inspection_tool class="FinalizeNotProtected" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="FoldExpressionIntoStream" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="FunctionName" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="namePattern" value="(__)?[a-z][A-Za-z\d]*" />
    </inspection_tool>
    <inspection_tool class="Guava" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="HtmlTagCanBeJavadocTag" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="IfCanBeSwitch" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="minimumBranches" value="3" />
      <option name="suggestIntSwitches" value="false" />
      <option name="suggestEnumSwitches" value="false" />
    </inspection_tool>
    <inspection_tool class="InconsistentLineSeparators" enabled="true" level="TYPO" enabled_by_default="true" />
    <inspection_tool class="IndexOfReplaceableByContains" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="InterfaceWithOnlyOneDirectInheritor" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JUnit4AnnotatedMethodInJUnit3TestCase" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JUnit5MalformedNestedClass" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JUnit5MalformedParameterized" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JUnit5MalformedRepeated" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JUnit5Platform" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Java8CollectionRemoveIf" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Java8ListSort" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Java8MapApi" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Java8MapForEach" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Java9CollectionFactory" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="TOP_LEVEL_CLASS_OPTIONS">
        <value>
          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
          <option name="REQUIRED_TAGS" value="" />
        </value>
      </option>
      <option name="INNER_CLASS_OPTIONS">
        <value>
          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
          <option name="REQUIRED_TAGS" value="" />
        </value>
      </option>
      <option name="METHOD_OPTIONS">
        <value>
          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
          <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
        </value>
      </option>
      <option name="FIELD_OPTIONS">
        <value>
          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
          <option name="REQUIRED_TAGS" value="" />
        </value>
      </option>
      <option name="IGNORE_DEPRECATED" value="false" />
      <option name="IGNORE_JAVADOC_PERIOD" value="true" />
      <option name="IGNORE_DUPLICATED_THROWS" value="false" />
      <option name="IGNORE_POINT_TO_ITSELF" value="false" />
      <option name="myAdditionalJavadocTags" value="squirreljme.syscallparam,squirreljme.syscallreturn,squirreljme.property,squirreljme.error,squirreljme.property" />
    </inspection_tool>
    <inspection_tool class="JavaLangImport" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JavaModuleNaming" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JavaRequiresAutoModule" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="LambdaBodyCanBeCodeBlock" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="LambdaCanBeMethodCall" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="LambdaCanBeReplacedWithAnonymous" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="LambdaParameterNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="m_regex" value="__[a-z][A-Za-z\d]*" />
    </inspection_tool>
    <inspection_tool class="LambdaParameterTypeCanBeSpecified" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="LambdaUnfriendlyMethodOverload" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="LocalVariableName" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="namePattern" value="(__)?[a-z][A-Za-z\d]*" />
    </inspection_tool>
    <inspection_tool class="LocalVariableNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="m_ignoreForLoopParameters" value="true" />
      <option name="m_ignoreCatchParameters" value="true" />
      <option name="m_regex" value="(__)?[a-z][A-Za-z\d]*" />
      <option name="m_minLength" value="1" />
      <option name="m_maxLength" value="20" />
    </inspection_tool>
    <inspection_tool class="LongLine" enabled="true" level="TYPO" enabled_by_default="true" />
    <inspection_tool class="MagicNumber" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="MethodCallInLoopCondition" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="MethodNameSameAsClassName" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="MethodNameSameAsParentName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="MethodRefCanBeReplacedWithLambda" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="MissingOverrideAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
      <option name="ignoreObjectMethods" value="false" />
      <option name="ignoreAnonymousClassMethods" value="false" />
    </inspection_tool>
    <inspection_tool class="MissingPackageInfo" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="MissortedModifiers" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_requireAnnotationsFirst" value="true" />
    </inspection_tool>
    <inspection_tool class="MisspelledMethodName" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="MultiplyOrDivideByPowerOfTwo" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="checkDivision" value="true" />
    </inspection_tool>
    <inspection_tool class="NewClassNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
      <extension name="AbstractClassNamingConvention" enabled="true">
        <option name="inheritDefaultSettings" value="true" />
        <option name="m_regex" value="[A-Z][A-Za-z\d]*" />
        <option name="m_minLength" value="8" />
        <option name="m_maxLength" value="64" />
      </extension>
      <extension name="AnnotationNamingConvention" enabled="true">
        <option name="inheritDefaultSettings" value="true" />
        <option name="m_regex" value="[A-Z][A-Za-z\d]*" />
        <option name="m_minLength" value="8" />
        <option name="m_maxLength" value="64" />
      </extension>
      <extension name="ClassNamingConvention" enabled="true">
        <option name="m_regex" value="(__)?[A-Z][A-Za-z\d]*(__)?" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="64" />
      </extension>
      <extension name="EnumeratedClassNamingConvention" enabled="true">
        <option name="inheritDefaultSettings" value="true" />
        <option name="m_regex" value="[A-Z][A-Za-z\d]*" />
        <option name="m_minLength" value="8" />
        <option name="m_maxLength" value="64" />
      </extension>
      <extension name="InterfaceNamingConvention" enabled="true">
        <option name="inheritDefaultSettings" value="true" />
        <option name="m_regex" value="[A-Z][A-Za-z\d]*" />
        <option name="m_minLength" value="8" />
        <option name="m_maxLength" value="64" />
      </extension>
      <extension name="TypeParameterNamingConvention" enabled="true">
        <option name="m_regex" value="[A-Z]" />
        <option name="m_minLength" value="1" />
        <option name="m_maxLength" value="1" />
      </extension>
    </inspection_tool>
    <inspection_tool class="NewMethodNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <extension name="InstanceMethodNamingConvention" enabled="true">
        <option name="m_regex" value="(__)?[a-z][A-Za-z\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
      <extension name="NativeMethodNamingConvention" enabled="true">
        <option name="m_regex" value="(__)?[a-z][A-Za-z\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
      <extension name="StaticMethodNamingConvention" enabled="true">
        <option name="m_regex" value="(__)?[a-z][A-Za-z\d]*" />
        <option name="m_minLength" value="2" />
        <option name="m_maxLength" value="32" />
      </extension>
    </inspection_tool>
    <inspection_tool class="NoExplicitFinalizeCalls" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="NonBooleanMethodNameMayNotStartWithQuestion" enabled="false" level="WEAK WARNING" enabled_by_default="false">
      <option name="questionString" value="add,are,can,check,contains,could,endsWith,equals,has,is,matches,must,put,remove,shall,should,startsWith,was,were,will,would" />
      <option name="ignoreBooleanMethods" value="false" />
      <option name="onlyWarnOnBaseMethods" value="true" />
    </inspection_tool>
    <inspection_tool class="NonExceptionNameEndsWithException" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="NonPublicClone" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="NotNullFieldNotInitialized" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NullableProblems" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="REPORT_NULLABLE_METHOD_OVERRIDES_NOTNULL" value="true" />
      <option name="REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL" value="true" />
      <option name="REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE" value="true" />
      <option name="REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL" value="true" />
      <option name="REPORT_NOT_ANNOTATED_GETTER" value="true" />
      <option name="REPORT_NOT_ANNOTATED_SETTER_PARAMETER" value="true" />
      <option name="REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS" value="true" />
      <option name="REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD" value="true" />
    </inspection_tool>
    <inspection_tool class="OctalLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="OnDemandImport" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="OverloadedMethodsWithSameNumberOfParameters" enabled="false" level="WEAK WARNING" enabled_by_default="false">
      <option name="ignoreInconvertibleTypes" value="true" />
    </inspection_tool>
    <inspection_tool class="OverloadedVarargsMethod" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="OverlyLargePrimitiveArrayInitializer" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_limit" value="64" />
    </inspection_tool>
    <inspection_tool class="PackageInfoWithoutPackage" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="PackageNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true">
      <option name="m_regex" value="[a-z]*" />
      <option name="m_minLength" value="2" />
      <option name="m_maxLength" value="16" />
    </inspection_tool>
    <inspection_tool class="ParameterNameDiffersFromOverriddenParameter" enabled="false" level="WEAK WARNING" enabled_by_default="false">
      <option name="m_ignoreSingleCharacterNames" value="false" />
      <option name="m_ignoreOverridesOfLibraryMethods" value="false" />
    </inspection_tool>
    <inspection_tool class="ParameterNamingConvention" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_regex" value="__[a-z][A-Za-z\d]*" />
      <option name="m_minLength" value="3" />
      <option name="m_maxLength" value="20" />
    </inspection_tool>
    <inspection_tool class="ParameterTypePreventsOverriding" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="PrivateMemberAccessBetweenOuterAndInnerClass" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="QuestionableName" enabled="false" level="WEAK WARNING" enabled_by_default="false">
      <option name="nameString" value="aa,abc,bad,bar,bar2,baz,baz1,baz2,baz3,bb,blah,bogus,bool,cc,dd,defau1t,dummy,dummy2,ee,fa1se,ff,foo,foo1,foo2,foo3,foobar,four,fred,fred1,fred2,gg,hh,hello,hello1,hello2,hello3,ii,nu11,one,silly,silly2,string,two,that,then,three,whi1e,var" />
    </inspection_tool>
    <inspection_tool class="ReadWriteStringCanBeUsed" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="RecordStoreResource" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="RedundantExplicitVariableType" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreSerializable" value="false" />
      <option name="ignoreCloneable" value="false" />
    </inspection_tool>
    <inspection_tool class="RedundantTypeArguments" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ReplaceNullCheck" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SamePackageImport" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SimplifiableJUnitAssertion" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SimplifyForEach" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="Since15" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="SingleCharacterStartsWith" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SizeReplaceableByIsEmpty" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="StandardVariableNames" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="StaticCallOnSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="StaticFieldReferenceOnSubclass" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="StaticImport" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="StaticInheritance" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="StaticPseudoFunctionalStyleMethod" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="StaticSuite" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="StaticVariableInitialization" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_ignorePrimitives" value="false" />
    </inspection_tool>
    <inspection_tool class="StaticVariableUninitializedUse" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_ignorePrimitives" value="false" />
    </inspection_tool>
    <inspection_tool class="StringRepeatCanBeUsed" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SystemGetenv" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="TestFailedLine" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="TestMethodIsPublicVoidNoArg" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="TextBlockBackwardMigration" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="TextBlockMigration" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ToArrayCallWithZeroLengthArrayArgument" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="TodoComment" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnaryPlus" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnconstructableTestCase" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="UnnecessaryConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryFinalOnLocalVariableOrParameter" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessarySuperQualifier" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnqualifiedFieldAccess" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnqualifiedInnerClassAccess" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreReferencesToLocalInnerClasses" value="true" />
    </inspection_tool>
    <inspection_tool class="UnqualifiedMethodAccess" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnqualifiedStaticUsage" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_ignoreStaticFieldAccesses" value="false" />
      <option name="m_ignoreStaticMethodCalls" value="false" />
      <option name="m_ignoreStaticAccessFromStaticContext" value="false" />
    </inspection_tool>
    <inspection_tool class="UnstableApiUsage" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="UpperCaseFieldNameNotConstant" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="UseCompareMethod" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="UseOfAWTPeerClass" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="UseOfClone" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UseOfJDBCDriverClass" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="UseOfProcessBuilder" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="UseOfSunClasses" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="VariableTypeCanBeExplicit" enabled="false" level="INFORMATION" enabled_by_default="false" />
    <inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true" klass="packageLocal" inner_class="packageLocal" field="packageLocal" method="packageLocal">
      <option name="LOCAL_VARIABLE" value="true" />
      <option name="FIELD" value="true" />
      <option name="METHOD" value="true" />
      <option name="CLASS" value="true" />
      <option name="PARAMETER" value="true" />
      <option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="true" />
      <option name="ADD_MAINS_TO_ENTRIES" value="true" />
      <option name="ADD_APPLET_TO_ENTRIES" value="true" />
      <option name="ADD_SERVLET_TO_ENTRIES" value="true" />
      <option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
    </inspection_tool>
  </profile>
</component>

Added .idea/misc.xml.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ExternalStorageConfigurationManager" enabled="true" />
  <component name="JavaScriptSettings">
    <option name="languageLevel" value="ES6" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>

Added .idea/squirreljme.iml.



1
2
+
+
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

Deleted bldt/TIMESPACE.MF.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Timespace-Title: Build Time
X-SquirrelJME-Timespace-Type: build
X-SquirrelJME-Timespace-Description: This contains everything which is 
 only available to the SquirrelJME build system. This means that when 
 target is to be built, no projects which support building for a given 
 target are permitted to be used. This depends on the JIT time projects.

Deleted bldt/buildtime.mkd.

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
# Build-time Projects

These are projects which are only available at build-time to run SquirrelJME
projects.

 * `javase/` -- Pseudo-environment for Java SE.
 * `libs/` -- Support libraries for building.
 * `mids/` -- Building support for platforms.

Deleted bldt/javase/javase.mkd.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
# JavaSE Pseudo-Environment

This directory contains the pseudo environment for Java SE host systems. It
still uses the host class libraries but this enables support for simulating a
basic Java ME environment on Java SE which is not completely compatible as
such.

Deleted bldt/javase/libs/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: JavaSE Builder Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: Libraries which are needed for the 
 builder to operate correctly on Java SE systems.

Deleted bldt/javase/libs/builder-implementation/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: fea37c1c-007d-462b-a417-e77f326cdf73
X-SquirrelJME-Depends: builder-support javase-runtime
X-SquirrelJME-Error: BM
X-SquirrelJME-Description: This contains the builder implementation 
 which is used to allow the builder to run on Java SE systems.
Microedition-Configuration: CLDC-1.8

Deleted bldt/javase/libs/builder-implementation/META-INF/services/net.multiphasicapps.javac.CompilerService.

1

-
cc.squirreljme.builder.javase.javac.HostCompilerService

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/HostCompiler.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
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
















































































































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

package cc.squirreljme.builder.javase.javac;

import java.io.PrintStream;
import java.io.Writer;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.tools.JavaCompiler;
import net.multiphasicapps.io.PrintStreamWriter;
import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerOptions;
import net.multiphasicapps.javac.CompilerOutput;
import net.multiphasicapps.javac.CompilerPathSet;

/**
 * This is the compiler which utilizes the system Java compiler, if one is
 * available.
 *
 * @since 2017/11/28
 */
public class HostCompiler
	extends Compiler
{
	/** The real Java compiler to use. */
	protected final JavaCompiler javac;
	
	/**
	 * Initializes the host compiler which uses the given Java compiler.
	 *
	 * @param __javac The Java compiler to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public HostCompiler(JavaCompiler __javac)
		throws NullPointerException
	{
		if (__javac == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.javac = __javac;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	protected Runnable newCompilerRunnable(CompilerOutput __out,
		PrintStream __log, CompilerOptions __opt,
		CompilerPathSet[][] __paths, CompilerInput[] __input)
		throws CompilerException, NullPointerException
	{
		if (__out == null || __log == null || __opt == null ||
			__paths == null || __input == null)
			throw new NullPointerException("NARG");
		
		JavaCompiler javac = this.javac;
		
		// Decode compilation options
		List<String> options = new ArrayList<>();
		
		// Which Java version to target?
		String targver;
		switch (__opt.version())
		{
			case JAVA_7:
				targver = "1.7";
				break;
			
				// {@squirreljme.error BM01 Unsupported Java version.}
			default:
				throw new CompilerException("BM01");
		}
		options.add("-source");
		options.add(targver);
		options.add("-target");
		options.add(targver);
		
		// Debugging?
		if (__opt.debug())
			options.add("-g");
		
		// Setup file manager lookup of files
		Writer log = new PrintStreamWriter(__log);
		HostFileManager fm = new HostFileManager(__paths, __out);
		
		// Wrap all input to file objects
		Set<InputHostFileObject> input = new LinkedHashSet<>();
		for (CompilerInput i : __input)
			input.add(new InputHostFileObject(i));
		
		// Wrap task
		return new HostCompilerRunnable(javac.getTask(
			log, fm, null, options, null, input));
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/HostCompilerRunnable.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.builder.javase.javac;

import javax.tools.JavaCompiler;
import net.multiphasicapps.javac.CompilationFailedException;
import net.multiphasicapps.javac.CompilerException;

/**
 * This is the runnable which runs the compilation task.
 *
 * @since 2017/11/29
 */
public class HostCompilerRunnable
	implements Runnable
{
	/** The task to run. */
	protected final JavaCompiler.CompilationTask task;
	
	/**
	 * Initializes the compiler runnable.
	 *
	 * @param __t The task to for running.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public HostCompilerRunnable(JavaCompiler.CompilationTask __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		this.task = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public void run()
	{
		try
		{
			// {@squirreljme.error BM02 Compilation failed.}
			if (!this.task.call())
				throw new CompilationFailedException("BM02");
		}
		
		// {@squirreljme.error BM03 The compiler has failed.}
		catch (RuntimeException e)
		{
			throw new CompilerException("BM03", e);
		}
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/HostCompilerService.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







































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

package cc.squirreljme.builder.javase.javac;

import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerService;

/**
 * This provides the host compiler as a service.
 *
 * @since 2017/11/28
 */
public class HostCompilerService
	implements CompilerService
{
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public Compiler createInstance()
	{
		JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
		if (javac == null)
			return null;
		return new HostCompiler(javac);
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/HostFileManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450


































































































































































































































































































































































































































































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

package cc.squirreljme.builder.javase.javac;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerOutput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.NoSuchInputException;

/**
 * This is used by the Java compiler to manage files used by the compiler
 * for compilation and ones which are output.
 *
 * @since 2017/11/29
 */
public class HostFileManager
	implements StandardJavaFileManager
{
	/** Paths to search for input within. */
	protected final CompilerPathSet[][] paths;
	
	/** The output for the compiler. */
	protected final CompilerOutput output;
	
	/**
	 * Initializes the host file manager.
	 *
	 * @param __paths Output paths.
	 * @param __out Compiler output.
	 * @since 2017/11/29
	 */
	public HostFileManager(CompilerPathSet[][] __paths, CompilerOutput __out)
		throws NullPointerException
	{
		if (__paths == null || __out == null)
			throw new NullPointerException("NARG");
		
		this.paths = __paths;
		this.output = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public void close()
		throws IOException
	{
		// Flush the output writer so that any entries which are waiting to
		// be written are written to the ZIP
		this.output.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public void flush()
		throws IOException
	{
		// Forward to output
		this.output.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public ClassLoader getClassLoader(JavaFileManager.Location __a)
	{
		// No plug-ins permitted at all
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public FileObject getFileForInput(JavaFileManager.Location __a,
		String __b, String __c)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public FileObject getFileForOutput(JavaFileManager.Location __a,
		String __b, String __c, FileObject __d)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public JavaFileObject getJavaFileForInput(
		JavaFileManager.Location __a, String __b, JavaFileObject.Kind __c)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public JavaFileObject getJavaFileForOutput(
		JavaFileManager.Location __loc, String __cn, JavaFileObject.Kind __k,
		FileObject __sib)
		throws IOException
	{
		// {@squirreljme.error BM04 Only class file output is supported.}
		if (JavaFileObject.Kind.CLASS != __k)
			throw new IllegalArgumentException("BM04");
		
		// Convert class to "class" name
		String name = __cn.replace('.', '/') + __k.extension;
		
		// Open output file
		return new OutputHostFileObject(this.output, name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<? extends JavaFileObject> getJavaFileObjects(
		File... __a)
	{
		return getJavaFileObjectsFromFiles(Arrays.<File>asList(__a));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<? extends JavaFileObject> getJavaFileObjects(
		String... __a)
	{
		return getJavaFileObjectsFromStrings(Arrays.<String>asList(__a));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<? extends JavaFileObject>
		getJavaFileObjectsFromFiles(Iterable<? extends File> __a)
	{
		// Forward call to string version
		Set<String> args = new LinkedHashSet<>();
		for (File f : __a)
			args.add(String.valueOf(f));
		return getJavaFileObjectsFromStrings(args);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<? extends JavaFileObject>
		getJavaFileObjectsFromStrings(Iterable<String> __a)
	{
		Set<JavaFileObject> rv = new LinkedHashSet<>();
		CompilerPathSet[] srcpaths =
			this.paths[CompilerInputLocation.SOURCE.ordinal()];
		
		// Discover files
		for (String s : __a)
			if (s.endsWith(".java"))
			{
				// Go through sources and try to find the first file
				for (CompilerPathSet ps : srcpaths)
					try
					{
						rv.add(new InputHostFileObject(ps.input(s)));
						break;
					}
					catch (NoSuchInputException e)
					{
					}
			}
			
			// {@squirreljme.error BM05 Do not know how to handle getting a
			// file object from the given file name. (The name of the file)}
			else
				throw new IllegalArgumentException(String.format("BM05 %s",
					s));
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<? extends File> getLocation(
		JavaFileManager.Location __l)
	{
		// Ignore null
		if (__l == null)
			return null;
		
		// Standard locations
		if (__l instanceof StandardLocation)
			switch ((StandardLocation)__l)
			{
					// This is required for Java 9's compiler to generate
					// code
				case CLASS_OUTPUT:
					return Arrays.<File>asList(new File("squirreljme$//"));
				
					// Unknown
				default:
					return null;
			}
		
		// Unknown
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public boolean handleOption(String __a, Iterator<String> __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public boolean hasLocation(JavaFileManager.Location __a)
	{
		// Only use standard locations
		if (!(__a instanceof StandardLocation))
			return false;
		
		// Depends
		switch ((StandardLocation)__a)
		{
				// Knows class input and output
			case CLASS_OUTPUT:
			case CLASS_PATH:
			case PLATFORM_CLASS_PATH:
			case SOURCE_PATH:
				return true;
			
				// Unknown
			default:
				return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public String inferBinaryName(JavaFileManager.Location __a,
		JavaFileObject __b)
	{
		// Get name
		String name = __b.getName();
		
		// Try to remove the extension
		int ls = name.lastIndexOf('/'),
			ld = name.lastIndexOf('.');
		
		// Remove everything up to the extension
		if (ld > ls && ld >= 0)
			name = name.substring(0, ld);
		
		// Convert any slashes to dots
		return name.replace('/', '.');
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public boolean isSameFile(FileObject __a, FileObject __b)
	{
		throw new todo.TODO();
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public int isSupportedOption(String __o)
	{
		// Ignore nulls
		if (__o == null)
			return -1;
		
		// Depends on the options
		switch (__o)
		{
				// Not supported
			case "--multi-release":		// Java 9 multi-release JARs
			default:
				return -1;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Iterable<JavaFileObject> list(JavaFileManager.Location
		__l, String __pk, Set<JavaFileObject.Kind> __kinds, boolean __rec)
		throws IOException
	{
		// Setup target
		Set<JavaFileObject> rv = new LinkedHashSet<>();
		
		// Determine which input file source to use
		CompilerPathSet[][] paths = this.paths;
		CompilerPathSet[] usesets;
		if (!(__l instanceof StandardLocation))
			return rv;
		else
			switch ((StandardLocation)__l)
			{
					// Class inputs
				case CLASS_PATH:
				case PLATFORM_CLASS_PATH:
					usesets = paths[CompilerInputLocation.CLASS.ordinal()];
					break;
				
					// Source inputs
				case SOURCE_PATH:
					usesets = paths[CompilerInputLocation.SOURCE.ordinal()];
					break;
			
					// Unknown, return nothing
				default:
					return rv;
			}
		
		// Load in all files from every set
		Set<CompilerInput> files = new LinkedHashSet<>();
		for (CompilerPathSet set : usesets)
			for (CompilerInput i : set)
				files.add(i);
		
		// Prefix to consider?
		String prefix = (__pk == null ? "" : __pk.replace('.', '/') + "/");
		int prefixn = prefix.length();
		
		// Go through all files
		boolean issource = (__l == StandardLocation.SOURCE_PATH);
		for (CompilerInput f : files)
		{
			String fname = f.fileName();
			
			// Prefix does not match?
			if (!fname.startsWith(prefix))
				continue;
			
			// If not recursive, then the last slash that appears must be
			// at the same length of the prefix
			if (!__rec)
			{
				int ls = Math.max(-1, fname.lastIndexOf('/')) + 1;
				if (ls != prefixn)
					continue;
			}
			
			// Only consider files with these extensions
			boolean hit = false;
			for (JavaFileObject.Kind k : __kinds)
				if (fname.endsWith(k.extension))
				{
					hit = true;
					break;
				}
			
			// Missed extension?
			if (!hit)
				continue;
			
			// Add file
			rv.add(new InputHostFileObject(f));
		}
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public void setLocation(JavaFileManager.Location __a, Iterable<?
		extends File> __b)
		throws IOException
	{
		// Ignore any location setting as all locations are completely
		// internal
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/HostFileObject.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
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

























































































































































































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

package cc.squirreljme.builder.javase.javac;

import java.net.URI;
import java.net.URISyntaxException;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;

/**
 * This is the base for file objects.
 *
 * @since 2017/11/29
 */
public abstract class HostFileObject
	implements JavaFileObject
{
	/** The name of the file. */
	protected final String name;
	
	/**
	 * Initializes the base file object.
	 *
	 * @param __name The name of the file.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public HostFileObject(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final boolean delete()
	{
		// Unsupported
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final Modifier getAccessLevel()
	{
		// Unknown
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final JavaFileObject.Kind getKind()
	{
		// Depends on the extension
		String name = this.name;
		
		// Java source code
		if (name.endsWith(".java"))
			return JavaFileObject.Kind.SOURCE;
		
		// Java class file
		else if (name.endsWith(".class"))
			return JavaFileObject.Kind.CLASS;
		
		// HTML
		else if (name.endsWith(".htm") || name.endsWith(".html"))
			return JavaFileObject.Kind.HTML;
		
		// Unknoen
		return JavaFileObject.Kind.OTHER;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final long getLastModified()
	{
		// Unsupported
		return Long.MIN_VALUE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final String getName()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final NestingKind getNestingKind()
	{
		// Unknown
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final boolean isNameCompatible(String __sn,
		JavaFileObject.Kind __k)
	{
		// Get name
		String name = this.name;
		
		// Does not match extension?
		if (!name.endsWith(__k.extension))
			return false;
		
		// Only consider anything after the last slash
		int ls = name.lastIndexOf('/');
		if (ls > 0)
			name = name.substring(ls + 1);
		
		// And remove the extension
		int ld = name.lastIndexOf('.');
		if (ld > 0)
			name = name.substring(0, ld);
		
		// Compare base
		return name.equals(__sn);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/22
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final URI toUri()
	{
		// Can fail, but it should not
		try
		{
			return new URI("squirreljme", this.name, null);
		}
		
		// {@squirreljme.error BM06 Could not create a URI for the file.}
		catch (URISyntaxException e)
		{
			throw new RuntimeException("BM06", e);
		}
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/InputHostFileObject.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
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






























































































































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

package cc.squirreljme.builder.javase.javac;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import net.multiphasicapps.javac.CompilerInput;

/**
 * This is a file object which is used for input.
 *
 * @since 2017/11/29
 */
public class InputHostFileObject
	extends HostFileObject
{
	/** The file to source input from. */
	protected final CompilerInput input;
	
	/**
	 * Initializes the file object for input.
	 *
	 * @param __i The stream for input of classes and sources.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public InputHostFileObject(CompilerInput __i)
		throws NullPointerException
	{
		super(__i.fileName());
		
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.input = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public CharSequence getCharContent(boolean __a)
		throws IOException
	{
		// Read in all the characters
		StringBuilder sb = new StringBuilder();
		try (Reader r = new InputStreamReader(openInputStream(), "utf-8"))
		{
			char[] buf = new char[2048];
			for (;;)
			{
				int rc = r.read(buf);
				
				// EOF?
				if (rc < 0)
					break;
				
				// Write
				sb.append(buf, 0, rc);
			}
		}
		
		// Return it
		return sb;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public InputStream openInputStream()
		throws IOException
	{
		return this.input.open();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public OutputStream openOutputStream()
		throws IOException
	{
		// {@squirreljme.error BM07 Attempted to open input file as output.}
		throw new IllegalStateException("BM07");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Reader openReader(boolean __a)
		throws IOException
	{
		return new InputStreamReader(openInputStream(), "utf-8");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Writer openWriter()
		throws IOException
	{
		// {@squirreljme.error BM08 Cannot open a writer for an input file.}
		throw new IllegalStateException("BM08");
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/OutputHostFileObject.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
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
















































































































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

package cc.squirreljme.builder.javase.javac;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import net.multiphasicapps.javac.CompilerOutput;

/**
 * This is a file object which is used for output.
 *
 * @since 2017/11/29
 */
public class OutputHostFileObject
	extends HostFileObject
{
	/** The output to write to. */
	protected final CompilerOutput output;
	
	/**
	 * Initializes the file output.
	 *
	 * @param __out The output to write to.
	 * @param __name The output file name.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public OutputHostFileObject(CompilerOutput __out, String __name)
		throws NullPointerException
	{
		super(__name);
		
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.output = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public CharSequence getCharContent(boolean __a)
		throws IOException
	{
		// {@squirreljme.error BM09 Cannot get character content for an output
		// file.}
		throw new IllegalStateException("BM09");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public InputStream openInputStream()
		throws IOException
	{
		// {@squirreljme.error BM0a Cannot open an input stream for an output
		// file.}
		throw new IllegalStateException("BM0a");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public OutputStream openOutputStream()
		throws IOException
	{
		return this.output.output(this.name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Reader openReader(boolean __a)
		throws IOException
	{
		// {@squirreljme.error BM0b Cannot open a reader for an output
		// file.}
		throw new IllegalStateException("BM0b");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public Writer openWriter()
		throws IOException
	{
		return new OutputStreamWriter(this.openOutputStream(), "utf-8");
	}
}

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/javac/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















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

/**
 * This package contains the support for the host Java compiler to run on
 * existing Java SE systems.
 *
 * @since 2017/11/28
 */

package cc.squirreljme.builder.javase.javac;

Deleted bldt/javase/libs/builder-implementation/cc/squirreljme/builder/javase/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the support for Java SE based systems.
 *
 * @since 2017/11/09
 */

package cc.squirreljme.builder.javase;

Deleted bldt/javase/libs/javase-runtime/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: d354b1ef-6941-4a0a-a20a-cec1191e995f
X-SquirrelJME-Error: AF
X-SquirrelJME-Name: Java SE Run-Time
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the support for using 
 SquirrelJME as a pseudo-runtime in Java SE, which is needed to run 
 programs such as the build environment.
X-SquirrelJME-Depends: midp-lcdui meep-swm io gcf
Microedition-Configuration: CLDC-1.8-Compact

Deleted bldt/javase/libs/javase-runtime/META-INF/services/cc.squirreljme.runtime.gcf.IPConnectionFactory.

1

-
cc.squirreljme.runtime.javase.JavaSEIPConnectionFactory

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/Assembly.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171



























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lang.ApiLevel;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;

/**
 * This class is used special by the compiler to transform all the various
 * operations into regular instructions rather than method calls.
 *
 * The compiler will take all of the method arguments and instead use their
 * inputs and outputs from the values of registers instead. However due to
 * this, this means that these instructions are purely primitive in that
 * they must not depend on any aspect of the virtual machine.
 *
 * @since 2019/04/20
 */
public final class Assembly
{
	/** Extra call stack depth. */
	private static final int _EXTRA_STACK_DEPTH =
		3;
	
	/** Local thread data. */
	private static final ThreadLocal<ThreadData> _THREAD_DATA =
		new ThreadLocal<>();
	
	/** Unique string map. */
	private static final Map<String, Integer> _STRINGS =
		new HashMap<>();
	
	/** Unique objects. */
	private static final Map<Object, Integer> _OBJECTS =
		new IdentityHashMap<>();
	
	/**
	 * Not used.
	 *
	 * @since 2019/04/20
	 */
	private Assembly()
	{
	}
	
	/**
	 * Returns the array length of the given object.
	 *
	 * @param __o The object to get the length of.
	 * @return The length of the array.
	 * @since 2019/05/24
	 */
	public static final int arrayLength(Object __o)
	{
		return Array.getLength(__o);
	}
	
	/**
	 * Trigger breakpoint within the virtual machine.
	 *
	 * @since 2019/04/21
	 */
	public static final void breakpoint()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Packs the given two integers to a double value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2019/06/21
	 */
	public static final double doublePack(int __hi, int __lo)
	{
		return Assembly.longBitsToDouble(Assembly.longPack(__hi, __lo));
	}
	
	/**
	 * Double to raw long bits.
	 *
	 * @param __d The input double.
	 * @return The raw long bits.
	 * @since 2018/11/03
	 */
	public static final long doubleToRawLongBits(double __d)
	{
		return Double.doubleToRawLongBits(__d);
	}
	
	/**
	 * Performs explicit exception handling.
	 *
	 * @since 2019/04/28
	 */
	public static final void exceptionHandle()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Float to raw int bits.
	 *
	 * @param __d The input float.
	 * @return The raw int bits.
	 * @since 2018/11/04
	 */
	public static final int floatToRawIntBits(float __f)
	{
		return Float.floatToRawIntBits(__f);
	}
	
	/**
	 * Integer bits to float.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static final float intBitsToFloat(int __b)
	{
		return Float.intBitsToFloat(__b);
	}
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr)
	{
		Assembly.__invoke(__addr);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a)
	{
		Assembly.__invoke(__addr, __a);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b)
	{
		Assembly.__invoke(__addr, __a, __b);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c)
	{
		Assembly.__invoke(__addr, __a, __b, __c);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c,
		int __d)
	{
		Assembly.__invoke(__addr, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e)
	{
		Assembly.__invoke(__addr, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/04/28
	 */
	public static final void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr)
	{
		return Assembly.__invoke(__addr);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a)
	{
		return Assembly.__invoke(__addr, __a);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b)
	{
		return Assembly.__invoke(__addr, __a, __b);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c)
	{
		return Assembly.__invoke(__addr, __a, __b, __c);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c,
		int __d)
	{
		return Assembly.__invoke(__addr, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e)
	{
		return Assembly.__invoke(__addr, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		return Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		return Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static final int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		return Assembly.__invoke(__addr, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
	
	/**
	 * Long bits to double.
	 *
	 * @param __b The input bits.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static final double longBitsToDouble(long __b)
	{
		return Double.longBitsToDouble(__b);
	}
	
	/**
	 * Packs the given two integers to a long value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The long value.
	 * @since 2019/06/21
	 */
	public static final long longPack(int __hi, int __lo)
	{
		return ((((long)__hi) << 32L) | (((long)__lo) & 0xFFFFFFFFL));
	}
	
	/**
	 * Unpack high value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static final int longUnpackHigh(long __v)
	{
		return (int)(__v >>> 32);
	}
	
	/**
	 * Unpack low value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static final int longUnpackLow(long __v)
	{
		return (int)__v;
	}
	
	/**
	 * Reads byte from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static final int memReadByte(int __p, int __o)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Reads integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/21
	 */
	public static final int memReadInt(int __p, int __o)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Reads big endian Java integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static final int memReadJavaInt(int __p, int __o)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Reads big endian Java short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static final int memReadJavaShort(int __p, int __o)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Reads short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static final int memReadShort(int __p, int __o)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Writes byte to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static final void memWriteByte(int __p, int __o, int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Writes integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static final void memWriteInt(int __p, int __o, int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Writes big endian Java integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static final void memWriteJavaInt(int __p, int __o, int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Writes big endian Java short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static final void memWriteJavaShort(int __p, int __o, int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Writes short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static final void memWriteShort(int __p, int __o, int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Used to convert an object to a pointer.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static final int objectToPointer(Object __o)
	{
		return Assembly.__uniqueObjectId(__o);
	}
	
	/**
	 * Used to convert an object to a pointer, do use reference queing for it
	 * so that if the object is a candidate for reference counting it will
	 * be uncounted.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static final int objectToPointerRefQueue(Object __o)
	{
		return Assembly.__uniqueObjectId(__o);
	}
	
	/**
	 * Used to convert a pointer to an object.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static final Object pointerToObject(int __p)
	{
		return Assembly.__uniqueObject(__p);
	}
	
	/**
	 * Used to convert a pointer to a class info type.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static final ClassInfo pointerToClassInfo(int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Perform reference counting logic on object.
	 *
	 * @param __p The object to count up.
	 * @since 2019/05/25
	 */
	public static final void refCount(int __p)
	{
		// No work needed
	}
	
	/**
	 * Perform reference uncounting logic on object.
	 *
	 * @param __p The object to count down.
	 * @since 2019/05/25
	 */
	public static final void refUncount(int __p)
	{
		// No work needed
	}
	
	/**
	 * Return from the current frame.
	 *
	 * @since 2019/04/21
	 */
	public static final void returnFrame()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns from the current frame, returning the given value.
	 *
	 * @param __v The value to return.
	 * @since 2019/04/28
	 */
	public static final void returnFrame(int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns from the current frame, returning both values.
	 *
	 * @param __h The high value.
	 * @param __l The low value.
	 * @since 2019/04/28
	 */
	public static final void returnFrame(int __h, int __l)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2019/04/28
	 */
	public static final int specialGetExceptionRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the value of the current pool register.
	 *
	 * @return The value of the pool register.
	 * @since 2019/05/01
	 */
	public static final int specialGetPoolRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the value of the return register, for long return values this
	 * is the first high register.
	 *
	 * @return The value of the return register.
	 * @since 2019/04/28
	 */
	public static final int specialGetReturnRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the value of the return register, the first high value.
	 *
	 * @return The value of the return register, the first high value.
	 * @since 2019/04/28
	 */
	public static final int specialGetReturnHighRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the value of the return register, the second low value.
	 *
	 * @return The value of the return register, the second low value.
	 * @since 2019/04/28
	 */
	public static final int specialGetReturnLowRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Reads the value of the static field register.
	 *
	 * @return The value of the static field register.
	 * @since 2019/04/22
	 */
	public static final int specialGetStaticFieldRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the register representing the current thread.
	 *
	 * @return The current thread register.
	 * @since 2019/04/22
	 */
	public static final int specialGetThreadRegister()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Sets the value of the exception register.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/28
	 */
	public static final void specialSetExceptionRegister(int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Sets the value of the constant pool register.
	 *
	 * @param __v The new value of the constant pool register.
	 * @since 2019/05/01
	 */
	public static final void specialSetPoolRegister(int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Sets the value of the static field register.
	 *
	 * @param __v The new value of the static field register.
	 * @since 2019/04/22
	 */
	public static final void specialSetStaticFieldRegister(int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Sets the current thread pointer.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/27
	 */
	public static final void specialSetThreadRegister(int __v)
	{
		throw new todo.OOPS();
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si)
	{
		Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a)
	{
		Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b)
	{
		Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c)
	{
		Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c,
		int __d)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si)
	{
		Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a)
	{
		Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b)
	{
		Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c)
	{
		Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c,
		int __d)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/23
	 */
	public static final void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si)
	{
		return (int)Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a)
	{
		return (int)Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b)
	{
		return (int)Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c,
		int __d)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si)
	{
		return Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a)
	{
		return Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b)
	{
		return Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c)
	{
		return Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si)
	{
		return (int)Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a)
	{
		return (int)Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b)
	{
		return (int)Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c,
		int __d)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		return (int)Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si)
	{
		return Assembly.__sysCall(__si);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a)
	{
		return Assembly.__sysCall(__si, __a);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b)
	{
		return Assembly.__sysCall(__si, __a, __b);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c)
	{
		return Assembly.__sysCall(__si, __a, __b, __c);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c,
		int __d)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static final long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h)
	{
		return Assembly.__sysCall(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
	
	/**
	 * Internal invocation call handling.
	 *
	 * @param __addr Method address.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	private static final int __invoke(int __addr, int... __args)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	private static final long __sysCall(short __si, int... __args)
	{
		// Make at least 8!
		if (__args == null)
			__args = new int[8];
		else if (__args.length < 8)
			__args = Arrays.copyOf(__args, 8);
		
		// Get thread data
		ThreadData data = _THREAD_DATA.get();
		if (data == null)
			_THREAD_DATA.set((data = new ThreadData()));
			
		// The error ID
		int eid = ((__si < 0 || __si >= SystemCallIndex.NUM_SYSCALLS) ?
			SystemCallIndex.QUERY_INDEX : __si);
		
		// Error state for the last call of this type
		int[] errors = data.errors;
		
		// Try executing it
		try
		{
			// Execute call
			long rv = Assembly.__sysCallInternal(data, __si, __args);
			
			// No error
			errors[eid] = 0;
			
			// Return the result
			return rv;
		}
		
		// Exception was caught
		catch (RuntimeException e)
		{
			// Use thrown error code?
			if (e instanceof SystemCallException)
				errors[eid] = ((SystemCallException)e).code;
			
			// Otherwise set as unknown
			else
				errors[eid] = SystemCallError.UNKNOWN;
			
			// Fail
			return 0;
		}
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __data The thread data.
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/29
	 */
	private static final long __sysCallInternal(ThreadData __data,
		short __si, int... __args)
		throws NullPointerException
	{
		// Depends on the system call type
		switch (__si)
		{
				// Check if system call is supported
			case SystemCallIndex.QUERY_INDEX:
				switch (__args[0])
				{
					case SystemCallIndex.API_LEVEL:
					case SystemCallIndex.CALL_STACK_HEIGHT:
					case SystemCallIndex.CALL_STACK_ITEM:
					case SystemCallIndex.ERROR_GET:
					case SystemCallIndex.ERROR_SET:
					case SystemCallIndex.EXCEPTION_LOAD:
					case SystemCallIndex.EXCEPTION_STORE:
					case SystemCallIndex.EXIT:
					case SystemCallIndex.FRAMEBUFFER:
					case SystemCallIndex.IPC_CALL:
					case SystemCallIndex.GARBAGE_COLLECT:
					case SystemCallIndex.LOAD_STRING:
					case SystemCallIndex.PD_OF_STDERR:
					case SystemCallIndex.PD_OF_STDIN:
					case SystemCallIndex.PD_OF_STDOUT:
					case SystemCallIndex.PD_WRITE_BYTE:
					case SystemCallIndex.SLEEP:
					case SystemCallIndex.TIME_MILLI_WALL:
					case SystemCallIndex.TIME_NANO_MONO:
					case SystemCallIndex.VMI_MEM_FREE:
					case SystemCallIndex.VMI_MEM_MAX:
					case SystemCallIndex.VMI_MEM_USED:
						return 1;
					
					default:
						return 0;
				}
				
				// API level
			case SystemCallIndex.API_LEVEL:
				return ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV;
				
				// Call trace height
			case SystemCallIndex.CALL_STACK_HEIGHT:
				// Remove traces for sysCall() and this method
				return new Throwable().getStackTrace().length -
					_EXTRA_STACK_DEPTH;
				
				// Call trace item
			case SystemCallIndex.CALL_STACK_ITEM:
				{
					// Get the current stack
					StackTraceElement[] stk = new Throwable().getStackTrace();
					
					// Get element trace here
					// Remove traces for sysCall() and this method
					int depth = _EXTRA_STACK_DEPTH + __args[0];
					StackTraceElement ele = (depth < 0 || depth >= stk.length ?
						null : stk[depth]);
					
					// Fail?
					if (ele == null)
						throw new SystemCallException(
							SystemCallError.VALUE_OUT_OF_RANGE);
					
					// Handle normally
					else
					{
						// Depends
						switch (__args[1])
						{
								// Class name
							case CallStackItem.CLASS_NAME:
								return Assembly.__uniqueStringId(
									ele.getClassName().replace('.', '/'));

								// The method name.
							case CallStackItem.METHOD_NAME:
								return Assembly.__uniqueStringId(
									ele.getMethodName());

								// The current file.
							case CallStackItem.SOURCE_FILE:
								return Assembly.__uniqueStringId(
									ele.getFileName());

								// Source line.
							case CallStackItem.SOURCE_LINE:
								return ele.getLineNumber();

							default:
								throw new SystemCallException(
									SystemCallError.VALUE_OUT_OF_RANGE);
						}
					}
				}
				
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return the stored error code
					return __data.errors[dx];
				}
				
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return last error code, and set new one
					long rv = __data.errors[dx];
					__data.errors[dx] = __args[0];
					return rv;
				}
				
				// Load IPC Exception
			case SystemCallIndex.EXCEPTION_LOAD:
				return __data.exception;
				
				// Store IPC Exception
			case SystemCallIndex.EXCEPTION_STORE:
				{
					long rv = __data.exception;
					__data.exception = __args[0];
					return rv;
				}
				
				// Exit the VM
			case SystemCallIndex.EXIT:
				System.exit(__args[0]);
				return 0;
				
				// Property of the framebuffer
			case SystemCallIndex.FRAMEBUFFER:
				try
				{
					return SwingFramebuffer.instance().vfb.
						framebufferControl(__args);
				}
				catch (Throwable t)
				{
					// Print the exception
					t.printStackTrace();
					
					// Drop
					throw new SystemCallException(
						SystemCallError.NO_FRAMEBUFFER);
				}
				
				// Invoke the garbage collector
			case SystemCallIndex.GARBAGE_COLLECT:
				Runtime.getRuntime().gc();
				return 0;
			
				// IPC Call
			case SystemCallIndex.IPC_CALL:
				try
				{
					return IPCManager.ipcCall(0, __args);
				}
				catch (RuntimeException e)
				{
					// Debug this
					e.printStackTrace();
					
					// Store class name caught
					__data.exception = Assembly.__uniqueStringId(
						e.getClass().getName().replace('.', '/'));
					
					// Fail
					throw new SystemCallException(
						SystemCallError.IPC_ERROR);
				}
				
				// Loads a string
			case SystemCallIndex.LOAD_STRING:
				return Assembly.__uniqueObjectId(
					Assembly.__uniqueString(__args[0]));
				
				// Pipe descriptor of standard input
			case SystemCallIndex.PD_OF_STDIN:
				return 0;
				
				// Pipe descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:
				return 1;
				
				// Pipe descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				return 2;
				
				// Write single byte to PD
			case SystemCallIndex.PD_WRITE_BYTE:
				{
					// Depends on the stream
					int pd = __args[0];
					OutputStream os = (pd == 1 ? System.out :
						(pd == 2 ? System.err : null));
					
					// Write
					if (os != null)
					{
						try
						{
							os.write(__args[1]);
							
							// Okay
							return 1;
						}
						
						// Failed
						catch (IOException e)
						{
							throw new SystemCallException(
								SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE);
						}
					}
					
					// Failed
					else
					{
						throw new SystemCallException(
							SystemCallError.PIPE_DESCRIPTOR_INVALID);
					}
				}
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					Thread.sleep(__args[0], __args[1]);
					return 0;
				}
				catch (InterruptedException e)
				{
					throw new SystemCallException(SystemCallError.INTERRUPTED);
				}
			
				// Current wall clock milliseconds
			case SystemCallIndex.TIME_MILLI_WALL:
				return System.currentTimeMillis();
				
				// Current monotonic clock nanoseconds
			case SystemCallIndex.TIME_NANO_MONO:
				return System.nanoTime();
			
				// VM information: Memory free bytes
			case SystemCallIndex.VMI_MEM_FREE:
				return (int)Math.min(Integer.MAX_VALUE,
					Runtime.getRuntime().freeMemory());
			
				// VM information: Memory used bytes
			case SystemCallIndex.VMI_MEM_USED:
				return (int)Math.min(Integer.MAX_VALUE,
					Runtime.getRuntime().totalMemory());
			
				// VM information: Memory max bytes
			case SystemCallIndex.VMI_MEM_MAX:
				return (int)Math.min(Integer.MAX_VALUE,
					Runtime.getRuntime().maxMemory());
			
			default:
				throw new SystemCallException(
					SystemCallError.UNSUPPORTED_SYSTEM_CALL);
		}
	}
	
	/**
	 * Returns the unique object for the given ID.
	 *
	 * @param __id The ID to get the object of.
	 * @return The object for the given ID.
	 * @since 2019/06/17
	 */
	private static Object __uniqueObject(int __id)
	{
		if (__id == 0)
			return null;
			
		// {@squirreljme.error AF0e Aliased pointer to object. (Value)}
		if (false)
			new Throwable(String.format("AF0e %08x", __id)).printStackTrace();
			
		Map<Object, Integer> objects = Assembly._OBJECTS;
		synchronized (objects)
		{
			for (Map.Entry<Object, Integer> e : objects.entrySet())
				if (__id == e.getValue().intValue())
					return e.getKey();
		}
		
		return null;
	}
	
	/**
	 * Returns the unique ID of the given object.
	 *
	 * @param __o The object to get.
	 * @return The ID of the given object.
	 * @since 2019/06/17
	 */
	private static int __uniqueObjectId(Object __o)
	{
		if (__o == null)
			return 0;
			
		// {@squirreljme.error AF0d Aliased object to pointer. (Value)}
		if (false)
			new Throwable(String.format("AF0d %s@%x", __o.getClass().
				getName(), System.identityHashCode(__o))).printStackTrace();
		
		Map<Object, Integer> objects = Assembly._OBJECTS;
		synchronized (objects)
		{
			Integer rv = objects.get(__o);
			if (rv == null)
				objects.put(__o, (rv = 1 + objects.size()));
			return rv;
		}
	}
	
	/**
	 * Returns the unique string for the given ID.
	 *
	 * @param __id The ID to get.
	 * @return The resulting string.
	 * @since 2019/06/17
	 */
	private static String __uniqueString(int __id)
	{
		if (__id == 0)
			return null;
		
		Map<String, Integer> strings = Assembly._STRINGS;
		synchronized (strings)
		{
			for (Map.Entry<String, Integer> e : strings.entrySet())
				if (__id == e.getValue().intValue())
					return e.getKey();
		}
		
		return null;
	}
	
	/**
	 * Returns an ID for the given unique string.
	 *
	 * @param __s The string to get the ID of.
	 * @return The unique string ID.
	 * @since 2019/06/17
	 */
	private static int __uniqueStringId(String __s)
	{
		if (__s == null)
			return 0;
		
		Map<String, Integer> strings = Assembly._STRINGS;
		synchronized (strings)
		{
			Integer rv = strings.get(__s);
			if (rv == null)
				strings.put(__s, (rv = 1 + strings.size()));
			return rv;
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/FramebufferPanel.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 javax.swing.JPanel;

/**
 * Panel which acts as the framebuffer.
 *
 * @since 2020/01/18
 */
public class FramebufferPanel
	extends JPanel
{
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/SwingFramebuffer.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
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

























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lcdui.vfb.VirtualFramebuffer;
import java.awt.Dimension;
import java.awt.Image;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import net.multiphasicapps.io.MIMEFileDecoder;

/**
 * This is a framebuffer that uses Java SE's Swing framework.
 *
 * @since 2019/12/28
 */
public final class SwingFramebuffer
{
	/** The singular created instance. */
	private static SwingFramebuffer _INSTANCE;
	
	/** Virtual framebuffer to use. */
	protected final VirtualFramebuffer vfb =
		new VirtualFramebuffer(new DefaultIPCRouter());
	
	/** Main frame for the framebuffer. */
	protected final JFrame frame;
	
	/** The panel for the framebuffer. */
	protected final FramebufferPanel panel;
	
	/**
	 * Sets global Swing settings.
	 *
	 * @since 2018/11/18
	 */
	static
	{
		try
		{
			// Setting this to true greatly increases the speed of the canvas
			// however this breaks on Windows 10 with pointer coordinates
			// being way off when scaling is used. So this must be false.
			JFrame.setDefaultLookAndFeelDecorated(false);
		}
		catch (Throwable t)
		{
			t.printStackTrace();
		}
	}
	
	/**
	 * Initializes the swing framebuffer.
	 *
	 * @since 2020/01/18
	 */
	public SwingFramebuffer()
	{
		// Setup frame and panel
		JFrame frame = new JFrame();
		FramebufferPanel panel = new FramebufferPanel();
		
		// Exit when close is pressed
		frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		
		// Initial title
		frame.setTitle("SquirrelJME");
		
		// Load icons
		try
		{
			frame.setIconImages(SwingFramebuffer.__loadIcons());
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		// Use a better panel size
		frame.setMinimumSize(new Dimension(160, 160));
		frame.setPreferredSize(new Dimension(640, 480));
		
		// Panel becomes part of the frame now
		frame.add(panel);
		
		// Pack the frame
		frame.pack();
		
		// Make the frame visible and set its properties
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		
		// Set
		this.frame = frame;
		this.panel = panel;
	}
	
	/**
	 * Returns an instance of the framebuffer.
	 *
	 * @return The framebuffer instance.
	 * @since 2019/12/28
	 */
	public static final SwingFramebuffer instance()
	{
		SwingFramebuffer rv = _INSTANCE;
		if (rv == null)
			_INSTANCE = (rv = new SwingFramebuffer());
		return rv;
	}
	
	/**
	 * Loads the program icons.
	 *
	 * @return The icons.
	 * @throws IOException If the icons could not be read.
	 * @since 2020/01/18
	 */
	private static final List<Image> __loadIcons()
		throws IOException
	{
		List<Image> rv = new ArrayList<>();
		
		// Use a fixed set of sizes
		for (int i : new int[]{8, 16, 24, 32, 48, 64})
		{
			// Format of the icons
			String rcname = String.format("head_%dx%d.png", i, i);
			
			// Icon data that has been loaded
			byte[] icondata = null;
			
			// Load data
			try (InputStream rin = SwingFramebuffer.class.
					getResourceAsStream(rcname);
				InputStream min = SwingFramebuffer.class.
					getResourceAsStream(rcname + ".__mime");
				InputStream in = (rin != null ? rin : (min != null ?
					new MIMEFileDecoder(min, "utf-8") : null)))
			{
				if (in == null)
					continue;
					
				// Read
				try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
				{
					// Copu
					byte[] buf = new byte[512];
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
					
					// Store
					icondata = baos.toByteArray();
				}
			}
			
			// Use the given data
			if (icondata != null)
				rv.add(new ImageIcon(icondata).getImage());
		}
		
		return rv;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/SystemCallException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is an exception for system calls.
 *
 * @since 2019/12/29
 */
public class SystemCallException
	extends RuntimeException
{
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception.
	 *
	 * @param __code The error code.
	 * @throws IllegalArgumentException If this is zero or positive.
	 * @since 2019/12/29
	 */
	public SystemCallException(int __code)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AF0f Invalid system call error code.}
		if (__code >= 0)
			throw new IllegalArgumentException("AF0f");
		
		this.code = __code;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/ThreadData.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 local thread data.
 *
 * @since 2019/12/29
 */
public final class ThreadData
{
	/** Errors used in system calls. */
	public final int[] errors =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/** The exception pointer. */
	public int exception;
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_128x128.png.__mime.

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


























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_128x128.png
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAADAFBMVEUAAAAA
AQABBAAJAgEOAQoDBgEZAQ0HCgYOCAYiCA8NDwsTDw47AxgzCBwSFBFPAyoW
FxUbFxZZBiBjAjAjGyAhHh0eHx2HABh6Aj2JAB9mDCqUABlrDCgiJCEnIyOO
AzItIi0lJyWXBRaSBT4vJiY5IjFcGTCRB0svKyorLSo0Kys1MTA8MDsyNDGj
FBe1DUKRGi82ODU/NjasFxY8ODfGEBa5FBc5OzjSC0TeDRbPD0hEOkrUEhlB
PTzXDkKeHlrmDhM9Pzz1CxPWFRHNGBRJPz1BQ0BGQkHsFBvtFQ/cGCy4JCZO
Qz6aLD34FAxFR0RKRkVISkjUHlTMJihWSklQTEtMTkuhOUpQUk9SUkpVUVBh
T029M2BaVVRdVFpVV1RXV0+NR27PODeoRVddXVWuQnRnW1ZcX1xiXl3gOWNi
YVlpYGVyX1xiZGLzPDrdQ0JuY2RmZl5qZWSvUHblQHTXSUfaSk9sbGRwbWuC
aWh5bGdwcGh/bGlzdGt+cWx3dHN3d2+HcIv0V1h+eXh7e3PhXl9/f3eCfn2+
a5OWe3uOgXyFhX3mZpiafaCJhYOFh4SMjISPi4mXioWSjIX3b3HdeXmqiImT
j46RkYijjIqVlYyZlJOYmI/kg4LqgbSfm5n2goWdnZTNjarbiqGymZa5lLuh
oZm9mZWkoJ6voK6lpZzck8aqpqSxpaapqaDpmZrZnbfKoM+traWzrKWyrav5
mZjLp6K5ra3IqqSxsai1tay5trTBtLXXrce5ubD4p6i9vbTIvL3Dvr3FvrfY
urPrseXttLvXuN7Bwrniu83ovLnHx77KxsTNxr7RxcXjwMbMyrviws7rwPb6
wsPqyMLS0MHT0M7bzs/nz8bU1cvq0sjh1NXd1s/8z8za2df00s7a2tHc2svl
2dnh3tz+1tTi4NHp3d3o4trt4eHn5dbp5OL049j14fvq5+Xr6drv6OD65ejv
7d7z7OT48On08uP08vD58P3+8vL89O329u359+f8+ur/+vr+/Oz9/vT9//zR
JTWlAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAADdcAAA3X
AUIom3gAAAAHdElNRQfiChMCMARE69Z9AAAXBklEQVR42s1bf1ibx33Pc/Qt
2ktLoRlquxY62q2GUdwSY6vuQmPhViyNWyArFJNpsI7GjMXNxNKJjjC0QERS
rUTMTVFBmUrnUU1T1E6mdYVdVcRdRyKHKE5kpmFSS7FeI9JK1Y80+H1z9u69
9xXSK70Swk6fZ/cHSHrv7vu57+/73r233fb/ugFwK4930enmBoNi4rcMAOQf
TMgKmRzcAoL8YwlptPa3CgCN7MwzFhBuOFyADEDXTUJAw6SLIA99PYT24gLm
cUpvCgEAJFDTuUcSMgbC8M4zA0Cr0FS7RwCkTrAIK0FOBvghaq07A6iGDpYJ
u2eAG5Z44BzIRd/A0oeWHWUA5qG7DHp2zQJQAWHoMswlA6KewQASBNhRAvBy
CMJdswA4X8MU1EB8Wg/kWu8OdgCGcbfXnLsEAEpf83JLFGUBOcDTh94dnCVi
AO72WunuEIC5kxyP4YwIBUCGkgCggshL38B3O3kC7E4FXzuRpFCVPZJ1Acm2
nE8LQE2y2z+/tis1BH0nk0IWsXVQmkgBgEeJPOsIJ3t5Tip3BeB/709RcGci
IAxp9GGYzOkrtlUVtfv/ZxcAAPnyQBoJpxCBkAEQ2nIIAQBnWq+Bl8nCEYBv
Pz6fTsJNpEMQMgA1bREQI4+CVVqbf/zruwDwiyMhAYmQNIUAlCQyAEC1kAds
XxTJMqY48ouCAQDJek0mDf02guJxmNWMRAoCYNkFgD6zT826pFAE4OHv3S8Y
S8djkUsVHAQAgtkAoFcBigFuJFAcLQaloawu93/v4YIB/Oxrafjp2AbFtkAj
RkC0QtHm0dRKACiV6/xwkaiPMVkd9F/7GSjUC135zLb+0hFEe2WssaREuVaH
ASzCnVoIrFCbdOavzs9cKdAXgfL1cp6DDEt+qZuQ6d3LtW1rKKSBcmZHAAxx
Fg3LRBBE0xYI4O+fI7kxcTTPaj/Rg+NSqLJ7hQDkONy5VZjRwM3MX8nnHigQ
wI9/xBlBDE0zVSJPurNgddMUAN6dOQAbpliliWWawY9+XCCAl791hGf/SkuJ
Jc3pNtSUV0J6ZwDySay214S/tn3r5QIBXHn8fo6+uaRTYE6JXlLDZAJgcgLY
ED66//EroDAjWH9AA2GECgxJMp0uTbi2MgFcywZQO02JINA8sF7YZrJi/T49
kv9qk9SdOfMyScczVkzHRZSwpm1wdpVVxPTO+vsKMwPwhfUjc1vUSo08nDWz
th1mqlZMhAN6nbZHWtRipQTuYO7I+pGCADy8fodt83R5j4i2KXQwkvHTZi6l
9I5I6szpmmi7Y/0fCgLw7fU7TlnJcRHlYkgXzDBvmsptDGGtpGOF2hbR4h3r
3y4IwI/X68aK9WIz+kCC2ciQQCYAOhZJLTrYTk5t+wNn3frJAgFUETOiS7JJ
YSIDQCTje5zaEMjEIlEGIhwzXY3rBXki8LPvEXPiPFW3w6sZBDM8bjzT+KGv
tmaFMwbXHesFxUNwMsv8k02mgZc2MlQgIvyaFYNgoqf8LNZU55ECAZRoc2mV
1Aifz1xxRKgRMRHVHSetrFwWv1AQACBR5VTrUgc8J1S6iJDiBiVqlHrChCRj
e6AgAISMzh3nPfCUEMCGAACTHYN5HyQxbcK5hwsBQEjDORkQRemgWQCAEQZd
WkwCPAJrzPB4AVYACG9uxxIEUdpEpWv5FkXFBV/jucYaCOvXT+4MABCWPGHe
B+jwfFLKDJ8yxQUMuZZzsI7s/tHOjojo5ZciOocLwJApSTHM50yCNW/mSZc0
5HPrj+9UTymLcsZ1LReA6HSSop8zAiEHruVLVbv+aP1rO9WeXRz9DfEp3IBm
JpJ65uGMQACA3bPlztgSdffdlx8A0cfrcjyXDiTgaNLzYKwo50iXVjDJmRzj
JX+QnwHFOAFkNigm14YjBIeSpu7gAaRznc2g8lgRNObfHfLb7lhOY2aAFwHg
HYGFcwNpro+hEaiQP58ayPIWlCrxXNeo3LZELsLjSZIznBtIAxBmQbmDopR5
nvryFZSIed65buRcQdkcHAjwGjJDY7BpANwQsdAu7kjDfHqvLs5jgjTvWmI5
AVSOQ+0S/3wmzG3dELuivKuBKJufz+HJg5xuhItBHg1gsAZSWzkBKNqhbZY1
A4TVGOQAbEGaE7u7C2p9cHE+hwT8nImPFOesSyXoKDdlHmdWBv1YCxFD57xJ
Dni4kk1rH3Tooa9BbGA8EofeRS6e5GABMYAteJMSZhhC36YHUaaDFTsibllO
coArGPiB0e8bgIlKpxiCa9TmltOVr7hMuFjfFs/Y1MbPpxWk6HGCcELlKtJC
RNxpSwLg4td4a8hA9/hga72oF6FR5mBgl5ijcA9KGdqNfXuaEdIbZ6+meZna
SnelBhpMiEfI4D16DkAcGySky2xQDVUjSExiGTVNo3Rxc5hdjvhBF6GGrgR2
LCk3GKdOn0/tc9oJTQL21kLfIOqCFh3UcH4gDvEWwkXSUOsf6Qt7e8mQmBWE
kM2eZ6sbelIMAGljOcmuaCOVYJ59OmnkUTWhCuJ4GIVNiO3zUZjow0kwFY9i
AMMokAeH3cPDsEtxVLSIFUKxe3I5hxqytTcjVxKJbNNfnUx+ni+rV2vdMBiE
5DxUrlAxJ9KXTh6AF+tAJfrrrfa3q9yePtIuhsAe3aQC3bS4DEApZN3YRkoH
ETOGApw0wr2l885SrVodtMtK5dA2Rm360M6llYsFccci9rFRSNdrFLZxRUij
KhXzx4whQVHmE+IyAK0wYeBUIJ5M9qbOcFi8UoXfZTGqLM4+KLeAcKIRdRpB
HEBuI4AAG9kYOIPM3641zmg67Ypwa6tcLCsI6xGH22LQK8YBFfTZEEfXeN+O
HOLKKKeONnKEP5+inaE5unQG9iBvjPYOI0gMqH9M50MP+4bhzFF3GI4MNDjk
bplULSYEp52iTJOQEXHHxDh0LyK2L/FGgKD2r2EGzKSnqYkw7KlkFgepTVUC
GtGDiwjAMMtvqR06O9kP+rJqp0zXQIrubkcuUYGma1CRDYA0QIeL1XvOESPl
sk5iKAaSdWxMPILUYzOGuBMinEzdGnXKCV0aDCAyEOJSlagLm5+3q2RqtIZA
ZiWS0agpasyKEuRsABZoYwFYuXwH+aOOQAzTX8bV2pXTVtPstDWAtv4NCqib
oi6NwyjSwksIVm8Y0s4ynJBg7d08q2wbUpYVaXiHwsRSCqE/R612bC1ne2Ny
DlociO4sdgM0KyqWAQ7kepFgAktTg10txyasU1OBuLvIF0Vq2A5hA4MBdEWh
T69IqnpkacJk6q6S1tQRKj45olcvJpPMRBdSw0siJ85IBBYLjAQmWQ6Er6Je
a8gHeBAuxJYzHQRXiQf1psmlSG0nHFygpv2wz4ddN7IG58AwT39z1jSa7F3U
x+cG186fjvBc0FupqSmYfYZI6uCiEUZWp1k/5N2kzg6iIBNF+QcCNYSm+sOP
fODd73wbmrR/9vQl4Pa3Ua8Y4IwRMsgOu8JwXs6lk8zGlLUc9Xr7O979ex/5
XQBKeUXYWpnlzTvRRq22bcmyABAj0K2HkSWcbSwiE1hCnBhooGF8qQZ89Bv/
8dAnP7Znz57b3w6AzLTU3wCVZ6lR6EPO+DxFHQ+F5qVcSI7NWotA0Tvfi/p+
4t6H/vOPAejjVh5fGQtwXmX8aarxqjpLCUA79A8jACwHwqeQrSCHaCf9kD5T
/tF/u3DhoU9+6q7Hnn32u3e9qwjUmV4hHL4O6hkfRM5nAam1320DPizsM2YC
vO32PXse+8mLP/ire//pwj8WlSq4eB5bGuKcfLCDGrIayOzLApA+inpNsqH2
IrUwRDEJKWLr+apvXLhw4V/u/dS9P3kRtR/sub0IKBdGy6NIC/SsEpyiqFmv
Yw5gMletJeBtaPnfRV2f/fm9D/3XhW9I2ls5HsTODlExGil264p5yC7JDkYJ
2A5jK2MIgJ6iBk+jf9U0jP31f//yl79585E7/+TnL+L2ZRbB9NUSVaSFstIW
AzxHUQsui547XzjfAd7O03/xxZe+89kfvvmbf5eo+YLfpnkUBS6USY2tNT6f
bYfAAzvp+OogAjBOUY2BeJRVoIu/uYHaG9+58yvPvfDCC2jWx/bseReoumQH
yxMm6hTyBKE16hm7UVuJVXABFL33y3ftefZF1PmFl3746UfQ4GfIkSi/dR9D
AnZBFErqLom4Qj3UeOhANzLDYWqthaJ1bGZ1maV/48r6V5sPfPxzn/viX/7t
XUi93gHMUCENNwUWmKMheJq6OGdU40yUVoLb9/zgsQ9/nO37xUe/ggHcOE+q
k9WLjrObjiBsW+l+PtsRADm0GxiqDQFQUU8PbTKVbHrtwgDWH7zz7sPvwe19
H9yz52NFSpgo7Ts1Rp2zzEATFdAZB7Afikl+B9nKB7me72k+tB8DuLFQquZ8
Ymy1cS2ihSemxszZGyRAJMJH4WYLigXHqMnp2DLJqpX7IjvDrx/cf6j5Q/y8
7/vYJ95ZwR7azylXlhKdrBZq5ro6ccYBPvCJD7+P73fg8wcPcABMPmkXp4gb
s/3UnNvXYR4TOUYmHFDGRFC2wyip/tNbA/jwmnmCneHNRw4cbj7IT/z+Q5/6
C4BWpCHOKalzKn94lRq1teIkTFP0Z5/lOfWeDzUf+vS+b2IAT0C/VJbgYlzb
6asqWLfUL3JuQByFw8uxMRN1rYNqW6VJLrvXvM5O8c29+w82H3w/O/Heuw/t
/wm+ltFQccJ03jsOzdTUohwXFoZ+/18PNx/mujXfffjAl15iB59BPipUXctV
dFYaA8PB7rNtTUDsroFzhLYOUVttVOOGu5hjmhuz4MqD+xCC5sP79x/8/N0H
n3yzAldCymTK1XO9tImyuutxbfNv/vzNLx1qbr5z//5Dn0f09z7yJju4h1WA
YGU1ikzR8Mbo5Dnt5GxLh0hSRBroeriGXGAr1RjZjm49r7KTfOeeffsPo7mb
mw8d/uobN7qwUoXInsGAw+JbW3FX41g0M3Fjff/Bu1Gvuw/deWDvg5gBZiOX
lUurUebmiKzVBBTnBlu6xbKySkbljiA97VxrjPWN8Busy+1YC755z94D++88
fPjwp7/66xs3prFAt7zk4Ox5FWOmnFIMIDh948Zzf4p77d+390s/ZUe+0spZ
QNQhlbohrd+cmDzuamnLvs6BQhih1baf6h4903O6KV6vTVZaLMcxgh/+3d69
+w4cuOepN9C3yzhpiUMn0b9yzmGi5vkUkLWZK48eOLBv3957HsXr/5XscjKz
95dIfdBxwlo12lfV2AJS99vAdqv11/umuxcG+qv0xXK9xcupgaEHK+IbP33q
yae+/2us1wxO29HjeaJ/TRu6uFCNdYC5jp/+4vtPPvnUS1j+rzTw52601zBQ
D0q0c63mjkl5XUd3imq6K1g2WK7WUY6xlgTQwvD8sN5gQ2mereHMDUG77qKT
ZWmLZPSZRev5Wmy0Tnhd2HFKzuZEIZtOrXeFDbVoibT/2FJbvbJf/EYNUR9t
jXcvXepoCYEZRqXyJtDgmZnl4JDC9HqKPEzMMShP4vawFnLK6lptwGboRdvv
FIRXJ2QGmlmembGFos7WOTjCSrkXqs40KQeVHeI7ZMI27DYNRerbgsBhawjP
c1HEazQuzx8/PvqEaeHitevJ7X4yy7OXPH3qGWVnKvO9/qvz1tmJoWNDLsZj
NGJV8jl9ZSEVioAEaQl2TCIGNOW4dyP190bqqK5uN7AwnpFUYu2dtwkvrqTV
cp3lZvtsvUhd1Da/XTJUG/1cYYIgo30LTd3dNbnKJDq1e9B6otvJXkFpTd9e
0Q5bKEfdxl81OSvN2gHYHGnD3Si5lAPMZIW7v0nWVpXzmuJy7/Pdz7fNAcRT
GRQWvNz2HBDCjYMVGeTtglPncLAX0lwABMRiw1BNS1XOUplcs9xysXFcglIc
RTCz2uNxilei6Z6S9LIM7fQIn8+70M6viKdQph+taqnIfWBhOGqeUPdIwbLX
qMu6rsK4sVivZ/2uZZl1nfvd68wsEmlGnAk1mXQ7491VLaV5jkx09pZTMgWh
0DMDIiW/qCeMbe36dSGK69exhSJ2e6JZg47p3IvbKQgg22payDwF2/q+6dla
FQEU0DkcFak8+/0pa7+OW9LycTzIHuFFe7hFGZlaoqKuKe996QFdd/8xkgBh
uoHmNtlCySeCiMU3shq7fCYotFY80BBsh8Y0lwvIxjqQ99xqYHJKjryWne4b
rtfr9Qaj0ThjNM5phy08d8PsxNnkIcOZjX9G75qfw4OMBr1WplB70quTaHdV
tcOl/eODjWUANBicDbp5elukl/UVA7wZ0My23LepJ7fnkC6Va130dgl/QK9O
uIrTow5RtcNNDqJsqBFFDiIKgwmZX5fGfG/U6Qznv8ETdjrTjt4ZnX0gREMb
kX7JHpDkToeH5f1tktskLGlvg9wjvLHjw2qeVY7l60hen+CZvlOOi6NEMvBj
AhJyh0v1gKhvKwGgmK35+Kpro4JTMVbTUTS0CqrY16zs3pfxB1O9sAFUsqU0
OEcAwbsGBLHT2wiAaFMStxENrCRpTes21138aoMJesIc2V4pEzFP0Lx5oG/L
2/TrjVnnNADfdtzxfRBANJHoTy+e0atJevbtiw0J5qpy9FW+phl7dVR5FRHm
V+7hAdD28TCXjxJZLN75dRRAIlsFkk6hXev9aQflE3VTr6J1069O102kXxvQ
CF2ht4wo9LUXwe+ghNVcojL9GDBo7PL6gwmG5/va1ODs1auzg1Nr29JgEkGf
zL2cqtQyxiKi0BdvgJg2EEDFB2GvzeGF9emelonH47On0R/hjTEkJ6/DxgH3
1Oe6c1zw+0GgmC230RYuuXLUCmWyNbuQEaEXKxN8ImehnXJA3NJbTtuvMzVo
koYw0CqUcCKDvqs0aQO0saLolsinq4OSVCRVu086t02TdhtPTNvnUxL3q0gH
/2hGWqEE4K0AwPqlhdVBSTtPx1JNtg8bjIbxPlmneXPM9Por4/JWtc5o1A3U
E0d5HXHVlk8GasBtbwEEfE3bRFErHRIdr/5uvapT0fbEGbRX+NXELLtjeMXa
3ne0V2PkMYa6yLEARYFbfdOsop7gxpPn2JMMa4UszQ3gTSsCwG9ZhtL0wFHa
ssIOKL9VBKQcX6oHRGmErQlTa8qS1FZBhas3r0+aMYAzqQe0isR3aqnICayD
gCy76XfNanvLCJIkatky6BaLYZpI1uChh9s1Ty/gXeixbcUMyyvYW82RLSQr
DXvfnGiovEkmIAUK0s4ZS9IXMjGKOl3elXQEnbh0YV7CpbjtpMEnbVqlqOTN
cr9WodCFiZt/2S3jVhmCsFIj5x2Bp4sl/QyG0Z50Dp7S/gAVESYLDgBu8mU3
1DKvNW1trDXVJ+8iWBHpTVYCTyS7uSSD1EbG6X+4GhA3o4rcWxKt4xlpNgpB
bZWctSXkfN3AlGSUXTJBZVxloi2qMuJmjIHrT5AemJmYxwLKMi4/iKpkx0c1
x2W65GmIZDbt7J9Ouk7eH+8SAd+bIMZZpVv2CC4tDkl4mgmfe9nPLznYVWJN
v3uQsLAjXZWpdOwm6LNOgJB11joyLtKaK8hjljTh0B6DgkDeR3D3IdqqaJem
p3/gJuhzylhcZmGE9zgDZmUVkFTJ+3S68Z6GMlBUN7SUcffC30Vkaj/YnQII
EvVqS3rc3dpkHeNZ01hjS0dTx6R5KZA6deb9wQAoBoWmYoWkK4Ao0/rTkyHu
xRe06uSHtOPJhE0BRK/r3FJoBGRRvc7DpGGIoeYy+mn0IZ4y/pClVyJ5izKR
LA6SgJQPzy17g9Fo2OeaUzcQBAmkvXqHJxhOhHxuu66nEiVQvxXqqTfIyCKu
xCkhuWCJcJH8UWkx+dYkQQX56dsK3W3s0P4PGU257ClnlmoAAAAASUVORK5C
YII=
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_16x16.png.__mime.

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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_16x16.png
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAAftJREFUeNqkkT9oE2EYh59LIoZrhztSIRSFLgVp0CISkcrhmBPK
ZZIsDiqClyWU4CBCMHBydMoQkGSQIFghWY+C5xwqUnAwYpaidApKhwtizqJc
ziHcR46M/abve/883/v+flIYhpzlpAB2dwooshqOfe8q8CVKKrIa0aWx70Xh
K4qsDgDJtLskosLC5jaKrA6CabAVxTRDRzN0gFCRVYJpsKXI6qCwuQ0QAjMA
wKk/wbRaZJZXDqKfs5cukssXBSSzvHJgWi1O/YlYQQDS8hLtWplSpQqAZuhk
stcByOWLmFYLzdBp18qk5aW4BgDvP+9TqlRRL6yL5N8/P+nYdTRDp++4mFZr
VuvsL05QqlQZHQ/xTo5EsmPXefisLt7eyVEMFAOMjoesrm3QazZiNk1+/xL3
XrOBabVo18qLK0TN957USKdTvHrxXBT1HRfN0Mnli7Rr5RgkMU9/YL/h3bU7
TD95mHZXxDNvP7D+7zIk1YUJBEAzdM5zbibe7Vuw1+GR/TKyEAo67HUgqQqn
5leQ+o4bAtz9dggJGcKAVDCzMPe9CFISpj7ej0N6zQalSlWKaaAZuoD0HVe4
Mq9PqVKNNQvA2PfoO25MsLgbrmiOOWJ3kcIwZHenwOOnVjg6HgqQZujkbt4H
4OvH17H46toGgKRmb8wAZzn/BwDHnNKkHmibPgAAAABJRU5ErkJggg==
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_24x24.png.__mime.

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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_24x24.png
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAAg9JREFUeNq0Vj1rG0EQfXsIB0N6l6muCHetYDGoVyVVJimFEsKp
TyWQEQj0F3SVMSaFCaSQG7t3c+A0BilOELhXlSZBWBBPinjWc3tzJ9mQ7XY+
3tv52l1DRJhnx/AWATB4+sr5RbaDQDOK6m02LgPBtn4+AQU3d//YdRLaIMeD
P5URVJ3YgfjyKmeV4Obkc4EkjK3bCCKSe8WvPIL51dQHyy0pn19Nnf1WBPev
X1SC+0Rsx36VBBr45dlFIbr1aqlG5JMEZafyASR4GFvs7O5Vpk0jIAm+mGVP
mjClZiQJiHPJ4GyYDnpbEYSxdamTkeRS9BzwdNBDOuhhZ3cPYWyxmGW59AYa
ODs1Wk00Wk0AwNF4qKaE9UxSWgMJzo4fD7/g1f47JONT9fTf3hzm9Omgh6je
xmKWuc4L/HAlePfHNV7e/wE+HaHRaqopY/306+9cW3NkTGBY2Gg1EdXbOD8/
AQD8fP+hACo7jPVs7x+ipg0Sr4Pb68ce94YuGU0Q3eb7PhlNCi1eE3qj3Y7r
1dIVT14Lmt6LzvgEhWnlzklGk0L4LGObbn/I4GbTVWEAmMUsQ7c/dKdcr5Zu
3+0PnawKHAAMEWH967tWSOIJlTOQjE+R9t+6PXdLZDuGcThNke3oKeI6cEEF
iCORH4XLswuEsXUPvnycapsedUkyz44R2Y4DV7qv8BsxRIT/uf4OAGHvLPvd
pD6TAAAAAElFTkSuQmCC
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_32x32.png.__mime.

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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_32x32.png
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAB9pJREFUeNrEl2lUlNcZx3/vvLOxyDqRQUUiRjQoRcU1CCrSNi5F
ibF4Yt2jYqqmxeOSqG2OqWlSqsF4mmNda9sTRRv35YSoKNYlCgiBsoggIALD
DrLMMLy8/YAzzITFfGqfc94P89zn3v//We8dQZZl/p+iBNj/4UKrQqPztjAS
TNXlVr2p1cjo0EnofX1oN5sBdgOxwC5gu0qtorSgCF//iXYAQ4MiiN+ySPZw
dSoNmf1Ln28TDlnXYj450UnAFnz5+7+jICuV5GuXZI3OuxsRAHObcf/wMTPW
5DxI5caZYzj2c7Wu+fpPZGhQBADxWxbJfHWUZbGbAAad2PupEdB2i4CtpMXt
Zeym9/HU66ipqLYQEUxPn/yokFrA//nZ2ie/eGc5nnodbjpf0uL29miv6CH0
pMXtxU3ni6deR9iM2QCyi88Qy/IxYE1LYwNjwxcyLWrxtubnDbttDz2+e0Pu
5Dfnv2oBtw0yUNMjAYBJ7iO6Mbzw1VEaDJU0GCplQDa3tS7x9Z+I58AAkOoY
Gx5NxIIVsc2N9buAt0/u3Zg5ISJyuC24xfupw6YDuPSZAgcvb1oN5cR/uA6A
hTGx6IeMAESeZCXi4jEAd70/SKbODVIjQWFRqNSaDxPPJFBWVkFZV957DX2v
BGzlV+u2oPPxA6kNRAerviDjLkNHBXcZSs8JGB9KfVXFbbO5LWTkhDAOf7yZ
wf4jM4fSL9DiWJ81YJFvcpNJLk9hWex2dD5DQDJTX11sXXd27W8PbiMqjTbE
xUOHztuHyBW/fVhT8Szwkbouty8nFT0pV+6Ix81rIEjt1FcXU1NRDVIrji46
ntdV9HqY1tGJopzvARgWNGHMT6PfJXJl7IibZfdJMTwsfimBm/lJtba/LeCe
eh0Az+srEBQiiFoeZSRS8J8bIHa1deDkcKJWb+pqyVHBlBfls3zbbmrKS31v
5icBNPZYAw2GStbu+LOHxtEZZJl6Q6EV3FLNokKJSq3l2eM7uHoOwmtQAEjG
vufCqGAKslJZuSOeI7ti0Tg4vjwFtp7/oI+7SXlJJuUl6QCk3/qWMwfiup3l
qdchSU2s+v0XtJmM3QkYJVEGUIgqclIv2oXd/rAaBKGTs1KlpbI0B1lqx3vw
6F4J2jqgdXKuEEWlB9DSLQLLYjehcnBCoejMSk1FIc+epGNsqQfg7ME9NNYa
EJUqOwBR1fVbVIp9kniceU2/aON2pHazQ8wnJ7qnIC/lPErlC8+FDvoPHI3W
0Y0LR+MpzstE7aClqaGRWkMVotgdTOPgiOFpIft3rOXC0fhu65arvwMF+zYv
6LkGPPU6ZGoZOGQity6cYP+OtQS9MYWYnX/gea2R45/vxFCaj6hU2+17cP0S
uWl3WL51Oz+LXsKzwjzOHrSvB69BIzA8zWbxxm0Acq+TUFSqObnvI5oanxO5
fA2r1tt7M3JSD5tkGUFQMO/tDwDQ9RMJoZDTf/2MWYt/TXV5Hjrv4Xj5BPD0
cWrPXSCqOvmYWowICgVR777HqvXxXEm80PktieJK4gV2H75PY109zY0ttLZU
8iQnBWdXdzIysq12//j6LPNidlJZWsT5Q58z2D+MqrIcAHxeC+69DU/v30PS
6TO8+c5y9L4BVn2TQuTUto9oUohsXRPB11/GodJocNf5YWptBiAoKMDOTj/Y
nxvZrdRWlfGvL3fhNzKC6opHPc+Bv+2Jw9jSDIKC6HWx6LyHISjUXLny985X
0IqVzHz6DPOKlYTMimT0lOlk3UukrrqQkkfpJCYcwsnF3c4O4Pipg8yP2UBD
TRWn/vIxQ0dG9JgCwZZVcX4GJlMLCC/UUh3uhw7g3CHhfugASo0Hb8yMxMV9
APnpWai1GgInTSN8/lI7O6Q6BIUanfcwFrz3G9qMrX3eBcLVs1dpbDYjy3Jp
N0upruuTO1Bq3JkQMQt33WByUzNQWuaBrR2AIGAytVDy+HtMrUZZEAQUNi2s
BNCKEkapS9luNlonXq8id6DUuDEmdAZmk5H6mro+zQVBwGg0Cvs+WN1zBLSi
ZE3FnWv3Bz1MPoWptQEUIpeO7eOPMfMoyOrK3RebVoDcgajqx+SZC8nPeNCV
wrxMPl37FucO7+kEUYiY2zrDr1KKOpVSlC1YCsv73DIaXywID5LukpJ0AoQO
Xp/wOs7u/TE2VYLYeZttiDvSSeIFmQ1xR170sgPGJgNObjoCJweCAtJunuS7
q/8GEMztUo25XbI6Lvzwn1H8lkVdc0Fuk8dNC8Fr8EAEQeDW+cuMDgnnJyFh
IIrcvXSOpNMnCYuMYsrcBdBuJvv+Pb67fpmp8+aALFNVVsH9a7fsCn39n07R
KwGL7Nu8gDlLo+WLxxIYGzaJAUM6L5T05LuUFhRhbjMSOnsu43++mrRrR7lx
9hRqrQN6Xx+Cp09BlmUMJc9IuXGbOUujAYSLxxLswPsk0N5aJD8tTKG8sIrU
W9cZHTKeQa/50WY0YWxpxs1zBL4BYV15z06mviYXraMjaq2WsifFpCXfIzg0
HG+/V/DxGwcgKB1effmDBKnOjlVwaDjptx9QkvfY5v0nUZydbAV3dO7aUvq4
0Apu9/xSu8rW9uyTAAhKtavg4zdO8PZ7RQCE4NBwYepbW4XhwYuEoux87n1z
mXZzGwUZV2k3t3HnykUKs/JITDgnhM7dLFiKuYfvx6XgfyX/HQCsB0HM346M
yAAAAABJRU5ErkJggg==
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_48x48.png.__mime.

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











































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_48x48.png
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAEtNJREFUeNq0mnd8VVW2x7/n3HtuS7kppBfSSEJIQiCGYlCBISAW
bIMi41im6DgzdkfF8pRngYdt5o2OYpk3OCKgCDhjoSmhl0BCCqRAIL2H1NvO
PeX9kYAEQgR9b30+5/M5n3P2Xnv99l57tb0FXde54+pc/p9IAmTAH+j7v2b+
8cbdiBfZ9kOgF/jjJfAXgVMjNdBH7n8XkH8xg1wMGQG/wRm9GAoBWgHfHyn8
L4F3gauAL38qgHeBOydFRpeOSUi4E3jpIvr0AqPe/PuHp4Xt0weF1ocRfphv
YRaLpfvO9IlclZQcD+z+KQCyU0LD92UFjEq6/fp58YkpqTOBF0doHwmUAoSE
hZ0WrPISVO++sMio+X968CHRpqpYzBYFmPBTAIh2oyQlXjfHmnDlDLvZYtaB
Zwef4agfGPP8a69WAPzHsv8qB5KBYiDiB8b6DfA66IbEqbmhST+/gQS/gISr
MicWAlt+LAAfj6qqlqAgjD7+/PqBP8Y+9PSi4oyJE2YCy85pGwdsBRgzdmwq
QMq4cWOfWPxCCZA5CG4kyrHabB2PPvdssNHqgy0sFBOCb/So0FDg8h8D4L20
0fGNE6NHj9YUBdAIi4iIzsnNHZ+Zne0PPAA8B6CqKg6nM0gQhJyHnl5UeDaT
8Zddljn4+jVgGWacu4FdMXFxMc8sXSJGxcbGgYamKCCAoihewPljAFw3OjQ8
xG6xhp39sfjgwZJP/7EieFCYHFVVGTUqmGtmz+rq6+8nJzd34rmM7n3ooQPA
NKAI2BMWEdFosVoOA3sEeCMiMtJy/+OPp8clJsZcii8w/pD+97tcHkxWAHZ9
u6Vg/coVSltzS4rZYm4bM3bs9qMlJdfouv6FzWrtuCx7gjAlL68UyDiX0VWz
8yZ5PJ59LU1NoqZpxlGhIZFOh0NxOZxy/ubNPakZGf2x8XHZl+rMRgKwOD4s
onRsbFwKPb0cKCwsWL1+XZzRaOzPnTGjJO+6ayOjR4++7POVK/efOHYsvLej
Y56mKHpDVeX2jMtyhmU4+/rrppzzKRaI3bXtu8Pdpzp/lDceSYX+dNmY1Niw
wKCYkobaA6vXr0s0W6ztTy95xfO7xx6dnpiSkmy2WHyunz8/1eN2u7u6u6mv
r+tCFC9ZiF/8+teujvYO8aUnn9pRuP9A8ZCfgsBIPEca7ZS/j49PSUV54bba
6mSz2dyyaMlS42nrcppKCwtPdjS3XJmZNpa6+oaWuQsWTr9UANPnzJl604Lb
LGXFxan//corQWeD0GQZSfEqF5J1JAC92w8fOvmvwn2xZqu18dnX/mxKHBOf
fHaD+pM1lWtWfHTKz8+P6VfkIpktIQCaqtJ0/Bgl+/ei6xcOGjqbGqk6eKDI
2d1VNPmKK3KeWLy4VRAE75svvhj1zrKl+WXlFQcNZjOFVeWxFwpjRgLQcby1
eZrZYmlf/Je3fOLio5JAGNKg6GCB7urvy4uLjab6xAl8fH1DTv+rPVLK9n//
C03TvmfYUI8iywPCNzbQ2dRIf1eXze1w9AFMnDwp40+LX3CFR0Ud27c9P3n5
e8ujtpw4Vni0rcU+4OAuDYCvr59f2UtvveUbFRUad67wAIHBwamx0VFMys6i
oqICgyig6zrt9XV0dnaSMj4LcVB/u1tbKPh2C33dXQAcO3iAwPAIJubNSQmK
ir7yNM+08ePHvbr83akvvPlnlyAIjqMtjROBbcDiSwGQC4x9YNFT5vDwsJjh
hIeBr15Fwe32IEkSiePSURWFqoL9nDh5ktnzb0MQBLrbWjmwZRMuRcVoMgEQ
HB2DxWq94OzFJ8Ylvvr+exKiWC4IQtKgTBcFYLKiqpsNRmOdJEnqxW5EAZ0p
s2ajqyq9fX1DIFfu30tlZSXz7rwbv4BAAMZk5+AXPGpEjmHh4aPf/miFvwYK
sAOY/EMAMlVV3R0yKti27J2/mZPT0lIvFsDpzdrbdYrKqiqi4+PP/HO53YRF
RSO73QDUnTyJo3/ksMjr8eDo7sIkSVHLP1kZAELDIIgLAkjVNL3YIAqGG6+d
i4/F3AfgcTrrHT3dvac33wVzR5OJ1oZ6ju7ZhZ+/nZt+9dsB4fv6KD58mPn3
/g6bnx8Azz38CFVHjoycUHS0c+jbLZTt3C5LktH7t5X/9Nd13TAY2Q4LoFyS
DEzMSEMUdFR1QHsKt25qPfzdVv/O5qZhsypBEBAEAcWr8NU/VwyuxoDl0TWN
om83IxmNuJ0Dsdipzk5MFgsiOorXe0EAwVHRpE6eunv/3j19ZfnfOgRdPyXL
chtQPhyAEE3T+rMz0jCbzeg6XYIoGhRZ7hJFgzkuPTM/bHTc8Evt9eJ0ulDU
4beLcI4XfeHRx/A4nXzz6WrqjlWNuAqh0TG51//yrpaS4pKE/Ru/Fj7buiVC
19GBUefGQm0GUUSWvUyalEXO3Gv7rL5+Y3evX9sUn5HZF5mUPMS7aqqKqir4
2WycrKnnRM1qfK0WIsLDvwcmyxiNxiEhgcftRgdun38TXZ2dKIqCpmlnTO1w
pCqqouu6MzAwwCu7XR2yLFvNZlMrYBiiQjkTMjCZJFRNQ1NVWdc1ta+vTx5E
PET4oj27ePv55zi6bzdPPfYgN1x7NS63G13X0XUdZ38//7NsyZnZNxhEJLOZ
J+//Pc2NjSjKwGp9s/oTqkqKR/TW8amp42cvWFhbXFSUuHPd5+7Vm76xnlWy
+R6Aqqhkjh+Pr68volEKevfFxcVAnNliGRKxfv7+cnZ89SVhYWEkJiXhcbsR
EOjtd7C7oJCKo0cxGo3nqY7BYEBRVX65YD4ho4JJTEoiMDCQzWs/pbzw0Iiq
FB2fkJp364KKmpqTfqIoIsuyCDjOM6Mmk4miwkJMZpPZZJQC0iZN2RscFZ0N
sHvj17z1H88gahpTpk4lJjYWxetF9nqJjY3m9vk343S6EIThnd79C26noa4e
QRgYUlEUklNTCQoKYsu6tZQVHBjS/lhpCZ+8+RrVRYcABKPJJKmqaj+08au6
NZs2aqdX4MzsigaRI2Vl3PX4k/L+r7+q1DR1vF9goEsQReN3G9ZRemA/kVFR
REVH4VR0/vrOxwiCgAjMmnkFIQFWurp7OFR6lKy0FPTBGGhAPQT6+vq4a+F8
goMCz1i4qpNNrP9qJykJEWz7Yj0Fu/dxz8MPApAwNg3Z42F//jZ0TSMpOyf5
2jvuLN+4amWqy+XsGKw9fb8CBlFkf2EJf33+uVZV9mQChsJvt4T0dXftRBCI
jokhKioKg6+dvzz8HJO3NTPhuxMEfFfJB59toK3LycJbb6a/34HRaMQry3z0
+qtDgFitVsblTuOyOXPZX3yMtz/+lIDtx/BdVYBa0Ybc28Ez99/P159/jsFo
JDVrAtkzZ1Gwa6e+998btkfFJ4wFXTCIhpDzMjJJMuKRvSiKEnOWdw3dumaV
b21tLXFxccSkpmMLi+fVl5ciLP+A4IW/wHrVlaz9429YsmoDd187i67uHoqO
lJOVlkpfTzeSJA3x1mabjVeeeZlPt27nkUA7dxzchOdwCU0r/o4nZAbRKZlU
HNhHcKCdyTNnYfXxwePxCKhq7qtPPH6i4viJhLOt25m3wtJyFFXhXBXu7e21
RYSHExISAoKBYHswQvUx8o8epv7DbuxrVyIdqeCu/n6alJ9x2y03smbdBtAh
a1wqZaWlQ0JqXdPpsflwe3U1vjYbnz38B3ocDiKqjzM9ZyJj73gWm9XCwfxt
6JrOlFl55M69tnLfxq9TzJIxIS46kp37Dp4HYEZfv2PbcOZM13VsNhuRSclE
JI4BBLorKrD09kFxKRuAdOAaoHXbTnLXrUR2u9nwzWYQBNJTEtF1kL3egf0g
WvnZzj0EyjLfyTKHdu3mCsAH6CovJ8Tqw7Rr5gEqxXt2caq1mabGpsg9e/Zx
xZRsdE2n3+E842NO74F8URTnAN0XCtQsNh8O786nrqaS0UuWkjB9OnHAvEEA
ktXGnEWLCI1P485HH+H6vJ9RV99IWcVxDAaRjJQxBAcFoamQ98STWO12koEb
gCQgbupU4t94k6aWOg7mbyY1IwNEI+s/X4+PZPSbOf0qDpUcRRCFIY7vbBu/
GXAPB0D2yPiPCsLib6Wu+jhaTBqpH69i1Csv49q5HSU+DvutC7Ddeito/Rgk
nbufeBST1cKGr74BQSBrXAoesw2rnwnDDfNIWP4eQWtWYTh2HNvl0xi16Bma
bAINpXuIjY/BbLEwJimRfoeD/YXF2O12enr7T5tp12D5/byySrgkGTGZTEPs
uSiKeJxO/IKDGJOeysnKKrZ3eXCnRhFou5KsW2/FNC4dXe3B6+lC12XM1hCu
W3AbCAJfbtxCuSTx8/sfwCDqoDkInJeHb1IkJZ+tpT0iFGtlAf42gczJE0GT
EA0SSePS6Xe5lNrGxpryyqoku7/fmUgF+Ow8AKIo/vZEbeP7kREn8coygjCQ
IvoGBrRbbL4hksmKUZJITEsluKMDQ/pojJqIKXL04Ab1oKkezNaAgQgxNo5r
fn4LAN/l78BgNOJw9GCz+SKYDEhZ40gM9SVG1EBV8fG3Y7b4IQgDlssWGIiv
zaYnj45Jam5qXQo8ZRqwasKwhS1RED5o7Thl2LFn/+LYyPAwk9mESZJwutx0
tLcRa7cjiCYEwciosAgQQDRIZ02AhMlsRxBM3xf64xO5fsFtBERF4+fvT09H
K4KP/5n/9ohINM2LrqqIRguCaARdBky4XC6MZrMMPK8oykqvV3mqurYeQRD8
LphSmk3S8pa2Tg+CQHtbOx6Ph5aGeq3y8OHWgahSxmwxYjT5YpR8EUXzmexA
1zwIwkDAdzaNihnNTQsXIggCASHhKF4Xuu4BNARBwmCwYTT5IYoSmuoGfSBP
aG1qajtaUqxERscsEUTB41WU92sbmhEE4YURk3qz2fROe+cpd01NLS6XE8Xr
9YgGQ81AhuYZyIA1+bwcVlE8tNYep6a0GNmtgGAe8qgK1JSV0FxdgaYpnFss
0HUVr8cFhgHFMBiNjYrX6zWbTOi63ioIwr2SZHzj7ArFsACMRnFpTUPzc/XN
Lf1er4IgCLs7mps8jTUnG80WH2SPimDQUFUPHpeLzqYGdE3GKPnhdqgcLyqi
aOcuqopLULwimiZRXXaEwh07qDpUiNuhIopWQKWrpQlnTw+apiC7uzGZJRSP
hqOvt6PicFE/8F7l8Wqk773vYz9Y3NV1sFktr9XUN4l2f7+XokJD8tubm8K2
bVgnzbjhZj0qPj7a63EjmQXaG9oozN/KmAnjSByXRVx6JgGhIdQer6KmdA94
3RgMRk4cKSA4Jobs2bMIDA1H9bqoP1FFZcFhEtOzSMpKx2zzQZFBVfTWVW+9
ddzjcpRs3bH3GYPBgM1mHTZvMI5UZZAk4zKzJIX0OZ3NHo/8HqB+u37t9bNu
nk9kXFw0OkgWMz39Tv710Rry5rvJnDKNgLAIAsLCcaSNpSh/O5rXy6TZedhD
IwYWXVCpKi1m06df4OPnz9gpuQOWR5dQFVfLijder/Z6XIV7DxU/6OvrM6Tq
cV7KOtJBt6IoJCfG0d7ZRWt7J2azaXRCbNRToaGhl992733+4TGxcQAet5tN
a1bR1dFJ5uTxhERE4HI6kCwmepo70HUde3gwqlfFYrPS1dFJ0a6DmCwW8m6Z
T3DYwPlJR0tL0+rl7zS2tbTWnahreBqo+qGD7hEBCIKA7PViEMV4URSDTSbT
MlmWZ0REhOenj00Omnfn3bbAkNCks/t8s+oTqstKsPkHoekQHOCHKAp0dPUh
oNPX1YF/UCDz7/s9vnb7mX5d7e1136z+pPPo0Yr+mrr6XEmSjnq93nsGj2yr
fhSAs2gjMMdssXjv+cPvpWkzZ1J6YN+Wwh07tLm3L4yz2GxW/8Cg2NONy/bs
YnRyFn5hMRRs24giy0ydMw9XVxuHt39F1sw8rD4DqtHb3dXk6u/v37hmVVdY
dIzz6ttun1FaWMRfly6VnQ6HCSgb7sTnNIAfOmI6TRVGo3Hm3Jtu9Ey58koX
4J8xaUqePSh4/6fL3wn287eXzrvrHiSTyexrt4elXz6N6qKDdJ9qJ3vaTBAE
mo+V0lJdSs6cazCaTDj6+tplt9v15ccfNfZ0ncqcPHNWW870GTMGCryZjplz
r9735drPc4GSEUual3DZ42XggfQJEw787tFHsswWi8Vqs/kANNXWlK/74L1U
QRTbf/XEIsnq4xMIUHu0jKbjVei6TkBI6MBmFUXcTmfPiteXtXplOXnmTbcU
pE3MzhncS06X0+la+/HKw/mbNk0BVg+eHfNTVehsehp4MX7MmL3PLHnlTMeW
+vqyL/7xYYJoMHQ+8J8vx8gXKEVKJhPLX3zhiMftSZh5400lYzIyzxRs33n9
9V2H9u67HHgbePBibqsIP+G6zX2D9yjONb81U7PHTwFaLtAvY1dB0ftGg2HK
cAeLwAuXct3mfwcAPCsNeMNZISwAAAAASUVORK5CYII=
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_64x64.png.__mime.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232








































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_64x64.png
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAHXtJREFUeNrkm3d0XNW1/z/3Tp+RRm3UJavYkuXee8cdGWPAFBtC
IE4IifN+hLzYwSYk5OUFkpAX4hdYCSShGDAJ9iM2xoCNC7Zwr7hhSbbkIlll
eq/33t8fMxpLtgRyQtZv/dY7a83S3Kt7zt37e/bZe5/vPiMoisL/5ibyv7yp
O1+sWb38Zvu3A7cD+/+Bd/8X8APgx8AvvgJdJgCbgJyeHpgRCHS5Hvq7V//f
WUBOccn3y4cMBzAAL3wFQ0rXT+hNW8AUc3avO9Z4rKeAbMDXuV/WoluT30uq
xnbbd83q5W/pjCaxuGogDadO5AHRx5558UvfeeyXT/cky2Tg1Snm7Iwaj9U6
p2Joj4pEPzvwz/uAGo/VPjUzb/B3n/qJH9hc47GOVmIxFEn60r5rVi9/Hliq
1moRBKFDhlhv3ivHoiiSdO0TS3aLAqkAc6uGW7bVn7z6L3OCNR5r09TM/Awl
JqHRak1ACNjzacA5Pmvh/N4M0bewoj8Ll3wTgD5VA5cCj6xZvfypL+s4YsVP
yFo4P/mpfOQhajzW8cBOwAWgSDKA5V8ZBdKUWEwY+r1HAHh09ZMWQAbUgqbr
ErxSf+z62X+nz4BBMxfcczcgIEkyiqLoAC0gfNmLVTodgkad/Ig6XccyVhJy
IAgCcweOVG+rP9n4lQNQ47EeBUwAaoMBAJ3BkPWtJ1YFgDc2rn19YheTlW6w
bJOoUhn1ej0AI0dOpHTQUPLL+wWAn6xZvfyHNyPPn3/1y4nAG996YlVAZzBk
AQTbW1GiMeFLrED/j1pAdnczZTSZspetWKkH1m5c+/rUHtb+b4FbVapOViKI
DBk2nrIhw41FFf2DwNNrVi//SW8ESbxn7bIVK/VGkykbYMh3lqHIcscjKdvq
Tx7ooXv4HwUgfVpu8Q2eLuD3o1ar877x7z/UA3/auPb1Gd30HdCnaiA5JeVd
bmo0WkaPnYpKo0lJWJe+F8rPAP70zZU/Kk0xm/OSY6WkJHAVmTd4NMCQHoZQ
ugVAkeUePzUe6z4gRQ6GVNcrLwC21lZcdnvhHQ89XAH8dOPa12/vNPv/BczT
GY2MGZcwEMl9zRAEFfMXP0RuabkHWLVm9fKfdWNBd61Zvfx/Nq59fWB6VtZH
dz70cDmgCvj9N2gXbG9FDkduPg8w5OT2/KTPXtrZ/IPBIELihr29HUmSOPTJ
ro/9Pt9oYBrwM4CrDScBRhX0q3TklpRnCkIHfjJIHlCZ475Eb+CeZY+ZFUWJ
fvD2S+PXrF7uuk6C94C/AWtuWXi7Vk6E3E4mf20ir4Vj5aYAEFSaL3rWPG/Y
OPyNDQn5ZWzt7fHJjEb5dNu2Gltb6+zZd9558eN3360H/rpx7evVj/38P++0
5OaOLS4pNgwaPCaudJfkrZNHjvsHzYL7H50lJzyoogh+QVBMgiDe+/unvv8B
kNuhvCiKyLJM0O/HYDLF19lD9/P5a28lne62+pM75lQMndkrAL4EMJUcCCYv
HO3tSNEoh/bsrgn4fAOGj59QlFtUVJdbWFiZk1+w/f231w31ulyH1q75nTJs
/ASxcuhQ9AYjSM4vNUtBVIsqUa1NXHb8ZdSUKV87WlMT6ixDZk4OcicrMGRb
kn5g7pAxka2nDk/u4TUaINqr3Hlb/cmt1zun/Tt37g/6/f0c1vYpE2fNbhw8
enSZSh0fzpKXd/+dDz+sd9kdfPL+ZkGlVmEw5YLs7Z2rlT3d3s4tKJgpqlSq
o3s/3TBq0uTF0WgUh9VKZnY24WB8cpR4dknI2o4uy6Lt7PEBdIpCOP5MjJvY
PMyaM3RMiGBYD3BeiRxqudg4YdLsOfW5RUXWwpKSgaKqi280BLw+FFnGlGpG
isVAUIF8XV4gpnajvBeU7lNqlUqtkyWJKxcuLJZjsYhaq902fPyEBQ6rNflM
ZnZ8GyBHk06wi5PYZzAwKhRKmntvw6DUofwFOXykxeseO2XevPpRkydXFJeX
X698PNCGQtja2mhqbKDfkAndz76g7kb5nrcFAb8PnV7P4mXfpKCkVLpUX7/g
8J7dtSf2798djUSIRiI4bbaO0JKcjG31Jzd2XLhEEV0nEqiLBLGAv8dlCVDr
bD9y1ecZPWXuvNoREyf1F4Qvzl7rT59ixMSJmFLTe7X2u1Pe1e5Do9FiytBS
XjWAnIJCcgoKyC0sNKi1mtj+7dv7A/39Xm9TSmrqlYGjRk2QgyFEgx5BVDF7
6Bj/xycPL+wc9w/o9YwIh28EoPyOe7qVa+cLz3rO2pqdTU776Hu/9Xg4rziz
P4LQK9PJzs/v5br33XDLbfUhKGoO7t3BoBFDyS0sxJhIdtQaDSMnTlLnFRVF
XXbHZltry8BThw9PGDR6NOmzpuLZe4iQ3YouI9OU2C0mm12lSlpBFwBMBUVd
BHji4SUAOWq1KlVRlMx7v/V4KMNi1vdWeQApJvXuQSV6nfJ+IqEYp09+iiUn
k9B1bE4HCH369tP06csCKRbTGoymz4/v26saOXVaJYAcTgYMZcDD346HycSN
N370KP174QPKtVr14Qkz52jufGi5JzPbrNcZNV8dLdTNrHe0SCgOSKYlnQxL
NjkFBV80klalVjN2xowBaZmZwROfflp/nR+4oVkTEevLAPijwaDrU33fgxh0
RrPOqP1K9D5Ys4fzp0/HZ1329QiEIIhkZeeQlZOTTHS+MFFRqZhWvWCYyWz2
NUqh81/4bHdLoJPpa4EXDAZt/uJl38VjbSc9O/UrUf7j994jHAxRWTWgW9NP
pp0WE9aWFiRJSq77Xu3vRZFbbrttxA5FPnrxbG39AKgYW9xPe7N8wAMajXre
ogeXDZajClqdgkav4krDhV4JYWtt7fa+xx6gobaeSChCRvYX8486g4ZYLHTT
ANtaWxFEkVmL7hhlHtjf0ei2nwrHoq/0GoAnHl5SotGof7JgyQPFLZeucOzA
bvQmLYc+rcFls/dKCL+3+4wvHIgQ8gfQ6XW9GkcQBCy5uTcFgNflwtbaAkDF
kKHj6tubh0z/t5XLbsYCvl45ZFiJVq3HYWtl4dK7ObLvU1SCiC7BAv1TdHhB
HzTa7h3p8YMHuFhXd41hzs3FZDbf1PhF5eVEAgKfHT5EwOtl6vxbWbN6+Uu9
AuCJh5eYVCrxu5FIlO2b/4fp1XOoO3saZOhbVdXtbLRf7UrAOhI7xJ5aSlpG
t/dPHT1KyB/AkHLN2aXcpPIdGVtKmokLtZ/T3tqCJS8P4JHeWsA4gyklV6vR
0m9gFfa2FoI+P/0GDECn19/giR1WK1qdrsu11+1O7sZUKjXX1x7jafON4enS
hfOkZ2SQW1BIe5Odjzas56P166k9eRKfK9hrAKLRKGod9KsYjrWtFZ/Hw8RZ
s1sSdPwXA2AwaH+hUmtobbrE7EULuNTQQEZmJjq9HikWRaONO1OnzYbH4cDj
dJCelZW853XFOQxFUTh15BitzVfjfeQgiHHwdDo9DpsNvzt8Y9IkSfjdYZov
NnBw936srW2cPnKEoDfcKxDsbW1EwmEUBfpW9aei/wiOHzyE3WrPB77/pQAo
CuNNKSlkWDI5eehoPCEJh5FlGZ0pC7VGg8NqJeDz8dnRw2g1qdcAcToRBAGv
283rL7zM3h27sdtc8b26EkpuyvRGEy6nk4AneIPyAAFPkD0ff0hxWQlT5s5B
VMVFDHrD+N09gxBXXMFltyOKIiqtTL8BVRQUlXGoZh9jpk5rXrN6+bNfCIAk
yQiiGDdTIS6UJS8PRZbQ6Mw4bTaCfj+N5+sw6NPJyLLgstvxOJ1EIxEu1tfz
9p9eIxIOYUoxoQDH9+3H1tYWtwIgLSODWOTG2N/e3EZWbk6SZxwxbjJet4u2
pibCEV8CnHC3u85wKIQUi2FKTUWWZXweD16XG0EVZeSYaWRkZ3D25JlC4IlE
et89AHqjiWg4TMDnR6USyLJkk5Wbi86YSTTkxuN0cvXKZXRaMxWVwzGYtbgd
DmLRKJvXrWPvzj3oDQaysrMRRBU5eQW4HbZkWDKa9VjyCggFQ2g013zHySOH
CYfC5BYWJXJ8LUWlpeTllzN68kw2v/0qkWgcBJ8zDqTfHUpmu6IgJNPeFLMZ
j8uF1+1Co9UhaENMmTkPh81O+YBBbfn5mT/tEQCtTo8sSUixGG0tV8myWJBi
MTT6NKJhFw219Rzcs5fK/iNQG2K4HXYEQeD9t9chqPXIkozeaCKnoJDSvpXY
2tu5fKmVs8eO43W5MKXpycrJQVSpqKv7jIAnhLWlhTPHT6DV6Qj7Y0SjUWRJ
JrswC73RSEn5AEZNuoVNb71CTAogSRJnjh0l4Anhd4fQ6vRodDpam5rZs3U7
5vR0zOnp6DRm6s+eIRoNU1I6kKohw7jceDkXeLpHANIysxAEAYPJiCiKyXUJ
EPAFqD97juI+5aj0URQk3A4nJ/bvx2jOxGFzkF9UTL/+g3BYrQwbO4rs3Dhl
39bcxI5Nm7BdtaPV6TGnmTlz/CCRgExbczPRSBStTovPFaD1amMySKRmGjGa
dZT1G0ROQSEb3/wLuz/6O9v//nfCER8BTyi5LARBoeniJTb/bQN6o5EUs5ld
H3zEpfrzqHUyk6fPw+f1EotJcudl0AUAU6oZUVShVmuRJKkLAEG/n7arLQwf
MwVBVHC0t+N2OPD5ArQ0t1JeUYEsC4ydNgm/z0uffn2YPHsmZZWVXLrYwqXz
9QS8ccIlN78QWRa4fLkuuWXWaDTIRGi6VE9GIrIAmNIMGFJ1zLztLqbNW0Sf
sipK+lXw7tqXiUT9+N1Bgt4IpRWV3LZkMU6bnd0fbkNjBJMpnWMHDhIMuVAU
BVOqiXA4KvRoAW6HDa1ej9ftISMzkwzLtfLa1aYmVCo1Gl083/a4XJw9cZK2
ljZSUszMvn0RFQOrKCwtYNVzz5CalsbQscMpLCli3JQZtLQ4aKj/jIDXzpip
c/E4XZyvO5kMm4IgcOroXgJ+f9IZJhOidAMqUUNRaTmFfSqYseBOisvK2PDa
H4lE/fhcAQKeMDn5BSy8715ampqpP32OeXfchc8TYM/W7fh8DiqqBhONSj07
QVvLFVLMaXg9TrJz88gpKEBR4uGr7sxZcvIKiUS9xKJRLtWf53LjZVQqDVNn
z+O5nzzL7oPH+E7+RB5UW3hUXcgwdSbvvvkOFy/U8uCj/4ePNn7Iib07yMzO
xmgyEfAGEkmTEA+1ej0oIIrXOMaG02d5qPpupuQVszKvkn1vvsWBmkMY0/sQ
DEbZ8Oof8HrsuO1OAp4wGVnZTJo5nQ82bESfomLh3Q9w6ugJ2lov0n/wsA4K
3dh9YUQQMKamEovGkGLxj0ZnxutqJxqNkmJORxBE3ntrLaj0ZFgsmFMzsTvd
/G7dm7D3LK2XVAhaSFdn8tf9H/PHXdshFmHx/V9Pxmu3tZl+VQM4enA/I8eN
Q6VSJZebLCuoEiTr2UNH+c1Pf05tzX5+MGQ+902YjavRgTAwFWFkZVLuD95d
hxQJc8+yf0Ot0lHWv5LyynI2vfk3ps6ax8Dhwzl24DATZ+g6DmUUAXU3WIAg
CAcE4rMR8PkRBNAZM3G0XCYUCJGaloYsSRjNGWRYMvE4PaSkZTH3rsXIXje7
J99PeGQRuX/5ObqXHmfJ3IU8EEqlae9p3ljzW5789W/4aOMH7PrgXYYMn4Ai
KTReOI9Go8HvvZEU2fjamzTtPc0DoVSWzF2I7qXHyf3Lzwleuoj73U8YOWpU
Yn9RTFFZGe+88kKiXCYxfvpUnHY7Z08dYfrseTjtDpx2F6KYBOBGC/D5gt9u
ajz/mahSUXf2HEPGjIs7ImM24VAIc1o6G159FVNaFmq1lrKKSm5dujS+16+r
RZOVRuDgBbat/jGCFvw79jOKHFIlONHSzLE9uwA4c/IsffqeZeL0uRw/VENh
WREet/tadUqA3Ru3YGtp5gEph0rggx3rMT3dhBKB4oYIzu2HyKiewISp09i/
ZzeTZoznkw82EQp50YbTsOQWkpWXRUPdBSy5OZRV9OXMiZMdFpDeQ2mMk0Gf
E1EQuHqlKVlyUhSZSDiCMcWI1xti6NgKDuzey/JVqzuVs0RkUY36b2s5jpNT
xAsTkyhmVBgubd7Oz3ft58P2Bp767mNsfudtlix7BFGlIegPIAgC4VAYnV5P
cVkpK+bdxTSfnyqKOQrsPb4Tju9kCFrKyODzSeOQjhxg7F33MmHqVIIeP7cs
uIMNr77MwKHjKSwppW/lIA6313D5wkUGDR/Kh+++h0ajAjjTIx9gNOo2anTa
mFqt5sS+o8kKbCQcZvt760nPzMDv8zFgyHAs+ZmEE2ytNjOL1BkjSdWLPKoq
4uvaLKbrRLIJUp6Vz9fuu5OZ996LRqth+eqVSJLMX1/5E3q9CpfdiVanxW5z
YDQZGTF+LDPvvZev3Xcn5Vn5ZBNkuk7k69osHlUVkaoXKe5TSrvbTSgYRGdK
QWfQ4HeFuWfZo1y8cJp3Xvk9Ff2HhgYOH8GVxkvEYjFSzKnIsgJQm5w4RVHY
smFdx/VSgJP79ryVnm0h6A8zYtJkBEFk56Z3ybBYyLBYcFitlFZWkZ2fhyXd
gjE9HY1OT25uBmee+AvpL60hO+pEJSi0mIvxfe/fGPT0o/HCR4IAPX/2HH/+
7X+j0ajJLyrA7w+gN+jp178f8++5B8QUENScefqPpLzwe/I9V5AUAasmg6s/
/hHFS2chiFrOnzuDFI2i1qqRYjKKoqBSi7idDqKRCBlZ2dLpw/tVaRkZIEBz
4yXcTpcwpfo2qhcvTS6BuxN/VwFk5haEwqGgPtWUQvP509z3nZXs3LgBj93K
4GGDsF5tZsrUmWQXp7Nr6x6UthZEtRpBHIblBwtwej1cOvwZihKj8N5qBj35
jfhmSAknEp8YRaV9WL56Jete/jPWNisp5lQcVjtKZfk1ylzQMejpZVzQCBz4
2xZig0pJ6VtKZHQxF+rqkWWZqr79MaQaScs2daonRMkuTg+seerHxiugKh08
WpIkSRWLRFCptUypvq1D3/UdAPwHQPXipQMSzFChTq9rqhoyLBIKebWRcDiR
GseISRK5eUVo9fGuM+ZOxWPz43f7OXfqBIIg0Pff7yIlOB9Lahq6gkJQ5GvK
SxJtzc3Y2toYOnYs33vyCd76w8tY29qIhCNY22yd9udhUEQMS2ZSMnc4Da1X
CYgik6bPJRYK4WptwWg2YrZcI2rSsk0427ycPnrEDewDTBdPH5kweNx4j9Pm
Nfs9TqVDX2B9hw8Y0KloAnBVkSXr558d12q0mrAsSR3ek0gohDHFRFp2SlIh
s8WEzqhn8IAhDKio4nxjA43t7fhTzahNqV0YoFAggNftTvKLptQUHln5AybO
mIbBoKWh9gKdj720t7ZRV3eORpuVGQvuZOL0OTiuXMLnsKMz6jFbTF1S9jjp
H2bHxo35jz3z4uyWFsdE4ODpgwfM8YwTarZsTurbU3lciURi1SqV+MnVxkZj
0OcNAgZRFBEEgez8rC4K6Y1GMvOv8Xe5pfFzQLu2foI4YjCWHEuX4oWiKFQN
HdrlhTMW3EpOQS4b31pPW3MLZZX9sLXbOHP8NDPmTk8QFk60OsgttXQhUkKB
AKbUODkTjUSwtlxVcgsL2wB++erbrFm9fEI4HJUdVjuCIApfcEKkSzssSfJm
t9u/4M3//oUJwJiSEqs/+7n67m9+A4fNESckwmFcTjf5hflcXyafMXc6Oz7a
xcx5MzpxDkaqhg3r9oWDRo5i0MhRyevPjp3q0rcLH2lzIMkykVAIUaUiHI6T
LC6HI/rhO+9oHnvmxc5V2axYTGpUoNho1H0eDIa/GIBfvvp2R2F0iSTJgw2p
ae+43G1VGbkFYuO5zzl7qhatVktqWipulwdFURBFEZ1eh5DI4zMy47lGTwr0
pnXu63R0PTN17PAJFDmeNCXL9IpCLBYTjeb0E++vf2viheP7Dj/2zIvRx555
0fbEw0tWyXLLX32+4NBeWcAvX32bLRvWdUxHVvPlrQQcV8X8okJ7c93prElz
ZlNYUoLRZEKlVrNty/bkfgJg9q3dn0vyuFxEwiFS09LRGbqyzOGgH6/bFecM
0tO7/O/IgaNdrrsbv625Wf7rH/+g6jdyUiGwsbBy8P1bNqxzVi9eekSn01zQ
atXnv+SQ1LW2ZcO6YcBWgJotm7PUapUrGIykGfBV6tJz6hVZzmysraW0spIU
s5k51bOuUdORCNFohHAwhNFk6rI0dr23ibrTZxkzbQrjZy1CShynVanUHNix
ncO7a6gcPJDbH/z6tSKyJDFh8hh0hvhusYOd7mitTU2EQyHZabUeBuTqxUsn
JnSwJ/7eEg5Hj4TD0YpOk9tzbXDLhnWDgN3Vi5dmVS9emgUQi0mzIpGoDcgY
MnZc1oGdOwIqtZorDQ04bTZi0WtEZ3vLVVqbmtj0xlr8vq6bnFGTJ9PQ2Mob
L/6Z2mO7CXnbCHnbqD22mzde/DMNja2Mmtz1YJff52PTG2tpbWqivaVrIcZp
s+F2OhVba8uR3R9sSXvsmReT55U7yb97SvVtg3pVGtuyYV05sL968dL0zssB
OBIIhLNbWhwXhk2cx8hJk02Hdu30q1QqpeXyZa5evpwEobCkFLVag8tuJxzq
WuDMK+7Dd370ONkFBdSeOhUvgGxYT+2pU2QXFPCdHz1OXnGfG5hfl92OWq2h
sKQ0fpwnGqXl8mU8Lpfsd7tPfrp1q3n6gtsGdKdkQpf9U6pvK0/o8oW1wQvV
i5f2qiY1cvKUlL3btvq1Oq3idji48PnnycpQfnExM29fxG+e/BkeV5w2j0Wj
iKLIkFHDeOr5XzFp3nx0ej06vZ5J8+bz1PO/YsioYQiiSMehJ4/LyW+e/Bkz
b19EfnFxnJ4LBLjc0ICiKLHWK1eO1Gz9SNuT8p1AMAMXeu0DunOKnduwifP4
bN9HjJ46LXX3R1t90+bPN0mxGJfOnyc7Lw9LXh5Vw4ax8L47eOaHT3L3N+5H
bzAAAhqtBo1Wi0qtTiZEkiTR3tpCNBIhHI4ACpFQiPWvvMXC++5Ihk57ezu2
1lbSMjOjzZcuNhzctdMUziia2SHTTdcS/5HfDf76uWfTVq5Y5U58NwPufhnx
GsH4mbMUWZYFnV5PUVkZer2evR9/zOZ3NnY71txFCwDYuvH9bv9/2z2LmDRn
DpFwmJYrV5AkSQr6vP6d772XkmGxiKOmTGXzzgMAaStXrPJcL19Pbc3q5Tz2
zIs3/yurRHv+1889uyLx/TXAVTlkaLokSZw6fMiuNxot/QYMpK2pCUteHuNm
zGDSnDm4HHY2vfYqk2+9h76DhiUKHfHcf8bt9wNwsfYMx2o+5M6Hl3VhpBtq
a5FlSd79/vuiLMufTKtesFClUlFaUYFu7zEkSVr/6+eeXZro8hzwjV6dKPkH
AfgV0Ao8L4piv289dE96+YABaDQaqoYOs1Tft2Tr6SOHCQWDnD97ltbmZvxe
LynmNEZOmUrzxTr83ngCpdOnotOnoigKfq+Hq5fOY8nL75QbBGltaiIaDnFi
/37n1Pm3CrMW3bFQo9EkD0s/uGQR6Wlpc4DnE3L96l+6BBJm9mPAsOLxbz8h
CILo9/kQgMa6OhRZRpZlmhobaG1qUqbOvxVAKC4rQwH279yOTm+m36BRyeKn
LMmcP3OUaNjLtFvjy8LtdHKpvo66U6eJRaMMHDkSlVpNWeU1QlQBTCkpKIri
f+75l9YAwZUrVv3nl8nfsQSEf+a3w79+7lkP4P7h9x+xJExV35EJNtbWJs8G
7Hxv0yfV9y2ZXlBSgiRJqDUaDuzYwbnPTpCeZUEURRAECktKGDFxIpcbGojF
o4DS2nRFKCorjydTikJZ//5dzhwYTKYQwG9+97It4Qd6FcG+EgASILwGnANY
8fi3/6PjjJAgCMlzMA3nzlF/+rSiycxR+lf0RS2CoiiCIAhIsVicBhcEYtEo
Gq1Wcbg8wtWrLZyvPV8/85bJZYIgMHjMGAJeb1L5jt3fc8+/1PEbo6qVK1Y9
1Fu5vzIAEiB8rcNpd9zrX9m3g3Whtu7CegB10JOLHJsKoJXCGFNSMJnN6HTx
k/hejxu3w0FE1IKo3hEzmF/vPGYPbTPAyhWr3rgZmb9SAP5/bv93AE4g+jcs
IS21AAAAAElFTkSuQmCC
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/jvm/head_8x8.png.__mime.

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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 head_8x8.png
iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAACXBIWXMAACZz
AAAmcwHzbHUKAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNn
VFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8ig
iAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfA
CAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH
vgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCd
mCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7
AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7
AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkX
KxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G
/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUA
oOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7i
JIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5E
mozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcA
APK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCB
KrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv
1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggX
mYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyG
vEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+
Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXA
CTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIx
h1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBoj
k8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU0
5QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgX
aPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+Y
TKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV
81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkG
WcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2q
qaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr
qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acK
pxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VH
DFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYP
jGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x
1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l
1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6T
vZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPj
thPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWd
m7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+B
Z7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nv
nl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5
QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeG
P45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu
ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxap
LhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgq
TXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqoh
TZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdl
V2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxx
edsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWF
fevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavE
uWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/
PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttV
AVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRS
j9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92
HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLT
k2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy
2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L15
8Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfV
P1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L9
6fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bC
xh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz
/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdv
kl/FRgAAAJFJREFUeNpivDZvxv+zX64zxGTVMyCDJdMaGYx5NBmYzn65jiKI
DM5+uc7AsHhS/v//f979x0Uz/P/z7v8qOdn/////R5WE8hn+/3n3/6eIMEQR
VBKZz/j/z7v/DHgAs4rIjwYNHU0GZlYehiXTGhkunT7IoGfqwPDr+0uG5bN7
GRhePNwHtxsOoFa9eLjvP2AAtLeFyIil+2IAAAAASUVORK5CYII=
====

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/ConsoleOutput.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
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

















































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import java.io.IOException;

/**
 * Used for printing to the console.
 *
 * @since 2018/09/21
 */
public final class ConsoleOutput
{
	/** Standard output. */
	public static final int OUTPUT =
		1;
	
	/** Standard error. */
	public static final int ERROR =
		2;
	
	/** End of file. */
	public static final int ERROR_EOF =
		-1;
	
	/** Invalid file descriptor. */
	public static final int ERROR_INVALIDFD =
		-2;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/21
	 */
	private ConsoleOutput()
	{
	}
	
	/**
	 * Reads the display console, that is anything which was output to the
	 * console itself.
	 *
	 * @param __dim The output dimensions of the console, columns and rows.
	 * This array must always have a length of at least two.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes which were read, this will be the minimum
	 * of either {@code __dim[0] * __dim[1]} or {@code __l}. Zero may be
	 * returned if this is not supported.
	 * @since 2018/12/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int displayRead(int[] __dim,
		byte[] __b, int __o, int __l)
	{
		// Not supported so always returns zero as nothing read
		return 0;
	}
	
	/**
	 * Flushes the stream.
	 *
	 * @param __fd The file descriptor to flush.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int flush(int __fd)
	{
		if (__fd == OUTPUT)
			System.out.flush();
		
		else if (__fd == ERROR)
			System.err.flush();
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
	
	/**
	 * Writes the character to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __c The byte to write, only the lowest 8-bits are used.
	 * @return Zero on success, negative values for EOF.
	 * @since 2018/09/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int write(int __fd, int __c)
	{
		if (__fd == OUTPUT)
			System.out.write(__c);
		
		else if (__fd == ERROR)
			System.err.write(__c);
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
	
	/**
	 * Writes the given bytes to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int write(int __fd,
		byte[] __b, int __o, int __l)
	{
		if (__fd == OUTPUT)
			System.out.write(__b, __o, __l);
		
		else if (__fd == ERROR)
			System.err.write(__b, __o, __l);
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841









































































































































































































































































































































































































































































































































































































































































































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.javase.lcdui.ColorInfo;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
import java.awt.image.DataBufferShort;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.lcdui.Display;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.WindowConstants;
import net.multiphasicapps.io.MIMEFileDecoder;

/**
 * Java SE implementation of the native display system using Swing.
 *
 * @since 2018/11/16
 */
@Deprecated
public final class NativeDisplayAccess
{
	/** The number of parameters available. */
	public static final int NUM_PARAMETERS =
		8;
	
	/** The pixel format. */
	public static final int PARAMETER_PIXELFORMAT =
		0;
	
	/** The buffer width. */
	public static final int PARAMETER_BUFFERWIDTH =
		1;
	
	/** The buffer height. */
	public static final int PARAMETER_BUFFERHEIGHT =
		2;
	
	/** Alpha channel is used? */
	public static final int PARAMETER_ALPHA =
		3;
	
	/** Buffer pitch. */
	public static final int PARAMETER_PITCH =
		4;
	
	/** Buffer offset. */
	public static final int PARAMETER_OFFSET =
		5;
	
	/** Virtual X offset. */
	public static final int PARAMETER_VIRTXOFF =
		6;
	
	/** Virtual Y offset. */
	public static final int PARAMETER_VIRTYOFF =
		7;
	
	/** The callback for events. */
	private static volatile NativeDisplayEventCallback _CALLBACK;
	
	/** The frame to display. */
	private static volatile JFrame _frame;
	
	/** The panel used to display graphics on. */
	private static volatile SwingPanel _panel;
	
	/** State count for this framebuffer. */
	static volatile int _statecount;
	
	/**
	 * Initializes some things
	 *
	 * @since 2018/11/18
	 */
	static
	{
		try
		{
			// Setting this to true greatly increases the speed of the canvas
			// however this breaks on Windows 10 with pointer coordinates
			// being way off when scaling is used. So this must be false.
			JFrame.setDefaultLookAndFeelDecorated(false);
		}
		catch (Throwable t)
		{
			t.printStackTrace();
		}
	}
	
	/**
	 * Initialize and/or reset accelerated graphics operations.
	 *
	 * @param __id The display to initialize for.
	 * @return {@code true} if acceleration is supported.
	 * @since 2018/11/19
	 */
	public static final boolean accelGfx(int __id)
	{
		// Not supported on Swing because graphics operations are pretty
		// fast already
		return false;
	}
	
	/**
	 * Performs accelerated graphics operation.
	 *
	 * @param __id The display ID.
	 * @param __func The function to call.
	 * @param __args Arguments to the operation.
	 * @return The result of the operation.
	 * @since 2018/11/19
	 */
	public static final Object accelGfxFunc(int __id, int __func,
		Object... __args)
	{
		return null;
	}
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @param __id The display ID.
	 * @return The capabilities of the display.
	 * @since 2018/11/17
	 */
	public static final int capabilities(int __id)
	{
		return Display.SUPPORTS_INPUT_EVENTS |
			Display.SUPPORTS_TITLE |
			Display.SUPPORTS_ORIENTATION_PORTRAIT |
			Display.SUPPORTS_ORIENTATION_LANDSCAPE |
			ExtendedCapabilities.SUPPORTS_POINTER_EVENTS;
	}
	
	/**
	 * Requests that the display should be repainted.
	 *
	 * @param __id The display ID.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	public static final void displayRepaint(int __id,
		int __x, int __y, int __w, int __h)
	{
		if (__id != 0)
			return;
		
		NativeDisplayAccess.__panel().repaint(__x, __y, __w, __h);
	}
	
	/**
	 * Returns the object representing the framebuffer data.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer array.
	 * @since 2018/11/18
	 */
	public static final Object framebufferObject(int __id)
	{
		if (__id != 0)
			return null;
		
		return ColorInfo.getArray(NativeDisplayAccess.__panel()._image);
	}
	
	/**
	 * Returns the palette of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The palette of the framebuffer.
	 * @since 2018/11/18
	 */
	public static final int[] framebufferPalette(int __id)
	{
		if (__id != 0)
			return null;
		
		return ColorInfo.getPalette(NativeDisplayAccess.__panel()._image);
	}
	
	/**
	 * Returns the parameters of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer parameters.
	 * @since 2018/11/18
	 */
	public static final int[] framebufferParameters(int __id)
	{
		if (__id != 0)
			return null;
		
		BufferedImage image = NativeDisplayAccess.__panel()._image;
		
		// Build parameters
		int[] rv = new int[NativeDisplayAccess.NUM_PARAMETERS];
		rv[NativeDisplayAccess.PARAMETER_PIXELFORMAT] =
			ColorInfo.PIXEL_FORMAT.ordinal();
		rv[NativeDisplayAccess.PARAMETER_BUFFERWIDTH] = image.getWidth();
		rv[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT] = image.getHeight();
		rv[NativeDisplayAccess.PARAMETER_ALPHA] = 0;
		rv[NativeDisplayAccess.PARAMETER_PITCH] = image.getWidth();
		rv[NativeDisplayAccess.PARAMETER_OFFSET] = 0;
		rv[NativeDisplayAccess.PARAMETER_VIRTXOFF] = 0;
		rv[NativeDisplayAccess.PARAMETER_VIRTYOFF] = 0;
		
		return rv;
	}
	
	/**
	 * Returns the state count of this framebuffer which is used to detect
	 * when the parameters have changed, where they must all be recalculated
	 * (that is the framebuffer wrapper must be recreated).
	 *
	 * @param __id The display ID.
	 * @return The state count for the framebuffer.
	 * @since 2018/12/02
	 */
	public static final int framebufferStateCount(int __id)
	{
		if (__id != 0)
			return -1;
		
		return NativeDisplayAccess._statecount;
	}
	
	/**
	 * Is the specified display upsidedown?
	 *
	 * @param __id The ID of the display.
	 * @return If the display is upsidedown.
	 * @since 2018/11/17
	 */
	public static final boolean isUpsideDown(int __id)
	{
		return false;
	}
	
	/**
	 * Returns the number of permanent displays which are currently attached to
	 * the system.
	 *
	 * @return The number of displays attached to the system.
	 * @since 2018/11/16
	 */
	public static final int numDisplays()
	{
		// There is ever only a single display that is supported
		return 1;
	}
	
	/**
	 * Registers the class to be called for when display events are to be
	 * called.
	 *
	 * @param __cb The callback.
	 * @since 2018/12/03
	 */
	public static final void registerEventCallback(
		NativeDisplayEventCallback __cb)
	{
		// Do not change to self!
		NativeDisplayEventCallback old = NativeDisplayAccess._CALLBACK;
		if (old == __cb)
			return;
		
		// Tell the old handler that the callback is now gone
		if (old != null)
			try
			{
				old.lostCallback();
			}
			catch (Throwable e)
			{
				e.printStackTrace();
			}
		
		NativeDisplayAccess._CALLBACK = __cb;
	}
	
	/**
	 * Sets the title of the display.
	 *
	 * @param __id The display ID.
	 * @param __t The title to use.
	 * @since 2018/11/18
	 */
	public static final void setDisplayTitle(int __id, String __t)
	{
		if (__id != 0)
			return;
		
		NativeDisplayAccess.__frame().setTitle(
			(__t == null ? "SquirrelJME" : __t));
	}
	
	/**
	 * Returns the current frame.
	 *
	 * @return The current frame.
	 * @since 2018/11/18
	 */
	static final JFrame __frame()
	{
		// Without the lock, the frame is initialized multiple times
		synchronized (NativeDisplayAccess.class)
		{
			JFrame rv = NativeDisplayAccess._frame;
			if (rv != null)
				return rv;
				
			// Debug
			todo.DEBUG.note("Setting up the frame.");
			
			// Setup frame
			NativeDisplayAccess._frame = (rv = new JFrame());
			
			// Exit when close is pressed
			rv.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
			
			// Initial title
			rv.setTitle("SquirrelJME");
			
			// Use a better panel size
			rv.setMinimumSize(new Dimension(160, 160));
			rv.setPreferredSize(new Dimension(640, 480));
			
			// Load icons, for those that exist anyway
			List<Image> icons = new ArrayList<>();
			for (int i : new int[]{8, 16, 24, 32, 48, 64})
			{
				String rcname = String.format("head_%dx%d.png", i, i);
				URL rc = ColorInfo.class.getResource(rcname);
				
				// If it does not exist, try loading MIME data instead
				// The new bootstrap does not decode these
				if (rc == null)
				{
					try (InputStream in = ColorInfo.class.getResourceAsStream(
						rcname + ".__mime"))
					{
						// Still does not exist
						if (in == null)
							continue;
						
						// Decode MIME data
						try (ByteArrayOutputStream baos = new
							ByteArrayOutputStream();
							InputStream inx = new MIMEFileDecoder(in, "utf-8"))
						{
							byte[] buf = new byte[512];
							for (;;)
							{
								int rcx = inx.read(buf);
								
								if (rcx < 0)
									break;
								
								baos.write(buf, 0, rcx);
							}
							
							// Load icon
							icons.add(new ImageIcon(baos.toByteArray()).
								getImage());
						}
					}
					
					// Ignore
					catch (IOException e)
					{
					}
					
					// Go to the next icon
					continue;
				}
				
				// Add the icon
				icons.add(new ImageIcon(rc).getImage());
			}
			rv.setIconImages(icons);
			
			return rv;
		}
	}
	
	/**
	 * Returns the current panel.
	 *
	 * @return The current panel.
	 * @since 2018/11/18
	 */
	static final SwingPanel __panel()
	{
		// Without the lock, the panel is initialized multiple times
		synchronized (NativeDisplayAccess.class)
		{
			SwingPanel rv = NativeDisplayAccess._panel;
			if (rv != null)
				return rv;
			
			// Debug
			todo.DEBUG.note("Setting up the panel.");
			
			// Setup panel
			NativeDisplayAccess._panel = (rv = new SwingPanel());
			
			// Add to the frame
			JFrame frame = NativeDisplayAccess.__frame();
			frame.add(rv);
			
			// Record some events
			frame.addComponentListener(rv);
			frame.addWindowListener(rv);
			frame.addKeyListener(rv);
			frame.addMouseListener(rv);
			frame.addMouseMotionListener(rv);
			
			// Pack the frame
			frame.pack();
			
			// Make the frame visible and set its properties
			frame.setLocationRelativeTo(null);
			frame.setVisible(true);
			
			return rv;
		}
	}
	
	/**
	 * The panel used to display graphics on.
	 *
	 * @since 2018/11/18
	 */
	public static final class SwingPanel
		extends JPanel
		implements ActionListener, ComponentListener, KeyListener,
			MouseListener, MouseMotionListener, WindowListener
	{
		/** Resize lock timer. */
		final Timer _resizetimer =
			new Timer(100, this);
		
		/** The image to be displayed. */
		volatile BufferedImage _image =
			ColorInfo.create(Math.max(240, this.getWidth()),
				Math.max(320, this.getHeight()), new Color(0xFFFFFFFF));
		
		/** The last mouse button pressed. */
		volatile int _lastbutton =
			Integer.MIN_VALUE;
		
		/**
		 * Initializes more panel details.
		 *
		 * @since 2018/12/03
		 */
		{
			this._resizetimer.setRepeats(false);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/03
		 */
		@Override
		public void actionPerformed(ActionEvent __e)
		{
			todo.DEBUG.note("Performed resize!");
			
			BufferedImage image = this._image;
			int oldw = image.getWidth(),
				oldh = image.getHeight(),
				xw = this.getWidth(),
				xh = this.getHeight();
		
			// Recreate the image if the size has changed
			if (xw != oldw || xh != oldh)
			{
				this._image = (image = ColorInfo.create(xw, xh,
					new Color(0xFFFFFFFF)));
				NativeDisplayAccess._statecount++;
			}
			
			// Indicate that the size changed
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.sizeChanged(0, xw, xh);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void componentHidden(ComponentEvent __e)
		{
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.shown(0, 0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void componentMoved(ComponentEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void componentResized(ComponentEvent __e)
		{
			// Call the resize code directly
			if (false)
				this.actionPerformed(null);
				
			// Restart the resize timer so that resizes are not flooding
			// everything
			else
				this._resizetimer.restart();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void componentShown(ComponentEvent __e)
		{
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.shown(0, 1);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyPressed(KeyEvent __e)
		{
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.keyEvent(0, NativeDisplayEventCallback.KEY_PRESSED,
					__KeyMap__.__map(__e), __KeyMap__.__char(__e),
					(int)__e.getWhen());
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyReleased(KeyEvent __e)
		{
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.keyEvent(0, NativeDisplayEventCallback.KEY_RELEASED,
					__KeyMap__.__map(__e), __KeyMap__.__char(__e),
					(int)__e.getWhen());
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyTyped(KeyEvent __e)
		{
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.keyEvent(0, NativeDisplayEventCallback.KEY_PRESSED,
					__KeyMap__.__map(__e), __KeyMap__.__char(__e),
					(int)__e.getWhen());
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseClicked(MouseEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseDragged(MouseEvent __e)
		{
			this.__mouseEvent(__e,
				NativeDisplayEventCallback.POINTER_DRAGGED);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseEntered(MouseEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseExited(MouseEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseMoved(MouseEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mousePressed(MouseEvent __e)
		{
			this.__mouseEvent(__e,
				NativeDisplayEventCallback.POINTER_PRESSED);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void mouseReleased(MouseEvent __e)
		{
			this.__mouseEvent(__e,
				NativeDisplayEventCallback.POINTER_RELEASED);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		protected void paintComponent(java.awt.Graphics __g)
		{
			// This must always be called
			super.paintComponent(__g);
			
			BufferedImage image = this._image;
			int oldw = image.getWidth(),
				oldh = image.getHeight(),
				xw = this.getWidth(),
				xh = this.getHeight();
		
			// Recreate the image if the size has changed
			if (xw != oldw || xh != oldh)
			{
				this._image = (image = ColorInfo.create(xw, xh,
					new Color(0xFFFFFFFF)));
				NativeDisplayAccess._statecount++;
			}
			
			// Have the display client draw whatever is on this display, but
			// only in the region we are drawing!
			Rectangle rect = __g.getClipBounds();
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.paintDisplay(0, rect.x, rect.y, rect.width, rect.height);
			
			// Draw the backed buffered image
			__g.drawImage(image, 0, 0, xw, xh,
				0, 0, xw, xh, null);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowActivated(WindowEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowClosed(WindowEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowClosing(WindowEvent __e)
		{
			todo.DEBUG.note("Window is closing!");
			
			// Post close event
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.exitRequest(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowDeactivated(WindowEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowDeiconified(WindowEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowIconified(WindowEvent __e)
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void windowOpened(WindowEvent __e)
		{
		}
		
		/**
		 * Handles mouse event.
		 *
		 * @param __e The event.
		 * @param __t The event type.
		 * @since 2018/12/02
		 */
		private final void __mouseEvent(MouseEvent __e, int __t)
		{
			int mybutton = __e.getButton(),
				lastbutton = this._lastbutton;
			
			// Depends on the event
			switch (__t)
			{
				case NativeDisplayEventCallback.POINTER_DRAGGED:
					// For some reason in Swing, the mouse being dragged is
					// always button zero, so just send drag event no matter
					// what without any button filtering
					break;
				
				case NativeDisplayEventCallback.POINTER_PRESSED:
					if (lastbutton < 0 || mybutton == lastbutton)
						this._lastbutton = mybutton;
					else
						return;
					break;
				
				case NativeDisplayEventCallback.POINTER_RELEASED:
					if (mybutton == lastbutton)
						this._lastbutton = Integer.MIN_VALUE;
					else
						return;
					break;
			}
			
			// Post event
			NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
			if (cbx != null)
				cbx.pointerEvent(0, __t, __e.getX(), __e.getY(),
					(int)__e.getWhen());
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/ObjectAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291



































































































































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;
import cc.squirreljme.runtime.cldc.ref.PrimitiveWeakReference;
import java.lang.reflect.Array;

/**
 * This contains accessors for object information.
 *
 * @since 2018/09/22
 */
public final class ObjectAccess
{
	/** Monitor is not owned by this thread. */
	public static final int MONITOR_NOT_OWNED =
		-1;
	
	/** Monitor did not interrupt. */
	public static final int MONITOR_NOT_INTERRUPTED =
		0;
	
	/** Monitor did interrupt. */
	public static final int MONITOR_INTERRUPTED =
		1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/22
	 */
	private ObjectAccess()
	{
	}
	
	/**
	 * Allocates an object but does not construct it
	 *
	 * @param __cl The class to allocate.
	 * @return An object for the class, it is not initialized with a
	 * constructor. Returns {@code null} if no more memory is available.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object allocateObject(String __cl)
	{
		return null;
	}
	
	/**
	 * Creates a new array of the given type, this is the actual array and
	 * not the component.
	 *
	 * @param __t The array type, not the component type.
	 * @param __l The array length.
	 * @return An array allocated to the given length.
	 * @since 2018/09/25
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object arrayNew(Class<?> __t, int __l)
	{
		return Array.newInstance(__t.getComponentType(), __l);
	}
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Class<?> classByName(String __s)
	{
		try
		{
			return Class.forName(__s.replace('/', '.'));
		}
		catch (ClassNotFoundException e)
		{
			return null;
		}
	}
	
	/**
	 * Returns the class data which is attached to the given class object.
	 *
	 * @param __cl The class to get the data from.
	 * @return The resulting class data.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final ClassData classData(Class<?> __cl)
	{
		// {@squirreljme.error AF01 Cannot obtain class data.}
		throw new Error("AF01");
	}
	
	/**
	 * Returns the class object for the given object.
	 *
	 * @param __v The object to get the class of.
	 * @return The class of the given object, or {@code null} if it has no
	 * class.
	 * @since 2018/09/22
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Class<?> classOf(Object __v)
	{
		if (__v == null)
			return null;
		return __v.getClass();
	}
	
	/**
	 * Checks if the given thread holds the given object in a lock.
	 *
	 * @param __ntid The native thread ID.
	 * @param __o The object to check.
	 * @return If the lock is held.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean holdsLock(int __ntid, Object __o)
	{
		if (__ntid == Thread.currentThread().getId())
			Thread.holdsLock(__o);
		
		// {@squirreljme.error AF02 Cannot check if another thread holds
		// a lock for an object.}
		throw new Error("AF02");
	}
	
	/**
	 * Returns the identity hashcode of the object.
	 *
	 * @return The identity hashcode.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int identityHashCode(Object __o)
	{
		return System.identityHashCode(__o);
	}
	
	/**
	 * Invokes the specified static method.
	 *
	 * @param __m The method to invoke.
	 * @param __args Arguments to the method, the parameters will be passed
	 * as-is and will not be unboxed, so the method must accept boxed values.
	 * @return The value to return from the method, {@code void} will return
	 * {@code null}.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object invokeStatic(StaticMethod __m, Object... __args)
	{
		// {@squirreljme.error AF03 Cannot invoke static method.}
		throw new Error("AF03");
	}
	
	/**
	 * Notifies threads waiting on the monitor.
	 *
	 * @param __o The object to notify.
	 * @param __all Notify all threads?
	 * @return If the monitor was a success or not.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int monitorNotify(Object __o, boolean __all)
	{
		try
		{
			if (__all)
				__o.notifyAll();
			else
				__o.notify();
			
			return MONITOR_NOT_INTERRUPTED;
		}
		catch (IllegalMonitorStateException e)
		{
			return MONITOR_NOT_OWNED;
		}
	}
	
	/**
	 * Waits for a notification on a monitor.
	 *
	 * @param __o The object to wait on.
	 * @param __ms The milliseconds.
	 * @param __ns The nanoseconds.
	 * @return The wait status.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int monitorWait(Object __o, long __ms,
		int __ns)
	{
		try
		{
			if (__ms == 0 && __ns == 0)
				__o.wait();
			else
				__o.wait(__ms, __ns);
			
			return MONITOR_NOT_INTERRUPTED;
		}
		catch (IllegalMonitorStateException e)
		{
			return MONITOR_NOT_OWNED;
		}
		catch (InterruptedException e)
		{
			return MONITOR_INTERRUPTED;
		}
	}
	
	/**
	 * Creates a new primitive weak reference. Note that it is not valid to
	 * operate on this object as a normal object, it is a special
	 * representation.
	 *
	 * @return The primitive weak reference.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final PrimitiveReference newWeakReference()
	{
		return new __WeakRef__();
	}
	
	/**
	 * Gets the given reference.
	 *
	 * @param __r The reference to read from.
	 * @return The reference value, may be {@code null} if the input reference
	 * is not valid, it was garbage collected, or it was never set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object referenceGet(PrimitiveReference __r)
	{
		return ((__WeakRef__)__r).__get();
	}
	
	/**
	 * Sets the given reference to the given value.
	 *
	 * @param __r The reference to set.
	 * @param __v The value to set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void referenceSet(PrimitiveReference __r,
		Object __v)
	{
		((__WeakRef__)__r).__set(__v);
	}
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param <C> The class to type this as.
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@SuppressWarnings({"unchecked"})
	public static final <C> Class<C> classByNameType(String __s)
	{
		return (Class<C>)((Object)ObjectAccess.classByName(__s));
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/ResourceAccess.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
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




























































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to resources and their raw data streams.
 *
 * Access to resources relies on the suites, so the correct suite must be
 * specified. {@link Class#getResourceAsStream(String)} should handle this.
 *
 * @since 2018/10/07
 */
public final class ResourceAccess
{
	/** Resource does not exist. */
	public static final int OPEN_STATUS_NO_RESOURCE =
		-1;
	
	/** JAR does not exist. */
	public static final int OPEN_STATUS_NO_JAR =
		-2;
	
	/** IOException. */
	public static final int OPEN_STATUS_IOEXCEPTION =
		-3;
	
	/** Read returned EOF. */
	public static final int READ_STATUS_EOF =
		-1;
	
	/** Read returned unknown file descriptor. */
	public static final int READ_STATUS_UNKNOWN_FD =
		-2;
	
	/** Read returned IOException. */
	public static final int READ_STATUS_IOEXCEPTION =
		-3;
	
	/** Descriptor was not found. */
	public static final int CLOSE_STATUS_UNKNOWN_FD =
		-2;
	
	/** Close resulted in any IOException. */
	public static final int CLOSE_STATUS_IOEXCEPTION =
		-3;
	
	/**
	 * Returns the number of bytes which are known to be available. This is
	 * not required to be supported but is available for usage if it would
	 * result in optimization.
	 *
	 * If this is not supported by a resource then zero or a negative value
	 * may be returned.
	 *
	 * @param __fd The file descriptor to check.
	 * @return The number of available bytes.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int available(int __fd)
	{
		return READ_STATUS_UNKNOWN_FD;
	}
	
	/**
	 * Closes the given resource.
	 *
	 * @param __fd The resource descriptor to close.
	 * @return A negative value indicating the reason for the failure.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int close(int __fd)
	{
		return CLOSE_STATUS_UNKNOWN_FD;
	}
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR the resource is in, this specifies the name of a
	 * suite.
	 * @param __res The name of the resource to load.
	 * @return The file descriptor or a negative value if it does not exist.
	 * If {@code -2} is returned that means there was an exception trying to
	 * load the resource.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int open(String __jar, String __res)
	{
		return OPEN_STATUS_NO_JAR;
	}
	
	/**
	 * Reads data from the given resource.
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative value if the end of
	 * stream was reached.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int read(int __fd, byte[] __b, int __o,
		int __l)
	{
		return READ_STATUS_UNKNOWN_FD;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/SuiteAccess.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















































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to suites and other suites which are available for usage.
 *
 * @since 2018/10/26
 */
public class SuiteAccess
{
	/**
	 * Returns the suites which are available for usage.
	 *
	 * @return The suites which are available for usage.
	 * @since 2018/10/26
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String[] availableSuites()
	{
		return new String[0];
	}
	
	/**
	 * Returns the current classpath that is being used.
	 *
	 * @return The current classpath.
	 * @since 2018/12/06
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String[] currentClassPath()
	{
		return new String[0];
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/SystemAccess.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





























































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to system related details.
 *
 * @since 2018/10/13
 */
public final class SystemAccess
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/13
	 */
	private SystemAccess()
	{
	}
	
	/**
	 * Exits the process with the system exit code.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void exit(int __code)
	{
		System.exit(__code);
	}
	
	/**
	 * Returns the specified environment variable, it is unspecified and
	 * system dependent if variables are case sensitive or not. Locale may
	 * be considered by the host system additionally. If environment variables
	 * do not exist in the environment then only {@code null} will be
	 * returned.
	 *
	 * @param __e The environment variable to get.
	 * @return The value of that variable or {@code null} if it is not set.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String getEnv(String __e)
	{
		return System.getenv(__e);
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/SystemProperties.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;

/**
 * Access to system properties.
 *
 * @since 2018/09/20
 */
public final class SystemProperties
{
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private SystemProperties()
	{
	}
	
	/**
	 * Returns the API level of the virtual machine.
	 *
	 * @return The API level.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static int apiLevel()
	{
		return ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225;
	}
	
	/**
	 * Returns the approximated path where the VM's executable exists. This
	 * will be the actual JVM's JAR or EXE file.
	 *
	 * @return The approximated executable path or {@code null} if it is not
	 * known.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String executablePath()
	{
		// Try using these methods
		try
		{
			// Try in the protection domain first
			ProtectionDomain pd = SystemProperties.class.getProtectionDomain();
			if (pd != null)
			{
				CodeSource cs = pd.getCodeSource();
				if (cs != null)
				{
					URL loc = cs.getLocation();
					if (loc != null)
					{
						String path = loc.getPath();
						if (path != null)
							return path;
					}
				}
			}
		}
		
		// Could not get
		catch (Throwable t)
		{
			return null;
		}
		
		// Unknown
		return null;
	}
	
	/**
	 * Returns the depth of the guests within the virtual machine.
	 *
	 * @return The number of guests.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int guestDepth()
	{
		return 0;
	}
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @since 2018/12/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String implementationClass(String __n)
	{
		return null;
	}
	
	/**
	 * Returns the e-mail to contact for the virtual machine.
	 *
	 * @return The contact e-mail for the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMEmail()
	{
		return "xer@multiphasicapps.net";
	}
	
	/**
	 * Returns the name of the Java virtual machine.
	 *
	 * @return The name of the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMName()
	{
		return "JavaSE Virtual Environment";
	}
	
	/**
	 * Returns the URL to the virtual machine's vendor's URL.
	 *
	 * @return The URL of the JVM's virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMURL()
	{
		return "http://multiphasicapps.net/";
	}
	
	/**
	 * Returns the vendor of the Java virtual machine.
	 *
	 * @return The vendor of the Java virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMVendor()
	{
		return "Stephanie Gawroriski";
	}
	
	/**
	 * Returns the full version of the Java virtual machine.
	 *
	 * @return The full Java virtual machine version.
	 * @since 2017/08/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMVersion()
	{
		return "0.3.0";
	}
	
	/**
	 * Returns the type of operating SquirrelJME is running on.
	 *
	 * @return The type of operating system SquirrelJME is running on.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int operatingSystemType()
	{
		return OperatingSystemType.UNKNOWN;
	}
	
	/**
	 * Returns a system property for the given value.
	 *
	 * @param __k The key to get.
	 * @return The value of the property, will be {@code null} if it is not
	 * valid.
	 * @since 2018/09/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String systemProperty(String __k)
	{
		return System.getProperty(__k);
	}
	
	/**
	 * Returns the version of the class libraries.
	 *
	 * @return The class library version.
	 * @since 2017/10/02
	 */
	public static String javaRuntimeVersion()
	{
		return SquirrelJME.RUNTIME_VERSION;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/TaskAccess.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
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






































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to tasks which are running.
 *
 * @since 2018/11/04
 */
public final class TaskAccess
{
	/** The entry point is not valid. */
	public static final int ERROR_INVALID_ENTRY =
		-2;
	
	/** Library in the classpath is missing. */
	public static final int ERROR_MISSING_LIBRARY =
		-3;
	
	/** Exit code indicating bad task things. */
	public static final int EXIT_CODE_FATAL_EXCEPTION =
		127;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private TaskAccess()
	{
	}
	
	/**
	 * Returns the ID of the current thread.
	 *
	 * @return The current thread ID.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int currentThread()
	{
		return (int)Thread.currentThread().getId();
	}
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __tid The thread ID.
	 * @param __p The priority.
	 * @since 2018/12/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void setThreadPriority(int __tid, int __p)
	{
		for (Thread t : Thread.getAllStackTraces().keySet())
			if ((int)t.getId() == __tid)
			{
				t.setPriority(__p);
				break;
			}
	}
	
	/**
	 * Signals a hardware interrupt on the given thread.
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void signalInterrupt(int __tid)
	{
		for (Thread t : Thread.getAllStackTraces().keySet())
			if ((int)t.getId() == __tid)
			{
				t.interrupt();
				break;
			}
	}
	
	/**
	 * Causes the thread to sleep for the given milliseconds and nanoseconds.
	 *
	 * If both values are zero this means to yield instead.
	 *
	 * @param __ms The milliseconds to sleep for.
	 * @param __ns The nanoseconds to sleep for, in the range of 0-999999.
	 * @return {@code true} if the thread was interrupted, otherwise
	 * {@code false}.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean sleep(long __ms, int __ns)
	{
		try
		{
			if (__ms == 0 && __ns == 0)
				Thread.yield();
			else
				Thread.sleep(__ms, __ns);
			
			return true;
		}
		catch (InterruptedException e)
		{
			return false;
		}
	}
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int startTask(String[] __cp, String __main,
		String[] __args)
	{
		return -1;
	}
	
	/**
	 * Starts the given thread.
	 *
	 * @param __t The thread which is to run, the execution point of the
	 * thread is the {@link Thread#__start()} method.
	 * @param __n The name hint of this thread.
	 * @return The thread ID.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int startThread(Thread __t, String __n)
	{
		__t.start();
		return (int)__t.getId();
	}
	
	/**
	 * Returns the status of the target task.
	 *
	 * @param __tid The task to get the status of.
	 * @return The status for the given task.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int taskStatus(int __tid)
	{
		return -1;
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/__KeyMap__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255































































































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import java.awt.event.KeyEvent;
import javax.microedition.lcdui.Canvas;

/**
 * Contains key mapping for Swing.
 *
 * @since 2018/12/01
 */
final class __KeyMap__
{
	/**
	 * Gets a character for a key event.
	 *
	 * @param __e The event to look up.
	 * @return The character for the key.
	 * @since 2018/12/02
	 */
	static final char __char(KeyEvent __e)
	{
		char ch = __e.getKeyChar();
		if (ch == KeyEvent.CHAR_UNDEFINED)
			return 0;
		return ch;
	}
	
	/**
	 * Maps the key event to a key.
	 *
	 * @param __e The event to map.
	 * @return The key it should do.
	 * @since 2018/12/01
	 */
	static final int __map(KeyEvent __e)
	{
		int keycode = __e.getExtendedKeyCode();
		switch (keycode)
		{
			case KeyEvent.VK_0:
			case KeyEvent.VK_1:
			case KeyEvent.VK_2:
			case KeyEvent.VK_3:
			case KeyEvent.VK_4:
			case KeyEvent.VK_5:
			case KeyEvent.VK_6:
			case KeyEvent.VK_7:
			case KeyEvent.VK_8:
			case KeyEvent.VK_9:
				return Canvas.KEY_NUM0 + (keycode - KeyEvent.VK_0);
			
			case KeyEvent.VK_NUMPAD0:
			case KeyEvent.VK_NUMPAD1:
			case KeyEvent.VK_NUMPAD2:
			case KeyEvent.VK_NUMPAD3:
			case KeyEvent.VK_NUMPAD4:
			case KeyEvent.VK_NUMPAD5:
			case KeyEvent.VK_NUMPAD6:
			case KeyEvent.VK_NUMPAD7:
			case KeyEvent.VK_NUMPAD8:
			case KeyEvent.VK_NUMPAD9:
				return Canvas.KEY_NUM0 +
					(keycode - KeyEvent.VK_NUMPAD0);
			
			case KeyEvent.VK_F1:
			case KeyEvent.VK_F2:
			case KeyEvent.VK_F3:
			case KeyEvent.VK_F4:
			case KeyEvent.VK_F5:
			case KeyEvent.VK_F6:
			case KeyEvent.VK_F7:
			case KeyEvent.VK_F8:
			case KeyEvent.VK_F9:
			case KeyEvent.VK_F10:
			case KeyEvent.VK_F11:
			case KeyEvent.VK_F12:
			case KeyEvent.VK_F13:
			case KeyEvent.VK_F14:
			case KeyEvent.VK_F15:
			case KeyEvent.VK_F16:
			case KeyEvent.VK_F17:
			case KeyEvent.VK_F18:
			case KeyEvent.VK_F19:
			case KeyEvent.VK_F20:
			case KeyEvent.VK_F21:
			case KeyEvent.VK_F22:
			case KeyEvent.VK_F23:
			case KeyEvent.VK_F24:
				return NonStandardKey.F1 +
					(keycode - KeyEvent.VK_F1);
					
				// Map the keyboard virtually onto a number pad so that
				// those without a number pad (such as myself) can actually
				// use the input in its natural order without
				// [q w e] > [1 2 3]
				// [a s d] > [4 5 6]
				// [z x c] > [7 8 9]
				// [v b n] > [* 0 #]
			case KeyEvent.VK_Q:					return Canvas.KEY_NUM1;
			case KeyEvent.VK_W:					return Canvas.KEY_NUM2;
			case KeyEvent.VK_E:					return Canvas.KEY_NUM3;
			case KeyEvent.VK_A:					return Canvas.KEY_NUM4;
			case KeyEvent.VK_S:					return Canvas.KEY_NUM5;
			case KeyEvent.VK_D:					return Canvas.KEY_NUM6;
			case KeyEvent.VK_Z:					return Canvas.KEY_NUM7;
			case KeyEvent.VK_X:					return Canvas.KEY_NUM8;
			case KeyEvent.VK_C:					return Canvas.KEY_NUM9;
			case KeyEvent.VK_V:					return Canvas.KEY_STAR;
			case KeyEvent.VK_B:					return Canvas.KEY_NUM0;
			case KeyEvent.VK_N:					return Canvas.KEY_POUND;

			case KeyEvent.VK_ADD:				return '+';
			case KeyEvent.VK_AMPERSAND:			return '&';
			case KeyEvent.VK_ASTERISK:			return Canvas.KEY_STAR;
			case KeyEvent.VK_AT:				return '@';
			case KeyEvent.VK_BACK_QUOTE:		return '`';
			case KeyEvent.VK_BACK_SLASH:		return '\\';
			case KeyEvent.VK_BRACELEFT:			return '{';
			case KeyEvent.VK_BRACERIGHT:		return '}';
			case KeyEvent.VK_CIRCUMFLEX:		return '^';
			case KeyEvent.VK_CLOSE_BRACKET:		return ']';
			case KeyEvent.VK_COLON:				return ':';
			case KeyEvent.VK_COMMA:				return ',';
			case KeyEvent.VK_DECIMAL:			return '.';
			case KeyEvent.VK_DIVIDE:			return '/';
			case KeyEvent.VK_DOLLAR:			return '$';
			case KeyEvent.VK_EQUALS:			return '=';
			case KeyEvent.VK_EURO_SIGN:			return 0x20AC;
			case KeyEvent.VK_EXCLAMATION_MARK:	return '!';
			case KeyEvent.VK_GREATER:			return '>';
			case KeyEvent.VK_LEFT_PARENTHESIS:	return '(';
			case KeyEvent.VK_LESS:				return '<';
			case KeyEvent.VK_MINUS:				return '-';
			case KeyEvent.VK_MULTIPLY:			return '*';
			case KeyEvent.VK_NUMBER_SIGN:		return Canvas.KEY_POUND;
			case KeyEvent.VK_OPEN_BRACKET:		return '[';
			case KeyEvent.VK_RIGHT_PARENTHESIS:	return ')';
			case KeyEvent.VK_PERIOD:			return '.';
			case KeyEvent.VK_PLUS:				return '+';
			case KeyEvent.VK_QUOTE:				return '\'';
			case KeyEvent.VK_QUOTEDBL:			return '"';
			case KeyEvent.VK_SEMICOLON:			return ';';
			case KeyEvent.VK_SLASH:				return '/';
			case KeyEvent.VK_SPACE:				return ' ';
			case KeyEvent.VK_SUBTRACT:			return '-';
			case KeyEvent.VK_TAB:				return '\t';
			case KeyEvent.VK_UNDERSCORE:		return '_';

			case KeyEvent.VK_ALT:
				return NonStandardKey.ALT;

			case KeyEvent.VK_BACK_SPACE:
				return Canvas.KEY_BACKSPACE;

			case KeyEvent.VK_CAPS_LOCK:
				return NonStandardKey.CAPSLOCK;

			case KeyEvent.VK_CONTEXT_MENU:
				return NonStandardKey.CONTEXT_MENU;

			case KeyEvent.VK_CONTROL:
				return NonStandardKey.CONTROL;

			case KeyEvent.VK_DELETE:
				return Canvas.KEY_DELETE;

			case KeyEvent.VK_DOWN:
				return Canvas.KEY_DOWN;

			case KeyEvent.VK_END:
				return NonStandardKey.END;

			case KeyEvent.VK_ENTER:
				return Canvas.KEY_ENTER;

			case KeyEvent.VK_ESCAPE:
				return Canvas.KEY_ESCAPE;

			case KeyEvent.VK_HOME:
				return NonStandardKey.HOME;

			case KeyEvent.VK_INSERT:
				return NonStandardKey.INSERT;

			case KeyEvent.VK_KP_DOWN:
				return Canvas.KEY_DOWN;

			case KeyEvent.VK_KP_LEFT:
				return Canvas.KEY_LEFT;

			case KeyEvent.VK_KP_RIGHT:
				return Canvas.KEY_RIGHT;

			case KeyEvent.VK_KP_UP:
				return Canvas.KEY_UP;

			case KeyEvent.VK_LEFT:
				return Canvas.KEY_LEFT;

			case KeyEvent.VK_META:
				return NonStandardKey.META;

			case KeyEvent.VK_NUM_LOCK:
				return NonStandardKey.NUMLOCK;

			case KeyEvent.VK_PAGE_DOWN:
				return NonStandardKey.PAGE_DOWN;

			case KeyEvent.VK_PAGE_UP:
				return NonStandardKey.PAGE_UP;

			case KeyEvent.VK_PAUSE:
				return NonStandardKey.PAUSE;

			case KeyEvent.VK_PRINTSCREEN:
				return NonStandardKey.PRINTSCREEN;

			case KeyEvent.VK_RIGHT:
				return Canvas.KEY_RIGHT;

			case KeyEvent.VK_SCROLL_LOCK:
				return NonStandardKey.SCROLLLOCK;

			case KeyEvent.VK_SHIFT:
				return NonStandardKey.SHIFT;

			case KeyEvent.VK_UP:
				return Canvas.KEY_UP;

			case KeyEvent.VK_WINDOWS:
				return NonStandardKey.LOGO;
			
				// Probably a character
			default:
				// Shift is not handled because these are raw key codes
				if (keycode >= KeyEvent.VK_A && keycode <= KeyEvent.VK_Z)
					return 'A' + (keycode - KeyEvent.VK_A);
				
				// Unknown
				return NonStandardKey.UNKNOWN;
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/__WeakRef__.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
66
67
68
69
70
71
72
73
74










































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.ref.PrimitiveWeakReference;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * Primitive weak reference.
 *
 * @since 2018/12/05
 */
class __WeakRef__
	implements PrimitiveWeakReference
{
	/** The reference. */
	volatile Reference<Object> _ref;
	
	/**
	 * Gets the value.
	 *
	 * @return The value.
	 * @since 2018/12/05
	 */
	final Object __get()
	{
		synchronized (this)
		{
			Reference<Object> ref = this._ref;
			if (ref == null)
				return null;
			return ref.get();
		}
	}
	
	/**
	 * Sets the value.
	 *
	 * @param __v The value.
	 * @since 2018/12/05
	 */
	final void __set(Object __v)
	{
		synchronized (this)
		{
			Reference<Object> ref = this._ref;
			
			// {@squirreljme.error AF04 Cannot set weak reference which has
			// already been set.}
			if (__v == null)
				if (ref == null)
				{
					// Do nothing
				}
				else
					ref.clear();
			else
				if (ref == null)
					this._ref = new WeakReference<>(__v);
				else
					throw new Error("AF04");
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/JavaSEIPConnectionFactory.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.javase;

import cc.squirreljme.runtime.gcf.IPAddress;
import cc.squirreljme.runtime.gcf.IPConnectionFactory;
import cc.squirreljme.runtime.gcf.TCPClientConnection;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.SocketConnection;

/**
 * This is a connection factory for IP based connection which is built on top
 * of Java SE's networking support.
 *
 * @since 2019/05/12
 */
public class JavaSEIPConnectionFactory
	extends IPConnectionFactory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final IPAddress resolveAddress(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		// Try to resolve it
		try
		{
			// Resolve and build new address
			return new IPAddress(InetAddress.getByName(__addr.hostname).
				getHostAddress(), __addr.port);
		}
		
		// {@squirreljme.error AF05 Unknown host.}
		catch (UnknownHostException e)
		{
			IOException t = new ConnectionNotFoundException("AF05");
			t.initCause(e);
			throw t;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final TCPClientConnection tcpClientConnect(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		// Create and wrap socket
		return new JavaSETCPClientConnection(__addr,
			new Socket(__addr.hostname, __addr.port));
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/JavaSETCPClientConnection.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.javase;

import cc.squirreljme.runtime.gcf.IPAddress;
import cc.squirreljme.runtime.gcf.IPConnectionFactory;
import cc.squirreljme.runtime.gcf.TCPClientConnection;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.SocketConnection;

/**
 * This is a TCP client connection that is backed on top of Java SE.
 *
 * @since 2019/05/12
 */
public class JavaSETCPClientConnection
	extends TCPClientConnection
{
	/** The socket this connects through. */
	protected final Socket socket;
	
	/** Default receive buffer size for this socket. */
	protected final int defrbs;
	
	/** Default send buffer size for this socket. */
	protected final int defsbs;
	
	/** Default timeout. */
	protected final int deftim;
	
	/**
	 * Initializes the wrapped socket.
	 *
	 * @param __addr The target address.
	 * @param __sock The socket to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public JavaSETCPClientConnection(IPAddress __addr, Socket __sock)
		throws NullPointerException
	{
		super(__addr);
		
		if (__sock == null)
			throw new NullPointerException("NARG");
		
		this.socket = __sock;
		
		// Get default buffer sizes for setting back
		int defrbs = 512,
			defsbs = 512,
			deftim = 0;
		try
		{
			defrbs = __sock.getReceiveBufferSize();
			defsbs = __sock.getSendBufferSize();
			deftim = __sock.getSoTimeout();
		}
		catch (SocketException e)
		{
		}
		
		// Set
		this.defrbs = defrbs;
		this.defsbs = defsbs;
		this.deftim = deftim;
	}
	
	/**
	 * Performs connection close.
	 *
	 * @throws IOException If it could not be closed.
	 * @since 2019/05/13
	 */
	protected final void doClose()
		throws IOException
	{
		this.socket.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	protected final InputStream doOpenInputStream()
		throws IOException
	{
		return socket.getInputStream();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	protected final OutputStream doOpenOutputStream()
		throws IOException
	{
		return socket.getOutputStream();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	protected final void doSetSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException
	{
		Socket socket = this.socket;
		switch (__o)
		{
			case DELAY:
				socket.setTcpNoDelay(__v == 0);
				break;
			
			case KEEPALIVE:
				socket.setKeepAlive(__v != 0);
				break;
			
			case LINGER:
				socket.setSoLinger(__v != 0, __v);
				break;
			
			case RCVBUF:
				if (__v == 0)
					socket.setReceiveBufferSize(this.defrbs);
				else
					socket.setReceiveBufferSize(__v);
				break;
			
			case SNDBUF:
				if (__v == 0)
					socket.setSendBufferSize(this.defsbs);
				else
					socket.setSendBufferSize(__v);
				break;
			
			case TIMEOUT:
				if (__v == 0)
					socket.setSoTimeout(this.deftim);
				else
					socket.setSoTimeout(__v);
				break;
			
			default:
				throw new todo.TODO();
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/Main.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255































































































































































































































































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

package cc.squirreljme.runtime.javase;

import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.Objects;
import javax.microedition.midlet.MIDlet;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This initializes the SquirrelJME CLDC run-time interfaces and provides a
 * bridge so that the run-time functions properly on non-SquirrelJME Java VMs.
 *
 * @since 2017/12/07
 */
public class Main
{
	/** Property which specifies the client main entry point. */
	public static final String CLIENT_MAIN =
		"cc.squirreljme.runtime.javase.clientmain";
	
	/** Property specifying the main entry point for server entries. */
	public static final String SERVER_MAIN =
		"cc.squirreljme.runtime.javase.servermain";
	
	/** The file which was passed. */
	public static final String FILE_PROPERTY =
		"cc.squirreljme.runtime.javase.file";
	
	/**
	 * {@squirreljme.property cc.squirreljme.runtime.javase.program=(id)
	 * The program to run when launching.}
	 */
	public static final String PROGRAM =
		"cc.squirreljme.runtime.javase.program";
	
	/**
	 * Wrapped main entry point.
	 *
	 * @param __args Program arguments, these are forwarded.
	 * @throws Throwable On any kind of throwable.
	 * @since 2017/12/07
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// These are launch parameters which are used by the actual Java SE
		// wrappers to spawn new tasks
		String servermain = System.getProperty(SERVER_MAIN),
			clientmain = System.getProperty(CLIENT_MAIN);
		boolean isclient = (servermain != null ? false : clientmain != null);
		
		// Initialize the run-time which sets up the SquirrelJME specific
		// APIs
		__initializeRunTime(isclient);
		
		// Try to extract from the program
		int pdx = Integer.getInteger(Main.PROGRAM, -1);
		String fprop = System.getProperty(FILE_PROPERTY);
		if (pdx < 0 && fprop != null)
		{
			int col = fprop.lastIndexOf(':');
			if (col >= 0)
				try
				{
					pdx = Integer.valueOf(fprop.substring(col + 1));
				}
				catch (NumberFormatException e)
				{
				}
		}
		
		// Search through programs to find the entry point desired
		String mainclassname;
		if (pdx >= 0)
		{
			// Need to go through all the URLs and find the midlet containing
			// entry points to be parsed. However since there is no way to
			// know which manifest in the classpath refers to the midlet we
			// kinda just have to guess
			List<URL> urls = Collections.<URL>list(Main.class.getClassLoader().
				getResources("META-INF/MANIFEST.MF"));
			EntryPoints entries = null;
			for (int i = 0, n = urls.size(); i < n; i++)
			{
				// Read in the manifest
				JavaManifest man;
				try (InputStream in = urls.get(i).openStream())
				{
					man = new JavaManifest(in);
				}
				
				// If this refers to a midlet then use it
				if (man.getMainAttributes().definesValue("midlet-name"))
				{
					entries = new EntryPoints(man);
					break;
				}
			}
			
			// {@squirreljme.error AF06 No entry points were found.}
			if (entries == null)
				throw new IllegalArgumentException("AF06");
			
			// Print them out for debug
			System.err.println("Entry points:");
			int n = entries.size();
			for (int i = 0; i < n; i++)
				System.err.printf("    %d: %s%n", i, entries.get(i));
			
			// If the entry is out of bounds just use the first one
			if (pdx < 0 || pdx >= n)
				pdx = 0;
			
			// Use that entry point
			mainclassname = entries.get(pdx).entryPoint();
		}
		
		// Using the old standard method of launching
		else
		{
			// The client just uses the specified main class
			if (isclient)
				mainclassname = clientmain;
			
			// Determines the class name via manifest
			else
				if (servermain != null)
					mainclassname = servermain;
				else
					mainclassname = __mainClassByManifest();
		}
		
		// Exceptions generated as of the result of the method call are
		// wrapped so they must be unwrapped
		try
		{
			Class<?> mainclass = Class.forName(mainclassname);
			
			// Try initializing with a main method
			try
			{
				// {@squirreljme.error AF07 The main method is not static.}
				Method mainmethod = mainclass.getMethod("main",
					String[].class);
				if ((mainmethod.getModifiers() & Modifier.STATIC) == 0)
					throw new RuntimeException("AF07");
				
				// Call it
				mainmethod.invoke(null, new Object[]{__args});
				
				// All okay!
				return;
			}
			
			// Does not exist
			catch (NoSuchMethodException e)
			{
			}
			
			// Construct new object but only say start is valid once it
			// has been fully constructed
			MIDlet mid = (MIDlet)mainclass.newInstance();
			
			// startApp is protected so it has to be made callable
			Method startmethod = MIDlet.class.getDeclaredMethod(
				"startApp");
			startmethod.setAccessible(true);
			
			// Invoke the start method
			startmethod.invoke(mid);
		}
		
		// Completely hide call exceptions
		catch (InvocationTargetException e)
		{
			Throwable c = e.getCause();
			if (c != null)
				throw c;
			else
				throw e;
		}
	}
	
	/**
	 * Initializes the run-time.
	 *
	 * @param __client If {@code true} then it is initialized for the client.
	 * @throws Throwable On any throwable.
	 * @since 2017/12/07
	 */
	private static void __initializeRunTime(boolean __client)
		throws Throwable
	{
		// Initialize anything needed for the client
		if (__client)
		{
			System.err.println("SquirrelJME Client Launch!");
		}
	}
	
	/**
	 * Returns the main class obtained by the manifest.
	 *
	 * @return The main manifest class.
	 * @throws Throwable On any throwable
	 * @since 2017/12/07
	 */
	private static String __mainClassByManifest()
		throws Throwable
	{
		// Determine the main class to actually call using the copied
		// manifest
		try (InputStream is = Main.class.getResourceAsStream(
			"/SQUIRRELJME-BOOTSTRAP.MF"))
		{
			// {@squirreljme.error AF08 No manifest is available?}
			if (is == null)
				throw new RuntimeException("AF08");
		
			// {@squirreljme.error AF09 No main class is available?}
			String mainclassname = new Manifest(is).getMainAttributes().
				getValue("Main-Class");
			if (mainclassname == null || mainclassname.isEmpty())
				throw new RuntimeException("AF09");
			return mainclassname;
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/SYSTEM.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-API-Name: Java SE Runtime
X-SquirrelJME-API-Vendor: Stephanie Gawroriski
X-SquirrelJME-API-Version: 0.2.0
X-SquirrelJME-API-Description: This permits the SquirrelJME APIs to be 
 ran on a Java SE host virtualizing as best as it can.
X-SquirrelJME-DefinedConfigurations: CLDC-1.8 CLDC-1.8-Compact 
 CLDC-1.1 CLDC-1.0
X-SquirrelJME-DefinedProfiles: MIDP-1.0 MIDP-2.0 MIDP-2.1 MEEP-8.0

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/lcdui/ColorInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252




























































































































































































































































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

package cc.squirreljme.runtime.javase.lcdui;

import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
import java.awt.image.DataBufferShort;
import java.awt.image.IndexColorModel;
import java.awt.Transparency;

/**
 * The type of color information to use.
 *
 * @since 2018/03/24
 */
@Deprecated
public final class ColorInfo
{
	/**
	 * {@squirreljme.property cc.squirreljme.runtime.javase.lcdui.pixelformat=f
	 * This selects the format to use for the display when creating images.}
	 */
	public static final String PIXEL_FORMAT_PROPERTY =
		"cc.squirreljme.runtime.javase.lcdui.pixelformat";
	
	/** The pixel format of the frame. */
	public static final PixelFormat PIXEL_FORMAT;
	
	/** The type of image to create. */
	public static final int IMAGE_TYPE;
	
	/** The color model to use. */
	public static final IndexColorModel COLOR_MODEL;
	
	/**
	 * Initializes the color information.
	 *
	 * @since 2018/03/24
	 */
	static
	{
		// Set the pixel format
		PixelFormat pf;
		PIXEL_FORMAT = (pf = PixelFormat.valueOf(
			System.getProperty(PIXEL_FORMAT_PROPERTY, "INTEGER_RGB888")));
		
		// Set the type of data to use for buffered images
		int btype;
		IndexColorModel icm;
		switch (pf)
		{
			case BYTE_INDEXED1:
				btype = BufferedImage.TYPE_BYTE_BINARY;
				icm = new IndexColorModel(1, 2, new int[]{
					0xFF000000, 0xFFFFFFFF}, 0, false, Transparency.OPAQUE,
					DataBuffer.TYPE_BYTE);
				break;
				
			case BYTE_INDEXED2:
				btype = BufferedImage.TYPE_BYTE_BINARY;
				icm = new IndexColorModel(2, 4, new int[]{
					0xFF_000000,
					0xFF_55FFFF,
					0xFF_FF55FF,
					0xFF_FFFFFF}, 0, false, Transparency.OPAQUE,
					DataBuffer.TYPE_BYTE);
				break;
				
			case BYTE_INDEXED4:
				btype = BufferedImage.TYPE_BYTE_BINARY;
				icm = new IndexColorModel(4, 16, new int[]{
					0xFF_000000,
					0xFF_808080,
					0xFF_C0C0C0,
					0xFF_FFFFFF,
					0xFF_800000,
					0xFF_FF0000,
					0xFF_808000,
					0xFF_FFFFFF,
					0xFF_008000,
					0xFF_00FF00,
					0xFF_008080,
					0xFF_00FFFF,
					0xFF_000080,
					0xFF_0000FF,
					0xFF_800080,
					0xFF_FF00FF,
					}, 0, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
				break;
				
			case BYTE_INDEXED8:
				btype = BufferedImage.TYPE_BYTE_INDEXED;
				throw new todo.TODO();
				
			case SHORT_RGB565:
				btype = BufferedImage.TYPE_USHORT_565_RGB;
				icm = null;
				break;
				
			case INTEGER_ARGB8888:
				btype = BufferedImage.TYPE_INT_ARGB;
				icm = null;
				break;
				
			case INTEGER_RGB888:
				btype = BufferedImage.TYPE_INT_RGB;
				icm = null;
				break;
			
				// {@squirreljme.error AF0a Cannot use the specified pixel
				// format. (The pixel format to use)}
			case BYTE_RGB332:
			case SHORT_INDEXED16:
			case SHORT_ARGB4444:
				throw new RuntimeException(String.format("AF0a %s", pf));
			
			default:
				throw new todo.OOPS();
		}
		
		// Store
		IMAGE_TYPE = btype;
		COLOR_MODEL = icm;
	}
	
	/**
	 * Creates a buffered image using the color parameters.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @param __c The initial color.
	 * @return The resulting image.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static BufferedImage create(int __w, int __h, Color __c)
		throws NullPointerException
	{
		BufferedImage rv;
		
		// Setup image
		IndexColorModel icm = ColorInfo.COLOR_MODEL;
		if (icm != null)
			rv = new BufferedImage(__w, __h, ColorInfo.IMAGE_TYPE, icm);
		else
			rv = new BufferedImage(__w, __h, ColorInfo.IMAGE_TYPE);
		
		// Fill the background with the default background color
		Graphics2D g = (Graphics2D)rv.getGraphics();
		g.setColor(__c);
		g.fillRect(0, 0, __w, __h);
		
		return rv;
	}
	
	/**
	 * Returns the array for the given image.
	 *
	 * @param __bi The buffer to read from.
	 * @return The array for the image data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static Object getArray(BufferedImage __bi)
		throws NullPointerException
	{
		if (__bi == null)
			throw new NullPointerException("NARG");
		
		DataBuffer db = __bi.getRaster().getDataBuffer();
		PixelFormat pf;
		switch ((pf = ColorInfo.PIXEL_FORMAT))
		{
			case BYTE_INDEXED1:
			case BYTE_INDEXED2:
			case BYTE_INDEXED4:
			case BYTE_INDEXED8:
			case BYTE_RGB332:
				return ((DataBufferByte)db).getData();
				
			case SHORT_INDEXED16:
			case SHORT_ARGB4444:
			case SHORT_RGB565:
				return ((DataBufferShort)db).getData();
				
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return ((DataBufferInt)db).getData();
			
				// {@squirreljme.error AF0b Unsupported pixel format.
				// (The pixel format to use)}
			default:
				throw new RuntimeException(String.format("AF0b %s", pf));
		}
	}
	
	/**
	 * Returns the palette to be used for the given image.
	 *
	 * @param __bi The palette to get for the image.
	 * @return The resulting palette or {@code null} if there is none.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/02/24
	 */
	public static int[] getPalette(BufferedImage __bi)
		throws NullPointerException
	{
		if (__bi == null)
			throw new NullPointerException("NARG");
		
		IndexColorModel model = ColorInfo.COLOR_MODEL;
		PixelFormat pf;
		switch ((pf = ColorInfo.PIXEL_FORMAT))
		{
			case BYTE_INDEXED1:
			case BYTE_INDEXED2:
			case BYTE_INDEXED4:
			case BYTE_INDEXED8:
			case SHORT_INDEXED16:
				int n = model.getNumColorComponents();
				int[] rv = new int[n];
				model.getRGBs(rv);
				return rv;
				
			case BYTE_RGB332:
			case SHORT_ARGB4444:
			case SHORT_RGB565:
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return null;
			
				// {@squirreljme.error AF0c Unsupported pixel format.
				// (The pixel format to use)}
			default:
				throw new RuntimeException(String.format("AF0c %s", pf));
		}
	}
}

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/lcdui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















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

/**
 * This contains support for the LCDUI API and provides display heads which
 * output to Swing.
 *
 * @since 2017/11/09
 */

package cc.squirreljme.runtime.javase.lcdui;

Deleted bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/javase/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















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

/**
 * This package contains the support for SquirrelJME which runs on an existing
 * Java SE run-time by providing basic support for implemented classes and
 * such.
 *
 * @since 2017/11/09
 */

package cc.squirreljme.runtime.javase;

Deleted bldt/libs/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Build Support Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: This project contains support for the
 build system libraries and their support platform.

Deleted bldt/libs/builder-implementation/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 77ca1f69-76f9-402f-a7b1-c89d7e312c60
X-SquirrelJME-Error: AG
X-SquirrelJME-Name: Builder Implementation
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the entry system which runs 
 on Java ME environments such as SquirrelJME. This allows for example 
 SquirrelJME to build itself.
Microedition-Configuration: CLDC-1.8

Deleted bldt/libs/builder-support/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: fda7df14-a58f-4781-8f8f-336111c7aec2
X-SquirrelJME-Error: AU
X-SquirrelJME-Name: Build System Support
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: collections tool-manifest-reader meep-swm 
 tool-manifest-writer zip meep-midlet tool-compiler io all-vms 
 tool-packfile palmos-utils
X-SquirrelJME-Description: This contains basic support for the build 
 system and project manager. The interfaces declared by this class 
 must be implemented in order for the build system to be functional.
Microedition-Configuration: CLDC-1.8

Deleted bldt/libs/builder-support/META-INF/services/cc.squirreljme.builder.support.dist.DistBuilder.

1
2
3
4
5
6






-
-
-
-
-
-
cc.squirreljme.builder.support.dist.ShadedJavaMEDist
cc.squirreljme.builder.support.dist.ShadedJavaSEDist
cc.squirreljme.builder.support.dist.SummerCoatROM
cc.squirreljme.builder.support.dist.SummerCoatROMTest
cc.squirreljme.builder.support.dist.PalmOSDist

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/BasicSource.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
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

















































































































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

package cc.squirreljme.builder.support;

import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.FilePathSet;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This represents a project which exists solely in the filesystem and does
 * not have virtually generated parts.
 *
 * @since 2018/03/06
 */
public final class BasicSource
	extends Source
{
	/** The path to the source code root. */
	protected final Path root;
	
	/** The manifest for this source. */
	private Reference<JavaManifest> _manifest;
	
	/**
	 * Initializes the project source.
	 *
	 * @param __name The name of the source.
	 * @param __p The path to the source code.
	 * @param __t The type of project this is.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public BasicSource(SourceName __name, Path __p, ProjectType __t)
		throws NullPointerException
	{
		super(__name, __t);
		
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.root = __p;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final CompilerPathSet pathSet(SourcePathSetType __spst)
		throws NullPointerException
	{
		if (__spst == null)
			throw new NullPointerException("NARG");
		
		// The same path set is used for compilation and for sources
		return new FilePathSet(this.root);
	}
	
	/**
	 * Returns the root directory of the project source code.
	 *
	 * @return The project source code root.
	 * @since 2017/11/28
	 */
	public final Path root()
	{
		return this.root;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final JavaManifest sourceManifest()
	{
		Reference<JavaManifest> ref = this._manifest;
		JavaManifest rv;
		
		if (ref == null || null == (rv = ref.get()))
			try (CompilerPathSet ps = this.pathSet(SourcePathSetType.SOURCE);
				InputStream in = ps.input("META-INF/MANIFEST.MF").open())
			{
				this._manifest = new WeakReference<>(
					(rv = new JavaManifest(in)));
			}
			
			// {@squirreljme.error AU01 Could not read the source manifest.}
			catch (IOException|CompilerException e)
			{
				throw new NoSuchSourceException("AU01", e);
			}
		
		return rv;
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/Binary.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360








































































































































































































































































































































































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

package cc.squirreljme.builder.support;

import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import cc.squirreljme.runtime.swm.SuiteInfo;
import cc.squirreljme.runtime.swm.SuiteName;
import cc.squirreljme.runtime.swm.SuiteVendor;
import cc.squirreljme.runtime.swm.SuiteVersion;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileTime;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.ZipPathSet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.zip.blockreader.FileChannelBlockAccessor;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This class represents a binary which has been loaded by the binary manager.
 *
 * @since 2017/10/31
 */
public final class Binary
{
	/** The name of this binary. */
	protected final SourceName name;
	
	/** The source code for this binary, may be null if there is none. */
	protected final Source source;
	
	/** The path to the binary for this executable. */
	protected final Path path;
	
	/** The cached manifest for this entry. */
	private Reference<JavaManifest> _manifest;
	
	/** The suite information. */
	private Reference<SuiteInfo> _suiteinfo;
	
	/**
	 * Initializes the binary.
	 *
	 * @param __name The name of this binary.
	 * @param __source The source of this binary, may be {@code null} if there
	 * is no source.
	 * @throws InvalidBinaryException If the tiven 
	 * @throws NoSuchBinaryException If the given binary does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/02
	 */
	Binary(SourceName __name, Source __source, Path __path)
		throws InvalidBinaryException, NoSuchBinaryException,
			NullPointerException
	{
		if (__name == null || __path == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.source = __source;
		this.path = __path;
	}
	
	/**
	 * Returns the input stream over the binary itself.
	 *
	 * @return The input stream over the binary.
	 * @throws IOException On read errors.
	 * @since 2017/11/17
	 */
	public final InputStream inputStream()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns if the binary is newer.
	 *
	 * @return If the binary is newer.
	 * @since 2017/11/06
	 */
	public final boolean isBinaryNewer()
	{
		Source source = this.source;
		return lastModifiedTime() >=
			(source != null ? source.lastModifiedTime() : Long.MIN_VALUE);
	}
	
	/**
	 * Returns if the source code is newer.
	 *
	 * @return If the source is newer.
	 * @since 2017/11/06
	 */
	public final boolean isSourceNewer()
	{
		return !isBinaryNewer();
	}
	
	/**
	 * Returns the time that the binary was last modified.
	 *
	 * @return The time the binary was last modified.
	 * @since 2017/11/06
	 */
	public final long lastModifiedTime()
	{
		// The file might not actually exist if it has not been built
		try
		{
			FileTime t = Files.getLastModifiedTime(this.path);
			if (t != null)
				return t.toMillis();
			return Long.MIN_VALUE;
		}
		
		// File does not exist or another error, so unknown an unknown time
		catch (IOException e)
		{
			return Long.MIN_VALUE;
		}
	}
	
	/**
	 * Returns the manifest for this binary.
	 *
	 * @return The manifest for this project.
	 * @since 2017/11/05
	 */
	public final JavaManifest manifest()
	{
		// Approximate the manifest to use
		if (isSourceNewer())
			return this.source.manifest();
		
		// Open the binary instead
		try (ZipBlockReader zip = zipBlock())
		{
			try (InputStream in = zip.open("META-INF/MANIFEST.MF"))
			{
				return new JavaManifest(in);
			}
		}
		
		// {@squirreljme.error AU02 Could not read the binary manifest.}
		catch (IOException e)
		{
			throw new InvalidBinaryException("AU02", e);
		}
	}
	
	/**
	 * Returns a dependency match result which contains the results of a
	 * dependency match between the provided dependencies and the provided
	 * dependencies for this project.
	 *
	 * @param __d The input dependencies to check.
	 * @return The result of the match.
	 * @throws NullPointerException On null arguments.
	 * @sine 2017/11/30
	 */
	public final MatchResult matchedDependencies(DependencyInfo __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		return __d.match(this.suiteInfo().provided());
	}
	
	/**
	 * Returns the name of the project.
	 *
	 * @return The project name.
	 * @since 2017/11/02
	 */
	public final SourceName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the path to the binary.
	 *
	 * @return The binary path.
	 * @since 2017/11/28
	 */
	public final Path path()
	{
		return this.path;
	}
	
	/**
	 * Returns the path set which represents the binary.
	 *
	 * @return The path set for this binary
	 * @since 2019/06/12
	 */
	public final CompilerPathSet pathSet()
		throws IOException, NullPointerException
	{
		// Just wrap the ZIP
		try
		{
			return new ZipPathSet(this.zipBlock());
		}
		
		// {@squirreljme.error AU03 Could not get the path set for this
		// binary.}
		catch (IOException e)
		{
			throw new CompilerException("AU03", e);
		}
	}
	
	/**
	 * Returns the source project that this binary is built from.
	 *
	 * @return The source project or {@code null} if there is no source.
	 * @since 2017/11/06
	 */
	public final Source source()
	{
		return this.source;
	}
	
	/**
	 * Returns the suite information for this binary.
	 *
	 * @return The binary suite information.
	 * @since 2017/11/29
	 */
	public final SuiteInfo suiteInfo()
	{
		// Use binary information
		if (isBinaryNewer())
		{
			Reference<SuiteInfo> ref = this._suiteinfo;
			SuiteInfo rv;
		
			if (ref == null || null == (rv = ref.get()))
				this._suiteinfo = new WeakReference<>((rv =
					new SuiteInfo(this.manifest())));
			
			return rv;
		}
		
		// {@squirreljme.error AU04 Cannot get suite information for the
		// binary because there is no source code.}
		Source source = this.source;
		if (source == null)
			throw new InvalidBinaryException("AU04");
		return this.source.suiteInfo();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/02/28
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
	
	/**
	 * Returns the type of project that this is.
	 *
	 * @return The project type.
	 * @since 2017/11/26
	 */
	public final ProjectType type()
	{
		JavaManifestAttributes attr = this.manifest().getMainAttributes();
		
		// Midlet?
		if (attr.definesValue("midlet-name"))
			return ProjectType.MIDLET;
		
		// APIs are like liblets but have a special flag to them
		else if ("true".equals(attr.getValue("x-squirreljme-isapi")))
			return ProjectType.API;
		
		// Otherwise everything else is a liblet
		return ProjectType.LIBLET;
	}
	
	/**
	 * Opens the binary as a ZIP file for reading the contents.
	 *
	 * @return The reader for the ZIP file as a block.
	 * @throws IOException On read errors.
	 * @since 2017/11/06
	 */
	public final ZipBlockReader zipBlock()
		throws IOException
	{
		// {@squirreljme.error AU05 Cannot get the ZIP for this binary because
		// it is out of date. (The name of this binary)}
		if (isSourceNewer())
			throw new OutOfDateBinaryException(
				String.format("AU05 %s", this.name));
		
		// Open it
		return new ZipBlockReader(new FileChannelBlockAccessor(this.path));
	}
	
	/**
	 * Opens the binary as a ZIP stream for reading the contents.
	 *
	 * @return The stream over the ZIP's contents.
	 * @throws IOException On read errors.
	 * @since 2017/11/02
	 */
	public final ZipStreamReader zipStream()
		throws IOException
	{
		// {@squirreljme.error AU06 Cannot get the ZIP for this binary because
		// it is out of date. (The name of this binary)}
		if (isSourceNewer())
			throw new OutOfDateBinaryException(
				String.format("AU06 %s", this.name));
		
		return new ZipStreamReader(Files.newInputStream(this.path,
			StandardOpenOption.READ));
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/BinaryManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700




























































































































































































































































































































































































































































































































































































































































































































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

package cc.squirreljme.builder.support;

import cc.squirreljme.runtime.swm.Configuration;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.MarkedProvided;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.Profile;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import cc.squirreljme.runtime.swm.Standard;
import cc.squirreljme.runtime.swm.SuiteDependency;
import cc.squirreljme.runtime.swm.SuiteDependencyLevel;
import cc.squirreljme.runtime.swm.SuiteDependencyType;
import cc.squirreljme.runtime.swm.SuiteInfo;
import cc.squirreljme.runtime.swm.SuiteName;
import cc.squirreljme.runtime.swm.SuiteVersion;
import cc.squirreljme.runtime.swm.SuiteVersionRange;
import java.io.Closeable;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.multiphasicapps.collections.CloseableList;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableCollection;
import net.multiphasicapps.io.MIMEFileDecoder;
import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerOutput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.DefaultCompiler;
import net.multiphasicapps.javac.FilePathSet;
import net.multiphasicapps.javac.MergedPathSet;
import net.multiphasicapps.javac.ZipCompilerOutput;
import net.multiphasicapps.javac.ZipPathSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;
import net.multiphasicapps.zip.streamwriter.ZipStreamWriter;

/**
 * This class is used to manage binaries which are available for running
 * and/or compilation.
 *
 * @since 2017/10/31
 */
public final class BinaryManager
	implements Iterable<Binary>
{
	/** The output directory where built binaries are to be placed. */
	protected final Path output;
	
	/** Projects which may exist that provide access to source code. */
	protected final SourceManager sources;
	
	/** Projects which have been read by the manager. */
	private final Map<SourceName, Binary> _binaries =
		new SortedTreeMap<>();
	
	/**
	 * Initializes the binary manager.
	 *
	 * @param __out The output directory, this directory is scanned for
	 * binaries as requested.
	 * @param __src The source code where projects may be sourced from, may
	 * be {@code null} if there is no source code.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException If no output path was specified.
	 * @since 2017/10/31
	 */
	public BinaryManager(Path __out, SourceManager __src)
		throws IOException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.output = __out;
		this.sources = __src;
		
		// Load in binaries from source code first
		Map<SourceName, Binary> binaries = this._binaries;
		for (Source src : __src)
		{
			SourceName name = src.name();
			binaries.put(name,
				new Binary(name, src, __out.resolve(name.toFileName())));
		}
		
		// Go through directory containing binaries and try building binaries
		// that have no source
		try (DirectoryStream<Path> ds = Files.newDirectoryStream(__out))
		{
			for (Path p : ds)
			{
				// Ignore directories and non-binary files
				if (Files.isDirectory(p) || !SourceName.isBinaryPath(p))
					continue;
				
				// Only add a binary if it does not exist, this allows one
				// to add external binaries
				SourceName name = SourceName.ofBinaryPath(p);
				Binary bin = binaries.get(name);
				if (bin == null)
					binaries.put(name, new Binary(name, null, p));
			}
		}
		
		// Ignore these
		catch (NoSuchFileException e)
		{
		}
	}
	
	/**
	 * Returns the class path for the given binary.
	 *
	 * @param __b The binary to get the classpath for.
	 * @return The binary class path.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/17
	 */
	public final Binary[] classPath(Binary __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Return value to use run-time
		Set<Binary> rv = new LinkedHashSet<>();
		
		// Make sure all dependencies are used
		for (Binary dep : this.matchDependencies(
			__b.suiteInfo().dependencies(), false))
			rv.add(dep);
		
		// Include this in the run-time
		rv.add(__b);
		return rv.<Binary>toArray(new Binary[rv.size()]);
	}
	
	/**
	 * Compiles the specified binary and all of their dependencies.
	 *
	 * @param __b The binary to compile.
	 * @return The binaries which were compiled and are part of the class
	 * path.
	 * @throws InvalidBinaryException If the binary is not valid because it
	 * could not be compiled or one of its dependencies could not be compiled.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/17
	 */
	public final Binary[] compile(Binary __b)
		throws InvalidBinaryException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Return value to use run-time
		Set<Binary> rv = new LinkedHashSet<>();
		
		// Make sure all dependencies are compiled, this will result in the
		// entire class path being determined aslso for compilation
		for (Binary dep : this.matchDependencies(
			__b.suiteInfo().dependencies(), false))
			try
			{
				for (Binary c : this.compile(dep))
					rv.add(c);
			}
			catch (NoSourceAvailableException e)
			{
				// For no source, just add the class path for the binary
				for (Binary c : this.classPath(dep))
					rv.add(c);
			}
		
		// Always recompile if the source is newer, but go through all
		// dependencies and recompile if any dependency is newer than this
		// binary
		boolean docompile = __b.isSourceNewer();
		if (!docompile)
		{
			// Get the date for this binary
			long mydate = __b.lastModifiedTime();
			
			// If any dependency has a newer binary than this one, compile
			for (Binary dep : rv)
				if (dep.isSourceNewer() || dep.lastModifiedTime() > mydate)
				{
					docompile = true;
					break;
				}
		}
		
		// Compilation needs to be performed
		if (docompile)
		{
			// Temporary output file to be cleaned
			Path temp = null;
			
			// {@squirreljme.error AU07 Cannot compile the specified project
			// because it has no source code. (The name of the project)}
			Source src = __b.source();
			if (src == null)
				throw new NoSourceAvailableException(
					String.format("AU07 %s", __b.name()));
			
			// Need to close everything that is opened
			try (CloseableList<Closeable> closing = new CloseableList<>())
			{
				// {@squirreljme.error AU08 Compiling the given project.
				// (The project name)}
				System.err.printf("AU08 %s%n", __b.name());
			
				// Setup compiler instance
				Compiler javac = DefaultCompiler.createInstance();
				
				// Use the source root to lookup source code
				CompilerPathSet srcps = closing.<CompilerPathSet>addThis(
					src.pathSet(SourcePathSetType.COMPILED),
					CompilerPathSet.class);
				javac.setLocation(CompilerInputLocation.SOURCE, srcps);
				
				// Explicitly compile every source file
				Set<CompilerInput> noninput = new LinkedHashSet<>();
				boolean hasinput = false;
				for (CompilerInput i : srcps)
				{
					String name = i.fileName();
					
					// Is there a dash in this?
					int ls = name.lastIndexOf('/');
					boolean dashname = (ls >= 0 && name.substring(0, ls).
						indexOf('-') >= 0);
					
					// Compile any source file
					if (!dashname && name.endsWith(".java"))
					{
						hasinput = true;
						javac.addInput(i);
					}
					
					// Do not include the manifest ever
					else if (!name.equals("META-INF/MANIFEST.MF"))
						noninput.add(i);
				}
				
				// Go through all binaries and load dependencies into the
				// class path
				int ndeps = rv.size(),
					i = 0;
				CompilerPathSet[] bins = new CompilerPathSet[ndeps];
				for (Binary dep : rv)
					bins[i++] = closing.<ZipPathSet>addThis(
						new ZipPathSet(dep.zipBlock()), ZipPathSet.class);
				javac.setLocation(CompilerInputLocation.CLASS, bins);
				
				// Need temporary file for output
				temp = Files.createTempFile("squirreljme-", ".ja_");
				
				// Output to a temporary ZIP file
				try (ZipCompilerOutput out = new ZipCompilerOutput(
					new ZipStreamWriter(Files.newOutputStream(temp,
						StandardOpenOption.CREATE,
						StandardOpenOption.WRITE,
						StandardOpenOption.TRUNCATE_EXISTING))))
				{
					// Write the resulting actual manifest
					try (OutputStream mos = out.output("META-INF/MANIFEST.MF"))
					{
						__writeRealManifest(mos, rv, __b);
					}
					
					// Run compilation task, but not if there is no input
					if (hasinput)
						javac.compile(out).run();
					
					// Go through non-input and copy all of the data
					byte[] buf = new byte[512];
					for (CompilerInput j : noninput)
					{
						// Detect UUEncoded binary files, that I encode due
						// to the pure text requirements of the repository
						String inname = j.fileName();
						boolean ismime;
						if ((ismime = inname.endsWith(".__mime")))
							inname = inname.substring(0, inname.length() - 7);
						
						// Copy data directly or just decode it
						try (InputStream ei = (!ismime ? j.open() :
							new MIMEFileDecoder(new InputStreamReader(j.open(),
							"utf-8")));
							OutputStream eo = out.output(inname))
						{
							for (;;)
							{
								int rc = ei.read(buf);
								
								if (rc < 0)
									break;
								
								eo.write(buf, 0, rc);
							}
						}
					}
					
					// Flush the ZIP before it is closed
					out.flush();
				}
				
				// Make sure the output directories exist
				Path outpath = __b.path();
				Files.createDirectories(outpath.getParent());
				
				// Replace output file with temporary one
				Files.move(temp, outpath,
					StandardCopyOption.REPLACE_EXISTING);
			}
			
			// {@squirreljme.error AU09 Could not compile the specified
			// project. (The project which failed to compile)}
			catch (CompilerException|IOException e)
			{
				throw new InvalidBinaryException(
					String.format("AU09 %s", __b.name()), e);
			}
			
			// Clean output temporary file as needed
			finally
			{
				if (temp != null)
					try
					{
						Files.deleteIfExists(temp);
					}
					catch (IOException e)
					{
						e.printStackTrace();
					}
			}
		}
		
		// Include this in the run-time
		rv.add(__b);
		return rv.<Binary>toArray(new Binary[rv.size()]);
	}
	
	/**
	 * Obtains the binary which uses the given source name.
	 *
	 * @param __n The name of the project to get.
	 * @return The binary for the given name.
	 * @throws NoSuchBinaryException If no binary with the given name exists.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/17
	 */
	public final Binary get(String __n)
		throws NoSuchBinaryException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return this.get(new SourceName(__n));
	}
	
	/**
	 * Obtains the binary which uses the given source name.
	 *
	 * @param __n The name of the project to get.
	 * @return The binary for the given name.
	 * @throws NoSuchBinaryException If no binary with the given name exists.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public final Binary get(SourceName __n)
		throws NoSuchBinaryException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Locate
		Binary rv = this._binaries.get(__n);
		
		// {@squirreljme.error AU0a The specified binary does not exist.
		// (The name of the binary)}
		if (rv == null)
			throw new NoSuchBinaryException(String.format("AU0a %s", __n));
		return rv;
	}
	
	/**
	 * Creates a virtual binary which is sourced from the given JAR file and
	 * where it has no backing in source code.
	 *
	 * @param __p The path to JAR to be opened as a binary.
	 * @return The binary for the given path.
	 * @throws NoSuchBinaryException If no such binary exists.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public final Binary getVirtual(Path __p)
		throws NoSuchBinaryException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AU0b Cannot open the specified path as a project
		// because it does not exist. (The path to open as a binary)}
		if (!Files.exists(__p))
			throw new NoSuchBinaryException(String.format("AU0b %s", __p));
		
		// Just create the binary
		return new Binary(SourceName.ofBinaryPath(__p), null, __p);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/25
	 */
	@Override
	public final Iterator<Binary> iterator()
	{
		return UnmodifiableCollection.<Binary>of(this._binaries.values()).
			iterator();
	}
	
	/**
	 * Returns the binaries which statisfy the given set.
	 *
	 * @param __set The set of dependencies to get.
	 * @param __opt If {@code true} include optional dependencies.
	 * @return Binaries which statisfy the given dependencies.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/17
	 */
	public final Binary[] matchDependencies(DependencyInfo __set,
		boolean __opt)
		throws NullPointerException
	{
		if (__set == null)
			throw new NullPointerException("NARG");
		
		// Clear all optionals if they are not included
		if (!__opt)
			__set = __set.noOptionals();
		
		// No dependencies to search for
		if (__set.isEmpty())
			return new Binary[0];
		
		// Remember the original set for recursive dependency checks
		DependencyInfo original = __set;
		
		// The returning set
		Set<Binary> rv = new LinkedHashSet<>();
		
		// Go through all binaries and attempt to match
		for (Binary bin : this)
		{
			// Only consider matches
			MatchResult result = bin.matchedDependencies(__set);
			if (!result.hasMatches())
				continue;
			
			// Use this as a dependency
			rv.add(bin);
			
			// Recursively go down
			for (Binary sub : this.matchDependencies(
				bin.suiteInfo().dependencies(), false))
				rv.add(sub);
			
			// Use remaining unmatched set
			__set = result.unmatched();
			
			// If the set was emptied then it will never have any more matches
			if (__set.isEmpty())
				break;
		}
		
		// {@squirreljme.error AU0c Could not locate the binary which
		// statifies the given dependency. (The dependency to look for)}
		if (rv.isEmpty())
			throw new InvalidBinaryException(
				String.format("AU0c %s", __set));
		
		return rv.<Binary>toArray(new Binary[rv.size()]);
	}
	
	/**
	 * Returns the dependency key to use for the manifest.
	 *
	 * @param __ismidlet Is this a midlet?
	 * @param __i The dependency index.
	 * @return The key to use in the manifest for the dependency.
	 * @since 2018/02/28
	 */
	private static JavaManifestKey __dependencyKey(boolean __ismidlet, int __i)
	{
		return new JavaManifestKey((__ismidlet ?
			"MIDlet-Dependency-" : "LIBlet-Dependency-") + __i);
	}
	
	/**
	 * Writes the real manifest to the output binary with non-proprietary
	 * SquirrelJME dependencies.
	 *
	 * @param __os The stream to write to.
	 * @param __deps The dependencies to use for lookup.
	 * @param __bin The binary to write the manifest for.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	private static void __writeRealManifest(OutputStream __os,
		Set<Binary> __deps, Binary __bin)
		throws IOException, NullPointerException
	{
		if (__os == null || __deps == null || __bin == null)
			throw new NullPointerException("NARG");
		
		// Initialize the output manifest with the initial approximated
		// manifest first
		MutableJavaManifest outman = new MutableJavaManifest(
			__bin.source().manifest());
		MutableJavaManifestAttributes outattr = outman.getMainAttributes();
		
		// Is this a midlet? Needed for correct dependency placement
		boolean ismidlet = (__bin.type() == ProjectType.MIDLET);
		
		// Read in all dependency values. Since SquirrelJME uses a rather
		// abstract dependency system, project references will be converted to
		// configurations, profiles, standard, or liblets.
		Set<SuiteDependency> mdeps = new LinkedHashSet<>();
		for (int i = 1; i >= 1; i++)
		{
			JavaManifestKey key = __dependencyKey(ismidlet, i);
			
			// No more values to parse
			String value = outattr.get(key);
			if (value == null)
				break;
			
			// Read in dependency and remove from original set, will be
			// re-added later after being evaluated
			mdeps.add(new SuiteDependency(outattr.remove(key)));
		}
		
		// Go through and remap dependencies
		int next = 1;
		Map<Binary, SuiteDependency> apideps = new LinkedHashMap<>();
		for (SuiteDependency dep : mdeps)
		{
			JavaManifestKey key = __dependencyKey(ismidlet, next);
			
			// Debug
			todo.DEBUG.note("Dep: %s%n", dep);
			
			// Non-proprietary dependency
			String name = Objects.toString(dep.name(), "").trim();
			if (dep.type() != SuiteDependencyType.PROPRIETARY ||
				!name.startsWith("squirreljme.project"))
			{
				// Just directly copy it since it has an unknown translation
				outattr.put(key, dep.toString());
				
				// Next key
				next++;
				continue;
			}
			
			// {@squirreljme.error AU0d Expected at sign in
			// {@code squirreljme.project} type dependency. (This project)}
			int at = name.indexOf('@');
			if (at < 0)
				throw new InvalidBinaryException(
					String.format("AU0d %s", __bin.name()));
			SourceName sname = new SourceName(name.substring(at + 1).trim());
			
			// Find the dependency using the given project
			Binary found = null;
			for (Binary bin : __deps)
				if (sname.equals(bin.name()))
				{
					found = bin;
					break;
				}
			
			// {@squirreljme.error AU0e Could not locate the project with the
			// specified dependency. (This project; The dependency)}
			if (found == null)
				throw new InvalidBinaryException(
					String.format("AU0e %s %s", __bin.name(), sname));
			
			// Depending on an API, use configuration, standard, or profile
			SuiteInfo foundinfo = found.suiteInfo();
			if (found.type() == ProjectType.API)
				apideps.put(found, dep);
			
			// Relying on a liblet
			else
			{
				outattr.put(key, new SuiteDependency(
					SuiteDependencyType.LIBLET,
					dep.level(),
					foundinfo.name(),
					foundinfo.vendor(),
					SuiteVersionRange.exactly(foundinfo.version())).
					toString());
				
				// Use next key
				next++;
			}
		}
		
		// Handle API dependencies since they require a more complex setup
		todo.DEBUG.note("API Depends: %s%n", apideps);
		if (!apideps.isEmpty())
			for (Map.Entry<Binary, SuiteDependency> e : apideps.entrySet())
			{
				Binary bin = e.getKey();
				SuiteDependency dep = e.getValue();
				
				// Go through provided dependencies and try to handle them
				for (MarkedProvided mp : bin.suiteInfo().provided().provided())
				{
					// Standard
					if (mp instanceof Standard)
					{
						Standard s = (Standard)mp;
						SuiteVersion v = s.version();
						outattr.put(__dependencyKey(ismidlet, next++),
							new SuiteDependency(
								SuiteDependencyType.STANDARD,
								dep.level(),
								s.name(),
								s.vendor(),
								(v == null ? null :
									SuiteVersionRange.exactly(v))).
							toString());
					}
					
					// Configuration
					else if (mp instanceof Configuration)
						throw new todo.TODO();
					
					// Profile
					else if (mp instanceof Profile)
						throw new todo.TODO();
					
					// Unknown, ignore
					else
						continue;
				}
			}
		
		// Debug
		todo.DEBUG.note("Manifest: %s",
			outman.write(new StringBuilder()));
		
		// Write it
		outman.write(__os);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/BuilderFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825

























































































































































































































































































































































































































































































































































































































































































































































































































































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

package cc.squirreljme.builder.support;

import cc.squirreljme.builder.support.dist.DistBuilder;
import cc.squirreljme.builder.support.vm.VMMain;
import cc.squirreljme.builder.support.vmshader.Shader;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * This is a factory which can invoke the build system using a common set
 * of input arguments.
 *
 * @since 2017/11/09
 */
public class BuilderFactory
	implements Runnable
{
	/** The command to execute. */
	protected final String command;
	
	/** The project manager to use. */
	protected final ProjectManager projectmanager;
	
	/** Arguments to the builder command. */
	private final String[] _args;
	
	/**
	 * Initializes the build factory.
	 *
	 * @param __args Program arguments.
	 * @throws IllegalArgumentException If the factory arguments are missing
	 * the primary command.
	 * @since 2017/11/09
	 */
	public BuilderFactory(String... __args)
		throws IllegalArgumentException
	{
		// Copy arguments for processing
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.addLast(a);
		
		// Parse options and such for the project
		ProjectManager projectmanager = ProjectManager.fromArguments(args);
		this.projectmanager = projectmanager;
		
		// {@squirreljme.error AU0f No command given.}
		String command = args.pollFirst();
		if (command == null)
			throw new IllegalArgumentException("AU0f");
		this.command = command;
		
		// Use remaining arguments as input
		this._args = args.<String>toArray(new String[args.size()]);
	}
	
	/**
	 * Returns the binary manager to use for binary project retrieval.
	 *
	 * @param __t The timespace to build for.
	 * @return The manager for the given timespace.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public BinaryManager binaryManager(TimeSpaceType __t)
		throws IOException, NullPointerException
	{
		return this.projectmanager.binaryManager(__t);
	}
	
	/**
	 * Builds the specified projects.
	 *
	 * @param __t The timespace to use for projects.
	 * @param __p The projects to be built.
	 * @return The binaries which are associated with the given project.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public Binary[] build(TimeSpaceType __t, String... __p)
		throws NullPointerException
	{
		return this.projectmanager.build(__t, __p);
	}
	
	/**
	 * Builds every binary.
	 *
	 * @param __t The timespace to build in.
	 * @return The resulting binaries.
	 * @throws NullPointerException On null arguments.
	 */
	public Binary[] buildAll(TimeSpaceType __t, String... __p)
		throws NullPointerException
	{
		return this.projectmanager.buildAll(__t);
	}
	
	/**
	 * Builds the given distributions.
	 *
	 * @param __args The distributions to build.
	 * @since 2018/12/24
	 */
	public void dist(String... __args)
	{
		ProjectManager projectmanager = this.projectmanager;
		
		// Build each requested distribution
		boolean builtone = false;
		for (String d : __args)
		{
			if (d == null)
				continue;
			
			// Get the builder for this
			DistBuilder db = DistBuilder.builder(d);
			
			// Work with a temporary file so nothing breaks
			Path tempfile = null;
			try
			{
				// Need a temporary file
				tempfile = Files.createTempFile("squirreljme-shaded", ".ja_");
				
				// Write to temporary stream first
				try (ZipCompilerOutput zco = new ZipCompilerOutput(
					Files.newOutputStream(tempfile,
					StandardOpenOption.CREATE,
					StandardOpenOption.WRITE,
					StandardOpenOption.TRUNCATE_EXISTING)))
				{
					db.build(projectmanager, zco);
				}
				
				// Move the file to the output since it was built!
				Files.move(tempfile, Paths.get(
					"squirreljme-" + db.name() + ".zip"),
					StandardCopyOption.REPLACE_EXISTING);
			}
			
			// {@squirreljme.error AU0g Could not build the distribution.
			// (The failed distribution)}
			catch (IOException e)
			{
				throw new RuntimeException("AU0g " + d, e);
			}
			
			// Cleanup temp file
			finally
			{
				if (tempfile != null)
					try
					{
						Files.delete(tempfile);
					}
					catch (IOException e)
					{
					}
			}
			
			// Did build one
			builtone = true;
		}
		
		// {@squirreljme.error AU0h No distributions were specified for
		// building.}
		if (!builtone)
			throw new IllegalArgumentException("AU0h");
	}
	
	/**
	 * Builds all distributions.
	 *
	 * @param __args Arguments.
	 * @since 2018/12/24
	 */
	public void distAll(String... __args)
	{
		// {@squirreljme.error AU0i Could not build at least one distribution.}
		RuntimeException fail = new RuntimeException("AU0i");
		boolean failed = false;
		
		// Build them one at a time so all of them are made regardless if they
		// all fail or not
		for (String d : DistBuilder.listBuilders())
			try
			{
				this.dist(d);
			}
			catch (RuntimeException t)
			{
				// Suppress it
				failed = true;
				fail.addSuppressed(t);
			}
		
		// If any failed, we throw the exception we made before
		if (failed)
			throw fail;
	}
	
	/**
	 * Lists distributions available to standard output.
	 *
	 * @since 2018/12/24
	 */
	public void distList()
	{
		PrintStream out = System.out;
		for (String d : DistBuilder.listBuilders())
			out.println(d);
	}
	
	/**
	 * Generate all of the Javadoc.
	 *
	 * @param __args Arguments.
	 * @since 2019/01/17
	 */
	public void javaDoc(String... __args)
	{
		// Defensive copy
		__args = (__args == null ? new String[0] : __args.clone());
		
		throw new todo.TODO();
	}
	
	/**
	 * Launch program.
	 *
	 * @param __args Arguments to use.
	 * @since 2018/12/22
	 */
	public void launch(String... __args)
	{
		// Load arguments into a queue
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.add(a);
		
		// Allows the VM to be overridden
		String vmname = null;
		
		// Alternative NPS location
		String npspath = null;
		
		// Listing entry points?
		boolean listentry = false;
		
		// Extra system properties
		Map<String, String> sprops = new HashMap<>();
		
		// Determine how shading is to be handled
		String[] parse;
		while (null != (parse = __getopts(":?v:n:D:e", args)))
			switch (parse[0])
			{
					// Use build timespace
				case "v":
					vmname = parse[1];
					break;
					
					// Write NPS somewhere
				case "n":
					npspath = parse[1];
					break;
					
					// System property
				case "D":
					String spl = parse[1];
					int eq = spl.indexOf('=');
					if (eq >= 0)
						sprops.put(spl.substring(0, eq),
							spl.substring(eq + 1));
					else
						sprops.put(spl, "");
					break;
					
					// List entry points of program
				case "e":
					listentry = true;
					break;
				
					// {@squirreljme.error AU0j Unknown argument.
					// Usage: vmshade [-v vmname] [-n NPS path] [-Dkey=value]
					// [-e] (program[:launchid]);
					// -v: The name of the virtual machine to use, this may
					// be springcoat or summercoat.
					// -n: Path to write NPS files to.
					// -D: System property key/value pair.
					// -e: List entry points but do not run program.
					// (The switch)}
				case "?":
				default:
					throw new IllegalArgumentException(
						String.format("AU0j %s", parse[0]));
			}
		
		// {@squirreljme.error AU0k Launch of program using a SquirrelJME
		// VM requires a program to be launched.}
		String program = args.pollFirst();
		if (program == null)
			throw new IllegalArgumentException("AU0k");
		
		// List entry points?
		ProjectManager pm = this.projectmanager;
		if (listentry)
		{
			// A launch ID might accidentally be specified, ignore it
			int col = program.indexOf(':');
			String check = (col >= 0 ? program.substring(0, col) : program);
			
			// Get the binaries to be ran
			Binary[] vclasspath;
			try
			{
				vclasspath = pm.build(check);
			}
			
			// If there is no source for this, just use the classpath then
			catch (NoSourceAvailableException e)
			{
				vclasspath = pm.classPath(check);
			}
			
			// Load entry points
			EntryPoints eps = new EntryPoints(
				vclasspath[vclasspath.length - 1].manifest());
			
			// List them
			System.err.println("Entry points:");
			for (int i = 0, n = eps.size(); i < n; i++)
				System.err.printf("    %d: %s%n", i, eps.get(i));
			
			// Do not continue
			return;
		}
		
		// Run the VM
		VMMain.main(vmname, npspath, sprops, pm, program,
			args.<String>toArray(new String[args.size()]));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/09
	 */
	@Override
	public void run()
	{
		// Load arguments into a queue
		Deque<String> args =
			new ArrayDeque<>(Arrays.<String>asList(this._args));
		
		// Depends on the command
		String command = this.command;
		switch (command)
		{
				// Build the specified project
			case "build":
				{
					TimeSpaceType space = TimeSpaceType.RUNTIME;
					
					// Try to determine the timespace to use, which determines
					// the available projects
					String[] parse;
					while (null != (parse = __getopts(":?rjtbRJTB", args)))
						switch (parse[0])
						{
							case "r":
							case "R":
								space = TimeSpaceType.RUNTIME;
								break;
							
							case "j":
							case "J":
								space = TimeSpaceType.JIT;
								break;
								
							case "t":
							case "T":
								space = TimeSpaceType.TEST;
								break;
							
							case "b":
							case "B":
								space = TimeSpaceType.BUILD;
								break;
							
								// {@squirreljme.error AU0l Unknown argument.
								// Usage: build [-R] [-J] [-T] [-B]
								// (projects...);
								// -R: Build for run-time;
								// -J: Build for jit-time;
								// -T: Build for tests;
								// -B: Build for build-time;
								// (The switch)}
							default:
								throw new IllegalArgumentException(
									String.format("AU0l %s", parse[0]));
						}
					
					// Run the builder
					this.build(space,
						args.<String>toArray(new String[args.size()]));
				}
				break;
				
				// Builds all projects
			case "buildall":
				{
					TimeSpaceType space = TimeSpaceType.RUNTIME;
					
					// Try to determine the timespace to use, which determines
					// the available projects
					String[] parse;
					while (null != (parse = __getopts(":?rjtbRJTB", args)))
						switch (parse[0])
						{
							case "r":
							case "R":
								space = TimeSpaceType.RUNTIME;
								break;
							
							case "j":
							case "J":
								space = TimeSpaceType.JIT;
								break;
								
							case "t":
							case "T":
								space = TimeSpaceType.TEST;
								break;
							
							case "b":
							case "B":
								space = TimeSpaceType.BUILD;
								break;
							
								// {@squirreljme.error AU0m Unknown argument.
								// Usage: build [-R] [-J] [-T] [-B]
								// (projects...);
								// -R: Build for run-time;
								// -J: Build for jit-time;
								// -T: Build for tests;
								// -B: Build for build-time;
								// (The switch)}
							default:
								throw new IllegalArgumentException(
									String.format("AU0m %s", parse[0]));
						}
					
					// Run the builder
					this.buildAll(space,
						args.<String>toArray(new String[args.size()]));
				}
				break;
				
				// Build distribution
			case "dist":
				this.dist(args.<String>toArray(new String[args.size()]));
				break;
			
			case "lsdist":
			case "distlist":
			case "dist-list":
				this.distList();
				break;
				
				// Build all distributions
			case "distall":
			case "dist-all":
				this.distAll(args.<String>toArray(new String[args.size()]));
				break;
				
				// Generate all of the JavaDoc
			case "javadoc":
				this.javaDoc(args.<String>toArray(new String[args.size()]));
				break;
				
				// Launch project within a VM
			case "launch":
				this.launch(args.<String>toArray(new String[args.size()]));
				break;
				
				// Perform SDK actions
			case "sdk":
				this.sdk(args.<String>toArray(new String[args.size()]));
				break;
				
				// Perform suite related operations
			case "suite":
				this.suite(args.<String>toArray(new String[args.size()]));
				break;
				
				// Perform task related operations
			case "task":
				this.task(args.<String>toArray(new String[args.size()]));
				break;
				
				// Shade VM provided JAR
			case "vmshade":
			case "vmshaded":
			case "shadevm":
			case "shadedvm":
				this.vmShade(args.<String>toArray(new String[args.size()]));
				break;
				
				// {@squirreljme.error AU0n Unknown command specified.
				// Usage: command (command arguments...);
				// Valid commands are:
				// build, javadoc, launch, sdk, suite, task, vmshade
				// .(The switch)}
			default:
				throw new IllegalArgumentException(String.format("AU0n %s",
					command));
		}
	}
	
	/**
	 * Returns the source manager to use for source code retrieval.
	 *
	 * @param __t The timespace to build for.
	 * @return The manager for the given timespace.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public SourceManager sourceManager(TimeSpaceType __t)
		throws IOException, NullPointerException
	{
		return this.projectmanager.sourceManager(__t);
	}
	
	/**
	 * Performs SDK related actions.
	 *
	 * @param __args Arguments to the SDK command.
	 * @since 2018/01/27
	 */
	public void sdk(String... __args)
	{
		try
		{
			new SDKFactory(this.binaryManager(TimeSpaceType.JIT), __args).
				run();
		}
		
		// {@squirreljme.error AU0o Could not initialize the SDK factory.}
		catch (IOException e)
		{
			throw new RuntimeException("AU0o", e);
		}
	}
	
	/**
	 * Performs suite related operations.
	 *
	 * @param __args Arguments to the suite command.
	 * @since 2017/12/08
	 */
	public void suite(String... __args)
	{
		new SuiteFactory(__args).run();
	}
	
	/**
	 * Performs task related operations.
	 *
	 * @param __args Arguments to the task commands.
	 * @since 2017/12/05
	 */
	public void task(String... __args)
	{
		new TaskFactory(__args).run();
	}
	
	/**
	 * Shaded VM output.
	 *
	 * @param __args Shader arguments.
	 * @since 2018/12/22
	 */
	public void vmShade(String... __args)
	{
		// Copy arguments for processing
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.addLast(a);
		
		// Bootstrap JAR path, for bootstrap variants (not pure ME)
		Path bootstrapjar = Paths.get("bootsjme", "javase-runtime.jar");
		
		// Build with the bootstrap?
		boolean withbootstrap = false;
		
		// Override the timespace?
		ProjectManager pm = this.projectmanager;
		TimeSpaceType pmts = TimeSpaceType.RUNTIME;
		
		// Determine how shading is to be handled
		String[] parse;
		while (null != (parse = __getopts(":?p:bRJTB", args)))
			switch (parse[0])
			{
					// Bootstrap path
				case "p":
					bootstrapjar = Paths.get(parse[1]);
					break;
					
					// Build with bootstrap JAR
				case "b":
					withbootstrap = true;
					break;
					
					// Use run-time timespace
				case "R":
					pmts = TimeSpaceType.RUNTIME;
					break;
					
					// Use JIT timespace
				case "J":
					pmts = TimeSpaceType.JIT;
					break;
					
					// Use test timespace
				case "T":
					pmts = TimeSpaceType.TEST;
					break;
					
					// Use build timespace
				case "B":
					pmts = TimeSpaceType.BUILD;
					break;
				
					// {@squirreljme.error AU0p Unknown argument.
					// Usage: vmshade [-b JAR] [output];
					// -p: Bootstrap JAR Path, defaults to
					// {@code bootsjme/javase-runtime.jar};
					// -b: Build and include the bootstrap;
					// -R: Build with run-time level (the default);
					// -J: Build with jit-time level;
					// -T: Build with tests level;
					// -B: Build with build-time level;
					// (The switch)}
				case "?":
				default:
					throw new IllegalArgumentException(
						String.format("AU0p %s", parse[0]));
			}
		
		// Output file name, which is optional
		String outfile = args.pollFirst();
		if (outfile == null)
			outfile = "squirreljme.jar";
		
		// Need to write to temporary to not kludge files
		Path tempfile = null;
		try
		{
			// Need a temporary file
			tempfile = Files.createTempFile("squirreljme-shaded", ".ja_");
			
			// Write to temporary stream first
			try (OutputStream out = Files.newOutputStream(tempfile,
				StandardOpenOption.CREATE,
				StandardOpenOption.WRITE,
				StandardOpenOption.TRUNCATE_EXISTING))
			{
				Shader.shade(pm, pmts, withbootstrap, bootstrapjar, out);
			}
			
			// Move the file to the output since it was built!
			Files.move(tempfile, Paths.get(outfile),
				StandardCopyOption.REPLACE_EXISTING);
		}
		catch (IOException e)
		{
			// {@squirreljme.error AU0q Could not build the shaded JAR.}
			throw new RuntimeException("AU0q", e);
		}
		finally
		{
			// Delete temporary file if there is one
			if (tempfile != null)
				try
				{
					Files.delete(tempfile);
				}
				catch (IOException e)
				{
					// Ignore
				}
		}
	}
	
	/**
	 * This is mostly similar to the way the POSIX getopts works but with
	 * some limitations.
	 *
	 * @param __optstring The option string, these are single characters. If a
	 * colon is placed after a character then
	 * @param __q The input command line argument queue.
	 * @return The switch which was parsed, it's character followed by the
	 * argument if there is one; {@code null} is returned when there are no
	 * arguments to parse. If the starting character is a colon then unknown
	 * arguments will return a question mark rather than failing.
	 * @throws IllegalArgumentException If an option requires an argument and
	 * it was not specified.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	static String[] __getopts(String __optstring, Queue<String> __q)
		throws IllegalArgumentException, NullPointerException
	{
		if (__optstring == null || __q == null)
			throw new NullPointerException("NARG");
		
		// No more arguments
		if (__q.isEmpty())
			return null;
		
		// Indicate the failed switch
		boolean colonfail = false;
		if (__optstring.startsWith(":"))
		{
			__optstring = __optstring.substring(1);
			colonfail = true;
		}
		int optstrlen = __optstring.length();
		
		// Peek the next argument
		String peek = __q.peek();
		
		// Stop parsing arguments, or nothing to parse
		if (peek.equals("--") || !peek.startsWith("-"))
			return null;
		
		// Parse switch 
		for (int i = 1, n = peek.length(); i < n; i++)
		{
			char c = peek.charAt(i);
			
			// Find the option in the option string
			int odx = __optstring.indexOf(c);
			if (odx < 0)
				return (colonfail ? new String[]{"?", Character.toString(c)} :
					new String[]{"?"});
			
			// Is an argument desired?
			boolean wantsarg = false;
			if (odx + 1 < optstrlen)
				wantsarg = (__optstring.charAt(odx + 1) == ':');
			
			// At this point the argument is consumed
			__q.remove();
			
			// Wants an argument?
			String rva = Character.toString(c);
			if (wantsarg)
			{
				// If this is the last argument then the value is passed
				// in the following switch
				if (i == n - 1)
				{
					// {@squirreljme.error AU0r The specified option argument
					// requires a value set to it. (The option argument)}
					String next = __q.peek();
					if (next == null)
						throw new IllegalArgumentException(
							String.format("AU0r %c", c));
					
					return new String[]{rva, __q.remove()};
				}
				
				// Otherwise it is just anything after the sequence
				else
					return new String[]{rva, peek.substring(i + 1)};
			}
			
			// Otherwise return just that switch
			else
				return new String[]{rva};
		}
		
		// Nothing parsed, indicate failure
		return new String[]{"?"};
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/DefinedTests.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















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

package cc.squirreljme.builder.support;

/**
 * This contains the tests which are defined in total for a given project.
 *
 * @since 2018/03/19
 */
@Deprecated
public final class DefinedTests
{
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/InvalidBinaryException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the specified binary is not valid.
 *
 * @since 2017/11/03
 */
public class InvalidBinaryException
	extends ProjectException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/03
	 */
	public InvalidBinaryException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/03
	 */
	public InvalidBinaryException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/03
	 */
	public InvalidBinaryException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/03
	 */
	public InvalidBinaryException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/InvalidDependencyException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the dependency for a project is not valid.
 *
 * @since 2017/11/21
 */
public class InvalidDependencyException
	extends ProjectException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/21
	 */
	public InvalidDependencyException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/21
	 */
	public InvalidDependencyException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/21
	 */
	public InvalidDependencyException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/21
	 */
	public InvalidDependencyException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/InvalidSourceException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the source project is not valid.
 *
 * @since 2017/10/31
 */
public class InvalidSourceException
	extends ProjectException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/10/31
	 */
	public InvalidSourceException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/10/31
	 */
	public InvalidSourceException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public InvalidSourceException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public InvalidSourceException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/InvalidSourceNameException.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
66


































































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

package cc.squirreljme.builder.support;


/**
 * This is thrown when the name of a given source is not valid.
 *
 * @since 2017/10/31
 */
public class InvalidSourceNameException
	extends InvalidSourceException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/10/31
	 */
	public InvalidSourceNameException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/10/31
	 */
	public InvalidSourceNameException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public InvalidSourceNameException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public InvalidSourceNameException(Throwable __c)
	{
		super(__c);
	}
}


Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/NoSourceAvailableException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.builder.support;

/**
 * This is thrown when source code is not available during compilation.
 *
 * @since 2019/05/02
 */
public class NoSourceAvailableException
	extends InvalidBinaryException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/05/02
	 */
	public NoSourceAvailableException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/02
	 */
	public NoSourceAvailableException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/05/02
	 */
	public NoSourceAvailableException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/05/02
	 */
	public NoSourceAvailableException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/NoSuchBinaryException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the specified binary does not exist.
 *
 * @since 2017/11/02
 */
public class NoSuchBinaryException
	extends InvalidBinaryException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/02
	 */
	public NoSuchBinaryException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/02
	 */
	public NoSuchBinaryException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/02
	 */
	public NoSuchBinaryException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/02
	 */
	public NoSuchBinaryException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/NoSuchSourceException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the specified source project does not exist.
 *
 * @since 2017/10/31
 */
public class NoSuchSourceException
	extends InvalidSourceException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/10/31
	 */
	public NoSuchSourceException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/10/31
	 */
	public NoSuchSourceException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public NoSuchSourceException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public NoSuchSourceException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/OutOfDateBinaryException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This is thrown when the specified binary is not valid.
 *
 * @since 2017/11/29
 */
public class OutOfDateBinaryException
	extends InvalidBinaryException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/29
	 */
	public OutOfDateBinaryException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/29
	 */
	public OutOfDateBinaryException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/29
	 */
	public OutOfDateBinaryException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/29
	 */
	public OutOfDateBinaryException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/ProjectException.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
































































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

package cc.squirreljme.builder.support;

/**
 * This exception is thrown when there is a problem with the project system.
 *
 * @since 2017/10/31
 */
public class ProjectException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/10/31
	 */
	public ProjectException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/10/31
	 */
	public ProjectException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public ProjectException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/10/31
	 */
	public ProjectException(Throwable __c)
	{
		super(__c);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/ProjectManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
















































































































































































































































































































































































































































































































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

package cc.squirreljme.builder.support;

import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedHashSet;
import java.util.Queue;
import java.util.Set;
import net.multiphasicapps.io.MIMEFileDecoder;
import net.multiphasicapps.strings.StringUtils;

/**
 * This class is used to initialize and setup source and binary project
 * representations in a common means which does not require
 * {@link BuilderFactory} to be initialized to have a shared setup of the
 * project state.
 *
 * @since 2018/07/29
 */
public final class ProjectManager
{
	/** The directory for the project root (source code). */
	protected final Path sourceroot;
	
	/** The default timespace to use for projects. */
	protected final TimeSpaceType deftimespace;
	
	/** The directory for each timespace binaries. */
	private final Path[] _bin;
	
	/** The source managers for each timespace. */
	private final SourceManager[] _sourcemanagers =
		new SourceManager[TimeSpaceType.values().length];
	
	/** Binary managers for each timespace. */
	private final BinaryManager[] _binarymanagers =
		new BinaryManager[TimeSpaceType.values().length];
	
	/**
	 * Initializes the project manager.
	 *
	 * @param __sr The source root.
	 * @param __brs The binary output roots.
	 * @param __dts Default time space.
	 * @throws IllegalArgumentException If the binary outputs does not match
	 * the number of available timespaces.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/07/29
	 */
	public ProjectManager(Path __sr, Path[] __brs, TimeSpaceType __dts)
		throws IllegalArgumentException, NullPointerException
	{
		if (__sr == null || __brs == null || __dts == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AU0s Binary paths array count does not match
		// the number of time spaces available.}
		if (__brs.length != TimeSpaceType.values().length)
			throw new IllegalArgumentException("AU0s");
		
		// These cannot be null, that would be bad
		for (Path p : (__brs = __brs.clone()))
			if (p == null)
				throw new NullPointerException("NARG");
		
		this.sourceroot = __sr;
		this._bin = __brs;
		this.deftimespace = __dts;
	}
	
	/**
	 * Initializes a binary manager using the default timespace.
	 *
	 * @return The binary manager with the default timespace.
	 * @throws IOException On read errors.
	 * @since 2018/12/22
	 */
	public BinaryManager binaryManager()
		throws IOException
	{
		return this.binaryManager(this.deftimespace);
	}
	
	/**
	 * Returns the binary manager to use for binary project retrieval.
	 *
	 * @param __t The timespace to build for.
	 * @return The manager for the given timespace.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public BinaryManager binaryManager(TimeSpaceType __t)
		throws IOException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		int i = __t.ordinal();
		BinaryManager[] binarymanagers = this._binarymanagers;
		BinaryManager rv = binarymanagers[i];
		if (rv == null)
			binarymanagers[i] =
				(rv = new BinaryManager(this._bin[i], sourceManager(__t)));
		return rv;
	}
	
	/**
	 * Builds the specified projects using the default time-space.
	 *
	 * @param __p The projects to be built.
	 * @return The binaries which are associated with the given project.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/22
	 */
	public Binary[] build(String... __p)
		throws NullPointerException
	{
		return this.build(this.deftimespace, __p);
	}
	
	/**
	 * Builds the specified projects.
	 *
	 * @param __t The timespace to use for projects.
	 * @param __p The projects to be built.
	 * @return The binaries which are associated with the given project.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public Binary[] build(TimeSpaceType __t, String... __p)
		throws NullPointerException
	{
		if (__t == null || __p == null)
			throw new NullPointerException("NARG");
		
		// Need the binary manager to build these projects
		BinaryManager bm;
		try
		{
			bm = this.binaryManager(__t);
		}
		
		// {@squirreljme.error AU0t Could not obtain the binary manager.}
		catch (IOException e)
		{
			throw new RuntimeException("AU0t", e);
		}
		
		// Get binaries
		int n = __p.length;
		Binary[] bins = new Binary[n];
		for (int i = 0; i < n; i++)
			bins[i] = bm.get(__p[i]);
		
		// Do not return duplicate binaries
		Set<Binary> rv = new LinkedHashSet<>();
		
		// Compile all of the project and return required class path for
		// it to operate
		for (Binary i : bins)
			for (Binary b : bm.compile(i))
				rv.add(b);
		
		// Return the completed set
		return rv.<Binary>toArray(new Binary[rv.size()]);
	}
	
	/**
	 * Builds every binary.
	 *
	 * @param __t The timespace to use.
	 * @return All of the built binaries.
	 * @since 2019/04/14
	 */
	public final Binary[] buildAll(TimeSpaceType __t)
	{
		Set<Binary> bin = new LinkedHashSet<>();
		
		try
		{
			// Build everything
			BinaryManager bm = this.binaryManager(__t);
			for (Binary b : bm)
				for (Binary x : bm.compile(b))
					bin.add(x);
		}
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
		
		return bin.<Binary>toArray(new Binary[bin.size()]);
	}
	
	/**
	 * Returns the class path for the given projects.
	 *
	 * @param __p The projects to lookup.
	 * @return The class path for the projects.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public final Binary[] classPath(String... __p)
		throws NullPointerException
	{
		return this.classPath(this.deftimespace, __p);
	}
	
	/**
	 * Returns the class path for the given projects in the given timespace.
	 *
	 * @param __t The timespace to use.
	 * @param __p The projects to lookup.
	 * @return The class path for the projects.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public final Binary[] classPath(TimeSpaceType __t, String... __p)
		throws NullPointerException
	{
		if (__t == null || __p == null)
			throw new NullPointerException("NARG");
		
		// Need the binary manager to get the class path for these
		BinaryManager bm;
		try
		{
			bm = this.binaryManager(__t);
		}
		
		// {@squirreljme.error AU0u Could not obtain the binary manager.}
		catch (IOException e)
		{
			throw new RuntimeException("AU0u", e);
		}
		
		// Get binaries
		int n = __p.length;
		Binary[] bins = new Binary[n];
		for (int i = 0; i < n; i++)
			bins[i] = bm.get(__p[i]);
		
		// Do not return duplicate binaries
		Set<Binary> rv = new LinkedHashSet<>();
		
		// Compile all of the project and return required class path for
		// it to operate
		for (Binary i : bins)
			for (Binary b : bm.classPath(i))
				rv.add(b);
		
		// Return the completed set
		return rv.<Binary>toArray(new Binary[rv.size()]);
	}
	
	/**
	 * Opens the given root file from the source tree. This also handles MIME
	 * encoded files if they exist and decodes them accordingly.
	 *
	 * @param __fn The filename to open.
	 * @return The input file or {@code null} if it does not exist.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/23
	 */
	public final InputStream rootFile(String __fn)
		throws IOException, NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		// Handle slashes and 
		Path sourceroot = this.sourceroot,
			open = sourceroot;
		for (String s : StringUtils.basicSplit('/', __fn))
			open = open.resolve(s);
		
		// Try to open a MIME file first and decode that
		try
		{
			return new MIMEFileDecoder(Files.newInputStream(
				open.resolveSibling(open.getFileName() + ".__mime"),
				StandardOpenOption.READ));
		}
		catch (NoSuchFileException e)
		{
			// Otherwise just use a normal file
			try
			{
				return Files.newInputStream(open,
					StandardOpenOption.READ);
			}
			catch (NoSuchFileException f)
			{
				// Does not exist
				return null;
			}
		}
	}
	
	/**
	 * Initializes a source manager using the default timespace.
	 *
	 * @return The source manager with the default timespace.
	 * @throws IOException On read errors.
	 * @since 2018/12/22
	 */
	public SourceManager sourceManager()
		throws IOException
	{
		return this.sourceManager(this.deftimespace);
	}
	
	/**
	 * Returns the source manager to use for source code retrieval.
	 *
	 * @param __t The timespace to build for.
	 * @return The manager for the given timespace.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/16
	 */
	public SourceManager sourceManager(TimeSpaceType __t)
		throws IOException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		int i = __t.ordinal();
		SourceManager[] sourcemanagers = this._sourcemanagers;
		SourceManager rv = sourcemanagers[i];
		if (rv == null)
			sourcemanagers[i] =
				(rv = new SourceManagerFactory(this.sourceroot).get(__t));
		return rv;
	}
	
	/**
	 * Initializes a project manager from the given arguments.
	 *
	 * @param __args The arguments to use.
	 * @return The project manager which was initialized.
	 * @since 2018/07/29
	 */
	public static ProjectManager fromArguments(String... __args)
	{
		// Copy arguments for processing
		Queue<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.add(a);
		
		// Forward it
		return ProjectManager.fromArguments(args);
	}
	
	/**
	 * Initializes the project manager from the given queue of arguments.
	 *
	 * @param __args The arguments to parse.
	 * @return The project manager parsed from the given arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/07/29
	 */
	public static ProjectManager fromArguments(Queue<String> __args)
		throws NullPointerException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		// Use default paths based on system properties
		Path sourceroot = Paths.get(
			System.getProperty("cc.squirreljme.builder.root",
				System.getProperty("user.dir", "squirreljme"))),
			binroot = Paths.get(
				System.getProperty(
					"cc.squirreljme.builder.output", "bins")),
			binruntime = null,
			binjit = null,
			bintest = null,
			binbuild = null;
		
		// Default timespace? Default to the build for compatibility purposes
		// since everything does that
		TimeSpaceType deftimespace = TimeSpaceType.BUILD;
		
		// Allow paths to be modified
		String[] parse;
		while (null != (parse = BuilderFactory.__getopts(
			":?RJTBs:o:j:t:b:", __args)))
			switch (parse[0])
			{
					// Change source code root
				case "s":
					sourceroot = Paths.get(parse[1]);
					break;
					
					// Change binary output base root
				case "o":
					binroot = Paths.get(parse[1]);
					break;
					
					// Run-time build path
				case "r":
					binruntime = Paths.get(parse[1]);
					break;
					
					// JIT-time build path
				case "j":
					binjit = Paths.get(parse[1]);
					break;
					
					// Test-time build path
				case "t":
					bintest = Paths.get(parse[1]);
					break;
					
					// Build-time build path
				case "b":
					binbuild = Paths.get(parse[1]);
					break;
					
					// Default RUNTIME
				case "R":
					deftimespace = TimeSpaceType.RUNTIME;
					break;
					
					// Default JIT
				case "J":
					deftimespace = TimeSpaceType.JIT;
					break;
					
					// Default Tests
				case "T":
					deftimespace = TimeSpaceType.TEST;
					break;
					
					// Default build time
				case "B":
					deftimespace = TimeSpaceType.BUILD;
					break;
				
					// {@squirreljme.error AU0v Unknown project argument.
					// Usage: [-s path] [-o path] [-r path] [-j path]
					// [-b path];
					// -s: The project source path;
					// -o: The base directory for binary output;
					// -r: The binary path for the run-time;
					// -j: The binary path for the jit-time;
					// -t: The binary path for the tests;
					// -b: The binary path for the build-time;
					// -R: Default timespace is run-time;
					// -J: Default timespace is JIT;
					// -T: Default timespace is tests;
					// -B: Default timespace is build-time}
				case "?":
				default:
					throw new IllegalArgumentException(
						String.format("AU0v %s", parse[0]));
			}
		
		// Fill with defaults if missing
		if (binruntime == null)
			binruntime = binroot.resolve("brun");
		if (binjit == null)
			binjit = binroot.resolve("bjit");
		if (bintest == null)
			bintest = binroot.resolve("btst");
		if (binbuild == null)
			binbuild = binroot.resolve("bbld");
		
		// Set paths
		return new ProjectManager(sourceroot,
			new Path[]{binruntime, binjit, bintest, binbuild}, deftimespace);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/ProjectType.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



























































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

package cc.squirreljme.builder.support;

/**
 * This represents the type of library or application that the project is, this
 * determines how it is used and depended upon.
 *
 * @since 2017/10/31
 */
public enum ProjectType
{
	/** APIs which implement configurations, profiles, and standards. */
	API,
	
	/** Liblets which are only included by midlets and APIs. */
	LIBLET,
	
	/** Midlets which are actual applications. */
	MIDLET,
	
	/** End. */
	;
	
	/**
	 * Returns the type of project that should be returned.
	 *
	 * @param __s The string to get the project type for.
	 * @return The project type or {@code null} if it is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public static ProjectType ofString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s)
		{
			case "api":		return API;
			case "liblet":	return LIBLET;
			case "midlet":	return MIDLET;
			
			default:
				return null;
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SDKFactory.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
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













































































































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

package cc.squirreljme.builder.support;

import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

/**
 * This goes through all of the projects and builds the SDK which is used as
 * a base for programs in SquirrelJME.
 *
 * There is the user SDK which only has specific packages which may be
 * referred to. In general, most programs will always use this.
 *
 * Additionally there is the proprietary SDK which can be used if one wants
 * to access the internal classes that exist.
 *
 * @since 2018/01/27
 */
public class SDKFactory
	implements Runnable
{
	/** The binary manager since they need to be accessed for building. */
	protected final BinaryManager binarymanager;
	
	/** The command to execute. */
	protected final String command;
	
	/** Arguments to the task command. */
	private final String[] _args;
	
	/**
	 * Initializes the factory.
	 *
	 * @param __bl The binary manager.
	 * @param __args factory arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/27
	 */
	public SDKFactory(BinaryManager __bm, String... __args)
		throws NullPointerException
	{
		if (__bm == null)
			throw new NullPointerException("NARG");
		
		this.binarymanager = __bm;
		
		// Copy arguments for processing
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.addLast(a);
		
		// {@squirreljme.error AU0w Expected command for SDK operation.}
		String command = args.pollFirst();
		if (command == null)
			throw new IllegalArgumentException("AU0w");
		this.command = command;
		
		// Use remaining arguments as input
		this._args = args.<String>toArray(new String[args.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/01/27
	 */
	@Override
	public void run()
	{
		// Load arguments into a queue
		Deque<String> args =
			new ArrayDeque<>(Arrays.<String>asList(this._args));
		
		// Depends on the command
		String command = this.command;
		switch (command)
		{
				// Build user SDK (publically available classes)
			case "build":
				throw new todo.TODO();
				
				// Build internal SDK (all classes)
			case "internal":
				throw new todo.TODO();
				
				// {@squirreljme.error AU0x The specified sdk command is not
				// valid. Valid commands are:
				// build, internal
				// .(The command)}
			case "help":
			default:
				throw new IllegalArgumentException(String.format("AU0x %s",
					command));
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/Source.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284




























































































































































































































































































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

package cc.squirreljme.builder.support;

import cc.squirreljme.runtime.swm.InvalidSuiteException;
import cc.squirreljme.runtime.swm.SuiteInfo;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Map;
import net.multiphasicapps.javac.ByteArrayCompilerInput;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.MergedPathSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;

/**
 * This represents a single source project which contains the source code for
 * a single project.
 *
 * @since 2017/10/31
 */
public abstract class Source
{
	/** The name of this project. */
	protected final SourceName name;
	
	/** The type of project this is. */
	protected final ProjectType type;
	
	/** The approximate binary manifest. */
	private Reference<JavaManifest> _approxbm;
	
	/** The suite information. */
	private Reference<SuiteInfo> _suiteinfo;
	
	/** Last modified time of the source code. */
	private long _lastmodtime =
		Long.MIN_VALUE;
	
	/**
	 * Initializes the base source.
	 *
	 * @param __n The name of the project.
	 * @param __t The type of project this is.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public Source(SourceName __n, ProjectType __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * Returns the path set which is used for the given path set type.
	 *
	 * @param __spst The path set type to get.
	 * @return The path set for the given type.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/30
	 */
	public abstract CompilerPathSet pathSet(SourcePathSetType __spst)
		throws NullPointerException;
	
	/**
	 * The source manifest.
	 *
	 * @return The source manifest.
	 * @since 2017/11/17
	 */
	public abstract JavaManifest sourceManifest();
	
	/**
	 * Returns the time that the source code was last modified.
	 *
	 * @return The last modification date of the source code.
	 * @throws IOException On read errors.
	 * @since 2017/11/06
	 */
	public final long lastModifiedTime()
	{
		// Could be pre-cached
		long rv = this._lastmodtime;
		if (rv != Long.MIN_VALUE)
			return rv;
		
		// Go through all input and compare the modified times
		try (CompilerPathSet ps = this.pathSet(SourcePathSetType.SOURCE))
		{
			rv = Long.MIN_VALUE;
			for (CompilerInput ci : ps)
			{
				long now = ci.lastModifiedTime();
				if (now > rv)
					rv = now;
			}
		}
		
		// Cache for next time
		this._lastmodtime = rv;
		return rv;
	}
	
	/**
	 * The approximated manifest which would be used for binary output.
	 *
	 * @return The approximated manifest.
	 * @since 2017/11/17
	 */
	public final JavaManifest manifest()
	{
		Reference<JavaManifest> ref = this._approxbm;
		JavaManifest rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Need the input manifest
			JavaManifest rman = this.sourceManifest();
			JavaManifestAttributes rattr = rman.getMainAttributes();
			MutableJavaManifest wman = new MutableJavaManifest();
			MutableJavaManifestAttributes wattr = wman.getMainAttributes();
			
			// Determine the prefix for the type keys
			ProjectType type = this.type;
			boolean isapi = type == ProjectType.API;
			String prefix = (type == ProjectType.MIDLET ?
				"MIDlet" : "LIBlet");
			
			// Projects might have dependencies, so find the actual base
			// before putting dependencies on top
			int depdx = 1;
			for (; depdx >= 0; depdx++)
				if (!rattr.containsKey(
					new JavaManifestKey(prefix + "-Dependency-" + depdx)))
					break;
			
			// Handle fields for the main attributes
			boolean apidetected = false;
			for (Map.Entry<JavaManifestKey, String> e : rattr.entrySet())
			{
				JavaManifestKey k = e.getKey();
				String v = e.getValue();
				
				// Depends on the key, these are lowercase
				switch (k.toString())
				{
						// Project name
					case "x-squirreljme-name":
						wattr.putValue(prefix + "-Name", v);
						break;
						
						// Project vendor
					case "x-squirreljme-vendor":
						wattr.putValue(prefix + "-Vendor", v);
						break;
						
						// Project version
					case "x-squirreljme-version":
						wattr.putValue(prefix + "-Version", v);
						break;
						
						// Project Description
					case "x-squirreljme-description":
						wattr.putValue(prefix + "-Description", v);
						break;
					
						// Dependencies, these are whitespace separated
					case "x-squirreljme-depends":
						for (String split : StringUtils.basicSplit("\0 \t\r\n",
							v))
							wattr.putValue(
								prefix + "-Dependency-" + (depdx++),
								"proprietary;required;squirreljme.project@" +
									split + ";Stephanie Gawroriski;*");
						break;
						
						// Never copy this flag
					case "x-squirreljme-isapi":
						break;
						
						// Only put API definitions in if these are actual APIs
					case "x-squirreljme-definesconfigurations":
					case "x-squirreljme-definesprofiles":
					case "x-squirreljme-definedstandards":
						if (isapi)
						{
							wattr.put(k, v);
							apidetected = true;
						}
						break;
					
						// Unhandled
					default:
						wattr.put(k, v);
						break;
				}
			}
			
			// Write the project name as it appears in the builder
			wattr.putValue("X-SquirrelJME-InternalProjectName",
				name().toString());
			
			// If an API was detected then flag it
			if (apidetected)
				wattr.putValue("X-SquirrelJME-IsAPI", "true");
			
			// Copy other attributes that may exist
			for (Map.Entry<String, JavaManifestAttributes> e : rman.entrySet())
			{
				// Do not copy the main manifest because that is specially
				// handled before
				String k;
				if (!"".equals((k = e.getKey())))
					wman.put(k,
						new MutableJavaManifestAttributes(e.getValue()));
			}
			
			// Build
			this._approxbm = new WeakReference<>((rv = wman.build()));
		}
		
		return rv;
	}
	
	/**
	 * Returns the name of the source.
	 *
	 * @return The source name.
	 * @since 2017/11/23
	 */
	public final SourceName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the suite information for this source project.
	 *
	 * @return The suite information to use.
	 * @throws InvalidSourceException If the source project is not valid.
	 * @since 2017/12/04
	 */
	public final SuiteInfo suiteInfo()
		throws InvalidSourceException
	{
		Reference<SuiteInfo> ref = this._suiteinfo;
		SuiteInfo rv;
		
		if (ref == null || null == (rv = ref.get()))
			try
			{
				this._suiteinfo = new WeakReference<>(
					(rv = new SuiteInfo(this.manifest())));
			}
			
			// {@squirreljme.error AU0y Could not approximate the binary
			// suite information. (The name of the project)}
			catch (InvalidSuiteException e)
			{
				throw new InvalidSourceException(
					String.format("AU0y %s", this.name), e);
			}
		
		return rv;
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SourceManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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





















































































































































































































































































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

package cc.squirreljme.builder.support;

import java.io.InputStream;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableCollection;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This class is used to provide access to source code that is available as
 * compilation sources.
 *
 * @since 2017/10/31
 */
public final class SourceManager
	implements Iterable<Source>
{
	/** The timespace used. */
	protected final TimeSpaceType timespace;
	
	/** Sources which are available. */
	private final Map<SourceName, Source> _sources;
	
	/**
	 * Initializes the source code manager.
	 *
	 * @param __t The timespace.
	 * @param __roots The root directories which contain namespaces where
	 * source projects are located.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public SourceManager(TimeSpaceType __t, Path... __roots)
		throws IOException, NullPointerException
	{
		if (__roots == null)
			throw new NullPointerException("NARG");
		
		this.timespace = __t;
		
		// Go through all the roots and detect the namespaces which are
		// valid
		Map<ProjectType, Set<Path>> namespaces = new SortedTreeMap<>();
		for (Path p : __roots)
			__scanNamespaces(p, namespaces);
		
		// Debug
		todo.DEBUG.note("Found namespaces %s%n", namespaces);
		
		// Go through all namespaces and initialize any projects which may be
		// within directories
		Map<SourceName, Source> sources = new SortedTreeMap<>();
		for (Map.Entry<ProjectType, Set<Path>> e : namespaces.entrySet())
		{
			ProjectType type = e.getKey();
			
			// Go through path and decode projects
			for (Path p : e.getValue())
				__scanSources(__t, p, sources, type);
		}
		
		// Set
		this._sources = sources;
	}
	
	/**
	 * Obtains the source by the given project name.
	 *
	 * @param __n The name of the source project.
	 * @return The source for the given project.
	 * @throws NoSuchSourceException If no source exists for the given name.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public final Source get(String __n)
		throws NoSuchSourceException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return get(new SourceName(__n));
	}
	
	/**
	 * Obtains the source by the given project name.
	 *
	 * @param __n The name of the source project.
	 * @return The source for the given project.
	 * @throws NoSuchSourceException If no source exists for the given name.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public final Source get(SourceName __n)
		throws NoSuchSourceException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AU0z No such source project exists. (The name
		// of the source project)}
		Source rv = this._sources.get(__n);
		if (rv == null)
			throw new NoSuchSourceException(String.format("AU0z %s", __n));
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/23
	 */
	@Override
	public final Iterator<Source> iterator()
	{
		return UnmodifiableCollection.<Source>of(this._sources.values()).
			iterator();
	}
	
	/**
	 * This scans the given directory for namespace directories and adds them
	 * to the given output path.
	 *
	 * @param __base The base path to scan for namespaces.
	 * @param __out The output map for namespace scans.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	private static final void __scanNamespaces(Path __base,
		Map<ProjectType, Set<Path>> __out)
		throws IOException, NullPointerException
	{
		if (__base == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Go through directories
		try (DirectoryStream<Path> ds = Files.newDirectoryStream(__base))
		{
			for (Path p : ds)
			{
				// Ignore non-directories
				if (!Files.isDirectory(p))
					continue;
				
				// Obtain the manifest
				JavaManifestAttributes attr;
				try (InputStream in = Files.newInputStream(
					p.resolve("NAMESPACE.MF"), StandardOpenOption.READ))
				{
					attr = new JavaManifest(in).getMainAttributes();
				}
				
				// No file here
				catch (NoSuchFileException e)
				{
					continue;
				}
				
				// Obtain the namespace type, ignore if none was specified
				String type = attr.getValue("X-SquirrelJME-Namespace-Type");
				if (type == null)
					continue;
				
				// See if it is a valid project type
				ProjectType ptype = ProjectType.ofString(type);
				if (ptype == null)
					continue;
				
				// Store into the map this path
				Set<Path> put = __out.get(ptype);
				if (put == null)
					__out.put(ptype, (put = new SortedTreeSet<>()));
				put.add(p);
			}
		}
	}
	
	/**
	 * This scans the given directory for source projects and adds them to the
	 * given map.
	 *
	 * @param __t Timespace type.
	 * @param __base The base directory to scan.
	 * @param __out The output map where projects are placed.
	 * @param __type The type 
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	private static final void __scanSources(TimeSpaceType __t, Path __base,
		Map<SourceName, Source> __out, ProjectType __type)
		throws IOException, NullPointerException
	{
		if (__t == null || __base == null || __out == null || __type == null)
			throw new NullPointerException("NARG");
		
		// Go through directories
		try (DirectoryStream<Path> ds = Files.newDirectoryStream(__base))
		{
			for (Path p : ds)
			{
				// Ignore non-directories
				if (!Files.isDirectory(p))
					continue;
				
				// Could fail
				SourceName triedname = null;
				try
				{
					// Determine source name
					SourceName name = new SourceName(
						p.getFileName().toString());
					triedname = name;
					
					// Ignore test projects, they are only referred to once
					// there is a base supporting project
					if (name.isTest())
						continue;
					
					// Initialize source project, check that the manifest
					// exists so invalid projects are not created
					BasicSource src = new BasicSource(name, p, __type);
					if (src.sourceManifest() == null)
						continue;
					
					// Store it
					__out.put(name, src);
					
					// If a test project exists, initialize it
					// But only if this is a the test timespace because
					// otherwise we will just get tons of tests in the way!
					if (__t.ordinal() >= TimeSpaceType.TEST.ordinal())
					{
						SourceName tn = new SourceName(name.name() + ".test");
						Path tr = p.resolveSibling(tn.name());
						if (Files.isRegularFile(tr.resolve("META-INF").resolve(
							"TEST.MF")))
							__out.put(tn, new TestSource(tr, src));
					}
				}
				
				// Ignore
				catch (InvalidSourceException e)
				{
					// {@squirreljme.error AU10 Tried to load a project but
					// it was determined to not be a valid project, ignoring.
					// (The project name; The exception message)}
					System.err.printf("AU10 %s `%s`%n", triedname,
						e.getMessage());
					continue;
				}
			}
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SourceManagerFactory.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
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


























































































































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

package cc.squirreljme.builder.support;

import java.io.InputStream;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.HashSet;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This is the factory which is used to create instances of
 * {@code SourceManager} which provides access to specific timespaces
 * depending on the needed context.
 *
 * @since 2017/11/10
 */
public class SourceManagerFactory
{
	/** The root of the source tree. */
	protected final Path root;
	
	/**
	 * Initializes the source manager.
	 *
	 * @param __root The root of the source tree.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/14
	 */
	public SourceManagerFactory(Path __root)
		throws NullPointerException
	{
		if (__root == null)
			throw new NullPointerException("NARG");
		
		this.root = __root;
	}
	
	/**
	 * Obtains the source manager which uses the specified types.
	 *
	 * @param __t The timespace to source projects from.
	 * @return The source manager over those packages.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/14
	 */
	public SourceManager get(TimeSpaceType __t)
		throws IOException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Only look for specific timespaces
		Set<TimeSpaceType> want = new HashSet<>();
		int basei = __t.ordinal();
		for (TimeSpaceType t : TimeSpaceType.values())
			if (t.ordinal() <= basei)
				want.add(t);
		
		// Go through root files searching for directories containing timespace
		// manifests
		Set<Path> from = new SortedTreeSet<>();
		try (DirectoryStream<Path> ds = Files.newDirectoryStream(this.root))
		{
			for (Path p : ds)
			{
				// Ignore non-directories
				if (!Files.isDirectory(p))
					continue;
				
				// Read manifest
				JavaManifest man;
				try (InputStream is = Files.newInputStream(
					p.resolve("TIMESPACE.MF"), StandardOpenOption.READ))
				{
					man = new JavaManifest(is);
				}
				
				catch (NoSuchFileException e)
				{
					continue;
				}
				
				// Ignore unspecified timespaces
				String stype = man.getMainAttributes().getValue(
					"X-SquirrelJME-Timespace-Type");
				if (stype == null)
					continue;
				
				// Ignore unknown timespaces
				TimeSpaceType type = TimeSpaceType.ofString(stype);
				if (type == null)
					continue;
				
				// If this is a desired namespace, use that
				if (want.contains(type))
					from.add(p);
			}	
		}
		
		// Setup source manager
		return new SourceManager(__t,
			from.<Path>toArray(new Path[from.size()]));
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SourceName.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
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
191
192
193
194


































































































































































































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

package cc.squirreljme.builder.support;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * This represents the name of a source project.
 *
 * @since 2017/10/31
 */
public final class SourceName
	implements Comparable<SourceName>
{
	/** The name string. */
	protected final String name;
	
	/**
	 * Initailizes the source name.
	 *
	 * @param __n The name of the source.
	 * @throws InvalidSourceNameException If the name is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/31
	 */
	public SourceName(String __n)
		throws InvalidSourceNameException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Is test
		boolean istest = __n.endsWith(".test");
		if (istest)
			__n = __n.substring(0, __n.length() - ".test".length());
		
		// Check for valid characters and lowercase
		StringBuilder sb = new StringBuilder();
		for (int i = 0, n = __n.length(); i < n; i++)
		{
			char c = __n.charAt(i);
			
			// {@squirreljme.error AU11 The project source name contains an
			// invalid character. (The specified character)}
			if (c <= ' ' || c >= 0x7F)
				throw new InvalidSourceNameException(
					String.format("AU11 %c", c));
			
			// Lowercase
			else if (c >= 'A' && c <= 'Z')
				c = (char)((c - 'A') + 'a');
			
			sb.append(c);
		}
		
		// If this is a test, then add the test
		if (istest)
			sb.append(".test");
		
		// Set
		this.name = sb.toString();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/31
	 */
	@Override
	public int compareTo(SourceName __n)
	{
		return this.name.compareTo(__n.name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof SourceName))
			return false;
		
		return this.name.equals(((SourceName)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/31
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Does this refer to a test project?
	 *
	 * @return If this refers to a test project.
	 * @since 2018/03/06
	 */
	public final boolean isTest()
	{
		return this.name().endsWith(".test");
	}
	
	/**
	 * Returns the source name.
	 *
	 * @return The source name.
	 * @since 2018/03/06
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Returns the path to the file.
	 *
	 * @return The file name of the path.
	 * @since 2017/11/23
	 */
	public final Path toFileName()
	{
		return Paths.get(this.name + ".jar");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/31
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
	
	/**
	 * Checks whether the the given path refers to a valid binary.
	 *
	 * @param __p The path to check.
	 * @return If the given path is a binary path.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final boolean isBinaryPath(Path __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Ignore no file name
		Path fn = __p.getFileName();
		if (fn == null)
			return false;
		
		// Only use certain extensions
		String base = fn.toString();
		return base.endsWith(".jar") || base.endsWith(".JAR");
	}
	
	/**
	 * Returns the source name for this binary path.
	 *
	 * @param __p The path to translate to the source name.
	 * @return The source name for this associated binary path.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/05
	 */
	public static final SourceName ofBinaryPath(Path __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Try to determine the base name of the path
		String base = __p.getFileName().toString();
		if (isBinaryPath(__p))
			return new SourceName(base.substring(0, base.length() - 4));
		return new SourceName(base);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SourcePathSetType.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





























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

package cc.squirreljme.builder.support;

/**
 * Represents the source path set that are available for usage.
 *
 * @since 2018/04/30
 */
public enum SourcePathSetType
{
	/** Source code. */
	SOURCE,
	
	/** Compiled code, may include generated code. */
	COMPILED,
	
	/** End. */
	;
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/SuiteFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254






























































































































































































































































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

package cc.squirreljme.builder.support;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;
import javax.microedition.swm.InstallErrorCodes;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteInstaller;
import javax.microedition.swm.SuiteInstallListener;
import javax.microedition.swm.SuiteInstallStage;
import javax.microedition.swm.SuiteManagementTracker;
import javax.microedition.swm.SuiteManager;
import javax.microedition.swm.SuiteStateFlag;
import javax.microedition.swm.SuiteType;

/**
 * This manages suites which are available to the build system.
 *
 * @since 2017/12/08
 */
public class SuiteFactory
	implements Runnable
{
	/** The command to execute. */
	protected final String command;
	
	/** The manager for suites, which is required. */
	protected final SuiteManager manager;
	
	/** Arguments to the task command. */
	private final String[] _args;
	
	/**
	 * Initializes the suite factory.
	 *
	 * @param __args The argument to the factory.
	 * @since 2017/12/08
	 */
	public SuiteFactory(String... __args)
	{
		// Copy arguments for processing
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.addLast(a);
		
		// Obtain the manager because it is possible that there are
		// no permissions to do so
		this.manager = ManagerFactory.getSuiteManager();
		
		// {@squirreljme.error AU12 Expected command for suite operation.}
		String command = args.pollFirst();
		if (command == null)
			throw new IllegalArgumentException("AU12");
		this.command = command;
		
		// Use remaining arguments as input
		this._args = args.<String>toArray(new String[args.size()]);
	}
	
	/**
	 * Installs the specified path which points to a JAR.
	 *
	 * @param __p The path to the JAR to install.
	 * @return The suite for the installed JAR.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/27
	 */
	public Suite installSuite(Path __p)
		throws IOException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Read in the JAR
		byte[] jardata;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream is = Files.newInputStream(__p,
				StandardOpenOption.READ))
		{
			byte[] buf = new byte[512];
			for (;;)
			{
				int rv = is.read(buf);
				
				if (rv < 0)
					break;
				
				baos.write(buf, 0, rv);
			}
			
			baos.flush();
			jardata = baos.toByteArray();
		}
		
		// Obtain installer for the JAR
		SuiteInstaller installer = this.manager.getSuiteInstaller(jardata, 0,
			jardata.length, false);
		
		// Setup a class which nicely waits for the suite to install
		__SuiteInstallWaiter__ waiter = new __SuiteInstallWaiter__(System.out);
		installer.addInstallationListener(waiter);
		
		// Run the installer and then wait for it to finish
		SuiteManagementTracker tracker = installer.start();
		return waiter.get();
	}
	
	/**
	 * Lists the suites which are available for usage.
	 *
	 * @param __out Where the suite list is output.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/08
	 */
	public void listSuites(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// Print application suites
		SuiteManager manager = this.manager;
		for (Suite s : manager.getSuites(SuiteType.APPLICATION))
			printSuite(__out, s);
		
		// Then print libraries
		for (Suite s : manager.getSuites(SuiteType.LIBRARY))
			printSuite(__out, s);
	}
	
	/**
	 * {@inheritDoc}
	 * @sincd 2017/12/08
	 */
	@Override
	public void run()
	{
		// Load arguments into a queue
		Deque<String> args =
			new ArrayDeque<>(Arrays.<String>asList(this._args));
		
		// Depends on the command
		String command = this.command;
		switch (command)
		{
				// List tasks
			case "ls":
			case "list":
				listSuites(System.out);
				break;
				
				// Install a suite
			case "install":
				try
				{
					// {@squirreljme.error AU13 The "suite install" command
					// requires a path to a JAR file to install.}
					String path = args.pollFirst();
					if (path == null)
						throw new IllegalArgumentException("AU13");
					
					// Install and print suite information
					printSuite(System.out, installSuite(Paths.get(path)));
				}
				
				// {@squirreljme.error AU14 Read/write error installing suite.}
				catch (IOException e)
				{
					throw new RuntimeException("AU14", e);
				}
				break;
				
				// {@squirreljme.error AU15 The specified suite command is not
				// valid. Valid commands are:
				// ls, list;
				// install (path);
				// . (The command)}
			case "help":
			default:
				throw new IllegalArgumentException(String.format("AU15 %s",
					command));
		}
	}
	
	/**
	 * Prints the specified suite to the output stream.
	 *
	 * @param __out The stream to print the suite information to.
	 * @param __s The suite to print.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/08
	 */
	public static void printSuite(PrintStream __out, Suite __s)
		throws NullPointerException
	{
		if (__out == null || __s == null)
			throw new NullPointerException("NARG");
		
		__out.printf("Suite: %s (%s)%n", __s.getName(), __s.getSuiteType());
		
		__out.printf("\tInstalled ? %s%n", __s.isInstalled());
		__out.printf("\tTrusted   ? %s%n", __s.isTrusted());
		__out.printf("\tVendor    : %s%n", __s.getVendor());
		__out.printf("\tVersion   : %s%n", __s.getVersion());
		__out.printf("\tSource URL: %s%n", __s.getDownloadUrl());
		
		__out.println("\tFlags:");
		for (SuiteStateFlag f : SuiteStateFlag.values())
			__out.printf("\t\tFlag %s is %s%n", f,
				(__s.isSuiteState(f) ? "set" : "not set"));
		
		__out.println("\tMIDlets:");
		for (Iterator<String> it = __s.getMIDlets(); it.hasNext();)
			__out.printf("\t\t%s%n", it.next());
		
		__out.println("\tAttributes:");
		for (Iterator<String> it = __s.getAttributes(); it.hasNext();)
		{
			String key = it.next();
			__out.printf("\t\t%s: %s%n", key, __s.getAttributeValue(key));
		}
			
		__out.println("\tDependencies:");
		for (Iterator<Suite> it = __s.getDependencies(); it.hasNext();)
		{
			Suite dep = it.next();
			__out.printf("\t\t%s %s%n", dep.getName(), dep.getVendor());
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/TaskFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254






























































































































































































































































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

package cc.squirreljme.builder.support;

import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteManager;
import javax.microedition.swm.SuiteType;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskManager;
import javax.microedition.swm.TaskStatus;

/**
 * This is a factory which is used to handle tasks via the SWM sub-system.
 *
 * @since 2017/12/07
 */
public class TaskFactory
	implements Runnable
{
	/** The command to execute. */
	protected final String command;
	
	/** The manager for tasks, which is required. */
	protected final TaskManager manager;
	
	/** Arguments to the task command. */
	private final String[] _args;
	
	/**
	 * Initializes the SWM task factory.
	 *
	 * @param __args The argument to the factory.
	 * @since 2017/12/07
	 */
	public TaskFactory(String... __args)
	{
		// Copy arguments for processing
		Deque<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.addLast(a);
		
		// Obtain the manager because it is possible that there are
		// no permissions to do so
		this.manager = ManagerFactory.getTaskManager();
		
		// {@squirreljme.error AU16 Expected command for task operation.}
		String command = args.pollFirst();
		if (command == null)
			throw new IllegalArgumentException("AU16");
		this.command = command;
		
		// Use remaining arguments as input
		this._args = args.<String>toArray(new String[args.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public void run()
	{
		// Load arguments into a queue
		Deque<String> args =
			new ArrayDeque<>(Arrays.<String>asList(this._args));
		
		// Depends on the command
		String command = this.command;
		switch (command)
		{
				// Launch a task
			case "launch":
				{
					// Parse arguments
					String[] parse;
					while (null != (parse = BuilderFactory.
						__getopts(":?", args)))
						switch (parse[0])
						{
								// {@squirreljme.error AU17 Unknown argument.
								// Usage: launch [suite] (class name).
								// }
							default:
								throw new IllegalArgumentException("AU17");
						}
					
					// {@squirreljme.error AU18 Expected name of class to
					// start as a system task.}
					String arga = args.pollFirst();
					if (arga == null)
						throw new IllegalArgumentException("AU18");
					
					// Secondary argument is optional
					String argb = args.pollFirst();
					
					// Launch task
					Task task;
					if (argb == null)
						task = launch(null, arga);
					else
						task = launch(arga, argb);
					
					// Wait for the task to terminate
					// There is no non-blocking mechanism which waits until
					// the task terminates, so just keep quering the state
					// until it is not running
					TaskStatus status;
					for (;;)
					{
						status = task.getStatus();
						if (status != TaskStatus.STARTING &&
							status != TaskStatus.RUNNING)
							break;
						
						// Sleep so the CPU is not burnt out
						try
						{
							Thread.sleep(500);
						}
						catch (InterruptedException e)
						{
						}
					}
					
					// {@squirreljme.error AU19 The task exited with the
					// given status. (The status)}
					if (status != TaskStatus.EXITED_REGULAR)
						throw new RuntimeException(String.format(
							"AU19 %s%n", status));
				}
				break;
				
				// List tasks
			case "ls":
			case "list":
				listTasks(System.out);
				break;
				
				// {@squirreljme.error AU1a The specified task command is not
				// valid. Valid commands are:
				// ls, list, launch
				// .(The command)}
			case "help":
			default:
				throw new IllegalArgumentException(String.format("AU1a %s",
					command));
		}
	}
	
	/**
	 * Lists the tasks and prints them to the specified stream.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/07
	 */
	public void listTasks(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Go through all tasks
		for (Task t : this.manager.getTaskList(true))
		{
			__ps.printf("Task: %s%n", t.getName());
			
			__ps.printf("\tis system? %s%n", t.isSystemTask());
			__ps.printf("\tpriority : %s%n", t.getPriority());
			__ps.printf("\tstatus   : %s%n", t.getStatus());
			__ps.printf("\tused heap: %d bytes%n", t.getHeapUse());
			
			// Print suite information
			Suite s = t.getSuite();
			if (s != null)
				SuiteFactory.printSuite(__ps, s);
		}
	}
	
	/**
	 * Launches the optional suite and via the given class.
	 *
	 * @param __su The suite to launch, if {@code null} then the system suite
	 * is used.
	 * @param __cl The class to use as the entry point.
	 * @throws NullPointerException If no class was specified.
	 * @since 2017/12/08
	 */
	public Task launch(String __su, String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Locate the suite to use
		Suite suite = null;
		if (__su != null)
		{
			// For simplicity have an index lookup
			int wantdx = -1;
			try
			{
				wantdx = Integer.parseInt(__su);
			}
			catch (NumberFormatException e)
			{
			}
			
			// Go through suites and try to find a match
			SuiteManager sm = ManagerFactory.getSuiteManager();
			int atdx = 0;
			for (Suite s : sm.getSuites(SuiteType.APPLICATION))
				if (wantdx == (atdx++) ||
					__su.equals(s.getName()) ||
					__su.equals(s.getVendor()))
				{
					suite = s;
					break;
				}
			
			// {@squirreljme.error AU1b Could not locate a suite with the
			// given name. (The input name)}
			if (suite == null)
				throw new IllegalArgumentException(
					String.format("AU1b %s", __su));
		}
		
		// Use system suite
		else
			suite = Suite.SYSTEM_SUITE;
		
		// Show suite to launch
		SuiteFactory.printSuite(System.out, suite);
		
		// Start the task
		return this.manager.startTask(suite, __cl);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/TestParser.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































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

package cc.squirreljme.builder.support;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;
import net.multiphasicapps.javac.token.BufferedTokenSource;

/**
 * This is used to parse classes to look for tests that exist within source
 * code.
 *
 * @since 2018/03/19
 */
@Deprecated
public final class TestParser
	implements Runnable
{
	/** The input to read from. */
	protected final CompilerInput input;
	
	/** The storage area for discovered tests. */
	protected final DefinedTests defined;
	
	/**
	 * Initializes the parser.
	 *
	 * @param __in The input file.
	 * @param __def Where discovered tests will go.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public TestParser(CompilerInput __in, DefinedTests __def)
		throws NullPointerException
	{
		if (__in == null || __def == null)
			throw new NullPointerException("NARG");
		
		this.input = __in;
		this.defined = __def;
	}
	 
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public void run()
	{
		CompilerInput input = this.input;
		
		// Parse the class layout
		try (InputStream in = input.open())
		{
			// Parse compilation unit
			CompilationUnitSyntax cu = CompilationUnitSyntax.parse(
				new BufferedTokenSource(input.fileName(), in));
			
			//toplevel = TopLevelLayout.parse(input.fileName(), in);
			if (true)
				throw new todo.TODO();
		}
		
		// {@squirreljme.error AU1c Could not parse file for tests.}
		catch (IOException|CompilerException e)
		{
			throw new RuntimeException("AU1c", e);
		}
		
		throw new todo.TODO();
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/TestSource.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
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
191































































































































































































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

package cc.squirreljme.builder.support;

import cc.squirreljme.runtime.swm.SuiteInfo;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.javac.ByteArrayCompilerInput;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.DistinctPathSet;
import net.multiphasicapps.javac.FilePathSet;
import net.multiphasicapps.javac.MergedPathSet;
import net.multiphasicapps.javac.structure.RuntimeInput;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;

/**
 * This represents source code for the tests which are made for a given project
 * which allows the invocation area of the test code to be automatically
 * generated accordingly.
 *
 * @since 2018/03/06
 */
public final class TestSource
	extends Source
{
	/** The root of the source. */
	protected final Path root;
	
	/** The project this is a test for. */
	protected final BasicSource testfor;
	
	/** The virtual main package. */
	protected final String mainpackage;
	
	/** Virtual manifest for this source. */
	private Reference<JavaManifest> _manifest;
	
	/** Last modified time of the source code. */
	private volatile long _lastmodtime =
		Long.MIN_VALUE;
	
	/**
	 * Initializes the source for test projects.
	 *
	 * @param __root The directory for the test.
	 * @param __for The base project this is a test for.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public TestSource(Path __root, BasicSource __for)
		throws NullPointerException
	{
		super(new SourceName(__for.name() + ".test"), ProjectType.MIDLET);
		
		if (__root == null || __for == null)
			throw new NullPointerException("NARG");
		
		this.root = __root;
		this.testfor = __for;
		
		// Setup virtual main package
		this.mainpackage = "cc.squirreljme.tests._" + __for.name().toString().
			replace('-', '_');
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final CompilerPathSet pathSet(SourcePathSetType __spst)
		throws NullPointerException
	{
		if (__spst == null)
			throw new NullPointerException("NARG");
		
		// Always use the root source set
		return new FilePathSet(this.root);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final JavaManifest sourceManifest()
	{
		Reference<JavaManifest> ref = this._manifest;
		JavaManifest rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Build virtual manifest intended to act as tests for the input
			// library
			BasicSource testfor = this.testfor;
			MutableJavaManifest wman = new MutableJavaManifest();
			MutableJavaManifestAttributes wattr = wman.getMainAttributes();
		
			SuiteInfo bs = testfor.suiteInfo();
			
			String coolname = "Tests for " + bs.name().toString();
			
			wattr.putValue("x-squirreljme-name", coolname);
			wattr.putValue("x-squirreljme-vendor", bs.vendor().toString());
			wattr.putValue("x-squirreljme-version", bs.version().toString());
			wattr.putValue("x-squirreljme-description", coolname);
			wattr.putValue("x-squirreljme-depends", testfor.name().name() +
				" meep-midlet tac");
			wattr.putValue("x-squirreljme-tests", "true");
			
			// All of the tests are just MIDlets to be ran accordingly as if
			// they were unique individual programs within the JAR
			Set<String> classes = this.__testClass();
			int next = 1;
			for (String cl : classes)
				wattr.putValue("midlet-" + (next++),
					"TEST " + cl + ",," + cl);
			
			// Finalize
			this._manifest = new WeakReference<>((rv = wman.build()));
		}
		
		return rv;
	}
	
	/**
	 * Returns classes which make up the test classes.
	 *
	 * @return The tests which are available.
	 * @since 2018/10/06
	 */
	private Set<String> __testClass()
	{
		// Classes which are available for testing
		Set<String> classes = new SortedTreeSet<>();
		
		// Parse every input class file and look for tests according to
		// a given file syntax
		for (CompilerInput ci : this.pathSet(SourcePathSetType.SOURCE))
		{
			// Only consider Java source and class files
			String name = ci.fileName();
			if (!name.endsWith(".java") && !name.endsWith(".class") &&
				!name.endsWith(".class.__mime"))
				continue;
			
			// Remove the extension
			name = name.substring(0, name.indexOf('.'));
			
			// Get the basename, because the test could be organized into
			// packages which might mess with parsing. Although generally
			// tests are likely in just the default package
			int ls = name.lastIndexOf('/');
			String base = (ls < 0 ? name : name.substring(ls + 1));
			
			// Ignore classes with dollar signs because that indicates an
			// inner class
			if (base.indexOf('$') >= 0)
				continue;
			
			// Only if the given patterns are matched is the test added
			if (base.startsWith("Do") ||
				base.startsWith("Test") ||
				base.endsWith("Test"))
				classes.add(name.replace('/', '.'));
		}
		
		// Return all the discovered classes
		return classes;
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/TimeSpaceType.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





























































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

package cc.squirreljme.builder.support;

/**
 * This specifies the type of timespace to select when looking for projects.
 *
 * @since 2017/11/14
 */
public enum TimeSpaceType
{
	/** Runtime. */
	RUNTIME,
	
	/** JIT time. */
	JIT,
	
	/** Testing. */
	TEST,
	
	/** Build time. */
	BUILD,
	
	/** End. */
	;
	
	/**
	 * Returns the timespace type for the given string.
	 *
	 * @param __s The input string.
	 * @return The timespace for the given input or {@code null} if there is
	 * no such timespace.
	 * @since 2017/11/16
	 */
	public static TimeSpaceType ofString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		switch (__s)
		{
			case "runtime":		return RUNTIME;
			case "jit":			return JIT;
			case "test":		return TEST;
			case "build":		return BUILD;
			
			default:
				return null;
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/__SuiteInstallWaiter__.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
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

























































































































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

package cc.squirreljme.builder.support;

import java.io.PrintStream;
import javax.microedition.swm.InstallErrorCodes;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteInstallListener;
import javax.microedition.swm.SuiteInstallStage;
import javax.microedition.swm.SuiteManagementTracker;

/**
 * This class allows for suites to be waited upon when they are installed.
 *
 * @since 2017/12/27
 */
class __SuiteInstallWaiter__
	implements SuiteInstallListener
{
	/** Where messages on progress are printed to. */
	protected final PrintStream out;
	
	/** The installed suite. */
	private volatile Suite _suite;
	
	/** Installation error code. */
	private volatile InstallErrorCodes _error;
	
	/**
	 * Initializes the waiter.
	 *
	 * @param __out The stream where progress is printed.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/27
	 */
	__SuiteInstallWaiter__(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
	}
	
	/**
	 * Returns the installed suite.
	 *
	 * @return The installed suite.
	 * @throws RuntimeException If the suite did not install properly.
	 * @since 2017/12/27
	 */
	public Suite get()
	{
		for (;;)
			synchronized (this)
			{
				// If a suite was installed use that
				Suite suite = this._suite;
				if (suite != null)
					return suite;
				
				// {@squirreljme.error AU1d The suite installation failed with
				// the given error code. (The error code)}
				InstallErrorCodes error = this._error;
				if (error != null)
					throw new RuntimeException(String.format("AU1d %s",
						error));
				
				// Installation can be notified from another thread
				try
				{
					this.wait(1_000);
				}
				catch (InterruptedException e)
				{
				}
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/27
	 */
	@Override
	public void installationDone(InstallErrorCodes __err,
		SuiteManagementTracker __tracker)
	{
		this.out.printf("Finished: %s%n", __err);
		
		// One thread will be locked on this
		synchronized (this)
		{
			// Set suite and code
			this._error = __err;
			this._suite = __tracker.getSuite();
		
			// Signal self that the suite was installed
			this.notify();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/27
	 */
	@Override
	public void updateStatus(SuiteManagementTracker __tracker,
		SuiteInstallStage __stage, int __percent)
	{
		this.out.printf("%s: %d%%%n", __stage, __percent);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/DistBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365













































































































































































































































































































































































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

package cc.squirreljme.builder.support.dist;

import cc.squirreljme.builder.support.ProjectManager;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.NoSuchFileException;
import java.util.Date;
import java.util.ServiceLoader;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * This is the base class which is used to build distributions.
 *
 * The service loader is used.
 *
 * @since 2018/12/24
 */
public abstract class DistBuilder
{
	/** The name of this distribution. */
	protected final String name;
	
	/**
	 * Initializes the base distribution builder.
	 *
	 * @param __n The name of the distribution.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public DistBuilder(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * Performs specific build stuff.
	 *
	 * @param __pm The project manager used.
	 * @param __zip The output ZIP.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	protected abstract void specific(ProjectManager __pm,
		ZipCompilerOutput __zip)
		throws IOException, NullPointerException;
	
	/**
	 * Builds this distribution.
	 *
	 * @param __pm The project manager, needed to get resources.
	 * @param __zip The output ZIP file.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public final void build(ProjectManager __pm, ZipCompilerOutput __zip)
		throws IOException, NullPointerException
	{
		if (__pm == null || __zip == null)
			throw new NullPointerException("NARG");
		
		// Add some information about the build
		long buildtime = System.currentTimeMillis();
		DistBuilder.copyStrings(__zip, "SQUIRRELJME-BUILD.MF",
			"Manifest-Version: 1.0",
			"Distribution-Name: " + this.name,
			"Build-Date: " + new Date(buildtime),
			"Build-Time: " + buildtime,
			"Build-Host-Java-Version: "
				+ System.getProperty("java.version"),
			"Build-Host-Java-Vendor: "
				+ System.getProperty("java.vendor"),
			"Build-Host-Java-Vendor-EMail: "
				+ System.getProperty("java.vendor.email"),
			"Build-Host-Java-Vendor-URL: "
				+ System.getProperty("java.vendor.url"),
			"Build-Host-Java-VM-Name: "
				+ System.getProperty("java.vm.name"),
			"Build-Host-Java-VM-Version: "
				+ System.getProperty("java.vm.version"),
			"Build-Host-SquirrelJME-APILevel: "
				+ System.getProperty("cc.squirreljme.apilevel"),
			"Build-Host-Java-VM-Vendor: "
				+ System.getProperty("java.vm.vendor"),
			"Build-Host-Java-VM-Vendor-EMail: "
				+ System.getProperty("java.vm.vendor.email"),
			"Build-Host-Java-VM-Vendor-URL: "
				+ System.getProperty("java.vm.vendor.url"),
			"Build-Host-Java-Runtime-Name: "
				+ System.getProperty("java.runtime.name"),
			"Build-Host-Java-Runtime-Version: "
				+ System.getProperty("java.runtime.version"),
			"Build-Host-OS-Name: "
				+ System.getProperty("os.name"),
			"Build-Host-OS-Arch: "
				+ System.getProperty("os.arch"),
			"Build-Host-OS-Version: "
				+ System.getProperty("os.version"));
		
		// Copy a bunch of root files which should always exist
		DistBuilder.copyRootFile(__zip, "asruntime.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "building.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "changelog.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "code-of-conduct.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "compatibility.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "contributing.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "design.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "history.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "license.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "public-key.gpg.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "readme.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "scope.mkd", __pm);
		DistBuilder.copyRootFile(__zip, "squirreljme-version", __pm);
		
		// Fossil specific stuff
		try
		{
			DistBuilder.copyRootFile(__zip, "repo-manifest",
				__pm, "manifest");
			DistBuilder.copyRootFile(__zip, "repo-revision",
				__pm, "manifest.uuid");
		}
		catch (NoSuchFileException e)
		{
		}
		
		// Dist specific usage file
		try
		{
			DistBuilder.copyRootFile(__zip, "usage.mkd",
				__pm, "assets/doc/usage-" + this.name + ".mkd");
		}
		catch (NoSuchFileException e)
		{
		}
		
		// Do specific build stuff, which depends on the distrubution target.
		this.specific(__pm, __zip);
	}
	
	/**
	 * Returns the name of the distribution.
	 *
	 * @return The distribution name.
	 * @since 2018/12/24
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Locates the builder for the given name and returns it.
	 *
	 * @param __n The name of the builder to locate.
	 * @return The builder.
	 * @throws IllegalArgumentException If the builder was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static DistBuilder builder(String __n)
		throws IllegalArgumentException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Find the one with the given name
		for (DistBuilder b : ServiceLoader.<DistBuilder>load(
			DistBuilder.class))
			if (__n.equals(b.name()))
				return b;
		
		// {@squirreljme.error AU1e No distribution exists under the given
		// name. (The distribution name)}
		throw new IllegalArgumentException("AU1e " + __n);
	}
	
	/**
	 * Copies the given bytes to the output.
	 *
	 * @param __out The output ZIP.
	 * @param __as The name to write the file as
	 * @param __b The bytes to store.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyBytes(ZipCompilerOutput __out, String __as,
		byte... __b)
		throws IOException, NullPointerException
	{
		DistBuilder.copyInputStream(__out, __as,
			new ByteArrayInputStream(__b));
	}
	
	/**
	 * Copies the given input stream to the output ZIP.
	 *
	 * @param __out The output ZIP.
	 * @param __as The name to write the file as
	 * @param __in The stream to read from.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyInputStream(ZipCompilerOutput __out, String __as,
		InputStream __in)
		throws IOException, NullPointerException
	{
		if (__out == null || __in == null || __as == null)
			throw new NullPointerException("NARG");
		
		// Setup output using the name we want to put it under
		try (OutputStream os = __out.output(__as))
		{
			byte[] buf = new byte[4096];
			for (;;)
			{
				int rc = __in.read(buf);
				
				if (rc < 0)
					break;
				
				os.write(buf, 0, rc);
			}
		}
	}
	
	/**
	 * Copies a file from the project manager root to the given ZIP output.
	 *
	 * @param __out The output ZIP.
	 * @param __as The name of the input file to load, it is named the in the
	 * ZIP as the name.
	 * @param __pm The project manager.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyRootFile(ZipCompilerOutput __out, String __as,
		ProjectManager __pm)
		throws IOException, NullPointerException
	{
		DistBuilder.copyRootFile(__out, __as, __pm, __as);
	}
	
	/**
	 * Copies a file from the project manager root to the given ZIP output.
	 *
	 * @param __out The output ZIP.
	 * @param __as The name the file should be in the target ZIP.
	 * @param __pm The project manager.
	 * @param __name The name of the input file.
	 * @throws IOException On read/write errors.
	 * @throws NoSuchFileException If the root file does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyRootFile(ZipCompilerOutput __out, String __as,
		ProjectManager __pm, String __name)
		throws IOException, NoSuchFileException, NullPointerException
	{
		if (__out == null || __pm == null || __name == null || __as == null)
			throw new NullPointerException("NARG");
		
		// Source the files from the project root always
		try (InputStream in = __pm.rootFile(__name))
		{
			// {@squirreljme.error AU1f The root file does not exist.
			// (The name of the file)}
			if (in == null)
				throw new NoSuchFileException("AU1f " + __name);
			
			// Copy the input
			DistBuilder.copyInputStream(__out, __as, in);
		}
	}
	
	/**
	 * Copies the given strings to the output. A CRLF is added at the end
	 * of each line.
	 *
	 * @param __out The output ZIP.
	 * @param __as The name to write the file as
	 * @param __s The strings to store.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyStrings(ZipCompilerOutput __out, String __as,
		String... __s)
		throws IOException, NullPointerException
	{
		DistBuilder.copyStrings("\r\n", __out, __as, __s);
	}
	
	/**
	 * Copies the given strings to the output.
	 *
	 * @param __eol The end of line sequence to use.
	 * @param __out The output ZIP.
	 * @param __as The name to write the file as
	 * @param __s The strings to store.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public static void copyStrings(String __eol,
		ZipCompilerOutput __out, String __as, String... __s)
		throws IOException, NullPointerException
	{
		if (__eol == null || __out == null || __as == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Setup string which has all the lines
		StringBuilder sb = new StringBuilder();
		for (String s : __s)
			if (s != null)
			{
				sb.append(s);
				sb.append(__eol);
			}
		
		// Treat this file as a bunch of 
		DistBuilder.copyBytes(__out, __as, sb.toString().getBytes("utf-8"));
	}
	
	/**
	 * Returns the list of builders which are available.
	 *
	 * @return The list of available builders.
	 * @since 2018/12/24
	 */
	public static String[] listBuilders()
	{
		// Build list but make sure it is always sorted since that works
		// much better
		Set<String> rv = new SortedTreeSet<>();
		for (DistBuilder b : ServiceLoader.<DistBuilder>load(
			DistBuilder.class))
			rv.add(b.name());
		
		return rv.<String>toArray(new String[rv.size()]);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/PalmOSDist.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
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



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.builder.support.dist;

import dev.shadowtail.palmos.PalmDatabaseAttribute;
import dev.shadowtail.palmos.PalmDatabaseBuilder;
import dev.shadowtail.palmos.PalmDatabaseType;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * Palm OS distribution.
 *
 * @since 2019/07/13
 */
public class PalmOSDist
	extends SummerCoatROM
{
	/** The size of a single fragment of the ROM. */
	public static final int ROM_FRAGMENT_SIZE =
		32768;
	
	/**
	 * Initializes the builder.
	 *
	 * @since 2019/07/13
	 */
	public PalmOSDist()
	{
		super("palmos");
	}
	
	/**
	 * Builds the ROM database.
	 *
	 * @param __out The stream to write to.
	 * @param __bp The build parameters.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	protected void buildRomDatabase(OutputStream __out, BuildParameters __bp)
		throws IOException, NullPointerException
	{
		if (__out == null || __bp == null)
			throw new NullPointerException("NARG");
		
		// Build the ROM first and get its bytes
		byte[] romdata = __bp.minimize();
		int romlen = romdata.length;
		
		// The ROM must be split into multiple fragments due to HotSync
		// limitation
		int numfrags = (romlen / ROM_FRAGMENT_SIZE) + 1;
		
		// Create builder for the database
		PalmDatabaseBuilder db = new PalmDatabaseBuilder(
			PalmDatabaseType.RESOURCE);
		
		// Used to set the version number
		Calendar cal = Calendar.getInstance();
		
		// Set information on the database
		db.setName("SquirrelJME ROM");
		db.setType("mROM");
		db.setCreator("SjME");
		db.setVersion(((((cal.get(Calendar.YEAR) - 2016) * 365) +
			cal.get(Calendar.DAY_OF_YEAR)) * 24) +
			cal.get(Calendar.HOUR_OF_DAY));
		db.setAttributes(PalmDatabaseAttribute.BACKUP,
			PalmDatabaseAttribute.OK_TO_INSTALL_NEWER,
			PalmDatabaseAttribute.BUNDLE);
		
		// Write ROM length
		try (DataOutputStream ent = new DataOutputStream(
			db.addEntry("RlEN", 0)))
		{
			ent.writeInt(romlen);
		}
		
		// Write fragment length
		try (DataOutputStream ent = new DataOutputStream(
			db.addEntry("FlEN", 0)))
		{
			ent.writeInt(ROM_FRAGMENT_SIZE);
		}
		
		// Write fragment count
		try (DataOutputStream ent = new DataOutputStream(
			db.addEntry("FnUM", 0)))
		{
			ent.writeInt(numfrags);
		}
		
		// Write every fragment to the database
		for (int i = 0, p = 0; i < numfrags; i++, p += ROM_FRAGMENT_SIZE)
		{
			// Write individual fragment
			try (DataOutputStream ent = new DataOutputStream(
				db.addEntry("FrOM", i)))
			{
				// Write the fragment data
				ent.write(romdata, p, Math.min(romlen - p, ROM_FRAGMENT_SIZE));
				
				// Make sure all fragments are the same size
				if (ent.size() < ROM_FRAGMENT_SIZE)
					ent.write(0);
			}
		}
		
		// Write the output
		db.writeTo(__out);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	protected void generate(ZipCompilerOutput __zip, BuildParameters __bp)
		throws IOException, NullPointerException
	{
		if (__zip == null || __bp == null)
			throw new NullPointerException("NARG");
		
		// PalmOS (especially older versions) do not have a concept of a
		// file system so a ROM has to exist as a database
		try (OutputStream out = __zip.output("squirreljme-rom.pdb"))
		{
			this.buildRomDatabase(out, __bp);
		}
		
		// Include the PRC that can run the actual ROM!
		todo.TODO.note("Include RatufaCoat squirreljme.prc for now!");
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/ShadedJavaMEDist.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

























































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

package cc.squirreljme.builder.support.dist;

import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.builder.support.vmshader.Shader;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * Distribution for building shaded Java ME JARs.
 *
 * @since 2018/12/24
 */
public class ShadedJavaMEDist
	extends DistBuilder
{
	/**
	 * Initializes the distribution.
	 *
	 * @since 2018/12/24
	 */
	public ShadedJavaMEDist()
	{
		super("javame");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/24
	 */
	@Override
	protected void specific(ProjectManager __pm, ZipCompilerOutput __zip)
		throws IOException, NullPointerException
	{
		if (__pm == null || __zip == null)
			throw new NullPointerException("NARG");
		
		// Write to the output ZIP
		try (OutputStream out = __zip.output("squirreljme-javame.jar"))
		{
			Shader.shade(__pm, TimeSpaceType.RUNTIME, false,
				null, out);
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/ShadedJavaSEDist.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



























































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

package cc.squirreljme.builder.support.dist;

import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.builder.support.vmshader.Shader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * Distribution for building shaded Java SE JARs.
 *
 * @since 2018/12/24
 */
public class ShadedJavaSEDist
	extends DistBuilder
{
	/**
	 * Initializes the distribution.
	 *
	 * @since 2018/12/24
	 */
	public ShadedJavaSEDist()
	{
		super("javase");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/24
	 */
	@Override
	protected void specific(ProjectManager __pm, ZipCompilerOutput __zip)
		throws IOException, NullPointerException
	{
		if (__pm == null || __zip == null)
			throw new NullPointerException("NARG");
		
		// Write to the output ZIP
		try (OutputStream out = __zip.output("squirreljme-javase.jar"))
		{
			Shader.shade(__pm, TimeSpaceType.RUNTIME, true,
				Paths.get("bootsjme", "javase-runtime.jar"), out);
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/SummerCoatROM.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.builder.support.dist;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.builder.support.vm.BuildClassLibrary;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.packfile.PackMinimizer;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.javac.ZipCompilerOutput;

/**
 * This is used to build the packed SummerCoat ROM file.
 *
 * @since 2019/05/28
 */
public class SummerCoatROM
	extends DistBuilder
{
	/** The timespace to use. */
	protected final TimeSpaceType timespace;
	
	/**
	 * Initializes the service.
	 *
	 * @since 2019/05/28
	 */
	public SummerCoatROM()
	{
		this("summercoatrom", TimeSpaceType.RUNTIME);
	}
	
	/**
	 * Initializes the service with the given name using the default type.
	 *
	 * @param __name The name to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public SummerCoatROM(String __name)
		throws NullPointerException
	{
		this(__name, TimeSpaceType.RUNTIME);
	}
	
	/**
	 * Initializes the service with the given name and type.
	 *
	 * @param __name The name to use.
	 * @param __ts The timespace type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public SummerCoatROM(String __name, TimeSpaceType __ts)
		throws NullPointerException
	{
		super(__name);
		
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		this.timespace = __ts;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/28
	 */
	@Override
	protected void specific(ProjectManager __pm, ZipCompilerOutput __zip)
		throws IOException, NullPointerException
	{
		// Compile everything and include the launcher bits as well
		Binary[] bins = __pm.buildAll(this.timespace);
		Binary[] lbins = __pm.build(this.timespace, "launcher");
		
		// Bootstrap library used as the kernel entry point
		String boot = null;
		
		// Translate these to VMClassLibraries and find the bootstrap
		int n = bins.length;
		VMClassLibrary[] libs = new VMClassLibrary[n];
		for (int i = 0; i < n; i++)
		{
			Binary b = bins[i];
			
			// Wrap library
			BuildClassLibrary lib;
			libs[i] = (lib = new BuildClassLibrary(b));
			
			// Use the supervisor as the booting point
			String name = lib.name().toString();
			if (name.equals("supervisor") || name.equals("supervisor.jar"))
				boot = name;
		}
		
		// Try to find the starting libraries for the launcher
		int numlbins = lbins.length;
		String[] lstrs = new String[numlbins];
		for (int i = 0; i < numlbins; i++)
		{
			// Get source name
			String name = lbins[i].name().toString();
			
			// Find the library for it
			for (int j = 0; j < n; j++)
			{
				String ln = libs[j].name();
				
				// Matching name?
				if (name.equals(ln) || name.equals(ln + ".jar") ||
					(name + ".jar").equals(ln) ||
					(name + ".jar").equals(ln + ".jar"))
				{
					lstrs[i] = ln;
					break;
				}
			}
		}
		
		// Write SummerCoat ROM file
		EntryPoint entrypoint = new EntryPoints(lbins[numlbins - 1].
			manifest()).get(0);
		this.generate(__zip, new BuildParameters(boot, lstrs,
			entrypoint.entryPoint(), entrypoint.isMidlet(), libs));
	}
	
	/**
	 * Generates the output files as needed.
	 *
	 * @param __zip The ZIP to write to.
	 * @param __bp The build parameters.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	protected void generate(ZipCompilerOutput __zip, BuildParameters __bp)
		throws IOException, NullPointerException
	{
		if (__zip == null || __bp == null)
			throw new NullPointerException("NARG");
		
		// Write SummerCoat ROM file
		try (OutputStream out = __zip.output("squirreljme.sqc"))
		{
			__bp.minimize(out);
		}
	}
	
	/**
	 * This contains the build parameters for the minimizer.
	 *
	 * @since 2019/07/13
	 */
	public static final class BuildParameters
	{
		/** The boot library. */
		public final String bootlib;
		
		/** Starting libraries. */
		public final String[] startlibs;
		
		/** Main boot class. */
		public final String mainbc;
		
		/** Is this a MIDlet? */
		public final boolean ismidlet;
		
		/** Libraries to use. */
		public final VMClassLibrary[] libs;
		
		/**
		 * Initializes the build parameters.
		 *
		 * @param __boot The boot library.
		 * @param __lstrs Starting libraries.
		 * @param __mainbc Main boot class.
		 * @param __ismid Is this a MIDlet?
		 * @param __libs Class Library.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/07/13
		 */
		public BuildParameters(String __boot, String[] __lstrs,
			String __mainbc, boolean __ismid, VMClassLibrary[] __libs)
			throws NullPointerException
		{
			if (__boot == null || __lstrs == null || __mainbc == null ||
				__libs == null)
				throw new NullPointerException("NARG");
			
			this.bootlib = __boot;
			this.startlibs = __lstrs;
			this.mainbc = __mainbc;
			this.ismidlet = __ismid;
			this.libs = __libs;
		}
		
		/**
		 * Minimizes to the given output stream.
		 *
		 * @param __out The stream to write to.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/07/13
		 */
		public final void minimize(OutputStream __out)
			throws IOException, NullPointerException
		{
			if (__out == null)
				throw new NullPointerException("NARG");
			
			PackMinimizer.minimize(__out, this.bootlib, this.startlibs,
				this.mainbc, this.ismidlet, this.libs);
		}
		
		/**
		 * Minimizes to a byte array.
		 *
		 * @return The byte array of the minimized output.
		 * @since 2019/07/13
		 */
		public final byte[] minimize()
			throws IOException
		{
			return PackMinimizer.minimize(this.bootlib, this.startlibs,
				this.mainbc, this.ismidlet, this.libs);
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/SummerCoatROMTest.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.builder.support.dist;

import cc.squirreljme.builder.support.TimeSpaceType;

/**
 * This builds the SummerCoat ROM except that it completely uses the test
 * projects and is used to make sure SummerCoat and RatufaCoat work properly
 * with all of the tests.
 *
 * @since 2019/05/29
 */
public class SummerCoatROMTest
	extends SummerCoatROM
{
	/**
	 * Initializes the builder.
	 *
	 * @since 2019/05/29
	 */
	public SummerCoatROMTest()
	{
		super("summercoatrom-test", TimeSpaceType.TEST);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/dist/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the distribution system.
 *
 * @since 2018/12/24
 */

package cc.squirreljme.builder.support.dist;

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the base support for the build system.
 *
 * @since 2017/11/09
 */

package cc.squirreljme.builder.support;

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/sdk/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















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

/**
 * This package contains the SDK support code which can be used to build and
 * construct the SDK as required.
 *
 * @since 2018/01/27
 */

package cc.squirreljme.builder.support.sdk;

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/testmain.template.

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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.util.ArrayList;
import java.util.Collection;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is an automatically generated class for running the test framework
 * for a given library.
 *
 * @since 2018/03/06
 */
public final class TestMain
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	protected final void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	protected final void startApp()
		throws MIDletStateChangeException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/03/06
	 */
	public static void main(String... __args)
	{
		// Always make it valid
		if (__args == null)
			__args = new String[0];
		
		throw new todo.TODO();
	}
}

// AUTOMATICALLY GENERATED INTERNAL TEST DATA WILL BE STORED FOLLOWING THIS
// POINT

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vm/BuildClassLibrary.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
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







































































































































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

package cc.squirreljme.builder.support.vm;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.vm.VMClassLibrary;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;
import net.multiphasicapps.zip.blockreader.ZipEntryNotFoundException;

/**
 * This represents a single library that is layered on top of the binary
 * provided by the build system.
 *
 * @since 2018/09/13
 */
public final class BuildClassLibrary
	implements VMClassLibrary
{
	/** The binary to source from. */
	protected final Binary binary;
	
	/**
	 * Initializes the library.
	 *
	 * @param __b The binary to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/13
	 */
	public BuildClassLibrary(Binary __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		this.binary = __b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final String[] listResources()
	{
		// Build name list
		List<String> rv = new ArrayList<>();
		try (ZipBlockReader zip = this.binary.zipBlock())
		{
			for (ZipBlockEntry e : zip)
			{
				// Do not consider directories as part of the JAR
				if (e.isDirectory())
					continue;
				
				rv.add(e.name());
			}
		}
		
		// Failed read
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
		
		// Return it
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/13
	 */
	@Override
	public final String name()
	{
		return this.binary.name().toString() + ".jar";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/13
	 */
	@Override
	public final InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		try (ZipBlockReader zip = this.binary.zipBlock())
		{
			// Might not exist
			try (InputStream in = zip.open(__rc))
			{
				// Copy all the data
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Wrap and return
				return new ByteArrayInputStream(baos.toByteArray());
			}
			
			// No entry exists to be read
			catch (ZipEntryNotFoundException e)
			{
				return null;
			}
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vm/BuildSuiteManager.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
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






























































































































































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

package cc.squirreljme.builder.support.vm;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.BinaryManager;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.NoSourceAvailableException;
import cc.squirreljme.builder.support.Source;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMSuiteManager;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * The manager for suites that use the build system.
 *
 * @since 2018/10/26
 */
public final class BuildSuiteManager
	implements VMSuiteManager
{
	/** The project manager which is used. */
	protected final ProjectManager manager;
	
	/** Loaded libraries. */
	private final Map<String, VMClassLibrary> _libraries =
		new HashMap<>();
	
	/**
	 * Initializes the suite manager.
	 *
	 * @param __pm The project manager that is used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/16
	 */
	public BuildSuiteManager(ProjectManager __pm)
		throws NullPointerException
	{
		if (__pm == null)
			throw new NullPointerException("NARG");
		
		this.manager = __pm;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/26
	 */
	@Override
	public final String[] listLibraryNames()
	{
		Set<String> rv = new SortedTreeSet<>();
		
		ProjectManager manager = this.manager;
		
		// Could fail
		try
		{
			// Add sources
			for (Source s : manager.sourceManager())
				rv.add(s.name().toString() + ".jar");
			
			// Add binaries
			for (Binary b : manager.binaryManager())
				rv.add(b.name().toString() + ".jar");
		}
		
		// {@squirreljme.error AU1g Could not list suites available.}
		catch (IOException e)
		{
			throw new RuntimeException("AU1g", e);
		}
		
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/26
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Remove the extension
		if (__s.endsWith(".jar"))
			__s = __s.substring(0, __s.length() - 4);
		
		// Lock
		Map<String, VMClassLibrary> libraries = this._libraries;
		synchronized (libraries)
		{
			// Pre-cached already?
			VMClassLibrary rv = libraries.get(__s);
			if (rv != null)
				return rv;
			
			// Build the binaries for this finding the matching one
			try
			{
				for (Binary b : this.manager.build(__s))
					if (__s.equals(b.name().toString()))
					{
						rv = new BuildClassLibrary(b);
						break;
					}
			}
			
			// If no source exists then just use it directly
			catch (NoSourceAvailableException e)
			{
				try
				{
					rv = new BuildClassLibrary(this.manager.binaryManager().
						get(__s));
				}
				
				// {@squirreljme.error AU1h Could not load the binary manager.}
				catch (IOException x)
				{
					RuntimeException t = new RuntimeException("AU1h", x);
					t.addSuppressed(e);
					throw t;
				}
			}
			
			// Library was found?
			if (rv != null)
			{
				libraries.put(__s, rv);
				return rv;
			}
			
			// {@squirreljme.error AU1i No such library exists. (The requested
			// library)}
			throw new RuntimeException(String.format("AU1i %s", __s));
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vm/VMMain.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252




























































































































































































































































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

package cc.squirreljme.builder.support.vm;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.NoSourceAvailableException;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.vm.VirtualMachine;
import cc.squirreljme.vm.VMFactory;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import net.multiphasicapps.profiler.ProfilerSnapshot;

/**
 * Main entry point for the virtual machine which is layered on the build
 * system.
 *
 * @since 2018/09/13
 */
public class VMMain
{
	/**
	 * Main entry point using the given project manager.
	 *
	 * @param __pm The project manager.
	 * @param __pn The project to be launched.
	 * @param __args Program arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/29
	 */
	public static void main(ProjectManager __pm, String __pn, String... __args)
		throws NullPointerException
	{
		VMMain.main(null, null, __pm, __pn, __args);
	}
	
	/**
	 * Main entry point using the given project manager.
	 *
	 * @param __vm The name of the VM engine to use, may be blank.
	 * @param __nps Profiler snapshot to use instead.
	 * @param __pm The project manager.
	 * @param __pn The project to be launched.
	 * @param __args Program arguments.
	 * @throws NullPointerException On null arguments, except for {@code __vm}.
	 * @since 2019/01/23
	 */
	public static void main(String __vm, String __nps, ProjectManager __pm,
		String __pn, String... __args)
		throws NullPointerException
	{
		VMMain.main(null, null, null, __pm, __pn, __args);
	}
	
	/**
	 * Main entry point using the given project manager.
	 *
	 * @param __vm The name of the VM engine to use, may be blank.
	 * @param __nps Profiler snapshot to use instead.
	 * @param __sprops System properties to use for the VM.
	 * @param __pm The project manager.
	 * @param __pn The project to be launched.
	 * @param __args Program arguments.
	 * @throws NullPointerException On null arguments, except for {@code __vm}.
	 * @since 2019/01/23
	 */
	public static void main(String __vm, String __nps,
		Map<String, String> __sprops, ProjectManager __pm,
		String __pn, String... __args)
		throws NullPointerException
	{
		if (__pm == null || __pn == null)
			throw new NullPointerException("NARG");
			
		// Copy arguments for processing
		Queue<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.add(a);
		
		// Determine the project and launch ID to execute
		String project = __pn;
		int launchid = 0;
		
		// Check if a launch ID was specified, separate with colon because
		// there could be command line arguments to launch with using the
		// classic entry point. So we cannot really specificy the entry point
		// using a switch as we would need to specially handle it. Not to
		// mention the program may require it.
		int col = project.indexOf(':');
		if (col >= 0)
		{
			launchid = Integer.valueOf(project.substring(col + 1));
			project = project.substring(0, col);
		}
		
		// Get the project and all of its dependencies built which forms
		// the class path
		Set<Binary> xclasspath = new LinkedHashSet<>();
		Binary[] vclasspath;
		try
		{
			vclasspath = __pm.build(project);
		}
		
		// If there is no source for this, just use the classpath then
		catch (NoSourceAvailableException e)
		{
			vclasspath = __pm.classPath(project);
		}
		
		// The boot entry always must be last
		Binary bootp = vclasspath[vclasspath.length - 1];
		
		// Merge the sets of classpaths
		Set<Binary> finalclasspath = new LinkedHashSet<>();
		for (Binary b : xclasspath)
			finalclasspath.add(b);
		for (Binary b : vclasspath)
			finalclasspath.add(b);
		
		// Remove and re-add the boot entry so it is always last
		finalclasspath.remove(bootp);
		finalclasspath.add(bootp);
		
		// Need to convert to array because we use direct index references
		// on the array
		Binary[] fcpa = finalclasspath.<Binary>toArray(
			new Binary[finalclasspath.size()]);
		
		// Build class references
		int numlibs = fcpa.length;
		String[] classpath = new String[numlibs];
		for (int i = 0; i < numlibs; i++)
			classpath[i] = fcpa[i].name().toString();
		
		// Profiled class information
		ProfilerSnapshot profiler = new ProfilerSnapshot();
		
		// Initialize the virtual machine with our launch ID
		VirtualMachine machine = VMFactory.main(__vm, profiler,
			new BuildSuiteManager(__pm), classpath,
			null, launchid, -1, __sprops,
			args.<String>toArray(new String[args.size()]));
		
		// Run the VM until it terminates
		int exitcode = -1;
		try
		{
			exitcode = machine.runVm();
		}
		
		// Dump the profiler snapshot somewhere
		finally
		{
			// Exit all frames in the profiler so that it is maybe valid
			// otherwise if the VM crashes mid-frame without a clean exit
			// the exact times will be hard to tell
			profiler.exitAll();
			
			// Dump to file
			try
			{
				// Create temporary file
				Calendar now = Calendar.getInstance();
				Path temp = Files.createTempFile(String.format(
					"squirreljme-vm-%TF_%TH-%TM-%TS-", now, now, now, now),
					".nps");
				
				// Write snapshot to this file
				try (OutputStream os = Files.newOutputStream(temp,
					StandardOpenOption.WRITE, StandardOpenOption.CREATE))
				{
					profiler.writeTo(os);
				}
				
				// Move the NPS somewhere?
				if (__nps != null)
					try
					{
						Files.move(temp, Paths.get(__nps),
							StandardCopyOption.REPLACE_EXISTING);
					}
					catch (IOException e)
					{
						e.printStackTrace();
					}
			}
			
			// Ignore
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
		
		// Exit with our given code, we cannot exit before the finally
		// because then the profiler would never be generatedg
		System.exit(exitcode);
	}
	
	/**
	 * Main entry point (for old compatibility).
	 *
	 * @param __args Program arguments.
	 * @since 2018/09/13
	 */
	public static void main(String... __args)
	{
		// Copy arguments for processing
		Queue<String> args = new ArrayDeque<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.add(a);
		
		// Setup project manager
		ProjectManager pm = ProjectManager.fromArguments(args);
		
		// {@squirreljme.error AU1j No project to launch was specified. The
		// format is project-name or project-name:entry-point-id.}
		if (args.isEmpty())
			throw new IllegalArgumentException("AU1j");
		
		// Forward
		VMMain.main(pm, args.remove(),
			args.<String>toArray(new String[args.size()]));
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















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

/**
 * This package contains the support for VMs to use the SquirrelJME
 * build system as a class path provider.
 *
 * @since 2018/09/13
 */

package cc.squirreljme.builder.support.vm;

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vmshader/ServicesMerge.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.builder.support.vmshader;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This is used for merging services together as one.
 *
 * @since 2019/05/19
 */
public final class ServicesMerge
{
	/** Services available. */
	final Set<String> _implementations =
		new LinkedHashSet<>();
	
	/**
	 * Returns the service implementations.
	 *
	 * @return The service implementations.
	 * @since 2019/05/19
	 */
	public final String[] implementations()
	{
		Set<String> impls = this._implementations;
		return impls.<String>toArray(new String[impls.size()]);
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vmshader/Shader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484




































































































































































































































































































































































































































































































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

package cc.squirreljme.builder.support.vmshader;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.BinaryManager;
import cc.squirreljme.builder.support.NoSourceAvailableException;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;
import net.multiphasicapps.zip.streamwriter.ZipStreamWriter;

/**
 * This class builds a shaded JAR of the virtual machine which contains the
 * classes for every JAR in SquirrelJME. This just uses the build system to
 * produce a JAR that is combined as one.
 *
 * @since 2018/11/16
 */
public class Shader
{
	/**
	 * Shades the JAR.
	 *
	 * @param __pm The project manager to use.
	 * @param __ts The timespace type.
	 * @param __withboot Use the bootstrap?
	 * @param __bootjar Bootstrap JAR to use.
	 * @param __out The stream to write the ZIP to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/22
	 */
	public static void shade(ProjectManager __pm, TimeSpaceType __ts,
		boolean __withboot, Path __bootjar, OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__pm == null || __ts == null ||
			(__withboot && __bootjar == null) || __out == null)
			throw new NullPointerException("NARG");
		
		// Setup output ZIP stream
		ZipStreamWriter zsw = new ZipStreamWriter(__out);
		
		// Files which were put in the JAR, to detect duplicates and
		// such!
		Set<String> putin = new HashSet<>();
		
		// Make sure that the bootstrap is always placed in first, this
		// provides the API and such (for example on Java SE systems we need
		// to provide the Swing code and such)
		if (__withboot)
			Shader.__injectRuntimeJar(zsw, __bootjar, putin);
		
		// Completely shade in the JAR for the entire run-time which we
		// selected
		BinaryManager bm = __pm.binaryManager(__ts);
		Shader.__shadeJar(zsw, bm);
		
		// All of our binaries are going to be merged into one and shaded in
		// the top level JAR. This includes the VM implementation
		Set<Binary> mergebins = new LinkedHashSet<>();
		
		// We might be runnign on a Java SE or Java ME system which does not
		// have the full API available, so in that case provide a bunch of
		// stub APIs so that things still somewhat work.
		// However add these in reverse order so that the stubs are always
		// first!
		Binary[] vmstubs = bm.compile(bm.get("common-vm-stubs"));
		for (int i = vmstubs.length - 1; i >= 0; i--)
			mergebins.add(vmstubs[i]);
		
		// Then we just include every single virtual machine that exists, so
		// that way they can be switched to in the event an older one is
		// desired.
		for (Binary bin : bm.compile(bm.get("all-vms")))
			mergebins.add(bin);
		
		// Merge all of those and those binaries into the output JAR as needed
		Shader.__bootIn(zsw, bm, mergebins.<Binary>toArray(
			new Binary[mergebins.size()]), putin);
		
		// End the stream
		zsw.flush();
		zsw.close();
	}
	
	/**
	 * Builds and loads the classes into.
	 *
	 * @param __zsw The ZIP to write to.
	 * @param __bm The manager for binaries.
	 * @param __bins The binaries to write, the compiled paths.
	 * @param __putin Files already in the JAR.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	private static final void __bootIn(ZipStreamWriter __zsw,
		BinaryManager __bm, Binary[] __bins, Set<String> __putin)
		throws IOException, NullPointerException
	{
		if (__zsw == null || __bm == null || __bins == null || __putin == null)
			throw new NullPointerException("NARG");
		
		// Services that are available
		Map<String, ServicesMerge> services = new LinkedHashMap<>();
		
		// We want to write and merge all the entries
		byte[] buf = new byte[512];
		for (Binary bin : __bins)
		{
			// Will be copying every single entry to the output
			try (ZipBlockReader zbr = bin.zipBlock())
			{
				// Copy every single entry to the output
				for (ZipBlockEntry e : zbr)
				{
					// Merge in services?
					String name = e.name();
					if (name.startsWith("META-INF/services/"))
					{
						// Get just the name of the class
						name = name.substring(18);
						
						// Setup merge for services
						ServicesMerge merge = services.get(name);
						if (merge == null)
							services.put(name, (merge = new ServicesMerge()));
						
						// Merge in service implementations
						try (BufferedReader br = new BufferedReader(
							new InputStreamReader(e.open())))
						{
							for (;;)
							{
								String ln = br.readLine();
								if (ln == null)
									break;
								
								merge._implementations.add(ln);
							}
						}
						
						// Do not process any further
						continue;
					}
					
					// Only add entries once!
					if (__putin.contains(name))
						continue;
					
					// Do not write manifests!
					if (name.equals("META-INF/MANIFEST.MF"))
						continue;
					
					// Not allowed to add stuff under this package?
					if (name.endsWith(".class") &&
						!Shader.__checkPackage(name))
						continue;
					
					// This was added, so it gets ignored
					__putin.add(name);
					
					// Copy the data in here
					try (InputStream is = e.open();
						OutputStream os = __zsw.nextEntry(name))
					{
						for (;;)
						{
							int rc = is.read(buf);
							
							if (rc < 0)
								break;
							
							os.write(buf, 0, rc);
						}
					}
				}
			}
		}
		
		// We need to know the classpath that is used for the launcher so
		// that the shaded entry main knows how to start the actual launcher!
		// Since all classes are needed for it!
		StringBuilder launchercp = new StringBuilder();
		for (Binary bin : __bm.classPath(__bm.get("launcher")))
		{
			if (launchercp.length() > 0)
				launchercp.append(' ');
			
			launchercp.append(bin.name());
		}
		
		// Setup manifest which allows us to run this on SpringCoat along
		// with doing a normal `java -jar` on it!
		MutableJavaManifest man = new MutableJavaManifest();
		MutableJavaManifestAttributes attr = man.getMainAttributes();
		
		// Needed for Java SE
		attr.putValue("Main-Class",
			"cc.squirreljme.vm.VMEntryShadedMain");
		
		// Needed for Java ME
		attr.putValue("MIDlet-1", "SquirrelJME," +
			"squirrejme-vm.png,cc.squirreljme.vm.VMEntryShadedMIDlet");
		attr.putValue("MicroEdition-Configuration", "CLDC-1.8");
		attr.putValue("MicroEdition-Profile", "MEEP-8.0 MIDP-3.1");
		attr.putValue("MIDlet-Name", "SquirrelJME");
		attr.putValue("MIDlet-Vendor", "Stephanie Gawroriski");
		attr.putValue("MIDlet-Version", SystemProperties.javaRuntimeVersion());
		
		// Write manifest to the output
		try (OutputStream os = __zsw.nextEntry("META-INF/MANIFEST.MF"))
		{
			man.write(os);
		}
		
		// Write VM properties into its own manifest as well
		man = new MutableJavaManifest();
		attr = man.getMainAttributes();
		
		// Needed by the VM so it knows the boot classpath for the launcher!
		attr.putValue("ClassPath", launchercp.toString());
		
		// Write manifest to the output
		try (OutputStream os = __zsw.nextEntry(
			"META-INF/SQUIRRELJME-SHADED.MF"))
		{
			man.write(os);
		}
		
		// Write in any services
		for (Map.Entry<String, ServicesMerge> e : services.entrySet())
			try (PrintStream os = new PrintStream(__zsw.nextEntry(
				"META-INF/services/" + e.getKey()), true))
			{
				for (String s : e.getValue().implementations())
					os.println(s);
				os.flush();
			}
	}
	
	/**
	 * Checks to make sure that the given package should be included.
	 *
	 * @param __name The name of the class to check.
	 * @return If the class can be stored.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	private static final boolean __checkPackage(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// There is no slash so this is okay!
		int ls = __name.lastIndexOf('/');
		if (ls < 0)
			return true;
		
		// Do not allow certain names
		switch (__name = __name.substring(0, ls))
		{
				// These will conflict with stuff in the CLDC and such and
				// technically it is not permitted to add these classes so
				// all of these will go away!
			case "java/io":
			case "java/lang":
			case "java/lang/annotation":
			case "java/lang/ref":
			case "java/net":
			case "java/nio":
			case "java/nio/channels":
			case "java/nio/file":
			case "java/nio/file/attribute":
			case "java/security":
			case "java/util":
				return false;
			
				// Can add this class
			default:
				return true;
		}
	}
	
	/**
	 * Injects the run-time support JAR into the classpath.
	 *
	 * @param __zsw The output ZIP.
	 * @param __ertj The support JAR.
	 * @param __putin The files which were already placed in the JAR.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	private static final void __injectRuntimeJar(ZipStreamWriter __zsw,
		Path __ertj, Set<String> __putin)
		throws IOException, NullPointerException
	{
		if (__zsw == null || __ertj == null || __putin == null)
			throw new NullPointerException("NARG");
		
		// Before we write the other files, we want to inject everything from
		// this JAR in there
		byte[] buf = new byte[512];
		if (__ertj != null)
			try (ZipStreamReader copy = new ZipStreamReader(
				Files.newInputStream(__ertj, StandardOpenOption.READ)))
			{
				for (;;)
					try (ZipStreamEntry e = copy.nextEntry())
					{
						// No more entries
						if (e == null)
							break;
						
						String name = e.name();
						
						// Already in the JAR?
						if (__putin.contains(name))
							continue;
						
						// Ignore manifests
						if (name.equals("META-INF/MANIFEST.MF"))
							continue;
						
						// Only once this can be added
						__putin.add(name);
						
						// Copy data
						try (OutputStream os = __zsw.nextEntry(name))
						{
							for (;;)
							{
								int rc = e.read(buf);
								
								if (rc < 0)
									break;
								
								os.write(buf, 0, rc);
							}
						}
					}
			}
	}
	
	/**
	 * Shades the JAR to the specified output.
	 *
	 * @param __zsw The output ZIP to write to.
	 * @param __bm The binary manager with classes.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	private static final void __shadeJar(ZipStreamWriter __zsw,
		BinaryManager __bm)
		throws IOException, NullPointerException
	{
		if (__zsw == null || __bm == null)
			throw new NullPointerException("NARG");
		
		// Raw suiite
		ByteArrayOutputStream rawsuites = new ByteArrayOutputStream();
		PrintStream suitelist = new PrintStream(rawsuites, true, "utf-8");
		
		// Go through all the binaries and just place them in the shaded JAR
		// with their associated names and prefixes
		byte[] buf = new byte[512];
		for (Binary bin : __bm)
		{
			// Compile the binary
			try
			{
				__bm.compile(bin);
			}
			
			// If no source code available, just ignore because it would
			// already be in binary form
			catch (NoSourceAvailableException e)
			{
			}
			
			// Use the name for this JAR
			String name = bin.name().toString();
			
			// Write it to the suite list
			suitelist.println(name);
			
			// Base prefix for this JAR
			String base = "__-squirreljme/" + name + "/";
			
			// Will be copying every single entry to the output
			try (ZipBlockReader zbr = bin.zipBlock())
			{
				// List of resources that are available
				List<String> jarresources = new LinkedList<>();
				
				// Copy every single entry to the output
				for (ZipBlockEntry e : zbr)
				{
					// Ignore directories
					if (e.isDirectory())
						continue;
					
					// Add to resource list
					jarresources.add(e.name());
					
					// Copy the data
					try (InputStream is = e.open();
						OutputStream os = __zsw.nextEntry(base + e.name()))
					{
						for (;;)
						{
							int rc = is.read(buf);
							
							if (rc < 0)
								break;
							
							os.write(buf, 0, rc);
						}
					}
				}
				
				// Write resource list into the JAR
				try (PrintStream os = new PrintStream(__zsw.nextEntry(base +
					"META-INF/squirreljme/resources.list"), true, "utf-8"))
				{
					// Write to stream
					for (String rcn : jarresources)
						os.println(rcn);
					
					// Make sure it is there!
					os.flush();
				}
			}
		}
		
		// Write the raw suite list to the JAR since it is needed for shading
		try (OutputStream os = __zsw.nextEntry("__-squirreljme/suites.list"))
		{
			rawsuites.writeTo(os);
		}
	}
}

Deleted bldt/libs/builder-support/cc/squirreljme/builder/support/vmshader/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the virtual machine shader.
 *
 * @since 2018/12/22
 */

package cc.squirreljme.builder.support.vmshader;

Deleted bldt/libs/palmos-utils/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: dfc85dd5-cd8b-40e4-956d-0fc938eb179e
X-SquirrelJME-Error: BP
X-SquirrelJME-Name: PalmOS Utilities
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains utilities for reading and writing 
 PalmOS PRC and PDB files.
Microedition-Configuration: CLDC-1.8-Compact

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseAttribute.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.palmos;

/**
 * This represents an attribute for the Palm Database.
 *
 * @since 2019/07/13
 */
public enum PalmDatabaseAttribute
{
	/** This is a resource database. */
	RESOURCE_DATABASE(0x0001),
	
	/** Read-only. */
	READ_ONLY(0x0002),
	
	/** Info block is dirty. */
	APP_INFO_DIRTY(0x0004),
	
	/** Database should be packed up to the PC. */
	BACKUP(0x0008),
	
	/** Is okay to install newer version? */
	OK_TO_INSTALL_NEWER(0x0010),
	
	/** Requires a reset after install. */
	RESET_AFTER_INSTALL(0x0020),
	
	/** Copy protection (prevent beaming/copy). */
	COPY_PROTECTION(0x0040),
	
	/** Used as a file stream. */
	STREAM(0x0080),
	
	/** Is hidden. */
	HIDDEN(0x0100),
	
	/** Is a data resource which can be launched. */
	LAUNCHABLE_DATA(0x0200),
	
	/** The database can be recycled. */
	RECYCLABLE(0x0400),
	
	/** Is a bundle, always beam with the same creator type. */
	BUNDLE(0x0800),
	
	/** Database is open and has not been closed properly. */
	OPEN(0x8000),
	
	/** End. */
	;
	
	/** The bit used. */
	public final int bit;
	
	/**
	 * Initializes the attribute.
	 *
	 * @param __b The bit used.
	 * @since 2019/07/13
	 */
	private PalmDatabaseAttribute(int __bit)
	{
		this.bit = __bit;
	}
}

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444




























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.palmos;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

/**
 * This class is used to build PalmOS databases and resource databases.
 *
 * @since 2019/07/13
 */
public final class PalmDatabaseBuilder
{
	/** The limit to the name length. */
	private static final int _NAME_LIMIT =
		32;
	
	/** Difference in the epoch in seconds. */
	private static final long _EPOCH_DIFF_SECONDS =
		2082844800L;
	
	/** Difference in the epoch in milliseconds. */
	private static final long _EPOCH_DIFF_MILLISECONDS =
		2082844800_000L;
	
	/** The type of database to create. */
	protected final PalmDatabaseType dbtype;
	
	/** Attributes within the database. */
	private final Set<PalmDatabaseAttribute> _attributes =
		new HashSet<>();
	
	/** The entries within the database. */
	private final List<PalmRecord> _records =
		new ArrayList<>();
	
	/** The creator of the database. */
	private String _creator =
		"????";
	
	/** The type of the database. */
	private String _type =
		"????";
	
	/** The name of the database. */
	private String _name =
		"Untitled";
	
	/** Creation time. */
	private long _createtime =
		System.currentTimeMillis();
	
	/** Modification time */
	private long _modtime =
		this._createtime;
	
	/** Backup time. */
	private long _backuptime =
		0;
	
	/** Modification number. */
	private int _modcount =
		0;
	
	/** The version. */
	private int _version =
		0;
	
	/**
	 * Initializes the database builder.
	 *
	 * @param __type The database type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public PalmDatabaseBuilder(PalmDatabaseType __type)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		this.dbtype = __type;
	}
	
	/**
	 * Adds the specified entry.
	 *
	 * @param __type The entry type.
	 * @param __id The ID to use.
	 * @return The stream to the entry data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final OutputStream addEntry(String __type, int __id)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		// Create a record writer to write there
		return new __RecordWriter__(__type, __id, this._records);
	}
	
	/**
	 * Sets the given attributes.
	 *
	 * @param __a The attribute to set.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setAttributes(
		PalmDatabaseAttribute... __a)
	{
		if (__a == null)
			return this;
		
		// Add the attributes
		Set<PalmDatabaseAttribute> attributes = this._attributes;
		for (PalmDatabaseAttribute attr : __a)
			if (attr != null)
				attributes.add(attr);
		
		// Return self
		return this;
	}
	
	/**
	 * Sets the backup time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setBackupTime(long __jt)
	{
		this._backuptime = __jt;
		return this;
	}
	
	/**
	 * Sets the creation time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setCreateTime(long __jt)
	{
		this._createtime = __jt;
		return this;
	}
	
	/**
	 * Sets the creator of the database.
	 *
	 * @param __creat The creator to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setCreator(String __creat)
		throws NullPointerException
	{
		if (__creat == null)
			throw new NullPointerException("NARG");
		
		this._creator = __creat;
		return this;
	}
	
	/**
	 * Sets the modification count.
	 *
	 * @param __c The count to use.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setModificationCount(int __c)
	{
		this._modcount = __c;
		return this;
	}
	
	/**
	 * Sets the modification time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setModificationTime(long __jt)
	{
		this._modtime = __jt;
		return this;
	}
	
	/**
	 * Sets the name of the database.
	 *
	 * @param __name The name to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setName(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this._name = __name;
		return this;
	}
	
	/**
	 * Sets the type of the database.
	 *
	 * @param __type The type to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setType(String __type)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		this._type = __type;
		return this;
	}
	
	/**
	 * Sets the version number.
	 *
	 * @param __v The version number.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setVersion(int __v)
	{
		this._version = __v;
		return this;
	}
	
	/**
	 * Returns the byte array representing the database.
	 *
	 * @return The byte array of the database.
	 * @since 2019/07/13
	 */
	public final byte[] toByteArray()
	{
		// Just write to a stream
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			// Write the database info
			this.writeTo(baos);
			
			// Return the resulting array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BP01 Could not write the database.}
		catch (IOException e)
		{
			throw new RuntimeException("BP01", e);
		}
	}
	
	/**
	 * Writes the database to the output.
	 *
	 * @param __out The output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final void writeTo(OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// Open data output to write to
		DataOutputStream dos = new DataOutputStream(__out);
		
		// Write the name bytes
		byte[] namebytes = this._name.getBytes("utf-8");
		int namelen = namebytes.length;
		dos.write(namebytes, 0, Math.min(namelen, _NAME_LIMIT));
		
		// Pad shorter names
		for (int i = namelen; i < _NAME_LIMIT; i++)
			dos.write(0);
		
		// Determine attribute bit-field
		int attrs = 0;
		for (PalmDatabaseAttribute attr : this._attributes)
			attrs |= attr.bit;
		
		// Make sure the attribute flag is always correct because if it was
		// specified it would make the database not valid to be handled
		PalmDatabaseType dbtype = this.dbtype;
		boolean isrc;
		if ((isrc = (dbtype == PalmDatabaseType.RESOURCE)))
			attrs |= PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		else
			attrs &= ~PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		
		// Write attributes
		dos.writeShort(attrs);
		
		// Write version
		dos.writeShort(this._version);
		
		// Creation/Modification/Backup Time (In Mac OS epoch seconds)
		dos.writeInt(
			(int)((this._createtime + _EPOCH_DIFF_MILLISECONDS) / 1000L));
		dos.writeInt(
			(int)((this._modtime + _EPOCH_DIFF_MILLISECONDS) / 1000L));
		dos.writeInt(
			(int)((this._backuptime + _EPOCH_DIFF_MILLISECONDS) / 1000L));
		
		// Modification count
		dos.writeInt(this._modcount);
		
		// Application Info
		dos.writeInt(0);
		
		// Sorting info
		dos.writeInt(0);
		
		// Type
		dos.writeInt(PalmDatabaseBuilder.__fourToInt(this._type));
		
		// Creator
		dos.writeInt(PalmDatabaseBuilder.__fourToInt(this._creator));
		
		// Unique ID
		dos.writeInt(0);
		
		// Next record list (unused in files)
		dos.writeInt(0);
		
		// Need to work with records now
		List<PalmRecord> records = this._records;
		int numrecords = records.size();
		
		// Write record count
		dos.writeShort(numrecords);
		
		// Determine the base offset for entry data
		int offset = 78 + ((isrc ? 10 : 8) * numrecords);
		
		// Write table data for records
		for (int i = 0; i < numrecords; i++)
		{
			PalmRecord pr = records.get(i);
			
			// Resource entry
			if (isrc)
			{
				// Type
				dos.writeInt(PalmDatabaseBuilder.__fourToInt(pr.type));
				
				// ID
				dos.writeShort(pr.id);
				
				// Offset
				dos.writeInt(offset);
			}
			
			// Database entry
			else
			{
				// Offset
				dos.writeInt(offset);
				
				// No attributes
				dos.write(0);
				
				// Unique ID (padding)
				dos.write(0);
				dos.write(0);
				dos.write(0);
			}
			
			// Offset is increased by length
			offset += pr.length;
		}
		
		// Write all records
		for (int i = 0; i < numrecords; i++)
			dos.write(records.get(i)._data);
	}
	
	/**
	 * Converts a four string to an integer.
	 *
	 * @param __four The string to convert.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	private static final int __fourToInt(String __four)
		throws NullPointerException
	{
		if (__four == null)
			throw new NullPointerException("NARG");
		
		// There must be at least four characters
		String use = __four;
		if (__four.length() < 4)
		{
			StringBuilder sb = new StringBuilder();
			sb.append(__four);
			sb.setLength(4);
			use = sb.toString();
		}
		
		// Convert
		return ((__four.charAt(0) & 0xFF) << 24) |
			((__four.charAt(1) & 0xFF) << 16) |
			((__four.charAt(2) & 0xFF) << 8) |
			((__four.charAt(3) & 0xFF));
	}
}

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseType.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.palmos;

/**
 * This represents the database type to use when creating databases.
 *
 * @since 2019/07/13
 */
public enum PalmDatabaseType
{
	/** Resource database. */
	RESOURCE,
	
	/** Record database. */
	RECORD,
	
	/** End. */
	;
}

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmRecord.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.palmos;

/**
 * This represents a single record within a database.
 *
 * @since 2019/07/13
 */
public final class PalmRecord
{
	/** The type. */
	public final String type;
	
	/** The record ID. */
	public final int id;
	
	/** The record length. */
	public final int length;
	
	/** The data. */
	final byte[] _data;
	
	/**
	 * Initializes the Palm record.
	 *
	 * @param __type The type.
	 * @param __id The ID.
	 * @param __b The buffer.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public PalmRecord(String __type, int __id, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__type == null || __b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.type = __type;
		this.id = __id;
		this.length = __l;
		
		// Copy and store bytes
		byte[] dest = new byte[__l];
		System.arraycopy(__b, __o, dest, 0, __l);
		this._data = dest;
	}
}

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/__RecordWriter__.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
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

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.palmos;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;

/**
 * This is used to write to the record data.
 *
 * @since 2019/07/13
 */
final class __RecordWriter__
	extends OutputStream
{
	/** The type used. */
	protected final String type;
	
	/** The ID used. */
	protected final int id;
	
	/** The record data. */
	private final ByteArrayOutputStream _data =
		new ByteArrayOutputStream();
	
	/** The target record collection. */
	private final Collection<PalmRecord> _target;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/**
	 * Initializes the record writer.
	 *
	 * @param __type The record type.
	 * @param __id The record ID.
	 * @param __t The target type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	__RecordWriter__(String __type, int __id, Collection<PalmRecord> __t)
		throws NullPointerException
	{
		if (__type == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.id = __id;
		this._target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void close()
	{
		// Only close once
		if (this._closed)
			return;
		
		// Set as closed
		this._closed = true;
		
		// Add record information
		byte[] buf = this._data.toByteArray();
		this._target.add(new PalmRecord(this.type, this.id,
			buf, 0, buf.length));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
		
		// Forward
		this._data.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
			
		// Forward
		this._data.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
			
		// Forward
		this._data.write(__b, __o, __l);
	}
}

Deleted bldt/libs/palmos-utils/dev/shadowtail/palmos/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the base for the PalmOS utilities.
 *
 * @since 2019/07/13
 */

package dev.shadowtail.palmos;

Deleted bldt/mids/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Build System MIDlets
X-SquirrelJME-Namespace-Type: midlet
X-SquirrelJME-Namespace-Description: This namespace contains the actual 
 applications which are invoked and initialized for the build system.

Deleted bldt/mids/builder/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: a67921b8-7a05-40c2-adc8-c8d09ed4515e
X-SquirrelJME-Depends: builder-support builder-implementation
X-SquirrelJME-Name: Build System
X-SquirrelJME-Error: AO
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the build system which is 
 used to generate target SquirrelJME binaries.
Microedition-Configuration: CLDC-1.8
Main-Class: cc.squirreljme.builder.entry.BuilderMain

Deleted bldt/mids/builder/cc/squirreljme/builder/entry/BuilderMain.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










































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

package cc.squirreljme.builder.entry;

import cc.squirreljme.builder.support.BuilderFactory;
import java.io.PrintStream;

/**
 * Main entry point for the builder.
 *
 * @since 2017/11/09
 */
public class BuilderMain
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2017/11/09
	 */
	public static void main(String... __args)
	{
		// Print some basic information about the build system
		PrintStream out = System.err;
		out.println("SquirrelJME Build System");
		
		// Space
		out.println();
		
		// Run the builder
		new BuilderFactory(__args).run();
	}
}

Deleted bldt/mids/builder/cc/squirreljme/builder/entry/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the main entry point for the builder.
 *
 * @since 2017/11/09
 */

package cc.squirreljme.builder.entry;

Deleted bldt/mids/instruction-popcount/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 135ed40b-e019-89f9-d36e-2089616072a7
X-SquirrelJME-Error: AT
X-SquirrelJME-Name: Instruction Population Count
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This goes through every library within 
 SquirrelJME and counts all of the instructions which are used.
X-SquirrelJME-Depends: builder-support
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: dev.shadowtail.javapopcount.Main

Deleted bldt/mids/instruction-popcount/dev/shadowtail/javapopcount/Main.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323



































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.javapopcount;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.TimeSpaceType;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionMnemonics;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * Main entry point.
 *
 * @since 2019/03/31
 */
public class Main
{
	/**
	 * Counts all of the instructions in the byte code.
	 *
	 * @param __bc The byte code to go through.
	 * @param __c The output count.
	 * @param __p Various progress indicators.
	 * @return The total number of instructions.
	 * @throws NullPointerException
	 * @since 2019/03/31
	 */
	public static int countByteCode(ByteCode __bc, Map<Integer, Counter> __c,
		Progress __p)
		throws NullPointerException
	{
		if (__bc == null || __c == null || __p == null)
			throw new NullPointerException("NARG");
		
		// Total number of instructions
		int rv = 0;
		
		// Go through every instruction
		boolean newtodo = false;
		for (Instruction i : __bc)
		{
			int op = i.operation();
			
			// Is this a todo? Note we cannot count throws because those
			// are objects on the stack, just check how many times TODOs
			// were allocated
			if (op == InstructionIndex.NEW &&
				i.<ClassName>argument(0, ClassName.class).toString().equals(
				"todo/TODO"))
			{
				__p.todos++;
				newtodo = true;
			}
			
			// Get counter
			Counter c = __c.get(op);
			if (c == null)
				__c.put(op, (c = new Counter()));
			
			// Increase the counters
			c.count++;
			rv++;
		}
		
		// Method made a todo, count it
		if (newtodo)
			__p.methodtodos++;
		else
			__p.methodnotodos++;
		
		// Return the total!
		return rv;
	}
	
	/**
	 * Runs the program.
	 *
	 * @param __args Program arguments.
	 * @throws Throwable On any throwable.
	 * @since 2019/03/31
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// Instruction Counts
		Map<Integer, Counter> counts = new LinkedHashMap<>();
		
		// Load project manager
		ProjectManager pm = ProjectManager.fromArguments(__args);
		
		// For a progress indicator
		PrintStream ps = System.err;
		
		// Totals, which might be useful
		long totalclass = 0,
			totalmeths = 0,
			totalnamth = 0,
			totalinsts = 0;
		Progress progress = new Progress();
		
		// Go through every binary that exists
		for (Binary b : pm.binaryManager(TimeSpaceType.BUILD))
		{
			// Compile the binary to make sure it will "run"
			Binary[] deps = pm.build(TimeSpaceType.BUILD, b.toString());
			
			// Go through the entire ZIP
			try (ZipStreamReader zsr = b.zipStream())
			{
				for (;;)
					try (ZipStreamEntry ent = zsr.nextEntry())
					{
						if (ent == null)
							break;
						
						// Only consider class files
						if (!ent.name().endsWith(".class"))
							continue;
						
						// Print the class
						//ps.printf("Class %s%n", ent.name());
						
						// Decode class file
						ClassFile cf = ClassFile.decode(ent);
						totalclass++;
						
						// Go through methods and count instructions
						for (Method m : cf.methods())
						{
							// Print method
							//ps.printf("\tMethod %s%n", m.nameAndType());
							
							// Count
							totalmeths++;
							
							// Must have code
							ByteCode bc = m.byteCode();
							if (bc == null)
								continue;
							
							// Progress indicator
							ps.print('.');
							
							// Count methods with code
							totalnamth++;
							
							// Count it
							totalinsts += Main.countByteCode(bc, counts,
								progress);
						}
					}
			}
		}
		
		// End progress indicator
		ps.println();
		
		// Build reverses
		List<Reverse> revs = new ArrayList<>(counts.size());
		for (Map.Entry<Integer, Counter> e : counts.entrySet())
			revs.add(new Reverse(e.getKey(), e.getValue().count));
		
		// Sort and reverse so higher values are first
		Collections.sort(revs, new CompareReverse());
		Collections.reverse(revs);
		
		// Switch to output
		ps = System.out;
		
		// Used for percentage cuts
		double dtotalinsts = (double)totalinsts,
			dtotalnamth = (double)totalnamth;
		
		// Print total then every instruction
		ps.printf("Total Classes     : %d%n", totalclass);
		ps.printf("Total Methods     : %d%n", totalmeths);
		ps.printf("Total Methods+Code: %d%n", totalnamth);
		ps.printf("Total Instructions: %d%n", totalinsts);
		ps.printf("Total TODOs       : %d%n", progress.todos);
		ps.printf("Total Methods+TODO: %d (~%6.3f%%)%n",
			progress.methodtodos,
			((double)progress.methodtodos / dtotalnamth) * 100.0);
		ps.printf("Total Methods+NoTD: %d (~%6.3f%%)%n",
			progress.methodnotodos,
			((double)progress.methodnotodos / dtotalnamth) * 100.0);
		for (Reverse r : revs)
		{
			long ic = r.count;
			ps.printf("%15s: %-5d (%6.3f%%)%n",
				InstructionMnemonics.toString(r.op), ic,
				((double)ic / dtotalinsts) * 100.0);
		}
	}
	
	/**
	 * Comparator for reverse operations.
	 *
	 * @since 2019/04/01
	 */
	public static final class CompareReverse
		implements Comparator<Reverse>
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/04/01
		 */
		@Override
		public final int compare(Reverse __a, Reverse __b)
		{
			// Compare counts first to group them together
			long lc = __a.count - __b.count;
			if (lc < 0)
				return -1;
			else if (lc > 0)
				return 1;
			
			// Then just compare the opcode mnemonic so the output list
			// appears more stable
			return InstructionMnemonics.toString(__a.op).compareTo(
				InstructionMnemonics.toString(__b.op));
		}
	}
	
	/**
	 * It is faster to use a counter than it is to create integers for
	 * incrementing.
	 *
	 * @since 2019/03/31
	 */
	public static final class Counter
	{
		/** Count. */
		public long count;
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final String toString()
		{
			return Long.toString(count);
		}
	}
	
	/**
	 * Progress indicators.
	 *
	 * @since 2019/04/01
	 */
	public static final class Progress
	{
		/** The number of TODOs initialized. */
		public long todos;
		
		/** The number of methods containing at least one todo. */
		public long methodtodos;
		
		/** Methods not throwing any todo. */
		public long methodnotodos;
	}
	
	/**
	 * Contains reverse instruction information.
	 *
	 * @since 2019/03/31
	 */
	public static final class Reverse
		implements Comparable<Reverse>
	{
		/** The operation. */
		protected final int op;
		
		/** The total count. */
		protected final long count;
		
		/**
		 * Initializes the reverse.
		 *
		 * @param __o The operation.
		 * @param __c The count.
		 * @since 2019/03/31
		 */
		public Reverse(int __o, long __c)
		{
			this.op = __o;
			this.count = __c;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final int compareTo(Reverse __b)
		{
			return (int)Math.min(Integer.MAX_VALUE,
				Math.max(Integer.MIN_VALUE, this.count - __b.count));
		}
	}
}

Deleted bldt/mids/instruction-popcount/dev/shadowtail/javapopcount/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the population count program.
 *
 * @since 2019/03/31
 */

package dev.shadowtail.javapopcount;

Deleted bldt/mids/pcf-to-sqf/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 913f028e-3ecc-4a95-8a6f-0c7b1dc38d16
X-SquirrelJME-Error: AP
X-SquirrelJME-Name: PCF to SQF Font Conversion
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This converts PCF font data into SQF fonts 
 which are smaller, simpler, and faster to read than supporting PCF 
 from within SquirrelJME.
X-SquirrelJME-Depends: io midp-lcdui
Microedition-Configuration: CLDC-1.8
Main-Class: net.multiphasicapps.pcftosqf.Main

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/GlyphNames.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237













































































































































































































































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

package net.multiphasicapps.pcftosqf;

/**
 * Glyph name conversion.
 *
 * @since 2018/11/28
 */
public class GlyphNames
{
	/**
	 * Converts a glyph name to character index.
	 *
	 * @param __n The name of the glyph.
	 * @return The index of the glyph.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final int toChar(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__n)
		{
			case "uni0000":			return 0;
			case "space":			return ' ';
			case "exclam":			return '!';
			case "quotedbl":		return '"';
			case "numbersign":		return '#';
			case "dollar":			return '$';
			case "percent":			return '%';
			case "ampersand":		return '&';
			case "quotesingle":		return '\'';
			case "parenleft":		return '(';
			case "parenright":		return ')';
			case "asterisk":		return '*';
			case "plus":			return '+';
			case "comma":			return ',';
			case "hyphen":			return '-';
			case "period":			return '.';
			case "slash":			return '/';
			case "zero":			return '0';
			case "one":				return '1';
			case "two":				return '2';
			case "three":			return '3';
			case "four":			return '4';
			case "five":			return '5';
			case "six":				return '6';
			case "seven":			return '7';
			case "eight":			return '8';
			case "nine":			return '9';
			case "colon":			return ':';
			case "semicolon":		return ';';
			case "less":			return '<';
			case "equal":			return '=';
			case "greater":			return '>';
			case "question":		return 63;
			case "at":				return '@';
			case "A":				return 'A';
			case "B":				return 'B';
			case "C":				return 'C';
			case "D":				return 'D';
			case "E":				return 'E';
			case "F":				return 'F';
			case "G":				return 'G';
			case "H":				return 'H';
			case "I":				return 'I';
			case "J":				return 'J';
			case "K":				return 'K';
			case "L":				return 'L';
			case "M":				return 'M';
			case "N":				return 'N';
			case "O":				return 'O';
			case "P":				return 'P';
			case "Q":				return 'Q';
			case "R":				return 'R';
			case "S":				return 'S';
			case "T":				return 'T';
			case "U":				return 'U';
			case "V":				return 'V';
			case "W":				return 'W';
			case "X":				return 'X';
			case "Y":				return 'Y';
			case "Z":				return 'Z';
			case "bracketleft":		return '[';
			case "backslash":		return '\\';
			case "bracketright":	return ']';
			case "asciicircum":		return '^';
			case "underscore":		return '_';
			case "grave":			return '`';
			case "a":				return 'a';
			case "b":				return 'b';
			case "c":				return 'c';
			case "d":				return 'd';
			case "e":				return 'e';
			case "f":				return 'f';
			case "g":				return 'g';
			case "h":				return 'h';
			case "i":				return 'i';
			case "j":				return 'j';
			case "k":				return 'k';
			case "l":				return 'l';
			case "m":				return 'm';
			case "n":				return 'n';
			case "o":				return 'o';
			case "p":				return 'p';
			case "q":				return 'q';
			case "r":				return 'r';
			case "s":				return 's';
			case "t":				return 't';
			case "u":				return 'u';
			case "v":				return 'v';
			case "w":				return 'w';
			case "x":				return 'x';
			case "y":				return 'y';
			case "z":				return 'z';
			case "braceleft":		return '{';
			case "bar":				return '|';
			case "braceright":		return '}';
			case "asciitilde":		return '~';
			case "uni007F":			return 0x7F;
			case "uni00A0":			return 0xA0;
			case "exclamdown":		return 0xA1;
			case "cent":			return 0xA2;
			case "sterling":		return 0xA3;
			case "Euro":			return 0xA4;
			case "yen":				return 0xA5;
			case "Scaron":			return 0xA6;
			case "section":			return 0xA7;
			case "scaron":			return 0xA8;
			case "copyright":		return 0xA9;
			case "ordfeminine":		return 0xAA;
			case "guillemotleft":	return 0xAB;
			case "logicalnot":		return 0xAC;
			case "uni00AD":			return 0xAD;
			case "registered":		return 0xAE;
			case "macron":			return 0xAF;
			case "degree":			return 0xB0;
			case "plusminus":		return 0xB1;
			case "uni00B2":			return 0xB2;
			case "uni00B3":			return 0xB3;
			case "Zcaron":			return 0xB4;
			case "mu":				return 0xB5;
			case "paragraph":		return 0xB6;
			case "periodcentered":	return 0xB7;
			case "zcaron":			return 0xB8;
			case "uni00B9":			return 0xB9;
			case "ordmasculine":	return 0xBA;
			case "guillemotright":	return 0xBB;
			case "OE":				return 0xBC;
			case "oe":				return 0xBD;
			case "Ydieresis":		return 0xBE;
			case "questiondown":	return 0xBF;
			case "Agrave":			return 0xC0;
			case "Aacute":			return 0xC1;
			case "Acircumflex":		return 0xC2;
			case "Atilde":			return 0xC3;
			case "Adieresis":		return 0xC4;
			case "Aring":			return 0xC5;
			case "AE":				return 0xC6;
			case "Ccedilla":		return 0xC7;
			case "Egrave":			return 0xC8;
			case "Eacute":			return 0xC9;
			case "Ecircumflex":		return 0xCA;
			case "Edieresis":		return 0xCB;
			case "Igrave":			return 0xCC;
			case "Iacute":			return 0xCD;
			case "Icircumflex":		return 0xCE;
			case "Idieresis":		return 0xCF;
			case "Eth":				return 0xD0;
			case "Ntilde":			return 0xD1;
			case "Ograve":			return 0xD2;
			case "Oacute":			return 0xD3;
			case "Ocircumflex":		return 0xD4;
			case "Otilde":			return 0xD5;
			case "Odieresis":		return 0xD6;
			case "multiply":		return 0xD7;
			case "Oslash":			return 0xD8;
			case "Ugrave":			return 0xD9;
			case "Uacute":			return 0xDA;
			case "Ucircumflex":		return 0xDB;
			case "Udieresis":		return 0xDC;
			case "Yacute":			return 0xDD;
			case "Thorn":			return 0xDE;
			case "germandbls":		return 0xDF;
			case "agrave":			return 0xE0;
			case "aacute":			return 0xE1;
			case "acircumflex":		return 0xE2;
			case "atilde":			return 0xE3;
			case "adieresis":		return 0xE4;
			case "aring":			return 0xE5;
			case "ae":				return 0xE6;
			case "ccedilla":		return 0xE7;
			case "egrave":			return 0xE8;
			case "eacute":			return 0xE9;
			case "ecircumflex":		return 0xEA;
			case "edieresis":		return 0xEB;
			case "igrave":			return 0xEC;
			case "iacute":			return 0xED;
			case "icircumflex":		return 0xEE;
			case "idieresis":		return 0xEF;
			case "eth":				return 0xF0;
			case "ntilde":			return 0xF1;
			case "ograve":			return 0xF2;
			case "oacute":			return 0xF3;
			case "ocircumflex":		return 0xF4;
			case "otilde":			return 0xF5;
			case "odieresis":		return 0xF6;
			case "divide":			return 0xF7;
			case "oslash":			return 0xF8;
			case "ugrave":			return 0xF9;
			case "uacute":			return 0xFA;
			case "ucircumflex":		return 0xFB;
			case "udieresis":		return 0xFC;
			case "yacute":			return 0xFD;
			case "thorn":			return 0xFE;
			case "ydieresis":		return 0xFF;
			
				// Unknown
			default:
				throw new RuntimeException(__n);
		}
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/Main.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
66
67
68




































































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

package net.multiphasicapps.pcftosqf;

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import net.multiphasicapps.pcftosqf.pcf.PCFFont;

/**
 * This is the main entry point for the font conversion.
 *
 * @since 2018/11/27
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @throws Throwable On any exception.
	 * @since 2018/11/27
	 */
	public static final void main(String... __args)
		throws Throwable
	{
		byte[] sqf;
		try (InputStream in = Files.newInputStream(Paths.get(__args[0])))
		{
			// Read PCF Font
			PCFFont pcf = PCFFont.read(in);
			
			// Convert to SQF
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
			{
				// Convert to SQF
				new SQFConverter(pcf).convertTo(baos);
				
				// Use those bytes
				sqf = baos.toByteArray();
			}
			
			// Check that the font is valid
			try (ByteArrayInputStream bais = new ByteArrayInputStream(sqf))
			{
				SQFFont.read(bais).printGlyphs(System.err);
			}
		}
		
		// Write output SQF
		System.out.write(sqf);
		System.out.flush();
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/SQFConverter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367















































































































































































































































































































































































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

package net.multiphasicapps.pcftosqf;

import java.io.OutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.pcftosqf.pcf.PCFFont;
import net.multiphasicapps.pcftosqf.pcf.PCFGlyphMap;
import net.multiphasicapps.pcftosqf.pcf.PCFMetric;

/**
 * Converts to SQF format from another font.
 *
 * @since 2018/11/27
 */
public class SQFConverter
{
	/** The input PCF font. */
	protected final PCFFont pcf;
	
	/** The pixel height of the font. */
	protected final int pixelheight;
	
	/** The ascent of the font. */
	protected final int ascent;
	
	/** The descent of the font. */
	protected final int descent;
	
	/** Bytes per scan. */
	protected final int bytesperscan;
	
	/** The character widths. */
	private final byte[] _charwidths =
		new byte[256];
	
	/** Bitmap data. */
	private final byte[] _bitmap;
	
	/** Character to glyph index. */
	private final Map<Integer, Integer> _chartoglyph;
	
	/**
	 * Initializes the converter
	 *
	 * @param __pcf The PCF font to convert.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public SQFConverter(PCFFont __pcf)
		throws NullPointerException
	{
		if (__pcf == null)
			throw new NullPointerException("NARG");
		
		// Set pixels
		this.pcf = __pcf;
		
		// Extract properties
		int ascent = __pcf.accelerators.ascent,
			descent = __pcf.accelerators.descent,
			pixelheight = ascent + descent;
		this.ascent = ascent;
		this.descent = descent;
		this.pixelheight = pixelheight;
		
		// Debug
		todo.DEBUG.note("Asc + Des = PxH: %d + %d = %d",
			ascent, descent, pixelheight);
		
		// Map characters to glyph indexes, that way we can quickly find
		// them as such
		Map<Integer, Integer> chartoglyph = new HashMap<>();
		for (Map.Entry<Integer, String> e : __pcf.glyphnames.names.
			entrySet())
		{
			int ch = GlyphNames.toChar(e.getValue());
			if (ch >= 0)
				chartoglyph.put(ch, e.getKey());
		}
		
		// Store
		this._chartoglyph = chartoglyph;
		
		// Obtain all the widths
		int maxwidth = 0;
		byte[] charwidths = this._charwidths;
		for (int i = 0; i < 256; i++)
		{
			// No glyph here, ignore
			if (!chartoglyph.containsKey(i))
				continue;
			
			// Get the index
			int pcfdx = chartoglyph.get(i);
			
			// The width of this font
			int cw = __pcf.metrics.get(pcfdx).charwidth;
			charwidths[i] = (byte)cw;
			
			// Use greater width
			if (cw > maxwidth)
				maxwidth = cw;
		}
		
		// Bytes per scanline
		int bytesperscan = ((maxwidth - 1) / 8) + 1;
		this.bytesperscan = bytesperscan;
		
		// Setup bitmap
		this._bitmap = new byte[256 * bytesperscan * pixelheight];
	}
	
	/**
	 * Converts the font to SQF.
	 *
	 * @param __os The output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public final void convertTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Get basic details
		int descent = this.descent,
			pixelheight = this.pixelheight,
			bytesperscan = this.bytesperscan;
		
		// Needed to build character data
		byte[] charwidths = this._charwidths;
		byte[] bitmap = this._bitmap;
		
		// Debug
		todo.DEBUG.note("Bitmap size: %d bytes", bitmap.length);
		
		// Used to only map valid characters
		boolean[] isvalidchar = new boolean[256];
		
		// Bits per scan
		int bitsperscan = bytesperscan * 8;
		
		// Draw glyphs
		Map<Integer, Integer> chartoglyph = this._chartoglyph;
		PCFFont pcf = this.pcf;
		for (int i = 0; i < 256; i++)
		{
			// Only draw known characters
			Integer uc = chartoglyph.get(i);
			if (uc == null)
				continue;
			
			// Only draw valid characters
			PCFGlyphMap gm = pcf.bitmap.glyphmaps.get(uc);
			if (gm == null)
				continue;
			
			// Is valid
			isvalidchar[i] = true;
			
			// Get the input glyph data to draw
			byte[] in = gm.data();
			
			// Just print for debugging
			/*for (byte x : in)
				todo.DEBUG.note("%8s", Integer.toString(x & 0xFF, 2));*/
			
			// Determine the output position and where it ends
			int outdx = i * bytesperscan * pixelheight,
				enddx = outdx + bytesperscan;
			
			// Metrics of the PCF are the following
			//  lb v   v rb
			//      ###  | ascent
			//     #   # |
			//     ##### |
			//     #   # |
			//     #   # |
			//        #  + descent
			//       #   |
			PCFMetric metrics = pcf.metrics.get(uc);
			
			// The X position starts at the left side bearing
			// The source X is zero
			int penxstart = metrics.leftsidebearing,
				srcxstart = 0;
			
			// The ending X position is just the right side bearing
			// The source ends at the difference between these
			int penxend = metrics.rightsidebearing,
				srcxend = penxend - penxstart;
			
			// The ascent is the height of the symbol character from the
			// baseline to the top (or top to baseline)
			// The baseline is the font's own ascent
			// The Y position is just the font's ascent minus our ascent
			int baseliney = pcf.accelerators.ascent,
				penystart = baseliney - metrics.charascent,
				srcystart = 0;
			
			// The end Y position is just the ascent and descent of the
			// character
			int srcyend = metrics.charascent + metrics.chardescent,
				penyend = penystart + srcyend;
			
			// The number of bits which make up a single scan of the glyph
			int scanbitlen = (srcxend + 7) & ~7;
			
			// Debug
			/*
			todo.DEBUG.note("src=(%d, %d)->(%d, %d) | pen=(%d, %d)->(%d, %d)",
				srcxstart, srcystart, srcxend, srcyend,
				penxstart, penystart, penxend, penyend);*/
			
			// Go through each pixel in the source glyph and just copy it to
			// the destination
			for (int peny = penystart, srcy = srcystart; peny < penyend;
				peny++, srcy++)
			{
				// Draw each column
				for (int penx = penxstart, srcx = srcxstart; penx < penxend;
					penx++, srcx++)
				{
					// If the pen is outside of the bounds, do not draw
					// anything because it would cause an overflow
					if (penx < 0 || penx >= bitsperscan ||
						peny < 0 || peny >= pixelheight)
						continue;
					
					// Determine the index offset into the input glyph
					// bitmap, additionally map the bit that is used as
					// well which is reversed because it goes from highest
					// to lowest
					int psp = (srcy * scanbitlen) + srcx,
						idx = psp >>> 3,
						sub = 7 - (psp & 7);
					
					/*todo.DEBUG.note("(%d, %d) -> [%d] << %d", srcx, srcy,
						idx, sub);*/
					
					// If the bit is not lit then no pixel is to be drawn
					if ((in[idx] & (1 << sub)) == 0)
						continue;
					
					// Draw into the destination bitmap
					bitmap[outdx + (bytesperscan * peny) + (penx >>> 3)] |=
						(byte)(1 << (penx & 7));
				}
			}
			
			/*
			// Determine the initial pen position. it is based on the bearing
			// and how far down the font is
			// The ascent of the font is length of the font from the baseline
			PCFMetric metrics = pcf.metrics.get(uc);
			int penxstart = metrics.leftsidebearing,
				penystart = (pixelheight - metrics.chardescent) -
					metrics.charascent,
				penxend = penxstart + (metrics.charwidth -
					(metrics.rightsidebearing + metrics.leftsidebearing)),
				penyend = penystart +
					(metrics.charascent + metrics.chardescent),
				py = penystart,
				viswidth = penxend - penxstart;
			
			// Bytes per viswidth
			int bpvw = (viswidth / 8) + 1;
			
			// penystart was (pixelheight - descent) - metrics.charascent
			
			// Draw each line
			for (; py < penyend; py++)
			{
				// Draw each column
				for (int px = penxstart; px < penxend; px++)
				{
					todo.DEBUG.note("Pen=(%d, %d)", px, py);
					
					// Pen outside bounds of destination character?
					if (px < 0 || px >= bitsperscan ||
						py < 0 || py >= pixelheight)
						continue;
					
					// Difference between the pen positions
					int pdiffx = (px - penxstart),
						pdiffy = (py - penystart);
					
					// Glyph pixels are padded to bytes
					int adx = pdiffy * bpvw;
					
					// Outside the array bounds
					if (adx < 0 || adx >= in.length)
						continue;
					
					// Figure out the position to check in the sub-pixel
					// Higher values are higher pixels
					int subpx = 7 - (pdiffx & 0x7);
					
					// If this not lit?
					if ((in[adx] & (1 << subpx)) == 0)
						continue;
					
					bitmap[outdx + (bytesperscan * py) + (px / 8)] |=
						(byte)(1 << (px % 8));
				}
			}
			*/
			/*
			// Draw all input lines
			int sxlimit = (metrics.charwidth + 7) & ~7;
			for (int idx = 0, inn = in.length; idx < inn; idx++, py++)
			{
				// Reset the X position to the starting left side
				px = penxstart;
				
				// Draw for the entire width of the glyph
				for (int sx = 0; sx < sxlimit; sx++, px++)
				{
					// The bitmap is encoded where the higher bits are the
					// left most pixels, so that needs to be swapped
					int subpx = 7 - (sx & 0x7);
					
					// No mark here?
					int uidx = idx + (sx >>> 3);
					if (uidx >= in.length || (in[uidx] & (1 << subpx)) == 0)
						continue;
					
					// Pen outside bounds?
					if (px < 0 || px >= bitsperscan ||
						py < 0 || py >= pixelheight)
						continue;
					
					bitmap[outdx + py + (px / 8)] |= (byte)(1 << (px % 8));
				}
			}*/
		}
		
		// Write font data
		__os.write(pixelheight);
		__os.write(this.ascent);
		__os.write(descent);
		__os.write(bytesperscan);
		__os.write(charwidths);
		
		for (boolean b : isvalidchar)
			__os.write((b ? 1 : 0));
		
		__os.write(bitmap);
		
		// Flush because this might be a buffered output
		__os.flush();
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package is for the conversion of PCFs to SQFs.
 *
 * @since 2018/11/27
 */

package net.multiphasicapps.pcftosqf;

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFAccelerators.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228




































































































































































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the accelerator table found in PCF fonts, just general
 * information on the font and such.
 *
 * @since 2018/11/27
 */
public final class PCFAccelerators
{
	/** Accelerators with ink bounds. */
	static final int _PCF_ACCEL_W_INKBOUNDS =
		0x00000100;
	
	/** The format. */
	public final int format;
	
	/** No overlap? */
	public final boolean nooverlap;
	
	/** Constant metrics? */
	public final boolean constantmetrics;
	
	/** Terminal font? */
	public final boolean terminalfont;
	
	/** Constant width? */
	public final boolean constantwidth;
	
	/** Ink inside the bounds? */
	public final boolean inkinside;
	
	/** Do the ink metrics differ ever? */
	public final boolean inkmetrics;
	
	/** Draw direction, false=LTR, true=RTL. */
	public final boolean drawdirection;
	
	/** Ascent. */
	public final int ascent;
	
	/** Descent. */
	public final int descent;
	
	/** Maximum overlap. */
	public final int maxoverlap;
	
	/** Minimum bounds. */
	public final PCFMetric minbounds;
	
	/** Maximum bounds. */
	public final PCFMetric maxbounds;
	
	/** Minimum ink bounds, is optional. */
	public final PCFMetric inkminbounds;
	
	/** Maximum ink bounds, is optional. */
	public final PCFMetric inkmaxbounds;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the accelerators.
	 *
	 * @param __format Format
	 * @param __nooverlap No overlap?
	 * @param __constantmetrics Constant metrics?
	 * @param __terminalfont Terminal font?
	 * @param __constantwidth Constant width?
	 * @param __inkinside All inks inside?
	 * @param __inkmetrics Ink metrics?
	 * @param __drawdirection Draw direction LTR or RTL?
	 * @param __ascent Ascent.
	 * @param __descent Descent.
	 * @param __maxoverlap Maximum overlap.
	 * @param __minbounds Minimum bounds.
	 * @param __maxbounds Maximum bounds.
	 * @param __inkminbounds Minimum ink bounds.
	 * @param __inkmaxbounds Maximum ink bounds.
	 * @throws NullPointerException If no min bounds or max bounds were
	 * specified.
	 * @since 2018/11/27
	 */
	PCFAccelerators(int __format, boolean __nooverlap,
		boolean __constantmetrics, boolean __terminalfont,
		boolean __constantwidth, boolean __inkinside, boolean __inkmetrics,
		boolean __drawdirection, int __ascent, int __descent, int __maxoverlap,
		PCFMetric __minbounds, PCFMetric __maxbounds,
		PCFMetric __inkminbounds, PCFMetric __inkmaxbounds)
		throws NullPointerException
	{
		if (__minbounds == null || __maxbounds == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.nooverlap = __nooverlap;
		this.constantmetrics = __constantmetrics;
		this.terminalfont = __terminalfont;
		this.constantwidth = __constantwidth;
		this.inkinside = __inkinside;
		this.inkmetrics = __inkmetrics;
		this.drawdirection = __drawdirection;
		this.ascent = __ascent;
		this.descent = __descent;
		this.maxoverlap = __maxoverlap;
		this.minbounds = __minbounds;
		this.maxbounds = __maxbounds;
		this.inkminbounds = __inkminbounds;
		this.inkmaxbounds = __inkmaxbounds;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/27
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("{" +
				"format=%x, " +
				"nooverlap=%s, " +
				"constantmetrics=%s, " +
				"terminalfont=%s, " +
				"constantwidth=%s, " +
				"inkinside=%s, " +
				"inkmetrics=%s, " +
				"drawdirection=%s, " +
				"ascent=%s, " +
				"descent=%s, " +
				"maxoverlap=%s, " +
				"minbounds=%s, " +
				"maxbounds=%s, " +
				"inkminbounds=%s, " +
				"inkmaxbounds=%s" +
				"}", this.format,
				this.nooverlap,
				this.constantmetrics,
				this.terminalfont,
				this.constantwidth,
				this.inkinside,
				this.inkmetrics,
				this.drawdirection,
				this.ascent,
				this.descent,
				this.maxoverlap,
				this.minbounds,
				this.maxbounds,
				this.inkminbounds,
				this.inkmaxbounds)));
		
		return rv;
	}
	
	/**
	 * Reads the accelerator data.
	 *
	 * @param __dis The input stream to parse from.
	 * @return The accelerator table.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFAccelerators read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read the format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Fields which might be true for all characters
		boolean nooverlap = (__dis.readByte() != 0);
		boolean constantmetrics = (__dis.readByte() != 0);
		boolean terminalfont = (__dis.readByte() != 0);
		boolean constantwidth = (__dis.readByte() != 0);
		boolean inkinside = (__dis.readByte() != 0);
		boolean inkmetrics = (__dis.readByte() != 0);
		boolean drawdirection = (__dis.readByte() != 0);
		
		// Padding byte
		__dis.readByte();
		
		// Ascent, descent, and max overlap
		int ascent = __dis.readInt();
		int descent = __dis.readInt();
		int maxoverlap = __dis.readInt();
		
		// Read minimum and maximum bounds
		PCFMetric minbounds = PCFMetric.readUncompressed(__dis);
		PCFMetric maxbounds = PCFMetric.readUncompressed(__dis);
		
		// These are optional only if the given format is used
		PCFMetric inkminbounds = null,
			inkmaxbounds = null;
		if ((format & _PCF_ACCEL_W_INKBOUNDS) != 0)
		{
			inkminbounds = PCFMetric.readUncompressed(__dis);
			inkmaxbounds = PCFMetric.readUncompressed(__dis);
		}
		
		return new PCFAccelerators(format, nooverlap, constantmetrics,
			terminalfont, constantwidth, inkinside, inkmetrics, drawdirection,
			ascent, descent, maxoverlap, minbounds, maxbounds, inkminbounds,
			inkmaxbounds);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFBitmap.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
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

















































































































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This represents the bitmap from within a PCF file.
 *
 * @since 2018/11/28
 */
public final class PCFBitmap
{
	/** The format. */
	public final int format;
	
	/** The number of glyphs. */
	public final int numglyphs;
	
	/** The glyph map. */
	public final Map<Integer, PCFGlyphMap> glyphmaps;
	
	/**
	 * Initializes the bitmap data.
	 *
	 * @param __format The format used.
	 * @param __numglyphs The glyphs used.
	 * @param __offsets The offsets.
	 * @param __data The data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFBitmap(int __format, int __numglyphs, int[] __offsets,
		byte[] __data)
		throws NullPointerException
	{
		if (__offsets == null || __data == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.numglyphs = __numglyphs;
		
		// This class is used to sort all of the offsets but still keep the
		// original indexes
		final class __Index__
			implements Comparable<__Index__>
		{
			/** The offset. */
			public final int offset;
			
			/** The index. */
			public final int index;
			
			/**
			 * Initializes the index.
			 *
			 * @param __o The offset.
			 * @param __i The index.
			 * @since 2018/11/29
			 */
			__Index__(int __o, int __i)
			{
				this.offset = __o;
				this.index = __i;
			}
			
			/**
			 * {@inheritDoc}
			 * @since 2018/11/29
			 */
			@Override
			public int compareTo(__Index__ __o)
			{
				// Sort by the offset first, but it is possible that some
				// glyphs might share the same offset, so do not lose them!
				int rv = this.offset - __o.offset;
				if (rv != 0)
					return rv;
				return this.index - __o.index;
			}
		}
		
		// Go through all the offsets and determine all of the bounds
		Set<__Index__> index = new SortedTreeSet<>();
		for (int i = 0; i < numglyphs; i++)
			index.add(new __Index__(__offsets[i], i));
		
		// Need to determine the bounds for every glyph to extract the data
		// for it, so mark when an index ends and such. So go through
		// and mark where a new glyph starts.
		int datalen = __data.length;
		boolean[] boops = new boolean[datalen];
		for (__Index__ i : index)
			boops[i.offset] = true;
		
		// Build the bitmaps for each map of glyphs so they can be converted
		// accordingly
		Map<Integer, PCFGlyphMap> glyphmaps = new HashMap<>();
		for (__Index__ i : index)
		{
			// Start with a dynamic set of copied byte data
			List<Byte> bm = new ArrayList<>();
			
			// Add all the bits that make up the glyph data there
			for (int o = i.offset; o < datalen;)
			{
				// Add this byte always
				bm.add(__data[o++]);
				
				// Since we are at the next index check for the end or if
				// it signaled a new glyph here
				if (o >= datalen || boops[o])
					break;
			}
			
			// Store the glyph data
			glyphmaps.put(i.index, new PCFGlyphMap(bm));
		}
		
		this.glyphmaps = glyphmaps;
	}
	
	/**
	 * Reads the bitmap data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting bitmap.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFBitmap read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the glyph offsets
		int numglyphs = __dis.readInt();
		int[] offsets = new int[numglyphs];
		for (int i = 0; i < numglyphs; i++)
			offsets[i] = __dis.readInt();
		
		// Read all four bitmap sizes
		int[] bitmapsizes = new int[4];
		for (int i = 0; i < 4; i++)
			bitmapsizes[i] = __dis.readInt();
		
		// The bytes depends on the format
		byte[] data = new byte[bitmapsizes[format & 3]];
		__dis.readFully(data);
		
		// Build bitmap
		return new PCFBitmap(format, numglyphs, offsets, data);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFEncoding.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
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















































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * This contains the PCF encoding data.
 *
 * @since 2018/11/28
 */
public final class PCFEncoding
{
	/** The format. */
	public final int format;
	
	/** The minimum char or byte 2? */
	public final int mincharorbyte2;
	
	/** The maximum char or byte 2? */
	public final int maxcharorbyte2;
	
	/** Min byte1? */
	public final int minbyte1;
	
	/** Max byte1? */
	public final int maxbyte1;
	
	/** Default character. */
	public final int defaultchar;
	
	/** Glyph indexes. */
	private final int[] _glyphindexes;
	
	/**
	 * Initializes the encoding.
	 *
	 * @param __format Format.
	 * @param __mincharorbyte2 Minimum char or byte2?
	 * @param __maxcharorbyte2 Maximum char or byte2?
	 * @param __minbyte1 Min byte1?
	 * @param __maxbyte1 Max byte1?
	 * @param __defaultchar Default character.
	 * @param __glyphindexes Glyph indexes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFEncoding(int __format, int __mincharorbyte2,
		int __maxcharorbyte2, int __minbyte1, int __maxbyte1,
		int __defaultchar, int[] __glyphindexes)
		throws NullPointerException
	{
		if (__glyphindexes == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.mincharorbyte2 = __mincharorbyte2;
		this.maxcharorbyte2 = __maxcharorbyte2;
		this.minbyte1 = __minbyte1;
		this.maxbyte1 = __maxbyte1;
		this.defaultchar = __defaultchar;
		this._glyphindexes = __glyphindexes.clone();
	}
	
	/**
	 * Reads the encoding data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting encoding data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFEncoding read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read properties
		int mincharorbyte2 = __dis.readShort(),
			maxcharorbyte2 = __dis.readShort(),
			minbyte1 = __dis.readShort(),
			maxbyte1 = __dis.readShort(),
			defaultchar = __dis.readShort();
		
		// Read index table
		int numglyphindexes = (maxcharorbyte2 - mincharorbyte2 + 1) *
			(maxbyte1 - minbyte1 + 1);
		int[] glyphindexes = new int[numglyphindexes];
		for (int i = 0; i < numglyphindexes; i++)
			glyphindexes[i] = __dis.readShort();
		
		// Build
		return new PCFEncoding(format, mincharorbyte2, maxcharorbyte2,
			minbyte1, maxbyte1, defaultchar, glyphindexes);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFFont.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275



















































































































































































































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.ByteArrayInputStream;	
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableList;

/**
 * This class is capable of reading PCF formatted fonts and reading all of
 * the information from it.
 *
 * Information on the font is at these locations:
 * * <https://fontforge.github.io/en-US/documentation/reference/pcf-format/>
 * * <https://web.archive.org/web/20020215194039if_/
 *   http://myhome.hananet.net:80/~bumchul/xfont/pcf.txt>
 * * <https://web.archive.org/web/20090205034052/
 *   http://www.tsg.ne.jp:80/GANA/S/pcf2bdf/pcf.pdf>
 *
 * @since 2018/11/25
 */
public class PCFFont
{
	/** Properties. */
	public final PCFProperties properties;
	
	/** Accelerators. */
	public final PCFAccelerators accelerators;
	
	/** Metrics. */
	public final List<PCFMetric> metrics;
	
	/** Bitmap. */
	public final PCFBitmap bitmap;
	
	/** Encoding. */
	public final PCFEncoding encoding;
	
	/** Scalable widths. */
	public final PCFScalableWidths scalablewidths;
	
	/** The glyph names. */
	public final PCFGlyphNames glyphnames;
	
	/**
	 * Initializes the font.
	 *
	 * @param __properties 
	 * @param __accelerators 
	 * @param __metrics 
	 * @param __bitmap 
	 * @param __encoding 
	 * @param __scalablewidths 
	 * @param __glyphnames 
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFFont(PCFProperties __properties, PCFAccelerators __accelerators,
		PCFMetric[] __metrics, PCFBitmap __bitmap, PCFEncoding __encoding,
		PCFScalableWidths __scalablewidths, PCFGlyphNames __glyphnames)
		throws NullPointerException
	{
		if (__properties == null || __accelerators == null ||
			__metrics == null || __bitmap == null || __encoding == null ||
			__scalablewidths == null || __glyphnames == null)
			throw new NullPointerException("NARG");
		
		this.properties = __properties;
		this.accelerators = __accelerators;
		this.metrics = UnmodifiableList.<PCFMetric>of(
			Arrays.<PCFMetric>asList(__metrics.clone()));
		this.bitmap = __bitmap;
		this.encoding = __encoding;
		this.scalablewidths = __scalablewidths;
		this.glyphnames = __glyphnames;
	}
	
	/**
	 * Reads the given stream for PCF font information.
	 *
	 * @param __in The stream to read from.
	 * @return The decoded font information.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/25
	 */
	public static final PCFFont read(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need to read in the data!
		DataInputStream dos = new DataInputStream(__in);
		
		// {@squirreljme.error AP01 Invalid PCF magic number.}
		int magic;
		if ((magic = dos.readInt()) != 0x01666370)
			throw new IOException(String.format("AP01 %08x", magic));
		
		// Read each table entry, since they have offsets into the file they
		// could be in any random order which would be bad
		Set<PCFTableEntry> tables = new SortedTreeSet<>();
		int numtables = Integer.reverseBytes(dos.readInt());
		for (int i = 0; i < numtables; i++)
			tables.add(new PCFTableEntry(
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt())));
		
		// Determine the base position of the read pointer
		int readptr = 8 + (numtables * 16);
		
		// Debug
		todo.DEBUG.note("Table: %s, ended at %d", tables, readptr);
		
		// Parsed fields
		PCFProperties pcfp = null;
		PCFAccelerators pcfaccel = null;
		PCFMetric[] metrics = null;
		PCFBitmap bitmap = null;
		PCFEncoding encoding = null;
		PCFScalableWidths scalablewidths = null;
		PCFGlyphNames glyphnames = null;
		
		// Go through all table entries and parse them, they will be sorted
		// by their offset and handled as such
		boolean waseofing = false;
		for (PCFTableEntry te : tables)
		{
			// {@squirreljme.error AP02 Expected EOF to occur on the last
			// entry, this likely means the file was truncated more than
			// what was expected.}
			if (waseofing)
				throw new IOException("AP02");
			
			// Skip bytes needed to reach the destination
			int skippy = te.offset - readptr;
			if (skippy > 0)
				dos.skipBytes(skippy);
			
			// {@squirreljme.error AP03 Negative skip distance.}
			else if (skippy < 0)
				throw new IOException("AP03");
			
			// Debug
			todo.DEBUG.note("Read entry %s", te);
			
			// Read in data that makes up this section, but the entries could
			// be clipped short and have a size larger than the file. So just
			// assume zero padding is used and hope it works
			int tesize;
			byte[] data = new byte[(tesize = te.size)];
			for (int i = 0; i < tesize; i++)
			{
				int rc = dos.read();
				
				// Make sure this is the last entry on EOF!
				if (rc < 0)
				{
					waseofing = true;
					break;
				}
				
				data[i] = (byte)rc;
			}
			
			// Handle the data in the section
			switch (te.type)
			{
					// Properties
				case 1:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						pcfp = PCFProperties.read(dis);
					}
					break;
					
					// Accelerators
				case 2:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						pcfaccel = PCFAccelerators.read(dis);
					}
					break;
					
					// Metrics
				case 4:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						metrics = PCFMetric.readMetrics(dis);
					}
					break;
					
					// Bitmaps
				case 8:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						bitmap = PCFBitmap.read(dis);
					}
					break;
					
					// Ink Metrics (NOT USED???)
				case 16:
					if (true)
						throw new todo.TODO();
					break;
					
					// BDF Encodings
				case 32:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						encoding = PCFEncoding.read(dis);
					}
					break;
					
					// SWidths
				case 64:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						scalablewidths = PCFScalableWidths.read(dis);
					}
					break;
					
					// Glyph Names
				case 128:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						glyphnames = PCFGlyphNames.read(dis); 
					}
					break;
					
					// BDF Accelerators
				case 256:
					// Debug
					todo.DEBUG.note("Ignoring BDF Accelerators");
					break;
					
					// {@squirreljme.error AP04 Unknown PCF type. (The type)}
				default:
					throw new IOException("AP04 " + te.type);
			}
			
			// Set pointer for next run
			readptr += te.size;
		}
		
		// Build font
		return new PCFFont(pcfp, pcfaccel, metrics, bitmap,
			encoding, scalablewidths, glyphnames);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFGlyphMap.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
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






















































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.List;

/**
 * This represents the map of a glyph.
 *
 * @since 2018/11/29
 */
public final class PCFGlyphMap
{
	/** The glyph data. */
	private byte[] _data;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the glyph map.
	 *
	 * @param __bm The bytes used to make up the map.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public PCFGlyphMap(List<Byte> __bm)
		throws NullPointerException
	{
		if (__bm == null)
			throw new NullPointerException("NARG");
		
		// Copy the data
		int n = __bm.size();
		byte[] data = new byte[n];
		for (int i = 0; i < n; i++)
			data[i] = __bm.get(i);
		
		this._data = data;
	}
	
	/**
	 * Initializes the glyph map.
	 *
	 * @param __bm The bytes used to make up the map.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public PCFGlyphMap(byte[] __bm)
		throws NullPointerException
	{
		if (__bm == null)
			throw new NullPointerException("NARG");
		
		this._data = __bm.clone();
	}
	
	/**
	 * Returns a copy of the glyph data.
	 *
	 * @return The glyph data.
	 * @since 2018/11/29
	 */
	public final byte[] data()
	{
		return this._data.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/29
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Setup buffer
			byte[] data = this._data;
			int n = data.length;
			StringBuilder sb = new StringBuilder(16 + (n * 9));
			
			sb.append("glyph[");
			sb.append(n);
			sb.append("]={");
			
			// Build glyph bytes
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append('|');
				for (int j = 7; j >= 0; j--)
					sb.append(((data[i] & (1 << j)) != 0 ? '#' : '.'));
			}
			
			sb.append("}");
			
			// Done
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFGlyphNames.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
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


























































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * Glyph name table.
 *
 * @since 2018/11/28
 */
public final class PCFGlyphNames
{
	/** The format. */
	public final int format;
	
	/** The glyph names. */
	public final Map<Integer, String> names;
	
	/**
	 * Initializes the glyph names.
	 *
	 * @param __format The format.
	 * @param __names The names.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFGlyphNames(int __format, Map<Integer, String> __names)
		throws NullPointerException
	{
		if (__names == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.names = UnmodifiableMap.<Integer, String>of(
			new SortedTreeMap<>(__names));
	}
	
	/**
	 * Reads the glyph name data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting glyph names.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFGlyphNames read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the string offsets
		int numglyphs = __dis.readInt();
		int[] offsets = new int[numglyphs];
		for (int i = 0; i < numglyphs; i++)
			offsets[i] = __dis.readInt();
		
		// Read the string table
		int stringsize = __dis.readInt();
		byte[] strings = new byte[stringsize];
		__dis.readFully(strings);
		
		// Map strings to indexes
		Map<Integer, String> names = new HashMap<>();
		for (int i = 0; i < numglyphs; i++)
			names.put(i, PCFProperties.__readString(strings, offsets[i]));
		
		// Build
		return new PCFGlyphNames(format, names);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFMetric.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
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






























































































































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/**
 * This contains a single metric within a PCF file.
 *
 * @since 2018/11/27
 */
public final class PCFMetric
{
	/** Compressed metrics format. */
	static final int _PCF_COMPRESSED_METRICS =
		0x00000100;
	
	/** Left side bearing. */
	public final short leftsidebearing;
	
	/** Right side bearing. */
	public final short rightsidebearing;
	
	/** Character width. */
	public final short charwidth;
	
	/** Character ascent. */
	public final short charascent;
	
	/** Character descent. */
	public final short chardescent;
	
	/** Character attributes. */
	public final int attributes;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the metric.
	 *
	 * @param __lsb Left side bearing.
	 * @param __rsb Right side bearing.
	 * @param __cw Character width.
	 * @param __ca Character ascent.
	 * @param __cd Character descent.
	 * @param __a Attributes.
	 * @since 2018/11/27
	 */
	PCFMetric(short __lsb, short __rsb, short __cw, short __ca,
		short __cd, int __a)
	{
		this.leftsidebearing = __lsb;
		this.rightsidebearing = __rsb;
		this.charwidth = __cw;
		this.charascent = __ca;
		this.chardescent = __cd;
		this.attributes = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/27
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"{leftsidebearing=%d, rightsidebearing=%d, " +
				"charwidth=%d, charascent=%d, chardescent=%d, " +
				"attributes=%x}", this.leftsidebearing,
				this.rightsidebearing, this.charwidth, this.charascent,
				this.chardescent, this.attributes)));
		
		return rv;
	}
	
	/**
	 * Reads a compressed metric from the input.
	 *
	 * @param __dis The stream to read from.
	 * @return The metric.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric readCompressed(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// All are unsigned bytes with implied attributes of zero
		// All of the values are offset signed
		return new PCFMetric(
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			0);
	}
	
	/**
	 * Reads the metric table.
	 *
	 * @param __dis The stream to read from.
	 * @return The read metrics.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric[] readMetrics(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		PCFMetric[] rv;
		
		// Are these compressed metrics
		if (((Integer.reverseBytes(__dis.readInt())) &
			_PCF_COMPRESSED_METRICS) != 0)
		{
			// Read length
			int n = __dis.readUnsignedShort();
			rv = new PCFMetric[n];
			
			// Read all metrics			
			for (int i = 0; i < n; i++)
				rv[i] = PCFMetric.readCompressed(__dis);
		}
		
		// They are uncompressed
		else
		{
			// Read length
			int n = __dis.readInt();
			rv = new PCFMetric[n];
			
			// Read all metrics			
			for (int i = 0; i < n; i++)
				rv[i] = PCFMetric.readUncompressed(__dis);
		}
		
		return rv;
	}
	
	/**
	 * Reads an uncompressed metric from the input.
	 *
	 * @param __dis The stream to read from.
	 * @return The metric.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric readUncompressed(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// All are unsigned bytes with implied attributes of zero
		return new PCFMetric(
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readUnsignedShort());
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFProperties.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
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
















































































































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * Properties which describe the PCF. These properties are the font atoms
 * which X11 provides to the user.
 *
 * @since 2018/11/27
 */
public final class PCFProperties
{
	/** The format of the event table. */
	public final int format;
	
	/** Values within the table. */
	public final Map<String, Object> values;
	
	/**
	 * Initializes the properties.
	 *
	 * @param __f The format.
	 * @param __v The values used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	private PCFProperties(int __f, Map<String, Object> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.format = __f;
		this.values = UnmodifiableMap.<String, Object>of(__v);
	}
	
	/**
	 * Reads from the input stream and loads the properties.
	 *
	 * @param __dis The input stream to read the properties from.
	 * @return The properties which have been read.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFProperties read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read the format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the raw properties which can only be parsed when the string
		// table is actually read
		int nprops = __dis.readInt();
		int[] pnameoff = new int[nprops];
		boolean[] pisstr = new boolean[nprops];
		int[] pvalue = new int[nprops];
		for (int i = 0; i < nprops; i++)
		{
			pnameoff[i] = __dis.readInt();
			pisstr[i] = (__dis.readByte() != 0);
			pvalue[i] = __dis.readInt();
		}
		
		// Since the stream knows nothing of the size, it must be determined
		int eopaddr = 8 + (9 * nprops);
		
		// Skip padding bytes, which is a 4 byte boundary
		if ((eopaddr & 3) != 0)
			__dis.skipBytes(4 - (eopaddr & 3));
		
		// Read the raw string table as a bunch of bytes, these are NUL
		// terminated strings
		int ssn = __dis.readInt();
		byte[] sschars = new byte[ssn];
		__dis.readFully(sschars);
		
		// Parse the input strings and such into property values which are
		// either strings or integers
		Map<String, Object> values = new HashMap<>();
		for (int i = 0; i < nprops; i++)
		{
			String key = PCFProperties.__readString(sschars, pnameoff[i]);
			
			// Store a value into map
			values.put(key, (!pisstr[i] ? Integer.valueOf(pvalue[i]) :
				PCFProperties.__readString(sschars, pvalue[i])));
		}
		
		// Debug
		todo.DEBUG.note("format=%d, props=%s", format, values);
		
		// Finish properties
		return new PCFProperties(format, values);
	}
	
	/**
	 * Reads a string from the byte array, since strings are NUL terminated
	 * they are scanned and read as such accordingly.
	 *
	 * @param __ssc Input bytes for string data.
	 * @param __p The pointer to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	static final String __readString(byte[] __ssc, int __p)
		throws NullPointerException
	{
		if (__ssc == null)
			throw new NullPointerException("NARG");
		
		// Place into string
		StringBuilder sb = new StringBuilder();
		for (int n = __ssc.length; __p < n; __p++)
		{
			// Stop at any NUL
			byte c = __ssc[__p];
			if (c == 0)
				break;
			
			sb.append((char)(c & 0xFF));
		}
		
		return sb.toString();
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFScalableWidths.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
66
67
68
69
70
71
72
73
74










































































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

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Scalable widths table, these are postscript em-units at 1/1000th of an em.
 *
 * @since 2018/11/28
 */
public final class PCFScalableWidths
{
	/** The format. */
	public final int format;
	
	/** The scalable widths. */
	private final int[] _swidths;
	
	/**
	 * Initializes the scalable widths.
	 *
	 * @param __format The format used.
	 * @param __swidths The widths.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFScalableWidths(int __format, int[] __swidths)
		throws NullPointerException
	{
		if (__swidths == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this._swidths = __swidths.clone();
	}
	
	/**
	 * Reads the scalable widths.
	 *
	 * @param __dis The input stream.
	 * @return The resulting encoding data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFScalableWidths read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read in table
		int n = __dis.readInt();
		int[] swidths = new int[n];
		for (int i = 0; i < n; i++)
			swidths[i] = __dis.readInt();
		
		return new PCFScalableWidths(format, swidths);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/PCFTableEntry.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
66
67
68
69
70
71







































































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

package net.multiphasicapps.pcftosqf.pcf;

/**
 * This represents a single table within the PCF.
 *
 * @since 2018/11/25
 */
public final class PCFTableEntry
	implements Comparable<PCFTableEntry>
{
	/** The type of table entry this is. */
	public final int type;
	
	/** The format of the entry. */
	public final int format;
	
	/** The size of the entry. */
	public final int size;
	
	/** The offset to the entry. */
	public final int offset;
	
	/**
	 * Initializes the table entry.
	 *
	 * @param __t The type.
	 * @param __f The format.
	 * @param __s The size.
	 * @param __o The offset.
	 * @since 2018/11/25
	 */
	public PCFTableEntry(int __t, int __f, int __s, int __o)
	{
		this.type = __t;
		this.format = __f;
		this.size = __s;
		this.offset = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public int compareTo(PCFTableEntry __o)
	{
		return this.offset - __o.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public String toString()
	{
		return String.format("(type=%d, format=%d, size=%d, offset=%d)",
			this.type, this.format, this.size, this.offset);
	}
}

Deleted bldt/mids/pcf-to-sqf/net/multiphasicapps/pcftosqf/pcf/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the needed classes to parse and decode PCF fonts.
 *
 * @since 2018/11/28
 */

package net.multiphasicapps.pcftosqf.pcf;

Deleted bldt/mids/sqf-to-c/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 759dec0c-46ab-4918-930e-ff39c386d41b
X-SquirrelJME-Error: BO
X-SquirrelJME-Name: SQF to C
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: Converts a SQF to a C file, so that RatufaCoat 
 can use it to draw a basic console screen and such.
X-SquirrelJME-Depends: midp-lcdui
Main-Class: dev.shadowtail.sqftoc.Main
Microedition-Configuration: CLDC-1.8-Compact

Deleted bldt/mids/sqf-to-c/dev/shadowtail/sqftoc/Main.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.sqftoc;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.PrintStream;
import cc.squirreljme.runtime.lcdui.font.SQFFont;

/**
 * Converts SQF to C file.
 *
 * @since 2019/06/20
 */
public class Main
{
	/** Column size. */
	public static final int COLUMNS =
		65;
	
	/**
	 * Main entry for the converter.
	 *
	 * @param __args Arguments, the first one is the resource to use.
	 * @throws Throwable On any exception
	 * @since 2019/06/20
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// Which font to convert?
		String rcname = (__args == null || __args.length == 0 ||
			__args[0] == null ? "monospace-12.sqf" : __args[0]);
		
		// The stream to write to
		PrintStream ps = System.out;
		
		// Load the font data
		try (DataInputStream dis = new DataInputStream(
			SQFFont.class.getResourceAsStream(rcname)))
		{
			// Read fields
			byte pixelheight = dis.readByte(),
				ascent = dis.readByte(),
				descent = dis.readByte(),
				bytesperscan = dis.readByte();
			
			// The character widths
			byte[] charwidths = new byte[256];
			dis.readFully(charwidths);
			ps.println("/** SQF Character Widths. */");
			Main.__dumpBytes(ps, "sjme_fontcharwidths", charwidths);
			ps.println();
			
			// Is the character valid?
			byte[] isvalidchar = new byte[256];
			dis.readFully(isvalidchar);
			ps.println("/** SQF Character validity. */");
			Main.__dumpBytes(ps, "sjme_fontisvalidchar", isvalidchar);
			ps.println();
			
			// Character bitmaps
			byte[] charbmp = new byte[256 * bytesperscan * pixelheight];
			dis.readFully(charbmp);
			ps.println("/** SQF Character Bitmaps. */");
			Main.__dumpBytes(ps, "sjme_fontcharbmp", charbmp);
			ps.println();
			
			// Output structure for the font
			ps.println("/** SQF Defined Font. */");
			ps.println("static sjme_sqf sjme_font =");
			ps.println("{");
			
			// All four fields in the header
			ps.printf("\t%d,%n", pixelheight);
			ps.printf("\t%d,%n", ascent);
			ps.printf("\t%d,%n", descent);
			ps.printf("\t%d,%n", bytesperscan);
			ps.println("\tsjme_fontcharwidths,");
			ps.println("\tsjme_fontisvalidchar,");
			ps.println("\tsjme_fontcharbmp");
			
			ps.println("};");
			ps.println();
		}
	}
	
	/**
	 * Dumps the specified byte array.
	 *
	 * @param __ps The stream to write to.
	 * @param __name The name of the field.
	 * @param __b The input bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/20
	 */
	private static final void __dumpBytes(PrintStream __ps, String __name,
		byte[] __b)
		throws NullPointerException
	{
		if (__ps == null || __name == null || __b == null)
			throw new NullPointerException("NARG");
		
		__ps.printf("static sjme_jbyte %s[] =%n", __name);
		__ps.println("{");
		
		// Used to fill up lines at a time
		StringBuilder sb = new StringBuilder();
		
		// Print every character!
		for (int i = 0, n = __b.length; i < n; i++)
		{
			// Append byte
			sb.append(__b[i]);
			
			// Add comma if this is not the last byte
			if (i < n - 1)
				sb.append(", ");
			
			// Dump if column limit was reached
			if (sb.length() >= COLUMNS)
			{
				// If it ends with a space, remove it (is annoying to have)
				if (sb.charAt(sb.length() - 1) == ' ')
					sb.setLength(sb.length() - 1);
				
				// Print out
				__ps.printf("\t%s%n", sb);
				
				// Reset for next run
				sb.setLength(0);
			}
		}
		
		// Print anything left over!
		if (sb.length() > 0)
			__ps.printf("\t%s%n", sb);
		
		__ps.println("};");
	}
}

Deleted bldt/mids/sqf-to-c/dev/shadowtail/sqftoc/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This converts a SQF to a C file for RatufaCoat.
 *
 * @since 2019/06/20
 */

package dev.shadowtail.sqftoc;

Deleted bldt/mids/sxs/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 62285c91-c4f4-4f61-83fe-ddc2c97e849c
X-SquirrelJME-Error: BL
X-SquirrelJME-Name: Side By Side Code Debug
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This utility is used to provide a view into 
 the native code translation by showing a side by side representation 
 of the input source code, the original byte code, and then the 
 generated native code.
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: dev.shadowtail.sxs.Main
X-SquirrelJME-Depends: builder-support

Deleted bldt/mids/sxs/dev/shadowtail/sxs/Main.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324




































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.sxs;

import cc.squirreljme.builder.support.Binary;
import cc.squirreljme.builder.support.BinaryManager;
import cc.squirreljme.builder.support.NoSuchSourceException;
import cc.squirreljme.builder.support.ProjectManager;
import cc.squirreljme.builder.support.Source;
import cc.squirreljme.builder.support.SourceManager;
import cc.squirreljme.builder.support.SourceName;
import cc.squirreljme.builder.support.SourcePathSetType;
import cc.squirreljme.builder.support.TimeSpaceType;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import dev.shadowtail.classfile.nncc.NativeCode;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.InstructionMnemonics;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.NoSuchInputException;

/**
 * Main entry point and dumber for the class code side by side
 *
 * @since 2019/06/12
 */
public class Main
{
	/** The maximum column size. */
	public static final int COLUMN_SIZE =
		44;
	
	/**
	 * Dumps the given method.
	 *
	 * @param __ps The stream to write to.
	 * @param __srclines The source lines.
	 * @param __m The method to dump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/12
	 */
	public static final void dump(PrintStream __ps,
		List<String> __srclines, Method __m)
		throws NullPointerException
	{
		if (__ps == null || __srclines == null || __m == null)
			throw new NullPointerException("NARG");
		
		// Note what is being dumped
		__ps.printf("****** %s ******", __m.nameAndType());
		__ps.println();
		
		// Line population count, to track how many times it changed to them
		Map<Integer, Integer> lnpopcount = new HashMap<>();
		
		// Get byte code and native code
		ByteCode bc = __m.byteCode();
		NativeCode nc = __m.nativeCode();
		
		// Native debug information
		int nijln = -1,
			nijop = -1,
			nijpc = -1;
		
		// Last position information, to detect changes
		int lljln = nijln,
			lljop = nijop,
			lljpc = nijpc;
		
		// Fragment part builder
		StringBuilder sb = new StringBuilder();
		
		// Major order is the native code
		for (int nidx = 0, numni = nc.length(); nidx < numni; nidx++)
		{
			// Get native instruction details
			NativeInstruction ni = nc.get(nidx);
			int niop = ni.operation();
			
			// Update location information?
			if (niop == NativeInstructionType.DEBUG_POINT)
			{
				nijln = ni.intArgument(0);
				nijop = ni.intArgument(1);
				nijpc = ni.intArgument(2);
			}
			
			// Change of source line?
			if (nijln != lljln)
			{
				// Get population of this line
				Integer popcount = lnpopcount.get(nijln);
				if (popcount == null)
					popcount = Integer.valueOf(1);
				lnpopcount.put(nijln, popcount + 1);
				
				// Get the line, turn tabs to spaces to save room
				String ln = (nijln > 0 && nijln <= __srclines.size() ?
					__srclines.get(nijln - 1) : "<INVALID LINE?>").
					replace('\t', ' ');
				
				// Print the line text
				__ps.printf("    L%4d%3s: %s", nijln, (popcount > 1 ?
					String.format("+%-2d", popcount) : "   "), ln);
				__ps.println();
				
				// Set new last line
				lljln = nijln;
			}
			
			// Change of Java instruction? Get its string form
			String jis = "";
			boolean chjpc;
			if ((chjpc = (nijpc != lljpc)))
			{
				// Which string to put here?
				Object jstr = (bc.isValidAddress(nijpc) ?
					bc.getByAddress(nijpc) :
					InstructionMnemonics.toString(nijop));
				
				// Get form
				jis = String.format("J@%3d: %s", nijpc, jstr);
				
				// Set new last address
				lljpc = nijpc;
			}
			
			// Get native instruction form
			String nis = String.format("N@%3d: %s",
				nidx, ni);
			
			// Get string lengths
			int nisl = nis.length(),
				jisl = jis.length();
			
			// Determine row count
			int nirl = Math.max(1, (nisl + COLUMN_SIZE) / COLUMN_SIZE),
				jirl = Math.max(1, (jisl + COLUMN_SIZE) / COLUMN_SIZE),
				mxrl = Math.max(nirl, jirl);
			
			// Print all rows
			for (int i = 0; i < mxrl; i++)
			{
				// Print indent space
				__ps.print("    ");
				
				// New line or continuation?
				__ps.print((i == 0 ? '>' : ' '));
				
				// Determine fragment start and ends
				int nfs = Math.min(nisl, COLUMN_SIZE * i),
					nfe = Math.min(nisl, nfs + COLUMN_SIZE),
					jfs = Math.min(jisl, COLUMN_SIZE * i),
					jfe = Math.min(jisl, jfs + COLUMN_SIZE);
				
				// Print native fragment
				sb.setLength(0);
				sb.append(nis.substring(nfs, nfe));
				while (sb.length() < COLUMN_SIZE)
					sb.append(' ');
				__ps.print(sb);
				
				// Print left splitter
				__ps.print((i == 0 ? '<' : ' '));
				
				// Splitter if a start match
				__ps.print((i == 0 && chjpc ? '=' : '|'));
				
				// Print right splitter?
				__ps.print((chjpc ? '>' : ' '));
				
				// Print Java fragment
				sb.setLength(0);
				sb.append(jis.substring(jfs, jfe));
				while (sb.length() < COLUMN_SIZE)
					sb.append(' ');
				__ps.print(sb);
				
				// New line or continuation?
				__ps.print((chjpc ? '<' : ' '));
				
				// End line
				__ps.println();
			}
		}
		
		// Spacing
		__ps.println();
	}
	
	/**
	 * Main entry points.
	 *
	 * @param __args Arguments.
	 * @throws Throwable On any exception.
	 * @since 2019/06/12
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// Must exist
		if (__args == null)
			__args = new String[0];
		
		// Load project manager
		ProjectManager pm = ProjectManager.fromArguments(__args);
		
		// Get source and binary manager
		SourceManager sm = pm.sourceManager(TimeSpaceType.BUILD);
		BinaryManager bm = pm.binaryManager(TimeSpaceType.BUILD);
		
		// Get project to look in
		SourceName projectname = new SourceName(
			(__args.length > 0 ? __args[0] : "cldc-compact"));
		
		// Get the source code for line lookup
		Source psrc;
		try
		{
			psrc = sm.get(projectname);
		}
		catch (NoSuchSourceException e)
		{
			psrc = null;
		}
		
		// Get up to date binary
		if (psrc != null)
			bm.compile(bm.get(projectname));
		Binary pbin = bm.get(projectname);
		
		// Get the class we want to look at, make sure dots are slashes!
		String wantclass = (__args.length > 1 ? __args[1] :
			"java/lang/Object").replace('.', '/');
		
		// Load the class file itself
		ClassFile classfile;
		try (CompilerPathSet cps = pbin.pathSet())
		{
			// Open source for parsing
			try (InputStream in = cps.input(wantclass + ".class").open())
			{
				classfile = ClassFile.decode(in);
			}
		}
		
		// Source file line information
		List<String> lines = new ArrayList<>();
		
		// If a source file is set, read all of it!
		String sfn = classfile.sourceFile();
		if (psrc != null && sfn != null)
			try (CompilerPathSet cps = psrc.pathSet(SourcePathSetType.SOURCE))
			{
				// Read
				try (BufferedReader br =
					new BufferedReader(new InputStreamReader(
						cps.input(wantclass + ".java").open())))
				{
					// Debug
					System.err.println("Reading lines...");
					
					// Note
					for (;;)
					{
						String ln = br.readLine();
						
						if (ln == null)
							break;
						
						// Add line
						lines.add(ln);
					}
					
					// Debug
					System.err.printf("Read %d lines!%n", lines.size());
				}
			}
			catch (NoSuchInputException e)
			{
				// Ignore
			}
		
		// Want a specific method by name?
		String onemethod = (__args.length > 2 ? __args[2] : "");
		if (onemethod.isEmpty())
			onemethod = null;
		
		// Scan through methods
		for (Method m : classfile.methods())
		{
			// Ignore abstracts/native
			if (m.flags().isAbstract() || m.flags().isNative())
				continue;
			
			// Wanted just one method and it did not match?
			if (onemethod != null && !m.name().toString().equals(onemethod))
				continue;
			
			// Dump it
			Main.dump(System.out, lines, m);
		}
	}
}

Deleted bldt/mids/sxs/dev/shadowtail/sxs/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the side by side debug stuff.
 *
 * @since 2019/06/12
 */

package dev.shadowtail.sxs;

Deleted bldt/mids/txt-to-pbm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: a0ad1c6a-7826-4f5e-b1f0-e252d9c8dbab
X-SquirrelJME-Error: BN
X-SquirrelJME-Name: txt-to-pbm
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: txt-to-pbm
X-SquirrelJME-Depends: midp-lcdui
Microedition-Configuration: CLDC-1.8
Main-Class: dev.shadowtail.txttopbm.Main

Deleted bldt/mids/txt-to-pbm/dev/shadowtail/txttopbm/Main.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
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
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.txttopbm;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;

/**
 * This class is used to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments.
	 * @since 2019/06/15
	 */
	public static final void main(String... __args)
		throws Throwable
	{
		// Read in strings, find maximum length
		int maxstrlen = 0,
			numlines = 0;
		Deque<String> lines = new LinkedList<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
			Files.newInputStream(Paths.get(__args[0]),
			StandardOpenOption.READ))))
		{
			for (;;)
			{
				String ln = br.readLine();
				
				if (ln == null)
					break;
				
				// Add line
				lines.add(ln);
				numlines++;
				
				// Maximum line size
				int strlen = ln.length();
				if (strlen > maxstrlen)
					maxstrlen = strlen;
			}
		}
		
		// Write output graphics file, line by line!
		try (PrintStream ps = new PrintStream(System.out))
		{
			// Get a large monospace font which is easy to read hopefully
			Font font = Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_LARGE);
			
			// Get the size properties of the font
			int fw = (font.charWidth('a') + font.charWidth('w')) >> 1,
				fh = font.getHeight();
				
			// Calculate size of image, width is rounded to 8 because of
			// the pixel packing!
			int iw = ((maxstrlen * fw) + 7) & (~7),
				ih = numlines * fh,
				sa = iw * fh,
				ua = sa / 8;
			
			// Write PBM header, use P4 format
			ps.printf("P4\n");
			ps.printf("%d %d\n", iw, ih);
			
			// Create image to contain a buffer for a single line, it is not
			// important to have an entire image because we can just pipe
			// this out!
			Image image = Image.createImage(iw, fh);
			Graphics g = image.getGraphics();
			
			// Use the monospace font!
			g.setFont(font);
			
			// RGB pixel output for lines
			int[] rgb = new int[sa];
			
			// Bulk byte data, for the fastest possible writing
			byte[] bulk = new byte[ua];
			
			// Used to keep track of the current column since PBM cannot exceed
			// 72 characters
			int col = 1;
			
			// Process each line!
			while (!lines.isEmpty())
			{
				// Read in line
				String ln = lines.removeFirst();
				
				// Clear background with white
				g.setColor(0xFFFFFF);
				g.fillRect(0, 0, iw, fh);
				
				// Draw text in black
				g.setColor(0x000000);
				g.drawString(ln, 0, 0, Graphics.TOP | Graphics.LEFT);
				
				// Get RGB pixel data
				image.getRGB(rgb, 0, iw, 0, 0, iw, fh);
				
				// Go through pixels and export to bulk format
				for (int i = 0, o = 0; i < sa; i += 8, o++)
					bulk[o] = (byte)(((rgb[i + 0] & 1) << 7) |
						((rgb[i + 1] & 1) << 6) |
						((rgb[i + 2] & 1) << 5) |
						((rgb[i + 3] & 1) << 4) |
						((rgb[i + 4] & 1) << 3) |
						((rgb[i + 5] & 1) << 2) |
						((rgb[i + 6] & 1) << 1) |
						((rgb[i + 7] & 1)));
				
				// Write all bytes at once
				ps.write(bulk);
			}
		}
	}
}

Deleted bldt/mids/txt-to-pbm/dev/shadowtail/txttopbm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the utility to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */

package dev.shadowtail.txttopbm;

Deleted bldt/mids/vm-build/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 82dcdfbb-27da-48a6-87f7-7a0a8810360f
X-SquirrelJME-Error: BA
X-SquirrelJME-Name: Virtual Machine on the Build System
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: builder-support
X-SquirrelJME-Description: This project is for compatibility purposes only 
 as the VM on top of the build system has been moved into the build 
 system.
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: cc.squirreljme.build.vm.Main

Deleted bldt/mids/vm-build/cc/squirreljme/build/vm/Main.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

































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

package cc.squirreljme.build.vm;

import cc.squirreljme.builder.support.vm.VMMain;

/**
 * Compatibility entry point.
 *
 * @since 2018/12/22
 */
public class Main
{
	/**
	 * Compatible entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/12/22
	 */
	public static void main(String... __args)
	{
		VMMain.main(__args);
	}
}

Deleted bldt/mids/vm-build/cc/squirreljme/build/vm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * Compatibility package for the VM system.
 *
 * @since 2018/12/22
 */

package cc.squirreljme.build.vm;

Deleted build.cmd.

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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@ECHO OFF
REM ---------------------------------------------------------------------------
REM Multi-Phasic Applications: SquirrelJME
REM     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
REM     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
REM ---------------------------------------------------------------------------
REM SquirrelJME is under the GNU General Public License v3, or later.
REM See license.mkd for licensing and copyright information.
REM ---------------------------------------------------------------------------
REM DESCRIPTION: Builds whatever is needed to support the builder and then
REM invokes it using the host virtual machine.

REM Location of EXE file (for out of tree builds)
SET __EXEDIR=%~dp0

REM Do NOT give any variable assignments to the calling shell
setlocal
setlocal enableextensions

REM reset error level
SET ERRORLEVEL=
cmd /c "EXIT /b 0"

REM Set some variables
IF NOT DEFINED JAVA SET JAVA=java
IF NOT DEFINED JAVAC SET JAVAC=javac
IF NOT DEFINED BOOTSTRAP_CLASS SET BOOTSTRAP_CLASS=NewBootstrap

REM Make sure commands exist (try to call them)
%JAVA% -version 2> NUL > NUL
IF %ERRORLEVEL% NEQ 0 (
	ECHO The java command is missing, please SET %%JAVA%%.
	EXIT /b 2
)

%JAVAC% -version 2> NUL > NUL
IF %ERRORLEVEL% NEQ 0 (
	ECHO The javac command is missing, please SET %%JAVAC%%.
	EXIT /b 3
)

REM If the build system class does NOT exist, compile it
SET __HB_VCLS=%BOOTSTRAP_CLASS%.class
SET __HB_VSRC=%__EXEDIR%\utils-dev\boot\%BOOTSTRAP_CLASS%.java
IF NOT EXIST %__HB_VCLS% (
	ECHO Compiling the build system...
	%JAVAC% -source 1.7 -target 1.7 -d . %__EXEDIR%\utils-dev\boot\*.java
	IF %ERRORLEVEL% NEQ 0 (
		ECHO Failed to compile the build system.
		EXIT /b 4
	)
)

REM Execute Java
%JAVA% -Dproject.root=%__EXEDIR% ^
	-Dcc.squirreljme.bootstrap.binary=. ^
	-Dcc.squirreljme.builder.root=%__EXEDIR% ^
	%BOOTSTRAP_CLASS% %*

REM Failed to build the bootstrap (stage 1)
IF %ERRORLEVEL% NEQ 0 (
	ECHO Failed to build the build system.
	EXIT /b %ERRORLEVEL%
)

REM Execute Java, since Proxy interfaces are a mess, a double invocation of
REM the JVM is performed.
%JAVA% -Dproject.root=%__EXEDIR% ^
	-Dcc.squirreljme.bootstrap.binary=. ^
	-Dcc.squirreljme.builder.root=%__EXEDIR% ^
	-Dcc.squirreljme.runtime.javase.java=%JAVA% ^
	-Dcc.squirreljme.runtime.javase.bootpath=sjmeboot.jar ^
	-Dcc.squirreljme.home=home ^
	-jar sjmeboot.jar %*

REM Failed?
EXIT /b %ERRORLEVEL%

Added build.gradle.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
group = "cc.squirreljme"
description = "SquirrelJME is a Java ME 8 Virtual Machine for embedded " +
	"and Internet of Things devices. It has the ultimate goal of being " +
	"99.9% compatible with the Java ME standard."
version = "0.3.0"

// Virtual machine version ID
ext.squirreljmeVMVersion = "03"

allprojects
{
	repositories
	{
		mavenCentral()
		jcenter()
	}
}

Deleted build.sh.

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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Builds whatever is needed to support hairball and then invokes
# it using the host virtual machine.

# Force C locale
export LC_ALL=C

# Common directories
__exedir="$(dirname -- "$0")"
__tmpdir="$("$__exedir/utils-dev/tmpdir.sh")"

# Default compilers and run-times
: ${JAVA:="$__exedir/utils-dev/java.sh"}
: ${JAVAC:="$__exedir/utils-dev/javac.sh"}

# The class to use for bootstrapping
: ${BOOTSTRAP_CLASS:=NewBootstrap}

# Bootstrap source file
__bootdir="$__exedir/utils-dev/boot"
__bootsrc="$__bootdir/$BOOTSTRAP_CLASS.java"

# If the Java compiler was not detected, try ECJ instead
if ! which "$JAVAC" > /dev/null
then
	__ecj="$(which ecj 2> /dev/null)"
	if [ "$__ecj" != "" ]
	then
		JAVAC="$__ecj"
	fi
fi

# The build class is missing or out of date?
if [ ! -f "$BOOTSTRAP_CLASS.class" ] || \
	[ "$__bootsrc" -nt "$BOOTSTRAP_CLASS.class" ]
then
	# Clear potential old stuff
	rm -f "$BOOTSTRAP_CLASS.class" "$BOOTSTRAP_CLASS\$"*".class"
	
	# Build it
	echo "Building the build system..." 1>&2
	if ! "$JAVAC" -source 1.7 -target 1.7 -d . \
		"$__bootdir/"*.java
	then
		echo "Failed to build the build system." 1>&2
		exit 1
	fi
fi

# JamVM on older Debian versions has trouble when tools.jar is dynamically
# loaded, it cannot find the resources JAR.
__flaw="$("$JAVA" $JAVA_OPTIONS "$BOOTSTRAP_CLASS" "--toolsflaw" |
	grep '\.jar$' | head -n 1)"

# No flaw was detected, operate normally
if [ -z "$__flaw" ]
then
	__cpflaw="."
	__bsflaw="sjmeboot.jar"

# Otherwise use the library which was found
else
	__cpflaw=".:$__flaw"
	__bsflaw="$__flaw:sjmeboot.jar"
	
	# Add a note that the flaw is being worked around
	echo "Working around tools.jar flaw ($__flaw)." 1>&2
fi

# Run it once to build the bootstrap
if ! "$JAVA" $JAVA_OPTIONS \
	"-Dcc.squirreljme.bootstrap.binary=$(pwd)" \
	"-Dcc.squirreljme.builder.root=$__exedir" \
	-classpath "$__cpflaw" "$BOOTSTRAP_CLASS" "$@"
then
	exit 1
fi

# Run it again to run the bootstrap
if ! "$JAVA" $JAVA_OPTIONS \
	"-Dcc.squirreljme.bootstrap.binary=$(pwd)" \
	"-Dcc.squirreljme.builder.root=$__exedir" \
	"-Dcc.squirreljme.runtime.javase.java=$JAVA" \
	"-Dcc.squirreljme.runtime.javase.bootpath=sjmeboot.jar" \
	"-Dcc.squirreljme.home=home" \
	-classpath "$__bsflaw" \
	"cc.squirreljme.runtime.javase.Main" "$@"
then
	exit 1
fi

Added buildSrc/build.gradle.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
plugins
{
	id 'java'
}

dependencies
{
	implementation gradleApi()
	implementation localGroovy()
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/ErrorCodeManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.plugin;

import java.io.PrintStream;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import org.gradle.api.Project;

/**
 * This is used to manage the list of errors and otherwise.
 *
 * @since 2020/02/22
 */
public final class ErrorCodeManager
{
	/** The project for discovery. */
	protected final Project project;
	
	/** The mapping of error codes to projects. */
	private final Map<String, Project> _codeMap =
		new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
	
	/** Unclaimed error codes. */
	private final SortedSet<String> _unclaimed =
		new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
	
	/**
	 * Initializes the error code manager.
	 *
	 * @param __project The root project to manage.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public ErrorCodeManager(Project __project)
		throws NullPointerException
	{
		if (__project == null)
			throw new NullPointerException("No project.");
		
		this.project = __project.getRootProject();
		
		// Add all unclaimed codes
		Set<String> unclaimed = this._unclaimed;
		for (char a = 'A'; a <= 'Z'; a++)
			for (char b = 'A'; b <= 'Z'; b++)
				unclaimed.add(a + "" + b);
	}
	
	/**
	 * Returns an error list manager for the given code ID.
	 *
	 * @param __code The code to get.
	 * @return The error list manager.
	 * @since 2020/02/22
	 */
	public final ErrorListManager errorList(String __code)
	{
		return new ErrorListManager(this.projectByCode(__code));
	}
	
	/**
	 * Returns the next available error code.
	 *
	 * @return The next available error code.
	 * @since 2020/02/22
	 */
	public final String next()
	{
		this.__init();
		
		synchronized (this)
		{
			return this._unclaimed.first();
		}
	}
	
	/**
	 * Prints the error codes to the given stream.
	 *
	 * @param __out The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public final void print(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("No output stream.");
		
		this.__init();
		
		// Print out every project
		Map<String, Project> codeMap = this._codeMap;
		synchronized (this)
		{
			for (Map.Entry<String, Project> e : codeMap.entrySet())
				__out.printf("%2s: %s%n", e.getKey(), e.getValue().getName());
		}
	}
	
	/**
	 * Returns the project which owns the given code.
	 *
	 * @param __code The code to obtain.
	 * @throws NoSuchElementException If no such project exists.
	 * @return The resulting
	 */
	public final Project projectByCode(String __code)
		throws NoSuchElementException
	{
		this.__init();
		
		// Search
		Map<String, Project> codeMap = this._codeMap;
		synchronized (this)
		{
			Project rv = codeMap.get(__code);
			if (rv == null)
				throw new IllegalArgumentException(
					String.format("No project for code %s", __code));
			
			return rv;
		}
	}
	
	/**
	 * Initializes the code map.
	 *
	 * @since 2020/02/22
	 */
	private void __init()
	{
		Map<String, Project> codeMap = this._codeMap;
		Set<String> unclaimed = this._unclaimed;
		synchronized (this)
		{
			// Already has been loaded?
			if (!codeMap.isEmpty())
				return;
			
			// Add all projects found to the list
			for (Project sub : this.project.getAllprojects())
			{
				// Only choose SquirrelJME projects
				SquirrelJMEPluginConfiguration config = sub.getExtensions()
					.<SquirrelJMEPluginConfiguration>findByType(
						SquirrelJMEPluginConfiguration.class);
				if (config == null)
					continue;
				
				String code = config.javaDocErrorCode;
				if (code == null)
					throw new IllegalStateException(String.format(
						"Project %s has no error code.", sub.getName()));
				
				Project dup = codeMap.put(code.toUpperCase(), sub);
				if (dup != null)
					throw new IllegalStateException(String.format(
						"Project %s shares error code %s with %s.",
						sub.getName(), code, dup.getName()));
				
				unclaimed.remove(code.toUpperCase());
			}
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/ErrorListManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.plugin;

import cc.squirreljme.plugin.util.CommentReader;
import cc.squirreljme.plugin.util.ErrorListTokenizer;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import java.util.TreeMap;
import org.gradle.api.Project;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;

/**
 * This is used to get the error lists from a project.
 *
 * @since 2020/02/22
 */
public final class ErrorListManager
{
	
	/** The project to manage the list for. */
	protected final Project project;
	
	/** The listed errors. */
	private final Map<Integer, SourceError> _errors =
		new TreeMap<>();
	
	/** The error code for this project. */
	private String _projectErrorCode;
	
	/**
	 * Initializes the error code manager.
	 *
	 * @param __project The project to manage.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public ErrorListManager(Project __project)
		throws NullPointerException
	{
		if (__project == null)
			throw new NullPointerException("No project.");
		
		this.project = __project;
	}
	
	/**
	 * Returns the next available error.
	 *
	 * @return The next available error.
	 * @since 2020/02/22
	 */
	public final String next()
	{
		this.__init();
		
		return this._projectErrorCode +
			SourceError.indexToString(this.nextIndex());
	}
	
	/**
	 * Returns the next available error.
	 *
	 * @return The next available error.
	 * @since 2020/02/22
	 */
	public final int nextIndex()
	{
		this.__init();
		
		Map<Integer, SourceError> errors = this._errors;
		synchronized (this)
		{
			for (int i = 1; i <= SourceError._MAX_ERROR_CODE; i++)
				if (!errors.containsKey(i))
					return i;
			
			throw new IllegalArgumentException("Ran out of error indexes.");
		}
	}
	
	/**
	 * Prints the errors to the given stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public final void print(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("No stream specified.");
		
		this.__init();
		
		synchronized (this)
		{
			for (SourceError e : this._errors.values())
				__out.println(e);
		}
	}
	
	/**
	 * Initializes the code map.
	 *
	 * @since 2020/02/22
	 */
	private void __init()
	{
		Project project = this.project;
		Map<Integer, SourceError> errors = this._errors;
		
		synchronized (this)
		{
			// Already loaded?
			if (this._projectErrorCode != null)
				return;
			
			// This must exist
			SquirrelJMEPluginConfiguration config = project.getExtensions()
				.<SquirrelJMEPluginConfiguration>getByType(
					SquirrelJMEPluginConfiguration.class);
			
			// Fail if this is missing
			String projectErrorCode = config.javaDocErrorCode;
			if (projectErrorCode == null)
				throw new IllegalStateException(String.format(
					"Project %s has no error code.", project.getName()));
			
			// Used as a flag and to indicate the group for this
			this._projectErrorCode = projectErrorCode;
			
			// Temporary buffer for data reading
			StringBuilder buffer = new StringBuilder();
			
			// Get source code
			FileTree sources = project.getConvention()
				.getPlugin(JavaPluginConvention.class).getSourceSets()
				.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getAllJava()
				.getAsFileTree();
			
			// Parse source code
			for (File source : sources)
				try (InputStream in = Files.newInputStream(source.toPath(),
					StandardOpenOption.READ);
					ErrorListTokenizer tokenizer = new ErrorListTokenizer(
						source.toPath().getFileName(),
						new CommentReader(in)))
				{
					// Keep reading in errors
					for (;;)
					{
						// Read the next error
						SourceError error = tokenizer.next();
						if (error == null)
							break;
						
						// Store error in the map
						SourceError old = errors.put(error.index, error);
						
						// Check duplicate
						if (old != null)
							System.err.printf("Duplicate error %s and %s.%n",
								error, old);
						
						// Wrong project
						if (!error.projectCode.equals(projectErrorCode))
							System.err.printf("Error has wrong project: %s," +
								"should be: %s%n", error, projectErrorCode);
					}
				}
				catch (IOException e)
				{
					throw new RuntimeException("Could not decode file.", e);
				}
		}
	}
	
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/SourceError.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.plugin;

import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.List;

/**
 * A single error that exists in source code.
 *
 * @since 2020/02/22
 */
public final class SourceError
{
	/** The maximum error code index that can exist. */
	static final int _MAX_ERROR_CODE =
		Character.MAX_RADIX * Character.MAX_RADIX;
	
	/** The code for the project. */
	public final String projectCode;
	
	/** The error index. */
	public final int index;
	
	/** The body of the error. */
	public final String body;
	
	/** Extra parameters. */
	public final List<String> parameters;
	
	/** Where is this located? */
	public final Path where;
	
	/**
	 * Decodes the content to tag information.
	 *
	 * @param __content The content to decode.
	 * @param __where Where the file is located.
	 * @throws IllegalArgumentException If the content is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public SourceError(Iterable<String> __content, Path __where)
		throws IllegalArgumentException, NullPointerException
	{
		if (__content == null)
			throw new NullPointerException();
		
		// Set file location
		this.where = __where;
		
		// Put items into the queue
		Deque<String> queue = new ArrayDeque<String>();
		for (String item : __content)
			queue.add(item);
		
		// Read the error code
		String errorCode = queue.pollFirst();
		if (errorCode == null)
			throw new IllegalArgumentException("No error code.");
		
		if (errorCode.length() < 4)
			throw new IllegalArgumentException("Error code too short.");
		
		// Project code is the first two characters
		this.projectCode = errorCode.substring(0, 2).toUpperCase();
		this.index = SourceError.stringToIndex(errorCode.substring(2, 4));
		
		// Fill in content description
		StringBuilder body = new StringBuilder();
		while (!queue.isEmpty())
		{
			// Stop when nothing is left, or if there are starting parameters
			String item = queue.peekFirst();
			if (item == null || item.equals("("))
				break;
			
			// Add formatting space
			if (body.length() > 0)
				body.append(' ');
			
			// And append whatever we put in
			body.append(queue.removeFirst());
		}
		
		// Store body in
		this.body = body.toString();
		
		// Parameter list?
		List<String> parameters = new ArrayList<String>();
		if ("(".equals(queue.peekFirst()))
		{
			// Process queue
			StringBuilder buffer = new StringBuilder();
			while (!queue.isEmpty())
			{
				String item = queue.peekFirst();
				
				// End parameter or next?
				boolean isEnd = (item == null || item.equals(")"));
				if (isEnd || item.equals(";"))
				{
					// Consume it
					queue.pollFirst();
					
					// Store into parameter list?
					if (buffer.length() > 0)
					{
						parameters.add(buffer.toString());
						buffer.setLength(0);
					}
					
					// End here?
					if (isEnd)
						break;
				}
				
				// Add formatting space
				if (buffer.length() > 0)
					buffer.append(' ');
				
				// And append whatever we put in
				buffer.append(queue.removeFirst());
			}
		}
		
		// Store parameters
		this.parameters = Collections.<String>unmodifiableList(parameters);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/22
	 */
	@Override
	public final String toString()
	{
		StringBuilder sb = new StringBuilder();
		
		// Code index
		sb.append(this.projectCode);
		sb.append(SourceError.indexToString(this.index));
		sb.append(": ");
		
		// Content
		sb.append(this.body);
		
		List<String> parameters = this.parameters;
		if (!parameters.isEmpty())
		{
			sb.append(" (");
			
			for (int i = 0, n = parameters.size(); i < n; i++)
			{
				if (i > 0)
					sb.append("; ");
				
				sb.append(parameters.get(0));
			}
			
			sb.append(")");
		}
		
		// Place location of this file
		Path where = this.where;
		if (where != null)
		{
			sb.append(" <");
			sb.append(where);
			sb.append(">");
		}
		
		return sb.toString();
	}
	
	/**
	 * Returns string form of the given index.
	 *
	 * @param __index The index to translate.
	 * @return The translated string to index.
	 * @since 2020/02/22
	 */
	public static String indexToString(int __index)
	{
		StringBuilder sb = new StringBuilder();
		
		sb.append(Character.toUpperCase(Character.forDigit(
			__index / Character.MAX_RADIX, Character.MAX_RADIX)));
		sb.append(Character.toUpperCase(Character.forDigit(
			__index % Character.MAX_RADIX, Character.MAX_RADIX)));
		
		return sb.toString();
	}
	
	/**
	 * Returns the index for the given string.
	 *
	 * @return The resulting index.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public static int stringToIndex(String __string)
		throws IllegalArgumentException, NullPointerException
	{
		if (__string == null)
			throw new NullPointerException("No string specified.");
		
		if (__string.length() != 2)
			throw new IllegalArgumentException("Invalid string length.");
		
		int rv = (Character.digit(__string.charAt(0), Character.MAX_RADIX) *
			Character.MAX_RADIX) +
			Character.digit(__string.charAt(1), Character.MAX_RADIX);
		
		if (rv < 0 || rv > SourceError._MAX_ERROR_CODE)
			throw new IllegalArgumentException("Out of range index.");
		
		return rv;
	}
}

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

package cc.squirreljme.plugin;

import cc.squirreljme.plugin.tasks.AdditionalManifestPropertiesTask;
import cc.squirreljme.plugin.tasks.GenerateTestsListTask;
import cc.squirreljme.plugin.tasks.MimeDecodeResourcesTask;
import cc.squirreljme.plugin.tasks.RunEmulatedTask;
import cc.squirreljme.plugin.tasks.RunNativeTask;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.SourceSet;

/**
 * Plugin for all SquirrelJME operations that are needed in Gradle in order
 * to provide the correct functionality.
 *
 * @since 2020/02/15
 */
public class SquirrelJMEPlugin
	implements Plugin<Project>
{
	/**
	 * {@inheritDoc}
	 * @since 2020/02/15
	 */
	@Override
	public void apply(Project __project)
	{
		// Add configuration for SquirrelJME
		__project.getExtensions().<SquirrelJMEPluginConfiguration>create(
			"squirreljme", SquirrelJMEPluginConfiguration.class,
			this, __project);
		
		// Resource processing tasks
		Task processResources = __project.getTasks().
			getByName("processResources");
		Task processTestResources = __project.getTasks().
			getByName("processTestResources");
		
		// JAR Tasks
		Task jarTask = __project.getTasks().getByName("jar");
		
		// Run native application
		Task rna = __project.getTasks().create("runNative",
			RunNativeTask.class, jarTask);
		
		// Run emulated program
		Task esp = __project.getTasks().create("runSpringCoat",
			RunEmulatedTask.class,
			jarTask, "springcoat", false);
		Task esu = __project.getTasks().create("runSummerCoat",
			RunEmulatedTask.class,
			jarTask, "summercoat", false);
		
		// Mime Decode Resources
		Task mmr = __project.getTasks().create("mimeDecodeResources",
			MimeDecodeResourcesTask.class, SourceSet.MAIN_SOURCE_SET_NAME,
			processResources);
		Task tmr = __project.getTasks().create("mimeDecodeTestResources",
			MimeDecodeResourcesTask.class, SourceSet.TEST_SOURCE_SET_NAME,
			processTestResources);
		
		// Generate the list of tests that are available
		Task gtl = __project.getTasks().create("generateTestsList",
			GenerateTestsListTask.class, processTestResources);
		
		// Add SquirrelJME properties to the manifest
		Task sjp = __project.getTasks().create("additionalJarProperties",
			AdditionalManifestPropertiesTask.class, jarTask, processResources);
		
		// List error codes used by projects
		Task listErrorCodes = __project.getTasks()
			.create("listErrorCodes");
		listErrorCodes.setGroup("squirreljme");
		listErrorCodes.setDescription("Lists error code prefixes.");
		listErrorCodes.doLast((Task __task) ->
			new ErrorCodeManager(__project.getRootProject())
				.print(System.out));
		
		// Determine the next error code that is available
		Task nextErrorCode = __project.getTasks()
			.create("nextErrorCode");
		nextErrorCode.setGroup("squirreljme");
		nextErrorCode.setDescription("Returns the next free error code.");
		nextErrorCode.doLast((Task __task) ->
			System.out.println(new ErrorCodeManager(__project.getRootProject())
				.next()));
		
		// List errors in single project
		Task listErrors = __project.getTasks()
			.create("listErrors");
		listErrors.setGroup("squirreljme");
		listErrors.setDescription("Lists all of the source error codes.");
		listErrors.doLast((Task __task) ->
			new ErrorListManager(__project).print(System.out));
		
		// Returns the next available error in single project
		Task nextError = __project.getTasks()
			.create("nextError");
		nextError.setGroup("squirreljme");
		nextError.setDescription("Returns the next free error code.");
		nextError.doLast((Task __task) ->
			System.out.println(new ErrorListManager(__project).next()));
	}
}

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

package cc.squirreljme.plugin;

import cc.squirreljme.plugin.swm.JavaMEConfiguration;
import cc.squirreljme.plugin.swm.JavaMEMidlet;
import cc.squirreljme.plugin.swm.JavaMEMidletType;
import cc.squirreljme.plugin.swm.JavaMEProfile;
import cc.squirreljme.plugin.swm.JavaMEStandard;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.gradle.api.Project;

/**
 * Allows SquirrelJME specific parts of modules to be configured.
 *
 * @since 2020/02/15
 */
public class SquirrelJMEPluginConfiguration
{
	/** The current plugin. */
	public SquirrelJMEPlugin currentPlugin;
	
	/** The current project. */
	public Project currentProject;
	
	/** The JavaDoc Error Code. */
	public String javaDocErrorCode;
	
	/** The type of program this is. */
	public JavaMEMidletType swmType =
		JavaMEMidletType.APPLICATION;
	
	/** The name of the MIDlet or LIBlet. */
	public String swmName;
	
	/** The vendor of the MIDlet or LIBlet. */
	public String swmVendor;
	
	/** Ignore in the launcher? */
	public boolean ignoreInLauncher;
	
	/** The configurations this defines. */
	public Set<JavaMEConfiguration> definedConfigurations =
		new LinkedHashSet<>();
	
	/** The profiles this defines. */
	public Set<JavaMEProfile> definedProfiles =
		new LinkedHashSet<>();
	
	/** The standards defined. */
	public Set<JavaMEStandard> definedStandards =
		new LinkedHashSet<>();
	
	/** The main class entry point (optional). */
	public String mainClass;
	
	/** MIDlets that are available for entry. */
	public List<JavaMEMidlet> midlets =
		new ArrayList<>();
	
	/**
	 * Initializes the configuration with the contained project.
	 *
	 * @param __plugin The current plugin.
	 * @param __project The project to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/15
	 */
	public SquirrelJMEPluginConfiguration(SquirrelJMEPlugin __plugin,
		Project __project)
		throws NullPointerException
	{
		if (__plugin == null || __project == null)
			throw new NullPointerException("NARG");
		
		this.currentPlugin = __plugin;
		this.currentProject = __project;
	}
	
	/**
	 * Gets the configuration from the given project.
	 *
	 * @param __proj The project to get the config from.
	 * @return The resulting configuration.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	public static SquirrelJMEPluginConfiguration configuration(Project __proj)
		throws NullPointerException
	{
		if (__proj == null)
			throw new NullPointerException("No project specified.");
			
		// Find our config
		return __proj.getExtensions()
			.<SquirrelJMEPluginConfiguration>getByType(
				SquirrelJMEPluginConfiguration.class);
	}
	
	/**
	 * Is this a SquirrelJME application?
	 *
	 * @param __project The project to check.
	 * @return If it is an application.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/16
	 */
	public static boolean isApplication(Project __project)
		throws NullPointerException
	{
		return SquirrelJMEPluginConfiguration.configuration(__project).swmType ==
			JavaMEMidletType.APPLICATION;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/PalmDatabaseAttribute.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.palmos;

/**
 * This represents an attribute for the Palm Database.
 *
 * @since 2019/07/13
 */
public enum PalmDatabaseAttribute
{
	/** This is a resource database. */
	RESOURCE_DATABASE(0x0001),
	
	/** Read-only. */
	READ_ONLY(0x0002),
	
	/** Info block is dirty. */
	APP_INFO_DIRTY(0x0004),
	
	/** Database should be packed up to the PC. */
	BACKUP(0x0008),
	
	/** Is okay to install newer version? */
	OK_TO_INSTALL_NEWER(0x0010),
	
	/** Requires a reset after install. */
	RESET_AFTER_INSTALL(0x0020),
	
	/** Copy protection (prevent beaming/copy). */
	COPY_PROTECTION(0x0040),
	
	/** Used as a file stream. */
	STREAM(0x0080),
	
	/** Is hidden. */
	HIDDEN(0x0100),
	
	/** Is a data resource which can be launched. */
	LAUNCHABLE_DATA(0x0200),
	
	/** The database can be recycled. */
	RECYCLABLE(0x0400),
	
	/** Is a bundle, always beam with the same creator type. */
	BUNDLE(0x0800),
	
	/** Database is open and has not been closed properly. */
	OPEN(0x8000),
	
	/** End. */
	;
	
	/** The bit used. */
	public final int bit;
	
	/**
	 * Initializes the attribute.
	 *
	 * @param __bit The bit used.
	 * @since 2019/07/13
	 */
	PalmDatabaseAttribute(int __bit)
	{
		this.bit = __bit;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/PalmDatabaseBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.palmos;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * This class is used to build PalmOS databases and resource databases.
 *
 * @since 2019/07/13
 */
public final class PalmDatabaseBuilder
{
	/** The limit to the name length. */
	private static final int _NAME_LIMIT =
		32;
	
	/** Difference in the epoch in seconds. */
	private static final long _EPOCH_DIFF_SECONDS =
		2082844800L;
	
	/** Difference in the epoch in milliseconds. */
	private static final long _EPOCH_DIFF_MILLISECONDS =
		2082844800_000L;
	
	/** The type of database to create. */
	protected final PalmDatabaseType dbtype;
	
	/** Attributes within the database. */
	private final Set<PalmDatabaseAttribute> _attributes =
		new HashSet<>();
	
	/** The entries within the database. */
	private final List<PalmRecord> _records =
		new ArrayList<>();
	
	/** The creator of the database. */
	private String _creator =
		"????";
	
	/** The type of the database. */
	private String _type =
		"????";
	
	/** The name of the database. */
	private String _name =
		"Untitled";
	
	/** Creation time. */
	private long _createtime =
		System.currentTimeMillis();
	
	/** Modification time */
	private long _modtime =
		this._createtime;
	
	/** Backup time. */
	private long _backuptime =
		0;
	
	/** Modification number. */
	private int _modcount =
		0;
	
	/** The version. */
	private int _version =
		0;
	
	/**
	 * Initializes the database builder.
	 *
	 * @param __type The database type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public PalmDatabaseBuilder(PalmDatabaseType __type)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		this.dbtype = __type;
	}
	
	/**
	 * Adds the specified entry.
	 *
	 * @param __type The entry type.
	 * @param __id The ID to use.
	 * @return The stream to the entry data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final OutputStream addEntry(String __type, int __id)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		// Create a record writer to write there
		return new __RecordWriter__(__type, __id, this._records);
	}
	
	/**
	 * Sets the given attributes.
	 *
	 * @param __a The attribute to set.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setAttributes(
		PalmDatabaseAttribute... __a)
	{
		if (__a == null)
			return this;
		
		// Add the attributes
		Set<PalmDatabaseAttribute> attributes = this._attributes;
		for (PalmDatabaseAttribute attr : __a)
			if (attr != null)
				attributes.add(attr);
		
		// Return self
		return this;
	}
	
	/**
	 * Sets the backup time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setBackupTime(long __jt)
	{
		this._backuptime = __jt;
		return this;
	}
	
	/**
	 * Sets the creation time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setCreateTime(long __jt)
	{
		this._createtime = __jt;
		return this;
	}
	
	/**
	 * Sets the creator of the database.
	 *
	 * @param __creat The creator to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setCreator(String __creat)
		throws NullPointerException
	{
		if (__creat == null)
			throw new NullPointerException("NARG");
		
		this._creator = __creat;
		return this;
	}
	
	/**
	 * Sets the modification count.
	 *
	 * @param __c The count to use.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setModificationCount(int __c)
	{
		this._modcount = __c;
		return this;
	}
	
	/**
	 * Sets the modification time.
	 *
	 * @param __jt Java milliseconds time.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setModificationTime(long __jt)
	{
		this._modtime = __jt;
		return this;
	}
	
	/**
	 * Sets the name of the database.
	 *
	 * @param __name The name to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setName(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this._name = __name;
		return this;
	}
	
	/**
	 * Sets the type of the database.
	 *
	 * @param __type The type to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setType(String __type)
		throws NullPointerException
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		this._type = __type;
		return this;
	}
	
	/**
	 * Sets the version number.
	 *
	 * @param __v The version number.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setVersion(int __v)
	{
		this._version = __v;
		return this;
	}
	
	/**
	 * Returns the byte array representing the database.
	 *
	 * @return The byte array of the database.
	 * @since 2019/07/13
	 */
	public final byte[] toByteArray()
	{
		// Just write to a stream
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			// Write the database info
			this.writeTo(baos);
			
			// Return the resulting array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BP01 Could not write the database.}
		catch (IOException e)
		{
			throw new RuntimeException("BP01", e);
		}
	}
	
	/**
	 * Writes the database to the output.
	 *
	 * @param __out The output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public final void writeTo(OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// Open data output to write to
		DataOutputStream dos = new DataOutputStream(__out);
		
		// Write the name bytes
		byte[] namebytes = this._name.getBytes("utf-8");
		int namelen = namebytes.length;
		dos.write(namebytes, 0, Math.min(namelen,
			PalmDatabaseBuilder._NAME_LIMIT));
		
		// Pad shorter names
		for (int i = namelen; i < PalmDatabaseBuilder._NAME_LIMIT; i++)
			dos.write(0);
		
		// Determine attribute bit-field
		int attrs = 0;
		for (PalmDatabaseAttribute attr : this._attributes)
			attrs |= attr.bit;
		
		// Make sure the attribute flag is always correct because if it was
		// specified it would make the database not valid to be handled
		PalmDatabaseType dbtype = this.dbtype;
		boolean isrc;
		if ((isrc = (dbtype == PalmDatabaseType.RESOURCE)))
			attrs |= PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		else
			attrs &= ~PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		
		// Write attributes
		dos.writeShort(attrs);
		
		// Write version
		dos.writeShort(this._version);
		
		// Creation/Modification/Backup Time (In Mac OS epoch seconds)
		dos.writeInt(
			(int)((this._createtime + PalmDatabaseBuilder._EPOCH_DIFF_MILLISECONDS) / 1000L));
		dos.writeInt(
			(int)((this._modtime + PalmDatabaseBuilder._EPOCH_DIFF_MILLISECONDS) / 1000L));
		dos.writeInt(
			(int)((this._backuptime + PalmDatabaseBuilder._EPOCH_DIFF_MILLISECONDS) / 1000L));
		
		// Modification count
		dos.writeInt(this._modcount);
		
		// Application Info
		dos.writeInt(0);
		
		// Sorting info
		dos.writeInt(0);
		
		// Type
		dos.writeInt(PalmDatabaseBuilder.__fourToInt(this._type));
		
		// Creator
		dos.writeInt(PalmDatabaseBuilder.__fourToInt(this._creator));
		
		// Unique ID
		dos.writeInt(0);
		
		// Next record list (unused in files)
		dos.writeInt(0);
		
		// Need to work with records now
		List<PalmRecord> records = this._records;
		int numrecords = records.size();
		
		// Write record count
		dos.writeShort(numrecords);
		
		// Determine the base offset for entry data
		int offset = 78 + ((isrc ? 10 : 8) * numrecords);
		
		// Write table data for records
		for (int i = 0; i < numrecords; i++)
		{
			PalmRecord pr = records.get(i);
			
			// Resource entry
			if (isrc)
			{
				// Type
				dos.writeInt(PalmDatabaseBuilder.__fourToInt(pr.type));
				
				// ID
				dos.writeShort(pr.id);
				
				// Offset
				dos.writeInt(offset);
			}
			
			// Database entry
			else
			{
				// Offset
				dos.writeInt(offset);
				
				// No attributes
				dos.write(0);
				
				// Unique ID (padding)
				dos.write(0);
				dos.write(0);
				dos.write(0);
			}
			
			// Offset is increased by length
			offset += pr.length;
		}
		
		// Write all records
		for (int i = 0; i < numrecords; i++)
			dos.write(records.get(i)._data);
	}
	
	/**
	 * Converts a four string to an integer.
	 *
	 * @param __four The string to convert.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	private static final int __fourToInt(String __four)
		throws NullPointerException
	{
		if (__four == null)
			throw new NullPointerException("NARG");
		
		// There must be at least four characters
		String use = __four;
		if (__four.length() < 4)
		{
			StringBuilder sb = new StringBuilder();
			sb.append(__four);
			sb.setLength(4);
			use = sb.toString();
		}
		
		// Convert
		return ((__four.charAt(0) & 0xFF) << 24) |
			((__four.charAt(1) & 0xFF) << 16) |
			((__four.charAt(2) & 0xFF) << 8) |
			((__four.charAt(3) & 0xFF));
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/PalmDatabaseType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.palmos;

/**
 * This represents the database type to use when creating databases.
 *
 * @since 2019/07/13
 */
public enum PalmDatabaseType
{
	/** Resource database. */
	RESOURCE,
	
	/** Record database. */
	RECORD,
	
	/** End. */
	;
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/PalmRecord.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.palmos;

/**
 * This represents a single record within a database.
 *
 * @since 2019/07/13
 */
public final class PalmRecord
{
	/** The type. */
	public final String type;
	
	/** The record ID. */
	public final int id;
	
	/** The record length. */
	public final int length;
	
	/** The data. */
	final byte[] _data;
	
	/**
	 * Initializes the Palm record.
	 *
	 * @param __type The type.
	 * @param __id The ID.
	 * @param __b The buffer.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	public PalmRecord(String __type, int __id, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__type == null || __b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.type = __type;
		this.id = __id;
		this.length = __l;
		
		// Copy and store bytes
		byte[] dest = new byte[__l];
		System.arraycopy(__b, __o, dest, 0, __l);
		this._data = dest;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/__RecordWriter__.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.palmos;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;

/**
 * This is used to write to the record data.
 *
 * @since 2019/07/13
 */
final class __RecordWriter__
	extends OutputStream
{
	/** The type used. */
	protected final String type;
	
	/** The ID used. */
	protected final int id;
	
	/** The record data. */
	private final ByteArrayOutputStream _data =
		new ByteArrayOutputStream();
	
	/** The target record collection. */
	private final Collection<PalmRecord> _target;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/**
	 * Initializes the record writer.
	 *
	 * @param __type The record type.
	 * @param __id The record ID.
	 * @param __t The target type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/13
	 */
	__RecordWriter__(String __type, int __id, Collection<PalmRecord> __t)
		throws NullPointerException
	{
		if (__type == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.id = __id;
		this._target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void close()
	{
		// Only close once
		if (this._closed)
			return;
		
		// Set as closed
		this._closed = true;
		
		// Add record information
		byte[] buf = this._data.toByteArray();
		this._target.add(new PalmRecord(this.type, this.id,
			buf, 0, buf.length));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
		
		// Forward
		this._data.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
			
		// Forward
		this._data.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/13
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Do not write when closed
		if (this._closed)
			throw new IOException("EOFF");
			
		// Forward
		this._data.write(__b, __o, __l);
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/palmos/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the base for the PalmOS utilities.
 *
 * @since 2019/07/13
 */

package cc.squirreljme.plugin.palmos;

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

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.StringUtils;

/**
 * This represents the name of an API.
 *
 * @since 2017/11/30
 */
public final class APIName
	implements Comparable<APIName>
{
	/** The name of the API. */
	protected final String string;
	
	/**
	 * Initializes the API name from the given string.
	 *
	 * @param __n The name of the API.
	 * @throws InvalidSuiteException If the suite is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public APIName(String __n)
		throws InvalidSuiteException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Force all APIs to be uppercase
		__n = StringUtils.toUpperCaseNoLocale(__n);
		
		// {@squirreljme.error DG01 An illegal character was
		// specified in the API name. (The API name)}
		if (StringUtils.firstIndex("\0\r\n:;", __n) >= 0)
			throw new InvalidSuiteException(String.format("DG01 %s", __n));
		
		// {@squirreljme.error DG02 API name cannot be blank.}
		if (__n.length() <= 0)
			throw new InvalidSuiteException("DG02");
		
		this.string = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(APIName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof APIName))
			return false;
		
		return this.string.equals(((APIName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/InternalName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

/**
 * This represents an internal project name which is used by SquirrelJME.
 *
 * @since 2017/12/31
 */
public final class InternalName
	implements MarkedProvided
{
	/** The project name. */
	protected final String name;
	
	/**
	 * Initializes the internal name.
	 *
	 * @param __n The name to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public InternalName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof InternalName))
			return false;
		
		return this.name.equals(((InternalName)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Returns the internal name.
	 *
	 * @return The internal name.
	 * @since 2017/12/31
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/InvalidSuiteException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

/**
 * This is thrown when a midlet has an invalid property or is otherwise not
 * valid.
 *
 * @since 2017/11/23
 */
public class InvalidSuiteException
	extends IllegalArgumentException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/23
	 */
	public InvalidSuiteException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(Throwable __c)
	{
		super(__c);
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/JavaMEConfiguration.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
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
191
192
193
194
195
196
197
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.StringUtils;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a configuration such as CLDC which specifies which base
 * classes are available. Configurations may optionally be "compact" in which
 * they are a lighter version.
 *
 * @since 2016/12/14
 */
public final class JavaMEConfiguration
	implements Comparable<JavaMEConfiguration>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** Is this configuration compact? */
	protected final boolean compact;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the configuration using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite.
	 * @param __c If {@code true} then the configuration is compact.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public JavaMEConfiguration(APIName __n, SuiteVersion __v, boolean __c)
		throws NullPointerException
	{
		if (__n == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __n;
		this.version = __v;
		this.compact = __c;
	}
	
	/**
	 * Initializes the configuration by parsing the given string.
	 *
	 * @param __n The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public JavaMEConfiguration(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG02 Expected two or three fields for the
		// configuration. (The input string)}
		String[] fields = StringUtils.fieldSplit('-', __n);
		int fn = fields.length;
		if (fn != 2 && fn != 3)
			throw new InvalidSuiteException(String.format("AR02 %s", __n));
		
		// Potentially compact?
		this.compact = (fn > 2 &&
			0 == fields[2].compareToIgnoreCase("compact"));
		
		// Parse name and version
		this.name = new APIName(fields[0]);
		this.version = new SuiteVersion(fields[1]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(JavaMEConfiguration __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		rv = this.version.compareTo(__o.version);
		if (rv != 0)
			return rv;
		
		// Compact is before non-compact
		boolean a = this.compact,
			b = __o.compact;
		if (a != b)
			return (a ? -1 : 1);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaMEConfiguration))
			return false;
		
		JavaMEConfiguration o = (JavaMEConfiguration)__o;
		return this.name.equals(o.name) &&
			this.version.equals(o.version) &&
			this.compact == o.compact;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version) ^
			(this.compact ? 0xFFFFFFFF : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "" +
				this.name + "-" + this.version +
				(this.compact ? "-compact" : "")));
		
		return rv;
	}
	
	/**
	 * Returns the version of this configuration.
	 *
	 * @return The configuration version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/JavaMEMidlet.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.swm;

/**
 * Defines a MIDlet that can be launched.
 *
 * @since 2020/02/15
 */
public final class JavaMEMidlet
{
	/** The title. */
	public final String title;
	
	/** The icon. */
	public final String icon;
	
	/** The main class. */
	public final String mainClass;
	
	/**
	 * Initializes the MIDlet information.
	 *
	 * @param __title The title of the MIDlet.
	 * @param __icon The icon of the MIDlet.
	 * @param __main The main class.
	 * @throws NullPointerException If no title or main class was specified.
	 * @since 2020/02/15
	 */
	public JavaMEMidlet(String __title, String __icon, String __main)
		throws NullPointerException
	{
		if (__title == null || __main == null)
			throw new NullPointerException("No title or main specified.");
		
		this.title = __title;
		this.icon = (__icon == null ? "" : __icon);
		this.mainClass = __main;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaMEMidlet))
			return false;
		
		JavaMEMidlet o = (JavaMEMidlet)__o;
		return this.title.equals(o.title) &&
			this.icon.equals(o.icon) &&
			this.mainClass.equals(o.mainClass);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/15
	 */
	@Override
	public final int hashCode()
	{
		return this.title.hashCode() ^
			this.icon.hashCode() ^
			this.mainClass.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/15
	 */
	@Override
	public final String toString()
	{
		return String.format("%s, %s, %s",
			this.title, this.icon, this.mainClass);
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/JavaMEMidletType.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.swm;

/**
 * Represents the type of MIDlet a program is.
 *
 * @since 2020/02/15
 */
public enum JavaMEMidletType
{
	/** API. */
	API,
	
	/** Library. */
	LIBRARY,
	
	/** Application. */
	APPLICATION,
	
	/* End. */
	;
	
	/**
	 * Returns the dependency key.
	 *
	 * @param __i The dependency index.
	 * @return The dependency key.
	 * @since 2020/02/28
	 */
	public final String dependencyKey(int __i)
	{
		return this.prefixKey() + "-Dependency-" + __i;
	}
	
	/**
	 * Returns the name key.
	 *
	 * @return The name key.
	 * @since 2020/02/28
	 */
	public final String nameKey()
	{
		return this.prefixKey() + "-Name";
	}
	
	/**
	 * Returns the prefix key.
	 *
	 * @return The prefix key.
	 * @since 2020/02/28
	 */
	public final String prefixKey()
	{
		switch (this)
		{
			case API:			return "X-SquirrelJME-API";
			case LIBRARY:		return "LIBlet";
			case APPLICATION:	return "MIDlet";
			
			default:
				throw new RuntimeException("Unknown project type.");
		}
	}
	
	/**
	 * Returns the vendor key.
	 *
	 * @return The vendor key.
	 * @since 2020/02/28
	 */
	public final String vendorKey()
	{
		return this.prefixKey() + "-Vendor";
	}
	
	/**
	 * Returns the version key.
	 *
	 * @return The version key.
	 * @since 2020/02/28
	 */
	public final String versionKey()
	{
		return this.prefixKey() + "-Version";
	}
}

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

package cc.squirreljme.plugin.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a profile that may be implemented, such as MIDP.
 *
 * @since 2016/12/14
 */
public final class JavaMEProfile
	implements Comparable<JavaMEProfile>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the profile using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite, this is optional.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/11/30
	 */
	public JavaMEProfile(APIName __n, SuiteVersion __v)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.version = __v;
	}
	
	/**
	 * Initializes the profile by parsing the given string.
	 *
	 * @param __n The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public JavaMEProfile(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// No version specified
		int n = __n.length(),
			dx = __n.lastIndexOf('-');
		char c;
		if (dx < 0 || dx + 1 >= n || (c = __n.charAt(dx + 1)) < '0' || c > '9')
		{
			this.name = new APIName(__n);
			this.version = null;
		}
		
		// There is a version
		else
		{
			this.name = new APIName(__n.substring(0, dx));
			this.version = new SuiteVersion(__n.substring(dx + 1));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(JavaMEProfile __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVersion a = this.version,
			b = __o.version;
		if ((a == null) != (b == null))
			return (a == null ? -1 : 1);
		else if (a != null)
			return a.compareTo(b);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaMEProfile))
			return false;
		
		JavaMEProfile o = (JavaMEProfile)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Profile " +
				this.name + ":" + this.version));
		
		return rv;
	}
	
	/**
	 * Returns the version of this profile.
	 *
	 * @return The profile version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/JavaMEStandard.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.StringUtils;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a standard which is provided by an API.
 *
 * @since 2017/12/05
 */
public final class JavaMEStandard
	implements Comparable<JavaMEStandard>, MarkedProvided
{
	/** The standard name. */
	protected final SuiteName name;
	
	/** The vendor of the standard. */
	protected final SuiteVendor vendor;
	
	/** The version of the standard. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the standard using the given fields.
	 *
	 * @param __name The name of the standard.
	 * @param __vend The vendor of the standard.
	 * @param __vers The version of the standard.
	 * @throws NullPointerException If no name was specified.
	 * @since 2020/02/28
	 */
	public JavaMEStandard(String __name, String __vend, String __vers)
		throws NullPointerException
	{
		this(new SuiteName(__name),
			(__vend == null ? null : new SuiteVendor(__vend)),
			(__vers == null ? null : new SuiteVersion(__vers)));
	}
	
	/**
	 * Initializes the standard using the given fields.
	 *
	 * @param __name The name of the standard.
	 * @param __vend The vendor of the standard.
	 * @param __vers The version of the standard.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/12/30
	 */
	public JavaMEStandard(SuiteName __name, SuiteVendor __vend,
		SuiteVersion __vers)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.vendor = __vend;
		this.version = __vers;
	}
	
	/**
	 * Decodes the standard from the specified string.
	 *
	 * @param __s The string to decode the standard from.
	 * @throws InvalidSuiteException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public JavaMEStandard(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG04 Expected input standard string to
		// contain three fields separated by semi-colon. (The input string)}
		String[] splice = StringUtils.fieldSplitAndTrim(';', __s);
		if (splice.length != 3)
			throw new InvalidSuiteException(String.format("DG04 %s", __s));
		
		// {@squirreljme.error DG05 Name in standard string is empty. (The
		// input string)}
		String name = splice[0];
		if (name.isEmpty())
			throw new InvalidSuiteException(String.format("DG05 %s", __s));
		this.name = new SuiteName(name);
		
		String vendor = splice[1];
		this.vendor = (vendor.isEmpty() ? null : new SuiteVendor(vendor));
		
		String version = splice[2];
		this.version = (version.isEmpty() ? null : new SuiteVersion(version));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int compareTo(JavaMEStandard __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVendor aven = this.vendor,
			bven = __o.vendor;
		if ((aven == null) != (bven == null))
			return (aven == null ? -1 : 1);
		else if (aven != null)
		{
			rv = aven.compareTo(bven);
			if (rv != 0)
				return rv;
		}
			
		SuiteVersion aver = this.version,
			bver = __o.version;
		if ((aver == null) != (bver == null))
			return (aver == null ? -1 : 1);
		else if (aver != null)
			return aver.compareTo(bver);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaMEStandard))
			return false;
		
		JavaMEStandard o = (JavaMEStandard)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * Returns the name of the API which is defined.
	 *
	 * @return The defined API name.
	 * @since 2017/12/30
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.name + ";" +
				Objects.toString(this.vendor, "") + ";" +
				Objects.toString(this.version, "")));
		
		return rv;
	}
	
	/**
	 * Returns the vendor of the standard.
	 *
	 * @return The vendor, may be {@code null} if no vendor was specified.
	 * @since 2017/12/30
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the version of the standard.
	 *
	 * @return The version, may be {@code null} if no version was specified.
	 * @since 2017/12/30
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

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

package cc.squirreljme.plugin.swm;

/**
 * This interface is used for anything which represents a dependency and as
 * such can be used to check if a provided meets the conditions for a match.
 *
 * @since 2017/12/31
 */
public interface MarkedDependency
{
	/**
	 * Is this dependency optional?
	 *
	 * @return {@code true} if this dependency is optional.
	 * @since 2017/12/31
	 */
	boolean isOptional();
	
	/**
	 * Checks if this dependency matches the specified provision in that the
	 * provided entry is acceptable to be used for this dependency.
	 *
	 * @param __mp The provided to check.
	 * @return {@code true} if the provided is valid for this dependency.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException;
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/MarkedProvided.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

/**
 * This interface is associated with anything which can be a provided detail
 * for a dependency.
 *
 * @since 2017/12/31
 */
public interface MarkedProvided
{
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/SuiteDependency.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.NaturalComparator;
import cc.squirreljme.plugin.util.StringUtils;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a dependency that a LIBlet or MIDlet may depend on.
 *
 * @since 2017/02/22
 */
public final class SuiteDependency
	implements Comparable<SuiteDependency>, MarkedDependency
{
	/** The dependency type. */
	protected final SuiteDependencyType type;
	
	/** The dependency level. */
	protected final SuiteDependencyLevel level;
	
	/** The name. */
	protected final SuiteName name;
	
	/** The vendor. */
	protected final SuiteVendor vendor;
	
	/** The version range. */
	protected final SuiteVersionRange version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dependency which is parsed from the given input string.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteDependency(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error DG06 Expected four semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 4)
			throw new InvalidSuiteException(String.format(
				"AR06 %s", __s));
		
		// Split fields
		String intype = __s.substring(0, sc[0]).trim(),
			inlevel = __s.substring(sc[0] + 1, sc[1]).trim(),
			inname = __s.substring(sc[1] + 1, sc[2]).trim(),
			invendor = __s.substring(sc[2] + 1, sc[3]).trim(),
			inversion = __s.substring(sc[3] + 1).trim();
		
		// Required fields
		SuiteDependencyType type;
		this.type = (type = SuiteDependencyType.of(intype));
		this.level = SuiteDependencyLevel.of(inlevel);
		
		// Optional fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		// Check
		SuiteDependency.__check(type, this.level, name, vendor, version);
	}
	
	/**
	 * Initializes the depedency with the given type, level, and where the
	 * remainder of the dependencies are parsed from the specified string.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __s The string to decode for the remainder of the dependency.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error DG07 Expected two semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 2)
			throw new InvalidSuiteException(String.format(
				"AR07 %s", __s));
		
		// Split fields
		String inname = __s.substring(0, sc[0]).trim(),
			invendor = __s.substring(sc[0] + 1, sc[1]).trim(),
			inversion = __s.substring(sc[1] + 1).trim();
		
		// Parse areas fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		SuiteDependency.__check(__type, __level, name, vendor, version);
		
		// Set
		this.type = __type;
		this.level = __level;
	}
	
	/**
	 * Initializes the dependency using the given parameters.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException If no type and/or name were specified.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null)
			throw new NullPointerException("NARG");
		
		SuiteDependency.__check(__type, __level, __name, __vendor, __version);
		
		// Set
		this.type = __type;
		this.level = __level;
		this.name = __name;
		this.vendor = __vendor;
		this.version = __version;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public final int compareTo(SuiteDependency __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Type first
		int rv = this.type.compareTo(__d.type);
		if (rv != 0)
			return rv;
			
		// Optionality
		rv = this.level.compareTo(__d.level);
		if (rv != 0)
			return rv;
		
		// Name
		rv = Objects.<SuiteName>compare(this.name, __d.name,
			NaturalComparator.<SuiteName>instance());
		if (rv != 0)
			return rv;
		
		// Vendor
		rv = Objects.<SuiteVendor>compare(this.vendor, __d.vendor,
			NaturalComparator.<SuiteVendor>instance());
		if (rv != 0)
			return rv;
		
		// Version
		return Objects.<SuiteVersionRange>compare(this.version, __d.version,
			NaturalComparator.<SuiteVersionRange>instance());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteDependency))
			return false;
		
		// Compare
		SuiteDependency o = (SuiteDependency)__o;
		return this.type.equals(o.type) &&
			this.level.equals(o.level) &&
			Objects.equals(this.name, o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.level.hashCode() ^
			Objects.hashCode(this.name) ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/22
	 */
	@Override
	public boolean isOptional()
	{
		return this.level.isOptional();
	}
	
	/**
	 * Is this a required dependency?
	 *
	 * @return {@code true} if this is a required dependency.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this.level.isRequired();
	}
	
	/**
	 * Returns the dependency level.
	 *
	 * @return The dependency level.
	 * @since 2017/02/22
	 */
	public SuiteDependencyLevel level()
	{
		return this.level;
	}
	
	/**
	 * Returns the dependency name.
	 *
	 * @return The dependency name, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		SuiteDependencyType type = this.type;
		Class<?> mpclass = __mp.getClass();
		SuiteName name = this.name;
		SuiteVendor vendor = this.vendor;
		SuiteVersionRange version = this.version;
		
		// Depends
		switch (type)
		{
				// Proprietary match
			case PROPRIETARY:
				// Potential internal project name
				if (__mp instanceof InternalName)
				{
					String myname = name.toString();
					
					// Needs at sign
					int dxat;
					if ((dxat = myname.indexOf('@')) < 0)
						return false;
					
					// Prefix must be project reference
					if (!myname.substring(0, dxat).
						equals("squirreljme.project"))
						return false;
					
					// Otherwise the project name must match
					return myname.substring(dxat + 1).
						equals(((InternalName)__mp).name());
				}
				
				// No matches
				return false;
				
				// Library
			case LIBLET:
				// Typed suite information
				if (__mp instanceof TypedSuite)
				{
					TypedSuite other = (TypedSuite)__mp;
					SuiteIdentifier ident = other.suite();
					
					// Only match other libraries
					if (other.type() != JavaMEMidletType.LIBRARY)
						return false;
					
					// Must match name
					if (!name.equals(ident.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(ident.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(ident.version()))
							return false;
					
					// Is okay!
					return true;
				}
				
				// Unknown
				else
					return false;
					
				// Standard
			case STANDARD:
				if (__mp instanceof JavaMEStandard)
				{
					JavaMEStandard other = (JavaMEStandard)__mp;
					
					// Must match name
					if (!name.equals(other.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(other.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(other.version()))
							return false;
					
					// Matches!
					return true;
				}
				
				// Not a standard
				else
					return false;
				
				// {@squirreljme.error DG08 Illegal dependency check.
				// (The dependency type; The target class)}
			default:
				throw new RuntimeException(String.format("AR08 %s %s",
					type, mpclass));
		}
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * required.
	 *
	 * @return This dependency but required.
	 * @since 2017/11/26
	 */
	public SuiteDependency toRequired()
	{
		if (this.isRequired())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.REQUIRED,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * optional.
	 *
	 * @return This dependency but optional.
	 * @since 2017/11/26
	 */
	public SuiteDependency toOptional()
	{
		if (this.isOptional())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.OPTIONAL,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// These are optional
			SuiteName name = this.name;
			SuiteVendor vendor = this.vendor;
			SuiteVersionRange version = this.version;
			
			// Generate
			this._string = new WeakReference<>((rv = String.format(
				"%s;%s;%s;%s;%s", this.type, this.level,
				(name == null ? "" : name),
				(vendor == null ? "" : vendor),
				(version == null ? "" : version))));
		}
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the dependency type.
	 *
	 * @return The dependency type.
	 * @since 2017/02/22
	 */
	public SuiteDependencyType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the dependency vendor.
	 *
	 * @return The dependency vendor, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the dependency version.
	 *
	 * @return The dependency version, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange version()
	{
		return this.version;
	}
	
	/**
	 * Checks whether the provided parameters are correct.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @since 2017/11/26
	 */
	private static final void __check(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException
	{
		// {@squirreljme.error DG09 Dependencies on LIBlets must have the
		// name, vendor, and version set. (The type; The level; The name;
		// The vendor; The version)}
		if (__type == SuiteDependencyType.LIBLET && (__name == null ||
			__vendor == null || __version == null))
			throw new InvalidSuiteException(
				String.format("AR09 %s %s %s %s %s", __type, __level, __name,
					__vendor, __version));
	}
}

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

package cc.squirreljme.plugin.swm;

/**
 * This represents the level of the dependency.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyLevel
{
	/** Required. */
	REQUIRED,
	
	/** Optional. */
	OPTIONAL,
	
	/** End. */
	;
	
	/**
	 * Is this an optional dependency level?
	 *
	 * @return {@code true} if this is an optional dependency level.
	 * @since 2017/11/22
	 */
	public boolean isOptional()
	{
		return this == SuiteDependencyLevel.OPTIONAL;
	}
	
	/**
	 * Is this an required dependency level?
	 *
	 * @return {@code true} if this is an required dependency level.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this == SuiteDependencyLevel.REQUIRED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case REQUIRED:	return "required";
			case OPTIONAL:	return "optional";
			default:
				throw new RuntimeException(this.toString());
		}
	}
	
	/**
	 * Returns the dependency level based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency level for the given string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyLevel of(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "required":	return SuiteDependencyLevel.REQUIRED;
			case "optional":	return SuiteDependencyLevel.OPTIONAL;
			
				// Should not happen
			default:
				throw new RuntimeException(__s);
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/SuiteDependencyType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

/**
 * This represents the type of the dependency that is to be included.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyType
{
	/** Liblet. */
	LIBLET,
	
	/** Standard. */
	STANDARD,
	
	/** Service. */
	SERVICE,
	
	/** Proprietary. */
	PROPRIETARY,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case LIBLET:		return "liblet";
			case STANDARD:		return "standard";
			case SERVICE:		return "service";
			case PROPRIETARY:	return "proprietary";
			
			default:
				throw new Error("TODO");
		}
	}
	
	/**
	 * Returns the dependency type based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency type for the given string.
	 * @throws InvalidSuiteException If the dependency type is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyType of(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "liblet":		return SuiteDependencyType.LIBLET;
			case "standard":	return SuiteDependencyType.STANDARD;
			case "service":		return SuiteDependencyType.SERVICE;
			case "proprietary":	return SuiteDependencyType.PROPRIETARY;
			
				// {@squirreljme.error DG0a The specified string is not a valid
				// dependency type. (The input string)}
			default:
				throw new InvalidSuiteException(
					String.format("AR0a %s", __s));
		}
	}
}

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

package cc.squirreljme.plugin.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is the identity for a midlet suite which contains a name, vendor,
 * and version.
 *
 * @since 2016/10/12
 */
public final class SuiteIdentifier
	implements Comparable<SuiteIdentifier>
{
	/** The suite name. */
	protected final SuiteName name;
	
	/** The suite vendor. */
	protected final SuiteVendor vendor;
	
	/** The suite version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __name The name of the suite.
	 * @param __ven The vendor of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteIdentifier(SuiteName __name, SuiteVendor __ven,
		SuiteVersion __ver)
		throws NullPointerException
	{
		this(__ven, __name, __ver);
	}
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __ven The vendor of the suite.
	 * @param __name The name of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteIdentifier(SuiteVendor __ven, SuiteName __name,
		SuiteVersion __ver)
		throws NullPointerException
	{
		// Check
		if (__ven == null || __name == null || __ver == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.vendor = __ven;
		this.version = __ver;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteIdentifier __o)
	{
		if (this == __o)
			return 0;
		
		// Compare name
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		// Then vendor
		rv = this.vendor.compareTo(__o.vendor);
		if (rv != 0)
			return rv;
		
		// Then the version last
		return this.version.compareTo(__o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteIdentifier))
			return false;
		
		return 0 == (this.compareTo((SuiteIdentifier)__o));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.vendor.hashCode() ^
			this.version.hashCode();
	}
	
	/**
	 * Returns the suite name.
	 *
	 * @return The suite name.
	 * @since 2016/10/12
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.vendor + ";" +
				this.name + ";" + this.version));
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the suite vendor.
	 *
	 * @return The suite vendor.
	 * @since 2016/10/12
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the suite version.
	 *
	 * @return The suite version.
	 * @since 2016/10/12
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

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

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.StringUtils;

/**
 * This represents the name of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteName
	implements Comparable<SuiteName>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite name.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteName(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG0e An illegal character was
		// specified in the midlet suite name. (The midlet suite
		// name)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AR0e %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteName __o)
	{
		if (this == __o)
			return 0;
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteName))
			return false;
		
		return this.string.equals(((SuiteName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

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

package cc.squirreljme.plugin.swm;

import cc.squirreljme.plugin.util.StringUtils;

/**
 * This represents the vendor of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteVendor
	implements Comparable<SuiteVendor>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite vendor.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVendor(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG0h An illegal character was
		// specified in the midlet suite vendor. (The midlet suite
		// vendor)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AD0d %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVendor __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVendor))
			return false;
		
		return this.string.equals(((SuiteVendor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/SuiteVersion.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a suite version.
 *
 * @since 2016/10/12
 */
public final class SuiteVersion
	implements Comparable<SuiteVersion>
{
	/** The minimum version number. */
	public static final SuiteVersion MIN_VERSION =
		new SuiteVersion(0, 0, 0);
	
	/** The maximum version number. */
	public static final SuiteVersion MAX_VERSION =
		new SuiteVersion(99, 99, 99);
	
	/** The major version. */
	protected final int major;
	
	/** The minor version. */
	protected final int minor;
	
	/** The release version. */
	protected final int release;
	
	/** The string representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the version.
	 *
	 * @param __v The value to parse.
	 * @throws IllegalArgumentException If there are too many or too little
	 * version fields, they contain illegal charactes, or have an out of range
	 * value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(String __v)
		throws IllegalArgumentException, NullPointerException
	{
		this(SuiteVersion.__decodeVersion(__v));
	}
	
	/**
	 * Initializes a Midlet version number from the specified array of
	 * integer values.
	 *
	 * @param __v The version triplet, up to the first three elements are
	 * used by the version number.
	 * @throws IllegalArgumentException If the version number has an out of
	 * range value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int[] __v)
		throws IllegalArgumentException, NullPointerException
	{
		this((__v.length > 0 ? __v[0] : 0),
			(__v.length > 1 ? __v[1] : 0),
			(__v.length > 2 ? __v[2] : 0));
	}
	
	/**
	 * Decodes the midlet version, optionally allowing it to a reverse
	 * operation of the {@link #hashCode()} method.
	 *
	 * @param __hash If {@code true} then the value to decode is treated as
	 * the hash code returned by this class.
	 * @param __maj If {@code __hash} is {@code true} then this is the hash
	 * code of a SuiteVersion, otherwise it is the major version number.
	 * @throws IllegalArgumentException If the version number has an out of
	 * range value.
	 * @since 2016/10/13
	 */
	public SuiteVersion(boolean __hash, int __maj)
		throws IllegalArgumentException
	{
		this((__hash ? __maj / 10000 : __maj),
			(__hash ? (__maj / 100) % 100 : 0),
			(__hash ? __maj % 100 : 0));
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj)
	{
		this(__maj, 0, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min)
	{
		this(__maj, __min, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @param __rel The release version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min, int __rel)
		throws IllegalArgumentException
	{
		// Check version ranges
		if (__maj < 0 || __maj > 99 || __min < 0 || __min > 99 ||
			__rel < 0 || __rel > 99)
			throw new IllegalArgumentException(String.format(
				"Input version number is out of range, only 0 through " +
				"99 are valid: (%d, %d, %d)", __maj, __min, __rel));
		
		// Set
		this.major = __maj;
		this.minor = __min;
		this.release = __rel;
	}
	
	/**
	 * Checks if this version at least the specified verison.
	 *
	 * @param __v The version to check against.
	 * @return {@code true} if this version is at least the other.
	 * @throws NullPointerException On nul arguments.
	 */
	public boolean atLeast(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Can compare the hashcodes
		return this.hashCode() >= __v.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVersion __o)
	{
		// Major first
		int amaj = this.major, bmaj = __o.major;
		int rv = amaj - bmaj;
		if (rv != 0)
			return rv;
		
		// Then minor
		int amin = this.minor, bmin = __o.minor;
		rv = amin - bmin;
		if (rv != 0)
			return rv;
		
		// Then release
		int arel = this.release, brel = __o.release;
		rv = arel - brel;
		if (rv != 0)
			return rv;
		
		// The same
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersion))
			return false;
		
		// Cast
		SuiteVersion o = (SuiteVersion)__o;
		return this.major == o.major &&
			this.minor == o.minor &&
			this.release == o.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return (this.major * 10000) +
			(this.minor * 100) +
			this.release;
	}
	
	/**
	 * Returns the major version.
	 *
	 * @return The major version.
	 * @since 2017/02/22
	 */
	public int major()
	{
		return this.major;
	}
	
	/**
	 * Returns the minor version.
	 *
	 * @return The minor version.
	 * @since 2017/02/22
	 */
	public int minor()
	{
		return this.minor;
	}
	
	/**
	 * Returns the release version.
	 *
	 * @return The release version.
	 * @since 2017/02/22
	 */
	public int release()
	{
		return this.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.major + "." +
				this.minor + "." + this.release));
		
		// Return it
		return rv;
	}
	
	/**
	 * Decodes the string based version number
	 *
	 * @param __v The input string.
	 * @return The version tuplet.
	 * @throws IllegalArgumentException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	private static final int[] __decodeVersion(String __v)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__v = __v.trim();
		
		// Output array
		int[] rv = new int[3];
		
		// Parse the input value
		int n = __v.length(), at = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i <= n; i++)
		{
			int c = (i == n ? -1 : __v.charAt(i));
			
			// Decimal point? or end
			if (c == '.' || c == -1)
			{
				rv[at++] = Integer.parseInt(sb.toString(), 10);
				
				// Too many fields
				if (c != -1 && at >= 4)
					throw new IllegalArgumentException(String.format(
						"Too many version fields in the specified string: %s",
						__v));
				
				// Clear
				sb.setLength(0);
			}
			
			// Add to string
			else if (c >= '0' && c <= '9')
				sb.append((char)c);
			
			// Invalid format
			else
				throw new IllegalArgumentException(String.format(
					"An illegal character is in the version string: %s %c",
					__v, c));
		}
		
		// Return it
		return rv;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/swm/SuiteVersionRange.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is used to handle version ranges that may be used for dependencies.
 *
 * Version ranges are inclusive.
 *
 * @since 2017/02/22
 */
public final class SuiteVersionRange
	implements Comparable<SuiteVersionRange>
{
	/** Any version. */
	public static final SuiteVersionRange ANY_VERSION =
		new SuiteVersionRange(SuiteVersion.MIN_VERSION,
			SuiteVersion.MAX_VERSION);
	
	/** The starting range, inclusive. */
	protected final SuiteVersion from;
	
	/** Tne ending range, inclusive. */
	protected final SuiteVersion to;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the range inclusively between the two given versions.
	 *
	 * @param __from The source version.
	 * @param __to The destination version.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(SuiteVersion __from, SuiteVersion __to)
		throws NullPointerException
	{
		// Check
		if (__from == null || __to == null)
			throw new NullPointerException("NARG");
		
		// Make sure from is always first
		if (__from.compareTo(__to) <= 0)
		{
			this.from = __from;
			this.to = __to;
		}
		
		// Swapped
		else
		{
			this.from = __to;
			this.to = __from;
		}
	}
	
	/**
	 * Parses the version range that is specified in the dependency of JAR
	 * files.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the range is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim
		__s = __s.trim();
		
		// {@squirreljme.error DG0l The version range cannot be blank.}
		int sl = __s.length();
		if (sl <= 0)
			throw new IllegalArgumentException("AR0l");
		
		// Get the last character
		char lc = __s.charAt(__s.length() - 1);
		
		// All versions following this.
		if (lc == '+')
		{
			this.from = new SuiteVersion(__s.substring(0, sl - 1));
			this.to = new SuiteVersion(99, 99, 99);
		}
		
		// All versions in the group
		else if (lc == '*')
		{
			// Get the last dot, if any
			int ld = __s.lastIndexOf('.');
			if (ld < 0)
			{
				// Any version, does not matter
				if (sl == 1)
				{
					this.from = new SuiteVersion(0);
					this.to = new SuiteVersion(99, 99, 99);
				}
				
				// {@squirreljme.error DG0m Major only wildcard versions must
				// be a single asterisk. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0m %s",
						__s));
			}
			
			// Parse otherwise, just count the number of dots to determine
			// how deep it goes
			else
			{
				// {@squirreljme.error DG0n The last dot in a wildcard must be
				// before the asterisk. (The input string)}
				if (ld != sl - 1)
					throw new InvalidSuiteException(String.format("AR0n %s",
						__s));
				
				// Source range is simple
				SuiteVersion ver = new SuiteVersion(
					__s.substring(0, sl - 2));
				this.from = ver;
				
				// Count dots, determines major/minor
				int numdots = 0;
				for (int i = 0; i < sl; i++)
					if (__s.charAt(i) == '.')
						numdots++;
				
				// minor and release wildcard
				if (numdots == 1)
					this.to = new SuiteVersion(ver.major(), 99, 99);
				
				// release ranged wildcard
				else if (numdots == 2)
					this.to = new SuiteVersion(ver.major(), ver.minor(), 99);
				
				// {@squirreljme.error DG0o There are too many decimal points
				// in the wildcard version string. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0o %s",
						__s));
			}
		}
		
		// Only this version
		else
		{
			SuiteVersion ver = new SuiteVersion(__s);
			this.from = ver;
			this.to = ver;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(SuiteVersionRange __o)
	{
		// From version is always first
		int rv = this.from.compareTo(__o.from);
		if (rv != 0)
			return rv;
		
		return this.to.compareTo(__o.to);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersionRange))
			return false;
		
		// Compare
		SuiteVersionRange o = (SuiteVersionRange)__o;
		return this.from.equals(o.from) && this.to.equals(o.to);
	}
	
	/**
	 * Returns the start of the range
	 *
	 * @return The range start.
	 * @since 2017/02/22
	 */
	public SuiteVersion from()
	{
		return this.from;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.to.hashCode() ^ (~this.from.hashCode());
	}
	
	/**
	 * Checks whether the specified version is in range.
	 *
	 * @param __v The version to check.
	 * @return {@code true} if it is in the range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public boolean inRange(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return __v.compareTo(this.from) >= 0 &&
			__v.compareTo(this.to) <= 0;
	}
	
	/**
	 * Checks whether the given version is within range of the other version.
	 *
	 * @param __r The other version range to check.
	 * @return If the other version range shares all or part of its range
	 * with this range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/27
	 */
	public boolean inRange(SuiteVersionRange __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		throw new Error("TODO");
	}
	
	/**
	 * Returns the end of the range.
	 *
	 * @return The range end.
	 * @since 2017/02/22
	 */
	public SuiteVersion to()
	{
		return this.to;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Slowly build version
			StringBuilder sb = new StringBuilder();
			SuiteVersion from = this.from;
			SuiteVersion to = this.to;
			
			// Get all values
			int amaj = from.major(),
				amin = from.minor(),
				arel = from.release(),
				bmaj = to.major(),
				bmin = to.minor(),
				brel = to.release();
			
			// Pure wildcard
			if (amaj == 0 && amin == 0 && arel == 0 &&
				bmaj == 99 && bmin == 99 && brel == 99)
				sb.append('*');
			
			// Exact, subwildcard, or any following
			else
			{
				// Add major version
				sb.append(amaj);
				sb.append('.');
				
				// Wild card minor and release
				if (amin == 0 && arel == 0 && bmin == 99 && brel == 99)
					sb.append('*');
				
				// Not wild
				else
				{
					// Add version
					sb.append(amin);
					sb.append('.');
					
					// Wild card release
					if (arel == 0 && brel == 99)
						sb.append('*');
					
					// Would be exact (or plus)
					else
						sb.append(arel);
				}
			
				// Will be all versions following
				if (bmaj == 99 && bmin == 99 && brel == 99)
					sb.append('+');
			}
			
			// Store
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Returns a version which at most implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange atMost(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(SuiteVersion.MIN_VERSION, __v);
	}
	
	/**
	 * Returns a version which exactly implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange exactly(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(__v, __v);
	}
}

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

package cc.squirreljme.plugin.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a suite with an associated type.
 *
 * @since 2017/12/30
 */
public final class TypedSuite
	implements MarkedProvided
{
	/** The suite type. */
	protected final JavaMEMidletType type;
	
	/** The suite. */
	protected final SuiteIdentifier suite;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the typed suite.
	 *
	 * @param __type The type of suite.
	 * @param __suite The suite information.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public TypedSuite(JavaMEMidletType __type, SuiteIdentifier __suite)
		throws NullPointerException
	{
		if (__type == null || __suite == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.suite = __suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof TypedSuite))
			return false;
		
		TypedSuite o = (TypedSuite)__o;
		return this.type.equals(o.type) &&
			this.suite.equals(o.suite);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.suite.hashCode();
	}
	
	/**
	 * Returns the suite.
	 *
	 * @return The suite.
	 * @since 2017/12/30
	 */
	public SuiteIdentifier suite()
	{
		return this.suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.type + " " + this.suite));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/12/30
	 */
	public JavaMEMidletType type()
	{
		return this.type;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/AdditionalManifestPropertiesTask.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import cc.squirreljme.plugin.SquirrelJMEPluginConfiguration;
import cc.squirreljme.plugin.swm.JavaMEMidlet;
import cc.squirreljme.plugin.swm.JavaMEMidletType;
import cc.squirreljme.plugin.swm.SuiteDependency;
import cc.squirreljme.plugin.swm.SuiteDependencyLevel;
import cc.squirreljme.plugin.swm.SuiteDependencyType;
import cc.squirreljme.plugin.swm.SuiteName;
import cc.squirreljme.plugin.swm.SuiteVendor;
import cc.squirreljme.plugin.swm.SuiteVersion;
import cc.squirreljme.plugin.swm.SuiteVersionRange;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import java.util.jar.Attributes;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.java.archives.Manifest;
import org.gradle.jvm.tasks.Jar;
import org.gradle.language.jvm.tasks.ProcessResources;

/**
 * Adds additional properties to the manifest file.
 *
 * @since 2020/02/28
 */
public class AdditionalManifestPropertiesTask
	extends DefaultTask
{
	/**
	 * Initializes the task.
	 *
	 * @param __jar The JAR Task.
	 * @param __pr The process resources task.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	@Inject
	public AdditionalManifestPropertiesTask(Jar __jar, ProcessResources __pr)
		throws NullPointerException
	{
		if (__jar == null)
			throw new NullPointerException("No JAR specified.");
		
		// Set details of this task
		this.setGroup("squirreljme");
		this.setDescription("Builds an additional manifest for this project.");
		
		// Configure inputs and outputs
		Project project = this.getProject();
		this.getInputs().files(
			project.provider(project::getBuildFile));
		this.getOutputs().files(
			project.provider(this::__taskOutputAsFileCollection));
		
		// This action creates the actual manifest file
		this.doLast(new Action<Task>()
			{
				@Override
				public void execute(Task __task)
				{
					AdditionalManifestPropertiesTask.this.__doLast(__task);
				}
			});
		
		// When the JAR is created it gets additional manifests from us
		__jar.manifest(new Action<Manifest>()
			{
				@Override
				public void execute(Manifest __manifest)
				{
					__manifest.from(AdditionalManifestPropertiesTask.this
						.__taskOutput().toFile());
				}
			});
		
		// Jar and resources depend on this task
		__jar.dependsOn(this);
		__pr.dependsOn(this);
	}
	
	/**
	 * Performs the task actions.
	 *
	 * @since 2002/02/28
	 */
	private void __doLast(Task __task)
	{
		// Get the project and the config details
		Project project = this.getProject();
		SquirrelJMEPluginConfiguration config =
			SquirrelJMEPluginConfiguration.configuration(project);
		
		// Setup manifest to write into
		java.util.jar.Manifest javaManifest = new java.util.jar.Manifest();
		Attributes attributes = javaManifest.getMainAttributes();
		
		// Set manifest to 1.0
		attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
		
		// Project name is used internally for dependency lookup
		attributes.putValue("X-SquirrelJME-InternalProjectName",
			project.getName());
		
		// Generation really depends on the application type
		JavaMEMidletType type = config.swmType;
		
		// Add common keys
		attributes.putValue(type.nameKey(), config.swmName);
		attributes.putValue(type.vendorKey(), config.swmVendor);
		attributes.putValue(type.versionKey(),
			new SuiteVersion(project.getVersion().toString()).toString());
			
		// Application
		if (type == JavaMEMidletType.APPLICATION)
		{
			// Main class of entry?
			if (config.mainClass != null)
				attributes.putValue("Main-Class", config.mainClass);
			
			// Add any defined MIDlets
			int midletId = 1;
			for (JavaMEMidlet midlet : config.midlets)
				attributes.putValue("MIDlet-" + (midletId++),
					midlet.toString());
			
			// Ignored in the launcher?
			if (config.ignoreInLauncher)
				attributes.putValue("X-SquirrelJME-NoLauncher",
					"true");
		}
		
		// Library
		else if (type == JavaMEMidletType.LIBRARY)
		{
		}
		
		// API
		else if (type == JavaMEMidletType.API)
		{
			// Configurations defined?
			if (!config.definedConfigurations.isEmpty())
				attributes.putValue(
					"X-SquirrelJME-DefinedConfigurations",
					AdditionalManifestPropertiesTask
						.__delimate(config.definedConfigurations, ' '));
			
			// Profiles defined?
			if (!config.definedProfiles.isEmpty())
				attributes.putValue(
					"X-SquirrelJME-DefinedProfiles",
					AdditionalManifestPropertiesTask
						.__delimate(config.definedProfiles, ' '));
			
			// Standards defined?
			if (!config.definedStandards.isEmpty())
				attributes.putValue(
					"X-SquirrelJME-DefinedStandards",
					AdditionalManifestPropertiesTask
						.__delimate(config.definedStandards, ' '));
		}
		
		// Find all module dependencies
		Map<String, ProjectDependency> dependencies = new TreeMap<>();
		for (String configurationName : Arrays.<String>asList(
				"api", "implementation"))
		{
			// The configuration might not even exist
			Configuration buildConfig = project.getConfigurations()
				.findByName(configurationName);
			if (buildConfig == null)
				continue;
			
			// Add all project based dependencies
			for (Dependency dependency : buildConfig.getDependencies())
				if (dependency instanceof ProjectDependency)
				{
					ProjectDependency mod = (ProjectDependency)dependency;
					
					dependencies.put(mod.getName(), mod);
				}
		}
		
		// Put in as many dependencies as possible
		int normalDep = 1;
		for (ProjectDependency dependency : dependencies.values())
		{
			// Find the associated project
			Project subProject = dependency.getDependencyProject();
			
			// Get the project config
			SquirrelJMEPluginConfiguration subConfig =
				SquirrelJMEPluginConfiguration.configuration(subProject);
			
			// The dependency being constructed (which might be added)
			SuiteDependency suiteDependency = null;
			boolean didDepend = false;
			
			// Nothing can depend on a MIDlet!
			if (subConfig.swmType == JavaMEMidletType.APPLICATION)
				throw new RuntimeException(String.format(
					"Project %s cannot depend on application %s.",
						project.getName(), subProject.getName()));
			
			// This is another library
			else if (subConfig.swmType == JavaMEMidletType.LIBRARY)
				suiteDependency = new SuiteDependency(
					SuiteDependencyType.LIBLET,
					SuiteDependencyLevel.REQUIRED,
					new SuiteName(subConfig.swmName),
					new SuiteVendor(subConfig.swmVendor),
					SuiteVersionRange.exactly(new SuiteVersion(
						subProject.getVersion().toString())));
			
			// Is otherwise an API
			else
			{
				// Configuration specified?
				try
				{
					attributes.putValue("Microedition-Configuration",
						Collections.max(subConfig.definedConfigurations)
							.toString());
					didDepend = true;
				}
				catch (NoSuchElementException e)
				{
					// Ignore
				}
				
				// Profile specified?
				try
				{
					attributes.putValue("Microedition-Profile",
						Collections.max(subConfig.definedProfiles).toString());
					didDepend = true;
				}
				catch (NoSuchElementException e)
				{
					// Ignore
				}
			}
			
			// Unknown, do a generic project dependency
			if (!didDepend && suiteDependency == null)
				suiteDependency = new SuiteDependency(
					SuiteDependencyType.PROPRIETARY,
					SuiteDependencyLevel.REQUIRED,
					new SuiteName("squirreljme.project@" +
						subProject.getName()),
					null,
					null);
			
			// Write out the dependency if one was requested
			if (suiteDependency != null)
				attributes.putValue(type.dependencyKey(normalDep++),
					suiteDependency.toString());
		}
		
		// Write the manifest output
		try (OutputStream out = Files.newOutputStream(this.__taskOutput(),
			StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING,
			StandardOpenOption.WRITE))
		{
			javaManifest.write(out);
			
			// Make sure it is really written!
			out.flush();
		}
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * Returns the output manifest file.
	 *
	 * @return The output manifest file.
	 * @since 2020/02/28
	 */
	private Path __taskOutput()
	{
		return this.getProject().getBuildDir().toPath().
			resolve("SQUIRRELJME.MF");
	}
	
	/**
	 * Returns the output manifest file.
	 *
	 * @return The output manifest file.
	 * @since 2020/02/28
	 */
	private FileCollection __taskOutputAsFileCollection()
	{
		return this.getProject().files(this.__taskOutput().toFile());
	}
	
	/**
	 * Turns an iterable into a string with the given delimeter.
	 *
	 * @param __it The iteration to convert.
	 * @param __delim The delimiter.
	 * @return The converted string.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/15
	 */
	private static String __delimate(Iterable<?> __it, char __delim)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		// Build output string
		StringBuilder sb = new StringBuilder();
		for (Object o : __it)
		{
			// Add delimeter?
			if (sb.length() > 0)
				sb.append(__delim);
			
			// Add object
			sb.append(o);
		}
		
		return sb.toString();
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/GenerateTestsListTask.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Collection;
import java.util.LinkedList;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.DirectoryTree;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.language.jvm.tasks.ProcessResources;

/**
 * This generates the list of tests that are available.
 *
 * @since 2020/02/28
 */
public class GenerateTestsListTask
	extends DefaultTask
{
	/** The service list path. */
	public static final Path SERVICE_LIST_PATH =
		Paths.get("META-INF", "services",
			"net.multiphasicapps.tac.TestInterface");
	
	/**
	 * Initializes the task.
	 *
	 * @param __processTask The resource task.
	 * @since 2020/02/28
	 */
	@Inject
	public GenerateTestsListTask(ProcessResources __processTask)
	{
		// Set details of this task
		this.setGroup("squirreljme");
		this.setDescription("Builds the list of tests which are available.");
		
		// Configure inputs and outputs
		Project project = this.getProject();
		this.getInputs().files(
			project.provider(this::__taskInputsAsFileCollection));
		this.getOutputs().files(
			project.provider(this::__taskOutputsAsFileCollection));
		
		// Only run in this condition
		this.onlyIf(this::__onlyIf);
		
		// Perform our task action
		this.doLast(new Action<Task>() {
				@Override
				public void execute(Task __task)
				{
					GenerateTestsListTask.this.__doLast(__task);
				}
			});
		
		// The process task depends on this task
		__processTask.dependsOn(this);
	}
	
	/**
	 * Runs the actual task.
	 *
	 * @param __task The task to run for.
	 * @since 2020/02/28
	 */
	private void __doLast(Task __task)
	{
		Path outputFile = this.__taskOutput();
		
		// Create list
		try
		{
			// Make sure the output directory exists
			Files.createDirectories(outputFile.getParent());
			
			// Write lines to service file
			try (PrintStream out = new PrintStream(Files.newOutputStream(
				outputFile, StandardOpenOption.CREATE,
				StandardOpenOption.TRUNCATE_EXISTING,
				StandardOpenOption.WRITE)))
			{
				// Write lines for each input
				for (__Input__ input : this.__taskInputs())
				{
					String fileName = input.relative.toString();
					
					// Write here
					out.println(fileName.substring(0,
						fileName.length() - ".java".length())
						.replace('\\', '.')
						.replace('/', '.'));
				}
				
				// Make sure the output is written
				out.flush();
			}
		}
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * Only run the task if certain conditions are met.
	 *
	 * @param __task The task to run.
	 * @return The result if it should run or not.
	 * @since 2020/02/28
	 */
	private boolean __onlyIf(Task __task)
	{
		// There is no point in running this, if nothing can be done
		return !this.__taskInputsAsFileCollection().isEmpty();
	}
	
	/**
	 * Returns the output path.
	 *
	 * @return The output path.
	 * @since 2020/02/28
	 */
	private Path __outputPath()
	{
		// We might need to set an output potentially
		Project project = this.getProject();
		SourceSetOutput outSet = this.getProject().getConvention().
			getPlugin(JavaPluginConvention.class).
			getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME).
			getOutput();
			
		// The base output directory
		File outDirFile = outSet.getResourcesDir();
		if (outDirFile == null)
			outSet.setResourcesDir((outDirFile = project.getBuildDir().
			toPath().resolve("test-list-resource").toFile()));
		
		return outDirFile.toPath();
	}
	
	/**
	 * Gets the inputs for this task.
	 *
	 * @return The task inputs.
	 * @since 2020/02/28
	 */
	private Iterable<__Input__> __taskInputs()
	{
		Project project = this.getProject();
		
		// Discover all the input files
		Collection<__Input__> result = new LinkedList<>();
		for (DirectoryTree dir : this.getProject().getConvention().
			getPlugin(JavaPluginConvention.class).getSourceSets().
			getByName("test").getJava().getSrcDirTrees())
		{
			Path baseDir = dir.getDir().toPath();
			
			// Process all files in each directory
			for (File file : project.files(dir))
			{
				Path path = file.toPath();
				
				if (GenerateTestsListTask.__isTest(path))
					result.add(new __Input__(path, baseDir.relativize(path)));
			}
		}
		
		return result;
	}
	
	/**
	 * Gets the inputs for the task.
	 *
	 * @return The task inputs.
	 * @since 2020/02/28
	 */
	private FileCollection __taskInputsAsFileCollection()
	{
		Collection<File> result = new LinkedList<>();
		for (__Input__ file : this.__taskInputs())
			result.add(file.absolute.toFile());
		
		return this.getProject().files(result);
	}
	
	/**
	 * Returns the output of this task.
	 *
	 * @return The task output.
	 * @since 2020/02/28
	 */
	private Path __taskOutput()
	{
		return this.__outputPath().resolve(
			GenerateTestsListTask.SERVICE_LIST_PATH);
	}
	
	/**
	 * Gets the outputs for the task.
	 *
	 * @return The task outputs.
	 * @since 2020/02/28
	 */
	private FileCollection __taskOutputsAsFileCollection()
	{
		// There is just a single output file
		return this.getProject().files(this.__taskOutput().toFile());
	}
	
	/**
	 * Is this considered a test?
	 *
	 * @param __path The path to get.
	 * @return If this is considered a test.
	 * @since 2020/02/8
	 */
	private static boolean __isTest(Path __path)
		throws NullPointerException
	{
		if (__path == null)
			throw new NullPointerException();
		
		// Only consider source files
		String fileName = __path.getFileName().toString();
		if (!fileName.endsWith(".java"))
			return false;
		
		// Get base class form
		String className = fileName.substring(0,
			fileName.length() - ".java".length());
		
		return (className.startsWith("Do") || className.startsWith("Test") ||
			className.endsWith("Test"));
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/MimeDecodeResourcesTask.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import cc.squirreljme.plugin.util.MIMEFileDecoder;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Collection;
import java.util.LinkedList;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.DirectoryTree;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.language.jvm.tasks.ProcessResources;

public class MimeDecodeResourcesTask
	extends DefaultTask
{
	/** The extension for MIME files. */
	public static final String EXTENSION =
		".__mime";
	
	/** The source set to modify. */
	protected final String sourceSet;
	
	/**
	 * Initializes the task.
	 *
	 * @param __sourceSet The source set to adjust.
	 * @param __processTask The processing task.
	 * @since 2020/02/28
	 */
	@Inject
	public MimeDecodeResourcesTask(String __sourceSet,
		ProcessResources __processTask)
	{
		// The source set we want to work with
		this.sourceSet = __sourceSet;
		
		// Set details of this task
		this.setGroup("squirreljme");
		this.setDescription("Decodes MIME encoded resource files.");
		
		// Configure tasks and such
		Project project = this.getProject();
		this.getInputs().files(
			project.provider(this::__taskInputsAsFileCollection));
		this.getOutputs().files(
			project.provider(this::__taskOutputsAsFileCollection));
		this.onlyIf(this::__onlyIf);
		
		// The action to do
		this.doLast(new __ActionTask__());
		
		// The process task depends on this task
		__processTask.dependsOn(this);
		
		// However, since we use our own files, we exclude files from this
		// task!
		__processTask.eachFile((FileCopyDetails __fcd) ->
			{
				// Exclude all MIME files from this task
				if (MimeDecodeResourcesTask.
					__isMimeFile(__fcd.getFile().toPath()))
					__fcd.exclude();
			});
	}
	
	/**
	 * Runs the actual task.
	 *
	 * @param __task The task to run for.
	 * @since 2020/02/28
	 */
	private void __doLast(Task __task)
	{
		// Anything here can fail for IO operations
		try
		{
			// Process all outputs
			for (__Output__ output : this.__taskOutputs())
			{
				Path outPath = output.output;
				
				// Make sure the output directory exists!
				Files.createDirectories(outPath.getParent());
				
				// Copy decoded MIME data to the output file
				try (MIMEFileDecoder in = new MIMEFileDecoder(
					Files.newInputStream(output.input.absolute,
							StandardOpenOption.READ));
					OutputStream out = Files.newOutputStream(outPath,
							StandardOpenOption.CREATE,
							StandardOpenOption.TRUNCATE_EXISTING,
							StandardOpenOption.WRITE))
				{
					byte[] buf = new byte[4096];
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
							break;
						
						out.write(buf, 0, rc);
					}
				}
			}
		}
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * Returns the output path.
	 *
	 * @return The output path.
	 * @since 2020/02/28
	 */
	private Path __outputPath()
	{
		// We might need to set an output potentially
		Project project = this.getProject();
		SourceSetOutput outSet = this.getProject().getConvention().
			getPlugin(JavaPluginConvention.class).
			getSourceSets().getByName(this.sourceSet).getOutput();
		
		// The base output directory
		File outDirFile = outSet.getResourcesDir();
		if (outDirFile == null)
			outSet.setResourcesDir((outDirFile = project.getBuildDir().
			toPath().resolve("mime-decoded-" + this.sourceSet).toFile()));
		
		return outDirFile.toPath();
	}
	
	/**
	 * Only run the task if certain conditions are met.
	 *
	 * @param __task The task to run.
	 * @return The result if it should run or not.
	 * @since 2020/02/28
	 */
	private boolean __onlyIf(Task __task)
	{
		// There is no point in running this, if nothing can be done
		return !this.__taskInputsAsFileCollection().isEmpty();
	}
	
	/**
	 * Gets the inputs for the task as fully informed files.
	 *
	 * @return The task inputs.
	 * @since 2020/02/28
	 */
	private Iterable<__Input__> __taskInputs()
	{
		Project project = this.getProject();
		
		// Discover all the input files
		Collection<__Input__> result = new LinkedList<>();
		for (DirectoryTree dir : this.getProject().getConvention().
			getPlugin(JavaPluginConvention.class).getSourceSets().
			getByName(this.sourceSet).getResources().getSrcDirTrees())
		{
			Path baseDir = dir.getDir().toPath();
			
			// Process all files in each directory
			for (File file : project.files(dir))
			{
				Path path = file.toPath();
				
				// Only consider MIME files
				if (!MimeDecodeResourcesTask.__isMimeFile(path))
					continue;
				
				result.add(new __Input__(path, baseDir.relativize(path)));
			}
		}
		
		return result;
	}
	
	/**
	 * Gets the inputs for the task.
	 *
	 * @return The task inputs.
	 * @since 2020/02/28
	 */
	private FileCollection __taskInputsAsFileCollection()
	{
		Collection<File> result = new LinkedList<>();
		for (__Input__ file : this.__taskInputs())
			result.add(file.absolute.toFile());
		
		return this.getProject().files(result);
	}
	
	/**
	 * Gets the outputs for the task.
	 *
	 * @return The task outputs.
	 * @since 2020/02/28
	 */
	private Iterable<__Output__> __taskOutputs()
	{
		// The output path to process
		Path outDir = this.__outputPath();
		
		// Store output files accordingly
		Collection<__Output__> result = new LinkedList<>();
		for (__Input__ input : this.__taskInputs())
			result.add(new __Output__(input, outDir.resolve(
				MimeDecodeResourcesTask.
					__removeMimeExtension(input.relative))));
		
		return result;
	}
	
	/**
	 * Gets the outputs for the task.
	 *
	 * @return The task outputs.
	 * @since 2020/02/28
	 */
	private FileCollection __taskOutputsAsFileCollection()
	{
		Collection<File> result = new LinkedList<>();
		for (__Output__ output : this.__taskOutputs())
			result.add(output.output.toFile());
		
		return this.getProject().files(result);
	}
	
	/**
	 * Is this a MIME file?
	 *
	 * @param __path The path to get.
	 * @return If this is a MIME file.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	private static boolean __isMimeFile(Path __path)
		throws NullPointerException
	{
		if (__path == null)
			throw new NullPointerException("No path specified.");
		
		return __path.getFileName().toString().endsWith(
			MimeDecodeResourcesTask.EXTENSION);
	}
	
	/**
	 * Removes the extension from the file.
	 *
	 * @param __fn The file name to remove.
	 * @return The file name without the extension.
	 * @throws IllegalArgumentException If the file does not have the
	 * extension.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	private static Path __removeMimeExtension(Path __fn)
		throws IllegalArgumentException, NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("No file name specified.");
		
		// Must be a MIME file
		String fileName = __fn.getFileName().toString();
		if (!fileName.endsWith(MimeDecodeResourcesTask.EXTENSION))
			throw new IllegalArgumentException("File does not end in MIME.");
		
		// The output will be a sibling of the path
		return __fn.resolveSibling(fileName.substring(0,
			fileName.length() - MimeDecodeResourcesTask.EXTENSION.length()));
	}
	
	/**
	 * The action to perform.
	 *
	 * @since 2020/02/29
	 */
	private class __ActionTask__
		implements Action<Task>
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/02/29
		 */
		@Override
		public void execute(Task __task)
		{
			MimeDecodeResourcesTask.this.__doLast(__task);
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/RunEmulatedTask.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import cc.squirreljme.plugin.SquirrelJMEPluginConfiguration;
import cc.squirreljme.plugin.swm.JavaMEMidlet;
import cc.squirreljme.plugin.swm.JavaMEMidletType;
import groovy.lang.Closure;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.jvm.tasks.Jar;
import org.gradle.process.JavaExecSpec;

/**
 * Launches the program but runs it in the Virtual Machine.
 *
 * @since 2020/02/29
 */
public class RunEmulatedTask
	extends DefaultTask
{
	/** Main configurations. */
	private static final String[] _MAIN_CONFIGS =
		new String[]{"api", "implementation"};
	
	/** Test configurations. */
	private static final String[] _TEST_CONFIGS =
		new String[]{"testApi", "testImplementation"};
	
	/** The emulator to use. */
	protected final String emulator;
	
	/** Is this for a test? */
	protected final boolean isTest;
	
	/**
	 * Initializes the task.
	 *
	 * @param __jar The JAR task.
	 * @param __emulator The emulator to use.
	 * @param __test Is this for tests?
	 * @since 2020/02/29
	 */
	@Inject
	public RunEmulatedTask(Jar __jar, String __emulator, boolean __test)
	{
		if (__test)
			throw new IllegalArgumentException("Implement test launching!");
		
		this.emulator = __emulator;
		this.isTest = __test;
		
		// Set details of this task
		this.setGroup("squirreljme");
		this.setDescription((__test ? "Tests the program with " +
			__emulator + "." : "Launches the program with the " +
			__emulator + " virtual machine."));
		
		// The output of this task is the profiling snapshot
		this.getOutputs().files(
			this.getProject().provider(this::__profilerSnapshotPath));
		
		// This only runs if this is an application
		this.onlyIf(this::__onlyIf);
		
		// Run the task accordingly
		this.doLast(new RunEmulatedTask.__ActionTask__());
		
		// This needs the JAR task and the emulation task
		this.dependsOn(__jar,
			(Callable<Object>)this::__findEmulatorJarTask,
			(Callable<Object>)this::__findEmulatorBaseJarTask);
	}
	
	/**
	 * Only runs if these conditions are met.
	 *
	 * @param __task Checks this task.
	 * @return If this can run or not.
	 * @since 2020/02/29
	 */
	private boolean __onlyIf(Task __task)
	{
		// Only allow if an application!
		return SquirrelJMEPluginConfiguration.configuration(this.getProject())
			.swmType == JavaMEMidletType.APPLICATION;
	}
	
	/**
	 * Finds the emulator JAR task.
	 *
	 * @return The emulator JAR task.
	 * @since 2020/02/29
	 */
	private Object __findEmulatorBaseJarTask()
	{
		return Objects.requireNonNull(this.getProject().getRootProject().
			findProject(":emulators:emulator-base"),
			"No emulator base?").getTasks().getByName("jar");
	}
	
	/**
	 * Locates the emulator package to base on.
	 *
	 * @return The emulator base.
	 * @since 2020/02/29
	 */
	private Object __findEmulatorJarTask()
	{
		return Objects.requireNonNull(this.getProject().getRootProject().
			findProject(":emulators:" + this.emulator + "-vm"),
			"No emulator?").getTasks().getByName("jar");
	}
	
	/**
	 * Returns the snapshot path for the profiler.
	 *
	 * @return The profiler snapshot path.
	 * @since 2020/02/29
	 */
	File __profilerSnapshotPath()
	{
		return this.getProject().getBuildDir().toPath()
			.resolve(this.emulator + ".nps").toFile();
	}
	
	/**
	 * Returns the run class path.
	 *
	 * @return The run class path.
	 * @since 2020/02/29
	 */
	Iterable<Path> __runClassPath()
	{
		Collection<Path> result = new LinkedHashSet<>();
		
		this.__recursiveDependencies(result, this.getProject());
		
		return result;
	}
	
	/**
	 * Returns the run class path as a string.
	 *
	 * @return The run class path as a string.
	 * @since 2020/02/29
	 */
	String __runClassPathAsString()
	{
		StringBuilder sb = new StringBuilder();
		
		for (Path path : this.__runClassPath())
		{
			if (sb.length() > 0)
				sb.append(File.pathSeparatorChar);
			sb.append(path);
		}
		
		return sb.toString();
	}
	
	/**
	 * Recursively scans and obtains dependencies.
	 *
	 * @param __out The output collection.
	 * @param __at The current project currently at.
	 * @since 2020/02/29
	 */
	final void __recursiveDependencies(Collection<Path> __out, Project __at)
	{
		// If this is not a SquirrelJME project, ignore
		SquirrelJMEPluginConfiguration config = __at.getExtensions()
			.<SquirrelJMEPluginConfiguration>findByType(
				SquirrelJMEPluginConfiguration.class);
		if (config == null)
			return;
		
		// Look in these configurations for dependencies, done first so what
		// we depend on has higher priority first
		for (String configurationName : (this.isTest ?
				RunEmulatedTask._TEST_CONFIGS : RunEmulatedTask._MAIN_CONFIGS))
		{
			// The configuration might not even exist
			Configuration buildConfig = __at.getConfigurations()
				.findByName(configurationName);
			if (buildConfig == null)
				continue;
			
			// Recursively scan dependencies
			for (Dependency dependency : buildConfig.getDependencies())
			{
				// Only consider modules
				if (!(dependency instanceof ProjectDependency))
					continue;
				
				// Recursive search these dependencies
				this.__recursiveDependencies(__out,
					((ProjectDependency)dependency).getDependencyProject());
			}
		}
		
		// Process the output files for the JAR of this project, use the
		// absolute path since there might be hard to find libraries that are
		// relative
		for (File file : ((Jar)__at.getTasks().getByName("jar"))
			.getOutputs().getFiles())
			__out.add(file.toPath().toAbsolutePath());
		
	}
	
	/**
	 * Used to run the emulator.
	 *
	 * @since 2020/02/29
	 */
	private class __ActionTask__
		implements Action<Task>
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/02/29
		 */
		@Override
		public void execute(Task __task)
		{
			// Get current and emulator projects
			Project project = RunEmulatedTask.this.getProject();
			Project emuBase = project.getRootProject().
				project(":emulators:emulator-base");
			Project emuCore = project.getRootProject().
				project(":emulators:" + RunEmulatedTask.this.emulator + "-vm");
			
			// Need this to get the program details
			SquirrelJMEPluginConfiguration config =
				SquirrelJMEPluginConfiguration.configuration(project);
			
			// Execute program
			project.javaexec((JavaExecSpec __spec) ->
				{
					// Are we launching a MIDlet?
					JavaMEMidlet midlet = null;
					if (!config.midlets.isEmpty())
						midlet = config.midlets.get(0);
					
					// Build arguments to the VM
					Collection<String> args = new LinkedList<>();
					
					// Add emulator
					args.add("-Xemulator:" + RunEmulatedTask.this.emulator);
					
					// Add snapshot path
					args.add("-Xsnapshot:" + RunEmulatedTask.this.
						__profilerSnapshotPath().toPath().toString());
					
					// Determine program classpath
					args.add("-classpath");
					args.add(RunEmulatedTask.this.__runClassPathAsString());
					
					// Add main class to launch
					args.add((midlet != null ?
						"javax.microedition.midlet.__MainHandler__" :
						Objects.requireNonNull(config.mainClass,
						"No main class in project.")));
					
					// We need to tell the MIDlet launcher what our main entry
					// point is going to be
					if (midlet != null)
						args.add(midlet.mainClass);
					
					// Use the given arguments
					__spec.args(args);
					
					// We only need the classpath of the emulator because this
					// runs on it
					__spec.classpath(
						((Jar)emuBase.getTasks().getByName("jar"))
							.getOutputs().getFiles(),
						((Jar)emuCore.getTasks().getByName("jar"))
							.getOutputs().getFiles(),
						RunNativeTask.__projectClassPath(emuBase),
						RunNativeTask.__projectClassPath(emuCore));
					
					// Main entry point for the emulator
					__spec.setMain("cc.squirreljme.emulator.vm.VMFactory");
				});
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/RunNativeTask.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import cc.squirreljme.plugin.SquirrelJMEPluginConfiguration;
import cc.squirreljme.plugin.swm.JavaMEMidlet;
import cc.squirreljme.plugin.swm.JavaMEMidletType;
import java.util.Objects;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.jvm.tasks.Jar;
import org.gradle.process.JavaExecSpec;

/**
 * Launches the program using the host system which is backed by the
 * base emulator.
 *
 * @since 2020/02/29
 */
public class RunNativeTask
	extends DefaultTask
{
	/**
	 * Initializes the task.
	 *
	 * @param __jar The JAR task.
	 * @since 2020/02/29
	 */
	@Inject
	public RunNativeTask(Jar __jar)
	{
		// Set details of this task
		this.setGroup("squirreljme");
		this.setDescription("Runs the program using the emulator.");
		
		// This only runs if this is an application
		this.onlyIf(this::__onlyIf);
		
		// Run the task accordingly
		this.doLast(new __ActionTask__());
		
		// This needs the JAR task and the emulation task
		this.dependsOn(__jar,
			(Callable<Object>)this::__findEmulatorJarTask);
	}
	
	/**
	 * Finds the emulator JAR task.
	 *
	 * @return The emulator JAR task.
	 * @since 2020/02/29
	 */
	private Object __findEmulatorJarTask()
	{
		return Objects.requireNonNull(this.getProject().getRootProject().
			findProject(":emulators:emulator-base"),
			"No emulator base?").getTasks().getByName("jar");
	}
	
	/**
	 * Only runs if these conditions are met.
	 *
	 * @param __task Checks this task.
	 * @return If this can run or not.
	 * @since 2020/02/29
	 */
	private boolean __onlyIf(Task __task)
	{
		// Only allow if an application!
		return SquirrelJMEPluginConfiguration.configuration(this.getProject())
			.swmType == JavaMEMidletType.APPLICATION;
	}
	
	/**
	 * Returns the project classpath.
	 *
	 * @param __project The project.
	 * @return The class path.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/29
	 */
	static Object __projectClassPath(Project __project)
		throws NullPointerException
	{
		if (__project == null)
			throw new NullPointerException("No project specified.");
		
		return __project.getConfigurations().
			getByName("runtimeClasspath").getFiles();
	}
	
	/**
	 * Performs the task action.
	 *
	 * @since 2020/02/29
	 */
	private class __ActionTask__
		implements Action<Task>
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/02/29
		 */
		@Override
		public void execute(Task __task)
		{
			// Get current and emulator projects
			Project project = RunNativeTask.this.getProject();
			Project emuBase = project.getRootProject().
				project(":emulators:emulator-base");
			
			// Need this to get the program details
			SquirrelJMEPluginConfiguration config =
				SquirrelJMEPluginConfiguration.configuration(project);
			
			// Execute program
			project.javaexec((JavaExecSpec __spec) ->
				{
					// Are we launching a MIDlet?
					JavaMEMidlet midlet = null;
					if (!config.midlets.isEmpty())
						midlet = config.midlets.get(0);
					
					// Which class do we launch?
					__spec.setMain((midlet != null ?
						"javax.microedition.midlet.__MainHandler__" :
						Objects.requireNonNull(config.mainClass,
						"No main class in project.")));
					
					// We need to tell the MIDlet launcher what our main entry
					// point is going to be
					if (midlet != null)
						__spec.args(midlet.mainClass);
					
					// Set the classpath needed
					__spec.classpath(
						((Jar)project.getTasks().getByName("jar"))
							.getOutputs().getFiles(),
						((Jar)emuBase.getTasks().getByName("jar"))
							.getOutputs().getFiles(),
						RunNativeTask.__projectClassPath(project),
						RunNativeTask.__projectClassPath(emuBase));
				});
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/__Input__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import java.nio.file.Path;

/**
 * Source file and its input/output.
 *
 * @since 2020/02/28
 */
final class __Input__
{
	/** The absolute path. */
	public final Path absolute;
	
	/** The relative path. */
	public final Path relative;
	
	/**
	 * Initializes the file information.
	 *
	 * @param __absolute The absolute path.
	 * @param __relative The relative path.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	__Input__(Path __absolute, Path __relative)
		throws NullPointerException
	{
		if (__absolute == null || __relative == null)
			throw new NullPointerException();
		
		this.absolute = __absolute;
		this.relative = __relative;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/28
	 */
	@Override
	public final String toString()
	{
		return String.format("{absolute=%s, relative=%s}",
			this.absolute, this.relative);
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/__Output__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

import java.nio.file.Path;

/**
 * The output for a task.
 *
 * @since 2020/02/28
 */
final class __Output__
{
	/** The input file. */
	public final __Input__ input;
	
	/** The output path. */
	public final Path output;
	
	/**
	 * Initializes the output path.
	 *
	 * @param __input The input path.
	 * @param __output The output path.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/28
	 */
	public __Output__(__Input__ __input, Path __output)
		throws NullPointerException
	{
		if (__input == null || __output == null)
			throw new NullPointerException();
		
		this.input = __input;
		this.output = __output;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/28
	 */
	@Override
	public final String toString()
	{
		return String.format("{input=%s, output=%s}",
			this.input, this.output);
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/tasks/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.tasks;

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

package cc.squirreljme.plugin.util;

/**
 * This represents the alphabet that is used for Base64.
 *
 * @since 2018/03/05
 */
public enum Base64Alphabet
{
	/** The basic and MIME alphabet. */
	BASIC('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='),
	
	/** The URL alphabet. */
	URL('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '='),
	
	/** End. */
	;
	
	/** The alphabet for the characters. */
	final char[] _alphabet;
	
	/**
	 * Initializes the alphabet.
	 *
	 * @param __alphabet The alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	Base64Alphabet(char... __alphabet)
		throws NullPointerException
	{
		if (__alphabet == null)
			throw new NullPointerException("NARG");
		
		this._alphabet = __alphabet;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/Base64Decoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;

/**
 * This decodes the base64 character set, ignoring invalid characters, and
 * provides the binary data for the input. If the padding character is reached
 * or if the input stream runs out of characters then EOF is triggered.
 *
 * @since 2018/03/05
 */
public final class Base64Decoder
	extends InputStream
{
	/** The source reader. */
	protected final Reader in;
	
	/** Ignore padding characters. */
	protected final boolean ignorepadding;
	
	/** The alphabet to use for decoding. */
	private final char[] _alphabet;
	
	/** The ASCII map for quick lookup. */
	private final byte[] _ascii;
	
	/** Output bytes to drain. */
	private final byte[] _drain =
		new byte[3];
	
	/** The current fill buffer. */
	private volatile int _buffer;
	
	/** The number of bits which are in the buffer. */
	private volatile int _bits;
	
	/** Has EOF been reached if the pad has been detected? */
	private volatile boolean _readeof;
	
	/** The current output drain position. */
	private volatile int _drained =
		-1;
	
	/** The maximum value for drained values. */
	private volatile int _drainedmax =
		-1;
	
	/**
	 * Initializes the decode the default MIME alphabet.
	 *
	 * @param __in The input set of characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/23
	 */
	public Base64Decoder(Reader __in)
	{
		this(__in, Base64Alphabet.BASIC);
	}
	
	/**
	 * Initializes the decoder using the specified alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars, false);
	}
	
	/**
	 * Initializes the decoder using the default alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars, boolean __ip)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __chars == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.erorr BD0g The alphabet to use for the base64
		// decoder must be 64 characters plus one padding character.
		// (The character count)}
		int n;
		if ((n = __chars.length) != 65)
			throw new IllegalArgumentException(String.format("BD0g %d", n));
		
		// Set
		this.in = __in;
		this.ignorepadding = __ip;
		this._alphabet = (__chars = __chars.clone());
		
		// Build ASCII map for quick in-range character lookup
		byte[] ascii = new byte[128];
		for (int i = 0; i < 128; i++)
			ascii[i] = -1;
		for (int i = 0; i < 65; i++)
		{
			int dx = __chars[i];
			if (dx < 128)
				ascii[dx] = (byte)i;
		}
		this._ascii = ascii;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		int drained = this._drained;
		
		// There are bytes which are ready and in the drain that we do not
		// need to block reading them?
		if (drained != -1)
			return this._drainedmax - drained;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		// If there is stuff to be drained, quickly drain that so we do not
		// need to go deeper into the heavier method
		int drained = this._drained;
		if (drained != -1)
		{
			// Read in drained character
			int rv = this._drain[drained++] & 0xFF;
			
			// Reached the drain limit?
			if (drained == this._drainedmax)
			{
				this._drained = -1;
				this._drainedmax = -1;
			}
			
			// Would still be drain
			else
				this._drained = drained;
			
			// Return the value
			return rv;
		}
		
		// Previously read EOF, so this will just return EOF
		if (this._readeof)
			return -1;
		
		// Otherwise decode and read
		byte[] next = new byte[1];
		for (;;)
		{
			int rc = this.read(next, 0, 1);
			
			// EOF?
			if (rc < 0)
				return -1;
			
			// Missed read
			else if (rc == 0)
				continue;
			
			return (next[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Did a previous read cause a padded EOF?
		boolean readeof = this._readeof;
		
		// Need lookups
		Reader in = this.in;
		boolean ignorepadding = this.ignorepadding;
		char[] alphabet = this._alphabet;
		byte[] ascii = this._ascii;
		byte[] drain = this._drain;
		
		// This buffer is filled into as needed when input characters are read
		int buffer = this._buffer,
			bits = this._bits,
			drained = this._drained,
			drainedmax = this._drainedmax;
		
		// Keep trying to fill bytes in
		int rv = 0;
		while (rv < __l)
		{
			// Still need to drain bytes away
			if (drained != -1 && drained < drainedmax)
			{
				// Drain it
				__b[__o++] = drain[drained++];
				rv++;
				
				// Drained all the characters
				if (drained == drainedmax)
					drained = drainedmax = -1;
				
				// Try again
				else
					continue;
			}
			
			// EOF was reached
			if (readeof)
				break;
			
			// Read in character and decode it
			int ch = in.read();
			
			// Is EOF?
			if (ch < 0)
			{
				// {@squirreljme.error BD01 Read EOF from input when there
				// were expected to be more characters or the ending padding
				// character. (The bits in the buffer)}
				if (bits != 0)
					throw new IOException("BD01 " + bits);
				
				// Did read EOF
				readeof = true;
				break;
			}
			
			// Determine the value of the character
			if (ch < 128)
				ch = ascii[ch];
			else
			{
				ch = -1;
				for (int i = 0; i < 65; i++)
					if (i == alphabet[i])
					{
						ch = i;
						break;
					}
			}
			
			// Invalid, ignore and continue
			if (ch == -1 || (ignorepadding && ch == 64))
				continue;
			
			// Decoded padding character
			else if (ch == 64)
			{
				// {@squirreljme.error BD02 Did not expect a padding character.
				// (The number of decoded bits in queue)}
				if (bits == 0 || bits == 24)
					throw new IOException("BD02 " + bits);
				
				// Only want to store a single extra byte since that is
				// all that is valid
				else if (bits < 16)
				{
					// {@squirreljme.error BD03 Expected another padding
					// character.}
					if (in.read() != alphabet[64])
						throw new IOException("BD03");
					
					drain[0] = (byte)(buffer >>> 4);
					
					drainedmax = 1;
				}
				
				// Otherwise there will be two characters to drain
				else
				{
					drain[0] = (byte)(buffer >>> 10);
					drain[1] = (byte)(buffer >>> 2);
					
					drainedmax = 2;
				}
				
				// Need to drain all
				drained = 0;
					
				// Clear the buffer
				buffer = bits = 0;
				
				// Did read EOF
				readeof = true;
			}
			
			// Normal data
			else
			{
				// Shift in six bits
				buffer <<= 6;
				buffer |= ch;
				bits += 6;
				
				// Drain and empty the buffer
				if (bits == 24)
				{
					// Fill the drain
					drain[0] = (byte)(buffer >>> 16);
					drain[1] = (byte)(buffer >>> 8);
					drain[2] = (byte)buffer;
					
					// Set these to drain
					drained = 0;
					drainedmax = 3;
					
					// Clear the buffer
					buffer = bits = 0;
				}
			}
		}
		
		// Store state for next run
		this._buffer = buffer;
		this._bits = bits;
		this._readeof = readeof;
		this._drained = drained;
		this._drainedmax = drainedmax;
		
		// Return the read count
		if (readeof && rv == 0)
			return -1;
		return rv;
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab)
		throws IllegalArgumentException, NullPointerException
	{
		return Base64Decoder.decode(__in, __ab, false);
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @param __ip Is padding ignored?
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab,
		boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __ab == null)
			throw new NullPointerException("NARG");
		
		// Wrap in a reader to decode
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			byte[] buf = new byte[32];
			
			// Loop handle bytes
			try (InputStream in = new Base64Decoder(
				new StringReader(__in), __ab, __ip))
			{
				for (;;)
				{
					int rc = in.read(buf);
					
					// EOF?
					if (rc < 0)
						break;
					
					// Copy
					baos.write(buf, 0, rc);
				}
			}
			
			// Return resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BD04 Could not decode the input string.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("BD04", e);
		}
	}
}

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

package cc.squirreljme.plugin.util;

import java.util.Arrays;

/**
 * This contains utilities which operate on character sequences.
 *
 * @since 2017/11/30
 */
public final class CharSequenceUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/30
	 */
	private CharSequenceUtils()
	{
	}
	
	/**
	 * Splits the specified character sequence using the given delimeter and
	 * returns all of the fields which are contained within. Extra whitespace
	 * within fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The sequence to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final CharSequence[] fieldSplit(char __delim,
		CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Get all indexes of that given character
		int[] ind = CharSequenceUtils.multipleIndexOf(__delim, __s);
		int delcount = ind.length;
		
		int n = delcount + 1;
		CharSequence[] rv = new CharSequence[n];
		for (int l = -1, r = 0, i = 0; i < n; i++, l++, r++)
			rv[i] = __s.subSequence((l >= 0 ? ind[l] + 1 : 0),
				(r < delcount ? ind[r] : __s.length()));
		
		return rv;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __s.length(); i < n; i++)
			if (__c == __s.charAt(i))
				return i;
		return -1;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// For optimization sort the input array to find characters faster
		__c = __c.clone();
		Arrays.sort(__c);
		
		// Forward to one which assumes sorted input
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		return CharSequenceUtils.firstIndex(__c.toCharArray(), __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Go through ever character
		for (int i = 0, n = __s.length(), y = __c.length; i < n; i++)
		{
			// Use binary search because it is faster than checking each
			// and every element
			char c = __s.charAt(i);
			if (Arrays.binarySearch(__c, c) >= 0)
				return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given sequence.
	 *
	 * @param __c The character to get the indexes for.
	 * @param __s The sequence to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		IntegerList list = new IntegerList();
		
		// Find every character index
		for (int i = 0, n = __s.length(), lastdx = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Add index to list if found
			if (c == __c)
				list.addInteger(i);
		}
		
		// Finish
		return list.toIntegerArray();
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/CommentReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.plugin.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

/**
 * This is used to read comments from a source code file.
 *
 * @since 2020/02/22
 */
public class CommentReader
	extends Reader
{
	/** The source reader. */
	protected final BufferedReader source;
	
	/** Extra character queue. */
	private final StringBuilder _queue =
		new StringBuilder();
	
	/** Line remainder. */
	private final StringBuilder _remainder =
		new StringBuilder();
	
	/** Are we in multi-line comment? */
	private boolean _inMultiLine;
	
	/**
	 * Initializes the comment reader.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public CommentReader(InputStream __in)
		throws NullPointerException
	{
		try
		{
			this.source = new BufferedReader(
				new InputStreamReader(__in, "utf-8"));
		}
		catch (UnsupportedEncodingException e)
		{
			throw new RuntimeException("UTF-8 is not supported?", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/22
	 */
	@Override
	public void close()
		throws IOException
	{
		this.source.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2002/02/22
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException
	{
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException();
		
		BufferedReader source = this.source;
		StringBuilder queue = this._queue;
		StringBuilder remainder = this._remainder;
		boolean inMultiLine = this._inMultiLine;
		
		// Constantly try to fill the output buffer
		int putCount = 0;
		while (putCount < __l)
		{
			// If there are characters in the queue, drain from it
			if (queue.length() > 0)
			{
				// Extract the first character
				char ch = queue.charAt(0);
				queue.deleteCharAt(0);
				
				// Place it in the output
				__c[__o++] = ch;
				putCount++;
				
				// Try again
				continue;
			}
			
			// Read the next source line
			String ln = (remainder.length() > 0 ? remainder.toString() :
				source.readLine());
			if (ln == null)
				return (putCount > 0 ? putCount : -1);
			
			// Always trim lines to remove extra clutter
			ln = ln.trim();
			
			// Always clear the remainder, since we might push it again later
			remainder.setLength(0);
			
			// The length of the line
			int len = ln.length();
			
			// Are we in a multi-line comment still?
			if (inMultiLine)
			{
				// This is likely a JavaDoc continuation so drop that
				if (ln.startsWith("* "))
					ln = ln.substring(2);
				
				// Length may have changed so recalculate it
				len = ln.length();
				
				// Find end of line
				int eml = ln.indexOf("*/");
				
				// There are no ending slashes, use entire line
				if (eml < 0)
					queue.append(ln);
				
				// Otherwise our multi-line is going to end and we need to
				// process the remainder of the line
				else
				{
					// Add starting chunk to the queue for output
					queue.append(ln, 0, eml);
					
					// Store the remainder of the line since we may still have
					// another comment on it
					remainder.append(ln, eml + 2, len);
					
					// Stop being in multi-line mode
					inMultiLine = false;
				}
			}
			
			// Normal line
			else
			{
				// Get potential start positions of lines
				int sng = ln.indexOf("//");
				int mul = ln.indexOf("/*");
				
				// Detect double star for JavaDoc
				if (mul >= 0)
				{
					int jdoc = ln.indexOf("/**", mul);
					if (jdoc >= 0)
						mul = jdoc;
				}
				
				// No comment on this line
				if (sng < 0 && mul < 0)
					continue;
				
				// Single line comment
				if (sng >= 0 && (mul < 0 || sng < mul))
				{
					// Add fragment to the queue
					queue.append(ln, sng + 2, len);
				}
				
				// Multi-line comment
				else
				{
					// Does the multi-line end on the same line?
					int eml = ln.indexOf("*/", mul + 2);
					if (eml > mul)
					{
						// Add the comment area to the queue
						queue.append(ln, mul + 2, eml);
						
						// Add the rest of the line to the remainder for
						// later processing
						remainder.append(ln, eml + 2, len);
					}
					
					// Does not, so keep reading
					else
					{
						// Now in a multi-line
						inMultiLine = true;
						
						// Add our comment into the queue
						queue.append(ln, mul + 2, len);
					}
				}
			}
		}
		
		// Store comment type for later runs
		this._inMultiLine = inMultiLine;
		
		// Return the number out placed characters
		return putCount;
	}
	
	/**
	 * Reads the entire file to a string.
	 *
	 * @param __sb The input buffer to write to.
	 * @return {@code __sb}.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/22
	 */
	public final StringBuilder readAll(StringBuilder __sb)
		throws IOException, NullPointerException
	{
		if (__sb == null)
			throw new NullPointerException();
		
		char[] buf = new char[512];
		for (;;)
		{
			int rc = this.read(buf, 0, 512);
			
			if (rc < 0)
				break;
			
			__sb.append(buf, 0, rc);
		}
		
		return __sb;
	}
	
	/**
	 * The type of comment being parsed.
	 *
	 * @since 2020/02/22
	 */
	private enum CommentType
	{
		/** No comment. */
		NONE,
		
		/** Single line comment. */
		SINGLE,
		
		/** Block comment. */
		BLOCK,
		
		/** End. */
		;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/ErrorListTokenizer.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
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
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.util;

import cc.squirreljme.plugin.SourceError;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.Deque;

/**
 * This is the tokenizer for error lists.
 *
 * @since 2020/03/01
 */
public class ErrorListTokenizer
	implements Closeable
{
	/** The tag used to detect errors. */
	public static final String _ERROR_TAG =
		"squirreljme.error";
	
	/** The internal tokenizer. */
	protected final StreamTokenizer tokenizer;
	
	/** The original stream. */
	protected final Reader reader;
	
	/** The original file name. */
	protected final Path fileName;
	
	/**
	 * Initializes the error list tokenizer.
	 *
	 * @param __fn The origin file name.
	 * @param __in The input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/03/01
	 */
	public ErrorListTokenizer(Path __fn, Reader __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// The original reader for input (for closing).
		this.reader = __in;
		this.fileName = __fn;
		
		// Create tokenizer over the stream
		StreamTokenizer tokenizer = new StreamTokenizer(__in);
		this.tokenizer = tokenizer;
		
		// Configure settings
		tokenizer.resetSyntax();
		tokenizer.eolIsSignificant(false);
		tokenizer.slashSlashComments(false);
		tokenizer.slashStarComments(false);
		tokenizer.wordChars('a', 'z');
		tokenizer.wordChars('A', 'Z');
		tokenizer.wordChars('.', '.');
		tokenizer.wordChars('0', '9');
		tokenizer.whitespaceChars('\0', ' ');
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/03/01
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.reader.close();
	}
	
	/**
	 * Returns the next error in the stream.
	 *
	 * @return The next error, or {@code null} if none remain.
	 * @throws IOException On read errors.
	 * @since 2020/03/01
	 */
	public final SourceError next()
		throws IOException
	{
		// Token stack for handling tokens
		Deque<String> stack = new ArrayDeque<>();
		
		// Keep reading tokens until we find the sequence as needed
		boolean withinBlock = false;
		boolean withinJavaDocTag = false;
		for (;;)
		{
			// Keep reading tokens until none are left
			String token = this.__nextToken();
			if (token == null)
				return null;
			
			//System.err.printf("Token: %s%n", token);
			
			// If we are not within a block, check for opening brace
			if (!withinBlock)
			{
				if (token.equals("{"))
					withinBlock = true;
				
				// Drop any tokens here, even the closing block
				continue;
			}
			
			// Check to see if this is the JavaDoc tag
			if (!withinJavaDocTag)
			{
				// If this is at then it is a tag definition
				if (token.equals("@"))
					withinJavaDocTag = true;
				
				// Otherwise just stop because it will not be
				else
					withinBlock = false;
				
				// Keep running
				continue;
			}
			
			// End of declared block
			if (token.equals("}"))
			{
				// Build result
				SourceError result = null;
				try
				{
					result = (!stack.isEmpty() &&
						"squirreljme.error".equals(stack.pollFirst()) ?
						new SourceError(stack, this.fileName) : null);
				}
				catch (IllegalArgumentException e)
				{
					// Ignore errors but still report them
					System.err.printf("Invalid error code %s in %s%n",
						stack, this.fileName);
				}
				
				// Reset state for next tag run
				stack.clear();
				withinBlock = withinJavaDocTag = false;
				
				// Return the parsed token
				if (result != null)
					return result;
				continue;
			}
			
			// Put token on the stack to evaluate it later
			stack.addLast(token);
		}
	}
	
	/**
	 * Returns the next token.
	 *
	 * @return The next token or {@code null}.
	 * @since 2020/03/01
	 */
	private String __nextToken()
		throws IOException
	{
		// Read in the next token
		StreamTokenizer tokenizer = this.tokenizer;
		int type = tokenizer.nextToken();
		
		// Single character
		if (type > 0)
			return Character.toString((char)type);
		
		// Quoted string
		else if (type == StreamTokenizer.TT_WORD)
			return tokenizer.sval;
		
		// Number
		else if (type == StreamTokenizer.TT_NUMBER)
			return Double.toString(tokenizer.nval);
		
		// EOF
		return null;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/IntegerList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.util;

import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/**
 * This is a list of integers which is backed by a primitive array rather than
 * boxed types.
 *
 * @since 2017/11/26
 */
public final class IntegerList
	extends AbstractList<Integer>
	implements RandomAccess
{
	/** The array growing size. */
	private static final int _GROW_SIZE =
		8;
	
	/** The internal integer list. */
	private volatile int[] _values;
	
	/** The number of values in the list. */
	private volatile int _size;
	
	/**
	 * Initializes an empty list.
	 *
	 * @since 2017/11/26
	 */
	public IntegerList()
	{
	}
	
	/**
	 * Initializes a list using the given collection of integers.
	 *
	 * @param __v The collection to source values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(Collection<Integer> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Iterate through collections
		int n = __v.size(), i = 0;
		int[] values = new int[n];
		for (Integer v : __v)
			values[i++] = v;
		
		// Set
		this._values = values;
		this._size = n;
	}
	
	/**
	 * Initializes a list using the given integer values from an array.
	 *
	 * @param __v The array of integers to use for values.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Defensive copy
		__v = __v.clone();
		
		// Simple set
		this._values = __v;
		this._size = __v.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean add(Integer __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return this.addInteger(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void add(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.addInteger(__i, __v);
	}
	
	/**
	 * Adds the specified integer to the list.
	 *
	 * @param __v The value to add.
	 * @return {@code true} if the list has changed.
	 * @since 2017/11/26
	 */
	public boolean addInteger(int __v)
	{
		this.addInteger(this._size, __v);
		return true;
	}
	
	/**
	 * Adds the specified integer to the list at the specified position.
	 *
	 * @param __i The index to add the value at.
	 * @param __v The value to add.
	 * @throws IndexOutOfBoundsException If the index to add it outside of
	 * the array bounds.
	 * @since 2017/11/26
	 */
	public void addInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i > this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Existing values
		boolean realloced = false;
		int[] values = this._values;
		int nvalues = (values == null ? 0 : values.length),
			size = this._size;
		
		// Need a larger array?
		if ((realloced = (size + 1 > nvalues)))
			if (values == null)
				values = new int[IntegerList._GROW_SIZE];
			else
				values = Arrays.copyOf(values, nvalues + IntegerList._GROW_SIZE);
		
		// Move all values up
		for (int o = size; o > __i; o++)
			values[o] = values[o - 1];
		
		// Set this index
		values[__i] = __v;
		size++;
		
		// Store new values
		if (realloced)
			this._values = values;
		this._size = size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void clear()
	{
		this._values = null;
		this._size = 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean contains(Object __a)
	{
		// Only contains integers
		if (!(__a instanceof Integer))
			return false;
		
		return this.containsInteger((Integer)__a);
	}
	
	/**
	 * Checks if the list contains the specified integer.
	 *
	 * @param __v The value to check.
	 * @return {@code true} if the list contains the given integer.
	 * @since 2017/11/26
	 */
	public boolean containsInteger(int __v)
	{
		return this.indexOfInteger(__v) >= 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer get(int __i)
		throws IndexOutOfBoundsException
	{
		return this.getInteger(__i);
	}
	
	/**
	 * Obtains the integer at the given index.
	 *
	 * @param __i The index to get.
	 * @return The integer at the given index.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int getInteger(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this._values[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int indexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.indexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int indexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int i = 0, n = values.length; i < n; i++)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean isEmpty()
	{
		return this._size == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int lastIndexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.lastIndexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer starting from
	 * the end of the list.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int lastIndexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int n = values.length, i = n - 1; i >= 0; i--)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean remove(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return false;
		
		int dx = this.indexOf(__a);
		if (dx < 0)
			return false;
		
		this.remove(dx);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer remove(int __a)
	{
		throw new Error("TODO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer set(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return this.setInteger(__i, __v);
	}
	
	/**
	 * Sets the integer at the specified index to the given value.
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int setInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		int[] values = this._values;
		int rv = values[__i];
		values[__i] = __v;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	/**
	 * Converts the integer list to an integer array.
	 *
	 * @return This list as an integer array.
	 * @since 2017/11/26
	 */
	public int[] toIntegerArray()
	{
		int[] values = this._values;
		int size = this._size;
		
		// Values would not be allocated
		if (size == 0)
			return new int[0];
		
		// Copy values
		int[] rv = new int[size];
		for (int i = 0; i < size; i++)
			rv[i] = values[i];
		return rv;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/MIMEFileDecoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

/**
 * This class is used to decode input streams which have been encoded in the
 * MIME Base64 format. This file format is genearted by {@code uuencode -m}.
 * This format usually begins with {@code begin-base64 mode filename} and
 * ends with the padding sequence {@code ====}.
 *
 * This class is not thread safe.
 *
 * @since 2018/03/05
 */
public final class MIMEFileDecoder
	extends InputStream
{
	/** The input base64 data. */
	protected Base64Decoder mime;
	
	/** The read mode. */
	private int _mode =
		Integer.MIN_VALUE;
	
	/** The read filename. */
	private String _filename;
	
	/**
	 * Initializes the MIME file decoder using the default encoding.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in)
		throws NullPointerException
	{
		this(new InputStreamReader(__in));
	}
	
	/**
	 * Initializes the MIME file decoder using the given encoding.
	 *
	 * @param __in The input source.
	 * @param __enc The encoding used.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(new InputStreamReader(__in, __enc));
	}
	
	/**
	 * Initializes the MIME file decoder from the given set of characters.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMEFileDecoder(Reader __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Directly wrap the reader with the MIME decoder which reads from
		// a source reader that is internally maintained
		this.mime = new Base64Decoder(new __SubReader__(__in));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		return this.mime.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.mime.close();
	}
	
	/**
	 * Returns the filename which was read.
	 *
	 * @return The read filename, {@code null} will be returned if it has not
	 * been read yet or has not been specified.
	 * @since 2018/03/05
	 */
	public final String filename()
	{
		return this._filename;
	}
	
	/**
	 * Returns the UNIX mode of the stream.
	 *
	 * @return The UNIX mode, a negative value will be returned if it has not
	 * been read yet.
	 * @since 2018/03/05
	 */
	public final int mode()
	{
		return this._mode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.mime.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.mime.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.mime.read(__b, __o, __l);
	}
	
	/**
	 * This is a sub-reader which handles parsing of the MIME header and
	 * otherwise just passing the data to the Base64Decoder instance.
	 *
	 * @since 2018/11/25
	 */
	private final class __SubReader__
		extends Reader
	{
		/** The line-by-line reader for data. */
		protected final BufferedReader in;
		
		/** The input character buffer. */
		private final StringBuilder _sb =
			new StringBuilder(80);
		
		/** The current read in the buffer. */
		private int _at;
		
		/** The current limit of the buffer. */
		private int _limit;
		
		/** Did we read the header? */
		private boolean _didheader;
		
		/** Did we read the footer? */
		private boolean _didfooter;
		
		/**
		 * Initializes the sub-reader for the MIME data.
		 *
		 * @param __in The source reader.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/24
		 */
		__SubReader__(Reader __in)
			throws NullPointerException
		{
			if (__in == null)
				throw new NullPointerException("NARG");
			
			this.in = new BufferedReader(__in, 80);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public void close()
			throws IOException
		{
			this.in.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read()
			throws IOException
		{
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Need to read more from the buffer
			int at = this._at,
				limit = this._limit;
			if (at >= limit)
			{
				// Read line next
				if (!this.__readNext())
					return -1;
				
				// Re-read
				at = this._at;
				limit = this._limit;
			}
			
			// Read the next character
			int rv = this._sb.charAt(at);
			this._at = at + 1;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			
			return this.read(__c, 0, __c.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c, int __o, int __l)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Where to read from
			StringBuilder sb = this._sb;
			int at = this._at,
				limit = this._limit;
			
			// Read in all characters
			int rv = 0;
			while (rv < __l)
			{
				// Need to read more?
				if (at >= limit)
				{
					// EOF?
					if (!this.__readNext())
						return (rv == 0 ? -1 : rv);
					
					// Re-read
					at = this._at;
					limit = this._limit;
				}
				
				// Read the next character
				__c[__o++] = sb.charAt(at++);
			}
			
			// Store new at position
			this._at = at;
			
			return rv;
		}
		
		/**
		 * Reads the header information.
		 *
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final void __readHeader()
			throws IOException
		{
			BufferedReader in = this.in;
			
			// {@squirreljme.error BD1k Unexpected end of file while trying
			// to read MIME header.}
			String ln = in.readLine();
			if (ln == null)
				throw new IOException("BD1k");
			
			// The header is in this format:
			// begin-base64 <unixmode> <filename>
			// {@squirreljme.error BD1l MIME encoded does not start with
			// MIME header.}
			if (!ln.startsWith("begin-base64"))
				throw new IOException("BD1l");
			
			// UNIX mode?
			int fs = ln.indexOf(' ');
			if (fs >= 0)
			{
				int ss = ln.indexOf(' ', fs + 1);
				
				// Decode octal mode bits
				MIMEFileDecoder.this._mode = Integer.parseInt(
					ln.substring(fs + 1, (ss < 0 ? ln.length() : ss)), 8);
				
				// Filename?
				if (ss >= 0)
					MIMEFileDecoder.this._filename =
						ln.substring(ss + 1);
			}
			
			// Set as read
			this._didheader = true;
		}
		
		/**
		 * Reads the next line into the character.
		 *
		 * @return If a line was read.
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final boolean __readNext()
			throws IOException
		{
			// {@squirreljme.error BD1m Unexpected EOF while read the MIME
			// file data.}
			String ln = this.in.readLine();
			if (ln == null)
				throw new IOException("BD1m");
			
			// End of MIME data?
			if (ln.equals("===="))
			{
				// Footer was read, so EOF now
				this._didfooter = true;
				
				// Was EOF
				return false;
			}
			
			// Fill buffer
			StringBuilder sb = this._sb;
			sb.setLength(0);
			sb.append(ln);
			
			// Set properties
			this._at = 0;
			this._limit = ln.length();
			
			// Was not EOF
			return true;
		}
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/NaturalComparator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Comparator;

/**
 * This is used to compare two values using their natural comparison.
 *
 * @since 2016/09/06
 */
public final class NaturalComparator<V>
	implements Comparator<V>
{
	/** The single instance. */
	private static Reference<NaturalComparator> _REF;
	
	/**
	 * Only one is ever needed.
	 *
	 * @since 2017/11/30
	 */
	private NaturalComparator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public int compare(V __a, V __b)
	{
		// Consider two nulls to be equal
		boolean na = (__a == null), nb = (__b == null);
		if (na && nb)
			return 0;
		
		// Nulls before non-null
		else if (na && !nb)
			return -1;
		else if (!na && nb)
			return 1;
		
		// Use standard comparison
		return ((Comparable<V>)__a).compareTo(__b);
	}
	
	/**
	 * Returns the natural comparator instance.
	 *
	 * @param <V> The type of value to compare.
	 * @return The instance of the natural comparator.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public static final <V> NaturalComparator<V> instance()
	{
		Reference<NaturalComparator> ref = NaturalComparator._REF;
		NaturalComparator rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			NaturalComparator._REF = new WeakReference<>((rv = new NaturalComparator()));
		
		// Return it
		return (NaturalComparator<V>)rv;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/StringUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.plugin.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * This class contains static methods which can be used for manipulating
 * strings.
 *
 * @since 2017/11/23
 */
public final class StringUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/23
	 */
	private StringUtils()
	{
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(char[] __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Parse string
		boolean dows = true;
		int lastdelim = -2;
		for (int i = 0, n = __s.length(), mark = 0; i <= n; i++)
		{
			// -1 is a special delimeter for the end of string because
			// otherwise if the string does not end in a delimeter it will not
			// be found
			int c = (i == n ? -1 : __s.charAt(i));
			
			// Is this a delimeter
			if (c == lastdelim || c == -1 || StringUtils.__indexOf(__delim, (char)c) >= 0)
			{
				// Remember last delimeter for potential speed
				lastdelim = c;
				
				// If reading delimeters, clear flag and mark
				// to remember the current index
				if (dows)
				{
					dows = false;
					mark = i;
				}
				
				// Otherwise end of sequence, generate string
				else
				{
					// Split out
					__out.add(__s.substring(mark, i));
					
					// Switch to handling delimeters
					dows = true;
				}
			}
			
			// If reading delimeters, clear flag and mark
			// to remember the current index, is not delimeters
			// here
			else if (dows)
			{
				dows = false;
				mark = i;
			}
		}
		
		// Return output always
		return __out;
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(String __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		return StringUtils.basicSplit(__delim.toCharArray(), __s, __out);
	}
	
	/**
	 * Splits the given string using the specified delimeter.
	 *
	 * @param __delim The delimeter to use.
	 * @param __s The string to split.
	 * @return The split string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/23
	 */
	public static final String[] basicSplit(char __delim, String __s)
	{
		return StringUtils.basicSplit(new char[]{__delim}, __s);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(char[] __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		Collection<String> rv = StringUtils.basicSplit(__delim, __s,
			new ArrayList<String>());
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(String __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		return StringUtils.basicSplit(__delim.toCharArray(), __s);
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within, any leading and trailing
	 * whitespace is trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplitAndTrim(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Split and trim
		String[] rv = StringUtils.fieldSplit(__delim, __s);
		for (int i = 0, n = rv.length; i < n; i++)
			rv[i] = rv[i].trim();
		return rv;
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within. Extra whitespace within
	 * fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplit(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		CharSequence[] xrv = CharSequenceUtils.fieldSplit(__delim, __s);
		return Arrays.<String, CharSequence>copyOf(xrv, xrv.length,
			String[].class);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given string.
	 *
	 * @param __c The character to get the indexes for.
	 * @param __s The string to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.multipleIndexOf(__c, __s);
	}
	
	/**
	 * Converts the specified string to lowercase ignoring locale, this uses
	 * {@link Character#toLowerCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The lowercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toLowerCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toLowerCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Converts the specified string to uppercase ignoring locale, this uses
	 * {@link Character#toUpperCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The uppercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toUpperCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toUpperCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Searches the input array to see if the given character is within the
	 * array.
	 *
	 * @param __a The array to check.
	 * @param __c The character to find in the array.
	 * @return The index of the character or {@code -1} if it was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	private static final int __indexOf(char[] __a, char __c)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			if (__c == __a[i])
				return i;
		return -1;
	}
}

Added buildSrc/src/main/java/cc/squirreljme/plugin/util/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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.plugin.util;

Added buildSrc/src/main/resources/META-INF/gradle-plugins/cc.squirreljme.plugin.properties.


1
+
implementation-class=cc.squirreljme.plugin.SquirrelJMEPlugin

Changes to building.mkd.

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













-
-
+
+
+
+
+
+










-
+
+











-
-
-
+
+
+



-
+

+
-
+
+

-
-
-
-
+
+
-
-
+

-
+










-
+

-
+
-
-
+
-
-
+
-
-
-
+
-

-
-
+
-

-
-
-
-
+

-
-
-
+
-
-
-
-

-
-
+
-

-
-
-
+
-
-
-
+
-
-
+
-

-
-
+
-

-
-
-
+
-
-
-
+
-

-
-
+
+
-
-
-
-
-
-
-
-
-
-

-
+

-
+

-
-
-
+

-
+

-
+
-
-
+
-
-
+
-

-
-
+
-
-
-
+

-
+







# Building

------------------------------------------------------------------------------

***Patience is required:***
***Currently SquirrelJME is in active development and although it can***
***run and produce binaries, there are limitations to consider.***
***Currently only a limited set of programs may be ran on SquirrelJME.***

------------------------------------------------------------------------------

SquirrelJME requires the following before it can be built:

 * Java 7 or newer Virtual Machine
 * Java 7 or newer Compiler
 * Java 8 or newer Virtual Machine and Compiler
 * C++ Compiler (Utilized for Testing)
   * Clang
   * GCC
   * Microsoft Visual Studio 2010 or newer
   * XCode

## Notes on Running

SquirrelJME uses a simplified error system which starts with a two capital
letter prefix followed by two digits and letters.

 * [List of Error Codes](http://multiphasicapps.net/uv/errors.mkd)

## Installing Java

SquirrelJME requires a Java 7 virtual machine in order to build itself.
SquirrelJME requires a Java 8 virtual machine in order to build itself. Gradle
is used however it is available through Gradle Wrapper.

### Common Linux Distributions

If you use a common and popular Linux distribution it likely has a JDK
available.

 * Arch
   * See <https://wiki.archlinux.org/index.php/Java>
 * Debian, Ubuntu, and derivatives
   * See <https://wiki.debian.org/Java>
   * One of the following depending on package availability
     * `apt-get install openjdk-7-jdk`
     * `apt-get install openjdk-8-jdk`
     * `apt-get install openjdk-9-jdk`
     * `apt-get install openjdk-8-jdk`
     * `apt-get install openjdk-9-jdk`
     * `apt-get install openjdk-11-jdk`
 * Gentoo
   * See <https://wiki.gentoo.org/wiki/Java>

### Oracle's JDK
### AdoptOpenJDK

AdoptOpenJDK is the recommended way to build and setup SquirrelJME as it has
Oracle's JDK supports the following (as of this writing):
long-term support and is easy to setup. You will need at least a Java 8
variant of AdoptOpenJDK.

 * Linux
 * Mac OS X
 * ReactOS (as Windows)
 * Solaris
 * <https://adoptopenjdk.net/releases.html?variant=openjdk8&jvmVariant=hotspot>

 * Windows
 * Wine (as Windows)
### Oracle's JDK

Oracle's Java JDK can be downloaded from:
Oracle's JDK supports modern systems and can be downloaded from:

 * <http://www.oracle.com/technetwork/java/javase/downloads/index.html>
 
Ensure that you **download and install** the ***JDK***.

If running on ReactOS/Windows/Wine, make sure that the `PATH` environment
variables refers to the JDK's binary directory:

 * `C:\Program Files\Java\jdk1.8.0_131\bin\`

# Bootstrap Build Environment
### IntelliJ IDEA (Optional)

The main interaction with the SquirrelJME build environment is with the build
SquirrelJME is developed on IntelliJ Ultimate, however Community Edition may
bootstrapper which initializes, compiles, and runs the build environment.

still be used. This makes development easier and more integrated along with
## System Specific

whatever code you write or contribute will match the style that is set in
Each system has a different interface to the bootstrap environment, beyond this
the remainder of it is the same regardless of the system used.

SquirrelJME.
### ReactOS and Windows

Oracle's Java JDK can be downloaded from:

 * <https://www.jetbrains.com/idea/>
 * <http://www.oracle.com/technetwork/java/javase/downloads/index.html>

The script used for building is `build.cmd` (referred to as `build` hereafter).
This requires the command prompt which may be accessed by running `cmd`.
This may be found in the start menu or may be accessed via **Windows Key + R**,
typing `cmd`, then hitting enter.
## Installing C++ Compiler

Recommended setup for running the environment, assuming SquirrelJME source
code is located in the example `c:\users\stephanie\desktop\squirreljme`:

### Common Linux Distributions
 * `cd c:\users\stephanie\temp`
 * `mkdir squirreljme-build`
 * `cd squirreljme-build`
 * `c:\users\stephanie\desktop\squirreljme\build.cmd`

### UNIX-Like: Linux, Mac OS X, Solaris, BSD, etc.

For the C++ Compiler which is needed for testing:
The script used for building is `build.sh` (referred to as `build` hereafter).

Recommended setup for running the environment, assuming SquirrelJME source
code is located in the example `/home/stephanie/squirreljme`:

 * Debian, Ubuntu, and derivatives
 * `cd /tmp`
 * `mkdir squirreljme-build`
 * `cd squirreljme-build`
   * `apt-get install build-essential g++`
 * `/home/stephanie/squirreljme/build.sh`

   * `apt-get install build-essential clang`
# Compiled SummerCoat ROM

This ROM file is required in order to work with SummerCoat or RatufaCoat.

### Windows
 * `build dist summercoatrom`

This will create a file called `squirreljme-summercoatrom.zip` which will
contain the needed ROM file `squirreljme.sqc`.

For Gradle to detect a C++ compiler, it needs either Microsoft Visual Studio
Additionally if all tests need to be built then a test ROM can be included as
well.

or a GCC installation via Cygwin.
 * `build dist summercoatrom-test`

# Shaded JARs for Java SE

More information is located at 
<https://docs.gradle.org/current/userguide/building_cpp_projects.html#windows>. 
Shaded SquirrelJME JARs are standalone JARs which can run on an existing
Java SE or Java ME system depending on which target it was built for.
Generally these JARs are just packaged by themselves and include the entire
set of libraries and applications from within SquirrelJME. These shaded JARs
are usually intended for demo projects and such. The JARs additionally are
pure Java code so they require a host Java VM. To contain the SquirrelJME
environment, an implementation of a virtual machine is used which is capable
of using and running the class library. This virtual machine has a speed
penalty because it is running the Java byte code itself however it is a
compatible environment.

## Building For Java SE
### Mac OS X

 * `build dist javase`  
You must install XCode, more information is here:

It is recommended that an out-of-tree build is performed (this means building
from another directory that is not in the SquirrelJME source tree). All the
commands pertain specifically to the build system itself.
 * <https://developer.apple.com/xcode/>

## Building for Java ME
# Build Enviromment

***NOTE:*** If the shaded JAR is not running on SquirrelJME, some features
The main interaction with the SquirrelJME build environment is with Gradle
will not be available for use. It should still run however.

which manages anything related to building and testing. All builds are
 * `build dist javame`

performed through Gradle Wrapper which is used as the following:
# RatufaCoat

Building the C based virtual machine depends on a C compiler.

 * Windows: `gradlew`
Note that you will need to build a separate SummerCoat ROM as above or
use a pre-existing one. If you are building for a standard C setup with no
graphical display or otherwise, to build the project you use make:
 * Others: `./gradlew`

 * `make`
Gradle uses tasks of which multiple may be specified accordingly.

## RetroArch

Building for RetroArch uses the `makefilelibretro` makefile. As such building
SquirrelJME for your current system involves using the alternative makefile.

 * `make`

Changes to changelog.mkd.

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
16
17
18
19
20
21
22


23
24

























25
26
27
28
29
30
31







-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







_Note that this is a work in progress and not everything will run, due to_
_the implementation being incomplete. However it does work and is proven to_
_work, which means progress can continue as such. Later releases of_
_SquirrelJME will always be an improvement over the older versions._

More detailed changes:

 * Build system
   * Builder
 * Modernized the build system to Gradle!
   * This will make it much easier to develop and allow for contributions!
     * Allow the build system to launch binaries in a VM even if they have no
       source code.
     * Handle cases during compilation if a dependency has no source code.
     * If an attempt is made to compile a binary with no source code, throw a
       new exception type indicating this rather than the generic failure
       exception because this case can be handled.
     * When shading JARs for distribution, ignore entries in JARs which are
       directories. Directories do not need to appear in the JAR, however they
       may still be implicit within ZIPs.
   * Launching
     * An alternative VM may be specified.
     * Correct cases where `NullPointerException` is thrown when a `Display`
       was initialized but was not yet claimed by any program.
     * The profiler snapshot can be written to a specific file.
     * System properties may be defined and passed to the launched program.
   * Started work on JavaDoc generation.
 * Tests
   * Adjusted the results in the logarithm test to adjust the ulp to what
     SquirrelJME generates. The results are still valid as it is valid to
     be within a 1 ulp range, however the test framework only supports
     exact values.
   * Added the missing _mimemessage_ file for the MIME file decoding test.
   * Allow tests to timeout so that they do not run forever in the event of
     some kind of deadlock.
   * Refactored the test framework to be easier to maintain.
 * Programs and Libraries
   * `cldc-compact`
     * Added a rehash indicator for the internal `__BucketMap__` so that
       `java.util.Hashtable` knows when a reorder was performed.
     * Added `java.util.Vector`, it was missing.
     * Added support for ISO-8859-15, this is the newer encoding with the
       Euro symbol.
77
78
79
80
81
82
83


84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
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







+
+








+







     * Implemented `java.util.LinkedList`.
     * Made the stack trace printed by `Throwable` much cleaner so that it
       takes up less screen space and is formatted a bit better.
     * Return values for `line.separator`, `microedition.encoding`,
       `microedition.configuration`, and `microedition.locale`.
   * `demo-hello`
     * Made the system properties array `final`.
   * `jblend-api`
     * Added API Stubs.
   * `launcher`
     * Added the system property `cc.squirreljme.autolaunch` to automatically
       launch a program once the program list is read.
     * When a program is launched, instead of saying just "Loading..." instead
       allow show the program which is being loaded in the title.
   * `media-api`
     * Add null media support for: players, and volume control.
   * `meep-midlet`
     * Allow a multi-threaded
     * Handle Konami's Mobile US games using a special system request.
     * Implement `MIDlet.checkPermission()`.
   * `meep-rms`
     * Added basic support for record stores.
   * `meep-swm`
     * Added proprietary `ExtendedTaskManager` interface which can be used
       to specify arguments, system properties, and console output alternatives
142
143
144
145
146
147
148









149
150
151
152
153
154
155
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142







+
+
+
+
+
+
+
+
+







       using SummerCoat it will result in the wrong class field being read
       from whatever class just happened to be set first.
     * Corrected parsing of the stack map table.
     * Removed `net.multiphasicapps.classfile.ExecutableCode`, it was not used.
   * `tool-profiler`
     * When writing the NPS snapshot, set a limit on how deep the stack can
       traverse in the event an infinite recursive method was profiled.
   * `vodafone-api`
     * Added API Stubs.
   * `zip`
     * Added `read(byte[])` which forwards to the more optimal function
       rather than the super-class which only performs single byte reads.
     * When reading entries where the size is fully known, if the uncompressed
       data size is fulfilled but there is still remaining compressed data
       (in the case where a zero byte file is compressed to two bytes),
       continue to read the compressed data to drain it out.
 * Compiler Backend
   * Added a bunch of string representations for class structures.
   * Created a stack-cached register based compiler for Java byte code.
   * Implemented a new tree based unit system for packages and classes.
   * `MergedPathSet` can be initialized by iterables now.
 * Virtual Machines
   * General
175
176
177
178
179
180
181

182
183
184
185
186
187
188
189
190
191
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179







+










     * New Virtual Machine, register based.
     * Vast improvements over SpringCoat, faster and slimmer.
   * RatufaCoat
     * New Virtual Machine, based off SummerCoat.
     * Fast and slim, written in C.
 * Cleanup
   * Removed the `test.sh` script, it was empty.
   * Removed unused scripts due to the Gradle refactor.

# 0.2.0 (December 25, 2018)

SquirrelJME's first release!

Note that this is a work in progress and not everything will run, due to
the implementation being incomplete. However it does work and is proven to
work, which means progress can continue as such. Later releases of SquirrelJME
will always be an improvement over the older versions.

Added config/checkstyle/checkstyle.xml.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE module PUBLIC
    "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
    "https://checktyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
	<module name="TreeWalker">
		<property name="tabWidth" value="4" />
		<module name="AvoidStarImport" />
	</module>
</module>

Added emulators/build.gradle.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
group = "cc.squirreljme.squirreljme.emulators"
description = "This module contains all of the emulators available for " +
	"running SquirrelJME. These run on top of Java SE itself."

subprojects
{
	apply plugin: "checkstyle"
}

Added emulators/emulator-base/build.gradle.
























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	// C++ needs to be first otherwise the build will break
	id "cpp-library"
	id "java-library"
	id "java-test-fixtures"
}

description = "This library provides the base support for testing and " +
	"running SquirrelJME on a Java SE host, which is normally not " +
	"capable of doing as such."

// Due to the combination of C++ and Java these dependencies have to be very
// specific in that they only refer to the Java or C++ portion. So
// "implementation" and "compile" cannot be used because the C++ library will
// try to use them during compilation.
dependencies
{
	// SquirrelJME just uses TestNG here since it is flexible enough to
	// support how SquirrelJME needs to be (testing more as if it were running
	// on the target device). Due to the flexibility it allows easier switching
	// from Java SE, SpringCoat, and SummerCoat
	compileClasspath "org.testng:testng:7.1.0"
	runtimeClasspath "org.testng:testng:7.1.0"

	// We need these two modules to obtain the SquirrelJME specific classes
	compileClasspath project(":modules:cldc-compact")
	compileClasspath project(":modules:cldc")
	compileClasspath project(":modules:common-vm")
	compileClasspath project(":modules:io")
	compileClasspath project(":modules:meep-swm")
	compileClasspath project(":modules:tac")
	compileClasspath project(":modules:tool-manifest-reader")
	compileClasspath project(":modules:zip")

	// And for run-time to be able to be ran
	runtimeClasspath project(":modules:cldc-compact")
	runtimeClasspath project(":modules:cldc")
	runtimeClasspath project(":modules:common-vm")
	runtimeClasspath project(":modules:io")
	runtimeClasspath project(":modules:meep-swm")
	runtimeClasspath project(":modules:tac")
	runtimeClasspath project(":modules:tool-manifest-reader")
	runtimeClasspath project(":modules:zip")
}

// We need the native library in the JAR before we can properly use it
// But we can compile the Java code just fine without it
jar {
	dependsOn "assembleRelease"

	from buildDir.toPath().resolve("lib").resolve("main").
		resolve("release").toFile()
	into "/"
}

Added emulators/emulator-base/enable-testing.gradle.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// This script is included so that the simulator and the other modules that
// need testing will work properly with the TestNG-based Simulator

dependencies
{
	// Need TestNG to run our tests
	testImplementation "org.testng:testng:7.1.0"

	// Needed to access all of the testing framework details
	testImplementation project(":modules:cldc-compact")
	testImplementation project(":modules:tac")
	testImplementation project(":modules:meep-midlet")
	testImplementation project(":emulators:emulator-base")
}

test
{
}

// Include Common Testing Configuration
apply from: project.rootProject.findProject(":emulators:emulator-base").
	projectDir.toPath().resolve("internal-shared-test-config.gradle").toFile()

Added emulators/emulator-base/internal-shared-test-config.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Our tests must be properly configured before they will work
test
{
	// SquirrelJME uses a different test framework, so we cannot rely on
	// Gradle to correctly pick it up
	scanForTestClasses = false
	includes = ['**/*Test', '**/Test*', '**/Do*',
		'*Test', 'Test*', 'Do*']
	
	// Make the standard streams always show
	testLogging.showStandardStreams = true

	// Use TestNG but make sure our custom factory is always picked up
	// so that tests work properly
	useTestNG(
		{ TestNGOptions options ->
			// Need to specify the suite which contains the factory so that
			// it will detect all of the tests and run them accordingly
			options.suiteXmlFiles = [project(":emulators:emulator-base").
				projectDir.toPath().resolve("src").resolve("main").
				resolve("resources").resolve("squirreljme.xml").toFile()]
		})
}

Added emulators/emulator-base/src/main/cpp/assembly.cpp.









































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* ---------------------------------------------------------------------------
// 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.
// --------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdint.h>

#include "jni.h"
#include "cc_squirreljme_jvm_Assembly.h"

// Recycle these methods because they do more advanced handling as needed
#define CAST_JOBJECT(v) \
	Java_cc_squirreljme_jvm_Assembly_pointerToObject(env, classy, (v))
#define CAST_JLONG(v) \
	Java_cc_squirreljme_jvm_Assembly_objectToPointer(env, classy, (v))

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLength__J
	(JNIEnv* env, jclass classy, jlong array)
{
	return Java_cc_squirreljme_jvm_Assembly_arrayLength__Ljava_lang_Object_2(
		env, classy, CAST_JOBJECT(array));
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLength__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject array)
{
	jint len;

	// Is null pointer
	if (array == NULL)
		return -1;

	// Only if the given class is an actual array can we get the length of it
	if (env->IsInstanceOf(array, env->FindClass("[Ljava/lang/Object;")) ||
		env->IsInstanceOf(array, env->FindClass("[Z")) ||
		env->IsInstanceOf(array, env->FindClass("[B")) ||
		env->IsInstanceOf(array, env->FindClass("[S")) ||
		env->IsInstanceOf(array, env->FindClass("[C")) ||
		env->IsInstanceOf(array, env->FindClass("[I")) ||
		env->IsInstanceOf(array, env->FindClass("[J")) ||
		env->IsInstanceOf(array, env->FindClass("[F")) ||
		env->IsInstanceOf(array, env->FindClass("[D")))
		return env->GetArrayLength((jarray)array);

	// Not an array
	return -1;
}

JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_longPack
	(JNIEnv* env, jclass classy, jint hi, jint lo)
{
	return ((((jlong)hi) & INT64_C(0xFFFFFFFF)) << INT64_C(32)) |
		((((jlong)lo)) & INT64_C(0xFFFFFFFF));
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_longUnpackHigh
	(JNIEnv* env, jclass classy, jlong value)
{
	return (jint)(value >> INT64_C(32));
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_longUnpackLow
	(JNIEnv* env, jclass classy, jlong value)
{
	return (jint)(value & INT64_C(0xFFFFFFFF));
}

JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_objectToPointer
	(JNIEnv* env, jclass classy, jobject object)
{
	jobject global;

	// Null references are just zero
	if (object == NULL)
		return (jlong)0;

	// Create global reference to object first
	global = env->NewGlobalRef(object);
	if (global == NULL)
	{
		env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"),
			"Could not box object as global.");
		return 0;
	}

	// We return the pointer to our global object
	return (jlong)((intptr_t)global);
}

JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_pointerToObject
	(JNIEnv* env, jclass classy, jlong object)
{
	// A pointer of zero is just NULL
	if (object == (jlong)0)
		return NULL;

	// We will always be returning the global reference because this is an
	// object that has a lifetime outside of the class
	return (jobject)((intptr_t)object);
}

Added emulators/emulator-base/src/main/cpp/nativebinding.cpp.




















































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* ---------------------------------------------------------------------------
// 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.
// --------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include "jni.h"
#include "cc_squirreljme_emulator_NativeBinding.h"
#include "cc_squirreljme_jvm_Assembly.h"

// Method handler for special functions
JNIEXPORT void JNICALL doNothing(JNIEnv* env, jclass classy);
JNIEXPORT jint JNICALL doNothingZeroI(JNIEnv* env, jclass classy);
JNIEXPORT void JNICALL notImplemented(JNIEnv* env, jclass classy);
JNIEXPORT void JNICALL restrictedFunction(JNIEnv* env, jclass classy);

// Glue for putting names together
#define GLUE_NAME(name) Java_cc_squirreljme_jvm_Assembly_sysCall##name

// Assembly method mappings
static const JNINativeMethod assemblyMethods[] =
{
	{"arrayLength", "(J)I", (void*)Java_cc_squirreljme_jvm_Assembly_arrayLength__J},
	{"arrayLength", "(Ljava/lang/Object;)I", (void*)Java_cc_squirreljme_jvm_Assembly_arrayLength__Ljava_lang_Object_2},
	{"arrayLengthSet", "(JI)V", (void*)restrictedFunction},
	{"arrayLengthSet", "(Ljava/lang/Object;I)V", (void*)restrictedFunction},
	{"atomicCompareGetAndSet", "(IIJ)I", (void*)notImplemented},
	{"atomicDecrementAndGet", "(J)I", (void*)notImplemented},
	{"atomicIncrement", "(J)V", (void*)notImplemented},
	{"breakpoint", "()V", (void*)doNothing},
	{"classInfoOfBoolean", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfBooleanPointer", "()J", (void*)restrictedFunction},
	{"classInfoOfByte", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfBytePointer", "()J", (void*)restrictedFunction},
	{"classInfoOfCharacter", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfCharacterPointer", "()J", (void*)restrictedFunction},
	{"classInfoOfDouble", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfDoublePointer", "()J", (void*)restrictedFunction},
	{"classInfoOfFloat", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfFloatPointer", "()J", (void*)restrictedFunction},
	{"classInfoOfInteger", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfIntegerPointer", "()J", (void*)restrictedFunction},
	{"classInfoOfLong", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfLongPointer", "()J", (void*)restrictedFunction},
	{"classInfoOfShort", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"classInfoOfShortPointer", "()J", (void*)restrictedFunction},
	{"doublePack", "(II)D", (void*)notImplemented},
	{"doubleToRawLongBits", "(D)J", (void*)notImplemented},
	{"doubleUnpackHigh", "(D)I", (void*)notImplemented},
	{"doubleUnpackLow", "(D)I", (void*)notImplemented},
	{"exceptionHandle", "()V", (void*)doNothing},
	{"floatToRawIntBits", "(F)I", (void*)notImplemented},
	{"intBitsToFloat", "(I)F", (void*)notImplemented},
	{"invoke", "(JJ)V", (void*)restrictedFunction},
	{"invoke", "(JJI)V", (void*)restrictedFunction},
	{"invoke", "(JJII)V", (void*)restrictedFunction},
	{"invoke", "(JJIII)V", (void*)restrictedFunction},
	{"invoke", "(JJIIII)V", (void*)restrictedFunction},
	{"invoke", "(JJIIIII)V", (void*)restrictedFunction},
	{"invoke", "(JJIIIIII)V", (void*)restrictedFunction},
	{"invoke", "(JJIIIIIII)V", (void*)restrictedFunction},
	{"invoke", "(JJIIIIIIII)V", (void*)restrictedFunction},
	{"invokeV", "(JJ)I", (void*)restrictedFunction},
	{"invokeV", "(JJI)I", (void*)restrictedFunction},
	{"invokeV", "(JJII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIIII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIIIII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIIIIII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIIIIIII)I", (void*)restrictedFunction},
	{"invokeV", "(JJIIIIIIII)I", (void*)restrictedFunction},
	{"invokeVL", "(JJ)J", (void*)restrictedFunction},
	{"invokeVL", "(JJI)J", (void*)restrictedFunction},
	{"invokeVL", "(JJII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIIII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIIIII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIIIIII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIIIIIII)J", (void*)restrictedFunction},
	{"invokeVL", "(JJIIIIIIII)J", (void*)restrictedFunction},
	{"longBitsToDouble", "(J)D", (void*)notImplemented},
	{"longPack", "(II)J", (void*)Java_cc_squirreljme_jvm_Assembly_longPack},
	{"longUnpackHigh", "(J)I", (void*)Java_cc_squirreljme_jvm_Assembly_longUnpackHigh},
	{"longUnpackLow", "(J)I", (void*)Java_cc_squirreljme_jvm_Assembly_longUnpackLow},
	{"memReadByte", "(JI)I", (void*)notImplemented},
	{"memReadInt", "(JI)I", (void*)notImplemented},
	{"memReadJavaInt", "(JI)I", (void*)notImplemented},
	{"memReadJavaLong", "(JI)J", (void*)notImplemented},
	{"memReadJavaShort", "(JI)I", (void*)notImplemented},
	{"memReadPointer", "(JI)J", (void*)notImplemented},
	{"memReadShort", "(JI)I", (void*)notImplemented},
	{"memWriteByte", "(JII)V", (void*)notImplemented},
	{"memWriteInt", "(JII)V", (void*)notImplemented},
	{"memWriteJavaInt", "(JII)V", (void*)notImplemented},
	{"memWriteJavaLong", "(JIJ)V", (void*)notImplemented},
	{"memWriteJavaShort", "(JII)V", (void*)notImplemented},
	{"memWritePointer", "(JIJ)V", (void*)notImplemented},
	{"memWriteShort", "(JII)V", (void*)notImplemented},
	{"monitorCountDecrementAndGetAtomic", "(J)I", (void*)restrictedFunction},
	{"monitorCountDecrementAndGetAtomic", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
	{"monitorCountIncrementAndGetAtomic", "(J)I", (void*)restrictedFunction},
	{"monitorCountIncrementAndGetAtomic", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
	{"monitorCountGetAtomic", "(J)I", (void*)restrictedFunction},
	{"monitorCountGetAtomic", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
	{"monitorCountSetAtomic", "(JI)V", (void*)restrictedFunction},
	{"monitorCountSetAtomic", "(Ljava/lang/Object;I)V", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomic", "(JJJ)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomic", "(Ljava/lang/Object;JJ)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomic", "(JLjava/lang/Thread;Ljava/lang/Thread;)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomic", "(Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Thread;)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomicPointer", "(JJJ)J", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomicPointer", "(Ljava/lang/Object;JJ)J", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomicPointer", "(JLjava/lang/Thread;Ljava/lang/Thread;)J", (void*)restrictedFunction},
	{"monitorOwnerCompareGetAndSetAtomicPointer", "(Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Thread;)J", (void*)restrictedFunction},
	{"monitorOwnerGetAtomic", "(J)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerGetAtomic", "(Ljava/lang/Object;)Ljava/lang/Thread;", (void*)restrictedFunction},
	{"monitorOwnerGetPointerAtomic", "(J)J", (void*)restrictedFunction},
	{"monitorOwnerGetPointerAtomic", "(Ljava/lang/Object;)J", (void*)restrictedFunction},
	{"monitorOwnerSetAtomic", "(JJ)V", (void*)restrictedFunction},
	{"monitorOwnerSetAtomic", "(JLjava/lang/Thread;)V", (void*)restrictedFunction},
	{"monitorOwnerSetAtomic", "(Ljava/lang/Object;J)V", (void*)restrictedFunction},
	{"monitorOwnerSetAtomic", "(Ljava/lang/Object;Ljava/lang/Thread;)V", (void*)restrictedFunction},
	{"objectGetClassInfo", "(J)Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"objectGetClassInfo", "(Ljava/lang/Object;)Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
	{"objectGetClassInfoPointer", "(J)J", (void*)restrictedFunction},
	{"objectGetClassInfoPointer", "(Ljava/lang/Object;)J", (void*)restrictedFunction},
	{"objectSetClassInfo", "(JJ)V", (void*)restrictedFunction},
	{"objectSetClassInfo", "(Ljava/lang/Object;J)V", (void*)restrictedFunction},
	{"objectSetClassInfo", "(JLcc/squirreljme/jvm/ClassInfo;)V", (void*)restrictedFunction},
	{"objectSetClassInfo", "(Ljava/lang/Object;Lcc/squirreljme/jvm/ClassInfo;)V", (void*)restrictedFunction},
	{"objectToPointer", "(Ljava/lang/Object;)J", (void*)Java_cc_squirreljme_jvm_Assembly_objectToPointer},
	{"objectToPointerRefQueue", "(Ljava/lang/Object;)J", (void*)Java_cc_squirreljme_jvm_Assembly_objectToPointer},
	{"pointerToObject", "(J)Ljava/lang/Object;", (void*)Java_cc_squirreljme_jvm_Assembly_pointerToObject},
	{"pointerToClassInfo", "(J)Lcc/squirreljme/jvm/ClassInfo;", (void*)Java_cc_squirreljme_jvm_Assembly_pointerToObject},
	{"poolLoad", "(JI)J", (void*)restrictedFunction},
	{"poolLoad", "(Ljava/lang/Object;I)J", (void*)restrictedFunction},
	{"poolStore", "(JIJ)V", (void*)restrictedFunction},
	{"poolStore", "(Ljava/lang/Object;IJ)V", (void*)restrictedFunction},
	{"refCount", "(J)V", (void*)doNothing},
	{"refCount", "(Ljava/lang/Object;)V", (void*)doNothing},
	{"refGetCount", "(J)I", (void*)restrictedFunction},
	{"refGetCount", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
	{"refSetCount", "(JI)V", (void*)restrictedFunction},
	{"refSetCount", "(Ljava/lang/Object;I)V", (void*)restrictedFunction},
	{"refUncount", "(J)V", (void*)doNothing},
	{"refUncount", "(Ljava/lang/Object;)V", (void*)doNothing},
	{"returnFrame", "()V", (void*)notImplemented},
	{"returnFrame", "(I)V", (void*)notImplemented},
	{"returnFrame", "(II)V", (void*)notImplemented},
	{"returnFrameLong", "(J)V", (void*)notImplemented},
	{"sizeOfBaseArray", "()I", (void*)notImplemented},
	{"sizeOfBaseObject", "()I", (void*)notImplemented},
	{"sizeOfPointer", "()I", (void*)notImplemented},
	{"specialGetExceptionRegister", "()Ljava/lang/Object;", (void*)restrictedFunction},
	{"specialGetExceptionRegisterThrowable", "()Ljava/lang/Throwable;", (void*)restrictedFunction},
	{"specialGetExceptionRegisterPointer", "()J", (void*)restrictedFunction},
	{"specialGetPoolRegister", "()Ljava/lang/Object;", (void*)restrictedFunction},
	{"specialGetPoolRegisterPointer", "()J", (void*)restrictedFunction},
	{"specialGetReturnRegister", "()I", (void*)restrictedFunction},
	{"specialGetReturnRegisterLong", "()J", (void*)restrictedFunction},
	{"specialGetStaticFieldRegister", "()J", (void*)restrictedFunction},
	{"specialGetThreadRegister", "()Ljava/lang/Thread;", (void*)restrictedFunction},
	{"specialGetThreadRegisterPointer", "()J", (void*)restrictedFunction},
	{"specialSetExceptionRegister", "(J)V", (void*)restrictedFunction},
	{"specialSetExceptionRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
	{"specialSetPoolRegister", "(J)V", (void*)restrictedFunction},
	{"specialSetPoolRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
	{"specialSetStaticFieldRegister", "(J)V", (void*)restrictedFunction},
	{"specialSetThreadRegister", "(J)V", (void*)restrictedFunction},
	{"specialSetThreadRegister", "(Ljava/lang/Thread;)V", (void*)restrictedFunction},

	// Un-Pure System Calls
	{"sysCall", "(S)V", (void*)GLUE_NAME(__S)},
	{"sysCall", "(SI)V", (void*)GLUE_NAME(__SI)},
	{"sysCall", "(SII)V", (void*)GLUE_NAME(__SII)},
	{"sysCall", "(SIII)V", (void*)GLUE_NAME(__SIII)},
	{"sysCall", "(SIIII)V", (void*)GLUE_NAME(__SIIII)},
	{"sysCall", "(SIIIII)V", (void*)GLUE_NAME(__SIIIII)},
	{"sysCall", "(SIIIIII)V", (void*)GLUE_NAME(__SIIIIII)},
	{"sysCall", "(SIIIIIII)V", (void*)GLUE_NAME(__SIIIIIII)},
	{"sysCall", "(SIIIIIIII)V", (void*)GLUE_NAME(__SIIIIIIII)},
	{"sysCallV", "(S)I", (void*)GLUE_NAME(V__S)},
	{"sysCallV", "(SI)I", (void*)GLUE_NAME(V__SI)},
	{"sysCallV", "(SII)I", (void*)GLUE_NAME(V__SII)},
	{"sysCallV", "(SIII)I", (void*)GLUE_NAME(V__SIII)},
	{"sysCallV", "(SIIII)I", (void*)GLUE_NAME(V__SIIII)},
	{"sysCallV", "(SIIIII)I", (void*)GLUE_NAME(V__SIIIII)},
	{"sysCallV", "(SIIIIII)I", (void*)GLUE_NAME(V__SIIIIII)},
	{"sysCallV", "(SIIIIIII)I", (void*)GLUE_NAME(V__SIIIIIII)},
	{"sysCallV", "(SIIIIIIII)I", (void*)GLUE_NAME(V__SIIIIIIII)},
	{"sysCallVL", "(S)J", (void*)GLUE_NAME(VL__S)},
	{"sysCallVL", "(SI)J", (void*)GLUE_NAME(VL__SI)},
	{"sysCallVL", "(SII)J", (void*)GLUE_NAME(VL__SII)},
	{"sysCallVL", "(SIII)J", (void*)GLUE_NAME(VL__SIII)},
	{"sysCallVL", "(SIIII)J", (void*)GLUE_NAME(VL__SIIII)},
	{"sysCallVL", "(SIIIII)J", (void*)GLUE_NAME(VL__SIIIII)},
	{"sysCallVL", "(SIIIIII)J", (void*)GLUE_NAME(VL__SIIIIII)},
	{"sysCallVL", "(SIIIIIII)J", (void*)GLUE_NAME(VL__SIIIIIII)},
	{"sysCallVL", "(SIIIIIIII)J", (void*)GLUE_NAME(VL__SIIIIIIII)},

	// Pure System Calls	{"sysCallP", "(S)V", (void*)GLUE_NAME(P__S)},
	{"sysCallP", "(SI)V", (void*)GLUE_NAME(P__SI)},
	{"sysCallP", "(SII)V", (void*)GLUE_NAME(P__SII)},
	{"sysCallP", "(SIII)V", (void*)GLUE_NAME(P__SIII)},
	{"sysCallP", "(SIIII)V", (void*)GLUE_NAME(P__SIIII)},
	{"sysCallP", "(SIIIII)V", (void*)GLUE_NAME(P__SIIIII)},
	{"sysCallP", "(SIIIIII)V", (void*)GLUE_NAME(P__SIIIIII)},
	{"sysCallP", "(SIIIIIII)V", (void*)GLUE_NAME(P__SIIIIIII)},
	{"sysCallP", "(SIIIIIIII)V", (void*)GLUE_NAME(P__SIIIIIIII)},
	{"sysCallPV", "(S)I", (void*)GLUE_NAME(PV__S)},
	{"sysCallPV", "(SI)I", (void*)GLUE_NAME(PV__SI)},
	{"sysCallPV", "(SII)I", (void*)GLUE_NAME(PV__SII)},
	{"sysCallPV", "(SIII)I", (void*)GLUE_NAME(PV__SIII)},
	{"sysCallPV", "(SIIII)I", (void*)GLUE_NAME(PV__SIIII)},
	{"sysCallPV", "(SIIIII)I", (void*)GLUE_NAME(PV__SIIIII)},
	{"sysCallPV", "(SIIIIII)I", (void*)GLUE_NAME(PV__SIIIIII)},
	{"sysCallPV", "(SIIIIIII)I", (void*)GLUE_NAME(PV__SIIIIIII)},
	{"sysCallPV", "(SIIIIIIII)I", (void*)GLUE_NAME(PV__SIIIIIIII)},
	{"sysCallPVL", "(S)J", (void*)GLUE_NAME(PVL__S)},
	{"sysCallPVL", "(SI)J", (void*)GLUE_NAME(PVL__SI)},
	{"sysCallPVL", "(SII)J", (void*)GLUE_NAME(PVL__SII)},
	{"sysCallPVL", "(SIII)J", (void*)GLUE_NAME(PVL__SIII)},
	{"sysCallPVL", "(SIIII)J", (void*)GLUE_NAME(PVL__SIIII)},
	{"sysCallPVL", "(SIIIII)J", (void*)GLUE_NAME(PVL__SIIIII)},
	{"sysCallPVL", "(SIIIIII)J", (void*)GLUE_NAME(PVL__SIIIIII)},
	{"sysCallPVL", "(SIIIIIII)J", (void*)GLUE_NAME(PVL__SIIIIIII)},
	{"sysCallPVL", "(SIIIIIIII)J", (void*)GLUE_NAME(PVL__SIIIIIIII)}
};

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
	JNIEnv* env;

	// Used to indicate that something might be happened
	fprintf(stderr, "SquirrelJME Native Bindings Initializing...\n");

	// Support Java 7!
	return JNI_VERSION_1_6;
}

JNIEXPORT void JNICALL doNothing(JNIEnv* env, jclass classy)
{
}

JNIEXPORT jint JNICALL doNothingZeroI(JNIEnv* env, jclass classy)
{
	return 0;
}

JNIEXPORT void JNICALL notImplemented(JNIEnv* env, jclass classy)
{
	fprintf(stderr, "Not implemented: %s.\n", __func__);
	env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"),
		__func__);
}

JNIEXPORT void JNICALL restrictedFunction(JNIEnv* env, jclass classy)
{
	fprintf(stderr, "Restricted function: %s.\n", __func__);
	env->ThrowNew(env->FindClass("java/lang/Error"),
		__func__);
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_emulator_NativeBinding__1_1bindMethods
	(JNIEnv* env, jclass classy)
{
	return env->RegisterNatives(env->FindClass("cc/squirreljme/jvm/Assembly"),
		assemblyMethods, sizeof(assemblyMethods) / sizeof(JNINativeMethod));
}

Added emulators/emulator-base/src/main/cpp/syscall.cpp.




























































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* ---------------------------------------------------------------------------
// 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.
// --------------------------------------------------------------------------*/

#include <stdio.h>

#include "jni.h"
#include "cc_squirreljme_jvm_Assembly.h"

/***************************** ACTUAL SYSTEM CALLS ***************************/

JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	jclass jvmFunctionClassy;
	jmethodID jvmSystemCallMethod;

	// Locate class
	jvmFunctionClassy = env->FindClass("cc/squirreljme/jvm/JVMFunction");

	if (jvmFunctionClassy == NULL)
	{
		env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
			"Could not find JVMFunction class.");
		return 0;
	}

	// Locate method
	jvmSystemCallMethod = env->GetStaticMethodID(
		jvmFunctionClassy, "jvmSystemCall", "(SIIIIIIII)J");

	if (jvmSystemCallMethod == NULL)
	{
		env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
			"Could not find JVMFunction.jvmSystemCall method.");
		return 0;
	}

	// These are un-pure system calls and as such will call jvmSystemCall
	// to handle the system call
	return env->CallStaticLongMethod(jvmFunctionClassy, jvmSystemCallMethod,
		si, a, b, c, d, e, f, g, h);
}


JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	jclass emulatorAssemblyClassy;
	jmethodID emulatorSystemCallClassy;

	// Locate class
	emulatorAssemblyClassy = env->FindClass(
		"cc/squirreljme/emulator/EmulatorAssembly");

	if (emulatorAssemblyClassy == NULL)
	{
		env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
			"Could not find EmulatorAssembly class.");
		return 0;
	}

	// Locate method
	emulatorSystemCallClassy = env->GetStaticMethodID(
		emulatorAssemblyClassy, "systemCall", "(SIIIIIIII)J");

	if (emulatorSystemCallClassy == NULL)
	{
		env->ThrowNew(env->FindClass("java/lang/RuntimeException"),
			"Could not find EmulatorAssembly.systemCall method.");
		return 0;
	}

	// Handle system call
	switch (si)
	{
			// System call not implemented in native code, forward to Java
			// based handler.
		default:
			return env->CallStaticLongMethod(emulatorAssemblyClassy,
				emulatorSystemCallClassy, si, a, b, c, d, e, f, g, h);
	}
}

/*************************** FINAL LEVEL FORWARDED ***************************/

JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIIIII(
		env, classy, si, a, b, c, d, e, f, g, h);
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	return (jint)Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIIIII(
		env, classy, si, a, b, c, d, e, f, g, h);
}

JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIIIII(
		env, classy, si, a, b, c, d, e, f, g, h);
}

JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort si, jint a, jint b, jint c, jint d,
	jint e, jint f, jint g, jint h)
{
	return (jint)Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIIIII(
		env, classy, si, a, b, c, d, e, f, g, h);
}

/*************************** FORWARDED SYSTEM CALLS **************************/

// Declaration of arguments
#define ARGDECL_ZERO JNIEnv* env, jclass classy, jshort si
#define ARGDECL_ONE ARGDECL_ZERO, jint a
#define ARGDECL_TWO ARGDECL_ONE, jint b
#define ARGDECL_THREE ARGDECL_TWO, jint c
#define ARGDECL_FOUR ARGDECL_THREE, jint d
#define ARGDECL_FIVE ARGDECL_FOUR, jint e
#define ARGDECL_SIX ARGDECL_FIVE, jint f
#define ARGDECL_SEVEN ARGDECL_SIX, jint g
#define ARGDECL_EIGHT ARGDECL_SEVEN, jint h

// Arguments to forward to the other function
#define ARGBASE_BASE	env, classy, si
#define ARGPASS_ZERO	ARGBASE_BASE, 0, 0, 0, 0, 0, 0, 0, 0
#define ARGPASS_ONE		ARGBASE_BASE, a, 0, 0, 0, 0, 0, 0, 0
#define ARGPASS_TWO		ARGBASE_BASE, a, b, 0, 0, 0, 0, 0, 0
#define ARGPASS_THREE	ARGBASE_BASE, a, b, c, 0, 0, 0, 0, 0
#define ARGPASS_FOUR	ARGBASE_BASE, a, b, c, d, 0, 0, 0, 0
#define ARGPASS_FIVE	ARGBASE_BASE, a, b, c, d, e, 0, 0, 0
#define ARGPASS_SIX		ARGBASE_BASE, a, b, c, d, e, f, 0, 0
#define ARGPASS_SEVEN	ARGBASE_BASE, a, b, c, d, e, f, g, 0
#define ARGPASS_EIGHT	ARGBASE_BASE, a, b, c, d, e, f, g, h

// Returning a value or not?
#define RETURN return
#define NO_RETURN

// Glues name together
#define GLUE_NAME(name) Java_cc_squirreljme_jvm_Assembly_sysCall##name

// Builds the entire declaration
#define BUILD(returnToken, returnType, name, toName, argDecl, argPass) \
	JNIEXPORT returnType JNICALL GLUE_NAME(name) \
		(argDecl) \
	{ \
		returnToken GLUE_NAME(toName) (argPass); \
	}

BUILD(NO_RETURN, void, __S, __SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(NO_RETURN, void, __SI, __SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(NO_RETURN, void, __SII, __SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(NO_RETURN, void, __SIII, __SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(NO_RETURN, void, __SIIII, __SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(NO_RETURN, void, __SIIIII, __SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(NO_RETURN, void, __SIIIIII, __SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(NO_RETURN, void, __SIIIIIII, __SIIIIIIII, ARGDECL_SEVEN, ARGPASS_SEVEN)

BUILD(RETURN, jint, V__S, V__SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(RETURN, jint, V__SI, V__SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(RETURN, jint, V__SII, V__SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(RETURN, jint, V__SIII, V__SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(RETURN, jint, V__SIIII, V__SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(RETURN, jint, V__SIIIII, V__SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(RETURN, jint, V__SIIIIII, V__SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(RETURN, jint, V__SIIIIIII, V__SIIIIIIII, ARGDECL_SEVEN, ARGPASS_SEVEN)

BUILD(RETURN, jlong, VL__S, VL__SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(RETURN, jlong, VL__SI, VL__SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(RETURN, jlong, VL__SII, VL__SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(RETURN, jlong, VL__SIII, VL__SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(RETURN, jlong, VL__SIIII, VL__SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(RETURN, jlong, VL__SIIIII, VL__SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(RETURN, jlong, VL__SIIIIII, VL__SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(RETURN, jlong, VL__SIIIIIII, VL__SIIIIIIII, ARGDECL_SEVEN, ARGPASS_SEVEN)

BUILD(NO_RETURN, void, P__S, P__SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(NO_RETURN, void, P__SI, P__SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(NO_RETURN, void, P__SII, P__SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(NO_RETURN, void, P__SIII, P__SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(NO_RETURN, void, P__SIIII, P__SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(NO_RETURN, void, P__SIIIII, P__SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(NO_RETURN, void, P__SIIIIII, P__SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(NO_RETURN, void, P__SIIIIIII, P__SIIIIIIII, ARGDECL_SEVEN, ARGPASS_SEVEN)

BUILD(RETURN, jint, PV__S, PV__SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(RETURN, jint, PV__SI, PV__SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(RETURN, jint, PV__SII, PV__SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(RETURN, jint, PV__SIII, PV__SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(RETURN, jint, PV__SIIII, PV__SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(RETURN, jint, PV__SIIIII, PV__SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(RETURN, jint, PV__SIIIIII, PV__SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(RETURN, jint, PV__SIIIIIII, PV__SIIIIIIII, ARGDECL_SEVEN, ARGPASS_SEVEN)

BUILD(RETURN, jlong, PVL__S, PVL__SIIIIIIII, ARGDECL_ZERO, ARGPASS_ZERO)
BUILD(RETURN, jlong, PVL__SI, PVL__SIIIIIIII, ARGDECL_ONE, ARGPASS_ONE)
BUILD(RETURN, jlong, PVL__SII, PVL__SIIIIIIII, ARGDECL_TWO, ARGPASS_TWO)
BUILD(RETURN, jlong, PVL__SIII, PVL__SIIIIIIII, ARGDECL_THREE, ARGPASS_THREE)
BUILD(RETURN, jlong, PVL__SIIII, PVL__SIIIIIIII, ARGDECL_FOUR, ARGPASS_FOUR)
BUILD(RETURN, jlong, PVL__SIIIII, PVL__SIIIIIIII, ARGDECL_FIVE, ARGPASS_FIVE)
BUILD(RETURN, jlong, PVL__SIIIIII, PVL__SIIIIIIII, ARGDECL_SIX, ARGPASS_SIX)
BUILD(RETURN, jlong, PVL__SIIIIIII, PVL__SIIIIIIII,
	ARGDECL_SEVEN, ARGPASS_SEVEN)

Added emulators/emulator-base/src/main/headers/cc_squirreljme_emulator_NativeBinding.h.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class cc_squirreljme_emulator_NativeBinding */

#ifndef _Included_cc_squirreljme_emulator_NativeBinding
#define _Included_cc_squirreljme_emulator_NativeBinding
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     cc_squirreljme_emulator_NativeBinding
 * Method:    __bindMethods
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_emulator_NativeBinding__1_1bindMethods
  (JNIEnv *, jclass);

#ifdef __cplusplus
}
#endif
#endif

Added emulators/emulator-base/src/main/headers/cc_squirreljme_jvm_Assembly.h.






























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class cc_squirreljme_jvm_Assembly */

#ifndef _Included_cc_squirreljme_jvm_Assembly
#define _Included_cc_squirreljme_jvm_Assembly
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    arrayLength
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLength__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    arrayLength
 * Signature: (Ljava/lang/Object;)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLength__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    arrayLengthSet
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLengthSet__JI
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    arrayLengthSet
 * Signature: (Ljava/lang/Object;I)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_arrayLengthSet__Ljava_lang_Object_2I
	(JNIEnv* env, jclass classy, jobject, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    atomicCompareGetAndSet
 * Signature: (IIJ)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_atomicCompareGetAndSet
	(JNIEnv* env, jclass classy, jint, jint, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    atomicDecrementAndGet
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_atomicDecrementAndGet
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    atomicIncrement
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_atomicIncrement
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    breakpoint
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_breakpoint
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfBoolean
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfBoolean
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfBooleanPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfBooleanPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfByte
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfByte
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfBytePointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfBytePointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfCharacter
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfCharacter
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfCharacterPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfCharacterPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfDouble
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfDouble
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfDoublePointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfDoublePointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfFloat
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfFloat
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfFloatPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfFloatPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfInteger
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfInteger
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfIntegerPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfIntegerPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfLong
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfLong
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfLongPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfLongPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfShort
 * Signature: ()Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfShort
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    classInfoOfShortPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_classInfoOfShortPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    doublePack
 * Signature: (II)D
 */
JNIEXPORT jdouble JNICALL Java_cc_squirreljme_jvm_Assembly_doublePack
	(JNIEnv* env, jclass classy, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    doubleToRawLongBits
 * Signature: (D)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_doubleToRawLongBits
	(JNIEnv* env, jclass classy, jdouble);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    doubleUnpackHigh
 * Signature: (D)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_doubleUnpackHigh
	(JNIEnv* env, jclass classy, jdouble);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    doubleUnpackLow
 * Signature: (D)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_doubleUnpackLow
	(JNIEnv* env, jclass classy, jdouble);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    exceptionHandle
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_exceptionHandle
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    floatToRawIntBits
 * Signature: (F)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_floatToRawIntBits
	(JNIEnv* env, jclass classy, jfloat);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    intBitsToFloat
 * Signature: (I)F
 */
JNIEXPORT jfloat JNICALL Java_cc_squirreljme_jvm_Assembly_intBitsToFloat
	(JNIEnv* env, jclass classy, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJ
	(JNIEnv* env, jclass classy, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJI
	(JNIEnv* env, jclass classy, jlong, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invoke
 * Signature: (JJIIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_invoke__JJIIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJ)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJ
	(JNIEnv* env, jclass classy, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJI
	(JNIEnv* env, jclass classy, jlong, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeV
 * Signature: (JJIIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_invokeV__JJIIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJ)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJ
	(JNIEnv* env, jclass classy, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJI
	(JNIEnv* env, jclass classy, jlong, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    invokeVL
 * Signature: (JJIIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_invokeVL__JJIIIIIIII
	(JNIEnv* env, jclass classy, jlong, jlong, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    longBitsToDouble
 * Signature: (J)D
 */
JNIEXPORT jdouble JNICALL Java_cc_squirreljme_jvm_Assembly_longBitsToDouble
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    longPack
 * Signature: (II)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_longPack
	(JNIEnv* env, jclass classy, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    longUnpackHigh
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_longUnpackHigh
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    longUnpackLow
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_longUnpackLow
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadByte
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_memReadByte
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadInt
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_memReadInt
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadJavaInt
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_memReadJavaInt
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadJavaLong
 * Signature: (JI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_memReadJavaLong
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadJavaShort
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_memReadJavaShort
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadPointer
 * Signature: (JI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_memReadPointer
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memReadShort
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_memReadShort
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteByte
 * Signature: (JII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteByte
	(JNIEnv* env, jclass classy, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteInt
 * Signature: (JII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteInt
	(JNIEnv* env, jclass classy, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteJavaInt
 * Signature: (JII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteJavaInt
	(JNIEnv* env, jclass classy, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteJavaLong
 * Signature: (JIJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteJavaLong
	(JNIEnv* env, jclass classy, jlong, jint, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteJavaShort
 * Signature: (JII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteJavaShort
	(JNIEnv* env, jclass classy, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWritePointer
 * Signature: (JIJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWritePointer
	(JNIEnv* env, jclass classy, jlong, jint, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    memWriteShort
 * Signature: (JII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_memWriteShort
	(JNIEnv* env, jclass classy, jlong, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountDecrementAndGetAtomic
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountDecrementAndGetAtomic__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountDecrementAndGetAtomic
 * Signature: (Ljava/lang/Object;)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountDecrementAndGetAtomic__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountIncrementAndGetAtomic
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountIncrementAndGetAtomic__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountIncrementAndGetAtomic
 * Signature: (Ljava/lang/Object;)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountIncrementAndGetAtomic__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountGetAtomic
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountGetAtomic__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountGetAtomic
 * Signature: (Ljava/lang/Object;)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountGetAtomic__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountSetAtomic
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountSetAtomic__JI
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorCountSetAtomic
 * Signature: (Ljava/lang/Object;I)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorCountSetAtomic__Ljava_lang_Object_2I
	(JNIEnv* env, jclass classy, jobject, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomic
 * Signature: (JJJ)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomic__JJJ
	(JNIEnv* env, jclass classy, jlong, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomic
 * Signature: (Ljava/lang/Object;JJ)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomic__Ljava_lang_Object_2JJ
	(JNIEnv* env, jclass classy, jobject, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomic
 * Signature: (JLjava/lang/Thread;Ljava/lang/Thread;)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomic__JLjava_lang_Thread_2Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jlong, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomic
 * Signature: (Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Thread;)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomic__Ljava_lang_Object_2Ljava_lang_Thread_2Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jobject, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomicPointer
 * Signature: (JJJ)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomicPointer__JJJ
	(JNIEnv* env, jclass classy, jlong, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomicPointer
 * Signature: (Ljava/lang/Object;JJ)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomicPointer__Ljava_lang_Object_2JJ
	(JNIEnv* env, jclass classy, jobject, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomicPointer
 * Signature: (JLjava/lang/Thread;Ljava/lang/Thread;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomicPointer__JLjava_lang_Thread_2Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jlong, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerCompareGetAndSetAtomicPointer
 * Signature: (Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Thread;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerCompareGetAndSetAtomicPointer__Ljava_lang_Object_2Ljava_lang_Thread_2Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jobject, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerGetAtomic
 * Signature: (J)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerGetAtomic__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerGetAtomic
 * Signature: (Ljava/lang/Object;)Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerGetAtomic__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerGetPointerAtomic
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerGetPointerAtomic__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerGetPointerAtomic
 * Signature: (Ljava/lang/Object;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerGetPointerAtomic__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerSetAtomic
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerSetAtomic__JJ
	(JNIEnv* env, jclass classy, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerSetAtomic
 * Signature: (JLjava/lang/Thread;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerSetAtomic__JLjava_lang_Thread_2
	(JNIEnv* env, jclass classy, jlong, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerSetAtomic
 * Signature: (Ljava/lang/Object;J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerSetAtomic__Ljava_lang_Object_2J
	(JNIEnv* env, jclass classy, jobject, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    monitorOwnerSetAtomic
 * Signature: (Ljava/lang/Object;Ljava/lang/Thread;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_monitorOwnerSetAtomic__Ljava_lang_Object_2Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectGetClassInfo
 * Signature: (J)Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_objectGetClassInfo__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectGetClassInfo
 * Signature: (Ljava/lang/Object;)Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_objectGetClassInfo__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectGetClassInfoPointer
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_objectGetClassInfoPointer__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectGetClassInfoPointer
 * Signature: (Ljava/lang/Object;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_objectGetClassInfoPointer__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectSetClassInfo
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_objectSetClassInfo__JJ
	(JNIEnv* env, jclass classy, jlong, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectSetClassInfo
 * Signature: (Ljava/lang/Object;J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_objectSetClassInfo__Ljava_lang_Object_2J
	(JNIEnv* env, jclass classy, jobject, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectSetClassInfo
 * Signature: (JLcc/squirreljme/jvm/ClassInfo;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_objectSetClassInfo__JLcc_squirreljme_jvm_ClassInfo_2
	(JNIEnv* env, jclass classy, jlong, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectSetClassInfo
 * Signature: (Ljava/lang/Object;Lcc/squirreljme/jvm/ClassInfo;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_objectSetClassInfo__Ljava_lang_Object_2Lcc_squirreljme_jvm_ClassInfo_2
	(JNIEnv* env, jclass classy, jobject, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectToPointer
 * Signature: (Ljava/lang/Object;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_objectToPointer
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    objectToPointerRefQueue
 * Signature: (Ljava/lang/Object;)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_objectToPointerRefQueue
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    pointerToObject
 * Signature: (J)Ljava/lang/Object;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_pointerToObject
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    pointerToClassInfo
 * Signature: (J)Lcc/squirreljme/jvm/ClassInfo;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_pointerToClassInfo
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    poolLoad
 * Signature: (JI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_poolLoad__JI
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    poolLoad
 * Signature: (Ljava/lang/Object;I)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_poolLoad__Ljava_lang_Object_2I
	(JNIEnv* env, jclass classy, jobject, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    poolStore
 * Signature: (JIJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_poolStore__JIJ
	(JNIEnv* env, jclass classy, jlong, jint, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    poolStore
 * Signature: (Ljava/lang/Object;IJ)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_poolStore__Ljava_lang_Object_2IJ
	(JNIEnv* env, jclass classy, jobject, jint, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refCount
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refCount__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refCount
 * Signature: (Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refCount__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refGetCount
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_refGetCount__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refGetCount
 * Signature: (Ljava/lang/Object;)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_refGetCount__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refSetCount
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refSetCount__JI
	(JNIEnv* env, jclass classy, jlong, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refSetCount
 * Signature: (Ljava/lang/Object;I)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refSetCount__Ljava_lang_Object_2I
	(JNIEnv* env, jclass classy, jobject, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refUncount
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refUncount__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    refUncount
 * Signature: (Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_refUncount__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    returnFrame
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_returnFrame__
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    returnFrame
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_returnFrame__I
	(JNIEnv* env, jclass classy, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    returnFrame
 * Signature: (II)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_returnFrame__II
	(JNIEnv* env, jclass classy, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    returnFrameLong
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_returnFrameLong
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sizeOfBaseArray
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sizeOfBaseArray
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sizeOfBaseObject
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sizeOfBaseObject
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sizeOfPointer
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sizeOfPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetExceptionRegister
 * Signature: ()Ljava/lang/Object;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetExceptionRegister
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetExceptionRegisterThrowable
 * Signature: ()Ljava/lang/Throwable;
 */
JNIEXPORT jthrowable JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetExceptionRegisterThrowable
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetExceptionRegisterPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetExceptionRegisterPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetPoolRegister
 * Signature: ()Ljava/lang/Object;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetPoolRegister
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetPoolRegisterPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetPoolRegisterPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetReturnRegister
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetReturnRegister
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetReturnRegisterLong
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetReturnRegisterLong
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetStaticFieldRegister
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetStaticFieldRegister
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetThreadRegister
 * Signature: ()Ljava/lang/Thread;
 */
JNIEXPORT jobject JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetThreadRegister
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialGetThreadRegisterPointer
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_specialGetThreadRegisterPointer
	(JNIEnv* env, jclass classy);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetExceptionRegister
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetExceptionRegister__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetExceptionRegister
 * Signature: (Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetExceptionRegister__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetPoolRegister
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetPoolRegister__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetPoolRegister
 * Signature: (Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetPoolRegister__Ljava_lang_Object_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetStaticFieldRegister
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetStaticFieldRegister
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetThreadRegister
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetThreadRegister__J
	(JNIEnv* env, jclass classy, jlong);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    specialSetThreadRegister
 * Signature: (Ljava/lang/Thread;)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_specialSetThreadRegister__Ljava_lang_Thread_2
	(JNIEnv* env, jclass classy, jobject);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (S)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCall
 * Signature: (SIIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCall__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (S)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SI)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallP
 * Signature: (SIIIIIIII)V
 */
JNIEXPORT void JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallP__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (S)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPV
 * Signature: (SIIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPV__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (S)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallPVL
 * Signature: (SIIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallPVL__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (S)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SI)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallV
 * Signature: (SIIIIIIII)I
 */
JNIEXPORT jint JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallV__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (S)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__S
	(JNIEnv* env, jclass classy, jshort);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SI)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SI
	(JNIEnv* env, jclass classy, jshort, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SII
	(JNIEnv* env, jclass classy, jshort, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint);

/*
 * Class:     cc_squirreljme_jvm_Assembly
 * Method:    sysCallVL
 * Signature: (SIIIIIIII)J
 */
JNIEXPORT jlong JNICALL Java_cc_squirreljme_jvm_Assembly_sysCallVL__SIIIIIIII
	(JNIEnv* env, jclass classy, jshort, jint, jint, jint, jint, jint, jint, jint, jint);

#ifdef __cplusplus
}
#endif
#endif

Added emulators/emulator-base/src/main/headers/jni.h.

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
 * We used part of Netscape's Java Runtime Interface (JRI) as the starting
 * point of our design and implementation.
 */

/******************************************************************************
 * Java Runtime Interface
 * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved.
 *****************************************************************************/

#ifndef _JAVASOFT_JNI_H_
#define _JAVASOFT_JNI_H_

#include <stdio.h>
#include <stdarg.h>

/* jni_md.h contains the machine-dependent typedefs for jbyte, jint
   and jlong */

#if defined(__linux__)
	#include "jni_linux.h"
#elif defined(_WIN32)
	#include "jni_win.h"
#elif defined(__APPLE__)
	#include "jni_mac.h"
#else
	#include "jni_md.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
 * JNI Types
 */

#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H

typedef unsigned char   jboolean;
typedef unsigned short  jchar;
typedef short           jshort;
typedef float           jfloat;
typedef double          jdouble;

typedef jint            jsize;

#ifdef __cplusplus

class _jobject {};
class _jclass : public _jobject {};
class _jthrowable : public _jobject {};
class _jstring : public _jobject {};
class _jarray : public _jobject {};
class _jbooleanArray : public _jarray {};
class _jbyteArray : public _jarray {};
class _jcharArray : public _jarray {};
class _jshortArray : public _jarray {};
class _jintArray : public _jarray {};
class _jlongArray : public _jarray {};
class _jfloatArray : public _jarray {};
class _jdoubleArray : public _jarray {};
class _jobjectArray : public _jarray {};

typedef _jobject *jobject;
typedef _jclass *jclass;
typedef _jthrowable *jthrowable;
typedef _jstring *jstring;
typedef _jarray *jarray;
typedef _jbooleanArray *jbooleanArray;
typedef _jbyteArray *jbyteArray;
typedef _jcharArray *jcharArray;
typedef _jshortArray *jshortArray;
typedef _jintArray *jintArray;
typedef _jlongArray *jlongArray;
typedef _jfloatArray *jfloatArray;
typedef _jdoubleArray *jdoubleArray;
typedef _jobjectArray *jobjectArray;

#else

struct _jobject;

typedef struct _jobject *jobject;
typedef jobject jclass;
typedef jobject jthrowable;
typedef jobject jstring;
typedef jobject jarray;
typedef jarray jbooleanArray;
typedef jarray jbyteArray;
typedef jarray jcharArray;
typedef jarray jshortArray;
typedef jarray jintArray;
typedef jarray jlongArray;
typedef jarray jfloatArray;
typedef jarray jdoubleArray;
typedef jarray jobjectArray;

#endif

typedef jobject jweak;

typedef union jvalue {
    jboolean z;
    jbyte    b;
    jchar    c;
    jshort   s;
    jint     i;
    jlong    j;
    jfloat   f;
    jdouble  d;
    jobject  l;
} jvalue;

struct _jfieldID;
typedef struct _jfieldID *jfieldID;

struct _jmethodID;
typedef struct _jmethodID *jmethodID;

/* Return values from jobjectRefType */
typedef enum _jobjectType {
     JNIInvalidRefType    = 0,
     JNILocalRefType      = 1,
     JNIGlobalRefType     = 2,
     JNIWeakGlobalRefType = 3
} jobjectRefType;


#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */

/*
 * jboolean constants
 */

#define JNI_FALSE 0
#define JNI_TRUE 1

/*
 * possible return values for JNI functions.
 */

#define JNI_OK           0                 /* success */
#define JNI_ERR          (-1)              /* unknown error */
#define JNI_EDETACHED    (-2)              /* thread detached from the VM */
#define JNI_EVERSION     (-3)              /* JNI version error */
#define JNI_ENOMEM       (-4)              /* not enough memory */
#define JNI_EEXIST       (-5)              /* VM already created */
#define JNI_EINVAL       (-6)              /* invalid arguments */

/*
 * used in ReleaseScalarArrayElements
 */

#define JNI_COMMIT 1
#define JNI_ABORT 2

/*
 * used in RegisterNatives to describe native method name, signature,
 * and function pointer.
 */

typedef struct {
    const char *name;
    const char *signature;
    void *fnPtr;
} JNINativeMethod;

/*
 * JNI Native Method Interface.
 */

struct JNINativeInterface_;

struct JNIEnv_;

#ifdef __cplusplus
typedef JNIEnv_ JNIEnv;
#else
typedef const struct JNINativeInterface_ *JNIEnv;
#endif

/*
 * JNI Invocation Interface.
 */

struct JNIInvokeInterface_;

struct JavaVM_;

#ifdef __cplusplus
typedef JavaVM_ JavaVM;
#else
typedef const struct JNIInvokeInterface_ *JavaVM;
#endif

struct JNINativeInterface_ {
    void *reserved0;
    void *reserved1;
    void *reserved2;

    void *reserved3;
    jint (JNICALL *GetVersion)(JNIEnv *env);

    jclass (JNICALL *DefineClass)
      (JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
       jsize len);
    jclass (JNICALL *FindClass)
      (JNIEnv *env, const char *name);

    jmethodID (JNICALL *FromReflectedMethod)
      (JNIEnv *env, jobject method);
    jfieldID (JNICALL *FromReflectedField)
      (JNIEnv *env, jobject field);

    jobject (JNICALL *ToReflectedMethod)
      (JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);

    jclass (JNICALL *GetSuperclass)
      (JNIEnv *env, jclass sub);
    jboolean (JNICALL *IsAssignableFrom)
      (JNIEnv *env, jclass sub, jclass sup);

    jobject (JNICALL *ToReflectedField)
      (JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic);

    jint (JNICALL *Throw)
      (JNIEnv *env, jthrowable obj);
    jint (JNICALL *ThrowNew)
      (JNIEnv *env, jclass clazz, const char *msg);
    jthrowable (JNICALL *ExceptionOccurred)
      (JNIEnv *env);
    void (JNICALL *ExceptionDescribe)
      (JNIEnv *env);
    void (JNICALL *ExceptionClear)
      (JNIEnv *env);
    void (JNICALL *FatalError)
      (JNIEnv *env, const char *msg);

    jint (JNICALL *PushLocalFrame)
      (JNIEnv *env, jint capacity);
    jobject (JNICALL *PopLocalFrame)
      (JNIEnv *env, jobject result);

    jobject (JNICALL *NewGlobalRef)
      (JNIEnv *env, jobject lobj);
    void (JNICALL *DeleteGlobalRef)
      (JNIEnv *env, jobject gref);
    void (JNICALL *DeleteLocalRef)
      (JNIEnv *env, jobject obj);
    jboolean (JNICALL *IsSameObject)
      (JNIEnv *env, jobject obj1, jobject obj2);
    jobject (JNICALL *NewLocalRef)
      (JNIEnv *env, jobject ref);
    jint (JNICALL *EnsureLocalCapacity)
      (JNIEnv *env, jint capacity);

    jobject (JNICALL *AllocObject)
      (JNIEnv *env, jclass clazz);
    jobject (JNICALL *NewObject)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jobject (JNICALL *NewObjectV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jobject (JNICALL *NewObjectA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jclass (JNICALL *GetObjectClass)
      (JNIEnv *env, jobject obj);
    jboolean (JNICALL *IsInstanceOf)
      (JNIEnv *env, jobject obj, jclass clazz);

    jmethodID (JNICALL *GetMethodID)
      (JNIEnv *env, jclass clazz, const char *name, const char *sig);

    jobject (JNICALL *CallObjectMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jobject (JNICALL *CallObjectMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jobject (JNICALL *CallObjectMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);

    jboolean (JNICALL *CallBooleanMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jboolean (JNICALL *CallBooleanMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jboolean (JNICALL *CallBooleanMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);

    jbyte (JNICALL *CallByteMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jbyte (JNICALL *CallByteMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jbyte (JNICALL *CallByteMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jchar (JNICALL *CallCharMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jchar (JNICALL *CallCharMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jchar (JNICALL *CallCharMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jshort (JNICALL *CallShortMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jshort (JNICALL *CallShortMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jshort (JNICALL *CallShortMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jint (JNICALL *CallIntMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jint (JNICALL *CallIntMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jint (JNICALL *CallIntMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jlong (JNICALL *CallLongMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jlong (JNICALL *CallLongMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jlong (JNICALL *CallLongMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jfloat (JNICALL *CallFloatMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jfloat (JNICALL *CallFloatMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jfloat (JNICALL *CallFloatMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    jdouble (JNICALL *CallDoubleMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    jdouble (JNICALL *CallDoubleMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    jdouble (JNICALL *CallDoubleMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);

    void (JNICALL *CallVoidMethod)
      (JNIEnv *env, jobject obj, jmethodID methodID, ...);
    void (JNICALL *CallVoidMethodV)
      (JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
    void (JNICALL *CallVoidMethodA)
      (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);

    jobject (JNICALL *CallNonvirtualObjectMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jobject (JNICALL *CallNonvirtualObjectMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jobject (JNICALL *CallNonvirtualObjectMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue * args);

    jboolean (JNICALL *CallNonvirtualBooleanMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jboolean (JNICALL *CallNonvirtualBooleanMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jboolean (JNICALL *CallNonvirtualBooleanMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue * args);

    jbyte (JNICALL *CallNonvirtualByteMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jbyte (JNICALL *CallNonvirtualByteMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jbyte (JNICALL *CallNonvirtualByteMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jchar (JNICALL *CallNonvirtualCharMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jchar (JNICALL *CallNonvirtualCharMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jchar (JNICALL *CallNonvirtualCharMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jshort (JNICALL *CallNonvirtualShortMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jshort (JNICALL *CallNonvirtualShortMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jshort (JNICALL *CallNonvirtualShortMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jint (JNICALL *CallNonvirtualIntMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jint (JNICALL *CallNonvirtualIntMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jint (JNICALL *CallNonvirtualIntMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jlong (JNICALL *CallNonvirtualLongMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jlong (JNICALL *CallNonvirtualLongMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jlong (JNICALL *CallNonvirtualLongMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jfloat (JNICALL *CallNonvirtualFloatMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jfloat (JNICALL *CallNonvirtualFloatMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jfloat (JNICALL *CallNonvirtualFloatMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    jdouble (JNICALL *CallNonvirtualDoubleMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    jdouble (JNICALL *CallNonvirtualDoubleMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    jdouble (JNICALL *CallNonvirtualDoubleMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue *args);

    void (JNICALL *CallNonvirtualVoidMethod)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
    void (JNICALL *CallNonvirtualVoidMethodV)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       va_list args);
    void (JNICALL *CallNonvirtualVoidMethodA)
      (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID,
       const jvalue * args);

    jfieldID (JNICALL *GetFieldID)
      (JNIEnv *env, jclass clazz, const char *name, const char *sig);

    jobject (JNICALL *GetObjectField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jboolean (JNICALL *GetBooleanField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jbyte (JNICALL *GetByteField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jchar (JNICALL *GetCharField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jshort (JNICALL *GetShortField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jint (JNICALL *GetIntField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jlong (JNICALL *GetLongField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jfloat (JNICALL *GetFloatField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);
    jdouble (JNICALL *GetDoubleField)
      (JNIEnv *env, jobject obj, jfieldID fieldID);

    void (JNICALL *SetObjectField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val);
    void (JNICALL *SetBooleanField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val);
    void (JNICALL *SetByteField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val);
    void (JNICALL *SetCharField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val);
    void (JNICALL *SetShortField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val);
    void (JNICALL *SetIntField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jint val);
    void (JNICALL *SetLongField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val);
    void (JNICALL *SetFloatField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val);
    void (JNICALL *SetDoubleField)
      (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val);

    jmethodID (JNICALL *GetStaticMethodID)
      (JNIEnv *env, jclass clazz, const char *name, const char *sig);

    jobject (JNICALL *CallStaticObjectMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jobject (JNICALL *CallStaticObjectMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jobject (JNICALL *CallStaticObjectMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jboolean (JNICALL *CallStaticBooleanMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jboolean (JNICALL *CallStaticBooleanMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jboolean (JNICALL *CallStaticBooleanMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jbyte (JNICALL *CallStaticByteMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jbyte (JNICALL *CallStaticByteMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jbyte (JNICALL *CallStaticByteMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jchar (JNICALL *CallStaticCharMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jchar (JNICALL *CallStaticCharMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jchar (JNICALL *CallStaticCharMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jshort (JNICALL *CallStaticShortMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jshort (JNICALL *CallStaticShortMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jshort (JNICALL *CallStaticShortMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jint (JNICALL *CallStaticIntMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jint (JNICALL *CallStaticIntMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jint (JNICALL *CallStaticIntMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jlong (JNICALL *CallStaticLongMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jlong (JNICALL *CallStaticLongMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jlong (JNICALL *CallStaticLongMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jfloat (JNICALL *CallStaticFloatMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jfloat (JNICALL *CallStaticFloatMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jfloat (JNICALL *CallStaticFloatMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    jdouble (JNICALL *CallStaticDoubleMethod)
      (JNIEnv *env, jclass clazz, jmethodID methodID, ...);
    jdouble (JNICALL *CallStaticDoubleMethodV)
      (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
    jdouble (JNICALL *CallStaticDoubleMethodA)
      (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);

    void (JNICALL *CallStaticVoidMethod)
      (JNIEnv *env, jclass cls, jmethodID methodID, ...);
    void (JNICALL *CallStaticVoidMethodV)
      (JNIEnv *env, jclass cls, jmethodID methodID, va_list args);
    void (JNICALL *CallStaticVoidMethodA)
      (JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args);

    jfieldID (JNICALL *GetStaticFieldID)
      (JNIEnv *env, jclass clazz, const char *name, const char *sig);
    jobject (JNICALL *GetStaticObjectField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jboolean (JNICALL *GetStaticBooleanField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jbyte (JNICALL *GetStaticByteField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jchar (JNICALL *GetStaticCharField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jshort (JNICALL *GetStaticShortField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jint (JNICALL *GetStaticIntField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jlong (JNICALL *GetStaticLongField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jfloat (JNICALL *GetStaticFloatField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);
    jdouble (JNICALL *GetStaticDoubleField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID);

    void (JNICALL *SetStaticObjectField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value);
    void (JNICALL *SetStaticBooleanField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value);
    void (JNICALL *SetStaticByteField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value);
    void (JNICALL *SetStaticCharField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value);
    void (JNICALL *SetStaticShortField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value);
    void (JNICALL *SetStaticIntField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value);
    void (JNICALL *SetStaticLongField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value);
    void (JNICALL *SetStaticFloatField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value);
    void (JNICALL *SetStaticDoubleField)
      (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value);

    jstring (JNICALL *NewString)
      (JNIEnv *env, const jchar *unicode, jsize len);
    jsize (JNICALL *GetStringLength)
      (JNIEnv *env, jstring str);
    const jchar *(JNICALL *GetStringChars)
      (JNIEnv *env, jstring str, jboolean *isCopy);
    void (JNICALL *ReleaseStringChars)
      (JNIEnv *env, jstring str, const jchar *chars);

    jstring (JNICALL *NewStringUTF)
      (JNIEnv *env, const char *utf);
    jsize (JNICALL *GetStringUTFLength)
      (JNIEnv *env, jstring str);
    const char* (JNICALL *GetStringUTFChars)
      (JNIEnv *env, jstring str, jboolean *isCopy);
    void (JNICALL *ReleaseStringUTFChars)
      (JNIEnv *env, jstring str, const char* chars);


    jsize (JNICALL *GetArrayLength)
      (JNIEnv *env, jarray array);

    jobjectArray (JNICALL *NewObjectArray)
      (JNIEnv *env, jsize len, jclass clazz, jobject init);
    jobject (JNICALL *GetObjectArrayElement)
      (JNIEnv *env, jobjectArray array, jsize index);
    void (JNICALL *SetObjectArrayElement)
      (JNIEnv *env, jobjectArray array, jsize index, jobject val);

    jbooleanArray (JNICALL *NewBooleanArray)
      (JNIEnv *env, jsize len);
    jbyteArray (JNICALL *NewByteArray)
      (JNIEnv *env, jsize len);
    jcharArray (JNICALL *NewCharArray)
      (JNIEnv *env, jsize len);
    jshortArray (JNICALL *NewShortArray)
      (JNIEnv *env, jsize len);
    jintArray (JNICALL *NewIntArray)
      (JNIEnv *env, jsize len);
    jlongArray (JNICALL *NewLongArray)
      (JNIEnv *env, jsize len);
    jfloatArray (JNICALL *NewFloatArray)
      (JNIEnv *env, jsize len);
    jdoubleArray (JNICALL *NewDoubleArray)
      (JNIEnv *env, jsize len);

    jboolean * (JNICALL *GetBooleanArrayElements)
      (JNIEnv *env, jbooleanArray array, jboolean *isCopy);
    jbyte * (JNICALL *GetByteArrayElements)
      (JNIEnv *env, jbyteArray array, jboolean *isCopy);
    jchar * (JNICALL *GetCharArrayElements)
      (JNIEnv *env, jcharArray array, jboolean *isCopy);
    jshort * (JNICALL *GetShortArrayElements)
      (JNIEnv *env, jshortArray array, jboolean *isCopy);
    jint * (JNICALL *GetIntArrayElements)
      (JNIEnv *env, jintArray array, jboolean *isCopy);
    jlong * (JNICALL *GetLongArrayElements)
      (JNIEnv *env, jlongArray array, jboolean *isCopy);
    jfloat * (JNICALL *GetFloatArrayElements)
      (JNIEnv *env, jfloatArray array, jboolean *isCopy);
    jdouble * (JNICALL *GetDoubleArrayElements)
      (JNIEnv *env, jdoubleArray array, jboolean *isCopy);

    void (JNICALL *ReleaseBooleanArrayElements)
      (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode);
    void (JNICALL *ReleaseByteArrayElements)
      (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode);
    void (JNICALL *ReleaseCharArrayElements)
      (JNIEnv *env, jcharArray array, jchar *elems, jint mode);
    void (JNICALL *ReleaseShortArrayElements)
      (JNIEnv *env, jshortArray array, jshort *elems, jint mode);
    void (JNICALL *ReleaseIntArrayElements)
      (JNIEnv *env, jintArray array, jint *elems, jint mode);
    void (JNICALL *ReleaseLongArrayElements)
      (JNIEnv *env, jlongArray array, jlong *elems, jint mode);
    void (JNICALL *ReleaseFloatArrayElements)
      (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode);
    void (JNICALL *ReleaseDoubleArrayElements)
      (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode);

    void (JNICALL *GetBooleanArrayRegion)
      (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf);
    void (JNICALL *GetByteArrayRegion)
      (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf);
    void (JNICALL *GetCharArrayRegion)
      (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf);
    void (JNICALL *GetShortArrayRegion)
      (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf);
    void (JNICALL *GetIntArrayRegion)
      (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf);
    void (JNICALL *GetLongArrayRegion)
      (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf);
    void (JNICALL *GetFloatArrayRegion)
      (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf);
    void (JNICALL *GetDoubleArrayRegion)
      (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf);

    void (JNICALL *SetBooleanArrayRegion)
      (JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf);
    void (JNICALL *SetByteArrayRegion)
      (JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf);
    void (JNICALL *SetCharArrayRegion)
      (JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf);
    void (JNICALL *SetShortArrayRegion)
      (JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf);
    void (JNICALL *SetIntArrayRegion)
      (JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf);
    void (JNICALL *SetLongArrayRegion)
      (JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf);
    void (JNICALL *SetFloatArrayRegion)
      (JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf);
    void (JNICALL *SetDoubleArrayRegion)
      (JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf);

    jint (JNICALL *RegisterNatives)
      (JNIEnv *env, jclass clazz, const JNINativeMethod *methods,
       jint nMethods);
    jint (JNICALL *UnregisterNatives)
      (JNIEnv *env, jclass clazz);

    jint (JNICALL *MonitorEnter)
      (JNIEnv *env, jobject obj);
    jint (JNICALL *MonitorExit)
      (JNIEnv *env, jobject obj);

    jint (JNICALL *GetJavaVM)
      (JNIEnv *env, JavaVM **vm);

    void (JNICALL *GetStringRegion)
      (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);
    void (JNICALL *GetStringUTFRegion)
      (JNIEnv *env, jstring str, jsize start, jsize len, char *buf);

    void * (JNICALL *GetPrimitiveArrayCritical)
      (JNIEnv *env, jarray array, jboolean *isCopy);
    void (JNICALL *ReleasePrimitiveArrayCritical)
      (JNIEnv *env, jarray array, void *carray, jint mode);

    const jchar * (JNICALL *GetStringCritical)
      (JNIEnv *env, jstring string, jboolean *isCopy);
    void (JNICALL *ReleaseStringCritical)
      (JNIEnv *env, jstring string, const jchar *cstring);

    jweak (JNICALL *NewWeakGlobalRef)
       (JNIEnv *env, jobject obj);
    void (JNICALL *DeleteWeakGlobalRef)
       (JNIEnv *env, jweak ref);

    jboolean (JNICALL *ExceptionCheck)
       (JNIEnv *env);

    jobject (JNICALL *NewDirectByteBuffer)
       (JNIEnv* env, void* address, jlong capacity);
    void* (JNICALL *GetDirectBufferAddress)
       (JNIEnv* env, jobject buf);
    jlong (JNICALL *GetDirectBufferCapacity)
       (JNIEnv* env, jobject buf);

    /* New JNI 1.6 Features */

    jobjectRefType (JNICALL *GetObjectRefType)
        (JNIEnv* env, jobject obj);
};

/*
 * We use inlined functions for C++ so that programmers can write:
 *
 *    env->FindClass("java/lang/String")
 *
 * in C++ rather than:
 *
 *    (*env)->FindClass(env, "java/lang/String")
 *
 * in C.
 */

struct JNIEnv_ {
    const struct JNINativeInterface_ *functions;
#ifdef __cplusplus

    jint GetVersion() {
        return functions->GetVersion(this);
    }
    jclass DefineClass(const char *name, jobject loader, const jbyte *buf,
                       jsize len) {
        return functions->DefineClass(this, name, loader, buf, len);
    }
    jclass FindClass(const char *name) {
        return functions->FindClass(this, name);
    }
    jmethodID FromReflectedMethod(jobject method) {
        return functions->FromReflectedMethod(this,method);
    }
    jfieldID FromReflectedField(jobject field) {
        return functions->FromReflectedField(this,field);
    }

    jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) {
        return functions->ToReflectedMethod(this, cls, methodID, isStatic);
    }

    jclass GetSuperclass(jclass sub) {
        return functions->GetSuperclass(this, sub);
    }
    jboolean IsAssignableFrom(jclass sub, jclass sup) {
        return functions->IsAssignableFrom(this, sub, sup);
    }

    jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) {
        return functions->ToReflectedField(this,cls,fieldID,isStatic);
    }

    jint Throw(jthrowable obj) {
        return functions->Throw(this, obj);
    }
    jint ThrowNew(jclass clazz, const char *msg) {
        return functions->ThrowNew(this, clazz, msg);
    }
    jthrowable ExceptionOccurred() {
        return functions->ExceptionOccurred(this);
    }
    void ExceptionDescribe() {
        functions->ExceptionDescribe(this);
    }
    void ExceptionClear() {
        functions->ExceptionClear(this);
    }
    void FatalError(const char *msg) {
        functions->FatalError(this, msg);
    }

    jint PushLocalFrame(jint capacity) {
        return functions->PushLocalFrame(this,capacity);
    }
    jobject PopLocalFrame(jobject result) {
        return functions->PopLocalFrame(this,result);
    }

    jobject NewGlobalRef(jobject lobj) {
        return functions->NewGlobalRef(this,lobj);
    }
    void DeleteGlobalRef(jobject gref) {
        functions->DeleteGlobalRef(this,gref);
    }
    void DeleteLocalRef(jobject obj) {
        functions->DeleteLocalRef(this, obj);
    }

    jboolean IsSameObject(jobject obj1, jobject obj2) {
        return functions->IsSameObject(this,obj1,obj2);
    }

    jobject NewLocalRef(jobject ref) {
        return functions->NewLocalRef(this,ref);
    }
    jint EnsureLocalCapacity(jint capacity) {
        return functions->EnsureLocalCapacity(this,capacity);
    }

    jobject AllocObject(jclass clazz) {
        return functions->AllocObject(this,clazz);
    }
    jobject NewObject(jclass clazz, jmethodID methodID, ...) {
        va_list args;
        jobject result;
        va_start(args, methodID);
        result = functions->NewObjectV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jobject NewObjectV(jclass clazz, jmethodID methodID,
                       va_list args) {
        return functions->NewObjectV(this,clazz,methodID,args);
    }
    jobject NewObjectA(jclass clazz, jmethodID methodID,
                       const jvalue *args) {
        return functions->NewObjectA(this,clazz,methodID,args);
    }

    jclass GetObjectClass(jobject obj) {
        return functions->GetObjectClass(this,obj);
    }
    jboolean IsInstanceOf(jobject obj, jclass clazz) {
        return functions->IsInstanceOf(this,obj,clazz);
    }

    jmethodID GetMethodID(jclass clazz, const char *name,
                          const char *sig) {
        return functions->GetMethodID(this,clazz,name,sig);
    }

    jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jobject result;
        va_start(args,methodID);
        result = functions->CallObjectMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jobject CallObjectMethodV(jobject obj, jmethodID methodID,
                        va_list args) {
        return functions->CallObjectMethodV(this,obj,methodID,args);
    }
    jobject CallObjectMethodA(jobject obj, jmethodID methodID,
                        const jvalue * args) {
        return functions->CallObjectMethodA(this,obj,methodID,args);
    }

    jboolean CallBooleanMethod(jobject obj,
                               jmethodID methodID, ...) {
        va_list args;
        jboolean result;
        va_start(args,methodID);
        result = functions->CallBooleanMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jboolean CallBooleanMethodV(jobject obj, jmethodID methodID,
                                va_list args) {
        return functions->CallBooleanMethodV(this,obj,methodID,args);
    }
    jboolean CallBooleanMethodA(jobject obj, jmethodID methodID,
                                const jvalue * args) {
        return functions->CallBooleanMethodA(this,obj,methodID, args);
    }

    jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jbyte result;
        va_start(args,methodID);
        result = functions->CallByteMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jbyte CallByteMethodV(jobject obj, jmethodID methodID,
                          va_list args) {
        return functions->CallByteMethodV(this,obj,methodID,args);
    }
    jbyte CallByteMethodA(jobject obj, jmethodID methodID,
                          const jvalue * args) {
        return functions->CallByteMethodA(this,obj,methodID,args);
    }

    jchar CallCharMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jchar result;
        va_start(args,methodID);
        result = functions->CallCharMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jchar CallCharMethodV(jobject obj, jmethodID methodID,
                          va_list args) {
        return functions->CallCharMethodV(this,obj,methodID,args);
    }
    jchar CallCharMethodA(jobject obj, jmethodID methodID,
                          const jvalue * args) {
        return functions->CallCharMethodA(this,obj,methodID,args);
    }

    jshort CallShortMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jshort result;
        va_start(args,methodID);
        result = functions->CallShortMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jshort CallShortMethodV(jobject obj, jmethodID methodID,
                            va_list args) {
        return functions->CallShortMethodV(this,obj,methodID,args);
    }
    jshort CallShortMethodA(jobject obj, jmethodID methodID,
                            const jvalue * args) {
        return functions->CallShortMethodA(this,obj,methodID,args);
    }

    jint CallIntMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jint result;
        va_start(args,methodID);
        result = functions->CallIntMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jint CallIntMethodV(jobject obj, jmethodID methodID,
                        va_list args) {
        return functions->CallIntMethodV(this,obj,methodID,args);
    }
    jint CallIntMethodA(jobject obj, jmethodID methodID,
                        const jvalue * args) {
        return functions->CallIntMethodA(this,obj,methodID,args);
    }

    jlong CallLongMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jlong result;
        va_start(args,methodID);
        result = functions->CallLongMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jlong CallLongMethodV(jobject obj, jmethodID methodID,
                          va_list args) {
        return functions->CallLongMethodV(this,obj,methodID,args);
    }
    jlong CallLongMethodA(jobject obj, jmethodID methodID,
                          const jvalue * args) {
        return functions->CallLongMethodA(this,obj,methodID,args);
    }

    jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jfloat result;
        va_start(args,methodID);
        result = functions->CallFloatMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jfloat CallFloatMethodV(jobject obj, jmethodID methodID,
                            va_list args) {
        return functions->CallFloatMethodV(this,obj,methodID,args);
    }
    jfloat CallFloatMethodA(jobject obj, jmethodID methodID,
                            const jvalue * args) {
        return functions->CallFloatMethodA(this,obj,methodID,args);
    }

    jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        jdouble result;
        va_start(args,methodID);
        result = functions->CallDoubleMethodV(this,obj,methodID,args);
        va_end(args);
        return result;
    }
    jdouble CallDoubleMethodV(jobject obj, jmethodID methodID,
                        va_list args) {
        return functions->CallDoubleMethodV(this,obj,methodID,args);
    }
    jdouble CallDoubleMethodA(jobject obj, jmethodID methodID,
                        const jvalue * args) {
        return functions->CallDoubleMethodA(this,obj,methodID,args);
    }

    void CallVoidMethod(jobject obj, jmethodID methodID, ...) {
        va_list args;
        va_start(args,methodID);
        functions->CallVoidMethodV(this,obj,methodID,args);
        va_end(args);
    }
    void CallVoidMethodV(jobject obj, jmethodID methodID,
                         va_list args) {
        functions->CallVoidMethodV(this,obj,methodID,args);
    }
    void CallVoidMethodA(jobject obj, jmethodID methodID,
                         const jvalue * args) {
        functions->CallVoidMethodA(this,obj,methodID,args);
    }

    jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz,
                                       jmethodID methodID, ...) {
        va_list args;
        jobject result;
        va_start(args,methodID);
        result = functions->CallNonvirtualObjectMethodV(this,obj,clazz,
                                                        methodID,args);
        va_end(args);
        return result;
    }
    jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz,
                                        jmethodID methodID, va_list args) {
        return functions->CallNonvirtualObjectMethodV(this,obj,clazz,
                                                      methodID,args);
    }
    jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz,
                                        jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualObjectMethodA(this,obj,clazz,
                                                      methodID,args);
    }

    jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz,
                                         jmethodID methodID, ...) {
        va_list args;
        jboolean result;
        va_start(args,methodID);
        result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
                                                         methodID,args);
        va_end(args);
        return result;
    }
    jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz,
                                          jmethodID methodID, va_list args) {
        return functions->CallNonvirtualBooleanMethodV(this,obj,clazz,
                                                       methodID,args);
    }
    jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz,
                                          jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualBooleanMethodA(this,obj,clazz,
                                                       methodID, args);
    }

    jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz,
                                   jmethodID methodID, ...) {
        va_list args;
        jbyte result;
        va_start(args,methodID);
        result = functions->CallNonvirtualByteMethodV(this,obj,clazz,
                                                      methodID,args);
        va_end(args);
        return result;
    }
    jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz,
                                    jmethodID methodID, va_list args) {
        return functions->CallNonvirtualByteMethodV(this,obj,clazz,
                                                    methodID,args);
    }
    jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz,
                                    jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualByteMethodA(this,obj,clazz,
                                                    methodID,args);
    }

    jchar CallNonvirtualCharMethod(jobject obj, jclass clazz,
                                   jmethodID methodID, ...) {
        va_list args;
        jchar result;
        va_start(args,methodID);
        result = functions->CallNonvirtualCharMethodV(this,obj,clazz,
                                                      methodID,args);
        va_end(args);
        return result;
    }
    jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz,
                                    jmethodID methodID, va_list args) {
        return functions->CallNonvirtualCharMethodV(this,obj,clazz,
                                                    methodID,args);
    }
    jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz,
                                    jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualCharMethodA(this,obj,clazz,
                                                    methodID,args);
    }

    jshort CallNonvirtualShortMethod(jobject obj, jclass clazz,
                                     jmethodID methodID, ...) {
        va_list args;
        jshort result;
        va_start(args,methodID);
        result = functions->CallNonvirtualShortMethodV(this,obj,clazz,
                                                       methodID,args);
        va_end(args);
        return result;
    }
    jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz,
                                      jmethodID methodID, va_list args) {
        return functions->CallNonvirtualShortMethodV(this,obj,clazz,
                                                     methodID,args);
    }
    jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz,
                                      jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualShortMethodA(this,obj,clazz,
                                                     methodID,args);
    }

    jint CallNonvirtualIntMethod(jobject obj, jclass clazz,
                                 jmethodID methodID, ...) {
        va_list args;
        jint result;
        va_start(args,methodID);
        result = functions->CallNonvirtualIntMethodV(this,obj,clazz,
                                                     methodID,args);
        va_end(args);
        return result;
    }
    jint CallNonvirtualIntMethodV(jobject obj, jclass clazz,
                                  jmethodID methodID, va_list args) {
        return functions->CallNonvirtualIntMethodV(this,obj,clazz,
                                                   methodID,args);
    }
    jint CallNonvirtualIntMethodA(jobject obj, jclass clazz,
                                  jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualIntMethodA(this,obj,clazz,
                                                   methodID,args);
    }

    jlong CallNonvirtualLongMethod(jobject obj, jclass clazz,
                                   jmethodID methodID, ...) {
        va_list args;
        jlong result;
        va_start(args,methodID);
        result = functions->CallNonvirtualLongMethodV(this,obj,clazz,
                                                      methodID,args);
        va_end(args);
        return result;
    }
    jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz,
                                    jmethodID methodID, va_list args) {
        return functions->CallNonvirtualLongMethodV(this,obj,clazz,
                                                    methodID,args);
    }
    jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz,
                                    jmethodID methodID, const jvalue * args) {
        return functions->CallNonvirtualLongMethodA(this,obj,clazz,
                                                    methodID,args);
    }

    jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz,
                                     jmethodID methodID, ...) {
        va_list args;
        jfloat result;
        va_start(args,methodID);
        result = functions->CallNonvirtualFloatMethodV(this,obj,clazz,
                                                       methodID,args);
        va_end(args);
        return result;
    }
    jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz,
                                      jmethodID methodID,
                                      va_list args) {
        return functions->CallNonvirtualFloatMethodV(this,obj,clazz,
                                                     methodID,args);
    }
    jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz,
                                      jmethodID methodID,
                                      const jvalue * args) {
        return functions->CallNonvirtualFloatMethodA(this,obj,clazz,
                                                     methodID,args);
    }

    jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz,
                                       jmethodID methodID, ...) {
        va_list args;
        jdouble result;
        va_start(args,methodID);
        result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
                                                        methodID,args);
        va_end(args);
        return result;
    }
    jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz,
                                        jmethodID methodID,
                                        va_list args) {
        return functions->CallNonvirtualDoubleMethodV(this,obj,clazz,
                                                      methodID,args);
    }
    jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz,
                                        jmethodID methodID,
                                        const jvalue * args) {
        return functions->CallNonvirtualDoubleMethodA(this,obj,clazz,
                                                      methodID,args);
    }

    void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
                                  jmethodID methodID, ...) {
        va_list args;
        va_start(args,methodID);
        functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
        va_end(args);
    }
    void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
                                   jmethodID methodID,
                                   va_list args) {
        functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args);
    }
    void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
                                   jmethodID methodID,
                                   const jvalue * args) {
        functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args);
    }

    jfieldID GetFieldID(jclass clazz, const char *name,
                        const char *sig) {
        return functions->GetFieldID(this,clazz,name,sig);
    }

    jobject GetObjectField(jobject obj, jfieldID fieldID) {
        return functions->GetObjectField(this,obj,fieldID);
    }
    jboolean GetBooleanField(jobject obj, jfieldID fieldID) {
        return functions->GetBooleanField(this,obj,fieldID);
    }
    jbyte GetByteField(jobject obj, jfieldID fieldID) {
        return functions->GetByteField(this,obj,fieldID);
    }
    jchar GetCharField(jobject obj, jfieldID fieldID) {
        return functions->GetCharField(this,obj,fieldID);
    }
    jshort GetShortField(jobject obj, jfieldID fieldID) {
        return functions->GetShortField(this,obj,fieldID);
    }
    jint GetIntField(jobject obj, jfieldID fieldID) {
        return functions->GetIntField(this,obj,fieldID);
    }
    jlong GetLongField(jobject obj, jfieldID fieldID) {
        return functions->GetLongField(this,obj,fieldID);
    }
    jfloat GetFloatField(jobject obj, jfieldID fieldID) {
        return functions->GetFloatField(this,obj,fieldID);
    }
    jdouble GetDoubleField(jobject obj, jfieldID fieldID) {
        return functions->GetDoubleField(this,obj,fieldID);
    }

    void SetObjectField(jobject obj, jfieldID fieldID, jobject val) {
        functions->SetObjectField(this,obj,fieldID,val);
    }
    void SetBooleanField(jobject obj, jfieldID fieldID,
                         jboolean val) {
        functions->SetBooleanField(this,obj,fieldID,val);
    }
    void SetByteField(jobject obj, jfieldID fieldID,
                      jbyte val) {
        functions->SetByteField(this,obj,fieldID,val);
    }
    void SetCharField(jobject obj, jfieldID fieldID,
                      jchar val) {
        functions->SetCharField(this,obj,fieldID,val);
    }
    void SetShortField(jobject obj, jfieldID fieldID,
                       jshort val) {
        functions->SetShortField(this,obj,fieldID,val);
    }
    void SetIntField(jobject obj, jfieldID fieldID,
                     jint val) {
        functions->SetIntField(this,obj,fieldID,val);
    }
    void SetLongField(jobject obj, jfieldID fieldID,
                      jlong val) {
        functions->SetLongField(this,obj,fieldID,val);
    }
    void SetFloatField(jobject obj, jfieldID fieldID,
                       jfloat val) {
        functions->SetFloatField(this,obj,fieldID,val);
    }
    void SetDoubleField(jobject obj, jfieldID fieldID,
                        jdouble val) {
        functions->SetDoubleField(this,obj,fieldID,val);
    }

    jmethodID GetStaticMethodID(jclass clazz, const char *name,
                                const char *sig) {
        return functions->GetStaticMethodID(this,clazz,name,sig);
    }

    jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID,
                             ...) {
        va_list args;
        jobject result;
        va_start(args,methodID);
        result = functions->CallStaticObjectMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID,
                              va_list args) {
        return functions->CallStaticObjectMethodV(this,clazz,methodID,args);
    }
    jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID,
                              const jvalue *args) {
        return functions->CallStaticObjectMethodA(this,clazz,methodID,args);
    }

    jboolean CallStaticBooleanMethod(jclass clazz,
                                     jmethodID methodID, ...) {
        va_list args;
        jboolean result;
        va_start(args,methodID);
        result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jboolean CallStaticBooleanMethodV(jclass clazz,
                                      jmethodID methodID, va_list args) {
        return functions->CallStaticBooleanMethodV(this,clazz,methodID,args);
    }
    jboolean CallStaticBooleanMethodA(jclass clazz,
                                      jmethodID methodID, const jvalue *args) {
        return functions->CallStaticBooleanMethodA(this,clazz,methodID,args);
    }

    jbyte CallStaticByteMethod(jclass clazz,
                               jmethodID methodID, ...) {
        va_list args;
        jbyte result;
        va_start(args,methodID);
        result = functions->CallStaticByteMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jbyte CallStaticByteMethodV(jclass clazz,
                                jmethodID methodID, va_list args) {
        return functions->CallStaticByteMethodV(this,clazz,methodID,args);
    }
    jbyte CallStaticByteMethodA(jclass clazz,
                                jmethodID methodID, const jvalue *args) {
        return functions->CallStaticByteMethodA(this,clazz,methodID,args);
    }

    jchar CallStaticCharMethod(jclass clazz,
                               jmethodID methodID, ...) {
        va_list args;
        jchar result;
        va_start(args,methodID);
        result = functions->CallStaticCharMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jchar CallStaticCharMethodV(jclass clazz,
                                jmethodID methodID, va_list args) {
        return functions->CallStaticCharMethodV(this,clazz,methodID,args);
    }
    jchar CallStaticCharMethodA(jclass clazz,
                                jmethodID methodID, const jvalue *args) {
        return functions->CallStaticCharMethodA(this,clazz,methodID,args);
    }

    jshort CallStaticShortMethod(jclass clazz,
                                 jmethodID methodID, ...) {
        va_list args;
        jshort result;
        va_start(args,methodID);
        result = functions->CallStaticShortMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jshort CallStaticShortMethodV(jclass clazz,
                                  jmethodID methodID, va_list args) {
        return functions->CallStaticShortMethodV(this,clazz,methodID,args);
    }
    jshort CallStaticShortMethodA(jclass clazz,
                                  jmethodID methodID, const jvalue *args) {
        return functions->CallStaticShortMethodA(this,clazz,methodID,args);
    }

    jint CallStaticIntMethod(jclass clazz,
                             jmethodID methodID, ...) {
        va_list args;
        jint result;
        va_start(args,methodID);
        result = functions->CallStaticIntMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jint CallStaticIntMethodV(jclass clazz,
                              jmethodID methodID, va_list args) {
        return functions->CallStaticIntMethodV(this,clazz,methodID,args);
    }
    jint CallStaticIntMethodA(jclass clazz,
                              jmethodID methodID, const jvalue *args) {
        return functions->CallStaticIntMethodA(this,clazz,methodID,args);
    }

    jlong CallStaticLongMethod(jclass clazz,
                               jmethodID methodID, ...) {
        va_list args;
        jlong result;
        va_start(args,methodID);
        result = functions->CallStaticLongMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jlong CallStaticLongMethodV(jclass clazz,
                                jmethodID methodID, va_list args) {
        return functions->CallStaticLongMethodV(this,clazz,methodID,args);
    }
    jlong CallStaticLongMethodA(jclass clazz,
                                jmethodID methodID, const jvalue *args) {
        return functions->CallStaticLongMethodA(this,clazz,methodID,args);
    }

    jfloat CallStaticFloatMethod(jclass clazz,
                                 jmethodID methodID, ...) {
        va_list args;
        jfloat result;
        va_start(args,methodID);
        result = functions->CallStaticFloatMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jfloat CallStaticFloatMethodV(jclass clazz,
                                  jmethodID methodID, va_list args) {
        return functions->CallStaticFloatMethodV(this,clazz,methodID,args);
    }
    jfloat CallStaticFloatMethodA(jclass clazz,
                                  jmethodID methodID, const jvalue *args) {
        return functions->CallStaticFloatMethodA(this,clazz,methodID,args);
    }

    jdouble CallStaticDoubleMethod(jclass clazz,
                                   jmethodID methodID, ...) {
        va_list args;
        jdouble result;
        va_start(args,methodID);
        result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
        va_end(args);
        return result;
    }
    jdouble CallStaticDoubleMethodV(jclass clazz,
                                    jmethodID methodID, va_list args) {
        return functions->CallStaticDoubleMethodV(this,clazz,methodID,args);
    }
    jdouble CallStaticDoubleMethodA(jclass clazz,
                                    jmethodID methodID, const jvalue *args) {
        return functions->CallStaticDoubleMethodA(this,clazz,methodID,args);
    }

    void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) {
        va_list args;
        va_start(args,methodID);
        functions->CallStaticVoidMethodV(this,cls,methodID,args);
        va_end(args);
    }
    void CallStaticVoidMethodV(jclass cls, jmethodID methodID,
                               va_list args) {
        functions->CallStaticVoidMethodV(this,cls,methodID,args);
    }
    void CallStaticVoidMethodA(jclass cls, jmethodID methodID,
                               const jvalue * args) {
        functions->CallStaticVoidMethodA(this,cls,methodID,args);
    }

    jfieldID GetStaticFieldID(jclass clazz, const char *name,
                              const char *sig) {
        return functions->GetStaticFieldID(this,clazz,name,sig);
    }
    jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticObjectField(this,clazz,fieldID);
    }
    jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticBooleanField(this,clazz,fieldID);
    }
    jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticByteField(this,clazz,fieldID);
    }
    jchar GetStaticCharField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticCharField(this,clazz,fieldID);
    }
    jshort GetStaticShortField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticShortField(this,clazz,fieldID);
    }
    jint GetStaticIntField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticIntField(this,clazz,fieldID);
    }
    jlong GetStaticLongField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticLongField(this,clazz,fieldID);
    }
    jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticFloatField(this,clazz,fieldID);
    }
    jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) {
        return functions->GetStaticDoubleField(this,clazz,fieldID);
    }

    void SetStaticObjectField(jclass clazz, jfieldID fieldID,
                        jobject value) {
      functions->SetStaticObjectField(this,clazz,fieldID,value);
    }
    void SetStaticBooleanField(jclass clazz, jfieldID fieldID,
                        jboolean value) {
      functions->SetStaticBooleanField(this,clazz,fieldID,value);
    }
    void SetStaticByteField(jclass clazz, jfieldID fieldID,
                        jbyte value) {
      functions->SetStaticByteField(this,clazz,fieldID,value);
    }
    void SetStaticCharField(jclass clazz, jfieldID fieldID,
                        jchar value) {
      functions->SetStaticCharField(this,clazz,fieldID,value);
    }
    void SetStaticShortField(jclass clazz, jfieldID fieldID,
                        jshort value) {
      functions->SetStaticShortField(this,clazz,fieldID,value);
    }
    void SetStaticIntField(jclass clazz, jfieldID fieldID,
                        jint value) {
      functions->SetStaticIntField(this,clazz,fieldID,value);
    }
    void SetStaticLongField(jclass clazz, jfieldID fieldID,
                        jlong value) {
      functions->SetStaticLongField(this,clazz,fieldID,value);
    }
    void SetStaticFloatField(jclass clazz, jfieldID fieldID,
                        jfloat value) {
      functions->SetStaticFloatField(this,clazz,fieldID,value);
    }
    void SetStaticDoubleField(jclass clazz, jfieldID fieldID,
                        jdouble value) {
      functions->SetStaticDoubleField(this,clazz,fieldID,value);
    }

    jstring NewString(const jchar *unicode, jsize len) {
        return functions->NewString(this,unicode,len);
    }
    jsize GetStringLength(jstring str) {
        return functions->GetStringLength(this,str);
    }
    const jchar *GetStringChars(jstring str, jboolean *isCopy) {
        return functions->GetStringChars(this,str,isCopy);
    }
    void ReleaseStringChars(jstring str, const jchar *chars) {
        functions->ReleaseStringChars(this,str,chars);
    }

    jstring NewStringUTF(const char *utf) {
        return functions->NewStringUTF(this,utf);
    }
    jsize GetStringUTFLength(jstring str) {
        return functions->GetStringUTFLength(this,str);
    }
    const char* GetStringUTFChars(jstring str, jboolean *isCopy) {
        return functions->GetStringUTFChars(this,str,isCopy);
    }
    void ReleaseStringUTFChars(jstring str, const char* chars) {
        functions->ReleaseStringUTFChars(this,str,chars);
    }

    jsize GetArrayLength(jarray array) {
        return functions->GetArrayLength(this,array);
    }

    jobjectArray NewObjectArray(jsize len, jclass clazz,
                                jobject init) {
        return functions->NewObjectArray(this,len,clazz,init);
    }
    jobject GetObjectArrayElement(jobjectArray array, jsize index) {
        return functions->GetObjectArrayElement(this,array,index);
    }
    void SetObjectArrayElement(jobjectArray array, jsize index,
                               jobject val) {
        functions->SetObjectArrayElement(this,array,index,val);
    }

    jbooleanArray NewBooleanArray(jsize len) {
        return functions->NewBooleanArray(this,len);
    }
    jbyteArray NewByteArray(jsize len) {
        return functions->NewByteArray(this,len);
    }
    jcharArray NewCharArray(jsize len) {
        return functions->NewCharArray(this,len);
    }
    jshortArray NewShortArray(jsize len) {
        return functions->NewShortArray(this,len);
    }
    jintArray NewIntArray(jsize len) {
        return functions->NewIntArray(this,len);
    }
    jlongArray NewLongArray(jsize len) {
        return functions->NewLongArray(this,len);
    }
    jfloatArray NewFloatArray(jsize len) {
        return functions->NewFloatArray(this,len);
    }
    jdoubleArray NewDoubleArray(jsize len) {
        return functions->NewDoubleArray(this,len);
    }

    jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) {
        return functions->GetBooleanArrayElements(this,array,isCopy);
    }
    jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) {
        return functions->GetByteArrayElements(this,array,isCopy);
    }
    jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) {
        return functions->GetCharArrayElements(this,array,isCopy);
    }
    jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) {
        return functions->GetShortArrayElements(this,array,isCopy);
    }
    jint * GetIntArrayElements(jintArray array, jboolean *isCopy) {
        return functions->GetIntArrayElements(this,array,isCopy);
    }
    jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) {
        return functions->GetLongArrayElements(this,array,isCopy);
    }
    jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) {
        return functions->GetFloatArrayElements(this,array,isCopy);
    }
    jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) {
        return functions->GetDoubleArrayElements(this,array,isCopy);
    }

    void ReleaseBooleanArrayElements(jbooleanArray array,
                                     jboolean *elems,
                                     jint mode) {
        functions->ReleaseBooleanArrayElements(this,array,elems,mode);
    }
    void ReleaseByteArrayElements(jbyteArray array,
                                  jbyte *elems,
                                  jint mode) {
        functions->ReleaseByteArrayElements(this,array,elems,mode);
    }
    void ReleaseCharArrayElements(jcharArray array,
                                  jchar *elems,
                                  jint mode) {
        functions->ReleaseCharArrayElements(this,array,elems,mode);
    }
    void ReleaseShortArrayElements(jshortArray array,
                                   jshort *elems,
                                   jint mode) {
        functions->ReleaseShortArrayElements(this,array,elems,mode);
    }
    void ReleaseIntArrayElements(jintArray array,
                                 jint *elems,
                                 jint mode) {
        functions->ReleaseIntArrayElements(this,array,elems,mode);
    }
    void ReleaseLongArrayElements(jlongArray array,
                                  jlong *elems,
                                  jint mode) {
        functions->ReleaseLongArrayElements(this,array,elems,mode);
    }
    void ReleaseFloatArrayElements(jfloatArray array,
                                   jfloat *elems,
                                   jint mode) {
        functions->ReleaseFloatArrayElements(this,array,elems,mode);
    }
    void ReleaseDoubleArrayElements(jdoubleArray array,
                                    jdouble *elems,
                                    jint mode) {
        functions->ReleaseDoubleArrayElements(this,array,elems,mode);
    }

    void GetBooleanArrayRegion(jbooleanArray array,
                               jsize start, jsize len, jboolean *buf) {
        functions->GetBooleanArrayRegion(this,array,start,len,buf);
    }
    void GetByteArrayRegion(jbyteArray array,
                            jsize start, jsize len, jbyte *buf) {
        functions->GetByteArrayRegion(this,array,start,len,buf);
    }
    void GetCharArrayRegion(jcharArray array,
                            jsize start, jsize len, jchar *buf) {
        functions->GetCharArrayRegion(this,array,start,len,buf);
    }
    void GetShortArrayRegion(jshortArray array,
                             jsize start, jsize len, jshort *buf) {
        functions->GetShortArrayRegion(this,array,start,len,buf);
    }
    void GetIntArrayRegion(jintArray array,
                           jsize start, jsize len, jint *buf) {
        functions->GetIntArrayRegion(this,array,start,len,buf);
    }
    void GetLongArrayRegion(jlongArray array,
                            jsize start, jsize len, jlong *buf) {
        functions->GetLongArrayRegion(this,array,start,len,buf);
    }
    void GetFloatArrayRegion(jfloatArray array,
                             jsize start, jsize len, jfloat *buf) {
        functions->GetFloatArrayRegion(this,array,start,len,buf);
    }
    void GetDoubleArrayRegion(jdoubleArray array,
                              jsize start, jsize len, jdouble *buf) {
        functions->GetDoubleArrayRegion(this,array,start,len,buf);
    }

    void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
                               const jboolean *buf) {
        functions->SetBooleanArrayRegion(this,array,start,len,buf);
    }
    void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
                            const jbyte *buf) {
        functions->SetByteArrayRegion(this,array,start,len,buf);
    }
    void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
                            const jchar *buf) {
        functions->SetCharArrayRegion(this,array,start,len,buf);
    }
    void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
                             const jshort *buf) {
        functions->SetShortArrayRegion(this,array,start,len,buf);
    }
    void SetIntArrayRegion(jintArray array, jsize start, jsize len,
                           const jint *buf) {
        functions->SetIntArrayRegion(this,array,start,len,buf);
    }
    void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
                            const jlong *buf) {
        functions->SetLongArrayRegion(this,array,start,len,buf);
    }
    void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
                             const jfloat *buf) {
        functions->SetFloatArrayRegion(this,array,start,len,buf);
    }
    void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
                              const jdouble *buf) {
        functions->SetDoubleArrayRegion(this,array,start,len,buf);
    }

    jint RegisterNatives(jclass clazz, const JNINativeMethod *methods,
                         jint nMethods) {
        return functions->RegisterNatives(this,clazz,methods,nMethods);
    }
    jint UnregisterNatives(jclass clazz) {
        return functions->UnregisterNatives(this,clazz);
    }

    jint MonitorEnter(jobject obj) {
        return functions->MonitorEnter(this,obj);
    }
    jint MonitorExit(jobject obj) {
        return functions->MonitorExit(this,obj);
    }

    jint GetJavaVM(JavaVM **vm) {
        return functions->GetJavaVM(this,vm);
    }

    void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) {
        functions->GetStringRegion(this,str,start,len,buf);
    }
    void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) {
        functions->GetStringUTFRegion(this,str,start,len,buf);
    }

    void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) {
        return functions->GetPrimitiveArrayCritical(this,array,isCopy);
    }
    void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) {
        functions->ReleasePrimitiveArrayCritical(this,array,carray,mode);
    }

    const jchar * GetStringCritical(jstring string, jboolean *isCopy) {
        return functions->GetStringCritical(this,string,isCopy);
    }
    void ReleaseStringCritical(jstring string, const jchar *cstring) {
        functions->ReleaseStringCritical(this,string,cstring);
    }

    jweak NewWeakGlobalRef(jobject obj) {
        return functions->NewWeakGlobalRef(this,obj);
    }
    void DeleteWeakGlobalRef(jweak ref) {
        functions->DeleteWeakGlobalRef(this,ref);
    }

    jboolean ExceptionCheck() {
        return functions->ExceptionCheck(this);
    }

    jobject NewDirectByteBuffer(void* address, jlong capacity) {
        return functions->NewDirectByteBuffer(this, address, capacity);
    }
    void* GetDirectBufferAddress(jobject buf) {
        return functions->GetDirectBufferAddress(this, buf);
    }
    jlong GetDirectBufferCapacity(jobject buf) {
        return functions->GetDirectBufferCapacity(this, buf);
    }
    jobjectRefType GetObjectRefType(jobject obj) {
        return functions->GetObjectRefType(this, obj);
    }

#endif /* __cplusplus */
};

typedef struct JavaVMOption {
    char *optionString;
    void *extraInfo;
} JavaVMOption;

typedef struct JavaVMInitArgs {
    jint version;

    jint nOptions;
    JavaVMOption *options;
    jboolean ignoreUnrecognized;
} JavaVMInitArgs;

typedef struct JavaVMAttachArgs {
    jint version;

    char *name;
    jobject group;
} JavaVMAttachArgs;

/* These will be VM-specific. */

#define JDK1_2
#define JDK1_4

/* End VM-specific. */

struct JNIInvokeInterface_ {
    void *reserved0;
    void *reserved1;
    void *reserved2;

    jint (JNICALL *DestroyJavaVM)(JavaVM *vm);

    jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args);

    jint (JNICALL *DetachCurrentThread)(JavaVM *vm);

    jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version);

    jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args);
};

struct JavaVM_ {
    const struct JNIInvokeInterface_ *functions;
#ifdef __cplusplus

    jint DestroyJavaVM() {
        return functions->DestroyJavaVM(this);
    }
    jint AttachCurrentThread(void **penv, void *args) {
        return functions->AttachCurrentThread(this, penv, args);
    }
    jint DetachCurrentThread() {
        return functions->DetachCurrentThread(this);
    }

    jint GetEnv(void **penv, jint version) {
        return functions->GetEnv(this, penv, version);
    }
    jint AttachCurrentThreadAsDaemon(void **penv, void *args) {
        return functions->AttachCurrentThreadAsDaemon(this, penv, args);
    }
#endif
};

#ifdef _JNI_IMPLEMENTATION_
#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT
#else
#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT
#endif
_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_GetDefaultJavaVMInitArgs(void *args);

_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args);

_JNI_IMPORT_OR_EXPORT_ jint JNICALL
JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);

/* Defined by native libraries. */
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved);

JNIEXPORT void JNICALL
JNI_OnUnload(JavaVM *vm, void *reserved);

#define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
#define JNI_VERSION_1_6 0x00010006
#define JNI_VERSION_1_8 0x00010008

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* !_JAVASOFT_JNI_H_ */

Added emulators/emulator-base/src/main/headers/jni_linux.h.




















































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_

#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
  #define JNIEXPORT     __attribute__((visibility("default")))
  #define JNIIMPORT     __attribute__((visibility("default")))
#else
  #define JNIEXPORT
  #define JNIIMPORT
#endif

#define JNICALL

typedef int jint;
#ifdef _LP64 /* 64-bit Solaris */
typedef long jlong;
#else
typedef long long jlong;
#endif

typedef signed char jbyte;

#endif /* !_JAVASOFT_JNI_MD_H_ */

Added emulators/emulator-base/src/main/headers/jni_mac.h.











































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_

#define JNIEXPORT     __attribute__((visibility("default")))
#define JNIIMPORT     __attribute__((visibility("default")))
#define JNICALL

typedef int jint;
#ifdef _LP64 /* 64-bit */
typedef long jlong;
#else
typedef long long jlong;
#endif

typedef signed char jbyte;

#endif /* !_JAVASOFT_JNI_MD_H_ */

Added emulators/emulator-base/src/main/headers/jni_win.h.






































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_

#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall

typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;

#endif /* !_JAVASOFT_JNI_MD_H_ */

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/AbstractSystemCallHandler.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

/**
 * This class handles system calls.
 *
 * @since 2020/02/22
 */
public class AbstractSystemCallHandler {
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/EmulatorAssembly.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

import cc.squirreljme.emulator.fb.NativeFramebuffer;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This contains the implementation of some system calls in the event that the
 * JNI emulation layer does not have a C-based implementation of a method.
 *
 * @since 2020/02/26
 */
public final class EmulatorAssembly
{
	/** The thread contexts, storing thread specific information. */
	private static final ThreadLocal<EmulatorThreadContext> _CONTEXT =
		new ThreadLocal<>();
	
	/**
	 * Not used.
	 *
	 * @since 2020/02/26
	 */
	private EmulatorAssembly()
	{
	}
	
	/**
	 * Handles system calls in Java.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2020/02/26
	 */
	public static long systemCall(short __si, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		// We need the context for thread based info
		EmulatorThreadContext context = EmulatorAssembly.threadContext();
		
		// Depends on the system call
		switch (__si)
		{
				// System calls that are supported?
			case SystemCallIndex.QUERY_INDEX:
				{
					// 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:
							return 1;
						
							// Not-implemented
						default:
							return 0;
					}
				}
			
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					context.setError(__si, 0);
					
					return context.getError((short)__a);
				}
			
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					context.setError(__si, 0);
					
					int oldError = context.getError((short)__a);
					context.setError((short)__a, __b);
					return oldError;
				}
			
				// Access the framebuffer
			case SystemCallIndex.FRAMEBUFFER:
				return NativeFramebuffer.getInstance().systemCall(context,
					__a, __b, __c, __d, __e, __f, __g, __h);
				
				// Current wall clock
			case SystemCallIndex.TIME_MILLI_WALL:
				{
					context.setError(__si, 0);
					
					return System.currentTimeMillis();
				}
			
				// Current monotonic clock
			case SystemCallIndex.TIME_NANO_MONO:
				{
					context.setError(__si, 0);
					
					return System.nanoTime();
				}
			
				// Un-handled, set as not supported and return a default value
			default:
				// Debug
				System.err.printf(
					"SysCall?: %d(%d, %d, %d, %d, %d, %d, %d, %d)%n",
					__si, __a, __b, __c, __d, __e, __f, __g, __h);
				
				// Set error
				context.setError(__si,
					SystemCallError.UNSUPPORTED_SYSTEM_CALL);
				return 0;
		}
	}
	
	/**
	 * Returns the current thread context.
	 *
	 * @return The thread context.
	 * @since 2020/02/26
	 */
	public static EmulatorThreadContext threadContext()
	{
		// Has this been created already?
		EmulatorThreadContext rv = EmulatorAssembly._CONTEXT.get();
		if (rv != null)
			return rv;
		
		// Does not exist, needs to be created
		synchronized (EmulatorAssembly.class)
		{
			// Check again
			rv = EmulatorAssembly._CONTEXT.get();
			if (rv != null)
				return rv;
			
			EmulatorAssembly._CONTEXT.set((rv = new EmulatorThreadContext()));
			return rv;
		}
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/EmulatorThreadContext.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.emulator;

// -*- 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.
// ---------------------------------------------------------------------------

import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This contains the needed context for emulator threads.
 *
 * @since 2020/02/26
 */
public final class EmulatorThreadContext
{
	/** Error codes that are available. */
	public final int[] errorCodes =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/**
	 * Gets the error for the given system call.
	 *
	 * @param __si The system call error to get.
	 * @return The error code.
	 * @since 2020/02/26
	 */
	public final int getError(short __si)
	{
		// If the index is out of bounds, write to the first system call
		return this.errorCodes[((__si < 0 ||
			__si >= SystemCallIndex.NUM_SYSCALLS) ? 0 : __si)];
	}
	
	/**
	 * Sets the error for the given system call.
	 *
	 * @param __si The system call error to set.
	 * @param __code The new code.
	 * @since 2020/02/26
	 */
	public final void setError(short __si, int __code)
	{
		// If the index is out of bounds, write to the first system call
		this.errorCodes[((__si < 0 ||
			__si >= SystemCallIndex.NUM_SYSCALLS) ? 0 : __si)] = __code;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/NativeBinding.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

/**
 * This class manages the native bindings.
 *
 * @since 2020/02/25
 */
public final class NativeBinding
{
	static
	{
		// Find the library to load
		String libName = System.mapLibraryName("emulator-base");
		
		// Copy resource to the output
		Path tempDir = null,
			libFile = null;
		try (InputStream in = NativeBinding.class.
			getResourceAsStream("/" + libName))
		{
			if (in == null)
				throw new RuntimeException(String.format(
					"Library %s not found in resource.", libName));
			
			// Store the library as a given file
			tempDir = Files.createTempDirectory("squirreljme-lib");
			libFile = tempDir.resolve(libName);
			
			// Write to the disk as we can only load there
			try (OutputStream out = Files.newOutputStream(libFile,
					StandardOpenOption.CREATE,
					StandardOpenOption.TRUNCATE_EXISTING,
					StandardOpenOption.WRITE))
			{
				// Store here
				byte[] buf = new byte[4096];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					out.write(buf, 0, rc);
				}
				
				// Make sure it is on the disk
				out.flush();
			}
		}
		catch (IOException e)
		{
			// Try to clear the file
			try
			{
				if (libFile != null)
					Files.delete(libFile);
				
				if (tempDir != null)
					Files.delete(tempDir);
			}
			catch (IOException f)
			{
				e.addSuppressed(f);
			}
			
			throw new RuntimeException("Could not copy native library.", e);
		}
		
		// Attempt cleanup at shutdown.
		final Path[] paths = new Path[]{libFile, tempDir};
		Runtime.getRuntime().addShutdownHook(new Thread(() ->
			{
				try
				{
					for (Path p : paths)
						Files.delete(p);
				}
				catch (IOException e)
				{
				}
			}, "SquirrelJME-LibraryCleanupThread"));
		
		// Try loading the library now
		System.load(libFile.toString());
		
		// Bind methods
		if (NativeBinding.__bindMethods() != 0)
			throw new RuntimeException("Could not bind methods!");
	}
	
	/**
	 * Binds methods accordingly.
	 *
	 * @since 2020/02/26
	 */
	private static native int __bindMethods();
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/SquirrelJMEAlterSuiteListener.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collection;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
import org.testng.IAlterSuiteListener;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

/**
 * Alters suite names.
 *
 * @since 2020/02/26
 */
public class SquirrelJMEAlterSuiteListener
	implements IAlterSuiteListener
{
	/** The service resource file. */
	public static final String SERVICE_RESOURCE =
		"META-INF/services/net.multiphasicapps.tac.TestInterface";
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/26
	 */
	@Override
	public void alter(List<XmlSuite> suites)
	{
		// Poke the native bindings class so it gets initializes and setup
		new NativeBinding();
		
		// Go through our test suites
		for (XmlSuite suite : suites)
		{
			// Only adjust SquirrelJME suites
			if (!"squirreljme".equals(suite.getName()))
				continue;
			
			// Get pre-existing test group
			XmlTest test = null;
			for (XmlTest sub : suite.getTests())
				if ("tests".equals(sub.getName()))
				{
					test = sub;
					break;
				}
			
			// Create one?
			if (test == null)
			{
				test = new XmlTest();
				test.setSuite(suite);
				test.setName("tests");
				
				suite.addTest(test);
			}
			
			// Add tests for every test class (each class has just one)
			List<XmlClass> classies = new LinkedList<>();
			for (String testClass : SquirrelJMEAlterSuiteListener
				.findTestClasses())
				try
				{
					XmlClass classy = new XmlClass();
					
					// It needs to point to our class!
					classy.setName(testClass);
					classy.setClass(Class.forName(testClass));
					
					// Use this test
					classies.add(classy);
				}
				catch (ClassNotFoundException e)
				{
					// Ignore
				}
			
			// Use these classes
			test.setClasses(classies);
		}
	}
	
	/**
	 * Returns the base name for the class.
	 *
	 * @param __name The name of the class.
	 * @return The base name.
	 * @since 2020/02/26
	 */
	public static String baseClassName(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("No name specified.");
		
		int ld = __name.lastIndexOf('.');
		return (ld < 0 ? __name : __name.substring(ld + 1));
	}
	
	/**
	 * Returns the base package for the class.
	 *
	 * @param __name The name of the class.
	 * @return The base package.
	 * @since 2020/02/26
	 */
	public static String basePackage(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("No name specified.");
		
		int ld = __name.lastIndexOf('.');
		return (ld < 0 ? __name : __name.substring(0, ld));
	}
	
	/**
	 * Collects all of the test classes that are known about.
	 *
	 * @return The test classes.
	 * @since 2020/02/26
	 */
	public static Iterable<String> findTestClasses()
	{
		Collection<String> rv = new LinkedList<>();
		
		// Process resources
		try
		{
			// Get all resource files
			Enumeration<URL> urls = SquirrelJMEAlterSuiteListener.class.
				getClassLoader().getResources(
				SquirrelJMEAlterSuiteListener.SERVICE_RESOURCE);
			
			// Process them all
			while (urls.hasMoreElements())
			{
				URL url = urls.nextElement();
				
				// Read in files
				try (BufferedReader br = new BufferedReader(
					new InputStreamReader(url.openStream(),
					"utf-8")))
				{
					for (;;)
					{
						String ln = br.readLine();
						
						// EOF?
						if (ln == null)
							break;
						
						// Ignore blank lines
						if (ln.isEmpty())
							continue;
						
						// Store test name
						rv.add(ln.replace('/', '.'));
					}
				}
				catch (IOException e)
				{
					// Ignore
				}
			}
		}
		catch (IOException e)
		{
			// Ignore
		}
		
		return rv;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/SquirrelJMETest.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

import net.multiphasicapps.tac.TestExecution;
import net.multiphasicapps.tac.TestInterface;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.TestException;
import org.testng.annotations.Test;

/**
 * Used to wrap SquirrelJME tests.
 *
 * @since 2020/02/23
 */
public class SquirrelJMETest
{
	/** The test class to execute. */
	protected final Class<?> testClass;
	
	/**
	 * Initializes the test information.
	 *
	 * @param __test The test class.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/23
	 */
	public SquirrelJMETest(Class<?> __test)
		throws NullPointerException
	{
		if (__test == null)
			throw new NullPointerException("No test class specified.");
		
		this.testClass = __test;
	}
	
	/**
	 * Runs the SquirrelJME test.
	 *
	 * @since 2020/02/23
	 */
	@Test
	public void test()
	{
		// Create instance of test
		TestInterface instance;
		try
		{
			instance = (TestInterface)this.testClass.newInstance();
		}
		catch (ClassCastException|InstantiationException|
			IllegalAccessException e)
		{
			throw new RuntimeException("Failed to run test.", e);
		}
		
		// Print name of test as debug
		System.err.printf("Running test %s...%n",
			instance.getClass().getName());
		
		// Run the test with no parameters passed
		TestExecution execution = instance.runExecution();
		
		// Depends on the result
		switch (execution.status)
		{
			case SUCCESS:
				System.err.println(execution.result);
				break;
				
			case FAILED:
				execution.expected.printComparison(System.err,
					execution.result);
				Assert.fail(execution.result.toString());
				break;
				
			case TEST_EXCEPTION:
				throw new TestException("Error in test.",
					((execution.tossed instanceof Throwable) ?
						(Throwable)execution.tossed : (Throwable)null));
			
			case UNTESTABLE:
				throw new SkipException("Skipping test.",
					((execution.tossed instanceof Throwable) ?
						(Throwable)execution.tossed : (Throwable)null));
		}
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/SquirrelJMETestFactory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator;

import java.util.Collection;
import java.util.LinkedList;
import org.testng.ITestContext;
import org.testng.annotations.Factory;

/**
 * The factory for SquirrelJME Tests.
 *
 * @since 2020/02/23
 */
public class SquirrelJMETestFactory
{
	/** The name of the service. */
	public static final String SERVICE_NAME =
		"META-INF/services/net.multiphasicapps.tac.TestInterface";
	
	/**
	 * Produces the tests to run.
	 *
	 * @return The tests to run.
	 * @since 2020/02/23
	 */
	@Factory
	public Object[] createInstance(ITestContext __context)
		throws Exception
	{
		// Poke the native bindings class so it gets initializes and setup
		new NativeBinding();
		
		// Collect tests
		Collection<Object> tests = new LinkedList<>();
		for (String testName : SquirrelJMEAlterSuiteListener.findTestClasses())
			try
			{
				tests.add(Class.forName(testName));
			}
			catch (ClassNotFoundException e)
			{
				// Ignore
			}
		
		return tests.<Object>toArray(new Object[tests.size()]);
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/fb/NativeFramebuffer.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator.fb;

import cc.squirreljme.emulator.EmulatorThreadContext;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * Contains the support for the framebuffer.
 *
 * @since 2020/02/29
 */
public final class NativeFramebuffer
{
	/** Framebuffer instance. */
	private static NativeFramebuffer _FRAMEBUFFER =
		null;
	
	/** The framebuffer title. */
	protected String title;
	
	/**
	 * Performs system call with the framebuffer.
	 *
	 * @param __ctx The emulator context.
	 * @param __func The function to perform.
	 * @param __a A.
	 * @param __b B.
	 * @param __c C.
	 * @param __d D.
	 * @param __e E.
	 * @param __f F.
	 * @param __g G.
	 * @return The result of the system call.
	 * @since 2020/02/29
	 */
	public final long systemCall(EmulatorThreadContext __ctx, int __func,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g)
	{
		// Depends on the function
		switch (__func)
		{
				// The format of the framebuffer
			case Framebuffer.CONTROL_FORMAT:
				return Framebuffer.FORMAT_INTEGER_RGB888;
			
				// The capabilities of the framebuffer
			case Framebuffer.CONTROL_GET_CAPABILITIES:
				return Framebuffer.CAPABILITY_COLOR |
					Framebuffer.CAPABILITY_IPC_EVENTS |
					Framebuffer.CAPABILITY_KEYBOARD |
					Framebuffer.CAPABILITY_TOUCH;
			
				// Set title of the framebuffer
			case Framebuffer.CONTROL_SET_TITLE:
				this.title = String.valueOf((char[])Assembly.pointerToObject(
					Assembly.longPack(__a, __b)));
				return 0;
			
			default:
				// So it is more easily known
				System.err.printf("FB?: %d(%d, %d, %d, %d, %d, %d, %d)\n",
					__func, __a, __b, __c, __d, __e, __f, __g);
				
				// Return as not supported
				__ctx.setError(SystemCallIndex.FRAMEBUFFER,
					SystemCallError.UNSUPPORTED_SYSTEM_CALL);
				return 0;
		}
	}
	
	/**
	 * Returns instance of the framebuffer.
	 *
	 * @return The framebuffer instance.
	 * @since 2020/02/29
	 */
	public static NativeFramebuffer getInstance()
	{
		NativeFramebuffer rv = NativeFramebuffer._FRAMEBUFFER;
		
		if (rv == null)
			synchronized (NativeFramebuffer.class)
			{
				rv = NativeFramebuffer._FRAMEBUFFER;
				if (rv == null)
				{
					rv = new NativeFramebuffer();
					NativeFramebuffer._FRAMEBUFFER = rv;
				}
			}
		
		return rv;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/fb/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator.fb;

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the base classes needed to support the emulator
 * sub-system.
 *
 * @since 2020/02/17
 */

package cc.squirreljme.emulator;

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

package cc.squirreljme.emulator.profiler;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the location of a frame.
 *
 * @since 2018/11/11
 */
public final class FrameLocation
	implements Comparable<FrameLocation>
{
	/** Location which represents the entry point node. */
	public static final FrameLocation ENTRY_POINT =
		new FrameLocation("<entry>", "<entry>", "()V");
	
	/** The class. */
	protected final String inclass;
	
	/** The method name. */
	protected final String methodname;
	
	/** The method type. */
	protected final String methodtype;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the location.
	 *
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public FrameLocation(String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		if (__cl == null || __mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.methodname = __mn;
		this.methodtype = __mt;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int compareTo(FrameLocation __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof FrameLocation))
			return false;
		
		FrameLocation o = (FrameLocation)__o;
		return this.inclass.equals(o.inclass) &&
			this.methodname.equals(o.methodname) &&
			this.methodtype.equals(o.methodtype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int hashCode()
	{
		return this.inclass.hashCode() ^
			this.methodname.hashCode() ^
			this.methodtype.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.inclass + "::" +
				this.methodname + ":" + this.methodtype));
		
		return rv;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/profiler/ProfiledFrame.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
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
191
192
193
194
195
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.profiler;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This contains information and statistics for a single frame within the
 * thread stack.
 *
 * @since 2018/11/10
 */
public final class ProfiledFrame
{
	/** Maximum stack depth. */
	public static final int MAX_STACK_DEPTH =
		64;
	
	/** The location of this frame. */
	protected final FrameLocation location;
	
	/** The depth of this frame. */
	final int _depth;
	
	/** The sub-frames of this frame. */
	final Map<FrameLocation, ProfiledFrame> _frames =
		new LinkedHashMap<>();
	
	/** The number of calls made into the frame. */
	int _numcalls;
	
	/** Cumulative time spent in this frame and child frames. */
	long _traceruntime;
	
	/** Cumulative time spent in this frame and child frames without sleep. */
	long _tracecputime;
	
	/** Time only spent in this frame. */
	long _frameruntime;
	
	/** Time only spent in this frame without sleep. */
	long _framecputime;
	
	/** Time to subtract from the measured self times. */
	private long _subtractself;
	
	/** Current frame start time. */
	private long _currentstart =
		Long.MIN_VALUE;
	
	/** Current time sub-frame started execution, to remove self time. */
	private long _currentsubstart =
		Long.MIN_VALUE;
	
	/**
	 * Initializes this frame.
	 *
	 * @param __l The frame location.
	 * @param __d The depth of this frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ProfiledFrame(FrameLocation __l, int __d)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.location = __l;
		this._depth = __d;
	}
	
	/**
	 * Indicates that this frame has been entered.
	 *
	 * @param __ns The starting nanoseconds.
	 * @throws IllegalStateException If the frame is already entered.
	 * @since 2018/11/11
	 */
	public final void enteredFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH01 Cannot enter frame which is in the
		// entered state.}
		long cs = this._currentstart;
		if (cs != Long.MIN_VALUE)
			throw new IllegalStateException("AH01");
			
		// {@squirreljme.error AH02 Cannot enter frame that is in an invoke.}
		if (this._currentsubstart != Long.MIN_VALUE)
			throw new IllegalStateException("AH02");
		
		// Mark time
		this._currentstart = __ns;
	}
	
	/**
	 * Indicates that the frame has been exited.
	 *
	 * @param __ns The time of the exit.
	 * @return The time spent in this frame, in total, self time, and CPU
	 * time.
	 * @throws IllegalStateException If the frame has not been entered.
	 * @since 2018/11/11
	 */
	public final long[] exitedFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH03 Cannot exit frame which is in the
		// exited state.}
		long cs = this._currentstart;
		if (cs == Long.MIN_VALUE)
			throw new IllegalStateException("AH03");
		
		// {@squirreljme.error AH04 Cannot exit frame that is in an invoke.}
		if (this._currentsubstart != Long.MIN_VALUE)
			throw new IllegalStateException("AH04");
		
		// Determine the cumulative and self time spent
		long total = __ns - cs,
			self = total - this._subtractself;
		
		// Increase call count
		this._numcalls++;
		
		// All sub-frames times
		this._traceruntime += total;
		this._tracecputime += total;
		
		// And only this frame time
		this._frameruntime += self;
		this._framecputime += self;
		
		// Clear these for next time
		this._currentstart = Long.MIN_VALUE;
		this._subtractself = 0;
		
		// Return both times since they may be useful
		return new long[]{total, self, total};
	}
	
	/**
	 * Indicates that this frame is no longer invoking some other method.
	 *
	 * @param __ns The ending nanoseconds.
	 * @return The time which has passed.
	 * @throws IllegalStateException If the frame is not in an invoke.
	 * @since 2018/11/11
	 */
	public final long invokeEnd(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH05 Frame is not in an invoke.}
		long css = this._currentsubstart;
		if (css == Long.MIN_VALUE)
			throw new IllegalStateException("AH05");
		
		// Reset
		this._currentsubstart = Long.MIN_VALUE;
		
		// Return the amount of time that was spend in this invocation
		long rv = __ns - css;
		this._subtractself += rv;
		return rv;
	}
	
	/**
	 * Indicates that this frame is invoking some other method.
	 *
	 * @param __ns The starting nanoseconds.
	 * @throws IllegalStateException If the frame is already in an invoke.
	 * @since 2018/11/11
	 */
	public final void invokeStart(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH06 Frame is already invoking another frame.}
		long css = this._currentsubstart;
		if (css != Long.MIN_VALUE)
			throw new IllegalStateException("AH06");
		
		// Mark it
		this._currentsubstart = __ns;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/profiler/ProfiledThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.profiler;

import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * This stores information along with the thread information along with the
 * call stack.
 *
 * This class is not thread safe and it is assumed to be called from the same
 * thread each time.
 *
 * @since 2018/11/10
 */
public final class ProfiledThread
{
	/** The name of this thread. */
	protected final String name;
	
	/** The root frames for this thread. */
	final Map<FrameLocation, ProfiledFrame> _frames =
		new LinkedHashMap<>();
	
	/** The stack of currently active frames. */
	private final Deque<ProfiledFrame> _stack =
		new LinkedList<>();
	
	/** Grand invocation total. */
	long _invtotal;
	
	/** Total time. */
	long _totaltime;
	
	/** CPU time. */
	long _cputime;
	
	/**
	 * Initializes the thread information.
	 *
	 * @param __n The name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public ProfiledThread(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * Enters the given frame, the enter time is the system time.
	 *
	 * @param __cl The name of the class.
	 * @param __mn The name of the method.
	 * @param __md The type of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public ProfiledFrame enterFrame(String __cl, String __mn, String __md)
		throws NullPointerException
	{
		return this.enterFrame(__cl, __mn, __md, System.nanoTime());
	}
	
	/**
	 * Enters the given frame.
	 *
	 * @param __cl The name of the class.
	 * @param __mn The name of the method.
	 * @param __md The type of the method.
	 * @param __ns The The starting time in nanoseconds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public ProfiledFrame enterFrame(String __cl, String __mn, String __md,
		long __ns)
		throws NullPointerException
	{
		if (__cl == null || __mn == null || __md == null)
			throw new NullPointerException("NARG");
		
		// Used as map key
		FrameLocation loc = new FrameLocation(__cl, __mn, __md);
		
		// We need to know the top-most frame because
		Deque<ProfiledFrame> stack = this._stack;
		ProfiledFrame top = stack.peek();
		
		// If the frame was not already recorded in the map then add a new one
		// but we always keep existing frames since their times add up and
		// such. Also remember that there is depth to this, like we cannot
		// just keep adding to the root and such!
		Map<FrameLocation, ProfiledFrame> frames = (top == null ?
			this._frames : top._frames);
		ProfiledFrame rv = frames.get(loc);
		if (rv == null)
			frames.put(loc, (rv = new ProfiledFrame(loc, stack.size() + 1)));
		
		// Tell the top-most frame that we are in an invoke, so this removes
		// self time accordingly
		if (top != null)
			top.invokeStart(__ns);
		
		// Push the frame to the stack since it is active
		this._stack.push(rv);
		
		// Indicate that this frame has been entered
		rv.enteredFrame(__ns);
		
		// Using this frame
		return rv;
	}
	
	/**
	 * Exits all frames as needed, the current time is used.
	 *
	 * @since 2019/06/30
	 */
	public void exitAll()
	{
		this.exitAll(System.nanoTime());
	}
	
	/**
	 * Exits all frames as needed.
	 *
	 * @param __ns The nanoseconds when exit all has happened.
	 * @since 2018/11/11
	 */
	public void exitAll(long __ns)
	{
		// Empty the frame stack
		Deque<ProfiledFrame> stack = this._stack;
		while (!stack.isEmpty())
			this.exitFrame(__ns);
	}
	
	/**
	 * Exits the frame which at the top of the stack, the current time is
	 * used.
	 *
	 * @return The exited frame.
	 * @throws IllegalStateException If there is no frame to exit.
	 * @since 2018/11/10
	 */
	public ProfiledFrame exitFrame()
		throws IllegalStateException
	{
		return this.exitFrame(System.nanoTime());
	}
	
	/**
	 * Exits the frame which at the top of the stack.
	 *
	 * @param __ns The nanoseconds when the frame exited.
	 * @return The exited frame.
	 * @throws IllegalStateException If there is no frame to exit.
	 * @since 2018/11/10
	 */
	public ProfiledFrame exitFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH07 No frame is in the stack to exit in.}
		Deque<ProfiledFrame> stack = this._stack;
		ProfiledFrame rv = stack.pop();
		if (rv == null)
			throw new IllegalStateException("AH07");
		
		// Tell that popped frame we left
		long[] times = rv.exitedFrame(__ns);
		
		// If we had a frame underneath, say the invocation has ended
		ProfiledFrame newtop = stack.peek();
		if (newtop != null)
			newtop.invokeEnd(__ns);
		
		// If all threads are out, count the times
		else
		{
			this._totaltime += times[0];
			this._cputime += times[2];
			
			// Invocation total goes up after each method ends
			this._invtotal++;
		}
		
		// Return the frame which was popped
		return rv;
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/profiler/ProfilerSnapshot.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.profiler;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.io.ZLibCompressor;

/**
 * This represents the main profiler snapshot which contains all of the data
 * within what is to be profiled, it is mutable and accordingly allows for
 * export to NPS formats.
 *
 * @since 2018/11/10
 */
public final class ProfilerSnapshot
{
	/** The start time of the snapshot. */
	protected final long startmillis =
		System.currentTimeMillis();
	
	/** Threads that are being measured. */
	private final Map<String, ProfiledThread> _threads =
		new LinkedHashMap<>();
	
	/**
	 * Starts profiling the given thread.
	 *
	 * @param __name The name of the thread.
	 * @return A class to handle the profiling of threads via the call stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public final ProfiledThread measureThread(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		ProfiledThread rv = new ProfiledThread(__name);
		
		// Although the frames are not thread safe, this may be called at
		// any time from any thread although the returned class is only inteded
		// to be used by a single thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			threads.put(__name, rv);
		}
		
		return rv;
	}
	
	/**
	 * Exits all threads and all frames using the current time.
	 *
	 * @since 2019/06/30
	 */
	public final void exitAll()
	{
		this.exitAll(System.nanoTime());
	}
	
	/**
	 * Exits all threads and all frames.
	 *
	 * @param __ns The current time.
	 * @since 2019/04/19
	 */
	public final void exitAll(long __ns)
	{
		// Exit every single thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			for (ProfiledThread thread : threads.values())
				thread.exitAll(__ns);
		}
	}
	
	/**
	 * Writes snapshot information to the given stream.
	 *
	 * @param __ps The resulting stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeDumpTo(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		__ps.println("Profiler snapshot:");
		
		// Dump every thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			for (ProfiledThread t : threads.values())
			{
				// Banner
				__ps.print("  Thread ");
				__ps.print(t.name);
				__ps.println(':');
				
				// Dump frame info
				ProfilerSnapshot.__dumpFrames(__ps, 4, t._frames.values());
			}
		}
	}
	
	/**
	 * Writes the snapshot information to the given output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// We write to this because we need the data
		DataOutputStream cont = new DataOutputStream(__os);
		
		// Magic number
		cont.writeBytes("nBpRoFiLeR");
		
		// Version
		cont.write(1);
		cont.write(2);
		
		// Type
		cont.writeInt(1);
		
		// Write compressed snapshot data to the byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(2048))
		{
			// Compress the CPU data
			ZLibCompressor olddefl;
			try (ZLibCompressor defl = new ZLibCompressor(baos);
				DataOutputStream cpu = new DataOutputStream(defl))
			{
				// Used to get compressed size and such
				olddefl = defl;
				
				// Write header
				cpu.writeInt(1);
				
				// Timestamp and duration
				long start = this.startmillis;
				cpu.writeLong(start);
				
				// Threads are needed now
				Map<String, ProfiledThread> threads = this._threads;
				synchronized (threads)
				{
					// The duration of the trace is the maximum time any
					// thread has spent
					long maxtime = 0;
					for (ProfiledThread t : threads.values())
						maxtime = Math.max(maxtime, t._totaltime);
					cpu.writeLong(maxtime);
					
					// Thread time is always measured
					cpu.writeBoolean(true);
					
					// Build and write the instrumented method table
					Map<FrameLocation, Integer> mids = this.__doMethodTable();
					cpu.writeInt(mids.size());
					for (FrameLocation loc : mids.keySet())
					{
						cpu.writeUTF(loc.inclass);
						cpu.writeUTF(loc.methodname);
						cpu.writeUTF(loc.methodtype);
					}
				
					// Write thread data
					cpu.writeInt(threads.size());
				
					// Write individual thread
					for (ProfiledThread t : threads.values())
						this.__doWriteThread(cpu, t, mids);
				}
			}
			
			// Store sizes, which are important
			cont.writeInt(baos.size());
			cont.writeInt((int)Math.min(Integer.MAX_VALUE,
				olddefl.uncompressedBytes()));
			
			// Store the compressed data
			baos.writeTo(cont);
		}
		
		// Write properties of the snapshot
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(2048))
		{
			// Write them all
			try (PrintStream ps = new PrintStream(baos, true))
			{
				// Make sure it is flushed
				ps.flush();
			}
			
			// Store data
			cont.writeInt(baos.size());
			baos.writeTo(cont);
		}
		
		// Write comment
		cont.writeUTF("Generated by SquirrelJME " +
			"<https://multiphasicapps.net/>\n" +
			"Copyright (C) Stephanie Gawroriski 2016-2019\n" +
			"\n" +
			"Record date: " + new Date());
		
		// Make sure everything is flushed
		cont.flush();
	}
	
	/**
	 * Builds the the method table.
	 *
	 * @return The table of instrumented methods.
	 * @since 2018/11/11
	 */
	private final Map<FrameLocation, Integer> __doMethodTable()
	{
		// The table and the ID, which must be passable to sub-builders
		Map<FrameLocation, Integer> rv = new LinkedHashMap<>();
		int[] next = new int[1];
		
		// Need root frame for the entry point, used virtually to refer to
		// multiple initial points in the entry frame since that is a thing
		rv.put(FrameLocation.ENTRY_POINT, next[0]++);
		
		// Have to go through all threads recursively due to all the frames
		// that exist to build IDs
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			// Go through all threads
			for (ProfiledThread t : threads.values())
				this.__doMethodTableSub(rv, next, t._frames.values());
		}
		
		return rv;
	}
	
	/**
	 * Builds the method table for frames.
	 *
	 * @param __rv The table to write to.
	 * @param __nid The next ID.
	 * @param __fs The frames to process.
	 * @return The table of instrumented methods.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private final Map<FrameLocation, Integer> __doMethodTableSub(
		Map<FrameLocation, Integer> __rv,
		int[] __nid, Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__rv == null || __nid == null || __fs == null)
			throw new NullPointerException("NARG");
		
		// Handle each frame
		for (ProfiledFrame f : __fs)
		{
			// Ignore if limit has been reached
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH)
				continue;
			
			// If the location is not in the map, set the ID
			FrameLocation loc = f.location;
			if (!__rv.containsKey(loc))
			{
				// Generate new ID
				int id = __nid[0]++;
				
				// Store
				__rv.put(loc, id);
			}
			
			// Go into this frame's sub-frames
			this.__doMethodTableSub(__rv, __nid, f._frames.values());
		}
		
		return __rv;
	}
	
	/**
	 * Writes the thread information to the stream.
	 *
	 * @param __cpu The stream to write to.
	 * @param __t The thread information to write.
	 * @param __mids The method IDs.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private final void __doWriteThread(DataOutputStream __cpu,
		ProfiledThread __t, Map<FrameLocation, Integer> __mids)
		throws IOException, NullPointerException
	{
		if (__cpu == null || __t == null || __mids == null)
			throw new NullPointerException("NARG");
		
		// ID and name
		__cpu.writeInt(__t.name.hashCode());
		__cpu.writeUTF(__t.name);
		
		// Always measure thread time
		__cpu.writeBoolean(true);
		
		// Parse the node table for this thread
		__NodeTable__ nodes = new __NodeTable__();
		nodes.parseThread(__t);
		
		// Write the node table
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Write to the temporary buffer
			nodes.writeTo(baos, __mids);
			
			// Store the node table
			__cpu.writeInt(baos.size());
			baos.writeTo(__cpu);
		}
		
		// Node size is always 28
		__cpu.writeInt(28);
		
		// Whole graph time
		__cpu.writeLong(__t._totaltime);
		__cpu.writeLong(__t._cputime);
		
		// No injected methods used
		__cpu.writeLong(0);
		__cpu.writeLong(0);
		
		// Pure time (always seems to be max value)
		__cpu.writeLong(Integer.MAX_VALUE);
		__cpu.writeLong(Integer.MAX_VALUE);
		
		// Net time
		__cpu.writeLong(__t._totaltime);
		__cpu.writeLong(__t._cputime);
		
		// The number of methods invoked
		__cpu.writeLong(__t._invtotal);
		
		// Always display CPU time
		__cpu.writeBoolean(true);
	}
	
	/**
	 * Dumps the frames to the given stream.
	 *
	 * @param __ps The stream to print to.
	 * @param __tab The current tab level.
	 * @param __fs The frames to dump.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private static final void __dumpFrames(PrintStream __ps, int __tab,
		Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__ps == null || __fs == null)
			throw new NullPointerException("NARG");
		
		// Go through each frame
		for (ProfiledFrame f : __fs)
		{
			// Write tabs first
			for (int i = 0; i < __tab; i++)
				__ps.print(' ');
			
			// Write the frame itself
			__ps.print(f.location);
			
			// Write information on the frame
			__ps.printf(" [n=%d, t=%d, s=%d]",
				f._numcalls,
				f._traceruntime,
				f._frameruntime);
			__ps.println();
			
			// Go into this frame's frames
			ProfilerSnapshot.__dumpFrames(__ps, __tab + 1, f._frames.values());
		}
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/profiler/__NodeTable__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.profiler;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This class contains the parsed node table which defines the structure for
 * each entry within the frame tree. A node represents a single frame.
 *
 * @since 2018/11/11
 */
final class __NodeTable__
{
	/** Linear set of frame nodes. */
	private final List<ProfiledFrame> _linear = 
		new ArrayList<>();
	
	/** Offsets for each node. */
	private final Map<ProfiledFrame, __Position__> _offsets =
		new HashMap<>();
	
	/** Current position. */
	private final __Position__ _at =
		new __Position__();
	
	/** Overflowed narrow point? */
	private boolean _overflowed;
	
	/**
	 * Parses the frames and loads into a node table.
	 *
	 * @param __fs The input frames to map.
	 * @param __depth The depth of the stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void parse(Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
			
		List<ProfiledFrame> linear = this._linear;
		Map<ProfiledFrame, __Position__> offsets = this._offsets;
		
		// Overflow check for wider offsets
		boolean overflowed = false;
		
		// Determine positions for all nodes
		__Position__ at = this._at;
		for (ProfiledFrame f : __fs)
		{
			// Too deep?
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH)
				continue;
			
			// Will need to know how many sub-frames there are
			Collection<ProfiledFrame> sub = f._frames.values();
			
			// Track position of this frame
			linear.add(f);
			offsets.put(f, at.increment(sub.size()));
			
			// Handle sub-frames for this frame
			this.parse(sub);
			
			// If these many bytes were written we overflow now
			if (at._narrow > 16777215)
				overflowed = true;
		}
		
		// Did we overflow?
		if (overflowed)
			this._overflowed = true;
	}
	
	/**
	 * Parses the frames and loads into a node table.
	 *
	 * @param __t The thread to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void parseThread(ProfiledThread __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		Iterable<ProfiledFrame> frames = __t._frames.values();
		
		// Create virtual frame since the root actually can have multiple
		// methods forking from it and the profiler format can only handle
		// a single root
		ProfiledFrame vframe = new ProfiledFrame(FrameLocation.ENTRY_POINT,
			0);
		
		// Only ever called once
		vframe._numcalls = 1;
		
		// Initialize frame times with thread times
		vframe._traceruntime = __t._totaltime;
		vframe._tracecputime = __t._cputime;
		
		// There is no self time since this is purely a virtual node
		vframe._frameruntime = 0;
		vframe._framecputime = 0;
		
		// Store the thread sub-frames into this virtual thread
		Map<FrameLocation, ProfiledFrame> vsubf = vframe._frames;
		for (ProfiledFrame f : frames)
			vsubf.put(f.location, f);
		
		// Parse this special frame, which will then parse its sub-frames
		// accordingly
		this.parse(Arrays.<ProfiledFrame>asList(vframe));
	}		
	
	/**
	 * Writes the node table to the given stream.
	 *
	 * @param __os The stream to write to.
	 * @param __mids Node IDs.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeTo(OutputStream __os,
		Map<FrameLocation, Integer> __mids)
		throws IOException, NullPointerException
	{
		if (__os == null || __mids == null)
			throw new NullPointerException("NARG");
		
		DataOutputStream dos = new DataOutputStream(__os);
		
		// If there were a large number of entries written then sub-node
		// offsets use more bytes
		List<ProfiledFrame> linear = this._linear;
		boolean wide = this._overflowed;
		
		// Just go through every frame and write it using a simple linear
		// index
		Map<ProfiledFrame, __Position__> offsets = this._offsets;
		for (ProfiledFrame f : linear)
		{
			// Too deep or missing location ID?
			FrameLocation location = f.location;
			Integer flid = __mids.get(f.location);
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH || flid == null)
				continue;
			
			// The frame location ID, this is data stored in a previous table
			dos.writeShort(flid);
			
			// Number of calls
			dos.writeInt((int)Math.min(Integer.MAX_VALUE, f._numcalls));
			
			// Total time and self time
			__NodeTable__.__writeLong40(dos, f._traceruntime);
			__NodeTable__.__writeLong40(dos, f._frameruntime);
			
			// Total time and self time (not sleeping/blocking)
			__NodeTable__.__writeLong40(dos, f._tracecputime);
			__NodeTable__.__writeLong40(dos, f._framecputime);
			
			// Write offsets to the sub-frame nodes
			Collection<ProfiledFrame> sub = f._frames.values();
			
			// Determine and write the actual number of sub-frames used
			int actsubs = 0;
			for (ProfiledFrame sf : sub)
				if (sf._depth >= ProfiledFrame.MAX_STACK_DEPTH)
					continue;
				else
					actsubs++;
			dos.writeShort(actsubs);
			
			// Write sub-frame table
			for (ProfiledFrame sf : sub)
			{
				// Too deep
				if (sf._depth >= ProfiledFrame.MAX_STACK_DEPTH)
					continue;
				
				__Position__ p = offsets.get(sf);
				
				// Nodes will either be wide or narrow
				if (wide)
					dos.writeInt(p._wide);
				else
					__NodeTable__.__writeInt24(dos, p._narrow);
			}
		}
	}
	
	/**
	 * Writes a 24-bit int.
	 *
	 * @param __dos The output stream.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @since 2018/11/11
	 */
	static final void __writeInt24(DataOutputStream __dos, int __v)
		throws IOException
	{
		// Only unsigned
		if (__v < 0)
			__v = 0;
		
		// This is limited to 24 bits, so cap it so there
		else if (__v > 16777215)
			__v = 16777215;
		
		// Write values
		__dos.writeByte((byte)(__v >>> 16));
		__dos.writeByte((byte)(__v >>> 8));
		__dos.writeByte((byte)(__v));
	}
	
	/**
	 * Writes a 40 bit long.
	 *
	 * @param __dos The output stream.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @since 2018/11/11
	 */
	static final void __writeLong40(DataOutputStream __dos, long __v)
		throws IOException
	{
		// Only unsigned
		if (__v < 0)
			__v = 0;
		
		// This is limited to 40 bits, so cap it so there
		else if (__v > 1099511627775L)
			__v = 1099511627775L;
		
		// Write values
		__dos.writeByte((byte)(__v >>> 32));
		__dos.writeByte((byte)(__v >>> 24));
		__dos.writeByte((byte)(__v >>> 16));
		__dos.writeByte((byte)(__v >>> 8));
		__dos.writeByte((byte)(__v));
	}
	
	/**
	 * Position of a node within the node table.
	 *
	 * @since 2018/11/11
	 */
	private static final class __Position__
	{
		/** Narrow position. */
		int _narrow;
		
		/** Wide position. */
		int _wide;
		
		/**
		 * Initializes default position.
		 *
		 * @since 2018/11/11
		 */
		__Position__()
		{
		}
		
		/**
		 * Initializes for the given positions.
		 *
		 * @param __n The narrow position.
		 * @param __w The wide position.
		 * @since 2018/11/11
		 */
		__Position__(int __n, int __w)
		{
			this._narrow = __n;
			this._wide = __w;
		}
		
		/**
		 * Increments this position by the given number of sub-node units
		 * and returns the old one.
		 *
		 * @param __num The number of sub-node references to increment by.
		 * @return The old position in a new object.
		 * @throws IllegalArgumentException If the number of nodes is negative.
		 * @since 2018/11/11
		 */
		public __Position__ increment(int __num)
			throws IllegalArgumentException
		{
			// {@squirreljme.error AH08 Cannot write negative number of
			// nodes.}
			if (__num < 0)
				throw new IllegalArgumentException("AH08");
			
			// Store the old position first
			int narrow = this._narrow,
				wide = this._wide;
			__Position__ rv = new __Position__(narrow, wide);
			
			// Increment with new offsets
			this._narrow = narrow + 28 + (__num * 3);
			this._wide = wide + 28 + (__num * 4);
			
			return rv;
		}
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/profiler/package-info.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the profiler or rather the code which supports the
 * generation of profiling snapshots which can be used to measure performance
 * and such.
 *
 * @since 2018/11/10
 */

package cc.squirreljme.emulator.profiler;

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/vm/ArraySuiteManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.util.Collection;
import java.util.LinkedList;

/**
 * This is a suite manager which is just a group of already specified
 * libraries.
 *
 * @since 2020/02/29
 */
public final class ArraySuiteManager
	implements VMSuiteManager
{
	/** Local libraries. */
	private final VMClassLibrary[] _libraries;
	
	/**
	 * Initializes the library manager.
	 *
	 * @param __libs Libraries to use.
	 * @since 2020/02/29
	 */
	public ArraySuiteManager(VMClassLibrary... __libs)
	{
		this._libraries = (__libs == null ? new VMClassLibrary[0] :
			__libs.clone());
			
		for (VMClassLibrary lib : this._libraries)
			if (lib == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * Initializes the library manager.
	 *
	 * @param __libs Libraries to use.
	 * @since 2020/02/29
	 */
	public ArraySuiteManager(Iterable<VMClassLibrary> __libs)
	{
		Collection<VMClassLibrary> copy = new LinkedList<>();
		for (VMClassLibrary lib : __libs)
			copy.add(lib);
		
		this._libraries = copy.<VMClassLibrary>toArray(
			new VMClassLibrary[copy.size()]);
		
		for (VMClassLibrary lib : this._libraries)
			if (lib == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/29
	 */
	@Override
	public String[] listLibraryNames()
	{
		VMClassLibrary[] libraries = this._libraries;
		int n = libraries.length;
		
		String[] rv = new String[n];
		for (int i = 0; i < n; i++)
			rv[i] = libraries[i].name();
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/29
	 */
	@Override
	public VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		for (VMClassLibrary lib : this._libraries)
			if (__s.equals(lib.name()))
				return lib;
		
		return null;
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This represents a class library which has been read into memory.
 *
 * @since 2018/12/08
 */
public final class InMemoryClassLibrary
	implements VMClassLibrary
{
	/** The name of this library. */
	protected final String name;
	
	/** The cache. */
	private final Map<String, byte[]> _cache;
	
	/**
	 * Internally initializes the library.
	 *
	 * @param __n The name.
	 * @param __m The internal mapping.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	private InMemoryClassLibrary(String __n, Map<String, byte[]> __m)
		throws NullPointerException
	{
		if (__n == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this._cache = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final String[] listResources()
	{
		Collection<String> names = this._cache.keySet();
		return names.<String>toArray(new String[names.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		// See if the byte data exists
		byte[] rv = this._cache.get(__rc);
		if (rv == null)
			return null;
		
		// Then use a byte array on it
		return new ByteArrayInputStream(rv);
	}
	
	/**
	 * Loads ZIP file data.
	 *
	 * @param __n The library name.
	 * @param __in The input stream.
	 * @return The class library.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	@SuppressWarnings("resource")
	public static final InMemoryClassLibrary loadZip(String __n,
		ZipStreamReader __in)
		throws IOException, NullPointerException
	{
		if (__n == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Target map
		Map<String, byte[]> rv = new HashMap<>();
		
		// Temporary buffer to reading class data
		byte[] buf = new byte[4096];
		
		// Process all entries
		ZipStreamEntry zse;
		while (true)
		{
			// No more entries?
			zse = __in.nextEntry();
			if (zse == null)
				break;
			
			// Copy data over
			try (ByteArrayOutputStream baos =
				new ByteArrayOutputStream(8192))
			{
				for (;;)
				{
					int rc = zse.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Cache
				rv.put(zse.name(), baos.toByteArray());
			}
			
			// Close
			zse.close();
		}
		
		return new InMemoryClassLibrary(__n, rv);
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This is a suite manager which merges multiple suite managers into one so
 * that more libraries from different sources may be included.
 *
 * @since 2018/12/08
 */
public final class MergedSuiteManager
	implements VMSuiteManager
{
	/** The source managers. */
	private final VMSuiteManager[] _sources;
	
	/**
	 * Initializes the merged suite manager.
	 *
	 * @param __s The sources to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	public MergedSuiteManager(VMSuiteManager... __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Defensive copy and check for nulls
		__s = __s.clone();
		for (VMSuiteManager s : __s)
			if (s == null)
				throw new NullPointerException("NARG");
		
		this._sources = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String[] listLibraryNames()
	{
		Set<String> rv = new LinkedHashSet<>();
		
		// Add libraries that exist, but do not duplicate them!
		for (VMSuiteManager m : this._sources)
			for (String s : m.listLibraryNames())
				rv.add(s);
		
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Go through the libraries and see if any exist
		for (VMSuiteManager m : this._sources)
		{
			VMClassLibrary rv = m.loadLibrary(__s);
			if (rv != null)
				return rv;
		}
		
		// Not found
		return null;
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This is a suite manager which uses the filesystem.
 *
 * @since 2018/12/08
 */
public final class PathSuiteManager
	implements VMSuiteManager
{
	/** The base lib directory. */
	protected final Path libpath;
	
	/** Cache of loaded libraries. */
	private final Map<String, VMClassLibrary> _cache =
		new HashMap<>();
	
	/**
	 * Initializes the suite manager.
	 *
	 * @param __lp The library path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/09
	 */
	public PathSuiteManager(Path __lp)
		throws NullPointerException
	{
		if (__lp == null)
			throw new NullPointerException("NARG");
		
		this.libpath = __lp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String[] listLibraryNames()
	{
		// Could fail
		try
		{
			Set<String> rv = new LinkedHashSet<>();
			
			// Go through directory entries
			try (DirectoryStream<Path> dir = Files.newDirectoryStream(
				this.libpath))
			{
				for (Path p : dir)
				{
					// Ignore directories
					if (Files.isDirectory(p))
						continue;
					
					String fn = p.getFileName().toString();
					if (fn.endsWith(".jar") || fn.endsWith(".JAR"))
						rv.add(fn);
				}
			}
			
			return rv.<String>toArray(new String[rv.size()]);
		}
		
		// Was not found, ignore
		catch (NoSuchFileException e)
		{
			return new String[0];
		}
		
		// Could not load!
		catch (IOException e)
		{
			e.printStackTrace();
			
			return new String[0];
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, VMClassLibrary> cache = this._cache;
		synchronized (cache)
		{
			VMClassLibrary rv = cache.get(__s);
			if (rv != null)
				return rv;
			
			// Pre-cached to not exist
			if (cache.containsKey(__s))
				return null;
			
			// Open file and stream the ZIP
			try (InputStream in = Files.newInputStream(
				this.libpath.resolve(__s), StandardOpenOption.READ);
				ZipStreamReader zsr = new ZipStreamReader(in))
			{
				cache.put(__s, (rv = InMemoryClassLibrary.loadZip(__s, zsr)));
				return rv;
			}
			
			// Does not exist, stop
			catch (NoSuchFileException e)
			{
				cache.put(__s, null);
				return null;
			}
			
			// Exists but it is not valid, verbosely fail
			catch (IOException e)
			{
				e.printStackTrace();
				
				cache.put(__s, null);
				return null;
			}
		}
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * This is a class library resource which is based on class resources.
 *
 * @since 2018/11/14
 */
public final class ResourceBasedClassLibrary
	implements VMClassLibrary
{
	/** The class to get resources from. */
	protected final Class<?> actingclass;
	
	/** The prefix for entries. */
	protected final String prefix;
	
	/** The name of this library. */
	protected final String name;
	
	/** Resources in this class. */
	private String[] _resources;
	
	/**
	 * Initializes the resource based class library.
	 *
	 * @param __act The class to act on.
	 * @param __pre The prefix for lookup.
	 * @param __name The name of the library.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/15
	 */
	public ResourceBasedClassLibrary(Class<?> __act, String __pre,
		String __name)
		throws NullPointerException
	{
		if (__act == null || __pre == null || __name == null)
			throw new NullPointerException("NARG");
		
		this.actingclass = __act;
		this.prefix = __pre;
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final String[] listResources()
	{
		// Pre-cached?
		String[] rv = this._resources;
		if (rv != null)
			return rv.clone();
		
		// Load in the resource list
		List<String> list = new LinkedList<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
			this.resourceAsStream("META-INF/squirreljme/resources.list"),
			"utf-8")))
		{
			String ln;
			while ((ln = br.readLine()) != null)
			{
				// Blank lines are not resources
				if (ln.isEmpty())
					continue;
				
				// Add otherwise
				list.add(ln);
			}
		}
		
		// {@squirreljme.error AK09 Could not load resource list.}
		catch (IOException e)
		{
			throw new VMException("AK09");
		}
		
		// Cache it and return
		this._resources = (rv = list.<String>toArray(new String[list.size()]));
		return rv.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		return this.actingclass.getResourceAsStream(
			this.prefix + __rc);
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This is a suite manager which is based on resources for accessing various
 * classes and other resources.
 *
 * @since 2018/11/14
 */
public final class ResourceBasedSuiteManager
	implements VMSuiteManager
{
	/** The class to get resources from. */
	protected final Class<?> actingclass;
	
	/** The prefix for libraries. */
	protected final String prefix;
	
	/** Cache of libraries. */
	private final Map<String, VMClassLibrary> _cache =
		new HashMap<>();
	
	/** Cache of all available suites. */
	private String[] _libs;
	
	/**
	 * Initializes the suite manager.
	 *
	 * @param __act The class to source resources from.
	 * @param __prefix The prefix for library lookup.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/14
	 */
	public ResourceBasedSuiteManager(Class<?> __act, String __prefix)
		throws NullPointerException
	{
		if (__act == null || __prefix == null)
			throw new NullPointerException("NARG");
		
		this.actingclass = __act;
		this.prefix = __prefix;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final String[] listLibraryNames()
	{
		// Resources are fixed, so if this was done already use the cached
		// form instead
		String[] libs = this._libs;
		if (libs != null)
			return libs.clone();
		
		// There should be a suite list
		try (InputStream in = this.actingclass.getResourceAsStream(
			this.prefix + "suites.list"))
		{
			// Does not exist, so there is no known library list
			if (in == null)
			{
				this._libs = (libs = new String[0]);
				return libs;
			}
			
			// Will just be a normal list
			List<String> rv = new ArrayList<>();
			try (BufferedReader br = new BufferedReader(
				new InputStreamReader(in, "utf-8")))
			{
				for (;;)
				{
					String ln = br.readLine();
					
					// EOF
					if (ln == null)
						break;
					
					// Trim and ignore empty lines
					ln = ln.trim();
					if (ln.isEmpty())
						continue;
					
					// Add otherwise
					rv.add(ln);
				}
			}
			
			// Cache and return
			this._libs = (libs = rv.<String>toArray(new String[rv.size()]));
			return libs;
		}
		
		// {@squirreljme.error AK01 Could not read the library list.}
		catch (IOException e)
		{
			throw new RuntimeException("AK01", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, VMClassLibrary> cache = this._cache;
		synchronized (cache)
		{
			// Already got?
			VMClassLibrary rv = cache.get(__s);
			if (rv != null)
				return rv;
			
			// Pre-cached to not exist
			if (cache.containsKey(__s))
				return null;
			
			// Make sure it is actually valid
			boolean found = false;
			for (String q : this.listLibraryNames())
				if ((found |= q.equals(__s)))
					break;
			
			// If it was not found, it does not exist so cache it and fail
			if (!found)
			{
				cache.put(__s, null);
				return null;
			}
			
			// Load and store it
			cache.put(__s,
				(rv = new ResourceBasedClassLibrary(this.actingclass,
					this.prefix + __s + '/', __s)));
			
			return rv;
		}
	}
}

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

package cc.squirreljme.emulator.vm;

/**
 * Base class for exceptions in the virtual machine.
 *
 * @since 2018/11/17
 */
public class VMException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/11/17
	 */
	public VMException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/17
	 */
	public VMException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/11/17
	 */
	public VMException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/11/17
	 */
	public VMException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/vm/VMFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.vm;

import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import cc.squirreljme.runtime.cldc.Poking;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VMClassLibrary;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This class is used to initialize virtual machines based on a set of factory
 * classes.
 *
 * This was added because there were many cases where tons of code was
 * duplicated to initialize the virtual machine, which were effectively
 * copy and pasted to each other so this will remove that.
 *
 * This uses the service loader to locate factories which are available.
 *
 * @since 2018/11/17
 */
public abstract class VMFactory
{
	/** The name of the VM implementation. */
	protected final String name;
	
	/**
	 * Initializes the factory.
	 *
	 * @param __name The name of the virtual machine.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/17
	 */
	public VMFactory(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
	}
	
	/**
	 * Creates the virtual machine using the given parameters.
	 *
	 * @param __ps The profiler snapshot to write to.
	 * @param __sm The suite manager.
	 * @param __cp The classpath to initialize with.
	 * @param __maincl The main class to start executing.
	 * @param __ismid Is the main class a MIDlet?
	 * @param __gd The guest depth of the virtual machine.
	 * @param __sprops System properties for the running program.
	 * @param __args Arguments for the running program.
	 * @return An instance of the virtual machine.
	 * @throws IllegalArgumentException If an input argument is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If the virtual machine could not be created.
	 * @since 2018/11/17
	 */
	protected abstract VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException;
	
	/**
	 * Main entry point for general programs.
	 *
	 * @param __args Arguments.
	 * @since 2020/02/29
	 */
	public static void main(String... __args)
	{
		// Poke the VM to initialize some probably important parts of it
		Poking.poke();
		
		// Default settings
		String vmName = "springcoat";
		Path snapshotPath = null;
		Collection<String> suiteClasspath = new LinkedList<>();
		
		// There always is a profiler being run, just differs if we save it
		ProfilerSnapshot profilerSnapshot = new ProfilerSnapshot();
		
		// Command line format is:
		// -Xemulator:(vm)
		// -Xsnapshot:(path-to-nps)
		// -classpath (class:path:...)
		// Main-class
		// Arguments...
		Deque<String> queue = new ArrayDeque<>(Arrays.<String>asList(__args));
		while (!queue.isEmpty())
		{
			// End of our items?
			String item = queue.peekFirst();
			if (item == null || item.isEmpty() || item.charAt(0) != '-')
				break;
			
			// Eat it up
			queue.removeFirst();
			
			// Select a VM
			if (item.startsWith("-Xemulator:"))
				vmName = item.substring("-Xemulator:".length());
			
			// VisualVM Snapshot Dump path
			else if (item.startsWith("-Xsnapshot:"))
				snapshotPath = Paths.get(
					item.substring("-Xsnapshot:".length()));
			
			// JARs to load
			else if (item.equals("-classpath") || item.equals("-cp"))
			{
				// Get argument attached to this
				String strings = queue.pollFirst();
				if (strings == null)
					throw new NullPointerException("Classpath missing.");
				
				// Extract path elements
				for (int i = 0, n = strings.length(); i < n; i++)
				{
					// Get location of the next colon
					int dx = strings.indexOf(File.pathSeparatorChar, i);
					if (dx < 0)
						dx = n;
					
					// Add to path
					suiteClasspath.add(strings.substring(i, dx));
					
					// Go to next colon
					i = dx;
				}
			}
			
			// Unknown
			else
				throw new IllegalArgumentException(String.format(
					"Unknown command line switch: %s", item));
		}
		
		// Main class is here
		String mainClass = Objects.<String>requireNonNull(queue.pollFirst(),
			"No main class specified.");
		
		// Fill in the rest with the main argument calls
		Collection<String> mainArgs = new LinkedList<>();
		while (!queue.isEmpty())
			mainArgs.add(queue.removeFirst());
		
		// Collect all the suites together
		Collection<String> classpath = new LinkedList<>();
		Collection<VMClassLibrary> suites = new LinkedList<>();
		for (String classitem : suiteClasspath)
		{
			Path path = Paths.get(classitem);
			
			// Load it into memory
			try (InputStream in = Files.newInputStream(path,
					StandardOpenOption.READ);
				ZipStreamReader zip = new ZipStreamReader(in))
			{
				String normalName = VMFactory.__normalizeName(
					path.getFileName().toString());
				
				System.err.printf("Loading %s (%s)...%n", normalName, path);
				suites.add(InMemoryClassLibrary.loadZip(
					normalName, zip));
				
				// Use the true name here
				classpath.add(normalName);
			}
			catch (IOException e)
			{
				throw new RuntimeException("Could not load library.", e);
			}
		}
		
		// Run the VM, but always make sure we can
		int exitCode = -1;
		try
		{
			// Debug
			System.err.println("Starting virtual machine...");
			
			// Run the VM
			VirtualMachine vm = VMFactory.mainVm(vmName,
				profilerSnapshot,
				new ArraySuiteManager(suites),
				classpath.<String>toArray(new String[classpath.size()]),
				mainClass,
				0, 0, null,
				mainArgs.<String>toArray(new String[mainArgs.size()]));
			
			// Run the virtual machine until it exits
			exitCode = vm.runVm();
			System.exit(vm.runVm());
		}
		
		// Always write the snapshot file
		finally
		{
			if (snapshotPath != null)
				try (OutputStream out = Files.newOutputStream(snapshotPath,
					StandardOpenOption.WRITE, StandardOpenOption.CREATE,
					StandardOpenOption.TRUNCATE_EXISTING))
				{
					profilerSnapshot.writeTo(out);
				}
				catch (IOException e)
				{
					// Ignore
				}
		}
		
		// Exit with the exit code the VM gave us back
		System.exit(exitCode);
	}
	
	/**
	 * Main entry point for the virtual machine using the given properties.
	 *
	 * @param __vm The name of the virtual machine to use, if {@code null}
	 * then this is automatically determined.
	 * @param __ps The profiler snapshot to use.
	 * @param __sm The suite manager used.
	 * @param __cp The starting class path.
	 * @param __bootcl The booting class, if {@code null} then {@code __bootid}
	 * is used instead.
	 * @param __bootid The booting index, if negative then {@code __bootcl}
	 * is used instead. This value takes priority.
	 * @param __gd The guest depth of the virtual machine, if negative this
	 * is automatically determined.
	 * @param __sprops System properties to pass to the target VM.
	 * @param __args Arguments to the program which is running.
	 * @return The created virtual machine.
	 * @throws IllegalArgumentException If neither a boot class or boot ID
	 * were specified.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If the virtual machine failed to initialize.
	 * @since 2018/11/17
	 */
	public static final VirtualMachine mainVm(String __vm,
		ProfilerSnapshot __ps, VMSuiteManager __sm, String[] __cp,
		String __bootcl, int __bootid, int __gd, Map<String, String> __sprops,
		String... __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		if (__sm == null || __cp == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AK02 Neither the boot class or boot ID was
		// specified, one must be specified.}
		if (__bootcl == null && __bootid < 0)
			throw new IllegalArgumentException("AK02");
		
		// Always exists
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// If not specified, check the system property that specifies the VM
		if (__vm == null)
			try
			{
				// {@squirreljme.property cc.squirreljme.vm.name Specifies the
				// name of the virtual machine to use.}
				__vm = VMFactory.__getProperty(__sprops,
					"cc.squirreljme.vm.name");
			}
			catch (SecurityException e)
			{
			}
		
		// If none specified, default to SpringCoat
		if (__vm == null)
			__vm = "springcoat";
		
		// Determine the virtual machine to use
		VMFactory factory = null;
		for (VMFactory f : ServiceLoader.<VMFactory>load(VMFactory.class))
		{
			// If no name was specified then use the first one, otherwise
			// use the one which matches the name
			if (__vm == null || __vm.equalsIgnoreCase(f.name))
			{
				factory = f;
				break;
			}
		}
		
		// {@squirreljme.error AK03 The specified virtual machine does not
		// exist. (The virtual machine name)}
		if (factory == null)
			throw new VMException("AK03 " + __vm);
		
		// Automatically determined guest depth? This is always deeper!
		if (__gd < 0)
			__gd = GuestDepth.guestDepth() + 1;
		
		// Always make a profiler snapshot exist
		if (__ps == null)
			__ps = new ProfilerSnapshot();
		
		// Go through the suites and load the classpath that we are using
		int numlibs = __cp.length;
		VMClassLibrary[] classpath = new VMClassLibrary[numlibs];
		for (int i = 0; i < numlibs; i++)
		{
			VMClassLibrary lib = __sm.loadLibrary(__cp[i]);
			if (lib == null)
				throw new IllegalArgumentException(String.format(
					"Library %s not in classpath!", __cp[i]));
			
			classpath[i] = lib;
		}
		
		// Need to load the manifest where the entry points will be
		VMClassLibrary bl = classpath[numlibs - 1];
		EntryPoints entries;
		try (InputStream in = bl.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// {@squirreljme.error AK04 Entry point JAR has no manifest.}
			if (in == null)
				throw new VMException("AK04");
			
			entries = new EntryPoints(new JavaManifest(in));
		}
		
		// {@squirreljme.error AK05 Failed to read the manifest.}
		catch (IOException e)
		{
			throw new VMException("AK05", e);
		}
		
		// Print them out for debug
		System.err.println("Entry points:");
		for (int i = 0, n = entries.size(); i < n; i++)
			System.err.printf("    %d: %s%n", i, entries.get(i));
		
		// If a class was specified and not a boot ID, we must search through
		// the boot JAR's (the last one) entry points for a match
		if (__bootid < 0)
		{
			// Determine the entry point used
			for (int i = 0, n = entries.size(); i < n; i++)
				if (__bootcl.equals(entries.get(i).entryPoint()))
				{
					__bootid = i;
					break;
				}
			
			// {@squirreljme.error AK06 Could not find the specified main
			// class in the entry point list. (The main class)}
			if (__bootid < 0)
				throw new VMException("AK06 " + __bootcl);
		}
		
		// Do not use an entry point which is outside of the bounds
		__bootid = Math.max(0, Math.min(entries.size(), __bootid));
		
		// Is this entry point a MIDlet? Used as a hint
		EntryPoint entry = entries.get(__bootid);
		boolean ismidlet = entry.isMidlet();
		
		// Create the virtual machine now that everything is available
		return factory.createVM(__ps, __sm, classpath, entry.entryPoint(),
			ismidlet, __gd, __sprops, __args);
	}
	
	/**
	 * Shaded main entry point.
	 *
	 * @param __args Arguments to the program.
	 * @since 2018/11/17
	 */
	@Deprecated
	public static final void shadedMain(String... __args)
	{
		VMFactory.shadedMain((Map<String, String>)null, __args);
	}
	
	/**
	 * Shaded main entry point, with extra properties map.
	 *
	 * @param __sprops Properties map to use.
	 * @param __args Arguments to the program.
	 * @since 2018/11/17
	 */
	@Deprecated
	public static final void shadedMain(Map<String, String> __sprops,
		String... __args)
	{
		// Defensive copy and force to exist
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// We may be able to grab some properties from the shaded manifest
		// information, if one is even available
		JavaManifest man;
		try (InputStream in = VMFactory.class.getResourceAsStream(
			"/META-INF/SQUIRRELJME-SHADED.MF"))
		{
			man = (in == null ? new JavaManifest() : new JavaManifest(in));
		}
		
		// {@squirreljme.error AK07 Could not read the manifest to load the
		// launcher's classpath.}
		catch (IOException e)
		{
			throw new RuntimeException("AK07", e);
		}
		
		// These are parameters which will be parsed to handle how to start
		// the shaded process
		String useactiveclass = null,
			useprefix = null,
			usecp = null,
			usemain = null;
		int bootid = -1;
		
		// Profiler snapshot to generate to
		ProfilerSnapshot psnap = null;
		
		// Try loading these from properties first, to take more priority
		try
		{
			// {@squirreljme.property cc.squirreljme.vm.shadeactiveclass=class
			// The class to use to load resources from.}
			useactiveclass = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeactiveclass");
			
			// {@squirreljme.property cc.squirreljme.vm.shadeprefix=prefix
			// The resource lookup prefix for the classes.}
			useprefix = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeprefix");
			
			// {@squirreljme.property cc.squirreljme.vm.shadeclasspath=[class:]
			// The classes which make up the class path for execution.}
			usecp = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeclasspath");
			
			// {@squirreljme.property cc.squirreljme.vm.shademain=class
			// The class to use as the main entry point for the VM.}
			usemain = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shademain");
			
			// {@squirreljme.property cc.squirreljme.vm.shadebootid=id
			// The MIDlet or Main class number to use for entering the JAR.}
			bootid = Integer.valueOf(VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadebootid", "-1"));
		}
		catch (SecurityException e)
		{
			// Ignore
		}
		
		// If properties were not defined in the system, then they should be
		// in the manifest
		JavaManifestAttributes attr = man.getMainAttributes();
		if (useactiveclass == null)
			useactiveclass = attr.getValue("ActiveClass");
		if (useprefix == null)
			useprefix = attr.getValue("Prefix");
		if (usecp == null)
			usecp = attr.getValue("ClassPath");
		if (usemain == null)
			usemain = attr.getValue("Main-Class");
		
		// Otherwise, if anything is missing use defaults
		if (useactiveclass == null)
			useactiveclass = VMFactory.class.getName();
		if (useprefix == null)
			useprefix = "/__-squirreljme/";
		if (bootid < 0)
			bootid = 0;
		
		// Load the resource based suite manager
		VMSuiteManager sm;
		try
		{
			sm = new ResourceBasedSuiteManager(Class.forName(useactiveclass),
				useprefix);
		}
		
		// {@squirreljme.error AK08 Could not locate the class to use for
		// resource lookup. (The class which was not found)}
		catch (ClassNotFoundException e)
		{
			throw new VMException("AK08 " + useactiveclass, e);
		}
		
		// Split the classpath accordingly using ' ', ';', and ':', allow
		// for multiple forms due to manifests and classpaths used in Windows
		// and UNIX
		List<String> classpath = new ArrayList<>();
		for (int i = 0, n = usecp.length(); i < n;)
		{
			// Find end clip position
			int sp;
			if ((sp = usecp.indexOf(' ', i)) < 0)
				if ((sp = usecp.indexOf(';', i)) < 0)
					if ((sp = usecp.indexOf(':', i)) < 0)
						sp = n;
			
			// Clip string
			String clip = usecp.substring(i, sp).trim();
			if (!clip.isEmpty())
				classpath.add(clip);
			
			// Skip the split character
			i = sp + 1;
		}
		
		// Since we are shaded, we might want to load some extra suites from
		// some directory
		List<VMSuiteManager> mergesm = new ArrayList<>();
		mergesm.add(sm);
		
		// Check our working directory
		String workdir = VMFactory.__getProperty(__sprops, "user.dir");
		if (workdir != null)
			try
			{
				mergesm.add(new PathSuiteManager(
					Paths.get(workdir).resolve("lib")));
			}
			catch (InvalidPathException e)
			{
			}
		
		// Check our executable path
		String execpath = SystemProperties.executablePath();
		if (execpath != null)
			try
			{
				mergesm.add(new PathSuiteManager(
					Paths.get(execpath).getParent().resolve("lib")));
			}
			catch (InvalidPathException|NullPointerException e)
			{
			}
		
		// Do the merge?
		if (mergesm.size() > 1)
			sm = new MergedSuiteManager(mergesm.<VMSuiteManager>toArray(
				new VMSuiteManager[mergesm.size()]));
		
		// Create the VM
		VirtualMachine vm = VMFactory.mainVm(null, null,
			sm, classpath.<String>toArray(new String[classpath.size()]),
			usemain, bootid, -1, null, __args);
		
		// Run the VM and exit with the code it generates
		System.exit(vm.runVm());
	}
	
	/**
	 * Tries to get a property from a passed map otherwise reads from the
	 * system properties used.
	 *
	 * @param __props The properties to check first.
	 * @param __key The key to get.
	 * @return The value for the given key, {@code null} means it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	private static final String __getProperty(Map<String, String> __props,
		String __key)
		throws NullPointerException
	{
		return VMFactory.__getProperty(__props, __key, null);
	}
	
	/**
	 * Tries to get a property from a passed map otherwise reads from the
	 * system properties used.
	 *
	 * @param __props The properties to check first.
	 * @param __key The key to get.
	 * @param __def Default value.
	 * @return The value for the given key, {@code __def} means it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	private static final String __getProperty(Map<String, String> __props,
		String __key, String __def)
		throws NullPointerException
	{
		if (__props == null || __key == null)
			throw new NullPointerException("NARG");
		
		// Grab from these properties first
		String rv = __props.get(__key);
		if (rv != null)
			return rv;
		
		// Otherwise try a property instead
		try
		{
			rv = System.getProperty(__key);
			if (rv != null)
				return rv;
			return __def;
		}
		catch (SecurityException e)
		{
			return __def;
		}
	}
	
	/**
	 * Normalizes the name of the library.
	 *
	 * @param __name The name of the JAR.
	 * @return The normalized name.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/03/01
	 */
	private static String __normalizeName(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Get the base name of the JAR
		if (__name.endsWith(".jar"))
			__name = __name.substring(0, __name.length() - ".jar".length());
		
		// Chop down potential foo"-0.4.0" from the end
		for (int n = __name.length(), i = n - 1; i >= 0; i--)
		{
			char c = __name.charAt(i);
			
			// Still potentially a version bit
			if (c == '.' || c == '-' || (c >= '0' && c <= '9'))
				__name = __name.substring(0, i);
			
			// Do not need
			else
				break;
		}
		
		// Use this name
		return __name + ".jar";
	}
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/vm/VMResourceAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * This class manages access to resources within the virtual machine.
 *
 * @since 2018/10/07
 */
public final class VMResourceAccess
{
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** Opened resources. */
	private final Map<Integer, InputStream> _streams =
		new HashMap<>();
	
	/** The next resource ID to use. */
	private volatile int _next;
	
	/**
	 * Initializes the resource access.
	 *
	 * @param __sm The suite manager.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public VMResourceAccess(VMSuiteManager __sm)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
	}
	
	/**
	 * Checks how many bytes are quickly available for read within a resource.
	 *
	 * @param __fd The file descriptor.
	 * @return The number of bytes available quickly or negative on failure.
	 * @since 2018/12/05
	 */
	public int available(int __fd)
	{
		// Locate the stream to read from
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Do the check
		try
		{
			return in.available();
		}
		
		// Failed so just pass that some exception happened
		catch (IOException e)
		{
			return -3;
		}
	}
	
	/**
	 * Closes the open resource.
	 *
	 * @param __fd The file descriptor.
	 * @return Zero on success or a negative value on failure.
	 * @since 2018/10/13
	 */
	public int close(int __fd)
	{
		// Locate the stream to close
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
			
			// Remove it
			if (in != null)
				streams.remove(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Close it
		try
		{
			in.close();
			return 0;
		}
		catch (IOException e)
		{
			return -3;
		}
	}
	
	/**
	 * Opens the given resource in the given JAR.
	 *
	 * @param __jar The source JAR.
	 * @param __rc The resource to load.
	 * @return The resource file descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public int open(String __jar, String __rc)
		throws NullPointerException
	{
		if (__jar == null || __rc == null)
			throw new NullPointerException("NARG");
		
		// Load the library to access its resources
		VMClassLibrary lib = this.suites.loadLibrary(__jar);
		if (lib == null)
			return -2;
		
		// Open input stream, if it even exists
		InputStream rv;
		try
		{
			rv = lib.resourceAsStream(__rc);
			
			// Debug
			todo.DEBUG.note("rAS(%s, %s) = %b", __jar, __rc, rv != null);
			
			if (rv == null)
				return -1;
		}
		catch (IOException e)
		{
			return -3;
		}
		
		// It does exist so it needs to be registered
		int id;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			streams.put((id = ++this._next), rv);
		}
		
		// Only the ID is used
		return id;
	}
	
	/**
	 * Reads from the 
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative status code.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public int read(int __fd, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the stream to read from
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Do the read
		try
		{
			int rv = in.read(__b, __o, __l);
			
			// Normalize the return value because negative values mean special
			// values, while we just want EOF
			if (rv < 0)
				return -1;
			return rv;
		}
		
		// Failed so just pass that some exception happened
		catch (IOException e)
		{
			return -3;
		}
	}
}

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

package cc.squirreljme.emulator.vm;

import cc.squirreljme.vm.VMClassLibrary;

/**
 * This is the suite manager which represents the.
 *
 * @since 2018/10/26
 */
public interface VMSuiteManager
{
	/**
	 * Lists the names of libraries which are available for usage.
	 *
	 * @return The list of available libraries.
	 * @since 2018/10/26
	 */
	String[] listLibraryNames();
	
	/**
	 * Loads the specified library by the given string.
	 *
	 * It is recommended that this caches the library internally so that it may
	 * be reused accordingly as such.
	 *
	 * @param __s The name of the library to load.
	 * @return The loaded library, or {@code null} if it does not exist.
	 * @since 2018/10/16
	 */
	VMClassLibrary loadLibrary(String __s)
		throws NullPointerException;
}

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

package cc.squirreljme.emulator.vm;

/**
 * This interface represents the virtual machine which may be executed
 * accordingly.
 *
 * @since 2018/11/17
 */
public interface VirtualMachine
{
	/**
	 * Runs the virtual machine.
	 *
	 * @return The exit code of the virtual machine.
	 * @throws VMException If the VM threw an exception.
	 * @since 2018/11/17
	 */
	int runVm()
		throws VMException;
}

Added emulators/emulator-base/src/main/java/cc/squirreljme/emulator/vm/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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.emulator.vm;

Added emulators/emulator-base/src/main/resources/META-INF/services/org.testng.IAlterSuiteListener.


1
+
cc.squirreljme.emulator.SquirrelJMEAlterSuiteListener

Added emulators/emulator-base/src/main/resources/squirreljme.xml.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="squirreljme">
    <listeners>
        <listener
            class-name="cc.squirreljme.emulator.SquirrelJMEAlterSuiteListener"
            />
    </listeners>
    <test name="tests">
        <classes>
            <class name="cc.squirreljme.emulator.SquirrelJMETestFactory"/>
        </classes>
    </test>
</suite>

Added emulators/springcoat-vm/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java-library"
}

description = "This is a SpringCoat virtual machine which " +
	"is an unoptimized pure interpreter aimed for the purpose of being an " +
	"educational stepping stone to other future virtual machines."

dependencies
{
	api project(":emulators:emulator-base")

	api project(":modules:cldc-compact")
	api project(":modules:tool-classfile")
	api project(":modules:tool-manifest-reader")
	api project(":modules:meep-swm")
	api project(":modules:meep-midlet")
	api project(":modules:common-vm")
	api project(":modules:collections")
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringArithmeticException.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a divide by zero occurs.
 *
 * @since 2018/12/04
 */
public class SpringArithmeticException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public SpringArithmeticException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArithmeticException";
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringArrayIndexOutOfBoundsException.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an invalid out of bounds index was accessed in an
 * array.
 *
 * @since 2018/09/16
 */
public class SpringArrayIndexOutOfBoundsException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArrayIndexOutOfBoundsException";
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringArrayObject.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is an object which acts as an array, which stores some kind of data.
 *
 * @since 2018/09/15
 */
public abstract class SpringArrayObject
	implements SpringObject
{
	/** The monitor for this array. */
	protected final SpringMonitor monitor =
		new SpringMonitor();
	
	/** The type of this object itself. */
	protected final SpringClass selftype;
	
	/** The component type. */
	protected final SpringClass component;
	
	/** The length of the array. */
	protected final int length;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public SpringArrayObject(SpringClass __self, SpringClass __cl, int __l)
		throws NullPointerException
	{
		if (__self == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK01 Attempt to allocate an array of a
		// negative size. (The length requested)}
		if (__l < 0)
			throw new SpringNegativeArraySizeException(
				String.format("BK01 %d", __l));
		
		this.selftype = __self;
		this.component = __cl;
		this.length = __l;
	}
	
	/**
	 * Returns the raw backing array.
	 *
	 * @return The array.
	 * @since 2018/11/19
	 */
	public abstract Object array();
	
	/**
	 * Sets the index to the specified value.
	 *
	 * @param <C> The type of value to get.
	 * @param __cl The type of value to get.
	 * @param __dx The index to set.
	 * @return The contained value.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringArrayStoreException If the array cannot store the given
	 * type.
	 * @throws SpringArrayIndexOutOfBoundsException If the index is not within
	 * bounds.
	 * @since 2018/09/16
	 */
	public abstract <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException;
	
	/**
	 * Sets the index to the specified value.
	 *
	 * @param __dx The index to set.
	 * @param __v The value to set.
	 * @throws SpringArrayStoreException If the array cannot store the given
	 * type.
	 * @throws SpringArrayIndexOutOfBoundsException If the index is not within
	 * bounds.
	 * @since 2018/09/16
	 */
	public abstract void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		return this.monitor;
	}
	
	/**
	 * Returns the length of this array.
	 *
	 * @return The array length.
	 * @since 2018/09/16
	 */
	public final int length()
	{
		return this.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s@%08x", this.selftype.name(),
				System.identityHashCode(this))));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringClass type()
	{
		return this.selftype;
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a boolean array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectBoolean
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final boolean[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectBoolean(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new boolean[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectBoolean(SpringClass __self, SpringClass __cl,
		boolean[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf((this._elements[__dx] ? 1 : 0));
		}
		
		// {@squirreljme.error BK02 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK02 %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] =
				((((((Integer)__v).intValue()) & 0x1) != 0) ? true : false);
		}
		
		// {@squirreljme.error BK03 Could not set the index in the boolean
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK03", e);
		}
		
		// {@squirreljme.error BK04 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK04 %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a byte array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectByte
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final byte[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectByte(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new byte[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectByte(SpringClass __self, SpringClass __cl,
		byte[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK05 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK05 %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).byteValue();
		}
		
		// {@squirreljme.error BK06 Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK06", e);
		}
		
		// {@squirreljme.error BK07 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK07 %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a char array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectChar
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final char[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectChar(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new char[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectChar(SpringClass __self, SpringClass __cl,
		char[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK08 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK08 %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = (char)((Integer)__v).intValue();
		}
		
		// {@squirreljme.error BK09 Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK09", e);
		}
		
		// {@squirreljme.error BK0a Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0a %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a double array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectDouble
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final double[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectDouble(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new double[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectDouble(SpringClass __self, SpringClass __cl,
		double[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Double.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0b Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0b %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Double)__v).doubleValue();
		}
		
		// {@squirreljme.error BK0c Could not set the index in the double
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0c", e);
		}
		
		// {@squirreljme.error BK0d Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0d %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a float array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectFloat
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final float[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectFloat(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new float[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectFloat(SpringClass __self, SpringClass __cl,
		float[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Float.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0e Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0e %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Float)__v).floatValue();
		}
		
		// {@squirreljme.error BK0f Could not set the index in the float
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0f", e);
		}
		
		// {@squirreljme.error BK0g Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0g %d %d", __dx, this.length), e);
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringArrayObjectGeneric.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.PrimitiveType;

/**
 * Generic array that can store any type.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectGeneric
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final Object[] _elements;
	
	/** The last class which was checked for compatibility. */
	private SpringClass _lastvalid;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public SpringArrayObjectGeneric(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		Object[] elements;
		this._elements = (elements = new Object[__l]);
		
		// Determine the initial value to use
		PrimitiveType type = __cl.name().primitiveType();
		Object v;
		if (type == null)
			v = SpringNullObject.NULL;
		else
			switch (type)
			{
				case BOOLEAN:
				case BYTE:
				case SHORT:
				case CHARACTER:
				case INTEGER:
					v = Integer.valueOf(0);
					break;
				
				case LONG:
					v = Long.valueOf(0);
					break;
				
				case FLOAT:
					v = Float.valueOf(0);
					break;
				
				case DOUBLE:
					v = Double.valueOf(0);
					break;
				
				default:
					throw new todo.OOPS();
			}
		
		// Set all elements to an initial value depending on the type
		// Set all 
		for (int i = 0; i < __l; i++)
			elements[i] = v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Faster to just have the host VM do bounds check
		try
		{
			return __cl.cast(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0h Out of bounds access to array.
		// (The index; The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0h %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		try
		{
			// This is a cached type for setting because an array of one type
			// will usually in most cases set with objects which are compatible
			// so the rather involved instanceof check will take awhile and
			// compound for setting single elements.
			SpringClass lastvalid = this._lastvalid,
				wouldset = null;
			
			// If the input value is an object
			boolean docheck;
			if (__v instanceof SpringObject)
			{
				// If a check is done, then 
				wouldset = ((SpringObject)__v).type();
				
				// Only if the types differ would we actually check
				docheck = (wouldset != lastvalid);
			}
			
			// Otherwise always do a check since we do not really know the
			// class type here
			else
				docheck = true;
			
			// Performing the check for cache?
			if (docheck)
			{
				// {@squirreljme.error BK0i The specified type is not
				// compatible with the values this array stores. (The input
				// value; The component type)}
				SpringClass component = this.component;
				if (!component.isCompatible(__v))
					throw new SpringArrayStoreException(String.format(
						"BK0i %s %s", __v, component));
				
				// Next validity check would be set if done on an object
				// Ignore setting it back to null, if one was previously
				// valid
				if (wouldset != null)
					this._lastvalid = wouldset;
			}
			
			// Set
			this._elements[__dx] = __v;
		}
		
		// {@squirreljme.error BK0j Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0j %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by an int array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectInteger
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final int[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectInteger(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new int[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectInteger(SpringClass __self, SpringClass __cl,
		int[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0k Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0k %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).intValue();
		}
		
		// {@squirreljme.error BK0l Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0l", e);
		}
		
		// {@squirreljme.error BK0m Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0m %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a long array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectLong
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final long[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectLong(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new long[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectLong(SpringClass __self, SpringClass __cl,
		long[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Long.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0n Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0n %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Long)__v).longValue();
		}
		
		// {@squirreljme.error BK0o Could not set the index in the long
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0o", e);
		}
		
		// {@squirreljme.error BK0p Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0p %d %d", __dx, this.length), e);
		}
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a short array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectShort
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final short[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectShort(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new short[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectShort(SpringClass __self, SpringClass __cl,
		short[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0q Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0q %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).shortValue();
		}
		
		// {@squirreljme.error BK0r Could not set the index in the short
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0r", e);
		}
		
		// {@squirreljme.error BK0s Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0s %d %d", __dx, this.length), e);
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringArrayStoreException.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an invalid value was attempted to be stored into an
 * array.
 *
 * @since 2018/09/16
 */
public class SpringArrayStoreException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArrayStoreException";
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringClass.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.HasAccessibleFlags;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This is a representation of a class file as it is seen by the virtual
 * machine, it is intended to remain simple and only refer to what is needed
 * for the machine to run.
 *
 * @since 2018/07/21
 */
public final class SpringClass
	implements HasAccessibleFlags
{
	/** The name of this class. */
	protected final ClassName name;
	
	/** The class file data. */
	protected final ClassFile file;
	
	/** The super class. */
	protected final SpringClass superclass;
	
	/** The number of instance fields that exist. */
	protected final int instancefieldcount;
	
	/** The special class index. */
	protected final int specialindex;
	
	/** The dimentions of this class. */
	protected final int dimensions;
	
	/** The component type. */
	protected final SpringClass component;
	
	/** The JAR this class is in. */
	protected final String injar;
	
	/** The virtualized size of instances for this class. */
	protected final int instancesize;
	
	/** Interface classes. */
	private final SpringClass[] _interfaceclasses;
	
	/** Methods which exist in this class, includes statics for this only. */
	private final Map<MethodNameAndType, SpringMethod> _methods =
		new HashMap<>();
	
	/** Non-virtual instance methods. */
	private final Map<MethodNameAndType, SpringMethod> _nonvirtmethods =
		new HashMap<>();
	
	/** Fields which exist in this class, only includes this class fields */
	private final Map<FieldNameAndType, SpringField> _fields =
		new HashMap<>();
	
	/** The table of fields defined in this class, includes super classes. */
	private final SpringField[] _fieldtable;
	
	/** Has this class been initialized? */
	private volatile boolean _initialized;
	
	/**
	 * Initializes the spring class.
	 *
	 * @param __super The super class of this class.
	 * @param __interfaces The the interfaces this class implements.
	 * @param __cf The class file for this class.
	 * @param __si The special class index.
	 * @param __ct The component type.
	 * @param __injar The JAR this class is in.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/07/21
	 */
	SpringClass(SpringClass __super, SpringClass[] __interfaces,
		ClassFile __cf, int __si, SpringClass __ct, String __injar)
		throws NullPointerException
	{
		if (__interfaces == null || __cf == null)
			throw new NullPointerException("NARG");
		
		ClassName name = __cf.thisName();
		this.name = name;
		this.specialindex = __si;
		this.injar = __injar;
		this.file = __cf;
		this.superclass = __super;
		this.component = __ct;
		this.dimensions = name.dimensions();
		
		// Check
		this._interfaceclasses = (__interfaces = __interfaces.clone());
		for (SpringClass x : __interfaces)
			if (x == null)
				throw new NullPointerException("NARG");
		
		// Used for method location
		String filename = __cf.sourceFile();
		
		// Go through and initialize methods declared in this class
		Map<MethodNameAndType, SpringMethod> nvmeths = this._nonvirtmethods;
		Map<MethodNameAndType, SpringMethod> methods = this._methods;
		for (Method m : __cf.methods())
		{
			SpringMethod sm;
			if (null != methods.put(m.nameAndType(),
				(sm = new SpringMethod(name, m, filename))))
			{
				// {@squirreljme.error BK0t Duplicated method in class. (The
				// method)}
				throw new SpringClassFormatException(name, String.format(
					"BK0t %s", m.nameAndType()));
			}
			
			// Store only instance methods which are not static
			if (!m.flags().isStatic())
				nvmeths.put(m.nameAndType(), sm);
		}
		
		// Fields that are defined in super classes must be allocated, stored,
		// and indexed appropriately so that way casting between types and
		// accessing other fields is actually valid
		int superfieldcount = (__super == null ? 0 :
			__super.instancefieldcount);
		int instancefieldcount = superfieldcount;
		
		// Calculate the instance size
		this.instancesize = (__super == null ? Constants.OBJECT_BASE_SIZE :
			(name.dimensions() > 0 ? Constants.ARRAY_BASE_SIZE :
			__super.instancesize + (instancefieldcount * 4)));
		
		// Initialize all of the fields as needed
		Map<FieldNameAndType, SpringField> fields = this._fields;
		List<SpringField> instfields = new ArrayList<>(fields.size());
		for (Field f : __cf.fields())
		{
			boolean isinstance = f.flags().isInstance();
			
			// {@squirreljme.error BK0u Duplicated field in class. (The field)}
			SpringField sf;
			if (null != fields.put(f.nameAndType(),
				(sf = new SpringField(name, f,
					(isinstance ? instancefieldcount++ : -1)))))
				throw new SpringClassFormatException(name, String.format(
					"BK0u %s", f.nameAndType()));
			
			// Used to build our part of the field table
			if (isinstance)
				instfields.add(sf);
		}
		
		// Each field is referenced by an index rather than a map, this is
		// more efficient for instances and additionally still allows for
		// sub-classes to declare fields as needed.
		SpringField[] fieldtable = new SpringField[instancefieldcount];
		this._fieldtable = fieldtable;
		
		// Copy the super class field table, since technically all of the
		// fields in the super class are a part of this class.
		if (__super != null)
		{
			SpringField[] supertable = __super._fieldtable;
			for (int i = 0; i < superfieldcount; i++)
				fieldtable[i] = supertable[i];
		}
		
		// Store all of the instance fields
		for (int i = superfieldcount, p = 0, pn = instfields.size();
			p < pn; i++, p++)
			fieldtable[i] = instfields.get(p);
		
		// Used to quickly determine how big to set storage for a class
		this.instancefieldcount = instancefieldcount;
		
		// Go through super and interfaces and add non-static methods which
		// exist in sub-classes
		for (int i = 0, n = __interfaces.length; i <= n; i++)
		{
			// The class to look within
			SpringClass lookin = (i == 0 ? __super : __interfaces[i - 1]);
			if (lookin == null)
				continue;
			
			// Go through class methods
			for (Map.Entry<MethodNameAndType, SpringMethod> e :
				lookin._methods.entrySet())
			{
				MethodNameAndType k = e.getKey();
				SpringMethod v = e.getValue();
				
				// Ignore initializer methods, and private methods
				if (v.isInstanceInitializer() ||
					v.isStaticInitializer() || v.flags().isPrivate())
					continue;
				
				// If the method does not exist in the table then it gets added
				// otherwise it is effectively replaced
				if (!methods.containsKey(k))
					methods.put(k, v);
			}
		}
		
		// Debug
		/*todo.DEBUG.note("Class %s (size=%d, fields=%d, methods=%d).", name,
			instancefieldcount,
			fields.size(),
			methods.size());*/
	}
	
	/**
	 * Returns the component type of this class.
	 *
	 * @return The component type.
	 * @since 2018/09/27
	 */
	public final SpringClass componentType()
	{
		return this.component;
	}
	
	/**
	 * Returns the number of array dimensions.
	 *
	 * @return The number of dimensions.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		return this.name.dimensions();
	}
	
	/**
	 * Returns the fields which are only declared in this class.
	 *
	 * @return The fields only declared in this class.
	 * @since 2018/09/09
	 */
	public final SpringField[] fieldsOnlyThisClass()
	{
		Map<FieldNameAndType, SpringField> fields = this._fields;
		return fields.values().<SpringField>toArray(
			new SpringField[fields.size()]);
	}
	
	/**
	 * Returns the table of fields used for this class.
	 *
	 * @return The field table used for this class.
	 * @since 2018/09/16
	 */
	public final SpringField[] fieldTable()
	{
		return this._fieldtable.clone();
	}
	
	/**
	 * Returns the associated class file.
	 *
	 * @return The class file.
	 * @since 2018/09/08
	 */
	public final ClassFile file()
	{
		return this.file;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final ClassFlags flags()
	{
		return this.file.flags();
	}
	
	/**
	 * Returns the JAR this class is in.
	 *
	 * @return The JAR this class is in.
	 * @since 2018/10/07
	 */
	public final String inJar()
	{
		return this.injar;
	}
	
	/**
	 * Returns the number of instance fields this class stores. This is for
	 * the most part the size of the given class.
	 *
	 * @return The number of instance fields this class stores.
	 * @since 2018/09/08
	 */
	public final int instanceFieldCount()
	{
		return this.instancefieldcount;
	}
	
	/**
	 * Returns the interfaces that this class implements.
	 *
	 * @return The implemented interfaces.
	 * @since 2018/09/08
	 */
	public final SpringClass[] interfaceClasses()
	{
		return this._interfaceclasses.clone();
	}
	
	/**
	 * Is this an array?
	 *
	 * @return If this is an array.
	 * @since 2018/09/27
	 */
	public final boolean isArray()
	{
		return this.name.isArray();
	}
	
	/**
	 * Checks if this class can be assigned from the target class, that is
	 * {@code this = (ThisClass)__o}.
	 *
	 * This is the same as {@link Class#isInstance(Object)} except it works
	 * only on class representations.
	 *
	 * @param __o The other class to check.
	 * @return If the other class can be assigned as this class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final boolean isAssignableFrom(SpringClass __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Go through target superclasses to find this class
		for (SpringClass r = __o; r != null; r = r.superclass)
		{
			if (r == this)
				return true;
		
			// Go through interfaces for the class to find this class
			for (SpringClass i : r._interfaceclasses)
				if (this.isAssignableFrom(i))
					return true;
		}
		
		// Need to cast from one array type to another
		int thisdims = this.dimensions(),
			otherdims = __o.dimensions();
		if (thisdims > 0)
		{
			// If this is an array and the other type is an array with the same
			// number of dimensions, then compare the base type so that say
			// Number[] is assignable from Integer[].
			if (otherdims == thisdims)
				if (this.__rootType().isAssignableFrom(__o.__rootType()))
					return true;
			
			// We can cast down to Object array types if there are less
			// dimensions ([[[[Integer -> [Object)
			if (this.__rootType().isObjectClass() && thisdims < otherdims)
				return true;
		}
		
		return false;
	}
	
	/**
	 * Checks if the given value is compatible with this class.
	 *
	 * @param __v The value to check.
	 * @return If it is compatible or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final boolean isCompatible(Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Primitive must match standard promoted type
		ClassName name = this.name;
		if (name.isPrimitive())
			switch (name.toString())
			{
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
					return (__v instanceof Integer);
				
				case "long":
					return (__v instanceof Long);
				
				case "float":
					return (__v instanceof Float);
					
				case "double":
					return (__v instanceof Double);
				
				default:
					throw new todo.OOPS();
			}
			
		// Would be an assignable reference
		else if (__v instanceof SpringNullObject)
			return true;
		
		// Not primitive type, must be assignable
		else if (__v instanceof SpringObject)
			return this.isAssignableFrom(((SpringObject)__v).type());
		
		// Unknown
		else
			throw new todo.OOPS();
	}
	
	/**
	 * Has this class been initialized?
	 *
	 * @return If the class has been initialized.
	 * @since 2018/09/08
	 */
	public final boolean isInitialized()
	{
		return this._initialized;
	}
	
	/**
	 * Is this the object class?
	 *
	 * @return If this is the object class.
	 * @since 2018/11/04
	 */
	public final boolean isObjectClass()
	{
		return this.name.toString().equals("java/lang/Object");
	}
	
	/**
	 * Checks if the given class is a super class of the this class.
	 *
	 * @param __cl The class to check.
	 * @return {@code true} if it is a superclass.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean isSuperClass(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		for (SpringClass r = this.superclass; r != null; r = r.superClass())
			if (r == __cl)
				return true;
		
		return true;
	}
	
	/**
	 * Looks up the method which acts as the default constructor for instance
	 * objects.
	 *
	 * @return The default constructor for the object or {@code null} if there
	 * is none.
	 * @since 2018/09/08
	 */
	public final SpringMethod lookupDefaultConstructor()
	{
		try
		{
			return this.lookupMethodNonVirtual(new MethodNameAndType("<init>",
				"()V"));
		}
		catch (SpringNoSuchMethodException e)
		{
			return null;
		}
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __name The name of the field.
	 * @param __desc The type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/11/19
	 */
	public final SpringField lookupField(boolean __static, String __name,
		String __desc)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupField(__static,
			new FieldName(__name), new FieldDescriptor(__desc));
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __name The name of the field.
	 * @param __desc The type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringField lookupField(boolean __static, FieldName __name,
		FieldDescriptor __desc)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupField(__static,
			new FieldNameAndType(__name, __desc));
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __nat The name and type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringField lookupField(boolean __static,
		FieldNameAndType __nat)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up field %s::%s (static=%b)", this.name,
			__nat, __static);*/
		
		// Field lookup starts at the current class, but also goes to the
		// super class for non-statics
		SpringField rv = this._fields.get(__nat);
		if (rv == null)
		{
			// Lookup non-static fields in super class
			if (!__static)
			{
				SpringClass sc = this.superclass;
				if (sc != null)
					return sc.lookupField(__static, __nat);
			}
			
			// {@squirreljme.error BK0v The specified field does not exist.
			// (The class which was looked in; The name and type of the field)}
			throw new SpringNoSuchFieldException(String.format("BK0v %s %s",
				this.name, __nat));
		}
		
		// {@squirreljme.error BK0w The specified field exists in the class
		// however it does not match being static. (The class the field is in;
		// The name and type of the method; If a static field was requested)}
		if (rv.isStatic() != __static)
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK0w %s %s %s", this.name, __nat, __static));
		
		return rv;
	}
	
	/**
	 * Locates the given method in the class.
	 *
	 * @param __static Is the method static?
	 * @param __name The name of the method.
	 * @param __desc The descriptor of the method.
	 * @return The method which was found.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * does not match staticness.
	 * @throws SpringNoSuchMethodException If the specified method does not
	 * exist.
	 * @since 2018/09/03
	 */
	public final SpringMethod lookupMethod(boolean __static, MethodName __name,
		MethodDescriptor __desc)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupMethod(__static, new MethodNameAndType(__name,
			__desc));
	}
	
	/**
	 * Locates the given method in the class.
	 *
	 * @param __static Is the method static?
	 * @param __nat The name and type of the method.
	 * @return The method which was found.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * does not match staticness.
	 * @throws SpringNoSuchMethodException If the specified method does not
	 * exist.
	 * @since 2018/09/03
	 */
	public final SpringMethod lookupMethod(boolean __static,
		MethodNameAndType __nat)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up method %s::%s (static=%b)", this.name,
			__nat, __static);*/
		
		// {@squirreljme.error BK0x The specified method does not exist.
		// (The class which was looked in; The name and type of the method)} 
		SpringMethod rv = this._methods.get(__nat);
		if (rv == null)
			throw new SpringNoSuchMethodException(String.format("BK0x %s %s",
				this.name, __nat));
		
		// {@squirreljme.error BK0y The specified method exists in the class
		// however it does not match being static. (The class the method is in;
		// The name and type of the method; If a static method was requested)}
		if (rv.isStatic() != __static)
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK0y %s %s %b", this.name, __nat, __static));
		
		return rv;
	}
	
	/**
	 * Looks up the specified method non-virtually.
	 *
	 * @param __nat The name and type.
	 * @return The target method.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * is static.
	 * @throws SpringNoSuchMethodException If no method exists.
	 * @since 2018/09/09
	 */
	public final SpringMethod lookupMethodNonVirtual(MethodNameAndType __nat)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up non-virtual method %s::%s.", this.name,
			__nat);*/
		
		// {@squirreljme.error BK0z The specified method does not exist, when
		// non-virtual lookup is used. (The class which was looked in; The
		// name and type of the method)} 
		SpringMethod rv = this._nonvirtmethods.get(__nat);
		if (rv == null)
			throw new SpringNoSuchMethodException(String.format("BK0z %s %s",
				this.name, __nat));
		
		// {@squirreljme.error BK10 Non-virtual method lookup found a static
		// method. (The class being looked in; The name and type requested)}
		if (rv.flags().isStatic())
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK10 %s %s", this.name, __nat));
		
		return rv;
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2018/09/08
	 */
	public final ClassName name()
	{
		return this.name;
	}
	
	/**
	 * Sets the class as initialized.
	 *
	 * @throws SpringVirtualMachineException If the class has already been
	 * initialized.
	 * @since 2018/09/08
	 */
	public final void setInitialized()
		throws SpringVirtualMachineException
	{
		// {@squirreljme.error BK11 Class attempted to be initialized twice.
		// (This class)}
		if (this._initialized)
			throw new SpringVirtualMachineException(String.format(
				"BK11 %s", this.name));
		
		this._initialized = true;
	}
	
	/**
	 * Returns the special class index.
	 *
	 * @return The special class index.
	 * @since 2018/09/20
	 */
	public final int specialIndex()
	{
		return this.specialindex;
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super class of this class.
	 * @since 2018/09/08
	 */
	public final SpringClass superClass()
	{
		return this.superclass;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
	
	/**
	 * Returns the root type, the base of the component.
	 *
	 * @return The root type of this type.
	 * @since 2018/09/27
	 */
	private final SpringClass __rootType()
	{
		SpringClass rv = this;
		for (SpringClass r = this; r != null; r = r.component)
			rv = r;
		return rv;
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringClassCastException.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an attempt is made to cast from one class type to
 * another.
 *
 * @since 2018/09/15
 */
public class SpringClassCastException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringClassCastException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ClassCastException";
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringClassFormatException.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;

/**
 * This is thrown when the format of a class is not correct, it is invalid.
 *
 * @since 2018/08/05
 */
public class SpringClassFormatException
	extends SpringException
{
	/** The name of the class. */
	protected final ClassName name;
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __cn The class which was not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __m The message.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, String __m)
		throws NullPointerException
	{
		super(__m);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __m The message.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, String __m,
		Throwable __c)
		throws NullPointerException
	{
		super(__m, __c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, Throwable __c)
		throws NullPointerException
	{
		super(__c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Returns the name of the class.
	 *
	 * @return The class name.
	 * @since 2018/08/05
	 */
	public final ClassName name()
	{
		return this.name;
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringClassLoader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.vm.VMClassLibrary;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This class acts as the equivalent to {@code ClassLoader} in that it manages
 * the class path and the eventual loading of classes.
 *
 * @since 2018/09/01
 */
public final class SpringClassLoader
{
	/** Class loading lock. */
	protected final Object loaderlock =
		new Object();
	
	/** The class path for the machine. */
	private final VMClassLibrary[] _classpath;
	
	/** The classes which have been loaded by the virtual machine. */
	private final Map<ClassName, SpringClass> _classes =
		new HashMap<>();
	
	/** Next special class index. */
	private int _nexcsi =
		1;
	
	/**
	 * Initializes the class loader.
	 *
	 * @param __classpath The classpath.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	public SpringClassLoader(VMClassLibrary... __classpath)
		throws NullPointerException
	{
		for (VMClassLibrary b : __classpath = (__classpath == null ?
			new VMClassLibrary[0] : __classpath.clone()))
			if (b == null)
				throw new NullPointerException("NARG");
		this._classpath = __classpath;
	}
	
	/**
	 * Returns the library that is used for booting, the main entry JAR.
	 *
	 * @return The boot library.
	 * @since 2018/09/13
	 */
	public final VMClassLibrary bootLibrary()
	{
		VMClassLibrary[] classpath = this._classpath;
		return classpath[classpath.length - 1];
	}
	
	/**
	 * Returns the class loading lock.
	 *
	 * @return The class loading lock.
	 * @since 2018/09/08
	 */
	public final Object classLoadingLock()
	{
		return this.loaderlock;
	}
	
	/**
	 * Returns the class path.
	 *
	 * @return The classpath.
	 * @since 2018/12/06
	 */
	public final VMClassLibrary[] classPath()
	{
		return this._classpath.clone();
	}
	
	/**
	 * Finds the specified library.
	 *
	 * @param __n The library to find.
	 * @return The given library or {@code null} if it was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public final VMClassLibrary findLibrary(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		for (VMClassLibrary lib : this._classpath)
			if (__n.equals(lib.name()))
				return lib;
		
		return null;
	}
	
	/**
	 * Loads the specified class.
	 *
	 * @param __cn The name of the class to load.
	 * @return The loaded class.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringClassFormatException If the class is not formatted
	 * properly.
	 * @throws SpringClassNotFoundException If the class was not found.
	 * @since 2018/09/01
	 */
	public final SpringClass loadClass(ClassName __cn)
		throws NullPointerException, SpringClassFormatException,
			SpringClassNotFoundException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Lock on classes
		Map<ClassName, SpringClass> classes = this._classes;
		synchronized (this.loaderlock)
		{
			// If the class has already been initialized, use that
			SpringClass rv = classes.get(__cn);
			if (rv != null)
				return rv;
			
			// Debug
			/*todo.DEBUG.note("Loading class `%s`...", __cn);*/
			
			// Load class file for this class
			ClassFile cf;
			String[] injar = new String[1];
			try
			{
				cf = this.loadClassFile(__cn, injar);
			}
			catch (InvalidClassFormatException e)
			{
				// {@squirreljme.error BK12 Could not load class. (The class
				// to load)}
				throw new InvalidClassFormatException(
					String.format("BK12 %s", __cn), e);
			}
			
			// Load the super class
			ClassName supername = cf.superName();
			SpringClass superclass = (supername == null ? null :
				this.loadClass(supername));
			
			// Load any interfaces
			ClassName[] interfacenames = cf.interfaceNames().toArray();
			int numinterfaces = interfacenames.length;
			SpringClass[] interfaceclasses = new SpringClass[numinterfaces];
			for (int i = 0; i < numinterfaces; i++)
				interfaceclasses[i] = this.loadClass(interfacenames[i]);
			
			// Component?
			SpringClass component = null;
			if (__cn.isArray())
				component = this.loadClass(__cn.componentType());
			
			// Load class information
			rv = new SpringClass(superclass, interfaceclasses, cf,
				this._nexcsi++, component, injar[0]);
			
			// Store for later use
			classes.put(__cn, rv);
			
			return rv;
		}
	}
	
	/**
	 * This goes through the classpath and loads the specified class file for
	 * the given class.
	 *
	 * @param __cn The class to load.
	 * @param __ij The input JAR file for the class.
	 * @return The loaded class file data.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringClassFormatException If the class is not formatted
	 * properly.
	 * @throws SpringClassNotFoundException If the class was not found.
	 * @since 2018/09/01
	 */
	public final ClassFile loadClassFile(ClassName __cn, String[] __ij)
		throws NullPointerException, SpringClassFormatException,
			SpringClassNotFoundException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Loading class file `%s`...", __cn);*/
		
		// If this is an array type use virtual class representation
		if (__cn.isPrimitive() || __cn.isArray())
			return ClassFile.special(__cn.field());
		
		// This is the class that is read, in binary form
		String fileform = __cn.toString() + ".class";
		
		// Otherwise we need to go through every single binary to find
		// the class we want, which can take awhile
		byte[] data = null;
		for (VMClassLibrary b : this._classpath)
			try (InputStream in = b.resourceAsStream(fileform))
			{
				// Class or file does not exist
				if (in == null)
					continue;
				
				// Read in the data
				byte[] buf = new byte[512];
				try (ByteArrayOutputStream baos =
					new ByteArrayOutputStream(1024))
				{
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
						{
							baos.flush();
							data = baos.toByteArray();
							break;
						}
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Record the binary
				if (__ij != null && __ij.length > 0)
					__ij[0] = b.name();
				
				break;
			}
			catch (IOException e)
			{
				// {@squirreljme.error BK13 Failed to read from the class
				// path.}
				throw new SpringException("BK13", e);
			}
		
		// {@squirreljme.error BK14 Could not locate the specified class.
		// (The class which was not found; The class file which was
		// attempted to be located)}
		if (data == null)
			throw new SpringClassNotFoundException(__cn, String.format(
				"BK14 %s %s", __cn, fileform));
		
		// Decode class file
		ClassFile cf;
		try (ByteArrayInputStream bais = new ByteArrayInputStream(data))
		{
			return ClassFile.decode(bais);
		}
		catch (IOException e)
		{
			// {@squirreljme.error BK15 Could not read from the source
			// class file. (The class being read)}
			throw new SpringVirtualMachineException(String.format(
				"BK15 %s", __cn), e);
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error BK16 The class is not formatted
			// correctly. (The class being read)}
			throw new SpringClassFormatException(__cn, String.format(
				"BK16 %s", __cn), e);
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringClassNotFoundException.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;

/**
 * This is thrown when the specified class could not be found.
 *
 * @since 2018/08/05
 */
public class SpringClassNotFoundException
	extends SpringException
{
	/** The name of the class. */
	protected final ClassName name;
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __cn The class which was not found.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __m The message.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, String __m)
		throws NullPointerException
	{
		super(__m);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __m The message.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, String __m,
		Throwable __c)
		throws NullPointerException
	{
		super(__m, __c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, Throwable __c)
		throws NullPointerException
	{
		super(__c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Returns the name of the class.
	 *
	 * @return The class name.
	 * @since 2018/08/05
	 */
	public final ClassName name()
	{
		return this.name;
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringCoatFactory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMFactory;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;
import java.util.Map;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;

/**
 * Factory which creates instances of the SpringCoat virtual machine.
 *
 * @since 2018/11/17
 */
public class SpringCoatFactory
	extends VMFactory
{
	/**
	 * Initializes the factory.
	 *
	 * @since 2018/11/17
	 */
	public SpringCoatFactory()
	{
		super("springcoat");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	protected VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Create a new instance of the VM
		SpringTaskManager tm = new SpringTaskManager(__sm, __ps, __sprops);
		return new SpringMachine(__sm, new SpringClassLoader(__cp),
			tm, __maincl, __ismid, -1,
			__gd, __ps, __sprops, __args);
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This interface describes any throwable which may be converted.
 *
 * @since 2018/12/04
 */
public interface SpringConvertableThrowable
{
	/**
	 * Returns the message.
	 *
	 * @return The message.
	 * @since 2018/12/04
	 */
	String getMessage();
	
	/**
	 * Returns the class this throwable converts to.
	 *
	 * @return The target class this converts to.
	 * @since 2018/12/04
	 */
	String targetClass();
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringDisplayEventCallback.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.NativeDisplayEventCallback;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This is the callback to use which calls the given spring object, this is
 * needed by the native display.
 *
 * @since 2018/12/03
 */
public final class SpringDisplayEventCallback
	implements NativeDisplayEventCallback
{
	/** The class used for callback. */
	private static final ClassName _CALLBACK_CLASS =
		new ClassName("cc/squirreljme/runtime/cldc/asm/" +
			"NativeDisplayEventCallback");
	
	/** The object to call into. */
	protected final SpringObject object;
	
	/** The thread to use. */
	protected final SpringThread thread;
	
	/** The worker for threads. */
	protected final SpringThreadWorker worker;
	
	/**
	 * Initializes the callback to call the given object.
	 *
	 * @param __m The machine owning this.
	 * @param __o The object to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/03
	 */
	public SpringDisplayEventCallback(SpringMachine __m, SpringObject __o)
		throws NullPointerException
	{
		if (__m == null || __o == null)
			throw new NullPointerException("NARG");
		
		// Set object to call
		this.object = __o;
		
		// Setup thread
		SpringThread thread = __m.createThread("SpringCoat-LCDUIThread");
		SpringThreadWorker worker = new SpringThreadWorker(__m, thread, false);
		
		// Need to initialize a thread object because this thread has to be
		// registered with the runtime in order for programs to operate
		// correctly on it, even though it is a weird thread
		// This is always registered until it is explicitely not registered
		SpringObject fakethread = worker.newInstance(
			new ClassName("java/lang/Thread"), new MethodDescriptor(
				"(ILjava/lang/String;)V"), thread.id,
				worker.asVMObject(thread.name));
		
		// Store
		this.thread = thread;
		this.worker = worker;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void command(int __d, int __c)
	{
		this.__exec("command", "(II)V", __d, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void exitRequest(int __d)
	{
		this.__exec("exitRequest", "(I)V", __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{
		this.__exec("keyEvent", "(IIIII)V", __d, __ty, __kc, __ch, __time);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public final void lostCallback()
	{
		this.__exec("lostCallback", "()V");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		this.__exec("paintDisplay", "(IIIII)V", __d, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{
		this.__exec("pointerEvent", "(IIIII)V", __d, __ty, __x, __y, __time);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void shown(int __d, int __shown)
	{
		this.__exec("shown", "(II)V", __d, __shown);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{
		this.__exec("sizeChanged", "(III)V", __d, __w, __h);
	}
	
	/**
	 * Executes the given function in the callback.
	 *
	 * @param __func The function to call.
	 * @param __desc The descriptor.
	 * @param __args The arguments to call.
	 * @return The object value.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/03
	 */
	private final Object __exec(String __func, String __desc, Object... __args)
		throws NullPointerException
	{
		if (__func == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Need object and our class
		SpringObject object = this.object;
		
		// Copy arguments to seed our object
		int n = __args.length;
		Object[] args = new Object[n + 1];
		args[0] = object;
		for (int i = 0, o = 1; i < n; i++, o++)
			args[o] = __args[i];
		
		// Call method
		SpringThreadWorker worker = this.worker;
		Object rv;
		try
		{
			// Only allow a single call to be performed at a time
			synchronized (this)
			{
				rv = worker.invokeMethod(false,
					SpringDisplayEventCallback._CALLBACK_CLASS,
					new MethodNameAndType(__func, __desc), args);
			}
		}
		
		// The VM is exiting from the method, we cannot propogate the method
		// up we could just do nothing, just cancel what has happened.
		catch (SpringMachineExitException e)
		{
			// Debug it
			todo.DEBUG.note("VM in exit state, canceling display function.");
			
			return null;
		}
		
		// Handle return value or keep it as void
		if (rv != null)
			return worker.asNativeObject(rv);
		return null;
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This is the base class for all exceptions within the spring machine.
 *
 * @since 2018/08/05
 */
public class SpringException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/08/05
	 */
	public SpringException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/08/05
	 */
	public SpringException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/08/05
	 */
	public SpringException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/08/05
	 */
	public SpringException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringFatalException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is an exception which describes something that is very fatal within
 * the virtual machine.
 *
 * @since 2018/09/20
 */
public class SpringFatalException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/20
	 */
	public SpringFatalException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/20
	 */
	public SpringFatalException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/20
	 */
	public SpringFatalException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/20
	 */
	public SpringFatalException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringField.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldNameAndType;

/**
 * This contains and stores the definition of a single field.
 *
 * @since 2018/07/22
 */
public final class SpringField
	implements SpringMember
{
	/** The class this technically belongs to. */
	protected final ClassName inclass;
	
	/** The field definition. */
	protected final Field field;
	
	/** The field index. */
	protected final int index;
	
	/**
	 * Initializes the field.
	 *
	 * @param __cn The class this field is in.
	 * @param __f The field definition.
	 * @param __dx The field index, this is ignored for statics and cannot be
	 * negative for instances.
	 * @throws IllegalArgumentException If the field index is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	SpringField(ClassName __cl, Field __f, int __dx)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.field = __f;
		
		// Instance fields require an index
		if (__f.flags().isInstance())
		{
			// {@squirreljme.error BK17 Negative field index.}
			if (__dx < 0)
				throw new IllegalArgumentException("BK17");	
			
			this.index = __dx;
		}
		
		// Not used for statics
		else
			this.index = -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldFlags flags()
	{
		return this.field.flags();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final ClassName inClass()
	{
		return this.inclass;
	}
	
	/**
	 * Returns the index of this field.
	 *
	 * @return The field index.
	 * @since 2018/09/16
	 */
	public final int index()
	{
		return this.index;
	}
	
	/**
	 * Is this a static field?
	 *
	 * @return If this is a static field.
	 * @since 2018/09/09
	 */
	public final boolean isStatic()
	{
		return this.field.flags().isStatic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldNameAndType nameAndType()
	{
		return this.field.nameAndType();
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringFieldStorage.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.FieldNameAndType;

/**
 * Contains storage and other information for fields.
 *
 * @since 2018/09/09
 */
public final class SpringFieldStorage
{
	/** The class this is in. */
	protected final ClassName inclass;
	
	/** Name and type of the field. */
	protected final FieldNameAndType nameandtype;
	
	/** Is this volatile? */
	protected final boolean isvolatile;
	
	/** Is this final? */
	protected final boolean isfinal;
	
	/** The value of the field. */
	private Object _normalvalue;
	
	/** The volatile value of the field. */
	private volatile Object _volatilevalue;
	
	/**
	 * Initializes the static field.
	 *
	 * @param __f The field to store for.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/09/09
	 */
	SpringFieldStorage(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Used for debug
		FieldNameAndType nameandtype;
		this.inclass = __f.inClass();
		this.nameandtype = (nameandtype = __f.nameAndType());
		
		// Initialize value depending on the field type
		Object init;
		switch (nameandtype.type().simpleStorageType())
		{
			case OBJECT:
				init = SpringNullObject.NULL;
				break;
			
			case INTEGER:
				init = Integer.valueOf(0);
				break;
			
			case LONG:
				init = Long.valueOf(0);
				break;
			
			case FLOAT:
				init = Float.valueOf(0);
				break;
			
			case DOUBLE:
				init = Double.valueOf(0);
				break;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
		
		// If the field starts with a constant, it must be initialized
		ConstantValue cv = __f.field.constantValue();
		if (cv != null)
			init = cv.boxedValue();
		
		// Set initial value
		if ((this.isvolatile = __f.flags().isVolatile()))
			this._volatilevalue = init;
		else
			this._normalvalue = init;
		
		this.isfinal = __f.flags().isFinal();
	}
	
	/**
	 * Returns the value of the field.
	 *
	 * @return The field value.
	 * @since 2018/09/15
	 */
	public final Object get()
	{
		// Volatile field, use volatile field instead
		if (this.isvolatile)
			return this._volatilevalue;
		
		// Otherwise just set thread without worrying about any contention
		else
			return this._normalvalue;
	}
	 
	/**
	 * Sets the static field to the given value.
	 *
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final void set(Object __v)
		throws NullPointerException
	{
		this.set(__v, false);
	}
	
	/**
	 * Sets the static field to the given value, final may be overridden
	 * potentially.
	 *
	 * @param __v The value to set.
	 * @param __writetofinal If true then final is overridden.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the field is final
	 * and we are not allowed to write to final fields.
	 * @since 2018/09/09
	 */
	public final void set(Object __v, boolean __writetofinal)
		throws SpringIncompatibleClassChangeException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("%s::%s = %s", this.inclass, this.nameandtype,
			__v);*/
		
		// {@squirreljme.error BK18 Attempt to write to final field.}
		if (this.isfinal && !__writetofinal)
			throw new SpringIllegalAccessException("BK18");
		
		// Volatile field, use volatile field instead
		if (this.isvolatile)
			this._volatilevalue = __v;
		
		// Otherwise just set thread without worrying about any contention
		else
			this._normalvalue = __v;
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a class or member of a class cannot be accessed.
 *
 * @since 2018/09/15
 */
public class SpringIllegalAccessException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringIllegalMonitorStateException.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the state of a monitor is not valid.
 *
 * @since 2018/09/15
 */
public class SpringIllegalMonitorStateException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/IllegalMonitorStateException";
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringIncompatibleClassChangeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a class refers to another reference and it differs
 * than what was expected at run-time.
 *
 * @since 2018/09/09
 */
public class SpringIncompatibleClassChangeException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringInstance.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This represents an instance of an object which has a class and defined
 * fields.
 *
 * @since 2018/07/22
 */
public final class SpringInstance
{
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringMachine.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMResourceAccess;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValueString;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodNameAndType;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This class contains the instance of the SpringCoat virtual machine and has
 * a classpath along with all the needed storage for variables and such.
 *
 * @since 2018/07/29
 */
public final class SpringMachine
	implements Runnable, VirtualMachine
{
	/** Lock. */
	public final Object strlock =
		new Object();
	
	/** The class loader. */
	protected final SpringClassLoader classloader;
	
	/** Resources accessor. */
	protected final VMResourceAccess resourceaccessor;
	
	/** The boot class. */
	protected final String bootcl;
	
	/** Is the boot a midlet? */
	protected final boolean bootmid;
	
	/** The boot index. */
	protected final int bootdx;
	
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** Task manager. */
	protected final SpringTaskManager tasks;
	
	/** The depth of this machine. */
	protected final int guestdepth;
	
	/** The profiling information. */
	protected final ProfilerSnapshot profiler;
	
	/** Pointer manager. */
	protected final SpringPointerManager pointers =
		new SpringPointerManager();
	
	/** Threads which are available. */
	private final List<SpringThread> _threads =
		new ArrayList<>();
	
	/** Static fields which exist within the virtual machine. */
	private final Map<SpringField, SpringFieldStorage> _staticfields =
		new HashMap<>();
	
	/** Global strings representing singular constants. */
	private final Map<ConstantValueString, SpringObject> _strings =
		new HashMap<>();
	
	/** Class objects which represent a given class. */
	private final Map<ClassName, SpringObject> _classobjects =
		new HashMap<>();
	
	/** Class names by their objects. */
	private final Map<SpringObject, ClassName> _namesbyclass =
		new HashMap<>();
	
	/** Main entry point arguments. */
	private final String[] _args;
	
	/** Long to string map. */
	private final Map<Long, String> _strlongtostring =
		new HashMap<>();
	
	/** String to long map. */
	private final Map<String, Long> _strstringtolong =
		new HashMap<>();
	
	/** System properties. */
	final Map<String, String> _sysproperties;
	
	/** The next thread ID to use. */
	private volatile int _nextthreadid;
	
	/** The next long to choose. */
	private long _strnextlong;
	
	/** Is the VM exiting? */
	private volatile boolean _exiting;
	
	/** Exit code of the VM. */
	volatile int _exitcode;
	
	/**
	 * Initializes the virtual machine.
	 *
	 * @param __sm The manager for suites.
	 * @param __cl The class loader.
	 * @param __tm Task manager.
	 * @param __bootcl The boot class.
	 * @param __bootmid The boot class a midlet.
	 * @param __bootdx The entry point which should be booted when the VM
	 * runs.
	 * @param __gd Guest depth.
	 * @param __profiler The profiler to use.
	 * @param __nda The native display provider.
	 * @param __sprops System properties.
	 * @param __args Main entry point arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public SpringMachine(VMSuiteManager __sm, SpringClassLoader __cl,
		SpringTaskManager __tm, String __bootcl, boolean __bootmid,
		int __bootdx, int __gd, ProfilerSnapshot __profiler,
		Map<String, String> __sprops, String... __args)
		throws NullPointerException
	{
		if (__cl == null || __sm == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.classloader = __cl;
		this.tasks = __tm;
		this.bootcl = __bootcl;
		this.bootmid = __bootmid;
		this.bootdx = __bootdx;
		this.guestdepth = __gd;
		this._args = (__args == null ? new String[0] : __args.clone());
		this.profiler = (__profiler != null ? __profiler :
			new ProfilerSnapshot());
		this._sysproperties = (__sprops == null ?
			new HashMap<String, String>() : new HashMap<>(__sprops));
		
		// Setup resource accessor
		this.resourceaccessor = new VMResourceAccess(__sm);
	}
	
	/**
	 * Returns the class loader.
	 *
	 * @return The class loader.
	 * @since 2018/09/08
	 */
	public final SpringClassLoader classLoader()
	{
		return this.classloader;
	}
	
	/**
	 * Creates a new thread within the virtual machine.
	 *
	 * @param __n The name of the thread.
	 * @return The newly created thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	public final SpringThread createThread(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Store thread
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			// Initialize new thread
			int v;
			SpringThread rv = new SpringThread((v = ++this._nextthreadid), __n,
				this.profiler.measureThread(String.format("%s-vm%08x-%d-%s",
				this.classloader.bootLibrary().name(),
				System.identityHashCode(this), v, __n)));
			
			// Store thread
			threads.add(rv);
			return rv;
		}
	}
	
	/**
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */
	public final String debugResolveString(long __p)
	{
		if (__p == -1L)
			return null;
		
		synchronized (this.strlock)
		{
			return this._strlongtostring.get(__p);
		}
	}
	
	/**
	 * Unresolves the given string.
	 *
	 * @param __s The string to unresolve.
	 * @return The pointer to the string.
	 * @since 2018/09/29
	 */
	public final long debugUnresolveString(String __s)
	{
		if (__s == null)
			return -1L;
		
		synchronized (this.strlock)
		{
			Long rv = this._strstringtolong.get(__s);
			if (rv != null)
				return rv.longValue();
			
			Long next = Long.valueOf(++this._strnextlong);
			this._strstringtolong.put(__s, next);
			this._strlongtostring.put(next, __s);
			
			return next;
		}
	}
	
	/**
	 * Exits the virtual machine.
	 *
	 * @param __code The exit code.
	 * @throws SpringMachineExitException To signal virtual machine exit.
	 * @since 2018/10/13
	 */
	public final void exit(int __code)
		throws SpringMachineExitException
	{
		// Set as exiting
		this._exitcode = __code;
		this._exiting = true;
		
		// Now signal exit
		throw new SpringMachineExitException(__code);
	}
	
	/**
	 * Checks whether the virtual machine is exiting.
	 *
	 * @throws SpringMachineExitException If the VM is exiting.
	 * @since 2018/10/13
	 */
	public final void exitCheck()
		throws SpringMachineExitException
	{
		// Only if exiting
		if (this._exiting)
			throw new SpringMachineExitException(this._exitcode);
	}
	
	/**
	 * Exits the virtual machine without throwing an exception.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	public final void exitNoException(int __code)
		throws SpringMachineExitException
	{
		// Set as exiting
		this._exitcode = __code;
		this._exiting = true;
	}
	
	/**
	 * Gets the thread by the given ID.
	 *
	 * @param __id The ID of the thread.
	 * @return The thread by this ID or {@code null} if it was not found.
	 * @since 2018/11/21
	 */
	public final SpringThread getThread(int __id)
	{
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			for (SpringThread t : threads)
				if (t.id == __id)
					return t;
		}
		
		return null;
	}
	
	/**
	 * Returns the static field for the given field.
	 *
	 * @param __f The field to get the static field for.
	 * @return The static field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringVirtualMachineException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringFieldStorage lookupStaticField(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Static fields may be added to when class loading is happening and
		// as such there must be a lock to be given safe access
		Map<SpringField, SpringFieldStorage> sfm = this._staticfields;
		synchronized (this.classloader.classLoadingLock())
		{
			SpringFieldStorage rv = sfm.get(__f);
			
			// {@squirreljme.error BK19 Could not locate the static field
			// storage?}
			if (rv == null)
				throw new SpringVirtualMachineException("BK19");
			
			return rv;
		}
	}
	
	/**
	 * Returns the number of threads which are currently alive and active.
	 *
	 * @return The number of active and alive threads.
	 * @since 2018/09/03
	 */
	public final int numThreads()
	{
		// Store thread
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			return threads.size();
		}
	}
	
	/**
	 * Returns the access for resources.
	 *
	 * @return The resource access.
	 * @since 2018/10/07
	 */
	public final VMResourceAccess resourceAccess()
	{
		return this.resourceaccessor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/13
	 */
	@Override
	public final void run()
	{
		// Obtain the boot library to read entry points from
		SpringClassLoader classloader = this.classloader;
		VMClassLibrary bootbin = classloader.bootLibrary();
		
		// May be specified or not
		String entryclass = this.bootcl;
		boolean ismidlet = this.bootmid;
		int launchid = this.bootdx;
		
		// Lookup the entry class via the manifest
		if (entryclass == null)
		{
			// Need to load the manifest where the entry points will be
			EntryPoints entries;
			try (InputStream in = bootbin.resourceAsStream(
				"META-INF/MANIFEST.MF"))
			{
				// {@squirreljme.error BK1a Entry point JAR has no manifest.
				// (The name of the boot binary)}
				if (in == null)
					throw new SpringVirtualMachineException("BK1a " +
						bootbin.name());
				
				entries = new EntryPoints(new JavaManifest(in));
			}
			
			// {@squirreljme.error BK1b Failed to read the manifest.}
			catch (IOException e)
			{
				throw new SpringVirtualMachineException("BK1b", e);
			}
			
			int n = entries.size();
			
			// Print entry points out out for debug, but only for the first
			// guest because this is annoying!
			if (GuestDepth.guestDepth() + 1 == this.guestdepth)
			{
				todo.DEBUG.note("Entry points:");
				for (int i = 0; i < n; i++)
					todo.DEBUG.note("    %d: %s", i, entries.get(i));
			}
			
			// Use the first program if the ID is not valid
			if (launchid < 0 || launchid >= n)
				launchid = 0;
			
			// Needed to enter the machine
			EntryPoint entry = entries.get(launchid);
			entryclass = entry.entryPoint().toString();
			ismidlet = entry.isMidlet();
		}
		
		// Thread that will be used as the main thread of execution, also used
		// to initialize classes when they are requested
		SpringThread mainthread = this.createThread("main");
		
		// We will be using the same logic in the thread worker if we need to
		// initialize any objects or arguments
		SpringThreadWorker worker = new SpringThreadWorker(this,
			mainthread, true);
		mainthread._worker = worker;
		
		// Load the entry point class
		SpringClass entrycl = worker.loadClass(new ClassName(
			entryclass.replace('.', '/')));
		
		// Find the method to be entered in
		SpringMethod mainmethod;
		if (ismidlet)
			mainmethod = entrycl.lookupMethod(false,
				new MethodNameAndType("startApp", "()V"));
		else
			mainmethod = entrycl.lookupMethod(true,
				new MethodNameAndType("main", "([Ljava/lang/String;)V"));
		
		// Setup object to initialize with for thread
		SpringVMStaticMethod vmsm = new SpringVMStaticMethod(mainmethod);
		
		// Determine the entry argument, midlets is just the class to run
		Object entryarg;
		if (ismidlet)
			entryarg = worker.asVMObject(entryclass.replace('.', '/'));
		else
		{
			String[] inargs = this._args;
			int inlen = inargs.length;
			
			// Setup array
			SpringArrayObject outargs = worker.allocateArray(
				worker.resolveClass(new ClassName("java/lang/String")), inlen);
			
			// Initialize the argument array
			for (int i = 0; i < inlen; i++)
				outargs.set(i, worker.asVMObject(inargs[i]));
			
			entryarg = outargs;
		}
		
		// Setup new thread object
		SpringObject threadobj = worker.newInstance(worker.loadClass(
			new ClassName("java/lang/Thread")), new MethodDescriptor(
			"(Ljava/lang/String;ILcc/squirreljme/runtime/cldc/asm/" +
			"StaticMethod;Ljava/lang/Object;)V"), worker.asVMObject("Main"),
			(ismidlet ? 3 : 4), vmsm, entryarg);
		
		// Enter the frame for that method using the arguments we passed (in
		// a static fashion)
		mainthread.enterFrame(worker.loadClass(
			new ClassName("java/lang/Thread")).lookupMethod(false,
			new MethodNameAndType("__start", "()V")), threadobj);
		
		// The main although it executes in this context will always have the
		// same exact logic as other threads running apart from this main
		// thread, so no code is needed to be duplicated at all.
		try
		{
			worker.run();
		}
		
		// Virtual machine exited, do not print fatal trace just exit here
		catch (SpringMachineExitException e)
		{
			throw e;
		}
		
		// Ooopsie!
		catch (RuntimeException e)
		{
			/*PrintStream err = System.err;
			
			err.println("****************************");
			
			// Print the real stack trace
			err.println("*** EXTERNAL STACK TRACE ***");
			e.printStackTrace(err);
			err.println();
			
			// Print the VM seen stack trace
			err.println("*** INTERNAL STACK TRACE ***");
			mainthread.printStackTrace(err);
			err.println();
			
			err.println("****************************");*/
			
			// Retoss
			throw e;
		}
		
		// Wait until all threads have terminated before actually leaving
		for (;;)
		{
			// Check if the VM is exiting, this would have happen if another
			// thread called exit
			// If we do not check, then the VM will never exit even after
			// another thread has exited
			this.exitCheck();
			
			// No more threads left?
			int okay = 0,
				notokay = 0;
			List<SpringThread> threads = this._threads;
			synchronized (threads)
			{
				for (SpringThread t : threads)
					if (t.isExitOkay())
						okay++;
					else
						notokay++;
			}
			
			// Okay to exit?
			if (notokay == 0)
				return;
			
			// Wait a short duration before checking again
			try
			{
				Thread.sleep(500);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	public final int runVm()
	{
		// Run until the VM terminates
		try
		{
			this.run();
			
			// Success, maybe
			return this._exitcode;
		}
		
		// Exit VM with given code
		catch (SpringMachineExitException e)
		{
			return e.code();
		}
		
		// Ignore these exceptions, just fatal exit
		catch (SpringFatalException e)
		{
			return TaskAccess.EXIT_CODE_FATAL_EXCEPTION;
		}
		
		// Any other exception is fatal and the task must be made to exit
		// with the error code otherwise the VM will stick trying to wait
		// to exit
		catch (RuntimeException|Error e)
		{
			PrintStream err = System.err;
			
			err.println("****************************");
			
			// Print the real stack trace
			err.println("*** EXTERNAL STACK TRACE ***");
			e.printStackTrace(err);
			err.println();
			
			err.println("****************************");
			
			return TaskAccess.EXIT_CODE_FATAL_EXCEPTION;
		}
	}
	
	/**
	 * Returns the suite manager which is available.
	 *
	 * @return The suite manager that is available.
	 * @since 2018/10/26
	 */
	public final VMSuiteManager suiteManager()
	{
		return this.suites;
	}
	
	/**
	 * Returns the task manager which is used.
	 *
	 * @return The task manager.
	 * @since 2018/11/04
	 */
	public final SpringTaskManager taskManager()
	{
		return this.tasks;
	}
	
	/**
	 * Splits long to integers.
	 *
	 * @param __dx The index.
	 * @param __v The output integers.
	 * @param __l The input long.
	 * @since 2018/09/29
	 */
	public static final void longToInt(int __dx, int[] __v, long __l)
	{
		__v[__dx] = (int)(__l >>> 32);
		__v[__dx + 1] = (int)__l;
	}
	
	/**
	 * Returns the mapping of class names to {@link Class} instances.
	 *
	 * @return The mapping of class names to object instances.
	 * @since 2018/09/19
	 */
	final Map<ClassName, SpringObject> __classObjectMap()
	{
		return this._classobjects;
	}
	
	/**
	 * Returns the mapping for objects to class names.
	 *
	 * @return The mapping of class objects to names.
	 * @since 2018/09/29
	 */
	final Map<SpringObject, ClassName> __classObjectToNameMap()
	{
		return this._namesbyclass;
	}
	
	/**
	 * Returns the map of static fields.
	 *
	 * @return The static field map.
	 * @since 2018/09/08
	 */
	final Map<SpringField, SpringFieldStorage> __staticFieldMap()
	{
		return this._staticfields;
	}
	
	/**
	 * Returns the global string map.
	 *
	 * @return The global string map.
	 * @since 2018/09/16
	 */
	final Map<ConstantValueString, SpringObject> __stringMap()
	{
		return this._strings;
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the virtual machine is exiting.
 *
 * @since 2018/10/13
 */
public class SpringMachineExitException
	extends SpringException
{
	/** The exit code. */
	protected final int code;
	
	/**
	 * Initializes the exception with the given exit code.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	public SpringMachineExitException(int __code)
	{
		super("" + __code);
		
		this.code = __code;
	}
	
	/**
	 * Returns the exit code.
	 *
	 * @return The exit code.
	 * @since 2018/10/33
	 */
	public final int code()
	{
		return this.code;
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringMember.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.HasMemberFlags;
import net.multiphasicapps.classfile.MemberNameAndType;

/**
 * This represents a member.
 *
 * @since 2018/09/09
 */
public interface SpringMember
	extends HasMemberFlags
{
	/**
	 * Returns the class this is a member of.
	 *
	 * @return The class which owns the method.
	 * @since 2018/09/09
	 */
	ClassName inClass();
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	MemberNameAndType nameAndType();
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringMethod.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This contains and stores the definition of a single method.
 *
 * @since 2018/07/22
 */
public final class SpringMethod
	implements SpringMember
{
	/** The class this technically belongs to. */
	protected final ClassName inclass;
	
	/** The backing method and its information. */
	protected final Method method;
	
	/** The file this method is in. */
	protected final String infile;
	
	/**
	 * Initializes the method representation.
	 *
	 * @param __ic The class this belongs to.
	 * @param __m The method to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	SpringMethod(ClassName __ic, Method __m, String __if)
		throws NullPointerException
	{
		if (__ic == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __ic;
		this.method = __m;
		this.infile = __if;
	}
	
	/**
	 * Returns the byte code of the method.
	 *
	 * @return The method byte code.
	 * @since 2018/09/03
	 */
	public final ByteCode byteCode()
	{
		return this.method.byteCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodFlags flags()
	{
		return this.method.flags();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/03
	 */
	@Override
	public final ClassName inClass()
	{
		return this.inclass;
	}
	
	/**
	 * Returns the file this method is in.
	 *
	 * @return The file this method is in, may be {@code null}.
	 * @since 2018/09/20
	 */
	public final String inFile()
	{
		return this.infile;
	}
	
	/**
	 * Returns whether this method is abstract.
	 *
	 * @return Whether this method is abstract.
	 * @since 2018/09/03
	 */
	public final boolean isAbstract()
	{
		return this.method.flags().isAbstract();
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2018/09/03
	 */
	public final boolean isInstanceInitializer()
	{
		return this.method.isInstanceInitializer();
	}
	
	/**
	 * Returns if this method is static.
	 *
	 * @return {@code true} if the method is static.
	 * @since 2018/09/03
	 */
	public final boolean isStatic()
	{
		return this.method.flags().isStatic();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2018/09/03
	 */
	public final boolean isStaticInitializer()
	{
		return this.method.isStaticInitializer();
	}
	
	/**
	 * Returns the name of this method.
	 *
	 * @return The name of this method.
	 * @since 2018/09/09
	 */
	public final MethodName name()
	{
		return this.method.name();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodNameAndType nameAndType()
	{
		return this.method.nameAndType();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public final String toString()
	{
		return this.inclass + "::" + this.method.nameAndType().toString();
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringMonitor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.ObjectAccess;

/**
 * This is a monitor which is associated with an object.
 *
 * @since 2018/09/15
 */
public final class SpringMonitor
{
	/** The monitor lock. */
	protected final Object lock =
		new Object();
	
	/** The thread which owns this monitor. */
	volatile SpringThread _owner;
	
	/** Number of threads which are waiting on this monitor. */
	volatile int _waitcount;
	
	/** The number of notifications happening. */
	volatile int _notifycount;
	
	/** The entry count on the monitor. */
	private int _count;
	
	/**
	 * Enters the monitor.
	 *
	 * @param __t The thread trying to lock the monitor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final void enter(SpringThread __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		for (;;)
			synchronized (lock)
			{
				// We take possession of this monitor
				SpringThread owner = this._owner;
				if (owner == null)
				{
					this._owner = __t;
					this._count = 1;
					return;
				}
				
				// We own the monitor, so increase the count
				else if (owner == __t)
				{
					this._count++;
					return;
				}
				
				// Need to wait for it to be cleared
				else
				{
					// Wait for lock to be freed
					try
					{
						lock.wait();
					}
					catch (InterruptedException e)
					{
						// Ignore
					}
				}
			}
	}
	
	/**
	 * Exits the monitor.
	 *
	 * @param __t The thread exiting the monitor.
	 * @param __notify Should threads be notified that an unlock happened?
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIllegalMonitorStateException If the monitor is not owned
	 * by this thread.
	 * @since 2018/09/15
	 */
	public final void exit(SpringThread __t, boolean __notify)
		throws NullPointerException, SpringIllegalMonitorStateException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// {@squirreljme.error BK1c This thread does not own the
			// monitor.}
			if (this._owner != __t)
				throw new SpringIllegalMonitorStateException("BK1c");	
			
			// {@squirreljme.error BK1d No previous entry call was made.
			// (The monitor entry count)}
			int count = this._count;
			if (count <= 0)
				throw new SpringIllegalMonitorStateException(
					String.format("BK1d %d", count));
			
			// If the count reaches zero, no thread owns this now
			this._count = --count;
			if (count <= 0)
			{
				this._owner = null;
				
				// Wake up all threads so that they try and lock on the lock
				// so whoever gets that chance
				if (__notify)
					lock.notifyAll();
			}
		}
	}
	
	/**
	 * Notifies on this monitor and returns the status.
	 *
	 * @param __by The thread that is doing the notify.
	 * @param __all Notify all threads?
	 * @return The notification status.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/20
	 */
	public final int monitorNotify(SpringThread __by, boolean __all)
		throws NullPointerException
	{
		if (__by == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// Wrong thread?
			if (this._owner != __by)
				return ObjectAccess.MONITOR_NOT_OWNED;
			
			// Nothing is waiting, do not bother at all!
			int waitcount = this._waitcount;
			if (waitcount == 0)
				return 0;
			
			// Notify all threads or just one?
			// Never let the notify count exceed the wait count as well
			int notifycount = this._notifycount;
			this._notifycount = Math.min(waitcount,
				(__all ? waitcount : notifycount + 1));
			
			// Notify all threads that something happened with the lock
			lock.notifyAll();
			
			return 0;
		}
	}
	
	/**
	 * Waits on the monitor.
	 *
	 * @param __by The thread doing the wait.
	 * @param __ms The milliseconds to wait.
	 * @param __ns The nanoseconds to wait.
	 * @return The wait result.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public final int monitorWait(SpringThread __by, long __ms, int __ns)
		throws NullPointerException
	{
		if (__by == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// Wrong thread?
			if (this._owner != __by)
				return ObjectAccess.MONITOR_NOT_OWNED;
			
			// Increase our wait count
			this._waitcount++;
			
			// Relinquish control of this monitor, so that way when we actually
			// internally do the wait we check notify counts and such.
			this.exit(__by, true);
			
			// Do looped wait, but it may be timed
			boolean waitforever = (__ms == 0 && __ns == 0),
				interrupted = false,
				expired = false;
			long end = (waitforever ? Long.MAX_VALUE :
				System.nanoTime() + (__ms * 1_000_000L) + __ns);
			for (;;)
			{
				// read our wait and notify counts to determine if we
				// should take control here
				int nownotifycount = this._notifycount,
					nowwaitcount = this._waitcount;
				
				// We were notified, interrupted, or expired, take it and leave
				if (interrupted || expired || nownotifycount > 0)
				{
					// Reduce the notify count, but not when interrupted or
					// expired
					if (!interrupted && !expired)
						this._notifycount--;
					
					// Reduce wait count
					int waitcount = this._waitcount;
					this._waitcount = --waitcount;
					
					// Never let the notification count exceed the wait count
					if (this._notifycount > waitcount)
						this._notifycount = waitcount;
					
					// Re-enter the monitor
					this.enter(__by);
					
					// Whatever state we ended up in
					if (interrupted)
						return ObjectAccess.MONITOR_INTERRUPTED;
					return ObjectAccess.MONITOR_NOT_INTERRUPTED;
				}
				
				// Otherwise wait for notification to happen
				else
				{
					// Could be interrupted
					try
					{
						// Check if time expired
						if (!waitforever)
						{
							long rem = end - System.nanoTime();
							if (rem <= 0)
							{
								expired = true;
								continue;
							}
							
							// Wait for this time
							lock.wait(rem / 1_000_000L,
								(int)(rem % 1_000_000L));
						}
						
						// Wait forever
						else
						{
							lock.wait();
						}
					}
					
					// Was interrupted
					catch (InterruptedException e)
					{
						interrupted = true;
					}
				}
			}
		}
	}
	
	/**
	 * Waiting information on this monitor.
	 *
	 * @since 2018/11/20
	 */
	private static final class __Waiting__
	{
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringNegativeArraySizeException.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an attempt was made to allocate an array of a negative
 * size.
 *
 * @since 2018/09/15
 */
public class SpringNegativeArraySizeException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/NegativeArraySizeException";
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a field in a class does not exist.
 *
 * @since 2018/09/09
 */
public class SpringNoSuchFieldException
	extends SpringIncompatibleClassChangeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(Throwable __c)
	{
		super(__c);
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a method in a class does not exist.
 *
 * @since 2018/09/03
 */
public class SpringNoSuchMethodException
	extends SpringIncompatibleClassChangeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(Throwable __c)
	{
		super(__c);
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Represents the null object.
 *
 * @since 2018/09/08
 */
public final class SpringNullObject
	implements SpringObject
{
	/** Single null object reference. */
	public static final SpringNullObject NULL =
		new SpringNullObject();
	
	/**
	 * Only used once.
	 *
	 * @since 2018/09/08
	 */
	private SpringNullObject()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK1e Cannot obtain the monitor of an object
		// that is null.}
		throw new SpringNullPointerException("BK1e");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		return SpringPointerArea.NULL;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final SpringClass type()
	{
		return null;
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringNullPointerException.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a null reference has been detected.
 *
 * @since 2018/09/09
 */
public class SpringNullPointerException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringNullPointerException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/NullPointerException";
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This represents anything that is treated by the virtual machine as a kind
 * of object reference. This is needed for SquirrelJME since it exposes a
 * pointer logic which is magically handled by the virtual machine.
 *
 * @since 2018/09/08
 */
public interface SpringObject
{
	/**
	 * Returns the monitor for this object.
	 *
	 * @return This object's monitor.
	 * @since 2018/09/15
	 */
	SpringMonitor monitor();
	
	/**
	 * Returns the pointer area for this object.
	 *
	 * @return The pointer area for this object.
	 * @since 2019/12/21
	 */
	SpringPointerArea pointerArea();
	
	/**
	 * Returns the object type.
	 *
	 * @return The object type.
	 * @since 2018/09/09
	 */
	SpringClass type();
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringPointerArea.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.springcoat;

/**
 * This represents a new area where pointers can go.
 *
 * @since 2019/12/21
 */
public final class SpringPointerArea
	implements Comparable<SpringPointerArea>
{
	/** Null pointer. */
	public static final SpringPointerArea NULL =
		new SpringPointerArea(0, 0);
	
	/** The base address. */
	public final int base;
	
	/** The length of the area. */
	public final int length;
	
	/**
	 * Initializes the pointer area.
	 *
	 * @param __b The basee.
	 * @param __l The length.
	 * @throws IllegalArgumentException If the length is negative.
	 * @since 2019/12/21
	 */
	public SpringPointerArea(int __b, int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BK3f Cannot have a negative length pointer
		// area.}
		if (__l < 0)
			throw new IllegalArgumentException("BK3f");
		
		this.base = __b;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final int compareTo(SpringPointerArea __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringPointerManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.springcoat;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
 * This is used to manage pointers within SpringCoat.
 *
 * @since 2019/12/21
 */
public final class SpringPointerManager
{
	/** Queue for cleared references. */
	private final ReferenceQueue<SpringObject> _queue =
		new ReferenceQueue<>();
	
	/** Reference to integer. */
	private final Map<Reference<SpringObject>, Integer> _rtoi =
		new HashMap<>();
	
	/** Integer to reference. */
	private final Map<Integer, Reference<SpringObject>> _itor =
		new HashMap<>();
	
	/** The next allocation address. */
	private int _next =
		4;
	
	/**
	 * Allocates and returns a new pointer area.
	 *
	 * @param __l The length to allocate.
	 * @return The resulting pointer.
	 * @throws IllegalArgumentException If the length is negative.
	 * @since 2019/12/21
	 */
	public final SpringPointerArea allocate(int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BK3g Cannot allocate negative pointer space.}
		if (__l < 0)
			throw new IllegalArgumentException("BK3g");
		
		// Determine base pointer
		int base = this._next;
		
		// {@squirreljme.error BK3h Ran out of address space allocating
		// object. (The requested length)}
		if (base < 0)
			throw new SpringVirtualMachineException("BK3h " + __l);
		
		// Set next position
		this._next = base + ((__l + 3) & ~3);
		
		// Build pointer here
		return new SpringPointerArea(base, __l);
	}
	
	/**
	 * Allocates a pointer of the given length and binds the specified object
	 * to that pointer.
	 *
	 * @param __l The length to allocate.
	 * @param __o The object to bind.
	 * @return The resulting pointer.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public final SpringPointerArea allocateAndBind(int __l, SpringObject __o)
		throws IllegalArgumentException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Allocate pointer
		SpringPointerArea rv = this.allocate(__l);
		
		// Setup reference
		Reference<SpringObject> ref = new WeakReference(__o, this._queue);
		
		// Bind it
		synchronized (this)
		{
			Integer ibase = rv.base;
			
			// Store into both referencing maps
			this._rtoi.put(ref, ibase);
			this._itor.put(ibase, ref);
		}
		
		// Return the result
		return rv;
	}
	
	/**
	 * Locates the object at the given address.
	 *
	 * @param __p The object to find.
	 * @return The object which was found.
	 * @since 2019/12/22
	 */
	public final SpringObject findObject(int __p)
	{
		// Zero address always returns null pointers!
		if (__p == 0)
			return SpringNullObject.NULL;
		
		// Need to use both maps
		Map<Reference<SpringObject>, Integer> rtoi = this._rtoi;
		Map<Integer, Reference<SpringObject>> itor = this._itor;
		
		// Lock on self
		synchronized (this)
		{
			// First try to cleanup anything that was cleared reference
			// wise
			ReferenceQueue<SpringObject> queue = this._queue;
			for (;;)
			{
				// Any new ones appeared?
				Reference<? extends SpringObject> polled = queue.poll();
				if (polled == null)
					break;
				
				// Read integer base
				Integer ibase = rtoi.get(polled);
				
				// Clear from both maps
				rtoi.remove(polled);
				itor.remove(ibase);
			}
			
			// Try to find object reference
			Reference<SpringObject> ref = itor.get(__p);
			
			// {@squirreljme.error BK3i Could not find object referenced at
			// the given pointer. (The requested address)}
			SpringObject rv = (ref != null ? ref.get() : null);
			if (rv == null)
				throw new SpringVirtualMachineException(
					String.format("BK3i @%08x", __p));
			
			return rv;
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringPrimitiveReference.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This interface represents a base reference.
 *
 * @since 2018/09/23
 */
public abstract class SpringPrimitiveReference
	implements SpringObject
{
	/**
	 * Gets the object from this reference.
	 *
	 * @return The value of the reference.
	 * @since 2018/09/23
	 */
	public abstract SpringObject get();
	
	/**
	 * Sets the reference to the given object.
	 *
	 * @param __o The object to set.
	 * @since 2018/09/23
	 */
	public abstract void set(SpringObject __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK1f Reference types are special and have no
		// monitor.}
		throw new SpringVirtualMachineException("BK1f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringClass type()
	{
		// {@squirreljme.error BK1g Reference types are special and have no
		// class.}
		throw new SpringVirtualMachineException("BK1g");
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringPrimitiveWeakReference.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This class stores information for weak references.
 *
 * @since 2018/09/23
 */
public final class SpringPrimitiveWeakReference
	extends SpringPrimitiveReference
{
	/** The reference used. */
	private Reference<SpringObject> _ref;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringObject get()
	{
		Reference<SpringObject> ref = this._ref;
		if (ref != null)
			return ref.get();
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final void set(SpringObject __o)
	{
		this._ref = new WeakReference<>(__o);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringSimpleObject.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is a representation of an object within the virtual machine.
 *
 * @since 2018/09/08
 */
public final class SpringSimpleObject
	implements SpringObject
{
	/** The type of object this is. */
	protected final SpringClass type;
	
	/** The monitor for this object, every object has one. */
	protected final SpringMonitor monitor =
		new SpringMonitor();
	
	/** The pointer for this object. */
	protected final SpringPointerArea pointer;
	
	/** Field storage in the class. */
	private final SpringFieldStorage[] _fields;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the object.
	 *
	 * @param __cl The class of the object.
	 * @param __spm The manager for pointers.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public SpringSimpleObject(SpringClass __cl, SpringPointerManager __spm)
		throws NullPointerException
	{
		if (__cl == null || __spm == null)
			throw new NullPointerException("NARG");
		
		this.type = __cl;
		
		// Setup field array
		int n;
		SpringFieldStorage[] fields;
		this._fields = (fields =
			new SpringFieldStorage[(n = __cl.instanceFieldCount())]);
		
		// Initialize variable for all fields
		int i = 0;
		for (SpringField f : __cl.fieldTable())
			fields[i++] = new SpringFieldStorage(f);
		
		// Allocate pointer
		this.pointer = __spm.allocateAndBind(__cl.instancesize, this);
	}
	
	/**
	 * Returns the field by the given field.
	 *
	 * @param __f The field to get.
	 * @return The storage for the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public final SpringFieldStorage fieldByField(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return this.fieldByIndex(__f.index());
	}
	
	/**
	 * Returns the field by the given index.
	 *
	 * @param __dx The field to get.
	 * @return The storage for the field by the specified index.
	 * @since 2018/09/16
	 */
	public final SpringFieldStorage fieldByIndex(int __dx)
	{
		return this._fields[__dx];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		return this.monitor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		return this.pointer;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s@%08x", this.type.name(), System.identityHashCode(this))));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final SpringClass type()
	{
		return this.type;
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * Represents the top of a long or double.
 *
 * @since 2018/09/09
 */
public final class SpringStackTop
{
	/** The top element representation. */
	public static final SpringStackTop TOP =
		new SpringStackTop();
	
	/**
	 * Internally used.
	 *
	 * @since 2018/09/09
	 */
	private SpringStackTop()
	{
	}
}

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

package cc.squirreljme.vm.springcoat;

/**
 * This represents a task which can be run.
 *
 * @since 2018/11/04
 */
public final class SpringTask
	implements Runnable
{
	/** The machine for this task. */
	protected final SpringMachine machine;
	
	/** The ID. */
	protected final int tid;
	
	/** Exit code. */
	volatile int _exitcode =
		Integer.MIN_VALUE;
	
	/** Is this terminated? */
	volatile boolean _isterminated;
	
	/**
	 * Initializes the task.
	 *
	 * @param __tid The task ID.
	 * @param __m The machine.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public SpringTask(int __tid, SpringMachine __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.machine = __m;
		this.tid = __tid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public final void run()
	{
		this._exitcode = this.machine.runVm();
		this._isterminated = true;
		
		// Debug
		todo.DEBUG.note("Task is terminated!");
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringTaskManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.TaskAccess;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.swm.TaskStatus;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This class manages tasks within SpringCoat and is used to launch and
 * provide access to those that are running.
 *
 * @since 2018/11/04
 */
public final class SpringTaskManager
{
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** The profiling information. */
	protected final ProfilerSnapshot profiler;
	
	/** Tasks that are used. */
	private final Map<Integer, SpringTask> _tasks =
		new HashMap<>();
	
	/** System properties. */
	private final Map<String, String> _sysprops;
	
	/** Next task ID. */
	private int _nextid;
	
	/**
	 * Initializes the task manager.
	 *
	 * @param __sm The suite manager.
	 * @param __ps The snapshot for profiling.
	 * @param __sp System properties.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public SpringTaskManager(VMSuiteManager __sm, ProfilerSnapshot __ps,
		Map<String, String> __sp)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.profiler = (__ps == null ? new ProfilerSnapshot() : __ps);
		this._sysprops = (__sp == null ? new HashMap<String, String>() :
			new HashMap<>(__sp));
	}
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The class path to use.
	 * @param __entry The entry point.
	 * @param __args Arguments used.
	 * @param __gd The current guest depth.
	 * @return The ID of the created task.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public final int startTask(String[] __cp, String __entry, String[] __args,
		int __gd)
		throws NullPointerException
	{
		if (__cp == null || __entry == null || __args == null)
			throw new NullPointerException("NARG");
		
		VMSuiteManager suites = this.suites;
		
		// Load classpath libraries
		int cpn = __cp.length;
		VMClassLibrary[] scl = new VMClassLibrary[cpn];
		for (int i = 0; i < cpn; i++)
		{
			VMClassLibrary lib = suites.loadLibrary(__cp[i]);
			
			// If missing, cannot continue
			if (lib == null)
			{
				todo.DEBUG.note("Could not find library: `%s`", __cp[i]);
				return TaskAccess.ERROR_MISSING_LIBRARY;
			}
			
			scl[i] = lib;
		}
		
		// Get the boot library since we need to look at the entry points
		VMClassLibrary boot = scl[cpn - 1];
		
		// Need to load the manifest where the entry points will be
		EntryPoints entries;
		try (InputStream in = boot.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// {@squirreljme.error BK1h Entry point JAR has no manifest.}
			if (in == null)
				throw new SpringVirtualMachineException("BK1h");
			
			entries = new EntryPoints(new JavaManifest(in));
		}
		
		// {@squirreljme.error BK1i Failed to read the manifest.}
		catch (IOException e)
		{
			throw new SpringVirtualMachineException("BK1i", e);
		}
		
		// Determine the entry point used
		int bootdx = -1;
		for (int i = 0, n = entries.size(); i < n; i++)
			if (__entry.equals(entries.get(i).entryPoint()))
			{
				bootdx = i;
				break;
			}
		
		// Could not find the boot point
		if (bootdx < 0)
			return TaskAccess.ERROR_INVALID_ENTRY;
		
		// Build machine for the task
		SpringMachine machine = new SpringMachine(suites,
			new SpringClassLoader(scl), this, null,
			false, bootdx, __gd + 1,
			this.profiler, this._sysprops, __args);
		
		// Lock on tasks
		Map<Integer, SpringTask> tasks = this._tasks;
		synchronized (tasks)
		{
			// Next task ID
			int tid = ++this._nextid;
			
			// Setup task in a new thread to run and such
			SpringTask rv = new SpringTask(tid, machine);
			
			// Store task in active set
			tasks.put(tid, rv);
			
			// Start a thread for this task, which is that task's main thread
			new Thread(rv, "MainTask-" + tid + "-" + __entry).start();
			
			// The task ID is our handle
			return tid;
		}
	}
	
	/**
	 * Returns the status for a task.
	 *
	 * @param __tid The task ID.
	 * @return The status.
	 * @since 2018/11/04
	 */
	public final int taskStatus(int __tid)
	{
		// Lock on tasks
		Map<Integer, SpringTask> tasks = this._tasks;
		synchronized (tasks)
		{
			// Must be a valid task
			SpringTask rv = tasks.get(__tid);
			if (rv == null)
				return -1;
			
			// Get the exit code
			int exitcode = rv._exitcode;
			
			// Still running
			if (exitcode == Integer.MIN_VALUE)
				return TaskStatus.RUNNING.ordinal();
			
			// Terminated with success
			else if (exitcode == 0)
				return TaskStatus.EXITED_REGULAR.ordinal();
			
			// Terminate with something else
			else
				return TaskStatus.EXITED_FATAL.ordinal();
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.SystemCallIndex;
import java.io.PrintStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ByteCode;
import cc.squirreljme.emulator.profiler.ProfiledThread;

/**
 * This class contains information about a thread within the virtual machine.
 *
 * @since 2018/09/01
 */
public final class SpringThread
{
	/** Maximum depth of the stack. */
	public static final int MAX_STACK_DEPTH =
		64;
	
	/** The thread ID. */
	protected final int id;
	
	/** The name of this thread. */
	protected final String name;
	
	/** Profiler information. */
	protected final ProfiledThread profiler;
	
	/** System call errors. */
	final int[] _syscallerrors =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/** The stack frames. */
	private final List<SpringThread.Frame> _frames =
		new ArrayList<>();
		
	/** String representation. */
	private Reference<String> _string;
	
	/** Ran at least one frame (was started)? */
	private volatile boolean _hadoneframe;
	
	/** Is this a daemon thread? */
	volatile boolean _daemon;
	
	/** Terminate the thread? */
	volatile boolean _terminate;
	
	/** Did we signal exit? */
	volatile boolean _signaledexit;
	
	/** The current worker for the thread. */
	volatile SpringThreadWorker _worker;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __id The thread ID.
	 * @param __n The name of the thread.
	 * @param __profiler Profiled storage.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	SpringThread(int __id, String __n, ProfiledThread __profiler)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.id = __id;
		this.name = __n;
		this.profiler = __profiler;
	}
	
	/**
	 * Returns the current frame of execution or {@code null} if there is none.
	 *
	 * @return The current frame of execution or {@code null} if there is none.
	 * @since 2018/09/03
	 */
	public final SpringThread.Frame currentFrame()
	{
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			if (frames.isEmpty())
				return null;
			return frames.get(frames.size() - 1);
		}
	}
	
	/**
	 * Enters a blank frame to store data.
	 *
	 * @return The
	 * @since 2018/09/20
	 */
	public final SpringThread.Frame enterBlankFrame()
	{
		// Setup blank frame
		SpringThread.Frame rv = new SpringThread.Frame();
		
		// {@squirreljme.error BK1j Stack overflow.}
		List<SpringThread.Frame> frames = this._frames;
		if (frames.size() >= SpringThread.MAX_STACK_DEPTH)
			throw new SpringVirtualMachineException("BK1j");
		
		// Lock on frames as a new one is added
		synchronized (frames)
		{
			frames.add(rv);
		}
		
		// Profile for this frame
		this.profiler.enterFrame("<blank>", "<blank>", "()V",
			System.nanoTime());
		
		// Had one frame (started)
		this._hadoneframe = true;
		
		// Undo termination
		this._terminate = false;
		
		return rv;
	}
	
	/**
	 * Enters the specified method and sets up a stack frame for it.
	 *
	 * @param __m The method to enter.
	 * @param __args Arguments to the frame entry (method arguments).
	 * @return The used stack frame.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringVirtualMachineException If the method is abstract.
	 * @since 2018/09/03
	 */
	public final SpringThread.Frame enterFrame(SpringMethod __m,
		Object... __args)
		throws NullPointerException, SpringVirtualMachineException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		if (__args == null)
			__args = new Object[0];
		
		// Debug
		/*todo.DEBUG.note("enterFrame(%s::%s, %s)", __m.inClass(),
			__m.nameAndType(), Arrays.<Object>asList(__args));*/
		
		// {@squirreljme.error BK1k Cannot enter the frame for a method which
		// is abstract. (The class the method is in; The method name and type)}
		if (__m.isAbstract())
			throw new SpringVirtualMachineException(String.format("BK1k %s %s",
				__m.inClass(), __m.nameAndType()));
		
		// Create new frame
		Frame rv = new Frame(__m, __args);
		
		// Profile for this frame
		this.profiler.enterFrame(__m.inClass().toString(),
			__m.nameAndType().name().toString(),
			__m.nameAndType().type().toString(), System.nanoTime());
		
		// Lock on frames as a new one is added
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			frames.add(rv);
		}
		
		// Had one frame (started)
		this._hadoneframe = true;
		
		// Undo termination
		this._terminate = false;
		
		// Handle synchronized method
		if (__m.flags().isSynchronized())
		{
			SpringObject monitor;
			
			// Monitor on the class object, needs the worker since we need to
			// load a class
			if (__m.flags().isStatic())
			{
				// {@squirreljme.error BK1l Cannot enter a synchronized static
				// method without a thread working, since we need to load
				// the class object.}
				SpringThreadWorker worker = this._worker;
				if (worker == null)
					throw new SpringVirtualMachineException("BK1l");
				
				// Use the class object
				monitor = (SpringObject)worker.asVMObject(__m.inClass(), true);
			}
			
			// On this object
			else
			{
				// {@squirreljme.error BK1m Cannot enter a synchronized
				// instance method with no arguments passed.}
				if (__args.length <= 0)
					throw new SpringVirtualMachineException("BK1m");
				
				// {@squirreljme.error BK1n Cannot enter a monitor of nothing
				// or a non-object.}
				Object argzero = __args[0];
				if (!(argzero instanceof cc.squirreljme.vm.springcoat.SpringObject))
					throw new SpringVirtualMachineException("BK1n");
				
				// Use this as the monitor
				monitor = (SpringObject)argzero;
			}
			
			// Set to unlock later on
			rv._monitor = monitor;
			
			// Enter the monitor and just wait around
			monitor.monitor().enter(this);
		}
		
		return rv;
	}
	
	/**
	 * Exits all frames in the stack.
	 *
	 * @since 2018/11/17
	 */
	public final void exitAllFrames()
	{
		// Lock on frames as a new one is added
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			frames.clear();
		}
	}
	
	/**
	 * Returns all of the frames which are available.
	 *
	 * @return All of the available stack frames.
	 * @since 2018/09/16
	 */
	public final SpringThread.Frame[] frames()
	{
		// Lock on frames
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			return frames.<SpringThread.Frame>toArray(
				new SpringThread.Frame[frames.size()]);
		}
	}
	
	/**
	 * Is exiting the virtual machine okay?
	 *
	 * @return If it is okay to exit.
	 * @since 2018/11/17
	 */
	public final boolean isExitOkay()
	{
		return this._daemon || this._terminate;
	}
	
	/**
	 * Returns the name of the thread.
	 *
	 * @return The name of the thread.
	 * @since 2018/09/03
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Returns the number of frames that are available in this thread.
	 *
	 * @return The number of available frames.
	 * @since 2018/09/03
	 */
	public final int numFrames()
	{
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			return frames.size();
		}
	}
	
	/**
	 * Pops a frame from the thread stack.
	 *
	 * @return The frame which was popped.
	 * @throws SpringVirtualMachineException If there are no stack frames.
	 * @since 2018/09/09
	 */
	public final SpringThread.Frame popFrame()
		throws SpringVirtualMachineException
	{
		// Exit the frame
		this.profiler.exitFrame(System.nanoTime());
		
		// Pop from the stack
		SpringThread.Frame rv;
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			// {@squirreljme.error BK1o No frames to pop.}
			int n;
			if ((n = frames.size()) <= 0)
				throw new SpringVirtualMachineException("BK1o");	
			
			rv = frames.remove(n - 1);
		}
		
		// If there is a monitor associated with this then leave it
		SpringObject monitor = rv._monitor;
		if (monitor != null)
			monitor.monitor().exit(this, true);
		
		return rv;
	}
	
	/**
	 * Prints this thread's stack trace.
	 *
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public final void printStackTrace(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Note the thread
		__ps.printf("Thread #%d: %s%n", this.id, this.name);
		
		// Lock since the frames may change!
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			// The frames at the end are at the top
			for (int n = frames.size(), i = n - 1; i >= 0; i--)
			{
				SpringThread.Frame frame = frames.get(i);
				
				// Do not print traces for blank frames
				if (frame.isBlank())
				{
					__ps.printf("    at <guard frame>%n");
					continue;
				}
				
				SpringMethod inmethod = frame.method();
				int pc = frame.lastExecutedPc();
				
				// Print information
				__ps.printf("    at %s.%s @ %d [%s] (%s:%d)%n",
					inmethod.inClass(),
					inmethod.nameAndType(),
					pc,
					inmethod.byteCode().getByAddress(pc).mnemonic(),
					inmethod.inFile(),
					inmethod.byteCode().lineOfAddress(pc));
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Thread-%d: %s", this.id, this.name)));
		
		return rv;
	}
	
	/**
	 * This class represents the stack frame and is used to store local
	 * variables and other such things.
	 *
	 * @since 2018/09/03
	 */
	public static class Frame
	{
		/** The current method in this frame. */
		protected final SpringMethod method;
		
		/** The method code for execution. */
		protected final ByteCode code;
		
		/** The current object of the current frame. */
		protected final SpringObject thisobject;
		
		/** Is this frame blank? */
		protected final boolean isblank;
		
		/** Local variables. */
		private final Object[] _locals;
		
		/** The stack. */
		private final Object[] _stack;
		
		/** The top of the stack. */
		private volatile int _stacktop;
		
		/** The current program counter. */
		private volatile int _pc;
		
		/** Last executed PC address. */
		private volatile int _lastexecpc;
		
		/** Frame execution count. */
		private volatile int _execcount;
		
		/** Exception which was tossed into this frame. */
		private SpringObject _tossedexception;
		
		/** Object which has a monitor for quicker unlock. */
		private volatile SpringObject _monitor;
		
		/**
		 * Initializes a blank guard frame.
		 *
		 * @since 2018/09/20
		 */
		private Frame()
		{
			this.method = null;
			this.code = null;
			this.thisobject = null;
			this.isblank = true;
			this._locals = new Object[0];
			this._stack = new Object[2];
		}
		
		/**
		 * Initializes the frame.
		 *
		 * @param __m The method used for the frame.
		 * @param __args The frame arguments.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/03
		 */
		private Frame(SpringMethod __m, Object... __args)
			throws NullPointerException
		{
			if (__m == null)
				throw new NullPointerException("NARG");
			
			__args = (__args == null ? new Object[0] : __args.clone());
			
			this.isblank = false;
			this.method = __m;
			
			// We will need to initialize the local and stack data from the
			// information the byte code gives
			ByteCode code;
			this.code = (code = __m.byteCode());
			
			// Initialize variable storage
			Object[] locals;
			this._locals = (locals = new Object[code.maxLocals()]);
			this._stack = new Object[code.maxStack()];
			
			// Copy arguments passed to the method
			for (int i = 0, n = __args.length, o = 0; i < n; i++)
			{
				Object av;
				locals[o++] = (av = __args[i]);
				
				// Add additional top for long/double
				if (av instanceof Long || av instanceof Double)
					locals[o++] = SpringStackTop.TOP;
			}
			
			// Store the this object, if needed
			this.thisobject = (__m.flags().isStatic() ? null :
				(SpringObject)__args[0]);
			
			// Debug
			/*todo.DEBUG.note("Frame has %d locals, %d stack", locals.length,
				this._stack.length);*/
		}
		
		/**
		 * Returns the byte code to execute.
		 *
		 * @return The byte code to execute.
		 * @since 2018/09/03
		 */
		public final ByteCode byteCode()
		{
			return this.code;
		}
		
		/**
		 * Clears the stack.
		 *
		 * @since 2018/10/13
		 */
		public final void clearStack()
		{
			this._stacktop = 0;
		}
		
		/**
		 * Increments the execution counter for this frame.
		 *
		 * @return The original execution count.
		 * @since 2018/10/12
		 */
		public final int incrementExecCount()
		{
			return this._execcount++;
		}
		
		/**
		 * Is this a blank frame?
		 *
		 * @return If this is a blank frame.
		 * @since 2018/09/20
		 */
		public final boolean isBlank()
		{
			return this.isblank;
		}
		
		/**
		 * Returns the last executed PC address.
		 *
		 * @return The last executed PC address.
		 * @since 2018/09/20
		 */
		public final int lastExecutedPc()
		{
			return this._lastexecpc;
		}
		
		/**
		 * Returns the source line of the last executed address.
		 *
		 * @return The source line for the last executed address.
		 * @since 2018/09/24
		 */
		public final int lastExecutedPcSourceLine()
		{
			ByteCode code = this.code;
			if (code == null)
				return -1;
			return code.lineOfAddress(this._lastexecpc);
		}
		
		/**
		 * Loads a value from local variables.
		 *
		 * @param <C> The type to return.
		 * @param __cl The type to return.
		 * @param __dx The index to load from.
		 * @return The read value.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/16
		 */
		public final <C> C loadLocal(Class<C> __cl, int __dx)
			throws NullPointerException
		{
			return __cl.cast(this._locals[__dx]);
		}
		
		/**
		 * Loads the specified value from a local variable and pushes it to
		 * the stack.
		 *
		 * @param __cl The expected class type.
		 * @param __dx The index to load from.
		 * @since 2018/09/08
		 */
		public final void loadToStack(Class<?> __cl, int __dx)
		{
			Object[] locals = this._locals;
			
			// {@squirreljme.error BK1p Cannot push local variable to the stack
			// because it of the incorrect type. (The varible to push; The
			// index to load from; The expected class; The value to push;
			// The type of value to push)}
			Object pushy = locals[__dx];
			if (!__cl.isInstance(pushy))
				throw new SpringVirtualMachineException(String.format(
					"BK1p %s %d %s %s %s", pushy, __dx, __cl, pushy,
					(pushy == null ? "null" : pushy.getClass())));
			
			// Just copy to the stack
			this.pushToStack(pushy);
		}
		
		/**
		 * Returns the method that this frame represents.
		 *
		 * @return The current method the frame is in.
		 * @since 2018/09/08
		 */
		public final SpringMethod method()
		{
			return this.method;
		}
		
		/**
		 * Returns the instruction counter.
		 *
		 * @return The instruction counter.
		 * @since 2018/09/03
		 */
		public final int pc()
		{
			return this._pc;
		}
		
		/**
		 * Returns the line of code the program counter is on.
		 *
		 * @return The program counter line of code.
		 * @since 2018/09/16
		 */
		public final int pcSourceLine()
		{
			return this.code.lineOfAddress(this._pc);
		}
		
		/**
		 * Pops from the stack.
		 *
		 * @return The popped value.
		 * @throws SpringVirtualMachineException If the stack underflows.
		 * @since 2018/09/09
		 */
		public final Object popFromStack()
			throws SpringVirtualMachineException
		{
			Object[] stack = this._stack;
			int stacktop = this._stacktop;
			
			// {@squirreljme.error BK1q Stack underflow. (The current top of
			// the stack; The stack limit)}
			if (stacktop <= 0)
				throw new SpringVirtualMachineException(String.format(
					"BK1q %d %d", stacktop, stack.length));
			
			// Read value and clear the value that was there
			Object rv = stack[--stacktop];
			stack[stacktop] = null;
			this._stacktop = stacktop;
			
			// {@squirreljme.error BK1r Popped a null value of the stack, which
			// should not occur.}
			if (rv == null)
				throw new SpringVirtualMachineException("BK1r");
			
			// Is top, so pop again to read the actual desired value
			if (rv == SpringStackTop.TOP)
			{
				rv = this.popFromStack();
				
				// {@squirreljme.error BK1s Expected long or double below
				// top entry in stack. (The current top of the stack; The
				// stack limit)}
				if (!(rv instanceof Long || rv instanceof Double))
					throw new SpringVirtualMachineException(String.format(
						"BK1s %d %d", stacktop, stack.length));
			}
			
			// Debug
			/*todo.DEBUG.note("popped(%s) <- %d", rv, stacktop);*/
			
			return rv;
		}
		
		/**
		 * Pops from the stack, checking the type.
		 *
		 * @param <C> The type to pop.
		 * @param __cl The type to pop.
		 * @return The popped data.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringVirtualMachineException If the type does not match or
		 * the stack underflows.
		 * @since 2018/09/15
		 */
		public final <C> C popFromStack(Class<C> __cl)
			throws NullPointerException, SpringVirtualMachineException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error BK1t Popped the wrong kind of value from the
			// stack. (The popped type; The expected type)}
			Object rv = this.popFromStack();
			if (!__cl.isInstance(rv))
				throw new SpringVirtualMachineException(
					String.format("BK1t %s %s",
						(rv == null ? null : rv.getClass()), __cl));
			
			return __cl.cast(rv);
		}
		
		/**
		 * Pops the given class from the stack and throws an exception if it
		 * is null.
		 *
		 * @param <C> The type to pop.
		 * @param __cl The type to pop.
		 * @return The popped data.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringNullPointerException If the popped item is null.
		 * @throws SpringVirtualMachineException If the type does not match or
		 * the stack underflows.
		 * @since 2018/12/11
		 */
		public final <C> C popFromStackNotNull(Class<C> __cl)
			throws NullPointerException, SpringNullPointerException,
				SpringVirtualMachineException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			// Pop from the stack
			Object rv = this.popFromStack();
			
			// {@squirreljme.error BK1u Did not expect a null value to be
			// popped from the stack.}
			if (rv == SpringNullObject.NULL ||
				(rv instanceof SpringNullObject))
				throw new SpringNullPointerException("BK1u");
			
			// {@squirreljme.error BK1v Popped the wrong kind of value from the
			// stack. (The popped type; The expected type)}
			if (!__cl.isInstance(rv))
				throw new SpringVirtualMachineException(
					String.format("BK1v %s %s",
						(rv == null ? null : rv.getClass()), __cl));
			
			return __cl.cast(rv);
		}
		
		/**
		 * Pushes the specified value to the stack.
		 *
		 * @param __v The value to push.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringVirtualMachineException If the stack overflows or is
		 * not valid.
		 * @since 2018/09/08
		 */
		public final void pushToStack(Object __v)
			throws NullPointerException, SpringVirtualMachineException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			Object[] stack = this._stack;
			int stacktop = this._stacktop;
			
			// Debug
			/*todo.DEBUG.note("push(%s) -> %d", __v, stacktop);*/
			
			// {@squirreljme.error BK1w Stack overflow pushing value. (The
			// value; The current top of the stack; The stack limit)}
			if (stacktop >= stack.length)
				throw new SpringVirtualMachineException(String.format(
					"BK1w %s %d %d", __v, stacktop, stack.length));
			
			// Store
			stack[stacktop++] = __v;
			this._stacktop = stacktop;
			
			// Push an extra top for long and double
			if (__v instanceof Long || __v instanceof Double)
				this.pushToStack(SpringStackTop.TOP);
		}
		
		/**
		 * Sets the last executed PC address.
		 *
		 * @param __pc The last executed PC address.
		 * @since 2018/09/20
		 */
		public final void setLastExecutedPc(int __pc)
		{
			this._lastexecpc = __pc;
		}
		
		/**
		 * Sets the program counter.
		 *
		 * @param __pc The program counter to set.
		 * @since 2018/09/03
		 */
		public final void setPc(int __pc)
		{
			this._pc = __pc;
		}
		
		/**
		 * Stores the specified value at the given local variable index.
		 *
		 * @param __dx The index to store into.
		 * @param __v The value to store.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/15
		 */
		public final void storeLocal(int __dx, Object __v)
			throws NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			this._locals[__dx] = __v;
		}
		
		/**
		 * Returns the {@code this} of the current frame.
		 *
		 * @return The current this,
		 * @since 2018/09/09
		 */
		public final SpringObject thisObject()
		{
			return this.thisobject;
		}
		
		/**
		 * Returns the tossed exception.
		 *
		 * @return The exception being tossed.
		 * @since 2018/10/13
		 */
		public final SpringObject tossedException()
		{
			return this._tossedexception;
		}
		
		/**
		 * Sets the tossed exception for this frame.
		 *
		 * @param __o The exception tossed for this frame.
		 * @since 2018/10/13
		 */
		public final void tossException(SpringObject __o)
		{
			this._tossedexception = __o;
		}
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringThreadWorker.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.CallStackItem;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.asm.ConsoleOutput;
import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import cc.squirreljme.vm.VMClassLibrary;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.ConstantValueClass;
import net.multiphasicapps.classfile.ConstantValueString;
import net.multiphasicapps.classfile.ExceptionHandler;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.IntMatchingJumpTable;
import net.multiphasicapps.classfile.MemberFlags;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.classfile.MethodReference;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * A worker which runs the actual thread code in single-step fashion.
 *
 * @since 2018/09/03
 */
public final class SpringThreadWorker
	extends Thread
{
	/** Number of instructions which can be executed before warning. */
	private static final int _EXECUTION_THRESHOLD =
		200000;
	
	/** The owning machine. */
	protected final SpringMachine machine;
	
	/** The thread being run. */
	protected final SpringThread thread;
	
	/** The thread to signal instead for interrupt. */
	protected final Thread signalinstead;
	
	/** The current step count. */
	private volatile int _stepcount;
	
	/**
	 * Initialize the worker.
	 *
	 * @param __m The executing machine.
	 * @param __t The running thread.
	 * @param __main Is this the main thread? Used for interrupt hacking.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public SpringThreadWorker(SpringMachine __m, SpringThread __t,
		boolean __main)
		throws NullPointerException
	{
		if (__m == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.machine = __m;
		this.thread = __t;
		this.signalinstead = (__main ? Thread.currentThread() : null);
		
		// Set the thread's worker to this
		if (__t._worker == null)
			__t._worker = this;
		
		// {@squirreljme.error BK1x Thread already has a worker associated
		// with it.}
		else
			throw new SpringVirtualMachineException("BK1x");
	}
	
	/**
	 * Allocates the memory needed to store an array of the given class and
	 * of the given length.
	 *
	 * @param __cl The component type.
	 * @param __l The length of the array.
	 * @return The allocated array.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public final SpringArrayObject allocateArray(SpringClass __cl, int __l)
		throws NullPointerException, SpringNegativeArraySizeException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		SpringClass dim = this.resolveClass(__cl.name().addDimensions(1));
		switch (__cl.name().toString())
		{
				// Boolean
			case "boolean":
				return new SpringArrayObjectBoolean(dim, __cl, __l);
			
				// Byte
			case "byte":
				return new SpringArrayObjectByte(dim, __cl, __l);
				
				// Short
			case "short":
				return new SpringArrayObjectShort(dim, __cl, __l);
				
				// Char
			case "char":
				return new SpringArrayObjectChar(dim, __cl, __l);
				
				// Int
			case "int":
				return new SpringArrayObjectInteger(dim, __cl, __l);
				
				// Long
			case "long":
				return new SpringArrayObjectLong(dim, __cl, __l);
				
				// Float
			case "float":
				return new SpringArrayObjectFloat(dim, __cl, __l);
				
				// Float
			case "double":
				return new SpringArrayObjectDouble(dim, __cl, __l);
			
				// Generic array
			default:
				return new SpringArrayObjectGeneric(dim, __cl, __l);
		}
		
	}
	
	/**
	 * Allocates the memory needed to store an object of the given class.
	 *
	 * @param __cl The object to allocate.
	 * @return The allocated instance of the object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringObject allocateObject(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// The called constructor will allocate the space needed to store
		// this object
		return new SpringSimpleObject(__cl, this.machine.pointers);
	}
	
	/**
	 * Converts the specified virtual machine object to a native object.
	 *
	 * @param __in The input object.
	 * @return The resulting native object.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringFatalException If the object cannot be translated.
	 * @since 2018/09/20
	 */
	public final Object asNativeObject(Object __in)
		throws NullPointerException, SpringFatalException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Is null refernece
		else if (__in == SpringNullObject.NULL)
			return null;
		
		// Boxed types remain the same
		else if (__in instanceof Integer || __in instanceof Long ||
			__in instanceof Float || __in instanceof Double)
			return __in;
		
		// Array type
		else if (__in instanceof SpringArrayObject)
		{
			SpringArrayObject sao = (SpringArrayObject)__in;
			
			int len = sao.length();
			
			// Depends on the array type
			SpringClass sscl = sao.type();
			ClassName type = sscl.name();
			switch (type.toString())
			{
					// Char array
				case "[C":
					{
						char[] rv = new char[len];
						
						for (int i = 0; i < len; i++)
							rv[i] = (char)(sao.<Integer>get(Integer.class, i).
								intValue());
						
						return rv;
					}
					
					// String
				case "[Ljava/lang/String;":
					{
						String[] rv = new String[len];
						
						for (int i = 0; i < len; i++)
							rv[i] = this.<String>asNativeObject(String.class,
								sao.<SpringObject>get(SpringObject.class, i));
						
						return rv;
					}
				
					// {@squirreljme.error BK1y Do not know how to convert the
					// given virtual machine array to a native machine array.
					// (The input class)}
				default:
					throw new RuntimeException(
						String.format("BK1y %s", type));
			}
		}
		
		// Class type
		else if (__in instanceof SpringSimpleObject)
		{
			SpringSimpleObject sso = (SpringSimpleObject)__in;
			
			// Depends on the class type
			SpringClass sscl = sso.type();
			ClassName type = sscl.name();
			switch (type.toString())
			{
				case "java/lang/Integer":
					return Integer.valueOf((Integer)
						sso.fieldByField(sscl.lookupField(false,
						"_value", "I")).get());
				
				case "java/lang/String":
					return new String(this.<char[]>asNativeObject(
						char[].class, this.invokeMethod(false,
							new ClassName("java/lang/String"),
							new MethodNameAndType("toCharArray", "()[C"),
							sso)));
				
					// {@squirreljme.error BK1z Do not know how to convert the
					// given virtual machine class to a native machine object.
					// (The input class)}
				default:
					throw new RuntimeException(
						String.format("BK1z %s", type));
			}
		}
		
		// {@squirreljme.error BK20 Do not know how to convert the given class
		// to a native machine object. (The input class)}
		else
			throw new SpringFatalException(
				String.format("BK20 %s", __in.getClass()));
	}
	
	/**
	 * Converts the specified object to a native object or unwraps an array
	 * for direct access.
	 *
	 * @param <C> The resulting class type.
	 * @param __cl The class to cast to.
	 * @param __in The input object.
	 * @return The resulting object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public final <C> C asNativeObjectUnwrapArray(Class<C> __cl, Object __in)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException();
		
		if (__in instanceof SpringArrayObject)
			return __cl.cast(((SpringArrayObject)__in).array());
		return this.<C>asNativeObject(__cl, __in);
	}
	
	/**
	 * Converts the specified virtual machine object to a native object.
	 *
	 * @param <C> The class type.
	 * @param __cl The class type.
	 * @param __in The input object.
	 * @return The resulting native object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public final <C> C asNativeObject(Class<C> __cl, Object __in)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this.asNativeObject(__in));
	}
	
	/**
	 * Converts the specified native object to a virtual machine object.
	 *
	 * @param __in The input object.
	 * @return The resulting VM object.
	 * @since 2018/09/16
	 */
	public final Object asVMObject(Object __in)
	{
		return this.asVMObject(__in, false);
	}
	
	/**
	 * Converts the specified native object to a virtual machine object.
	 *
	 * @param __in The input object.
	 * @param __noclassres Do not use class resolution? Just load the class?
	 * @return The resulting VM object.
	 * @since 2018/09/16
	 */
	public final Object asVMObject(Object __in, boolean __noclassres)
	{
		// Null is converted to null
		if (__in == null)
			return SpringNullObject.NULL;
		
		// As-is
		else if (__in instanceof Integer || __in instanceof Long ||
			__in instanceof Float || __in instanceof Double ||
			__in instanceof SpringObject)
			return __in;
		
		// Boolean to integer
		else if (__in instanceof Boolean)
			return Integer.valueOf((Boolean.TRUE.equals(__in) ? 1 : 0));
		
		// Character to Integer
		else if (__in instanceof Character)
			return Integer.valueOf(((Character)__in).charValue());
		
		// Promoted to integer
		else if (__in instanceof Byte || __in instanceof Short)
			return Integer.valueOf(((Number)__in).intValue());
		
		// Character array
		else if (__in instanceof char[])
		{
			char[] in = (char[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("char")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, (int)in[i]);
			
			return rv;
		}
		
		// Integer array
		else if (__in instanceof int[])
		{
			int[] in = (int[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("int")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, (int)in[i]);
			
			return rv;
		}
		
		// String array
		else if (__in instanceof String[])
		{
			String[] in = (String[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("java/lang/String")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, this.asVMObject(in[i]));
			
			return rv;
		}
		
		// Convertable exception
		else if (__in instanceof SpringConvertableThrowable)
		{
			SpringConvertableThrowable e = (SpringConvertableThrowable)__in;
			
			// Initialize new instance with this type, use the input message
			return this.newInstance(new ClassName(e.targetClass()),
				new MethodDescriptor("(Ljava/lang/String;)V"),
				this.asVMObject(e.getMessage()));
		}
		
		// String object
		else if (__in instanceof String)
		{
			String s = (String)__in;
			
			// Locate the string class
			SpringClass strclass = this.loadClass(
				new ClassName("java/lang/String"));
				
			// Setup an array of characters to represent the string data,
			// this is the simplest thing to do right now
			SpringObject array = (SpringObject)this.asVMObject(
				s.toString().toCharArray());
			
			// Setup string which uses this sequence
			SpringObject rv = this.newInstance(
				new ClassName("java/lang/String"),
				new MethodDescriptor("([CS)V"),
				array, 0);
			
			return rv;
		}
		
		// Constant string from the constant pool, which shared a global pool
		// of string objects! This must be made so that "aaa" == "aaa" is true
		// even across different classes!
		else if (__in instanceof ConstantValueString)
		{
			ConstantValueString cvs = (ConstantValueString)__in;
			
			// Get the string map but lock on the class loader because a class
			// might want a string but then another thread might be
			// initializing some class, and it will just deadlock as they wait
			// on each other
			SpringMachine machine = this.machine;
			Map<ConstantValueString, SpringObject> stringmap =
				machine.__stringMap();
			synchronized (machine.classLoader().classLoadingLock())
			{
				// Pre-cached object already exists?
				SpringObject rv = stringmap.get(cvs);
				if (rv != null)
					return rv;
				
				// Setup an array of characters to represent the string data,
				// this is the simplest thing to do right now
				SpringObject array = (SpringObject)this.asVMObject(
					cvs.toString().toCharArray());
				
				// Setup string which uses this sequence, but it also needs
				// to be interned!
				ClassName strclass = new ClassName("java/lang/String");
				rv = (SpringObject)this.invokeMethod(false, strclass,
					new MethodNameAndType("intern", "()Ljava/lang/String;"),
					this.newInstance(strclass, new MethodDescriptor("([CS)V"),
						array, 0));
				
				// Cache
				stringmap.put(cvs, rv);
				
				// Use it
				return rv;
			}
		}
		
		// A class object, as needed
		else if (__in instanceof ClassName ||
			__in instanceof ConstantValueClass ||
			__in instanceof SpringClass)
		{
			ClassName name = ((__in instanceof SpringClass) ?
				((SpringClass)__in).name() : ((__in instanceof ClassName) ?
				(ClassName)__in : ((ConstantValueClass)__in).className()));
			
			// Get the class object map but lock on the class loader since we
			// might end up just initializing classes and such
			SpringMachine machine = this.machine;
			Map<ClassName, SpringObject> com = machine.__classObjectMap();
			Map<SpringObject, ClassName> ocm = machine.
				__classObjectToNameMap();
			synchronized (machine.classLoader().classLoadingLock())
			{
				// Pre-cached object already exists?
				SpringObject rv = com.get(name);
				if (rv != null)
					return rv;
				
				// Resolve the input class, so it is initialized
				SpringClass resclass = (__noclassres ? this.loadClass(name) :
					this.resolveClass(name));
				
				// Resolve the class object
				SpringClass classobj = this.resolveClass(
					new ClassName("java/lang/Class"));
				
				// Copy interfaces into a class array
				SpringClass[] interfaces = resclass.interfaceClasses();
				int ni = interfaces.length;
				SpringArrayObject ints = this.allocateArray(classobj, ni);
				for (int i = 0; i < ni; i++)
					ints.set(i, this.asVMObject(interfaces[i]));
				
				// See if there is a default constructor
				SpringMethod defconmeth = resclass.lookupDefaultConstructor();
				
				// Get static method for this constructor
				int defconflags;
				SpringObject defconsm;
				if (defconmeth != null)
				{
					defconflags = defconmeth.flags().toJavaBits();
					defconsm = new SpringVMStaticMethod(defconmeth);
				}
				
				// There is none
				else
				{
					defconflags = 0;
					defconsm = SpringNullObject.NULL;
				}
				
				// Get the static method for enumeration values
				ClassFlags classflags = resclass.flags();
				SpringObject enumsm;
				if (classflags.isEnum())
					try
					{
						enumsm = new SpringVMStaticMethod(
							resclass.lookupMethod(true,
							new MethodName("values"),
							new MethodDescriptor(name.addDimensions(1).
							field())));
					}
					catch (SpringIncompatibleClassChangeException e)
					{
						enumsm = SpringNullObject.NULL;
					}
				else
					enumsm = SpringNullObject.NULL;
				
				// Initialize V1 class data which is initialized with class
				// data
				SpringObject cdata = this.newInstance(new ClassName(
					"cc/squirreljme/runtime/cldc/lang/ClassDataV1"),
					new MethodDescriptor("(ILjava/lang/String;" +
						"Ljava/lang/Class;[Ljava/lang/Class;" +
						"Ljava/lang/Class;Ljava/lang/String;II" +
						"Lcc/squirreljme/runtime/cldc/asm/StaticMethod;" +
						"Lcc/squirreljme/runtime/cldc/asm/StaticMethod;)V"),
					resclass.specialIndex(),
					this.asVMObject(name.toString(), true),
					this.asVMObject(resclass.superClass(), true),
					ints,
					(!resclass.isArray() ? SpringNullObject.NULL :
						this.asVMObject(resclass.componentType(), true)),
					this.asVMObject(resclass.inJar()),
					classflags.toJavaBits(),
					defconflags, defconsm, enumsm);
				
				// Initialize class with special class index and some class
				// information
				rv = this.newInstance(classobj.name(),
					new MethodDescriptor(
					"(Lcc/squirreljme/runtime/cldc/lang/ClassData;)V"), cdata);
				
				// Cache and use it
				com.put(name, rv);
				ocm.put(rv, name);
				return rv;
			}
		}
		
		// {@squirreljme.error BK21 Do not know how to convert the given class
		// to a virtual machine object. (The input class)}
		else
			throw new RuntimeException(
				String.format("BK21 %s", __in.getClass()));
	}
	
	/**
	 * As VM object, but boxed if a primitive.
	 *
	 * @param __in The object to convert.
	 * @return The converted object.
	 * @since 2018/11/19
	 */
	public final Object asVMObjectBoxed(Object __in)
	{
		// Null is converted to null
		if (__in == null)
			return SpringNullObject.NULL;
		
		// Box these
		else if (__in instanceof Integer)
			return this.newInstance(new ClassName("java/lang/Integer"),
				new MethodDescriptor("(I)V"), __in);
		else if (__in instanceof Long)
			return this.newInstance(new ClassName("java/lang/Long"),
				new MethodDescriptor("(J)V"), __in);
		else if (__in instanceof Float)
			return this.newInstance(new ClassName("java/lang/Float"),
				new MethodDescriptor("(F)V"), __in);
		else if (__in instanceof Double)
			return this.newInstance(new ClassName("java/lang/Double"),
				new MethodDescriptor("(D)V"), __in);
		
		// As-is
		else if (__in instanceof SpringObject)
			return __in;
		
		else
			return this.asVMObject(__in);
	}
	
	/**
	 * As VM object, if it is an array it is wrapped otherwise if the object is
	 * a primitive type it becomes boxed.
	 *
	 * @param __in The object to convert.
	 * @return The converted object.
	 * @since 2018/12/03
	 */
	public final Object asVMObjectBoxedOrWrappedArray(Object __in)
	{
		if (__in == null)
			return SpringNullObject.NULL;
		
		// Array types
		else if (__in instanceof boolean[] ||
			__in instanceof byte[] ||
			__in instanceof short[] ||
			__in instanceof char[] ||
			__in instanceof int[] ||
			__in instanceof long[] ||
			__in instanceof float[] ||
			__in instanceof double[])
			return this.asWrappedArray(__in);
		
		// As boxed type instead
		else
			return this.asVMObjectBoxed(__in);
	}
	
	/**
	 * Wraps the native array so that it is directly read and written in
	 * the VM code.
	 *
	 * @param __a The object to convert.
	 * @return The object representing the array.
	 * @throws RuntimeException If the type is not an array.
	 * @since 2018/11/18
	 */
	public final SpringObject asWrappedArray(Object __a)
		throws RuntimeException
	{
		if (__a == null)
			return SpringNullObject.NULL;
		
		// Boolean
		else if (__a instanceof boolean[])
			return new SpringArrayObjectBoolean(
				this.loadClass(new ClassName("[Z")),
				this.loadClass(new ClassName("boolean")),
				(boolean[])__a);
		
		// Byte
		else if (__a instanceof byte[])
			return new SpringArrayObjectByte(
				this.loadClass(new ClassName("[B")),
				this.loadClass(new ClassName("byte")),
				(byte[])__a);
		
		// Short
		else if (__a instanceof short[])
			return new SpringArrayObjectShort(
				this.loadClass(new ClassName("[S")),
				this.loadClass(new ClassName("short")),
				(short[])__a);
		
		// Character
		else if (__a instanceof char[])
			return new SpringArrayObjectChar(
				this.loadClass(new ClassName("[C")),
				this.loadClass(new ClassName("char")),
				(char[])__a);
		
		// Integer
		else if (__a instanceof int[])
			return new SpringArrayObjectInteger(
				this.loadClass(new ClassName("[I")),
				this.loadClass(new ClassName("int")),
				(int[])__a);
		
		// Long
		else if (__a instanceof long[])
			return new SpringArrayObjectLong(
				this.loadClass(new ClassName("[J")),
				this.loadClass(new ClassName("long")),
				(long[])__a);
		
		// Float
		else if (__a instanceof float[])
			return new SpringArrayObjectFloat(
				this.loadClass(new ClassName("[F")),
				this.loadClass(new ClassName("float")),
				(float[])__a);
		
		// Double
		else if (__a instanceof double[])
			return new SpringArrayObjectDouble(
				this.loadClass(new ClassName("[D")),
				this.loadClass(new ClassName("double")),
				(double[])__a);
		
		// {@squirreljme.error BK22 Cannot wrap this as a native array.
		// (The input class type)}
		else
			throw new RuntimeException("BK22 " + __a.getClass());
	}
	
	/**
	 * Checks if the given class may be accessed.
	 *
	 * @param __cl The class to access.
	 * @return {@code true} if it may be accessed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean checkAccess(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// If the target class is public then we can access it
		ClassFlags targetflags = __cl.flags();
		if (targetflags.isPublic())
			return true;
		
		// Get our current class
		SpringClass self = this.contextClass();
		
		// No current class, treat as always valid
		if (self == null)
			return true;
		
		// Allow object and class unlimited access to anything
		ClassName cn = self.name();
		if (cn.toString().equals("java/lang/Object") ||
			cn.toString().equals("java/lang/Class"))
			return true;
		
		// This is ourself so access is always granted
		else if (__cl == self)
			return true;
		
		// Protected class, we must be a super class
		else if (targetflags.isProtected())
		{
			for (SpringClass r = self; r != null; r = r.superClass())
				if (__cl == r)
					return true;
		}
		
		// Must be in the same package
		else if (targetflags.isPackagePrivate())
		{
			if (self.name().inPackage().equals(__cl.name().inPackage()))
				return true;
		}
		
		// This should not occur
		else
			throw new todo.OOPS();
		
		// No access permitted
		return false;
	}
	
	/**
	 * Checks if the given member can be accessed.
	 *
	 * @param __m The member to check.
	 * @return If the member can be accessed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean checkAccess(SpringMember __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Need the current and the target class to check permissions
		SpringClass self = this.contextClass(),
			target = this.loadClass(__m.inClass());
		
		// No current class, treat as always valid
		if (self == null)
			return true;
		
		// If in the same class all access is permitted
		if (self == target)
			return true;
		
		// Public has full access
		MemberFlags flags = __m.flags();
		if (flags.isPublic())
			return true;
		
		// Protected class, we must be a super class
		else if (flags.isProtected())
		{
			for (SpringClass r = self; r != null; r = r.superClass())
				if (target == r)
					return true;
			
			// Otherwise it has to be in the same package
			if (self.name().inPackage().equals(target.name().inPackage()))
				return true;
		}
		
		// Classes must be in the same package
		else if (flags.isPackagePrivate())
		{
			if (self.name().inPackage().equals(target.name().inPackage()))
				return true;
		}
		
		// Access not permitted
		return false;
	}
	
	/**
	 * Returns the current class context, if any.
	 *
	 * @return The current class context or {@code null} if there is none.
	 * @since 2018/09/09
	 */
	public final SpringClass contextClass()
	{
		SpringThread thread = this.thread;
		SpringThread.Frame[] frames = thread.frames();
		
		// Go through frames
		for (int n = frames.length, i = n - 1; i >= 0; i--)
		{
			SpringThread.Frame frame = frames[i];
			
			// No method, could be a blank frame
			SpringMethod m = frame.method();
			if (m == null)
				continue;
			
			// If this is the assembly classes, treat it as if the caller were
			// doing things rather than the asm classes itself
			ClassName icl = frame.method().inClass();
			if (icl.toString().startsWith("cc/squirreljme/runtime/cldc/asm/"))
				continue;
			
			return this.machine.classLoader().loadClass(icl);
		}
		
		return null;
	}
	
	/**
	 * Invokes the given method.
	 *
	 * @param __static Is the method static?
	 * @param __cl The class name.
	 * @param __nat The name and type.
	 * @param __args The arguments.
	 * @return The return value, if any.
	 * @since 2018/09/20
	 */
	public final Object invokeMethod(boolean __static, ClassName __cl,
		MethodNameAndType __nat, Object... __args)
		throws NullPointerException
	{
		if (__cl == null || __nat == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Lookup class and method for the static method
		SpringClass cl;
		SpringMethod method;
		if (__static)
		{
			cl = this.resolveClass(__cl);
			method = cl.lookupMethod(__static, __nat);
		}
		
		// Call it based on the object instead
		else
		{
			cl = ((SpringObject)__args[0]).type();
			method = cl.lookupMethod(false, __nat);
		} 
		
		// Overflow or exceptions might occur
		int framelimit;
		SpringThread.Frame blank, execframe;
		SpringThread thread = this.thread;
		try
		{
			// Add blank frame for protection, this is used to hold the return
			// value on the stack
			blank = thread.enterBlankFrame();
			
			// Enter the method we really want to execute
			framelimit = thread.numFrames();
			execframe = thread.enterFrame(method, __args);
			
			// Execute this method
			this.run(framelimit);
		}
		
		// Exception when running which was not caught
		catch (SpringVirtualMachineException e)
		{
			// Print the thread trace
			thread.printStackTrace(System.err);
			
			// Propogate up
			throw e;
		}
		
		// This is an error unless the thread signaled exit
		SpringThread.Frame currentframe = thread.currentFrame();
		if (currentframe != blank)
		{
			// If our thread just happened to signal an exit of the VM, then
			// the current frame will be invalid anyway, so since the
			// exception or otherwise might be signaled we must make an
			// exception for exit here so it continues going down.
			if (thread._signaledexit)
				throw new SpringMachineExitException(this.machine._exitcode);
			
			// {@squirreljme.error BK23 Current frame is not our blank frame.}
			throw new SpringVirtualMachineException("BK23");
		}
		
		// Read return value from the blank frame
		Object rv;
		if (__nat.type().hasReturnValue())
			rv = blank.popFromStack();
		else
			rv = null;
		
		// Pop the blank frame, we do not need it anymore
		thread.popFrame();
		
		// Return the popped value
		return rv;
	}
	
	/**
	 * Loads the specified class, potentially performing initialization on it
	 * if it has not been initialized.
	 *
	 * @param __cn The class to load.
	 * @return The loaded class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringClass loadClass(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Use the class loading lock to prevent other threads from loading or
		// initializing classes while this thread does such things
		SpringClassLoader classloader = this.machine.classLoader();
		synchronized (classloader.classLoadingLock())
		{
			// Load the class from the class loader
			return this.loadClass(classloader.loadClass(__cn));
		}
	}
	
	/**
	 * Loads the specified class.
	 *
	 * @param __cl The class to load.
	 * @return {@code __cl}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringClass loadClass(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Use the class loading lock to prevent other threads from loading or
		// initializing classes while this thread does such things
		SpringMachine machine = this.machine;
		SpringClassLoader classloader = machine.classLoader();
		synchronized (classloader.classLoadingLock())
		{
			// If the class has already been initialized then the class is
			// ready to be used
			if (__cl.isInitialized())
				return __cl;
			
			// Debug
			/*todo.DEBUG.note("Need to initialize %s.", __cl.name());*/
			
			// Set the class as initialized early to prevent loops, because
			// a super class might call something from the base class which
			// might be seen as initialized when it should not be. So this is
			// to prevent bad things from happening.
			__cl.setInitialized();
			
			// Initialize the static field map
			Map<SpringField, SpringFieldStorage> sfm =
				machine.__staticFieldMap();
			for (SpringField f : __cl.fieldsOnlyThisClass())
				if (f.isStatic())
					sfm.put(f, new SpringFieldStorage(f));
			
			// Recursively call self to load the super class before this class
			// is handled
			SpringClass clsuper = __cl.superClass();
			if (clsuper != null)
				this.loadClass(clsuper);
			
			// Go through interfaces and do the same
			for (SpringClass iface : __cl.interfaceClasses())
				this.loadClass(iface);
			
			// Look for static constructor for this class to initialize it as
			// needed
			SpringMethod init;
			try
			{
				init = __cl.lookupMethod(true,
					new MethodNameAndType("<clinit>", "()V"));
			}
			
			// No static initializer exists
			catch (SpringNoSuchMethodException e)
			{
				init = null;
				
				// Debug
				/*todo.DEBUG.note("Class %s has no static initializer.",
					__cl.name());*/
			}
			
			// Static initializer exists, setup a frame and call it
			if (init != null)
			{
				// Stop execution when the initializer exits
				SpringThread thread = this.thread;
				int framelimit = thread.numFrames();
				
				// Enter the static initializer
				thread.enterFrame(init);
				
				// Execute until it finishes
				this.run(framelimit);
			}
		}
		
		// Return the input class
		return __cl;
	}
	
	/**
	 * Handles a native action within the VM.
	 *
	 * Note that the return value should be a native type, it is translated
	 * as needed.
	 *
	 * @param __func The function to call.
	 * @param __args The arguments to the function.
	 * @return The result from the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final Object nativeMethod(String __func, Object... __args)
		throws NullPointerException
	{
		if (__func == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Call native %s", __func);*/
		
		// Depends on the function
		switch (__func)
		{
				// Return the length of the array
			case "cc/squirreljme/jvm/Assembly::" +
				"arrayLength:(Ljava/lang/Object;)I":
				return ((SpringArrayObject)__args[0]).length();
				
				// Pack double together
			case "cc/squirreljme/jvm/Assembly::" +
				"doublePack:(II)D":
				return Double.longBitsToDouble(
					((((Integer)__args[0]).longValue() << 32L) |
					((((Integer)__args[1]).longValue()) & 0xFFFFFFFFL)));
				
				// Gets the raw bits for the given double value
			case "cc/squirreljme/jvm/Assembly::" +
				"doubleToRawLongBits:(D)J":
				return Double.doubleToRawLongBits((Double)__args[0]);
				
				// Float to raw int bits
			case "cc/squirreljme/jvm/Assembly::" +
				"floatToRawIntBits:(F)I":
				return Float.floatToRawIntBits((Float)__args[0]);
				
				// Int bits to float
			case "cc/squirreljme/jvm/Assembly::" +
				"intBitsToFloat:(I)F":
				return Float.intBitsToFloat((Integer)__args[0]);
				
				// Convert long bits to double
			case "cc/squirreljme/jvm/Assembly::" +
				"longBitsToDouble:(J)D":
				return Double.longBitsToDouble((Long)__args[0]);
				
				// Pack long together
			case "cc/squirreljme/jvm/Assembly::" +
				"longPack:(II)J":
				return ((((Integer)__args[0]).longValue() << 32L) |
					((((Integer)__args[1]).longValue()) & 0xFFFFFFFFL));
				
				// Unpack high long
			case "cc/squirreljme/jvm/Assembly::" +
				"longUnpackHigh:(L)I":
				return (int)((((Long)__args[0]).longValue()) >>> 32L);
				
				// Unpack low long
			case "cc/squirreljme/jvm/Assembly::" +
				"longUnpackLow:(L)I":
				return (int)(((Long)__args[0]).longValue());
				
				// Object to pointer
			case "cc/squirreljme/jvm/Assembly::" +
				"objectToPointer:(Ljava/lang/Object;)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"objectToPointerRefQueue:(Ljava/lang/Object;)I":
				return this.uniqueObjectToPointer((SpringObject)__args[0]);
				
				// Pointer to object
			case "cc/squirreljme/jvm/Assembly::" +
				"pointerToObject:(I)Ljava/lang/Object;":
				return this.uniquePointerToObject((Integer)__args[0]);
				
				// System calls (no return value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(S)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SI)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(S)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SI)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIIIII)V":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					this.systemCall((short)si, ta);
					return null;
				}
				
				// System calls (returns value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(S)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SI)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(S)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SI)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIIIII)I":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					return (int)this.systemCall((short)si, ta);
				}
				
				// System calls (returns long value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(S)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SI)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(S)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SI)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIIIII)J":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					return (long)this.systemCall((short)si, ta);
				}
			
				// Read console buffer
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"displayRead:([I[BII)I":
				return 0;
				
				// Flush the console
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"flush:(I)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Flush if valid
					if (to != null)
					{
						to.flush();
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
			
				// Write to the console
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"write:(II)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Write if it exists
					if (to != null)
					{
						to.write((Integer)__args[1]);
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
				
				// Write to the console (bulk)
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"write:(I[BII)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Write if it exists
					if (to != null)
					{
						to.write(
							(byte[])((SpringArrayObjectByte)__args[1]).array(),
							(Integer)__args[2],
							(Integer)__args[3]);
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
				
				// Allocate object but do not construct it
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"allocateObject:(Ljava/lang/String;)Ljava/lang/Object;":
				return this.allocateObject(this.loadClass(
					new ClassName(this.<String>asNativeObject(
					String.class, ((SpringObject)__args[0])))));
			
				// Allocate array of a given class
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"arrayNew:(Ljava/lang/Class;I)Ljava/lang/Object;":
				{
					// Cannot do a reverse lookup
					SpringMachine machine = this.machine;
					Map<SpringObject, ClassName> ocm = machine.
						__classObjectToNameMap();
					synchronized (machine.classLoader().classLoadingLock())
					{
						// {@squirreljme.error BK24 Could not reverse class
						// object to class name.}
						ClassName cn = ocm.get((SpringObject)__args[0]);
						if (cn == null)
							throw new SpringVirtualMachineException("BK24");
						
						// Lookup class for the component type, we need it
						SpringClass cl = this.loadClass(cn.componentType());
						
						// Allocate array for the component type
						return this.allocateArray(cl,
							(Integer)__args[1]);
					}
				}
			
				// Get the class by the name of whatever is input
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classByName:(Ljava/lang/String;)Ljava/lang/Class;":
				try
				{
					return this.asVMObject(new ClassName(
						this.<String>asNativeObject(String.class,
						(SpringObject)__args[0])), true);
				}
				catch (SpringClassNotFoundException e)
				{
					return this.asVMObject(null);
				}
				
				// Returns the class data for a class object
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classData:(Ljava/lang/Class;)Lcc/squirreljme/" +
				"runtime/cldc/lang/ClassData;":
				return this.invokeMethod(false,
					new ClassName("java/lang/Class"),
					new MethodNameAndType("__classData",
					"()Lcc/squirreljme/runtime/cldc/lang/ClassData;"),
					(SpringObject)__args[0]);
				
				// Get the class object for an object
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classOf:(Ljava/lang/Object;)Ljava/lang/Class;":
				{
					// Just use the input class of the type
					SpringObject so = (SpringObject)__args[0];
					return so.type();
				}
				
				// Check if thread holds the given lock
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"holdsLock:(ILjava/lang/Object;)Z":
				{
					SpringThread owner =
						((SpringObject)__args[1]).monitor()._owner;
					return (owner == null ? false :
						((Integer)__args[0]).intValue() == owner.id);
				}
				
				// Identity hash code
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"identityHashCode:(Ljava/lang/Object;)I":
				return System.identityHashCode(((SpringObject)__args[0]));
				
				// Invoke static method
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"invokeStatic:(Lcc/squirreljme/runtime/cldc/asm/" +
				"StaticMethod;[Ljava/lang/Object;)Ljava/lang/Object;":
				{
					// We will need this to pass object arguments
					SpringArrayObject vargs = (SpringArrayObject)__args[1];
					
					// Copy object values
					int n = vargs.length();
					Object[] xargs = new Object[n];
					for (int i = 0; i < n; i++)
						xargs[i] = vargs.get(Object.class, i);
					
					// The method to execute
					SpringMethod m = ((SpringVMStaticMethod)__args[0]).method;
					
					// Enter the frame for this method
					this.thread.enterFrame(m, xargs);
					
					// If the method has no return value, just push a null to
					// the stack
					if (!m.nameAndType().type().hasReturnValue())
						return SpringNullObject.NULL;
					
					// No return value, sort of
					return null;
				}
				
				// Monitor notify
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"monitorNotify:(Ljava/lang/Object;Z)I":
				return ((SpringObject)__args[0]).monitor().
					monitorNotify(this.thread,
					((Integer)__args[1]).intValue() != 0);
			
				// Monitor notify
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"monitorWait:(Ljava/lang/Object;JI)I":
				return ((SpringObject)__args[0]).monitor().
					monitorWait(this.thread, (Long)__args[1],
						(Integer)__args[2]);
				
				// Create new primitive weak reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"newWeakReference:" +
				"()Lcc/squirreljme/runtime/cldc/ref/PrimitiveReference;":
				{
					return new SpringPrimitiveWeakReference();
				}
				
				// Get reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"referenceGet:(Lcc/squirreljme/runtime/cldc/ref/" +
				"PrimitiveReference;)Ljava/lang/Object;":
				return ((SpringPrimitiveReference)__args[0]).get();
				
				// Set reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"referenceSet:(Lcc/squirreljme/runtime/cldc/ref/" +
				"PrimitiveReference;Ljava/lang/Object;)V":
				((SpringPrimitiveReference)__args[0]).set(
					(SpringObject)__args[1]);
				return null;
				
				// Returns the number of bytes available in the resource.
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"available:(I)I":
				return this.machine.resourceAccess().available(
					(Integer)__args[0]);
				
				// Close resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"close:(I)I":
				return this.machine.resourceAccess().close(
					(Integer)__args[0]);
				
				// Open resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"open:(Ljava/lang/String;Ljava/lang/String;)I":
				return this.machine.resourceAccess().open(
					this.<String>asNativeObject(String.class, __args[0]),
					this.<String>asNativeObject(String.class, __args[1]));
				
				// Read resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"read:(I[BII)I":
				return this.machine.resourceAccess().read(
					(Integer)__args[0],
					(byte[])((SpringArrayObjectByte)__args[1]).array(),
					(Integer)__args[2],
					(Integer)__args[3]);
			
				// List suites that are available
			case "cc/squirreljme/runtime/cldc/asm/SuiteAccess::" +
				"availableSuites:()[Ljava/lang/String;":
				return this.machine.suiteManager().listLibraryNames();
			
				// List current class path
			case "cc/squirreljme/runtime/cldc/asm/SuiteAccess::" +
				"currentClassPath:()[Ljava/lang/String;":
				{
					VMClassLibrary[] vp = this.machine.classloader.classPath();
					int n = vp.length;
					String[] rv = new String[n];
					for (int i = 0; i < n; i++)
						rv[i] = vp[i].name();
					return this.asVMObject(rv);
				}
				
				// Get environment variable
			case "cc/squirreljme/runtime/cldc/asm/SystemAccess::" +
				"getEnv:(Ljava/lang/String;)Ljava/lang/String;":
				return this.asVMObject(SystemAccess.getEnv(
					this.<String>asNativeObject(String.class, __args[0])));
			
				// Approximated executable path
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"executablePath:()Ljava/lang/String;":
				// Just use the one of the host VM, if it is known anyway
				return this.asVMObject(SystemProperties.executablePath());
				
				// The guest depth of this virtual machine
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"guestDepth:()I":
				return this.machine.guestdepth;
				
				// The class to use for an implementation of something, by
				// default
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"implementationClass:(Ljava/lang/String;)Ljava/lang/String;":
				return SpringNullObject.NULL;
				
				// VM e-mail
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMEmail:()Ljava/lang/String;":
				return "xerthesquirrel@gmail.com";
				
				// VM name
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMName:()Ljava/lang/String;":
				return "SquirrelJME SpringCoat";
				
				// VM URL
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMURL:()Ljava/lang/String;":
				return "http://squirreljme.cc/";
				
				// VM vendor
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMVendor:()Ljava/lang/String;":
				return "Stephanie Gawroriski";
				
				// VM Version
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMVersion:()Ljava/lang/String;":
				return "0.2.0";
				
				// Get the operating system type
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"operatingSystemType:()I":
				return OperatingSystemType.UNKNOWN;
				
				// Get system property
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"systemProperty:(Ljava/lang/String;)Ljava/lang/String;":
				String pk = this.<String>asNativeObject(String.class,
					__args[0]),
					pv = this.machine._sysproperties.get(pk);
				if (pv != null)
					return pv;
				return System.getProperty(pk);
				
				// Current thread ID
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"currentThread:()I":
				return this.thread.id;
				
				// Set thread priority
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"setThreadPriority:(II)V":
				{
					SpringThread st = this.machine.getThread(
						(Integer)__args[0]);
					if (st != null)
					{
						SpringThreadWorker stw = st._worker;
						if (stw != null)
						{
							Thread signal = stw.signalinstead;
							if (signal != null)
								signal.setPriority((Integer)__args[1]);
							else
								stw.setPriority((Integer)__args[1]);
						}
					}
					
					return null;
				}
				
				// Interrupt the given thread
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"signalInterrupt:(I)V":
				{
					SpringThread st = this.machine.getThread(
						(Integer)__args[0]);
					if (st != null)
					{
						SpringThreadWorker stw = st._worker;
						if (stw != null)
						{
							Thread signal = stw.signalinstead;
							if (signal != null)
								signal.interrupt();
							else
								stw.interrupt();
						}
					}
					
					return null;
				}
				
				// Sleep
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"sleep:(JI)Z":
				try
				{
					long ms = (Long)__args[0];
					int ns = (Integer)__args[1];
					
					// Zero time is a yield
					if (ms == 0 && ns == 0)
						Thread.yield();
					
					// Otherwise sleep for given time
					else
						Thread.sleep(ms, ns);
					return 0;
				}
				catch (InterruptedException e)
				{
					return 1;
				}
				
				// Start Task
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startTask:([Ljava/lang/String;Ljava/lang/String;" +
				"[Ljava/lang/String;)I":
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startTask:([Ljava/lang/String;Ljava/lang/String;" +
				"[Ljava/lang/String;[Ljava/lang/String;" +
				"Lcc/squirreljme/runtime/cldc/asm/ConsoleCallback;" +
				"Lcc/squirreljme/runtime/cldc/asm/ConsoleCallback;)I":
				return this.machine.taskManager().startTask(
					this.<String[]>asNativeObject(String[].class, __args[0]),
					this.<String>asNativeObject(String.class, __args[1]),
					this.<String[]>asNativeObject(String[].class, __args[2]),
					this.machine.guestdepth);
				
				// Start Thread
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startThread:(Ljava/lang/Thread;Ljava/lang/String;)I":
				{
					// Create thread
					String name;
					SpringThread thread = this.machine.createThread(
						(name = this.<String>asNativeObject(String.class,
							__args[1])));
					
					// Enter Thread's `__start()`
					SpringObject throbj = (SpringObject)__args[0];
					thread.enterFrame(this.resolveClass(
						new ClassName("java/lang/Thread")).lookupMethod(false,
						new MethodNameAndType("__start", "()V")), throbj);
					
					// Create worker for this thread
					SpringThreadWorker worker = new SpringThreadWorker(
						this.machine, thread, false);
					worker.start();
					
					// Return this thread ID
					return thread.id;
				}
				
				// Task status
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"taskStatus:(I)I":
				return this.machine.taskManager().taskStatus(
					(Integer)__args[0]);
				
				// {@squirreljme.error BK25 Unknown native function. (The
				// native function)}
			default:
				throw new SpringVirtualMachineException(
					String.format("BK25 %s", __func));
		}
	}
	
	/**
	 * Creates a new instance of the given class and initializes it using the
	 * given arguments. Access checks are ignored.
	 *
	 * @param __cl The class to initialize.
	 * @param __desc The descriptor of the constructor.
	 * @param __args The arguments to the constructor.
	 * @return The newly created and setup object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final SpringObject newInstance(ClassName __cl,
		MethodDescriptor __desc, Object... __args)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.newInstance(this.loadClass(__cl), __desc, __args);
	}
	
	/**
	 * Creates a new instance of the given class and initializes it using the
	 * given arguments. Access checks are ignored.
	 *
	 * @param __cl The class to initialize.
	 * @param __desc The descriptor of the constructor.
	 * @param __args The arguments to the constructor.
	 * @return The newly created and setup object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final SpringObject newInstance(SpringClass __cl,
		MethodDescriptor __desc, Object... __args)
		throws NullPointerException
	{
		if (__cl == null || __desc == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Make sure this class is loaded
		__cl = this.loadClass(__cl);
		
		// Lookup constructor to this method
		SpringMethod cons = __cl.lookupMethod(false, new MethodName("<init>"),
			__desc);
		
		// Allocate the object
		SpringObject rv = this.allocateObject(__cl);
			
		// Stop execution when the constructor exits
		SpringThread thread = this.thread;
		int framelimit = thread.numFrames();
		
		// Need to pass the allocated object as the first argument
		int nargs = __args.length;
		Object[] callargs = new Object[nargs + 1];
		callargs[0] = rv;
		for (int i = 0, o = 1; i < nargs; i++, o++)
			callargs[o] = __args[i];
		
		// Enter the constructor
		thread.enterFrame(cons, callargs);
		
		// Execute until it finishes
		this.run(framelimit);
		
		// Return the resulting object
		return rv;
	}
	
	/**
	 * Resolves the given class, checking access.
	 *
	 * @param __cl The class to resolve.
	 * @return The resolved class.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIllegalAccessException If the class cannot be accessed.
	 * @since 2018/09/15
	 */
	public final SpringClass resolveClass(ClassName __cl)
		throws NullPointerException, SpringIllegalAccessException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK26 Could not access the specified class.
		// (The class to access; The context class)}
		SpringClass rv = this.loadClass(__cl);
		if (!this.checkAccess(rv))
			throw new SpringIllegalAccessException(String.format("BK26 %s %s",
				__cl, this.contextClass()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/03
	 */
	@Override
	public final void run()
	{
		// Run until there are no frames left
		this.run(0);
	}
	
	/**
	 * Runs the worker with a limit on the lowest frame that may be reached
	 * when execution finishes. This is needed in some cases to invoke methods
	 * and static initializers in auxiliary code without needing complex state
	 * or otherwise to handle such things.
	 *
	 * @param __framelimit The current frame depth execution will stop at.
	 * @throws IllegalArgumentException If the frame limit is negative.
	 * @since 2018/09/08
	 */
	public final void run(int __framelimit)
		throws IllegalArgumentException
	{
		SpringThread thread = this.thread;
		try
		{
			// {@squirreljme.error BK27 Cannot have a negative frame limit.
			// (The frame limit)}
			if (__framelimit < 0)
				throw new IllegalArgumentException(String.format("BK27 %d",
					__framelimit));
			
			// The thread is alive as long as there are still frames of
			// execution
			while (thread.numFrames() > __framelimit)
			{
				// Single step executing the top frame
				this.__singleStep();
			}
		}
		
		// If the VM is exiting then clear the execution stack before we go
		// away
		catch (SpringMachineExitException e)
		{
			// Thread is okay to exit!
			thread._terminate = true;
			thread._signaledexit = true;
			
			// Exit all frames
			thread.exitAllFrames();
			
			// Exit profiler stack
			thread.profiler.exitAll(System.nanoTime());
			
			// Do not rethrow though
			return;
		}
		
		// Caught exception
		catch (RuntimeException e)
		{
			// Frame limit is zero, so kill the thread
			if (__framelimit == 0)
			{
				PrintStream err = System.err;
				
				err.println("****************************");
				
				// Print the real stack trace
				err.println("*** EXTERNAL STACK TRACE ***");
				e.printStackTrace(err);
				err.println();
				
				// Print the VM seen stack trace
				err.println("*** INTERNAL STACK TRACE ***");
				thread.printStackTrace(err);
				err.println();
				
				err.println("****************************");
				
				// Terminate the thread
				thread._terminate = true;
				
				// Exit all frames
				thread.exitAllFrames();
				
				// Exit from all profiler threads
				thread.profiler.exitAll(System.nanoTime());
			}
			
			// Re-toss
			throw e;
		}
		
		// Terminate if the last frame
		finally
		{
			if (__framelimit == 0)
				thread._terminate = true;
		}
	}
	
	/**
	 * Checks if an exception is being thrown and sets up the state from it.
	 *
	 * @return True if an exception was detected.
	 * @since 2018/12/06
	 */
	boolean __checkException()
	{
		// Are we exiting in the middle of an exception throwing?
		this.machine.exitCheck();
		
		// Check if this frame handles the exception
		SpringThread.Frame frame = this.thread.currentFrame();
		SpringObject tossing = frame.tossedException();
		if (tossing != null)
		{
			// Handling the tossed exception, so do not try handling it again
			frame.tossException(null);
			
			// Handle it
			int pc = this.__handleException(tossing);
			if (pc < 0)
				return true;
			
			// Put it on an empty stack
			frame.clearStack();
			frame.pushToStack(tossing);
			
			// Execute at the handler address now
			frame.setPc(pc);
			return true;
		}
		
		// No exception thrown
		return false;
	}
	
	/**
	 * Handles the exception, if it is in this frame to be handled then it
	 * will say that the instruction is to be moved elsewhere. Otherwise it
	 * will flag the frame above that an exception occurred and should be
	 * handled.
	 *
	 * @param __o The object being thrown.
	 * @return The next PC address of the handler or a negative value if it
	 * is to proprogate to the above frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	int __handleException(SpringObject __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
			
		// Are we exiting in the middle of an exception throwing?
		this.machine.exitCheck();
		
		// Need the current frame and its byte code
		SpringThread thread = this.thread;
		SpringThread.Frame frame = thread.currentFrame();
		ByteCode code = frame.byteCode();
		int pc = frame.lastExecutedPc();
		
		// Get the handler for the given exception at the
		// given address
		ExceptionHandler useeh = null;
		for (ExceptionHandler eh : code.exceptions().at(pc))
		{
			// Is this handler compatible for the thrown
			// exception?
			SpringClass ehcl = this.loadClass(eh.type());
			
			if (ehcl.isCompatible(__o))
			{
				useeh = eh;
				break;
			}
		}
		
		// No handler for this exception, so just go up the
		// stack and find a handler recursively up every frame
		if (useeh == null)
		{
			// Pop our current frame from the call stack
			thread.popFrame();
			
			// Did we run out of stack frames?
			SpringThread.Frame cf = thread.currentFrame();
			if (cf == null)
			{
				// Send our throwable to a special handler
				this.invokeMethod(true, new ClassName("cc/squirreljme/" +
					"runtime/cldc/lang/UncaughtExceptionHandler"),
					new MethodNameAndType("handle",
					"(Ljava/lang/Throwable;)V"), __o);
				
				// Just stop execution here
				return -1;
			}
			
			// Toss onto the new current frame
			cf.tossException(__o);
			
			// Stop executing here and let it continue on the
			// other top frame
			return -1;
		}
		
		// Otherwise jump to that address
		else
		{
			// Clear the stack frame and then push our
			// exception back onto the stack
			frame.clearStack();
			frame.pushToStack(__o);
			
			// Handle at this address
			return useeh.handlerAddress();
		}
	}
	
	/**
	 * Looks up the specified instance field specifier and returns the
	 * information for it.
	 *
	 * @param __f The field to lookup.
	 * @return The specified for the field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the field is static.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/16
	 */
	private final SpringField __lookupInstanceField(FieldReference __f)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchFieldException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
			
		// {@squirreljme.error BK28 Could not access the target class for
		// instance field access. (The field reference)}
		SpringClass inclass = this.loadClass(__f.className());
		if (!this.checkAccess(inclass))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK28 %s", __f));
		
		// {@squirreljme.error BK29 Could not access the target field for
		// instance field access. (The field reference; The field flags)}
		SpringField field = inclass.lookupField(false,
			__f.memberNameAndType());
		if (!this.checkAccess(field))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK29 %s %s", __f, field.flags()));
		
		return field;
	}
	
	/**
	 * Looks up the specified static field and returns the storage for it.
	 *
	 * @param __f The field to lookup.
	 * @return The static field storage.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target field is
	 * not static.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	private final SpringFieldStorage __lookupStaticField(FieldReference __f)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchFieldException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK2a Could not access the target class for
		// static field access. (The field reference)}
		SpringClass inclass = this.loadClass(__f.className());
		if (!this.checkAccess(inclass))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK2a %s", __f));
		
		// {@squirreljme.error BK2b Could not access the target field for
		// static field access. (The field reference)}
		SpringField field = inclass.lookupField(true, __f.memberNameAndType());
		if (!this.checkAccess(field))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK2b %s", __f));
		
		// Lookup the global static field
		return this.machine.lookupStaticField(field);
	}
	
	/**
	 * Single step through handling a single instruction.
	 *
	 * This method uses strict floating point to make operations consistent.
	 *
	 * @since 2018/09/03
	 */
	private final strictfp void __singleStep()
	{
		// Need the current frame and its byte code
		SpringThread thread = this.thread;
		
		// Check if the VM is exiting, to discontinue execution if it has been
		// requested by any thread
		SpringMachine machine = this.machine;
		try
		{
			machine.exitCheck();
		}
		
		// If the VM is exiting then clear the execution stack before we go
		// away
		catch (SpringMachineExitException e)
		{
			// Thread is okay to exit!
			thread._terminate = true;
			
			// Exit profiler stack
			thread.profiler.exitAll(System.nanoTime());
			
			throw e;
		}
		
		// Increase the step count
		this._stepcount++;
		
		SpringThread.Frame frame = thread.currentFrame();
		ByteCode code = frame.byteCode();
		
		// Frame is execution
		int iec = frame.incrementExecCount();
		if (iec > 0 && (iec % SpringThreadWorker._EXECUTION_THRESHOLD) == 0)
		{
			// {@squirreljme.error BK2c Execution seems to be stuck in this
			// method.}
			System.err.println("BK2c");
			this.thread.printStackTrace(System.err);
		}
		
		// Are these certain kinds of initializers? Because final fields are
		// writable during initialization accordingly
		SpringClass currentclass = this.contextClass();
		SpringMethod method = frame.method();
		boolean isstaticinit = method.isStaticInitializer(),
			isinstanceinit = method.isInstanceInitializer();
		
		// Determine the current instruction of execution
		int pc = frame.pc();
		Instruction inst = code.getByAddress(pc);
		
		// If we are tossing an exception, we need to handle it
		if (this.__checkException())
			return;
		
		// This PC is about to be executed, so set it as executed since if an
		// exception is thrown this could change potentially
		frame.setLastExecutedPc(pc);
		
		// Debug
		/*todo.DEBUG.note("step(%s %s::%s) -> %s", thread.name(),
			method.inClass(), method.nameAndType(), inst);*/
		
		// Used to detect the next instruction of execution following this,
		// may be set accordingly in the frame manually
		int nextpc = code.addressFollowing(pc),
			orignextpc = nextpc;
		
		// Handle individual instructions
		int opid;
		try
		{
			// Handle it
			switch ((opid = inst.operation()))
			{
					// Do absolutely nothing!
				case InstructionIndex.NOP:
					break;
					
					// Load object from array
				case InstructionIndex.AALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<SpringObject>get(
							SpringObject.class, dx));
					}
					break;
					
					// Store object to array
				case InstructionIndex.AASTORE:
					{
						SpringObject value = frame.<SpringObject>popFromStack(
							SpringObject.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Push null reference
				case InstructionIndex.ACONST_NULL:
					frame.pushToStack(SpringNullObject.NULL);
					break;
					
					// Load reference from local
				case InstructionIndex.ALOAD:
				case InstructionIndex.WIDE_ALOAD:
					frame.loadToStack(SpringObject.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load reference from local (short)
				case InstructionIndex.ALOAD_0:
				case InstructionIndex.ALOAD_1:
				case InstructionIndex.ALOAD_2:
				case InstructionIndex.ALOAD_3:
					frame.loadToStack(SpringObject.class,
						opid - InstructionIndex.ALOAD_0);
					break;
				
					// Allocate new array
				case InstructionIndex.ANEWARRAY:
					frame.pushToStack(this.allocateArray(this.resolveClass(
						inst.<ClassName>argument(0, ClassName.class)),
						frame.<Integer>popFromStack(Integer.class)));
					break;
					
					// Return reference
				case InstructionIndex.ARETURN:
					this.__vmReturn(thread,
						frame.<SpringObject>popFromStack(SpringObject.class));
					nextpc = Integer.MIN_VALUE;
					break;
					
					// Length of array
				case InstructionIndex.ARRAYLENGTH:
					frame.pushToStack(
						frame.<SpringArrayObject>popFromStackNotNull(
						SpringArrayObject.class).length());
					break;
					
					// Store reference to local variable
				case InstructionIndex.ASTORE:
				case InstructionIndex.WIDE_ASTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<SpringObject>popFromStack(SpringObject.class));
					break;
					
					// Store reference to local varibale
				case InstructionIndex.ASTORE_0:
				case InstructionIndex.ASTORE_1:
				case InstructionIndex.ASTORE_2:
				case InstructionIndex.ASTORE_3:
					{
						frame.storeLocal(opid - InstructionIndex.ASTORE_0,
							frame.<SpringObject>popFromStack(
								SpringObject.class));
					}
					break;
					
					// Throwing of an exception
				case InstructionIndex.ATHROW:
					nextpc = this.__handleException(
						frame.<SpringObject>popFromStack(SpringObject.class));
					if (nextpc < 0)
						return;
					break;
					
					// Push value
				case InstructionIndex.BIPUSH:
				case InstructionIndex.SIPUSH:
					frame.pushToStack(inst.<Integer>argument(
						0, Integer.class));
					break;
					
					// Checks casting from a type to another
				case InstructionIndex.CHECKCAST:
					{
						SpringClass as = this.resolveClass(inst.
							<ClassName>argument(0, ClassName.class));
						
						// This is just popped back on if it passes
						SpringObject pop = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2d Cannot cast object to the
						// target type. (The type to cast to; The type of the
						// object)}
						if (pop != SpringNullObject.NULL &&
							!as.isAssignableFrom(pop.type()))
							throw new SpringClassCastException(String.format(
								"BK2d %s %s", as, pop.type()));
						
						// Return the popped value
						else
							frame.pushToStack(pop);
					}
					break;
					
					// Double to float
				case InstructionIndex.D2F:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Float.valueOf((float)value));
					}
					break;
					
					// Double to int
				case InstructionIndex.D2I:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Double to long
				case InstructionIndex.D2L:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Long.valueOf((long)value));
					}
					break;
				
					// Addiply double
				case InstructionIndex.DADD:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a + b);
					}
					break;
					
					// Compare double, NaN is positive
				case InstructionIndex.DCMPG:
					{
						double b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Double.isNaN(a) || Double.isNaN(b))
							frame.pushToStack(1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
				
					// Compare double, NaN is negative
				case InstructionIndex.DCMPL:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						
						if (Double.isNaN(a) || Double.isNaN(b))
							frame.pushToStack(-1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Double constant
				case InstructionIndex.DCONST_0:
				case InstructionIndex.DCONST_1:
					frame.pushToStack(
						Double.valueOf(opid - InstructionIndex.DCONST_0));
					break;
				
					// Divide double
				case InstructionIndex.DDIV:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load double from local variable
				case InstructionIndex.DLOAD:
				case InstructionIndex.WIDE_DLOAD:
					frame.loadToStack(Double.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load double from local variable
				case InstructionIndex.DLOAD_0:
				case InstructionIndex.DLOAD_1:
				case InstructionIndex.DLOAD_2:
				case InstructionIndex.DLOAD_3:
					frame.loadToStack(Double.class,
						opid - InstructionIndex.DLOAD_0);
					break;
				
					// Multiply double
				case InstructionIndex.DMUL:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate double
				case InstructionIndex.DNEG:
					{
						double a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(-a);
					}
					break;
				
					// Remainder double
				case InstructionIndex.DREM:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return double
				case InstructionIndex.DRETURN:
					this.__vmReturn(thread,
						frame.<Double>popFromStack(Double.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Subtract double
				case InstructionIndex.DSUB:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Store double to local variable
				case InstructionIndex.DSTORE:
				case InstructionIndex.WIDE_DSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Double>popFromStack(Double.class));
					break;
					
					// Store long to double variable
				case InstructionIndex.DSTORE_0:
				case InstructionIndex.DSTORE_1:
				case InstructionIndex.DSTORE_2:
				case InstructionIndex.DSTORE_3:
					frame.storeLocal(opid - InstructionIndex.DSTORE_0,
						frame.<Double>popFromStack(Double.class));
					break;
					
					// Duplicate top-most stack entry
				case InstructionIndex.DUP:
					{
						Object copy = frame.popFromStack();
						
						// {@squirreljme.error BK2e Cannot duplicate category
						// two type.}
						if (copy instanceof Long || copy instanceof Double)
							throw new SpringVirtualMachineException("BK2e");
						
						// Push twice!
						frame.pushToStack(copy);
						frame.pushToStack(copy);
					}
					break;
					
					// Duplicate top and place two down
				case InstructionIndex.DUP_X1:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2f Cannot duplicate and place
						// down below with two type.}
						if (a instanceof Long || a instanceof Double ||
							b instanceof Long || b instanceof Double)
							throw new SpringVirtualMachineException("BK2f");
						
						frame.pushToStack(a);
						frame.pushToStack(b);
						frame.pushToStack(a);
					}
					break;
					
					// Dup[licate top entry and place two or three down
				case InstructionIndex.DUP_X2:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2g Cannot duplicate cat2
						// type.}
						if (a instanceof Long || a instanceof Double)
							throw new SpringVirtualMachineException("BK2g");
						
						// Insert A below C
						if (b instanceof Long || b instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
						
						// Grab C as well and push below that
						else
						{
							Object c = frame.popFromStack();
							
							// {@squirreljme.error BK2h Cannot duplicate top
							// most entry and place two down because a cat2
							// type is in the way.}
							if (c instanceof Long || c instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2h");
									
							frame.pushToStack(a);
							frame.pushToStack(c);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
					
					// Duplicate top two cat1s or single cat2
				case InstructionIndex.DUP2:
					{
						Object a = frame.popFromStack();
						
						// Just cat two
						if (a instanceof Long || a instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(a);
						}
						
						// Double values
						else
						{
							Object b = frame.popFromStack();
							
							// {@squirreljme.error BK2i Cannot duplicate top
							// two values.}
							if (b instanceof Long || b instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2i");
							
							frame.pushToStack(b);
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
					
					// Duplicate top one or two operand values and insert two
					// or three values down
				case InstructionIndex.DUP2_X1:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2j Expected category one
						// type.}
						if (b instanceof Long || b instanceof Double)
							throw new SpringVirtualMachineException(
								"BK2j");
						
						// Insert this below b
						if (a instanceof Long || a instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
						
						// Three cat1 values
						else
						{
							Object c = frame.popFromStack();
							
							// {@squirreljme.error BK2k Cannot duplicate value
							// below category two type.}
							if (c instanceof Long || c instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2k");
							
							frame.pushToStack(b);
							frame.pushToStack(a);
							frame.pushToStack(c);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
				
					// Duplicate top one or two stack entries and insert
					// two, three, or four down
				case InstructionIndex.DUP2_X2:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// Category two is on top
						if (a instanceof Long || a instanceof Double)
						{
							// Category two is on bottom (form 4)
							if (b instanceof Long || b instanceof Double)
							{
								frame.pushToStack(a);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
							
							// Category ones on bottom (form 2)
							else
							{
								Object c = frame.popFromStack();
								
								// {@squirreljme.error BK2l Cannot pop cat2
								// type for dup.}
								if (c instanceof Long || c instanceof Double)
									throw new SpringVirtualMachineException(
										"BK2l");
								
								frame.pushToStack(a);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
						}
						
						// Category one is on top
						else
						{
							// {@squirreljme.error BK2m Category two type
							// cannot be on the bottom.}
							if (b instanceof Long || b instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2m");
							
							Object c = frame.popFromStack();
							
							// C is category two (Form 3)
							if (c instanceof Long || c instanceof Double)
							{
								frame.pushToStack(b);
								frame.pushToStack(a);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
							
							// Category one on bottom (Form 1)
							else
							{
								Object d = frame.popFromStack();
								
								// {@squirreljme.error BK2n Bottommost entry
								// cannot be cat2 type.}
								if (d instanceof Long || d instanceof Double)
									throw new SpringVirtualMachineException(
										"BK2n");
								
								frame.pushToStack(b);
								frame.pushToStack(a);
								frame.pushToStack(d);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
						}
					}
					break;
					
					// Float to double
				case InstructionIndex.F2D:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Double.valueOf((double)value));
					}
					break;
					
					// Float to integer
				case InstructionIndex.F2I:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Float to long
				case InstructionIndex.F2L:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Long.valueOf((long)value));
					}
					break;
				
					// Add float
				case InstructionIndex.FADD:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// Compare float, NaN is positive
				case InstructionIndex.FCMPG:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Float.isNaN(a) || Float.isNaN(b))
							frame.pushToStack(1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
				
					// Compare float, NaN is negative
				case InstructionIndex.FCMPL:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Float.isNaN(a) || Float.isNaN(b))
							frame.pushToStack(-1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Float constant
				case InstructionIndex.FCONST_0:
				case InstructionIndex.FCONST_1:
				case InstructionIndex.FCONST_2:
					frame.pushToStack(
						Float.valueOf(opid - InstructionIndex.FCONST_0));
					break;
				
					// Divide float
				case InstructionIndex.FDIV:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load float from local variable
				case InstructionIndex.FLOAD:
				case InstructionIndex.WIDE_FLOAD:
					frame.loadToStack(Float.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load float from local variable
				case InstructionIndex.FLOAD_0:
				case InstructionIndex.FLOAD_1:
				case InstructionIndex.FLOAD_2:
				case InstructionIndex.FLOAD_3:
					frame.loadToStack(Float.class,
						opid - InstructionIndex.FLOAD_0);
					break;
				
					// Multiply float
				case InstructionIndex.FMUL:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate float
				case InstructionIndex.FNEG:
					{
						float a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(-a);
					}
					break;
				
					// Remainder float
				case InstructionIndex.FREM:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return float
				case InstructionIndex.FRETURN:
					this.__vmReturn(thread,
						frame.<Float>popFromStack(Float.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Subtract float
				case InstructionIndex.FSUB:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Store float to local variable
				case InstructionIndex.FSTORE:
				case InstructionIndex.WIDE_FSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Float>popFromStack(Float.class));
					break;
					
					// Store float to local variable
				case InstructionIndex.FSTORE_0:
				case InstructionIndex.FSTORE_1:
				case InstructionIndex.FSTORE_2:
				case InstructionIndex.FSTORE_3:
					frame.storeLocal(opid - InstructionIndex.FSTORE_0,
						frame.<Float>popFromStack(Float.class));
					break;
					
					// Read from instance field
				case InstructionIndex.GETFIELD:
					{
						// Lookup field
						SpringField ssf = this.__lookupInstanceField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Pop the object to read from
						SpringObject ref = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2o Cannot read value from
						// null reference.}
						if (ref == SpringNullObject.NULL)
							throw new SpringNullPointerException("BK2o");
						
						// {@squirreljme.error BK2p Cannot read value from
						// this instance because it not a simple object.}
						if (!(ref instanceof SpringSimpleObject))
							throw new SpringIncompatibleClassChangeException(
								"BK2p");
						SpringSimpleObject sso = (SpringSimpleObject)ref;
						
						// Read and push to the stack
						frame.pushToStack(this.asVMObject(
							sso.fieldByIndex(ssf.index()).get()));
					}
					break;
					
					// Read static variable
				case InstructionIndex.GETSTATIC:
					{
						// Lookup field
						SpringFieldStorage ssf = this.__lookupStaticField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Push read value to stack
						frame.pushToStack(this.asVMObject(ssf.get()));
					}
					break;
					
					// Go to address
				case InstructionIndex.GOTO:
				case InstructionIndex.GOTO_W:
					nextpc = inst.<InstructionJumpTarget>argument(0,
						InstructionJumpTarget.class).target();
					break;
					
					// Load integer from array
				case InstructionIndex.BALOAD:
				case InstructionIndex.CALOAD:
				case InstructionIndex.SALOAD:
				case InstructionIndex.IALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Integer>get(Integer.class, dx));
					}
					break;
					
					// Load double from array
				case InstructionIndex.DALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Double>get(Double.class, dx));
					}
					break;
					
					// Load float from array
				case InstructionIndex.FALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Float>get(Float.class, dx));
					}
					break;
					
					
					// Load long from array
				case InstructionIndex.LALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Long>get(Long.class, dx));
					}
					break;
					
					// Store integer to array (compatible)
				case InstructionIndex.BASTORE:
				case InstructionIndex.CASTORE:
				case InstructionIndex.SASTORE:
				case InstructionIndex.IASTORE:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store double to array
				case InstructionIndex.DASTORE:
					{
						double value = frame.<Double>popFromStack(
							Double.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store float to array
				case InstructionIndex.FASTORE:
					{
						float value = frame.<Float>popFromStack(Float.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store long to array
				case InstructionIndex.LASTORE:
					{
						long value = frame.<Long>popFromStack(Long.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Integer to byte
				case InstructionIndex.I2B:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Byte.valueOf((byte)value).
							intValue());
					}
					break;
					
					// Integer to double
				case InstructionIndex.I2D:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Double.valueOf(value));
					}
					break;
					
					// Integer to long
				case InstructionIndex.I2L:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Long.valueOf(value));
					}
					break;
					
					// Integer to character
				case InstructionIndex.I2C:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Integer.valueOf((char)value));
					}
					break;
					
					// Integer to short
				case InstructionIndex.I2S:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Integer.valueOf((short)value));
					}
					break;
					
					// Integer to float
				case InstructionIndex.I2F:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Float.valueOf(value));
					}
					break;
					
					// Integer constant
				case InstructionIndex.ICONST_M1:
				case InstructionIndex.ICONST_0:
				case InstructionIndex.ICONST_1:
				case InstructionIndex.ICONST_2:
				case InstructionIndex.ICONST_3:
				case InstructionIndex.ICONST_4:
				case InstructionIndex.ICONST_5:
					frame.pushToStack(Integer.valueOf(
						-1 + (opid - InstructionIndex.ICONST_M1)));
					break;
					
					// Object a == b
				case InstructionIndex.IF_ACMPEQ:
					{
						SpringObject b = frame.<SpringObject>popFromStack(
								SpringObject.class),
							a = frame.<SpringObject>popFromStack(
								SpringObject.class);
						
						if (a == b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// Object a != b
				case InstructionIndex.IF_ACMPNE:
					{
						SpringObject b = frame.<SpringObject>popFromStack(
								SpringObject.class),
							a = frame.<SpringObject>popFromStack(
								SpringObject.class);
						
						if (a != b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a == b
				case InstructionIndex.IF_ICMPEQ:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a == b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a >= b
				case InstructionIndex.IF_ICMPGE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a >= b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a > b
				case InstructionIndex.IF_ICMPGT:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a > b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a <= b
				case InstructionIndex.IF_ICMPLE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a <= b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a < b
				case InstructionIndex.IF_ICMPLT:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a < b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a != b
				case InstructionIndex.IF_ICMPNE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a != b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a == 0
				case InstructionIndex.IFEQ:
					if (frame.<Integer>popFromStack(Integer.class) == 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a >= 0
				case InstructionIndex.IFGE:
					if (frame.<Integer>popFromStack(Integer.class) >= 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a > 0
				case InstructionIndex.IFGT:
					if (frame.<Integer>popFromStack(Integer.class) > 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a <= 0
				case InstructionIndex.IFLE:
					if (frame.<Integer>popFromStack(Integer.class) <= 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a < 0
				case InstructionIndex.IFLT:
					if (frame.<Integer>popFromStack(Integer.class) < 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a != 0
				case InstructionIndex.IFNE:
					if (frame.<Integer>popFromStack(Integer.class) != 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// If reference is not null
				case InstructionIndex.IFNONNULL:
					if (frame.<SpringObject>popFromStack(
						SpringObject.class) != SpringNullObject.NULL)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// If reference is null
				case InstructionIndex.IFNULL:
					{
						SpringObject a = frame.<SpringObject>popFromStack(
							SpringObject.class);
						if (a == SpringNullObject.NULL)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// Increment local variable
				case InstructionIndex.IINC:
				case InstructionIndex.WIDE_IINC:
					{
						int dx = inst.<Integer>argument(0, Integer.class);
						frame.storeLocal(dx, frame.<Integer>loadLocal(
							Integer.class, dx) + inst.<Integer>argument(1,
							Integer.class));
					}
					break;
					
					// Load integer from local variable
				case InstructionIndex.ILOAD:
				case InstructionIndex.WIDE_ILOAD:
					frame.loadToStack(Integer.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load integer from local variable
				case InstructionIndex.ILOAD_0:
				case InstructionIndex.ILOAD_1:
				case InstructionIndex.ILOAD_2:
				case InstructionIndex.ILOAD_3:
					frame.loadToStack(Integer.class,
						opid - InstructionIndex.ILOAD_0);
					break;
				
					// Addly integer
				case InstructionIndex.IADD:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// AND integer
				case InstructionIndex.IAND:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a & b);
					}
					break;
				
					// Divide integer
				case InstructionIndex.IDIV:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a / b);
					}
					break;
				
					// Multiply integer
				case InstructionIndex.IMUL:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate integer
				case InstructionIndex.INEG:
					{
						int a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(-a);
					}
					break;
					
					// Is the given object an instance of the given class?
				case InstructionIndex.INSTANCEOF:
					{
						// Check against this
						SpringClass as = this.resolveClass(inst.
							<ClassName>argument(0, ClassName.class));
						
						SpringClass vtype = frame.<SpringObject>popFromStack(
							SpringObject.class).type();
						frame.pushToStack((vtype != null &&
							as.isAssignableFrom(vtype) ? 1 : 0));
					}
					break;
					
					// Invoke interface method
				case InstructionIndex.INVOKEINTERFACE:
					this.__vmInvokeInterface(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke special method (constructor, superclass,
					// or private)
				case InstructionIndex.INVOKESPECIAL:
					this.__vmInvokeSpecial(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke static method
				case InstructionIndex.INVOKESTATIC:
					this.__vmInvokeStatic(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke virtual method
				case InstructionIndex.INVOKEVIRTUAL:
					this.__vmInvokeVirtual(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
				
					// OR integer
				case InstructionIndex.IOR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a | b);
					}
					break;
				
					// Remainder integer
				case InstructionIndex.IREM:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return integer
				case InstructionIndex.IRETURN:
					this.__vmReturn(thread,
						frame.<Integer>popFromStack(Integer.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Shift left integer
				case InstructionIndex.ISHL:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a << (b & 0x1F));
					}
					break;
				
					// Shift right integer
				case InstructionIndex.ISHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a >> (b & 0x1F));
					}
					break;
					
					// Store integer to local variable
				case InstructionIndex.ISTORE:
				case InstructionIndex.WIDE_ISTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Integer>popFromStack(Integer.class));
					break;
					
					// Store integer to local variable
				case InstructionIndex.ISTORE_0:
				case InstructionIndex.ISTORE_1:
				case InstructionIndex.ISTORE_2:
				case InstructionIndex.ISTORE_3:
					frame.storeLocal(opid - InstructionIndex.ISTORE_0,
						frame.<Integer>popFromStack(Integer.class));
					break;
				
					// Subtract integer
				case InstructionIndex.ISUB:
					{
						Integer b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a - b);
					}
					break;
				
					// Unsigned shift right integer
				case InstructionIndex.IUSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a >>> (b & 0x1F));
					}
					break;
				
					// XOR integer
				case InstructionIndex.IXOR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a ^ b);
					}
					break;
					
					// Long to double
				case InstructionIndex.L2D:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Double.valueOf((double)value));
					}
					break;
					
					// Long to float
				case InstructionIndex.L2F:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Float.valueOf((float)value));
					}
					break;
					
					// Long to integer
				case InstructionIndex.L2I:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Add long
				case InstructionIndex.LADD:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// And long
				case InstructionIndex.LAND:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a & b);
					}
					break;
				
					// Compare long
				case InstructionIndex.LCMP:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Long constant
				case InstructionIndex.LCONST_0:
				case InstructionIndex.LCONST_1:
					frame.pushToStack(Long.valueOf(
						(opid - InstructionIndex.LCONST_0)));
					break;
					
					// Load from constant pool, push to the stack
				case InstructionIndex.LDC:
				case InstructionIndex.LDC_W:
					{
						ConstantValue value = inst.<ConstantValue>argument(0,
							ConstantValue.class);
						
						// Pushing a string, which due to the rules of Java
						// there must always be an equality (==) between two
						// strings, so "foo" == "foo" must be true even if it
						// is in different parts of the code
						// Additionally internall class objects are adapted
						// too as needed
						if (value instanceof ConstantValueString ||
							value instanceof ConstantValueClass)
							frame.pushToStack(this.asVMObject(value));
						
						// This will be pre-boxed so push it to the stack
						else
							frame.pushToStack(value.boxedValue());
					}
					break;
					
					// Load long or double from constant pool, to the stack
				case InstructionIndex.LDC2_W:
					frame.pushToStack(inst.<ConstantValue>argument(0,
						ConstantValue.class).boxedValue());
					break;
				
					// Divide long
				case InstructionIndex.LDIV:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load integer from local variable
				case InstructionIndex.LLOAD:
				case InstructionIndex.WIDE_LLOAD:
					frame.loadToStack(Long.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load integer from local variable
				case InstructionIndex.LLOAD_0:
				case InstructionIndex.LLOAD_1:
				case InstructionIndex.LLOAD_2:
				case InstructionIndex.LLOAD_3:
					frame.loadToStack(Long.class,
						opid - InstructionIndex.LLOAD_0);
					break;
					
					// Multiply long
				case InstructionIndex.LMUL:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate long
				case InstructionIndex.LNEG:
					{
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(-a);
					}
					break;
					
					// OR long
				case InstructionIndex.LOR:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a | b);
					}
					break;
					
					// Subtract long
				case InstructionIndex.LSUB:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Lookup in a jump table
				case InstructionIndex.LOOKUPSWITCH:
				case InstructionIndex.TABLESWITCH:
					nextpc = inst.<IntMatchingJumpTable>argument(0,
						IntMatchingJumpTable.class).match(
						frame.<Integer>popFromStack(Integer.class)).target();
					break;
				
					// Remainder long
				case InstructionIndex.LREM:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return long
				case InstructionIndex.LRETURN:
					this.__vmReturn(thread,
						frame.<Long>popFromStack(Long.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Shift left long
				case InstructionIndex.LSHL:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a << (((long)b) & 0x3F));
					}
					break;
				
					// Shift right long
				case InstructionIndex.LSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a >> (((long)b) & 0x3F));
					}
					break;
					
					// Store long to local variable
				case InstructionIndex.LSTORE:
				case InstructionIndex.WIDE_LSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Long>popFromStack(Long.class));
					break;
					
					// Store long to local variable
				case InstructionIndex.LSTORE_0:
				case InstructionIndex.LSTORE_1:
				case InstructionIndex.LSTORE_2:
				case InstructionIndex.LSTORE_3:
					frame.storeLocal(opid - InstructionIndex.LSTORE_0,
						frame.<Long>popFromStack(Long.class));
					break;
				
					// Unsigned shift right long
				case InstructionIndex.LUSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a >>> (((long)b) & 0x3F));
					}
					break;
					
					// XOR long
				case InstructionIndex.LXOR:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a ^ b);
					}
					break;
					
					// Enter monitor
				case InstructionIndex.MONITORENTER:
					frame.<SpringObject>popFromStack(SpringObject.class).
						monitor().enter(thread);
					break;
					
					// Exit monitor
				case InstructionIndex.MONITOREXIT:
					frame.<SpringObject>popFromStack(SpringObject.class).
						monitor().exit(thread, true);
					break;
					
					// Allocate multi-dimensional array
				case InstructionIndex.MULTIANEWARRAY:
					{
						// Determine component type and dimension count
						SpringClass ccl = this.resolveClass(
							inst.<ClassName>argument(0, ClassName.class));
						int n = inst.<Integer>argument(1, Integer.class);
						
						// Pop values into array
						int[] pops = new int[n];
						for (int i = n - 1; i >= 0; i--)
							pops[i] = frame.<Integer>popFromStack(
								Integer.class);
						
						// Call method within the class library since it is
						// easier, becuse this is one super complex
						// instruction
						frame.pushToStack(
							this.invokeMethod(true, new ClassName(
							"cc/squirreljme/runtime/cldc/lang/ArrayUtils"),
							new MethodNameAndType("multiANewArray",
								"(Ljava/lang/Class;I[I)Ljava/lang/Object;"),
							this.asVMObject(ccl), 0, this.asVMObject(pops)));
						
						// Exception to be handled?
						if (this.__checkException())
							return;
					}
					break;
					
					// Allocate new object
				case InstructionIndex.NEW:
					this.__vmNew(inst, frame);
					break;
				
					// Allocate new primitive array
				case InstructionIndex.NEWARRAY:
					frame.pushToStack(this.allocateArray(this.resolveClass(
						ClassName.fromPrimitiveType(
						inst.<PrimitiveType>argument(0, PrimitiveType.class))),
						frame.<Integer>popFromStack(Integer.class)));
					break;
					
					// Return from method with no return value
				case InstructionIndex.RETURN:
					thread.popFrame();
					break;
					
					// Pop category 1 value
				case InstructionIndex.POP:
					{
						// {@squirreljme.error BK2q Cannot pop category two
						// value from stack.}
						Object val = frame.popFromStack();
						if (val instanceof Long || val instanceof Double)
							throw new SpringVirtualMachineException("BK2q");
					}
					break;
					
					// Pop two cat1s or one cat2
				case InstructionIndex.POP2:
					{
						// Pop one value, if it is a long or double then only
						// pop one
						Object val = frame.popFromStack();
						if (!(val instanceof Long || val instanceof Double))
						{
							// {@squirreljme.error BK2r Cannot pop a category
							// one then category two type.}
							val = frame.popFromStack();
							if (val instanceof Long || val instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2r");
						}
					}
					break;
					
					// Put to instance field
				case InstructionIndex.PUTFIELD:
					{
						// Lookup field
						SpringField ssf = this.__lookupInstanceField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Pop the value and the object to mess with
						Object value = frame.popFromStack();
						SpringObject ref = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2s Cannot store value into
						// null reference.}
						if (ref == SpringNullObject.NULL)
							throw new SpringNullPointerException("BK2s");
						
						// {@squirreljme.error BK2t Cannot store value into
						// this instance because it not a simple object.}
						if (!(ref instanceof SpringSimpleObject))
							throw new SpringIncompatibleClassChangeException(
								"BK2t");
						SpringSimpleObject sso = (SpringSimpleObject)ref;
						
						// {@squirreljme.error BK2u Cannot store value into
						// a field which belongs to another class.}
						if (!this.loadClass(ssf.inClass()).isAssignableFrom(
							sso.type()))
							throw new SpringClassCastException("BK2u");
						
						// Set
						sso.fieldByIndex(ssf.index()).set(value,
							isinstanceinit);
					}
					break;
				
					// Put to static field
				case InstructionIndex.PUTSTATIC:
					{
						// Lookup field
						SpringFieldStorage ssf = this.__lookupStaticField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Set value, note that static initializers can set
						// static field values even if they are final
						ssf.set(frame.popFromStack(), isstaticinit);
					}
					break;
					
					// Swap top two cat1 stack entries
				case InstructionIndex.SWAP:
					{
						Object v1 = frame.popFromStack(),
							v2 = frame.popFromStack();
						
						// {@squirreljme.error BK2v Cannot swap category
						// two types.}
						if (v1 instanceof Long || v1 instanceof Double ||
							v2 instanceof Long || v2 instanceof Double)
							throw new SpringClassCastException("BK2v");
						
						frame.pushToStack(v1);
						frame.pushToStack(v2);
					}
					break;
				
					// {@squirreljme.error BK2w Reserved instruction. (The
					// instruction)}
				case InstructionIndex.BREAKPOINT:
				case InstructionIndex.IMPDEP1:
				case InstructionIndex.IMPDEP2:
					throw new SpringVirtualMachineException(String.format(
						"BK2w %s", inst));
					
					// {@squirreljme.error BK2x Unimplemented operation.
					// (The instruction)}
				default:
					throw new SpringVirtualMachineException(String.format(
						"BK2x %s", inst));
			}
		}
		
		// Arithmetic exception, a divide by zero happened somewhere
		catch (ArithmeticException e)
		{
			// PC converts?
			nextpc = this.__handleException(
				(SpringObject)this.asVMObject(new SpringArithmeticException(
				e.getMessage())));
			
			// Do not set PC address?
			if (nextpc < 0)
				return;
		}
		
		// Use the original exception, just add a suppression note on it since
		// that is the simplest action
		catch (SpringException e)
		{
			// Do not add causes or do anything if this was already thrown
			if ((e instanceof SpringFatalException) ||
				(e instanceof SpringMachineExitException))
				throw e;
			
			// Now the exception is either converted or tossed for failure
			// Is this a convertable exception on the VM?
			if (e instanceof SpringConvertableThrowable)
			{
				// PC converts?
				nextpc = this.__handleException(
					(SpringObject)this.asVMObject(e));
				
				// Do not set PC address?
				if (nextpc < 0)
					return;
			}
			
			// Not a wrapped exception, kill the VM
			else
			{
				// Kill the VM
				this.machine.exitNoException(127);
				
				// Print the stack trace
				thread.printStackTrace(System.err);
				
				// Where is this located?
				SpringMethod inmethod = frame.method();
				ClassName inclassname = inmethod.inClass();
				SpringClass inclass = machine.classLoader().loadClass(
					inclassname);
				
				// Location information if debugging is used, this makes it
				// easier to see exactly where failed code happened
				String onfile = inclass.file().sourceFile();
				int online = code.lineOfAddress(pc);
				
				// {@squirreljme.error BK2y An exception was thrown in the
				// virtual machine while executing the specified location.
				// (The class; The method; The program counter; The file in
				// source code, null means it is unknown; The line in source
				// code, negative values are unknown; The instruction)}
				e.addSuppressed(new SpringVirtualMachineException(
					String.format("BK2y %s %s %d %s %d %s", inclassname,
					inmethod.nameAndType(), pc, onfile, online, inst)));
				
				// {@squirreljme.error BK2z Fatal VM exception.}
				throw new SpringFatalException("BK2z", e);
			}
		}
		
		// Set implicit next PC address, if it has not been set or the next
		// address was actually changed
		if (nextpc != orignextpc || pc == frame.pc())
			frame.setPc(nextpc);
	}
	
	/**
	 * Invokes a method in an interface.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	private final void __vmInvokeInterface(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK30 Could not access the target
		// method for interface invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK30 %s", ref));
		
		// Load arguments, includes the instance it acts on
		int nargs = refmethod.nameAndType().type().argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
			
		// {@squirreljme.error BK31 Instance object for interface invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK31");
			
		// {@squirreljme.error BK32 Cannot invoke the method in the object
		// because it is of the wrong type. (The reference class; The class
		// of the target object; The first argument)}
		SpringClass objclass = onthis.type();
		if (objclass == null || !refclass.isAssignableFrom(objclass))
			throw new SpringClassCastException(
				String.format("BK32 %s %s %s", refclass, objclass, args[0]));
		
		// Relookup the method since we need to the right one! Then invoke it
		__t.enterFrame(objclass.lookupMethod(false, ref.memberNameAndType()),
			args);
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	public final long systemCall(short __si, int... __args)
	{
		// Make at least 8!
		if (__args == null)
			__args = new int[8];
		if (__args.length < 8)
			__args = Arrays.copyOf(__args, 8);
		
		// Error state for the last call of this type
		int[] errors = this.thread._syscallerrors;
		
		// Return value with error value, to set if any
		long rv;
		int err;
		
		// Depends on the system call type
		switch (__si)
		{
				// Check if system call is supported
			case SystemCallIndex.QUERY_INDEX:
				{
					err = 0;
					switch (__args[0])
					{
						case SystemCallIndex.API_LEVEL:
						case SystemCallIndex.CALL_STACK_HEIGHT:
						case SystemCallIndex.CALL_STACK_ITEM:
						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.EXIT:
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
							rv = 1;
							break;
						
						default:
							rv = 0;
							break;
					}
				}
				break;
				
				// Returns the height of the call stack
			case SystemCallIndex.CALL_STACK_HEIGHT:
				{
					rv = this.thread.frames().length;
					err = 0;
				}
				break;
				
				// Returns the given call stack item
			case SystemCallIndex.CALL_STACK_ITEM:
				{
					// Need to get all the stack frames first
					SpringThread.Frame[] frames = this.thread.frames();
					int numframes = frames.length;
					int curf = (numframes - __args[0]) - 1;
					
					// Out of range item
					if (curf < 0 || curf >= numframes)
					{
						rv = -1;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Depends on the item
					else
					{
						// Reset
						rv = err = 0;
						
						// Get method we are in
						SpringMethod inmethod = frames[curf].method();
						
						// Depends on the item
						switch (__args[1])
						{
								// Class name
							case CallStackItem.CLASS_NAME:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(
										inmethod.inClass().toString());
								break;

								// The method name.
							case CallStackItem.METHOD_NAME:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(inmethod.
										nameAndType().name().toString());
								break;

								// The method type.
							case CallStackItem.METHOD_TYPE:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(inmethod.
										nameAndType().type().toString());
								break;

								// The current file.
							case CallStackItem.SOURCE_FILE:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(
										inmethod.inFile());
								break;

								// Source line.
							case CallStackItem.SOURCE_LINE:
								rv = frames[curf].lastExecutedPcSourceLine();
								break;

								// The PC address.
							case CallStackItem.PC_ADDRESS:
							case CallStackItem.JAVA_PC_ADDRESS:
								rv = frames[curf].lastExecutedPc();
								break;

							default:
								err = SystemCallError.VALUE_OUT_OF_RANGE;
								break;
						}
					}
				}
				break;
				
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return the stored error code
					synchronized (errors)
					{
						rv = errors[dx];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return last error code, and set new one
					synchronized (errors)
					{
						rv = errors[dx];
						errors[dx] = __args[0];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Exit the VM
			case SystemCallIndex.EXIT:
				{
					// Tell everything to cleanup and exit
					this.thread.profiler.exitAll(System.nanoTime());
					this.machine.exit((Integer)__args[0]);
					
					rv = 0;
					err = 0;
				}
				break;
				
				// Fatal ToDo
			case SystemCallIndex.FATAL_TODO:
				// {@squirreljme.error BK33 Virtual machine code executed
				// a fatal Todo. (The To Do code)}
				rv = err = 0;
				throw new SpringVirtualMachineException("BK33 " + __args[1]);
				
				// Invoke the garbage collector
			case SystemCallIndex.GARBAGE_COLLECT:
				{
					Runtime.getRuntime().gc();
					
					rv = 0;
					err = 0;
				}
				break;
				
				// Loads a string
			case SystemCallIndex.LOAD_STRING:
				{
					rv = (__args[0] == 0 ? 0 :
						this.uniqueObjectToPointer((SpringObject)
						this.asVMObject(new ConstantValueString(
						this.uniqueString(__args[0])))));
					err = 0;
				}
				break;
			
				// Current wall clock milliseconds (low).
			case SystemCallIndex.TIME_MILLI_WALL:
				{
					rv = System.currentTimeMillis();
					err = 0;
				}
				break;

				// Current monotonic clock nanoseconds (low).
			case SystemCallIndex.TIME_NANO_MONO:
				{
					rv = System.nanoTime();
					err = 0;
				}
				break;
			
				// VM information: Memory free bytes
			case SystemCallIndex.VMI_MEM_FREE:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().freeMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory used bytes
			case SystemCallIndex.VMI_MEM_USED:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().totalMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory max bytes
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
				// API level
			case SystemCallIndex.API_LEVEL:
				{
					rv = ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard input
			case SystemCallIndex.PD_OF_STDIN:
				{
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Write single byte to PD
			case SystemCallIndex.PD_WRITE_BYTE:
				{
					// Depends on the stream
					int pd = __args[0];
					OutputStream os = (pd == 1 ? System.out :
						(pd == 2 ? System.err : null));
					
					// Write
					if (os != null)
					{
						try
						{
							os.write(__args[1]);
							
							// Okay
							rv = 1;
							err = 0;
						}
						
						// Failed
						catch (IOException e)
						{
							rv = -1;
							err = SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE;
						}
					}
					
					// Failed
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used
				if (__si < 0 || __si >= SystemCallIndex.NUM_SYSCALLS)
					__si = SystemCallIndex.QUERY_INDEX;
				break;
		}
		
		// Set error state as needed
		synchronized (errors)
		{
			errors[__si] = err;
		}
		
		// Use returning value
		return rv;
	}
	
	/**
	 * Converts an object to a unique pointer.
	 *
	 * @param __p The object to convert.
	 * @return The resulting pointer.
	 * @since 2019/06/16
	 */
	public final int uniqueObjectToPointer(SpringObject __p)
	{
		// Null reference?
		if (__p == SpringNullObject.NULL)
			return 0;
		
		// Return the base of the pointer area
		return __p.pointerArea().base;
	}
	
	/**
	 * Converts an object to a unique pointer.
	 *
	 * @param __p The object to convert.
	 * @return The resulting pointer.
	 * @since 2019/06/16
	 */
	public final SpringObject uniquePointerToObject(int __p)
	{
		// Null reference?
		if (__p == 0)
			return SpringNullObject.NULL;
		
		return this.machine.pointers.findObject(__p);
	}
	
	/**
	 * Returns the string of the given ID.
	 *
	 * @param __id The ID to get.
	 * @return The resulting string.
	 * @since 2019/06/16
	 */
	public final String uniqueString(int __id)
	{
		if (__id == 0)
			return null;
		return this.machine.debugResolveString((int)__id);
	}
	
	/**
	 * Returns a unique ID for the given string.
	 *
	 * @param __s The String to get the ID of.
	 * @return The unique string ID.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	public final int uniqueStringId(String __s)
		throws NullPointerException
	{
		if (__s == null)
			return 0;
		
		return (int)this.machine.debugUnresolveString(__s);
	}
	
	/**
	 * Performs a special invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmInvokeSpecial(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK34 Could not access the target
		// method for special invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK34 %s", ref));
		
		// Load arguments
		int nargs = refmethod.nameAndType().type().
			argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// Get the class of the current method being executed, lookup depends
		// on it
		SpringClass currentclass = this.loadClass(
			this.thread.currentFrame().method().inClass());
		
		// {@squirreljme.error BK35 Instance object for special invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK35");
		
		// These modify the action to be performed
		boolean insame = (currentclass == refclass),
			insuper = currentclass.isSuperClass(refclass),
			isinit = refmethod.name().isInstanceInitializer(),
			isprivate = refmethod.flags().isPrivate();
		
		// {@squirreljme.error BK36 Cannot call private method that is not
		// in the same class. (The method reference)}
		if (isprivate && !insame)
			throw new SpringIncompatibleClassChangeException(
				String.format("BK36 %s", ref));
		
		// Call superclass method instead?
		else if (!isprivate && insuper && !isinit)
			refmethod = currentclass.superClass().lookupMethod(false,
				ref.memberNameAndType());
		
		// Invoke this method
		__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Performs a static invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmInvokeStatic(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(true,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK37 Could not access the target
		// method for static invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK37 %s", ref));
		
		// Load arguments
		int nargs = refmethod.nameAndType().type().
			argumentCount();
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// Virtualized native call, depends on what it is
		if (refmethod.flags().isNative())
		{
			// Calculate result of method
			MethodDescriptor type = ref.memberType();
			Object rv = this.nativeMethod(ref.className() + "::" +
				ref.memberName() + ":" + type, args);
			
			// Push native object to the stack
			if (type.hasReturnValue())
				__f.pushToStack(this.asVMObject(rv, true));
		}
		
		// Real code that exists in class file format
		else
			__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Performs a virtual invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	private final void __vmInvokeVirtual(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK38 Could not access the target
		// method for virtual invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK38 %s", ref));
		
		// Load arguments, includes the instance it acts on
		int nargs = refmethod.nameAndType().type().argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// {@squirreljme.error BK39 Instance object for virtual invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK39");
		
		// Re-resolve method for this object's class
		refmethod = onthis.type().lookupMethod(false,
			ref.memberNameAndType());
		
		// Enter frame for static method
		__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Allocates a new instance of the given object, it is not initialized just
	 * allocated.
	 *
	 * @param __i The instruction.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmNew(Instruction __i, SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __f == null)
			throw new NullPointerException("NARG");
		
		// Lookup class we want to allocate
		ClassName allocname;
		SpringClass toalloc = this.loadClass((allocname =
			__i.<ClassName>argument(0, ClassName.class)));
		
		// {@squirreljme.error BK3a Cannot allocate an instance of the given
		// class because it cannot be accessed. (The class to allocate)}
		if (!this.checkAccess(toalloc))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK3a %s", allocname));
		
		// Push a new allocation to the stack
		__f.pushToStack(this.allocateObject(toalloc));
	}
	
	/**
	 * Returns from the top-most frame then pushes the return value to the
	 * parent frame's stack (if any).
	 *
	 * @param __thread The thread to return in.
	 * @param __value The value to push.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	private final void __vmReturn(SpringThread __thread, Object __value)
		throws NullPointerException
	{
		if (__thread == null || __value == null)
			throw new NullPointerException("NARG");
		
		// Pop our current frame
		SpringThread.Frame old = __thread.popFrame();
		old.setPc(Integer.MIN_VALUE);
		
		// Push the value to the current frame
		SpringThread.Frame cur = __thread.currentFrame();
		if (cur != null)
			cur.pushToStack(__value);
		
		/*System.err.printf("+++RETURN: %s%n", __value);
		__thread.printStackTrace(System.err);*/
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringVMStaticMethod.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is a virtual machine representation of a static method.
 *
 * @since 2018/11/20
 */
@Deprecated
public final class SpringVMStaticMethod
	implements SpringObject
{
	/** The method to execute. */
	protected final SpringMethod method;
	
	/**
	 * Initializes the static method.
	 *
	 * @param __m The method to execute.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/20
	 */
	public SpringVMStaticMethod(SpringMethod __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.method = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK3b StaticMethod does not have a monitor.}
		throw new SpringFatalException("BK3b");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public final SpringClass type()
	{
		// {@squirreljme.error BK3c StaticMethod does not have a type.}
		throw new SpringFatalException("BK3c");
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/SpringVirtualMachineException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the virtual machine has been detected to not be
 * operating properly, this is an error.
 *
 * @since 2018/09/01
 */
public class SpringVirtualMachineException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SpringCoat virtual machine which is capable of
 * running SpringCoat binaries.
 *
 * @since 2018/07/21
 */

package cc.squirreljme.vm.springcoat;

Added emulators/springcoat-vm/src/main/resources/META-INF/services/cc.squirreljme.emulator.vm.VMFactory.


1
+
cc.squirreljme.vm.springcoat.SpringCoatFactory

Added emulators/summercoat-vm/build.gradle.

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java-library"
}

description = "This is the SummerCoat VM which is a more " +
	"optimized register based virtual machine which should result in faster" +
	"code execution."

dependencies
{
	api project(":emulators:emulator-base")

	api project(":modules:cldc-compact")
	api project(":modules:collections")
	api project(":modules:common-vm")
	api project(":modules:io")
	api project(":modules:meep-midlet")
	api project(":modules:meep-swm")
	api project(":modules:tool-classfile")
	api project(":modules:tool-jarfile")
	api project(":modules:tool-manifest-reader")
	api project(":modules:tool-packfile")
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/AbstractReadableMemory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This is a class which handles reading of memory by using pure integers
 * instead of forcing all implementations to implement short and byte
 * readers.
 *
 * @since 2019/04/21
 */
public abstract class AbstractReadableMemory
	implements ReadableMemory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		for (int i = 0; i < __l; i++)
			__b[__o++] = (byte)this.memReadByte(__addr++);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		return (this.memReadByte(__addr++) << 24) |
			(this.memReadByte(__addr++) << 16) |
			(this.memReadByte(__addr++) << 8) |
			this.memReadByte(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		return (this.memReadByte(__addr++) << 8) |
			this.memReadByte(__addr);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/AbstractWritableMemory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This class is used to provide simple writing for types other than integers
 * into memory.
 *
 * @since 2019/04/21
 */
public abstract class AbstractWritableMemory
	extends AbstractReadableMemory
	implements WritableMemory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteBytes(int __a, byte[] __b, int __o, int __l)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		for (int i = 0; i < __l; i++)
			this.memWriteByte(__a++, __b[__o++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteInt(int __addr, int __v)
	{
		this.memWriteByte(__addr++, __v >>> 24);
		this.memWriteByte(__addr++, __v >>> 16);
		this.memWriteByte(__addr++, __v >>> 8);
		this.memWriteByte(__addr++, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteShort(int __addr, int __v)
	{
		this.memWriteByte(__addr++, __v >>> 8);
		this.memWriteByte(__addr++, __v);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/ByteArrayMemory.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This is a region of memory which uses a read-only byte array.
 *
 * @since 2019/04/21
 */
public final class ByteArrayMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** The offset to this address. */
	protected final int offset;
	
	/** The size of the byte array. */
	protected final int size;
	
	/** Offset into the byte array. */
	protected final int boff;
	
	/** The backing byte array. */
	private final byte[] _bytes;
	
	/**
	 * Initializes the byte array memory.
	 *
	 * @param __mo The memory offset.
	 * @param __b The memory bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ByteArrayMemory(int __mo, byte[] __b)
		throws NullPointerException
	{
		this(__mo, __b, 0, __b.length);
	}
	
	/**
	 * Initializes the byte array memory.
	 *
	 * @param __mo The memory offset.
	 * @param __b The memory bytes.
	 * @param __o The array offset.
	 * @param __l The number of bytes to access.
	 * @throws IndexOutOfBoundsException If the byte array offset and/or
	 * length exceeds the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ByteArrayMemory(int __mo, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.offset = __mo;
		this._bytes = __b;
		this.boff = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size)
			return -1;
		
		return this._bytes[this.boff + __addr] & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get properties
		byte[] bytes = this._bytes;
		int offset = this.offset,
			size = this.size;
		
		// The end index where we are reading
		int enddx = __addr + __l;
		
		// The limiting index, which never exceeds the size
		int limdx = (enddx > size ? size : enddx);
		
		// The real address to read from
		int ai = this.boff + __addr;
		
		// Copy all data
		while (ai < limdx)
			__b[__o++] = bytes[ai++];
		
		// If there is anything left over, pour in -1s
		while ((ai++) < enddx)
			__b[__o++] = -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 3)
			return -1;
		
		byte[] bytes = this._bytes;
		int rp = this.boff + __addr;
		return ((bytes[rp++] & 0xFF) << 24) |
			((bytes[rp++] & 0xFF) << 16) |
			((bytes[rp++] & 0xFF) << 8) |
			(bytes[rp++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 1)
			return -1;
		
		byte[] bytes = this._bytes;
		int rp = this.boff + __addr;
		return (short)(((bytes[rp++] & 0xFF) << 8) |
			(bytes[rp++] & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/ConfigRomWriter.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * These are utility methods to write to config space.
 *
 * @since 2019/06/14
 */
public final class ConfigRomWriter
{
	/**
	 * Not used.
	 *
	 * @since 2019/06/14
	 */
	private ConfigRomWriter()
	{
	}
	
	/**
	 * Writes raw byte data.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __b The value.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeData(DataOutputStream __dos, int __opt,
		byte[] __b)
		throws IOException, NullPointerException
	{
		if (__dos == null || __b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AE01 Attempt to write very large configuration
		// item. (The length)}
		int len = __b.length;
		if (len >= 65536)
			throw new IOException("AE01 " + len);
		
		// Round to make data aligned
		int rlen = (len + 3) & (~3);
		
		// Key, value, and the data
		__dos.writeShort(__opt);
		__dos.writeShort(rlen);
		__dos.write(__b, 0, len);
		
		// Align?
		for (int i = len; i < rlen; i++)
			__dos.write(0);
	}
	
	/**
	 * Writes the specified integer.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeInteger(DataOutputStream __dos, int __opt,
		int __v)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeInt(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes key/value.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __k The key.
	 * @param __v The value.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeKeyValue(DataOutputStream __dos, int __opt,
		String __k, String __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeUTF(__k);
			xdos.writeUTF(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes the specified string.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The string to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeString(DataOutputStream __dos, int __opt,
		String __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeUTF(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes the specified strings.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The strings to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeStrings(DataOutputStream __dos, int __opt,
		String... __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			// Write string length
			int n = __v.length;
			xdos.writeShort(n);
			
			// Write actual strings
			for (int i = 0; i < n; i++)
				xdos.writeUTF(__v[i]);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/ExecutionSlice.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import java.io.PrintStream;
import net.multiphasicapps.classfile.InstructionMnemonics;

/**
 * This represents a single slice of execution.
 *
 * @since 2019/10/27
 */
public final class ExecutionSlice
{
	/** The tracing information. */
	protected final CallTraceElement trace;
	
	/** The operand executed. */
	protected final int op;
	
	/** Operand arguments. */
	private final int[] _opargs;
	
	/** CPU registers. */
	private final int[] _cpuregs;
	
	/** Method call arguments (optional). */
	private final int[] _callargs;
	
	/**
	 * Creates an execution slice of the given frame information.
	 *
	 * @param __cte Call trace information.
	 * @param __rreg CPU registers stored here.
	 * @param __op The operand.
	 * @param __args The arguments.
	 * @param __argslen Number of arguments available.
	 * @param __reglist The register list for method calls.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/03
	 */
	public ExecutionSlice(CallTraceElement __cte, int[] __rreg,
		int __op, int[] __args, int __argslen, int[] __reglist)
		throws NullPointerException
	{
		if (__cte == null || __rreg == null || __args == null)
			throw new NullPointerException("NARG");
		
		this.trace = __cte;
		this._cpuregs = __rreg.clone();
		this.op = __op;
		this._callargs = (__reglist != null ? __reglist.clone() : null);
		
		int[] args = new int[__argslen];
		for (int i = 0; i < __argslen; i++)
			args[i] = __args[i];
		this._opargs = args;
	}
	
	/**
	 * Prints the information about this slice.
	 *
	 * @since 2019/10/27
	 */
	public final void print()
	{
		this.print(System.err);
	}
	
	/**
	 * Prints the information about this slice.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final void print(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// We need all of these!
		CallTraceElement trace = this.trace;
		int op = this.op;
		int[] opargs = this._opargs,
			cpuregs = this._cpuregs,
			callargs = this._callargs;
		
		// Print CPU operation state
		__ps.printf("$$$$$$$$ @%08x (%s/%s)%n", trace.address(),
			NativeInstruction.mnemonic(op),
			InstructionMnemonics.toString(trace.byteCodeInstruction()));
		
		// Print normal trace info
		__ps.printf("  - InFrm: %s%n", trace.toString());
		
		// Print instruction arguments
		__ps.print("  - OpArg: (");
		for (int i = 0, n = opargs.length; i < n; i++)
		{
			if (i > 0)
				__ps.print(", ");
			
			__ps.printf("%d [%xh]", opargs[i], opargs[i]);
		}
		__ps.println(")");
		
		// Do not print the large number of final registers that are zero
		int maxregister = cpuregs.length - 1;
		while (maxregister > 0 && cpuregs[maxregister] == 0)
			maxregister--;
		
		// Print CPU registers
		__ps.print("  - CPU+g:[");
		int didonline = 0;
		for (int i = 0; i <= maxregister; i++)
		{
			// Put local registers on a new line
			if (i == NativeCode.LOCAL_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+l:[");
				didonline = 0;
			}
			
			// Start the arguments as well
			else if (i == NativeCode.ARGUMENT_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+a:[");
				didonline = 0;
			}
			
			// Other formatting
			else if (i > 0)
			{
				// Comma these
				if (didonline < 6)
					__ps.print(", ");
					
				// Reset count
				else
				{
					__ps.printf("%n  -   ...:.");
					didonline = 0;
				}
			}
			
			// Known register name?
			String knownreg = null;
			switch (i)
			{
				case NativeCode.ZERO_REGISTER:
					knownreg = "zer";
					break;
				
				case NativeCode.RETURN_REGISTER:
					knownreg = "rv1";
					break;
				
				case NativeCode.RETURN_REGISTER + 1:
					knownreg = "rv2";
					break;
				
				case NativeCode.EXCEPTION_REGISTER:
					knownreg = "exc";
					break;
				
				case NativeCode.STATIC_FIELD_REGISTER:
					knownreg = "sfp";
					break;
				
				case NativeCode.THREAD_REGISTER:
					knownreg = "thr";
					break;
				
				case NativeCode.POOL_REGISTER:
					knownreg = "cpl";
					break;
				
				case NativeCode.NEXT_POOL_REGISTER:
					knownreg = "npl";
					break;
				
				case NativeCode.ARGUMENT_REGISTER_BASE:
					knownreg = "a0t";
					break;
			}
			
			// Show a value
			int val = cpuregs[i];
			
			// Print out
			__ps.printf("%3s=%8xh", (knownreg != null ? knownreg :
			String.format("r%02d", i)), cpuregs[i]);
			
			// Count line up
			didonline++;
		}
		__ps.println("]");
		
		// Print call arguments, if any
		if (callargs != null)
		{
			__ps.print("  - CallA: (");
			for (int i = 0, n = callargs.length; i < n; i++)
			{
				if (i > 0)
					__ps.print(", ");
				
				__ps.printf("%xh", callargs[i]);
			}
			__ps.println(")");
		}
		
		/*
		PrintStream out = System.err;
		
		// Limit class name
		CallTraceElement trace = this.trace(__nf);
		String cname = "" + trace.className();
		int nl;
		if ((nl = cname.length()) > 20)
			cname = cname.substring(nl - 20, nl);
		
		// Print Header (with location info)
		out.printf("***** @%08x %-19.19s/%10.10s | L%-4d/J%-3d %20.20s::%s %n",
			__nf._pc,
			NativeInstruction.mnemonic(__op),
			InstructionMnemonics.toString(trace.byteCodeInstruction()),
			trace.line(),
			trace.byteCodeAddress(),
			cname,
			trace.methodName() + ":" + trace.methodDescriptor());
		
		// Is this an invoke?
		boolean isinvoke = (__op == NativeInstructionType.INVOKE ||
			__op == NativeInstructionType.SYSTEM_CALL);
		
		// Arguments to print, invocations get 1 (pc) + register list
		int naf = (isinvoke ? 1 + __reglist.length:
			__af.length);
		
		// Used to modify some calls
		int encoding = NativeInstruction.encoding(__op);
		
		// Print out arguments to the call
		out.printf("  A:[");
		for (int i = 0, n = naf; i < n; i++)
		{
			int iv = (isinvoke ? (i == 0 ? __args[i] : __reglist[i - 1]) :
				__args[i]);
			
			// Comma
			if (i > 0)
				out.print(", ");
			
			// Can be special?
			boolean canspec = true;
			if (encoding == NativeInstructionType.DEBUG_ENTRY ||
				encoding == NativeInstructionType.DEBUG_POINT ||
				(encoding == NativeInstructionType.IF_ICMP &&
					i == 2) ||
				(encoding == NativeInstructionType.MATH_CONST_INT &&
					i == 1) ||
				(encoding == NativeInstructionType.IFEQ_CONST &&
					i == 1) ||
				(encoding == NativeInstructionType.ATOMIC_INT_INCREMENT &&
					i == 1) ||
				(encoding == NativeInstructionType.
					ATOMIC_INT_DECREMENT_AND_GET && i == 2) ||
				(encoding == NativeInstructionType.MEMORY_OFF_ICONST &&
					i == 2) ||
				(encoding == NativeInstructionType.LOAD_POOL && i == 0))
				canspec = false;
			
			// Is this a special register?
			String spec = null;
			if (canspec)
				switch (iv)
				{
					case NativeCode.ZERO_REGISTER:
						spec = "zero";
						break;
					
					case NativeCode.RETURN_REGISTER:
						spec = "return1";
						break;
					
					case NativeCode.RETURN_REGISTER + 1:
						spec = "return2";
						break;
					
					case NativeCode.EXCEPTION_REGISTER:
						spec = "exception";
						break;
					
					case NativeCode.STATIC_FIELD_REGISTER:
						spec = "sfieldptr";
						break;
					
					case NativeCode.THREAD_REGISTER:
						spec = "thread";
						break;
					
					case NativeCode.POOL_REGISTER:
						spec = "pool";
						break;
					
					case NativeCode.NEXT_POOL_REGISTER:
						spec = "nextpool";
						break;
					
					case NativeCode.ARGUMENT_REGISTER_BASE:
						spec = "a0/this";
						break;
				}
			
			// Print special register
			if (spec != null)
				out.printf("%10.10s", spec);
			else
				out.printf("%10d", iv);
		}
		out.print("] | ");
		
		// And register value
		out.printf("V:[");
		int[] registers = __nf._registers;
		for (int i = 0, n = naf; i < n; i++)
		{
			int iv = (isinvoke ? (i == 0 ? __args[i] : __reglist[i - 1]) :
				__args[i]);
				
			if (i > 0)
				out.print(", ");
			
			// Load register value
			if (iv < 0 || iv >= registers.length)
				out.print("----------");
			else
				out.printf("%+10d", registers[iv]);
		}
		out.println("]");
		*/
	}
	
	/**
	 * Creates an execution slice of the given frame information.
	 *
	 * @param __cte The call trace information.
	 * @param __nf The native frame.
	 * @param __op The operand.
	 * @param __args The arguments.
	 * @param __argslen Arguments available.
	 * @param __reglist The register list for method calls.
	 * @return The execution slice.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public static final ExecutionSlice of(CallTraceElement __cte,
		NativeCPU.Frame __nf, int __op, int[] __args, int __argslen,
		int[] __reglist)
		throws NullPointerException
	{
		if (__nf == null || __args == null)
			throw new NullPointerException("NARG");
		
		return new ExecutionSlice(__cte,
			__nf._registers,
			__op,
			__args,
			__argslen,
			__reglist);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/MachineState.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.emulator.profiler.ProfilerSnapshot;

/**
 * This contains the machine state.
 *
 * @since 2019/06/19
 */
public final class MachineState
{
	/** The virtual machine memory. */
	protected final WritableMemory memory;
	
	/** The profiler snapshot to write to. */
	protected final ProfilerSnapshot profiler;
	
	/** Was the supervisor okay? */
	private volatile boolean _supervisorokay;
	
	/**
	 * Initializes the machine state.
	 *
	 * @param __mem The memory state.
	 * @param __pf The profiler, this is optional.
	 * @throws NullPointerException If no memory was specified.
	 * @since 2019/12/28
	 */
	public MachineState(WritableMemory __mem, ProfilerSnapshot __pf)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.profiler = __pf;
	}
	
	/**
	 * Flags that the supervisor booted okay.
	 *
	 * @since 2019/06/19
	 */
	public final void flagSupervisorOkay()
	{
		synchronized (this)
		{
			this._supervisorokay = true;
		}
	}
	
	/**
	 * Has the supervisor initialized correctly?
	 *
	 * @return If the supervisor initialized it was okay.
	 * @since 2019/06/19
	 */
	public final boolean isSupervisorOkay()
	{
		synchronized (this)
		{
			return this._supervisorokay;
		}
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/Memory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This represents the starting region of memory.
 *
 * @since 2019/04/21
 */
public interface Memory
{
	/**
	 * The starting region of this memory.
	 *
	 * @return The starting region of this memory.
	 * @since 2019/04/21
	 */
	int memRegionOffset();
	
	/**
	 * The length of this memory region.
	 *
	 * @return The memory region length.
	 * @since 2019/04/21
	 */
	int memRegionSize();
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/NativeCPU.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SupervisorPropertyIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.emulator.vm.VMException;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.InvalidInstructionException;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Deque;
import java.util.LinkedList;
import cc.squirreljme.emulator.profiler.ProfiledThread;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;

/**
 * This represents a native CPU which may run within its own thread to
 * execute code that is running from within the virtual machine.
 *
 * @since 2019/04/21
 */
public final class NativeCPU
	implements Runnable
{
	/**
	 * {@squirreljme.property cc.squirreljme.summercoat.debug=boolean
	 * Should SummerCoat print lots of debugging information?}
	 */
	public static final boolean ENABLE_DEBUG =
		Boolean.getBoolean("cc.squirreljme.summercoat.debug");
	
	/** Maximum amount of CPU registers. */
	public static final int MAX_REGISTERS =
		64;
	
	/** The size of the method cache. */
	public static final int METHOD_CACHE =
		2048;
	
	/** Spill over protection for the cache. */
	public static final int METHOD_CACHE_SPILL =
		1024;
	
	/** The number of execution slices to store. */
	public static final int MAX_EXECUTION_SLICES =
		32;
	
	/** The maximum number of popped slices to store. */
	public static final int MAX_POPPED_SLICE_STORE =
		8;
	
	/** Threshhold for too many debug points */
	private static final int _POINT_THRESHOLD =
		65536;
	
	/** The machine state. */
	protected final MachineState state;
	
	/** The memory to read/write from. */
	protected final WritableMemory memory;
	
	/** The profiler to use. */
	protected final ProfiledThread profiler;
	
	/** Virtual CPU id. */
	protected final int vcpuid;
	
	/** Stack frames. */
	private final LinkedList<Frame> _frames =
		new LinkedList<>();
	
	/** System call error states for this CPU. */
	private final int[] _syscallerrors =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/** Super visor properties. */
	private final int[] _supervisorproperties =
		new int[SupervisorPropertyIndex.NUM_PROPERTIES];
	
	/** Execution slices which came from the popped frame. */
	private final Deque<Deque<ExecutionSlice>> _sopf =
		(NativeCPU.ENABLE_DEBUG ? new LinkedList<Deque<ExecutionSlice>>() : null);
	
	/** IPC Exception register. */
	private int _ipcexception;
	
	/**
	 * Initializes the native CPU.
	 *
	 * @param __ms The machine state.
	 * @param __mem The memory space.
	 * @param __ps The profiler to use.
	 * @param __vcid Virtual CPU id.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public NativeCPU(MachineState __ms, WritableMemory __mem, int __vcid,
		ProfilerSnapshot __ps)
		throws NullPointerException
	{
		if (__ms == null || __mem == null)
			throw new NullPointerException("NARG");
		
		this.state = __ms;
		this.memory = __mem;
		this.vcpuid = __vcid;
		this.profiler = (__ps == null ? null :
			__ps.measureThread("cpu-" + __vcid));
	}
	
	/**
	 * Enters the given frame for the given address.
	 *
	 * @param __pc The address of the frame.
	 * @param __args Arguments to the frame
	 * @return The newly created frame.
	 * @since 2019/04/21
	 */
	public final Frame enterFrame(int __pc, int... __args)
	{
		// Old frame, to source globals from
		LinkedList<Frame> frames = this._frames;
		Frame lastframe = frames.peekLast();
		
		// Setup new frame
		Frame rv = new Frame();
		rv._pc = __pc;
		rv._entrypc = __pc;
		rv._lastpc = __pc;
		
		// Add to frame list
		frames.addLast(rv);
		
		// Seed initial registers, if valid
		int[] dest = rv._registers;
		if (lastframe != null)
		{
			// Copy globals
			int[] src = lastframe._registers;
			for (int i = 0; i < NativeCode.LOCAL_REGISTER_BASE; i++)
				dest[i] = src[i];
			
			// Set the pool register to the next pool register value
			dest[NativeCode.POOL_REGISTER] =
				src[NativeCode.NEXT_POOL_REGISTER];
			
			// Copy task register.
			rv._taskid = lastframe._taskid;
		}
		
		// Copy the arguments to the argument slots
		for (int i = 0, o = NativeCode.ARGUMENT_REGISTER_BASE,
			n = __args.length; i < n; i++, o++)
			dest[o] = __args[i];
		
		// Clear zero
		dest[0] = 0;
		
		// Use this frame
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void run()
	{
		this.run(0);
	}
	
	/**
	 * Runs anything after this frame.
	 *
	 * @param __fl The frame limit.
	 * @since 2019/06/13
	 */
	public final void run(int __fl)
	{
		try
		{
			this.runWithoutCatch(0);
		}
		
		// Failed
		catch (VMException|InvalidInstructionException e)
		{
			// Spacer
			System.err.println("********************************************");
			
			// Only print execution slices if debugging is enabled
			if (NativeCPU.ENABLE_DEBUG)
			{
				// Each frame has its own slices
				for (Frame l : this._frames)
				{
					// Traces for this frame
					System.err.print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
					System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
					System.err.printf(">>>>>>>>>>>> %s%n", this.trace(l));
					
					// Print all the various execution slices
					Deque<ExecutionSlice> execslices = l._execslices;
					System.err.printf("Printing the last %d instructions:%n",
						execslices.size());
					while (!execslices.isEmpty())
						execslices.removeFirst().print(System.err);
					
					// Spacer
					System.err.println();
				}
				
				// Spacer
				System.err.println();
				
				// If there were any execution slices that came from the
				// method we called, print them out.
				Deque<Deque<ExecutionSlice>> sopf = this._sopf;
				if (sopf != null)
				{
					// Traces for this frame
					System.err.print("++++++++++++++++++++++++++++++++++++");
					System.err.println("++++++++++++++++++++++++++++++++++++");
					
					// Print all of them
					while (!sopf.isEmpty())
					{
						// Spacer
						System.err.println(
							"++++++++++++++++++++++++++++++++++++++++++++");
						System.err.println("Slices of a popped frame:");
						
						// Print out
						Deque<ExecutionSlice> qq = sopf.removeFirst();
						while (!qq.isEmpty())
							qq.removeFirst().print(System.err);
						
						// Spacer
						System.err.println();
					}
				}
					
				// Spacer
				System.err.println(
					"--------------------------------------------");
			}
			
			// Print the call trace
			CallTraceElement[] calltrace = this.trace();
			System.err.println("Call trace:");
			for (CallTraceElement l : calltrace)
				System.err.printf("    %s%n", l);
			System.err.println();
			
			// Spacer
			System.err.println("********************************************");
			
			// {@squirreljme.error AE02 Virtual machine exception. (The failing
			// instruction)}
			throw new VMException(
				String.format("AE02 %s", this.traceTop()), e);
		}
	}
	
	/**
	 * Runs anything after this frame, no catching is performed.
	 *
	 * @param __fl The frame limit.
	 * @since 2019/04/21
	 */
	public final void runWithoutCatch(int __fl)
	{
		// Read the CPU stuff
		final WritableMemory memory = this.memory;
		boolean reload = true;
		ProfiledThread profiler = this.profiler;
		
		// Frame specific info
		Frame nowframe = null;
		int[] lr = null;
		int pc = -1;
		
		// Per operation handling
		final int[] args = new int[6];
		
		// Method cache to reduce tons of method reads
		final byte[] icache = new byte[NativeCPU.METHOD_CACHE];
		int lasticache = -(NativeCPU.METHOD_CACHE_SPILL + 1);
		
		// Debug point counter
		int pointcounter = 0;
		
		// Execution is effectively an infinite loop
		LinkedList<Frame> frames = this._frames;
		for (int frameat = frames.size(), lastframe = -1; frameat >= __fl;
			frameat = frames.size())
		{
			// Reload parameters?
			if ((reload |= (lastframe != frameat)))
			{
				// Before dumping this frame, store old info
				if (nowframe != null)
					nowframe._pc = pc;
				
				// Get current frame, stop execution if there is nothing
				// left to execute
				nowframe = frames.peekLast();
				if (nowframe == null)
					return;
				
				// Load stuff needed for execution
				lr = nowframe._registers;
				pc = nowframe._pc;
				
				// Used to auto-detect frame change
				lastframe = frameat;
				
				// No longer reload information
				reload = false;
			}
			
			// For a bit faster execution of the method, cache a bunch of
			// the code that is being executed in memory. Constantly performing
			// the method calls to read single bytes of memory is a bit so, so
			// this should hopefully improve performance slightly.
			int pcdiff = pc - lasticache;
			if (pcdiff < 0 || pcdiff >= NativeCPU.METHOD_CACHE_SPILL)
			{
				memory.memReadBytes(pc, icache, 0, NativeCPU.METHOD_CACHE);
				lasticache = pc;
			}
			
			// Calculate last PC base address
			int bpc = pc - lasticache;
			
			// Always set PC address for debugging frames
			nowframe._pc = pc;
			
			// Read operation
			nowframe._lastpc = pc;
			int op = icache[bpc] & 0xFF;
			
			// Reset all input arguments
			for (int i = 0, n = args.length; i < n; i++)
				args[i] = 0;
			
			// Register list, just one is used everywhere
			int[] reglist = null;
			
			// Load arguments for this instruction
			ArgumentFormat[] af = NativeInstruction.argumentFormat(op);
			int rargp = bpc + 1;
			for (int i = 0, n = af.length; i < n; i++)
				switch (af[i])
				{
					// Variable sized entries, may be pool values
					case VUINT:
					case VUREG:
					case VPOOL:
					case VJUMP:
						{
							// Long value?
							int base = (icache[rargp++] & 0xFF);
							if ((base & 0x80) != 0)
							{
								base = ((base & 0x7F) << 8);
								base |= (icache[rargp++] & 0xFF);
							}
							
							// Set
							if (af[i] == ArgumentFormat.VJUMP)
								args[i] = (short)(base |
									((base & 0x4000) << 1));
							else
								args[i] = base;
							
							// {@squirreljme.error AE03 Reference to register
							// which is out of range of maximum number of
							// registers. (The register index)}
							if (af[i] == ArgumentFormat.VUREG &&
								(base < 0 || base >= NativeCode.MAX_REGISTERS))
								throw new VMException("AE03 " + base);
						}
						break;
					
					// Register list.
					case REGLIST:
						{
							// Wide
							int count = (icache[rargp++] & 0xFF);
							if ((count & 0x80) != 0)
							{
								count = ((count & 0x7F) << 8) |
									(icache[rargp++] & 0xFF);
								
								// Read values
								reglist = new int[count];
								for (int r = 0; r < count; r++)
									reglist[r] =
										((icache[rargp++] & 0xFF) << 8) |
										(icache[rargp++] & 0xFF);
							}
							// Narrow
							else
							{
								reglist = new int[count];
								
								// Read values
								for (int r = 0; r < count; r++)
									reglist[r] = (icache[rargp++] & 0xFF);
							}
						}
						break;
					
					// 32-bit integer/float
					case INT32:
					case FLOAT32:
						args[i] = ((icache[rargp++] & 0xFF) << 24) |
							((icache[rargp++] & 0xFF) << 16) |
							((icache[rargp++] & 0xFF) << 8) |
							((icache[rargp++] & 0xFF));
						break;
					
					default:
						throw new todo.OOPS(af[i].name());
				}
			
			// Determine the encoding
			int encoding = NativeInstruction.encoding(op);
			
			// Set first point flag
			if (encoding == NativeInstructionType.DEBUG_ENTRY)
				pointcounter = 0;
			
			// Only track slices if we are debugging
			if (NativeCPU.ENABLE_DEBUG)
			{
				// Get slice for this instruction
				ExecutionSlice el = ExecutionSlice.of(this.trace(nowframe),
					nowframe, op, args, af.length, reglist);
				
				// Add to previous instructions, do not exceed slice limits
				Deque<ExecutionSlice> execslices = nowframe._execslices;
				if (execslices.size() >= NativeCPU.MAX_EXECUTION_SLICES)
					execslices.removeFirst();
				execslices.addLast(el);
			
				// In debug points check to see if the execution seems to
				// be stuck in here (really long methods)
				if (encoding == NativeInstructionType.DEBUG_POINT)
				{
					// Seems to be stuck?
					boolean doprint = false;
					if (pointcounter++ >= NativeCPU._POINT_THRESHOLD)
					{
						doprint = true;
						pointcounter = 0;
					}
					
					// Print the point?
					if (doprint)
						el.print();
				}
			}
			
			// By default the next instruction is the address after all
			// arguments have been read
			int nextpc = lasticache + rargp;
			
			// Handle the operation
			switch (encoding)
			{
					// CPU Breakpoint
				case NativeInstructionType.BREAKPOINT:
					// Breakpoints only function when debugging is enabled
					if (NativeCPU.ENABLE_DEBUG)
					{
						// If profiling, immediately enter the frame to signal
						// a break point then exit it
						if (profiler != null)
						{
							profiler.enterFrame("<breakpoint>", "<breakpoint>",
								"<breakpoint>");
							profiler.exitFrame();
						}
						
						// {@squirreljme.error AE04 CPU breakpoint hit.}
						throw new VMException("AE04");
					}
					break;
				
					// Debug entry point of method
				case NativeInstructionType.DEBUG_ENTRY:
					this.__debugEntry(nowframe, args[0], args[1], args[2],
						args[3]);
					break;
					
					// Debug exit of method
				case NativeInstructionType.DEBUG_EXIT:
					this.__debugExit(nowframe);
					break;
					
					// Debug point in method.
				case NativeInstructionType.DEBUG_POINT:
					this.__debugPoint(nowframe, args[0], args[1], args[2]);
					break;
					
					// Atomic compare, get, and set
				case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
					synchronized (memory)
					{
						// Read parameters
						int check = lr[args[0]],
							set = lr[args[2]],
							addr = lr[args[3]],
							off = args[4];
						
						// Read value here
						int read = memory.memReadInt(addr + off);
						
						// Is the value the same?
						if (read == check)
							memory.memWriteInt(addr + off, set);
						
						// Set the read value before check
						lr[args[1]] = read;
						
						// Debug
						/*if (ENABLE_DEBUG)
							todo.DEBUG.note("%08x(%d) = %d ? %d = %d",
								addr, off, read, check, set);*/
					}
					break;
				
					// Atomic decrement and get
				case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
					synchronized (memory)
					{
						// The address to load from/store to
						int addr = lr[args[1]],
							off = args[2];
						
						// Read, increment, and store
						int newval;
						memory.memWriteInt(addr + off,
							(newval = memory.memReadInt(addr + off) - 1));
						
						// Store the value after the decrement
						lr[args[0]] = newval;
					}
					break;
					
					// Atomic increment
				case NativeInstructionType.ATOMIC_INT_INCREMENT:
					synchronized (memory)
					{
						// The address to load from/store to
						int addr = lr[args[0]],
							off = args[1];
						
						// Read, increment, and store
						int oldv;
						memory.memWriteInt(addr + off,
							(oldv = memory.memReadInt(addr + off)) + 1);
						
						// Debug
						/*if (ENABLE_DEBUG)
							todo.DEBUG.note("%08x(%d) += %d + 1 = %d",
								addr, off, oldv, oldv + 1);*/
					}
					break;
				
					// Copy
				case NativeInstructionType.COPY:
					lr[args[1]] = lr[args[0]];
					break;
					
					// Compare integers and possibly jump
				case NativeInstructionType.IF_ICMP:
					{
						// Parts
						int a = lr[args[0]],
							b = lr[args[1]];
						
						// Compare
						boolean branch;
						CompareType ct;
						switch ((ct = CompareType.of(op & 0b111)))
						{
							case EQUALS:
								branch = (a == b); break;
							case NOT_EQUALS:
								branch = (a != b); break;
							case LESS_THAN:
								branch = (a < b); break;
							case LESS_THAN_OR_EQUALS:
								branch = (a <= b); break;
							case GREATER_THAN:
								branch = (a > b); break;
							case GREATER_THAN_OR_EQUALS:
								branch = (a >= b); break;
							case TRUE:
								branch = true; break;
							case FALSE:
								branch = false; break;
							
							default:
								throw new todo.OOPS();
						}
						
						// Branching?
						if (branch)
							nextpc = pc + args[2];
					}
					break;
					
					// If value equal to constant
				case NativeInstructionType.IFEQ_CONST:
					{
						// Branching? Remember that jumps are relative
						if (lr[args[0]] == args[1])
							nextpc = pc + args[2];
					}
					break;
					
					// Invoke a pointer
				case NativeInstructionType.INVOKE:
					{
						// Load values into the register list
						for (int i = 0, n = reglist.length; i < n; i++)
							reglist[i] = lr[reglist[i]];
						
						// Enter the frame
						this.enterFrame(lr[args[0]], reglist);
						
						// Entering some other frame
						reload = true;
						
						// Clear point counter
						pointcounter = 0;
					}
					break;
					
					// Load value from int array
				case NativeInstructionType.LOAD_FROM_INTARRAY:
					{
						// Get arguments
						int addr = lr[args[1]],
							indx = lr[args[2]],
							rout = args[0];
						
						// Calculate array index offset
						int ioff = Constants.ARRAY_BASE_SIZE + (indx * 4);
						
						// Read value
						lr[rout] = memory.memReadInt(addr + ioff);
					}
					break;
					
					// Load from constant pool
				case NativeInstructionType.LOAD_POOL:
					lr[args[1]] = memory.memReadInt(
						lr[NativeCode.POOL_REGISTER] + (args[0] * 4));
					break;
					
					// Integer math
				case NativeInstructionType.MATH_CONST_INT:
				case NativeInstructionType.MATH_REG_INT:
					{
						// Parts
						int a = lr[args[0]],
							b = (((op & 0x80) != 0) ? args[1] : lr[args[1]]),
							c;
						
						// Operation to execute
						MathType mt;
						switch ((mt = MathType.of(op & 0xF)))
						{
							case ADD:		c = a + b; break;
							case SUB:		c = a - b; break;
							case MUL:		c = a * b; break;
							case DIV:		c = a / b; break;
							case REM:		c = a % b; break;
							case NEG:		c = -a; break;
							case SHL:		c = a << b; break;
							case SHR:		c = a >> b; break;
							case USHR:		c = a >>> b; break;
							case AND:		c = a & b; break;
							case OR:		c = a | b; break;
							case XOR:		c = a ^ b; break;
							case SIGNX8:	c = (byte)a; break;
							case SIGNX16:	c = (short)a; break;
							
							case CMPL:
							case CMPG:
								c = (a < b ? -1 : (a == b ? 0 : 1));
								break;
							
							default:
								throw new todo.OOPS();
						}
						
						// Set result
						lr[args[2]] = c;
					}
					break;
				
					// Read off memory
				case NativeInstructionType.MEMORY_OFF_REG:
				case NativeInstructionType.MEMORY_OFF_REG_JAVA:
				case NativeInstructionType.MEMORY_OFF_ICONST:
				case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
					{
						// Is this Java?
						boolean isjava = (encoding == NativeInstructionType.
							MEMORY_OFF_REG_JAVA || encoding ==
							NativeInstructionType.MEMORY_OFF_ICONST_JAVA);
						
						// Is this a load operation?
						boolean load = ((op & 0b1000) != 0);
						
						// The address to load from/store to
						int base = lr[args[1]],
							offs = (((op & 0x80) != 0) ? args[2] :
								lr[args[2]]),
							addr = base + offs;
						
						// Loads
						DataType dt = DataType.of(op & 0b0111);
						if (load)
						{
							// Load value
							int v;
							switch (dt)
							{
								case BYTE:
									v = (byte)memory.memReadByte(addr);
									break;
									
								case SHORT:
									v = (short)memory.memReadShort(addr);
									break;
									
								case CHARACTER:
									v = memory.memReadShort(addr) & 0xFFFF;
									break;
									
								case OBJECT:
								case INTEGER:
								case FLOAT:
									v = memory.memReadInt(addr);
									break;
									
									// Unknown
								default:
									throw new todo.OOPS(dt.name());
							}
							
							// Set value
							lr[args[0]] = v;
							
							// Debug
							/*if (ENABLE_DEBUG)
								todo.DEBUG.note(
									"%c %08x+%d (%08x) -> %d (%08x)",
									(isjava ? 'J' : 'N'),
									base, offs, addr, v, v);*/
						}
						
						// Stores
						else
						{
							// Value to store
							int v = lr[args[0]];
							
							// Store
							switch (dt)
							{
								case BYTE:
									memory.memWriteByte(addr, v);
									break;
									
								case SHORT:
									memory.memWriteShort(addr, v);
									break;
									
								case CHARACTER:
									memory.memWriteShort(addr, v);
									break;
								
								case OBJECT:
								case INTEGER:
								case FLOAT:
									memory.memWriteInt(addr, v);
									break;
									
									// Unknown
								default:
									throw new todo.OOPS(dt.name());
							}
							
							// Debug
							/*if (ENABLE_DEBUG)
								todo.DEBUG.note(
									"%c %08x+%d (%08x) <- %d (%08x)",
									(isjava ? 'J' : 'N'),
									base, offs, addr, v, v);*/
						}
					}
					break;
					
					// Return from method call
				case NativeInstructionType.RETURN:
					{
						// Go up frame
						Frame was = frames.removeLast(),
							now = frames.peekLast();
						
						// {@squirreljme.error AE0m Return from the main frame
						// without using a system call to exit.
						// (The return value pair; The exception register)}
						if (now == null)
							throw new VMException(String.format(
								"AE0m [%d, %d] @%08x",
								was._registers[NativeCode.RETURN_REGISTER],
								was._registers[NativeCode.RETURN_REGISTER + 1],
								was._registers[
									NativeCode.EXCEPTION_REGISTER]));
						
						// Capture the execution slices of this popped frame
						Deque<Deque<ExecutionSlice>> sopf = this._sopf;
						if (sopf != null)
						{
							// Add these slices
							sopf.addLast(was._execslices);
							
							// If there are too many, remove them
							if (sopf.size() > NativeCPU.MAX_POPPED_SLICE_STORE)
								sopf.removeFirst();
						}
						
						// We are going back onto a frame so copy all
						// the globals which were set since they are meant to
						// be global!
						int[] wr = was._registers,
							nr = now._registers;
						
						// Copy globals
						for (int i = 0; i < NativeCode.LOCAL_REGISTER_BASE;
							i++)
						{
							// Ignore the pool register because if it is
							// replaced then it will just explode and
							// cause issues for the parent method
							if (i == NativeCode.POOL_REGISTER)
								continue;
							
							// Reset the next pool register
							else if (i == NativeCode.NEXT_POOL_REGISTER)
							{
								nr[i] = 0;
								break;
							}
							
							// Copy otherwise
							else
								nr[i] = wr[i];
						}
						
						// A reload is done as the frame has changed
						reload = true;
						
						// Clear point counter
						pointcounter = 0;
						
						// Debug
						/*if (ENABLE_DEBUG)
							System.err.printf(
								"<<<< %08x <<<<<<<<<<<<<<<<<<<<<<%n",
								(now != null ? now._pc : 0));*/
					}
					break;
					
					// Store to constant pool
				case NativeInstructionType.STORE_POOL:
					memory.memWriteInt(lr[NativeCode.POOL_REGISTER] +
						(args[0] * 4), lr[args[1]]);
					break;
					
					// Store value into integer array
				case NativeInstructionType.STORE_TO_INTARRAY:
					{
						// Get arguments
						int addr = lr[args[1]],
							indx = lr[args[2]],
							rinn = args[0];
						
						// Calculate array index offset
						int ioff = Constants.ARRAY_BASE_SIZE + (indx * 4);
						
						// Read value
						memory.memWriteInt(addr + ioff, lr[rinn]);
					}
					break;
				
					// System call
				case NativeInstructionType.SYSTEM_CALL:
					{
						// The arguments to the system calls are in registers
						// so they must be extracted first before they can be
						// known
						int nrl = reglist.length;
						int[] sargs = new int[nrl];
						for (int i = 0; i < nrl; i++)
							sargs[i] = lr[reglist[i]];
						
						// Get the system call ID
						short syscallid = (short)lr[args[0]];
						
						// Handle system call as is from the supervisor
						// IPC Exception load/store is not included
						// IPC Calls are always virtualized even in supervisor.
						Frame was = frames.getLast();
						if ((was._taskid == 0 ||
							syscallid == SystemCallIndex.EXCEPTION_LOAD ||
							syscallid == SystemCallIndex.EXCEPTION_STORE) &&
							syscallid != SystemCallIndex.IPC_CALL)
						{
							// If profiling, profile the handling of the
							// system call in a sub-frame
							if (profiler != null)
								profiler.enterFrame("<syscall>",
									Integer.toString(syscallid),
									"(IIIIIIII)I");
							
							// Set the return register to whatever system call
							// was used
							try
							{
								long rv = this.__sysCall(syscallid, sargs);
								
								lr[NativeCode.RETURN_REGISTER] = (int)rv;
								lr[NativeCode.RETURN_REGISTER + 1] =
									(int)(rv >>> 32);
							}
							
							// If profiling, that frame needs to exit always!
							finally
							{
								if (profiler != null)
									profiler.exitFrame();
							}
						}
						
						// Otherwise jump into supervisor and handle the
						// system call on behalf of the task
						else
						{
							// Enter the frame
							int[] svp = this._supervisorproperties;
							Frame f = this.enterFrame(
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_METHOD_HANDLER]);
							
							// Set frame's task ID to zero
							f._taskid = 0;
							
							// Set required registers
							f._registers[NativeCode.POOL_REGISTER] =
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_METHOD_POOL_POINTER];
							f._registers[NativeCode.STATIC_FIELD_REGISTER] =
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_STATIC_FIELD_POINTER];
							
							// Setup call: taskid + oldsfp + sysid + 8 syscall
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 0] =
								was._taskid;
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 1] =
								was._registers[
									NativeCode.STATIC_FIELD_REGISTER];
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 2] =
								syscallid;
							
							// Forward system call arguments
							for (int x = 0, xn = sargs.length; x < xn; x++)
								f._registers[NativeCode.ARGUMENT_REGISTER_BASE
									+ 3 + x] = sargs[x];
							
							// Setup for frame enter
							reload = true;
							pointcounter = 0;
						}
					}
					break;
					
					// {@squirreljme.error AE0n Invalid instruction.}
				default:
					throw new VMException("AE0n " +
						NativeInstruction.mnemonic(op));
			}
			
			// Set next PC address
			pc = nextpc;
		}
	}
	
	/**
	 * Returns the trace of the current execution.
	 *
	 * @return The current trace.
	 * @since 2019/04/22
	 */
	public final CallTraceElement[] trace()
	{
		LinkedList<Frame> frames = this._frames;
		
		// Need to store all the frames
		int numframes = frames.size();
		CallTraceElement[] rv = new CallTraceElement[numframes];
		
		// Make the newest frame first!
		for (int i = numframes - 1, o = 0; i >= 0; i--, o++)
			rv[o] = this.trace(frames.get(i));
		
		return rv;
	}
	
	/**
	 * Returns the trace for the given frame.
	 *
	 * @param __f The frame to trace.
	 * @return The trace of this frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	public final CallTraceElement trace(Frame __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Build trace
		return new CallTraceElement(
			__f._inclass,
			__f._inmethodname,
			__f._inmethodtype,
			__f._pc, __f._insourcefile,
			__f._inline,
			__f._injop,
			__f._injpc,
			__f._taskid);
	}
	
	/**
	 * Traces the top most frame.
	 *
	 * @return The top most frame.
	 * @since 2019/06/13
	 */
	public final CallTraceElement traceTop()
	{
		LinkedList<Frame> frames = this._frames;
		
		// Only look at the top most frame
		Frame top = frames.peekLast();
		if (top == null)
			return new CallTraceElement();
		return this.trace(top);
	}
	
	/**
	 * Sets the frame information string from the given pool entries.
	 *
	 * @param __f The frame.
	 * @param __pcl The class string from the pool.
	 * @param __pmn The method name from the pool.
	 * @param __pmt The method type from the pool.
	 * @param __psf The current source file.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	private final void __debugEntry(Frame __f, int __pcl, int __pmn, int __pmt,
		int __psf)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Get the pool address
		int pooladdr = __f._registers[NativeCode.POOL_REGISTER];
		
		int icl = this.memory.memReadInt(pooladdr + (__pcl * 4)),
			imn = this.memory.memReadInt(pooladdr + (__pmn * 4)),
			imt = this.memory.memReadInt(pooladdr + (__pmt * 4)),
			isf = this.memory.memReadInt(pooladdr + (__psf * 4));
		
		// Store in state
		__f._inclassp = icl;
		__f._inmethodnamep = imn;
		__f._inmethodtypep = imt;
		__f._insourcefilep = isf;
		
		// Load strings
		String scl, smn, smt, ssf;
		WritableMemory memory = this.memory;
		__f._inclass = 
			(scl = (icl == 0 ? null : this.__loadUtfString(icl)));
		__f._inmethodname = 
			(smn = (imn == 0 ? null : this.__loadUtfString(imn)));
		__f._inmethodtype = 
			(smt = (imt == 0 ? null : this.__loadUtfString(imt)));
		__f._insourcefile = 
			(ssf = (isf == 0 ? null : this.__loadUtfString(isf)));
		
		// Enter it on the profiler
		ProfiledThread profiler = this.profiler;
		if (profiler != null)
			profiler.enterFrame(
				(scl == null ? "<AClass>" : scl),
				(smn == null ? "<AMethod>" : smn),
				(smt == null ? "<AType>" : smt));
	}
	
	/**
	 * Debugs the exit of a frame.
	 *
	 * @param __f The frame to exit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	private final void __debugExit(Frame __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Exit the frame, but if we extra exited then it is very possible
		// that the state can be messed up so do not absolutely destroy the
		// VM stuff
		ProfiledThread profiler = this.profiler;
		if (profiler != null)
			try
			{
				profiler.exitFrame();
			}
			catch (IllegalStateException e)
			{
			}
	}
	
	/**
	 * Sets the debug point in the frame.
	 *
	 * @param __f The frame.
	 * @param __sln The source line.
	 * @param __jop The Java operation.
	 * @param __jpc The Java address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	private final void __debugPoint(Frame __f, int __sln, int __jop, int __jpc)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		__f._inline = __sln;
		__f._injop = __jop;
		__f._injpc = __jpc;
	}
	
	/**
	 * Loads a UTF string from the given memory address.
	 *
	 * @param __addr The address to read from.
	 * @return The resulting string.
	 * @since 2019/05/15
	 */
	private final String __loadUtfString(int __addr)
	{
		// Read length to figure out how long the string is
		WritableMemory memory = this.memory;
		int strlen = memory.memReadShort(__addr) & 0xFFFF;
		
		// Decode string data
		try (DataInputStream dis = new DataInputStream(
			new ReadableMemoryInputStream(memory, __addr, strlen + 2)))
		{
			return dis.readUTF();
		}
		
		// Could not read string, use some other string form
		catch (IOException e)
		{
			return String.format("??? @%08x (len=%d)", __addr, strlen);
		}
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	private final long __sysCall(short __si, int... __args)
	{
		// Error state for the last call of this type
		int[] errors = this._syscallerrors;
		
		// Return value with error value, to set if any
		long rv;
		int err;
		
		// Depends on the system call type
		switch (__si)
		{
				// Check if system call is supported
			case SystemCallIndex.QUERY_INDEX:
				{
					err = 0;
					switch (__args[0])
					{
						case SystemCallIndex.BYTE_ORDER_LITTLE:
						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.EXCEPTION_LOAD:
						case SystemCallIndex.EXCEPTION_STORE:
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.FRAME_TASK_ID_GET:
						case SystemCallIndex.FRAME_TASK_ID_SET:
						case SystemCallIndex.CALL_STACK_HEIGHT:
						case SystemCallIndex.CALL_STACK_ITEM:
						case SystemCallIndex.MEM_SET:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.SUPERVISOR_BOOT_OKAY:
						case SystemCallIndex.SUPERVISOR_PROPERTY_GET:
						case SystemCallIndex.SUPERVISOR_PROPERTY_SET:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
							rv = 1;
							break;
						
						default:
							rv = 0;
							break;
					}
				}
				break;
				
				// Is this little endian?
			case SystemCallIndex.BYTE_ORDER_LITTLE:
				rv = 0;
				err = 0;
				break;
			
				// Get the height of the call stack
			case SystemCallIndex.CALL_STACK_HEIGHT:
				{
					rv = this._frames.size();
					err = 0;
				}
				break;
				
				// Get item on the call stack
			case SystemCallIndex.CALL_STACK_ITEM:
				{
					// Locate frame
					int fr = __args[0];
					LinkedList<Frame> frames = this._frames;
					int numframes = frames.size();
					Frame frame = ((fr < 0 || fr >= numframes) ? null :
						frames.get((numframes - 1) - fr));
					
					// Depends on the ID
					int dx = (frame == null ? -1 : __args[1]);
					switch (dx)
					{
						case CallStackItem.CLASS_NAME:
							err = 0;
							rv = frame._inclassp;
							break;
							
						case CallStackItem.METHOD_NAME:
							err = 0;
							rv = frame._inmethodnamep;
							break;
							
						case CallStackItem.METHOD_TYPE:
							err = 0;
							rv = frame._inmethodtypep;
							break;
						
						case CallStackItem.SOURCE_FILE:
							err = 0;
							rv = frame._insourcefilep;
							break;
							
						case CallStackItem.SOURCE_LINE:
							err = 0;
							rv = frame._inline;
							break;
							
						case CallStackItem.PC_ADDRESS:
							err = 0;
							rv = frame._lastpc;
							break;
							
						case CallStackItem.JAVA_OPERATION:
							err = 0;
							rv = frame._injop;
							break;
							
						case CallStackItem.JAVA_PC_ADDRESS:
							err = 0;
							rv = frame._injpc;
							break;
						
						case CallStackItem.TASK_ID:
							err = 0;
							rv = frame._taskid;
						
							// Not valid
						default:
							rv = 0;
							err = SystemCallError.VALUE_OUT_OF_RANGE;
							break;
					}
				}
				break;
				
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return the stored error code
					synchronized (errors)
					{
						rv = errors[dx];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return last error code, and set new one
					synchronized (errors)
					{
						rv = errors[dx];
						errors[dx] = __args[0];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// IPC Exception load
			case SystemCallIndex.EXCEPTION_LOAD:
				rv = this._ipcexception;
				err = 0;
				break;
				
				// IPC Exception store
			case SystemCallIndex.EXCEPTION_STORE:
				rv = this._ipcexception;
				this._ipcexception = __args[0];
				err = 0;
				break;
				
				// Fatal exit because of incomplete code
			case SystemCallIndex.FATAL_TODO:
				// {@squirreljme.error AE0o Fatal ToDo system call executed.}
				throw new VMToDoException("AE0o");
				
				// Gets the frame task ID
			case SystemCallIndex.FRAME_TASK_ID_GET:
				{
					LinkedList<Frame> frames = this._frames;
					Frame frame = frames.getLast();
					
					// Is fine
					rv = frame._taskid;
					err = 0;
				}
				break;
				
				// Sets the frame task ID
			case SystemCallIndex.FRAME_TASK_ID_SET:
				{
					LinkedList<Frame> frames = this._frames;
					Frame frame = frames.getLast();
					
					// Set
					frame._taskid = __args[0];
					
					// Is fine
					rv = 1;
					err = 0;
				}
				break;
				
				// Sets memory to byte value
			case SystemCallIndex.MEM_SET:
				{
					// Set memory
					WritableMemory memory = this.memory;
					
					// Get parameters
					int addr = __args[0],
						valu = __args[1],
						lens = __args[2];
					
					// Wipe
					for (int i = 0; i < lens; i++)
						memory.memWriteByte(addr + i, valu);
					
					// Is okay
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				{
					rv = 2;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard input
			case SystemCallIndex.PD_OF_STDIN:
				{
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Write single byte to PD
			case SystemCallIndex.PD_WRITE_BYTE:
				{
					// Depends on the stream
					int pd = __args[0];
					OutputStream os = (pd == 1 ? System.out :
						(pd == 2 ? System.err : null));
					
					// Write
					if (os != null)
					{
						try
						{
							os.write(__args[1]);
							
							// Okay
							rv = 1;
							err = 0;
						}
						
						// Failed
						catch (IOException e)
						{
							rv = -1;
							err = SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE;
						}
					}
					
					// Failed
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					// Sleep
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
				
				// Supervisor booted okay!
			case SystemCallIndex.SUPERVISOR_BOOT_OKAY:
				// Flag that this happened!
				this.state.flagSupervisorOkay();
				
				// Is fine
				rv = 0;
				err = 0;
				break;
				
				// Get supervisor property
			case SystemCallIndex.SUPERVISOR_PROPERTY_GET:
				{
					int dx = __args[0];
					
					// Out of range?
					if (dx < 0 || dx >= SupervisorPropertyIndex.NUM_PROPERTIES)
					{
						rv = 0;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Valid
					else
					{
						rv = this._supervisorproperties[dx];
						err = SystemCallError.NO_ERROR;
					}
				}
				break;
				
				// Set supervisor property
			case SystemCallIndex.SUPERVISOR_PROPERTY_SET:
				{
					int dx = __args[0];
					
					// Out of range?
					if (dx < 0 || dx >= SupervisorPropertyIndex.NUM_PROPERTIES)
					{
						rv = 0;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Valid
					else
					{
						this._supervisorproperties[dx] = __args[1];
						
						rv = 0;
						err = SystemCallError.NO_ERROR;
					}
				}
				break;

				// Current wall clock milliseconds.
			case SystemCallIndex.TIME_MILLI_WALL:
				{
					rv = System.currentTimeMillis();
					err = 0;
				}
				break;

				// Current monotonic clock nanoseconds.
			case SystemCallIndex.TIME_NANO_MONO:
				{
					rv = System.nanoTime();
					err = 0;
				}
				break;
				
				// VM information: Memory free bytes
			case SystemCallIndex.VMI_MEM_FREE:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().freeMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory used bytes
			case SystemCallIndex.VMI_MEM_USED:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().totalMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory max bytes
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
			default:
				// Returns no value but sets an error
				rv = 0;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used
				if (__si < 0 || __si >= SystemCallIndex.NUM_SYSCALLS)
					__si = SystemCallIndex.QUERY_INDEX;
				break;
		}
		
		// Set error state as needed
		synchronized (errors)
		{
			errors[__si] = err;
		}
		
		// Use returning value
		return rv;
	}
	
	/**
	 * This represents a single frame in the execution stack.
	 *
	 * @since 2019/04/21
	 */
	public static final class Frame
	{
		/** Execution slices. */
		final Deque<ExecutionSlice> _execslices;
		
		/** Registers for this frame. */
		final int[] _registers =
			new int[NativeCPU.MAX_REGISTERS];
		
		/** The entry PC address. */
		int _entrypc;
		
		/** The PC address for this frame. */
		volatile int _pc;
		
		/** Last executed address. */
		int _lastpc;
		
		/** The executing class. */
		String _inclass;
		
		/** Executing class name pointer. */
		int _inclassp;
		
		/** The executing method name. */
		String _inmethodname;
		
		/** Executing method name pointer. */
		int _inmethodnamep;
		
		/** The executing method type. */
		String _inmethodtype;
		
		/** Executing method type pointer. */
		int _inmethodtypep;
		
		/** Source file. */
		String _insourcefile;
		
		/** Source file pointer. */
		int _insourcefilep;
		
		/** The current line. */
		int _inline;
		
		/** The current Java operation. */
		int _injop;
		
		/** The current Java address. */
		int _injpc;
		
		/** The current task ID. */
		int _taskid;
		
		/**
		 * Potential initialization.
		 */
		{
			this._execslices = (NativeCPU.ENABLE_DEBUG ?
				new LinkedList<ExecutionSlice>() :
				(Deque<ExecutionSlice>)null);
		}
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/RawMemory.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * Raw memory access.
 *
 * @since 2019/04/21
 */
public final class RawMemory
	extends AbstractWritableMemory
{
	/** The memory offset. */
	protected final int offset;
	
	/** The memory size. */
	protected final int size;
	
	/** The memory data. */
	protected final byte[] bytes;
	
	/**
	 * Raw memory space.
	 *
	 * @param __off The offset.
	 * @param __sz The size of this region.
	 * @since 2019/04/21
	 */
	public RawMemory(int __off, int __sz)
	{
		this.offset = __off;
		this.size = __sz;
		this.bytes = new byte[__sz];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadByte(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size)
			return -1;
		
		return (this.bytes[__addr] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadInt(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 3)
			return -1;
		
		byte[] bytes = this.bytes;
		return ((bytes[__addr++] & 0xFF) << 24) |
			((bytes[__addr++] & 0xFF) << 16) |
			((bytes[__addr++] & 0xFF) << 8) |
			(bytes[__addr++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadShort(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 1)
			return -1;
		
		byte[] bytes = this.bytes;
		return (((bytes[__addr++] & 0xFF) << 8) |
			(bytes[__addr++] & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteByte(int __addr, int __v)
	{
		// {@squirreljme.error AE06 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 1)
			throw new VMRuntimeException(String.format("AE06 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteInt(int __addr, int __v)
	{
		// {@squirreljme.error AE07 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 3)
			throw new VMRuntimeException(String.format("AE07 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v >>> 24);
		bytes[__addr++] = (byte)(__v >>> 16);
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteShort(int __addr, int __v)
	{
		// {@squirreljme.error AE08 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 2)
			throw new VMRuntimeException(String.format("AE08 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/ReadableMemory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This interface is used to represent anything which provides memory which
 * can be read.
 *
 * @since 2019/04/21
 */
public interface ReadableMemory
	extends Memory
{
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	int memReadByte(int __addr);
	
	/**
	 * Bulk read of memory bytes.
	 *
	 * @param __ad The address to read from.
	 * @param __b The output bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	void memReadBytes(int __ad, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	int memReadInt(int __addr);
	
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	int memReadShort(int __addr);
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/ReadableMemoryInputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import java.io.InputStream;

/**
 * This is an input stream which can read from readable memory.
 *
 * @since 2019/04/21
 */
public final class ReadableMemoryInputStream
	extends InputStream
{
	/** The input memory. */
	protected final ReadableMemory memory;
	
	/** The base read address. */
	protected final int address;
	
	/** The number of bytes that can be read. */
	protected final int length;
	
	/** The current read offset. */
	private int _at;
	
	/**
	 * Initializes the stream.
	 *
	 * @param __mem The memory.
	 * @param __ad The start address.
	 * @param __ln The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ReadableMemoryInputStream(ReadableMemory __mem, int __ad, int __ln)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.address = __ad;
		this.length = __ln;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int available()
	{
		return this.length - this._at;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read()
	{
		// EOF?
		int at = this._at;
		if (at >= this.length)
			return -1;
		
		// Read
		this._at = at + 1;
		return this.memory.memReadByte(this.address + at) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read(byte[] __b)
		throws NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Used to check bounds
		int at = this._at,
			length = this.length,
			address = this.address;
		
		// Read in all bytes
		ReadableMemory memory = this.memory;
		for (int i = 0; i < __l; i++)
		{
			// EOF?
			if (at >= length)
			{
				this._at = at + i;
				return (i == 0 ? -1 : i);
			}
			
			// Read in
			__b[__o++] = (byte)memory.memReadByte(address + at + i);
		}
		
		// Count
		this._at = at + __l;
		return __l;
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/StaticAllocator.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
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This class is used to assist in static allocation of data.
 *
 * @since 2019/04/24
 */
@Deprecated
public final class StaticAllocator
{
	/** Start address. */
	protected final int base;
	
	/** The current size. */
	private int _size;
	
	/**
	 * Initializes the static allocator.
	 *
	 * @param __ba The allocation size.
	 * @since 2019/04/24
	 */
	public StaticAllocator(int __ba)
	{
		this.base = __ba;
	}
	
	/**
	 * Allocates the given number of bytes.
	 *
	 * @param __sz The number of bytes to allocate.
	 * @return The allocation pointer.
	 * @since 2019/04/24
	 */
	public final int allocate(int __sz)
	{
		// Round up
		__sz = (__sz + 3) & (~3);
		
		// Determine new size
		int oldsize = this._size;
		this._size = oldsize + __sz;
		
		// Return pointer
		return this.base + oldsize;
	}
	
	/**
	 * Returns the current size of the allocator.
	 *
	 * @return The allocation size.
	 * @since 2019/04/24
	 */
	public final int size()
	{
		return this._size;
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/SuiteMemory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import dev.shadowtail.jarfile.JarMinimizer;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import java.io.IOException;

/**
 * This represents the single virtual memory space for suite memory.
 *
 * @since 2019/04/21
 */
public final class SuiteMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** The suite manager. */
	protected final VMSuiteManager suites;
	
	/** The library this uses. */
	protected final String libname;
	
	/** The offset to this memory region. */
	protected final int offset;
	
	/** Was this initialized? */
	private volatile boolean _didinit;
	
	/** Memory for this suite. */
	private volatile ReadableMemory _memory;
	
	/** Header for this JAR. */
	volatile MinimizedJarHeader _jarheader;
	
	/**
	 * Initializes the suite memory.
	 *
	 * @param __off The memory offset for this suite.
	 * @param __sm The suite manager.
	 * @param __ln The library name.
	 * @throws NullPointerException On null arguments.
	 */
	public SuiteMemory(int __off, VMSuiteManager __sm, String __ln)
		throws NullPointerException
	{
		if (__sm == null || __ln == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.libname = __ln;
		this.offset = __off;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadByte(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		this._memory.memReadBytes(__addr, __b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadInt(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadShort(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return SuitesMemory.SUITE_CHUNK_SIZE;
	}
	
	/**
	 * Initializes all the memory and suites here.
	 *
	 * @throws IOException On read/write errors.
	 * @since 2019/04/21
	 */
	final void __init()
		throws IOException
	{
		// Do not initialize twice!
		if (this._didinit)
			return;
		this._didinit = true;
		
		// Load the class library
		String libname = this.libname;
		VMClassLibrary clib = this.__loadLibrary(libname);
		
		// Debug
		todo.DEBUG.note("Initialize suite %s @%08d", libname, this.offset);
		
		// Minimize and format the JAR
		byte[] jf = JarMinimizer.minimize(
			(libname.startsWith("cldc-compact.") ||
			libname.startsWith("cldc-compact-")), clib);
		
		// {@squirreljme.error AE09 Suite chunk size limit was exceeded.
		// (The required chunk size; The limit; More space that is needed)}
		if (jf.length > SuitesMemory.SUITE_CHUNK_SIZE)
			throw new RuntimeException("AE09 " + jf.length + " " +
				SuitesMemory.SUITE_CHUNK_SIZE + " " +
				(jf.length - SuitesMemory.SUITE_CHUNK_SIZE));
		
		// Set memory using this byte array
		ReadableMemory rm;
		this._memory = (rm = new ByteArrayMemory(this.offset, jf));
		
		// Load the JAR header
		this._jarheader = MinimizedJarHeader.decode(
			new ReadableMemoryInputStream(rm, 0,
				MinimizedJarHeader.HEADER_SIZE_WITH_MAGIC));
	}
	
	/**
	 * Attempts to load the given library.
	 *
	 * @param __libname The library to load.
	 * @return The loaded library.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If it was not found.
	 * @since 2019/11/28
	 */
	private final VMClassLibrary __loadLibrary(String __libname)
		throws NullPointerException, VMException
	{
		if (__libname == null)
			throw new NullPointerException("NARG");
			
		VMSuiteManager suites = this.suites;
		
		// Try as it is requested
		VMClassLibrary rv = suites.loadLibrary(__libname);
		if (rv != null)
			return rv;
		
		// Try with an extension added
		rv = suites.loadLibrary(__libname + ".jar");
		if (rv != null)
			return rv;
		
		// Try to remove the JAR extension
		if (__libname.endsWith(".jar"))
		{
			rv = suites.loadLibrary(__libname.substring(0,
				__libname.length() - 4));
			if (rv != null)
				return rv;
		}
		
		// {@squirreljme.error AE0p Could not find library. (The library)}
		throw new VMException("AE0p " + __libname);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/SuitesMemory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import dev.shadowtail.packfile.MinimizedPackHeader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This class contains the memory information for every single suite which
 * exists within the VM.
 *
 * @since 2019/04/21
 */
public final class SuitesMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** Configuration and table space size. */
	public static final int CONFIG_TABLE_SIZE =
		1048576;
	
	/** The suite chunk size. */
	public static final int SUITE_CHUNK_SIZE =
		25_165_824;
	
	/** The suite manage to base from. */
	protected final VMSuiteManager suites;
	
	/** Offset. */
	protected final int offset;
	
	/** The size of this memory region. */
	protected final int size;
	
	/** The individual regions of suite memory. */
	private final SuiteMemory[] _suitemem;
	
	/** This is the mapping of suite names to memory. */
	private final Map<String, SuiteMemory> _suitemap;
	
	/** The suite configuration table (addresses of suites). */
	private volatile ReadableMemory _configtable;
	
	/** Was the config table initialized? */
	private volatile boolean _didconfiginit;
	
	/**
	 * Initializes the suites memory.
	 *
	 * @param __off The offset of suite memory.
	 * @param __sm The suite manager.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public SuitesMemory(int __off, VMSuiteManager __sm)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		// Set suites
		this.suites = __sm;
		
		// All the libraries which are available for usage
		String[] libnames = __sm.listLibraryNames();
		int n = libnames.length;
		
		// Setup suite memory area
		SuiteMemory[] suitemem = new SuiteMemory[n];
		Map<String, SuiteMemory> suitemap = new LinkedHashMap<>();
		
		// Setup memory regions for the various suites
		int off = SuitesMemory.CONFIG_TABLE_SIZE;
		for (int i = 0; i < n; i++, off += SuitesMemory.SUITE_CHUNK_SIZE)
		{
			// Need the suite name for later lookup on init
			String libname = libnames[i];
			
			// Normalize and add JAR
			if (!libname.endsWith(".jar"))
				libname = libname + ".jar";
			
			// Map suite
			SuiteMemory sm;
			suitemem[i] = (sm = new SuiteMemory(off, __sm, libname));
			
			// Also use map for quick access
			suitemap.put(libname, sm);
		}
		
		// {@squirreljme.error AE0q Suite space has exceeded size limit of
		// 2GiB. (The current size; The amount of bytes over)}
		if (off < 0)
			throw new VMException("AE0q " + (((long)off) & 0xFFFFFFFFL) + " " +
				(off - 0x7FFFFFFF));
		
		// Store all the various suite memories
		this._suitemem = suitemem;
		this._suitemap = suitemap;
		
		// Store final memory parameters
		this.offset = __off;
		this.size = off;
	}
	
	/**
	 * Finds the specified library.
	 *
	 * @param __name The library to locate.
	 * @return The located library.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/03/01
	 */
	public final SuiteMemory findLibrary(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		Map<String, SuiteMemory> suitemap = this._suitemap;
		
		// Direct name match?
		SuiteMemory rv = suitemap.get(__name);
		if (rv != null)
			return rv;
		
		// With JAR attached?
		rv = suitemap.get(__name + ".jar");
		if (rv != null)
			return rv;
		
		// Try one last time with JAR removed
		if (__name.endsWith(".jar"))
			return suitemap.get(__name.substring(
				0, __name.length() - ".jar".length()));
		
		// Not found, give up
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Needs to be initialized?
		if (!this._didconfiginit)
			this.__init();
		
		// Reading from the config table?
		if (__addr < SuitesMemory.CONFIG_TABLE_SIZE)
			return this._configtable.memReadByte(__addr);
		
		// Determine the suite index we are wanting to look in memory
		int si = (__addr - SuitesMemory.CONFIG_TABLE_SIZE) /
			SuitesMemory.SUITE_CHUNK_SIZE;
		
		// Instead of failing, return some invalid values
		SuiteMemory[] suitemem = this._suitemem;
		if (si < 0 || si >= suitemem.length)
			return 0xFF;
		
		// Read from suite memory
		return suitemem[si].memReadByte(__addr - suitemem[si].offset);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
	
	/**
	 * Initializes the configuration space.
	 *
	 * @since 2019/04/21
	 */
	final void __init()
	{
		// Do not initialize twice!
		if (this._didconfiginit)
			return;
		this._didconfiginit = true;
		
		// Initialize the bootstrap
		SuiteMemory superv = this.findLibrary("cldc-compact");
		try
		{
			superv.__init();
		}
		
		// {@squirreljme.error AE0a Could not initialize the supervisor.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0a", e);
		}
		
		// Get suites and the number of them for processing
		SuiteMemory[] suitemem = this._suitemem;
		int numsuites = suitemem.length;
		
		// Build a virtualized pack header which works with SummerCoat and
		// matches the ROM format (just appears as a larger ROM)
		int packoffset = this.offset;
		try (ByteArrayOutputStream pbaos = new ByteArrayOutputStream(4096);
			DataOutputStream dos = new DataOutputStream(pbaos))
		{
			// Relative offset for names
			int reloff = MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC +
				(MinimizedPackHeader.TOC_ENTRY_SIZE * numsuites);
			
			// Write pack header
			dos.writeInt(MinimizedPackHeader.MAGIC_NUMBER);
			
			// Count and table of contents position
			dos.writeInt(numsuites);
			dos.writeInt(MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC);
			
			// Boot properties
			dos.writeInt(Arrays.asList(suitemem).indexOf(superv));
			dos.writeInt(superv.offset);
			dos.writeInt(SuitesMemory.SUITE_CHUNK_SIZE);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			
			// Class and run-time constant pools
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			
			// Name table output
			ByteArrayOutputStream nbaos = new ByteArrayOutputStream(4096);
			DataOutputStream ndos = new DataOutputStream(nbaos);
			
			// Write TOC
			for (int i = 0; i < numsuites; i++)
			{
				SuiteMemory suite = suitemem[i];
				
				// Align name
				while (((reloff + ndos.size()) & 1) != 0)
					ndos.write(0);
				
				// Name position
				dos.writeInt(reloff + ndos.size());
				
				// Write name
				ndos.writeUTF(suite.libname);
				
				// Offset and size of the chunk
				dos.writeInt(suite.offset);
				dos.writeInt(SuitesMemory.SUITE_CHUNK_SIZE);
				
				// The manifest is not known, must be searched
				dos.writeInt(0);
				dos.writeInt(0);
			}
			
			// Write name table
			nbaos.writeTo(dos);
			
			// Store written configuration table
			ReadableMemory configtable = new ByteArrayMemory(packoffset,
				pbaos.toByteArray());
			this._configtable = configtable;
		}
		
		// {@squirreljme.error AE0b Could not write the virtual packfile.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0b", e);
		}
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/SummerCoatFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;

import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VMFactory;
import cc.squirreljme.emulator.vm.VMSuiteManager;
import cc.squirreljme.emulator.vm.VirtualMachine;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import dev.shadowtail.packfile.MinimizedPackHeader;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import cc.squirreljme.emulator.profiler.ProfilerSnapshot;

/**
 * This is the factory which is capable of creating instances of the
 * SummerCoat virtual machine.
 *
 * @since 2018/12/29
 */
public class SummerCoatFactory
	extends VMFactory
{
	/** The starting address for RAM. */
	public static final int RAM_START_ADDRESS =
		0x0010_0000;
	
	/** Default size of RAM. */
	public static final int DEFAULT_RAM_SIZE =
		33554432;
	
	/** Base address for configuration data. */
	public static final int CONFIG_BASE_ADDR =
		0x1000_0000;
	
	/** The base address for suites. */
	public static final int SUITE_BASE_ADDR =
		0x2000_0000;
	
	/** Size of the configuration area. */
	public static final int CONFIG_SIZE =
		65536;
	
	/**
	 * Initializes the factory.
	 *
	 * @since 2018/12/29
	 */
	public SummerCoatFactory()
	{
		super("summercoat");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/29
	 */
	@Override
	protected VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Virtual memory which provides access to many parts of memory
		VirtualMemory vmem = new VirtualMemory();
		
		// The ROM always starts here
		int rombase = SummerCoatFactory.SUITE_BASE_ADDR,
			romsize = 0;
		
		// Try to load a specific ROM file instead of the dynamically
		// generate one?
		String romfile = __sprops.get("cc.squirreljme.romfile");
		if (romfile == null)
			try
			{
				romfile = System.getProperty("cc.squirreljme.romfile");
			}
			catch (SecurityException e)
			{
			}
		
		// Load existing ROM file
		if (romfile != null)
		{
			// Debug
			todo.DEBUG.note("Using ROM %s", romfile);
			
			// Copy all of the file data
			Path p = Paths.get(romfile);
			try (InputStream in = Files.newInputStream(p,
					StandardOpenOption.READ);
				ByteArrayOutputStream baos = new ByteArrayOutputStream(
					(int)Files.size(p)))
			{
				// Read data
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Initialize memory with the ROM data
				ReadableMemory sm = new ByteArrayMemory(rombase,
					baos.toByteArray());
				vmem.mapRegion(sm);
				
				// Record size of ROM
				romsize = baos.size();
			}
			
			// {@squirreljme.error AE0c Could not load SummerCoat ROM. (File)}
			catch (IOException e)
			{
				throw new RuntimeException("AE0c " + romfile, e);
			}
		}
		
		// Dynamically initialized suite memory
		else
		{
			// Create and map dynamic suite region
			SuitesMemory sm = new SuitesMemory(rombase, __sm);
			vmem.mapRegion(sm);
			
			// Initialize suite memory explicitly since we need it!
			sm.__init();
			
			// Rom size is derived from the chunk size
			romsize = sm.size;
		}
		
		// Initialize RAM
		int ramsize = SummerCoatFactory.DEFAULT_RAM_SIZE,
			ramstart = SummerCoatFactory.RAM_START_ADDRESS;
		vmem.mapRegion(new RawMemory(ramstart, ramsize));
		
		// Initialize configuration memory
		WritableMemory cmem = new RawMemory(SummerCoatFactory.CONFIG_BASE_ADDR,
			SummerCoatFactory.CONFIG_SIZE);
		vmem.mapRegion(cmem);
		
		// Read the boot JAR offset of this packfile
		int bootjaroff = rombase + vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJAROFFSET),
			bootjarsize = vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJARSIZE);
		
		// Load the bootstrap JAR header
		MinimizedJarHeader bjh;
		try (InputStream bin = new ReadableMemoryInputStream(vmem,
			bootjaroff, bootjarsize))
		{
			bjh = MinimizedJarHeader.decode(bin);
		}
		
		// {@squirreljme.error AE0e Could not read the boot JAR header.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0e", e);
		}
		
		// Write configuration information
		try (DataOutputStream dos = new DataOutputStream(
			new WritableMemoryOutputStream(cmem, 0,
				SummerCoatFactory.CONFIG_SIZE)))
		{
			// Version
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_VERSION,
				"0.3.0");
			
			// Name
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_NAME,
				"SquirrelJME SummerCoat");
			
			// Vendor
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_VENDOR,
				"Stephanie Gawroriski");
			
			// E-Mail
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_EMAIL,
				"xerthesquirrel@gmail.com");
			
			// URL
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_URL,
				"https://squirreljme.cc/");
			
			// Guest depth
			ConfigRomWriter.writeInteger(dos, ConfigRomType.GUEST_DEPTH,
				__gd);
			
			// Main class
			if (__maincl != null)
				ConfigRomWriter.writeString(dos, ConfigRomType.MAIN_CLASS,
					__maincl.replace('.', '/'));
			
			// Is midlet?
			ConfigRomWriter.writeInteger(dos, ConfigRomType.IS_MIDLET,
				(__ismid ? 1 : -1));
			
			// System properties
			if (__sprops != null)
				for (Map.Entry<String, String> e : __sprops.entrySet())
				{
					ConfigRomWriter.writeKeyValue(dos,
						ConfigRomType.DEFINE_PROPERTY,
						e.getKey(), e.getValue());
				}
			
			// Class path
			ConfigRomWriter.writeStrings(dos, ConfigRomType.CLASS_PATH,
				SummerCoatFactory.classPathToStringArray(__cp));
			
			// System call handler
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_STATIC_FIELD_POINTER,
				ramstart + bjh.syscallsfp);
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_CODE_POINTER,
				bootjaroff + bjh.syscallhandler);
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_POOL_POINTER,
				ramstart + bjh.syscallpool);
			
			// End
			dos.writeShort(ConfigRomType.END);
		}
		
		// {@squirreljme.error AE0d Could not write to configuration ROM.}
		catch (IOException e)
		{
			throw new VMException("AE0d", e);
		}
		
		// Load the bootstrap JAR header
		int bra = bootjaroff + bjh.bootoffset,
			lram;
		
		// Debug
		if (NativeCPU.ENABLE_DEBUG)
			todo.DEBUG.note("Unpacking BootRAM!");
		
		// Load the boot RAM
		try (DataInputStream dis = new DataInputStream(
			new ReadableMemoryInputStream(vmem, bra, bjh.bootsize)))
		{
			// Read entire RAM space
			lram = dis.readInt();
			byte[] bram = new byte[lram];
			dis.readFully(bram);
			
			// Write into memory
			vmem.memWriteBytes(ramstart, bram, 0, lram);
			
			// Handle RAM initializers
			int n = dis.readInt();
			for (int i = 0; i < n; i++)
			{
				int key = dis.readUnsignedByte(),
					addr = dis.readInt() + ramstart,
					mod = (key & 0x0F),
					siz = ((key & 0xF0) >>> 4);
				
				// Which offset is used?
				int off;
				switch (mod)
				{
						// Nothing
					case 0:
						off = 0;
						break;
						
						// RAM
					case 1:
						off = ramstart;
						break;
					
						// JAR
					case 2:
						off = bootjaroff;
						break;
					
						// {@squirreljme.error AE0f Corrupt Boot RAM with
						// invalid value modifier. (Modifier)}
					default:
						throw new VMException("AE0f " + mod);
				}
				
				// Depends on operation size
				switch (siz)
				{
						// Byte
					case 1:
						vmem.memWriteByte(addr, dis.readByte() + off);
						break;
					
						// Short
					case 2:
						vmem.memWriteShort(addr, dis.readShort() + off);
						break;
					
						// Integer
					case 4:
						vmem.memWriteInt(addr, dis.readInt() + off);
						break;
						
						// Long
					case 8:
						{
							long v = dis.readLong() + off;
							vmem.memWriteInt(addr, (int)(v >>> 32));
							vmem.memWriteInt(addr + 4, (int)(v));
						}
						break;
					
						// {@squirreljme.error AE0g Corrupt Boot RAM with
						// invalid size. (Size)}
					default:
						throw new VMException("AE0g " + siz);
				}
			}
			
			// {@squirreljme.AE04 Expected value at end of initializer
			// memory, the Boot RAM is corrupt. (Key value)}
			int key;
			if (-1 != (key = dis.readInt()))
				throw new VMException("AE04 " + key);
				
			// Debug
			if (NativeCPU.ENABLE_DEBUG)
				todo.DEBUG.note("BootRAM unpacked at %08x (size %d)!",
					ramstart, lram);
		}
		
		// {@squirreljme.error AE0h Could not initialize the boot RAM for
		// the virtual machine.}
		catch (IOException e)
		{
			throw new VMException("AE0h", e);
		}
		
		// Setup non-cpu VM state
		MachineState ms = new MachineState(vmem, __ps);
		
		// Setup virtual execution CPU
		NativeCPU cpu = new NativeCPU(ms, vmem, 0, __ps);
		NativeCPU.Frame iframe = cpu.enterFrame(bootjaroff + bjh.bootstart,
			ramstart, ramsize, rombase, romsize,
			SummerCoatFactory.CONFIG_BASE_ADDR, SummerCoatFactory.CONFIG_SIZE);
		
		// Seed initial frame registers
		iframe._registers[NativeCode.POOL_REGISTER] =
			ramstart + bjh.bootpool;
		iframe._registers[NativeCode.STATIC_FIELD_REGISTER] =
			ramstart + bjh.bootsfieldbase;
		
		// Setup virtual machine with initial thread
		return new SummerCoatVirtualMachine(cpu);
	}
	
	/**
	 * Converts a class path to a string array.
	 *
	 * @param __cp The class path to convert.
	 * @return The resulting string array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public static final String[] classPathToStringArray(VMClassLibrary... __cp)
		throws NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		int n = __cp.length;
		String[] rv = new String[n];
		for (int i = 0; i < n; i++)
		{
			String name = __cp[i].name();
			rv[i] = (name.endsWith(".jar") ? name : name + ".jar");
		}
		
		return rv;
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/SummerCoatVirtualMachine.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.emulator.vm.VMException;
import cc.squirreljme.emulator.vm.VirtualMachine;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * This represents a virtual machine within SummerCoat.
 *
 * @since 2019/06/30
 */
public class SummerCoatVirtualMachine
	implements VirtualMachine
{
	/** Threads currently running. */
	private final List<Thread> _threads =
		new ArrayList<>();
	
	/**
	 * Initializes the virtual machine.
	 *
	 * @param __bootcpu The boot CPU.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public SummerCoatVirtualMachine(NativeCPU __bootcpu)
		throws NullPointerException
	{
		if (__bootcpu == null)
			throw new NullPointerException("NARG");
		
		// Add initial thread
		this._threads.add(new Thread(__bootcpu, "BootCPU"));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final int runVm()
		throws VMException
	{
		// Start all threads
		List<Thread> threads = this._threads;
		synchronized (threads)
		{
			// Run threads
			for (int i = 0, n = threads.size(); i < n; i++)
				try
				{
					// Start the thread
					threads.get(i).start();
				}
				
				// Ignore, in the event this was called multiple times!
				catch (IllegalThreadStateException e)
				{
				}
		} 
		
		// Wait for all threads to stop
		for (;;)
		{
			// Available threads
			int count = 0;
			
			// Lock!
			synchronized (threads)
			{
				// Get iterator
				Iterator<Thread> it = threads.iterator();
				
				// Ask about all the threads
				while (it.hasNext())
				{
					// Get the thread
					Thread t = it.next();
					
					// If thread is alive, count it
					if (t.isAlive())
						count++;
					
					// Otherwise remove it
					else
						it.remove();
				}
				
				// If there are many threads alive, just wait around to not
				// waste CPU and poll periodically for the thread states
				if (count > 0)
					try
					{
						threads.wait(1000L);
					}
					catch (InterruptedException e)
					{
					}
			}
			
			// Return error for now
			if (count == 0)
			{
				todo.TODO.note("Actual return value!");
				return 1;
			}
		}
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/VMRuntimeException.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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;

import cc.squirreljme.emulator.vm.VMException;

/**
 * This is an exception in SummerCoat which is translated to an exception
 * for the virtual machine itself when it has a chance to do so.
 *
 * @since 2019/01/11
 */
public class VMRuntimeException
	extends VMException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/01/11
	 */
	public VMRuntimeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/VMToDoException.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.vm.summercoat;

import cc.squirreljme.emulator.vm.VMException;

/**
 * This is thrown when incomplete code has been reached.
 *
 * @since 2019/11/09
 */
public class VMToDoException
	extends VMException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/11/09
	 */
	public VMToDoException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/09
	 */
	public VMToDoException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/11/09
	 */
	public VMToDoException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/11/09
	 */
	public VMToDoException(Throwable __c)
	{
		super(__c);
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/VirtualMemory.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import cc.squirreljme.emulator.vm.VMException;
import java.util.ArrayList;
import java.util.List;

/**
 * This class contains the entirety of virtual memory, this includes access
 * to the various on-demand minification of suites and classes.
 *
 * @since 2019/04/21
 */
public final class VirtualMemory
	extends AbstractWritableMemory
{
	/** Memory map. */
	private final List<Memory> _memories =
		new ArrayList<>();
	
	/** Active cache map. */
	private volatile Memory[] _cache =
		new Memory[0];
	
	/**
	 * Maps the given region of memory.
	 *
	 * @param __mem The region to map.
	 * @since 2019/04/21
	 */
	public final void mapRegion(Memory __mem)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		// Add memory
		List<Memory> memories = this._memories;
		synchronized (memories)
		{
			memories.add(__mem);
			
			// Redo cache
			this._cache = memories.<Memory>toArray(
				new Memory[memories.size()]);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadByte(int __addr)
	{
		// Find memory to read from
		Memory[] cache = this._cache;
		for (Memory c : cache)
		{
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
				return ((ReadableMemory)c).memReadByte(vaddr);
		}
		
		// {@squirreljme.error AE0i Invalid read from unmapped or non-writable
		// memory! (The address)}
		throw new VMException(String.format("AE0i %08x", __addr));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return 0x00000000;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return 0x7FFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteByte(int __addr, int __v)
	{
		// Find memory to write to
		Memory[] cache = this._cache;
		for (Memory c : cache)
		{
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
			{
				if (c instanceof WritableMemory)
				{
					((WritableMemory)c).memWriteByte(vaddr, __v);
					return;
				}
			}
		}
		
		// {@squirreljme.error AE0j Invalid write to unmapped or non-writable
		// memory! (The address; The value to write)}
		throw new VMException(String.format("AE0j %08x %d", __addr, __v));
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/WritableMemory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

/**
 * This is used to provide an interface for reading memory.
 *
 * @since 2019/04/21
 */
public interface WritableMemory
	extends ReadableMemory
{
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	void memWriteByte(int __addr, int __v);
	
	/**
	 * Writes multiple bytes to memory
	 *
	 * @param __a The address to write to.
	 * @param __b The input bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	void memWriteBytes(int __a, byte[] __b, int __o, int __l);
	
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	void memWriteInt(int __addr, int __v);
	
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	void memWriteShort(int __addr, int __v);
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/WritableMemoryOutputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.vm.summercoat;

import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which can directly write to memory areas.
 *
 * @since 2019/06/14
 */
public final class WritableMemoryOutputStream
	extends OutputStream
{
	/** The output memory. */
	protected final WritableMemory memory;
	
	/** The base write address. */
	protected final int address;
	
	/** The number of bytes that can be written. */
	protected final int length;
	
	/** The current write offset. */
	private int _at;
	
	/**
	 * Initializes the stream.
	 *
	 * @param __mem The memory.
	 * @param __ad The start address.
	 * @param __ln The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public WritableMemoryOutputStream(WritableMemory __mem, int __ad, int __ln)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.address = __ad;
		this.length = __ln;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/14
	 */
	@Override
	public final void close()
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/14
	 */
	@Override
	public final void flush()
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/14
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error AE0k Reached end of memory.}
		int at = this._at;
		if (at >= this.length)
			throw new EOFException("AE0k");
		
		// Write
		this.memory.memWriteByte(this.address + at, __b);
		this._at = at + 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/14
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/14
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Needed to check bounds.
		int memlen = this.length,
			at = this._at,
			left = memlen - at;
		
		// {@squirreljme.error AE0l Reached end of memory.}
		if (left <= 0)
			throw new EOFException("AE0l");
		
		// Do not write past the bounds
		if (__l > left)
			__l = left;
		
		// Write to memory
		this.memory.memWriteBytes(this.address + at, __b, __o, __l);
		
		// Increase pointer
		this._at = at + __l;
	}
}

Added emulators/summercoat-vm/src/main/java/cc/squirreljme/vm/summercoat/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SummerCoat virtual machine which is a virtual
 * machine which has register based optimizations.
 *
 * @since 2018/12/29
 */

package cc.squirreljme.vm.summercoat;

Added emulators/summercoat-vm/src/main/resources/META-INF/services/cc.squirreljme.emulator.vm.VMFactory.


1
+
cc.squirreljme.vm.summercoat.SummerCoatFactory

Added gradle/wrapper/gradle-wrapper.jar.

cannot compute difference between binary files

Added gradle/wrapper/gradle-wrapper.properties.






1
2
3
4
5
+
+
+
+
+
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Added gradlew.
























































































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
    echo "$*"
}

die () {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
    JAVACMD=`cygpath --unix "$JAVACMD"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=`expr $i + 1`
    done
    case $i in
        0) set -- ;;
        1) set -- "$args0" ;;
        2) set -- "$args0" "$args1" ;;
        3) set -- "$args0" "$args1" "$args2" ;;
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Escape application args
save () {
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
    echo " "
}
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "$@"

Added gradlew.bat.





































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

Deleted jitt/TIMESPACE.MF.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Timespace-Title: JIT Time
X-SquirrelJME-Timespace-Type: jit
X-SquirrelJME-Timespace-Description: This contains everything that 
 should be visible if the JIT is enabled. This depends on the run-time 
 but the build-time is not required in any way.

Deleted jitt/jittime.mkd.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
# JIT-time Projects

These are projects which are available if a JIT is enabled and as such contain
all of the JIT code.

 * `libs/` -- JIT Libraries.

Deleted jitt/libs/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: JIT Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: This namespace contains all of the 
 JIT libraries which are needed for the JIT compiler to properly operate.

Added modules/build.gradle.










































































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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "de.set.ecj" version "1.4.1" apply false
}

group = "cc.squirreljme.modules"
description = "Modules which are a part of SquirrelJME."

// Every sub-project needs SquirrelJME specific pieces
subprojects
{
	//apply plugin: "de.set.ecj"
	apply plugin: "java"
	apply plugin: "checkstyle"
	apply plugin: "cc.squirreljme.plugin"

	// Configure the compiler
	java
	{
		// Java ME 8 is effectively Java 7
        compileJava.sourceCompatibility = JavaVersion.VERSION_1_7
		compileJava.targetCompatibility = JavaVersion.VERSION_1_7

		// All files are always in UTF-8 format
		compileJava.options.encoding = "utf-8"

		// Copy to tests
		compileTestJava.sourceCompatibility = compileJava.sourceCompatibility
		compileTestJava.targetCompatibility = compileJava.targetCompatibility
		compileTestJava.options.encoding = compileJava.options.encoding
		compileTestJava.options.verbose = compileJava.options.verbose

		// Copy to JavaDoc
		javadoc.options.source = "1.7"
		javadoc.options.tags = [ "squirreljme.property",
			"squirreljme.env",
			"squirreljme.error",
			"squirreljme.syscallparam",
			"squirreljme.syscallreturn" ]
	}

	// Enable SquirrelJME Tests
	apply from: project.rootProject.findProject(":emulators:emulator-base").
		projectDir.toPath().resolve("enable-testing.gradle").toFile()
}

// Properties for every sub-project, except for cldc-compact as it is special
configure(subprojects
	- project(":modules:cldc-compact"))
{
	apply plugin: "java"

	// All projects use the base classpath
    java
    {
		// Only use SquirrelJME's boot classes, not the system SDK
		Project cldcCompactProject = project(":modules:cldc-compact")
		compileJava.options.bootstrapClasspath = project.objects.
			fileCollection().from(cldcCompactProject.buildDir.toPath().
			resolve("classes").resolve("java").resolve("main")).getAsFileTree()

		// Copy to JavaDoc
		javadoc.options.bootClasspath = compileJava.options.bootstrapClasspath
			.collect()
    }

	dependencies
	{
		// All projects depend on the Compact CLDC Library
		implementation project(":modules:cldc-compact")
		testImplementation project(":modules:cldc-compact")
	}
}

Added modules/cldc-compact/build.gradle.



































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEConfiguration
import cc.squirreljme.plugin.swm.JavaMEMidletType

// Setup plugins
plugins
{
	id "java"
}

version = "1.8.${rootProject.ext.squirreljmeVMVersion}"
description = "This is the standard JavaME 8 Connection " +
	"Limited  Device Configuration which contains the core classes used " +
	"by Java ME."

squirreljme
{
	javaDocErrorCode = "ZZ"
	swmType = JavaMEMidletType.API
	swmName = "Connection Limited Device Configuration (Compact)"
	swmVendor = "Stephanie Gawroriski"
	definedConfigurations += new JavaMEConfiguration("CLDC-1.8-Compact")
	definedConfigurations += new JavaMEConfiguration("CLDC-1.1")
	definedConfigurations += new JavaMEConfiguration("CLDC-1.0")
}

java
{
	// No classes are available for this project
	compileJava.options.bootstrapClasspath = project.objects.fileCollection()
}

dependencies
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/Assembly.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 class is used special by the compiler to transform all the various
 * operations into regular instructions rather than method calls.
 *
 * The compiler will take all of the method arguments and instead use their
 * inputs and outputs from the values of registers instead. However due to
 * this, this means that these instructions are purely primitive in that
 * they must not depend on any aspect of the virtual machine.
 *
 * @since 2019/04/20
 */
@SuppressWarnings("NewMethodNamingConvention")
public final class Assembly
{
	/**
	 * Not used.
	 *
	 * @since 2019/04/20
	 */
	private Assembly()
	{
	}
	
	/**
	 * Returns the array length of the given object.
	 *
	 * @param __o The object to get the length of.
	 * @return The length of the array, will return a negative value if not
	 * an array.
	 * @since 2020/02/23
	 */
	public static native int arrayLength(long __o);
	
	/**
	 * Returns the array length of the given object.
	 *
	 * @param __o The object to get the length of.
	 * @return The length of the array, will return a negative value if not
	 * an array.
	 * @since 2019/05/24
	 */
	public static native int arrayLength(Object __o);
	
	/**
	 * Sets the array length of an array.
	 *
	 * @param __o The object to set.
	 * @param __l The length to set.
	 * @since 2020/02/23
	 */
	public static native void arrayLengthSet(long __o, int __l);
	
	/**
	 * Sets the array length of an array.
	 *
	 * @param __o The object to set.
	 * @param __l The length to set.
	 * @since 2020/02/23
	 */
	public static native void arrayLengthSet(Object __o, int __l);
	
	/**
	 * Atomic comparison and set.
	 *
	 * @param __comp The value to compare and if matches, {@code __set} is
	 * written.
	 * @param __set The value to set if matched.
	 * @param __addr The address to write to.
	 * @return The value that was read before the set.
	 * @since 2019/07/01
	 */
	public static native int atomicCompareGetAndSet(int __comp, int __set,
		long __addr);
	
	/**
	 * Atomically decrements a value and returns the result.
	 *
	 * @param __addr The address to decrement.
	 * @return The get value.
	 * @since 2019/07/01
	 */
	public static native int atomicDecrementAndGet(long __addr);
	
	/**
	 * Atomically increments a value.
	 *
	 * @param __addr The address to increment.
	 * @since 2019/07/01
	 */
	public static native void atomicIncrement(long __addr);
	
	/**
	 * Trigger breakpoint within the virtual machine.
	 *
	 * @since 2019/04/21
	 */
	public static native void breakpoint();
	
	/**
	 * Returns the class info pointer of {@code boolean}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfBoolean();
	
	/**
	 * Returns the class info pointer of {@code boolean}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfBooleanPointer();
	
	/**
	 * Returns the class info pointer of {@code byte}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfByte();
	
	/**
	 * Returns the class info pointer of {@code byte}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfBytePointer();
	
	/**
	 * Returns the class info pointer of {@code char}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfCharacter();
	
	/**
	 * Returns the class info pointer of {@code char}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfCharacterPointer();
	
	/**
	 * Returns the class info pointer of {@code double}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfDouble();
	
	/**
	 * Returns the class info pointer of {@code double}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfDoublePointer();
	
	/**
	 * Returns the class info pointer of {@code float}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfFloat();
	
	/**
	 * Returns the class info pointer of {@code float}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfFloatPointer();
	
	/**
	 * Returns the class info pointer of {@code int}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfInteger();
	
	/**
	 * Returns the class info pointer of {@code int}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfIntegerPointer();
	
	/**
	 * Returns the class info pointer of {@code long}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfLong();
	
	/**
	 * Returns the class info pointer of {@code long}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfLongPointer();
	
	/**
	 * Returns the class info pointer of {@code short}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native ClassInfo classInfoOfShort();
	
	/**
	 * Returns the class info pointer of {@code short}.
	 *
	 * @return The class info pointer.
	 * @since 2020/02/24
	 */
	public static native long classInfoOfShortPointer();
	
	/**
	 * Packs the given two integers to a double value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2019/06/21
	 */
	public static native double doublePack(int __hi, int __lo);
	
	/**
	 * Double to raw long bits.
	 *
	 * @param __d The input double.
	 * @return The raw long bits.
	 * @since 2018/11/03
	 */
	public static native long doubleToRawLongBits(double __d);
	
	/**
	 * Unpacks the high value of a double.
	 *
	 * @param __d The double to unpack.
	 * @return The unpacked high value.
	 * @since 2020/02/24
	 */
	public static native int doubleUnpackHigh(double __d);
	
	/**
	 * Unpacks the low value of a double.
	 *
	 * @param __d The double to unpack.
	 * @return The unpacked low value.
	 * @since 2020/02/24
	 */
	public static native int doubleUnpackLow(double __d);
	
	/**
	 * Performs explicit exception handling.
	 *
	 * @since 2019/04/28
	 */
	public static native void exceptionHandle();
	
	/**
	 * Float to raw int bits.
	 *
	 * @param __f The input float.
	 * @return The raw int bits.
	 * @since 2018/11/04
	 */
	public static native int floatToRawIntBits(float __f);
	
	/**
	 * Integer bits to float.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static native float intBitsToFloat(int __b);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c, int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c, int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(long __addr, long __pool, int __a,
		int __b, int __c, int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a,
		int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a,
		int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a, 
		int __b, int __c, int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a, 
		int __b, int __c, int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool address to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool pointer to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(long __addr, long __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Long bits to double.
	 *
	 * @param __b The input bits.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static native double longBitsToDouble(long __b);
	
	/**
	 * Packs the given two integers to a long value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The long value.
	 * @since 2019/06/21
	 */
	public static native long longPack(int __hi, int __lo);
	
	/**
	 * Unpack high value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackHigh(long __v);
	
	/**
	 * Unpack low value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackLow(long __v);
	
	/**
	 * Reads byte from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadByte(long __p, int __o);
	
	/**
	 * Reads integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/21
	 */
	public static native int memReadInt(long __p, int __o);
	
	/**
	 * Reads big endian Java integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaInt(long __p, int __o);
	
	/**
	 * Reads big endian Java long from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2020/02/24
	 */
	public static native long memReadJavaLong(long __p, int __o);
	
	/**
	 * Reads big endian Java short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaShort(long __p, int __o);
	
	/**
	 * Reads pointer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native long memReadPointer(long __p, int __o);
	
	/**
	 * Reads short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadShort(long __p, int __o);
	
	/**
	 * Writes byte to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteByte(long __p, int __o, int __v);
	
	/**
	 * Writes integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteInt(long __p, int __o, int __v);
	
	/**
	 * Writes big endian Java integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaInt(long __p, int __o, int __v);
	
	/**
	 * Writes big endian Java long to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2020/02/24
	 */
	public static native void memWriteJavaLong(long __p, int __o, long __v);
	
	/**
	 * Writes big endian Java short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaShort(long __p, int __o, int __v);
	
	/**
	 * Writes a pointer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2020/02/24
	 */
	public static native void memWritePointer(long __p, int __o, long __v);
	
	/**
	 * Writes short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteShort(long __p, int __o, int __v);
	
	/**
	 * Atomically decrements an object's monitor count.
	 * 
	 * @param __p The object to count.
	 * @return The resulting value.
	 * @since 2020/02/24
	 */
	public static native int monitorCountDecrementAndGetAtomic(long __p);
	
	/**
	 * Atomically decrements an object's monitor count.
	 * 
	 * @param __p The object to count.
	 * @return The resulting value.
	 * @since 2020/02/24
	 */
	public static native int monitorCountDecrementAndGetAtomic(Object __p);
	
	/**
	 * Atomically increments an object's monitor count.
	 * 
	 * @param __p The object to count.
	 * @return The resulting value.
	 * @since 2020/02/24
	 */
	public static native int monitorCountIncrementAndGetAtomic(long __p);
	
	/**
	 * Atomically increments an object's monitor count.
	 * 
	 * @param __p The object to count.
	 * @return The resulting value.
	 * @since 2020/02/24
	 */
	public static native int monitorCountIncrementAndGetAtomic(Object __p);
	
	/**
	 * Atomically reads the object's monitor count.
	 * 
	 * @param __p The object to read.
	 * @return The current monitor count.
	 * @since 2020/02/24
	 */
	public static native int monitorCountGetAtomic(long __p);
	
	/**
	 * Atomically reads the object's monitor count.
	 * 
	 * @param __p The object to read.
	 * @return The current monitor count.
	 * @since 2020/02/24
	 */
	public static native int monitorCountGetAtomic(Object __p);
	
	/**
	 * Atomically writes the object's monitor count.
	 * 
	 * @param __p The object to write.
	 * @param __v The count to write.
	 * @since 2020/02/24
	 */
	public static native void monitorCountSetAtomic(long __p, int __v);
	
	/**
	 * Atomically writes the object's monitor count.
	 * 
	 * @param __p The object to write.
	 * @param __v The count to write.
	 * @since 2020/02/24
	 */
	public static native void monitorCountSetAtomic(Object __p, int __v);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerCompareGetAndSetAtomic(
		long __p, long __comp, long __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerCompareGetAndSetAtomic(
		Object __p, long __comp, long __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerCompareGetAndSetAtomic(
		long __p, Thread __comp, Thread __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerCompareGetAndSetAtomic(
		Object __p, Thread __comp, Thread __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerCompareGetAndSetAtomicPointer(
		long __p, long __comp, long __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerCompareGetAndSetAtomicPointer(
		Object __p, long __comp, long __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerCompareGetAndSetAtomicPointer(
		long __p, Thread __comp, Thread __set);
	
	/**
	 * Atomically compares the owner of the object's monitor and sets it,
	 * returning the value before it was set (or was unchanged).
	 * 
	 * @param __p The object to potentially modify.
	 * @param __comp The owner to compare against.
	 * @param __set The owner to set to, if the comparison succeeds.
	 * @return The owner that originally was set.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerCompareGetAndSetAtomicPointer(
		Object __p, Thread __comp, Thread __set);
	
	/**
	 * Returns the owner of an object's monitor.
	 * 
	 * @param __p The object to get the owner from.
	 * @return The owner of the object's monitor.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerGetAtomic(long __p);
	
	/**
	 * Returns the owner of an object's monitor.
	 * 
	 * @param __p The object to get the owner from.
	 * @return The owner of the object's monitor.
	 * @since 2020/02/24
	 */
	public static native Thread monitorOwnerGetAtomic(Object __p);
	
	/**
	 * Returns the owner of an object's monitor.
	 * 
	 * @param __p The object to get the owner from.
	 * @return The owner of the object's monitor.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerGetPointerAtomic(long __p);
	
	/**
	 * Returns the owner of an object's monitor.
	 * 
	 * @param __p The object to get the owner from.
	 * @return The owner of the object's monitor.
	 * @since 2020/02/24
	 */
	public static native long monitorOwnerGetPointerAtomic(Object __p);
	
	/**
	 * Sets the owner of an object's monitor.
	 * 
	 * @param __p The object which will be set the new owner.
	 * @param __t The owner to set.
	 * @since 2020/02/24
	 */
	public static native void monitorOwnerSetAtomic(long __p, long __t);
	
	/**
	 * Sets the owner of an object's monitor.
	 * 
	 * @param __p The object which will be set the new owner.
	 * @param __t The owner to set.
	 * @since 2020/02/24
	 */
	public static native void monitorOwnerSetAtomic(long __p, Thread __t);
	
	/**
	 * Sets the owner of an object's monitor.
	 * 
	 * @param __p The object which will be set the new owner.
	 * @param __t The owner to set.
	 * @since 2020/02/24
	 */
	public static native void monitorOwnerSetAtomic(Object __p, long __t);
	
	/**
	 * Sets the owner of an object's monitor.
	 * 
	 * @param __p The object which will be set the new owner.
	 * @param __t The owner to set.
	 * @since 2020/02/24
	 */
	public static native void monitorOwnerSetAtomic(Object __p, Thread __t);
	
	/**
	 * Gets the ClassInfo of an object.
	 *
	 * @param __o The object to read from.
	 * @return The resulting class info.
	 * @since 2020/02/23
	 */
	public static native ClassInfo objectGetClassInfo(long __o);
	
	/**
	 * Gets the ClassInfo of an object.
	 *
	 * @param __o The object to read from.
	 * @return The resulting class info.
	 * @since 2020/02/23
	 */
	public static native ClassInfo objectGetClassInfo(Object __o);
	
	/**
	 * Gets the ClassInfo of an object.
	 *
	 * @param __o The object to read from.
	 * @return The resulting class info.
	 * @since 2020/02/23
	 */
	public static native long objectGetClassInfoPointer(long __o);
	
	/**
	 * Gets the ClassInfo of an object.
	 *
	 * @param __o The object to read from.
	 * @return The resulting class info.
	 * @since 2020/02/23
	 */
	public static native long objectGetClassInfoPointer(Object __o);
	
	/**
	 * Sets the ClassInfo of an object.
	 *
	 * @param __o The object to set the class of.
	 * @param __v The class info to set.
	 * @since 2020/02/23
	 */
	public static native void objectSetClassInfo(long __o, long __v);
	
	/**
	 * Sets the ClassInfo of an object.
	 *
	 * @param __o The object to set the class of.
	 * @param __v The class info to set.
	 * @since 2020/02/23
	 */
	public static native void objectSetClassInfo(Object __o, long __v);
	
	/**
	 * Sets the ClassInfo of an object.
	 *
	 * @param __o The object to set the class of.
	 * @param __v The class info to set.
	 * @since 2020/02/23
	 */
	public static native void objectSetClassInfo(long __o, ClassInfo __v);
	
	/**
	 * Sets the ClassInfo of an object.
	 *
	 * @param __o The object to set the class of.
	 * @param __v The class info to set.
	 * @since 2020/02/23
	 */
	public static native void objectSetClassInfo(Object __o, ClassInfo __v);
	
	/**
	 * Used to convert an object to a pointer.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native long objectToPointer(Object __o);
	
	/**
	 * Used to convert an object to a pointer, do use reference queing for it
	 * so that if the object is a candidate for reference counting it will
	 * be uncounted.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native long objectToPointerRefQueue(Object __o);
	
	/**
	 * Used to convert a pointer to an object.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native Object pointerToObject(long __p);
	
	/**
	 * Used to convert a pointer to a class info type.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native ClassInfo pointerToClassInfo(long __p);
	
	/**
	 * Loads a value from the constant pool at the given index.
	 *
	 * @param __p The memory address of the pool to access.
	 * @param __i The index to load.
	 * @return The read value, this may be truncated to 32-bits on 32-bit
	 * systems.
	 * @since 2020/02/24
	 */
	public static native long poolLoad(long __p, int __i);
	
	/**
	 * Loads a value from the constant pool at the given index.
	 *
	 * @param __p The object representation of the pool to access.
	 * @param __i The index to load.
	 * @return The read value, this may be truncated to 32-bits on 32-bit
	 * systems
	 * @since 2020/02/24
	 */
	public static native long poolLoad(Object __p, int __i);
	
	/**
	 * Writes a value to the constant pool of a class.
	 * 
	 * @param __p The address of the constant pool.
	 * @param __i The index to write.
	 * @param __v The value to write, note that on 32-bit .
	 * @since 2019/02/24
	 */
	public static native void poolStore(long __p, int __i, long __v);
	
	/**
	 * Writes a value to the constant pool of a class.
	 * 
	 * @param __p The object representation of the pool to access.
	 * @param __i The index to write.
	 * @param __v The value to write, note that on 32-bit .
	 * @since 2019/02/24
	 */
	public static native void poolStore(Object __p, int __i, long __v);
	
	/**
	 * Perform reference counting logic on object.
	 *
	 * @param __p The object to count up.
	 * @since 2019/05/25
	 */
	public static native void refCount(long __p);
	
	/**
	 * Perform reference counting logic on object.
	 *
	 * @param __p The object to count up.
	 * @since 2020/02/24
	 */
	public static native void refCount(Object __p);
	
	/**
	 * Get reference count of object.
	 * 
	 * @param __p The object to get the count for.
	 * @return The reference count of the object.
	 * @since 2020/02/24
	 */
	public static native int refGetCount(long __p);
	
	/**
	 * Get reference count of object.
	 * 
	 * @param __p The object to get the count for.
	 * @return The reference count of the object.
	 * @since 2020/02/24
	 */
	public static native int refGetCount(Object __p);
	
	/**
	 * Set reference count of object.
	 * 
	 * @param __p The object to set the count for.
	 * @param __v The value to set.
	 * @since 2020/02/24
	 */
	public static native void refSetCount(long __p, int __v);
	
	/**
	 * Set reference count of object.
	 * 
	 * @param __p The object to set the count for.
	 * @param __v The value to set.
	 * @since 2020/02/24
	 */
	public static native void refSetCount(Object __p, int __v);
	
	/**
	 * Perform reference uncounting logic on object.
	 *
	 * @param __p The object to count down.
	 * @since 2019/05/25
	 */
	public static native void refUncount(long __p);
	
	/**
	 * Perform reference uncounting logic on object.
	 *
	 * @param __p The object to count down.
	 * @since 2020/02/24
	 */
	public static native void refUncount(Object __p);
	
	/**
	 * Return from the current frame.
	 *
	 * @since 2019/04/21
	 */
	public static native void returnFrame();
	
	/**
	 * Returns from the current frame, returning the given value.
	 *
	 * @param __v The value to return.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __v);
	
	/**
	 * Returns from the current frame, returning both values.
	 *
	 * @param __h The high value.
	 * @param __l The low value.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __h, int __l);
	
	/**
	 * Returns from the current frame, returning a long value.
	 *
	 * @param __v The value.
	 * @since 2020/02/24
	 */
	public static native void returnFrameLong(long __v);
	
	/**
	 * Returns the size of base arrays.
	 * 
	 * @return The base array size.
	 * @since 2020/02/24
	 */
	public static native int sizeOfBaseArray();
	
	/**
	 * Returns the size of base objects.
	 * 
	 * @return The base object size.
	 * @since 2020/02/24
	 */
	public static native int sizeOfBaseObject();
	
	/**
	 * Returns the size of pointers and object references.
	 * 
	 * @return The pointer size.
	 * @since 2020/02/24
	 */
	public static native int sizeOfPointer();
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2020/02/24
	 */
	public static native Object specialGetExceptionRegister();
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2020/02/24
	 */
	public static native Throwable specialGetExceptionRegisterThrowable();
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2019/04/28
	 */
	public static native long specialGetExceptionRegisterPointer();
	
	/**
	 * Returns the value of the current pool register.
	 *
	 * @return The value of the pool register.
	 * @since 2020/02/24
	 */
	public static native Object specialGetPoolRegister();
	
	/**
	 * Returns the value of the current pool register.
	 *
	 * @return The value of the pool register.
	 * @since 2019/05/01
	 */
	public static native long specialGetPoolRegisterPointer();
	
	/**
	 * Returns the value of the return register, for long return values this
	 * is the first high register.
	 *
	 * @return The value of the return register.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnRegister();
	
	/**
	 * Reads the long value from the return register, treating it as a long
	 * value.
	 *
	 * @return The value of the return register.
	 * @since 2020/02/24
	 */
	public static native long specialGetReturnRegisterLong();
	
	/**
	 * Reads the value of the static field register.
	 *
	 * @return The value of the static field register.
	 * @since 2019/04/22
	 */
	public static native long specialGetStaticFieldRegister();
	
	/**
	 * Returns the register representing the current thread.
	 *
	 * @return The current thread register.
	 * @since 2019/04/22
	 */
	public static native Thread specialGetThreadRegister();
	
	/**
	 * Returns the register representing the current thread.
	 *
	 * @return The current thread register.
	 * @since 2020/02/24
	 */
	public static native long specialGetThreadRegisterPointer();
	
	/**
	 * Sets the value of the exception register.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/28
	 */
	public static native void specialSetExceptionRegister(long __v);
	
	/**
	 * Sets the value of the exception register.
	 *
	 * @param __v The value to use.
	 * @since 2020/02/24
	 */
	public static native void specialSetExceptionRegister(Object __v);
	
	/**
	 * Sets the value of the constant pool register.
	 *
	 * @param __v The new value of the constant pool register.
	 * @since 2019/05/01
	 */
	public static native void specialSetPoolRegister(long __v);
	
	/**
	 * Sets the value of the constant pool register.
	 *
	 * @param __v The new value of the constant pool register.
	 * @since 2020/02/24
	 */
	public static native void specialSetPoolRegister(Object __v);
	
	/**
	 * Sets the value of the static field register.
	 *
	 * @param __v The new value of the static field register.
	 * @since 2019/04/22
	 */
	public static native void specialSetStaticFieldRegister(long __v);
	
	/**
	 * Sets the current thread pointer.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/27
	 */
	public static native void specialSetThreadRegister(long __v);
	
	/**
	 * Sets the current thread pointer.
	 *
	 * @param __v The value to use.
	 * @since 2020/02/24
	 */
	public static native void specialSetThreadRegister(Thread __v);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si The address to invoke.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si The address to invoke.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/CallStackItem.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 single item within the call stack request.
 *
 * @since 2019/06/16
 */
public interface CallStackItem
{
	/** The class name. */
	byte CLASS_NAME =
		0;
	
	/** The method name. */
	byte METHOD_NAME =
		1;
	
	/** The method type. */
	byte METHOD_TYPE =
		2;
	
	/** The current file. */
	byte SOURCE_FILE =
		3;
	
	/** Source line. */
	byte SOURCE_LINE =
		4;
	
	/** The PC address. */
	byte PC_ADDRESS =
		5;
	
	/** Java operation. */
	byte JAVA_OPERATION =
		6;
	
	/** Java PC address. */
	byte JAVA_PC_ADDRESS =
		7;
	
	/** The current task ID. */
	byte TASK_ID =
		8;
	
	/** The number of supported items. */
	byte NUM_ITEMS =
		9;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/ClassInfo.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 contains class information which is used to define the information
 * that is needed to parse it properly.
 *
 * @since 2019/05/25
 */
public final class ClassInfo
{
	/** The magic number which should be used. */
	public static final int MAGIC_NUMBER =
		0x4C6F7665;
	
	/** Self pointer. */
	public final int selfptr;
	
	/** Magic number used to detect corruption. */
	public final int magic;
	
	/** Class information flags. */
	public final int flags;
	
	/** The pointer to the minimized class file. */
	public final int miniptr;
	
	/** The pointer to the class name. */
	public final int namep;
	
	/** The allocation size of this class. */
	public final int size;
	
	/** The base offset for fields in this class. */
	public final int base;
	
	/** The number of objects in the instance fields, for GC. */
	public final int numobjects;
	
	/** The dimensions this class uses, if it is an array. */
	public final int dimensions;
	
	/** The cell size of components if this is an array. */
	public final int cellsize;
	
	/** The super class data. */
	public final ClassInfo superclass;
	
	/** Interfaces. */
	public final ClassInfo[] interfaceclasses;
	
	/** The component class. */
	public final ClassInfo componentclass;
	
	/** Pointer to the class object. */
	public final Class<?> classobjptr;
	
	/** Virtual invoke VTable. */
	public final int[] vtablevirtual;
	
	/** Virtual invoke VTable pool entries. */
	public final int[] vtablepool;
	
	/** The pointer to the constant pool of this class. */
	public final int pool;
	
	/** The JAR this class is a part of. */
	public final int jardx;
	
	/** The total method count. */
	public final int nummethods;
	
	/** The depth of this class. */
	public final int classdepth;
	
	/** The static field pointer offset for the class. */
	public final int sfoffset;
	
	/** The pointer of the default constructor. */
	public final int defaultnew;
	
	/**
	 * Class information constructor.
	 *
	 * @param __sp Self pointer.
	 * @param __fl Class information flags.
	 * @param __minip Pointer to the hardware class data in ROM.
	 * @param __namep The name pointer.
	 * @param __sz The size of this class.
	 * @param __bz The base offset for fields.
	 * @param __no The number of objects in the field instance.
	 * @param __dim Dimensions.
	 * @param __csz Cell size.
	 * @param __scl The super class data.
	 * @param __icl Interface classes.
	 * @param __ccl Component class.
	 * @param __cop Pointer to the class object.
	 * @param __vtv Virtual invoke VTable address.
	 * @param __vtp Virtual invoke VTable pool addresses.
	 * @param __pool The pointer to the class constant pool.
	 * @param __jardx The JAR Index.
	 * @param __nm The number of methods that are used.
	 * @param __cd The class depth.
	 * @param __sfp The static field offset.
	 * @param __dn The default constructor.
	 * @since 2019/04/26
	 */
	public ClassInfo(int __sp, int __fl, int __minip, int __namep, int __sz,
		int __bz, int __no, int __dim, int __csz, ClassInfo __scl,
		ClassInfo[] __icl, ClassInfo __ccl, Class<?> __cop, int[] __vtv,
		int[] __vtp, int __pool, int __jardx, int __nm, int __cd, int __sfp,
		int __dn)
	{
		// Always implicitly set magic
		this.magic = ClassInfo.MAGIC_NUMBER;
		
		// Set
		this.selfptr = __sp;
		this.flags = __fl;
		this.miniptr = __minip;
		this.namep = __namep;
		this.size = __sz;
		this.base = __bz;
		this.numobjects = __no;
		this.dimensions = __dim;
		this.cellsize = __csz;
		this.superclass = __scl;
		this.interfaceclasses = (__icl == null ? new ClassInfo[0] : __icl);
		this.componentclass = __ccl;
		this.classobjptr = __cop;
		this.vtablevirtual = (__vtv == null ? new int[0] : __vtv);
		this.vtablepool = (__vtp == null ? new int[0] : __vtp);
		this.pool = __pool;
		this.jardx = __jardx;
		this.nummethods = __nm;
		this.classdepth = __cd;
		this.sfoffset = __sfp;
		this.defaultnew = __dn;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/ClassLoadingAdjustments.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Adjustments to class loading.
 *
 * @since 2019/12/15
 */
public final class ClassLoadingAdjustments
{
	/**
	 * Is this class deferred loaded?
	 *
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __cl)
		throws NullPointerException
	{
		switch (__cl)
		{
				// Primitive types
			case "boolean":
			case "byte":
			case "short":
			case "char":
			case "int":
			case "float":
			case "long":
			case "double":
			
				// Primitive array types
			case "[Z":
			case "[B":
			case "[S":
			case "[C":
			case "[I":
			case "[F":
			case "[J":
			case "[D":
				
				// Common Java objects
			case "java/io/IOException":
			case "java/io/PrintStream":
			case "java/lang/Appendable":
			case "java/lang/ArithmeticException":
			case "java/lang/ArrayIndexOutOfBoundsException":
			case "java/lang/AssertionError":
			case "java/lang/AutoCloseable":
			case "java/lang/Boolean":
			case "java/lang/Byte":
			case "java/lang/Character":
			case "java/lang/Class":
			case "java/lang/ClassCastException":
			case "java/lang/Cloneable":
			case "java/lang/Closeable":
			case "java/lang/Comparable":
			case "java/lang/Double":
			case "java/lang/Enum":
			case "java/lang/Error":
			case "java/lang/Float":
			case "java/lang/IllegalArgumentException":
			case "java/lang/IllegalMonitorStateException":
			case "java/lang/IllegalStateException":
			case "java/lang/IllegalThreadStateException":
			case "java/lang/IndexOutOfBoundsException":
			case "java/lang/Integer":
			case "java/lang/InterruptedException":
			case "java/lang/Long":
			case "java/lang/Math":
			case "java/lang/NegativeArraySizeException":
			case "java/lang/NoClassDefFoundError":
			case "java/lang/NoSuchElementException":
			case "java/lang/NullPointerException":
			case "java/lang/Number":
			case "java/lang/Object":
			case "java/lang/OutOfMemoryError":
			case "java/lang/Runtime":
			case "java/lang/RuntimeException":
			case "java/lang/Short":
			case "java/lang/String":
			case "java/lang/StringBuffer":
			case "java/lang/StringBuilder":
			case "java/lang/StringIndexOutOfBoundsException":
			case "java/lang/System":
			case "java/lang/Thread":
			case "java/lang/Throwable":
			case "java/lang/VirtualMachineError":
			case "java/lang/ref/Reference":
			case "java/lang/ref/ReferenceQueue":
			case "java/lang/ref/WeakReference":
			case "java/util/Deque":
			case "java/util/Formatter":
			case "java/util/Iterable":
			case "java/util/Iterator":
			case "java/util/List":
			case "java/util/Map":
			case "java/util/Objects":
			case "java/util/Queue":
			case "java/util/Random":
			case "java/util/Set":
			
				// SquirrelJME special classes
			case "cc/squirreljme/jvm/Assembly":
			case "cc/squirreljme/jvm/ClassInfo":
			case "cc/squirreljme/jvm/Constants":
			case "cc/squirreljme/jvm/IPCCallback":
			case "cc/squirreljme/jvm/IPCException":
			case "cc/squirreljme/jvm/IPCManager":
			case "cc/squirreljme/jvm/JVMFunction":
			case "cc/squirreljme/jvm/SoftDouble":
			case "cc/squirreljme/jvm/SoftFloat":
			case "cc/squirreljme/jvm/SoftInteger":
			case "cc/squirreljme/jvm/SoftLong":
			case "cc/squirreljme/jvm/SystemCallError":
			case "cc/squirreljme/jvm/SystemCallIndex":
			
				// Common array classes
			case "[Lcc/squirreljme/jvm/ClassInfo;":
			case "[Ljava/lang/String;":
				return false;
				
			default:
				return true;
		}
	}
	
	/**
	 * Is this class deferred loaded in relation to the current class?
	 *
	 * @param __self The current class.
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __self, String __cl)
		throws NullPointerException
	{
		if (__self == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Same class is never deferred
		if (__self.equals(__cl))
			return false;
		
		// Is within the same package?
		int ls = __self.lastIndexOf('/');
		if (ls >= 0 && __self.regionMatches(0, __cl, 0, ls))
			return false;
		
		// Use default defer logic
		return ClassLoadingAdjustments.isDeferredLoad(__cl);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/ConfigRomType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 an option in the configuration ROM.
 *
 * @since 2019/06/14
 */
public interface ConfigRomType
{
	/** End of configuration. */
	byte END =
		0;
	
	/** Java VM Version. */
	byte JAVA_VM_VERSION =
		1;
	
	/** Java VM Name. */
	byte JAVA_VM_NAME =
		2;
	
	/** Java VM Vendor. */
	byte JAVA_VM_VENDOR =
		3;
	
	/** Java VM E-Mail. */
	byte JAVA_VM_EMAIL =
		4;
	
	/** Java VM URL. */
	byte JAVA_VM_URL =
		5;
	
	/** The guest depth. */
	byte GUEST_DEPTH =
		6;
	
	/** Main class. */
	byte MAIN_CLASS =
		7;
	
	/** Main program arguments. */
	byte MAIN_ARGUMENTS =
		8;
	
	/** Is this a MIDlet? */
	byte IS_MIDLET =
		9;
	
	/** Define system propertly. */
	byte DEFINE_PROPERTY =
		10;
	
	/** Classpath to use. */
	byte CLASS_PATH =
		11;
	
	/** System call static field pointer. */
	byte SYSCALL_STATIC_FIELD_POINTER =
		12;
	
	/** System call method pointer. */
	byte SYSCALL_CODE_POINTER =
		13;
	
	/** System call pool pointer. */
	byte SYSCALL_POOL_POINTER =
		14;
	
	/** Number of available options. */
	byte NUM_OPTIONS =
		15;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/Constants.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Virtual machine constants.
 *
 * @since 2019/05/26
 */
public interface Constants
{
	/** The offset for the object's class type. */
	byte OBJECT_CLASS_OFFSET =
		0;
	
	/** The offset for the object's reference count. */
	byte OBJECT_COUNT_OFFSET =
		4;
	
	/** Object monitor owner offset. */
	byte OBJECT_MONITOR_OFFSET =
		8;
	
	/** Object monitor count offset. */
	byte OBJECT_MONITOR_COUNT_OFFSET =
		12;
	
	/** Base size for object types. */
	byte OBJECT_BASE_SIZE =
		16;
	
	/** The offset for array length. */
	byte ARRAY_LENGTH_OFFSET =
		16;
	
	/** The base size for arrays. */
	byte ARRAY_BASE_SIZE =
		20;
	
	/** Constant pool cell size. */
	byte POOL_CELL_SIZE =
		4;
	
	/** Bad magic number. */
	int BAD_MAGIC =
		0xE7E5E7E4;
	
	/** Class info flag: Is array type? */
	short CIF_IS_ARRAY =
		0x0001;
	
	/** Class info flag: Is array of objects? */
	short CIF_IS_ARRAY_OF_OBJECTS =
		0x0002;
	
	/** Is this a primitive type? */
	short CIF_IS_PRIMITIVE =
		0x0004;
	
	/** Offset for the configuration key. */
	byte CONFIG_KEY_OFFSET =
		0;
	
	/** Offset for the configuration size. */
	byte CONFIG_SIZE_OFFSET =
		2;
	
	/** Size of the header for configuration items. */
	byte CONFIG_HEADER_SIZE =
		4;
	
	/** The thread ID for out-of-bound IPC events. */
	int OOB_IPC_THREAD =
		0xFFFFFFFF;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/DefaultIPCRouter.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 is a router which just forward IPC requests to the standard manager.
 *
 * @since 2019/12/28
 */
public final class DefaultIPCRouter
	implements IPCCallback
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		return IPCManager.ipcCall(__tid, __ipcid, __a, __b, __c, __d, __e,
			__f, __g, __h);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/DeviceFeedbackType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 the type of feedback to perform for a device.
 *
 * @since 2019/10/05
 */
public interface DeviceFeedbackType
{
	/** Vibrate. */
	byte VIBRATE =
		1;
	
	/** Blink/Pulse LED, be aware of conditions such as epilepsy. */
	byte BLINK_LED =
		2;
	
	/** The number of feedback types. */
	byte NUM_FEEDBACK_TYPES =
		3;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/Framebuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 is used to get/set the property of the framebuffer.
 *
 * @since 2019/06/20
 */
public interface Framebuffer
{
	/**
	 * Returns the address of the framebuffer.
	 *
	 * @squirreljme.syscallreturn The framebuffer address.
	 */
	byte CONTROL_ADDRESS =
		1;
	
	/**
	 * Returns the width of the framebuffer.
	 *
	 * @squirreljme.syscallreturn The framebuffer width.
	 */
	byte CONTROL_WIDTH =
		2;
	
	/**
	 * Returns the height of the framebuffer.
	 *
	 * @squirreljme.syscallreturn The framebuffer height.
	 */
	byte CONTROL_HEIGHT =
		3;
	
	/**
	 * Returns the scanline length.
	 *
	 * @squirreljme.syscallreturn The framebuffer scanline length.
	 */
	byte CONTROL_SCANLEN =
		4;
	
	/**
	 * Flush the display because it has been drawn.
	 */
	byte CONTROL_FLUSH =
		5;
	
	/**
	 * Returns the pixel format of the screen.
	 *
	 * @squirreljme.syscallreturn The pixel format of the screen.
	 */
	byte CONTROL_FORMAT =
		6;
	
	/**
	 * Returns the scanline length in bytes.
	 *
	 * @squirreljme.syscallreturn The scanline length in bytes.
	 */
	byte CONTROL_SCANLEN_BYTES =
		7;
	
	/**
	 * Returns the number of bytes per pixel.
	 *
	 * @squirreljme.syscallreturn The bytes per pixel.
	 */
	byte CONTROL_BYTES_PER_PIXEL =
		8;
	
	/**
	 * Returns the number of available pixels.
	 *
	 * @squirreljme.syscallreturn The number of pixels.
	 */
	byte CONTROL_NUM_PIXELS =
		9;
	
	/**
	 * Bits per pixel.
	 *
	 * @squirreljme.syscallreturn The bits per pixel.
	 */
	byte CONTROL_BITS_PER_PIXEL =
		10;
	
	/**
	 * Get backlight level.
	 *
	 * @squirreljme.syscallreturn The current backlight level.
	 */
	byte CONTROL_BACKLIGHT_LEVEL_GET =
		11;
	
	/**
	 * Set backlight level.
	 *
	 * @squirreljme.syscallparam 1 The level to set.
	 */
	byte CONTROL_BACKLIGHT_LEVEL_SET =
		12;
	
	/**
	 * Maximum backlight level.
	 *
	 * @squirreljme.syscallreturn The maximum backlight level.
	 */
	byte CONTROL_BACKLIGHT_LEVEL_MAX =
		13;
	
	/**
	 * Uploads an integer array of pixel data to the framebuffer.
	 *
	 * @squirreljme.syscallparam 1 The address of the array to upload.
	 * @since 2019/12/21
	 */
	byte CONTROL_UPLOAD_ARRAY_INT =
		14;
	
	/**
	 * The array which backs the framebuffer, if there is one.
	 *
	 * @squirreljme.syscallreturn The backing array object, if there is one.
	 * @since 2019/12/28
	 */
	byte CONTROL_BACKING_ARRAY_OBJECT =
		15;
		
	/**
	 * Returns the capabilities of the display.
	 *
	 * @squirreljme.syscallreturn The display capabilities.
	 * @since 2020/01/10
	 */
	byte CONTROL_GET_CAPABILITIES =
		16;
	
	/**
	 * Query acceleration function.
	 *
	 * @squirreljme.syscallparam 1 The graphics function.
	 * @squirreljme.syscallreturn A non-zero value if this is supported.
	 * @since 2020/01/10
	 */
	byte CONTROL_ACCEL_FUNC_QUERY =
		17;
	
	/**
	 * Perform acceleration function.
	 *
	 * @squirreljme.syscallparam 1 The graphics function.
	 * @squirreljme.syscallparam ... Parameters to the function.
	 * @squirreljme.syscallreturn A value that is according to the invoked
	 * function, if it is supported or possible.
	 * @since 2020/01/10
	 */
	byte CONTROL_ACCEL_FUNC_INVOKE =
		18;
	
	/**
	 * Requests that the framebuffer be repainted.
	 *
	 * @squirreljme.syscallparam 1 The X coordinate.
	 * @squirreljme.syscallparam 2 The Y coordinate.
	 * @squirreljme.syscallparam 3 The width.
	 * @squirreljme.syscallparam 4 The height.
	 * @squirreljme.syscallreturn Returns {@code 0} if the repaint was not
	 * queued and it must be handled by the code running the application,
	 * @since 2020/01/15
	 */
	byte CONTROL_REPAINT_REQUEST =
		19;
	
	/**
	 * Sets the title of the framebuffer if applicable.
	 *
	 * @squirreljme.syscallparam 1 Char buffer pointer (high).
	 * @squirreljme.syscallparam 2 Char buffer pointer (low).
	 * @since 2020/01/15
	 */
	byte CONTROL_SET_TITLE =
		20;
	
	/** The number of framebuffer controls. */
	byte NUM_CONTROLS =
		21;
	
	/** Screen is RGB 32-bit. */
	byte FORMAT_INTEGER_RGB888 =
		0;
	
	/** Screen is 8-bit indexed. */
	byte FORMAT_BYTE_INDEXED =
		1;
	
	/** Screen is 16-bit RGB565. */
	byte FORMAT_SHORT_RGB565 =
		2;
	
	/** Screen is packed 1 bit values. */
	byte FORMAT_PACKED_ONE =
		3;
	
	/** Screen is packed 2 bit values. */
	byte FORMAT_PACKED_TWO =
		4;
	
	/** Screen is packed 4 bit values. */
	byte FORMAT_PACKED_FOUR =
		5;
	
	/** Has touch-screen. */
	byte CAPABILITY_TOUCH =
		0x01;
	
	/** Has keyboard. */
	byte CAPABILITY_KEYBOARD =
		0x02;
	
	/** The JVM pushes to the IPC handler when events happen. */
	byte CAPABILITY_IPC_EVENTS =
		0x04;
	
	/** Has screen flipping? */
	byte CAPABILITY_SCREEN_FLIP =
		0x08;
	
	/** Screen has color that is not just a single shade. */
	byte CAPABILITY_COLOR =
		0x10;
	
	/** Set color. */
	byte ACCEL_FUNC_SET_COLOR =
		0;
	
	/** Draw line. */
	byte ACCEL_FUNC_DRAW_LINE =
		1;
	
	/** Get the X clip. */
	byte ACCEL_FUNC_GET_CLIP_X =
		2;
	
	/** Get the Y clip. */
	byte ACCEL_FUNC_GET_CLIP_Y =
		3;
	
	/** Get the width clip. */
	byte ACCEL_FUNC_GET_CLIP_WIDTH =
		4;
	
	/** Get the height clip. */
	byte ACCEL_FUNC_GET_CLIP_HEIGHT =
		5;
	
	/** Set the clip. */
	byte ACCEL_FUNC_SET_CLIP =
		6;
	
	/** Draw rectangle. */
	byte ACCEL_FUNC_DRAW_RECT =
		7;
	
	/** Get the alpha color. */
	byte ACCEL_FUNC_GET_ALPHA_COLOR =
		8;
	
	/** Set the alpha color. */
	byte ACCEL_FUNC_SET_ALPHA_COLOR =
		9;
	
	/** Fill rectangle. */
	byte ACCEL_FUNC_FILL_RECT =
		10;
	
	/** Sets the fonts for the graphics. */
	byte ACCEL_FUNC_SET_FONT =
		11;
	
	/** Gets the font to use for drawing. */
	byte ACCEL_FUNC_GET_FONT =
		12;
	
	/** Draw sub-characters. */
	byte ACCEL_FUNC_DRAW_SUB_CHARS =
		13;
	
	/** Draw text. */
	byte ACCEL_FUNC_DRAW_TEXT =
		14;
	
	/** Get stroke style. */
	byte ACCEL_FUNC_GET_STROKE_STYLE =
		15;
	
	/** Set stroke style. */
	byte ACCEL_FUNC_SET_STROKE_STYLE =
		16;
	
	/** Copy area. */
	byte ACCEL_FUNC_COPY_AREA =
		17;
	
	/** Draw arc. */
	byte ACCEL_FUNC_DRAW_ARC =
		18;
	
	/** Draw ARGB16. */
	byte ACCEL_FUNC_DRAW_ARGB16 =
		19;
	
	/** Draw character. */
	byte ACCEL_FUNC_DRAW_CHAR =
		20;
	
	/** Draw characters. */
	byte ACCEL_FUNC_DRAW_CHARS =
		21;
	
	/** Draw RGB. */
	byte ACCEL_FUNC_DRAW_RGB =
		22;
	
	/** Draw RGB16. */
	byte ACCEL_FUNC_DRAW_RGB16 =
		23;
	
	/** Draw round rectangle. */
	byte ACCEL_FUNC_DRAW_ROUND_RECT =
		24;
	
	/** Fill arc. */
	byte ACCEL_FUNC_FILL_ARC =
		25;
	
	/** Fill round rectangle. */
	byte ACCEL_FUNC_FILL_ROUND_RECT =
		26;
	
	/** Fill triangle. */
	byte ACCEL_FUNC_FILL_TRIANGLE =
		27;
	
	/** Get blending mode. */
	byte ACCEL_FUNC_GET_BLENDING_MODE =
		28;
	
	/** Get display color. */
	byte ACCEL_FUNC_GET_DISPLAY_COLOR =
		29;
	
	/** Set blending mode. */
	byte ACCEL_FUNC_SET_BLENDING_MODE =
		30;
	
	/** Draw region. */
	byte ACCEL_FUNC_DRAW_REGION =
		31;
	
	/** Number of acceleration functions. */
	byte NUM_ACCEL_FUNC =
		32;
	
	/** The IPC ID for the graphics callbacks. */
	int IPC_ID =
		0x47665821;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/IPCCallback.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Anything which would like to listen for IPCs must implement and register
 * this callback.
 *
 * @since 2019/12/28
 */
public interface IPCCallback
{
	/**
	 * Any classes which
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Argument C.
	 * @param __d Argument D.
	 * @param __e Argument E.
	 * @param __f Argument F.
	 * @param __g Argument G.
	 * @param __h Argument H.
	 * @return The result of the IPC call.
	 * @since 2019/12/28
	 */
	long ipcCall(int __tid, int __ipcid, int __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/IPCException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 is an exception which was thrown in a cross RPC call.
 *
 * @since 2019/12/28
 */
public class IPCException
	extends RuntimeException
{
	/** The class name note pointer. */
	protected final int classnotepointer;
	
	/**
	 * Initializes the exception with an unknown type.
	 *
	 * @since 2019/12/28
	 */
	public IPCException()
	{
		this.classnotepointer = 0;
	}
	
	/**
	 * Initializes the IPC Exception.
	 *
	 * @param __cnp The class note pointer which was used.
	 * @since 2019/12/28
	 */
	public IPCException(int __cnp)
	{
		this.classnotepointer = __cnp;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/IPCManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util.HashMap;
import java.util.Map;

/**
 * This class is used to manage the IPC interface and allow any service to
 * register IPC messages and such.
 *
 * @since 2019/12/28
 */
public final class IPCManager
{
	/** Services that are available. */
	private static final Map<Integer, IPCCallback> _IPC_MAP =
		new HashMap<>();
	
	/**
	 * No instances of this class.
	 *
	 * @since 2019/12/28
	 */
	private IPCManager()
	{
	}
	
	/**
	 * This is the handler for IPC messages.
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Argument C.
	 * @param __d Argument D.
	 * @param __e Argument E.
	 * @param __f Argument F.
	 * @param __g Argument G.
	 * @param __h Argument H.
	 * @return The result of the IPC call.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		IPCCallback handler = null;
		
		// Find the IPC Callback handler
		Map<Integer, IPCCallback> ipcmap = IPCManager._IPC_MAP;
		synchronized (ipcmap)
		{
			handler = ipcmap.get(__ipcid);
		}
		
		// Drop the call if there is no handler
		if (handler == null)
			return 0;
		
		// Perform the call
		return handler.ipcCall(__tid, __ipcid, __a, __b, __c, __d, __e, __f,
			__g, __h);
	}
	
	/**
	 * This is the handler for IPC messages, which performs unfolding
	 * accordingly.
	 *
	 * @param __tid The origin task ID.
	 * @param __v Input values.
	 * @return The result of the IPC call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int n = __v.length;
		return IPCManager.ipcCall(__tid,
			(0 < n ? __v[0] : 0),
			(1 < n ? __v[1] : 0),
			(2 < n ? __v[2] : 0),
			(3 < n ? __v[3] : 0),
			(4 < n ? __v[4] : 0),
			(5 < n ? __v[5] : 0),
			(6 < n ? __v[6] : 0),
			(7 < n ? __v[7] : 0),
			(8 < n ? __v[8] : 0));
	}
	
	/**
	 * This is the handler for IPC messages, which performs unfolding
	 * accordingly.
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __v Input values.
	 * @return The result of the IPC call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int __ipcid, int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int n = __v.length;
		return IPCManager.ipcCall(__tid,
			__ipcid,
			(0 < n ? __v[0] : 0),
			(1 < n ? __v[1] : 0),
			(2 < n ? __v[2] : 0),
			(3 < n ? __v[3] : 0),
			(4 < n ? __v[4] : 0),
			(5 < n ? __v[5] : 0),
			(6 < n ? __v[6] : 0),
			(7 < n ? __v[7] : 0));
	}
	
	/**
	 * Registers the given ID with the specified callback.
	 *
	 * @param __ipcid The IPC ID to listen on.
	 * @param __cb The callback for the IPC.
	 * @throws IllegalArgumentException If IPC ID is zero.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final void register(int __ipcid, IPCCallback __cb)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cb == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3u It is not valid to register the zero
		// IPC ID.}
		if (__ipcid == 0)
			throw new IllegalArgumentException("ZZ3u");
		
		// Lock and register
		Map<Integer, IPCCallback> ipcmap = IPCManager._IPC_MAP;
		synchronized (ipcmap)
		{
			ipcmap.put(__ipcid, __cb);
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/JVMFunction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 class contains the functions of the virtual machine.
 *
 * @since 2019/05/25
 */
public final class JVMFunction
{
	/**
	 * 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
	 * be returned, otherwise {@code 0} will.
	 * @since 2019/04/27
	 */
	public static final int jvmCanArrayStore(int __p, int __v)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the component type of the array
	 *
	 * @param __clid The class ID
	 * @return The component type of the array or {@code 0} if it is not an
	 * array.
	 * @since 2019/04/27
	 */
	public static final int jvmComponentType(int __clid)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Performs aggressive garbage collection of the JVM heap to free as much
	 * memory as possible.
	 *
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollect()
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Garbage collects a single object.
	 *
	 * @param __p The object to garbage collect.
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the given class.
	 *
	 * @param __ns The noted string.
	 * @return The loaded class info.
	 * @since 2019/12/15
	 */
	public static final ClassInfo jvmInitClass(int __ns)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Searches the interface vtables for the class of object {@code __p}
	 * and searches for an interface implementation of class {@code __icl} and
	 * if one is found then the pointer for index {@code __mdx} is returned.
	 *
	 * @param __p The object to do a interface lookup on.
	 * @param __icl The interface class to find.
	 * @param __mdx The method index to relate to, of the interface class.
	 * @return The pointer to the code to be invoked in the low-word and the
	 * pool of the target class in the high-word.
	 * @since 2019/04/30
	 */
	public static final long jvmInterfacePointer(int __p, int __icl, int __mdx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
		// Assembly.longPack(hi, lo)
	}
	
	/**
	 * Checks whether the given pointer is an array.
	 *
	 * @param __p The pointer to check.
	 * @return Either {@code 1} if it is an array or {@code 0} if it is not.
	 * @since 2019/04/27
	 */
	public static final int jvmIsArray(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an instance of the given class.
	 *
	 * @param __p The pointer to check.
	 * @param __cldx The class index.
	 * @return Either {@code 1} if the class is an instance or {@code 0} if
	 * it is not.
	 * @since 2019/04/22
	 */
	public static final int jvmIsInstance(int __p, int __cldx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the {@link Class} instance for the given class info pointer,
	 * if none has been created yet then it will be created as needed.
	 *
	 * @param <T> The class type.
	 * @param __cldx The class index pointer.
	 * @return The resulting class.
	 * @since 2019/05/26
	 */
	public static final <T> Class<T> jvmLoadClass(ClassInfo __cldx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Loads a string from memory and returns an `intern()` string value.
	 *
	 * @param __p The pointer to load the string bytes from.
	 * @return The resulting string.
	 * @since 2019/05/26
	 */
	public static final String jvmLoadString(int __p)
	{
		// Zero will be the null pointer
		if (__p == 0)
			return null;
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Reads a long value from the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @return The read value.
	 * @since 2019/05/29
	 */
	public static final long jvmMemReadLong(int __addr, int __off)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __hv The high value.
	 * @param __lv The low value.
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, int __hv,
		int __lv)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __v The value
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, long __v)
	{
		JVMFunction.jvmMemWriteLong(__addr, __off,
			(int)(__v >>> 32), (int)__v);
	}
	
	/**
	 * Enters the monitor for the given object.
	 *
	 * @param __p The object to enter.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorEnter(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Exits the monitor for the given object.
	 *
	 * @param __p The object to exit.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorExit(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new object.
	 *
	 * @param __cl The class type.
	 * @return The resulting class pointer.
	 * @throws OutOfMemoryError If there is not enough memory to allocate the
	 * class.
	 * @since 2019/05/24
	 */
	public static final int jvmNew(int __cl)
		throws OutOfMemoryError
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new array.
	 *
	 * @param __at The array type.
	 * @param __len The length of the array.
	 * @return The resulting array pointer.
	 * @throws NegativeArraySizeException If the array length is negative.
	 * @throws OutOfMemoryError If there is not enough memory to allocate the
	 * array.
	 * @since 2019/04/24
	 */
	public static final int jvmNewArray(int __at, int __len)
		throws NegativeArraySizeException, OutOfMemoryError
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * This handles an unpure system call which may modify the behavior of
	 * any system call which needs to be done. Some system calls might not be
	 * supported by the host machine or they might not make sense (such as
	 * garbage collection), so as such this allows their behavior to modified.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static final long jvmSystemCall(short __si, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		// Call pure form
		return Assembly.sysCallPVL(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SoftDouble.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Software math operations on 64-bit double.
 *
 * @since 2019/05/24
 */
public class SoftDouble
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftDouble()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double add(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double div(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double neg(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * ORs value, used for constants.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static double or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.doublePack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double rem(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double sub(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SoftFloat.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
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
191
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Software math operations on 32-bit floats.
 *
 * @since 2019/05/24
 */
public class SoftFloat
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftFloat()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float add(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float div(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float mul(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float neg(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Ors a value, used for constant loading.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float or(int __a, int __b)
	{
		return Assembly.intBitsToFloat(__a | __b);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float rem(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float sub(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SoftInteger.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Software integer operations.
 *
 * @since 2019/05/27
 */
public class SoftInteger
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/27
	 */
	private SoftInteger()
	{
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		// If the integer has the sign bit, then it will be sign extended
		// meaning all the upper bits get set
		if ((__a & 0x80000000) != 0)
			return Assembly.longPack(0xFFFFFFFF, __a);
		
		// Otherwise the top is just zero
		else
			return Assembly.longPack(0, __a);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SoftLong.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Software math operations on 64-bit integer types.
 *
 * @since 2019/05/24
 */
public final class SoftLong
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftLong()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long add(int __ah, int __al, int __bh, int __bl)
	{
		// Add the higher/lower parts
		int ch = __ah + __bh,
			cl = __al + __bl;
		
		// If the low addition carried a bit over, then set that bit in the
		// high part
		if ((cl + 0x80000000) < (__al + 0x80000000))
			ch++;
		
		// Return result
		return Assembly.longPack(ch, cl);
	}
	
	/**
	 * Ands two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long and(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah & __bh, __al & __bl);
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmp(int __ah, int __al, int __bh, int __bl)
	{
		// Compare high values firsts
		if (__ah < __bh)
			return -1;
		else if (__ah > __bh)
			return 1;
		
		// Compare low values with unsigned comparison
		__al += Integer.MIN_VALUE;
		__bl += Integer.MIN_VALUE;
		if (__al < __bl)
			return -1;
		else if (__al > __bl)
			return 1;
		return 0;
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long div(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(false, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long neg(int __ah, int __al)
	{
		// Negate and check for overflow
		int nh = (~__ah),
			nl = (~__al + 1);
		if (nl == 0)
			nh++;
		
		// Return result
		return Assembly.longPack(nh, nl);
	}
	
	/**
	 * Ors a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long rem(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(true, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Shifts value left by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shl(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the low bits to the high bits
		else if (__s >= 32)
			return Assembly.longPack(__al << (__s - 32), 0);
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah << __s) | (__al >>> (32 - __s)),
				(__al << __s));
	}
	
	/**
	 * Shifts value right by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack((__ah & 0x80000000) >> 31,
				__ah >> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long sub(int __ah, int __al, int __bh, int __bl)
	{
		// The same as add, but the second operand is negated
		long nb = SoftLong.neg(__bh, __bl);
		return SoftLong.add(__ah, __al,
			Assembly.longUnpackHigh(nb), Assembly.longUnpackLow(nb));
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __ah High value.
	 * @param __al Low value.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		// Just return the low order bits
		return __al;
	}
	
	/**
	 * Shifts value bits right unsigned.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long ushr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack(0, __ah >>> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >>> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Xors two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long xor(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah ^ __bh, __al ^ __bl);
	}
	
	/**
	 * Divides and remainders two values.
	 *
	 * @param __dorem Return the remainder?
	 * @param __num The numerator.
	 * @param __den The denominator.
	 * @return The result.
	 * @since 2019/05/24
	 */
	private static long __div(boolean __dorem, long __num, long __den)
	{
		// Wikipedia (http://en.wikipedia.org/wiki/Division_%28digital%29)
		// if D == 0 then throw DivisionByZeroException end
		// Q := 0 # initialize quotient and remainder to zero
		// R := 0
		// for i = n-1...0 do  # " where n is no of bits "
		//   R := R << 1       # left-shift R by 1 bit
		//   R(0) := N(i)      # set the least-significant bit
		//              # of R equal to bit i of the numerator
		//   if R >= D then
		//     R = R - D
		//     Q(i) := 1
		//   end
		// end
		long inquot = 0, inrem = 0;
		boolean isneg;
		
		// Disallow division by zero
		if (__den == 0)
			return 0;
		
		// Negative?
		isneg = ((__num < 0 && __den >= 0) || (__num >= 0 && __den < 0));
		
		// Force Positive
		__num = (__num < 0 ? -__num : __num);
		__den = (__den < 0 ? -__den : __den);
		
		// Perform Math
		for (int i = 63; i >= 0; i--)
		{
			inrem <<= 1;
			inrem &= 0xFFFFFFFFFFFFFFFEL;
			inrem |= ((__num >>> i) & 1L);
			
			// Unsigned comparison
			if ((inrem + Long.MIN_VALUE) >= (__den + Long.MIN_VALUE))
			{
				inrem -= __den;
				inquot |= (1L << i);
			}
		}
		
		// Make Negative
		if (isneg)
			inquot = -inquot;
		
		// Return
		return (__dorem ? inrem : inquot);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SupervisorPropertyIndex.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 indicates an index for a supervisor register which is controlled and
 * only settable by the supervisor. It is used in system call handling and
 * otherwise.
 *
 * @since 2019/10/04
 */
public interface SupervisorPropertyIndex
{
	/** The static field register of the task syscall handler. */
	byte TASK_SYSCALL_STATIC_FIELD_POINTER =
		1;
	
	/** The method pointer of the task syscall method. */
	byte TASK_SYSCALL_METHOD_HANDLER =
		2;
	
	/** The pool pointer of the task syscall method. */
	byte TASK_SYSCALL_METHOD_POOL_POINTER =
		3;
	
	/** The number of available properties. */
	byte NUM_PROPERTIES =
		4;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallError.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 interface contains the various error codes for all of the system calls.
 *
 * @since 2019/05/23
 */
public final class SystemCallError
{
	/** No error, or success. */
	public static final byte NO_ERROR =
		0;
	
	/** The system call is not supported. */
	public static final byte UNSUPPORTED_SYSTEM_CALL =
		-1;
	
	/** The pipe descriptor is not valid. */
	public static final byte PIPE_DESCRIPTOR_INVALID =
		-2;
	
	/** Write error when writing to the pipe. */
	public static final byte PIPE_DESCRIPTOR_BAD_WRITE =
		-3;
	
	/** Value out of range. */
	public static final byte VALUE_OUT_OF_RANGE =
		-4;
	
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;
	
	/** Interrupted. */
	public static final byte INTERRUPTED =
		-7;
	
	/** Unknown error. */
	public static final byte UNKNOWN =
		-8;
	
	/** End of file reached. */
	public static final byte END_OF_FILE =
		-9;
	
	/** Error with IPC Call. */
	public static final byte IPC_ERROR =
		-10;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}
	
	/**
	 * Checks if an error was set, if it was an exception is thrown.
	 *
	 * @param __si The system call to check.
	 * @throws SystemCallException If there was an error.
	 * @since 2020/01/12
	 */
	public static final void checkError(short __si)
		throws SystemCallException
	{
		int code = SystemCallError.getError(__si);
		if (code != SystemCallError.NO_ERROR)
			throw new SystemCallException(__si, code);
	}
	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
	
	/**
	 * Converts the error to a string.
	 *
	 * @param __err The input error.
	 * @return The resulting string.
	 * @since 2020/01/12
	 */
	public static final String toString(int __err)
	{
		switch (__err)
		{
			case SystemCallError.NO_ERROR:					return "NoError";
			case SystemCallError.UNSUPPORTED_SYSTEM_CALL:	return "UnsupportedSystemCall";
			case SystemCallError.PIPE_DESCRIPTOR_INVALID:	return "PDInvalid";
			case SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE:	return "PDBadWrite";
			case SystemCallError.VALUE_OUT_OF_RANGE:		return "ValueOutOfRange";
			case SystemCallError.NO_FRAMEBUFFER:			return "NoFramebuffer";
			case SystemCallError.PERMISSION_DENIED:			return "PermissionDenied";
			case SystemCallError.INTERRUPTED:				return "Interrupted";
			case SystemCallError.UNKNOWN:					return "Unknown";
			case SystemCallError.END_OF_FILE:				return "EndOfFile";
			case SystemCallError.IPC_ERROR:					return "IPCError";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallException.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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;

/**
 * Exception that may be thrown by {@link SystemCallError#checkError(short)}.
 *
 * @since 2020/01/12
 */
public class SystemCallException
	extends RuntimeException
{
	/** The system call ID. */
	public final int callid;
	
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @param __sid The call ID.
	 * @param __ec The error code.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec)
	{
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __sid The call ID.
	 * @param __ec The error code.
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m)
	{
		super(__m);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __sid The call ID.
	 * @param __ec The error code.
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m, Throwable __t)
	{
		super(__m, __t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __sid The call ID.
	 * @param __ec The error code.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, Throwable __t)
	{
		super(__t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/12
	 */
	@Override
	public String getMessage()
	{
		return "[SID=" + this.callid + ", ERR=" +
			SystemCallError.toString(this.code) + "]: " + super.getMessage();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallIndex.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 contains the index of system calls.
 *
 * @since 2019/05/23
 */
public interface SystemCallIndex
{
	/**
	 * Checks if the system call is supported.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn Zero if not supported, otherwise a non-zero
	 * value.
	 */
	byte QUERY_INDEX =
		0;
	
	/**
	 * Gets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn The last error code, will be zero if the last
	 * command succeeded.
	 */
	byte ERROR_GET =
		1;
	
	/**
	 * Sets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallparam 2 The value to set error register to.
	 * @squirreljme.syscallreturn The value which was previously in the
	 * register.
	 */
	byte ERROR_SET =
		2;
	
	/**
	 * Current wall clock milliseconds.
	 *
	 * @squirreljme.syscallreturn The current milliseconds time.
	 */
	byte TIME_MILLI_WALL =
		3;
	
	/**
	 * Returns the cross-IPC exception class which has been stored.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallreturn The exception which has been stored.
	 */
	byte EXCEPTION_LOAD =
		4;
	
	/**
	 * Current monotonic clock nanoseconds (low).
	 *
	 * @squirreljme.syscallreturn The monotonic nanoseconds time.
	 */
	byte TIME_NANO_MONO =
		5;
	
	/**
	 * Stores the cross-IPC exception class for system call errors.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallparam 1 The exception to store.
	 * @squirreljme.syscallreturn The old value that was stored in the
	 * register.
	 */
	byte EXCEPTION_STORE =
		6;
	
	/**
	 * VM Information: Free memory in bytes.
	 *
	 * @squirreljme.syscallreturn The free memory amount in bytes.
	 */
	byte VMI_MEM_FREE =
		7;
	
	/**
	 * VM Information: Used memory in bytes.
	 *
	 * @squirreljme.syscallreturn The used memory amount in bytes.
	 */
	byte VMI_MEM_USED =
		8;
	
	/**
	 * VM Information: Max memory in bytes.
	 *
	 * @squirreljme.syscallreturn The max memory amount in bytes.
	 */
	byte VMI_MEM_MAX =
		9;
	
	/**
	 * Suggests that the garbage collector should run, note that this may be
	 * a deferred operation and might not be immediate.
	 *
	 * @squirreljme.syscallreturn Generally zero although any other value could
	 * be returned.
	 */
	byte GARBAGE_COLLECT =
		10;
	
	/**
	 * Exits the VM with the given exit code.
	 *
	 * @squirreljme.syscallparam 1 The exit code to exit the process with.
	 * @squirreljme.syscallreturn This generally does not return, if it does
	 * then the error code will likely specify why this failed.
	 */
	byte EXIT =
		11;
	
	/**
	 * The API Level of the VM, this has been deprecated since the current
	 * SquirrelJME API specified in these system calls better handles various
	 * features.
	 *
	 * @squirreljme.syscallreturn The API level of the virtual machine.
	 */
	@Deprecated
	byte API_LEVEL =
		12;
	
	/**
	 * The pipe descriptor for stdin.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard input.
	 */
	byte PD_OF_STDIN =
		13;
	
	/**
	 * The pipe descriptor for stdout.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard output.
	 */
	byte PD_OF_STDOUT =
		14;
	
	/**
	 * The pipe descriptor for stderr.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard error.
	 */
	byte PD_OF_STDERR =
		15;
	
	/**
	 * Pipe descriptor: Write single byte.
	 *
	 * @squirreljme.syscallparam 1 The pipe descriptor.
	 * @squirreljme.syscallparam 2 The value of the byte to write, only the
	 * lowest 8-bits is used.
	 * @squirreljme.syscallreturn The number of bytes written to the output,
	 * if this returns a value lower than zero then it indicates an error.
	 */
	byte PD_WRITE_BYTE =
		16;
	
	/**
	 * Bulk sets the memory inside of a region, this follows the same pattern
	 * as C's {@code memset()} operation.
	 *
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set.
	 * @squirreljme.syscallreturn The number of bytes actually written, if this
	 * is zero then it is likely the system call is not supported.
	 */
	byte MEM_SET =
		17;
	
	/**
	 * Bulk sets the memory inside of a region writing full integer values at
	 * a time which is generally faster, this follows the same pattern as C's
	 * {@code memset()} operation.
	 *
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set, the lower 2-bits
	 * ({@code 0x3}) will be masked off so the length is always a multiple of
	 * four.
	 * @squirreljme.syscallreturn The number of bytes actually written,
	 * if this is zero then it is likely the system call is not supported.
	 */
	byte MEM_SET_INT =
		18;
	
	/**
	 * Get the height of the call stack.
	 *
	 * @squirreljme.syscallreturn The height of the call stack.
	 */
	byte CALL_STACK_HEIGHT =
		19;
	
	/**
	 * Gets the specified call stack item.
	 *
	 * @squirreljme.syscallparam 1 The number of frames from the top of the
	 * call stack to get the items for, zero will be the top-most item.
	 * @squirreljme.syscallparam 2 The item to obtain as specified in
	 * {@link CallStackItem}.
	 * @squirreljme.syscallreturn The value of the item, if it is undefined or
	 * not supported then zero will be returned.
	 */
	byte CALL_STACK_ITEM =
		20;
	
	/**
	 * Returns the string of the given pointer.
	 *
	 * @squirreljme.syscallparam 1 The pointer to the modified UTF encoded
	 * string.
	 * @squirreljme.syscallreturn An instance of {@link String}.
	 */
	byte LOAD_STRING =
		21;
	
	/**
	 * Fatal ToDo hit.
	 *
	 * @squirreljme.syscallparam 1 The code to use for the To Do.
	 * @squirreljme.syscallreturn This should not return unless it is not
	 * supported.
	 */
	byte FATAL_TODO =
		22;
	
	/**
	 * This is used to indicate that the supervisor booted correctly and that
	 * execution control is normal.
	 *
	 * @squirreljme.syscallreturn Generally zero as no value is intended to be
	 * returned.
	 */
	byte SUPERVISOR_BOOT_OKAY =
		23;
	
	/**
	 * Get, set, or change a property of the framebuffer, the properties which
	 * are defined are specified in {@link Framebuffer}.
	 *
	 * @squirreljme.syscallparam 1 The frame buffer property to select.
	 * @squirreljme.syscallparam ... Undefined, this depends on the property
	 * selected.
	 * @squirreljme.syscallreturn Whatever value the frame buffer property will
	 * return.
	 */
	byte FRAMEBUFFER =
		24;
	
	/**
	 * Returns the native byte order of the system the virtual machine is
	 * running on.
	 *
	 * @squirreljme.syscallreturn Non-zero if little endian, otherwise zero
	 * will be big endian.
	 */
	byte BYTE_ORDER_LITTLE =
		25;
	
	/**
	 * Returns the pointer to the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn A pointer to the data or zero if there is no
	 * option JAR defined in the requested slot.
	 */
	byte OPTION_JAR_DATA =
		26;
	
	/**
	 * Returns the size of the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn The size of the specified option JAR or zero
	 * if there is no
	 * option JAR defined in the requested slot.
	 */
	byte OPTION_JAR_SIZE =
		27;
	
	/**
	 * Loads the specified class.
	 *
	 * @squirreljme.syscallparam 1 The Modified UTF specifying the class name.
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.
	 */
	byte LOAD_CLASS_UTF =
		28;
	
	/**
	 * Loads the specified class.
	 *
	 * @squirreljme.syscallparam 1 A byte array encoded in UTF-8 which contains
	 * the class name.
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.
	 */
	byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to set.
	 * @squirreljme.syscallparam 2 The new value of the property.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.
	 */
	byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to get.
	 * @squirreljme.syscallreturn The value of that property, error should be
	 * checked to ensure that it did not fail.
	 */
	byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
	 *
	 * Only the supervisor is allowed to set tihus.
	 *
	 * @squirreljme.syscallparam 1 The task ID to set.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.
	 */
	byte FRAME_TASK_ID_SET =
		32;
	
	/**
	 * Gets the value of a thread register.
	 *
	 * @squirreljme.syscallreturn The value of the task ID.
	 */
	byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @squirreljme.syscallparam 1 The type of feedback to perform.
	 * @squirreljme.syscallparam 2 The duration of the feedback.
	 * @squirreljme.syscallreturn Non-zero on success.
	 */
	byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * @squirreljme.syscallparam 1 The number of milliseconds to sleep for.
	 * @squirreljme.syscallparam 2 The number of nanoseconds to sleep for.
	 * @squirreljme.syscallreturn Returns zero unless sleep was interrupted.
	 */
	byte SLEEP =
		35;
	
	/**
	 * If the framebuffer is shared with the console, this tells the console
	 * printer to not send messages to the screen as it will corrupt the
	 * display on the screen.
	 */
	byte SQUELCH_FB_CONSOLE =
		36;
	
	/**
	 * Perform IPC call.
	 *
	 * @squirreljme.syscallparam 1 The task to call, {@code 0} is the
	 * supervisor.
	 * @squirreljme.syscallparam 2 The IPC identifier which specifies which
	 * service this was associated with.
	 * @squirreljme.syscallparam ... Any arguments to the call.
	 * @squirreljme.syscallreturn The value returned from the remote call.
	 */
	byte IPC_CALL =
		37;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	byte NUM_SYSCALLS =
		38;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/Allocator.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.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")
public final class Allocator
{
	/** Chunk is an object. */
	public static final byte CHUNK_BIT_IS_OBJECT =
		0x01;
	
	/** Constant pool. */
	public static final byte CHUNK_BIT_IS_POOL =
		0x02;
	
	/** Tag value bits mask. */
	public static final int CHUNK_BITS_VALUE_MASK =
		0x0F;
	
	/** Shift for the chunk tag. */
	public static final byte CHUNK_TAG_SHIFT =
		24;
	
	/** Memory free tag (all bits set). */
	public static final int CHUNK_TAG_FREE =
		0xFF000000;
	
	/** Chunk tag mask. */
	public static final int CHUNK_TAG_MASK =
		0xFF000000;
	
	/** The chunk size mask. */
	public static final int CHUNK_SIZE_MASK =
		0x00FFFFFF;
	
	/** Chunk size limit, lower than the cap to allow for chunk area. */
	public static final int CHUNK_SIZE_LIMIT =
		16777200;
	
	/** Memory chunk size offset. */
	public static final byte CHUNK_SIZE_OFFSET =
		0;
	
	/** Next chunk address. */
	public static final byte CHUNK_NEXT_OFFSET =
		4;
	
	/** The length of chunks. */
	public static final byte CHUNK_LENGTH =
		8;
	
	/** Extra size to add that must be hit before a chunk is split. */
	public static final byte SPLIT_REQUIREMENT =
		16;
	
	/** The base RAM address. */
	private static volatile int _rambase;
	
	/** The locking pointer address. */
	private static volatile int _lockptr;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/26
	 */
	private Allocator()
	{
	}
	
	/**
	 * Allocates the given number of bytes.
	 *
	 * @param __tag The tag to use, only the lowest 8-bits are used.
	 * @param __sz The number of bytes to allocate.
	 * @return The address of the allocated data or {@code 0} if there is
	 * not enough memory remaining.
	 * @since 2019/10/19
	 */
	public static final int allocate(int __tag, int __sz)
	{
		// Determine the special locking key to use, never let this be zero!
		int key = Allocator.__giveLockKey();
		
		// Try locking the pointer
		int lp = Allocator._lockptr;
		try
		{
			// Lock using our special key, which will never be zero!
			// Spin-lock so this is executed as fast as possible!
			while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
				continue;
			
			// Fall into the allocation without lock
			return Allocator.allocateWithoutLock(__tag, __sz);
		}
		
		// Clear the lock always
		finally
		{
			// Clear out lock, if not matched then something is wrong!
			int old;
			if (key != (old = Assembly.atomicCompareGetAndSet(key, 0, lp)))
			{
				// Another allocation took our lock??
				Assembly.breakpoint();
				
				// {@squirreljme.error SV0j Another allocation took the lock
				// from us?}
				throw new BootstrapMachineError("SV0j");
			}
		}
	}
	
	/**
	 * Allocates the given number of bytes, no locking is performed at all.
	 *
	 * @param __tag The tag to use, only the lowest 8-bits are used.
	 * @param __sz The number of bytes to allocate.
	 * @return The address of the allocated data or {@code 0} if there is
	 * not enough memory remaining.
	 * @since 2019/05/26
	 */
	public static final int allocateWithoutLock(int __tag, int __sz)
	{
		// The number of desired bytes
		int want = Allocator.CHUNK_LENGTH + (__sz <= 4 ? 4 : ((__sz + 3) & (~3)));
		
		// Negative size or too big?
		if (__sz < 0 || want > Allocator.CHUNK_SIZE_LIMIT)
			return 0;
		
		// Go through the memory chunks to locate a free chunk
		int seeker = Allocator._rambase;
		while (seeker != 0)
		{
			// Read chunk properties
			int csz = Assembly.memReadInt(seeker, Allocator.CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, Allocator.CHUNK_NEXT_OFFSET);
			
			// Is this a free block? And can we fit in it?
			if ((csz & Allocator.CHUNK_TAG_MASK) == Allocator.CHUNK_TAG_FREE &&
				want <= (csz & Allocator.CHUNK_SIZE_MASK))
				return Allocator.__claim(__tag, want, seeker, csz, cnx);
			
			// Go to the next chunk
			seeker = cnx;
		}
		
		// Did not find a free chunk
		return 0;
	}
	
	/**
	 * Frees the specified memory pointer, making it available for later use.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/10/19
	 */
	public static final void free(int __p)
	{
		// Determine the special locking key to use, never let this be zero!
		int key = Allocator.__giveLockKey();
		
		// Try locking the pointer
		int lp = Allocator._lockptr;
		try
		{
			// Lock using our special key, which will never be zero!
			// Spin-lock so this is executed as fast as possible!
			while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
				continue;
			
			// Fall into the free without lock
			Allocator.freeWithoutLock(__p);
		}
		
		// Clear the lock always
		finally
		{
			// Clear out lock, if not matched then something is wrong!
			int old;
			if (key != (old = Assembly.atomicCompareGetAndSet(key, 0, lp)))
			{
				// Another free took our lock??
				Assembly.breakpoint();
				
				// {@squirreljme.error SV0k Another free took the lock
				// from us?}
				throw new BootstrapMachineError("SV0k");
			}
		}
	}
	
	/**
	 * Frees the specified memory pointer, making it available for later use,
	 * without using a lock.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/05/27
	 */
	public static final void freeWithoutLock(int __p)
	{
		// This should never happen
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Determine the seeker position for this chunk
		int seeker = __p - Allocator.CHUNK_LENGTH;
		
		// Read chunk properties
		int csz = Assembly.memReadInt(seeker, Allocator.CHUNK_SIZE_OFFSET),
			cnx = Assembly.memReadInt(seeker, Allocator.CHUNK_NEXT_OFFSET);
		
		// Actual logically used space
		int usedspace = (csz & Allocator.CHUNK_SIZE_MASK);
		
		// Clear out memory with invalid data, that is BAD_MAGIC
		int bm = Constants.BAD_MAGIC;
		Assembly.sysCallP(SystemCallIndex.MEM_SET_INT,
			__p, bm, usedspace - Allocator.CHUNK_LENGTH);
		if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.MEM_SET_INT) != SystemCallError.NO_ERROR)
		{
			// Fast memsetint() is not supported, so manually wipe
			// all the bytes!
			for (int i = Allocator.CHUNK_LENGTH; i < usedspace; i += 4)
				Assembly.memWriteInt(seeker, i, bm);
		}
		
		// Make sure the reference count index is zero, to detect uncount
		// after free
		int rci = Allocator.CHUNK_LENGTH + Constants.OBJECT_COUNT_OFFSET;
		if (rci + 4 <= csz)
			Assembly.memWriteInt(seeker, rci, 0);
		
		// See if we can merge this with the following chunk
		if (cnx != 0)
		{
			// Get properties of the next chunk
			int nsz = Assembly.memReadInt(cnx, Allocator.CHUNK_SIZE_OFFSET),
				nnx = Assembly.memReadInt(cnx, Allocator.CHUNK_NEXT_OFFSET);
			
			// Free space? Merge into it!
			if ((nsz & Allocator.CHUNK_TAG_MASK) == Allocator.CHUNK_TAG_FREE)
			{
				// Calculate the would be new size
				int newsize = usedspace + (nsz & Allocator.CHUNK_SIZE_MASK);
				
				// Only merge chunks which are within the size limit, otherwise
				// a large portion of memory will not able to be reclaimed
				// because it would logically have a small size
				if (newsize <= Allocator.CHUNK_SIZE_LIMIT)
				{
					// New size of our current chunk
					Assembly.memWriteInt(seeker, Allocator.CHUNK_SIZE_OFFSET,
						newsize | Allocator.CHUNK_TAG_FREE);
					
					// Our chunk's next becomes the right side's next
					Assembly.memWriteInt(seeker, Allocator.CHUNK_NEXT_OFFSET,
						nnx);
					
					// Do not use normal free set
					return;
				}
			}
		}
		
		// Set chunk as free now, keep the original size
		Assembly.memWriteInt(seeker, Allocator.CHUNK_SIZE_OFFSET,
			csz | Allocator.CHUNK_TAG_FREE);
	}
	
	/**
	 * Claims the given block and returns it.
	 *
	 * @param __tag The tag to use, only 8-bits are used.
	 * @param __want The wanted size.
	 * @param __seeker The current chunk position.
	 * @param __csz The chunk size.
	 * @param __cnx The chunk next pointer.
	 * @return The allocation pointer.
	 * @since 2019/06/21
	 */
	private static final int __claim(int __tag, int __want, int __seeker,
		int __csz, int __cnx)
	{
		// Calculate free space in this chunk
		int freespace = (__csz & Allocator.CHUNK_SIZE_MASK);
		
		// This chunk will be split into a used and free chunk
		if (__want + Allocator.SPLIT_REQUIREMENT <= freespace)
		{
			// The size of the right side chunk is cut by our wanted
			// size
			int nextsize = freespace - __want;
			
			// The position of the next chunk
			int nextpos = __seeker + __want;
			
			// Setup new chunk
			Assembly.memWriteInt(__seeker, Allocator.CHUNK_SIZE_OFFSET,
				(__want & Allocator.CHUNK_SIZE_MASK) | (__tag << Allocator.CHUNK_TAG_SHIFT));
			Assembly.memWriteInt(__seeker, Allocator.CHUNK_NEXT_OFFSET,
				nextpos);
			
			// Setup the split chunk, points to the original next
			Assembly.memWriteInt(nextpos, Allocator.CHUNK_SIZE_OFFSET,
				(nextsize & Allocator.CHUNK_SIZE_MASK) | Allocator.CHUNK_TAG_FREE);
			Assembly.memWriteInt(nextpos, Allocator.CHUNK_NEXT_OFFSET,
				__cnx);
		}
		
		// Not being split, so the block gets claimed
		else
		{
			// Keep the originally passed size, but set the tag
			Assembly.memWriteInt(__seeker, Allocator.CHUNK_SIZE_OFFSET,
				freespace | (__tag << Allocator.CHUNK_TAG_SHIFT));
		}
		
		// The returning pointer
		int rv = __seeker + Allocator.CHUNK_LENGTH;
		
		// Clear out memory since Java expects the data to be
		// initialized to zero always
		Assembly.sysCallP(SystemCallIndex.MEM_SET,
			rv, 0, __want - Allocator.CHUNK_LENGTH);
		if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.MEM_SET) != SystemCallError.NO_ERROR)
		{
			// Fast memset() is not supported, so manually wipe
			// all the bytes!
			for (int i = Allocator.CHUNK_LENGTH; i < __want; i += 4)
				Assembly.memWriteInt(__seeker, i, 0);
		}
		
		// Return the used pointer
		return rv;
	}
	
	/**
	 * Returns a locking key.
	 *
	 * @return The locking key.
	 * @since 2019/11/22
	 */
	static final int __giveLockKey()
	{
		Assembly.breakpoint();
		throw new Error("TODO");
		/*
		// Use the thread register so we know the thread that is performing
		// the allocation/free, but never allow it to be zero
		int rv = Assembly.specialGetThreadRegister();
		if (rv == 0)
			return 0x506F4C79;
		return rv;
		*/
	}
	
	/**
	 * Initializes the RAM links.
	 *
	 * @param __rambase The base of RAM.
	 * @param __ramsize The amount of RAM available.
	 * @since 2019/05/26
	 */
	static final void __initRamLinks(int __rambase, int __ramsize)
	{
		// Loops through all blocks
		for (int seeker = __rambase;;)
		{
			// Read current and next offset
			int csz = Assembly.memReadInt(seeker, Allocator.CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, Allocator.CHUNK_NEXT_OFFSET);
			
			// Reached the terminator which has been initialized to zero by
			// the BootROM, so this block and whatever is left becomes free
			// allocation space
			if (csz == 0 || cnx == 0)
			{
				// Since there is an allocation limit of 16MiB, if there is
				// more than 16MiB of memory available then there will be the
				// problem of having one gigantic chunk that is too small, or
				// keeping total memory capped at 16MiB. So to avoid this,
				// this will create as many chunks as needed to fill the
				// remainder of memory!
				
				// Create chunks as big as possible across a span
				int sizeleft = __ramsize - seeker;
				while (sizeleft > 0)
				{
					// Determine how big this chunk becomes
					int usesize = (sizeleft > Allocator.CHUNK_SIZE_LIMIT ?
						Allocator.CHUNK_SIZE_LIMIT : sizeleft);
					
					// Reduce used size
					sizeleft -= usesize;
					
					// Create free block here
					Assembly.memWriteInt(seeker, Allocator.CHUNK_SIZE_OFFSET,
						usesize | Allocator.CHUNK_TAG_FREE);
					
					// Set pointer and seeker to the next block
					if (sizeleft > Allocator.SPLIT_REQUIREMENT)
					{
						// Where is this located?
						int nextp = seeker + usesize;
						
						// Write next block position
						Assembly.memWriteInt(seeker,
							Allocator.CHUNK_NEXT_OFFSET,
							nextp);
						
						// Go here next
						seeker = nextp;
					}
					
					// Too small to really be considered a block, so just
					// drop the next one
					else
					{
						// Always ensure the next block is zero!
						Assembly.memWriteInt(seeker,
							Allocator.CHUNK_NEXT_OFFSET,
							0);
						
						// Stop
						break;
					}
				}
				
				// Stop
				break;
			}
			
			// Go to the next block in memory
			seeker = cnx;
		}
		
		// Set memory parameters
		Allocator._rambase = __rambase;
		
		// Set pointer used to control the lock state of memory
		Allocator._lockptr = Allocator.allocateWithoutLock(0, 4);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/Bootstrap.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.boot.lib.BootRom;
import cc.squirreljme.jvm.boot.task.TaskCreateResult;
import cc.squirreljme.jvm.boot.task.TaskManager;
import cc.squirreljme.jvm.boot.task.TaskSysCallHandler;
import cc.squirreljme.jvm.boot.task.ThreadManager;

/**
 * This is the bootstrap entry point for the supervisor.
 *
 * @since 2019/05/25
 */
public final class Bootstrap
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/25
	 */
	private Bootstrap()
	{
	}
	
	/**
	 * Entry point for the bootstrap.
	 *
	 * @param __rambase The base RAM address.
	 * @param __ramsize The size of RAM.
	 * @param __rombase Base address of the ROM (for offset calculation).
	 * @param __romsize The size of ROM.
	 * @param __confbase The configuration memory base.
	 * @param __confsize The configuration memory size.
	 * @since 2019/05/25
	 */
	@SuppressWarnings("unused")
	static final void __start(int __rambase, int __ramsize,
		int __rombase, int __romsize, int __confbase, int __confsize)
	{
		// Initialize the RAM links to setup dirty bits and initialize the
		// last block of memory with anything that remains. This makes it so
		// the RAM is actually useable.
		Allocator.__initRamLinks(__rambase, __ramsize);
		
		// Could crash!
		try
		{
			// Initialize kernel thread, since there has to be a thread
			// reference for classes to work!
			ThreadManager thm = Globals.getThreadManager();
			Assembly.specialSetThreadRegister(Assembly.objectToPointer(
				thm.BOOT_THREAD));
			
			// Initialize config reader
			ConfigReader config = new ConfigReader(__confbase);
			
			// Basic SquirrelJME Banner
			todo.DEBUG.note("SquirrelJME Run-Time 0.3.0");
			todo.DEBUG.note("VM: %s %s",
				config.loadString(ConfigRomType.JAVA_VM_NAME),
				config.loadString(ConfigRomType.JAVA_VM_VERSION));
			todo.DEBUG.note("(C) %s",
				config.loadString(ConfigRomType.JAVA_VM_VENDOR));
			todo.DEBUG.note("RAM/ROM (bytes): %d/%d", __ramsize, __romsize);
			
			// Spacer
			todo.DEBUG.note("");
			
			// Load system call handler
			TaskSysCallHandler.initTaskHandler(config);
			
			// Get the task manager
			TaskManager ctm = Globals.getTaskManager();
			
			// Start the initial task
			todo.DEBUG.note("Creating initial task...");
			TaskCreateResult boot = ctm.newTask(
				BootRom.initialClasspath(__rombase, config),
				BootRom.initialMain(__rombase, config),
				BootRom.initialIsMidlet(__rombase, config),
				config.loadStrings(ConfigRomType.MAIN_ARGUMENTS),
				config.loadKeyValueMap(ConfigRomType.DEFINE_PROPERTY));
			todo.DEBUG.note("Okay.");
			
			// Set the kernel as booted okay!
			todo.DEBUG.note("Appears things are going well?");
			Assembly.sysCall(SystemCallIndex.SUPERVISOR_BOOT_OKAY);
			
			// Enter the main task now, since we can do that!
			todo.DEBUG.note("Entering main method!");
			boot.thread.execute(boot.mainclass, boot.mainmethodname,
				boot.mainmethodtype, boot.callargs);
			
			// Finished? Just terminate then
			todo.DEBUG.note("Main program finished execution, terminating!");
			Assembly.sysCallP(SystemCallIndex.EXIT, 0);
		}
		
		// It crashes
		catch (Throwable t)
		{
			// Print the trace
			try
			{
				// Print stack trace for this class
				t.printStackTrace();
			}
			
			// Double fault?!?!?! SOMETHING IS VERY WRONG!
			catch (Throwable u)
			{
				// Ignore
			}
			
			// Try to exit the VM
			Assembly.sysCallP(SystemCallIndex.EXIT, 1);
			
			// If that did not work, just break and return!
			Assembly.breakpoint();
			return;
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/BootstrapMachineError.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot;

/**
 * This is thrown when the bootstrap has errors.
 *
 * @since 2020/03/01
 */
public class BootstrapMachineError
	extends VirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2020/03/01
	 */
	public BootstrapMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2020/03/01
	 */
	public BootstrapMachineError(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/ConfigReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot;

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

/**
 * This is a helper class used to read the configuration.
 *
 * @since 2019/06/22
 */
public final class ConfigReader
{
	/** The configuration base. */
	protected final int configbase;
	
	/**
	 * Initializes the configuration reader.
	 *
	 * @param __configbase The configuration base.
	 * @since 2019/06/22
	 */
	public ConfigReader(int __configbase)
	{
		this.configbase = __configbase;
	}
	
	/**
	 * Loads a key/value mapping of the given key, the resulting array will
	 * always be even and be key/value pairs.
	 *
	 * @param __key The key to locate.
	 * @return The resulting map, will be an empty array if no values were
	 * found.
	 * @since 2019/06/22
	 */
	public final String[] loadKeyValueMap(int __key)
	{
		// Configuration scanner
		int scanner = 0;
		
		// Count the number of key/values used
		int n = 0;
		while ((scanner = this.scan(__key, scanner)) != 0)
			n++;
		
		// Setup resulting array to store twice the values!
		n *= 2;
		String[] rv = new String[n];
		
		// Load in all values
		scanner = 0;
		for (int i = 0; i < n; i += 2)
		{
			// Scan for next item
			scanner = this.scan(__key, scanner);
			
			// Copy data pointer
			int dp = scanner;
			
			// Load the key
			int kl = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
			rv[i] = JVMFunction.jvmLoadString(dp);
			
			// Skip
			dp += kl + 2;
			
			// Load the value
			rv[i + 1] = JVMFunction.jvmLoadString(dp);
		}
		
		// Done!
		return rv;
	}
	
	/**
	 * Loads the given integer.
	 *
	 * @param __key The key to load.
	 * @return The resulting value or {@code 0} if not set.
	 * @since 2019/10/05
	 */
	public final int loadInteger(int __key)
	{
		int addr = this.search(__key);
		return (addr == 0 ? 0 : Assembly.memReadJavaInt(addr, 0));
	}
	
	/**
	 * Loads the given string for the given key.
	 *
	 * @param __key The key to load.
	 * @return The resulting string or {@code null} if it is not set.
	 * @since 2019/06/22
	 */
	public final String loadString(int __key)
	{
		return JVMFunction.jvmLoadString(this.search(__key));
	}
	
	/**
	 * Loads multiple string values.
	 *
	 * @param __key The key to locate.
	 * @return The resulting string values or {@code null} if there are none.
	 * @since 2019/06/22
	 */
	public final String[] loadStrings(int __key)
	{
		// Locate the key pointer
		int dp = this.search(__key);
		if (dp == 0)
			return null;
		
		// Read string count
		int n = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
		dp += 2;
		
		// Build resulting array
		String[] rv = new String[n];
		for (int i = 0; i < n; i++)
		{
			// Need to read the string length for skipping
			int strlen = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
			
			// Decode and store string
			rv[i] = JVMFunction.jvmLoadString(dp);
			
			// Skip
			dp += strlen + 2;
		}
		
		// Use this
		return rv;
	}
	
	/**
	 * Scans through the configuration space.
	 *
	 * @param __key The key to locate.
	 * @param __at The current at position of the scanner, {@code 0} will
	 * start a new search.
	 * @return The value pointer of the given item, or {@code 0} if there are
	 * no more entries.
	 * @since 2019/06/22
	 */
	public final int scan(int __key, int __at)
	{
		// Where do we start the search from? From the start?
		int seeker;
		if (__at == 0)
			seeker = this.configbase;
		
		// Otherwise, since we parked on a currently found item, we have to
		// go back and skip over it
		else
		{
			// Place the seeker at the config slot base
			seeker = __at - Constants.CONFIG_HEADER_SIZE;
			
			// If we just happened to be planted at the end, just stop
			if (Assembly.memReadJavaShort(seeker,
				Constants.CONFIG_KEY_OFFSET) == ConfigRomType.END)
				return 0;
			
			// Otherwise, skip to the next entry start
			seeker += Constants.CONFIG_HEADER_SIZE + Assembly.memReadJavaShort(
				seeker, Constants.CONFIG_SIZE_OFFSET);
		}
		
		// Constant scanning loop for the next item
		for (;;)
		{
			// Read the key
			int key = Assembly.memReadJavaShort(seeker,
				Constants.CONFIG_KEY_OFFSET);
			
			// Stop at the end
			if (key == ConfigRomType.END)
				return 0;
			
			// If the key matches then return the value
			if (key == __key)
				return seeker + Constants.CONFIG_HEADER_SIZE;
			
			// Otherwise skip to the next entry
			seeker += Constants.CONFIG_HEADER_SIZE + Assembly.memReadJavaShort(
				seeker, Constants.CONFIG_SIZE_OFFSET);
		}
	}
	
	/**
	 * Searches the configuration space for the given key and returns it's
	 * value.
	 *
	 * @param __key The key to search for.
	 * @return The pointer to the configuration value or {@code 0} if it was
	 * not found.
	 * @since 2019/06/19
	 */
	public final int search(int __key)
	{
		// Seek through items
		for (int seeker = this.configbase;;)
		{
			// Read key and size
			int key = Assembly.memReadJavaShort(seeker,
					Constants.CONFIG_KEY_OFFSET),
				len = Assembly.memReadJavaShort(seeker,
					Constants.CONFIG_SIZE_OFFSET) & 0xFFFF;
			
			// Stop?
			if (key == ConfigRomType.END)
				break;
			
			// Found here?
			if (key == __key)
				return seeker + Constants.CONFIG_HEADER_SIZE;
			
			// Skip otherwise
			seeker += Constants.CONFIG_HEADER_SIZE + len;
		}
		
		// Not found
		return 0;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/Globals.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.boot;

import cc.squirreljme.jvm.boot.task.TaskManager;
import cc.squirreljme.jvm.boot.task.ThreadManager;

/**
 * This class contains all of the globals which are used by the supervisor.
 *
 * @since 2019/10/06
 */
public final class Globals
{
	/** Manager for tasks. */
	private static TaskManager _TASK_MANAGER;
	
	/** The thread manager. */
	private static ThreadManager _THREAD_MANAGER;
	
	/**
	 * Not used.
	 *
	 * @since 2019/10/06
	 */
	private Globals()
	{
	}
	
	/**
	 * Gets the task manager.
	 *
	 * @return The task manager.
	 * @since 2019/10/06
	 */
	public static final TaskManager getTaskManager()
	{
		TaskManager rv = Globals._TASK_MANAGER;
		if (rv == null)
			Globals._TASK_MANAGER = (rv = new TaskManager());
		return rv;
	}
	
	/**
	 * Gets the thread manager.
	 *
	 * @return The thread manager.
	 * @since 2019/10/13
	 */
	public static final ThreadManager getThreadManager()
	{
		ThreadManager rv = Globals._THREAD_MANAGER;
		if (rv == null)
			Globals._THREAD_MANAGER = (rv = new ThreadManager());
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/io/BinaryBlob.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.io;

/**
 * This is a binary blob which provides memory and I/O access.
 *
 * Sub-classes only need to implement reading of a single byte, however
 * implementing the other methods will result in faster code.
 *
 * @since 2019/09/22
 */
public abstract class BinaryBlob
{
	/**
	 * Reads a single byte.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public abstract byte readByte(int __o);
	
	/**
	 * Returns the size of this blob.
	 *
	 * @return The size of this blob.
	 * @since 2019/11/17
	 */
	public abstract int size();
	
	/**
	 * Reads in multiple bytes.
	 *
	 * @param __i The read index.
	 * @param __b The bytes to read.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the index is out of bounds, or
	 * the offset and/or length are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/24
	 */
	public void readBytes(int __i, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __o < 0 || (__o + __l) > __b.length)
			throw new NullPointerException("IOOB");
		
		for (int i = 0; i < __l; i++)
			__b[__o + i] = (byte)this.readByte(__i + i);
	}
	
	/**
	 * Reads a Java integer.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public int readJavaInt(int __o)
		throws IndexOutOfBoundsException
	{
		return ((this.readByte(__o) & 0xFF) << 24) |
			((this.readByte(__o + 1) & 0xFF) << 16) |
			((this.readByte(__o + 2) & 0xFF) << 8) |
			((this.readByte(__o + 3) & 0xFF));
	}
	
	/**
	 * Reads a Java short.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/11/17
	 */
	public short readJavaShort(int __o)
		throws IndexOutOfBoundsException
	{
		return (short)(((this.readByte(__o + 1) & 0xFF) << 8) |
			((this.readByte(__o) & 0xFF)));
	}
	
	/**
	 * Reads an unsigned Java short.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/11/17
	 */
	public int readJavaUnsignedShort(int __o)
		throws IndexOutOfBoundsException
	{
		return this.readJavaShort(__o) & 0xFFFF;
	}
	
	/**
	 * Reads a single unsigned byte.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public int readUnsignedByte(int __o)
		throws IndexOutOfBoundsException
	{
		return this.readByte(__o) & 0xFF;
	}
	
	/**
	 * Reads a Modified UTF encoded string.
	 *
	 * @param __o The offset.
	 * @return The read string.
	 * @throws IndexOutOfBoundsException If the string is outside of bounds.
	 * @since 2019/09/24
	 */
	public final String readUTF(int __o)
		throws IndexOutOfBoundsException
	{
		// Read length of data first
		int len = this.readJavaUnsignedShort(__o);
		
		// Read in data to byte array
		byte[] data = new byte[len];
		this.readBytes(__o + 2, data, 0, len);
		
		// Initialize string with it
		return new String(data);
	}
	
	/**
	 * Returns a blob which is a sub-section of the given blob.
	 *
	 * It is recommended to replace this class with a more efficient one if
	 * possible, as otherwise it will use a less-efficient sub-section
	 * implementation for this blob.
	 *
	 * @param __base The base of this blob within this one.
	 * @param __len The length of the section.
	 * @return The sub-section.
	 * @throws IndexOutOfBoundsException If the base or length are negative
	 * or exceed the bounds of this blob.
	 * @since 2019/11/17
	 */
	public BinaryBlob subSection(int __base, int __len)
		throws IndexOutOfBoundsException
	{
		if (__base < 0 || __len < 0 || (__base + __len) > this.size())
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/io/MemoryBlob.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
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
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.io;

import cc.squirreljme.jvm.Assembly;

/**
 * This is a blob of data which is sourced from memory.
 *
 * @since 2019/09/22
 */
public final class MemoryBlob
	extends BinaryBlob
{
	/** The base address. */
	protected final int base;
	
	/** The size. */
	protected final int size;
	
	/**
	 * Initializes the memory blob.
	 *
	 * @param __base The base address of the blob.
	 * @param __size The size of the blob.
	 * @throws IllegalArgumentException If the size is negative.
	 * @since 2019/09/22
	 */
	public MemoryBlob(int __base, int __size)
		throws IllegalArgumentException
	{
		// {@squirreljme.error SV06 Negative memory blob size.}
		if (__size < 0)
			throw new IllegalArgumentException("SV06");
		
		this.base = __base;
		this.size = __size;
	}
	
	/**
	 * Returns the base address of this blob.
	 *
	 * @return The base address of this blob.
	 * @since 2019/12/01
	 */
	public final int baseAddress()
	{
		return this.base;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/01
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MemoryBlob))
			return false;
		
		MemoryBlob o = (MemoryBlob)__o;
		return this.base == o.base &&
			this.size == o.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/01
	 */
	@Override
	public final int hashCode()
	{
		return this.base ^ (-this.size);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public byte readByte(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || __o >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return (byte)Assembly.memReadByte(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public void readBytes(int __i, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __o < 0 || (__o + __l) > __b.length)
			throw new NullPointerException("IOOB");
			
		// {@squirreljme.error SV0u Out of range region read.}
		if (__i < 0 || (__i + __l) > this.size)
			throw new IndexOutOfBoundsException("SV0u");
		
		for (int i = 0, bp = this.base + __i; i < __l; i++)
			__b[__o + i] = (byte)Assembly.memReadByte(bp, i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int readJavaInt(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 3) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return Assembly.memReadJavaInt(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public short readJavaShort(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 1) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return (short)Assembly.memReadJavaShort(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int readJavaUnsignedShort(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 1) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return Assembly.memReadJavaShort(this.base, __o) & 0xFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int size()
	{
		return this.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public BinaryBlob subSection(int __base, int __len)
		throws IndexOutOfBoundsException
	{
		int size = this.size;
		if (__base < 0 || __len < 0 || (__base + __len) > size)
			throw new IndexOutOfBoundsException("IOOB " + __base + " "
				+ __len);
		
		return new MemoryBlob(this.base + __base, __len);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/io/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains extra utilities for input/output.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.boot.io;

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/AbstractPoolParser.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This is the base class for a pool parser.
 *
 * @since 2019/10/13
 */
public abstract class AbstractPoolParser
{
	/**
	 * Returns the number of pool entries that exist.
	 *
	 * @param __ft Does this fall through to the actually backed pool?
	 * @return The pool entry count.
	 * @since 2019/11/25
	 */
	public abstract int count(boolean __ft)
		throws InvalidClassFormatException;
	
	/**
	 * Returns a blob to the entry's data for parsing.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The blob to the entry data.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public abstract BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Returns the number of parts this entry has.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The read parts
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public abstract short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Return the type a pool entry is.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The entry type.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public abstract int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Returns the number of pool entries that exist.
	 *
	 * @return The pool entry count.
	 * @since 2019/11/25
	 */
	public final int count()
		throws InvalidClassFormatException
	{
		return this.count(false);
	}
		
	/**
	 * Returns a blob to the entry's data for parsing.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The blob to the entry data.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final BinaryBlob entryData(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryData(__dx, false);
	}
	
	/**
	 * Returns the number of parts this entry has.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The read parts
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final short[] entryParts(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryParts(__dx, false);
	}
	
	/**
	 * Return the type a pool entry is.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The entry type.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final int entryType(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryType(__dx, false);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/AliasedPoolParser.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This class is used to provide access to the aliased pool where entries are.
 *
 * @since 2019/10/13
 */
public final class AliasedPoolParser
	extends AbstractPoolParser
{
	/** The blob. */
	protected final BinaryBlob blob;
	
	/** The inherited pool data. */
	protected final AbstractPoolParser inherited;
	
	/** The count of this aliased pool. */
	private int _count =
		-1;
	
	/**
	 * Initializes the aliased pool parser.
	 *
	 * @param __b The blob for aliased data.
	 * @param __inh The inherited pool to source real data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public AliasedPoolParser(BinaryBlob __b, AbstractPoolParser __inh)
		throws NullPointerException
	{
		if (__b == null || __inh == null)
			throw new NullPointerException("NARG");
		
		this.blob = __b;
		this.inherited = __inh;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final int count(boolean __ft)
		throws InvalidClassFormatException
	{
		// If falling through use the inherited pool count
		if (__ft)
			return this.inherited.count();
		
		// Already cached the count?
		int rv = this._count;
		if (rv >= 0)
			return rv;
		
		// {@squirreljme.error SV0w Aliased pool has a count of zero.}
		rv = this.blob.readJavaInt(0);
		if (rv < 0)
			throw new InvalidClassFormatException("SV0w");
		
		// Cache and return
		this._count = rv;
		return rv;
	}
	
	/**
	 * Returns the entry this was aliased to.
	 *
	 * @param __dx The index to get.
	 * @return The index this was aliased to.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @since 2019/11/24
	 */
	public final int entryAliasedIndex(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		// The size is stored in the zero index, so this ensures that
		// zero always maps to zero!
		if (__dx == 0)
			return 0;
		
		// Read size of this pool and check the bounds
		BinaryBlob blob = this.blob;
		int count = blob.readJavaInt(0);
		if (__dx < 0 || __dx >= this.count())
			throw new IndexOutOfBoundsException("IOOB");
		
		// Read the entry index now
		return blob.readJavaInt(__dx * 4);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryData((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryParts((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryType((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/BootRom.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.boot.ConfigReader;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.JVMFunction;

/**
 * This contains boot ROM information.
 *
 * @since 2019/06/23
 */
public final class BootRom
{
	/** Boot libraries which have been loaded. */
	public static volatile BootRomLibrary[] BOOT_LIBRARIES;
	
	/** The offset to the jar count. */
	public static final byte ROM_NUMJARS_OFFSET =
		4;
	
	/** Offset to the table of contents offset. */
	public static final byte ROM_TOCOFFSET_OFFSET =
		8;
		
	/** The index of the JAR which should be the boot point. */
	public static final byte ROM_BOOTJARINDEX_OFFSET =
		12;
	
	/** The offset into the packfile where the boot entry is. */
	public static final byte ROM_BOOTJAROFFSET_OFFSET =
		16;
	
	/** The size of the boot jar. */
	public static final byte ROM_BOOTJARSIZE_OFFSET =
		20;
	
	/** Initial class path library indexes. */
	public static final byte ROM_BOOTICPOFFSET_OFFSET =
		24;
	
	/** Initial class path library index count. */
	public static final byte ROM_BOOTICPSIZE_OFFSET =
		28;
	
	/** Initial main class. */
	public static final byte ROM_BOOTMAINCLASS_OFFSET =
		32;
	
	/** Is the boot class a MIDlet? */
	public static final byte ROM_BOOTMAINMIDLET_OFFSET =
		36;
	
	/** Static constant pool offset. */
	public static final byte ROM_STATICPOOLOFF_OFFSET =
		40;
	
	/** Static constant pool size. */
	public static final byte ROM_STATICPOOLSIZE_OFFSET =
		44;
	
	/** Runtime constant pool offset. */
	public static final byte ROM_RUNTIMEPOOLOFF_OFFSET =
		48;
	
	/** Runtime constant pool size. */
	public static final byte ROM_RUNTIMEPOOLSIZE_OFFSET =
		52;
	
	/** Table of contents size. */
	public static final byte TOC_ENTRY_SIZE =
		20;
	
	/** Table of contents name offset. */
	public static final byte TOC_NAME_OFFSET =
		0;
	
	/** Table of contents JAR data offset. */
	public static final byte TOC_JAR_OFFSET =
		4;
	
	/** Table of contents size of the JAR. */
	public static final byte TOC_JARLEN_OFFSET =
		8;
	
	/** Table of contents manifest offset. */
	public static final byte TOC_MANIFEST_OFFSET =
		12;
	
	/** Table of contents length of manifest. */
	public static final byte TOC_MANIFEST_LENGTH_OFFSET =
		16;
	
	/**
	 * Returns the boot libraries which make up the initial classpath.
	 *
	 * @param __rombase The ROM base.
	 * @param __config The configuration system to use.
	 * @return The libraries to set for the initial classpath.
	 * @since 2019/06/20
	 */
	public static final ClassLibrary[] initialClasspath(int __rombase,
		ConfigReader __config)
	{
		// Load all libraries
		BootRomLibrary[] bootlibs = BootRom.bootLibraries(__rombase);
		if (bootlibs == null)
			Assembly.breakpoint();
		int numboot = bootlibs.length;
		
		// The initial class path to use
		ClassLibrary[] usecp;
		
		// Use the passed class-path if one was specified.
		String[] usercp = __config.loadStrings(ConfigRomType.CLASS_PATH);
		if (usercp != null)
		{
			// Debug
			todo.DEBUG.note("Using user class path!");
			
			// Scan for libraries
			int n = usercp.length;
			usecp = new ClassLibrary[n];
			for (int i = 0; i < n; i++)
			{
				String libname = usercp[i];
				
				// Find library
				for (int j = 0; j < numboot; j++)
				{
					BootRomLibrary bl = bootlibs[j];
					
					// Is this library?
					if (libname.equals(bl.name))
					{
						usecp[i] = bl;
						break;
					}
				}
			}
		}
		
		// Use class-path built into the ROM
		else
		{
			// Debug
			todo.DEBUG.note("Using firmware class path!");
			
			// Get offset to the table and its length
			int icpoff = __rombase + Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_BOOTICPOFFSET_OFFSET),
				icpsize = Assembly.memReadJavaInt(__rombase,
					BootRom.ROM_BOOTICPSIZE_OFFSET);
			
			// Read all of them
			usecp = new ClassLibrary[icpsize];
			for (int i = 0; i < icpsize; i++)
				usecp[i] = bootlibs[Assembly.memReadJavaInt(icpoff,
					i * 4)];
		}
		
		// Use them!
		return usecp;
	}
	
	/**
	 * Returns if the initial class is a MIDlet.
	 *
	 * @param __rombase The base of the ROM.
	 * @param __config The configuration to use.
	 * @return Is this initial program a MIDlet?
	 * @since 2019/12/14
	 */
	public static final boolean initialIsMidlet(int __rombase,
		ConfigReader __config)
	{
		// Get from configuration first
		int rv = __config.loadInteger(ConfigRomType.IS_MIDLET);
		if (rv != 0)
			return (rv > 0);
		
		return Assembly.memReadJavaInt(
			__rombase, BootRom.ROM_BOOTMAINMIDLET_OFFSET) > 0;
	}
	
	/**
	 * Returns the initial main class.
	 *
	 * @param __rombase The base of the ROM.
	 * @param __config The configuration to use.
	 * @return The initial main class.
	 * @since 2019/06/23
	 */
	public static final String initialMain(int __rombase,
		ConfigReader __config)
	{
		// Use main user class
		String usermain = __config.loadString(ConfigRomType.MAIN_CLASS);
		if (usermain != null)
			return usermain;
		
		// Otherwise read it from the boot ROM
		return JVMFunction.jvmLoadString(__rombase +
			Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_BOOTMAINCLASS_OFFSET));
	}
	
	/**
	 * Returns all of the libraries which are available to the bootstrap.
	 *
	 * @param __rombase The ROM base.
	 * @return The available bootstrap libraries.
	 * @since 2019/06/14
	 */
	public static final BootRomLibrary[] bootLibraries(int __rombase)
	{
		// Already exists?
		BootRomLibrary[] bootlibs = BootRom.BOOT_LIBRARIES;
		if (bootlibs != null)
			return bootlibs;
		
		// Number of JARs in the ROM
		int numjars = Assembly.memReadJavaInt(__rombase,
			BootRom.ROM_NUMJARS_OFFSET);
		
		// Offset to table of contents
		int tocoff = Assembly.memReadJavaInt(__rombase,
			BootRom.ROM_TOCOFFSET_OFFSET);
		
		// Debug
		todo.DEBUG.note("Scanning %d libraries...", numjars);
		
		// Seeker for the table of contents
		int seeker = __rombase + tocoff;
		
		// This is used to contain the constant pool data offset and size which
		// is then used when we initialize classes
		BootRomPoolInfo brpi = new BootRomPoolInfo(
			__rombase + Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_STATICPOOLOFF_OFFSET),
			Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_STATICPOOLSIZE_OFFSET),
			__rombase + Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_RUNTIMEPOOLOFF_OFFSET),
			Assembly.memReadJavaInt(__rombase,
				BootRom.ROM_RUNTIMEPOOLSIZE_OFFSET));
		
		// Load all the JAR informations
		bootlibs = new BootRomLibrary[numjars];
		for (int i = 0; i < numjars; i++)
		{
			// Manifest address is optional
			int ma = Assembly.memReadJavaInt(seeker,
				BootRom.TOC_MANIFEST_LENGTH_OFFSET);
			
			// Load library info
			BootRomLibrary bl = new BootRomLibrary(JVMFunction.jvmLoadString(
				__rombase + Assembly.memReadJavaInt(seeker,
					BootRom.TOC_NAME_OFFSET)),
				__rombase + Assembly.memReadJavaInt(seeker,
					BootRom.TOC_JAR_OFFSET),
				Assembly.memReadJavaInt(seeker, BootRom.TOC_JARLEN_OFFSET),
				(ma == 0 ? 0 : __rombase + ma),
				Assembly.memReadJavaInt(seeker,
					BootRom.TOC_MANIFEST_LENGTH_OFFSET),
				brpi);
			
			// Store it
			bootlibs[i] = bl;
			
			// Go to the next entry
			seeker += BootRom.TOC_ENTRY_SIZE;
		}
		
		// Store for later usage
		BootRom.BOOT_LIBRARIES = bootlibs;
		
		// Debug
		todo.DEBUG.note("Okay.");
		
		// Return the libraries
		return bootlibs;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/BootRomLibrary.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.jvm.boot.io.BinaryBlob;
import cc.squirreljme.jvm.boot.io.MemoryBlob;

/**
 * This represents a single boot library.
 *
 * @since 2019/06/14
 */
public final class BootRomLibrary
	extends ClassLibrary
{
	/** Offset of the resource count. */
	public static final byte JAR_NUMRC_OFFSET =
		4;
		
	/** Offset of the table of contents. */
	public static final byte JAR_TOC_OFFSET_OFFSET =
		8;
		
	/** Manifest offset. */
	public static final byte JAR_MANIFESTOFF_OFFSET =
		12;
	
	/** Manifest length. */
	public static final byte JAR_MANIFESTLEN_OFFSET =
		16;
	
	/** Boot initializer offset. */
	public static final byte JAR_BOOTOFFSET_OFFSET =
		20;
	
	/** Boot initializer size. */
	public static final byte JAR_BOOTSIZE_OFFSET =
		24;
	
	/** The boot pool offset. */
	public static final byte JAR_BOOTPOOL_OFFSET =
		28;
	
	/** Static field basein RAM. */
	public static final byte JAR_BOOTSFIELDBASE_OFFSET =
		32;
	
	/** The start method offset. */
	public static final byte JAR_BOOTSTART_OFFSET =
		36;
	
	/** System call static field pointer. */
	public static final byte JAR_SYSCALLSFP_OFFSET =
		40;
	
	/** System call handler code address .*/
	public static final byte JAR_SYSCALLHANDLER_OFFSET =
		44;
	
	/** System call pool address. */
	public static final byte JAR_SYSCALLPOOL_OFFSET =
		48;
	
	/** The ClassInfo for {@code byte[]}. */
	public static final byte JAR_BOOTCLASSIDBA_OFFSET =
		52;
	
	/** The ClassInfo for {@code byte[][]}. */
	public static final byte JAR_BOOTCLASSIDBAA_OFFSET =
		56;
	
	/** Static constant pool offset. */
	public static final byte JAR_STATICPOOLOFF_OFFSET =
		60;
	
	/** Static constant pool size. */
	public static final byte JAR_STATICPOOLSIZE_OFFSET =
		64;
	
	/** Runtime constant pool offset. */
	public static final byte JAR_RUNTIMEPOOLOFF_OFFSET =
		68;
	
	/** Runtime constant pool size. */
	public static final byte JAR_RUNTIMEPOOLSIZE_OFFSET =
		72;
	
	/** TOC hashcode offset. */
	public static final int TOC_HASHCODE_OFFSET =
		0;
	
	/** TOC name offset. */
	public static final int TOC_NAME_OFFSET =
		4;
	
	/** TOC Data offset. */
	public static final int TOC_DATA_OFFSET =
		8;
	
	/** TOC Size offset. */
	public static final int TOC_SIZE_OFFSET =
		12;
	
	/** Size of table of contents entries. */
	public static final int TOC_ENTRY_SIZE =
		16;
	
	/** The name of this library. */
	protected final String name;
	
	/** The absolute address of the JAR. */
	@Deprecated
	protected final int address;
	
	/** The length of the JAR. */
	@Deprecated
	protected final int length;
	
	/** Manifest address. */
	protected final int manifestaddress;
	
	/** Manifest length. */
	protected final int manifestlength;
	
	/** Boot pool information. */
	protected final BootRomPoolInfo bootrompool;
	
	/** The blob for this JAR. */
	protected final BinaryBlob blob;
	
	/**
	 * Initializes the boot library.
	 *
	 * @param __name The name of the library.
	 * @param __addr The JAR address.
	 * @param __len The JAR length.
	 * @param __maddr The manifest address.
	 * @param __mlen The manifest length.
	 * @param __brpi The boot pool information from the ROM.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/19
	 */
	public BootRomLibrary(String __name, int __addr, int __len, int __maddr,
		int __mlen, BootRomPoolInfo __brpi)
		throws NullPointerException
	{
		if (__name == null || __brpi == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.address = __addr;
		this.length = __len;
		this.manifestaddress = __maddr;
		this.manifestlength = __mlen;
		this.bootrompool = __brpi;
		
		// Initializes the blob
		this.blob = new MemoryBlob(__addr, __len);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/23
	 */
	@Override
	public final int indexOf(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Hash code for this string
		int hash = __name.hashCode();
		
		// Scan through the table of contents
		int bp = this.address,
			sp = bp + Assembly.memReadJavaInt(bp,
				BootRomLibrary.JAR_TOC_OFFSET_OFFSET);
		for (int i = 0, n = Assembly.memReadJavaInt(bp,
			BootRomLibrary.JAR_NUMRC_OFFSET); i < n;
			 i++, sp += BootRomLibrary.TOC_ENTRY_SIZE)
		{
			// Hash code does not match
			if (hash != Assembly.memReadJavaInt(sp,
				BootRomLibrary.TOC_HASHCODE_OFFSET))
				continue;
			
			// Is at this index
			if (__name.equals(JVMFunction.jvmLoadString(
				bp + Assembly.memReadJavaInt(sp,
					BootRomLibrary.TOC_NAME_OFFSET))))
				return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final String libraryName()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/11
	 */
	@Override
	public final BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException
	{
		// Get base address of the library
		int bp = this.address;
		
		// {@squirreljme.error SV07 Attempt to access resource which was not
		// in range of the boot library.}
		if (__dx < 0 || __dx >= Assembly.memReadJavaInt(bp,
			BootRomLibrary.JAR_NUMRC_OFFSET))
			throw new IndexOutOfBoundsException("SV07");
		
		// Read from the table of contents, the offset to the data.
		int tocoffset = bp + Assembly.memReadJavaInt(bp,
			BootRomLibrary.JAR_TOC_OFFSET_OFFSET);
		return new MemoryBlob(bp + Assembly.memReadJavaInt(tocoffset,
				(BootRomLibrary.TOC_ENTRY_SIZE * __dx) + BootRomLibrary.TOC_DATA_OFFSET),
			Assembly.memReadJavaInt(tocoffset,
				(BootRomLibrary.TOC_ENTRY_SIZE * __dx) + BootRomLibrary.TOC_SIZE_OFFSET));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/18
	 */
	@Override
	public AbstractPoolParser splitPool(boolean __rt)
	{
		BinaryBlob blob = this.blob;
		
		// Static
		int jpo, jps;
		if (__rt)
		{
			jpo = blob.readJavaInt(BootRomLibrary.JAR_RUNTIMEPOOLOFF_OFFSET);
			jps = blob.readJavaInt(BootRomLibrary.JAR_RUNTIMEPOOLSIZE_OFFSET);
		}
		
		// Run-time
		else
		{
			jpo = blob.readJavaInt(BootRomLibrary.JAR_STATICPOOLOFF_OFFSET);
			jps = blob.readJavaInt(BootRomLibrary.JAR_STATICPOOLSIZE_OFFSET);
		}
		
		// This JAR has a pool in it
		AbstractPoolParser rv;
		if (jpo >= 0 && jps >= 0)
			rv = new ClassPoolParser(blob.subSection(jpo, jps));
		
		// Possibly using JAR pool
		else
		{
			BootRomPoolInfo bootrompool = this.bootrompool;
			if (bootrompool.isDefined(__rt))
				rv = new ClassPoolParser(
					new MemoryBlob(bootrompool.address(__rt),
						bootrompool.size(__rt)));
			
			// Not using any pool
			else
				rv = null;
		}
		
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/BootRomPoolInfo.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This class contains the information on the boot pool addresses.
 *
 * @since 2019/11/17
 */
public final class BootRomPoolInfo
{
	/** This is the static constant pool offset. */
	protected final int staticpooladdress;
	
	/** This is the static constant pool size. */
	protected final int staticpoolsize;
	
	/** This is the run-time constant pool address. */
	protected final int runtimepooladdress;
	
	/** This is the run-time constant pool size. */
	protected final int runtimepoolsize;
	
	/**
	 * Initializes the boot ROM pool information.
	 *
	 * @param __so Static pool address.
	 * @param __ss Static pool size.
	 * @param __ro Run-time pool address.
	 * @param __rs Run-time pool size.
	 * @since 2019/11/18
	 */
	public BootRomPoolInfo(int __so, int __ss, int __ro, int __rs)
	{
		this.staticpooladdress = __so;
		this.staticpoolsize = __ss;
		this.runtimepooladdress = __ro;
		this.runtimepoolsize = __rs;
	}
	
	/**
	 * Returns the address of the pool.
	 *
	 * @param __rt The run-time pool.
	 * @return The address.
	 * @since 2019/11/18
	 */
	public final int address(boolean __rt)
	{
		return (__rt ? this.runtimepooladdress : this.staticpooladdress);
	}
	
	/**
	 * Is this pool valid?
	 *
	 * @param __rt The run-time pool.
	 * @return If it is valid.
	 * @since 2019/11/18
	 */
	public final boolean isDefined(boolean __rt)
	{
		// The address is not considered because it may be negative
		return (__rt ? this.runtimepoolsize : this.staticpoolsize) > 0;
	}
	
	/**
	 * Returns the size of the pool.
	 *
	 * @param __rt The run-time pool.
	 * @return The size.
	 * @since 2019/11/18
	 */
	public final int size(boolean __rt)
	{
		return (__rt ? this.runtimepoolsize : this.staticpoolsize);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final String toString()
	{
		return "Pools{st=(@" + Integer.toString(this.staticpooladdress, 16) +
			" len=" + this.staticpoolsize + "), rt=(@" +
			Integer.toString(this.runtimepooladdress, 16) +
			" len=" + this.runtimepoolsize + ")}";
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassDualPoolParser.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This class manages the parsing of the standard individual constant pools
 * to the combined run-time and static dual-pool setup.
 *
 * @see ClassPoolParser
 * @since 2019/10/12
 */
public final class ClassDualPoolParser
{
	/** The class level static pool. */
	protected final AbstractPoolParser classpool;
	
	/** The run-time pool. */
	protected final AbstractPoolParser runtimepool;
	
	/**
	 * Initializes the dual class pool parser.
	 *
	 * @param __cl The static class pool.
	 * @param __rt The run-time class pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/12
	 */
	public ClassDualPoolParser(AbstractPoolParser __cl,
		AbstractPoolParser __rt)
		throws NullPointerException
	{
		if (__cl == null || __rt == null)
			throw new NullPointerException("NARG");
		
		this.classpool = __cl;
		this.runtimepool = __rt;
	}
	
	/**
	 * Returns the given pool count.
	 *
	 * @param __rt Use the run-time pool?
	 * @return The given pool count.
	 * @since 2019/12/14
	 */
	public final int count(boolean __rt)
	{
		return this.count(__rt, false);
	}
	
	/**
	 * Returns the given pool count.
	 *
	 * @param __rt Use the run-time pool?
	 * @param __ft Forward?
	 * @return The given pool count.
	 * @since 2019/12/14
	 */
	public final int count(boolean __rt, boolean __ft)
	{
		return this.pool(__rt).count(__ft);
	}
	
	/**
	 * Returns the decoded entry as any object.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final Object entry(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entry(__rt, __dx, false);
	}
	
	/**
	 * Returns the decoded entry as any object.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final Object entry(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		// The zero index is always null!
		if (__dx == 0)
			return null;
		
		// Need these pools
		AbstractPoolParser sp = this.classpool,
			rp = this.runtimepool,
			ap = (__rt ? rp : sp);
		
		// Get pool entry properties
		int etype = ap.entryType(__dx, __ft);
		short[] eparts = ap.entryParts(__dx, __ft);
		int enumparts = eparts.length;
		BinaryBlob eblob = ap.entryData(__dx, __ft);
		
		// Depends on the entry type
		switch (etype)
		{
				// String, skip hash and length copies
			case ClassPoolConstants.TYPE_STRING:
				return eblob.readUTF(4);
				
				// Name of class
			case ClassPoolConstants.TYPE_CLASSNAME:
				return new PoolClassName(
					(String)this.entry(false, eparts[0] & 0xFFFF, true),
					(PoolClassName)this.entry(false, eparts[1] & 0xFFFF,
						true));
					
				// Names of multiple classes
			case ClassPoolConstants.TYPE_CLASSNAMES:
				PoolClassName[] rvpn = new PoolClassName[enumparts];
				for (int i = 0; i < enumparts; i++)
					rvpn[i] = (PoolClassName)this.entry(false,
						eparts[i] & 0xFFFF, true);
				return rvpn;
				
				// Method descriptor
			case ClassPoolConstants.TYPE_METHOD_DESCRIPTOR:
				PoolClassName[] mdargs = new PoolClassName[enumparts - 3];
				for (int i = 0, n = enumparts - 3; i < n; i++)
					mdargs[i] = (PoolClassName)this.entry(false,
						eparts[i + 3] & 0xFFFF, true);
				return new PoolMethodDescriptor(
					(String)this.entry(false, eparts[0] & 0xFFFF, true),
					(PoolClassName)this.entry(false, eparts[2] & 0xFFFF, true),
					mdargs);
				
				// Class information pointer
			case ClassPoolConstants.TYPE_CLASS_INFO_POINTER:
				return new PoolClassInfoPointer(
					((PoolClassName)this.entry(false, eparts[0] & 0xFFFF,
						true)).toString());
					
				// Class pool pointer
			case ClassPoolConstants.TYPE_CLASS_POOL_POINTER:
				return new PoolClassPoolPointer(
					((PoolClassName)this.entry(false, eparts[0] & 0xFFFF,
						true)).toString());
				
				// Noted string
			case ClassPoolConstants.TYPE_NOTED_STRING:
				return new PoolNotedString(
					this.entryData(false, eparts[0] & 0xFFFF, true));
			
				// Unknown
			default:
				throw new todo.TODO("Pool " + etype);
		}
	}
	
	/**
	 * Returns the decoded entry as a class name.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final PoolClassName entryAsClassName(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassName)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as class names.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final PoolClassName[] entryAsClassNames(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassName[])this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a method descriptor.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final PoolMethodDescriptor entryAsMethodDescriptor(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolMethodDescriptor)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a noted string.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final PoolNotedString entryAsNotedString(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolNotedString)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a class info pointer.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/15
	 */
	public final PoolClassInfoPointer entryAsClassInfoPointer(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassInfoPointer)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a class pool pointer.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/15
	 */
	public final PoolClassPoolPointer entryAsClassPoolPointer(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassPoolPointer)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a string.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final String entryAsString(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (String)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the data to the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The data to the entry.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final BinaryBlob entryData(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool(__rt).entryData(__dx, __ft);
	}
	
	/**
	 * Returns the type of the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The type of the entry
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final int entryType(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryType(__rt, __dx, false);
	}
	
	/**
	 * Returns the type of the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The type of the entry
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final int entryType(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool(__rt).entryType(__dx, __ft);
	}
	
	/**
	 * Returns the given pool.
	 *
	 * @param __rt Use the run-time pool?
	 * @return The given pool.
	 * @since 2019/12/14
	 */
	public final AbstractPoolParser pool(boolean __rt)
	{
		return (__rt ? this.runtimepool : this.classpool); 
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassFieldsParser.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This class is used to parse the fields of a class.
 *
 * @since 2019/11/17
 */
public final class ClassFieldsParser
{
	/** The size of entries in the field list. */
	public static final byte ENTRY_SIZE =
		16;
	
	/** Offset to field flags. */
	public static final byte FLAGS_INT_OFFSET =
		0;
		
	/** Offset to offset within class base. */
	public static final byte OFFSET_USHORT_OFFSET =
		4;
	
	/** Offset to field size. */
	public static final byte SIZE_USHORT_OFFSET =
		6;
		
	/** Offset to field name. */
	public static final byte NAME_USHORT_OFFSET =
		8;
	
	/** Offset to field type. */
	public static final byte TYPE_USHORT_OFFSET =
		10;
		
	/** Offset to constant value. */
	public static final byte CVALUE_USHORT_OFFSET =
		12;
		
	/** Offset to the data type. */
	public static final byte DATATYPE_BYTE_OFFSET =
		14;
	
	/** The constant pool for the class. */
	protected final ClassDualPoolParser pool;
	
	/** The blob for the field data. */
	protected final BinaryBlob blob;
	
	/** The number of fields available. */
	protected final int count;
	
	/**
	 * Initializes the class fields parser.
	 *
	 * @param __cp The dual pool parser.
	 * @param __b The binary blob.
	 * @param __n The field count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public ClassFieldsParser(ClassDualPoolParser __cp, BinaryBlob __b, int __n)
		throws NullPointerException
	{
		if (__cp == null || __b == null)
			throw new NullPointerException("NARG");
		
		this.pool = __cp;
		this.blob = __b;
		this.count = __n;
	}
	
	/**
	 * Returns the number of fields.
	 *
	 * @return The number of fields.
	 * @since 2019/11/17
	 */
	public final int count()
	{
		return this.count;
	}
	
	/**
	 * Returns the flags for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The field flags.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int flags(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaInt(this.tocOffset(__dx) + ClassFieldsParser.FLAGS_INT_OFFSET);
	}
	
	/**
	 * Returns the name of the field.
	 *
	 * @param __dx The index of the field.
	 * @return The name of the field.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final String name(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsString(false, this.blob.readJavaUnsignedShort(
			this.tocOffset(__dx) + ClassFieldsParser.NAME_USHORT_OFFSET));
	}
	
	/**
	 * Returns the offset for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The field offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int offset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaUnsignedShort(this.tocOffset(__dx) + ClassFieldsParser.OFFSET_USHORT_OFFSET);
	}
	
	/**
	 * Returns the size for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The size offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int size(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaUnsignedShort(this.tocOffset(__dx) + ClassFieldsParser.SIZE_USHORT_OFFSET);
	}
	
	/**
	 * Index of the entry in the table of contents.
	 *
	 * @param __dx The index.
	 * @return The table of contents offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int tocOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx > this.count)
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ClassFieldsParser.ENTRY_SIZE;
	}
	
	/**
	 * Returns the type of the field.
	 *
	 * @param __dx The index of the field.
	 * @return The type of the field.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/25
	 */
	public final PoolClassName type(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsClassName(false,
			this.blob.readJavaUnsignedShort(this.tocOffset(__dx) + ClassFieldsParser.TYPE_USHORT_OFFSET));
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassFileConstants.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This interface defines all of the class file constants which is used to
 * remove the usages of magic numbers.
 *
 * @since 2019/10/12
 */
public interface ClassFileConstants
{
	/** The magic number for the header. */
	int MAGIC_NUMBER =
		0x00586572;
	
	/** Magic number for the end of file. */
	int END_MAGIC_NUMBER =
		0x42796521;
	
	/** The size of the header without the magic number. */
	byte HEADER_SIZE_WITHOUT_MAGIC =
		108;
	
	/** The size of the header with the magic number. */
	byte HEADER_SIZE_WITH_MAGIC =
		112;
		
	/** Unused A. */
	byte OFFSET_OF_USHORT_UNUSEDA =
		4;
	
	/** The index of the method which is __start. */
	byte OFFSET_OF_UBYTE_STARTMETHODINDEX =
		6;
	
	/** The data type of the class. */
	byte OFFSET_OF_UBYTE_DATATYPE =
		7;
	
	/** Not used. */
	byte OFFSET_OF_USHORT_UNUSEDB =
		8;
	
	/** Class flags. */
	byte OFFSET_OF_INT_CLASSFLAGS =
		10;
	
	/** Name of class. */
	byte OFFSET_OF_USHORT_CLASSNAME =
		14;
	
	/** Super class name. */
	byte OFFSET_OF_USHORT_CLASSSUPER =
		16;
	
	/** Interfaces in class. */
	byte OFFSET_OF_USHORT_CLASSINTS =
		18;
	
	/** Class type. */
	byte OFFSET_OF_UBYTE_CLASSTYPE =
		20;
	
	/** Class version. */
	byte OFFSET_OF_UBYTE_CLASSVERS =
		21;
	
	/** Class source filename. */
	byte OFFSET_OF_USHORT_CLASSSFN =
		22;
	
	/** Static field count. */
	byte OFFSET_OF_USHORT_SFCOUNT =
		24;
	
	/** Static field bytes. */
	byte OFFSET_OF_USHORT_SFBYTES =
		26;
	
	/** Static field objects. */
	byte OFFSET_OF_USHORT_SFOBJS =
		28;
	
	/** Instance field count. */
	byte OFFSET_OF_USHORT_IFCOUNT =
		30;
	
	/** Instance field bytes. */
	byte OFFSET_OF_USHORT_IFBYTES =
		32;
	
	/** Instance field objects. */
	byte OFFSET_OF_USHORT_IFOBJS =
		34;
	
	/** Static method count. */
	byte OFFSET_OF_USHORT_SMCOUNT =
		36;
	
	/** Instance method count. */
	byte OFFSET_OF_USHORT_IMCOUNT =
		38;
	
	/** Not used. */
	byte OFFSET_OF_INT_UNUSEDC =
		40;
	
	/** Not used. */
	byte OFFSET_OF_INT_UNUSEDD =
		44;
	
	/** Static field data offset. */
	byte OFFSET_OF_INT_SFOFF =
		48;
	
	/** Static field data size. */
	byte OFFSET_OF_INT_SFSIZE =
		52;
	
	/** Interface field data offset. */
	byte OFFSET_OF_INT_IFOFF =
		56;
	
	/** Interface field data size. */
	byte OFFSET_OF_INT_IFSIZE =
		60;
	
	/** Static method data offset. */
	byte OFFSET_OF_INT_SMOFF =
		64;
	
	/** Static method data size. */
	byte OFFSET_OF_INT_SMSIZE =
		68;
	
	/** Instance method data offset. */
	byte OFFSET_OF_INT_IMOFF =
		72;
	
	/** Instance method data size. */
	byte OFFSET_OF_INT_IMSIZE =
		76;
	
	/** High bits for UUID. */
	byte OFFSET_OF_INT_UUIDHI =
		80;
	
	/** Low bits for UUID. */
	byte OFFSET_OF_INT_UUIDLO =
		84;
	
	/** File size. */
	byte OFFSET_OF_INT_FILESIZE =
		88;
	
	/** Not used. */
	byte OFFSET_OF_INT_UNUSEDE =
		92;
	
	/** Static constant pool offset. */
	byte OFFSET_OF_INT_STATICPOOLOFF =
		96;
	
	/** Static constant pool size. */
	byte OFFSET_OF_INT_STATICPOOLSIZE =
		100;
	
	/** Runtime constant pool offset. */
	byte OFFSET_OF_INT_RUNTIMEPOOLOFF =
		104;
	
	/** Runtime constant pool size. */
	byte OFFSET_OF_INT_RUNTIMEPOOLSIZE =
		108;
	
	/** Public class. */
	short FLAG_PUBLIC =
		0x0001;
	
	/** Final class. */
	short FLAG_FINAL =
		0x0010;
	
	/** Super class. */
	short FLAG_SUPER =
		0x0020;
	
	/** Interface class. */
	short FLAG_INTERFACE =
		0x0200;
	
	/** Abstract. */
	short FLAG_ABSTRACT =
		0x0400;
	
	/** Synthetic. */
	short FLAG_SYNTHETIC =
		0x1000;
	
	/** Annotation. */
	short FLAG_ANNOTATION =
		0x2000;
	
	/** Enum. */
	short FLAG_ENUM =
		0x4000;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassFileParser.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;
import cc.squirreljme.jvm.boot.io.MemoryBlob;

/**
 * This utility exists for the parsing of SquirrelJME's class files and allows
 * the bootstrap and class loaders the ability to read them.
 *
 * @since 2019/10/06
 */
public final class ClassFileParser
{
	/** The blob of the class. */
	public final BinaryBlob blob;
	
	/** Root static split pool, when aliased. */
	protected final AbstractPoolParser rootstaticpool;
	
	/** Root runtime split pool, when aliased. */
	protected final AbstractPoolParser rootruntimepool;
	
	/**
	 * Initializes the class file parser.
	 *
	 * @param __blob The ROM blob.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public ClassFileParser(BinaryBlob __blob)
		throws NullPointerException
	{
		this(__blob, null, null);
	}
	
	/**
	 * Initializes the class file parser.
	 *
	 * @param __blob The ROM blob.
	 * @param __sp Static pool, may be {@code null}.
	 * @param __rp Run-time pool, may be {@code null}.
	 * @throws NullPointerException On null arguments, except for the pools.
	 * @since 2019/10/06
	 */
	public ClassFileParser(BinaryBlob __blob, AbstractPoolParser __sp,
		AbstractPoolParser __rp)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
		this.rootstaticpool = __sp;
		this.rootruntimepool = __rp;
	}
	
	/**
	 * Returns the base address of the class if it is known.
	 *
	 * @return The base address or {@code 0} if it is not known.
	 * @since 2019/12/01
	 */
	public final int baseAddress()
	{
		BinaryBlob blob = this.blob;
		if (blob instanceof MemoryBlob)
			return ((MemoryBlob)blob).baseAddress();
		return 0;
	}
	
	/**
	 * Returns the number of fields in the class.
	 *
	 * @param __is Get the static field count.
	 * @return The number of fields in the class.
	 * @since 2019/10/26
	 */
	public final int fieldCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFCOUNT :
			ClassFileConstants.OFFSET_OF_USHORT_IFCOUNT));
	}
	
	/**
	 * Returns the field data offset.
	 *
	 * @param __is Get the static field data offset.
	 * @return The field data offset.
	 * @since 2019/11/17
	 */
	public final int fieldDataOffset(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SFOFF :
			ClassFileConstants.OFFSET_OF_INT_IFOFF));
	}
	
	/**
	 * Returns the field data size.
	 *
	 * @param __is Get the static field data size.
	 * @return The field data size.
	 * @since 2019/11/17
	 */
	public final int fieldDataSize(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SFSIZE :
			ClassFileConstants.OFFSET_OF_INT_IFSIZE));
	}
	
	/**
	 * Returns a parser for class fields.
	 *
	 * @param __is Get static fields?
	 * @return The parser for fields.
	 * @since 2019/11/17
	 */
	public final ClassFieldsParser fields(boolean __is)
	{
		BinaryBlob blob = this.blob;
		return new ClassFieldsParser(this.pool(),
			this.blob.subSection(this.fieldDataOffset(__is),
				this.fieldDataSize(__is)), this.fieldCount(__is));
	}
	
	/**
	 * Returns the size of all of the fields in bytes.
	 *
	 * @param __is Get the size of static fields?
	 * @return The number of bytes the field requires for consumption.
	 * @since 2019/10/21
	 */
	public final int fieldSize(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFBYTES :
			ClassFileConstants.OFFSET_OF_USHORT_IFBYTES));
	}
	
	/**
	 * Returns the raw class flags.
	 *
	 * @return The class flags.
	 * @since 2019/12/01
	 */
	public final int flags()
	{
		return this.blob.readJavaInt(
			ClassFileConstants.OFFSET_OF_INT_CLASSFLAGS);
	}
	
	/**
	 * Returns the names of the interfaces that this class implements.
	 *
	 * @return The names of the implemented interfaces.
	 * @since 2019/12/01
	 */
	public final PoolClassName[] interfaceNames()
	{
		PoolClassName[] rv = this.pool().entryAsClassNames(false, this.blob.
			readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSINTS));
		return (rv == null ? new PoolClassName[0] : rv);
	}
	
	/**
	 * Gets the code bytes which represent the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @return The blob for the method, or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final BinaryBlob methodCodeBytes(String __mn, String __mt)
		throws NullPointerException
	{
		if (__mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// Search static methods first
		for (boolean dostatic = true;; dostatic = false)
		{
			// Get methods parser
			ClassMethodsParser methods = this.methods(dostatic);
			
			// See if method is a match
			for (int i = 0, n = methods.count; i < n; i++)
				if (__mn.equals(methods.name(i)) &&
					__mt.equals(methods.type(i).toString()))
					return methods.code(i);
			
			// End?
			if (!dostatic)
				break;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Returns the number of methods in the class.
	 *
	 * @param __is Get the static method count.
	 * @return The number of methods in the class.
	 * @since 2019/11/29
	 */
	public final int methodCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SMCOUNT :
			ClassFileConstants.OFFSET_OF_USHORT_IMCOUNT));
	}
	
	/**
	 * Returns the method data offset.
	 *
	 * @param __is Get the static method data offset.
	 * @return The method data offset.
	 * @since 2019/11/29
	 */
	public final int methodDataOffset(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SMOFF :
			ClassFileConstants.OFFSET_OF_INT_IMOFF));
	}
	
	/**
	 * Returns the method data size.
	 *
	 * @param __is Get the static method data size.
	 * @return The method data size.
	 * @since 2019/11/29
	 */
	public final int methodDataSize(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SMSIZE :
			ClassFileConstants.OFFSET_OF_INT_IMSIZE));
	}
	
	/**
	 * Returns a parser for class methods.
	 *
	 * @param __is Get static methods?
	 * @return The parser for methods.
	 * @since 2019/11/29
	 */
	public final ClassMethodsParser methods(boolean __is)
	{
		BinaryBlob blob = this.blob;
		return new ClassMethodsParser(this.pool(),
			this.blob.subSection(this.methodDataOffset(__is),
				this.methodDataSize(__is)), this.methodCount(__is));
	}
	
	/**
	 * Returns the number of objects in the class.
	 *
	 * @param __is Get the static object count.
	 * @return The number of objects in the class.
	 * @since 2019/11/29
	 */
	public final int objectCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFOBJS :
			ClassFileConstants.OFFSET_OF_USHORT_IFOBJS));
	}
	
	/**
	 * Returns a dual pool parser for this class.
	 *
	 * @return The dual pool parser.
	 * @since 2019/10/13
	 */
	public final ClassDualPoolParser pool()
	{
		return new ClassDualPoolParser(this.splitPool(false),
			this.splitPool(true));
	}
	
	/**
	 * Returns the appropriate pool parser.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @throws InvalidClassFormatException If the pool is virtual and no
	 * root pool was specified.
	 * @since 2019/11/17
	 */
	public final AbstractPoolParser splitPool(boolean __rt)
		throws InvalidClassFormatException
	{
		int off = this.splitPoolOffset(__rt),
			len = this.splitPoolSize(__rt);
		
		// Blob needed to read any pool type from
		BinaryBlob blob = this.blob;
		
		// Is a virtually aliased pool and relies on a higher up ROM pool
		// for this to be decoded. Use the static pool because the run-time
		// pool can be empty if the class has no methods
		if (this.splitPoolSize(false) < 0)
		{
			// {@squirreljme.error SV0t No root pool was specified and the
			// class pool is purely virtual.}
			AbstractPoolParser rootp = (__rt ? this.rootruntimepool :
				this.rootstaticpool);
			if (rootp == null)
				throw new InvalidClassFormatException("SV0t");
			
			// Initialize aliased pool
			return new AliasedPoolParser(blob.subSection(off, -len), rootp);
		}
		
		// Otherwise read the data straight from the class
		return new ClassPoolParser(blob.subSection(off, len));
	}
	
	/**
	 * Returns the offset of the split pool.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @return The offset of the pool.
	 * @since 2019/11/17
	 */
	public final int splitPoolOffset(boolean __rt)
	{
		return this.blob.readJavaInt(
			(__rt ? ClassFileConstants.OFFSET_OF_INT_RUNTIMEPOOLOFF :
			ClassFileConstants.OFFSET_OF_INT_STATICPOOLOFF));
	}
	
	/**
	 * Returns the size of the split pool.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @return The size of the pool.
	 * @since 2019/11/17
	 */
	public final int splitPoolSize(boolean __rt)
	{
		return this.blob.readJavaInt(
			(__rt ? ClassFileConstants.OFFSET_OF_INT_RUNTIMEPOOLSIZE :
			ClassFileConstants.OFFSET_OF_INT_STATICPOOLSIZE));
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super-class of this class.
	 * @since 2019/11/25
	 */
	public final PoolClassName superClassName()
	{
		return this.pool().entryAsClassName(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSSUPER));
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/11/25
	 */
	public final PoolClassName thisName()
	{
		return this.pool().entryAsClassName(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSNAME));
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/11/25
	 */
	public final BinaryBlob thisNameAsBinaryBlob()
	{
		return this.pool().entryData(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSNAME), false);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassInfoProperty.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This contains properties of class info.
 *
 * @since 2019/11/30
 */
public interface ClassInfoProperty
{
	/** Self pointer. */
	byte INT_SELFPTR =
		0;
	
	/** Magic number used to detect corruption. */
	byte INT_MAGIC =
		1;
	
	/** Class information flags. */
	byte INT_FLAGS =
		2;
	
	/** The pointer to the minimized class file. */
	byte INT_MINIPTR =
		3;
	
	/** The pointer to the class name. */
	byte INT_NAMEP =
		4;
	
	/** The allocation size of this class. */
	byte INT_SIZE =
		5;
	
	/** The base offset for fields in this class. */
	byte INT_BASE =
		6;
	
	/** The number of objects in the instance fields, for GC. */
	byte INT_NUMOBJECTS =
		7;
	
	/** The dimensions this class uses, if it is an array. */
	byte INT_DIMENSIONS =
		8;
	
	/** The cell size of components if this is an array. */
	byte INT_CELLSIZE =
		9;
	
	/** The super class data. */
	byte CLASSINFO_SUPERCLASS =
		10;
	
	/** Interfaces. */
	byte CLASSINFO_ARRAY_INTERFACECLASSES =
		11;
	
	/** The component class. */
	byte CLASSINFO_COMPONENTCLASS =
		12;
	
	/** Pointer to the class object. */
	byte CLASS_CLASSOBJPTR =
		13;
	
	/** Virtual invoke VTable. */
	byte INT_ARRAY_VTABLEVIRTUAL =
		14;
	
	/** Virtual invoke VTable pool entries. */
	byte INT_ARRAY_VTABLEPOOL =
		15;
	
	/** The pointer to the constant pool of this class. */
	byte INT_POOL =
		16;
	
	/** The JAR Index. */
	byte INT_JARDX =
		17;
	
	/** The number of methods the class has. */
	byte INT_NUMMETHODS =
		18;
	
	/** The depth of this class. */
	byte INT_CLASSDEPTH =
		19;
	
	/** Static field offset. */
	byte INT_SFOFFSET =
		20;
	
	/** New instance method. */
	byte INT_DEFAULTNEW =
		21;
	
	/** The number of properties available. */
	byte NUM_PROPERTIES =
		22;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassInfoUtility.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.boot.task.TaskClass;

/**
 * This is a utility which allows access to the various fields within
 * {@link cc.squirreljme.jvm.ClassInfo}.
 *
 * @since 2019/11/30
 */
public final class ClassInfoUtility
{
	/** The allocation size. */
	protected final int allocationsize;
	
	/** Class info properties. */
	protected final int[] properties;
	
	/**
	 * Initializes the class info utility.
	 *
	 * @param __as The allocation size.
	 * @param __props Class info properties.
	 * @since 2019/11/30
	 */
	public ClassInfoUtility(int __as, int[] __props)
	{
		this.allocationsize = __as;
		
		int[] properties = new int[ClassInfoProperty.NUM_PROPERTIES];
		for (int i = 0, lim = Math.min(__props.length,
			ClassInfoProperty.NUM_PROPERTIES); i < lim; i++)
			properties[i] = __props[i];
		this.properties = properties;
	}
	
	/**
	 * Returns the class allocation size.
	 *
	 * @param __cl The class.
	 * @return The class allocation size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int classAllocationSize(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_SIZE);
	}
	
	/**
	 * Returns the class depth.
	 *
	 * @param __cl The class.
	 * @return The class depth.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int classDepth(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_CLASSDEPTH);
	}
	
	/**
	 * Returns the allocation size of instances of this class.
	 *
	 * @return The allocation size of this.
	 * @since 2019/11/30
	 */
	public final int classInfoAllocationSize()
	{
		return this.allocationsize;
	}
	
	/**
	 * Returns the default constructor pointer.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final int defaultNew(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_DEFAULTNEW);
	}
	
	/**
	 * Returns the ClassInfo flags.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int flags(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_FLAGS);
	}
	
	/**
	 * Returns the JAR Index.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int jarIndex(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_JARDX);
	}
	
	/**
	 * Returns the method count of the class.
	 *
	 * @param __cl The class.
	 * @return The class method count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int methodCount(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_NUMMETHODS);
	}
	
	/**
	 * Returns the object count of the class.
	 *
	 * @param __cl The class.
	 * @return The class object count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int objectCount(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_NUMOBJECTS);
	}
	
	/**
	 * Returns the pool pointer.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int poolPointer(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_POOL);
	}
	
	/**
	 * Returns the specified property.
	 *
	 * @param __cl The class.
	 * @param __prop The property to return.
	 * @return The property value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int property(TaskClass __cl, int __prop)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return Assembly.memReadInt(__cl.infoPointer(),
			this.properties[__prop]);
	}
	
	/**
	 * Sets the base of the class.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setBaseSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_BASE,
			__v);
	}
	
	/**
	 * Sets the cell size.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setCellSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_CELLSIZE,
			__v);
	}
	
	/**
	 * Sets the allocation size.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setClassAllocationSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_SIZE,
			__v);
	}
	
	/**
	 * Sets the class depth, the number of super classes ahead of this.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setClassDepth(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_CLASSDEPTH,
			__v);
	}
	
	/**
	 * Sets the component type class.
	 *
	 * @param __cl The class.
	 * @param __co The component type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setComponentType(TaskClass __cl, TaskClass __co)
		throws NullPointerException
	{
		if (__co == null)
			throw new NullPointerException("NARG");
		
		this.setProperty(__cl, ClassInfoProperty.CLASSINFO_COMPONENTCLASS,
			__co.infoPointer());
	}
	
	/**
	 * Sets the default constructor to use.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final void setDefaultNew(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_DEFAULTNEW,
			__v);
	}
	
	/**
	 * Sets the number of dimensions the class has.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setDimensions(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_DIMENSIONS,
			__v);
	}
	
	/**
	 * Sets the flags.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setFlags(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_FLAGS,
			__v);
	}
	
	/**
	 * Sets the interfaces array of the class.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setInterfaces(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl,
			ClassInfoProperty.CLASSINFO_ARRAY_INTERFACECLASSES, __v);
	}
	
	/**
	 * Sets the JAR index.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setJarIndex(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_JARDX,
			__v);
	}
	
	/**
	 * Sets the class magic number.
	 *
	 * @param __cl The class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMagicNumber(TaskClass __cl)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_MAGIC,
			ClassFileConstants.MAGIC_NUMBER);
	}
	
	/**
	 * Sets the method count.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMethodCount(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NUMMETHODS,
			__v);
	}
	
	/**
	 * Sets the mini class pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMiniClassPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_MINIPTR,
			__v);
	}
	
	/**
	 * Sets the name pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setNamePointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NAMEP,
			__v);
	}
	
	/**
	 * Sets the object count.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setObjectCount(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NUMOBJECTS,
			__v);
	}
	
	/**
	 * Sets the pool pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setPoolPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_POOL,
			__v);
	}
	
	/**
	 * Sets the value of the given property.
	 *
	 * @param __cl The class to set.
	 * @param __prop The property to set.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setProperty(TaskClass __cl, int __prop, int __v)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Write value
		Assembly.memWriteInt(__cl.infoPointer(),
			this.properties[__prop], __v);
	}
	
	/**
	 * Sets the self pointer value.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setSelfPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_SELFPTR,
			__v);
	}
	
	/**
	 * Sets the super class.
	 *
	 * @param __cl The class.
	 * @param __su The super class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setSuperClass(TaskClass __cl, TaskClass __su)
		throws NullPointerException
	{
		if (__su == null)
			throw new NullPointerException("NARG");
		
		this.setProperty(__cl, ClassInfoProperty.CLASSINFO_SUPERCLASS,
			__su.infoPointer());
	}
	
	/**
	 * Sets the VTable pool array.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setVTablePool(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_ARRAY_VTABLEPOOL,
			__v);
	}
	
	/**
	 * Sets the VTable method array.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setVTableVirtual(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL,
			__v);
	}
	
	/**
	 * Returns the VTable for pools.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int vTablePool(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_ARRAY_VTABLEPOOL);
	}
	
	/**
	 * Returns the VTable for method pointers.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int vTableVirtual(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL);
	}
	
	/**
	 * Initializes the {@code ClassInfo} utility.
	 *
	 * @param __cfp The class info parser to use.
	 * @return The utility for {@code ClassInfo}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	public static final ClassInfoUtility of(ClassFileParser __cfp)
		throws NullPointerException
	{
		if (__cfp == null)
			throw new NullPointerException("NARG");
		
		// Allocation size
		int as = Constants.OBJECT_BASE_SIZE + __cfp.fieldSize(false);
		
		// Properties
		int[] props = new int[ClassInfoProperty.NUM_PROPERTIES];
		
		// Extract properties from fields
		ClassFieldsParser cifs = __cfp.fields(false);
		for (int cif = 0, cifn = cifs.count(); cif < cifn; cif++)
		{
			// Determine actual offset of this property
			int offset = Constants.OBJECT_BASE_SIZE + cifs.offset(cif);
			
			// The property index
			int pdx;
			
			// Depends on the field name and type
			String nat = cifs.name(cif) + ":" + cifs.type(cif);
			switch (nat)
			{
					// Self pointer.
				case "selfptr:int":
					pdx = ClassInfoProperty.INT_SELFPTR;
					break;

					// Magic number used to detect corruption.
				case "magic:int":
					pdx = ClassInfoProperty.INT_MAGIC;
					break;

					// Class information flags.
				case "flags:int":
					pdx = ClassInfoProperty.INT_FLAGS;
					break;

					// The pointer to the minimized class file.
				case "miniptr:int":
					pdx = ClassInfoProperty.INT_MINIPTR;
					break;

					// The pointer to the class name.
				case "namep:int":
					pdx = ClassInfoProperty.INT_NAMEP;
					break;

					// The allocation size of this class.
				case "size:int":
					pdx = ClassInfoProperty.INT_SIZE;
					break;

					// The base offset for fields in this class.
				case "base:int":
					pdx = ClassInfoProperty.INT_BASE;
					break;

					// The number of objects in the instance fields, for GC.
				case "numobjects:int":
					pdx = ClassInfoProperty.INT_NUMOBJECTS;
					break;

					// The dimensions this class uses, if it is an array.
				case "dimensions:int":
					pdx = ClassInfoProperty.INT_DIMENSIONS;
					break;

					// The cell size of components if this is an array.
				case "cellsize:int":
					pdx = ClassInfoProperty.INT_CELLSIZE;
					break;

					// The super class data.
				case "superclass:cc/squirreljme/jvm/ClassInfo":
					pdx = ClassInfoProperty.CLASSINFO_SUPERCLASS;
					break;

					// Interfaces.
				case "interfaceclasses:[Lcc/squirreljme/jvm/ClassInfo;":
					pdx = ClassInfoProperty.CLASSINFO_ARRAY_INTERFACECLASSES;
					break;

					// The component class.
				case "componentclass:cc/squirreljme/jvm/ClassInfo":
					pdx = ClassInfoProperty.CLASSINFO_COMPONENTCLASS;
					break;

					// Pointer to the class object.
				case "classobjptr:java/lang/Class":
					pdx = ClassInfoProperty.CLASS_CLASSOBJPTR;
					break;

					// Virtual invoke VTable.
				case "vtablevirtual:[I":
					pdx = ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL;
					break;

					// Virtual invoke VTable pool entries.
				case "vtablepool:[I":
					pdx = ClassInfoProperty.INT_ARRAY_VTABLEPOOL;
					break;

					// The pointer to the constant pool of this class.
				case "pool:int":
					pdx = ClassInfoProperty.INT_POOL;
					break;
					
					// The JAR Index
				case "jardx:int":
					pdx = ClassInfoProperty.INT_JARDX;
					break;
					
					// The number of methods in the class
				case "nummethods:int":
					pdx = ClassInfoProperty.INT_NUMMETHODS;
					break;
					
					// The class depth
				case "classdepth:int":
					pdx = ClassInfoProperty.INT_CLASSDEPTH;
					break;
					
					// The static field offset
				case "sfoffset:int":
					pdx = ClassInfoProperty.INT_SFOFFSET;
					break;
					
					// Default new constructor
				case "defaultnew:int":
					pdx = ClassInfoProperty.INT_DEFAULTNEW;
					break;
				
				default:
					throw new todo.TODO(nat);
			}
			
			// Store
			props[pdx] = offset;
		}
		
		// Initialize now
		return new ClassInfoUtility(as, props);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassLibrary.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This class represents a class library which makes classes available for
 * usage and such. It allows one to obtain class library information and
 * pointers.
 *
 * @since 2019/09/22
 */
public abstract class ClassLibrary
{
	/**
	 * Locates the given resource.
	 *
	 * @param __name The name of the resource to get.
	 * @return The index of the resource or {@code -1} if it was not found.
	 * @since 2019/09/22
	 */
	public abstract int indexOf(String __name)
		throws NullPointerException;
	
	/**
	 * Returns the name of the library.
	 *
	 * @return The library name.
	 * @since 2019/09/22
	 */
	public abstract String libraryName();
	
	/**
	 * Returns the data pointer of the given index.
	 *
	 * @param __dx The index to get the data for.
	 * @return The binary blob data.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2019/07/11
	 */
	public abstract BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException;
	
	/**
	 * Returns the split pool for this library, if one is available.
	 *
	 * @param __rt Access the run-time pool?
	 * @return The split pool or {@code null} if there is none.
	 * @since 2019/11/17
	 */
	public AbstractPoolParser splitPool(boolean __rt)
	{
		return null;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassMethodsParser.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This is a parser for methods within a class.
 *
 * @since 2019/11/29
 */
public final class ClassMethodsParser
{
	/** The size of entries in the field list. */
	public static final byte ENTRY_SIZE =
		20;
	
	/** Flags offset. */
	public static final byte FLAGS_INT_OFFSET =
		0;
	
	/** Index of method. */
	public static final byte INDEX_USHORT_OFFSET =
		4;
	
	/** Name of method. */
	public static final byte NAME_USHORT_OFFSET =
		6;
	
	/** Type of method. */
	public static final byte TYPE_USHORT_OFFSET =
		8;
	
	/** Address of the code. */
	public static final byte CODE_ADDRESS_INT_OFFSET =
		10;
	
	/** Size of the code. */
	public static final byte CODE_SIZE_INT_OFFSET =
		14;
	
	/** The constant pool for the class. */
	protected final ClassDualPoolParser pool;
	
	/** The blob for the method data. */
	protected final BinaryBlob blob;
	
	/** The number of fields available. */
	protected final int count;
	
	/**
	 * Initializes the class method parser.
	 *
	 * @param __cp The dual pool parser.
	 * @param __b The binary blob.
	 * @param __n The method count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/29
	 */
	public ClassMethodsParser(ClassDualPoolParser __cp, BinaryBlob __b,
		int __n)
		throws NullPointerException
	{
		if (__cp == null || __b == null)
			throw new NullPointerException("NARG");
		
		this.pool = __cp;
		this.blob = __b;
		this.count = __n;
	}
	
	/**
	 * Returns the blob to the method code.
	 *
	 * @param __dx The index of the method.
	 * @return The blob for the method.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final BinaryBlob code(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		BinaryBlob blob = this.blob;
		int offset = this.tocOffset(__dx);
		
		return blob.subSection(
			blob.readJavaInt(offset + ClassMethodsParser.CODE_ADDRESS_INT_OFFSET),
			blob.readJavaInt(offset + ClassMethodsParser.CODE_SIZE_INT_OFFSET));
	}
	
	/**
	 * Finds the given method and returns the index of it.
	 *
	 * @param __name The method name.
	 * @param __type The method type, may be {@code null} if not needed.
	 * @return The found index or {@code -1} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/27
	 */
	public final int findMethod(String __name, String __type)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Locate
		for (int i = 0, n = this.count; i < n; i++)
		{
			// Name does not match
			if (!__name.equals(this.name(i)))
				continue;
			
			// Type does not match
			if (__type != null && __type.equals(this.type(i)))
				continue;
			
			return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @param __dx The index of the method.
	 * @return The method name.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final String name(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsString(false, this.blob.readJavaUnsignedShort(
			this.tocOffset(__dx) + ClassMethodsParser.NAME_USHORT_OFFSET));
	}
	
	/**
	 * Index of the entry in the table of contents.
	 *
	 * @param __dx The index.
	 * @return The table of contents offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final int tocOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx > this.count)
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ClassMethodsParser.ENTRY_SIZE;
	}
	
	/**
	 * Returns the tyoe of the method.
	 *
	 * @param __dx The index of the method.
	 * @return The method type.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final PoolMethodDescriptor type(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsMethodDescriptor(false,
			this.blob.readJavaUnsignedShort(this.tocOffset(__dx) + ClassMethodsParser.TYPE_USHORT_OFFSET));
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassNameUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * Utilities for working with class names.
 *
 * @since 2019/11/04
 */
public final class ClassNameUtils
{
	/**
	 * Not used.
	 *
	 * @since 2019/11/04
	 */
	private ClassNameUtils()
	{
	}
	
	/**
	 * Returns the component type of the given array class.
	 *
	 * @param __cl The class to check.
	 * @return The component type of the class.
	 * @throws IllegalArgumentException If this is not an array.
	 * @throws InvalidClassFormatException If the component type is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final String componentType(String __cl)
		throws IllegalArgumentException, InvalidClassFormatException,
			NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV0o Cannot get component type of empty
		// class name.}
		int len = __cl.length();
		if (len <= 0)
			throw new IllegalArgumentException("SV0o");
		
		// {@squirreljme.error SV0p The class name is not an array.}
		if (__cl.charAt(0) != '[')
			throw new IllegalArgumentException("SV0p");
		
		switch (__cl.charAt(1))
		{
				// Primitive types
			case 'Z':	return "boolean";
			case 'B':	return "byte";
			case 'S':	return "short";
			case 'C':	return "char";
			case 'I':	return "int";
			case 'J':	return "long";
			case 'F':	return "float";
			case 'D':	return "double";
			
				// Another array
			case '[':
				return __cl.substring(1);
				
				// Class
			case 'L':
				// {@squirreljme.error SV0r Expected class name of array type
				// to end in semi-colon.}
				if (__cl.charAt(len - 1) != ';')
					throw new IllegalArgumentException("SV0r");
				return __cl.substring(2, len - 1);
			
				// {@squirreljme.error SV0q Unknown component type.}
			default:
				throw new InvalidClassFormatException("SV0q");
		}
	}
	
	/**
	 * Returns the number of dimensions the class name has.
	 *
	 * @param __cl The class name to check.
	 * @return The dimension count.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public static final int dimensions(String __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Non-array types have no dimensions ever
		if (!ClassNameUtils.isArray(__cl))
			return 0;
		
		// Count up to the last one
		for (int i = 0, n = __cl.length(); i < n; i++)
			if (__cl.charAt(i) != '[')
				return i - 1;
		
		// {@squirreljme.error SV0y Malformed array class name.}
		throw new InvalidClassFormatException("SV0y");
	}
	
	/**
	 * Checks whether the given class name is an array.
	 *
	 * @param __cl The class name to check.
	 * @return If it is an array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isArray(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return (__cl.length() >= 1 && __cl.charAt(0) == '[');
	}
	
	/**
	 * Is this the class info class?
	 *
	 * @param __cl The class name to check.
	 * @return If this is for class info.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public static final boolean isClassInfo(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return "cc/squirreljme/jvm/ClassInfo".equals(__cl);
	}
	
	/**
	 * Checks whether the specified class is object.
	 *
	 * @param __cl The class name to check.
	 * @return If this is the object class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/29
	 */
	public static final boolean isObject(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return "java/lang/Object".equals(__cl);
	}
	
	/**
	 * Checks whether the given class name is a primitive type.
	 *
	 * @param __cl The class name to check.
	 * @return If it is a primitive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isPrimitiveType(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		switch (__cl)
		{
			case "boolean":
			case "byte":
			case "short":
			case "char":
			case "int":
			case "long":
			case "float":
			case "double":
				return true;
		}
		
		return false;
	}
	
	/**
	 * Is this an array or primitive type?
	 *
	 * @param __cl The class name to check.
	 * @return If it is an array or primitive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isSpecial(String __cl)
		throws NullPointerException
	{
		return ClassNameUtils.isArray(__cl) ||
			ClassNameUtils.isPrimitiveType(__cl);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassPath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This represents a class path which contains multiple class libraries.
 *
 * @since 2019/09/22
 */
public final class ClassPath
{
	/** The shift for index access. */
	private static final int _INDEX_SHIFT =
		24;
	
	/** The mask for the index. */
	private static final int _INDEX_MASK =
		0x00FFFFFF;
	
	/** Mask for JAR index. */
	private static final int _JAR_MASK =
		0x7F000000;
	
	/** The classpath. */
	public final ClassLibrary[] classpath;
	
	/**
	 * Initializes the classpath.
	 *
	 * @param __cp The class path to use.
	 * @throws IllegalArgumentException If the number of class path libraries
	 * exceeds the absolute limit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/22
	 */
	public ClassPath(ClassLibrary... __cp)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV0a Too many entries on the class path.}
		int n = __cp.length;
		if (n > (ClassPath._JAR_MASK >>> ClassPath._INDEX_SHIFT))
			throw new IllegalArgumentException("SV0a");
		
		// Defensive copy and check
		ClassLibrary[] classpath = new ClassLibrary[n];
		for (int i = 0; i < n; i++)
		{
			// Make sure this is not null!
			ClassLibrary cl = __cp[i];
			if (cl == null)
				throw new NullPointerException("NARG");
			
			classpath[i] = cl;
		}
		
		// Use this
		this.classpath = classpath;
	}
	
	/**
	 * Returns the class library of the given index.
	 *
	 * @param __rcdx The class library to get the index of.
	 * @return The class library of the given index.
	 * @throws IndexOutOfBoundsException If the resource index is outside
	 * of bounds.
	 * @since 2019/11/17
	 */
	public final ClassLibrary classLibrary(int __rcdx)
		throws IndexOutOfBoundsException
	{
		return this.classpath[ClassPath.resourceIndexToJarIndex(__rcdx)];
	}
	
	/**
	 * Returns a class file parser for the given index.
	 *
	 * @param __rcdx The index to load.
	 * @return The class file parser.
	 * @throws IndexOutOfBoundsException If the resource is not valid.
	 * @since 2019/11/17
	 */
	public final ClassFileParser classParser(int __rcdx)
		throws IndexOutOfBoundsException
	{
		// We need to take the pools from the class library, if it has any
		ClassLibrary clib = this.classLibrary(__rcdx);
		
		return new ClassFileParser(this.resourceData(__rcdx),
			clib.splitPool(false), clib.splitPool(true));
	}
	
	/**
	 * Searches for the given class name resource for the given class
	 *
	 * @param __name The name of the class.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceClassFind(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		return this.resourceFind(__name + ".class");
	}
	
	/**
	 * Returns the data pointer for the given resource.
	 *
	 * @param __dx The index to get the data pointer for.
	 * @return The data pointer of the resource.
	 * @throws IndexOutOfBoundsException If the index is not found in any
	 * library.
	 * @since 2019/07/11
	 */
	public final BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV08 Out of range resource.}
		int cpdx = __dx >>> ClassPath._INDEX_SHIFT;
		ClassLibrary[] classpath = this.classpath;
		if (cpdx < 0 || cpdx >= classpath.length)
			throw new IndexOutOfBoundsException("SV08");
		
		// Get resource pointer from this
		return classpath[cpdx].resourceData(__dx & ClassPath._INDEX_MASK);
	}
	
	/**
	 * Searches for the given resource in this client task.
	 *
	 * @param __name The name of the resource.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFind(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Scan the classpath
		ClassLibrary[] classpath = this.classpath;
		for (int i = 0, n = classpath.length; i < n; i++)
		{
			// Locate resource
			int rv = classpath[i].indexOf(__name);
			
			// Was found?
			if (rv >= 0)
				return (i << ClassPath._INDEX_SHIFT) | rv;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Searches for the given resource in this client task in the given
	 * specified classpath library.
	 *
	 * @param __name The name of the resource.
	 * @param __in The class path library to look in.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFindIn(String __name, int __in)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Out of range values are always not found
		ClassLibrary[] classpath = this.classpath;
		if (__in < 0 || __in >= classpath.length)
			return -1;
		
		// Locate resource
		int rv = classpath[__in].indexOf(__name);
		
		// If it was found shift in
		if (rv >= 0)
			return (__in << ClassPath._INDEX_SHIFT) | rv;
		
		// Otherwise does not exist
		return -1;
	}
	
	/**
	 * Searches for the given resource in this client task in the given
	 * specified classpath library, if it is not found in that library then
	 * all libraries on the classpath are searched.
	 *
	 * @param __name The name of the resource.
	 * @param __in The class path library to look in.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFindInOtherwise(String __name, int __in)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Search in this specific library first
		int rv = this.resourceFindIn(__name, __in);
		if (rv >= 0)
			return rv;
		
		// Then locate it in any class library
		return this.resourceFind(__name);
	}
	
	/** 
	 * Returns the JAR index of the given resource index.
	 *
	 * @param __rcid The resource index.
	 * @return The JAR index of the given resource.
	 * @since 2019/10/27
	 */
	public static final int resourceIndexToJarIndex(int __rcid)
	{
		return (__rcid & ClassPath._JAR_MASK) >>> ClassPath._INDEX_SHIFT;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassPoolConstants.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * Constants used when parsing the constant pool and such.
 *
 * @since 2019/10/13
 */
public interface ClassPoolConstants
{
	/** Offset to the tag type. */
	byte OFFSET_OF_BYTE_ENTRY_TAG =
		0;
	
	/** Offset to the number of parts. */
	byte OFFSET_OF_BYTE_ENTRY_NUMPARTS =
		1;
	
	/** Offset to the length of the data. */
	byte OFFSET_OF_USHORT_ENTRY_LENGTH =
		2;
	
	/** Offset to the entry. */
	byte OFFSET_OF_INT_ENTRY_OFFSET =
		4;
	
	/** Size of entries. */
	byte ENTRY_SIZE =
		8;
	
	/** String type. */
	byte TYPE_STRING =
		1;
	
	/** Class name. */
	byte TYPE_CLASSNAME =
		2;
	
	/** Class names. */
	byte TYPE_CLASSNAMES =
		3;
	
	/** Class pool pointer. */
	byte TYPE_CLASS_POOL_POINTER =
		4;
	
	/** Method descriptor. */
	byte TYPE_METHOD_DESCRIPTOR =
		7;
	
	/** A string that is used as a constant (cached). */
	byte TYPE_USED_STRING =
		12;
	
	/** Class information pointer. */
	byte TYPE_CLASS_INFO_POINTER =
		14;
	
	/** Noted string. */
	byte TYPE_NOTED_STRING =
		15;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/ClassPoolParser.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This class is used to parse individual pool treads.
 *
 * @see ClassDualPoolParser
 * @since 2019/10/12
 */
public final class ClassPoolParser
	extends AbstractPoolParser
{
	/** The blob for this pool. */
	protected final BinaryBlob blob;
	
	/** The size of this pool. */
	private int _size =
		-1;
	
	/**
	 * Initializes the constant pool parser.
	 *
	 * @param __blob The blob data for the pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/12
	 */
	public ClassPoolParser(BinaryBlob __blob)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final int count(boolean __ft)
		throws InvalidClassFormatException
	{
		// If the size is negative, it has never been read before
		int rv = this._size;
		if (rv < 0)
			this._size = (rv = this.blob.readJavaInt(
				ClassPoolConstants.OFFSET_OF_INT_ENTRY_OFFSET));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		int tocoff = this.entryTableOffset(__dx);
		
		// Return blob to just the data area
		BinaryBlob blob = this.blob;
		return blob.subSection(blob.readJavaInt(tocoff +
			ClassPoolConstants.OFFSET_OF_INT_ENTRY_OFFSET),
			blob.readJavaUnsignedShort(tocoff +
				ClassPoolConstants.OFFSET_OF_USHORT_ENTRY_LENGTH));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		int tocoff = this.entryTableOffset(__dx);
		
		// We need the part count, since these values may be wide or not
		BinaryBlob blob = this.blob;
		int numparts = blob.readByte(tocoff +
			ClassPoolConstants.OFFSET_OF_BYTE_ENTRY_NUMPARTS);
		
		// The parts is actually in the data, so we have to access it!
		BinaryBlob data = this.entryData(__dx);
		
		// Wide
		short[] rv;
		if (numparts < 0)
		{
			// Setup array
			rv = new short[-numparts];
			
			// Read in parts
			for (int i = 0, p = 0; i > numparts; i--, p += 2)
				rv[-i] = data.readJavaShort(p);
		}
		
		// Narrow
		else
		{
			// Setup array
			rv = new short[numparts];
			
			// Read in parts
			for (int i = 0, p = 0; i < numparts; i++, p++)
				rv[i] = data.readByte(p);
		}
		
		// Use whatever values were read
		return rv;
	}
	
	/**
	 * Returns the offset of the pool entry in the table of contents.
	 *
	 * @param __dx The index to get.
	 * @return The offset in the table of contents.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @since 2019/11/24
	 */
	public final int entryTableOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx >= this.count())
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ClassPoolConstants.ENTRY_SIZE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readUnsignedByte(this.entryTableOffset(__dx) +
			ClassPoolConstants.OFFSET_OF_BYTE_ENTRY_TAG);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/DataType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This contains the various data types classes and fields may be.
 *
 * @since 2019/10/12
 */
public interface DataType
{
	/** Object. */
	byte OBJECT =
		0;
	
	/** Byte. */
	byte BYTE =
		1;
	
	/** Short. */
	byte SHORT =
		2;
	
	/** Character. */
	byte CHARACTER =
		3;
	
	/** Integer. */
	byte INTEGER =
		4;
	
	/** Float. */
	byte FLOAT =
		5;
	
	/** Long. */
	byte LONG =
		6;
	
	/** Double. */
	byte DOUBLE =
		7;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/InvalidClassFormatException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This is thrown when a class is not valid.
 *
 * @since 2019/11/17
 */
public class InvalidClassFormatException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/PoolClassInfoPointer.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This is a reference to a Class's information pointer.
 *
 * @since 2019/12/15
 */
public final class PoolClassInfoPointer
{
	/** The name of the class. */
	protected final String name;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __n The name of the class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public PoolClassInfoPointer(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/15
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/PoolClassName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import java.util.Objects;

/**
 * This represents a class name within the constant pool.
 *
 * @since 2019/11/25
 */
public final class PoolClassName
{
	/** The class name. */
	protected final String name;
	
	/** The component type. */
	protected final PoolClassName componenttype;
	
	/**
	 * Initializes the pool class name.
	 *
	 * @param __n The name of the class.
	 * @param __cp The component type, this is optional.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/25
	 */
	public PoolClassName(String __n, PoolClassName __cp)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.componenttype = __cp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (!(__o instanceof PoolClassName))
			return false;
		
		PoolClassName o = (PoolClassName)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.componenttype, o.componenttype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.componenttype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/PoolClassPoolPointer.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This is a reference to a Class's pool pointer.
 *
 * @since 2019/12/15
 */
public final class PoolClassPoolPointer
{
	/** The name of the class. */
	protected final String name;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __n The name of the class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public PoolClassPoolPointer(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/15
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/PoolMethodDescriptor.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
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

/**
 * This represents a method descriptor.
 *
 * @since 2019/12/14
 */
public final class PoolMethodDescriptor
{
	/** The descriptor. */
	protected final String descriptor;
	
	/** The return value. */
	protected final PoolClassName returnvalue;
	
	/** Arguments. */
	private final PoolClassName[] _args;
	
	/**
	 * Initializes the descriptor.
	 *
	 * @param __str The string to use.
	 * @param __rv The return value.
	 * @param __args The arguments.
	 * @throws NullPointerException If no string or arguments were specified.
	 * @since 2019/12/14
	 */
	public PoolMethodDescriptor(String __str, PoolClassName __rv,
		PoolClassName... __args)
		throws NullPointerException
	{
		if (__str == null || __args == null)
			throw new NullPointerException("NARG");
		
		this.descriptor = __str;
		this.returnvalue = __rv;
		
		// Copy arguments
		int numargs = __args.length;
		PoolClassName[] args = new PoolClassName[numargs];
		for (int i = 0; i < numargs; i++)
		{
			PoolClassName a = __args[i];
			if (a == null)
				throw new NullPointerException("NARG");
			
			args[i] = a;
		}
		
		this._args = args;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final String toString()
	{
		return this.descriptor;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/PoolNotedString.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.lib;

import cc.squirreljme.jvm.boot.io.BinaryBlob;

/**
 * This represents a noted string.
 *
 * @since 2019/12/14
 */
public final class PoolNotedString
{
	/** The blob for the string data. */
	protected final BinaryBlob blob;
	
	/**
	 * Initializes the noted string.
	 *
	 * @param __blob The blob for this string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public PoolNotedString(BinaryBlob __blob)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
	}
	
	/**
	 * Returns the blob for this string.
	 *
	 * @return The used blob.
	 * @since 2019/12/14
	 */
	public final BinaryBlob blob()
	{
		return this.blob;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/lib/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the information and classes for handling the class
 * library within the SquirrelJME JVM instance.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.boot.lib;

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot;

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/NoSuchMethodTaskException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when there is no such method.
 *
 * @since 2019/12/14
 */
public class NoSuchMethodTaskException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/NoSuchTaskException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when there is no such given task.
 *
 * @since 2019/12/14
 */
public class NoSuchTaskException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public NoSuchTaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/Task.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

import cc.squirreljme.jvm.boot.Globals;
import cc.squirreljme.jvm.boot.lib.ClassInfoUtility;
import cc.squirreljme.jvm.boot.lib.ClassNameUtils;
import cc.squirreljme.jvm.boot.lib.ClassPath;
import java.util.HashMap;

/**
 * This represents a single task which has information on what it is running
 * along with its ID and such.
 *
 * @since 2019/06/22
 */
public final class Task
{
	/** The physical task ID. */
	public final int pid;
	
	/** The logical task ID. */
	public final int lid;
	
	/** Allocator for this task. */
	public final TaskAllocator allocator;
	
	/** The classpath. */
	public final ClassPath classpath;
	
	/** Classes which have been read and initialized. */
	private final HashMap<String, TaskClass> _classes =
		new HashMap<>();
	
	/** Class info parser utility. */
	private ClassInfoUtility _ciutil;
	
	/**
	 * Initializes the client task.
	 *
	 * @param __pid The PID.
	 * @param __lid The LID.
	 * @param __cp The classpath used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/22
	 */
	public Task(int __pid, int __lid, ClassPath __cp)
		throws NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		this.pid = __pid;
		this.lid = __lid;
		this.classpath = __cp;
		
		// Initialize allocator for memory grabbing
		this.allocator = new TaskAllocator(__pid);
	}
	
	/**
	 * Since {@link cc.squirreljme.jvm.ClassInfo} is an important and often
	 * used part of loading classes within tasks, this is used to quickly
	 * cache and obtain a class information utility without requiring a search
	 * be done for it every time.
	 *
	 * @return The utility for {@code ClassInfo}.
	 * @since 2019/11/17
	 */
	public final ClassInfoUtility classInfoUtility()
	{
		ClassInfoUtility rv = this._ciutil;
		if (rv != null)
			return rv;
		
		// Create utility
		ClassPath classpath = this.classpath;
		this._ciutil = (rv = ClassInfoUtility.of(classpath.classParser(
			classpath.resourceClassFind("cc/squirreljme/jvm/ClassInfo"))));
		
		return rv;
	}
	
	/**
	 * Returns the current context thread of execution.
	 *
	 * @return The current context thread.
	 * @since 2019/12/14
	 */
	public final TaskThread contextThread()
	{
		todo.DEBUG.note("TODO -- Implement better contextThread(), lid=%d.",
			this.lid);
		
		// Could not determine the context thread, use fallback by calling
		// any thread and hoping it works
		return Globals.getThreadManager().anyThreadOwnedByTask(this.lid);
	}
	
	/**
	 * Creates a new thread
	 *
	 * @return The resulting thread.
	 * @since 2019/10/13
	 */
	public final TaskThread createThread()
	{
		return Globals.getThreadManager().createThread(this.lid);
	}
	
	/**
	 * Loads the given class.
	 *
	 * @param __cl The class to load.
	 * @return The pointer to the class information.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskNoSuchClassException If the task does not have the specified
	 * class.
	 * @throws TaskVirtualMachineError If there is something wrong with the
	 * task virtual machine.
	 * @since 2019/10/13
	 */
	public final TaskClass loadClass(String __cl)
		throws NullPointerException, TaskNoSuchClassException,
			TaskVirtualMachineError
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Needed to search for classes
		TaskClass rv;
		
		// Try to find already initialized class
		HashMap<String, TaskClass> classes = this._classes;
		synchronized (this)
		{
			// Already made?
			rv = classes.get(__cl);
			if (rv != null)
				return rv;
			
			// {@squirreljme.error SV0m The specified class does not exist
			// and it is not a special class. (The class which does not exist)}
			int cldx = this.classpath.resourceClassFind(__cl);
			if (cldx < 0 && !ClassNameUtils.isSpecial(__cl))
				throw new TaskNoSuchClassException("SV0m " + __cl);
			
			// Setup new one and store it
			classes.put(__cl, (rv = new TaskClass(cldx)));
			
			// Pre-initialize the class
			rv.initializeClassInfoSetup(this, __cl);
		}
		
		// Perform post initialization as needed
		return rv.initializeClassInfo(this, __cl);
	}
	
	/**
	 * Loads an object array with the given values and class type.
	 *
	 * @param __cl The class type.
	 * @param __vs The values to store.
	 * @return The resulting object array.
	 * @since 2019/10/13
	 */
	public final int loadObjectArray(TaskClass __cl, int... __vs)
	{
		return this.allocator.allocateArrayInt(__cl, __vs);
	}
	
	/**
	 * Loads a string in the target virtual machine instance.
	 *
	 * @param __s The string to load.
	 * @return The resulting string pointer.
	 * @since 2019/10/13
	 */
	public final int loadString(String __s)
	{
		if (__s == null)
			return 0;
		
		throw new todo.TODO();
	}
	
	/**
	 * Allocates and initializes a new instance of the given class target.
	 *
	 * @param __cl The class to allocate.
	 * @return The pointer to the instance of the given object.
	 * @throws NoSuchMethodTaskException If there is no default constructor.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/13
	 */
	public final int newInstance(TaskClass __cl)
		throws NoSuchMethodTaskException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Need this to load from the class info
		ClassInfoUtility ciutil = this.classInfoUtility();
		
		// {@squirreljme.error SV13 Class has no default constructor.}
		int defnew = ciutil.defaultNew(__cl);
		if (defnew == 0)
			throw new NoSuchMethodTaskException("SV13");
		
		// Allocate memory here
		int rv = this.allocator.allocateObject(__cl,
			ciutil.classAllocationSize(__cl));
		
		// Invoke the default constructor
		this.contextThread().execute(defnew, ciutil.poolPointer(__cl), rv);
		
		// Return the allocated pointer
		return rv;
	}
	
	/**
	 * Returns the physical ID of the task.
	 *
	 * @return The task physical ID.
	 * @since 2019/12/14
	 */
	public final int physicalProcessId()
	{
		return this.pid;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskAllocator.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

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

/**
 * This is an allocator which uses a pre-set tag value for any allocations.
 *
 * @since 2019/09/23
 */
public final class TaskAllocator
{
	/** The size of the static field area. */
	public static final short STATIC_FIELD_SIZE =
		8192;
	
	/** The extra tag bits to use. */
	protected final int tagbits;
	
	/** The static field pointer. */
	private int _staticfieldptr;
	
	/**
	 * Initializes the tagged allocator.
	 *
	 * @param __pid The PID to allocate for.
	 * @since 2019/09/23
	 */
	public TaskAllocator(int __pid)
	{
		// The tag bits are just the PID shifted up a bit
		this.tagbits = __pid << 4;
	}
	
	/**
	 * Allocates memory for this tag.
	 *
	 * @param __tag The tag used.
	 * @param __sz The number of bytes to allocate.
	 * @return The allocated bytes.
	 * @since 2019/06/23
	 */
	public final int allocate(int __tag, int __sz)
	{
		// Just perform the allocation with our PID as part of the tag and
		// whatever was passed, masked correctly
		int rv = Allocator.allocate(
			this.tagbits | (__tag & Allocator.CHUNK_BITS_VALUE_MASK), __sz);
		
		// Ran out of memory?
		if (rv == 0)
			throw new TaskOutOfMemoryError();
		
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values, no class type
	 * is set.
	 *
	 * @param __v The values to store.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayInt(int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Initialize base array
		int count = __v.length;
		int rv = this.allocateArrayIntEmpty(count);
		
		// Copy pointer values to the array
		int bp = rv + Constants.ARRAY_BASE_SIZE;
		for (int i = 0, wp = 0; i < count; i++, wp += 4)
			Assembly.memWriteInt(bp, wp, __v[i]);
		
		// Return the result of it
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values.
	 *
	 * @param __cl The class to set it as.
	 * @param __v The values to store.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayInt(TaskClass __cl, int... __v)
		throws NullPointerException
	{
		if (__cl == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Allocate using the base form
		int rv = this.allocateArrayInt(__v);
		
		// Store object type
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl.infoPointer());
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values, no class type
	 * is set here.
	 *
	 * @param __n The number of elements in the array.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayIntEmpty(int __n)
		throws NullPointerException
	{
		// Allocate array pointer
		int rv = this.allocateObject(Constants.ARRAY_BASE_SIZE + (__n * 4));
		
		// Write array size
		Assembly.memWriteInt(rv, Constants.ARRAY_LENGTH_OFFSET, __n);
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values.
	 *
	 * @param __cl The class to set it as.
	 * @param __n The number of elements in the array.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayIntEmpty(TaskClass __cl, int __n)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Allocate array pointer
		int rv = this.allocateObject(__cl,
			Constants.ARRAY_BASE_SIZE + (__n * 4));
		
		// Write array size
		Assembly.memWriteInt(rv, Constants.ARRAY_LENGTH_OFFSET, __n);
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @throws IllegalArgumentException If the allocation size is smaller
	 * than the object base size.
	 * @since 2019/10/26
	 */
	public final int allocateObject(int __sz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error SV0x Object allocation is less than the object
		// base size.}
		if (__sz < Constants.OBJECT_BASE_SIZE)
			throw new IllegalArgumentException("SV0x");
		
		// Allocate
		int rv = this.allocate(Allocator.CHUNK_BIT_IS_OBJECT, __sz);
		
		// Set initial count to one, to match new
		Assembly.memWriteInt(rv, Constants.OBJECT_COUNT_OFFSET,
			1);
		
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __cl The class type.
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @since 2019/12/01
	 */
	public final int allocateObject(TaskClass __cl, int __sz)
	{
		int rv = this.allocateObject(__sz);
		
		// Store class type here
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl.infoPointer());
		
		return rv;
	}
	
	/**
	 * Allocates a region that can fit a constant pool with the given number
	 * of entries.
	 *
	 * @param __n The number of entries to use.
	 * @return The pointer to the allocation.
	 * @since 2019/11/25
	 */
	public final int allocatePool(int __n)
	{
		return this.allocate(Allocator.CHUNK_BIT_IS_POOL, 4 * __n);
	}
	
	/**
	 * Frees the given pointer, this is just a helper method.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/10/19
	 */
	public final void free(int __p)
	{
		Allocator.free(__p);
	}
	
	/**
	 * Returns the static field pointer.
	 *
	 * @return The static field pointer.
	 * @since 2019/10/13
	 */
	public final int getStaticFieldPointer()
	{
		// If this has already been initialized then use it!
		int rv = this._staticfieldptr;
		if (rv != 0)
			return rv;
		
		// We need to allocate this data region
		synchronized (this)
		{
			// Double-get in case we ran into this twice!
			rv = this._staticfieldptr;
			if (rv != 0)
				return rv;
			
			// Allocate and store this space
			this._staticfieldptr = (rv = this.allocate(0,
				TaskAllocator.STATIC_FIELD_SIZE));
			
			// Could not allocate for this task!
			if (rv == 0)
				throw new TaskOutOfMemoryError();
			
			// And use it
			return rv;
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskClass.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ClassLoadingAdjustments;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.boot.io.BinaryBlob;
import cc.squirreljme.jvm.boot.io.MemoryBlob;
import cc.squirreljme.jvm.boot.lib.ClassDualPoolParser;
import cc.squirreljme.jvm.boot.lib.ClassFileParser;
import cc.squirreljme.jvm.boot.lib.ClassInfoUtility;
import cc.squirreljme.jvm.boot.lib.ClassNameUtils;
import cc.squirreljme.jvm.boot.lib.ClassPath;
import cc.squirreljme.jvm.boot.lib.ClassPoolConstants;
import cc.squirreljme.jvm.boot.lib.PoolClassName;
import java.util.Objects;

/**
 * This represents a class of a task.
 *
 * @since 2019/10/19
 */
public final class TaskClass
{
	/** The index of the class in the resource table. */
	protected final int resourceindex;
	
	/** The allocated class information. */
	private int _infopointer;
	
	/**
	 * Initializes the class container.
	 *
	 * @param __cldx The class path resource index.
	 * @since 2019/10/19
	 */
	public TaskClass(int __cldx)
	{
		this.resourceindex = __cldx;
	}
	
	/**
	 * Returns the info pointer.
	 *
	 * @return The info pointer.
	 * @throws TaskVirtualMachineError If the info pointer was not set.
	 * @since 2019/10/27
	 */
	public final int infoPointer()
		throws TaskVirtualMachineError
	{
		int rv = this._infopointer;
		
		// {@squirreljme.error SV0n Class information pointer not set.}
		if (rv == 0)
			throw new TaskVirtualMachineError("SV0n");
		
		return rv;
	}
	
	/**
	 * Performs the main initialization of this class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final TaskClass initializeClassInfo(Task __task, String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Right now nothing needs to actually be done here
		return this;
	}
	
	/**
	 * Performs enough setup of the class info to rever to it when the
	 * class table is not locked.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final TaskClass initializeClassInfoSetup(Task __task, String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Debug
		todo.DEBUG.note("Loading class `%s`...", __cl);
		
		// We need the parser for class info so that we can initialize the
		// classes, however every variant of the loader can use this.
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// All branches require the info
		int infopointer = __task.allocator.allocateObject(
			ciutil.classInfoAllocationSize());
		this._infopointer = infopointer;
		
		// This object has the class type of ClassInfo so it must always point
		// to the ClassInfo instance of ClassInfo, however if we are loading
		// ClassInfo then we just use our own pointer
		Assembly.memWriteInt(infopointer, Constants.OBJECT_CLASS_OFFSET,
			(ClassNameUtils.isClassInfo(__cl) ? infopointer :
			__task.loadClass("cc/squirreljme/jvm/ClassInfo")._infopointer));
		
		// These objects should never be garbage collected because they
		// contain important class information!
		Assembly.memWriteInt(infopointer, Constants.OBJECT_COUNT_OFFSET,
			9999999);
		
		// If these are special classes, we need to handle them unique because
		// arrays and primitive types do not exist in any form as a class
		if (ClassNameUtils.isArray(__cl))
			return this.__initializeClassInfoArray(__task, __cl);
		else if (ClassNameUtils.isPrimitiveType(__cl))
			return this.__initializeClassInfoPrimitive(__task, __cl);
		
		// Otherwise initialize a standard class
		return this.__initializeClassInfoClass(__task, __cl);
	}

	/**
	 * Builds the constant pool for the given class.
	 *
	 * @param __task The owning task.
	 * @param __ciu The class info utility.
	 * @param __cfp The class file parser for this class.
	 * @param __poolp The pool pointer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	private final void __buildPool(Task __task, ClassInfoUtility __ciu,
		ClassFileParser __cfp, int __poolp)
		throws NullPointerException
	{
		if (__task == null || __ciu == null || __cfp == null)
			throw new NullPointerException("NARG");
		
		// The name of this class
		String self = __cfp.thisName().toString();
		
		// Initialize individual entries
		ClassDualPoolParser pool = __cfp.pool();
		for (int i = 1, n = pool.count(true); i < n; i++)
		{
			// The value to write into the slot
			int slotv;
			
			// Depends on the type
			int type = pool.entryType(true, i);
			switch (type)
			{
					// A class information pointer
				case ClassPoolConstants.TYPE_CLASS_INFO_POINTER:
					String cip = pool.entryAsClassInfoPointer(true, i).
						toString();
					
					// The given class may be deferred loaded in which case
					// we do not really care about it right now
					slotv = (ClassLoadingAdjustments.isDeferredLoad(self, cip)
						? 0 : __task.loadClass(cip)._infopointer);
					break;
					
					// A class pool pointer
				case ClassPoolConstants.TYPE_CLASS_POOL_POINTER:
					String pip = pool.entryAsClassPoolPointer(true, i).
						toString();
					
					// The pool may be deferred
					slotv = (ClassLoadingAdjustments.isDeferredLoad(self, pip)
						? 0 : __task.classInfoUtility().
							poolPointer(__task.loadClass(pip)));
					break;
					
					// A string which as been noted, not interned
				case ClassPoolConstants.TYPE_NOTED_STRING:
					slotv = ((MemoryBlob)pool.entryAsNotedString(true, i).
						blob()).baseAddress() + 4;
					break;
					
					// Cached string, these are loaded at run-time so there
					// value here is always null!
				case ClassPoolConstants.TYPE_USED_STRING:
					slotv = 0;
					break;
				
				default:
					todo.DEBUG.note("TODO -- Load of pool type %d?", type);
					continue;
			}
			
			// Store slot value
			Assembly.memWriteInt(__poolp, i * Constants.POOL_CELL_SIZE, slotv);
		}
	}
	
	/**
	 * Builds the VTable for this class.
	 *
	 * @param __task The owning task.
	 * @param __ciu The class info utility.
	 * @param __cfp The class file parser for this class.
	 * @param __vtvirtual The virtual method pointer table.
	 * @param __vtpool The pool used for that method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/28
	 */
	private final void __buildVTable(Task __task, ClassInfoUtility __ciu,
		ClassFileParser __cfp, int __vtvirtual, int __vtpool)
		throws NullPointerException
	{
		if (__task == null || __ciu == null || __cfp == null)
			throw new NullPointerException("NARG");
		
		todo.DEBUG.note("TODO -- Build VTables.");
		//throw new todo.TODO();
	}
	
	/**
	 * Initializes an array class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	private final TaskClass __initializeClassInfoArray(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We just need the utility to access the class info
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// Always points to self
		ciutil.setSelfPointer(this, this._infopointer);
		
		// The size is always the base array size
		ciutil.setClassAllocationSize(this, Constants.ARRAY_BASE_SIZE);
		
		// The base of this class is always after object
		ciutil.setBaseSize(this, Constants.OBJECT_BASE_SIZE);
		
		// The number of dimensions this class has
		ciutil.setDimensions(this, ClassNameUtils.dimensions(__cl));
		
		// Set name of our class
		ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// The class depth is always one because this extends object
		ciutil.setClassDepth(this, 1);
		
		// The super-class is always object, so load that and set
		TaskClass object = __task.loadClass("java/lang/Object");
		ciutil.setSuperClass(this, object);
		
		// The VTables, pools, and method counts always use Object's
		ciutil.setVTableVirtual(this, ciutil.vTableVirtual(object));
		ciutil.setVTablePool(this, ciutil.vTablePool(object));
		ciutil.setPoolPointer(this, ciutil.poolPointer(object));
		ciutil.setMethodCount(this, ciutil.methodCount(object));
		
		// We need to handle the component type
		TaskClass comptype = __task.loadClass(
			ClassNameUtils.componentType(__cl));
		
		// Is this component type a primitive?
		boolean compisprim =
			(ciutil.flags(comptype) & Constants.CIF_IS_PRIMITIVE) != 0;
		
		// Set our own flags, note that if our component type is not primitive
		// it is a bunch of objects which is needed for garbage collection
		// of object arrays
		ciutil.setFlags(this, Constants.CIF_IS_ARRAY |
			(compisprim ? 0 : Constants.CIF_IS_ARRAY_OF_OBJECTS));
		
		// The component class is set here
		ciutil.setComponentType(this, comptype);
		
		// The JAR this came from is always the component's JAR
		ciutil.setJarIndex(this, ciutil.jarIndex(comptype));
		
		// The cell size is always 4 unless this is a primitive
		ciutil.setCellSize(this, (compisprim ?
			ciutil.classAllocationSize(comptype) : 4));
		
		// Done
		return this;
	}
	
	/**
	 * Initializes a standard type class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	private final TaskClass __initializeClassInfoClass(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We need the parser for class info so that we can initialize the
		// classes
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// First we load the base class because it will contain information
		// about the class that we need
		ClassFileParser thisparser = __task.classpath.classParser(
			this.resourceindex);
		
		// Pointer to self
		int infopointer = this._infopointer;
		ciutil.setSelfPointer(this, infopointer);
		
		// Set the JAR index
		ciutil.setJarIndex(this, ClassPath.resourceIndexToJarIndex(
			this.resourceindex));
		
		// Set pointer to the mini-class which may or may not be valid at all
		ciutil.setMiniClassPointer(this, thisparser.baseAddress());
		
		// Set magic number
		ciutil.setMagicNumber(this);
		
		// Set flags, note that these are not class flags but VM flags
		ciutil.setFlags(this, 0);
		
		// Set self name
		BinaryBlob name = thisparser.thisNameAsBinaryBlob();
		if (name instanceof MemoryBlob)
			ciutil.setNamePointer(this, ((MemoryBlob)name).baseAddress() + 4);
		
		// Need to store the name elsewhere, since we do not have a direct
		// pointer to the name
		else
			ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// The run-time pool is initialized later, but we need to allocate it
		// now!
		int poolpointer = __task.allocator.allocatePool(
			thisparser.splitPool(true).count());
		ciutil.setPoolPointer(this, poolpointer);
		
		// Allocate static field space
		todo.DEBUG.note("TODO -- Allocate static field space.");
		
		// Set default constructor
		BinaryBlob defnew = thisparser.methodCodeBytes("<init>", "()V");
		if (defnew != null)
			ciutil.setDefaultNew(this, ((MemoryBlob)defnew).baseAddress());
		
		// Load super class if there is one
		String superclassname = Objects.toString(thisparser.superClassName(),
			null);
		TaskClass superclass = (superclassname == null ? null :
			__task.loadClass(superclassname));
		if (superclass != null)
			ciutil.setSuperClass(this, superclass);
		
		// Set the class depth
		int classdepth = (superclass == null ? 0 :
			ciutil.classDepth(superclass) + 1);
		ciutil.setClassDepth(this, classdepth);
		
		// The base for this class
		int basesize = (superclass == null ? 0 :
			ciutil.classAllocationSize(superclass));
		ciutil.setBaseSize(this, basesize);
		
		// Number of methods the class has
		int methodcount = (superclass != null ? ciutil.
			methodCount(superclass) : 0) + thisparser.methodCount(false);
		ciutil.setMethodCount(this, methodcount);
		
		// Pre-allocate the class VTables since we may need to refer to them!
		int vtvirtual = __task.allocator.allocateArrayIntEmpty(methodcount),
			vtpool = __task.allocator.allocateArrayIntEmpty(methodcount);
		ciutil.setVTableVirtual(this, vtvirtual);
		ciutil.setVTablePool(this, vtpool);
		
		// Allocation size of this class
		ciutil.setClassAllocationSize(this,
			basesize + thisparser.fieldSize(false));
		
		// Set number of objects this has, for garbage collection
		ciutil.setObjectCount(this, thisparser.objectCount(false));
		
		// Initialize interfaces
		PoolClassName[] interfacenames = thisparser.interfaceNames();
		int numints = interfacenames.length;
		int[] ifps = new int[numints];
		for (int i = 0; i < numints; i++)
			ifps[i] = __task.loadClass(interfacenames[i].toString()).
				infoPointer();
		
		// Allocate and store
		int ifacespointer = __task.allocator.allocateArrayInt(ifps);
		ciutil.setInterfaces(this, ifacespointer);
		
		// Initialize the VTables for the class now, it is a bit complicated
		// so it is in another method
		this.__buildVTable(__task, ciutil, thisparser, vtvirtual, vtpool);
		
		// Initialize the actual pool constants now
		this.__buildPool(__task, ciutil, thisparser, poolpointer);
		
		// Load static field constant values
		todo.DEBUG.note("TODO -- Load static field constant values.");
		
		// Set interfaces array type
		Assembly.memWriteInt(ifacespointer, Constants.OBJECT_CLASS_OFFSET,
			__task.loadClass("[Lcc/squirreljme/jvm/ClassInfo;").infoPointer());
		
		// Set the class type for the vtable array last, since everything
		// is now setup with it!
		TaskClass intarrayclass = __task.loadClass("[I");
		Assembly.memWriteInt(vtvirtual, Constants.OBJECT_CLASS_OFFSET,
			intarrayclass.infoPointer());
		Assembly.memWriteInt(vtpool, Constants.OBJECT_CLASS_OFFSET,
			intarrayclass.infoPointer());
		
		// Call static initializer for class, if one exists
		BinaryBlob clinit = thisparser.methodCodeBytes("<clinit>", "()V");
		if (clinit != null)
			__task.contextThread().execute(((MemoryBlob)clinit).baseAddress(),
				poolpointer);
		
		// All done! This class should hopefully work!
		return this;
	}
	
	/**
	 * Initializes a primitive type class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	private final TaskClass __initializeClassInfoPrimitive(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We just need the utility to access the class info
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// Always points to self
		ciutil.setSelfPointer(this, this._infopointer);
		
		// Determine the size of this type
		int size;
		switch (__cl)
		{
			case "boolean":
			case "byte":
				size = 1;
				break;
			
			case "short":
			case "char":
				size = 2;
				break;
			
			case "int":
			case "float":
				size = 4;
				break;
			
			case "long":
			case "double":
				size = 8;
				break;
			
				// {@squirreljme.error SV0z Invalid primitive type.}
			default:
				throw new RuntimeException("SV0z");
		}
		
		// Set as primitive
		ciutil.setFlags(this, Constants.CIF_IS_PRIMITIVE);
		
		// Set size of type
		ciutil.setClassAllocationSize(this, size);
		ciutil.setCellSize(this, size);
		
		// Set name of our class
		ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// Comes from no JAR so is invalid
		ciutil.setJarIndex(this, -1);
		
		// The VTables, pools, and method counts always use Object's, even
		// if it is not the super-class of object
		TaskClass object = __task.loadClass("java/lang/Object");
		ciutil.setVTableVirtual(this, ciutil.vTableVirtual(object));
		ciutil.setVTablePool(this, ciutil.vTablePool(object));
		ciutil.setPoolPointer(this, ciutil.poolPointer(object));
		ciutil.setMethodCount(this, ciutil.methodCount(object));
		
		// Done
		return this;
	}
	
	/**
	 * Makes a UTF-8 string of the given string.
	 *
	 * @param __task The task.
	 * @param __s The string to encode.
	 * @return The raw string pointer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	private final int __makeString(Task __task, String __s)
		throws NullPointerException
	{
		if (__task == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Count the number of bytes this will take up
		int bytes = 2;
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			if (c >= 0x0001 && c <= 0x007F)
				bytes += 1;
			else if (c == 0x0000 || (c >= 0x0080 && c <= 0x07FF))
				bytes += 2;
			else
				bytes += 3;
		}
		
		// Allocate and set the length of the string
		int rv = __task.allocator.allocate(0, bytes);
		Assembly.memWriteJavaShort(rv, 0, bytes);
		
		// Write character data within
		int base = rv + 2;
		for (int i = 0, o = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Single byte
			if (c >= 0x0001 && c <= 0x007F)
				Assembly.memWriteByte(base, o++, c);
			
			// Two byte
			else if (c == 0x0000 || (c >= 0x0080 && c <= 0x07FF))
			{
				Assembly.memWriteByte(base, o++, 0b110_00000 |
					((c >>> 6) & 0b11111));
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					(c & 0b111111));
			}
			
			// Three byte
			else
			{
				Assembly.memWriteByte(base, o++, 0b1110_0000 |
					(c >>> 12) & 0b1111);
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					((c >>> 6) & 0b111111));
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					(c & 0b111111));
			}
		}
		
		// All done!
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskCreateResult.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.boot.task;

/**
 * This is the result of a created task
 *
 * @since 2019/12/08
 */
public final class TaskCreateResult
{
	/** The resulting task. */
	public final Task task;
	
	/** The initial thread. */
	public final TaskThread thread;
	
	/** The main entry class. */
	public final String mainclass;
	
	/** The main entry method name. */
	public final String mainmethodname;
	
	/** The main entry method type. */
	public final String mainmethodtype;
	
	/** The arguments to call. */
	public final int[] callargs;
	
	/**
	 * Initializes the task creation result.
	 *
	 * @param __task The created task.
	 * @param __thread The created task.
	 * @param __mcl The main class.
	 * @param __mname The method name.
	 * @param __mtype The method type.
	 * @param __callargs The arguments to the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public TaskCreateResult(Task __task, TaskThread __thread, String __mcl,
		String __mname, String __mtype, int[] __callargs)
		throws NullPointerException
	{
		if (__task == null || __thread == null || __mcl == null ||
			__mname == null || __mtype == null || __callargs == null)
			throw new NullPointerException("NARG");
		
		this.task = __task;
		this.thread = __thread;
		this.mainclass = __mcl;
		this.mainmethodname = __mname;
		this.mainmethodtype = __mtype;
		this.callargs = __callargs;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is the base for any exception thrown when processing tasks.
 *
 * @since 2019/10/21
 */
public class TaskException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public TaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

import cc.squirreljme.jvm.boot.lib.ClassLibrary;
import cc.squirreljme.jvm.boot.lib.ClassPath;

/**
 * This manages multiple tasks.
 *
 * @since 2019/06/22
 */
public final class TaskManager
{
	/** The maximum number of permitted tasks. */
	public static final byte MAX_TASKS =
		15;
	
	/** The shift for tasks. */
	private static final byte _TASK_SHIFT =
		4;
	
	/** The low mask for tasks. */
	private static final byte _TASK_MASK =
		0xF;
	
	/** The tasks which are available. */
	public final Task[] tasks =
		new Task[TaskManager.MAX_TASKS];
	
	/** The next logical task ID. */
	private volatile int _nextlid =
		1;
	
	/**
	 * Initializes the client task manager.
	 *
	 * @since 2019/06/22
	 */
	public TaskManager()
	{
		// Setup a system task, it has no classpath and is always zero
		this.tasks[0] = new Task(0, 0, new ClassPath());
	}
	
	/**
	 * Returns the task by the given logical ID.
	 *
	 * @param __lid The logical ID of the task.
	 * @return The given task.
	 * @throws NoSuchTaskException If the given task does not exist.
	 * @since 2019/12/14
	 */
	public final Task getTask(int __lid)
		throws NoSuchTaskException
	{
		synchronized (this)
		{
			// The lower bits are used to quickly obtain the PID slot
			Task rv = this.tasks[__lid & TaskManager._TASK_MASK];
			if (rv != null && rv.lid == __lid)
				return rv;
		}
		
		// {@squirreljme.error SV10 No such task exists. (The task)}
		throw new NoSuchTaskException("SV10 " + __lid);
	}
	
	/**
	 * Creates a new task.
	 *
	 * @param __cp The class path to use.
	 * @param __im Is the initial class a MIDlet?
	 * @param __mcl The main class.
	 * @param __args The arguments to the task.
	 * @param __sp System properties.
	 * @return The resulting task.
	 * @throws NullPointerException On null arguments.
	 * @throws TooManyTasksException If the task could not be created.
	 * @since 2019/06/22
	 */
	public TaskCreateResult newTask(ClassLibrary[] __cp, String __mcl,
		boolean __im, String[] __args, String[] __sp)
		throws NullPointerException, TooManyTasksException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		// Tasks that are currently active
		Task[] tasks = this.tasks;
		
		// The resulting new task and its PID
		Task rv;
		int pid;
		
		// One a single process may make tasks at a time, so we need to lock
		// here to prevent the entire system from collapsing
		synchronized (this)
		{
			// Find a free task spot
			for (pid = 1; pid < TaskManager.MAX_TASKS; pid++)
				if (tasks[pid] == null)
					break;
			
			// {@squirreljme.error SV01 Task limit reached.}
			if (pid >= TaskManager.MAX_TASKS)
				throw new TooManyTasksException("SV01");
			
			// Setup and store task now
			rv = new Task(pid, ((this._nextlid++) << TaskManager._TASK_SHIFT) | pid,
				new ClassPath(__cp));
			tasks[pid] = rv;
		}
		
		// Create main thread to initialize
		TaskThread thread = rv.createThread();
		
		// Set static field pointer of this thread, this is so that static
		// field areas can be executed properly
		thread.setStaticFieldPointer(rv.allocator.getStaticFieldPointer());
		
		// The method and arguments to use for the entry call
		String mname, mtype;
		int[] callargs;
		
		// Loading a MIDlet, so initialize MIDlet class
		if (__im)
		{
			// Load instance of main MIDlet class
			TaskClass mainclass = rv.loadClass(__mcl);
			
			// Create instance of the MIDlet class
			int midinstance = rv.newInstance(mainclass);
			
			// Setup call information
			mname = "startApp";
			mtype = "()V";
			callargs = new int[]{midinstance};
		}
		
		// Start from static main() entry point
		else
		{
			// Load arguments for main class into array
			int numargs = (__args == null ? 0 : __args.length);
			int[] mainargs = new int[numargs];
			for (int i = 0; i < numargs; i++)
				mainargs[i] = rv.loadString(__args[i]);
			
			// Load main arguments into string array
			int argsarray = rv.loadObjectArray(
				rv.loadClass("[Ljava/lang/String;"), mainargs);
			
			// Setup call information
			mname = "main";
			mtype = "([Ljava/lang/String;)V";
			callargs = new int[]{argsarray};
		}
		
		// Create result
		return new TaskCreateResult(rv, thread, __mcl, mname, mtype, callargs);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskNoSuchClassException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when a class does not exist for a task.
 *
 * @since 2019/10/27
 */
public class TaskNoSuchClassException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskNoSuchClassException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskOutOfMemoryError.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when a task has ran out of memory.
 *
 * @since 2019/11/25
 */
public class TaskOutOfMemoryError
	extends TaskVirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskSysCallHandler.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.boot.ConfigReader;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.SupervisorPropertyIndex;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is the handler for system calls within tasks.
 *
 * @since 2019/10/06
 */
public final class TaskSysCallHandler
{
	/**
	 * Not used.
	 *
	 * @since 2019/10/06
	 */
	private TaskSysCallHandler()
	{
	}
	
	/**
	 * Initializes and sets the task handler for system calls.
	 *
	 * @param __cr The configuration to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/06
	 */
	public static final void initTaskHandler(ConfigReader __cr)
		throws NullPointerException
	{
		if (__cr == null)
			throw new NullPointerException("NARG");
			
		// Message
		todo.DEBUG.note("Setting task system call handler...");
		
		// Set handlers
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_STATIC_FIELD_POINTER,
			__cr.loadInteger(ConfigRomType.SYSCALL_STATIC_FIELD_POINTER));
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_METHOD_HANDLER,
			__cr.loadInteger(ConfigRomType.SYSCALL_CODE_POINTER));
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_METHOD_POOL_POINTER,
			__cr.loadInteger(ConfigRomType.SYSCALL_POOL_POINTER));
		
		// Message
		todo.DEBUG.note("Okay.");
	}
	
	/**
	 * Handler for task system calls.
	 *
	 * @param __tid The task ID.
	 * @param __oldsfp The old static field pointer.
	 * @param __si The system call that was made.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2019/10/05
	 */
	public static final long taskSysCall(int __tid, int __oldsfp, short __si,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g, int __h)
	{
		return Assembly.sysCallPVL(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.boot.Globals;
import cc.squirreljme.jvm.boot.io.MemoryBlob;
import cc.squirreljme.jvm.boot.lib.ClassNameUtils;

/**
 * This represents a single thread, which is associated with a task.
 *
 * Every thread has a controller thread, this is the thread which is
 * actually executing the given thread even if the IDs are different. This
 * allows other threads to execute within the contexts of other threads
 * accordingly.
 *
 * @since 2019/10/13
 */
public final class TaskThread
{
	/** Maximum number of arguments to methods. */
	public static final byte MAX_CALL_ARGUMENTS =
		8;
	
	/** The owning process ID. */
	protected final int pid;
	
	/** The thread ID. */
	protected final int tid;
	
	/** The logical ID of this thread. */
	protected final int lid;
	
	/** The static field pointer for this thread. */
	private int _staticfieldptr;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __pid The owning process ID.
	 * @param __tid The task ID.
	 * @param __lid The logical thread ID.
	 * @since 2019/10/19
	 */
	public TaskThread(int __pid, int __tid, int __lid)
	{
		this.pid = __pid;
		this.tid = __tid;
		this.lid = __lid;
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * This searches for the method and loads any classes as needed.
	 *
	 * @param __cl The class to execute.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call.
	 * @throws IllegalArgumentException If the argument count is too high or
	 * the requested class is an array or primitive type.
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/10/13
	 */
	public final long execute(String __cl, String __mn, String __mt,
		int... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException, TaskThrownException
	{
		if (__cl == null || __mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV12 Cannot execute into a special class type
		// such as an array or primitive type.}
		if (ClassNameUtils.isSpecial(__cl))
			throw new IllegalArgumentException("SV12");
		
		// Get the owning task
		Task task = Globals.getTaskManager().getTask(this.pid);
		
		// Load our class
		TaskClass eclass = task.loadClass(__cl);
		
		// Execute the resultant method (use the pool of the target class)
		return this.execute(((MemoryBlob)task.classpath.classParser(eclass.
				resourceindex).methodCodeBytes(__mn, __mt)).baseAddress(),
			task.classInfoUtility().poolPointer(eclass), __args);
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * @param __methpool The combined method pointer to invoke and the
	 * constant pool pointer to load, the method pointer is in the low word
	 * while the pool is in the high word.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/12/08
	 */
	public final long execute(long __methpool, int... __args)
		throws IllegalStateException, NullPointerException, TaskThrownException
	{
		return this.execute(Assembly.longUnpackLow(__methpool),
			Assembly.longUnpackHigh(__methpool), __args);
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * @param __meth The method pointer to invoke.
	 * @param __pool The constant pool pointer to load.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call
	 * @throws IllegalArgumentException If too many method arguments were
	 * passed.
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/12/08
	 */
	public final long execute(int __meth, int __pool, int... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException, TaskThrownException
	{
		Assembly.breakpoint();
		throw new Error("TODO");
		/*
		if (__args == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV11 Cannot execute method with the given
		// number of arguments.}
		if (__args.length > TaskThread.MAX_CALL_ARGUMENTS)
			throw new IllegalArgumentException("SV11");
		
		// Get the owning task
		Task task = Globals.getTaskManager().getTask(this.pid);
		
		// Set the task and enter user mode now
		Assembly.sysCallP(SystemCallIndex.FRAME_TASK_ID_SET, task.lid);
		
		// Set new static field register
		int oldsfp = Assembly.specialGetStaticFieldRegister();
		Assembly.specialSetStaticFieldRegister(this._staticfieldptr);
		
		// The number of pass arguments varies!
		int exception = 0;
		long rv = 0;
		try
		{
			switch (__args.length)
			{
				case 0:
				default:
					rv = Assembly.invokeVL(__meth, __pool);
					break;
				
				case 1:
					rv = Assembly.invokeVL(__meth, __pool, __args[0]);
					break;
				
				case 2:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1]);
					break;
				
				case 3:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2]);
					break;
				
				case 4:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3]);
					break;
				
				case 5:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4]);
					break;
				
				case 6:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5]);
					break;
				
				case 7:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5],
						__args[6]);
					break;
				
				case 8:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5],
						__args[6], __args[7]);
					break;
			}
		}
		
		// Wrap the exception value
		catch (Throwable t)
		{
			exception = Assembly.objectToPointer(t);
		}
		
		// Restore some of our state
		finally
		{
			// The static field register space
			Assembly.specialSetStaticFieldRegister(oldsfp);
		}
		
		// Return the result or throw exception
		if (exception != 0)
			throw new TaskThrownException(exception);
		return rv;
		*/
	}
	
	/**
	 * Returns the process ID of this task.
	 *
	 * @return The process ID.
	 * @since 2019/12/14
	 */
	public final int processId()
	{
		return this.pid;
	}
	
	/**
	 * Sets the static field pointer for this thread.
	 *
	 * @param __d The static field pointer.
	 * @since 2019/10/13
	 */
	public final void setStaticFieldPointer(int __d)
	{
		this._staticfieldptr = __d;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskThrownException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This exception is thrown when a task throws an exception, it just points
 * to the exception register pointer itself.
 *
 * @since 2019/10/13
 */
public class TaskThrownException
	extends TaskException
{
	/** The thrown exception value. */
	protected final int pointer;
	
	/**
	 * Initializes the exception with the given pointer.
	 *
	 * @param __p The pointer value to set.
	 * @since 2019/10/13
	 */
	public TaskThrownException(int __p)
	{
		this.pointer = __p;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TaskVirtualMachineError.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when there is something wrong with the task's virtual
 * machine.
 *
 * @since 2019/10/21
 */
public class TaskVirtualMachineError
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/ThreadManager.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This class manages threads within the system.
 *
 * @since 2019/10/13
 */
public final class ThreadManager
{
	/** Default number of threads. */
	private static final int _DEFAULT_THREAD_COUNT =
		16;
	
	/** The number of slots to grow by when out of threads. */
	private static final int _GROW_SIZE =
		8;
	
	/** This is the bootstrap main thread. */
	public final TaskThread BOOT_THREAD =
		new TaskThread(0, 0, 0);
	
	/** Threads that currently exist. */
	private TaskThread[] _threads =
		new TaskThread[ThreadManager._DEFAULT_THREAD_COUNT];
	
	/** The next logical thread id. */
	private int _nextlid;
	
	/**
	 * Always fills in the boot thread.
	 *
	 * @since 2019/10/19
	 */
	{
		this._threads[0] = this.BOOT_THREAD;
	}
	
	/**
	 * Returns any thread that is owned by the given task.
	 *
	 * @param __pid The process ID.
	 * @return The thread owned by the given task or {@code null}.
	 * @since 2019/12/14
	 */
	public final TaskThread anyThreadOwnedByTask(int __pid)
	{
		// Lock self to inspect threads
		TaskThread[] threads = this._threads;
		synchronized (this)
		{
			// The array may be dynamically resized
			int n = threads.length;
			
			// Search for a thread
			for (int i = 0; i < n; i++)
			{
				TaskThread thread = threads[i];
				
				if (thread == null || thread.processId() != __pid)
					continue;
				
				return thread;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Creates the specified thread owned by the given task.
	 *
	 * @param __pid The owning PID.
	 * @return The thread which was created.
	 * @since 2019/10/13
	 */
	public final TaskThread createThread(int __pid)
	{
		TaskThread rv;
		
		// Need to lock on our own manager, since only a single thread an
		// request a new thread
		TaskThread[] threads = this._threads;
		synchronized (this)
		{
			// The array may be dynamically resized
			int n = threads.length;
			
			// Find free spot in physical thread list
			int freespot = -1;
			for (int i = 0; i < n; i++)
				if (threads[i] == null)
				{
					freespot = i;
					break;
				}
			
			// If we ran out of free spots then we need to grow the array to
			// fit more threads
			if (freespot < 0)
			{
				// Setup and copy source
				TaskThread[] newthreads = new TaskThread[n + ThreadManager._GROW_SIZE];
				for (int i = 0; i < n; i++)
					newthreads[i] = threads[i];
				
				// Set as new
				this._threads = (threads = newthreads);
				
				// Use the old size as the end point
				freespot = n;
			}
			
			// Setup thread object itself and store
			rv = new TaskThread(__pid, freespot, ++this._nextlid);
			threads[freespot] = rv;
		}
		
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/TooManyTasksException.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.boot.task;

/**
 * This is thrown when there are too many tasks remaining..
 *
 * @since 2019/12/14
 */
public class TooManyTasksException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public TooManyTasksException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/task/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes and utilities regarding client tasks.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.boot.task;

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



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains SquirrelJME specific special functions which either
 * act on or modify how code is compiled for the JVM.
 *
 * @since 2019/05/25
 */

package cc.squirreljme.jvm;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/Poking.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc;

/**
 * Not Described
 *
 * @since 2020/02/29
 */
public final class Poking
{
	/** Has this been poked? */
	private static volatile boolean _POKED =
		false;
	
	/**
	 * Attempts to poke some native portions of SquirrelJME so that they start.
	 *
	 * @since 2020/02/29
	 */
	public static void poke()
	{
		// Only poke once!
		if (Poking._POKED)
			return;
		Poking._POKED = true;
		
		// We might be running on the emulator, if we are try to poke the
		// NativeBinding class so that way our native calls can be initialized
		try
		{
			Class.forName("cc.squirreljme.emulator.NativeBinding")
				.newInstance();
		}
		catch (ClassNotFoundException|IllegalAccessException|
			InstantiationException e)
		{
			// Ignore
			e.printStackTrace(System.err);
		}
	}
}

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

package cc.squirreljme.runtime.cldc;

/**
 * Contains information on SquirrelJME.
 *
 * @since 2018/12/05
 */
public interface SquirrelJME
{
	/** The version of this SquirrelJME runtime. */
	String RUNTIME_VERSION =
		"0.3.0";
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/annotation/Api.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Indicates the API level of the native call.
 *
 * @since 2018/12/05
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface Api
{
	/** @return The API level. */
	int value();
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/annotation/ImplementationNote.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is an implementation note annotation.
 *
 * @since 2018/09/09
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface ImplementationNote
{
	/** @return The note to be stored. */
	String value() default "";
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/annotation/ProgrammerTip.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a tip to the programmer (along with the developers of SquirrelJME)
 * so things can be remembered easier.
 *
 * @since 2018/10/29
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface ProgrammerTip
{
	/** @return The note to be stored. */
	String value() default "";
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/annotation/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * SquirrelJME specific annotations.
 *
 * @since 2018/03/05
 */

package cc.squirreljme.runtime.cldc.annotation;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/ConsoleCallback.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import java.io.IOException;

/**
 * This is the callback used for the console.
 *
 * @since 2019/02/02
 */
public interface ConsoleCallback
{
	/**
	 * This is called when the stream has been closed.
	 *
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	boolean close();
	
	/**
	 * This is called when the callback is flushed.
	 *
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	boolean flush();
	
	/**
	 * Writes the specified bytes to the output.
	 *
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	boolean write(byte[] __b, int __o, int __l);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/ConsoleOutput.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Used for printing to the console.
 *
 * @since 2018/09/21
 */
public final class ConsoleOutput
{
	/** Standard output. */
	public static final int OUTPUT =
		1;
	
	/** Standard error. */
	public static final int ERROR =
		2;
	
	/** End of file. */
	public static final int ERROR_EOF =
		-1;
	
	/** Invalid file descriptor. */
	public static final int ERROR_INVALIDFD =
		-2;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/21
	 */
	private ConsoleOutput()
	{
	}
	
	/**
	 * Reads the display console, that is anything which was output to the
	 * console itself.
	 *
	 * @param __dim The output dimensions of the console, columns and rows.
	 * This array must always have a length of at least two.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes which were read, this will be the minimum
	 * of either {@code __dim[0] * __dim[1]} or {@code __l}. Zero may be
	 * returned if this is not supported.
	 * @since 2018/12/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int displayRead(int[] __dim,
		byte[] __b, int __o, int __l);
	
	/**
	 * Flushes the stream.
	 *
	 * @param __fd The file descriptor to flush.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int flush(int __fd);
	
	/**
	 * Writes the character to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __c The byte to write, only the lowest 8-bits are used.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/09/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int write(int __fd, int __c);
	
	/**
	 * Writes the given bytes to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int write(int __fd,
		byte[] __b, int __o, int __l);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to the native display system that is used by the
 * LCDUI code to display widgets and such to the screen. Any application may
 * access the screen directly and must manage exclusivity by itself if such a
 * thing is applicable for a single shared screen resource.
 *
 * @since 2018/11/09
 */
@Deprecated
public final class NativeDisplayAccess
{
	/** The number of parameters available. */
	@Deprecated
	public static final int NUM_PARAMETERS =
		8;
	
	/** The pixel format. */
	@Deprecated
	public static final int PARAMETER_PIXELFORMAT =
		0;
	
	/** The buffer width. */
	@Deprecated
	public static final int PARAMETER_BUFFERWIDTH =
		1;
	
	/** The buffer height. */
	@Deprecated
	public static final int PARAMETER_BUFFERHEIGHT =
		2;
	
	/** Alpha channel is used? */
	@Deprecated
	public static final int PARAMETER_ALPHA =
		3;
	
	/** Buffer pitch. */
	@Deprecated
	public static final int PARAMETER_PITCH =
		4;
	
	/** Buffer offset. */
	@Deprecated
	public static final int PARAMETER_OFFSET =
		5;
	
	/** Virtual X offset. */
	@Deprecated
	public static final int PARAMETER_VIRTXOFF =
		6;
	
	/** Virtual Y offset. */
	@Deprecated
	public static final int PARAMETER_VIRTYOFF =
		7;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/09
	 */
	@Deprecated
	private NativeDisplayAccess()
	{
	}
	
	/**
	 * Initialize and/or reset accelerated graphics operations.
	 *
	 * @param __id The display to initialize for.
	 * @return {@code true} if acceleration is supported.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native boolean accelGfx(int __id);
	
	/**
	 * Performs accelerated graphics operation.
	 *
	 * @param __id The display ID.
	 * @param __func The function to call.
	 * @param __args Arguments to the operation.
	 * @return The result of the operation.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native Object accelGfxFunc(int __id, int __func,
		Object... __args);
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @param __id The display ID.
	 * @return The capabilities of the display.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int capabilities(int __id);
	
	/**
	 * Requests that the display should be repainted.
	 *
	 * @param __id The display ID.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void displayRepaint(int __id,
		int __x, int __y, int __w, int __h);
	
	/**
	 * Returns the object representing the framebuffer data.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer array.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native Object framebufferObject(int __id);
	
	/**
	 * Returns the palette of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The palette of the framebuffer.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int[] framebufferPalette(int __id);
	
	/**
	 * Returns the parameters of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer parameters.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int[] framebufferParameters(int __id);
	
	/**
	 * Returns the state count of this framebuffer which is used to detect
	 * when the parameters have changed, where they must all be recalculated
	 * (that is the framebuffer wrapper must be recreated).
	 *
	 * @param __id The display ID.
	 * @return The state count for the framebuffer.
	 * @since 2018/12/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int framebufferStateCount(int __id);
	
	/**
	 * Is the specified display upsidedown?
	 *
	 * @param __id The ID of the display.
	 * @return If the display is upsidedown.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native boolean isUpsideDown(int __id);
	
	/**
	 * Returns the number of permanent displays which are currently attached to
	 * the system.
	 *
	 * @return The number of displays attached to the system.
	 * @since 2018/11/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int numDisplays();
	
	/**
	 * Registers the class to be called for when display events are to be
	 * called.
	 *
	 * @param __cb The callback.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void registerEventCallback(
		NativeDisplayEventCallback __cb);
	
	/**
	 * Sets the title of the display.
	 *
	 * @param __id The display ID.
	 * @param __t The title to use.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void setDisplayTitle(int __id, String __t);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/NativeDisplayEventCallback.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

/**
 * For any native display event that occurs, this method is called back and
 * executed accordingly so that any events may be processed accordingly. This
 * is needed by some operating systems and devices where any access to the
 * native display must be done through this event loop. Most operating systems
 * have a UI event loop
 *
 * @since 2018/12/03
 */
@Deprecated
public interface NativeDisplayEventCallback
{
	/** Key pressed. */
	@Deprecated
	int KEY_PRESSED =
		1;
	
	/** Key repeated. */
	@Deprecated
	int KEY_REPEATED =
		2;
	
	/** Key released. */
	@Deprecated
	int KEY_RELEASED =
		3;
	
	/** Pointer pressed. */
	@Deprecated
	int POINTER_PRESSED =
		4;
	
	/** Pointer dragged. */
	@Deprecated
	int POINTER_DRAGGED =
		5;
	
	/** Pointer released. */
	@Deprecated
	int POINTER_RELEASED =
		6;
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __d The display to run the command on.
	 * @param __c The command to execute.
	 * @since 2018/12/03
	 */
	void command(int __d, int __c);
	
	/**
	 * Exit request generated for a display, this likely means the close
	 * button was pressed.
	 *
	 * Note that an exit might not happen if it is caught (like an exit
	 * dialog question or similar).
	 *
	 * @param __d The display which the close was performed on.
	 * @since 2018/12/03
	 */
	@Deprecated
	void exitRequest(int __d);
	
	/**
	 * Key action has been performed.
	 *
	 * @param __d The display ID.
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @since 2018/12/03
	 */
	@Deprecated
	void keyEvent(int __d, int __ty, int __kc, int __ch, int __time);
	
	/**
	 * This is called when the callback has been lost, another task has claimed
	 * access to the display event handler. This should be called before
	 * a registration occurs.
	 *
	 * @since 2018/12/10
	 */
	@Deprecated
	void lostCallback();
	
	/**
	 * Paints the display.
	 *
	 * @param __d The display.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	@Deprecated
	void paintDisplay(int __d, int __x, int __y, int __w, int __h);
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __d The display to have the end.
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @since 2018/12/03
	 */
	@Deprecated
	void pointerEvent(int __d, int __ty, int __x, int __y, int __time);
	
	/**
	 * Display has been shown or hidden.
	 *
	 * @param __d The display.
	 * @param __shown If this is non-zero the display is shown.
	 * @since 2018/12/03
	 */
	@Deprecated
	void shown(int __d, int __shown);
	
	/**
	 * Display size has changed.
	 *
	 * @param __d The display which has changed.
	 * @param __w The width of the display.
	 * @param __h The height of the display.
	 * @since 2018/12/03
	 */
	@Deprecated
	void sizeChanged(int __d, int __w, int __h);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/ObjectAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;

/**
 * This contains accessors for object information.
 *
 * @since 2018/09/22
 */
@Deprecated
public final class ObjectAccess
{
	/** Monitor is not owned by this thread. */
	@Deprecated
	public static final int MONITOR_NOT_OWNED =
		-1;
	
	/** Monitor did not interrupt. */
	@Deprecated
	public static final int MONITOR_NOT_INTERRUPTED =
		0;
	
	/** Monitor did interrupt. */
	@Deprecated
	public static final int MONITOR_INTERRUPTED =
		1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/22
	 */
	private ObjectAccess()
	{
	}
	
	/**
	 * Allocates an object but does not construct it
	 *
	 * @param __cl The class to allocate.
	 * @return An object for the class, it is not initialized with a
	 * constructor. Returns {@code null} if no more memory is available.
	 * @since 2018/12/04
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object allocateObject(String __cl);
	
	/**
	 * Creates a new array of the given type, this is the actual array and
	 * not the component.
	 *
	 * @param __t The array type, not the component type.
	 * @param __l The array length.
	 * @return An array allocated to the given length.
	 * @since 2018/09/25
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object arrayNew(Class<?> __t, int __l);
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Class<?> classByName(String __s);
	
	/**
	 * Returns the class data which is attached to the given class object.
	 *
	 * @param __cl The class to get the data from.
	 * @return The resulting class data.
	 * @since 2018/12/04
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native ClassData classData(Class<?> __cl);
	
	/**
	 * Returns the class object for the given object.
	 *
	 * @param __v The object to get the class of.
	 * @return The class of the given object, or {@code null} if it has no
	 * class.
	 * @since 2018/09/22
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Class<?> classOf(Object __v);
	
	/**
	 * Checks if the given thread holds the given object in a lock.
	 *
	 * @param __ntid The native thread ID.
	 * @param __o The object to check.
	 * @return If the lock is held.
	 * @since 2018/11/21
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native boolean holdsLock(int __ntid, Object __o);
	
	/**
	 * Returns the identity hashcode of the object.
	 *
	 * @param __o The object to get the hashCode for.
	 * @return The identity hashcode.
	 * @since 2018/10/14
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int identityHashCode(Object __o);
	
	/**
	 * Invokes the specified static method.
	 *
	 * @param __m The method to invoke.
	 * @param __args Arguments to the method, the parameters will be passed
	 * as-is and will not be unboxed, so the method must accept boxed values.
	 * @return The value to return from the method, {@code void} will return
	 * {@code null}.
	 * @since 2018/11/20
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object invokeStatic(StaticMethod __m,
		Object... __args);
	
	/**
	 * Notifies threads waiting on the monitor.
	 *
	 * @param __o The object to notify.
	 * @param __all Notify all threads?
	 * @return If the monitor was a success or not.
	 * @since 2018/11/20
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int monitorNotify(Object __o, boolean __all);
	
	/**
	 * Waits for a notification on a monitor.
	 *
	 * @param __o The object to wait on.
	 * @param __ms The milliseconds.
	 * @param __ns The nanoseconds.
	 * @return The wait status.
	 * @since 2018/11/21
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int monitorWait(Object __o, long __ms,
		int __ns);
	
	/**
	 * Creates a new primitive weak reference. Note that it is not valid to
	 * operate on this object as a normal object, it is a special
	 * representation.
	 *
	 * @return The primitive weak reference.
	 * @since 2018/09/23
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native PrimitiveReference newWeakReference();
	
	/**
	 * Gets the given reference.
	 *
	 * @param __r The reference to read from.
	 * @return The reference value, may be {@code null} if the input reference
	 * is not valid, it was garbage collected, or it was never set.
	 * @since 2018/09/23
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object referenceGet(PrimitiveReference __r);
	
	/**
	 * Sets the given reference to the given value.
	 *
	 * @param __r The reference to set.
	 * @param __v The value to set.
	 * @since 2018/09/23
	 */
	@Deprecated
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void referenceSet(PrimitiveReference __r,
		Object __v);
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param <C> The class to type this as.
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@SuppressWarnings({"unchecked"})
	@Deprecated
	public static final <C> Class<C> classByNameType(String __s)
	{
		return (Class<C>)((Object)ObjectAccess.classByName(__s));
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/ResourceAccess.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to resources and their raw data streams.
 *
 * Access to resources relies on the suites, so the correct suite must be
 * specified. {@link Class#getResourceAsStream(String)} should handle this.
 *
 * @since 2018/10/07
 */
public final class ResourceAccess
{
	/** Resource does not exist. */
	public static final int OPEN_STATUS_NO_RESOURCE =
		-1;
	
	/** JAR does not exist. */
	public static final int OPEN_STATUS_NO_JAR =
		-2;
	
	/** IOException. */
	public static final int OPEN_STATUS_IOEXCEPTION =
		-3;
	
	/** Read returned EOF. */
	public static final int READ_STATUS_EOF =
		-1;
	
	/** Read returned unknown file descriptor. */
	public static final int READ_STATUS_UNKNOWN_FD =
		-2;
	
	/** Read returned IOException. */
	public static final int READ_STATUS_IOEXCEPTION =
		-3;
	
	/** Descriptor was not found. */
	public static final int CLOSE_STATUS_UNKNOWN_FD =
		-2;
	
	/** Close resulted in any IOException. */
	public static final int CLOSE_STATUS_IOEXCEPTION =
		-3;
	
	/**
	 * Returns the number of bytes which are known to be available. This is
	 * not required to be supported but is available for usage if it would
	 * result in optimization.
	 *
	 * If this is not supported by a resource then zero or a negative value
	 * may be returned.
	 *
	 * @param __fd The file descriptor to check.
	 * @return The number of available bytes.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int available(int __fd);
	
	/**
	 * Closes the given resource.
	 *
	 * @param __fd The resource descriptor to close.
	 * @return A negative value indicating the reason for the failure.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int close(int __fd);
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR the resource is in, this specifies the name of a
	 * suite.
	 * @param __res The name of the resource to load.
	 * @return The file descriptor or a negative value if it does not exist.
	 * If {@code -2} is returned that means there was an exception trying to
	 * load the resource.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int open(String __jar, String __res);
	
	/**
	 * Reads data from the given resource.
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative value if the end of
	 * stream was reached.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int read(int __fd, byte[] __b, int __o,
		int __l);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/StaticMethod.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

/**
 * This interface represents a static method which may be executed accordingly.
 *
 * @since 2018/11/20
 */
public interface StaticMethod
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/SuiteAccess.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to suites and other suites which are available for usage.
 *
 * @since 2018/10/26
 */
public class SuiteAccess
{
	/**
	 * Compile/install using data which was passed directly to the given
	 * byte array.
	 */
	public static final int WHERE_DIRECT =
		1;
	
	/**
	 * Compile/install using the given JAR suite specified as a string, this
	 * may be the same as a classpath value.
	 */
	public static final int WHERE_SUITE =
		2;
	
	/**
	 * Returns the suites which are available for usage.
	 *
	 * @return The suites which are available for usage.
	 * @since 2018/10/26
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String[] availableSuites();
	
	/**
	 * Returns the current classpath that is being used.
	 *
	 * @return The current classpath.
	 * @since 2018/12/06
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String[] currentClassPath();
	
	/**
	 * Specifies that the given JAR should be installed into the suite
	 * manager, it may be compiled first.
	 *
	 * @param __wh Where is this JAR located?
	 * @param __data Data which depends on the where parameter.
	 * @return The install status.
	 * @since 2019/04/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int installJar(int __wh, byte[] __data);
	
	/**
	 * Returns the last compile error which was set.
	 *
	 * @return The last compile error.
	 * @since 2019/04/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int lastCompileError();
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/SystemAccess.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to system related details.
 *
 * @since 2018/10/13
 */
public final class SystemAccess
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/13
	 */
	private SystemAccess()
	{
	}
	
	/**
	 * Returns the specified environment variable, it is unspecified and
	 * system dependent if variables are case sensitive or not. Locale may
	 * be considered by the host system additionally. If environment variables
	 * do not exist in the environment then only {@code null} will be
	 * returned.
	 *
	 * @param __e The environment variable to get.
	 * @return The value of that variable or {@code null} if it is not set.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String getEnv(String __e);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/SystemProperties.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to system properties.
 *
 * @since 2018/09/20
 */
public final class SystemProperties
{
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private SystemProperties()
	{
	}
	
	/**
	 * Returns the approximated path where the VM's executable exists. This
	 * will be the actual JVM's JAR or EXE file.
	 *
	 * @return The approximated executable path or {@code null} if it is not
	 * known.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String executablePath();
	
	/**
	 * Returns the depth of the guests within the virtual machine.
	 *
	 * @return The number of guests.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int guestDepth();
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @since 2018/12/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String implementationClass(String __n);
	
	/**
	 * Returns the e-mail to contact for the virtual machine.
	 *
	 * @return The contact e-mail for the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMEmail();
	
	/**
	 * Returns the name of the Java virtual machine.
	 *
	 * @return The name of the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMName();
	
	/**
	 * Returns the URL to the virtual machine's vendor's URL.
	 *
	 * @return The URL of the JVM's virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMURL();
	
	/**
	 * Returns the vendor of the Java virtual machine.
	 *
	 * @return The vendor of the Java virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMVendor();
	
	/**
	 * Returns the full version of the Java virtual machine.
	 *
	 * @return The full Java virtual machine version.
	 * @since 2017/08/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMVersion();
	
	/**
	 * Returns the type of operating SquirrelJME is running on.
	 *
	 * @return The type of operating system SquirrelJME is running on.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int operatingSystemType();
	
	/**
	 * Returns a system property for the given value.
	 *
	 * @param __k The key to get.
	 * @return The value of the property, will be {@code null} if it is not
	 * valid.
	 * @since 2018/09/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String systemProperty(String __k);
	
	/**
	 * Returns the version of the class libraries.
	 *
	 * @return The class library version.
	 * @since 2017/10/02
	 */
	public static String javaRuntimeVersion()
	{
		return SquirrelJME.RUNTIME_VERSION;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/TaskAccess.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to tasks which are running.
 *
 * @since 2018/11/04
 */
public final class TaskAccess
{
	/** The entry point is not valid. */
	public static final int ERROR_INVALID_ENTRY =
		-2;
	
	/** Library in the classpath is missing. */
	public static final int ERROR_MISSING_LIBRARY =
		-3;
	
	/** Exit code indicating bad task things. */
	public static final int EXIT_CODE_FATAL_EXCEPTION =
		127;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private TaskAccess()
	{
	}
	
	/**
	 * Returns the ID of the current thread.
	 *
	 * @return The current thread ID.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int currentThread();
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __tid The thread ID.
	 * @param __p The priority.
	 * @since 2018/12/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void setThreadPriority(int __tid, int __p);
	
	/**
	 * Signals a hardware interrupt on the given thread.
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void signalInterrupt(int __tid);
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int startTask(String[] __cp, String __main,
		String[] __args);
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @param __sprops System properties in key/value pairs to pass to the
	 * target environment.
	 * @param __stdout Callback to receive standard output data, may be
	 * {@code null} to ignore.
	 * @param __stderr Callback to receive standard error data, may be
	 * {@code null} to ignore.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2019/02/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int startTask(String[] __cp, String __main,
		String[] __args, String[] __sprops, ConsoleCallback __stdout,
		ConsoleCallback __stderr);
	
	/**
	 * Starts the given thread.
	 *
	 * @param __t The thread which is to run, the execution point of the
	 * thread is the {@link Thread#__start()} method.
	 * @param __n The name hint of this thread.
	 * @return The thread ID.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int startThread(Thread __t, String __n);
	
	/**
	 * Returns the status of the target task.
	 *
	 * @param __tid The task to get the status of.
	 * @return The status for the given task.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int taskStatus(int __tid);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/asm/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains static methods which in which invocations of methods
 * in the package are replaced by the compiler using native means.
 *
 * @since 2017/12/27
 */

package cc.squirreljme.runtime.cldc.asm;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/CallTraceElement.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.debug;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single entry within the call stack. This is used for
 * debugging purposes to determine where code has thrown an exception.
 *
 * @since 2018/02/21
 */
public final class CallTraceElement
{
	/** The class name. */
	protected final String classname;
	
	/** The method name. */
	protected final String methodname;
	
	/** The method descriptor. */
	protected final String methoddescriptor;
	
	/** The execution pointer of the address. */
	protected final long address;
	
	/** The source code file. */
	protected final String file;
	
	/** The line in the file. */
	protected final int line;
	
	/** The Java byte code instruction. */
	protected final int jbcinst;
	
	/** The Java byte code address. */
	protected final int jbcaddr;
	
	/** The task ID. */
	protected final int taskid;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** At line form. */
	private Reference<String> _stringatl;
	
	/** Class header form. */
	private Reference<String> _stringclh;
	
	/** Hash code. */
	private int _hash;
	
	/**
	 * Initializes an empty call trace element.
	 *
	 * @since 2018/02/21
	 */
	public CallTraceElement()
	{
		this(null, null, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn)
	{
		this(__cl, __mn, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn, String __md)
	{
		this(__cl, __mn, __md, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr)
	{
		this(__cl, __mn, __md, __addr, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @since 2018/04/02
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line)
	{
		this(__cl, __mn, __md, __addr, __file, __line, -1, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @param __jbc The Java byte code instruction used.
	 * @param __jpc The Java PC address.
	 * @since 2019/04/26
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line, int __jbc, int __jpc)
	{
		this(__cl, __mn, __md, __addr, __file, __line, __jbc, __jpc, 0);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @param __jbc The Java byte code instruction used.
	 * @param __jpc The Java PC address.
	 * @param __tid The task ID.
	 * @since 2019/10/05
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line, int __jbc, int __jpc, int __tid)
	{
		this.classname = __cl;
		this.methodname = __mn;
		this.methoddescriptor = __md;
		this.address = __addr;
		this.file = __file;
		this.line = __line;
		this.jbcinst = __jbc;
		this.jbcaddr = __jpc;
		this.taskid = __tid;
	}
	
	/**
	 * Returns the address of the element.
	 *
	 * @return The element address.
	 * @since 2018/03/15
	 */
	public final long address()
	{
		return this.address;
	}
	
	/**
	 * Returns the address of the instruction at the Java byte code position.
	 *
	 * @return The address of the instruction in Java byte code.
	 * @since 2019/04/26
	 */
	public final int byteCodeAddress()
	{
		return this.jbcaddr;
	}
	
	/**
	 * Returns the byte code instruction that was used for this.
	 *
	 * @return The used byte code instruction or {@code 0xFF} if it is not
	 * valid or specified.
	 * @since 2019/04/26
	 */
	public final int byteCodeInstruction()
	{
		return this.jbcinst & 0xFF;
	}
	
	/**
	 * Returns the name of the associated class.
	 *
	 * @return The associated class.
	 * @since 2018/03/15
	 */
	public final String className()
	{
		return this.classname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/02/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof CallTraceElement))
			return false;
		
		CallTraceElement o = (CallTraceElement)__o;
		return Objects.equals(this.classname, o.classname) &&
			Objects.equals(this.methodname, o.methodname) &&
			Objects.equals(this.methoddescriptor, o.methoddescriptor) &&
			Objects.equals(this.file, o.file) &&
			this.address == o.address &&
			this.line == o.line &&
			this.jbcinst == o.jbcinst &&
			this.jbcaddr == o.jbcaddr &&
			this.taskid == o.taskid;
	}
	
	/**
	 * Returns the source file.
	 *
	 * @return The source file.
	 * @since 2018/04/02
	 */
	public final String file()
	{
		return this.file;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/02/21
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
		{
			long address = this.address;
			this._hash = (rv = Objects.hashCode(this.classname) ^
				Objects.hashCode(this.methodname) ^
				Objects.hashCode(this.methoddescriptor) ^
				Objects.hashCode(this.file) ^
				(int)((address >>> 32) | address) ^
				~this.line +
				~this.jbcinst +
				~this.jbcaddr +
				~this.taskid);
		}
		return rv;
	}
	
	/**
	 * Returns the source file line.
	 *
	 * @return The source file line.
	 * @since 2018/04/02
	 */
	public final int line()
	{
		return this.line;
	}
	
	/**
	 * Returns the descriptor of the method.
	 *
	 * @return The method descriptor.
	 * @since 2018/03/15
	 */
	public final String methodDescriptor()
	{
		return this.methoddescriptor;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2018/03/15
	 */
	public final String methodName()
	{
		return this.methodname;
	}
	
	/**
	 * Formats the call trace element but having it only represent the method
	 * point without the class information.
	 *
	 * @return The at line string.
	 * @since 2019/05/11
	 */
	public final String toAtLineString()
	{
		Reference<String> ref = this._stringatl;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String methodname = this.methodname,
				methoddescriptor = this.methoddescriptor;
			long address = this.address;
			int line = this.line;
			int jbcinst = this.jbcinst & 0xFF;
			int jbcaddr = this.jbcaddr;
			int taskid = this.taskid;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			// Method name
			sb.append('.');
			sb.append((methodname == null ? "<unknown>" : methodname));
			
			// Method type
			if (methoddescriptor != null)
			{
				sb.append(':');
				sb.append(methoddescriptor);
			}
			
			// Task ID?
			if (taskid != 0)
			{
				sb.append(" T");
				sb.append(taskid);
			}
			
			// Execution address
			if (address != Long.MIN_VALUE)
			{
				sb.append(" @");
				
				// If the address is really high then it is very likely that
				// this is some RAM/ROM address rather than some easily read
				// index. This makes them more readable and understandable
				if (address > 4096)
				{
					sb.append(Long.toString(address, 16).toUpperCase());
					sb.append('h');
				}
				
				// Otherwise use an index
				else
					sb.append(address);
			}
			
			// File, Line, and/or Java instruction/address
			boolean hasline = (line >= 0),
				hasjbcinst = (jbcinst > 0xFF && jbcinst < 0xFF),
				hasjbcaddr = (jbcaddr >= 0);
			if (hasline || hasjbcinst || hasjbcaddr)
			{
				sb.append(" (");
				
				// Line
				boolean sp = false;
				if ((sp |= hasline))
				{
					sb.append(':');
					sb.append(line);
				}
				
				// Java instruction info
				if (hasjbcinst || hasjbcaddr)
				{
					// Using space?
					if (sp)
						sb.append(' ');
					
					// Used to indicate Java specific stuff
					sb.append('J');
					
					// Write instruction
					if (hasjbcinst)
						sb.append(jbcinst);
					
					// Write address of Java operation
					if (hasjbcaddr)
					{
						sb.append('@');
						sb.append(jbcaddr);
					}
				}
				
				sb.append(')');
			}
			
			this._stringatl = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Formats the call trace element but having it only represent the class.
	 *
	 * @return The class header string.
	 * @since 2019/05/11
	 */
	public final String toClassHeaderString()
	{
		Reference<String> ref = this._stringclh;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String classname = this.classname,
				file = this.file;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			// Class name
			sb.append((classname == null ? "<unknown>" : classname));
			
			// Is this in a file?
			boolean hasfile = (file != null);
			if (hasfile)
			{
				sb.append(" (");
				
				// File
				boolean sp = false;
				if ((sp |= hasfile))
					sb.append(file);
				
				sb.append(')');
			}
			
			this._stringclh = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/14
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String classname = this.classname,
				methodname = this.methodname,
				methoddescriptor = this.methoddescriptor,
				file = this.file;
			long address = this.address;
			int line = this.line;
			int jbcinst = this.jbcinst & 0xFF;
			int jbcaddr = this.jbcaddr;
			int taskid = this.taskid;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			sb.append((classname == null ? "<unknown>" : classname));
			sb.append('.');
			sb.append((methodname == null ? "<unknown>" : methodname));
			
			if (methoddescriptor != null)
			{
				sb.append(':');
				sb.append(methoddescriptor);
			}
			
			// Task ID?
			if (taskid != 0)
			{
				sb.append(" T");
				sb.append(taskid);
			}
			
			if (address != Long.MIN_VALUE)
			{
				sb.append(" @");
				
				// If the address is really high then it is very likely that
				// this is some RAM/ROM address rather than some easily read
				// index. This makes them more readable and understandable
				if (address > 4096)
				{
					sb.append(Long.toString(address, 16).toUpperCase());
					sb.append('h');
				}
				
				// Otherwise use an index
				else
					sb.append(address);
			}
			
			// File, Line, and/or Java instruction/address
			boolean hasfile = (file != null),
				hasline = (line >= 0),
				hasjbcinst = (jbcinst > 0x00 && jbcinst < 0xFF),
				hasjbcaddr = (jbcaddr >= 0);
			if (hasfile || hasline || hasjbcinst || hasjbcaddr)
			{
				sb.append(" (");
				
				// File
				boolean sp = false;
				if ((sp |= hasfile))
					sb.append(file);
				
				// Line
				if ((sp |= hasline))
				{
					sb.append(':');
					sb.append(line);
				}
				
				// Java instruction info
				if (hasjbcinst || hasjbcaddr)
				{
					// Using space?
					if (sp)
						sb.append(' ');
					
					// Used to indicate Java specific stuff
					sb.append('J');
					
					// Write instruction
					if (hasjbcinst)
						sb.append(jbcinst);
					
					// Write address of Java operation
					if (hasjbcaddr)
					{
						sb.append('@');
						sb.append(jbcaddr);
					}
				}
				
				sb.append(')');
			}
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Obtains the current raw call trace which has not been resolved.
	 *
	 * @return The raw call trace.
	 * @since 2019/06/16
	 */
	public static final int[] traceRaw()
	{
		// Get the call height, ignore if not supported!
		int callheight = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_HEIGHT);
		if (callheight <= 0 || Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.CALL_STACK_HEIGHT) != SystemCallError.NO_ERROR)
			return new int[0];
		
		// Remove the top-most frame because it will be this method
		callheight--;
		
		// Get the call parameters
		int[] rv = new int[callheight * CallStackItem.NUM_ITEMS];
		for (int z = 0, base = 0; z < callheight; z++,
			base += CallStackItem.NUM_ITEMS)
			for (int i = 0; i < CallStackItem.NUM_ITEMS; i++)
			{
				// Get parameter
				int vx = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_ITEM,
					1 + z, i);
				
				// Nullify unknown or invalid parameters
				if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
					SystemCallIndex.CALL_STACK_ITEM) !=
					SystemCallError.NO_ERROR)
					vx = 0;
				
				// Fill in
				rv[base + i] = vx;
			}
		
		// Return the raw parameters
		return rv;
	}
	
	/**
	 * Resolves the specified call trace into call trace elements.
	 *
	 * @param __trace The trace to resolve.
	 * @return The resolved trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	public static final CallTraceElement[] traceResolve(int[] __trace)
		throws NullPointerException
	{
		if (__trace == null)
			throw new NullPointerException("NARG");
		
		// Get the call height
		int callheight = __trace.length / CallStackItem.NUM_ITEMS;
		
		// Process all the items
		CallTraceElement[] rv = new CallTraceElement[callheight];
		for (int z = 0, base = 0; z < callheight; z++,
			base += CallStackItem.NUM_ITEMS)
		{
			// Load class name
			int xcl = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.CLASS_NAME]);
			String scl = ((xcl == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xcl));
				
			// Load method name
			int xmn = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.METHOD_NAME]);
			String smn = ((xmn == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xmn));
			
			// Load method type
			int xmt = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.METHOD_NAME]);
			String smt = ((xmt == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xmt));
			
			// Load source file
			int xsf = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.SOURCE_FILE]);
			String ssf = ((xsf == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xsf));
			
			// The PC address
			int pcaddr = __trace[base + CallStackItem.PC_ADDRESS];
			
			// Task ID
			int tid = __trace[base + CallStackItem.TASK_ID];
			
			// Build elements
			rv[z] = new CallTraceElement(
				scl,
				smn,
				smt,
				(pcaddr == 0 ? -1 : pcaddr),
				ssf,
				__trace[base + CallStackItem.SOURCE_LINE],
				__trace[base + CallStackItem.JAVA_OPERATION],
				__trace[base + CallStackItem.JAVA_PC_ADDRESS],
				tid);
		}
		
		// Use the resolved form
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains debugging interfaces and classes used by SquirrelJME.
 *
 * @since 2018/02/21
 */

package cc.squirreljme.runtime.cldc.debug;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/BasicLocale.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Basic locale support.
 *
 * @since 2018/09/20
 */
public abstract class BasicLocale
	implements Locale
{
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public char toLowerCase(char __c)
	{
		if ((__c >= 'A' && __c <= 'Z') || (__c >= 0xC0 && __c <= 0xDE))
			return (char)(__c + 0x20);
		return __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/29
	 */
	@Override
	public char toUpperCase(char __c)
	{
		if ((__c >= 'a' && __c <= 'z') || (__c >= 0xE0 && __c <= 0xFE))
			return (char)(__c - 0x20);
		return __c;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/DefaultLocale.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 final 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();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/Locale.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 represents the interface used to perform locale based operations.
 *
 * @since 2018/09/20
 */
public interface Locale
{
	/**
	 * Converts the specified character to lowercase.
	 *
	 * @param __c The input character.
	 * @return The lowercased character.
	 * @since 2018/09/20
	 */
	char toLowerCase(char __c);
	
	/**
	 * Converts the specified character to uppercase.
	 *
	 * @param __c The input character.
	 * @return The uppercased character.
	 * @since 2018/09/28
	 */
	char toUpperCase(char __c);
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/LocaleEn.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * English locale support.
 *
 * @since 2018/09/20
 */
public class LocaleEn
	extends BasicLocale
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/LocaleEnUs.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * English in United States locale support.
 *
 * @since 2018/09/20
 */
public class LocaleEnUs
	extends LocaleEn
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/i18n/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Internationalization support classes.
 *
 * @since 2018/09/20
 */

package cc.squirreljme.runtime.cldc.i18n;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ASCIIDecoder.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Decoder for ASCII.
 *
 * @since 2018/12/23
 */
public final class ASCIIDecoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Negative values are 128 and up
		byte b = __b[__o];
		if (b < 0)
			return 0x1_0000 | 0xFFFD;
		return 0x1_0000 | (b & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final String encodingName()
	{
		return "ascii";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ASCIIEncoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This encodes ASCII.
 *
 * @since 2018/12/23
 */
public final class ASCIIEncoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x80)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final String encodingName()
	{
		return "ascii";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/CodecFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 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
 */
public final class CodecFactory
{
	/** The encoding to use if it is unknown or not set anywhere. */
	public static final String FALLBACK_ENCODING =
		"utf-8";
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/16
	 */
	private CodecFactory()
	{
	}
	
	/**
	 * Returns a decoder for the given encoding.
	 *
	 * @param __enc The encoding to decode for.
	 * @return The decoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public static final Decoder decoder(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Normalization makes it easier to match
		switch ((__enc = CodecFactory.__normalizeEncodingName(__enc)))
		{
				// ASCII
			case "ascii":
				return new ASCIIDecoder();
				
				// IBM037
			case "ibm037":
				throw new todo.TODO();

				// ISO-8859-1
			case "iso-8859-1":
				return new ISO88591Decoder();
				
				// ISO-8859-15
			case "iso-8859-15":
				return new ISO885915Decoder();
				
				// UTF-8
			case "utf-8":
				return new UTF8Decoder();
			
				// {@squirreljme.error ZZ01 Unknown encoding. (The input
				// encoding)}
			default:
				throw new UnsupportedEncodingException(
					String.format("ZZ01 %s", __enc));
		}
	}
	
	/**
	 * Returns a decoder for the given encoding.
	 *
	 * @param __enc The encoding to decode for.
	 * @return The decoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws RuntimeException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public static final Decoder decoderUnchecked(String __enc)
		throws NullPointerException, RuntimeException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return CodecFactory.decoder(__enc);
		}
		
		// {@squirreljme.error ZZ02 Unknown or unsupported encoding.
		// (The encoding)}
		catch (UnsupportedEncodingException e)
		{
			throw new RuntimeException(String.format("ZZ02 %s", __enc), e);
		}
	}
	
	/**
	 * Returns the default decoder.
	 *
	 * @return The default decoder.
	 * @since 2018/10/13
	 */
	public static final Decoder defaultDecoder()
	{
		return CodecFactory.decoderUnchecked(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default system encoder.
	 *
	 * @return The default encoder.
	 * @since 2018/09/16
	 */
	public static final Encoder defaultEncoder()
	{
		return CodecFactory.encoderUnchecked(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default encoding.
	 *
	 * @return The default encoding.
	 * @since 2018/09/16
	 */
	public static final String defaultEncoding()
	{
		// If no encoding has been set, fallback on one so it is always valid
		try
		{
			String rv = System.getProperty("microedition.encoding");
			if (rv == null)
				return CodecFactory.FALLBACK_ENCODING;
			return rv;
		}
		catch (SecurityException e)
		{
			return CodecFactory.FALLBACK_ENCODING;
		}
	}
	
	/**
	 * Returns the specified encoder.
	 *
	 * @param __enc The encoding to encode to.
	 * @return The encoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	public static final Encoder encoder(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Normalization makes it easier to match
		switch ((__enc = CodecFactory.__normalizeEncodingName(__enc)))
		{
				// ASCII
			case "ascii":
				return new ASCIIEncoder();
				
				// IBM037
			case "ibm037":
				return new IBM037Encoder();

				// ISO-8859-1
			case "iso-8859-1":
				return new ISO88591Encoder();
				
				// ISO-8859-15
			case "iso-8859-15":
				return new ISO885915Encoder();
				
				// UTF-8
			case "utf-8":
				return new UTF8Encoder();
			
				// {@squirreljme.error ZZ03 Unknown encoding. (The output
				// encoding)}
			default:
				throw new UnsupportedEncodingException(
					String.format("ZZ03 %s", __enc));
		}
	}
	
	/**
	 * Returns the specified encoder.
	 *
	 * @param __enc The encoding to encode to.
	 * @return The encoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws RuntimeException If the encoding is not valid.
	 * @since 2018/09/17
	 */
	public static final Encoder encoderUnchecked(String __enc)
		throws NullPointerException, RuntimeException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return CodecFactory.encoder(__enc);
		}
		
		// {@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
	 * returned.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	private static final String __normalizeEncodingName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Store original since it will be lowercase
		String orign = __n;
		
		// Lowercase and map values
		switch ((__n = __n.toLowerCase()))
		{
				// ASCII
			case "646":
			case "ansi_x3.4-1968":
			case "ansi_x3.4-1986":
			case "ascii":
			case "ascii7":
			case "cp367":
			case "csascii":
			case "ibm367":
			case "iso_646.irv:1983":
			case "iso_646.irv:1991":
			case "iso646-us":
			case "iso-ir-6":
			case "us":
			case "us-ascii":
				return "ascii";
				
				// IBM037
			case "037":
			case "cp037":
			case "cpibm37":
			case "cs-ebcdic-cp-ca":
			case "cs-ebcdic-cp-nl":
			case "cs-ebcdic-cp-us":
			case "cs-ebcdic-cp-wt":
			case "csibm037":
			case "ebcdic-cp-ca":
			case "ebcdic-cp-nl":
			case "ebcdic-cp-us":
			case "ebcdic-cp-wt":
			case "ibm037":
			case "ibm-037":
			case "ibm-37":
				return "ibm037";
			
				// ISO-8859-1
			case "819":
			case "8859_1":
			case "cp819":
			case "csisolatin1":
			case "ibm819":
			case "ibm-819":
			case "iso_8859_1":
			case "iso_8859-1":
			case "iso-8859-1":
			case "iso8859_1":
			case "iso8859-1":
			case "iso_8859-1:1987":
			case "iso-ir-100":
			case "l1":
			case "latin1":
				return "iso-8859-1";
			
				// UTF-8
			case "unicode-1-1-utf-8":
			case "utf8":
			case "utf-8":
				return "utf-8";
			
				// Unknown use original
			default:
				return orign;
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ConsoleOutputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.runtime.cldc.asm.ConsoleOutput;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This provides an output stream which writes to a console file descriptor.
 *
 * @since 2018/12/08
 */
public final class ConsoleOutputStream
	extends OutputStream
{
	/** the file descriptor to write to. */
	protected final int fd;
	
	/**
	 * Initializes the output stream.
	 *
	 * @param __fd The descriptor to write to.
	 * @since 2018/12/08
	 */
	public ConsoleOutputStream(int __fd)
	{
		this.fd = __fd;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public void flush()
		throws IOException
	{
		// {@squirreljme.error ZZ05 Could not flush the console.}
		if (ConsoleOutput.flush(this.fd) < 0)
			throw new IOException("ZZ05");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/06/16
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		// {@squirreljme.error ZZ06 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b) != 0)
			throw new IOException("ZZ06");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void write(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ07 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b, 0, __b.length) < 0)
			throw new IOException("ZZ07");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error ZZ08 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b, __o, __l) < 0)
			throw new IOException("ZZ08");
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/Decoder.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This is a decoder which is able to decode input characters and return
 * characters for the input sequence.
 *
 * @since 2018/10/13
 */
public interface Decoder
	extends NamedCodec
{
	/**
	 * Decodes the input bytes.
	 *
	 * @param __b The input byte array.
	 * @param __o The offset.
	 * @param __l The length. Due to the way the return value is used, the
	 * maximum supported length must be limited to 32,767 characters.
	 * @return The decoded character with the upper 16-bits specifying the
	 * number of read bytes, if a negative value is used it is a hint
	 * on the number of bytes needed to decode the character. Note that the
	 * hint may always be {@code -1} if in the event it will not be known how
	 * many bytes to read for a given character. The only result which will
	 * return the length in the upper bytes are sequences which generate
	 * characters, so incomplete sequences will always be negative. When
	 * casting the result to {@code char} the upper bits will be truncated.
	 * @throws IndexOutOfBoundsException If the offset and or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/Encoder.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This interface represents an encoder that is used to turn characters into
 * potentially multiple bytes.
 *
 * @since 2018/09/16
 */
public interface Encoder
	extends NamedCodec
{
	/**
	 * Encodes the given character and writes it to the output byte array.
	 *
	 * @param __c The character to encode.
	 * @param __b The output byte array.
	 * @param __o The offset to the array.
	 * @param __l The length of the area to write.
	 * @return The number of bytes written, {@code -1} means the character
	 * cannot be encoded because it will not fit in the buffer.
	 * @throws IndexOutOfBoundsException If the offset and or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/21
	 */
	int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/IBM037Encoder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Encodes to EBCDIC IBM037.
 *
 * @since 2018/09/24
 */
public final class IBM037Encoder
	implements Encoder
{
	/** Mapping of char to byte. */
	private static final byte[] _MAP =
		new byte[]
		{
			0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, 16, 17,
			18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, 64, 90,
			127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97, -16,
			-15, -14, -13, -12, -11, -10, -9, -8, -7, 122, 94, 76, 126, 110,
			111, 124, -63, -62, -61, -60, -59, -58, -57, -56, -55, -47, -46,
			-45, -44, -43, -42, -41, -40, -39, -30, -29, -28, -27, -26, -25,
			-24, -23, -70, -32, -69, -80, 109, 121, -127, -126, -125, -124,
			-123, -122, -121, -120, -119, -111, -110, -109, -108, -107, -106,
			-105, -104, -103, -94, -93, -92, -91, -90, -89, -88, -87, -64, 79,
			-48, -95, 7, 32, 33, 34, 35, 36, 0, 6, 23, 40, 41, 42, 43, 44, 9,
			10, 27, 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,
			-1, 65, -86, 74, -79, -97, -78, 106, -75, -67, -76, -102, -118, 95,
			-54, -81, -68, -112, -113, -22, -6, -66, -96, -74, -77, -99, -38,
			-101, -117, -73, -72, -71, -85, 100, 101, 98, 102, 99, 103, -98,
			104, 116, 113, 114, 115, 120, 117, 118, 119, -84, 105, -19, -18,
			-21, -17, -20, -65, -128, -3, -2, -5, -4, -83, -82, 89, 68, 69, 66,
			70, 67, 71, -100, 72, 84, 81, 82, 83, 88, 85, 86, 87, -116, 73,
			-51, -50, -53, -49, -52, -31, 112, -35, -34, -37, -36, -115, -114,
			-33
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// Invalid characters are turned into question marks
		if (__c >= 0x100)
			__c = '?';
		
		// Map
		__b[__o] = IBM037Encoder._MAP[__c];
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "ibm037";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ISO885915Decoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.io;

/**
 * Decoder for ISO-8859-15.
 *
 * @since 2019/04/29
 */
public class ISO885915Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Remap some characters?
		int c = (__b[__o] & 0xFF);
		switch (c)
		{
			case 0x00A4:	c = 0x20AC; break;
			case 0x00A6:	c = 0x0160; break;
			case 0x00A8:	c = 0x0161; break;
			case 0x00B4:	c = 0x017D; break;
			case 0x00B8:	c = 0x017E; break;
			case 0x00BC:	c = 0x0152; break;
			case 0x00BD:	c = 0x0153; break;
			case 0x00BE:	c = 0x0178; break;
		}
		
		return 0x1_0000 | c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-15";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ISO885915Encoder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.io;

/**
 * Encodes character data to ISO-8859-15.
 *
 * @since 2019/04/29
 */
public final class ISO885915Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
			
		// Remap some characters?
		switch (__c)
		{
				// Convert
			case 0x20AC:	__c = (char)0x00A4; break;
			case 0x0160:	__c = (char)0x00A6; break;
			case 0x0161:	__c = (char)0x00A8; break;
			case 0x017D:	__c = (char)0x00B4; break;
			case 0x017E:	__c = (char)0x00B8; break;
			case 0x0152:	__c = (char)0x00BC; break;
			case 0x0153:	__c = (char)0x00BD; break;
			case 0x0178:	__c = (char)0x00BE; break;
			
				// Cannot be encoded
			case 0x00A4:
			case 0x00A6:
			case 0x00A8:
			case 0x00B4:
			case 0x00B8:
			case 0x00BC:
			case 0x00BD:
			case 0x00BE:	__c = (char)0xFFFD; break;
		}
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x100)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-15";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ISO88591Decoder.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Decoder for ISO-8859-1.
 *
 * @since 2018/11/11
 */
public final class ISO88591Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		return 0x1_0000 | (__b[__o] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-1";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ISO88591Encoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Encodes character data to ISO-8859-1.
 *
 * @since 2018/09/20
 */
public final class ISO88591Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x100)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-1";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/NamedCodec.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This is used to get the name of the encoder or decoder that was used.
 *
 * @since 2018/10/13
 */
public interface NamedCodec
{
	/**
	 * The average sequence length used for characters, used to estimate how
	 * big of an array to allocate for characters.
	 *
	 * @return The average sequence length.
	 * @since 2018/11/06
	 */
	double averageSequenceLength();
	
	/**
	 * Returns the name of the encoding.
	 *
	 * @return The encoding name.
	 * @since 2018/10/13
	 */
	String encodingName();
	
	/**
	 * Returns a hint which specifies the maximum length of a byte sequence
	 * for decoding.
	 *
	 * @return The maximum sequence length for decoding.
	 * @since 2018/10/13
	 */
	int maximumSequenceLength();
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/ResourceInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.runtime.cldc.asm.ResourceAccess;
import java.io.IOException;
import java.io.InputStream;

/**
 * This input stream handles reading of resources.
 *
 * @since 2018/10/07
 */
public final class ResourceInputStream
	extends InputStream
{
	/** The file descriptor. */
	protected final int fd;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/**
	 * Initializes the resource input stream.
	 *
	 * @param __fd The file descriptor.
	 * @since 2018/10/07
	 */
	public ResourceInputStream(int __fd)
	{
		this.fd = __fd;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int available()
		throws IOException
	{
		// {@squirreljme.error ZZ09 Could not obtain the available
		// number of bytes left. (The error value)}
		int rv = ResourceAccess.available(this.fd);
		if (rv < 0)
			throw new IOException("ZZ09 " + rv);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Prevent double close of resources because the values may be
		// recycled
		if (!this._closed)
		{
			this._closed = true;
			
			// {@squirreljme.error ZZ0a Closing of resource resulted in an
			// IOException.}
			int rv;
			if ((rv = ResourceAccess.close(this.fd)) < 0)
				throw new IOException("ZZ0a " + rv);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read()
		throws IOException
	{
		byte[] rv = new byte[1];
		for (;;)
		{
			int code = this.read(rv, 0, 1);
			
			// Try again
			if (code == 0)
				continue;
			
			// EOF
			else if (code < 0)
				return -1;
			
			// Snip bits off
			return (rv[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If the stream has been closed it is probably not valid so always
		// return EOF
		if (this._closed)
			return -1;
		
		// Read from stream
		int rv = ResourceAccess.read(this.fd, __b, __o, __l);
		
		// If the end of stream was reached, so just close this stream so
		// that resources are free. Since resources always exist it is very
		// possible that they might not be closed because they are seen as
		// a free resource that has no implications if they are never closed.
		if (rv < 0)
		{
			// {@squirreljme.error ZZ0b Read of resource resulted in an
			// IOException.}
			IOException toss = (rv != ResourceAccess.READ_STATUS_EOF ?
				new IOException("ZZ0b " + rv) : null);
			
			// Close it to not claim resources
			try
			{
				this.close();
			}
			catch (IOException e)
			{
				// If closing caused an issue then
				if (toss != null)
					toss.addSuppressed(e);
				else
					toss = e;
			}
			
			// Either throw the exception or EOF
			if (toss != null)
				throw toss;
			return -1;
		}
		
		// Will be the number of read bytes
		return rv;
	}
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR to look within.
	 * @param __rc The name of the resource to open.
	 * @return The stream for the given resource or {@code null} if it does not
	 * exist.
	 * @since 2018/10/26
	 */
	public static final ResourceInputStream open(String __jar, String __rc)
		throws NullPointerException
	{
		if (__jar == null || __rc == null)
			throw new NullPointerException("NARG");
		
		// If no resource exists then
		int fd = ResourceAccess.open(__jar, __rc);
		if (fd < 0)
		{
			// Any other value besides this means some resource error
			if (fd != ResourceAccess.OPEN_STATUS_NO_RESOURCE)
				todo.DEBUG.note("RA.o(%s, %s) = %d", __jar, __rc, fd);
			return null;
		}
		
		// Otherwise read from that resource
		return new ResourceInputStream(fd);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/SecureByteArrayOutputStream.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is a {@link ByteArrayOutputStream} which does not expose the internal
 * buffer field via the {@link #writeTo(OutputStream)} method.
 *
 * @since 2018/01/15
 */
public final class SecureByteArrayOutputStream
	extends ByteArrayOutputStream
{
	/**
	 * Initializes using the default capacity.
	 *
	 * @since 2018/01/15
	 */
	public SecureByteArrayOutputStream()
	{
	}
	
	/**
	 * Initializes using the specified capacity.
	 *
	 * @param __n The number of bytes to store.
	 * @since 2018/01/15
	 */
	public SecureByteArrayOutputStream(int __n)
	{
		super(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/01/15
	 */
	@Override
	public void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/UTF8Decoder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This class provides a decoder for UTF-8 bytes.
 *
 * @since 2018/10/13
 */
public final class UTF8Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.3333;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Determine the length of the sequence
		byte a = __b[__o];
		int seqlen = 
			(((a & 0b1_0000000) == 0b0_0000000) ? 1 :
			(((a & 0b111_00000) == 0b110_00000) ? 2 :
			(((a & 0b1111_0000) == 0b1110_0000) ? 3 :
			(((a & 0b11111_000) == 0b11110_000) ? 4 :
			-1))));
		
		// Either some unknown sequence or it is a character after U+FFFF which
		// is not supported
		if (seqlen < 0 || seqlen == 4)
			return 0xFFFD | (seqlen > 0 ? (seqlen << 16) : 0x1_0000);
		
		// Cannot decode the entire sequence because there is not enough
		// room
		if (__l < seqlen)
			return -seqlen;
		
		// Decode the character
		switch (seqlen)
		{
				// U+0000 to U+007F
			case 1:
				return (a & 0xFF) | 0x1_0000;
				
				// U+0080 to U+07FF
			case 2:
				return (((__b[__o + 0] & 0b11111) << 6) |
					(__b[__o + 1] & 0b111111)) | 0x2_0000;
				
				// U+0800 to U+FFFF
			case 3:
				return (((__b[__o + 0] & 0b1111) << 12) |
					((__b[__o + 1] & 0b111111) << 6) |
					(__b[__o + 2] & 0b111111)) | 0x3_0000;
				
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "utf-8";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 4;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/UTF8Encoder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This encoder encodes input characters to standard UTF-8 sequences.
 *
 * Surrogate pairs will be encoded as 6 bytes.
 *
 * @since 2018/09/19
 */
public final class UTF8Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.3333;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// One byte
		if (__c >= 0x0000 && __c <= 0x007F)
		{
			if (__l < 1)
				return -1;
			
			__b[__o] = (byte)__c;
			
			return 1;
		}
		
		// Two Byte
		else if (__c >= 0x0080 && __c <= 0x07FF)
		{
			if (__l < 2)
				return -2;
			
			__b[__o + 0] = (byte)(((__c >>> 6) & 0b11111) | 0b110_00000); 
			__b[__o + 1] = (byte)((__c & 0b111111) | 0b10_000000);
			
			return 2;
		}
		
		// Three byte (__c >= 0x0800 && __c <= 0xFFFF)
		else
		{
			if (__l < 3)
				return -3;
				
			__b[__o + 0] = (byte)(((__c >>> 12) & 0b1111) | 0b1110_0000); 
			__b[__o + 1] = (byte)(((__c >>> 6) & 0b111111) | 0b10_000000);
			__b[__o + 2] = (byte)((__c & 0b111111) | 0b10_000000);
			
			return 3;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "utf-8";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 4;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/io/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains I/O related classes.
 *
 * @since 2018/03/01
 */

package cc.squirreljme.runtime.cldc.io;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ApiLevel.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

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

/**
 * Provides access to the current API level.
 *
 * This is used for backwards compatibility.
 *
 * Levels are in the form of {@code 0M_mm_R_yyDDD} (Major version, minor
 * version, release version, year (20yy), day of year). This means they are
 * limited to the form of {@code [0-9].[0-99].[0-9] (Day [0-999] of 20[0-99])}.
 *
 * @since 2018/12/05
 */
@Deprecated
public final class ApiLevel
{
	/** The current API level. */
	@Deprecated
	public static final int CURRENT_LEVEL =
		Assembly.sysCallV(SystemCallIndex.API_LEVEL);
	
	/** Undefined. */
	@Deprecated
	public static final int UNDEFINED =
		0x7FFFFFFF;
	
	/** SquirrelJME 0.2.0 (December 25, 2018). */
	@Deprecated
	public static final int LEVEL_SQUIRRELJME_0_2_0_20181225 =
		2_0_18359;
	
	/** SquirrelJME 0.3.0 (Development). */
	@Deprecated
	public static final int LEVEL_SQUIRRELJME_0_3_0_DEV =
		3_0_19001;
	
	/** SquirrelJME 0.4.0 (July 4, 2019). */
	@Deprecated
	public static final int LEVEL_SQUIRRELJME_0_4_0_20190704 =
		4_0_19185;
	
	/**
	 * Not used.
	 *
	 * @since 2018/12/05
	 */
	@Deprecated
	private ApiLevel()
	{
	}
	
	/**
	 * Converts an API level to a string.
	 *
	 * @param __l The input level.
	 * @return The string.
	 * @since 2018/12/05
	 */
	@Deprecated
	public static String levelToString(int __l)
	{
		return String.format("%d.%d.%d (Day %d of %d)",
			(__l / 100000000) % 10,
			(__l / 1000000) % 100,
			(__l / 100000) % 10,
			__l % 1000,
			2000 + ((__l / 1000) % 100));
	}
	
	/**
	 * Checks if the runtime API level is at a minimum this given level.
	 *
	 * @param __l The level to check.
	 * @return If the minimum level is met.
	 * @since 2019/02/02
	 */
	@Deprecated
	public static boolean minimumLevel(int __l)
	{
		return (ApiLevel.CURRENT_LEVEL >= __l);
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ArrayUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This method contains the code which is able to initialize multi-dimensional
 * arrays and perform other array related tasks.
 *
 * @since 2018/11/03
 */
public final class ArrayUtils
{
	/** Boolean array. */
	public static final byte ARRAY_BOOLEAN =
		1;
	
	/** Byte array. */
	public static final byte ARRAY_BYTE =
		2;
	
	/** Short array. */
	public static final byte ARRAY_SHORT =
		3;
	
	/** Character array. */
	public static final byte ARRAY_CHARACTER =
		4;
	
	/** Integer array. */
	public static final byte ARRAY_INTEGER =
		5;
	
	/** Long array. */
	public static final byte ARRAY_LONG =
		6;
	
	/** Float array. */
	public static final byte ARRAY_FLOAT =
		7;
	
	/** Double array. */
	public static final byte ARRAY_DOUBLE =
		8;
	
	/** Object array. */
	public static final byte ARRAY_OBJECT =
		9;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/03
	 */
	private ArrayUtils()
	{
	}
	
	/**
	 * Sets the value in the array.
	 *
	 * @param __a The array.
	 * @param __dx The index to set.
	 * @param __v The value to store.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @throws ClassCastException If the wrong class is used.
	 * @throws IllegalArgumentException If the argument is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final void arraySet(Object __a, int __dx, Object __v)
		throws ArrayIndexOutOfBoundsException, ClassCastException,
			IllegalArgumentException, NullPointerException
	{
		ArrayUtils.arraySet(ArrayUtils.arrayType(__a), __a, __dx, __v);
	}
	
	/**
	 * Sets the value in the array.
	 *
	 * @param __type The type of array used.
	 * @param __a The array.
	 * @param __dx The index to set.
	 * @param __v The value to store.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @throws ClassCastException If the wrong class is used.
	 * @throws IllegalArgumentException If the argument is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final void arraySet(int __type, Object __a, int __dx,
		Object __v)
		throws ArrayIndexOutOfBoundsException, ClassCastException,
			IllegalArgumentException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Depends on the type
		switch (__type)
		{
			case ArrayUtils.ARRAY_BOOLEAN:
				((boolean[])__a)[__dx] = ((Boolean)__v).booleanValue();
				break;
				
			case ArrayUtils.ARRAY_BYTE:
				((byte[])__a)[__dx] = ((Byte)__v).byteValue();
				break;
				
			case ArrayUtils.ARRAY_SHORT:
				((short[])__a)[__dx] = ((Short)__v).shortValue();
				break;
				
			case ArrayUtils.ARRAY_CHARACTER:
				((char[])__a)[__dx] = ((Character)__v).charValue();
				break;
				
			case ArrayUtils.ARRAY_INTEGER:
				((int[])__a)[__dx] = ((Integer)__v).intValue();
				break;
				
			case ArrayUtils.ARRAY_LONG:
				((long[])__a)[__dx] = ((Long)__v).longValue();
				break;
				
			case ArrayUtils.ARRAY_FLOAT:
				((float[])__a)[__dx] = ((Float)__v).floatValue();
				break;
				
			case ArrayUtils.ARRAY_DOUBLE:
				((double[])__a)[__dx] = ((Double)__v).doubleValue();
				break;
				
			case ArrayUtils.ARRAY_OBJECT:
				((Object[])__a)[__dx] = __v;
				break;
			
				// {@squirreljme.error ZZ0c Invalid array type.}
			default:
				throw new IllegalArgumentException("ZZ0c");
		}
	}
	
	/**
	 * Returns the type of array the object is.
	 *
	 * @param __a The array type.
	 * @return The type of array this is.
	 * @throws IllegalArgumentException If not an array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final int arrayType(Object __a)
		throws IllegalArgumentException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		if (__a instanceof Object[])
			return ArrayUtils.ARRAY_OBJECT;
		else if (__a instanceof boolean[])
			return ArrayUtils.ARRAY_BOOLEAN;
		else if (__a instanceof byte[])
			return ArrayUtils.ARRAY_BYTE;
		else if (__a instanceof short[])
			return ArrayUtils.ARRAY_SHORT;
		else if (__a instanceof char[])
			return ArrayUtils.ARRAY_CHARACTER;
		else if (__a instanceof int[])
			return ArrayUtils.ARRAY_INTEGER;
		else if (__a instanceof long[])
			return ArrayUtils.ARRAY_LONG;
		else if (__a instanceof float[])
			return ArrayUtils.ARRAY_FLOAT;
		else if (__a instanceof double[])
			return ArrayUtils.ARRAY_DOUBLE;
		
		// {@squirreljme.error ZZ0d Invalid array type.}
		throw new IllegalArgumentException("ZZ0d");
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @param __i Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h, int __i)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h, __i});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @param __i Length of dimension.
	 * @param __j Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h, int __i, int __j)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h, __i, __j});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __dims The dimensions and the number of them to use.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/03
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int[] __dims)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__type == null || __dims == null)
			throw new NullPointerException("NARG");
		
		// Count the number of dimensions represented in the type
		String typename = __type.getName();
		int typedims = 0;
		while (typename.charAt(typedims) == '[')
			typedims++;
		
		// {@squirreljme.error ZZ0e Negative number of dimensions available
		// or input type is not correct for the array type.}
		int dims = __dims.length - __skip;
		if (__skip < 0 || dims <= 0 || typedims < dims)
			throw new IllegalArgumentException("ZZ0e");
		
		// Allocate array of this type
		int numelem = __dims[__skip];
		Object rv = ObjectAccess.arrayNew(__type, numelem);
		
		// Need to determine the type for setting
		int type = ArrayUtils.arrayType(rv);
		
		// The array has more dimensions which must be set
		if (dims > 1)
		{
			// Remove a single brace from the class to cut down its dimensions
			// Class names use dot forms, so refer to classes using the class
			// handler.
			Class<?> subtype;
			try
			{
				subtype = Class.forName(typename.substring(1));
			}
			
			// {@squirreljme.error ZZ0f Could not find the sub-type for
			// multi-dimensional array.}
			catch (ClassNotFoundException e)
			{
				throw new Error("ZZ0f", e);
			}
			
			// Skipping ahead by one
			int nxskip = __skip + 1;
			
			// Allocate
			for (int i = 0; i < numelem; i++)
				ArrayUtils.arraySet(type, rv, i,
					ArrayUtils.multiANewArray(subtype, nxskip, __dims));
		}
		
		return (Object)rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/BasicStaticMethod.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * This represents a basic static method.
 *
 * @since 2019/04/19
 */
@Deprecated
public final class BasicStaticMethod
	implements StaticMethod
{
	/** The method index this refers to. */
	private final int _index;
	
	/**
	 * Internally initialized.
	 *
	 * @param __dx The method index.
	 * @since 2019/04/19
	 */
	private BasicStaticMethod(int __dx)
	{
		this._index = __dx;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ClassData.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * This class contains information that is needed by the class object.
 *
 * The purpose is to allow newer versions of the SquirrelJME library to be
 * used on older virtual machines so they can benefit from an updated library
 * without breaking backwards compatiblity by missing things.
 *
 * @since 2018/12/04
 */
@Deprecated
public abstract class ClassData
{
	/** The version of the class data. */
	public final byte version;
	
	/**
	 * Initializes the base class data.
	 *
	 * @param __v The version.
	 * @since 2018/12/04
	 */
	public ClassData(int __v)
	{
		this.version = (byte)__v;
	}
	
	/**
	 * Returns the binary name.
	 *
	 * @return The binary name.
	 * @since 2018/12/04
	 */
	public abstract String binaryName();
	
	/**
	 * Returns the component of the array.
	 *
	 * @return The array component.
	 * @since 2018/12/04
	 */
	public abstract Class<?> component();
	
	/**
	 * Returns the flags for the default constructor.
	 *
	 * @return The default constructor flags.
	 * @since 2018/12/04
	 */
	public abstract int defaultConstructorFlags();
	
	/**
	 * Returns the method which is used for the default constructor.
	 *
	 * @return The static method for the default constructor.
	 * @since 2018/12/04
	 */
	public abstract StaticMethod defaultConstructorMethod();
	
	/**
	 * Returns the number of dimensions for the array.
	 *
	 * @return The dimension count.
	 * @since 2018/12/04
	 */
	public abstract int dimensions();
	
	/**
	 * Method which returns the enumeration values, if an enum.
	 *
	 * @return The enumeration values getter.
	 * @since 2018/12/08
	 */
	public abstract StaticMethod enumValues();
	
	/**
	 * Returns the class flags.
	 *
	 * @return The class flags.
	 * @since 2018/12/04
	 */
	public abstract int flags();
	
	/**
	 * Returns the JAR this class is in.
	 *
	 * @return The JAR this class is in.
	 * @since 2018/12/04
	 */
	public abstract String inJar();
	
	/**
	 * Returns the the interfaces this class implements.
	 *
	 * @return The interface classes.
	 * @since 2018/12/04
	 */
	public abstract Class<?>[] interfaceClasses();
	
	/**
	 * Returns the super class.
	 *
	 * @return The super class.
	 * @since 2018/12/04
	 */
	public abstract Class<?> superClass();
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ClassDataV1.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
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
191
192
193
194
195
196
197
198
199
200
201
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * Version 1 class data.
 *
 * @since 2018/12/04
 */
@Deprecated
public class ClassDataV1
	extends ClassData
{
	/** The super class of this class. */
	private final Class<?> _superclass;
	
	/** The interface classes of this class. */
	private final Class<?>[] _interfaceclasses;
	
	/** The component type. */
	private final Class<?> _component;
	
	/** The binary name of this class. */
	private final String _binaryname;
	
	/** Special class reference index. */
	private final int _specialindex;
	
	/** The number of dimensions. */
	private final int _dimensions;
	
	/** The JAR this class is in. */
	private final String _injar;
	
	/** Class flags. */
	private final int _flags;
	
	/** Default constructor flags. */
	private final int _defaultconflags;
	
	/** Default constructor method. */
	private final StaticMethod _defaultconmethod;
	
	/** Enumeration values. */
	private final StaticMethod _enumvalues;
	
	/**
	 * Version 1 constructor.
	 *
	 * @param __csi Class special index.
	 * @param __bn The binary name of this class.
	 * @param __sc Super classes.
	 * @param __ic Interface classes.
	 * @param __ct The class type.
	 * @param __ij The JAR this class is in.
	 * @param __flags Class flags.
	 * @param __dcf Default constructor flag.
	 * @param __dcm Default constructor method.
	 * @param __efm The method used to fill enumerations.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/04
	 */
	public ClassDataV1(int __csi, String __bn, Class<?> __sc, Class<?>[] __ic,
		Class<?> __ct, String __ij, int __flags, int __dcf, StaticMethod __dcm,
		StaticMethod __efm)
		throws NullPointerException
	{
		super(1);
		
		if (__bn == null)
			throw new NullPointerException("NARG");
		
		this._specialindex = __csi;
		this._binaryname = __bn;
		this._superclass = __sc;
		this._interfaceclasses = __ic;
		this._component = __ct;
		this._injar = __ij;
		this._flags = __flags;
		this._defaultconflags = __dcf;
		this._defaultconmethod = __dcm;
		this._enumvalues = __efm;
		
		// Count dimensions, used for comparison purposes
		int dims = 0;
		for (; __bn.charAt(dims) == '['; dims++)
			;
		this._dimensions = dims;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String binaryName()
	{
		return this._binaryname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?> component()
	{
		return this._component;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int defaultConstructorFlags()
	{
		return this._defaultconflags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public StaticMethod defaultConstructorMethod()
	{
		return this._defaultconmethod;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int dimensions()
	{
		return this._dimensions;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public StaticMethod enumValues()
	{
		return this._enumvalues;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int flags()
	{
		return this._flags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String inJar()
	{
		return this._injar;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?>[] interfaceClasses()
	{
		return this._interfaceclasses;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?> superClass()
	{
		return this._superclass;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ClassFlag.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This represent class flags and their values.
 *
 * @since 2018/12/04
 */
public interface ClassFlag
{
	/** Public. */
	int PUBLIC =
		0x0001;
	
	/** Final. */
	int FINAL =
		0x0010;
	
	/** Super. */
	int SUPER =
		0x0020;
	
	/** Interface. */
	int INTERFACE =
		0x0200;
	
	/** Abstract. */
	int ABSTRACT =
		0x0400;
	
	/** Synthetic. */
	int SYNTHETIC =
		0x1000;
	
	/** Annotation. */
	int ANNOTATION =
		0x2000;
	
	/** Enum. */
	int ENUM =
		0x4000;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/GuestDepth.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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This class returns the current guest depth.
 *
 * @since 2018/11/04
 */
public final class GuestDepth
{
	/** The calculated guest depth. */
	private static int _DEPTH =
		-1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private GuestDepth()
	{
	}
	
	/**
	 * The guest depth for the virtual machine.
	 *
	 * @return The guest depth for the virtual machine.
	 * @since 2018/11/04
	 */
	public static final int guestDepth()
	{
		// Pre-cached depth?
		int rv = GuestDepth._DEPTH;
		if (rv >= 0)
			return rv;
		
		// System property will indicate the number of guests in the VM
		try
		{
			String prop = System.getProperty("cc.squirreljme.guests");
			if (prop == null)
				rv = 0;
			else
				rv = Integer.parseInt(prop);
		}
		
		// Cannot get property so it cannot be known
		catch (SecurityException|NumberFormatException e)
		{
			rv = 0;
		} 
		
		// Cache it for later
		GuestDepth._DEPTH = rv;
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ImplementationClass.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This is used to return an appropriate class to use for the implemenation
 * of something. This is similar to {@link java.util.ServiceLoader} except
 * that it is specific to the virtual machine itself.
 *
 * @since 2018/12/13
 */
@Deprecated
public final class ImplementationClass
{
	/**
	 * Not used.
	 *
	 * @since 2018/12/17
	 */
	@Deprecated
	private ImplementationClass()
	{
	}
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	@Deprecated
	public static final String implementationClass(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Check to see if there is a system property for the implementation
		// to allow it to be replaced
		try
		{
			String rv = System.getProperty("cc.squirreljme.implclass." + __n);
			if (rv != null)
				return rv;
		}
		catch (SecurityException e)
		{
		}
		
		// No implementation
		return null;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/OperatingSystemType.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This represents the type of operating system SquirrelJME is running on.
 *
 * This enumeration is intended to make OS detection standard.
 *
 * @since 2018/01/13
 */
public interface OperatingSystemType
{
	/** Unknown. */
	int UNKNOWN =
		0;
	
	/** Amiga. */
	int AMIGA =
		1;
	
	/** Linux. */
	int LINUX =
		2;
	
	/** Class Mac OS. */
	int MAC_OS_CLASSIC =
		3;
	
	/** Mac OS X. */
	int MAC_OS_X =
		4;
	
	/** MS-DOS and compatibles. */
	int MS_DOS =
		5;
	
	/** Palm OS. */
	int PALM_OS =
		6;
		
	/** Solaris. */
	int SOLARIS =
		7;
	
	/** Windows 16-bit. */
	int WINDOWS_WIN16 =
		8;
	
	/** Windows CE. */
	int WINDOWS_CE =
		9;
	
	/** Windows 9x. */
	int WINDOWS_9X =
		10;
	
	/** Windows NT. */
	int WINDOWS_NT =
		11;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/UncaughtExceptionHandler.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import java.io.PrintStream;

/**
 * This method is called when there has been an uncaught exception being
 * handled.
 *
 * @since 2018/10/29
 */
public final class UncaughtExceptionHandler
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/29
	 */
	private UncaughtExceptionHandler()
	{
	}
	
	/**
	 * Performs some default handling for exceptions that were not caught
	 * anywhere.
	 *
	 * @param __t The throwable to handle.
	 * @since 2018/10/29
	 */
	public static final void handle(Throwable __t)
	{
		// Make a nice and big banner on it
		PrintStream out = System.err;
		out.println("****************************************************");
		out.print("UNCAUGHT EXCEPTION IN THREAD: ");
		out.println(Thread.currentThread());
		
		if (__t != null)
			__t.printStackTrace(out);
		
		out.println("****************************************************");
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * General language support and such.
 *
 * @since 2018/10/29
 */

package cc.squirreljme.runtime.cldc.lang;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/package-info.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for the CLDC runtime and contains the
 * classes and their implementations which are required and needed for the
 * run-time to operate properly.
 *
 * For security purposes, all classes which extend the abstract interfaces to
 * provide an API should and must have package private constructors so that
 * they can be initialized properly.
 *
 * @since 2017/11/10
 */

package cc.squirreljme.runtime.cldc;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/ref/PrimitiveReference.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.ref;

/**
 * Represents an internal primitive reference.
 *
 * @since 2018/09/23
 */
public interface PrimitiveReference
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/ref/PrimitiveWeakReference.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.ref;

/**
 * This represents a primitive weak reference which should be garbage
 * collected when it does not point to anything.
 *
 * @since 2018/09/23
 */
public interface PrimitiveWeakReference
	extends PrimitiveReference
{
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/ref/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support classes for garbage collector references and
 * such.
 *
 * @since 2018/09/23
 */

package cc.squirreljme.runtime.cldc.ref;

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/ByteIntegerArray.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
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

/**
 * Wraps a byte array to provide integer access to it.
 *
 * @since 2019/05/09
 */
public final class ByteIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final byte[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public ByteIntegerArray(byte[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (byte)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/CharacterIntegerArray.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This wraps a character array and provides integer access to it.
 *
 * @since 2018/10/28
 */
public final class CharacterIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final char[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public CharacterIntegerArray(char[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (char)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/DoubleArrayList.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code double} array.
 *
 * @since 2020/01/01
 */
public class DoubleArrayList
	extends AbstractList<Double>
{
	/** The backing array. */
	protected final double[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public DoubleArrayList(double[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public DoubleArrayList(double[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Double get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public double set(int __i, double __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, Double.valueOf(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Double set(int __i, Double __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		double[] array = this.array;
		double rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/FDMLMath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This class contains math methods which are derived from the Freely
 * Distributed Math Library, which is written in C which is then translated
 * into Java. The conversion process is copy and pasted from the origin sources
 * and adapted to Java.
 *
 * The library is located at http://www.netlib.org/fdlibm/ and was
 * developed at Sun Microsystems, Inc.
 *
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 * Developed at SunSoft, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice 
 * is preserved.
 *
 * @since 2018/11/02
 */
@ImplementationNote("This code is derived from the Freely " +
	"Distributable Math Library (http://www.netlib.org/fdlibm/). " +
	"Additionally this class is strictfp to keep math consistent.")
public final strictfp class FDMLMath
{
	/** The sign bit value. */
	private static final int _SIGN =
		0x80000000;
	
	/** The zero value. */
	private static final double _ZERO =
		0.0;
	
	/** The one value. */
	private static final double _ONE =
		1.0;
	
	/** The tiniest value. */
	private static final double _TINY =
		1.0e-300;

	/** Ln2 high. */
	private static final double _LN2_HI =
		0x1.62e42feep-1;
	
	/** Ln2 Low. */
	private static final double _LN2_LO =
		0x1.a39ef35793c76p-33;
	
	/** 2^54. */
	private static final double _TWO54 =
		0x1.0p54;
	
	/** log(1). */
	private static final double _LG1 =
		0x1.5555555555593p-1;
	
	/** log(2). */
	private static final double _LG2 =
		0x1.999999997fa04p-2;
	
	/** log(3). */
	private static final double _LG3 =
		0x1.2492494229359p-2;
	
	/** log(4). */
	private static final double _LG4 =
		0x1.c71c51d8e78afp-3;
	
	/** log(5). */
	private static final double _LG5 =
		0x1.7466496cb03dep-3;
	
	/** log(6). */
	private static final double _LG6 =
		0x1.39a09d078c69fp-3;
	
	/** log(7). */
	private static final double _LG7 =
		0x1.2f112df3e5244p-3;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/02
	 */
	private FDMLMath()
	{
	}

	/**
	 * Logarithm of a number.
	 *
	 * @param __v The input value.
	 * @return The resulting logarithm value.
	 * @since 2018/11/02
	 */
	@ImplementationNote("Source http://www.netlib.org/fdlibm/e_log.c")
	public static double log(double __v)
	{
		double hfsq, f, s, z, r, w, t1, t2, dk;
		int k, hx, i, j;
		int uulx;

		// high and low word of __v
		hx = FDMLMath.__hi(__v);
		uulx = FDMLMath.__lo(__v);

		k = 0;
		
		// x < 2**-1022
		if (hx < 0x00100000)
		{
			// log(+-0)=-inf
			if (((hx & 0x7FFFFFFF) | uulx) == 0) 
				return -FDMLMath._TWO54 / FDMLMath._ZERO;
			
			// log(-#) = NaN
			if (hx < 0)
				return (__v - __v) / FDMLMath._ZERO;
			
			// subnormal number, scale up __v
			k -= 54;
			__v *= FDMLMath._TWO54;
			
			// high word of __v
			hx = FDMLMath.__hi(__v);
		} 
		
		if (hx >= 0x7FF00000)
			return __v + __v;
		
		k += (hx >> 20) - 1023;
		hx &= 0x000FFFFF;
		i = (hx + 0x95F64) & 0x100000;
		
		// normalize x or x/2
		// __HI(__v) = hx | (i^0x3FF00000);
		__v = FDMLMath.__compose(hx | (i ^ 0x3FF00000), FDMLMath.__lo(__v));
		k += (i >> 20);
		f = __v - 1.0;
		
		// |f| < 2**-20
		if ((0x000FFFFF & (2 + hx)) < 3)
		{
			if (f == FDMLMath._ZERO)
				if (k == 0)
					return FDMLMath._ZERO;
				else
				{
					dk = (double)k;
					return dk * FDMLMath._LN2_HI + dk * FDMLMath._LN2_LO;
				}
			
			r = f * f * (0.5 - 0.33333333333333333 * f);
			if (k == 0)
				return f - r;
			else
			{
				dk = (double)k;
				return dk * FDMLMath._LN2_HI - ((r - dk * FDMLMath._LN2_LO) - f);
			}
		}
		
		s = f / (2.0 + f); 
		dk = (double)k;
		z = s * s;
		i = hx - 0x6147A;
		w = z * z;
		j = 0x6B851 - hx;
		t1 = w * (FDMLMath._LG2 + w * (FDMLMath._LG4 + w * FDMLMath._LG6));
		t2 = z * (FDMLMath._LG1 + w * (FDMLMath._LG3 + w * (FDMLMath._LG5 + w * FDMLMath._LG7)));
		i |= j;
		r = t2 + t1;
		
		if (i > 0)
		{
			hfsq = 0.5 * f * f;
			if (k == 0)
				return f - (hfsq - s * (hfsq + r));
			else
				return dk * FDMLMath._LN2_HI -
					((hfsq - (s * (hfsq + r) + dk * FDMLMath._LN2_LO)) - f);
		}
		else
		{
			if (k == 0)
				return f - s * (f - r);
			else
				return dk * FDMLMath._LN2_HI - (( s * (f - r) - dk * FDMLMath._LN2_LO) - f);
		}
	}

	/**
	 * Square root of a number.
	 *
	 * @param __v The input value.
	 * @return The resulting square root value.
	 * @since 2018/11/02
	 */
	@ImplementationNote("Source: http://www.netlib.org/fdlibm/e_sqrt.c")
	public static double sqrt(double __v)
	{
		double z;
		int uur, uut1, uus1, uuix1, uuq1;
		int ix0, s0, q, m, t, i;

		// high and low word of __v
		ix0 = FDMLMath.__hi(__v);
		uuix1 = FDMLMath.__lo(__v);

		// Take care of Inf and NaN
		if ((ix0 & 0x7FF00000) == 0x7FF00000)
		{
			// sqrt(NaN)=NaN, sqrt(+inf)=+inf
			// sqrt(-inf)=sNaN
			return __v * __v + __v;
		}
		
		// take care of zero
		if (ix0 <= 0)
		{
			// sqrt(+-0) = +-0
			if (((ix0 & (~FDMLMath._SIGN)) | uuix1) == 0)
				return __v;
			
			// sqrt(-ve) = sNaN
			else if (ix0 < 0)
				return (__v - __v) / (__v - __v);
		}
		
		// normalize
		m = (ix0 >> 20);
		
		// subnormal __v
		if (m == 0)
		{
			while (ix0 == 0)
			{
				m -= 21;
				ix0 |= (uuix1 >>> 11);
				uuix1 <<= 21;
			}
			
			for (i = 0; (ix0 & 0x00100000) == 0; i++)
				ix0 <<= 1;
			
			m -= i - 1;
			ix0 |= (uuix1 >>> (32 - i));
			uuix1 <<= i;
		}
		
		// unbias exponent
		m -= 1023;
		ix0 = (ix0 & 0x000FFFFF) | 0x00100000;
		
		// odd m, double __v to make it even
		if ((m & 1) != 0)
		{
			ix0 += ix0 + ((uuix1 & FDMLMath._SIGN) >>> 31);
			uuix1 += uuix1;
		}
		
		// m = [m/2]
		m >>= 1;

		// generate sqrt(__v) bit by bit
		ix0 += ix0 + ((uuix1 & FDMLMath._SIGN) >>> 31);
		uuix1 += uuix1;
		
		// [q,q1] = sqrt(__v)
		q = uuq1 = s0 = uus1 = 0;
		
		// r = moving bit from right to left
		uur = 0x00200000;
		while (uur != 0)
		{
			t = s0 + uur;
			if (t <= ix0)
			{
				s0 = t + uur;
				ix0 -= t;
				q += uur;
			}
			ix0 += ix0 + ((uuix1 & FDMLMath._SIGN) >>> 31);
			uuix1 += uuix1;
			uur >>>= 1;
		}

		uur = FDMLMath._SIGN;
		while (uur != 0)
		{
			uut1 = uus1 + uur;
			t = s0;
			
			if ((t < ix0) || ((t == ix0) &&
				UnsignedInteger.compareSignedUnsigned(uut1, uuix1) <= 0))
			{
				uus1 = uut1 + uur;
				
				if (((uut1 & FDMLMath._SIGN) == FDMLMath._SIGN) && (uus1 & FDMLMath._SIGN) == 0)
					s0 += 1;
				
				ix0 -= t;
				
				if (UnsignedInteger.compareUnsigned(uuix1, uut1) < 0)
					ix0 -= 1;
				
				uuix1 -= uut1;
				uuq1 += uur;
			}
			
			ix0 += ix0 + ((uuix1 & FDMLMath._SIGN) >>> 31);
			uuix1 += uuix1;
			uur >>>= 1;
		}

		// use floating add to find out rounding direction
		if ((ix0 | uuix1) != 0)
		{
			// trigger inexact flag
			z = FDMLMath._ONE - FDMLMath._TINY;
			
			if (z >= FDMLMath._ONE)
			{
				z = FDMLMath._ONE + FDMLMath._TINY;
				if (uuq1 == 0xFFFFFFFF)
				{
					uuq1 = 0;
					q += 1;
				}
				else if (z > FDMLMath._ONE)
				{
					if (uuq1 == 0xFFFFFFFE)
						q += 1;
					uuq1 += 2;
				}
				else
					uuq1 += (uuq1 & 1);
			}
		}
		
		ix0 = (q >> 1) + 0x3FE00000;
		uuix1 = uuq1 >>> 1;
		
		if ((q & 1) == 1)
			uuix1 |= FDMLMath._SIGN;
		
		ix0 += (m << 20);
		
		return FDMLMath.__compose(ix0, uuix1);
	}
	
	/**
	 * Compose high and low value to double.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2018/11/03
	 */
	private static final double __compose(int __hi, int __lo)
	{
		return Double.longBitsToDouble(
			(((long)__hi & 0xFFFFFFFFL) << 32) |
			((long)__lo & 0xFFFFFFFFL));
	}

	/**
	 * Returns the high word of the double.
	 *
	 * @param __v The input double.
	 * @return The high word of the double.
	 * @since 2018/11/03
	 */
	private static final int __hi(double __v)
	{
		return (int)(Double.doubleToRawLongBits(__v) >>> 32);
	}

	/**
	 * Returns the low word of the double.
	 *
	 * @param __v The input double.
	 * @return The low word of the double.
	 * @since 2018/11/03
	 */
	private static final int __lo(double __v)
	{
		return (int)(Double.doubleToRawLongBits(__v));
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/FloatArrayList.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code float} array.
 *
 * @since 2020/01/01
 */
public class FloatArrayList
	extends AbstractList<Float>
{
	/** The backing array. */
	protected final float[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public FloatArrayList(float[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public FloatArrayList(float[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Float get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public float set(int __i, float __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, Float.valueOf(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Float set(int __i, Float __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		float[] array = this.array;
		float rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/IntegerArray.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This interface represents integer arrays.
 *
 * @since 2018/10/28
 */
public interface IntegerArray
{
	/**
	 * Gets the value at the given index.
	 *
	 * @param __i The index to get.
	 * @return The value at the given index.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2018/10/28
	 */
	int get(int __i);
	
	/**
	 * Sets the value at the given index.
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2018/10/28
	 */
	void set(int __i, int __v);
	
	/**
	 * Returns the size of the array.
	 *
	 * @return The array size.
	 * @since 2018/10/28
	 */
	int size();
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/IntegerArrays.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This class contains utilities used for {@link IntegerArray}.
 *
 * @since 2018/10/28
 */
public final class IntegerArrays
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/28
	 */
	private IntegerArrays()
	{
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(IntegerArray __a, int __from, int __to,
		int __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Empty array, will always be at the 0th index
		int len = __from - __to;
		if (len == 0)
			return -1;
		
		// Array has a single element, so only check that
		else if (len == 1)
		{
			int pv = __a.get(__from);
			
			// Is same
			if (pv == __key)
				return __from;
			
			// Value is either the 0th or 1st element
			if (pv < __key)
				return -1;
			else
				return -2;
		}
		
		// Use the same index
		__to -= 1;
		
		// Search for element at the pivot first, stop if the from and to are
		// at the same points
		while (__from <= __to)
		{
			// Calculate the pivot and use its value
			int p = __from + (((__to - __from) + 1) >> 1),
				pv = __a.get(p);
			
			// Left of pivot?
			if (__key < pv)
				__to = p - 1;
			
			// Right of pivot?
			else if (__key > pv)
				__from = p + 1;
			
			// Match
			else
				return p;
		}
		
		return (-__from) - 1;
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The source array.
	 * @param __to The destination array.
	 * @throws ArrayIndexOutOfBoundsException If the from and/or to index
	 * exceed the array bounds.
	 * @throws IllegalArgumentException If the from index is greater than to
	 * index.
	 * @throws NullPointerException If no array was specified.
	 * @since 2018/10/28
	 */
	public static void sort(IntegerArray __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Pointless sort?
		int n = __to - __from;
		if (n == 0 || n == 1)
			return;
		
		// If only two values are being sorted, it is a simple swap check
		if (n == 2)
		{
			int ia = __from,
				ib = __from + 1;
				
			// Get both values
			int a = __a.get(ia),
				b = __a.get(ib);
			
			// If the second is lower than the first, we need to swap
			if (b < a)
			{
				__a.set(ia, b);
				__a.set(ib, a);
			}
			
			// Nothing else needs to be done
			return;
		}
		
		// Work down from the highest gap to the lowest
		for (int gap : ShellSort._GAPS)
		{
			// Gapped insertion sort
			for (int i = gap; i < n; i++)
			{
				// Use this to make a hole
				int temp = __a.get(__from + i);
				
				// Shift earlier gap elements down
				int j;
				for (j = i; j >= gap &&
						__a.get(__from + (j - gap)) > temp; j -= gap)
					__a.set(__from + j, __a.get(__from + (j - gap)));
				
				// Put in the correct position
				__a.set(__from + j, temp);
			}
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/IntegerIntegerArray.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * Wraps an integer array for access.
 *
 * @since 2018/10/28
 */
public final class IntegerIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final int[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public IntegerIntegerArray(int[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/IteratorToEnumeration.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.runtime.cldc.util;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This adapts an iterator to an enumeration.
 *
 * @param <E> The element type.
 * @since 2019/05/05
 */
public final class IteratorToEnumeration<E>
	implements Enumeration<E>
{
	/** The iterator to access. */
	private final Iterator<E> _it;
	
	/**
	 * Initializes the iterator adapter.
	 *
	 * @param __it The iterator to adapt.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public IteratorToEnumeration(Iterator<E> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this._it = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasMoreElements()
	{
		return this._it.hasNext();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final E nextElement()
		throws NoSuchElementException
	{
		return this._it.next();
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/LongArrayList.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code long} array.
 *
 * @since 2020/01/01
 */
public class LongArrayList
	extends AbstractList<Long>
{
	/** The backing array. */
	protected final long[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public LongArrayList(long[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public LongArrayList(long[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Long get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public long set(int __i, long __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, Long.valueOf(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Long set(int __i, Long __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		long[] array = this.array;
		long rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/NaturalComparator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Comparator;

/**
 * This is used to compare two values using their natural comparison.
 *
 * @since 2016/09/06
 */
public final class NaturalComparator<V>
	implements Comparator<V>
{
	/** The single instance. */
	private static Reference<NaturalComparator> _REF;
	
	/**
	 * Only one is ever needed.
	 *
	 * @since 2017/11/30
	 */
	private NaturalComparator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public int compare(V __a, V __b)
	{
		// Consider two nulls to be equal
		boolean na = (__a == null), nb = (__b == null);
		if (na && nb)
			return 0;
		
		// Nulls before non-null
		else if (na && !nb)
			return -1;
		else if (!na && nb)
			return 1;
		
		// Use standard comparison
		return ((Comparable<V>)__a).compareTo(__b);
	}
	
	/**
	 * Returns the natural comparator instance.
	 *
	 * @param <V> The type of value to compare.
	 * @return The instance of the natural comparator.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public static final <V> NaturalComparator<V> instance()
	{
		Reference<NaturalComparator> ref = NaturalComparator._REF;
		NaturalComparator rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			NaturalComparator._REF = new WeakReference<>((rv = new NaturalComparator()));
		
		// Return it
		return (NaturalComparator<V>)rv;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/ShellSort.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/**
 * Shell sorting algorithm.
 *
 * @since 2019/05/10
 */
public class ShellSort
{
	/** Gaps used in shell sort. */
	static final int[] _GAPS =
		new int[]{701, 301, 132, 57, 23, 10, 4, 1};
	
	/**
	 * Sorts the specified collection.
	 *
	 * @param <T> The type to sort.
	 * @param __a The collection to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __comp The comparator to use.
	 * @throws IndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no collection was specified.
	 * @since 2019/05/09
	 */
	public static final <T> void sort(List<T> __a,
		int __from, int __to, Comparator<? super T> __comp)
		throws IndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Use natural comparator?
		if (__comp == null)
			__comp = NaturalComparator.<T>instance();
		
		// Pointless sort?
		int n = __to - __from;
		if (n == 0 || n == 1)
			return;
		
		// If the list is not random access, then there will be a great
		// penalty sorting it and this may result in quadratic performance loss
		if (!(__a instanceof RandomAccess))
		{
			// Setup duplicate
			List<T> dup = new ArrayList<>(n);
			
			// Copy values using source iterator (less CPU intensive)
			ListIterator<T> it = __a.listIterator(__from);
			for (int o = 0; o < n; o++)
				dup.add(it.next());
			
			// Sort this array
			ShellSort.<T>sort(dup, 0, n, __comp);
			
			// Our iterator should still be good, so we can go backwords
			// setting all the values in it
			for (int i = n - 1; i >= 0; i--)
			{
				it.previous();
				it.set(dup.get(i));
			}
			
			// Stop
			return;
		}
		
		// If only two values are being sorted, it is a simple swap check
		if (n == 2)
		{
			int ia = __from,
				ib = __from + 1;
				
			// Get both values
			T a = __a.get(ia),
				b = __a.get(ib);
			
			// If the second is lower than the first, we need to swap
			if (__comp.compare(b, a) < 0)
			{
				__a.set(ia, b);
				__a.set(ib, a);
			}
			
			// Nothing else needs to be done
			return;
		}
		
		// Work down from the highest gap to the lowest
		for (int gap : ShellSort._GAPS)
		{
			// Gapped insertion sort
			for (int i = gap; i < n; i++)
			{
				// Use this to make a hole
				T temp = __a.get(__from + i);
				
				// Shift earlier gap elements down
				int j;
				for (j = i; j >= gap && __comp.compare(
					__a.get(__from + (j - gap)), temp) > 0; j -= gap)
					__a.set(__from + j, __a.get(__from + (j - gap)));
				
				// Put in the correct position
				__a.set(__from + j, temp);
			}
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/ShortIntegerArray.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
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

/**
 * Wraps a short array to provide integer access to it.
 *
 * @since 2019/05/09
 */
public final class ShortIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final short[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public ShortIntegerArray(short[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (short)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * This is an entry set which is synchronized against a lock.
 *
 * @param <K> The entry keys.
 * @param <V> The entry values.
 * @since 2019/05/05
 */
public final class SynchronizedEntrySet<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<Map.Entry<K, V>> set;
	
	/**
	 * Initializes the synchronized entry set.
	 *
	 * @param __lock The locking object.
	 * @param __set The entry set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySet(Object __lock, Set<Map.Entry<K, V>> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<Map.Entry<K, V>> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedEntrySetIterator<K, V>(
				lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetIterator.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This is a synchronized iterator over entry set iterators.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public class SynchronizedEntrySetIterator<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<Map.Entry<K, V>> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetIterator(Object __lock,
		Iterator<Map.Entry<K, V>> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Map.Entry<K, V> next()
		throws NoSuchElementException
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedMapEntry<K, V>(lock, this.iterator.next());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetIteratorNotNull.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This is a synchronized iterator over entry set iterators, null values are
 * not permitted.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public class SynchronizedEntrySetIteratorNotNull<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<Map.Entry<K, V>> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetIteratorNotNull(Object __lock,
		Iterator<Map.Entry<K, V>> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Map.Entry<K, V> next()
		throws NoSuchElementException
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedMapEntryNotNull<K, V>(lock,
				this.iterator.next());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetNotNull.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * This is an entry set which is synchronized against a lock, null values
 * are not allowed.
 *
 * @param <K> The entry keys.
 * @param <V> The entry values.
 * @since 2019/05/05
 */
public final class SynchronizedEntrySetNotNull<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<Map.Entry<K, V>> set;
	
	/**
	 * Initializes the synchronized entry set.
	 *
	 * @param __lock The locking object.
	 * @param __set The entry set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetNotNull(Object __lock,
		Set<Map.Entry<K, V>> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<Map.Entry<K, V>> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedEntrySetIteratorNotNull<K, V>(
				lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedIterator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator which locks on an object before accesses are made.
 *
 * @param <V> The type of values to iterate over.
 * @since 2019/05/05
 */
public final class SynchronizedIterator<V>
	implements Iterator<V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<V> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedIterator(Object __lock, Iterator<V> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V next()
		throws NoSuchElementException
	{
		synchronized (this.lock)
		{
			return this.iterator.next();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedMapEntry.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.Map;

/**
 * This is a synchronized map entry.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public final class SynchronizedMapEntry<K, V>
	implements Map.Entry<K, V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing entry. */
	protected final Map.Entry<K, V> entry;
	
	/**
	 * Initializes the synchronized entry.
	 *
	 * @param __lock The locking object.
	 * @param __ent The entry object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedMapEntry(Object __lock, Map.Entry<K, V> __ent)
		throws NullPointerException
	{
		if (__lock == null || __ent == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.entry = __ent;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		synchronized (this.lock)
		{
			return this.entry.equals(__o);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final K getKey()
	{
		synchronized (this.lock)
		{
			return this.entry.getKey();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V getValue()
	{
		synchronized (this.lock)
		{
			return this.entry.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int hashCode()
	{
		synchronized (this.lock)
		{
			return this.entry.hashCode();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V setValue(V __v)
	{
		synchronized (this.lock)
		{
			return this.entry.setValue(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final String toString()
	{
		synchronized (this.lock)
		{
			return this.entry.toString();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedMapEntryNotNull.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.Map;

/**
 * This is a synchronized map entry, null values are not permitted.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public final class SynchronizedMapEntryNotNull<K, V>
	implements Map.Entry<K, V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing entry. */
	protected final Map.Entry<K, V> entry;
	
	/**
	 * Initializes the synchronized entry.
	 *
	 * @param __lock The locking object.
	 * @param __ent The entry object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedMapEntryNotNull(Object __lock, Map.Entry<K, V> __ent)
		throws NullPointerException
	{
		if (__lock == null || __ent == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.entry = __ent;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		synchronized (this.lock)
		{
			return this.entry.equals(__o);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final K getKey()
	{
		synchronized (this.lock)
		{
			return this.entry.getKey();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V getValue()
	{
		synchronized (this.lock)
		{
			return this.entry.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int hashCode()
	{
		synchronized (this.lock)
		{
			return this.entry.hashCode();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If this value is null.
	 * @since 2019/05/05
	 */
	@Override
	public final V setValue(V __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this.lock)
		{
			return this.entry.setValue(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final String toString()
	{
		synchronized (this.lock)
		{
			return this.entry.toString();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/SynchronizedSet.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which is synchronized against a lock.
 *
 * @param <V> The set value.
 * @since 2019/05/05
 */
public final class SynchronizedSet<V>
	extends AbstractSet<V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<V> set;
	
	/**
	 * Initializes the synchronized set.
	 *
	 * @param __lock The locking object.
	 * @param __set The set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedSet(Object __lock, Set<V> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<V> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedIterator<V>(lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/UnsignedInteger.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This class manages a boxed like representation of unsigned integers.
 *
 * @since 2018/11/03
 */
public final class UnsignedInteger
	extends Number
	implements Comparable<UnsignedInteger>
{
	/** The stored value. */
	protected final int value;
	
	/**
	 * Initializes the unsigned integer.
	 *
	 * @param __v The value to use.
	 * @since 2018/11/03
	 */
	public UnsignedInteger(int __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int compareTo(UnsignedInteger __i)
	{
		return UnsignedInteger.compareUnsigned(this.value, __i.value);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final long longValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Compares two signed values.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareSigned(int __a, int __b)
	{
		if (__a == __b)
			return 0;
		else if (__a < __b)
			return -1;
		else
			return 1;
	}
	
	/**
	 * Compares a signed and unsigned value.
	 *
	 * @param __a The first value.
	 * @param __ub The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareSignedUnsigned(int __a, int __ub)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Compares two unsigned values.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareUnsigned(int __a, int __b)
	{
		// Quick shortcut if they are the same number
		if (__a == __b)
			return 0;
		
		// Check if there is a sign bit
		boolean na = ((__a & 0x8000_0000) != 0),
			nb = ((__b & 0x8000_0000) != 0);
		
		// Comparison is the same as signed integers if the sign is the same
		// 0x80000000 == -2147483648
		// 0xFFFFFFFF == -1
		if (na == nb)
			return UnsignedInteger.compareSigned(__a, __b);
		
		// Only A has sign bit, it is always greater
		else if (na && !nb)
			return 1;
		
		// Only B has sign bit, it is always lesser
		else
			return -1;
	}
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/util/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Utilities which could be reused, primarily used by {@link java.util}.
 *
 * @since 2018/10/28
 */

package cc.squirreljme.runtime.cldc.util;

Added modules/cldc-compact/src/main/java/java/io/BufferedReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

/**
 * This is a reader which is backed by a buffer which should increase the
 * efficiency of read operations by allowing for bulk reads for easily.
 *
 * It is recommended to wrap these around {@link InputStreamReader} for
 * example due to that class not being efficient due to character conversions.
 *
 * @since 2018/11/22
 */
@ImplementationNote("This implementation uses a simple flat buffer with a " +
	"length and size.")
public class BufferedReader
	extends Reader
{
	/** Default buffer size. */
	private static final int _DEFAULT_SIZE =
		128;
	
	/** The buffer to source from. */
	private final Reader _in;
	
	/** The buffer, this is a linear buffer, null for close(). */
	private char[] _buf;
	
	/** The buffer limit. */
	private int _limit;
	
	/** The read position of the buffer (which one to read next). */
	private int _rp;
	
	/** The write position of the buffer (the valid characters). */
	private int _wp;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __r The reader to source from.
	 * @param __bs The size of the internal buffer.
	 * @throws IllegalArgumentException If the buffer size is zero or
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public BufferedReader(Reader __r, int __bs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0g Cannot have a zero or negative buffer
		// size.}
		if (__bs <= 0)
			throw new IllegalArgumentException("ZZ0g");
		
		this._in = __r;
		this._buf = new char[__bs];
		this._limit = __bs;
	}
	
	/**
	 * Initializes the buffer using a default buffer size.
	 *
	 * @param __r The reader to source from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public BufferedReader(Reader __r)
		throws NullPointerException
	{
		this(__r, BufferedReader._DEFAULT_SIZE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void close()
		throws IOException
	{
		// The buffer not existing indicates this is closed
		char[] buf = this._buf;
		if (buf != null)
			this._buf = null;
		
		// Close the underlying stream
		this._in.close();
	}
	
	@Override
	@ProgrammerTip("If the mark length is greater than the length of the " +
	 "internal buffer, it will be re-allocated to fit. Care must be taken " +
	 "depending on how large of a buffer is needed to be stored.")
	public void mark(int __l)
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public boolean markSupported()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read()
		throws IOException
	{
		// Has this been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// There are no characters in the buffer? Fill it
		int rp = this._rp;
		if (rp == this._wp)
		{
			// Read up to the limit
			int rc = this._in.read(buf, 0, this._limit);
			
			// EOF reached
			if (rc < 0)
				return -1;
			
			// Set new properties
			rp = 0;
			this._wp = rc;
		}
		
		// Read and return the next character
		int rv = buf[rp++];
		this._rp = rp;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read(char[] __c)
		throws IOException, NullPointerException
	{
		return this.read(__c, 0, __c.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLOS");
		
		// Number of characters read
		int rv = 0;
		int rp = this._rp,
			wp = this._wp;
		
		// Drain what remains of the buffer
		int left = wp - rp;
		if (left > 0)
		{
			int lim = (left < __l ? left : __l);
			
			for (; rv < lim; rv++)
				__c[__o++] = buf[rp++];
			
			// Invalidate the buffer
			if (rp == wp)
			{
				this._rp = 0;
				this._wp = 0;
			}
		}
		
		// Nothing was in the buffer, so read directly from the source
		// stream
		Reader in = this._in;
		while (rv < __l)
		{
			int rc = in.read();
			
			// EOF
			if (rc < 0)
				return (rv == 0 ? -1 : rv);
			
			// Add character
			__c[__o++] = (char)rc;
			rv++;
		}
		
		// Return the read count
		return rv;
	}
	
	/**
	 * Reads a line from the input and returns it.
	 *
	 * @return The line which was read, or {@code null} on EOF.
	 * @throws IOException On read errors.
	 * @since 2018/11/22
	 */
	public String readLine()
		throws IOException
	{
		// Has this been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// Read/write positions
		int rp = this._rp,
			wp = this._wp;
		
		// The line is potentially what is left in the buffer perhaps
		// But do not make a super tiny string builder, make a guess as to
		// what the average line length is.
		int diff = wp - rp;
		StringBuilder sb = new StringBuilder((diff > 64 ? diff : 64));
		
		// Continually read data
		Reader in = this._in;
		boolean wasinbuf = false;
		for (;;)
		{
			// Was newline read? Did we stop on a CR?
			boolean readnl = false,
				stoppedoncr = false,
				readeof = false;
			
			// Scan
			int ln = rp;
			if (ln < wp)
			{
				// Was something in the buffer?
				wasinbuf = true;
				
				while (ln < wp)
				{
					// Stop on end of line characters
					char c = buf[ln];
					if ((stoppedoncr = (c == '\r')) || c == '\n')
					{
						readnl = true;
						break;
					}
					
					// Keep going
					ln++;
				}
				
				// Append all the characters in this buffer
				sb.append(buf, rp, ln - rp);
				
				// Discard everything which was appended
				this._rp = (rp = ln);
			}
			
			// Ran out of characters to use?
			if (rp == wp)
			{
				// Read in new characters to the buffer
				int rc = in.read(buf, 0, this._limit);
				
				// EOF was reached, if the buffer was empty then nothing was
				// read anyway
				if (rc < 0)
				{
					// True EOF
					if (!wasinbuf && sb.length() == 0)
						return null;
					
					readeof = true;
				}
				
				// Set new properties
				this._rp = (rp = ln = 0);
				this._wp = (wp = (rc > 0 ? rc : 0));
			}
			
			// Eat newline?
			if (readnl)
			{
				// We stopped on a CR, need to check if the following character
				// is a newline. However since the CRLF pair can end on a
				// buffer read barrier, it must be checked to make sure
				// there is absolutely no connection still.
				if (stoppedoncr)
				{
					// There are characters left in the buffer
					int gap = ln + 1;
					if (gap < wp)
					{
						// Is a newline, so skip it
						if (buf[gap] == '\n')
							rp = ln + 2;
						
						// Otherwise do not
						else
							rp = ln + 1;
					}
					
					// Need to actually read a character, to see what it
					// is
					else
					{
						int rx = in.read();
						
						// If the character is not a newline and is not EOF
						// we will just place it in the buffer as if it
						// were a fresh buffer
						if (rx >= 0 && rx != '\n')
						{
							// Store character state
							buf[wp++] = (char)rx;
							this._rp = rp;
							this._wp = wp;
							
							// Do not do any more of our loop stuff
							break;
						}
						
						// We will be skipping a character in the buffer
						// anyway so ln == wp, so always just skip one
						rp = ln + 1;
					}
				}
				
				// Skip single character
				else
					rp = ln + 1;
				
				// Store the new read position
				this._rp = rp;
				
				// Stop
				break;
			}
			
			// Nothing else to do on EOF
			if (readeof)
				break;
		}
		
		// Use this line
		return sb.toString();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public boolean ready()
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// There are characters in the buffer or the stream itself is
		// ready
		return (this._rp < this._wp) || this._in.ready();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void reset()
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLOS");
		
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

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

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This class buffers characters into an internal buffer so that they can be
 * written in bulk to the underlying stream. This increases performance and
 * is a more optimal operation because it writes multiple characters at once
 * instead of writing them one at a time.
 *
 * The default buffer size in SquirrelJME is very small due to potential memory
 * limitations.
 *
 * @since 2018/09/18
 */
@ImplementationNote("The buffer size is undefined in the class library, " +
	"therefor due to potential memory limitations the buffer size should " +
	"be kept small.")
public class BufferedWriter
	extends Writer
{
	/**
	 * This buffer size is kept small by default since having a large buffer
	 * for a memory contrained system is not really that important and will
	 * pretty much only be used by console output. So as such to prevent
	 * wasting memory with streams that will not likely be used for most
	 * programs (MIDlets) or they will be outputting characters anyway.
	 *
	 * It should be noted that Java SE uses a buffer size of 8KiB.
	 */
	private static final int _DEFAULT_BUFFER_SIZE =
		128;
	
	/** The writer to buffer at. */
	private final Writer _out;
	
	/**
	 * Initializes the buffered writer to the target writer using the default
	 * buffer size.
	 *
	 * @param __out The writer to buffer to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public BufferedWriter(Writer __out)
		throws NullPointerException
	{
		this(__out, BufferedWriter._DEFAULT_BUFFER_SIZE);
	}
	
	/**
	 * Initializes the buffered writer to the target writer using the given
	 * buffer size.
	 *
	 * @param __out The writer to buffer to.
	 * @param __bs The number of characters to store in the buffer before
	 * flushing.
	 * @throws IllegalArgumentException If the buffer size is less than or
	 * equal to zero.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public BufferedWriter(Writer __out, int __bs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0h Requested a buffer size that is zero or
		// negative. (The requested buffer size)}
		if (__bs <= 0)
			throw new IllegalArgumentException(String.format("ZZ0h %d", __bs));
		
		throw new todo.TODO();
	}
	
	/**
	 * Closes the stream, it is flushed first.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/09/18
	 */
	@Override
	public void close()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void flush()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Writes the value of {@code System.getProperty("line.separator")} to the
	 * stream.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/09/18
	 */
	public void newLine()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * This normally stores characters into the internal buffer, however if
	 * the length of the output is at least the size of the buffer then it
	 * will flush the buffer then write all the input characters.
	 *
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(char[] __b, int __o, int __l)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(String __s, int __o, int __l)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/io/ByteArrayInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is a class which reads from an input byte array and returns its data.
 *
 * @since 2018/11/11
 */
public class ByteArrayInputStream
	extends InputStream
{
	/** The buffer to read from. */
	protected byte[] buf;
	
	/** The number of bytes to read. */
	protected int count;
	
	/** The current mark. */
	protected int mark;
	
	/** The position within the byte array. */
	protected int pos;
	
	/**
	 * Wraps the specified byte array.
	 *
	 * @param __b The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ByteArrayInputStream(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length);
	}
	
	/**
	 * Wraps the specified byte array.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ByteArrayInputStream(byte[] __b, int __o, int __l)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		this.buf = __b;
		this.pos = __o;
		this.mark = __o;
		this.count = Math.min(__o + __l, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int available()
	{
		synchronized (this)
		{
			return Math.max(0, this.count - Math.max(0, this.pos));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void close()
		throws IOException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void mark(int __p)
	{
		synchronized (this)
		{
			this.mark = this.pos;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public boolean markSupported()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read()
	{
		synchronized (this)
		{
			int pos = this.pos,
				count = this.count;
			
			// EOF?
			if (pos >= count)
				return -1;
			
			// Read single byte
			int rv = this.buf[pos] & 0xFF;
			this.pos = pos + 1;
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public int read(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Only read this many bytes
		int len = __b.length;
		
		synchronized (this)
		{
			// Determine how many bytes we can read
			byte[] buf = this.buf;
			int pos = this.pos,
				count = this.count,
				read = count - pos;
			
			// Do not exceed this
			if (len < read)
				read = len;
			
			// Copy bytes
			for (int i = 0; i < len; i++)
				__b[i] = buf[pos++];
			
			// Store new position
			this.pos = pos;
			
			if (read == 0)
				return (pos >= count ? -1 : 0);
			return read;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			// Determine how many bytes we can read
			byte[] buf = this.buf;
			int pos = this.pos,
				count = this.count,
				read = count - pos;
			
			// Do not exceed this
			if (__l < read)
				read = __l;
			
			// Copy bytes
			for (int i = 0; i < read; i++)
				__b[__o++] = buf[pos++];
			
			// Store new position
			this.pos = pos;
			
			if (read == 0)
				return (pos >= count ? -1 : 0);
			return read;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void reset()
	{
		synchronized (this)
		{
			this.pos = this.mark;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public long skip(long __n)
	{
		// Doing nothing?
		if (__n <= 0)
			return 0;
		
		synchronized (this)
		{
			int pos = this.pos,
				count = this.count,
				read = count - pos,
				newpos;
			
			// Reading less bytes than what is available
			if (__n < read)
				this.pos = (newpos = (int)(pos + __n));
			
			// No more bytes to read
			else
				this.pos = (newpos = count);
			
			return newpos - pos;
		}
	}
}

Added modules/cldc-compact/src/main/java/java/io/ByteArrayOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import java.util.Arrays;

/**
 * This an output stream which outputs any written bytes to a byte array.
 *
 * @since 2018/11/06
 */
public class ByteArrayOutputStream
	extends OutputStream
{
	/** The initial capacity. */
	private static final int _CAPACITY =
		32;
	
	/** The bytes in the buffer. */
	protected byte[] buf;
	
	/** The number of valid bytes in the buffer. */
	protected int count;
	
	/**
	 * Initializes the output stream using the default capacity of 32 bytes.
	 *
	 * @since 2018/11/06
	 */
	public ByteArrayOutputStream()
	{
		this(ByteArrayOutputStream._CAPACITY);
	}
	
	/**
	 * Initializes the output stream using the given capacity.
	 *
	 * @param __cap The capacity to use.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/06
	 */
	public ByteArrayOutputStream(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ0i Cannot initialize output stream using a
		// negative capacity.}
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ0i");
		
		this.buf = new byte[__cap];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void close()
		throws IOException
	{
	}
	
	/**
	 * Resets the count back to zero while keeping the buffer, allowing it
	 * to be reused.
	 *
	 * @since 2018/11/06
	 */
	public void reset()
	{
		synchronized (this)
		{
			this.count = 0;
		}
	}
	
	/**
	 * Returns the number of bytes that are valid in the internal buffer.
	 *
	 * @return The number of bytes that are valid in the internal buffer.
	 * @since 2018/11/06
	 */
	public int size()
	{
		synchronized (this)
		{
			return this.count;
		}
	}
	
	/**
	 * Returns a newly allocated copy of the byte array.
	 *
	 * @return A copy of the byte array.
	 * @since 2018/11/06
	 */
	public byte[] toByteArray()
	{
		synchronized (this)
		{
			return Arrays.copyOf(this.buf, this.count);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public String toString()
	{
		synchronized (this)
		{
			return new String(this.buf, 0, this.count);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void write(int __b)
	{
		byte[] buf = this.buf;
		int count = this.count;
		
		synchronized (this)
		{
			// Not enough room? Increase buffer size
			if (count == buf.length)
				this.buf = (buf = Arrays.copyOf(buf, count + ByteArrayOutputStream._CAPACITY));
			
			// Write byte at end position
			buf[count] = (byte)__b;
			this.count = count + 1;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		int bufn = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bufn)
			throw new IndexOutOfBoundsException("IOOB");
		
		byte[] buf = this.buf;
		int count = this.count;
		
		synchronized (this)
		{
			// Reallocate buffer if it cannot be store data
			int endcount = count + __l;
			if (endcount > buf.length)
				this.buf = (buf = Arrays.copyOf(buf, endcount + ByteArrayOutputStream._CAPACITY));
			
			// Write bytes
			for (int i = 0; i < __l; i++)
				buf[count++] = __b[__o++];
			
			this.count = endcount;
		}
	}
	
	/**
	 * Writes the internal buffer to the given output stream.
	 *
	 * @param __os The output stream to write to.
	 * @throws IOException On write.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			__os.write(this.buf, 0, this.count);
		}
	}
}

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

package java.io;

/**
 * This is attached to a resource which may be closed when it is no longer
 * required.
 *
 * Note that despite being similar to {@link AutoCloseable} there is a subtle
 * difference in that this class must never throw an {@link IOException} if the
 * resource is already closed and must have no effect.
 *
 * @since 2016/04/12
 */
public interface Closeable
	extends AutoCloseable
{
	/**
	 * Attempts to close the resource which may free other resources.
	 *
	 * Unlike {@link AutoCloseable}, if the resource is already closed then
	 * this method should have no effect and not throw a {@link IOException}.
	 *
	 * If it is possible, it is recommended to mark a resource as closed after
	 * freeing the resources before throwing an {@link IOException}. However,
	 * this case should only be considered if this is a top level resource
	 * which relies on no other {@link Closeable} resources.
	 *
	 * @throws IOException If there was an error closing this resource.
	 * @since 2016/04/12
	 */
	@Override
	void close()
		throws IOException;
}

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

package java.io;

public interface DataInput
{
	boolean readBoolean()
		throws IOException;
	
	byte readByte()
		throws IOException;
	
	char readChar()
		throws IOException;
	
	double readDouble()
		throws IOException;
	
	float readFloat()
		throws IOException;
	
	void readFully(byte[] __a)
		throws IOException;
	
	void readFully(byte[] __a, int __b, int __c)
		throws IOException;
	
	int readInt()
		throws IOException;
	
	long readLong()
		throws IOException;
	
	short readShort()
		throws IOException;
	
	String readUTF()
		throws IOException;
	
	int readUnsignedByte()
		throws IOException;
	
	int readUnsignedShort()
		throws IOException;
	
	int skipBytes(int __a)
		throws IOException;
}

Added modules/cldc-compact/src/main/java/java/io/DataInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This class provides the ability to read binary data from a stream.
 *
 * All data which is read, is stored as big endian.
 *
 * @since 2018/12/01
 */
public class DataInputStream
	extends InputStream
	implements DataInput
{
	/** The wrapped stream. */
	protected final InputStream in;	
	
	/**
	 * Wraps the specified stream.
	 *
	 * @param __in The stream to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public DataInputStream(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException();
		
		// Set
		this.in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public void mark(int __rl)
	{
		this.in.mark(__rl);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public boolean markSupported()
	{
		return this.in.markSupported();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.in.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.in.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		return this.in.read(__b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final boolean readBoolean()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return (rv != 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final byte readByte()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return (byte)rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final char readChar()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (char)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	@Override
	public final double readDouble()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read(),
			e = in.read(),
			f = in.read(),
			g = in.read(),
			h = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d | e | f | g | h) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return Double.longBitsToDouble((((long)(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF))) << 32L) |
			(((long)((((e & 0xFF) << 24) |
			((f & 0xFF) << 16) |
			((g & 0xFF) << 8) |
			(h & 0xFF)))) & 0xFFFFFFFFL));
	}
	
	@Override
	public final float readFloat()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return Float.intBitsToFloat(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 3018/12/01
	 */
	@Override
	public final void readFully(byte[] __b)
		throws EOFException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		int rv = 0,
			bl = __b.length;
		
		// Constantly read in as many chunks as possible
		InputStream in = this.in;
		while (rv < bl)
		{
			// Read entire chunk
			int rc = in.read(__b, rv, bl - rv);
			
			// Reached EOF
			if (rc < 0)
				throw new EOFException("EOFF");
			
			// These many characters were read, we might try again
			rv += rc;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void readFully(byte[] __b, int __o, int __l)
		throws EOFException, IOException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		int rv = 0;
		
		// Constantly read in as many chunks as possible
		InputStream in = this.in;
		while (rv < __l)
		{
			// Read entire chunk
			int rc = in.read(__b, __o + rv, __l - rv);
			
			// Reached EOF
			if (rc < 0)
				throw new EOFException("EOFF");
			
			// These many characters were read, we might try again
			rv += rc;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readInt()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return ((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public final long readLong()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read(),
			e = in.read(),
			f = in.read(),
			g = in.read(),
			h = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d | e | f | g | h) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return ((((long)(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF))) << 32L) |
			(((long)(((e & 0xFF) << 24) |
			((f & 0xFF) << 16) |
			((g & 0xFF) << 8) |
			(h & 0xFF))) & 0xFFFFFFFFL));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final short readShort()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (short)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readUnsignedByte()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return rv & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readUnsignedShort()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (int)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final String readUTF()
		throws EOFException, IOException, UTFDataFormatException
	{
		return DataInputStream.readUTF(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public void reset()
		throws IOException
	{
		this.in.reset();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public long skip(long __n)
		throws IOException
	{
		if (__n < 0)
			return 0;
		
		return this.in.skip(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int skipBytes(int __n)
		throws IOException
	{
		// Try to read as many bytes as possible
		InputStream in = this.in;
		for (int i = 0; i < __n; i++)
			if (in.read() < 0)
				return i;
		
		// Read all the bytes
		return __n;
	}
	
	/**
	 * Reads a modified-UTF sequence from the input.
	 *
	 * @param __in The input.
	 * @return The decoded string.
	 * @throws EOFException On end of file.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @throws UTFDataFormatException If the input UTF data is not correct.
	 * @since 2018/12/03
	 */
	public static final String readUTF(DataInput __in)
		throws EOFException, IOException, NullPointerException,
			UTFDataFormatException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read length and setup buffer
		int len = __in.readUnsignedShort();
		char[] buf = new char[len];
		
		// Instead of calling read multiple times to get multiple bytes we
		// can just do a full read of the entire length. If the queue only
		// contains single byte characters then we end up in the fast route
		// otherwise once the queue is finished, we will start reading from
		// the stream
		byte[] queue = new byte[len];
		int queueat = 0;
		if (len > 0)
			__in.readFully(queue);
		
		// Read all encoded character data, if EOF ever happens it will be
		// generated for us
		for (int i = 0; i < len; i++)
		{
			// Read character
			int a = (queueat < len ? (queue[queueat++] & 0xFF) :
				__in.readUnsignedByte());
			
			// Single byte
			if ((a & 0b1000_0000) == 0b0000_0000)
			{
				// {@squirreljme.error ZZ0j The zero byte cannot be represented
				// with a zero value.}
				if (a == 0)
					throw new UTFDataFormatException("ZZ0j");
				
				buf[i] = (char)a;
			}
			
			// Double byte
			else if ((a & 0b1110_0000) == 0b1100_0000)
			{
				int b = (queueat < len ? (queue[queueat++] & 0xFF) :
					__in.readUnsignedByte());
				
				// {@squirreljme.error ZZ0k Invalid double byte character.
				// (The byte sequence)}
				if ((b & 0b1100_0000) != 0b1000_0000)
					throw new UTFDataFormatException(String.format(
						"ZZ0k %02x%02x", a, b));
				
				// Decode
				buf[i] = (char)(((a & 0x1F) << 6) | (b & 0x3F));
			}
			
			// Triple byte
			else if ((a & 0b1111_0000) == 0b1110_0000)
			{
				// Can we quickly read at least one byte from the stream?
				int b, c;
				if (queueat < len)
				{
					b = queue[queueat++] & 0xFF;
					c = (queueat < len ? (queue[queueat++] & 0xFF) :
						__in.readUnsignedByte());
				}
				
				// Nothing
				else
				{
					b = __in.readUnsignedByte();
					c = __in.readUnsignedByte();
				}
				
				// {@squirreljme.error ZZ0l Invalid double byte character.
				// (The byte sequence)}
				if (((b & 0b1100_0000) != 0b1000_0000) ||
					((c & 0b1100_0000) != 0b1000_0000))
					throw new UTFDataFormatException(String.format(
						"ZZ0l %02x%02x%02x", a, b, c));
				
				// Decode
				buf[i] = (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) |
					(c & 0x3F));
			}
			
			// {@squirreljme.error ZZ0m Invalid byte sequence. (The byte)}
			else
				throw new UTFDataFormatException(String.format("ZZ0m %02x",
					a));
		}
		
		// Convert to string
		return new String(buf);
	}
}

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

package java.io;

public interface DataOutput
{
	void write(int __b)
		throws IOException;
	
	void write(byte[] __b)
		throws IOException, NullPointerException;
	
	void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException;
	
	void writeBoolean(boolean __v)
		throws IOException;
	
	void writeByte(int __v)
		throws IOException;
	
	void writeBytes(String __v)
		throws IOException, NullPointerException;
	
	void writeChar(int __v)
		throws IOException;
	
	void writeChars(String __v)
		throws IOException, NullPointerException;
	
	void writeDouble(double __v)
		throws IOException;
	
	void writeFloat(float __v)
		throws IOException;
	
	void writeInt(int __v)
		throws IOException;
	
	void writeLong(long __v)
		throws IOException;
	
	void writeShort(int __v)
		throws IOException;
	
	void writeUTF(String __v)
		throws IOException;
}

Added modules/cldc-compact/src/main/java/java/io/DataOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This stream is capable of writing binary data to an output stream.
 *
 * @since 2018/11/18
 */
public class DataOutputStream
	extends OutputStream
	implements DataOutput
{
	/** The underlying stream to write to. */
	protected OutputStream out;
	
	/** The number of bytes written. */
	protected int written;
	
	/**
	 * Initializes the stream to write to the given destination.
	 *
	 * @param __o The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public DataOutputStream(OutputStream __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		this.out = __o;
	}
	
	@Override
	public void close()
		throws IOException
	{
		this.out.close();
	}
	
	@Override
	public void flush()
		throws IOException
	{
		this.out.flush();
	}
	
	/**
	 * Returns the current number of bytes which were written.
	 *
	 * @return The number of bytes which were written.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this.written;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(byte[] __b)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b, __o, __l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeBoolean(boolean __v)
		throws IOException
	{
		this.out.write((__v ? 1 : 0));
		this.written += 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeByte(int __v)
		throws IOException
	{
		this.out.write(__v);
		this.written += 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeBytes(String __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeChar(int __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeChars(String __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeDouble(double __v)
		throws IOException
	{
		long v = Double.doubleToRawLongBits(__v);
		
		OutputStream out = this.out;
		out.write((int)(v >> 56));
		out.write((int)(v >> 48));
		out.write((int)(v >> 40));
		out.write((int)(v >> 32));
		out.write((int)(v >> 24));
		out.write((int)(v >> 16));
		out.write((int)(v >> 8));
		out.write((int)(v));
		this.written += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeFloat(float __v)
		throws IOException
	{
		int v = Float.floatToRawIntBits(__v);
		
		OutputStream out = this.out;
		out.write(v >> 24);
		out.write(v >> 16);
		out.write(v >> 8);
		out.write(v);
		this.written += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeInt(int __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write(__v >> 24);
		out.write(__v >> 16);
		out.write(__v >> 8);
		out.write(__v);
		this.written += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeLong(long __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write((int)(__v >> 56));
		out.write((int)(__v >> 48));
		out.write((int)(__v >> 40));
		out.write((int)(__v >> 32));
		out.write((int)(__v >> 24));
		out.write((int)(__v >> 16));
		out.write((int)(__v >> 8));
		out.write((int)(__v));
		this.written += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeShort(int __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write(__v >> 8);
		out.write(__v);
		this.written += 2;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeUTF(String __v)
		throws IOException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		OutputStream out = this.out;
		
		// Write length of string
		int n = __v.length();
		out.write(n >> 8);
		out.write(n);
		
		// Load string into character array to more quickly access it
		char[] chars = __v.toCharArray();
		
		// Write string contents in modified UTF-8
		int written = 2;
		for (int i = 0; i < n; i++)
		{
			char c = chars[i];
			
			// Single byte
			if (c >= 0x0001 && c <= 0x007F)
			{
				// As a sort of turbo mode, scan the string to see how many
				// single characters we can write all at once instead of
				// writing call so many times. Since most of the time these
				// single characters will be ones which are read
				int end = i + 1;
				for (; end < n; end++)
				{
					char d = chars[end];
					if (d == 0 || c > 0x007F)
						break;
				}
				
				// Just a single byte
				if (end == i)
				{
					out.write((byte)c);
					
					written += 1;
				}
				
				// Multiple bytes were so, convert and write in bulk
				else
				{
					int xl = end - i;
					
					// Convert to bytes
					byte[] chunk = new byte[xl];
					for (int o = 0; o < xl; o++, i++)
						chunk[o] = (byte)chars[i];
					
					// Write all at once
					out.write(chunk, 0, xl);
					
					written += xl;
				}
			}
			
			// Double byte
			// as: (char)(((a & 0x1F) << 6) | (b & 0x3F))
			else if (c == 0 || (c >= 0x0080 && c <= 0x07FF))
			{
				out.write(0b110_00000 | ((c >>> 6) & 0x1F));
				out.write(0b10_000000 | (c & 0x3F));
				
				written += 2;
			}
			
			// Triple byte
			// as: (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
			else
			{
				out.write(0b1110_0000 | ((c >>> 12) & 0x0F));
				out.write(0b10_000000 | ((c >>> 6) & 0x3F));
				out.write(0b10_000000 | (c & 0x3F));
				
				written += 3;
			}
		}
		
		// Record it
		this.written += written;
	}
}

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

package java.io;

/**
 * This thrown when the end of file has been reached.
 *
 * @since 2018/12/08
 */
public class EOFException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public EOFException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public EOFException(String __m)
	{
		super(__m);
	}
}

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

package java.io;

/**
 * This is thrown when there is a general input and/or output exception.
 *
 * @since 2018/12/08
 */
public class IOException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public IOException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public IOException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/08
	 */
	public IOException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/08
	 */
	public IOException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/java/io/InputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

/**
 * This is the base class for any input stream which is used for reading a
 * stream of bytes.
 *
 * @since 2019/01/20
 */
public abstract class InputStream
	implements Closeable
{
	/** The number of bytes to skip at a time. */
	private static final int _SKIP_LEN =
		256;
	
	/**
	 * Reads a single byte from the input stream.
	 *
	 * @return The read unsigned byte value ({@code 0-255}) or {@code -1} if
	 * the end of stream has been reached.
	 * @throws IOException On read errors.
	 * @since 2018/11/06
	 */
	public abstract int read()
		throws IOException;
	
	/**
	 * Returns the number of bytes which can be read from the stream without
	 * blocking.
	 *
	 * @return The number of bytes which can be read.
	 * @throws IOException On read errors.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation always returns 0.")
	public int available()
		throws IOException
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public void close()
		throws IOException
	{
	}
	
	/**
	 * Marks the stream so that a future {@link #reset()} returns to the point
	 * that was marked, if it is still within the bounds of the read limit.
	 *
	 * After the limit has been reached, the mark may become invalidated.
	 *
	 * @param __l The number of bytes to store for later resets before the
	 * mark becomes invalid.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation does nothing.")
	public void mark(int __l)
	{
	}
	
	/**
	 * Returns whether or not marking is supported on the input stream.
	 *
	 * @return If marking is supported.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation always returns false.")
	public boolean markSupported()
	{
		return false;
	}
	
	/**
	 * Reads multiple bytes and stores them into the array.
	 *
	 * @param __b The destination array.
	 * @return The number of bytes read or {@code -1} if the end of stream has
	 * been reached.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// No bytes to read?
		int n = __b.length;
		if (n <= 0)
			return 0;
		
		// Read bytes into the array
		for (int i = 0, o = 0; i < n; i++)
		{
			int rv = this.read();
			
			// EOF?
			if (rv < 0)
				return (i == 0 ? -1 : i);
			
			__b[o++] = (byte)rv;
		}
		
		// Read all bytes
		return n;
	}
	
	/**
	 * Reads multiple bytes and stores them into the array.
	 *
	 * @param __b The destination array.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read or {@code -1} if the end of stream has
	 * been reached.
	 * @throws IndexOutOfBoundsException If the offset and/or length 
	 * negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// No bytes to read?
		if (__l <= 0)
			return 0;
		
		// Read bytes into the array
		for (int i = 0; i < __l; i++)
		{
			int rv = this.read();
			
			// EOF?
			if (rv < 0)
				return (i == 0 ? -1 : i);
			
			__b[__o++] = (byte)rv;
		}
		
		// Read all bytes
		return __l;
	}
	
	/**
	 * Resets the stream to a previously marked position.
	 *
	 * @throws IOException If marking is not supported or the mark has been
	 * invalidated by reading more than the limit bytes.
	 * @since 2019/01/20
	 */
	public void reset()
		throws IOException
	{
		// {@squirreljme.error ZZ0n Reset is not supported.}
		throw new IOException("ZZ0n");
	}
	
	/**
	 * Attemps to skip over the given number of bytes.
	 *
	 * It is not required for the actual number of bytes skipped to match the
	 * input amount, this could be specific to the input stream implementation
	 * or the end of file has been reached.
	 *
	 * @param __n The number of bytes to skip, if this value is negative then
	 * no bytes are skipped.
	 * @return The number of skipped bytes.
	 * @throws IOException On read errors.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation allocates an array and reads " +
		"into that array until all bytes have been skipped.")
	public long skip(long __n)
		throws IOException
	{
		// Not doing anything
		if (__n <= 0)
			return 0;
		
		// Keep reading bytes
		byte[] buf = new byte[InputStream._SKIP_LEN];
		long actual = 0;
		while (__n > 0)
		{
			// Only skip the small group
			int now = (int)(InputStream._SKIP_LEN < __n ?
				InputStream._SKIP_LEN : __n);
			
			// Try to skip these bytes
			int rv = this.read(buf, 0, now);
			
			// EOF?
			if (rv < 0)
				return actual;
			
			// Discard the bytes
			actual += rv;
			__n -= rv;
		}
		
		return actual;
	}
}

Added modules/cldc-compact/src/main/java/java/io/InputStreamReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Decoder;

/**
 * This is a reader which adapts to an input stream and decodes the input
 * bytes into characters.
 *
 * @since 2018/10/13
 */
public class InputStreamReader
	extends Reader
{
	/** The input source. */
	private final InputStream _in;
	
	/** The decoder to use. */
	private final Decoder _decoder;
	
	/** The input read storage. */
	private final byte[] _store;
	
	/**
	 * Initializes the reader from the given input stream using the default
	 * encoding.
	 *
	 * @param __in The input byte source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public InputStreamReader(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this._in = __in;
		
		Decoder d;
		this._decoder = (d = CodecFactory.defaultDecoder());
		this._store = new byte[d.maximumSequenceLength()];
	}
	
	/**
	 * Initializes the reader from the given input stream using the default
	 * encoding.
	 *
	 * @param __in The input byte source.
	 * @param __enc The encoding to decode.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public InputStreamReader(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this._in = __in;
		
		Decoder d;
		this._decoder = (d = CodecFactory.decoder(__enc));
		this._store = new byte[d.maximumSequenceLength()];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public void close()
		throws IOException
	{
		this._in.close();
	}
	
	/**
	 * Returns the name of the encoding.
	 *
	 * @return The encoding name.
	 * @since 2018/12/08
	 */
	public String getEncoding()
	{
		return this._decoder.encodingName();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read()
		throws IOException
	{
		InputStream in = this._in;
		Decoder decoder = this._decoder;
		byte[] store = this._store;
		int storelen = 0,
			declimit = store.length;
		
		// Read characters
		for (;;)
		{
			// {@squirreljme.error ZZ0o Read of input byte sequence exceeded
			// the maximum specified sequence length. (The store length)}
			if (storelen >= declimit)
				throw new IOException("ZZ0o " + storelen);
			
			// Read byte from input stream
			int brc = in.read(store, storelen, 1);
			
			// Reached EOF from the input bytes
			if (brc < 0)
			{
				// No characters were read, so this is a complete EOF
				if (storelen <= 0)
					return -1;
				
				// Try to decode whatever was read, if it ends up not being
				// valid then just use the replacement character because it
				// probably got chopped off
				int cha = decoder.decode(store, 0, storelen);
				if (cha >= 0)
					return (char)cha;
				else
					return (char)0xFFFD;
			}
			
			// Increment the store length since bytes were read
			storelen++;
			
			// Try to decode a character, if it decodes to a valid character we
			// just store that
			int cha = decoder.decode(store, 0, storelen);
			if (cha >= 0)
				return (char)cha;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IOException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		InputStream in = this._in;
		Decoder decoder = this._decoder;
		byte[] store = this._store;
		int storelen = 0,
			declimit = store.length;
		
		int rv = 0,
			baseo = __o;
		for (int o = __o; rv < __l;)
		{
			// {@squirreljme.error ZZ0p Read of input byte sequence exceeded
			// the maximum specified sequence length. (The store length)}
			if (storelen >= declimit)
				throw new IOException("ZZ0p " + storelen);
			
			// Read byte from input stream
			int brc = in.read(store, storelen, 1);
			
			// Reached EOF from the input bytes
			if (brc < 0)
			{
				// No characters were read, so this is a complete EOF
				// However if there were characters sitting in the output we
				// need to return those
				if (storelen <= 0)
					return (rv > 0 ? rv : brc);
				
				// Try to decode whatever was read, if it ends up not being
				// valid then just use the replacement character because it
				// probably got chopped off
				int cha = decoder.decode(store, 0, storelen);
				if (cha >= 0)
					__c[o++] = (char)cha;
				else
					__c[o++] = (char)0xFFFD;
				rv++;
				
				// There could have been characters placed before this, so
				// this should be at least 1
				return rv;
			}
			
			// Increment the store length since bytes were read
			storelen++;
			
			// Try to decode a character, if it decodes to a valid character we
			// just store that
			int cha = decoder.decode(store, 0, storelen);
			if (cha >= 0)
			{
				__c[o++] = (char)cha;
				storelen = 0;
				rv++;
			}
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public boolean ready()
		throws IOException
	{
		// If the number of available bytes is at least the maximum sequence
		// length then we can read a single character without blocking
		return this._in.available() >= this._store.length;
	}
}

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

package java.io;

/**
 * This is thrown when an I/O operation was interrupted.
 *
 * @since 2018/12/08
 */
public class InterruptedIOException
	extends IOException
{
	/** The number of bytes which were transferred. */
	public int bytesTransferred;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public InterruptedIOException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public InterruptedIOException(String __m)
	{
		super(__m);
	}
}

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

package java.io;

/**
 * This class is the base class for all byte oriented output streams.
 *
 * @since 2016/04/16
 */
public abstract class OutputStream
	implements Closeable
{
	
	/**
	 * Writes a single byte to the output stream, the byte is in the range of
	 * 0 and 255. If the byte exceeds that range, then it must take the low
	 * order value and write that {@code __a & 0xFF}.
	 *
	 * @param __b The value the low order byte is derived from for output to
	 * this stream.
	 * @throws IOException On write errors.
	 * @since 2016/04/16
	 */
	public abstract void write(int __b)
		throws IOException;
	
	/**
	 * {@inheritDoc}
	 *
	 * If this method is not overridden by a sub-class then this does nothing.
	 *
	 * @since 2016/04/16
	 */
	@Override
	public void close()
		throws IOException
	{	
		// Does nothing
	}
	
	/**
	 * This is used to indicate that the stream should be flushed.
	 *
	 * If this method is not overridden by a sub-class then this does nothing.
	 *
	 * @throws IOException If flushing failed.
	 * @since 2016/04/16
	 */
	public void flush()
		throws IOException
	{
		// Does nothing
	}
	
	/**
	 * Writes bytes from the given input array to this output stream.
	 *
	 * If this method is not overidden by a sub-class then this will call
	 * {@link #write(int)} for each byte in the buffer.
	 *
	 * @param __a The source byte array to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/16
	 */
	public void write(byte[] __a)
		throws IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Write all bytes
		for (int i = 0, n = __a.length; i < n; i++)
			this.write(__a[i]);
	}
	
	/**
	 * Writes multiple bytes from the specific array into this output stream.
	 *
	 * @param __a The array to source bytes from.
	 * @param __o The offset from the start of the array to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IndexOutOfBoundsException If the offset or length are negative;
	 * or the offset and the length exceeds the input array.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/16
	 */
	public void write(byte[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Write all bytes
		for (int i = 0; i < __l; i++)
			this.write(__a[__o + i]);
	}
}

Added modules/cldc-compact/src/main/java/java/io/OutputStreamWriter.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

public class OutputStreamWriter
	extends Writer
{
	public OutputStreamWriter(OutputStream __a, String __b)
		throws UnsupportedEncodingException
	{
		if (false)
			throw new UnsupportedEncodingException();
		throw new todo.TODO();
	}
	
	public OutputStreamWriter(OutputStream __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void close()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void flush()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public String getEncoding()
	{
		throw new todo.TODO();
	}
	
	@Override
	public void write(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void write(char[] __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void write(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/io/PrintStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Encoder;
import java.util.Formatter;

/**
 * This class is used to print translated and formatted text.
 *
 * No {@link IOException} is ever thrown by any of these methods, they are
 * handled and provided as an error flag which can be obtained. If
 * {@link InterruptedIOException} is thrown then the error state is not set,
 * any operations which cause this to occur will instead call
 * {@code Thread.currentThread().interrupt()}.
 *
 * Print streams may optionally have automatic flushing which will call
 * {@link #flush()} whenever a byte array is written or when it is detected
 * that {@code '\n'} is written. Internally the output is bufferred to optimize
 * for writing multiple characters at once rather than one at a time.
 *
 * If not specified, the current system encoding is used.
 *
 * Any characters which are written to the output will be encoded accordingly.
 *
 * @since 2018/09/16
 */
public class PrintStream
	extends OutputStream
	implements Appendable, Closeable
{
	/**
	 * This buffer size for this class has been chosen to be small, since in
	 * most cases this class will either not be used or will be outputting just
	 * text to the console. So since most consoles and most text will likely
	 * be 80 columns or less, this buffer size is enough to fit such a terminal
	 * but also give some extra room in the event of overflow.
	 */
	private static final int _BUFFER_SIZE =
		96;
	
	/** Threshold before a forced flush. */
	private static final int _THRESHOLD =
		90;
	
	/** The newline sequence. */
	private static final String _NEWLINE;
	
	/** The stream to write bytes to. */
	private final OutputStream _out;
	
	/** Is auto-flushing to be used? */
	private final boolean _autoflush;
	
	/** The encoder used to encode chars to bytes. */
	private final Encoder _encoder;
	
	/** Mini-byte buffer for encoded characters. */
	private final byte[] _minienc =
		new byte[8];
	
	/** The internal buffer. */
	private final byte[] _buf =
		new byte[PrintStream._BUFFER_SIZE];
	
	/** The position the buffer is at. */
	private int _bat;
	
	/** Error state? */
	private boolean _inerror;
	
	/**
	 * Cache the line separator which is derived from the system properties.
	 *
	 * @since 2018/09/18
	 */
	static
	{
		String nl;
		try
		{
			nl = System.getProperty("line.separator");
		}
		catch (SecurityException e)
		{
			nl = "\n";
		}
		
		_NEWLINE = nl;
	}
	
	/**
	 * Writes to the given stream using the default encoding and with no
	 * auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out)
		throws NullPointerException
	{
		this(__out, false, CodecFactory.defaultEncoder());
	}
	
	/**
	 * Writes to the given stream using the default encoding and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out, boolean __autoflush)
		throws NullPointerException
	{
		this(__out, __autoflush, CodecFactory.defaultEncoder());
	}
	
	/**
	 * Writes to the given stream using the given encoding and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @param __enc The encoding to use.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out, boolean __autoflush, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(__out, __autoflush, CodecFactory.encoder(__enc));
	}
	
	/**
	 * Writes to the given stream using the given encoder and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @param __enc The encoder to use to encode characters to bytes.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	private PrintStream(OutputStream __out, boolean __autoflush, Encoder __enc)
		throws NullPointerException
	{
		if (__out == null || __enc == null)
			throw new NullPointerException("NARG");
		
		this._out = __out;
		this._autoflush = __autoflush;
		this._encoder = __enc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(CharSequence __c)
	{
		this.print((__c == null ? "null" : __c.toString()));
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(CharSequence __c, int __s, int __e)
	{
		this.print((__c == null ? "null" :
			__c.subSequence(__s, __e).toString()));
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(char __c)
	{
		this.print(__c);
		return this;
	}
	
	/**
	 * Flushes the stream and checks the error state.
	 *
	 * @return The current error state.
	 * @since 2019/06/21
	 */
	public boolean checkError()
	{
		synchronized (this)
		{
			this.__flush();
			return this._inerror;
		}
	}
	
	/**
	 * Clears the error state.
	 *
	 * @since 2019/06/21
	 */
	protected void clearError()
	{
		synchronized (this)
		{
			this._inerror = false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public void close()
	{
		synchronized (this)
		{
			// Flush output
			this.__flush();
			
			// Close the stream
			try
			{
				this._out.close();
			}
			
			// Set error state?
			catch (IOException e)
			{
				this._inerror = true;
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public void flush()
	{
		synchronized (this)
		{
			this.__flush();
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public PrintStream format(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		return this.__printf(__fmt, __args);
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(boolean __v)
	{
		synchronized (this)
		{
			this.__print((__v ? "true" : "false"));
		}
	}
	
	/**
	 * Prints the specified character to the stream.
	 *
	 * @param __v The character to print.
	 * @since 2018/09/23
	 */
	public void print(char __v)
	{
		synchronized (this)
		{
			this.__writeChar(__v);
		}
	}
	
	/**
	 * Prints the specified integer to the stream.
	 *
	 * @param __v The value to print.
	 * @since 2018/11/04
	 */
	public void print(int __v)
	{
		synchronized (this)
		{
			this.__print(Integer.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(long __v)
	{
		synchronized (this)
		{
			this.__print(Long.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(float __v)
	{
		synchronized (this)
		{
			this.__print(Float.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(double __v)
	{
		synchronized (this)
		{
			this.__print(Double.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public void print(char[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			for (int i = 0, n = __v.length; i < n; i++)
				this.__writeChar(__v[i]);
		}
	}
	
	/**
	 * Prints the specified string.
	 *
	 * @param __v The string to print, if {@code null} then {@code "null"} is
	 * printed.
	 * @since 2018/09/20
	 */
	public void print(String __v)
	{
		synchronized (this)
		{
			this.__print(__v);
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(Object __v)
	{
		synchronized (this)
		{
			this.__print((__v == null ? "null" : __v.toString()));
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public PrintStream printf(String __fmt, Object... __args)
	{
		return this.__printf(__fmt, __args);
	}
	
	/**
	 * Prints the end of line sequence that is used for the current platform.
	 *
	 * @since 2018/09/21
	 */
	public void println()
	{
		synchronized (this)
		{
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(boolean __v)
	{
		synchronized (this)
		{
			this.__print((__v ? "true" : "false"));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(char __v)
	{
		synchronized (this)
		{
			this.__writeChar(__v);
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(int __v)
	{
		synchronized (this)
		{
			this.__print(Integer.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(long __v)
	{
		synchronized (this)
		{
			this.__print(Long.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(float __v)
	{
		synchronized (this)
		{
			this.__print(Float.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(double __v)
	{
		synchronized (this)
		{
			this.__print(Double.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public void println(char[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			for (int i = 0, n = __v.length; i < n; i++)
				this.__writeChar(__v[i]);
			this.__println();
		}
	}
	
	/**
	 * Prints the given string to the output stream followed by a new line.
	 *
	 * @param __v The string to write.
	 * @since 2018/09/18
	 */
	public void println(String __v)
	{
		synchronized (this)
		{
			this.__print(__v);
			this.__println();
		}
	}
	
	/**
	 * Prints the given object to the output stream followed by a new line.
	 *
	 * @param __v The string to write.
	 * @since 2018/11/20
	 */
	public void println(Object __v)
	{
		synchronized (this)
		{
			this.__print((__v == null ? "null" : __v.toString()));
			this.__println();
		}
	}
	
	/**
	 * Sets the error state to on.
	 *
	 * @since 2019/06/21
	 */
	protected void setError()
	{
		this._inerror = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If newline is written, this will flush.")
	public void write(int __c)
	{
		// Is always in array form
		byte[] b = new byte[]{(byte)__c};
		
		// Forward
		synchronized (this)
		{
			this.__writeBytes(b, 0, 1);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If auto-flushing, this calls flush after writing.")
	public void write(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			this.__writeBytes(__b, 0, __b.length);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If auto-flushing, this calls flush after writing.")
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			this.__writeBytes(__b, __o, __l);
		}
	}
	
	/**
	 * Flushes the stream to the output.
	 *
	 * @since 2018/09/21
	 */
	private final void __flush()
	{
		// Nothing to be written at all?
		int bat = this._bat;
		if (bat <= 0)
			return;
		
		// Write individual bytes and detect any exceptions
		OutputStream out = this._out;
		boolean oopsie = false;
		byte[] buf = this._buf;
		int bop = 0;
		for (bop = 0; bop < bat; bop++)
			try
			{
				out.write(buf[bop]);
			}
			catch (InterruptedIOException e)
			{
				// Just stop handling here and interrupt the thread
				Thread.currentThread().interrupt();
				break;
			}
			catch (IOException e)
			{
				oopsie = true;
				break;
			}
		
		// Could not flush to the output
		if (oopsie)
		{
			// Bring down the characters in the buffer so that they are not
			// just lost
			for (int i = bop, o = 0; i < bat; i++, o++)
				buf[o] = buf[i];
			this._bat = bat - bop;
			
			// Set error state
			this._inerror = true;
		}
		
		// Is perfectly fine, so "clear" the buffer
		else
			this._bat = 0;
	}
	
	/**
	 * Prints the specified string.
	 *
	 * @param __s The string to print, if {@code null} then {@code "null"} is
	 * printed.
	 * @since 2018/09/20
	 */
	private final void __print(String __s)
	{
		synchronized (this)
		{
			// Print null explicitely
			if (__s == null)
				__s = "null";
			
			for (int i = 0, n = __s.length(); i < n; i++)
				this.__writeChar(__s.charAt(i));
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	private final PrintStream __printf(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		if (__fmt == null)
			throw new NullPointerException("NARG");
		
		// Generate text to write into a string builder
		StringBuilder sb = new StringBuilder();
		try (Formatter f = new Formatter(sb))
		{
			f.format(__fmt, __args);
		}
		
		// Dump characters that were written into the string but without
		// turning it into an actual string, for memory purposes
		synchronized (this)
		{
			for (int i = 0, n = sb.length(); i < n; i++)
				this.__writeChar(sb.charAt(i));
		}
		
		return this;
	}
	
	/**
	 * Prints the end of line sequence that is used for the current platform.
	 *
	 * @return The end of line sequence.
	 * @since 2018/09/21
	 */
	private final void __println()
	{
		synchronized (this)
		{
			// If the newline character has not yet been set, use a fallback
			String nl = PrintStream._NEWLINE;
			if (nl == null)
				nl = "\n";
			
			// Write the ending
			for (int i = 0, n = nl.length(); i < n; i++)
				this.__writeChar(nl.charAt(i));
			
			// Flush the stream after every line printed, in the event the
			// system does not use a UNIX newline
			if (this._autoflush)
				this.flush();
		}
	}
	
	/**
	 * Writes multiple bytes to the output.
	 *
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	private final void __writeBytes(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Our current buffer state
		byte[] buf = this._buf;
		int bat = this._bat;
		
		// Auto-flush on any newlines?
		boolean autoflush = this._autoflush;
		
		// Copy bytes into the buffer
		boolean flush = false;
		for (int i = 0; i < __l; i++)
		{
			byte b = __b[i];
			
			// Fill into buffer
			buf[bat++] = b;
			
			// Auto-flushing on newline?
			if (autoflush && b == '\n')
				flush = true;
			
			// Force a flush?
			if (bat >= PrintStream._THRESHOLD)
			{
				// Store at location, flush then reload it
				this._bat = bat;
				this.__flush();
				bat = this._bat;
			}
		}
		
		// Store changes
		this._bat = bat;
		
		// Perform a flush?
		if (flush || bat >= PrintStream._THRESHOLD)
			this.__flush();
	}
	
	/**
	 * Writes a single character to the output, encoding it as required.
	 *
	 * @param __c The character to write.
	 * @since 2018/09/19
	 */
	private final void __writeChar(char __c)
	{
		// Encode bytes into the array
		byte[] minienc = this._minienc;
		int wc = this._encoder.encode(__c, minienc, 0, minienc.length);
		
		// {@squirreljme.error ZZ0q Did not expect the buffer to be out of
		// room.}
		if (wc < 0)
			throw new Error("ZZ0q");
		
		// Write them into the buffer
		this.__writeBytes(minienc, 0, wc);
	}
}

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

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public abstract class Reader
	implements Closeable
{
	/** The lock to use when performing read operations. */
	@ImplementationNote("This is only used with the skip() method.")
	protected Object lock;
	
	/**
	 * Initializes the base reader.
	 *
	 * @since 2018/10/13
	 */
	@ImplementationNote("The lock should be initialized to this, however " +
		"this would result in the reader itself never able to be freed " +
		"because it refers to itself.")
	protected Reader()
	{
		this.lock = null;
	}
	
	/**
	 * Initializes the reader to lock against the given object.
	 *
	 * @param __l The object to lock against.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	protected Reader(Object __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.lock = __l;
	}
	
	public abstract void close()
		throws IOException;
	
	/**
	 * Reads multiple characters.
	 *
	 * @param __c The output characters.
	 * @param __o The offset into the output.
	 * @param __l The number of characters to read.
	 * @return The number of read characters or {@code -1} on end of file.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public abstract int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException;
	
	public void mark(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean markSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reads a single character from the input.
	 *
	 * @return The character which was read or {@code -1} on end of file.
	 * @throws IOException On read errors.
	 * @since 2018/10/13
	 */
	public int read()
		throws IOException
	{
		// Try reading the character in a loop
		char[] buf = new char[1];
		for (;;)
		{
			int rc = this.read(buf, 0, 1);
			
			// Try to read character again
			if (rc == 0)
				continue;
			
			// EOF
			else if (rc < 0)
				return rc;
			
			return buf[0];
		}
	}
	
	/**
	 * Reads in multiple characters from the stream.
	 *
	 * @param __c The characters to read.
	 * @return The number of read characters.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public int read(char[] __c)
		throws IOException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		return this.read(__c, 0, __c.length);
	}
	
	public boolean ready()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void reset()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public long skip(long __a)
		throws IOException
	{
		// To prevent clashes when skipping characters
		synchronized (this.__lock())
		{
			if (false)
				throw new IOException();
			throw new todo.TODO();
		}
	}
	
	/**
	 * Returns the locking object.
	 *
	 * @return The locking object.
	 * @since 2018/10/13
	 */
	final Object __lock()
	{
		Object rv = this.lock;
		return (rv == null ? this : rv);
	}
}

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

package java.io;

/**
 * This is thrown when the format of a UTF string is not correct.
 *
 * @since 2018/12/03
 */
public class UTFDataFormatException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/03
	 */
	public UTFDataFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given cause.
	 *
	 * @param __m The message to use.
	 * @since 2018/12/03
	 */
	public UTFDataFormatException(String __m)
	{
		super(__m);
	}
}

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

package java.io;

/**
 * This is thrown when the encoding is not supported.
 *
 * @since 2018/12/08
 */
public class UnsupportedEncodingException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public UnsupportedEncodingException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public UnsupportedEncodingException(String __m)
	{
		super(__m);
	}
}

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

package java.io;

public abstract class Writer
	implements Appendable, Closeable
{
	protected Object lock;
	
	protected Writer()
	{
		throw new todo.TODO();
	}
	
	protected Writer(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public abstract void close()
		throws IOException;
	
	public abstract void flush()
		throws IOException;
	
	public abstract void write(char[] __a, int __b, int __c)
		throws IOException;
	
	@Override
	public Writer append(CharSequence __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public Writer append(CharSequence __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public Writer append(char __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(char[] __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(String __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

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

package java.lang;

import java.io.IOException;

/**
 * This is an appendable which is given characters and character sequences
 * to be written into the output.
 *
 * @since 2018/12/07
 */
public interface Appendable
{
	/**
	 * Appends a character sequence to the output.
	 *
	 * @param __c The sequence to append.
	 * @return {@code this}.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	Appendable append(CharSequence __c)
		throws IOException;
	
	/**
	 * Appends a character sequence to the output.
	 *
	 * @param __c The sequence to append.
	 * @param __s The start index.
	 * @param __e The end index.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the start or end is outside of
	 * the bounds of the sequence, or the start exceeds the end.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	Appendable append(CharSequence __c, int __s, int __e)
		throws IndexOutOfBoundsException, IOException;
	
	/**
	 * Appends a single character to the output.
	 *
	 * @param __c The character to append.
	 * @return {@code this}.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	Appendable append(char __c)
		throws IOException;
}

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

package java.lang;

/**
 * This is thrown when there is a divide by zero.
 *
 * @since 2018/12/04
 */
public class ArithmeticException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArithmeticException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public ArithmeticException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when an attempt is made to read from or write to an array
 * index which is out of bounds.
 *
 * @since 2018/12/04
 */
public class ArrayIndexOutOfBoundsException
	extends IndexOutOfBoundsException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initializes the exception with the index specified as the message and
	 * no cause.
	 *
	 * @param __i The out of bounds index.
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException(int __i)
	{
		// {@squirreljme.error ZZ0r Array index out of bounds. (The index)}
		super("ZZ0r " + __i);
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The exception message.
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when the given value cannot be stored into the given array
 * because it is of the wrong type.
 *
 * @since 2018/12/04
 */
public class ArrayStoreException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArrayStoreException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public ArrayStoreException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when an assertion check fails.
 *
 * @since 2018/12/04
 */
public class AssertionError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public AssertionError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(Object __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(boolean __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(char __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(int __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(long __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(float __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(double __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Converts the given object to a string.
	 *
	 * @param __o The object to convert.
	 * @return The string form of the object.
	 * @since 2018/12/04
	 */
	private static final String __convert(Object __o)
	{
		if (__o == null)
			return "null";
		
		// Just make sure we can convert this
		try
		{
			return __o.toString();
		}
		
		// Could not convert
		catch (Throwable t)
		{
			// Debug it
			t.printStackTrace();
			
			// {@squirreljme.error ZZ0s Assertion string conversion failed
			// with no message.}
			String m = t.getMessage();
			return (m == null ? "ZZ0s" : m);
		}
	}
}

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

package java.lang;

/**
 * This interface is used with the classes which are initialized in the
 * {@code try-with-resources} block, after the entire block has been finished
 * the {@link #close()} method is called automatically. This makes it much
 * simpler to free resources and no longer requires a {@code finally} with a
 * local variable mess to handle closing of streams.
 *
 * {@code
 *
 * try (FileInputStream fis = new FileInputStream("foo"))
 * {
 *     // fis is VISIBLE here.
 *     // Do stuff with file.
 * }
 * catch (IOException ioe)
 * {
 *     // fis is NOT VISIBLE here.
 *     // Handle exception or rethrow as needed
 * }
 * finally
 * {
 *     // fis is NOT VISIBLE here.
 *     // Other things to do regardless of success or an exception.
 * }
 * // The variable fis is NOT VISIBLE here and when this point of code has
 * // been reached, fis.close() would have been called.
 * 
 * }
 *
 * @since 2015/03/23
 */
public interface AutoCloseable
{
	/**
	 * This releases all (or most) of the resources associated with
	 * an implementing class. When used with a try-with-resources block, this
	 * is automatically called after the scope of block has been left (it is
	 * executed after {@code finally}).
	 *
	 * It is recommended that a resource is actually closed (or at least
	 * marked as such) before an exception is thrown.
	 *
	 * Unlike {@link java.io.Closeable#close()} (and provided the class does
	 * not extend {@link java.io.Closeable}), calling this multiple times may
	 * produce side effects rather than doing nothing on a closed resource.
	 * However, it is stronly recommended and encouraged to follow the "do
	 * nothing when closed" behavior of {@link java.io.Closeable}.
	 *
	 * @throws Exception If there was an error closing the specified object.
	 * @since 2015/03/23
	 */
	void close()
		throws Exception;
}

Added modules/cldc-compact/src/main/java/java/lang/Boolean.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
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
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This is a boxed boolean value.
 *
 * @since 2018/12/07
 */
public final class Boolean
	implements Comparable<Boolean>
{
	/** The false value. */
	public static final Boolean FALSE =
		new Boolean(false);
	
	/** The true value. */
	public static final Boolean TRUE =
		new Boolean(true);
	
	/** The class representing the primitive type. */
	public static final Class<Boolean> TYPE =
		ObjectAccess.<Boolean>classByNameType("boolean");
	
	/** The value of this boolean. */
	private final boolean _value;
	
	/**
	 * Initializes the boolean with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Boolean(boolean __v)
	{
		this._value = __v;
	}
	
	/**
	 * Initializes the boolean from the given string.
	 *
	 * @param __s String boolean representation.
	 * @since 2018/12/07
	 */
	public Boolean(String __s)
	{
		this(Boolean.valueOf(__s)._value);
	}
	
	/**
	 * Returns the value of this boolean.
	 *
	 * @return The boolean value.
	 * @since 2018/09/23
	 */
	public boolean booleanValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int compareTo(Boolean __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		boolean a = this._value,
			b = __o._value;
		
		if (a == b)
			return 0;
		else if (a)
			return 1;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Boolean))
			return false;
		
		return this._value == ((Boolean)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		return (this._value ? 1231 : 1237);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		return Boolean.toString(this._value);
	}
	
	/**
	 * Gets boolean value from the system property.
	 *
	 * @param __p The property to get.
	 * @return The value of the boolean.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If it is not permitted to get the property.
	 * @since 2018/12/07
	 */
	public static boolean getBoolean(String __p)
		throws NullPointerException, SecurityException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return Boolean.parseBoolean(System.getProperty(__p));
	}
	
	/**
	 * Parses the given boolean value without regards to case.
	 *
	 * @param __v The value to parse.
	 * @return The boolean of the parse.
	 * @since 2018/12/07
	 */
	public static boolean parseBoolean(String __v)
	{
		return (__v != null && __v.equalsIgnoreCase("true"));
	}
	
	/**
	 * Returns a string representing the given value.
	 *
	 * @param __a The boolean to represent.
	 * @return The string representation of the boolean.
	 * @since 2018/09/23
	 */
	public static String toString(boolean __a)
	{
		if (__a)
			return "true";
		return "false";
	}
	
	/**
	 * Boxes the given boolean value.
	 *
	 * @param __a The boolean to box.
	 * @return Either {@link #TRUE} or {@link #FALSE}.
	 * @since 2016/03/21
	 */
	public static Boolean valueOf(boolean __a)
	{
		if (__a)
			return Boolean.TRUE;
		return Boolean.FALSE;
	}
	
	/**
	 * Returns the value of the given boolean.
	 *
	 * @param __v The value to parse.
	 * @return The boolean value.
	 * @since 2018/12/07
	 */
	public static Boolean valueOf(String __v)
	{
		if (__v != null && __v.equalsIgnoreCase("true"))
			return Boolean.TRUE;
		return Boolean.FALSE;
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Byte.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a boxed byte value.
 *
 * @since 2018/12/07
 */
public final class Byte
	extends Number
	implements Comparable<Byte>
{
	/** The maximum value. */
	public static final byte MAX_VALUE =
		127;
	
	/** The minimum value. */
	public static final byte MIN_VALUE =
		-128;
	
	/** The number of bits in a byte. */
	public static final int SIZE =
		8;
	
	/** The class representing the primitive type. */
	public static final Class<Byte> TYPE =
		ObjectAccess.<Byte>classByNameType("byte");
	
	/** The value of the byte. */
	private final byte _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the boxed value.
	 *
	 * @param __v The value to store.
	 * @since 2018/11/14
	 */
	public Byte(byte __v)
	{
		this._value = __v;
	}
	
	/**
	 * Initializes the byte value from the string.
	 *
	 * @param __s The string to parse.
	 * @throws NumberFormatException If the string is not a valid number.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public Byte(String __s)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this._value = Byte.parseByte(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public byte byteValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int compareTo(Byte __o)
	{
		return this._value - __o._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public double doubleValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Byte))
			return false;
		
		return this._value == ((Byte)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public float floatValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int intValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public short shortValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Byte.toString(this._value)));
		
		return rv;
	}
	
	/**
	 * Decodes a byte value from the string in the same form as
	 * {@link Integer#decode(String)}.
	 *
	 * @param __s The string to decode.
	 * @return The byte value.
	 * @throws NumberFormatException If the value is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte decode(String __s)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0t Byte value out of bounds.}
		int val = Integer.decode(__s);
		if (val < Byte.MIN_VALUE || val > Byte.MAX_VALUE)
			throw new NumberFormatException("ZZ0t");
		
		return Byte.valueOf((byte)val);
	}
	
	/**
	 * Parses the given byte using the given radix.
	 *
	 * @param __s The string to parse.
	 * @param __r The radix of the value.
	 * @return The parsed value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static byte parseByte(String __s, int __r)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0u Byte value out of range.}
		int val = Integer.parseInt(__s, __r);
		if (val < Byte.MIN_VALUE || val > Byte.MAX_VALUE)
			throw new NumberFormatException("ZZ0u");
		
		return (byte)val;
	}
	
	/**
	 * Parses the given string to a byte.
	 *
	 * @param __s The string to parse.
	 * @return The parsed value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static byte parseByte(String __s)
		throws NumberFormatException, NullPointerException
	{
		return Byte.parseByte(__s, 10);
	}
	
	/**
	 * Returns the string representation of the given byte value.
	 *
	 * @param __v The value to represent.
	 * @return The string value.
	 * @since 2018/11/14
	 */
	public static String toString(byte __v)
	{
		return Integer.toString(__v, 10);
	}
	
	/**
	 * Boxes the specified byte value.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/11/14
	 */
	public static Byte valueOf(byte __v)
	{
		return new Byte(__v);
	}
	
	/**
	 * Parses the string to the given byte value.
	 *
	 * @param __s The string to parse.
	 * @param __r The radix.
	 * @return The decoded value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte valueOf(String __s, int __r)
		throws NumberFormatException, NullPointerException
	{
		return new Byte(Byte.parseByte(__s, __r));
	}
	
	/**
	 * Parses the string to the given byte value.
	 *
	 * @param __s The string to parse.
	 * @return The decoded value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte valueOf(String __s)
		throws NumberFormatException, NullPointerException
	{
		return new Byte(Byte.parseByte(__s, 10));
	}
}

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

package java.lang;

/**
 * This represents a sequence of characters.
 *
 * @since 2018/12/07
 */
public interface CharSequence
{
	/**
	 * Returns the character at the given index.
	 *
	 * @param __i The index to get.
	 * @return The character at the given index.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/07
	 */
	char charAt(int __i)
		throws IndexOutOfBoundsException;
	
	/**
	 * Returns the length of the character sequence.
	 *
	 * @return The length of the sequence.
	 * @since 2018/12/07
	 */
	int length();
	
	/**
	 * Returns a sub-sequence of this character sequence.
	 *
	 * @param __s The start index.
	 * @param __e The end index.
	 * @return The sub sequence of this one.
	 * @throws IndexOutOfBoundsException If the start or end exceed the
	 * sequence bounds or start is greater than end.
	 * @since 2018/12/07
	 */
	CharSequence subSequence(int __s, int __e)
		throws IndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	String toString();
}

Added modules/cldc-compact/src/main/java/java/lang/Character.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.i18n.DefaultLocale;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is a boxed representation of {@link char}.
 *
 * @since 2018/10/13
 */
public final class Character
	implements Comparable<Character>
{
	/** The maximum radix for digit conversions. */
	public static final int MAX_RADIX =
		36;
	
	/** The maximum value for characters. */
	public static final char MAX_VALUE =
		65535;
	
	/** The minimum radix for digit conversions. */
	public static final int MIN_RADIX =
		2;
	
	/** The minimum value for characters. */
	public static final char MIN_VALUE =
		0;
	
	/** The number of bits used to represent a character. */
	public static final int SIZE =
		16;
	
	/** The class representing the primitive type. */
	public static final Class<Character> TYPE =
		ObjectAccess.<Character>classByNameType("char");
	
	/** The character value. */
	private final char _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the boxed character.
	 *
	 * @param __v The character to use.
	 * @since 2018/10/11
	 */
	public Character(char __v)
	{
		this._value = __v;
	}
	
	/**
	 * Returns the character value.
	 *
	 * @return The character value.
	 * @since 2018/10/11
	 */
	public char charValue()
	{
		return this._value;
	}
	
	/**
	 * This compares the numerical value for characters, it does not depend
	 * on locale at all.
	 *
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int compareTo(Character __o)
		throws NullPointerException
	{
		char a = this._value,
			b = __o._value;
		
		return a - b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Character))
			return false;
		
		return this._value == ((Character)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// We can represent a string for our single character as this
		// special sequence instead of just creating a new temporary string
		// just to store a single character or creating some kind of array.
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = new String(new char[]{this._value}, (short)0)));
		
		return rv;
	}
	
	/**
	 * Returns the digit for the given character and radix.
	 *
	 * @param __c The character to decode.
	 * @param __r The radix used.
	 * @return The digit for the given radix, if the character or the radix is
	 * not valid then {@code -1} is returned.
	 * @since 2018/10/13
	 */
	public static int digit(char __c, int __r)
	{
		// Invalid radix
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			return -1;
		
		// Decode character
		int rv;
		if (__c >= 'a' && __c <= 'z')
			rv = 10 + (__c - 'a');
		else if (__c >= 'A' && __c <= 'Z')
			rv = 10 + (__c - 'A');
		else if (__c >= '0' && __c <= '9')
			rv = __c - '0';
		
		// Not valid
		else
			return -1;
		
		// Out of bounds of the radix
		if (rv >= __r)
			return -1;
		return rv;
	}
	
	/**
	 * Returns the character for the given digit and radix.
	 *
	 * @param __dig The digit to convert to a character.
	 * @param __r The radix to use for conversion.
	 * @return The character for the digit or NUL if the digit is out of range
	 * or the radix is out of range.
	 * @since 2018/10/13
	 */
	public static char forDigit(int __dig, int __r)
	{
		if (__dig < 0 || __dig >= __r || __r < Character.MIN_RADIX ||
			__r > Character.MAX_RADIX)
			return '\0';
		
		if (__dig < 10)
			return (char)('0' + __dig);
		return (char)('a' + (__dig - 10));
	}
	
	/**
	 * Returns true if the character is a digit.
	 *
	 * @param __c The character to check.
	 * @return True if the character is a digit.
	 * @since 2018/12/08
	 */
	public static boolean isDigit(char __c)
	{
		return (__c >= '0' && __c <= '9');
	}
	
	/**
	 * Returns true if the character is an ISO control code.
	 *
	 * @param __c The character to check.
	 * @return True if the character is an ISO control code.
	 * @since 2018/12/08
	 */
	public static boolean isISOControl(char __c)
	{
		return (__c >= 0 && __c <= 0x1F) || (__c >= 0x7F && __c <= 0x9F);
	}
	
	/**
	 * Returns true if the character is lowercase.
	 *
	 * Java ME only supports the Latin-1 characters.
	 *
	 * @param __c The character to check.
	 * @return True if the character is lowercase.
	 * @since 2018/12/08
	 */
	public static boolean isLowerCase(char __c)
	{
		// 0xF7 is Divide
		return ((__c >= 'a' && __c <= 'z') ||
			(__c != 0xF7 && __c >= 0xDF && __c <= 0xFF));
	}
	
	/**
	 * Returns true if the character is a space character.
	 *
	 * @param __c The character to check.
	 * @return True if the character is a space character.
	 * @since 2018/12/08
	 */
	public static boolean isSpaceChar(char __c)
	{
		return (__c == 0x09 || __c == 0x0A || __c == 0x0C || __c == 0x0D ||
			__c == 0x20);
	}
	
	/**
	 * Returns true if the character is uppercase.
	 *
	 * Java ME only supports the Latin-1 characters.
	 *
	 * @param __c The character to check.
	 * @return True if the character is uppercase.
	 * @since 2018/12/08
	 */
	public static boolean isUpperCase(char __c)
	{
		// 0xD7 is multiply
		return (__c >= 'A' && __c <= 'Z') ||
			(__c != 0xD7 && __c >= 0xC0 && __c <= 0xDE);
	}
	
	/**
	 * Returns true if this is a whitespace character according to Java.
	 *
	 * @param __c The character to check.
	 * @return True if the character is whitespace.
	 * @since 2018/12/08
	 */
	public static boolean isWhitespace(char __c)
	{
		switch (__c)
		{
			case 0x00A0:
			case 0x2007:
			case 0x202F:
			case 0x0009:
			case 0x000A:
			case 0x000B:
			case 0x000C:
			case 0x000D:
			case 0x001C:
			case 0x001D:
			case 0x001E:
			case 0x001F:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @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.
	 * @since 2018/10/13
	 */
	public static String toString(char __c)
	{
		return new String(new char[]{__c}, (short)0);
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @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.
	 * @since 2018/10/11
	 */
	@ImplementationNote("This is not cached.")
	public static Character valueOf(char __v)
	{
		return new Character(__v);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Class.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import cc.squirreljme.runtime.cldc.lang.ClassFlag;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This class is the in-language representation of a Java class, the CLDC
 * allows for minimal reflection via {@link Class#forName(String)} and
 * {@link Class#newInstance()}.
 *
 * @since 2018/12/08
 */
public final class Class<T>
{
	/** This is the prefix that is used for assertion checks. */
	private static final String _ASSERTION_PREFIX =
		"cc.squirreljme.runtime.noassert.";
	
	/** The class data storage. */
	final ClassData _data;
	
	/** Has the assertion status been checked already? */
	private volatile boolean _checkedassert;
	
	/** Is this class being asserted? */
	private volatile boolean _useassert;
	
	/** The display name of the class. */
	private Reference<String> _name;
	
	/** String representation of class. */
	private Reference<String> _string;
	
	/**
	 * Initializes the class with the class data.
	 *
	 * @param __d The data to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/04
	 */
	private Class(ClassData __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this._data = __d;
	}
	
	/**
	 * This checks whether the specified input class extends this class or
	 * implements an interface and then returns this class object which is
	 * "cast" to the specified type. Note that this does not change the
	 * returned value.
	 *
	 * @param <U> The sub-class to cast this class object to.
	 * @param __cl A class which is checked to see if it extends or implements
	 * this class.
	 * @return {@code this} except cast to the specified sub-class
	 * @throws ClassCastException If the specified class is not a sub-class of
	 * this class type.
	 * @throws NullPointerException On null arguments.
	 * @see Class#isAssignableFrom(Class)
	 * @since 2016/06/13
	 */
	@SuppressWarnings({"unchecked"})
	public <U> Class<? extends U> asSubclass(Class<U> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0v The specifed class is not a sub-class
		// of this class. (The class being checked; The current class)}
		if (!this.isAssignableFrom(__cl))
			throw new ClassCastException(
				String.format("ZZ0v %s %s", __cl, this));
		
		return (Class<? extends U>)this;
	}
	
	/**
	 * Casts the object to this class, checking it.
	 *
	 * @param __o The object to cast.
	 * @return The casted object.
	 * @throws ClassCastException If the type is not matched.
	 * @since 2018/09/29
	 */
	@SuppressWarnings({"unchecked"})
	public T cast(Object __o)
		throws ClassCastException
	{
		// Null always casts OK
		if (__o == null)
			return null;
		
		// {@squirreljme.error ZZ0w The other class cannot be casted to this
		// class. (This class; The other class)}
		Class<?> other = __o.getClass();
		if (!this.isAssignableFrom(other))
			throw new ClassCastException("ZZ0w " + this.getName() + " " +
				other.getName());
		
		return (T)__o;
	}
	
	/**
	 * Returns whether or not assertions should be enabled in the specified
	 * class, this is used internally by the virtual machine to determine if
	 * assertions should fail or not.
	 *
	 * In SquirrelJME, this defaults to returning {@code true}. To disable
	 * assertions for a class or an entire package then the following system
	 * property may be specified to disable them:
	 * {@code cc.squirreljme.noassert.(package)(.class)=true}.
	 *
	 * @return In SquirrelJME this returns by default {@code true}, otherwise
	 * this may return {@code false} if they are disabled for a class.
	 * @since 2016/06/13
	 */
	public boolean desiredAssertionStatus()
	{
		// If assertions have been checked, they do not have to be rechecked
		if (this._checkedassert)
			return this._useassert;
		
		// Otherwise check it
		return this.__checkAssertionStatus();
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2018/09/22
	 */
	public String getName()
	{
		Reference<String> ref = this._name;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			String bn = this._data.binaryName();
			
			// Slashes become dots
			this._name = new WeakReference<>((rv = bn.replace('/', '.')));
		}
		
		return rv;
	}
	
	/**
	 * Obtains a resource from the classpath which exists within a JAR file,
	 * inside of a directory, or in a prepacked resource. If a resource needs
	 * to be obtain from another class which exists in another JAR file then
	 * this method must be called from a class in that JAR.
	 *
	 * In the Java ME environment, one should not rely on getting resources
	 * which are executable class files (files ending in .class). These class
	 * files may be deleted during native compilation. This however should not
	 * be relied upon.
	 *
	 * Using this method on the classes for primitive types ({@code int.class})
	 * and using a relative name will always result in the path being treated
	 * as absolute.
	 *
	 * Relative paths are converted to absolute paths by appending the name
	 * to the binary name of the class package.
	 *
	 * @param __name The name of the resource to find, if this starts with a
	 * forward slash {@code '/'} then it is treated as an absolute path.
	 * Otherwise a resource will be derived from the calling class.
	 * @return A stream to the given resource or {@code null} if one was not
	 * found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/01
	 */
	public InputStream getResourceAsStream(String __name)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Do not lookup blank resources
		if (__name.isEmpty())
			return null;
		
		// This is not within any JAR, so nothing will ever be found
		String injar = this._data.inJar();
		if (injar == null)
			return null;
		
		// Absolute paths are not translated
		String want;
		if (__name.startsWith("/"))
			want = __name.substring(1);
		
		// Otherwise append to the binary name
		else
		{
			// Has a package
			String pkg = this._data.binaryName();
			int ld = pkg.lastIndexOf('/');
			if (ld >= 0)
				want = pkg.substring(0, ld + 1) + __name;
			
			// Is in default package
			else
				want = __name;
		}
		
		// Open the resource, perhaps
		InputStream rv = ResourceInputStream.open(injar, want);
		if (rv != null)
			return rv;
		
		// Otherwise, do a traditional back to front search for the resource
		// since it might be in another JAR
		String[] classpath = SuiteAccess.currentClassPath();
		for (int i = classpath.length - 1; i >= 0; i--)
			if (null != (rv = ResourceInputStream.open(classpath[i], want)))
				return rv;
		
		// Not found
		return null;
	}
	
	/**
	 * Returns the class which is the superclass of this class.
	 *
	 * @return The superclass or {@code null} if there is none.
	 * @since 2017/03/29
	 */
	@SuppressWarnings({"unchecked"})
	public Class<? super T> getSuperclass()
	{
		return (Class<? super T>)((Object)this._data.superClass());
	}
	
	/**
	 * Returns {@code true} if this class represents an array type.
	 *
	 * @return {@code true} if this class represents an array type.
	 * @since 2016/06/16
	 */
	public boolean isArray()
	{
		// Guess what! Every array starts with with brackets so this is quite
		// easily something which can be determined from the classname
		return this._data.binaryName().startsWith("[");
	}
	
	/**
	 * Checks if the given class can be assigned to this one, the check is
	 * in the same order as {code instanceOf Object} that is
	 * {@code a.getClass().isAssignableFrom(b.getClass()) == (a instanceof b)}.
	 *
	 * @param __cl The other class type.
	 * @return If the otehr class can be assigned to this one.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/27
	 */
	public boolean isAssignableFrom(Class<?> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Go through target superclasses to find this class
		for (Class<?> r = __cl; r != null; r = r._data.superClass())
		{
			if (r == this)
				return true;
		
			// Go through interfaces for the class to find this class
			for (Class<?> i : r._data.interfaceClasses())
				if (i == this)
					return true;
		}
		
		// If this is an array and the other type is an array with the same
		// number of dimensions, then compare the base type so that say
		// Number[] is assignable from Integer[].
		int thisdims = this._data.dimensions(),
			otherdims = __cl._data.dimensions();
		if (thisdims > 0 && thisdims == otherdims)
			if (this.__rootType().isAssignableFrom(__cl.__rootType()))
				return true;
		
		// Not assignable
		return false;
	}
	
	/**
	 * Is this class an interface?
	 *
	 * @return If this is an interface.
	 * @since 2018/11/03
	 */
	public boolean isInterface()
	{
		return (this._data.flags() & ClassFlag.INTERFACE) != 0;
	}
	
	/**
	 * Checks if the given class is an instance of this class.
	 *
	 * @param __o The object to check.
	 * @return If the given object is an instance of this class.
	 * @since 2018/09/27
	 */
	public boolean isInstance(Object __o)
	{
		// Null will never be an instance
		if (__o == null)
			return false;
		
		// This is in the same form
		return this.isAssignableFrom(__o.getClass());
	}
	
	/**
	 * Constructs a new instance of this class.
	 *
	 * @throws InstantiationException If the default constructor cannot be
	 * accessed by the calling method.
	 * @throws IllegalAccessException If the class or constructor could not
	 * be accessed.
	 * @return The newly created instance.
	 * @since 2018/12/04
	 */
	@SuppressWarnings({"unchecked"})
	public T newInstance()
		throws InstantiationException, IllegalAccessException
	{
		todo.TODO.note("Implement newInstance() access checks.");
		
		return (T)((Object)this.__newInstance());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Based on the binary name
			String binaryname = this._data.binaryName();
			switch (binaryname)
			{
					// Primitive types have the same binary name
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
				case "long":
				case "float":
				case "double":
					rv = binaryname;
					break;
				
					// Otherwise build a string
				default:
					rv = (this.isInterface() ? "interface " : "class ") +
						this.getName(); 
					break;
			}
			
			// Cache it
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * This checks whether assertions should be **disabled** for this class (or
	 * for the entire package).
	 *
	 * @return The assertions status to use.
	 * @since 2016/10/09
	 */
	private final boolean __checkAssertionStatus()
	{
		// Default to true
		boolean rv = true;
		
		// Determine class name
		String cn = this.getName();
		String prop = Class._ASSERTION_PREFIX + cn;
		
		// Disabled for this class?
		if (Boolean.getBoolean(prop))
			rv = false;
		
		// Disabled for this package?
		else
		{
			// Find last dot, if there is none then this is just the default
			// package so never bother checking the package
			int ld = cn.lastIndexOf('.');
			if (ld > 0 && Boolean.getBoolean(prop.substring(0,
				prop.length() - (cn.length() - ld))))
				rv = false;
		}
		
		// Set as marked
		this._checkedassert = true;
		this._useassert = rv;
		return rv;
	}
	
	/**
	 * Returns the class data.
	 *
	 * SpringCoat depends on this method to exist.
	 *
	 * @return The class data.
	 * @since 2018/12/05
	 */
	final ClassData __classData()
	{
		return this._data;
	}
	
	/**
	 * Constructs a new instance of this class.
	 *
	 * @throws InstantiationException If the default constructor cannot be
	 * accessed by the calling method.
	 * @throws IllegalAccessException If the class or constructor could not
	 * be accessed.
	 * @since 2018/12/04
	 */
	final Object __newInstance()
		throws InstantiationException, IllegalAccessException
	{
		// Get class details
		ClassData data = this._data;
		String binaryname = data.binaryName();
		
		// {@squirreljme.error ZZ0x Cannot construct new instance of class
		// because it has no default constructor.}
		StaticMethod sm = data.defaultConstructorMethod();
		if (sm == null)
			throw new InstantiationException("ZZ0x " + binaryname);
		
		// Allocate class instance
		Object rv = ObjectAccess.allocateObject(binaryname);
		
		// {@squirreljme.error ZZ0y Could not allocate new instance.}
		if (rv == null)
			throw new OutOfMemoryError("ZZ0y");
		
		// Call default constructor
		ObjectAccess.invokeStatic(sm, rv);
		
		// All done!
		return rv;
	}
	
	/**
	 * Returns the root type, the base of the component.
	 *
	 * @return The root type of this type.
	 * @since 2018/09/27
	 */
	private final Class<?> __rootType()
	{
		Class<?> rv = this;
		for (Class<?> r = this; r != null; r = r._data.component())
			rv = r;
		return rv;
	}
	
	/**
	 * Locates the class with the given name and returns it, otherwise an
	 * exception is thrown.
	 *
	 * The expected form of the class is a name as is mostly used in the
	 * Java language ({@code some.package.Foo}) and not one that is internal
	 * to the virtual machine except in the case of an array. Inner classes do
	 * not follow dot notation, an inner class is usually separated by a dollar
	 * sign '$'. For example {@code Map.Entry} is {@code java.util.Map$Entry}.
	 *
	 * If an array is requested then it must only be of a primitive type using
	 * a Java internal type descriptor.
	 *
	 * @param __n The name of the class to find.
	 * @return The class with the given name.
	 * @throws ClassNotFoundException If the given class was not found.
	 * @throws NullPointerException If no name was specified.
	 * @since 2016/03/01
	 */
	public static Class<?> forName(String __n)
		throws ClassNotFoundException
	{
		// No class specified
		if (__n == null)
			throw new NullPointerException();
		
		// The name will have to be converted to binary form since that is
		// what is internally used
		Class<?> rv = ObjectAccess.classByName(__n.replace('.', '/'));
		
		// {@squirreljme.error ZZ0z Could not find the specified class. (The
		// name of the class)}
		if (rv == null)
			throw new ClassNotFoundException(String.format("ZZ0z %s", __n));
		return rv;
	}
}

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

package java.lang;

/**
 * This is thrown when a class cannot be cast to another class.
 *
 * @since 2018/12/04
 */
public class ClassCastException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassCastException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public ClassCastException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when the format of a class is not valid.
 *
 * @since 2018/12/04
 */
public class ClassFormatError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassFormatError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public ClassFormatError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when a class has not been found.
 *
 * @since 2018/12/04
 */
public class ClassNotFoundException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public ClassNotFoundException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public ClassNotFoundException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * This returns the cause of the exception.
	 *
	 * @return The cause of the exception.
	 * @since 2018/12/04
	 */
	public Throwable getException()
	{
		return this.getCause();
	}
}

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

package java.lang;

/**
 * This is thrown when cloning is not supported for the given object.
 *
 * @since 2018/12/04
 */
public class CloneNotSupportedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Cloneable.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This represents an object which may be cloned via the {@link Object#clone()}
 * method.
 *
 * @since 2018/12/07
 */
public interface Cloneable
{
}

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

package java.lang;

/**
 * This interface is used to set two classes as being comparable to other
 * classes.
 *
 * It is not required to but comparisons performed by this interface should
 * be comparable to {@link Object#equals(Object)} so that
 * {@code a.equals(b) == (a.compareTo(b) == 0)}.
 *
 * It is recommended to implement this class so that
 * {@code a.compareTo(b) == -b.compareTo(a)} is true, this makes the
 * comparisons consistent. However this might not be feasible for speed
 * purposes so it is highly recommended to at least have comparible negative,
 * zero, and positive.
 *
 * @param <T> The type to compare.
 * @since 2018/09/19
 */
public interface Comparable<T>
{
	/**
	 * Compares this instance to the argument passed, 
	 *
	 * Note that {@code NullPointerException} should be thrown for {@code __b}
	 * since {@code __b.compareTo(this)} would thrown an exception.
	 *
	 * @param __b The object to compare against.
	 * @return The result of the comparison, negative values mean
	 * {@code this < __b}, zero means {@code this == __b}, and positive values
	 * mean {@code this > __b}.
	 * @since 2018/09/19
	 */
	int compareTo(T __b);
}


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

package java.lang;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which may be attached to classes, fields,
 * and methods to indicate that it should no longer be used in the future and
 * alternatives should be searched for and used instead.
 *
 * @since 2016/04/12
 */
@Documented
@Retention(value=RetentionPolicy.RUNTIME)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface Deprecated
{
}

Added modules/cldc-compact/src/main/java/java/lang/Double.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

public final class Double
	extends Number
	implements Comparable<Double>
{
	public static final int MAX_EXPONENT =
		1023;
	
	public static final double MAX_VALUE =
		+0x1.FFFFFFFFFFFFFp1023D;
	
	public static final int MIN_EXPONENT =
		-1022;
	
	public static final double MIN_NORMAL =
		+0x1.0p-1022D;
	
	public static final double MIN_VALUE =
		+0x0.0000000000001p-1022D;
	
	public static final double NEGATIVE_INFINITY =
		Double.longBitsToDouble(-4503599627370496L);
	
	public static final double NaN =
		Double.longBitsToDouble(9221120237041090560L);
	
	public static final double POSITIVE_INFINITY =
		Double.longBitsToDouble(9218868437227405312L);
	
	/** The number of bits double requires for storage. */
	public static final int SIZE =
		64;
	
	/** The class representing the primitive type. */
	public static final Class<Double> TYPE =
		ObjectAccess.<Double>classByNameType("double");
	
	/** The mask for NaN values. */
	private static final long _NAN_MASK =
		0b0111111111111000000000000000000000000000000000000000000000000000L;
	
	/** The value for this double. */
	private final double _value;
	
	public Double(double __a)
	{
		throw new todo.TODO();
	}
	
	public Double(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Double __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int hashCode()
	{
		long v = this.doubleToLongBits(this._value); 
		return (int)(v ^ (v >>> 32));
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInfinite()
	{
		throw new todo.TODO();
	}
	
	public boolean isNaN()
	{
		throw new todo.TODO();
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static int compare(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the bits which represent the double value with all NaN values
	 * collapsed into a single form.
	 *
	 * @param __v The input value.
	 * @return The bits for the value.
	 * @since 2018/11/04
	 */
	public static long doubleToLongBits(double __v)
	{
		long raw = Double.doubleToRawLongBits(__v);
		
		// Collapse all NaN values to a single form
		if ((raw & Double._NAN_MASK) == (Double._NAN_MASK))
			return Double._NAN_MASK;
		
		return raw;
	}
	
	/**
	 * Returns the raw bits which represent the double value.
	 *
	 * @param __v The input value.
	 * @return The raw bits for the value.
	 * @since 2018/11/03
	 */
	public static long doubleToRawLongBits(double __v)
	{
		return Assembly.doubleToRawLongBits(__v);
	}
	
	public static boolean isInfinite(double __a)
	{
		throw new todo.TODO();
	}
	
	public static boolean isNaN(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the given long bits to a double.
	 *
	 * Note that this value might be modified depending on the platform if
	 * the platform based conversion cannot handle signaling NaNs or illegal
	 * floating point values.
	 *
	 * @param __b The bits to convert.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static double longBitsToDouble(long __b)
	{
		return Assembly.longBitsToDouble(__b);
	}
	
	public static double parseDouble(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static String toString(double __a)
	{
		throw new todo.TODO();
	}
	
	public static Double valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Double valueOf(double __a)
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Enum.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
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
191
192
193
194
195
196
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.lang.ClassData;

/**
 * This is the base class for enum types.
 *
 * @param <E> The enum type.
 * @since 2018/09/24
 */
public abstract class Enum<E extends Enum<E>>
	implements Comparable<E>
{
	/** The name of the enum. */
	private final String _name;
	
	/** The ordinal of the enumeration. */
	private final int _ordinal;
	
	/**
	 * Initializes the enum properties.
	 *
	 * @param __s The enum name.
	 * @param __o The enum ordinal.
	 * @throws IllegalArgumentException If the ordinal is negative.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/24
	 */
	protected Enum(String __s, int __o)
		throws IllegalArgumentException, NullPointerException
	{
		// {@squirreljme.error ZZ10 Enum has no string.}
		if (__s == null)
			throw new NullPointerException("ZZ10");
		
		// {@squirreljme.error ZZ11 Enum has negative ordinal.}
		if (__o < 0)
			throw new IllegalArgumentException("ZZ11");
		
		this._name = __s;
		this._ordinal = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	protected final Object clone()
		throws CloneNotSupportedException
	{
		// {@squirreljme.error ZZ12 Enums cannot be cloned.}
		throw new CloneNotSupportedException("ZZ12");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int compareTo(E __o)
		throws ClassCastException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ13 Cannot compare enums of a different
		// type.}
		if (this.getDeclaringClass() != __o.getDeclaringClass())
			throw new ClassCastException("ZZ13");
		
		// Just ordinal subtraction
		return this.ordinal() - __o.ordinal();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class that declares this enum, this may be different from
	 * {@link Object#getClass()}.
	 *
	 * @return The declaring class of this enum.
	 * @since 2018/09/24
	 */
	@SuppressWarnings({"unchecked"})
	public final Class<E> getDeclaringClass()
	{
		// Enums are either directly extending or extending a base class which
		// then extends this class, so we just need to look a few places up
		// the tree
		Class<?> me = this.getClass(),
			ext = me.getSuperclass();
		if (ext == Enum.class)
			return (Class<E>)((Object)me);
		return (Class<E>)((Object)ext);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int hashCode()
	{
		return super.hashCode();
	}
	
	/**
	 * Returns the name of the constant.
	 *
	 * @return The constant name.
	 * @since 2018/09/24
	 */
	public final String name()
	{
		return this._name;
	}
	
	/**
	 * Returns the ordinal of the constant.
	 *
	 * @return The ordinal constant.
	 * @since 2018/09/24
	 */
	public final int ordinal()
	{
		return this._ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public String toString()
	{
		return this._name;
	}
	
	/**
	 * From the given enumeration, find a value which matches the given name.
	 *
	 * @param <T> The enumeration type to search in.
	 * @param __cl The class to lookup.
	 * @param __s The string to search for.
	 * @return The enumeration value.
	 * @throws IllegalArgumentException If the value was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static <T extends Enum<T>> T valueOf(Class<T> __cl, String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Get the data for this class because the enum information will be
		// in here somewhere
		ClassData data = ObjectAccess.classData(__cl);
		
		// {@squirreljme.error ZZ14 Cannot get the value of a non-enumeration
		// type or it has no implicit {@code values()} method.}
		StaticMethod getvalues = data.enumValues();
		if (getvalues == null)
			throw new ClassCastException("ZZ14");
		
		// Go through and check all the names
		for (Enum e : (Enum[])ObjectAccess.invokeStatic(getvalues))
			if (__s.equals(e.name()))
				return __cl.cast(e);
		
		// {@squirreljme.error ZZ15 Not an enumeration value. (The value)}
		throw new IllegalArgumentException(String.format("ZZ15 %s", __s));
	}
}

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

package java.lang;

/**
 * This is the base class for non-checked errors.
 *
 * @since 2016/02/26
 */
public class Error
	extends Throwable
{
	/**
	 * Initializes the error with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Error()
	{
	}
	
	/**
	 * Initializes the error with a message and no cause.
	 *
	 * @param __m The message to use.
	 * @since 2018/09/16
	 */
	public Error(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with a message and the given cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause of this error.
	 * @since 2018/09/16
	 */
	public Error(String __m, Throwable __t)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with no message and the given cause.
	 *
	 * @param __t The cause of this error.
	 * @since 2018/09/16
	 */
	public Error(Throwable __t)
	{
		super(__t);
	}
}

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

package java.lang;

/**
 * For any exceptions which extend this class and not {@link RuntimeException}
 * they will act as checked exceptions by the compiler, thus they will need
 * to be handled accordingly.
 *
 * @since 2018/09/16
 */
public class Exception
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Exception()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public Exception(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Float.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

public final class Float
	extends Number
	implements Comparable<Float>
{
	public static final int MAX_EXPONENT =
		127;
	
	public static final float MAX_VALUE =
		+0x1.FFFFFEp127F;
	
	public static final int MIN_EXPONENT =
		-126;
	
	public static final float MIN_NORMAL =
		+0x1.0p-126F;
	
	public static final float MIN_VALUE =
		+0x1.0p-149F;
	
	public static final float NEGATIVE_INFINITY =
		Float.intBitsToFloat(-8388608);
	
	public static final float NaN =
		Float.intBitsToFloat(2143289344);
	
	public static final float POSITIVE_INFINITY =
		Float.intBitsToFloat(2139095040);
	
	/** The number of bits float requires for storage. */
	public static final int SIZE =
		32;
	
	/** The mask for NaN values. */
	private static final int _NAN_MASK =
		0b0111_1111_1000_0000_0000_0000_0000_0000;
	
	/** The class representing the primitive type. */
	public static final Class<Float> TYPE =
		JVMFunction.<Float>jvmLoadClass(Assembly.classInfoOfFloat());
	
	/** The stored value. */
	private final float _value;
	
	/**
	 * Stores the specified float.
	 *
	 * @param __v The value to store.
	 * @since 2018/11/04
	 */
	public Float(float __v)
	{
		this._value = __v;
	}
	
	public Float(double __a)
	{
		throw new todo.TODO();
	}
	
	public Float(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Float __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	@ProgrammerTip("NaN values are equal to each other, positive and " +
		"negative zero are not equal to each other.")
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Float))
			return false;
		
		float a = this._value,
			b = ((Float)__o)._value;
		
		// Both values are NaN, consider it equal
		if (Float.isNaN(a) && Float.isNaN(b))
			return true;
		
		// If both values are zero, the sign is important
		int ra = Float.floatToRawIntBits(a),
			rb = Float.floatToRawIntBits(b);
		if ((ra & 0x7FFFFFFF) == 0 && (rb & 0x7FFFFFFF) == 0)
			return ra == rb;
		
		// Otherwise standard comparison
		return a == b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public float floatValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int hashCode()
	{
		return Float.floatToIntBits(this._value);
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInfinite()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this the NaN value.
	 *
	 * @return If this is the NaN value.
	 * @since 2018/11/04
	 */
	public boolean isNaN()
	{
		return Float.isNaN(this._value);
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static int compare(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the specified float into its integer bit form with NaNs losing
	 * all their signaling and turning into non-signaling NaNs.
	 *
	 * @param __v The value the get the bit representation of.
	 * @return The bit representation of the float.
	 * @since 2018/11/04
	 */
	public static int floatToIntBits(float __v)
	{
		int raw = Float.floatToRawIntBits(__v);
		
		// Collapse all NaN values to a single form
		if ((raw & Float._NAN_MASK) == (Float._NAN_MASK))
			return Float._NAN_MASK;
		
		return raw;
	}
	
	/**
	 * Converts the specified float into its raw integer bit form.
	 *
	 * @param __v The input value.
	 * @return The bits that make up the float.
	 * @since 2018/11/04
	 */
	public static int floatToRawIntBits(float __v)
	{
		return Assembly.floatToRawIntBits(__v);
	}
	
	/**
	 * Converts the specified integer bits into a floating point value.
	 *
	 * Note that this value might be modified depending on the platform if
	 * the platform based conversion cannot handle signaling NaNs or illegal
	 * floating point values.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static float intBitsToFloat(int __b)
	{
		return Assembly.intBitsToFloat(__b);
	}
	
	public static boolean isInfinite(float __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is the specified value a NaN?
	 *
	 * @param __v The value to check.
	 * @return If it is NaN or not.
	 * @since 2018/11/04
	 */
	public static boolean isNaN(float __v)
	{
		return (Float.floatToRawIntBits(__v) & Float._NAN_MASK) == Float._NAN_MASK;
	}
	
	public static float parseFloat(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static String toString(float __a)
	{
		throw new todo.TODO();
	}
	
	public static Float valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the boxed representation of the given float.
	 *
	 * @param __v The float value.
	 * @return The boxed float.
	 * @since 2018/11/04
	 */
	public static Float valueOf(float __v)
	{
		return new Float(__v);
	}
}

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

package java.lang;

/**
 * This is thrown when access is denied.
 *
 * @since 2018/12/04
 */
public class IllegalAccessException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalAccessException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IllegalAccessException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when the argument of a method is not correct.
 *
 * @since 2018/10/12
 */
public class IllegalArgumentException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public IllegalArgumentException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(Throwable __t)
	{
		super(__t);
	}
}

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

package java.lang;

/**
 * This is usually thrown when an attempt is made to use a monitor which is
 * not owned by the current thread.
 *
 * @since 2018/12/04
 */
public class IllegalMonitorStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when a certain state is invalid.
 *
 * @since 2018/12/04
 */
public class IllegalStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(Throwable __t)
	{
		super(__t);
	}
}

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

package java.lang;

/**
 * This is thrown when the state of a thread is not valid.
 *
 * @since 2018/02/21
 */
public class IllegalThreadStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message.
	 *
	 * @since 2018/02/21
	 */
	public IllegalThreadStateException()
	{
	}
	
	/**
	 * Initializes the exception with the specified message.
	 *
	 * @param __m The message to use.
	 * @since 2018/02/21
	 */
	public IllegalThreadStateException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when a class has changed and when that change is no longer
 * compatible.
 *
 * @since 2018/12/04
 */
public class IncompatibleClassChangeError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IncompatibleClassChangeError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IncompatibleClassChangeError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when an index which is not within bounds was accessed.
 *
 * @since 2018/09/16
 */
public class IndexOutOfBoundsException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public IndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public IndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when an instance could not be instantiated.
 *
 * @since 2018/12/04
 */
public class InstantiationException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public InstantiationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public InstantiationException(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Integer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a boxed {@code int} value.
 *
 * @since 2019/05/11
 */
public final class Integer
	extends Number
	implements Comparable<Integer>
{
	/** The maximum value. */
	public static final int MAX_VALUE =
		2147483647;
	
	/** The minimum value. */
	public static final int MIN_VALUE =
		-2147483648;
	
	/** The number of bits this uses. */
	public static final int SIZE =
		32;
	
	/** The class type representing the primitive type. */
	public static final Class<Integer> TYPE =
		ObjectAccess.<Integer>classByNameType("int");
	
	/** The value of this integer. */
	private final int _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the integer with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Integer(int __v)
	{
		this._value = __v;
	}
	
	/**
	 * Parses the given string and initializes the integer value, it is
	 * parsed the same as {@code Integer.parseInt(__v, 10)}.
	 *
	 * @param __v The value to parse.
	 * @throws NullPointerException On null arguments.
	 * @throws NumberFormatException If the number is not valid.
	 * @since 2019/05/11
	 */
	public Integer(String __v)
		throws NullPointerException, NumberFormatException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this._value = Integer.parseInt(__v, 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public byte byteValue()
	{
		return (byte)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/10
	 */
	@Override
	public int compareTo(Integer __b)
	{
		int a = this._value,
			b = __b;
		
		if (a == b)
			return 0;
		else if (a < b)
			return -1;
		else
			return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public double doubleValue()
	{
		return (double)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Integer))
			return false;
		
		return this._value == ((Integer)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public float floatValue()
	{
		return (float)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/12
	 */
	@Override
	public int intValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public short shortValue()
	{
		return (short)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Integer.toString(this._value)));
		
		return rv;
	}
	
	/**
	 * Returns the number of bits which are in the value, this is the
	 * population count.
	 *
	 * @param __v The value to count.
	 * @return The number of bits set in the value.
	 * @since 2018/11/11
	 */
	public static int bitCount(int __v)
	{
		__v = __v - ((__v >>> 1) & 0x55555555);
		__v = (__v & 0x33333333) + ((__v >>> 2) & 0x33333333);
		return ((__v + (__v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24;
	}
	
	/**
	 * Decodes the input string for an integer value.
	 *
	 * There is an optional sign: {@code -} or {@code +}.
	 *
	 * Then the number may be prefixed by:
	 * {@code 0x}, {@code 0X}, or {@code #} for hexadecimal,
	 * {@code 0} for octal. If there is no prefix then the number is treated
	 * as decimal.
	 *
	 * @param __s The input string to decode.
	 * @return The decoded integer.
	 * @throws NullPointerException On null arguments.
	 * @throws NumberFormatException If the string is of an incorrect value.
	 * @since 2018/11/11
	 */
	public static Integer decode(String __s)
		throws NullPointerException, NumberFormatException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ16 Cannot decode an empty string.}
		if (__s.isEmpty())
			throw new NumberFormatException("ZZ16");
		
		// It may be changed!
		String orig = __s;
		
		// Check for sign, assume positive otherwise
		char sign = __s.charAt(0);
		if (sign != '-' && sign != '+')
			sign = '+';
		
		// Remove the sign
		else
			__s = __s.substring(1);
		
		// Which number format?
		int radix;
		if (__s.startsWith("0x") || __s.startsWith("0X"))
		{
			radix = 16;
			__s = __s.substring(2);
		}
		else if (__s.startsWith("#"))
		{
			radix = 16;
			__s = __s.substring(1);
		}
		else if (__s.startsWith("0"))
		{
			radix = 8;
			__s = __s.substring(1);
		}
		else
			radix = 10;
		
		// {@squirreljme.error ZZ17 Misplaced sign. (The input string)}
		if (__s.startsWith("-") || __s.startsWith("+"))
			throw new NumberFormatException("ZZ2p " + orig);
		
		// Decode value with radix
		try
		{
			return Integer.parseInt(sign + __s, radix);
		}
		
		// {@squirreljme.error ZZ18 Could not parse number. (The input string)}
		catch (NumberFormatException e)
		{
			RuntimeException t = new NumberFormatException("ZZ18 " + orig);
			t.initCause(e);
			throw t;
		}
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key)
		throws NumberFormatException, SecurityException
	{
		return Integer.getInteger(__key, null);
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @param __def The default value.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key, int __def)
		throws NumberFormatException, SecurityException
	{
		Integer rv = Integer.getInteger(__key, null);
		if (rv == null)
			return __def;
		return rv;
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @param __def The default value.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key, Integer __def)
		throws NumberFormatException, SecurityException
	{
		// If there is no property, use the default
		String prop = System.getProperty(__key);
		if (prop == null)
			return __def;
		
		// Otherwise decode the value
		return Integer.decode(prop);
	}
	
	public static int highestOneBit(int __a)
	{
		throw new todo.TODO();
	}
	
	public static int lowestOneBit(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of leading zeros in the bit representation.
	 *
	 * @param __v The value to process.
	 * @return The number of leading zeros.
	 * @since 2019/04/14
	 */
	public static int numberOfLeadingZeros(int __v)
	{
		// From https://stackoverflow.com/a/23857066/11286149
		__v = __v | (__v >>> 1);
		__v = __v | (__v >>> 2);
		__v = __v | (__v >>> 4);
		__v = __v | (__v >>> 8);
		__v = __v | (__v >>> 16);
		
		return Integer.bitCount(~__v);
	}
	
	/**
	 * Returns the number of zeros which trail on the right side.
	 *
	 * @param __v The value to check.
	 * @return The number of trailing zeros.
	 * @since 2018/11/11
	 */
	public static int numberOfTrailingZeros(int __v)
	{
		// c will be the number of zero bits on the right
		int c = 32;
		__v &= -__v;
		
		if ((__v) != 0)
			c--;
		
		if ((__v & 0x0000FFFF) != 0)
			c -= 16;
			
		if ((__v & 0x00FF00FF) != 0)
			c -= 8;
		
		if ((__v & 0x0F0F0F0F) != 0)
			c -= 4;
		
		if ((__v & 0x33333333) != 0)
			c -= 2;
		
		if ((__v & 0x55555555) != 0)
			c -= 1;
		
		return c;
	}
	
	/**
	 * Returns the value of the specified string using the given radix.
	 *
	 * @param __v The String to decode.
	 * @param __r The radix to use.
	 * @return The resulting integer.
	 * @throws NumberFormatException If the string is not valid or the radix
	 * is outside of the valid bounds.
	 * @since 2018/10/12
	 */
	public static int parseInt(String __v, int __r)
		throws NumberFormatException
	{
		// {@squirreljme.error ZZ19 The radix is out of bounds. (The radix)}
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			throw new NumberFormatException("ZZ19 " + __r);
		
		// {@squirreljme.error ZZ1a String is null or has zero length.}
		int n = __v.length();
		if (__v == null || n <= 0)
			throw new NumberFormatException("ZZ1a");
		
		// Detect sign
		boolean neg = false,
			signed = false;
		char c = __v.charAt(0);
		if ((neg = (c == '-')) || c == '+')
			signed = true;
		
		// If the number is negative, instead of negating the value at the end
		// just subtract digits instead.
		int digsign = (neg ? -1 : 1);
		
		// Read all digits
		int rv = 0;
		for (int i = (signed ? 1 : 0); i < n; i++)
		{
			// Read character
			c = __v.charAt(i);
			
			// Convert to digit
			int dig = Character.digit(c, __r);
			
			// {@squirreljme.error ZZ1b Character out of range of radix.
			// (The input string; The out of range character)}
			if (dig < 0)
				throw new NumberFormatException("ZZ1b " + __v + " " + c);
			
			// {@squirreljme.error ZZ1c Input integer out of range of 32-bit
			// integer. (The input string)}
			int prod = rv * __r;
			if (rv != 0 && (neg ? (prod > rv) : (prod < rv)))
				throw new NumberFormatException("ZZ1c " + __v);
			
			// Add up
			rv = prod + (dig * digsign);
		}
		
		return rv;
	}
	
	/**
	 * Returns the value of the specified string.
	 *
	 * @param __v The String to decode.
	 * @return The parsed integer.
	 * @throws NumberFormatException If the string is not valid.
	 * @since 2018/10/12
	 */
	public static int parseInt(String __v)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, 10);
	}
	
	/**
	 * Reverses all of the bits in the given integer.
	 *
	 * @param __i The input value.
	 * @return The integer but with the bits reversed.
	 * @since 2018/11/11
	 */
	@ImplementationNote("Taken from " +
		"<http://aggregate.org/MAGIC/#Bit%20Reversal>.")
	public static int reverse(int __i)
	{
		__i = (((__i & 0xAAAAAAAA) >>> 1) | ((__i & 0x55555555) << 1));
		__i = (((__i & 0xCCCCCCCC) >>> 2) | ((__i & 0x33333333) << 2));
		__i = (((__i & 0xF0F0F0F0) >>> 4) | ((__i & 0x0F0F0F0F) << 4));
		__i = (((__i & 0xFF00FF00) >>> 8) | ((__i & 0x00FF00FF) << 8));
		
		return ((__i >>> 16) | (__i << 16));
	}
	
	public static int reverseBytes(int __i)
	{
		throw new todo.TODO();
	}
	
	public static int rotateLeft(int __i, int __d)
	{
		throw new todo.TODO();
	}
	
	public static int rotateRight(int __i, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the sign of the given integer value, this will be {@code -1}
	 * for negative values, {@code 0} for zero, and {@code 1} for positive
	 * values.
	 *
	 * @param __v The value to get the sign for.
	 * @return The sign of the given value.
	 * @since 2019/05/11
	 */
	public static int signum(int __v)
	{
		if (__v < 0)
			return -1;
		else if (__v > 1)
			return 1;
		else
			return 0;
	}
	
	public static String toBinaryString(int __a)
	{
		throw new todo.TODO();
	}
	
	public static String toHexString(int __a)
	{
		throw new todo.TODO();
	}
	
	public static String toOctalString(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(int __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Calls {@link Integer#toString(int, int)} with a radix of 10.
	 *
	 * @param __v The input value.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(int __v)
	{
		return Integer.toString(__v, 10);
	}
	
	/**
	 * Returns the value of the specified string using the given radix.
	 *
	 * @param __v The String to decode.
	 * @param __r The radix to use.
	 * @return The boxed value.
	 * @throws NumberFormatException If the string is not valid or the radix
	 * is outside of the valid bounds.
	 * @since 2018/10/12
	 */
	public static Integer valueOf(String __v, int __r)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, __r);
	}
	
	/**
	 * Returns the value of the specified string.
	 *
	 * @param __v The String to decode.
	 * @return The boxed value.
	 * @throws NumberFormatException If the string is not valid.
	 * @since 2018/10/12
	 */
	public static Integer valueOf(String __v)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, 10);
	}
	
	/**
	 * Returns a instance of the given value, this may be cached.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/09/23
	 */
	@ImplementationNote("This is not cached.")
	public static Integer valueOf(int __v)
	{
		return new Integer(__v);
	}
}

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

package java.lang;

/**
 * This is thrown when a thread is interrupted.
 *
 * Note that this does not clear the interrupt status of a thread.
 *
 * @since 2018/11/21
 */
public class InterruptedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/21
	 */
	public InterruptedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/21
	 */
	public InterruptedException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

import java.util.Iterator;

/**
 * This represents a class which can be iterated through giving one or more
 * values.
 *
 * @param <T> The type this returns.
 * @since 2018/12/08
 */
public interface Iterable<T>
{
	/**
	 * Returns the iterator over the object.
	 *
	 * @return The object iterator.
	 * @since 2018/12/08
	 */
	Iterator<T> iterator();
}

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

package java.lang;

/**
 * This is thrown when a class could not be linked into the virtual machine.
 *
 * @since 2018/12/04
 */
public class LinkageError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public LinkageError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public LinkageError(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Long.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

public final class Long
	extends Number
	implements Comparable<Long>
{
	/** The maximum value. */
	public static final long MAX_VALUE =
		9223372036854775807L;
	
	/** The minimum value. */
	public static final long MIN_VALUE =
		-9223372036854775808L;
	
	/** The size of the type in bits. */
	public static final int SIZE =
		64;
	
	/** The class representing the primitive long type. */
	public static final Class<Long> TYPE =
		ObjectAccess.<Long>classByNameType("long");
	
	/** The value of this long. */
	private final long _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the long with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Long(long __v)
	{
		this._value = __v;
	}
	
	public Long(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Long __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Long))
			return false;
		
		return this._value == ((Long)__o)._value;
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Long.toString(this._value)));
		
		return rv;
	}
	
	public static int bitCount(long __a)
	{
		throw new todo.TODO();
	}
	
	public static Long decode(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a)
	{
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a, Long __b)
	{
		throw new todo.TODO();
	}
	
	public static long highestOneBit(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long lowestOneBit(long __a)
	{
		throw new todo.TODO();
	}
	
	public static int numberOfLeadingZeros(long __a)
	{
		throw new todo.TODO();
	}
	
	public static int numberOfTrailingZeros(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long parseLong(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static long parseLong(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static long reverse(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long reverseBytes(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long rotateLeft(long __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static long rotateRight(long __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static int signum(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long sum(long __a, long __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a string of the given value in binary.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toBinaryString(long __v)
	{
		return Long.__unsignedString(__v, 2);
	}
	
	/**
	 * Returns a string of the given value in hexadecimal.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toHexString(long __v)
	{
		return Long.__unsignedString(__v, 16);
	}
	
	/**
	 * Returns a string of the given value in octal.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toOctalString(long __v)
	{
		return Long.__unsignedString(__v, 8);
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(long __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Calls {@link Long#toString(long, int)} with a radix of 10.
	 *
	 * @param __v The input value.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(long __v)
	{
		return Long.toString(__v, 10);
	}
	
	public static Long valueOf(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Long valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Returns a instance of the given value, this may be cached.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/09/23
	 */
	@ImplementationNote("This is not cached.")
	public static Long valueOf(long __v)
	{
		return new Long(__v);
	}
	
	/**
	 * Returns an unsigned string of the given number and base.
	 *
	 * @param __v The value to translate.
	 * @param __b The number base.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	private static final String __unsignedString(long __v, int __b)
	{
		throw new todo.TODO();
	}
}


Added modules/cldc-compact/src/main/java/java/lang/Math.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.FDMLMath;

/**
 * This class contains mathematical functions.
 *
 * @since 2018/12/08
 */
@SuppressWarnings("FieldNamingConvention")
@ImplementationNote("This class uses strict floating point.")
public final strictfp class Math
{
	/** E. */
	public static final double E =
		+0x1.5BF0A8B145769p1D;
	
	/** Pi. */
	public static final double PI =
		+0x1.921FB54442D18p1D;
	
	/**
	 * Not used.
	 *
	 * @since 2018/12/08
	 */
	private Math()
	{
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @param __v The input value.
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static int abs(int __v)
	{
		return (__v < 0 ? -__v : __v);
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @param __v The input value.
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static long abs(long __v)
	{
		return (__v < 0 ? -__v : __v);
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @param __v The input value.
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static float abs(float __v)
	{
		return Float.intBitsToFloat(0x7FFFFFFF & Float.floatToIntBits(__v));
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @param __v The input value.
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static double abs(double __v)
	{
		return Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL &
			Double.doubleToLongBits(__v));
	}
	
	public static double acos(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double asin(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double atan(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double atan2(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static double ceil(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double copySign(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static float copySign(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static double cos(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double floor(double __a)
	{
		throw new todo.TODO();
	}
	
	public static int getExponent(float __a)
	{
		throw new todo.TODO();
	}
	
	public static int getExponent(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the logarithm of the given number.
	 *
	 * This method does not exist in CLDC and is SquirrelJME specified.
	 *
	 * @param __v The value to get the logarithm from.
	 * @return The logarithm for the given value.
	 * @since 2018/11/03
	 */
	@Deprecated
	@ImplementationNote("This method does not exist in the CLDC library.")
	public static double log(double __v)
	{
		return FDMLMath.log(__v);
	}
	
	/**
	 * Returns the higher of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The higher value.
	 * @since 2018/09/29
	 */
	public static int max(int __a, int __b)
	{
		if (__a > __b)
			return __a;
		return __b;
	}
	
	public static long max(long __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static float max(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static double max(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/09/29
	 */
	public static int min(int __a, int __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static long min(long __a, long __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static float min(float __a, float __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static double min(double __a, double __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	public static double random()
	{
		throw new todo.TODO();
	}
	
	public static int round(float __a)
	{
		throw new todo.TODO();
	}
	
	public static long round(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double signum(double __a)
	{
		throw new todo.TODO();
	}
	
	public static float signum(float __a)
	{
		throw new todo.TODO();
	}
	
	public static double sin(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the square root of the given number.
	 *
	 * @param __v The input value.
	 * @return The square root.
	 * @since 2018/11/03
	 */
	public static double sqrt(double __v)
	{
		return FDMLMath.sqrt(__v);
	}
	
	public static double tan(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double toDegrees(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double toRadians(double __a)
	{
		throw new todo.TODO();
	}
}

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

package java.lang;

/**
 * This is thrown when an attempt is made to allocate an array that is of a
 * negative size.
 *
 * @since 2018/09/22
 */
public class NegativeArraySizeException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/22
	 */
	public NegativeArraySizeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/22
	 */
	public NegativeArraySizeException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when no class definition was found.
 *
 * @since 2018/12/04
 */
public class NoClassDefFoundError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NoClassDefFoundError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public NoClassDefFoundError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown when a field in a class does not exist.
 *
 * @since 2018/12/04
 */
public class NoSuchFieldError
	extends IncompatibleClassChangeError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NoSuchFieldError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public NoSuchFieldError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

/**
 * This is thrown by the virtual machine when an attempt is made to read from
 * a reference which is {@code null}.
 *
 * @since 2016/02/26
 */
public class NullPointerException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NullPointerException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public NullPointerException(String __m)
	{
		super(__m);
	}
}


Added modules/cldc-compact/src/main/java/java/lang/Number.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * A number represents any kind of number which may be transformed to other
 * types for those numbers.
 *
 * Note that any of these methods may result in values which lose their sign,
 * significant bits, or the value itself. Most classes will likely implement
 * these using narrowing conversions that match the Java language.
 *
 * @since 2018/09/23
 */
public abstract class Number
{
	
	/**
	 * Returns the value of this number converted as a double.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract double doubleValue();
	
	/**
	 * Returns the value of this number converted as a float.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract float floatValue();
	
	/**
	 * Returns the value of this number converted as an integer.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract int intValue();
	
	/**
	 * Returns the value of this number converted as a long.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract long longValue();
	
	/**
	 * Returns the value of this number converted as a byte.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public byte byteValue()
	{
		return (byte)this.intValue();
	}
	
	/**
	 * Returns the value of this number converted as a short.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public short shortValue()
	{
		return (short)this.intValue();
	}
}

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

package java.lang;

/**
 * This is thrown when the format of a number is not correct.
 *
 * @since 2018/10/12
 */
public class NumberFormatException
	extends IllegalArgumentException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public NumberFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public NumberFormatException(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Object.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This class is the root of all class trees in Java.
 *
 * @since 2016/02/08
 */
@ImplementationNote("The Java compiler does not allow any final fields to " +
	"exist in Object and if they are set via assignment no code will be " +
	"generated for them, so as such Object effectively has no fields.")
public class Object
{
	
	/**
	 * Clones the current copy creating a shallow copy of it if
	 * {@code Cloneable} is implemented, unless this method is overridden to
	 * perform class specific cloning.
	 *
	 * @throws CloneNotSupportedException If cloning is not supported by the
	 * current class, the default implementation always throws this if the
	 * {@link Cloneable} interface does not exist.
	 * @return The cloned object.
	 * @since 2016/02/08
	 */
	protected Object clone()
		throws CloneNotSupportedException
	{
		// If this is an array copy elements around
		Class<?> cl = this.getClass();
		if (cl.isArray())
		{
			// Need length of this array to recreate!
			int len = Assembly.arrayLength(this);
			
			// Allocate new array
			Object dest = ObjectAccess.arrayNew(cl, len);
			
			// Copy everything over
			System.arraycopy(this, 0, dest, 0, len);
			
			// This array was cloned
			return dest;
		}
		
		// {@squirreljme.error ZZ1d This object does not support being cloned.}
		throw new CloneNotSupportedException("ZZ1d");
	}
	
	/**
	 * Checks for equality between this object and another. Equality should be
	 * reflexive (equal to self), symmetric (a is equal to b as b is equal to
	 * a), transitive (a is equal to b, and b is equal to c, then a must be
	 * equal to c), and consistent (if no modifications to the object were made
	 * then it should return the same value returned as the previous call).
	 *
	 * If this method is overriden, then also override {@code hashCode()}.
	 *
	 * @param __o The object to check equality against.
	 * @return {@code true} if the two objects are equal.
	 * @since 2016/02/08
	 */
	public boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class object which is associated with this object, this is
	 * the class of the current object.
	 *
	 * @return The current class object.
	 * @since 2016/02/08
	 */
	public final Class<?> getClass()
	{
		return ObjectAccess.classOf(this);
	}
	
	/**
	 * Calculates the hash code for this object.
	 *
	 * If two objects are equal than they must have the same hash code,
	 * otherwise undefined behavior will occur with their potential usage.
	 *
	 * @return The hash code of this object.
	 * @since 2016/02/08
	 */
	public int hashCode()
	{
		return System.identityHashCode(this);
	}
	
	/**
	 * Notifies a single thread which is waiting on this monitor.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @since 2016/02/08
	 */
	public final void notify()
		throws IllegalMonitorStateException
	{
		// {@squirreljme.error ZZ1e This thread does not own the monitor for
		// this thread.}
		if (ObjectAccess.monitorNotify(this, false) < 0)
			throw new IllegalMonitorStateException("ZZ1e");
	}
	
	/**
	 * Notifies all threads which are waiting on this monitor.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @since 2016/02/09
	 */
	public final void notifyAll()
		throws IllegalMonitorStateException
	{
		// {@squirreljme.error ZZ1f This thread does not own the monitor for
		// this thread.}
		if (ObjectAccess.monitorNotify(this, true) < 0)
			throw new IllegalMonitorStateException("ZZ1f");
	}
	
	/**
	 * Returns the string representation of this object.
	 *
	 * The default implementation is {@code classname@hashcode}.
	 *
	 * @return The string representation of this object.
	 * @since 2016/02/09
	 */
	public String toString()
	{
		return this.getClass().getName() + "@" +
			Integer.toString(this.hashCode(), 16);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait()
		throws InterruptedException, IllegalMonitorStateException
	{
		this.wait(0, 0);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call, however it will
	 * stop after the given time has elapsed.
	 *
	 * @param __ms The milliseconds to wait for, if this is {@code 0} then this
	 * will wait forever.
	 * @throws IllegalArgumentException If any input time is negative.
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait(long __ms)
		throws IllegalArgumentException, IllegalMonitorStateException,
			InterruptedException
	{
		this.wait(__ms, 0);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call, however it will
	 * stop after the given time has elapsed.
	 *
	 * If both {@code __ms} and {@code __ns} are zero, then the wait will be
	 * forever.
	 *
	 * @param __ms The milliseconds to wait for, if this is {@code 0} then this
	 * will wait forever.
	 * @param __ns The number of nanoseconds to additionally wait for.
	 * @throws IllegalArgumentException If any input time is negative or
	 * {@code __ns} is not in the range [0, 999999].
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait(long __ms, int __ns)
		throws IllegalArgumentException, IllegalMonitorStateException,
			InterruptedException
	{
		// Call wait, but return status can have multiple kind of things
		// going on
		switch (ObjectAccess.monitorWait(this, __ms, __ns))
		{
				// {@squirreljme.error ZZ1g Cannot wait on monitor because
				// this thread does not own the monitor.}
			case ObjectAccess.MONITOR_NOT_OWNED:
				throw new IllegalMonitorStateException("ZZ1g");
			
				// Not interrupted
			case ObjectAccess.MONITOR_NOT_INTERRUPTED:
				return;
			
				// {@squirreljme.error ZZ1h Wait operation has been
				// interrupted.}
			case ObjectAccess.MONITOR_INTERRUPTED:
				Thread.currentThread()._interrupted = false;
				throw new InterruptedException("ZZ1h");
				
				// Should not happen
			default:
				throw new todo.OOPS();
		}
	}
}

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

package java.lang;

/**
 * This is thrown when the virtual machine is out of memory.
 *
 * @since 2018/12/04
 */
public class OutOfMemoryError
	extends VirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public OutOfMemoryError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public OutOfMemoryError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which is attached to a method to indicate that
 * it overrides a method in the super class. When the compiler encounters
 * this, it makes sure that it actually overrides a method. If it does not
 * then a compilation error occurs. Using this all the time is recommended when
 * a method is intended to be overidden.
 *
 * As an example, if the base class has the following method:
 *
 * {@code
 * public static int foo(long __a);
 * }
 *
 * And a class which extends the base class has the following method:
 *
 * {@code
 * public static int foo(int __a);
 * }
 *
 * If it is intended to add a new {@code foo} which handles {@code int} instead
 * of {@code long} then this annotation should not be used, however it it is
 * intended to replace it (and specifying {@code int} was a mistake) then this
 * should be used.
 *
 * @since 2016/04/12
 */
@Target(value={ElementType.METHOD})
@Retention(value=RetentionPolicy.SOURCE)
public @interface Override
{
}


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

package java.lang;

/**
 * This interface should be used by any class which is intended and capable
 * of being run in its own thread (via {@link Thread#Thread(Runnable)}.
 *
 * When used with {@link Thread}, the method {@link #run()} will be executed
 * when the thread is started.
 *
 * @since 2018/09/19
 */
public interface Runnable
{
	/**
	 * Performs any action that is required as needed.
	 *
	 * @since 2018/09/19
	 */
	void run();
}

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

package java.lang;

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

/**
 * This class contains information about the host memory environment along
 * with providing methods to perform garbage collection and exit the
 * virtual machine.
 *
 * @since 2018/10/14
 */
public class Runtime
{
	/** There is only a single instance of the run-time. */
	private static final Runtime _INSTANCE =
		new Runtime();
	
	/**
	 * Not used.
	 *
	 * @since 2018/10/14
	 */
	private Runtime()
	{
	}
	
	/**
	 * Indicates that the application exits with the given code.
	 *
	 * @param __v The exit code, the value of this code may change according
	 * to the host operating system and the resulting process might not exit
	 * with the given code.
	 * @throws SecurityException If exiting is not permitted.
	 * @since 2017/02/08
	 */
	public void exit(int __v)
		throws SecurityException
	{
		// Check that we can exit
		System.getSecurityManager().checkExit(__v);
		
		// Then do the exit if no exception was thrown
		Assembly.sysCall(SystemCallIndex.EXIT, __v);
	}
	
	/**
	 * Returns the amount of memory that is free for the JVM to use.
	 *
	 * @return The amount of free memory.
	 * @since 2018/10/14
	 */
	public long freeMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_FREE);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_FREE))
			return Integer.MAX_VALUE;
		return rv;
	}
	
	/**
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public void gc()
	{
		Assembly.sysCall(SystemCallIndex.GARBAGE_COLLECT);
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *
	 * @return The maximum amount of memory available to the virtual machine.
	 * @since 2018/10/14
	 */
	public long maxMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_MAX);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_MAX))
			return Integer.MAX_VALUE;
		return rv;
	}
	
	/**
	 * Returns the total amount of memory that is being used by the virtual
	 * machine. This is a count of all the memory claimed by the virtual
	 * machine itself for its memory pools and such.
	 *
	 * @return The amount of memory being used by the virtual machine.
	 * @since 2018/10/14
	 */
	public long totalMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_USED);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_USED))
			return 0;
		return rv;
	}
	
	/**
	 * Returns the single instance of this class.
	 *
	 * Only a single runtime is valid and there will only be one.
	 *
	 * @return The current run-time.
	 * @since 2018/03/01
	 */
	public static Runtime getRuntime()
	{
		return Runtime._INSTANCE;
	}
}

Added modules/cldc-compact/src/main/java/java/lang/RuntimeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This and all of its sub-classes represents exceptions which are unchecked
 * by the compiler.
 *
 * @since 2018/09/16
 */
public class RuntimeException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public RuntimeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public RuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public RuntimeException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public RuntimeException(Throwable __t)
	{
		super(__t);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/RuntimePermission.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
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.security.BasicPermission;

/**
 * This is a permission which may be available at runtime.
 *
 * The following permissions are available:
 * {@code "exitVM.(n)"} -- Exiting the VM with the given error code, if
 * an asterisk {@code '*'} is used then any exit code is specified.
 * {@code "setSecurityManager"} -- Setting a new security manager.
 * {@code "createSecurityManager"} -- Creating a new security manager.
 * {@code "setIO"} -- Setting {@link System#out} and {@link System#err}.
 * {@code "modifyThread"} -- Allows one to interrupt threads, set priority,
 * and rename them.
 *
 * @since 2018/09/18
 */
public final class RuntimePermission
	extends BasicPermission
{
	/**
	 * Initializes the permission.
	 *
	 * @param __name The name to check.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public RuntimePermission(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		super(__name);
		
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1i Runtime permission name cannot be empty.}
		if (__name.isEmpty())
			throw new IllegalArgumentException("ZZ1i");
	}
	
	/**
	 * Invokes {@code RuntimePermission(__name)}, the action is not used.
	 *
	 * @param __name The name to check.
	 * @param __act This is ignored.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public RuntimePermission(String __name, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		this(__name);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/SecurityException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the security manager has detected a security violation.
 *
 * @see SecurityManager
 * @since 2018/09/18
 */
public class SecurityException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/18
	 */
	public SecurityException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/18
	 */
	public SecurityException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/18
	 */
	public SecurityException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/18
	 */
	public SecurityException(Throwable __t)
	{
		super(__t);
	}
}

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

package java.lang;

import java.security.AccessController;
import java.security.Permission;
import java.util.PropertyPermission;

public class SecurityManager
{
	/** The current security manager, defaults to the system one. */
	static volatile SecurityManager _CURRENT_MANAGER =
		new SecurityManager();
	
	/**
	 * Initializes the security manager, if a security manager already exists
	 * then the
	 *
	 * @throws SecurityException If the manager could not be created.
	 * @since 2018/09/18 
	 */
	public SecurityManager()
		throws SecurityException
	{
		// Lock on this class, since multiple threads cannot mess around with
		// this check
		synchronized (SecurityManager.class)
		{
			// If one already exists, check to see if it can be created first
			SecurityManager current = SecurityManager._CURRENT_MANAGER;
			if (current != null)
				current.checkPermission(
					new RuntimePermission("createSecurityManager"));
		}
	}
	
	public void checkAccept(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks if the given thread may be modified.
	 *
	 * @param __t The thread to check.
	 * @throws SecurityException If threads cannot be modified.
	 * @since 2018/11/21
	 */
	public void checkAccess(Thread __t)
		throws SecurityException
	{
		this.checkPermission(new RuntimePermission("modifyThread"));
	}
	
	public void checkConnect(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void checkDelete(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks that the virtual machine can exit with the given code.
	 *
	 * @param __code The exit code.
	 * @throws SecurityException If exit is not permitted.
	 * @since 2018/10/13
	 */
	public void checkExit(int __code)
		throws SecurityException
	{
		this.checkPermission(new RuntimePermission("exitVM." + __code));
	}
	
	public void checkListen(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given permission is permitted.
	 *
	 * @param __p The permission to check.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If permission is denied.
	 * @since 2018/09/18
	 */
	public void checkPermission(Permission __p)
		throws NullPointerException, SecurityException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		AccessController.checkPermission(__p);
	}
	
	/**
	 * Checks if the given system property can be accessed.
	 *
	 * @param __key The key to check.
	 * @throws IllegalArgumentException If the key is empty.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/09/18
	 */
	public void checkPropertyAccess(String __key)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1j Request to check access to system property
		// with an empty key.}
		if (__key.isEmpty())
			throw new IllegalArgumentException("ZZ1j");
		
		// Forward
		this.checkPermission(new PropertyPermission(__key, "read"));
	}
	
	public void checkRead(String __a)
	{
		throw new todo.TODO();
	}
	
	public void checkWrite(String __a)
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Short.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

public final class Short
	extends Number
	implements Comparable<Short>
{
	public static final short MAX_VALUE =
		32767;
	
	public static final short MIN_VALUE =
		-32768;
	
	public static final int SIZE =
		16;
	
	/** The class representing the primitive type. */
	public static final Class<Short> TYPE =
		ObjectAccess.<Short>classByNameType("short");
	
	/** The value of this integer. */
	private final short _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Wraps the boxed value.
	 *
	 * @param __v The value to wrap.
	 * @since 2018/11/14
	 */
	public Short(short __v)
	{
		this._value = __v;
	}
	
	public Short(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Short __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Short.toString(this._value)));
		
		return rv;
	}
	
	public static Short decode(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short parseShort(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short parseShort(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short reverseBytes(short __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the string representation of the short value.
	 *
	 * @param __v The value to represent.
	 * @return The string representation of it.
	 * @since 2018/11/14
	 */
	public static String toString(short __v)
	{
		return Integer.toString(__v, 10);
	}
	
	public static Short valueOf(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Short valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Boxes the given short value.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/11/14
	 */
	public static Short valueOf(short __v)
	{
		return new Short(__v);
	}
	
	/**
	 * The {@link #TYPE} field is magically initialized by the virtual machine.
	 *
	 * @return {@link #TYPE}.
	 * @since 2016/06/16
	 */
	private static Class<Short> __getType()
	{
		return Short.TYPE;
	}
}

Added modules/cldc-compact/src/main/java/java/lang/String.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;
import cc.squirreljme.runtime.cldc.i18n.DefaultLocale;
import cc.squirreljme.runtime.cldc.i18n.Locale;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Decoder;
import cc.squirreljme.runtime.cldc.io.Encoder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.Formatter;
import java.util.Iterator;
import java.util.LinkedList;

/**
 * A {@link String} represents a sequence of characters which make up a group
 * of alphanumeric or other symbols and represents text.
 *
 * Note that only {@link #toLowerCase()} and {@link #toUpperCase()} take
 * locale into considering during their conversion.
 *
 * @since 2018/09/16
 */
public final class String
	implements Comparable<String>, CharSequence
{
	/** The minumum trim character. */
	private static final char _MIN_TRIM_CHAR =
		' ';
	
	/** Is this string already lowercased? */
	private static final short _QUICK_ISLOWER =
		0b0000_0000__0000_0001;
	
	/** Is this string already uppercased? */
	private static final short _QUICK_ISUPPER =
		0b0000_0000__0000_0010;
	
	/** String is already interned? */
	private static final short _QUICK_INTERN =
		0b0000_0000__0000_0100;
	
	/** Intern string table, weakly cached to reduce memory use. */
	private static final Collection<Reference<String>> _INTERNS =
		new LinkedList<>();
	
	/** String character data. */
	private final char[] _chars;
	
	/** Quick determination flags for speedy operations. */
	private volatile short _quickflags;
	
	/** The hash code for this string, is cached. */
	private int _hashcode;
	
	/**
	 * Initializes a new empty string.
	 *
	 * @since 2018/02/24
	 */
	public String()
	{
		this._chars = new char[0];
		this._quickflags = String._QUICK_ISLOWER | String._QUICK_ISUPPER;
		this._hashcode = 0;
	}
	
	/**
	 * Initializes a string which is an exact copy of the other string.
	 *
	 * @param __s The other string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	public String(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Just copies all the fields since they were pre-calculated already
		this._chars = __s._chars;
		this._quickflags = ((short)(__s._quickflags & (~String._QUICK_INTERN)));
		this._hashcode = __s._hashcode;
	}
	
	/**
	 * Initializes a string which uses characters which are a copy of the given
	 * character array.
	 *
	 * @param __c The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public String(char[] __c)
		throws NullPointerException
	{
		this(__c, 0, __c.length);
	}
	
	/**
	 * Initializes a string which uses characters which are a copy of the given
	 * character array, using the offset and length.
	 *
	 * @param __c The characters to copy.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public String(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Copy characters
		char[] copy = new char[__l];
		for (int i = __o, o = 0; o < __l; i++, o++)
			copy[o] = __c[i];
		
		// Just use the copied buffer
		this._chars = copy;
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @param __e The encoding to use when decoding the bytes.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, int __o, int __l, String __e)
		throws IndexOutOfBoundsException, NullPointerException,
			UnsupportedEncodingException
	{
		this(__b, __o, __l, CodecFactory.decoder(__e));
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __e The encoding to use when decoding the bytes.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, String __e)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(__b, 0, __b.length, CodecFactory.decoder(__e));
	}
	
	/**
	 * Decodes the given bytes to a string using the default encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		this(__b, __o, __l, CodecFactory.defaultDecoder());
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public String(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length, CodecFactory.defaultDecoder());
	}
	
	/**
	 * Initializes string from the given buffer.
	 *
	 * @param __a The input buffer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public String(StringBuffer __a)
		throws NullPointerException
	{
		this(__a.toString());
	}
	
	/**
	 * Initializes string from the given builder.
	 *
	 * @param __a The input builder.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public String(StringBuilder __a)
		throws NullPointerException
	{
		this(__a.toString());
	}
	
	/**
	 * Decodes the given bytes to a string using the specified decoder.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @param __dec The decoder to use for the input bytes.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	private String(byte[] __b, int __o, int __l, Decoder __dec)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null || __dec == null)
			throw new NullPointerException("NARG");
		int bn = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bn)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup a temporary character array with average sequence length to
		// hopefully have enough room to store the decoded characters
		int cap = (int)(__l * __dec.averageSequenceLength()),
			at = 0;
		char[] out = new char[cap];
		
		// Start decoding input sequences
		for (int i = __o, e = i + __l; i < e;)
		{
			// Decode sequence (the decoded char is in the low 16-bits)
			int left = e - i,
				rc = __dec.decode(__b, i, left);
			
			// If there is not enough room to decode a sequence then store the
			// replacement character
			char ch;
			if (rc < 0)
			{
				ch = 0xFFFD;
				i = e;
			}
			
			// The lower 16-bits contains the character, the upper bytes
			// contains the number of characters read
			else
			{
				ch = (char)rc;
				i += (rc >> 16);
			}
			
			// Need to re-allocate?
			if (at >= cap)
				out = Arrays.copyOf(out, (cap += left));
			
			// Store
			out[at++] = ch;
		}
		
		// Just allocate an exact buffer since the estimate could have been off
		if (at != cap)
			out = Arrays.copyOf(out, at);
		this._chars = out;
	}
	
	/**
	 * Initializes the string using the given character data.
	 *
	 * @param __c Character data.
	 * @param __qf The quick flags to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	String(char[] __c, short __qf)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		this._chars = __c;
		this._quickflags = __qf;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public char charAt(int __i)
		throws IndexOutOfBoundsException
	{
		char[] chars = this._chars;
		if (__i < 0 || __i >= chars.length)
			throw new IndexOutOfBoundsException("IOOB " + __i);
		return chars[__i];
	}
	
	/**
	 * Compares the character values of this string and compares it to the
	 * character values of the other string.
	 *
	 * Smaller strings always precede longer strings.
	 *
	 * This is equivalent to the standard POSIX {@code strcmp()} with the "C"
	 * locale.
	 *
	 * Internally this does not handle the special variants of this class and
	 * is a general purpose method.
	 *
	 * @param __o The string to compare against.
	 * @return A negative value if this string precedes the other string, a
	 * positive value if this string procedes the other string, or zero if the
	 * strings are equal.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/02
	 */
	public int compareTo(String __o)
		throws NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Refers to the same exact string?
		//noinspection StringEquality
		if (this == __o)
			return 0;
		
		// Characters of both
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Get both string lengths
		int an = ac.length;
		int bn = bc.length;
		
		// Max comparison length
		int max = Math.min(an, bn);
		
		// Compare both strings
		for (int i = 0; i < max; i++)
		{
			// Get character difference
			int diff = ((int)ac[i]) - ((int)bc[i]);
			
			// If there is a difference, then return it
			if (diff != 0)
				return diff;
		}
		
		// Remaining comparison is the length parameter, shorter strings are
		// first
		return an - bn;
	}
	
	/**
	 * Compares two strings lexicographically without regards to case. This
	 * method does not take locale into account.
	 *
	 * @param __o The other string.
	 * @return The comparison of the string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public int compareToIgnoreCase(String __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Refers to the same exact string?
		//noinspection StringEquality
		if (this == __o)
			return 0;
		
		// Characters of both
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Get both string lengths
		int an = ac.length;
		int bn = bc.length;
		
		// Max comparison length
		int max = Math.min(an, bn);
		
		// Compare both strings
		for (int i = 0; i < max; i++)
		{
			// Get both characters and normalize case
			char ca = Character.toLowerCase(Character.toUpperCase(ac[i])),
				cb = Character.toLowerCase(Character.toUpperCase(bc[i]));
			
			// Get character difference
			int diff = ca - cb;
			
			// If there is a difference, then return it
			if (diff != 0)
				return diff;
		}
		
		// Remaining comparison is the length parameter, shorter strings are
		// first
		return an - bn;
	}
	
	/**
	 * Concatenates the given string to the end of this string.
	 *
	 * If the given string has a length of zero then this string is returned,
	 * otherwise if this string has a length of zero the given string is
	 * returned.
	 *
	 * @param __s The string to append to this string (returning a new string).
	 * @return The new string with the appended characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public String concat(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
			
		// Get both character sources
		char[] ac = this._chars,
			bc = __s._chars;
		
		// Lengths
		int an = ac.length,
			bn = bc.length;
		
		// One of the strings has no length, which means it will be a no-op
		if (an == 0)
			return __s;
		else if (bn == 0)
			return this;
		
		// Setup result
		int nl = an + bn;
		char[] rv = new char[nl];
		
		// Copy first part
		int o = 0;
		for (int i = 0; i < an; i++)
			rv[o++] = ac[i];
		
		// Copy second
		for (int i = 0; i < bn; i++)
			rv[o++] = bc[i];
		
		// Build string
		return new String(rv, (short)0);
	}
	
	/**
	 * Returns {@code true} if the string contains the given sequence.
	 *
	 * @param __b The sequence to find.
	 * @return If the string contains the given sequence or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/14
	 */
	public boolean contains(CharSequence __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// This is the same operation
		return this.__indexOf(__b, 0) >= 0;
	}
	
	/**
	 * Checks whether the content of this string is equal to the specified
	 * string buffer, the input buffer will be synchronized.
	 *
	 * @param __s The character sequence to check, this is synchronized.
	 * @return If the content equals the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public boolean contentEquals(StringBuffer __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// StringBuffers are synchronized and as such a lock is used to
		// prevent it from being changed.
		synchronized (__s)
		{
			return this.__contentEquals(__s);
		}
	}
	
	/**
	 * Checks whether the content of this string is equal to the specified
	 * character sequence.
	 *
	 * @param __s The character sequence to check, if it is a
	 * {@link StringBuffer} then it will be synchronized.
	 * @return If the content equals the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public boolean contentEquals(CharSequence __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Synchronize on StringBuffers
		if (__s instanceof StringBuffer)
			return this.contentEquals((StringBuffer)__s);
		
		return this.__contentEquals(__s);
	}
	
	/**
	 * Tests if this string ends with the given string.
	 *
	 * @param __s The string to test.
	 * @return If this string ends with the other string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/20
	 */
	public boolean endsWith(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Character data
		char[] ac = this._chars,
			bc = __s._chars;
		
		// Lengths
		int na = ac.length,
			nb = bc.length;
		
		// If the other string is empty, it is always a match
		if (nb == 0)
			return true;
		
		// If our string is smaller than the other string then it will not
		// fit and as such, will not match
		if (na < nb)
			return false;
		
		// Check all characters at the end of the string, we fail if there is
		// a mismatch
		for (int ia = na - nb, ib = 0; ia < na; ia++, ib++)
			if (ac[ia] != bc[ib])
				return false;
		
		// Is a match since nothing failed!
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Short circuit match, the same string object is always equals
		if (this == __o)
			return true;
		
		// If not a string, fail
		if (!(__o instanceof String))
			return false;
		
		// Cast
		String o = (String)__o;
		
		// Quickly determine if the string is likely the same via the hashcode
		// This at best removes all loops and just results in a simple integer
		// comparison being used
		int an = this.hashCode(),
			bn = o.hashCode();
		if (an != bn)
			return false;
		
		// Character data
		char[] ac = this._chars,
			bc = o._chars;
		
		// If the length differs, they are not equal
		int n = ac.length;
		if (n != bc.length)
			return false;
		
		// Compare individual characters
		for (int i = 0; i < n; i++)
			if (ac[i] != bc[i])
				return false;
		
		// Would be a match!
		return true;
	}
	
	/**
	 * Checks if one string is equal to the other, ignoring case and ignoring
	 * any locale differences.
	 *
	 * A character is considered equal if they are the same character, the
	 * uppercase result of both characters is the same, or the lowercase
	 * result of each character is the same.
	 *
	 * @param __o The other string to check.
	 * @return If the two strings are equal.
	 * @since 2018/10/29
	 */
	@ProgrammerTip("Locale is not considered.")
	public boolean equalsIgnoreCase(String __o)
	{
		// Always false
		if (__o == null)
			return false;
		
		// Character data
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Two strings of inequal length will never be the same
		int n = ac.length;
		if (n != bc.length)
			return false;
		
		// Check characters
		for (int i = 0; i < n; i++)
		{
			char a = Character.toLowerCase(Character.toUpperCase(ac[i])),
				b = Character.toLowerCase(Character.toUpperCase(bc[i]));
			
			// Is a different character?
			if (a != b)
				return false;
		}
		
		// The same
		return true;
	}
	
	/**
	 * Translates this string into a byte array using the default encoding.
	 *
	 * @return The resulting byte array.
	 * @since 2018/12/08
	 */
	public byte[] getBytes()
	{
		return this.__getBytes(CodecFactory.defaultEncoder());
	}
	
	/**
	 * Translates this string using into a byte array using the specified
	 * character encoding.
	 *
	 * @param __enc The character encoding to use.
	 * @return A byte array with the characters of this string converted to
	 * bytes.
	 * @throws NullPointerException If no encoding was specified.
	 * @throws UnsupportedEncodingException If the encoding is unknown.
	 * @since 2018/12/08
	 */
	public byte[] getBytes(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		// Check
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		try
		{
			return this.__getBytes(CodecFactory.encoder(__enc));
		}
		
		// {@squirreljme.error ZZ1k The specified encoding is not supported by
		// the virtual machine. (The encoding)}
		catch (UnsupportedEncodingException uee)
		{
			throw new AssertionError("ZZ1k " + __enc);
		}
	}
	
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public int hashCode()
	{
		// If the hashcode was already determined before then use that
		// cache
		int rv = this._hashcode;
		if (rv != 0)
			return rv;
		
		// Calculate the hashCode(), the JavaDoc gives the following formula:
		// == s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] .... yikes!
		char[] ch = this._chars;
		for (int i = 0, n = ch.length; i < n; i++)
			rv = ((rv << 5) - rv) + ch[i];
		
		// Cache hashcode for later
		this._hashcode = rv;
		return rv;
	}
	
	/**
	 * Searches the string for the given character and returns the index if it
	 * was found.
	 *
	 * @param __c The character to find.
	 * @return The character index or {@code -1} if it was not found.
	 * @since 2018/09/20
	 */
	public int indexOf(int __c)
	{
		return this.indexOf(__c, 0);
	}
	
	/**
	 * Searches the string for the given character starting from the given
	 * index and returns the index if it was found.
	 *
	 * @param __c The character to find.
	 * @param __i The index to start at, the values are capped within the
	 * string length.
	 * @return The character index or {@code -1} if it was not found.
	 * @since 2018/09/20
	 */
	public int indexOf(int __c, int __i)
	{
		char[] ch = this._chars;
		
		// Cap index
		int n = ch.length;
		if (__i < 0)
			__i = 0;
		
		for (int i = __i; i < n; i++)
			if (__c == ch[i])
				return i;
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/14
	 */
	public int indexOf(String __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.__indexOf(__b, 0);
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @param __i The starting index.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @since 2019/05/14
	 */
	public int indexOf(String __b, int __i)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.__indexOf(__b, __i);
	}
	
	/**
	 * This returns the unique string instance used for the current string, if
	 * the current string is not within the internal map then it is added. If
	 * it already exists in the map then that pre-existing value is returned.
	 * The purpose of this method is for potential optimizations where there
	 * are a large number of long-term string objects in memory which may be
	 * duplicated in many places (such as in a database). As such, only
	 * persistant strings should be interned, never short lived strings.
	 *
	 * Although this may be used for {@code ==} to work, it is not recommended
	 * to use this method for such things.
	 *
	 * @return The unique string instance.
	 * @since 2016/04/01
	 */
	@ImplementationNote("This method is a bit slow in SquirrelJME as it " +
		"will search a list of weak reference to string. So despite this " +
		"being a O(n) search it will allow any strings to be garbage " +
		"collected when no longer used. Also the collection is a LinkedList " +
		"since the __BucketMap__ is a complicated class. But do note that " +
		"String.equals() checks the hashCode() so in-depth searches will " +
		"only be performed for strings with the same hashCode().")
	public String intern()
	{
		// If this string is already interned then use this one instead
		// of searching through the map
		if ((this._quickflags & String._QUICK_INTERN) != 0)
			return this;
		
		// Search for string in the collection
		Collection<Reference<String>> interns = String._INTERNS;
		synchronized (interns)
		{
			// Same string that was internalized?
			Iterator<Reference<String>> it = interns.iterator();
			while (it.hasNext())
			{
				Reference<String> ref = it.next();
				
				// If the reference has been cleared, then delete it
				String oth = ref.get();
				if (oth == null)
				{
					it.remove();
					continue;
				}
				
				// If this matches the string, use that one
				if (this.equals(oth))
					return oth;
			}
			
			// Not in the table, so add it
			interns.add(new WeakReference<>(this));
			
			// Also flag that this has been interned
			this._quickflags |= String._QUICK_INTERN;
			
			// This will be the intern string
			return this;
		}
	}
	
	/**
	 * Returns {@code true} if this string is empty.
	 *
	 * @return {@code true} if this string is empty.
	 * @since 2017/08/15
	 */
	public boolean isEmpty()
	{
		return this._chars.length == 0;
	}
	
	/**
	 * Returns the last occurance of the given character.
	 *
	 * @param __c The character to find.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c)
	{
		return this.lastIndexOf(__c, Integer.MAX_VALUE);
	}
	
	/**
	 * Returns the last occurance of the given character going backwards from
	 * the given index.
	 *
	 * @param __c The character to find.
	 * @param __dx The index to start at, this is clipped to within the
	 * string bounds accordingly although if it is negative no searching is
	 * done.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c, int __dx)
	{
		// Never going to find anything at all
		if (__dx < 0)
			return -1;
		
		// Cap index
		char[] ch = this._chars;
		int n = ch.length;
		if (__dx >= n)
			__dx = n - 1;
		
		for (; __dx >= 0; __dx--)
			if (__c == ch[__dx])
				return __dx;
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the last occurance of the given string.
	 *
	 * @param __s The string to find.
	 * @return The last occurance of the string or {@code -1} if it was
	 * not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public int lastIndexOf(String __s)
		throws NullPointerException
	{
		return this.lastIndexOf(__s, Integer.MAX_VALUE);
	}
	
	public int lastIndexOf(String __s, int __dx)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of this string.
	 *
	 * @return The length of this string.
	 * @since 2018/09/19
	 */
	public int length()
	{
		return this._chars.length;
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __toff The offset for this string.
	 * @param __b The other string to compare against.
	 * @param __boff The offset of the target string.
	 * @param __len The number of characters to compare.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(int __toff, String __b, int __boff, int __len)
	{
		return this.regionMatches(false, __toff, __b, __boff, __len);
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __igncase Is case to be ignored?
	 * @param __toff The offset for this string.
	 * @param __b The other string to compare against.
	 * @param __boff The offset of the target string.
	 * @param __len The number of characters to compare, if this is negative
	 * then this is treated as zero.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(boolean __igncase, int __toff, String __b,
		int __boff, int __len)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Automatically false
		if (__toff < 0 || __boff < 0 ||
			__toff + __len > this.length() || __boff + __len > __b.length())
			return false;
		
		// A quirk of the standard is that negative lengths are not an error
		// but are treated as matches
		if (__len < 0)
			return true;
		
		// Disregarding case
		if (__igncase)
			for (int i = 0; i < __len; i++, __toff++, __boff++)
			{
				char a = this.charAt(__toff),
					b = __b.charAt(__boff);
				
				if (Character.toLowerCase(a) != Character.toLowerCase(b) &&
					Character.toUpperCase(a) != Character.toUpperCase(b))
					return false;
			}
		
		// Regarding case
		else
			for (int i = 0; i < __len; i++, __toff++, __boff++)
				if (this.charAt(__toff) != __b.charAt(__boff))
					return false;
		
		// Matches
		return true;
	}
	
	/**
	 * Returns a string with all characters which match the starting character
	 * which are then replaced with the replacement character.
	 *
	 * @param __a The starting character.
	 * @param __b The replacement character.
	 * @return The resulting string.
	 * @since 2018/09/22
	 */
	public String replace(char __a, char __b)
	{
		// If a character is going to be replaced with itself then no
		// replacement has to actually be performed. Or if the original
		// character is not even in the string.
		if (__a == __b || this.indexOf(__a) < 0)
			return this;
		
		// Get source sequence
		char[] ch = this._chars;
		int n = ch.length;
		
		// Copy data into an array with translated characters
		char[] rv = new char[n];
		for (int i = 0; i < n; i++)
		{
			char c = ch[i];
			if (c == __a)
				c = __b;
			rv[i] = c;
		}
		
		// Build new string
		return new String(rv, (short)0);
	}
	
	/**
	 * Checks if this string starts with the other string at the given index.
	 *
	 * @param __s The string to check for a starting match.
	 * @param __sdx The starting index to start checking at.
	 * @return If this string starts with the given string.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public boolean startsWith(String __s, int __sdx)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1l Starting index in string is out of
		// bounds. (The starting index)}
		if (__sdx < 0)
			throw new IndexOutOfBoundsException(
				String.format("ZZ1l %d", __sdx));
		
		// Need to work on both sequences
		char[] ca = this._chars,
			cb = __s._chars;
		
		// If the second string is empty then it will always match
		int na = ca.length,
			nb = cb.length;
		if (nb == 0)
			return true;
		
		// The second string cannot even fit from this index so do not bother
		// checking anything
		if (__sdx + nb > na)
			return false;
		
		// Find false match
		for (int ia = __sdx, ib = 0; ib < nb; ia++, ib++)
			if (ca[ia] != cb[ib])
				return false;
		
		// False not found, so it matches
		return true;
	}
	
	/**
	 * Checks if this string starts with the other string.
	 *
	 * @param __s The string to check for a starting match.
	 * @return If this string starts with the given string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public boolean startsWith(String __s)
		throws NullPointerException
	{
		return this.startsWith(__s, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public CharSequence subSequence(int __s, int __e)
	{
		// Is the same code as substring
		return this.substring(__s, __e);
	}
	
	/**
	 * Returns a substring of this string starting at the given index.
	 *
	 * @param __s The index to start at.
	 * @return The sub-string for that index.
	 * @throws IndexOutOfBoundsException If the start is outside of the bounds.
	 * @since 2018/11/04
	 */
	public String substring(int __s)
		throws IndexOutOfBoundsException
	{
		// A substring starting at the zero character is the same
		if (__s == 0)
			return this;
		
		// Call other
		return this.substring(__s, this.length());
	}
	
	/**
	 * Returns a substring of this string.
	 *
	 * @param __s The starting index.
	 * @param __e The ending index.
	 * @return The resulting string.
	 * @throws IndexOutOfBoundsException If the string region is outside of
	 * bounds.
	 * @since 2018/09/29
	 */
	public String substring(int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// The entire string region requires no new string
		char[] ch = this._chars;
		int n = ch.length;
		if (__s == 0 && __e == n)
			return this;
		
		// A blank string with no characters
		if (__s == __e)
			return "";
		
		// {@squirreljme.error ZZ1m String substring is outside of bounds.
		// (The start index; The end index; The length)}
		if (__s < 0 || __s > __e || __e > n)
			throw new IndexOutOfBoundsException("ZZ1m " + __s + " " + __e +
				" " + n);
		
		// Derive sub-sequence
		int nl = __e - __s;
		char[] rv = new char[nl];
		for (int o = 0; o < nl; o++, __s++)
			rv[o] = ch[__s];
		
		// Build
		return new String(rv, (short)0);
	}
	
	/**
	 * Returns a character array which contains every character within this
	 * string.
	 *
	 * @return A character array containing the characters of this string.
	 * @since 2017/08/15
	 */
	public char[] toCharArray()
	{
		// Direct copy of the character array
		return this._chars.clone();
	}
	
	/**
	 * Translates this string to lowercase using the current locale.
	 *
	 * Java ME specifies that only Latin-1 characters are supported
	 *
	 * @return The lowercased result of this string.
	 * @since 2018/09/20
	 */
	public String toLowerCase()
	{
		// If this string is lowercased already do not mess with it
		if ((this._quickflags & String._QUICK_ISLOWER) != 0)
			return this;
		
		// Needed for case conversion
		char[] ch = this._chars;
		Locale locale = DefaultLocale.defaultLocale();
		
		// Setup new character array for the conversion
		int n = ch.length;
		char[] rv = new char[n];
		
		// Copy and convert characters
		boolean changed = false;
		for (int i = 0; i < n; i++)
		{
			char a = ch[i],
				b = locale.toLowerCase(a);
			
			// Detect if the string actually changed
			if (!changed && a != b)
				changed = true;
			
			rv[i] = b;
		}
		
		// String was unchanged, so forget about the array we just handled and
		// set that the string is lowercase
		if (!changed)
		{
			this._quickflags |= String._QUICK_ISLOWER;
			return this;
		}
		
		// New string will be lowercase, so ignore this operation
		return new String(rv, String._QUICK_ISLOWER);
	}
	
	/**
	 * Returns {@code this}.
	 *
	 * @return {@code this}.
	 * @since 2017/08/15
	 */
	@Override
	public String toString()
	{
		return this;
	}
	
	/**
	 * Translates this string to uppercase using the current locale.
	 *
	 * Java ME specifies that only Latin-1 characters are supported
	 *
	 * @return The uppercased result of this string.
	 * @since 2018/09/29
	 */
	public String toUpperCase()
	{
		// If this string is uppercased already do not mess with it
		if ((this._quickflags & String._QUICK_ISUPPER) != 0)
			return this;
		
		// Needed for case conversion
		char[] ch = this._chars;
		Locale locale = DefaultLocale.defaultLocale();
		
		// Setup new character array for the conversion
		int n = ch.length;
		char[] rv = new char[n];
		
		// Copy and convert characters
		boolean changed = false;
		for (int i = 0; i < n; i++)
		{
			char a = ch[i],
				b = locale.toUpperCase(a);
			
			// Detect if the string actually changed
			if (!changed && a != b)
				changed = true;
			
			rv[i] = b;
		}
		
		// String was unchanged, so forget about the array we just handled and
		// set that the string is lowercase
		if (!changed)
		{
			this._quickflags |= String._QUICK_ISUPPER;
			return this;
		}
		
		// New string will be uppercase, so ignore this operation
		return new String(rv, String._QUICK_ISUPPER);
	}
	
	/**
	 * This trims all of the low ASCII whitespace and control characters at
	 * the start and the end of this string and returns a new string with
	 * the trimmed whitespace.
	 *
	 * This does not handle any other potential characters which may act as
	 * whitespace in the high unicode range and only handles the first 32
	 * ASCII characters.
	 *
	 * @return A string with the whitespace trimmed, if the string does not
	 * start or end in whitespace then {@code this} is returned.
	 * @since 2016/04/20
	 */
	public String trim()
	{
		// Empty strings do not need trimming
		char[] ch = this._chars;
		int n = ch.length;
		if (n <= 0)
			return this;
		
		// Find starting trim position
		int s;
		for (s = 0; s < n && ch[s] <= String._MIN_TRIM_CHAR; s++)
			;
		
		// Find ending trim position
		int e;
		for (e = n; e > s && ch[e - 1] <= String._MIN_TRIM_CHAR; e--)
			;
		
		// Return trimmed variant of it
		return this.substring(s, e);
	}
	
	/**
	 * Checks to see if this string matches the target sequence.
	 *
	 * @param __s The input sequence to check against.
	 * @return If they are the same or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	private final boolean __contentEquals(CharSequence __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// If the two have different lengths they will never be equal
		char[] ca = this._chars;
		int al = ca.length,
			bl = __s.length();
		if (al != bl)
			return false;
		
		// Check each character
		for (int i = 0; i < al; i++)
			if (ca[i] != __s.charAt(i))
				return false;
		
		// If reached, they are equal
		return true;
	}
	
	/**
	 * Returns the encoded byte sequence.
	 *
	 * @param __e The encoder to use when writing bytes.
	 * @return The bytes from this string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	private final byte[] __getBytes(Encoder __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		// Maximum size of sequences that can be encoded
		int msl;
		byte[] seq = new byte[(msl = __e.maximumSequenceLength())];
		
		// We operate directly on the sequence
		char[] ch = this._chars;
		int n = ch.length;
		
		// Write here
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			(int)(n * __e.averageSequenceLength())))
		{
			// Encode every character!
			for (int i = 0; i < n; i++)
			{
				int sz = __e.encode(ch[i], seq, 0, msl);
				
				// Should not occur
				if (sz < 0)
					throw new todo.OOPS();
				
				baos.write(seq, 0, sz);
			}
			
			// Use this byte array
			return baos.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @param __i The starting index.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @since 2019/05/14
	 */
	private final int __indexOf(CharSequence __b, int __i)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Normalize position
		if (__i < 0)
			__i = 0;
		
		// If the sequence is empty, then it will always be a match
		char[] ca = this._chars;
		int an = ca.length,
			bn = __b.length();
		if (bn <= 0)
			return __i;
		
		// If the string is longer than ours, then it will never be a match
		if (bn > an - __i)
			return -1;
		
		// Do a long complicated loop matching, but we only need to check
		// for as long as the sequence can actually fit
__outer:
		for (int a = __i, lim = an - bn; a < lim; a++)
		{
			// Check sequence characters
			for (int x = a, b = 0; b < bn; x++, b++)
				if (ca[x] != __b.charAt(b))
					continue __outer;
			
			// Since the inner loop continues to the outer, if this was reached
			// then we know the full sequence was matched
			return a;
		}
		
		// Otherwise nothing was found because we tried every character
		return -1;
	}
	
	/**
	 * Invokes {@code String.valueOf(__c, __o, __l)}.
	 *
	 * @param __c The input character array to copy.
	 * @param __o The starting offset.
	 * @param __l The number of characters to copy.
	 * @return The result of the other call.
	 * @since 2016/06/13
	 */
	public static String copyValueOf(char[] __c, int __o, int __l)
	{
		return String.valueOf(__c, __o, __l);
	}
	
	/**
	 * Invokes {@code String.valueOf(__a)}.
	 *
	 * @param __c The input character array to copy.
	 * @return The result of the other call.
	 * @since 2016/06/13
	 */
	public static String copyValueOf(char[] __c)
	{
		return String.valueOf(__c);
	}
	
	/**
	 * Returns a formatted string using a temporary instance of the
	 * {@link Formatter} class.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments to the formatter.
	 * @return The formatted string.
	 * @throws IllegalArgumentException If the format is not correct.
	 * @throws NullPointerException On null arguments.
	 * @see java.util.Formatter
	 * @since 2018/11/02
	 */
	public static String format(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		// Just forward everything to this formatter
		return new Formatter().format(__fmt, __args).toString();
	}
	
	/**
	 * Returns the value of the given object as a string.
	 *
	 * @param __a The object to get the string value of, if {@code null} then
	 * the string {@code "null"} is returned.
	 * @return The string value of the given object or {@code "null"}
	 * @since 2016/06/13
	 */
	public static String valueOf(Object __a)
	{
		// The value is a string already
		if (__a instanceof String)
			return (String)__a;
		
		// If null use null
		if (__a == null)
			return "null";
		
		// Just return the toString of the given object.
		return __a.toString();
	}
	
	/**
	 * Returns a string representation of the given character array.
	 *
	 * @param __a The array.
	 * @return The resulting string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public static String valueOf(char[] __a)
		throws NullPointerException
	{
		return String.valueOf(__a, 0, (__a != null ? __a.length : 0));
	}
	
	/**
	 * Returns a string representation of the given character array.
	 *
	 * @param __c The input array.
	 * @param __o The offset.
	 * @param __l The number of characters to set.
	 * @return The resulting string.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public static String valueOf(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return new String(__c, __o, __l);
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(boolean __a)
	{
		return Boolean.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(char __a)
	{
		return Character.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(int __a)
	{
		return Integer.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(long __a)
	{
		return Long.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(float __a)
	{
		return Float.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(double __a)
	{
		return Double.valueOf(__a).toString();
	}
}

Added modules/cldc-compact/src/main/java/java/lang/StringBuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is a thread safe version of {@link StringBuilder}, to reduce the need
 * to document everything please see that documentation instead.
 *
 * The instance itself is used as the monitor.
 *
 * @see StringBuilder
 * @since 2018/12/09
 */
public final class StringBuffer
	implements Appendable, CharSequence
{
	/** The base buffer. */
	protected final StringBuilder builder;
	
	/**
	 * Initializes a blank string buffer.
	 *
	 * @since 2018/12/08
	 */
	public StringBuffer()
	{
		this.builder = new StringBuilder();
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(int __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(String __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(CharSequence __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * See {@link StringBuffer#append(Object)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(Object __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(String __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(StringBuffer)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(StringBuffer __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(CharSequence)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(CharSequence __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(CharSequence, int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(CharSequence __a, int __b, int __c)
	{
		synchronized (this)
		{
			this.builder.append(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char[])}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char[] __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char[], int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char[] __a, int __b, int __c)
	{
		synchronized (this)
		{
			this.builder.append(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(boolean)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(boolean __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(int __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(long)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(long __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(float)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(float __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(double)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(double __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#capacity()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int capacity()
	{
		synchronized (this)
		{
			return this.builder.capacity();
		}
	}
	
	/**
	 * See {@link StringBuffer#charAt(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public char charAt(int __a)
	{
		synchronized (this)
		{
			return this.builder.charAt(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#delete(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer delete(int __a, int __b)
	{
		synchronized (this)
		{
			this.builder.delete(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#deleteCharAt(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer deleteCharAt(int __a)
	{
		synchronized (this)
		{
			this.builder.deleteCharAt(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#ensureCapacity(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void ensureCapacity(int __a)
	{
		synchronized (this)
		{
			this.builder.ensureCapacity(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#getChars(int, int, char[], int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		synchronized (this)
		{
			this.builder.getChars(__a, __b, __c, __d);
		}
	}
	
	/**
	 * See {@link StringBuffer#indexOf(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int indexOf(String __a)
	{
		synchronized (this)
		{
			return this.builder.indexOf(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#indexOf(String, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int indexOf(String __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.indexOf(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char[], int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char[] __b, int __c, int __d)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b, __c, __d);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, Object)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, Object __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, String __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char[])}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char[] __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, CharSequence)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, CharSequence __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, CharSequence, int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, CharSequence __b, int __c,
		int __d)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b, __c, __d);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, boolean)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, boolean __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, int __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, long)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, long __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, float)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, float __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, double)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, double __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#lastIndexOf(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int lastIndexOf(String __a)
	{
		synchronized (this)
		{
			return this.builder.lastIndexOf(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#lastIndexOf(String, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int lastIndexOf(String __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.lastIndexOf(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#length()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int length()
	{
		synchronized (this)
		{
			return this.builder.length();
		}
	}
	
	/**
	 * See {@link StringBuffer#replace(int, int, String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer replace(int __a, int __b, String __c)
	{
		synchronized (this)
		{
			this.builder.replace(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#reverse()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer reverse()
	{
		synchronized (this)
		{
			this.builder.reverse();
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#setCharAt(int, char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void setCharAt(int __a, char __b)
	{
		synchronized (this)
		{
			this.builder.setCharAt(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#setLength(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void setLength(int __a)
	{
		synchronized (this)
		{
			this.builder.setLength(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#subSequence(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public CharSequence subSequence(int __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.subSequence(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#substring(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String substring(int __a)
	{
		synchronized (this)
		{
			return this.builder.substring(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#substring(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String substring(int __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.substring(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#toString()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String toString()
	{
		synchronized (this)
		{
			return this.builder.toString();
		}
	}
	
	/**
	 * See {@link StringBuffer#trimToSize()}.
	 *
	 * @since 2018/12/08
	 */
	public void trimToSize()
	{
		synchronized (this)
		{
			this.builder.trimToSize();
		}
	}
}

Added modules/cldc-compact/src/main/java/java/lang/StringBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This is a string which has a mutable buffer.
 *
 * This class is not thread safe, for that use {@link StringBuffer} instead.
 *
 * The default capacity of this builder is 16 characters.
 *
 * @since 2018/09/22
 */
public final class StringBuilder
	implements Appendable, CharSequence
{
	/** Default capacity of the internal array. */
	private static final int _DEFAULT_CAPACITY =
		16;
	
	/** The internal buffer for storing characters. */
	private char[] _buffer;
	
	/** The characters which are in the buffer. */
	private int _at;
	
	/** The limit of the string buffer. */
	private int _limit;
	
	/**
	 * Initializes with the default capacity.
	 *
	 * @since 2018/09/22
	 */
	public StringBuilder()
	{
		this(StringBuilder._DEFAULT_CAPACITY);
	}
	
	/**
	 * Initailizes with the given capacity.
	 *
	 * @param __c The initial capacity.
	 * @throws NegativeArraySizeException If the capacity is negative.
	 * @since 2018/09/22
	 */
	public StringBuilder(int __c)
		throws NegativeArraySizeException
	{
		// {@squirreljme.error ZZ1n The initial capacity cannot be negative.
		// (The initial capacity)}
		if (__c < 0)
			throw new NegativeArraySizeException(
				String.format("ZZ1n %d", __c));
		
		// Initialize buffer
		this._buffer = new char[__c];
		this._limit = __c;
	}
	
	/**
	 * Initializes with the initial characters given by the input sequence,
	 * the internal buffer is the default capacity plus the input string
	 * length.
	 *
	 * @param __s The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder(String __s)
		throws NullPointerException
	{
		this((CharSequence)__s);
	}
	
	/**
	 * Initializes with the initial characters given by the input sequence,
	 * the internal buffer is the default capacity plus the input string
	 * length.
	 *
	 * @param __cs The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder(CharSequence __cs)
	{
		if (__cs == null)
			throw new NullPointerException("NARG");
		
		// Initialize buffer with the default and the input sequence length
		this._buffer = new char[StringBuilder._DEFAULT_CAPACITY +
			__cs.length()];
		
		// Just append the sequence since the code is the same
		this.append(__cs);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(Object __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the given string.
	 *
	 * @param __v The string to append.
	 * @return {@code this}.
	 * @since 2018/09/22 
	 */
	public StringBuilder append(String __v)
	{
		if (__v == null)
			__v = "null";
		
		return this.append((CharSequence)__v, 0, __v.length());
	}
	
	/**
	 * Appends the given string buffer.
	 *
	 * @param __v The string buffer to append.
	 * @return {@code this}.
	 * @since 2018/09/22 
	 */
	public StringBuilder append(StringBuffer __v)
	{
		// Is null, cannot lock on it so just forward
		if (__v == null)
			return this.append("null");
		
		// Lock on the buffer because this is thread safe
		synchronized (__v)
		{
			return this.append((CharSequence)__v, 0, __v.length());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(CharSequence __v)
	{
		// Print null instead
		if (__v == null)
			__v = "null";
		
		return this.append(__v, 0, __v.length());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(CharSequence __v, int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// Print null?
		if (__v == null)
			__v = "null";
		
		// Check bounds
		int vn = __v.length();
		if (__s < 0 || __e < 0 || __e > vn || __s > __e)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Length to add
		int len = __e - __s;
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + len > limit ? this.__buffer(len) : this._buffer);
		
		// Place input characters at this point
		while (__s < __e)
			buffer[at++] = __v.charAt(__s++);
		
		// Set new size
		this._at = at;
		
		return this;
	}
	
	/**
	 * Appends the given characters to the string.
	 *
	 * @param __c The characters to append.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder append(char[] __c)
		throws NullPointerException
	{
		return this.append(__c, 0, __c.length);
	}
	
	/**
	 * Appends the given characters to the string.
	 *
	 * @param __c The characters to append.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder append(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + __l > limit ? this.__buffer(__l) : this._buffer);
		
		// Place input characters at this point
		for (int i = 0; i < __l; i++)
			buffer[at++] = __c[__o++];
		
		// Set new size
		this._at = at;
		
		return this;
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(boolean __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(char __v)
	{
		// Before we go deeper check if the buffer needs to grow
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + 1 > limit ? this.__buffer(1) : this._buffer);
		
		// Add to the end
		buffer[at] = __v;
		this._at = at + 1;
		
		// Self
		return this;
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(int __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(long __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(float __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(double __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Returns the current capacity of the internal buffer.
	 *
	 * @return The internal capacity.
	 * @since 2018/09/22
	 */
	public int capacity()
	{
		return this._buffer.length;
	}
	
	/**
	 * Returns the character at the given index.
	 *
	 * @param __dx The index.
	 * @return The character at the given index.
	 * @throws IndexOutOfBoundsException If the character is outside of
	 * bounds.
	 * @since 2018/09/29
	 */
	public char charAt(int __dx)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1o Out of bound access. (The index)}
		if (__dx < 0 || __dx >= this._at)
			throw new IndexOutOfBoundsException("ZZ1o " + __dx);
		
		return this._buffer[__dx];
	}
	
	public StringBuilder delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder deleteCharAt(int __a)
	{
		throw new todo.TODO();
	}
	
	public void ensureCapacity(int __a)
	{
		throw new todo.TODO();
	}
	
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int indexOf(String __a)
	{
		throw new todo.TODO();
	}
	
	public int indexOf(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder insert(int __a, char[] __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/29
	 */
	public StringBuilder insert(int __dx, Object __v)
	{
		return this.insert(__dx, (__v == null ? "null" : __v.toString()));
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws StringIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, String __v)
		throws StringIndexOutOfBoundsException
	{
		return this.insert(__dx, (CharSequence)__v);
	}
	
	public StringBuilder insert(int __a, char[] __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, CharSequence __v)
		throws IndexOutOfBoundsException
	{
		// Print null instead
		if (__v == null)
			__v = "null";
		
		return this.insert(__dx, __v, 0, __v.length());
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @param __s The start position.
	 * @param __e The end position.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, CharSequence __v, int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1p Cannot insert sequence at a negative
		// index.}
		if (__dx < 0)
			throw new IndexOutOfBoundsException("ZZ1p");
		
		// Check bounds
		int vn = __v.length();
		if (__s < 0 || __e < 0 || __e > vn || __s > __e)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Length to add
		int len = __e - __s;
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + len > limit ? this.__buffer(len) : this._buffer);
		
		// {@squirreljme.error ZZ1q The index of insertion exceeds the
		// length of the current string. (The insertion index; The string
		// length)}
		if (__dx > at)
			throw new IndexOutOfBoundsException(String.format("ZZ1q %d %d",
				__dx, at));
		
		// First move all characters on the right to the end so that this can
		// properly fit
		for (int i = at - 1, o = i + len; i >= __dx; i--, o--)
			buffer[o] = buffer[i];
		
		// Place input characters at this point
		while (__s < __e)
			buffer[__dx++] = __v.charAt(__s++);
		
		// Set new size
		this._at = at + len;
		
		return this;
	}
	
	public StringBuilder insert(int __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given character into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, char __v)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1r Cannot insert sequence at a negative
		// index.}
		if (__dx < 0)
			throw new IndexOutOfBoundsException("ZZ1r");
		
		// Before we go deeper check if the buffer needs to grow
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + 1 > limit ? this.__buffer(1) : this._buffer);
		
		// {@squirreljme.error ZZ1s The index of insertion exceeds the
		// length of the current string. (The insertion index; The string
		// length)}
		if (__dx > at)
			throw new IndexOutOfBoundsException(String.format("ZZ1s %d %d",
				__dx, at));
		
		// First move all characters on the right to the end so that this can
		// properly fit
		for (int i = at - 1, o = i + 1; i >= __dx; i--, o--)
			buffer[o] = buffer[i];
		
		// Place input characters at this point
		buffer[__dx] = __v;
		
		// Set new size
		this._at = at + 1;
		
		return this;
	}
	
	/**
	 * Inserts the given value into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, int __v)
	{
		return this.insert(__dx, Long.valueOf(__v).toString());
	}
	
	/**
	 * Inserts the given value into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, long __v)
	{
		return this.insert(__dx, Long.valueOf(__v).toString());
	}
	
	public StringBuilder insert(int __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder insert(int __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public int lastIndexOf(String __a)
	{
		throw new todo.TODO();
	}
	
	public int lastIndexOf(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of the string.
	 *
	 * @return The string length.
	 * @since 2018/09/29
	 */
	public int length()
	{
		return this._at;
	}
	
	public StringBuilder replace(int __a, int __b, String __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reverses all of the characters in the string.
	 *
	 * @return {@code this}.
	 * @since 2018/09/23
	 */
	public StringBuilder reverse()
	{
		// Get the buffer
		char[] buffer = this._buffer;
		int at = this._at;
		
		// Swap all the characters, a less than be because if it reaches the
		// center there will be no need to swap anything
		for (int a = 0, b = at - 1; a < b; a++, b--)
		{
			char x = buffer[a];
			buffer[a] = buffer[b];
			buffer[b] = x;
		}
		
		// Self
		return this;
	}
	
	public void setCharAt(int __dx, char __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the length of the internal buffer, either truncating it or
	 * padding it with NUL characters.
	 *
	 * @param __nl The new length.
	 * @throws IndexOutOfBoundsException If the length is negative.
	 * @since 2018/10/13
	 */
	@ImplementationNote("This does not actually even pad NULs it just " +
		"sets the length or regrows the buffer as needed.")
	public void setLength(int __nl)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1t Attempt to use a length of a negative
		// size.}
		if (__nl < 0)
			throw new IndexOutOfBoundsException("ZZ1t");
		
		// We only need to do something if we are going up, staying the same
		// or going down just sets a variable
		// If the buffer is resized, we do not need to pad for NUL characters
		// because it already has zero values
		int at = this._at;
		if (__nl > at)
			this.__buffer(__nl);
		
		// Set new length
		this._at = __nl;
	}
	
	/**
	 * Invokes {@code this.substring(__s, __e)}.
	 *
	 * @param __s The start.
	 * @param __e The end.
	 * @return The sub-sequence.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/11
	 */
	public CharSequence subSequence(int __s, int __e)
		throws IndexOutOfBoundsException
	{
		return this.substring(__s, __e);
	}
	
	/**
	 * Returns a string which is a substring of the given portion of the
	 * string.
	 *
	 * @param __s The start.
	 * @return The resulting sub-string.
	 * @throws StringIndexOutOfBoundsException If the specified positions
	 * are not within the string bounds.
	 * @since 2019/05/11
	 */
	public String substring(int __s)
		throws StringIndexOutOfBoundsException
	{
		return this.substring(__s, this.length());
	}
	
	/**
	 * Returns a string which is a substring of the given portion of the
	 * string.
	 *
	 * @param __s The start.
	 * @param __e The end.
	 * @return The resulting sub-string.
	 * @throws StringIndexOutOfBoundsException If the specified positions
	 * are not within the string bounds.
	 * @since 2019/05/11
	 */
	public String substring(int __s, int __e)
		throws StringIndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1u String index out of bounds.}
		int len = this._at;
		if (__s < 0 || __e < 0 || __s > __e || __s > len || __e > len)
			throw new StringIndexOutOfBoundsException("ZZ1u");
		
		// Would be an empty string
		if (__s == __e)
			return "";
		
		// Build string and operate directly on the buffer
		return new String(this._buffer, __s, __e - __s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public String toString()
	{
		return new String(this._buffer, 0, this._at);
	}
	
	public void trimToSize()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Obtains the buffer, potentially resizing it to fit the given amount
	 * of characters.
	 *
	 * @param __l The number of characters to add.
	 * @return The buffer.
	 * @since 2018/09/23
	 */
	private final char[] __buffer(int __l)
	{
		// Get buffer properties
		char[] buffer = this._buffer;
		int limit = this._limit,
			at = this._at;
		
		// Need to resize the buffer to fit this?
		int nextat = at + __l;
		if (nextat > limit)
		{
			int newcapacity = nextat + StringBuilder._DEFAULT_CAPACITY;
			
			// Copy characters over
			char[] extra = new char[newcapacity];
			for (int i = 0; i < at; i++)
				extra[i] = buffer[i];
			
			this._buffer = (buffer = extra);
			this._limit = newcapacity;
		}
		
		return buffer;
	}
}

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

package java.lang;

/**
 * This is thrown when an attempt is made to read from an index within a string
 * which is not within bounds.
 *
 * @since 2018/09/16
 */
public class StringIndexOutOfBoundsException
	extends IndexOutOfBoundsException
{
	/**
	 * Initializes the exception with no message and no cause.
	 *
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initailizes the exception with the given index with no cause.
	 *
	 * @param __dx The index to reference.
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException(int __dx)
	{
		// {@squirreljme.error ZZ1v String index out of bounds. (The index)}
		super("ZZ1v " + __dx);
	}
	
	/**
	 * Initializes the exception with given message and no cause.
	 *
	 * @param __m The message used.
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Suppresses warnings that are generated by the compiler so that they do not
 * appear for the given method. Duplicates are permitted and values which are
 * unknown are ignored.
 *
 * The following warnings may have support to be disabled, although it is not
 * required: {@code all}, {@code boxing}, {@code cast}, {@code dep-ann},
 * {@code deprecation}, {@code fallthrough}, {@code finally}, {@code hiding},
 * {@code incomplete-switch}, {@code nls}, {@code null}, {@code rawtypes},
 * {@code restriction}, {@code serial}, {@code static-access},
 * {@code synthetic-access}, {@code unchecked},
 * {@code unqualified-field-access}, and {@code unused}.
 *
 * @since 2018/09/19
 */
@Target(value={ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
	ElementType.PARAMETER, ElementType.CONSTRUCTOR,
	ElementType.LOCAL_VARIABLE})
@Retention(value=RetentionPolicy.SOURCE)
public @interface SuppressWarnings
{
	/** @return The warnings that should be suppressed. */
	String[] value();
}

Added modules/cldc-compact/src/main/java/java/lang/System.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.asm.ConsoleOutput;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.ConsoleOutputStream;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import java.io.PrintStream;

/**
 * This class contains methods which are used to interact with the system and
 * the environment.
 *
 * @since 2018/10/14
 */
public final class System
{
	/** Standard error stream (stderr). */
	public static final PrintStream err =
		new __CanSetPrintStream__(new PrintStream(
			new ConsoleOutputStream(ConsoleOutput.ERROR), true));
	
	/** Standard output stream (stdout). */
	public static final PrintStream out =
		new __CanSetPrintStream__(new PrintStream(
			new ConsoleOutputStream(ConsoleOutput.OUTPUT), true));
	
	/**
	 * Not used.
	 *
	 * @since 2018/03/01
	 */
	private System()
	{
	}
	
	/**
	 * Copies from the source array to the destination.
	 *
	 * @param __src The source array.
	 * @param __srcoff The source offset.
	 * @param __dest The destination array.
	 * @param __destoff The destination offset.
	 * @param __copylen The number of elements to copy.
	 * @throws ArrayStoreException If the destination array cannot contain
	 * the given data.
	 * @throws IndexOutOfBoundsException If the offset and or/lengths are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/27
	 */
	public static void arraycopy(Object __src, int __srcoff,
		Object __dest, int __destoff, int __copylen)
		throws ArrayStoreException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__src == null || __dest == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1w Negative offsets and/or length cannot be
		// specified. (The source offset; The destination offset; The copy
		// length)}
		if (__srcoff < 0 || __destoff < 0 || __copylen < 0)
			throw new IndexOutOfBoundsException(String.format("ZZ1w %d %d %d",
				__srcoff, __destoff, __copylen));
		
		// {@squirreljme.error ZZ1x Copy operation would exceed the bounds of
		// the array. (Source offset; Source length; Destination offset;
		// Destination length; The copy length)}
		int srclen = Assembly.arrayLength(__src),
			destlen = Assembly.arrayLength(__dest);
		if (__srcoff + __copylen > srclen ||
			__destoff + __copylen > destlen)
			throw new IndexOutOfBoundsException(String.format(
				"ZZ1x %d %d %d %d %d", __srcoff, srclen, __destoff, destlen,
				__copylen));
		
		// {@squirreljme.error ZZ1y The source array type is not compatible
		// with destination array. (The source array; The destination array)}
		if (!__dest.getClass().isAssignableFrom(__src.getClass()))
			throw new ArrayStoreException(String.format(
				"ZZ1y %s %s", __src, __dest));
		
		// These offsets for the loops are the same
		int i = __srcoff,
			o = __destoff,
			end = __srcoff + __copylen;
		
		// Copy depending on the type
		if (__src instanceof boolean[])
			for (boolean[] s = (boolean[])__src, d = (boolean[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof byte[])
			for (byte[] s = (byte[])__src, d = (byte[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof short[])
			for (short[] s = (short[])__src, d = (short[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof char[])
			for (char[] s = (char[])__src, d = (char[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof int[])
			for (int[] s = (int[])__src, d = (int[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof long[])
			for (long[] s = (long[])__src, d = (long[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof float[])
			for (float[] s = (float[])__src, d = (float[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof double[])
			for (double[] s = (double[])__src, d = (double[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else
			for (Object[] s = (Object[])__src, d = (Object[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
	}
	
	/**
	 * Returns the current time on the system's clock in UTC since the epoch
	 * (January 1, 1970 UTC).
	 *
	 * Note that this clock is not monotonic in that if a system adjusts the
	 * system clock this method may return values lower than previous calls
	 * which are made.
	 *
	 * Depending on the host hardware and operating system, the granularity of
	 * this clock may or may not be accurate.
	 *
	 * @return The number of milliseconds since the epoch.
	 * @since 2017/11/10
	 */
	public static long currentTimeMillis()
	{
		// Returns the current time in UTC, not local time zone.
		return Assembly.sysCallPVL(SystemCallIndex.TIME_MILLI_WALL);
	}
	
	/**
	 * Indicates that the application exits with the given code.
	 *
	 * @param __e The exit code, the value of this code may change according
	 * to the host operating system and the resulting process might not exit
	 * with the given code.
	 * @since 2017/02/08
	 */
	public static void exit(int __e)
	{
		Runtime.getRuntime().exit(__e);
	}
	
	/**
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public static void gc()
	{
		Runtime.getRuntime().gc();
	}
	
	/**
	 * This obtains the value of a system property (if one is set) and returns
	 * its value. System properties are declared by the system and are used
	 * by applications to potentially modify their behavior.
	 *
	 * {@squirreljme.property java.io.tmpdir This is the temporary directory
	 * which indicates where temporary files (those that are deleted after
	 * an unspecified duration) are to be placed. If there is no filesystem
	 * on the device then a blank string will always be returned.}
	 * {@squirreljme.property java.version This is the version of the virtual
	 * machine which the environment runs under.}
	 * {@squirreljme.property java.vendor This is the vendor of the virtual
	 * machine and specifies who wrote it.}
	 * {@squirreljme.property java.vendor.url This is a URL which usually
	 * points to the website of the vendor.}
	 * {@squirreljme.property line.separator This represents the line
	 * separation sequence that the host operating system uses for its native
	 * files. Generally it would either be {@code '\n'}, {@code '\r'}, or
	 * {@code "\r\n"), however retro-systems might use a different line ending
	 * sequence.}}
	 * {@squirreljme.property microedition.configuration This is the current
	 * configuration of CLDC library which indicates which primary classes
	 * are available to it. The values will either be {@code "CLDC-1.8"} for
	 * the complete set of APIs and {@code "CLDC-1.8-Compact"} for the compact
	 * set of APIs.}
	 * {@squirreljme.property microedition.deviceid.uuid This is the unique
	 * identifier to the current device that regardless of the number of
	 * reboots and reinitializations that occur, this should return the same
	 * value.}
	 * {@squirreljme.property microedition.encoding This is the character
	 * encoding that is used by default for specific methods when one has not
	 * been specified. On modern systems this is likely to be {@code "UTF-8},
	 * while on retro-devices and operating systems this will likely be an
	 * encoding starting with {@code "x-squirreljme"}. Please note that the
	 * default encoding might not be compatible with UTF-8 (and may possibly
	 * well be EBCDIC).}
	 * {@squirreljme.property microedition.hostname The host name of the
	 * current system that the virtual machine is running on as it appears
	 * to other machines on the network.}
	 * {@squirreljme.property microedition.locale The current locale that the
	 * library will use.}
	 * {@squirreljme.property microedition.platform This is the device that
	 * SquirrelJME is running on. It is in the format of
	 * {@code (Manufacturer)(DeviceModelNumber)[/version[/comments]]}. The
	 * manufacturer and device model number are concatenated with no spaces.}
	 * {@squirreljme.property microedition.profiles This is a space separated
	 * list of profiles which are supported by the run-time, an example
	 * value that may be returned is MIDP-3.0 representing that that specified
	 * standard is implemented.}
	 * {@squirreljme.property os.arch This is the architecture of the hardware
	 * that SquirrelJME is running on, the value is dependent on the platform
	 * itself. Note that architecture names use standard SquirrelJME
	 * architecture names.}
	 * {@squirreljme.property os.name This is the name of the operating system
	 * that SquirrelJME is running on, if SquirrelJME is the operating itself
	 * then this value will be {@code "squirreljme"}.}
	 * {@squirreljme.property os.version This is the version number of the
	 * host operating system. The returned value might not be a number and may
	 * be a string representing the host.}
	 * {@squirreljme.property user.dir This is the current working directory
	 * which indicates the location where non-absolute file paths are derived
	 * from. If there is no filesystem on the device then a blank string will
	 * always be returned.}
	 *
	 * @param __k The system property value to obtain.
	 * @return The value of the system property or {@code null} if it is not
	 * does not exist.
	 * @throws IllegalArgumentException If the key is empty.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current process is not permitted to
	 * access system properties or obtain the value of a specific property.
	 * @since 2016/05/21
	 */
	public static String getProperty(String __k)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		// Check
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1z Cannot request a system property which has
		// a blank key.}
		if (__k.equals(""))
			throw new IllegalArgumentException("ZZ1z");
		
		// Short circuit for run-time detection
		if (__k.equals("cc.squirreljme.isruntime"))
			return "true";
		
		// Not allowed to do this?
		System.getSecurityManager().checkPropertyAccess(__k);
		
		// Depends on the property
		String rv;
		switch (__k)
		{
				// API level of SquirrelJME
			case "cc.squirreljme.apilevel":
				return ApiLevel.levelToString(ApiLevel.CURRENT_LEVEL);
			
				// SquirrelJME guest depth
			case "cc.squirreljme.guests":
				return Integer.toString(SystemProperties.guestDepth());
				
				// SquirrelJME VM executable path
			case "cc.squirreljme.vm.execpath":
				return SystemProperties.executablePath();
				
				// SquirrelJME free memory
			case "cc.squirreljme.vm.freemem":
				return Long.toString(Runtime.getRuntime().freeMemory());
				
				// SquirrelJME total memory
			case "cc.squirreljme.vm.totalmem":
				return Long.toString(Runtime.getRuntime().totalMemory());
				
				// SquirrelJME free memory
			case "cc.squirreljme.vm.maxmem":
				return Long.toString(Runtime.getRuntime().maxMemory());
			
				// The version of the Java virtual machine (fixed value)
			case "java.version":
				return "1.8.0";
				
				// The version of the JVM (full)
			case "java.vm.version":
				return SystemProperties.javaVMVersion();
				
				// The name of the JVM
			case "java.vm.name":
				return SystemProperties.javaVMName();
				
				// The vendor of the JVM
			case "java.vm.vendor":
				return SystemProperties.javaVMVendor();
			
				// The e-mail of the JVM
			case "java.vm.vendor.email":
				return SystemProperties.javaVMEmail();
			
				// The URL of the JVM
			case "java.vm.vendor.url":
				return SystemProperties.javaVMURL();
				
				// The vendor of the class libraries
			case "java.vendor":
				return "Stephanie Gawroriski";
				
				// Non-standard e-mail address
			case "java.vendor.email":
				return "xerthesquirrel@gmail.com";
				
				// The URL to the virtual machine's site
			case "java.vendor.url":
				return "http://squirreljme.cc/";
				
				// The name of the runtime library
			case "java.runtime.name":
				return "SquirrelJME";
				
				// The version of the run-time
			case "java.runtime.version":
				return SystemProperties.javaRuntimeVersion();
				
				// End of line character
			case "line.separator":
				rv = SystemProperties.systemProperty("line.separator");
				if (rv == null)
					return "\n";
				return rv;
				
				// The current configuration, must be set!
			case "microedition.configuration":
				rv = SystemProperties.systemProperty(
					"microedition.configuration");
				if (rv == null)
					try
					{
						Class<?> file = Class.forName("java.nio.FileSystem");
						if (file == null)
							return "CLDC-1.8-Compact";
						return "CLDC-1.8";
					}
					catch (ClassNotFoundException e)
					{
						return "CLDC-1.8-Compact";
					}
				return rv;
				
				// The current encoding
			case "microedition.encoding":
				rv = SystemProperties.systemProperty("microedition.encoding");
				if (rv == null)
					return CodecFactory.FALLBACK_ENCODING;
				return rv;
				
				// The current local, must be set!
			case "microedition.locale":
				rv = SystemProperties.systemProperty("microedition.locale");
				if (rv == null)
					return "en-US";
				return rv;
				
				// The current platform
			case "microedition.platform":
				return "SquirrelJME/" + SquirrelJME.RUNTIME_VERSION;
				
				// Unknown, use system call
			default:
				return SystemProperties.systemProperty(__k);
		}
	}
	
	/**
	 * Obtains the specified system property and if it has not been set then
	 * the default value will be returned instead.
	 *
	 * @param __k The system property to get.
	 * @param __d If the system property is not set (returns {@code null}
	 * then this value will be returned instead.
	 * @return The system property.
	 * @throws IllegalArgumentException If the requested system property is
	 * not valid (it is blank).
	 * @throws NullPointerException If no key was specified.
	 * @throws SecurityException If obtaining the given system property is
	 * not permitted.
	 * @since 2017/08/13
	 */
	public static String getProperty(String __k, String __d)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		// Get it
		String rv = System.getProperty(__k);
		
		// If not set, return the default, otherwise the read value
		if (rv == null)
			return __d;
		return rv;
	}
	
	/**
	 * Returns the current security manager that is in use.
	 *
	 * @return The current security manager in use.
	 * @since 2018/09/18
	 */
	public static SecurityManager getSecurityManager()
	{
		// Lock because it is managed by that class for checking
		synchronized (SecurityManager.class)
		{
			return SecurityManager._CURRENT_MANAGER;
		}
	}
	
	/**
	 * This returns the identity hash code of the object. The identity hash
	 * code is randomly given by the virtual machine to an object. There is
	 * no definition on how the value is to be derived. It may be a unique
	 * object ID or it may be a memory address. Two objects may also share the
	 * same identity hash code.
	 *
	 * @param __o The input object to get the hash code for.
	 * @return The hash code which was given by the virtual machine, if the
	 * input is {@code null} then {@code 0} is returned.
	 * @since 2015/11/09
	 */
	public static int identityHashCode(Object __o)
	{
		// If null, this is zero
		if (__o == null)
			return 0;
		
		return ObjectAccess.identityHashCode(__o);
	}
	
	/**
	 * Returns the number of nanoseconds which have passed from a previously
	 * unspecified time. The returned value might not be accurate to the
	 * nanosecond. This clock is monotonic and does not suffer from time
	 * shifts caused by clock adjustments.
	 *
	 * The value returned here is specific to the current virtual machine and
	 * cannot be used elsewhere. Even two virtual machines running on the
	 * same system can use completely different values.
	 *
	 * After about 292 years (2 to the 63rd power nanoseconds) using signed
	 * comparison to calculate the amount of time that has passed will no
	 * longer function properly. For extremely long running processes it is
	 * recommended to treat the values as unsigned to extend past this limit
	 * or handle the overflow of the time value to represent any time
	 * quantity, this of course requires that time be checked every 292 or
	 * 584 years).
	 *
	 * @return The number of nanoseconds which have passed.
	 * @since 2016/06/16
	 */
	public static long nanoTime()
	{
		// Returns the current monotonic clock time
		return Assembly.sysCallPVL(SystemCallIndex.TIME_NANO_MONO);
	}
	
	/**
	 * Sets the new destination for standard error.
	 *
	 * Note that the {@link System#err} field is not changed, a wrapper class
	 * is used to prevent reflective abuse.
	 *
	 * @param __a The new stream to use when outputting values.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current program lacks the given
	 * permission to set the stream.
	 * @since 2016/03/17
	 */
	public static void setErr(PrintStream __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Not allowed to do this?
		System.getSecurityManager().checkPermission(new RuntimePermission("setIO"));
		
		// Use a wrapped class to prevent final abuse.
		((__CanSetPrintStream__)System.err).__set(__a);
	}
	
	/**
	 * Sets the new destination for standard output.
	 *
	 * Note that the {@link System#out} field is not changed, a wrapper class
	 * is used to prevent reflective abuse.
	 *
	 * @param __a The new stream to use when outputting values.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current program lacks the given
	 * permission to set the stream.
	 * @since 2016/03/17
	 */
	public static void setOut(PrintStream __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Not allowed to do this?
		System.getSecurityManager().checkPermission(new RuntimePermission("setIO"));
		
		// Use a wrapped class to prevent final abuse.
		((__CanSetPrintStream__)System.out).__set(__a);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Thread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.UncaughtExceptionHandler;
import java.util.HashMap;
import java.util.Map;

/**
 * A thread represents literally a single stream of execution that can
 * execute concurrently (or not).
 *
 * SquirrelJME may be running with multiple threads executing at once or it
 * may also be executing cooperatively (only a single thread at a time). If
 * SquirrelJME is running cooperatively then only locking,
 * {@link Thread#sleep(long, int)}, or {@link Thread#yield()} will allow
 * another thread to run.
 *
 * @since 2018/12/07
 */
@ImplementationNote("Internally all threads start in the Thread.__start() " +
	"method which sets up the thread and such.")
public class Thread
	implements Runnable
{
	/** Use fake name for string? */
	private static final String _USE_FAKE_NAME =
		new String();
	
	/** Maximum supported priority. */
	public static final int MAX_PRIORITY =
		10;
	
	/** Minimum supported priority. */
	public static final int MIN_PRIORITY =
		1;
	
	/** Default priority. */
	public static final int NORM_PRIORITY =
		5;
	
	/** Start kind: Self Runnable */
	private static final int _START_SELF_RUNNABLE =
		1;
	
	/** Start kind: Specified Runnable. */
	private static final int _START_GIVEN_RUNNABLE =
		2;
	
	/** Start kind: MIDlet (construct then run startApp()). */
	private static final int _START_MIDLET =
		3;
	
	/** Start kind: main() method (is String[] argument). */
	private static final int _START_MAIN =
		4;
	
	/** Threads by virtual ID. */
	private static final Map<Integer, Thread> _BY_VIRTID =
		new HashMap<>();
	
	/** Threads by real ID. */
	private static final Map<Integer, Thread> _BY_REALID =
		new HashMap<>();
	
	/** The next virtual thread ID. */
	private static volatile int _NEXT_VIRTUAL_ID =
		0;
	
	/** The active number of threads. */
	private static volatile int _ACTIVE_THREADS;
	
	/** Which kind of start are we doing? */
	private final int _startkind;
	
	/** The method to execute. */
	private final StaticMethod _runmethod;
	
	/** The argument to the method. */
	private final Object _runargument;
	
	/** The virtual thread ID. */
	private final int _virtid;
	
	/** The real thread ID. */
	private volatile int _realid =
		-1;
	
	/** The name of this thread. */
	private volatile String _name;
	
	/** Has this thread been started? */
	private volatile boolean _started;
	
	/** Is this thread alive? */
	private volatile boolean _isalive;
	
	/** The priority of the thread. */
	private volatile int _priority = Thread.NORM_PRIORITY;
	
	/** Is this thread interrupted? */
	volatile boolean _interrupted;
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses a default thread name.
	 *
	 * @since 2018/11/17
	 */
	public Thread()
	{
		this(null, Thread._USE_FAKE_NAME);
	}
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses a default thread name.
	 *
	 * @param __r The runnable to execute.
	 * @since 2018/11/17
	 */
	public Thread(Runnable __r)
	{
		this(__r, Thread._USE_FAKE_NAME);
	}
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses the specified thread name.
	 *
	 * @param __n The thread's name.
	 * @throws NullPointerException If the thread name is null.
	 * @since 2018/11/17
	 */
	public Thread(String __n)
		throws NullPointerException
	{
		this(null, __n);
	}
	
	/**
	 * Initializes the thread which invokes the given {@link Runnable} and uses
	 * the given name.
	 *
	 * @param __r The runnable to execute.
	 * @param __n The thread's name.
	 * @throws NullPointerException If the thread name is null.
	 * @since 2018/11/17
	 */
	public Thread(Runnable __r, String __n)
		throws NullPointerException
	{
		this(__n, (__r == null ? Thread._START_SELF_RUNNABLE :
				Thread._START_GIVEN_RUNNABLE),
			null, __r);
	}
	
	/**
	 * Initializes a thread which is registered in this constructor and
	 * additionally has the given name and real ID.
	 *
	 * The thread is started in the started state and technically is not
	 * removed ever. This is generally used by the native display thread
	 * since there has to be a thread running as the VM sees it otherwise
	 * things will break much. A thread started this way never terminates
	 * unless that termination is explicit.
	 *
	 * @param __n The thread name.
	 * @param __rid The real ID.
	 * @since 2018/12/03
	 */
	private Thread(int __rid, String __n)
	{
		this._startkind = -1;
		this._runmethod = null;
		this._runargument = null;
		this._realid = __rid;
		this._name = __n;
		this._started = true;
		this._isalive = true;
		
		// Obtain the next virtual ID to use
		int virtid;
		synchronized (Thread.class)
		{
			this._virtid = (virtid = Thread._NEXT_VIRTUAL_ID++);
		}
		
		// Now register this thread in the main objects
		this.__registerThread();
	}
	
	/**
	 * Initializes the thread to execute the given static method.
	 *
	 * @param __n The name of the thread.
	 * @param __rk How is this method to be run?
	 * @param __mm The static method to call.
	 * @param __ma The argument to use.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/11/20
	 */
	private Thread(String __n, int __rk, StaticMethod __mm, Object __ma)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Obtain the next virtual ID to use
		int virtid;
		synchronized (Thread.class)
		{
			this._virtid = (virtid = Thread._NEXT_VIRTUAL_ID++);
		}
		
		// Set
		this._name = (__n == Thread._USE_FAKE_NAME ? "Thread-" + virtid : __n);
		this._startkind = __rk;
		this._runmethod = __mm;
		this._runargument = __ma;
		
		// The main thread is implicitly started
		boolean implicitstart = (__rk == Thread._START_MAIN || __rk == Thread._START_MIDLET);
		this._started = implicitstart;
	}
	
	/**
	 * Checks that the thread has access to perform some operations.
	 *
	 * @throws SecurityException If access is denied.
	 * @since 2018/11/21
	 */
	public final void checkAccess()
		throws SecurityException
	{
		SecurityManager sm = System.getSecurityManager();
		if (sm != null)
			sm.checkAccess(this);
	}
	
	/**
	 * Returns the ID of this thread.
	 *
	 * @return The thread ID.
	 * @since 2018/11/20
	 */
	public long getId()
	{
		return this._virtid;
	}
	
	/**
	 * Returns the name of this thread.
	 *
	 * @return The thread name.
	 * @since 2018/11/17
	 */
	public final String getName()
	{
		return this._name;
	}
	
	/**
	 * Returns the priority of the thread.
	 *
	 * @return The thread priority.
	 * @since 2018/12/07
	 */
	public final int getPriority()
	{
		return this._priority;
	}
	
	/**
	 * Interrupts the thread.
	 *
	 * @since 2018/11/21
	 */
	public void interrupt()
	{
		// Signal software interrupt
		this._interrupted = true;
		
		// Signal hardware interrupt
		int realid = this._realid;
		if (realid >= 0)
			TaskAccess.signalInterrupt(realid);
	}
	
	/**
	 * Is this thread currently alive?
	 *
	 * @return If this thread is alive.
	 * @since 2018/11/20
	 */
	public final boolean isAlive()
	{
		return this._isalive;
	}
	
	/**
	 * Is this thread interrupted?
	 *
	 * @return If this thread is interrupted.
	 * @since 2018/11/21
	 */
	public boolean isInterrupted()
	{
		return this._interrupted;
	}
	
	/**
	 * Waits forever for a thread to die or until interrupted.
	 *
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join()
		throws InterruptedException
	{
		this.join(0, 0);
	}
	
	/**
	 * Waits for a thread to die.
	 *
	 * @param __ms The milliseconds to wait for, if this is zero then this
	 * will wait forever.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join(long __ms)
		throws IllegalArgumentException, InterruptedException
	{
		this.join(__ms, 0);
	}
	
	/**
	 * Waits for a thread to die.
	 *
	 * If both milliseconds and nanoseconds are zero this will wait forever.
	 *
	 * @param __ms The milliseconds to wait for.
	 * @param __ns The nanoseconds to wait for.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// The end time, since our thread could be notified
		long end = (__ms == 0 && __ns == 0 ? Long.MAX_VALUE :
			System.nanoTime() + (__ms * 1_000_000L) + __ns);
		
		// Lock on self
		synchronized (this)
		{
			// Loop constantly until the thread is dead
			for (;;)
			{
				// Time ended?
				long now;
				if ((now = System.nanoTime()) >= end)
					return;
				
				// Did the thread die yet?
				if (this._started && !this._isalive)
					return;
				
				// Otherwise wait on our own monitor
				long diff = end - now;
				this.wait(diff / 1_000_000L, (int)(diff % 1_000_000L));
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	public void run()
	{
		// Does nothing
	}
	
	/**
	 * Sets the name of the thread.
	 *
	 * @param __n The new name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public final void setName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Check access first
		this.checkAccess();
		
		// Set new name
		synchronized (this)
		{
			this._name = __n;
		}
	}
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __p The thread priority.
	 * @throws IllegalArgumentException If the priority is not valid.
	 * @throws SecurityException If setting the priority is not permitted.
	 * @since 2018/12/07
	 */
	public final void setPriority(int __p)
		throws IllegalArgumentException, SecurityException
	{
		// {@squirreljme.error ZZ20 Invalid priority.}
		if (__p < Thread.MIN_PRIORITY || __p > Thread.MAX_PRIORITY)
			throw new IllegalArgumentException("ZZ20");
		
		// Check access
		this.checkAccess();
		
		// Store for later
		this._priority = __p;
		
		// Only set the priority if the thread is active
		int realid = this._realid;
		if (realid >= 0)
			TaskAccess.setThreadPriority(realid, __p);
	}
	
	/**
	 * Starts the specified thread.
	 *
	 * @throws IllegalThreadStateException If the thread was already started
	 * or failed to start.
	 * @since 2018/11/17
	 */
	public void start()
		throws IllegalThreadStateException
	{
		synchronized (this)
		{
			// {@squirreljme.error ZZ21 A thread may only be started once.}
			if (this._started)
				throw new IllegalThreadStateException("ZZ21");
			this._started = true;
			
			// Start the thread
			int realid = TaskAccess.startThread(this, this._name);
			this._realid = realid;
			
			// {@squirreljme.error ZZ22 Could not start the thread.}
			if (realid < 0)
				throw new RuntimeException("ZZ22");
			
			// Set the initial priority of the thread
			TaskAccess.setThreadPriority(realid, this._priority);
			this._isalive = true;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public String toString()
	{
		// JavaSE is in the format of `Thread[name,priority,group]` but
		// we do not have thread groups here
		return "Thread[" + this._name + "," + this._priority + "]";
	}
	
	/**
	 * Returns the number of threads which are currently alive.
	 *
	 * @return The number of alive threads.
	 * @since 2018/11/20
	 */
	public static int activeCount()
	{
		return Thread._ACTIVE_THREADS;
	}
	
	/**
	 * Returns the current thread.
	 *
	 * @return The current thread.
	 * @since 2018/11/20
	 */
	public static Thread currentThread()
	{
		int rid = TaskAccess.currentThread();
		
		// If the map is not initialized yet, ignore
		Map<Integer, Thread> byrealid = Thread._BY_REALID;
		if (byrealid == null)
			return null;
		
		// Lock, it should be in the map
		synchronized (Thread.class)
		{
			return byrealid.get(rid);
		}
	}
	
	/**
	 * Checks if the current thread holds the monitor for the given object.
	 *
	 * @param __o The object to check.
	 * @return If the thread owns the monitor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public static boolean holdsLock(Object __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		return ObjectAccess.holdsLock(TaskAccess.currentThread(), __o);
	}
	
	/**
	 * Checks if the current thread was interrupted, if it was then the
	 * interrupt status will be cleared.
	 *
	 * @return If this thread was interrupted.
	 * @since 2018/11/21
	 */
	public static boolean interrupted()
	{
		Thread self = Thread.currentThread();
		
		// Check interrupt?
		boolean rv = self._interrupted;
		self._interrupted = false;
		return rv;
	}
	
	/**
	 * Causes the thread to sleep for the given amount of milliseconds.
	 *
	 * @param __ms The number of milliseconds to sleep for.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/11/04
	 */
	public static void sleep(long __ms)
		throws InterruptedException
	{
		Thread.sleep(__ms, 0);
	}
	
	/**
	 * Causes the thread to sleep for the given milliseconds and nanoseconds.
	 *
	 * @param __ms The milliseconds to sleep for.
	 * @param __ns The nanoseconds to sleep for, in the range of 0-999999.
	 * @throws IllegalArgumentException If the milliseconds and/or nanoseconds
	 * are out of range.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/11/04
	 */
	public static void sleep(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ23 Invalid sleep arguments.}
		if (__ms < 0 || __ns < 0 || __ns > 999999)
			throw new IllegalArgumentException("ZZ23");
		
		// Convert to integer but do not sleep for too long
		int ims = (__ms > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)__ms);
		
		// Perform sleep, if it was interrupted then the return status will
		// be non-zero!
		if (Assembly.sysCallV(SystemCallIndex.SLEEP, ims, __ns) != 0)
		{
			Thread.currentThread()._interrupted = false;
			
			// {@squirreljme.error ZZ24 Sleep was interrupted.}
			throw new InterruptedException("ZZ24");
		}
	}
	
	/**
	 * Yields the current thread giving up its execution slice, but allowing
	 * it to continue instantly resuming as needed.
	 *
	 * @since 2018/12/05
	 */
	public static void yield()
	{
		// Zero times means to yield
		Assembly.sysCallV(SystemCallIndex.SLEEP, 0, 0);
	}
	
	/**
	 * Registers this thread so that way it is in the thread list and can be
	 * obtained and such.
	 *
	 * @since 2018/12/03
	 */
	final void __registerThread()
	{
		// Lock
		synchronized (Thread.class)
		{
			// Increase the active thread count
			Thread._ACTIVE_THREADS++;
			
			// Add threads to the thread list
			Map<Integer, Thread> byvirtid = Thread._BY_VIRTID,
				byrealid = Thread._BY_REALID;
			byvirtid.put(this._virtid, this);
			byrealid.put(this._realid, this);
		}
	}
	
	/**
	 * Ends the current thread and cleans up its registration.
	 *
	 * @since 2018/12/03
	 */
	final void __revokeThread()
	{
		// Thread no longer alive
		this._isalive = false;
		
		// Lock
		synchronized (Thread.class)
		{
			// Decrease the active count
			Thread._ACTIVE_THREADS--;
			
			// Remove from the thread list
			Map<Integer, Thread> byvirtid = Thread._BY_VIRTID,
				byrealid = Thread._BY_REALID;
			byvirtid.remove(this._virtid);
			byrealid.remove(this._realid);
		}
		
		// Signal all threads which are waiting on a join for this thread
		// only
		synchronized (this)
		{
			this.notifyAll();
		}
		
		// Signal anything waiting on the class itself, to indicate that
		// a thread has finished
		int startkind = this._startkind;
		if (startkind != Thread._START_MAIN && startkind != Thread._START_MIDLET)
			synchronized (Thread.class)
			{
				Thread.class.notifyAll();
			}
	}
	
	/**
	 * This is the starting point for all threads, including the main thread
	 * and such.
	 *
	 * @throws IllegalThreadStateException If the thread has already been
	 * started.
	 * @since 2018/11/20
	 */
	@ImplementationNote("This is the starting point of all threads.")
	final void __start()
		throws IllegalThreadStateException
	{
		// Get the kind and determine if this is a main entry point
		int startkind = this._startkind;
		boolean ismain = (startkind == Thread._START_MAIN ||
			startkind == Thread._START_MIDLET);
		
		// We need to lock because the real ID might just not get assigned
		// yet here.
		int realid;
		int virtid = this._virtid;
		if (!ismain)
			synchronized (this)
			{
				// {@squirreljme.error ZZ25 Real ID has not been set yet while
				// in the lock, this should not occur unless the virtual
				// machine is very broken.}
				if ((realid = this._realid) < 0)
					throw new Error("ZZ25");
			}
		
		// Main thread, so set our real ID to the current thread the VM says
		// we are since it will still be negatively initialized 
		else
		{
			realid = TaskAccess.currentThread();
			this._realid = realid;
		}
		
		// The exit code is something that is only handled by the main thread
		// It will exit with the given code 
		int exitcode = 0;
		
		// Execution setup
		try
		{
			// Register this thread
			this.__registerThread();
				
			// Set the thread as alive
			this._isalive = true;
			
			// The main method and/or its arguments
			StaticMethod runmethod = this._runmethod;
			Object runargument = this._runargument;
			
			// How do we run this thread?
			switch (this._startkind)
			{
					// Start Runnable in this instance (extended from)
				case Thread._START_SELF_RUNNABLE:
					this.run();
					break;
					
					// Start the given runnable
				case Thread._START_GIVEN_RUNNABLE:
					((Runnable)runargument).run();
					break;
					
					// Start MIDlet, construct then startApp()
				case Thread._START_MIDLET:
					ObjectAccess.invokeStatic(runmethod,
						ObjectAccess.classByName((String)runargument).
						__newInstance());
					break;
					
					// Start main(String[]) method
				case Thread._START_MAIN:
					ObjectAccess.invokeStatic(runmethod, runargument);
					break;
					
					// Unknown
				default:
					throw new todo.OOPS();
			}
		}
		
		// Uncaught exception
		catch (Throwable t)
		{
			// Set the exit code for the process to some error number, if
			// the VM does not exit in this thread but exits in another
			// it would at least be set for the main thread
			// But this is only needed for the main thread
			if (ismain)
				exitcode = 127;
			
			// Handle uncaught exception
			UncaughtExceptionHandler.handle(t);
		}
		
		// Cleanup after the thread:
		//  * Signal joins (for those that are waiting)
		//  * Remove the thread from the thread list
		//  * Decrease the active count
		//  * Set thread as not alive
		finally
		{
			// Revoke this thread
			this.__revokeThread();
		}
		
		// If this is the main thread, wait for every other thread to
		// stop execution. This saves the VM execution code itself from
		// worrying about which threads are running or not.
		if (ismain)
		{
			// Wait for threads to go away
			for (;;)
			{
				// No threads are active, so that works
				if (Thread._ACTIVE_THREADS == 0)
					break;
				
				// Wait a bit until trying again, unless we get notified
				synchronized (Thread.class)
				{
					try
					{
						// Three seconds is short enough to not be forever
						// but long enough to where we can get a notify to
						// quit
						Thread.class.wait(3_000);
					}
					catch (InterruptedException e)
					{
					}
				}
			}
			
			// Exit the VM with our normal exit code, since no other
			// thread called exit at all for this point
			Assembly.sysCall(SystemCallIndex.EXIT, exitcode);
		}
	}
}

Added modules/cldc-compact/src/main/java/java/lang/Throwable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import java.io.PrintStream;

/**
 * This class is the base class for all types which are thrown, itself being a
 * checked exception handled by the compiler.
 *
 * Each {@link Throwable} contains internal stack trace information which is
 * initialized when the {@link Throwable} is.
 *
 * A {@link Throwable} may have suppressed exceptions, which are exceptions
 * which may be added to a {@link Throwable} to indicate that there was an
 * exception that was caused in a try-with-resources when the resource was
 * attempted to be closed.
 *
 * @since 2018/09/15
 */
public class Throwable
{
	/** Exception message. */
	private static final int _TYPE_EXCEPTION =
		0;
	
	/** Caused by message. */
	private static final int _TYPE_CAUSED_BY =
		1;
	
	/** Suppressed message. */
	private static final int _TYPE_SUPPRESSED =
		2;
	
	/** The message for this exception. */
	private final String _message;
	
	/** Suppressed exceptions. */
	private volatile Throwable[] _suppressed;
	
	/** Was a cause initialized already? */
	private volatile boolean _initcause;
	
	/**
	 * The cause of this exception, note this is writeable because of
	 * {@link #initCause(Throwable)}. This is mostly just for older versions
	 * of the class library which did not have a cause specified in the
	 * constructor.
	 */
	private volatile Throwable _cause;
	
	/** The stack trace for this throwable (in raw form). */
	private volatile int[] _stack;
	
	/**
	 * Initializes a throwable with no cause or message.
	 *
	 * @since 2018/09/15
	 */
	public Throwable()
	{
		this(false, 2, null, null);
	}
	
	/**
	 * Initializes a throwable with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public Throwable(String __m)
	{
		this(false, 2, __m, null);
	}
	
	/**
	 * Initializes a throwable with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	public Throwable(Throwable __t)
	{
		this(true, 2, null, __t);
	}
	
	/**
	 * Initializes a throwable with the given cause and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	public Throwable(String __m, Throwable __t)
	{
		this(true, 2, __m, __t);
	}
	
	/**
	 * Since the cause can only be set once, this constructor needs to keep
	 * track of whether it was set by a constructor or not.
	 *
	 * @param __ic Is the cause initialized?
	 * @param __clip The number of stack trace entries to clip.
	 * @param __m The exception message.
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	private Throwable(boolean __ic, int __clip, String __m, Throwable __t)
	{
		// These are trivially set
		this._message = __m;
		this._cause = __t;
		this._initcause = __ic;
		
		// The stack trace is implicitly filled in by this constructor, it
		// matches the stack trace of the current thread of execution
		this._stack = this.__getStackTrace(this, __clip, true);
	}
	
	/**
	 * Adds a suppressed throwable which will be thrown alongside this
	 * throwable. This is mainly used with try-with-resources although a
	 * programmer may wish to add related throwables that additionally
	 * happened.
	 *
	 * This method is thread safe.
	 *
	 * @param __t The throwable to suppress.
	 * @throws IllegalArgumentException If the passed throwable is this.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final void addSuppressed(Throwable __t)
		throws IllegalArgumentException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ26 Cannot add a suppressed exception which
		// is this exception.}
		if (__t == this)
			throw new IllegalArgumentException("ZZ26");
		
		// Just lock on this to add suppressed exceptions, it is unspecified
		// where the lock is done, but this prevent creation of an object just
		// to hold a lock.
		synchronized (this)
		{
			// No suppressed exceptions were set, initialize
			Throwable[] suppressed = this._suppressed;
			if (suppressed == null)
				this._suppressed = new Throwable[]{__t};
			
			// Otherwise rebuild the array and add it
			else
			{
				int n = suppressed.length;
				Throwable[] copy = new Throwable[n + 1];
				for (int i = 0; i < n; i++)
					copy[i] = suppressed[i];
				copy[n] = __t;
				
				// Use this instead
				this._suppressed = copy;
			}
		}
	}
	
	/**
	 * Fills in the stack trace of this throwable for the current thread.
	 *
	 * @return {@code this}.
	 * @since 2018/09/15
	 */
	public Throwable fillInStackTrace()
	{
		// Get stack trace, ignore this method
		this._stack = this.__getStackTrace(this, 1, false);
		
		// Returns self
		return this;
	}
	
	/**
	 * Returns the throwable which caused this throwable to occur.
	 *
	 * @return The throwable which caused this throwable.
	 * @since 2018/09/15
	 */
	public Throwable getCause()
	{
		return this._cause;
	}
	
	/**
	 * Returns a potentially localized message for this throwable, the default
	 * implementation just returns {@link #getMessage()}.
	 *
	 * @return A localized message.
	 * @since 2018/09/15
	 */
	public String getLocalizedMessage()
	{
		return this.getMessage();
	}
	
	/**
	 * Returns the message which was set for this throwable, if one was set.
	 *
	 * @return The message for this throwable, may be {@code null} if one was
	 * not set.
	 * @since 2018/09/15
	 */
	public String getMessage()
	{
		return this._message;
	}
	
	/**
	 * Returns an array of all the throwables which were suppressed.
	 *
	 * This method is thread safe.
	 *
	 * @return An array of all the suppresed throwables.
	 * @since 2018/09/15
	 */
	public final Throwable[] getSuppressed()
	{
		// Since this is volatile we can just read whatever value is here
		// without needing to lock
		Throwable[] rv = this._suppressed;
		if (rv == null)
			return new Throwable[0];
		return rv.clone();
	}
	
	/**
	 * Initializes the cause of the throwable if it has not been set.
	 *
	 * Calls to {@link #initCause(Throwable)}, {@link #Throwable(Throwable)},
	 * or {@link #Throwable(String, Throwable)} will cause the cause to be
	 * initialized, preventing this from being called or called again.
	 *
	 * @param __t The cause of the throwable.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the cause is this throwable.
	 * @throws IllegalStateException If a cause has already been set.
	 * @since 2018/09/15
	 */
	public Throwable initCause(Throwable __t)
		throws IllegalArgumentException, IllegalStateException
	{
		// {@squirreljme.error ZZ27 Cannot initialize the cause of the
		// throwable with itself as the cause.}
		if (__t == this)
			throw new IllegalArgumentException("ZZ27");
		
		// {@squirreljme.error ZZ28 The cause of the throwable has already
		// been initialized.}
		if (this._initcause)
			throw new IllegalStateException("ZZ28");
		
		// Set
		this._initcause = true;
		this._cause = __t;
		
		return this;
	}
	
	/**
	 * Prints the stack trace to the standard error stream.
	 *
	 * @since 2018/09/15
	 */
	public void printStackTrace()
	{
		Throwable.__printStackTrace(this, System.err, 0,
			Throwable._TYPE_EXCEPTION);
	}
	
	/**
	 * Prints the stack trace to the specified stream.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public void printStackTrace(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		Throwable.__printStackTrace(this, __ps, 0, Throwable._TYPE_EXCEPTION);
	}
	
	/**
	 * Returns a string representation of this throwable.
	 *
	 * If there is a localized message, the form is {@code <class>: <message>}.
	 * If there is no message, the form is {@code <class>}.
	 *
	 * @return A string representing this throwable.
	 * @since 2018/09/15
	 */
	@Override
	public String toString()
	{
		String clname = this.getClass().getName(),
			lm = this.getLocalizedMessage();
		
		if (lm == null)
			return clname;
		return clname + ": " + lm;
	}
	
	/**
	 * Obtains the stack trace for the current thread in raw format.
	 *
	 * @param __this The this throwable object.
	 * @param __clip The number of entries on the top to clip.
	 * @param __initclip Clip off initializers?
	 * @return The stack trace for the current stack.
	 * @throws IllegalArgumentException If the clip is negative.
	 * @since 2018/09/16
	 */
	private static int[] __getStackTrace(Throwable __this,
		int __clip, boolean __initclip)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ29 Cannot specify a negative clip for a
		// stack trace.}
		if (__clip < 0)
			throw new IllegalArgumentException("ZZ29");
		
		// Get the raw trace here
		int[] rawstack = CallTraceElement.traceRaw();
		
		// Just use the raw stack
		return rawstack;
	}
	
	/**
	 * Prints the indentation of the stack trace.
	 *
	 * @param __ps The stream to print to.
	 * @param __indent The current indentation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/11
	 */
	private static void __printStackIndent(PrintStream __ps, int __indent)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Doing nothing
		if (__indent == 0)
			return;
		
		// Base space indent
		__ps.print("  ");
		
		// Print bars for indentation level
		for (int i = 0; i < __indent; i++)
			__ps.print('|');
	}
	
	/**
	 * Prints the stack trace to the specified stream. This is internal so that
	 * one stack printing does not call the other since it is not specified if
	 * it actually does it.
	 *
	 * @param __t The throwable to print for.
	 * @param __ps The stream to print to.
	 * @param __indent The indentation level.
	 * @param __type The string type to use for the message base.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private static void __printStackTrace(Throwable __t, PrintStream __ps,
		int __indent, int __type)
		throws NullPointerException
	{
		if (__t == null || __ps == null)
			throw new NullPointerException("NARG");
		
		// Internally raw stacks are stored since that is the fastest way
		// to generate a stack trace, which will only be resolved when this
		// method is called to print.
		int[] rawstack = __t._stack;
		if (rawstack == null)
		{
			__ps.println("<No stack trace>");
			return;
		}
		
		// Resolve the stack trace so it is easier to work with
		CallTraceElement[] stack = CallTraceElement.traceResolve(rawstack);
		
		// Indent and print exception type
		Throwable.__printStackIndent(__ps, __indent);
		switch (__type)
		{
			case Throwable._TYPE_CAUSED_BY:
				__ps.print("> CAUSED BY ");
				break;
			
			case Throwable._TYPE_SUPPRESSED:
				__ps.print("> SUPPRESSED ");
				break;
			
			case Throwable._TYPE_EXCEPTION:
			default:
				__ps.print("EXCEPTION ");
				break;
		}
		
		// Then the string representation of it, which may be replaced
		__ps.println(__t.toString());
		
		// Increase indentation to get more bars
		__indent++;
		
		// The first entry is the top of the stack so it gets printed first 
		String wasclass = "<Unknown>";
		for (int i = 0, n = stack.length; i < n; i++)
		{
			// Ignore any elements that may happen to be null
			CallTraceElement e = stack[i];
			if (e == null)
				continue;
			
			// Get the element class, always make sure the class is valid
			// even if it is not known
			String nowclass = e.className();
			if (nowclass == null)
				nowclass = "<Unknown>";
			
			// If the class changed, specify that it has
			if (!nowclass.equals(wasclass))
			{
				// Indent
				Throwable.__printStackIndent(__ps, __indent);
				
				__ps.print(" IN ");
				__ps.println(e.toClassHeaderString());
				
				// Changed
				wasclass = nowclass;
			}
			
			// Indent and print the at line
			Throwable.__printStackIndent(__ps, __indent);
			__ps.print("- ");
			__ps.println(e.toAtLineString());
		}
		
		// Print cause of the exception
		Throwable cause = __t.getCause();
		if (cause != null)
			Throwable.__printStackTrace(cause, __ps, __indent,
				Throwable._TYPE_CAUSED_BY);
		
		// Print suppressed exceptions
		for (Throwable sup : __t.getSuppressed())
			Throwable.__printStackTrace(sup, __ps, __indent,
				Throwable._TYPE_SUPPRESSED);
	}
}

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

package java.lang;

/**
 * This is thrown when the version of a class is not supported.
 *
 * @since 2018/12/04
 */
public class UnsupportedClassVersionError
	extends ClassFormatError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public UnsupportedClassVersionError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public UnsupportedClassVersionError(String __m)
	{
		super(__m);
	}
}

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

package java.lang;

public class UnsupportedOperationException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(Throwable __t)
	{
		super(__t);
	}
}

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

package java.lang;

/**
 * This is thrown when the virtual machine has encountered an error.
 *
 * @since 2018/12/04
 */
public class VirtualMachineError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public VirtualMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public VirtualMachineError(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/__CanSetPrintStream__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.io.PrintStream;

/**
 * This is an internal {@link PrintStream} which can have the target stream
 * it writes to changed. This is to prevent abuse of using reflection to
 * change final values. Due to the potential to have extremely aggressive
 * optimization and romization, having it not do this would be dangerous
 * because in fully optimized code, the finals will NEVER change regardless
 * of how many times stream setting is called.
 *
 * @since 2016/03/17
 */
final class __CanSetPrintStream__
	extends PrintStream
{
	/** Internal lock. */
	protected final Object lock =
		new Object();
	
	/** Target output stream. */
	private volatile PrintStream _target;
	
	/**
	 * Initializes the settable proxy for the given stream as the default
	 * value.
	 *
	 * @param __def The initial stream to target.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/17
	 */
	__CanSetPrintStream__(PrintStream __def)
		throws NullPointerException
	{
		super(__def, true);
		
		// Check
		if (__def == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._target = __def;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(CharSequence __a)
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.append(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(CharSequence __a, int __b, int __c)
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.append(__a, __b, __c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(char __a)
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.append(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public boolean checkError()
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void close()
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.close();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void flush()
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.flush();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream format(String __a, Object... __b)
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.format(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(boolean __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(char __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(int __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(long __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(float __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(double __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(char[] __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(String __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(Object __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream printf(String __a, Object... __b)
	{
		// Lock
		synchronized (this.lock)
		{
			return this._target.printf(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println()
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(boolean __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(char __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(int __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(long __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(float __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(double __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(char[] __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(String __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(Object __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void write(int __a)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.write(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void write(byte[] __a, int __b, int __c)
	{
		// Lock
		synchronized (this.lock)
		{
			this._target.write(__a, __b, __c);
		}
	}
	
	/**
	 * Sets the new stream to target.
	 *
	 * @param __ps The stream to target.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/17
	 */
	void __set(PrintStream __ps)
		throws NullPointerException
	{
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// If this is a can set stream then we likely tried to restore the
		// old output stream, so if we ever print anything again this will
		// fail completely with infinite recursion.
		while (__ps instanceof __CanSetPrintStream__)
			__ps = ((__CanSetPrintStream__)__ps)._target;
		
		// Lock
		synchronized (this.lock)
		{
			// Flush the current stream so any written bytes are written to
			// the output, so that they are not lost forever. However some
			// trickery could be done which causes flush to fail.
			try
			{
				this.flush();
			}
			
			// Completely ignore, also do not try printing the stack trace
			// because an infinite loop could occur.
			catch (Throwable t)
			{
			}
		
			// Change it
			this._target = __ps;
		}
	}
}

Added modules/cldc-compact/src/main/java/java/lang/annotation/Annotation.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is the common interface in which all annotation types are inherited
 * from.
 *
 * If a random class or interface implements this interface and it is not an
 * annotation type, then it is not an annotation.
 *
 * @since 2014/10/13
 */
public interface Annotation
{
	/**
	 * Returns the annotation type used for this annotation.
	 *
	 * @return The annotation type.
	 * @since 2014/10/13
	 */
	Class<? extends Annotation> annotationType();
	
	/**
	 * Checks the logical equality to another annotation type, they are both
	 * considered to be equal when all of their members are equal and they are
	 * of the same type.
	 *
	 * Primitive types are checked directly except for floating point types
	 * which are equality checked through their wrapper classes.
	 *
	 * Floating point NaN values are considered to be equal, that is the
	 * {@code ==} operator is not used.
	 *
	 * {@link String}, {@link Class}, and enumerations are considered equal if
	 * their normal {@code equals()} evaluates to true.
	 *
	 * Two arrays are equal if {@code Arrays.equals(a, b)} evaluates to
	 * {@code true}.
	 *
	 * @param __o The other object to check against.
	 * @return {@code true} if they are logically equivalent.
	 * @since 2014/10/13
	 */
	boolean equals(Object __o);
	
	/**
	 * Calculates the hash code which is a sum of the hash codes of its members
	 * in a specifically defined pattern.
	 *
	 * The base hash code for a member is {@code (127 *
	 * ((String)memberName).hashCode()) ^ specialValue}. The variable
	 * {@code specialValue} is defined depending on the
	 * context. If it is a primitive type, then the hash code that would be
	 * returned if they were object types (their wrapper classes) is used. If
	 * an array then {@code Arrays.hashCode()} is used. Otherwise, it is the
	 * normal hashCode of the specified value.
	 *
	 * @return The hash code for this annotation.
	 * @since 2014/10/13
	 */
	int hashCode();
	
	/**
	 * Returns an implementation dependent string which represents the
	 * annotation and all of its values.
	 *
	 * @return The string representation of this annotation.
	 * @since 2014/10/13
	 */
	String toString();
}

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

package java.lang.annotation;

/**
 * This indicates that the specified annotation should be documented by the
 * Java documentation tool whenever it is used.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Documented
{
}

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

package java.lang.annotation;

/**
 * Specifies the type of element that the annotation is permitted to be
 * attached to in the source code.
 *
 * @since 2014/10/13
 */
public enum ElementType
{
	/** Annotation types). */
	ANNOTATION_TYPE(),
	
	/** Constructors. */
	CONSTRUCTOR(),
	
	/** Fields. */
	FIELD(),
	
	/** Local variables. */
	LOCAL_VARIABLE(),
	
	/** Methods. */
	METHOD(),
	
	/** Packages. */
	PACKAGE(),
	
	/** Parameter of a method. */
	PARAMETER(),
	
	/** A class, interface, or enumeration. */
	TYPE(),
	
	/** End. */
	;
}

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

package java.lang.annotation;

/**
 * Indicates that the annotation type should automatically be inherited so that
 * the subclass type appears to have this annotation when it is requested. That
 * is, if an annotation with this annotation is requested it will keep going up
 * the superclasses until it is found.
 *
 * This only affects classes which use an annotation with this annotation, as
 * such interfaces are excluded.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Inherited
{
}

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

package java.lang.annotation;

/**
 * This is used to indicate how far into the compilation and runtime process
 * should keep a visible mark on an annotation.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Retention
{
	/**
	 * Specifies where the annotation exists during and after compilation of
	 * source code.
	 *
	 * @return The storage of the annotation.
	 * @see RetentionPolicy
	 * @since 2014/10/13
	 */
	RetentionPolicy value();
}

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

package java.lang.annotation;

/**
 * Specifies how far through compilation and running of code that an annotation
 * should be visible.
 *
 * @since 2014/10/13
 */
public enum RetentionPolicy
{
	/** Kept after compilation, but not visible at runtime. */
	CLASS(),
	
	/** Kept after compilation and visible at runtime. */
	RUNTIME(),
	
	/** Removed after compilation, does not appear in the class file. */
	SOURCE(),
	
	/** End. */
	;
}

Added modules/cldc-compact/src/main/java/java/lang/annotation/Target.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the context in which the annotation is valid.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Target
{
	/**
	 * A list of valid contexts where the annotation may be used.
	 *
	 * @return An array of permitted targets.
	 * @since 2014/10/13
	 */
	ElementType[] value();
}

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

package java.lang.ref;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;

/**
 * This class represents references which may be referred to using various
 * different means of attachment, as such this family of classes integrates
 * with the garbage collector.
 *
 * @param <T> The type of object to store.
 * @since 2018/09/23
 */
public abstract class Reference<T>
{
	/** The primitive reference used to access the object. */
	private final PrimitiveReference _ref;
	
	/** The queue this reference is in, volatile to be clearned. */
	private volatile ReferenceQueue<? super T> _queue;
	
	/** Has this been enqueued? */
	private volatile boolean _enqueued;
	
	/**
	 * Initializes a reference pointing to the given object and an optionally
	 * specified queue to place this reference into when garbage collection
	 * occurs.
	 *
	 * @param __r The primitive reference storage.
	 * @param __v The object to point to, may be {@code null}.
	 * @param __q When the given object is garbage collected the specified
	 * queue will be given this reference (not {@code __v} itself}, may be
	 * {@code null}
	 * @since 2018/09/23
	 */
	Reference(PrimitiveReference __r, T __v, ReferenceQueue<? super T> __q)
	{
		// Set
		this._ref = __r;
		this._queue = __q;
		
		// Set primitive reference data
		ObjectAccess.referenceSet(__r, __v);
	}
	
	/**
	 * Clears this reference without placing it in the queue.
	 *
	 * @since 2018/09/23
	 */
	public void clear()
	{
		ObjectAccess.referenceSet(this._ref, null);
	}
	
	/**
	 * Places this reference in the queue.
	 *
	 * @return If it was added to the queue then this will return true,
	 * otherwise if there is no queue or it was already added this will
	 * return false.
	 * @since 2018/09/23
	 */
	public boolean enqueue()
	{
		// Already been enqueued
		ReferenceQueue<? super T> queue = this._queue;
		if (this._enqueued || queue == null)
			return false;
		
		// Enqueue it
		queue.__enqueue(this);
		
		// The queue is not needed anymore so there is no need to keep a
		// reference to it around, this will help remove circular references
		// if one forgets to drain the queues.
		this._enqueued = true;
		this._queue = null;
		
		// Was enqueued
		return true;
	}
	
	/**
	 * Returns the object that this reference refers to.
	 *
	 * @return The reference of this object.
	 * @since 2018/09/23
	 */
	@SuppressWarnings({"unchecked"})
	public T get()
	{
		// If the reference was cleared, enqueue it!
		Object rv = ObjectAccess.referenceGet(this._ref);
		if (rv == null)
			this.enqueue();
		
		return (T)rv;
	}
	
	/**
	 * Returns if this reference was enqueued into the reference queue.
	 *
	 * @return If this object was enqueued.
	 * @since 2018/09/23
	 */
	public boolean isEnqueued()
	{
		return this._enqueued;
	}
}

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

package java.lang.ref;

import java.util.Deque;
import java.util.LinkedList;

/**
 * This is a queue of references, when a reference is freed or detected to be
 * freed then the object references will be placed here.
 *
 * @param <T> The type of reference to store.
 * @since 2018/09/23
 */
public class ReferenceQueue<T>
{
	/** Internal queue of references. */
	private final Deque<Reference<? extends T>> _queue =
		new LinkedList<>();
	
	/**
	 * Checks the queue and returns a reference immedietely if one is
	 * available.
	 *
	 * @return The next removed reference or {@code null} if there is none.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> poll()
	{
		// Lock and remove
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			return queue.poll();
		}
	}
	
	/**
	 * Removes the next reference from the queue for the given duration.
	 *
	 * @param __ms The number of milliseconds to wait, zero means to wait
	 * forever.
	 * @return The reference or {@code null} if the timeout was reached.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> remove(long __ms)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ2a A negative timeout was specified.}
		if (__ms < 0)
			throw new IllegalArgumentException("ZZ2a");
		
		// A timeout of zero means to wait forever
		if (__ms == 0)
			return this.remove();
		
		// Determine the time to just stop waiting
		long endtime = System.nanoTime() + (__ms * 1_000_000L);
		
		// Lock on the queue
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			for (;;)
			{
				// Is there an item in the queue?
				Reference<? extends T> rv = queue.poll();
				if (rv != null)
					return rv;
				
				// No time left
				long difftime = (endtime - System.nanoTime()) / 1_000_000L;
				if (difftime <= 0)
					return null;
				
				// Wait for the time difference, InterruptedException drops
				// out if it occurs
				queue.wait(difftime);
			}
		}
	}
	
	/**
	 * Removes the next reference from the queue, waiting forever until there
	 * is one.
	 *
	 * @return The next reference in the queue.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> remove()
		throws InterruptedException
	{
		// Lock on the queue
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			for (;;)
			{
				// Is there an item in the queue?
				Reference<? extends T> rv = queue.poll();
				if (rv != null)
					return rv;
				
				// Otherwise wait for a signal, InterruptedException is tossed
				// on the outside
				queue.wait();
			}
		}
	}
	
	/**
	 * Enqueues the reference into this queue.
	 *
	 * @param __ref The reference to enqueue.
	 * @since 2018/09/23
	 */
	final void __enqueue(Reference<? extends T> __ref)
	{
		// Just ignore and do nothing
		if (__ref == null)
			return;
		
		// Lock on the queue to add it
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			queue.add(__ref);
			
			// Signal all waiting threads, one will grab it
			queue.notifyAll();
		}
	}
}

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

package java.lang.ref;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * A weak reference is one which is garbage collected when there are no strong
 * references to it.
 *
 * @param <T> The type of object to store.
 * @since 2018/09/23
 */
public class WeakReference<T>
	extends Reference<T>
{
	/**
	 * Initializes a reference pointing to the given object.
	 *
	 * @param __v The object to point to, may be {@code null}.
	 * @since 2018/09/23
	 */
	public WeakReference(T __v)
	{
		super(ObjectAccess.newWeakReference(), __v, null);
	}
	
	/**
	 * Initializes a reference pointing to the given object and an optionally
	 * specified queue to place this reference into when garbage collection
	 * occurs.
	 *
	 * @param __v The object to point to, may be {@code null}.
	 * @param __q When the given object is garbage collected the specified
	 * queue will be given this reference (not {@code __v} itself}, may be
	 * {@code null}
	 * @since 2018/09/23
	 */
	public WeakReference(T __v, ReferenceQueue<? super T> __q)
	{
		super(ObjectAccess.newWeakReference(), __v, __q);
	}
}

Added modules/cldc-compact/src/main/java/java/lang/ref/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes of reference and their utilities which are
 * utilized with garbage collection.
 *
 * @since 2018/09/23
 */

package java.lang.ref;

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

package java.net;

/**
 * This is thrown when an attempt to bind to a local address and/or port has
 * failed.
 *
 * @since 2018/12/08
 */
public class BindException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public BindException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public BindException(String __m)
	{
		super(__m);
	}
}

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

package java.net;

/**
 * This is thrown when a connection could not be made to a remote host.
 *
 * @since 2018/12/08
 */
public class ConnectException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public ConnectException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public ConnectException(String __m)
	{
		super(__m);
	}
}

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

package java.net;

/**
 * This is thrown when there is no route to the remote destination.
 *
 * @since 2018/12/08
 */
public class NoRouteToHostException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public NoRouteToHostException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public NoRouteToHostException(String __m)
	{
		super(__m);
	}
}

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

package java.net;

/**
 * This is thrown when the remote system has a port which cannot be reached.
 *
 * @since 2018/12/08
 */
public class PortUnreachableException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public PortUnreachableException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public PortUnreachableException(String __m)
	{
		super(__m);
	}
}

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

package java.net;

import java.io.IOException;

/**
 * This is thrown for general socket exceptions.
 *
 * @since 2018/12/08
 */
public class SocketException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public SocketException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public SocketException(String __m)
	{
		super(__m);
	}
}

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

package java.net;

import java.io.IOException;

/**
 * This is thrown when a host is looked up, however it is not valid.
 *
 * @since 2018/12/08
 */
public class UnknownHostException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public UnknownHostException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public UnknownHostException(String __m)
	{
		super(__m);
	}
}

Added modules/cldc-compact/src/main/java/java/security/AccessControlException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

/**
 * This is thrown when access to a system critical resource such as a file
 * or network stream is denied.
 *
 * @since 2018/09/18
 */
public class AccessControlException
	extends SecurityException
{
	/** The permission which was set, is optional. */
	private final Permission _permission;
	
	/**
	 * Initializes the exception with the given message with no permission or
	 * cause.
	 *
	 * @param __s The message.
	 * @since 2018/09/18
	 */
	public AccessControlException(String __s)
	{
		super(__s);
		
		this._permission = null;
	}
	
	/**
	 * Initializes the exception with the given message and permission, no
	 * cause is used.
	 *
	 * @param __s The message.
	 * @param __p The permission.
	 * @since 2018/09/18
	 */
	public AccessControlException(String __s, Permission __p)
	{
		super(__s);
		
		this._permission = __p;
	}
	
	/**
	 * Returns the permission that was specified, if one was.
	 *
	 * @return The specified permission or {@code null} if there was none.
	 * @since 2018/09/18
	 */
	public Permission getPermission()
	{
		return this._permission;
	}
}

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

package java.security;

/**
 * This is used for access control on resources that may be available at
 * run-time.
 *
 * @since 2018/09/18
 */
public final class AccessController
{
	/**
	 * Checks the specified permission.
	 *
	 * @param __p The permission to check.
	 * @throws AccessControlException If access is denied or the permission
	 * is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public static void checkPermission(Permission __p)
		throws AccessControlException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		todo.TODO.note("Check permission: %s", __p);
	}
}

Added modules/cldc-compact/src/main/java/java/security/BasicPermission.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

public abstract class BasicPermission
	extends Permission
{
	/**
	 * Initializes the basic permission.
	 *
	 * @param __name The name of the permission.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/18
	 */
	public BasicPermission(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		super(__name);
		
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2b The name for basic permissions cannot
		// be empty.}
		if (__name.equals(""))
			throw new IllegalArgumentException("ZZ0z");
	}
	
	/**
	 * Initializes the basic permission.
	 *
	 * @param __name The name of the permission.
	 * @param __act The action to use, this is ignored for basic permissions.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/18
	 */
	public BasicPermission(String __name, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		this(__name);
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}

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

package java.security;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is the base class for all permissions.
 *
 * Permissions have a name and may have multiple actions.
 *
 * Actions are comma separated and they must be returned in a fixed order.
 *
 * @since 2018/12/08
 */
public abstract class Permission
{
	/** The permission name. */
	private final String _name;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the base permission.
	 *
	 * @param __name The name of the permission.
	 * @since 2018/09/18
	 */
	public Permission(String __name)
	{
		this._name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public abstract boolean equals(Object __a);
	
	/**
	 * Returns the actions which are performed on this permission.
	 *
	 * @return The actions performed on this permission.
	 * @since 2018/12/08
	 */
	public abstract String getActions();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * Checks if this permission implies the given permission.
	 *
	 * @param __p The other permission to check.
	 * @return If this permission implies the specified one.
	 * @since 2018/12/08
	 */
	public abstract boolean implies(Permission __p);
	
	/**
	 * Returns the name of this permission.
	 *
	 * @return The permission name.
	 * @since 2018/12/08
	 */
	public final String getName()
	{
		return this._name;
	}
	
	/**
	 * Returns an empty permission collection for this given permission or
	 * {@code null} if one is not defined. This collection may be used by
	 * permission implementation to check if there are any implied
	 * permissions via {@link #implies(Permission)}. If {@code null} is
	 * returned this means the caller may store this within any collection
	 * of permissions.
	 *
	 * The default implementation returns {@code null}.
	 *
	 * @return The permission collection.
	 * @since 2018/12/08
	 */
	public PermissionCollection newPermissionCollection()
	{
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
			"(\"" + this.getClass().getName() + "\" \"" + this._name + "\")"));
		
		return rv;
	}
}

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

package java.security;

import java.util.Enumeration;

public abstract class PermissionCollection
{
	public PermissionCollection()
	{
		throw new todo.TODO();
	}
	
	public abstract void add(Permission __a);
	
	public abstract Enumeration<Permission> elements();
	
	public abstract boolean implies(Permission __a);
	
	public boolean isReadOnly()
	{
		throw new todo.TODO();
	}
	
	public void setReadOnly()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/AbstractCollection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a basic implementation of a {@link Collection}.
 *
 * Sub-classes are only required to implement {@link #iterator()} and
 * {@link #size()}.
 *
 * To support adding elements {@link add(Object)} must be implemented.
 *
 * To support removing elements {@link Iterator#remove()} must be implemented.
 *
 * @param <E> The element type.
 * @since 2018/09/15
 */
public abstract class AbstractCollection<E>
	implements Collection<E>
{
	/**
	 * Constructor which requires a sub-class to exist.
	 *
	 * @since 2018/09/15
	 */
	protected AbstractCollection()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public abstract Iterator<E> iterator();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public abstract int size();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean add(E __a)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public boolean addAll(Collection<? extends E> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Add but we also need to keep track if the underlying collection
		// was actually changed
		boolean changed = false;
		for (E e : __c)
			changed |= this.add(e);
		
		return changed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			// Remove is always after a next
			it.next();
			it.remove();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean contains(Object __v)
	{
		// Slow as it checks each entry
		for (E e : this)
			if (__v == null ? e == null : __v.equals(e))
				return true;
		
		// Not found
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean containsAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Check each entry
		int total = 0,
			found = 0;
		for (Object e : __c)
		{
			total++;
			if (this.contains(e))
				found++;
			
			// Entry is missing so this will later return false
			else
				return false;
		}
		
		return found == total;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean remove(Object __v)
	{
		// Find it and remove it
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			if (__v == null ? e == null : __v.equals(e))
			{
				it.remove();
				return true;
			}
		}
		
		// No changes
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean removeAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Remove things through our own iterator
		boolean did = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			
			// If it is in the collection, remove it
			if (__c.contains(e))
			{
				it.remove();
				did = true;
			}
		}
		
		return did;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean retainAll(Collection<?> __c)
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Remove things through our own iterator
		boolean did = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			
			// If it is not in the collection, remove it
			if (!__c.contains(e))
			{
				it.remove();
				did = true;
			}
		}
		
		return did;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public Object[] toArray()
	{
		int n = this.size();
		Object[] rv = new Object[n];
		int i = 0;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
			rv[i++] = it.next();
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public <T> T[] toArray(T[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Use to check or create a new array of the given type
		int size = this.size();
		
		// Only copy elements if there are any to copy, prevents creation
		// of the iterator
		if (size > 0)
		{
			// If the array is too small, reallocate it to fit
			if (__v.length < size)
				__v = Arrays.<T>copyOf(__v, size);
			
			// Copy elements based on the iteration order, just ignore the
			// class and hope it works
			int o = 0;
			for (E e : this)
				__v[o++] = (T)e;
		}
		
		// The element at the end of the array, if there is room is set to
		// null
		if (__v.length > size)
			__v[size] = null;
		
		return __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder("[");
		
		// Build string
		boolean comma = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			// Add comma
			if (comma)
				sb.append(", ");
			comma = true;
			
			// Add item
			sb.append(it.next());
		}
		
		sb.append("]");
		return sb.toString();
	}
}

Added modules/cldc-compact/src/main/java/java/util/AbstractList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

/**
 * This is the base class for all list types.
 *
 * @since 2018/12/07
 */
public abstract class AbstractList<E>
	extends AbstractCollection<E>
	implements List<E>
{
	/**
	 * The modification count of this list, used to detect situations
	 * where a list was modified while it was being iterated.
	 */
	protected transient int modCount;
	
	/**
	 * Constructor requiring sub-classing.
	 *
	 * @since 2018/09/15
	 */
	protected AbstractList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public abstract E get(int __i)
		throws IndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public boolean add(E __v)
	{
		int oldsize = this.size();
		this.add(oldsize, __v);
		return this.size() != oldsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for variable sized lists.")
	public void add(int __a, E __b)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		int n = this.size();
		if (__i < 0 || __i > n)
			throw new IndexOutOfBoundsException("NARG");
		
		// Add all elements
		for (E e : __c)
			this.add(__i++, e);
		
		// If the size changed the list was modified
		return this.size() != n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void clear()
	{
		this.removeRange(0, this.size());
	}
	
	/**
	 * This method follows the contract of the {@link List#equals(Object)}
	 * method.
	 *
	 * @param __o The object to compare against.
	 * @return If the specified object is a list and is equal to this list.
	 * @see List#equals(Object)
	 * @since 2017/11/21
	 */
	@Override
	@ImplementationNote("This method considers if the source and target " +
		"lists are RandomAccess, for more optimized comparison.")
	public boolean equals(Object __o)
	{
		// Same object, no point in comparing against self
		if (this == __o)
			return true;
		
		// The other object must be a list
		if (!(__o instanceof List))
			return false;
		
		// If either (or both) lists are not random access then it is possible
		// that there is a penalty in determining the size of the list, so
		// single entries must be considered via the iterators.
		List<?> o = (List<?>)__o;
		if (!(this instanceof RandomAccess) || !(o instanceof RandomAccess))
		{
			// Need both iterators
			Iterator<?> ai = this.iterator(),
				bi = o.iterator();
			
			// The lists may have infinite length
			while (true)
			{
				// If one list ends before the other then they are not equal
				boolean anext;
				if ((anext = ai.hasNext()) != bi.hasNext())
					return false;
				
				// Both are empty at the same time, same length
				if (!anext)
					return true;
				
				// Need these
				Object a = ai.next(),
					b = bi.next();
				
				// Nulls compare the same, but fail on mismatches
				if (a == null)
					if (b == null)
						continue;
					else
						return false;
				
				// This call should check b for null
				else if (!a.equals(b))
					return false;
			}
		}
		
		// Otherwise, a size comparison is likely not to be costly.
		else
		{
			// Equal lists always have the same size
			int an = this.size(),
				bn = o.size();
			if (an != bn)
				return false;
			
			for (int i = 0; i < an; i++)
			{
				Object a = this.get(i),
					b = o.get(i);
				
				// Nulls compare the same, but fail on mismatches
				if (a == null)
					if (b == null)
						continue;
					else
						return false;
				
				// This call should check b for null
				else if (!a.equals(b))
					return false;
			}
			
			// If this point reached, the lists are equal
			return true;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		int rv = 1;
		for (E e : this)
			rv = 31 * rv + (e == null ? 0 : e.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int indexOf(Object __v)
	{
		for (int i = 0, n = this.size(); i < n; i++)
		{
			E e = this.get(i);
			if ((__v == null ? e == null : __v.equals(e)))
				return i;
		}
		
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Iterator<E> iterator()
	{
		return new __AbstractListListIterator__<E>(this, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int lastIndexOf(Object __v)
	{
		for (int i = this.size() - 1; i >= 0; i--)
		{
			E e = this.get(i);
			if ((__v == null ? e == null : __v.equals(e)))
				return i;
		}
		
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public ListIterator<E> listIterator()
	{
		return this.listIterator(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public ListIterator<E> listIterator(int __i)
	{
		return new __AbstractListListIterator__<E>(this, __i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for variable sized lists.")
	public E remove(int __i)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Removes elements from the given inclusive range to the given exclusive
	 * range.
	 *
	 * The basic implementation of this method uses the list iterator until
	 * the from index is reached, once it has been reached it will remove
	 * the given number of elements. Therefor
	 *
	 * @param __from The first element to remove, inclusive.
	 * @param __to The last element to remove, exclusive.
	 * @since 2018/10/29
	 */
	@ProgrammerTip("The basic implementation of this method is not " +
		"efficient at all, it should be reimplemented if removal is a " +
		"busy operation.")
	protected void removeRange(int __from, int __to)
	{
		int left = __to - __from;
		ListIterator<E> li = this.listIterator(__from);
		while (left > 0)
		{
			if (!li.hasNext())
				break;
			
			// Get and remove
			li.next();
			li.remove();
			left--;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for modifiable lists.")
	public E set(int __i, E __v)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/30
	 */
	@Override
	public List<E> subList(int __from, int __to)
		throws IllegalArgumentException, IndexOutOfBoundsException
	{
		return new __AbstractListSubList__<E>(this, __from, __to);
	}
}

Added modules/cldc-compact/src/main/java/java/util/AbstractMap.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
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
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public abstract class AbstractMap<K, V>
	implements Map<K, V>
{
	protected AbstractMap()
	{
	}
	
	public abstract Set<Map.Entry<K, V>> entrySet();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		this.entrySet().clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	protected Object clone()
		throws CloneNotSupportedException
	{
		return (AbstractMap<?, ?>)super.clone();
	}
	
	public boolean containsKey(Object __a)
	{
		throw new todo.TODO();
	}
	
	public boolean containsValue(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public V get(Object __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (Map.Entry<K, V> e : this.entrySet())
			rv += e.hashCode();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public Set<K> keySet()
	{
		return new __AbstractMapKeySet__<K, V>(this);
	}
	
	public V put(K __a, V __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public void putAll(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Copy everything
		for (Map.Entry<? extends K, ? extends V> e : __m.entrySet())
			this.put(e.getKey(), e.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public V remove(Object __k)
	{
		// Linearly search through the hash map to remove the key
		for (Iterator<Map.Entry<K, V>> it = this.entrySet().iterator();
			it.hasNext();)
		{
			Map.Entry<K, V> e = it.next();
			
			// If the key matches, then it is removed
			if (Objects.equals(e.getKey(), __k))
			{
				V rv = e.getValue();
				it.remove();
				return rv;
			}
		}
		
		// If this point was reached, there is no matching key
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int size()
	{
		return this.entrySet().size();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder("{");
		
		// Go through and append
		boolean comma = false;
		for (Map.Entry<?, ?> e : this.entrySet())
		{
			// Space comma
			if (comma)
				sb.append(", ");
			comma = true;
			
			// Key is equal to the value
			sb.append(e.getKey());
			sb.append('=');
			sb.append(e.getValue());
		}
		
		sb.append('}');
		return sb.toString();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public Collection<V> values()
	{
		return new __AbstractMapValues__<K, V>(this);
	}
}


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

package java.util;

/**
 * This is the base list for classes which are optimized for sequential and
 * not randomized access.
 *
 * @param <E> The element to store in the list.
 * @since 2018/10/29
 */
public abstract class AbstractSequentialList<E>
	extends AbstractList<E>
{
	/**
	 * Initializes the base sequential list.
	 *
	 * @since 2018/10/29
	 */
	protected AbstractSequentialList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public abstract ListIterator<E> listIterator(int __i);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void add(int __i, E __v)
	{
		// Just adds the entry at the given position
		this.listIterator(__i).add(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		boolean mod = false;
		ListIterator<E> li = this.listIterator(__i);
		for (E e : __c)
		{
			li.add(e);
			li.next();
			
			// Modified
			mod = true;
		}
		
		return mod;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E get(int __i)
	{
		return this.listIterator(__i).next();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Iterator<E> iterator()
	{
		return this.listIterator(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E remove(int __i)
	{
		ListIterator<E> li = this.listIterator(__i);
		E rv = li.next();
		li.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E set(int __i, E __v)
	{
		ListIterator<E> li = this.listIterator(__i);
		E rv = li.next();
		li.set(__v);
		return rv;
	}
}

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

package java.util;

/**
 * This is an abstract set which provides only a few more methods than the
 * base collection class.
 *
 * @param <E> The storage type.
 * @since 2018/12/07
 */
public abstract class AbstractSet<E>
	extends AbstractCollection<E>
	implements Set<E>
{
	/**
	 * Requires that the class be extended.
	 *
	 * @since 2018/10/10
	 */
	protected AbstractSet()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Set))
			return false;
		
		// Compare size first
		Set<?> o = (Set<?>)__o;
		if (this.size() != o.size())
			return false;
		
		// Just check if this set contains everything in the other set
		return this.containsAll(o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (E e : this)
			rv += (e == null ? 0 : e.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean removeAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Iterate over our set and remove
		boolean did = false;
		if (this.size() <= __c.size())
		{
			for (Iterator<E> it = this.iterator(); it.hasNext();)
			{
				E e = it.next();
				
				if (__c.contains(e))
				{
					it.remove();
					did = true;
				}
			}
		}
		
		// Iterate over the other set and remove from ours
		else
		{
			for (Iterator<?> it = __c.iterator(); it.hasNext();)
			{
				Object e = it.next();
				
				if (this.contains(e))
				{
					this.remove(e);
					did = true;
				}
			}
		}
		
		return did;
	}
}

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

package java.util;

public class ArrayDeque<E>
	extends AbstractCollection<E>
	implements Deque<E>, Cloneable
{
	public ArrayDeque()
	{
		throw new todo.TODO();
	}
	
	public ArrayDeque(int __a)
	{
		throw new todo.TODO();
	}
	
	public ArrayDeque(Collection<? extends E> __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean add(E __a)
	{
		throw new todo.TODO();
	}
	
	public void addFirst(E __a)
	{
		throw new todo.TODO();
	}
	
	public void addLast(E __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}
	
	@Override
	public ArrayDeque<E> clone()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean contains(Object __a)
	{
		throw new todo.TODO();
	}
	
	public Iterator<E> descendingIterator()
	{
		throw new todo.TODO();
	}
	
	public E element()
	{
		throw new todo.TODO();
	}
	
	public E getFirst()
	{
		throw new todo.TODO();
	}
	
	public E getLast()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Iterator<E> iterator()
	{
		throw new todo.TODO();
	}
	
	public boolean offer(E __a)
	{
		throw new todo.TODO();
	}
	
	public boolean offerFirst(E __a)
	{
		throw new todo.TODO();
	}
	
	public boolean offerLast(E __a)
	{
		throw new todo.TODO();
	}
	
	public E peek()
	{
		throw new todo.TODO();
	}
	
	public E peekFirst()
	{
		throw new todo.TODO();
	}
	
	public E peekLast()
	{
		throw new todo.TODO();
	}
	
	public E poll()
	{
		throw new todo.TODO();
	}
	
	public E pollFirst()
	{
		throw new todo.TODO();
	}
	
	public E pollLast()
	{
		throw new todo.TODO();
	}
	
	public E pop()
	{
		throw new todo.TODO();
	}
	
	public void push(E __a)
	{
		throw new todo.TODO();
	}
	
	public E remove()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean remove(Object __a)
	{
		throw new todo.TODO();
	}
	
	public E removeFirst()
	{
		throw new todo.TODO();
	}
	
	public boolean removeFirstOccurrence(Object __a)
	{
		throw new todo.TODO();
	}
	
	public E removeLast()
	{
		throw new todo.TODO();
	}
	
	public boolean removeLastOccurrence(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public int size()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/ArrayList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a resizeable list which is backed by an array.
 *
 * This class is not thread safe, for a thread safe version see {@link Vector}.
 *
 * If a modification is detected in the iterator then
 * {@link ConcurrentModificationException} is thrown as soon as possible.
 *
 * @param <E> The element type.
 * @see Vector
 * @since 2018/09/15
 */
public class ArrayList<E>
	extends AbstractList<E>
	implements List<E>, RandomAccess, Cloneable
{
	/** Capacity growth size. */
	private static final int _GROWTH =
		8;
	
	/** Elements in the list. */
	private E[] _elements;
	
	/** The number of elements in the list. */
	private int _size;
	
	/**
	 * Initializes a list which has an initial capacity of 10.
	 *
	 * @since 2018/09/15
	 */
	public ArrayList()
	{
		this(10);
	}
	
	/**
	 * Initializes a list which has the specified capacity.
	 *
	 * @param __cap The initial capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/09/15
	 */
	@SuppressWarnings({"unchecked"})
	public ArrayList(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ2e Attempt to initialize array list with
		// a negative capacity. (The capicity)}
		if (__cap < 0)
			throw new IllegalArgumentException(
				String.format("ZZ2e %d", __cap));
		
		this._elements = (E[])new Object[__cap];
	}
	
	/**
	 * Initializes a list which has all the elements of the given collection
	 * in its iteration order.
	 *
	 * @param __o The other collection.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	@SuppressWarnings({"unchecked"})
	public ArrayList(Collection<? extends E> __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Initial capacity is the size of the other collection
		this._elements = (E[])new Object[__o.size()];
		
		// And then add everything
		this.addAll(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public void add(int __i, E __v)
		throws IndexOutOfBoundsException
	{
		int size = this._size;
		if (__i < 0 || __i > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		E[] elements = this._elements;
		int cap = elements.length,
			nextsize = size + 1;
		
		// Cannot fit in this array
		E[] source = elements;
		if (nextsize > cap)
		{
			// Grow the list by a bit
			int newcap = nextsize + ArrayList._GROWTH;
			elements = (E[])new Object[newcap];
			
			// Copy old stuff over, but only up to the index as needed
			for (int i = 0; i < __i; i++)
				elements[i] = source[i];
		}
		
		// Move down to fit
		for (int i = size - 1, o = size; o > __i; i--, o--)
			elements[o] = source[i];
		
		// Store data here
		elements[__i] = __v;
		
		// Store new information
		this._size = nextsize;
		if (elements != source)
			this._elements = elements;
		
		// Structurally modified
		this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void clear()
	{
		// Clear the entire array so things get collected
		E[] elements = this._elements;
		int size = this._size;
		for (int i = 0; i < size; i++)
			elements[i] = null;
		
		// Keep the backing array, just clear the size
		this._size = 0;
		
		// Structurally modified
		this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public Object clone()
	{
		return new ArrayList<>(this);
	}
	
	/**
	 * Ensures that the given number of elements can fit in the list.
	 *
	 * @param __n The number of elements.
	 * @since 2019/05/14
	 */
	@SuppressWarnings({"unchecked"})
	public void ensureCapacity(int __n)
	{
		// Pointless
		if (__n <= 0)
			return;
		
		// Meets or exceeds the desired capacity?
		E[] elements = this._elements;
		int nowl = elements.length;
		if (__n <= nowl)
			return;
		
		// Copy values over
		E[] extra = (E[])new Object[__n];
		for (int i = 0; i < nowl; i++)
			extra[i] = elements[i];
		
		// Set
		this._elements = extra;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public E get(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this._elements[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/12
	 */
	@Override
	public E remove(int __i)
		throws IndexOutOfBoundsException
	{
		// Out of bounds?
		int size = this._size;
		if (__i < 0 || __i >= size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get the old element first
		E[] elements = this._elements;
		E rv = elements[__i];
		
		// Copy all of the elements down
		for (int o = __i, i = __i + 1; i < size; o++, i++)
			elements[o] = elements[i];
		elements[size - 1] = null;
		
		// Set new size
		this._size = size - 1;
		
		// Structurally modified
		this.modCount++;
		
		// And the old element
		return rv;
	}
	
	@Override
	protected void removeRange(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/10
	 */
	@Override
	public E set(int __i, E __v)
	{
		// Out of bounds?
		int size = this._size;
		if (__i < 0 || __i >= size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Read old value
		E[] elements = this._elements;
		E rv = elements[__i];
		
		// Set new value
		elements[__i] = __v;
		
		// Return old
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	public void trimToSize()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/Arrays.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.util.ByteIntegerArray;
import cc.squirreljme.runtime.cldc.util.CharacterIntegerArray;
import cc.squirreljme.runtime.cldc.util.DoubleArrayList;
import cc.squirreljme.runtime.cldc.util.FloatArrayList;
import cc.squirreljme.runtime.cldc.util.IntegerArrays;
import cc.squirreljme.runtime.cldc.util.IntegerIntegerArray;
import cc.squirreljme.runtime.cldc.util.LongArrayList;
import cc.squirreljme.runtime.cldc.util.ShellSort;
import cc.squirreljme.runtime.cldc.util.ShortIntegerArray;

/**
 * This class contains utility methods which operate on arrays.
 *
 * {@squirreljme.error ZZ2f The sort range exceeds the array bounds.}
 * {@squirreljme.error ZZ2g The from index exceeds the to index.}
 *
 * @since 2016/09/30
 */
public class Arrays
{
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private Arrays()
	{
	}
	
	/**
	 * Wraps the specified array allowing access to its data as a fixed size
	 * list. The returned {@link List} will have {@link RandomAccess}
	 * implemented.
	 *
	 * @param <T> The type of values contained within the array.
	 * @param __a The array to wrap.
	 * @return The specified array wrapped in a {@link List}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/31
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> List<T> asList(T... __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		return new __ArraysList__<T>(__a);
	}
	
	public static int binarySearch(long[] __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(long[] __a, int __b, int __c, long __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(int[] __a, int __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(int[] __a, int __from, int __to, int __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new IntegerIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(short[] __a, short __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(short[] __a, int __from, int __to,
		short __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new ShortIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(char[] __a, char __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(char[] __a, int __from, int __to,
		char __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new CharacterIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(byte[] __a, byte __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(byte[] __a, int __from, int __to,
		byte __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new ByteIntegerArray(__a),
			__from, __to, __key);
	}
	
	public static int binarySearch(double[] __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(double[] __a, int __b, int __c, double __d)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(float[] __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(float[] __a, int __b, int __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(Object[] __a, Object __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(Object[] __a, int __b, int __c, Object __d)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(T[] __a, T __b, Comparator<? super T>
		__c)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(T[] __a, int __b, int __c, T __d,
		Comparator<? super T> __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a copy of the given array but using the specified type.
	 *
	 * @param <T> The resulting type of the array to use.
	 * @param __src The source array.
	 * @param __newlen The new length of the array.
	 * @return The copy of the array with the new length and type.
	 * @throws ArrayStoreException If an element being copied from the source
	 * array is not compatible with the destination array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> T[] copyOf(T[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		return Arrays.<T, T>copyOf(__src, __newlen,
			(Class<T[]>)__src.getClass());
	}
	
	/**
	 * Returns a copy of the given array but using the specified type.
	 *
	 * @param <T> The resulting type of the array to use.
	 * @param <U> The input array type.
	 * @param __src The source array.
	 * @param __newlen The new length of the array.
	 * @param __targettype The type type.
	 * @return The copy of the array with the new length and type.
	 * @throws ArrayStoreException If an element being copied from the source
	 * array is not compatible with the destination array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	@SuppressWarnings({"unchecked"})
	public static <T, U> T[] copyOf(U[] __src, int __newlen,
		Class<? extends T[]> __targettype)
		throws ArrayStoreException, NegativeArraySizeException,
			NullPointerException
	{
		if (__src == null || __targettype == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		// Allocate array in the target type
		Object[] rv = (Object[])ObjectAccess.arrayNew(__targettype, __newlen);
		
		// Copy source to destination
		for (int i = 0, n = Math.min(__src.length, __newlen); i < n; i++)
			rv[i] = __src[i];
		
		return (T[])rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static byte[] copyOf(byte[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		byte[] rv = new byte[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static short[] copyOf(short[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		short[] rv = new short[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static int[] copyOf(int[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		int[] rv = new int[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static long[] copyOf(long[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		long[] rv = new long[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static char[] copyOf(char[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		char[] rv = new char[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static float[] copyOf(float[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		float[] rv = new float[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static double[] copyOf(double[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		double[] rv = new double[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @return The copied array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static boolean[] copyOf(boolean[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		boolean[] rv = new boolean[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(long[] __a, long[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(int[] __a, int[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(short[] __a, short[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(char[] __a, char[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(byte[] __a, byte[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(boolean[] __a, boolean[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(double[] __a, double[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(float[] __a, float[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(Object[] __a, Object[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (!Objects.equals(__a[i], __b[i]))
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(long[] __a, long __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(int[] __a, int __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(short[] __a, short __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(char[] __a, char __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(byte[] __a, byte __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(boolean[] __a, boolean __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(double[] __a, double __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(float[] __a, float __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(Object[] __a, Object __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(int[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(int[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		IntegerArrays.sort(new IntegerIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(long[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(long[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Long>sort(new LongArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(short[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(short[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new ShortIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(char[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The source array.
	 * @param __to The destination array.
	 * @throws ArrayIndexOutOfBoundsException If the from and/or to index
	 * exceed the array bounds.
	 * @throws IllegalArgumentException If the from index is greater than to
	 * index.
	 * @throws NullPointerException If no array was specified.
	 * @since 2018/10/28
	 */
	public static void sort(char[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new CharacterIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(byte[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(byte[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new ByteIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(float[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(float[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Float>sort(new FloatArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(double[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(double[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Double>sort(new DoubleArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array using the natural {@link Comparator}.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(Object[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		Arrays.<Object>sort(__a, 0, __a.length, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(Object[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		Arrays.<Object>sort(__a, __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param <T> The type to sort.
	 * @param __a The array to sort.
	 * @param __comp The comparator to use.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static <T> void sort(T[] __a, Comparator<? super T> __comp)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.<T>sort(__a, 0, __a.length, __comp);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param <T> The type to sort.
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __comp The comparator to use.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static <T> void sort(T[] __a, int __from, int __to,
		Comparator<? super T> __comp)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// The thrown exception may need to be remapped
		try
		{
			ShellSort.<T>sort(Arrays.<T>asList(__a), __from, __to, __comp);
		}
		
		// {@squirreljme.error ZZ2h Out of bounds access when sorting array.}
		catch (IndexOutOfBoundsException e)
		{
			if (e instanceof ArrayIndexOutOfBoundsException)
				throw e;
			
			RuntimeException t = new ArrayIndexOutOfBoundsException("ZZ2h");
			t.initCause(e);
			throw t;
		}
	}
}

Added modules/cldc-compact/src/main/java/java/util/Calendar.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public abstract class Calendar
	implements Cloneable, Comparable<Calendar>
{
	public static final int AM =
		0;
	
	public static final int AM_PM =
		9;
	
	public static final int APRIL =
		3;
	
	public static final int AUGUST =
		7;
	
	public static final int DATE =
		5;
	
	public static final int DAY_OF_MONTH =
		5;
	
	public static final int DAY_OF_WEEK =
		7;
	
	public static final int DAY_OF_WEEK_IN_MONTH =
		8;
	
	public static final int DAY_OF_YEAR =
		6;
	
	public static final int DECEMBER =
		11;
	
	public static final int DST_OFFSET =
		16;
	
	public static final int ERA =
		0;
	
	public static final int FEBRUARY =
		1;
	
	public static final int FIELD_COUNT =
		17;
	
	public static final int FRIDAY =
		6;
	
	public static final int HOUR =
		10;
	
	public static final int HOUR_OF_DAY =
		11;
	
	public static final int JANUARY =
		0;
	
	public static final int JULY =
		6;
	
	public static final int JUNE =
		5;
	
	public static final int MARCH =
		2;
	
	public static final int MAY =
		4;
	
	public static final int MILLISECOND =
		14;
	
	public static final int MINUTE =
		12;
	
	public static final int MONDAY =
		2;
	
	public static final int MONTH =
		2;
	
	public static final int NOVEMBER =
		10;
	
	public static final int OCTOBER =
		9;
	
	public static final int PM =
		1;
	
	public static final int SATURDAY =
		7;
	
	public static final int SECOND =
		13;
	
	public static final int SEPTEMBER =
		8;
	
	public static final int SUNDAY =
		1;
	
	public static final int THURSDAY =
		5;
	
	public static final int TUESDAY =
		3;
	
	public static final int UNDECIMBER =
		12;
	
	public static final int WEDNESDAY =
		4;
	
	public static final int WEEK_OF_MONTH =
		4;
	
	public static final int WEEK_OF_YEAR =
		3;
	
	public static final int YEAR =
		1;
	
	public static final int ZONE_OFFSET =
		15;
	
	protected boolean areFieldsSet;
	
	protected int[] fields;
	
	protected boolean[] isSet;
	
	protected boolean isTimeSet;
	
	protected long time;
	
	protected Calendar()
	{
		throw new todo.TODO();
	}
	
	public abstract void add(int __a, int __b);
	
	protected abstract void computeFields();
	
	protected abstract void computeTime();
	
	public abstract int getGreatestMinimum(int __a);
	
	public abstract int getLeastMaximum(int __a);
	
	public abstract int getMaximum(int __a);
	
	public abstract int getMinimum(int __a);
	
	public abstract void roll(int __a, boolean __b);
	
	public boolean after(Object __a)
	{
		throw new todo.TODO();
	}
	
	public boolean before(Object __a)
	{
		throw new todo.TODO();
	}
	
	public final void clear()
	{
		throw new todo.TODO();
	}
	
	public final void clear(int __a)
	{
		throw new todo.TODO();
	}
	
	public Object clone()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Calendar __a)
	{
		throw new todo.TODO();
	}
	
	protected void complete()
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int get(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getActualMaximum(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getActualMinimum(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getFirstDayOfWeek()
	{
		throw new todo.TODO();
	}
	
	public int getMinimalDaysInFirstWeek()
	{
		throw new todo.TODO();
	}
	
	public final Date getTime()
	{
		throw new todo.TODO();
	}
	
	public long getTimeInMillis()
	{
		throw new todo.TODO();
	}
	
	public TimeZone getTimeZone()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	protected final int internalGet(int __a)
	{
		throw new todo.TODO();
	}
	
	public boolean isLenient()
	{
		throw new todo.TODO();
	}
	
	public final boolean isSet(int __a)
	{
		throw new todo.TODO();
	}
	
	public void roll(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c, int __d, int __e, int
		__f)
	{
		throw new todo.TODO();
	}
	
	public void setFirstDayOfWeek(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setLenient(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setMinimalDaysInFirstWeek(int __a)
	{
		throw new todo.TODO();
	}
	
	public final void setTime(Date __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeInMillis(long __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeZone(TimeZone __a)
	{
		throw new todo.TODO();
	}
	
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static Calendar getInstance()
	{
		throw new todo.TODO();
	}
	
	public static Calendar getInstance(TimeZone __a)
	{
		throw new todo.TODO();
	}
}

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

package java.util;

public interface Collection<E>
	extends Iterable<E>
{
	boolean add(E __a);
	
	boolean addAll(Collection<? extends E> __a);
	
	void clear();
	
	boolean contains(Object __a);
	
	boolean containsAll(Collection<?> __a);
	
	@Override
	boolean equals(Object __a);
	
	@Override
	int hashCode();
	
	boolean isEmpty();
	
	Iterator<E> iterator();
	
	boolean remove(Object __a);
	
	boolean removeAll(Collection<?> __a);
	
	boolean retainAll(Collection<?> __a);
	
	int size();
	
	Object[] toArray();
	
	<T> T[] toArray(T[] __v)
		throws NullPointerException;
}

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

package java.util;

import cc.squirreljme.runtime.cldc.util.ShellSort;

public class Collections
{
	private Collections()
	{
		throw new todo.TODO();
	}
	
	@SuppressWarnings({"unchecked"})
	public static <T> boolean addAll(Collection<? super T> __a, T... __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(List<? extends Comparable<? super T>>
		__a, T __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(List<? extends T> __a, T __b,
		Comparator<? super T> __c)
	{
		throw new todo.TODO();
	}
	
	public static <T> void copy(List<? super T> __a, List<? extends T> __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean disjoint(Collection<?> __a, Collection<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> Enumeration<T> enumeration(Collection<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> void fill(List<? super T> __a, T __b)
	{
		throw new todo.TODO();
	}
	
	public static int frequency(Collection<?> __a, Object __b)
	{
		throw new todo.TODO();
	}
	
	public static int indexOfSubList(List<?> __a, List<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static int lastIndexOfSubList(List<?> __a, List<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> ArrayList<T> list(Enumeration<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T extends Object & Comparable<? super T>> T max(Collection
		<? extends T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> T max(Collection<? extends T> __a, Comparator<? super T
		> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T extends Object & Comparable<? super T>> T min(Collection
		<? extends T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> T min(Collection<? extends T> __a, Comparator<? super T
		> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> boolean replaceAll(List<T> __a, T __b, T __c)
	{
		throw new todo.TODO();
	}
	
	public static void reverse(List<?> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> Comparator<T> reverseOrder()
	{
		throw new todo.TODO();
	}
	
	public static <T> Comparator<T> reverseOrder(Comparator<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static void rotate(List<?> __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static void shuffle(List<?> __a)
	{
		throw new todo.TODO();
	}
	
	public static void shuffle(List<?> __a, Random __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sorts the specified list.
	 *
	 * @param <T> The type of values to sort.
	 * @param __a The list to sort.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	public static <T extends Comparable<? super T>> void sort(List<T> __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		ShellSort.<T>sort(__a, 0, __a.size(), null);
	}
	
	/**
	 * Sorts the specified list.
	 *
	 * @param <T> The type of values to sort.
	 * @param __a The list to sort.
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	public static <T> void sort(List<T> __a, Comparator<? super T> __comp)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		ShellSort.<T>sort(__a, 0, __a.size(), __comp);
	}
	
	public static void swap(List<?> __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
}

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

package java.util;

public interface Comparator<T>
{
	int compare(T __a, T __b);
	
	/**
	 * Generally this should return {@code true} if a given comparison results
	 * in a value of {@code 0}.
	 *
	 * {@inheritDoc}
	 * @since 2016/04/12
	 */
	@Override
	boolean equals(Object __a);
}

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

package java.util;

/**
 * This is thrown when through iteration the structure of the collection
 * was modified between iterations.
 *
 * @since 2018/12/08
 */
public class ConcurrentModificationException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public ConcurrentModificationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public ConcurrentModificationException(String __m)
	{
		super(__m);
	}
}

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

package java.util;

/**
 * This represents a simplified time and date.
 *
 * The epoch is the same as {@link System#currentTimeMillis()} and is from
 * January 1, 1970 at 00:00 GMT.
 *
 * @since 2019/12/25
 */
public class Date
	implements Cloneable, Comparable<Date>
{
	/** The current Java time. */
	private transient long _javatime;
	
	/**
	 * Initializes this date at the current system time.
	 *
	 * @since 2019/12/25
	 */
	public Date()
	{
		this(System.currentTimeMillis());
	}
	
	/**
	 * Initializes the date to the given time.
	 *
	 * @param __time The time to set.
	 * @since 2019/12/25
	 */
	public Date(long __time)
	{
		this._javatime = __time;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public Object clone()
	{
		return new Date(((Date)this)._javatime);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public int compareTo(Date __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		long a = this._javatime,
			b = __b._javatime;
		
		return (a < b ? -1 : (a > b ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(this instanceof Date))
			return false;
		
		return this._javatime == ((Date)__o)._javatime;
	}
	
	/**
	 * Returns the number of milliseconds since the epoch.
	 *
	 * @return The number of milliseconds since the epoch.
	 * @since 2019/12/25
	 */
	public long getTime()
	{
		return this._javatime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public int hashCode()
	{
		long javatime = this._javatime;
		return (int)(javatime ^ (javatime >>> 32));
	}
	
	/**
	 * Sets the current time.
	 *
	 * @param __v The time to set.
	 * @since 2019/12/25
	 */
	public void setTime(long __v)
	{
		this._javatime = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public String toString()
	{
		// "dow mon dd hh:mm:ss zzz yyyy"
		
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/Deque.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Deque<E>
	extends Queue<E>
{
	boolean add(E __a);
	
	void addFirst(E __a);
	
	void addLast(E __a);
	
	boolean contains(Object __a);
	
	Iterator<E> descendingIterator();
	
	E element();
	
	E getFirst();
	
	E getLast();
	
	Iterator<E> iterator();
	
	boolean offer(E __a);
	
	boolean offerFirst(E __a);
	
	boolean offerLast(E __a);
	
	E peek();
	
	E peekFirst();
	
	E peekLast();
	
	E poll();
	
	E pollFirst();
	
	E pollLast();
	
	E pop();
	
	void push(E __a);
	
	E remove();
	
	boolean remove(Object __a);
	
	E removeFirst();
	
	boolean removeFirstOccurrence(Object __a);
	
	E removeLast();
	
	boolean removeLastOccurrence(Object __a);
	
	int size();
}

Added modules/cldc-compact/src/main/java/java/util/EmptyStackException.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is thrown when the stack is empty.
 *
 * @since 2018/11/29
 */
public class EmptyStackException
	extends RuntimeException
{
}

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

package java.util;

/**
 * This is an old class which duplicates the functionality of {@link Iterator}
 * without having support for removal.
 *
 * Generally, {@link Enumeration}s are not meant to be shared across threads.
 *
 * It is recommended to use {@link Iterator} when writing new code. However
 * this class exists for backwards compatibility with J2ME environments.
 *
 * @param <E> The type of value to iterate over.
 * @see Iterator
 * @since 2016/04/12
 */
public interface Enumeration<E>
{
	/**
	 * Returns {@code true} if there are more elements in the enumeration.
	 *
	 * @return {@code true} if there are more elements available.
	 * @since 2016/04/12
	 */
	boolean hasMoreElements();
	
	/**
	 * Returns the next element in the enumeration.
	 *
	 * @return The next element.
	 * @throws NoSuchElementException If no more elements remain.
	 * @since 2016/04/12
	 */
	E nextElement()
		throws NoSuchElementException;
}

Added modules/cldc-compact/src/main/java/java/util/EventListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This class must be implemented by anything that listens for events.
 *
 * @since 2016/06/23
 */
public interface EventListener
{
}

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

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * The class which all event objects shall be derived from.
 *
 * @since 2019/01/20
 */
public class EventObject
{
	/** The source of the event. */
	private Object _source;
	
	/**
	 * Initializes the object.
	 *
	 * @param __s The source of the event.
	 * @throws IllegalArgumentException If no source was specified.
	 * @since 2019/01/20
	 */
	@ImplementationNote("Throwing IllegalArgumentException is intended.")
	public EventObject(Object __s)
		throws IllegalArgumentException
	{
		if (__s == null)
			throw new IllegalArgumentException("NARG");
		
		this._source = __s;
	}
	
	/**
	 * Returns the source object.
	 *
	 * @return The source object.
	 * @since 2019/01/20
	 */
	public Object getSource()
	{
		return this._source;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public String toString()
	{
		// Matches what Java SE returns
		return this.getClass().getName() + "[source=" + this._source + "]";
	}
}

Added modules/cldc-compact/src/main/java/java/util/Formatter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Writer;

/**
 * This class implements C-style {@code printf()} formatted for text, it is
 * inspired by the C language but it does not match it exactly and this is
 * far more strict in what it requires.
 *
 * Format specifiers start with the {@code '%'} character which defines a
 * sequence accordingly. The format specifiers are in the following format:
 * {@code %[argument_index$][flags][width][.precision]conversion}. Any fields
 * within brackets are optional. For any specifiers which do not conform to
 * arguments, their format is {@code %[flags][width]conversion}.
 *
 * {@code argument_index$} specifies which argument to take the value from,
 * this allows one to use an alternative order. If this is not specified then
 * the order is implied based on the argument order for any specifiers which
 * do not use an argument index. This means that:
 * {@code format("%7$d %d %6$d %d %% %d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)} will
 * print {@code "7 1 6 2 % 3"}.
 *
 * {@code flags} specifies special flags which are used to modify how the
 * printing is done. The following flags are used:
 *
 *  - {@code '-'} -- Left justified
 *    (general, char, int, float, date).
 *  - {@code '#'} -- Conversion dependent alternate form
 *    (general, int (only: o, x, X), float).
 *  - {@code '+'} -- Include a sign always
 *    (int, float).
 *  - {@code ' '} -- Include leading space for positive values
 *    (int, float).
 *  - {@code '0'} -- Zero padding
 *    (int, float).
 *  - {@code ','} -- Use locale specific grouping separators
 *    (int (only: d), float).
 *  - {@code '('} -- Negative values are enclosed in parenthesis
 *    (int, float).
 *
 * {@code width} is a positive decimal integer which specifies the minimum
 * amount of space the text will take up, it will be aligned accordingly
 * depending on the flags used.
 *
 * {@code precision} is a positive decimal integer which specified a limit
 * on the output, this depends on the format specifier.
 *
 * {@code conversion} is the symbol which determines how the input is to be
 * formatted.
 *
 * @since 2018/09/23
 */
@ImplementationNote("")
public final class Formatter
	implements Closeable
{
	/** The newline sequence. */
	private static final String _NEWLINE;
	
	/** The appendable to write to. */
	private final Appendable _out;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/** The IOException if any was generated. */
	private IOException _ioe;
	
	/**
	 * Cache the line separator which is derived from the system properties.
	 *
	 * @since 2018/10/10
	 */
	static
	{
		String nl;
		try
		{
			nl = System.getProperty("line.separator");
		}
		catch (SecurityException e)
		{
			nl = "\n";
		}
		
		_NEWLINE = nl;
	}
	
	/**
	 * Initializes a formatter which uses an internal {@link StringBuilder}.
	 *
	 * @since 2018/09/23
	 */
	public Formatter()
	{
		this._out = new StringBuilder();
	}
	
	/**
	 * Initializes the formatter writing to the given output.
	 *
	 * @param __a The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	public Formatter(Appendable __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this._out = __a;
	}
	
	/**
	 * Initializes the formatter writing to the given output.
	 *
	 * @param __ps The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	public Formatter(PrintStream __ps)
		throws NullPointerException
	{
		this((Appendable)__ps);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public void close()
	{
		// No effect?
		if (this._closed)
			return;
		
		// Set closed
		this._closed = true;
		
		// Can only be done if it is closeable
		Appendable out = this._out;
		if (out instanceof Closeable)
			try
			{
				((Closeable)out).close();
			}
			catch (IOException e)
			{
				this._ioe = e;
			}
	}
	
	/**
	 * Flushes the output formatter, if it is flushable.
	 *
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	public void flush()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2i The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2i");
		
		// Java ME has no Flushable interface so only certain classes have
		// the flush method
		try
		{
			Appendable out = this._out;
			if (out instanceof OutputStream)
				((OutputStream)out).flush();
			else if (out instanceof Writer)
				((Writer)out).flush();
		}
		
		// {@squirreljme.error ZZ2j Could not flush the formatter.}
		catch (IOException e)
		{
			throw new RuntimeException("ZZ2j", e);
		}
	}
	
	/**
	 * Prints formatted text to the output.
	 *
	 * @param __fmt The format specified.
	 * @param __args The input arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the format specifiers are not
	 * valid.
	 * @throws IllegalStateException If this formatter has been closed.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public Formatter format(String __fmt, Object... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__fmt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2k This formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2k");
		
		// Force this to exist
		if (__args == null)
			__args = new Object[0];
		
		// Global state needed for argument handling.
		__PrintFGlobal__ pg = new __PrintFGlobal__(__args);
		
		// Writing to the appendable may cause an exception to occur
		try
		{
			// Process input characters
			Appendable out = this._out;
			for (int i = 0, n = __fmt.length(), next = 0; i < n; i = next)
			{
				char c = __fmt.charAt(i);
				
				// Just a normal character
				if (c != '%')
				{
					out.append(c);
					
					// Just skip the single character
					next = i + 1;;
					continue;
				}
				
				// It is simpler to handle the parsing of the specifier in
				// another method due to loops and variables
				__PrintFState__ pf = new __PrintFState__(pg);
				next = this.__specifier(pf, i, __fmt);
				
				// Handle output of the specifier
				this.__output(out, pf);
			}
		}
		
		// Catch any exception
		catch (IOException e)
		{
			this._ioe = e;
		}
		
		return this;
	}
	
	/**
	 * Returns the last {@link IOException} that was thrown by the output.
	 *
	 * @return The last exception thrown or {@code null} if one was never
	 * thrown.
	 * @since 2018/09/23
	 */
	public IOException ioException()
	{
		return this._ioe;
	}
	
	/**
	 * Returns the output.
	 *
	 * @return The output.
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	public Appendable out()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2l The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2l");
		
		return this._out;
	}
	
	/**
	 * This performs {@code this.out().toString()} and returns that result, as
	 * such the value here might not match what was written into the string.
	 *
	 * @return The string from the output.
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2m The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2m");
		
		return this._out.toString();
	}
	
	/**
	 * Formats integer number in decimal format.
	 *
	 * @param __pf The state used.
	 * @param __n The number used.
	 * @return The formatted integer number.
	 * @throws NullPointerException If no state is specified.
	 * @since 2018/11/03
	 */
	private static String __formatDecimalInt(__PrintFState__ __pf, Number __n)
		throws NullPointerException
	{
		if (__pf == null)
			throw new NullPointerException("NARG");
		
		// Null is used.
		if (__n == null)
			return null;
		
		// {@squirreljme.error ZZ3s Decimal integers cannot have an
		// alternative form.}
		if (__pf.__hasFlag(__PrintFFlag__.ALTERNATIVE_FORM))
			throw new IllegalArgumentException("ZZ3s");
		
		// Generate base number
		long value = __n.longValue();
		boolean neg = (value < 0);
		StringBuilder base = new StringBuilder(Long.toString(value));
		
		// Use local digit grouping
		if (__pf.__hasFlag(__PrintFFlag__.LOCALE_GROUPING))
			throw new todo.TODO();
		
		// Negative values can have flags (note negatives are always signed)
		boolean signed = neg;
		if (neg)
		{
			// Use parenthesis for negative instead
			if (__pf.__hasFlag(__PrintFFlag__.NEGATIVE_PARENTHESIS))
			{
				// Replace the sign with open parenthesis
				base.setCharAt(0, '(');
				
				// And add parenthesis to the end
				base.append(')');
			}
		}
		
		// Positive values have some flags
		else
		{
			// Always use the sign
			if (signed |= __pf.__hasFlag(__PrintFFlag__.ALWAYS_SIGNED))
				base.insert(0, '+');
			
			// Space for positive value
			else if (signed |= __pf.__hasFlag(
				__PrintFFlag__.SPACE_FOR_POSITIVE))
				base.insert(0, ' ');
		}
		
		// Padding with zero? Remember if there is a sign in place
		if (__pf.__hasFlag(__PrintFFlag__.ZERO_PADDED))
			for (int w = __pf.__width(), idx = (signed ? 1 : 0);
				base.length() < w;)
				base.insert(idx, '0');
		
		// Use this result
		return base.toString();
	}
	
	/**
	 * Formats other unsigned value.
	 *
	 * @param __pf Printing state.
	 * @param __n The number to print.
	 * @param __base The number's base.
	 * @throws 
	 */
	private static String __formatOtherUnsignedInt(__PrintFState__ __pf,
		Number __n, int __base)
		throws NullPointerException
	{
		if (__pf == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3t Invalid flag specified for unsigned
		// formatted value.}
		if (__pf.__hasFlag(__PrintFFlag__.LOCALE_GROUPING) ||
			__pf.__hasFlag(__PrintFFlag__.NEGATIVE_PARENTHESIS) ||
			__pf.__hasFlag(__PrintFFlag__.ALWAYS_SIGNED) ||
			__pf.__hasFlag(__PrintFFlag__.SPACE_FOR_POSITIVE))
			throw new IllegalArgumentException("ZZ3t");
		
		// Get the long value of the given value, because it is limited to
		// the precision (byte:-2 becomes 0xFE)
		long input;
		if (__n instanceof Byte)
			input = __n.byteValue() & 0xFF;
		else if (__n instanceof Short)
			input = __n.shortValue() & 0xFFFF;
		else if (__n instanceof Integer)
			input = __n.intValue() & 0xFFFFFFFF;
		else
			input = __n.longValue();
		
		// Bit shift and mask used for the value
		int shift, mask;
		switch (__pf._conv)
		{
			case OCTAL_INTEGER:
				mask = 0x7;
				shift = 3;
				break;
			
			default:
			case HEXADECIMAL_INTEGER:
				mask = 0xF;
				shift = 4;
				break;
		}
		
		// Build the output number, constantly shift it until it is zero
		StringBuilder out = new StringBuilder();
		for (long rest = input; rest != 0; rest >>>= shift)
		{
			// Mask out the value
			int val = (int)(rest & mask);
			
			// Add the character for this digit
			out.append(Character.forDigit(val, __base));
		}
		
		// Pad the remaining space with zero
		if (__pf.__hasFlag(__PrintFFlag__.ZERO_PADDED))
			for (int i = out.length(), n = __pf.__width(); i < n; i++)
				out.append('0');
		
		// Place in the alternative form somewhere
		if (__pf.__hasFlag(__PrintFFlag__.ALTERNATIVE_FORM))
		{
			// The length of the string
			int len = out.length();
			
			// Hex
			if (__base == 16)
			{
				// If the last two characters are zero, set the one before
				// last to X
				if (len >= 2 && out.charAt(len - 1) == '0' &&
					out.charAt(len - 2) == '0')
					out.setCharAt(len - 2, 'x');
				
				// If the last character is zero, then make it x and append
				// zero
				else if (len >= 1 && out.charAt(len - 1) == '0')
				{
					out.setCharAt(len - 1, 'x');
					out.append('0');
				}
				
				// Otherwise append 0x (reversed)
				else
				{
					out.append('x');
					out.append('0');
				}
			}
			
			// Octal
			else if (__base == 8)
			{
				// If the last character is not zero, then add zero to the end
				if (len < 1 && out.charAt(len - 1) != '0')
					out.append('0');
			}
		}
		
		// Reverse string because it is in the other order
		out.reverse();
		
		// Use it
		return out.toString();
	}
	
	/**
	 * Outputs to the state to the appendable.
	 *
	 * @param __out The output appendable.
	 * @param __pf The standard state.
	 * @throws IllegalArgumentException If the format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/28
	 */
	private static void __output(Appendable __out, __PrintFState__ __pf)
		throws IllegalArgumentException, IOException, NullPointerException
	{
		if (__out == null || __pf == null)
			throw new NullPointerException("NARG");
			
		__PrintFConversion__ conv = __pf._conv;
		__PrintFCategory__ cat = conv.__category();
		
		// Depends on the conversion
		String append;
		switch (conv)
		{
				// Newline sequence
			case NEWLINE:
				append = Formatter._NEWLINE;
				break;
				
				// Boolean
			case BOOLEAN:
				append = __pf.<Boolean>__argument(Boolean.class,
					Boolean.FALSE).toString();
				break;
				
				// Single character
			case CHARACTER:
				Character cha = __pf.<Character>__argument(Character.class);
				append = (cha == null ? "null" : cha.toString());
				break;
				
				// Octal 
			case OCTAL_INTEGER:
				append = Formatter.__formatOtherUnsignedInt(__pf,
					__pf.<Number>__argument(Number.class), 8);
				break;
			
				// Decimal Integer
			case DECIMAL_INTEGER:
				append = Formatter.__formatDecimalInt(__pf,
					__pf.<Number>__argument(Number.class));
				break;
				
				// Hexadecimal Integer
			case HEXADECIMAL_INTEGER:
				append = Formatter.__formatOtherUnsignedInt(__pf,
					__pf.<Number>__argument(Number.class), 16);
				break;
			
				// Simple string conversion
			case STRING:
				append = __pf.<Object>__argument(Object.class, "null").
					toString();
				break;
			
				// {@squirreljme.error ZZ2n Unimplemented conversion.
				// (The conversion)}
			default:
				throw new todo.TODO("ZZ2n " + conv);
		}
		
		// Convert to uppercase
		if (__pf._upper)
			append = append.toUpperCase();
		
		// General items may be reduced by the precision, at most
		if (cat == __PrintFCategory__.GENERAL)
		{
			int precision = __pf._precision;
			if (precision >= 0)
				append = append.substring(0,
					Math.min(precision, append.length()));
		}
		
		// Width is either higher of the input width or the string length
		int strlen = append.length(),
			width = Math.max(strlen, __pf._width),
			padding = width - strlen;
		
		// Right justification spaces?
		boolean isleft = __pf.__isLeftJustified();
		if (!isleft)
			for (int i = 0; i < padding; i++)
				__out.append(' ');
		
		// Send the string in
		__out.append(append);
		
		// Left justification spaces?
		if (isleft)
			for (int i = 0; i < padding; i++)
				__out.append(' ');
	}
	
	/**
	 * Parses the specifier in the input format.
	 *
	 * This parses the following, just returning that information:
	 * {@code %[argument_index$][flags][width][.precision]conversion}.
	 *
	 * @param __pf The PrintF state.
	 * @param __base The base character index.
	 * @param __fmt The format specifiers.
	 * @return The index where the format specifier ends, this is so the
	 * calling loop can properly set its counter.
	 * @throws IllegalArgumentException If the format specifiers are not
	 * correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	private static int __specifier(__PrintFState__ __pf, int __base,
		String __fmt)
		throws IllegalArgumentException, NullPointerException
	{
		if (__pf == null || __fmt == null)
			throw new NullPointerException("NARG");
		
		// Length of the format
		int fmtlen = __fmt.length();
		
		// The specifier could be too short! So handle these cases and make
		// sure the exception of the right type
		int at = __base + 1;
		try
		{
			char c = __fmt.charAt(at);
			
			// The first might be a number specifying the argument index to use
			// Note that zero is NOT included because it would be parsed as
			// a flag, additionally argument indexes are 1-based!
			if (c >= '1' && c <= '9')
			{
				// Read the entire number
				int base = at;
				for (;;)
				{
					c = __fmt.charAt(at);
					if (c >= '0' && c <= '9')
						at++;
					else
						break;
				}
				
				// Parse value
				int val = Integer.valueOf(__fmt.substring(base, at));
				
				// If there is a dollar sign, this is going to be the
				// argument index
				if (__fmt.charAt(at) == '$')
				{
					__pf.__setArgumentIndex(val);
					
					// Skip the dollar
					at++;
				}
				
				// Otherwise this is the width
				else
					__pf.__setWidth(val);
			}
			
			// Parse flags, but only if no width was specified
			if (!__pf.__hasWidth())
				for (c = __fmt.charAt(at); __pf.__setFlag(c);
					at++, c = __fmt.charAt(at))
					;
			
			// Parse width
			c = __fmt.charAt(at);
			if (!__pf.__hasWidth() && c >= '1' && c <= '9')
			{
				// Read the entire number
				int base = at;
				for (;;)
				{
					c = __fmt.charAt(at);
					if (c >= '0' && c <= '9')
						at++;
					else
						break;
				}
				
				// Set width
				__pf.__setWidth(Integer.valueOf(__fmt.substring(base, at)));
			}
			
			// Parse precision
			c = __fmt.charAt(at);
			if (c == '.')
				throw new todo.TODO();
			
			// Parse the conversion
			c = __fmt.charAt(at);
			if (c == 't' || c == 'T')
			{
				__pf.__setConversion(c, __fmt.charAt(at + 1));
				at++; 
			}
			else
				__pf.__setConversion(c, -1);
			
			// Skip conversion character
			at++;
		}
		
		// {@squirreljme.error ZZ2o Could not parse the format specifier
		// properly. (The string with the specifier sequence)}
		catch (IndexOutOfBoundsException|NumberFormatException e)
		{
			throw new IllegalArgumentException("ZZ2o " +
				__fmt.substring(__base, Math.min(at, __fmt.length())), e);
		}
		
		// Return the new ending index, after everything was parsed
		return at;
	}
}

Added modules/cldc-compact/src/main/java/java/util/HashMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This is a hash table where keys are mapped to values.
 *
 * This class is not thread safe.
 *
 * If keys are added or removed during iteration then
 * {@link ConcurrentModificationException} will be thrown.
 *
 * @since 2018/10/07
 */
public class HashMap<K, V>
	extends AbstractMap<K, V>
	implements Map<K, V>, Cloneable
{
	/** Internal map. */
	final __BucketMap__<K, V> _map;
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/10/07
	 */
	public HashMap(int __cap, float __load)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			false, __cap, __load);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/10/07
	 */
	public HashMap(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			__cap);
	}
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @since 2018/10/07
	 */
	public HashMap()
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap));
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public HashMap(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the map
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __m.size()));
		
		// Put all entries
		this.putAll(__m);
	}
	
	/**
	 * Initializes the map with the given capacity and load factor in the
	 * given access order.
	 *
	 * This is an internal constructor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @param __ao Is access order used?
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	HashMap(int __cap, float __load, boolean __ao)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			__ao, __cap, __load);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * Returns a shallow copy of this map which just shares the same key and
	 * value mappings, the actual keys and values are not cloned.
	 *
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		try
		{
			// Create a new instance of this class to put into, since the class
			// is always of the same type
			Map<K, V> copy = (Map<K, V>)this.getClass().newInstance();
			
			// Copy all the elements over
			copy.putAll(this);
			
			return copy;
		}
		
		// Oops
		catch (IllegalAccessException|InstantiationException e)
		{
			// {@squirreljme.error ZZ2p Could not clone the map.}
			throw new RuntimeException("ZZ2p", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/26
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return null != this._map.getEntry(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public Set<Map.Entry<K, V>> entrySet()
	{
		return this._map.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public V get(Object __k)
	{
		__BucketMapEntry__<K, V> e = this._map.getEntry(__k);
		if (e == null)
			return null;
		return e.getValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public V put(K __k, V __v)
	{
		// Just operates on that key
		return this._map.putEntry(__k).setValue(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public V remove(Object __k)
	{
		return this._map.remove(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}


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

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public class HashSet<E>
	extends AbstractSet<E>
	implements Set<E>, Cloneable
{
	/** Internal map. */
	private final __BucketMap__<E, Object> _map;
	
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	public HashSet(int __cap, float __load)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet), false, __cap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/01
	 */
	public HashSet(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet), __cap);
	}
	
	/**
	 * Initializes the set with the default capacity and load factor.
	 *
	 * @since 2018/11/01
	 */
	public HashSet()
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet));
	}
	
	/**
	 * Initializes a set which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input set.
	 *
	 * @param __s The set to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public HashSet(Collection<? extends E> __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the set
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet),
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __s.size()));
		
		// Add all entries
		this.addAll(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public boolean add(E __v)
	{
		// The set has been modified only if the special taken value was
		// set to null (it will become non-null)
		__BucketMapEntry__<E, Object> e = this._map.putEntry(__v);
		return (e.setValue(__BucketMap__._TAKEN) == null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * Returns a shallow copy of this map which just shares the same key and
	 * value mappings, the actual keys and values are not cloned.
	 *
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		try
		{
			// Create a new instance of this class to put into, since the class
			// is always of the same type
			Set<E> copy = (Set<E>)this.getClass().newInstance();
			
			// Copy all the elements over
			copy.addAll(this);
			
			return copy;
		}
		
		// Oops
		catch (IllegalAccessException|InstantiationException e)
		{
			// {@squirreljme.error ZZ2q Could not clone the map.}
			throw new RuntimeException("ZZ2q", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public boolean contains(Object __v)
	{
		return null != this._map.getEntry(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public Iterator<E> iterator()
	{
		return this._map.keySet().iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public boolean remove(Object __v)
	{
		// Return true if there was an entry for this key
		__BucketMapEntry__<E, Object> rv = this._map.removeEntry(__v, false);
		return rv != null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

Added modules/cldc-compact/src/main/java/java/util/Hashtable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.IteratorToEnumeration;
import cc.squirreljme.runtime.cldc.util.SynchronizedEntrySetNotNull;

/**
 * This is similar to {@link HashMap} except that it is thread safe and does
 * not permit null keys or values.
 *
 * @since 2019/05/05
 */
public class Hashtable<K, V>
	implements Map<K, V>, Cloneable
{
	/** Internal map. */
	private final __BucketMap__<K, V> _map;
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/05
	 */
	public Hashtable(int __cap, float __load)
	{
		this._map = new __BucketMap__<K, V>(false, false, __cap, __load);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/05
	 */
	public Hashtable(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>(false, __cap);
	}
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @since 2019/05/05
	 */
	public Hashtable()
	{
		this._map = new __BucketMap__<K, V>(false);
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException If {@code __m} is null or it contains
	 * null keys or values.
	 * @since 2018/10/07
	 */
	public Hashtable(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the map
		this._map = new __BucketMap__<K, V>(false,
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __m.size()));
		
		// Put all entries
		this.putAll(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void clear()
	{
		synchronized (this)
		{
			this._map.clear();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		synchronized (this)
		{
			try
			{
				// Create a new instance of this class to put into, since the
				// class is always of the same type
				Map<K, V> copy = (Map<K, V>)this.getClass().newInstance();
				
				// Copy all the elements over
				copy.putAll(this);
				
				return copy;
			}
			
			// Oops
			catch (IllegalAccessException|InstantiationException e)
			{
				// {@squirreljme.error ZZ2r Could not clone the hashtable.}
				throw new RuntimeException("ZZ2r", e);
			}
		}
	}
	
	/**
	 * Checks if the map contains the specified value.
	 *
	 * @param __v The value to check.
	 * @return If the map contains the value or not.
	 * @since 2019/05/05
	 */
	public boolean contains(Object __v)
	{
		synchronized (this)
		{
			return this.values().contains(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		synchronized (this)
		{
			return null != this._map.getEntry(__k);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean containsValue(Object __v)
	{
		synchronized (this)
		{
			return this.values().contains(__v);
		}
	}
	
	/**
	 * Returns an enumeration over the elements.
	 *
	 * @return The enumerator over the elements.
	 * @since 2019/05/05
	 */
	public Enumeration<V> elements()
	{
		synchronized (this)
		{
			return new IteratorToEnumeration<V>(this.values().iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public Set<Map.Entry<K, V>> entrySet()
	{
		synchronized (this)
		{
			return new SynchronizedEntrySetNotNull<K, V>(this,
				this._map.entrySet());
		}
	}
	
	@Override
	public boolean equals(Object __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If the requested key is null.
	 * @since 2019/05/05
	 */
	@Override
	public V get(Object __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			__BucketMapEntry__<K, V> e = this._map.getEntry(__k);
			if (e == null)
				return null;
			return e.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public int hashCode()
	{
		synchronized (this)
		{
			int rv = 0;
			for (Map.Entry<K, V> e : this.entrySet())
				rv += e.hashCode();
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean isEmpty()
	{
		synchronized (this)
		{
			return this._map.isEmpty();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public Set<K> keySet()
	{
		return new __AbstractMapKeySet__<K, V>(this);
	}
	
	/**
	 * Returns an enumeration over the keys.
	 *
	 * @return The key enumeration.
	 * @since 2019/05/05
	 */
	public Enumeration<K> keys()
	{
		synchronized (this)
		{
			return new IteratorToEnumeration<K>(this.keySet().iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If the key or value is null.
	 * @since 2019/05/05
	 */
	@Override
	public V put(K __k, V __v)
		throws NullPointerException
	{
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		__BucketMap__<K, V> map = this._map;
		synchronized (this)
		{
			// To detect rehashing
			int numrehash = map._numrehash;
			
			// Set value, remember old one
			V rv = this._map.putEntry(__k).setValue(__v);
			
			// If the map was ever rehashed, then call this method
			if (map._numrehash != numrehash)
				this.rehash();
			
			// Done
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void putAll(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// Copy everything
			for (Map.Entry<? extends K, ? extends V> e : __m.entrySet())
				this.put(e.getKey(), e.getValue());
		}
	}
	
	/**
	 * This reorganizes and reorders the entries internally in the hash map,
	 * this is called automatically when the map has been reordered.
	 *
	 * @since 2019/05/05
	 */
	@ImplementationNote("In SquirrelJME this has no actual effect because " +
		"it is internally handled, however code might rely on overriding " +
		"this method to determine when the map has been rehashed.")
	protected void rehash()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If a null key was specified.
	 * @since 2019/05/05
	 */
	@Override
	public V remove(Object __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		__BucketMap__<K, V> map = this._map;
		synchronized (this)
		{
			// To detect rehashing
			int numrehash = map._numrehash;
			
			// Remove key
			V rv = this._map.remove(__k);
			
			// If the map was ever rehashed, then call this method
			if (map._numrehash != numrehash)
				this.rehash();
			
			// Done
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public int size()
	{
		synchronized (this)
		{
			return this._map.size();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public String toString()
	{
		synchronized (this)
		{
			StringBuilder sb = new StringBuilder("{");
			
			// Go through and append
			boolean comma = false;
			for (Map.Entry<?, ?> e : this.entrySet())
			{
				// Space comma
				if (comma)
					sb.append(", ");
				comma = true;
				
				// Key is equal to the value
				sb.append(e.getKey());
				sb.append('=');
				sb.append(e.getValue());
			}
			
			sb.append('}');
			return sb.toString();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public Collection<V> values()
	{
		return new __AbstractMapValues__<K, V>(this);
	}
}

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

package java.util;

/**
 * This provides support for linear iteration through unspecified elements.
 *
 * Generally, {@link Iterator}s are not meant to be shared across threads.
 *
 * This class should be used instead of {@link Enumeration}.
 *
 * @param <E> The element to iterate over.
 * @see Iterable
 * @since 2016/04/12
 */
public interface Iterator<E>
{
	/**
	 * Returns {@code true} if there are more elements in the iteration
	 * sequence.
	 *
	 * @return {@code true} if more elements are available, otherwise
	 * {@code false}.
	 * @since 2016/04/12
	 */
	boolean hasNext();
	
	/**
	 * Returns the next element in the iteration or throws an exception if
	 * there are none remaining.
	 *
	 * @return The next element in the iteration.
	 * @throws NoSuchElementException If no more elements are available.
	 * @since 2016/04/12
	 */
	E next()
		throws NoSuchElementException;
	
	/**
	 * This removes the last element which was returned by {@link #next()}. If
	 * removal is supported then it may only be performed once per call to
	 * {@link #next()}.
	 *
	 * @throws IllegalStateException If the object returned by {@code #next()}
	 * was already removed or said method was never called.
	 * @throws UnsupportedOperationException If removal of elements is not
	 * supported by this iteration.
	 * @since 2016/04/12
	 */
	void remove()
		throws IllegalStateException, UnsupportedOperationException;
}

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

package java.util;

/**
 * This is a map which is backed by a hash table except that the iterator
 * order is in the order of which elements were added first.
 *
 * Otherwise this class is exactly the same as {@link HashMap}.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @see HashMap
 * @since 2019/05/09
 */
public class LinkedHashMap<K, V>
	extends HashMap<K, V>
	implements Map<K, V>
{
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __cap, float __load)
		throws IllegalArgumentException
	{
		super(__cap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __initcap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __initcap)
		throws IllegalArgumentException
	{
		super(__initcap);
	}
	
	/**
	 * Initializes an empty map.
	 *
	 * @since 2019/05/09
	 */
	public LinkedHashMap()
	{
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		super(__m);
	}
	
	/**
	 * Initializes the set with the given capacity and load factor, but the
	 * may be ordered based on what is first accessed.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @param __ao If the iterator should always return the same order for
	 * accesses.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __cap, float __load, boolean __ao)
	{
		super(__cap, __load, __ao);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public V put(K __k, V __v)
	{
		__BucketMap__<K, V> map = this._map;
		
		// Put entry into the map and store the old value
		__BucketMapEntry__<K, V> entry = map.putEntry(__k);
		V rv = entry.setValue(__v);
		
		// Remove the eldest entry (which is the oldest/first item in the map)
		__BucketMapEntry__<K, V> eldest = map._links.peekFirst();
		if (eldest != null && this.removeEldestEntry(eldest))
			map.removeEntry(eldest.getKey(), false);
		
		// Return the former value
		return rv;
	}
	
	/**
	 * After a {@code put} or {@code putAll} operation this will be called with
	 * the eldest entry to determine if it should be removed or not. This may
	 * be used for cache purposes.
	 *
	 * The default implementation returns {@code false}.
	 *
	 * If the implementation of this method modifies the map then this should
	 * always return {@code null}.
	 *
	 * @param __e The entry being
	 * @return If the map was modified.
	 * @since 2019/05/09
	 */
	protected boolean removeEldestEntry(Map.Entry<K, V> __e)
	{
		return false;
	}
}

Added modules/cldc-compact/src/main/java/java/util/LinkedHashSet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a set which is backed by a hash table except that the iterator
 * order is in the order of which elements were added first.
 *
 * Otherwise this class is exactly the same as {@link HashSet}.
 *
 * @param <E> The element type to store.
 * @see HashSet
 * @since 2018/11/01
 */
public class LinkedHashSet<E>
	extends HashSet<E>
	implements Set<E>, Cloneable
{
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __initcap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	public LinkedHashSet(int __initcap, float __load)
		throws IllegalArgumentException
	{
		super(__initcap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __initcap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/01
	 */
	public LinkedHashSet(int __initcap)
		throws IllegalArgumentException
	{
		super(__initcap);
	}
	
	/**
	 * Initializes the set with the default capacity and load factor.
	 *
	 * @since 2018/11/01
	 */
	public LinkedHashSet()
	{
	}
	
	/**
	 * Initializes a set which is a copy of the other set.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input set.
	 *
	 * @param __s The set to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public LinkedHashSet(Collection<? extends E> __s)
	{
		super(__s);
	}
}

Added modules/cldc-compact/src/main/java/java/util/LinkedList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * A linked list is a list of items which are held together using chains. Each
 * value for an element is placed within a chain link which is then held to
 * other links in the chain. This is a doubly linked list.
 *
 * This class has efficient insertion and removal via the iterator interfaces.
 *
 * Random access is not efficient and the further away the element is from the
 * initial sequence the more elements will need to be skipped to access the
 * data.
 *
 * This class is not thread safe.
 *
 * @param <E> The type of element to store.
 * @since 2016/09/05
 */
@ImplementationNote("For simplicity this uses base anchor nodes for the " +
	"head and tail of the list.")
public class LinkedList<E>
	extends AbstractSequentialList<E>
	implements List<E>, Deque<E>, Cloneable
{
	/** The list head. */
	final __Link__<E> _head =
		new __Link__<E>(null, null, null);
	
	/** The list tail, this gets linked into the head. */
	final __Link__<E> _tail =
		new __Link__<E>(this._head, null, null);
		
	/** The number of entries in the list. */
	int _size;
	
	/**
	 * Initializes a linked list with no entries.
	 *
	 * @since 2016/09/05
	 */
	public LinkedList()
	{
	}
	
	/**
	 * Initializes a linked list which contains a copy of all of the elements
	 * of the other collection in its iterator order.
	 *
	 * @param __a The collection to copy elements from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/05
	 */
	public LinkedList(Collection<? extends E> __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Just call addAll
		this.addAll(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void addFirst(E __v)
	{
		this.add(0, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void addLast(E __v)
	{
		this.add(this._size, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		// Since there are anchor entries used for the linked list we can just
		// set the anchor points to each other
		__Link__<E> head = this._head,
			tail = this._tail;
		head._next = tail;
		tail._prev = head;
		
		// Clear size
		this._size = 0;
		
		// List was modified
		LinkedList.this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public Object clone()
	{
		return new LinkedList<>(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public Iterator<E> descendingIterator()
	{
		return new __DescendingIteratorViaListIterator__<E>(
			new __LinkedListListIterator__<E>(this, this._size));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E element()
		throws NoSuchElementException
	{
		return this.getFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E getFirst()
		throws NoSuchElementException
	{
		// {@squirreljme.error ZZ2s Cannot get the first element because the
		// linked list is empty.}
		if (this._size == 0)
			throw new NoSuchElementException("ZZ2s");
		
		// One forward from the head
		return this._head._next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E getLast()
	{
		// {@squirreljme.error ZZ2t Cannot get the last element because the
		// linked list is empty.}
		int sz;
		if ((sz = this._size) == 0)
			throw new NoSuchElementException("ZZ2t");
		
		// Just one back from the tail
		return this._tail._prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public ListIterator<E> listIterator(int __i)
	{
		return new __LinkedListListIterator__<E>(this, __i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean offer(E __v)
	{
		return this.offerLast(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean offerFirst(E __v)
	{
		// There are no capacity restrictions
		this.add(0, __v);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public boolean offerLast(E __v)
	{
		// There are no capacity restrictions
		this.add(this._size, __v);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peek()
	{
		return this.peekFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peekFirst()
	{
		// Return null on empty list
		if (this._size == 0)
			return null;
		
		// One forward from the head
		return this._head._next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peekLast()
	{
		// Return null if the list is empty
		int sz;
		if ((sz = this._size) == 0)
			return null;
		
		// Just one back from the tail
		return this._tail._prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E poll()
	{
		return this.pollFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pollFirst()
	{
		if (this._size == 0)
			return null;
		
		ListIterator<E> it = this.listIterator(0);
		
		// Remove the first element
		E rv = it.next();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pollLast()
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(this._size);
		
		// Remove the last element
		E rv = it.previous();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pop()
	{
		return this.removeFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void push(E __v)
	{
		this.addFirst(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E remove()
	{
		return this.removeFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E removeFirst()
		throws NoSuchElementException
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(0);
		
		// Remove the first element
		E rv = it.next();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean removeFirstOccurrence(Object __a)
	{
		// Start at the start of the list and remove the first match
		Iterator<E> rover = this.iterator();
		while (rover.hasNext())
		{
			E v = rover.next();
			
			// If this is the same object then remove it
			if (Objects.equals(v, __a))
			{
				rover.remove();
				return true;
			}
		}
		
		// Nothing was removed
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E removeLast()
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(this._size);
		
		// Remove the last element
		E rv = it.previous();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean removeLastOccurrence(Object __a)
	{
		// Start at the end of the list and remove the first match
		ListIterator<E> rover = this.listIterator(this._size);
		while (rover.hasPrevious())
		{
			E v = rover.previous();
			
			// If this is the same object then remove it
			if (Objects.equals(v, __a))
			{
				rover.remove();
				return true;
			}
		}
		
		// Nothing was removed
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public int size()
	{
		return this._size;
	}
}

Added modules/cldc-compact/src/main/java/java/util/List.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface List<E>
	extends Collection<E>
{
	boolean add(E __a);
	
	void add(int __a, E __b);
	
	boolean addAll(Collection<? extends E> __a);
	
	boolean addAll(int __a, Collection<? extends E> __b);
	
	void clear();
	
	boolean contains(Object __a);
	
	boolean containsAll(Collection<?> __a);
	
	@Override
	boolean equals(Object __a);
	
	/**
	 * Gets the value at the specified index.
	 *
	 * @param __i The index to get.
	 * @return The value at this index.
	 * @throws IndexOutOfBoundsException If the index it out of bounds for the
	 * list.
	 * @since 2018/12/07
	 */
	E get(int __i)
		throws IndexOutOfBoundsException;
	
	@Override
	int hashCode();
	
	int indexOf(Object __a);
	
	boolean isEmpty();
	
	Iterator<E> iterator();
	
	int lastIndexOf(Object __a);
	
	ListIterator<E> listIterator();
	
	ListIterator<E> listIterator(int __a);
	
	boolean remove(Object __a);
	
	E remove(int __a);
	
	boolean removeAll(Collection<?> __a);
	
	boolean retainAll(Collection<?> __a);
	
	E set(int __a, E __b);
	
	int size();
	
	List<E> subList(int __a, int __b);
	
	Object[] toArray();
	
	<T> T[] toArray(T[] __a);
}

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

package java.util;

public interface ListIterator<E>
	extends Iterator<E>
{
	void add(E __v);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	boolean hasNext();
	
	boolean hasPrevious();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	E next();
	
	int nextIndex();
	
	E previous();
	
	int previousIndex();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	void remove();
	
	void set(E __v);
}

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

package java.util;

public interface Map<K, V>
{
	void clear();
	
	boolean containsKey(Object __a);
	
	boolean containsValue(Object __a);
	
	Set<Map.Entry<K, V>> entrySet();
	
	@Override
	boolean equals(Object __a);
	
	V get(Object __a);
	
	@Override
	int hashCode();
	
	boolean isEmpty();
	
	Set<K> keySet();
	
	V put(K __a, V __b);
	
	void putAll(Map<? extends K, ? extends V> __a);
	
	V remove(Object __a);
	
	int size();
	
	Collection<V> values();
	
	interface Entry<K, V>
	{
		@Override
		boolean equals(Object __a);
		
		K getKey();
		
		V getValue();
		
		@Override
		int hashCode();
		
		V setValue(V __a);
	}
}

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

package java.util;

/**
 * This is thrown when no element exists, usually from an {@link Iterator}.
 *
 * @since 2018/10/29
 */
public class NoSuchElementException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/29
	 */
	public NoSuchElementException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/29
	 */
	public NoSuchElementException(String __m)
	{
		super(__m);
	}
}

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

package java.util;

/**
 * This class provides utility methods which are usually able to handle null
 * values.
 *
 * @since 2016/04/12
 */
public final class Objects
{
	/**
	 * Should not be called at all.
	 *
	 * @since 2016/04/12
	 */
	private Objects()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * This compares two values and possibly may compare it with the given
	 * {@link Comparator}. First, if the input objects are identical (in that
	 * {@code __a == __b} is performed) then {@code 0} is returned. Otherwise,
	 * the values are passed to the specified {@link Comparator}.
	 *
	 * A {@link NullPointerException} may be thrown by the comparator.
	 *
	 * @param <T> The type of value to compare.
	 * @param __a The first value.
	 * @param __b The second value.
	 * @param __c The comparator to use.
	 * @return {@code 0} if {@code __a == __b}, otherwise the value returned
	 * from the {@link Comparator}.
	 * @throws NullPointerException If the objects are not the same object
	 * reference and there is no {@link Comparator}. May also be thrown if the
	 * comparator is unable to handle {@code null} arguments.
	 * @since 2016/04/12
	 */
	public static <T> int compare(T __a, T __b, Comparator<? super T> __c)
		throws NullPointerException
	{
		// The same object?
		if (__a == __b)
			return 0;
		
		// Compare otherwise
		if (__c == null)
			throw new NullPointerException("NARG");
		return __c.compare(__a, __b);
	}
	
	/**
	 * Checks whether two objects are equal to each other, if one of the
	 * values is {@code null} then this returns {@code false}, otherwise
	 * equality is checked. If both values are {@code null} then {@code true}
	 * is returned.
	 *
	 * @param __a The object which gets {@link Object#equals(Object)} called.
	 * @param __b The parameter to that call.
	 * @return {@code true} if they are both equal or both {@code null}.
	 * @since 2016/04/12
	 */
	public static boolean equals(Object __a, Object __b)
	{
		// Same instance or both are null
		if (__a == __b)
			return true;
		
		// Left side is null and right is not, so not the same
		else if (__a == null)
			return false;
		
		// Use standard comparison
		return __a.equals(__b);
	}
	
	/**
	 * Returns the hash code of the given object or {@code 0} if it is
	 * {@code null}.
	 *
	 * @param __a The object to get the hashcode of.
	 * @return The object's hash code or {@code 0} if it is {@code null}.
	 * @since 2016/04/12
	 */
	public static int hashCode(Object __a)
	{
		if (__a == null)
			return 0;
		return __a.hashCode();
	}
	
	/**
	 * Checks whether the given input value is not {@code null} and then
	 * returns it, otherwise this throws {@link NullPointerException}.
	 *
	 * @param <T> The type of value to return.
	 * @param __a The value to return.
	 * @return {@code __a}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/12
	 */
	public static <T> T requireNonNull(T __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		return __a;
	}
	
	/**
	 * Checks whether the given input value is not {@code null} and then
	 * returns it, otherwise this throws a {@link NullPointerException} with
	 * the given message.
	 *
	 * @param <T> The type of value to return.
	 * @param __a The value to return.
	 * @param __m The exception message.
	 * @return {@code __a}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/12
	 */
	public static <T> T requireNonNull(T __a, String __m)
	{
		// Check
		if (__a == null)
			throw new NullPointerException((__m != null ? __m : "NARG"));
		return __a;
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code "null"} is returned.
	 *
	 * @param __a The value to get the string of.
	 * @return The string of the given value or {@code "null"} if the input is
	 * {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a)
	{
		if (__a == null)
			return "null";
		return __a.toString();
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code __b} is returned.
	 *
	 * @param __a The object to get the string of.
	 * @param __b The value to return if {@code __a} is {@code null}.
	 * @return The string represention of {@code __a} or else {@code __b} if
	 * the input is {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a, String __b)
	{
		if (__a == null)
			return __b;
		return __a.toString();
	}
}

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

package java.util;

import java.security.BasicPermission;
import java.security.Permission;
import java.security.PermissionCollection;

/**
 * This permission is used to specify access to a system property.
 *
 * Property names come in two formats: A fully specified string which matches
 * the key, or if it ends in asterisk {@code '*'} it will be a wildcard match
 * at the base string. Note that only the last character is considered if this
 * is a wildcard match.
 *
 * The following permissions are available:
 * {@code "read"} -- Read access to the property.
 * {@code "write"} -- Write access to the property.
 *
 * Multiple permissions may be specified, separated by comma.
 *
 * @since 2018/09/18
 */
public final class PropertyPermission
	extends BasicPermission
{
	/** The key to check or the prefix if a wildcard. */
	private final String _key;
	
	/** If this is a wildcard permission. */
	private final boolean _iswildcard;
	
	/** Is this read permission? */
	private final boolean _isread;
	
	/** Is this write permission? */
	private final boolean _iswrite;
	
	/**
	 * Initializes the permission.
	 *
	 * @param __key The key to check.
	 * @param __act The action on the key.
	 * @throws IllegalArgumentException If the action is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public PropertyPermission(String __key, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		super(__key, __act);
		
		if (__key == null || __act == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2x Property permission key cannot be
		// negative.}
		if (__key.isEmpty())
			throw new IllegalArgumentException("ZZ2x");
		
		// Setup key first
		this._key = __key;
		this._iswildcard = (__key.charAt(__key.length() - 1) == '*');
		
		// Convert action to lowercase first
		__act = __act.toLowerCase();
		
		// This field is split with commas and may contain read or write
		boolean r = false,
			w = false;
		for (int i = 0, n = __act.length(); i < n;)
		{
			// Find the next comma, if there is none use the end of string
			int dx = __act.indexOf(',', i);
			if (dx < 0)
				dx = n;
			
			// Determine which action to take
			String sub;
			switch ((sub = __act.substring(i, dx)))
			{
				case "read":
					r = true;
					break;
				
				case "write":
					w = true;
					break;
				
					// {@squirreljme.error ZZ2y The specified action is not
					// valid for property permissions. (The action; The input
					// actions)}
				default:
					throw new IllegalArgumentException(
						String.format("ZZ2y %s %s", sub, __act));
			}
			
			// Remember to skip the comma, if there is one
			i = dx + 1;
		}
		
		// Read or writing?
		this._isread = r;
		this._iswrite = w;
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}

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

package java.util;

public interface Queue<E>
	extends Collection<E>
{
	boolean add(E __a);
	
	E element();
	
	boolean offer(E __a);
	
	E peek();
	
	E poll();
	
	E remove();
}

Added modules/cldc-compact/src/main/java/java/util/Random.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.FDMLMath;

/**
 * This is an insecure pseudo-random number generator.
 *
 * This class is thread safe however if multiple threads are using a single
 * instance then it is undefined if their order is the same.
 *
 * @since 2018/11/02
 */
@ImplementationNote("This code essentially is a copy and paste from the " +
	"library documentation since it must always be the same exact code. " +
	"Since there is only one way to implement this class it should be " +
	"legal to do so for compatibility purposes.")
public class Random
{
	/** The current seed value. */
	private long _seed;
	
	/** The next gaussian value. */
	private double _nextg;
	
	/** Has next next gaussian value? */
	private boolean _hasnng;
	
	/**
	 * Initializes the random number generator using an unspecified and
	 * potentially different key per construction.
	 *
	 * @since 2018/11/02
	 */
	public Random()
	{
		this(System.currentTimeMillis() +
			System.nanoTime());
	}
	
	/**
	 * Initializes the random number generator with the given seed.
	 *
	 * @param __seed The seed to initialize with.
	 * @since 2018/11/02
	 */
	public Random(long __seed)
	{
		this.setSeed(__seed);
	}
	
	/**
	 * Generates the next pseudorandom number, this method is used by every
	 * other method in this class. As such this is the only method that has
	 * to be changed if the internal algorithm is to be changed.
	 *
	 * @param __bits The number of bits to return.
	 * @return The produced value.
	 * @since 2018/11/02
	 */
	protected int next(int __bits)
	{
		// This has to be atomic
		synchronized (this)
		{
			// Update the seed
			long seed = (this._seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
			this._seed = seed;
			
			return (int)(seed >>> (48 - __bits));
		}
	}
	
	/**
	 * Returns the next boolean value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public boolean nextBoolean()
	{
		return this.next(1) != 0;
	}
	
	/**
	 * Generates random bytes and places them into the array.
	 *
	 * @param __a The output array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/02
	 */
	public void nextBytes(byte[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, l = __a.length; i < l;)
			for (int r = this.nextInt(), n = Math.min(l - i, 4); n-- > 0;
				r >>= 8)
				__a[i++] = (byte)r;
	}
	
	/**
	 * Returns the next double value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public double nextDouble()
	{
		return (((long)this.next(26) << 27) + this.next(27)) /
			(double)(1L << 53);
	}
	
	/**
	 * Returns the next float value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public float nextFloat()
	{
		return this.next(24) / ((float)(1 << 24));
	}
	
	/**
	 * Return the next gaussian value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public double nextGaussian()
	{
		synchronized (this)
		{
			// If there was already a cached value, use it
			boolean hasnng = this._hasnng;
			if (hasnng)
			{
				this._hasnng = false;
				return this._nextg;
			}
			
			// Otherwise generate it
			else
			{
				double v1, v2, s;
				do
				{
					// Between -1.0 and 1.0
					v1 = 2 * this.nextDouble() - 1;
					v2 = 2 * this.nextDouble() - 1;

					s = v1 * v1 + v2 * v2;
				} while (s >= 1 || s == 0);
				
				double multiplier =
					FDMLMath.sqrt(-2 * FDMLMath.log(s) / s);
				
				// Store for next time
				this._nextg = v2 * multiplier;
				this._hasnng = true;
				
				// Return generated value
				return v1 * multiplier;
			}
		}
	}
	
	/**
	 * Returns the next int value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public int nextInt()
	{
		return this.next(32);
	}
	
	/**
	 * Returns the next int value between inclusive 0 and exclusive
	 * {@code __cap}.
	 *
	 * @param __cap The exclusive value to end at.
	 * @return The next value.
	 * @throws IllegalArgumentException If the cap is zero or negative.
	 * @since 2018/11/02
	 */
	public int nextInt(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ2z Cap value must be a positive integer}
		if (__cap <= 0)
			throw new IllegalArgumentException("ZZ2z");
		
		// Cap is a power of two
		if ((__cap & -__cap) == __cap)
			return (int)((__cap * (long)this.next(31)) >> 31);
		
		// Otherwise calculate based on values in the range
		int bits, val;
		do
		{
			bits = this.next(31);
			val = bits % __cap;
		} while (bits - val + (__cap - 1) < 0);
		
		return val;
	}
	
	/**
	 * Returns the next long value.
	 *
	 * @return The next long value.
	 * @since 2018/11/02
	 */
	public long nextLong()
	{
		return ((long)this.next(32) << 32) + this.next(32);
	}
	
	/**
	 * Sets the seed for this random number generator.
	 *
	 * This is an atomic operation.
	 *
	 * @param __seed The seed to use.
	 * @since 2018/11/02
	 */
	public void setSeed(long __seed)
	{
		synchronized (this)
		{
			this._seed = (__seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
			this._hasnng = false;
		}
	}
}


Added modules/cldc-compact/src/main/java/java/util/RandomAccess.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a collection which may be randomly accessed without
 * additional cost.
 *
 * @since 2018/12/08
 */
public interface RandomAccess
{
}

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

package java.util;

/**
 * This is thrown when a service has not been configured properly.
 *
 * @since 2018/12/06
 */
public class ServiceConfigurationError
	extends Error
{
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/06
	 */
	public ServiceConfigurationError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with a message and the given cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause of this error.
	 * @since 2018/12/06
	 */
	public ServiceConfigurationError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
}

Added modules/cldc-compact/src/main/java/java/util/ServiceLoader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * The service loader is used to lookup services which may be defined in the
 * classpath.
 *
 * Services are stored as a list of class in resources within the JAR, these
 * services lists are declared in files specifying the class name. So the
 * format is {@code META-INF/services/fully.qualified.class.name}.
 *
 * The iterator may throw {@code ServiceConfigurationError}.
 *
 * @param <S> The class to provide a service for.
 * @since 2018/12/06
 */
public final class ServiceLoader<S>
	implements Iterable<S>
{
	/** The class to search for. */
	private final Class<S> _search;
	
	/** The service cache. */
	private final __Cache__<S> _cache =
		new __Cache__<S>();
	
	/**
	 * Initializes the service loader.
	 *
	 * @param __cl The class to search.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/06
	 */
	private ServiceLoader(Class<S> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this._search = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public Iterator<S> iterator()
	{
		Class<S> search = this._search;
		__Cache__<S> cache = this._cache;
		
		// Use the cached array?
		Object[] use = cache._cache;
		if (use != null)
			return new __CachedIterator__<S>(search, use);
		
		// Cache it
		else
			return new __FreshIterator__<S>(search, cache);
	}
	
	/**
	 * Clears the cache of services.
	 *
	 * @since 2018/12/06
	 */
	public void reload()
	{
		// Clear the cache
		this._cache._cache = null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		// Just matches what Java SE gives
		return "java.util.ServiceLoader[" + this._search.getName() + "]";
	}
	
	/**
	 * Create a service loader for the given class.
	 *
	 * @param <S> The class to handle services for.
	 * @param __cl The class to load a service for.
	 * @return The service loader for this class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/06
	 */
	public static <S> ServiceLoader<S> load(Class<S> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return new ServiceLoader<S>(__cl);
	}
	
	/**
	 * Cache for the service loader.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __Cache__<S>
	{
		/** The cache of services. */
		volatile Object[] _cache;
	}
	
	/**
	 * Iterator over the cached set.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __CachedIterator__<S>
		implements Iterator<S>
	{
		/** The search class. */
		private final Class<S> _search;
		
		/** The array to use for this. */
		private final Object[] _items;
		
		/** The next index. */
		private int _next;
		
		/**
		 * Wraps the given array and provides an iterator of it.
		 *
		 * @param __s The search class.
		 * @param __it The iterator to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/12/06
		 */
		__CachedIterator__(Class<S> __s, Object[] __it)
			throws NullPointerException
		{
			if (__s == null || __it == null)
				throw new NullPointerException("NARG");
			
			this._search = __s;
			this._items = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final boolean hasNext()
		{
			return this._next < this._items.length;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final S next()
		{
			Object[] items = this._items;
			int next = this._next;
			
			// No more?
			if (next >= items.length)
				throw new NoSuchElementException("NSEE");
			
			// Get and iterator
			Object rv = items[next];
			this._next = next + 1;
			return this._search.cast(rv);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * Iterator over a fresh search pouring into the cache.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __FreshIterator__<S>
		implements Iterator<S>
	{
		/** The search class. */
		private final Class<S> _search;
		
		/** The cache to put in. */
		private final __Cache__<S> _cache;
		
		/** Temporary cache building. */
		private final List<Object> _cachebuild =
			new ArrayList<>();
		
		/** Suites left to parse. */
		private final Queue<String> _suites =
			new LinkedList<>();
		
		/** Classes left to create and scan. */
		private final Queue<String> _classes =
			new LinkedList<>();
		
		/** The next service to run. */
		private S _next;
		
		/** Is this finished? */
		private boolean _finished;
		
		/**
		 * Initializes the iterator for fresh service lookup.
		 *
		 * @param __s The search class.
		 * @param __c The cache class.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/12/06
		 */
		__FreshIterator__(Class<S> __s, __Cache__<S> __c)
			throws NullPointerException
		{
			if (__s == null || __c == null)
				throw new NullPointerException("NARG");
			
			this._search = __s;
			this._cache = __c;
			
			// Seed suites left with the
			Queue<String> suites = this._suites;
			for (String s : SuiteAccess.currentClassPath())
				suites.add(s);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final boolean hasNext()
		{
			// If already finished, nothing can be done
			if (this._finished)
				return false;
			
			// Already cached?
			if (this._next != null)
				return true;
			
			Queue<String> suites = this._suites;
			Queue<String> classes = this._classes;
			
			// Loops until an element was found
			for (;;)
			{
				// If there is an entry in the class list, try to load that
				// class
				String maybe = classes.poll();
				if (maybe != null)
				{
					// Try to load this class
					try
					{
						// If this fails an exception is thrown
						Class<?> cl = Class.forName(maybe);
						
						// Try to create a new instance since this is new,
						// any exceptions thrown cause errors
						Object rv = cl.newInstance();
						
						// Cache this instance for later
						this._cachebuild.add(rv);
						
						// Cast this class
						this._next = this._search.cast(rv);
						return true;
					}
					
					// {@squirreljme.error ZZ30 Could not load the service
					// class.}
					catch (ClassCastException|IllegalAccessException|
						InstantiationException|ClassNotFoundException e)
					{
						throw new ServiceConfigurationError("ZZ30", e);
					}
				}
				
				// Nothing is in the classes, so we need to pull a suite
				// resource
				String pull = suites.poll();
				if (pull == null)
				{
					// Mark as finished
					this._finished = true;
					
					// Store in the cache for later since it is all done
					// now
					List<Object> cb = this._cachebuild;
					this._cache._cache = cb.<Object>toArray(
						new Object[cb.size()]);
					
					// Clear from this iterator
					cb.clear();
					
					// Nothing else to do
					return false;
				}
				
				// Could services list
				else
				{
					// Load resources
					try (InputStream in = ResourceInputStream.open(pull,
						"META-INF/services/" + this._search.getName()))
					{
						// Ignore unknown resources
						if (in == null)
							continue;
						
						// Read by line
						Set<String> pushy = new LinkedHashSet<>();
						try (BufferedReader br = new BufferedReader(
							new InputStreamReader(in, "utf-8")))
						{
							for (;;)
							{
								// Stop on EOF
								String ln = br.readLine();
								if (ln == null)
									break;
								
								// Trim the line
								ln = ln.trim();
								
								// Ignore blank lines
								if (ln.isEmpty())
									continue;
								
								// Ignore comments
								if (ln.startsWith("#"))
									continue;
								
								// Add otherwise
								pushy.add(ln);
							}
						}
						
						// Add unique entries
						for (String ln : pushy)
							classes.add(ln);
					}
					
					// {@squirreljme.error ZZ31 Could not read the services
					// list}
					catch (IOException e)
					{
						throw new ServiceConfigurationError("ZZ31", e);
					}
				}
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final S next()
		{
			// Cache
			if (!this.hasNext())
				throw new NoSuchElementException("NSEE");
			
			// Return the cached element
			S rv = this._next;
			this._next = null;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

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

package java.util;

public interface Set<E>
	extends Collection<E>
{
	@Override
	boolean add(E __a);
	
	@Override
	boolean addAll(Collection<? extends E> __a);
	
	@Override
	void clear();
	
	@Override
	boolean contains(Object __a);
	
	@Override
	boolean containsAll(Collection<?> __a);
	
	@Override
	boolean equals(Object __a);
	
	@Override
	int hashCode();
	
	@Override
	boolean isEmpty();
	
	@Override
	Iterator<E> iterator();
	
	@Override
	boolean remove(Object __a);
	
	@Override
	boolean removeAll(Collection<?> __a);
	
	@Override
	boolean retainAll(Collection<?> __a);
	
	@Override
	int size();
	
	@Override
	Object[] toArray();
	
	@Override
	<T> T[] toArray(T[] __a);
}


Added modules/cldc-compact/src/main/java/java/util/Stack.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;

/**
 * This is a last-in-first-out, this uses {@link Vector} as a base and provides
 * operations for pushing and popping.
 *
 * It is recommended to use {@link LinkedList} or {@link ArrayDeque} as they
 * are newer classes.
 *
 * @since 2019/05/08
 */
public class Stack<E>
	extends Vector<E>
{
	public boolean empty()
	{
		throw new todo.TODO();
	}
	
	public E peek()
	{
		throw new todo.TODO();
	}
	
	public E pop()
	{
		throw new todo.TODO();
	}
	
	public E push(E __item)
	{
		throw new todo.TODO();
	}
	
	public int search(Object __o)
	{
		throw new todo.TODO();
	}
}

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

package java.util;

public class StringTokenizer
	implements Enumeration<Object>
{
	public StringTokenizer(String __a, String __b, boolean __c)
	{
		throw new todo.TODO();
	}
	
	public StringTokenizer(String __a, String __b)
	{
		throw new todo.TODO();
	}
	
	public StringTokenizer(String __a)
	{
		throw new todo.TODO();
	}
	
	public int countTokens()
	{
		throw new todo.TODO();
	}
	
	public boolean hasMoreElements()
	{
		throw new todo.TODO();
	}
	
	public boolean hasMoreTokens()
	{
		throw new todo.TODO();
	}
	
	public Object nextElement()
	{
		throw new todo.TODO();
	}
	
	public String nextToken()
	{
		throw new todo.TODO();
	}
	
	public String nextToken(String __a)
	{
		throw new todo.TODO();
	}
}

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

package java.util;

public abstract class TimeZone
	implements Cloneable
{
	public static final int LONG =
		1;
	
	public static final int SHORT =
		0;
	
	public TimeZone()
	{
		throw new todo.TODO();
	}
	
	public abstract int getOffset(int __a, int __b, int __c, int __d, int __e
		, int __f);
	
	public abstract int getRawOffset();
	
	public abstract boolean inDaylightTime(Date __a);
	
	public abstract void setRawOffset(int __a);
	
	public abstract boolean useDaylightTime();
	
	@Override
	public Object clone()
	{
		throw new todo.TODO();
	}
	
	public int getDSTSavings()
	{
		throw new todo.TODO();
	}
	
	public final String getDisplayName()
	{
		throw new todo.TODO();
	}
	
	public final String getDisplayName(boolean __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public String getID()
	{
		throw new todo.TODO();
	}
	
	public int getOffset(long __a)
	{
		throw new todo.TODO();
	}
	
	public boolean hasSameRules(TimeZone __a)
	{
		throw new todo.TODO();
	}
	
	public void setID(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] getAvailableIDs(int __a)
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static String[] getAvailableIDs()
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static TimeZone getDefault()
	{
		throw new todo.TODO();
	}
	
	public static TimeZone getTimeZone(String __a)
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static void setDefault(TimeZone __a)
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/Timer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * The timer class is used to schedule events for the future which may
 * repeatedly happen or may happen once.
 *
 * This class is thread safe and multiple threads may interact with this
 * class.
 *
 * This class is not real-time and offers no gaurantee that tasks will execute
 * on time.
 *
 * All instances of this class create a background thread.
 *
 * @since 2018/12/11
 */
public class Timer
{
	/** The thread which runs the task of running things. */
	final __TimerThread__ _thread;
	
	/**
	 * Initializes a timer.
	 *
	 * @since 2018/12/11
	 */
	public Timer()
	{
		this("TimerThread");
	}
	
	/**
	 * Initializes a timer with a thread using the given name.
	 *
	 * @param __s The name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public Timer(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Setup thread and start it
		__TimerThread__ thread;
		this._thread = (thread = new __TimerThread__(__s));
		thread.start();
	}
	
	/**
	 * Cancels the timer and all of its events.
	 *
	 * @since 2018/12/11
	 */
	public void cancel()
	{
		__TimerThread__ thread = this._thread;
		synchronized (thread)
		{
			// Cancel and interrupt the thread so it checks and wakes up
			if (!thread._cancel)
			{
				thread._cancel = true;
				thread.interrupt();
			}
		}
	}
	
	/**
	 * Purges all of the cancelled tasks so that they become garbage collected.
	 *
	 * @since 2018/12/11
	 */
	public void purge()
	{
		// Lock to prevent adds
		__TimerThread__ thread = this._thread;
		synchronized (thread)
		{
			// Remove every task which has been cancelled
			for (Iterator<TimerTask> it = thread._tasks.iterator();
				it.hasNext();)
				if (it.next()._cancel)
					it.remove();
		}
	}
	
	/**
	 * Schedules a task to run once at the given time.
	 *
	 * @param __task The task to run.
	 * @param __time The time when the task should run.
	 * @throws IllegalArgumentException If the date is negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, Date __time)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __time, false, false, 0);
	}
	
	/**
	 * Schedules a task to run multiple times starting at the given date and
	 * executing every period.
	 *
	 * @param __task The task to run.
	 * @param __time The time when the task should run.
	 * @param __period The duration of time between each invocation.
	 * @throws IllegalArgumentException If the date is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, Date __time, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __time, true, false, __period);
	}
	
	/**
	 * Schedules a task to run once at the given time.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @throws IllegalArgumentException If the delay is negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, long __delay)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, false, false, 0);
	}
	
	/**
	 * Schedules a task to run once at the given time repeating for the given
	 * period.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @param __period The delay before each subsequence execution.
	 * @throws IllegalArgumentException If the delay is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, long __delay, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, true, false, __period);
	}
	
	/**
	 * Schedules a task to run multiple times starting at the given date and
	 * executing every period, the tasks are scheduled again at the start of
	 * each execution rather than the end.
	 *
	 * @param __task The task to run.
	 * @param __first The time when the task should run.
	 * @param __period The duration of time between each invocation.
	 * @throws IllegalArgumentException If the date is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void scheduleAtFixedRate(TimerTask __task, Date __first,
		long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __first, true, true,
			__period);
	}
	
	/**
	 * Schedules a task to run once at the given time repeating for the given
	 * period, execution is scheduled from the start of execution.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @param __period The delay before each subsequence execution.
	 * @throws IllegalArgumentException If the delay is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void scheduleAtFixedRate(TimerTask __task, long __delay,
		long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, true, true, __period);
	}
}

Added modules/cldc-compact/src/main/java/java/util/TimerTask.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a tasks which can be run within a timer.
 *
 * @since 2018/12/11
 */
public abstract class TimerTask
	implements Runnable
{
	/** Indicates the task has been cancelled. */
	volatile boolean _cancel;
	
	/** The scheduled time for the task, undefined at first. */
	volatile long _schedtime =
		Long.MIN_VALUE;
	
	/** The last run time. */
	volatile long _lastrun =
		Long.MIN_VALUE;
	
	/** Is this being run? */
	volatile boolean _inrun;
	
	/** Was this scheduled? */
	volatile boolean _scheduled;
	
	/** Is this a repeated execution? */
	volatile boolean _repeated;
	
	/** Fixed repeat? */
	volatile boolean _fixed;
	
	/** The period. */
	volatile long _period;
	
	/**
	 * Initializes the base timer task.
	 *
	 * @since 2018/12/11
	 */
	protected TimerTask()
	{
	}
	
	/**
	 * Cancels this task so that it no longer runs.
	 *
	 * @return This will return true if a future execution was canceled.
	 * @since 2018/12/11
	 */
	public boolean cancel()
	{
		// Was already canceled
		if (this._cancel)
			return false;
		
		this._cancel = true;
		return this._repeated || this._scheduled;
	}
	
	/**
	 * Returns the scheduled execution time.
	 *
	 * If this task has not been scheduled, this value is undefined.
	 *
	 * @return The scheduled execution time.
	 * @since 2018/12/11
	 */
	public long scheduledExcutionTime()
	{
		if (this._inrun)
			return this._lastrun;
		return this._schedtime;
	}
}

Added modules/cldc-compact/src/main/java/java/util/Vector.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.util.IteratorToEnumeration;
import cc.squirreljme.runtime.cldc.util.SynchronizedIterator;

/**
 * This is similar to {@link ArrayList} except that it is synchronized and
 * thread-safe by default.
 *
 * @see ArrayList
 * @since 2019/05/13
 */
public class Vector<E>
	extends AbstractList<E>
	implements RandomAccess, Cloneable
{
	/** The number of elements to add if the size is too small. */
	protected int capacityIncrement;
	
	/** The number of elements in the vector. */
	protected int elementCount;
	
	/** The elements in the vector. */
	protected Object[] elementData;
	
	/**
	 * Initializes the vector using the specified initial capacity.
	 *
	 * @param __cap The initial capacity.
	 * @param __inc The capacity increment.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/13
	 */
	public Vector(int __cap, int __inc)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ32 Initial capacity cannot be negative.
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ32");
		
		this.elementData = new Object[__cap];
		this.capacityIncrement = (__inc < 0 ? 0 : __inc);
	}
	
	/**
	 * Initializes the vector using the specified initial capacity.
	 *
	 * @param __cap The initial capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/13
	 */
	public Vector(int __cap)
		throws IllegalArgumentException
	{
		this(__cap, 0);
	}
	
	/**
	 * Initializes the vector.
	 *
	 * @since 2019/05/13
	 */
	public Vector()
	{
		this(10, 0);
	}
	
	public Vector(Collection<? extends E> __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public void add(int __i, E __v)
	{
		synchronized (this)
		{
			int size = this.elementCount;
			if (__i < 0 || __i > size)
				throw new IndexOutOfBoundsException("IOOB");
			
			Object[] elements = this.elementData;
			int cap = elements.length,
				nextsize = size + 1;
			
			// Cannot fit in this array
			Object[] source = elements;
			if (nextsize > cap)
			{
				// Grow the list by a bit
				int newcap = nextsize + Math.max(1, this.capacityIncrement);
				elements = new Object[newcap];
				
				// Copy old stuff over, but only up to the index as needed
				for (int i = 0; i < __i; i++)
					elements[i] = source[i];
			}
			
			// Move down to fit
			for (int i = size - 1, o = size; o > __i; i--, o--)
				elements[o] = source[i];
			
			// Store data here
			elements[__i] = __v;
			
			// Store new information
			this.elementCount = nextsize;
			if (elements != source)
				this.elementData = elements;
			
			// Structurally modified
			this.modCount++;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public boolean addAll(Collection<? extends E> __c)
	{
		synchronized (this)
		{
			return super.addAll(__c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
	{
		synchronized (this)
		{
			return super.addAll(__i, __c);
		}
	}
	
	/**
	 * Adds an element to the end of the vector.
	 *
	 * @param __v The element to add.
	 * @since 2019/05/14
	 */
	public void addElement(E __v)
	{
		synchronized (this)
		{
			this.add(__v);
		}
	}
	
	public int capacity()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public void clear()
	{
		synchronized (this)
		{
			// Wipe the length
			this.elementCount = 0;
			
			// And wipe the array
			Object[] elements = this.elementData;
			for (int i = 0, n = elements.length; i < n; i++)
				elements[i] = null;
		}
	}
	
	@Override
	public Object clone()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	@Override
	public boolean contains(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsAll(Collection<?> __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Copies this vector to the given array.
	 *
	 * @param __a The target array.
	 * @throws ArrayStoreException If the array cannot store the vector
	 * values.
	 * @throws IndexOutOfBoundsException If the array is too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/24
	 */
	public void copyInto(Object[] __a)
		throws ArrayStoreException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// {@squirreljme.error ZZ3q The destination array is too small.}
			int n = this.elementCount;
			if (n > __a.length)
				throw new IndexOutOfBoundsException("ZZ3q");
			
			// Copy into
			Object[] elements = this.elementData;
			for (int i = 0; i < n; i++)
				__a[i] = elements[i];
		}
	}
	
	/**
	 * Returns the element at the given index.
	 *
	 * @param __i The element index.
	 * @return The element.
	 * @since 2019/05/14
	 */
	public E elementAt(int __i)
	{
		synchronized (this)
		{
			return this.get(__i);
		}
	}
	
	/**
	 * Returns an enumeration over the elements.
	 *
	 * @return The element enumeration.
	 * @since 2019/05/14
	 */
	public Enumeration<E> elements()
	{
		return new IteratorToEnumeration<E>(this.iterator());
	}
	
	/**
	 * Ensures that the vector can store the given number of elements.
	 *
	 * @param __n The element capacity.
	 * @since 2019/05/14
	 */
	public void ensureCapacity(int __n)
	{
		synchronized (this)
		{
			// Pointless
			if (__n <= 0)
				return;
			
			// Meets or exceeds the desired capacity?
			Object[] elements = this.elementData;
			int nowl = elements.length;
			if (__n <= nowl)
				return;
			
			// Copy values over
			Object[] extra = new Object[__n];
			for (int i = 0; i < nowl; i++)
				extra[i] = elements[i];
			
			// Set
			this.elementData = extra;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean equals(Object __o)
	{
		synchronized (this)
		{
			return super.equals(__o);
		}
	}
	
	/**
	 * Returns the first element in the vector.
	 *
	 * @return The first element.
	 * @throws NoSuchElementException If the vector is empty.
	 * @since 2019/05/14
	 */
	@SuppressWarnings({"unchecked"})
	public E firstElement()
		throws NoSuchElementException
	{
		synchronized (this)
		{
			if (this.elementCount <= 0)
				throw new NoSuchElementException("NSEE");
			
			return (E)this.elementData[0];
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E get(int __i)
	{
		synchronized (this)
		{
			if (__i < 0 || __i >= this.elementCount)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			return (E)this.elementData[__i];
		}
	}
	
	@Override
	public int hashCode()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public int indexOf(Object __v)
	{
		synchronized (this)
		{
			return super.indexOf(__v);
		}
	}
	
	public int indexOf(Object __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public void insertElementAt(E __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public Iterator<E> iterator()
	{
		synchronized (this)
		{
			return new SynchronizedIterator<E>(this, super.iterator());
		}
	}
	
	public E lastElement()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	@Override
	public int lastIndexOf(Object __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public int lastIndexOf(Object __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean remove(Object __v)
	{
		synchronized (this)
		{
			return super.remove(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E remove(int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			// Out of bounds?
			int size = this.elementCount;
			if (__i < 0 || __i >= size)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			// Get the old element first
			Object[] elements = this.elementData;
			Object rv = elements[__i];
			
			// Copy all of the elements down
			for (int o = __i, i = __i + 1; i < size; o++, i++)
				elements[o] = elements[i];
			elements[size - 1] = null;
			
			// Set new size
			this.elementCount = size - 1;
			
			// And the old element
			return (E)rv;
		}
	}
	
	@Override
	public boolean removeAll(Collection<?> __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Removes all elements in the vector.
	 *
	 * @since 2019/05/14
	 */
	public void removeAllElements()
	{
		synchronized (this)
		{
			this.clear();
		}
	}
	
	/**
	 * Removes the given value from the list.
	 *
	 * @param __v The value to remove.
	 * @return If it was removed.
	 * @since 2019/05/19
	 */
	public boolean removeElement(Object __v)
	{
		synchronized (this)
		{
			return this.remove(__v);
		}
	}
	
	/**
	 * Removes the element at the given index.
	 *
	 * @param __i The index to remove.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/19
	 */
	public void removeElementAt(int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			this.remove(__i);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	protected void removeRange(int __a, int __b)
	{
		synchronized (this)
		{
			super.removeRange(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean retainAll(Collection<?> __c)
	{
		synchronized (this)
		{
			return super.retainAll(__c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E set(int __i, E __v)
	{
		synchronized (this)
		{
			// Out of bounds?
			int size = this.elementCount;
			if (__i < 0 || __i >= size)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			// Read old value
			Object[] elements = this.elementData;
			E rv = (E)elements[__i];
			
			// Set new value
			elements[__i] = __v;
			
			// Return old
			return rv;
		}
	}
	
	/**
	 * Sets the element at the given index, note that compared to
	 * {@link #set(int, Object)} the parameters are reversed.
	 *
	 * @param __v The value to set.
	 * @param __i The index to set.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/14
	 */
	public void setElementAt(E __v, int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			this.set(__i, __v);
		}
	}
	
	/**
	 * Sets the size of this vector so that it has the given number of
	 * elements.
	 *
	 * @param __n The number of elements the vector should be.
	 * @throws ArrayIndexOutOfBoundsException If the size is negative.
	 * @since 2019/05/14
	 */
	public void setSize(int __n)
		throws ArrayIndexOutOfBoundsException
	{
		if (__n < 0)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			// Ensure elements can fit first
			this.ensureCapacity(__n);
			
			// Null out any extra elements
			int count = this.elementCount;
			Object[] elements = this.elementData;
			for (int i = count; i < __n; i++)
				elements[i] = null;
			
			// Set new count
			this.elementCount = __n;
			
			// Modified
			this.modCount++;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public int size()
	{
		synchronized (this)
		{
			return this.elementCount;
		}
	}
	
	@Override
	public List<E> subList(int __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public void trimToSize()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
}

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

package java.util;

import java.lang.ref.ReferenceQueue;

public class WeakHashMap<K, V>
	extends AbstractMap<K, V>
	implements Map<K, V>
{
	/** The default capacity. */
	private static final int _DEFAULT_CAPACITY =
		16;
	
	/** The default load factor. */
	private static final float _DEFAULT_LOAD =
		0.75F;
	
	/** The load factor. */
	private final float _load;
	
	/** This is used to clear keys when they are collected. */
	private final ReferenceQueue<K> _rq =
		new ReferenceQueue<>();
	
	/**
	 * Initializes the weak hash map with the given initial capacity and load
	 * factor.
	 *
	 * @param __icap The initial capacity.
	 * @param __load The initial load factor.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2016/04/19
	 */
	public WeakHashMap(int __icap, float __load)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ33 The initial capacity of the weak
		// hash map is negative. (The negative initial capacity)}
		if (__icap < 0)
			throw new IllegalArgumentException(String.format("ZZ33 %d",
				__icap));
		
		// {@squirreljme.error ZZ34 The load factor of the weak hash map is
		// not positive. (The non-positive load factor)}
		if (__load <= 0.0F)
			throw new IllegalArgumentException(String.format("ZZ34 %f",
				__load));
		
		// Setup
		this._load = __load;
	}
	
	/**
	 * Initializes the weak hash map with the given initial capacity.
	 *
	 * @param __icap The initial weak hash map capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2016/04/19
	 */
	public WeakHashMap(int __icap)
		throws IllegalArgumentException
	{
		this(__icap, WeakHashMap._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the weak hash map with the default initial capacity and load
	 * factor.
	 *
	 * @since 2016/04/19
	 */
	public WeakHashMap()
	{
		this(WeakHashMap._DEFAULT_CAPACITY, WeakHashMap._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the weak hash map with the default initial capacity and load
	 * factor and then copies the keys and values of the given map to this one.
	 *
	 * @param __a The map to source entries from.
	 * @throws NullPointerException If no map was specified.
	 * @since 2016/04/19
	 */
	public WeakHashMap(Map<? extends K, ? extends V> __a)
	{
		// {@squirreljme.error ZZ35 No map to copy data from was specified.}
		if (__a == null)
			throw new NullPointerException("ZZ35");
		
		// Setup initial map
		this._load = WeakHashMap._DEFAULT_LOAD;
		
		// Add all entries to it
		for (Map.Entry<? extends K, ? extends V> e : __a.entrySet())
			this.put(e.getKey(), e.getValue());
	}
	
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsKey(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsValue(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		throw new todo.TODO();
	}
	
	@Override
	public V get(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Set<K> keySet()
	{
		throw new todo.TODO();
	}
	
	@Override
	public V put(K __a, V __b)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void putAll(Map<? extends K, ? extends V> __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public V remove(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public int size()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Collection<V> values()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc-compact/src/main/java/java/util/__AbstractListListIterator__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;

/**
 * List iterator which can go forwards and backwards through this abstract
 * list. Indexed elements are used here, not sequential lists.
 *
 * @param <E> The element type.
 * @since 2018/10/28
 */
final class __AbstractListListIterator__<E>
	implements ListIterator<E>
{
	/** The owning list. */
	protected final AbstractList<E> owner;
	
	/** The next element to be returned. */
	private int _next;
	
	/** The current modification count, to detect modifications. */
	private int _atmod;
	
	/** The index to be removed. */
	private int _rmdx =
		-1;
	
	/**
	 * Initializes the list iterator.
	 *
	 * @param __owner The owner of this list.
	 * @param __i The index to use.
	 * @throws IndexOutOfBoundsException If the index is outside the list
	 * bounds.
	 * @since 2018/10/28
	 */
	__AbstractListListIterator__(AbstractList<E> __owner, int __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__owner == null)
			throw new NullPointerException("NARG");
		
		if (__i < 0 || __i > __owner.size())
			throw new IndexOutOfBoundsException("IOOB");
		
		this.owner = __owner;
		this._next = __i;
		this._atmod = __owner.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void add(E __a)
	{
		// Check modification
		this.__checkConcurrent();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final boolean hasNext()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There are elements as long as the next one is below the size
		return this._next < this.owner.size();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final boolean hasPrevious()
	{
		// Check modification
		this.__checkConcurrent();
		
		// As long as this is not the first element there will be
		// previous ones
		return this._next > 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E next()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// End of list?
		int next = this._next;
		if (this._next >= this.owner.size())
			throw new NoSuchElementException("NSEE");
		
		// Get this element
		E rv = this.owner.get(next);
		
		// Next one is after this, also the element to be removed is set
		// by this method
		this._rmdx = next;
		this._next = next + 1;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int nextIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		return this._next;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E previous()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// End of list?
		int next = this._next;
		if (this._next <= 0)
			throw new NoSuchElementException("NSEE");
		
		// Get this element
		int eldx = next - 1;
		E rv = this.owner.get(eldx);
		
		// The element to remove is the one we just got and the next one
		// is one down the list
		this._rmdx = eldx;
		this._next = eldx;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int previousIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// If next is zero then this would be -1
		return this._next - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void remove()
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2c No previously returned element was
		// iterated, it was already removed, or an element was added.}
		int rmdx = this._rmdx;
		if (rmdx < 0)
			throw new IllegalStateException("ZZ2c");
		
		// Remove this index
		this._rmdx = -1;
		this.owner.remove(rmdx);
		
		// Next element would be moved down
		int next = this._next;
		if (next > rmdx)
			this._next = next - 1;
		
		// Set new modification count
		this._atmod = this.owner.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(E __v)
	{
		// Check modification
		this.__checkConcurrent();
		
		throw new todo.TODO();
	}
	
	/**
	 * Checks if the list was concurrently modified.
	 *
	 * @throws ConcurrentModificationException If it was modified.
	 * @since 2018/10/29
	 */
	private final void __checkConcurrent()
		throws ConcurrentModificationException
	{
		// {@squirreljme.error ZZ2d List has been concurrently modified.}
		if (this._atmod != this.owner.modCount)
			throw new ConcurrentModificationException("ZZ2d");
	}
}

Added modules/cldc-compact/src/main/java/java/util/__AbstractListSubList__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;

/**
 * This is a sub-list of an abstract list
 *
 * @param <E> The type of value being stored
 * @since 2019/11/30
 */
final class __AbstractListSubList__<E>
	extends AbstractList<E>
{
	/**
	 * Initializes the abstract sub-list.
	 *
	 * @param __list The list to wrap.
	 * @param __from The index to start from.
	 * @param __to The index to end at.
	 * @throws IllegalArgumentException If the end point is before the start.
	 * @throws IndexOutOfBoundsException If the from is negative or the to
	 * exceeds the list size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	__AbstractListSubList__(AbstractList<E> __list, int __from, int __to)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__list == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3r End point is before starting point.}
		if (__from > __to)
			throw new IllegalArgumentException("ZZ3r");
		
		// Check bounds
		int size = this.size();
		if (__from < 0 || __to > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
	
	@Override
	public final void add(int __a, E __b)
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E get(int __i)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E set(int __i, E __v)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E remove(int __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
}

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

package java.util;

/**
 * This is the key set for an abstract map.
 *
 * @param <K> The key type.
 * @param <V> The value stored.
 * @since 2018/10/10
 */
final class __AbstractMapKeySet__<K, V>
	extends AbstractSet<K>
{
	/** The backing map. */
	protected final Map<K, V> map;
	
	/**
	 * Initializes the set.
	 *
	 * @param __map The backing map
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/01
	 */
	__AbstractMapKeySet__(Map<K, V> __map)
		throws NullPointerException
	{
		if (__map == null)
			throw new NullPointerException("NARG");
		
		this.map = __map;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final boolean contains(Object __o)
	{
		return this.map.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public final Iterator<K> iterator()
	{
		return new __Iterator__<K, V>(this.map.entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public final int size()
	{
		return this.map.size();
	}
	
	/**
	 * This is the iterator over the map's key set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2018/11/01
	 */
	static final class __Iterator__<K, V>
		implements Iterator<K>
	{
		/** The entry set iterator. */
		protected final Iterator<Map.Entry<K, V>> iterator;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __it The backing iterator.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/01
		 */
		__Iterator__(Iterator<Map.Entry<K, V>> __it)
			throws NullPointerException
		{
			if (__it == null)
				throw new NullPointerException("NARG");
			
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public K next()
			throws NoSuchElementException
		{
			return this.iterator.next().getKey();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public void remove()
		{
			this.iterator.remove();
		}
	}
}

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

package java.util;

/**
 * This is the value set for an abstract map.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/29
 */
final class __AbstractMapValues__<K, V>
	extends AbstractCollection<V>
{
	/** The backing map. */
	protected final Map<K, V> map;
	
	/**
	 * Initializes the set.
	 *
	 * @param __map The backing map
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/01
	 */
	__AbstractMapValues__(Map<K, V> __map)
		throws NullPointerException
	{
		if (__map == null)
			throw new NullPointerException("NARG");
		
		this.map = __map;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final boolean contains(Object __o)
	{
		return this.map.containsValue(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/19
	 */
	@Override
	public final Iterator<V> iterator()
	{
		return new __Iterator__<K, V>(this.map.entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/19
	 */
	@Override
	public final int size()
	{
		return this.map.size();
	}
	
	/**
	 * This is the iterator over the map's value set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2018/11/01
	 */
	static final class __Iterator__<K, V>
		implements Iterator<V>
	{
		/** The entry set iterator. */
		protected final Iterator<Map.Entry<K, V>> iterator;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __it The backing iterator.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/01
		 */
		__Iterator__(Iterator<Map.Entry<K, V>> __it)
			throws NullPointerException
		{
			if (__it == null)
				throw new NullPointerException("NARG");
			
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public V next()
			throws NoSuchElementException
		{
			return this.iterator.next().getValue();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public void remove()
		{
			this.iterator.remove();
		}
	}
}

Added modules/cldc-compact/src/main/java/java/util/__ArraysList__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This wraps the given array as a list for {@link Arrays#asList(Object[])}.
 *
 * @since 2016/08/31
 */
final class __ArraysList__<T>
	extends AbstractList<T>
	implements RandomAccess
{
	/** The array length. */
	protected final int length;
	
	/** The wrapped array. */
	private final T[] _wrapped;
	
	/**
	 * Initializes the wrapped array.
	 *
	 * @param __v The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/31
	 */
	__ArraysList__(T[] __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._wrapped = __v;
		this.length = __v.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public T get(int __i)
	{
		return this._wrapped[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public T set(int __i, T __v)
	{
		T[] wrapped = this._wrapped;
		T rv = wrapped[__i];
		wrapped[__i] = __v;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public int size()
	{
		return this.length;
	}
}

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

package java.util;

/**
 * This class provides the block sort algorithm used to sort items.
 *
 * https://en.wikipedia.org/wiki/Block_sort
 *
 * @since 2018/10/26
 */
final class __BlockSort__
{
	/**
	 * Sorts the given list using block sort.
	 *
	 * @param <T> The type to use.
	 * @param __a The list to sort.
	 * @param __from From index.
	 * @param __to To index.
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/16
	 */
	public static <T> void sort(List<T> __a, int __from, int __to,
		Comparator<? super T> __comp)
		throws NullPointerException
	{
		if (__a == null || __comp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

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

package java.util;

/**
 * This represents a single entry within the bucket map.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/07
 */
final class __BucketMapEntry__<K, V>
	implements Map.Entry<K, V>
{
	/** The key. */
	final K _key;
	
	/** The key hashcode. */
	final int _keyhash;
	
	/** The value here. */
	V _value;		
	
	/**
	 * Initializes the entry.
	 *
	 * @param __k The key.
	 * @since 2018/10/08
	 */
	__BucketMapEntry__(K __k)
	{
		this._key = __k;
		this._keyhash = (__k == null ? 0 : __k.hashCode());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Map.Entry))
			return false;
		
		Map.Entry<?, ?> o = (Map.Entry<?, ?>)__o;
		return Objects.equals(this._key, o.getKey()) &&
			Objects.equals(this._value, o.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final K getKey()
	{
		return this._key;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final V getValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final int hashCode()
	{
		V value = this._value;
		return this._keyhash ^ (value == null ? 0 : value.hashCode());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final V setValue(V __v)
	{
		V rv = this._value;
		this._value = __v;
		return rv;
	}
}

Added modules/cldc-compact/src/main/java/java/util/__BucketMap__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a bucket map which acts as the raw internal hash table
 * implementation.
 *
 * @see HashMap
 * @see HashSet
 * @see LinkedHashMap
 * @see LinkedHashSet
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/07
 */
final class __BucketMap__<K, V>
	extends AbstractMap<K, V>
{
	/** Special holder for when backing for a set. */
	static final Object _TAKEN =
		new Object();
	
	/** The default capacity. */
	static final int _DEFAULT_CAPACITY =
		16;
	
	/** The default load factor. */
	static final float _DEFAULT_LOAD =
		0.75F;
	
	/** Is this bucket map ordered? */
	protected final boolean ordered;
	
	/** Is this bucket map in accessed order? */
	protected final boolean accessorder;
	
	/** Track put order? */
	protected final boolean trackputorder;
	
	/** The load factor. */
	protected final float loadfactor;
	
	/** Linked order of entries. */
	final LinkedList<__BucketMapEntry__<K, V>> _links;
	
	/** The entry chains for each element. */
	__BucketMapEntry__<K, V>[][] _buckets;
	
	/** The hashcode divisor for buckets. */
	int _bucketdiv;
	
	/** The number of elements in the map. */
	int _size;
	
	/** The current capacity. */
	int _capacity;
	
	/** The size threshold before a rebuild is done. */
	int _loadthreshold;
	
	/** Modification count. */
	int _modcount;
	
	/** The rehash count. */
	int _numrehash;
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o)
	{
		this(__o, false, __BucketMap__._DEFAULT_CAPACITY,
			__BucketMap__._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o, int __cap)
	{
		this(__o, false, __cap, __BucketMap__._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @param __ao Is access order used additionally?
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o, boolean __ao, int __cap, float __load)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ36 The initial capacity of the map cannot be
		// negative.}
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ36");
		
		// {@squirreljme.error ZZ37 The load factor must be a positive value.}
		if (__load <= 0.0F)
			throw new IllegalArgumentException("ZZ37");
		
		this.ordered = __o;
		this.accessorder = (__ao = (__o && __ao));
		this.trackputorder = (__o && !__ao);
		this.loadfactor = __load;
		this._buckets = __BucketMap__.<K, V>__newBucket(__cap);
		this._bucketdiv = __cap;
		this._capacity = __cap;
		this._loadthreshold = (int)(__cap * __load);
		
		// Set linked list for ordered storage if it is used
		this._links = ((__o || __ao) ?
			new LinkedList<__BucketMapEntry__<K, V>>() : null);
	}
	
	/**
	 * Gets the entry for the given key.
	 *
	 * @param __k The key to get.
	 * @return The entry for the given or {@code null} if none exists.
	 * @since 2018/10/08
	 */
	public final __BucketMapEntry__<K, V> getEntry(Object __k)
	{
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % this._bucketdiv;
		
		// If the chain does not exist then do not bother at all
		__BucketMapEntry__<K, V>[] chain = this._buckets[div];
		if (chain == null)
			return null;
		
		// Go through the chain and find the matching entry
		for (__BucketMapEntry__<K, V> e : chain)
		{
			// Ignore blank entries
			if (e == null)
				continue;
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found
			if (Objects.equals(e._key, __k))
			{
				// In access order?
				if (this.accessorder)
					throw new todo.TODO();	
				
				return e;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final Set<Map.Entry<K, V>> entrySet()
	{
		return new __EntrySet__();
	}
	
	/**
	 * Returns the chain that the hashed object is within for the bucket.
	 *
	 * @param __k The key.
	 * @return The key for the given entry.
	 * @since 2018/10/07
	 */
	public final __BucketMapEntry__<K, V> putEntry(K __k)
	{
		__BucketMapEntry__<K, V>[][] buckets = this._buckets;
		int bucketdiv = this._bucketdiv;
		
		// Used to determine if we rebuild
		int size = this._size,
			nextsize = size + 1;
		
		// Hypothetically putting a new entry could cause the threshold to be
		// hit, so just in this case a new entry would be put so rebuild
		// the hash table. The buckets need to remain the same object
		// references for iteration.
		if (nextsize >= this._loadthreshold)
		{
			// Increase rehash count
			this._numrehash++;
			
			// Double the number of buckets
			int newbucketdiv = (bucketdiv * 2);
			__BucketMapEntry__<K, V>[][] newbuckets =
				__BucketMap__.<K, V>__newBucket(newbucketdiv);
			
			// Go through every source bucket and redistribute entries
			for (int i = 0; i < bucketdiv; i++)
			{
				// Ignore empty chains
				__BucketMapEntry__<K, V>[] chain = buckets[i];
				if (chain == null)
					continue;
				
				// Go through chain and re-add entries, we do not need to
				// worry about object equality since if something is in the
				// map it is already unique!
				for (__BucketMapEntry__<K, V> e : chain)
				{
					// Was an entry which was removed, ignore
					if (e == null)
						continue;
					
					// Determine the new placement for it
					int hash = e._keyhash,
						div = (hash & 0x7FFF_FFFF) % newbucketdiv;
					
					// Get the new chain for it
					__BucketMapEntry__<K, V>[] newchain = newbuckets[div];
					if (newchain == null)
						newchain = __BucketMap__.<K, V>__newChain(1);
					else
					{
						// Need to setup new chain
						int cn = newchain.length;
						__BucketMapEntry__<K, V>[] newnewchain =
							__BucketMap__.<K, V>__newChain(cn + 1);
						
						// Copy all the old chain stuff over
						for (int j = 0; j < cn; j++)
							newnewchain[j] = newchain[j];
						
						// Use this chain
						newchain = newnewchain;
					}
					
					// Store entry in the last spot
					newchain[newchain.length - 1] = e;
					
					// New chain was created so update it naturally
					newbuckets[div] = newchain;
				}
			}
			
			// Map was modified, in case hashCode() fails!
			this._modcount++;
			
			// Store new data for later
			this._buckets = newbuckets;
			this._bucketdiv = newbucketdiv;
			this._capacity = newbucketdiv;
			this._loadthreshold = (int)(newbucketdiv * this.loadfactor);
			
			// Use these new properties and continue on
			buckets = newbuckets;
			bucketdiv = newbucketdiv;
		}
		
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % bucketdiv;
		
		// This will be set depending on the situation
		__BucketMapEntry__<K, V> rv;
		
		// No entries exist in the chain, we can just create one
		__BucketMapEntry__<K, V>[] chain = buckets[div];
		if (chain == null)
		{
			// Setup chain
			chain = __BucketMap__.<K, V>__newChain(1);
			buckets[div] = chain;
			
			// Fill
			chain[0] = (rv = new __BucketMapEntry__<K, V>(__k));
			
			// Add to order?
			if (this.trackputorder)
				this._links.add(rv);
			
			// Map is modified
			this._modcount++;
			
			// Size would have been increased at this point
			this._size = nextsize;
			
			return rv;
		}
		
		// Go through and find if there was a pre-existing item
		int nulldx = -1,
			n = chain.length;
		for (int i = 0; i < n; i++)
		{
			__BucketMapEntry__<K, V> e = chain[i];
			
			// If no entry is here remember this blank spot in the event
			// nothing is ever found
			if (e == null)
			{
				if (nulldx < 0)
					nulldx = i;
				continue;
			}
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found
			if (Objects.equals(__k, e._key))
				return e;
		}
		
		// Found a blank spot, we can just put the entry here
		if (nulldx >= 0)
			chain[nulldx] = (rv = new __BucketMapEntry__<K, V>(__k));
		
		// Otherwise, increase the chain and use that instead
		else
		{
			// Copy the old chain over
			__BucketMapEntry__<K, V>[] dup =
				__BucketMap__.<K, V>__newChain(n + 1);
			for (int i = 0; i < n; i++)
				dup[i] = chain[i];
			
			// Set at end
			dup[n] = (rv = new __BucketMapEntry__<K, V>(__k));
			
			// Use this chain again
			buckets[div] = dup;
		}
		
		// Map has been modified
		this._modcount++;
		
		// Add to order?
		if (this.trackputorder)
			this._links.add(rv);
		
		// Size would have been increased at this point
		this._size = nextsize;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public final V remove(Object __k)
	{
		__BucketMapEntry__<K, V> rv = this.removeEntry(__k, false);
		if (rv != null)
			return rv._value;
		return null;
	}
	
	/**
	 * Removes the specified key from this map.
	 *
	 * Note that because iterators need to keep the same order, the entries
	 * cannot be shuffled or the map rebuilt.
	 *
	 * @param __k The key to remove.
	 * @param __preunlinked If this is true then the link chain will not have
	 * the entry removed by this method, it is assumed it was already
	 * removed by an iterator.
	 * @return The removed map entry or {@code null} if one did not exist.
	 * @since 2018/11/04
	 */
	public final __BucketMapEntry__<K, V> removeEntry(Object __k,
		boolean __preunlinked)
	{
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % this._bucketdiv;
		
		// If the chain does not exist then do not bother at all
		__BucketMapEntry__<K, V>[] chain = this._buckets[div];
		if (chain == null)
			return null;
		
		// Go through the chain and find the matching entry
		for (int i = 0, n = chain.length; i < n; i++)
		{
			// Ignore blank entries
			__BucketMapEntry__<K, V> e = chain[i];
			if (e == null)
				continue;
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found so it must be
			// removed
			if (Objects.equals(e._key, __k))
			{
				// Removing an entry from the chain is as simple as just
				// setting it to null. We do not need to move entries around
				// since that can be a bit slow
				chain[i] = null;
				
				// If this was not pre-unlinked from the iterator call then
				// it will be removed from the chain accordingly
				if (!__preunlinked)
				{
					Collection<__BucketMapEntry__<K, V>> links = this._links;
					if (links != null)
						links.remove(e);
				}	
				
				// Size goes down
				this._size--;
				
				// Map has been modified
				this._modcount++;
				
				// This entry was removed, so it gets returned by the map
				return e;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final int size()
	{
		return this._size;
	}
	
	/**
	 * Clears the bucket map.
	 *
	 * @since 2018/11/05
	 */
	final void __clear()
	{
		// Set all buckets to null so they are empty
		__BucketMapEntry__<K, V>[][] buckets = this._buckets;
		for (int i = 0, n = buckets.length; i < n; i++)
			buckets[i] = null;
		
		// Set size to zero
		this._size = 0;
		
		// Clear the linked list if there is one
		LinkedList<__BucketMapEntry__<K, V>> links = this._links;
		if (links != null)
			links.clear();
		
		// Modification count goes up
		this._modcount++;
	}
	
	/**
	 * Return the iterator over the map entries.
	 *
	 * @return The map iterator.
	 * @since 2018/11/01
	 */
	final Iterator<Map.Entry<K, V>> __iterator()
	{
		if (__BucketMap__.this.ordered)
			return new __IteratorLinkedOrder__();
		return new __IteratorBucketOrder__();
	}
	
	/**
	 * Creates a new bucket array.
	 *
	 * @param <K> Key type.
	 * @param <V> Value type.
	 * @param __n The length.
	 * @return The array.
	 * @since 2018/10/08
	 */
	@SuppressWarnings({"unchecked"})
	private static <K, V> __BucketMapEntry__<K, V>[][] __newBucket(int __n)
	{
		return (__BucketMapEntry__<K, V>[][])
			((Object)new __BucketMapEntry__[__n][]);
	}
	
	/**
	 * Creates a new chain array.
	 *
	 * @param <K> Key type.
	 * @param <V> Value type.
	 * @param __n The length.
	 * @return The array.
	 * @since 2018/10/08
	 */
	@SuppressWarnings({"unchecked"})
	private static <K, V> __BucketMapEntry__<K, V>[] __newChain(int __n)
	{
		return (__BucketMapEntry__<K, V>[])
			((Object)new __BucketMapEntry__[__n]);
	}
	
	/**
	 * Implements the entry set over the map, this iterates in a given order.
	 *
	 * @since 2018/11/01
	 */
	final class __EntrySet__
		extends AbstractSet<Map.Entry<K, V>>
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final void clear()
		{
			__BucketMap__.this.__clear();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final Iterator<Map.Entry<K, V>> iterator()
		{
			return __BucketMap__.this.__iterator();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final int size()
		{
			return __BucketMap__.this._size;
		}
	}
	
	/**
	 * Base iterator.
	 *
	 * @since 2018/11/01
	 */
	abstract class __IteratorBase__
		implements Iterator<Map.Entry<K, V>>
	{
		/** The mod init this iterator is at, to detect modifications. */
		int _atmod =
			__BucketMap__.this._modcount;
		
		/**
		 * Checks if the map's internal structure modification count has
		 * changed.
		 *
		 * @throws ConcurrentModificationException If the map was modified.
		 * @since 2018/10/13
		 */
		final void __checkModified()
			throws ConcurrentModificationException
		{
			// {@squirreljme.error ZZ38 Backing map has been modified.}
			if (this._atmod != __BucketMap__.this._modcount)
				throw new ConcurrentModificationException("ZZ38");
		}
	}
	
	/**
	 * Iterator over the entries in this map.
	 *
	 * @since 2018/10/13
	 */
	final class __IteratorBucketOrder__
		extends __IteratorBase__
	{
		/** The current bucket this is at. */
		int _bucketat;
		
		/** The current chain link this is at. */
		int _chainat;
		
		/** The cached next entry. */
		__BucketMapEntry__<K, V> _next;
		
		/** The last entry. */
		__BucketMapEntry__<K, V> _last;
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final boolean hasNext()
		{
			// Check modification
			this.__checkModified();
			
			// Already cached, do not need to check anything more
			if (this._next != null)
				return true;
			
			// No more buckets remain?
			int bucketat = this._bucketat,
				bucketdiv = __BucketMap__.this._bucketdiv;
			if (bucketat >= bucketdiv)
				return false;
			
			// Get the current chain
			__BucketMapEntry__<K, V>[][] buckets = __BucketMap__.this._buckets;
			
			// We can store the current location parameters at the end rather
			// than every time (keeps everything in locals)
			int chainat = this._chainat;
			try
			{
				// We might try looking at the next bucket if we reach the end
				// of this chain.
				for (;;)
				{
					__BucketMapEntry__<K, V>[] chain = buckets[bucketat];
					
					// No more chain links remain? Or there is no chain?
					int chaindiv = (chain == null ? -1 : chain.length);
					if (chainat >= chaindiv)
					{
						// Reset to start of next bucket
						bucketat++;
						chainat = 0;
						
						// No more buckets to look in
						if (bucketat >= bucketdiv)
							return false;
						
						// Try again
						continue;
					}
					
					// Will use the next chain
					int oldchainat = chainat++;
					
					// If no link was here try again
					__BucketMapEntry__<K, V> link = chain[oldchainat];
					if (link == null)
						continue;
					
					// Cache that link for returning
					this._next = link;
					return true;
				}
			}
			
			// Store properties
			finally
			{
				this._bucketat = bucketat;
				this._chainat = chainat;
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final Map.Entry<K, V> next()
			throws NoSuchElementException
		{
			// {@squirreljme.error ZZ39 Map has no more entries remaining.}
			if (!this.hasNext())
				throw new NoSuchElementException("ZZ39");
			
			// hasNext() caches this
			__BucketMapEntry__<K, V> rv = this._next;
			this._next = null;
			this._last = rv;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final void remove()
		{
			// Check modification
			this.__checkModified();
			
			// No last element was nexted
			__BucketMapEntry__<K, V> last = this._last;
			if (last == null)
				throw new IllegalStateException("NSEE");
			
			// Remove from the map but we never unlinked it, so if there is
			// a link it will be scanned and removed accordingly
			if (__BucketMap__.this.removeEntry(last.getKey(), false) != last)
				throw new todo.OOPS();
			
			// The map likely was structurally modified so use the new state
			this._atmod = __BucketMap__.this._modcount;
		}
	}
	
	/**
	 * Iterator over the linked order in this map.
	 *
	 * @since 2018/11/01
	 */
	final class __IteratorLinkedOrder__
		extends __IteratorBase__
	{
		/** The iterator for entries in linked order. */
		final Iterator<__BucketMapEntry__<K, V>> _iterator =
			__BucketMap__.this._links.iterator();
		
		/** The last returned entry, for removal. */
		__BucketMapEntry__<K, V> _last;
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final boolean hasNext()
		{
			// Check for modification
			this.__checkModified();
			
			// Just if it has a next anyway
			return this._iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final Map.Entry<K, V> next()
		{
			// Check for modification
			this.__checkModified();
			
			// Use the direct next entry
			__BucketMapEntry__<K, V> rv = this._iterator.next();
			this._last = rv;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final void remove()
		{
			// Check for modification
			this.__checkModified();
			
			// No last element was nexted
			__BucketMapEntry__<K, V> last = this._last;
			if (last == null)
				throw new IllegalStateException("NSEE");
			
			// Clear last because it will be invalid
			this._last = null;
			
			// Try removing it from the link first, if the state is bad then
			// we cannot remove the link. Has to be removed from the iterator
			// because otherwise there will be a concurrent modification
			// exception thrown when modification is detected.
			try
			{
				this._iterator.remove();
			}
			
			// Just rethrow this, this means the entry was already removed
			catch (IllegalStateException e)
			{
				throw e;
			}
			
			// Otherwise, remove the entry from the map but hint that it was
			// already removed from the ordered list
			// The entry being mismatched to the key should not happen ever
			// but if it does then something is very wrong
			if (__BucketMap__.this.removeEntry(last.getKey(), true) != last)
				throw new todo.OOPS();
			
			// The map likely was structurally modified so use the new state
			this._atmod = __BucketMap__.this._modcount;
		}
	}
}

Added modules/cldc-compact/src/main/java/java/util/__DescendingIteratorViaListIterator__.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;

/**
 * Descending iterator over the linked list.
 *
 * @param <E> The class type.
 * @since 2019/01/20
 */
final class __DescendingIteratorViaListIterator__<E>
	implements Iterator<E>
{
	/** The list iterator to use. */
	protected final ListIterator<E> it;
	
	/**
	 * Initializes the descending iterator.
	 *
	 * @param __it The input iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/20
	 */
	__DescendingIteratorViaListIterator__(ListIterator<E> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this.it = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final boolean hasNext()
	{
		return this.it.hasPrevious();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final E next()
	{
		return this.it.previous();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final void remove()
	{
		this.it.remove();
	}
}

Added modules/cldc-compact/src/main/java/java/util/__Link__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;

/**
 * Represents a single link in the linked list. This is just a basic
 * structure like object with public fields for simple access.
 *
 * @param <E> The type to store.
 * @since 2018/10/29
 */
final class __Link__<E>
{
	/** The previous link. */
	__Link__<E> _prev;
	
	/** The next link. */
	__Link__<E> _next;
	
	/** The value to store. */
	E _value;
	
	/**
	 * Initializes the new link and links into the chain.
	 *
	 * @param __prev The previous link to link in.
	 * @param __v The value to use.
	 * @param __next The next link to link in.
	 * @since 2018/10/29
	 */
	__Link__(__Link__<E> __prev, E __v, __Link__<E> __next)
	{
		// Set value first
		this._value = __v;
		
		// Link into previous chain
		this._prev = __prev;
		if (__prev != null)
			__prev._next = this;
		
		// Link into next chain
		this._next = __next;
		if (__next != null)
			__next._prev = this;
	}
}

Added modules/cldc-compact/src/main/java/java/util/__LinkedListListIterator__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 java.util;


/**
 * The list iterator for this linked list.
 *
 * @param <E> The types of values to store.
 * @since 2018/10/29
 */
final class __LinkedListListIterator__<E>
	implements ListIterator<E>
{
	/** The owning linked list. */
	protected final LinkedList<E> list;
	
	/** The virtualized index for the list (estimated). */
	private int _vdx;
	
	/** Last virtualized index. */
	private int _lastvdx;
	
	/** The current link the list is at. */
	private __Link__<E> _next;
	
	/** The last element, for removal or setting */
	private __Link__<E> _last;
	
	/** The current modification count, to detect modifications. */
	private int _atmod;
	
	/**
	 * Initializes the iterator starting at the given index.
	 *
	 * @param __list The linked list this interfaces with.
	 * @param __i The index to start at.
	 * @throws IndexOutOfBoundsException If the index is outside of the
	 * list bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	__LinkedListListIterator__(LinkedList<E> __list, int __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__list == null)
			throw new NullPointerException("NARG");
		
		int size = __list._size;
		if (__i < 0 || __i > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Closer to the start of the list
		__Link__<E> rover;
		if (__i < (size >> 1))
		{
			rover = __list._head;
			
			for (int i = -1; i < __i; i++)
				rover = rover._next;
		}
		
		// Closer to the end of the list
		else
		{
			rover = __list._tail;
			
			for (int i = size; i > __i; i--)
				rover = rover._prev;
		}
		
		// Store start information
		this.list = __list;
		this._next = rover;
		this._vdx = __i;
		this._atmod = __list.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void add(E __v)
	{
		// Check modification
		this.__checkConcurrent();
		
		// These will both be adjusted
		int vdx = this._vdx;
		__Link__<E> next = this._next;
		
		// The documentation specifies that the object is inserted
		// before the implicit cursor, which means the next call to
		// previous will return the new element. Next would just return
		// the same element no matter how many elements are added.
		// So it is inserted between the previous and our current next
		new __Link__<E>(next._prev, __v, next);
		
		// Since we inserted an item, vdx goes up
		this._vdx++;
		
		// Size also goes up
		this.list._size++;
		
		// Set list as being modified and update our count to match
		this._atmod = ++this.list.modCount;
		
		// Cannot remove or set
		this._last = null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final boolean hasNext()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There is a next as long as the current element is before the
		// size
		return this._vdx < this.list._size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final boolean hasPrevious()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There is a previous as long as this is not the first element
		return this._vdx > 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E next()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// We are at the tail node, do nothing
		__Link__<E> next = this._next;
		if (next == this.list._tail)
			throw new NoSuchElementException("NSEE");
		
		// Removal and set can be done on this
		this._last = next;
		
		// Iterate and record for the next element
		this._lastvdx = this._vdx++;
		this._next = next._next;
		
		// Return the current value
		return next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final int nextIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// Virtual index should match this one
		return this._vdx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final E previous()
	{
		// Check modification
		this.__checkConcurrent();
		
		// We are at the head node, do nothing
		__Link__<E> next = this._next;
		if (next._prev == this.list._head)
			throw new NoSuchElementException("NSEE");
		
		// Move to previous
		__Link__<E> prev = next._prev;
		
		// Removal is done on this
		this._last = prev;
		
		// Move index back
		this._lastvdx = --this._vdx;
		this._next = prev;
		
		// Use previous value
		return prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final int previousIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// Should be the previous virtual index
		return this._vdx - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void remove()
		throws IllegalStateException
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2u Cannot remove the element from the
		// linked list because there was no previous call to next or
		// previous, or add was called.}
		__Link__<E> last = this._last;
		if (last == null)
			throw new IllegalStateException("ZZ2u");
		
		// Only removed once
		this._last = null;
		
		// Just link the previous and next entries to the others and
		// drop this link
		last._prev._next = last._next;
		last._next._prev = last._prev;
		
		// If the next entry is after this point then it will needs its
		// index dropped
		int vdx = this._vdx,
			lastvdx = this._lastvdx;
		if (vdx > lastvdx)
			this._vdx = vdx - 1;
		
		// Set list as being modified and update our count to match
		this._atmod = ++this.list.modCount;
		
		// Size goes down
		this.list._size--;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void set(E __v)
		throws IllegalStateException
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2v Cannot set the element from the
		// linked list because there was no previous call to next or
		// previous, or add was called.}
		__Link__<E> last = this._last;
		if (last == null)
			throw new IllegalStateException("ZZ2v");
		
		// Just set it
		last._value = __v;
	}
	
	/**
	 * Checks if the list was concurrently modified.
	 *
	 * @throws ConcurrentModificationException If it was modified.
	 * @since 2018/10/29
	 */
	private final void __checkConcurrent()
		throws ConcurrentModificationException
	{
		// {@squirreljme.error ZZ2w List has been concurrently modified.}
		if (this._atmod != this.list.modCount)
		{
			// Just empty these out so they are never used again
			this._next = null;
			this._last = null;
			
			// Fail
			throw new ConcurrentModificationException("ZZ2w");
		}
	}
}

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

package java.util;

/**
 * Represents the category of the conversion.
 *
 * @since 2018/09/29
 */
enum __PrintFCategory__
{
	/** General. */
	GENERAL,
	
	/** Character. */
	CHARACTER,
	
	/** Integral. */
	INTEGRAL,
	
	/** Floating point. */
	FLOATING_POINT,
	
	/** Date/Time. */
	DATE_TIME,
	
	/** Percent. */
	PERCENT,
	
	/** Line Separator. */
	LINE_SEPARATOR,
	
	/** End. */
	;
	
	/**
	 * Is the specified flag valid?
	 *
	 * @param __f The flag to check.
	 * @return If it is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		switch (this)
		{
				// May only be left justified
			case CHARACTER:
			case DATE_TIME:
			case GENERAL:
				return __f == __PrintFFlag__.LEFT_JUSTIFIED;
				
				// Anything is valid
			case INTEGRAL:
				return true;
				
				// Not valid at all
			case PERCENT:
			case LINE_SEPARATOR:
				return false;
				
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is the precision valid?
	 *
	 * @return Is the precision valid?
	 * @since 2018/09/29
	 */
	final boolean __hasPrecision()
	{
		switch (this)
		{
			case GENERAL:
			case FLOATING_POINT:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is the width valid?
	 *
	 * @return If the width is valid.
	 * @since 2018/09/29
	 */
	final boolean __hasWidth()
	{
		return this != __PrintFCategory__.LINE_SEPARATOR;
	}
}

Added modules/cldc-compact/src/main/java/java/util/__PrintFConversion__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a conversion that can be used for formatted printing.
 *
 * @since 2018/09/28
 */
enum __PrintFConversion__
{
	/** Literal percent. */
	PERCENT,
	
	/** Newline. */
	NEWLINE,
	
	/** Boolean. */
	BOOLEAN,
	
	/** Hashcode. */
	HASHCODE,
	
	/** String. */
	STRING,
	
	/** Character. */
	CHARACTER,
	
	/** Decimal Integer. */
	DECIMAL_INTEGER,
	
	/** Octal Integer. */
	OCTAL_INTEGER,
	
	/** Hexadecimal Integer. */
	HEXADECIMAL_INTEGER,
	
	/** Scientific decimal floating point. */
	SCIENTIFIC_DECIMAL_FLOAT,
	
	/** Decimal floating point. */
	NORMAL_DECIMAL_FLOAT,
	
	/** Floating point in scientific or normal mode. */
	SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT,
	
	/** Hour: 00 - 23. */
	TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO,
	
	/** Hour: 01 - 12. */
	TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO,
	
	/** Hour: 0 - 24. */
	TIME_MILITARY_HOUR,
	
	/** Hour: 1 - 12. */
	TIME_STANDARD_HOUR,
	
	/** Minute: 00 - 59. */
	TIME_MINUTE,
	
	/** Seconds: 00 - 60 (60 for leap seconds). */
	TIME_SECONDS,
	
	/** Milliseconds: 000 - 999. */
	TIME_MILLISECONDS,
	
	/** Locale based am or pm. */
	TIME_AM_PM,
	
	/** RFC 822 zone offset from GMT, such as -0800 for the current zone. */
	TIME_ZONE_RFC822_OFFSET,
	
	/** The abbreviation for this timezone. */
	TIME_ZONE_ABBREVIATION,
	
	/** Seconds since UNIX Epoch. */
	TIME_UNIX_SECONDS,
	
	/** Milliseconds since UNIX Epoch. */
	TIME_UNIX_MILLISECONDS,
	
	/** Local abbreviated month: Jan, Feb. */
	DATE_ABBREVIATED_MONTH_NAME,
	
	/** Local short name of the day of week: Sun, Mon. */
	DATE_ABBREVIATED_DAY_NAME,
	
	/** Century, two digits with leading zero: 00 - 99. */
	DATE_CENTURY_TWO_DIGIT_LEADING_ZERO,
	
	/** Year formatted with at least four digits. */
	DATE_YEAR_FOUR_DIGITS,
	
	/** Last two digits of the year. */
	DATE_YEAR_LAST_TWO_DIGITS,
	
	/** Day of year, with leading zeros as needed: 001 - 366. */
	DATE_DAY_OF_YEAR,
	
	/** Month with two digits with leading zero: 01 - 13. */
	DATE_MONTH_TWO_DIGIT_LEADING_ZERO,
	
	/** Day of month, two digits with leading zero: 01 - 31. */
	DATE_DAY_TWO_DIGIT_LEADING_ZERO,
	
	/** Day of month: 1 - 31. */
	DATE_DAY,
	
	/** 24-hour clock format: %tH:%tM. */
	DATE_TIME_MILITARY,
	
	/** 24-hour clock format with seconds: %tH:%tM:%tS. */
	DATE_TIME_MILITARY_WITH_SECONDS,
	
	/** 12-hour clock format with seconds: %tI:%tM:%tS %Tp. */
	DATE_TIME_STANDARD,
	
	/** Date formatted as %tm/%td/%ty. */
	DATE_MONTH_DAY_YEAR,
	
	/** ISO 8601 Date: %tY-%tm-%td. */
	DATE_ISO8601,
	
	/** Date and time as: %ta %tb %td %tT %tZ %tY. */
	DATE_LONG_FORMAT,
	
	/** End. */
	;
	
	/**
	 * Returns the category of this conversion.
	 *
	 * @return The conversion category.
	 * @since 2018/09/29
	 */
	final __PrintFCategory__ __category()
	{
		switch (this)
		{
			case PERCENT:
				return __PrintFCategory__.PERCENT;
			
			case NEWLINE:
				return __PrintFCategory__.LINE_SEPARATOR;
			
			case BOOLEAN:
			case HASHCODE:
			case STRING:
				return __PrintFCategory__.GENERAL;
				
			case CHARACTER:
				return __PrintFCategory__.CHARACTER;
				
			case DECIMAL_INTEGER:
			case OCTAL_INTEGER:
			case HEXADECIMAL_INTEGER:
				return __PrintFCategory__.INTEGRAL;
				
			case SCIENTIFIC_DECIMAL_FLOAT:
			case NORMAL_DECIMAL_FLOAT:
			case SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT:
				return __PrintFCategory__.FLOATING_POINT;
				
			case TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO:
			case TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO:
			case TIME_MILITARY_HOUR:
			case TIME_STANDARD_HOUR:
			case TIME_MINUTE:
			case TIME_SECONDS:
			case TIME_MILLISECONDS:
			case TIME_AM_PM:
			case TIME_ZONE_RFC822_OFFSET:
			case TIME_ZONE_ABBREVIATION:
			case TIME_UNIX_SECONDS:
			case TIME_UNIX_MILLISECONDS:
			case DATE_ABBREVIATED_MONTH_NAME:
			case DATE_ABBREVIATED_DAY_NAME:
			case DATE_CENTURY_TWO_DIGIT_LEADING_ZERO:
			case DATE_YEAR_FOUR_DIGITS:
			case DATE_YEAR_LAST_TWO_DIGITS:
			case DATE_DAY_OF_YEAR:
			case DATE_MONTH_TWO_DIGIT_LEADING_ZERO:
			case DATE_DAY_TWO_DIGIT_LEADING_ZERO:
			case DATE_DAY:
			case DATE_TIME_MILITARY:
			case DATE_TIME_MILITARY_WITH_SECONDS:
			case DATE_TIME_STANDARD:
			case DATE_MONTH_DAY_YEAR:
			case DATE_ISO8601:
			case DATE_LONG_FORMAT:
				return __PrintFCategory__.DATE_TIME;
				
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is the specified flag valid?
	 *
	 * @param __f The flag to check.
	 * @return If it is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// If the category does not have it then it will never have it
		__PrintFCategory__ cat = this.__category();
		if (!cat.__hasFlag(__f))
			return false;
		
		// Only this category has exclusions
		if (cat == __PrintFCategory__.INTEGRAL)
			switch (__f)
			{
					// Only valid for octal and hex ints
				case ALTERNATIVE_FORM:
					return this == __PrintFConversion__.OCTAL_INTEGER ||
						this == __PrintFConversion__.HEXADECIMAL_INTEGER;
				
					// Only valid for decimal ints
				case LOCALE_GROUPING:
					return this == __PrintFConversion__.DECIMAL_INTEGER;
				
				default:
					break;
			}
		
		// Is valid!
		return true;
	}
	
	/**
	 * Returns the conversion that is used for the characters.
	 *
	 * @param __f The first character.
	 * @param __s The second character.
	 * @return The conversion or {@code null} if it is not valid.
	 * @since 2018/09/28
	 */
	static final __PrintFConversion__ __decode(int __f, int __s)
	{
		// There are a ton of date formats, so just if a date is used do
		// not bother
		if (__f != 't' && __f != 'T')
			switch (__f)
			{
				case '%':	return __PrintFConversion__.PERCENT;
				case 'n':	return __PrintFConversion__.NEWLINE;
				case 'B':
				case 'b':	return __PrintFConversion__.BOOLEAN;
				case 'H':
				case 'h':	return __PrintFConversion__.HASHCODE;
				case 'S':
				case 's':	return __PrintFConversion__.STRING;
				case 'C':
				case 'c':	return __PrintFConversion__.CHARACTER;
				case 'd':	return __PrintFConversion__.DECIMAL_INTEGER;
				case 'o':	return __PrintFConversion__.OCTAL_INTEGER;
				case 'X':
				case 'x':	return __PrintFConversion__.HEXADECIMAL_INTEGER;
				case 'E':
				case 'e':	return __PrintFConversion__.SCIENTIFIC_DECIMAL_FLOAT;
				case 'f':	return __PrintFConversion__.NORMAL_DECIMAL_FLOAT;
				case 'G':
				case 'g':	return __PrintFConversion__.SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT;
				
				default:
					return null;
			}
		
		// A date format
		switch (__s)
		{
			case 'H':	return __PrintFConversion__.TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO;
			case 'I':	return __PrintFConversion__.TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO;
			case 'k':	return __PrintFConversion__.TIME_MILITARY_HOUR;
			case 'l':	return __PrintFConversion__.TIME_STANDARD_HOUR;
			case 'M':	return __PrintFConversion__.TIME_MINUTE;
			case 'S':	return __PrintFConversion__.TIME_SECONDS;
			case 'L':	return __PrintFConversion__.TIME_MILLISECONDS;
			case 'p':	return __PrintFConversion__.TIME_AM_PM;
			case 'z':	return __PrintFConversion__.TIME_ZONE_RFC822_OFFSET;
			case 'Z':	return __PrintFConversion__.TIME_ZONE_ABBREVIATION;
			case 's':	return __PrintFConversion__.TIME_UNIX_SECONDS;
			case 'Q':	return __PrintFConversion__.TIME_UNIX_MILLISECONDS;
			case 'h':
			case 'b':	return __PrintFConversion__.DATE_ABBREVIATED_MONTH_NAME;
			case 'a':	return __PrintFConversion__.DATE_ABBREVIATED_DAY_NAME;
			case 'C':	return __PrintFConversion__.DATE_CENTURY_TWO_DIGIT_LEADING_ZERO;
			case 'Y':	return __PrintFConversion__.DATE_YEAR_FOUR_DIGITS;
			case 'y':	return __PrintFConversion__.DATE_YEAR_LAST_TWO_DIGITS;
			case 'j':	return __PrintFConversion__.DATE_DAY_OF_YEAR;
			case 'm':	return __PrintFConversion__.DATE_MONTH_TWO_DIGIT_LEADING_ZERO;
			case 'd':	return __PrintFConversion__.DATE_DAY_TWO_DIGIT_LEADING_ZERO;
			case 'e':	return __PrintFConversion__.DATE_DAY;
			case 'R':	return __PrintFConversion__.DATE_TIME_MILITARY;
			case 'T':	return __PrintFConversion__.DATE_TIME_MILITARY_WITH_SECONDS;
			case 'r':	return __PrintFConversion__.DATE_TIME_STANDARD;
			case 'D':	return __PrintFConversion__.DATE_MONTH_DAY_YEAR;
			case 'F':	return __PrintFConversion__.DATE_ISO8601;
			case 'c':	return __PrintFConversion__.DATE_LONG_FORMAT;
		
			default:
				return null;
		}
	}
}

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

package java.util;

/**
 * PrintF flags which may exist to be used.
 *
 * @since 2018/09/24
 */
enum __PrintFFlag__
{
	/** Left justification. */
	LEFT_JUSTIFIED,
	
	/** Alternative form. */
	ALTERNATIVE_FORM,
	
	/** Include sign always. */
	ALWAYS_SIGNED,
	
	/** Padded sign with space. */
	SPACE_FOR_POSITIVE,
	
	/** Zero padded. */
	ZERO_PADDED,
	
	/** Locale specific grouping specifiers. */
	LOCALE_GROUPING,
	
	/** Negative numbers in parenthesis. */
	NEGATIVE_PARENTHESIS,
	
	/** End. */
	;
	
	/** Internal values. */
	private static final __PrintFFlag__[] _VALUES =
		__PrintFFlag__.values();
	
	/** The number of flags used. */
	public static final int COUNT =
		__PrintFFlag__._VALUES.length;
	
	/**
	 * Returns the value for the given ordinal/
	 *
	 * @param __i The ordinal.
	 * @return The flag.
	 * @throws IndexOutOfBoundsException If the ordinal is out of range.
	 * @since 2018/09/29
	 */
	public static final __PrintFFlag__ valueOf(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= __PrintFFlag__.COUNT)
			throw new IndexOutOfBoundsException("IOOB");
		return __PrintFFlag__._VALUES[__i];
	}
	
	/**
	 * Decodes the given character to a flag.
	 *
	 * @param __c The character to decode.
	 * @return The flag for the character or {@code null} if it is not valid.
	 * @since 2018/09/24
	 */
	static final __PrintFFlag__ __decode(char __c)
	{
		switch (__c)
		{
			case '-':	return __PrintFFlag__.LEFT_JUSTIFIED;
			case '#':	return __PrintFFlag__.ALTERNATIVE_FORM;
			case '+':	return __PrintFFlag__.ALWAYS_SIGNED;
			case ' ':	return __PrintFFlag__.SPACE_FOR_POSITIVE;
			case '0':	return __PrintFFlag__.ZERO_PADDED;
			case ',':	return __PrintFFlag__.LOCALE_GROUPING;
			case '(':	return __PrintFFlag__.NEGATIVE_PARENTHESIS;
			default:
				return null;
		}
	}
}

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

package java.util;

/**
 * Global PrintF state.
 *
 * @since 2018/09/28
 */
final class __PrintFGlobal__
{
	/** Arguments. */
	final Object[] _args;
	
	/** Linear index, used to implicitly define which argument to use. */
	int _lineardx;
	
	/**
	 * Initializes the global state.
	 *
	 * @param __args The arguments.
	 * @since 2018/09/29
	 */
	__PrintFGlobal__(Object... __args)
	{
		this._args = (__args == null ? new Object[0] : __args);
	}
}

Added modules/cldc-compact/src/main/java/java/util/__PrintFState__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This stores the state for printf parsing.
 *
 * @since 2018/09/24
 */
final class __PrintFState__
{
	/** Global state. */
	final __PrintFGlobal__ _global;
	
	/** Flags specified. */
	final boolean[] _flags =
		new boolean[__PrintFFlag__.COUNT];
	
	/** The argument index. */
	int _argdx =
		-1;
	
	/** The width. */
	int _width =
		-1;
	
	/** The precision. */
	int _precision =
		-1;
	
	/** The conversion used. */
	__PrintFConversion__ _conv;
	
	/** Is the conversion to be uppercase? */
	boolean _upper;
	
	/**
	 * Initializes the state.
	 *
	 * @param __pg The state.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	__PrintFState__(__PrintFGlobal__ __pg)
		throws NullPointerException
	{
		if (__pg == null)
			throw new NullPointerException("NARG");
		
		this._global = __pg;
	}
	
	/**
	 * Returns the specified argument.
	 *
	 * @param <C> The return type.
	 * @param __i The index.
	 * @return The argument value.
	 * @throws IllegalArgumentException If the argument is not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/09/29
	 */
	final <C> C __argument(Class<C> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3a Null argument was passed.}
		C rv = this.<C>__argument(__cl, null);
		if (rv == null)
			throw new NullPointerException("ZZ3a");
		return rv;
	}
	
	/**
	 * Returns the specified argument.
	 *
	 * @param <C> The return type.
	 * @param __i The index.
	 * @param __def The default value, if the input is null then this will
	 * be returned.
	 * @return The argument value or the default if it was null.
	 * @throws IllegalArgumentException If the argument is not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/09/29
	 */
	final <C> C __argument(Class<C> __cl, C __def)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		__PrintFGlobal__ global = this._global;
		
		// Determine the argument index to use, if the argument was not
		// explicitely passed then it is tracked manually
		int argdx = this._argdx,
			usedx = (argdx < 0 ? global._lineardx++ : argdx - 1);
		
		// {@squirreljme.error ZZ3b Request to use argument which is not
		// within the bounds of the input arguments. (The argument index)}
		Object[] args = global._args;
		if (usedx < 0 || usedx >= args.length)
			throw new IllegalArgumentException("ZZ3b " + (usedx + 1));
		
		// Return default value if one was used and there was no value here
		Object rv = args[usedx];
		if (rv == null)
			return __def;
		
		// {@squirreljme.error ZZ3c Expected argument of one class however it
		// was instead another class. (The requested class; The actual class)}
		if (!__cl.isInstance(rv))
			throw new IllegalArgumentException("ZZ3c " + __cl + " " +
				rv.getClass());
		
		return __cl.cast(rv);
	}
	
	/**
	 * Is the given flag used?
	 *
	 * @param __f The flag to use.
	 * @return If the flag is used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/03
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return this._flags[__f.ordinal()];
	}
	
	/**
	 * Was a width specified?
	 *
	 * @return If a width was specified.
	 * @since 2018/09/24
	 */
	final boolean __hasWidth()
	{
		return this._width >= 1;
	}
	
	/**
	 * Is this left justified?
	 *
	 * @return If this is left justified.
	 * @since 2018/09/29
	 */
	final boolean __isLeftJustified()
	{
		return this._flags[__PrintFFlag__.LEFT_JUSTIFIED.ordinal()];
	}
	
	/**
	 * Sets the argument index.
	 *
	 * @param __dx The index to set.
	 * @throws IllegalArgumentException If the index is not valid.
	 * @since 2018/09/24
	 */
	final void __setArgumentIndex(int __dx)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3d Argument index already set or is of an
		// invalid value. (The index used)}
		if (__dx <= 0 || this._argdx >= 1)
			throw new IllegalArgumentException("ZZ3d " + __dx);
		
		this._argdx = __dx;
	}
	
	/**
	 * Sets the conversion.
	 *
	 * @param __p The primary conversion.
	 * @param __s The secondary conversion.
	 * @throws IllegalArgumentException If the conversion is not valid.
	 * @since 2018/09/28
	 */
	final void __setConversion(int __p, int __s)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3e The conversion has already been specified.}
		if (this._conv != null)
			throw new IllegalArgumentException("ZZ3e");
		
		// {@squirreljme.error ZZ3f Invalid conversion specified. (The first
		// character; The second character)}
		__PrintFConversion__ conv = __PrintFConversion__.__decode(__p, __s);
		if (conv == null)
			throw new IllegalArgumentException("ZZ3f " + (char)__p + " " +
				(char)(__s < 0 ? ' ' : __s));
		
		// Set
		this._conv = conv;
		
		// Uppercase conversion?
		switch (__p)
		{
			case 'B':
			case 'H':
			case 'S':
			case 'C':
			case 'X':
			case 'E':
			case 'G':
			case 'T':
				this._upper = true;
				break;
			
			default:
				break;
		}
		
		// Need this to do sanity checks
		__PrintFCategory__ cat = conv.__category();
		
		// {@squirreljme.error ZZ3g The specified flag cannot be specified
		// for the given conversion. (The conversion; The flag)}
		boolean[] flags = this._flags;
		for (int i = 0, n = __PrintFFlag__.COUNT; i < n; i++)
		{
			__PrintFFlag__ flag = __PrintFFlag__.valueOf(i);
			if (flags[i] && !conv.__hasFlag(flag))
				throw new IllegalArgumentException("ZZ3g " + conv + " " +
					flag);
		}
		
		// {@squirreljme.error ZZ3h Width cannot be specified for the given
		// convesion. (The conversion)}
		if (this._width > 0 && !cat.__hasWidth())
			throw new IllegalArgumentException("ZZ3h " + conv);
		
		// {@squirreljme.error ZZ3i Precision cannot be specified for the
		// given conversion. (The conversion)}
		if (this._precision > 0 && !cat.__hasPrecision())
			throw new IllegalArgumentException("ZZ3i " + conv);
	}
	
	/**
	 * Sets the specified flag.
	 *
	 * @param __c The flag to set.
	 * @return If the flag is valid.
	 * @throws IllegalArgumentException If the flag was duplicated.
	 * @since 2018/09/24
	 */
	final boolean __setFlag(char __c)
		throws IllegalArgumentException
	{
		// Is this flag one that exists?
		__PrintFFlag__ f = __PrintFFlag__.__decode(__c);
		if (f == null)
			return false;
		
		boolean[] flags = this._flags;
		
		// There may be a duplicate flag
		int ord = f.ordinal();
		if (flags[ord])
			throw new IllegalArgumentException("ZZ1p " + __c);
		
		// {@squirreljme.error ZZ3j Always signed and space for positive values
		// cannot be combined for format flags.}
		if ((f == __PrintFFlag__.ALWAYS_SIGNED &&
			flags[__PrintFFlag__.SPACE_FOR_POSITIVE.ordinal()]) ||
			(f == __PrintFFlag__.SPACE_FOR_POSITIVE &&
			flags[__PrintFFlag__.ALWAYS_SIGNED.ordinal()]))
			throw new IllegalArgumentException("ZZ3j");
		
		// Use it
		flags[ord] = true;
		return true;
	}
	
	/**
	 * Sets the width.
	 *
	 * @param __w The width to use.
	 * @throws IllegalArgumentException If the width is not valid.
	 * @since 2018/09/24
	 */
	final void __setWidth(int __w)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3k Width already or is of an invalid value.
		// (The width used)}
		if (__w <= 0 || this._width >= 1)
			throw new IllegalArgumentException("ZZ3k " + __w);
		
		this._width = __w;
	}
	
	/**
	 * Returns the width.
	 *
	 * @return The width.
	 * @throws IllegalArgumentException If it was not specified.
	 * @since 2018/11/03
	 */
	final int __width()
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3l No width was specified where one was
		// expected.}
		int rv = this._width;
		if (rv < 0)
			throw new IllegalArgumentException("ZZ3l");
		
		return rv;
	}
}

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

package java.util;

/**
 * Comparator for task scheduling.
 *
 * @since 2018/12/11
 */
@Deprecated
final class __TaskSchedComparator__
	implements Comparator<TimerTask>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final int compare(TimerTask __a, TimerTask __b)
	{
		long diff = (__a._schedtime - __b._schedtime);
		if (diff == 0)
			return 0;
		else if (diff < 0)
			return -1;
		return 1;
	}
}

Added modules/cldc-compact/src/main/java/java/util/__TimerThread__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a thread which provides the basis for the timer.
 *
 * @since 2018/12/11
 */
final class __TimerThread__
	extends Thread
{
	/**
	 * Tasks which may be running, note that this is not a binary heap as
	 * Java SE says since there should not be thousands of running tasks.
	 * This is Java ME and timers are less likely to be heavy.
	 */
	final List<TimerTask> _tasks =
		new ArrayList<>();
	
	/** Cancel execution? */
	volatile boolean _cancel;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __n The thread name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	__TimerThread__(String __n)
		throws NullPointerException
	{
		super(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final void run()
	{
		List<TimerTask> tasks = this._tasks;
		
		// Constantly loop on our own look since we will mess with things
		for (;;)
			synchronized (this)
			{
				if (this._cancel)
				{
					// Set all tasks to cancel
					for (TimerTask t : tasks)
						t._cancel = true;
					
					// Clear all the tasks, because we no longer need them
					tasks.clear();
					
					// And just stop executing
					return;
				}
				
				// Task to run
				TimerTask execute = null;
				
				// Need to determine how long to wait to run a task for
				try
				{
					// If there are no tasks to run, then we wait forever
					if (tasks.isEmpty())
						this.wait();
					
					// Otherwise see how long we need to wait
					else
					{
						// Need to determine if we are running this task
						// or just waiting
						TimerTask next = tasks.get(0);
						long now = System.currentTimeMillis(),
							sched = next._schedtime;
						
						// We cancelled the task, so remove and do not bother
						// at all
						if (next._cancel)
						{
							tasks.remove(0);
							continue;
						}
						
						// We can execute it!
						else if (sched <= now)
						{
							execute = next;
							tasks.remove(0);
						}
						
						// Wait around for it to happen, but another event
						// could come before this!
						else
							this.wait(sched - now);
					}
				}
				
				// If interrupted, try another run of the loop
				catch (InterruptedException e)
				{
					continue;
				}
				
				// Execute if things are to be done
				if (execute != null)
				{
					// We need to set the last one because fixed scheduling
					// will set a new schedule time while delayed will wait
					// on that
					long schedtime = execute._schedtime;
					execute._lastrun = schedtime;
					
					// Fixed scheduling has it where the next event gets the
					// period added to the scheduling time. This way if the
					// task runs too slowly it gets built up.
					boolean repeated = execute._repeated,
						fixed = execute._fixed;
					long period = execute._period;
					if (repeated && fixed)
						schedtime += period;
					
					// Execute the task
					execute._inrun = true;
					try
					{
						execute.run();
					}
					catch (Throwable t)
					{
						// Ignore
						t.printStackTrace();
					}
					execute._inrun = false;
					
					// Repeat as long as the task is not cancelled
					if (repeated && !execute._cancel)
					{
						// If not fixed use delay from the end of this
						// execution
						if (!fixed)
							schedtime = System.currentTimeMillis() + period;
						
						// Schedule for re-execution
						execute._schedtime = schedtime;
						this.__addTask(execute);
					}
				}
			}
	}
	
	/**
	 * Adds the specified task.
	 *
	 * @param __task The task to add.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/12
	 */
	private void __addTask(TimerTask __task)
		throws NullPointerException
	{
		if (__task == null)
			throw new NullPointerException("NARG");
		
		List<TimerTask> tasks = this._tasks;
		
		// Add task to the task list, but in task sorted order
		// It is always inserted into the correct location
		int dx = (tasks.isEmpty() ? 0 :
			Collections.<TimerTask>binarySearch(tasks,
			__task, new __TaskSchedComparator__()));
		if (dx < 0)
			dx = (-(dx) - 1);
		
		// Add task at the index we found it should be at
		tasks.add(dx, __task);
	}
	
	/**
	 * Schedules the task.
	 *
	 * @param __task The task to run.
	 * @param __first The time when the task should run.
	 * @param __rep Repeat the task?
	 * @param __fixed Fixed delays from execution?
	 * @param __period The period between each repetition.
	 * @throws IllegalArgumentException If the date is negative or the
	 * period is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	void __schedule(TimerTask __task, Date __first,
		boolean __rep, boolean __fixed, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__task == null || __first == null)
			throw new NullPointerException("NARG");
		
		// Need to determine when 
		long datemilli = __first.getTime(),
			nowtime = System.currentTimeMillis(),
			diff = datemilli - nowtime;
		
		// {@squirreljme.error ZZ3m Cannot use a date which is far into the
		// past.}
		if (datemilli < 0)
			throw new IllegalArgumentException("ZZ3m");
		
		// Schedule immedietly?
		if (diff < 0)
			diff = 0;
		
		// Forward since we use fixed delay schedule
		this.__schedule(__task, diff, __rep, __fixed, __period);
	}
	
	/**
	 * Schedules the task.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before the first invocation.
	 * @param __rep Repeat the task?
	 * @param __fixed Fixed delays from execution?
	 * @param __period The period between each repetition.
	 * @throws IllegalArgumentException If the delay is negative or the
	 * period is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	void __schedule(TimerTask __task, long __delay,
		boolean __rep, boolean __fixed, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__task == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3n The delay cannot be negative.}
		if (__delay < 0)
			throw new IllegalArgumentException("ZZ3n");
		
		// {@squirreljme.error ZZ3o The period cannot be zero or negative.}
		if (__rep && __period <= 0)
			throw new IllegalArgumentException("ZZ3o");
		
		// When is the time to be scheduled?
		long now = System.currentTimeMillis(),
			sched = now + __delay;
		
		// Lock on self
		List<TimerTask> tasks = this._tasks;
		synchronized (this)
		{
			// {@squirreljme.error ZZ3p Cannot add a task to a timer which
			// was cancelled or a task which was cancelled.}
			if (this._cancel || __task._cancel)
				throw new IllegalStateException("ZZ3p");
			
			// Set task properties
			__task._schedtime = sched;
			__task._scheduled = true;
			__task._repeated = __rep;
			__task._fixed = __fixed;
			__task._period = __period;
			
			// Add the task
			this.__addTask(__task);
			
			// And notify that there is a new task in place
			this.notifyAll();
		}
	}
}

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

package todo;

import cc.squirreljme.runtime.cldc.Poking;

/**
 * This class contains static methods for debug printing messages as needed.
 *
 * @since 2018/04/09
 */
public final class DEBUG
{
	static
	{
		// Poke native VM stuff to make sure it exists before we try to use it
		Poking.poke();
	}
	
	/**
	 * Not used.
	 *
	 * @since 2018/04/09
	 */
	private DEBUG()
	{
	}
	
	/**
	 * Prints a debug note to standard error about something that is
	 * incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/09
	 */
	public static final void note(String __fmt, Object... __args)
	{
		TODO.__note("DBUG", __fmt, __args);
	}
}

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

package todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import java.io.PrintStream;

/**
 * This is an error which is thrown when a condition which should not occur
 * occurs.
 *
 * @since 2018/11/25
 */
public class OOPS
	extends Error
{
	/**
	 * Generates an oops with no message.
	 *
	 * @since 2018/11/25
	 */
	public OOPS()
	{
		this(null, null);
	}
	
	/**
	 * Generates an oops with the given message.
	 *
	 * @param __m The message to use.
	 * @since 2018/11/25
	 */
	public OOPS(String __m)
	{
		this(__m, null);
	}
	
	/**
	 * Generates an oops with the given cause.
	 *
	 * @param __t The cause to use.
	 * @since 2018/11/25
	 */
	public OOPS(Throwable __t)
	{
		this(null, __t);
	}
	
	/**
	 * Generates an oops with the given message and cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause.
	 * @since 2018/11/25
	 */
	public OOPS(String __m, Throwable __t)
	{
		super(__m, __t);
		
		// Detect OOPSes/TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			// Top banner
			ps.println("****************************************************");
			ps.print("OOPS CONDITION WAS MET: ");
			if (__m != null)
				ps.print(__m);
			ps.println();
			
			// Print the current thread
			ps.print("IN THREAD: ");
			ps.println(Thread.currentThread());
			
			// Spacer
			ps.println();
			
			// Print the trace
			this.printStackTrace(ps);
			
			// Ending banner
			ps.println("****************************************************");
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		
		// {@squirreljme.property
		// cc.squirreljme.nooopsexit=(boolean)
		// If this is {@code true} then the OOPS exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.nooopsexit")))
			try
			{
				System.exit(125);
			}
		
			// Ignore
			catch (SecurityException e)
			{
			}
	}
}

Added modules/cldc-compact/src/main/java/todo/TODO.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.Poking;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import java.io.PrintStream;

/**
 * This exception is thrown.
 *
 * When constructed, this exception does not normall finish execution.
 *
 * @since 2017/02/28
 */
public class TODO
	extends Error
{
	/** Debug by default? */
	private static final boolean _DEFAULT_DEBUG =
		true;
	
	/** Should messages be squelched? */
	private static final boolean _SQUELCH;
	
	/** Used to detect TODOs recursively being called. */
	static volatile boolean _DOUBLE_TRIP;
	
	/** Suppress infinite note TODOs being printed over and over. */
	private static volatile boolean _notelock;
	
	/** The number of suppressed note TODOs. */
	private static volatile int _supressednotes;
	
	/**
	 * Checks if debug messages should be printed.
	 *
	 * @since 2018/11/04
	 */
	static
	{
		// Poke native VM stuff to make sure it exists before we try to use it
		Poking.poke();
		
		// Debugging?
		boolean debug;
		try
		{
			// {@squirreljme.property cc.squirreljme.debug Set to a boolean
			// value (true or false) which specifies whether todo and debug
			// messages should be printed to the console.}
			debug = Boolean.valueOf(
				System.getProperty("cc.squirreljme.debug",
				Boolean.valueOf(TODO._DEFAULT_DEBUG).toString()));
		}
		
		// Cannot access properties so use the default
		catch (SecurityException e)
		{
			debug = TODO._DEFAULT_DEBUG;
		}
		
		// Squelch based on reverse debug
		_SQUELCH = !debug;
	}
	
	/**
	 * Initializes the exception, prints the trace, and exits the program.
	 *
	 * @since 2017/02/28
	 */
	public TODO()
	{
		this(null);
	}
	
	/**
	 * Initializes the exception, prints the trace, and exits the program.
	 *
	 * @param __s Message input.
	 * @since 2018/09/29
	 */
	public TODO(String __s)
	{
		super(__s);
		
		// Detect TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			ps.println("****************************************************");
			ps.print("INCOMPLETE CODE HAS BEEN REACHED: ");
			if (__s != null)
				ps.print(__s);
			ps.println();
			
			// Print the current thread
			ps.print("IN THREAD: ");
			ps.println(Thread.currentThread());
			
			// Spacer
			ps.println();
			
			// Print the trace
			this.printStackTrace(ps);
			
			// Ending banner
			ps.println("****************************************************");
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		
		// {@squirreljme.property
		// cc.squirreljme.notodoexit=(boolean)
		// If this is {@code true} then the ToDo exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.notodoexit")))
			try
			{
				System.exit(126);
			}
		
			// Ignore
			catch (SecurityException e)
			{
			}
	}
	
	/**
	 * Specifies that the integer value is missing.
	 *
	 * @return An integer, but is not returned from.
	 * @since 2017/10/27
	 */
	public static final int missingInteger()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Specifies that the object value is missing.
	 *
	 * @param <T> The object to miss.
	 * @return Should return that object, but never does.
	 * @since 2017/10/24
	 */
	public static final <T> T missingObject()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Prints a note to standard error about something that is incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/02
	 */
	public static final void note(String __fmt, Object... __args)
	{
		TODO.__note("TODO", __fmt, __args);
	}
	
	/**
	 * Formats a call trace element in a condensed form.
	 *
	 * @param __e The element to print out.
	 * @return The condensed string.
	 * @since 2018/05/03
	 */
	static final String __formatCondensedTrace(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String cn = __e.className(),
			mn = __e.methodName(),
			md = __e.methodDescriptor(),
			fi = __e.file();
		long ad = __e.address();
		int ln = __e.line();
		
		StringBuilder sb = new StringBuilder();
		
		// Location
		if (cn != null)
		{
			// Get identifier part
			int ld = cn.lastIndexOf('.');
			if (ld < 0)
				if ((ld = cn.lastIndexOf('/')) < 0)
					ld = 0;
			
			// Print slimmed down packages since they could be guessed
			for (int i = 0, n = cn.length(); i >= 0 && i < n;)
			{
				// Before the last dot, print single and skip ahead
				if (i < ld)
				{
					sb.append(cn.charAt(i));
					
					int ldi = cn.indexOf('.', i);
					if (ldi < 0)
						ldi = cn.indexOf('/', i);
					
					i = ldi + 1;
				}
				
				// Finish string
				else
				{
					if (i > 0)
						sb.append('.');
					sb.append(cn.substring(i));
					break;
				}
			}
		}
		sb.append("::");
		if (mn != null)
			sb.append(mn);
		/*if (md != null)
			sb.append(md);*/
		
		// Address, if it is valid
		if (ad != -1L)
		{
			sb.append(" @ ");
			sb.append(Long.toString(ad, 16).toUpperCase());
			sb.append("h");
		}
		
		// Add file/line information if it is valid
		if (fi != null)
		{
			sb.append(" (");
			
			// Use blank class name if not specified
			if (cn == null)
				cn = "";
			
			// The class will end with the Java extension
			int ld = cn.lastIndexOf('.');
			if (ld < 0)
				ld = cn.lastIndexOf('/');
			if (ld >= 0)
				cn = cn.substring(ld + 1);
			
			// Determine how many charcters the class name and the file
			// name have in common, so that it can be shortened
			int deep = 0;
			for (int n = Math.min(cn.length(), fi.length()); deep < n; deep++)
				if (cn.charAt(deep) != fi.charAt(deep))
					break;
			
			// Use whole name
			if (deep == 0)
				sb.append(fi);
			
			// Use fragment
			else
			{
				// But only if it does not end in .java, this makes it
				// implied since it is always around
				String sub = fi.substring(deep);
				if (!sub.equals(".java"))
				{
					sb.append('*');
					sb.append(sub);
				}
			}
			
			if (ln >= 0)
			{
				sb.append(':');
				sb.append(ln);
			}
			
			sb.append(')');
		}
		
		return sb.toString();
	}
	
	/**
	 * Formats the call trace element.
	 *
	 * @param __e The element to format.
	 * @return The formatted string.
	 * @since 2018/04/02
	 */
	static final String __formatTrace(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String cn = __e.className(),
			mn = __e.methodName(),
			md = __e.methodDescriptor(),
			fi = __e.file();
		long ad = __e.address();
		int ln = __e.line();
		
		StringBuilder sb = new StringBuilder();
		
		// Location
		if (cn != null)
			sb.append(cn);
		sb.append("::");
		if (mn != null)
			sb.append(mn);
		
		if (md != null)
			sb.append(md);
		
		// Address, if it is valid
		if (ad != -1L)
		{
			sb.append(" @ ");
			sb.append(ad);
		}
		
		// Add file/line information if it is valid
		if (fi != null)
		{
			sb.append(" (");
			sb.append(fi);
			
			if (ln >= 0)
			{
				sb.append(':');
				sb.append(ln);
			}
			
			sb.append(')');
		}
		
		return sb.toString();
	}
	
	
	/**
	 * Prints a note to standard error about something that is incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/02
	 */
	static final void __note(String __pfx, String __fmt, Object... __args)
	{
		// If messages are squelched, ignore anything output
		if (TODO._SQUELCH)
			return;
		
		// Only print if the stream is valid
		PrintStream ps = System.err;
		if (ps == null)
			return;
		
		// Prevent infinite recursion when printing notes because things might
		// get stuck here if code that this method calls ends up calling
		// things
		boolean printy = false;
		synchronized (TODO.class)
		{
			// Use simple lock counter
			if (!TODO._notelock)
				try
				{
					// Lock note
					TODO._notelock = true;
					printy = true;
				}
				finally
				{
				}
			
			// Add marker for suppressed notes
			else
				TODO._supressednotes++;
		}
		
		// Print it out?
		if (printy)
			try
			{
				ps.print(__pfx);
				ps.print(GuestDepth.guestDepth());
				ps.print(' ');
				ps.print(TODO.__formatCondensedTrace(TODO.__where()));
				ps.print(" -- ");
				
				ps.printf(__fmt, __args);
				
				// Add markers to indicate the number of notes which were
				// suppressed
				int suppressed = TODO._supressednotes;
				TODO._supressednotes = 0;
				for (int i = 0; i < suppressed; i++)
					ps.print('^');
				
				ps.println();
			}
			finally
			{
				// In case of exceptions, this will always be unlocked
				TODO._notelock = false;
			}
	}
	
	/**
	 * Determines where the code is in the call stack.
	 *
	 * @return The call trace element for the current location.
	 * @since 2018/04/02
	 */
	static final CallTraceElement __where()
	{
		// For the SquirrelJME runtime, use the debug stuff to get the
		// current call trace
		CallTraceElement[] stack = CallTraceElement.traceResolve(
			CallTraceElement.traceRaw());
		
		// Get the first one which is not in this class
		for (CallTraceElement e : stack)
		{
			String cn = e.className();
			if (cn == null)
				cn = "<unknown>";
			
			if (!cn.startsWith("todo/"))
				return e;
		}
		
		// Unknown
		return new CallTraceElement();
	}
}

Added modules/cldc-compact/src/main/java/todo/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the exception indicating that incomplete code has been
 * reached.
 *
 * @since 2017/02/28
 */

package todo;

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

package io;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests read line on EOF.
 *
 * @since 2018/12/08
 */
public class TestReadLineEOF
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(
			new ByteArrayInputStream(
			"Rodents are softly cute!\nSquirrels!\r\nMice!\rAnd rats!".
			getBytes("utf-8")), "utf-8"));
		
		String ln;
		int i = 1;
		while (null != (ln = br.readLine()))
			this.secondary("line-" + (i++), ln);
		
		return i;
	}
}

Added modules/cldc-compact/src/test/java/io/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * IO Tests.
 *
 * @since 2018/12/08
 */

package io;

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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that arrays work properly.
 *
 * @since 2018/11/14
 */
public class TestArray
	extends TestRunnable
{
	/** Storage count. */
	public static final int COUNT =
		8;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0x4C6F7665596F7521L);
		
		// Store values
		boolean az[] = new boolean[COUNT];
		for (int i = 0; i < COUNT; i++)
			az[i] = rand.nextBoolean();
		
		byte ab[] = new byte[COUNT];
		for (int i = 0; i < COUNT; i++)
			ab[i] = (byte)rand.nextInt();
		
		short as[] = new short[COUNT];
		for (int i = 0; i < COUNT; i++)
			as[i] = (short)rand.nextInt();
		
		char ac[] = new char[COUNT];
		for (int i = 0; i < COUNT; i++)
			ac[i] = (char)rand.nextInt();
		
		int ai[] = new int[COUNT];
		for (int i = 0; i < COUNT; i++)
			ai[i] = rand.nextInt();
		
		long al[] = new long[COUNT];
		for (int i = 0; i < COUNT; i++)
			al[i] = rand.nextLong();
		
		float af[] = new float[COUNT];
		for (int i = 0; i < COUNT; i++)
			af[i] = rand.nextFloat();
		
		double ad[] = new double[COUNT];
		for (int i = 0; i < COUNT; i++)
			ad[i] = rand.nextDouble();
		
		// Read all values
		for (int i = 0; i < COUNT; i++)
			this.secondary("boolean-" + i, az[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("byte-" + i, ab[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("short-" + i, as[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("char-" + i, ac[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("int-" + i, ai[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("long-" + i, al[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("float-" + i, Float.floatToRawIntBits(af[i]));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("double-" + i, Double.doubleToRawLongBits(ad[i]));
	}
}

Added modules/cldc-compact/src/test/java/lang/TestArrayClone.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 lang;

import java.util.Arrays;
import net.multiphasicapps.tac.TestBoolean;

/**
 * This tests that array cloning is correct.
 *
 * @since 2019/12/25
 */
public class TestArrayClone
	extends TestBoolean
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public final boolean test()
	{
		// Setup new array
		int[] array = new int[12];
		for (int i = 0; i < 12; i++)
			array[i] = i;
		
		int[] cloned = array.clone();
		return Arrays.equals(array, cloned) && array != cloned;
	}
}

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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the number of bits in values.
 *
 * @since 2018/11/11
 */
public class TestBitCount
	extends TestSupplier<Integer>
{
	/** The number of values to count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		Random rand = new Random(0xDEADBEEF);
		
		int rv = 0;
		for (int i = 0; i < COUNT; i++)
		{
			int test = rand.nextInt(),
				bits = Integer.bitCount(test);
			
			this.secondary("" + test, bits);
			
			rv += bits;
		}
		
		return rv;
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests division by zero.
 *
 * @since 2018/12/04
 */
public class TestDivideByZero
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Integer test()
	{
		return 42 / 0;
	}
}

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

package lang;

import lang.extra.ABasicEnum;
import lang.extra.AClassEnum;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests enumerations.
 *
 * @since 2018/12/08
 */
public class TestEnumValueOf
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public String test()
	{
		return ABasicEnum.A.name() +
			Enum.<ABasicEnum>valueOf(ABasicEnum.class, "B") +
			AClassEnum.B.boop() +
			Enum.<AClassEnum>valueOf(AClassEnum.class, "C").boop();
	}
}

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

package lang;

import java.util.NoSuchElementException;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests exceptions being caught in higher stack frames.
 *
 * @since 2018/12/06
 */
public class TestExceptionCatchUp
	extends TestSupplier<String>
{
	/**
	 * Throws an exception.
	 *
	 * @since 2018/12/06
	 */
	public final String levelA()
	{
		return this.levelB();
	}
	
	/**
	 * Throws an exception.
	 *
	 * @since 2018/12/06
	 */
	public final String levelB()
	{
		throw new NoSuchElementException("TEST");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String test()
	{
		try
		{
			return this.levelA();
		}
		catch (NoSuchElementException t)
		{
			throw new IllegalArgumentException(t);
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that the current thread holds the lock.
 *
 * @since 2018/11/21
 */
public class TestHoldLock
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		this.secondary("before", Thread.holdsLock(this));
		
		synchronized (this)
		{
			this.secondary("during", Thread.holdsLock(this));
		}
		
		this.secondary("after", Thread.holdsLock(this));
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests a member inner class being able to access a protected member in the
 * parent class.
 *
 * @since 2018/10/13
 */
public class TestInnerClassOnProtected
	extends TestSupplier<Integer>
{
	/** The value to use. */
	protected int value;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public Integer test()
	{
		new Inner();
		return this.value;
	}
	
	/**
	 * Inner class.
	 *
	 * @since 2018/10/13
	 */
	public class Inner
	{
		/**
		 * Sets the value.
		 *
		 * @since 2018/10/13
		 */
		public Inner()
		{
			TestInnerClassOnProtected.this.value = 1234;
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests integer decoding.
 *
 * @since 2018/11/11
 */
public class TestIntegerDecode
	extends TestSupplier<Integer>
{
	/** Values to test. */
	private static final String[] _VALUES =
		new String[]
		{
			"0x1234",
			"0X1234",
			"#1234",
			"01234",
			"1234",
			"-0x1234",
			"-0X1234",
			"-#1234",
			"-01234",
			"-1234",
			"+0x1234",
			"+0X1234",
			"+#1234",
			"+01234",
			"+1234",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		int rv = 0;
		for (String s : _VALUES)
		{
			int v = Integer.decode(s);
			rv += v;
			this.secondary(s, v);
		}
		
		return rv;
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * This tests that {@link Integer#parseInt(int, int)} when the input value
 * overflows it throws an exception.
 *
 * @since 2018/10/13
 */
public class TestIntegerParseIntOverflow
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String test()
	{
		StringBuilder sb = new StringBuilder();
		
		// Check overflow for all radixes
		int rv = 0;
		for (int r = Character.MIN_RADIX; r <= Character.MAX_RADIX; r++)
			try
			{
				// This is a really long value which is valid for all radixes
				// it is either a 33-bit integer or log(33)??
				Integer.parseInt("-111111111111111111111111111111111", r);
				
				sb.append(Character.toUpperCase(
					Character.forDigit(r, Character.MAX_RADIX)));
			}
			catch (NumberFormatException e)
			{
				sb.append(Character.forDigit(r, Character.MAX_RADIX));
			}
		
		return sb.toString();
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * This tests that {@link Integer#parseInt(int, int)} when the input value
 * overflows it throws an exception, but where each character is the max for
 * the given radix.
 *
 * @since 2018/10/13
 */
public class TestIntegerParseIntOverflowMax
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String test()
	{
		StringBuilder sb = new StringBuilder();
		
		// Check overflow for all radixes
		int rv = 0;
		for (int r = Character.MIN_RADIX; r <= Character.MAX_RADIX; r++)
			try
			{
				// This is a really long value which is valid for all radixes
				// it is either a 33-bit integer or log(33)??
				char c = Character.forDigit(r - 1, r);
				StringBuilder seq = new StringBuilder("-");
				for (int i = 0; i < 33; i++)
					seq.append(c);
				
				// Decode that max value
				Integer.parseInt(seq.toString(), r);
				
				sb.append(Character.toUpperCase(
					Character.forDigit(r, Character.MAX_RADIX)));
			}
			catch (NumberFormatException e)
			{
				sb.append(Character.forDigit(r, Character.MAX_RADIX));
			}
		
		return sb.toString();
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that private calls can be done.
 *
 * @since 2018/10/10
 */
public class TestInvokePrivate
	extends TestRunnable
{
	/**
	 * Private call.
	 *
	 * @since 2018/10/10
	 */
	private void doPrivate()
	{
		this.secondary("private", true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doPrivate();
	}
}

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

package lang;

/**
 * Tests calling a private method where the extending class also has a method
 * with the same name and descriptor, but is public.
 *
 * @since 2018/10/10
 */
public class TestInvokePrivateInSuper
	extends __InvokePrivateInSuper__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doSuper();
	}
	
	/**
	 * Private method in current class, named the same but is public since it
	 * was hidden in a super class.
	 *
	 * @since 2018/10/10
	 */
	public void doPrivate()
	{
		this.secondary("instanceprivatewascalled", false);
	}
}

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

package lang;

/**
 * Tests that super calls can be done.
 *
 * @since 2018/10/10
 */
public class TestInvokeSuper
	extends __InvokeSuper__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void doSuper()
	{
		this.secondary("childbefore", true);
		
		super.doSuper();
		
		this.secondary("childafter", true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doSuper();
	}
}

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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests the log of a number.
 *
 * @since 2018/11/03
 */
public class TestMathLog
	extends TestRunnable
{
	/** Random sequence count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	@SuppressWarnings({"deprecated"})
	public void test()
	{
		// Linear sequence of values
		for (int i = -2; i <= 128; i++)
			this.secondary(String.format("value-%03d", i),
				Double.doubleToRawLongBits(Math.log(i)));
		
		// Random sequence of bits, generate NaN and such
		Random rand = new Random(0xDEADBEEF);
		for (int i = 0; i < COUNT; i++)
		{
			long raw = rand.nextLong();
			this.secondary(String.format("random-%d", raw),
				Double.doubleToRawLongBits(Math.log(
					Double.longBitsToDouble(raw))));
		}
	}
}


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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests the square root of a number.
 *
 * @since 2018/11/03
 */
public class TestMathSqrt
	extends TestRunnable
{
	/** Random sequence count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public void test()
	{
		// Linear sequence of values
		for (int i = -2; i <= 128; i++)
			this.secondary(String.format("value-%03d", i),
				Double.doubleToRawLongBits(Math.sqrt(i)));
		
		// Random sequence of bits, generate NaN and such
		Random rand = new Random(0xDEADBEEF);
		for (int i = 0; i < COUNT; i++)
		{
			long raw = rand.nextLong();
			this.secondary(String.format("random-%d", raw),
				Double.doubleToRawLongBits(Math.sqrt(
					Double.longBitsToDouble(raw))));
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that monitor notification works.
 *
 * @since 2018/11/21
 */
public class TestMonitorNotify
	extends TestRunnable
{
	/** Counter. */
	volatile int _count;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		// Note
		this.secondary("before-lock", this._count++);
		
		// Lock the monitor for this
		synchronized (this)
		{
			// Note
			this.secondary("in-lock", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Sub__(), "MonitorNotifyTest");
			t.start();
			
			// Note
			this.secondary("thread-created", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				this.wait();
				
				// Note
				this.secondary("expected-resume", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock", this._count++);
	}
	
	/**
	 * Sub-thread which runs.
	 *
	 * @since 2018/11/21
	 */
	final class __Sub__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/21
		 */
		@Override
		public void run()
		{
			// Lock on that monitor
			TestMonitorNotify tmn = TestMonitorNotify.this;
			synchronized (tmn)
			{
				// Note
				tmn.secondary("sub-in-lock", tmn._count++);
				
				// Notify other thread
				tmn.notify();
				
				// Note
				tmn.secondary("sub-after-notify", tmn._count++);
				
				// Sleep for a bit, for sanity
				try
				{
					Thread.sleep(1000);
				}
				catch (InterruptedException e)
				{
				}
				
				// Sub continued
				tmn.secondary("sub-after-sleep", tmn._count++);
			}
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests allocation of a multi-dimensional array.
 *
 * @since 2018/11/03
 */
public class TestMultiANewArray
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public String test()
	{
		// Allocate array
		Integer[][][] array = new Integer[6][7][4];
		
		// Determine the number of elements
		int total = 0;
		for (int i = 0, in = array.length; i < in; i++)
		{
			// Down to next level
			Integer[][] subi = array[i];
			for (int j = 0, jn = subi.length; j < jn; j++)
				total += subi[j].length;
		}
		
		// Is this time
		this.secondary("total", total);
		
		// Use the name of it
		return array.getClass().getName();
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests new class instance.
 *
 * @since 2018/12/04
 */
public class TestNewInstance
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String test()
		throws Throwable
	{
		return SpawnedClass.class.newInstance().toString();
	}
	
	/**
	 * The class to be spawed.
	 *
	 * @since 2018/12/04
	 */
	public static final class SpawnedClass
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public String toString()
		{
			return "Hello squirrels are cute!";
		}
	}
}

Added modules/cldc-compact/src/test/java/lang/TestStringIntern.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that string interning works properly.
 *
 * @since 2019/05/24
 */
public class TestStringIntern
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/24
	 */
	@Override
	public void test()
	{
		this.secondary("cca", "squirrel" == "acorn");
		this.secondary("ccb", "squirrel" == "squirrel");
		
		this.secondary("cna", "squirrel" == new String("acorn"));
		this.secondary("cnb", "squirrel" == new String("squirrel"));
		
		this.secondary("cia", "squirrel" == "acorn".intern());
		this.secondary("cib", "squirrel" == "squirrel".intern());
		
		this.secondary("cxa",
			"squirrel" == new String("acorn").intern());
		this.secondary("cxb",
			"squirrel" == new String("squirrel").intern());
			
		this.secondary("iia", "squirrel".intern() ==
			new String("acorn").intern());
		this.secondary("iib", "squirrel".intern() ==
			new String("squirrel").intern());
	}
}

Added modules/cldc-compact/src/test/java/lang/TestStringRegionMatches.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
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that {@link String#regionMatches(boolean, int, String, int, int, int)}
 * is working.
 *
 * @since 2020/01/18
 */
public class TestStringRegionMatches
	extends TestRunnable
{
	/** String A. */
	public static final String A =
		"Hello! Squirrels are adorable!";
	
	/** String B. */
	public static final String B =
		"AdoRable squirRels are hello!";
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/18
	 */
	@Override
	public void test()
	{
		for (boolean igncase = false;; igncase = true)
		{
			char key = (igncase ? 'i' : 'c');
			
			this.secondary("same" + key,
				A.regionMatches(igncase, 0, A, 0, A.length()));
				
			this.secondary("sameover" + key,
				A.regionMatches(igncase, 0, A, 0, A.length() + 3));
			this.secondary("samehalf" + key,
				A.regionMatches(igncase, 0, A, 0, A.length() / 2));
			
			this.secondary("neglen" + key,
				A.regionMatches(igncase, 0, A, 0, -3));
			
			this.secondary("samenega" + key,
				A.regionMatches(igncase, -7, A, 7, 9));
			this.secondary("samenegb" + key,
				A.regionMatches(igncase, 7, A, -7, 9));
			
			this.secondary("hello" + key,
				A.regionMatches(igncase, 0, B, 23, 5));
			this.secondary("squirrels" + key,
				A.regionMatches(igncase, 7, B, 9, 9));
			this.secondary("are" + key,
				A.regionMatches(igncase, 17, B, 19, 3));
			this.secondary("adorable" + key,
				A.regionMatches(igncase, 21, B, 0, 8));
			
			if (igncase)
				return;
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests string trim.
 *
 * @since 2018/12/05
 */
public class TestStringTrim
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void test()
	{
		this.secondary("a", "squirrels are cute".trim());
		this.secondary("b", "  \t      squirrels are cute".trim());
		this.secondary("c", "squirrels are cute    \t".trim());
		this.secondary("d", "       \tsquirrels are cute \t    ".trim());
		this.secondary("e", "           ".trim());
		this.secondary("f", "           ".trim());
	}
}

Added modules/cldc-compact/src/test/java/lang/TestSynchronizedMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests synchronized methods.
 *
 * @since 2018/12/04
 */
public class TestSynchronizedMethod
	extends TestRunnable
{
	/** Counter. */
	volatile int _count;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		// Note
		this.secondary("before-lock", this._count++);
		
		// Lock the monitor for this
		synchronized (this)
		{
			// Note
			this.secondary("in-lock", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Sub__(), "SynchronizedMethodTest");
			t.start();
			
			// Note
			this.secondary("thread-created", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				this.wait();
				
				// Note
				this.secondary("expected-resume", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock", this._count++);
		
		// Perform another test
		synchronized (TestSynchronizedMethod.class)
		{
			// Note
			this.secondary("in-lock2", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Cl__(), "SynchronizedMethodTest2");
			t.start();
			
			// Note
			this.secondary("thread-created2", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				TestSynchronizedMethod.class.wait();
				
				// Note
				this.secondary("expected-resume2", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted2", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock2", this._count++);
	}
	
	/**
	 * Tests synchronized method.
	 *
	 * @since 2018/12/04
	 */
	public synchronized void testSomething()
	{
		// Note
		this.secondary("sub-in-lock", this._count++);
		
		// Notify other thread
		this.notify();
		
		// Note
		this.secondary("sub-after-notify", this._count++);
		
		// Sleep for a bit, for sanity
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Sub continued
		this.secondary("sub-after-sleep", this._count++);
	}
	
	/**
	 * Same as above, but static.
	 *
	 * @param __m The method to report to.
	 * @since 2018/12/04
	 */
	public static synchronized void testStatic(TestSynchronizedMethod __m)
	{
		// Note
		__m.secondary("sub-in-lock2", __m._count++);
		
		// Notify other thread
		TestSynchronizedMethod.class.notify();
		
		// Note
		__m.secondary("sub-after-notify2", __m._count++);
		
		// Sleep for a bit, for sanity
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Sub continued
		__m.secondary("sub-after-sleep2", __m._count++);
	}
	
	/**
	 * Sub-thread which runs on the class!
	 *
	 * @since 2018/12/04
	 */
	final class __Cl__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public void run()
		{
			TestSynchronizedMethod.testStatic(TestSynchronizedMethod.this);
		}
	}
	
	/**
	 * Sub-thread which runs.
	 *
	 * @since 2018/12/04
	 */
	final class __Sub__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public void run()
		{
			TestSynchronizedMethod.this.testSomething();
		}
	}
}

Added modules/cldc-compact/src/test/java/lang/TestThreadNew.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
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the creation of a new thread.
 *
 * @since 2018/11/20
 */
public class TestThreadNew
	extends TestSupplier<Boolean>
{
	/** Did things? */
	volatile boolean _didstuff;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public Boolean test()
	{
		// Create and start thread to set the boolean flag
		new Thread(new __Task__()).start();
		
		// Run thread and wait, this should result in did being performed
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Did stuff
		return this._didstuff;
	}
	
	/**
	 * The task to run.
	 *
	 * @since 2018/11/20
	 */
	final class __Task__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/20
		 */
		@Override
		public void run()
		{
			// Just set as true!
			TestThreadNew.this._didstuff = true;
		}
	}
}

Added modules/cldc-compact/src/test/java/lang/TestThrowInSynchronized.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 lang;

import java.util.NoSuchElementException;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This ensures that throwing excpetions within synchronized methods works
 * properly.
 *
 * @since 2019/12/24
 */
public class TestThrowInSynchronized
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	public void test()
	{
		synchronized (new Object())
		{
			TestThrowInSynchronized.levelA(new Object());
		}
	}
	
	/**
	 * First level call.
	 *
	 * @param __v The value.
	 * @since 2019/12/24
	 */
	public static final void levelA(Object __v)
	{
		synchronized (__v)
		{
			TestThrowInSynchronized.levelB(__v);
		}
	}
	
	/**
	 * Second level call.
	 *
	 * @param __v The value.
	 * @since 2019/12/24
	 */
	public static final void levelB(Object __v)
	{
		synchronized (__v)
		{
			throw new NoSuchElementException();
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests trailing zero count.
 *
 * @since 2018/11/11
 */
public class TestTrailingZeros
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		int rv = Integer.numberOfTrailingZeros(0);
		this.secondary("zero", rv);
		
		for (int i = 0; i < 31; i++)
		{
			int v = Integer.numberOfTrailingZeros(1 << i);
			
			this.secondary("b" + i, v);
			
			rv += v;
		}
		
		for (int i = 0; i < 31; i++)
		{
			int v = Integer.numberOfTrailingZeros(0xDEADBEEF << i);
			
			this.secondary("d" + i, v);
			
			rv += v;
		}
		
		return rv;
	}
}

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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests that reading the array causes an out of bounds to occur.
 *
 * @since 2018/12/04
 */
public class TestVMIndexOutOfBounds
	extends TestSupplier<String>
{
	/** Strings to test. */
	private static final String[] _STRINGS =
		{
			"Squirrels are cute!",
			"They really are!",
			"So are red pandas!",
			"I love you so much!",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String test()
	{
		return _STRINGS[5];
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests interrupted, monitors, and threads as well.
 *
 * @since 2018/11/20
 */
public class TestVMInterrupt
	extends TestRunnable
{
	/** The object to lock on. */
	protected final Object lock =
		new Object();
	
	/** The order of things, is a check for locks. */
	protected volatile int order;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public void test()
	{
		Thread self = Thread.currentThread();
		
		// Note
		this.secondary("a-before-lock", order++);
		
		// Lock on this object
		synchronized (this.lock)
		{
			// Note
			this.secondary("a-after-lock", order++);
			
			// Setup thread to run
			Thread runner = new Thread(new __Runner__(
				self), "VMInterruptChild");
			runner.start();
			
			// Note
			this.secondary("a-thread-created", order++);
			this.secondary("a-before-wait", self.isInterrupted());
			
			// Wait for a notification
			try
			{
				this.lock.wait();
				
				// Note
				this.secondary("a-was-not-interrupted", order++);
			}
			catch (InterruptedException e)
			{
				// Note
				this.secondary("a-was-interrupted", order++);
			}
			
			// Note
			this.secondary("a-after-wait", self.isInterrupted());
		}
		
		// Note
		this.secondary("a-done", order++);
	}
	
	/**
	 * Performs the second part of the test run.
	 *
	 * @since 2018/11/20
	 */
	final class __Runner__
		implements Runnable
	{
		/** The thread to signal. */
		protected final Thread signal;
		
		/**
		 * Initializes the runner.
		 *
		 * @param __t The thread to signal.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/20
		 */
		public __Runner__(Thread __t)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.signal = __t;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/20
		 */
		@Override
		public void run()
		{
			// Lock
			synchronized (TestVMInterrupt.this.lock)
			{
				// Note
				TestVMInterrupt.this.secondary("b-in-lock",
					TestVMInterrupt.this.order++);
				
				// Interrupt A
				this.signal.interrupt();
				
				// Note
				TestVMInterrupt.this.secondary("b-interrupt-a",
					TestVMInterrupt.this.order++);
				
				// Sleep for a bit
				try
				{
					// Note
					TestVMInterrupt.this.secondary("b-dosleep",
						TestVMInterrupt.this.order++);
					
					// Sleep for a bit longer than the main thread
					Thread.sleep(3000);
					
					// Note
					TestVMInterrupt.this.secondary("b-sleepdone",
						TestVMInterrupt.this.order++);
				}
				catch (InterruptedException e)
				{
					TestVMInterrupt.this.secondary("b-interrupted",
						TestVMInterrupt.this.order++);
				}
				
				// About to unlock
				TestVMInterrupt.this.secondary("b-about-to-unlock",
					TestVMInterrupt.this.order++);
			}
		}
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests calling a private method where the extending class also has a method
 * with the same name and descriptor, but is public.
 *
 * @since 2018/10/10
 */
abstract class __InvokePrivateInSuper__
	extends TestRunnable
{
	/**
	 * Super method call.
	 *
	 * @since 2018/10/10
	 */
	public final void doSuper()
	{
		this.doPrivate();
	}
	
	/**
	 * Private method in superclass.
	 *
	 * @since 2018/10/10
	 */
	private void doPrivate()
	{
		this.secondary("superprivate", true);
	}
}

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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Super class to test execution with.
 *
 * @since 2018/10/10
 */
abstract class __InvokeSuper__
	extends TestRunnable
{
	/**
	 * Tests the super call.
	 *
	 * @since 2018/10/10
	 */
	public void doSuper()
	{
		this.secondary("super", true);
	}
}

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

package lang.extra;

/**
 * A basic enumeration.
 *
 * @since 2018/12/08
 */
public enum ABasicEnum
{
	/** A. */
	A,
	
	/** B. */
	B,
	
	/** C. */
	C,
	
	/** End. */
	;
}

Added modules/cldc-compact/src/test/java/lang/extra/AClassEnum.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lang.extra;

/**
 * This is a class enumeration.
 *
 * @since 2018/12/08
 */
public enum AClassEnum
{
	/** A. */
	A
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "Love you!";
		}
	},
	
	/** B. */
	B
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "You are beautiful!";
		}
	},
	
	/** C. */
	C
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "You are wonderful!";
		}
	},
	
	/** End. */
	;
	
	/**
	 * Returns a message.
	 *
	 * @return A message.
	 * @since 2018/12/08
	 */
	public abstract String boop();
}

Added modules/cldc-compact/src/test/java/lang/extra/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Extra classes.
 *
 * @since 2018/12/08
 */

package lang.extra;

Added modules/cldc-compact/src/test/java/lang/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Java language tests.
 *
 * @since 2018/10/10
 */

package lang;

Added modules/cldc-compact/src/test/java/squirreljme/TestArrayLength.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package squirreljme;

import cc.squirreljme.jvm.Assembly;
import net.multiphasicapps.tac.TestRunnable;

public class TestArrayLength
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2020/02/23
	 */
	@Override
	public final void test()
	{
		Object z = new boolean[1],
			b = new byte[2],
			s = new short[3],
			c = new char[4],
			i = new int[5],
			j = new long[6],
			f = new float[7],
			d = new double[8],
			l = new Object[9],
			o = new Object();
		
		// As pointers
		this.secondary("zp",
			Assembly.arrayLength(Assembly.objectToPointer(z)));
		this.secondary("bp",
			Assembly.arrayLength(Assembly.objectToPointer(b)));
		this.secondary("sp",
			Assembly.arrayLength(Assembly.objectToPointer(s)));
		this.secondary("cp",
			Assembly.arrayLength(Assembly.objectToPointer(c)));
		this.secondary("ip",
			Assembly.arrayLength(Assembly.objectToPointer(i)));
		this.secondary("jp",
			Assembly.arrayLength(Assembly.objectToPointer(j)));
		this.secondary("fp",
			Assembly.arrayLength(Assembly.objectToPointer(f)));
		this.secondary("dp",
			Assembly.arrayLength(Assembly.objectToPointer(d)));
		this.secondary("lp",
			Assembly.arrayLength(Assembly.objectToPointer(l)));
		this.secondary("op",
			Assembly.arrayLength(Assembly.objectToPointer(o)));
		
		// As objects
		this.secondary("z", Assembly.arrayLength(z));
		this.secondary("b", Assembly.arrayLength(b));
		this.secondary("s", Assembly.arrayLength(s));
		this.secondary("c", Assembly.arrayLength(c));
		this.secondary("i", Assembly.arrayLength(i));
		this.secondary("j", Assembly.arrayLength(j));
		this.secondary("f", Assembly.arrayLength(f));
		this.secondary("d", Assembly.arrayLength(d));
		this.secondary("l", Assembly.arrayLength(l));
		this.secondary("o", Assembly.arrayLength(o));
	}
}

Added modules/cldc-compact/src/test/java/squirreljme/TestErrorGetSet.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package squirreljme;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that error getting and setting works properly.
 *
 * @since 2020/02/26
 */
public class TestErrorGetSet
	extends TestRunnable
{
	/** The error code to use. */
	private static final int _ERROR_CODE =
		12;
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/26
	 */
	@Override
	public void test() throws Throwable
	{
		int orig = Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.GARBAGE_COLLECT);
		
		int fset = Assembly.sysCallV(SystemCallIndex.ERROR_SET,
			SystemCallIndex.GARBAGE_COLLECT, _ERROR_CODE);
		
		this.secondary("sameasorig", (orig == fset));
		
		int fnow = Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.GARBAGE_COLLECT);
		
		this.secondary("isset", (fnow == _ERROR_CODE));
	}
}

Added modules/cldc-compact/src/test/java/squirreljme/TestPointerAccess.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 squirreljme;

import cc.squirreljme.jvm.Assembly;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that pointer access makes sense.
 *
 * @since 2019/12/21
 */
public class TestPointerAccess
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public void test()
	{
		// Create a new object which we will get a pointer of
		Object object = new Object();
		
		// This object cannot be null
		long pointer = Assembly.objectToPointer(object);
		this.secondary("otpnotnull", pointer != 0); 
		
		// Reversing this operation should return the original object
		Object from = Assembly.pointerToObject(pointer);
		this.secondary("sameobject", object == from);
		
		// The zero pointer must be null
		Object ozero = Assembly.pointerToObject(0);
		this.secondary("zeroisnull", ozero == null);
		
		// The null object must be zero
		long pnull = Assembly.objectToPointer(null);
		this.secondary("nulliszero", pnull == 0L);
	}
}

Added modules/cldc-compact/src/test/java/squirreljme/TestSystemTime.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 squirreljme;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that the system time can be obtained without error.
 *
 * @since 2019/05/23
 */
public class TestSystemTime
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/23
	 */
	@Override
	public void test()
	{
		Assembly.sysCall(SystemCallIndex.TIME_MILLI_WALL);
		this.secondary("mw", Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.TIME_MILLI_WALL));
		
		Assembly.sysCall(SystemCallIndex.TIME_NANO_MONO);
		this.secondary("nm", Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.TIME_NANO_MONO));
	}
}

Added modules/cldc-compact/src/test/java/squirreljme/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains tests for the SquirrelJME specific system interfaces
 * and system calls.
 *
 * @since 2019/05/23
 */

package squirreljme;

Added modules/cldc-compact/src/test/java/util/TestArrayBinarySearch.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package util;

import java.util.Arrays;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Test that binary search works properly.
 *
 * @since 2018/10/28
 */
public class TestArrayBinarySearch
	extends TestSupplier<Long>
{
	/** The array length. */
	public static final int LENGTH =
		31;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Long test()
	{
		long rv = 0;
		
		// Setup array with values
		int[] values = new int[LENGTH];
		for (int i = 0; i < LENGTH; i++)
			values[i] = i * 2;
		
		// Search for all values
		for (int i = 0; i < LENGTH * 2; i++)
		{
			// Find the value
			int res = Arrays.binarySearch(values, i);
			
			// Value is even, it will be in the array
			int want;
			if ((i & 1) == 0)
				want = i / 2;
			
			// Is odd, will not be in the array
			else
				want = -((i / 2) + 2);
			
			// Is this our expected value?
			if (res == want)
				rv |= (1L << (long)i);
		}
		
		return rv;
	}
}

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

package util;

import java.util.ArrayDeque;

/**
 * Tests array deques.
 *
 * @since 2019/01/20
 */
public class TestArrayDequeDeque
	extends __TestDeque__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/01/20
	 */
	public TestArrayDequeDeque()
	{
		super(new ArrayDeque<Number>(), false);
	}
}

Added modules/cldc-compact/src/test/java/util/TestArrayList.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.ArrayList;

/**
 * Tests array list.
 *
 * @since 2019/05/08
 */
public class TestArrayList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestArrayList()
	{
		super(new ArrayList<String>());
	}
}

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

package util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that {@link HashMap} works properly.
 *
 * @since 2018/10/07
 */
public class TestHashMap
	extends TestRunnable
{
	/** The map to test on. */
	protected final Map<Integer, String> map;
	
	/**
	 * Initializes the test using the base map.
	 *
	 * @since 2018/11/05
	 */
	public TestHashMap()
	{
		this(new HashMap<Integer, String>());
	}
	
	/**
	 * Initializes the test using the given map.
	 *
	 * @param __m The map to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/05
	 */
	public TestHashMap(Map<Integer, String> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.map = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public void test()
	{
		// Initialize a map to work with
		Map<Integer, String> map = this.map;
		
		// Initial size and such
		this.secondary("initempty", map.isEmpty());
		this.secondary("initsize", map.size());
		
		// Some initial values to use
		Integer ka = Integer.valueOf(1989),
			kb = Integer.valueOf(2018);
		String va = "Squirrels",
			vb = "Cute";
		
		// Store into the map
		map.put(ka, va);
		
		// Some checks for that initial value
		this.secondary("firstcontained", map.containsKey(ka));
		this.secondary("firstvalue", map.get(ka));
		
		// Has the same equality, despite a different object?
		this.secondary("firstcontainednew",
			map.containsKey(new Integer(1989)));
		this.secondary("firstvaluenew",
			map.get(new Integer(1989)));
		this.secondary("firstsize", map.size());
		this.secondary("firsthassecond", map.containsKey(kb));
		
		// Add second value
		map.put(kb, vb);
		
		// Check for second value
		this.secondary("secondcontained", map.containsKey(kb));
		this.secondary("secondvalue", map.get(kb));
		this.secondary("secondsize", map.size());
		
		// Replace first value
		this.secondary("replaceput", map.put(ka, vb));
		
		// Checks for replaced value
		this.secondary("replacevalue", map.get(ka));
		this.secondary("replacesecondvalue", map.get(kb));
		this.secondary("replacesize", map.size());
		
		// Add in a bunch of values
		for (int i = 0; i < 128; i++)
			map.put(i, "" + i);
		
		// Hash map
		this.secondary("hashcode", map.hashCode());
		
		// Check the size
		this.secondary("dumpsize", map.size());
		
		// Search for entry by iterator
		for (Iterator<Map.Entry<Integer, String>> it =
			map.entrySet().iterator(); it.hasNext();)
		{
			Map.Entry<Integer, String> e = it.next();
			
			// Matches first value
			if (ka.equals(e.getKey()))
			{
				this.secondary("ithasfirst", e.getValue());
				
				// Remove it
				it.remove();
			}
		}
		
		// Must not have first value
		this.secondary("itafterhasfirst", map.containsKey(ka));
		this.secondary("itputfirstagain", map.put(ka, vb));
		
		// Remove second value
		this.secondary("removesecond", map.remove(kb));
		this.secondary("removesize", map.size());
		
		// Add new value
		map.put(-1, "Adorable");
		
		// Check that
		this.secondary("hasanother", map.get(-1));
		this.secondary("hasanothersize", map.size());
		
		// Empty the map
		map.clear();
		
		// Check that
		this.secondary("clearsize", map.size());
		
		// Store into the map again
		map.put(ka, va);
		
		// Reused values
		this.secondary("reusedcontained", map.containsKey(ka));
		this.secondary("reusedvalue", map.get(ka));
		this.secondary("reusedcontainednew",
			map.containsKey(new Integer(1989)));
		this.secondary("reusedvaluenew",
			map.get(new Integer(1989)));
		this.secondary("reusedsize", map.size());
		this.secondary("reusedhassecond", map.containsKey(kb));
	}
}

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

package util;

import java.util.HashMap;
import net.multiphasicapps.tac.TestSupplier;

/**
 * {@link HashMap}s can contain NaN.
 *
 * @since 2018/10/10
 */
public class TestHashMapNaN
	extends TestSupplier<Boolean>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public Boolean test()
	{
		// Initialize a map to work with
		HashMap<Float, String> map = new HashMap<>();
		
		// Store a NaN
		map.put(Float.NaN, "Squirrels are adorable!");
		
		return map.containsKey(Float.NaN);
	}
}

Added modules/cldc-compact/src/test/java/util/TestHashtable.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.Hashtable;
import java.util.Map;

/**
 * This is a test for {@link Hashtable}.
 *
 * @since 2019/05/05
 */
public class TestHashtable
	extends TestHashMap
{
	/**
	 * Initializes the test using the base map.
	 *
	 * @since 2019/05/05
	 */
	public TestHashtable()
	{
		this(new Hashtable<Integer, String>());
	}
	
	/**
	 * Initializes the test using the given map.
	 *
	 * @param __m The map to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public TestHashtable(Map<Integer, String> __m)
		throws NullPointerException
	{
		super(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void test()
	{
		// Run basic HashMap test
		super.test();
		
		// Initialize a map to work with
		Map<Integer, String> map = this.map;
		
		// Null key should fail
		boolean nullkey = false;
		try
		{
			map.put(null, "Hiya!");
		}
		catch (NullPointerException e)
		{
			nullkey = true;
		}
		this.secondary("nullkey", nullkey);
		
		// Null value should fail
		boolean nullval = false;
		try
		{
			map.put(9876, null);
		}
		catch (NullPointerException e)
		{
			nullval = true;
		}
		this.secondary("nullval", nullval);
		
		// Cannot set values via the iterator either
		Map.Entry<Integer, String> ent = map.entrySet().iterator().next();
		boolean nullset = false;
		try
		{
			ent.setValue(null);
		}
		catch (NullPointerException e)
		{
			nullset = true;
		}
		this.secondary("nullset", nullset);
	}
}

Added modules/cldc-compact/src/test/java/util/TestLinkedHashMap.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This is used to test that LinkedHashMap works.
 *
 * @since 2019/05/11
 */
public class TestLinkedHashMap
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public void test()
	{
		// Initialize a map to work with
		Map<Integer, String> map = new LinkedHashMap<>();
		
		// Go through this twice!
		for (char x = 'a'; x != 'c'; x = (char)(x + 1))
		{
			// Initial size and such
			this.secondary(x + "initempty", map.isEmpty());
			this.secondary(x + "initsize", map.size());
			
			// Some initial values to use
			Integer ka = Integer.valueOf(1989),
				kb = Integer.valueOf(2018);
			String va = "Squirrels",
				vb = "Cute";
			
			// Store into the map
			map.put(ka, va);
			
			// Some checks for that initial value
			this.secondary(x + "firstcontained", map.containsKey(ka));
			this.secondary(x + "firstvalue", map.get(ka));
			
			// Has the same equality, despite a different object?
			this.secondary(x + "firstcontainednew",
				map.containsKey(new Integer(1989)));
			this.secondary(x + "firstvaluenew",
				map.get(new Integer(1989)));
			this.secondary(x + "firstsize", map.size());
			this.secondary(x + "firsthassecond", map.containsKey(kb));
			
			// Add second value
			map.put(kb, vb);
			
			// Check for second value
			this.secondary(x + "secondcontained", map.containsKey(kb));
			this.secondary(x + "secondvalue", map.get(kb));
			this.secondary(x + "secondsize", map.size());
			
			// Replace first value
			this.secondary(x + "replaceput", map.put(ka, vb));
			
			// Checks for replaced value
			this.secondary(x + "replacevalue", map.get(ka));
			this.secondary(x + "replacesecondvalue", map.get(kb));
			this.secondary(x + "replacesize", map.size());
			
			// Add in a bunch of values
			for (int i = 0; i < 128; i++)
				map.put(i, "" + i);
			
			// Contents
			this.secondary(x + "contentsa", map.toString());
			
			// Hash map
			this.secondary(x + "hashcode", map.hashCode());
			
			// Check the size
			this.secondary(x + "dumpsize", map.size());
			
			// Search for entry by iterator
			for (Iterator<Map.Entry<Integer, String>> it =
				map.entrySet().iterator(); it.hasNext();)
			{
				Map.Entry<Integer, String> e = it.next();
				
				// Matches first value
				if (ka.equals(e.getKey()))
				{
					this.secondary(x + "ithasfirst", e.getValue());
					
					// Remove it
					it.remove();
				}
			}
			
			// Must not have first value
			this.secondary(x + "itafterhasfirst", map.containsKey(ka));
			this.secondary(x + "itputfirstagain", map.put(ka, vb));
			
			// Remove second value
			this.secondary(x + "removesecond", map.remove(kb));
			this.secondary(x + "removesize", map.size());
			
			// Add new value
			map.put(-1, "Adorable");
			
			// Check that
			this.secondary(x + "hasanother", map.get(-1));
			this.secondary(x + "hasanothersize", map.size());
			
			// Contents
			this.secondary(x + "contentsb", map.toString());
			
			// Store into the map again
			map.put(ka, va);
			
			// Reused values
			this.secondary(x + "reusedcontained", map.containsKey(ka));
			this.secondary(x + "reusedvalue", map.get(ka));
			this.secondary(x + "reusedcontainednew",
				map.containsKey(new Integer(1989)));
			this.secondary(x + "reusedvaluenew",
				map.get(new Integer(1989)));
			this.secondary(x + "reusedsize", map.size());
			this.secondary(x + "reusedhassecond", map.containsKey(kb));
			
			
			// Contents
			this.secondary(x + "contentsc", map.toString());
		}
	}
}

Added modules/cldc-compact/src/test/java/util/TestLinkedHashMapEldest.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests to ensure that the eldest entry removal works correctly.
 *
 * @since 2019/05/09
 */
public class TestLinkedHashMapEldest
	extends TestRunnable
{
	/** Maximum entries in the map. */
	public static final int MAX_ENTRIES = 10;
	
	/** Eldest order. */
	int _order;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public void test()
	{
		Map<Integer, String> map = new EldestMap();
		
		// Add a bunch of values
		for (int i = 0; i < MAX_ENTRIES * 5; i++)
		{
			// Used for ordering
			int order = TestLinkedHashMapEldest.this._order++;
			this.secondary("eldest" + order + "add", i);
			
			// Put in value
			map.put(i, "Value" + i);
		}
		
		// Array should be in same order!
		this.secondary("ordkeys",
			map.keySet().<Integer>toArray(new Integer[map.size()]));
		this.secondary("ordvals",
			map.values().<String>toArray(new String[map.size()]));
	}
	
	/**
	 * Map which overrides the eldest entry check.
	 *
	 * @since 2109/05/09
	 */
	public final class EldestMap
		extends LinkedHashMap<Integer, String>
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/09
		 */
		@Override
		protected boolean removeEldestEntry(Map.Entry<Integer, String> __e)
		{
			// Used to make sure the order is correct
			int order = TestLinkedHashMapEldest.this._order++;
			TestLinkedHashMapEldest.this.secondary(
				"eldest" + order + "key", __e.getKey());
			TestLinkedHashMapEldest.this.secondary(
				"eldest" + order + "val", __e.getValue());
			
			// This comes from the documentation example which specifies that
			// a value should be removed
			return this.size() > MAX_ENTRIES;
		}
	}
}

Added modules/cldc-compact/src/test/java/util/TestLinkedHashSet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package util;

import java.util.LinkedHashSet;
import java.util.Random;
import java.util.Set;
import net.multiphasicapps.tac.TestSupplier;

/**
 * This tests that linked hash set works properly.
 *
 * @since 2018/11/02
 */
public class TestLinkedHashSet
	extends TestSupplier<Integer>
{
	/** Random key used. */
	public static final long KEY =
		0x537175697272656CL;
	
	/** Number of entries to test. */
	public static final int COUNT =
		128;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public Integer test()
	{
		// The set to test
		Set<Integer> links = new LinkedHashSet<>();
		
		// Add entries to the set
		Random rand = new Random(KEY);
		int intotal = 0;
		for (int i = 0; i < COUNT; i++)
		{
			// Generate and store total value
			int v = rand.nextInt();
			intotal += v;
			
			// Store in the map
			if (!links.add(v))
				this.secondary("duplicatekey", true);
		}
		
		// Mark expected value
		this.secondary("intotal", intotal);
		
		// Go through and re-add the same values which should result in the
		// same order
		rand = new Random(KEY);
		for (int i = 0; i < COUNT; i++)
			if (links.add(rand.nextInt()))
				this.secondary("readd" + i, true);
		
		// Go through iterator and match
		rand = new Random(KEY);
		int ittotal = 0;
		for (int i : links)
		{
			if (i != rand.nextInt())
				this.secondary("unmatched", true);
			
			ittotal += i;
		}
		
		// Hashcode
		this.secondary("hashcode", links.hashCode());
		
		return ittotal;
	}
}

Added modules/cldc-compact/src/test/java/util/TestLinkedList.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.LinkedList;

/**
 * Tests linked list.
 *
 * @since 2019/05/08
 */
public class TestLinkedList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestLinkedList()
	{
		super(new LinkedList<String>());
	}
}

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

package util;

import java.util.LinkedList;

/**
 * Tests linked lists.
 *
 * @since 2019/01/20
 */
public class TestLinkedListDeque
	extends __TestDeque__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/01/20
	 */
	public TestLinkedListDeque()
	{
		super(new LinkedList<Number>(), true);
	}
}

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

package util;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests the random number generator, integer values only.
 *
 * @since 2018/11/02
 */
public class TestRandom
	extends TestRunnable
{
	/** Count for values. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0xCAFEBABE);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("boolean-%02d", i),
				rand.nextBoolean());
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("int-%02d", i),
				rand.nextInt());
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("long-%02d", i),
				rand.nextLong());
			
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("range-%02d", i),
				rand.nextInt(i + 1));
	}
}

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

package util;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Test random number generator, floating point values only.
 *
 * @since 2018/11/02
 */
public class TestRandomFloat
	extends TestRunnable
{
	/** Count for values. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0xCAFED00D);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("double-%02d", i),
				Double.doubleToRawLongBits(rand.nextDouble()));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("float-%02d", i),
				Float.floatToRawIntBits(rand.nextFloat()));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("gauss-%02d", i),
				Double.doubleToRawLongBits(rand.nextGaussian()));
	}
}

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

package util;

import java.util.ServiceLoader;
import net.multiphasicapps.tac.TestRunnable;
import util.serviceloader.ServiceThingy;

/**
 * Tests the service loader.
 *
 * @since 2018/12/06
 */
public class TestServiceLoader
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public void test()
	{
		ServiceLoader<ServiceThingy> sl = ServiceLoader.<ServiceThingy>load(
			ServiceThingy.class);
		
		// Initial run
		for (ServiceThingy sv : sl)
			this.secondary("init-" + sv.getClass().getName(), sv.toString());
		
		// Cached run
		for (ServiceThingy sv : sl)
			this.secondary("cache-" + sv.getClass().getName(), sv.toString());
		
		// Clear cache
		sl.reload();
		
		// Should be fresh
		for (ServiceThingy sv : sl)
			this.secondary("again-" + sv.getClass().getName(), sv.toString());
	}
}

Added modules/cldc-compact/src/test/java/util/TestSorting.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that arrays can be sorted.
 *
 * @since 2019/05/09
 */
public class TestSorting
	extends TestRunnable
{
	/** Random seed. */
	public static final int SEED =
		123456789;
	
	/** The number of elements to sort through. */
	private static final int[] _COUNTS =
		new int[]{1, 2, 3, 4, 8, 13, 26};
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public void test()
	{
		for (int c = 0, cn = _COUNTS.length; c < cn; c++)
		{
			Random rand;
			
			int count = _COUNTS[c];
			String cid = String.format("%02d", count);
		
			// Byte
			rand = new Random(SEED);
			byte[] ab = new byte[count];
			for (int i = 0; i < count; i++)
				ab[i] = (byte)rand.nextInt();
			Arrays.sort(ab);
			this.secondary("arraybyte" + cid, ab);
			
			// Short
			rand = new Random(SEED);
			short[] as = new short[count];
			for (int i = 0; i < count; i++)
				as[i] = (short)rand.nextInt();
			Arrays.sort(as);
			this.secondary("arrayshort" + cid, as);
			
			// Char
			rand = new Random(SEED);
			char[] ac = new char[count];
			for (int i = 0; i < count; i++)
				ac[i] = (char)rand.nextInt();
			Arrays.sort(ac);
			this.secondary("arraychar" + cid, ac);
			
			// Integer
			rand = new Random(SEED);
			int[] ai = new int[count];
			for (int i = 0; i < count; i++)
				ai[i] = rand.nextInt();
			Arrays.sort(ai);
			this.secondary("arrayint" + cid, ai);
			
			// Object (just integers)
			rand = new Random(SEED);
			Integer[] ao = new Integer[count];
			for (int i = 0; i < count; i++)
				ao[i] = rand.nextInt();
			Arrays.sort(ao);
			this.secondary("arrayobject" + cid, ao);
			
			// Array List
			rand = new Random(SEED);
			List<Integer> la = new ArrayList<>(count);
			for (int i = 0; i < count; i++)
				la.add(rand.nextInt());
			Collections.sort(la);
			this.secondary("listarray" + cid,
				la.<Integer>toArray(new Integer[count]));
			
			// Linked List
			rand = new Random(SEED);
			List<Integer> ll = new LinkedList<>();
			for (int i = 0; i < count; i++)
				ll.add(rand.nextInt());
			Collections.sort(ll);
			this.secondary("listlinked" + cid,
				ll.<Integer>toArray(new Integer[count]));
		}
	}
}

Added modules/cldc-compact/src/test/java/util/TestStackAsList.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.Stack;

/**
 * Tests the stack class but solely to make sure that the {@link Vector} it
 * inherits from has not been broken.
 *
 * @since 2019/05/08
 */
public class TestStackAsList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestStackAsList()
	{
		super(new Stack<String>());
	}
}

Added modules/cldc-compact/src/test/java/util/TestVector.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.Vector;

/**
 * Tests the old-style vector.
 *
 * @since 2019/05/08
 */
public class TestVector
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestVector()
	{
		super(new Vector<String>());
	}
}

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

package util;

import java.util.Deque;
import java.util.Iterator;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Performs tests on deques.
 *
 * @since 2019/01/20
 */
abstract class __TestDeque__
	extends TestRunnable
{
	/** The deque to test. */
	protected final Deque<Number> deque;
	
	/** Can we hash code? */
	private final boolean _canHashCode;
	
	/**
	 * Initializes the base test.
	 *
	 * @param __d The deque to test on.
	 * @since 2019/01/20
	 */
	public __TestDeque__(Deque<Number> __d, boolean __canHash)
	{
		this.deque = __d;
		this._canHashCode = __canHash;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public void test()
	{
		Deque<Number> q = this.deque;
		
		// Add a bunch of numbers
		for (int i = 0; i < 10; i++)
			this.secondary("init-add-" + i, q.add(i));
		
		// Offer first values
		q.addFirst(100);
		this.secondary("offer-first", q.offerFirst(200));
		
		// Size of this
		this.secondary("size-a", q.size());
		
		// Offer last values
		q.addLast(300);
		this.secondary("offer-last", q.offerLast(400));
		
		// Queue
		q.add(500);
		q.offer(600);
		
		// Stack
		q.push(1234);
		
		// Size of this
		int size;
		this.secondary("size-b", (size = q.size()));
		
		// Get iterators from both positions
		int[] ita = new int[size];
		Iterator<Number> it = q.iterator();
		for (int i = 0; it.hasNext(); i++)
			ita[i] = it.next().intValue();
		this.secondary("iterator-ascending", ita);
		
		// And descend it
		it = q.descendingIterator();
		for (int i = 0; it.hasNext(); i++)
			ita[i] = it.next().intValue();
		this.secondary("iterator-descending", ita);
		
		// Hashcode, but not all collections have a valid hashcode
		if (this._canHashCode)
			this.secondary("hashcode", q.hashCode());
		
		// As array form
		this.secondary("array", q.<Integer>toArray(new Integer[q.size()]));
		this.secondary("arraygrow",
			q.<Integer>toArray(new Integer[q.size() / 2]));
		this.secondary("arrayover",
			q.<Integer>toArray(new Integer[q.size() + 17]));
		
		// Do removals
		this.secondary("removefirst", q.removeFirst());
		this.secondary("getfirst", q.getFirst());
		this.secondary("pollfirst", q.pollFirst());
		this.secondary("peekfirst", q.peekFirst());
		this.secondary("removelast", q.removeLast());
		this.secondary("polllast", q.pollLast());
		this.secondary("getlast", q.getLast());
		this.secondary("peeklast", q.peekLast());
		this.secondary("remove", q.remove());
		this.secondary("poll", q.poll());
		this.secondary("element", q.element());
		this.secondary("peek", q.peek());
		this.secondary("pop", q.pop());
		
		// Array form again
		this.secondary("array2", q.<Integer>toArray(new Integer[q.size()]));
		
		// Contains some things?
		this.secondary("has7", q.contains(7));
		this.secondary("has14", q.contains(14));
		this.secondary("has500", q.contains(500));
		
		// Add a bunch of numbers
		for (int i = 0; i < 10; i++)
			this.secondary("other-add-" + i, q.add(i));
			
		// Array form again!
		this.secondary("array3", q.<Integer>toArray(new Integer[q.size()]));
		
		// Remove first occurance of value
		for (int i = 0; i < 15; i += 2)
			this.secondary("remove-first-" + i, q.removeFirstOccurrence(i));
		this.secondary("array4", q.<Integer>toArray(new Integer[q.size()]));
		
		// Remove last occurance of value
		for (int i = 1; i < 15; i += 2)
			this.secondary("remove-last-" + i, q.removeLastOccurrence(i));
		this.secondary("array5", q.<Integer>toArray(new Integer[q.size()]));
		
		// Clear it
		q.clear();
		this.secondary("array6", q.<Integer>toArray(new Integer[q.size()]));
	}
}

Added modules/cldc-compact/src/test/java/util/__TestList__.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
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
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 util;

import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that lists work correctly and do all the things they should do.
 *
 * @since 2019/05/08
 */
abstract class __TestList__
	extends TestRunnable
{
	/** The list being tested. */
	protected final List<String> list;
	
	/**
	 * Initializes the test with the list to work with.
	 *
	 * @param __l The list to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	__TestList__(List<String> __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.list = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public void test()
	{
		List<String> list = this.list;
		
		// Initial list is empty and has zero size
		this.secondary("initialzerosize", list.size());
		this.secondary("initialisempty", list.isEmpty());
		
		// Initial list does not contain value
		this.secondary("initialnocont", list.contains("Cutie squirrels!"));
		
		// Initial list throws IOOB
		try
		{
			this.secondary("initialioob", list.get(29));
		}
		catch (Throwable t)
		{
			this.secondary("initialioob", t);
		}
		
		// Add various entries to the list
		this.secondary("add1", list.add("Hello!"));
		this.secondary("add2", list.add("Squirrels!"));
		this.secondary("add3", list.add("Are!"));
		this.secondary("add4", list.add("Cute!"));
		
		// Must be the correct size
		this.secondary("addempty", list.isEmpty());
		this.secondary("addsize", list.size());
		
		// Remove the second element
		this.secondary("removeindex", list.remove(2));
		
		// Remove by value
		this.secondary("hascutebefore", list.contains("Cute!"));
		this.secondary("removevalue", list.remove("Cute!"));
		this.secondary("hascuteafter", list.contains("Cute!"));
		
		// Remove size
		this.secondary("removeempty", list.isEmpty());
		this.secondary("removesize", list.size());
		
		// Add a bunch of entries
		for (int i = 1; i <= 17; i++)
			this.secondary("add" + i, list.add(Integer.toString(i)));
		
		// Set some element values
		this.secondary("set6", list.set(6, "Xer!"));
		this.secondary("set13", list.set(13, "Is!"));
		try
		{
			this.secondary("set29", list.set(29, "Cute!"));
		}
		catch (Throwable t)
		{
			this.secondary("set29", t);
		}
		
		// Get some values
		this.secondary("get2", list.get(2));
		this.secondary("get6", list.get(6));
		this.secondary("get13", list.get(13));
		this.secondary("get17", list.get(17));
		try
		{
			this.secondary("get29", list.get(29));
		}
		catch (Throwable t)
		{
			this.secondary("get29", t);
		}
			
		// Count sizes more
		this.secondary("bulkempty", list.isEmpty());
		this.secondary("bulksize", list.size());
		
		// Add another squirrels, then remove it
		this.secondary("moresquirrels", list.add("Squirrels!"));
		this.secondary("hasmoresquirrels", list.contains("Squirrels!"));
		this.secondary("removemoresquirrels", list.remove("Squirrels!"));
		this.secondary("hasmoresquirrelsstill", list.contains("Squirrels!"));
		
		// Hashcode
		this.secondary("hashcode", list.hashCode());
		
		// Go through and check iteration sequence
		Object[] array = list.toArray();
		ListIterator<String> it = list.listIterator();
		for (int i = 0, n = array.length; i < n; i++)
		{
			// Must be equal
			this.secondary("itequal" + i, Objects.equals(array[i], it.next()));
			
			// Remove some elements
			if (i == 3 || i == 7 || i == 12)
				it.remove();
		}
		
		// The iterator should be at the end
		try
		{
			this.secondary("noneleft", it.next());
		}
		catch (Throwable t)
		{
			this.secondary("noneleft", t);
		}
		
		// Go back down the iterator
		array = list.toArray();
		for (int i = array.length - 1; i >= 0; i--)
		{
			// Must be equal
			this.secondary("previtequal" + i,
				Objects.equals(array[i], it.previous()));
			
			// Remove some elements
			if (i == 3 || i == 7 || i == 12)
				it.remove();
		}
		
		// The iterator should be at the end
		try
		{
			this.secondary("prevnoneleft", it.previous());
		}
		catch (Throwable t)
		{
			this.secondary("prevnoneleft", t);
		}
		
		// As array form
		this.secondary("array",
			list.<String>toArray(new String[list.size()]));
		this.secondary("arrowgrow",
			list.<String>toArray(new String[list.size() / 2]));
		this.secondary("arrayover",
			list.<String>toArray(new String[list.size() + 17]));
		
		// Check string result
		this.secondary("stringform", list.toString());
		
		// Clear and count size
		list.clear();
		this.secondary("clearempty", list.isEmpty());
		this.secondary("clearsize", list.size());
	}
}

Added modules/cldc-compact/src/test/java/util/serviceloader/ServiceThingy.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package util.serviceloader;

/**
 * A service thing that is supported.
 *
 * @since 2018/12/06
 */
public interface ServiceThingy
{
}

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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class ComfortableDrey
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "A very comfortable drey!";
	}
}

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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class CuteSquirrels
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "Cute squirrels!";
	}
}

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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class StashTheAcorns
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "Stash all the acorns!";
	}
}

Added modules/cldc-compact/src/test/java/util/serviceloader/impls/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Contains some implementations of services.
 *
 * @since 2018/12/06
 */

package util.serviceloader.impls;

Added modules/cldc-compact/src/test/java/util/serviceloader/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes used for service loader tests.
 *
 * @since 2018/12/06
 */

package util.serviceloader;

Added modules/cldc-compact/src/test/resources/META-INF/services/util.serviceloader.ServiceThingy.




1
2
3
+
+
+
util.serviceloader.impls.CuteSquirrels
util.serviceloader.impls.ComfortableDrey
util.serviceloader.impls.StashTheAcorns

Added modules/cldc-compact/src/test/resources/io/TestReadLineEOF.in.








1
2
3
4
5
6
7
+
+
+
+
+
+
+
result: int:5
thrown: NoExceptionThrown
secondary-line--1: string:Rodents\_are\_softly\_cute!
secondary-line--2: string:Squirrels!
secondary-line--3: string:Mice!
secondary-line--4: string:And\_rats!

Added modules/cldc-compact/src/test/resources/lang/TestArray.in.




































































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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-boolean--0: false
secondary-boolean--1: true
secondary-boolean--2: false
secondary-boolean--3: false
secondary-boolean--4: true
secondary-boolean--5: false
secondary-boolean--6: false
secondary-boolean--7: false
secondary-byte--0: byte:10
secondary-byte--1: byte:79
secondary-byte--2: byte:46
secondary-byte--3: byte:95
secondary-byte--4: byte:-102
secondary-byte--5: byte:1
secondary-byte--6: byte:121
secondary-byte--7: byte:0
secondary-char--0: char:35618
secondary-char--1: char:2365
secondary-char--2: char:55767
secondary-char--3: char:32692
secondary-char--4: char:41045
secondary-char--5: char:62683
secondary-char--6: char:38834
secondary-char--7: char:12892
secondary-double--0: long:4602249605880005352
secondary-double--1: long:4604568770661008052
secondary-double--2: long:4605565894347753078
secondary-double--3: long:4606776481611615370
secondary-double--4: long:4604912020652972472
secondary-double--5: long:4605705353082206991
secondary-double--6: long:4592761750090831968
secondary-double--7: long:4605403023904893675
secondary-float--0: int:1054137296
secondary-float--1: int:1062125601
secondary-float--2: int:1055303542
secondary-float--3: int:1057111330
secondary-float--4: int:1062160289
secondary-float--5: int:1059716047
secondary-float--6: int:1064508947
secondary-float--7: int:1051431500
secondary-int--0: int:-540490261
secondary-int--1: int:7073627
secondary-int--2: int:-1882904776
secondary-int--3: int:2037297493
secondary-int--4: int:1647086087
secondary-int--5: int:-141001931
secondary-int--6: int:849191592
secondary-int--7: int:-1122918633
secondary-long--0: long:-4071615891382181537
secondary-long--1: long:5902863659456241668
secondary-long--2: long:-6162285531878494405
secondary-long--3: long:-1914963148333505296
secondary-long--4: long:-3532328660556861777
secondary-long--5: long:-4041979462155839005
secondary-long--6: long:-8032429601186284395
secondary-long--7: long:-574384260408492771
secondary-short--0: short:-1257
secondary-short--1: short:-17981
secondary-short--2: short:-3792
secondary-short--3: short:-8768
secondary-short--4: short:9375
secondary-short--5: short:-30486
secondary-short--6: short:25991
secondary-short--7: short:3726

Added modules/cldc-compact/src/test/resources/lang/TestArrayClone.in.



1
2
+
+
result: true
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestBitCount.in.




































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: int:516
thrown: NoExceptionThrown
secondary---1311576848: int:17
secondary---1332382087: int:17
secondary---1340642358: int:16
secondary---1415577226: int:13
secondary---1423971382: int:20
secondary---1492189590: int:19
secondary---1551205178: int:16
secondary---1874748849: int:13
secondary---1880491709: int:19
secondary---2056315975: int:18
secondary---2068379663: int:16
secondary---289506626: int:23
secondary---333491629: int:17
secondary---439795945: int:19
secondary---458098343: int:18
secondary---516743031: int:12
secondary---610984458: int:20
secondary---668136350: int:13
secondary---727125616: int:14
secondary---758524624: int:15
secondary-1069159422: int:21
secondary-1141137495: int:10
secondary-1254667026: int:13
secondary-1695406993: int:16
secondary-181321777: int:12
secondary-1831602766: int:14
secondary-1883960650: int:15
secondary-1966145181: int:19
secondary-2126472996: int:20
secondary-27286603: int:11
secondary-36993251: int:13
secondary-993338671: int:17

Added modules/cldc-compact/src/test/resources/lang/TestDivideByZero.in.




1
2
3
+
+
+
result: ExceptionThrown
thrown: throwable:ArithmeticException

Added modules/cldc-compact/src/test/resources/lang/TestEnumValueOf.in.



1
2
+
+
result: string:ABYou\_are\_beautiful!You\_are\_wonderful!
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestExceptionCatchUp.in.




1
2
3
+
+
+
result: ExceptionThrown
thrown: throwable:IllegalArgumentException

Added modules/cldc-compact/src/test/resources/lang/TestHoldLock.in.






1
2
3
4
5
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-before: false
secondary-during: true
secondary-after: false

Added modules/cldc-compact/src/test/resources/lang/TestInnerClassOnProtected.in.



1
2
+
+
result: int:1234
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestIntegerDecode.in.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: int:15882
thrown: NoExceptionThrown
secondary--h1234: int:4660
secondary--p-h1234: int:4660
secondary--p01234: int:668
secondary--p0x1234: int:4660
secondary--p1234: int:1234
secondary----h1234: int:-4660
secondary---01234: int:-668
secondary---0x1234: int:-4660
secondary---1234: int:-1234
secondary-01234: int:668
secondary-0x1234: int:4660
secondary-1234: int:1234

Added modules/cldc-compact/src/test/resources/lang/TestIntegerParseIntOverflow.in.



1
2
+
+
result: string:23456789abcdefghijklmnopqrstuvwxyz\0
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestIntegerParseIntOverflowMax.in.



1
2
+
+
result: string:23456789abcdefghijklmnopqrstuvwxyz\0
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestInvokePrivate.in.




1
2
3
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-private: true

Added modules/cldc-compact/src/test/resources/lang/TestInvokePrivateInSuper.in.





1
2
3
4
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-superprivate: true

Added modules/cldc-compact/src/test/resources/lang/TestInvokeSuper.in.






1
2
3
4
5
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-childbefore: true
secondary-super: true
secondary-childafter: true

Added modules/cldc-compact/src/test/resources/lang/TestMathLog.in.








































































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-random----1432335638160804534: long:-2251799813685248
secondary-random----1888909202756794383: long:-2251799813685248
secondary-random----1967517401509503925: long:-2251799813685248
secondary-random----2219394418870420802: long:-2251799813685248
secondary-random----2624158267349034417: long:-2251799813685248
secondary-random----3122980739108447343: long:-2251799813685248
secondary-random----3339783707453616697: long:-2251799813685248
secondary-random----5400592651466114974: long:-2251799813685248
secondary-random----5722537487475081571: long:-2251799813685248
secondary-random----6115910518010414781: long:-2251799813685248
secondary-random----6408905489149784990: long:-2251799813685248
secondary-random----6437715043167905200: long:-2251799813685248
secondary-random----7033748006474773329: long:-2251799813685248
secondary-random----7867116347168471483: long:-2251799813685248
secondary-random----8831809862686031823: long:-2251799813685248
secondary-random--1255568899445664322: long:-4575623698181355925
secondary-random--1434825769210690147: long:-4576075885753216990
secondary-random--158884801877076938: long:-4574139165859803029
secondary-random--2180097264311650148: long:-4578093203530993396
secondary-random--2343294179524792790: long:-4578535680152507644
secondary-random--3018518297123294602: long:-4580566804536331392
secondary-random--4266357105038578992: long:-4590800524580975423
secondary-random--4592004750388686064: long:-4611046322738335769
secondary-random--5388753842488376518: long:4638169200724828892
secondary-random--5404559425704385608: long:4638337402247354041
secondary-random--5662129423103150469: long:4639918514832386509
secondary-random--6377033640133724733: long:4643499723705780022
secondary-random--7197361914604609929: long:4645721385009566601
secondary-random--7843894698618392042: long:4647472167532842776
secondary-random--7866673980374278231: long:4647533729646704837
secondary-random--8572265387981001411: long:4648579681512836525
secondary-random--9133131972231561590: long:4649338522149113304
secondary-value----01: long:-2251799813685248
secondary-value----02: long:-2251799813685248
secondary-value--000: long:-4503599627370496
secondary-value--001: long:0
secondary-value--002: long:4604418534313441775
secondary-value--003: long-fudge:4607626529066517258:1
secondary-value--004: long:4608922133940812271
secondary-value--005: long:4609927083155361075
secondary-value--006: long:4610748186450599938
secondary-value--007: long:4611442419394828887
secondary-value--008: long:4611864904876141427
secondary-value--009: long:4612130128693887755
secondary-value--010: long:4612367379483415830
secondary-value--011: long:4612581998928541516
secondary-value--012: long:4612777931131035261
secondary-value--013: long:4612958171285261393
secondary-value--014: long:4613125047603149735
secondary-value--015: long:4613280405738309663
secondary-value--016: long:4613425733568182767
secondary-value--017: long:4613562248080293754
secondary-value--018: long:4613690957385929094
secondary-value--019: long:4613812705944711980
secondary-value--020: long:4613928208175457169
secondary-value--021: long:4614038073858043569
secondary-value--022: long:4614142827620582856
secondary-value--023: long:4614242924091257840
secondary-value--024: long:4614338759823076601
secondary-value--025: long:4614430682782731571
secondary-value--026: long:4614518999977302733
secondary-value--027: long:4614603983640822928
secondary-value--028: long:4614685876295191075
secondary-value--029: long:4614764894922604063
secondary-value--030: long:4614841234430351003
secondary-value--031: long:4614915070547274586
secondary-value--032: long:4614986562260224107
secondary-value--033: long:4615055853875476689
secondary-value--034: long:4615123076772335094
secondary-value--035: long:4615188350902465477
secondary-value--036: long:4615251786077970434
secondary-value--037: long:4615313483082942397
secondary-value--038: long:4615373534636753320
secondary-value--039: long:4615432026232196566
secondary-value--040: long:4615489036867498509
secondary-value--041: long:4615544639687928910
secondary-value--042: long:4615598902550084909
secondary-value--043: long:4615651888519769105
secondary-value--044: long:4615703656312624195
secondary-value--045: long:4615754260685244836
secondary-value--046: long:4615803752783299180
secondary-value--047: long:4615852180452208822
secondary-value--048: long-fudge:4615899588515117940:1
secondary-value--049: long:4615946019022199383
secondary-value--050: long:4615991511474772911
secondary-value--051: long:4616036103027228927
secondary-value--052: long:4616079828669344073
secondary-value--053: long:4616122721391230123
secondary-value--054: long:4616164812332864268
secondary-value--055: long:4616197874487328499
secondary-value--056: long:4616218161520995408
secondary-value--057: long:4616238089473202777
secondary-value--058: long:4616257670834701901
secondary-value--059: long:4616276917455628665
secondary-value--060: long:4616295840588575371
secondary-value--061: long:4616314450928102413
secondary-value--062: long:4616332758647037163
secondary-value--063: long:4616350773429868571
secondary-value--064: long:4616368504503511923
secondary-value--065: long:4616385960665688437
secondary-value--066: long:4616403150311138214
secondary-value--067: long:4616420081455862061
secondary-value--068: long:4616436761759567417
secondary-value--069: long:4616453198546475707
secondary-value--070: long:4616469398824632609
secondary-value--071: long:4616485369303848649
secondary-value--072: long:4616501116412385087
secondary-value--073: long:4616516646312488934
secondary-value--074: long-fudge:4616531964914871068:1
secondary-value--075: long:4616547077892212572
secondary-value--076: long:4616561990691776530
secondary-value--077: long:4616576708547195452
secondary-value--078: long:4616591236489498153
secondary-value--079: long:4616605579357434227
secondary-value--080: long:4616619741807149124
secondary-value--081: long:4616633728321258251
secondary-value--082: long:4616647543217364325
secondary-value--083: long:4616661190656058498
secondary-value--084: long:4616674674648442324
secondary-value--085: long:4616687999063204618
secondary-value--086: long:4616701167633284422
secondary-value--087: long:4616714183962148818
secondary-value--088: long:4616727051529711968
secondary-value--089: long:4616739773697919734
secondary-value--090: long:4616752353716022288
secondary-value--091: long:4616764794725555390
secondary-value--092: long:4616777099765049460
secondary-value--093: long:4616789271774484080
secondary-value--094: long:4616801313599504281
secondary-value--095: long:4616813227995413731
secondary-value--096: long:4616825017630958840
secondary-value--097: long:4616836685091916792
secondary-value--098: long:4616848232884499562
secondary-value--099: long:4616859663438585131
secondary-value--100: long:4616870979110786326
secondary-value--101: long:4616882182187366961
secondary-value--102: long:4616893274887014333
secondary-value--103: long:4616904259363476460
secondary-value--104: long:4616915137708071906
secondary-value--105: long:4616925911952079525
secondary-value--106: long:4616936584069014931
secondary-value--107: long:4616947155976800091
secondary-value--108: long:4616957629539832004
secondary-value--109: long:4616968006570956038
secondary-value--110: long:4616978288833349169
secondary-value--111: long:4616988478042317985
secondary-value--112: long:4616998575867016077
secondary-value--113: long:4617008583932085084
secondary-value--114: long:4617018503819223447
secondary-value--115: long:4617028337068686661
secondary-value--116: long:4617038085180722571
secondary-value--117: long:4617047749616945070
secondary-value--118: long:4617057331801649335
secondary-value--119: long:4617066833123071571
secondary-value--120: long:4617076254934596041
secondary-value--121: long:4617085598555912012
secondary-value--122: long:4617094865274123083
secondary-value--123: long:4617104056344811241
secondary-value--124: long:4617113172993057833
secondary-value--125: long:4617122216414423527
secondary-value--126: long:4617131187775889241
secondary-value--127: long:4617140088216759874
secondary-value--128: long:4617148918849532593


Added modules/cldc-compact/src/test/resources/lang/TestMathSqrt.in.







































































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-value----01: long:-2251799813685248
secondary-value----02: long:-2251799813685248
secondary-value--000: long:0
secondary-value--001: long:4607182418800017408
secondary-value--002: long:4609047870845172685
secondary-value--003: long:4610479282544200874
secondary-value--004: long:4611686018427387904
secondary-value--005: long:4612217596255138984
secondary-value--006: long:4612698179346440494
secondary-value--007: long:4613140121109330154
secondary-value--008: long:4613551470472543181
secondary-value--009: long:4613937818241073152
secondary-value--010: long:4614303235046005587
secondary-value--011: long:4614650793885003572
secondary-value--012: long:4614982882171571370
secondary-value--013: long:4615301398490339827
secondary-value--014: long:4615607882206429001
secondary-value--015: long:4615903601977413338
secondary-value--016: long:4616189618054758400
secondary-value--017: long:4616328222667173127
secondary-value--018: long:4616462807181782233
secondary-value--019: long:4616593702341856761
secondary-value--020: long:4616721195882509480
secondary-value--021: long:4616845539975437957
secondary-value--022: long:4616966957094426279
secondary-value--023: long:4617085644692718614
secondary-value--024: long:4617201778973810990
secondary-value--025: long:4617315517961601024
secondary-value--026: long:4617427004022730742
secondary-value--027: long:4617536365956053376
secondary-value--028: long:4617643720736700650
secondary-value--029: long:4617749174982072819
secondary-value--030: long:4617852826192094607
secondary-value--031: long:4617954763804819907
secondary-value--032: long:4618055070099913677
secondary-value--033: long:4618153820975976688
secondary-value--034: long:4618251086622598050
secondary-value--035: long:4618346932104053293
secondary-value--036: long:4618441417868443648
secondary-value--037: long:4618534600193596473
secondary-value--038: long:4618626531579070041
secondary-value--039: long:4618717261092017034
secondary-value--040: long:4618806834673376083
secondary-value--041: long:4618895295409815296
secondary-value--042: long:4618982683775996516
secondary-value--043: long:4619069037851025760
secondary-value--044: long:4619154393512374068
secondary-value--045: long:4619238784610070268
secondary-value--046: long:4619322243123564579
secondary-value--047: long:4619404799303324646
secondary-value--048: long:4619486481798941866
secondary-value--049: long:4619567317775286272
secondary-value--050: long:4619647333018045120
secondary-value--051: long:4619726552029807566
secondary-value--052: long:4619804998117710323
secondary-value--053: long:4619882693473532905
secondary-value--054: long:4619959659247022534
secondary-value--055: long:4620035915613135320
secondary-value--056: long:4620111481833799497
secondary-value--057: long:4620186376314736476
secondary-value--058: long:4620260616657814640
secondary-value--059: long:4620334219709357787
secondary-value--060: long:4620407201604783834
secondary-value--061: long:4620479577809908840
secondary-value--062: long:4620551363159215890
secondary-value--063: long:4620622571891357023
secondary-value--064: long:4620693217682128896
secondary-value--065: long:4620728265678633680
secondary-value--066: long:4620763045096241164
secondary-value--067: long:4620797562016421003
secondary-value--068: long:4620831822294543623
secondary-value--069: long:4620865831571476489
secondary-value--070: long:4620899595284426715
secondary-value--071: long:4620933118677089030
secondary-value--072: long:4620966406809152729
secondary-value--073: long:4620999464565216419
secondary-value--074: long:4621032296663155022
secondary-value--075: long:4621064907661979627
secondary-value--076: long:4621097301969227257
secondary-value--077: long:4621129483847914467
secondary-value--078: long:4621161457423085828
secondary-value--079: long:4621193226687985776
secondary-value--080: long:4621224795509879976
secondary-value--081: long:4621256167635550208
secondary-value--082: long:4621287346696484900
secondary-value--083: long:4621318336213785640
secondary-value--084: long:4621349139602808453
secondary-value--085: long:4621379760177557146
secondary-value--086: long:4621410201154844724
secondary-value--087: long:4621440465658237670
secondary-value--088: long:4621470556721796775
secondary-value--089: long:4621500477293627201
secondary-value--090: long:4621530230239249534
secondary-value--091: long:4621559818344802731
secondary-value--092: long:4621589244320089110
secondary-value--093: long:4621618510801470784
secondary-value--094: long:4621647620354626310
secondary-value--095: long:4621676575477175713
secondary-value--096: long:4621705378601181486
secondary-value--097: long:4621734032095532642
secondary-value--098: long:4621762538268218451
secondary-value--099: long:4621790899368498023
secondary-value--100: long:4621819117588971520
secondary-value--101: long:4621847195067558384
secondary-value--102: long:4621875133889387642
secondary-value--103: long:4621902936088605011
secondary-value--104: long:4621930603650101238
secondary-value--105: long:4621958138511165833
secondary-value--106: long:4621985542563070088
secondary-value--107: long:4622012817652583048
secondary-value--108: long:4622039965583423872
secondary-value--109: long:4622066988117653815
secondary-value--110: long:4622093886977010867
secondary-value--111: long:4622120663844189920
secondary-value--112: long:4622147320364071146
secondary-value--113: long:4622173858144899126
secondary-value--114: long:4622200278759415130
secondary-value--115: long:4622226583745944792
secondary-value--116: long:4622252774609443315
secondary-value--117: long:4622278852822500215
secondary-value--118: long:4622304819826305498
secondary-value--119: long:4622330677031579077
secondary-value--120: long:4622356425819465103
secondary-value--121: long:4622382067542392832
secondary-value--122: long:4622407603524905544
secondary-value--123: long:4622433035064458942
secondary-value--124: long:4622458363432190403
secondary-value--125: long:4622483589873660370
secondary-value--126: long:4622508715609567095
secondary-value--127: long:4622533741836435920
secondary-value--128: long:4622558669727284173
secondary-random----1432335638160804534: long:-2251799813685248
secondary-random----1888909202756794383: long:-2251799813685248
secondary-random----1967517401509503925: long:-2251799813685248
secondary-random----2219394418870420802: long:-2251799813685248
secondary-random----2624158267349034417: long:-2251799813685248
secondary-random----3122980739108447343: long:-2251799813685248
secondary-random----3339783707453616697: long:-2251799813685248
secondary-random----5400592651466114974: long:-2251799813685248
secondary-random----5722537487475081571: long:-2251799813685248
secondary-random----6115910518010414781: long:-2251799813685248
secondary-random----6408905489149784990: long:-2251799813685248
secondary-random----6437715043167905200: long:-2251799813685248
secondary-random----7033748006474773329: long:-2251799813685248
secondary-random----7867116347168471483: long:-2251799813685248
secondary-random----8831809862686031823: long:-2251799813685248
secondary-random--1255568899445664322: long:2931362841864629624
secondary-random--1434825769210690147: long:3020952646369542971
secondary-random--158884801877076938: long:2382994875329581799
secondary-random--2180097264311650148: long:3393322263858566792
secondary-random--2343294179524792790: long:3475077629777803516
secondary-random--3018518297123294602: long:3812650250847330100
secondary-random--4266357105038578992: long:4436719366953915272
secondary-random--4592004750388686064: long:4599421220444606324
secondary-random--5388753842488376518: long:4997901707625293227
secondary-random--5404559425704385608: long:5005532053458444485
secondary-random--5662129423103150469: long:5134625659391588651
secondary-random--6377033640133724733: long:5491730931508304087
secondary-random--7197361914604609929: long:5901998413481527113
secondary-random--7843894698618392042: long:6225333553435010730
secondary-random--7866673980374278231: long:6236909802700178660
secondary-random--8572265387981001411: long:6589639284353588013
secondary-random--9133131972231561590: long:6869795181514067063

Added modules/cldc-compact/src/test/resources/lang/TestMonitorNotify.in.












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-after--lock: int:7
secondary-before--lock: int:0
secondary-expected--resume: int:6
secondary-in--lock: int:1
secondary-sub--after--notify: int:4
secondary-sub--after--sleep: int:5
secondary-sub--in--lock: int:3
secondary-thread--created: int:2

Added modules/cldc-compact/src/test/resources/lang/TestMultiANewArray.in.





1
2
3
4
+
+
+
+
result: string:[[[Ljava.lang.Integer;
thrown: NoExceptionThrown
secondary-total: int:168

Added modules/cldc-compact/src/test/resources/lang/TestNewInstance.in.



1
2
+
+
result: string:Hello\_squirrels\_are\_cute!
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestStringIntern.in.













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-cca: false
secondary-ccb: true
secondary-cna: false
secondary-cnb: false
secondary-cia: false
secondary-cib: true
secondary-cxa: false
secondary-cxb: true
secondary-iia: false
secondary-iib: true

Added modules/cldc-compact/src/test/resources/lang/TestStringRegionMatches.in.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-adorablec: false
secondary-adorablei: true
secondary-arec: true
secondary-arei: true
secondary-helloc: false
secondary-helloi: true
secondary-neglenc: true
secondary-negleni: true
secondary-samec: true
secondary-samehalfc: true
secondary-samehalfi: true
secondary-samei: true
secondary-samenegac: false
secondary-samenegai: false
secondary-samenegbc: false
secondary-samenegbi: false
secondary-sameoverc: false
secondary-sameoveri: false
secondary-squirrelsc: false
secondary-squirrelsi: true

Added modules/cldc-compact/src/test/resources/lang/TestStringTrim.in.










1
2
3
4
5
6
7
8
9
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:squirrels\_are\_cute
secondary-b: string:squirrels\_are\_cute
secondary-c: string:squirrels\_are\_cute
secondary-d: string:squirrels\_are\_cute
secondary-e: string:
secondary-f: string:

Added modules/cldc-compact/src/test/resources/lang/TestSynchronizedMethod.in.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-after--lock: int:7
secondary-before--lock: int:0
secondary-expected--resume: int:6
secondary-in--lock: int:1
secondary-sub--after--notify: int:4
secondary-sub--after--sleep: int:5
secondary-sub--in--lock: int:3
secondary-thread--created: int:2
secondary-in--lock2: int:8
secondary-thread--created2: int:9
secondary-after--lock2: int:14
secondary-expected--resume2: int:13
secondary-sub--after--notify2: int:11
secondary-sub--after--sleep2: int:12
secondary-sub--in--lock2: int:10

Added modules/cldc-compact/src/test/resources/lang/TestThreadNew.in.




1
2
3
+
+
+
result: true
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/TestThrowInSynchronized.in.




1
2
3
+
+
+
result: ExceptionThrown
thrown: throwable:java.util.NoSuchElementException

Added modules/cldc-compact/src/test/resources/lang/TestTrailingZeros.in.




































































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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: int:962
thrown: NoExceptionThrown
secondary-b0: int:0
secondary-b1: int:1
secondary-b10: int:10
secondary-b11: int:11
secondary-b12: int:12
secondary-b13: int:13
secondary-b14: int:14
secondary-b15: int:15
secondary-b16: int:16
secondary-b17: int:17
secondary-b18: int:18
secondary-b19: int:19
secondary-b2: int:2
secondary-b20: int:20
secondary-b21: int:21
secondary-b22: int:22
secondary-b23: int:23
secondary-b24: int:24
secondary-b25: int:25
secondary-b26: int:26
secondary-b27: int:27
secondary-b28: int:28
secondary-b29: int:29
secondary-b3: int:3
secondary-b30: int:30
secondary-b4: int:4
secondary-b5: int:5
secondary-b6: int:6
secondary-b7: int:7
secondary-b8: int:8
secondary-b9: int:9
secondary-d0: int:0
secondary-d1: int:1
secondary-d10: int:10
secondary-d11: int:11
secondary-d12: int:12
secondary-d13: int:13
secondary-d14: int:14
secondary-d15: int:15
secondary-d16: int:16
secondary-d17: int:17
secondary-d18: int:18
secondary-d19: int:19
secondary-d2: int:2
secondary-d20: int:20
secondary-d21: int:21
secondary-d22: int:22
secondary-d23: int:23
secondary-d24: int:24
secondary-d25: int:25
secondary-d26: int:26
secondary-d27: int:27
secondary-d28: int:28
secondary-d29: int:29
secondary-d3: int:3
secondary-d30: int:30
secondary-d4: int:4
secondary-d5: int:5
secondary-d6: int:6
secondary-d7: int:7
secondary-d8: int:8
secondary-d9: int:9
secondary-zero: int:32


Added modules/cldc-compact/src/test/resources/lang/TestVMIndexOutOfBounds.in.



1
2
+
+
result: ExceptionThrown
thrown: throwable:ArrayIndexOutOfBoundsException

Added modules/cldc-compact/src/test/resources/lang/TestVMInterrupt.in.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-a--after--lock: int:1
secondary-a--after--wait: false
secondary-a--before--lock: int:0
secondary-a--before--wait: false
secondary-a--done: int:9
secondary-a--thread--created: int:2
secondary-a--was--interrupted: int:8
secondary-b--about--to--unlock: int:7
secondary-b--dosleep: int:5
secondary-b--in--lock: int:3
secondary-b--interrupt--a: int:4
secondary-b--sleepdone: int:6

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDup.class.__mime.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
begin-base64 644 TestDup.class
yv66vgAAAC4ADgEAFWxhbmcvYnl0ZWNvZGUvVGVzdER1cAEAClNvdXJjZUZp
bGUBAAY8aW5pdD4BAAMoKUkHAAEMAAMADQoACwAGAQAEQ29kZQEACVRlc3RE
dXAuagEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRlZ2VyBwAK
AQAEdGVzdAEAAygpVgAgAAUACwAAAAAAAgABAAMADQABAAgAAAASAAEAAQAA
AAYZALcAB7EAAAAAAAEADAAEAAEACAAAABIAAgABAAAABhEE0llgrAAAAAAA
AQACAAAAAgAJ
====

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDup.in.



1
2
+
+
result: int:2468
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDup.j.






























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDup
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 2
	
	sipush 1234
	
	dup
	
	iadd
	ireturn
.end method
	

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXOne.class.__mime.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
begin-base64 644 TestDupXOne.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUHAAUBAAY8aW5pdD4BAAMoKUkBABls
YW5nL2J5dGVjb2RlL1Rlc3REdXBYT25lDAADAAwKAAoABgEABENvZGUBACNu
ZXQvbXVsdGlwaGFzaWNhcHBzL3RhYy9UZXN0SW50ZWdlcgcACQEABHRlc3QB
AAMoKVYBAA1UZXN0RHVwWE9uZS5qACAAAgAKAAAAAAACAAEAAwAMAAEACAAA
ABIAAQABAAAABhkAtwAHsQAAAAAAAQALAAQAAQAIAAAAFgADAAEAAAAKEQTS
EQu4WmBgrAAAAAAAAQABAAAAAgAN
====

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXOne.in.



1
2
+
+
result: int:7234
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXOne.j.


































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXOne
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 3
	
	sipush 1234	; b
	sipush 3000	; a
	
	; b, a -> a, b, a
	dup_x1
	
	iadd		; b + a -> x [a, x]
	iadd		; a + x -> y [y]
	
	ireturn
.end method
	

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoIII.class.__mime.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
begin-base64 644 TestDupXTwoIII.class
yv66vgAAAC4ADgEAEFRlc3REdXBYVHdvSUlJLmoHAA0BAApTb3VyY2VGaWxl
AQAGPGluaXQ+AQADKClJDAAEAAwKAAoABgEABENvZGUBACNuZXQvbXVsdGlw
aGFzaWNhcHBzL3RhYy9UZXN0SW50ZWdlcgcACQEABHRlc3QBAAMoKVYBABxs
YW5nL2J5dGVjb2RlL1Rlc3REdXBYVHdvSUlJACAAAgAKAAAAAAACAAEABAAM
AAEACAAAABIAAQABAAAABhkAtwAHsQAAAAAAAQALAAUAAQAIAAAAGgAEAAEA
AAAOEQTSEQu4ER5hW2BgYKwAAAAAAAEAAwAAAAIAAQ==
====

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoIII.in.



1
2
+
+
result: int:19788
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoIII.j.




































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXTwoIII
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 4
	
	sipush 1234	; c
	sipush 3000	; b
	sipush 7777 ; a
	
	; c, b, a -> a, c, b, a
	dup_x2
	
	iadd		; b + a -> x [a, c, x]
	iadd		; c + x -> y [a, y]
	iadd		; a + y -> z [z]
	
	ireturn
.end method
	

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoJI.class.__mime.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
begin-base64 644 TestDupXTwoJI.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUBAAY8aW5pdD4BAAMoKUkMAAIACwoA
CAAEAQAEQ29kZQEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRl
Z2VyBwAHAQAEdGVzdAcADQEAAygpVgEAD1Rlc3REdXBYVHdvSkkuagEAG2xh
bmcvYnl0ZWNvZGUvVGVzdER1cFhUd29KSQAgAAoACAAAAAAAAgABAAIACwAB
AAYAAAASAAEAAQAAAAYZALcABbEAAAAAAAEACQADAAEABgAAABkABQABAAAA
DREE0oURC7hbhWGIYKwAAAAAAAEAAQAAAAIADA==
====

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoJI.in.



1
2
+
+
result: int:7234
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestDupXTwoJI.j.








































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXTwoJI
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 5
	
	sipush 1234	; b
	i2l
	
	sipush 3000 ; a
	
	; J b, I a -> I a, J b, I a
	dup_x2
	
	i2l			; I a -> J a [I a, J b, J a]
	ladd		; J b + J a -> x [I a, J x]
	
	l2i			; J x -> I x [I a, I x]
	
	iadd		; I a + I x -> I y [I y]
	
	ireturn
.end method
	

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestSwap.class.__mime.









1
2
3
4
5
6
7
8
+
+
+
+
+
+
+
+
begin-base64 644 TestSwap.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUBAAY8aW5pdD4BAAMoKUkMAAIADAoA
CQAEAQAEQ29kZQEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRl
Z2VyBwALBwAHAQAEdGVzdAEAFmxhbmcvYnl0ZWNvZGUvVGVzdFN3YXABAAMo
KVYBAApUZXN0U3dhcC5qACAACAAJAAAAAAACAAEAAgAMAAEABgAAABIAAQAB
AAAABhkAtwAFsQAAAAAAAQAKAAMAAQAGAAAAFAACAAEAAAAIEQTSEQu4X6wA
AAAAAAEAAQAAAAIADQ==
====

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestSwap.in.



1
2
+
+
result: int:1234
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/lang/bytecode/TestSwap.j.































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: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestSwap
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 2
	
	sipush 1234	; b
	sipush 3000	; a
	
	; b, a -> a, b
	swap
	
	ireturn
.end method
	

Added modules/cldc-compact/src/test/resources/squirreljme/TestArrayLength.in.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-o: int:-1
secondary-op: int:-1
secondary-z: int:1
secondary-b: int:2
secondary-s: int:3
secondary-c: int:4
secondary-i: int:5
secondary-j: int:6
secondary-f: int:7
secondary-d: int:8
secondary-l: int:9
secondary-zp: int:1
secondary-bp: int:2
secondary-sp: int:3
secondary-cp: int:4
secondary-ip: int:5
secondary-jp: int:6
secondary-fp: int:7
secondary-dp: int:8
secondary-lp: int:9

Added modules/cldc-compact/src/test/resources/squirreljme/TestErrorGetSet.in.





1
2
3
4
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-sameasorig: true
secondary-isset: true

Added modules/cldc-compact/src/test/resources/squirreljme/TestPointerAccess.in.







1
2
3
4
5
6
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-otpnotnull: true
secondary-sameobject: true
secondary-zeroisnull: true
secondary-nulliszero: true

Added modules/cldc-compact/src/test/resources/squirreljme/TestSystemTime.in.





1
2
3
4
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-mw: int:0
secondary-nm: int:0

Added modules/cldc-compact/src/test/resources/util/TestArrayBinarySearch.in.




1
2
3
+
+
+
result: long:4611686018427387903
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/util/TestArrayDequeDeque.in.

Added modules/cldc-compact/src/test/resources/util/TestHashMap.in.



































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-hashcode: int:5740575
secondary-initempty: true
secondary-initsize: int:0
secondary-firstcontained: true
secondary-firstvalue: string:Squirrels
secondary-firstcontainednew: true
secondary-firstvaluenew: string:Squirrels
secondary-firstsize: int:1
secondary-firsthassecond: false
secondary-secondcontained: true
secondary-secondvalue: string:Cute
secondary-secondsize: int:2
secondary-replaceput: string:Squirrels
secondary-replacevalue: string:Cute
secondary-replacesecondvalue: string:Cute
secondary-replacesize: int:2
secondary-dumpsize: int:130
secondary-ithasfirst: string:Cute
secondary-itafterhasfirst: false
secondary-itputfirstagain: null
secondary-removesecond: string:Cute
secondary-removesize: int:129
secondary-hasanother: string:Adorable
secondary-hasanothersize: int:130
secondary-clearsize: int:0
secondary-reusedcontained: true
secondary-reusedvalue: string:Squirrels
secondary-reusedcontainednew: true
secondary-reusedvaluenew: string:Squirrels
secondary-reusedsize: int:1
secondary-reusedhassecond: false

Added modules/cldc-compact/src/test/resources/util/TestHashMapNaN.in.



1
2
+
+
result: true
thrown: NoExceptionThrown

Added modules/cldc-compact/src/test/resources/util/TestHashtable.in.




1
2
3
+
+
+
secondary-nullkey: true
secondary-nullval: true
secondary-nullset: true

Added modules/cldc-compact/src/test/resources/util/TestLinkedHashMap.in.


































































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-acontentsa: string:\(1989=Cute,\_2018=Cute,\_0=0,\_1=1,\_2=2
 ,\_3=3,\_4=4,\_5=5,\_6=6,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_1
 3=13,\_14=14,\_15=15,\_16=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\
 _22=22,\_23=23,\_24=24,\_25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30
 ,\_31=31,\_32=32,\_33=33,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=
 39,\_40=40,\_41=41,\_42=42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_4
 8=48,\_49=49,\_50=50,\_51=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\
 _57=57,\_58=58,\_59=59,\_60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65
 ,\_66=66,\_67=67,\_68=68,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=
 74,\_75=75,\_76=76,\_77=77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_8
 3=83,\_84=84,\_85=85,\_86=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\
 _92=92,\_93=93,\_94=94,\_95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=1
 00,\_101=101,\_102=102,\_103=103,\_104=104,\_105=105,\_106=106,\_107=1
 07,\_108=108,\_109=109,\_110=110,\_111=111,\_112=112,\_113=113,\_114=1
 14,\_115=115,\_116=116,\_117=117,\_118=118,\_119=119,\_120=120,\_121=1
 21,\_122=122,\_123=123,\_124=124,\_125=125,\_126=126,\_127=127\)
secondary-acontentsb: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Cute,\_-1=Adorable\)
secondary-acontentsc: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Squirrels,\_-1=Adorable\
 )
secondary-adumpsize: int:130
secondary-afirstcontained: true
secondary-afirstcontainednew: true
secondary-afirsthassecond: false
secondary-afirstsize: int:1
secondary-afirstvalue: string:Squirrels
secondary-afirstvaluenew: string:Squirrels
secondary-ahasanother: string:Adorable
secondary-ahasanothersize: int:130
secondary-ahashcode: int:5740575
secondary-ainitempty: true
secondary-ainitsize: int:0
secondary-aitafterhasfirst: false
secondary-aithasfirst: string:Cute
secondary-aitputfirstagain: null
secondary-aremovesecond: string:Cute
secondary-aremovesize: int:129
secondary-areplaceput: string:Squirrels
secondary-areplacesecondvalue: string:Cute
secondary-areplacesize: int:2
secondary-areplacevalue: string:Cute
secondary-areusedcontained: true
secondary-areusedcontainednew: true
secondary-areusedhassecond: false
secondary-areusedsize: int:130
secondary-areusedvalue: string:Squirrels
secondary-areusedvaluenew: string:Squirrels
secondary-asecondcontained: true
secondary-asecondsize: int:2
secondary-asecondvalue: string:Cute
secondary-bcontentsa: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Cute,\_-1=Adorable,\_201
 8=Cute\)
secondary-bcontentsb: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_-1=Adorable,\_1989=Cute\)
secondary-bcontentsc: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_-1=Adorable,\_1989=Squirrels\
 )
secondary-bdumpsize: int:131
secondary-bfirstcontained: true
secondary-bfirstcontainednew: true
secondary-bfirsthassecond: false
secondary-bfirstsize: int:130
secondary-bfirstvalue: string:Squirrels
secondary-bfirstvaluenew: string:Squirrels
secondary-bhasanother: string:Adorable
secondary-bhasanothersize: int:130
secondary-bhashcode: int:845026398
secondary-binitempty: false
secondary-binitsize: int:130
secondary-bitafterhasfirst: false
secondary-bithasfirst: string:Cute
secondary-bitputfirstagain: null
secondary-bremovesecond: string:Cute
secondary-bremovesize: int:130
secondary-breplaceput: string:Squirrels
secondary-breplacesecondvalue: string:Cute
secondary-breplacesize: int:131
secondary-breplacevalue: string:Cute
secondary-breusedcontained: true
secondary-breusedcontainednew: true
secondary-breusedhassecond: false
secondary-breusedsize: int:130
secondary-breusedvalue: string:Squirrels
secondary-breusedvaluenew: string:Squirrels
secondary-bsecondcontained: true
secondary-bsecondsize: int:131
secondary-bsecondvalue: string:Cute

Added modules/cldc-compact/src/test/resources/util/TestLinkedHashMapEldest.in.





























































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-eldest0add: int:0
secondary-eldest10add: int:5
secondary-eldest11key: int:0
secondary-eldest11val: string:Value0
secondary-eldest12add: int:6
secondary-eldest13key: int:0
secondary-eldest13val: string:Value0
secondary-eldest14add: int:7
secondary-eldest15key: int:0
secondary-eldest15val: string:Value0
secondary-eldest16add: int:8
secondary-eldest17key: int:0
secondary-eldest17val: string:Value0
secondary-eldest18add: int:9
secondary-eldest19key: int:0
secondary-eldest19val: string:Value0
secondary-eldest1key: int:0
secondary-eldest1val: string:Value0
secondary-eldest20add: int:10
secondary-eldest21key: int:0
secondary-eldest21val: string:Value0
secondary-eldest22add: int:11
secondary-eldest23key: int:1
secondary-eldest23val: string:Value1
secondary-eldest24add: int:12
secondary-eldest25key: int:2
secondary-eldest25val: string:Value2
secondary-eldest26add: int:13
secondary-eldest27key: int:3
secondary-eldest27val: string:Value3
secondary-eldest28add: int:14
secondary-eldest29key: int:4
secondary-eldest29val: string:Value4
secondary-eldest2add: int:1
secondary-eldest30add: int:15
secondary-eldest31key: int:5
secondary-eldest31val: string:Value5
secondary-eldest32add: int:16
secondary-eldest33key: int:6
secondary-eldest33val: string:Value6
secondary-eldest34add: int:17
secondary-eldest35key: int:7
secondary-eldest35val: string:Value7
secondary-eldest36add: int:18
secondary-eldest37key: int:8
secondary-eldest37val: string:Value8
secondary-eldest38add: int:19
secondary-eldest39key: int:9
secondary-eldest39val: string:Value9
secondary-eldest3key: int:0
secondary-eldest3val: string:Value0
secondary-eldest40add: int:20
secondary-eldest41key: int:10
secondary-eldest41val: string:Value10
secondary-eldest42add: int:21
secondary-eldest43key: int:11
secondary-eldest43val: string:Value11
secondary-eldest44add: int:22
secondary-eldest45key: int:12
secondary-eldest45val: string:Value12
secondary-eldest46add: int:23
secondary-eldest47key: int:13
secondary-eldest47val: string:Value13
secondary-eldest48add: int:24
secondary-eldest49key: int:14
secondary-eldest49val: string:Value14
secondary-eldest4add: int:2
secondary-eldest50add: int:25
secondary-eldest51key: int:15
secondary-eldest51val: string:Value15
secondary-eldest52add: int:26
secondary-eldest53key: int:16
secondary-eldest53val: string:Value16
secondary-eldest54add: int:27
secondary-eldest55key: int:17
secondary-eldest55val: string:Value17
secondary-eldest56add: int:28
secondary-eldest57key: int:18
secondary-eldest57val: string:Value18
secondary-eldest58add: int:29
secondary-eldest59key: int:19
secondary-eldest59val: string:Value19
secondary-eldest5key: int:0
secondary-eldest5val: string:Value0
secondary-eldest60add: int:30
secondary-eldest61key: int:20
secondary-eldest61val: string:Value20
secondary-eldest62add: int:31
secondary-eldest63key: int:21
secondary-eldest63val: string:Value21
secondary-eldest64add: int:32
secondary-eldest65key: int:22
secondary-eldest65val: string:Value22
secondary-eldest66add: int:33
secondary-eldest67key: int:23
secondary-eldest67val: string:Value23
secondary-eldest68add: int:34
secondary-eldest69key: int:24
secondary-eldest69val: string:Value24
secondary-eldest6add: int:3
secondary-eldest70add: int:35
secondary-eldest71key: int:25
secondary-eldest71val: string:Value25
secondary-eldest72add: int:36
secondary-eldest73key: int:26
secondary-eldest73val: string:Value26
secondary-eldest74add: int:37
secondary-eldest75key: int:27
secondary-eldest75val: string:Value27
secondary-eldest76add: int:38
secondary-eldest77key: int:28
secondary-eldest77val: string:Value28
secondary-eldest78add: int:39
secondary-eldest79key: int:29
secondary-eldest79val: string:Value29
secondary-eldest7key: int:0
secondary-eldest7val: string:Value0
secondary-eldest80add: int:40
secondary-eldest81key: int:30
secondary-eldest81val: string:Value30
secondary-eldest82add: int:41
secondary-eldest83key: int:31
secondary-eldest83val: string:Value31
secondary-eldest84add: int:42
secondary-eldest85key: int:32
secondary-eldest85val: string:Value32
secondary-eldest86add: int:43
secondary-eldest87key: int:33
secondary-eldest87val: string:Value33
secondary-eldest88add: int:44
secondary-eldest89key: int:34
secondary-eldest89val: string:Value34
secondary-eldest8add: int:4
secondary-eldest90add: int:45
secondary-eldest91key: int:35
secondary-eldest91val: string:Value35
secondary-eldest92add: int:46
secondary-eldest93key: int:36
secondary-eldest93val: string:Value36
secondary-eldest94add: int:47
secondary-eldest95key: int:37
secondary-eldest95val: string:Value37
secondary-eldest96add: int:48
secondary-eldest97key: int:38
secondary-eldest97val: string:Value38
secondary-eldest98add: int:49
secondary-eldest99key: int:39
secondary-eldest99val: string:Value39
secondary-eldest9key: int:0
secondary-eldest9val: string:Value0
secondary-ordkeys: int[10]:40,41,42,43,44,45,46,47,48,49
secondary-ordvals: string[10]:Value40,Value41,Value42,Value43,Value44,
 Value45,Value46,Value47,Value48,Value49

Added modules/cldc-compact/src/test/resources/util/TestLinkedHashSet.in.





1
2
3
4
+
+
+
+
result: int:205464769
thrown: NoExceptionThrown
secondary-intotal: int:205464769
secondary-hashcode: int:205464769

Added modules/cldc-compact/src/test/resources/util/TestLinkedListDeque.in.


1
+
secondary-hashcode: int:1315173338

Added modules/cldc-compact/src/test/resources/util/TestRandom.in.




































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-boolean--00: true
secondary-boolean--01: true
secondary-boolean--02: true
secondary-boolean--03: false
secondary-boolean--04: false
secondary-boolean--05: true
secondary-boolean--06: true
secondary-boolean--07: true
secondary-boolean--08: true
secondary-boolean--09: false
secondary-boolean--10: false
secondary-boolean--11: true
secondary-boolean--12: false
secondary-boolean--13: true
secondary-boolean--14: true
secondary-boolean--15: false
secondary-boolean--16: true
secondary-boolean--17: false
secondary-boolean--18: false
secondary-boolean--19: false
secondary-boolean--20: true
secondary-boolean--21: false
secondary-boolean--22: false
secondary-boolean--23: true
secondary-boolean--24: true
secondary-boolean--25: true
secondary-boolean--26: false
secondary-boolean--27: true
secondary-boolean--28: false
secondary-boolean--29: false
secondary-boolean--30: true
secondary-boolean--31: true
secondary-int--00: int:-128266353
secondary-int--01: int:1948586741
secondary-int--02: int:-737493750
secondary-int--03: int:-1691956655
secondary-int--04: int:981813466
secondary-int--05: int:-162976284
secondary-int--06: int:914154380
secondary-int--07: int:453943797
secondary-int--08: int:-1545361761
secondary-int--09: int:1742258951
secondary-int--10: int:1884219158
secondary-int--11: int:1240009219
secondary-int--12: int:-150729253
secondary-int--13: int:-103157653
secondary-int--14: int:1955413213
secondary-int--15: int:1734636865
secondary-int--16: int:1214260749
secondary-int--17: int:1428227275
secondary-int--18: int:1515069861
secondary-int--19: int:622848097
secondary-int--20: int:425202528
secondary-int--21: int:1696159965
secondary-int--22: int:1491573386
secondary-int--23: int:990471538
secondary-int--24: int:-2068721
secondary-int--25: int:-1104025112
secondary-int--26: int:-813810180
secondary-int--27: int:-1351411048
secondary-int--28: int:-2056461820
secondary-int--29: int:367036826
secondary-int--30: int:717818122
secondary-int--31: int:801130495
secondary-long--00: long:-3163983508611287273
secondary-long--01: long:1650222797263606028
secondary-long--02: long:6817728031649985877
secondary-long--03: long:-3610267759146193707
secondary-long--04: long:-2536078921006665050
secondary-long--05: long:-5303301747738367533
secondary-long--06: long:5521166055606326678
secondary-long--07: long:7264686321048172758
secondary-long--08: long:-7012317779647905034
secondary-long--09: long:7862271327053001528
secondary-long--10: long:-1901553912186736328
secondary-long--11: long:1119445396624625749
secondary-long--12: long:5235895235630161149
secondary-long--13: long:8069826110581587514
secondary-long--14: long:4458715635812528876
secondary-long--15: long:-4444455872085454437
secondary-long--16: long:3777918499557884613
secondary-long--17: long:3889224343776968970
secondary-long--18: long:-8667154457880916043
secondary-long--19: long:-4224915374486675610
secondary-long--20: long:6685784791951315435
secondary-long--21: long:-5103934627298473583
secondary-long--22: long:-6889010091118281366
secondary-long--23: long:5325327304787082085
secondary-long--24: long:5970574507478393377
secondary-long--25: long:8285736199708606439
secondary-long--26: long:7011400902825490744
secondary-long--27: long:-6505535853870468931
secondary-long--28: long:-7388450604473437268
secondary-long--29: long:-9133519556251469603
secondary-long--30: long:-8160769781198250467
secondary-long--31: long:3623915951947550343
secondary-range--00: int:0
secondary-range--01: int:0
secondary-range--02: int:1
secondary-range--03: int:1
secondary-range--04: int:2
secondary-range--05: int:1
secondary-range--06: int:5
secondary-range--07: int:4
secondary-range--08: int:7
secondary-range--09: int:8
secondary-range--10: int:0
secondary-range--11: int:2
secondary-range--12: int:3
secondary-range--13: int:3
secondary-range--14: int:7
secondary-range--15: int:12
secondary-range--16: int:8
secondary-range--17: int:9
secondary-range--18: int:7
secondary-range--19: int:15
secondary-range--20: int:11
secondary-range--21: int:16
secondary-range--22: int:10
secondary-range--23: int:17
secondary-range--24: int:18
secondary-range--25: int:24
secondary-range--26: int:6
secondary-range--27: int:1
secondary-range--28: int:3
secondary-range--29: int:0
secondary-range--30: int:11
secondary-range--31: int:26

Added modules/cldc-compact/src/test/resources/util/TestRandomFloat.in.



































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-double--00: long:4583909210855270848
secondary-double--01: long:4602738393933575197
secondary-double--02: long:4603742102265903055
secondary-double--03: long:4604590768449826100
secondary-double--04: long:4604613072216156731
secondary-double--05: long:4603238476080670868
secondary-double--06: long:4600290051921914700
secondary-double--07: long:4606717221631719828
secondary-double--08: long:4582504350769550560
secondary-double--09: long:4602152829906238736
secondary-double--10: long:4606772738959557498
secondary-double--11: long:4607057355126703601
secondary-double--12: long:4598489981875330452
secondary-double--13: long:4576807129618328640
secondary-double--14: long:4606376720726924374
secondary-double--15: long:4604315246192439139
secondary-double--16: long:4605311185659059328
secondary-double--17: long:4600375544876332514
secondary-double--18: long:4600953627928857584
secondary-double--19: long:4604075885202442894
secondary-double--20: long:4599595528618966298
secondary-double--21: long:4602009499117278822
secondary-double--22: long:4595423160873490792
secondary-double--23: long:4598336528600956288
secondary-double--24: long:4604181088498391135
secondary-double--25: long:4590756644732688040
secondary-double--26: long:4601747187517950818
secondary-double--27: long:4598024309499659892
secondary-double--28: long:4583584827350993536
secondary-double--29: long:4596064983813882400
secondary-double--30: long:4595798268525523916
secondary-double--31: long:4590286194157885920
secondary-float--00: int:1064428361
secondary-float--01: int:1056498462
secondary-float--02: int:1057309969
secondary-float--03: int:1027839328
secondary-float--04: int:1032745072
secondary-float--05: int:1031774640
secondary-float--06: int:1061677308
secondary-float--07: int:1064592218
secondary-float--08: int:1057850516
secondary-float--09: int:1050973560
secondary-float--10: int:1064445530
secondary-float--11: int:1060042316
secondary-float--12: int:1030816640
secondary-float--13: int:1063160622
secondary-float--14: int:1058726493
secondary-float--15: int:1052115186
secondary-float--16: int:1064119846
secondary-float--17: int:1054339600
secondary-float--18: int:1062701626
secondary-float--19: int:1031105824
secondary-float--20: int:1059194506
secondary-float--21: int:993181952
secondary-float--22: int:1057526466
secondary-float--23: int:1061922672
secondary-float--24: int:1057421954
secondary-float--25: int:1045750832
secondary-float--26: int:1058543673
secondary-float--27: int:1060877318
secondary-float--28: int:1058661909
secondary-float--29: int:1062276535
secondary-float--30: int:1062789292
secondary-float--31: int:1020083488
secondary-gauss--00: long:-4623803088418409174
secondary-gauss--01: long:4584133852783928400
secondary-gauss--02: long:-4627394787988143985
secondary-gauss--03: long:-4626611366287662152
secondary-gauss--04: long:4609881647929977493
secondary-gauss--05: long:-4617068582227882878
secondary-gauss--06: long:-4618958457578674353
secondary-gauss--07: long:4609087581065641843
secondary-gauss--08: long:4591487963111091550
secondary-gauss--09: long:4590448397979296854
secondary-gauss--10: long:-4632370091595809028
secondary-gauss--11: long:4608509811925940350
secondary-gauss--12: long:4602249218918814087
secondary-gauss--13: long:4590523063934368092
secondary-gauss--14: long:-4614310018215318234
secondary-gauss--15: long:-4617920598175668757
secondary-gauss--16: long:-4613994234367488310
secondary-gauss--17: long:-4621339478468475950
secondary-gauss--18: long:4608279811145892292
secondary-gauss--19: long:-4624123072180092538
secondary-gauss--20: long:4611752626028141074
secondary-gauss--21: long:4606682148419602193
secondary-gauss--22: long:4586613298334863399
secondary-gauss--23: long:-4628618392113107096
secondary-gauss--24: long:4604616087800580199
secondary-gauss--25: long:4606989109614282399
secondary-gauss--26: long:4606481251143648582
secondary-gauss--27: long:4605185051404723134
secondary-gauss--28: long:-4614152961942226543
secondary-gauss--29: long:-4616674189163974394
secondary-gauss--30: long:4599325178184023106
secondary-gauss--31: long:-4622107386309634845

Added modules/cldc-compact/src/test/resources/util/TestServiceLoader.in.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-again--util-dserviceloader-dimpls-dcomfortabledrey: string:A
 \_very\_comfortable\_drey!
secondary-again--util-dserviceloader-dimpls-dcutesquirrels: string:Cut
 e\_squirrels!
secondary-again--util-dserviceloader-dimpls-dstashtheacorns: string:St
 ash\_all\_the\_acorns!
secondary-cache--util-dserviceloader-dimpls-dcomfortabledrey: string:A
 \_very\_comfortable\_drey!
secondary-cache--util-dserviceloader-dimpls-dcutesquirrels: string:Cut
 e\_squirrels!
secondary-cache--util-dserviceloader-dimpls-dstashtheacorns: string:St
 ash\_all\_the\_acorns!
secondary-init--util-dserviceloader-dimpls-dcomfortabledrey: string:A\
 _very\_comfortable\_drey!
secondary-init--util-dserviceloader-dimpls-dcutesquirrels: string:Cute
 \_squirrels!
secondary-init--util-dserviceloader-dimpls-dstashtheacorns: string:Sta
 sh\_all\_the\_acorns!

Added modules/cldc-compact/src/test/resources/util/TestSorting.in.






























































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-arraybyte01: byte[1]:-85
secondary-arraybyte02: byte[2]:-85,1
secondary-arraybyte03: byte[3]:-85,-57,1
secondary-arraybyte04: byte[4]:-85,-80,-57,1
secondary-arraybyte08: byte[8]:-113,-102,-92,-85,-80,-57,1,36
secondary-arraybyte13: byte[13]:-125,-113,-102,-94,-92,-85,-80,-61,-57
 ,1,17,36,47
secondary-arraybyte26: byte[26]:-125,-113,-102,-99,-94,-92,-92,-85,-80
 ,-75,-61,-57,-37,-31,-4,1,1,2,17,36,47,52,58,95,100,115
secondary-arraychar01: char[1]:26283
secondary-arraychar02: char[2]:26283,46337
secondary-arraychar03: char[3]:26283,46337,51911
secondary-arraychar04: char[4]:8880,26283,46337,51911
secondary-arraychar08: char[8]:410,8880,15268,26283,46337,51911,57124,
 59791
secondary-arraychar13: char[13]:410,785,4258,8880,15268,15919,26283,33
 987,46337,51911,52099,57124,59791
secondary-arraychar26: char[26]:410,785,1505,4258,4609,6003,6052,8880,
 15268,15919,19508,24415,26283,32731,33987,37301,40605,43772,46180,4633
 7,47674,51911,52099,56834,57124,59791
secondary-arrayint01: int[1]:-1442945365
secondary-arrayint02: int[2]:-1442945365,-1016548095
secondary-arrayint03: int[3]:-1442945365,-1016548095,1962592967
secondary-arrayint04: int[4]:-1442945365,-1016548095,1094656688,196259
 2967
secondary-arrayint08: int[8]:-1442945365,-1016548095,-458096230,930275
 108,1094656688,1677212580,1827465615,1962592967
secondary-arrayint13: int[13]:-1442945365,-1075280701,-1016548095,-458
 096230,930275108,1094656688,1543966882,1677212580,1827465615,185114577
 5,1962592967,2041709329,2105985923
secondary-arrayint26: int[26]:-2145218123,-1872816220,-1574936737,-144
 2945365,-1075280701,-1016548095,-458096230,-223996045,68659964,4926387
 21,505839579,823057922,930275108,1068715060,1094656688,1178377885,1543
 966882,1677212580,1754641508,1827465615,1851145775,1962592967,20417093
 29,2054142522,2092500449,2105985923
secondary-arrayobject01: int[1]:-1442945365
secondary-arrayobject02: int[2]:-1442945365,-1016548095
secondary-arrayobject03: int[3]:-1442945365,-1016548095,1962592967
secondary-arrayobject04: int[4]:-1442945365,-1016548095,1094656688,196
 2592967
secondary-arrayobject08: int[8]:-1442945365,-1016548095,-458096230,930
 275108,1094656688,1677212580,1827465615,1962592967
secondary-arrayobject13: int[13]:-1442945365,-1075280701,-1016548095,-
 458096230,930275108,1094656688,1543966882,1677212580,1827465615,185114
 5775,1962592967,2041709329,2105985923
secondary-arrayobject26: int[26]:-2145218123,-1872816220,-1574936737,-
 1442945365,-1075280701,-1016548095,-458096230,-223996045,68659964,4926
 38721,505839579,823057922,930275108,1068715060,1094656688,1178377885,1
 543966882,1677212580,1754641508,1827465615,1851145775,1962592967,20417
 09329,2054142522,2092500449,2105985923
secondary-arrayshort01: short[1]:26283
secondary-arrayshort02: short[2]:-19199,26283
secondary-arrayshort03: short[3]:-19199,-13625,26283
secondary-arrayshort04: short[4]:-19199,-13625,8880,26283
secondary-arrayshort08: short[8]:-19199,-13625,-8412,-5745,410,8880,15
 268,26283
secondary-arrayshort13: short[13]:-31549,-19199,-13625,-13437,-8412,-5
 745,410,785,4258,8880,15268,15919,26283
secondary-arrayshort26: short[26]:-31549,-28235,-24931,-21764,-19356,-
 19199,-17862,-13625,-13437,-8702,-8412,-5745,410,785,1505,4258,4609,60
 03,6052,8880,15268,15919,19508,24415,26283,32731
secondary-listarray01: int[1]:-1442945365
secondary-listarray02: int[2]:-1442945365,-1016548095
secondary-listarray03: int[3]:-1442945365,-1016548095,1962592967
secondary-listarray04: int[4]:-1442945365,-1016548095,1094656688,19625
 92967
secondary-listarray08: int[8]:-1442945365,-1016548095,-458096230,93027
 5108,1094656688,1677212580,1827465615,1962592967
secondary-listarray13: int[13]:-1442945365,-1075280701,-1016548095,-45
 8096230,930275108,1094656688,1543966882,1677212580,1827465615,18511457
 75,1962592967,2041709329,2105985923
secondary-listarray26: int[26]:-2145218123,-1872816220,-1574936737,-14
 42945365,-1075280701,-1016548095,-458096230,-223996045,68659964,492638
 721,505839579,823057922,930275108,1068715060,1094656688,1178377885,154
 3966882,1677212580,1754641508,1827465615,1851145775,1962592967,2041709
 329,2054142522,2092500449,2105985923
secondary-listlinked01: int[1]:-1442945365
secondary-listlinked02: int[2]:-1442945365,-1016548095
secondary-listlinked03: int[3]:-1442945365,-1016548095,1962592967
secondary-listlinked04: int[4]:-1442945365,-1016548095,1094656688,1962
 592967
secondary-listlinked08: int[8]:-1442945365,-1016548095,-458096230,9302
 75108,1094656688,1677212580,1827465615,1962592967
secondary-listlinked13: int[13]:-1442945365,-1075280701,-1016548095,-4
 58096230,930275108,1094656688,1543966882,1677212580,1827465615,1851145
 775,1962592967,2041709329,2105985923
secondary-listlinked26: int[26]:-2145218123,-1872816220,-1574936737,-1
 442945365,-1075280701,-1016548095,-458096230,-223996045,68659964,49263
 8721,505839579,823057922,930275108,1068715060,1094656688,1178377885,15
 43966882,1677212580,1754641508,1827465615,1851145775,1962592967,204170
 9329,2054142522,2092500449,2105985923

Added modules/cldc-compact/src/test/resources/util/__TestDeque__.in.








































































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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-array: int[17]:1234,200,100,0,1,2,3,4,5,6,7,8,9,300,400,500,600
secondary-array2: int[10]:2,3,4,5,6,7,8,9,300,400
secondary-element: int:1
secondary-getfirst: int:200
secondary-getlast: int:400
secondary-init--add--0: true
secondary-init--add--1: true
secondary-init--add--2: true
secondary-init--add--3: true
secondary-init--add--4: true
secondary-init--add--5: true
secondary-init--add--6: true
secondary-init--add--7: true
secondary-init--add--8: true
secondary-init--add--9: true
secondary-iterator--ascending: int[17]:
 1234,200,100,0,1,2,3,4,5,6,7,8,9,300,400,500,600
secondary-iterator--descending: int[17]:
 600,500,400,300,9,8,7,6,5,4,3,2,1,0,100,200,1234
secondary-offer--first: true
secondary-offer--last: true
secondary-peek: int:1
secondary-peekfirst: int:100
secondary-peeklast: int:400
secondary-poll: int:0
secondary-pollfirst: int:200
secondary-polllast: int:500
secondary-pop: int:1
secondary-remove: int:100
secondary-removefirst: int:1234
secondary-removelast: int:600
secondary-size--a: int:12
secondary-size--b: int:17
secondary-remove--first--0: true
secondary-remove--first--10: false
secondary-remove--first--12: false
secondary-remove--first--14: false
secondary-remove--first--2: true
secondary-remove--first--4: true
secondary-remove--first--6: true
secondary-remove--first--8: true
secondary-remove--last--1: true
secondary-remove--last--11: false
secondary-remove--last--13: false
secondary-remove--last--3: true
secondary-remove--last--5: true
secondary-remove--last--7: true
secondary-remove--last--9: true
secondary-other--add--0: true
secondary-other--add--1: true
secondary-other--add--2: true
secondary-other--add--3: true
secondary-other--add--4: true
secondary-other--add--5: true
secondary-other--add--6: true
secondary-other--add--7: true
secondary-other--add--8: true
secondary-other--add--9: true
secondary-has14: false
secondary-has500: false
secondary-has7: true
secondary-array3: int[20]:2,3,4,5,6,7,8,9,300,400,0,1,2,3,4,5,6,7,8,9
secondary-array4: int[15]:3,5,7,9,300,400,1,2,3,4,5,6,7,8,9
secondary-array5: int[10]:3,5,7,9,300,400,2,4,6,8
secondary-array6: int[0]:
secondary-arrayover: int[34]:1234,200,100,0,1,2,3,4,5,6,7,8,
 9,300,400,500,600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
secondary-arraygrow: int[17]:1234,200,100,0,1,2,3,4,5,6,7,8,
 9,300,400,500,600

Added modules/cldc-compact/src/test/resources/util/__TestList__.in.





































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
MANIFEST-VERSION: 1.0
result: NoResult
thrown: NoExceptionThrown
secondary-add1: true
secondary-add10: true
secondary-add11: true
secondary-add12: true
secondary-add13: true
secondary-add14: true
secondary-add15: true
secondary-add16: true
secondary-add17: true
secondary-add2: true
secondary-add3: true
secondary-add4: true
secondary-add5: true
secondary-add6: true
secondary-add7: true
secondary-add8: true
secondary-add9: true
secondary-addempty: false
secondary-addsize: int:4
secondary-array: string[13]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,Squi
 rrels!
secondary-arrayover: string[30]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,
 Squirrels!,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL
 ,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL
secondary-arrowgrow: string[13]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,
 Squirrels!
secondary-bulkempty: false
secondary-bulksize: int:19
secondary-clearempty: true
secondary-clearsize: int:0
secondary-get13: string:Is!
secondary-get17: string:16
secondary-get2: string:1
secondary-get29: throwable:IndexOutOfBoundsException,RuntimeException,
 Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_19
secondary-get6: string:Xer!
secondary-hascuteafter: false
secondary-hascutebefore: true
secondary-hashcode: int:1797125451
secondary-hasmoresquirrels: true
secondary-hasmoresquirrelsstill: true
secondary-initialioob: throwable:IndexOutOfBoundsException,RuntimeExce
 ption,Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_0
secondary-initialisempty: true
secondary-initialnocont: false
secondary-initialzerosize: int:0
secondary-itequal0: true
secondary-itequal1: true
secondary-itequal10: true
secondary-itequal11: true
secondary-itequal12: true
secondary-itequal13: true
secondary-itequal14: true
secondary-itequal15: true
secondary-itequal16: true
secondary-itequal17: true
secondary-itequal18: true
secondary-itequal2: true
secondary-itequal3: true
secondary-itequal4: true
secondary-itequal5: true
secondary-itequal6: true
secondary-itequal7: true
secondary-itequal8: true
secondary-itequal9: true
secondary-moresquirrels: true
secondary-noneleft: throwable:java.util.NoSuchElementException,java.la
 ng.RuntimeException,Exception,Throwable
secondary-previtequal0: true
secondary-previtequal1: true
secondary-previtequal10: true
secondary-previtequal11: true
secondary-previtequal12: true
secondary-previtequal13: true
secondary-previtequal14: true
secondary-previtequal15: true
secondary-previtequal2: true
secondary-previtequal3: true
secondary-previtequal4: true
secondary-previtequal5: true
secondary-previtequal6: true
secondary-previtequal7: true
secondary-previtequal8: true
secondary-previtequal9: true
secondary-prevnoneleft: throwable:java.util.NoSuchElementException,jav
 a.lang.RuntimeException,Exception,Throwable
secondary-removeempty: false
secondary-removeindex: string:Are!
secondary-removemoresquirrels: true
secondary-removesize: int:2
secondary-removevalue: true
secondary-set13: string:12
secondary-set29: throwable:IndexOutOfBoundsException,RuntimeException,
 Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_19
secondary-set6: string:5
secondary-stringform: string:[Hello!,\_1,\_2,\_Xer!,\_6,\_8,\_10,\_11,
 \_13,\_14,\_16,\_17,\_Squirrels!]

Added modules/cldc/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEConfiguration
import cc.squirreljme.plugin.swm.JavaMEMidletType

version = "1.8.${rootProject.ext.squirreljmeVMVersion}"
description = "This is the standard Java ME 8 Connection " +
	"Limited Device Configuration which contains the full set of classes " +
	"used by JavaME."

squirreljme
{
	javaDocErrorCode = "ZY"
	swmType = JavaMEMidletType.API
	swmName = "Connection Limited Device Configuration"
	swmVendor = "Stephanie Gawroriski"
	definedConfigurations += new JavaMEConfiguration("CLDC-1.8")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/cldc/src/main/java/cc/squirreljme/runtime/cldc/full/NullFileSystem.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.full;

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * This is a file system which is completely nullary.
 *
 * @since 2019/12/22
 */
public final class NullFileSystem
	extends FileSystem
{
	/** The instance of this filesystem. */
	public static final NullFileSystem INSTANCE =
		new NullFileSystem();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Has no effect
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterable<FileStore> getFileStores()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getPath(String __base, String... __more)
		throws NullPointerException
	{
		if (__base == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZY01 The null filesystem only supports a single
		// path element.}
		if (!__base.equals(NullPath.ONLY_PATH_STRING))
			throw new InvalidPathException(__base, "ZY01");
		
		// {@squirreljme.error ZY02 Additional null path elements must be
		// blank or null.}
		if (__more != null)
			for (String m : __more)
				if (m != null && !m.isEmpty())
					throw new InvalidPathException(m, "ZY02");
		
		return NullPath.INSTANCE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterable<Path> getRootDirectories()
	{
		// There is only a single null root
		return Arrays.<Path>asList(this.getPath("null:$"));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final String getSeparator()
	{
		// Null file system uses dollar signs as paths
		return "$";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isOpen()
	{
		// Always is open
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isReadOnly()
	{
		// File system is always read-only
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Set<String> supportedFileAttributeViews()
	{
		// No attributes are supported
		return new HashSet<>();
	}
}

Added modules/cldc/src/main/java/cc/squirreljme/runtime/cldc/full/NullPath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.cldc.full;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Iterator;

/**
 * This represents a null path.
 *
 * @since 2019/12/22
 */
public class NullPath
	implements Path
{
	/** The only valid path permitted. */
	public static final String ONLY_PATH_STRING =
		"null:$";
	
	/** The instance of this class. */
	public static final Path INSTANCE =
		new NullPath();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int compareTo(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean endsWith(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean endsWith(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getFileName()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final FileSystem getFileSystem()
	{
		return NullFileSystem.INSTANCE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getName(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int getNameCount()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getParent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getRoot()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isAbsolute()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterator<Path> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path normalize()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path relativize(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolve(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolve(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolveSibling(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolveSibling(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean startsWith(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean startsWith(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path subpath(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path toAbsolutePath()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path toRealPath(LinkOption... __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc/src/main/java/cc/squirreljme/runtime/cldc/full/StandardPaths.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.full;

import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

/**
 * This class contains the standard set of paths which is where SquirrelJME's
 * data is stored.
 *
 * @since 2018/01/13
 */
public final class StandardPaths
{
	/**
	 * {@squirreljme.property cc.squirreljme.home=path
	 * This specifies the singular base for where the user configuration,
	 * library, and cache data is stored.}
	 */
	public static final String HOME_PROPERTY =
		"cc.squirreljme.home";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_HOME=path
	 * This specifies the singular base for where the user configuration,
	 * library, and cache data is stored.}
	 */
	public static final String HOME_ENV =
		"SQUIRRELJME_HOME";
	
	/**
	 * {@squirreljme.property cc.squirreljme.path.config=path
	 * This specifies the location where configuration files are stored.}
	 */
	public static final String CONFIG_PATH_PROPERTY =
		"cc.squirreljme.path.config";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_CONFIG_PATH=path
	 * This specifies the location where configuration files are stored.}
	 */
	public static final String CONFIG_PATH_ENV =
		"SQUIRRELJME_CONFIG_PATH";
	
	/**
	 * {@squirreljme.property cc.squirreljme.path.data=path
	 * This specifies the location where data files are stored.}
	 */
	public static final String DATA_PATH_PROPERTY =
		"cc.squirreljme.path.data";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_DATA_PATH=path
	 * This specifies the location where data files are stored.}
	 */
	public static final String DATA_PATH_ENV =
		"SQUIRRELJME_DATA_PATH";
	/**
	 * {@squirreljme.property cc.squirreljme.path.cache=path
	 * This specifies the location where cache files are stored.}
	 */
	public static final String CACHE_PATH_PROPERTY =
		"cc.squirreljme.path.cache";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_CACHE_PATH=path
	 * This specifies the location where cache files are stored.}
	 */
	public static final String CACHE_PATH_ENV =
		"SQUIRRELJME_CACHE_PATH";
	
	/** Determines the default paths to use. */
	public static final StandardPaths DEFAULT = StandardPaths.__defaultPaths();
	
	/** The configuration path. */
	protected final Path config;
	
	/** The data path. */
	protected final Path data;
	
	/** The cache path. */
	protected final Path cache;
	
	/** Library path. */
	private Reference<Path> _libpath;
	
	/**
	 * Initializes a standard path using the specified path as a base for
	 * the required directories.
	 *
	 * @param __p The base path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/13
	 */
	public StandardPaths(Path __p)
		throws NullPointerException
	{
		this(__p.resolve("config"), __p.resolve("data"), __p.resolve("cache"));
	}
	
	/**
	 * Initializes the standard path set.
	 *
	 * @param __conf The configuration directory.
	 * @param __data The data directory.
	 * @param __cache The cache directory.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/13
	 */
	public StandardPaths(Path __conf, Path __data, Path __cache)
		throws NullPointerException
	{
		if (__conf == null || __data == null || __cache == null)
			throw new NullPointerException("NARG");
		
		this.config = __conf;
		this.data = __data;
		this.cache = __cache;
	}
	
	/**
	 * Returns the library path where JARs are installed.
	 *
	 * @return The JAR installation path.
	 * @since 2018/02/10
	 */
	public final Path libraryPath()
	{
		Reference<Path> ref = this._libpath;
		Path rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._libpath = new WeakReference<>(
				(rv = this.data.resolve("lib")));
		
		return rv;
	}
	
	/**
	 * Determines how to get the default paths.
	 *
	 * @return The set of standard paths.
	 * @since 2018/01/13
	 */
	private static StandardPaths __defaultPaths()
	{
		Path[] rv = null;
		
		// Using a basic home path
		String basichome = Objects.toString(System.getProperty(
			StandardPaths.HOME_PROPERTY),
			SystemAccess.getEnv(StandardPaths.HOME_ENV));
		if (basichome != null)
			rv = new Path[]{Paths.get(basichome)};
		
		// If no basic path was used, detect more paths
		if (rv == null)
		{
			rv = StandardPaths.__defaultPathsOs();
			
			// Still could not be used?
			if (rv == null)
				rv = new Path[]{StandardPaths.__getPropertyPath("user.dir").
					resolve("squirreljme")};
		}
		
		// If only a single path is returned then expand it to
		// multiple ones
		if (rv.length == 1)
		{
			Path base = rv[0];
			rv = new Path[]
				{
					base.resolve("config"),
					base.resolve("data"),
					base.resolve("cache"),
				};
		}
		
		// Setup paths
		return new StandardPaths(StandardPaths.__triple(rv[0], System.getProperty(
			StandardPaths.CONFIG_PATH_PROPERTY),
				SystemAccess.getEnv(StandardPaths.CONFIG_PATH_ENV)),
			StandardPaths.__triple(rv[1], System.getProperty(
				StandardPaths.DATA_PATH_PROPERTY),
				SystemAccess.getEnv(StandardPaths.DATA_PATH_ENV)),
			StandardPaths.__triple(rv[2], System.getProperty(
				StandardPaths.CACHE_PATH_PROPERTY),
				SystemAccess.getEnv(StandardPaths.CACHE_PATH_ENV)));
	}
	
	/**
	 * Use paths specific to the operation system.
	 *
	 * @return The set of paths, either 1 for singular or 3 for config, data,
	 * and cache.
	 * @since 2018/01/31
	 */
	private static Path[] __defaultPathsOs()
	{
		// Based on OS
		int ostype = SystemProperties.operatingSystemType();
		
		// These may be used by either OS
		Path userhome = StandardPaths.__getPropertyPath("user.home");
		Path userdir = StandardPaths.__getPropertyPath("user.dir");
		
		if (true)
			throw new todo.TODO();
		
		// Unix systems
		if (false)
		{
			Path[] rv = new Path[]
				{
					StandardPaths.__getEnv("XDG_CONFIG_HOME"),
					StandardPaths.__getEnv("XDG_DATA_HOME"),
					StandardPaths.__getEnv("XDG_CACHE_HOME"),
				};
			
			if (rv[0] == null)
				rv[0] = userhome.resolve(".config").resolve("squirreljme");
			
			if (rv[1] == null)
				rv[1] = userhome.resolve(".local").resolve("share").
					resolve("squirreljme");
			
			if (rv[2] == null)
				rv[2] = userhome.resolve(".cache").resolve("squirreljme");
			
			return rv;
		}
		
		// Unknown
		return null;
	}
	
	/**
	 * Returns the path of an environment variable.
	 *
	 * @param __s The environment variable to get.
	 * @return The path of the property or {@code null} if it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/02/09
	 */
	private static Path __getEnv(String __s)
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		String v = SystemAccess.getEnv(__s);
		if (v != null)
			return Paths.get(v);
		return null;
	}
	
	/**
	 * Returns the path of a system property.
	 *
	 * @param __s The system property to get.
	 * @return The path of the property or {@code null} if it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/13
	 */
	private static Path __getPropertyPath(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		String v = System.getProperty(__s);
		if (v != null)
			return Paths.get(v);
		return null;
	}
	
	/**
	 * Prefers path A, then B, and if neither the default is used.
	 *
	 * @param __default The default path.
	 * @param __a The first path.
	 * @param __b The second path.
	 * @return The path to use.
	 * @since 2018/01/31
	 */
	private static Path __triple(Path __default, String __a, String __b)
	{
		if (__a != null)
			return Paths.get(__a);
		
		else if (__b != null)
			return Paths.get(__b);
		
		return __default;
	}
}

Added modules/cldc/src/main/java/cc/squirreljme/runtime/cldc/full/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package is the base for full CLDC support.
 *
 * @since 2018/10/14
 */

package cc.squirreljme.runtime.cldc.full;

Added modules/cldc/src/main/java/java/nio/Buffer.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class Buffer
{
	Buffer()
	{
		throw new todo.TODO();
	}
	
	public final int capacity()
	{
		throw new todo.TODO();
	}
	
	public final Buffer clear()
	{
		throw new todo.TODO();
	}
	
	public final Buffer flip()
	{
		throw new todo.TODO();
	}
	
	public final boolean hasRemaining()
	{
		throw new todo.TODO();
	}
	
	public final int limit()
	{
		throw new todo.TODO();
	}
	
	public final Buffer limit(int __a)
	{
		throw new todo.TODO();
	}
	
	public final int position()
	{
		throw new todo.TODO();
	}
	
	public final Buffer position(int __a)
	{
		throw new todo.TODO();
	}
	
	public final int remaining()
	{
		throw new todo.TODO();
	}
	
	public final Buffer rewind()
	{
		throw new todo.TODO();
	}
}


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

package java.nio;

public abstract class ByteBuffer
	extends Buffer
	implements Comparable<ByteBuffer>
{
	ByteBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract FloatBuffer asFloatBuffer();
	
	public abstract IntBuffer asIntBuffer();
	
	public abstract ShortBuffer asShortBuffer();
	
	public abstract byte get();
	
	public abstract byte get(int __a);
	
	public abstract float getFloat();
	
	public abstract float getFloat(int __a);
	
	public abstract int getInt();
	
	public abstract int getInt(int __a);
	
	public abstract short getShort();
	
	public abstract short getShort(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteBuffer put(byte __a);
	
	public abstract ByteBuffer put(int __a, byte __b);
	
	public abstract ByteBuffer putFloat(float __a);
	
	public abstract ByteBuffer putFloat(int __a, float __b);
	
	public abstract ByteBuffer putInt(int __a);
	
	public abstract ByteBuffer putInt(int __a, int __b);
	
	public abstract ByteBuffer putShort(short __a);
	
	public abstract ByteBuffer putShort(int __a, short __b);
	
	public abstract ByteBuffer slice();
	
	public final byte[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(ByteBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer get(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer get(byte[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public final ByteOrder order()
	{
		throw new todo.TODO();
	}
	
	public final ByteBuffer order(ByteOrder __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer put(ByteBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer put(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final ByteBuffer put(byte[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer allocateDirect(int __a)
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer wrap(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer wrap(byte[] __a)
	{
		throw new todo.TODO();
	}
}

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

package java.nio;

/**
 * This represents the byte order that data may be in.
 *
 * @since 2016/02/27
 */
public final class ByteOrder
{
	/** Big endian byte order. */
	public static final ByteOrder BIG_ENDIAN =
		new ByteOrder("BIG_ENDIAN");
	
	/** Little endian byte order. */
	public static final ByteOrder LITTLE_ENDIAN =
		new ByteOrder("LITTLE_ENDIAN");
	
	/** The string representing the byte order. */
	private final String _string;
	
	/**
	 * Initializes the byte order.
	 *
	 * @param __str String pertaining to the order.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/27
	 */
	private ByteOrder(String __str)
		throws NullPointerException
	{
		// Check
		if (__str == null)
			throw new NullPointerException();
		
		// Set
		this._string = __str;
	}
	
	/**
	 * Returns the string representing the byte order, either
	 * {@code BIG_ENDIAN} or {@code LITTLE_ENDIAN}.
	 *
	 * @return The byte order's string.
	 * @since 2016/02/27
	 */
	@Override
	public String toString()
	{
		return this._string;
	}
	
	public static ByteOrder nativeOrder()
	{
		throw new todo.TODO();
	}
}

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

package java.nio;

public abstract class FloatBuffer
	extends Buffer
	implements Comparable<FloatBuffer>
{
	FloatBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract float get();
	
	public abstract float get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract FloatBuffer put(float __a);
	
	public abstract FloatBuffer put(int __a, float __b);
	
	public abstract FloatBuffer slice();
	
	public final float[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(FloatBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer get(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer get(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer put(FloatBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer put(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final FloatBuffer put(float[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static FloatBuffer wrap(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static FloatBuffer wrap(float[] __a)
	{
		throw new todo.TODO();
	}
}


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

package java.nio;

public abstract class IntBuffer
	extends Buffer
	implements Comparable<IntBuffer>
{
	IntBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract int get();
	
	public abstract int get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract IntBuffer put(int __a);
	
	public abstract IntBuffer put(int __a, int __b);
	
	public abstract IntBuffer slice();
	
	public final int[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(IntBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer get(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer get(int[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public IntBuffer put(IntBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer put(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final IntBuffer put(int[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static IntBuffer wrap(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static IntBuffer wrap(int[] __a)
	{
		throw new todo.TODO();
	}
}

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

package java.nio;

public abstract class ShortBuffer
	extends Buffer
	implements Comparable<ShortBuffer>
{
	ShortBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract short get();
	
	public abstract short get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract ShortBuffer put(short __a);
	
	public abstract ShortBuffer put(int __a, short __b);
	
	public abstract ShortBuffer slice();
	
	public final short[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(ShortBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer get(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer get(short[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer put(ShortBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer put(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final ShortBuffer put(short[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static ShortBuffer wrap(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static ShortBuffer wrap(short[] __a)
	{
		throw new todo.TODO();
	}
}


Added modules/cldc/src/main/java/java/nio/channels/ByteChannel.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

public interface ByteChannel
	extends ReadableByteChannel, WritableByteChannel
{
}

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

package java.nio.channels;

import java.io.Closeable;
import java.io.IOException;

public interface Channel
	extends Closeable
{
	void close()
		throws IOException;
	
	boolean isOpen();
}

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

package java.nio.channels;

import java.io.InputStream;
import java.io.OutputStream;

public final class Channels
{
	private Channels()
	{
		throw new todo.TODO();
	}
	
	public static ReadableByteChannel newChannel(InputStream __a)
	{
		throw new todo.TODO();
	}
	
	public static WritableByteChannel newChannel(OutputStream __a)
	{
		throw new todo.TODO();
	}
	
	public static InputStream newInputStream(ReadableByteChannel __a)
	{
		throw new todo.TODO();
	}
	
	public static OutputStream newOutputStream(WritableByteChannel __a)
	{
		throw new todo.TODO();
	}
}

Added modules/cldc/src/main/java/java/nio/channels/ClosedChannelException.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;

public class ClosedChannelException
	extends IOException
{
	public ClosedChannelException()
	{
		throw new todo.TODO();
	}
}

Added modules/cldc/src/main/java/java/nio/channels/FileChannel.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
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.util.Set;

public abstract class FileChannel
	implements SeekableByteChannel
{
	protected FileChannel()
	{
		throw new todo.TODO();
	}
	
	public abstract void force(boolean __a)
		throws IOException;
	
	public abstract long position()
		throws IOException;
	
	public abstract FileChannel position(long __a)
		throws IOException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException;
	
	public abstract int read(ByteBuffer __a, long __b)
		throws IOException;
	
	public abstract long size()
		throws IOException;
	
	public abstract FileChannel truncate(long __a)
		throws IOException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException;
	
	public abstract int write(ByteBuffer __a, long __b)
		throws IOException;
	
	public static FileChannel open(Path __a, Set<? extends OpenOption> __b,
		FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileChannel open(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Added modules/cldc/src/main/java/java/nio/channels/ReadableByteChannel.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface ReadableByteChannel
	extends Channel
{
	int read(ByteBuffer __a)
		throws IOException;
}


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

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface SeekableByteChannel
	extends ByteChannel
{
	long position()
		throws IOException;
	
	SeekableByteChannel position(long __a)
		throws IOException;
	
	int read(ByteBuffer __a)
		throws IOException;
	
	long size()
		throws IOException;
	
	SeekableByteChannel truncate(long __a)
		throws IOException;
	
	int write(ByteBuffer __a)
		throws IOException;
}


Added modules/cldc/src/main/java/java/nio/channels/WritableByteChannel.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface WritableByteChannel
	extends Channel
{
	int write(ByteBuffer __a)
		throws IOException;
}

Added modules/cldc/src/main/java/java/nio/file/CopyOption.java.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public interface CopyOption
{
}

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

package java.nio.file;

import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;

public interface DirectoryStream<T>
	extends Closeable, Iterable<T>
{
	Iterator<T> iterator();
	
	interface Filter<T>
	{
		boolean accept(T __a)
			throws IOException;
	}
}

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

package java.nio.file;

public class FileAlreadyExistsException
	extends FileSystemException
{
	public FileAlreadyExistsException(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public FileAlreadyExistsException(String __a, String __b, String __c)
	{
		super((String)null);
		throw new todo.TODO();
	}
}

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

package java.nio.file;

import java.io.IOException;

public abstract class FileStore
{
	protected FileStore()
	{
		throw new todo.TODO();
	}
	
	public abstract Object getAttribute(String __a)
		throws IOException;
	
	public abstract long getTotalSpace()
		throws IOException;
	
	public abstract long getUnallocatedSpace()
		throws IOException;
	
	public abstract long getUsableSpace()
		throws IOException;
	
	public abstract boolean isReadOnly();
	
	public abstract String name();
	
	public abstract boolean supportsFileAttributeView(String __a);
	
	public abstract String type();
}


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

package java.nio.file;

import java.io.Closeable;
import java.io.IOException;
import java.util.Set;

public abstract class FileSystem
	implements Closeable
{
	/**
	 * Base constructor.
	 *
	 * @since 2019/12/22
	 */
	protected FileSystem()
	{
	}
	
	public abstract void close()
		throws IOException;
	
	public abstract Iterable<FileStore> getFileStores();
	
	public abstract Path getPath(String __a, String... __b);
	
	public abstract Iterable<Path> getRootDirectories();
	
	public abstract String getSeparator();
	
	public abstract boolean isOpen();
	
	public abstract boolean isReadOnly();
	
	public abstract Set<String> supportedFileAttributeViews();
}

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

package java.nio.file;

import java.io.IOException;

public class FileSystemException
	extends IOException
{
	public FileSystemException(String __a)
	{
		throw new todo.TODO();
	}
	
	public FileSystemException(String __a, String __b, String __c)
	{
		throw new todo.TODO();
	}
	
	public String getFile()
	{
		throw new todo.TODO();
	}
	
	public String getMessage()
	{
		throw new todo.TODO();
	}
	
	public String getOtherFile()
	{
		throw new todo.TODO();
	}
	
	public String getReason()
	{
		throw new todo.TODO();
	}
}

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

package java.nio.file;

import cc.squirreljme.runtime.cldc.full.NullFileSystem;

/**
 * This contains a static method which is used to obtain the default filesystem
 * which is used by SquirrelJME's native filesystem interface.
 *
 * @since 2017/06/12
 */
public final class FileSystems
{
	/**
	 * Not used.
	 *
	 * @since 2017/06/12
	 */
	private FileSystems()
	{
	}
	
	/**
	 * This returns the default filesystem which is used by the system to
	 * access the filesystem.
	 *
	 * @return The system's default filesystem.
	 * @since 2017/06/12
	 */
	public static FileSystem getDefault()
	{
		todo.DEBUG.note("Implement FileSystem support!");
		return NullFileSystem.INSTANCE;
	}
}

Added modules/cldc/src/main/java/java/nio/file/Files.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileTime;
import java.util.Map;
import java.util.Set;

public final class Files
{
	private Files()
	{
		throw new todo.TODO();
	}
	
	public static Path copy(Path __a, Path __b, CopyOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createDirectories(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createDirectory(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createFile(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempDirectory(Path __a, String __b,
		FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempDirectory(String __a, FileAttribute<?>...
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempFile(Path __a, String __b, String __c,
		FileAttribute<?>... __d)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempFile(String __a, String __b, FileAttribute
		<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static void delete(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean deleteIfExists(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean exists(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static Object getAttribute(Path __a, String __b, LinkOption... __c
		)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileStore getFileStore(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileTime getLastModifiedTime(Path __a, LinkOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isDirectory(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean isHidden(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isReadable(Path __a)
	{
		throw new todo.TODO();
	}
	
	public static boolean isRegularFile(Path __p)
	{
		throw new todo.TODO();
	}
	
	public static boolean isSameFile(Path __a, Path __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isWritable(Path __a)
	{
		throw new todo.TODO();
	}
	
	public static Path move(Path __a, Path __b, CopyOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SeekableByteChannel newByteChannel(Path __a, Set<? extends
		OpenOption> __b, FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SeekableByteChannel newByteChannel(Path __a, OpenOption...
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a, String
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a,
		DirectoryStream.Filter<? super Path> __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static InputStream newInputStream(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static OutputStream newOutputStream(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean notExists(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static <A extends BasicFileAttributes> A readAttributes(Path __a,
		Class<A> __b, LinkOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Map<String, Object> readAttributes(Path __a, String __b,
		LinkOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path setAttribute(Path __a, String __b, Object __c,
		LinkOption... __d)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path setLastModifiedTime(Path __a, FileTime __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static long size(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

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

package java.nio.file;

/**
 * This indicates that the given path is not valid.
 *
 * @since 2019/12/22
 */
public class InvalidPathException
	extends IllegalArgumentException
{
	/** The input. */
	private final transient String _input;
	
	/** The reason. */
	private final transient String _reason;
	
	/** The index. */
	private final transient int _index;
	
	/**
	 * Initializes the exception.
	 *
	 * @param __in The input string.
	 * @param __reason The reason for the failure.
	 * @param __index The index of the failure, {@code -1} if not known.
	 * @throws IllegalArgumentException If the index is less than {@code -1}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public InvalidPathException(String __in, String __reason, int __index)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __reason == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZY04 Invalid path index specified for
		// exception. (Index)}
		if (__index < -1)
			throw new IllegalArgumentException("ZY04 " + __index);
		
		this._input = __in;
		this._reason = __reason;
		this._index = __index;
	}
	
	/**
	 * Initializes the exception.
	 *
	 * @param __in The input string.
	 * @param __reason The reason for the failure.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public InvalidPathException(String __in, String __reason)
		throws NullPointerException
	{
		this(__in, __reason, -1);
	}
	
	/**
	 * Returns the index where the error occurred.
	 *
	 * @return The index where the error occurred, or {@code -1} if it is not
	 * known.
	 * @since 2019/12/22
	 */
	public int getIndex()
	{
		return this._index;
	}
	
	/**
	 * Returns the input path.
	 *
	 * @return The input path.
	 * @since 2019/12/22
	 */
	public String getInput()
	{
		return this._input;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public String getMessage()
	{
		// This is specifically specified by the documentation
		int index = this._index;
		return this._reason + ": " + this._input +
			(index > -1 ? " at index " + index : "");
	}
	
	/**
	 * Returns the reason the path is not valid.
	 *
	 * @return The reason the path is not valid.
	 * @since 2019/12/22
	 */
	public String getReason()
	{
		return this._reason;
	}
}

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

package java.nio.file;

public enum LinkOption
	implements OpenOption, CopyOption
{
	NOFOLLOW_LINKS(),
	
	/** End. */
	;
	
	LinkOption()
	{
		throw new todo.TODO();
	}
}

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

package java.nio.file;

public class NoSuchFileException
	extends FileSystemException
{
	public NoSuchFileException(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public NoSuchFileException(String __a, String __b, String __c)
	{
		super((String)null);
		throw new todo.TODO();
	}
}

Added modules/cldc/src/main/java/java/nio/file/OpenOption.java.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public interface OpenOption
{
}

Added modules/cldc/src/main/java/java/nio/file/Path.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.IOException;
import java.util.Iterator;

public interface Path
	extends Comparable<Path>, Iterable<Path>
{
	int compareTo(Path __a);
	
	boolean endsWith(Path __a);
	
	boolean endsWith(String __a);
	
	@Override
	boolean equals(Object __a);
	
	Path getFileName();
	
	FileSystem getFileSystem();
	
	Path getName(int __a);
	
	int getNameCount();
	
	Path getParent();
	
	Path getRoot();
	
	@Override
	int hashCode();
	
	boolean isAbsolute();
	
	Iterator<Path> iterator();
	
	Path normalize();
	
	Path relativize(Path __a);
	
	Path resolve(Path __a);
	
	Path resolve(String __a);
	
	Path resolveSibling(Path __a);
	
	Path resolveSibling(String __a);
	
	boolean startsWith(Path __a);
	
	boolean startsWith(String __a);
	
	Path subpath(int __a, int __b);
	
	Path toAbsolutePath();
	
	Path toRealPath(LinkOption... __a)
		throws IOException;
	
	@Override
	String toString();
}

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

package java.nio.file;

/**
 * This class provides a single static method which is used to create instances
 * of {@link Path} which represent native filesystem paths.
 *
 * @since 2017/06/12
 */
public final class Paths
{
	/**
	 * Not used.
	 *
	 * @since 2017/06/12
	 */
	private Paths()
	{
	}
	
	/**
	 * This creates a representation of a native filesystem path. It has the
	 * same function and rules
	 * as {@link FileSystem#getPath(String, String...)}.
	 *
	 * @param __a The first path fragment.
	 * @param __b The optional remaining path fragments.
	 * @return The native representation of the native filesystem path.
	 * @throws InvalidPathException If the specified path cannot be represented
	 * on the native system.
	 * @since 2017/06/12
	 */
	public static Path get(String __a, String... __b)
		throws InvalidPathException
	{
		return FileSystems.getDefault().getPath(__a, __b);
	}
}

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

package java.nio.file;

public enum StandardCopyOption
	implements CopyOption
{
	ATOMIC_MOVE,
	
	COPY_ATTRIBUTES,
	
	REPLACE_EXISTING,
	
	/** End. */
	;
}

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

package java.nio.file;

public enum StandardOpenOption
	implements OpenOption
{
	APPEND(),
	
	CREATE(),
	
	CREATE_NEW(),
	
	DELETE_ON_CLOSE(),
	
	DSYNC(),
	
	READ(),
	
	SPARSE(),
	
	SYNC(),
	
	TRUNCATE_EXISTING(),
	
	WRITE(),
	
	/** End. */
	;
	
	StandardOpenOption()
	{
		throw new todo.TODO();
	}
}

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

package java.nio.file.attribute;

public interface BasicFileAttributes
{
	FileTime creationTime();
	
	boolean isDirectory();
	
	boolean isOther();
	
	boolean isRegularFile();
	
	boolean isSymbolicLink();
	
	FileTime lastAccessTime();
	
	FileTime lastModifiedTime();
	
	long size();
}


Added modules/cldc/src/main/java/java/nio/file/attribute/FileAttribute.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file.attribute;

public interface FileAttribute<T>
{
	String name();
	
	T value();
}

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

package java.nio.file.attribute;

public final class FileTime
	implements Comparable<FileTime>
{
	private FileTime()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(FileTime __a)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public long toMillis()
	{
		throw new todo.TODO();
	}
	
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static FileTime fromMillis(long __v)
	{
		throw new todo.TODO();
	}
}

Added modules/collections/build.gradle.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This class contains various collections " +
	"which can be used to store objects."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AC"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Collections"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

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

package net.multiphasicapps.collections;

import java.util.List;

/**
 * This contains some utilities for arrays.
 *
 * @since 2017/11/30
 */
public final class ArrayUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/30
	 */
	private ArrayUtils()
	{
	}
	
	/**
	 * Returns an unmodifiable list over the given array.
	 *
	 * @param <T> The type of list to return.
	 * @param __e The array to wrap.
	 * @return The unmodifiable list.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	@SuppressWarnings({"unchecked"})
	public static final <T> List<T> unmodifiableList(T... __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayList<T>(__e, 0, __e.length);
	}
}

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

package net.multiphasicapps.collections;

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;

/**
 * This is based on top of {@link ArrayList} and is the same interface except
 * that it is {@link Closeable} and on close will attempt to close all
 * elements within the list.
 *
 * @since 2017/11/28
 */
public class CloseableList<T extends Closeable>
	extends ArrayList<T>
	implements Closeable
{
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
		throws IOException
	{
		int count = 0;
		IOException defer = null;
		for (int i = 0, n = this.size(); i < n; i++)
			try
			{
				T v = this.get(i);
				if (v != null)
					v.close();
			}
			catch (IOException e)
			{
				if (defer == null)
					defer = e;
				count++;
			}
		
		// {@squirreljme.error AC01 There was at least one exception which
		// occurred while closing the list. (The number of exceptions thrown)}
		if (defer != null)
			throw new IOException(String.format("AC01 %d", count), defer);
	}
	
	/**
	 * Adds the specified item to the list and returns it.
	 *
	 * @param __t The element to add.
	 * @return {@code __t}.
	 * @since 2017/11/28
	 */
	public final T addThis(T __t)
	{
		this.add(__t);
		return __t;
	}
	
	/**
	 * Adds the specified item to the list and returns it.
	 *
	 * @param <E> The class to cast to.
	 * @param __t The element to add.
	 * @param __cl The class to cast to on return.
	 * @return {@code __t} cast to {@code E}.
	 * @throws NullPointerException If no class was specified.
	 * @since 2017/11/28
	 */
	public final <E extends T> E addThis(E __t, Class<E> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.add(__t);
		return __cl.cast(__t);
	}
}

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

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator which is empty.
 *
 * @since 2016/04/10
 */
public final class EmptyIterator
	implements Iterator
{
	/** The empty iterator. */
	private static Reference<Iterator> _EMPTY_ITERATOR;
	
	/**
	 * Initializes the empty iterator.
	 *
	 * @since 2016/04/10
	 */
	private EmptyIterator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public boolean hasNext()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Object next()
	{
		// {@squirreljme.error AC02 The empty iterator contains no elements.}
		throw new NoSuchElementException("AC02");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public void remove()
	{
		// {@squirreljme.error AC03 Cannot remove elements from the empty
		// iterator.}
		throw new UnsupportedOperationException("AC03");
	}
	
	/**
	 * This returns an iterator which contains nothing.
	 *
	 * @param <V> The type of values to iterate over.
	 * @return The empty iterator.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> Iterator<V> empty()
	{
		// Get reference
		Reference<Iterator> ref = EmptyIterator._EMPTY_ITERATOR;
		Iterator rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			EmptyIterator._EMPTY_ITERATOR = new WeakReference<>(
				(rv = new EmptyIterator()));
		
		// Return it
		return (Iterator<V>)rv;
	}
}

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

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

/**
 * This is a list which contains no elements.
 *
 * @since 2016/04/10
 */
public final class EmptyList
	extends AbstractList
	implements RandomAccess
{
	/** The empty list. */
	private static Reference<List> _EMPTY_LIST;
	
	/**
	 * Initializes the empty list.
	 *
	 * @since 2016/04/10
	 */
	private EmptyList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsAll(Collection __c)
	{
		return __c.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Object get(int __i)
	{
		// {@squirreljme.error AC04 The empty list contains no elements.}
		throw new IndexOutOfBoundsException("AC04");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int indexOf(Object __o)
	{
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/01
	 */
	@Override
	public Iterator iterator()
	{
		return EmptyIterator.empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int lastIndexOf(Object __o)
	{
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * This returns a list which contains nothing.
	 *
	 * @param <V> The type of values the list contains.
	 * @return The empty list.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> List<V> empty()
	{
		// Get reference
		Reference<List> ref = EmptyList._EMPTY_LIST;
		List rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			EmptyList._EMPTY_LIST = new WeakReference<>(
				(rv = new EmptyList()));
		
		// Return it
		return (List<V>)rv;
	}
}

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

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * This is a map which contains no entries.
 *
 * @since 2016/05/12
 */
public class EmptyMap
	extends AbstractMap
{
	/** The empty map. */
	private static Reference<Map> _EMPTY_MAP;
	
	/**
	 * Initializes the empty map.
	 *
	 * @since 2016/05/12
	 */
	private EmptyMap()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsValue(Object __v)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Set<Map.Entry> entrySet()
	{
		return EmptySet.<Map.Entry>empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Object get(Object __k)
	{
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Set keySet()
	{
		return EmptySet.<Object>empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Collection values()
	{
		return EmptySet.<Object>empty();
	}
	
	/**
	 * This returns an empty and unmodifiable map.
	 *
	 * @param <K> The key type to use.
	 * @param <V> The value type to use.
	 * @return The unmodifiable and empty map.
	 * @since 2016/05/12
	 */
	@SuppressWarnings({"unchecked"})
	public static <K, V> Map<K, V> empty()
	{
		// Get reference
		Reference<Map> ref = EmptyMap._EMPTY_MAP;
		Map rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			EmptyMap._EMPTY_MAP = new WeakReference<>((rv = new EmptyMap()));
		
		// Return it
		return (Map<K, V>)rv;
	}
}

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

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which cannot be changed and has no entries.
 *
 * @since 2016/04/10
 */
public final class EmptySet
	extends AbstractSet
{
	/** The empty set. */
	private static Reference<Set> _EMPTY_SET;
	
	/**
	 * Initializes the empty set.
	 *
	 * @since 2016/04/10
	 */
	private EmptySet()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsAll(Collection __c)
	{
		return __c.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Iterator iterator()
	{
		return EmptyIterator.empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * This returns an empty and unmodifiable set.
	 *
	 * @param <V> The element type used by the set.
	 * @return The unmodifiable and empty set.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> Set<V> empty()
	{
		// Get reference
		Reference<Set> ref = EmptySet._EMPTY_SET;
		Set rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			EmptySet._EMPTY_SET = new WeakReference<>((rv = new EmptySet()));
		
		// Return it
		return (Set<V>)rv;
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;

/**
 * This is a set which allows enumeration values to be stored in it efficiently
 * using only a bit field.
 *
 * @since 2018/03/21
 */
public final class EnumSet<T extends Enum<T>>
	extends AbstractSet<T>
{
	/** The type of class being stored. */
	protected final Class<T> type;
	
	/** The number of used bits so far. */
	protected final int numbits;
	
	/** The number of ints in use. */
	protected final int numints;
	
	/** The values which are in the set, split into fields. */
	private int[] _bits;
	
	/** Is the null element in this set? */
	private boolean _hasnull;
	
	/**
	 * Initializes an empty enumeration set.
	 *
	 * @param __cl The class type to store.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/21
	 */
	public EnumSet(Class<T> __cl)
		throws NullPointerException
	{
		this(__cl, EmptySet.<T>empty());
	}
	
	/**
	 * Initializes an enumeration set with the given initial values.
	 *
	 * @param __cl The class type to store.
	 * @param __v The initial values to store.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/21
	 */
	public EnumSet(Class<T> __cl, Collection<? extends T> __v)
		throws NullPointerException
	{
		if (__cl == null || __v == null)
			throw new NullPointerException("NARG");
		
		this.type = __cl;
		
		// Setup storage bits
		this.numbits = 0;
		this.numints = 0;
		this._bits = new int[0];
		
		// Add values
		for (T v : __v)
			this.add(v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean add(T __v)
	{
		// Adding null element?
		if (__v == null)
		{
			boolean hasnull = this._hasnull;
			if (hasnull)
				return false;
			else
			{
				this._hasnull = true;
				return true;
			}
		}
		
		// Need a place to store
		if (true)
			throw new todo.TODO();
		
		// Determine bit position
		int bit = __v.ordinal(),
			high = bit >>> 5;
		bit &= 0x1F;
		int flag = (1 << bit);
		
		// Did it have it before?
		int[] bits = this._bits;
		boolean had = ((bits[high] & flag) != 0);
		
		// Set it
		bits[high] |= flag;
		
		// The collection only changes if it did not have the bit
		return !had;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean contains(Object __o)
	{
		// Only has null if it was explicitely added
		if (__o == null)
			return this._hasnull;
		
		if (!this.type.isInstance(__o))
			return false;
		
		// Determine bit position
		int bit = ((Enum)__o).ordinal(),
			high = bit >>> 5;
		bit &= 0x1F;
		
		return 0 != (this._bits[high] & (1 << bit));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final Iterator<T> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean remove(Object __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.collections;

import java.util.Collection;
import java.util.HashSet;

/**
 * This is a set which uses the identity of objects for comparison rather than
 * the actual equality of said objects.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
public final class IdentityHashSet<T>
	extends __IdentityBaseSet__<T>
{
	/**
	 * Initializes an empty set.
	 *
	 * @since 2017/12/28
	 */
	public IdentityHashSet()
	{
		super(new HashSet<__IdentityWrapper__<T>>());
	}
	
	/**
	 * Initializes a set copied from the other collection.
	 *
	 * @param __from The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public IdentityHashSet(Collection<? extends T> __from)
		throws NullPointerException
	{
		super(new HashSet<__IdentityWrapper__<T>>(), __from);
	}
}

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

package net.multiphasicapps.collections;

import java.util.Collection;
import java.util.LinkedHashSet;

/**
 * This is a set which uses the identity of objects for comparison rather than
 * the actual equality of said objects. The order of elements in the set is
 * linked according to {@link java.util.LinkedHashSet}.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
public final class IdentityLinkedHashSet<T>
	extends __IdentityBaseSet__<T>
{
	/**
	 * Initializes an empty set.
	 *
	 * @since 2017/12/28
	 */
	public IdentityLinkedHashSet()
	{
		super(new LinkedHashSet<__IdentityWrapper__<T>>());
	}
	
	/**
	 * Initializes a set copied from the other collection.
	 *
	 * @param __from The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public IdentityLinkedHashSet(Collection<? extends T> __from)
		throws NullPointerException
	{
		super(new LinkedHashSet<__IdentityWrapper__<T>>(), __from);
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/IntegerList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.RandomAccess;

/**
 * This is a list of integers which is backed by a primitive array rather than
 * boxed types.
 *
 * @since 2017/11/26
 */
public final class IntegerList
	extends AbstractList<Integer>
	implements RandomAccess
{
	/** The array growing size. */
	private static final int _GROW_SIZE =
		8;
	
	/** The internal integer list. */
	private volatile int[] _values;
	
	/** The number of values in the list. */
	private volatile int _size;
	
	/**
	 * Initializes an empty list.
	 *
	 * @since 2017/11/26
	 */
	public IntegerList()
	{
	}
	
	/**
	 * Initializes a list using the given collection of integers.
	 *
	 * @param __v The collection to source values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(Collection<Integer> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Iterate through collections
		int n = __v.size(), i = 0;
		int[] values = new int[n];
		for (Integer v : __v)
			values[i++] = v;
		
		// Set
		this._values = values;
		this._size = n;
	}
	
	/**
	 * Initializes a list using the given integer values from an array.
	 *
	 * @param __v The array of integers to use for values.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Defensive copy
		__v = __v.clone();
		
		// Simple set
		this._values = __v;
		this._size = __v.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean add(Integer __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return this.addInteger(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void add(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.addInteger(__i, __v);
	}
	
	/**
	 * Adds the specified integer to the list.
	 *
	 * @param __v The value to add.
	 * @return {@code true} if the list has changed.
	 * @since 2017/11/26
	 */
	public boolean addInteger(int __v)
	{
		this.addInteger(this._size, __v);
		return true;
	}
	
	/**
	 * Adds the specified integer to the list at the specified position.
	 *
	 * @param __i The index to add the value at.
	 * @param __v The value to add.
	 * @throws IndexOutOfBoundsException If the index to add it outside of
	 * the array bounds.
	 * @since 2017/11/26
	 */
	public void addInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i > this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Existing values
		boolean realloced = false;
		int[] values = this._values;
		int nvalues = (values == null ? 0 : values.length),
			size = this._size;
		
		// Need a larger array?
		if ((realloced = (size + 1 > nvalues)))
			if (values == null)
				values = new int[IntegerList._GROW_SIZE];
			else
				values = Arrays.copyOf(values, nvalues + IntegerList._GROW_SIZE);
		
		// Move all values up
		for (int o = size; o > __i; o++)
			values[o] = values[o - 1];
		
		// Set this index
		values[__i] = __v;
		size++;
		
		// Store new values
		if (realloced)
			this._values = values;
		this._size = size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void clear()
	{
		this._values = null;
		this._size = 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean contains(Object __a)
	{
		// Only contains integers
		if (!(__a instanceof Integer))
			return false;
		
		return this.containsInteger((Integer)__a);
	}
	
	/**
	 * Checks if the list contains the specified integer.
	 *
	 * @param __v The value to check.
	 * @return {@code true} if the list contains the given integer.
	 * @since 2017/11/26
	 */
	public boolean containsInteger(int __v)
	{
		return this.indexOfInteger(__v) >= 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer get(int __i)
		throws IndexOutOfBoundsException
	{
		return this.getInteger(__i);
	}
	
	/**
	 * Obtains the integer at the given index.
	 *
	 * @param __i The index to get.
	 * @return The integer at the given index.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int getInteger(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this._values[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int indexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.indexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int indexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int i = 0, n = values.length; i < n; i++)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean isEmpty()
	{
		return this._size == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int lastIndexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.lastIndexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer starting from
	 * the end of the list.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int lastIndexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int n = values.length, i = n - 1; i >= 0; i--)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean remove(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return false;
		
		int dx = this.indexOf(__a);
		if (dx < 0)
			return false;
		
		this.remove(dx);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer remove(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer set(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return this.setInteger(__i, __v);
	}
	
	/**
	 * Sets the integer at the specified index to the given value.
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int setInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		int[] values = this._values;
		int rv = values[__i];
		values[__i] = __v;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	/**
	 * Converts the integer list to an integer array.
	 *
	 * @return This list as an integer array.
	 * @since 2017/11/26
	 */
	public int[] toIntegerArray()
	{
		int[] values = this._values;
		int size = this._size;
		
		// Values would not be allocated
		if (size == 0)
			return new int[0];
		
		// Copy values
		int[] rv = new int[size];
		for (int i = 0; i < size; i++)
			rv[i] = values[i];
		return rv;
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/MultiSetDeque.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
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
191
192
193
194
195
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * This is a class which provides a multiple {@link Deque} compatible interface
 * where every element within the queue is unique as if it were a member of
 * a {@link Set}. Note that the subdeques can be given elements that are shared
 * in multiple deques.
 *
 * In the returned {@link Deque}, elements which are removed will be removed
 * from the other {@link Deque}s. As such, clearing of one {@link Deque} may
 * result in other ones getting smaller in size.
 *
 * {@code null} elements are not permitted.
 *
 * This class is not thread safe.
 *
 * @param <V> The type of value to store in the dequeues.
 * @since 2016/09/03
 */
public class MultiSetDeque<V>
{
	/** Sub-queue list. */
	private final List<__Sub__<V>> _subs =
		new ArrayList<>();
	
	/** The master set of added elements. */
	final Set<V> _master =
		new HashSet<>();
	
	/**
	 * Clears the multi-set deque and every sub-deque so that all are empty.
	 *
	 * @since 2017/03/25
	 */
	public final void clear()
	{
		// Clear the master set
		this._master.clear();
		
		// And all the subsets
		for (__Sub__<V> s : this._subs)
			s.__clear();
	}
	
	/**
	 * Checks if the any of the sub-deques contain the specified element.
	 *
	 * @param __v The element to check.
	 * @return {@code true} if the element is any in deque.
	 * @since 2017/04/25
	 */
	public final boolean contains(V __v)
	{
		return this._master.contains(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (!(__o instanceof MultiSetDeque))
			return false;
		
		return this._subs.equals(((MultiSetDeque<?>)__o)._subs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final int hashCode()
	{
		return this._subs.hashCode();
	}
	
	/**
	 * Removes the given element from any of the sub-{@link Deque}s that are
	 * a part of the multi-set.
	 *
	 * @param __v The value to remove.
	 * @return {@code true} if it was in any {@link Deque}.
	 * @since 2016/09/03
	 */
	public final boolean remove(V __v)
	{
		// Null will never be in this deque
		if (__v == null)
			return false;
		
		// If not in the master set then it will not be in any deque
		Set<V> master = this._master;
		if (!master.contains(__v))
			return false;
		
		// Remove in all
		List<__Sub__<V>> subs = this._subs;
		int n = subs.size();
		boolean rv = false;
		for (int i = 0; i < n; i++)
			rv |= subs.get(i).__remove(__v);
		
		// Remove from the master set because it will be no sub-deque
		master.remove(__v);
		
		// Was it removed?
		return rv;
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque.
	 *
	 * @return A new deque which shares the set restrictions.
	 * @since 2016/09/03
	 */
	public final Deque<V> subDeque()
	{
		return this.subDeque(Integer.MAX_VALUE);
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque
	 * which is initialized using the given collection.
	 *
	 * @param __c The collection to add to the resulting {@link Deque}.
	 * @return A new deque which shares the set restrictions.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/15
	 */
	public final Deque<V> subDeque(Collection<V> __c)
		throws NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Create
		Deque<V> rv = this.subDeque();
		rv.addAll(__c);
		return rv;
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque
	 * which is limited to the given number of elements.
	 *
	 * @param __l The number of elements to limit to.
	 * @return A new deque which shares the set restrictions.
	 * @throws IllegalArgumentException If the limit is zero or negative.
	 * @since 2016/09/03
	 */
	public final Deque<V> subDeque(int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AC05 The sub-deque limit is zero or negative.}
		if (__l <= 0)
			throw new IllegalArgumentException("AC05");
		
		// Create it
		__Sub__<V> rv = new __Sub__<>(this, __l);
		this._subs.add(rv);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final String toString()
	{
		return this._subs.toString();
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/NaturalComparator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Comparator;

/**
 * This is used to compare two values using their natural comparison.
 *
 * @since 2016/09/06
 */
public final class NaturalComparator<V>
	implements Comparator<V>
{
	/** The single instance. */
	private static Reference<NaturalComparator> _REF;
	
	/**
	 * Only one is ever needed.
	 *
	 * @since 2017/11/30
	 */
	private NaturalComparator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public int compare(V __a, V __b)
	{
		// Consider two nulls to be equal
		boolean na = (__a == null), nb = (__b == null);
		if (na && nb)
			return 0;
		
		// Nulls before non-null
		else if (na && !nb)
			return -1;
		else if (!na && nb)
			return 1;
		
		// Use standard comparison
		return ((Comparable<V>)__a).compareTo(__b);
	}
	
	/**
	 * Returns the natural comparator instance.
	 *
	 * @param <V> The type of value to compare.
	 * @return The instance of the natural comparator.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public static final <V> NaturalComparator<V> instance()
	{
		Reference<NaturalComparator> ref = NaturalComparator._REF;
		NaturalComparator rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			NaturalComparator._REF = new WeakReference<>((rv = new NaturalComparator()));
		
		// Return it
		return (NaturalComparator<V>)rv;
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/SortedTreeMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;

/**
 * This is a sorted map which is internally implemented by using
 * {@link SortedTreeSet} and special handlers.
 *
 * This class is not thread safe.
 *
 * @param <K> The type of key to store.
 * @param <V> The type of value to store.
 * @since 2016/09/06
 */
public class SortedTreeMap<K, V>
	extends AbstractMap<K, V>
{
	/** Rotate left. */
	private static final boolean _LEFT =
		false;
	
	/** Rotate right. */
	private static final boolean _RIGHT =
		true;
	
	/** The comparison method to use. */
	final Comparator<K> _compare;
	
	/** The entry set. */
	private Reference<Set<Map.Entry<K, V>>> _entryset;
	
	/** The root node. */
	__Node__<K, V> _root;
	
	/** The minimum value. */
	__Data__<K, V> _min;
	
	/** The size of the tree. */
	int _size;
	
	/**
	 * Initializes a new empty map using the natural comparator.
	 *
	 * @since 2016/09/06
	 */
	public SortedTreeMap()
	{
		this(NaturalComparator.<K>instance());
	}
	
	/**
	 * Initializes a map using the natural comparator where values are copied
	 * from the specified map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Map<? extends Comparable<K>, ? extends V> __m)
		throws NullPointerException
	{
		this(NaturalComparator.<K>instance(), (Map<? extends K, ? extends V>)__m);
	}
	
	/**
	 * Initializes a new empty map using the given comparator.
	 *
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Comparator<? extends K> __comp)
		throws NullPointerException
	{
		// Check
		if (__comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._compare = (Comparator<K>)__comp;
	}
	
	/**
	 * Initializes a map using the given comparator where values are copied
	 * from the specified map.
	 *
	 * @param __comp The comparator to use for key sorts.
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Comparator<? extends K> __comp,
		Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		// Check
		if (__comp == null || __m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._compare = (Comparator<K>)__comp;
		
		// Put everything
		this.putAll(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public void clear()
	{
		this._root = null;
		this._min = null;
		this._size = 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return (null != this.__findNode(__o));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		// Get
		Reference<Set<Map.Entry<K, V>>> ref = this._entryset;
		Set<Map.Entry<K, V>> rv;
		
		// Check
		if (ref == null || null == (rv = ref.get()))
			this._entryset = new WeakReference<>(
				(rv = new __EntrySet__<>(this)));
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V get(Object __k)
	{
		__Node__<K, V> node = this.__findNode(__k);
		if (node == null)
			return null;
		return node._data._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public V put(K __k, V __v)
	{
		// Insert node
		__Found__ found = new __Found__();
		__Node__<K, V> now = this.__insert(null, this._root, found, __k, __v);
		
		// The root of the tree always becomes black
		now.__makeBlack();
		this._root = now;
		
		// Old value
		return found._oldvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/29
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public V remove(Object __k)
	{
		// Delete node
		__Found__ found = new __Found__();
		__Node__<K, V> newroot = this.__remove(this._root, found, (K)__k);
		
		// The root of the tree is always black
		this._root = newroot;
		if (newroot != null)
			newroot._isred = false;
		
		// Old value
		return found._oldvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	/**
	 * Corrects nodes going back up the tree.
	 *
	 * @param __at The node to potentially correct.
	 * @return The parent node and not a side node.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/30
	 */
	private __Node__<K, V> __correctNodes(__Node__<K, V> __at)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Rotate right side value to the left
		if (this.__isRed(__at._right))
			__at = this.__rotate(__at, SortedTreeMap._LEFT);
		
		// If there are a bunch of dangling red nodes on the left balance
		// them
		if (this.__isRed(__at._left) && this.__isRed(__at._left._left))
			__at = this.__rotate(__at, SortedTreeMap._RIGHT);
		
		// If both side nodes are red then flip the color of this node
		if (this.__isRed(__at._left) && this.__isRed(__at._right))
			this.__flipColor(__at);
		
		// Return current node
		return __at;
	}
	
	/**
	 * Finds the node with the given value.
	 *
	 * @param __o The object to find.
	 * @return The node for the given object or {@code null} if it was not
	 * found.
	 * @since 2016/09/06
	 */
	final __Node__<K, V> __findNode(Object __o)
	{
		// If there are no nodes then the tree is empty
		__Node__<K, V> rover = this._root;
		if (rover == null)
			return null;
		
		return this.__findNode(rover, __o);
	}
	
	/**
	 * Finds the node with the given key starting at the specified node.
	 *
	 * @param __at The node to start at.
	 * @param __k The key to find.
	 * @return The specified node or {@code null} if not found.
	 * @since 2017/03/30
	 */
	@SuppressWarnings({"unchecked"})
	final __Node__<K, V> __findNode(__Node__<K, V> __at, Object __k)
	{	
		// Constant search
		Comparator<K> compare = this._compare;
		while (__at != null)
		{
			// Compare
			K against = __at._data._key;
			int res = compare.compare((K)__k, against);
			
			// The same? stop here
			if (res == 0)
				return __at;
			
			// Go left
			else if (res < 0)
				__at = __at._left;
			
			// Otherwise go right
			else
				__at = __at._right;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Flips the color of the specified node.
	 *
	 * @param __at The node to flip colors for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/30
	 */
	private final void __flipColor(__Node__<K, V> __at)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Flip node colors
		__at._isred = !__at._isred;
		__at._left._isred = !__at._left._isred;
		__at._right._isred = !__at._right._isred;
	}
	
	/**
	 * Inserts the given node into the tree
	 *
	 * @param __from The node this iterated from.
	 * @param __at The current node iteration.
	 * @param __found The value information when a value is discovered.
	 * @param __k The key to use.
	 * @param __v The value to use.
	 * @return The root of the local segment, the first iteration of this call
	 * will always return the root of the tree.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __insert(__Node__<K, V> __from,
		__Node__<K, V> __at, __Found__ __found, K __k, V __v)
	{
		// No root of the tree?
		if (__at == null)
		{
			// Setup data
			__Data__<K, V> data = new __Data__<>(this, __k, __v);
			
			// Create new node
			__at = new __Node__<>();
			__at._data = data;
			data._node = __at;
			
			// Need to link the data in with the source nodes data chain
			if (__from != null)
			{
				// Need to directly modify the from data links
				__Data__<K, V> fd = __from._data;
				
				// Link before the from node?
				if (data.__compare(fd) < 0)
				{
					// The from's previous data needs to point to this node
					// and not the from data
					__Data__<K, V> pp = fd._prev;
					if (pp != null)
						pp._next = data;
					
					// This links back to that from data
					data._prev = pp;
					
					// and then links to the from data
					data._next = fd;
					
					// Then the from's previous becomes this data
					fd._prev = data;
				}
				
				// Link after
				else
				{
					// The from's next has to point back to this data
					__Data__<K, V> nn = fd._next;
					if (nn != null)
						nn._prev = data;
					
					// This links back into the from node
					data._prev = fd;
					
					// And links to the original next in the from
					data._next = nn;
					
					// Then the from next links to this data
					fd._next = data;
				}
			}
			
			// If the tree has no minimum use this node as it
			// Otherwise always use the smaller value
			__Data__<K, V> oldmin = this._min;
			if (oldmin == null || data.__compare(oldmin) < 0)
				this._min = data;
			
			// Size of the tree increased
			this._size++;
			
			// Use this new node
			return __at;
		}
		
		// Matched key, set its value
		int comp = this._compare.compare(__k, __at._data._key);
		if (comp == 0)
		{
			__found._oldvalue = __at._data._value;
			__at._data._value = __v;
		}
		
		// Less than
		else if (comp < 0)
			__at._left = this.__insert(__at, __at._left, __found, __k, __v);
		
		// Greater
		else
			__at._right = this.__insert(__at, __at._right, __found, __k, __v);
		
		// Correct nodes going back up
		return this.__correctNodes(__at);
	}
	
	/**
	 * Returns {@code true} if the given node is red.
	 *
	 * @param __n The node to see if it is red.
	 * @return {@code true} if the node is red.
	 * @since 2017/03/30
	 */
	private final boolean __isRed(__Node__<K, V> __n)
	{
		if (__n == null)
			return false;
		return __n._isred;
	}
	
	/**
	 * Returns the minimum node.
	 *
	 * @return The minimum node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __min(__Node__<K, V> __at)
	{
		while (__at._left != null)
			__at = __at._left;
		return __at;
	}
	
	/**
	 * Moves the specified red node.
	 *
	 * @param __at The node to move.
	 * @return The node that is not a side node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __moveRed(__Node__<K, V> __at, boolean __r)
	{
		// Flip the node color
		this.__flipColor(__at);
		
		// Move to the right
		if (__r)
		{
			if (this.__isRed(__at._left._left))
			{
				__at = this.__rotate(__at, SortedTreeMap._RIGHT);
				
				this.__flipColor(__at);
			}
		}
		
		// Move to the left
		else
		{
			if (this.__isRed(__at._right._left))
			{
				__at._right = this.__rotate(__at._right, SortedTreeMap._RIGHT);
				__at = this.__rotate(__at, SortedTreeMap._LEFT);
				
				this.__flipColor(__at);
			}
		}
		
		// This would be the node at the top
		return __at;
	}
	
	/**
	 * Recursive node removal based on the given key.
	 *
	 * @param __at The current node being traversed.
	 * @param __found Node searching information.
	 * @param __k The key to remove the value from.
	 * @return The node at the top (will not be a leaf)
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __remove(__Node__<K, V> __at,
		__Found__ __found, K __k)
	{
		// Key is lower?
		Comparator<K> compare = this._compare;
		int comp = compare.compare(__k, __at._data._key);
		if (comp < 0)
		{
			// Move red node to the left
			if (!this.__isRed(__at._left) && !this.__isRed(__at._left._left))
				__at = this.__moveRed(__at, SortedTreeMap._LEFT);
			
			// Delete left side
			__at._left = this.__remove(__at._left, __found, __k);
		}
		
		// Equal or higher
		else
		{
			// If the left is red then rotate it to the right
			if (this.__isRed(__at._left))
			{
				__at = this.__rotate(__at, SortedTreeMap._RIGHT);
				
				// Compare value is trashed, recompute
				comp = compare.compare(__k, __at._data._key);
			}
			
			// If this is the key and there is no right then no values need
			// to be shifted in
			if (comp == 0 && __at._right == null)
			{
				this.__unlink(__at, __found);
				
				// Return no key
				return null;
			}
			
			// If the red side contains a black chain move red nodes to the
			// right
			if (!this.__isRed(__at._right) && !this.__isRed(__at._right._left))
			{
				__at = this.__moveRed(__at, SortedTreeMap._RIGHT);
				
				// Comparison is trashed
				comp = compare.compare(__k, __at._data._key);
			}
			
			// Keys are the same
			if (comp == 0)
			{
				// Get the node with the minimum value on the right side
				__Node__<K, V> right = __at._right;
				__Node__<K, V> minright = this.__min(right);
				
				// Unlink the current data because that is getting destroyed
				this.__unlink(__at, __found);
				
				// The current node gets the data for that key
				__at._data = minright._data;
				
				// Remove the minimum without unlinking (because it gets
				// re-associated)
				this.__removeMin(right, null, false);
			}
			
			// Delete right side of the tree
			else
				__at._right = this.__remove(__at._right, __found, __k);
		}
		
		// Correct tree on the way up
		return this.__correctNodes(__at);
	}
	
	/**
	 * Removes the minimum node.
	 *
	 * @param __at Current node.
	 * @param __found The found node information.
	 * @param __unlink If {@code true} the node is unlinked.
	 * @return The top node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __removeMin(__Node__<K, V> __at,
		__Found__ __found, boolean __unlink)
	{
		// If there is no left, remove the left node
		if (__at._left == null)
		{
			// Unlink our node
			if (__unlink)
				this.__unlink(__at, __found);
			
			// No left node
			return null;
		}
		
		// If the left side is black move red to the left
		if (!this.__isRed(__at._left) && !this.__isRed(__at._left._left))
			__at = this.__moveRed(__at, SortedTreeMap._LEFT);
		
		// Continue deleting the minimum
		__at._left = this.__removeMin(__at, __found, __unlink);
		
		// Correct nodes back up the tree
		return this.__correctNodes(__at);
	}
	
	/**
	 * Rotates the nodes in the given direction.
	 *
	 * @param __at The node to rotate.
	 * @param __r If {@code true} then rotation is to the right, otherwise it
	 * is to the left.
	 * @return The center node.
	 * @since 2017/03/27
	 */
	private final __Node__<K, V> __rotate(__Node__<K, V> __at, boolean __r)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Rotate right
		if (__r)
		{
			__Node__<K, V> x = __at._left;
			__at._left = x._right;
			x._right = __at;
			x._isred = x._right._isred;
			x._right._isred = true;
			return x;
		}
		
		// Rotate left
		else
		{
			__Node__<K, V> x = __at._right;
			__at._right = x._left;
			x._left = __at;
			x._isred = x._left._isred;
			x._left._isred = true;
			return x;
		}
	}
	
	/**
	 * Unlinks the specified node.
	 *
	 * @param __at The node to unlink.
	 * @param __found The found node data.
	 * @since 2017/03/30
	 */
	private final void __unlink(__Node__<K, V> __at, __Found__ __found)
	{
		// Get the data to unlink
		__Data__<K, V> unlink = __at._data;
		if (__found != null)
			__found._oldvalue = unlink._value;
		
		// Link next node with the previous
		__Data__<K, V> prev = unlink._prev,
			next = unlink._next;
		if (next != null)
			next._prev = prev;
		
		// Link previous node with the next one
		if (prev != null)
			prev._next = next;
		
		// If this is the minimum node then the next one will be the
		// new minimum
		if (this._min == unlink)
			this._min = next;
		
		// Destroy chains
		unlink._value = null;
		unlink._node = null;
		unlink._prev = null;
		unlink._next = null;
		
		// Reduce count
		this._size--;
	}
	
	/**
	 * The data which used to be at the given position.
	 *
	 * @since 2017/03/30
	 */
	private final class __Found__
	{
		V _oldvalue;
		
		__Found__()
		{
		}
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a sorted {@link Set} which internally uses a red-black tree to sort
 * the entries.
 *
 * The algorithm is derived from Robert Sedgewick's (of Princeton University)
 * 2008 variant of Red-Black Trees called Left Leaning Red-Black Trees.
 *
 * @param <V> The type of value stored in the set.
 * @since 2016/09/06
 */
public class SortedTreeSet<V>
	extends AbstractSet<V>
{
	/** Marker object to indicate that a value is set. */
	private static final Object _HAS_VALUE =
		new Object();
	
	/** The backing map. */
	private final SortedTreeMap<V, Object> _map;
	
	/**
	 * Initializes an empty red/black set using the natural comparator.
	 *
	 * @since 2016/09/06
	 */
	public SortedTreeSet()
	{
		this(NaturalComparator.<V>instance());
	}
	
	/**
	 * Initializes a red/black set using the natural comparator which is
	 * initialized with the given values.
	 *
	 * @param __s The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Collection<? extends Comparable<V>> __s)
		throws NullPointerException
	{
		this(NaturalComparator.<V>instance(), (Collection<? extends V>)__s);
	}
	
	/**
	 * Initializes an empty red/black set using the given comparator.
	 *
	 * @param __comp The comparator to use for values.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Comparator<? extends V> __comp)
		throws NullPointerException
	{
		// Check
		if (__comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = new SortedTreeMap<>(__comp);
	}
	
	/**
	 * Initializes a red/black set using the given comparator which is
	 * initialized with the given values.
	 *
	 * @param __comp The comparator to use for values.
	 * @param __s The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Comparator<? extends V> __comp,
		Collection<? extends V> __s)
		throws NullPointerException
	{
		// Check
		if (__comp == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = new SortedTreeMap<>(__comp);
		
		// Just call add all from collection
		this.addAll(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean add(V __v)
	{
		return (SortedTreeSet._HAS_VALUE != this._map.put(__v,
			SortedTreeSet._HAS_VALUE));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean contains(Object __o)
	{
		return this._map.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Iterator<V> iterator()
	{
		return this._map.keySet().iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean remove(Object __o)
	{
		Object q = this._map.remove(__o);
		return (q == SortedTreeSet._HAS_VALUE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

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

package net.multiphasicapps.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator where elements cannot be removed and where it iterates
 * over an array.
 *
 * @param <T> The type to use.
 * @since 2018/05/13
 */
public final class UnmodifiableArrayIterator<T>
	implements Iterator<T>
{
	/** The element limit. */
	protected final int limit;
	
	/** The source elements, cleared when empty. */
	private T[] _source;
	
	/** The current element. */
	private int _at;
	
	/**
	 * Initializes the iterator.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableArrayIterator(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this.limit = __o + __l;
		this._source = __a;
		this._at = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final boolean hasNext()
	{	
		return (this._at < this.limit);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final T next()
		throws NoSuchElementException
	{
		// Is at the end?
		int at = this._at;
		if (at >= this.limit)
		{
			this._source = null;
			throw new NoSuchElementException("NSEE");
		}
		
		this._at = at + 1;
		return this._source[at];
	}
	
	/**
	 * {@inheritDoc}
	 * @throws UnsupportedOperationException Always.
	 * @since 2108/05/13
	 */
	@Override
	public final void remove()
		throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The iterator type.
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Iterator<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayIterator<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The iterator type.
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayIterator<T>(__a, __o, __l);
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.List;
import java.util.RandomAccess;

/**
 * This is a list representation of an array which cannot be modified.
 *
 * @param <T> The type of values to store.
 * @since 2018/05/13
 */
public final class UnmodifiableArrayList<T>
	extends AbstractList<T>
	implements RandomAccess
{
	/** The element offset. */
	protected final int offset;
	
	/** The element length. */
	protected final int length;
	
	/** The source elements. */
	private final T[] _source;
	
	/**
	 * Initializes the list.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableArrayList(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this._source = __a;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/13
	 */
	@Override
	public final T get(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this.length)
			throw new IndexOutOfBoundsException(String.format("IOOB %d", __i));
		
		return this._source[this.offset + __i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/13
	 */
	@Override
	public final int size()
	{
		return this.length;
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The list type.
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> List<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayList<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The list type.
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> List<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayList<T>(__a, __o, __l);
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * This class represents a collection which cannot be modified.
 *
 * @since 2017/10/09
 */
public final class UnmodifiableCollection<T>
	extends AbstractCollection<T>
{
	/** The collection to wrap. */
	protected final Collection<T> wrapped;
	
	/**
	 * Initializes a collection view which cannot be modified.
	 *
	 * @param __w The collection to wrap a view for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	private UnmodifiableCollection(Collection<T> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		this.wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public boolean contains(Object __o)
	{
		return this.wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public boolean isEmpty()
	{
		return this.wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public Iterator<T> iterator()
	{
		return new Iterator<T>()
			{
				/** The base iterator. */
				final Iterator<T> _base = UnmodifiableCollection.this.wrapped.iterator();
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public boolean hasNext()
				{
					return this._base.hasNext();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public T next()
				{
					return this._base.next();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public void remove()
				{
					throw new UnsupportedOperationException("RORO");
				}
			};
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public int size()
	{
		return this.wrapped.size();
	}
	
	/**
	 * This creates a view of the specified collection which cannot be
	 * modified.
	 *
	 * @param <T> The type of value the set stores.
	 * @param __c The collection to wrap to disable modifications of.
	 * @return An unmodifiable view of the collection.
	 * @since 2017/10/09
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Collection<T> of(Collection<T> __c)
	{
		// If already one, return that collection
		if (__c instanceof UnmodifiableCollection)
			return __c;
		
		// Use List instead
		else if (__c instanceof List)
			return UnmodifiableList.<T>of((List<T>)__c);
		
		// Use Set instead
		else if (__c instanceof Set)
			return UnmodifiableSet.<T>of((Set<T>)__c);
		
		// Otherwise wrap as a collection
		return new UnmodifiableCollection<T>(__c);
	}
}

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

package net.multiphasicapps.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This creates an unmodifiable iterator over an existing iterator.
 *
 * @param <T> The type to use.
 * @since 2018/05/13
 */
public final class UnmodifiableIterator<T>
	implements Iterator<T>
{
	/** The source iterator. */
	protected final Iterator<T> source;
	
	/**
	 * Initializes the iterator.
	 *
	 * @param __it The source iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableIterator(Iterator<T> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this.source = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final boolean hasNext()
	{
		return this.source.hasNext();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final T next()
		throws NoSuchElementException
	{
		return this.source.next();
	}
	
	/**
	 * {@inheritDoc}
	 * @throws UnsupportedOperationException Always.
	 * @since 2108/05/13
	 */
	@Override
	public final void remove()
		throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Wraps the given iterable.
	 *
	 * @param <T> The iterator type.
	 * @param __i The iterable to wrap.
	 * @return The wrapped iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(Iterable<T> __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableIterator<T>(__i.iterator());
	}
	
	/**
	 * Wraps the given iterator.
	 *
	 * @param <T> The iterator type.
	 * @param __i The iterator to wrap.
	 * @return The wrapped iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(Iterator<T> __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableIterator<T>(__i);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The iterator type.
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Iterator<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayIterator<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param <T> The iterator type.
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayIterator<T>(__a, __o, __l);
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/UnmodifiableList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/**
 * This is a list which cannot be modified.
 *
 * @param <V> The type of value the list stores.
 * @since 2016/03/03
 */
public abstract class UnmodifiableList<V>
	extends AbstractList<V>
{
	/** The list to wrap. */
	protected final List<V> wrapped;	
	
	/**
	 * Initializes the list which cannot be modified.
	 *
	 * @param __l The list to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/03
	 */
	private UnmodifiableList(List<V> __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.wrapped = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return this.wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/03
	 */
	@Override
	public final V get(int __i)
	{
		return this.wrapped.get(__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int indexOf(Object __o)
	{
		return this.wrapped.indexOf(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return this.wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int lastIndexOf(Object __o)
	{
		return this.wrapped.lastIndexOf(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/03
	 */
	@Override
	public final int size()
	{
		return this.wrapped.size();
	}
	
	/**
	 * This creates a view of the specified list which cannot be modified.
	 *
	 * @param <V> The type of value stored in the list.
	 * @param __l The list to view.
	 * @return An unmodifiable view of the list.
	 * @since 2016/03/03
	 */
	public static <V> List<V> of(List<V> __l)
	{
		// If already one, return it
		if (__l instanceof UnmodifiableList)
			return __l;
		
		// Wrap, make sure that if the list being wrapped can be randomly
		// accessed that it also carries the RandomAccess interface.
		if (__l instanceof RandomAccess)
			return new UnmodifiableList.__Random__<V>(__l);
		return new UnmodifiableList.__Sequential__<V>(__l);
	}
	
	/**
	 * Wraps a list iterator so that it cannot have modifications.
	 *
	 * @param <V> The type of value in the list.
	 * @since 2016/05/12
	 */
	private static final class __ListIterator__<V>
		implements ListIterator<V>
	{
		/** The list iterator to wrap. */
		protected final ListIterator<V> li;
		
		/**
		 * Initializes the wrapped list iterator.
		 *
		 * @param __li The iterator to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/05/12
		 */
		private __ListIterator__(ListIterator<V> __li)
			throws NullPointerException
		{
			// Check
			if (__li == null)
				throw new NullPointerException("NARG");
			
			// Set
			this.li = __li;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void add(V __e)
		{
			throw new UnsupportedOperationException("RORO");
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public boolean hasNext()
		{
			return this.li.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public boolean hasPrevious()
		{
			return this.li.hasPrevious();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public V next()
		{
			return this.li.next();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public int nextIndex()
		{
			return this.li.nextIndex();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public V previous()
		{
			return this.li.previous();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public int previousIndex()
		{
			return this.li.previousIndex();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void set(V __v)
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * This is a list which implements {@link RandomAccess} so that the sort
	 * and search operations do not result in an entire copy of the list
	 * before the operation is performed.
	 *
	 * @param <V> The type to contain.
	 * @since 2016/04/28
	 */
	private static final class __Random__<V>
		extends UnmodifiableList<V>
		implements RandomAccess
	{
		/**
		 * Initializes the random access list.
		 *
		 * @param __l The list to wrap.
		 * @since 2016/04/28
		 */
		private __Random__(List<V> __l)
		{
			super(__l);
		}
	}
	
	/**
	 * This is a list which does not implement {@link RandomAccess} and as
	 * such when sort or binary search is done, an intermediate array is used
	 * in place.
	 *
	 * @param <V> The type to contain.
	 * @since 2016/04/28
	 */
	private static final class __Sequential__<V>
		extends UnmodifiableList<V>
	{
		/**
		 * Initializes the sequential access list.
		 *
		 * @param __l The list to wrap.
		 * @since 2016/04/28
		 */
		private __Sequential__(List<V> __l)
		{
			super(__l);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public Iterator<V> iterator()
		{
			return this.listIterator();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public ListIterator<V> listIterator()
		{
			return this.listIterator(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public ListIterator<V> listIterator(int __i)
		{
			return new __ListIterator__<V>(this.wrapped.listIterator(__i));
		}
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/UnmodifiableMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * This is a map which cannot be modified.
 *
 * @param <K> Key type to use.
 * @param <V> Value type to store.
 * @since 2016/02/29
 */
public final class UnmodifiableMap<K, V>
	extends AbstractMap<K, V>
{
	/** The existing map to wrap. */
	protected final Map<K, V> wrapped;
	
	/** Entry set cache, since it is not always needed. */
	private Reference<Set<Map.Entry<K, V>>> _escache;
	
	/**
	 * Initializes the unmodifiable wrapped map.
	 *
	 * @param __w The map to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/29
	 */
	private UnmodifiableMap(Map<K, V> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return this.wrapped.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsValue(Object __o)
	{
		return this.wrapped.containsValue(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		// Get reference to the map
		Reference<Set<Map.Entry<K, V>>> ref = this._escache;
		Set<Map.Entry<K, V>> rv = null;
		
		// In reference?
		if (ref != null)
			rv = ref.get();
		
		// Needs initialization?
		if (rv == null)
			this._escache = new WeakReference<>((rv = new __SetView__()));
		
		// Return it
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public V get(Object __k)
	{
		return this.wrapped.get(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return this.wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public int size()
	{
		return this.wrapped.size();
	}
	
	/**
	 * This creates a view of the specified map which cannot be modified.
	 *
	 * @param <K> The map key.
	 * @param <V> The map value.
	 * @param __m The map to wrap.
	 * @return An unmodifiable view of the map.
	 * @since 2016/02/28
	 */
	public static <K, V> Map<K, V> of(Map<K, V> __m)
	{
		// If already one, return it
		if (__m instanceof UnmodifiableMap)
			return __m;
		
		// Wrap
		return new UnmodifiableMap<K, V>(__m);
	}
	
	/**
	 * This is the iterator over the entry set of the map.
	 *
	 * @since 2016/02/29
	 */
	private final class __SetIterator__
		implements Iterator<Map.Entry<K, V>>
	{
		/** The base iterator. */
		protected final Iterator<Map.Entry<K, V>> from =
			UnmodifiableMap.this.wrapped.entrySet().iterator();
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public boolean hasNext()
		{
			return this.from.hasNext();
		}
	
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public Map.Entry<K, V> next()
		{
			// Get the next entry
			Map.Entry<K, V> ent = this.from.next();
			
			// If null, this is a bad map but possibly might be valid
			if (ent == null)
				return null;
			
			// Wrap it
			return new __SetEntry__<K, V>(ent);
		}
		
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * This implements the unmodifiable set view.
	 *
	 * @since 2016/02/29
	 */
	private final class __SetView__
		extends AbstractSet<Map.Entry<K, V>>
	{
		
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public Iterator<Map.Entry<K, V>> iterator()
		{
			return new __SetIterator__();
		}
	
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public int size()
		{
			return UnmodifiableMap.this.wrapped.size();
		}
	}
	
	/**
	 * This is a single entry in the set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2016/02/29
	 */
	private static final class __SetEntry__<K, V>
		implements Map.Entry<K, V>
	{
		/** The base entry. */
		protected final Map.Entry<K, V> base;
		
		/**
		 * Initializes the set entry.
		 *
		 * @param __e The entry to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/02/29
		 */
		private __SetEntry__(Map.Entry<K, V> __e)
			throws NullPointerException
		{
			// Check
			if (__e == null)
				throw new NullPointerException("NARG");
			
			// Set
			this.base = __e;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public boolean equals(Object __a)
		{
			return this.base.equals(__a);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public K getKey()
		{
			return this.base.getKey();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public V getValue()
		{
			return this.base.getValue();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public int hashCode()
		{
			return this.base.hashCode();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public V setValue(V __a)
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which cannot be modified.
 *
 * @param <T> The value to store in the set.
 * @since 2016/02/28
 */
public final class UnmodifiableSet<T>
	extends AbstractSet<T>
{
	/** The set to wrap. */
	protected final Set<T> wrapped;
	
	/**
	 * Initializes a set view which cannot be modified.
	 *
	 * @param __w The set to wrap a view for.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/28
	 */
	private UnmodifiableSet(Set<T> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		this.wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public boolean contains(Object __o)
	{
		return this.wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return this.wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public Iterator<T> iterator()
	{
		return new Iterator<T>()
			{
				/** The base iterator. */
				final Iterator<T> _base = UnmodifiableSet.this.wrapped.iterator();
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public boolean hasNext()
				{
					return this._base.hasNext();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public T next()
				{
					return this._base.next();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public void remove()
				{
					throw new UnsupportedOperationException("RORO");
				}
			};
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public int size()
	{
		return this.wrapped.size();
	}
	
	/**
	 * This creates a view of the specified set which cannot be modified.
	 *
	 * @param <T> The type of value the set stores.
	 * @param __s The set to wrap to disable modifications of.
	 * @return An unmodifiable view of the set.
	 * @since 2016/02/28
	 */
	public static <T> Set<T> of(Set<T> __s)
	{
		// If already one, return that set
		if (__s instanceof UnmodifiableSet)
			return __s;
		
		// Otherwise create a new one
		return new UnmodifiableSet<T>(__s);
	}
}

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

package net.multiphasicapps.collections;

import java.util.Comparator;
import java.util.Map;
import java.util.Objects;

/**
 * This stores a key and value pair which is referenced by a node.
 *
 * @since 2017/03/30
 */
class __Data__<K, V>
	implements Map.Entry<K, V>
{
	/** The comparison method to use. */
	final Comparator<K> _compare;
	
	/** The key for this data. */
	final K _key;
	
	/** The value of the data. */
	volatile V _value;
	
	/** The node owning this data (used only to detect modification). */
	volatile __Node__<K, V> _node;
	
	/** The data before this one. */
	volatile __Data__<K, V> _prev;
	
	/** The data after this one. */
	volatile __Data__<K, V> _next;
	
	/**
	 * Initializes the data.
	 *
	 * @param __m The owning map.
	 * @param __k The key used for this data.
	 * @param __v The value to initially store.
	 * @throws NullPointerException If no map was specified.
	 * @since 2017/03/30
	 */
	__Data__(SortedTreeMap<K, V> __m, K __k, V __v)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this._compare = __m._compare;
		this._key = __k;
		this._value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Must be another entry
		if (!(__o instanceof Map.Entry))
			return false;
		
		// Compare
		Map.Entry<?, ?> o = (Map.Entry<?, ?>)__o;
		return Objects.equals(this._key, o.getKey()) &&
			Objects.equals(this._value, o.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public K getKey()
	{
		return this._key;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V getValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this._key) ^ Objects.hashCode(this._value);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V setValue(V __a)
	{
		V rv = this._value;
		this._value = __a;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public String toString()
	{
		return String.format("[%s, %s]", this._key, this._value);
	}
	
	/**
	 * Compares this data against the given key.
	 *
	 * @param __n The key to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(K __k)
	{
		return this._compare.compare(this._key, __k);
	}
	
	/**
	 * Compares this data against the given data.
	 *
	 * @param __n The data to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Data__<K, V> __d)
	{
		return this.__compare(__d._key);
	}
	
	/**
	 * Compares this data against the given node.
	 *
	 * @param __n The node to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Node__<K, V> __n)
	{
		return this.__compare(__n._data);
	}
}

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

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;

/**
 * This represents the entry set of the map.
 *
 * @param <K> The keys to use.
 * @param <V> The values to use.
 * @since 2016/09/07
 */
final class __EntrySet__<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The owning map. */
	private final SortedTreeMap<K, V> _map;
	
	/**
	 * Initializes the entry set.
	 *
	 * @param __m The owning map.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/07
	 */
	__EntrySet__(SortedTreeMap<K, V> __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public Iterator<Map.Entry<K, V>> iterator()
	{
		return new __MapIterator__<K, V>(this._map);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/__IdentityBaseSet__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is the base class for the identity set.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
abstract class __IdentityBaseSet__<T>
	extends AbstractSet<T>
{
	/** The set to use as a backing storage. */
	private final Set<__IdentityWrapper__<T>> _backing;
	
	/**
	 * Initializes the base set using the given backing set.
	 *
	 * @param __back The set to back with.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityBaseSet__(Set<__IdentityWrapper__<T>> __back)
		throws NullPointerException
	{
		if (__back == null)
			throw new NullPointerException("NARG");
		
		this._backing = __back;
	}
	
	/**
	 * Initializes the base set using the given backing set.
	 *
	 * @param __back The set to back with.
	 * @param __from The collection to source data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityBaseSet__(Set<__IdentityWrapper__<T>> __back,
		Collection<? extends T> __from)
		throws NullPointerException
	{
		if (__back == null || __from == null)
			throw new NullPointerException("NARG");
		
		this._backing = __back;
		this.addAll(__from);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean add(T __t)
	{
		if (__t == null)
			return this._backing.add(null);
		return this._backing.add(new __IdentityWrapper__<T>(__t));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final void clear()
	{
		this._backing.clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean contains(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean containsAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Set))
			return false;
		
		Set<?> o = (Set<?>)__o;
		return this.size() == o.size() &&
			this.containsAll(o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean isEmpty()
	{
		return this._backing.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final Iterator<T> iterator()
	{
		return new __Iterator__();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean remove(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean removeAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean retainAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final int size()
	{
		return this._backing.size();
	}
	
	/**
	 * Iterates over wrapped entries.
	 *
	 * @since 2017/12/28
	 */
	private final class __Iterator__
		implements Iterator<T>
	{
		/** The boxed iterator. */
		protected final Iterator<__IdentityWrapper__<T>> boxed =
			__IdentityBaseSet__.this._backing.iterator();
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public boolean hasNext()
		{
			return this.boxed.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public T next()
		{
			__IdentityWrapper__<T> rv = this.boxed.next();
			if (rv == null)
				return null;
			return rv.get();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public void remove()
		{
			this.boxed.remove();
		}
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/__IdentityWrapper__.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
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

/**
 * This wraps an object and allows comparison of the object by value only.
 *
 * @param <T> The type of value to wrap.
 * @since 2017/12/28
 */
final class __IdentityWrapper__<T>
{
	/** The wrapped object. */
	protected final T value;
	
	/**
	 * Initializes the wrapped object.
	 *
	 * @param __v The value to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityWrapper__(T __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof __IdentityWrapper__))
			return false;
		
		return this.value == ((__IdentityWrapper__<?>)__o).value;
	}
	
	/**
	 * Returns the wrapped object.
	 *
	 * @return The wrapped object.
	 * @since 2017/12/28
	 */
	public T get()
	{
		return this.value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public int hashCode()
	{
		return this.value.hashCode();
	}
}

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

package net.multiphasicapps.collections;

import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This iterates over the sorted set.
 *
 * @since 2016/09/06
 */
class __MapIterator__<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The owning map. */
	protected final SortedTreeMap<K, V> map;
	
	/** The current node position. */
	private volatile __Data__<K, V> _at;
	
	/** The last visited node (for deletion). */
	private volatile __Data__<K, V> _last;
	
	/**
	 * Iterates over the given map.
	 *
	 * @param __m The map to iterate over.
	 * @since 2016/09/06
	 */
	__MapIterator__(SortedTreeMap<K, V> __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.map = __m;
		this._at = __m._min;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean hasNext()
	{
		__Data__<K, V> at = this._at;
		if (at == null)
			return false;
		return (this.__detect(at) != null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Map.Entry<K, V> next()
	{
		// {@squirreljme.error AC06 No more elements to iterate over.}
		__Data__<K, V> rv = this._at;
		if (rv == null)
			throw new NoSuchElementException("AC06");
		
		// Make sure the value was not removed
		rv = this.__detect(rv);
		
		// Store last node (for removal) and iterate to the next node value
		this._last = rv;
		this._at = rv._next;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public void remove()
	{
		// {@squirreljme.error AC07 No last entry exists for deletion.}
		__Data__<K, V> last = this._last;
		if (last == null)
			throw new IllegalStateException("AC07");
		
		// Remove the entry
		this._last = null;
		this.map.remove(last._key);
	}
	
	/**
	 * Detects if concurrent modification has occured.
	 *
	 * @param __data The data to check.
	 * @return {@code __data}.
	 * @throws ConcurrentModificationException If modification was detected.
	 * @throws NullPointerException On null arguments. 
	 * @since 2017/03/30
	 */
	private final __Data__<K, V> __detect(__Data__<K, V> __data)
		throws ConcurrentModificationException, NullPointerException
	{
		// Check
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AC08 Referenced node was deleted.}
		if (__data._node == null)
			throw new ConcurrentModificationException("AC08");
		
		return __data;
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/__Node__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

/**
 * This represents a single node within the tree.
 *
 * @param <K> The key used.
 * @param <V> The value used.
 * @since 2016/09/06
 */
class __Node__<K, V>
{
	/** The color, defaults to red. */
	volatile boolean _isred =
		true;
	
	/** The currently associated data for this node. */
	volatile __Data__<K, V> _data;
	
	/** The node to the left. */
	volatile __Node__<K, V> _left;
	
	/** The node to the right. */
	volatile __Node__<K, V> _right;
	
	/**
	 * Compares this node against the given key.
	 *
	 * @param __n The key to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(K __k)
	{
		return this._data.__compare(__k);
	}
	
	/**
	 * Compares this node against the given data.
	 *
	 * @param __n The data to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Data__<K, V> __d)
	{
		return this._data.__compare(__d);
	}
	
	/**
	 * Compares this node against the given node.
	 *
	 * @param __n The node to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Node__<K, V> __n)
	{
		return this._data.__compare(__n);
	}
	
	/**
	 * Makes the node black.
	 *
	 * @since 2017/03/30
	 */
	final void __makeBlack()
	{
		this._isred = false;
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/__Sub__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This is a sub-deque which is given access to the {@link MultiSetDeque}.
 *
 * @since 2016/09/03
 */
final class __Sub__<V>
	implements Deque<V>
{
	/** The owning multi-set. */
	final MultiSetDeque<V> _msd;
	
	/** The list which acts as a queue. */
	final List<V> _deque;
	
	/** The items which are in this queue. */
	final Set<V> _set =
		new HashSet<>();
	
	/** The capacity limit. */
	final int _limit;
	
	/**
	 * Initializes the sub-queue.
	 *
	 * @param __msd The owning queue.
	 * @param __l The size limit of this queue.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/03
	 */
	__Sub__(MultiSetDeque<V> __msd, int __l)
		throws NullPointerException
	{
		// Check
		if (__msd == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._msd = __msd;
		this._limit = __l;
		
		// Base on a list
		this._deque = new ArrayList<>();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean add(V __a)
		throws NullPointerException
	{
		// Remember old size
		List<V> deque = this._deque;
		int was = deque.size();
		
		// Add it
		this.addLast(__a);
		
		// If the size changed then it was added
		return deque.size() != was;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean addAll(Collection<? extends V> __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Add everything
		boolean rv = false;
		for (V v : __a)
			rv |= this.add(v);
		
		// Has this changed?
		return rv;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void addFirst(V __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void addLast(V __a)
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AC09 Deque capacity would be exceeded.}
		List<V> deque = this._deque;
		if (deque.size() + 1 >= this._limit)
			throw new IllegalStateException("AC09");
		
		// Do not add the element if it is already in this queue.
		Set<V> set = this._set;
		if (set.contains(__a))
			return;
		
		// Otherwise add it
		deque.add(__a);
		set.add(__a);
		this._msd._master.add(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean contains(Object __a)
	{
		return this._deque.contains(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean containsAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Iterator<V> descendingIterator()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V element()
	{
		return this.getFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean equals(Object __a)
	{
		
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V getFirst()
	{
		// {@squirreljme.error AC0a The deque is empty.}
		List<V> deque = this._deque;
		if (deque.size() <= 0)
			throw new NoSuchElementException("AC0a");
		
		// Just get it
		return deque.get(0);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V getLast()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public int hashCode()
	{
		return this._deque.hashCode();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Iterator<V> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offer(V __a)
	{
		return this.offerLast(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offerFirst(V __a)
	{
		try
		{
			this.addFirst(__a);
			return true;
		}
		
		// Exceeds capacity
		catch (IllegalStateException e)
		{
			return false;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offerLast(V __a)
	{
		try
		{
			this.addLast(__a);
			return true;
		}
		
		// Exceeds capacity
		catch (IllegalStateException e)
		{
			return false;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peek()
	{
		return this.peekFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peekFirst()
	{
		try
		{
			return this.getFirst();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peekLast()
	{
		try
		{
			return this.getLast();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V poll()
	{
		return this.pollFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pollFirst()
	{
		try
		{
			return this.removeFirst();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pollLast()
	{
		try
		{
			return this.removeLast();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pop()
	{
		return this.removeFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void push(V __a)
	{
		this.addFirst(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean remove(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V remove()
	{
		return this.removeFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V removeFirst()
		throws NoSuchElementException
	{
		// {@squirreljme.error AC0b The deque is empty.}
		List<V> deque = this._deque;
		if (deque.size() <= 0)
			throw new NoSuchElementException("AC0b");
		
		// Remove it
		V rv = deque.remove(0);
		
		// The value is gone from this collection now so remove it
		Set<V> set = this._set;
		set.remove(rv);
		
		// Remove from all over queues
		this._msd.remove(rv);
		
		// Return
		return rv;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeFirstOccurrence(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V removeLast()
		throws NoSuchElementException
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeLastOccurrence(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean retainAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public int size()
	{
		return this._deque.size();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public <T> T[] toArray(T[] __a)
	{
		return this._deque.<T>toArray(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Object[] toArray()
	{
		return this._deque.toArray();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public String toString()
	{
		return this._deque.toString();
	}
	
	/**
	 * Quick clear of the queue.
	 *
	 * @since 2017/03/25
	 */
	final void __clear()
	{
		this._deque.clear();
		this._set.clear();
	}
	
	/**
	 * Removes the item if it is in this deque.
	 *
	 * @param __v The item to remove.
	 * @return {@code true} if it was removed.
	 * @since 2016/09/03
	 */
	final boolean __remove(V __v)
	{
		// Not in this deque
		Set<V> set = this._set;
		if (!set.contains(__v))
			return false;
		
		// Otherwise remove it
		if (!this._deque.remove(__v))
			throw new todo.OOPS();
		
		// Remove from set
		set.remove(__v);
		
		// Did remove
		return true;
	}
}

Added modules/collections/src/main/java/net/multiphasicapps/collections/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains a number of collections.
 *
 * @since 2017/10/26
 */

package net.multiphasicapps.collections;

Added modules/common-vm/build.gradle.


























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This contains classes which are common across " +
 "the various SquirrelJME VMs, and these only need to be written once " +
 "as such."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AK"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Common Virtual Machine Classes"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:midp-lcdui")
	implementation project(":modules:meep-swm")
	implementation project(":modules:meep-midlet")
	implementation project(":modules:tool-manifest-reader")
	implementation project(":modules:zip")
}

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

package cc.squirreljme.vm;

import java.io.IOException;
import java.io.InputStream;

/**
 * This class represents a class library which represents a single JAR file
 * whether it exists on the disk or is virtually provided.
 *
 * @since 2018/09/13
 */
public interface VMClassLibrary
{
	/**
	 * Lists the names of the resources in this library.
	 *
	 * @return The resource names.
	 * @since 2019/04/21
	 */
	String[] listResources();
	
	/**
	 * Returns the name of this library.
	 *
	 * @return The library name.
	 * @since 2018/09/13
	 */
	String name();
	
	/**
	 * Opens the specified resource as a stream.
	 *
	 * @param __rc The name of the resource to open.
	 * @return The stream to the resource data or {@code null} if it is not
	 * valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/13
	 */
	InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException;
}

Added modules/common-vm/src/main/java/cc/squirreljme/vm/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes and utilities which are common to all
 * the virtual machine implementations.
 *
 * @since 2018/11/17
 */

package cc.squirreljme.vm;

Added modules/common-vm/src/main/resources/squirreljme-vm.png.__mime.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 squirreljme-vm.png
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/
AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4gwXESMJRfeU
jAAAAcBJREFUOMutkzFoU1EYhb+mFUM7hSIUUXApETuISAeRi2OvUG4Hh+fg
oOLwsgQJLhEeBiLPrUihvAySgK3QOoaC7VwwdHAQQlW6dGqQQoJiVWz1d3i9
lzxfxMW33HPP/5/Duf+9D/7XF5U9GcT9jbc4Y4mZi7OJQlT2RBmNMjrF9/eO
2ML3rwf41QjANU+cPcP4xOVYeMz71Yh3z1+SSACQHR2jFhTwiiUAlNFOPDU9
h1+NUEZTCwpkR8ecgUuw8XYNr1gid2rSFX98+0g9rKCMZrO5bhOy0VxLJ/CK
JfZ2t+nt77hiPaxw92HF7Xv7OwmjhMHe7janz11gdWE+MfGDL58dXl2Yx69G
1IJC+ghWfOtBQDY7wrPHj1zTZnMdZTRT03PUgkLCJNPvfidc4tWl6/x608MP
Vxw//uI1k4fnYTiXSuAMlNGc5EQ8vGtXYbnOvXARZXTcMKNhuQ7DOXdTqdfV
bjVEDjsiPz9JHhE56oocdWN8zOURicqewwNNbEO71ZB2q5EQ2RUgj0jmzyR2
YBbfuHKb++WbidgfGBpKzaDb2ZJ+IcDTJyu8l3g+9nqV0XQ7W/LPvzN1vgFc
HpHfHmPowBfRG4IAAAAASUVORK5CYII=
====

Added modules/demo-hello/build.gradle.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This is a basic demo which prints a hello " +
	"message and prints some details about the virtual machine."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BT"
	swmType = JavaMEMidletType.APPLICATION
	swmName = "Hello (Demo)"
	swmVendor = "Stephanie Gawroriski"
	mainClass = "net.multiphasicapps.demo.hello.Hello"
}

dependencies
{
	project(":modules:cldc-compact")
}

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

package net.multiphasicapps.demo.hello;

import java.io.PrintStream;

/**
 * Prints a hello message along with information about the virtual machine.
 *
 * @since 2018/09/22
 */
public class Hello
{
	/** Properties to print. */
	private static final String[] _PROPERTIES =
		new String[]
		{
			"java.version",
			"java.vendor",
			"java.vendor.email",
			"java.vendor.url",
			"java.vm.name",
			"java.vm.version",
			"cc.squirreljme.apilevel",
			"java.vm.vendor",
			"java.vm.vendor.email",
			"java.vm.vendor.url",
			"java.runtime.name",
			"java.runtime.version",
			"os.name",
			"os.arch",
			"os.version",
			"microedition.encoding",
			"microedition.configuration",
			"microedition.locale",
			"microedition.profiles",
			"cc.squirreljme.vm.execpath",
			"cc.squirreljme.vm.freemem",
			"cc.squirreljme.vm.totalmem",
			"cc.squirreljme.vm.maxmem",
		};
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/09/22
	 */
	public static final void main(String... __args)
	{
		PrintStream out = System.out;
		
		// Print input message if used
		int an;
		if (__args != null && (an = __args.length) > 0)
		{
			for (int i = 0; i < an; i++)
			{
				// Add space for nicer formatting
				if (i > 0)
					out.print(' ');
				
				out.print(__args[i]);
			}
			
			// Make it nice
			out.println();
		}
		
		// Just a basic message
		else
			out.println("Hello! Squirrels are so cute!");
		
		// Print some information about the virtual machine itself
		for (String p : Hello._PROPERTIES)
		{
			String v = System.getProperty(p);
			if (v != null)
			{
				out.print(p);
				out.print(": ");
				out.println(v);
			}
		}
	}
}

Added modules/demo-hello/src/main/java/net/multiphasicapps/demo/hello/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the hello program.
 *
 * @since 2018/09/22
 */

package net.multiphasicapps.demo.hello;

Added modules/dio-adc/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to analog to digital converters."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CV"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (ADC)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.adc;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.adc;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface ADCChannel
	extends Device<ADCChannel>, BufferAccess<IntBuffer>
{
	int acquire()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void acquire(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int getMaxSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMinSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMinValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	double getVRefValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setSamplingInterval(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startAcquisition(IntBuffer __a, AcquisitionRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void startAcquisition(IntBuffer __a, IntBuffer __b,
		AcquisitionRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void startMonitoring(int __a, int __b, MonitoringListener __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stopAcquisition()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stopMonitoring()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


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

package jdk.dio.adc;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class ADCChannelConfig
	implements DeviceConfig<ADCChannel>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public ADCChannelConfig(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public ADCChannelConfig(String __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getResolution()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingInterval()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingTime()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static ADCChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public ADCChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setResolution(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingInterval(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingTime(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.adc;

import jdk.dio.DevicePermission;

public class ADCPermission
	extends DevicePermission
{
	public ADCPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public ADCPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


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

package jdk.dio.adc;

import java.nio.IntBuffer;
import jdk.dio.InputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface AcquisitionRoundListener
	extends InputRoundListener<ADCChannel, IntBuffer>
{
	void failed(Throwable __a, ADCChannel __b);
	
	void inputRoundCompleted(RoundCompletionEvent<ADCChannel, IntBuffer> __a);
}


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

package jdk.dio.adc;


public class InvalidInputSamplingRateException
	extends RuntimeException
{
	public InvalidInputSamplingRateException()
	{
		throw new todo.TODO();
	}
	
	public InvalidInputSamplingRateException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.adc;

import jdk.dio.DeviceEvent;

public class MonitoringEvent
	extends DeviceEvent<ADCChannel>
{
	public static final int BACK_TO_RANGE =
		1;
	
	public static final int OUT_OF_RANGE =
		0;
	
	public MonitoringEvent(ADCChannel __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public MonitoringEvent(ADCChannel __a, int __b, int __c, long __d, int 
		__e)
	{
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.adc;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface MonitoringListener
	extends DeviceEventListener, AsyncErrorHandler<ADCChannel>
{
	void failed(Throwable __a, ADCChannel __b);
	
	void thresholdReached(MonitoringEvent __a);
}


Added modules/dio-adc/src/main/java/jdk/dio/adc/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to analog to digital converters.
 *
 * @since 2016/06/23
 */

package jdk.dio.adc;

Added modules/dio-atcmd/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to devices which use the " +
	"standard AT command set."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CZ"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (AT Device)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.atcmd;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
	implementation project(":modules:dio-modem")
}

Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/ATDevice.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface ATDevice
	extends Device<ATDevice>
{
	@Deprecated
	void abortCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void close()
		throws IOException;
	
	@Deprecated
	void escapeToCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMaxCommandLength()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	boolean isConnected()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	boolean isInCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	DataConnection openDataConnection(String __a, CommandResponseHandler __b,
		DataConnectionHandler __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	String sendCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void sendCommand(String __a, CommandResponseHandler __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setUnsolicitedResponseHandler(UnsolicitedResponseHandler __a)
		throws IOException, ClosedDeviceException;
	
	String tryAbortCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	String tryEscapeToCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/ATDeviceConfig.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class ATDeviceConfig
	implements DeviceConfig<ATDevice>, DeviceConfig.HardwareAddressing
{
	public ATDeviceConfig(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public ATDeviceConfig(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static ATDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/ATModem.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import jdk.dio.modem.ModemSignalsControl;

public interface ATModem
	extends ATDevice, ModemSignalsControl<ATModem>
{
}


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

package jdk.dio.atcmd;

import jdk.dio.DevicePermission;

public class ATPermission
	extends DevicePermission
{
	public static final String DATA =
		"data";
	
	public ATPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public ATPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/CommandResponseHandler.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface CommandResponseHandler
{
	String processResponse(ATDevice __a, String __b);
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/DataConnection.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.nio.channels.ByteChannel;

public interface DataConnection
	extends ByteChannel
{
	ATDevice getDevice();
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/DataConnectionHandler.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface DataConnectionHandler
{
	void handleClosedDataConnection(ATDevice __a, DataConnection __b);
	
	void handleOpenedDataConnection(ATDevice __a, DataConnection __b);
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/UnsolicitedResponseHandler.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface UnsolicitedResponseHandler
{
	void processResponse(ATDevice __a, String __b);
}


Added modules/dio-atcmd/src/main/java/jdk/dio/atcmd/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for AT command devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.atcmd;

Added modules/dio-counter/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to hardware counters."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DQ"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (Counters)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.counter;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc-compact")
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
	implementation project(":modules:dio-gpio")
}

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

package jdk.dio.counter;

import jdk.dio.DevicePermission;

public class CounterPermission
	extends DevicePermission
{
	public CounterPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public CounterPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


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

package jdk.dio.counter;

import jdk.dio.DeviceEvent;

public class CountingEvent
	extends DeviceEvent<PulseCounter>
{
	public static final int INTERVAL_EXPIRED =
		1;
	
	public static final int TERMINAL_VALUE_REACHED =
		0;
	
	public CountingEvent(PulseCounter __a, int __b, int __c, long __d)
	{
		throw new todo.TODO();
	}
	
	public CountingEvent(PulseCounter __a, int __b, int __c, long __d, long 
		__e, int __f)
	{
		throw new todo.TODO();
	}
	
	public long getInterval()
	{
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.counter;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface CountingListener
	extends DeviceEventListener, AsyncErrorHandler<PulseCounter>
{
	void countValueAvailable(CountingEvent __a);
	
	void failed(Throwable __a, PulseCounter __b);
}


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

package jdk.dio.counter;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.gpio.GPIOPin;

public interface PulseCounter
	extends Device<PulseCounter>
{
	int getCount()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	GPIOPin getSource();
	
	void resetCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void resumeCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startCounting(int __a, long __b, CountingListener __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stopCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void suspendCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


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

package jdk.dio.counter;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.gpio.GPIOPinConfig;

public final class PulseCounterConfig
	implements DeviceConfig<PulseCounter>, DeviceConfig.HardwareAddressing
{
	public static final int TYPE_FALLING_EDGE_ONLY =
		0;
	
	public static final int TYPE_NEGATIVE_PULSE =
		3;
	
	public static final int TYPE_POSITIVE_PULSE =
		2;
	
	public static final int TYPE_RISING_EDGE_ONLY =
		1;
	
	@Deprecated
	public PulseCounterConfig(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(int __a, int __b, int __c, GPIOPinConfig __d)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(String __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(String __a, int __b, int __c, GPIOPinConfig __d
		)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin getSource()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig getSourceConfig()
	{
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static PulseCounterConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public PulseCounterConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSourceConfig(GPIOPinConfig __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setType(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Added modules/dio-counter/src/main/java/jdk/dio/counter/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to hardware counters.
 *
 * @since 2016/06/23
 */

package jdk.dio.counter;

Added modules/dio-dac/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to digital to analog converters."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CW"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (DAC)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.dac;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

Added modules/dio-dac/src/main/java/jdk/dio/dac/DACChannel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface DACChannel
	extends Device<DACChannel>, BufferAccess<IntBuffer>
{
	void generate(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void generate(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int getMaxSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMinSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMinValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	double getVRefValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setSamplingInterval(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startGeneration(IntBuffer __a, GenerationRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void startGeneration(IntBuffer __a, IntBuffer __b,
		GenerationRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void stopGeneration()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


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

package jdk.dio.dac;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class DACChannelConfig
	implements DeviceConfig<DACChannel>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public DACChannelConfig(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public DACChannelConfig(String __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getResolution()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingInterval()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DACChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public DACChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setResolution(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingInterval(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.dac;

import jdk.dio.DevicePermission;

public class DACPermission
	extends DevicePermission
{
	public DACPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public DACPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


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

package jdk.dio.dac;

import java.nio.IntBuffer;
import jdk.dio.OutputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface GenerationRoundListener
	extends OutputRoundListener<DACChannel, IntBuffer>
{
	void failed(Throwable __a, DACChannel __b);
	
	void outputRoundCompleted(RoundCompletionEvent<DACChannel, IntBuffer> __a);
}


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

package jdk.dio.dac;


public class InvalidOutputSamplingRateException
	extends RuntimeException
{
	public InvalidOutputSamplingRateException()
	{
		throw new todo.TODO();
	}
	
	public InvalidOutputSamplingRateException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio-dac/src/main/java/jdk/dio/dac/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to digital to analog converters.
 *
 * @since 2016/06/23
 */

package jdk.dio.dac;

Added modules/dio-generic/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to generic devices."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DS"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (Generic)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.generic;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.generic;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface GenericBufferIODevice
	extends GenericDevice, ByteChannel, BufferAccess<ByteBuffer>
{
	int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
}


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

package jdk.dio.generic;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GenericDevice
	extends Device<GenericDevice>
{
	<T> T getControl(GenericDeviceControl<T> __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	<T> void setControl(GenericDeviceControl<T> __a, T __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setEventListener(int __a, GenericEventListener __b)
		throws IOException, ClosedDeviceException;
}


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

package jdk.dio.generic;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GenericDeviceConfig
	implements DeviceConfig<GenericDevice>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public GenericDeviceConfig(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GenericDeviceConfig(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GenericDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public GenericDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.generic;


public class GenericDeviceControl<T>
{
	public GenericDeviceControl(int __a, Class<T> __b)
	{
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
	
	public Class<T> getType()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.generic;

import jdk.dio.DeviceEvent;

public class GenericEvent
	extends DeviceEvent<GenericDevice>
{
	public static final int INPUT_BUFFER_OVERRUN =
		1;
	
	public static final int INPUT_DATA_AVAILABLE =
		0;
	
	public static final int OUTPUT_BUFFER_EMPTY =
		2;
	
	public GenericEvent(GenericDevice __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public GenericEvent(GenericDevice __a, int __b, long __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-generic/src/main/java/jdk/dio/generic/GenericEventListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import jdk.dio.DeviceEventListener;

public interface GenericEventListener
	extends DeviceEventListener
{
	void eventDispatched(GenericEvent __a);
}


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

package jdk.dio.generic;

import jdk.dio.DevicePermission;

public class GenericPermission
	extends DevicePermission
{
	public GenericPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GenericPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Added modules/dio-generic/src/main/java/jdk/dio/generic/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to generic devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.generic;

Added modules/dio-gpio/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to GPIO pins."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CS"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (GPIO)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.gpio;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.gpio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GPIOPin
	extends Device<GPIOPin>
{
	int INPUT =
		0;
	
	int OUTPUT =
		1;
	
	int getDirection()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getTrigger()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	boolean getValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setDirection(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setInputListener(PinListener __a)
		throws IOException, ClosedDeviceException;
	
	void setTrigger(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setValue(boolean __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


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

package jdk.dio.gpio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GPIOPinConfig
	implements DeviceConfig<GPIOPin>, DeviceConfig.HardwareAddressing
{
	public static final int DIR_BOTH_INIT_INPUT =
		2;
	
	public static final int DIR_BOTH_INIT_OUTPUT =
		3;
	
	public static final int DIR_INPUT_ONLY =
		0;
	
	public static final int DIR_OUTPUT_ONLY =
		1;
	
	public static final int MODE_INPUT_PULL_DOWN =
		2;
	
	public static final int MODE_INPUT_PULL_UP =
		1;
	
	public static final int MODE_OUTPUT_OPEN_DRAIN =
		8;
	
	public static final int MODE_OUTPUT_PUSH_PULL =
		4;
	
	public static final int TRIGGER_BOTH_EDGES =
		3;
	
	public static final int TRIGGER_BOTH_LEVELS =
		6;
	
	public static final int TRIGGER_FALLING_EDGE =
		1;
	
	public static final int TRIGGER_HIGH_LEVEL =
		4;
	
	public static final int TRIGGER_LOW_LEVEL =
		5;
	
	public static final int TRIGGER_NONE =
		0;
	
	public static final int TRIGGER_RISING_EDGE =
		2;
	
	@Deprecated
	public GPIOPinConfig(int __a, int __b, int __c, int __d, int __e, boolean
		__f)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPinConfig(String __a, int __b, int __c, int __d, int __e, 
		boolean __f)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getDirection()
	{
		throw new todo.TODO();
	}
	
	public int getDriveMode()
	{
		throw new todo.TODO();
	}
	
	public boolean getInitValue()
	{
		throw new todo.TODO();
	}
	
	public int getPinNumber()
	{
		throw new todo.TODO();
	}
	
	public int getTrigger()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GPIOPinConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public GPIOPinConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDirection(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDriveMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInitValue(boolean __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPinNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setTrigger(int __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.gpio;

import jdk.dio.DevicePermission;

public class GPIOPinPermission
	extends DevicePermission
{
	public static final String SET_DIRECTION =
		"setdirection";
	
	public GPIOPinPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GPIOPinPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.gpio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GPIOPort
	extends Device<GPIOPort>
{
	int INPUT =
		0;
	
	int OUTPUT =
		1;
	
	int getDirection()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	GPIOPin[] getPins();
	
	int getValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setDirection(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setInputListener(PortListener __a)
		throws IOException, ClosedDeviceException;
	
	void setValue(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-gpio/src/main/java/jdk/dio/gpio/GPIOPortConfig.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GPIOPortConfig
	implements DeviceConfig<GPIOPort>
{
	public static final int DIR_BOTH_INIT_INPUT =
		2;
	
	public static final int DIR_BOTH_INIT_OUTPUT =
		3;
	
	public static final int DIR_INPUT_ONLY =
		0;
	
	public static final int DIR_OUTPUT_ONLY =
		1;
	
	public GPIOPortConfig(int __a, int __b, GPIOPinConfig... __c)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getDirection()
	{
		throw new todo.TODO();
	}
	
	public int getInitValue()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig[] getPinConfigs()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin[] getPins()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GPIOPortConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


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

package jdk.dio.gpio;

import jdk.dio.DevicePermission;

public class GPIOPortPermission
	extends DevicePermission
{
	public static final String SET_DIRECTION =
		"setdirection";
	
	public GPIOPortPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GPIOPortPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.gpio;

import jdk.dio.DeviceEvent;

public class PinEvent
	extends DeviceEvent<GPIOPin>
{
	public PinEvent(GPIOPin __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	public PinEvent(GPIOPin __a, boolean __b, long __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public boolean getValue()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-gpio/src/main/java/jdk/dio/gpio/PinListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DeviceEventListener;

public interface PinListener
	extends DeviceEventListener
{
	void valueChanged(PinEvent __a);
}


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

package jdk.dio.gpio;

import jdk.dio.DeviceEvent;

public class PortEvent
	extends DeviceEvent<GPIOPort>
{
	public PortEvent(GPIOPort __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public PortEvent(GPIOPort __a, int __b, long __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-gpio/src/main/java/jdk/dio/gpio/PortListener.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;


public interface PortListener
{
	void valueChanged(PortEvent __a);
}


Added modules/dio-gpio/src/main/java/jdk/dio/gpio/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains generic GPIO interfaces.
 *
 * @since 2016/06/23
 */

package jdk.dio.gpio;

Added modules/dio-i2cbus/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to the I2C bus."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CT"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (I2C)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.i2cbus;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.i2cbus;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface I2CCombinedMessage
{
	I2CCombinedMessage appendRead(I2CDevice __a, ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	I2CCombinedMessage appendRead(I2CDevice __a, int __b, ByteBuffer __c)
		throws IOException, ClosedDeviceException;
	
	I2CCombinedMessage appendWrite(I2CDevice __a, ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	int[] transfer()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-i2cbus/src/main/java/jdk/dio/i2cbus/I2CDevice.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.i2cbus;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface I2CDevice
	extends Device<I2CDevice>, ByteChannel, BufferAccess<ByteBuffer>
{
	I2CDevice.Bus getBus()
		throws IOException;
	
	int read()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(int __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(int __a, int __b, int __c, ByteBuffer __d)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void write(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int write(int __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	interface Bus
	{
		I2CCombinedMessage createCombinedMessage();
	}
}


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

package jdk.dio.i2cbus;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class I2CDeviceConfig
	implements DeviceConfig<I2CDevice>, DeviceConfig.HardwareAddressing
{
	public static final int ADDR_SIZE_10 =
		10;
	
	public static final int ADDR_SIZE_7 =
		7;
	
	@Deprecated
	public I2CDeviceConfig(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public I2CDeviceConfig(String __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getAddress()
	{
		throw new todo.TODO();
	}
	
	public int getAddressSize()
	{
		throw new todo.TODO();
	}
	
	public int getClockFrequency()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static I2CDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public I2CDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setAddress(int __a, int __b)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockFrequency(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.i2cbus;

import jdk.dio.DevicePermission;

public class I2CPermission
	extends DevicePermission
{
	public I2CPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public I2CPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Added modules/dio-i2cbus/src/main/java/jdk/dio/i2cbus/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides interfaces to interact with the I2C bu.
 *
 * @since 2016/06/23
 */

package jdk.dio.i2cbus;

Added modules/dio-mmio/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to memory mapped I/O devices."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DT"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (MMIO)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.mmio;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/AccessOutOfBoundsException.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class AccessOutOfBoundsException
{
}

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

package jdk.dio.mmio;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface MMIODevice
	extends Device<MMIODevice>
{
	RawBlock getAsRawBlock()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	RawBlock getBlock(String __n)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void setMMIOEventListener(int __evid, int __cdx, ByteBuffer __cbuf,
		MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
	
	void setMMIOEventListener(int __evid, MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
	
	void setMMIOEventListener(int __evid, String __cn, MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/MMIODeviceConfig.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIODeviceConfig
{
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/MMIOEvent.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIOEvent
{
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/MMIOEventListener.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

import jdk.dio.DeviceEventListener;

public interface MMIOEventListener
	extends DeviceEventListener
{
	void eventDispatched(MMIOEvent __e);
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/MMIOPermission.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIOPermission
{
}

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

package jdk.dio.mmio;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface RawBlock
	extends RawMemory
{
	ByteBuffer asDirectBuffer()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/RawMemory.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

public interface RawMemory
{
	String getName();
}

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

package jdk.dio.mmio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface RawRegister<T extends Number>
	extends RawMemory
{
	void and(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void clearBit(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void clearBits(T __mask)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	T get()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	Class<T> getType();
	
	boolean isBitSet(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void or(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void set(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void setBit(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void setBits(T __mask)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	void xor(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
}

Added modules/dio-mmio/src/main/java/jdk/dio/mmio/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to memory mapped input and output.
 *
 * @since 2016/06/23
 */

package jdk.dio.mmio;

Added modules/dio-modem/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to dial-up modems."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CY"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (Modems)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.modem;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.modem;

import jdk.dio.Device;
import jdk.dio.DeviceEvent;

public class ModemSignalEvent<P extends Device<? super P>>
	extends DeviceEvent<P>
{
	protected int signalID;
	
	protected boolean signalState;
	
	public ModemSignalEvent(P __a, int __b, boolean __c)
	{
		throw new todo.TODO();
	}
	
	public ModemSignalEvent(P __a, int __b, boolean __c, long __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public int getSignalID()
	{
		throw new todo.TODO();
	}
	
	public boolean getSignalState()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-modem/src/main/java/jdk/dio/modem/ModemSignalListener.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.modem;

import jdk.dio.Device;
import jdk.dio.DeviceEventListener;

public interface ModemSignalListener<P extends Device<? super P>>
	extends DeviceEventListener
{
	void signalStateChanged(ModemSignalEvent<P> __a);
}


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

package jdk.dio.modem;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface ModemSignalsControl<P extends Device<? super P>>
{
	int CTS_SIGNAL =
		32;
	
	int DCD_SIGNAL =
		2;
	
	int DSR_SIGNAL =
		4;
	
	int DTR_SIGNAL =
		1;
	
	int RI_SIGNAL =
		8;
	
	int RTS_SIGNAL =
		16;
	
	boolean getSignalState(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setSignalChangeListener(ModemSignalListener<P> __a, int __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setSignalState(int __a, boolean __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-modem/src/main/java/jdk/dio/modem/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for modems.
 *
 * @since 2016/06/23
 */

package jdk.dio.modem;

Added modules/dio-pwm/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to PWM devices."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DR"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (PWM)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.pwm;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc-compact")
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
	implementation project(":modules:dio-gpio")
}

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

package jdk.dio.pwm;

import jdk.dio.DeviceEvent;

public class GenerationEvent
	extends DeviceEvent<PWMChannel>
{
	public GenerationEvent(PWMChannel __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public GenerationEvent(PWMChannel __a, int __b, long __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int getPulseCount()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.pwm;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface GenerationListener
	extends DeviceEventListener, AsyncErrorHandler<PWMChannel>
{
	void failed(Throwable __a, PWMChannel __b);
	
	void pulseGenerationCompleted(GenerationEvent __a);
}


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

package jdk.dio.pwm;

import java.nio.IntBuffer;
import jdk.dio.OutputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface GenerationRoundListener
	extends OutputRoundListener<PWMChannel, IntBuffer>
{
	void failed(Throwable __a, PWMChannel __b);
	
	void outputRoundCompleted(RoundCompletionEvent<PWMChannel, IntBuffer> __a);
}


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

package jdk.dio.pwm;


public class InvalidPulseRateException
	extends RuntimeException
{
	public InvalidPulseRateException()
	{
		throw new todo.TODO();
	}
	
	public InvalidPulseRateException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio-pwm/src/main/java/jdk/dio/pwm/PWMChannel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;
import jdk.dio.gpio.GPIOPin;

public interface PWMChannel
	extends Device<PWMChannel>, BufferAccess<IntBuffer>
{
	void generate(int __a, int __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void generate(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int getMaxPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getMinPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	GPIOPin getOutput();
	
	int getPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setPulsePeriod(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startGeneration(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startGeneration(int __a, int __b, GenerationListener __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startGeneration(IntBuffer __a, GenerationRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void startGeneration(IntBuffer __a, IntBuffer __b,
		GenerationRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void stopGeneration()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-pwm/src/main/java/jdk/dio/pwm/PWMChannelConfig.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
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
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.gpio.GPIOPinConfig;

public final class PWMChannelConfig
	implements DeviceConfig<PWMChannel>, DeviceConfig.HardwareAddressing
{
	public static final int ALIGN_CENTER =
		0;
	
	public static final int ALIGN_LEFT =
		1;
	
	public static final int ALIGN_RIGHT =
		2;
	
	public static final int IDLE_STATE_HIGH =
		0;
	
	public static final int IDLE_STATE_LOW =
		1;
	
	@Deprecated
	public PWMChannelConfig(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(int __a, int __b, int __c, int __d, int __e, 
		GPIOPinConfig __f)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(String __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(String __a, int __b, int __c, int __d, int __e, 
		GPIOPinConfig __f)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getIdleState()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin getOutput()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig getOutputConfig()
	{
		throw new todo.TODO();
	}
	
	public int getPulseAlignment()
	{
		throw new todo.TODO();
	}
	
	public int getPulsePeriod()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static PWMChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public PWMChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setIdleState(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputConfig(GPIOPinConfig __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPulseAlignment(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPulsePeriod(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.pwm;

import jdk.dio.DevicePermission;

public class PWMPermission
	extends DevicePermission
{
	public PWMPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public PWMPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Added modules/dio-pwm/src/main/java/jdk/dio/pwm/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to PWM devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.pwm;

Added modules/dio-spibus/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to the SPI bus."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CU"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (SPI)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.spibus;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.spibus;


public class InvalidWordLengthException
	extends RuntimeException
{
	public InvalidWordLengthException()
	{
		throw new todo.TODO();
	}
	
	public InvalidWordLengthException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio.spibus;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface SPICompositeMessage
{
	SPICompositeMessage appendDelay(int __a)
		throws IOException, ClosedDeviceException;
	
	SPICompositeMessage appendRead(ByteBuffer __a)
		throws IOException, ClosedDeviceException;
	
	SPICompositeMessage appendRead(int __a, ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	SPICompositeMessage appendWrite(ByteBuffer __a)
		throws IOException, ClosedDeviceException;
	
	SPICompositeMessage appendWriteAndRead(ByteBuffer __a, ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	SPICompositeMessage appendWriteAndRead(ByteBuffer __a, int __b,
		ByteBuffer __c)
		throws IOException, ClosedDeviceException;
	
	SPIDevice getTargetedDevice();
	
	int[] transfer()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


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

package jdk.dio.spibus;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface SPIDevice
	extends Device<SPIDevice>, ByteChannel, BufferAccess<ByteBuffer>
{
	SPICompositeMessage createCompositeMessage();
	
	int getWordLength()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	void write(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int writeAndRead(ByteBuffer __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int writeAndRead(ByteBuffer __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	int writeAndRead(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-spibus/src/main/java/jdk/dio/spibus/SPIDeviceConfig.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
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
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class SPIDeviceConfig
	implements DeviceConfig<SPIDevice>, DeviceConfig.HardwareAddressing
{
	public static final int CS_ACTIVE_HIGH =
		0;
	
	public static final int CS_ACTIVE_LOW =
		1;
	
	public static final int CS_NOT_CONTROLLED =
		2;
	
	@Deprecated
	public SPIDeviceConfig(int __a, int __b, int __c, int __d, int __e, int 
		__f)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(int __a, int __b, int __c, int __d, int __e, int 
		__f, int __g)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(String __a, int __b, int __c, int __d, int __e, 
		int __f)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(String __a, int __b, int __c, int __d, int __e, 
		int __f, int __g)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getAddress()
	{
		throw new todo.TODO();
	}
	
	public int getBitOrdering()
	{
		throw new todo.TODO();
	}
	
	public int getCSActiveLevel()
	{
		throw new todo.TODO();
	}
	
	public int getClockFrequency()
	{
		throw new todo.TODO();
	}
	
	public int getClockMode()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getWordLength()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SPIDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public SPIDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setAddress(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setBitOrdering(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setCSActiveLevel(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockFrequency(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setWordLength(int __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.spibus;

import jdk.dio.DevicePermission;

public class SPIPermission
	extends DevicePermission
{
	public SPIPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public SPIPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Added modules/dio-spibus/src/main/java/jdk/dio/spibus/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to the SPI Bus.
 *
 * @since 2016/06/23
 */

package jdk.dio.spibus;

Added modules/dio-uart/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to serial UARTs."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CX"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (UART)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.uart;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc-compact")
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
	implementation project(":modules:dio-modem")
}

Added modules/dio-uart/src/main/java/jdk/dio/uart/ModemUART.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.modem.ModemSignalsControl;

public interface ModemUART
	extends UART, ModemSignalsControl<ModemUART>
{
}


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

package jdk.dio.uart;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.InputRoundListener;
import jdk.dio.OutputRoundListener;
import jdk.dio.UnavailableDeviceException;

public interface UART
	extends Device<UART>, ByteChannel, BufferAccess<ByteBuffer>
{
	void generateBreak(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getBaudRate()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getDataBits()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getFlowControlMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getParity()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getReceiveTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getReceiveTriggerLevel()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int getStopBits()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setBaudRate(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setDataBits(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setEventListener(int __a, UARTEventListener __b)
		throws IOException, ClosedDeviceException;
	
	void setFlowControlMode(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setParity(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setReceiveTimeout(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setReceiveTriggerLevel(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void setStopBits(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startReading(ByteBuffer __a,
	 InputRoundListener<UART, ByteBuffer> __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startReading(ByteBuffer __a, ByteBuffer __b,
		InputRoundListener<UART, ByteBuffer> __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startWriting(ByteBuffer __a,
		OutputRoundListener<UART, ByteBuffer> __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void startWriting(ByteBuffer __a, ByteBuffer __b,
		OutputRoundListener<UART, ByteBuffer> __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stopReading()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stopWriting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-uart/src/main/java/jdk/dio/uart/UARTConfig.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class UARTConfig
	implements DeviceConfig<UART>, DeviceConfig.HardwareAddressing
{
	public static final int DATABITS_5 =
		5;
	
	public static final int DATABITS_6 =
		6;
	
	public static final int DATABITS_7 =
		7;
	
	public static final int DATABITS_8 =
		8;
	
	public static final int DATABITS_9 =
		9;
	
	public static final int FLOWCONTROL_NONE =
		0;
	
	public static final int FLOWCONTROL_RTSCTS_IN =
		1;
	
	public static final int FLOWCONTROL_RTSCTS_OUT =
		2;
	
	public static final int FLOWCONTROL_XONXOFF_IN =
		4;
	
	public static final int FLOWCONTROL_XONXOFF_OUT =
		8;
	
	public static final int PARITY_EVEN =
		2;
	
	public static final int PARITY_MARK =
		3;
	
	public static final int PARITY_NONE =
		0;
	
	public static final int PARITY_ODD =
		1;
	
	public static final int PARITY_SPACE =
		4;
	
	public static final int STOPBITS_1 =
		1;
	
	public static final int STOPBITS_1_5 =
		2;
	
	public static final int STOPBITS_2 =
		3;
	
	@Deprecated
	public UARTConfig(int __a, int __b, int __c, int __d, int __e, int __f, 
		int __g)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(int __a, int __b, int __c, int __d, int __e, int __f, 
		int __g, int __h, int __i)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(String __a, int __b, int __c, int __d, int __e, int __f
		, int __g)
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(String __a, int __b, int __c, int __d, int __e, int __f
		, int __g, int __h, int __i)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getBaudRate()
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getDataBits()
	{
		throw new todo.TODO();
	}
	
	public int getFlowControlMode()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getParity()
	{
		throw new todo.TODO();
	}
	
	public int getStopBits()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static UARTConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			throw new todo.TODO();
		}
		
		public UARTConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setBaudRate(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDataBits(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setFlowControlMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setParity(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setStopBits(int __a)
		{
			throw new todo.TODO();
		}
	}
}


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

package jdk.dio.uart;

import jdk.dio.DeviceEvent;

public class UARTEvent
	extends DeviceEvent<UART>
{
	public static final int BREAK_INTERRUPT =
		4;
	
	public static final int FRAMING_ERROR =
		16;
	
	public static final int INPUT_BUFFER_OVERRUN =
		1;
	
	public static final int INPUT_DATA_AVAILABLE =
		0;
	
	public static final int OUTPUT_BUFFER_EMPTY =
		2;
	
	public static final int PARITY_ERROR =
		8;
	
	public UARTEvent(UART __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public UARTEvent(UART __a, int __b, long __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
}


Added modules/dio-uart/src/main/java/jdk/dio/uart/UARTEventListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.DeviceEventListener;

public interface UARTEventListener
	extends DeviceEventListener
{
	void eventDispatched(UARTEvent __a);
}


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

package jdk.dio.uart;

import jdk.dio.DevicePermission;

public class UARTPermission
	extends DevicePermission
{
	public UARTPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public UARTPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Added modules/dio-uart/src/main/java/jdk/dio/uart/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to UARTs.
 *
 * @since 2016/06/23
 */

package jdk.dio.uart;

Added modules/dio-watchdog/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides access to the watchdog."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DP"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O (Watchdog)"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio.watchdog;;1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:dio")
}

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

package jdk.dio.watchdog;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface WatchdogTimer
	extends Device<WatchdogTimer>
{
	boolean causedLastReboot()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	long getMaxTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	long getTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void refresh()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void start(long __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	void stop()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Added modules/dio-watchdog/src/main/java/jdk/dio/watchdog/WatchdogTimerConfig.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.watchdog;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class WatchdogTimerConfig
	implements DeviceConfig<WatchdogTimer>, DeviceConfig.HardwareAddressing
{
	public WatchdogTimerConfig(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public WatchdogTimerConfig(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getTimerNumber()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static WatchdogTimerConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


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

package jdk.dio.watchdog;

import jdk.dio.DevicePermission;

public class WatchdogTimerPermission
	extends DevicePermission
{
	public WatchdogTimerPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public WatchdogTimerPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


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

package jdk.dio.watchdog;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;

public interface WindowedWatchdogTimer
	extends WatchdogTimer
{
	long getClosedWindowTimeout()
		throws IOException, ClosedDeviceException;
	
	void start(long __a)
		throws IOException, ClosedDeviceException;
	
	void start(long __a, long __b)
		throws IOException, ClosedDeviceException;
}


Added modules/dio-watchdog/src/main/java/jdk/dio/watchdog/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to watchdog interfaces.
 *
 * @since 2016/06/23
 */

package jdk.dio.watchdog;

Added modules/dio/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides the base support for devices " +
	"that may be provided by an implementation."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CR"
	swmType = JavaMEMidletType.API
	swmName = "JavaME 8 Device I/O"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("dio", null, "1.0.1")
}

dependencies
{
	implementation project(":modules:cldc")
}

Added modules/dio/src/main/java/jdk/dio/AsyncErrorHandler.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

public interface AsyncErrorHandler<P extends Device<? super P>>
{
	void failed(Throwable __a, P __b);
}


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

package jdk.dio;

import java.io.IOException;
import java.nio.Buffer;
import java.nio.ByteBuffer;

public interface BufferAccess<B extends Buffer>
{
	B getInputBuffer()
		throws ClosedDeviceException, IOException;
	
	B getOutputBuffer()
		throws ClosedDeviceException, IOException;
	
	B prepareBuffer(ByteBuffer __a, int __b)
		throws IOException, ClosedDeviceException;
}


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

package jdk.dio;

import java.nio.channels.ClosedChannelException;

public class ClosedDeviceException
	extends ClosedChannelException
{
	public ClosedDeviceException()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;

import java.io.IOException;
import java.nio.ByteOrder;
import java.nio.channels.Channel;

public interface Device<P extends Device<? super P>>
	extends Channel
{
	int BIG_ENDIAN =
		1;
	
	int LITTLE_ENDIAN =
		0;
	
	int MIXED_ENDIAN =
		2;
	
	void close()
		throws IOException;
	
	ByteOrder getByteOrder()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	<U extends P> DeviceDescriptor<U> getDescriptor();
	
	boolean isOpen();
	
	void tryLock(int __a)
		throws UnavailableDeviceException, ClosedDeviceException, 
			IOException;
	
	void unlock()
		throws IOException;
}


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

package jdk.dio;


public class DeviceAlreadyExistsException
	extends DeviceException
{
	public DeviceAlreadyExistsException()
	{
		throw new todo.TODO();
	}
	
	public DeviceAlreadyExistsException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;

import java.io.IOException;
import java.io.OutputStream;

public interface DeviceConfig<P extends Device<? super P>>
{
	@Deprecated
	int DEFAULT =
		-1;
	
	int UNASSIGNED =
		-1;
	
	int serialize(OutputStream __a)
		throws IOException;
	
	interface HardwareAddressing
	{
		String getControllerName();
		
		int getControllerNumber();
	}
}


Added modules/dio/src/main/java/jdk/dio/DeviceDescriptor.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public interface DeviceDescriptor<P extends Device<? super P>>
{
	int UNDEFINED_ID =
		-1;
	
	<C extends DeviceConfig<? super P>> C getConfiguration();
	
	int getID();
	
	Class<P> getInterface();
	
	String getName();
	
	String[] getProperties();
}


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

package jdk.dio;


public abstract class DeviceEvent<P extends Device<? super P>>
{
	protected int count;
	
	protected P device;
	
	protected long lastTimeStamp;
	
	protected int lastTimeStampMicros;
	
	protected long timeStamp;
	
	protected int timeStampMicros;
	
	public DeviceEvent()
	{
		throw new todo.TODO();
	}
	
	public final int getCount()
	{
		throw new todo.TODO();
	}
	
	public final P getDevice()
	{
		throw new todo.TODO();
	}
	
	public final long getLastTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public final int getLastTimeStampMicros()
	{
		throw new todo.TODO();
	}
	
	public final long getTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public final int getTimeStampMicros()
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/DeviceEventListener.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public interface DeviceEventListener
{
}


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

package jdk.dio;

import java.io.IOException;

public class DeviceException
	extends IOException
{
	public DeviceException()
	{
		throw new todo.TODO();
	}
	
	public DeviceException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/DeviceManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;
import java.util.Iterator;

public class DeviceManager
{
	public static final int EXCLUSIVE =
		1;
	
	public static final int SHARED =
		2;
	
	public static final int UNSPECIFIED_ID =
		-1;
	
	private DeviceManager()
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> void addRegistrationListener(
		RegistrationListener<P> __a, Class<P> __b)
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> Iterator<DeviceDescriptor<P>>
		list()
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> Iterator<DeviceDescriptor<P>>
		list(Class<P> __a)
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(Class<P> __a, 
		DeviceConfig<? super P> __b)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(Class<P> __a, 
		DeviceConfig<? super P> __b, int __c)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a)
		throws IOException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, Class<P> __b)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, Class<P> __b,
		int __c)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException, 
			UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, int __b)
		throws IOException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(DeviceConfig<? super P
		> __a)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(DeviceConfig<? super P
		> __a, int __b)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(String __a, Class<P> 
		__b, int __c, String... __d)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException, 
			UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(String __a, Class<P> 
		__b, String... __c)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> int register(int __a, Class<P
		> __b, DeviceConfig<? super P> __c, String __d, String... __e)
		throws IOException, UnsupportedDeviceTypeException, 
			InvalidDeviceConfigException, DeviceNotFoundException, 
			DeviceAlreadyExistsException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new DeviceAlreadyExistsException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> void 
		removeRegistrationListener(RegistrationListener<P> __a, Class<P> __b)
	{
		throw new todo.TODO();
	}
	
	public static void unregister(int __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;

import java.security.Permission;
import java.security.PermissionCollection;

public class DeviceMgmtPermission
	extends Permission
{
	public static final String OPEN =
		"open";
	
	public static final String REGISTER =
		"register";
	
	public static final String UNREGISTER =
		"unregister";
	
	public DeviceMgmtPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;


public class DeviceNotFoundException
	extends DeviceException
{
	public DeviceNotFoundException()
	{
		throw new todo.TODO();
	}
	
	public DeviceNotFoundException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/DevicePermission.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
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.security.Permission;
import java.security.PermissionCollection;

public abstract class DevicePermission
	extends Permission
{
	public static final String OPEN =
		"open";
	
	public static final String POWER_MANAGE =
		"powermanage";
	
	public DevicePermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public DevicePermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/InputRoundListener.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.Buffer;

public interface InputRoundListener<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEventListener, AsyncErrorHandler<P>
{
	void inputRoundCompleted(RoundCompletionEvent<P, B> __a);
}


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

package jdk.dio;


public class InvalidDeviceConfigException
	extends DeviceException
{
	public InvalidDeviceConfigException()
	{
		throw new todo.TODO();
	}
	
	public InvalidDeviceConfigException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/OutputRoundListener.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.Buffer;

public interface OutputRoundListener<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEventListener, AsyncErrorHandler<P>
{
	void outputRoundCompleted(RoundCompletionEvent<P, B> __a);
}


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

package jdk.dio;

import java.util.EventObject;

public class RegistrationEvent<P extends Device<? super P>>
	extends EventObject
{
	public RegistrationEvent(String __a, DeviceDescriptor<P> __b)
	{
		super((Object)null);
		throw new todo.TODO();
	}
	
	public RegistrationEvent(DeviceDescriptor<P> __a)
	{
		super((Object)null);
		throw new todo.TODO();
	}
	
	public DeviceDescriptor<P> getDescriptor()
	{
		throw new todo.TODO();
	}
	
	public String getInitiator()
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/RegistrationListener.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.util.EventListener;

public interface RegistrationListener<P extends Device<? super P>>
	extends EventListener
{
	void deviceRegistered(RegistrationEvent<P> __a);
	
	void deviceUnregistered(RegistrationEvent<P> __a);
}


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

package jdk.dio;

import java.nio.Buffer;

public class RoundCompletionEvent<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEvent<P>
{
	public RoundCompletionEvent(P __a, B __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, long __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, boolean __d)
	{
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, boolean __d, long __e,
		int __f)
	{
		throw new todo.TODO();
	}
	
	public B getBuffer()
	{
		throw new todo.TODO();
	}
	
	public int getNumber()
	{
		throw new todo.TODO();
	}
	
	public boolean isOnError()
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;

import java.io.IOException;

public interface Transactional
{
	void begin()
		throws ClosedDeviceException, IOException;
	
	void end()
		throws ClosedDeviceException, IOException;
}


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

package jdk.dio;


public class UnavailableDeviceException
	extends DeviceException
{
	public UnavailableDeviceException()
	{
		throw new todo.TODO();
	}
	
	public UnavailableDeviceException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;


public class UnsupportedAccessModeException
	extends DeviceException
{
	public UnsupportedAccessModeException()
	{
		throw new todo.TODO();
	}
	
	public UnsupportedAccessModeException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;


public class UnsupportedByteOrderException
	extends DeviceException
{
	public UnsupportedByteOrderException()
	{
		throw new todo.TODO();
	}
	
	public UnsupportedByteOrderException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package jdk.dio;


public class UnsupportedDeviceTypeException
	extends DeviceException
{
	public UnsupportedDeviceTypeException()
	{
		throw new todo.TODO();
	}
	
	public UnsupportedDeviceTypeException(String __a)
	{
		throw new todo.TODO();
	}
}


Added modules/dio/src/main/java/jdk/dio/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the base package for the device I/O support.
 *
 * @since 2016/06/23
 */

package jdk.dio;

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

package jdk.dio.power;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;

public interface PowerManaged
{
	int LOWEST_POWER =
		4;
	
	int LOW_POWER =
		2;
	
	int POWER_OFF =
		8;
	
	int POWER_ON =
		1;
	
	long UNLIMITED_DURATION =
		-1L;
	
	void disablePowerSaving()
		throws IOException, ClosedDeviceException;
	
	void enablePowerSaving(int __a)
		throws IOException, ClosedDeviceException;
	
	void enablePowerSaving(int __a, PowerSavingHandler __b)
		throws IOException, ClosedDeviceException;
	
	PowerManaged.Group getGroup()
		throws IOException, ClosedDeviceException;
	
	int getPowerState()
		throws IOException, ClosedDeviceException;
	
	long requestPowerStateChange(int __a, long __b)
		throws IOException, ClosedDeviceException;
	
	interface Group
	{
		boolean contains(PowerManaged __a)
			throws IOException, ClosedDeviceException;
		
		void setPowerSavingHandler(PowerSavingHandler __a)
			throws IOException, ClosedDeviceException;
	}
}


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

package jdk.dio.power;

import jdk.dio.Device;

public interface PowerSavingHandler
{
	<P extends Device<? super P>> void handlePowerStateChange(P __a,
		PowerManaged.Group __b, int __c, int __d, long __e);
	
	<P extends Device<? super P>> long
		handlePowerStateChangeRequest(P __a, PowerManaged.Group __b, int __c,
		int __d, long __e);
}


Added modules/dio/src/main/java/jdk/dio/power/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains interfaces related to power management of devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.power;

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

package jdk.dio.spi;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.DeviceDescriptor;
import jdk.dio.UnavailableDeviceException;

public abstract class AbstractDevice<P extends Device<? super P>>
	implements Device<P>
{
	public AbstractDevice()
	{
		throw new todo.TODO();
	}
	
	public final <U extends P> DeviceDescriptor<U> getDescriptor()
	{
		throw new todo.TODO();
	}
	
	public void tryLock(int __a)
		throws UnavailableDeviceException, ClosedDeviceException, 
			IOException
	{
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new ClosedDeviceException();
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void unlock()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


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

package jdk.dio.spi;

import java.io.IOException;
import java.io.InputStream;
import jdk.dio.Device;
import jdk.dio.DeviceConfig;
import jdk.dio.DeviceNotFoundException;
import jdk.dio.InvalidDeviceConfigException;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedAccessModeException;

public interface DeviceProvider<P extends Device<? super P>>
{
	DeviceConfig<? super P> deserialize(InputStream __a)
		throws IOException;
	
	Class<? extends DeviceConfig<? super P>> getConfigType();
	
	Class<P> getType();
	
	boolean matches(String[] __a);
	
	AbstractDevice<? super P> open(DeviceConfig<? super P> __a, String[] __b,
		int __c)
		throws DeviceNotFoundException, UnavailableDeviceException, 
			InvalidDeviceConfigException, UnsupportedAccessModeException, 
			IOException;
}


Added modules/dio/src/main/java/jdk/dio/spi/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides service management support for devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.spi;

Added modules/gcf/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This projects contains the Generic " +
	"connection framework which is used to create connections to other " +
	"resources."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EC"
	swmType = JavaMEMidletType.API
	swmName = "Generic Connection Framework"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-midlet")
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/ConnectionStateTracker.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This is a tracker for the connection state.
 *
 * @since 2019/05/13
 */
public final class ConnectionStateTracker
{
	/** Has the input been closed? */
	boolean _inclosed;
	
	/** Has the output been closed? */
	boolean _outclosed;
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/FileAddress.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This is an address which represents a file.
 *
 * @since 2019/05/06
 */
public final class FileAddress
	implements SocketAddress
{
	/** The file. */
	public final String file;
	
	/**
	 * Initializes the file address.
	 *
	 * @param __p The file path.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public FileAddress(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Decode the path
		this.file = FileAddress.stringDecode(__p);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final String toString()
	{
		return this.file;
	}
	
	/**
	 * Decodes the specified string to handle the path.
	 *
	 * @param __p The path.
	 * @return The decoded path.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final String stringDecode(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Build new decoded path
		StringBuilder sb = new StringBuilder();
		for (int i = 0, n = __p.length(); i < n;)
		{
			int c = __p.charAt(i++);
			
			// Potentially condense slashes
			if (c == '/')
			{
				// Do not condense
				int sbl = sb.length();
				if (sbl > 0 && sb.charAt(sbl - 1) == '/')
					continue;
				
				// Add slash
				sb.append('/');
			}
			
			// Percent encoded
			else if (c == '%')
			{
				throw new todo.TODO();
			}
			
			// Directly usable
			else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
				(c >= '0' && c <= '9') || c == ':' || c == '@' || c == '-' ||
				c == '.' || c == '_' || c == '~' || c == '!' || c == '$' ||
				c == '&' || c == '\'' || c == '(' || c == ')' || c == '*' ||
				c == '+' || c == ',' || c == ';' || c == '=')
				sb.append((char)c);
			
			// {@squirreljme.error EC01 Path contains invalid character.
			// (The path)}
			else
				throw new IllegalArgumentException("EC01 " + __p);
		}
		
		// Done
		return sb.toString();
	}
	
	/**
	 * Decodes and build the file address.
	 *
	 * @param __p The string address.
	 * @return The resulting file address.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final FileAddress of(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return new FileAddress(__p);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPAddress.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This represents an IP address.
 *
 * @since 2019/05/06
 */
public final class HTTPAddress
	implements SocketAddress
{
	/** The IP Address. */
	public final IPAddress ipaddr;
	
	/** The file. */
	public final FileAddress file;
	
	/** The query. */
	public final String query;
	
	/** The fragment. */
	public final String fragment;
	
	/**
	 * Initializes the HTTP Address.
	 *
	 * @param __ip The IP address.
	 * @param __file The file.
	 * @param __query The query, may be {@code null}.
	 * @param __frag The fragment, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public HTTPAddress(IPAddress __ip, FileAddress __file, String __query,
		String __frag)
		throws NullPointerException
	{
		if (__ip == null || __file == null)
			throw new NullPointerException("NARG");
		
		this.ipaddr = __ip;
		this.file = __file;
		this.query = __query;
		this.fragment = __frag;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Decodes an address from the URI part.
	 *
	 * @param __p The part to decode from.
	 * @return The HTTP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final HTTPAddress fromUriPart(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EC02 HTTP address must start with double
		// slash. (The URI part)}
		if (!__p.startsWith("//"))
			throw new IllegalArgumentException("EC02 " + __p);
		__p = __p.substring(2);
		
		// Debug
		todo.DEBUG.note("Decode %s", __p);
		
		// Only contains the host part
		int sl = __p.indexOf('/');
		if (sl < 0)
			return new HTTPAddress(IPAddress.of(__p), FileAddress.of("/"),
				null, null);
		
		// Parse host portion
		IPAddress ipaddr = IPAddress.of(__p.substring(0, sl));
		
		// Parse remaining part, but keep the slash
		__p = __p.substring(sl);
		
		// Parse fragment
		String fragment;
		int fl = __p.indexOf('#');
		if (fl >= 0)
			throw new todo.TODO();
		
		// No fragment used
		else
			fragment = null;
		
		// Parse query
		String query;
		int ql = __p.indexOf('?');
		if (ql >= 0)
			throw new todo.TODO();
		
		// No query used
		else
			query = null;
		
		// Build remaining address
		return new HTTPAddress(ipaddr, FileAddress.of(__p), query, fragment);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPAgent.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.SocketConnection;

/**
 * This class manages the HTTP connection data and is able to encode and
 * establish a connection.
 *
 * @since 2019/05/13
 */
public final class HTTPAgent
	implements HTTPSignalListener
{
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** The state tracker. */
	protected final HTTPStateTracker tracker;
	
	/** The HTTP response. */
	HTTPResponse _response;
	
	/**
	 * Initializes the HTTP agent.
	 *
	 * @param __addr The address.
	 * @param __t The state tracker.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPAgent(HTTPAddress __addr, HTTPStateTracker __t)
		throws NullPointerException
	{
		if (__addr == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.address = __addr;
		this.tracker = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void requestReady(byte[] __data)
		throws IOException, NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Debug
		todo.DEBUG.note(" -> %d", __data.length);
		
		// Open connection to remote server
		byte[] response;
		try (SocketConnection socket = (SocketConnection)Connector.open(
			"socket://" + this.address.ipaddr))
		{
			// Connect to remote system and send all the HTTP data and
			// read it as well
			try (OutputStream out = socket.openOutputStream();
				InputStream in = socket.openInputStream())
			{
				// Write and send data
				out.write(__data, 0, __data.length);
				out.flush();
				
				// Read response data
				try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
					Math.max(1024, in.available())))
				{
					// Copy all input data
					byte[] buf = new byte[512];
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
					
					// Store for later decode
					response = baos.toByteArray();
				}
			}
		}
		
		// Failed read/write
		catch (IOException e)
		{
			// Debug
			e.printStackTrace();
			
			throw e;
		}
		
		// Parse the input
		this._response = HTTPResponse.parse(response);
		
		// Enter the connected state
		this.tracker._state = HTTPState.CONNECTED;
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPClientConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.HttpConnection;

/**
 * This is a connection to a remote HTTP server, this runs off an existing
 * socket since it may be SSL encrypted. SquirrelJME does all the HTTP
 * handling since it could just be based on any existing stream connection
 * and does not need any other library.
 *
 * @since 2019/05/06
 */
public class HTTPClientConnection
	implements HttpConnection
{
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** Tracker for the HTTP state. */
	protected final HTTPStateTracker tracker =
		new HTTPStateTracker();
	
	/** The target HTTP agent which contains the response. */
	protected final HTTPAgent agent;
	
	/** Request builder for outgoing connections. */
	private HTTPRequestBuilder _request;
	
	/**
	 * Initializes the HTTP connection.
	 *
	 * @param __addr The address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public HTTPClientConnection(HTTPAddress __addr)
		throws NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		this.address = __addr;
		
		// Setup agents and handlers
		HTTPStateTracker tracker = this.tracker;
		HTTPAgent agent = new HTTPAgent(__addr, tracker);
		this.agent = agent;
		
		// Setup builder for the requests
		this._request = new HTTPRequestBuilder(__addr, tracker, agent);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Transition to the closed state
		this.tracker._state = HTTPState.CLOSED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final AccessPoint getAccessPoint()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getDate()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getEncoding()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getExpiration()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getFile()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderField(String __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderField(int __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getHeaderFieldDate(String __a, long __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getHeaderFieldInt(String __a, int __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderFieldKey(int __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHost()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getLastModified()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getLength()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getPort()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getProtocol()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getQuery()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRef()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRequestMethod()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRequestProperty(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getResponseCode()
		throws IOException
	{
		return this.__response().header.code;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getResponseMessage()
		throws IOException
	{
		return this.__response().header.message;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getType()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getURL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataInputStream openDataInputStream()
		throws IOException
	{
		return new DataInputStream(this.openInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataOutputStream openDataOutputStream()
		throws IOException
	{
		return new DataOutputStream(this.openOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final InputStream openInputStream()
		throws IOException
	{
		// The response is the direct stream of the body
		return this.__response().inputStream();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final OutputStream openOutputStream()
		throws IOException
	{
		// This is the request stream directly
		return this.__request();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setRequestMethod(String __m)
		throws IOException, NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.__request().setRequestMethod(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setRequestProperty(String __k, String __v)
		throws IOException, NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.__request().setRequestProperty(__k, __v);
	}
	
	/**
	 * Attempts to obtain the request.
	 *
	 * @return The request information.
	 * @throws IOException If the connection was closed or is in connected
	 * state.
	 * @since 2019/05/13
	 */
	private final HTTPRequestBuilder __request()
		throws IOException
	{
		// {@squirreljme.error EC03 Cannot access the request
		if (this.tracker._state != HTTPState.SETUP)
		{
			// Clear before it is thrown
			this._request = null;
			
			// Toss
			throw new IOException("EC03");
		}
		
		// Return the request value
		return this._request;
	}
	
	/**
	 * Returns the response.
	 *
	 * @return The response.
	 * @throws IOException If the response could not be returned.
	 * @since 2019/05/13
	 */
	private HTTPResponse __response()
		throws IOException
	{
		HTTPAgent agent = this.agent;
		
		// Depends on the state
		HTTPStateTracker tracker = this.tracker;
		switch (tracker._state)
		{
				// Need to connect to the server, fall through to get the
				// agent response. Closing the request will send the HTTP
				// data over and load the server response
			case SETUP:
				this.__request().close();
			
				// Agent already has the response
			case CONNECTED:
			case CLOSED:
				return agent._response;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Connects to the given address using the given stream.
	 *
	 * @param __addr The address.
	 * @return The open connection.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final HTTPClientConnection connect(HTTPAddress __addr)
		throws NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		return new HTTPClientConnection(__addr);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPRequestBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This is used for building HTTP requests which will build the request to use
 * for the server.
 *
 * @since 2019/05/12
 */
public final class HTTPRequestBuilder
	extends OutputStream
{
	/** The user agent SquirrelJME uses. */
	public static final String USER_AGENT =
		"SquirrelJME/" + SquirrelJME.RUNTIME_VERSION + " " +
		"Configuration/CLDC-1.0 Configuration/CLDC-1.1 " +
		"Configuration/CLDC-1.8 Profile/MIDP-1.0 Profile/MIDP-2.0 " +
		"Profile/MIDP-2.1 Profile/MIDP-3.0 Profile/MEEP-8.0";
	
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** The listener when the connection is closed. */
	protected final HTTPSignalListener listener;
	
	/** State tracker for connections. */
	protected final HTTPStateTracker tracker;
	
	/** Byte data output. */
	private final ByteArrayOutputStream _bytes =
		new ByteArrayOutputStream();
	
	/** Request properties. */
	private final Map<String, String> _rqprops =
		new LinkedHashMap<>();
	
	/** The connection method. */
	private String _rqmethod =
		"GET";
	
	/**
	 * Initializes the request builder.
	 *
	 * @param __addr The remote address.
	 * @param __st State tracker for HTTP connections.
	 * @param __l The agent listener.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPRequestBuilder(HTTPAddress __addr, HTTPStateTracker __st,
		HTTPSignalListener __l)
		throws NullPointerException
	{
		if (__l == null || __st == null || __addr == null)
			throw new NullPointerException("NARG");
		
		this.listener = __l;
		this.tracker = __st;
		this.address = __addr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Only close once
		if (this.tracker._state != HTTPState.SETUP)
			return;
		
		// Send the agent out request bytes
		this.listener.requestReady(this.getBytes());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// {@squirreljme.error EC04 Cannot flush closed HTTP stream.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC04");
		
		// Note
		todo.TODO.note("Implement HTTP Flush");
	}
	
	/**
	 * Builds the bytes for the request.
	 *
	 * @return The bytes to send down the stream.
	 * @throws IOException If they could not be set.
	 * @since 2019/05/13
	 */
	public final byte[] getBytes()
		throws IOException
	{
		HTTPAddress address = this.address;
		
		// Build output
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Get any written data
			byte[] bytes = this._bytes.toByteArray();
			
			// Print header data, note that CRLF is used everywhere regardless
			// of whether the system uses it or not
			try (PrintStream ps = new PrintStream(baos, true, "utf-8"))
			{
				// HTTP header
				ps.printf("%s %s HTTP/1.1\r\n",
					this._rqmethod, address.file);
				
				// Add some implicit properties
				Map<String, String> rqp = new LinkedHashMap<>(this._rqprops);
				rqp.put("host", address.ipaddr.hostname);
				
				// If the user agent was specified, add to it or set one
				String ua = rqp.get("user-agent");
				rqp.put("user-agent", (ua == null ?
					HTTPRequestBuilder.USER_AGENT :
					ua + HTTPRequestBuilder.USER_AGENT));
				
				// Is content being specified?
				if (bytes != null)
					rqp.put("content-length", Integer.toString(bytes.length));
				
				// Write headers
				for (Map.Entry<String, String> e : rqp.entrySet())
					ps.printf("%s: %s\r\n", e.getKey(), e.getValue());
				
				// End of header
				ps.print("\r\n");
				
				// Flush to make sure nothing is buffered
				ps.flush();
			}
			
			// Write any data
			if (bytes != null)
				baos.write(bytes, 0, bytes.length);
			
			// Build
			return baos.toByteArray();
		}
	}
	
	/**
	 * Sets the request method to use.
	 *
	 * @param __m The method to use.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If no method was specified.
	 * @since 2019/05/13
	 */
	public final void setRequestMethod(String __m)
		throws IOException, NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._rqmethod = __m.toUpperCase();
	}
	
	/**
	 * Adds or replaces an existing request property, note that for multiple
	 * request property specifications they need to manually be comma
	 * separated.
	 *
	 * @param __k The request header key.
	 * @param __v The value to use, {@code null} clears.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If the key was null.
	 * @since 2019/05/13
	 */
	public final void setRequestProperty(String __k, String __v)
		throws IOException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// All fields are case insensitive, so lowercase them!
		__k = __k.toLowerCase();
		
		// Clear?
		Map<String, String> rqprops = this._rqprops;
		if (__v == null)
			rqprops.remove(__k);
		
		// Otherwise add
		else
			rqprops.put(__k, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error EC05 Cannot write more HTTP data.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC05");
		
		// Write to bytes
		this._bytes.write(__b);
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __a)
		throws IOException, NullPointerException
	{
		this.write(__a, 0, __a.length);
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void write(byte[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error EC06 Cannot write more HTTP data.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC06");
		
		// Write to bytes
		this._bytes.write(__a, __o, __l);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPResponse.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * This contains the response of the HTTP request.
 *
 * @since 2019/05/13
 */
public final class HTTPResponse
{
	/** The header. */
	public final HTTPResponseHeader header;
	
	/** The data bytes. */
	private final byte[] _data;
	
	/**
	 * Initializes the response.
	 *
	 * @param __h The header.
	 * @param __d The data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPResponse(HTTPResponseHeader __h, byte[] __d)
		throws NullPointerException
	{
		if (__h == null || __d == null)
			throw new NullPointerException("NARG");
		
		this.header = __h;
		this._data = __d.clone();
	}
	
	/**
	 * Returns the input stream of the body data.
	 *
	 * @return The input stream for the body.
	 * @since 2019/05/13
	 */
	public final InputStream inputStream()
	{
		return new ByteArrayInputStream(this._data);
	}
	
	/**
	 * Parses the HTTP response.
	 *
	 * @param __b The input bytes.
	 * @return The parsed response.
	 * @throws IOException If the response is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponse parse(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return HTTPResponse.parse(new ByteArrayInputStream(__b));
	}
	
	/**
	 * Parses the HTTP response.
	 *
	 * @param __in The input bytes.
	 * @return The parsed response.
	 * @throws IOException If the response is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponse parse(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse the header first
		HTTPResponseHeader header = HTTPResponseHeader.parse(__in);
		
		// Decode content length
		int length;
		try
		{
			// Decode length
			String rl = header.header("content-length");
			if (rl != null)
				length = Integer.parseInt(rl, 10);
			
			// Variable length...
			else
				length = -1;
		}
		
		// {@squirreljme.error EC07 Invalid content length.}
		catch (NumberFormatException e)
		{
			throw new IOException("EC07", e);
		}
		
		// Length of specific size
		byte[] bytes;
		if (length >= 0)
		{
			bytes = new byte[length];
			for (int at = 0; at < length;)
			{
				int rc = __in.read(bytes, at, length - at);
				
				// {@squirreljme.error EC08 The HTTP body was too small. (The
				// read length; The expected size)}
				if (rc < 0)
					throw new IOException("EC08 " + at + " " + length);
				
				// Move at up
				at += rc;
			}
		}
		
		// Variable length
		else
		{
			// Read in all the data
			byte[] buf = new byte[512];
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
			{
				for (;;)
				{
					int rc = __in.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Done
				bytes = baos.toByteArray();
			}
		}
		
		// Debug
		todo.DEBUG.note(" <- %d", bytes.length);
		
		// Build response
		return new HTTPResponse(header, bytes);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPResponseHeader.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
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
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This contains the HTTP response header.
 *
 * @since 2019/05/13
 */
public final class HTTPResponseHeader
{
	/** The response code. */
	public final int code;
	
	/** The response message. */
	public final String message;
	
	/** Header key/values. */
	private final Map<String, String> _headers;
	
	/**
	 * Initializes the response header.
	 *
	 * @param __rcode The response code.
	 * @param __rmesg The response message.
	 * @param __hkvs Header key/value pairs.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPResponseHeader(int __rcode, String __rmesg,
		Map<String, String> __hkvs)
		throws NullPointerException
	{
		if (__rmesg == null || __hkvs == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.code = __rcode;
		this.message = __rmesg;
		
		// Copy header values
		Map<String, String> headers = new LinkedHashMap<>();
		for (Map.Entry<String, String> e : __hkvs.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			headers.put(k.trim().toLowerCase(),
				v.trim().toLowerCase());
		}
		this._headers = headers;
	}
	
	/**
	 * Obtains the specified header value.
	 *
	 * @param __k The header to get.
	 * @return The header value or {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public final String header(String __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this._headers.get(__k.toLowerCase());
	}
	
	/**
	 * Decodes the HTTP response header.
	 *
	 * @param __in The input bytes.
	 * @return The response header.
	 * @throws IOException On read errors or if the header is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponseHeader parse(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// HTTP headers
		int rcode = -1;
		String rmesg = "";
		Map<String, String> headers = new LinkedHashMap<>();
		
		// Decode the header line by line
		StringBuilder sb = new StringBuilder();
		for (int ln = 0;; ln++)
		{
			// Clear line
			sb.setLength(0);
			
			// Read until CRLF
			boolean cr = false;
			for (;;)
			{
				int c = __in.read();
				
				// EOF?
				if (c < 0)
					break;
				
				// Flag CR
				if (c == '\r')
					cr = true;
				
				// Read CRLF, line is complete?
				else if (cr && c == '\n')
					break;
				
				// Just another character
				else
				{
					sb.append((char)c);
					cr = false;
				}
			}
			
			// End of header?
			if (sb.length() <= 0)
				break;
			
			// Decode status line?
			String line = sb.toString();
			if (ln == 0)
			{
				// {@squirreljme.error EC09 Invalid status line. (The line)}
				if (!line.startsWith("HTTP/1.0 ") &&
					!line.startsWith("HTTP/1.1 "))
					throw new IOException("EC09 " + line);
				
				// Clip off
				line = line.substring(9);
				
				try
				{
					// Code and response message
					int sp = line.indexOf(' ');
					if (sp >= 0)
					{
						rcode = Integer.parseInt(line.substring(0, sp), 10);
						rmesg = line.substring(sp + 1);
					}
					
					// Just the code
					else
					{
						rcode = Integer.parseInt(line.substring(0, sp), 10);
						rmesg = "";
					}
				}
				
				// {@squirreljme.error EC0a Invalid HTTP status code. (Line)}
				catch (NumberFormatException e)
				{
					throw new IOException("EC0a " + line);
				}
			}
			
			// A header key/value otherwise
			else
			{
				// {@squirreljme.error EC0b Invalid header pair. (The line)}
				int lc = line.indexOf(':');
				if (lc < 0)
					throw new IOException("EC0b " + line);
				
				// Put in header
				headers.put(line.substring(0, lc),
					line.substring(lc + 1));
			}
		}
		
		// Build headed
		return new HTTPResponseHeader(rcode, rmesg, headers);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPSignalListener.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.IOException;

/**
 * This interface is used to signal changes in the HTTP state such as
 * when a connection should be made.
 *
 * @since 2019/05/13
 */
public interface HTTPSignalListener
{
	/**
	 * Tells the other end that the HTTP request data is ready.
	 *
	 * @param __data The data of the request.
	 * @throws IOException If the request could not be sent.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	void requestReady(byte[] __data)
		throws IOException, NullPointerException;
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPState.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This represents a state of the HTTP connection.
 *
 * @since 2019/05/12
 */
public enum HTTPState
{
	/** Setup, before a connection is made. */
	SETUP,
	
	/** Connected to remote HTTP server. */
	CONNECTED,
	
	/** Connection is closed. */
	CLOSED,
	
	/** End. */
	;
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/HTTPStateTracker.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This is used to track the state of the HTTP connection since it must be
 * shared across many classes for HTTP.
 *
 * @since 2019/05/13
 */
public final class HTTPStateTracker
{
	/** The state of this connection. */
	HTTPState _state =
		HTTPState.SETUP;
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/IPAddress.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is an immutable class which represents an IP address and possibly the
 * port.
 *
 * @since 2019/05/06
 */
public final class IPAddress
	implements SocketAddress
{
	/** System assigned port. */
	public static final int ASSIGNED_PORT =
		-1;
	
	/** The hostname. */
	public final String hostname;
	
	/** The port. */
	public final int port;
	
	/** The string reference. */
	private Reference<String> _string;
	
	/**
	 * Initializes the address.
	 *
	 * @param __h The hostname, may be {@code null}.
	 * @param __p The port, may be {@link ASSIGNED_PORT}.
	 * @throws IllegalArgumentException If the hostname or port is not valid.
	 * @since 2019/05/06
	 */
	public IPAddress(String __h, int __p)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EC0c IP port out of range. (The port)}
		if (__p != IPAddress.ASSIGNED_PORT && __p < 0 || __p > 65535)
			throw new IllegalArgumentException("EC0c " + __p);
		
		// {@squirreljme.error EC0d No IP address was specified.}
		if (__h == null && __p == IPAddress.ASSIGNED_PORT)
			throw new IllegalArgumentException("EC0d");
		
		// Validate hostname
		if (__h != null)
		{
			// Make it lowercase
			__h = __h.toLowerCase();
			
			// Is this an IPv6 address?
			boolean isvsix;
			String checkpart;
			if ((isvsix = __h.startsWith("[")))
			{
				// {@squirreljme.error EC0e IPv6 address must end in bracket.
				// (The hostname)}
				if (!__h.endsWith("]"))
					throw new IllegalArgumentException("EC0e " + __h);
				
				// Only check the insides
				checkpart = __h.substring(1, __h.length() - 1);
			}
			
			// Not one
			else
				checkpart = __h;
			
			// Check characters
			for (int i = 0, n = checkpart.length(); i < n; i++)
			{
				int c = checkpart.charAt(i);
				
				// {@squirreljme.error EC0f Hostname has an invalid
				// character. (The hostname)}
				if (!((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
					c == '-' || c == '.' || (isvsix && c == ':')))
					throw new IllegalArgumentException("EC0f " + __h);
			}
		}
		
		// Set
		this.hostname = __h;
		this.port = __p;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this a server connection?
	 *
	 * @return If this is a server connection.
	 * @since 2019/05/06
	 */
	public final boolean isServer()
	{
		return this.hostname == null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			String hostname = this.hostname;
			int port = this.port;
			
			// Include the port or not?
			if (hostname == null)
				rv = ":" + port;
			else if (port == IPAddress.ASSIGNED_PORT)
				rv = hostname;
			else
				rv = hostname + ":" + port;
			
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * Creates an address from a URI part.
	 *
	 * @param __part The URI part.
	 * @return The resulting IP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final IPAddress fromUriPart(String __part)
		throws IllegalArgumentException, NullPointerException
	{
		if (__part == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EC0g IP Address must start with double
		// slash. (The URI part)}
		if (!__part.startsWith("//"))
			throw new IllegalArgumentException("EC0g " + __part);
		
		// Parse
		return IPAddress.of(__part.substring(2));
	}
	
	/**
	 * Creates an address from the given string.
	 *
	 * @param __s The input string
	 * @return The resulting IP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final IPAddress of(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// The port could be weird
		try
		{
			// Need to detect that an IPv6 address is being used
			int col = __s.lastIndexOf(':'),
				eb = __s.lastIndexOf(']');
			if (eb >= 0 && eb > col)
				col = -1;
			
			// Just has a hostname?
			if (col < 0)
				return new IPAddress(__s, IPAddress.ASSIGNED_PORT);
			
			// Just has the port
			else if (col == 0)
				return new IPAddress(null,
					Integer.parseInt(__s.substring(1), 10));
			
			// Has both
			else
				return new IPAddress(__s.substring(0, col),
					Integer.parseInt(__s.substring(col + 1), 10));
		}
		
		// {@squirreljme.error EC0h Invalid port number. (The URI part)}
		catch (NumberFormatException e)
		{
			throw new IllegalArgumentException("EC0h " + __s, e);
		}
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/IPConnectionFactory.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import java.io.IOException;
import java.util.ServiceLoader;
import javax.microedition.io.ConnectionNotFoundException;

/**
 * This factory is used in the creation of IP based connections thus allowing
 * SquirrelJME access to the internet.
 *
 * @since 2019/05/12
 */
public abstract class IPConnectionFactory
{
	/** The existing connection factory. */
	private static volatile IPConnectionFactory _FACTORY;
	
	/**
	 * Resolves the specified IP address.
	 *
	 * @param __addr The IP address.
	 * @return The resolved address.
	 * @throws ConnectionNotFoundException If the host was not found.
	 * @throws IOException If the address could not resolved.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public abstract IPAddress resolveAddress(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException;
	
	/**
	 * Opens a TCP client connection to the remote address.
	 *
	 * @param __addr The address to connect to.
	 * @return The connection.
	 * @throws ConnectionNotFoundException If the connection was not found.
	 * @throws IOException On connection issues.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public abstract TCPClientConnection tcpClientConnect(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException;
	
	/**
	 * Returns the factory which manages IP based connections.
	 *
	 * @return The IP connection factory.
	 * @since 2019/05/12
	 */
	public static IPConnectionFactory factory()
	{
		// Already created?
		IPConnectionFactory rv = IPConnectionFactory._FACTORY;
		
		// Create factory?
		if (rv == null)
			synchronized (IPConnectionFactory.class)
			{
				// Check for double create
				rv = IPConnectionFactory._FACTORY;
				if (rv != null)
					return rv;
				
				// Use implementation for this
				String ipf = SystemProperties.implementationClass(
					"cc.squirreljme.runtime.gcf.IPConnectionFactory");
				if (ipf != null)
					try
					{
						rv = (IPConnectionFactory)Class.forName(ipf).
							newInstance();
					}
					catch (ClassNotFoundException|InstantiationException|
						IllegalAccessException e)
					{
						e.printStackTrace();
					}
				
				// Use the first found service
				if (rv == null)
					for (IPConnectionFactory mb : ServiceLoader.
						<IPConnectionFactory>load(IPConnectionFactory.class))
					{
						rv = mb;
						break;
					}
				
				// Fallback to no connection factory (IP not supported)
				if (rv == null)
					rv = new NullIPConnectionFactory();
				
				// Use it for later and return
				IPConnectionFactory._FACTORY = rv;
			}
		
		return rv;
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/NullIPConnectionFactory.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.IOException;
import javax.microedition.io.ConnectionNotFoundException;

/**
 * This is a connection factory which does not support any IP based
 * connections. Any attempt to open any kind of connection will result in
 * a connection not being made.
 *
 * @since 2019/05/12
 */
public final class NullIPConnectionFactory
	extends IPConnectionFactory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final IPAddress resolveAddress(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0i Host name resolution not supported.}
		throw new ConnectionNotFoundException("EC0i");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final TCPClientConnection tcpClientConnect(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0j TCP client connections are not
		// supported.}
		throw new ConnectionNotFoundException("EC0j");
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/SocketAddress.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

/**
 * This interface represents a generic address type.
 *
 * @since 2019/05/06
 */
public interface SocketAddress
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	boolean equals(Object __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	int hashCode();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	String toString();
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/TCPClientConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.SocketConnection;

/**
 * This is a connection to a remote TCP server as a client.
 *
 * @since 2019/05/06
 */
public abstract class TCPClientConnection
	implements SocketConnection
{
	/** The used IP address. */
	protected final IPAddress ipaddr;
	
	/** State tracker. */
	protected final ConnectionStateTracker tracker =
		new ConnectionStateTracker();
	
	/**
	 * Initializes the TCP client connection.
	 *
	 * @param __ip The IP to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public TCPClientConnection(IPAddress __ip)
		throws NullPointerException
	{
		if (__ip == null)
			throw new NullPointerException("NARG");
		
		this.ipaddr = __ip;
	}
	
	/**
	 * Performs connection close.
	 *
	 * @throws IOException If it could not be closed.
	 * @since 2019/05/13
	 */
	protected abstract void doClose()
		throws IOException;
	
	/**
	 * Performs the actual input stream open.
	 *
	 * @return The resulting stream.
	 * @throws IOException If it could not be opened.
	 * @since 2019/05/13
	 */
	protected abstract InputStream doOpenInputStream()
		throws IOException;
	
	/**
	 * Performs the actual output stream open.
	 *
	 * @return The resulting stream.
	 * @throws IOException If it could not be opened.
	 * @since 2019/05/13
	 */
	protected abstract OutputStream doOpenOutputStream()
		throws IOException;
	
	/**
	 * Sets an option for the socket.
	 *
	 * @param __o The option to use.
	 * @param __v The value to use.
	 * @throws IllegalArgumentException If the option is not valid.
	 * @throws IOException If it could not be set.
	 * @since 2019/05/12
	 */
	protected abstract void doSetSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Tracker knows if the streams have been closed...
		ConnectionStateTracker tracker = this.tracker;
		
		// Close input
		IOException supin = null;
		if (!tracker._inclosed)
			try
			{
				this.openInputStream().close();
			}
			catch (IOException e)
			{
				supin = e;
			}
		
		// Close output
		IOException supout = null;
		if (!tracker._outclosed)
			try
			{
				this.openOutputStream().close();
			}
			catch (IOException e)
			{
				supout = e;
			}
		
		// Forward close
		IOException supclo = null;
		try
		{
			this.doClose();
		}
		catch (IOException e)
		{
			supclo = e;
		}
		
		// Set tracker as closed
		tracker._inclosed = true;
		tracker._outclosed = true;
		
		// Exceptions were thrown?
		if (supin != null || supout != null || supclo != null)
		{
			// {@squirreljme.error EC0k The connection could not be closed
			// properly.}
			IOException t = new IOException("EC0k");
			
			// Add suppressed exceptions
			if (supin != null)
				t.addSuppressed(supin);
			if (supout != null)
				t.addSuppressed(supout);
			if (supclo != null)
				t.addSuppressed(supclo);
			
			// Toss it
			throw t;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final AccessPoint getAccessPoint()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getAddress()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getLocalAddress()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getLocalPort()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getPort()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getSocketOption(byte __o)
		throws IllegalArgumentException, IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataInputStream openDataInputStream()
		throws IOException
	{
		return new DataInputStream(this.openInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataOutputStream openDataOutputStream()
		throws IOException
	{
		return new DataOutputStream(this.openOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final InputStream openInputStream()
		throws IOException
	{
		// {@squirreljme.error EC0l The input has been closed.}
		ConnectionStateTracker tracker = this.tracker;
		if (tracker._inclosed)
			throw new IOException("EC0l");
		return new TrackedInputStream(tracker, this.doOpenInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final OutputStream openOutputStream()
		throws IOException
	{
		// {@squirreljme.error EC0m The output has been closed.}
		ConnectionStateTracker tracker = this.tracker;
		if (tracker._outclosed)
			throw new IOException("EC0m");
		return new TrackedOutputStream(tracker, this.doOpenOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException
	{
		// {@squirreljme.error EC0n Invalid socket option. (The option)}
		if (__o != SocketConnection.KEEPALIVE || __o != SocketConnection.LINGER || __o != SocketConnection.SNDBUF ||
			__o != SocketConnection.RCVBUF || __o != SocketConnection.DELAY || __o != SocketConnection.TIMEOUT)
			throw new IllegalArgumentException("EC0n " + __o);
		
		// Check options
		switch (__o)
		{
			case SocketConnection.LINGER:
				// {@squirreljme.error EC0o Linger cannot be negative.
				// (The requested linger)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0o " + __v);
				break;
			
			case SocketConnection.RCVBUF:
			case SocketConnection.SNDBUF:
				// {@squirreljme.error EC0p Send/receive buffer size cannot
				// be negative. (The requested buffer size)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0p " + __v);
				break;
			
			case SocketConnection.TIMEOUT:
				// {@squirreljme.error EC0q Timeout cannot be negative.
				// (The requested timeout)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0q " + __v);
				break;
		}
		
		// Forward
		this.doSetSocketOption(__o, __v);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/TrackedInputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is an input which tracks if it has been closed, if EOF is read from
 * a stream then it will automatically be closed.
 *
 * @since 2019/05/13
 */
public final class TrackedInputStream
	extends InputStream
{
	/** The tracker used. */
	protected final ConnectionStateTracker tracker;
	
	/** The wrapped stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the tracked stream.
	 *
	 * @param __t The tracker.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public TrackedInputStream(ConnectionStateTracker __t, InputStream __in)
		throws NullPointerException
	{
		if (__t == null || __in == null)
			throw new NullPointerException("NARG");
		
		this.tracker = __t;
		this.in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int available()
		throws IOException
	{
		// {@squirreljme.error EC0r The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0r");
		
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Always close the input
		this.in.close();
		
		// Set stream as closed
		this.tracker._inclosed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read()
		throws IOException
	{
		// {@squirreljme.error EC0s The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0s");
		
		// Read data
		int rv = this.in.read();
		if (rv < 0)
			this.close();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		// {@squirreljme.error EC0t The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0t");
		
		// Read data
		int rv = this.in.read(__b);
		if (rv < 0)
			this.close();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		// {@squirreljme.error EC0u The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0u");
		
		// Read data
		int rv = this.in.read(__b, __o, __l);
		if (rv < 0)
			this.close();
		return rv;
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/TrackedOutputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.gcf;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which keeps track if the connection has been
 * closed or not.
 *
 * @since 2019/05/13
 */
public final class TrackedOutputStream
	extends OutputStream
{
	/** The tracker used. */
	protected final ConnectionStateTracker tracker;
	
	/** The wrapped stream. */
	protected final OutputStream out;
	
	/**
	 * Initializes the tracked stream.
	 *
	 * @param __t The tracker.
	 * @param __out The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public TrackedOutputStream(ConnectionStateTracker __t, OutputStream __out)
		throws NullPointerException
	{
		if (__t == null || __out == null)
			throw new NullPointerException("NARG");
		
		this.tracker = __t;
		this.out = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Always close the output
		this.out.close();
		
		// Set stream as closed
		this.tracker._outclosed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// {@squirreljme.error EC0v The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0v");
		
		// Forward
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error EC0w The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0w");
		
		// Forward
		this.out.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		// {@squirreljme.error EC0x The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0x");
		
		// Forward
		this.out.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0y The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0y");
		
		// Forward
		this.out.write(__b, __o, __l);
	}
}

Added modules/gcf/src/main/java/cc/squirreljme/runtime/gcf/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the default implementation of the GCF classes.
 *
 * @since 2016/10/12
 */

package cc.squirreljme.runtime.gcf;

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

package javax.microedition.io;

import java.io.IOException;

public class AccessPoint
{
	public AccessPoint()
	{
		throw new todo.TODO();
	}
	
	public void addListener(AccessPointListener __a)
	{
		throw new todo.TODO();
	}
	
	public boolean connect()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnect()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public NetworkInterface getNetworkInterface()
	{
		throw new todo.TODO();
	}
	
	public String getProperty(String __a)
	{
		throw new todo.TODO();
	}
	
	public String[] getPropertyNames()
	{
		throw new todo.TODO();
	}
	
	public String[] getPropertyValues(String __a)
	{
		throw new todo.TODO();
	}
	
	public int getTimeout()
	{
		throw new todo.TODO();
	}
	
	public String getType()
	{
		throw new todo.TODO();
	}
	
	public boolean isConnected()
	{
		throw new todo.TODO();
	}
	
	public boolean isRemovable()
	{
		throw new todo.TODO();
	}
	
	public void removeListener(AccessPointListener __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeout(int __a)
	{
		throw new todo.TODO();
	}
	
	public static AccessPoint[] getAccessPoints(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public static AccessPoint of(String __a, ConnectionOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean remove(AccessPoint __a)
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/AccessPointListener.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.util.EventListener;

public interface AccessPointListener
	extends EventListener
{
	int EVENT_TYPE_CONNECTED =
		0;
	
	int EVENT_TYPE_DISCONNECTED =
		1;
	
	int EVENT_TYPE_REMOVED =
		2;
	
	void notifyEvent(AccessPoint __a, int __b);
}


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

package javax.microedition.io;

import java.security.BasicPermission;
import java.security.Permission;

public final class AccessPointPermission
	extends BasicPermission
{
	public AccessPointPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/CommConnection.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface CommConnection
	extends StreamConnection
{
	int getBaudRate();
	
	int setBaudRate(int __a);
}


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

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class CommProtocolPermission
	extends GCFPermission
{
	public CommProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.io.Closeable;
import java.io.IOException;

/**
 * This is the base class for all connection types.
 *
 * @since 2019/05/06
 */
public interface Connection
	extends Closeable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	void close()
		throws IOException;
}


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

package javax.microedition.io;

import java.io.IOException;

/**
 * This is thrown when the connection was not available.
 *
 * @since 2019/05/06
 */
public class ConnectionNotFoundException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/06
	 */
	public ConnectionNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/06
	 */
	public ConnectionNotFoundException(String __m)
	{
		super(__m);
	}
}


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

package javax.microedition.io;


public class ConnectionOption<T>
{
	public ConnectionOption(String __a, T __b)
	{
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public T getValue()
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/Connector.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import cc.squirreljme.runtime.gcf.HTTPAddress;
import cc.squirreljme.runtime.gcf.HTTPClientConnection;
import cc.squirreljme.runtime.gcf.IPAddress;
import cc.squirreljme.runtime.gcf.IPConnectionFactory;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;

/**
 * This class is used to create new connections via the generic connection
 * framework. All connection resources are URIs which describe the resource
 * to be accessed.
 *
 * @since 2016/10/12
 */
public class Connector
{
	/** Access mode to allow reading from the connection stream. */
	public static final int READ =
		1;
	
	/** Access mode to allow for writing to the connection stream. */
	public static final int WRITE =
		2;
	
	/** Access mode to allow for read and writing from/to the stream. */
	public static final int READ_WRITE = Connector.READ | Connector.WRITE;
	
	/**
	 * Not used.
	 *
	 * @since 2016/10/12
	 */
	private Connector()
	{
	}
	
	public static long getBytesRead(Connection __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static long getBytesWritten(Connection __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * This checks whether the specified protocol is supported.
	 *
	 * @param __uri The scheme to check if it is supported, if there is a colon
	 * then only the characters up to the first colon are used.
	 * @param __server If {@code true} then check for support for being a
	 * server.
	 * @return {@code true} if the protocol is supported.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public static boolean isProtocolSupported(String __uri, boolean __server)
		throws NullPointerException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// Only use up to the colon, if one exists
		int fc = __uri.indexOf(':');
		if (fc > 0)
			__uri = __uri.substring(0, fc);
		
		// Only these protocols are handled
		switch (__uri)
		{
				// Does not matter
			case "comm":
			case "datagram":
			case "dtls":
			case "file":
			case "imc":
			case "multicast":
			case "socket":
			case "ssl":
				return true;
			
				// Client only
			case "http":
			case "https":
				return !__server;
			
				// Unknown
			default:
				return false;
		}
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, READ_WRITE, false, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri)
		throws IOException
	{
		return Connector.open(__uri, Connector.READ_WRITE, false, (ConnectionOption<?>[])null);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, READ_WRITE, false, __opts)}.
	 *
	 * @param __uri As forwarded.
	 * @param __opts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, ConnectionOption<?>... __opts)
		throws IOException
	{
		return Connector.open(__uri, Connector.READ_WRITE, false, __opts);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, false, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode)
		throws IOException
	{
		return Connector.open(__uri, __mode, false, (ConnectionOption<?>[])null);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, false, __opts)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @param __opts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode,
		ConnectionOption<?>... __opts)
		throws IOException
	{
		return Connector.open(__uri, __mode, false, __opts);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, __timeouts, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @param __timeouts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode, boolean __timeouts)
		throws IOException
	{
		return Connector.open(__uri, __mode, __timeouts, (ConnectionOption<?>[])null);
	}
	
	/**
	 * This opens and creates a connection to the specified resource which is
	 * named by the URI.
	 *
	 * @param __uri The URI to open.
	 * @param __mode The open mode of the socket.
	 * @param __timeouts This is a hint to the connection system that it is
	 * acceptable for {@link InterruptedIOException}s to be generated. This
	 * is not required to be followed.
	 * @param __opts Options which modify the properties of a stream.
	 * @return The opened connection.
	 * @throws ConnectionNotFoundException Either the protocol is not supported
	 * or the target to connect to could not be located.
	 * @throws IllegalArgumentException If a parameter is not valid.
	 * @throws IOException On other unspecified exceptions.
	 * @throws NullPointerException If no URI was specified.
	 * @throws SecurityException If access to the protocol is not permitted.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode, boolean __timeouts,
		ConnectionOption<?>... __opts)
		throws ConnectionNotFoundException, IllegalArgumentException,
			IOException, NullPointerException, SecurityException
	{
		// Debug
		todo.DEBUG.note("Open %s", __uri);
		
		// Used to debug connections
		try
		{
			return Connector.__open(__uri, __mode, __timeouts, __opts);
		}
		
		// Print the exception
		catch (IllegalArgumentException|
			IOException|NullPointerException|SecurityException e)
		{
			e.printStackTrace();
			
			throw e;
		}
	}
	
	/**
	 * Invokes {@code new DataInputStream(openInputStream(__uri))}.
	 *
	 * @param __uri The URI to open.
	 * @return The data stream.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static DataInputStream openDataInputStream(String __uri)
		throws IOException
	{
		return new DataInputStream(Connector.openInputStream(__uri));
	}
	
	/**
	 * Invokes {@code new DataOutputStream(openOutputStream(__uri))}.
	 *
	 * @param __uri The URI to open.
	 * @return The data stream.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static DataOutputStream openDataOutputStream(String __uri)
		throws IOException
	{
		return new DataOutputStream(Connector.openOutputStream(__uri));
	}
	
	/**
	 * This opens a connection, obtains the input stream, then closes the
	 * connection.
	 *
	 * @param __uri The URI to open.
	 * @return An input stream for the given connection.
	 * @throws IllegalArgumentException If the connection is not an
	 * {@link InputConnection}.
	 * @throws IOException On open errors.
	 * @since 2016/10/12
	 */
	public static InputStream openInputStream(String __uri)
		throws IllegalArgumentException, IOException
	{
		// Open it, then close it
		try (Connection c = Connector.open(__uri))
		{
			// {@squirreljme.error EC0z The specified URI is not an input
			// connection. (The URI)}
			if (!(c instanceof InputConnection))
				throw new IllegalArgumentException(String.format("EC0z %s",
					__uri));
			
			// Open it
			return ((InputConnection)c).openInputStream();
		}
	}
	
	/**
	 * This opens a connection, obtains the output stream, then closes the
	 * connection.
	 *
	 * @param __uri The URI to open.
	 * @return An output stream for the given connection.
	 * @throws IllegalArgumentException If the connection is not an
	 * {@link OutputConnection}.
	 * @throws IOException On open errors.
	 * @since 2016/10/12
	 */
	public static OutputStream openOutputStream(String __uri)
		throws IllegalArgumentException, IOException
	{
		// Open it, then close it
		try (Connection c = Connector.open(__uri))
		{
			// {@squirreljme.error EC10 The specified URI is not an output
			// connection. (The URI)}
			if (!(c instanceof OutputConnection))
				throw new IllegalArgumentException(String.format("EC10 %s",
					__uri));
			
			// Open it
			return ((OutputConnection)c).openOutputStream();
		}
	}
	
	/**
	 * This opens and creates a connection to the specified resource which is
	 * named by the URI.
	 *
	 * @param __uri The URI to open.
	 * @param __mode The open mode of the socket.
	 * @param __timeouts This is a hint to the connection system that it is
	 * acceptable for {@link InterruptedIOException}s to be generated. This
	 * is not required to be followed.
	 * @param __opts Options which modify the properties of a stream.
	 * @throws ConnectionNotFoundException Either the protocol is not supported
	 * or the target to connect to could not be located.
	 * @throws IllegalArgumentException If a parameter is not valid.
	 * @throws IOException On other unspecified exceptions.
	 * @throws NullPointerException If no URI was specified.
	 * @throws SecurityException If access to the protocol is not permitted.
	 * @since 2016/10/12
	 */
	private static Connection __open(String __uri, int __mode,
		boolean __timeouts, ConnectionOption<?>... __opts)
		throws ConnectionNotFoundException, IllegalArgumentException,
			IOException, NullPointerException, SecurityException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// If missing, create
		if (__opts == null)
			__opts = new ConnectionOption<?>[0];
		
		// {@squirreljme.error EC11 The URI does not have a scheme. (The URI)}
		int fc = __uri.indexOf(':');
		if (fc < 0)
			throw new IllegalArgumentException(String.format("EC11 %s",
				__uri));
		String scheme = __uri.substring(0, fc),
			part = __uri.substring(fc + 1);
		
		// Sockets of a given protocol must be of a given class type
		switch (scheme)
		{
				// Communication port, which may be a modem
			case "comm":
				throw new todo.TODO();
				
				// UDP datagrams
			case "datagram":
				throw new todo.TODO();
				
				// SSL UDP datagrams
			case "dtls":
				throw new todo.TODO();
				
				// Local Files
			case "file":
				throw new todo.TODO();
				
				// HTTP
			case "http":
				return HTTPClientConnection.connect(
					HTTPAddress.fromUriPart(part));
				
				// HTTPS
			case "https":
				throw new todo.TODO();
				
				// Intermidlet communication
			case "imc":
				throw new todo.TODO();
				
				// UDP Multicast
			case "multicast":
				throw new todo.TODO();
				
				// TCP Socket
			case "socket":
				{
					// Decode address
					IPAddress addr = IPAddress.fromUriPart(part);
					
					// Creating server
					if (addr.isServer())
						throw new todo.TODO();
					
					// Creating client
					else
					{
						IPConnectionFactory pf = IPConnectionFactory.factory();
						return pf.tcpClientConnect(pf.resolveAddress(addr));
					}
				}
				
				// SSL/TLS TCP Socket
			case "ssl":
				throw new todo.TODO();
				
				// {@squirreljme.error EC12 Unhandled URI protocol. (The URI)}.
			default:
				throw new ConnectionNotFoundException(String.format("EC12 %s",
					__uri));
		}
	}
}


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

package javax.microedition.io;


public interface ContentConnection
	extends StreamConnection
{
	String getEncoding();
	
	long getLength();
	
	String getType();
}


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

package javax.microedition.io;

import java.security.Permission;

public final class DTLSProtocolPermission
	extends GCFPermission
{
	public DTLSProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public interface Datagram
	extends DataInput, DataOutput
{
	String getAddress();
	
	byte[] getData();
	
	int getLength();
	
	int getOffset();
	
	void reset();
	
	void setAddress(String __a)
		throws IOException;
	
	void setAddress(Datagram __a);
	
	void setData(byte[] __a, int __b, int __c);
	
	void setLength(int __a);
}


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

package javax.microedition.io;

import java.io.IOException;

public interface DatagramConnection
	extends Connection
{
	AccessPoint[] getAccessPoints()
		throws IOException;
	
	int getMaximumLength()
		throws IOException;
	
	int getNominalLength()
		throws IOException;
	
	Datagram newDatagram(int __a)
		throws IOException;
	
	Datagram newDatagram(int __a, String __b)
		throws IOException;
	
	Datagram newDatagram(byte[] __a, int __b)
		throws IOException;
	
	Datagram newDatagram(byte[] __a, int __b, String __c)
		throws IOException;
	
	void receive(Datagram __a)
		throws IOException;
	
	void send(Datagram __a)
		throws IOException;
}


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

package javax.microedition.io;

import java.security.Permission;

public final class DatagramProtocolPermission
	extends GCFPermission
{
	public DatagramProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class FileProtocolPermission
	extends GCFPermission
{
	public FileProtocolPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public abstract class GCFPermission
	extends Permission
{
	public GCFPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getProtocol()
	{
		throw new todo.TODO();
	}
	
	public String getURI()
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/HttpConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

/**
 * This is a connection which enables HTTP based API access.
 *
 * This connection is within three states:
 *  - SETUP where the connection is being setup.
 *  - CONNECTED where the connection has been made.
 *  - CLOSED where the connection has been completed and closed.
 *
 * The {@link #openOutputStream()} and {@link #openDataOutputStream()} may only
 * be called when in the SETUP state, when either of these streams are closed
 * the connection will transition to the connected state. Additionally if
 * the state transitions to the CONNECTED state for any reason then the stream
 * will be implicitly closed and its data will be used.
 *
 * @since 2019/05/12
 */
public interface HttpConnection
	extends ContentConnection
{
	String CONNECT =
		"CONNECT";
	
	String DELETE =
		"DELETE";
	
	String GET =
		"GET";
	
	String HEAD =
		"HEAD";
	
	int HTTP_ACCEPTED =
		202;
	
	int HTTP_BAD_GATEWAY =
		502;
	
	int HTTP_BAD_METHOD =
		405;
	
	int HTTP_BAD_REQUEST =
		400;
	
	int HTTP_CLIENT_TIMEOUT =
		408;
	
	int HTTP_CONFLICT =
		409;
	
	int HTTP_CREATED =
		201;
	
	int HTTP_ENTITY_TOO_LARGE =
		413;
	
	int HTTP_EXPECT_FAILED =
		417;
	
	int HTTP_FORBIDDEN =
		403;
	
	int HTTP_GATEWAY_TIMEOUT =
		504;
	
	int HTTP_GONE =
		410;
	
	int HTTP_INTERNAL_ERROR =
		500;
	
	int HTTP_LENGTH_REQUIRED =
		411;
	
	int HTTP_MOVED_PERM =
		301;
	
	int HTTP_MOVED_TEMP =
		302;
	
	int HTTP_MULT_CHOICE =
		300;
	
	int HTTP_NOT_ACCEPTABLE =
		406;
	
	int HTTP_NOT_AUTHORITATIVE =
		203;
	
	int HTTP_NOT_FOUND =
		404;
	
	int HTTP_NOT_IMPLEMENTED =
		501;
	
	int HTTP_NOT_MODIFIED =
		304;
	
	int HTTP_NO_CONTENT =
		204;
	
	int HTTP_OK =
		200;
	
	int HTTP_PARTIAL =
		206;
	
	int HTTP_PAYMENT_REQUIRED =
		402;
	
	int HTTP_PRECON_FAILED =
		412;
	
	int HTTP_PROXY_AUTH =
		407;
	
	int HTTP_REQ_TOO_LONG =
		414;
	
	int HTTP_RESET =
		205;
	
	int HTTP_SEE_OTHER =
		303;
	
	int HTTP_TEMP_REDIRECT =
		307;
	
	int HTTP_UNAUTHORIZED =
		401;
	
	int HTTP_UNAVAILABLE =
		503;
	
	int HTTP_UNSUPPORTED_RANGE =
		416;
	
	int HTTP_UNSUPPORTED_TYPE =
		415;
	
	int HTTP_USE_PROXY =
		305;
	
	int HTTP_VERSION =
		505;
	
	String OPTIONS =
		"OPTIONS";
	
	String POST =
		"POST";
	
	String PUT =
		"PUT";
	
	String TRACE =
		"TRACE";
	
	AccessPoint getAccessPoint()
		throws IOException;
	
	long getDate()
		throws IOException;
	
	long getExpiration()
		throws IOException;
	
	String getFile();
	
	String getHeaderField(String __a)
		throws IOException;
	
	String getHeaderField(int __a)
		throws IOException;
	
	long getHeaderFieldDate(String __a, long __b)
		throws IOException;
	
	int getHeaderFieldInt(String __a, int __b)
		throws IOException;
	
	String getHeaderFieldKey(int __a)
		throws IOException;
	
	String getHost();
	
	long getLastModified()
		throws IOException;
	
	int getPort();
	
	String getProtocol();
	
	String getQuery();
	
	String getRef();
	
	String getRequestMethod();
	
	String getRequestProperty(String __a);
	
	int getResponseCode()
		throws IOException;
	
	String getResponseMessage()
		throws IOException;
	
	String getURL();
	
	/**
	 * Sets the request method to use.
	 *
	 * @param __m The method to use.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If no method was specified.
	 * @since 2019/05/12
	 */
	void setRequestMethod(String __m)
		throws IOException, NullPointerException;
	
	/**
	 * Adds or replaces an existing request property, note that for multiple
	 * request property specifications they need to manually be comma
	 * separated.
	 *
	 * @param __k The request header key.
	 * @param __v The value to use, {@code null} clears.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If the key was null.
	 * @since 2019/05/12
	 */
	void setRequestProperty(String __k, String __v)
		throws IOException;
}


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

package javax.microedition.io;

import java.security.Permission;

public final class HttpProtocolPermission
	extends GCFPermission
{
	public HttpProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.io.IOException;

public interface HttpsConnection
	extends HttpConnection
{
	int getPort();
	
	SecurityInfo getSecurityInfo()
		throws IOException;
}


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

package javax.microedition.io;

import java.security.Permission;

public final class HttpsProtocolPermission
	extends GCFPermission
{
	public HttpsProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import javax.microedition.midlet.MIDletIdentity;

public interface IMCConnection
	extends StreamConnection
{
	MIDletIdentity getRemoteIdentity();
	
	String getRequestedServerVersion();
	
	String getServerName();
}


Added modules/gcf/src/main/java/javax/microedition/io/IMCServerConnection.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface IMCServerConnection
	extends StreamConnectionNotifier
{
	String getName();
	
	String getVersion();
}


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

package javax.microedition.io;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

public interface InputConnection
	extends Connection
{
	DataInputStream openDataInputStream()
		throws IOException;
	
	InputStream openInputStream()
		throws IOException;
}


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

package javax.microedition.io;

import java.io.IOException;

public interface ModemConnection
	extends CommConnection
{
	int DCD_SIGNAL =
		2;
	
	int DSR_SIGNAL =
		4;
	
	int DTR_SIGNAL =
		1;
	
	int INPUT_MODE =
		0;
	
	int OUTPUT_MODE =
		1;
	
	int RI_SIGNAL =
		8;
	
	int UNSUPPORTED =
		-1;
	
	void addListener(ModemListener __a, int __b);
	
	int getLineMode(int __a);
	
	boolean getLineState(int __a)
		throws IOException;
	
	void removeListener(ModemListener __a);
	
	void setLineState(int __a, boolean __b)
		throws IOException;
}


Added modules/gcf/src/main/java/javax/microedition/io/ModemListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.util.EventListener;

public interface ModemListener
	extends EventListener
{
	void signalChanged(ModemConnection __a, int __b, boolean __c);
}


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

package javax.microedition.io;

import java.security.Permission;

public final class MulticastProtocolPermission
	extends GCFPermission
{
	public MulticastProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/NetworkInterface.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public class NetworkInterface
{
	public NetworkInterface()
	{
		throw new todo.TODO();
	}
	
	public void connect(AccessPoint __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnect(AccessPoint __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnectAll()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public AccessPoint[] getConnectedAccessPoints()
	{
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public String getType()
	{
		throw new todo.TODO();
	}
	
	public boolean isRoaming()
	{
		throw new todo.TODO();
	}
	
	public boolean supportsConcurrentAccessPoints()
	{
		throw new todo.TODO();
	}
	
	public static NetworkInterface[] getNetworkInterfaces(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] getNetworkTypes()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.io.IOException;
import java.net.UnknownHostException;

public class NetworkUtilities
{
	public NetworkUtilities()
	{
		throw new todo.TODO();
	}
	
	public static String getByName(String __a)
		throws UnknownHostException
	{
		if (false)
			throw new UnknownHostException();
		throw new todo.TODO();
	}
	
	public static String getCanonicalHostName(String __a)
		throws IllegalArgumentException, UnknownHostException
	{
		if (false)
			throw new IllegalArgumentException();
		if (false)
			throw new UnknownHostException();
		throw new todo.TODO();
	}
	
	public static boolean isReachable(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

@SuppressWarnings("InterfaceWithOnlyOneDirectInheritor")
public interface OutputConnection
	extends Connection
{
	DataOutputStream openDataOutputStream()
		throws IOException;
	
	OutputStream openOutputStream()
		throws IOException;
}


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

package javax.microedition.io;

import java.io.IOException;

public class PushRegistry
{
	public PushRegistry()
	{
		throw new todo.TODO();
	}
	
	public static String getFilter(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String getMIDlet(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] listConnections(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public static long registerAlarm(String __a, long __b)
		throws ClassNotFoundException, ConnectionNotFoundException
	{
		if (false)
			throw new ClassNotFoundException();
		if (false)
			throw new ConnectionNotFoundException();
		throw new todo.TODO();
	}
	
	public static void registerConnection(String __a, String __b, String __c)
		throws ClassNotFoundException, IOException
	{
		if (false)
			throw new ClassNotFoundException();
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean unregisterConnection(String __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class PushRegistryPermission
	extends Permission
{
	public PushRegistryPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io;

import java.security.Permission;

public final class SSLProtocolPermission
	extends GCFPermission
{
	public SSLProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/SecureConnection.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SecureConnection
	extends SocketConnection
{
	SecurityInfo getSecurityInfo()
		throws IOException;
}


Added modules/gcf/src/main/java/javax/microedition/io/SecureDatagramConnection.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SecureDatagramConnection
	extends UDPDatagramConnection
{
	SecurityInfo getSecurityInfo()
		throws IOException;
}


Added modules/gcf/src/main/java/javax/microedition/io/SecureServerConnection.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface SecureServerConnection
	extends ServerSocketConnection
{
}


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

package javax.microedition.io;

import javax.microedition.pki.Certificate;

public interface SecurityInfo
{
	String getCipherSuite();
	
	Certificate getClientCertificate();
	
	String getProtocolName();
	
	String getProtocolVersion();
	
	Certificate getServerCertificate();
}


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

package javax.microedition.io;

import java.io.IOException;

public interface ServerSocketConnection
	extends StreamConnectionNotifier
{
	AccessPoint[] getAccessPoints()
		throws IOException;
	
	String getLocalAddress()
		throws IOException;
	
	int getLocalPort()
		throws IOException;
}


Added modules/gcf/src/main/java/javax/microedition/io/SocketConnection.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SocketConnection
	extends StreamConnection
{
	/** Use the nagle algorithm? Zero disables, non-zero enables. */
	byte DELAY =
		0;
	
	/** Keep connections alive? Zero disables, non-zero enables. */
	byte KEEPALIVE =
		2;
	
	/**
	 * Time to wait in seconds before closing connections. Zero disables and
	 * only positive values are used.
	 */
	byte LINGER =
		1;
	
	/** Receive buffer size? Zero is default, only positive is permitted. */
	byte RCVBUF =
		3;
	
	/** Send buffer size? Zero is default, only positive is permitted. */
	byte SNDBUF =
		4;
	
	/**
	 * Sets the timeout on blocking read/write. Zero is default, otherwise a
	 * positive value in milliseconds.
	 */
	byte TIMEOUT =
		5;
	
	AccessPoint getAccessPoint()
		throws IOException;
	
	String getAddress()
		throws IOException;
	
	String getLocalAddress()
		throws IOException;
	
	int getLocalPort()
		throws IOException;
	
	int getPort()
		throws IOException;
	
	int getSocketOption(byte __o)
		throws IllegalArgumentException, IOException;
	
	/**
	 * Sets an option for the socket.
	 *
	 * @param __o The option to use.
	 * @param __v The value to use.
	 * @throws IllegalArgumentException If the option is not valid.
	 * @throws IOException If it could not be set.
	 * @since 2019/05/12
	 */
	void setSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException;
}


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

package javax.microedition.io;

import java.security.Permission;

public final class SocketProtocolPermission
	extends GCFPermission
{
	public SocketProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Added modules/gcf/src/main/java/javax/microedition/io/StreamConnection.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface StreamConnection
	extends InputConnection, OutputConnection
{
}


Added modules/gcf/src/main/java/javax/microedition/io/StreamConnectionNotifier.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface StreamConnectionNotifier
	extends Connection
{
	StreamConnection acceptAndOpen()
		throws IOException;
}


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

package javax.microedition.io;

import java.io.IOException;

public interface UDPDatagramConnection
	extends DatagramConnection
{
	String getLocalAddress()
		throws IOException;
	
	int getLocalPort()
		throws IOException;
}


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

package javax.microedition.io;

import java.io.IOException;

public interface UDPMulticastConnection
	extends UDPDatagramConnection
{
	int getTimeToLive()
		throws IOException;
	
	boolean isDisableLoopback()
		throws IOException;
	
	boolean isJoinSupported();
	
	void join(String __a)
		throws IOException;
	
	void leave(String __a)
		throws IOException;
	
	void receive(Datagram __a)
		throws IOException;
	
	void send(Datagram __a)
		throws IOException;
	
	void setDisableLoopback(boolean __a)
		throws IOException;
	
	void setTimeToLive(int __a)
		throws IOException;
}


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

package javax.microedition.io.file;


public class ConnectionClosedException
	extends RuntimeException
{
	public ConnectionClosedException()
	{
		throw new todo.TODO();
	}
	
	public ConnectionClosedException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.io.file;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.microedition.io.StreamConnection;

public interface FileConnection
	extends StreamConnection
{
	long availableSize();
	
	boolean canRead();
	
	boolean canWrite();
	
	void create()
		throws IOException;
	
	void delete()
		throws IOException;
	
	long directorySize(boolean __a)
		throws IOException;
	
	boolean exists();
	
	long fileSize()
		throws IOException;
	
	String getName();
	
	String getPath();
	
	String getURL();
	
	boolean isDirectory();
	
	boolean isHidden();
	
	boolean isOpen();
	
	long lastModified();
	
	Enumeration list()
		throws IOException;
	
	Enumeration list(String __a, boolean __b)
		throws IOException;
	
	void mkdir()
		throws IOException;
	
	DataInputStream openDataInputStream()
		throws IOException;
	
	DataOutputStream openDataOutputStream()
		throws IOException;
	
	InputStream openInputStream()
		throws IOException;
	
	OutputStream openOutputStream()
		throws IOException;
	
	OutputStream openOutputStream(long __a)
		throws IOException;
	
	void rename(String __a)
		throws IOException;
	
	void setFileConnection(String __a)
		throws IOException;
	
	void setHidden(boolean __a)
		throws IOException;
	
	void setReadable(boolean __a)
		throws IOException;
	
	void setWritable(boolean __a)
		throws IOException;
	
	long totalSize();
	
	void truncate(long __a)
		throws IOException;
	
	long usedSize();
}


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

package javax.microedition.io.file;


public interface FileSystemListener
{
	int ROOT_ADDED =
		0;
	
	int ROOT_REMOVED =
		1;
	
	void rootChanged(int __a, String __b);
}


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

package javax.microedition.io.file;


public class IllegalModeException
	extends RuntimeException
{
	public IllegalModeException()
	{
		throw new todo.TODO();
	}
	
	public IllegalModeException(String __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.pki;


public interface Certificate
{
	String getIssuer();
	
	long getNotAfter();
	
	long getNotBefore();
	
	String getSerialNumber();
	
	String getSigAlgName();
	
	String getSubject();
	
	String getType();
	
	String getVersion();
}


Added modules/gcf/src/main/java/javax/microedition/pki/CertificateException.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.pki;

import java.io.IOException;

public class CertificateException
	extends IOException
{
	public static final byte BAD_EXTENSIONS =
		1;
	
	public static final byte BROKEN_CHAIN =
		11;
	
	public static final byte CERTIFICATE_CHAIN_TOO_LONG =
		2;
	
	public static final byte EXPIRED =
		3;
	
	public static final byte INAPPROPRIATE_KEY_USAGE =
		10;
	
	public static final byte MISSING_SIGNATURE =
		5;
	
	public static final byte NOT_YET_VALID =
		6;
	
	public static final byte ROOT_CA_EXPIRED =
		12;
	
	public static final byte SITENAME_MISMATCH =
		7;
	
	public static final byte UNAUTHORIZED_INTERMEDIATE_CA =
		4;
	
	public static final byte UNRECOGNIZED_ISSUER =
		8;
	
	public static final byte UNSUPPORTED_PUBLIC_KEY_TYPE =
		13;
	
	public static final byte UNSUPPORTED_SIGALG =
		9;
	
	public static final byte VERIFICATION_FAILED =
		14;
	
	public CertificateException(Certificate __a, byte __b)
	{
		throw new todo.TODO();
	}
	
	public CertificateException(String __a, Certificate __b, byte __c)
	{
		throw new todo.TODO();
	}
	
	public Certificate getCertificate()
	{
		throw new todo.TODO();
	}
	
	public byte getReason()
	{
		throw new todo.TODO();
	}
}


Added modules/io/build.gradle.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This provides slightly more powerful data " +
	"input and output streams which can be used to read and write data."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BD"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Generic Input/Output"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

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

package net.multiphasicapps.io;

/**
 * This class calculates the Adler32 checksum.
 *
 * This class is not thread safe.
 *
 * @since 2017/03/05
 */
public class Adler32Calculator
	implements Checksum
{
	/** The modulo for adler values. */
	private static final int _ADLER_MODULO =
		65521;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** The A value. */
	private volatile int _a =
		1;
	
	/** The B value. */
	private volatile int _b;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final int checksum()
	{
		return (this._b << 16) | this._a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		this.offer(solo, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte[] __b)
		throws NullPointerException
	{
		this.offer(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("BAOB");
		
		// Get parameters
		int a = this._a,
			b = this._b;
		
		// Calculate
		for (int p = __o, e = __o + __l; p < e; p++)
		{
			a = (a + (__b[p] & 0xFF)) % Adler32Calculator._ADLER_MODULO;
			b = (b + a) % Adler32Calculator._ADLER_MODULO;
		}
		
		// Set parameters
		this._a = a;
		this._b = b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void reset()
	{
		// Reset both parameters
		this._a = 1;
		this._b = 0;
	}
}

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

package net.multiphasicapps.io;

/**
 * This represents the alphabet that is used for Base64.
 *
 * @since 2018/03/05
 */
public enum Base64Alphabet
{
	/** The basic and MIME alphabet. */
	BASIC('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='),
	
	/** The URL alphabet. */
	URL('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '='),
	
	/** End. */
	;
	
	/** The alphabet for the characters. */
	final char[] _alphabet;
	
	/**
	 * Initializes the alphabet.
	 *
	 * @param __alphabet The alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	Base64Alphabet(char... __alphabet)
		throws NullPointerException
	{
		if (__alphabet == null)
			throw new NullPointerException("NARG");
		
		this._alphabet = __alphabet;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/Base64Decoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

/**
 * This decodes the base64 character set, ignoring invalid characters, and
 * provides the binary data for the input. If the padding character is reached
 * or if the input stream runs out of characters then EOF is triggered.
 *
 * @since 2018/03/05
 */
public final class Base64Decoder
	extends InputStream
{
	/** The source reader. */
	protected final Reader in;
	
	/** Ignore padding characters. */
	protected final boolean ignorepadding;
	
	/** The alphabet to use for decoding. */
	private final char[] _alphabet;
	
	/** The ASCII map for quick lookup. */
	private final byte[] _ascii;
	
	/** Output bytes to drain. */
	private final byte[] _drain =
		new byte[3];
	
	/** The current fill buffer. */
	private volatile int _buffer;
	
	/** The number of bits which are in the buffer. */
	private volatile int _bits;
	
	/** Has EOF been reached if the pad has been detected? */
	private volatile boolean _readeof;
	
	/** The current output drain position. */
	private volatile int _drained =
		-1;
	
	/** The maximum value for drained values. */
	private volatile int _drainedmax =
		-1;
	
	/**
	 * Initializes the decode the default MIME alphabet.
	 *
	 * @param __in The input set of characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/23
	 */
	public Base64Decoder(Reader __in)
	{
		this(__in, Base64Alphabet.BASIC);
	}
	
	/**
	 * Initializes the decoder using the specified alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars, false);
	}
	
	/**
	 * Initializes the decoder using the default alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars, boolean __ip)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __chars == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.erorr BD0g The alphabet to use for the base64
		// decoder must be 64 characters plus one padding character.
		// (The character count)}
		int n;
		if ((n = __chars.length) != 65)
			throw new IllegalArgumentException(String.format("BD0g %d", n));
		
		// Set
		this.in = __in;
		this.ignorepadding = __ip;
		this._alphabet = (__chars = __chars.clone());
		
		// Build ASCII map for quick in-range character lookup
		byte[] ascii = new byte[128];
		for (int i = 0; i < 128; i++)
			ascii[i] = -1;
		for (int i = 0; i < 65; i++)
		{
			int dx = __chars[i];
			if (dx < 128)
				ascii[dx] = (byte)i;
		}
		this._ascii = ascii;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		int drained = this._drained;
		
		// There are bytes which are ready and in the drain that we do not
		// need to block reading them?
		if (drained != -1)
			return this._drainedmax - drained;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		// If there is stuff to be drained, quickly drain that so we do not
		// need to go deeper into the heavier method
		int drained = this._drained;
		if (drained != -1)
		{
			// Read in drained character
			int rv = this._drain[drained++] & 0xFF;
			
			// Reached the drain limit?
			if (drained == this._drainedmax)
			{
				this._drained = -1;
				this._drainedmax = -1;
			}
			
			// Would still be drain
			else
				this._drained = drained;
			
			// Return the value
			return rv;
		}
		
		// Previously read EOF, so this will just return EOF
		if (this._readeof)
			return -1;
		
		// Otherwise decode and read
		byte[] next = new byte[1];
		for (;;)
		{
			int rc = this.read(next, 0, 1);
			
			// EOF?
			if (rc < 0)
				return -1;
			
			// Missed read
			else if (rc == 0)
				continue;
			
			return (next[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Did a previous read cause a padded EOF?
		boolean readeof = this._readeof;
		
		// Need lookups
		Reader in = this.in;
		boolean ignorepadding = this.ignorepadding;
		char[] alphabet = this._alphabet;
		byte[] ascii = this._ascii;
		byte[] drain = this._drain;
		
		// This buffer is filled into as needed when input characters are read
		int buffer = this._buffer,
			bits = this._bits,
			drained = this._drained,
			drainedmax = this._drainedmax;
		
		// Keep trying to fill bytes in
		int rv = 0;
		while (rv < __l)
		{
			// Still need to drain bytes away
			if (drained != -1 && drained < drainedmax)
			{
				// Drain it
				__b[__o++] = drain[drained++];
				rv++;
				
				// Drained all the characters
				if (drained == drainedmax)
					drained = drainedmax = -1;
				
				// Try again
				else
					continue;
			}
			
			// EOF was reached
			if (readeof)
				break;
			
			// Read in character and decode it
			int ch = in.read();
			
			// Is EOF?
			if (ch < 0)
			{
				// {@squirreljme.error BD01 Read EOF from input when there
				// were expected to be more characters or the ending padding
				// character. (The bits in the buffer)}
				if (bits != 0)
					throw new IOException("BD01 " + bits);
				
				// Did read EOF
				readeof = true;
				break;
			}
			
			// Determine the value of the character
			if (ch < 128)
				ch = ascii[ch];
			else
			{
				ch = -1;
				for (int i = 0; i < 65; i++)
					if (i == alphabet[i])
					{
						ch = i;
						break;
					}
			}
			
			// Invalid, ignore and continue
			if (ch == -1 || (ignorepadding && ch == 64))
				continue;
			
			// Decoded padding character
			else if (ch == 64)
			{
				// {@squirreljme.error BD02 Did not expect a padding character.
				// (The number of decoded bits in queue)}
				if (bits == 0 || bits == 24)
					throw new IOException("BD02 " + bits);
				
				// Only want to store a single extra byte since that is
				// all that is valid
				else if (bits < 16)
				{
					// {@squirreljme.error BD03 Expected another padding
					// character.}
					if (in.read() != alphabet[64])
						throw new IOException("BD03");
					
					drain[0] = (byte)(buffer >>> 4);
					
					drainedmax = 1;
				}
				
				// Otherwise there will be two characters to drain
				else
				{
					drain[0] = (byte)(buffer >>> 10);
					drain[1] = (byte)(buffer >>> 2);
					
					drainedmax = 2;
				}
				
				// Need to drain all
				drained = 0;
					
				// Clear the buffer
				buffer = bits = 0;
				
				// Did read EOF
				readeof = true;
			}
			
			// Normal data
			else
			{
				// Shift in six bits
				buffer <<= 6;
				buffer |= ch;
				bits += 6;
				
				// Drain and empty the buffer
				if (bits == 24)
				{
					// Fill the drain
					drain[0] = (byte)(buffer >>> 16);
					drain[1] = (byte)(buffer >>> 8);
					drain[2] = (byte)buffer;
					
					// Set these to drain
					drained = 0;
					drainedmax = 3;
					
					// Clear the buffer
					buffer = bits = 0;
				}
			}
		}
		
		// Store state for next run
		this._buffer = buffer;
		this._bits = bits;
		this._readeof = readeof;
		this._drained = drained;
		this._drainedmax = drainedmax;
		
		// Return the read count
		if (readeof && rv == 0)
			return -1;
		return rv;
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab)
		throws IllegalArgumentException, NullPointerException
	{
		return Base64Decoder.decode(__in, __ab, false);
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @param __ip Is padding ignored?
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab,
		boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __ab == null)
			throw new NullPointerException("NARG");
		
		// Wrap in a reader to decode
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			byte[] buf = new byte[32];
			
			// Loop handle bytes
			try (InputStream in = new Base64Decoder(
				new StringReader(__in), __ab, __ip))
			{
				for (;;)
				{
					int rc = in.read(buf);
					
					// EOF?
					if (rc < 0)
						break;
					
					// Copy
					baos.write(buf, 0, rc);
				}
			}
			
			// Return resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BD04 Could not decode the input string.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("BD04", e);
		}
	}
}

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

package net.multiphasicapps.io;

import java.io.IOException;

/**
 * This is used for huffman tree traversal.
 *
 * @since 2016/08/16
 */
public interface BitSource
{
	/**
	 * Returns the next bit.
	 *
	 * @return The next bit.
	 * @throws IOException On read errors.
	 * @since 2016/08/16
	 */
	boolean nextBit()
		throws IOException;
}

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

package net.multiphasicapps.io;

/**
 * This provides random access to data in the given byte array.
 *
 * @since 2016/08/11
 */
public class ByteArrayData
	implements RandomAccessData
{
	/** The starting offset. */
	protected final int offset;
	
	/** The number of bytes to access. */
	protected final int length;
	
	/** The endianess of the data to read. */
	protected final DataEndianess endianess;
	
	/** The backing array. */
	final byte[] _array;
	
	/**
	 * This wraps the given set of bytes.
	 *
	 * @param __end The endianess of the data.
	 * @param __b The bytes to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/11
	 */
	public ByteArrayData(DataEndianess __end, byte... __b)
		throws NullPointerException
	{
		this(__end, __b, 0, __b.length);
	}	
	
	/**
	 * This wraps the given set of bytes.
	 *
	 * @param __end The endianess of the data.
	 * @param __b The bytes to wrap.
	 * @param __o The starting offset.
	 * @param __l The length of bytes to wrap.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array size.
	 * @throws NullPointerException On null arguments
	 * @since 2016/08/11
	 */
	public ByteArrayData(DataEndianess __end, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__end == null || __b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("AIOB");
		
		// Set
		this.endianess = __end;
		this._array = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public DataEndianess getEndianess()
	{
		return this.endianess;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public void read(int __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readByte(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public double readDouble(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public double readFloat(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readInt(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public long readLong(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readShort(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readUnsignedByte(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readUnsignedShort(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/ByteDeque.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.NoSuchElementException;

/**
 * This is a byte buffer which provides bytes for input and output as a
 * double ended queue.
 *
 * If the queue reaches full capacity then it is increased in size.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/11
 */
public class ByteDeque
{
	/**
	 * {@squirreljme.property net.multiphasicapps.util.datadeque.blocksize=n
	 * The block size of individual arrays that make up the {@link ByteDeque}
	 * class. The value must be a power of two.}
	 */
	private static final int _BLOCK_SIZE =
		Math.max(8, Integer.getInteger(
			"net.multiphasicapps.util.datadeque.blocksize", 128));
	
	/** The block size mask. */
	private static final int _BLOCK_MASK = ByteDeque._BLOCK_SIZE - 1;
	
	/** The shift to convert block based values. */
	private static final int _BLOCK_SHIFT =
		Integer.numberOfTrailingZeros(ByteDeque._BLOCK_SIZE);
	
	/** The maximum permitted capacity. */
	protected final int capacity;
	
	/** Blocks which make up the queue. */
	private final LinkedList<byte[]> _blocks =
		new LinkedList<>();
	
	/** Single byte (since it is synchronized). */
	private final byte[] _solo =
		new byte[1];
	
	/** The number of bytes in the queue. */
	private volatile int _total;
	
	/** The relative position of the head in relation to the first block. */
	private volatile int _head;
	
	/** The relative position of the tail in relation to the last block. */
	private volatile int _tail;
	
	/**
	 * Sets the default block size.
	 *
	 * @since 2016/05/01
	 */
	static
	{
		// {@squirreljme.error BD21 The block size of the data deque is not
		// a power of two. (The specified block size)}
		if (Integer.bitCount(ByteDeque._BLOCK_SIZE) != 1)
			throw new RuntimeException(String.format("BD21 %d",
				ByteDeque._BLOCK_SIZE));
	}
	
	/**
	 * Initializes a byte deque with a 2GiB buffer size limit.
	 *
	 * @since 2016/03/11
	 */
	public ByteDeque()
	{
		this(Integer.MAX_VALUE);
	}
	
	/**
	 * Initializes a byte deque with the given capacity.
	 *
	 * @param __cap The maximum deque capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2016/05/01
	 */
	public ByteDeque(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD22 Negative deque capacity specified.}
		if (__cap < 0)
			throw new IllegalArgumentException("BD22");
		
		// Set
		this.capacity = __cap;
	}
	
	/**
	 * Attempts to add a single byte to the start of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The byte to add.
	 * @throws IllegalStateException If the capacity is violated.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte __b)
		throws IllegalStateException
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		this.addFirst(solo, 0, 1);
	}
	
	/**
	 * Attempts to add multiple bytes to the start of the queue, if the
	 * capacity would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte[] __b)
		throws IllegalStateException, NullPointerException
	{
		this.addFirst(__b, 0, __b.length);
	}
	
	/**
	 * Attempts to add multiple bytes to the start of the queue, if the
	 * capacity would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte[] __b, int __o, int __l)
		throws IllegalStateException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// No bytes to add, do nothing
		if (__l == 0)
			return;
		
		// {@squirreljme.error BD23 Adding bytes to the start would exceed
		// the capacity of the queue.}
		int total = this._total;
		int newtotal = total + __l;
		if (newtotal < 0 || newtotal > this.capacity)
			throw new IllegalStateException("BD23");
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		throw new todo.TODO();
	}
	
	/**
	 * Attempts to add a single byte to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The byte to add.
	 * @throws IllegalStateException If the capacity is violated.
	 * @since 2016/05/01
	 */
	public final void addLast(byte __b)
		throws IllegalStateException
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		this.addLast(solo, 0, 1);
	}
	
	/**
	 * Attempts to add multiple bytes to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addLast(byte[] __b)
		throws IllegalStateException, NullPointerException
	{
		this.addLast(__b, 0, __b.length);
	}
	
	/**
	 * Attempts to add multiple bytes to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addLast(byte[] __b, int __o, int __l)
		throws IllegalStateException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// No bytes to add, do nothing
		if (__l == 0)
			return;
		
		// {@squirreljme.error BD24 Adding bytes to the end would exceed
		// the capacity of the queue.}
		int total = this._total;
		int newtotal = total + __l;
		if (newtotal < 0 || newtotal > this.capacity)
			throw new IllegalStateException("BD24");
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		// Keep adding in data
		int bs = ByteDeque._BLOCK_SIZE;
		int bm = ByteDeque._BLOCK_MASK;
		int left = __l;
		int at = __o;
		while (left > 0)
		{
			// If the tail is at the start of the block then a new one
			// must be created
			byte[] bl;
			if (tail == 0)
			{
				bl = new byte[bs];
				blocks.addLast(bl);
			}
			
			// Otherwise get the last one
			else
				bl = blocks.getLast();
			
			// Only can fit a single block
			int limit = bs - tail;
			if (left < limit)
				limit = left;
			
			// Write data
			for (int i = 0; i < limit; i++)
				bl[tail++] = __b[at++];
			
			// Masking is only needed after the write
			tail &= bm;
			
			// Consumed bytes
			left -= limit;
		}
		
		// Set new details
		this._total = newtotal;
		this._tail = tail;
	}
	
	/**
	 * Returns the number of available bytes inside of the queue.
	 *
	 * @return The number of bytes in the queue.
	 * @since 2016/05/01
	 */
	public final int available()
	{
		return this._total;
	}
	
	/**
	 * Clears the queue and every associated byte.
	 *
	 * @since 2016/08/02
	 */
	public final void clear()
	{
		// Reset variables
		this._total = 0;
		this._head = 0;
		this._tail = 0;
	
		// Zero out all blocks (for security and better compression)
		LinkedList<byte[]> blocks = this._blocks;
		for (byte[] bl : blocks)
			Arrays.fill(bl, (byte)0);
		blocks.clear();
	}
	
	/**
	 * Deletes the specified number of bytes at the start of the deque.
	 *
	 * @param __l The number of bytes to delete.
	 * @return The number of deleted bytes.
	 * @throws IndexOutOfBoundsException If the number of bytes is negative.
	 * @since 2016/08/04
	 */
	public final int deleteFirst(int __l)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD25 Attempt to delete starting from a negative
		// address.}
		if (__l < 0)
			throw new IndexOutOfBoundsException("BD25");
		
		// Do nothing
		if (__l == 0)
			return 0;
		
		// If the queue is empty do nothing
		int total = this._total;
		if (total == 0)
			return 0;
		
		// Do not remove more bytes than there are available
		int limit = (__l < total ? __l : total);
		int newtotal = total - limit;
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		// Write bytes into the target
		int left = limit;
		int bs = ByteDeque._BLOCK_SIZE;
		int bm = ByteDeque._BLOCK_MASK;
		while (left > 0)
		{
			// Get the first block
			byte[] bl = blocks.getFirst();
			boolean lastbl = (nb == 1);
			
			// Determine the max number of bytes to delete
			int rc = (lastbl ? (tail == 0 ? bs : tail) - head : bs - head);
			if (left < rc)
				rc = left;
			
			// Should never occur, because that means the end is lower
			// than the start
			if (rc < 0)
				throw new todo.OOPS();
			
			// Erase data
			for (int i = 0; i < rc; i++)
				bl[head++] = 0;
			
			// Mask the head to detect overflow
			head &= bm;
			
			// If cycled, remove the first block
			if (head == 0 || (lastbl && head == tail))
			{
				blocks.removeFirst();
				nb--;
			}
			
			// Bytes were removed
			left -= rc;
		}
		
		// Emptied? Clear head/tail pointers
		if (newtotal == 0)
			head = tail = 0;
		
		// Set details
		this._total = newtotal;
		this._head = head;
		this._tail = tail;
		
		// Return the erase count
		return limit;
	}
	
	/**
	 * Gets a single byte offset from the start of the deque as if it were an
	 * array.
	 *
	 * @param __a The index to get the byte value of.
	 * @return The byte at the given position.
	 * @throws IndexOutOfBoundsException If the address is not within bounds.
	 * @since 2016/08/03
	 */
	public final byte get(int __a)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD26 Request get at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD26");
		
		byte[] solo = this._solo;
		int rv = this.get(__a, solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD27 Could not get the byte at the
		// given position because it exceeds the deque bounds. (The index)}
		throw new IndexOutOfBoundsException(String.format("BD27 %d", __a));
	}
	
	/**
	 * Gets multiple bytes offset from the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start reading values from.
	 * @param __b The destination array for values.
	 * @return The number of bytes read.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/03
	 */
	public final int get(int __a, byte[] __b)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return this.get(__a, __b, 0, __b.length);
	}
	
	/**
	 * Gets multiple bytes offset from the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start reading values from.
	 * @param __b The destination array for values.
	 * @param __o Where to start writing destination values.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque, the offset and/or length are negative, or the
	 * offset and length exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/03
	 */
	public final int get(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// {@squirreljme.error BD28 Request get at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD28");
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD29 The requested address is outside of
		// the bounds of the queue. (The requested address; The number of
		// bytes in the queue)}
		int total = this._total;
		if (__a < 0 || __a >= total)
			throw new IndexOutOfBoundsException(String.format("BD29 %d %d",
				__a, total));
		
		// If there are no bytes, all reads do nothing
		if (total <= 0)
			return 0;
		
		// If the address is within the starting half then seek from the
		// start, otherwise start from the trailing end
		return this.__getOrSetVia((__a < (total >> 1)), __a, __b, __o, __l, false);
	}
	
	/**
	 * Obtains but does not remove the first byte.
	 *
	 * @return The value of the first byte.
	 * @throws NoSuchElementException If the deque is empty.
	 * @since 2016/05/01
	 */
	public final byte getFirst()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = this.getFirst(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2a Could not get the first byte
		// because the deque is empty.}
		throw new NoSuchElementException("BD2a");
	}
	
	/**
	 * Obtains but does not remove the first set of bytes.
	 *
	 * @param __b The destination array to obtain the first bytes for.
	 * @return The number of read bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getFirst(byte[] __b)
		throws NullPointerException
	{
		return this.getFirst(__b, 0, __b.length);
	}
	
	/**
	 * Obtains but does not remove the first set of bytes.
	 *
	 * @param __b The destination array to obtain the first bytes for.
	 * @param __o The offset in the destination array to start reading bytes
	 * into.
	 * @param __l The number of bytes to read.
	 * @return The number of read bytes.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the bounds of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// This is the same of an any position get at the start
		return this.get(0, __b, __o, __l);
	}
	
	/**
	 * Obtains but does not remove the last byte.
	 *
	 * @return The value of the last byte.
	 * @throws NoSuchElementException If the deque is empty.
	 * @since 2016/05/01
	 */
	public final byte getLast()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = this.getLast(solo, 0, 1);
		if (rv == 0)
			return solo[0];
		
		// {@squirreljme.error BD2b Could not remove the last byte because
		// the deque is empty.}
		throw new NoSuchElementException("BD2b");
	}
	
	/**
	 * Obtains but does not remove the last set of bytes.
	 *
	 * @param __b The destination array to obtain the last bytes for.
	 * @return The number of read bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getLast(byte[] __b)
		throws NullPointerException
	{
		return this.getLast(__b, 0, __b.length);
	}
	
	/**
	 * Obtains but does not remove the last set of bytes.
	 *
	 * @param __b The destination array to obtain the last bytes for.
	 * @param __o The offset in the destination array to start reading bytes
	 * into.
	 * @param __l The number of bytes to read.
	 * @return The number of read bytes.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the bounds of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check, the length is used so make sure it is positive
		if (__l < 0)
			throw new IndexOutOfBoundsException("BAOB");
		
		// This is the same of an any position get from the end
		int total = this._total;
		return this.get(Math.max(0, total - __l), __b, __o, __l);
	}
	
	/**
	 * Returns whether or not this deque is empty.
	 *
	 * @return Whether it is empty or not.
	 * @since 2017/08/22
	 */
	public final boolean isEmpty()
	{
		return this.available() == 0;
	}
	
	/**
	 * Offers a single byte to the start of the deque and returns {@code true}
	 * if it was added to the deque.
	 *
	 * @param __b The byte to add to the start.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte __b)
	{
		// May violate the capacity
		try
		{
			this.addFirst(__b);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers multiple bytes to the start of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte[] __b)
		throws NullPointerException
	{
		return this.offerFirst(__b, 0, __b.length);
	}
	
	/**
	 * Offers multiple bytes to the start of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		// May violate the capacity
		try
		{
			this.addFirst(__b, __o, __l);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers a single byte to the end of the deque and returns {@code true} if
	 * it was added to the deque.
	 *
	 * @param __b The byte to add to the end.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte __b)
	{
		// May violate the capacity
		try
		{
			this.addLast(__b);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers multiple bytes to the end of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte[] __b)
		throws NullPointerException
	{
		return this.offerLast(__b, 0, __b.length);
	}
	
	/**
	 * Offers multiple bytes to the end of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		// May violate the capacity
		try
		{
			this.addLast(__b, __o, __l);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Obtains but does not remove the first byte, returning a special value
	 * if the deque is empty.
	 *
	 * @return The value of the first byte or a negative value if the deque is
	 * empty.
	 * @since 2016/05/01
	 */
	public final int peekFirst()
		throws NoSuchElementException
	{
		// The deque could be empty
		try
		{
			return ((int)this.getFirst()) & 0xFF;
		}
		
		// Does not exist.
		catch (NoSuchElementException e)
		{
			return -1;
		}
	}
	
	/**
	 * Obtains but does not remove the last byte, returning a special value
	 * if the deque is empty.
	 *
	 * @return The value of the last byte or a negative value if the deque is
	 * empty.
	 * @since 2016/05/01
	 */
	public final int peekLast()
		throws NoSuchElementException
	{
		// The deque could be empty
		try
		{
			return ((int)this.getLast()) & 0xFF;
		}
		
		// Does not exist.
		catch (NoSuchElementException e)
		{
			return -1;
		}
	}
	
	/**
	 * Removes a single byte from the from of the deque.
	 *
	 * @return The next input byte.
	 * @throws NoSuchElementException If not a single byte is available.
	 * @since 2016/05/01
	 */
	public final byte removeFirst()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = this.removeFirst(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2c Could not remove the first byte
		// because the deque is empty.}
		throw new NoSuchElementException("BD2c");
	}
	
	/**
	 * Removes multiple bytes from the front of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeFirst(byte[] __b)
		throws NullPointerException
	{
		return this.removeFirst(__b, 0, __b.length);
	}
	
	/**
	 * Removes multiple bytes from the front of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @param __o The offset to start writing into.
	 * @param __l The number of bytes to remove.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// If nothing to remove, do nothing
		if (__l == 0)
			return 0;
		
		// If the queue is empty do nothing
		int total = this._total;
		if (total == 0)
			return 0;
		
		// A remove is a get followed by a delete
		int rva = this.get(0, __b, __o, __l);
		int rvb = this.deleteFirst(__l);
		
		// If this occurs then the number of bytes deleted was not the
		// same as the number of bytes which were read.
		if (rva != rvb)
			throw new todo.OOPS();
		
		// Return the read count
		return rva;
	}
	
	/**
	 * Removes a single byte from the from of the deque.
	 *
	 * @return The next input byte.
	 * @throws NoSuchElementException If not a single byte is available.
	 * @since 2016/05/01
	 */
	public final byte removeLast()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = this.removeLast(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2d Could not remove the last byte because
		// the deque is empty.}
		throw new NoSuchElementException("BD2d");
	}
	
	/**
	 * Removes multiple bytes from the end of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeLast(byte[] __b)
		throws NullPointerException
	{
		return this.removeLast(__b, 0, __b.length);
	}
	
	/**
	 * Removes multiple bytes from the end of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @param __o The offset to start writing into.
	 * @param __l The number of bytes to remove.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets a single byte offset to the start of the deque as if it were an
	 * array.
	 *
	 * @param __a The index to set the byte value of.
	 * @return The byte at the given position.
	 * @throws IndexOutOfBoundsException If the address is not within bounds.
	 * @since 2017/02/04
	 */
	public final byte set(int __a)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD2e Request set at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD2e");
		
		byte[] solo = this._solo;
		int rv = this.set(__a, solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2f Could not set the byte at the
		// given position because it exceeds the deque bounds. (The index)}
		throw new IndexOutOfBoundsException(String.format("BD2f %d", __a));
	}
	
	/**
	 * Sets multiple bytes offset to the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start writing values to.
	 * @param __b The source array for values.
	 * @return The number of bytes write.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/04
	 */
	public final int set(int __a, byte[] __b)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return this.set(__a, __b, 0, __b.length);
	}
	
	/**
	 * Sets multiple bytes offset to the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start writing values to.
	 * @param __b The source array for values.
	 * @param __o Where to start writing source values.
	 * @param __l The number of bytes to write.
	 * @return The number of bytes write.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque, the offset and/or length are negative, or the
	 * offset and length exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/04
	 */
	public final int set(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// {@squirreljme.error BD2g Request set at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD2g");
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD2h The requested address is outside of
		// the bounds of the queue. (The requested address; The number of
		// bytes in the queue)}
		int total = this._total;
		if (__a < 0 || __a >= total)
			throw new IndexOutOfBoundsException(String.format("BD2h %d %d",
				__a, total));
		
		// If there are no bytes, all writes do nothing
		if (total <= 0)
			return 0;
		
		// If the address is within the starting half then seek to the
		// start, otherwise start to the trailing end
		return this.__getOrSetVia((__a < (total >> 1)), __a, __b, __o, __l, true);
	}
	
	/**
	 * Returns the number of bytes which are in this deque.
	 *
	 * @return The total number of bytes in this deque.
	 * @since 2017/08/14
	 */
	public final int size()
	{
		return this._total;
	}
	
	/**
	 * Returns all of the data in this deque as a single byte array.
	 *
	 * @return The data contained within this deque.
	 * @since 2017/02/04
	 */
	public final byte[] toByteArray()
	{
		int sz = this.available();
		byte[] rv = new byte[sz];
		this.get(0, rv, 0, sz);
		return rv;
	}
	
	/**
	 * Writes the entire deque into the specified output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/25
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Obtains or reads bytes starting from the head or tail side.
	 *
	 * @param __last If {@code true} then initial block traversal is done
	 * from the tail end rather than the head end.
	 * @param __a The address to read.
	 * @param __b The destination or source array.
	 * @param __o The output offset into the array.
	 * @param __l The number of bytes to read or write.
	 * @param __set If {@code true} then bytes will be read from the input
	 * array for writing.
	 * @return The number of bytes read.
	 * @since 2016/08/04
	 */
	private final int __getOrSetVia(boolean __last, int __a, byte[] __b,
		int __o, int __l, boolean __set)
	{
		// Get some things
		int total = this._total;
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		int bs = ByteDeque._BLOCK_SIZE;
		int bm = ByteDeque._BLOCK_MASK;
		
		// The number of bytes to read
		int limit = total - __a;
		if (__l < limit)
			limit = __l;
		
		// Skip through the starting set of blocks since they are not
		// needed at all
		Iterator<byte[]> it;
		int blskip = (head + __a) >> ByteDeque._BLOCK_SHIFT;
		if (__last && nb > 1)
		{
			// Start from the back and then go to the index where we are
			// supposed to be at
			ListIterator<byte[]> lit = blocks.listIterator(nb);
			it = lit;
			int backskip = nb - blskip;
			for (int i = 0; i < backskip; i++)
				lit.previous();
		}
		
		// Start from the head size (the front)
		else
		{
			it = blocks.iterator();
			for (int i = 0; i < blskip; i++)
				it.next();
		}
		
		// The initial read head starts where the actual data starts
		// logicall in the buffer (if the head is 2 then address 42 is
		// 44 within the buffer).
		int rhead = (head + __a) & bm;
		
		// Read these bytes
		int left = limit;
		int at = __o;
		while (left > 0)
		{
			// Get the block data
			byte[] bl = it.next();
			
			// Is this the last block?
			boolean lastbl = !it.hasNext();
			
			// Determine the number of bytes to read
			int rc = (lastbl && tail != 0 ? tail : bs) - rhead;
			if (left < rc)
				rc = left;
			
			// Write the data
			if (__set)
				for (int i = 0; i < rc; i++)
					bl[rhead++] = __b[at++];
		
			// Read the data
			else
				for (int i = 0; i < rc; i++)
					__b[at++] = bl[rhead++];
			
			// Reset head to zero for the next block read
			rhead = 0;
			
			// Read this many bytes
			left -= rc;
		}
		
		// Return the nymber of bytes read
		return limit;
	}
}

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

package net.multiphasicapps.io;

/**
 * This is a data sink which supports the CRC 32 algorithm.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/16
 */
public class CRC32Calculator
	implements Checksum
{
	/** Working buffer size. */
	private static final int _WORK_BUFFER =
		32;
	
	/** The polynomial to use. */
	protected final int polynomial;
	
	/** The final XOR value. */
	protected final int finalxor;
	
	/** Reflect the data? */
	protected final boolean reflectdata;
	
	/** Reflect the remainder? */
	protected final boolean reflectremainder;
	
	/** The initial remainder. */
	protected final int initremainder;
	
	/** The CRC Table. */
	final __CRC32Table__ _table;
	
	/** Solo buffer. */
	private final byte[] _solo =
		new byte[1];
	
	/** The work buffer. */
	private final byte[] _work =
		new byte[CRC32Calculator._WORK_BUFFER];
	
	/** The current CRC value (remainder). */
	private volatile int _remainder;
	
	/**
	 * Initializes the CRC-32 data sink.
	 *
	 * @param __rdata Reflect the data?
	 * @param __rrem Reflect the remainder?
	 * @param __poly The polynomial.
	 * @param __initrem The initial remainder.
	 * @param __fxor The value to XOR the remainder with on return.
	 * @since 2016/07/16
	 */
	public CRC32Calculator(boolean __rdata, boolean __rrem, int __poly,
		int __initrem, int __fxor)
	{
		// Set
		this.reflectdata = __rdata;
		this.reflectremainder = __rrem;
		this.polynomial = __poly;
		this.finalxor = __fxor;
		this.initremainder = __initrem;
		this._remainder = __initrem;
		
		// Setup table
		this._table = __CRC32Table__.__table(__poly);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/16
	 */
	@Override
	public final int checksum()
	{
		// Return the current CRC
		int rem = this._remainder;
		return (this.reflectremainder ? Integer.reverse(rem) : rem) ^
			this.finalxor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		this.offer(solo, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte[] __b)
		throws NullPointerException
	{
		this.offer(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("BAOB");
		
		// Read data into the work buffer
		boolean reflectdata = this.reflectdata;
		int remainder = this._remainder;
		int[] table = this._table._table;
		for (int i = __o, end = __o + __l; i < end; i++)
		{
			// Read in data value
			int val = __b[i] & 0xFF;
		
			// Reflect the data?
			if (reflectdata)
				val = Integer.reverse(val) >>> 24;
		
			int d = (val ^ (remainder >>> 24));
			remainder = table[d] ^ (remainder << 8);
		}
		
		// Set new remainder
		this._remainder = remainder;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void reset()
	{
		// Only the remainder has to be updated
		this._remainder = this.initremainder;
	}
}

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

package net.multiphasicapps.io;

/**
 * This interface is implemented by checksum calculators and may be used to
 * assist in the calculation of checksums.
 *
 * @since 2017/03/05
 */
public interface Checksum
{
	/**
	 * Returns the currently calculated checksum value.
	 *
	 * @return The current checksum value.
	 * @since 2017/03/05
	 */
	int checksum();
	
	/**
	 * Offers a single byte for checksum calcualtion.
	 *
	 * @param __b The byte to offer.
	 * @since 2017/03/05
	 */
	void offer(byte __b);
	
	/**
	 * Offers multiple byte for checksum calculation.
	 *
	 * @param __b The bytes to offer.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/05
	 */
	void offer(byte[] __b)
		throws NullPointerException;
	
	/**
	 * Offers multiple byte for checksum calculation.
	 *
	 * @param __b The bytes to offer.
	 * @param __o The starting offset to read bytes from.
	 * @param __l The number of bytes to buffer.
	 * @throws ArrayIndexOutOfBoundsException If the offset or length are
	 * negative or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/05
	 */
	void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Resets the checksum calculator to its initial state.
	 *
	 * @since 2017/03/05
	 */
	void reset();
}

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

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * The forwards data from an input stream and calculates the checksum for that
 * data stream.
 *
 * @since 2017/03/05
 */
public class ChecksumInputStream
	extends InputStream
{
	/** The checksum Calculator used. */
	protected final Checksum checksum;
	
	/** Input stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the calculator.
	 *
	 * @param __calc The checksum calculator to write to.
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public ChecksumInputStream(Checksum __calc, InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__calc == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.checksum = __calc;
		this.in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.in.read();
		
		// EOF?
		if (rv < 0)
			return rv;
		
		// Calculate checksum
		this.checksum.offer((byte)rv);
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Read data
		int rv = this.in.read(__b, __o, __l);
		
		// EOF?
		if (rv < 0)
			return rv;
		
		// Calculate checksum
		this.checksum.offer(__b, __o, rv);
		
		// Read count
		return rv;
	}
}

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

package net.multiphasicapps.io;

/**
 * This represents the compression level, which is based on how fast things
 * are.
 *
 * @since 2018/11/10
 */
public enum CompressionLevel
{
	/** Fast compression level. */
	FASTEST,
	
	/** Faster compression. */
	FASTER,
	
	/** Fast compression. */
	FAST,
	
	/** Slow compression. */
	SLOW,
	
	/** Slower compression. */
	SLOWER,
	
	/** Slowest compression. */
	SLOWEST,
	
	/** End. */
	;
	
	/** The default compression level. */
	public static final CompressionLevel DEFAULT = CompressionLevel.SLOW;
	
	/** The best compression level. */
	public static final CompressionLevel BEST = CompressionLevel.SLOWEST;
	
	/**
	 * The number of symbols to look at as a single unit with a given
	 * dictionary before attempting with another dictionary.
	 *
	 * @return The block size to use for compression.
	 * @since 2018/11/10
	 */
	public final int blockSize()
	{
		switch (this)
		{
				// Fast has no sliding window
			case FASTEST:	return 64;
			case FASTER:	return 128;
			case FAST:		return 256;
			
				// Slow algorithms compress in more chunks
			case SLOW:		return 256;
			case SLOWER:	return 512;
			case SLOWEST:	return 1024;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Converts a ZIP compression 1-10 scale index to compression level.
	 *
	 * @param __i The input scale.
	 * @return The compression level for the scale.
	 * @since 2018/11/10
	 */
	public static final CompressionLevel ofLevel(int __i)
	{
		switch (__i)
		{
			case 1:		return CompressionLevel.FASTEST;
			
			case 2:
			case 3:		return CompressionLevel.FASTER;
			
			case 4:
			case 5:		return CompressionLevel.FAST;
			
			case 6:
			case 7:		return CompressionLevel.SLOW;
			
			case 8:
			case 9:		return CompressionLevel.SLOWER;
			
			case 10:	return CompressionLevel.SLOWEST;
			
				// Out of range, so just treat as capped
			default:
				return (__i <= 0 ? CompressionLevel.FASTEST :
					CompressionLevel.SLOWEST);
		}
	}
}

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

package net.multiphasicapps.io;

import java.io.Closeable;

/**
 * This interface is used for compressed streams.
 *
 * @since 2017/08/22
 */
public interface CompressionStream
	extends Closeable
{
	/**
	 * Returns the number of compressed bytes which were read.
	 *
	 * @return The number of compressed bytes which were read.
	 * @since 2017/08/22
	 */
	long compressedBytes();
	
	/**
	 * Returns the number of uncompressed bytes which have been read.
	 *
	 * @return The number of read uncompressed bytes.
	 * @since 2017/08/22
	 */
	long uncompressedBytes();
}

Added modules/io/src/main/java/net/multiphasicapps/io/DataEndianess.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This can be set on a stream which sets the default endianess on methods
 * that do not read using a specified endianess.
 *
 * @since 2016/07/10
 */
public enum DataEndianess
{
	/** Big endian. */
	BIG,
	
	/** Little endian. */
	LITTLE,
	
	/** End. */
	;
}

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

package net.multiphasicapps.io;

import java.io.InputStream;

/**
 * This interface is used to describe a compression stream which is used as
 * input.
 *
 * @since 2017/08/22
 */
public abstract class DecompressionInputStream
	extends InputStream
	implements CompressionStream
{
	/**
	 * If the decompression algorithm has a means or flag to indicate that
	 * there is no more compressed data and that the end of stream has been
	 * reached then this should return {@code true}.
	 *
	 * If it is unknown whether it can be detected or not, then {@code false}
	 * should be returned.
	 *
	 * @return {@code true} if this algorithm detects the end of file before
	 * the end of the actual input source, otherwise if only the end of the
	 * file causes EOF to be returned then this returns {@code false}. If it
	 * is not known then {@code false} must be returned.
	 * @since 2017/08/22
	 */
	public abstract boolean detectsEOF();
}

Added modules/io/src/main/java/net/multiphasicapps/io/DeflaterOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is used to compress to standard deflate streams.
 *
 * Associated standards: https://www.ietf.org/rfc/rfc1951.txt.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/10
 */
public class DeflaterOutputStream
	extends OutputStream
	implements CompressionStream
{
	/** Stream to write compressed data to. */
	protected final OutputStream out;
	
	/** The block size to compress for. */
	private final int _blocksize;
	
	/** The bytes to process first. */
	private final byte[] _fill;
	
	/** The number of bytes in the fill. */
	private int _fillbytes;
	
	/** Has this been closed? */
	private boolean _closed;
	
	/** Compressed bytes. */
	private long _ncompressed;
	
	/** Uncompressed bytes. */
	private long _nuncompressed;
	
	/** The temporary bits for output. */
	private int _wout;
	
	/** The number to bits available to the output. */
	private int _wbits;
	
	/**
	 * Initializes the deflation stream.
	 *
	 * @param __os The output stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public DeflaterOutputStream(OutputStream __os)
		throws NullPointerException
	{
		this(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Initializes the deflation stream.
	 *
	 * @param __os The output stream.
	 * @param __cl The compression level to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public DeflaterOutputStream(OutputStream __os, CompressionLevel __cl)
		throws NullPointerException
	{
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		this.out = __os;
		
		// Process data by blocks for efficiency
		int blocksize = __cl.blockSize();
		this._fill = new byte[blocksize];
		this._blocksize = blocksize;
		
		// Since compression is not actually implemented, say it should
		// actually be done here!
		todo.TODO.note("Implement fixed and dynamic huffman!");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Only close once!
		if (!this._closed)
		{
			// Is closed
			this._closed = true;
			
			// Process any fill remaining so it gets compressed
			if (this._fillbytes > 0)
				this.__processFill();
			
			// Mark final block
			this.__bitOut(1, 1, false);
			
			// Fixed huffman
			this.__bitOut(InflaterInputStream._TYPE_FIXED_HUFFMAN, 2, false);
			
			// Write code 256 which means to end processing the data, this
			// is just 0b000 + 0b0000 for the offset value
			this.__bitOut(0b000_0000, 7, true);
			
			// Pad to 8 bytes so partial bits for the end are not lost
			this.__bitPad(8);
			
			// Perform final flushing before closing to make sure everything
			// is written
			this.__bitFlush();
			this.flush();
		}
		
		// We need to pass close to the wrapped stream
		this.out.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final long compressedBytes()
	{
		return this._ncompressed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// Flush all the bits
		this.__bitFlush();
		
		// Then flush the stream itself
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final long uncompressedBytes()
	{
		return this._nuncompressed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Just forward write call since it is easier
		this.write(new byte[]{(byte)__b}, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		byte[] fill = this._fill;
		int blocksize = this._blocksize,
			fillbytes = this._fillbytes;
		
		// Write into the fill buffer, but do fill in chunks since that is
		// more optimized
		boolean addedfill = false;
		while (__l > 0)
		{
			// We can only fit so many bytes in the fill before it is full
			int leftinfill = blocksize - fillbytes;
			if (__l < leftinfill)
				leftinfill = __l;
			
			// Copy bytes into the fill
			for (int i = 0; i < leftinfill; i++)
				fill[fillbytes++] = __b[__o++];
			
			// Length is dropped by the fill
			__l -= leftinfill;
			
			// Process entire block of bytes
			if (fillbytes == blocksize)
			{
				// Need to store the number of bytes written before we
				// continue
				this._fillbytes = fillbytes;
				this.__processFill();
				
				// Since the entire fill was drained, this would have been
				// reset
				fillbytes = 0;
			}
			
			// Fill would have been added, so need to say that there are
			// bytes in here currently
			else
				addedfill = true;
		}
		
		// These original bytes were added
		this._nuncompressed += __l;
		
		// Bytes were added to the fill, record those
		if (addedfill)
			this._fillbytes = fillbytes;
	}
	
	/**
	 * Flushes the input bits to the output stream.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/11/01
	 */
	final void __bitFlush()
		throws IOException
	{
		// Only write if there are enough bits to write
		int wbits = this._wbits;
		if (wbits >= 8)
		{
			OutputStream out = this.out;
			int wout = this._wout;
			long ncompressed = this._ncompressed;
			
			// Send to the output
			while (wbits >= 8)
			{
				// Send to output
				out.write(wout & 0xFF);
				
				// Clip down
				wout >>>= 8;
				wbits -= 8;
				
				// Single byte was written
				ncompressed++;
			}
			
			// Store new values
			this._wbits = wbits;
			this._wout = wout;
			this._ncompressed = ncompressed;
		}
	}
	
	/**
	 * Writes the specified bits to the output.
	 *
	 * @param __v The value to write.
	 * @param __n The number of bits to store.
	 * @param __msb Is the most significant bit first?
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __bitOut(int __v, int __n, boolean __msb)
		throws IOException
	{
		// If writing with the most significant bit first, flip
		if (__msb)
			__v = Integer.reverse(__v) >>> (32 - __n);
		
		// Bit storage
		int wout = this._wout,
			wbits = this._wbits;
		
		// Need to mask off so sign values do not mess anything up above
		int mask = (1 << __n) - 1;
		
		// Add the new value to the top of the bits
		wout |= (__v & mask) << wbits;
		wbits += __n;
		
		// Store for next cycle (or out flush)
		this._wout = wout;
		this._wbits = wbits;
		
		// There are too many bits in the output, so send them to the stream
		// accordingly
		if (wbits >= 24)
			this.__bitFlush();
	}
	
	/**
	 * Pads the output bits the given number.
	 *
	 * @param __n The number of bits to pad to.
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __bitPad(int __n)
		throws IOException
	{
		// If we have two bits 0b00 and we pad to 8 we want 0b00000000 then
		// we add six extra bits. But if we are at 8 already we just keep
		// it as is. In this code wbits is 2, pad is 8... 2 % 8 is 2, then
		// we just take 2 from 8 and we get 6.
		int wbits = this._wbits,
			rem = wbits % __n;
		this._wbits = wbits + (__n - rem);
	}
	
	/**
	 * Processes the bytes which are in the fill buffer.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __processFill()
		throws IOException
	{
		// Get fill parameters
		byte[] fill = this._fill;
		int fillbytes = this._fillbytes;
		
		// Determine the best way to handle this block
		int hufftype = 0;
		
		// Compress with fixed table
		if (hufftype == 1)
		{
			throw new todo.TODO();
		}
		
		// Compress with dynamically generated table
		else if (hufftype == 2)
		{
			throw new todo.TODO();
		}
		
		// No compression used
		else
		{
			// Write all the bytes with no compression at all
			// Write no-compression marker, stream not ended yet
			this.__bitOut(0, 1, false);
			this.__bitOut(InflaterInputStream._TYPE_NO_COMPRESSION, 2, false);
			
			// Pad because byte boundary
			this.__bitPad(8);
			
			// Length and complement of that
			this.__bitOut(fillbytes, 16, false);
			this.__bitOut(fillbytes ^ 0xFFFF, 16, false);
			
			// Then write every individual byte
			for (int i = 0; i < fillbytes; i++)
				this.__bitOut(fill[i], 8, false);
		}
		
		// Remove the fill
		this._fillbytes = 0;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/DynamicHistoryInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is an input stream which allows any future data in the stream to be
 * cached for later actual reading. This class should be used in situations
 * where it is needed to read future bytes in the stream and react to those
 * bytes.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public class DynamicHistoryInputStream
	extends InputStream
{
	/** The backing buffer. */
	protected final ByteDeque buffer;
	
	/** The source input stream. */
	protected final InputStream input;
	
	/** Closed? */
	private volatile boolean _closed;
	
	/** EOF reached? */
	private volatile boolean _eof;
	
	/**
	 * Initializes a dynamic history stream which sources data from the given
	 * input stream.
	 *
	 * @param __is The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public DynamicHistoryInputStream(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.input = __is;
		this.buffer = new ByteDeque();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public void close()
		throws IOException
	{
		// Close
		this._closed = true;
		
		// Clear the buffer since it is not needed
		this.buffer.clear();
		
		// Close wrapped stream
		this.input.close();
	}
	
	/**
	 * Grabs the specified number of bytes and loads them into an internal
	 * queue where they may then be obtained using another method. 
	 *
	 * @param __i The number of bytes to read ahead and buffer.
	 * @return The number of bytes which are available for input, this may
	 * be less than or greater than the input parameter.
	 * @throws IndexOutOfBoundsException If the count is negative.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public int grab(int __i)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0m A negative number of bytes cannot be
		// grabbed. (The number of bytes to grab)}
		if (__i < 0)
			throw new IndexOutOfBoundsException(String.format("BD0m %s", __i));
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0n Cannot grab bytes because the stream
		// is closed.}
		if (this._closed)
			throw new IOException("BD0n");
		
		// Already have this number of bytes grabbed
		int cursize = buffer.available();
		if (__i <= cursize)
			return cursize;
		
		// The number of bytes that need to be read
		int diff = __i - cursize;
		
		// Read them from the input
		byte[] qq = new byte[diff];
		int total = 0;
		while (total < diff)
		{
			// Read in bytes
			int rc = this.input.read(qq);
		
			// If EOF was read, stop
			if (rc < 0)
				break;
		
			// Add them to the end of the buffer
			buffer.addLast(qq, 0, rc);
		
			// The number of available bytes is the current and the read
			// count
			total += rc;
		}
		
		// Read total
		return cursize + total;
	}
	
	/**
	 * Reads a single byte that is ahead of the current read position.
	 *
	 * @param __a The position of the byte ahead of the current read position
	 * to read.
	 * @return The read value or a negative value if the byte to be read
	 * exceeds the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public int peek(int __a)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0o Cannot a peek byte which have already been
		// read. (The requested index)}
		if (__a < 0)
			throw new IndexOutOfBoundsException(String.format("BD0o %d", __a));
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0p Cannot peek a single byte because the
		// stream is closed.}
		if (this._closed)
			throw new IOException("BD0p");
		
		// Grab bytes, stop if none are available
		int avail = this.grab(__a + 1);
		if (avail < __a)
			return -1;
		
		throw new todo.TODO();
	}
	
	/**
	 * Reads multiple bytes which are ahead of the current read position.
	 *
	 * @param __a The start position of the bytes ahead of the current read
	 * position.
	 * @param __b The array which receives the bytes being read.
	 * @return The number of bytes read or a negative value if there are no
	 * bytes to be read because they exceed the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public int peek(int __a, byte[] __b)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.peek(__a, __b, 0, __b.length);
	}
	
	/**
	 * Reads multiple bytes which are ahead of the current read position.
	 *
	 * @param __a The start position of the bytes ahead of the current read
	 * position.
	 * @param __b The array which receives the bytes being read.
	 * @param __o The starting offset into the array to write into.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read or a negative value if there are no
	 * bytes to be read because they exceed the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative; or the offset and or length exceed the array size.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public int peek(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// {@squirreljme.error BD0q Cannot peek bytes which have already been
		// read. (The requested index)}
		if (__a < 0)
			throw new IndexOutOfBoundsException(String.format("BD0q %d", __a));
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0r Cannot peek multiple bytes because
		// the stream is closed.}
		if (this._closed)
			throw new IOException("BD0r");
		
		// Grab bytes, stop if none are available
		int avail = this.grab(__a + __l);
		if (avail < __a)
			return -1;
		
		// Not reading anything?
		int rc = Math.min(__l, avail);
		if (rc < 0)
			return 0;
		
		// Read from the buffer
		buffer.get(__a, __b, __o, rc);
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read()
		throws IOException
	{
		// {@squirreljme.error BD0s Cannot read a single byte because the
		// stream has been closed.}
		if (this._closed)
			throw new IOException("BD0s");
		
		// Grab a single byte
		int gc = this.grab(1);
		
		// Nothing left
		if (gc <= 0)
			return -1;
		
		// Read single byte
		return (this.buffer.removeFirst() & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme BI08 Cannot read multiple bytes because the
		// stream is closed.}
		if (this._closed)
			throw new IOException("BI08");
		
		// Grab multiple bytes
		int gc = this.grab(__l);
		
		// Nothing left?
		if (gc <= 0)
			return -1;
		
		// No bytes to read?
		int dc = Math.min(gc, __l);
		if (dc <= 0)
			return 0;
		
		// Remove the early bytes
		buffer.removeFirst(__b, __o, dc);
		return dc;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/ExtendedDataInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

/**
 * This is an extended input stream which is better suited for general binary
 * data file reading compared to the standard {@link DataInputStream}.
 *
 * Streams default to big endian.
 *
 * @since 2016/07/10
 */
public class ExtendedDataInputStream
	extends InputStream
	implements DataInput, SettableEndianess, SizedStream
{
	/** The original input stream. */
	protected final DataInputStream input;
	
	/** Is mark supported? */
	protected final boolean canmark;
	
	/** The target endianess. */
	private volatile DataEndianess _endian =
		DataEndianess.BIG;
	
	/** The number of bytes read. */
	private volatile long _count;
	
	/** The mark start position. */
	private volatile long _markstart =
		-1L;
	
	/** The mark end position. */
	private volatile long _markend =
		-1L;
	
	/**
	 * Initializes the extended input stream.
	 *
	 * @param __is The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/10
	 */
	public ExtendedDataInputStream(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		DataInputStream w;
		this.input = (w = ((__is instanceof DataInputStream) ?
			(DataInputStream)__is : new DataInputStream(__is)));
		
		// Need to know if marking is supported
		this.canmark = w.markSupported();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int available()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void close()
		throws IOException
	{
		this.input.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public DataEndianess getEndianess()
	{
		return this._endian;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void mark(int __rl)
	{
		// Nothing to mark or not supported? Do nothing
		if (__rl <= 0 || !this.canmark)
			return;
		
		// Mark the sub-stream
		this.input.mark(__rl);
		
		// Start marker count
		long count = this._count;
		this._markstart = count;
		this._markend = count + __rl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public boolean markSupported()
	{
		return this.canmark;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.input.read();
		
		// Increase count if not EOF
		if (rv >= 0)
			this._count++;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read(byte[] __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public boolean readBoolean()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public byte readByte()
		throws IOException
	{
		// Read value
		int rv = this.read();
		
		// {@squirreljme.error BD0t End of file reached.}
		if (rv < 0)
			throw new EOFException("BD0t");
		
		// Cast
		return (byte)rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public char readChar()
		throws IOException
	{
		return (char)this.readShort();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public double readDouble()
		throws IOException
	{
		return Double.longBitsToDouble(this.readLong());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public float readFloat()
		throws IOException
	{
		return Float.intBitsToFloat(this.readInt());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void readFully(byte[] __b)
		throws IOException
	{
		this.readFully(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void readFully(byte[] __b, int __o, int __l)
		throws IOException
	{
		this.input.readFully(__b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readInt()
		throws IOException
	{
		// Read
		int val = this.input.readInt();
		
		// Increase read count
		this._count += 4; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Integer.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Reads the next line of bytes, treating them as characters (0-255).
	 *
	 * Reading stops when a newline is encountered, which is discarded from
	 * the input.
	 *
	 * If a carriage return is read then if the next character is a newline,
	 * they are both discarded, otherwise the carriage return is discarded.
	 * Reading stops in either case.
	 *
	 * @return The read line or {@code null} if the end of file was reached
	 * before any bytes were read.
	 * @throws IOException On read errors.
	 * @since 2016/09/18
	 */
	public String readLine()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long readLong()
		throws IOException
	{
		// Read
		long val = this.input.readLong();
		
		// Increase read count
		this._count += 8; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Long.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public short readShort()
		throws IOException
	{
		// Read
		short val = this.input.readShort();
		
		// Increase read count
		this._count += 2; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Short.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readUnsignedByte()
		throws IOException
	{
		return this.readByte() & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readUnsignedShort()
		throws IOException
	{
		return this.readShort() & 0xFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public String readUTF()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void reset()
		throws IOException
	{
		// {@squirreljme.error BD0u The stream has not been marked.}
		long markstart = this._markstart;
		if (markstart < 0)
			throw new IOException("BD0u");
		
		// {@squirreljme.error BD0v Exceeded the number of bytes specified by
		// mark.}
		long count = this._count;
		long markend = this._markend;
		if (count > markend)
			throw new IOException("BD0v");
		
		// Call reset
		this.input.reset();
		
		// Reset the current count to the start of the mark
		this._count = markstart;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public DataEndianess setEndianess(DataEndianess __end)
	{
		// Check
		if (__end == null)
			throw new NullPointerException("NARG");
		
		// Get and set
		DataEndianess rv = this._endian;
		this._endian = __end;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long size()
	{
		return this._count;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long skip(long __n)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int skipBytes(int __n)
		throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/ExtendedDataOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an extended output stream which is better suited to writing
 * general binaries compared to the standard {@link DataOutputStream}.
 *
 * Streams default to big endian.
 *
 * This class is not thread safe.
 *
 * {@squirreljme.error BD0w Unhandled endianess. (The endianess)}
 *
 * @since 2016/07/10
 */
public class ExtendedDataOutputStream
	extends OutputStream
	implements DataOutput, SettableEndianess, SizedStream
{
	/** The output data stream. */
	protected final DataOutputStream output;
	
	/** The target endianess. */
	private volatile DataEndianess _endian =
		DataEndianess.BIG;
	
	/** The current file size. */
	private volatile long _size;
	
	/**
	 * Initializes the extended data output stream.
	 *
	 * @param __os The stream to write data to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/10
	 */
	public ExtendedDataOutputStream(OutputStream __os)
		throws NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = ((__os instanceof DataOutputStream) ?
			(DataOutputStream)__os : new DataOutputStream(__os));
	}
	
	/**
	 * Aligns the output to the given number of bytes.
	 *
	 * @param __n The number of bytes to align to.
	 * @throws IndexOutOfBoundsException If the alignment amount is zero or
	 * negative.
	 * @throws IOException On write errors.
	 * @since 2016/09/11
	 */
	public void align(int __n)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0x Cannot align to zero or a negative
		// amount.}
		if (__n <= 0)
			throw new IndexOutOfBoundsException("BD0x");
		
		// Pad
		while ((this.size() % __n) != 0)
			this.write(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void close()
		throws IOException
	{
		this.output.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void flush()
		throws IOException
	{
		this.output.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final DataEndianess getEndianess()
	{
		return this._endian;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final DataEndianess setEndianess(DataEndianess __end)
		throws NullPointerException
	{
		// Check
		if (__end == null)
			throw new NullPointerException("NARG");
		
		// Get and set
		DataEndianess rv = this._endian;
		this._endian = __end;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final long size()
	{
		return this._size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Write
		this.output.write(__b, __o, __l);
		
		// Add size
		this._size += __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		this.output.write(__b);
		this._size++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeBoolean(boolean __v)
		throws IOException
	{
		this.writeByte((__v ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeByte(int __v)
		throws IOException
	{
		this.output.write(__v);
		this._size++;
	}
	
	/**
	 * Writes a single byte, if its value is out of range then a write error
	 * occurs.
	 *
	 * @param __v The byte to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeByteExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD0y Byte value out of range.}
		if (__v < -128 || __v > 127)
			throw new IOException("BD0y");
		
		this.writeByte(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeBytes(String __s)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeChar(int __v)
		throws IOException
	{
		this.writeShort(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeChars(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Write all characters
		int n = __s.length();
		for (int i = 0; i < n; i++)
			this.writeShort(__s.charAt(i));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeDouble(double __v)
		throws IOException
	{
		this.writeLong(Double.doubleToRawLongBits(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeFloat(float __v)
		throws IOException
	{
		this.writeInt(Float.floatToRawIntBits(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeInt(int __v)
		throws IOException
	{
		// Depends on the endian
		DataOutputStream output = this.output;
		DataEndianess endian = this._endian;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeInt(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeInt(Integer.reverseBytes(__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04 %s", endian));
		}
		
		// Increase
		this._size += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeLong(long __v)
		throws IOException
	{
		// Depends on the endianess
		DataEndianess endian = this._endian;
		DataOutputStream output = this.output;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeLong(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeLong(Long.reverseBytes(__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04 %s", endian));
		}
		
		// Increase
		this._size += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeShort(int __v)
		throws IOException
	{
		// Depends on the endian
		DataEndianess endian = this._endian;
		DataOutputStream output = this.output;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeShort(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeShort(Short.reverseBytes((short)__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04 %s", endian));
		}
		
		// Increase
		this._size += 2;
	}
	
	/**
	 * Writes a single short, if its value is out of range then a write error
	 * occurs.
	 *
	 * @param __v The short to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeShortExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD0z Short value out of range.}
		if (__v < -32768 || __v > 32767)
			throw new IOException("BD0z");
		
		this.writeShort(__v);
	}
	
	/**
	 * Writes a single unsigned byte, if its value is out of range then a
	 * write error occurs.
	 *
	 * @param __v The unsigned byte to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeUnsignedByteExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD10 Unsigned byte value out of range.}
		if (__v < 0 || __v > 255)
			throw new IOException("BD10");
		
		this.writeByte(__v);
	}
	
	/**
	 * Writes a single unsigned byte, if its value is out of range then a
	 * write error occurs.
	 *
	 * @param __v The unsigned short to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeUnsignedShortExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD11 Unsigned short value out of range.}
		if (__v < 0 || __v > 65535)
			throw new IOException("BD11");
		
		this.writeShort(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeUTF(String __s)
		throws IOException
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.io;

/**
 * This interface is used for classes which can get their endianess obtained.
 *
 * @since 2016/08/11
 */
public interface GettableEndianess
{
	/**
	 * Obtains the current default endianess of the data.
	 *
	 * @return The current endianess.
	 * @since 2016/07/10
	 */
	DataEndianess getEndianess();
}

Added modules/io/src/main/java/net/multiphasicapps/io/HexDumpOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Writer;

/**
 * This contains a stream which when given bytes hexadecimal bytes will
 * output to the given stream.
 *
 * Closing this stream does not close the dumping stream, it only closes the
 * piped stream if one is used.
 *
 * @since 2016/08/12
 */
public class HexDumpOutputStream
	extends OutputStream
{
	/** The number of columns to print. */
	private static final int _COLUMNS =
		16;
	
	/** Where to pipe data to. */
	protected final OutputStream pipe;
	
	/** Where to write characters to. */
	protected final Writer dump;
	
	/** The write queue. */
	private final byte[] _queue =
		new byte[HexDumpOutputStream._COLUMNS];
	
	/** The current write position. */
	private volatile int _at;
	
	/**
	 * Initializes dumping to the given stream.
	 *
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(PrintStream __dump)
		throws NullPointerException
	{
		this(new PrintStreamWriter(__dump));
	}
	
	/**
	 * Initializes dumping to the given stream.
	 *
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(Writer __dump)
		throws NullPointerException
	{
		// Check
		if (__dump == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.pipe = null;
		this.dump = __dump;
	}
	
	/**
	 * Initializes dumping to the given stream and also copying them to
	 * another stream to act as a pipe.
	 *
	 * @param __pipe The stream to copy bytes to.
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(OutputStream __pipe, PrintStream __dump)
		throws NullPointerException
	{
		this(__pipe, new PrintStreamWriter(__dump));
	}
	
	/**
	 * Initializes dumping to the given stream and also copying them to
	 * another stream to act as a pipe.
	 *
	 * @param __pipe The stream to copy bytes to.
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(OutputStream __pipe, Writer __dump)
		throws NullPointerException
	{
		// Check
		if (__pipe == null || __dump == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.pipe = __pipe;
		this.dump = __dump;
	}
	
	/**
	 * {@inheritDoc}
	 *
	 * The stream to dump to is not closed.
	 *
	 * @since 2016/08/12
	 */
	@Override
	public void close()
		throws IOException
	{
		// Force printing of bytes
		this.__printLine();
		
		// Only close the pipe and not the dump
		Closeable c = this.pipe;
		if (c != null)
			c.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void flush()
		throws IOException
	{
		// Flush the forward pipe
		this.pipe.flush();
		
		// And the dump
		this.dump.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		// Write a single byte
		int cols = HexDumpOutputStream._COLUMNS;
		byte b = (byte)__b;
		byte[] queue = this._queue;
		int at = this._at;
		try
		{
			// Write to the queue
			queue[at++] = b;
			this._at = at;
			
			// Send to the output
			OutputStream pipe = this.pipe;
			if (pipe != null)
				pipe.write(__b);
		}
		
		// Check if a row is to be printed
		finally
		{
			// Print entire row
			if (at == cols)
				this.__printLine();
		}
	}
	
	/**
	 * Prints a hexdumpped line.
	 *
	 * @throws IOException If it could not be written.
	 * @since 2016/08/12
	 */
	private void __printLine()
		throws IOException
	{
		// Might not always work
		int cols = HexDumpOutputStream._COLUMNS;
		byte[] queue = this._queue;
		int at = this._at;
		try
		{
			Writer w = this.dump;
			
			// Print starting hex data
			for (int i = 0; i < cols; i++)
			{
				// Padding
				if (i > 0)
				{
					w.write(' ');
				
					// Extra space?
					if ((i & 3) == 0)
						w.write(' ');
				}
				
				// No data?
				if (i >= at)
				{
					w.write("  ");
					continue;
				}
				
				// Write both bytes
				int x = queue[i] & 0xFF;
				w.write(Character.forDigit(((x >>> 4) & 0xF), 16));
				w.write(Character.forDigit((x & 0xF), 16));
			}
			
			// Print ASCII version of it
			w.write("  |");
			for (int i = 0; i < cols; i++)
			{
				// No data?
				if (i >= at)
					break;	
				
				// Only print in the range of ASCII
				char c = (char)(queue[i] & 0xFF);
				if (c < ' ' || c > 0x7E)
					c = '.';
				
				w.write(c);
			}
			w.write('|');
			w.write('\n');
		}
	
		// Always clear the position
		finally
		{
			this._at = 0;
		}
	}
	
	/**
	 * Dumps the resulting input stream to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __in The stream to dump.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/021
	 */
	public static final boolean dump(PrintStream __dump, InputStream __in)
		throws NullPointerException
	{
		if (__dump == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Open dump output
		try (HexDumpOutputStream hdos = new HexDumpOutputStream(__dump))
		{
			byte[] buf = new byte[24];
			for (;;)
			{
				int rc = __in.read(buf);
				
				if (rc < 0)
					break;
				
				hdos.write(buf, 0, rc);
			}
		}
		
		// Failed
		catch (IOException e)
		{
			return false;
		}
		
		// Okay
		return true;
	}
	
	/**
	 * Dumps the resulting byte array to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __b The byte array to dump.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/26
	 */
	public static final boolean dump(PrintStream __dump, byte[] __b)
		throws NullPointerException
	{
		if (__dump == null || __b == null)
			throw new NullPointerException("NARG");
		
		return HexDumpOutputStream.dump(__dump, __b, 0, __b.length);
	}	
	
	/**
	 * Dumps the resulting byte array to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __b The byte array to dump.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/26
	 */
	public static final boolean dump(PrintStream __dump, byte[] __b, int __o,
		int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__dump == null || __b == null)
			throw new NullPointerException("NARG");
		
		// Open dump output
		try (HexDumpOutputStream hdos = new HexDumpOutputStream(__dump))
		{
			hdos.write(__b, __o, __l);
		}
		
		// Failed
		catch (IOException e)
		{
			return false;
		}
		
		// Okay
		return true;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/HexInputStream.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 * This reads a stream of hexadecimal characters and converts it to a binary
 * input.
 *
 * @since 2016/05/15
 */
public class HexInputStream
	extends InputStream
{
	/** The source stream. */
	protected final Reader source;
	
	/** EOF? */
	private volatile boolean _eof;
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __s The source hex bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/15
	 */
	public HexInputStream(Reader __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.source = __s;
	}
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __is The source hex bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/25
	 */
	public HexInputStream(InputStream __is)
		throws NullPointerException
	{
		this(new InputStreamReader(__is));
	}
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __is The source hex bytes.
	 * @param __cs The character set used.
	 * @throws IOException If the character set is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/25
	 */
	public HexInputStream(InputStream __is, String __cs)
		throws IOException, NullPointerException
	{
		this(new InputStreamReader(__is, __cs));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/15
	 */
	@Override
	public void close()
		throws IOException
	{
		// Always set EOF
		this._eof = true;
		
		// Close it
		this.source.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/15
	 */
	@Override
	public int read()
		throws IOException
	{
		// EOF?
		if (this._eof)
			return -1;
		
		// Read the high value
		int hi = -1;
		while (hi < 0)
		{
			// Read 
			int c = this.source.read();
			
			// EOF?
			if (c < 0)
				return -1;
			
			// Try a digit
			hi = Character.digit((char)c, 16);
		}
		
		// Read the low value
		int lo = -1;
		while (lo < 0)
		{
			// Read 
			int c = this.source.read();
			
			// EOF?
			if (c < 0)
				return -1;
			
			// Try a digit
			lo = Character.digit((char)c, 16);
		}
		
		// Merge together
		return (hi << 4) | lo;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/HuffmanTreeInt.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.util.NoSuchElementException;

/**
 * This represents a mutable huffman tree.
 * 
 * This class is not thread safe.
 *
 * Iteration of values goes through the internal value table in no particular
 * order. The iterator is fail-fast.
 *
 * {@squirreljme.error BD12 The huffman tree was modified in the middle of
 * iteration.}
 *
 * @since 2016/03/10
 */
public class HuffmanTreeInt
{
	/** The huffman table. */
	private volatile int[] _table;
	
	/** Stored tree values. */
	private volatile int[] _values;
	
	/** Modification count. */
	private volatile int _modcount;
	
	/** Maximum used bits. */
	private volatile int _maxbits;
	
	/**
	 * Initializes a basic blank huffman tree.
	 *
	 * @since 2016/03/10
	 */
	public HuffmanTreeInt()
	{
		// Initially add table space so that it is always initially valid but
		// points to nothing.
		this.__addTableSpace();
	}
	
	/**
	 * Adds the specified object which is associated with the given symbol
	 * and mask.
	 *
	 * @param __v The value to add.
	 * @param __sym The bit representation of the symbol.
	 * @param __mask The mask of the symbol for its valid bits.
	 * @return The old value, or {@code null} if it is not set.
	 * @throws IllegalArgumentException If the specified symbol contains a bit
	 * which is outside of the mask or the mask does not start at shift zero
	 * or has zero gaps.
	 * @since 2016/03/28
	 */
	public final int add(int __v, int __sym, int __mask)
		throws IllegalArgumentException
	{
		// Number of bits in the mask
		int ibm = Integer.bitCount(__mask);
		
		// Check mask and representation
		// {@squirreljme.error BD13 The symbol exceeds the range of the mask.
		// (The value; The mask)}
		if ((__sym & (~__mask)) != 0)
			throw new IllegalArgumentException(String.format("BD13 %x %x",
				__sym, __mask));
		// {@squirreljme.error BD14 The mask has a zero gap between bits or
		// at the least significant end. (The value; The mask)}
		if (ibm != (32 - Integer.numberOfLeadingZeros(__mask)) ||
			(__mask & 1) == 0)
			throw new IllegalArgumentException(String.format("BD14 %x %x",
				__sym, __mask));
		
		// Get the table
		int[] table = this._table;
		int n = table.length;
		
		// Increase max bit count
		this._maxbits = Math.max(this._maxbits, ibm);
		
		// Find the spot to add it based on the bit depth
		int at = 0;
		for (int sh = (1 << (ibm - 1)); sh != 0; sh >>>= 1)
		{
			// Last bit set?
			boolean last = (sh == 1);
			
			// The array index to look at for the current position depends
			// on which bit is set
			int q = (((__sym & sh) != 0) ? 1 : 0);
			
			// Get the jump value
			int jump = table[at + q];
			
			// If this points to a constant area but this is not the last
			// bit, then trash it.
			if (!last && jump < 0)
			{
				jump = Integer.MAX_VALUE;
				table[at + q] = jump;
			}
			
			// Jumps off the table end? Needs more values to be added for
			// the tree to be built
			if (jump == Integer.MAX_VALUE)
			{
				// If this is the last entry then a value index needs to
				// be created to store the value
				if (last)
				{
					// Add space for a new variable
					int vat = this.__addValueSpace();
					
					// Place value there
					this._values[vat] = __v;
					
					// Set table index to point there
					table[at + q] = -(vat + 1);
					
					// Modified
					this._modcount++;
					
					// No old value exists
					return 0;
				}
				
				// Otherwise, add some table space and jump to that
				// instead on the next run.
				else
				{
					// Add new location info
					int jat = this.__addTableSpace();
				
					// Correct vars
					table = this._table;
					n = table.length;
				
					// Set jump to that position
					// Use that position instead on the next read
					table[at + q] = at = jat;
				}
			}
			
			// Points to a constant area, return a value
			else if (jump < 0)
			{
				// Calculate actual placement
				int vat = (-jump) - 1;
				
				// Get old value
				int[] vals = this._values;
				int old = vals[vat];
				
				// Set new value
				vals[vat] = __v;
				
				// Modified
				this._modcount++;
				
				// Return the old value
				return old;
			}
			
			// Points to another location in the array
			else
				at = jump;
		}
		
		// Should not occur
		throw new todo.OOPS();
	}
	
	/**
	 * Clears the huffman tree.
	 *
	 * @since 2017/02/25
	 */
	public void clear()
	{
		// Reset parameters
		this._table = null;
		this._values = null;
		this._modcount = 0;
		this._maxbits = 0;
		
		// Setup initial tree
		this.__addTableSpace();
	}
	
	/**
	 * Finds the bit sequence associated with the given value.
	 *
	 * @param __i The value to find the sequence for the given bit pattern.
	 * @return A {@code long} where the upper 32-bits is the bit mask while
	 * the lower 32-bits are the symbol.
	 * @throws NoSuchElementException If no sequence was found.
	 * @since 2016/08/24
	 */
	public final long findSequence(int __i)
		throws NoSuchElementException
	{
		// Get values
		int[] vals = this._values;
		
		// No values? nothing will ever be found
		if (vals == null)
			throw new NoSuchElementException("NSEE");
		
		// Look through all values
		int n = vals.length;
		for (int i = 0; i < n; i++)
			if (vals[i] == __i)
				return this.__recursiveMatch(0, 0, 0, -(i + 1));
		
		// Not found
		throw new NoSuchElementException("NSEE");
	}
	
	/**
	 * Returns the value obtained via the given bit source.
	 *
	 * @param __bs The source for bits.
	 * @return The value.
	 * @throws IOException On read errors.
	 * @throws NoSuchElementException If no value was found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/16
	 */
	public final int getValue(BitSource __bs)
		throws IOException, NoSuchElementException, NullPointerException
	{
		// Check
		if (__bs == null)
			throw new NullPointerException("NARG");
		
		// Get the jump table
		int[] table = this._table;
		if (table == null)
			throw new NoSuchElementException("NSEE");
		
		// Try to find a value
		for (int at = 0;;)
		{
			// A value has been read?
			if (at < 0)
				return this._values[(-at) - 1];
			
			// {@squirreljme.error BD15 Key not found in tree.}
			else if (at == Integer.MAX_VALUE)
				throw new NoSuchElementException("BD15");
			
			// Set the new position to the table position
			at = table[at + (__bs.nextBit() ? 1 : 0)];
		}
	}
	
	/**
	 * Returns the maximum number of bits entries use.
	 *
	 * @return The maximum number of used bits.
	 * @since 2016/03/28
	 */
	public final int maximumBits()
	{
		return this._maxbits;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/10
	 */
	@Override
	public final String toString()
	{
		// Setup
		StringBuilder sb = new StringBuilder("[");
		
		// Add elements in no particular order
		int[] vals = this._values;
		if (vals != null)
		{
			int n = vals.length;
			for (int i = 0; i < n; i++)
			{
				// Comma?
				if (i > 0)
					sb.append(", ");
				
				// Begin sequence data
				sb.append('<');
				
				// Get the sequence of it
				int v = vals[i];
				int seq = -1;
				
				// Not found?
				if (seq == -1L)
					sb.append('?');
				
				// Print bit pattern otherwise
				else
				{
					// Get mask and value
					int msk = (int)(seq >>> 32L);
					int val = (int)(seq);
					
					// Start from the highest bit first
					int hib = Integer.bitCount(msk);
					for (int b = hib - 1; b >= 0; b--)
						sb.append(((0 == (val & (1 << b))) ? '0' : '1'));
				}
				
				// End sequence data
				sb.append(">=");
				
				// Add the value
				sb.append(v);
			}
		}
		
		// Build it
		sb.append(']');
		return sb.toString();
	}
	
	/**
	 * Adds more table space for a branch.
	 *
	 * @return The base index of the newly added space.
	 * @since 2016/03/28
	 */
	private int __addTableSpace()
	{
		// The returned value is the end of the table
		int[] table = this._table;
		int rv = (table == null ? 0 : table.length);
		
		// Allocate some extra space
		int[] becomes = new int[rv + 2];
		
		// Copy the old array over
		for (int i = 0; i < rv; i++)
			becomes[i] = table[i];
		
		// The end bits become invalidated
		becomes[rv] = Integer.MAX_VALUE;
		becomes[rv + 1] = Integer.MAX_VALUE;
		
		// Set new table
		this._table = becomes;
		
		// Return it
		return rv;
	}
	
	/**
	 * Adds more value space to add a new value.
	 *
	 * @return The index where the value space was increased.
	 * @since 2016/03/28
	 */
	private int __addValueSpace()
	{
		// The returned value is the end of the table
		int[] values = this._values;
		int rv = (values == null ? 0 : values.length);
		
		// Allocate some extra space
		int[] becomes = new int[rv + 1];
		
		// Copy the old array over
		for (int i = 0; i < rv; i++)
			becomes[i] = values[i];
		
		// Set new table
		this._values = becomes;
		
		// Return it
		return rv;
	}
	
	/**
	 * Searches the huffman tree for the given raw match value.
	 *
	 * @param __at The index to look at.
	 * @param __huf The huffman index.
	 * @param __mask The mask of the input value.
	 * @param __match The value to match.
	 * @return The bit mask and the value for the given entry or {@code -1L} if
	 * not found.
	 * @since 2016/03/28
	 */
	private long __recursiveMatch(int __at, int __huf, int __mask, int __match)
	{
		// Get tree
		int[] table = this._table;
		
		// Get the left and right side jump values
		int jl = table[__at];
		int jr = table[__at + 1];
		
		// Matches left or right side?
		boolean left = (jl == __match);
		if (left || jr == __match)
			return (((long)((__mask << 1) | 1)) << 32L) |
				((long)((__huf << 1) | (left ? 0 : 1)));
		
		// Traverse left side
		long rv;
		if (jl >= 0 && jl != Integer.MAX_VALUE)
		{
			rv = this.__recursiveMatch(jl, __huf << 1, (__mask << 1) | 1,
				__match);
			if (rv != -1L)
				return rv;
		}
		
		// Traverse right side
		if (jr >= 0 && jr != Integer.MAX_VALUE)
		{
			rv = this.__recursiveMatch(jr, (__huf << 1) | 1, (__mask << 1) | 1,
				__match);
			if (rv != 1L)
				return rv;
		}
		
		// Not found
		return -1L;
	}
}

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

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which is able to be indented on each new line.
 *
 * This class cannot handle indentation characters which are beyond the
 * standard ASCII range.
 *
 * @since 2018/05/14
 */
public final class IndentedOutputStream
	extends OutputStream
{
	/** The output stream to write to. */
	protected final OutputStream out;
	
	/** The indentation character. */
	private char _char;
	
	/** The indentation level. */
	private int _level;
	
	/** On a new line? */
	private boolean _newline =
		true;
	
	/**
	 * Initializes the indented output stream using tab as the indentation
	 * character.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public IndentedOutputStream(OutputStream __out)
		throws NullPointerException
	{
		this(__out, '\t');
	}
	
	/**
	 * Initializes the indented output stream.
	 *
	 * @param __out The stream to write to.
	 * @param __c The character to indent with.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public IndentedOutputStream(OutputStream __out, char __c)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
		this._char = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.out.close();
	}
	
	/**
	 * Decrements the indentation level.
	 *
	 * @since 2018/05/14
	 */
	public final void decrement()
	{
		int level = this._level;
		if (level > 0)
			this._level = level - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void flush()
		throws IOException
	{
		this.out.flush();
	}
	
	/**
	 * Increments the indentation level.
	 *
	 * @since 2018/05/14
	 */
	public final void increment()
	{
		int level = this._level;
		if (level < Integer.MAX_VALUE)
			this._level = level + 1;
	}
	
	/**
	 * Sets the level of indentation.
	 *
	 * @param __i The indentation level.
	 * @throws IllegalArgumentException If the level is negative.
	 * @since 2018/05/14
	 */
	public final void setLevel(int __i)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD16 Cannot set the indentation level to a
		// negative value.}
		if (__i < 0)
			throw new IllegalArgumentException("BD16");
		
		this._level = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		OutputStream out = this.out;
		
		// New-line will set the newline flag
		int actb = (__b & 0xFF);
		if (actb == '\r' || actb == '\n')
			this._newline = true;
		
		// Every other character will indent, if on a newline
		else if (this._newline)
		{
			// Clear flag to not indent again
			this._newline = false;
			
			// Indent using the given character
			char indentchar = this._char;
			for (int i = 0, n = this._level; i < n; i++)
				out.write(indentchar);
		}
		
		// Forward always, but use the original input
		out.write(__b);
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/InflaterInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.NoSuchElementException;

/**
 * This is used to decompress standard deflate compressed stream.
 *
 * Associated standards: https://www.ietf.org/rfc/rfc1951.txt.
 *
 * This class is not thread safe.
 *
 * @since 2017/02/24
 */
public class InflaterInputStream
	extends DecompressionInputStream
{
	/** The size of the sliding window. */
	private static final int _DEFAULT_SLIDING_WINDOW_SIZE =
		32768;
	
	/** No compression. */
	static final int _TYPE_NO_COMPRESSION =
		0b00;
	
	/** Fixed huffman table compression. */
	static final int _TYPE_FIXED_HUFFMAN =
		0b01;
	
	/** Dynamic huffman table compression. */
	static final int _TYPE_DYNAMIC_HUFFMAN =
		0b10;
	
	/** An error. */
	static final int _TYPE_ERROR =
		0b11;
	
	/** The maximum number of bits in the code length tree. */
	private static final int _MAX_BITS =
		15;
	
	/** Shuffled bit values when reading values. */
	private static final int[] _SHUFFLE_BITS =
		new int[]
		{
			16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
		};
	
	/** The deflated compressed stream to be decompressed. */
	protected final InputStream in;
	
	/** Sliding window for accessing old bytes. */
	protected final SlidingByteWindow window;
	
	/** If the output cannot be filled, bytes are written here instead. */
	protected final ByteDeque overflow =
		new ByteDeque();
	
	/** When bytes are read, a checkum will be calculated for it, optional. */
	protected final Checksum checksum;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** The read-in buffer which is used to bulk read input bytes. */
	private final byte[] _readin =
		new byte[4];
	
	/** The bit source for reading. */
	private final BitSource _bitsource =
		new __BitSource__();
	
	/**
	 * Raw code lengths (allocated once), the size is the max code length
	 * count.
	 */
	private final int[] _rawcodelens =
		new int[19];
	
	/**
	 * Raw literal and distances (allocated once), the size is the total of
	 * both the maximum length count and distance count.
	 */
	private final int[] _rawlitdistlens =
		new int[322];
	
	/** Used to store bit length counts. */
	private final int[] _blcount =
		new int[InflaterInputStream._MAX_BITS + 1];
	
	/** Used to store the next code. */
	private final int[] _nextcode =
		new int[InflaterInputStream._MAX_BITS + 1];
	
	/** The number of compressed bytes. */
	private long _compressedsize;
	
	/** The number of uncompressed bytes. */
	private long _uncompressedsize;
	
	/** The code length tree. */
	private Reference<HuffmanTreeInt> _codelentree;
	
	/** The literal tree. */
	private Reference<HuffmanTreeInt> _literaltree;
	
	/** The distance tree. */
	private Reference<HuffmanTreeInt> _distancetree;
	
	/** Window reader. */
	private Reference<byte[]> _readwindow;
	
	/**
	 * The miniature read window, it stores a 32-bit value and is given input
	 * bytes to read along with being used as output. This is an int because it
	 * is faster to work with integer values rather than bytes. It also means
	 * that it is much simpler to work with.
	 */
	private int _miniwindow;
	
	/** Represents the number of bits in the mini window. */
	private int _minisize;
	
	/** The output write window, this is used to shift out writes as needed. */
	private int _writewindow;
	
	/** The number of bits in the write window. */
	private int _writesize;
	
	/** EOF has been reached? */
	private boolean _eof;
	
	/** The target byte array for writes. */
	private byte[] _targ;
	
	/** The target offset for writes. */
	private int _targoff;
	
	/** The target end offset for writes. */
	private int _targend;
	
	/**
	 * Initializes the deflate compression stream inflater.
	 *
	 * @param __in The stream to inflate.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/24
	 */
	public InflaterInputStream(InputStream __in)
		throws NullPointerException
	{
		this(__in, InflaterInputStream._DEFAULT_SLIDING_WINDOW_SIZE);
	}
	
	/**
	 * Initializes the deflate compression stream inflater, an optional
	 * checksum calculator may be specified also.
	 *
	 * @param __in The stream to inflate.
	 * @param __cs The checksum.
	 * @throws NullPointerException On null arguments, except for {@code __cs}.
	 * @since 2017/02/24
	 */
	public InflaterInputStream(InputStream __in, Checksum __cs)
		throws NullPointerException
	{
		this(__in, InflaterInputStream._DEFAULT_SLIDING_WINDOW_SIZE, __cs);
	}
	
	/**
	 * Initializes the deflate compression stream inflater with a custom
	 * size specified for the sliding window.
	 *
	 * @param __in The stream to inflate.
	 * @param __sls Custom size to the sliding window.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/04
	 */
	public InflaterInputStream(InputStream __in, int __sls)
	{
		this(__in, __sls, null);
	}
	
	/**
	 * Initializes the deflate compression stream inflater with a custom
	 * size specified for the sliding window, an optional checksum calculator
	 * may be specified also.
	 *
	 * @param __in The stream to inflate.
	 * @param __sls Custom size to the sliding window.
	 * @param __checksum If not {@code null} then when bytes are read from this
	 * stream they will have their checksum calculated. The checksum is
	 * calculated on the uncompressed bytes.
	 * @throws NullPointerException On null arguments, except for
	 * {@code __checksum}.
	 * @since 2017/08/22
	 */
	public InflaterInputStream(InputStream __in, int __sls,
		Checksum __checksum)
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __in;
		this.window = new SlidingByteWindow(__sls);
		this.checksum = __checksum;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int available()
		throws IOException
	{
		// Use the number of bytes that are able to be read quickly without
		// requiring decompression
		return this.overflow.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public void close()
		throws IOException
	{
		// Close input
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		return this._compressedsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = this.read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int bl = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bl)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// If there are bytes in the overflow buffer, read them first into the
		// output because they are the result of previous decompression.
		ByteDeque overflow = this.overflow;
		int ovn = overflow.available(),
			ovr = (ovn < __l ? ovn : __l);
		int c = overflow.removeFirst(__b, __o, __l);
		
		// More bytes can be read from the input compressed data because the
		// overflow buffer has been emptied
		boolean eof = this._eof;
		if (!eof && c < __l)
		{
			// Store write information
			this._targ = __b;
		
			// Try to fit as many bytes as possible into the output
			while (c < __l)
			{
				// Decompress
				int base;
				this._targoff = (base = __o + c);
				this._targend = base + (__l - c);
				int rv = this.__decompress();
			
				// Ended?
				if (rv < 0)
				{
					this._eof = true;
					break;
				}
			
				// Otherwise add those bytes
				c += rv;
			}
		}
		
		// Calculate CRC for this output data
		Checksum checksum = this.checksum;
		if (checksum != null)
			checksum.offer(__b, __o, c);
		
		// Count uncompressed size
		if (c > 0)
			this._uncompressedsize += c;
		
		// Return the read count or end of file if the end of the stream has
		// been reached
		// But never leave bytes waiting in the overflow buffer ever
		return (c == 0 && eof && overflow.isEmpty() ? -1 : c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._uncompressedsize;
	}
	
	/**
	 * Reads the input and performs decompression on the data.
	 *
	 * @return The number of stored bytes or a negative value if the stream
	 * has terminated.
	 * @throws IOException On read or decompression errors.
	 * @since 2017/02/25
	 */
	private int __decompress()
		throws IOException
	{
		// Do nothing on EOF
		if (this._eof)
			return -1;
		
		// The target offset on entry
		int enteroff = this._targoff;
		
		// Read the final bit which determines if this is the last block
		int finalhit = this.__readBits(1, false);
		
		// Read the window type
		int type = this.__readBits(2, false);
		switch (type)
		{
				// None
			case InflaterInputStream._TYPE_NO_COMPRESSION:
				this.__decompressNone();
				break;
				
				// Fixed huffman
			case InflaterInputStream._TYPE_FIXED_HUFFMAN:
				this.__decompressFixed();
				break;
				
				// Dynamic huffman
			case InflaterInputStream._TYPE_DYNAMIC_HUFFMAN:
				this.__decompressDynamic();
				break;
			
				// Error or unknown
			case InflaterInputStream._TYPE_ERROR:
			default:
				// {@squirreljme.error BD17 Unknown type or the error type
				// was reached. (The type code used in the stream)}
				throw new IOException(String.format("BD17 %d", type));
		}
		
		// If this was the last block to read, then return EOF if no data
		// was actually read, but mark EOF otherwise
		int rv = (this._targoff - enteroff);
		if (finalhit != 0)
		{
			this._eof = true;
			return (rv == 0 ? -1 : rv);
		}
		
		// Just the read count
		else
			return rv;
	}
	
	/**
	 * Decompress dynamic huffman code.
	 *
	 * @throws IOException On read or decompression errors.
	 * @since 2017/02/25
	 */
	private void __decompressDynamic()
		throws IOException
	{
		// Read the code length parameters
		int dhlit = this.__readBits(5, false) + 257;
		int dhdist = this.__readBits(5, false) + 1;
		int dhclen = this.__readBits(4, false) + 4;
		
		// Read the code length tree
		HuffmanTreeInt codelentree = this.__decompressDynamicLoadLenTree(dhclen);
		
		// Read the literal and distance trees
		HuffmanTreeInt literaltree = this.__obtainLiteralTree(),
			distancetree = this.__obtainDistanceTree();
		this.__decompressDynamicLoadLitDistTree(codelentree, dhlit, dhdist,
			literaltree, distancetree);
		
		// Decode input
		for (;;)
		{
			// Read code
			int code = literaltree.getValue(this._bitsource);
			
			// Literal byte value
			if (code >= 0 && code <= 255)
				this.__write(code, 8, false);
		
			// Stop processing
			else if (code == 256)
				return;
		
			// Window based result
			else if (code >= 257 && code <= 285)
				this.__decompressWindow(this.__handleLength(code),
					distancetree.getValue(this._bitsource));
			
			// {@squirreljme.error BD18 Illegal dynamic huffman code. (The
			// code.)}
			else
				throw new IOException(String.format("BD18 %d", code));
		}
	}
	
	/**
	 * Reads the literal and distance trees.
	 *
	 * @param __cltree The code length tree.
	 * @param __dhlit The literal count.
	 * @param __dhdist The distance count.
	 * @param __ltree The literal tree.
	 * @param __dtree The distance tree.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressDynamicLoadLitDistTree(HuffmanTreeInt __cltree,
		int __dhlit, int __dhdist, HuffmanTreeInt __ltree,
		HuffmanTreeInt __dtree)
		throws IOException
	{
		// Determine the maximum bit count that is used when reading values
		int total = __dhlit + __dhdist;
		
		// Cached, erase the data because later reads may have less
		int[] rawlitdistlens = this._rawlitdistlens;
		for (int i = 0, n = rawlitdistlens.length; i < n; i++)
			rawlitdistlens[i] = 0;
		
		// Read every code
		try
		{
			for (int next = 0; next < total;)
				next += this.__readCodeBits(__cltree, rawlitdistlens, next);
		}

		// {@squirreljme.error BD19 The compressed stream is
		// damaged by being too short or having an illegal tree
		// access.}				
		catch (NoSuchElementException e)
		{
			throw new IOException("BD19", e);
		}
		
		// Initialize both trees
		this.__thunkCodeLengthTree(__ltree, rawlitdistlens, 0, __dhlit);
		this.__thunkCodeLengthTree(__dtree, rawlitdistlens, __dhlit, __dhdist);
	}
	
	/**
	 * Reads the code length tree.
	 *
	 * @param __dhclen The code length size.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private HuffmanTreeInt __decompressDynamicLoadLenTree(int __dhclen)
		throws IOException
	{
		// Target tree
		HuffmanTreeInt codelentree = this.__obtainCodeLenTree();
		
		// {@squirreljme.error BD1a There may only be at most 19 used
		// code lengths. (The number of code lengths)}
		if (__dhclen > 19)
			throw new IOException(String.format("BD1a %d", __dhclen));
		
		// The same array is used for reading code lengths but the next time
		// around it is possible that less code lengths are read, so if the
		// higher elements have previously been set they will be used
		int[] rawcodelens = this._rawcodelens;
		for (int i = 0, n = rawcodelens.length; i < n; i++)
			rawcodelens[i] = 0;
		
		// Read lengths, they are just 3 bits but their placement values are
		// shuffled since some sequences are more common than others
		int[] hsbits = InflaterInputStream._SHUFFLE_BITS;
		for (int next = 0; next < __dhclen; next++)
			rawcodelens[hsbits[next]] = this.__readBits(3, false);
		
		// Thunk the tree and return it
		return this.__thunkCodeLengthTree(codelentree, rawcodelens, 0,
			rawcodelens.length);
	}
	
	/**
	 * Decodes decompressed data stored with the fixed huffman table and
	 * decompresses it.
	 *
	 * @throws IOException On read or decompression errors.
	 * @since 2017/02/25
	 */
	private void __decompressFixed()
		throws IOException
	{
		// Read until the sequence has ended
		for (;;)
		{
			// Read code
			int code = this.__readFixedHuffman();
				
			// Literal byte value
			if (code >= 0 && code <= 255)
				this.__write(code, 8, false);
		
			// Stop processing
			else if (code == 256)
				return;
		
			// Window based result
			else if (code >= 257 && code <= 285)
				this.__decompressWindow(this.__handleLength(code), Integer.MIN_VALUE);
		
			// {@squirreljme.error BD1b Illegal fixed huffman code. (The
			// code.)}
			else
				throw new IOException(String.format("BD1b %d", code));
		}
	}
	
	/**
	 * Decompresses uncompressed data.
	 *
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressNone()
		throws IOException
	{
		// Throw out bits that have been read so that the following reads are
		// aligned to byte boundaries
		int minisub = this._minisize & 7;
		if (minisub > 0)
			this.__readBits(minisub, false);
		
		// Read length and the one's complement of it
		int len = this.__readBits(16, false);
		int com = this.__readBits(16, false);
		
		// The complemented length must be equal to the complement
		// {@squirreljme.error BD1c Value mismatch reading the number of
		// uncompressed symbols that exist. (The length; The complement;
		// The complemented input length; The complemented input complement)}
		if ((len ^ 0xFFFF) != com)
			throw new IOException(String.format("BD1c %04x %04x %04x %04x",
				len, com, len ^ 0xFFFF, com ^ 0xFFFF));
		
		// Read all bytes
		for (int i = 0; i < len; i++)
			this.__write(this.__readBits(8, false), 8, false);
	}
	
	/**
	 * Handles decompressing window data.
	 *
	 * @param __len The length to read, must be prehandled.
	 * @param __dist The distance to read.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressWindow(int __len, int __dist)
		throws IOException
	{
		// Handle distance
		__dist = this.__handleDistance(__dist);
	
		// Get the maximum valid length, so for example if the length
		// is 5 and the distance is two, then only read two bytes.
		int maxlen;
		if (__dist < __len)
			maxlen = __dist;
		else
			maxlen = __len;
		
		// Create a byte array from the sliding window data
		byte[] winb = new byte[maxlen];
		try
		{
			this.window.get(__dist, winb, 0, maxlen);
		}
	
		// Bad window read
		catch (IndexOutOfBoundsException ioobe)
		{
			// {@squirreljme.error BD1d Window access out of range.
			// (The distance; The length)}
			throw new IOException(String.format(
				"BD1d %d %d", __dist, __len), ioobe);
		}
	
		// Add those bytes to the output, handle wrapping around if the
		// length is greater than the current position
		for (int i = 0, v = 0; i < __len; i++)
		{
			// Write byte
			this.__write(winb[v], 8, false);
		
			// Wrap around
			if ((++v) >= maxlen)
				v = 0;
		}
	}
	
	/**
	 * Handles fixed huffman distance.
	 *
	 * @param __code The input code.
	 * @return The ditsance read.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private int __handleDistance(int __code)
		throws IOException
	{
		// Read distance
		if (__code == Integer.MIN_VALUE)
			__code = this.__readBits(5, true);
		
		// {@squirreljme.error BD1e Illegal fixed distance code. (The distance
		// code)}
		if (__code > 29)
			throw new IOException(String.format("BD1e %d", __code));
		
		// Calculate the required distance to use
		int rv = 1;
		for (int i = 0; i < __code; i++)
		{
			// This uses a similar pattern to the length code, however the
			// division is half the size (so there are groups of 2 now).
			int v = ((i / 2) - 1);
			if (v >= 0)
				rv += (1 << v);
			else
				rv++;
		}
		
		// Determine the number of extra bits that make up the distance which
		// is used as an additional distance value
		int extrabits = ((__code / 2) - 1);
		if (extrabits > 0)
			rv += this.__readBits(extrabits, false);
		
		// Return it
		return rv;
	}
	
	/**
	 * Reads length codes from the input.
	 *
	 * @param __c Input code value.
	 * @throws IOException On read/write errors.
	 * @since 2016/03/12
	 */
	private int __handleLength(int __c)
		throws IOException
	{
		// The maximum length that can ever be used is 258, it has no bits also
		if (__c == 285)
			return 258;
		
		// Get the base code
		int base = __c - 257;
		
		// {@squirreljme.error BD1f Illegal length code. (The length code)}
		if (base < 0)
			throw new IOException(String.format("BD1f %d", __c));
		
		// Calculate the required length to use
		int rv = 3;
		for (int i = 0; i < base; i++)
		{
			// Determine how many groups of 4 the code is long. Since zero
			// appears as items then subtract 1 to make it longer. However
			// after the first 8 it goes up in a standard pattern.
			int v = ((i / 4) - 1);
			if (v > 0)
				rv += (1 << v);
			else
				rv++;
		}
		
		// Add extra bits which are used to modify the amount of data read
		int extrabits = (base / 4) - 1;
		if (extrabits > 0)
			rv += (extrabits = this.__readBits(extrabits, false));
		
		// Return the length
		return rv;
	}
	
	/**
	 * Obtains the code length tree.
	 *
	 * @return The code length tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainCodeLenTree()
	{
		Reference<HuffmanTreeInt> ref = this._codelentree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._codelentree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the distance tree.
	 *
	 * @return The distance tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainDistanceTree()
	{
		Reference<HuffmanTreeInt> ref = this._distancetree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._distancetree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the literal tree.
	 *
	 * @return The literal tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainLiteralTree()
	{
		Reference<HuffmanTreeInt> ref = this._literaltree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._literaltree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the read window.
	 *
	 * @return The read window.
	 * @since 2017/02/26
	 */
	private byte[] __obtainReadWindow()
	{
		Reference<byte[]> ref = this._readwindow;
		byte[] rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._readwindow = new WeakReference<>(
				(rv = new byte[128]));
		
		return rv;
	}
	
	/**
	 * Reads bits from the input stream.
	 *
	 * @param __n The number of bits to read.
	 * @param __msb If {@code true} the most significant bits are first
	 * @return The read data.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	int __readBits(int __n, boolean __msb)
		throws IOException
	{
		// Nothing to read
		if (__n == 0)
			return 0;
		
		// Get the mini window information
		int miniwindow = this._miniwindow,
			minisize = this._minisize;
		
		// Not enough bits to read the value
		while (minisize < __n)
		{
			// The number of bytes to be read
			int bc = (__n - minisize) / 8;
			if (bc == 0)
				bc = 1;
			
			// Read input bytes
			byte[] readin = this._readin;
			int rc = this.in.read(readin, 0, bc);
			
			// {@squirreljme.error BD1g Reached EOF while reading bytes to
			// decompress. (Bits in the queue; Requested number of bits)}
			if (rc < 0)
				throw new IOException(String.format("BD1g %d %d", minisize,
					__n));
			
			// Shift in the read bytes to the higher positions
			for (int i = 0; i < rc; i++)
			{
				miniwindow |= ((readin[i] & 0xFF) << minisize);
				minisize += 8;
			}
			
			// Count the number of compressed bytes
			this._compressedsize += rc;
		}
		
		// Mask in the value, which is always at the lower bits
		int rv = miniwindow & ((1 << __n) - 1);
		
		// Shift down the mini window for the next read
		// Make sure the shift down is unsigned so that zeroes are in the
		// higher bits for the filling OR operation.
		miniwindow >>>= __n;
		minisize -= __n;
		
		// Store for next run
		this._miniwindow = miniwindow;
		this._minisize = minisize;
		
		// Want MSB to be first, need to swap all the bits so the lowest ones
		// are at the highest positions
		// Luckily such a method already exists and it could potentially be
		// inlined by the JVM or converted to native code if such an
		// instruction exists.
		if (__msb)
			return Integer.reverse(rv) >>> (32 - __n);
		
		// Return read result
		return rv;
	}
	
	/**
	 * Reads code bits using the given huffman tree and into the specified
	 * array.
	 *
	 * @param __codes The huffman tree which contains the length codes which
	 * the values being read are encoded with.
	 * @param __out The output array.
	 * @param __next The next value to read.
	 * @throws IOException On read or decompression errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/28
	 */
	private int __readCodeBits(HuffmanTreeInt __codes, int[] __out,
		int __next)
		throws IOException, NullPointerException
	{
		// Check
		if (__codes == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Read in code based on an input huffman tree
		int basenext = __next;
		int code = __codes.getValue(this._bitsource);
		
		// Literal length, the input is used
		if (code >= 0 && code < 16)
			__out[__next++] = code;
		
		// Repeating
		else
		{
			// Repeat this value and for this many lengths
			int repval;
			int repfor;
			
			// Repeat the previous length 3-6 times
			if (code == 16)
			{
				// {@squirreljme.error BD1h A repeat code was specified,
				// however this is the first entry. (The last length index)}
				int lastlendx = __next - 1;
				if (lastlendx < 0)
					throw new IOException(String.format("BD1h %d",
						lastlendx));
				
				// Read the last
				repval = __out[lastlendx];
				
				// Read the repeat count
				repfor = 3 + this.__readBits(2, false);
			}
			
			// Repeat zero for 3-10 times
			else if (code == 17)
			{
				// Use zero
				repval = 0;
				
				// Read 3 bits
				repfor = 3 + this.__readBits(3, false);
			}
			
			// Repeat zero for 11-138 times
			else if (code == 18)
			{
				// Use zero
				repval = 0;
				
				// Read 7 bits
				repfor = 11 + this.__readBits(7, false);
			}
			
			// {@squirreljme.error BD1i Illegal code. (The code)}
			else
				throw new IOException(String.format("BD1i %d", code));
			
			// Could fail
			try
			{
				// Place in repeated values
				for (int i = 0; i < repfor; i++)
					__out[__next++] = repval;
			}
			
			// Out of bounds entry
			catch (IndexOutOfBoundsException ioobe)
			{
				// {@squirreljme.error BD1j Out of bounds index read.}
				throw new IOException("BD1j", ioobe);
			}
		}
		
		// Skip count
		return __next - basenext;
	}
	
	/**
	 * Reads a fixed huffman code for use by the {@code _TYPE_FIXED_HUFFMAN}
	 * state. This method does not traverse a huffman tree so to speak, but it
	 * instead uses many if statements. Initially every consideration was made
	 * but now instead it uses ranges once it keeps deep enough into the tree.
	 * This method is faster and provides a built-in huffman tree while not
	 * taking up too many bytes in the byte code.
	 *
	 * @return The read value.
	 * @throws IOException On read errors.
	 * @since 2016/03/10
	 */
	private int __readFixedHuffman()
		throws IOException
	{
		// The long if statement block
		if (this.__readBits(1, true) != 0)
			if (this.__readBits(1, true) != 0)
				if (this.__readBits(1, true) != 0)
					return 192 + this.__readBits(6, true);
				else
					if (this.__readBits(1, true) != 0)
						return 160 + this.__readBits(5, true);
					else
						if (this.__readBits(1, true) != 0)
							return 144 + this.__readBits(4, true);
						else
							return 280 + this.__readBits(3, true);
			else
				return 80 + this.__readBits(6, true);
		else
			if (this.__readBits(1, true) != 0)
				return 16 + this.__readBits(6, true);
			else
				if (this.__readBits(1, true) != 0)
					if (this.__readBits(1, true) != 0)
						return 0 + this.__readBits(4, true);
					else
						return 272 + this.__readBits(3, true);
				else
					return 256 + this.__readBits(4, true);
	}
	
	/**
	 * Creates a huffman tree from the given code lengths. These generate
	 * symbols which are used to determine how the dynamic huffman data is to
	 * be decoded.
	 *
	 * @param __tree The tree to output.
	 * @param __lens The input code lengths.
	 * @param __o The starting offset.
	 * @param __l The number of lengths to decode.
	 * @return A huffman tree from the code length input.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/28
	 */
	private HuffmanTreeInt __thunkCodeLengthTree(HuffmanTreeInt __tree,
		int[] __lens, int __o, int __l)
		throws NullPointerException
	{
		// Check
		if (__lens == null)
			throw new NullPointerException("NARG");
		
		// Initialize both arrays with zero
		int[] bl_count = this._blcount;
		int[] next_code = this._nextcode;
		for (int i = 0, n = bl_count.length; i < n; i++)
		{
			bl_count[i] = 0;
			next_code[i] = 0;
		}
		
		// Determine the bitlength count for all of the inputs
		for (int i = 0, p = __o; i < __l; i++, p++)
			bl_count[__lens[p]]++;
		bl_count[0] = 0;
		
		// Find the numerical value of the smallest code for each code
		// length.
		int code = 0;
		for (int bits = 1; bits <= InflaterInputStream._MAX_BITS; bits++)
		{
			code = (code + bl_count[bits - 1]) << 1;
			next_code[bits] = code;
		}
	
		// Assign values to all codes
		__tree.clear();
		for (int q = 0, p = __o; q < __l; q++, p++)
		{
			// Get length
			int len = __lens[p];
		
			// Add code length to the huffman tree
			if (len != 0)
				__tree.add(q, (next_code[len])++, (1 << len) - 1);
		}
		
		// Return it
		return __tree;
	}
	
	/**
	 * Writes the specified value to the output.
	 *
	 * @param __v The value to write.
	 * @param __bits The number of bits to write.
	 * @param __msb Most significant bits first?
	 * @throws IOException On write errors.
	 * @since 2017/02/25
	 */
	private void __write(int __v, int __bits, boolean __msb)
		throws IOException
	{
		// Calculate the mask
		int mask = (1 << __bits) - 1;
		
		// Write LSB value, need to swap bits if writing MSB
		__v &= mask;
		if (__msb)
			__v = Integer.reverse(__v) >>> (32 - __bits);
		
		// Get the current write window
		int writewindow = this._writewindow,
			writesize = this._writesize;
		
		// Add bits to write
		writewindow |= (__v & mask) << writesize;
		writesize += __bits;
		
		// Enough bytes to write to the output?
		if (writesize >= 8)
		{
			// Write to a byte array first
			byte[] targ = this._targ;
			int targoff = this._targoff,
				targend = this._targend;
			
			// But if writes overflow then add to the overflow buffer
			ByteDeque overflow = this.overflow;
			
			// Any bytes written are appended to the sliding window
			SlidingByteWindow window = this.window;
			
			// Write bytes
			do
			{
				// Read input byte
				byte b = (byte)writewindow;
				writewindow >>>= 8;
				writesize -= 8;
				
				// Can fit in the output buffer
				if (targoff < targend)
					targ[targoff++] = b;
				
				// Overflows
				else
					overflow.offerLast(b);
				
				// Append to the window
				window.append(b);
			} while (writesize >= 8);
			
			// Store new position
			this._targoff = targoff;
		}
		
		// Store the write window info
		this._writewindow = writewindow;
		this._writesize = writesize;
	}
	
	/**
	 * Bit source for huffman reads.
	 *
	 * @since 2017/02/25
	 */
	private final class __BitSource__
		implements BitSource
	{
		/**
		 * {@inheritDoc}
		 * @since 2017/02/25
		 */
		@Override
		public boolean nextBit()
			throws IOException
		{
			return 0 != InflaterInputStream.this.__readBits(1, true);
		}
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/MIMEFileDecoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

/**
 * This class is used to decode input streams which have been encoded in the
 * MIME Base64 format. This file format is genearted by {@code uuencode -m}.
 * This format usually begins with {@code begin-base64 mode filename} and
 * ends with the padding sequence {@code ====}.
 *
 * This class is not thread safe.
 *
 * @since 2018/03/05
 */
public final class MIMEFileDecoder
	extends InputStream
{
	/** The input base64 data. */
	protected Base64Decoder mime;
	
	/** The read mode. */
	private int _mode =
		Integer.MIN_VALUE;
	
	/** The read filename. */
	private String _filename;
	
	/**
	 * Initializes the MIME file decoder using the default encoding.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in)
		throws NullPointerException
	{
		this(new InputStreamReader(__in));
	}
	
	/**
	 * Initializes the MIME file decoder using the given encoding.
	 *
	 * @param __in The input source.
	 * @param __enc The encoding used.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(new InputStreamReader(__in, __enc));
	}
	
	/**
	 * Initializes the MIME file decoder from the given set of characters.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMEFileDecoder(Reader __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Directly wrap the reader with the MIME decoder which reads from
		// a source reader that is internally maintained
		this.mime = new Base64Decoder(new __SubReader__(__in));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		return this.mime.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.mime.close();
	}
	
	/**
	 * Returns the filename which was read.
	 *
	 * @return The read filename, {@code null} will be returned if it has not
	 * been read yet or has not been specified.
	 * @since 2018/03/05
	 */
	public final String filename()
	{
		return this._filename;
	}
	
	/**
	 * Returns the UNIX mode of the stream.
	 *
	 * @return The UNIX mode, a negative value will be returned if it has not
	 * been read yet.
	 * @since 2018/03/05
	 */
	public final int mode()
	{
		return this._mode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.mime.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.mime.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.mime.read(__b, __o, __l);
	}
	
	/**
	 * This is a sub-reader which handles parsing of the MIME header and
	 * otherwise just passing the data to the Base64Decoder instance.
	 *
	 * @since 2018/11/25
	 */
	private final class __SubReader__
		extends Reader
	{
		/** The line-by-line reader for data. */
		protected final BufferedReader in;
		
		/** The input character buffer. */
		private final StringBuilder _sb =
			new StringBuilder(80);
		
		/** The current read in the buffer. */
		private int _at;
		
		/** The current limit of the buffer. */
		private int _limit;
		
		/** Did we read the header? */
		private boolean _didheader;
		
		/** Did we read the footer? */
		private boolean _didfooter;
		
		/**
		 * Initializes the sub-reader for the MIME data.
		 *
		 * @param __in The source reader.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/24
		 */
		__SubReader__(Reader __in)
			throws NullPointerException
		{
			if (__in == null)
				throw new NullPointerException("NARG");
			
			this.in = new BufferedReader(__in, 80);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public void close()
			throws IOException
		{
			this.in.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read()
			throws IOException
		{
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Need to read more from the buffer
			int at = this._at,
				limit = this._limit;
			if (at >= limit)
			{
				// Read line next
				if (!this.__readNext())
					return -1;
				
				// Re-read
				at = this._at;
				limit = this._limit;
			}
			
			// Read the next character
			int rv = this._sb.charAt(at);
			this._at = at + 1;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			
			return this.read(__c, 0, __c.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c, int __o, int __l)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Where to read from
			StringBuilder sb = this._sb;
			int at = this._at,
				limit = this._limit;
			
			// Read in all characters
			int rv = 0;
			while (rv < __l)
			{
				// Need to read more?
				if (at >= limit)
				{
					// EOF?
					if (!this.__readNext())
						return (rv == 0 ? -1 : rv);
					
					// Re-read
					at = this._at;
					limit = this._limit;
				}
				
				// Read the next character
				__c[__o++] = sb.charAt(at++);
			}
			
			// Store new at position
			this._at = at;
			
			return rv;
		}
		
		/**
		 * Reads the header information.
		 *
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final void __readHeader()
			throws IOException
		{
			BufferedReader in = this.in;
			
			// {@squirreljme.error BD1k Unexpected end of file while trying
			// to read MIME header.}
			String ln = in.readLine();
			if (ln == null)
				throw new IOException("BD1k");
			
			// The header is in this format:
			// begin-base64 <unixmode> <filename>
			// {@squirreljme.error BD1l MIME encoded does not start with
			// MIME header.}
			if (!ln.startsWith("begin-base64"))
				throw new IOException("BD1l");
			
			// UNIX mode?
			int fs = ln.indexOf(' ');
			if (fs >= 0)
			{
				int ss = ln.indexOf(' ', fs + 1);
				
				// Decode octal mode bits
				MIMEFileDecoder.this._mode = Integer.parseInt(
					ln.substring(fs + 1, (ss < 0 ? ln.length() : ss)), 8);
				
				// Filename?
				if (ss >= 0)
					MIMEFileDecoder.this._filename =
						ln.substring(ss + 1);
			}
			
			// Set as read
			this._didheader = true;
		}
		
		/**
		 * Reads the next line into the character.
		 *
		 * @return If a line was read.
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final boolean __readNext()
			throws IOException
		{
			// {@squirreljme.error BD1m Unexpected EOF while read the MIME
			// file data.}
			String ln = this.in.readLine();
			if (ln == null)
				throw new IOException("BD1m");
			
			// End of MIME data?
			if (ln.equals("===="))
			{
				// Footer was read, so EOF now
				this._didfooter = true;
				
				// Was EOF
				return false;
			}
			
			// Fill buffer
			StringBuilder sb = this._sb;
			sb.setLength(0);
			sb.append(ln);
			
			// Set properties
			this._at = 0;
			this._limit = ln.length();
			
			// Was not EOF
			return true;
		}
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/NullOutputStream.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.io;

import java.io.OutputStream;

/**
 * This is an output stream which does nothing.
 *
 * @since 2019/06/30
 */
public final class NullOutputStream
	extends OutputStream
{
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void flush()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(int __b)
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(byte[] __b)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/PrintStreamWriter.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.Closeable;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Writer;

/**
 * This is a class which takes input characters and writes to the given
 * print stream.
 *
 * This class is thread safe.
 *
 * @since 2016/08/12
 */
public class PrintStreamWriter
	extends Writer
	implements Closeable
{
	/** The stream to write to. */
	protected final PrintStream output;
	
	/**
	 * Initializes the wrapped print stream writer.
	 *
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/12
	 */
	public PrintStreamWriter(PrintStream __ps)
		throws NullPointerException
	{
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = __ps;
	}
	
	/**
	 * Initializes the wrapped print stream writer and using the given lock.
	 *
	 * @param __lock The lock to use.
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/12
	 */
	public PrintStreamWriter(Object __lock, PrintStream __ps)
		throws NullPointerException
	{
		super(__lock);
		
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = __ps;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void close()
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.close();
			this.__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void flush()
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.flush();
			this.__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(int __c)
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.print((char)__c);
			this.__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		int n = __c.length;
		int end = __o + __l;
		if (__o < 0 || __l < 0 || end > n)
			throw new IndexOutOfBoundsException("IOOB");
	
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			// Print characters
			for (int i = __o; i < end; i++)
				output.print((char)__c[i]);
			
			// Check
			this.__checkError();
		}
	}
	
	/**
	 * Checks if the given stream has reported an error.
	 *
	 * @throws IOException If the stream has entered the error state.
	 * @since 2016/08/12
	 */
	private void __checkError()
		throws IOException
	{
		// {@squirreljme.error BD1n The underlying stream has entered the
		// error state.}
		if (this.output.checkError())
			throw new IOException("BD1n");
	}
}

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

package net.multiphasicapps.io;

/**
 * This interface is used to describe classes which allow access to data via
 * a specific position.
 *
 * @since 2016/08/11
 */
public interface RandomAccessData
	extends GettableEndianess
{
	/**
	 * Reads multiple bytes.
	 *
	 * @param __p The position to read from.
	 * @param __b The byte array to place values at.
	 * @param __o The offset to read from.
	 * @param __l The number of bytes to read.
	 * @throws IndexOutOfBoundsException If the position is not within bounds;
	 * the offset and/or length are negative; or the offset and length exceed
	 * the array bounds.
	 * @since 2016/08/11
	 */
	void read(int __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a byte at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	int readByte(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a double at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	double readDouble(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a float at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	double readFloat(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an integer at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	int readInt(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a long at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	long readLong(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a short at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	int readShort(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an unsigned byte at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	int readUnsignedByte(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an unsigned short at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	int readUnsignedShort(int __p)
		throws IndexOutOfBoundsException;
}

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

package net.multiphasicapps.io;

/**
 * This is used by both data streams to indicate that they allow their default
 * endianess to be set and obtained.
 *
 * @since 2016/07/10
 */
public interface SettableEndianess
	extends GettableEndianess
{
	/**
	 * Sets the endianess of the data.
	 *
	 * @param __end The new default endianess to use.
	 * @return The old endianess.
	 * @throws NullPointerException If no endianess was specified.
	 * @since 2016/07/10
	 */
	DataEndianess setEndianess(DataEndianess __end)
		throws NullPointerException;
}

Added modules/io/src/main/java/net/multiphasicapps/io/SizeLimitedInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is an input stream in which the size of the input stream is maximally
 * bound to a given size or fixed to a specific size.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/09
 */
public class SizeLimitedInputStream
	extends InputStream
{
	/** The wrapped stream. */
	protected final InputStream wrapped;
	
	/** Exact size? */
	protected final boolean exact;
	
	/** The read limit. */
	protected final long limit;
	
	/** If {@code true} then close propogates to the wrapped stream. */
	protected final boolean propogate;
	
	/** The current read size. */
	private volatile long _current;
	
	/** Was this closed? */	
	private volatile boolean _closed;
	
	/**
	 * Initializes the size limited input stream. The close operation in this
	 * stream propogates to the wrapped stream.
	 *
	 * @param __is Input stream to wrap.
	 * @param __li The length of data to limit to.
	 * @param __ex If {@code true} then the stream must end at least at the
	 * limit and not before it, otherwise if {@code false} then it is only
	 * limited to either the limit or the number of bytes in the stream. If
	 * {@code true} then closing the stream will read the remaining number of
	 * bytes.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/09
	 */
	public SizeLimitedInputStream(InputStream __is, long __li, boolean __ex)
		throws IllegalArgumentException, NullPointerException
	{
		this(__is, __li, __ex, true);
	}
	
	/**
	 * Initializes the size limited input stream.
	 *
	 * @param __is Input stream to wrap.
	 * @param __li The length of data to limit to.
	 * @param __ex If {@code true} then the stream must end at least at the
	 * limit and not before it, otherwise if {@code false} then it is only
	 * limited to either the limit or the number of bytes in the stream. If
	 * {@code true} then closing the stream will read the remaining number of
	 * bytes.
	 * @param __prop If {@code true} then when this stream is closed, it will
	 * forward the close to the wrapped stream. Otherwise if {@code false}.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/28
	 */
	public SizeLimitedInputStream(InputStream __is, long __li, boolean __ex,
		boolean __prop)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BD1o The limit is negative. (The negative
		// limit)}
		if (__li < 0)
			throw new IllegalArgumentException(String.format("BD1o %d", __li));
		
		// Set
		this.wrapped = __is;
		this.limit = __li;
		this.exact = __ex;
		this.propogate = __prop;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public int available()
		throws IOException
	{
		// Get the count for the wrapped stream
		long wav = this.wrapped.available();
	
		// Either limited to the max integer size, the number of available
		// bytes, or the remaining stream count.
		return (int)Math.min(Integer.MAX_VALUE,
			Math.min(wav, (this.limit - this._current)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public void close()
		throws IOException
	{
		// Read in?
		if (!this._closed)
		{
			// Set
			this._closed = true;
			
			// Read in remaining bytes if doing so
			if (this.exact)
			{
				// {@squirreljme.error BD1p Reached EOF on wrapped stream when
				// requesting an exact number of bytes. (The current read
				// count; The read limit)}
				long limit = this.limit;
				long at;
				while ((at = this._current) < limit)
					if (this.read() < 0)
						throw new IOException(String.format("BD1p %d %d",
							at, limit));
			}
		}
		
		// Close the underlying stream, but only if propogating
		if (this.propogate)
			this.wrapped.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public int read()
		throws IOException
	{
		// Current position
		long limit = this.limit;
		long cur = this._current;
		
		// Reached the limit?
		if (cur >= limit)
			return -1;
		
		// Read next byte
		int next = this.wrapped.read();
		
		// EOF?
		if (next < 0)
		{
			// {@squirreljme.error BD1q Required an exact number of bytes
			// however the limit was not yet reached, the input stream is too
			// short. (The limit; The current position)}
			if (this.exact && cur != limit)
				throw new IOException(String.format("BD1q %d %d",
					limit, cur));
			
			// Return original negative
			return next;
		}
		
		// Increase current location
		this._current = cur + 1L;
		
		// Return it
		return next;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/05
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// If the limit was reached, stop
		long current = this._current;
		long limit = this.limit;
		if (current >= limit)
		{
			// {@squirreljme.error BD1r Required an exact number of bytes
			// however the limit was not yet reached, the file is too short.
			// (The limit; The current position)}
			if (this.exact && current != limit)
				throw new IOException(String.format("BD1r %d %d",
					limit, current));
			
			return -1;
		}
		
		// Do not read more bytes after the limit
		int cc = (int)Math.min(limit - current, __l);
		
		// Read the next few bytes
		InputStream wrapped = this.wrapped;
		int rc = wrapped.read(__b, __o, cc);
		
		// EOF?
		if (rc < 0)
		{
			// {@squirreljme.error BD1s Required an exact number of bytes
			// however the limit was not yet reached. (The limit; The
			// current position)}
			if (this.exact && current != limit)
				throw new IOException(String.format("BD1s %d %d",
					limit, current));
			
			// Just EOF
			return -1;
		}
		
		// Set the new current
		this._current = current + rc;
		
		// Return the read count
		return rc;
	}
}

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

package net.multiphasicapps.io;

/**
 * This is used to obtain the number of bytes which were read from or written
 * to a given stream.
 *
 * @since 2016/07/10
 */
public interface SizedStream
{
	/**
	 * Returns the number of written or read bytes.
	 *
	 * @return The number of read or written bytes.
	 * @since 2016/07/10
	 */
	long size();
}

Added modules/io/src/main/java/net/multiphasicapps/io/SlidingByteWindow.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This represents a sliding byte window.
 *
 * It is allocated in chunks of a given fragment size so that the entire window
 * is not allocated in its entirety until it is actually used.
 *
 * In the future this class may support a kind of compression so that older
 * bytes in the sliding window may be compacted when they are not used.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/10
 */
public class SlidingByteWindow
{
	/** The backing byte buffer. */
	protected final ByteDeque deque;
	
	/** The window size. */
	protected final int windowsize;
	
	/** Single byte for forcing bulk operations. */
	private final byte[] _solo =
		new byte[1];
	
	/** The total number of written bytes. */
	private volatile int _total;
	
	/**
	 * This initializes the sliding byte window.
	 *
	 * @param __wsz The size of the sliding window.
	 * @since 2016/03/10
	 */
	public SlidingByteWindow(int __wsz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD1t Zero or negative window size specified.
		// (The window size)}
		if (__wsz <= 0)
			throw new IllegalArgumentException(String.format("BD1t %d",
				__wsz));
		
		// Set
		this.windowsize = __wsz;
		
		// Setup backing store
		this.deque = new ByteDeque(__wsz);
	}
	
	/**
	 * Appends a single byte to the sliding window.
	 *
	 * @param __b The byte to add to the window.
	 * @since 2016/03/10
	 */
	public void append(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		this.append(solo, 0, 1);
	}
	
	/**
	 * Appends multiple bytes to the sliding window.
	 *
	 * @param __b Bytes to add to the sliding window.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/10
	 */
	public void append(byte[] __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Call other
		this.append(__b, 0, __b.length);
	}
	
	/**
	 * Appends the bytes from the input array in the given range to the sliding
	 * window.
	 *
	 * @param __b Bytes to add to the sliding window.
	 * @param __o Offset into the byte array.
	 * @param __l The number of bytes to add.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or the offset and the length exceeds the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/10
	 */
	public void append(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l > __b.length))
			throw new IndexOutOfBoundsException("BAOB");
		
		// Get
		ByteDeque deque = this.deque;
		int windowsize = this.windowsize;
		int total = this._total;
		
		// Check if the new amount will overflow
		int newtotal = total + __l;
		int overflow = 0;
		if (newtotal < 0 || newtotal > windowsize)
		{
			overflow = (newtotal - windowsize);
			newtotal = windowsize;
		}
		
		// Will overflow, delete last bytes
		if (overflow > 0)
			deque.deleteFirst(overflow);
		
		// Add data to the end so that the single-byte insertion order
		// would be the same as the multi-byte insertion.
		// And so no shuffling is required
		deque.addLast(__b, __o, __l);
		this._total = newtotal;
	}
	
	/**
	 * Obtains a single byte at the specified position in the past.
	 *
	 * @param __ago The number of positions ago to get the value for.
	 * @return The byte value at the given position.
	 * @throws IndexOutOfBoundsException If the position is not within the
	 * bounds of the sliding window.
	 * @since 2017/03/04
	 */
	public byte get(int __ago)
		throws IndexOutOfBoundsException
	{
		byte[] solo = this._solo;
		this.get(__ago, solo, 0, 1);
		return solo[0];
	}
	
	/**
	 * This reads bytes from the sliding window at a given historical index
	 * and writes them to the input array.
	 *
	 * @param __ago How many bytes in the past to read.
	 * @param __b The output array of bytes to write.
	 * @param __o The offset into the array where to start writing bytes to.
	 * @param __l The number of bytes to read from history to write into the
	 * array.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or the offset and the length exceeds the array bounds; {@code __ago}
	 * is zero or negative; the distance back and the length exceeds the
	 * amount of available history; the distance back exceeds the maximum
	 * window size; or the distance back exceeds the total amount of history.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/13
	 */
	public void get(int __ago, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l > __b.length))
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD1u Bulk read of window bytes would exceed
		// the bounds of the window. (The bytes in the past to start the
		// copy from; The number of bytes to read; The total number of
		// bytes in the window)}
		int windowsize = this.windowsize;
		int total = this._total;
		if (__ago <= 0 || ((total - __ago) + __l) > total)
			throw new IndexOutOfBoundsException(String.format(
				"BD1u %d %d %d", __ago, __l, total));
		
		// {@squirreljme.error BD1v Get of a sliding window read did not
		// read the expected number of bytes. (The expected number of bytes
		// to read; The actual number read)}
		int rv;
		if ((rv = this.deque.get(total - __ago, __b, __o,
			__l)) != __l)
			throw new IndexOutOfBoundsException(String.format(
				"BD1v %d %d", __l, rv));
	}
	
	/**
	 * Returns the total number of bytes in the sliding window.
	 *
	 * @return The total number of bytes in the window.
	 * @since 2016/03/28
	 */
	public int size()
	{
		return this._total;
	}
}

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

package net.multiphasicapps.io;

import java.io.Reader;

/**
 * This is a reader which can read from a string.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/04
 */
public class StringReader
	extends Reader
{
	/** The string to read from. */
	protected final String string;
	
	/** The string length. */
	protected final int length;
	
	/** The current position. */
	private int _at;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __s The input string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public StringReader(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
		this.length = __s.length();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Determine the current position and string length
		int at = this._at,
			length = this.length,
			left = length - at;
		
		// EOF?
		if (at >= length)
			return -1;
		
		// Can only read so many characters
		String string = this.string;
		int max = Math.min(__l, left),
			limit = at + max;
		for (int o = __o; at < limit; at++, o++)
			__c[o] = string.charAt(at);
		
		// Set position for next time
		this._at = at;
		
		return max;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/TableSectionOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.io;

import java.io.ByteArrayOutputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.ref.Reference;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * This is an output stream which writes to section tables, essentially a
 * number of various data chunks in the stream. All sections are ordered in
 * the order that they are created.
 *
 * This class is not thread safe.
 *
 * @since 2019/08/11
 */
public final class TableSectionOutputStream
{
	/** This represents a variable sized section. */
	public static final int VARIABLE_SIZE =
		Integer.MIN_VALUE;
	
	/** The sections which are available in the output. */
	private final List<Section> _sections =
		new LinkedList<>();
	
	/** Are the section informations dirty? */
	private final __Dirty__ _dirty =
		new __Dirty__();
	
	/** The current file size. */
	private int _filesize;
	
	/**
	 * Adds a section which is of a variable size.
	 *
	 * @return The resulting section.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection()
	{
		return this.addSection(TableSectionOutputStream.VARIABLE_SIZE, 1);
	}
	
	/**
	 * Adds a section which consists of the given byte array.
	 *
	 * @param __bytes The byte array to initialize as.
	 * @return The resulting section.
	 * @throws IOException If the section could not be written.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(byte[] __bytes)
		throws IOException, NullPointerException
	{
		return this.addSection(__bytes, 1);
	}
	
	/**
	 * Adds a section which consists of the given byte array using the given
	 * alignment.
	 *
	 * @param __bytes The byte array to initialize as.
	 * @param __align The alignment to use.
	 * @return The resulting section.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @throws IOException If the section could not be written.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(byte[] __bytes,
		int __align)
		throws IllegalArgumentException, IOException, NullPointerException
	{
		if (__bytes == null)
			throw new NullPointerException("NARG");
		
		// Add new section
		Section rv = this.addSection(__bytes.length, __align);
		
		// Write all the bytes into it
		rv.write(__bytes);
		
		// Use this section
		return rv;
	}
	
	/**
	 * Adds a section which is either of a variable size of a fixed size.
	 *
	 * @param __size The size of the section to use, if {@link #VARIABLE_SIZE}
	 * then the section will have a variable size.
	 * @return The section which was created for writing.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(int __size)
		throws IllegalArgumentException
	{
		return this.addSection(__size, 1);
	}
	
	/**
	 * Adds a section which is either of a variable size of a fixed size and
	 * one which has an alignment.
	 *
	 * @param __size The size of the section to use, if {@link #VARIABLE_SIZE}
	 * then the section will have a variable size.
	 * @param __align The alignment of the section, if the value is lower than
	 * {@code 1} it will be set to {@code 1}.
	 * @return The section which was created for writing.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(int __size,
		int __align)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD3h Zero or negative size section. (The size)}
		if (__size != TableSectionOutputStream.VARIABLE_SIZE && __size <= 0)
			throw new IllegalArgumentException("BD3h " + __size);
		
		// {@squirreljme.error BD3q Zero or negative alignment.
		// (The alignment)}
		if (__align < 1)
			throw new IllegalArgumentException("BD3q " + __align);
		
		// Create section
		Section rv = new Section(__size, __align, this._dirty);
		
		// Add to our section list
		this._sections.add(rv);
		
		// Becomes dirty because new section was added
		this._dirty._dirty = true;
		
		// And return this section
		return rv;
	}
	
	/**
	 * Returns the current size of the file.
	 *
	 * @return The file size.
	 * @since 2019/08/25
	 */
	public final int fileSize()
	{
		this.__undirty();
		return this._filesize;
	}
	
	/**
	 * Returns the address of the given section.
	 *
	 * @param __s The section.
	 * @return The address of the section.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final int sectionAddress(Section __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__undirty();
		return __s._writeaddress;
	}
	
	/**
	 * Returns the size of the given section.
	 *
	 * @param __s The section.
	 * @return The size of the section.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final int sectionSize(Section __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__undirty();
		return __s._writesize;
	}
	
	/**
	 * Returns a byte array representing the table file.
	 *
	 * @return The resulting byte array.
	 * @since 2019/08/11
	 */
	public final byte[] toByteArray()
	{
		// Setup output byte array which has a base size for the size of the
		// file
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			this.fileSize()))
		{
			// Record everything in
			this.writeTo(baos);
			
			// Return the resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BD3i Could not create the byte array.}
		catch (IOException e)
		{
			throw new RuntimeException("BD3i", e);
		}
	}
	
	/**
	 * Writes the table file to the given output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// The current write pointer
		int writeptr = 0;
		
		// Undirty and get the file size
		this.__undirty();
		int filesize = this._filesize;
		
		// Write each individual section to the output stream
		List<Section> sections = this._sections;
		for (int i = 0, n = sections.size(); i < n; i++)
		{
			Section section = sections.get(i);
			
			// Get properties of the section
			byte[] data = section._data;
			int cursize = section._size,
				writeaddress = section._writeaddress,
				writesize = section._writesize,
				writeendaddress = writeaddress + writesize,
				actualwrite = (cursize < writesize ? cursize : writesize);
			
			// Write padding until we reach our needed address
			while (writeptr < writeaddress)
			{
				__os.write(0);
				writeptr++;
			}
			
			// Rewrites must be processed to figure out how to refer to
			// other section aliases!
			for (__Rewrite__ rewrite : section._rewrites)
			{
				// The target section if any
				Reference<TableSectionOutputStream.Section> refsection =
					rewrite._section;
				
				// Determine the value that is to be written
				int value = 0;
				switch (rewrite._value)
				{
						// Address of section
					case ADDRESS:
						if (refsection != null)
							value = refsection.get()._writeaddress;
						break;
						
						// Size of section or file.
					case SIZE:
						if (refsection == null)
							value = filesize;
						else
							value = refsection.get()._writesize;
						break;
				}
				
				// Add offset of value
				value += rewrite._offset;
				
				// Perform the actual rewrite
				int paddr = rewrite._address;
				switch (rewrite._type)
				{
					case SHORT:
						data[paddr] = (byte)(value >>> 8);
						data[paddr + 1] = (byte)(value);
						break;
					
					case INTEGER:
						data[paddr] = (byte)(value >>> 24);
						data[paddr + 1] = (byte)(value >>> 16);
						data[paddr + 2] = (byte)(value >>> 8);
						data[paddr + 3] = (byte)(value);
						break;
				}
			}
			
			// Write the section data as an entire chunk, note that this
			// could be a fixed size section with a short buffer!
			__os.write(data, 0, actualwrite);
			writeptr += actualwrite;
			
			// Write padding until we reach our ending address
			while (writeptr < writeendaddress)
			{
				__os.write(0);
				writeptr++;
			}
		}
	}
	
	/**
	 * Undirties and calculations all the section layout and information.
	 *
	 * @since 2019/08/25
	 */
	private final void __undirty()
	{
		// There is no need to calculate if this is not dirty at all
		__Dirty__ dirty = this._dirty;
		if (!dirty._dirty)
			return;
		
		// Our current file size
		int filesize = 0;
		
		// We must go through all of the sections, perform their required
		// alignment while additionally calculating their addresses within
		// the file for section references.
		List<Section> sections = this._sections;
		for (int i = 0, n = sections.size(); i < n; i++)
		{
			Section section = sections.get(i);
			
			// Perform alignment of this section
			if ((filesize % section.alignment) != 0)
				filesize += section.alignment - (filesize % section.alignment);
			
			// Section is addressed here
			section._writeaddress = filesize;
			
			// Move the current file size up by the section's size
			int writesize = (section.isvariable ?
				section._size : section.fixedsize);
			filesize += writesize;
			section._writesize = writesize;
		}
		
		// Store file size
		this._filesize = filesize;
		
		// Clear dirty flag
		dirty._dirty = false;
	}
	
	/**
	 * This represents a single section within the output.
	 *
	 * @since 2019/08/11
	 */
	public static final class Section
		extends OutputStream
		implements DataOutput
	{
		/** The size of the bufer. */
		private static final int _BUFFER_SIZE =
			512;
		
		/** The fixed size of this section. */
		protected final int fixedsize;
		
		/** The alignment of this section. */
		protected final int alignment;
		
		/** Is this a variable size section? */
		protected final boolean isvariable;
		
		/** Data rewrites which are possible. */
		private final List<__Rewrite__> _rewrites =
			new LinkedList<>();
		
		/** The tracker for the dirtiness. */
		private final __Dirty__ _dirty;
		
		/** The byte buffer data. */
		private byte[] _data;
		
		/** The current size of the section. */
		private int _size;
		
		/** The write address of this section. */
		private int _writeaddress =
			-1;
		
		/** The write size of this section. */
		private int _writesize =
			-1;
		
		/**
		 * Initializes the written section.
		 *
		 * @param __size The size to use.
		 * @param __align The alignment to use.
		 * @param __d The dirty flag.
		 * @throws IllegalArgumentException If the size is zero or negative.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		private Section(int __size, int __align, __Dirty__ __d)
			throws IllegalArgumentException, NullPointerException
		{
			if (__d == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error BD3l Zero or negative size. (The size)}
			if (__size != TableSectionOutputStream.VARIABLE_SIZE && __size <= 0)
				throw new IllegalArgumentException("BD3l " + __size);
			
			// Set
			this.fixedsize = __size;
			this.alignment = (__align >= 1 ? __align : 1);
			this.isvariable = (__size == TableSectionOutputStream.VARIABLE_SIZE);
			
			// Dirty flag storage
			this._dirty = __d;
			
			// If this is a fixed size section, we never have to expand it
			// so we can allocate all the needed data!
			if (__size != TableSectionOutputStream.VARIABLE_SIZE)
				this._data = new byte[__size];
			else
				this._data = new byte[Section._BUFFER_SIZE];
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void close()
		{
			// Do nothing
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void flush()
		{
			// Do nothing
		}
		
		/**
		 * Returns the current written size of the section.
		 *
		 * @return The current section size.
		 * @since 2019/08/11
		 */
		public final int size()
		{
			return this._size;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(int __b)
			throws IOException
		{
			// {@squirreljme.error BD3m Size of section exceeded. (The size
			// of the section)}
			int size = this._size;
			if (!this.isvariable && size + 1 > this.fixedsize)
				throw new IOException("BD3m " + size);
			
			// Possibly resize the data array, only when variable
			byte[] data = this._data;
			if (this.isvariable && size >= data.length)
			{
				data = Arrays.copyOf(data, size + Section._BUFFER_SIZE);
				this._data = data;
			}
			
			// Write into the data
			data[size] = (byte)__b;
			
			// Size up
			this._size = size + 1;
			
			// Becomes dirty
			this._dirty._dirty = true;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(byte[] __b)
			throws IOException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			
			this.write(__b, 0, __b.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BD3p Size of section exceeded.}
			int size = this._size;
			if (!this.isvariable && size + __l > this.fixedsize)
				throw new IOException("BD3p");
			
			// Possibly resize the data array (only when variable)
			byte[] data = this._data;
			if (this.isvariable && size + __l >= data.length)
			{
				data = Arrays.copyOf(data,
					size + (__l < Section._BUFFER_SIZE ? Section._BUFFER_SIZE : __l));
				this._data = data;
			}
			
			// Write into the data
			for (int i = 0; i < __l; i++)
				data[size++] = __b[__o++];
			
			// Size up
			this._size = size;
			
			// Becomes dirty
			this._dirty._dirty = true;
		}
		
		/**
		 * Writes padding which aligns to a given amount from within the
		 * data stream as itself.
		 *
		 * @param __n The number of bytes to align to.
		 * @return The number of alignment bytes written.
		 * @throws IllegalArgumentException If the requested alignment is
		 * negative.
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final int writeAlignment(int __n)
			throws IllegalArgumentException, IOException
		{
			// {@squirreljme.error BD3k Cannot align to a negative amount.
			// (The alignment)}
			if (__n < 1)
				throw new IllegalArgumentException("BD3k " + __n);
			
			// Not point aligning to a byte
			if (__n == 1)
				return 0;
			
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeBoolean(boolean __v)
			throws IOException
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeByte(int __v)
			throws IOException
		{
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeBytes(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			for (int i = 0, n = __v.length(); i < n; i++)
				this.write(__v.charAt(i));
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeChar(int __v)
			throws IOException
		{
			this.writeShort(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeChars(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			for (int i = 0, n = __v.length(); i < n; i++)
			{
				char c = __v.charAt(i);
				
				this.write(c >> 8);
				this.write(c);
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeDouble(double __v)
			throws IOException
		{
			this.writeLong(Double.doubleToLongBits(__v));
		}
		
		/**
		 * Writes the size of the file as an integer.
		 *
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writeFileSizeInt()
			throws IOException
		{
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.SIZE, 0, null));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the size of the file as a short.
		 *
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writeFileSizeShort()
			throws IOException
		{
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.SIZE, 0, null));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeFloat(float __v)
			throws IOException
		{
			this.writeInt(Float.floatToIntBits(__v));
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeInt(int __v)
			throws IOException
		{
			this.write(__v >> 24);
			this.write(__v >> 16);
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeLong(long __v)
			throws IOException
		{
			this.write((int)(__v >> 56));
			this.write((int)(__v >> 48));
			this.write((int)(__v >> 40));
			this.write((int)(__v >> 32));
			this.write((int)(__v >> 24));
			this.write((int)(__v >> 16));
			this.write((int)(__v >> 8));
			this.write((int)(__v));
		}
		
		/**
		 * Writes the specified number of bytes as padding, the padding
		 * value is zero.
		 *
		 * @param __n The number of bytes to pad with.
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writePadding(int __n)
			throws IOException
		{
			this.writePadding(__n, 0);
		}
		
		/**
		 * Writes the specified number of bytes as padding.
		 *
		 * @param __n The number of bytes to pad with.
		 * @param __v The padding value to write.
		 * @throws IllegalArgumentException If the padding amount is negative.
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writePadding(int __n, int __v)
			throws IllegalArgumentException, IOException
		{
			// {@squirreljme.error BD3j Negative padding. (The padding)}
			if (__n < 0)
				throw new IllegalArgumentException("BD3j " + __n);
			
			// Not writing anything, so ignore
			if (__n == 0)
				return;
			
			// Write the padding
			for (int i = 0; i < __n; i++)
				this.write(__v);
		}
		
		/**
		 * Writes the address of the given section as an integer.
		 *
		 * @param __s The section to write the address of.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/24
		 */
		public final void writeSectionAddressInt(Section __s)
			throws IOException, NullPointerException
		{
			this.writeSectionAddressInt(__s, 0);
		}
		
		/**
		 * Writes the address of the given section as an integer.
		 *
		 * @param __s The section to write the address of.
		 * @param __o The offset to use.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionAddressInt(Section __s, int __o)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.ADDRESS, __o, __s));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the address of the given section as a short.
		 *
		 * @param __s The section to write the address of.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/24
		 */
		public final void writeSectionAddressShort(Section __s)
			throws IOException, NullPointerException
		{
			this.writeSectionAddressShort(__s, 0);
		}
		
		/**
		 * Writes the address of the given section as a short.
		 *
		 * @param __s The section to write the address of.
		 * @param __o The offset value.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionAddressShort(Section __s, int __o)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.ADDRESS, __o, __s));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * Writes the size of the given section as an integer.
		 *
		 * @param __s The section and its size to write.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionSizeInt(Section __s)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.SIZE, 0, __s));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the size of the given section as a short.
		 *
		 * @param __s The section and its size to write.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionSizeShort(Section __s)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.SIZE, 0, __s));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeShort(int __v)
			throws IOException
		{
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * Writes the specified short value and checks to make sure it is
		 * within the range of a short.
		 *
		 * @param __v The value to write.
		 * @throws IOException If the short could not be written or it
		 * exceeds the range of a short value.
		 * @since 2019/08/11
		 */
		public final void writeShortChecked(int __v)
			throws IOException
		{
			// {@squirreljme.error BD3o Signed short value out of range.
			// (The value)}
			if (__v < -32768 || __v > 32767)
				throw new IOException("BD3o " + __v);
			
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * Writes the specified unsigned short value and checks to make sure it
		 * is within the range of an unsigned short.
		 *
		 * @param __v The value to write.
		 * @throws IOException If the unsigned short could not be written or it
		 * exceeds the range of an unsigned short value.
		 * @since 2019/08/11
		 */
		public final void writeUnsignedShortChecked(int __v)
			throws IOException
		{
			// {@squirreljme.error BD3n Unsigned short value out of range.
			// (The value)}
			if (__v < 0 || __v > 65535)
				throw new IOException("BD3n " + __v);
			
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeUTF(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			// Write into a buffer
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
				2 + (__v.length() * 2));
				DataOutputStream dos = new DataOutputStream(baos))
			{
				// Write data
				dos.writeUTF(__v);
				
				// Dump to this internally
				baos.writeTo(this);
			}
		}
	}
	
	/**
	 * Are the addresses and sizes considered dirty?
	 *
	 * @since 2019/08/25
	 */
	static final class __Dirty__
	{
		/** Flag used to store the dirty state. */
		volatile boolean _dirty;
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/ZLibCompressor.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
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
191
192
193
194
195
196
197
198
199
200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This class supports compressing data to ZLib streams.
 *
 * Associated standards: https://www.ietf.org/rfc/rfc1950.txt .
 *
 * This class is not thread safe.
 *
 * @since 2018/11/11
 */
public final class ZLibCompressor
	extends OutputStream
	implements CompressionStream
{
	/** The stream to forward to. */
	protected final OutputStream out;
	
	/** The deflater used. */
	private final DeflaterOutputStream _dos;
	
	/** Adler checksum of uncompressed stream. */
	private final Adler32Calculator _adler =
		new Adler32Calculator();
	
	/** Has this been closed? */
	private boolean _closed;
	
	/** Initialized with Zlib header? */
	private boolean _init;
	
	/**
	 * Initializes the compressor.
	 *
	 * @param __os The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ZLibCompressor(OutputStream __os)
		throws NullPointerException
	{
		this(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Initializes the compressor with the given compression level.
	 *
	 * @param __os The stream to write to.
	 * @param __cl The compression level to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ZLibCompressor(OutputStream __os, CompressionLevel __cl)
		throws NullPointerException
	{
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		this.out = __os;
		this._dos = new DeflaterOutputStream(__os);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final long compressedBytes()
	{
		return this._dos.compressedBytes() +
			(this._init ? 2 + (this._closed ? 4 : 0) : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Close only once
		if (!this._closed)
		{
			this._closed = true;
			
			// Flush and close the other compression stream
			DeflaterOutputStream dos = this._dos;
			dos.flush();
			dos.close();
			
			// Write the checksum
			OutputStream out = this.out;
			int checksum = this._adler.checksum();
			out.write(checksum >> 24);
			out.write(checksum >> 16);
			out.write(checksum >> 8);
			out.write(checksum);
			
			// Flush the output
			out.flush();
		}
		
		// Forward close to output
		this.out.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// Flush to the output
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final long uncompressedBytes()
	{
		return this._dos.uncompressedBytes();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Just forward write call since it is easier
		this.write(new byte[]{(byte)__b}, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		OutputStream out = this.out;
		
		// If the stream has not been initialized, we need to set a flag
		// and such
		if (!this._init)
		{
			this._init = true;
			
			// DEFLATE compression with no flags
			out.write(0x78);
			out.write(1);
		}
		
		// Write to data
		this._dos.write(__b, __o, __l);
		
		// Checksum that
		this._adler.offer(__b, __o, __l);
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/ZLibDecompressor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * This class supports decompressing ZLib streams.
 *
 * Associated standards: https://www.ietf.org/rfc/rfc1950.txt .
 *
 * This class is not thread safe.
 *
 * @since 2017/03/04
 */
public class ZLibDecompressor
	extends DecompressionInputStream
{
	/** Compression method mask. */
	private static final int _CMF_COMPRESSION_METHOD_MASK =
		0b00001111;
	
	/** Compression info mask. */
	private static final int _CMF_COMPRESSION_INFO_MASK =
		0b11110000;
	
	/** Compression info shift. */
	private static final int _CMF_COMPRESSION_INFO_SHIFT =
		4;
	
	/** Deflate compression method. */
	private static final int _CMF_METHOD_DEFLATE =
		8;
	
	/** Is a preset dictionary being used? */
	private static final int _FLAG_PRESET_DICTIONARY =
		1 << 5;
	
	/** The source stream. */
	protected final DataInputStream in;
	
	/** Single byte array to be shared for single reads. */
	private final byte[] _solo =
		new byte[1];
	
	/** The current checksum being calculated. */
	private final Adler32Calculator _checksum =
		new Adler32Calculator();
	
	/** Current stream to read data from, will change for blocks. */
	private volatile DecompressionInputStream _current;
	
	/** Has EOF been read? */
	private volatile boolean _eof;
	
	/** The number of uncompressed bytes. */
	private volatile long _uncomp;
	
	/** The base number of compressed bytes. */
	private volatile long _basecomp;
	
	/**
	 * Initializes the ZLib decompressor.
	 *
	 * @param __in The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/04
	 */
	public ZLibDecompressor(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int available()
		throws IOException
	{
		// If the current stream is known, it is possible that the number
		// of available bytes will be known from it
		InputStream current = this._current;
		if (current != null)
			return current.available();
		
		// Otherwise no amount is known
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
		
		// Close the current stream also
		InputStream current = this._current;
		if (current != null)
			current.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		// It is really hard to tell how many compressed bytes were read so
		// if there is a current stream then use it from the base because
		// otherwise it would be really unknown how many bytes were truly
		// read from the compressed stream
		long basecomp = this._basecomp;
		DecompressionInputStream current = this._current;
		if (current != null)
			return basecomp + current.compressedBytes();
		return basecomp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = this.read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// Read EOF?
		if (this._eof)
			return -1;
		
		// Try to fill the buffer up as much as possible
		int rv = 0;
		boolean eof = false;
		DataInputStream in = this.in;
		DecompressionInputStream current = this._current;
		Adler32Calculator checksum = this._checksum;
		for (int at = __o, rest = __l; rv < __l;)
		{
			// There is a current stream being read
			if (current != null)
			{
				int rc = current.read(__b, at, rest);
				
				// If EOF is reached then the checksum must be checked
				if (rc < 0)
				{
					// The number of compressed bytes always acts as a base
					// since it is unknown how many bytes were read by the
					// decompression stream. So when it has ended it a new base
					// must be set for every byte which was read.
					this._basecomp += current.compressedBytes();
					
					// {@squirreljme.error BD1w The checksum for the ZLib
					// stream is not valid. (The desired checksum; The actual
					// checksum)}
					int want = in.readInt(),
						was = checksum.checksum();
					if (want != was)
						throw new IOException(String.format("BD1w %08x %08x",
							want, was));
					
					// This is the checksum
					this._basecomp += 4;
					
					// Clear current because no more data can be read from
					// it
					current = null;
					this._current = null;
				}
				
				// Otherwise consume those bytes
				else
				{
					at += rc;
					rv += rc;
					rest -= rc;
					
					// Count those bytes as uncompressed
					this._uncomp += rc;
				}
			}
			
			// Otherwise try to see if there is data to be read
			else
			{
				// Compression method and flags
				int cmf = in.read();
				
				// The end of stream could be at this point at which point it
				// is acceptable to stop reading data
				if (cmf < 0)
				{
					eof = true;
					this._eof = true;
					break;
				}
				
				// Count single compressed byte
				this._basecomp++;
				
				// {@squirreljme.error BD1x Only deflate compressed ZLib
				// streams are supported. (The compression method used)}
				int method = (cmf & ZLibDecompressor._CMF_COMPRESSION_METHOD_MASK);
				if (ZLibDecompressor._CMF_METHOD_DEFLATE != method)
					throw new IOException(String.format("BD1x %d", method));
				
				// {@squirreljme.error BD1y The specified binary logarithm
				// specified for the sliding window is not valid. (The binary
				// logarithm of the sliding window)}
				// The specification says that higher sliding windows are not
				// allowed, but skirt that requirement
				int slwin = ((cmf & ZLibDecompressor._CMF_COMPRESSION_INFO_MASK) >>> ZLibDecompressor._CMF_COMPRESSION_INFO_SHIFT) + 8;
				if (slwin < 0 || slwin > 30)
					throw new IOException(String.format("BD1y %d", slwin));
				
				// Shift up
				slwin = 1 << slwin;
				
				// Read more flags
				int mf = in.readUnsignedByte();
				
				// Count single compressed byte
				this._basecomp++;
				
				// {@squirreljme.error BD1z The checksum for the starting
				// ZLib header is not a multiple of 31. (The checksum
				// remainder)}
				// This is a basic check to ensure that in most cases that the
				// header of the ZLib chunk is not corrupt.
				int was = ((cmf * 256) + mf) % 31;
				if (was != 0)
					throw new IOException(String.format("BD1z %d", was));
				
				// {@squirreljme.error BD20 Preset dictionaries in ZLib
				// streams are not supported.}
				if ((mf & ZLibDecompressor._FLAG_PRESET_DICTIONARY) != 0)
					throw new IOException("BD20");
				
				// Setup inflate stream
				checksum.reset();
				current = new InflaterInputStream(in, slwin, checksum);
				this._current = current;
			}
		}
		
		// Return EOF or the read count
		return (eof && rv == 0 ? -1 : rv);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._uncomp;
	}
}

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

package net.multiphasicapps.io;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
 * This contains the table used for calculation of the CRC.
 *
 * @since 2016/07/16
 */
final class __CRC32Table__
{
	/** Static table reference. */
	private static final Map<Integer, Reference<__CRC32Table__>> _TABLES =
		new HashMap<>();
	
	/** CRC table data. */
	final int[] _table;
	
	/**
	 * Initializes the table data.
	 *
	 * @param __poly The polynomial.
	 * @since 2016/07/16
	 */
	private __CRC32Table__(int __poly)
	{
		// Setup table;
		int[] table = new int[256];
		for (int i = 0; i < 256; i++)
		{
			int remainder = i << 24;
			
			// Divide all bits possibly
			for (int b = 0; b < 8; b++)
			{
				int oldrem = remainder;
				remainder <<= 1;
				
				// XOR in polynomial
				if (0 != (oldrem & 0x8000_0000))
					remainder ^= __poly;
			}
			
			// Store
			table[i] = remainder;
		}
		
		// Store
		this._table = table;
	}
	
	/**
	 * Obtains the CRC table.
	 *
	 * @param __poly The polynomial.
	 * @return The CRC table.
	 * @since 2016/07/16
	 */
	static final __CRC32Table__ __table(int __poly)
	{
		// Lock
		Map<Integer, Reference<__CRC32Table__>> tables =
			__CRC32Table__._TABLES;
		synchronized (tables)
		{
			// Get
			Integer i = Integer.valueOf(__poly);
			Reference<__CRC32Table__> ref = tables.get(i);
			__CRC32Table__ rv;
		
			// Cache?
			if (ref == null || null == (rv = ref.get()))
				tables.put(i,
					new WeakReference<>((rv = new __CRC32Table__(__poly))));
		
			// Return
			return rv;
		}
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/__RewriteType__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.io;

/**
 * The type of data to write in.
 *
 * @since 2019/08/17
 */
enum __RewriteType__
{
	/** Short. */
	SHORT,
	
	/** Integer. */
	INTEGER,
	
	/** End. */
	;
}

Added modules/io/src/main/java/net/multiphasicapps/io/__RewriteValue__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.io;

/**
 * This is the value to be written.
 *
 * @since 2019/08/17
 */
enum __RewriteValue__
{
	/** Address. */
	ADDRESS,
	
	/** Size. */
	SIZE,
	
	/** End. */
	;
}

Added modules/io/src/main/java/net/multiphasicapps/io/__Rewrite__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.io;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This stores a single rewrite.
 *
 * @since 2019/08/17
 */
final class __Rewrite__
{
	/** The address. */
	final int _address;
	
	/** The type. */
	final __RewriteType__ _type;
	
	/** The value. */
	final __RewriteValue__ _value;
	
	/** Value offset. */
	final int _offset;
	
	/** The target section to use. */
	final Reference<TableSectionOutputStream.Section> _section;
	
	/**
	 * Initializes the rewrite info.
	 *
	 * @param __addr The address to replace.
	 * @param __type The value type to rewrite.
	 * @param __value The value of the information.
	 * @param __offset The value offset.
	 * @param __section The section being targeted, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/17
	 */
	__Rewrite__(int __addr, __RewriteType__ __type, __RewriteValue__ __value,
		int __offset, TableSectionOutputStream.Section __section)
		throws NullPointerException
	{
		if (__type == null || __value == null)
			throw new NullPointerException("NARG");
		
		this._address = __addr;
		this._type = __type;
		this._value = __value;
		this._offset = __offset;
		this._section = (__section == null ? null :
			new WeakReference<>(__section));
	}
}

Added modules/io/src/main/java/net/multiphasicapps/io/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the data related input and output streams.
 *
 * @since 2016/07/09
 */

package net.multiphasicapps.io;

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

import net.multiphasicapps.io.Base64Alphabet;
import net.multiphasicapps.io.Base64Decoder;
import net.multiphasicapps.tac.TestBiConsumer;

/**
 * This tests the base 64 decoder.
 *
 * @since 2018/03/06
 */
public class TestBase64Decoder
	extends TestBiConsumer<String, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06	
	 */
	@Override
	public void test(String __a, String __b)
		throws Throwable
	{
		this.secondary("a", new String(Base64Decoder.decode(__a,
			Base64Alphabet.BASIC), "utf-8"));
		this.secondary("b", new String(Base64Decoder.decode(__b,
			Base64Alphabet.BASIC), "utf-8"));
	}
}

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.DeflaterOutputStream;
import net.multiphasicapps.io.InflaterInputStream;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the deflater and then the inflater, making sure that compressed
 * data ends up the same when decompressed.
 *
 * @since 2018/11/10
 */
public class TestDeflaterInflater
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		// Read in the message first
		byte[] message;
		try (InputStream in = TestDeflaterInflater.class.getResourceAsStream(
			"message");
			ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Copy in data
			byte[] buf = new byte[128];
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Finalize
			message = baos.toByteArray();
		}
		
		// Original message as a string for comparison
		String original = new String(message, "iso-8859-1");
		
		// Compression is hopefully smaller so use a buffer size matching this
		int gn = message.length;
		
		// For each compression level since they vary
		int rv = 0;
		for (CompressionLevel cl : CompressionLevel.values())
		{
			// Compress the data with my compression code first
			byte[] compressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Compress the input message
				try (DeflaterOutputStream dos = new DeflaterOutputStream(baos))
				{
					dos.write(message);
				}
				
				// Need to keep this message
				compressed = baos.toByteArray();
			}
			
			// Then it will be decompressed accordingly
			byte[] decompressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Decompress the message
				try (InflaterInputStream iis = new InflaterInputStream(
					new ByteArrayInputStream(compressed)))
				{
					byte[] buf = new byte[128];
					for (;;)
					{
						int rc = iis.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Store decompressed message
				decompressed = baos.toByteArray();
			}
			
			// Return string as processed through the algorithm
			String result = new String(decompressed, "iso-8859-1");
			
			// If the strings are the same then it is okay!
			if (original.equals(result))
				rv++;
			
			// Otherwise flag it and note it
			else
				this.secondary("failed-" + cl, result);
		}
		
		return rv;
	}
}

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

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Objects;
import net.multiphasicapps.io.MIMEFileDecoder;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests decoding of MIME files.
 *
 * @since 2018/11/25
 */
public class TestMIMEFileDecoder
	extends TestSupplier<Boolean>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public Boolean test()
		throws Throwable
	{
		byte[] buf = new byte[512];
		
		// Read the expected message
		byte[] expected;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream in = this.getClass().getResourceAsStream("message"))
		{
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Read it
			expected = baos.toByteArray();
		}
		
		// Decode
		byte[] decoded;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream in = new MIMEFileDecoder(new InputStreamReader(
			this.getClass().getResourceAsStream("mimemessage"), "utf-8")))
		{
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Read it
			decoded = baos.toByteArray();
		}
		
		// The decoded is a fixed length, even with the raw data
		this.secondary("dlen", decoded.length);
		
		// Compare all lines
		int linecount = 0;
		try (BufferedReader dec = new BufferedReader(new InputStreamReader(
				new ByteArrayInputStream(decoded), "utf-8"));
			BufferedReader exp = new BufferedReader(new InputStreamReader(
				new ByteArrayInputStream(expected), "utf-8")))
		{
			for (;; linecount++)
			{
				String dl = dec.readLine();
				String xl = exp.readLine();
				
				// Compare equality first
				if (!Objects.equals(dl, xl))
				{
					// Add these in case
					this.secondary("decoded", dl);
					this.secondary("expected", xl);
					
					// Fail
					return false;
				}
				
				if (dl == null || xl == null)
					break;
			}
		}
		
		// Line count
		this.secondary("linecount", linecount);
		
		// Would be a mis-match if not reached
		return true;
	}
}

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.ZLibCompressor;
import net.multiphasicapps.io.ZLibDecompressor;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the deflater and then the inflater, making sure that compressed
 * data ends up the same when decompressed.
 *
 * @since 2018/11/11
 */
public class TestZlibCompressorDecompressor
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		// Read in the message first
		byte[] message;
		try (InputStream in = TestDeflaterInflater.class.getResourceAsStream(
			"message");
			ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Copy in data
			byte[] buf = new byte[128];
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Finalize
			message = baos.toByteArray();
		}
		
		// Original message as a string for comparison
		String original = new String(message, "iso-8859-1");
		
		// Compression is hopefully smaller so use a buffer size matching this
		int gn = message.length;
		
		// For each compression level since they vary
		int rv = 0;
		for (CompressionLevel cl : CompressionLevel.values())
		{
			// Compress the data with my compression code first
			byte[] compressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Compress the input message
				try (ZLibCompressor dos = new ZLibCompressor(baos))
				{
					dos.write(message);
				}
				
				// Need to keep this message
				compressed = baos.toByteArray();
			}
			
			// Then it will be decompressed accordingly
			byte[] decompressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Decompress the message
				try (ZLibDecompressor iis = new ZLibDecompressor(
					new ByteArrayInputStream(compressed)))
				{
					byte[] buf = new byte[128];
					for (;;)
					{
						int rc = iis.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Store decompressed message
				decompressed = baos.toByteArray();
			}
			
			// Return string as processed through the algorithm
			String result = new String(decompressed, "iso-8859-1");
			
			// If the strings are the same then it is okay!
			if (original.equals(result))
				rv++;
			
			// Otherwise flag it and note it
			else
				this.secondary("failed-" + cl, result);
		}
		
		return rv;
	}
}

Added modules/io/src/test/resources/TestBase64Decoder.in.








1
2
3
4
5
6
7
+
+
+
+
+
+
+
argument-1: string:SSBsb3ZlIHNxdWlycmVscyE=
argument-2: string:SSBsb3ZlIExlYWggYW5kIEppbmV0dGUsIEkgcmVhbGx5IGRvIQ==
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:I\_love\_squirrels!
secondary-b: string:I\_love\_Leah\_and\_Jinette,\_I\_really\_do!

Added modules/io/src/test/resources/TestDeflaterInflater.in.




1
2
3
+
+
+
result: int:6
thrown: NoExceptionThrown

Added modules/io/src/test/resources/TestMIMEFileDecoder.in.





1
2
3
4
+
+
+
+
result: true
thrown: NoExceptionThrown
secondary-dlen: int:4988
secondary-linecount: int:71

Added modules/io/src/test/resources/TestZlibCompressorDecompressor.in.




1
2
3
+
+
+
result: int:6
thrown: NoExceptionThrown

Added modules/io/src/test/resources/message.








































































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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From the Encyclopedia Britannica 11th Edition, Volume 25
This is under the public domain.

SQUIRREL, properly the name of the well known red, bushy-tailed British
arboreal mammal, Sciurus vulgaris, typifying the genus Sciurus and the family
Sciuridae, but in a wider sense embracing all the rodents included in this and
a few nearly allied genera. For the characteristics of the family Sciuridae and
the different squirrel-like genera by which it is represented, see RODENTIA.

What may be called typical, that is so arboreal, squirrels are found throughout
the greater part of the tropical and temperate regions of both hemispheres,
although they are absent both from Madagascar and Australasia. The species are
both largest and most numerous in the tropics, and reach their greatest
development in the Malay countries. Squirrels vary in size from animals no
larger than a mouse, such as the Nannosciurus soricirius of Borneo, or N.
ininulus of West Africa, to others as large as a cat, such as the black and
yellow Ratufa bi-color of Burma and the Malay area. The larger species, as
might be expected from their heavier build, are somewhat less strictly arboreal
in their habits than the smaller ones. The common squirrel, whose habits are
too well known to need special description, ranges over the whole of Europe and
Norther Asia, from Ireland to Japan, and from Lapland to North Italy; but
specimens from different parts of this wide range differ so much in color as to
constitute distinct races. Thus, while the squirrels of north and west Europe
are of the bright red color of the British animal, those of the mountainous
regions of southern Europe are of a deep blackish gray; while those from
Siberia are a clear pale grey colour, with scarcely a tinge of rufous. There is
also a great seasonal change in appearance and color in this squirrel, owing to
the ears losing their tufts of hair and the bleaching of the tail. The pairing
time of the squirrel is from February to April; and after a period of gestation
of about thirty days the female brings forth from three to nine young. In
addition to all sorts of vegetables and fruits, the squirrel is exceedingly
fond of animal food, greedily devouring mice, small birds and eggs. The
squirrels of the typical genus Sciurus are unknown in Africa south of the
Sahara, but otherwise have a distribution co-extensive with the rest of the
family.

Although the English squirrel is a beautiful little animal, it is surpassed by
the many of the tropical members of the group, and especially by those of the
Malay countries, where nearly all the species are brilliantly marked, and many
are ornamented with variously colored longitudinal stripes along their bodies.
Every one who has visited India is familiar with the pretty little striped
palm-squirrel, which is to a considerable extent a partially domesticated
animal, or, rather, and animal which has taken to quarter itself in the
immediate neighborhood of human habitations. It has been generally supposed
that there is only one palm-squirrel throughout India, but there are really
two distinct types, each with local modifications. The first or typical
palm-squirrel, Funambulus palmaraum, inhabits Madras, has but three light
stripes on the back, and shows a rufous hand on the under-side of the base of
the tail. In Pennant's palm-squirrel, F. pennanti, on the other hand, there is
a pair of faint additional lateral white stripes, making five in all, and the
under-surface of the tail is uniformly whitish olive. As this species has been
obtained in Surat and the Punjab, it is believed to be the northern type. One
Oriental species (Sciurus caniceps) presents almost the only known instance
among mammals of the assumption during the breeding season of a distinctly
ornamental coat, corresponding to the breeding plumage of birds. For the
greater part of the tear the animal is of a uniform gray color, but about
December its back becomes a brilliant orange-yellow, which lasts until about
March, when it is again replaced by gray. The squirrel shown in the
illustration is a native of Burma and Tenasserim, and is closely allied to S.
caniceps, but goes through no seasonal change of color. Another Burmese
squirrel, S. haringtoni, differs as regards in a remarkabale manner from all
other known members of the group. It is a medium-sized species of a pale creamy
buff color above, lighter beneath, and with a whitish tail, while it is further
characterized by the absence of the first upper premolar, which shows that it
is not an albino or pale variety. Two examples were obtains by Captain H. H.
Harington, of one of the Punjabu regiments, on the Upper Chindwin river. It may
also be added that generic subdivisions of the squirrels are based mainly on
the characters of the skull and teeth. That they are essential is evident from
the circumstances that the African spiny squirrels Xerus (see SPINY SQUIRREL)
come between Sciurus and some of the other African genera.

Added modules/io/src/test/resources/mimemessage.


















































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 message
RnJvbSB0aGUgRW5jeWNsb3BlZGlhIEJyaXRhbm5pY2EgMTF0aCBFZGl0aW9u
LCBWb2x1bWUgMjUKVGhpcyBpcyB1bmRlciB0aGUgcHVibGljIGRvbWFpbi4K
ClNRVUlSUkVMLCBwcm9wZXJseSB0aGUgbmFtZSBvZiB0aGUgd2VsbCBrbm93
biByZWQsIGJ1c2h5LXRhaWxlZCBCcml0aXNoCmFyYm9yZWFsIG1hbW1hbCwg
U2NpdXJ1cyB2dWxnYXJpcywgdHlwaWZ5aW5nIHRoZSBnZW51cyBTY2l1cnVz
IGFuZCB0aGUgZmFtaWx5ClNjaXVyaWRhZSwgYnV0IGluIGEgd2lkZXIgc2Vu
c2UgZW1icmFjaW5nIGFsbCB0aGUgcm9kZW50cyBpbmNsdWRlZCBpbiB0aGlz
IGFuZAphIGZldyBuZWFybHkgYWxsaWVkIGdlbmVyYS4gRm9yIHRoZSBjaGFy
YWN0ZXJpc3RpY3Mgb2YgdGhlIGZhbWlseSBTY2l1cmlkYWUgYW5kCnRoZSBk
aWZmZXJlbnQgc3F1aXJyZWwtbGlrZSBnZW5lcmEgYnkgd2hpY2ggaXQgaXMg
cmVwcmVzZW50ZWQsIHNlZSBST0RFTlRJQS4KCldoYXQgbWF5IGJlIGNhbGxl
ZCB0eXBpY2FsLCB0aGF0IGlzIHNvIGFyYm9yZWFsLCBzcXVpcnJlbHMgYXJl
IGZvdW5kIHRocm91Z2hvdXQKdGhlIGdyZWF0ZXIgcGFydCBvZiB0aGUgdHJv
cGljYWwgYW5kIHRlbXBlcmF0ZSByZWdpb25zIG9mIGJvdGggaGVtaXNwaGVy
ZXMsCmFsdGhvdWdoIHRoZXkgYXJlIGFic2VudCBib3RoIGZyb20gTWFkYWdh
c2NhciBhbmQgQXVzdHJhbGFzaWEuIFRoZSBzcGVjaWVzIGFyZQpib3RoIGxh
cmdlc3QgYW5kIG1vc3QgbnVtZXJvdXMgaW4gdGhlIHRyb3BpY3MsIGFuZCBy
ZWFjaCB0aGVpciBncmVhdGVzdApkZXZlbG9wbWVudCBpbiB0aGUgTWFsYXkg
Y291bnRyaWVzLiBTcXVpcnJlbHMgdmFyeSBpbiBzaXplIGZyb20gYW5pbWFs
cyBubwpsYXJnZXIgdGhhbiBhIG1vdXNlLCBzdWNoIGFzIHRoZSBOYW5ub3Nj
aXVydXMgc29yaWNpcml1cyBvZiBCb3JuZW8sIG9yIE4uCmluaW51bHVzIG9m
IFdlc3QgQWZyaWNhLCB0byBvdGhlcnMgYXMgbGFyZ2UgYXMgYSBjYXQsIHN1
Y2ggYXMgdGhlIGJsYWNrIGFuZAp5ZWxsb3cgUmF0dWZhIGJpLWNvbG9yIG9m
IEJ1cm1hIGFuZCB0aGUgTWFsYXkgYXJlYS4gVGhlIGxhcmdlciBzcGVjaWVz
LCBhcwptaWdodCBiZSBleHBlY3RlZCBmcm9tIHRoZWlyIGhlYXZpZXIgYnVp
bGQsIGFyZSBzb21ld2hhdCBsZXNzIHN0cmljdGx5IGFyYm9yZWFsCmluIHRo
ZWlyIGhhYml0cyB0aGFuIHRoZSBzbWFsbGVyIG9uZXMuIFRoZSBjb21tb24g
c3F1aXJyZWwsIHdob3NlIGhhYml0cyBhcmUKdG9vIHdlbGwga25vd24gdG8g
bmVlZCBzcGVjaWFsIGRlc2NyaXB0aW9uLCByYW5nZXMgb3ZlciB0aGUgd2hv
bGUgb2YgRXVyb3BlIGFuZApOb3J0aGVyIEFzaWEsIGZyb20gSXJlbGFuZCB0
byBKYXBhbiwgYW5kIGZyb20gTGFwbGFuZCB0byBOb3J0aCBJdGFseTsgYnV0
CnNwZWNpbWVucyBmcm9tIGRpZmZlcmVudCBwYXJ0cyBvZiB0aGlzIHdpZGUg
cmFuZ2UgZGlmZmVyIHNvIG11Y2ggaW4gY29sb3IgYXMgdG8KY29uc3RpdHV0
ZSBkaXN0aW5jdCByYWNlcy4gVGh1cywgd2hpbGUgdGhlIHNxdWlycmVscyBv
ZiBub3J0aCBhbmQgd2VzdCBFdXJvcGUKYXJlIG9mIHRoZSBicmlnaHQgcmVk
IGNvbG9yIG9mIHRoZSBCcml0aXNoIGFuaW1hbCwgdGhvc2Ugb2YgdGhlIG1v
dW50YWlub3VzCnJlZ2lvbnMgb2Ygc291dGhlcm4gRXVyb3BlIGFyZSBvZiBh
IGRlZXAgYmxhY2tpc2ggZ3JheTsgd2hpbGUgdGhvc2UgZnJvbQpTaWJlcmlh
IGFyZSBhIGNsZWFyIHBhbGUgZ3JleSBjb2xvdXIsIHdpdGggc2NhcmNlbHkg
YSB0aW5nZSBvZiBydWZvdXMuIFRoZXJlIGlzCmFsc28gYSBncmVhdCBzZWFz
b25hbCBjaGFuZ2UgaW4gYXBwZWFyYW5jZSBhbmQgY29sb3IgaW4gdGhpcyBz
cXVpcnJlbCwgb3dpbmcgdG8KdGhlIGVhcnMgbG9zaW5nIHRoZWlyIHR1ZnRz
IG9mIGhhaXIgYW5kIHRoZSBibGVhY2hpbmcgb2YgdGhlIHRhaWwuIFRoZSBw
YWlyaW5nCnRpbWUgb2YgdGhlIHNxdWlycmVsIGlzIGZyb20gRmVicnVhcnkg
dG8gQXByaWw7IGFuZCBhZnRlciBhIHBlcmlvZCBvZiBnZXN0YXRpb24Kb2Yg
YWJvdXQgdGhpcnR5IGRheXMgdGhlIGZlbWFsZSBicmluZ3MgZm9ydGggZnJv
bSB0aHJlZSB0byBuaW5lIHlvdW5nLiBJbgphZGRpdGlvbiB0byBhbGwgc29y
dHMgb2YgdmVnZXRhYmxlcyBhbmQgZnJ1aXRzLCB0aGUgc3F1aXJyZWwgaXMg
ZXhjZWVkaW5nbHkKZm9uZCBvZiBhbmltYWwgZm9vZCwgZ3JlZWRpbHkgZGV2
b3VyaW5nIG1pY2UsIHNtYWxsIGJpcmRzIGFuZCBlZ2dzLiBUaGUKc3F1aXJy
ZWxzIG9mIHRoZSB0eXBpY2FsIGdlbnVzIFNjaXVydXMgYXJlIHVua25vd24g
aW4gQWZyaWNhIHNvdXRoIG9mIHRoZQpTYWhhcmEsIGJ1dCBvdGhlcndpc2Ug
aGF2ZSBhIGRpc3RyaWJ1dGlvbiBjby1leHRlbnNpdmUgd2l0aCB0aGUgcmVz
dCBvZiB0aGUKZmFtaWx5LgoKQWx0aG91Z2ggdGhlIEVuZ2xpc2ggc3F1aXJy
ZWwgaXMgYSBiZWF1dGlmdWwgbGl0dGxlIGFuaW1hbCwgaXQgaXMgc3VycGFz
c2VkIGJ5CnRoZSBtYW55IG9mIHRoZSB0cm9waWNhbCBtZW1iZXJzIG9mIHRo
ZSBncm91cCwgYW5kIGVzcGVjaWFsbHkgYnkgdGhvc2Ugb2YgdGhlCk1hbGF5
IGNvdW50cmllcywgd2hlcmUgbmVhcmx5IGFsbCB0aGUgc3BlY2llcyBhcmUg
YnJpbGxpYW50bHkgbWFya2VkLCBhbmQgbWFueQphcmUgb3JuYW1lbnRlZCB3
aXRoIHZhcmlvdXNseSBjb2xvcmVkIGxvbmdpdHVkaW5hbCBzdHJpcGVzIGFs
b25nIHRoZWlyIGJvZGllcy4KRXZlcnkgb25lIHdobyBoYXMgdmlzaXRlZCBJ
bmRpYSBpcyBmYW1pbGlhciB3aXRoIHRoZSBwcmV0dHkgbGl0dGxlIHN0cmlw
ZWQKcGFsbS1zcXVpcnJlbCwgd2hpY2ggaXMgdG8gYSBjb25zaWRlcmFibGUg
ZXh0ZW50IGEgcGFydGlhbGx5IGRvbWVzdGljYXRlZAphbmltYWwsIG9yLCBy
YXRoZXIsIGFuZCBhbmltYWwgd2hpY2ggaGFzIHRha2VuIHRvIHF1YXJ0ZXIg
aXRzZWxmIGluIHRoZQppbW1lZGlhdGUgbmVpZ2hib3Job29kIG9mIGh1bWFu
IGhhYml0YXRpb25zLiBJdCBoYXMgYmVlbiBnZW5lcmFsbHkgc3VwcG9zZWQK
dGhhdCB0aGVyZSBpcyBvbmx5IG9uZSBwYWxtLXNxdWlycmVsIHRocm91Z2hv
dXQgSW5kaWEsIGJ1dCB0aGVyZSBhcmUgcmVhbGx5CnR3byBkaXN0aW5jdCB0
eXBlcywgZWFjaCB3aXRoIGxvY2FsIG1vZGlmaWNhdGlvbnMuIFRoZSBmaXJz
dCBvciB0eXBpY2FsCnBhbG0tc3F1aXJyZWwsIEZ1bmFtYnVsdXMgcGFsbWFy
YXVtLCBpbmhhYml0cyBNYWRyYXMsIGhhcyBidXQgdGhyZWUgbGlnaHQKc3Ry
aXBlcyBvbiB0aGUgYmFjaywgYW5kIHNob3dzIGEgcnVmb3VzIGhhbmQgb24g
dGhlIHVuZGVyLXNpZGUgb2YgdGhlIGJhc2Ugb2YKdGhlIHRhaWwuIEluIFBl
bm5hbnQncyBwYWxtLXNxdWlycmVsLCBGLiBwZW5uYW50aSwgb24gdGhlIG90
aGVyIGhhbmQsIHRoZXJlIGlzCmEgcGFpciBvZiBmYWludCBhZGRpdGlvbmFs
IGxhdGVyYWwgd2hpdGUgc3RyaXBlcywgbWFraW5nIGZpdmUgaW4gYWxsLCBh
bmQgdGhlCnVuZGVyLXN1cmZhY2Ugb2YgdGhlIHRhaWwgaXMgdW5pZm9ybWx5
IHdoaXRpc2ggb2xpdmUuIEFzIHRoaXMgc3BlY2llcyBoYXMgYmVlbgpvYnRh
aW5lZCBpbiBTdXJhdCBhbmQgdGhlIFB1bmphYiwgaXQgaXMgYmVsaWV2ZWQg
dG8gYmUgdGhlIG5vcnRoZXJuIHR5cGUuIE9uZQpPcmllbnRhbCBzcGVjaWVz
IChTY2l1cnVzIGNhbmljZXBzKSBwcmVzZW50cyBhbG1vc3QgdGhlIG9ubHkg
a25vd24gaW5zdGFuY2UKYW1vbmcgbWFtbWFscyBvZiB0aGUgYXNzdW1wdGlv
biBkdXJpbmcgdGhlIGJyZWVkaW5nIHNlYXNvbiBvZiBhIGRpc3RpbmN0bHkK
b3JuYW1lbnRhbCBjb2F0LCBjb3JyZXNwb25kaW5nIHRvIHRoZSBicmVlZGlu
ZyBwbHVtYWdlIG9mIGJpcmRzLiBGb3IgdGhlCmdyZWF0ZXIgcGFydCBvZiB0
aGUgdGVhciB0aGUgYW5pbWFsIGlzIG9mIGEgdW5pZm9ybSBncmF5IGNvbG9y
LCBidXQgYWJvdXQKRGVjZW1iZXIgaXRzIGJhY2sgYmVjb21lcyBhIGJyaWxs
aWFudCBvcmFuZ2UteWVsbG93LCB3aGljaCBsYXN0cyB1bnRpbCBhYm91dApN
YXJjaCwgd2hlbiBpdCBpcyBhZ2FpbiByZXBsYWNlZCBieSBncmF5LiBUaGUg
c3F1aXJyZWwgc2hvd24gaW4gdGhlCmlsbHVzdHJhdGlvbiBpcyBhIG5hdGl2
ZSBvZiBCdXJtYSBhbmQgVGVuYXNzZXJpbSwgYW5kIGlzIGNsb3NlbHkgYWxs
aWVkIHRvIFMuCmNhbmljZXBzLCBidXQgZ29lcyB0aHJvdWdoIG5vIHNlYXNv
bmFsIGNoYW5nZSBvZiBjb2xvci4gQW5vdGhlciBCdXJtZXNlCnNxdWlycmVs
LCBTLiBoYXJpbmd0b25pLCBkaWZmZXJzIGFzIHJlZ2FyZHMgaW4gYSByZW1h
cmthYmFsZSBtYW5uZXIgZnJvbSBhbGwKb3RoZXIga25vd24gbWVtYmVycyBv
ZiB0aGUgZ3JvdXAuIEl0IGlzIGEgbWVkaXVtLXNpemVkIHNwZWNpZXMgb2Yg
YSBwYWxlIGNyZWFteQpidWZmIGNvbG9yIGFib3ZlLCBsaWdodGVyIGJlbmVh
dGgsIGFuZCB3aXRoIGEgd2hpdGlzaCB0YWlsLCB3aGlsZSBpdCBpcyBmdXJ0
aGVyCmNoYXJhY3Rlcml6ZWQgYnkgdGhlIGFic2VuY2Ugb2YgdGhlIGZpcnN0
IHVwcGVyIHByZW1vbGFyLCB3aGljaCBzaG93cyB0aGF0IGl0CmlzIG5vdCBh
biBhbGJpbm8gb3IgcGFsZSB2YXJpZXR5LiBUd28gZXhhbXBsZXMgd2VyZSBv
YnRhaW5zIGJ5IENhcHRhaW4gSC4gSC4KSGFyaW5ndG9uLCBvZiBvbmUgb2Yg
dGhlIFB1bmphYnUgcmVnaW1lbnRzLCBvbiB0aGUgVXBwZXIgQ2hpbmR3aW4g
cml2ZXIuIEl0IG1heQphbHNvIGJlIGFkZGVkIHRoYXQgZ2VuZXJpYyBzdWJk
aXZpc2lvbnMgb2YgdGhlIHNxdWlycmVscyBhcmUgYmFzZWQgbWFpbmx5IG9u
CnRoZSBjaGFyYWN0ZXJzIG9mIHRoZSBza3VsbCBhbmQgdGVldGguIFRoYXQg
dGhleSBhcmUgZXNzZW50aWFsIGlzIGV2aWRlbnQgZnJvbQp0aGUgY2lyY3Vt
c3RhbmNlcyB0aGF0IHRoZSBBZnJpY2FuIHNwaW55IHNxdWlycmVscyBYZXJ1
cyAoc2VlIFNQSU5ZIFNRVUlSUkVMKQpjb21lIGJldHdlZW4gU2NpdXJ1cyBh
bmQgc29tZSBvZiB0aGUgb3RoZXIgQWZyaWNhbiBnZW5lcmEuCgo=
====

Added modules/jblend-api/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "Proprietary Aplix JBlend API"
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "LB"
	swmType = JavaMEMidletType.API
	swmName = "Aplix JBlend API"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-midlet")
	implementation project(":modules:midp-lcdui")
}

Added modules/jblend-api/src/main/java/com/jblend/graphics/WindowSystem.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.graphics;

public class WindowSystem
{
    public final int real_width;
    public final int real_height;
    public final int virtual_width;
    public final int virtual_height;
    public final boolean isColor;
    public final int numColors;
    public final boolean hasPointerEvents;
    public final boolean hasPointerMotionEvents;
    public final int numSoftkeys;
    
    public WindowSystem()
	{
		throw new todo.TODO();
	}

    public static WindowSystem getDefaultWindowSystem()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/ConnectorImpl.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

public class ConnectorImpl
{
    public static synchronized Class getProtocol(String var0)
	{
		throw new todo.TODO();
	}

    public static synchronized void setProtocol(String var0, String var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/NotSimpleSerializableException.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

public class NotSimpleSerializableException
	extends SimpleSerializeException
{
	public NotSimpleSerializableException()
	{
		super(null);
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/SimpleObjectInputStream.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

public class SimpleObjectInputStream
	extends DataInputStream
{
    public SimpleObjectInputStream(InputStream var1) {
        super((InputStream)null);
        
        throw new todo.TODO();
    }

    public String readString() throws IOException
	{
		throw new todo.TODO();
	}

    public SimpleSerializable read(SimpleSerializable var1) throws IOException
	{
		throw new todo.TODO();
	}

    public Object dispatchReadCommand(Class var1) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/SimpleObjectOutputStream.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class SimpleObjectOutputStream
	extends DataOutputStream
{
    public SimpleObjectOutputStream(OutputStream var1) {
        super((OutputStream)null);
        
        throw new todo.TODO();
    }

    public void write(String var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void write(SimpleSerializable var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void dispatchWriteCommand(Object var1) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/SimpleSerializable.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

import java.io.IOException;

public interface SimpleSerializable
{
    void writeObject(SimpleObjectOutputStream var1) throws IOException;

    void readObject(SimpleObjectInputStream var1) throws IOException;
}

Added modules/jblend-api/src/main/java/com/jblend/io/SimpleSerializeException.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io;

import java.io.IOException;

public class SimpleSerializeException
	extends IOException
{
    public SimpleSerializeException(String var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/EventDispatcher.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

import javax.microedition.midlet.MIDlet;

public class EventDispatcher
{
    public EventDispatcher()
    {
    	throw new todo.TODO();
    }

    public static Thread getEventThread()
	{
		throw new todo.TODO();
	}

    public static void start()
	{
		throw new todo.TODO();
	}

    public static void setCurrentMIDlet(MIDlet var0)
	{
		throw new todo.TODO();
	}

    public static void setJoclEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static UiEventDispatcherInterface setUiEventDispatcherInterface(UiEventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setMIDletEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setMediaEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setSmafEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setPhraseEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setDialEventDispatcherInterface(EventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static synchronized int setOptionalEventDispatcher(EventDispatcherInterface var0, int var1)
	{
		throw new todo.TODO();
	}

    public static int setOptionalEventDispatcher(EventDispatcherInterface var0, int var1, String var2)
	{
		throw new todo.TODO();
	}

    public static synchronized void dispatchEvent()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/EventDispatcherInterface.java.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface EventDispatcherInterface
{
    void dispatch(int var1, int var2, int var3, int var4);
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/EventType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface EventType
{
    int PRESSED = 1;
    int RELEASED = 2;
    int CLICKED = 3;
    int EXPIRED = 4;
    int STARTED = 5;
    int STOPPED = 6;
    int PAUSED = 7;
    int REQUEST_PAUSE = 8;
    int REQUEST_STOP = 9;
    int REQUEST_RESUME = 10;
    int CALLING = 11;
    int RECEIVED = 12;
    int SCHEDULED_ALARM = 13;
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/InternalEvent.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface InternalEvent
{
    int BEAM_RECEIVE_KVM_EVENT = 0;
    int PEN_DOWN_KVM_EVENT = 1;
    int PEN_UP_KVM_EVENT = 2;
    int PEN_MOVE_KVM_EVENT = 3;
    int KEY_DOWN_KVM_EVENT = 4;
    int KEY_UP_KVM_EVENT = 5;
    int LAST_KVM_EVENT = 6;
    int APP_STOP_KVM_EVENT = 7;
    int UI_KVM_EVENT = 8;
    int TIMER_KVM_EVENT = 9;
    int PLATFORM_KVM_EVENT = 10;
    int SOUND_KVM_EVENT = 11;
    int MEDIA_KVM_EVENT = 12;
    int DIAL_KVM_EVENT = 14;
    int APP_RESUME_KVM_EVENT = 100;
    int APP_SUSPEND_KVM_EVENT = 101;
    int GENERAL_NOTIFY_EVENT = 200;
    int ANI_CHAR_EVENT = 221;
    int USER_KVM_EVENT = 255;
    int VENDOR_KVM_EVENT = 1000;
    int OPTIONAL_EVENT_ORIGIN = 10000;
    int MAX_OPTIONAL_EVENT = 5;
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/JoclEventDispatcher.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

@SuppressWarnings("NewMethodNamingConvention")
public class JoclEventDispatcher
	implements EventDispatcherInterface
{
	
	public void dispatch(int var1, int var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public static void setPhraseEventDispatcherInterface(JoclEventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setMediaEventDispatcherInterface(JoclEventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setPlatformEventDispatcherInterface(JoclEventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void setVendorEventDispatcherInterface(JoclEventDispatcherInterface var0)
	{
		throw new todo.TODO();
	}

    public static void init()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/JoclEventDispatcherInterface.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface JoclEventDispatcherInterface
{
    void dispatch(int var1, int var2, int var3);
}


Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/NativeMediaEventDispatcher.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface NativeMediaEventDispatcher
{
    void stateChanged(int var1);

    void repeated(int var1);

    int getMediaType();
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/UiEventDispatcherInterface.java.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface UiEventDispatcherInterface
{
    void dispatchUi(int var1, int var2, int var3, int var4, int var5);
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/UiEventType.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

public interface UiEventType
{
    int CLICKED = 1;
    int SELECTED = 2;
    int DESELECTED = 3;
    int CHANGED = 4;
    int REPAINT = 5;
    int GOTDISPLAY = 6;
    int LOSTFOCUS = 7;
    int REPAINTCOMPONENT = 8;
    int RELEASEDISPLAY = 9;
}

Added modules/jblend-api/src/main/java/com/jblend/io/j2me/events/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.io.j2me.events;

Added modules/jblend-api/src/main/java/com/jblend/media/MediaData.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media;

import java.io.IOException;

public abstract class MediaData
{
    public MediaData()
	{
		throw new todo.TODO();
	}

    public MediaData(String var1)
    	throws IOException
	{
		throw new todo.TODO();
	}

    public MediaData(byte[] var1)
	{
		throw new todo.TODO();
	}

    public abstract String getMediaType();

    public abstract void setData(byte[] var1);
}

Added modules/jblend-api/src/main/java/com/jblend/media/MediaImageOperator.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media;

public interface MediaImageOperator
{
    int getX();

    int getY();

    int getWidth();

    int getHeight();

    void setBounds(int var1, int var2, int var3, int var4);

    int getOriginX();

    int getOriginY();

    void setOrigin(int var1, int var2);

    int getMediaWidth();

    int getMediaHeight();
}

Added modules/jblend-api/src/main/java/com/jblend/media/MediaPlayer.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media;

import com.jblend.io.j2me.events.NativeMediaEventDispatcher;

public abstract class MediaPlayer
{
    public static final int NO_DATA = 0;
    public static final int READY = 1;
    public static final int PLAYING = 2;
    public static final int PAUSED = 3;
    public static final int ERROR = 65536;
    
    protected static final int REAL_WIDTH =
    	todo.TODO.missingInteger();
    	
    protected static final int REAL_HEIGHT =
    	todo.TODO.missingInteger();

    public MediaPlayer()
	{
		throw new todo.TODO();
	}

    public abstract void setData(MediaData var1);

    public abstract void play();

    public abstract void play(boolean var1);

    public abstract void play(int var1);

    public abstract void stop();

    public abstract void pause();

    public abstract void resume();

    public abstract int getState();

    public abstract void addMediaPlayerListener(MediaPlayerListener var1);

    public abstract void removeMediaPlayerListener(MediaPlayerListener var1);

    protected static void addNativeMediaEventDispatcher(NativeMediaEventDispatcher var0)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/media/MediaPlayerListener.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media;

public interface MediaPlayerListener
{
    void playerStateChanged(MediaPlayer var1);

    void playerRepeated(MediaPlayer var1);
}

Added modules/jblend-api/src/main/java/com/jblend/media/audio/AudioData.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media.audio;

import com.jblend.media.MediaData;
import java.io.IOException;

public class AudioData
	extends MediaData
{
    public static final String type = "AUDIO";

    public AudioData()
	{
		throw new todo.TODO();
	}

    public AudioData(String var1)
    	throws IOException
	{
		throw new todo.TODO();
	}

    public AudioData(byte[] var1)
	{
		throw new todo.TODO();
	}

    public String getMediaType()
	{
		throw new todo.TODO();
	}

    public void setData(byte[] var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/media/audio/AudioPlayer.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media.audio;

import com.jblend.media.MediaData;
import com.jblend.media.MediaPlayer;
import com.jblend.media.MediaPlayerListener;

public class AudioPlayer
	extends MediaPlayer
{
    public AudioPlayer()
	{
		throw new todo.TODO();
	}

    public AudioPlayer(AudioData var1)
	{
		throw new todo.TODO();
	}

    public AudioPlayer(byte[] var1)
	{
		throw new todo.TODO();
	}

    public static int checkData(byte[] var0)
	{
		throw new todo.TODO();
	}

    public void setData(AudioData var1)
	{
		throw new todo.TODO();
	}

    public void setData(MediaData var1)
	{
		throw new todo.TODO();
	}

    public int getCurrent()
	{
		throw new todo.TODO();
	}

    public int getVolume()
	{
		throw new todo.TODO();
	}

    public void setVolume(int var1)
	{
		throw new todo.TODO();
	}

    public void play()
	{
		throw new todo.TODO();
	}

    public void play(boolean var1)
	{
		throw new todo.TODO();
	}

    public void play(int var1)
	{
		throw new todo.TODO();
	}

    public void stop()
	{
		throw new todo.TODO();
	}

    public void pause()
	{
		throw new todo.TODO();
	}

    public void resume()
	{
		throw new todo.TODO();
	}

    public int getState()
	{
		throw new todo.TODO();
	}

    public void addMediaPlayerListener(MediaPlayerListener var1)
	{
		throw new todo.TODO();
	}

    public void removeMediaPlayerListener(MediaPlayerListener var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/media/audio/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media.audio;

Added modules/jblend-api/src/main/java/com/jblend/media/video/VideoData.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media.video;

import com.jblend.media.MediaData;
import java.io.IOException;

public class VideoData extends MediaData {
    public static final String type = "VIDEO";

    public VideoData() {
    }

    public VideoData(String var1) throws IOException {
    }

    public VideoData(byte[] var1) {
    }

    public int getWidth()
	{
		throw new todo.TODO();
	}

    public int getHeight()
	{
		throw new todo.TODO();
	}

    public String getMediaType()
	{
		throw new todo.TODO();
	}

    public void setData(byte[] var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/media/video/VideoPlayer.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.media.video;

import com.jblend.media.MediaData;
import com.jblend.media.MediaImageOperator;
import com.jblend.media.MediaPlayer;
import com.jblend.media.MediaPlayerListener;

public class VideoPlayer
	extends MediaPlayer
	implements MediaImageOperator {
    public VideoPlayer()
	{
		throw new todo.TODO();
	}

    public VideoPlayer(VideoData var1)
	{
		throw new todo.TODO();
	}

    public VideoPlayer(byte[] var1)
	{
		throw new todo.TODO();
	}

    public static int checkData(byte[] var0)
	{
		throw new todo.TODO();
	}

    public void setData(VideoData var1)
	{
		throw new todo.TODO();
	}

    public void setData(MediaData var1)
	{
		throw new todo.TODO();
	}

    public int getX()
	{
		throw new todo.TODO();
	}

    public int getY()
	{
		throw new todo.TODO();
	}

    public int getWidth()
	{
		throw new todo.TODO();
	}

    public int getHeight()
	{
		throw new todo.TODO();
	}

    public void setBounds(int var1, int var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public int getOriginX()
	{
		throw new todo.TODO();
	}

    public int getOriginY()
	{
		throw new todo.TODO();
	}

    public void setOrigin(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public int getMediaWidth()
	{
		throw new todo.TODO();
	}

    public int getMediaHeight()
	{
		throw new todo.TODO();
	}

    public void repaintCurrent()
	{
		throw new todo.TODO();
	}

    public void play()
	{
		throw new todo.TODO();
	}

    public void play(boolean var1)
	{
		throw new todo.TODO();
	}

    public void play(int var1)
	{
		throw new todo.TODO();
	}

    public void stop()
	{
		throw new todo.TODO();
	}

    public void pause()
	{
		throw new todo.TODO();
	}

    public void resume()
	{
		throw new todo.TODO();
	}

    public int getState()
	{
		throw new todo.TODO();
	}

    public void addMediaPlayerListener(MediaPlayerListener var1)
	{
		throw new todo.TODO();
	}

    public void removeMediaPlayerListener(MediaPlayerListener var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/CalendarImpl.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

public class CalendarImpl implements CalendarInterface {
	
	public void initCalendarValues(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void paint(Graphics var1, int var2, int var3, int var4, int var5, int var6, int var7)
	{
		throw new todo.TODO();
	}

    public String getBackCommand()
	{
		throw new todo.TODO();
	}

    public String getSaveCommand()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/CalendarInterface.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

@SuppressWarnings({"FieldNamingConvention",
"InterfaceWithOnlyOneDirectInheritor"})
public interface CalendarInterface {
    int kYearSelectionMode = 1;
    int kMonthSelectionMode = 2;
    int kDaySelectionMode = 3;

    void initCalendarValues(int var1, int var2);

    void paint(Graphics var1, int var2, int var3, int var4, int var5, int var6, int var7);

    String getBackCommand();

    String getSaveCommand();
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/GaugeImpl.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

public class GaugeImpl implements GaugeInterface {
	
	public void init(boolean var1, int var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public void setValue(int var1)
	{
		throw new todo.TODO();
	}

    public int getValue()
	{
		throw new todo.TODO();
	}

    public void setMaxValue(int var1)
	{
		throw new todo.TODO();
	}

    public int getMaxValue()
	{
		throw new todo.TODO();
	}

    public void paint(boolean var1, Graphics var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public int processEvent(int var1, int var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public synchronized int getWidth()
	{
		throw new todo.TODO();
	}

    public synchronized int getHeight()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/GaugeInterface.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

public interface GaugeInterface {
    int LOST_FOCUS = 1;
    int VALUE_CHANGED = 2;

    void init(boolean var1, int var2, int var3, int var4);

    void setValue(int var1);

    int getValue();

    void setMaxValue(int var1);

    int getMaxValue();

    void paint(boolean var1, Graphics var2, int var3, int var4);

    int processEvent(int var1, int var2, int var3, int var4);

    int getWidth();

    int getHeight();
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/WatchImpl.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

public class WatchImpl
	implements WatchInterface
{
    public WatchImpl()
	{
		throw new todo.TODO();
	}

    public void initWatchValues(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void paint(Graphics var1, int var2, int var3, int var4)
	{
		throw new todo.TODO();
	}

    public String getBackCommand()
	{
		throw new todo.TODO();
	}

    public String getSaveCommand()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/WatchInterface.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

import javax.microedition.lcdui.Graphics;

public interface WatchInterface
{
    int kHourSelection = 1;
    int kMinuteSelection = 2;

    void initWatchValues(int var1, int var2);

    void paint(Graphics var1, int var2, int var3, int var4);

    String getBackCommand();

    String getSaveCommand();
}

Added modules/jblend-api/src/main/java/com/jblend/micro/lcdui/package-info.java.











1
2
3
4
5
6
7
8
9
10
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.micro.lcdui;

Added modules/jblend-api/src/main/java/com/jblend/net/HttpUrlParser.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.net;

public class HttpUrlParser
{
    public HttpUrlParser(String var1)
    	throws IllegalArgumentException
	{
		throw new todo.TODO();
	}

    public String getFile()
	{
		throw new todo.TODO();
	}

    public String getHost()
	{
		throw new todo.TODO();
	}

    public int getPort()
	{
		throw new todo.TODO();
	}

    public String getQuery()
	{
		throw new todo.TODO();
	}

    public String getRef()
	{
		throw new todo.TODO();
	}

    public String getRequestUri()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/ui/SequenceInterface.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.ui;

public interface SequenceInterface
{
    void sequenceStart();

    void sequenceStop();
}

Added modules/jblend-api/src/main/java/com/jblend/util/BASE64Decoder.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class BASE64Decoder
{
    public BASE64Decoder()
	{
		throw new todo.TODO();
	}

    public static synchronized String decode(String var0)
	{
		throw new todo.TODO();
	}

    protected static int bytesPerAtom()
	{
		throw new todo.TODO();
	}

    protected static int bytesPerLine()
	{
		throw new todo.TODO();
	}

    protected static void decodeAtom(InputStream var0, OutputStream var1, int var2) throws IOException
	{
		throw new todo.TODO();
	}

    protected static int readFully(InputStream var0, byte[] var1, int var2, int var3) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/BASE64Encoder.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class BASE64Encoder
{
    public BASE64Encoder()
	{
		throw new todo.TODO();
	}

    public static synchronized String encode(String var0)
	{
		throw new todo.TODO();
	}

    protected static int bytesPerAtom()
	{
		throw new todo.TODO();
	}

    protected static int bytesPerLine()
	{
		throw new todo.TODO();
	}

    protected static void encodeAtom(OutputStream var0, byte[] var1, int var2, int var3) throws IOException
	{
		throw new todo.TODO();
	}

    protected static int readFully(InputStream var0, byte[] var1) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/ByteRingBuffer.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;

public final class ByteRingBuffer
{
    public ByteRingBuffer()
	{
		throw new todo.TODO();
	}

    public ByteRingBuffer(int var1)
	{
		throw new todo.TODO();
	}

    public ByteRingBuffer(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void write(byte var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void write(byte[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public byte read() throws IOException
	{
		throw new todo.TODO();
	}

    public void read(byte[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public byte peek() throws IOException
	{
		throw new todo.TODO();
	}

    public void peek(byte[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int available()
	{
		throw new todo.TODO();
	}

    public int getFreeArea()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Case.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public final class Case
{
    public static final String toLower(String var0)
	{
		throw new todo.TODO();
	}

    public static final String toUpper(String var0)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Debug.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public final class Debug
{
    public static final boolean WATCH_TIME = false;

    public Debug()
	{
		throw new todo.TODO();
	}

    public static void trace(Object var0, String var1)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Hack.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public final class Hack
{
    public Hack()
	{
		throw new todo.TODO();
	}

    public static final void disableDispatch()
	{
		throw new todo.TODO();
	}

    public static final void enableDispatch()
	{
		throw new todo.TODO();
	}

    public static final void initializeDispatch()
	{
		throw new todo.TODO();
	}

    public static final void expandTimeslice(int var0)
	{
		throw new todo.TODO();
	}

    public static final void setTimeslice(int var0)
	{
		throw new todo.TODO();
	}
	
    public static final void dumpTheHeap()
	{
		throw new todo.TODO();
	}

    public static final void traceMethod(boolean var0)
	{
		throw new todo.TODO();
	}

    public static final void printAllThreadStatus()
	{
		throw new todo.TODO();
	}

    public static final boolean isSomeoneWaiting(Object var0)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Hashtable.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import com.jblend.io.SimpleObjectInputStream;
import com.jblend.io.SimpleObjectOutputStream;
import com.jblend.io.SimpleSerializable;
import java.io.IOException;

public class Hashtable
	extends java.util.Hashtable
	implements SimpleSerializable
{
    public Hashtable() {
        super(0, 0.0F);
        
        throw new todo.TODO();
    }

    public Hashtable(int var1) {
        super(0, 0.0F);
        
        throw new todo.TODO();
    }

    public void writeObject(SimpleObjectOutputStream var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void readObject(SimpleObjectInputStream var1) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/IntRingBuffer.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;

public class IntRingBuffer
{
    public IntRingBuffer()
	{
		throw new todo.TODO();
	}

    public IntRingBuffer(int var1)
	{
		throw new todo.TODO();
	}

    public IntRingBuffer(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void write(int var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void write(int var1, int var2, int var3, int var4, int var5) throws IOException
	{
		throw new todo.TODO();
	}

    public void write(int[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int read() throws IOException
	{
		throw new todo.TODO();
	}

    public void read(int[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int peek() throws IOException
	{
		throw new todo.TODO();
	}

    public void peek(int[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int available()
	{
		throw new todo.TODO();
	}

    public int getFreeArea()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Log.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public final class Log
{
    public static final PrintStream out =
    	todo.TODO.<PrintStream>missingObject();
    	
    public static final PrintStream err =
    	todo.TODO.<PrintStream>missingObject();

    public Log()
	{
		throw new todo.TODO();
	}

    public static final void out(String var0)
	{
		throw new todo.TODO();
	}

    public static final void err(String var0)
	{
		throw new todo.TODO();
	}

    private static final class PrivateOutputStream extends OutputStream {
        public void write(int var1) throws IOException
		{
			throw new todo.TODO();
		}
    }
}

Added modules/jblend-api/src/main/java/com/jblend/util/NativeSyncObject.java.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public class NativeSyncObject
{
}

Added modules/jblend-api/src/main/java/com/jblend/util/NativeThreadJoinner.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public final class NativeThreadJoinner
	{
    public static NativeThreadJoinner createInstance()
	{
		throw new todo.TODO();
	}

    public static void destroyInstance(NativeThreadJoinner var0)
	{
		throw new todo.TODO();
	}

    public void reset()
	{
		throw new todo.TODO();
	}

    public int getId()
	{
		throw new todo.TODO();
	}

    public synchronized int getCause()
	{
		throw new todo.TODO();
	}

    public synchronized int getOption()
	{
		throw new todo.TODO();
	}

    public synchronized void join() throws InterruptedException
	{
		throw new todo.TODO();
	}

    public synchronized void join(long var1) throws InterruptedException
	{
		throw new todo.TODO();
	}

    public boolean causeContains(int var1)
	{
		throw new todo.TODO();
	}

    public synchronized void joinNotify(int var1, int var2, int var3)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/NativeThreadMonitor.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public class NativeThreadMonitor
	extends Thread
{
    public static void reset()
	{
		throw new todo.TODO();
	}

    public void run()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Properties.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
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.util.Enumeration;

public class Properties
	extends StringKeyHashtable
{
    protected Properties defaults;

    public Properties()
	{
		throw new todo.TODO();
	}

    public Properties(int var1)
	{
		throw new todo.TODO();
	}

    public Properties(Properties var1)
	{
		throw new todo.TODO();
	}

    public synchronized String getProperty(String var1)
	{
		throw new todo.TODO();
	}

    public synchronized Integer getIntegerProperty(String var1)
	{
		throw new todo.TODO();
	}

    public synchronized String getProperty(String var1, String var2)
	{
		throw new todo.TODO();
	}

    public synchronized Integer getIntegerProperty(String var1, Integer var2)
	{
		throw new todo.TODO();
	}

    public synchronized String setProperty(String var1, String var2)
	{
		throw new todo.TODO();
	}

    public synchronized Integer setProperty(String var1, Integer var2)
	{
		throw new todo.TODO();
	}

    public synchronized Enumeration propertyNames()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/RingBuffer.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.io.IOException;

public final class RingBuffer
{
    public RingBuffer()
	{
		throw new todo.TODO();
	}

    public RingBuffer(int var1)
	{
		throw new todo.TODO();
	}

    public RingBuffer(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void write(Object var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void write(Object[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public Object read() throws IOException
	{
		throw new todo.TODO();
	}

    public void read(Object[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public Object peek() throws IOException
	{
		throw new todo.TODO();
	}

    public void peek(Object[] var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int available()
	{
		throw new todo.TODO();
	}

    public int getFreeArea()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Secure.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public final class Secure
{
    public static final String javaPackageName = "java.";
    public static final String javaxPackageName = "javax.";

    public static void checkPackage()
	{
		throw new todo.TODO();
	}

    public static void checkPackage(String var0)
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/SimpleStack.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.util.Enumeration;

public final class SimpleStack
{
    public Object[] elementData;
    public int size;

    public SimpleStack()
	{
		throw new todo.TODO();
	}

    public SimpleStack(int var1)
	{
		throw new todo.TODO();
	}

    public Object push(Object var1)
	{
		throw new todo.TODO();
	}

    public Object pop()
	{
		throw new todo.TODO();
	}

    public Object peek()
	{
		throw new todo.TODO();
	}

    public int size()
	{
		throw new todo.TODO();
	}

    public boolean empty()
	{
		throw new todo.TODO();
	}

    public Enumeration elements()
	{
		throw new todo.TODO();
	}

    final class SimpleStackEnumerator implements Enumeration {
        public boolean hasMoreElements()
		{
			throw new todo.TODO();
		}

        public Object nextElement()
		{
			throw new todo.TODO();
		}
    }
}

Added modules/jblend-api/src/main/java/com/jblend/util/SimpleVector.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.util.Enumeration;

public final class SimpleVector
{
    public Object[] elementData;
    public int elementCount;

    public SimpleVector()
	{
		throw new todo.TODO();
	}

    public SimpleVector(int var1)
	{
		throw new todo.TODO();
	}

    public void addElement(Object var1)
	{
		throw new todo.TODO();
	}

    public boolean removeElement(Object var1)
	{
		throw new todo.TODO();
	}

    public int size()
	{
		throw new todo.TODO();
	}

    public Object elementAt(int var1)
	{
		throw new todo.TODO();
	}

    public Object lastElement()
	{
		throw new todo.TODO();
	}

    public boolean contains(Object var1)
	{
		throw new todo.TODO();
	}

    public int indexOf(Object var1, int var2)
	{
		throw new todo.TODO();
	}

    public void removeElementAt(int var1)
	{
		throw new todo.TODO();
	}

    public void insertElementAt(Object var1, int var2)
	{
		throw new todo.TODO();
	}

    public void removeAllElements()
	{
		throw new todo.TODO();
	}

    public Enumeration elements()
	{
		throw new todo.TODO();
	}

    final class SimpleVectorEnumerator implements Enumeration {
        public boolean hasMoreElements()
		{
			throw new todo.TODO();
		}

        public Object nextElement()
		{
			throw new todo.TODO();
		}
    }
}

Added modules/jblend-api/src/main/java/com/jblend/util/StringKeyHashtable.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import java.util.Hashtable;

public class StringKeyHashtable
	extends Hashtable
{
    public StringKeyHashtable() {
        super(0, 0.0F);
        
        throw new todo.TODO();
    }

    public StringKeyHashtable(int var1) {
        super(0, 0.0F);
        
        throw new todo.TODO();
    }

    public final Object get(String var1)
	{
		throw new todo.TODO();
	}

    public final boolean containsKey(String var1)
	{
		throw new todo.TODO();
	}

    public final Object put(Object var1, Object var2)
	{
		throw new todo.TODO();
	}

    protected final void rehash()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/SystemProperties.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

public class SystemProperties
{
    public SystemProperties()
	{
		throw new todo.TODO();
	}

    public static Properties getSystemProperties()
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/Vector.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util;

import com.jblend.io.SimpleObjectInputStream;
import com.jblend.io.SimpleObjectOutputStream;
import com.jblend.io.SimpleSerializable;
import java.io.IOException;

public class Vector
	extends java.util.Vector
	implements SimpleSerializable
{
    public Vector() {
        super(0, 0);
        
        throw new todo.TODO();
    }

    public Vector(int var1) {
        super(0, 0);
        
        throw new todo.TODO();
    }

    public void writeObject(SimpleObjectOutputStream var1) throws IOException
	{
		throw new todo.TODO();
	}

    public void readObject(SimpleObjectInputStream var1) throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/jblend-api/src/main/java/com/jblend/util/locale/Calendar.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.jblend.util.locale;

public final class Calendar
{
    public Calendar()
	{
		throw new todo.TODO();
	}

    public static String getMonthString(int var0)
	{
		throw new todo.TODO();
	}

    public static String getWeekString(int var0)
	{
		throw new todo.TODO();
	}
}

Added modules/launcher/build.gradle.




























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidlet
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains the graphical launcher " +
	"that SquirrelJME uses to act as a front end interface to running user" +
	"programs."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EP"
	swmType = JavaMEMidletType.APPLICATION
	swmName = "SquirrelJME Launcher (Graphical)"
	swmVendor = "Stephanie Gawroriski"
	ignoreInLauncher = true
	midlets += new JavaMEMidlet("SquirrelJME Launcher (Graphical)", null,
		"cc.squirreljme.runtime.launcher.ui.MidletMain")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:midp-lcdui")
	implementation project(":modules:meep-midlet")
	implementation project(":modules:meep-swm")
}

Added modules/launcher/src/main/java/cc/squirreljme/runtime/launcher/ui/MidletMain.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import java.util.ArrayList;
import java.util.Timer;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteType;

/**
 * This is the main midlet for the LCDUI based launcher interface.
 *
 * @since 2016/10/11
 */
public class MidletMain
	extends MIDlet
{
	/**
	 * {@squirreljme.property cc.squirreljme.autolaunch=program This specifies
	 * the program that should be auto-launched once the program list has been
	 * processed.}
	 */
	public static final String AUTOLAUNCH_PROPERTY =
		"cc.squirreljme.autolaunch";
	
	/** Command used to exit the launcher and terminate. */
	public static final Command EXIT_COMMAND =
		new Command("Exit", Command.EXIT, 1);
	
	/** The about command. */
	public static final Command ABOUT_COMMAND =
		new Command("About", Command.HELP, 2);
	
	/** Timer used to reschedule things. */
	static final Timer _TIMER =
		new Timer("LauncherRecoverThread");
	
	/** The display that is being used. */
	static volatile Display _MAIN_DISPLAY;
	
	/** The list which contains all of the programs we can run. */
	protected final List programlist =
		new List("SquirrelJME Launcher", Choice.IMPLICIT);
	
	/** The active task. */
	private final __ActiveTask__ _activetask =
		new __ActiveTask__();
	
	/** The programs which are mapped to the list. */
	private volatile __Program__[] _programs;
	
	/** Automatic launch program. */
	private volatile String _autolaunch;
	
	/**
	 * Initializes the launcher.
	 *
	 * @since 2019/04/14
	 */
	{
		// Do not crash if we cannot read properties
		String al = null;
		try
		{
			al = System.getProperty(MidletMain.AUTOLAUNCH_PROPERTY);
		}
		catch (SecurityException e)
		{
		}
		
		this._autolaunch = al;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/11
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
		// This is not used at all
	}
	
	/**
	 * Refreshes the list.
	 *
	 * @since 2018/11/16
	 */
	public void refresh()
	{
		// When a refresh is happening, change the title so that is
		// indicated
		List programlist = this.programlist;
		programlist.setTitle("Loading (Querying Suites)...");
		
		// Used for checking and such
		__ActiveTask__ activetask = this._activetask;
		
		// The list was previously not used
		if (programlist.size() <= 0)
		{
			// Add a message saying what is going on
			programlist.append("Loading available programs...", null);
			programlist.append("This might take awhile!", null);
			programlist.append("UP/DOWN -- Adjust focused item", null);
			programlist.append("FIRE    -- Select item", null);
			programlist.append("The SPACEBAR key is the FIRE key", null);
			
			// Re-flip on this display
			if (MidletMain._MAIN_DISPLAY.getCurrent() == programlist)
				MidletMain._MAIN_DISPLAY.setCurrent(programlist);
		}
		
		// Go through all of the available application suites and build the
		// program list
		boolean queried = false;
		int foundcount = 0;
		ArrayList<__Program__> programs = new ArrayList<>();
		for (Suite suite : ManagerFactory.getSuiteManager().getSuites(
			SuiteType.APPLICATION))
		{
			// Hide this on the SquirrelJME launcher?
			if (Boolean.valueOf(suite.getAttributeValue(
				"X-SquirrelJME-NoLauncher")))
				continue;
			
			// Query is done, scan suites
			if (!queried)
			{
				programlist.setTitle("Loading (Scanning Suites)...");
				queried = true;
			}
			
			// Since we need the program name AND the entry point we need
			// to decode the parts that make it up!
			for (int i = 1; i >= 1; i++)
			{
				// No more programs in this suite
				String value = suite.getAttributeValue("MIDlet-" + i);
				if (value == null)
					break;
				
				// There will be two commas and the format is in:
				// title, icon-resource, mainclass
				int fc = value.indexOf(','),
					sc = value.lastIndexOf(',');
				if (fc < 0 || sc < 0)
					continue;
				
				// Split off
				String title = value.substring(0, fc).trim(),
					iconrc = value.substring(fc + 1, sc).trim(),
					main = value.substring(sc + 1).trim();
				
				// Build program
				programs.add(new __Program__(suite, main, title, activetask,
					iconrc));
				
				// Say it was found via the title
				programlist.setTitle(String.format(
					"Loading (%d Found)...", ++foundcount));
			}
		}
		
		// Indicate that the program list is being built
		programlist.setTitle(String.format(
			"Building List (%d Found)...", foundcount));
		
		// Build program array
		__Program__[] arrprogs = programs.<__Program__>toArray(
			new __Program__[programs.size()]);
		
		// Clear the program list
		programlist.deleteAll();
		
		// Build the list in the program order
		for (__Program__ p : arrprogs)
			programlist.append(p.displayName(), p.displayImage());
		
		// Use this list
		this._programs = arrprogs;
		
		// All done so, return the title back
		programlist.setTitle("SquirrelJME Launcher");
		
		// Make sure the program list is showing
		Displayable current = MidletMain._MAIN_DISPLAY.getCurrent();
		if (current == null || (current instanceof SplashScreen))
			MidletMain._MAIN_DISPLAY.setCurrent(programlist);
		
		// Automatically launch a program?
		String autolaunch = this._autolaunch;
		if (autolaunch != null)
		{
			this._autolaunch = null;
			
			// Launch it
			System.err.println("Auto-launching " + autolaunch + "...");
			this.__launch(autolaunch);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/16
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// We will need to access our own display to build the list of
		// MIDlets that could actually be ran
		Display disp = Display.getDisplay(this);
		MidletMain._MAIN_DISPLAY = disp;
		
		// Add commands to the list so things can be done with them
		List programlist = this.programlist;
		programlist.addCommand(MidletMain.EXIT_COMMAND);
		programlist.addCommand(MidletMain.ABOUT_COMMAND);
		
		// Need to handle commands and such
		__CommandHandler__ ch = new __CommandHandler__();
		programlist.setCommandListener(ch);
		
		// Used to ensure the splash screen is visible for at least a second
		long endtime = System.nanoTime() + 1_000_000_000L;
		
		// Refresh the list in another thread
		Thread refresher = new Thread("LauncherRefresh")
			{
				/**
				 * {@inheritDoc}
				 * @since 2019/05/19
				 */
				public final void run()
				{
					MidletMain.this.refresh();
				}
			};
		refresher.start();
		
		// Instead of showing the program list early, just show a splash screen
		// with a handsome Lex and the version information
		SplashScreen spl = new SplashScreen(disp.getWidth(), disp.getHeight());
		if (disp.getCurrent() == null)
			disp.setCurrent(spl);
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __launch(__Program__ __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Indication that something is happening
		this.programlist.setTitle("Launching " + __p.displayname + "...");
		
		// Launch this program
		__p.__launch();
		
		// All done so, return the title back
		this.programlist.setTitle("SquirrelJME Launcher");
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @since 2019/04/14
	 */
	private void __launch(int __p)
	{
		__Program__[] programs = this._programs;
		
		// Do nothing if out of bounds
		if (programs == null || __p < 0 || __p >= programs.length)
			return;
		
		// Launch
		this.__launch(programs[__p]);
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __launch(String __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// This will use multiple matches, with less priority following
		__Program__ bysj = null,
			bydn = null,
			bysn = null,
			bymc = null;
		
		// Find all the possible matches for a program
		for (__Program__ p : this._programs)
			if (bysj == null && __p.equalsIgnoreCase(p.squirreljmename))
				bysj = p;
			else if (bydn == null && __p.equalsIgnoreCase(p.displayname))
				bydn = p;
			else if (bysn == null && __p.equalsIgnoreCase(p.suitename))
				bysn = p;
			else if (bymc == null && __p.equalsIgnoreCase(p.main))
				bymc = p;
		
		// Use a priority based order
		__Program__ p = (bysj != null ? bysj :
			(bydn != null ? bydn :
			(bysn != null ? bysn :
			(bymc != null ? bymc : null))));
		if (p != null)
		{
			this.__launch(p);
			return;
		}
		
		// If everything fails, just assume it is an index to a program on the
		// program list
		try
		{
			this.__launch(Integer.parseInt(__p));
		}
		catch (NumberFormatException e)
		{
		}
	}
	
	/**
	 * This is the handler for commands.
	 *
	 * @since 2018/11/16
	 */
	private final class __CommandHandler__
		implements CommandListener
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/16
		 */
		@Override
		public final void commandAction(Command __c, Displayable __d)
		{
			// Launching a program?
			if (__c == List.SELECT_COMMAND)
			{
				// If the list is empty then do nothing because it will NPE
				// or out of bounds if the selection is off
				List list = (List)__d;
				int seldx = list.getSelectedIndex();
				if (list.size() <= 0 || seldx < 0)
					return;
				
				// Call other launcher
				MidletMain.this.__launch(seldx);
			}
			
			// Exiting the VM?
			else if (__c == MidletMain.EXIT_COMMAND)
			{
				// Indication that something is happening
				MidletMain.this.programlist.setTitle("Exiting...");
				
				System.exit(0);
			}
			
			// About SquirrelJME
			else if (__c == MidletMain.ABOUT_COMMAND)
			{
			}
		}
	}
}

Added modules/launcher/src/main/java/cc/squirreljme/runtime/launcher/ui/SplashScreen.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
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
191
192
193
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.launcher.ui;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

/**
 * This is the splash screen for the launcher which always shows.
 *
 * @since 2019/05/19
 */
public final class SplashScreen
	extends Canvas
	implements Runnable
{
	/** The copyright string. */
	public static final String COPYRIGHT =
		"https://squirreljme.cc/\n" +
		"(C) 2013-2019 Stephanie Gawroriski\n" +
		"Licensed under the GPLv3!\nDonate to me on Patreon:\n" +
		"*** https://www.patreon.com/SquirrelJME! ***";
	
	/** The splash image width. */
	public static final int WIDTH =
		240;
	
	/** The splash image height. */
	public static final int HEIGHT =
		320;
	
	/** The image data to draw. */
	volatile int[] _image;
	
	/**
	 * Initializes the splash screen with a precached image.
	 *
	 * @param __sw The screen width.
	 * @param __sh The screen height.
	 * @since 2019/05/19
	 */
	public SplashScreen(int __sw, int __sh)
	{
		// Full-screen mode for the entire image
		this.setFullScreenMode(true);
		
		// Load the launcher image in a background thread so the splash screen
		// can still display the copyright notice
		new Thread(this, "LauncherImageLoader").start();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public final void paint(Graphics __g)
	{
		// Draw the raw image data, is the fastest
		int[] image = this._image;
		if (image != null)
			__g.drawRGB(image, 0, SplashScreen.WIDTH, 0, 0, SplashScreen.WIDTH,
				SplashScreen.HEIGHT, false);
		
		// The image is not fully loaded yet, so draw the copyright at least
		else
			SplashScreen.__copyright(__g, true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final void run()
	{
		// Image is completely operated with using raw data
		int np = SplashScreen.WIDTH * SplashScreen.HEIGHT;
		int[] image = new int[np];
		
		// Load splash image onto the data
		try (InputStream in = SplashScreen.class.
			getResourceAsStream("splash.raw"))
		{
			// If it exists, use it
			if (in != null)
			{
				// Input raw pixels
				int nr = SplashScreen.WIDTH * SplashScreen.HEIGHT * 3;
				byte[] raw = new byte[nr];
				
				// Read in raw data
				for (int read = 0; read < nr;)
				{
					int rc = in.read(raw, read, nr - read);
					
					if (rc < 0)
						break;
					
					read += rc;
				}
				
				// Translate RGB byte pixels to RGB int pixels
				for (int o = 0, i = 0; o < np; o++)
					image[o] = ((raw[i++] & 0xFF) << 16) |
						((raw[i++] & 0xFF) << 8) |
						(raw[i++] & 0xFF);
			}
		}
		catch (IOException e)
		{
		}
		
		// Text will be drawn using the advanced graphics since it can
		// operate on integer buffers directly
		Graphics g = new AdvancedGraphics(image, false, null,
			SplashScreen.WIDTH, SplashScreen.HEIGHT, SplashScreen.WIDTH, 0, 0, 0);
		
		// Draw copyright at the bottom
		SplashScreen.__copyright(g, false);
		
		// Use this image
		this._image = image;
		
		// Perform a repaint before we return so the better looking splash
		// screen is used
		this.repaint();
	}
	
	/**
	 * Draws the copyright text onto the given graphics.
	 *
	 * @param __g The graphics to draw onto.
	 * @param __swip Should "SquirrelJME Loading..." be drawn?
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/29
	 */
	private static final void __copyright(Graphics __g, boolean __swip)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Draw version number
		__g.setFont(Font.getFont("sansserif", 0, 16));
		__g.drawString(SquirrelJME.RUNTIME_VERSION, 238, 48,
			Graphics.RIGHT | Graphics.TOP);
		
		// Draw loading and the SquirrelJME string?
		if (__swip)
		{
			// SquirrelJME String
			__g.drawString("SquirrelJME", 2, 2, Graphics.TOP | Graphics.LEFT);
			
			// Loading...
			__g.drawString("Loading...", 120, 160,
				Graphics.VCENTER | Graphics.HCENTER);
		}
		
		// Set properties
		__g.setFont(Font.getFont("sansserif", 0, 12));
		
		// Draw a black drop-shadow, this makes the lighter front easier to
		// see regardless of what is on the background
		__g.setColor(0x000000);
		__g.drawString(SplashScreen.COPYRIGHT, 1, 318,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(SplashScreen.COPYRIGHT, 3, 318,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(SplashScreen.COPYRIGHT, 2, 317,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(SplashScreen.COPYRIGHT, 2, 319,
			Graphics.BOTTOM | Graphics.LEFT);
		
		// Then draw the frontal white text
		__g.setColor(0xFFFFFF);
		__g.drawString(SplashScreen.COPYRIGHT, 2, 318,
			Graphics.BOTTOM | Graphics.LEFT);
	}
}

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

package cc.squirreljme.runtime.launcher.ui;

import javax.microedition.swm.Task;

/**
 * The currently active task.
 *
 * @since 2018/12/10
 */
final class __ActiveTask__
{
	/** The current task. */
	volatile Task _task;
}

Added modules/launcher/src/main/java/cc/squirreljme/runtime/launcher/ui/__Program__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Image;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * Stores the program information which is mapped to what is displayed.
 *
 * @since 2018/11/16
 */
final class __Program__
{
	/** The suite that is used. */
	protected final Suite suite;
	
	/** The name of the suite. */
	protected final String suitename;
	
	/** The main entry point. */
	protected final String main;
	
	/** The display name of this suite. */
	protected final String displayname;
	
	/** The SquirrelJME name. */
	protected final String squirreljmename;
	
	/** The name of the JAR (SquirrelJME specific). */
	protected final String jarfile;
	
	/** The icon resource to use. */
	protected final String iconrc;
	
	/** The active task. */
	final __ActiveTask__ _activetask;
	
	/** The icon to show for this program. */
	Image _icon;
	
	/**
	 * Initializes the program.
	 *
	 * @param __suite The suite used.
	 * @param __main The main class.
	 * @param __dn The display name of this suite.
	 * @param __at The active task.
	 * @param __iconrc The icon resource used, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	__Program__(Suite __suite, String __main, String __dn,
		__ActiveTask__ __at, String __iconrc)
		throws NullPointerException
	{
		if (__suite == null || __main == null || __at == null)
			throw new NullPointerException("NARG");
		
		this.suite = __suite;
		this.main = __main;
		this.iconrc = __iconrc;
		
		String suitename = __suite.getName();
		this.suitename = suitename;
		
		String displayname;
		this.displayname = (displayname = (__dn != null ? __dn :
			suitename + " " + __main));
		this._activetask = __at;
		
		// Try to get the internal project name for SquirrelJME, this is used
		// for quick launching
		String sjn = __suite.getAttributeValue(
			"X-SquirrelJME-InternalProjectName");
		if (sjn == null)
		{
			// Only add normal characters
			StringBuilder sb = new StringBuilder();
			for (int i = 0, n = displayname.length(); i < n; i++)
			{
				char c = displayname.charAt(i);
				if (Character.isDigit(c) || Character.isLowerCase(c) ||
					Character.isUpperCase(c))
					sb.append(c);
			}
			
			sjn = sb.toString();
		}
		
		// SquirrelJME special name
		String squirreljmename = sjn.toLowerCase();
		this.squirreljmename = squirreljmename;
		
		// SquirrelJME specific name for the JAR file this belongs to,
		// note that this is only valid within SquirrelJME itself as the
		// property is set from the launcher
		String jarfile = __suite.getAttributeValue("x-squirreljme-jarfile");
		this.jarfile = (jarfile == null ? squirreljmename : jarfile);
	}
	
	/**
	 * The display image for this suite.
	 *
	 * @return The display image.
	 * @since 2018/11/16
	 */
	public final Image displayImage()
	{
		// Image already known?
		Image rv = this._icon;
		if (rv != null)
			return rv;
		
		// No image is here at all
		String iconrc = this.iconrc;
		if (iconrc == null || iconrc.isEmpty())
			return null;
		
		// Load image from JAR resource
		try (InputStream in = ResourceInputStream.open(this.jarfile, iconrc))
		{
			// No resource exists
			if (in == null)
				return null;
			
			// Load image data
			rv = Image.createImage(in);
		}
		
		// Not a valid image, ignore
		catch (IOException e)
		{
			return null;
		}
		
		// Cache and use
		this._icon = rv;
		return rv;
	}
	
	/**
	 * The display name for this suite.
	 *
	 * @return The display name.
	 * @since 2018/11/16
	 */
	public final String displayName()
	{
		return this.displayname;
	}
	
	/**
	 * Launches this program.
	 *
	 * @since 2018/11/16
	 */
	final void __launch()
	{
		// Need these
		Suite suite = this.suite;
		String main = this.main;
		
		// Make it so only a single thing can be launched
		__ActiveTask__ activetask = this._activetask;
		synchronized (activetask)
		{
			// Do not start another task until the current one has finished
			Task oldtask = activetask._task;
			if (oldtask != null)
			{
				TaskStatus status = oldtask.getStatus();
				if (status == TaskStatus.RUNNING ||
					status == TaskStatus.STARTING)
				{
					todo.DEBUG.note("Other task has not finished yet!");
					return;
				}
				
				// Not running, so we can forget it
				activetask._task = null;
			}
			
			// Start the task
			try
			{
				Task task = ManagerFactory.getTaskManager().
					startTask(suite, main);
				activetask._task = task;
			}
			
			// Could not launch so, oh well!
			catch (IllegalArgumentException|IllegalStateException e)
			{
				// Debug to the system console
				e.printStackTrace();
				
				// Then pop up a nasty message!
				String msg = e.getMessage();
				MidletMain._MAIN_DISPLAY.setCurrent(
					new Alert("Oopsie!", (msg == null ? String.format(
						"Could not launch %s:%s.", suite, main): msg),
						null, AlertType.ERROR));
			}
			
			// Setup timer to recover our display on termination
			MidletMain._TIMER.schedule(new __ReControlTask__(
				MidletMain._MAIN_DISPLAY, activetask), 500, 500);
		}
	}
}

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

package cc.squirreljme.runtime.launcher.ui;

import java.util.TimerTask;
import javax.microedition.lcdui.Display;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * This is used to regain control of tasks and make it so the launcher is
 * brought back up after it has lost hardware control.
 *
 * @since 2018/12/11
 */
final class __ReControlTask__
	extends TimerTask
{
	/** The display used. */
	protected final Display display;
	
	/** The task information. */
	private final __ActiveTask__ _active;
	
	/**
	 * Initializes the re-control task.
	 *
	 * @param __display The display used.
	 * @param __task The task to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	__ReControlTask__(Display __display, __ActiveTask__ __task)
		throws NullPointerException
	{
		if (__display == null || __task == null)
			throw new NullPointerException("NARG");
		
		this.display = __display;
		this._active = __task;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final void run()
	{
		Display display = this.display;
		__ActiveTask__ active = this._active;
		
		// Need to check the task status
		boolean recover = false;
		synchronized (active)
		{
			Task task = active._task;
			
			// If null, then we should recover because it was cleared
			if (task == null)
				recover = true;
			
			// If the task has stopped for any reason, we recover
			if (!recover)
			{
				TaskStatus status = task.getStatus();
				recover = (status != TaskStatus.RUNNING &&
					status != TaskStatus.STARTING);
			}
			
			// Recover our display?
			if (recover)
			{
				// Note it
				todo.DEBUG.note("Recovering %s...", task);
				
				// Make it current which takes the display over again, we
				// do not need to specify which displayable it was because the
				// display remembers it
				display.setCurrent(display.getCurrent());
				
				// Cancel self since we did it!
				this.cancel();
			}
		}
	}
}

Added modules/launcher/src/main/java/cc/squirreljme/runtime/launcher/ui/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the LCDUI based launcher interface.
 *
 * @since 2016/10/11
 */

package cc.squirreljme.runtime.launcher.ui;

Added modules/launcher/src/main/resources/cc/squirreljme/runtime/launcher/ui/splash.raw.__mime.



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 750 splash.raw
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4
W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3
W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3a8v1qLvTvLW/qrzPcMrzZcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3gMjq7ppu/4wA/4wA/4wA75lrjcXj
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4ZMn0YsbwYsbwWMnxYsbw
WMnxWMnxYsbwYsbwWMnxWMnxYsbwWMnxWMnxWMnxWcv0W8/4W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3
W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3XM/46pt5/4wA/4wA/4wA/4wA/4wA9JVa
as3zZcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4Y8nzYsbwWMnxWMnxWMnxWMnx
Wcv0Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4ULneO32YG0FQAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4ksLi/4wA/4wA/4wA/4wA/4wA/4wA/4wA
rrnOW8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YW8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3TqDDQZe2W8/4W8/4Zcz3Zcz3TLDUAAAATJ2/
Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4VMHnAw8VOomlZcz3
W8/4Zcz3Zcz3RaHBDygzFDlHFDlHFzlGFzlGFDlHFzlGFzlGFDlHFzlGFDlH
FzlGFzlGFzlGFDlHFDlHFzlGFzlGFDlHFDlHFzlGU6rOW8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3SJa2AggMAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4m8Lb/4wA/4wA/4wA/4wA/4wA/4wA/4wA
vrO+Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TMWmBIFRm
ZMv2Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Q4upMWqCOomlZcz3
W8/4W8/4Zcz3RaHBSZe3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3
Zcz3W8/4W8/4Zcz3Zcz3SarMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPI6rW8/4W8/4W8/4W8/4
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3d8nw/o0V/4wA/4wA/4wA/4wA/4wA/4wA
pL7UW8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4
Zcz3W8/4Zcz3W8/4W8/4Zcz3RqPDSJW1W8/4Zcz3W8/4W8/4TLDUOIaiOXiS
TK7RW8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3WMnxHkZXSKjJQIekW8/4
Zcz3Zcz3W8/4TZ7AQZm4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4Zcz3ZMv1IEpbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz30qul/4wA/4wA/4wA/4wA/4wA7Jpz
asv1Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
NX+ZW8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4Zcz3Zcz3W8/4Zcz3RqPDSJW1W8/4Zcz3Zcz3Zcz3Va7TP4ShWLPZ
MmuDZcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Q529RI6tS67RQIekW8/4
W8/4Zcz3Zcz3TZ7AQZm4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
W8/4Zcz3Zcz3W8/4WLPZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3ZMv1Zcv2Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3csry1qig/4wA/4wA/4wA5p+De8ns
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3W8/4Zcz3Zcz3TLDUOIaiZcz3
KGR5UbvgW8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3ZMv2JVJlVcLpVKvQQIekZcz3
Zcz3W8/4W8/4RaHBSZe3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3RaDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4T7bbQIajW8/4W8/4WbbdX8Hp
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4dsrumMLce8nsZcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YW8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3RqPDQZe2Zcz3Zcz3W8/4Zcz3Va7TOIaiZcz3
UabJPoGdZcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4S63POnuWZcz3S67ROomlZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4RpGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPI6rZcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3SJW1Aw8VXbzkVKzRUqjMAAAA
IldqQIekW7rhZcz3Zcz3ZMv2Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4QYmmAAAAAAAAAAAAAAAAAAAA
NX+ZZcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3W8/4W8/4TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TP4ShZcz3
ZMr0IEpbYMLrZcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3MGh/WbXcZcz3VKvQQIekW8/4
Zcz3W8/4Zcz3TZ7ASZe3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAIEpbUrvhYsbwYsbw
YsbwWMnxYsbwYsbwYsbwWMnxWMnxYsbwYsbwYsbwY8jzZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4YsbwWLTaWcvzZcz3Zcz3M26HAAAALGyCGUNSX8HqAw8V
AAAAAAAAFDNAVsTrW8/4U6vPY8n0Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TOIaiZcz3
Zcz3QZm4QJa1Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W7ngLWF3W8/4Zcz3VKvQQIekW8/4
Zcz3Zcz3W8/4TZ7AQZm4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3W8/4Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAPpGvZcz3Zcz3W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3NnOMCiApMniRW7ngDygzAAAAAAAAAAAARpKxHEJS
AAAAAAAAAAAAP4ShZcz3O4yoWrfdZcz3Zcz3Zcz3Zcz3Zcz3Zcz3V7LXH1Fj
JFBjJFBjH1FjJFBjK15zW8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4YMPsJFBjH1Fj
JFBjJFBjJFBjJFBjX8DpZcz3Zcz3Zcz3RJ+/KFhsKFhsI1lsKFhsKFhsOoml
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Y8n0UKXIPX+bKmd9J1drJFBjJFBjJFBjPpGv
Zcz3Zcz3W8/4Zcz3Y8jyT6LEO32YKWd8J1ZpH1FjJFBjJFBjSZi4W8/4Zcz3
Zcz3Zcz3YsXvTJy+OHaQLWF3H1FjJFBjJFBjH1FjJFBjJFBjH1FjJFBjKFhs
MGd+QIekWLPZZcz3Zcz3Zcz3Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3RqPDQZe2Zcz3Zcz3W8/4W8/4TLDUP4ShW8/4
W8/4YcTuIEpbY8nzZcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3PH+aSqrNZcz3Zcz3S67RQIekZcz3
Zcz3W8/4Zcz3RaHBSZe3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
Zcz3W8/4W8/4Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAR5OzW8/4Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3YMLsZcz3Zcz3Zcz3QIWiAAAAAAAACBwlAAAAAAAAAAAAAAAAAggMAggM
AAAAAAAAAAAAES04Y8fxMWmBPpOxZcz3Zcz3W8/4W8/4W8/4W8/4Va3SAAAA
AAAAAAAAAAAAAAAAFTVCW8/4W8/4W8/4W8/4Zcz3Zcz3W8/4X8HqAAAAAAAA
AAAAAAAAAAAAAAAAVMHnW8/4Zcz3Zcz3PpOxAAAAAAAAAAAAAAAAAAAANXKL
W8/4Zcz3Zcz3Zcz3Zcz3XLvjH1BiAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
W8/4Zcz3Zcz3UbrfHkZXAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
W8/4WLPZGj1MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAOISgZMv2Zcz3Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3TqDDSJW1W8/4Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3QIWiR6bHZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3VsXtIk1eZMr0W8/4Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4PpKwAAAAAAAAAAAAAAAAAAAAAAAAR5OzZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3
W8/4QoqoZcz3Zcv2TqDDDCMsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAATqHDFDNAECs2YMLrZcz3Zcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3YsfwIEpbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3YMPsGz9OAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tW8/4W8/4
X8HqFTVCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAASZe3Zcz3W8/4Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3W8/4U7/lKVtvZcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3RpKxSpm6Zcz3Zcz3Zcz3VKvQQIekW8/4
Zcz3Zcz3Zcz3TZ7ASZe3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAPoGdZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
XLzkK190W8/4QIWiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAABxkgAAAAAAAAOYijZcz3Zcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
W8/4Zcz3W8/4Zcz3Q529AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3RpKxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
QoqoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAFDlHY8n0Zcz3W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3W8/4Va7TP4ShW8/4
Zcz3Zcz3Zcz3NHCIV7LXZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Y8jzIEpbWMjwZcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAABRQbRpKxWLLYW7ng
W7ngW7ngW7ngW7ngW7nhYcTuW8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
TJ2+K190Va3SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAACBwlX8DpZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3M22FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3K15zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
IElaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAWLTaW8/4Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3Zcz3TbHVN3WPZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqHEQYimZcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3a8vwZcz3Zcz3R5OzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAJlVoTZ7AZMv1Zcz3a8vwZcz3Zcz3Zcz3Zcz3
PoKeK15zOHaQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQoqoZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3H0hYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3DSs2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Y8jz
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUKTHZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3a8vwZcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TQ4Sda8vw
Zcz3Zcz3Zcz3Zcz3JFpuXb3lZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3KVpuYrzeZcz3Zcz3W8/4Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3UKXIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANXCJY8n0Zcz3Zcz3Zcz3a8vwZcz3
K190LVxuIElaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIUtdZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3FDNAAAAAAAAAAAAAAAAAAAAAFDNAQ4yqSpq7Spq7Va/U
Zcz3ZMv2AAAAAAAAAAAAAAAAAAAAAAAAGTxKRY6tSpq7Spq7WLLYZcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAHUNTM22GOG+ENHCIOG+EMmuDDCMsAAAA
AAAAAAAAAAAAAAAAAAAATqHDa8vwZcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3W8/4
a8vwZcz3Zcz3Zcz3Zcz3Zcz3TqDDTJSwa8vwZcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3a8vwZcz3TqDDQomnZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3a8vwZcz3W6/PNnONZcz3Zcz3Zcz3Zcz3Zcz3VKvQRYafZcz3
Zcz3Zcz3Zcz3Up67SZe3Zcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3a8vwZcz3
Zcz3Zcz3Zcz3a8vwY73fBA8UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARpGxa8vwZcz3Zcz3Zcz3a8vw
H0hYKVtvCBgfAAAAAAAAAAAAAAAAAAAACRwjOnOJO3yXP3uTO3yXO3yXMmV5
Aw8VAAAAAAAAAAAAAAAAAAAAAAAAAAAAJlVoZcz3Zcz3Zcz3a8vwVa3SAAAA
AAAAAAAAAAAAAAAAFTVCa8vwa8vwZcz3a8vwa8vwa8vwa8vwZcDkAAAAAAAA
AAAAAAAAAAAAAAAAY73gZcz3a8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAAOXGH
a8vwZcz3a8vwa8vwEi87AAAAAAAAAAAAAAAAAAAAVaTCa8vwa8vwZcz3a8vw
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWavLa8vwa8vwa8vwa8vwa8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAAQomna8vwZcz3Zcz3Zcz3Zcz3Zcz3Xr/nCBwl
AAAAAAAAAAAAAAAAAAAATqHDa8vwZcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32Ya8vwa8vwZcz3a8vwZcz3a8vwa8vwa8vwZcz3Zcz3a8vwa8vwZcz3Zcz3
a8vwa8vwZcz3Zcz3a8vwa8vwTqDDSJW1Zcz3a8vwa8vwa8vwVa7TP4ShZcz3
a8vwZcz3Zcz3Zcz3Y8jzI0pZYcXvZcz3Zcz3a8vwa8vwZcz3Zcz3a8vwa8vw
a8vwZcz3Zcz3a8vwZcz3OXGHV7HWa8vwa8vwZcz3a8vwZcz3VKvQRYafa8vw
a8vwZcz3Zcz3TZ7AJFFkOG+EOG+ENHCINHCINHCIOG+ENHCINHCINHCIOG+E
NHCIOG+EOG+ENHCINHCIOG+ENHCIOG+ENHCIYcTtZcz3a8vwZcz3a8vwZcz3
Zcz3a8vwa8vwZcz3Zcz3OnuWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAES04Ysfwa8vwZcz3Zcz3Zcz3
GDRCECs2AAAAAAAAAAAAAAAAAAAAAAAAVa3SZcz3Zcz3Zcz3a8vwZcz3b8n1
Spm6AAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4Sda8vwZcz3a8vwb8n1WqzMAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3ab7oAAAAAAAA
AAAAAAAAAAAAAAAAXr7ma8vwZcz3Zcz3SpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3a8vwZcz3Zcz3FC85AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3Zcz3
Zcz3bsfzAAAAAAAAAAAAAAAAAAAAAAAAYrPaZcz3Zcz3b8n1Zcz3Zcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAV7HXZcz3Zcz3Zcz3Zcz3Z8PnUZy5Kl1yAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3a8vwa8vwQYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3
Zcz3Zcz3Zcz3a8vwZcz3Zcz3TqDDSJW1a8vwZcz3Zcz3Zcz3Va7TP4Sha8vw
Zcz3Zcz3Zcz3a8vwa8vwRpGwT5q2a8vwa8vwZcz3Zcz3a8vwb8n1Zcz3Zcz3
Zcz3a8vwZcz3Zcz3Xb3mKVtvZcz3Zcz3Zcz3a8vwZcz3a8vwVKvQQIekZcz3
Zcz3a8vwZcz3Up67RYehW7ngW7ngYLjZW7ngW7ngW7ngYLjZW7ngW7ngW7ng
YLjZW7ngW7ngW7ngW7ngW7ngYLjZW7ngW7ngZMr0Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3YMLsH0hYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVKvQZcz3a8vwZcz3Zcz3
ESo0AAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTuZcz3Zcz3Zcz3Zcz3Zcz3Zcz3
YcXvAAAAAAAAAAAAAAAAAAAAAAAAAAAAUabJa8vwZcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3a8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3b8n1Zcz3b8n1Ei87AAAAAAAAAAAAAAAAAAAAVa7TZcz3a8vwZcz3Zcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXcZcz3Zcz3Zcz3Zcz3b8n1YcTt
AAAAAAAAAAAAAAAAAAAAAAAAWLLYZcz3asntVa7TO3yXCBwlAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3b8n1b8n1Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3a8vwWq3NP4ShZcz3
Zcz3a8vwZcz3Zcz3Zcz3YMLrI09hZMr1Zcz3Zcz3Zcz3Zcz3b8n1Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3QIekVKLAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe4Zcz3b8n1b8n1Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3
Zcz3Zcz3Zcz3Zcz3b8n1Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3dMnvXbzkKVpuAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASZe3a8vwZcz3Zcz3Zcz3
FDNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTua8vwb8n1Zcz3Zcz3Zcz3a8vw
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAFDNAY8fxZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3dMnvZcz3Zcz3Zcz3b8n1Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3FC85AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3Zcz3
Zcz3ZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPaZcz3Zcz3Zcz3Zcz3Zcz3asHr
AAAAAAAAAAAAAAAAAAAAAAAATJ2+Q4upGTxKAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwb8n1Zcz3Zcz3dMnvZcz3
Zcz3a8vwZcz3Zcz3Zcz3Zcz3U5+9SJW1b8n1Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3b8n1Zcz3Zcz3Zcz3PH6aU6nNZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3YsXvIEpbbcXxZcz3Zcz3Zcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3a8vwZcz3TZ7ASZe4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3b8n1
Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3b8n1a8vwZcz3Zcz3a8vwZcz3a8vwZcz3
a8vwdMnvdMnva8vwZcz3b8n1a8vwacjtUabJOXiTLl1wJFBjKk9fKk9fJlBg
JFBjJlBgDCMsAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3b8n1a8vwZcz3
HkVVAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTua8vwZcz3a8vwZcz3b8n1Zcz3
Y8nzAAAAAAAAAAAAAAAAAAAAAAAARomjb8n1W7jfZcz3Zcz3a8vwVa3SAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwX8HqAAAAAAAA
AAAAAAAAAAAAAAAAY73gZcz3Zcz3dMnvSpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3a8vwZcz3b8n1Fi45AAAAAAAAAAAAAAAAAAAAWq3Nb8n1a8vwZcz3Zcz3
Zcz3asnuAAAAAAAAAAAAAAAAAAAAAAAAZrPVZcz3a8vwa8vwa8vwa8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAMmB2VKG/Y8jyZcz3a8vwZcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3b8n1Zcz3b8n1dMnvZcz3b8n1a8vwZcz3Zcz3Zcz3dMnva8vw
Zcz3a8vwa8vwa8vwa8vwZcz3U5+9SJW1b8n1a8vwb8n1b8n1XqvRP4ShdMnv
Zcz3Zcz3b8n1a8vwZcz3Zcz3W7jfMWN2a8vwZcz3a8vwa8vwa8vwa8vwb8n1
dMnva8vwa8vwSpi5R5Oza8vwa8vwZcz3a8vwZcz3a8vwa8vwWavKRYafZcz3
Zcz3b8n1b8n1TZ7ASZe4Zcz3a8vwa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3
a8vwZcz3b8n1a8vwZcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3a8vwZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3a8vwdMnvZcz3a8vwZcz3Zcz3Zcz3
Zcz3b8n1a8PuKlxxAAAAAAAAAAAAAAAAAAAAAAAAQ4yqdMnva8vwZcz3a8vw
LWF3AAAAAAAAAAAAAAAAAAAAAAAAAAAAa8HsZcz3a8vwb8n1Zcz3Zcz3a8vw
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAVa7TZMr1QH6Wa8vwZcz3b8n1XarQAAAA
AAAAAAAAAAAAAAAAFTVCZcz3dMnvdMnvdMnva8vwa8vwZcz3ZcDkAAAAAAAA
AAAAAAAAAAAAAAAAXr7ma8vwa8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAAOXGH
a8vwZcz3a8vwZcz3Ei87AAAAAAAAAAAAAAAAAAAAVa7Ta8vwZcz3dMnvZcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXca8vwZcz3Zcz3Zcz3Zcz3ZsPm
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
HkVVRpGwXr7mZcz3b8n1a8vwa8vwb8n1a8vwQYmmAAAAAAAAAAAAAAAAAAAA
QXuXdMnva8vwa8vwa8vwa8vwZcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3b8n1
b8n1Zcz3Zcz3Zcz3Zcz3b8n1TqDDTJSwa8vwb8n1Zcz3Zcz3Wq3NSYKcZcz3
Zcz3a8vwa8vwZcz3b8n1dMnvZcz3MGd+Wrfda8vwZcz3Zcz3b8n1Zcz3a8vw
Zcz3Zcz3bsfzKU5eYMLrZcz3Zcz3dMnvZcz3dMnvZcz3Zcz3XKnOQIeka8vw
Zcz3a8vwa8vwWZy6VJWya8vwZcz3b8n1Zcz3a8vwb8n1a8vwZcz3a8vwa8vw
Zcz3Zcz3Zcz3Zcz3a8vwa8vwa8vwZcz3a8vwb8n1b8n1Zcz3b8n1dMnvZcz3
Zcz3Zcz3b8n1Zcz3Zcz3Zcz3b8n1b8n1Zcz3Zcz3Zcz3Zcz3Zcz3a8vwa8vw
Zcz3a8vwa8vwRY+uAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3dMnv
Q4upAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTuZcz3Zcz3dMnvZcz3b8n1a8vw
acjsAAAAAAAAAAAAAAAAAAAAAAAAYLfZVJu+MWqCdMnvZcz3Zcz3XarQAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3b8n1br7jAAAAAAAA
AAAAAAAAAAAAAAAAXr7mb8n1Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3Ei87AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3b8n1
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXca8vwZcz3Zcz3Zcz3Zcz3ZsPm
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABRQbOm6HWKnJ
ZMv1Zcz3a8vwZcz3b8n1b8n1Zcz3b8n1a8vwQYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3b8n1Zcz3Zcz3dMnva8vwZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
b8n1Zcz3Zcz3Zcz3Zcz3b8n1TqDDSJW1Zcz3a8vwa8vwZcz3Va7TP4Sha8vw
Zcz3Zcz3b8n1a8vwZcz3a8vwZcz3U6rOQnyYb8n1Zcz3Zcz3a8vwZcz3Zcz3
b8n1Zcz3UqfLQYGZdMnvb8n1Zcz3Zcz3Zcz3a8vwZcz3Zcz3WavKR4Wjb8n1
Zcz3Zcz3Zcz3TZ7ASZe4Zcz3Zcz3Zcz3b8n1a8vwZcz3Zcz3Zcz3b8n1Zcz3
a8vwa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3a8vwa8vwZcz3Zcz3dMnvZcz3
a8vwa8vwZcz3b8n1Zcz3a8vwa8vwZcz3Zcz3a8vwb8n1Zcz3a8vwb8n1Zcz3
a8vwZcz3Zcz3S5GsAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3a8vwa8vwZcz3
bLvfAw8VAAAAAAAAAAAAAAAAAAAAAAAAb8Hmb8n1a8vwZcz3a8vwa8vwb8n1
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAVq/VFjdEPW+FZcz3a8vwa8vwWqzMAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3dMnva8vwdMnvZcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3a8vwUY6qAAAAAAAAAAAAAAAAAAAAOXGH
dMnva8vwa8vwa8vwFC85AAAAAAAAAAAAAAAAAAAAVa7TdMnvZcz3dMnva8vw
Zcz3ZMr1AAAAAAAAAAAAAAAAAAAAAAAAXrTWZcz3a8vwdMnva8vwa8vwasHr
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ1drT5m1Z8Pna8vwZcz3
Zcz3a8vwZcz3a8vwa8vwZcz3a8vwa8vwb8n1RoihAAAAAAAAAAAAAAAAAAAA
O32YdMnvZcz3a8vwZ8PnX7XXZcz3Zcz3a8vwa8vwb8n1a8vwZcz3Zcz3Zcz3
a8vwa8vwdMnvdMnvZcz3a8vwWp68TJSwa8vwZcz3Zcz3Zcz3Va7TQ4Sdb8n1
a8vwZcz3a8vwZcz3Zcz3b8n1a8vwbsj0KFNkX8HqdMnva8vwZcz3a8vwa8vw
a8vwZcz3LmR7WrjfZcz3a8vwZcz3a8vwZcz3b8n1dMnvZcz3XKnOQIeka8vw
Zcz3Zcz3Zcz3TZ7ASZe4a8vwa8vwdMnvZcz3Zcz3dMnvdMnvZcz3a8vwa8vw
Zcz3Zcz3Zcz3b8n1dMnva8vwZcz3b8n1Zcz3Zcz3Zcz3a8vwZcz3Zcz3a8vw
Zcz3a8vwa8vwdMnvZcz3Zcz3a8vwZcz3b8n1a8vwdMnvZcz3a8vwb8n1Zcz3
a8vwdMnvZcz3SpGsAAAAAAAAAAAAAAAAAAAAAAAATomkb8n1Zcz3Zcz3X8Hp
asjtOnqVAAAAAAAAAAAAAAAAAAAAAAAAZ8PnZcz3a8vwb8n1Zcz3a8vwZcz3
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAGDZCAAAANHCIZcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFzVAa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3ab7oAAAAAAAA
AAAAAAAAAAAAAAAAY73gdMnvb8n1Zcz3SpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3b8n1Zcz3b8n1Ei87AAAAAAAAAAAAAAAAAAAAVa7Tb8n1Zcz3Zcz3b8n1
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPab8n1Zcz3b8n1Zcz3Zcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAFjM+PoGdZK/QZcz3b8n1Zcz3b8n1dMnv
b8n1b8n1Zcz3Zcz3a8vwZcz3Zcz3a8vwZcz3SIelAAAAAAAAAAAAAAAAAAAA
O32YdMnvZcz3Zcz3WLTaOnuVa8vwZcz3Zcz3a8vwb8n1a8vwa8vwa8vwZcz3
b8n1Zcz3Zcz3a8vwZcz3Zcz3TqDCSJW1b8n1dMnvdMnva8vwVa7TQ4SdZcz3
a8vwZcz3a8vwZcz3Zcz3b8n1a8vwZcz3UJq3RpGwZcz3dMnvZcz3Zcz3Zcz3
a8vwXrTVOml+Zcz3Zcz3Zcz3b8n1a8vwa8vwZcz3a8vwa8vwWavKQIekdMnv
a8vwa8vwa8vwWZy6SZe4b8n1Zcz3a8vwa8vwZcz3Zcz3dMnvZcz3Zcz3b8n1
b8n1Zcz3a8vwZcz3b8n1dMnva8vwa8vwa8vwa8vwZcz3a8vwZcz3Zcz3Zcz3
a8vwZcz3Zcz3Zcz3dMnva8vwZcz3dMnva8vwZcz3Zcz3dMnvZcz3a8vwb8n1
b8n1Zcz3a8vwO32YAAAAAAAAAAAAAAAAAAAAAAAAQ4yqa8vwdMnva8vwYLjZ
S4urZ7PVAAAAAAAAAAAAAAAAAAAAAAAAYcTudMnvZcz3acjsaMXpZcz3dMnv
dMnvXr/nUI6qGDpIAAAAAAAAAAAAAAAAAAAANm2CdMnvdMnva8vwWqzMAAAA
AAAAAAAAAAAAAAAAGDRCZcz3b8n1Zcz3a8vwa8vwZcz3a8vwX8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3a8vwa8vwTY6vAAAAAAAAAAAAAAAAAAAAOXGH
a8vwa8vwdMnva8vwFC85AAAAAAAAAAAAAAAAAAAAWq3Na8vwZcz3a8vwa8vw
b8n1asnuAAAAAAAAAAAAAAAAAAAAAAAAXrTWZcz3Zcz3a8vwdMnva8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAASZa2Y8jzZcz3Zcz3a8vwZcz3a8vwa8vwZcz3
a8vwa8vwdMnva8vwZcz3dMnva8vwZcz3dMnvRoihAAAAAAAAAAAAAAAAAAAA
O32YZcz3a8vwdMnvZrLUPXmQb8n1b8n1dMnvZcz3a8vwb8n1b8n1b8n1dMnv
Zcz3a8vwZcz3b8n1a8vwZcz3Vpe0VJWya8vwZcz3Zcz3b8n1YqvMP4ShdMnv
b8n1a8vwZcz3dMnva8vwa8vwZcz3a8vwYsfxIk1ecsXqZcz3dMnvdMnvb8n1
b8n1QXmVVKzRa8vwa8vwdMnva8vwZcz3Zcz3a8vwb8n1Zcz3VKvQRYafZcz3
b8n1b8n1b8n1TZ7AVJWyZcz3a8vwZcz3Zcz3Zcz3a8vwZcz3a8vwdMnva8vw
a8vwdMnvZcz3Zcz3a8vwZcz3Zcz3b8n1Zcz3b8n1a8vwb8n1a8vwdMnvdMnv
dMnva8vwZcz3Zcz3Z7vlZK/QV7LXV7LXXLHRXLHRV7LXYK/WV7LXXLHRXLHR
V7LXYK/WSpCrBA4UAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3b8n1Zcz3YcTt
AggMWKnIAAAAAAAAAAAAAAAAAAAAAAAAYcTudMnvZcz3bsjzNmN2HUNTNnON
T5O0XLvia8vwZ8PnQXqWAAAAAAAAAAAAAAAANHCIZcz3b8n1b8n1Va3SAAAA
AAAAAAAAAAAAAAAACBggZ8TodMnvb8n1b8n1dMnvb8n1a8vwVrDVAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3a8vwUY6qAAAAAAAAAAAAAAAAAAAAO3CK
Zcz3Zcz3Zcz3Zcz3FS46AAAAAAAAAAAAAAAAAAAAVa7TdMnvb8n1Zcz3a8vw
b8n1bsfzAAAAAAAAAAAAAAAAAAAAAAAAXrTWa8vwZcz3Zcz3Zcz3dMnvYcTt
AAAAAAAAAAAAAAAAAAAAAAAAV6jHa8vwZcz3b8n1a8vwb8n1Zcz3a8vwZcz3
Zcz3Zcz3b8n1dMnvZcz3b8n1b8n1Zcz3Zcz3SIelAAAAAAAAAAAAAAAAAAAA
O32Yb8n1Zcz3Zcz3ZbffNXCJa8vwZcz3a8vwZcz3a8vwa8vwa8vwZcz3dMnv
Zcz3dMnva8vwb8n1a8vwZcz3RpKxTZ/Ba8vwZcz3a8vwZcz3XqvRP4Sha8vw
b8n1dMnvZcz3Zcz3Zcz3a8vwb8n1dMnvdMnvQoqoTqHDZcz3Zcz3a8vwa8vw
ZcDjJ1Fhbsj0b8n1Zcz3Zcz3dMnva8vwZcz3a8vwb8n1dMnvXKnOQIeka8vw
a8vwa8vwZcz3TZ7ATpayb8n1dMnvb8n1dMnvZcz3a8vwb8n1Zcz3Zcz3Zcz3
Zcz3dMnva8vwZcz3a8vwdMnva8vwdMnva8vwb8n1a8vwb8n1Zcz3Zcz3Zcz3
Zcz3b8n1dMnvZcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUpGtZcz3a8vwdMnva8vw
JlVoEi87AAAAAAAAAAAAAAAAAAAAAAAAZbjgZcz3dMnvZcz3W7ngBA8UAAAA
AAAAAAAAOWyFXb3la8vwSYKbAAAAAAAAAAAAOHaQa8vwa8vwa8vwWqzMAAAA
AAAAAAAAAAAAAAAAAAAAKFhsSJW1T5m1T5m1Spq7T5m1TI2tHT9MAAAAAAAA
AAAAAAAAAAAAAAAAbLvfdMnvdMnvb8n1RpGwAAAAAAAAAAAAAAAAAAAANXKL
a8vwZcz3dMnvdMnvFC85AAAAAAAAAAAAAAAAAAAAYqzMZcz3a8vwdMnvZcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPab8n1a8vwZcz3dMnvZcz3YcXv
AAAAAAAAAAAAAAAAAAAAAAAAKVFlUZW3T5m1T5m1Spq7Spq7Vpe1Upe5Vpe1
Vpe1T5m1Spq7Spq7Spq7Yrvda8vwa8vwb8n1RoihAAAAAAAAAAAAAAAAAAAA
RXuTa8vwZcz3Zcz3ZcHkLl5xZcz3Zcz3b8n1dMnvb8n1b8n1Zcz3b8n1Zcz3
b8n1Zcz3Zcz3a8vwb8n1Zcz3O32YYKjJZcz3dMnvZcz3Zcz3Wq3NRoKgb8n1
Zcz3Zcz3b8n1dMnvdMnvb8n1Zcz3Zcz3Zcz3ZL7gLlVnZcv2Zcz3Zcz3Zcz3
RY6tVJu+a8vwa8vwZcz3b8n1Zcz3b8n1dMnvZcz3a8vwZcz3VKvQS4WfZcz3
Zcz3Zcz3dMnvVZy/UZW2Zcz3Zcz3a8vwZcz3dMnvZcz3a8vwZcz3dMnvdMnv
Zcz3Zcz3b8n1a8vwZcz3Zcz3b8n1Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3dMnv
Zcz3Zcz3dMnvdMnvRZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWp28b8n1Zcz3b8n1dMnv
T4yoAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ01fRI6tUY6qWKHFb8n1Q4SdAAAA
AAAAAAAAAAAAEi87W7jfbcXxIk5gAAAAAAAARoOhZcz3b8n1b8n1XbHSAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAYMPsZcz3Zcz3b8n1UY6qAAAAAAAAAAAAAAAAAAAAO3CK
dMnvZcz3Zcz3Zcz3Fi45AAAAAAAAAAAAAAAAAAAAXqzRZcz3Zcz3dMnvZcz3
dMnvbsfzAAAAAAAAAAAAAAAAAAAAAAAAXrTWb8n1a8vwZcz3Zcz3dMnva8vw
CiApAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUabKb8n1a8vwZcz3SIelAAAAAAAAAAAAAAAAAAAA
O32Ya8vwdMnvb8n1b8n1JkhXcsbra8vwZcz3Zcz3Zcz3dMnvZcz3Zcz3a8vw
Zcz3dMnvZcz3a8vwdMnva8vwJFBjbb3hZcz3dMnvdMnvb8n1Wq3NP4ShdMnv
b8n1a8vwZcz3Zcz3a8vwdMnvdMnvb8n1b8n1Zcz3QXWMY6zNdMnvdMnvccXq
I0pZbMTvZcz3dMnva8vwb8n1a8vwZcz3dMnvb8n1b8n1a8vwVKvQS4Wfb8n1
dMnvZcz3a8vwUp67VJWyb8n1b8n1Zcz3Zcz3dMnvZcz3dMnvZcz3Zcz3dMnv
dMnva8vwb8n1dMnvZcz3Zcz3dMnva8vwdMnva8vwb8n1dMnvdMnvZcz3a8vw
dMnvdMnvZcz3Zcz3UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXLvja8vwb8n1a8vwZcz3
Xr7mBA8UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx8nZcDkZrniAggM
AAAAAAAAAAAAAAAALFlra8rvVZazAAAAAAAAU5+9dMnva8vwa8vwaL3mAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAFjM+bsj0dMnvdMnva8vwRpGwAAAAAAAAAAAAAAAAAAAAOXGH
Zcz3b8n1a8vwdMnvEi87AAAAAAAAAAAAAAAAAAAAWq3NdMnvb8n1Zcz3dMnv
Zcz3asnuAAAAAAAAAAAAAAAAAAAAAAAAZrPVa8vwb8n1b8n1dMnvZcz3b8n1
LllvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAXqTDZcz3Zcz3dMnvRoihAAAAAAAAAAAAAAAAAAAA
QXuXb8n1Zcz3Zcz3a8vwPoGdVKzRb8n1b8n1dMnvdMnvZcz3dMnvdMnvdMnv
dMnvZcz3dMnvb8n1Zcz3ZLbeL1ZoZcz3dMnvZcz3Zcz3a8vwVa7TSYKcZcz3
a8vwZcz3dMnvb8n1dMnvZcz3Zcz3a8vwa8vwb8n1WLLYNXCJZcz3Zcz3TZ/B
S4ura8vwdMnvZcz3Zcz3a8vwZcz3b8n1Zcz3Zcz3a8vwdMnvWavKQIeka8vw
Zcz3dMnvb8n1VZy/SZe4a8vwa8vwdMnvb8n1Zcz3dMnvZcz3b8n1dMnvZcz3
Zcz3b8n1Zcz3Zcz3dMnva8vwZcz3b8n1Zcz3b8n1a8vwZcz3Zcz3b8n1b8n1
Zcz3dMnvdMnvZcz3UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOWd7Zcz3a8vwb8n1b8n1dMnv
b8n1SoOdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASY2odMnvNmiA
AAAAAAAAAAAAAAAAAAAAXLriW7jfAAAAAAAAWrfddMnvb8n1a8vwZcz3K1Fi
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAPXmQZcz3Zcz3b8n1dMnvUY6qAAAAAAAAAAAAAAAAAAAAPnCG
a8vwb8n1Zcz3b8n1FS46AAAAAAAAAAAAAAAAAAAAVa7Ta8vwdMnvZcz3dMnv
b8n1asnuAAAAAAAAAAAAAAAAAAAAAAAAYrPaa8vwdMnvZcz3b8n1a8vwa8vw
VZWyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAXqTDdMnvZcz3b8n1RoihAAAAAAAAAAAAAAAAAAAA
RXuTdMnvdMnvb8n1dMnvZ7PWM2Z6a8rvZcz3Zcz3dMnvZcz3Zcz3Zcz3Zcz3
b8n1Zcz3b8n1dMnva8vwPH6aWZ27Zcz3b8n1b8n1b8n1dMnvVa7TSYKcb8n1
dMnvZcz3a8vwZcz3dMnvZcz3dMnvb8n1a8vwdMnvb8n1M11warjbb8n1Kldp
bLzgZcz3dMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1b8n1XKnOR4WjdMnv
Zcz3a8vwa8vwUp67UZW2b8n1Zcz3a8vwdMnvZcz3b8n1a8vwZcz3dMnvb8n1
a8vwdMnvdMnvZcz3dMnvdMnva8vwdMnva8vwb8n1b8n1b8n1a8vwa8vwZcz3
b8n1Zcz3b8n1dMnvRZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjA9XLzkdMnvb8n1a8vwa8vwZcz3
a8vwa8LsIkhXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHj5OZMr1Up+8
AAAAAAAAAAAAAAAAAAAAXaPCbcXwAAAAAggMccTpZcz3a8vwb8n1b8n1UKTH
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABA8UY7Tcb8n1dMnva8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
b8n1a8vwdMnva8vwFi45AAAAAAAAAAAAAAAAAAAAYqzMb8n1b8n1dMnvZcz3
a8vwc8ftAAAAAAAAAAAAAAAAAAAAAAAAXrTWb8n1Zcz3dMnva8vwb8n1dMnv
Y8jyJ1drAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUabKb8n1dMnva8vwSIelAAAAAAAAAAAAAAAAAAAA
O32YZcz3a8vwa8vwZcz3Zcz3SIWkTY+vdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvdMnva8vwZcz3WaPHNmJ1ZMv1b8n1dMnvdMnva8vwb8n1YqvMP4Sha8vw
Zcz3b8n1b8n1b8n1Zcz3dMnvZcz3a8vwb8n1Zcz3a8vwUKXIQIajWqzMQ3iQ
Zcz3dMnvZcz3Zcz3a8vwZcz3Zcz3a8vwZcz3Zcz3Zcz3a8vwWavKRYafZcz3
dMnvb8n1dMnvVZy/Tpaya8vwdMnvdMnvZcz3dMnva8vwdMnvdMnva8vwa8vw
dMnvb8n1b8n1dMnvZcz3Zcz3b8n1Zcz3dMnva8vwa8vwa8vwb8n1dMnvdMnv
dMnvZcz3b8n1b8n1UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKVRlabfZb8n1dMnvdMnvb8n1dMnvb8n1
a8vwdMnvYrPbEicxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZrHTYrvd
AAAAAAAAAAAAAAAAAAAAT5i0a8vwDB8oGDpIWKLGb8Dka8vwdMnvdMnvb8n1
TIysAggMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAADR8nVKLAdMnvZcz3dMnvdMnvdMnvSpCrAAAAAAAAAAAAAAAAAAAAOXGH
b8n1b8n1dMnvZcz3FS46AAAAAAAAAAAAAAAAAAAAWq3NZcz3Zcz3dMnvb8n1
b8n1bsfzAAAAAAAAAAAAAAAAAAAAAAAAZrPVdMnvZcz3dMnva8vwZcz3dMnv
dMnvbLzfM11wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAVqbEZcz3dMnvdMnvTIehAAAAAAAAAAAAAAAAAAAA
RXuTb8n1dMnvdMnvdMnvdMnvasjtO32YPH+aX8HqZcz3Zcz3a8vwb8n1Zcz3
Zcz3b8n1bMTvUY+rMV91b8Dka8vwZcz3a8vwdMnva8vwZcz3YqvMRoKgdMnv
dMnva8vwdMnvdMnvb8n1b8n1dMnva8vwdMnvdMnvdMnvc8fsJ01fLWJ5YbHZ
b8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1XKnOS4WfZcz3
dMnvb8n1a8vwVZy/UpGtYsbwYsbwcMPoa8PucMPoYsbwYsbwa8PucMPoa8Pu
aMXpYsbwaMXpcMPocMPocMPocMPoa8PucMPocMPocsbrdMnvb8n1b8n1b8n1
b8n1dMnvb8n1dMnvSpq7Kk9fKE9iJFBjJlBgKE9iKE9iKk9fKE9iKk9fKk9f
Kk9fKk9fKE9iK1NnNWV9RYCeYKfHc8jtZcz3a8vwb8n1b8n1dMnvb8n1dMnv
b8n1Zcz3dMnvVa3SBxkgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXKjNbLzg
AAAAAAAAAAAAAAAAAAAAUpCsb8n1IkFPAAAAL1dpZcz3dMnvZcz3b8n1dMnv
dMnvZ7TXSYemMGd+J1ZpKk9fKE9iKE9iJFBjKk9fKk9fJlBgKk9fK1hqOGqD
UY6qZ7vldMnvZcz3dMnvb8n1b8n1Zcz3U5m8LFJjKFNkLFJjKlJmLFJjSoOd
dMnva8vwb8n1dMnvMVlsKE9iJFBjJFBjKk9fKk9fZbDRdMnvdMnvb8n1dMnv
b8n1asruKE9iKk9fKE9iJFBjJFBjKE9iYLjZb8n1dMnvb8n1b8n1b8n1Zcz3
b8n1b8n1ZMn0UqnNRn2WNWp+KFhsKE9iJFBjKk9fKk9fKk9fJFBjKk9fKE9i
JFBjJFBjKE9iJlBgKE9iYarKdMnvb8n1Zcz3UJO0KlJmKFNkLFJjJVRnKFNk
S4uqdMnvb8n1b8n1b8n1Zcz3dMnvb8j0XaTDLVRmPHGLUZW2XaPCWKnJXaPC
Vpi1Q3mQKEtbSpi5acfrb8n1b8n1dMnvb8n1Zcz3b8n1dMnvWLLYSpCrZcz3
Zcz3dMnva8vwb8n1a8vwdMnvb8n1dMnvb8n1b8n1Zcz3Zcz3UJq3PnCGdMnv
a8vwb8n1b8n1b8n1b8n1Zcz3Zcz3a8vwZcz3b8n1b8n1a8vwY67PTpCwdMnv
Zcz3a8vwb8n1XaPCKE9iKk9fKk9fKE9iJlBgKE9iKk9fKk9fKk9fJFBjJFBj
KE9iKk9fKE9iKE9iJFBjJFBjJFBjJlBgJFBjJFBjUZa3Zcz3Zcz3dMnva8vw
dMnva8vwdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnva8vwa8vwb8n1b8n1Zcz3
b8n1dMnvdMnvdMnvdMnvZcz3b8n1dMnvdMnva8vwa8vwb8n1a8vwZcz3dMnv
dMnvb8n1dMnvdMnvV6fGID5LV5m2S4agRYafOXiTAAAAOXKIJU1dZrniX7bY
AAAAAAAAAAAAAAAAAAAATomka8vwKVFlAAAAXKLBZcz3dMnva8vwbsfzZcz3
dMnvdMnvdMnvdMnvb8n1a8vwa8vwdMnvZcz3b8n1b8n1b8n1dMnva8vwb8n1
a8vwb8n1dMnvdMnva8vwdMnvdMnvdMnvZcz3b8n1Zcz3dMnvb8n1b8n1a8vw
b8n1a8vwb8n1b8n1dMnvdMnvdMnvb8n1Zcz3b8n1b8n1b8n1a8vwZcz3a8vw
b8n1dMnvdMnva8vwdMnvdMnva8vwb8n1a8vwb8n1a8vwdMnvdMnvdMnva8vw
a8vwdMnvdMnvb8n1dMnvdMnva8vwdMnvb8n1a8vwdMnvdMnvb8n1a8vwdMnv
dMnvi6W2iqW5a8vwb8n1b8n1Zcz3b8n1dMnvdMnvb8n1Zcz3dMnvdMnva8vw
Zcz3Zcz3dMnva8vwdMnvb8n1dMnvb8n1b8n1dMnvarncV6DDUZW2RpGwUJS2
Wp+9YLfYc8jub8n1a8vwdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnv
b8n1b8n1dMnvdMnvZcz3a8vwb8n1dMnva8vwdMnvdMnvdMnvZcz3Zcz3b8n1
a8vwa8vwa8vwa8vwb8n1dMnvb8n1dMnva8vwa8vwdMnvb8n1dMnvb8n1dMnv
b8n1dMnva8vwdMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1Zcz3dMnvdMnvdMnv
b8n1dMnva8vwdMnvdMnvdMnvb8n1dMnvdMnva8vwdMnvdMnvZcz3dMnvdMnv
b8n1dMnvZcz3b8n1Zcz3a8vwb8n1b8n1a8vwZcz3b8n1b8n1a8vwdMnvdMnv
dMnvdMnvZcz3Zcz3Zcz3dMnva8vwb8n1b8n1b8n1b8n1a8vwdMnvdMnva8vw
b8n1a8vwdMnvb8n1dMnvW6fMbsjzZcz3dMnvdMnvPm+GVJSxZrrjdMnvU5Kv
AAAAAAAAAAAAAAAAAAAAQ4Sdb8n1M15xKVRlc8jtdMnvb8n1b8n1ZcHkZK/Q
b8n1Zcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1a8vw
b8n1a8vwb8n1b8n1dMnvZcz3b8n1dMnvdMnvdMnvdMnvZcz3a8vwdMnvb8n1
dMnvb8n1a8vwa8vwZcz3b8n1b8n1a8vwdMnvdMnvdMnva8vwb8n1dMnvdMnv
dMnvb8n1b8n1b8n1dMnvmIZ/dMnvdMnvb8n1a8vwb8n1dMnvb8n1b8n1dMnv
iqS4mIZ/b8n1b8n1b8n1dMnvb8n1dMnva8vwb8n1Zcz3b8n1a8vwb8n1b8n1
mIZ/mIZ/mIZ/mIZ/k5KWjKKydMnvdMnvZcz3Zcz3dMnvdMnvb8n1b8n1b8n1
dMnvdMnvZcz3dMnvb8n1a8vwdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
Zcz3b8n1b8n1dMnvb8n1dMnvdMnvZcz3b8n1b8n1Zcz3dMnvb8n1b8n1dMnv
a8vwdMnvZcz3b8n1dMnvdMnvdMnvZcz3b8n1b8n1b8n1b8n1dMnvdMnvdMnv
b8n1dMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1b8n1b8n1a8vwZcz3dMnvb8n1
dMnvb8n1b8n1Zcz3Zcz3a8vwZcz3dMnvZcz3a8vwa8vwdMnvb8n1b8n1a8vw
dMnvb8n1dMnvb8n1b8n1b8n1dMnvb8n1b8n1b8n1dMnvb8n1dMnvb8n1Zcz3
b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvdMnvZcz3b8n1Zcz3
Zcz3dMnvdMnvdMnvb8n1dMnvdMnva8vwdMnvdMnvdMnvb8n1dMnvb8n1a8vw
dMnvZcz3dMnvb8n1dMnva8vwdMnvb8n1b8n1b8n1asDqRXuUZcz3bsfyH0hY
AAAAAAAAAAAAAAAAAAAAQHKJZcz3P3GHW6fMdMnvdMnvdMnvdMnvb8HlLl1w
dMjub8n1dMnva8vwb8n1b8n1Zcz3dMnva8vwb8n1Zcz3a8vwdMnvdMnvdMnv
dMnvdMnva8vwb8n1dMnvdMnvZcz3dMnvZcz3b8n1dMnvb8n1Zcz3dMnvdMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1Zcz3a8vwdMnvdMnvb8n1b8n1b8n1
a8vwa8vwdMnvZcz3mIZ/mIZ/dMnvdMnvdMnvdMnvZcz3a8vwdMnvb8n1gbfT
mIZ/mIZ/a8vwdMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/l4qHdMnvdMnvZcz3b8n1a8vwdMnvdMnvdMnv
b8n1dMnvb8n1dMnvdMnvZcz3a8vwZcz3Zcz3a8vwZcz3b8n1dMnva8vwdMnv
dMnvdMnvb8n1dMnvZcz3Zcz3dMnvdMnva8vwdMnvb8n1dMnvdMnvb8n1dMnv
b8n1dMnvb8n1dMnvb8n1Zcz3dMnvdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnv
b8n1b8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvZcz3b8n1Zcz3
a8vwdMnvb8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvb8n1Zcz3
a8vwb8n1dMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnv
dMnvb8n1a8vwb8n1dMnva8vwZcz3dMnvb8n1b8n1b8n1b8n1dMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnv
b8n1dMnva8vwdMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvccTpdMnvV6DEAAAA
AAAAAAAAAAAAAAAAAAAAMltudMnvVJq9a8vwb8n1a8vwdMnvdMnvasDrAAAA
XKjNa8vwb8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1
b8n1a8vwb8n1b8n1dMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1
b8n1b8n1dMnvb8n1a8vwZcz3b8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnva8vw
dMnvdMnvdsnvmIZ/mIZ/mIZ/Zcz3dMnvb8n1b8n1dMnvdMnvZcz3g83tmYiB
mIZ/mIZ/dMnvZcz3dMnvdMnva8vwb8n1b8n1b8n1a8vwb8n1mIZ/mIZ/mIZ/
//fX//fX//fX3dG6momBmIZ/mIZ/mIZ/dMnvdMnvdMnvb8n1Zcz3dMnvb8n1
dMnvb8n1a8vwZcz3b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1b8n1
a8vwb8n1a8vwb8n1b8n1dMnvdMnvb8n1dMnvb8n1b8n1a8vwZcz3a8vwb8n1
a8vwb8n1dMnvb8n1dMnvdMnvdMnvb8n1Zcz3a8vwZcz3b8n1b8n1dMnvb8n1
dMnvdMnvb8n1a8vwa8vwa8vwb8n1b8n1dMnvZcz3b8n1b8n1dMnva8vwdMnv
dMnvdMnvdMnvb8n1b8n1b8n1a8vwb8n1dMnvb8n1dMnvZcz3Zcz3dMnvdMnv
b8n1dMnvZcz3a8vwZcz3a8vwZcz3Zcz3dMnva8vwa8vwdMnvb8n1b8n1Zcz3
dMnvb8n1dMnvb8n1b8n1dMnvb8n1dMnva8vwdMnvdMnvdMnva8vwdMnvdMnv
b8n1dMnvb8n1Zcz3dMnvdMnvb8n1a8vwdMnvdMnva8vwa8vwdMnvdMnvdMnv
b8n1b8n1a8vwdMnvb8n1b8n1a8vwZcz3a8vwZcz3Zcz3b8n1c8jtKE9iAAAA
AAAAAAAAAAAAAAAAAAAAHjtIdMnvbsfza8vwb8n1Zcz3b8n1a8vwkH54AAAA
TUM/mIZ/mIZ/b8n1b8n1b8n1a8vwdMnvZcz3dMnvb8n1Zcz3dMnva8vwa8vw
b8n1dMnva8vwb8n1dMnvb8n1a8vwb8n1Zcz3b8n1dMnvb8n1dMnva8vwa8vw
dMnvdMnvdMnvb8n1dMnvdMnvZcz3b8n1dMnvdMnvZcz3Zcz3Zcz3dMnvb8n1
d8v1acz3mIZ/mIZ/mIZ/2szKmIZ/dsnvdMnvb8n1dMnveMnvZcz3mIZ/mIZ/
3dfamIZ/m9LrdMnvZcz3dMnvdMnvdMnvdMnvb8n1dMnvmIZ/mIZ///fX//fX
//fX//fX//fX//fX/vbWx7mnmIZ/mIZ/dMnvZcz3dMnvdMnvZcz3dMnvZcz3
dMnvdMnvdMnvdMnvb8n1dMnvb8n1b8n1b8n1dMnvZcz3a8vwdMnvdMnvb8n1
a8vwdMnvdMnvdMnvdMnvb8n1a8vwb8n1dMnva8vwb8n1dMnvb8n1dMnvdMnv
dMnvZcz3a8vwZcz3b8n1b8n1dMnvdMnvdMnvdMnvdMnva8vwdMnva8vwa8vw
b8n1a8vwdMnvb8n1dMnva8vwdMnvZcz3dMnvdMnvdMnvdMnvdMnvdMnvb8n1
b8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvZcz3dMnvdMnvdMnvdMnvdMnv
a8vwdMnvb8n1dMnvdMnvdMnvdMnvZcz3dMnvb8n1b8n1a8vwdMnvdMnvdMnv
b8n1dMnvb8n1a8vwdMnvb8n1dMnvdMnvdMnvb8n1Zcz3b8n1b8n1b8n1b8n1
dMnvdMnvdMnvdMnvZcz3b8n1dMnvdMnva8vwb8n1b8n1b8n1Zcz3b8n1a8vw
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvWKjHAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAasDqdMnvdMnvdMnvdMnvX6bGmIZ/iHhxAAAA
AAAA2824mIZ/dMnva8vwdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnv
dMnvb8n1dMnva8vwdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnva8vwb8n1dMnv
a8vwb8n1b8n1dMnvb8n1a8vwdMnvdMnvdMnvZcz3dMnvdMnvdMnvdMnvdMnv
dsnvmIZ/mIZ/mIZ/7t/I2szKmIZ/cc3wa8vwdMnvb8n1fcvzmIZ/mIZ/mIZ/
2szKmIZ/eMnvb8n1dMnvb8n1b8n1a8vwZcz3dMnvmIZ/mIZ///fX//fX//fX
//fX//fX//fX//fX//fX//fX3tO7mYeAmIZ/dMnvdMnvb8n1dMnvb8n1dMnv
Zcz3b8n1dMnvZcz3dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnv
dMnvb8n1a8vwb8n1b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1b8n1
Zcz3dMnvdMnvdMnvdMnva8vwZcz3dMnvdMnvdMnvZcz3b8n1b8n1dMnvdMnv
a8vwdMnvdMnvdMnvb8n1b8n1Zcz3dMnvb8n1Zcz3Zcz3b8n1b8n1b8n1dMnv
a8vwZcz3a8vwb8n1a8vwdMnvZcz3b8n1a8vwdMnvdMnvdMnvb8n1b8n1b8n1
dMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvb8n1dMnvdMnvb8n1a8vwb8n1Zcz3
dMnvdMnvdMnvdMnvdMnvb8n1b8n1b8n1a8vwdMnvdMnvdMnvdMnvdMnvb8n1
b8n1a8vwb8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnva8vw
dMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1b8n1P3aRAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAXaTDdMnvdMnvb8n1dcv1O2uDkYB5eWpkAAAA
AAAAsaaUmIZ/dMnvdMnvb8n1Zcz3dMnvdMnvdMnvdMnva8vwb8n1b8n1dMnv
dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1b8n1dMnvb8n1b8n1dMnvdMnvb8n1
dMnva8vwdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvb8n1b8n1b8n1
ccn1mIZ/mIZ/mIZ/7t/I2szKmIZ/ccn1ccn1dMnvmIZ/mIZ/mIZ/mIZ/2szK
3dfamIZ/dMnvb8n1f8vtdMnvb8n1dMnvdMnvmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/dMnvb8n1dMnvdMnvdMnv
dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvdMnv
dMnvb8n1dMnvdMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnv
b8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1
dMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1Zcz3dMnvb8n1dMnvdMnvdMnv
b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1a8vwdMnvdMnvdMnvdMnv
a8vwdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnv
b8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1dMnvcsXqDyIrAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAO3CKb8n1b8n1fsvviHhxBAMDhnZwjoV3AAAA
AAAAe3Nm7t/ImIZ/b8n1dMnvdMnvb8n1b8n1b8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnv
a8vwdMnvb8n1b8n1b8n1b8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnv
mIZ/mIZ/7t/I7t/I7t/I2szKmIZ/s9nnesvvj9DxmIZ/mIZ/mIZ/7t/I3dfa
3dfamIZ/dMnvdMnvdMnvdMnvdMnvdMnvmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXtqeZmIZ/mIZ/dMnvb8n1b8n1dMnv
dMnvb8n1b8n1dMnva8vwb8n1b8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnv
dMnvdMnvdMnvb8n1dMnvdMnvdMnva8vwdMnvb8n1b8n1dMnvb8n1a8vwdMnv
dMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1
b8n1dMnva8vwdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnva8vwa8vwdMnv
dMnvdMnva8vwb8n1dMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnv
b8n1Zcz3dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1
dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1b8n1b8n1dMnvdMnv
b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1b8n1dMnvb8n1b8n1dMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvYrPbAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAXaPCdMnva7faNy8tAAAAuq6cGhcUAAAA
AAAAOTQu7d7H7t/ImIZ/dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvfsvvmIZ/
mIZ/7t/I//fX//fX//fX3dfamIZ/mIZ/jM/tmIZ/mIZ/mIZ/7t/I7t/I3dfa
3dfamIZ/dsnvb8n1ccn1dMnvmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXp5aLmIZ/mIZ/dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvb8n1dMnv
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1b8n1dMnvb8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnv
dMnvfMbub8n1b8n1dMnvdMnvdMnvb8n1b8n1b8n1b8n1b8n1b8n1dMnvb8n1
dMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnv
dMnvb8n1dMnvb8n1dMnvb8n1b8n1dMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvfMbub8n1dMnvdMnvdMnvdMnvdMnv
dMnvb8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnvfMbudMnv
b8n1dMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvb8n1b8n1W5++AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAggMNGBzCAYFAAAAAAAAJyQfAAAAAAAA
AAAAAAAA4tS+7t/ImIZ/dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1b8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvb8n1dMnvmIZ/mIZ/
7t/I//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX3dfa
3dfamIZ/b8n1dMnvf8vtb8n1mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX59zCqZiNmIZ/b8n1b8n1dMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1
dMnvb8n1dMnvb8n1b8n1b8n1b8n1fMbub8n1dMnvdMnvdMnvb8n1b8n1dMnv
b8n1dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnv
b8n1b8n1dMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnv
dMnvb8n1dMnvb8n1fMbudMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnv
fMbudMnvdMnvdMnvb8n1a8vwdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1
fMbudMnvb8n1b8n1dMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvb8n1fMbub8n1
fMbudMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvfMbudMnvUpi6AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA3c+57t/ImIZ/u8HKdMnvb8n1b8n1dMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1
b8n1dMnvb8n1b8n1dMnvdMnvdMnvfMbub8n1dMnvdMnvb8n1mIZ/mIZ/mIZ/
7t/I//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/7t/I7t/I7t/I//fX//fX3dfa
3dfamIZ/dMnvdMnvp9bpmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbW7ePHmIZ/mIZ/dMnvb8n1
dMnvdMnvfMbub8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvb8n1dMnvdMnvb8n1dMnvb8n1fMbudMnvb8n1b8n1dMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1
fMbufMbudMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnv
dMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvfMbufMbudMnvdMnvdMnvdMnvdMnv
dMnvdMnvfMbudMnvdMnvfMbudMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnv
dMnvfMbub8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvYJWvAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA3tC67t/ImIZ/mIZ/dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvfMbu
b8n1fMbub8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1b8n1gcbodMnvfMbufMbu
dMnvb8n1fMbudMnvb8n1dMnvb8n1b8n1dMnvb8n1dMnvmIZ/mIZ/mIZ/7uPf
//////fX//fX3dfa3dfa3dfamIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX3dfa
3dfamIZ/js/tmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXu5SNmYZ///fX+/LTwLKhmIZ/b8n1dMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvfMbufMbudMnv
b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvb8n1b8n1dMnvdMnvdMnvb8n1fMbudMnvb8n1dMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvdMnvdMnvfMbub8n1dMnvfMbub8n1b8n1b8n1fMbub8n1dMnvdMnv
dMnvdMnvdMnvb8n1b8n1b8n1b8n1dMnvdMnvb8n1b8n1dMnvdMnvfMbudMnv
b8n1dMnvdMnvdMnvfMbub8n1b8n1dMnvb8n1dMnvdMnvb8n1dMnvdMnvfMbu
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1XqXFAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAADQwJ+vLT7t/I7t/ImIZ/mIZ/fMbufMbufMbudMnvdMnvb8n1dMnvdMnv
a8vwdMnvb8n1dMnvdMnvdMnvb8n1dMnvfMbumIZ/mIZ/fMbudMnvdMnvfMbu
dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvgcbob8n1mIZ/mIZ/mIZ/7uPf7uPf
////////3dfa3dfa3dfamIZ/7t/I7uPf//fX//fX//fX//fX//fX//fX3dfa
z8fImIZ/mIZ/mIZ/9PLa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXtZGLoImC1p6Y//fX//fXmIZ/mIZ/dMnv
dMnvdMnvdMnvdMnvdMnvb8n1fMbufMbub8n1fMbudMnvb8n1b8n1fMbudMnv
dMnvdMnvfMbub8n1fMbudMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1b8n1b8n1dMnv
dMnvfMbudMnvb8n1b8n1dMnvdMnvdMnvgcbob8n1dMnvfMbudMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvgcbob8n1dMnvdMnvdMnvb8n1
dMnvdMnvfMbub8n1gcbodMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
fMbudMnvdMnvgcbodMnvdMnvdMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnv
fMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvfMbudMnva7rdAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAdXFh//fX//fX7t/I7t/ImIZ/mIZ/dMnvb8n1dMnvdMnvfMbub8n1dMnv
fMbudMnvfMbub8n1fMbub8n1dMnvdMnvmIZ/mIZ/mIZ/mIZ/is/xdMnvdMnv
dMnvb8n1dMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvmIZ/mIZ/xbSl7uPf////
////////3dfamIZ/mIZ/7uPf7uPf7uPf//fX//fX//fX//fX//fX3dfa3dfa
zsXGmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXqYyGmIZ///fX//fXmIZ/mIZ/b8n1
b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvdMnvgcbodMnvdMnv
dMnvdMnvb8n1fMbub8n1dMnvb8n1fMbudMnvfMbudMnvb8n1dMnvdMnvdMnv
dMnvfMbub8n1dMnvdMnvdMnvdMnvfMbufMbub8n1fMbugcbodMnvdMnvb8n1
dMnvdMnvfMbudMnvdMnvfMbub8n1b8n1dMnvdMnvfMbub8n1fMbudMnvb8n1
dMnvb8n1dMnvdMnvfMbudMnvdMnvfMbua8vwb8n1dMnvdMnvdMnvdMnvfMbu
fMbufMbudMnvdMnva8vwb8n1b8n1dMnvdMnvdMnvdMnvfMbudMnvdMnvdMnv
dMnvb8n1a8vwdMnvdMnvfMbub8n1dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbufMbudMnvfMbudMnvb8n1b8n1dMnvdMnv
b8n1fMbudMnvb8n1fMbufMbub8n1b8n1dMnvdMnvdMnvb8n1MlVoAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAubOb//fX//fX7t/I7t/I7t/ImIZ/mIZ/dMnvdMnvdMnvdMnvdMnvdMnv
fMbudMnvdMnvdMnvgcbodMnvfcvzeMnvmIZ/7t/I7t/ImIZ/mIZ/f8vtfMvv
dMnvfMbudMnvdMnvfMbufMbudMnvb8n1fMbudMnvmIZ/taSY7t/I//////fX
////3dfamIZ/mIZ/7t/I7uPf7uPf//////////fX//fX//fX//fX3dfa3dfa
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXw7WkmIZ/1p6Y//fXs6SWmIZ/mIZ/
dMnvdMnvdMnvfMbudMnvdMnvfMbudMnvdMnvdMnvfMbua8vwdMnvb8n1b8n1
b8n1dMnvdMnvgcbob8n1fMbudMnvdMnvdMnvdMnvdMnvdMnvfMbufMbufMbu
dMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvfMbufMbugcbodMnv
dMnvdMnvdMnvfMbudMnvgcbodMnvb8n1fMbudMnvdMnvb8n1fMbufMbudMnv
gcbofMbub8n1dMnvdMnvfMbugcbodMnvdMnvfMbufMbudMnvdMnvdMnvdMnv
dMnvb8n1dMnvfMbufMbudMnvdMnvb8n1fMbudMnvdMnvdMnvdMnvb8n1dMnv
fMbudMnvfMbudMnvdMnvdMnvdMnvdMnvfMbufMbub8n1b8n1b8n1b8n1dMnv
fMbub8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvfMbugcbodMnvb8n1
fMbudMnvfMbudMnvb8n1dMnvdMnvgcbodMnvdMnvb8n1dMnvXaPCAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
MjAo8uvM//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/fMbudMnvdMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvfMbufMbumIZ/mIZ/7t/I7t/ImIZ/mIZ/ccn1fMbu
fMbudMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvmIZ/mIZ/y7ur7t/I//////fX
//fX3dfamIZ/mIZ/7uPf7uPf//fX//////////////fX//fX3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXnIuDmIZ/1p6Y1p6YmIZ/mIZ/
fMbufMbudMnvdMnvfMbub8n1dMnvdMnvdMnvfMbudMnvfMbub8n1fMbufMbu
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbufMbudMnvdMnvdMnvb8n1
dMnvdMnvgcbofMbudMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvb8n1
dMnvdMnvfMbudMnvdMnvdMnvdMnvgcbob8n1fMbub8n1dMnvfMbufMbudMnv
fMbudMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnvfMbufMbufMbufMbub8n1
gcbofMbufMbufMbudMnvdMnvdMnvdMnvdMnvfMbugcboa8vwdMnvdMnvgcbo
b8n1dMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnve8XtOmh9AAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
v7mh//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/dMnvfMbufMbudMnvdMnv
fMbufMbub8n1b8n1dMnvdMnvmIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/mIZ/dMnv
ccn1fMbufMbub8n1b8n1dMnvdMnvdMnvdMnvmIZ/mIZ/7t/I7t/I//fX//fX
//fXmIZ/mIZ/7t/I7uPf//////////////////////fX//fX3dfamIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXp5aLmIZ/1p6Y1p6YmIZ/mIZ/
b8n1fMbudMnvfMbudMnvfMbub8n1fMbub8n1dMnvdMnvdMnvdMnvfMbudMnv
fMbudMnvb8n1fMbudMnvfMbufMbudMnvdMnvdMnvb8n1fMbudMnvgcbodMnv
fMbudMnvdMnvfMbufMbub8n1dMnvfMbufMbugcbob8n1dMnvb8n1fMbudMnv
dMnvdMnvdMnvdMnvb8n1fMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1
b8n1fMbudMnvfMbudMnvb8n1fMbudMnvdMnvb8n1dMnvfMbufMbufMbudMnv
dMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbudMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbudMnvb8n1dMnvgcbodMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbufMbudMnvdMnvdMnvfMbufMbufMbudMnv
dMnvb8n1gcbodMnvb8n1fMbub8n1fMbufMbudMnvfMbufMbudMnvdr3jK0lZ
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmZSA
/vbW//fX//fX//fX//fX7t/I//fX7t/I7t/ImIZ/mIZ/dMnvdMnvfMbudMnv
a8vwfMbudMnvgcbodMnvmIZ/mIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/
j8rmdMnvdMnvgcbogcbodMnvfMbudMnvfMbumIZ/wrSj7t/I7t/I//fX//fX
//fXmIZ/mIZ/7t/I7uPf//////fX//fX////////3dfa3dfa3dfamIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXq5uPmIZ/1p6Y1p6YmIeBmIZ/
dMnvb8n1fMbufMbufMbudMnvgcbodMnvdMnvfMbub8n1fMbudMnvgcbofMbu
dMnvdMnvdMnvfMbufMbua8vwfMbub8n1fMbufMbufMbudMnvb8n1fMbub8n1
dMnvb8n1dMnvb8n1dMnvgcbofMbudMnvdMnvdMnvdMnvb8n1gcbodMnvfMbu
dMnvdMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvfMbufMbub8n1dMnvfMbudMnv
fMbudMnvfMbub8n1dMnvdMnvdMnvfMbub8n1fMbub8n1dMnva8vwfMbufMbu
fMbudMnvb8n1dMnvfMbub8n1b8n1dMnvdMnvfMbufMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvfMbudMnvdMnvfMbugcbofMbudMnvdMnvfMbudMnvfMbub8n1
dMnvdMnvdMnvfMbudMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvb8n1fMbu
gcbodMnvdMnvfMbudMnvgcbodMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvbr/j
OV90AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApqCL/PTV
//fX//fX//fX//fX//fX//fX7t/I//fX7t/I7t/ImIZ/fMbufMbudMnvfMbu
dMnvfMbudMnvdMnvdMnvmIZ/mIZ/7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/
fsbudMnvdMnvdMnvfMbudMnvfMbudMnvdMnvmIZ/wrSj7t/I7t/I//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fX//fX////3dfa3dfamIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6YsZCJmIZ/
mIZ/dMnvfMbua8vwdMnvfMbudMnvdMnvfMbufMbudMnvdMnvfMbua8vwdMnv
fMbufMbufMbua8vwfMbudMnvdMnvfMbua8vwgcbofMbua8vwfMbufMbufMbu
gcbofMbugcbob8n1fMbudMnvdMnvdMnvfMbufMbufMbudMnvb8n1b8n1fMbu
fMbufMbufMbufMbudMnvfMbufMbufMbufMbudMnvfMbufMbudMnvdMnvdMnv
dMnvdMnvgcbodMnvfMbudMnvfMbugcbodMnvgcbodMnvfMbufMbua8vwdMnv
dMnvfMbufMbudMnvfMbufMbufMbufMbudMnvdMnvfMbudMnvb8n1fMbudMnv
fMbufMbub8n1fMbufMbudMnvdMnvdMnvfMbub8n1dMnvdMnvfMbudMnvgcbo
dMnvfMbufMbudMnvfMbudMnvdMnvgcbodMnvdMnvfMbudMnvdMnvfMbudMnv
dMnvdMnvdMnvgcbodMnvdMnvdMnvgcbofMbudMnvfMbufMbufMbudMnvdMnv
c8jtV5m2ID5LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZmNV1c6z//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/fMbufMbudMnv
dMnvgcbofMbufMbumIZ/p5aL7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/
mIZ/nM/qic3tg83tdMnvdMnvb8n1dMnveMnvmIZ/wbOi7t/I7t/I//fX//fX
//fXmIZ/3M257t/I//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6YmIZ/
mIZ/fMbudMnvfMbufMbua8vwfMbufMbudMnvgcbodMnvfMbufMbugcbofMbu
dMnvdMnvfMbudMnvfMbub8n1fMbufMbufMbufMbudMnvfMbua8vwgcbodMnv
dMnvdMnvdMnvfMbudMnvdMnvfMbufMbudMnva8vwgcbodMnvfMbugcbob8n1
dMnvdMnvgcbofMbudMnvdMnvdMnvgcbodMnvdMnvgcbodMnvb8n1fMbufMbu
fMbudMnvdMnvfMbudMnvfMbua8vwfMbudMnva8vwfMbudMnvgcbofMbufMbu
dMnvgcbofMbudMnvdMnvdMnvdMnvdMnvfMbufMbudMnvfMbufMbudMnvfMbu
dMnvfMbudMnvdMnvfMbudMnvfMbudMnvfMbufMbufMbufMbudMnvfMbudMnv
dMnvdMnvfMbudMnvfMbudMnvdMnvfMbufMbudMnvfMbufMbugcbodMnvdMnv
fMbufMbudMnvfMbufMbub8n1fMbudMnvfMbufMbudMnvfMbudMnvfMbufMbu
fMbudMnvcsXrZaLDRHmRQDg0IBsZNjIsa2RZpqCL2tO3/fXV//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/lMzsfMbu
a8vwdMnvdMnvmIZ/m4qDyrqp7t/I7t/I//fX//fX//fX//fX//fX//fX7t/I
7t/ImIZ/gcvtfsbufsbug8bopNHqfMbufMbumIZ/wLKi7t/I//fX//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fX//fX3dfamIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6YmIZ/
mIZ/a8vwdMnvfMbufMbufMbudMnvfMbudMnvfMbudMnva8vwdMnvdMnvb8n1
gcboa8vwfMbudMnvgcbodMnvdMnvfMbua8vwfMbufMbufMbudMnvfMbudMnv
b8n1fMbugcbofMbufMbub8n1fMbudMnvgcbodMnvdMnvgcbodMnvfMbub8n1
b8n1dMnva8vwfMbudMnvfMbudMnvdMnvfMbudMnvfMbugcbodMnvdMnvdMnv
fMbudMnvfMbudMnvfMbugcbodMnvfMbufMbudMnvdMnvfMbua8vwdMnvfMbu
fMbua8vwfMbufMbudMnvfMbub8n1fMbub8n1fMbudMnvdMnvdMnvdMnvdMnv
fMbugcbodMnvfMbudMnvfMbudMnvdMnvgcbogcbofMbudMnvfMbudMnvfMbu
fMbudMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvfMbudMnvdMnvdMnvfMbufMbu
b8n1dMnvb8n1fMbudMnvgcbodMnvfMbudMnvfMbub8n1gcbofMbudMnvdMnv
dMnvfMbub8n1dMnvfMbumIZ/pZOK7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/esvv
fMbufMbudMnvmIZ/u6ufzb2s7t/I//fX//fX//fX//fX//fX//fX//fX7t/I
7t/ImIZ/mIZ/mIZ/fsvvdMnvdMnvk8vmdsnvmIZ/wbOi7t/I//fX//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/fMbufMbudMnvdMnva8vwfMbufMbufMbufMbufMbufMbufMbufMbufMbu
dMnvfMbudMnvfMbufMbufMbufMbufMbufMbua8vwgcbodMnvfMbudMnvfMbu
gcbodMnvdMnvdMnvfMbugcbodMnvfMbudMnvfMbufMbudMnvdMnvdMnvfMbu
gcbodMnvfMbudMnvfMbudMnvfMbufMbudMnvdMnvdMnvfMbugcbofMbufMbu
fMbufMbudMnvfMbudMnvfMbudMnvdMnvfMbub8n1b8n1dMnvfMbufMbudMnv
dMnvfMbudMnvfMbufMbufMbugcbodMnvgcbodMnvfMbufMbufMbudMnvfMbu
dMnvfMbudMnvfMbufMbufMbudMnvfMbudMnvgcbodMnvdMnvdMnvfMbufMbu
fMbufMbufMbufMbufMbufMbufMbufMbufMbufMbufMbudMnvdMnvdMnvgcbo
fMbugcbodMnvdMnvfMbufMbufMbufMbudMnvgcbofMbudMnvfMbufMbufMbu
gcbogcbofMbufMbufMbumIZ/t6aZ7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I4dXGmIZ/
eMnvkMzsmIZ/n4+Kzr2t7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/IpJOJnYuDmYeAmIZ/mIZ/mIZ/mIZ/t6ia7t/I7t/I//fX//fX
//fX3dfa7t/I7t/I//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/dMnvfMbufMbufMbugcboa8vwdMnvdMnvdMnvgcbodMnvdMnvgcbofMbu
fMbufMbufMbua8vwdMnvdMnvdMnvfMbufMbudMnvfMbudMnvfMbudMnvfMbu
fMbufMbufMbudMnvfMbudMnvfMbudMnvfMbudMnvb8n1fMbugcbogcbofMbu
fMbugcbofMbudMnvdMnvfMbudMnvfMbufMbufMbudMnvfMbudMnvfMbudMnv
dMnvfMbufMbudMnvdMnvfMbufMbudMnvfMbugcbofMbudMnvdMnvfMbub8n1
fMbufMbugcbogcbodMnvfMbudMnvfMbudMnvgcbodMnvdMnvfMbudMnvfMbu
dMnvdMnvfMbufMbudMnvfMbufMbudMnvdMnvfMbudMnvfMbufMbudMnvgcbo
dMnvdMnvdMnvfMbudMnvfMbufMbudMnvdMnvdMnvdMnvfMbufMbufMbufMbu
dMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvgcbodMnvdMnv
dMnvdMnvdMnvdMnvkpynmIZ/wrKj7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7d7HmIZ/
mIZ/esvvmIZ/qqGh7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/IvK2dtqWY7t/IsaCUoY+GmIZ/pJOJ7t/I7t/I//fX//fX
//fX//fX7t/I7t/I//fX//fX3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/dMnvgcbodMnvdMnvfMbufMbufMbudMnvfMbudMnvdMnvfMbudMnv
gcbodMnvdMnvfMbufMbufMbudMnvgcbodMnvfMbugcbofMbudMnvfMbudMnv
dMnvdMnvdMnvfMbudMnvfMbudMnvfMbudMnvfMbugcbodMnvdMnvdMnvdMnv
dMnvdMnvfMbufMbufMbudMnvfMbudMnvdMnvfMbudMnvdMnvfMbudMnvfMbu
dMnvgcbogcbofMbudMnvdMnvdMnvfMbugcbodMnvdMnvfMbufMbudMnvgcbo
dMnvdMnvdMnvfMbudMnvdMnvfMbudMnvfMbudMnvfMbufMbudMnvfMbugcbo
fMbudMnvdMnvfMbudMnvfMbudMnvfMbudMnvfMbufMbufMbudMnvdMnvfMbu
fMbufMbufMbufMbudMnvdMnvfMbufMbufMbufMbufMbudMnvdMnvdMnvfMbu
fMbudMnvfMbudMnvfMbufMbufMbufMbudMnvfMbufMbufMbufMbufMbufMbu
fMbufMbufMbudMnvkZyomIZ/ybmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/mIZ/rpyR7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/7t/I7t/I//fX//fX
//fX//fX//fX7t/I//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/dMnvfMbufMbugcbodMnvdMnvfMbudMnvfMbufMbudMnvdMnvfMbu
dMnvfMbufMbudMnvdMnvfMbufMbudMnvfMbudMnvdMnvfMbufMbufMbufMbu
dMnvfMbugcbodMnvdMnvfMbufMbufMbufMbufMbufMbudMnvdMnvfMbufMbu
fMbudMnvgcbodMnvfMbufMbufMbufMbugcbofMbufMbudMnvfMbudMnvfMbu
dMnvdMnvgcbofMbufMbudMnvdMnvdMnvfMbufMbudMnvdMnvfMbufMbufMbu
fMbudMnvdMnvfMbufMbudMnvfMbufMbufMbugcbofMbufMbudMnvdMnvfMbu
fMbufMbufMbudMnvfMbufMbufMbudMnvfMbufMbugcbodMnvfMbufMbufMbu
fMbufMbudMnvgcbofMbufMbudMnvdMnvfMbugcbodMnvfMbufMbufMbugcbo
dMnvfMbufMbufMbudMnvgcbogcbodMnvfMbudMnvdMnvdMnvdMnvgcbodMnv
fMbufMbugcbofMbuj52pmIZ/yrmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
3dfamIZ/zLyr7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/7t/I7t/I//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/fMbugcbodMnvdMnvfMbufMbugcbofMbudMnvfMbufMbufMbudMnv
dMnvgcbogcbofMbufMbugcbodMnvfMbudMnvfMbufMbugcbodMnvdMnvfMbu
fMbudMnvdMnvfMbufMbudMnvdMnvfMbudMnvdMnvfMbufMbufMbufMbufMbu
fMbufMbudMnvfMbugcbogcbodMnvdMnvdMnvdMnvdMnvfMbufMbufMbugcbo
fMbufMbudMnvfMbufMbufMbufMbufMbufMbudMnvfMbufMbugcbofMbugcbo
fMbufMbufMbugcbofMbufMbudMnvgcbofMbudMnvdMnvgcbofMbufMbudMnv
gcbogcbofMbugcbogcbofMbufMbugcbofMbudMnvfMbugcbofMbugcbofMbu
fMbufMbudMnvgcbogcbofMbufMbugcbofMbufMbugcbofMbufMbufMbufMbu
fMbugcbogcbofMbudMnvdMnvfMbufMbufMbufMbufMbufMbudMnvfMbugcbo
gcbodMnvfMbufMbugcbomIZ/yrqp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mIZ/qZiO7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/xbWl7t/I//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/esHifMbufMbufMbugcbofMbudMnvfMbugcbofMbugcbofMbufMbu
dMnvdMnvgcbogcbodMnvfMbugcbofMbufMbufMbudMnvfMbufMbudMnvfMbu
fMbufMbufMbufMbugcbofMbugcbofMbufMbudMnvfMbugcbogcbofMbugcbo
gcbofMbufMbudMnvdMnvfMbufMbufMbufMbufMbugcbogcbogcbodMnvfMbu
dMnvfMbufMbugcbogcbofMbufMbugcbogcbofMbugcbodMnvdMnvdMnvgcbo
fMbufMbudMnvgcbogcbogcbodMnvdMnvfMbugcbodMnvfMbudMnvfMbufMbu
fMbufMbugcbodMnvdMnvgcbogcbodMnvgcbofMbufMbufMbudMnvfMbudMnv
gcbogcbofMbufMbufMbugcbogcbodMnvdMnvgcbofMbugcbogcbodMnvgcbo
gcbodMnvfMbugcbofMbufMbugcbogcbogcbogcbogcbogcbofMbufMbudMnv
dMnvfMbugcbogcbodMnvmIZ/yrqp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mYeAzLyr7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IxLel7t/I//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7uTImIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/gb7hfMbugcbogcbodMnvdMnvfMbugcbofMbugcbodMnvfMbugcbo
fMbufMbudMnvfMbufMbugcbodMnvgcbogcbodMnvfMbugcbogcbofMbugcbo
fMbufMbufMbugcbofMbufMbudMnvgcbofMbufMbugcbofMbufMbugcbodMnv
fMbufMbugcbofMbufMbugcbogcbofMbugcbofMbufMbudMnvdMnvfMbufMbu
fMbufMbugcbodMnvfMbugcbogcbofMbufMbugcbodMnvfMbufMbufMbudMnv
fMbugcbofMbudMnvfMbufMbufMbugcbofMbufMbufMbugcbofMbugcbofMbu
fMbufMbufMbufMbudMnvfMbufMbudMnvfMbugcbofMbugcbodMnvfMbudMnv
fMbufMbugcbodMnvfMbufMbufMbufMbufMbugcbofMbudMnvfMbufMbufMbu
fMbufMbufMbufMbufMbufMbudMnvfMbufMbudMnvfMbufMbugcbofMbufMbu
fMbudMnvfMbufMbugcbomIZ/ybmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
qJaMzr6t7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I//fX//fX//fX
//fX//fX//fXmIZ/nIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFmIZ/mIZ/1p6Y1p6Y1p6Y
noiBmIZ/hrzZfMbudMnvfMbufMbugcbofMbufMbudMnvfMbugcbofMbufMbu
fMbufMbugcbofMbufMbufMbufMbudMnvgcbofMbufMbufMbugcbodMnvgcbo
gcbogcbodMnvfMbugcbofMbufMbugcbogcbodMnvfMbufMbufMbufMbufMbu
fMbudMnvfMbufMbufMbufMbugcbofMbugcbofMbufMbufMbufMbugcbofMbu
fMbudMnvfMbugcbodMnvdMnvfMbufMbudMnvfMbufMbugcbofMbufMbugcbo
dMnvfMbufMbudMnvfMbufMbufMbugcbofMbugcbofMbugcbofMbugcbofMbu
gcbofMbugcbogcbogcbogcbogcbofMbugcbofMbugcbofMbufMbugcbofMbu
gcbogcbodMnvgcbogcbogcbogcbogcbogcbodMnvfMbufMbugcbogcbogcbo
fMbugcbogcbogcbogcbofMbufMbudMnvfMbufMbugcbogcbofMbufMbufMbu
gcbofMbufMbugcbofMbumIZ/yrmp7t/I//fX//fX//fX//fX//fX3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
yLen7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXxLalmIZ/sqSh3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
sI+JmIZ/g7rbgcbofMbugcbogcbofMbugcbogcbofMbugcbofMbugcbogcbo
gcbofMbudMnvgcbofMbugcbofMbufMbufMbugcbofMbugcbofMbufMbudMnv
fMbudMnvfMbugcbofMbugcbofMbudMnvfMbufMbugcbogcbodMnvgcbofMbu
gcbofMbufMbugcbofMbufMbufMbufMbufMbugcbofMbugcbogcbodMnvgcbo
gcbofMbugcbofMbufMbufMbugcbogcbofMbufMbugcbofMbugcbofMbufMbu
fMbugcbogcbogcbogcbogcbogcbofMbugcbofMbugcbofMbufMbudMnvgcbo
gcbofMbufMbufMbudMnvfMbugcbofMbugcbodMnvgcbogcbofMbugcbofMbu
dMnvgcbofMbufMbufMbufMbufMbudMnvfMbugcbogcbofMbufMbudMnvgcbo
fMbufMbufMbufMbugcbogcbogcbogcbogcbodMnvfMbufMbugcbogcbofMbu
gcbogcbofMbudMnvgcbomIZ/yrqp7t/I//fX//fX//fX//fX3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfazsXG3dfam4mB
zr6t7uPf//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7OXZ//fX3dfa//fX//fX//fX
//fX//fXxrmnmIZ/saGUtqeZmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
o5KImIZ/grzegcbofMbufMbugcbofMbufMbugcbofMbugcbofMbufMbufMbu
gcbofMbufMbugcbofMbugcbogcbogcbofMbugcbofMbugcbogcbogcbogcbo
gcbogcbodMnvgcbofMbugcbogcbogcbogcbodMnvdMnvgcbofMbugcbofMbu
gcbogcbofMbugcbogcbogcbogcbofMbudMnvgcbofMbufMbugcbofMbufMbu
gcbofMbugcbogcbogcbodMnvfMbugcbogcbofMbufMbufMbugcbogcbogcbo
fMbufMbufMbufMbufMbufMbufMbudMnvgcbodMnvfMbugcbofMbufMbufMbu
fMbugcbogcbogcbofMbugcbofMbugcbofMbufMbufMbufMbugcbofMbugcbo
gcbofMbugcbogcbogcbogcbogcbogcbogcbofMbufMbugcbogcbogcbofMbu
gcbogcbogcbogcbofMbufMbufMbufMbufMbufMbugcbogcbofMbufMbugcbo
fMbufMbugcbogcbofMbumIZ/y7qq7t/I//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/t6aa
3M25//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6ePZ3dfa3dfa//fX//fX//fX
//fX//fXx7mnmIZ/mIZ/mIZ/mIZ/mIZ///fX//fXt6iZnIuDmIZ/mIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/hb3afMbugcbogcbofMbugcbogcbofMbugcbofMbugcbogcbogcbo
fMbugcbogcbofMbugcbodMnvfMbufMbugcbofMbugcbofMbufMbufMbufMbu
fMbufMbugcbofMbugcbodMnvfMbufMbufMbugcbofMbufMbugcbofMbugcbo
fMbufMbugcbofMbufMbufMbufMbugcbogcbofMbugcbogcbofMbugcbogcbo
fMbugcbofMbufMbufMbugcbogcbofMbufMbugcbogcbogcbofMbufMbufMbu
gcbogcbogcbogcbogcbogcbogcbogcbofMbugcbogcbofMbugcbogcbogcbo
fMbufMbuiMTogcbofMbugcbofMbugcbogcbogcboiMTofMbugcbofMbuiMTo
fMbufMbudMnvfMbufMbufMbufMbufMbugcbogcboiMTofMbufMbugcbofMbu
fMbufMbufMbugcbogcbogcbogcbogcbogcbofMbufMbugcbogcbofMbugcbo
gcbofMbufMbugcbogcbomIZ/vq6g7t/I//fX3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ///fXmIZ/nIqCzL+5
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX5N7Z3dfa3dfa3dfa//fX//fX
//fX//fXsaGUmIZ/mIZ/mIZ///fX//fX//fX//fX//fX1Miy//fXp5aMmIZ/
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/1p6Y1p6Y1p6Y1p6Y
mIZ/mIZ/hb7cfMbufMbugcbofMbufMbugcbogcbogcbofMbufMbufMbugcbo
fMbufMbugcbofMbugcbogcbogcbogcbogcbofMbugcbogcbogcbogcbogcbo
gcbofMbugcbofMbugcbogcbogcbogcbofMbugcbogcbodMnvgcbofMbugcbo
gcbofMbugcbogcbogcbogcbofMbufMbugcbofMbufMbugcbofMbufMbugcbo
fMbugcbogcbogcbofMbufMbugcbogcbofMbufMbufMbugcbogcbogcbofMbu
fMbufMbufMbufMbufMbufMbufMbugcbofMbufMbugcbofMbugcbofMbufMbu
gcbogcbofMbufMbuiMTofMbugcbofMbufMbufMbufMbugcbofMbugcbofMbu
gcboiMToiMTogcbogcboiMTogcbogcbofMbuiMTofMbufMbugcboiMTogcbo
gcbogcbogcbofMbufMbufMbufMbufMbuiMTogcbogcbofMbufMbugcbofMbu
fMbugcbogcbofMbufMbumIZ/n42F7t/I3dfa3dfa3dfa3dfa3dfamIZ/nIqC
qpqPsaGUtqeZ//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fXmIZ/tKOX0sXA
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX39na3dfa3dfa3dfa//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX0sWw
xLelp5eMmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/wI6I1p6Y1p6Y1p6Y
mIZ/mIZ/gb7hgcbogcbofMbugcbogcboiMTofMbufMbugcbogcbogcbofMbu
gcbogcbofMbugcbofMbuiMTofMbufMbufMbugcbofMbufMbufMbufMbufMbu
fMbugcbofMbugcbofMbufMbufMbuiMTogcbogcbofMbugcbofMbugcbofMbu
fMbugcbofMbufMbufMbufMbuiMTogcbofMbuiMTogcbofMbugcbogcbofMbu
gcbofMbufMbufMbugcbogcbofMbufMbugcbogcbogcbofMbufMbufMbugcbo
gcbogcbogcbogcbogcbogcboiMTofMbugcbogcbofMbugcbodMnvgcbogcbo
fMbufMbuiMTofMbugcbofMbugcbogcbogcbogcbofMbugcbofMbufMbufMbu
fMbufMbufMbufMbufMbufMbufMbugcbofMbufMbugcbofMbufMbufMbufMbu
fMbufMbugcboiMTogcbogcboiMTofMbufMbufMbugcboiMTofMbugcbogcbo
fMbufMbugcbogcboiMTomIZ/7t/I2szK3dfa3dfa3dfamIZ/oI+Gq5uPs6OW
vrCfyr2q//fX//fX//fX//fXmIZ///fX//fX//fX//fX7OLHmIZ/vaye59vX
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX2c22zsGtn46FmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6I1p6Y1p6Y1p6Y
mIZ/mIZ/grzffMbugcbofMbufMbufMbugcbogcbofMbufMbufMbuiMTofMbu
fMbugcbofMbugcbofMbuiMTogcbogcbofMbugcbogcbogcbogcbogcbogcbo
iMTogcbofMbuiMToiMTogcbofMbufMbuiMToiMToiMTogcbofMbugcbogcbo
fMbugcbogcbogcbogcbofMbufMbugcbofMbufMbufMbufMbufMbuiMToiMTo
fMbugcbogcboiMTofMbugcbogcbofMbufMbufMbugcbogcboiMTofMbufMbu
fMbufMbufMbufMbufMbufMbugcboiMToiMTogcbofMbuiMTofMbufMbufMbu
gcbogcbofMbugcbofMbugcbofMbuiMToiMTofMbugcboiMTogcbogcboiMTo
fMbugcbogcbogcbogcboiMToiMTofMbufMbugcboiMToiMTofMbugcbogcbo
iMTogcboiMTofMbuiMTogcbofMbufMbugcbogcbofMbufMbuiMTofMbufMbu
gcboiMTogcbofMbufMbumIZ/mIZ/2szK3dfamIZ/mIZ/saGUt6iau6yd//fX
//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX0sWwmIZ/7uPf7uPf
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX1sq0tqeZopGImIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6I1p6Y1p6Y1p6Y
1p6YmIZ/hrvYgcbofMbugcbogcbofMbufMbufMbugcbogcbogcbofMbuiMTo
gcbofMbuiMToiMTofMbufMbufMbuiMTogcbofMbuiMToiMTofMbuiMTofMbu
fMbufMbugcbofMbufMbuiMTofMbugcbofMbufMbufMbufMbugcbofMbufMbu
gcboiMTogcbofMbufMbugcbogcbofMbugcbogcboiMTogcbogcbogcbofMbu
gcboiMTofMbufMbufMbuiMToiMTogcboiMTogcbofMbufMbufMbugcbogcbo
gcbogcboiMTogcbogcbogcbofMbufMbufMbuiMTogcbofMbugcbogcbogcbo
gcbogcbofMbuiMTofMbugcbofMbufMbugcboiMTofMbufMbugcbofMbugcbo
fMbufMbuiMTofMbufMbufMbugcbogcbogcbofMbufMbugcbofMbufMbufMbu
fMbufMbugcbofMbufMbugcbogcbogcboiMTogcbogcbofMbuiMTogcboiMTo
fMbuiMTofMbugcboiMTomIZ/mIZ/2szK3dfamIZ/rJyQ//fX//fX//fX//fX
//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fXtaaYmIZ/7uPf7uPf
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX18y12c22x7mnnIqCmIZ/3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/wI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/hrvXiMToiMTogcbogcbogcbogcboiMTofMbuiMTogcbofMbuiMTo
gcbofMbufMbugcbogcbogcbofMbufMbugcbofMbufMbugcbofMbuiMTogcbo
gcbofMbugcbofMbufMbugcboiMTofMbugcbogcbogcbogcboiMTogcboiMTo
fMbufMbugcboiMToiMToiMToiMTofMbuiMTofMbuiMTofMbufMbufMbufMbu
fMbuiMTofMbuiMTofMbufMbufMbufMbufMbugcbogcbogcbogcboiMToiMTo
iMTofMbufMbugcbofMbugcbofMbufMbufMbugcbogcboiMTogcboiMTogcbo
iMTofMbugcbogcboiMToiMTogcbogcbogcbofMbugcboiMToiMTogcboiMTo
iMToiMTofMbugcbogcbogcboiMToiMToiMTogcbogcbogcboiMTogcbogcbo
iMTogcbogcbogcboiMTogcbogcboiMTofMbuiMTofMbugcbofMbuiMTofMbu
gcbofMbugcbogcbogcbomIZ/mIZ/2szKmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fXnIqCsZ+U7uPf////
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX8uvY3dfa3dfa3dfa3dfamIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX2c2218u0taaYmIZ/3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/jLnXgcbofMbufMbuiMTofMbugcbofMbugcbofMbufMbugcbofMbu
iMTogcbogcbogcbofMbuiMTogcboiMTogcbogcbofMbuiMToiMTogcbofMbu
iMTogcbogcbogcbogcbofMbufMbugcbofMbufMbugcboiMTogcboiMTofMbu
gcboiMToiMTogcbofMbufMbugcboiMTofMbugcbofMbuiMTogcbogcbogcbo
gcbogcbogcbofMbugcbogcboiMTogcbogcboiMToiMTogcbofMbufMbufMbu
fMbugcboiMToiMTogcboiMTogcbogcbogcboiMTofMbufMbufMbufMbuiMTo
iMToiMTofMbugcbofMbufMbuiMToiMTogcbogcbofMbufMbugcbofMbugcbo
gcbogcboiMToiMTogcbofMbufMbufMbufMbugcbofMbugcbogcbogcbogcbo
fMbuiMTofMbugcbogcboiMTofMbugcbogcboiMTogcbogcbofMbugcbogcbo
gcboiMTofMbufMbugcbomIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fXmIZ/u6ud7t/I////
//////////////fX//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX6+XZ3dfa3dfa3dfamIZ/mIZ///fX
//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXybypoI+GmIZ/3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/grzeiMToiMTofMbuiMToiMTogcboiMTogcboiMTogcbogcbogcbo
gcbofMbuiMToiMTofMbufMbugcboiMTofMbuiMTofMbufMbugcboiMTofMbu
gcbofMbuiMTogcboiMTogcboiMToiMToiMTofMbufMbugcbogcbogcbofMbu
fMbufMbufMbugcbogcbofMbugcbogcbogcbogcbogcbogcboiMToiMTofMbu
fMbuiMTogcbogcbofMbugcbogcboiMTofMbufMbuiMToiMTogcbogcbogcbo
iMTogcbofMbuiMTofMbuiMToiMToiMTofMbuiMTogcboiMTogcbofMbugcbo
gcbofMbugcbofMbuiMToiMTofMbufMbufMbuiMTogcboiMToiMToiMToiMTo
gcbogcbofMbufMbuiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMTofMbu
iMTofMbuiMTogcboiMTofMbugcboiMTofMbugcboiMToiMTogcboiMTofMbu
gcbogcboiMToiMToiMTofMbumIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fXmIZ/wrGi7t/I////
//////////////fX//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX+vLX493Z3dfa3dfa3dfamIZ/mIZ///fX
//fXm4mB2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX1cmz0cSwpZWKmIZ/3dfa3dfa
3dfa//fX//fX//fX//fXmIZ/mIZ/mIZ/t4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/iMTofMbugcboiMTogcbofMbuiMTogcbogcbogcboiMToiMTofMbu
fMbuiMTofMbugcbogcboiMToiMTofMbuiMTogcboiMTogcboiMTogcbogcbo
iMToiMTogcbofMbugcboiMTofMbugcbogcboiMTogcboiMTofMbugcboiMTo
iMTogcboiMTogcboiMTogcbogcbogcboiMTogcboiMToiMTogcbogcboiMTo
iMTofMbugcboiMToiMToiMToiMTofMbugcboiMTofMbugcboiMToiMToiMTo
fMbugcbogcbofMbugcbogcbofMbufMbugcbogcboiMTogcboiMTogcboiMTo
iMToiMToiMTogcbogcboiMTogcboiMTofMbuiMTogcbofMbugcbofMbuiMTo
iMToiMTogcbofMbuiMTogcboiMTogcbofMbugcboiMTofMbufMbugcbogcbo
gcbogcboiMTofMbuiMToiMTofMbuiMTogcbofMbugcboiMTofMbuiMToiMTo
iMTogcbogcbogcboiMTofMbumIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/xrWm7t/I////
//////////////////fX//fX//////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+fLY+fLX3tja3dfa3dfa3dfamIZ/3dfa//fX
//fXmYeA18nH3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXqpmOmIZ/mIZ/
//fX//fX//fX//fXmIZ/mIZ/mIZ/t4eCt4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/gcbofMbuiMToiMTogcbofMbufMbuiMToiMTo
gcboiMToiMToiMTogcbofMbuiMTogcbofMbufMbuiMTofMbuiMToiMTofMbu
gcbofMbuiMTogcbofMbugcbogcbogcbogcboiMTofMbuiMToiMTogcbogcbo
iMTogcboiMTofMbuiMToiMToiMTofMbuiMTofMbufMbuiMTofMbugcbogcbo
iMToiMTofMbugcbofMbufMbuiMToiMTogcbogcbogcbogcbogcbofMbugcbo
iMToiMToiMToiMToiMToiMToiMToiMTogcbofMbugcbofMbuiMTofMbugcbo
gcbogcbogcboiMToiMTogcboiMTogcbogcbogcboiMToiMTogcbogcbofMbu
fMbugcboiMToiMTogcboiMTofMbuiMTogcboiMTogcboiMToiMToiMToiMTo
iMToiMTofMbugcbogcbofMbugcbogcboiMToiMToiMTogcbogcbogcbofMbu
fMbuiMToiMTofMbugcbomIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9+7QmIZ/wrGi7t/I////
////////7uPfmIZ///////////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+vLX3dfa3tja3dfa3dfa3dfamomCmIZ///fX//fX
//fXmIZ/6drE2szK//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//////////fX//////fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/pHl0t4eCt4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/k8jmfMbufMbuiMToiMToiMTogcbogcbo
gcbogcbofMbufMbuiMTogcbofMbuiMToiMToiMTofMbuiMTofMbufMbuiMTo
gcboiMTogcboiMTogcboiMToiMToiMToiMTogcboiMTogcbofMbuiMToiMTo
fMbuiMTofMbuiMTogcbofMbufMbuiMTofMbuiMTogcbofMbugcboiMTofMbu
gcbogcbogcboiMToiMTogcbogcbogcboiMToiMToiMToiMToiMTogcboiMTo
fMbugcbogcbogcbofMbugcbogcbogcboiMToiMToiMTogcbogcboiMToiMTo
iMToiMTofMbugcboiMTogcboiMToiMToiMTofMbugcboiMToiMTogcboiMTo
iMTogcbogcboiMTofMbuiMTogcboiMTogcboiMTogcbogcbogcbogcbogcbo
gcboiMToiMToiMToiMToiMToiMTofMbugcbofMbuiMToiMToiMToiMToiMTo
gcbofMbuiMToiMTogcbomIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/uqmc//fX////
//fX////283LmIZ///////////////////////fX//fX//fX//fX////////
//////fX//fX//fX//fX4Nra3dfa3dfa3dfa3dfanYyFmIZ/mIZ///fX//fX
//fXmIZ/xre02szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//////////fX//fX//////fX//////////////fX
mIZ/mIZ/mIZ/mIZ/mIZ/pHl0pHl0t4eCt4eCwI6IwI6IwI6I1p6Y1p6YmIZ/
mIZ/momBmIZ/mIZ///fXmIZ/mIZ/mIZ/isTofMbugcbogcboiMTogcboiMTo
gcboiMToiMTogcboiMToiMTofMbugcbogcboiMTogcboiMToiMTogcboiMTo
gcboiMTofMbuiMTogcbofMbufMbufMbuiMTogcboiMToiMTogcbogcboiMTo
fMbuiMTogcboiMToiMToiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMTo
iMToiMTofMbugcboiMTofMbuiMTofMbufMbufMbufMbufMbuiMTogcboiMTo
iMToiMToiMToiMToiMToiMToiMTofMbugcbofMbuiMToiMTogcbofMbugcbo
fMbugcboiMToiMTogcboiMTogcbofMbugcboiMToiMTofMbugcboiMToiMTo
gcboiMToiMToiMToiMTogcboiMTogcboiMTogcboiMToiMToiMToiMToiMTo
iMTogcbofMbugcbogcbogcbogcboiMToiMToiMTofMbugcbogcboiMTogcbo
iMToiMToiMTomIZ/jsbomIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/pZSK//fX//fX
//fX2szKmIZ///////////////////////////fX//fX//fX////////////
//fX//fX//fX//fX493Z3dfa3dfa3dfa3dfarqCcmIZ/mIZ///fX//fX//fX
//fXmIZ/opGK2szK3dfa//fX//fX//fX//fX//fX//fX//fX////////////
//fX//fX//fX//fX//fX//fX//fX//////////////////fX//fX////////
////////mIZ/mIZ/pHl0pHl0pHl0t4eCt4eCwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/6eLZ/PTX+vLX/vbX//fXmIZ/mIZ/mIZ/mIZ/mIZ/iMTogcboiMTogcbo
iMTogcbogcboiMToiMTogcboiMToiMToiMTogcboiMTogcbogcboiMTofMbu
iMTogcboiMTogcboiMToiMToiMToiMTogcboiMTogcbogcboiMToiMTogcbo
iMTogcboiMTofMbugcbogcboiMTogcboiMTogcbogcbogcboiMToiMTogcbo
gcbogcboiMToiMTogcboiMTofMbuiMToiMToiMToiMToiMTogcboiMTogcbo
fMbufMbufMbugcbogcbogcbofMbuiMToiMToiMToiMToiMToiMToiMToiMTo
iMTogcbogcboiMTogcboiMToiMToiMTogcbogcboiMToiMTogcbofMbuiMTo
gcbogcbofMbugcboiMTofMbuiMToiMToiMTogcboiMTogcbofMbuiMToiMTo
iMToiMToiMToiMToiMToiMToiMTogcbogcboiMToiMToiMTofMbuiMTogcbo
gcbogcboiMTomIZ/mIZ/mIZ///fX//fX//////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9OzYmIZ/saCb//fX//fX
3dfa2szKmIZ///////////////////////////fX////////////7uPf7uPf
//fX//fX//fX8OnY3dfa3dfa3dfa3dfatKajmIZ/mIZ///fX//fX//fX//fX
//fXmIZ/mIZ/2cvJ2szK//fX//fX//fX//fX//fX//fX//fX//fX////////
//////////fX//fX//fX//fX//fX//fX//////////////fX//fX////////
////////////mIZ/mIZ/pHl0pHl0t4eCwI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/3dfa5t/Z9e3Y/vbX+vLX//fX/vbXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/iMTo
iMToiMTogcbogcboiMTogcbogcbogcboiMTofMbuiMToiMToiMToiMTogcbo
iMToiMToiMToiMTogcbogcbogcboiMTogcboiMToiMToiMTofMbuiMToiMTo
iMTogcboiMToiMToiMTogcboiMTogcboiMToiMToiMTogcbogcboiMToiMTo
iMTogcbogcboiMToiMToiMTogcboiMTogcbogcbogcboiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMTogcbogcbogcbofMbufMbuiMTogcbogcbogcbo
iMToiMToiMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMTogcboiMToiMTofMbuiMToiMTogcboiMToiMTofMbufMbu
iMToiMTogcboiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToiMToiMTo
iMToiMTogcbomIZ/n46F7t/I//fX//////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6OHZmIZ/tqah3dfa//fX
287KmIZ/////////////////////////////////////////////7uPf3c/N
mIZ///fX+fLX3tja3dfa3dfa3dfatqqnnIqCmIZ///fX//fX//fX//fX//fX
//fX//fXmIZ/y7y52szK3dfa//fX//fX//fX//fX//fX//fX//fX////////
//////////fX//fX//fX//fX//fX//fX//fX////////////////////////
////////////////mIZ/mIZ/mIZ/t4eCwI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/3dfa3dfa5N3Z+vLX/vbX9e7Y//fX/vbX/fXXmIZ/mIZ/mIZ/mIZ/mIZ/
gcboiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMTofMbuiMToiMTo
iMTogcboiMTofMbuiMToiMToiMTogcboiMToiMToiMTofMbuiMToiMTogcbo
gcboiMToiMToiMTogcboiMToiMTomIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/pdHklcjmisTogcboiMToiMToiMToiMTofMbugcbogcbo
gcboiMTogcbogcbogcboiMToiMToiMToiMToiMToiMTofMbuiMToiMToiMTo
iMToiMToiMTogcbogcboiMTogcboiMToiMTogcbogcboiMTogcbogcboiMTo
gcboiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMToiMToiMTogcbo
iMToiMTogcbogcbogcboiMToiMToiMTogcbofMbuiMToiMToiMToiMTogcbo
iMToiMToiMTomIZ/0MCu7t/I//fX//////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX8uvY3tjamIZ/tKSf3dfa3dfa
59jImIZ/////////////////////////////////////////7uPf7uPfmIZ/
8u/w8+zY4tva3dfa3dfa3dfas6ajmIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fXmIZ/pJON2szK3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//////////////fX//fX//fX//fX//fX//fX//fX////////////////////
//////////////////fX//fXmIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
3dfa3dfa3dfa3dfa3dfa9u/Y//fX9/DY/vbX//fX//fXmIZ/mIZ/mIZ/mIZ/
mIZ/iMToiMTogcboiMToiMToiMTogcboiMToiMToiMToiMTogcboiMTogcbo
iMTogcboiMToiMTogcboiMToiMTogcbogcbogcboiMToiMTogcboiMToiMTo
iMTogcbogcboiMToiMTomIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I7t/I
7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/o83mmcrmiMTofMbuiMToiMToiMToiMTo
gcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMTofMbuiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMTogcboiMToiMToiMToiMToiMToiMTogcboiMTogcboiMTo
gcboiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTofMbuiMToiMTo
gcboiMToiMTomIZ/zr6t//////////fX//////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX/PTX4Nra3dfamIZ/s6Oe3dfa2szK
mIZ/7uPf////////7uPf////////////////////////////7uPfmIZ/9PLz
7uzt3tja3dfa3dfa3dfa3dfamIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//////////////////fX//fX//////fX//fX////////////////////////
//////////////////////fXwI6ImIZ/mIZ/wI6I1p6Y1p6Y1p6Y1p6YmIZ/
3dfa3dfa3dfa3dfa3dfa3tja8OnY/vbX+/PX/vbX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/gcboiMToiMToiMTofMbuiMToiMToiMTogcboiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
gcbomIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/ImIZ/mIZ/oI6GmIZ/mIZ/mIZ/icjonszmiMToiMToiMToiMTo
iMToiMToiMTogcbogcbogcboiMTogcboiMTogcboiMTogcboiMTogcboiMTo
iMToiMToiMToiMTogcboiMTofMbufMbuiMToiMTogcboiMToiMToiMToiMTo
gcboiMToiMToiMTofMbuiMToiMToiMToiMTofMbuiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMTogcboiMToiMToiMTofMbuiMToiMTofMbuiMToiMTo
iMTogcbomIZ/mIZ/1se0//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX6OHZ3dfa2szKmIZ/q5uV3dfa2szK
mIZ//Pz8////////7uPf//fX////////////////////7uPf7eLemIZ/7uvs
3dfa3dfa3dfa3dfa3dfamYeAmIZ///fX//fX//fX//fX6+HG6d/EqJiNqJeM
mYeAmIZ/mIZ/mIZ/vK2o2szK3dfa3dfa//fX//////////fX//fX//fX//fX
//fX//////////////////fX//fX////////////////////////////////
//////////////////////fX//fXmIZ/mIZ/mIZ/1p6Y1p6Y1p6YmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa8erY+/PX/PTX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/mIZ/mIZ/iMToiMTogcboiMToiMTogcboiMTogcboiMToiMTo
iMToiMToiMToiMTofMbuiMToiMToiMToiMTokqKxkqGwlJqjl4uImIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/Iy7ur7t/ImIZ/mIZ/mIZ/mIZ/ksrmiMTogcboiMTo
iMToiMToiMToiMToiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMToiMTo
iMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMTofMbuiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbok8HhiMToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTo
gcboiMTomIZ/mIZ/5NjT//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7ebZ3dfa2szK2szKmIZ/oZCK3dfa2szK
mIZ///////fX////7t/ImIZ/////////////////////7uPf7ePfmIZ/3dfa
3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX+O/Rrp6SmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mYeAm4mD2szK2szK3dfa3dfa//////////////fX//////fX
//////fX//////////////////////fX////////////////////////////
//////////////////fX//////fX//fXmIZ/mIZ/mIZ/1p6Y1p6YmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja8OnY9u/Y/vbX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/jbXRjLrYiMLmk8HhiMLmiMLm
iMLmiMTogcboiMTok8HhisDhjLrZibXOkqO1mIiCmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/IoI6GmIZ/mIZ/mIZ/mIZ/lsjmiMToiMTo
gcbogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMTo
iMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToiMTogcbo
iMToiMToiMToiMTok8HhiMToiMToiMToiMToiMToiMTok8HhiMToiMToiMTo
iMToiMTomIZ/mYeA7uPf//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3tja3dfa2szKmIZ/3dfamIZ/3dfa3dfa
mIZ///fX//fX7t/I7t/ImIZ///fX////////////////7uPf6NnImIZ/3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX8ejLqZmNmIZ/mIZ/mIZ/mIZ/mIZ/rp6S
oZCHmIZ/mIZ/mIZ/mIZ/uKej2szK2szK3dfa//fX//////////////fX////
//////////fX////////////////////////////////////////////////
//////////////////fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa7+jY+fHY//fX//fX//fX//fX
//fX//fX//fX//fX/vbX+/PXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/isToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMTok8HhiMToiMToiMToiMToiMTogcboiMToiMTo
iMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToj8Hn
gcboiMToiMTogcbogcboiMToiMToiMToiMToiMToiMTogcbogcboiMToiMTo
iMToiMTomIZ/rJ2Y7t/I//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa2szK2szKmIZ/3dfaqJaMz8C92szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////////fX7t/I7t/ImIZ/3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ///fX29C5wLGhmIZ/mIZ/mIZ///fXmIZ/saGU/fTV
oI6GmIZ///fX//fXmIZ/mIZ/39PP2NHU2szK3dfa//fX////////////////
////////////////////////////////////////////////////////////
//fX//////////////fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja8OnY//fX//fX//fX//fX
//fX/vbX//fX//fX//fX/PTX/vbX//fX//fX//fXmIZ/nYuDoI6Gn46FnIqC
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/jMbo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMTok8HhiMToiMToiMToiMTo
iMToiMToiMToiMTok8HhgcboiMToiMToiMToiMToiMToiMToiMToiMTok8Hh
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTok8Hh
iMToiMTok8HhiMTok8HhgcboiMToiMToiMToiMToiMToiMToiMToiMToiMTo
k8HhiMTomIZ/3tjW//////////////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX4Nra3dfa3dfa2szK2szKmIZ/3dfaqJaM08TC2szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////fX//fX7t/I69zImIZ/3dfa3dfa
3dfa3dfamIZ/mIZ///fX/vbWw7WkmIZ/mIZ//vbW//fX//fXmIZ///fX+vLT
mIZ///fX/fXW/fXV/vbWmIZ/r52S0cK/2szK3dfa3dfa////////////////
//////////////////////////////////////////////////////////fX
//////////////////fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na/fXX/vbX//fX//fX
//fX//fX//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/mIZ/
isToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
k8HhiMToiMToiMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMToiMToiMToiMToiMToiMToiMToiMTok8HhiMToj8Hnk8HhiMToiMToiMTo
iMToiMTogcboiMTogcboiMTok8Hhj8HniMToiMToiMToj8HniMTok8Hhk8Hh
gcbomIZ/mIZ//fz8//////////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/3dfamIZ/2su32szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////fX7t/I7t/ImIZ/3dfa3dfa3dfa
3dfamIZ/mIZ///fX//fXu62dmoiAmIZ/mIZ//PTV//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/s6Od0MG+2szK3dfa3dfa////////////
//////////////////////////////////////////////////////fX//fX
//fX//////////////fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+/PX/PTX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
isTok8HhiMToiMToiMTok8HhiMTok8HhiMToiMToiMToiMToiMToiMToiMTo
iMToj8HniMToiMToiMTok8Hhgcbok8HhiMToj8Hnj8Hnk8HhiMToj8HniMTo
j8Hnk8HhiMToiMToiMTok8HhiMTogcboiMToiMTogcboiMToiMToiMToiMTo
iMToj8HniMToiMToiMToiMTogcbok8HhiMToj8HniMToiMTogcbogcboiMTo
iMTomIZ/mIZ////+//////////////////////////fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa2szK2szKmIZ/3dfa3dfamIZ/z7+txLOk
mIZ///fX//fX7t/I7t/ImIZ///fX//fX//fX7t/I6tvIpZSO3dfa3dfa3dfa
mIZ/mIZ/mIZ///fXu6ydmIZ/mIZ///fXmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/nIqE08XC2szK3dfa////////////
//////////////////////////////////////////////////////////fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9e7Y/vbX/vbX//fX
//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/
mIZ/iMToiMToiMToiMToiMTogcboiMToiMToiMTok8HhiMTok8Hhk8Hhgcbo
k8HhiMToiMToj8HniMToiMTok8HhiMToiMTok8HhgcbogcboiMToiMToj8Hn
iMToiMTok8HhiMToj8HniMToj8Hnj8HniMToiMToj8HniMToiMToiMToiMTo
iMTogcbok8HhiMToj8HniMTok8HhgcboiMToiMToiMToiMToj8Hnj8HniMTo
iMTomIZ/rZ2R//////////////////////////////fX//fX//fX//////fX
//fX//fX//fX3dfa3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/wbCiw7Kj
mIZ///fX//fX7t/I7t/ImIZ///fX//fX//fX7d7I4dTJuKik3dfamIZ/mIZ/
mIZ/mIZ///fX//fXnIuDmIZ///fX//fXmIZ///fX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fXmIZ/opGM2szK3dfa3dfa////////
////////////////////////////////////////////////////////////
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+vLX/PTX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/j8HniMToiMToiMToj8HniMToiMToiMTogcbok8Hhgcbogcbok8Hh
iMTok8HhiMTok8HhiMToiMToiMTok8HhiMTok8Hhj8Hnk8HhiMTok8Hhgcbo
iMToiMToiMToiMToiMToiMTok8HhiMTok8HhiMToiMToiMToiMTok8HhiMTo
j8Hngcboj8Hnk8HhiMToiMToj8Hnk8Hhk8Hhk8HhiMToiMToiMToj8HniMTo
mIZ/mYeB9vTz//////////////////////////////fX//////////////fX
//fX4Nve3tja3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/sqGVzb2s
mIZ///fX//fX//fX7t/ImIZ///fX//fX//fX7d7I287KpZaQ3dfamIZ/m4qD
nYuD//fXrJyQ3NG5mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/qpuWmoiB2szK3dfa3dfa////
//////////////////////////////////////////////fX////////////
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa8enY+/PX//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImoiA
mIZ/mIZ/mIZ/iMToj8HniMToiMToiMToiMToiMToiMToiMToj8HniMToiMTo
k8HhiMTok8HhiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbok8Hh
k8HhiMToj8HniMToiMTok8HhiMTok8HhiMToiMTok8HhiMTok8HhiMToj8Hn
iMToj8HniMToiMToiMToiMToiMToiMToiMToiMToiMTok8HhiMTok8HhiMTo
mIZ/pZSN////////////////////////////////////////////////////
3dfa3dfa3dfa3dfa3dfa2szKmIZ/mIZ/3dfa3dfa3dfa3dfamIZ/oI+I1cWz
mIZ///fX//fX//fX7t/ImIZ///fX//fX//fX59nIrZyX3dfa3dfamIZ/4te+
//fX//fXy76qx7mn//fX29C5//fX//fX//fX//fXmIZ/o5ONz8bH19DS3dfa
3dfa3dfa3dfa3dfa3dfa3dfaxry7y8HCmIZ/mIZ/mIZ/opCK2szK3dfa3dfa
//////////////////////////////////////////////////fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ/fXX//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/Ix7en
n46FmIZ/mIZ/mIZ/iMToiMTok8HhiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMTok8HhiMToiMToiMTok8HhiMToiMToj8HniMToiMTo
iMTok8Hhk8Hhk8HhgcboiMToiMToiMToiMToiMTok8HhiMToiMTok8HhiMTo
iMTok8HhiMToiMToiMTok8HhiMToiMToiMTok8HhiMToiMToiMTok8HhiMTo
mIZ/7uPf//////////////////////////////fX////////////////3dfa
3dfa3dfa3dfa3dfa2szKmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamYeAw7Ok
mIZ/3dfa//fX//fX7t/ImIZ///fX//fX7ebZ2szKmoiC3dfamIZ/n4+J9ezP
//fX//fXpZSKoZCH//fX//fX//fX//fX//fXmIZ/wLW02NLU3dfa3dfa3dfa
1c3P0srL19DT2tTW19DS9+7Q3dfa3dfa3NbZmIZ/mIZ/mIZ/wLGs2szK3dfa
//////////////////////////fX//////////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z+fHY//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
zLyrp5aMm4iBmIZ/iMToiMTok8Hhk8Hhj8HniMTok8Hhk8HhiMTok8HhiMTo
iMToiMToiMTok8Hhj8HniMToiMTok8Hhj8HniMToiMTok8Hhk8HhiMToiMTo
j8HniMTogcboiMToj8HniMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToj8Hnk8Hhgcbok8Hhk8Hhk8HhiMToiMToiMToiMToiMTomIZ/
mIZ///////////fX//////////////////////fX////////9OzY3dfa3dfa
3dfa3dfa3dfa2szK2szKmIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfamIZ/
mIZ/mIZ///fX//fX7t/ImIZ///fX//fX4tza2szKmIZ/3dfamYiB29C5//fX
//fX//fXmIZ/mIZ///fX//fX//fX//fXmIZ/t6uo3NXY3NXYq52ZmIZ/moiB
nYyKmomEno2NmoiBmIZ/mIZ/pZWKz8Kuu6+t2NLUuqucmIZ/mIZ/wrOv2szK
3dfa//////////fX//////////////fX//////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na+PDY/vbX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
y7urx7ano5GKmIZ/mIZ/mIZ/iMToiMTok8Hhk8HhiMTogcbok8HhiMToj8Hn
k8Hhk8HhiMTok8Hhk8Hhk8HhiMTok8HhiMTok8HhiMToiMTok8Hhj8Hnk8Hh
iMTok8HhiMToiMTok8Hhk8Hhk8Hhk8Hhj8HniMToj8Hnk8HhiMTok8Hhk8Hh
iMTok8Hhk8HhiMTok8HhiMTogcboiMToiMToiMTok8Hhk8HhiMToj8HnmIZ/
t6eh//////////fX//////////////////fX////////+/r74dze3dfa3dfa
3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/3dfa//fX7t/ImIZ///fX//fX2szK2szKmIZ/3dfaycDA//fX//fX
//fXmIZ/mIZ///fX//fX//fX//fXmIZ/vK2d3NbZ2dLVtqeZmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/1M3P2tTWzMPEnIqCmIZ/wLCs
2szK3dfa3dfa//////////////////fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXwrWj
mIZ/no2H3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+PHY/PTX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/I7t/IwrGjopCHmIaAmIZ/j8HniMToiMToiMToj8HniMToiMTok8HhiMTo
iMToiMToiMToiMToiMTogcbok8HhiMToiMToiMToiMToiMTogcbok8HhiMTo
iMToiMToj8Hnk8HhiMToiMToiMToiMTok8Hhj8Hnk8HhiMToj8HniMToiMTo
k8HhiMToiMToiMToiMToiMToj8HniMTok8Hhk8HhiMToiMToiMTomIZ/mIZ/
69/b//////fX/////////////////////////////v7+5+DZ3dfa3dfa3dfa
3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/3dfa3dfa7t/I7t/ImIZ///fX2szK2szK3dfam4qC+O/R//fX//fX
//fXmIZ/mIZ//fTV//fX//fXmIZ/p5eM2tTW2tTWv7GhmIZ/mIZ/jCBHixxB
ixxBjCBHjCBHjCBHoCVKoCVKjCBHm2NsmYN9mIZ/q5yY3dfa0MjJoJCKmIZ/
ybq32szK2szK//fX//////////////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX8+rN
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9+/Y/PTX
/PTX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/IyrmpxLSlmoiBmIZ/mIZ/iMToiMTok8HhiMToiMTok8HhiMTok8Hh
iMTok8HhiMToiMToj8HniMTok8Hhk8Hhj8Hnk8Hhk8Hhk8HhiMToj8Hnk8Hh
k8Hhk8HhiMToj8HniMTok8HhiMToiMTok8HhiMToj8Hnk8Hhk8Hhj8HniMTo
j8HniMTok8HhiMToj8HniMToj8HniMToiMTok8HhiMTok8HhiMTomIZ/moiB
///+//////fX//////////////fX////////////9PLz3dfa3dfa3dfa3dfa
2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/3dfa3dfa7t/I7t/ImIZ///fX2szK2szKmIZ/uKmb//fX//fX//fX
mIZ/mIZ///fX//fX//fX//fXn46F8OfL3NbZzL+rmIZ/1NH3jCBHjCBHixxB
jCBHjCBHjCBHkRxEmRdBrxpDrxpDmRdBmRdBmRdBmIZ/oI+JzsXGwba1m4mD
sqOV2szK2szK2szK//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX/f39
pJOJmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9u7Y/fXX
9u/Y//fX//fX//fX//fX//fXmIZ/opGH//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/IyLiorZyRmIZ/mIZ/k8HhiMTok8Hhk8HhiMTok8HhiMToiMTo
k8Hhj8Hnk8Hhk8Hhk8Hhk8HhiMToiMTok8HhiMToj8HniMTok8Hhk8HhiMTo
iMToiMTok8Hhk8Hhk8HhiMTok8HhiMToiMTok8Hhk8HhiMToiMTok8Hhk8Hh
k8Hhk8HhiMTok8Hhk8Hhk8Hhk8Hhk8Hhk8HhiMTok8HhiMTok8HhmIZ/xLSl
//////fX//fX//fX//////////fX////////+/r73dfa3dfa3dfa3dfa2szK
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfamIZ/
mIZ/mIZ/mIZ/3dfa2szK7t/ImIZ/3dfa2szK2szKmIZ/6+HG//fX//fX//fX
mIZ///fX//fX//fX//fX//fX+/PU/vbW6uDFmYeB1NH31NH3oCVKoCVKixxB
kRxEkRxEkRxEnBQ/nBQ/nxI9nxI9txQ/txQ/nxI9nBQ/mIZ/n4+J2tPW6OPi
mIZ/o5KNwbKu2szK2szK2szK//fX//////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX7t/I7eLe
ysG9mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9O3Y/vbX
/PXX//fX//fX//fX//fXmIZ/mIZ/5dvB//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/Izr6twbGimIZ/mIZ/mIZ/k8HhiMToiMTok8HhiMToj8Hnk8Hh
k8HhiMToj8HniMToiMTok8Hhk8HhiMTok8Hhk8Hhk8HhiMToiMToj8Hnk8Hh
k8HhiMToiMToj8Hnk8Hhj8Hnk8Hhk8HhiMToiMTok8HhiMToiMToiMToiMTo
j8Hnk8HhiMToiMToj8HniMToiMToiMTok8Hhj8Hnk8HhiMToiMTomIZ/3c66
//////fX//fX//fX//fX//fX//fX//fX+/PX5eHj3dfa3dfa3dfa2szKmIZ/
mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/mIZ/1NH3oCVKoCVKoCVKmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/2szK3dfa2szKmIZ/3dfa2szK2szKmIZ/x7qn//fX//fX//fX
//fX//fX//fX//fX//fX/fTV//fX5tzCmIZ/mIZ/1NH3oCVKoCVKoCVKpiFH
kRxEkRxElRpCohA8ohA8////////////vRA9uhI+sxdBmRdBmIZ/m4qE2tTW
19DS3dfapJOJwrOv2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX7t/I
7uzqmIZ/1M3O3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa8+zY/vbX
/vbX//fX//fX//fX//fXmIZ/vrCg//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/IzLyrp5WMmIZ/mIZ/k8Hhk8HhiMTok8Hhk8HhiMToj8Hn
iMTok8Hhk8Hhk8Hhk8HhiMToj8Hnk8Hhj8HniMToj8Hnk8Hhk8Hhk8HhiMTo
iMTok8Hhk8Hhk8HhiMTok8Hhj8HniMTok8Hhk8HhiMTok8Hhk8Hhk8Hhk8Hh
k8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8HhiMTok8HhiMTok8Hhk8HhmIZ/28u4
//fX//fX//fX//fX//fX//fX//fX//fX7ebZ3dfa3dfa3dfa2szK2szKmIZ/
mIZ/3dfa3dfamIZ/mIZ/1NH31NH31NH3oCVKoCVKoCVKoCVKmIZ/mIZ/mIZ/
3dfa3dfamIZ/2szK2szK2szKmIZ/3dfa2szK2szKmIZ/9OvO//fX//fX//fX
//fX//fX//fX//fX//fX//fX9OvOno2JmIZ/1NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5FvRA9////////////////////vw88vRA9sxdBkRxEmIZ/tKek
3NbZ19DS7t/InoyE3dfa2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX7t/I
/Pv7mIZ/08vN3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9O3Y/PTX
+fHY//fX//fX//fXmIZ/mIZ/+vLT//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/Izr6twbGimIZ/mIZ/j8HniMTok8HhiMToiMTok8Hhk8Hh
j8HniMTok8HhiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhj8HniMToj8Hnk8Hhk8Hh
j8HniMToiMTok8HhiMTok8Hhk8HhiMToiMTok8Hhj8HniMToj8Hnj8HniMTo
k8Hhj8Hnk8HhiMToj8Hnj8HniMTok8HhiMTok8Hhj8HniMTok8HhmIZ///fX
//fX//fX//fX//fX//fX//fX//fX/PTX39na3dfa3dfa2szK2szKmIZ/mIZ/
//fX3dfamIZ/mIZ/mIZ/1NH31NH31NH3oCVKoCVKoCVKoCVKoCVKmIZ/mIZ/
mIZ/4b/ImIZ/mIZ/mIZ/2szKmIZ/3dfa2szK2szKmIZ//PPU//fX//fX//fX
//fX//fX//fX//fX//fX9ezPmoiB1NH31NH31NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5Fvw88////////////////////wQ07vw88txQ/kRxEmIZ/mIZ/
pmZs2dLV//fX7t/Im4mCy8HC2szK2szK2szK//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX////mIZ///fX//fX//fX//fX7t/I
7eLenIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9u7Y+fLX
+fHY//fX//fX//fXmIZ/+fDR//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/I7t/IzbysopCHmIZ/mIZ/iMTok8Hhk8HhiMToiMToj8Hn
k8Hhk8HhiMTok8Hhj8HniMTok8HhiMToj8HniMTok8Hhk8Hhk8Hhj8HniMTo
k8Hhk8Hhk8Hhj8Hnk8HhiMToiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hh
iMTok8HhiMTok8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhj8HnmIZ///fX
//fX//fX//fX//fX//fX//fX//fX5+DZ3dfa3dfa3dfa2szK2szKmIZ/mIZ/
//fX2szKmIZ/mIZ/1NH31NH31NH31NH3oCVKoCVKqx5Fqx5Fqx5FrxpDmIZ/
mIZ/4b/I4b/ImIZ/mIZ/2szKmIZ/3dfa2szK2szKmIZ/+fDS//fX//fX//fX
//fX//fX//fX//fX+/PUq5uPmIZ/1NH31NH31NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5Fpg06////////////////////qQs5vw88txQ/piFHoCVKmIZ/
mIZ/18u1//fX7t/ImIZ/momCvrOx29TX2szK2szK//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX////mIZ///////fX//fX7t/I//fX
7uPfopGLmoiB3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+PDY+fHY
+fLY//fX//fXmIZ/sKCT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/Ivq6gmIZ/mIZ/k8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
j8Hnk8Hhj8Hnk8Hhk8HhiMTok8Hhk8Hhk8HhiMToj8HniMTok8Hhk8HhiMTo
j8Hnj8Hnk8Hhj8Hnk8Hhk8Hhj8Hnj8Hnk8HhiMToj8HniMToiMToj8Hnk8Hh
iMTok8HhiMToiMToj8Hnj8HniMToj8Hnk8HhiMToj8Hnk8HhmIZ/rpyR//fX
//fX//fX//fX//fX//fX//fX//fX3tja3dfa3dfa2szK2szKmIZ///fX//fX
//fX2szKmIZ/mIZ/1NH31NH31NH31NH3oCVKqx5FsxdBtxQ/////////uhI+
mIZ/mIZ/4b/ImIZ/mIZ/2szK2szKmIZ/2szK2szKmIZ/+/LT//fX//fX//fX
//fX//fX//fX//fXx7qnmIZ/1NH31NH31NH31NH31NH3oCVKoCVKpCZKsSNH
syNIuSBGuSBGwA88////////////////////6RA9vw88txQ/oCVKoCVKoCFE
mIZ/nYyG3dfa7t/I7t/ImIZ/mIZ/r6Gd3dfa2szK2szK7t/I//fX7t/I//fX
//fX//fX//fX//fX//fX//fX////////////mIZ///////////fX7uPf//fX
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja+vLX+PDY
+fHY//fXmIZ/w7Wk+O/R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/Izr6tmIZ/mIZ/k8HhiMToj8Hnj8HniMToj8Hn
k8Hhj8Hnk8HhiMToj8Hnk8Hhj8HniMToj8Hnk8Hhj8Hnk8Hhj8Hnj8Hnk8Hh
k8Hhk8HhiMTok8Hhj8Hnj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hn
k8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8HhiMTomIZ/6NnD//fX
//fX//fX//fX//fX//fX//fX8uvY3dfa3dfa2szK2szKmIZ/mIZ///fX//fX
//fX2szKmIZ/1NH32NX47Ov78O/87+78sypLvCFGwxY/txU/////////////
uhI+mIZ/4b/I4b/ImIZ/mIZ/2szKmIZ/2szK3dfamIZ//fXW//fX//fX//fX
//fX//fX//fX//fXm4qCmIZ/1NH31NH31NH31NH31NH3qSdKtytLvSxMxSdJ
xyhJ////////4xQ/4xQ/////////////6RA95hI+4BZAziRHoCVKoCVKoCFE
mIZ/mIZ/3dfa//fX7t/I7t/ImIZ/mIZ/3dfa3dfa2szK2szK7t/I//fX7t/I
//fX//fX//fX//fX//fX//fX////////////mIZ/////////////7uPf7uPf
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa4tza9+/Y+PDY
+fLY/vbXmYeA9OvN//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/IzLyrmIeBmIZ/j8Hnk8Hhk8Hhk8Hhk8Hhk8Hh
k8HhiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhj8HniMTo
iMTok8Hhj8Hnk8Hhk8HhiMToj8Hnj8Hnk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8HhiMTok8Hhj8Hnk8Hhk8Hhj8Hnj8Hnk8HhiMTomIZ/6tvF//fX
//fX//fX//fXmIZ///fX//fX5t/Z3dfa3dfa2szK2szKmIZ/mIZ///fX//fX
//fX2szKmIZ/3Nn4/f3/////////////wS1MziRH3BlB1hhB////////////
uhI+mIZ/mIZ/4b/I3dfamIZ/2szK2szKmIZ/2szKmIZ//PPU//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/1NH31NH32tj46Of79PT99/f+vSxMvixMyChJ
yChJ////////4BZA4xQ/4xQ/5hI+5hI+5hI+4BZA2BxDziRHwS1MwChG1NH3
r6KsmIZ/mIZ/3dfa//fX//fX7t/I7t/ImIZ/mIZ/mIZ/3dfa2szK2szK7t/I
7t/I//fX//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5t/Z9OzY+vLX
+vLXmIZ/r6CT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IybmpmIZ/mIZ/k8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hh
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnj8Hnk8Hhj8Hnj8Hnk8Hhj8Hn
j8Hnk8Hhj8Hnk8Hhj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/7t/I//fX
//fX//fX//fXmIZ///fX//fX3tja3dfa3dfa2szKmIZ/k8Hhj8Hn//fX//fX
//fX7t/ImIZ/mIZ//f3/////////////wS1MyChJ3BlB3BlB3BlB////xhM+
uhI+uhI+mIZ/w6fP3dfamIZ/mIZ/2szKmIZ/2szKmIZ//fXW//fX//fX//fX
//fX//fX//fXmIZ/mIZ/1NH319X46un78fH89fT9/Pz//v7/wS1MwS1MwS1M
////////////3BlB3BlB3BlB4BZA4BZA3BlB0yBFziRHyChJwS1MwS1M////
+/r5mIZ/mIZ///fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/2szK2szK2szK
7t/I//fX//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfn4+ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ8erY+PDY
/vbXmIZ/1sq0/vbW//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IyrmpmIZ/mIZ/j8Hnj8Hnj8Hnk8HhiMToj8Hn
k8Hhk8Hhj8Hnj8Hnj8Hnj8Hnj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hh
j8Hnk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/7t/I//fX
//fX//fX//fXmIZ///fX+fLX3dfa3dfa2szK2szKmIZ/mr/hk8Hh//fX//fX
//fX7t/ImIZ/mIZ/////////////////wS1MwS1M2BxD////3BlB3BlB3BlB
txQ/txQ/mIZ/mIZ/3dfa//fXmIZ/mIZ/mIZ/2szKmomB/PTV//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dv59vb9+fn+/v7/////////////wS1MwS1MwS1M
////////////0yBF0yBF////////2BxD0yBFziRHziRHwS1MwS1MwS1M////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfrZ6ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+HZ8erY3tja
mIZ/mIZ//PPU//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/r5+SnoyEmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImoiBmIZ/k8Hhk8Hhj8Hnmr/hk8Hhk8Hh
mr/hmr/hk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhmr/hj8Hnk8Hhj8Hnk8Hhk8Hh
j8Hnj8Hnj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnmr/hk8HhmIZ/7uPf////
//fX//fXmIZ///fX//fX7ufZ3dfa2szK2szKmIZ/k8Hhk8Hhk8Hh//fX//fX
//fX7t/ImIZ/mIZ/////////////////////wS1M////////2BxD3BlB3BlB
3BlBsxdBmIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ/nIqE//fX//fX//fX//fX
//fX//fX//fXmIZ/4+H6+fj+////////////////////////wS1MwS1MwS1M
wS1MwS1MziRHziRHziRH////////ziRHyChJyChJwS1MwS1MwS1M////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/
mIZ/7t/I//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfq52ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+HZ8erY3dfa
mIZ/p5eM//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/no2H3dfaxLm5uqycmIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Ino2FmIZ/k8Hhj8Hnk8Hhk8Hhk8Hhj8Hn
iMTok8Hhmr/hk8Hhk8Hhk8Hhj8Hnmr/hk8Hhk8Hhmr/hk8Hhj8Hnmr/hmr/h
k8Hhk8Hhmr/hj8Hnk8Hhj8Hnk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
k8Hhj8Hnk8Hhj8Hnk8Hhk8Hhmr/hj8Hnk8Hhj8Hnj8Hnk8HhmIZ/7uPf////
//////fXmIZ///fX//fX4Nra3dfa3dfarp6YmIZ/k8Hhk8Hhj8Hn//fX//fX
//fX//fX2szKmIZ/////////////////////wS1MwS1MyChJyChJ2BxD////
0yBF0yBFmIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ/mIZ//vbW//fX//fX//fX
//fX//fX//fXmIZ/////////////////////////////////////wS1MwS1M
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fXmIZ/
mIZ///fX7t/I//fX//fX//fX//fX////////////mIZ/////////7uPf7uPf
7uPf3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ8uvY7ufZ
mIZ/5NnA//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfazMPE0srLuKupno2FmIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Io5GJmIZ/pMfgk8Hhk8Hhk8Hhk8Hhk8Hh
mr/hk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhmr/hj8Hnk8Hh
mr/hk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnj8Hnk8Hhmr/hmr/hk8Hhmr/hk8Hhmr/h
mr/hk8Hhj8Hnmr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhmr/hmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfa2szKm4mDmIZ/j8Hnj8Hnk8Hhk8Hh//fX
//fX//fX7t/ImIZ/mIZ/////////////////////wS1MwS1MwS1MwS1MwS1M
yChJyChJmIZ/mIZ///fX//fX//fX//fXmIZ/mIZ/mIZ/+vHT//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////wS1M
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ///fX//fXmIZ/mIZ/
//fX////////7uPf//fX////////////////////mIZ/7uPf7uPf7uPf7uPf
7t/IsaShmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z9O3YmIZ/
mIZ/7uXJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfap5eSmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Ip5aMmIZ/rcjfk8Hhj8Hnj8Hnmr/hj8Hn
mr/hj8Hnmr/hj8Hnmr/hmr/hk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhmr/hk8Hhk8Hhmr/hk8Hhj8Hnk8Hhk8Hhk8Hhmr/hk8Hhj8Hn
k8Hhk8Hhk8Hhj8Hnmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8HhmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfawrOvmIZ/k8Hhmr/hmIZ/mIZ/k8Hh//fX
//fX//fX7t/ImIZ/mIZ/////////////////////////wS1MwS1MwS1MwS1M
yChJyChJmIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/08ex//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////////////
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ///fXmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/7uPf//fX//////////////////fXmIZ/7uPf7t/I7t/I7t/I
7uPf3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/+vLT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX/PTXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfarZ6amIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IqJaMmIZ/nsHhk8Hhk8Hhk8Hhmr/hk8Hh
j8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hh
mr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hh
k8Hhmr/hk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfasKCbmIZ/mr/hmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX7t/I7t/ImIZ/mIZ/////////////////////////////////wS1M
wS1MyChJmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX6N7D//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////wS1MwS1MwS1MwS1MwS1MuwIU////////////////////mIZ/
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ///fX//fXmIZ///fX7t/I
mIZ/mIZ/mIZ/////7uPf//////////////fX//fXmIZ/7uPf7t/I7t/I7t/I
2szKt6uomIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa493ZmIZ/
oZCH//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+fDSnYyEmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IoI6GmIZ/lcHhk8Hhmr/hk8Hhk8Hhj8Hn
mr/hk8Hhmr/hk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhk8Hh
k8Hhmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8Hhmr/hj8Hnk8Hhk8Hhk8Hhmr/h
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8HhmIZ/5NjU////
////////mIZ/////////3dfa3dfan46HmIZ/k8Hhmr/hmIZ/mIZ/mIZ/mIZ/
mIZ///fX//fX7t/I7t/ImIZ/////////////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
///////////////////9////////////////////////////////mIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/3dfa////7uPfmIZ/////////7t/I7t/ImIZ/7uPf7t/I7t/I7t/I
2szKtqmmmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/9OzYmIZ/
q5uQ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXx7qnmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/nsHhk8Hhk8Hhk8Hhmr/hk8Hh
k8Hhmr/hk8Hhk8Hhmr/hmr/hk8Hhk8Hhmr/hk8Hhmr/hj8Hnj8Hnmr/hk8Hh
mr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/hmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hh
k8Hhmr/hk8Hhmr/hmr/hmr/hj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/xrWm////
////////mIZ///////fX3dfa2dPVmIZ/lcLhmr/hk8Hhmr/hlcHhmIZ/mIZ/
//fX//fX//fX//fX7t/ImIZ/mIZ/////////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////////////////////////////////////////mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/2szK2szK7uPfmIZ/7uPf7uPf7t/I7t/ImIZ/7uPf7uPf7t/I7uPf
2szKq52YmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
y76q//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
9OvNmYiAmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhj8Hnmr/hmr/hk8Hhmr/h
k8Hhmr/hmr/hk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hj8Hn
k8Hhmr/hmr/hmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhmr/hj8Hnj8Hnmr/hmr/h
k8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hmr/hmr/hmIZ/pJOJ//fX
//fX////mIZ///////fX3dfa08vNmIZ/k8Hhmr/hmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////////////////////////////////m4mDmIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/2szK7t/I7uPfmIZ/7uPf7t/I7t/ImIZ/7uPf7uPf7uPf7t/I
2szKnIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
8OfL//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
/vbXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mr/hk8Hhk8Hhmr/hj8Hnmr/h
k8Hhk8Hhj8Hnk8Hhmr/hmr/hmr/hmr/hk8Hhk8Hhmr/hmr/hmr/hk8Hhmr/h
mr/hk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/hmr/hj8Hnk8Hh
mr/hk8Hhk8Hhmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8Hhk8HhmIZ/mIZ//vbW
//fX//fXmIZ///fX//fX3dfaxrazmIZ/mr/hmIZ/mIZ///fX//fX//fXmIZ/
//fX//fX//fX//fX//fX//fX7t/I//fX////////////////////////////
////////7uPf7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/////////////////////////////////////////
////////////////////////////////+/r5////mIZ/mIZ///fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ///fXmIZ/2szK////7uPfmIZ/7uPf7t/I7t/ImIZ/7uPf7uPf7t/I7t/I
2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbX
n46GmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhmr/hmr/hk8Hho77bj8Hn
mr/hmr/hmr/hj8Hnk8Hhk8Hhk8Hhmr/hmr/hk8Hhk8Hhj8Hnmr/hk8Hhk8Hh
mr/hmr/hmr/hmr/hk8Hhmr/hmr/hmr/hk8Hho77bk8Hhk8Hhmr/hmr/hk8Hh
mr/hmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hhmr/hmr/hmr/hmr/hk8HhmIZ/29C5
//fX//fXmIZ///fX//fX3dfavKyomIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX////////////////////
////mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/////////////////////////////////////
////////////////////////////////mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fXwbOiw7Wk0MOvoI+GmIZ///fX//fX//fX//fXmIZ/mIZ/nYuD
xrmnmIZ/mIZ/mIZ/3dfa7uPfmIZ/////7t/I7t/ImIZ/7t/I7t/I7t/I7t/I
w7SwmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/moiB
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PTXmIZ/
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhk8Hhk8Hhk8Hhmr/hk8Hh
k8Hhk8Hhj8Hno77bmr/hmr/hmr/hk8Hhk8Hho77bmr/hmr/hk8Hhmr/hmr/h
k8Hhk8Hhk8Hhmr/hmr/hmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/h
k8Hhk8Hhmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hhk8Hhk8Hhk8Hhmr/hmIZ/saCU
//fX//fXmIZ///fX//fX3dfaxbWymIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX////////////////
mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa//fX//fX//fX//fX//fX//fX////////////////////////////
///////////+//75mIZ/mIZ/mIZ/mIZ///fY//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXvrCfnIuEmIZ///fX//fX//fX//fX//fXnIuFxry7
//fXn46ImIZ/mIZ/2szK7t/I7t/ImIZ/7t/I7t/ImIZ/7t/I7t/I7t/I7t/I
uqqmmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/rp6S3NC5mIZ/oI+G
//fX/vbW//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/IrJuQmIZ/mr/hmr/hmr/hmr/hk8Hhmr/h
mr/hmr/hk8Hhk8Hhmr/hk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/h
o77bmr/hk8Hhk8Hhk8Hhmr/hmr/ho77bmr/hmr/hmr/hk8Hhmr/hmr/hmr/h
mr/hk8Hhmr/ho77bk8Hhk8Hhmr/hmr/hmr/hmr/hmr/hmr/hmr/hw73EmYeA
//fX//fXmIZ///fX4tza3dfa2szKmIZ/mIZ/mIZ/mIZ/mIZ///fX3dfa//fX
//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
oY+H7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//vs//zw//3z//74
//30//jc//fY//fY//ng//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXr5+SmIZ/mIZ/3dfa//fX//fX//fXmIZ///fX3dfatKek
18/Ry8LDmIZ/mIZ/3dfa7t/I7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I7t/I2szK
r56ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/7eTI//fXmIZ/p5aL
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbXmIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/IrJuQmIZ/k8Hhk8Hhk8Hhmr/hmr/hmr/h
k8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8Hhmr/hmr/ho77bk8Hhk8Hhmr/hk8Hh
k8Hhk8Hhk8Hho77bo77bk8Hhk8Hhk8Hhk8Hhk8Hho77bmr/hmr/hk8Hhk8Hh
mr/hmr/hk8Hhk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hw73Ew73E
6trE//fXm4mBmIZ/4tza3dfa2szKmIZ/mIZ/mIZ/mIZ/mIZ/3dfa//fX//fX
//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
3c257t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX//fX//////////fX//////////fX
//fX//fX//fX//fX//fXtqeZmIZ/mIZ///fX//fX//fXmYeAmIZ///fXm4qD
0cnL2NHTqZmN3dfa3dfa2szK7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I7t/I2szK
n46ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/o5ON+/LT//fX//fXrp6S
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9O3YmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa39na5+DZ//fX//fX//fX39na3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mr/ho77bmr/hk8Hhk8Hhk8Hh
o77bk8Hhmr/ho77bk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hmr/h
mr/ho77bk8Hhk8Hho77bmr/hmr/hmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hh
k8Hhmr/hmr/hmr/hk8Hhmr/hmr/hmr/hk8Hhk8Hhmr/hk8Hhk8Hhmr/hwb7E
wrKj3dfa3dfamIZ/493Z3dfa2szKycnJycnJycnJycnJycnJycnJycnJycnJ
ycnJycnJycnJmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fXmoiAz7+u
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJ
ycnJ//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fXmIZ/mIZ///fX
ua2r29XYrZ2R3dfa3dfa2szK7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I2szK1sjG
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/uayq/PTV//fX//fXxbim
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbXmIZ/mIZ/
mIZ/3dfa3dfa3dfa3dfa3tja//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3My5mIZ/mIZ/k8Hhmr/ho77bo77bmr/hmr/h
k8Hhmr/hk8Hhk8Hho77bmr/hk8Hhmr/ho77bmr/ho77bk8Hho77bmr/hmr/h
k8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8Hho77bmr/ho77bo77bmr/hk8Hho77b
mr/ho77bmr/hk8Hhmr/hk8Hhmr/hmr/hmr/hmr/hk8Hhmr/ho77bk8Hhxr3B
moiB1s/R3dfamYeAycnJycnJycnJmIZ/k8Hhmr/hmIZ/3dfa3dfamIZ///fX
//fX//fXmIZ/ycnJycnJycnJ//fX//fX//fX//fX//fX//fX//fXx7an7N3G
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX////ycnJycnJ
ycnJycnJycnJycnJ//////////////////////////fX//fX//fX//fX//fX
////ycnJycnJycnJpZWK//fXmIZ/3dfa//fX//fX//fX//fX//fXmIZ///fX
pJWP2dLUoZCHmIZ/3dfa3dfa2szKmIZ/2szK7t/ImIZ/7t/I7t/I2szK3dfa
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/7+XJ//fX//fX//fX2c22
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7ufYmIZ/mIZ/
3dfa3dfa3dfa3dfa6uPZ//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX28u4mIZ/mIZ/mr/hk8Hhk8Hhk8Hhk8Hhk8Hh
mr/ho77bmr/hk8Hhk8Hho77bo77bk8Hhk8Hhk8Hho77bk8Hhmr/hk8Hho77b
mr/hmr/hk8Hhmr/hk8Hho77bmr/hk8Hhk8Hhk8Hhk8Hhk8Hho77bk8Hhk8Hh
k8Hhk8Hho77bo77bo77bmr/hk8Hho77bmr/ho77bk8Hhk8Hhk8Hhk8Hhwb7E
mIZ/x7enycnJycnJ6eLZ3dfa2szKmIZ/mr/ho77bmIZ/3dfamIZ/mIZ/3dfa
//fX//fXmIZ/mIZ/mIZ///fXycnJycnJ//fX//fX//fXmIZ/pZSK7N3H//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa//fX//fX//fX//fX//fX//fX//fXycnJycnJycnJ//fX////
//////////////////////fX//////////fX//////fX//fX//fX//fX//fX
//fX//////fX//fXycnJycnJycnJ3dfa//fX//fX//fX//fX9+7QmIZ/mIZ/
qZmN19DTopKMmIZ/3dfa3dfa2szKmIZ/2szK7t/ImIZ/7t/I2szK2szKn46I
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamYeA/fXW//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3dfa5t/Z//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX5NnA
mIZ/mYeA7OLH//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I1MSymIZ/mIZ/o77bmr/hmr/hmr/ho77bmr/h
mr/hk8Hhmr/hmr/ho77bk8Hhk8Hhmr/ho77bmr/hk8Hhmr/ho77bo77bk8Hh
o77bk8Hhmr/hmr/ho77bk8Hho77bmr/hmr/hmr/hmr/ho77bk8Hhmr/ho77b
mr/ho77bk8Hhk8Hhk8Hhk8Hho77bk8Hho77bk8Hho77bmr/ho77bmr/hmr/h
ycnJycnJ2cvJ7ebZmIZ/3dfa2szKmIZ/k8Hhk8HhmIZ/mIZ/mIZ/mIZ/3dfa
//fX//fX//fX//fXmIZ/mIZ///fX//fXycnJ//fXmIZ/mIZ/zb2s7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fX
//fX//////////fX//////fX//fX//////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fXmIZ/mIZ/ycnJycnJycnJmIZ///fX//fXmIZ/mIZ/
q5yY19DSpZSKmIZ/mIZ/3dfa2szKmIZ/2szK7t/ImIZ/7t/I2szKwre2mIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfaqpmO//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3tja/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX49i/
mIZ/nYyD7OLG//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IzbysmIZ/mIZ/k8Hhmr/hmr/ho77bk8Hhk8Hh
mr/hk8Hhmr/hmr/hmr/hmr/ho77bk8Hho77bmr/hmr/hk8Hhk8Hhmr/hk8Hh
o77bo77bk8Hhk8Hhmr/hk8Hho77bk8Hho77bmr/hk8Hhmr/hmr/hk8Hho77b
k8Hho77bmr/hmr/ho77bk8Hhmr/hk8Hho77bk8Hhmr/hk8Hho77bmr/hycnJ
k8HhmIZ/ybq36OLZpZWM3dfa2szKqpuXo77bo77bmIZ/mIZ/mIZ/mIZ/3dfa
//fX//fX//fX//fXmIZ/mIZ///fX//fX//fXycnJycnJvKud7t/I//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa//fX//fX//fX//fX//fXycnJ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fXmIZ/3dfa//fX//fXmIZ/ycnJycnJycnJmIZ/mIZ/
3dfa1c7QmYeAmIZ/mIZ/3dfa3dfa2szKmIZ/7t/ImIZ/3dfa2szKrqCcmIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/uquc/fXV//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa
3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX29C5
mIZ/o5KJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IxrWmmIZ/mIZ/k8Hhk8Hhk8Hhmr/ho77bmr/h
o77bo77bo77bk8Hho77bo77bk8Hhmr/hk8Hho77bo77boL3gmr/ho77boL3g
k8Hhmr/ho77boL3gmr/hmr/hk8Hho77bk8Hhk8Hhmr/ho77bo77bmr/hmr/h
mr/hk8Hhmr/ho77bmr/hmr/hmr/hmr/hmr/hmr/hk8HhoL3gmr/hycnJo77b
o77bxr3Br56S3c/Jx7uu3dfa2szKsJ+amIZ/k8HhycnJycnJycnJycnJycnJ
ycnJycnJycnJycnJycnJycnJycnJ//fXycnJmIZ/sqGV7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa//fX//fX//fX//fX//fXycnJ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/3dfa//fX//fXmIZ/mIZ///fXmIZ/ycnJycnJ
ycnJ3dfamIZ/mIZ/mIZ/3dfa3dfa2szKmIZ/7t/ImIZ/3dfa3dfam4qDmIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/noyE8+rN//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa
3dfa5d7Z//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXy76q
mIZ/qJeM//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IoI6ImIZ/o77bo77bo77bo77bo77bmr/hmr/h
mr/hmr/ho77bk8Hhk8HhoL3gmr/hmr/hk8Hhk8Hho77bk8Hhmr/hk8HhoL3g
mr/hmr/ho77bo77bmr/hoL3gmr/ho77bo77bo77bk8Hhk8Hhmr/hmr/ho77b
mr/ho77bk8Hhmr/ho77bo77bk8Hhmr/ho77bo77bo77bk8HhycnJmr/hmr/h
mr/hoL3gmIZ/69zF19DS3dfa2szKu6unycnJycnJo77bk8Hho77bmIZ/3dfa
3dfa//fX//fX//fX//fX//fX//fXycnJycnJmIZ/6dnD//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/3dfamIZ/mIZ/3dfa//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfaycnJycnJmIZ/mIZ/3dfa3dfa2szKmIZ/2szKmIZ/3dfa3dfamIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFsqKV
mIZ/rJyQ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I2sq3mIZ/mIZ/mr/hmr/hmr/hk8Hhmr/ho77bmr/h
mr/hmr/hmr/hoL3gmr/ho77bo77bo77bo77bmr/hk8Hho77bo77bo77bk8Hh
o77bmr/hk8Hhk8Hho77bk8Hho77bmr/hmr/hmr/hoL3goL3go77bk8Hhk8Hh
o77bmr/hmr/ho77bk8Hhk8Hho77bo77bmr/hk8Hhmr/hycnJmr/hmr/hk8Hh
mr/ho77bmr/huqmc3dfaopKNycnJycnJmIZ/o77bmr/hmr/hmr/hmIZ/mIZ/
3dfa3dfaycnJycnJycnJycnJycnJycnJycnJuqmc7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXo5KImIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/3dfa//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/3dfa3dfa3dfa
3dfa3dfamIZ/ycnJmIZ/3dfa3dfamIZ/2szK2szKmIZ/3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFnIqC
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/Ivq2fmIZ/mIZ/o77bmr/hmr/ho77bk8Hhmr/hmr/h
o77bk8Hho77bo77bk8Hhk8Hhmr/hmr/ho77bo77bmr/hk8Hhmr/ho77bmr/h
k8Hho77bo77bmr/ho77bmr/hmr/ho77bk8Hho77bo77bk8Hho77boL3gmr/h
mr/ho77bk8Hho77bo77bmr/hmr/hk8Hho77bo77bk8Hho77bk8Hho77bo77b
k8Hhk8Hho77bmIZ/1cfEycnJmYeA2MrImIZ/o77bo77bk8Hho77bo77bycnJ
ycnJycnJ//fX//fX//fX//fX//fXmIZ/mIZ/r56S7t/I//fX//fX//fX3dfa
mIZ/mIZ/xrim//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fXycnJycnJycnJycnJycnJycnJycnJycnJ
//fXmoiAmIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX3dfa
mIZ/mIZ///fX//fX//fX//fX//fX4dK9uqqcmIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfamIZ/3dfaycnJycnJ3dfamIZ/2szKmIZ/3dfa3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3tja
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/InYuEmIZ/mIZ/o77bk8Hho77bo77bo77bk8Hhmr/h
mr/ho77bk8Hhmr/ho77bo77bmr/ho77bmr/hmr/hk8Hho77bo77bk8Hho77b
o77bmr/hk8Hho77bk8Hho77bk8Hho77bo77bmr/hk8Hho77bo77bo77bk8Hh
o77bmr/ho77bk8Hho77bk8Hho77bo77bo77bmr/ho77bk8Hho77bo77bmr/h
o77bo77bmr/hycnJycnJ2szKoJCK2szKnYyFk8Hhmr/ho77bycnJycnJmIZ/
mIZ/3dfa3dfa//fX//fX//fX//fX//fXmIZ/7t/I7t/I//fX//fX//fX3dfa
3dfamIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fXrJuQmIZ/
ycnJycnJycnJmIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX3dfamIZ/
//fX//fX//fX//fX//fX7t/I7t/I4dG9oI+GmIZ/3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/mIZ/3dfa3dfamIZ/ycnJmIZ/2szKmIZ/3dfamIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhk8Hho77bmr/hk8Hhmr/ho77bo77b
mr/ho77bo77bmr/hmr/ho77bk8Hho77bo77bo77bo77bk8Hho77bmr/hmr/h
o77bo77bmr/ho77bo77bo77bk8Hhk8Hho77bo77bmr/hk8Hhk8Hho77bo77b
k8Hho77bo77bmr/ho77bo77bk8Hhmr/ho77bmr/ho77bmr/hk8Hhk8Hhmr/h
mr/ho77bycnJmr/hmIZ/2szKyb+/0cnKnoyFo77bmr/hycnJo77bk8Hhmr/h
mIZ/3dfa3dfa//fX//fX//fX//fX//fXmIZ/2Mm27t/I//fX//fX//fX//fX
3dfa3dfamIZ/mIZ/mIZ///fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/InYuD
mIZ/mIZ/7t/IycnJycnJ7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IrZyRmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfa3dfamIZ/3dfaycnJ3dfamIZ/3dfamIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/IpZaSmIZ/mIZ/o77bmr/ho77bo77bo77bk8Hhmr/hmr/h
o77bmr/hmr/ho77bo77bmr/ho77bmr/hmr/hmr/hmr/ho77bmr/ho77bmr/h
mr/hmr/ho77bmr/hmr/hmr/ho77bo77bmr/hmr/ho77bo77bo77bmr/hmr/h
o77bmr/hmr/ho77bmr/hmr/ho77bo77bmr/ho77bmr/ho77bo77bo77bo77b
o77bmr/hmr/ho77bmIZ/mIZ/tqah3dfamIZ/ycnJycnJmr/hmr/ho77bo77b
mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fXmIZ/y7uq7t/I//fX//fX//fX//fX
//fX//fX3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IpJOK
mIZ/7t/I7t/I7t/I//fXycnJycnJ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IxrmnmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfa3dfamIZ/3dfamIZ/ycnJycnJmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/6N3D//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX2su3m4mDmIZ/mIZ/mr/ho77bmr/hk8Hhmr/ho77bo77bo77b
o77bo77bmr/hmr/ho77bmr/ho77bo77bo77bo77bmr/ho77bmr/ho77bo77b
o77bk8Hho77bmr/ho77bmr/hmr/ho77bo77bk8Hhmr/hmr/ho77bo77bmr/h
mr/ho77bmr/ho77bk8Hho77bmr/ho77bk8Hho77bk8HhoL3gmr/hmr/hmr/h
o77bo77bmr/hmr/ho77bmIZ/mIZ/mIZ/ycnJmIZ/o77bk8Hhmr/hmr/hmr/h
o77bmIZ/mIZ/3dfa3dfa3dfa3dfa//fX3dfam4mC6tvF7t/I//fX//fX//fX
//fX//fX//fX3dfa3dfamIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IoI6G
mIZ/7t/I7t/I//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/Is6OWmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/3dfa3dfa3dfa3dfamIZ/3dfamIZ/mIZ/2szKycnJycnJ3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/5dvB//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa6uPZ//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/IrqGhmIZ/mIZ/o77bmr/ho77bo77bo77bmr/hmr/hmr/ho77b
mr/hmr/ho77bk8Hho77bo77bmr/hk8Hho77bk8Hho77bo77bo77bo77bk8Hh
o77bo77bo77bo77bmr/ho77bo77bo77bmr/ho77bo77bo77bo77bmr/ho77b
o77bmr/ho77bmr/ho77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77b
mr/hk8Hho77bo77bmr/ho77bmIZ/ycnJmIZ/mIZ/o77bo77bo77bo77bo77b
mr/ho77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/uqqc7t/I//fX//fX//fX
//fX//fX//fX//fX3dfamIZ/2szK2szK//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I0MCumIZ/
mIZ/7t/I//fX//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX
//fX7t/I7t/I//fXr6CTmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
3dfa3dfa3dfa3dfa3dfamIZ/3dfamIZ/mIZ/mIZ/2szK3dfaycnJ3dfa3dfa
3dfa29TX3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/u6yd//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa/fXX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX28+4taWYmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3My5oZCLmIZ/mr/ho77bo77bmr/ho77bo77bo77bo77bo77bmr/h
o77bo77bo77bmr/hmr/ho77bo77bmr/ho77bmr/hmr/ho77bk8Hho77bmr/h
o77bk8Hhmr/ho77bmr/ho77bk8Hho77bo77bo77bo77bmr/ho77bo77bo77b
o77bmr/ho77bo77bo77bk8Hho77bo77bo77bo77bo77bmr/ho77bo77bk8Hh
o77bmr/hmr/ho77bo77bmr/hycnJmr/hmIZ/mIZ/mIZ/o77bk8Hhmr/ho77b
o77bk8Hhmr/hmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/o5KI7t/I7t/I//fX
//fX//fX7t/I7t/I7t/ImIZ/2szK2szK7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXycnJycnJycnJ//fX//fX//fX7t/Iq5qPmIZ/
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXycnJ//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfaycnJ3dfa
3dfaua2rwLSzyL+/zcTF3dfa3dfa3dfa3dfamIZ/p5eM//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa6OLZ//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXv7GgmIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I1cWzmoeAmIZ/mr/ho77bk8Hho77bmr/ho77bo77bk8Hho77bmr/h
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
mr/ho77bo77bo77bo77bo77bo77bo77bmr/hmr/hmr/ho77bo77bk8Hho77b
o77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/hmr/ho77bmr/ho77bo77b
o77bo77bo77bmr/hmr/hycnJo77bo77bo77bmIZ/mIZ/mr/ho77bo77bo77b
mr/ho77bo77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamIZ/saCU7t/I7t/I
7t/I7t/I7t/IxbWlmIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXycnJycnJ7t/I7t/ImIZ///fX
7t/I//fX//fX//fX//fX//fX//fX//fX//fX9OfN7t/I7t/IycnJ//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/3dfa2szK3dfa3dfa3dfaycnJ
mIZ/mIZ/mIZ/oJCKoJCKmIZ/3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa/PTX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXx7qnn46FopGI//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/Iv6+gmIZ/mIZ/o77bo77bo77bmr/ho77bmr/hmr/ho77bo77bo77b
o77bo77bo77bo77bmr/hmr/hmr/hmr/ho77bo77bmr/ho77bmr/hmr/ho77b
o77bo77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77bo77bmr/hoL3g
o77bk8Hho77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/ho77bo77b
o77bo77bo77bo77bycnJo77bo77bo77bo77bo77bo77bo77bo77bmr/ho77b
o77bo77bmr/ho77bo77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/taSYy7ur
0sKw7t/Ip5WMmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IycnJmYeAmIZ///fX
//fX//fX//fX//fX//fX//fX+e7R9+vQ8eTL7t/I7t/I7t/ImIZ/ycnJ//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa2szK3dfa3dfa3dfa3dfa
ycnJmIZ/mIZ/uKmanoyEmIZ/mIZ/mIZ/3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/3dfa5+HZ//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6d/EqZiNpZWK//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/InYuDmIZ/xr3Bmr/ho77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bk8Hho77bo77bo77bo77bo77bo77bmr/hmr/ho77bo77bo77bo77bo77b
o77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bmr/hmr/ho77bo77bo77b
mr/ho77bo77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77b
mr/hmr/hmr/hycnJo77bo77bo77bmr/ho77bmr/ho77bo77bmr/ho77bo77b
mr/ho77bo77bo77bmr/ho77bmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/7uPfmIZ/mIZ/7uPfmIZ/mIZ/mIZ/7t/I7t/I7t/I7t/I
7t/I7t/I//fX//fX//fX//fX//fX//fX//fX7t/IqZiOmIZ/ycnJ//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R9+zQ7t/ImIZ/mIZ/mIZ/3dfaycnJ
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa2szK3dfa3dfa3dfa3dfa
3dfaycnJmoiB19DS/fXW//fX//fXmIZ/mIZ/mIZ/mIZ/5NrA//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa+fLX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXuKmbppaLzsGt//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/IsJ+TmIZ/xr3Bmr/ho77bo77bo77bo77bo77bo77bmr/ho77bo77bmr/h
o77bmr/ho77bo77bo77bo77bo77bo77bo77bmr/hmr/ho77bmr/hmr/hmr/h
mr/ho77bo77bo77bo77bmr/ho77bmr/ho77bo77bo77bmr/ho77bo77bo77b
o77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/hmr/ho77bmr/hmr/ho77b
o77bo77bo77bo77bmr/hmr/ho77bmr/ho77bo77bmr/ho77bo77bo77bo77b
o77bo77bmr/ho77bo77bmr/ho77bpcDbmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfamIZ/7uPf7uPf7uPfmIZ/mIZ/7uPf7uPf7uPfmIZ/mIZ/mIZ/mIZ/mIZ/
7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ///fX//fXycnJ//fX
//fX//fX//fX+e7R+e7R+O7R9+zQ8+bN7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/xLal/fTV//fX//fXw7WkmIZ/mIZ/sqOV//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/49za//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7uTJmoiA1Miy//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/InYuDmIZ/xr3Bo77bmr/ho77bmr/ho77bmr/ho77bmr/hmr/ho77bo77b
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bmr/ho77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bo77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77b
oL3go77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
mr/hmr/ho77bo77bo77bo77bo77bmr/ho77bmIZ/mIZ/3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/////////////mIZ/////////7uPf7uPf7uPfmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I//fX//fX//fXycnJ//fX
//fX//fX//fX+e7R9uvP8uXMmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3NbZ3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/uaqb//fX/vbW9+7Q//fXmIZ/nYyD/fXV//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX493ZmIZ/mIZ/3dfa8uvY//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXqZmO//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/ImIZ/mIZ/o77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77b
o77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bmr/hmr/ho77bo77bo77bo77boL3go77bo77bo77bo77boL3go77bo77b
o77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77bo77boL3go77b
oL3go77bo77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bmr/ho77bo77b
o77bo77boL3gmr/ho77bo77bo77bo77bo77bo77bmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfamIZ/////////////mIZ/mIZ/////////////////////////7uPf
mIZ///fX//fX//fX//fX//fX//fX7t/I//fX//fX//fX//fX//fX//fXycnJ
//fX//fX//fX8+bM7t/ImIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/mIZ/uaqb//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX/vbXmIZ/mIZ/3dfa4Nra//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7uTJno2E//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/ImIZ/o77bmr/ho77bmr/ho77bo77bo77boL3go77bo77bo77boL3go77b
o77bo77bo77bo77bo77bo77bo77boL3go77bo77bo77bo77boL3go77bo77b
o77bo77bo77boL3go77bo77bo77bo77bo77boL3go77bo77bo77bo77bo77b
oL3go77bo77bmr/ho77bo77bo77bmr/ho77bo77bmr/ho77bo77bo77bo77b
o77bo77boL3go77bo77bo77bo77bo77boL3go77bo77bmr/ho77bo77bo77b
o77bo77bo77bo77bo77boL3go77boL3go77bo77bo77bmIZ/mIZ/3dfa3dfa
3dfa3dfamIZ/mIZ/////////////mIZ/////////////////////mIZ/mIZ/
//fX//fX//fX//fX//fX//fX7t/I//fX//fX//fX//fX//fX//fX//fX//fX
ycnJ//fX8OLK7t/ImIZ/mIZ/2szKmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa29XY3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfawbSrmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+/TXmIZ/mIZ/3dfa7ebZ//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
7t/ImIZ/o77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bo77b
o77boL3go77bo77bo77bo77bo77bo77bqrvboL3go77bqrvbo77bo77bo77b
o77bo77bo77boL3go77bo77bo77bo77bo77bo77boL3go77bo77boL3go77b
oL3go77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bqrvbo77b
oL3go77bo77bo77boL3go77bo77bo77bo77bo77bo77bqrvbo77bo77bo77b
o77bo77bo77bo77bo77bo77bo77boL3go77boL3go77bo77bmIZ/mIZ/3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/////////////////////////mIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
9+zQycnJmIZ/mIZ/3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfano2HmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX/vbXmIZ/mIZ/3dfa+vLX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/mIZ/o77boL3go77bo77bo77boL3go77bo77bo77bo77bo77boL3go77b
o77bo77bo77bo77bo77bo77bo77boL3goL3go77bo77bo77bo77bo77bo77b
o77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77brbzVo77b
o77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvboL3go77bqrvbo77bo77b
o77bo77bo77bo77bo77bo77bo77bo77bo77boL3gqrvbo77bo77bo77bqrvb
o77bo77bqrvbo77bo77bo77bo77bqrvboL3go77bo77bo77boL3gmIZ/mIZ/
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/////////////mIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R9urP9urP
7+HJycnJmIZ/3dfa3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szK3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfauq6smIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/o77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bqrvbo77bo77bqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bo77b
o77bo77bo77bo77bo77bqrvbqrvbo77bo77bo77bqrvbo77bo77bqrvbo77b
o77bo77bo77bo77bqrvbqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77b
o77bo77bo77bo77bo77bo77bo77bqrvbo77bqrvbo77bo77bo77bo77bmIZ/
mIZ/3dfa3dfa3dfa3dfa//fXmIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9+zQ7t/I7uDImIZ/
mIZ/mIZ/ycnJ3dfa3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa4tza
8+zY//fX//fX39HJmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfappeSmIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/o77bqrvbqrvbo77bo77bo77bqrvbqrvbqrvbqrvbo77bqrvbqrvbo77b
qrvbo77bo77bo77bo77bqrvbo77bo77bqrvbqrvbo77bo77bqrvbo77bo77b
o77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bo77b
qrvbqrvbqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
qrvbo77bqrvbo77bqrvbo77bo77bo77bo77bo77bo77bo77bpcDbsb/bqcLb
mIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa7t/ImIZ/3dfa3dfa3dfa3dfa3dfa5d7Z/vbX
//fX//fX//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfawba1moiAmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/vbXmIZ/mIZ/mIZ/3tja//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/qrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
qrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77bo77b
qrvbo77bo77bqrvbo77bqrvbqrvbqrvbqrvbqrvbo77bo77bo77bqrvbqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77b
o77bo77bqrvbo77bo77bqrvbqrvbo77bo77bo77bo77bo77bo77bqrvbo77b
o77bo77bo77bo77bo77bo77bo77bqrvbo77bo77bssDbo77bpcDbo77btMHb
qcLbmIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa//fX7t/ImIZ/3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa0cnKtKWXmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/PTXmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
o77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bqrvbo77bo77bqrvbo77b
rbzVqrvbo77bo77bo77brbzVqrvbo77bo77bqrvbqrvbo77bo77bo77bqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77bo77b
qrvbo77bqrvbo77brbzVo77bqrvbqrvbo77bo77bqrvbo77bqrvbo77brbzV
o77bo77brbzVo77bo77bo77bo77bqrvbqrvbqrvbqrvbo77bqrvbo77bo77b
o77bo77bqrvbo77bqrvbqrvbo77bo77bqrvbrL3bo77brL3bo77bqrvbp8Db
qrvbxNDamIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX7t/ImIZ/3dfa3dfa4Nra//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa1s/Rwri3mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+fHYmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
o77bo77bo77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvb
o77bqrvbo77bqrvbo77bo77bqrvbo77bo77bo77bqrvbrbzVqrvbo77bo77b
o77bqrvbo77bqrvbo77bo77bo77bo77bo77bo77brbzVqrvbrbzVo77bo77b
o77bo77bqrvbo77bqrvbo77bo77brbzVqrvbo77bqrvbo77brbzVoL3go77b
o77boL3go77bqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77brbzV
qrvbo77bqrvbo77bo77bqrvbo77brbzVo77brbzVo77brr3bo77bo77bo77b
o77bmIZ/mIZ/3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX7t/ImIZ/3dfa5uDZ+/PX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa1MzO08vMnYyDmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+PDYmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
rbzVqrvbqrvbo77bo77bqrvbo77bqrvbqrvbrbzVqrvbqrvbo77bo77bo77b
o77brbzVqrvbo77bo77brbzVrbzVqrvbqrvbqrvbo77bo77brbzVqrvbrbzV
rbzVo77bqrvbo77brbzVrbzVqrvbqrvbqrvbrbzVo77brbzVo77bqrvbqrvb
qrvbo77bo77bo77bo77bo77bo77boL3grbzVqrvbo77bo77bo77brbzVqrvb
qrvbrbzVqrvbo77bqrvbrbzVrbzVqrvbqrvbo77bo77bqrvbqrvbqrvbqrvb
o77bo77bo77brbzVo77brbzVqrvbo77bo77bo77brr3bpcDbrbzVqrvbqrvb
vcjbmIZ/mIZ/3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX7t/ImIZ/3tja//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfas6SWmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+vLXmIZ/xLm53dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/o77b
o77brbzVo77bo77brbzVo77bqrvbo77brbzVo77bo77bo77bqrvbo77bqrvb
o77brbzVo77bqrvbo77bo77brbzVrbzVo77brbzVo77bo77bo77bqrvbqrvb
qrvbo77bo77boL3gqrvbo77brbzVo77bo77bqrvbo77bqrvbo77brbzVrbzV
qrvbqrvbqrvbqrvbqrvbqrvbrbzVo77brbzVqrvbqrvbo77bo77bo77bo77b
o77bo77bqrvbrbzVqrvbo77brbzVo77bqrvbo77bo77bo77bo77bo77bqrvb
qrvbrbzVo77bqrvboL3grbzVo77bqrvbqrvbpcDbr77VpcDbrbzVo77brr3b
mIZ/mIZ/3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa//fX//fX//fX//fX7t/ImIZ/7OXZ//fX//fX7t/I//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfawLSzmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/w7i33dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/qrvb
o77bo77brbzVo77bqrvbo77bqrvbo77bo77brbzVo77bo77bqrvbrbzVo77b
o77bo77brbzVqrvbqrvbqrvbo77bo77brbzVqrvbqrvbqrvbrbzVo77bo77b
o77bo77brbzVrbzVo77bqrvbo77bqrvbo77bo77bqrvbo77brbzVo77bo77b
o77bo77bo77bo77bqrvbrbzVo77bqrvbo77brbzVo77bqrvbqrvbqrvbrbzV
qrvbrbzVrbzVo77bo77bqrvbo77bqrvbqrvbrbzVqrvbqrvbqrvbqrvbrbzV
rbzVo77bqrvbrbzVrbzVo77bqrvbo77bo77bsb7Vo77bqrvbo77bpcDbmIZ/
mIZ/mIZ/3dfa2szK2szK2szK7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX7t/ImIZ/+fLY//fX//fX7t/I7t/I7t/I7t/I
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfay8LCmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvb
qrvbqrvbqrvbqrvbo77bqrvbo77bqrvbqrvbo77bqrvbrbzVqrvbo77bqrvb
qrvbqrvbrbzVo77bo77bo77bqrvbo77bo77bo77bo77bo77bqrvbqrvbrbzV
rbzVqrvbqrvbqrvbrbzVo77brbzVqrvbqrvbo77bqrvbo77bqrvbqrvbqrvb
rbzVrbzVrbzVrbzVo77bqrvbo77bqrvbo77brbzVo77bo77bo77bo77bo77b
qrvbo77bqrvbqrvbo77bqrvbrbzVrbzVo77brbzVrbzVrbzVo77bo77bo77b
qrvbo77bo77bqrvbqrvbo77brbzVqrvbqrvbtcLbpcDbqrvbmIZ/mIZ/mIZ/
//fX//fX//fX3dfa2szK3dfa3dfamIZ/2szK3dfamIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX7t/ImIZ/7d7I7t/I//fX//fX7t/I7t/I7t/I
//fX7t/I//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfaz8bHmIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/ImIZ/xr3Bo77b
o77bo77bo77brbzVo77brbzVo77bqrvbqrvbrbzVqrvbrbzVqrvbrbzVqrvb
o77bo77bo77bqrvbqrvbqrvbo77bqrvbqrvbrbzVqrvbqrvbqrvbrbzVo77b
qrvbo77bo77bo77bo77bqrvbo77bo77brbzVrbzVrbzVqrvbo77bo77brbzV
qrvbqrvbqrvbo77bqrvbo77bqrvbo77bqrvbqrvbrbzVrbzVrbzVqrvbqrvb
o77bqrvbo77bo77bqrvbo77bo77bo77bqrvbo77bo77bo77brbzVqrvbqrvb
o77brbzVqrvbOV41Qmw9Qmw9OV41OV41OV41o77brL3bq8LbmIZ///fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa2szK2szK2szK2szK
2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ//vbXmIZ/7t/I7t/I7t/I7t/ImIZ/
7t/I7t/I//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfazcXFmIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/qrvbqrvb
rbzVqrvbrbzVqrvbrbzVqrvbqrvbrbzVo77bqrvbo77bo77bo77bo77bo77b
qrvbqrvbrbzVrbzVqrvbrbzVqrvbrbzVqrvbrbzVqrvbrbzVo77bqrvbo77b
qrvbqrvbrbzVqrvbrbzVqrvbrbzVo77bo77bo77bqrvbrbzVqrvbo77bo77b
o77bo77bqrvbo77bqrvbrbzVrbzVo77bo77bqrvbqrvbqrvbo77brbzVqrvb
o77brbzVrbzVrbzVrbzVqrvbqrvbqrvbqrvbqrvbqrvbqrvbo77bo77bqbvR
prvXQmw9Qmw9UJhVUJhVUJhVUJhVQmw9Qmw9Qmw9OV41OV41OV41OV41//fX
//fXz9Kw//fX//fX3dfa3dfa6+TZmIZ/6uPZ3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z7ufZ//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/7t/I7t/I7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/rbzVqrvb
rbzVqrvbo77bqrvbo77brbzVo77brbzVo77bqrvbqrvbqrvbqrvbrbzVqrvb
rbzVqrvbo77bo77brbzVo77brbzVqrvbqrvbo77brbzVo77bqrvbqrvbqrvb
rbzVrbzVqrvbqrvbqrvbqrvbqrvbqrvbqrvbqrvbo77bqrvbrbzVqrvbqrvb
rbzVqrvbqrvbrbzVrbzVo77bqrvbrbzVrbzVo77bo77bqrvbrbzVqrvbqrvb
qrvbqrvbqrvbo77bo77brbzVrbzVrbzVqrvbrbzVrbzVo77brbzTOV41OV41
Qmw9Qmw9UJhVUJhVUJhVUJhVUJhVUJhVUJhVUJhVQmw9Qmw9Qmw9Qmw9OV41
SmtDtr+bZTwhZTwhZTwhZTwhZTwhZTwh//fX5tjI3tja3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa39na5d7Z7ebZ9O3Y//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/o77bqrvbo77b
o77bo77brbzVo77bqrvbo77bqrvbqrvbqrvbqrvbqrvbrbzVrbzVqrvbrbzV
rbzVqrvbqrvbo77brbzVo77bo77brbzVqrvbo77brbzVo77brbzVrbzVqrvb
qrvbqrvbrbzVo77brbzVqrvbrbzVqrvbrbzVrbzVo77bqrvbrbzVqrvbqrvb
rbzVrbzVqrvbo77bqrvbo77bqrvbqrvbrbzVrbzVrbzVqrvbo77brbzVrbzV
qrvbqrvbqrvbqrvbo77bo77bo77brbzVo77bo77bq7zROV41OV41Qmw9Qmw9
UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVUJhVUJhV
UJhVOV41O1gyTSobXDQjXDQjXDQjZTwhZTwh7t/I7t/I/PTX+PDY9e3Y8+vY
8erY8OnY7+jY8erY9e3Y+PDY+vLX+fHY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/ZTwhmIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVqrvb
rbzVqrvbrbzVrbzVqrvbqrvbo77brbzVrbzVrbzVo77bqrvbo77bo77bqrvb
o77brbzVrbzVrbzVqrvbrbzVsrnVo77brbzVqrvbqrvbrbzVqrvbqrvbqrvb
qrvbrbzVo77bqrvbo77bo77bqrvbrbzVqrvbqrvbrbzVrbzVqrvbrbzVqrvb
qrvbqrvbrbzVqrvbqrvbsrnVqrvbqrvbqrvbqrvbo77bqrvbrbzVo77bqrvb
o77brbzVrbzVrbzVqrvbqrvbqrvbqrvbqrvbOV41OV41Qmw9Qmw9UJhVUJhV
UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVOV41OV41TSobXDQjXDQjZTwhZTwhZTwh7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/Ik3FdZTwhZTwhZTwhZTwhZTwhmIZ/mIZ/mIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/rbzVqrvbrbzV
qrvbqrvbqrvbqrvbrbzVrbzVrbzVqrvbqrvbo77brbzVqrvbrbzVqrvbrbzV
qrvbqrvbqrvbqrvbqrvbo77bqrvbqrvbrbzVrbzVqrvbqrvbqrvbrbzVrbzV
qrvbsrnVrbzVqrvbsrnVrbzVqrvbo77brbzVsrnVoL3gqrvbqrvbrbzVrbzV
o77bqrvbrbzVrbzVo77brbzVrbzVqrvbrbzVsrnVrbzVqrvbqrvbqrvbrbzV
qrvbqrvbqrvbrbzVrbzVrbzVo77brbzVOV41Qmw9UJhVUJhVUJhVUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjZTwhZTwhk3Fd7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/Ik3Fdk3Fdk3FdZTwhZTwhTSobTSobTSobZTwhZTwhZTwh3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/fXXmIZ/2szK3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/o77brbzVqrvbqrvb
o77brbzVo77bqrvbqrvbqrvbrbzVo77bsrnVsrnVrbzVqrvbqrvbqrvbqrvb
qrvbrbzVqrvbrbzVqrvbqrvbrbzVqrvbsrnVqrvbrbzVqrvbrbzVqrvbqrvb
o77bqrvbqrvbrbzVqrvbqrvbo77bsrnVqrvbqrvbsrnVrbzVrbzVqrvbqrvb
srnVqrvbsrnVqrvbsrnVqrvbqrvbrbzVqrvbo77bqrvbrbzVrbzVrbzVsrnV
rbzVrbzVqrvbqrvbqrvbqrvbsrnVOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVOV41OV41OV41TSobXDQjXDQjXDQjXDQjZTwhZTwhk3Fd7t/I
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/IZTwhZTwhZTwhXTYkXTYkVDIiTSobTSobTSobTSobXDQjXDQjOV41OV41
OV41OV41OV41OV41OV41OV41OV41OV41OV41OV41SWpCQHRBRYJJO2M4OV41
OV41Qmw9OV41OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/fXXmIZ/2szK3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVqrvbqrvbrbzV
rbzVqrvbrbzVrbzVqrvbrbzVo77brbzVqrvbqrvbqrvbqrvbrbzVo77brbzV
qrvbrbzVqrvbrbzVrbzVqrvbrbzVqrvbqrvbqrvbrbzVqrvbrbzVqrvbsrnV
qrvbrbzVsrnVqrvbqrvbsrnVqrvbqrvbqrvbqrvbqrvbqrvbrbzVqrvbqrvb
rbzVqrvbqrvbqrvbqrvbrbzVqrvbrbzVsrnVqrvbqrvbrbzVqrvbqrvbqrvb
qrvbrbzVqrvbrbzVqrvbo77bOV41OV41UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQjZTwhZTwhk3Fd
k3Fd7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fXZTwh
ZTwhZTwhYzwrXjYlZj8uXDQjTSobTSobTSobTSobTSobOV41OV41UaheOV41
OV41OV41OV41OV41PWw9O2U5QHNBSY9QS5VUT6FaT6JaTJlWSI1PUaheUahe
UaheUJhVUJhVQmw9OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/vbXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVsrnVqrvb
qrvbrbzVqrvbrbzVqrvbrbzVsrnVqrvbqrvbrbzVrbzVqrvbsrnVqrvbqrvb
rbzVqrvbrbzVqrvbqrvbrbzVqrvbqrvbrbzVrbzVrbzVrbzVqrvbrbzVqrvb
rbzVqrvbo77brbzVrbzVqrvbrbzVrbzVrbzVrbzVqrvbrbzVqrvbrbzVrbzV
qrvbqrvbrbzVqrvbrbzVo77brbzVqrvbqrvbrbzVrbzVqrvbrbzVqrvbqrvb
qrvbqrvbrbzVqrvbrbzVsrnVOV41Qmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQjZTwhZTwh
ZTwhZTwhk3Fdk3Fd7t/I7t/I7t/I//fX7t/Ik3Fdk3FdZTwhZTwhZTwhZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobOV41OV41OV41UaheUahe
UaheUaheUaheUaheUaheUaheT6JbT6NbUadeUadeUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQmw9Qmw93dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/rbzVqrvbqrvbrbzV
rbzVsrnVrbzVqrvbqrvbsrnVqrvbrbzVrbzVqrvbsrnVrbzVqrvbrbzVrbzV
srnVqrvbrbzVrbzVsrnVqrvbrbzVqrvbsrnVqrvbqrvbrbzVqrvbrbzVqrvb
qrvbsrnVqrvbqrvbrbzVqrvbqrvbqrvbqrvbrbzVqrvbqrvbqrvbqrvbqrvb
rbzVsrnVrbzVqrvbsrnVqrvbsrnVrbzVqrvbsrnVqrvbqrvbrbzVrbzVrbzV
rbzVsrnVsrnVqrvbqrvbqrvbOV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhXDQjXDQj
XDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobOV41OV41OV41UaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9Qmw93dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/2szK2szK3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbqrvbsrnVqrvb
qrvbqrvbqrvbrbzVqrvbqrvbqrvbqrvbqrvbqrvbsrnVrbzVqrvbqrvbqrvb
rbzVrbzVqrvbqrvbqrvbrbzVqrvbrbzVqrvbqrvbqrvbsrnVrbzVqrvbrbzV
rbzVqrvbrbzVrbzVqrvbrbzVsrnVqrvbqrvbqrvbqrvbrbzVrbzVrbzVrbzV
qrvbqrvbqrvbrbzVqrvbrbzVqrvbqrvbqrvbqrvbrbzVrbzVqrvbqrvbsrnV
qrvbqrvbqrvbrbzVqrvbrbzVOV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjTSobTSobTSobTSobOV41OV41OV41UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9Qmw9OV413dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/rbzVrbzVqrvbqrvb
rbzVsrnVrbzVsrnVqrvbrbzVrbzVrbzVrbzVqrvbqrvbqrvbrbzVsrnVrbzV
srnVsrnVsrnVrbzVsrnVrbzVsrnVrbzVrbzVsrnVqrvbsrnVsrnVsrnVsrnV
rbzVsrnVsrnVrbzVsrnVqrvbrbzVsrnVsrnVsrnVsrnVqrvbqrvbsrnVrbzV
rbzVsrnVsrnVrbzVsrnVrbzVrbzVrbzVqrvbsrnVsrnVrbzVsrnVqrvbsrnV
rbzVrbzVsrnVrbzVqrvbOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSob
TSobTSobTSobTSobTSobTSobOV41OV41OV41UaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9Qmw9OV413dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVrbzVrbzVqrvb
qrvbsrnVqrvbrbzVqrvbqrvbqrvbsrnVrbzVrbzVsrnVsrnVqrvbsrnVqrvb
qrvbqrvbqrvbsrnVqrvbsrnVqrvbqrvbsrnVrbzVrbzVqrvbqrvbqrvbqrvb
srnVqrvbqrvbsrnVqrvbrbzVsrnVrbzVqrvbrbzVqrvbsrnVsrnVqrvbsrnV
qrvbrbzVqrvbsrnVqrvbqrvbsrnVsrnVsrnVqrvbqrvbsrnVqrvbrbzVrbzV
qrvbsrnVqrvbsrnVrbzVOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUaheOV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobOV41OV41OV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVUJhVQmw9OV41OV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVsrnVsrnV
rbzVqrvbqrvbsrnVsrnVrbzVrbzVqrvbsrnVqrvbrbzVqrvbrbzVqrvbsrnV
rbzVrbzVqrvbrbzVqrvbsrnVsrnVqrvbsrnVsrnVrbzVrbzVrbzVsrnVqrvb
srnVrbzVqrvbrbzVqrvbqrvbsrnVrbzVsrnVsrnVrbzVrbzVrbzVqrvbsrnV
qrvbrbzVsrnVrbzVsrnVqrvbqrvbrbzVqrvbsrnVqrvbrbzVsrnVsrnVrbzV
qrvbsrnVqrvbsrnVqrvbOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9OV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobOV41OV41TSobOV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheQmw9Qmw9
Qmw9Qmw9UJhVUJhVUaheUaheUaheUaheUJhVUJhVQmw9OV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVrbzVsrnV
srnVsrnVqrvbrbzVsrnVsrnVrbzVqrvbsrnVqrvbrbzVsrnVrbzVrbzVsrnV
srnVsrnVsrnVsrnVrbzVrbzVqrvbsrnVqrvbqrvbsrnVsrnVsrnVqrvbsrnV
rbzVsrnVsrnVsrnVsrnVrbzVqrvbsrnVqrvbrbzVsrnVsrnVsrnVrbzVrbzV
srnVqrvbqrvbsrnVqrvbrbzVrbzVsrnVsrnVrbzVsrnVsrnVsrnVqrvbsrnV
srnVqrvbrbzVqrvbsrnVOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQj
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobOV41OV41OV41OV41
OV41OV41OV41OV41OV41PGc6UaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9Qmw9UJhVQmw9
UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUJhVUJhVUJhVOV41OV413dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnVsrnVqrvb
qrvbrbzVrbzVsrnVqrvbqrvbsrnVrbzVrbzVsrnVsrnVqrvbsrnVsrnVqrvb
srnVqrvbsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnV
qrvbrbzVqrvbrbzVsrnVsrnVqrvbrbzVsrnVqrvbqrvbrbzVsrnVsrnVrbzV
srnVsrnVqrvbsrnVsrnVsrnVqrvbrbzVsrnVrbzVqrvbqrvbsrnVqrvbrbzV
rbzVsrnVsrnVqrvbqrvbOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQj
TSobTSobTSobTSobOV41OV41OV41OV41OV41OV41OV41OV41OV41UaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVSYVLO2U5OV41
OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVqrvbsrnVrbzV
srnVsrnVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnVrbzVsrnVqrvbrbzVsrnV
qrvbsrnVqrvbsrnVqrvbsrnVsrnVqrvbqrvbqrvbsrnVqrvbrbzVsrnVqrvb
srnVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVsrnVrbzVrbzVsrnV
rbzVrbzVsrnVrbzVsrnVqrvbsrnVsrnVqrvbsrnVsrnVrbzVrbzVsrnVsrnV
srnVqrvbrbzVsrnVsrnVOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41TSobTSobXDQjXDQjXDQjXDQjTSob
TSobTSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVT5ZUOmE3
OV41OV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVrbzVsrnV
qrvbsrnVqrvbrbzVrbzVsrnVsrnVqrvbsrnVqrvbsrnVqrvbsrnVsrnVrbzV
rbzVsrnVqrvbsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVqrvbsrnVrbzV
qrvbrbzVqrvbsrnVsrnVrbzVsrnVqrvbrbzVrbzVsrnVsrnVsrnVsrnVsrnV
srnVrbzVsrnVqrvbsrnVrbzVsrnVsrnVqrvbrbzVsrnVsrnVsrnVqrvbsrnV
srnVsrnVrbzVrbzVmrfGOV41Qmw9UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41TSobTSobXDQjXDQjXDQjXDQjTSob
TSobTSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVQ4xfQ31P
OV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVsrnVsrnV
qrvbsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnV
srnVrbzVsrnVrbzVqrvbqrvbsrnVsrnVrbzVsrnVrbzVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnV
srnVsrnVsrnVsrnVrbzVsrnVsrnVrbzVsrnVsrnVsrnVsrnVrbzVsrnVrbzV
srnVsrnVsrnVsrnVsLnTQmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9TSobTSobTSobXDQjXDQjXDQjTSobTSob
TSobTSobTSobOV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheQ4xfQ4xf
OmxEOV41OV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/yru/qrvbrbzVrbzV
srnVrbzVrbzVsrnVsrnVsrnVrbzVsrnVsrnVsrnVrbzVsrnVrbzVsrnVsrnV
srnVrbzVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnV
srnVsrnVqrvbsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVqrvbsrnVsrnVsrnV
srnVrbzVsrnVsrnVsrnVqrvbsrnVsrnVsrnVsrnVqrvbsrnVsrnVsrnVrbzV
srnVsrnVsrnVrbzVsLnRQmw9UJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41TSobTSobTSobXDQjXDQjXDQjTSobTSob
TSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheQmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvQ4xf
Q4pcOV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnVrbzV
srnVsrnVsrnVsrnVsrnVsrnVrbzVrbzVqrvbsrnVsrnVsrnVqrvbrbzVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVrbzVrbzVsrnVsrnVsrnV
rbzVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVqrvbsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnV
rbzVsrnVsrnVsrnVQmw9Qmw9UaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41TSobTSobTSobXDQjXDQjTSobTSobTSob
TSobOV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
Q4xfQ31QOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/yru/srnVsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVrbzVsrnVsrnVsrnVuLjVsrnVuLjVuLjVsrnVsrnVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnV
srnVsrnVrLfPQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVOV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobTSobXDQjXDQjTSobTSobTSobTSob
OV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheOV41UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
Q4xfQ4xfQnBBOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnV
srnVuLjVqrvbsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnV
rbzVu7jQsrnVrbzVsrnVuLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVrbzVu7jQsrnVrbzVrbzVsrnVsrnVsrnVu7jQrbzVu7jQsrnV
rbzVsLnTQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobTSobXDQjTSobTSobTSobTSobTSob
OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvQ4xfQ4xfOV41OV413dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQsrnV
srnVsrnVu7jQrbzVsrnVsrnVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnV
rbzVu7jQu7jQu7jQrbzVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnV
srnVqrvbsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVrbzVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVrbzVuLjVuLjVsrnVu7jQrbzVsrnVuLjVsrnVsrnVuLjV
srnVP2M/Qmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUJhVUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobTSobTSobTSobOV41
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa5d/Z+fLX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/rbzVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVu7jQsrnVsrnVsrnVsrnV
srnVuLjVuLjVsrnVsrnVsrnVsrnVuLjVsrnVsrnVuLjVuLjVsrnVsrnVsrnV
srnVu7jQsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnV
gJOaQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UJhVUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobTSobTSobOV41OV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQ4xfOV413dfa3dfa9/DY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/srnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVu7jQrbzVsrnVsrnVuLjVuLjVsrnV
u7jQsrnVuLjVu7jQsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVu7jQuLjVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVipej
Qm0/Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVOV41OV41UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobOV41OV41OV41Uahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV413dfa3dfa9O3Y/PTX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/
srnVuLjVsrnVsrnVsrnVu7jQsrnVuLjVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVu7jQ
srnVuLjVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVQmw9
Qmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobOV41OV41UaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV413dfa3dfa8OnY/fXX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
mIZ/mIZ/srnVsrnVu7jQrbzVu7jQsrnVsrnVsrnVrbzVu7jQu7jQu7jQsrnV
srnVsrnVsrnVuLjVsrnVu7jQsrnVsrnVsrnVsrnVu7jQu7jQsrnVu7jQsrnV
srnVsrnVsrnVuLjVu7jQsrnVuLjVu7jQsrnVu7jQu7jQuLjVsrnVsrnVsrnV
srnVsrnVsrnVu7jQsrnVu7jQsrnVuLjVu7jQsrnVsrnVu7jQsrnViq+hQmw9
Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVQmw9OV41UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobOV41OV41OV41UaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa7OXZ/vbX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+PHY//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/mIZ/mIZ/srnVuLjVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVu7jQsrnV
uLjVuLjVu7jQu7jQu7jQsrnVuLjVsrnVuLjVuLjVsrnVsrnVu7jQsrnVsrnV
u7jQuLjVsrnVu7jQsrnVsrnVsrnVsrnVu7jQsrnVsrnVu7jQsrnVsrnVu7jQ
u7jQu7jQu7jQsrnVu7jQsrnVu7jQu7jQsrnVuLjVu7jQsrnVQmw9Qmw9UJhV
UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41Q4xfUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41OV41OV41OV41UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa6OLZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa6+TZ+fHY/vbX/vbX/fXX//fX//fX7t/I7t/I
7t/ImIZ/mIZ/mIZ/uLjVsrnVu7jQuLjVsrnVu7jQsrnVsrnVsrnVsrnVuLjV
u7jQsrnVsrnVsrnVsrnVu7jQu7jQu7jQu7jQsrnVsrnVsrnVsrnVu7jQsrnV
srnVu7jQsrnVuLjVuLjVuLjVsrnVsrnVsrnVsrnVsrnVu7jQuLjVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVOV41Qmw9Qmw9UJdVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQ4xfQmw9OV41Q4xfUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa5uDZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7+bK//fXmIZ/mIZ/
7N3I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa4dva7OXZ8+zY+PDY+vLX+/PX7N3I
7t/I7t/ImIZ/mIZ/mIZ/tLnVu7jQsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVu7jQsrnVu7jQu7jQsrnVsrnVsrnVsrnVuLjVu7jQuLjVu7jQsrnVuLjV
u7jQsrnVu7jQu7jQu7jQu7jQu7jQuLjVu7jQuLjVuLjVsrnVu7jQuLjVuLjV
u7jQsrnVu7jQuLjVsrnVu7jQu7jQuLjVu7jQQmw9Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQmw9OV41PJRvQ4xfUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvUaheUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa493Z//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PPUpJOJmIZ/mIZ/
4dPJ7d7I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3tja4dra5N7Z4NHJ
4tTJ5NbI5dfImIZ/mIZ/m4mEpJ+rsqu9uLjVsrnVs62/s62/u7jQu7jQu7jQ
srnVu7jQuLjVsrnVuLjVu7jQuLjVu7jQu7jQsrnVu7jQuLjVuLjVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVuLjVu7jQsrnVu7jQu7jQuLjVsrnVu7jQu7jQsrnV
u7jQuLjVu7jQu7jQsrnVsrnVu7jQOV41OV41Qmw9Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheQ4xfQmw9PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvUaheUaheUJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa5t/Z//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/5NbI/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/4dva
8+zY+/PX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa2szK2szK2szKmIZ/mIZ/mYiDmomEnI2Nq6S2q6zAq63CuLjVuLjVuLjV
u7jQsrnVu7jQu7jQu7jQsrnVu7jQuLjVuLjVu7jQsrnVu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQu7jQuLjVu7jQsrnVu7jQsrnVsrnVu7jQu7jQsrnVsrnVu7jQ
uLjVu7jQsrnVuLjVuLjVu7jQuLjVOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVQ4xfQmw9PJRvPJRvUaheUaheUaheUaheUaheUahemIZ/Uahe
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa6+XZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/2szK8erY//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa5d7Z9O3Y//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mYeBu7jQu7jQsrnVu7jQ
u7jQuLjVuLjVuLjVu7jQsrnVu7jQu7jQsrnVu7jQsrnVuLjVuLjVuLjVsrnV
uLjVuLjVuLjVu7jQsrnVu7jQuLjVu7jQu7jQuLjVuLjVu7jQu7jQuLjVu7jQ
srnVu7jQu7jQu7jQuLjVu7jQuLjVQmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVQmw9OV41PJRvPJRvUaheUaheUaheUahemIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa8erY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/3dfa8erY+vPX//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/
opGM3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/uLjVsrnVu7jQsrnVuLjV
uLjVu7jQu7jQu7jQuLjVu7jQu7jQsrnVu7jQuLjVu7jQu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQuLjVu7jQuLjVu7jQu7jQuLjVu7jQu7jQu7jQuLjVu7jQuLjV
u7jQuLjVu7jQuLjVu7jQsrnVu7jQQmw9Q4xfQ4xfPJRvPJRvUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUJhVUJhVQmw9PJRvPJRvUaheUaheUahemIZ/mIZ/mIZ/mIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fXmIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvOV41PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV41OV413dfa+PDY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
mIZ/mIZ/3dfa3tja6uTZ9u/Y//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/va2p2cvJ3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/uLjVu7jQu7jQuLjVu7jQu7jQ
uLjVsrnVuLjVu7jQu7jQuLjVu7jQuLjVu7jQu7jQu7jQu7jQsrnVu7jQu7jQ
uLjVu7jQu7jQu7jQu7jQu7jQuLjVu7jQu7jQuLjVuLjVu7jQsrnVu7jQu7jQ
u7jQsrnVu7jQuLjVu7jQuLjVu7jQQmw9Qmw9Q4xfPJRvPJRvUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUJhVQ4xfOV41PJRvPJRvUaheUahemIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/UaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvOV41PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV41OV414Nna+vLX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
mIZ/mIZ/3dfa3dfa3dfa5d/Z+vLX/fXX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/m4mCyLm22szK3dfa3dfa3dfa3dfa//fX3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/u7jQu7jQuLjVu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQu7jQuLjVu7jQu7jQuLjVuLjVuLjVu7jQuLjVuLjV
u7jQuLjVuLjVuLjVu7jQuLjVu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQuLjV
uLjVu7jQuLjVu7jQu7jQu7jQu7jQOV41Qmw9Q4xfQ4xfPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVQmw9OV41PJRvPJRvUahemIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/Y7BqUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvOV82PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV413dfa5uDZ9+/Y//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/ImIZ/mIZ/3dfa3dfa3dfa3tja7+jY+fHY//fX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/uLjVu7jQuLjVu7jQu7jQu7jQuLjVuLjV
u7jQu7jQu7jQuLjVu7jQwbbQu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQuLjVu7jQuLjVuLjVuLjVu7jQu7jQuLjVu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQwbbQu7jQuLjVu7jQOV41OV41Q4xfQ4xfQ4xfPJRvPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVOV41OV41PJRvUahemIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvOnFJUKZdUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQmw9OV413dfa7OXZ9u7Y//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fXmIZ/mIZ/7t/I2szK2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/mIZ/u7jQu7jQu7jQuLjVu7jQu7jQuLjVu7jQu7jQu7jQu7jQ
wbbQu7jQuLjVu7jQu7jQu7jQwbbQuLjVwbbQu7jQu7jQwbbQu7jQu7jQuLjV
u7jQu7jQu7jQwbbQu7jQwbbQu7jQu7jQu7jQuLjVu7jQuLjVu7jQu7jQuLjV
u7jQu7jQuLjVuLjVuLjVu7jQuLjVu7jQOV41Qmw9Qmw9Qmw9Q4xfPJRvPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
Q4xfQmw9OV41PJRvmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvO3pTUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQmw9OV413dfa7+jY/fXX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ/7t/I2szK2szK2szK2szK2szK2szK2szK3dfamIZ/
mIZ/mIZ/u7jQu7jQu7jQu7jQu7jQu7jQu7jQuLjVu7jQuLjVuLjVu7jQuLjV
uLjVwbbQu7jQuLjVuLjVuLjVu7jQuLjVwbbQuLjVuLjVwbbQuLjVu7jQuLjV
u7jQu7jQu7jQuLjVuLjVu7jQwbbQuLjVu7jQu7jQu7jQu7jQuLjVwbbQwbbQ
uLjVu7jQu7jQu7jQu7jQwbbQwbbQwbbQuLjVOV41Qmw9Qmw9Qmw9Q4xfPJRv
PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
Q4xfQmw9OV41mIZ/mIZ/3dfa+vLX/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/mIZ/mIZ/m4mD3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
uLjVu7jQu7jQwbbQwbbQwbbQwbbQu7jQu7jQwbbQu7jQwbbQuLjVwbbQu7jQ
wbbQu7jQuLjVu7jQwbbQu7jQu7jQu7jQuLjVwbbQu7jQuLjVwbbQwbbQwbbQ
wbbQuLjVuLjVu7jQu7jQwbbQuLjVu7jQwbbQwbbQwbbQuLjVu7jQu7jQuLjV
wbbQu7jQwbbQu7jQwbbQu7jQuLjVuLjVwbbQwbbQOV41Qmw9Qmw9Q4xfQ4xf
PJRvPJRvPJRvPJRvPJRvUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
Q4xfOV41mIZ/mIZ/3dfa3dfa8+zY/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/ImIZ/mIZ/mIZ/2NHT18/R3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/u7jQu7jQwbbQu7jQu7jQwbbQu7jQuLjVwbbQ
u7jQwbbQwbbQuLjVuLjVuLjVu7jQwbbQu7jQu7jQwbbQuLjVwbbQu7jQuLjV
uLjVwbbQwbbQu7jQu7jQwbbQwbbQu7jQu7jQwbbQu7jQu7jQu7jQu7jQuLjV
wbbQwbbQwbbQwbbQuLjVu7jQwbbQuLjVuLjVu7jQwbbQwbbQuLjVu7jQu7jQ
wbbQuLjVwbbQuLjVuLjVu7jQu7jQu7jQuLjVuLjVuLjVOV41Qmw9Q4xfQ4xf
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
Q4xfOV41mIZ/3dfa3dfa3dfa5d/Z/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OjY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/ImIZ/mIZ/mIZ/rqCczcTF2NHT3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfamIZ/mIZ/mIZ/uLjVu7jQuLjVuLjVwbbQwbbQu7jQu7jQ
uLjVuLjVu7jQu7jQu7jQu7jQuLjVwbbQu7jQu7jQu7jQu7jQuLjVwbbQu7jQ
wbbQu7jQu7jQuLjVwbbQu7jQuLjVwbbQu7jQuLjVwbbQu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQwbbQu7jQu7jQu7jQu7jQu7jQu7jQwbbQwbbQwbbQ
uLjVu7jQuLjVu7jQwbbQu7jQwbbQuLjVu7jQu7jQu7jQwbbQOV41Qmw9Q4xf
Q4xfPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
TpFlmIZ/mIZ/3dfa3dfa3dfa3dfa9O3Y/PTX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41OV41UaheUaheUaheUaheVqZgU6dfVqZgWqRiUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4ZZOV41OV413dfa7+jY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/pJSPsaShwLW01M3P3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/3dfa3dfamIZ/mIZ/wbbQu7jQwbbQu7jQu7jQu7jQwbbQwbbQ
u7jQu7jQwbbQu7jQu7jQwbbQu7jQu7jQuLjVu7jQwbbQu7jQwbbQu7jQwbbQ
wbbQwbbQwbbQu7jQwbbQu7jQuLjVu7jQu7jQu7jQwbbQwbbQwbbQwbbQwbbQ
uLjVwbbQu7jQwbbQu7jQu7jQwbbQwbbQwbbQu7jQu7jQu7jQuLjVuLjVwbbQ
wbbQwbbQwbbQu7jQwbbQuLjVwbbQwbbQwbbQwbbQu7jQu7jQwbbQeYVoQmw9
Q4xfRIxfPpVwP5ZxRZl0PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa8+zY8+zY6OLZ6uPZ8uvYmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/2szK6uPZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41UaheUaheUaheUahemIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
VaphUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4teOV41OV413dfa7ufZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/mIZ/u7jQmIZ/mIZ/mIZ/mIZ/oI+Jxry72NLU3NbZ
3NbZ2NHUmIZ/mIZ/mIZ/3dfamIZ/mIZ/u7jQwbbQu7jQu7jQuLjVu7jQwbbQ
wbbQuLjVwbbQwbbQuLjVu7jQwbbQwbbQwbbQu7jQwbbQu7jQwbbQuLjVu7jQ
u7jQuLjVu7jQwbbQuLjVwbbQwbbQwbbQwbbQwbbQuLjVu7jQuLjVu7jQu7jQ
wbbQuLjVwbbQu7jQwbbQwbbQu7jQu7jQu7jQwbbQwbbQu7jQwbbQu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQwbbQu7jQu7jQu7jQu7jQwbbQwbbQu7jQe6SLeYVo
OV41U5RoQ4xfQ4xfPJRvPZRvPpVwPJRvPJRvPJRvPJRvPJRvPJRvPJRvRIxf
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na7ebZ9e3YmIZ/mIZ/mIZ///fX
//fX//fX//fXmIZ/mIZ/3dfa2szK8uvY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41
OV41OV41Y7BrmIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fXmIZ/
mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV41OV416+TZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/ImIZ/wbbQuLjVu7jQmIZ/mIZ/mIZ/mIZ/mIZ/oZCL
3dfa3dfarqCcmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQu7jQwbbQu7jQ
u7jQwbbQu7jQu7jQu7jQwbbQuLjVu7jQuLjVwbbQuLjVu7jQuLjVwbbQwbbQ
wbbQwbbQu7jQwbbQu7jQu7jQuLjVu7jQu7jQwbbQwbbQwbbQwbbQu7jQu7jQ
wbbQwbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQu7jQu7jQwbbQwbbQu7jQmIZ/
2szKeYVoQmw9PZRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfmIZ/
mIZ/3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa2szK6eLZ//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/UaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41
OV41OV41mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4pcOV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQu7jQmIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQuLjVwbbQwbbQ
u7jQu7jQwbbQwbbQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQu7jQuLjVu7jQ
u7jQu7jQwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQ
u7jQuLjVu7jQwbbQwbbQu7jQwbbQu7jQwbbQu7jQwbbQwbbQwbbQu7jQwbbQ
u7jQwbbQu7jQu7jQwbbQu7jQwbbQwbbQu7jQwbbQwbbQu7jQu7jQxbvQmIZ/
2szK2szKeYVoOV41OV41P5ZxPJRvPJRvPJRvPJRvPJRvPJRvQ4xfRIxfmIZ/
3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK5N3Z/vbX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
UqlfUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvQZNwPJRvPJRvWZ58SGRB
OV41mIZ/mIZ///fX//fXmIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX
mIZ/mIZ/WKtjUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4ZYOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/ImIZ/u7jQu7jQwbbQwbbQwbbQmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQwbbQwbbQwbbQu7jQ
wbbQwbbQu7jQwbbQwbbQu7jQwbbQu7jQwbbQu7jQwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQu7jQwbbQwbbQu7jQwbbQ
wbbQwbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQu7jQu7jQu7jQwbbQu7jQwbbQ
u7jQwbbQwbbQu7jQwbbQu7jQu7jQwbbQwbbQu7jQwbbQwbbQu7jQmIZ/mIZ/
2szK2szK2szK2szKOV41OV41OV41RJhzPJRvPJRvPJRvP5ZxQ4xfcKN3mIZ/
mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK+fHY//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/d7l4PJRvPJRvPJRvPJRvPJRvmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX
//fXmIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQwbbQwbbQu7jQwbbQu7jQ
wbbQwbbQwbbQu7jQu7jQu7jQu7jQwbbQwbbQwbbQu7jQwbbQu7jQwbbQu7jQ
wbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQ
wbbQu7jQwbbQu7jQybTKwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQwbbQu7jQ
wbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQwbbQwbbQ
wbbQwbbQu7jQybTKwbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQz7q9mIZ/2szK
2szK3dfa2szK2szK2szKrr6mOV41Qmw9Qmw9Qmw9Qmw9Qmw9Qmw9OV41mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3c7K+PDY//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX/PXVmIZ/mIZ/PJRvPJRvmIZ/mIZ/mIZ///fX8vHO/vfX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/+O3R//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX
//fX//fXmIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/u7jQu7jQu7jQwbbQwbbQwbbQwbbQ
wbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQu7jQwbbQu7jQwbbQwbbQwbbQ
u7jQwbbQwbbQwbbQu7jQwbbQwbbQu7jQybTKu7jQybTKwbbQu7jQu7jQu7jQ
wbbQu7jQwbbQu7jQwbbQwbbQu7jQu7jQwbbQwbbQu7jQwbbQwbbQybTKu7jQ
wbbQwbbQwbbQu7jQwbbQu7jQwbbQwbbQwbbQwbbQwbbQwbbQwbbQu7jQybTK
u7jQwbbQu7jQu7jQwbbQwbbQwbbQwbbQwbbQu7jQu7jQwbbQmIZ/mIZ/2szK
2szK3dfa3dfa3dfa3dfa2szK2szKeYVoQmw9Y51wQmw9Qmw9OV41OV41OV41
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa6uPZ//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R//fX//fX//fXmIZ/mIZ///fX//fX
//fXmIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQu7jQwbbQwbbQwbbQu7jQ
u7jQwbbQwbbQwbbQwbbQwbbQu7jQybTKwbbQu7jQwbbQwbbQwbbQybTKwbbQ
wbbQu7jQu7jQwbbQwbbQwbbQwbbQu7jQwbbQu7jQu7jQwbbQwbbQwbbQwbbQ
u7jQybTKybTKxrTQu7jQwbbQwbbQwbbQu7jQybTKwbbQwbbQu7jQu7jQybTK
wbbQwbbQwbbQwbbQwbbQxrTQwbbQwbbQwbbQybTKwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQybTKu7jQwbbQu7jQwbbQwbbQxrTQwbbQu7jQmIZ/2szK2szK
3dfa3dfa3dfa4tza5N7Z5d7Z5d7Z5+HZ2c7EOV41OV41OV41OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3tja//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfQmw9OV41Q4xfOV41OV41//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQu7jQu7jQxrTQ
wbbQwbbQu7jQwbbQu7jQu7jQwbbQu7jQwbbQwbbQybTKybTKu7jQwbbQu7jQ
u7jQxrTQwbbQwbbQu7jQybTKwbbQwbbQwbbQwbbQwbbQwbbQwbbQwbbQwbbQ
u7jQu7jQu7jQybTKwbbQwbbQybTKybTKu7jQwbbQwbbQybTKxrTQwbbQwbbQ
wbbQwbbQybTKu7jQybTKwbbQu7jQwbbQwbbQu7jQybTKu7jQybTKu7jQwbbQ
wbbQwbbQwbbQybTKu7jQybTKybTKu7jQybTKwbbQwbbQu7jQmIZ/2szK2szK
3dfa3dfa6uPZ9O3Y8uvY8uvY+PDY//fX/vbX/vbX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa
//fX//fX//fX//fX//fXmIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ/W61l
VqpiUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvQ4xfQmw9OV41Q4xfOV41OV41OV41//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQwbbQybTKu7jQwbbQ
ybTKybTKu7jQybTKybTKwbbQxrTQu7jQwbbQu7jQu7jQwbbQu7jQybTKybTK
u7jQwbbQybTKybTKu7jQu7jQwbbQybTKu7jQybTKybTKu7jQwbbQwbbQwbbQ
xrTQxrTQwbbQu7jQybTKu7jQu7jQwbbQwbbQybTKwbbQu7jQwbbQwbbQu7jQ
ybTKu7jQu7jQybTKwbbQu7jQybTKwbbQwbbQybTKwbbQwbbQwbbQwbbQybTK
wbbQwbbQwbbQu7jQybTKu7jQu7jQwbbQu7jQybTKwbbQmIZ/mIZ/2szK2szK
3dfa7ufZ//fX8+zY9u/Y+/PX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/2szK2szK3dfa
//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R+O3R+O3R
//fX//fX//fX//fX//fX//fX//fXmIZ/+O3R+O3R//fX//fX//fXmIZ/V6ti
WqxkUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvQmw9OV41PJRvQ4xfQmw9OV41//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQwbbQybTK
u7jQwbbQybTKwbbQwbbQwbbQu7jQybTKybTKwbbQwbbQybTKxrTQu7jQu7jQ
ybTKybTKu7jQwbbQwbbQwbbQybTKwbbQwbbQu7jQu7jQwbbQybTKybTKwbbQ
wbbQybTKwbbQwbbQybTKwbbQwbbQwbbQwbbQu7jQxrTQybTKu7jQybTKu7jQ
ybTKwbbQwbbQwbbQybTKwbbQwbbQwbbQwbbQwbbQybTKu7jQybTKu7jQybTK
u7jQwbbQxrTQwbbQwbbQwbbQybTKwbbQwbbQybTKu7jQmIZ/mIZ/2szK2szK
6uPZ+PDY//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/2szK2szK
3dfa//fX//fX//fX//fX7t/ImIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R
+O3R+O3R//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX+fDSnZOFmIZ/
U6lfUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvQ4BSQmw9PJRvQ4xfQmw9Qmw9//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQu7jQybTKu7jQwbbQ
wbbQwbbQwbbQwbbQwbbQxrTQwbbQwbbQwbbQybTKu7jQu7jQybTKwbbQwbbQ
wbbQwbbQwbbQybTKu7jQwbbQwbbQwbbQxrTQxrTQybTKu7jQu7jQu7jQwbbQ
ybTKwbbQwbbQwbbQwbbQybTKwbbQwbbQwbbQybTKu7jQu7jQybTKwbbQybTK
wbbQwbbQu7jQybTKwbbQu7jQybTKu7jQybTKu7jQwbbQxrTQwbbQwbbQu7jQ
ybTKybTKwbbQwbbQybTKwbbQu7jQybTKwbbQwbbQybbKmIZ/2szK2szK4Nna
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK
3dfa3dfa//fX//fX//fX//fXmIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/+O3R+O3R+O3R//fX//fX//fXmIZ/mIZ/mIZ/+O3R//fX//fXm4mBmIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvQ4teQm4/OV41PJRvQ4xfQmw9OV41//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/wbbQwbbQwbbQybTK
wbbQu7jQybTKu7jQybTKybTKwbbQu7jQybTKwbbQxrTQybTKwbbQybTKwbbQ
u7jQybTKu7jQu7jQybTKu7jQybTKu7jQybTKu7jQwbbQxrTQxrTQybTKybTK
wbbQybTKybTKu7jQwbbQybTKybTKu7jQwbbQybTKybTKwbbQybTKu7jQwbbQ
ybTKybTKu7jQwbbQxrTQwbbQybTKu7jQybTKwbbQybTKu7jQybTKwbbQwbbQ
u7jQybTKu7jQwbbQybTKybTKu7jQwbbQwbbQwbbQ0rq7mIZ/2szK3dfa4tza
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PXX3tjamIZ/mIZ/
2szK2szK7ebZ//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fXmIZ/mIZ/+O3R//fX//fX//fXmIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJJtQnlLQmw9PJRvPJRvQ4xfQmw9OV41//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQybTK
wbbQwbbQybTKu7jQu7jQu7jQybTKu7jQwbbQu7jQwbbQwbbQwbbQybTKybTK
wbbQybTKybTKwbbQybTKwbbQybTKu7jQybTKwbbQybTKu7jQwbbQwbbQwbbQ
ybTKwbbQu7jQybTKybTKu7jQwbbQybTKybTKwbbQu7jQybTKwbbQwbbQybTK
wbbQwbbQwbbQybTKu7jQybTKwbbQybTKybTKu7jQwbbQybTKwbbQwbbQwbbQ
ybTKu7jQybTKwbbQwbbQwbbQybTKybTKu7jQwbbQvbrQmIZ/2szK3dfa49za
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX8OnY3dfa3dfamIZ/
mIZ/2szK2szK5uDZ/PXX/vbX//fXmIZ/mIZ/mIZ/mIZ/7N3G//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/+O3R+O3R+O3R//fX//fXmIZ/mIZ/+O3R//fX//fXmIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJRvQ4xfQ4xfPJRvPJRvPJRvQmw9Qmw9OV41//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/ybTKwbbQwbbQwbbQ
u7jQybTKwbbQxrTQybTKybTKybTKybTKybTKybTKwbbQybTKu7jQwbbQwbbQ
wbbQwbbQu7jQybTKu7jQybTKwbbQybTKu7jQybTKwbbQybTKybTKybTKxrTQ
u7jQybTKwbbQu7jQybTKwbbQwbbQwbbQybTKybTKu7jQybTKybTKwbbQwbbQ
ybTKybTKwbbQybTKwbbQybTKu7jQu7jQybTKybTKwbbQwbbQybTKybTKwbbQ
ybTKybTKybTKwbbQwbbQwbbQwbbQybTKybTKxrTQw7rQmIZ/2szK3dfa49za
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX5t/Z3tja3dfa3dfamIZ/
mIZ/mIZ/2szK2szK5d/Z/fXX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/+O3R+O3R+O3R//fXmIZ/mIZ///fX+O3RmIZ/mIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvQ4xfPJRvPJRvPJRvOV41Q4xfOV41OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/ybTKybTKu7jQybTK
wbbQybTKu7jQwbbQwbbQwbbQwbbQu7jQwbbQybTKu7jQybTKybTKwbbQwbbQ
ybTKybTKwbbQxrTQwbbQybTKu7jQybTKwbbQybTKu7jQu7jQwbbQybTKwbbQ
ybTKwbbQybTKybTKwbbQybTKybTKwbbQwbbQwbbQybTKwbbQwbbQybTKybTK
wbbQu7jQybTKu7jQybTKwbbQybTKybTKwbbQu7jQybTKybTKwbbQwbbQybTK
wbbQwbbQu7jQybTKybTKybTKybTKwbbQwbbQybTKy7bKmIZ/2szK3dfa4dva
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX8uvY4Nra3dfa3dfa3dfa3dfamIZ/
mIZ/mIZ/mIZ/2szK2szK3dfa+PDY//fX//fX//fXmIZ/mIZ/mIZ/7t/ImIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ///fXUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQmw9OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/wbbQwbbQybTKybTK
u7jQybTKybTKybTKybTKybTKybTKybTKybTKwbbQxrTQwbbQu7jQybTKybTK
wbbQwbbQu7jQybTKybTKwbbQybTKwbbQybTKwbbQybTKybTKybTKwbbQybTK
ybTKwbbQwbbQybTKwbbQwbbQybTKybTKybTKu7jQybTKybTKu7jQybTKu7jQ
ybTKybTKybTKybTKybTKwbbQwbbQybTKybTKybTKu7jQybTKybTKwbbQybTK
ybTKybTKwbbQwbbQu7jQwbbQybTKybTKwbbQwbbQybTKmIZ/2szK3dfa3tja
mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX6ePZ3dfa3dfa3dfa3dfa3dfamIZ/PJRv
RJZkmIZ/mIZ/mIZ/2szK2szK2szK8+zY/vbW//fX//fX//fXmIZ/mIZ/mIZ/
7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fXmIZ/mIZ///fXUJhVUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQmw9Uahe//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQybTK
ybTKu7jQu7jQybTKu7jQwbbQwbbQwbbQybTKybTKybTKybTKwbbQwbbQybTK
ybTKybTKybTKu7jQybTKwbbQybTKwbbQybTKwbbQybTKu7jQybTKwbbQwbbQ
wbbQybTKybTKwbbQybTKybTKwbbQwbbQwbbQybTKwbbQybTKybTKwbbQybTK
ybTKwbbQwbbQwbbQwbbQybTKybTKwbbQwbbQwbbQybTKwbbQwbbQybTKwbbQ
wbbQwbbQybTKybTKybTKybTKwbbQwbbQybTKybTKwbbQmIZ/2szK3dfa3dfa
mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I7t/I7t/I7t/I
7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX/vbX+/PX//fX9/DY9O3Y5t/Z3dfa3dfa3dfa3dfamIZ/mIZ/ValhPJRv
RJZkRpdlSJdnmIZ/mIZ/2szK2szK2szK6eLZ/vbX/vbX//fX//fXmIZ/mIZ/
mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3RmIZ/mIZ/3dfaQmw9UJhVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQmw9Qmw9zM6x
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/ybTKybTKybTK
wbbQybTKybTKwbbQybTKybTKybTKybTKwbbQu7jQybTKwbbQybTKybTKwbbQ
wbbQwbbQwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKybTK
wbbQwbbQybTKwbbQwbbQybTKybTKybTKwbbQybTKwbbQwbbQybTKwbbQwbbQ
ybTKybTKybTKybTKwbbQwbbQybTKybTKybTKybTKybTKybTKwbbQybTKybTK
ybTKwbbQwbbQwbbQwbbQybTKybTKwbbQwbbQybTKy8HRmIZ/2szK3dfa3dfa
mIZ/mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX7t/ImIZ/7t/ImIZ/mIZ/
7t/ImIZ/7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ///fX+fLX
9+/Y9u/Y8uvY6uPZ4tza2szK2szK3dfa3dfamIZ/mIZ/WKpkUaheUahePJRv
PJRvRJZkRZZlRZZkmIZ/mIZ/no2F2szK2szK2szK8uvY8OnY//fX//fXmIZ/
mIZ/7d7I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ///fX+O3RmIZ/mIZ/orSeQmw9UJhVUJhV
UJhVUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQ4xfQ4xfR45haJ9zQm0+5uLJ
9vDP//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/wbbQwbbQybTK
wbbQwbbQybTKwbbQwbbQwbbQwbbQybTKybTKwbbQybTKwbbQybTKybTKybTK
ybTKybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQwbbQxrTQ
ybTKybTKybTKybTKybTKwbbQwbbQwbbQybTKybTKybTKybTKwbbQybTKybTK
ybTKwbbQwbbQwbbQybTKybTKybTKwbbQwbbQwbbQwbbQwbbQybTKwbbQwbbQ
ybTKybTKybTKybTKybTKwbbQwbbQybTKybTKwbbQzbjKmIZ/2szK2szK3dfa
mIZ/mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/6OHZ5t/Z493Z4dva39na
3tja3tja3dfa3dfa2szK3dfa3dfa3dfamIZ/UaheUaheUaheUaheUahePJRv
PJRvPJRvRJZkRJZkRJZkRZZlmIZ/nIuF18jG2szK3dfa3dfa7OXZ//fX//fX
//fXmIZ/mIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/nYyG3dfaorSeQmw9UJhV
UJhVUJhVUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvQ4xfQ4xfQ4xfQ4xfQ4xfQWw9OV41OV41OV41OV41//fX//fX
9e/P//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTKwbbQ
ybTKybTKwbbQybTKybTKybTKybTKwbbQwbbQybTKwbbQybTKu7jQybTKwbbQ
wbbQwbbQwbbQybTKybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKybTKybTK
xrTQwbbQybTKu7jQybTKybTKybTKwbbQwbbQwbbQybTKybTKybTKybTKwbbQ
ybTKybTKybTKybTKwbbQxrTQybTKybTKybTKybTKybTKwbbQybTKybTKwbbQ
wbbQybTKwbbQybTKybTKybTKybTKwbbQybTKwbbQwbbQmIZ/mIZ/2szK3dfa
mIZ/2szKmIZ/mIZ///fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa2szK2szK2szK2szK2szK
2szK2szK2szK2szK3dfamIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvRJZkRJZkRJZkmIZ/mIZ/mIZ/yLm22szK2szK3dfa8erY+fDR
//fX//fX/vbXmIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX4trQ3dfaorSeorSeQmw9
Qmw9UJhVUJhVUJhVUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvQ4xfQ4xfQ4xfOV41OV41OV41OV41OV41//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/wbbQybTKybTK
ybTKybTKxrTQwbbQybTKybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKybTK
ybTKybTKwbbQxrTQybTKybTKybTKwbbQybTKxrTQybTKybTKybTKybTKybTK
ybTKybTKwbbQybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKwbbQybTK
ybTKybTKybTKwbbQybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTK
ybTKwbbQybTKwbbQybTKwbbQybTKybTKxrTQybTKybTKybTKmIZ/2szK3dfa
3dfa3dfamIZ/mIZ/mIZ/7t/I//fX//fX//fX3dfa//fX3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK3dfa2szK2szKmIZ/
3dfamIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvRJZkU5xuRZZkmIZ/mIZ/2szK2szK2szK3dfa6OHZ
9OvQ//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfaorSeQmw9
Qmw9Qmw9UJhVUJhVUJhVQ4xfQ4xfQ4xfQ4xfQ4xfQ4xfPJRvPJRvPJRvPJRv
PJRvPJRvQ4xfQmw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTKwbbQ
xrTQwbbQybTKybTKybTKwbbQybTKybTKybTKwbbQybTKybTKybTKybTKybTK
ybTKwbbQybTKybTKybTKwbbQybTKybTKybTKybTKybTKwbbQwbbQwbbQwbbQ
ybTKybTKybTKwbbQybTKybTKybTKybTKybTKwbbQybTKwbbQybTKybTKybTK
wbbQybTKybTKybTKybTKwbbQxrTQwbbQybTKwbbQybTKybTKybTKybTKybTK
ybTKybTKybTKxrTQybTKwbbQybTKybTKybTKybTKwbbQybTKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szK2szK2szK2szK3dfa
3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szKmIZ/2szKmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/WatjW6xlUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvRZZkSZdnmIZ/mIZ/mIZ/2szK2szK2szK3dfa
4dva9u/Y/fXX//fX//fX//fX/vbXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX+vHT//fX5N3Z3dfa3dfa3dfa
OV41Qmw9Qmw9OV41OV41Qmw9Qmw9Qmw9Q4xfQ4xfQ4xfQ4xfQ4xfQ4xfQ4xf
Q4xfTpFlQWw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/ybTKybTKybTK
ybTKybTKybTKwbbQybTKwbbQwbbQybTKybTKybTKwbbQybTKwbbQwbbQwbbQ
ybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKybTKybTKybTKybTKybTKxrTQ
ybTKybTKwbbQybTKwbbQwbbQybTKybTKwbbQybTKybTKybTKybTKybTKwbbQ
ybTKwbbQybTKwbbQxrTQybTKybTKybTKwbbQybTKybTKwbbQybTKybTKxrTQ
ybTKwbbQybTKybTKybTKybTKwbbQybTKxrTQwbbQybTKy7jKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK3dfa3dfa2szK2szK2szK
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/Uahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvRJZkRpZlmIZ/mIZ/mIZ/3dfa2szK2szK
3dfa3tja6+TZ+PHY/vbX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX/fTV//fX/vbW39na3dfa3dfa
3dfaOV41OV41OV41OV41OV41OV41mIZ/OV41OV41OV41OV41Qmw9Qmw9TJBj
Qmw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/ybTKybTK
ybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKwbbQybTKybTKybTK
ybTKybTKxrTQybTKybTKybTKxrTQybTKybTKxrTQybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKxrTQxrTQybTKybTKybTKybTKybTKwbbQybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvRZZlVJxvmIZ/mIZ/mIZ/2szK
2szK3dfa3dfa4tva8erY+fHY/vbX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfaOV41OV413dfamIZ/mIZ/OV41OV41OV41OV41OV41OV41PWE4
SmtDn62J//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKybTKybTKybTKybTKybTK
xrTQybTKybTKxrTQybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTK
xrTQybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTK
ybTKxrTQybTKxrTQybTKybTKybTKybTKybTKybTKybTKybTKyrnQmIZ/3dfa
3dfa3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTK
ybTKOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkmIZ/mIZ/mIZ/
2szK2szK2szK3dfa3dfa5d/Z9u/Y+/PX/vbX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa5NrT3dfamIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
6+fG//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQ
ybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTK
ybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKzrPLybTKz7zMmIZ/2szK
2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTKybTKzrPL
ybTKOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkmIZ/mIZ/
mIZ/o72j2szK2szK3dfa3dfa3dfa6eLZ+fHY/PTX/vbX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX8OnY3dfa5NrT5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/ybTK
xrTQybTKybTKzrPLzrPLybTKybTKzrPLybTKybTKxrTQybTKybTKxrTQybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTK
zrPLzrPLybTKybTKybTKybTKzrPLybTKybTKybTKybTKzrPLzrPLybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKzrPL
ybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKybTKz7zMmIZ/2szK
2szKmIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTKybTKybTKybTKybTKzrPLybTKxrTQ
ybTKOV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkRJZk
mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa39na6uTZ9/DY/fXX/vbX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R+O3R//fXmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/xrTQ
ybTKybTKxrTQybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTK
ybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQ
ybTKzrPLzrPLybTKybTKybTKzrPLybTKzrPLybTKybTKybTKybTKzrPLybTK
ybTKybTKybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKxrTQzrPL
ybTKzrPLybTKzrPLybTKybTKybTKzrPLybTKybTKybTKybTKybTKmIZ/2szK
mIZ/mIZ/mIZ/ybTKybTKzrPLybTKybTKzrPLybTKybTKybTKybTKybTKOV41
OV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
RJZkmIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa4Nra6+TZ+vLX/vbX/vbX
/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTK
zrPLybTKybTKybTKybTKybTKybTKzrPLzrPLybTKzrPLybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKzrPLybTKybTKzrPLzrPLybTK
ybTKybTKybTKzrPLzrPLybTKybTKybTKybTKybTKybTKybTKzrPLybTKzrPL
ybTKzrPLybTKybTKzrPLybTKybTKzrPLzrPLybTKybTKybTKybTK0bPFybTK
zrPLybTKzrPLybTKybTKybTKzrPLybTKzrPLzrPLzrPLzrPLybTKmIZ/mIZ/
mIZ/mIZ/zrPLzrPLzrPLybTKybTKzrPLybTKybTKybTKzrPLzrPLOV41Qmw9
Qmw9OV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3tja6uTZ/fXX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/zrPL
ybTKzrPLzrPLzrPLybTK0bPFzrPLybTKybTKzrPLybTKybTKzrPLzrPLzrPL
ybTKzrPLybTKzrPLzrPLybTKybTKzrPLybTKybTKzrPLybTKybTKybTKzrPL
zrPLzrPL0bPFybTKzrPLzrPLzrPLybTKzrPLzrPLzrPLybTKybTKzrPLzrPL
ybTKzrPLzrPLybTKzrPLzrPLybTKybTKzrPLzrPLzrPLzrPLybTKzrPLybTK
zrPLybTKybTKzrPLzrPLybTKzrPLybTKybTKybTKybTKzrPLxrTQmIZ/mIZ/
mIZ/ybTKybTKybTKybTKzrPLybTK0bPFzrPLzrPLybTKybTKOV41OV41Qmw9
Q4xfOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
7ebZ/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX+O3R5NrTmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/
ybTKybTKybTKzrPLxrTQybTKzrPLzrPLybTKzrPLzrPL0bPFybTKybTKzrPL
ybTKzrPLybTKybTKzrPLzrPLybTKzrPLzrPLybTKzrPLzrPLybTKybTKzrPL
ybTKybTKxrTQzrPLybTKybTK0bPFzrPLybTKzrPLybTKzrPLzrPLybTKybTK
0bPF0bPFybTKzrPLybTKybTKzrPLzrPLzrPLzrPLybTKybTKybTKybTKybTK
ybTKzrPL0bPFzrPLybTK0bPFybTKzrPLzrPLzrPLzrPLzrPL0bPFmIZ/mIZ/
ybTKzrPLzrPLybTKzrPLzrPLzrPLxrTQybTKzrPLzrPLzrPLOV41Qmw9Q4xf
Q4xfOV41OV41Q4xfUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvRJZkRJZkmIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa
3dfa3tja9O3Y//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/
0bPFzrPLzrPLybTKzrPLzrPLzrPLybTKzrPLybTKybTKybTK0bPFybTKybTK
0bPFybTKzrPLzrPLybTKybTKzrPLybTK0bPFzrPLybTKzrPL0bPFzrPLybTK
ybTK0bPF0bPF0bPFzrPLybTK0bPF0bPFybTKzrPLzrPLzrPLzrPLybTKxrTQ
ybTK0bPF0bPFzrPL0bPFzrPL0bPFzrPLybTKzrPLzrPLzrPL0bPFzrPL0bPF
0bPFybTK0bPFybTKybTKzrPLzrPLybTK0bPFybTK0bPFybTK0bPFzrPLzrPL
zrPLzrPLzrPLzrPLybTKzrPLzrPLzrPLzrPL0bPFybTKybTKOV41Qmw9Q4xf
PJRvOV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvRJZkRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa
3dfa3dfa3dfa4tza+vLX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/
0bPFybTKzrPL0bPFybTK0bPFzrPL0bPFybTKybTKybTKybTK0bPFzrPLybTK
0bPF0bPFzrPL0bPF0bPFybTK0bPFxrTQybTKzrPLybTKybTKybTKzrPLybTK
zrPLzrPLybTKybTKzrPLzrPLybTKybTK0bPF0bPFybTKybTKzrPL0bPF0bPF
zrPLybTKybTK0bPFybTKybTKzrPLybTKzrPL0bPFzrPLzrPLybTK0bPFzrPL
ybTKzrPLybTK0bPFzrPLybTKybTK0bPFybTKzrPLybTKybTKybTK0bPF0bPF
zrPL0bPF0bPF0bPF0bPF0bPF0bPF0bPFybTKybTK0bPFzrPLOV41Qmw9Q4xf
PJRvOV41OV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvRJZkmIZ/mIZ/mIZ/mIZ/o72j2szK2szK
3dfa3dfa3dfa3dfa493Z9OzY//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
ybTK0bPFybTKybTK0bPFybTK0bPFybTKzrPLzrPLzrPLzrPLzrPLybTKzrPL
ybTKybTK0bPFybTKybTKzrPLybTK0bPFzrPL0bPFzrPLzrPL0bPFzrPLzrPL
zrPLzrPLybTK0bPFzrPLzrPLzrPLzrPLybTK0bPF0bPFzrPLzrPLybTKzrPL
zrPLzrPLybTKzrPL0bPFybTK0bPF0bPFybTKzrPL0bPFzrPLzrPLzrPLzrPL
zrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPL0bPFzrPLzrPLzrPLybTKybTK0bPF
ybTKybTKybTKybTKybTKybTKybTK0bPFzrPLzrPLzrPLybTKOV41Q4xfQ4xf
PJRvPJRvPJRvOV41UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkmIZ/mIZ/mIZ/mIZ/2szK
2szK2szK2szK49TJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R
+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX69/GmYeA//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPL0bPFzrPLybTKzrPLybTKzrPL0bPF0bPFzrPLzrPLzrPL0bPFzrPLzrPL
zrPLybTKzrPLzrPL0bPFzrPLzrPLzrPLybTKzrPLzrPLybTK0bPF0bPFzrPL
zrPLzrPLzrPLybTKzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPLybTK
ybTKzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL
0bPFzrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLybTK
zrPLzrPLzrPLzrPLzrPLzrPLzrPLybTKzrPLybTKzrPLzrPLOV41Q4xfQ4xf
PJRvPJRvPJRvOV41UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvmIZ/mIZ/mIZ/mIZ/
3dfa5NrT3dfa5NXI//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3Rm4qCmIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLybTK0bPFzrPLzrPLzrPLzrPLzrPL
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPF0bPFzrPLybTKybTK0bPF
0bPF0bPFzrPL0bPF0bPF0bPFzrPLzrPLzrPLzrPLybTK0bPFzrPL0bPFzrPL
0bPF0bPF0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPL0bPF0bPF0bPF0bPFybTK
0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPL0bPF0bPF0bPF0bPFzrPLzrPLzrPL
zrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPFzrPL0bPFzrPL0bPF0bPFOV41Q4xf
PJRvPJRvPJRvPJRvUJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvVqF9mIZ/mIZ/
mIZ/mIZ/3dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3RmIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPL0bPF0bPF0bPF0bPF0bPFzrPLzrPLzrPL0bPF0bPFzrPL0bPF0bPFzrPL
zrPL0bPFzrPLzrPL0bPFzrPLzrPLzrPLzrPLybTK0bPFzrPLzrPLzrPLzrPL
ybTKzrPL0bPFzrPLybTKzrPL0bPF0bPF0bPF0bPFzrPLzrPL0bPFzrPL1rHG
zrPLzrPLzrPLzrPLzrPL0bPF0bPF0bPFybTK0bPFzrPLybTKzrPLzrPLzrPL
ybTK0bPFybTK0bPF0bPF0bPFzrPL0bPFzrPLzrPLzrPLzrPL0bPFzrPL0bPF
0bPF0bPF0bPF0bPFzrPL0bPF0bPFybTK0bPFzrPL0bPFybTKzrPLOV41Q4xf
Q4xfPJRvPJRvPJRvPJRvUaheUJhVUaheUaheUaheUaheUaheUaheUaheUahe
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV41//fX
mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
0bPFzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPF
0bPFzrPL0bPFzrPLzrPL0bPF0bPF0bPFzrPLzrPLzrPL0bPFzrPLzrPL0bPF
zrPLzrPLzrPL0bPF0bPFzrPLzrPLzrPLzrPL1rHGzrPLzrPLzrPLzrPL0bPF
zrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPL0bPFzrPLzrPL0bPF0bPFzrPL
zrPL0bPFzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPFzrPL0bPFzrPLzrPL
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLOV41
OV41Q4xfPJRvOV41PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUahe
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV413dfa
3dfa3dfamIZ/mIZ/+vLX+/PX//fX//fX//fX//fX//fX//fX+O3RmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/0bPFzrPLzrPLzrPLzrPL0bPF0bPF0bPFzrPLzrPL0bPFzrPLzrPLzrPL
0bPFzrPL0bPFzrPLzrPLzrPLzrPL0bPF1rHGzrPLzrPL0bPF0bPFzrPLzrPL
zrPLzrPL0bPFzrPLybTKzrPLzrPLzrPLzrPLybTKzrPL1rHG0bPF0bPFzrPL
0bPF0bPF0bPF1rHGzrPLzrPLzrPL1rHGzrPLybTK1rHG0bPFzrPLzrPL0bPF
0bPFzrPL0bPFzrPLzrPL0bPFzrPLzrPL0bPF0bPFzrPLzrPLzrPLzrPL1rHG
0bPF0bPFzrPL0bPFzrPLzrPL1rHG0bPFzrPL1rHG0bPF1rHGzrPLzrPLOV41
OV41OV41PJRvOV41Qmw9PJRvUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV413dfa
3dfa3dfamIZ/mIZ///fX/fXX/vbX//fX//fX//fX3dfa//fX+O3RmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/mIZ/
3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL1rHG0bPF0bPFzrPL1rHGzrPLzrPL0bPFzrPLzrPL1rHGzrPLzrPL
zrPL0bPFzrPL0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPF
0bPFzrPL0bPFzrPL1rHG0bPF0bPF0bPF1rHG0bPFzrPLzrPLzrPLzrPLzrPL
zrPLzrPLzrPL0bPF0bPF1rHGzrPL1rHG1rHGzrPLzrPL0bPFzrPLzrPLzrPL
0bPFzrPL1rHG1rHG1rHG1rHGzrPLzrPLzrPLzrPL1rHG1rHG0bPFzrPLzrPL
zrPL1rHGzrPL1rHG1rHGzrPLzrPL0bPFzrPLzrPLzrPLzrPL1rHG0bPF1rHG
OV41OV41OV41OV41Qmw9Q4xfUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPZRvOV413dfa
3dfa3dfa3dfamIZ/mIZ/+vPX9e3Y//fX//fX3dfa3dfa+O3RmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ///fXmIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPF0bPFzrPL
zrPLzrPLzrPL0bPFzrPL1rHG1rHGzrPLzrPL1rHG1rHGzrPL0bPFzrPLzrPL
1rHGzrPLzrPL1rHGzrPLzrPLzrPLzrPLzrPLzrPLzrPL1rHG0bPF1rHG1rHG
0bPF1rHG0bPFzrPLzrPLzrPLzrPLzrPLzrPL0bPF1rHGzrPL1rHG1rHG1rHG
zrPL1rHGzrPLzrPLzrPLzrPL0bPF1rHG1rHG1rHGzrPLzrPL1rHG0bPF0bPF
0bPF0bPF0bPFzrPLzrPL0bPF1rHGzrPLzrPL1rHG0bPF1rHG0bPFzrPLzrPL
0bPFZTwhZTwhOV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfamIZ/5dvT3tja5d/Z//fX3dfa5NrT+O3RmIZ/3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/mIZ/3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/1rHG0bPF0bPF1rHG0bPF1rHG0bPF0bPFzrPL1rHG0bPF1rHG1rHG1rHG
1rHG1rHG1rHGzrPL1rHGzrPLzrPL0bPF0bPFzrPLzrPLzrPL1rHG1rHG1rHG
1rHG1rHGzrPL0bPF1rHG1rHG1rHG0bPF1rHG1rHGzrPLzrPLzrPLzrPLzrPL
zrPLzrPL1rHG1rHG0bPF1rHGzrPL0bPFzrPLzrPL1rHGzrPLzrPLzrPL1rHG
zrPL0bPFzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPF0bPFzrPLzrPL1rHG1rHG
zrPL1rHG0bPFzrPLzrPLzrPL1rHG1rHGzrPLzrPLzrPLzrPL1rHG0bPFzrPL
ZTwhZTwhXDQjXDQjXDQjOV41Qmw9UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfamIZ/mIZ/3dfamIZ/3dfa5NrT3dfamIZ/3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/1rHGzrPLzrPLzrPLzrPL1rHG1rHG1rHGzrPLzrPLzrPLzrPLzrPLzrPL
0bPFzrPL1rHGzrPLzrPLzrPL1rHGzrPL0bPF1rHG1rHGzrPLzrPL0bPF0bPF
0bPFzrPL1rHGzrPL0bPFzrPLzrPLzrPL0bPFzrPL1rHG1rHG0bPF1rHG1rHG
0bPF1rHGzrPLzrPLzrPLzrPL1rHGzrPL1rHG0bPFzrPL0bPFzrPL0bPFzrPL
0bPFzrPL1rHG1rHGzrPL1rHG0bPF0bPF0bPFzrPLzrPL0bPF1rHGzrPLzrPL
zrPLzrPLzrPL1rHG1rHG1rHGzrPLzrPL0bPF1rHG1rHG0bPFzrPLzrPL1rHG
ZTwhXDQjXDQjXDQjXDQjXDQjOV41Qmw9UJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/3dfamIZ/5NrT5NrTmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX//fX3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/zrPL1rHG0bPF1rHG0bPFzrPLzrPLzrPL1rHG1rHG0bPF0bPF0bPFzrPL
zrPL0bPFzrPL0bPF1rHG1rHGzrPL1rHGzrPLzrPLzrPL0bPFzrPLzrPLzrPL
1rHG0bPF1rHGzrPL0bPF0bPF1rHGzrPL0bPF0bPFzrPL1rHGzrPLzrPLzrPL
0bPF1rHG0bPF1rHG1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHGzrPL1rHG1rHG
1rHG0bPF0bPF1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHGzrPL0bPF0bPF1rHG
0bPF1rHG0bPFzrPLzrPL0bPF1rHG1rHGzrPL0bPF1rHG0bPF1rHG0bPFZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjOV41Qmw9Qmw9UJhVPJRvPJRvPJRvPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/+O3RmIZ/3dfa3dfamIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX//fX3dfamIZ/3dfa
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL0bPFzrPL1rHG0bPF0bPF1rHG0bPFzrPL1rHGzrPL1rHG1rHG0bPF
1rHG0bPF1rHGzrPL0bPF0bPF0bPF1rHG0bPF0bPF1rHG1rHG0bPF1rHG0bPF
0bPFzrPL0bPF1rHG1rHG1rHG0bPF1rHG1rHGzrPL0bPFzrPL1rHG1rHG1rHG
zrPLzrPL1rHG0bPFzrPL1rHGzrPL1rHGzrPL0bPFzrPL0bPF1rHG0bPFzrPL
zrPL1rHGzrPL0bPFzrPLzrPL1rHGzrPL0bPF0bPFzrPL0bPF1rHG1rHG0bPF
1rHG0bPFzrPL0bPF1rHG0bPF0bPFzrPL1rHGzrPLzrPL1rHG0bPF1rHGZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41UJhVQ4xfRJZkRJZkPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R
+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fXmIZ/3dfa3dfa
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/1rHG1rHG0bPFzrPL1rHG1rHG0bPFzrPL1rHGzrPL1rHGzrPL0bPF1rHG
zrPL1rHGzrPL1rHGzrPL1rHGzrPL0bPF1rHG1rHGzrPL0bPF1rHGzrPL1rHG
1rHG1rHG1rHGzrPLzrPL1rHGzrPLzrPL1rHG1rHG1rHG0bPF0bPF1rHG1rHG
1rHG1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
zrPL1rHG1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHGzrPLzrPL1rHGzrPL
zrPL1rHG1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHGzrPLzrPLzrPL1rHGZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41OV41Q4xfRJZkRJZkRJZkPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3Ro5GI
rZ2RtaaYsJ+TmIZ/mIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa
mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL1rHG1rHGzrPLzrPL1rHG1rHG0bPF1rHG1rHG1rHG1rHGzrPL1rHG
zrPL1rHG1rHG1rHGzrPL1rHG1rHGzrPLzrPL1rHG1rHGzrPL1rHGzrPL1rHG
1rHGzrPLzrPL1rHG1rHGzrPL1rHG1rHG1rHGzrPL0bPF1rHG1rHG0bPF1rHG
0bPFzrPL1rHG0bPF1rHG1rHG1rHG0bPFzrPL0bPFzrPL0bPFzrPLzrPL1rHG
1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHGzrPL1rHG
1rHG1rHGzrPL1rHGzrPLzrPLzrPLzrPL1rHG0bPF1rHG1rHG1rHG1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41OV41QnZCRJZkRJZkPJRv
PJRvUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R6d3E
+O3R69/G+O3R//fX//fX//fX//fX//fX//fX//fXmIZ/3dfa3dfa3dfamIZ/
mIZ/mIZ/+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
1rHG1rHG0bPFzrPL1rHG1rHGzrPL1rHG1rHG0bPFzrPL0bPFzrPL1rHG0bPF
1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG1rHG0bPFzrPL1rHG1rHG1rHGzrPL
1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG0bPF1rHG1rHG0bPF1rHG
1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG
0bPF1rHGzrPL1rHG0bPF0bPF1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG
0bPF1rHGzrPL1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPFzrPL1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41QnZCRJZkRJZk
RJZkPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfamIZ/
mIZ/+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
1rHG1rHG1rHG0bPF0bPF1rHG1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG
0bPF1rHG0bPF1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG0bPF0bPF1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHG
1rHG1rHG1rHG0bPFzrPL0bPFzrPL1rHGzrPL1rHG1rHG1rHG1rHG1rHGzrPL
1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41QnZCRJZk
RJZkPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFaUaFaUaFa
RJZkRJZkPJRvPJRvPJRvUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
0bPFzrPL1rHG1rHG1rHG1rHGzrPL1rHG0bPF1rHGzrPL1rHG1rHGzrPL0bPF
1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG0bPF
1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHGzrPL0bPF
1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG1rHG1rHG0bPF
0bPF1rHGzrPL1rHG1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG1rHG1rHG0bPF
1rHG1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHGZTwhZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41QnZCQnZC
RJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZCQnZC
QnZCOV41OV41OV41OV41OV41OV41OV41OV41OV41OV41OV41QnZCQnZCUaFa
RJZkRJZkRJZkRJZkRJZkRJZkRJZkPJRvUaheUahePJRvPJRvPJRvQnZCQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfamIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG
zrPL1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG1rHG
1rHG1rHGzrPL0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL26/G1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG26/G1rHG1rHG1rHG1rHGzrPL0bPF1rHG26/G1rHG1rHG1rHG1rHG
1rHG1rHGzrPL1rHG0bPF0bPF1rHG26/G1rHG1rHG1rHG1rHGOV41ZTwhOV41
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjQnZC
QnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZCQnZCQnZCQnZCQnZCQnZC
QnZCOV41OV41OV41OV41OV41OV41TSobTSobTSobTSobTSobOV41OV41OV41
QnZCQnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkPJRvPJRvPJRvRZZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHG1rHG
26/GzrPL1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHGzrPL1rHG1rHG1rHG1rHG
1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG26/G1rHG1rHG1rHG
3rDA1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG
1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHGOV41OV41OV41QnZCQnZCQnZC
QnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
OV41QnZCRJZkRJZkRJZkRJZkRJZkOV41OV41OV41OV41OV41OV41OV41TSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
OV41OV41OV41OV41QnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkR5dlRJZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
5NrTmIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL26/G1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHGOV41OV41QnZCQnZCUaFaUaFaUaFaUaFaUaFa
QnZCQnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
OV41OV41QnZCQnZCQnZCQnZCQnZCOV41OV41OV41OV41OV41XDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobOV41OV41QnZCQnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG
3rDA1rHG1rHG1rHGzrPLOV41OV41OV41UaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaQnZCQnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjOV41OV41OV41OV41OV41OV41OV41XDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobOV41OV41OV41OV41OV41PJRvRJZkRZZlQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/3dfa3dfa3dfamIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA
0bPF1rHG1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG
3rDA26/G1rHG1rHG1rHG1rHG26/G1rHG1rHG3rDA0bPF3rDA1rHG3rDA1rHG
1rHG3rDA1rHG1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG3rDA
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG26/G1rHGTWRFQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaRJZkOV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjOV41OV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobXDQjOV41OV41OV41OV41OV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/1rHG1rHG
1rHG1rHG1rHG3rDA1rHG1rHG3rDA1rHG1rHG26/G3rDA1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G26/G1rHG1rHG1rHG
1rHG3rDA3rDA3rDA3rDA0bPF26/G1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG
1rHG1rHG3rDA0bPF1rHG1rHG1rHG3rDA1rHG1rHG3rDA1rHG3rDA0bPF1rHG
26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA3rDA3rDA1rHG3rDA1rHG1rHG
3rDA1rHG1rHGVmlQQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaPJRvOV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobUzAhZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/1rHG3rDA
1rHG3rDAzrPL1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG3rDA1rHG26/G
1rHG1rHG26/G3rDA1rHG1rHG1rHG1rHG1rHG3rDA0bPF3rDA3rDA1rHG1rHG
3rDA1rHG1rHG0bPF1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA
1rHG26/G1rHG26/G26/G3rDA1rHG0bPF3rDA26/G1rHG1rHG1rHG26/G1rHG
1rHG1rHG1rHG3rDA1rHG1rHG3rDA26/G1rHG1rHG1rHG1rHG0bPF3rDA1rHG
0bPFy6SwP3A/QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UahePJRvPJRvPJRvOV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTiwcZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/+O3R
+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/3rDA1rHG
1rHG1rHG3rDA3rDA1rHG1rHG1rHG26/G1rHG1rHG26/G1rHG1rHG1rHG1rHG
26/G3rDA1rHG1rHG26/G26/G1rHG26/G1rHG1rHG1rHG1rHG1rHG26/G26/G
1rHG1rHG26/G1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA1rHG26/G1rHG1rHG
1rHG1rHG3rDA1rHG1rHG1rHG26/G1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA
26/G26/G1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG26/G
1rHGP3JAQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvOV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscUC0eZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/26/G26/G
1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA26/G3rDA1rHG1rHG26/G1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHG1rHG26/G1rHG3rDA1rHG1rHG3rDA3rDA1rHG
1rHG1rHG1rHG26/G26/G3rDA3rDA3rDA26/G3rDA1rHG3rDA3rDA1rHG26/G
3rDA26/G1rHG3rDA26/G3rDA1rHG1rHG3rDA1rHG3rDA26/G1rHG3rDA1rHG
3rDA3rDA1rHG3rDA1rHG26/G26/G26/G26/G26/G3rDA1rHG1rHG3rDA1rHG
RX5HQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvOV41OV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiwcTiscZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/26/G1rHG3rDA
26/G26/G26/G1rHG26/G26/G26/G1rHG1rHG1rHG3rDA3rDA3rDA3rDA3rDA
1rHG1rHG1rHG3rDA1rHG3rDA3rDA3rDA26/G1rHG1rHG1rHG1rHG1rHG1rHG
3rDA3rDA3rDA1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG3rDA3rDA1rHG
3rDA1rHG1rHG1rHG1rHG3rDA26/G1rHG3rDA1rHG3rDA3rDA1rHG1rHG1rHG
1rHG1rHG1rHG26/G1rHG3rDA3rDA3rDA3rDA1rHG3rDA26/G1rHGlKCKQnZC
QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvOV41OV41OV41OV41XDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscTiscZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/3rDA1rHG3rDA
3rDA3rDA3rDA3rDA1rHG3rDA1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG3rDA
3rDA3rDA1rHG26/G1rHG1rHG1rHG3rDA1rHG3rDA3rDA1rHG26/G3rDA26/G
1rHG1rHG1rHG3rDA3rDA26/G26/G1rHG3rDA3rDA26/G26/G1rHG1rHG3rDA
1rHG26/G26/G3rDA3rDA1rHG3rDA3rDA1rHG1rHG1rHG1rHG26/G3rDA26/G
26/G3rDA26/G3rDA3rDA1rHG1rHG1rHG1rHG26/G1rHG3rDA3rDAQnZCQnZC
QnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvOV41OV41OV41OV41XDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobSzAeSzAeSzAeTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscTSobZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/3rDA1rHG1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHG3rDA1rHG1rHG26/G1rHG26/G1rHG26/G1rHG
1rHG1rHG1rHG3rDA26/G26/G3rDA1rHG3rDA1rHG26/G3rDA3rDA1rHG3rDA
26/G3rDA1rHG1rHG3rDA3rDA1rHG1rHG1rHG3rDA3rDA3rDA1rHG1rHG26/G
3rDA3rDA1rHG1rHG26/G1rHG26/G26/G3rDA26/G26/G1rHG1rHG3rDA3rDA
1rHG3rDA1rHG1rHG3rDA1rHG26/G3rDA3rDA1rHG1rHG1rHGQnZCQnZCUaFa
UaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41XDQjXDQjXDQj
XDQjOV41OV41OV41OV41OV41OV41OV41OV41QnZCQnZCQnZCQnZCQnZCQnZC
QnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCOV41OV41OV41
OV41OV41OV41OV41OV41OV41OV41OV41OV41/vbX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/26/G26/G1rHG26/G
26/G3rDA1rHG1rHG26/G26/G26/G3rDA3rDA3rDA3rDA3rDA3rDA26/G3rDA
26/G3rDA1rHG3rDA3rDA1rHG26/G26/G26/G3rDA1rHG1rHG26/G1rHG26/G
3rDA26/G3rDA26/G1rHG1rHG3rDA26/G26/G1rHG1rHG1rHG3rDA26/G3rDA
1rHG1rHG3rDA26/G3rDA3rDA26/G3rDA26/G3rDA3rDA3rDA3rDA1rHG26/G
3rDA1rHG26/G26/G1rHG3rDA3rDA26/G1rHG3rDAlKCKQnZCUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41QnZC
QnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaQnZCQnZC
QnZCQnZCQnZCOV41OV41QnZCQnZCRJZkQnZCQnZCOV413dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/26/G3rDA3rDA3rDA3rDA
3rDA1rHG3rDA3rDA3rDA1rHG3rDA26/G1rHG26/G1rHG26/G1rHG3rDA26/G
3rDA26/G26/G1rHG1rHG26/G3rDA3rDA3rDA1rHG3rDA3rDA3rDA3rDA3rDA
3rDA26/G3rDA3rDA26/G26/G3rDA3rDA3rDA3rDA26/G26/G3rDA1rHG3rDA
26/G26/G3rDA3rDA26/G1rHG26/G3rDA1rHG1rHG26/G26/G26/G1rHG26/G
3rDA3rDA3rDA3rDA3rDA1rHG3rDA26/G26/GlqGHQnZCUaFaUaFaUaFaUaFa
UaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41QnZCQnZC
QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaRJZkRJZkRJZkVZ5tQnZCQnZCOV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G1rHGmIZ/mIZ/1rHG
26/G26/G26/G1rHG3rDA26/G3rDA26/G3rDA3rDA26/G3rDA1rHG26/G26/G
26/G3rDA3rDA26/G3rDA26/G1rHG1rHG3rDA26/G26/G1rHG26/G1rHG26/G
26/G3rDA26/G26/G3rDA3rDA26/G26/G1rHG26/G3rDA3rDA26/G26/G26/G
3rDA3rDA1rHG1rHG3rDA3rDA3rDA1rHG3rDA3rDA3rDA26/G3rDA3rDA3rDA
26/G26/G26/G26/G26/G26/G1rHG3rDAaaFpQnZCUaFaUaFaUaFaUaFaUaFa
UaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41QnZCQnZCQnZCUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaFaUaFaUaFaUaFaRJZkPJRvPJRvRJZkRpdlTZppQnZC3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G26/G3rDAmIZ/mIZ/26/G
3rDA3rDA3rDA3rDA26/G3rDA26/G3rDA1rHG1rHG3rDA26/G3rDA3rDA3rDA
3rDA26/G26/G3rDA26/G3rDA26/G3rDA26/G26/G3rDA3rDA26/G26/G3rDA
26/G3rDA3rDA3rDA26/G3rDA3rDA3rDA3rDA26/G26/G3rDA3rDA3rDA26/G
26/G3rDA3rDA3rDA3rDA26/G3rDA26/G26/G26/G3rDA26/G26/G26/G3rDA
3rDA3rDA26/G26/G3rDA3rDA3rDAOV41QnZCUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41QnZCRJZkUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaFaUaFaPJRvPJRvRJZkRJZkRJZkQnZCQnZC3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ/+O3R5NrTmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/3rDA26/GmIZ/mIZ/mIZ/26/G
26/G1rHG26/G3rDA26/G3rDA3rDA3rDA3rDA26/G3rDA26/G1rHG26/G3rDA
3rDA3rDA26/G3rDA26/G3rDA26/G26/G3rDA1rHG26/G3rDA3rDA26/G26/G
3rDA3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA3rDA26/G26/G26/G3rDA
3rDA26/G26/G26/G26/G3rDA26/G3rDA3rDA3rDA3rDA3rDA3rDA3rDA26/G
26/G26/G3rDA3rDAOV41OV41QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvPJRvOV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkQnZCQnZCOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/3rDA3rDAmIZ/mIZ/mIZ/mIZ/3rDA
3rDA3rDA3rDA3rDA3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA3rDA26/G
3rDA3rDA3rDA3rDA3rDA26/G3rDA3rDA3rDA3rDA3rDA26/G3rDA3rDA3rDA
26/G3rDA3rDA26/G3rDA26/G3rDA26/G26/G26/G3rDA3rDA3rDA3rDA26/G
467B3rDA3rDA3rDA26/G3rDA3rDA467B26/G26/G3rDA3rDA26/G3rDA3rDA
3rDA3rDA3rDAOV41OV41UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvOV41QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZCOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/3rDA26/GmIZ/uqmcmIZ/q5uPmIZ/26/G
467B26/G26/G26/G3rDA3rDA26/G467B3rDA3rDA467B3rDA26/G3rDA26/G
26/G3rDA26/G26/G467B26/G467B26/G26/G26/G3rDA26/G3rDA3rDA3rDA
3rDA467B26/G3rDA26/G3rDA467B467B467B3rDA26/G467B3rDA26/G3rDA
26/G26/G26/G26/G3rDA467B26/G26/G3rDA3rDA26/G26/G3rDA26/G3rDA
3rDAOV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvOV41OV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRZZkQnZCOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
3dfamIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G3rDAmIZ/5tbBmIZ/qJeMmIZ/3rDA
26/G467B467B3rDA3rDA26/G467B3rDA26/G26/G26/G26/G3rDA26/G3rDA
3rDA26/G3rDA3rDA3rDA3rDA26/G3rDA467B467B3rDA467B26/G26/G26/G
26/G467B467B467B3rDA26/G3rDA3rDA467B3rDA26/G26/G467B3rDA3rDA
467B467B467B3rDA26/G3rDA3rDA467B3rDA3rDA467B26/G467B26/GOV41
QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUKZdUaheOV41
QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
7t/I7t/I7d7HmIZ/mIZ/mIZ/3rDA4LLAmIZ/uqmc5NW/mIZ/m4mBmIZ/3rDA
3rDA26/G3rDA26/G3rDA26/G26/G3rDA3rDA3rDA467B26/G3rDA3rDA3rDA
467B3rDA3rDA26/G467B3rDA3rDA26/G3rDA26/G3rDA3rDA467B467B3rDA
3rDA3rDA26/G3rDA26/G3rDA26/G26/G26/G467B3rDA467B3rDA26/G467B
3rDA3rDA3rDA26/G3rDA467B26/G3rDA26/G467B3rDA467BOV41QnZCUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUKZdP3E/RJZk
RJZkRJZkUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I
7t/ImIZ/mIZ/mIZ/mIZ/467BmIZ/mIZ/m4mC69zF6tvFmIZ/mIZ/mIZ/3rDA
3rDA3rDA467B3rDA3rDA467B3rDA467B467B26/G3rDA467B467B26/G26/G
3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA467B26/G3rDA3rDA3rDA467B
3rDA3rDA3rDA467B467B467B467B3rDA3rDA467B3rDA26/G467B26/G467B
26/G3rDA467B467B26/G467B26/G467B3rDAOV41OV41QnZCUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFa
UaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/3rDAmIZ/mIZ/mIZ/yrqq7N3GmIZ/qpuXmIZ/27HG26/G
467B26/G467B467B3rDA467B26/G3rDA467B3rDA3rDA3rDA467B467B26/G
467B467B467B3rDA26/G467B467B26/G26/G467B26/G26/G3rDA26/G3rDA
467B467B26/G3rDA3rDA3rDA3rDA467B26/G26/G467B467B3rDA3rDA26/G
467B467B467B3rDA3rDA3rDAOV41OV41OV41OV41UaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRpdlQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/3bTGmIZ/mIZ/mIZ/mYeAyrmp7t/ImIZ/1c3PmYeAmIZ/467B467B
26/G467B3rDA26/G26/G3rDA467B26/G467B26/G467B26/G3rDA467B467B
467B3rDA3rDA467B467B467B3rDA467B467B3rDA467B467B26/G467B467B
467B467B467B26/G467B467B26/G467B3rDA26/G3rDA26/G467B3rDA467B
26/GmaqROV41OV41QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRZZkQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/7t/I5dXA7t/I7t/ImIZ/sqShmIZ/47DB467B467B
3rDA467B467B467B26/G3rDA467B3rDA467B26/G467B467B3rDA3rDA3rDA
467B26/G3rDA467B3rDA26/G467B3rDA467B3rDA467B467B3rDA3rDA467B
3rDA467B3rDA467B467B26/G6qy8467B467B467B467BQnZCQnZCQnZCQnZC
QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvRJZkRZZkXqNy
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/7t/I7t/I7t/I7t/I7t/I2szKmIZ/z8C9mIZ/mIZ/3rLA467B47DB
467B26/G3rDA467B6qy8467B467B467B3rDA467B3rDA3rDA467B467B26/G
3rDA467B26/G3rDA26/G6qy8467B467B26/G467B3rDA467B467B26/G3rDA
OV41467B467B3rDA467BOV41OV41QnZCQnZCQnZCQnZCUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvRJZkRZZkRZZl
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/I
7t/I7t/I7t/I7t/I7t/I//fXmIZ/mIZ/3dfarJyWmIZ/mIZ/3rDA47DB3rDA
467B467B3rDA3rDA3rDA467B3rDA467B467B467B26/G26/G467B6qy8467B
467B467B26/G6qy83rDA3rDA467B467B26/G467B467B467B467B467B467B
QnZCQnZCQnZCQnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvR5dmR5dl
QnZC3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R5NrT3dfa//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/I7t/I7t/I
7t/I//fX//fX//fX//fXmIZ/3dfa3dfawri3mIZ/mIZ/47DB26/G47DB26/G
467B467B467B467B467B3rDA467B467B467B467B467B6qy8467B3rDA3rDA
467B467B6qy8467B26/G467B26/G467B6qy8467B3rDA467B467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRZZkRJFf
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+O3R+O3R+O3R5NrT5NrT5NrT5NrT3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/5NrT+O3R+O3R
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/3dfa3dfa3dfanoyGmIZ/3bjI6qy847DB5bPD467B
3rDA467B26/G467B467B467B3rDA3rDA467B467B3rDA26/G467B467B3rDA
467B3rDA3rDA467B26/G6qy8467B467B3rDA467B26/G467B3rDA467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZk
Q3ZDOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa5NrTmIZ/mIZ/mIZ/mIZ/mIZ/5NrT5NrT5NrT5NrT
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R+O3R5NrT+O3R
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/5MfN6rC+467B47DB467B467B
467B467B6qy8467B467B467B467B467B467B467B467B6qy8467B467B467B
467B467B467B467B6qy8467B467B467B467B467B6qy8467B467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwPJRvRJZkRZZl
Q3ZDOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/5NrT
5NrT5NrT3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R+O3R+O3R+O3R+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/477K47DB467B5bbD467B467B
467B467B467B467B467B467B467B467B467B467B467B467B467B467B467B
467B467B467B467B467B467B467B467B467B467B467B6KzB467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheP5ZxPJRvRJZkRZZk
QnZDOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/+O3R+O3R+O3R//fX+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/477K47DB47DB5bTD467B467B467B
467B467B467B467B467B6KzB6KzB467B467B467B467B467B467B6KzB467B
467B467B467B467B467B467B467B6KzB467B467B467B467B467B467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwQZdyQJZxRJZkRJZk
QnZDOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3R+O3R+O3R
+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa2szK2szKmIZ/5bvG467B5bXD57jD6KzB467B467B467B
467B467B467B467B467B467B467B467B467B467B467B467B467B467B6KzB
6KzB467B467B467B467B467B467B6KzB467B467B467B467B467B467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPpVwQJZxRJZkRZZl
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3R
+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szKmIZ/mIZ/6q68467B467B467B467B6KzB6KzB467B
467B467B467B467B467B467B6KzB6qy86KzB467B467B6KzB467B6qy8467B
467B6qy8467B467B467B467B467B467B467B467B467B467B467B6qy8467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwPJRvPJRvRJZkRJZk
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
+O3R+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/467B6K7B5bTD6KzB6qy8467B6qy8467B467B
467B467B6KzB467B467B467B467B467B6qy8467B467B467B467B467B467B
467B467B6KzB6qy8467B467B6qy86qy8467B467B467B6qy8467B6qy8467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvQJZxPJRvPpVwRJZkRZZk
QnZCOV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa
2szK2szKmIZ/mIZ/mIZ/mIZ/467B6qy8467B6qy8467B6qy8467B6qy86qy8
6KzB6KzB467B6KzB467B6KzB467B467B467B467B467B6qy8467B467B6qy8
467B6qy86qy8467B6KzB6KzB467B467B6qy86KzB467B467B467B467B6qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJhzPJRvPZRvRJZkRJZk
RZZkOV41OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK
3dfamIZ/mIZ/mIZ/mIZ/6qy8467B6qy8467B467B467B467B467B6qy86qy8
6qy8467B6qy86KzB6qy86KzB6KzB467B6qy86qy8467B6KzB6qy8467B6qy8
467B467B467B6qy86qy8467B6KzB467B6qy86qy8467B6KzB467B467B6KzB
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPZRvPJRvPZRvRJZk
RZZlOV41OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szKmIZ/
mIZ/mIZ/mIZ/6q686qy8467B6KzB467B6qy86qy86qy86qy8467B467B467B
467B6qy8467B6qy8467B6qy8467B6qy8467B467B6KzB6qy8467B6qy8467B
6KzB6qy86KzB467B467B6qy86qy8467B6qy8467B6qy86qy86qy8467B6qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPZRvPJRvPZRvRJZk
RZZkOV413dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/
mIZ/6q++47DD47DB6qy86qy86qy8467B467B467B467B6qy8467B467B6qy8
467B6qy8467B6qy86qy86qy8467B6qy86qy86qy8467B6qy8467B467B6qy8
467B6qy86qy8467B467B6qy86qy8467B6qy8467B467B467B6qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPZRvRJZk
RJZkOV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK287K5tfImIZ/mIZ/mIZ/48bO
47DB467B6q686q6+467B6qy8467B6qy8467B6qy86qy86qy86qy86qy8467B
6qy8467B6qy8467B467B6qy86qy8467B6qy86qy86qy8467B6qy86qy8467B
6qy8467B467B6qy86qy8467B467B6qy8467B6qy86qy86qy86qy8467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkOV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szK2szK2szK2szK4NLJmIZ/mIZ/mIZ/4cLN6LLA6q6+
6q686qy86qy86qy8467B6qy8467B6qy86qy8467B467B467B6KzB6qy8467B
6qy8467B6qy86qy8467B6qy86qy8467B467B6qy86qy8467B467B6qy8467B
6qy86qy86qy8467B6qy86qy8467B6qy8467B6qy86qy8467B6qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRZZk
RJZkOV41OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/6LC/6qy86qy847DB6LXC
467B467B467B467B6qy86qy86qy86qy8467B6qy86qy86qy86qy86qy86qy8
6KzB6qy86KzB6qy86qy86qy86qy86qy86qy8467B6qy86qy86qy86qy86qy8
467B6qy8467B6qy86qy86qy86qy86qy86qy8467B467B6qy86qy86qy86KzB
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkeYVoeYVo2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK
2szK2szK2szK2szK2szK2szK2szK2szK2szK3dfa2szK2szK2szK2szK2szK
2szK287KmIZ/mIZ/mIZ/mIZ/6rG+6K7B6rjF6qy8467B6qy86qy8467B6qy8
6qy86qy86qy86qy8467B6qy86KzB6qy86qy86qy86qy86qy86KzB6qy86qy8
6qy86qy86KzB6qy86KzB467B6qy86qy86qy86qy86qy86KzB6KzB6qy86qy8
6qy86qy86qy86qy86KzB6qy86KzB6qy86qy86qy86qy86KzB467B6qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRZZk
RZZlOV41eYVo2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/48TN6q6+6q686q686qy86KzB6q686qy86qy86qy86qy8
6qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86KzB6KzB6qy86qy86qy8
6qy86qy86qy86KzB6qy86qy86qy86qy86qy86KzB6KzB6qy86qy86qy86qy8
6KzB6qy8467B6qy86qy86KzB6qy86qy86qy86qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
SplnOV41OV41mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/6LbD6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86KzB6qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86KzB6KzB6qy86qy86qy86qy86qy86KzB6qy86qy8
6qy88Kq96qy86qy86qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV41OV41mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/7LK+6rC+6qy86LTC
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy8
6qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkOV41OV41mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX7t/I
//fX3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/8Kq9
8Kq96qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy88Kq96qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy8
6qy86qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV41OV41mIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa//fX7t/I
7t/I2szK3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ/6q+86qy86q686qy87LjA7LK+6qy86qy86qy86qy86qy86qy86qy8
6qy88Kq96qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
8Kq96qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq9
6qy86qy86qy88Kq98Kq96qy88Kq96qy86qy86qy86qy88Kq96qy86qy86qy8
6qy86qy86qy86qy86qy88Kq96qy88Kq98Kq96qy86qy86qy86qy88Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV416qy88Kq98rO/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa//fX7t/I
7t/I7t/I2szKmIZ/2szK3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/6qy88Kq98Kq98Kq98Kq96qy86qy88Kq96qy88Kq96qy8
6qy88Kq98Kq96qy88Kq96qy88Kq98Kq96qy86qy86qy86qy88Kq96qy86qy8
6qy88Kq96qy88Kq96qy88Kq98Kq96qy88qu38qu36qy86qy88Kq96qy88Kq9
8Kq96qy86qy86qy88Kq96qy86qy88Kq98qu36qy86qy88Kq96qy86qy86qy8
8Kq98Kq98Kq98Kq96qy88Kq96qy86qy88Kq96qy88Kq98Kq96qy86qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV41OV418Kq97rrA6qy8mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa//fX
7t/I7t/ImIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/6qy86qy86qy88Kq98Kq96qy88Kq96qy88Kq9
6qy86qy86qy86qy86qy88qu36qy88qu38Kq98Kq98Kq98Kq96qy88qu38qu3
8Kq96qy88qu36qy88Kq96qy86qy88Kq96qy86qy88Kq98Kq96qy88Kq96qy8
6qy88Kq96qy86qy88qu36qy86qy88qu36qy88qu36qy88qu38Kq98Kq98qu3
6qy86qy86qy86qy86qy88qu38Kq96qy88qu36qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV41OV418qu36qy88Kq98Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa
//fX7t/ImIZ/mIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/I2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
8Kq96qy88Kq96qy86qy86qy86qy86qy88qu36qy86qy86qy86qy86qy86qy8
8qu36qy86qy88qu38Kq96qy86qy86qy86qy86qy88qu36qy86qy88qu38qu3
8qu36qy86qy86qy88qu38qu36qy86qy86qy88qu36qy88qu36qy86qy88Kq9
8Kq96qy88qu36qy86qy86qy88qu36qy88Kq96qy88Kq96qy88qu36qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV418qu36qy88Kq96qy86qy88Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa
3dfa7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
2szK2szK2szK2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/8Kq98qu38qu36qy88qu36qy88qu36qy88Kq96qy88qu38Kq98Kq96qy8
6qy86qy88qu36qy88qu38qu38qu38Kq98Kq98qu36qy86qy88Kq96qy86qy8
6qy86qy88qu38Kq96qy86qy88Kq96qy86qy86qy86qy86qy88qu36qy86qy8
8qu38qu36qy88Kq98Kq96qy86qy86qy88qu38Kq96qy88Kq96qy88Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkQnZC
OV418Kq98qu38Kq98qu36qy86qy88Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa
3dfa3dfa7t/I7t/ImIZ/6qy8mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa2szK3dfa3dfa2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/8Kq98Kq9
8qu36qy86qy88Kq96qy88Kq96qy88Kq96qy88qu36qy86qy86qy88Kq98Kq9
8Kq96qy88Kq96qy86qy86qy86qy88qu36qy88Kq98Kq96qy86qy88Kq98Kq9
8qu36qy86qy88Kq98Kq96qy88qu38qu38Kq98Kq98Kq96qy88Kq98qu36qy8
6qy88Kq96qy88Kq98qu38Kq98qu36qy88qu38qu38qu36qy88qu38qu36qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkQnZC
OV416qy86qy88qu38Kq98Kq98Kq98qu38Kq9mIZ/mIZ/3dfa2szK2szK3dfa
3dfa2szK2szK7t/ImIZ/mIZ/8Kq96qy8mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK
2szK2szK2szK2szK3dfa2szK2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szKmIZ/mIZ/37i28q238qu38qu3
6qy88Kq98Kq98qu38Kq96qy88Kq98Kq98qu38Kq98Kq98Kq98qu38qu36qy8
8qu38Kq96qy88Kq98Kq98Kq98qu36qy86qy88Kq98qu38Kq98Kq98qu38Kq9
8Kq98Kq98Kq98qu38Kq98qu36qy86qy88Kq98qu36qy88Kq98qu36qy88Kq9
6qy88Kq98qu38qu36qy86qy86qy88Kq96qy86qy86qy88qu36qy86qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV416qy86qy88Kq98qu38qu36qy88qu38qu38qu3mIZ/mIZ/mIZ/2szK2szK
2szK3dfa2szK2szK7t/ImIZ/mIZ/6qy86qy8mIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa2szK2szK2szK283JmIZ/mIZ/4Le06q687LS+6qy86qy88qu3
8qu38qu36qy88qu38qu38qu38qu38Kq96qy88qu38qu38Kq98Kq98qu38Kq9
8qu38qu38qu38qu38qu36qy88Kq98Kq98qu38Kq98qu38qu36qy88qu36qy8
8qu38qu36qy88qu36qy88Kq98Kq98qu36qy88qu36qy86qy88Kq98qu38Kq9
8Kq98Kq96qy88Kq98qu38Kq98qu38Kq98Kq98qu38Kq98Kq98Kq98qu38Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV418qu38qu38qu36qy88Kq98Kq98Kq98Kq96qy8mIZ/mIZ/mIZ/mIZ/2szK
2szK2szK3dfa2szK2szK7t/ImIZ/8qu38Kq98Kq98Ky9mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK2szK2szK2szK2szK2szK
2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/8q238LC/8qu38Ky98Kq98Kq98Kq9
6qy86qy88Kq98Kq98Kq96qy86qy86qy88qu36qy86qy88Kq96qy88Kq96qy8
8Kq98Kq96qy86qy86qy88Kq98Kq98qu36qy86qy88Kq96qy88Kq96qy88Kq9
6qy86qy88Kq98Kq98Kq98qu38qu36qy88Kq98Kq98qu38Kq98qu36qy88Kq9
8qu38qu38Kq98qu38Kq98qu36qy88qu38qu38Kq96qy88qu38qu38Kq98qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV418Kq98Kq98qu36qy88qu36qy88qu38qu38Kq98Kq9mIZ/mIZ/mIZ/mIZ/
2szK2szK2szK2szK2szK2szKmIZ/mIZ/8Kq98qu38qu37LS+8rG/8qu3mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK
mIZ/mIZ/mIZ/mIZ/mIZ/7MDF8q237LK+8qu38Ky98qu38qu38qu38Kq98Kq9
8Kq98qu38Kq98Kq98Kq98Kq98qu38Kq98Kq98qu38qu38qu38Kq98qu36qy8
8qu38Kq98qu38Kq98qu38qu38Kq98qu38qu38qu38Kq98Kq98Kq98qu38Kq9
8qu38qu38Kq98qu38Kq96qy88qu38qu38qu38Kq98qu38Kq98Kq98qu36qy8
6qy88qu38Kq96qy88Kq98Kq98Kq98Kq98qu38qu36qy86qy88qu36qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRv
OV418Kq98Kq98Kq98qu38Kq98qu36qy88Kq98qu38qu38Kq98Kq9mIZ/mIZ/
mIZ/2szK2szK2szK3dfa2szK2szKmIZ/mIZ/6q686qy88qu38q+58Kq98qu3
8Kq98Kq996m48Kq98Kq98Kq9mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/+NHG8q+58q236q688Kq98Kq98qu36qy88Kq98Kq98Kq98Kq98qu38qu3
8qu38Kq98qu38qu38qu38qu38Kq98Kq98qu38Kq96qy88Kq98qu38Kq996m4
8Kq98qu38Kq98qu38Kq96qy88qu38Kq98Kq96qy88qu38qu38qu38Kq98qu3
8Kq98Kq98qu38Kq98qu38qu38Kq98Kq96qy88qu38Kq98qu38qu36qy88qu3
8Kq98Kq98Kq98qu38qu38qu38qu38Kq96qy88Kq98qu38qu38Kq98qu38qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkRJZkOV41
OV418qu38Kq98Kq98qu38Kq98Kq98Kq98Kq98Kq98Kq98qu38Kq98qu3mIZ/
mIZ/mIZ/mIZ/2szK2szK2szK2szK2szKmIZ/mIZ/8K6/8Kq98qu38Kq98qu3
8qu38Kq98qu38Kq98Kq98Kq98Kq98Kq98qu38Kq98qu38Kq98qu38Kq98qu3
8Kq98Kq98Kq98qu38qu38qu38Kq996m48qu38Kq98qu38qu38Kq96qy88Kq9
8Kq98Kq96qy88Kq98Kq98qu38qu38Kq98qu38qu38qu38Kq98qu38Kq98qu3
8Kq98Kq98Kq98qu38qu38Kq98Kq98qu38qu38Kq98Kq98qu38qu38Kq98Kq9
8qu38Kq98qu38Kq98Kq98Kq98Kq98qu38Kq98qu38Kq98Kq996m48Kq98qu3
8qu38qu38Kq98Kq98Kq98Kq98qu396m48qu38Kq98Kq98Kq98Kq98Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
OV418Kq996m48qu38Kq98qu396m48qu38qu38qu38qu38Kq98Kq98Kq98qu3
8qu3mIZ/mIZ/mIZ/2szK2szK2szK2szK2szKmIZ/mIZ/9L6+8Kq98qu38qu3
8Kq98qu38Kq98qu38qu38qu38qu38qu38Kq98qu38Kq98qu38Kq98qu38Kq9
8qu38qu38qu38Kq98Kq98Kq98qu38Kq98Kq98qu38Kq98Kq98qu396m496m4
8qu38qu396m48qu396m48Kq996m48qu38Kq996m48Kq98qu38Kq98qu38Kq9
8Kq98qu38qu38Kq98Kq98qu396m48Kq98Kq98qu38qu38Kq98Kq98qu396m4
8Kq98qu38Kq98qu38qu396m48qu38Kq98Kq98Kq98qu38qu38Kq98qu38Kq9
8Kq98Kq98qu38qu38qu38qu38Kq98Kq996m48qu38Kq98qu38qu38qu38qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38Kq98Kq996m48Kq98Kq98Kq98Kq98Kq98Kq98qu396m48qu38Kq98Kq9
8Kq98Kq9mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szKmIZ/mIZ/9cbG8Kq98qu3
8Kq98qu38qu38Kq98Kq98Kq98Kq98qu38Kq98qu396m496m48Kq98qu38Kq9
8Kq98Kq98qu38qu38qu396m48qu38qu38Kq98qu38qu38qu38Kq98Kq98Kq9
8Kq98Kq98Kq98Kq98qu38Kq98Kq98qu38Kq996m48Kq996m48Kq98qu38qu3
8Kq996m48qu396m48Kq98qu396m48qu38Kq98Kq98qu38qu38Kq98Kq98qu3
8qu38qu38qu396m48Kq98Kq98qu38qu38qu38Kq98Kq98qu38Kq98qu38Kq9
8qu38qu38Kq98Kq98Kq98qu38Kq98Kq996m496m48qu38Kq98Kq98Kq98qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8Kq98qu396m48Kq996m48qu396m48qu38qu396m48Kq98qu38Kq98qu396m4
96m496m48qu396m4mIZ/mIZ/mIZ/mIZ/mIZ/2szKmIZ/mIZ/mIZ/mIZ/8Kq9
8qu396m48Kq996m496m496m48qu38qu396m48qu38Kq98Kq98qu38Kq996m4
8qu38qu396m496m48Kq98Kq996m496m48qu396m48Kq98Kq98qu38qu396m4
8qu38qu38qu38qu38Kq98qu38qu38Kq98qu38Kq98qu38Kq98qu38Kq996m4
96m48Kq98Kq98Kq98qu38Kq98Kq98Kq996m48qu396m48Kq996m48qu38Kq9
8Kq98Kq98Kq98Kq98qu396m496m496m48qu38qu38qu38Kq996m496m48qu3
8Kq996m496m496m48qu38qu38qu38qu38Kq98Kq98Kq996m48qu396m48Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38qu38qu38Kq98qu38qu38qu38qu38qu396m48Kq996m496m48Kq98qu3
8qu38Kq996m48qu396m48q65mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
8Kq98qu38qu38Kq98Kq996m496m48Kq98Kq98qu396m496m48qu38Kq996m4
96m48Kq98Kq98qu38qu38Kq98Kq996m48Kq996m496m48Kq996m48qu396m4
96m496m496m496m48Kq98qu396m48Kq98qu396m48qu396m496m48Kq98Kq9
8qu396m48qu396m48qu38qu38qu38qu396m48Kq98qu38Kq98qu396m496m4
96m48qu396m48qu38Kq98Kq98Kq98Kq98Kq996m48qu38Kq98Kq996m48qu3
8Kq98qu38qu38qu396m48Kq98Kq98qu38qu38qu38qu396m496m496m48qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8Kq98Kq996m496m48Kq98qu396m48Kq98Kq98Kq996m48qu38Kq996m48Kq9
8qu396m48Kq98Kq98qu38qu38Kq99626mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/96m48Kq996m48qu38Kq98Kq98qu396m496m48qu38Kq996m496m48Kq9
8Kq996m48qu38Kq996m48qu396m48Kq996m48qu38qu396m48Kq996m48Kq9
8Kq98Kq98Kq98qu38qu396m48Kq996m496m48Kq996m48Kq98Kq996m48qu3
96m48qu396m48Kq996m48Kq996m496m48Kq98qu396m48qu38Kq98qu38Kq9
8qu38qu38Kq996m496m48qu38qu396m496m48Kq996m496m496m48Kq996m4
8qu38Kq996m496m48Kq996m496m496m496m48Kq98Kq98Kq98Kq996m48Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
96m48Kq98qu396m48Kq98Kq996m496m496m496m48Kq98qu38qu396m48Kq9
96m496m496m496m48Kq996m48K6996u496m496m496m496m48Kq9mIZ/mIZ/
mIZ/mIZ/8qu396m496m496m496m48qu38Kq996m496m48Kq98qu396m48qu3
8qu396m496m48Kq996m48Kq996m48qu396m48Kq98qu396m48Kq98qu396m4
96m496m496m496m48Kq996m48qu38Kq996m48Kq996m496m48qu396m48Kq9
96m48Kq996m48Kq996m48Kq98Kq996m496m48qu396m496m48Kq996m496m4
96m496m48Kq98qu396m496m48qu38qu396m48Kq98qu38qu396m48Kq996m4
96m48Kq98Kq98qu38qu38Kq98Kq996m496m496m48qu396m48Kq996m496m4
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu396m496m48qu396m496m48qu396m48qu38Kq996m496m496m48qu396m4
8qu38qu396m48Kq996m496m496m496m48qu38Kq98qu38qu396m48qu38Kq9
96m496m48Kq98qu38qu38qu38Kq996m496m48Kq98Kq996m496m48qu396m4
96m48Kq98qu396m48Kq996m48qu396m48Kq996m48Kq98qu396m496m48qu3
8qu38qu38Kq98Kq996m48qu396m496m48qu396m496m48qu396m48Kq996m4
8Kq996m48qu396m48qu396m496m496m48Kq996m48qu38qu396m48qu38Kq9
8Kq98qu396m496m48qu38Kq996m496m48qu396m496m496m48qu396m48Kq9
8Kq996m496m496m496m496m496m48Kq996m48qu396m48qu396m496m48qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38Kq996m496m48qu396m48qu396m496m496m48qu38Kq996m496m48Kq9
96m48Kq996m496m48qu396m48Kq996m496m48Kq98Kq996m496m496m48qu3
8qu396m48Kq996m496m496m48Kq98qu396m496m496m48Kq996m48Kq98Kq9
96m496m48qu396m48qu396m48Kq996m48qu396m496m48qu396m496m496m4
96m496m496m48qu396m496m48qu396m48qu38qu396m48Kq996m48qu396m4
96m496m496m496m48qu38qu38Kq996m496m496m496m48Kq996m496m496m4
96m48Kq98Kq996m496m496m496m496m48Kq996m48Kq996m496m496m496m4
8qu38qu38qu38Kq98qu38qu396m48Kq996m496m496m48qu38qu38Kq996m4
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvPJRv
96m496m48Kq98qu396m48Kq996m48Kq98qu396m48Kq996m48Kq98qu396m4
96m496m496m48qu396m496m496m48qu396m496m496m48qu38Kq996m496m4
96m496m496m496m496m496m496m496m496m496m48qu396m496m496m496m4
96m496m496m48qu396m48qu396m496m496m496m496m496m48Kq996m48Kq9
8Kq996m496m496m48Kq98Kq996m496m496m496m48qu396m496m496m48Kq9
96m48qu38Kq996m496m496m496m496m48Kq98Kq996m496m496m48qu396m4
96m496m496m496m48Kq996m48Kq996m496m48qu396m48Kq996m48qu396m4
96m496m496m496m496m496m496m496m496m48Kq98Kq996m48Kq996m496m4
====

Added modules/launcher/src/main/resources/cc/squirreljme/runtime/launcher/ui/splash.xpm.



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\kmid\launcher\cc\squirreljme\runtime\launcher\ui\splash_xpm[] = {
"240 320 1631 2",
"  	c None",
". 	c #5BCFF8",
"+ 	c #65CCF7",
"@ 	c #6BCBF5",
"# 	c #A8BBD3",
"$ 	c #BCB5BF",
"% 	c #AABCCF",
"& 	c #70CAF3",
"* 	c #80C8EA",
"= 	c #EE9A6E",
"- 	c #FF8C00",
"; 	c #EF996B",
"> 	c #8DC5E3",
", 	c #64C9F4",
"' 	c #62C6F0",
") 	c #58C9F1",
"! 	c #59CBF4",
"~ 	c #5CCFF8",
"{ 	c #EA9B79",
"] 	c #F4955A",
"^ 	c #6ACDF3",
"/ 	c #63C9F3",
"( 	c #50B9DE",
"_ 	c #3B7D98",
": 	c #1B4150",
"< 	c #000000",
"[ 	c #438CAA",
"} 	c #92C2E2",
"| 	c #AEB9CE",
"1 	c #3B8BA7",
"2 	c #4EA0C3",
"3 	c #4197B6",
"4 	c #4CB0D4",
"5 	c #4C9DBF",
"6 	c #54C1E7",
"7 	c #030F15",
"8 	c #3A89A5",
"9 	c #45A1C1",
"0 	c #0F2833",
"a 	c #143947",
"b 	c #173946",
"c 	c #53AACE",
"d 	c #4896B6",
"e 	c #02080C",
"f 	c #9BC2DB",
"g 	c #BEB3BE",
"h 	c #4189A6",
"i 	c #4895B5",
"j 	c #55AED3",
"k 	c #316981",
"l 	c #205466",
"m 	c #64CBF6",
"n 	c #438BA9",
"o 	c #316A82",
"p 	c #4997B7",
"q 	c #49AACC",
"r 	c #3C8EAB",
"s 	c #77C9F0",
"t 	c #FE8D15",
"u 	c #A4BED4",
"v 	c #46A3C3",
"w 	c #3886A2",
"x 	c #397892",
"y 	c #4CAED1",
"z 	c #1E4657",
"A 	c #48A8C9",
"B 	c #4087A4",
"C 	c #4D9EC0",
"D 	c #4199B8",
"E 	c #64CBF5",
"F 	c #204A5B",
"G 	c #D2ABA5",
"H 	c #EC9A73",
"I 	c #6ACBF5",
"J 	c #357F99",
"K 	c #3F84A1",
"L 	c #58B3D9",
"M 	c #326B83",
"N 	c #439DBD",
"O 	c #448EAD",
"P 	c #4BAED1",
"Q 	c #65CBF6",
"R 	c #72CAF2",
"S 	c #D6A8A0",
"T 	c #E69F83",
"U 	c #7BC9EC",
"V 	c #286479",
"W 	c #51BBE0",
"X 	c #255265",
"Y 	c #55C2E9",
"Z 	c #54ABD0",
"` 	c #45A0C0",
" .	c #4FB6DB",
"..	c #4086A3",
"+.	c #59B6DD",
"@.	c #5FC1E9",
"#.	c #76CAEE",
"$.	c #98C2DC",
"%.	c #51A6C9",
"&.	c #3E819D",
"*.	c #4BADCF",
"=.	c #3A7B96",
"-.	c #4691B1",
";.	c #5DBCE4",
">.	c #54ACD1",
",.	c #52A8CC",
"'.	c #22576A",
").	c #5BBAE1",
"!.	c #64CAF4",
"~.	c #60C2EB",
"{.	c #30687F",
"].	c #59B5DC",
"^.	c #4590AF",
"/.	c #52BBE1",
"(.	c #63C8F3",
"_.	c #58B4DA",
":.	c #59CBF3",
"<.	c #336E87",
"[.	c #2C6C82",
"}.	c #194352",
"|.	c #5FC1EA",
"1.	c #143340",
"2.	c #56C4EB",
"3.	c #53ABCF",
"4.	c #63C9F4",
"5.	c #4096B5",
"6.	c #5BB9E0",
"7.	c #2D6177",
"8.	c #3E91AF",
"9.	c #36738C",
"0.	c #0A2029",
"a.	c #327891",
"b.	c #4692B1",
"c.	c #1C4252",
"d.	c #3B8CA8",
"e.	c #5AB7DD",
"f.	c #57B2D7",
"g.	c #1F5163",
"h.	c #245063",
"i.	c #2B5E73",
"j.	c #60C3EC",
"k.	c #5FC0E9",
"l.	c #449FBF",
"m.	c #28586C",
"n.	c #23596C",
"o.	c #50A5C8",
"p.	c #3D7F9B",
"q.	c #2A677D",
"r.	c #27576B",
"s.	c #63C8F2",
"t.	c #4FA2C4",
"u.	c #29677C",
"v.	c #275669",
"w.	c #4998B8",
"x.	c #62C5EF",
"y.	c #4C9CBE",
"z.	c #387690",
"A.	c #30677E",
"B.	c #61C4EE",
"C.	c #3C7F9A",
"D.	c #4AAACD",
"E.	c #4793B3",
"F.	c #60C2EC",
"G.	c #4085A2",
"H.	c #081C25",
"I.	c #112D38",
"J.	c #63C7F1",
"K.	c #3E93B1",
"L.	c #55ADD2",
"M.	c #153542",
"N.	c #35728B",
"O.	c #5CBBE3",
"P.	c #1F5062",
"Q.	c #3E829F",
"R.	c #51BADF",
"S.	c #1A3D4C",
"T.	c #3884A0",
"U.	c #47A6C7",
"V.	c #56C5ED",
"W.	c #224D5E",
"X.	c #3E92B0",
"Y.	c #428AA8",
"Z.	c #0C232C",
"`.	c #4EA1C3",
" +	c #102B36",
".+	c #5EBEE6",
"++	c #4691B0",
"@+	c #62C7F0",
"#+	c #1B3F4E",
"$+	c #53BFE5",
"%+	c #295B6F",
"&+	c #4A99BA",
"*+	c #5CBCE4",
"=+	c #2B5F74",
"-+	c #071920",
";+	c #3988A3",
">+	c #347088",
",+	c #58C8F0",
"'+	c #05141B",
")+	c #58B2D8",
"!+	c #5BB9E1",
"~+	c #4C9DBE",
"{+	c #336D85",
"]+	c #20495A",
"^+	c #4DB1D5",
"/+	c #37758F",
"(+	c #4EA1C4",
"_+	c #4188A6",
":+	c #6BCBF0",
"<+	c #265568",
"[+	c #3E829E",
"}+	c #1F4858",
"|+	c #0D2B36",
"1+	c #50A4C7",
"2+	c #43849D",
"3+	c #245A6E",
"4+	c #5DBDE5",
"5+	c #295A6E",
"6+	c #62BCDE",
"7+	c #357089",
"8+	c #2D5C6E",
"9+	c #214B5D",
"0+	c #4A9ABB",
"a+	c #55AFD4",
"b+	c #193C4A",
"c+	c #458EAD",
"d+	c #61C4ED",
"e+	c #1D4353",
"f+	c #336D86",
"g+	c #386F84",
"h+	c #4C94B0",
"i+	c #4289A7",
"j+	c #5BAFCF",
"k+	c #36738D",
"l+	c #45869F",
"m+	c #529EBB",
"n+	c #63BDDF",
"o+	c #040F14",
"p+	c #08181F",
"q+	c #091C23",
"r+	c #3A7389",
"s+	c #3B7C97",
"t+	c #3F7B93",
"u+	c #326579",
"v+	c #65C0E4",
"w+	c #63BDE0",
"x+	c #397187",
"y+	c #122F3B",
"z+	c #55A4C2",
"A+	c #64CAF5",
"B+	c #59ABCB",
"C+	c #5EBFE7",
"D+	c #234A59",
"E+	c #61C5EF",
"F+	c #57B1D6",
"G+	c #245164",
"H+	c #183442",
"I+	c #6FC9F5",
"J+	c #5AACCC",
"K+	c #173540",
"L+	c #69BEE8",
"M+	c #4A90AB",
"N+	c #142F39",
"O+	c #6EC7F3",
"P+	c #62B3DA",
"Q+	c #57B1D7",
"R+	c #67C3E7",
"S+	c #519CB9",
"T+	c #2A5D72",
"U+	c #4F9AB6",
"V+	c #5DBDE6",
"W+	c #4587A1",
"X+	c #60B8D9",
"Y+	c #112A34",
"Z+	c #6AC9ED",
"`+	c #5AADCD",
" @	c #234F61",
".@	c #54A2C0",
"+@	c #4997B8",
"@@	c #74C9EF",
"#@	c #6AC1EB",
"$@	c #539FBD",
"%@	c #3C7E9A",
"&@	c #53A9CD",
"*@	c #6DC5F1",
"=@	c #69C8ED",
"-@	c #397893",
";@	c #2E5D70",
">@	c #2A4F5F",
",@	c #265060",
"'@	c #1E4555",
")@	c #4689A3",
"!@	c #5BB8DF",
"~@	c #162E39",
"{@	c #6AC9EE",
"]@	c #66B3D5",
"^@	c #326076",
"/@	c #54A1BF",
"(@	c #5EABD1",
"_@	c #316376",
":@	c #4A98B9",
"<@	c #59ABCA",
"[@	c #6BC3EE",
"}@	c #2A5C71",
"|@	c #6BC1EC",
"1@	c #407E96",
"2@	c #5DAAD0",
"3@	c #66C3E6",
"4@	c #417B97",
"5@	c #49829C",
"6@	c #294E5E",
"7@	c #5CA9CE",
"8@	c #599CBA",
"9@	c #5495B2",
"0@	c #458FAE",
"a@	c #69C8EC",
"b@	c #60B7D9",
"c@	c #549BBE",
"d@	c #6EBEE3",
"e@	c #3A6E87",
"f@	c #58A9C9",
"g@	c #427C98",
"h@	c #52A7CB",
"i@	c #418199",
"j@	c #4785A3",
"k@	c #4B91AC",
"l@	c #6CBBDF",
"m@	c #6FC1E6",
"n@	c #56AFD5",
"o@	c #163744",
"p@	c #3D6F85",
"q@	c #518EAA",
"r@	c #5EB4D6",
"s@	c #4F99B5",
"t@	c #4688A1",
"u@	c #5FB5D7",
"v@	c #5A9EBC",
"w@	c #6EC8F4",
"x@	c #285364",
"y@	c #2E647B",
"z@	c #5AB8DF",
"A@	c #4A91AC",
"B@	c #4E89A4",
"C@	c #6AC8ED",
"D@	c #3A7A95",
"E@	c #183642",
"F@	c #16333E",
"G@	c #64AFD0",
"H@	c #4887A5",
"I@	c #3A7B95",
"J@	c #4EA0C2",
"K@	c #509AB7",
"L@	c #5EB4D5",
"M@	c #3A697E",
"N@	c #4B8BAB",
"O@	c #67B3D5",
"P@	c #68C5E9",
"Q@	c #508EAA",
"R@	c #183A48",
"S@	c #366D82",
"T@	c #4D8EAF",
"U@	c #4996B6",
"V@	c #66B2D4",
"W@	c #3D7990",
"X@	c #5697B4",
"Y@	c #62ABCC",
"Z@	c #62C7F1",
"`@	c #72C5EA",
" #	c #417995",
".#	c #67BBE5",
"+#	c #5CB1D1",
"@#	c #60AFD6",
"##	c #040E14",
"$#	c #58A9C8",
"%#	c #6EC8F3",
"&#	c #366376",
"*#	c #4F93B4",
"=#	c #5CBBE2",
"-#	c #417A96",
";#	c #081820",
">#	c #67C4E8",
",#	c #56B0D5",
"'#	c #3B708A",
")#	c #152E3A",
"!#	c #57A8C7",
"~#	c #65B7DF",
"{#	c #4D9FC1",
"]#	c #65C0E3",
"^#	c #275161",
"/#	c #4E96B2",
"(#	c #5291AD",
"_#	c #65B8E0",
":#	c #396C85",
"<#	c #49829B",
"[#	c #4C8DAD",
"}#	c #1D3F4C",
"|#	c #62ACCC",
"1#	c #295165",
"2#	c #5195B7",
"3#	c #5697B5",
"4#	c #5297B9",
"5#	c #62BBDD",
"6#	c #457B93",
"7#	c #65C1E4",
"8#	c #2E5E71",
"9#	c #60A8C9",
"0#	c #4682A0",
"a#	c #64BEE0",
"b#	c #2E5567",
"c#	c #4B859F",
"d#	c #559CBF",
"e#	c #5195B6",
"f#	c #5A9DBC",
"g#	c #4F8CA8",
"h#	c #274D5F",
"i#	c #58A1C5",
"j#	c #224E60",
"k#	c #4683A1",
"l#	c #5DB1D2",
"m#	c #5EACD1",
"n#	c #51A6CA",
"o#	c #264857",
"p#	c #72C6EB",
"q#	c #6DBDE1",
"r#	c #41758C",
"s#	c #63ACCD",
"t#	c #71C5EA",
"u#	c #6CC4EF",
"v#	c #0B1F27",
"w#	c #66B9E2",
"x#	c #2C596B",
"y#	c #6BCAEF",
"z#	c #5596B3",
"A#	c #68BDE6",
"B#	c #2E596F",
"C#	c #5EA4C3",
"D#	c #64B6DE",
"E#	c #2F5668",
"F#	c #39677B",
"G#	c #4A839D",
"H#	c #498DA8",
"I#	c #366880",
"J#	c #5CBAE2",
"K#	c #2B5162",
"L#	c #3E7086",
"M#	c #5595B2",
"N#	c #67B3D6",
"O#	c #33667A",
"P#	c #599DBB",
"Q#	c #335D70",
"R#	c #6AB8DB",
"S#	c #2A5769",
"T#	c #6CBCE0",
"U#	c #16303D",
"V#	c #6BC2EC",
"W#	c #224857",
"X#	c #1E3E4E",
"Y#	c #529FBC",
"Z#	c #5DA3C2",
"`#	c #6DC5F0",
" $	c #71C4E9",
".$	c #63B4DC",
"+$	c #73C7ED",
"@$	c #4885A4",
"#$	c #4D8FAF",
"$$	c #59A3C7",
"%$	c #366275",
"&$	c #437890",
"*$	c #295465",
"=$	c #69B7D9",
"-$	c #62B3DB",
";$	c #122731",
">$	c #66B1D3",
",$	c #4F98B4",
"'$	c #0C1F28",
")$	c #58A2C6",
"!$	c #6FC0E4",
"~$	c #4C8CAC",
"{$	c #0D1F27",
"]$	c #6CBCDF",
"^$	c #56A6C4",
"/$	c #4C87A1",
"($	c #518FAB",
"_$	c #315F75",
":$	c #73C7EC",
"<$	c #2D6279",
"[$	c #61B1D9",
"}$	c #70C3E8",
"|$	c #284F62",
"1$	c #2B5367",
"2$	c #35657D",
"3$	c #45809E",
"4$	c #60A7C7",
"5$	c #73C8ED",
"6$	c #5CA8CD",
"7$	c #5290AC",
"8$	c #22414F",
"9$	c #2F5769",
"0$	c #67B4D7",
"a$	c #4987A6",
"b$	c #2B586A",
"c$	c #386A83",
"d$	c #5399BC",
"e$	c #2C5263",
"f$	c #2A5266",
"g$	c #31596C",
"h$	c #65B0D1",
"i$	c #6ACAEE",
"j$	c #52A9CD",
"k$	c #467D96",
"l$	c #356A7E",
"m$	c #61AACA",
"n$	c #5093B4",
"o$	c #255467",
"p$	c #4B8BAA",
"q$	c #6FC8F4",
"r$	c #5DA4C3",
"s$	c #2D5466",
"t$	c #3C718B",
"u$	c #5698B5",
"v$	c #437990",
"w$	c #284B5B",
"x$	c #69C7EB",
"y$	c #63AECF",
"z$	c #4E90B0",
"A$	c #5196B7",
"B$	c #57A7C6",
"C$	c #203E4B",
"D$	c #5799B6",
"E$	c #4B86A0",
"F$	c #397288",
"G$	c #254D5D",
"H$	c #5FB6D8",
"I$	c #5CA2C1",
"J$	c #8BA5B6",
"K$	c #8AA5B9",
"L$	c #6AB9DC",
"M$	c #57A0C3",
"N$	c #5094B6",
"O$	c #5A9FBD",
"P$	c #60B7D8",
"Q$	c #73C8EE",
"R$	c #5BA7CC",
"S$	c #3E6F86",
"T$	c #5494B1",
"U$	c #66BAE3",
"V$	c #5392AF",
"W$	c #335E71",
"X$	c #98867F",
"Y$	c #8AA4B8",
"Z$	c #939296",
"`$	c #8CA2B2",
" %	c #6AC0EA",
".%	c #457B94",
"+%	c #6EC7F2",
"@%	c #407289",
"#%	c #3F7187",
"$%	c #6FC1E5",
"%%	c #74C8EE",
"&%	c #81B7D3",
"*%	c #978A87",
"=%	c #57A0C4",
"-%	c #325B6E",
";%	c #549ABD",
">%	c #6AC0EB",
",%	c #76C9EF",
"'%	c #83CDED",
")%	c #998881",
"!%	c #FFF7D7",
"~%	c #DDD1BA",
"{%	c #9A8981",
"]%	c #1E3B48",
"^%	c #907E78",
"/%	c #4D433F",
"(%	c #77CBF5",
"_%	c #69CCF7",
":%	c #DACCCA",
"<%	c #78C9EF",
"[%	c #DDD7DA",
"}%	c #9BD2EB",
"|%	c #FEF6D6",
"1%	c #C7B9A7",
"2%	c #58A8C7",
"3%	c #5FA6C6",
"4%	c #887871",
"5%	c #DBCDB8",
"6%	c #EEDFC8",
"7%	c #71CDF0",
"8%	c #7DCBF3",
"9%	c #DED3BB",
"0%	c #998780",
"a%	c #3F7691",
"b%	c #75CBF5",
"c%	c #3B6B83",
"d%	c #918079",
"e%	c #796A64",
"f%	c #B1A694",
"g%	c #71C9F5",
"h%	c #7FCBED",
"i%	c #0F222B",
"j%	c #7ECBEF",
"k%	c #040303",
"l%	c #867670",
"m%	c #8E8577",
"n%	c #7B7366",
"o%	c #B3D9E7",
"p%	c #7ACBEF",
"q%	c #8FD0F1",
"r%	c #B6A799",
"s%	c #6BB7DA",
"t%	c #372F2D",
"u%	c #BAAE9C",
"v%	c #1A1714",
"w%	c #39342E",
"x%	c #EDDEC7",
"y%	c #8CCFED",
"z%	c #A7968B",
"A%	c #7CC6EE",
"B%	c #5B9FBE",
"C%	c #346073",
"D%	c #080605",
"E%	c #27241F",
"F%	c #E2D4BE",
"G%	c #E7DCC2",
"H%	c #A9988D",
"I%	c #5298BA",
"J%	c #DDCFB9",
"K%	c #BBC1CA",
"L%	c #A7D6E9",
"M%	c #EDE3C7",
"N%	c #6095AF",
"O%	c #DED0BA",
"P%	c #81C6E8",
"Q%	c #EEE3DF",
"R%	c #FFFFFF",
"S%	c #8ECFED",
"T%	c #BB948D",
"U%	c #99867F",
"V%	c #FBF2D3",
"W%	c #C0B2A1",
"X%	c #5EA5C5",
"Y%	c #0D0C09",
"Z%	c #FAF2D3",
"`%	c #CFC7C8",
" &	c #F4F2DA",
".&	c #B5918B",
"+&	c #A08982",
"@&	c #D69E98",
"#&	c #6BBADD",
"$&	c #757161",
"%&	c #8ACFF1",
"&&	c #C5B4A5",
"*&	c #CEC5C6",
"=&	c #A98C86",
"-&	c #325568",
";&	c #B9B39B",
">&	c #7CCBEF",
",&	c #B5A498",
"'&	c #C3B5A4",
")&	c #B3A496",
"!&	c #323028",
"~&	c #F2EBCC",
"{&	c #CBBBAB",
"]&	c #9C8B83",
"^&	c #7BC5ED",
"/&	c #3A687D",
"(&	c #BFB9A1",
"_&	c #76BDE3",
":&	c #2B4959",
"<&	c #999480",
"[&	c #8FCAE6",
"}&	c #C2B4A3",
"|&	c #AB9B8F",
"1&	c #988781",
"2&	c #6EBFE3",
"3&	c #395F74",
"4&	c #A6A08B",
"5&	c #FCF4D5",
"6&	c #7EC6EE",
"7&	c #B19089",
"8&	c #666355",
"9&	c #D5CEB3",
"0&	c #9CCFEA",
"a&	c #89CDED",
"b&	c #C1B3A2",
"c&	c #DCCDB9",
"d&	c #72C5EB",
"e&	c #65A2C3",
"f&	c #447991",
"g&	c #403834",
"h&	c #201B19",
"i&	c #36322C",
"j&	c #6B6459",
"k&	c #DAD3B7",
"l&	c #FDF5D5",
"m&	c #94CCEC",
"n&	c #9B8A83",
"o&	c #CABAA9",
"p&	c #81CBED",
"q&	c #83C6E8",
"r&	c #A4D1EA",
"s&	c #C0B2A2",
"t&	c #A5938A",
"u&	c #BBAB9F",
"v&	c #CDBDAC",
"w&	c #93CBE6",
"x&	c #B7A699",
"y&	c #E1D5C6",
"z&	c #90CCEC",
"A&	c #9F8F8A",
"B&	c #CEBDAD",
"C&	c #A49389",
"D&	c #9D8B83",
"E&	c #B7A89A",
"F&	c #929CA7",
"G&	c #C2B2A3",
"H&	c #AAA1A1",
"I&	c #BCAD9D",
"J&	c #B6A598",
"K&	c #B1A094",
"L&	c #A18F86",
"M&	c #919CA8",
"N&	c #C9B9A9",
"O&	c #AE9C91",
"P&	c #8F9DA9",
"Q&	c #CAB9A9",
"R&	c #CCBCAB",
"S&	c #A9988E",
"T&	c #C5B5A5",
"U&	c #EAE0C5",
"V&	c #7AC1E2",
"W&	c #C4B7A5",
"X&	c #EEE4C8",
"Y&	c #81BEE1",
"Z&	c #A8968C",
"`&	c #CEBEAD",
" *	c #9C8A84",
".*	c #9E8881",
"+*	c #86BCD9",
"@*	c #C8B7A7",
"#*	c #C4B6A5",
"$*	c #B2A4A1",
"%*	c #B08F89",
"&*	c #83BADB",
"**	c #9B8981",
"=*	c #ECE5D9",
"-*	c #C6B9A7",
";*	c #B1A194",
">*	c #A39288",
",*	c #82BCDE",
"'*	c #CBBAAA",
")*	c #B7A69A",
"!*	c #E9E3D9",
"~*	c #B7A899",
"{*	c #85BDDA",
"]*	c #88C4E8",
"^*	c #BEAEA0",
"/*	c #9C8A82",
"(*	c #CCBFB9",
"_*	c #E4DED9",
":*	c #D4C8B2",
"<*	c #A7968C",
"[*	c #85BEDC",
"}*	c #9F8D85",
"|*	c #AA9A8F",
"1*	c #B4A397",
"2*	c #D2C5C0",
"3*	c #DFD9DA",
"4*	c #D2C5B0",
"5*	c #A7978C",
"6*	c #C08E88",
"7*	c #A08F86",
"8*	c #B3A396",
"9*	c #BEB09F",
"0*	c #CABDAA",
"a*	c #ECE2C7",
"b*	c #BDAC9E",
"c*	c #E7DBD7",
"d*	c #D9CDB6",
"e*	c #CEC1AD",
"f*	c #9F8E85",
"g*	c #82BCDF",
"h*	c #BBAC9D",
"i*	c #D6CAB4",
"j*	c #A29188",
"k*	c #86BBD8",
"l*	c #AC9C90",
"m*	c #B5A698",
"n*	c #D7CCB5",
"o*	c #86BBD7",
"p*	c #B19F94",
"q*	c #F2EBD8",
"r*	c #D7CBB4",
"s*	c #8CB9D7",
"t*	c #BBAB9D",
"u*	c #EBE5D9",
"v*	c #C9BCA9",
"w*	c #C2B1A2",
"x*	c #FAF2D7",
"y*	c #E3DDD9",
"z*	c #D5C9B3",
"A*	c #D1C4B0",
"B*	c #A5958A",
"C*	c #B78782",
"D*	c #C6B5A6",
"E*	c #F9F2D8",
"F*	c #F9F2D7",
"G*	c #DED8DA",
"H*	c #D7C9C7",
"I*	c #AA998E",
"J*	c #F7EED0",
"K*	c #9A8982",
"L*	c #E9DAC4",
"M*	c #A47974",
"N*	c #93C8E6",
"O*	c #BAA99C",
"P*	c #DBCDCB",
"Q*	c #E0DADA",
"R*	c #9D8C85",
"S*	c #C6B7B4",
"T*	c #8AC4E8",
"U*	c #8EC6E8",
"V*	c #A5948A",
"W*	c #AEA09C",
"X*	c #A2918A",
"Y*	c #E9E2D9",
"Z*	c #FCF4D7",
"`*	c #FEF6D7",
" =	c #F4ECD8",
".=	c #B1A09B",
"+=	c #F0E9D8",
"@=	c #B4A6A3",
"#=	c #D9CBC9",
"$=	c #E6DFD9",
"%=	c #F5EDD8",
"&=	c #E8E1D9",
"*=	c #B6A6A1",
"==	c #DBCECA",
"-=	c #DDCFCD",
";=	c #B6AAA7",
">=	c #CBBCB9",
",=	c #E4DDD9",
"'=	c #F5EED8",
")=	c #FDF5D7",
"!=	c #A5D1E4",
"~=	c #95C8E6",
"{=	c #D0C0AE",
"]=	c #B4A49F",
"^=	c #E7D8C8",
"/=	c #F2EFF0",
"(=	c #F3ECD8",
"_=	c #E2DBDA",
":=	c #B3A6A3",
"<=	c #A4938D",
"[=	c #F6EFD8",
"}=	c #F7F0D8",
"|=	c #A3CDE6",
"1=	c #99CAE6",
"2=	c #B3A39E",
"3=	c #F4F2F3",
"4=	c #EEECED",
"5=	c #FBF3D7",
"6=	c #A08E86",
"7=	c #89C8E8",
"8=	c #9ECCE6",
"9=	c #D6C7B4",
"0=	c #AB9B95",
"a=	c #FCFCFC",
"b=	c #EDE2DE",
"c=	c #EEEBEC",
"d=	c #EBE1C6",
"e=	c #E9DFC4",
"f=	c #A8988D",
"g=	c #A8978C",
"h=	c #BCADA8",
"i=	c #F1EAD8",
"j=	c #92A2B1",
"k=	c #92A1B0",
"l=	c #949AA3",
"m=	c #978B88",
"n=	c #92CAE6",
"o=	c #93C1E1",
"p=	c #E4D8D3",
"q=	c #EDE6D9",
"r=	c #A1908A",
"s=	c #EDE3DF",
"t=	c #F8EFD1",
"u=	c #AE9E92",
"v=	c #9B8983",
"w=	c #8DB5D1",
"x=	c #8CBAD8",
"y=	c #88C2E6",
"z=	c #8AC0E1",
"A=	c #8CBAD9",
"B=	c #89B5CE",
"C=	c #92A3B5",
"D=	c #988882",
"E=	c #96C8E6",
"F=	c #E8D9C8",
"G=	c #F1E8CB",
"H=	c #A9998D",
"I=	c #A19087",
"J=	c #B8A7A3",
"K=	c #EFE8D8",
"L=	c #F9F1D8",
"M=	c #8FC1E7",
"N=	c #AC9D98",
"O=	c #CFC0BD",
"P=	c #DBD0B9",
"Q=	c #C0B1A1",
"R=	c #FDF4D5",
"S=	c #DFD3CF",
"T=	c #D8D1D4",
"U=	c #8CC6E8",
"V=	c #DED8D6",
"W=	c #D3C4C2",
"X=	c #EBDCC8",
"Y=	c #FDF5D6",
"Z=	c #AF9D92",
"`=	c #D1C2BF",
" -	c #FDFCFC",
".-	c #DACBB7",
"+-	c #BBAD9D",
"@-	c #9A8880",
"#-	c #B3A39D",
"$-	c #D0C1BE",
"%-	c #FFFFFE",
"&-	c #CFBFAD",
"*-	c #C4B3A4",
"=-	c #EADBC8",
"--	c #A5948E",
";-	c #D3C5C2",
">-	c #AD9D91",
",-	c #C1B0A2",
"'-	c #C3B2A3",
")-	c #EDDEC8",
"!-	c #E1D4C9",
"~-	c #B8A8A4",
"{-	c #A2918C",
"]-	c #998781",
"^-	c #F6F4F3",
"/-	c #E0DBDE",
"(-	c #B2A195",
"_-	c #A59690",
":-	c #DCD1B9",
"<-	c #AA9B96",
"[-	c #9A8881",
"}-	c #F1E9D8",
"|-	c #A5948D",
"1-	c #A08F88",
"2-	c #D5C5B3",
"3-	c #E7D9C8",
"4-	c #AD9C97",
"5-	c #E2D7BE",
"6-	c #CBBEAA",
"7-	c #A3938D",
"8-	c #CFC6C7",
"9-	c #D7D0D2",
"0-	c #C6BCBB",
"a-	c #CBC1C2",
"b-	c #A2908A",
"c-	c #E7E0D9",
"d-	c #C7B7A7",
"e-	c #C3B3A4",
"f-	c #9A8882",
"g-	c #9F8F89",
"h-	c #F5ECCF",
"i-	c #C0B5B4",
"j-	c #D8D2D4",
"k-	c #D5CDCF",
"l-	c #D2CACB",
"m-	c #D7D0D3",
"n-	c #DAD4D6",
"o-	c #DCD6D9",
"p-	c #C0B1AC",
"q-	c #9B8881",
"r-	c #E2DCDA",
"s-	c #B7ABA8",
"t-	c #DCD5D8",
"u-	c #AB9D99",
"v-	c #9D8C8A",
"w-	c #9A8984",
"x-	c #9E8D8D",
"y-	c #CFC2AE",
"z-	c #BBAFAD",
"A-	c #BAAB9C",
"B-	c #C2B3AF",
"C-	c #F8F0D8",
"D-	c #C7B6A7",
"E-	c #A3918A",
"F-	c #B7A7A1",
"G-	c #FBFAFB",
"H-	c #E1DCDE",
"I-	c #C9C0C0",
"J-	c #D9D2D5",
"K-	c #D4CDCF",
"L-	c #CCC3C4",
"M-	c #C0B0AC",
"N-	c #C2B5A3",
"O-	c #9E8D87",
"P-	c #F8F1D8",
"Q-	c #C2B1A3",
"R-	c #A29087",
"S-	c #988680",
"T-	c #EBDFDB",
"U-	c #FEFEFE",
"V-	c #9B8A82",
"W-	c #BFB1A1",
"X-	c #8C2047",
"Y-	c #8B1C41",
"Z-	c #A0254A",
"`-	c #9B636C",
" ;	c #99837D",
".;	c #AB9C98",
"+;	c #D0C8C9",
"@;	c #A0908A",
"#;	c #C9BAB7",
"$;	c #F3EACD",
"%;	c #F7EFD8",
"&;	c #C4B4A5",
"*;	c #B8A99B",
"=;	c #F0E7CB",
"-;	c #CCBFAB",
";;	c #D4D1F7",
">;	c #911C44",
",;	c #991741",
"';	c #AF1A43",
");	c #A08F89",
"!;	c #C1B6B5",
"~;	c #B2A395",
"{;	c #FDFDFD",
"];	c #F6EED8",
"^;	c #A29187",
"/;	c #C8B8A8",
"(;	c #AD9C91",
"_;	c #FBF3D4",
":;	c #9C143F",
"<;	c #9F123D",
"[;	c #B7143F",
"};	c #DAD3D6",
"|;	c #E8E3E2",
"1;	c #A3928D",
"2;	c #C1B2AE",
"3;	c #CAC1BD",
"4;	c #F4EDD8",
"5;	c #FCF5D7",
"6;	c #E5DBC1",
"7;	c #C1B1A2",
"8;	c #DDCEBA",
"9;	c #E5E1E3",
"0;	c #C7BAA7",
"a;	c #E6DCC2",
"b;	c #A62147",
"c;	c #951A42",
"d;	c #A2103C",
"e;	c #BD103D",
"f;	c #BA123E",
"g;	c #B31741",
"h;	c #9B8A84",
"i;	c #EEECEA",
"j;	c #D4CDCE",
"k;	c #BEB0A0",
"l;	c #A7958C",
"m;	c #DBCBB8",
"n;	c #F4EBCE",
"o;	c #9E8D89",
"p;	c #AB1E45",
"q;	c #BF0F3C",
"r;	c #B4A7A4",
"s;	c #9E8C84",
"t;	c #FCFBFB",
"u;	c #D3CBCD",
"v;	c #E1BFC8",
"w;	c #FCF3D4",
"x;	c #C10D3B",
"y;	c #A6666C",
"z;	c #9B8982",
"A;	c #F9F0D1",
"B;	c #CDBCAC",
"C;	c #F9F0D2",
"D;	c #A60D3A",
"E;	c #A90B39",
"F;	c #D7CBB5",
"G;	c #BEB3B1",
"H;	c #DBD4D7",
"I;	c #A2918B",
"J;	c #B0A093",
"K;	c #A4264A",
"L;	c #B12347",
"M;	c #B32348",
"N;	c #B92046",
"O;	c #C00F3C",
"P;	c #E9103D",
"Q;	c #A02144",
"R;	c #9D8C86",
"S;	c #AFA19D",
"T;	c #E8D9C3",
"U;	c #D8D5F8",
"V;	c #ECEBFB",
"W;	c #F0EFFC",
"X;	c #EFEEFC",
"Y;	c #B32A4B",
"Z;	c #BC2146",
"`;	c #C3163F",
" >	c #B7153F",
".>	c #A9274A",
"+>	c #B72B4B",
"@>	c #BD2C4C",
"#>	c #C52749",
"$>	c #C72849",
"%>	c #E3143F",
"&>	c #E6123E",
"*>	c #E01640",
"=>	c #CE2447",
"->	c #F4EBCD",
";>	c #EADBC5",
">>	c #DCD9F8",
",>	c #FDFDFF",
"'>	c #C12D4C",
")>	c #DC1941",
"!>	c #D61841",
"~>	c #DAD8F8",
"{>	c #E8E7FB",
"]>	c #F4F4FD",
"^>	c #F7F7FE",
"/>	c #BE2C4C",
"(>	c #C82849",
"_>	c #D81C43",
":>	c #C02846",
"<>	c #AFA2AC",
"[>	c #AFA093",
"}>	c #C6133E",
"|>	c #C3A7CF",
"1>	c #D7D5F8",
"2>	c #EAE9FB",
"3>	c #F1F1FC",
"4>	c #F5F4FD",
"5>	c #FCFCFF",
"6>	c #FEFEFF",
"7>	c #D32045",
"8>	c #FBFAF9",
"9>	c #9F8F88",
"0>	c #9ABFE1",
"a>	c #DDDBF9",
"b>	c #F6F6FD",
"c>	c #F9F9FE",
"d>	c #AD9E99",
"e>	c #E7E1D9",
"f>	c #AF9F92",
"g>	c #EEE7D9",
"h>	c #E3E1FA",
"i>	c #F9F8FE",
"j>	c #C4B9B9",
"k>	c #BAAC9C",
"l>	c #9E8D85",
"m>	c #AE9E98",
"n>	c #E4D9C0",
"o>	c #B8ABA9",
"p>	c #A39189",
"q>	c #A4C7E0",
"r>	c #FAF1D3",
"s>	c #B1A4A1",
"t>	c #EEE5C9",
"u>	c #A79792",
"v>	c #ADC8DF",
"w>	c #D3C7B1",
"x>	c #AD9E9A",
"y>	c #9EC1E1",
"z>	c #B0A09B",
"A>	c #E8DEC3",
"B>	c #BB0214",
"C>	c #9D8C84",
"D>	c #95C1E1",
"E>	c #E4D8D4",
"F>	c #9F8E87",
"G>	c #FFFFFD",
"H>	c #B6A9A6",
"I>	c #AB9B90",
"J>	c #D9D3D5",
"K>	c #95C2E1",
"L>	c #AB9D98",
"M>	c #998880",
"N>	c #C6B6B3",
"O>	c #9F8E86",
"P>	c #A3BEDB",
"Q>	c #BCACA8",
"R>	c #D0C3AF",
"S>	c #C3B4B0",
"T>	c #C5B5B2",
"U>	c #FFFEF9",
"V>	c #FFF7D8",
"W>	c #9C8B84",
"X>	c #9C8B85",
"Y>	c #9F8E88",
"Z>	c #BAAAA6",
"`>	c #DCD0B9",
" ,	c #AC9B90",
".,	c #C3BDC4",
"+,	c #A18F87",
"@,	c #FFFBEC",
"#,	c #FFFCF0",
"$,	c #FFFDF3",
"%,	c #FFFEF8",
"&,	c #FFFDF4",
"*,	c #FFF8DC",
"=,	c #FFF9E0",
"-,	c #D7CFD1",
";,	c #CBC2C3",
">,	c #AF9E99",
",,	c #EDE4C8",
"',	c #EADAC4",
"),	c #DDCDB9",
"!,	c #D1C9CB",
"~,	c #D8D1D3",
"{,	c #C1BEC4",
"],	c #C9C9C9",
"^,	c #CFBFAE",
"/,	c #B9ADAB",
"(,	c #DBD5D8",
"_,	c #D6C8C6",
":,	c #B9ACAA",
"<,	c #C5B8A6",
"[,	c #DCCCB9",
"},	c #C6BDC1",
"|,	c #D6CFD1",
"1,	c #ECDDC6",
"2,	c #A4958F",
"3,	c #D9D2D4",
"4,	c #EFE5C9",
"5,	c #EEE7D8",
"6,	c #EAE3D9",
"7,	c #ECDDC7",
"8,	c #A2928C",
"9,	c #D4C4B2",
"0,	c #C2B7B6",
"a,	c #E3D8BF",
"b,	c #9D8C83",
"c,	c #ECE2C6",
"d,	c #E8E2D9",
"e,	c #A5958C",
"f,	c #AA9B97",
"g,	c #BCAB9D",
"h,	c #D5CED0",
"i,	c #A39289",
"j,	c #A0BDE0",
"k,	c #AF9E92",
"l,	c #DDCFC9",
"m,	c #C7BBAE",
"n,	c #B09F9A",
"o,	c #E5DED9",
"p,	c #A08E88",
"q,	c #EBDCC5",
"r,	c #BBABA7",
"s,	c #E9D9C3",
"t,	c #B2A295",
"u,	c #DACAB7",
"v,	c #A2928D",
"w,	c #BEAD9F",
"x,	c #D5C7C4",
"y,	c #D8CAC8",
"z,	c #C6B8A6",
"A,	c #E1D2BD",
"B,	c #BAAA9C",
"C,	c #9D8B84",
"D,	c #E1D1BD",
"E,	c #C9BFBF",
"F,	c #D1C9CA",
"G,	c #9E8C85",
"H,	c #D8C9B6",
"I,	c #A59692",
"J,	c #CBBBAA",
"K,	c #A4938A",
"L,	c #E8DDC3",
"M,	c #AEA1A1",
"N,	c #DBCFB8",
"O,	c #B5A598",
"P,	c #A1908B",
"Q,	c #AB9A8F",
"R,	c #C0B4B3",
"S,	c #C8BFBF",
"T,	c #CDC4C5",
"U,	c #BFB1A0",
"V,	c #9A8780",
"W,	c #F4E7CD",
"X,	c #BFAFA0",
"Y,	c #D2C2B0",
"Z,	c #F9EED1",
"`,	c #F7EBD0",
" '	c #F1E4CB",
".'	c #B8A99A",
"+'	c #F8EDD1",
"@'	c #F7ECD0",
"#'	c #E4DAC0",
"$'	c #A6968B",
"%'	c #B09F93",
"&'	c #A5C0DB",
"*'	c #F8EED1",
"='	c #F3E6CD",
"-'	c #E3DCDA",
";'	c #EEE4C9",
">'	c #F6EBCF",
",'	c #F2E5CC",
"''	c #B9AA9B",
")'	c #A9998E",
"!'	c #F3E6CC",
"~'	c #9E8D84",
"{'	c #F0E2CA",
"]'	c #C1B4AB",
"^'	c #FBF4D7",
"/'	c #AABBDB",
"('	c #ADBCD5",
"_'	c #F6EACF",
":'	c #EFE1C9",
"<'	c #BAAEAC",
"['	c #EEE0C8",
"}'	c #DFD1C9",
"|'	c #A69792",
"1'	c #B1BFDB",
"2'	c #A9C2DB",
"3'	c #B2C0DB",
"4'	c #B4C1DB",
"5'	c #B4A597",
"6'	c #ACBDDB",
"7'	c #A7C0DB",
"8'	c #C4D0DA",
"9'	c #C2B8B7",
"0'	c #AEBDDB",
"a'	c #E6E0D9",
"b'	c #D4CCCE",
"c'	c #D3CBCC",
"d'	c #BDC8DB",
"e'	c #AFBED5",
"f'	c #C3B8B7",
"g'	c #B1BED5",
"h'	c #CBC2C2",
"i'	c #B5C2DB",
"j'	c #395E35",
"k'	c #426C3D",
"l'	c #ABC2DB",
"m'	c #CDC5C5",
"n'	c #A9BBD1",
"o'	c #A6BBD7",
"p'	c #509855",
"q'	c #CFD2B0",
"r'	c #EBE4D9",
"s'	c #ADBCD3",
"t'	c #4A6B43",
"u'	c #B6BF9B",
"v'	c #653C21",
"w'	c #E6D8C8",
"x'	c #ABBCD1",
"y'	c #51A85E",
"z'	c #3B5832",
"A'	c #4D2A1B",
"B'	c #5C3423",
"C'	c #F3EBD8",
"D'	c #B2B9D5",
"E'	c #93715D",
"F'	c #5D3624",
"G'	c #543222",
"H'	c #496A42",
"I'	c #407441",
"J'	c #458249",
"K'	c #3B6338",
"L'	c #633C2B",
"M'	c #5E3625",
"N'	c #663F2E",
"O'	c #3D6C3D",
"P'	c #3B6539",
"Q'	c #407341",
"R'	c #498F50",
"S'	c #4B9554",
"T'	c #4FA15A",
"U'	c #4FA25A",
"V'	c #4C9956",
"W'	c #488D4F",
"X'	c #4FA25B",
"Y'	c #4FA35B",
"Z'	c #51A75E",
"`'	c #3C673A",
" )	c #49854B",
".)	c #4F9654",
"+)	c #3A6137",
"@)	c #9AB7C6",
"#)	c #438C5F",
"$)	c #437D4F",
"%)	c #B0B9D3",
"&)	c #3A6C44",
"*)	c #CABBBF",
"=)	c #B0B9D1",
"-)	c #3C946F",
";)	c #438A5C",
">)	c #437D50",
",)	c #B8B8D5",
"')	c #ACB7CF",
"))	c #427041",
"!)	c #BBB8D0",
"~)	c #3F633F",
"{)	c #E5DFD9",
"])	c #80939A",
"^)	c #8A97A3",
"/)	c #426D3F",
"()	c #8AAFA1",
"_)	c #509755",
":)	c #EFE6CA",
"<)	c #ECDDC8",
"[)	c #E1DBDA",
"})	c #B4B9D5",
"|)	c #E1D3C9",
"1)	c #E1DADA",
"2)	c #E0D1C9",
"3)	c #E2D4C9",
"4)	c #E4D6C8",
"5)	c #E5D7C8",
"6)	c #9B8984",
"7)	c #A49FAB",
"8)	c #B2ABBD",
"9)	c #B3ADBF",
"0)	c #998883",
"a)	c #9C8D8D",
"b)	c #ABA4B6",
"c)	c #ABACC0",
"d)	c #ABADC2",
"e)	c #FAF3D7",
"f)	c #EAE4D9",
"g)	c #BDADA9",
"h)	c #E0D9DA",
"i)	c #C8B9B6",
"j)	c #63B06A",
"k)	c #395F36",
"l)	c #C1B6D0",
"m)	c #3A7149",
"n)	c #50A65D",
"o)	c #3B7A53",
"p)	c #F0E8D8",
"q)	c #4E9165",
"r)	c #56A660",
"s)	c #53A75F",
"t)	c #5AA462",
"u)	c #438659",
"v)	c #A4948F",
"w)	c #798568",
"x)	c #448C5F",
"y)	c #3E9570",
"z)	c #3F9671",
"A)	c #459974",
"B)	c #55AA61",
"C)	c #438B5E",
"D)	c #7BA48B",
"E)	c #539468",
"F)	c #3D946F",
"G)	c #63B06B",
"H)	c #C5BBD0",
"I)	c #52A95F",
"J)	c #419370",
"K)	c #599E7C",
"L)	c #486441",
"M)	c #58AB63",
"N)	c #438658",
"O)	c #449873",
"P)	c #70A377",
"Q)	c #77B978",
"R)	c #C9B4CA",
"S)	c #CFBABD",
"T)	c #AEBEA6",
"U)	c #DDCECA",
"V)	c #FCF5D5",
"W)	c #F2F1CE",
"X)	c #FEF7D7",
"Y)	c #639D70",
"Z)	c #C6B4D0",
"`)	c #D9CEC4",
" !	c #5BAD65",
".!	c #56AA62",
"+!	c #57AB62",
"@!	c #5AAC64",
"#!	c #9D9385",
"$!	c #53A95F",
"%!	c #438052",
"&!	c #C9B6CA",
"*!	c #426E3F",
"=!	c #D2BABB",
"-!	c #3C926D",
";!	c #42794B",
">!	c #BDBAD0",
",!	c #C3BAD0",
"'!	c #CBB6CA",
")!	c #449664",
"!!	c #55A961",
"~!	c #469765",
"{!	c #489767",
"]!	c #CCCEB1",
"^!	c #CBC1D1",
"/!	c #58AA64",
"(!	c #459665",
"_!	c #459664",
":!	c #A2B49E",
"<!	c #478E61",
"[!	c #689F73",
"}!	c #426D3E",
"|!	c #E6E2C9",
"1!	c #F6F0CF",
"2!	c #CDB8CA",
"3!	c #D7C8C6",
"4!	c #416C3D",
"5!	c #F5EFCF",
"6!	c #E2DAD0",
"7!	c #539C6E",
"8!	c #F4EBD0",
"9!	c #59AB63",
"0!	c #5BAC65",
"a!	c #499767",
"b!	c #CBB8CA",
"c!	c #469665",
"d!	c #4C9063",
"e!	c #549C6F",
"f!	c #3D6138",
"g!	c #9FAD89",
"h!	c #CAB9D0",
"i!	c #E4DAD3",
"j!	c #EBE7C6",
"k!	c #CEB3CB",
"l!	c #CFBCCC",
"m!	c #A3BDA3",
"n!	c #D1B3C5",
"o!	c #E3D4C9",
"p!	c #EBDFC6",
"q!	c #E4D5C8",
"r!	c #56A17D",
"s!	c #D6B1C6",
"t!	c #E5DBD3",
"u!	c #A39188",
"v!	c #427642",
"w!	c #E9DDC4",
"x!	c #51A15A",
"y!	c #DBAFC6",
"z!	c #DEB0C0",
"A!	c #479765",
"B!	c #4D6445",
"C!	c #566950",
"D!	c #533021",
"E!	c #CBA4B0",
"F!	c #3F703F",
"G!	c #4E2C1C",
"H!	c #3F7240",
"I!	c #4E2B1C",
"J!	c #502D1E",
"K!	c #457E47",
"L!	c #94A08A",
"M!	c #4B301E",
"N!	c #96A187",
"O!	c #559E6D",
"P!	c #69A169",
"Q!	c #4D9A69",
"R!	c #E3AEC1",
"S!	c #E6D6C1",
"T!	c #E0B2C0",
"U!	c #E4D5BF",
"V!	c #3F713F",
"W!	c #CABAAA",
"X!	c #DBB1C6",
"Y!	c #DDB4C6",
"Z!	c #99AA91",
"`!	c #E5D5C0",
" ~	c #E3B0C1",
".~	c #EAACBC",
"+~	c #5EA372",
"@~	c #DEB2C0",
"#~	c #AC9C96",
"$~	c #479766",
"%~	c #44915F",
"&~	c #9E8C86",
"*~	c #DDB8C8",
"=~	c #E5B3C3",
"-~	c #437643",
";~	c #E4C7CD",
">~	c #EAB0BE",
",~	c #E3BECA",
"'~	c #E5B6C3",
")~	c #E8ACC1",
"!~	c #427643",
"~~	c #E5B4C3",
"{~	c #419772",
"]~	c #409671",
"^~	c #E5BBC6",
"/~	c #E5B5C3",
"(~	c #E7B8C3",
"_~	c #EAAEBC",
":~	c #E8AEC1",
"<~	c #EAAFBE",
"[~	c #E3B0C3",
"}~	c #E6D7C8",
"|~	c #E3C6CE",
"1~	c #EAAEBE",
"2~	c #E0D2C9",
"3~	c #E1C2CD",
"4~	c #E8B2C0",
"5~	c #E8B0BF",
"6~	c #E8B5C2",
"7~	c #EAB1BE",
"8~	c #EAB8C5",
"9~	c #E3C4CD",
"0~	c #4A9967",
"a~	c #E8B6C3",
"b~	c #F0AABD",
"c~	c #ECB2BE",
"d~	c #E8B4C2",
"e~	c #EAAFBC",
"f~	c #ECB8C0",
"g~	c #F2B3BF",
"h~	c #F2ABB7",
"i~	c #EEBAC0",
"j~	c #DFB8B6",
"k~	c #F2ADB7",
"l~	c #DBCDC9",
"m~	c #E0B7B4",
"n~	c #ECB4BE",
"o~	c #F0ACBD",
"p~	c #F0B0BF",
"q~	c #F2B1BF",
"r~	c #ECC0C5",
"s~	c #F2AFB9",
"t~	c #F7A9B8",
"u~	c #F8D1C6",
"v~	c #F0AEBF",
"w~	c #F4BEBE",
"x~	c #F5C6C6",
"y~	c #F2AEB9",
"z~	c #F7ADBA",
"A~	c #F0AEBD",
"B~	c #F7ABB8",
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
"+ . . . . . . + . + . . . + . . . . . . . . . . . + . . . . . . + + + . + + + + . . . . . . . + . + . . . + + . + + + + . + . . + . . . + . + + . . . . . + . . + . . . . + . + . . . + . . + . . . . + + + . + . . . . . + + + + + . . . . . . . + . + . . . . . . . + + . + . + . . . + . + . + + + . . . + . . + + . . + . . + . . . . . . . . + . + . . + . . + . . . + . . . . . . . + + . + . . . + . . + + . . . . . + . + . + . . . . . + + + + . . + . . + . . . + . . . + . . . . + . ",
"+ + + + + + . + . + + + . + . + + + + + . + + + . + + + + + + . . . + . . . . + + + + + + + . + . + + . . . + . . . . + . + + . + + + . + . . + + + + + . + + . + + + + . + . + + + . + + . + + + + . . . + . + + + + + . . . . . + + + + + . + . + . + + + + + + + . . + . + . + + + . + . + . . . + + + . + . . . + + . + + . + + + + + + + + . + . + + . + + . + + + . + + + + + + + . . + . + + + . + + . . + + + + + . + . + . + + + + + . . . . + + . + + . + + + . + + + . + + + + . + . ",
". . . . . . . . + . . . + . + . . . . . + . . . + . . . . . . + + + . + . . . . . . . . . . + . . . . + . . . + . + + . . . . . . . . . . + . . . . . . + . . + . . . . . . . . . . . . . + . . . . . . . . + . . . . . + + + + . . . . . . + . . . . . . . . . . . . + . + . . . . . . . + . . . . . . . + . + . + . . . . . . . . . . . . . . + . . . . . . . . . . . + . . . . . . . . . . . . . . + . . . . . . . . . + . + . . . . . . . . . . . . . . . . + . . . . . . . + . . . . + . + ",
"+ + . + + + . . + + . . + . . + + + + . + + . . . . . . + + . . . + . + + + + . . . + + + . + . + . . + + + . + . . . + . . . + + . + . . + + . . + + . . + . . . + . + @ # $ % & + + + . + + . . + . + + . + + + . . . . . . + + + . + + . + + + + + + . . . + . + . . . + + . + + + + . . + + + + + + . + . + . . + + + + + . . . . + + + + . . + . . + + + + . . . . + . . + + + + + + . + . + . . . . + + + . + + + . + . + + + . + + + + + + + + + + + + . . + + + + + + . . + + . . + . . ",
". . + . . . + . . . + . . . + . . . . . . . . + + + + + . . . . . . . . . . . + + + . . . . . + . + . . . . + . . . + . + + + . . + . + . . . + + . . . + . + + . . + * = - - - ; > . . . . . + + . + . . + . . . + . . + + . . . . . . . . . . . . . . . + + . + . + + + . . + . . . . . + . . . . . . + . + . . + . . . . . + + + + . . . . . . . + + . . . . + + . . . + + . . . . . . . . + . + . + + . . . + . . . . . . . . . + . . . . . . . . . . . . . + . . . . . . + + . . + + . + . ",
". . + + + . + + . . , ' ' ) ' ) ) ' ' ) ) ' ) ) ) ! . . + + + + + + + + + + . . . + + . + + . + . + . + + . + + . . + . . . + + . + . + + . . . + + + . + . . + . + ~ { - - - - - ] ^ + + . . . + . + . . . + . . + + . . + + + . + . + + + + + + + . + . . . . + . . . . + . + + + . + . + . . / ' ) ) ) ) ! + . + + + + . . . . . + + + + + + + . . . + + + . . + + . . . + . . . + + + . . . . + . . . + + . + . . + + + + + + . + . . + . + + . . + . . + . + . . . + + . . + + . . + . + . ",
"+ + . . . + . ( _ : < < < < < < < < < < < < < < < [ . + . . . . . . . . + . + + + . . + . . . . + . + . . + . . + . . + + + + . . . + . . + + + . . . + . + + . + . } - - - - - - - | . . + + + . + . + + + . + + . . + . . . . + . + . . . . . . . + . . + + + . + + + + . . . . . + . . . + + 1 < < < < < _ . . . . . . + + . + + . . . . . . . . + 2 3 . . + + 4 < 5 + . . + + + . + . + + + + . + + + . . + . + + . . . 6 7 8 + . + + 9 0 a a b b a b b a b a b b b a a b b a a b c . + . + ",
". + + + . + d e < < < < < < < < < < < < < < < < < [ + + + + + + + + + . + . + . + + + + + + + . + . + + . + + + + + . . . . + + + . . + . . . + + + . + . . + . + . f - - - - - - - g + . . . + . + . . . + + . + + . + + + + . + . + + + + + + + . + + . . . + . . . . + + + + + + + + + . . + h < < < < < _ + + + + + + + + . . + + + + + + + + + . 2 i + . + + j k l m + . . . + . + + . . . + . + . + + . + + . + + + + n o 8 + . . + 9 p + . . + . . + + + . . . + + . . + + . . + . + . + ",
"+ . . + + q < < < < < < < < < < < < < < < < < < < r . . . . + + + + . + + + . + . . . . . + . + + + . . + . . . . . + + + + . + + + + . + + . . . + + . + + . + . + s t - - - - - - u . + + + . + + + + + . . + + + + . . . . + . + + . . . . . . + . + + + + . + + + + . + . . . . + + . + + + 1 < < < < < _ + + . . . + . + + + . . . . + . + . . + v i . + . . 4 w x y . + + + . + + . + + + . + . + . . + . . + + . + ) z A B . + + . C D + + + . + + . . . + + + . . + + . . + + . + . + . ",
"+ + . + E F < < < < < < < < < < < < < < < < < < < [ + + + . . . . + . . + + . + + + + + . + . . . + + . + + + + + . . + + + . . + + + + . + + + . + + . + + + + . + + G - - - - - H I + + . + + . + . + + + . . + . + + + + + + . . + + + + + + + + . + . . + . + . + + . + + + + . . + . + . + h < < < < < J . + + + . + . . . + + + + . + . + + . + v i . + + + j K L M + + . + . . + . . . + + + + + + . + + . . + . + N O P B . . + + C D + + + . . + + + . . . + + . + + + . + + . + . + . ",
". + + . L < < < < < < < < < < < < < < < < < < < < [ . + + + + + + + + + . + + E Q + + + + + + + + + . + . + + + + + + + + + + + . + + . + + . + + + + + . + . + + . + R S - - - T U . . . + + . + + + . + . + + . + + . . . . + + + + . + + + . . + + . + + + + . + . . + . + . . + + + + + + . 1 < < < < < _ + + + + + + + + + + . . + + + + + + + + 2 i + . + + 4 w + V W . + + + + + + + + . + + . . . + + + + + + + m X Y Z B + + . . 9 p . . . + + . + . + + + + . + . + + + . + + + + . + ",
". + + + ` < < < < < < < < < < < < < < < < < < < < [ . + . + + + + + + + . + .  .... . +.@.+ + + . + + + + . . . + + . . . + + + . . + + . + . + . . + + . + + + + . . + . #.$.U + + + + + + + + . + + . + + + + + . + + + + + + + . + . + + + + + + + + + . + + + + + + + . + + + + . + . + + + h < < < < < _ . . + + . + + + . + + + + + + . + + + + v 3 + + . + j w + %.&.+ . + + . + + + + . + + + + + . . + + + + . *.=.+ P 8 + + + + C p + + + + + . + . + + + + + + + . . + . + + + + + + ",
"+ . + . -.< < < < < < < < < < < < < < < < < < < < r + . + . . . . . + . + + + i 7 ;.>.,.< '.B ).+ + m + . + + + . . + + + . . + + + + . + . + . + + . + + + . + + + + . + + + + + + + + . . + . + + + + + . . + + + . + + + . . + + + + . . . + . . + + . + + + + + + + + + + + . + + . + + + . h < < < < < J + + . . + . + + + + + . . . . + . + . . 2 i + . + + j K + !.F ~.+ . . + + + . + + . + + + + + + + . . . + {.].+ Z B . + . + C p + + . . + + + + + + . + . + . + + + + + . . + + . ",
"+ + + + ^.< < < < < < F /.' ' ' ) ' ' ' ) ) ' ' ' (.+ + + + + + + . ' _.:.+ + <.< [.}.|.7 < < 1.2.. 3.4.+ + . + + + + + + + + + + + + + + + + + + + + + . + . . + + + + + + + + . + . + + . + + . + + + + + . . + + + + . + + . + . + + + + + + + + . + + . + . . + . . + + . + . + + + . . + . h < < < < < _ + + + + + . . + + + + + + + + + . + + + 2 i + + + + j w + + D 5.+ + + . . + + + + . + + . + + . + + + . 6.7.. + Z B . + + . C D . + + . + + + . . + + + + + + + . + . + + + . + . ",
"+ . + + ^.< < < < < < 8.+ + . . + + . + + + + + + + + . + + + + + + + 9.0.a.6.0 < < < b.c.< < < K + d.e.+ + + + + + f.g.h.h.g.h.i.. + + + + + . j.h.g.h.h.h.h.k.+ + + l.m.m.n.m.m.8 + + + + + + 4.o.p.q.r.h.h.h.8.+ + . + s.t._ u.v.g.h.h.w.. + + + x.y.z.7.g.h.h.g.h.h.g.h.m.A.B L + + + + + + h < < < < < _ + + + . + + + . + . + + + + + + + + + + v 3 + + . . 4 K . . B.F / + . + + + . . + + . . + + + + + + + + C.D.+ + P B + + . + 9 p + + + + + + + + + + . + . + + . + . + + + . + + + ",
"+ . . + ^.< < < < < < E.. + + + + + . + + . + + . + + + + + + F.+ + + G.< < H.< < < < e e < < < I.J.k K.+ + . . . . L.< < < < < M.. . . . + + . |.< < < < < < 6 . + + K.< < < < < N.. + + + + O.P.< < < < < < < Q.. + + R.z < < < < < < < O + + . L S.< < < < < < < < < < < < < < < T.m + + + + h < < < < < _ + + + . + + + . + . + + + + . + + + . + 2 i . + + + j K + + + G.U.+ + + + + + + + + + + . . + + + + + V.W.!.. + Z B + + + + C p + . + . + + + + . + + + + . + + + + + . + + + + + ",
"+ + + . X.< < < < < < E.+ + + + + + + + + + + . + . + . + + . Y.+ Q 2 Z.< < < < < < < < < < < < < `.1. +~.+ + + + + L.< < < < < M.+ + + + . + + |.< < < < < < .++ + + ++< < < < < N.+ + + + @+F < < < < < < < < Q.+ + j.#+< < < < < < < < O . . |.M.< < < < < < < < < < < < < < < < < p + . + + 1 < < < < < _ + . + + + . + + + + . + . + + + + . + + 2 i + + + + j K + + . $+%++ + + . + + . + + + + + + + . . + + b.&++ + + Z B . + + + C p . + + + + + + + + + . + + + + + + + + + + + . + . ",
"+ + + + ^.< < < < < < &.+ + + + + + + + + + + + + + + . . + *+=+. G.< < < < < < < < < < < < < < < -+< < ;++ + + + + L.< < < < < M.+ + + + . + + |.< < < < < < .++ + + ++< < < < < N.. + . + N < < < < < < < < < Q.+ + b.< < < < < < < < < O + + Y.< < < < < < < < < < < < < < < < < < a 4.+ . + h < < < < < _ + + + + + + + + + + + + + + + + + + + + 2 i + + + . j K . + + + >+f.+ + + + + + + + + + + + + + . + (.F ,++ + + Z B + + + + C p + . + + + . + + + + + . + + + + . + + + . + + + + ",
"+ + + + ^.< < < < < < '+b.)+6.6.6.6.6.!+B.. + + + + + + + + ~+=+L.< < < < < < < < < < < < < < < < < < < H.k.+ + + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ + + ++< < < < < N.+ + + + {+< < < < < < < < < Q.+ + i.< < < < < < < < < O + + ]+< < < < < < < < < < < < < < < < < < < _.. + + h < < < < < _ + + + + + + + + + + + + . + + . + + + + 2 i + . + + j K + + + + ^+/++ + + + + + + + + + + + + + + + (+_++ + + + Z B + + + + C p + + + + + + + + + + + + + + + + + + + + + + + + + ",
"+ :++ + E.< < < < < < < < < < < < < < < < <+C E + :++ + + + [+i.z.< < < < < < < < < < < < < < < < < < < < Y.+ + + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ + + ++< < < < < N.+ + + + }+< < < < < < < < < Q.+ + |+< < < < < < < < < O + (.< < < < < < < < < < < < < < < < < < < < 1++ + + h < < < < < _ + + + + + + + + + :++ + + + + + + :++ + 2 i + + + + j 2+:++ + + + 3+4++ + + + + + + + + + + + + + + 5+6++ + . + Z B + + + + C p + + + . + + + + + + + + + + + + . + + + + :++ + + ",
"+ + + + o.< < < < < < < < < < < < < < < < < < 7+4.+ + + :++ =+8+]+< < < < < < < < < < < < < < < < < < < < 9++ + + + L.< < < < < M.+ + + :++ + + |.< < < < < < .++ + + ++< < < < < N.+ + + + 1.< < < < < 1.[ 0+0+a++ m < < < < < < b+c+0+0+)++ d+< < < < < < < e+f+g+>+g+M Z.< < < < < < `.:++ + h < < < < < _ + + + + + + + + + + :++ + . :++ + + + + 2 h+:++ + + j K + + + :++ 2 i++ + + + + + + + + + + + :++ j+k++ + + + + Z l++ + + + m+p + + + + :+:++ + + + + + + + :+:++ + + :+:++ + :++ ",
"+ + + :+n+o+< < < < < < < < < < < < < < < < < < -.:++ + + :+}+%+p+< < < < < q+r+s+t+s+s+u+7 < < < < < < < <++ + + :+L.< < < < < M.:+:++ :+:+:+:+v+< < < < < < w++ :++ ++< < < < < x+:++ :+:+y+< < < < < z+:+:++ :+:+A+< < < < < < B+:+:+:+:+:+d+< < < < < < i+:++ + + + + C+H.< < < < < `.:++ + h < < < < < _ :+:++ :++ :+:+:++ + :+:++ + :+:++ + :+:+2 i + :+:+:+j K + :++ + + (.D+E++ + :+:++ + :+:+:++ + :++ x+F+:+:++ :++ Z l+:+:++ + C G+g+g+>+>+>+g+>+>+>+g+>+g+g+>+>+g+>+g+>+d++ :++ :++ ",
"+ :+:++ + =.< < < < < < < < < < < < < < < < < < I.@+:++ + + H+ +< < < < < < L.+ + + :++ I+&+< < < < < < < 2+:++ :+I+J+< < < < < K++ + + + + + + L+< < < < < < .+:++ + M+< < < < < N.+ :++ + N+< < < < < j + + + + + O+< < < < < < P++ + I++ + d+< < < < < < Q++ + + + R+S+T+< < < < < < `.+ :+:+h < < < < < _ + + :++ + + + + + + + + :++ + + + :++ + 2 i :++ + + j K :++ + + :+:+++U+:+:++ + :+I++ + + :++ + V+%++ + + :++ :+Z B + + :++ m+W+6.6.X+6.6.6.X+6.6.6.X+6.6.6.6.6.X+6.6.!.+ + + + + ",
"+ + + + + F.}+< < < < < < < < < < < < < < < < < < Z + :++ + Y+< < < < < < < B.+ + + + + + E+< < < < < < < %.:++ + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ :++ ++< < < < < N.+ I++ I+y+< < < < < j + :++ + :+A+< < < < < < ].+ + + + I+d+< < < < < < )++ Z+j s+H.< < < < < < < < `.+ + + h < < < < < _ + + + :++ + + :++ + I+I++ + + + + + + + 2 i + + + :+`+K + + :++ + + ~. @A++ + + + I++ + + + + + B .@+ + + + + + Z B + + + + C +@+ I+I++ + + :+:++ + + + + + I++ + + + :++ + + + + ",
"+ + + + + @@;.5+< < < < < < < < < < < < < < < < < p :++ + + 1.< < < < < < < B.:+I++ + + :+/ < < < < < < 1.J.+ + + + L.< < < < < M.+ @@+ + + I++ |.< < < < < < .++ + + ++< < < < < N.+ + + + N+< < < < < j + + + + + A+< < < < < < P++ + + + + #@< < < < < < ~+n b+< < < < < < < < < < < `.+ + + h < < < < < _ + + + + + + + + :+I++ + @@+ + :++ + + + $@i I++ + + j K + + + I++ + + %@&@+ + + + + + + + + + x.F *@+ + + + + + Z B + + :++ C +@+ + + + + + + + + I++ + :+:++ + + I+:++ + :++ :++ ",
":+@@@@:++ I+:+=@%.-@;@h.>@>@,@h.,@Z.< < < < < < < [ + I+:++ '@< < < < < < < B.:++ :++ I++ / < < < < < < )@I+!@+ + :+L.< < < < < K++ + + + + + :+|.< < < < < < w++ + @@M+< < < < < N.+ :++ I+~@< < < < < `+I+:++ + + {@< < < < < < ]@+ :+:+:+:+d+< < < < < < < < < < < < < < < < < < ^@/@s.+ :++ h < < < < < _ + + I++ I+@@+ I+:++ + + @@:++ :+:+:+:++ $@i I+:+I+I+(@K @@+ + I+:++ + !@_@:++ :+:+:+:+I+@@:+:+:@E.:+:++ :++ :+:+<@l++ + I+I+C +@+ :+:+:++ + + :++ + :++ I+:++ + + + + :++ :++ + + ",
"+ + + + + :++ + :+@@+ :++ + + + I+[@}@< < < < < < [ @@:++ :+7.< < < < < < < |@+ :+I++ + :+/ < < < < < < j A+1@:++ I+2@< < < < < M.+ @@@@@@:+:++ v+< < < < < < .+:+:++ ++< < < < < x+:++ :++ y+< < < < < j :++ @@+ :+A+< < < < < < ].:++ + + + 3@< < < < < < < < < < < < < < < '@++.++ I+:+:+I+:+h < < < < < 4@@@:+:+:+:++ + + + :+:++ + I+I++ + + + I+2 h+:+I++ + `+5@+ + :+:++ I+@@+ A.e.:++ + I++ :++ + O+6@~.+ + @@+ @@+ + 7@B :++ :+:+8@9@:++ I++ :+I+:++ :+:++ + + + :+:+:++ :+I+I++ I+@@+ ",
"+ + I++ + + I+I++ + + + + :+:++ :+:+0@< < < < < < [ + + + @@n < < < < < < < B.+ + @@+ I+:+a@< < < < < < b@c@o @@+ + 2@< < < < < K++ + + + + + I+d@< < < < < < .+I++ + ++< < < < < N.+ + + + y+< < < < < j + + + I+:+A+< < < < < < ].:++ + + + 3@< < < < < < < < < < < < '+e@f@E + :++ I+I++ I+:+h < < < < < _ + + I++ + @@:++ + + + + + + I++ + + + I+2 i + :+:++ j K :++ + I+:++ :++ c g@I++ + :++ + I++ h@i@@@I++ + + :++ + <@j@I++ + + C +@+ + + I+:++ + + I++ :+:+:++ + + :++ + :+:++ + @@+ ",
":+:++ I++ :+:++ + :+I++ :+I++ :++ + k@< < < < < < [ + :+:++ l@7 < < < < < < m@I+:++ :+:+I+/ < < < < < < n@o@p@+ :+:+J+< < < < < M.+ + + @@:+@@+ |.< < < < < < .++ + :+q@< < < < < x+@@:+:+:+N+< < < < < j @@+ @@:++ A+< < < < < < r@+ :+@@:+:+#@< < < < < < < < < < r.s@R+:++ + :++ :+:++ :+:+I+t@< < < < < _ @@+ :+R+u@+ + :+:+I+:++ + + :+:+@@@@+ :+v@h+:++ + + j 2+I+:++ :++ + I+:+w@x@|.@@:++ :+:+:++ y@z@+ :++ :++ I+@@+ 7@B :++ + + C +@:+:+@@+ + @@@@+ :+:++ + + I+@@:++ I++ + + :++ + :+",
"+ :+:+@@+ + :++ I+:+@@+ :+I++ :+@@+ A@< < < < < < B@I++ + @.C@D@< < < < < < R++ :+I++ :++ / < < < < < < E@< >++ + + L.< < < < < K+:+:++ + + :++ L+< < < < < < w+@@I++ M+< < < < < N.+ I++ I+y+< < < < < j I++ + I+:+A+< < < < < < P+I++ I++ + d+< < < < < < < F@&.G@+ I++ I+@@I+I++ + :++ + :++ H@< < < < < _ @@+ + _.I@:++ + :+I+:+:+:++ I++ + :++ + J@i I+@@@@:+j 2++ :++ :++ + I+:++ K@+++ @@+ + + :+L@M@+ + + I+:+:++ :+:+<@B @@:+:+:+8@+@I++ :+:++ + @@+ + I+I++ :++ I+@@:+:+:+:++ :++ + + ",
":++ + + @@:++ @@:++ + @@+ :+I+I++ :+_ < < < < < < [ :+@@:+X+N@O@< < < < < < B.@@+ a@P@+ @@@@C+Q@R@< < < < < S@@@@@:+J+< < < < < H++ I++ :+:++ :+|.< < < < < < .++ :+:+T@< < < < < x+:+:+@@:+N+< < < < < `+:++ :+:+I+{@< < < < < < r@+ + :+@@:+d+< < < < < < U@(.+ + :++ :+:++ :+:+@@:++ @@:++ @@t@< < < < < _ + :+@@V@W@I+I+@@+ :+I+I+I+@@+ :++ I+:++ X@9@:++ + I+Y@K @@I+:++ @@:+:++ :+Z@W.`@+ @@@@I+I+ #>.:+:+@@:++ + :+I++ Z l++ I+I+I+C 9@+ :++ + + :++ :+@@:+:+@@+ + :++ + I++ I+:+I+:+@@@@",
"@@:++ + .#G@f.f.+#+#f.@#f.+#+#f.@#M+##< < < < < < [ + I++ d+e $#< < < < < < B.@@+ %#&#e+k+*#=#:+R+-#< < < < >++ I+I+L.< < < < < ;#>#@@I+I+@@I+:+,#< < < < < < .++ + :+q@< < < < < '#+ + + + )#< < < < < j @@I++ :+I+O+< < < < < < r@:++ + + @@d+< < < < < < !#:++ I+:+I++ :++ + + I+@@+ I+I++ + H@< < < < < _ I++ + ~#7+:++ :++ :+:+:++ @@+ @@:+I+:++ b.{#:++ :++ (@K :+I+@@+ + + :+I+@@@@Y.`.+ + :+:+]#^#w@I++ + @@:++ :+I+@@7@B :+:+:++ C /#I+@@I+@@+ :+I++ + + + @@:++ :+@@:+@@:+I+:+I++ + + ",
"+ I+@@+ ^.< < < < < < < < < < < < < < < < < < < < (#+ :+@@:+<+y+< < < < < < _#+ @@+ 6.o+< < < :#4+:+<#< < < z.:+:+:+J+< < < < < < m.i s@s@0+s@[#}#< < < < < < l@@@@@I+++< < < < < N.:++ @@@@N+< < < < < |#+ :+@@+ :+A+< < < < < < P+I+:++ @@+ E+< < < < < < 1#2#s@s@0+0+3#4#3#3#s@0+0+0+5#:+:+I+t@< < < < < 6#:++ + 7#8#+ + I+@@I+I++ I++ I++ + :+I++ _ 9#+ @@+ + `+0#I++ + I+@@@@I++ + + a#b#Q + + + c+c@:+:++ I++ I+@@+ :++ Z c#+ + + @@d#e#+ + :++ @@+ :++ @@@@+ + I+:++ + I++ + + + :++ + @@",
"+ + @@@@^.< < < < < < < < < < < < < < < < < < < < f#I++ I+@@g#< < < < < < < h#O q@i#I+2+< < < < y+!@*@j#< < k#+ I+I+l#< < < < < < < < < < < < < < < < < < < < j.+ + I+q@< < < < < '#@@+ + + ~@< < < < < m#+ + @@+ @@O+< < < < < < r@I+:++ + @@:+0.< < < < < < < < < < < < < < < < < < < n#I+:++ H@< < < < < _ :+@@I+I+o#p#:++ + + @@+ + :++ @@+ :+@@:+h.q#+ @@@@I+`+K @@I+:++ + :+@@@@I+I++ r#s#@@@@t#D+u#+ @@:+I+:++ @@I+I+:+Z c#I+@@+ :+m+9@I+I++ + @@+ @@+ + @@@@:+I+@@+ + @@:+@@:+I+@@@@+ :+",
"@@@@+ + Q@< < < < < < < < < < < < < < < < < < < < O.:+I+:++ .+o+< < < < < < < < < v#v+w#e < < < < x#y#z#< < $@@@:+:+A#< < < < < < < < < < < < < < < < < < < F@w@@@@@:+++< < < < < x++ I+:+@@y+< < < < < `+@@I++ @@+ {@< < < < < < ]@:+I+I+@@+ I+B#< < < < < < < < < < < < < < < < < < < C#+ + @@t@< < < < < 4@I++ + :+&.>.I+I+@@@@+ @@@@@@@@+ @@I++ D#E#+ @@+ + :+j 5@+ :++ @@I+@@+ + :+:+I+)+7++ + {#N@:+@@+ + :++ I++ + :+@@<@B :++ @@I+d#+@:+:+@@I++ @@+ I+@@+ + I++ + @@:++ I++ I+:++ + I+I+",
"+ @@@@+ Q@< < < < < < < < < < < < < < < < < < < F#+ :+I+I+@@I+G#< < < < < < < < < < H#@@I#< < < < < J#!@< < e.@@I+:++ K#< < < < < < < < < < < < < < < < < < W@+ + I+@@q@< < < < < L#:+I++ I+)#< < < < < j :+@@+ @@I+{@< < < < < < P+:+@@+ I+:+:+M#< < < < < < < < < < < < < < < < < < < C#@@+ I+t@< < < < < 6#@@@@I+@@N#O#y#+ + @@+ + + + I++ I+@@:+%@P#+ I+I+I+@@j 5@I+@@+ :++ @@+ @@I+:+@@I+Q#R#I+S#T#+ @@@@I+@@@@I+@@@@I+I+7@j@@@+ :+:+m+e#I++ :+@@+ I+:++ @@I+:+@@@@+ @@@@:+@@:+I+I+I+:+:++ ",
"I++ I+@@^.< < < < < < < < < < < < < < < < < < U#*+@@I+:+:++ :+V#W#< < < < < < < < < X#A+Y#< < < < < Z#`#< e  $+ :+I+I+1+< < < < < < < < < < < < < < < < < o+.$I+@@:++ ++< < < < < N.I+:+@@:+~@< < < < < |#I+I+@@+ :++$< < < < < < r@I++ @@:+I+@@s.r.< < < < < < < < < < < < < < < < < < n#I+@@:+H@< < < < < _ + :+:++ + @$#$@@@@I+@@@@I+@@@@@@:++ $$%$E I+@@@@:+I+Y@K :++ I+I+I++ @@+ :+I++ :+o...J+&$+ @@+ + :++ + :++ + + :+<@l++ @@I+@@d#/#:+@@@@+ @@:+@@@@:+:+@@I+I+@@+ + I++ @@:+:+:+I+@@@@",
"@@+ I+I+Q@< < < < < < < < < < < < < < < < < *$=$I+@@@@I+@@I+:+@@-$;$< < < < < < < < < >$5#< < < < < ,$:+'$R@)$!$:+@@@@I+~$e < < < < < < < < < < < < < < {$.@@@+ @@@@@@M+< < < < < x+I+I+@@+ )#< < < < < `++ + @@I+I+O+< < < < < < ]@@@+ @@:++ @@@@]$Q#< < < < < < < < < < < < < < < < < ^$+ @@@@/$< < < < < 6#I+@@@@@@@@C@_ C.|.+ + :+I++ + I+u#($_$!$:++ :+@@:++ Y@0#@@@@:+@@@@I+I+@@:+@@@@@@:$h#<$[$I+@@@@@@@@@@@@@@@@@@@@I+7@c#+ @@I+:+d#(#' ' }$[@}$' ' [@}$[@P@' P@}$}$}$}$[@}$}$p#@@I+I+I+",
"I+@@I+@@0+>@|$h.,@|$|$>@|$>@>@>@>@|$1$2$3$4$5$+ :+I+I+@@I+@@I++ @@L.-+< < < < < < < < 6$T#< < < < < 7$I+8$< 9$+ @@+ I+@@@@0$a$A.v.>@|$|$h.>@>@,@>@b$c$q@.#@@+ @@I+I++ d$e$x@e$f$e$G#@@:+I+@@g$|$h.h.>@>@h$@@@@I+@@I+i$|$>@|$h.h.|$X+I+@@I+I+I++ I+I+, j$k$l$m.|$h.>@>@>@h.>@|$h.h.|$,@|$m$@@I++ n$f$x@e$o$x@p$@@I+I+I++ @@q$r$s$t$e#Z#f@Z#u$v$w$:@x$I+I+@@I++ I+@@)+M++ + @@:+I+:+@@I+@@I+I++ + K@L#@@:+I+I+I+I++ + :++ I+I+:+y$z$@@+ :+I+Z#|$>@>@|$,@|$>@>@>@h.h.|$>@|$|$h.h.h.,@h.h.A$+ + @@:+",
"@@:+@@@@@@@@@@@@@@@@:+:+I+I++ I+@@@@@@@@+ I+@@@@:+:+I+:++ @@@@I+@@@@B$C$D$E$l+-@< F$G$w#H$< < < < < B@:+1#< I$+ @@:+O++ @@@@@@@@I+:+:+@@+ I+I+I+@@:+I+:+I+@@@@:+@@@@@@+ I++ @@I+I+:+I+:+I+I+@@@@@@I++ I+I+I+:++ :+I+@@@@:+@@@@:+I+:+I+:+@@@@@@:+:+@@@@I+@@@@:+@@I+:+@@@@I+:+@@@@J$K$:+I+I++ I+@@@@I++ @@@@:++ + @@:+@@I+@@I+I+@@L$M$e#++N$O$P$Q$I+:+@@I+@@@@@@@@@@@@@@@@I+I+@@@@+ :+I+@@:+@@@@@@+ + I+:+:+:+:+I+@@I+@@:+:+@@I+@@I+@@I+@@:+@@@@I+@@I+@@I+I++ @@@@@@I+@@:+@@@@@@I+@@@@:+@@@@+ @@@@",
"I+@@+ I++ :+I+I+:++ I+I+:+@@@@@@@@+ + + @@:+I+I+I+I+:+@@@@:+I+:+@@I+@@R$%#+ @@@@S$T$U$@@V$< < < < < 2+I+W$*$5$@@I+I+7#G@I++ @@I+@@@@@@@@@@@@@@@@I+I+:+I+:+I+I+@@+ I+@@@@@@@@+ :+@@I+@@I+:+:++ I+I+:+@@@@@@:+I+@@@@@@I+I+I+@@X$@@@@I+:+I+@@I+I+@@Y$X$I+I+I+@@I+@@:+I++ I+:+I+I+X$X$X$X$Z$`$@@@@+ + @@@@I+I+I+@@@@+ @@I+:+@@@@@@@@I+@@@@@@@@+ I+I+@@I+@@@@+ I+I++ @@I+I+@@:+@@+ I+@@@@@@+ I+I+I+I+@@@@@@I+@@@@I+@@I+@@I+I+I+I+:++ @@I+@@I+I++ + :++ @@+ :+:+@@I+I+:+@@I+@@I+I+I+@@I+I+I+@@I+@@I++ ",
"I+@@@@@@I+@@@@I+@@@@@@@@+ I++ + @@@@@@I+@@@@:+@@@@@@I+@@I+:+@@+ @@I+@@:+@@I+I+I+ %.%+ +%}+< < < < < @%+ #%R$@@@@@@@@$%;@%%I+@@:+I+I++ @@:+I++ :+@@@@@@@@@@:+I+@@@@+ @@+ I+@@I++ @@@@@@@@I+@@@@@@@@I++ :+@@@@I+I+I+:+:+@@+ X$X$@@@@@@@@+ :+@@I+&%X$X$:+@@+ @@I+@@@@@@@@@@@@X$X$X$X$X$X$X$X$*%@@@@+ I+:+@@@@@@I+@@I+@@@@+ :++ + :++ I+@@:+@@@@@@I+@@+ + @@@@:+@@I+@@@@I+@@I+@@I+@@I++ @@@@@@I+@@@@@@+ @@I+I+@@I+@@I+@@@@@@@@@@@@+ I++ :+@@I+@@@@@@I+@@I+@@I+@@@@I++ :+I+@@@@@@I+@@@@@@I+@@I+@@@@@@",
"@@I+:+I+@@:++ @@I+I+I+I+@@@@@@@@@@I+@@@@I+I+@@I+I+I+@@I+@@@@I+@@:+@@+ @@I+@@@@@@@@ $@@=%< < < < < < -%@@;%:+I+:+@@@@>%< 6$:+I+I+@@@@@@I+I+@@@@@@@@I+I+I+:+I+I+@@+ @@I+@@@@@@@@@@I+I+I+I+@@I+:++ I+@@@@I+I+@@@@@@:+@@@@,%X$X$X$+ @@I+I+@@@@+ '%)%X$X$@@+ @@@@:+I+I+I+:+I+X$X$X$!%!%!%~%{%X$X$X$@@@@@@I++ @@I+@@I+:++ I+@@I+@@@@@@@@@@I+I+I+:+I+:+I+I+@@@@I+@@I+I+:++ :+I+:+I+@@I+@@@@@@I++ :++ I+I+@@I+@@@@I+:+:+:+I+I+@@+ I+I+@@:+@@@@@@@@I+I+I+:+I+@@I+@@+ + @@@@I+@@+ :++ :++ + @@:+:+@@I+I++ ",
"@@I+@@I+I+@@I+@@:+@@@@@@:+@@@@I+@@I++ @@@@I+:+@@@@:+:+@@@@@@I+I+:+@@I+I+:++ :++ + I+5$|$< < < < < < ]%@@O+:+I++ I+:+^%< /%X$X$I+I+I+:+@@+ @@I++ @@:+:+I+@@:+I+@@I+:+I++ I+@@I+@@:+:+@@@@@@I+@@@@+ I+@@@@+ + + @@I+(%_%X$X$X$:%X$,%@@I+@@<%+ X$X$[%X$}%@@+ @@@@@@@@I+@@X$X$!%!%!%!%!%!%|%1%X$X$@@+ @@@@+ @@+ @@@@@@@@I+@@I+I+I+@@+ :+@@@@I+:+@@@@@@@@I+:+I+@@:+I+@@I+@@@@@@+ :++ I+I+@@@@@@@@@@:+@@:+:+I+:+@@I+@@:+@@+ @@@@@@@@@@@@I+I+@@@@@@@@@@@@@@@@+ @@@@@@@@@@:+@@I+@@@@@@@@+ @@I+I+:+@@@@@@",
"I+@@I+:+@@I+@@@@@@I++ I+I+I+I+@@@@@@@@+ I+@@@@:+I+I+I++ I+:+@@@@@@@@@@@@@@@@I+@@@@@@2%< < < < < < < <  %@@@@@@@@3%X$4%< < 5%X$@@:+@@@@@@@@I+@@@@I+@@@@@@I+@@:+@@@@I+@@@@@@+ @@:+I+@@:+I+I+@@I+:+@@@@@@+ @@@@@@@@@@,%X$X$X$6%:%X$7%:+@@I+8%X$X$X$:%X$<%I+@@I+I+:++ @@X$X$!%!%!%!%!%!%!%!%!%9%0%X$@@@@I+@@I+@@+ I+@@+ @@@@@@@@@@I+@@@@@@+ @@@@I+:+I+I+@@@@@@I+@@@@I+@@I+I++ @@@@@@@@:++ @@@@@@+ I+I+@@@@:+@@@@@@I+I++ @@I++ + I+I+I+@@:++ :+I+:+@@+ I+:+@@@@@@I+I+I+@@@@@@I+I+I+@@@@I+@@@@I+:+I++ ",
"@@@@@@@@@@I+I+I+:+@@@@@@@@@@I+I+:+I+@@@@@@I+I+@@@@@@@@@@@@:+@@I+I+I+@@I+@@@@@@@@I+I+a%< < < < < < < < r$@@@@I+b%c%d%e%< < f%X$@@@@I++ @@@@@@@@:+I+I+@@@@I+@@I+@@@@@@I+I+@@I+I+@@@@I+@@:+@@@@@@@@@@I+@@I+@@@@I+I+I+g%X$X$X$6%:%X$g%g%@@X$X$X$X$:%[%X$@@I+h%@@I+@@@@X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@@I+@@@@@@@@@@@@I+I+@@@@@@@@I+I+I+@@@@@@@@I+@@@@I+I+I+@@I+@@@@@@@@@@@@I+I+@@@@@@@@I+I+I+@@@@@@I+I+@@@@I+@@@@@@@@@@@@@@@@@@@@@@@@I+@@I+@@@@I+@@@@I+@@I+I+@@@@@@I+@@@@@@@@@@@@@@@@I++ @@I+@@@@@@",
"I+I+@@I+@@@@@@@@@@I+:+@@@@@@@@:+@@@@@@I+I+@@@@@@@@@@@@I+@@@@I+@@@@@@I+@@I+@@I+I+@@`@i%< < < < < < < < '#I+I+j%4%k%l%m%< < n%6%X$I+@@@@I+I+I+I+@@@@@@I+@@@@I+@@I+@@I+@@@@@@@@@@@@I+@@:+@@I+I+I+I+I+@@@@@@I+I+@@@@@@X$X$6%6%6%:%X$o%p%q%X$X$X$6%[%[%X$@@@@@@@@@@@@X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%r%X$X$@@I+I+@@@@I+I+@@:+I+I+I+@@@@@@@@@@I+@@@@@@@@I+@@@@@@:+@@I+I+@@I+:+@@@@@@I+I+@@@@@@@@@@I+@@@@@@@@I+I+@@:+@@@@@@I+@@@@@@@@@@:+:+@@@@@@:+I+@@@@@@@@I+@@@@I+@@@@@@I++ @@I+@@I+@@@@@@@@@@@@@@I+I+",
"@@I+@@I+@@@@@@I+@@@@I+I+I+@@@@I+@@I+@@@@@@@@I+I+I+I+@@I+I+@@@@I+@@@@@@@@@@@@@@@@@@-$< < < < < < < < < < Z#@@s%t%< u%v%< < w%x%6%X$@@@@@@@@@@@@I+@@@@I+@@@@@@@@I+@@@@@@I+@@@@I+@@@@@@@@@@@@@@@@@@I+I+@@@@@@@@@@j%X$X$6%!%!%!%[%X$X$y%X$X$X$6%6%[%[%X$,%I+g%@@X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z%X$X$@@@@I+@@@@@@@@@@@@@@I+@@I+@@I+@@I+@@@@@@@@@@@@@@@@@@@@@@I+@@@@@@@@@@@@@@I+I+@@I+@@@@I+I+@@@@@@@@@@A%I+I+@@@@@@I+I+I+I+I+I+@@I+@@@@@@@@I+I+@@@@@@@@@@I+I+@@@@@@I+@@I+@@I+I+@@@@I+@@I+@@@@@@",
"@@@@I+@@@@I+I+@@A%I+@@@@@@@@@@@@I+@@@@@@I+I+@@@@@@@@@@@@A%@@I+@@I+@@I+@@I+@@@@I+I+B%< < < < < < < < < < e C%D%< < E%< < < < F%6%X$@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@I+@@I+@@I+@@@@@@I+I+@@@@@@@@@@@@@@A%@@@@@@I+@@X$X$6%!%!%!%[%[%[%X$X$X$X$6%6%!%[%[%X$I+@@h%I+X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%G%H%X$I+I+@@@@@@I+@@@@@@@@@@@@@@I+@@@@@@I+@@I+@@I+I+I+I+A%I+@@@@@@I+I+@@I+@@@@@@A%@@@@@@@@@@@@@@I+@@@@I+I+@@@@I+@@I+@@@@@@@@@@@@@@@@@@I+@@I+A%@@I+@@@@I+@@@@@@I+@@A%@@@@@@I+:+@@I+I+@@@@@@@@@@I+",
"A%@@I+I+@@@@A%@@@@@@@@@@I+A%I+A%@@@@I+@@@@@@@@@@@@I+@@@@I+@@@@@@I+@@I+@@I+@@@@A%@@I%< < < < < < < < < < < < < < < < < < < < J%6%X$K%@@I+I+@@@@I+@@@@I+@@@@@@@@@@@@@@@@@@@@@@I+@@@@I+I+@@I+I+@@@@@@A%I+@@@@I+X$X$X$6%!%!%[%[%[%[%X$X$6%6%6%!%!%[%[%X$@@@@L%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%|%M%X$X$@@I+@@@@A%I+I+I+@@I+@@@@@@I+@@@@I+@@@@@@@@@@@@I+@@@@@@I+@@@@I+@@@@I+@@@@I+@@I+A%@@I+I+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@I+@@I+A%A%@@@@@@@@@@I+@@@@@@@@@@I+@@@@I+I+@@@@@@@@@@A%A%@@@@@@@@@@",
"@@@@A%@@@@A%@@@@@@I+@@@@@@I+@@@@A%I+@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@@@N%< < < < < < < < < < < < < < < < < < < < O%6%X$X$@@@@@@@@@@@@I+@@A%I+A%I+@@@@I+@@@@@@I+I+P%@@A%A%@@I+A%@@I+@@I+I+@@I+@@X$X$X$Q%R%!%!%[%[%[%X$X$6%6%6%!%!%!%[%[%X$S%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%T%U%!%V%W%X$I+@@@@@@I+@@@@@@@@@@@@@@I+@@@@@@@@@@I+@@@@@@@@@@@@@@I+@@@@A%A%@@I+@@I+@@@@@@@@I+@@@@A%@@@@@@@@@@I+I+@@@@@@I+A%@@I+@@@@@@@@@@@@@@@@I+@@@@I+@@@@I+I+@@@@@@I+@@@@@@@@A%I+@@A%I+I+I+A%I+@@@@",
"@@@@@@I+I+I+I+@@@@I+I+@@@@A%@@I+@@@@@@A%I+I+@@I+@@@@I+@@@@A%@@@@@@@@@@@@@@@@@@I+I+X%< < < < < < < < < < < < < < < < < < < Y%Z%6%6%X$X$A%A%A%@@@@I+@@@@:+@@I+@@@@@@I+@@A%X$X$A%@@@@A%@@@@@@A%@@@@@@@@P%I+X$X$X$Q%Q%R%R%[%[%[%X$6%Q%!%!%!%!%!%!%[%`%X$X$X$ &!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%.&+&@&!%!%X$X$@@@@@@@@@@@@I+A%A%I+A%@@I+I+A%@@@@@@A%I+A%@@@@I+@@@@A%@@@@@@@@@@@@@@@@I+@@@@I+@@@@@@I+I+I+@@@@A%@@I+I+@@@@@@P%I+@@A%@@@@@@I+@@@@@@@@@@@@I+@@P%I+@@@@@@I+@@@@A%I+P%@@@@@@@@@@I+@@@@I+@@",
"A%@@@@P%@@@@@@A%A%@@@@@@@@@@@@@@@@@@@@I+@@@@@@@@A%@@@@@@@@@@A%@@@@@@@@@@@@A%@@A%@@#&< < < < < < < < < < < < < < < < < < < $&!%!%6%6%X$X$@@I+@@@@A%I+@@A%@@A%I+A%I+@@@@X$X$X$X$%&@@@@@@I+@@@@I+@@@@A%@@@@X$X$&&Q%R%R%R%[%X$X$Q%Q%Q%!%!%!%!%!%[%[%*&X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%=&X$!%!%X$X$I+I+@@@@@@I+@@@@I+@@@@@@@@P%@@@@@@@@I+A%I+@@I+A%@@A%@@I+@@@@@@@@A%I+@@@@@@@@A%A%I+A%P%@@@@I+@@@@A%@@@@A%I+I+@@@@A%I+A%@@I+@@I+@@@@A%@@@@A%:+I+@@@@@@@@A%A%A%@@@@:+I+I+@@@@@@@@A%@@@@@@",
"@@I+:+@@@@A%I+@@@@@@A%@@@@@@@@@@@@@@@@@@A%A%A%@@A%@@I+I+@@@@I+A%@@I+A%A%I+I+@@@@@@I+-&< < < < < < < < < < < < < < < < < < ;&!%!%6%6%6%X$X$@@@@@@@@@@@@A%@@@@@@P%@@8%<%X$6%6%X$X$h%>&@@A%@@@@A%A%@@I+A%@@X$,&6%R%!%R%[%X$X$6%Q%Q%R%R%!%!%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%'&X$@&!%)&X$X$@@@@@@A%@@@@A%@@@@@@A%:+@@I+I+I+@@@@P%I+A%@@@@@@@@@@@@A%A%A%@@@@I+@@@@@@@@I+@@I+@@A%A%P%@@@@@@@@A%@@P%@@I+A%@@@@I+A%A%@@P%A%I+@@@@A%P%@@@@A%A%@@@@@@@@@@I+@@A%A%@@@@I+A%@@@@@@@@I+@@",
"A%@@A%@@@@@@@@@@A%A%I+I+I+I+@@A%I+I+@@@@@@@@@@I+I+@@A%P%@@I+A%@@A%@@I+@@@@P%@@@@I+@@Z#< < < < < < < < < < < < < < < < < !&~&!%!%!%6%6%6%X$X$A%@@@@@@@@I+@@@@@@@@A%A%X$X$6%6%X$X$g%A%A%@@I+@@@@@@I+@@@@X$X${&6%R%!%!%[%X$X$Q%Q%!%R%R%R%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%]&X$@&@&X$X$A%A%@@@@A%I+@@@@@@A%@@A%I+A%A%@@@@@@@@@@@@@@@@@@A%A%@@@@@@I+@@@@P%A%@@@@@@@@@@@@I+@@@@@@@@@@@@A%@@@@@@@@@@@@I+@@@@@@@@@@@@@@@@I+@@I+@@@@@@@@@@A%@@@@I+@@@@A%@@@@@@@@P%I+A%I+@@A%A%@@",
"A%@@A%A%@@@@@@@@@@@@A%A%A%A%I+P%A%A%A%@@@@@@@@@@A%P%:+@@@@P%I+@@A%@@@@@@@@@@@@A%@@@@^&/&< < < < < < < < < < < < < < < < (&!%!%!%!%6%6%6%X$X$@@A%A%@@@@A%A%I+I+@@@@X$X$6%6%6%6%X$X$@@g%A%A%I+I+@@@@@@@@X$X$6%6%!%!%!%X$X$6%Q%R%R%R%R%R%!%!%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z%X$@&@&X$X$I+A%@@A%@@A%I+A%I+@@@@@@@@A%@@A%@@I+A%@@A%A%@@@@@@I+A%@@P%@@A%@@@@A%A%I+@@A%A%P%I+@@I+A%@@@@@@@@@@I+A%@@@@@@@@@@@@@@@@I+I+A%@@A%@@I+A%@@@@I+@@A%A%A%@@@@@@@@@@@@A%@@@@@@@@@@@@@@A%@@",
"@@@@@@@@@@A%A%@@I+@@P%@@@@@@@@@@@@@@@@@@A%A%A%@@@@@@A%A%A%@@@@I+P%@@I+A%I+A%A%@@A%A%@@_&:&< < < < < < < < < < < < < < <&|%!%!%!%!%6%!%6%6%X$X$@@@@A%@@:+A%@@P%@@X$X$X$6%6%6%6%X$X$X$[&@@@@P%P%@@A%@@A%X$}&6%6%!%!%!%X$X$6%Q%R%!%!%R%R%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%|&X$@&@&1&X$@@I+A%A%A%@@P%@@@@A%I+A%@@P%A%@@@@@@A%A%:+A%I+A%A%A%@@I+A%I+@@I+@@I+@@P%A%@@@@@@@@I+P%@@A%@@@@@@I+@@@@A%@@@@A%A%I+@@A%@@A%@@A%I+@@@@@@A%I+A%I+@@:+A%A%A%@@I+@@A%I+I+@@@@A%A%@@@@@@@@",
"@@@@@@A%@@@@A%P%A%@@@@A%@@A%I+@@@@@@A%@@@@@@A%@@@@@@@@@@I+A%P%@@@@A%@@P%@@I+@@@@@@@@@@@@2&3&< < < < < < < < < < < < 4&5&!%!%!%!%!%!%6%!%6%6%X$A%A%@@A%@@A%@@@@@@X$X$6%6%6%6%6%6%X$X$6&@@@@@@A%@@A%@@@@X$}&6%6%!%!%!%X$6%6%!%!%!%!%!%R%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&7&X$X$@@A%:+@@A%@@@@A%A%@@@@A%:+@@A%A%A%:+A%@@@@A%:+P%A%:+A%A%A%P%A%P%I+A%@@@@@@A%A%A%@@I+I+A%A%A%A%A%@@A%A%A%A%@@A%A%@@@@@@@@@@P%@@A%@@A%P%@@P%@@A%A%:+@@@@A%A%@@A%A%A%A%@@@@A%@@I+A%@@",
"A%A%I+A%A%@@@@@@A%I+@@@@A%@@P%@@A%A%@@A%@@@@P%@@@@A%@@@@A%@@@@@@@@P%@@@@@@P%A%@@A%A%A%@@@@5$D$C$< < < < < < < < 8&9&!%!%!%!%!%!%!%!%!%!%!%6%X$X$A%A%@@@@P%A%A%X$z%6%6%6%6%6%6%6%6%X$X$0&a&'%@@@@I+@@<%X$b&6%6%!%!%!%X$c&6%!%!%!%!%!%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&X$X$A%@@A%A%:+A%A%@@P%@@A%A%P%A%@@@@A%@@A%I+A%A%A%A%@@A%:+P%@@@@@@@@A%@@@@A%A%@@:+P%@@A%P%I+@@@@P%A%@@@@@@P%@@@@P%@@I+A%A%A%@@@@A%@@A%:+A%@@:+A%@@P%A%A%@@P%A%@@@@@@@@@@A%A%@@A%A%@@A%",
"@@A%@@@@A%@@A%@@A%A%A%A%@@A%@@@@@@A%@@A%@@@@A%A%@@A%A%P%@@@@A%A%@@A%A%I+A%@@A%A%@@A%@@A%A%A%@@d&e&f&g&h&i&j&4&k&l&!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$m&A%:+@@@@X$n&o&6%6%!%!%!%!%!%!%6%6%X$p&6&6&q&r&A%A%X$s&6%!%!%!%!%X$6%6%!%!%!%!%!%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&X$X$:+@@A%A%A%@@A%@@A%@@:+@@@@I+P%:+A%@@P%@@@@A%:+A%A%A%@@A%@@I+A%P%A%A%I+A%@@P%@@@@P%@@A%I+I+@@:+A%@@A%@@@@A%@@A%P%@@@@@@A%@@A%@@A%P%@@A%A%@@@@A%:+@@A%A%:+A%A%@@A%I+A%I+A%@@@@@@@@@@",
"A%P%@@A%@@A%@@@@P%P%A%@@A%@@A%A%@@@@@@@@A%@@@@@@A%@@@@@@A%A%I+@@I+A%@@P%@@A%@@A%I+P%A%@@@@@@A%I+@@A%X$t&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$p%A%A%@@X$u&v&6%!%!%!%!%!%!%!%6%6%X$X$X$j%@@@@w&,%X$b&6%!%!%!%!%X$6%6%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$A%A%@@@@:+A%A%A%A%A%A%A%A%A%@@A%@@A%A%A%A%A%A%:+P%@@A%@@A%P%@@@@@@A%P%@@A%@@A%A%@@@@@@A%P%@@A%@@A%@@A%A%@@@@@@A%P%A%A%A%A%@@A%@@A%@@@@A%I+I+@@A%A%@@@@A%@@A%A%A%P%@@P%@@A%A%A%@@A%",
"@@A%@@A%A%A%@@A%@@P%@@@@@@A%A%A%A%A%A%A%A%A%A%A%A%A%@@@@@@P%A%P%@@@@A%A%A%A%@@P%A%@@A%A%A%P%P%A%A%A%X$x&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%y&X$<%z&X$A&B&6%!%!%!%!%!%!%!%!%!%6%6%6%C&D&0%X$X$X$X$E&6%6%!%!%!%[%6%6%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$@@A%A%A%P%:+@@@@@@P%@@@@P%A%A%A%A%:+@@@@@@A%A%@@A%@@A%@@A%A%A%A%@@A%@@A%@@A%@@I+A%P%P%A%A%P%A%@@@@A%@@A%A%A%@@A%@@A%@@@@A%A%@@@@A%A%@@A%P%A%@@@@A%I+A%A%P%P%@@A%@@A%@@P%@@@@A%@@A%",
"@@@@A%A%@@A%A%@@@@A%@@A%A%@@P%@@@@@@A%@@A%A%@@@@@@@@A%A%A%A%@@A%A%@@@@@@@@@@@@A%@@@@P%@@@@@@@@@@@@F&X$G&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%x%X$X$p%X$H&6%!%!%!%!%!%!%!%!%!%!%!%6%6%6%I&J&6%K&L&X$C&6%6%!%!%!%!%6%6%!%!%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$@@P%@@@@A%A%A%@@A%@@@@A%@@P%@@@@A%A%A%@@P%@@A%P%A%@@A%@@@@@@@@A%@@A%@@A%@@A%P%@@@@@@@@@@@@A%A%A%@@A%@@@@A%@@@@A%@@A%@@P%P%A%@@@@@@A%P%@@@@A%A%@@P%@@@@@@A%@@@@A%@@A%@@A%A%@@A%P%",
"A%@@@@A%@@A%@@A%@@A%A%A%@@@@A%A%A%A%A%@@@@A%A%A%A%A%@@@@@@A%A%@@A%@@A%A%A%A%@@A%A%A%A%A%A%A%A%A%@@M&X$N&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$O&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$6%6%!%!%!%!%!%6%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$@@A%A%P%@@@@A%@@A%A%@@@@A%@@A%A%@@@@A%A%@@A%@@@@A%A%A%A%@@A%P%@@@@A%A%A%A%A%A%@@@@A%A%A%@@P%@@A%A%A%A%P%A%A%@@A%@@A%@@@@P%A%A%@@@@@@A%A%@@@@A%A%A%A%@@@@A%A%@@A%A%A%P%A%A%@@@@A%",
"A%A%A%@@A%A%A%@@A%A%P%@@A%A%A%A%A%@@P%A%A%@@@@A%P%@@A%A%A%P%@@A%A%A%@@P%P%@@A%@@@@@@@@P%@@A%A%P%A%P&X$Q&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$R&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$6%6%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$A%P%@@@@A%A%P%A%@@A%A%A%@@@@P%P%A%A%P%@@A%@@A%A%P%@@@@A%A%@@@@A%A%@@@@A%@@@@A%A%A%A%A%A%A%@@A%P%P%@@@@@@@@@@A%A%A%P%A%A%@@A%A%A%A%A%A%@@A%A%P%A%P%A%A%A%P%A%A%@@P%A%@@@@P%A%A%@@",
"P%P%A%P%P%A%A%P%A%@@A%P%A%P%A%A%A%@@P%P%A%A%P%A%A%P%A%A%A%A%A%P%P%A%@@@@A%A%A%A%A%A%@@A%P%P%@@A%A%P%X$o&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$S&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$T&6%!%!%!%!%!%!%X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%U&X$X$@&@&@&X$X$V&A%A%A%P%A%@@A%P%A%P%A%A%@@@@P%P%@@A%P%A%A%A%@@A%A%@@A%A%A%A%A%P%A%P%A%A%@@A%P%P%A%P%P%A%A%@@@@A%A%A%A%A%P%P%P%@@A%@@A%A%P%P%A%A%P%P%A%P%@@@@@@P%A%A%@@P%P%P%@@@@A%P%@@A%@@A%A%",
"A%A%P%@@@@P%P%@@P%A%A%A%@@A%@@P%P%A%A%A%P%P%@@@@P%A%P%P%@@P%P%@@A%P%A%A%P%P%P%P%P%P%A%A%@@@@A%P%P%@@X$o&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%0%R&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%W&6%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X&X$X$@&@&@&X$X$Y&A%P%P%@@@@A%P%A%P%@@A%P%A%A%@@A%A%P%@@P%P%@@A%P%P%A%P%A%A%A%P%A%A%@@P%A%A%P%A%A%P%@@A%A%P%A%A%P%P%A%P%A%A%@@@@A%A%A%A%P%@@A%P%P%A%A%P%@@A%A%A%@@A%P%A%@@A%A%A%P%A%A%A%P%A%P%A%",
"A%A%A%A%@@A%A%@@A%P%A%P%@@A%@@A%A%P%@@A%A%A%A%A%P%A%@@A%A%A%A%A%A%A%A%A%@@A%A%@@A%A%P%A%A%A%@@A%A%P%X$N&6%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%X$Z&`&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%!%!%!%!%!%!%X$ *[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%U&X$X$@&@&@&.*X$+*A%@@A%A%P%A%A%@@A%P%A%A%A%A%P%A%A%A%A%@@P%A%A%A%P%@@P%P%P%@@A%P%A%A%P%P%@@A%A%A%A%A%A%@@A%A%A%A%P%A%P%A%A%A%A%P%A%A%@@A%P%@@@@A%A%@@A%A%P%A%A%P%@@A%A%@@A%A%A%P%A%P%A%P%A%P%A%",
"P%A%P%P%P%P%P%A%P%A%P%A%A%P%A%P%P%@@P%P%P%P%P%P%@@A%A%P%P%P%A%P%P%P%P%A%A%@@A%A%P%P%A%A%A%P%A%A%P%A%X$Q&6%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$@*6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%#*X$$*[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&%*X$&*P%A%P%P%A%P%P%A%P%A%P%P%P%A%@@P%A%P%A%A%A%P%A%P%A%A%@@A%@@A%P%A%P%A%@@A%A%P%P%@@P%A%P%A%A%P%A%A%A%A%A%P%A%P%P%@@P%P%A%P%A%A%A%P%P%A%A%P%A%P%A%A%A%P%P%P%P%P%P%A%P%A%P%A%A%@@P%",
"P%A%A%A%@@A%P%A%P%@@P%P%A%P%A%@@P%A%A%A%A%A%@@A%P%P%A%A%@@P%A%A%A%A%P%P%P%P%P%@@A%A%P%P%A%P%P%A%@@P%X$o&6%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%*&[%**`&Q%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%=*!%[%!%!%!%!%!%-*X$;*r%X$X$X$X$X$X$X$[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&>*X$,*P%A%A%P%A%A%P%A%P%A%A%A%P%A%A%P%A%P%P%P%A%P%A%P%P%P%P%P%P%@@P%A%P%P%P%P%@@@@P%A%P%A%P%P%A%P%P%P%P%A%@@P%A%A%P%A%A%P%A%P%P%P%@@A%P%P%A%A%A%P%P%P%A%A%A%A%A%A%A%@@P%@@A%P%A%A%A%",
"A%P%P%P%A%P%A%P%A%A%A%A%P%A%P%P%A%P%P%P%P%P%P%P%A%A%P%P%P%A%P%P%P%P%A%A%A%A%A%A%P%P%A%A%P%A%A%P%P%A%X$'*6%!%!%[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$X$X$X$X$)*c&R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!*[%[%!%!%!%!%!%1%X$X$X$X$X$!%!%~*]&X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X${*A%P%P%A%P%P%A%P%A%P%P%P%A%P%P%A%P%@@A%A%P%A%P%A%A%A%A%A%A%P%A%P%@@A%A%A%P%A%A%P%A%P%A%A%P%A%A%A%A%P%P%A%P%P%A%P%P%A%P%A%A%A%P%P%A%A%P%P%P%A%A%A%P%P%P%P%P%P%P%P%A%P%P%A%P%P%P%",
"A%A%]*P%A%P%A%P%P%P%]*A%P%A%]*A%A%@@A%A%A%A%A%P%P%]*A%A%P%A%A%A%A%P%P%P%P%P%P%A%A%P%P%A%P%P%A%A%P%P%X$^*6%!%[%[%[%[%[%[%[%[%[%X$X$!%!%!%X$X$X$!%X$/*(*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%_*[%[%[%!%!%!%!%;*X$X$X$!%!%!%!%!%:*!%<*X$X$X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$@&@&@&@&X$X$[*A%A%P%A%A%P%P%P%A%A%A%P%A%A%P%A%P%P%P%P%P%A%P%P%P%P%P%P%A%P%A%P%P%P%P%A%P%P%@@P%A%P%P%A%P%P%P%P%A%A%P%A%A%P%A%A%P%A%P%P%P%A%A%P%P%A%A%A%P%P%P%A%A%A%A%A%A%A%A%P%A%A%P%A%P%A%A%",
"P%P%A%A%]*A%P%A%A%A%A%P%A%P%A%P%]*]*P%P%]*P%P%A%]*A%A%P%]*P%P%P%P%A%A%A%A%A%]*P%P%A%A%P%A%A%P%P%A%A%X$}*6%[%[%[%[%[%X$/*|*;*r%!%!%!%X$X$X$!%!%!%X$1*2*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%3*[%[%[%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%4*W&5*X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6*@&@&@&X$X$Y&P%P%A%P%P%]*A%A%P%P%P%A%P%P%A%P%A%]*A%A%A%P%A%A%A%A%A%A%P%A%P%A%A%A%]*P%P%A%P%A%P%A%A%P%A%A%A%A%]*P%A%]*P%A%P%P%A%P%A%A%A%P%P%A%A%P%P%P%A%A%A%P%P%P%P%P%P%P%]*A%P%P%A%P%@@P%P%",
"A%A%]*A%P%A%P%P%P%P%A%P%A%A%A%A%A%A%A%A%A%A%P%A%A%P%A%A%A%A%A%A%P%]*P%P%]*A%A%A%P%]*A%P%P%A%A%P%P%]*X$6%:%[%[%[%X$7*|&8*9*0*!%!%!%!%X$!%!%!%!%a*X$b*c*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%d*e*f*X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6*@&@&@&X$X$g*A%P%A%A%A%P%P%A%A%A%]*A%A%P%A%P%A%]*P%P%A%P%P%P%P%P%P%]*P%A%]*]*P%A%A%]*]*]*P%A%P%P%A%P%P%P%P%A%A%P%A%A%A%A%A%]*]*A%P%P%]*A%P%P%A%A%A%P%P%]*A%A%A%A%A%A%A%A%P%]*]*P%A%]*A%A%A%",
"P%P%A%P%A%P%A%]*]*A%P%]*P%P%]*A%P%P%P%P%]*]*A%A%P%]*]*A%P%P%]*P%]*A%]*P%A%A%P%P%A%A%]*A%A%P%]*P%A%A%X$X$:%[%X$X$;*E&h*!%!%!%!%!%X$X$!%!%!%!%!%4*X$Q%Q%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%i*r%j*X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%X$X$X$6*@&@&@&@&X$k*P%A%P%P%A%A%A%P%P%P%A%]*P%A%]*]*A%A%A%]*P%A%]*]*A%]*A%A%A%P%A%A%]*A%P%A%A%A%A%P%A%A%P%]*P%A%A%P%P%A%P%P%]*P%P%P%A%P%]*A%A%A%]*]*P%]*P%A%A%A%P%P%P%P%]*P%P%P%A%A%A%]*P%A%P%P%P%",
"P%P%A%]*A%P%A%A%P%]*A%A%P%A%P%A%A%]*A%A%A%P%P%P%A%A%P%A%A%A%A%A%P%A%A%P%P%P%]*P%P%A%]*P%]*A%]*A%P%]*X$X$:%[%X$l*!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%m*X$Q%Q%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%n*d*1%/*X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%X$X$6*6*@&@&@&X$X$o*]*]*P%P%P%P%]*A%]*P%A%]*P%A%A%P%P%P%A%A%P%A%A%P%A%]*P%P%A%P%A%A%P%]*A%P%P%P%P%]*P%]*A%A%P%]*]*]*]*A%]*A%]*A%A%A%A%A%]*A%]*A%A%A%A%A%P%P%P%P%]*]*]*A%A%P%A%P%A%A%A%P%P%]*P%]*P%",
"]*A%P%P%]*]*P%P%P%A%P%]*]*P%]*]*]*A%P%P%P%]*]*]*P%P%P%]*P%P%]*P%P%P%]*P%P%]*A%]*A%P%A%]*A%P%A%P%P%P%X$X$:%X$!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%/*p*Q%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%d*r*m*X$[%[%[%[%[%!%!%!%!%!%!%!%X$X$6*6*6*@&@&@&X$X$s*P%A%A%]*A%P%A%P%A%A%P%A%]*P%P%P%A%]*P%]*P%P%A%]*]*P%A%]*P%P%P%P%A%A%P%A%A%P%]*P%]*A%P%]*]*P%A%A%P%]*A%P%A%]*P%P%P%P%P%P%A%P%P%]*P%P%]*]*P%A%A%A%A%P%]*]*P%]*P%P%P%]*A%A%A%A%]*",
"]*]*A%P%A%A%]*]*P%P%A%A%P%A%P%P%P%]*]*P%A%A%A%A%P%A%P%P%P%P%A%]*A%P%P%]*A%P%P%]*P%P%A%P%P%P%]*A%A%P%X$X$X$X$!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%X$t*6%R%R%R%R%!%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%u*[%[%[%X$X$!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%v*7*X$[%[%[%[%!%!%!%!%!%X$X$X$6*6*6*@&@&@&X$X$,*]*]*A%]*]*P%]*P%]*P%P%P%P%A%]*]*A%A%P%]*A%]*A%A%P%]*A%P%A%]*P%]*P%]*]*]*A%A%P%P%P%A%A%A%A%P%P%A%P%P%P%P%P%P%]*]*A%A%]*P%P%A%P%P%]*A%A%]*]*P%P%P%]*P%A%]*A%]*]*]*A%]*P%]*P%A%P%",
"P%A%P%A%]*]*A%A%A%]*P%]*]*]*]*P%P%A%A%]*P%]*P%]*]*]*A%]*]*A%]*A%]*P%]*A%P%]*A%P%]*]*P%]*A%P%P%]*]*]*A%X$X$!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%X$w*6%R%R%R%R%!%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%x*y*[%[%[%X$X$!%!%**:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z*A*B*X$[%[%[%!%!%!%!%X$X$X$C*6*6*6*@&@&@&X$X$]*A%P%]*P%A%]*P%P%P%]*]*A%A%]*A%P%P%]*]*A%]*P%]*P%]*P%P%]*]*P%A%P%]*A%P%P%]*P%]*A%P%]*]*P%]*P%]*P%P%P%]*P%]*]*P%P%]*]*A%P%]*]*]*]*A%P%]*A%P%]*]*]*A%P%P%A%P%P%A%A%P%P%]*P%]*P%]*",
"]*]*]*P%P%]*P%]*A%]*P%A%P%A%]*]*]*P%A%]*P%]*P%A%P%]*A%A%P%P%P%P%]*A%]*]*A%]*P%A%P%]*A%]*]*]*P%P%P%]*A%X$X$!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%X$D*6%R%R%R%R%R%!%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%E*F*G*[%[%[%X$[%!%!%0%H*[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%I*X$X$!%!%!%!%X$X$X$C*C*6*6*6*@&@&@&X$X$X$X$X$X$P%A%]*]*P%A%A%]*]*P%]*]*]*P%A%]*P%A%A%]*A%]*]*A%P%A%]*P%A%P%P%P%P%]*A%]*]*P%P%]*P%]*A%]*]*]*A%]*A%A%]*A%P%P%]*]*A%P%A%A%]*]*P%P%P%P%P%A%P%]*]*]*]*]*]*]*]*P%A%P%A%]*A%P%",
"P%P%P%]*]*P%]*P%P%P%]*]*P%P%A%A%P%]*]*P%]*A%]*P%]*P%]*]*]*]*]*]*A%P%P%A%P%P%]*]*]*P%P%P%A%A%]*]*A%P%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%J*X$w*6%R%R%R%Q%X$R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%x*[%G*[%[%[%K*X$!%!%!%X$L*:%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%!%R%!%!%!%!%!%X$X$X$X$X$X$X$M*C*C*6*6*6*@&@&@&X$X$X$X$X$X$X$N*A%A%]*]*]*P%P%P%P%A%A%]*P%A%]*]*]*A%]*A%A%]*P%]*P%]*P%]*]*]*]*P%]*P%A%]*]*A%]*A%]*P%A%A%]*A%]*P%A%P%]*A%P%P%P%]*]*P%P%P%]*]*]*]*]*P%]*A%P%P%P%A%P%P%P%]*]*]*P%P%]*]*",
"]*]*A%P%]*P%]*]*]*A%P%]*]*P%]*]*P%P%]*A%]*P%]*P%]*P%P%P%P%P%P%]*]*]*]*]*]*A%P%A%]*]*]*]*]*P%A%]*]*P%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$O*!%R%!%R%P*X$R%R%R%R%R%!%!%!%!%R%R%R%!%!%!%!%Q*[%[%[%[%R*X$X$!%!%!%X$S*:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%!%!%R%!%R%R%R%!%X$X$X$X$X$M*M*C*C*6*6*6*@&@&X$X${%X$X$!%X$X$X$T*A%P%P%]*P%]*P%]*]*P%]*]*A%P%P%]*P%]*]*P%]*P%]*A%]*P%A%A%A%]*P%]*]*P%P%]*A%]*P%]*]*]*P%]*P%]*]*]*A%]*]*]*]*A%P%]*A%]*A%A%A%A%A%]*P%]*]*]*]*]*]*]*]*A%P%A%]*]*P%A%P%",
"A%P%]*]*P%]*P%A%P%]*]*A%P%]*]*P%]*]*]*]*P%]*P%]*P%]*]*]*]*]*]*P%A%P%P%P%P%]*]*]*A%P%P%]*P%]*]*]*X$U*X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$V*!%!%!%:%X$R%R%R%R%R%R%!%!%!%R%R%R%!%!%!%!%y*[%[%[%[%W*X$X$!%!%!%!%X$X*:%[%!%!%!%!%!%!%!%R%R%R%!%!%!%!%!%!%!%R%R%R%R%!%!%R%R%R%R%X$X$M*M*M*C*C*6*6*@&@&@&X$X$Y*Z*x*`*!%X$X$X$X$X$]*P%]*P%]*P%P%]*]*P%]*]*]*P%]*P%P%]*A%]*P%]*P%]*]*]*]*P%]*P%P%]*]*P%]*P%]*A%P%P%]*P%]*P%P%P%]*]*P%P%P%]*]*P%]*A%]*]*]*]*]*P%]*P%A%A%A%P%P%P%A%]*]*]*]*]*]*]*]*",
"]*P%P%]*P%]*]*]*P%P%]*]*P%A%]*P%P%A%P%]*A%]*]*]*P%]*P%A%]*]*]*]*]*]*]*]*]*P%P%]*]*]*A%]*P%P%P%]*X$X$X$!%!%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!% =X$.=!%!%[%:%X$R%R%R%R%R%R%!%R%R%R%Q%Q%!%!%!%+=[%[%[%[%@=X$X$!%!%!%!%!%X$X$#=:%!%!%!%!%!%!%!%!%R%R%R%R%!%!%!%!%!%!%R%R%R%!%!%R%R%R%R%R%X$X$M*M*C*6*6*6*@&@&@&X$X$[%$=%=`*x*!%`*X$X$X$X$X$X$]*]*]*P%P%]*P%P%P%]*A%]*]*]*]*P%]*]*]*]*P%P%P%]*P%]*]*]*A%]*]*]*P%]*]*]*P%]*P%]*]*]*P%P%]*]*]*P%P%]*]*]*P%]*P%P%P%]*]*]*]*]*]*]*]*]*]*P%P%P%A%A%]*P%P%P%",
"]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*A%]*]*P%]*]*A%A%]*]*P%]*]*]*P%]*]*]*]*P%]*]*]*]*]*P%X$f*6%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%&=X$*=[%!%==X$R%R%R%R%R%R%R%R%R%R%R%Q%-=X$!%F*G*[%[%[%;=/*X$!%!%!%!%!%!%!%X$>=:%[%!%!%!%!%!%!%!%R%R%R%R%!%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%R%X$X$X$C*6*6*6*@&@&@&X$X$[%[%,=x*`*'=!%`*)=X$X$X$X$X$P%]*]*]*]*]*]*]*]*]*P%]*A%]*]*]*P%]*A%]*]*]*P%]*]*]*A%]*]*P%P%]*]*]*P%]*]*X$X$X$X$X$X$X$X$X$X$X$X$!=~=T*P%]*]*]*]*A%P%P%P%]*P%P%P%]*]*]*]*]*]*A%]*]*]*",
"]*]*]*P%P%]*P%]*]*P%P%]*P%P%]*P%]*]*]*]*]*]*P%]*]*]*]*]*]*P%]*]*P%P%P%]*]*]*P%A%]*]*]*]*P%]*]*]*X${=6%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*G*X$]=[%[%^=X$R%R%R%R%R%R%R%R%R%R%Q%Q%X$/=(=_=[%[%[%:=X$X$!%!%!%!%!%!%!%!%X$<=:%[%[%!%!%!%!%!%!%!%!%R%R%R%!%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%!%!%X$X$6*6*6*@&@&@&X$[%[%[%[%[%[=!%}=`*!%!%X$X$X$X$X$]*]*P%]*]*]*P%]*]*]*]*P%]*P%]*P%]*]*P%]*]*P%P%P%]*]*P%]*]*]*P%P%]*]*X$X$X$X$X$X$X$X$6%6%6%6%6%X$X$X$X$|=1=]*A%]*]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*P%",
"]*A%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*P%]*P%]*P%]*]*]*]*]*]*P%]*]*]*]*A%]*]*P%]*]*X$`&R%R%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*Q*[%X$2=[%:%X$Q%R%R%Q%R%R%R%R%R%R%R%Q%X$3=4=G*[%[%[%[%X$X$[%!%!%!%!%!%!%!%!%X$X$:%:%[%!%!%!%!%!%!%!%!%R%R%R%R%!%!%R%!%!%R%R%R%R%R%R%R%R%R%R%R%!%6*X$X$6*@&@&@&@&X$[%[%[%[%[%G*+=`*5=`*!%!%!%X$X$X$X$P%]*]*]*A%]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%X$X$X$X$X$X$!%!%!%!%!%!%!%!%6%6%6%X$X$6=X$X$X$7=8=]*]*]*]*]*]*]*P%P%P%]*P%]*P%]*P%]*P%]*",
"]*]*]*]*P%]*A%A%]*]*P%]*]*]*]*P%]*]*]*A%]*]*]*]*A%]*]*]*]*]*]*]*]*]*]*P%]*]*]*A%]*]*A%]*]*]*P%X$X$9=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%&=[%:%X$0=[%:%X$a=R%R%Q%!%R%R%R%R%R%Q%b=X$c=[%[%[%[%[%0%X$!%!%!%!%d=e=f=g=0%X$X$X$h=:%[%[%!%R%R%!%!%!%!%!%R%R%R%R%!%!%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%X$X$X$@&@&@&X$X$[%[%[%[%[%[%[%i=5=Z*!%!%!%!%!%X$X$X$X$X$]*]*P%]*]*P%]*P%]*]*]*]*]*]*A%]*]*]*]*j=k=l=m=X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%{&6%X$X$X$X$n=]*P%]*]*]*]*]*]*P%]*P%]*]*]*A%]*]*]*",
"]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*A%]*]*]*]*]*]*]*]*]*P%o=]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*X$X$p=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%q=[%:%:%X$r=[%:%X$R%!%R%6%X$R%R%R%R%R%Q%s=X$[%[%[%[%[%X$X$!%!%!%t=u=X$X$X$X$X$X$X$0%v=:%:%[%[%R%R%R%!%R%!%R%!%R%R%R%R%R%!%R%R%R%R%R%R%R%R%R%R%R%!%R%!%!%X$X$X$@&@&X$X$[%[%[%[%[%[%[%G*+=[=`*!%!%!%!%!%!%X$X$X$X$X$X$X$w=x=y=o=y=y=y=]*P%]*o=z=A=B=C=D=X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6=X$X$X$X$E=]*]*P%P%]*]*]*]*]*]*]*]*]*]*]*]*P%",
"]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*]*P%]*]*]*]*o=]*]*]*]*]*]*o=]*]*]*]*]*X$0%Q%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%G*[%:%X$[%X$[%[%X$!%!%6%6%X$!%R%R%R%R%Q%F=X$[%[%[%[%X$X$!%!%G=H=X$X$X$X$X$u=I=X$X$X$X$J=:%:%[%!%R%R%R%!%R%R%R%!%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%K=L=!%!%!%!%!%!%!%!%`*5=X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$T*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*",
"]*]*]*]*]*]*o=]*]*]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*M=P%]*]*P%P%]*]*]*]*]*]*P%P%]*]*]*]*X$N=6%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%[%[%:%:%X$[%Z&O=:%X$!%!%6%6%X$!%R%R%!%6%6%X$[%[%[%[%X$X$X$!%P=Q=X$X$X$!%X$;*R=6=X$!%!%X$X$S=T=:%[%!%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%G*+=!%!%!%!%!%`*!%!%!%Z*`*!%!%!%X$D&6=f*/*X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$U=]*]*]*]*]*]*]*]*]*]*o=]*]*]*]*",
"]*]*]*]*o=P%]*]*]*]*]*]*]*]*o=]*]*]*]*]*]*]*]*]*]*]*]*]*]*o=]*]*o=]*o=P%]*]*]*]*]*]*]*]*]*o=]*X$V=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%Q*[%[%:%:%X$[%Z&W=:%X$!%!%6%6%X$!%R%!%!%6%X=X$[%[%[%[%X$X$!%|%'&X$X$|%!%!%X$!%Z%X$!%Y=l&|%X$Z=`=:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%R%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%3*)=`*!%!%!%!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$X$T*]*]*]*]*]*]*]*]*]*]*]*]*]*]*",
"o=]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*]*]*o=]*M=o=]*]*]*]*]*P%]*P%]*o=M=]*]*]*M=]*o=o=P%X$X$ -R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$[%X$.-:%X$!%!%6%6%X$!%R%!%6%6%X$[%[%[%[%X$X$!%!%+-@-X$X$5&!%!%!%!%!%!%!%!%!%!%!%X$#-$-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%R%R%R%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%5=Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$T*o=]*]*]*o=]*o=]*]*]*]*]*]*]*",
"]*M=]*]*]*o=P%o=]*M=M=o=]*M=]*M=o=]*]*]*o=]*P%]*]*P%]*]*]*]*]*M=]*]*]*]*P%o=]*M=]*]*P%P%]*]*X$X$%-R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%[%[%[%:%:%X$[%[%X$&-*-X$!%!%6%6%X$!%!%!%6%=---[%[%[%X$X$X$!%h*X$X$!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$ *;-:%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%'=`*`*!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$]*]*]*]*]*P%]*]*]*o=]*o=o=P%",
"o=]*]*M=]*]*o=]*]*o=P%P%]*]*M=]*]*o=]*M=]*M=M=]*]*M=]*]*]*]*]*P%o=]*M=]*o=P%]*]*]*]*M=M=]*]*X$>-R%R%R%R%R%R%R%!%!%!%R%!%!%!%!%[%[%[%:%:%X$X$X$X$X$,-'-X$!%!%6%6%X$!%!%!%)-!-~-[%X$X$X$X$!%!%]&X$!%!%X$!%!%!%!%!%!%X$X$X$X$X$!%!%!%X${-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%x*Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$M=]*]*]*M=]*]*]*P%o=P%P%o=",
"]*o=]*o=]*]*]*o=]*o=M=o=]*o=P%]*]*]*]*]*]*o=]*o=]*]*]*]*o=]*M=P%M=o=]*]*M=o=o=o=]*]*]*M=]*X$]-^-R%R%R%R%R%R%R%!%R%R%R%!%!%/-G*[%[%:%:%X$X$X$X$X$X$(-v&X$!%!%!%6%X$!%!%!%)-==_-[%X$n&D&!%l*:-X$X$!%!%!%!%!%!%X$X$X$X$X$[%X$X$X$X$X$X$<-[-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%}-5=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%@-X$X$X$]*M=]*]*]*]*]*]*]*M=]*]*",
"o=]*o=]*]*]*]*]*]*]*]*]*]*P%o=o=]*M=]*]*o=]*o=]*]*o=]*o=]*M=]*M=]*]*]*]*]*]*]*]*]*o=]*o=]*X$|-R%R%R%R%R%R%R%R%R%R%R%R%R%[%[%[%[%[%:%X$X$[%[%[%[%X$1-2-X$!%!%!%6%X$!%!%!%3-4-[%[%X$5-!%!%6-1%!%P=!%!%!%!%X$7-8-9-[%[%[%[%[%[%[%0-a-X$X$X$b-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%c-)=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%d-f*X$X$X$]*]*o=]*]*]*]*]*]*]*]*",
"]*]*]*]*]*o=]*]*]*o=]*]*M=]*]*]*o=o=o=P%]*]*]*]*]*o=]*]*o=]*]*o=]*]*]*o=]*]*]*o=]*]*]*o=]*X$Q%R%R%R%R%R%R%R%!%R%R%R%R%[%[%[%[%[%:%X$X$[%[%[%[%[%[%0%e-X$[%!%!%6%X$!%!%q=:%f-[%X$g-h-!%!%V*I=!%!%!%!%!%X$i-j-[%[%[%k-l-m-n-9-J*[%[%o-X$X$X$p-:%[%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%y*L=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%R&<*q-X$]*]*o=o=M=]*o=o=]*o=]*",
"]*]*]*o=M=]*]*o=M=]*]*o=o=]*]*M=]*P%]*M=]*]*]*]*]*]*]*]*]*]*]*]*]*M=o=P%o=o=o=]*]*]*]*]*X$X$R%R%!%R%R%R%R%R%!%R%R% =[%[%[%[%[%:%:%X$X$[%X$X$X$X$[%[%X$X$X$!%!%6%X$!%!%r-:%X$[%)%P=!%!%!%X$X$!%!%!%!%X$s-t-t-u-X$[-v-w-x-[-X$X$B*y-z-j-A-X$X$B-:%[%R%R%!%R%R%R%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%3*C-`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%{&D-E-X$X$X$]*]*o=o=]*P%o=]*M=",
"o=o=]*o=o=o=]*o=]*o=]*]*o=M=o=]*o=]*]*o=o=o=o=M=]*M=o=]*o=o=]*o=o=]*o=]*P%]*]*]*o=o=]*M=X$F-R%R%!%R%R%R%R%!%R%R%G-H-[%[%[%[%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$[%!%6%X$!%!%:%:%X$[%I-!%!%!%X$X$!%!%!%!%X$I&o-J-r%X$X$X$X$X$X$X$X$X$X$X$X$K-n-L-/*X$M-:%[%[%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%N-X$O-[%[%[%[%[%[%[%[%[%[%[%P-Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%Q-R-S-X$M=]*]*]*M=]*]*o=]*",
"]*]*]*]*]*P%o=]*]*]*]*]*P%o=]*]*]*M=o=]*]*]*]*o=M=o=]*M=]*]*o=]*]*]*]*]*M=]*o=o=]*]*]*X$X$T-R%!%R%R%R%R%R%R%R%U-c-[%[%[%[%:%:%X$X$X$X$[%[%[%[%[%[%X$X$X$X$[%[%6%6%X$!%:%:%[%V-t=!%!%!%X$X$R=!%!%X$5*n-n-W-X$X$X-Y-Y-X-X-X-Z-Z-X-`- ;X$.;[%+;@;X$#;:%:%!%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%$;X$X$[%[%[%[%[%[%[%[%[%[%[%%;Z*Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Q&&;[-X$X$]*]*o=]*]*o=]*o=",
"]*o=]*]*M=]*o=o=M=o=o=o=]*M=o=o=o=]*M=]*o=]*]*o=]*M=o=o=M=]*M=]*o=]*M=]*M=]*]*o=]*o=]*X$[-%-R%!%R%R%R%!%R%R%R%3=[%[%[%[%:%X$X$X$X$[%[%X$X$X$[%[%[%X$X$X$X$[%[%6%6%X$!%:%:%X$*;!%!%!%X$X$!%!%!%!%f*=;o--;X$;;X-X-Y-X-X-X->;,;';';,;,;,;X$);*&!;v=~;:%:%:%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%{;C&X$[%[%[%[%[%[%[%[%[%[%[%];)=[=!%!%!%!%!%X$^;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%/;(;X$X$o=]*o=o=]*o=]*]*",
"o=M=o=o=o=o=]*]*o=]*M=]*o=o=]*]*]*o=o=o=]*o=]*]*o=o=]*]*o=o=o=o=]*o=o=o=o=o=o=]*o=]*o=X$&;R%!%!%!%R%R%!%R%R%G-[%[%[%[%:%X$X$X$X$X$X$X$X$X$X$X$X$X$[%X$X$X$X$[%:%6%X$[%:%:%X$d=!%!%!%X$!%!%!%!%!%_;|%U&]-;;;;Z-Z-Y->;>;>;:;:;<;<;[;[;<;:;X$g-};|;X$1;2;:%:%:%!%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%6%b=3;X$[%[%[%[%[%[%[%[%[%[%[%4;`*5;!%!%!%!%X$X$6;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%`&7;X$X$X$o=]*]*o=]*M=o=",
"o=]*M=]*]*o=o=]*o=o=o=]*]*M=o=o=]*]*M=o=M=o=o=]*]*o=]*]*]*]*M=o=]*]*M=]*]*]*o=M=o=]*]*X$8;R%!%!%!%!%!%!%!%5=9;[%[%[%:%X$X$X$[%X$X$X$X$X$;;Z-Z-Z-X$X$X$X$X$X$:%[%:%X$[%:%:%X$0;!%!%!%!%!%!%!%!%R=!%a;X$X$;;Z-Z-Z-b;>;>;c;d;d;R%R%R%e;f;g;,;X$h;n-9-[%C&B-:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%6%i;X$j;[%[%[%[%[%[%[%[%[%[%(=`*`*!%!%!%!%X$k;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%R&l;X$X$o=o=]*o=o=]*M=",
"]*o=o=o=o=]*M=o=M=]*M=o=o=o=]*]*o=o=o=]*o=M=]*o=o=]*o=o=o=o=o=M=o=o=o=o=o=o=]*o=]*o=o=X$m;!%!%!%!%!%!%!%!%q=[%[%[%:%:%X$X$[%[%X$X$;;;;;;Z-Z-Z-Z-X$X$X$[%[%X$:%:%:%X$[%:%:%X$n;!%!%!%!%!%!%!%!%!%n;o;X$;;;;Z-Z-Z-b;b;p;p;e;R%R%R%R%R%q;e;g;>;X$r;o-9-6%s;[%:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%6%t;X$u;[%[%[%[%[%[%[%[%[%[%4;Z*L=!%!%!%X$X$Z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%`&7;X$X$M=]*o=]*]*o=o=",
"M=]*o=]*o=o=M=o=o=o=M=]*M=o=o=M=]*]*o=]*o=o=]*]*o=M=]*M=M=]*o=M=o=]*M=M=]*o=]*o=M=]*o=X$!%!%!%!%!%!%!%!%Z*3*[%[%:%:%X$X$!%[%X$X$X$;;;;;;Z-Z-Z-Z-Z-X$X$X$v;X$X$X$:%X$[%:%:%X$w;!%!%!%!%!%!%!%!%h-[-;;;;;;;;Z-Z-Z-b;b;p;p;q;R%R%R%R%R%x;q;[;>;X$X$y;J-!%6%z;a-:%:%:%!%!%!%!%!%!%!%!%!%!%!%!%R%!%R%X$!%!%!%!%6%b= *[%[%[%[%[%[%[%[%[%[%[%];F*L=!%!%!%X$A;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%B;R-X$X$]*o=o=]*]*M=",
"o=o=]*o=M=]*o=]*M=]*o=o=o=M=]*o=o=o=M=o=]*]*o=o=M=o=o=o=o=o=]*o=]*o=o=o=o=o=o=M=o=o=M=X$!%!%!%!%!%!%!%!%c-[%[%[%:%:%X$X$!%:%X$X$;;;;;;;;Z-Z-p;p;p;';X$X$v;v;X$X$:%X$[%:%:%X$C;!%!%!%!%!%!%!%_;|&X$;;;;;;;;Z-Z-Z-b;b;p;p;D;R%R%R%R%R%E;q;[;b;Z-X$X$F;!%6%X$K*G;H;:%:%!%!%!%!%!%!%!%!%!%!%!%R%!%R%X$R%!%!%6%!%Q%I;[-[%[%[%[%[%[%[%[%[%[%C-L=E*!%!%X$J;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%^*X$X$o=M=o=o=o=o=",
"M=o=M=o=o=]*o=o=o=]*M=]*o=o=]*M=M=o=M=o=o=M=M=o=]*M=]*]*M=o=]*o=]*]*M=M=]*M=o=]*M=o=X$O&!%!%!%!%!%!%!%!%G*[%[%:%:%X$!%!%!%:%X$X$;;;;;;;;Z-p;g;[;R%R%f;X$X$v;X$X$:%:%X$:%:%X$V%!%!%!%!%!%!%!%0;X$;;;;;;;;;;Z-Z-K;L;M;N;N;O;R%R%R%R%R%P;q;[;Z-Z-Q;X$R;[%6%6%X$X$S;[%:%:%6%!%6%!%!%!%!%!%!%!%R%R%R%X$R%R%!%Q%!%Q%X$X$[%[%[%[%[%[%[%[%[%G*x*C-L=!%X$'&t=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%`&X$X$o=]*M=M=]*M=",
"o=M=o=]*M=o=M=]*M=o=M=o=M=M=o=o=o=]*o=M=M=o=o=o=o=o=o=o=o=M=o=M=o=o=o=o=o=o=M=o=o=]*X$T;!%!%!%!%!%!%!%q*[%[%:%:%X$X$!%!%!%:%X$;;U;V;W;X;Y;Z;`; >R%R%R%f;X$v;v;X$X$:%X$:%[%X$Y=!%!%!%!%!%!%!%V-X$;;;;;;;;;;.>+>@>#>$>R%R%%>%>R%R%R%P;&>*>=>Z-Z-Q;X$X$[%!%6%6%X$X$[%[%:%:%6%!%6%!%!%!%!%!%!%R%R%R%X$R%R%R%Q%Q%Q%X$X$[%[%[%[%[%[%[%[%[%r-%;C-E*`*0%->!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%R&1&X$M=o=o=o=o=o=",
"o=]*o=o=M=o=o=o=M=o=o=o=o=M=]*]*o=M=o=o=]*M=M=o=o=M=o=o=o=o=o=o=o=]*o=M=o=o=M=M=o=]*X$;>!%!%!%!%X$!%!%$=[%[%:%:%X$X$!%!%!%:%X$>>,>R%R%R%'>=>)>!>R%R%R%f;X$X$v;[%X$:%:%X$:%X$w;!%!%!%!%!%!%!%X$X$;;;;~>{>]>^>@>/>(>(>R%R%*>%>%>&>&>&>*>_>=>'>:>;;<>X$X$[%!%!%6%6%X$X$X$[%:%:%6%6%!%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%X$X$[%[%[%[%[%[%[%[%[%$= =x*x*X$[>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%N&X$X$o=o=o=o=o=o=",
"o=o=o=o=o=o=o=o=o=o=M=o=M=o=o=o=o=o=o=o=o=o=o=M=M=o=M=M=o=M=M=o=M=o=M=o=M=o=o=o=o=o=X$6%!%!%!%!%X$!%!%G*[%[%:%X$o=M=!%!%!%6%X$X$,>R%R%R%'>(>)>)>)>R%}>f;f;X$|>[%X$X$:%X$:%X$Y=!%!%!%!%!%!%X$X$;;1>2>3>4>5>6>'>'>'>R%R%R%)>)>)>*>*>)>7>=>(>'>'>R%8>X$X$!%!%!%!%6%6%6%X$X$:%:%:%6%!%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%9>X$[%[%[%[%[%[%[%[%[%c-i=C-`*X$i*|%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Q&X$X$M=M=M=o=]*M=",
"o=o=M=M=M=M=M=o=M=o=o=o=o=o=o=o=o=o=M=o=M=o=0>o=o=o=o=M=o=o=M=o=o=o=o=o=M=o=o=o=o=o=X$6%!%!%!%!%X$!%F*[%[%:%:%X$0>o=!%!%!%6%X$X$R%R%R%R%'>'>_>R%)>)>)>[;[;X$X$[%!%X$X$X$:%{%5&!%!%!%!%!%!%X$X$a>b>c>6>R%R%R%'>'>'>R%R%R%7>7>R%R%_>7>=>=>'>'>'>R%R%X$X$!%!%!%!%!%!%6%6%6%X$X$X$X$X$!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%d>X$[%[%[%[%[%[%[%[%[%e>i=G*X$X$w;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$f>s;X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%[-X$o=o=M=0>o=o=",
"0>0>o=o=o=0>o=o=o=0>M=o=M=o=o=M=M=M=o=0>o=o=o=o=0>o=o=o=o=o=o=o=0>o=o=o=o=M=o=M=0>o=X$Q%R%!%!%X$!%!%g>[%:%:%X$o=o=o=!%!%!%6%X$X$R%R%R%R%R%'>R%R%_>)>)>)>g;X$X$!%!%!%X$X$X$ *!%!%!%!%!%!%!%X$h>i>R%R%R%R%R%R%'>'>'>'>'>=>=>=>R%R%=>(>(>'>'>'>R%R%R%X$X$!%!%!%!%!%!%!%6%X$X$X$X$X$6%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%u-X$[%[%[%[%[%[%[%[%[%e>i=[%X$5*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$O-[%j>k>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%l>X$o=M=o=o=o=M=",
"]*o=0>o=o=o=M=0>o=o=0>o=M=0>0>o=o=0>M=o=M=o=o=M=o=M=o=o=o=o=o=M=o=M=o=o=0>M=o=M=M=o=X$Q%R%R%!%X$!%!%Q*[%[%m>X$o=o=M=!%!%!%!%:%X$R%R%R%R%R%'>'>(>(>_>R%7>7>X$X$!%!%!%X$X$X$X$|%!%!%!%!%!%!%X$R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>'>'>'>'>R%R%R%X$X$!%!%!%!%!%!%!%X$X$X$!%X$X$!%6%!%!%!%!%R%R%R%X$R%R%Q%Q%Q%[%X$[%[%[%[%[%[%[%[%[%c-q*g>X$n>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%L-l-o>l>X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%p>X$q>o=o=o=o=o=",
"0>o=o=M=o=o=o=o=M=o=M=o=0>M=o=0>o=o=o=M=o=M=M=o=0>0>o=0>o=0>0>o=M=0>o=o=o=o=0>o=o=0>X$Q%R%R%R%X$!%!%[%[%:%v=X$M=M=o=o=!%!%!%6%X$X$R%R%R%R%R%'>'>'>'>'>(>(>X$X$!%!%!%!%X$X$X$r>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>'>R%R%R%R%R%X$X$!%!%!%!%!%!%X$X$!%!%X$X$!%R%R%Q%!%R%R%R%R%R%X$Q%Q%Q%Q%6%s>X$[%[%[%[%[%[%[%[%[%y*4;X$X$t>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%u>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%<*X$v>o=M=M=0>M=",
"0>M=0>M=0>0>o=o=0>o=o=o=o=o=o=o=o=o=0>o=o=0>o=M=o=o=o=0>o=M=o=o=o=M=0>o=0>o=o=0>o=o=X$Q%R%R%R%X$!%!%[%[%B-X$o=0>X$X$o=!%!%!%6%X$X$R%R%R%R%R%R%'>'>'>'>(>(>X$X$!%!%!%!%!%X$X$w>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>R%R%R%R%X$X$X$!%!%!%!%!%!%X$X$!%X$X$X$X$X$X$Q%!%R%R%R%R%!%X$Q%6%6%6%Q%[%X$[%[%[%[%[%[%[%[%[%[%[%X$X$Z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$X$[%[%[%[%[%[%[%x>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Z&X$y>o=o=o=0>o=",
"M=o=o=o=o=o=o=o=M=o=0>o=o=o=o=0>o=o=o=o=0>o=o=o=o=M=o=M=o=o=o=0>o=0>o=o=o=o=o=o=o=0>X$Q%R%R%R%X$!%!%[%[%z>X$0>X$X$X$X$X$!%!%6%6%X$X$R%R%R%R%R%R%R%R%'>'>(>X$X$!%!%!%!%!%!%!%A>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>B>R%R%R%R%R%X$X$X$X$!%!%!%!%!%!%X$!%!%X$!%6%X$X$X$R%Q%R%R%R%!%!%X$Q%6%6%6%:%s-X$[%[%[%[%[%[%[%[%X$[%y*X$I=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%C;C>X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6=X$D>o=0>o=o=M=",
"0>o=0>o=o=o=0>o=o=o=o=0>0>o=o=o=0>o=0>o=o=0>o=o=0>M=o=o=o=0>o=o=o=o=o=o=0>0>o=0>o=o=X$E>R%R%R%X$R%R%[%[%F>X$o=0>X$X$X$X$X$!%!%6%6%X$R%R%R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%G>R%R%R%R%R%R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$[%R%Q%X$R%R%6%6%X$Q%6%6%6%:%H>X$[%[%[%[%[%[%[%[%X$X$ =X$I>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%0;X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$y>o=o=o=0>o=",
"o=0>o=o=0>0>o=o=0>o=0>M=M=0>o=0>o=o=o=o=0>o=0>0>o=0>o=0>0>o=o=0>o=0>0>0>M=o=o=o=o=o=X$D*R%R%R%X$R%!%[%J>X$K>0>o=0>D>X$X$!%!%!%!%6%X$X$R%R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$:%:%Q%X$Q%Q%6%6%X$Q%Q%6%Q%:%L>X$[%[%[%[%[%[%[%[%X$X$X$X$6-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%->M>X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=M=0>0>o=0>",
"o=0>0>o=o=o=o=o=0>o=o=o=o=0>M=o=0>0>0>o=0>o=o=0>o=0>M=M=0>0>o=0>o=o=o=o=0>0>o=0>0>0>X$C&!%!%R%X$R%!%[%u;X$o=0>X$X$X$X$X$!%!%!%!%!%6%X$X$R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%v=X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%6%Q%X$Q%6%6%X$Q%Q%Q%6%:% *[%[%[%[%[%[%[%[%[%X$X$X$X$=;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$0>o=o=0>M=0>",
"o=o=M=o=0>0>0>0>o=o=0>0>0>o=0>0>o=M=o=o=o=o=o=o=0>o=0>0>M=o=0>o=o=0>o=0>o=o=0>o=o=o=X$X$|%!%!%X$!%!%[%N>X$0>X$X$!%!%!%X$!%!%!%!%!%!%6%!%R%R%R%R%R%R%R%R%R%Q%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%8>R%X$X$!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%X$X$X$!%X$:%R%Q%X$Q%6%6%X$Q%Q%6%6%:%X$[%[%[%[%[%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*O>X$X$[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=0>0>o=P>M=",
"0>0>0>M=o=o=o=0>0>o=o=M=0>o=o=0>0>0>0>o=0>0>0>o=P>o=o=0>0>o=0>0>o=0>o=0>0>o=0>0>0>0>o=X$P=!%!%X$!%!%[%Q>X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%R%R%R%R%X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%X$X$!%!%!%!%!%!%!%!%b&'&R>7*X$!%!%!%!%X$X$D&-*X$X$X$[%Q%X$R%6%6%X$6%6%6%6%S>X$[%[%[%[%[%[%[%[%X$X$X$X$[-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=o=o=o=0>o=",
"o=o=M=P>0>0>0>o=o=P>0>0>o=0>0>o=o=o=0>0>0>o=o=o=o=o=o=0>o=0>o=o=0>o=0>o=0>0>o=o=o=o=0>X$K&!%!%X$!%!%[%T>X$X$[%[%[%[%[%!%!%!%X$!%!%!%!%!%!%!%!%R%R%R%R%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%%-U>X$X$X$X$V>!%!%!%!%!%!%!%!%!%!%!%9*W>X$!%!%!%!%!%X>0-!%Y>X$X$:%6%6%X$6%6%X$6%6%6%6%Z>X$[%[%[%[%[%[%[%[%X$u=`>X$7*!%|%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6% ,X$0>0>0>0>o=0>",
"0>0>o=o=0>o=0>0>o=o=o=0>0>o=0>P>0>o=o=o=0>0>P>0>0>0>o=0>0>0>0>o=0>P>o=o=0>0>0>0>0>0>0>.,0%!%!%X$!%r-[%:%X$X$X$X$X$!%[%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%+,6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%!%!%!%!%!%!%!%@,#,$,%,&,*,V>V>=,!%!%!%!%!%!%!%!%!%!%!%!%!%!%f>X$X$[%!%!%!%X$!%[%r;-,;,X$X$[%6%6%X$6%6%6%X$6%6%:%>,X$[%[%[%[%[%[%[%[%X$,,!%X$z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6% ,X$o=o=o=0>0>0>",
"o=o=0>0>o=0>o=o=0>0>P>o=o=0>o=o=o=o=P>P>o=o=o=o=o=P>0>0>o=o=0>0>o=o=0>0>o=o=o=0>0>o=0>.,.,',!%**X$r-[%:%X$X$X$X$X$[%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%X$),6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%!%!%R%R%!%R%R%!%!%!%!%!%!%r%X$X$!%!%!%0%X$!%n&!,~,H=[%[%:%6%X$6%6%6%X$6%6%:%Y>X$[%[%[%[%[%[%[%X$7-V%!%!%u=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%4;X$X$[%[%[%[%[%3*c-!%!%!%3*[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$0>P>0>o=o=o=",
"P>o=0>P>o=0>0>o=o=o=0>0>o=0>0>0>P>o=o=P>0>0>0>0>o=o=o=0>0>o=o=0>0>0>o=0>0>0>o=o=0>o=o=0>{,G&[%[%X$y*[%:%],],],],],],],],],],],X$!%!%!%!%!%!%!%!%!%@-^,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%],],],],],],],],],],],],!%!%!%!%!%X$X$!%!%!%!%X$X$!%/,(,>-[%[%:%6%X$6%6%6%X$6%:%_,X$[%[%[%[%[%[%[%[%X$:,5&!%!%<,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$[%[%[%[%G*!%!%!%!%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[,X$X$o=0>P>P>0>0>",
"o=0>o=o=P>0>o=0>P>0>P>o=P>0>0>o=o=0>0>o=0>o=o=P>0>P>P>0>o=P>0>P>0>o=0>o=0>0>0>0>o=0>P>o=},[-|,[%0%],],],X$o=0>X$[%[%X$!%!%!%X$],],],!%!%!%!%!%!%!%D-1,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%!%!%!%R%],],],],],],R%R%R%R%R%R%!%!%!%!%!%R%],],],B*!%X$[%!%!%!%!%!%X$!%2,3,I=X$[%[%:%X$:%6%X$6%6%:%[%X$[%[%[%[%[%[%[%[%X$4,!%!%!%d*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%5,X$X$[%[%[%[%6,!%!%!%!%!%!%!%!%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%m;X$X$0>o=o=o=o=o=",
"0>P>0>o=o=P>P>o=o=o=P>o=0>o=P>0>0>o=0>o=P>0>o=o=o=o=o=P>o=o=o=o=P>P>P>0>o=P>0>P>o=o=o=o={,X$d-],],Y*[%:%X$0>P>X$[%X$X$[%!%!%X$X$X$!%],],!%!%!%X$V*7,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%!%],],],!%R%R%R%R%R%R%!%R%R%!%R%!%!%!%!%!%!%R%!%!%],],],[%!%!%!%!%J*X$X$H=m-8,X$[%[%:%X$:%6%X$6%:%:%Y>X$[%[%[%[%[%[%[%[%0%Y=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%$=!%!%!%!%!%!%!%!%!%!%n>X$0%a*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%9,X$X$P>0>0>0>P>0>",
"0>o=0>0>P>o=o=0>P>0>o=0>P>P>o=P>o=0>0>P>o=P>0>0>0>0>P>o=0>P>0>P>o=o=o=o=P>o=P>o=P>0>P>0>0>],],#=q=X$[%:%X$o=o=X$X$X$X$[%!%!%!%!%X$X$!%!%],!%X$X$v&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%],],!%!%!%!%!%!%R%R%!%R%!%!%R%!%!%!%!%!%!%!%!%!%!%X$!%X$X$],],],X$!%!%X$X$.;9-V*X$X$[%:%X$:%6%X$6%:%0,X$X$[%[%[%[%[%[%[%[%I*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%G*`*!%!%!%!%!%!%!%!%!%!%a,X$b,c,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%B;X$X$o=0>0>P>o=o=",
"0>o=0>0>0>0>P>o=P>0>0>o=o=0>o=P>P>o=o=0>o=P>o=P>0>o=0>0>o=P>o=P>0>0>P>o=0>o=P>o=0>o=P>0>],o=X$#;d,e,[%:%f,P>P>X$X$X$X$[%!%!%!%!%X$X$!%!%!%],],g,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%],!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%X$[%!%!%X$],],],X$X$[%h,0%X$X$[%[%:%X$6%X$[%:%W*X$[%[%[%[%[%[%[%[%X$A-l&!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%P=X$i,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%D*X$X$o=o=o=0>P>0>",
"P>P>P>o=P>P>o=0>o=P>P>j,0>P>j,o=0>P>j,0>0>o=P>o=o=0>P>P>0>0>0>o=0>P>0>0>0>0>0>0>o=j,0>],P>P>},k,l,m,[%:%n,X$o=],],],],],],],],],],],],!%],X$(-6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%],!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$[%!%!%X$X$!%X$],],],[%X$X$X$[%[%:%X$6%X$[%[%n&X$[%[%[%[%[%[%[%[%X$s;$;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%o,!%!%!%!%!%!%!%!%!%!%!%!%6-X$g=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%p,X$P>P>P>P>P>0>0>",
"0>0>P>o=o=j,0>0>o=o=P>o=0>o=j,0>0>P>P>0>j,0>P>P>P>o=o=0>0>P>0>P>o=0>P>P>o=0>P>P>P>o=],0>0>0>j,X$q,9-[%:%r,],],P>o=P>X$[%[%!%!%!%!%!%!%],],X$s,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$[%X$X$[%!%!%6%X$X$X$X$X$[%[%],],X$X$[%[%:%X$:%X$[%[%X$X$[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%U&t,X$l*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%u,X$X$0>0>0>o=0>P>0>",
"0>0>0>j,0>P>P>P>P>0>o=P>P>P>o=P>0>o=o=P>o=P>0>0>0>j,j,P>o=o=P>0>0>P>o=o=P>P>0>o=0>],0>0>o=0>P>0>O*[%v,],],X$P>0>0>0>X$X$[%[%],],],],],],],O*6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%>*X$X$X$X$!%!%!%!%!%!%!%X$X$[%!%!%!%!%6%X$X$X$[%[%[%[%[%X$],X$[%[%X$:%:%X$[%X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%U&/*X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%w,X$X$P>0>0>P>o=0>0>",
"P>o=P>P>o=o=0>0>P>P>0>o=0>P>0>o=P>P>0>P>0>0>P>o=P>P>o=P>j,0>0>P>o=P>P>0>0>o=P>P>o=P>o=P>P>o=o=P>X$x,],0%y,X$P>P>o=P>P>],],],!%!%!%!%!%X$X$k,6%!%!%!%[%X$X$z,!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%],],],],],],],],!%@-X$X$X$X$6%6%!%!%!%!%!%!%[%X$X$!%!%!%!%!%A,B,X$X$[%[%[%[%[%[%X$[%],],[%X$:%X$[%[%X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%C,X$X$P>o=P>P>P>o=0>",
"0>P>o=0>P>P>0>P>0>0>o=P>P>o=P>P>0>o=P>o=P>o=P>P>0>o=P>P>P>o=P>0>P>o=P>o=P>P>P>0>P>o=P>P>0>P>P>0>],],:%@;:%R*o=0>P>],],X$X$[%[%!%!%!%!%!%X$6%6%!%!%!%[%[%X$X$!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%],],!%!%!%!%!% ,X$],],],X$6%6%6%!%!%!%!%!%!%[%X$!%!%!%!%!%6%6%D,7*X$[%[%[%[%[%X$X$X$[%[%X$],X$:%X$[%X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=o=P>0>o=0>P>P>",
"0>P>P>0>0>P>o=P>P>P>P>o=P>0>0>P>P>0>P>P>P>o=o=P>P>0>o=o=P>P>o=P>P>0>P>P>o=0>P>0>P>0>o=o=0>0>P>],0>X$:%E,F,G,P>0>],P>o=0>X$[%[%!%!%!%!%!%X$H,6%!%!%!%!%[%[%X$X$X$!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%D&X$X$6%],],6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%(;X$X$[%[%[%[%[%X$X$[%[%[%X$[%],[%X$[%X$[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%I,X$X$P>0>P>P>P>o=0>0>",
"P>0>0>P>P>0>P>0>0>0>0>P>0>P>0>0>0>P>0>0>0>P>P>0>0>P>P>P>0>0>P>0>0>P>0>0>P>P>0>P>0>P>P>P>P>P>0>0>P>X$X$*=[%X$],],0>0>P>P>X$X$[%[%[%!%!%!%X$J,6%!%!%!%!%!%!%[%[%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%K,X$6%6%6%!%],],!%!%!%!%!%!%!%!%!%!%!%!%6%6%-*X$X$[%[%[%[%[%[%X$X$[%[%[%X$[%X$],],X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$L,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%.-v=X$X$0>P>0>o=0>P>P>P>",
"P>P>0>0>P>0>P>P>P>P>0>P>0>P>P>P>o=P>0>P>0>0>P>P>o=0>0>P>P>0>0>P>0>P>o=P>0>P>o=P>o=j,0>0>0>P>P>0>0>P>X$X$X$],X$P>o=0>0>0>P>X$X$[%[%[%[%!%[%z;;>6%!%!%!%!%!%!%[%[%X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6=X$6%6%!%!%!%!%],],!%!%!%!%!%!%!%!%!%6%6%8*X$X$X$[%[%[%[%[%X$X$[%[%[%[%X$[%X$X$:%],],[%[%[%[%[%[%[%[%[%[%[%X$X$6;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%M,X$X$P>0>P>P>P>0>0>0>P>",
"0>0>P>o=P>P>0>o=P>o=P>P>P>P>o=P>P>P>P>0>P>P>P>0>P>P>P>P>0>P>P>0>P>0>P>0>P>0>P>0>P>P>P>P>P>0>o=P>P>0>P>X$],X$X$P>P>P>P>P>0>P>X$X$[%[%[%[%[%X$B,6%!%!%!%!%!%!%!%[%X$:%:%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%{=X$X$6%!%!%!%!%!%!%!%],],!%!%!%!%!%6%6%!%[>X$X$[%[%[%[%[%[%[%X$[%[%[%[%[%X$[%X$X$X$:%[%],[%[%[%H;[%[%[%[%[%[%[%X$h*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%)=!%!%!%!%!%!%!%!%!%!%!%!%!%N,O,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[,P,X$0>P>P>0>P>P>P>P>P>0>",
"P>P>P>0>0>P>P>0>P>0>0>P>o=P>0>P>o=0>P>0>P>o=P>P>P>P>0>P>P>P>P>0>P>P>P>o=P>P>P>P>P>0>P>P>o=P>0>0>P>P>0>],0>X$X$X$P>o=0>P>P>o=0>X$X$[%[%[%[%[%X$>*6%6%!%!%!%6%6%6%X$:%:%6%!%!%!%!%!%!%!%!%!%!%!%!%],],],!%!%!%6%Q,X$6%!%!%!%!%!%!%!%!%!%!%],!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%X$X$X$X$X$:%[%[%],[%[%/,R,S,T,[%[%[%[%X$5*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%d,!%!%!%!%!%!%!%!%!%!%!%!%!%!%U,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%2-V,X$0>P>o=P>0>P>P>o=P>0>",
"P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>P>P>P>0>0>0>P>P>o=P>P>P>P>0>P>P>P>P>P>0>0>P>0>P>P>P>P>P>0>0>],P>P>P>X$X$0>P>P>P>0>P>P>X$X$[%[%[%[%[%[%X$K&6%6%6%6%6%T&X$X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%],],6%6%X$!%6%!%!%!%!%!%!%!%!%W,6%6%],!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%X$X$X$X$[%:%[%[%[%],X$X$X$@;@;X$[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%Z*!%!%!%!%!%!%!%!%!%!%!%!%!%0;f*j*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X,X$X$P>P>P>0>P>0>0>P>P>P>",
"P>P>P>P>0>0>0>0>P>P>0>P>0>0>P>P>P>0>P>0>P>P>P>P>P>P>P>P>0>j,P>o=P>P>P>P>0>P>P>P>P>P>0>P>P>P>P>P>P>],P>P>P>P>P>P>P>P>0>P>P>P>0>P>P>X$X$[%[%[%[%[%X$,&{&Y,6%l;X$X$X$X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%6%],0%X$!%!%!%!%!%!%!%Z,`, '6%6%6%X$],!%!%!%!%[%[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%X$X$X$[%[%:%[%[%[%[%],X$X$.'s;X$X$X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$[%e>!%!%!%!%!%!%!%!%!%!%!%!%!%e=H%B*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%D&X$},0>P>P>P>P>P>P>P>P>P>",
"P>o=P>P>P>P>P>P>0>0>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>0>0>P>P>P>0>P>P>0>P>0>P>0>P>P>P>P>P>P>P>0>0>0>],P>P>P>0>P>0>P>P>0>P>P>0>P>P>P>0>P>X$X$X$[%[%[%[%X$X$X$X$X$X$Q%X$X$Q%X$X$X$6%6%6%6%6%6%!%!%!%!%!%!%!%6%S&X$],!%!%!%!%!%!%!%!%+'+'@'6%X$X$X$[%],[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%X$X$[%[%[%:%[%[%[%[%[%],[-9-Y=!%!%X$X$X$X$#'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%F*!%!%!%!%!%!%!%!%!%!%!%!%!%*;$'e*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%%'X$},0>P>P>P>P>P>P>0>P>P>0>",
"P>0>P>P>P>P>P>P>P>0>0>P>0>0>0>0>P>P>P>P>0>P>0>P>P>P>0>P>P>P>P>P>P>0>P>P>P>P>P>0>0>P>0>0>P>P>P>P>P>0>0>P>0>P>P>0>P>P>P>P>P>P>0>P>P>0>P>&'X$X$[%[%[%[%[%[%X$Q%Q%Q%X$X$Q%Q%Q%X$X$X$X$X$6%6%6%6%6%6%6%X$X$X$X$!%!%],!%!%!%!%Z,Z,*'@'='6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%[%[%[%[%[%X$#*R=!%!%'&X$X$~;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$-'!%!%!%!%!%!%!%!%!%!%!%!%!%;'@-:*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%D&X$},P>0>P>0>P>0>P>0>0>P>P>",
"P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>0>P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>P>P>P>j,P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>0>P>P>P>P>P>0>P>X$X$[%[%[%[%[%X$X$R%R%R%X$R%R%Q%Q%Q%X$X$X$X$X$X$X$X$X$X$X$X$6%!%!%!%],!%!%!%!%Z,>','X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%[%o-[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$''!%|%J*!%X$b,l&!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%y*X$X$[%q*!%!%!%!%!%!%!%!%!%!%!%!%!%)'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$P>P>P>P>P>0>P>P>P>P>P>P>",
"P>0>P>0>P>0>P>P>P>P>P>P>P>P>P>P>0>0>P>P>P>P>j,P>P>P>P>j,P>P>P>P>P>P>0>P>P>P>P>P>P>P>P>j,P>j,P>P>P>P>P>P>0>P>P>P>P>0>P>P>P>P>j,0>P>P>P>P>P>P>X$X$[%[%[%[%[%X$R%R%R%X$X$R%R%R%R%R%R%Q%X$!%!%!%!%!%!%6%!%!%!%!%!%!%],!%!%!%!'6%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$''!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%Q*!%!%!%!%!%!%!%!%!%!%!%!%!%;'~'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>0>P>0>P>P>P>j,P>P>P>j,P>",
"P>P>P>P>P>P>P>j,P>P>P>P>j,P>P>P>P>P>j,P>P>P>P>P>j,P>P>P>P>P>j,P>P>0>P>P>P>0>P>P>0>P>P>P>P>P>P>j,P>P>P>P>P>j,P>P>0>P>P>P>P>P>P>P>P>j,P>j,P>P>P>X$X$[%[%[%[%X$X$R%R%R%X$R%R%R%R%R%X$X$!%!%!%!%!%!%6%!%!%!%!%!%!%!%!%],!%{'6%X$X$:%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%[%[%(,[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%]'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%^'X$X$[%q=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%X$P>P>P>P>P>P>P>P>P>P>j,P>P>",
"P>j,P>P>P>P>P>P>/'j,P>/'P>P>P>P>P>P>j,P>P>P>P>P>P>j,P>P>j,P>j,P>P>P>P>P>P>P>P>P>P>j,P>/'P>j,P>P>P>j,P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>P>P>j,P>j,P>P>X$X$[%[%[%[%X$X$X$R%R%R%R%R%R%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%@'],X$X$[%[%:%X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%O-X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%x*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>j,P>P>P>j,P>P>P>P>P>j,P>",
"P>P>P>P>P>P>P>j,j,P>P>P>P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>('P>P>P>/'P>P>P>P>P>P>/'j,P>/'P>P>P>P>P>P>P>P>P>P>P>j,/'P>P>P>/'P>P>/'P>P>P>P>/'j,P>P>P>j,X$X$[%[%[%[%X$X$X$R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'_'_':'],X$[%[%[%:%X$[%[%[%[%[%[%[%[%[%[%[%:%[%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%<'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>P>P>P>/'P>P>P>P>P>P>P>P>",
"P>P>P>/'P>P>/'P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>P>P>P>P>j,P>P>P>P>P>P>P>/'/'P>P>P>/'P>P>/'P>P>P>P>P>/'/'P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>P>/'P>/'P>P>P>P>X$X$[%[%[%[%!%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%@'6%['X$X$X$],[%[%[%:%X$[%[%[%[%[%[%r-(=!%!%}'X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%|'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>/'/'P>P>P>/'/'/'/'P>/'/'P>",
"/'P>P>P>P>/'P>P>/'/'P>P>/'P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>P>P>P>/'P>P>P>P>P>P>/'P>P>P>P>P>/'/'/'P>P>P>P>P>P>P>P>P>P>P>P>/'P>/'P>/'P>P>P>P>P>P>P>&'1'2'X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$[%[%[%[%[%6%X$[%[%[%[%[%o,`*!%!%!%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%!;@-X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'P>P>/'P>P>P>P>P>P>P>P>P>P>",
"/'P>P>/'P>P>P>P>P>P>P>P>/'P>P>/'P>P>/'P>/'/'/'/'/'P>P>P>/'/'P>P>P>P>P>P>P>P>P>P>P>P>P>/'P>P>P>/'P>P>/'/'P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>/'P>P>3'P>&'P>4'2'X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$[%[%[%[%[%[%!%6%X$[%[%[%[%!%!%!%!%!%!%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%F,5'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>P>P>P>/'P>P>P>P>/'P>P>/'P>",
"('/'P>P>P>('/'P>P>/'/'P>P>P>/'P>P>P>P>P>P>P>P>P>P>/'P>P>P>P>/'P>/'P>('P>/'/'P>P>/'P>/'P>('P>P>('P>P>P>P>/'/'/'/'P>/'P>P>P>P>/'P>/'/'P>P>/'6'P>6'P>/'7'/'8'X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$[%[%[%[%[%[%!%!%6%X$[%[%Q*!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%|,9'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%L=X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>P>P>P>/'P>P>/'P>P>P>P>P>P>/'",
"P>/'P>/'P>P>/'P>P>P>/'('/'P>P>P>/'P>/'P>P>P>P>P>P>('/'('P>P>P>P>/'P>/'P>P>('/'P>/'P>('j,P>P>j,P>/'P>P>P>P>P>P>/'P>P>P>('/'P>/'P>P>/'P>('P>('P>0'P>P>P>P>X$X$[%X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$[%[%[%[%[%[%[%[%!%!%6%X$[%a'5=!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%b'c'b,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%C-X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'/'P>P>/'P>/'/'('/'/'P>P>P>",
"P>('/'P>P>('('/'/'/'P>P>('/'('('P>/'P>('('/'/'/'('P>('P>/'/'/'P>P>P>P>P>P>j,('/'P>P>P>('/'/'('/'P>/'('('/'/'P>P>/'/'/'/'P>P>P>('P>('/'P>P>P>0'&'('/'/'d'X$X$[%X$X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%[%X$X$X$[%[%[%[%[%[%[%[%!%!%!%6%X$G*!%!%!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%)&X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%x*X$j>[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>('P>P>('P>/'P>('P>P>P>/'P>/'",
"P>('P>/'P>P>('('P>('P>P>P>/'/'/'P>P>j,/'P>('P>P>/'P>/'P>('('/'/'/'/'/'/'('P>('/'/'P>P>P>P>P>P>/'('/'P>('P>/'P>P>P>P>P>/'/'('P>/'j,('P>/'/'&'e'&'('P>0'X$X$[%[%:%:%X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%!%!%!%!%6%X$=*!%!%6%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%R,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$f'[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$/'P>P>('P>/'P>/'P>P>('P>P>/'('P>",
"P>P>('/'/'/'P>P>('/'/'/'('P>P>P>P>('('P>/'P>/'P>P>/'P>('P>P>P>P>P>P>/'('P>/'P>('P>/'/'/'('/'('('P>P>/'P>/'/'('/'/'/'/'('('P>/'('('P>/'P>P>g'P>/'P>&'X$X$X$[%:%:%:%6%X$X$X$X$X$X$X$X$X$X$X$X$X$X$:%[%[%[%[%[%[%[%[%!%!%!%!%!%!%6%X$E*!%!%6%6%6%6%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%h'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'/'/'/'/'P>/'P>/'/'P>/'('/'P>/'",
"/'/'('P>P>P>/'P>P>P>P>P>/'/'('('/'/'/'('P>('/'/'P>/'P>/'/'/'('('('('P>/'P>/'P>('P>P>P>P>P>/'P>/'/'P>/'('('P>('('('P>P>P>/'P>P>/'/'P>('/'/'i'&'/'X$X$X$!%!%!%[%:%[%[%X$:%[%X$X$X$X$X$X$X$X$X$:%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%6%X$)-6%!%!%6%6%6%!%6%!%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%8-X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%X$},P>P>P>P>('P>('P>/'/'('/'('/'('/'",
"P>P>P>/'/'/'P>/'/'('/'/'/'('P>/'P>P>P>P>/'P>P>('('('/'P>P>('/'/'/'P>/'P>/'P>/'/'('('('/'/'P>/'P>P>/'P>P>P>/'P>P>P>('/'/'P>('/'j'k'k'j'j'j'P>6'l'X$!%!%!%!%!%[%[%[%[%X$[%[%[%:%:%:%:%:%:%:%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%6%X$`*X$6%6%6%6%X$6%6%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%m'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'/'('/'('/'('/'/'('P>/'P>P>P>P>P>",
"/'/'('('/'('/'('/'('/'('P>/'P>/'/'('/'('/'('P>P>P>/'('/'P>P>P>P>/'P>/'('('P>P>/'/'/'P>('/'P>('('('('/'/'/'/'/'/'/'P>P>n'o'k'k'p'p'p'p'k'k'k'j'j'j'j'!%!%q'!%!%[%[%r'X$6,[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%y*g>!%!%!%!%!%!%!%!%!%6%6%X$X$6%6%6%6%X$X$X$6%6%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'('/'P>/'P>('P>('P>/'/'/'/'('/'",
"('/'P>P>('P>('/'/'P>('P>/'/'/'('('/'/'/'/'/'/'/'/'P>/'('/'/'('/'/'('('P>/'('('P>P>/'('/'/'/'/'/'P>P>('('('/'('('P>s'j'j'k'k'p'p'p'p'p'p'p'p'k'k'k'k'j't'u'v'v'v'v'v'v'!%w'G*[%[%[%[%[%[%[%[%[%[%3*o,q=4;!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$6%6%6%X$X$X$X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>/'P>P>P>('P>/'P>/'/'/'/'/'('('/'('",
"('/'/'P>('P>P>('/'P>('P>('('/'/'/'('P>('/'('/'('('P>/'('/'/'('('/'P>/'P>/'/'('('('/'P>('('/'/'/'/'P>P>P>('P>P>x'j'j'k'k'p'p'y'y'y'y'y'y'y'y'y'p'p'p'p'p'j'z'A'B'B'B'v'v'6%6%Z*C-%=C'i=+=K=i=%=C-x*L=!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$v'X$X$X$X$X$X$X$X$[%X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'('/'('/'('('/'/'P>('('('P>/'P>P>/'",
"P>('('('/'('D'P>('/'/'('/'/'/'/'('P>/'P>P>/'('/'/'('('/'('/'/'/'('/'/'D'/'/'/'/'P>/'('P>/'P>('('('/'/'/'/'/'j'j'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'B'B'v'v'v'6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%E'v'v'v'v'v'X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'('/'/'/'/'('('('/'/'P>('/'('/'('",
"/'/'/'/'/'P>/'/'('('/'/'/'('('/'D'('/'D'('/'P>('D'j,/'/'('('P>/'('('P>('('/'('D'('/'/'/'('/'/'/'('('('P>('j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'v'v'E'6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%E'E'E'v'v'A'A'A'v'v'v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%)=X$:%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>('/'/'P>('P>/'/'/'('P>D'D'('/'/'/'/'",
"/'('/'('/'/'('/'D'/'('/'('/'/'P>/'/'('/'/'P>D'/'/'D'('('/'/'D'/'D'/'D'/'/'('/'P>/'('('('D'('('/'/'/'/'D'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'j'A'B'B'B'B'v'v'E'6%6%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%v'v'v'F'F'G'A'A'A'A'B'B'j'j'j'j'j'j'j'j'j'j'j'j'H'I'J'K'j'j'k'j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%)=X$:%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'/'/'('('/'('('/'('P>('/'/'/'/'('P>('",
"/'('/'('('/'('/'/'/'('/'('/'D'/'('D'/'/'D'/'/'/'/'/'/'('/'/'('/'/'/'/'('/'('D'/'/'('/'/'/'/'('/'('/'P>j'j'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'A'B'B'B'B'v'v'E'E'6%6%6%6%6%6%6%6%6%6%6%6%!%v'v'v'L'M'N'B'A'A'A'A'A'j'j'y'j'j'j'j'j'O'P'Q'R'S'T'U'V'W'y'y'y'p'p'k'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'('D'/'/'('/'('/'('D'/'/'('('/'D'/'/'",
"('/'('/'/'('/'/'('('('('/'('/'('/'P>('('/'('('('('/'('/'('('/'/'('/'('P>('/'/'('('/'('/'/'/'/'('/'('D'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'A'B'B'B'B'v'v'v'v'E'E'6%6%6%!%6%E'E'v'v'v'v'v'B'B'B'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'X'Y'Z'Z'y'y'y'y'y'y'y'y'p'k'k'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$('/'/'('('D'('/'/'D'/'('('/'D'('/'('('",
"D'/'('('D'/'('/'D'/'/'('/'('/'/'D'/'/'('/'/'/'/'('/'/'/'/'/'('D'('/'D'/'D'('/'D'/'/'('('('('D'D'/'/'/'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'B'B'B'B'B'v'v'v'v'v'v'v'v'v'v'v'B'B'B'B'B'B'A'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'/'D'/'/'/'/'('/'/'/'/'/'/'D'('/'/'/'",
"('('/'/'/'('/'('/'/'/'D'('/'('('/'('('/'('D'/'/'/'/'('('('('/'/'/'('/'('/'/'/'/'('('/'/'D'/'/'/'('/'('j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$('('/'/'('D'('D'/'('('('('/'/'/'('D'('",
"D'D'D'('D'('D'('('D'/'D'D'D'D'('D'D'('D'/'('D'D'D'D'/'/'D'('('D'D'('D'('('('/'D'D'('D'/'D'('('D'('/'j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'j'[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'('('/'/'D'/'('/'/'/'D'('('D'D'/'D'/'",
"/'/'/'D'/'D'/'/'D'('('/'/'/'/'D'/'/'D'/'('D'('/'('/'D'D'/'D'/'('/'D'/'/'D'D'D'/'/'D'/'('('/'D'/'D'('j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'y'j'A'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'j'[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'D'D'('/'/'D'D'('('/'D'/'('/'('/'D'",
"('('/'('/'D'D'/'D'D'('('('D'/'D'('/'('/'/'D'('D'D'('('('/'D'/'('D'('D'/'/'('/'D'/'('D'D'('/'D'/'D'/'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'A'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'k'k'k'p'p'y'y'y'y'p'p'k'j'[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'('('D'D'D'/'('D'D'('/'D'/'('D'('('D'",
"D'D'D'D'('('/'D'/'/'D'D'D'/'D'('D'D'D'D'('/'D'/'('D'D'D'('('D'/'/'D'/'('('D'D'('D'D'D'/'D'D'/'('/'D'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'A'A'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'j'j'j'j'j'`'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'p'k'p'p'p'y'y'y'y'y'y'p'p'p'j'j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'D'/'/'('('D'/'/'D'('('D'D'/'D'D'/'",
"D'/'D'D'D'('('D'D'D'/'D'D'('D'/'('/'('D'D'/'('D'/'/'('D'D'('D'D'/'D'D'D'/'('D'('/'/'D'/'('('D'D'/'/'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'A'A'B'B'B'B'A'A'A'A'j'j'j'j'j'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'p'p' )P'j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'/'D'('D'D'D'D'D'/'D'D'('D'('D'/'('D'",
"/'D'/'D'/'D'D'/'/'/'D'/'('D'/'D'D'D'D'('('D'D'D'D'D'D'('('D'('('D'('D'/'D'D'/'D'D'('('D'D'D'/'('D'D'j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'y'y'y'y'y'y'y'y'y'y'p'k'j'A'A'B'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'p'p'.)+)j'j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'('D'/'D'/'('('D'D'/'D'/'D'/'D'D'('",
"('D'/'D'D'D'D'D'D'('D'D'/'D'('/'('/'D'D'('D'/'('('D'D'D'D'D'D'('D'/'D'('D'D'/'('D'D'D'/'D'D'D'('('@)j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'y'y'y'y'y'y'y'y'y'p'k'j'A'A'B'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)$)j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'D'D'/'D'D'D'('('D'D'D'D'D'('D'D'D'",
"D'('D'('/'/'D'D'('D'('D'D'D'D'D'D'D'D'D'D'('D'D'D'/'D'D'('D'D'D'D'D'('D'D'('D'D'D'D'('D'('D'D'D'D'%)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'y'y'y'y'y'y'y'y'p'k'A'A'A'B'B'B'A'A'A'A'A'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'#)#)&)j'j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$*)/'('('D'('('D'D'D'('D'D'D'('D'('D'D'",
"D'('D'D'D'('('D'D'D'D'D'('D'D'D'D'/'D'D'D'D'D'D'D'D'/'D'D'D'D'('D'D'D'/'D'D'D'D'/'D'D'D'('D'D'D'('=)k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'y'y'y'y'y'y'y'y'p'j'A'A'A'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#);)j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'('D'D'D'D'D'D'('('/'D'D'D'/'('D'",
"D'D'D'D'D'D'D'D'('D'('('D'D'D'('('D'D'D'D'D'D'D'D'D'D'D'/'D'D'D'('D'D'D'D'D'D'('D'D'D'D'D'('D'D'D'k'k'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'y'y'y'y'y'y'y'y'p'j'A'A'A'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)>)j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$*)D'D'D'D'('D'D'D'D'D'D'D'D'D'D'D'D'",
"D'D'D'('D'D'D',)D',),)D'D'D'D',)D'D'D'D'('D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'('D'D'D'D'D'')k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'k'p'y'y'y'y'y'y'y'p'p'j'A'A'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#)#)))j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'D',)/'D'D'D'D'D'D'D'D'D'D'('D'",
"D'D'('D'D'D'D'D'D'D'D'D'('D'D'('!)D'('D',)D'D'D'D'D'D'D'D'D'D'D'D'('!)D'('('D'D'D'!)('!)D'('%)k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'p'y'y'y'y'y'y'y'p'p'j'A'A'B'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#)#)j'j'[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)D'D'D'!)('D'D'D'D'D'('('D'D'D'D'",
"('!)!)!)('D'D'D'D'D'D',)D'D'D'D'/'D'D'D'D'D'('D'D'('D'D'D'D'D'D'D'D'(',),)D'!)('D',)D'D',)D'~)k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'p'y'y'y'y'y'y'y'p'k'j'A'A'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%{)F*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$('D'D'D'D'D'D'D'D'D'D'D'D'D',)D'D'",
",)D'D'D'D'D'D'D'D'D'!)D'D'D'D'D',),)D'D'D'D',)D'D',),)D'D'D'D'!)D'D'D'D'D'D'D',)D'D'D'D'D'])k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'p'y'y'y'y'y'y'y'y'p'k'j'A'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)#)j'[%[%}=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$D'D'D'D'D'D'D'D'D'D'!)D'D'D'D'D'",
"D'D'D',)D'D'D'D'!)('D'D',),)D'!)D',)!)D'D'!)D'D'D'D'D'D'D'D'D'D'D'!),)D'D'D'D'D',)D'D'D'^)/)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'p'p'y'y'y'y'y'y'y'y'p'k'j'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'[%[%4;Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D',)D'D'D'!)D',)D'!)D'D'D'D'D'",
"D'D'D'D'D'D'D'D'D',)D'D'D'D'D'D'D'D'D'D'('D'D'D'D'D'D'D',)!)D',)D'D'D',)D'D'D'D'D'D'D',)k'k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'p'y'y'y'y'y'y'y'y'y'p'k'j'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'[%[%+=)=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$D'D'!)('!)D'D'D'('!)!)!)D'",
"D'D'D',)D'!)D'D'D'D'!)!)D'!)D'D'D'D',)!)D',)!)D'!)!),)D'D'D'D'D'D'!)D'!)D',)!)D'D'!)D'()k'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'p'p'y'y'y'y'y'y'y'y'y'p'p'j'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%=*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%P-!%!%!%!%!%!%6%6%6%X$X$X$D',)D'D'D'D',)D'D'D'!)D'",
",),)!)!)!)D',)D',),)D'D'!)D'D'!),)D'!)D'D'D'D'!)D'D'!)D'D'!)!)!)!)D'!)D'!)!)D',)!)D'k'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'#)p'y'y'y'y'y'y'y'y'y'y'p'p'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%d,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%r'L=`*`*)=!%!%6%6%6%X$X$X$,)D'!),)D'!)D'D'D'D',)",
"!)D'D'D'D'!)!)!)!)D'D'D'D'!)D'D'!)D',),),)D'D'D'D'D'!),)D'D'D'D'D'D'D'D'D'D'D'D'j'k'k'_)p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)k'j'#)y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%a'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%:)!%X$X$<)6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[)=*(=C-x*5=<)6%6%X$X$X$})!)D'D'!)D'D'D'D'D'",
"D'!)D'!)!)D'D'D'D',)!),)!)D',)!)D'!)!)!)!)!),)!),),)D'!),),)!)D'!),)D'!)!),)!)k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'-)#)y'y'y'y'y'y'y'y'y'y'y'y'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)y'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%y*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%w;C&X$X$|))-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%G*1)_*2)3)4)5)X$X$6)7)8),)D'9)9)!)!)!)",
"D'!),)D',)!),)!)!)D'!),),)D'D',)D'D'D'D',)!)D'!)!),)D'!)!)D'!),)!)!)D'D'!)j'j'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'#)k'-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%$=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$4)`*!%!%!%!%!%!%!%!%!%!%X$[)(=5=!%!%!%!%!%X$X$[%[%[%[%[%[%[%:%:%:%X$X$0)w-a)b)c)d),),),)",
"!)D'!)!)!)D'!),),)!)D'!)!)!)!)!)!)!)!),)!)D'!)D'D'!)!)D'D'!),)!)D',),)!),)j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)k'-)-)y'y'y'y'y'y'X$y'X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%u*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%i=!%!%!%!%!%!%!%!%!%!%X$X$[%o,4;!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$]-!)!)D'!)",
"!),),),)!)D'!)!)D'!)D',),),)D',),),)!)D'!),)!)!),),)!)!),)!)D'!)!)!),)!),)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'-)-)y'y'y'y'X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%i=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%i=e)!%!%!%!%!%!%!%!%[%X${-[%[%[%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$,)D'!)D',)",
",)!)!)!),)!)!)D'!),)!)!)!)!)!)!)!)!),)!),)!)!),)!)!)!),)!),)!),)!),)!)D'!)k'#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'-)-)y'y'y'X$X$X$X$X$!%!%!%!%!%!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'j'[%C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%G*f)[=!%!%!%!%!%!%!%!%X$X$g)#=[%[%[%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$,)!)!),)!)!)",
",)D',)!)!),)!),)!)!)!)!)D'!)!),)!)!)!)!)!),)!)!),),)!)D'!)!)!)D'!),)!),)!)k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)j'-)-)y'y'X$X$X$!%!%!%!%!%!%!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'j'h)x*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%{)x*)=!%!%!%!%!%!%X$X$z;i):%[%[%[%[%!%[%[%[%[%[%[%[%[%[%[%[%X$X$X$!)!),)!),)!)!)",
"!)!)!)!)!)!),)!)!),),),)!),),)!),),),)!),)!)!)!)!)!)!)!)!),),)!),)!)!)!)!)j'k'#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'-)-)y'X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$j)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)k)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'[%a'%;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$[%[%[%G*K=L=!%!%!%!%!%!%X$X$X$:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$X$,)!),)!)!)!),),)",
"!)!)!),)!)l)!)!)!)!)!)!)!)!)!)!)!)!),)!),),),)!)!),)!),)!)!)!)!)!)l)!),)!)j'j'#)#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'-)y'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)m)n)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'[%=*];!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%!%!%!%!%!%!%X$X$6%:%:%:%:%:%[%[%[%[%[%[%[%X$X$X$!)!)!),)!)!),)!)!)!)!)",
"l)!),)!)!)!)l),)l)!)!)l)!)!),)!)!)!)l)!)l)!)!)!),)!),)!)!),)!)!),),),)!),)!)j'k'k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'-)X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)o)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'[%K=)=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$6%:%:%:%:%:%:%:%[%X$X$X$!)!)!)!)!)!)!),)!),),)!),)",
",)l)!),),),)!),)l),),)l),)!),)!)!)!),),)!)l),)!)!)!)!),)l)l),)!)!)!)!)l)l)l),)j'k'k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)k'j'X$X$[%x*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%+=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$v=[%[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$X$X$X$X$X$X$X$X$,)!)!)l)l)l)l)!)!)l)!)l),)l)!)",
"l)!),)!)l)!)!)!),)l)!),)l)l)l)l),),)!)!)l),)!)l)l)l),)!)!),)l)!)l)!)l)!),),)l)l)j'k'k'#)#)-)-)-)-)-)y'-)-)-)-)-)-)-)-)-)#)j'X$X$[%[%(=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%+=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$~,-,[%[%[%[%[%[%[%[%[%[%X$X$X$!)!)l)!)!)l)!),)l)!)l)l),),),)!)l)!)!)l),)l)!),)",
",)l)l)!)!)l)l)!)!)l)!)!)!)!),)l)l)l)l),)!)l),),)!)l)l),)!)!)l),)l),),)!)!)!),),),)j'k'#)#)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)j'X$[%[%[%{)`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%p)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$W*T,~,[%[%[%[%[%[%X$X$[%[%X$X$X$,)!),),)l)l)!)!),),)!)!)!)!),)l)!)!)!)!),)l)!)",
"l)!)!),)l)!),)l)!),)l)!),)!)!)!)!)!)!)!)l)!)!)!)!)!)!)l)l)l),)!),)!)l)!)l),)!)!)!)l)j'k'#)#)-)-)-)-)-)-)-)-)-)-)-)-)-)#)q)X$X$[%[%[%[%4;Z*!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)j'j'j'y'y'y'y'r)s)r)t)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)u)j'j'[%K=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$v)s>i-K-[%[%[%[%[%X$X$[%[%X$X$l)!)l)!)!)!)l)l)!)!)l)!)!)l)!)!),)!)l)!)l)!)l)",
"l)l)l)!)l)!),)!)!)!)l)l)l)l)l),)l)!)l)!)!)l)l)l)!)!)!),),)l)l)l)l)!)l),)l)l)l)l)!)!)l)w)k'#)x)y)z)A)-)-)-)-)-)-)-)-)-)#)X$X$X$[%[%[%[%[%(=(=d,6,q*X$X$X$X$X$X$X$:%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'y'y'y'y'X$X$X$X$X$X$X$X$X$B)y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)C)j'j'[%g>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)X$X$X$X$);0-j-o-o-T=X$X$X$[%X$X$!)l)!)!),)!)l)l),)l)l),)!)l)l)l)!)l)!)l),)!)",
"!),)!)l),)l)l)l)l)l),)!),)!)!)l),)l)!)l)l)!)!)!)l)l)!)l)!)!)!)!)!)!)!)l)!)!)!)!)l)l)!)D)w)j'E)#)#)-)F)y)-)-)-)-)-)-)-)x)X$[%[%[%[%[%[%[%3*q=%=X$X$X$!%!%!%!%X$X$[%:%q*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'j'G)X$X$X$X$X$X$!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'j'r'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l),)!)X$X$X$X$X$P,[%[%W*X$X$X$X$X$X$X$X$l)!)l)!)!)l)!)!)!)l),)!),)l),)!),)l)l)",
"l)l)!)l)!)!),)!)!)l)l)l)l)!)!)l)l)l)!)!)l)l)l)!)l)l)!)l)l)l)l)l)l)l)!)l)l)l)l)!)!)l)l)!)X$:%w)k'F)-)-)-)-)-)-)-)-)-)#)X$X$[%[%[%[%X$X$X$X$X$X$X$[%[%!%!%!%!%!%X$X$[%:%Y*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)j'j'j'X$X$X$X$!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'-)-);)j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)!)X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$l),)l)l)!)!)l)l)!)l)l)l)!)l)l)l)!),)!)",
"!)!)l)!)l)l)l)l)l)!)l)l)!)l)l)!),)!)l)l)!)l)!)l)!)l)l)l)!)l)!)l)!)!)l)!)l)l)!)l)l)!)!)H)X$:%:%w)j'j'z)-)-)-)-)-)-)#)x)X$[%X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%,=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$I)y'y'y'y'-)-)-)-)-)J)-)-)K)L)j'X$X$!%!%X$X$X$X$X$!%!%!%!%!%X$X$M)y'y'y'y'y'y'y'y'y'y'y'-)-)-)N)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$!)!)l)l)l)X$X$X$X$X$X$X$X$X$X$X$X$X$l)l)l)l)!)l)l)!)l)l)!)l)!)l)!)l)!)l)l)l)",
"l)l)l)l)!)!)l)l)l)!)!)l)l)!)l)l)l)l)l)l)!)l)l)l)!)!)!)l)!)l)!)l)l)!)l)!)!)l)l)!)l)l)!)X$X$:%:%:%:%j'j'j'O)-)-)-)z)#)P)X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%L=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$Q)-)-)-)-)-)X$X$X$X$X$X$X$X$X$X$X$+'!%!%!%X$X$X$!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)l)l)!)l)!)l)l)l)!)!)!)!)l)l)l)!)l)!)l)!)l)l)!)l)l)!)l)l)l)!)l)l)l)l)l)",
"l)!)l)!)R)l)!)l)l)l)l)l)!)l)!)l)l)!)!)l)l)l)!)l)l)l)l)l)l)l)l)l)!)R)l)l)l)l)!)l)l)l)S)X$:%:%[%:%:%:%T)j'k'k'k'k'k'k'j'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%U)C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%V)X$X$-)-)X$X$X$!%W)X)!%!%!%!%!%X$X$X$+'!%!%!%!%X$X$!%!%!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$!)!)!)l)l)l)l)l)l)!)l)l)l)l)l)!)!)l)!)l)l)l)!)l)l)l)!)l)l)!)R)!)R)l)!)!)!)",
"l)!)l)!)l)l)!)!)l)l)!)l)l)R)!)l)l)l)!)l)!)l)l)l)l)l)l)l)!)R)!)l)!)!)l)l)l)l)l)!)!)l)X$X$:%:%[%[%[%[%:%:%w)k'Y)k'k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'!%!%!%X$X$!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)!)l)l)l)!)!)l)l)l)l)l)!)R)l)!)l)l)l)R)l)l)!)!)l)l)l)l)!)l)!)!)l)l)l)l)",
"!)R)R)Z)!)l)l)l)!)R)l)l)!)!)R)l)l)l)l)l)Z)l)l)l)R)l)!)l)l)l)l)l)l)R)!)l)!)l)l)Z)l)!)X$:%:%[%[%[%r-_*o,o,e>`)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)k'j'#)j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)!)!)Z)l)l)!)l)!)!)l)!)l)l)R)R)!)l)!)!)Z)l)l)!)R)l)l)l)l)l)l)l)l)l)",
"!)!)!)R)l)l)R)R)!)l)l)R)Z)l)l)l)l)R)!)R)l)!)l)l)!)R)!)R)!)l)l)l)l)R)!)R)R)!)R)l)l)!)X$:%:%[%[%6,4;q*q*C-!%`*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'!%!%!%!%!%!%!%!%X$X$X$+'+'!%!%X$X$ !.!y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)#)k'j'#)j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)l)R)!)l)R)R)!)R)R)l)Z)!)l)!)!)l)!)R)R)!)l)R)R)!)!)l)R)!)R)R)!)l)l)l)",
"Z)Z)l)!)R)!)!)l)l)R)l)!)l)l)!)R)!)!)R)l)!)R)l)l)R)l)l)l)l)R)l)l)l)!)R)!)!)l)!)R)l)X$X$:%:%[%g>!%(=[=5=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$:%:%[%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'+'!%!%!%!%!%!%!%X$+'+'!%!%!%X$+!@!y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)k'j'-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)l)R)!)l)R)l)l)l)!)R)R)l)l)R)Z)!)!)R)R)!)l)l)l)R)l)l)!)!)l)R)R)l)",
"l)R)l)l)R)l)l)l)l)!)Z)R)!)R)!)R)l)l)l)R)l)l)l)l)l)R)!)R)!)R)!)l)Z)l)l)l)R)l)l)R)!)X$X$:%:%6,C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$:%:%[%!%!%!%!%6%X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'+'!%!%!%!%!%X$X$+'+'!%C;#!X$$!y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)%!k'-)#)k'k'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)!)R)!)l)l)l)l)l)l)Z)l)l)l)R)!)!)R)l)l)l)l)l)R)!)l)l)l)Z)Z)R)!)!)!)l)",
"R)l)l)l)l)R)l)l)l)R)!)!)R)l)R)l)l)!)R)l)!)R)!)R)!)l)Z)l)l)!)R)R)l)l)R)l)!)R)l)l)&!X$:%:%h)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$+'+'+'!%!%!%X$X$X$+'!%!%**X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)C)*!j'-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$l)l)l)R)l)!)R)!)R)R)l)!)R)l)Z)R)l)R)l)!)R)!)!)R)!)R)!)R)!)l)Z)Z)R)R)",
"l)R)R)!)l)R)R)!)l)R)R)l)R)!)l)R)R)!)l)Z)l)R)!)R)l)R)!)R)l)l)!)R)!)l)R)R)!)l)l)l)=!X$:%[%r-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%5;G*X$X$:%:%q=!%!%!%!%X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'!%!%!%X$X$+'!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-!;!k'-)-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)R)l)l)R)!)!)!)R)!)l)!)l)l)l)R)R)l)R)R)l)R)l)R)!)R)l)R)!)l)l)l)",
"R)l)!)R)R)!)l)R)R)l)!)R)l)l)R)l)l)l)R)!)R)l)R)R)!)l)R)l)l)l)R)!)R)l)l)l)R)R)!)l)>!X$:%[%-'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+=[%[%X$X$:%:%a'5;`*!%X$X$X$X$1,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'+'!%!%X$X$+'!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)#)#)-)-)-)k'k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)l)l)l)!)R)l)Z)R)R)R)R)R)R)l)R)!)l)l)l)l)!)R)!)R)l)R)!)R)l)R)R)R)Z)",
"!)R)l)!)R)l)l)l)R)R)!)R)R)l)l)R)R)l)R)l)R)!)!)R)R)l)l)R)R)l)R)R)R)l)l)l)l)R)R)Z),!X$:%[%-'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%$=G*[%[%X$X$X$:%:%{))=!%!%!%X$X$X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'+'!%X$X$!%+'X$X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)#)-)-)-)j'#)j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$R)R)!)R)l)R)!)l)l)l)l)!)l)R)!)R)R)l)l)R)R)l)Z)l)R)!)R)l)R)!)!)l)R)l)",
"R)l)R)R)l)R)R)l)l)l)R)l)l)R)R)l)!)R)!)R)l)R)R)l)!)R)R)l)l)R)l)l)!)R)R)R)R)l)l)R)'!X$:%[%[)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*Q*[%[%[%[%X$X$X$X$:%:%[%C-!%!%!%X$X$X$6%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%X$X$!%y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l)l)R)R)!)R)R)R)R)R)R)R)R)l)Z)l)!)R)R)l)l)!)R)R)l)R)l)R)l)R)R)R)l)R)",
"R)l)l)R)l)l)R)R)R)!)R)R)!)R)!)R)R)R)R)R)l)l)R)R)R)!)R)R)l)R)R)R)l)l)!)l)R)R)l)l)R)X$:%[%G*X$6%6%!%!%!%!%!%!%6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!*[%[%[%[%[%X$-))!X$X$X$:%:%:%(=|%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%X$X$!%p'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)k'y'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)R)R)!)!)R)!)l)l)l)R)R)R)R)l)l)R)R)R)R)!)R)l)R)l)R)l)R)!)R)l)l)",
"l)R)R)l)R)R)l)l)l)R)l)R)R)l)R)R)l)l)l)l)R)R)l)l)l)R)l)l)R)l)l)l)R)R)R)R)l)l)R)R)l)X$:%[%[%X$6%6%!%!%!%!%!%!%!%X$6%6%6%6%6%6%6%6%6%6%6%6%6%!%!%!%!%!%!%!%`*5=!%}=4;$=[%[%[%[%X$X$!!-))!~!{!X$X$:%:%:%Y*`*`*!%!%X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'X$X$[%k'p'p'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)k'k']!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)R)R)l)R)R)l)R)R)R)R)l)!)R)l)R)R)l)l)l)l)R)l)R)l)R)l)R)l)R)l)R)R)",
"l)l)R)l)l)R)R)R)l)R)l)l)R)l)l)R)R)R)R)l)l)R)R)R)R)R)R)l)R)R)R)l)l)l)l)R)R)l)l)R)^!X$:%[%[%X$X$X$6%!%!%!%!%!%!%6%X$6%X$X$6%X$6%6%6%6%6%6%6%6%X$X$X$!%F*%;[=q*6,r-:%:%[%[%X$X$/!y'y'-)-))!(!_!X$X$l>:%:%:%q*+=!%!%X$X$)-6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%+'X$X$:!k'p'p'p'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)#)<![!}!|!1!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$l)l)R)l)l)R)l)l)l)l)R)R)l)R)l)R)R)R)R)R)R)R)l)R)l)R)l)R)l)R)l)l)Z)",
"R)R)R)R)R)l)l)l)R)R)R)R)l)R)R)R)l)l)l)R)R)R)l)l)l)l)l)R)l)l)R)R)R)R)R)l)l)R)R)l)2!X$:%:%[%X$X$X$6%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$&=$=y*[)3*G*G*[%[%:%[%[%[%X$y'y'y'y'y'-)-)-))!)!)!(!X$X>3!:%[%[%=*!%!%!%X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$R;[%:!k'p'p'p'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)#)#)4!j'j'j'j'!%!%5!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)l)R)R)l)R)R)R)R)l)l)R)l)R)!)R)l)l)l)l)R)R)l)R)l)R)l)R)l)R)R)R)",
"Z)l)R)!)R)R)R)l)l)l)R)R)R)R)l)R)R)R)R)l)Z)R)R)R)R)R)l)R)R)l)l)R)l)R)R)R)R)l)R)l)l)X$X$:%[%X$:%X$X$!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%:%:%:%:%:%:%:%:%:%[%X$X$X$y'y'y'y'y'y'y'-)-)-))!)!)!X$X$X$i):%:%[%i=A;!%!%`*X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6![%:!:!k'k'p'p'p'y'-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)j'j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l)R)R)R)R)Z)l)R)R)R)R)l)R)l)R)l)R)R)R)R)l)Z)R)R)R)l)R)Z)R)R)R)R)R)",
"R)R)l)R)R)R)R)R)R)R)R)l)R)l)R)R)R)R)l)R)R)R)R)R)R)R)R)R)Z)R)R)l)R)l)R)l)R)R)Z)R)R)R)X$:%[%[%[%X$X$X$6%!%!%!%[%!%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%[%:%:%X$[%X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'-)-)-)-))!7!_!X$X$:%:%:%[%&=8!!%!%!%!%X$X$6%6%6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%:!k'k'k'p'p'p'#)#)#)#)#)#)-)-)-)-)-)-)#)k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)l)Z)l)R)R)R)l)R)R)R)l)R)R)R)R)R)R)l)R)R)R)l)R)R)R)R)R)l)l)l)l)",
"R)R)R)l)R)R)R)R)R)l)R)l)R)R)R)l)R)R)R)R)l)Z)l)R)l)R)R)R)R)R)R)R)R)Z)R)l)R)R)R)R)l)R)X$X$[%[%[%[%[%[%[%:%:%:%:%:%:%:%:%[%[%[%[%[%:%:%:%:%:%X$:%X$X$X$X$X$X$9!0!y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)_!a!X$X$X$:%:%:%[%[)[=)=!%!%!%`*X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%r>!%,=[%[%[%j'k'k'j'j'k'k'k'#)#)#)#)#)#)#)#)q)4!j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R)R)R)R)R)R)l)R)l)l)R)R)R)l)R)l)l)l)R)R)R)l)R)l)R)l)R)R)R)R)R)R)Z)",
"R)R)l)R)l)l)R)R)l)R)R)R)R)R)l)R)l)R)l)Z)R)R)R)l)R)R)l)R)R)Z)R)l)R)R)R)R)l)R)Z)l)R)b!X$X$[%[%[%[%[%[%[%[%:%:%:%[%[%:%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!c!X$X$X$[%:%:%[%G*r'P-`*!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%R=!%|%3*[%[%[%j'j'j'j'j'j'X$j'j'j'j'k'k'd!k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$R)R)R)R)R)R)R)R)R)Z)R)R)R)l)R)R)R)R)R)Z)R)R)R)Z)R)R)Z)R)R)R)R)R)",
"R)R)R)R)R)Z)Z)R)R)R)R)R)l)R)R)R)R)R)R)R)R)R)R)R)l)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)X$X$[%[%[%[%[%[%:%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)(!e!X$X$X$:%:%[%[%_=i=L=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%j'j'[%X$X$j'j'j'j'j'j'f!t'g!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)R)R)R)R)R)R)R)R)l)R)R)R)R)R)R)Z)R)R)Z)R)R)R)Z)R)R)R)R)R)R)R)",
"Z)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)Z)R)R)R)R)R)R)R)R)h!X$[%[%[%[%:%:%:%X$X$X$X$X$X$X$R)R)R)j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!X$X$X$:%:%:%[%[%{)[=5=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%i![%X$[%[%[%!%!%!%!%!%j!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)",
"R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)k!R)l!X$:%:%:%:%X$X$X$X$X$X$X$X$R)R)R)k!R)j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!X$X$X$m!:%:%[%[%[%Y*L=Z*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+=[%i!i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$R)Z)R)R)k!k!R)R)k!R)R)Z)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)",
"k!k!R)R)R)R)k!R)R)R)R)k!k!R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)k!R)R)R)k!R)R)R)R)R)R)R)R)l!X$:%:%X$X$X$X$X$R)R)R)R)R)R)k!R)Z)R)j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!)!X$X$:%:%:%[%[%[%3*f)}=)=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'!%X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$Z)R)R)Z)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)k!R)R)R)R)R)R)R)R)R)R)Z)",
"R)k!k!R)R)R)k!R)k!R)R)R)R)k!R)R)R)R)R)R)k!R)R)R)R)R)R)R)Z)k!R)k!R)k!R)R)R)k!R)R)R)R)R)X$:%X$X$X$R)R)k!R)R)k!R)R)R)R)R)j'j'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!X$X$X$:%:%[%[%[%[%Q*r'x*`*`*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)k!R)R)R)R)R)R)k!k!R)k!R)R)R)R)R)R)R)R)R)R)R)R)R)k!R)R)k!k!R)",
"R)R)R)k!k!R)R)R)R)R)R)R)k!R)k!R)k!R)R)k!R)R)k!k!R)R)R)R)n!R)k!R)k!R)R)R)k!R)k!k!k!k!R)X$X$X$X$k!k!k!R)R)k!R)R)R)k!k!j'k'k'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!X$X$:%:%:%[%[%[%[%G*f))=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$k!R)k!k!k!R)n!k!R)R)k!R)R)k!k!k!R)k!R)k!k!R)R)k!R)R)k!R)R)R)k!",
"k!k!n!R)k!k!k!R)k!k!k!R)R)k!k!R)k!k!R)k!k!R)R)k!k!k!k!R)k!R)k!R)R)k!k!R)k!R)R)R)R)k!Z)X$X$X$R)R)R)R)k!R)n!k!k!R)R)j'j'k'#)j'k'p'p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!X$X$:%:%:%[%[%[%[%[%q=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$R)R)R)k!Z)R)k!k!R)k!k!n!R)R)k!R)k!R)R)k!k!R)k!k!R)k!k!R)R)k!",
"R)R)Z)k!R)R)n!k!R)k!R)k!k!R)R)n!n!R)k!R)R)k!k!k!k!R)R)R)R)R)R)k!n!k!R)n!R)k!k!k!k!k!n!X$X$R)k!k!R)k!k!k!Z)R)k!k!k!j'k'#)#)j'j'#)p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!)!X$X$X$:%:%[%[%[%[%[%G*4;!%!%!%!%!%!%!%!%!%!%!%!%!%+'X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$n!k!k!R)k!k!k!R)k!R)R)R)n!R)R)n!R)k!k!R)R)k!R)n!k!R)k!n!k!R)",
"R)n!n!n!k!R)n!n!R)k!k!k!k!R)Z)R)n!n!k!n!k!n!k!R)k!k!k!n!k!n!n!R)n!R)R)k!k!R)n!R)n!R)n!k!k!k!k!k!k!R)k!k!k!k!n!R)R)j'k'#)-)j'j'k'p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!)!X$X$:%:%:%[%[%[%[%[%r-x*!%!%!%!%!%!%!%!%!%!%!%+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$n!R)k!n!R)n!k!n!R)R)R)R)n!k!R)n!n!k!n!n!R)n!Z)R)k!R)R)R)k!R)",
"k!k!R)R)k!k!R)R)n!n!R)R)k!n!n!k!R)R)n!R)R)k!R)k!n!k!k!R)n!k!R)k!R)n!k!R)R)n!R)k!R)R)R)n!n!k!n!n!n!n!n!n!n!R)R)n!k!j'k'#)-)j'j'k'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!X$X$X$X$m!:%:%[%[%[%[%y* =!%!%!%!%!%!%!%!%!%!%+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)n!R)R)n!R)n!R)k!k!k!k!k!R)k!R)R)n!R)R)k!R)n!k!n!k!k!n!k!k!",
"k!k!R)n!k!k!k!k!R)n!n!k!k!R)k!k!k!R)k!n!R)n!n!R)k!n!k!k!k!k!k!k!k!k!n!k!k!k!n!k!k!k!R)R)n!R)R)R)R)R)R)R)n!k!k!k!R)j'#)#)-)-)-)j'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!X$X$X$X$:%:%:%:%o!!%!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%p!0%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!k!R)k!R)k!n!n!k!k!k!n!k!k!k!R)k!k!n!k!k!k!R)k!k!R)n!n!k!",
"k!k!k!R)k!k!k!k!k!k!k!n!k!k!R)R)k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!k!k!k!k!n!k!k!k!k!k!k!k!k!R)k!k!k!k!k!k!k!R)k!R)k!k!j'#)#)-)-)-)j'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)X$X$X$X$[%i![%q!!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'V-X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!k!k!k!k!k!k!k!R)n!k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!n!k!R)R)n!",
"n!n!k!n!n!n!k!k!k!k!R)n!k!n!k!n!n!n!k!n!k!k!k!n!k!n!n!n!n!R)n!k!n!k!k!k!n!k!n!n!n!n!k!k!k!k!k!k!k!n!k!k!n!k!n!k!n!n!j'#)-)-)-)-)p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)r!X$X$X$X$[%+=!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!n!n!n!n!k!k!k!n!n!k!n!n!k!k!n!k!k!n!k!k!k!k!R)n!k!k!k!k!",
"R)k!n!k!R)k!n!n!n!n!k!k!n!k!s!k!k!k!k!k!n!n!n!R)n!k!R)k!k!k!R)n!R)n!n!n!k!n!k!k!k!k!n!k!n!n!n!n!n!k!n!n!R)n!k!n!R)k!j'#)#)-)-)-)-)y'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'!%X$X$X$X$X$!%!%!%!%!%!%!%!%+'+'X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$n!k!k!k!k!k!n!k!k!k!k!n!k!k!n!n!k!n!k!k!n!n!n!k!k!k!n!k!k!n!",
"k!k!k!n!n!k!k!k!k!s!k!k!k!k!n!k!k!k!k!k!k!k!n!k!n!k!k!n!n!k!k!n!k!k!k!k!k!n!k!k!n!k!n!k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!k!j'j'#)-)j'-)-)y'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'[%[%[%X$X$x*5=!%!%!%!%!%!%+'X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$n!k!k!k!k!n!n!n!k!k!n!k!k!k!n!k!n!k!k!k!k!n!s!k!k!n!n!k!k!",
"k!k!n!k!R)k!k!k!k!R)k!s!n!n!k!n!n!n!s!k!k!k!s!k!R)s!n!k!k!n!n!k!n!k!k!n!k!k!n!n!k!k!k!k!s!n!n!k!n!k!k!s!n!k!s!n!s!k!k!j'j'j'-)j'k'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'[%[%[%X$X$!%)=`*!%!%!%[%!%+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!s!n!n!k!s!k!k!n!k!k!s!k!k!k!n!k!n!k!n!k!k!k!n!k!k!k!k!n!",
"n!k!n!k!s!n!n!n!s!n!k!k!k!k!k!k!k!k!n!n!s!k!s!s!k!k!n!k!k!k!n!k!s!s!s!s!k!k!k!k!s!s!n!k!k!k!s!k!s!s!k!k!n!k!k!k!k!s!n!s!j'j'j'j'k'#)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)F)j'[%[%[%[%X$X$e)%=!%!%[%[%+'X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$!%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$k!k!k!k!k!k!k!k!n!k!k!n!n!k!k!k!k!n!k!s!s!k!k!s!s!k!n!k!k!",
"s!k!k!s!k!k!k!k!k!k!k!s!n!s!s!n!s!n!k!k!k!k!k!k!n!s!k!s!s!s!k!s!k!k!k!k!n!s!s!s!k!k!s!n!n!n!n!n!k!k!n!s!k!k!s!n!s!n!k!k!n!v'v'j'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)j'j'[%[%[%[%[%X$t!G*{)!%[%i!+'X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!n!n!s!n!s!n!n!k!s!n!s!s!s!s!s!s!k!s!k!k!n!n!k!k!k!s!s!s!",
"s!s!k!n!s!s!s!n!s!s!k!k!k!k!k!k!k!s!s!n!s!k!n!k!k!s!k!k!k!s!k!n!k!k!n!k!k!k!k!n!n!k!k!s!s!k!s!n!k!k!k!s!s!k!k!k!k!s!n!k!v'v'B'B'B'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%X$X$[%X$[%i![%X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!k!k!k!k!s!s!s!k!k!k!k!k!k!n!k!s!k!k!k!s!k!n!s!s!k!k!n!n!",
"n!k!s!k!n!k!k!k!n!k!s!s!n!s!s!n!s!k!k!k!k!s!k!s!n!k!n!k!n!k!n!k!s!s!k!s!n!n!n!k!k!n!s!k!k!k!k!k!s!s!s!k!k!n!s!s!n!k!k!s!v'B'B'B'B'B'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$[%X$i!i!X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%!%[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$k!s!n!s!n!k!k!k!s!s!n!n!n!k!k!n!k!n!s!s!k!s!k!k!k!n!k!k!k!",
"s!n!s!k!n!n!s!k!n!n!k!s!k!k!k!n!s!n!s!s!n!s!n!s!s!s!s!k!s!s!s!n!n!s!n!s!n!s!s!s!s!k!n!n!s!n!s!n!k!k!n!s!s!k!n!s!n!s!n!v'v'B'B'B'B'B'j'k'k'p'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$+'X$[%[%X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%!%[%X$[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!k!s!n!n!s!n!k!s!k!s!s!n!s!n!s!k!n!n!n!s!n!n!s!s!n!s!n!",
"n!k!n!s!s!s!n!s!s!k!n!k!s!s!s!k!k!s!n!k!s!k!s!k!n!k!n!s!n!k!k!s!k!n!k!k!s!k!n!n!k!n!s!s!n!s!n!k!n!s!n!n!k!s!k!k!s!n!s!v'v'B'B'B'B'B'B'j'j'p'#))!)!-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$X$X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'X$X$X$X$!%!%!%!%X$[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!n!k!s!s!n!k!s!k!s!k!n!s!k!s!k!s!k!s!k!n!s!s!k!n!s!k!s!",
"s!s!s!k!k!s!k!k!s!s!s!n!n!s!s!s!s!s!s!k!s!k!s!s!s!s!s!s!s!s!k!s!s!s!s!k!s!k!s!s!s!k!k!s!k!k!s!s!n!s!s!s!s!s!s!k!k!k!s!v'v'B'B'B'B'B'B'j'j'j'#))!)!)!-)y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'u!>-m*%'X$X$X$!%!%!%!%!%X$X$[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!s!s!k!k!s!s!n!s!s!s!s!k!s!k!s!s!s!k!s!s!k!k!s!s!k!s!k!s!",
"s!k!k!s!s!k!s!s!s!k!n!s!s!n!s!n!k!s!n!s!s!s!n!k!n!k!n!k!k!s!s!s!k!s!n!s!s!s!k!s!k!s!s!k!s!s!s!k!s!k!k!k!k!s!n!s!s!s!s!v'B'B'B'B'B'B'B'B'j'j'j'v!)!)!-)-)y'y'y'y'y'y'y'-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'j'[%[%[%[%[%X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'w!+'p!+'!%!%!%!%!%!%!%X$[%[%[%X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$s!s!n!k!s!s!k!s!s!n!k!n!k!s!n!s!s!n!s!s!s!k!s!s!n!k!s!s!s!k!",
"s!s!s!s!s!s!s!k!s!s!n!s!s!n!s!s!k!s!s!s!s!s!s!s!s!s!s!s!n!s!n!s!k!s!n!n!s!s!n!s!s!s!s!n!s!n!s!k!s!s!s!s!n!s!s!s!n!k!s!v'B'B'B'B'B'B'B'B'B'B'j'j'v!)!)!)!-)-)-)-)-)-)-)-)-)-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$s!s!s!n!n!s!s!k!s!s!s!s!s!s!s!n!s!n!s!n!s!n!s!s!s!s!n!s!s!s!",
"s!s!s!s!s!n!n!s!s!k!s!k!s!s!s!s!s!s!n!k!n!k!s!k!s!s!s!s!s!k!s!s!s!s!s!s!n!s!s!s!n!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!v'B'B'B'B'B'B'B'B'B'B'B'j'j'v!)!)!-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'x!x!x!)!)!-)-)-)y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$n!k!s!s!s!s!k!s!n!s!k!s!s!k!n!s!s!s!n!s!s!s!n!s!s!s!s!n!s!n!",
"s!n!s!s!s!s!s!s!s!s!s!k!s!k!n!s!k!s!s!s!s!s!s!s!k!s!s!s!s!n!n!s!k!s!s!s!n!s!s!s!k!s!s!s!n!s!s!s!n!s!s!s!k!s!n!s!s!s!v'v'B'B'B'B'B'B'B'B'B'B'B'B'j'v!v!)!)!)!)!)!)!)!)!)!)!)!)!)!v!v!v!j'j'j'j'j'j'j'j'j'j'j'v!v!x!)!)!)!)!)!)!)!-)y'y'-)-)-)v!v![%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!n!s!s!s!k!s!s!n!s!s!s!n!s!s!s!s!n!s!s!",
"s!s!k!n!s!s!s!s!s!s!s!s!k!y!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!k!n!s!y!s!s!s!s!s!s!k!s!n!n!s!y!s!s!s!s!j'v'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'v!v!)!)!)!)!)!)!)!)!v!v!v!v!v!v!v!j'j'j'j'j'j'A'A'A'A'A'j'j'j'v!v!)!)!)!)!)!)!)!)!-)-)-)_!v![%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!n!s!s!s!s!s!s!k!s!n!s!s!s!s!y!k!s!s!s!s!s!s!n!s!k!s!s!s!s!",
"s!y!s!s!s!s!s!s!n!s!s!y!s!s!s!z!s!s!s!s!s!s!n!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!k!s!s!s!y!s!s!s!s!s!s!s!j'j'j'v!v!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'v!)!)!)!)!)!j'j'j'j'j'j'j'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'v!)!)!)!)!)!)!)!A!)!v![%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$X$i!X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!k!y!s!s!s!s!s!",
"s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!s!s!s!s!s!s!z!s!s!s!s!s!y!s!s!s!s!s!s!z!s!j'j'v!v!x!x!x!x!x!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'v!v!v!v!v!j'j'j'j'j'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'v!v!)!)!)!)!)!)!)!v![%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$X$X$[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!",
"s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!z!n!s!s!s!s!s!z!s!s!s!k!j'j'j'x!x!x!x!x!x!x!x!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'j'j'j'j'j'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'j'-))!(!v!j'[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$[%[%[%X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!z!n!s!s!s!s!s!s!",
"z!y!s!s!s!s!y!s!s!z!n!z!s!z!s!s!z!s!s!s!s!s!z!s!s!s!s!s!s!z!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!B!v!v!x!x!x!x!x!x!x!x!x!x!)!j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'j'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'B'j'j'j'j'j'[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$s!s!s!s!s!z!s!s!z!s!s!y!z!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!y!s!s!s!",
"s!z!z!z!z!n!y!s!s!z!s!s!s!s!s!s!s!z!n!s!s!s!z!s!s!z!s!z!n!s!y!s!s!s!s!s!s!s!z!z!z!s!z!s!s!z!s!s!C!v!v!x!x!x!x!x!x!x!x!x!x!x!-)j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'D!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!z!s!z!k!s!s!s!z!s!s!s!s!s!z!s!y!s!s!y!z!s!s!s!s!s!z!n!z!z!s!s!",
"z!s!s!n!s!z!s!s!s!s!s!s!s!s!z!s!y!s!y!y!z!s!n!z!y!s!s!s!y!s!s!s!s!z!s!s!z!y!s!s!s!s!n!z!s!n!E!F!v!v!x!x!x!x!x!x!y'y'y'y'y'-)-)-)j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'G!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$z!s!s!s!z!z!s!s!s!y!s!s!y!s!s!s!s!y!z!s!s!y!y!s!y!s!s!s!s!s!y!y!",
"s!s!y!s!s!s!y!s!s!s!z!s!y!s!s!s!s!z!s!s!s!y!s!s!s!y!s!s!s!z!y!y!s!s!z!s!s!s!s!s!s!y!s!s!y!s!H!v!v!x!x!x!x!x!x!y'y'y'y'y'y'-)-)-)-)j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!J!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$y!y!s!s!s!y!s!s!s!z!y!z!s!s!y!s!s!s!s!s!s!z!s!s!y!s!z!s!s!z!z!s!",
"s!s!s!y!y!z!z!z!y!z!s!z!z!s!y!z!y!s!z!y!z!s!s!z!s!z!y!s!z!s!z!z!s!z!s!y!y!y!y!y!z!s!s!z!s!K!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'-)-)-)-)j'j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'G!I!v'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$y!s!z!y!y!y!s!y!y!y!s!s!s!z!z!z!z!z!s!s!s!z!s!z!z!z!y!s!s!s!s!s!s!",
"z!z!z!s!s!s!s!z!s!s!s!s!z!z!s!z!s!s!s!s!z!y!s!z!s!z!z!s!s!s!s!s!s!y!s!z!z!z!z!s!z!y!s!L!v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'j'j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!I!v'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$z!s!z!z!z!z!z!s!z!s!z!s!s!s!s!s!s!z!z!z!s!y!s!s!s!z!s!z!z!s!y!z!y!",
"s!s!s!z!z!y!y!s!z!z!y!y!s!s!z!s!y!y!z!z!s!z!z!s!s!s!s!y!z!y!y!z!y!z!z!s!s!s!s!y!s!z!z!v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)j'j'j'j'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'M!M!M!A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!A'v'[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$z!s!s!s!s!s!s!s!z!s!z!s!s!y!s!y!s!y!s!s!s!s!z!y!y!z!s!z!s!y!z!z!s!z!",
"y!z!s!s!z!z!s!s!s!z!z!z!s!s!y!z!z!s!s!y!s!y!y!z!y!y!s!s!z!z!s!z!s!s!z!s!y!z!z!s!s!s!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'B'B'B'B'j'j'j'j'j'j'j'j'v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!j'j'j'j'j'j'j'j'j'j'j'j'`*[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$y!y!s!y!y!z!s!s!y!y!y!z!z!z!z!z!z!y!z!y!z!s!z!z!s!y!y!y!z!s!s!y!s!y!",
"z!y!z!y!s!s!z!y!y!s!s!s!z!y!z!s!s!z!y!z!z!y!z!y!z!z!z!z!s!y!z!s!y!y!s!z!z!y!s!z!L!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)j'j'v!v!v!v!v!v!v!v!v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!v!v!v!v!v!j'j'v!v!)!v!v!j'[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$y!z!z!z!z!z!s!z!z!z!s!z!y!s!y!s!y!s!z!y!z!y!y!s!s!y!z!z!z!s!z!z!z!z!z!",
"z!y!z!z!y!y!z!z!z!z!y!y!z!s!z!y!y!z!z!y!s!y!z!s!s!y!y!y!s!y!z!z!z!z!z!s!z!y!y!N!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)j'v!v!v!v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!x!x!x!x!x!x!x!)!)!)!O!v!v!j'[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$y!s!X$X$s!y!y!y!s!z!y!z!y!z!z!y!z!s!y!y!y!z!z!y!z!y!s!s!z!y!y!s!y!s!y!",
"y!z!y!y!z!z!y!y!s!y!z!z!y!y!y!z!z!s!s!z!z!z!s!z!z!z!y!z!z!z!y!y!y!y!y!y!s!z!P!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'v!v!v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!x!)!-)-))!~!Q!v![%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%[%[%[%[%[%X$X$X$X$+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$y!y!z!X$X$y!z!z!z!z!y!z!y!z!s!s!z!y!z!z!z!z!y!y!z!y!z!y!z!y!y!z!z!y!y!z!",
"y!z!z!z!y!z!z!z!z!y!y!z!z!z!y!y!z!z!z!z!y!z!y!y!y!z!y!y!y!z!z!z!y!y!z!z!z!j'v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)j'j'v!)!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!-)-))!)!)!v!v![%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%X$X$X$X$X$+'i!X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$z!y!X$X$X$y!y!s!y!z!y!z!z!z!z!y!z!y!s!y!z!z!z!y!z!y!z!y!y!z!s!y!z!z!y!y!",
"z!z!y!y!z!y!z!y!z!z!z!y!y!y!z!z!y!y!y!y!z!y!z!z!z!z!z!z!z!y!y!y!z!z!j'j'v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'v!v!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!v!v!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$z!z!X$X$X$X$z!z!z!z!z!z!y!y!z!y!z!y!z!z!z!y!z!z!z!z!z!y!z!z!z!z!z!y!z!z!z!",
"y!z!z!y!z!y!z!y!y!y!z!z!z!z!y!R!z!z!z!y!z!z!R!y!y!z!z!y!z!z!z!z!z!j'j'x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)j'v!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$z!y!X$O*X$|&X$y!R!y!y!y!z!z!y!R!z!z!R!z!y!z!y!y!z!y!y!R!y!R!y!y!y!z!y!z!z!z!",
"z!R!y!z!y!z!R!R!R!z!y!R!z!y!z!y!y!y!y!z!R!y!y!z!z!y!y!z!y!z!z!j'v!v!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)j'j'v!v!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)_!v!j'j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$y!z!X$S!X$g=X$z!y!R!R!z!z!y!R!z!y!y!y!y!z!y!z!z!y!z!z!z!z!y!z!R!R!z!R!y!y!y!",
"y!R!R!R!z!y!z!z!R!z!y!y!R!z!z!R!R!R!z!y!z!z!R!z!z!R!y!R!y!j'v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'n)y'j'v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%x%X$X$X$z!T!X$O*U!X$**X$z!z!y!z!y!z!y!y!z!z!z!R!y!z!z!z!R!z!z!y!R!z!z!y!z!y!z!z!R!R!z!",
"z!z!y!z!y!z!y!y!y!R!z!R!z!y!R!z!z!z!y!z!R!y!z!y!R!z!R!j'v!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'n)V!)!)!)!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!v!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$X$R!X$X$z;q,;>X$X$X$z!z!z!R!z!z!R!z!R!R!y!z!R!R!y!y!z!y!y!z!y!z!y!z!z!R!y!z!z!z!R!",
"z!z!z!R!R!R!R!z!z!R!z!y!R!y!R!y!z!R!R!y!R!y!R!z!j'j'v!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$X$z!X$X$X$W!1,X$f,X$X!y!R!y!R!R!z!R!y!z!R!z!z!z!R!R!y!R!R!R!z!y!R!R!y!y!R!y!y!z!y!z!",
"R!R!y!z!z!z!z!R!y!y!R!R!z!z!y!R!R!R!z!z!z!j'j'j'j'x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!~!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$X$X$Y!X$X$X$0%Q&6%X$k-0%X$R!R!y!R!z!y!y!z!R!y!R!y!R!y!z!R!R!R!z!z!R!R!R!z!R!R!z!R!R!y!R!R!",
"R!R!R!y!R!R!y!R!z!y!z!y!R!z!R!y!Z!j'j'v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!_!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$X$X$X$X$X$X$X$6%`!6%6%X$$*X$ ~R!R!z!R!R!R!y!z!R!z!R!y!R!R!z!z!z!R!y!z!R!z!y!R!z!R!z!R!R!z!z!R!",
"z!R!z!R!R!y!.~R!R!R!R!v!v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-))!_!+~j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$X$6%6%6%6%6%:%X$O=X$X$@~R! ~R!y!z!R!.~R!R!R!z!R!z!z!R!R!y!z!R!y!z!y!.~R!R!y!R!z!R!R!y!z!",
"j'R!R!z!R!j'j'v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-))!_!(!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$6%6%6%6%6%6%6%6%6%!%X$X$[%#~X$X$z! ~z!R!R!z!z!z!R!z!R!R!R!y!y!R!.~R!R!R!y!.~z!z!R!R!y!R!R!R!R!R!R!",
"v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)$~A!v![%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'i![%!%!%!%!%!%!%!%X$X$X$X$X$X$[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$6%6%6%6%6%6%6%!%!%!%!%X$[%[%9'X$X$ ~y! ~y!R!R!R!R!R!z!R!R!R!R!R!.~R!z!z!R!R!.~R!y!R!y!R!.~R!z!R!R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)_!%~v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'i!i!i!i![%[%[%[%[%[%[%[%[%[%[%X$X$X$X$i!+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%!%!%!%!%!%!%!%!%X$[%[%[%&~X$*~.~ ~=~R!z!R!y!R!R!R!z!z!R!R!z!y!R!R!z!R!z!z!R!y!.~R!R!z!R!y!R!z!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!-~j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%i!X$X$X$X$X$i!i!i!i![%[%[%[%[%[%[%X$X$X$+'+'+'i!+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%!%!%!%!%!%!%X$X$X$[%[%[%X$X$;~>~R! ~R!R!R!R!.~R!R!R!R!R!R!R!R!.~R!R!R!R!R!R!R!.~R!R!R!R!R!.~R!R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y)-))!(!-~j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'X$X$X$X$X$X$i!i!i![%[%[%X$X$X$+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$,~ ~R!'~R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!)~R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'z)-))!_!!~j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'X$X$X$X$X$X$X$X$X$X$+'+'+'!%+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$,~ ~ ~~~R!R!R!R!R!R!R!R!)~)~R!R!R!R!R!R!)~R!R!R!R!R!R!R!R!)~R!R!R!R!R!R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y){~]~)!)!!~j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%!%!%!%!%!%!%!%!%[%[%[%[%:%:%X$^~R!/~(~)~R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!)~)~R!R!R!R!R!R!)~R!R!R!R!R!R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)y)]~)!(!v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'+'+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%:%X$X$_~R!R!R!R!)~)~R!R!R!R!R!R!R!)~.~)~R!R!)~R!.~R!R!.~R!R!R!R!R!R!R!R!R!R!R!.~R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y)-)-))!)!v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$X$R!:~~~)~.~R!.~R!R!R!R!)~R!R!R!R!R!.~R!R!R!R!R!R!R!R!)~.~R!R!.~.~R!R!R!.~R!.~R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)]~-)y))!_!v!j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%:%:%X$X$X$X$R!.~R!.~R!.~R!.~.~)~)~R!)~R!)~R!R!R!R!R!.~R!R!.~R!.~.~R!)~)~R!R!.~)~R!R!R!R!.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)O)-)F))!)!_!j'j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%:%[%X$X$X$X$.~R!.~R!R!R!R!R!.~.~.~R!.~)~.~)~)~R!.~.~R!)~.~R!.~R!R!R!.~.~R!)~R!.~.~R!)~R!R!)~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)F)-)F))!(!j'j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%:%:%:%X$X$X$X$_~.~R!)~R!.~.~.~.~R!R!R!R!.~R!.~R!.~R!.~R!R!)~.~R!.~R!)~.~)~R!R!.~.~R!.~R!.~.~.~R!.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)F)-)F))!_!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%:%:%:%:%:%:%X$X$X$X$<~[~ ~.~.~.~R!R!R!R!.~R!R!.~R!.~R!.~.~.~R!.~.~.~R!.~R!R!.~R!.~.~R!R!.~.~R!.~R!R!R!.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)F))!)!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%:%:%:%==}~X$X$X$|~ ~R!_~1~R!.~R!.~R!.~.~.~.~.~R!.~R!.~R!R!.~.~R!.~.~.~R!.~.~R!.~R!R!.~.~R!R!.~R!.~.~.~.~R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-))!)!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%2~X$X$X$3~4~1~_~.~.~.~R!.~R!.~.~R!R!R!)~.~R!.~R!.~.~R!.~.~R!R!.~.~R!R!.~R!.~.~.~R!.~.~R!.~R!.~.~R!.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)_!)!j'j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%[%[%[%[%[%[%[%:%:%:%X$X$X$X$X$5~.~.~ ~6~R!R!R!R!.~.~.~.~R!.~.~.~.~.~.~)~.~)~.~.~.~.~.~.~R!.~.~.~.~.~R!.~R!.~.~.~.~.~.~R!R!.~.~.~)~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-))!)!w)w):%:%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$:%:%:%:%:%:%:%:%:%:%:%:%:%[%:%:%:%:%:%:%==X$X$X$X$7~:~8~.~R!.~.~R!.~.~.~.~.~R!.~)~.~.~.~.~.~)~.~.~.~.~)~.~)~R!.~.~.~.~.~)~)~.~.~.~.~.~.~)~.~)~.~.~.~.~)~R!.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-))!_!(!j'w):%:%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$X$X$X$X$X$X$X$X$X$:%:%:%:%:%:%:%:%X$X$X$X$X$X$X$9~1~_~_~.~)~_~.~.~.~.~.~.~.~.~.~)~.~.~.~.~)~)~.~.~.~.~.~.~)~.~.~.~.~.~)~)~.~.~.~.~)~.~R!.~.~)~.~.~.~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!0~j'j'X$:%:%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$a~.~.~.~.~.~.~.~.~.~.~.~.~)~.~.~.~.~.~)~.~.~.~.~.~.~.~.~.~.~.~.~)~)~.~.~.~.~.~)~.~.~.~b~.~.~.~.~.~.~.~)~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'X$X$:%:%[%[%[%[%[%[%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$c~>~.~d~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'X$X$X$:%[%[%[%[%[%[%!%6%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$b~b~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'X$X$X$:%:%[%[%[%[%[%!%6%6%:%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$e~.~_~.~f~c~.~.~.~.~.~.~.~.~b~.~.~b~.~.~.~.~.~.~.~.~.~.~b~.~.~b~.~.~.~.~.~.~.~.~.~.~b~.~.~.~b~b~.~b~.~.~.~.~b~.~.~.~.~.~.~.~.~b~.~b~b~.~.~.~.~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'.~b~g~X$X$:%:%[%[%[%[%!%6%6%6%:%X$:%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$.~b~b~b~b~.~.~b~.~b~.~.~b~b~.~b~.~b~b~.~.~.~.~b~.~.~.~b~.~b~.~b~b~.~h~h~.~.~b~.~b~b~.~.~.~b~.~.~b~h~.~.~b~.~.~.~b~b~b~b~.~b~.~.~b~.~b~b~.~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'b~i~.~X$X$:%:%:%[%[%[%[%!%6%6%X$X$X$:%:%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$.~.~.~b~b~.~b~.~b~.~.~.~.~.~h~.~h~b~b~b~b~.~h~h~b~.~h~.~b~.~.~b~.~.~b~b~.~b~.~.~b~.~.~h~.~.~h~.~h~.~h~b~b~h~.~.~.~.~.~h~b~.~h~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'h~.~b~b~X$X$:%:%:%[%[%[%[%!%6%X$X$X$X$:%:%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%6%6%6%:%X$X$X$X$X$X$X$X$X$X$X$X$X$b~.~b~.~.~.~.~.~h~.~.~.~.~.~.~h~.~.~h~b~.~.~.~.~.~h~.~.~h~h~h~.~.~.~h~h~.~.~.~h~.~h~.~.~b~b~.~h~.~.~.~h~.~b~.~b~.~h~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'h~.~b~.~.~b~X$X$:%:%:%[%[%[%[%6%6%X$X$X$X$X$:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%:%:%:%:%:%X$X$X$X$X$X$X$b~h~h~.~h~.~h~.~b~.~h~b~b~.~.~.~h~.~h~h~h~b~b~h~.~.~b~.~.~.~.~h~b~.~.~b~.~.~.~.~.~h~.~.~h~h~.~b~b~.~.~.~h~b~.~b~.~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!v!j'b~h~b~h~.~.~b~X$X$:%:%:%[%[%[%[%6%6%X$.~X$X$X$X$:%:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%[%[%:%:%:%:%:%:%X$X$X$b~b~h~.~.~b~.~b~.~b~.~h~.~.~.~b~b~b~.~b~.~.~.~.~h~.~b~b~.~.~b~b~h~.~.~b~b~.~h~h~b~b~b~.~b~h~.~.~b~.~b~h~b~h~.~h~h~h~.~h~h~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!v!j'.~.~h~b~b~b~h~b~X$X$[%:%:%[%[%:%:%6%X$X$b~.~X$X$X$X$X$:%:%:%:%:%:%[%:%:%:%:%:%[%[%[%[%[%[%[%[%[%[%:%:%:%:%X$X$j~k~h~h~.~b~b~h~b~.~b~b~h~b~b~b~h~h~.~h~b~.~b~b~b~h~.~.~b~h~b~b~h~b~b~b~b~h~b~h~.~.~b~h~.~b~h~.~b~.~b~h~h~.~.~.~b~.~.~.~h~.~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'.~.~b~h~h~.~h~h~h~X$X$X$:%:%:%[%:%:%6%X$X$.~.~X$X$X$X$X$[%[%[%[%:%:%:%:%[%[%[%[%[%[%[%[%[%[%[%:%:%:%l~X$X$m~_~n~.~.~h~h~h~.~h~h~h~h~b~.~h~h~b~b~h~b~h~h~h~h~h~.~b~b~h~b~h~h~.~h~.~h~h~.~h~.~b~b~h~.~h~.~.~b~h~b~b~b~.~b~h~b~h~b~b~h~b~b~b~h~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'h~h~h~.~b~b~b~b~.~X$X$X$X$:%:%:%[%:%:%6%X$h~b~b~o~X$X$X$X$X$X$X$X$X$X$:%:%:%:%:%:%:%:%:%:%:%:%:%:%X$X$X$k~p~h~o~b~b~b~.~.~b~b~b~.~.~.~h~.~.~b~.~b~.~b~b~.~.~.~b~b~h~.~.~b~.~b~.~b~.~.~b~b~b~h~h~.~b~b~h~b~h~.~b~h~h~b~h~b~h~.~h~h~b~.~h~h~b~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'b~b~h~.~h~.~h~h~b~b~X$X$X$X$:%:%:%:%:%:%X$X$b~h~h~n~q~h~X$X$X$X$X$X$X$X$X$X$X$X$X$:%:%:%X$X$X$X$X$r~k~c~h~o~h~h~h~b~b~b~h~b~b~b~b~h~b~b~h~h~h~b~h~.~h~b~h~b~h~h~b~h~h~h~b~b~b~h~b~h~h~b~h~b~.~h~h~h~b~h~b~b~h~.~.~h~b~.~b~b~b~b~h~h~.~.~h~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~b~b~h~b~h~.~b~h~h~b~b~X$X$X$:%:%:%[%:%:%X$X$_~.~h~s~b~h~b~b~t~b~b~b~X$X$X$X$X$X$X$X$X$X$u~s~k~_~b~b~h~.~b~b~b~b~h~h~h~b~h~h~h~h~b~b~h~b~.~b~h~b~t~b~h~b~h~b~.~h~b~b~.~h~h~h~b~h~b~b~h~b~h~h~b~b~.~h~b~h~h~.~h~b~b~b~h~h~h~h~b~.~b~h~h~b~h~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'h~b~b~h~b~b~b~b~b~b~h~b~h~X$X$X$X$:%:%:%:%:%X$X$v~b~h~b~h~h~b~h~b~b~b~b~b~h~b~h~b~h~b~h~b~b~b~h~h~h~b~t~h~b~h~h~b~.~b~b~b~.~b~b~h~h~b~h~h~h~b~h~b~h~b~b~b~h~h~b~b~h~h~b~b~h~h~b~b~h~b~h~b~b~b~b~h~b~h~b~b~t~b~h~h~h~b~b~b~b~h~t~h~b~b~b~b~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'j'b~t~h~b~h~t~h~h~h~h~b~b~b~h~h~X$X$X$:%:%:%:%:%X$X$w~b~h~h~b~h~b~h~h~h~h~h~b~h~b~h~b~h~b~h~h~h~b~b~b~h~b~b~h~b~b~h~t~t~h~h~t~h~t~b~t~h~b~t~b~h~b~h~b~b~h~h~b~b~h~t~b~b~h~h~b~b~h~t~b~h~b~h~h~t~h~b~b~b~h~h~b~h~b~b~b~h~h~h~h~b~b~t~h~b~h~h~h~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~b~b~t~b~b~b~b~b~b~h~t~h~b~b~b~b~X$X$X$X$X$:%:%:%X$X$x~b~h~b~h~h~b~b~b~b~h~b~h~t~t~b~h~b~b~b~h~h~h~t~h~h~b~h~h~h~b~b~b~b~b~b~b~h~b~b~h~b~t~b~t~b~h~h~b~t~h~t~b~h~t~h~b~b~h~h~b~b~h~h~h~h~t~b~b~h~h~h~b~b~h~b~h~b~h~h~b~b~b~h~b~b~t~t~h~b~b~b~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~h~t~b~t~h~t~h~h~t~b~h~b~h~t~t~t~h~t~X$X$X$X$X$:%X$X$X$X$b~h~t~b~t~t~t~h~h~t~h~b~b~h~b~t~h~h~t~t~b~b~t~t~h~t~b~b~h~h~t~h~h~h~h~b~h~h~b~h~b~h~b~h~b~t~t~b~b~b~h~b~b~b~t~h~t~b~t~h~b~b~b~b~b~h~t~t~t~h~h~h~b~t~t~h~b~t~t~t~h~h~h~h~b~b~b~t~h~t~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~h~h~b~h~h~h~h~h~t~b~t~t~b~h~h~b~t~h~t~y~X$X$X$X$X$X$X$X$X$b~h~h~b~b~t~t~b~b~h~t~t~h~b~t~t~b~b~h~h~b~b~t~b~t~t~b~t~h~t~t~t~t~t~b~h~t~b~h~t~h~t~t~b~b~h~t~h~t~h~h~h~h~t~b~h~b~h~t~t~t~h~t~h~b~b~b~b~b~t~h~b~b~t~h~b~h~h~h~t~b~b~h~h~h~h~t~t~t~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~b~t~t~b~h~t~b~b~b~t~h~b~t~b~h~t~b~b~h~h~b~z~X$X$X$X$X$X$X$X$t~b~t~h~b~b~h~t~t~h~b~t~t~b~b~t~h~b~t~h~t~b~t~h~h~t~b~t~b~b~b~b~h~h~t~b~t~t~b~t~b~b~t~h~t~h~t~b~t~b~t~t~b~h~t~h~b~h~b~h~h~b~t~t~h~h~t~t~b~t~t~t~b~t~h~b~t~t~b~t~t~t~t~b~b~b~b~t~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j't~b~h~t~b~b~t~t~t~t~b~h~h~t~b~t~t~t~t~b~t~A~B~t~t~t~t~b~X$X$X$X$h~t~t~t~t~h~b~t~t~b~h~t~h~h~t~t~b~t~b~t~h~t~b~h~t~b~h~t~t~t~t~t~b~t~h~b~t~b~t~t~h~t~b~t~b~t~b~t~b~b~t~t~h~t~t~b~t~t~t~t~b~h~t~t~h~h~t~b~h~h~t~b~t~t~b~b~h~h~b~b~t~t~t~h~t~b~t~t~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~t~t~h~t~t~h~t~h~b~t~t~t~h~t~h~h~t~b~t~t~t~t~h~b~h~h~t~h~b~t~t~b~h~h~h~b~t~t~b~b~t~t~h~t~t~b~h~t~b~t~h~t~b~t~b~h~t~t~h~h~h~b~b~t~h~t~t~h~t~t~h~t~b~t~b~t~h~t~h~t~t~t~b~t~h~h~t~h~b~b~h~t~t~h~b~t~t~h~t~t~t~h~t~b~b~t~t~t~t~t~t~b~t~h~t~h~t~t~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~b~t~t~h~t~h~t~t~t~h~b~t~t~b~t~b~t~t~h~t~b~t~t~b~b~t~t~t~h~h~t~b~t~t~t~b~h~t~t~t~b~t~b~b~t~t~h~t~h~t~b~t~h~t~t~h~t~t~t~t~t~t~h~t~t~h~t~h~h~t~b~t~h~t~t~t~t~t~h~h~b~t~t~t~t~b~t~t~t~t~b~b~t~t~t~t~t~b~t~b~t~t~t~t~h~h~h~b~h~h~t~b~t~t~t~h~h~b~t~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)-)t~t~b~h~t~b~t~b~h~t~b~t~b~h~t~t~t~t~h~t~t~t~h~t~t~t~h~b~t~t~t~t~t~t~t~t~t~t~t~t~h~t~t~t~t~t~t~t~h~t~h~t~t~t~t~t~t~b~t~b~b~t~t~t~b~b~t~t~t~t~h~t~t~t~b~t~h~b~t~t~t~t~t~b~b~t~t~t~h~t~t~t~t~t~b~t~b~t~t~h~t~b~t~h~t~t~t~t~t~t~t~t~t~t~b~b~t~b~t~t~"};

Added modules/lcdui-demo/build.gradle.





































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidlet
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This is a demo which is used to demonstrate " +
	"how the graphic operations operate."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AW"
	swmType = JavaMEMidletType.APPLICATION
	swmName = "LCDUI Graphics Demo"
	swmVendor = "Stephanie Gawroriski"
	midlets += new JavaMEMidlet("Font Demo", "fonts.xpm",
		"net.multiphasicapps.lcduidemo.Fonts")
	midlets += new JavaMEMidlet("Mystify Your Squirrels!", "mystify.xpm",
		"net.multiphasicapps.lcduidemo.Mystify")
	midlets += new JavaMEMidlet("Events Demo", "event.xpm",
		"net.multiphasicapps.lcduidemo.Events")
	midlets += new JavaMEMidlet("List Demo", "list.xpm",
		"net.multiphasicapps.lcduidemo.Lists")
	midlets += new JavaMEMidlet("Image Demo (XPM)", "image.xpm",
		"net.multiphasicapps.lcduidemo.XPMDemo")
	midlets += new JavaMEMidlet("Image Demo (PNG)", "image.xpm",
		"net.multiphasicapps.lcduidemo.PNGDemo")
	midlets += new JavaMEMidlet("Image Demo (JPEG)", "image.xpm",
		"net.multiphasicapps.lcduidemo.JPEGDemo")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-midlet")
	implementation project(":modules:midp-lcdui")
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/AbstractImageDemo.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.lcduidemo;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is the base for image demos.
 *
 * @since 2019/04/15
 */
public abstract class AbstractImageDemo
	extends MIDlet
{
	/** No mirrors. */
	private static final int[] _NO_MIRROR =
		new int[]{Sprite.TRANS_NONE, Sprite.TRANS_ROT90,
			Sprite.TRANS_ROT180, Sprite.TRANS_ROT270};
			
	/** Mirrors. */
	private static final int[] _MIRROR =
		new int[]{Sprite.TRANS_MIRROR, Sprite.TRANS_MIRROR_ROT90,
			Sprite.TRANS_MIRROR_ROT180, Sprite.TRANS_MIRROR_ROT270};
	
	/** The image to use. */
	protected final Image image;
	
	/**
	 * Initializes the image demo.
	 *
	 * @param __in Input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	public AbstractImageDemo(InputStream __in)
		throws NullPointerException
	{
		// Load image data
		try
		{
			this.image = Image.createImage(__in);
		}
		
		// Fail
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas(this.image);
		cv.setTitle("Image Demo");
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * The demo canvas which does the drawing.
	 *
	 * @since 2019/04/15
	 */
	public static final class DemoCanvas
		extends Canvas
	{
		/** The image to draw. */
		protected final Image image;
		
		/**
		 * Initializes the demo canvas.
		 *
		 * @param __i The image to use.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/15
		 */
		public DemoCanvas(Image __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.image = __i;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/22
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Get image
			Image image = this.image;
			int w = image.getWidth(),
				h = image.getHeight();
			
			// Base Y position
			int basey = 0;
			
			// Draw portions of the image
			for (int i = 0; i < 4; i++)
			{
				// Determine x and y offset
				int xoff = (((i & 0b01) == 0) ? 0 : w >>> 1),
					yoff = (((i & 0b10) == 0) ? 0 : h >>> 1);
				
				// Source X and Y dimensions
				int sx = xoff,
					sy = yoff,
					sw = w - xoff,
					sh = h - yoff;
				
				// Non-mirrored rotations
				for (int j = 0; j < AbstractImageDemo._NO_MIRROR.length; j++)
					__g.drawRegion(image, sx, sy, sw, sh,
						AbstractImageDemo._NO_MIRROR[j],
						(w * j), basey, 0);
				basey += h;
					
				// Mirrored rotations
				for (int j = 0; j < AbstractImageDemo._MIRROR.length; j++)
					__g.drawRegion(image, sx, sy, sw, sh,
						AbstractImageDemo._MIRROR[j],
						(w * j), basey, 0);
				basey += h;
			}
		}
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/Events.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This example project handles events and allows for some interaction based
 * on buttons and such.
 *
 * @since 2018/12/01
 */
public class Events
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * Converts the game code to a string.
	 *
	 * @param __gc The game code.
	 * @return The string for this game code.
	 * @since 2018/12/02
	 */
	static final String __gamecodeToString(int __gc)
	{
		switch (__gc)
		{
			case 0:					return "Unknown";
			
			case Canvas.UP:			return "Up";
			case Canvas.DOWN:		return "Down";
			case Canvas.LEFT:		return "Left";
			case Canvas.RIGHT:		return "Right";
			
			case Canvas.FIRE:		return "Fire";
			
			case Canvas.GAME_A:		return "A";
			case Canvas.GAME_B:		return "B";
			case Canvas.GAME_C:		return "C";
			case Canvas.GAME_D:		return "D";
			
			default:				return "Invalid";
		}
	}
	
	/**
	 * The demo canvas which does the event handling and other things.
	 *
	 * @since 2018/12/01
	 */
	public static final class DemoCanvas
		extends Canvas
	{
		/** The number of times this was shown. */
		volatile int _numshown;
		
		/** The number of times this was hidden. */
		volatile int _numhides;
		
		/** Pointer position. */
		volatile int _pointerx,
			_pointery;
		
		/** Pointer event type. */
		volatile PointerType _pointertype;
		
		/** The number of key events which happened. */
		volatile int _numkeys;
		
		/** The last key event. */
		volatile int _keycode;
		
		/** The last key done. */
		volatile KeyboardType _keyboardtype;
		
		/**
		 * Initializes the canvas.
		 *
		 * @since 2018/12/01
		 */
		{
			// Setup title
			this.setTitle("Events");
			
			// Draw as opaque, so we do not need to update everything
			this.setPaintMode(false);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void hideNotify()
		{
			this._numhides++;
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyPressed(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.PRESSED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Pressed: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyReleased(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.RELEASED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Released: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyRepeated(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.REPEATED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Repeated: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void paint(Graphics __g)
		{
			Font font = __g.getFont();
			int height = font.getHeight(),
				x = 2,
				y = 2 - height,
				keycode = this._keycode,
				gamecode = -1;
			
			// Get the key name, but it might not even be valid
			String keyname = null;
			try
			{
				keyname = this.getKeyName(keycode);
				gamecode = this.getGameAction(keycode);
			}
			catch (IllegalArgumentException e)
			{
			}
			
			// Draw text info
			__g.drawString(String.format("Showns: %d", this._numshown),
				x, y += height, 0);
			__g.drawString(String.format("Hides: %d", this._numhides),
				x, y += height, 0);
			__g.drawString(String.format("Pointer: (%d, %d) %s",
				this._pointerx, this._pointery, this._pointertype),
				x, y += height, 0);
			__g.drawString(String.format(
				"Key: \"%s\" (Code=%d Game=%s) %s [Count=%d]",
				keyname, keycode, Events.__gamecodeToString(gamecode),
				this._keyboardtype, this._numkeys),
				x, y += height, 0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerDragged(int __x, int __y)
		{
			this._pointertype = PointerType.DRAGGED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerPressed(int __x, int __y)
		{
			this._pointertype = PointerType.PRESSED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerReleased(int __x, int __y)
		{
			this._pointertype = PointerType.RELEASED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void showNotify()
		{
			this._numshown++;
			
			// Repaint to update stuff
			this.repaint();
		}
	}
	
	/**
	 * The type of keyboard event which happened.
	 *
	 * @since 2018/12/01
	 */
	public static enum KeyboardType
	{
		/** Pressed. */
		PRESSED,
		
		/** Released. */
		RELEASED,
		
		/** Repeated. */
		REPEATED,
		
		/** End. */
		;
	}
	
	/**
	 * The type of pointer event which happened.
	 *
	 * @since 2018/12/01
	 */
	public static enum PointerType
	{
		/** Pressed. */
		PRESSED,
		
		/** Released. */
		RELEASED,
		
		/** Dragged. */
		DRAGGED,
		
		/** End. */
		;
	}
}

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

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * This is an exit command which terminates the application.
 *
 * @since 2018/12/02
 */
public class Exit
	implements CommandListener
{
	/** The command used to exit. */
	public static final Command command =
		new Command("Exit", Command.EXIT, 1);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void commandAction(Command __c, Displayable __d)
	{
		// Exiting the VM?
		if (__c == Exit.command)
		{
			System.exit(0);
		}
	}
}

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

package net.multiphasicapps.lcduidemo;

import java.util.ArrayList;
import java.util.List;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Font demo, this essentially just draws the fonts which are available.
 *
 * @since 2018/11/23
 */
public class Fonts
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/23
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/23
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * The demo canvas which does the animation.
	 *
	 * @since 2018/11/23
	 */
	public static final class DemoCanvas
		extends Canvas
	{
		/** Fonts to use. */
		private final Font[] _fonts;
		
		/**
		 * Initializes the canvas.
		 *
		 * @since 2018/11/23
		 */
		{
			this.setTitle("Font Demo");
			
			// Draw as transparent
			this.setPaintMode(false);
			
			// Try to get fonts of various pixel sizes
			List<Font> fonts = new ArrayList<>();
			for (Font f : Font.getAvailableFonts())
				for (int i = 4; i <= 36; i += 4)
					try
					{
						fonts.add(f.deriveFont(i));
					}
					catch (IllegalArgumentException e)
					{
					}
			
			// Set font list
			this._fonts = fonts.<Font>toArray(new Font[fonts.size()]);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/23
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Start position
			int x = 10,
				y = 10;
			
			// Draw a sample for each font, for each size!
			for (Font f : this._fonts)
			{
				// Use this font
				__g.setFont(f);
				
				// Yes I do know buried is spelt wrong, but this is staying
				// here because a transphobe troll searched through all of my
				// images on Twitter and chose to insult me here. So this is
				// here to spite them.
				__g.drawString("The quick gray squirrel Xer burried all of " +
					"her acorns! <3 0123456789",
					x, y, Graphics.BASELINE);
				
				// Move position up
				y += f.getHeight();
				
				// Draw sample
				__g.drawString("abcdefghijklmnopqrstuvwxyz " +
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ 01234567890!@#$%^&*()",
					x, y, Graphics.BASELINE);
					
				// Move position with some more room
				y += f.getHeight() + 3;
			}
		}
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/JPEGDemo.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 net.multiphasicapps.lcduidemo;


/**
 * This is the JPEG demo.
 *
 * @since 2019/05/05
 */
public final class JPEGDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/05/05
	 */
	public JPEGDemo()
	{
		super(JPEGDemo.class.getResourceAsStream("image.jpg"));
	}
}

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

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is a demo for lists.
 *
 * @since 2018/12/02
 */
public class Lists
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup list
		List list = new List("List Demo", List.MULTIPLE);
		
		// Exit command
		list.addCommand(Exit.command);
		list.setCommandListener(new Exit());
		
		// Add things to the list
		list.append("Sciurus aberti", null);
		list.append("Sciurus aestuans", null);
		list.append("Sciurus alleni", null);
		list.append("Sciurus anomalus", null);
		list.append("Sciurus arizonensis", null);
		list.append("Sciurus aureogaster", null);
		list.append("Sciurus carolinensis", null);
		list.append("Sciurus colliaei", null);
		list.append("Sciurus deppei", null);
		list.append("Sciurus flammifer", null);
		list.append("Sciurus gilvigularis", null);
		list.append("Sciurus granatensis", null);
		list.append("Sciurus griseus", null);
		list.append("Sciurus ignitus", null);
		list.append("Sciurus igniventris", null);
		list.append("Sciurus kaibabensis", null);
		list.append("Sciurus lis", null);
		list.append("Sciurus nayaritensis", null);
		list.append("Sciurus niger", null);
		list.append("Sciurus oculatus", null);
		list.append("Sciurus pucheranii", null);
		list.append("Sciurus pyrrhinus", null);
		list.append("Sciurus richmondi", null);
		list.append("Sciurus sanborni", null);
		list.append("Sciurus spadiceus", null);
		list.append("Sciurus stramineus", null);
		list.append("Sciurus variegatoides", null);
		list.append("Sciurus vulgaris", null);
		list.append("Sciurus yucatanensis", null);
		
		// Use a certain font for some items
		list.setFont(2,
			Font.getFont(Font.FACE_SYSTEM, 0, Font.SIZE_SMALL));
		list.setFont(4,
			Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_MEDIUM));
		list.setFont(6,
			Font.getFont(Font.FACE_PROPORTIONAL, 0, Font.SIZE_MEDIUM));
		list.setFont(8,
			Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_SMALL));
		
		// Select some items for us
		list.setSelectedIndex(1, true);
		list.setSelectedIndex(6, true);
		list.setSelectedIndex(12, true);
		
		// Disable some items
		list.setEnabled(8, false);
		list.setEnabled(12, false);
		
		// Display the list
		Display.getDisplay(this).setCurrent(list);
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/Mystify.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import java.util.Random;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is a MIDlet which simulates the old-style Mystify Your Mind
 * screensaver from Windows 3.1.
 *
 * @since 2018/11/22
 */
public class Mystify
	extends MIDlet
{
	/** The number of polygon points. */
	public static final int NUM_POINTS =
		5;
	
	/** The number of shadows to draw. */
	public static final int NUM_SHADOWS =
		7;
	
	/** The maximum line speed. */
	public static final int MAX_SPEED =
		9;
	
	/** Use to detect way off coordinates. */
	public static final int WAY_OFF =
		50;
	
	/** How oftens the colors shift. */
	public static final int COLOR_SHIFT =
		2;
	
	/** The delay time. */
	public static final int DELAY_TIME =
		250;
	
	/** Delay time in nanoseconds. */
	public static final long DELAY_TIME_NS = Mystify.DELAY_TIME * 1_000_000L;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
		
		// Setup thread to force repaints on canvas
		new RepaintTimer(cv, Mystify.DELAY_TIME).start();
	}
	
	/**
	 * The demo canvas which does the animation.
	 *
	 * @since 2018/11/22
	 */
	public static final class DemoCanvas
		extends Canvas
	{
		/** Random number generator for bounces and such. */
		protected final Random random =
			new Random();
		
		/** Points and their shadows. */
		protected final Point[][] points =
			new Point[Mystify.NUM_SHADOWS][Mystify.NUM_POINTS];
		
		/** Colors. */
		protected final int[] colors =
			new int[Mystify.NUM_SHADOWS];
		
		/** The direction of the points. */
		protected final Point[] direction =
			new Point[Mystify.NUM_POINTS];
		
		/** Update lock to prevent multiple threads updating at once. */
		private volatile boolean _lockflag;
		
		/** The last time an update happened. */
		private volatile long _nextnano =
			Long.MIN_VALUE;
		
		/**
		 * Initializes the canvas state.
		 *
		 * @since 2018/11/22
		 */
		{
			// Setup title
			this.setTitle("Mystify Your Squirrels");
			
			// Draw as transparent
			this.setPaintMode(false);
			
			// Setup points
			Point[][] points = this.points;
			
			// Generate random start points
			Random random = this.random;
			Point[] start = points[0];
			for (int i = 0; i < Mystify.NUM_POINTS; i++)
				start[i] = new Point(random.nextInt(), random.nextInt());
			
			// Copy all the points to the shadow
			for (int i = 1; i < Mystify.NUM_SHADOWS; i++)
				for (int j = 0; j < Mystify.NUM_POINTS; j++)
					points[i][j] = new Point(start[j]);
			
			// Initialize the color cycle
			int[] colors = this.colors;
			for (int i = 0; i < Mystify.NUM_SHADOWS; i++)
				colors[i] = random.nextInt();
			
			// Determine new directions for all the points
			Point[] direction = this.direction;
			for (int i = 0; i < Mystify.NUM_POINTS; i++)
				direction[i] = this.__newDirection(new Point(),
					random.nextBoolean(), random.nextBoolean());
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/22
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Get widget bounds
			int w = this.getWidth(),
				h = this.getHeight();
			
			// Needed for cycling	
			Random random = this.random;
			
			// Needed for drawing
			Point[][] points = this.points;
			Point[] direction = this.direction;
			int[] colors = this.colors;
			
			// Used to limit update rate
			long now = System.nanoTime(),
				nextnano = this._nextnano;
			
			// Draw every point, from older shadows to the newer shape
			for (int i = Mystify.NUM_SHADOWS - 1; i >= 0; i--)
			{
				Point[] draw = points[i];
				
				// Update the state of the demo, but keep it consistent so
				// that it is not always updating
				if (i == 0 && now >= nextnano)
				{
					// Only allow a single run to update this
					boolean lockflag;
					synchronized (this)
					{
						// Set the lock flag
						lockflag = this._lockflag;
						if (!lockflag)
							this._lockflag = true;
					}
					
					// If we did hit a false, we can update
					if (!lockflag)
						try
						{
							// Update the state
							this.__updateState(w, h);
						}
						finally
						{
							// Always clear the flag so another run can
							// have a go
							this._lockflag = false;
							
							// Update some other time in the future
							this._nextnano = System.nanoTime() + Mystify.DELAY_TIME_NS;
						}
				}
				
				// Set the color for this shadow
				__g.setColor(colors[i]);
				
				// Draw all the points
				for (int j = 0; j < Mystify.NUM_POINTS; j++)
				{
					// Get A and B points
					Point a = draw[j],
						b = draw[(j + 1) % Mystify.NUM_POINTS];
					
					// Draw line
					__g.drawLine(a.x, a.y, b.x, b.y);
				}
			}
		}
		
		/**
		 * Gives a new direction for the point.
		 *
		 * @param __p The input point to get a new direction for.
		 * @param __px Positive X?
		 * @param __py Positive Y?
		 * @return {@code __p}
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/22
		 */
		private Point __newDirection(Point __p, boolean __px, boolean __py)
			throws NullPointerException
		{
			if (__p == null)
				throw new NullPointerException("NARG");
			
			// Generate new speeds
			Random random = this.random;
			int x = random.nextInt(Mystify.MAX_SPEED) + 1,
				y = random.nextInt(Mystify.MAX_SPEED) + 1;
			
			// Flip signs?
			if (!__px)
				x = -x;
			if (!__py)
				y = -y;
			
			// set
			__p.x = x;
			__p.y = y;
			
			// Use that point
			return __p;
		}
		
		/**
		 * Updates the state of the demo.
		 *
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2018/11/22
		 */
		private void __updateState(int __w, int __h)
		{
			// Needed for cycling	
			Random random = this.random;
			
			// Base points to modify
			Point[] draw = this.points[0];
			
			// Needed for drawing
			Point[][] points = this.points;
			Point[] direction = this.direction;
			int[] colors = this.colors;
			
			// Move all the old points and colors down
			for (int j = Mystify.NUM_SHADOWS - 2; j >= 0; j--)
			{
				points[j + 1] = points[j];
				colors[j + 1] = colors[j];
			}
			
			// Allocate a new set of points offset in the directions
			Point[] place = new Point[Mystify.NUM_POINTS];
			for (int j = 0; j < Mystify.NUM_POINTS; j++)
			{
				// Get base coordinates
				int newx = draw[j].x,
					newy = draw[j].y;
				
				// Limit to the bounds of the screen. If a point is
				// way off, just choose a random point on the
				// screen instead
				if (newx < 0 || newx >= __w)
				{
					if (newx < -Mystify.WAY_OFF || newy > __w + Mystify.WAY_OFF)
						newx = random.nextInt((__w > 0 ? __w : 1));
					else
					{
						if (newx < 0)
							newx = 0;
						else if (newx >= __w)
							newx = __w;
					}
				}
				
				if (newy < 0 || newy >= __h)
				{
					if (newy < -Mystify.WAY_OFF || newy > __h + Mystify.WAY_OFF)
						newy = random.nextInt((__h > 0 ? __h : 1));
					else
					{
						if (newy < 0)
							newy = 0;
						else if (newy >= __h)
							newy = __h;
					}
				}
				
				// Move point in the target direction
				newx += direction[j].x;
				newy += direction[j].y;
				
				// Previous positive position?
				boolean ppx = (direction[j].x >= 0),
					ppy = (direction[j].y >= 0);
				
				// Deflect points?
				boolean defx = (newx <= 0 || newx >= __w),
					defy = (newy <= 0 || newy >= __h);
				
				// Deflect direction
				this.__newDirection(direction[j],
					ppx ^ defx, ppy ^ defy);
				
				// Make sure the points are not on a bound!
				if (defx)
					if (ppx)
						newx--;
					else
						newx++;
				if (defy)
					if (ppy)
						newx--;
					else
						newy++;
				
				// Extract the color
				int color = colors[j];
				byte r = (byte)((color & 0xFF0000) >>> 16),
					g = (byte)((color & 0x00FF00) >>> 8),
					b = (byte)((color & 0x0000FF));
				
				// Cycle the colors depending on the direction of travel
				r += (ppx ^ ppy ? +Mystify.COLOR_SHIFT : -Mystify.COLOR_SHIFT);
				g += (ppy | ppy ? -Mystify.COLOR_SHIFT : +Mystify.COLOR_SHIFT);
				b += (ppx ^ ppy ? -Mystify.COLOR_SHIFT : +Mystify.COLOR_SHIFT);
				
				// Recombine the color
				colors[j] = ((r & 0xFF) << 16) |
					((g & 0xFF) << 8) |
					(b & 0xFF);
				
				// Store the point
				place[j] = new Point(newx, newy);
			}
			
			// Use all these points
			points[0] = place;
		}
	}
	
	/**
	 * Volatile point information.
	 *
	 * @since 2018/11/22
	 */
	public static final class Point
	{
		/** X position. */
		public int x;
		
		/** Y position. */
		public int y;
		
		/**
		 * Initializes the point.
		 *
		 * @since 2018/11/22
		 */
		public Point()
		{
		}
		
		/**
		 * Initializes the point from another point.
		 *
		 * @param __p The point to copy.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/22
		 */
		public Point(Point __p)
			throws NullPointerException
		{
			if (__p == null)
				throw new NullPointerException("NARG");
			
			this.x = __p.x;
			this.y = __p.y;
		}
		
		/**
		 * Initializes the point from the given coordinates.
		 *
		 * @param __x The X coordinate.
		 * @param __y The Y coordinate.
		 * @since 2018/11/22
		 */
		public Point(int __x, int __y)
		{
			this.x = __x;
			this.y = __y;
		}
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/PNGDemo.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 net.multiphasicapps.lcduidemo;

/**
 * This is the PNG demo.
 *
 * @since 2019/04/15
 */
public final class PNGDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/04/15
	 */
	public PNGDemo()
	{
		super(PNGDemo.class.getResourceAsStream("image.png"));
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/RepaintTimer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Canvas;

/**
 * This is a thread which does timing.
 *
 * @since 2018/11/22
 */
public class RepaintTimer
	extends Thread
{
	/** Canvas to repaint. */
	protected final Canvas canvas;
	
	/** The delay. */
	protected final int delay;
	
	/**
	 * Initialize the timer.
	 *
	 * @param __c The canvas to redraw.
	 * @param __ms The millisecond delay.
	 * @throws IllegalArgumentException If the delay is zero or negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public RepaintTimer(Canvas __c, int __ms)
		throws IllegalArgumentException, NullPointerException
	{
		super("LCDUIDemoRepaintTimer");
		
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AW01 The timer cannot be zero or negative.}
		if (__ms <= 0)
			throw new IllegalArgumentException("AW01");
		
		this.canvas = __c;
		this.delay = __ms;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void run()
	{
		Canvas canvas = this.canvas;
		int delay = this.delay;
		
		// Infinite loop
		for (;;)
		{
			// Stop if there is no display
			if (canvas.getCurrentDisplay() == null)
				break;
			
			// Repaint
			canvas.repaint();
			
			// Sleep
			try
			{
				Thread.sleep(delay);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/XPMDemo.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 net.multiphasicapps.lcduidemo;

/**
 * This is the XPM demo.
 *
 * @since 2019/04/15
 */
public final class XPMDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/04/15
	 */
	public XPMDemo()
	{
		super(XPMDemo.class.getResourceAsStream("image.xpm"));
	}
}

Added modules/lcdui-demo/src/main/java/net/multiphasicapps/lcduidemo/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the graphics demonstration which shows graphics
 * rendering and such.
 *
 * @since 2018/03/23
 */

package net.multiphasicapps.lcduidemo;

Added modules/lcdui-demo/src/main/resources/event.xpm.

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\event_xpm[] = {
"16 16 5 1",
" 	c #FFFFFF",
".	c #000000",
"+	c #FF0000",
"@	c #00FF00",
"#	c #0000FF",
"                ",
"   .....        ",
"   .+++.        ",
"   .+++.        ",
"   .....        ",
"     .          ",
"     .          ",
"  ........      ",
"  .      .      ",
"  .      .      ",
"  .      .      ",
" ....   ...     ",
" .@@.  .###.    ",
" .@@.  .###.    ",
" ....   ...     ",
"                "};

Added modules/lcdui-demo/src/main/resources/fonts.xpm.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\fonts_xpm[] = {
"16 16 2 1",
" 	c #FFFFFF",
".	c #000000",
"                ",
"    .. .....    ",
"   . .  .   .   ",
"  .  .  .   .   ",
"  ....  ....    ",
"  .  .  .   .   ",
"  .  .  .   .   ",
" ..  . .....    ",
"                ",
"                ",
"   .  ..   ..   ",
"  . . . . .     ",
"  ... ..  .     ",
"  . . . . .     ",
"  . . ..   ..   ",
"                "};

Added modules/lcdui-demo/src/main/resources/image.xpm.



























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\image_xpm[] = {
"16 16 7 1",
" 	c #FFFFFF",
".	c #000000",
"+	c #2ED2D5",
"@	c #FFE142",
"#	c #6FB642",
"$	c #5F2616",
"%	c #00BB00",
"                ",
"                ",
" .............. ",
" .++++++++@++@. ",
" .+++++++++@@+. ",
" .+++###+++@@+. ",
" .++#####+@++@. ",
" .+++###++++++. ",
" .++++$+++++++. ",
" .++++$+++++++. ",
" .++++$+++++++. ",
" .%%%%%%%%%%%%. ",
" .%%%%%%%%%%%%. ",
" .............. ",
"                ",
"                "};

Added modules/lcdui-demo/src/main/resources/list.xpm.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\list_xpm[] = {
"16 16 2 1",
" 	c #FFFFFF",
".	c #000000",
"                ",
"                ",
" .. ..........  ",
" .. ..........  ",
"                ",
" .. ....        ",
" .. ....        ",
"                ",
" .. ......      ",
" .. ......      ",
"                ",
" .. ..          ",
" .. ..          ",
"                ",
"                ",
"                "};

Added modules/lcdui-demo/src/main/resources/mystify.xpm.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\mystify_xpm[] = {
"16 16 4 1",
" 	c #FFFFFF",
".	c #00C0C4",
"+	c #00C484",
"@	c #00C400",
"         .      ",
"        . .     ",
"       .   .    ",
"    ++.++++ ..  ",
"   + .     + ...",
"  +.. @@@@@+   .",
"  .  @    + @ . ",
" .  @     + @.  ",
".+ @      + .   ",
"+.@      +  .   ",
"+@.     +  .@   ",
" +@.    +  .@   ",
"  +@... +  .@   ",
"   +@  .   .@   ",
"    +@+@.@.@@   ",
"     ++  .      "};

Added modules/lcdui-demo/src/main/resources/net/multiphasicapps/lcduidemo/image.jpg.__mime.


















































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 750 image.jpg
/9j/4AAQSkZJRgABAQEASABIAAD/4iOISUNDX1BST0ZJTEUAAQEAACN4bGNt
cwIQAABtbnRyUkdCIFhZWiAH3wALAAoADAASADhhY3NwKm5peAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAA
ALBjcHJ0AAABuAAAARJ3dHB0AAACzAAAABRjaGFkAAAC4AAAACxyWFlaAAAD
DAAAABRiWFlaAAADIAAAABRnWFlaAAADNAAAABRyVFJDAAADSAAAIAxnVFJD
AAADSAAAIAxiVFJDAAADSAAAIAxjaHJtAAAjVAAAACRkZXNjAAAAAAAAABxz
UkdCLWVsbGUtVjItc3JnYnRyYy5pY2MAAAAAAAAAAAAAAB0AcwBSAEcAQgAt
AGUAbABsAGUALQBWADIALQBzAHIAZwBiAHQAcgBjAC4AaQBjAGMAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0
IDIwMTUsIEVsbGUgU3RvbmUgKHdlYnNpdGU6IGh0dHA6Ly9uaW5lZGVncmVl
c2JlbG93LmNvbS87IGVtYWlsOiBlbGxlc3RvbmVAbmluZWRlZ3JlZXNiZWxv
dy5jb20pLiBUaGlzIElDQyBwcm9maWxlIGlzIGxpY2Vuc2VkIHVuZGVyIGEg
Q3JlYXRpdmUgQ29tbW9ucyBBdHRyaWJ1dGlvbi1TaGFyZUFsaWtlIDMuMCBV
bnBvcnRlZCBMaWNlbnNlIChodHRwczovL2NyZWF0aXZlY29tbW9ucy5vcmcv
bGljZW5zZXMvYnktc2EvMy4wL2xlZ2FsY29kZSkuAAAAAFhZWiAAAAAAAAD2
1gABAAAAANMtc2YzMgAAAAAAAQxCAAAF3v//8yUAAAeTAAD9kP//+6H///2i
AAAD3AAAwG5YWVogAAAAAAAAb6AAADj1AAADkFhZWiAAAAAAAAAknwAAD4QA
ALbEWFlaIAAAAAAAAGKXAAC3hwAAGNljdXJ2AAAAAAAAEAAAAAABAAIABAAF
AAYABwAJAAoACwAMAA4ADwAQABEAEwAUABUAFgAYABkAGgAbABwAHgAfACAA
IQAjACQAJQAmACgAKQAqACsALQAuAC8AMAAyADMANAA1ADcAOAA5ADoAOwA9
AD4APwBAAEIAQwBEAEUARwBIAEkASgBMAE0ATgBPAFEAUgBTAFQAVQBXAFgA
WQBaAFwAXQBeAF8AYQBiAGMAZABmAGcAaABpAGsAbABtAG4AbwBxAHIAcwB0
AHYAdwB4AHkAewB8AH0AfgCAAIEAggCDAIUAhgCHAIgAiQCLAIwAjQCOAJAA
kQCSAJMAlQCWAJcAmACaAJsAnACdAJ8AoAChAKIApAClAKYApwCoAKoAqwCs
AK0ArwCwALEAsgC0ALUAtgC3ALkAugC7ALwAvgC/AMAAwQDCAMQAxQDGAMcA
yQDKAMsAzADOAM8A0ADRANMA1ADVANcA2ADZANoA3ADdAN4A4ADhAOIA5ADl
AOYA6ADpAOoA7ADtAO8A8ADxAPMA9AD2APcA+AD6APsA/QD+AP8BAQECAQQB
BQEHAQgBCgELAQ0BDgEPAREBEgEUARUBFwEYARoBGwEdAR8BIAEiASMBJQEm
ASgBKQErAS0BLgEwATEBMwE0ATYBOAE5ATsBPAE+AUABQQFDAUUBRgFIAUoB
SwFNAU8BUAFSAVQBVQFXAVkBWgFcAV4BYAFhAWMBZQFnAWgBagFsAW4BbwFx
AXMBdQF2AXgBegF8AX4BfwGBAYMBhQGHAYkBigGMAY4BkAGSAZQBlgGXAZkB
mwGdAZ8BoQGjAaUBpwGpAasBrAGuAbABsgG0AbYBuAG6AbwBvgHAAcIBxAHG
AcgBygHMAc4B0AHSAdQB1gHYAdoB3AHeAeEB4wHlAecB6QHrAe0B7wHxAfMB
9QH4AfoB/AH+AgACAgIEAgcCCQILAg0CDwISAhQCFgIYAhoCHQIfAiECIwIl
AigCKgIsAi4CMQIzAjUCOAI6AjwCPgJBAkMCRQJIAkoCTAJPAlECUwJWAlgC
WgJdAl8CYQJkAmYCaQJrAm0CcAJyAnUCdwJ5AnwCfgKBAoMChgKIAosCjQKQ
ApIClQKXApoCnAKfAqECpAKmAqkCqwKuArACswK1ArgCuwK9AsACwgLFAsgC
ygLNAs8C0gLVAtcC2gLdAt8C4gLkAucC6gLsAu8C8gL1AvcC+gL9Av8DAgMF
AwgDCgMNAxADEwMVAxgDGwMeAyADIwMmAykDLAMuAzEDNAM3AzoDPQM/A0ID
RQNIA0sDTgNRA1QDVgNZA1wDXwNiA2UDaANrA24DcQN0A3cDegN9A4ADggOF
A4gDiwOOA5EDlAOYA5sDngOhA6QDpwOqA60DsAOzA7YDuQO8A78DwgPFA8kD
zAPPA9ID1QPYA9sD3wPiA+UD6APrA+4D8gP1A/gD+wP+BAIEBQQIBAsEDwQS
BBUEGAQcBB8EIgQlBCkELAQvBDMENgQ5BD0EQARDBEcESgRNBFEEVARXBFsE
XgRiBGUEaARsBG8EcwR2BHkEfQSABIQEhwSLBI4EkgSVBJkEnASgBKMEpwSq
BK4EsQS1BLgEvAS/BMMExgTKBM4E0QTVBNgE3ATgBOME5wTqBO4E8gT1BPkE
/QUABQQFCAULBQ8FEwUWBRoFHgUiBSUFKQUtBTEFNAU4BTwFQAVDBUcFSwVP
BVIFVgVaBV4FYgVmBWkFbQVxBXUFeQV9BYEFhAWIBYwFkAWUBZgFnAWgBaQF
qAWsBa8FswW3BbsFvwXDBccFywXPBdMF1wXbBd8F4wXnBesF7wX0BfgF/AYA
BgQGCAYMBhAGFAYYBhwGIQYlBikGLQYxBjUGOQY+BkIGRgZKBk4GUwZXBlsG
XwZjBmgGbAZwBnQGeQZ9BoEGhQaKBo4GkgaXBpsGnwakBqgGrAaxBrUGuQa+
BsIGxgbLBs8G1AbYBtwG4QblBuoG7gbyBvcG+wcABwQHCQcNBxIHFgcbBx8H
JAcoBy0HMQc2BzoHPwdDB0gHTQdRB1YHWgdfB2MHaAdtB3EHdgd7B38HhAeJ
B40HkgeXB5sHoAelB6kHrgezB7cHvAfBB8YHygfPB9QH2QfdB+IH5wfsB/EH
9Qf6B/8IBAgJCA0IEggXCBwIIQgmCCsILwg0CDkIPghDCEgITQhSCFcIXAhh
CGYIawhwCHUIegh/CIQIiQiOCJMImAidCKIIpwisCLEItgi7CMAIxQjKCM8I
1AjZCN8I5AjpCO4I8wj4CP0JAwkICQ0JEgkXCR0JIgknCSwJMQk3CTwJQQlG
CUwJUQlWCVsJYQlmCWsJcQl2CXsJgQmGCYsJkQmWCZsJoQmmCasJsQm2CbwJ
wQnGCcwJ0QnXCdwJ4gnnCe0J8gn4Cf0KAgoICg0KEwoZCh4KJAopCi8KNAo6
Cj8KRQpKClAKVgpbCmEKZgpsCnIKdwp9CoMKiAqOCpQKmQqfCqUKqgqwCrYK
vArBCscKzQrTCtgK3grkCuoK7wr1CvsLAQsHCwwLEgsYCx4LJAsqCy8LNQs7
C0ELRwtNC1MLWQtfC2QLagtwC3YLfAuCC4gLjguUC5oLoAumC6wLsgu4C74L
xAvKC9AL1gvcC+IL6QvvC/UL+wwBDAcMDQwTDBkMIAwmDCwMMgw4DD4MRQxL
DFEMVwxdDGQMagxwDHYMfQyDDIkMjwyWDJwMogyoDK8MtQy7DMIMyAzODNUM
2wzhDOgM7gz1DPsNAQ0IDQ4NFQ0bDSENKA0uDTUNOw1CDUgNTw1VDVwNYg1p
DW8Ndg18DYMNiQ2QDZYNnQ2kDaoNsQ23Db4NxQ3LDdIN2Q3fDeYN7A3zDfoO
AQ4HDg4OFQ4bDiIOKQ4vDjYOPQ5EDkoOUQ5YDl8OZg5sDnMOeg6BDogOjg6V
DpwOow6qDrEOuA6+DsUOzA7TDtoO4Q7oDu8O9g79DwQPCw8SDxkPIA8nDy4P
NQ88D0MPSg9RD1gPXw9mD20PdA97D4IPiQ+QD5gPnw+mD60PtA+7D8IPyg/R
D9gP3w/mD+0P9Q/8EAMQChASEBkQIBAnEC8QNhA9EEQQTBBTEFoQYhBpEHAQ
eBB/EIYQjhCVEJ0QpBCrELMQuhDCEMkQ0BDYEN8Q5xDuEPYQ/REFEQwRFBEb
ESMRKhEyETkRQRFIEVARVxFfEWcRbhF2EX0RhRGNEZQRnBGkEasRsxG7EcIR
yhHSEdkR4RHpEfAR+BIAEggSDxIXEh8SJxIuEjYSPhJGEk4SVRJdEmUSbRJ1
En0ShBKMEpQSnBKkEqwStBK8EsQSzBLUEtsS4xLrEvMS+xMDEwsTExMbEyMT
KxMzEzsTRBNME1QTXBNkE2wTdBN8E4QTjBOUE50TpROtE7UTvRPFE80T1hPe
E+YT7hP2E/8UBxQPFBcUIBQoFDAUOBRBFEkUURRaFGIUahRzFHsUgxSMFJQU
nBSlFK0UthS+FMYUzxTXFOAU6BTxFPkVARUKFRIVGxUjFSwVNBU9FUUVThVX
FV8VaBVwFXkVgRWKFZMVmxWkFawVtRW+FcYVzxXYFeAV6RXyFfoWAxYMFhQW
HRYmFi8WNxZAFkkWUhZaFmMWbBZ1Fn4WhhaPFpgWoRaqFrMWuxbEFs0W1hbf
FugW8Rb6FwMXDBcUFx0XJhcvFzgXQRdKF1MXXBdlF24XdxeAF4kXkhecF6UX
rhe3F8AXyRfSF9sX5BftF/cYABgJGBIYGxgkGC4YNxhAGEkYUhhcGGUYbhh3
GIEYihiTGJwYphivGLgYwhjLGNQY3hjnGPAY+hkDGQwZFhkfGSkZMhk7GUUZ
ThlYGWEZaxl0GX4ZhxmRGZoZpBmtGbcZwBnKGdMZ3RnmGfAZ+hoDGg0aFhog
GioaMxo9GkYaUBpaGmMabRp3GoEaihqUGp4apxqxGrsaxRrOGtga4hrsGvUa
/xsJGxMbHRsnGzAbOhtEG04bWBtiG2wbdRt/G4kbkxudG6cbsRu7G8UbzxvZ
G+Mb7Rv3HAEcCxwVHB8cKRwzHD0cRxxRHFscZRxwHHochByOHJgcohysHLYc
wRzLHNUc3xzpHPQc/h0IHRIdHB0nHTEdOx1FHVAdWh1kHW8deR2DHY4dmB2i
Ha0dtx3BHcwd1h3hHesd9R4AHgoeFR4fHioeNB4+HkkeUx5eHmgecx59Hoge
kx6dHqgesh69Hsce0h7cHuce8h78HwcfEh8cHycfMh88H0cfUh9cH2cfch98
H4cfkh+dH6cfsh+9H8gf0h/dH+gf8x/+IAggEyAeICkgNCA/IEogVCBfIGog
dSCAIIsgliChIKwgtyDCIM0g2CDjIO4g+SEEIQ8hGiElITAhOyFGIVEhXCFn
IXIhfiGJIZQhnyGqIbUhwCHMIdch4iHtIfgiBCIPIhoiJSIwIjwiRyJSIl4i
aSJ0In8iiyKWIqEirSK4IsMizyLaIuYi8SL8IwgjEyMfIyojNSNBI0wjWCNj
I28jeiOGI5EjnSOoI7QjvyPLI9Yj4iPuI/kkBSQQJBwkKCQzJD8kSyRWJGIk
biR5JIUkkSScJKgktCS/JMsk1yTjJO4k+iUGJRIlHiUpJTUlQSVNJVklZSVw
JXwliCWUJaAlrCW4JcQl0CXcJecl8yX/JgsmFyYjJi8mOyZHJlMmXyZrJncm
hCaQJpwmqCa0JsAmzCbYJuQm8Cb9JwknFSchJy0nOSdGJ1InXidqJ3YngyeP
J5snpye0J8AnzCfZJ+Un8Sf9KAooFigjKC8oOyhIKFQoYChtKHkohiiSKJ4o
qyi3KMQo0CjdKOko9ikCKQ8pGykoKTQpQSlNKVopZylzKYApjCmZKaYpsim/
Kcwp2CnlKfEp/ioLKhgqJCoxKj4qSipXKmQqcSp9KooqlyqkKrEqvSrKKtcq
5CrxKv4rCisXKyQrMSs+K0srWCtlK3IrfyuMK5krpSuyK78rzCvZK+Yr8ywB
LA4sGywoLDUsQixPLFwsaSx2LIMskCyeLKssuCzFLNIs3yztLPotBy0ULSEt
Ly08LUktVi1kLXEtfi2LLZktpi2zLcEtzi3bLekt9i4ELhEuHi4sLjkuRy5U
LmEuby58Loouly6lLrIuwC7NLtsu6C72LwMvES8eLywvOi9HL1UvYi9wL34v
iy+ZL6cvtC/CL9Av3S/rL/kwBjAUMCIwLzA9MEswWTBnMHQwgjCQMJ4wrDC5
MMcw1TDjMPEw/zENMRoxKDE2MUQxUjFgMW4xfDGKMZgxpjG0McIx0DHeMewx
+jIIMhYyJDIyMkAyTjJcMmoyeTKHMpUyozKxMr8yzTLcMuoy+DMGMxQzIzMx
Mz8zTTNcM2ozeDOGM5UzozOxM8AzzjPcM+sz+TQHNBY0JDQzNEE0TzReNGw0
ezSJNJg0pjS1NMM00jTgNO80/TUMNRo1KTU3NUY1VDVjNXI1gDWPNZ01rDW7
Nck12DXnNfU2BDYTNiE2MDY/Nk42XDZrNno2iTaXNqY2tTbENtM24TbwNv83
DjcdNyw3OzdJN1g3Zzd2N4U3lDejN7I3wTfQN9837jf9OAw4GzgqODk4SDhX
OGY4dTiEOJM4ojixOME40DjfOO44/TkMORs5Kzk6OUk5WDlnOXc5hjmVOaQ5
tDnDOdI54TnxOgA6DzofOi46PTpNOlw6azp7Ooo6mjqpOrg6yDrXOuc69jsG
OxU7JTs0O0Q7UztjO3I7gjuRO6E7sDvAO9A73zvvO/48DjwePC08PTxNPFw8
bDx8PIs8mzyrPLo8yjzaPOo8+T0JPRk9KT05PUg9WD1oPXg9iD2YPac9tz3H
Pdc95z33Pgc+Fz4nPjc+Rz5XPmc+dz6HPpc+pz63Psc+1z7nPvc/Bz8XPyc/
Nz9HP1c/Zz94P4g/mD+oP7g/yD/ZP+k/+UAJQBlAKkA6QEpAWkBrQHtAi0Cc
QKxAvEDNQN1A7UD+QQ5BHkEvQT9BT0FgQXBBgUGRQaJBskHDQdNB5EH0QgVC
FUImQjZCR0JXQmhCeEKJQppCqkK7QstC3ELtQv1DDkMfQy9DQENRQ2FDckOD
Q5RDpEO1Q8ZD10PnQ/hECUQaRCtEO0RMRF1EbkR/RJBEoUSyRMJE00TkRPVF
BkUXRShFOUVKRVtFbEV9RY5Fn0WwRcFF0kXjRfRGBUYXRihGOUZKRltGbEZ9
Ro9GoEaxRsJG00bkRvZHB0cYRylHO0dMR11HbkeAR5FHoke0R8VH1kfoR/lI
CkgcSC1IP0hQSGFIc0iESJZIp0i5SMpI3EjtSP9JEEkiSTNJRUlWSWhJekmL
SZ1JrknASdJJ40n1SgZKGEoqSjtKTUpfSnFKgkqUSqZKt0rJSttK7Ur/SxBL
Iks0S0ZLWEtpS3tLjUufS7FLw0vVS+dL+UwKTBxMLkxATFJMZEx2TIhMmkys
TL5M0EziTPRNBk0ZTStNPU1PTWFNc02FTZdNqU28Tc5N4E3yTgROF04pTjtO
TU5fTnJOhE6WTqlOu07NTt9O8k8ETxZPKU87T05PYE9yT4VPl0+qT7xPzk/h
T/NQBlAYUCtQPVBQUGJQdVCHUJpQrVC/UNJQ5FD3UQlRHFEvUUFRVFFnUXlR
jFGfUbFRxFHXUelR/FIPUiJSNFJHUlpSbVKAUpJSpVK4UstS3lLxUwRTFlMp
UzxTT1NiU3VTiFObU65TwVPUU+dT+lQNVCBUM1RGVFlUbFR/VJJUpVS4VMtU
3lTyVQVVGFUrVT5VUVVlVXhVi1WeVbFVxVXYVetV/lYSViVWOFZLVl9WclaF
VplWrFa/VtNW5lb6Vw1XIFc0V0dXW1duV4JXlVepV7xX0FfjV/dYClgeWDFY
RVhYWGxYgFiTWKdYuljOWOJY9VkJWR1ZMFlEWVhZa1l/WZNZp1m6Wc5Z4ln2
WglaHVoxWkVaWVpsWoBalFqoWrxa0FrkWvhbC1sfWzNbR1tbW29bg1uXW6tb
v1vTW+db+1wPXCNcN1xLXGBcdFyIXJxcsFzEXNhc7F0BXRVdKV09XVFdZV16
XY5dol22Xctd313zXgheHF4wXkReWV5tXoJell6qXr9e017nXvxfEF8lXzlf
Tl9iX3dfi1+gX7RfyV/dX/JgBmAbYC9gRGBYYG1ggmCWYKtgv2DUYOlg/WES
YSdhO2FQYWVhemGOYaNhuGHNYeFh9mILYiBiNWJJYl5ic2KIYp1ismLHYtti
8GMFYxpjL2NEY1ljbmODY5hjrWPCY9dj7GQBZBZkK2RAZFVkamR/ZJVkqmS/
ZNRk6WT+ZRNlKWU+ZVNlaGV9ZZNlqGW9ZdJl6GX9ZhJmJ2Y9ZlJmZ2Z9ZpJm
p2a9ZtJm6Gb9ZxJnKGc9Z1NnaGd+Z5NnqWe+Z9Rn6Wf/aBRoKmg/aFVoamiA
aJZoq2jBaNZo7GkCaRdpLWlDaVhpbmmEaZlpr2nFadtp8GoGahxqMmpIal1q
c2qJap9qtWrKauBq9msMayJrOGtOa2RremuQa6ZrvGvSa+hr/mwUbCpsQGxW
bGxsgmyYbK5sxGzabPBtBm0cbTNtSW1fbXVti22hbbhtzm3kbfpuEW4nbj1u
U25qboBulm6tbsNu2W7wbwZvHG8zb0lvYG92b4xvo2+5b9Bv5m/9cBNwKnBA
cFdwbXCEcJpwsXDHcN5w9HELcSJxOHFPcWZxfHGTcapxwHHXce5yBHIbcjJy
SHJfcnZyjXKkcrpy0XLocv9zFnMsc0NzWnNxc4hzn3O2c81z5HP6dBF0KHQ/
dFZ0bXSEdJt0snTJdOB093UOdSZ1PXVUdWt1gnWZdbB1x3XedfZ2DXYkdjt2
UnZqdoF2mHavdsd23nb1dwx3JHc7d1J3aneBd5h3sHfHd9539ngNeCV4PHhU
eGt4gniaeLF4yXjgePh5D3kneT55VnlueYV5nXm0ecx543n7ehN6KnpCelp6
cXqJeqF6uHrQeuh7AHsXey97R3tfe3Z7jnume7571nvufAV8HXw1fE18ZXx9
fJV8rXzFfNx89H0MfSR9PH1UfWx9hH2cfbR9zX3lff1+FX4tfkV+XX51fo1+
pX6+ftZ+7n8Gfx5/N39Pf2d/f3+Xf7B/yH/gf/mAEYApgEGAWoBygIqAo4C7
gNSA7IEEgR2BNYFOgWaBf4GXgbCByIHhgfmCEoIqgkOCW4J0goyCpYK+gtaC
74MHgyCDOYNRg2qDg4Obg7SDzYPlg/6EF4QwhEiEYYR6hJOErITEhN2E9oUP
hSiFQYVahXKFi4Wkhb2F1oXvhgiGIYY6hlOGbIaFhp6Gt4bQhumHAocbhzSH
TYdnh4CHmYeyh8uH5If9iBeIMIhJiGKIe4iViK6Ix4jgiPqJE4ksiUaJX4l4
iZGJq4nEid6J94oQiiqKQ4pdinaKj4qpisKK3Ir1iw+LKItCi1uLdYuOi6iL
wovbi/WMDowojEKMW4x1jI+MqIzCjNyM9Y0PjSmNQo1cjXaNkI2pjcON3Y33
jhGOK45Ejl6OeI6SjqyOxo7gjvqPE48tj0ePYY97j5WPr4/Jj+OP/ZAXkDGQ
S5BlkH+QmpC0kM6Q6JECkRyRNpFQkWuRhZGfkbmR05HukgiSIpI8kleScZKL
kqaSwJLakvSTD5Mpk0STXpN4k5OTrZPIk+KT/JQXlDGUTJRmlIGUm5S2lNCU
65UFlSCVO5VVlXCVipWllcCV2pX1lg+WKpZFll+WepaVlrCWypbllwCXG5c1
l1CXa5eGl6GXu5fWl/GYDJgnmEKYXZh3mJKYrZjImOOY/pkZmTSZT5lqmYWZ
oJm7mdaZ8ZoMmieaQppemnmalJqvmsqa5ZsAmxybN5tSm22biJukm7+b2pv1
nBGcLJxHnGOcfpyZnLWc0JzrnQedIp09nVmddJ2Qnaudxp3inf2eGZ40nlCe
a56HnqKevp7anvWfEZ8sn0ifY59/n5uftp/Sn+6gCaAloEGgXKB4oJSgsKDL
oOehA6EfoTqhVqFyoY6hqqHGoeGh/aIZojWiUaJtoomipaLBot2i+aMVozGj
TaNpo4WjoaO9o9mj9aQRpC2kSaRlpIGknqS6pNak8qUOpSqlR6VjpX+lm6W4
pdSl8KYMpimmRaZhpn6mmqa2ptOm76cLpyinRKdgp32nmae2p9Kn76gLqCio
RKhhqH2omqi2qNOo76kMqSmpRaliqX6pm6m4qdSp8aoOqiqqR6pkqoCqnaq6
qteq86sQqy2rSqtnq4OroKu9q9qr96wUrDCsTaxqrIespKzBrN6s+60YrTWt
Uq1vrYytqa3GreOuAK4drjquV650rpKur67MrumvBq8jr0CvXq97r5ivta/T
r/CwDbAqsEiwZbCCsJ+wvbDasPexFbEysVCxbbGKsaixxbHjsgCyHrI7slmy
drKUsrGyz7LsswqzJ7NFs2KzgLOes7uz2bP2tBS0MrRPtG20i7SotMa05LUC
tR+1PbVbtXm1lrW0tdK18LYOtiy2SbZntoW2o7bBtt+2/bcbtzm3V7d1t5O3
sbfPt+24C7gpuEe4ZbiDuKG4v7jduPu5Gbk4uVa5dLmSubC5zrntugu6KbpH
uma6hLqiusC637r9uxu7OrtYu3a7lbuzu9G78LwOvC28S7xqvIi8przFvOO9
Ar0gvT+9Xb18vZu9ub3Yvfa+Fb4zvlK+cb6Pvq6+zb7rvwq/Kb9Hv2a/hb+k
v8K/4cAAwB/APsBcwHvAmsC5wNjA98EVwTTBU8FywZHBsMHPwe7CDcIswkvC
asKJwqjCx8LmwwXDJMNDw2LDgcOgw8DD38P+xB3EPMRbxHvEmsS5xNjE98UX
xTbFVcV1xZTFs8XSxfLGEcYwxlDGb8aPxq7GzcbtxwzHLMdLx2vHiseqx8nH
6cgIyCjIR8hnyIbIpsjFyOXJBckkyUTJZMmDyaPJw8niygLKIspBymHKgcqh
ysDK4MsAyyDLQMtfy3/Ln8u/y9/L/8wfzD/MXsx+zJ7MvszezP7NHs0+zV7N
fs2ezb7N3s3+zh/OP85fzn/On86/zt/O/88gz0DPYM+Az6DPwc/h0AHQIdBC
0GLQgtCi0MPQ49ED0STRRNFl0YXRpdHG0ebSB9In0kfSaNKI0qnSydLq0wrT
K9NM02zTjdOt087T7tQP1DDUUNRx1JLUstTT1PTVFNU11VbVd9WX1bjV2dX6
1hrWO9Zc1n3Wnta/1t/XANch10LXY9eE16XXxtfn2AjYKdhK2GvYjNit2M7Y
79kQ2THZUtlz2ZTZtdnW2fjaGdo62lvafNqe2r/a4NsB2yLbRNtl24bbqNvJ
2+rcC9wt3E7cb9yR3LLc1Nz13RbdON1Z3XvdnN2+3d/eAd4i3kTeZd6H3qje
yt7s3w3fL99Q33LflN+139ff+eAa4DzgXuB/4KHgw+Dl4QbhKOFK4WzhjeGv
4dHh8+IV4jfiWeJ64pzivuLg4wLjJONG42jjiuOs487j8OQS5DTkVuR45Jrk
vOTe5QHlI+VF5WflieWr5c3l8OYS5jTmVuZ55pvmvebf5wLnJOdG52nni+et
59Dn8ugU6DfoWeh76J7owOjj6QXpKOlK6W3pj+my6dTp9+oZ6jzqXuqB6qTq
xurp6wvrLutR63Prluu569zr/uwh7ETsZuyJ7Kzsz+zy7RTtN+1a7X3toO3D
7eXuCO4r7k7uce6U7rfu2u797yDvQ+9m74nvrO/P7/LwFfA48FvwfvCh8MXw
6PEL8S7xUfF08Zjxu/He8gHyJPJI8mvyjvKx8tXy+PMb8z/zYvOF86nzzPPw
9BP0NvRa9H30ofTE9Oj1C/Uv9VL1dvWZ9b314PYE9if2S/Zv9pL2tvbZ9v33
IfdE92j3jPew99P39/gb+D74YviG+Kr4zvjx+RX5Ofld+YH5pfnJ+ez6EPo0
+lj6fPqg+sT66PsM+zD7VPt4+5z7wPvk/Aj8LPxQ/HX8mfy9/OH9Bf0p/U39
cv2W/br93v4C/if+S/5v/pT+uP7c/wD/Jf9J/23/kv+2/9v//2Nocm0AAAAA
AAMAAAAAo9cAAFR8AABMzQAAmZoAACZnAAAPXP/bAEMAAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAf/bAEMBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIABgAGAMBEQAC
EQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAAIBwYK/8QAIBAAAgMBAQEAAgMA
AAAAAAAABQYDBAcCAQgUFRYXGP/EABgBAQEAAwAAAAAAAAAAAAAAAAYFAAQH
/8QAIxEAAwEBAAIDAAIDAQAAAAAAAgMEAQUGExESFAcVACEiI//aAAwDAQAC
EQMRAD8A7LNseXMTuKcogBxg3XK5wdsgKomSrX9XX+wRteAW6TqaOPi5HBGH
6Ckqt67EPiVizNLcish5Do0nzryvo0z9dUyGO1489D+WhO5hB0Xu6Cyq0fkQ
MAVOsHlRpIXIVKSz1V0poZcSHmv8f6tVTkprT0IAVjMMzrjIHZXKIifwvM+6
6ff6yIXonUBA1qSzY+6CzWVWxovDAs/sVY21L5BWpEJPVY/7n9o8Hfwo6511
Le6ZrRVZLkxduxVtW1rkDXXZR0UXTmRO6x+TdT6b1GNlScDnSt52MMI7RlAv
3AozzW5VQxR0RtIGFKtCp8WQM6Da5/8AXz4f5fW7ceCmg8hz3K/RgFMZDnwP
pEGgDBzRx2sJv2+cnFU/Wn7QP9D5+pHxRcJbLKzbffLlnmh4KYLVirITWgYa
tVvHa9cAkRDJIARKqXjnJXCLRLcpVDFpo7JZxuta7yCFVhtT0KzePQSWCKWy
/htqmXKsXUK2SJyQWhq2e4W/qJ30dbZ+ipRz+WPi91a3KZWrpxJkR/6Y5Evq
dlNJlvrxx2NJYvDU7+bJ5sw/W2cRL/1J9g2MIuaoyh8yetCcMtoPTBpRYKvN
5ikhICfZsMCcRNxA6vnEgGvQOI5v+vQJZLicBstx+17QMyzml65t0Lp3UM73
QFqy/XLRbjGVFQlSOdE51UdL9BZEvmIm2d4RwL9/WfnsP2vZOu6h4949R2mc
jmQ4Lqe1ZzOZyYVMlW/pdfquTAuRLKnJnS19ZnOXQvaMnPzfj5+oN/NIUH6O
5yz5s1Enrc8TI55Zmn0DqzlKuEFq6Rdl7bDNTT5mIX6u9+Zt4z1zU2nLF1XS
3BkUJi+cXzK053s7Y1RrvHD6GqmIaCW2zE9TaQW1ZZjOqqHTzGpEpWmhjKAZ
+Nj5WFMZzUMlYmg23S/j7pD/ACJL4NM6XKrfI+J43Ba1PXi55tN64edYc/X5
sPksPPsmo53RFXb4PL8gimuGXr8KDszW8tFQyj6/I6A8pqhqgSsE2PvR8rgV
4FebqEE2iNC6rFbTVll+21GKRJQVEpde89+gJkx91HHZ9BV6UecOzuXZfx+L
0ltZ9ThNqJK6X9DlmIT1Ld6v1VBLQMzZ3t0VeuazndNGPoge3E1yHVNaqnTv
l/hzvFOn5DxCdlS+OV0zq9k6ciqBQkKIqvy9nlcfrzj0VWQdLlz9ni8XyCJF
Jxd7kcfpQ2wzvbdgn8MWHbV88WmX3R+AJTq/HlqkvFnZ18tVVsVLY7rX1g94
wtoQIuC4kjstWI1a9sWMHkhxdaiuB5HXlsXrV/Z82Ss+xo6nP66Jb9pUxkgt
K88lcZfnSgcj3TwgZvx62oxwiA5Lta1UdTk5H9w3P2UMWlG5rjzF/Dl+tTGN
PaPp9fkSIhIG6J/4JKBL6MLdpn0QUzjptN4qvzJAxYa80Nquiap7eEnxR3XI
45/klj1HIyxGGtbsFMoz5nLL7DIUo1K7GOohqYrcBi0d0kZ1T5tO1waiJcTu
RX+20GLfhWY/Oew04P8A1rFqqxXzp4w0kSFdFGRcsCbzQqFSrj2g3psSyaTR
NZLj346y5qhzdzAqeoWL+u76z0jOBffNQxje8uQG3Y5X4+7g7JPqDzTkeHNi
8RcOZMhemuwi0RC5Vg9N9VujCfyaC8kwCnMsedR9M3hxqZlnivL2uee3tz2n
0onfadXQlZKubcwgB6w0FhW09H2Y54kcxAn1LWwdrrg9l4IqeiAplytEftsd
H6hITAD1Ov02FmB8/RuLP6NZ7f8Aeq+iU//Z
====

Added modules/lcdui-demo/src/main/resources/net/multiphasicapps/lcduidemo/image.png.__mime.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 750 image.png
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsS
AAALEgHS3X78AAAB1UlEQVRIx71Vv0tCURS+7xFJUHNjU4PoGljQ3lRT2FgW
YXtLQiIE/gs6WUhDBA222N6QUItgSgTuLTVERFG+Ohc+Pe967vXl0IXL454f
3/n13XeVElbr5jhQY6xIfmQUfD0HNmOX3OXXN2pXytpQMraBQE6b/Lnej1o2
fRMLa6Lc5S8G6FTPh4LMJ1P9MwIBHGfTz1nB/W0tBGYuLidb2EcK0IvHnOBm
INjBzxlAAr++vBqq7vP9SazIDOLbsjIBODjNY3Jq1tm2oQB8YAT+2Gr86ZKZ
MwOezynIwWFYPtyLFICqQut4JaEWjQNONrSpZRSE/Hl7fQkcTsurK3rTqhQL
YkugRxDrDDg4HPfzF2puaVtli2di9u10PqQnX8IgLDDPN8vl4JmHpprufSt1
WtEyqWXQ1+7eQrRGZTpAcnHLg5A2ZVGvV7XBy87uEChnGPSwN5OYcA1wvdsc
cNy4dNmjkkp0w7wnmUlxT/p7cpqRgzQ8mx7Dp65YK8BtBXMoM7N8yGCTyRV0
5gCO9LJ9vHaC0kFaf7FtZ9u74I16aHglOvNfSpZzG/0z2GLLXBRSRuAyAPSg
U5uDNjZOQrSkFsVm4t7I3zWB8zM5gzkAxZfrJN9/WT/5DYY2PNCyJwAAAABJ
RU5ErkJggg==
====

Added modules/lcdui-demo/src/main/resources/net/multiphasicapps/lcduidemo/image.xpm.








































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * head_24x24_xpm[] = {
"24 24 12 1",
" 	c None",
".	c #D4C79F",
"+	c #FFFCEE",
"@	c #D69E98",
"#	c #F9F3D7",
"$	c #977957",
"%	c #48454C",
"&	c #F30102",
"*	c #FFFFFF",
"=	c #AA1E1D",
"-	c #FFA39D",
";	c #EE6365",
"     .             .    ",
"    .+.     .     .+.   ",
"   .@++.   .+.   .++@.  ",
"   .@++.. .++.. ..++@.  ",
"   .@@+...#+++...++@@.  ",
"   .@@..+.#++++....@@.  ",
"   .@..++.#++++.++..@.  ",
"   ...+++$#++.#.+++...  ",
"   ..+#++$#+.#+.++++..  ",
"  ..+#.++$#+.#+.++.++.. ",
" .++#.++$$#+.#+.++#.#+. ",
" .+#.++$$$#+.#+.$$+#.#. ",
" .#.+$$..$$+.#...$$+.#. ",
" ..+$$.%&*$+.#.=&*$$+.$ ",
" ..$$.%=*-.$.#.=*-%$+$. ",
"  $..++=;-.$...=;-+$$$. ",
"  $..++++++.$$++++++#.. ",
"    .+++#+++++++#+++..  ",
"    ..#$$++$$$++$$#.    ",
"      .#$###$###$#.     ",
"      ..#$$$*$$$..      ",
"     #.$...***...$#     ",
"    ##.$$$..*..$$$##    ",
"                        "};

Added modules/m3g/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This contains an implementation of the J2ME "
	"Mobile 3D Graphics API. In SquirrelJME it utilizes OpenGL ES to " +
	"perform the rendering as required."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EK"
	swmType = JavaMEMidletType.API
	swmName = "Mobile 3D Graphics API"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:opengles")
}

Added modules/m3g/src/main/java/javax/microedition/m3g/AnimationController.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class AnimationController
	extends Object3D
{
	public AnimationController()
	{
		throw new todo.TODO();
	}
	
	public int getActiveIntervalEnd()
	{
		throw new todo.TODO();
	}
	
	public int getActiveIntervalStart()
	{
		throw new todo.TODO();
	}
	
	public float getPosition(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getRefWorldTime()
	{
		throw new todo.TODO();
	}
	
	public float getSpeed()
	{
		throw new todo.TODO();
	}
	
	public float getWeight()
	{
		throw new todo.TODO();
	}
	
	public void setActiveInterval(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setPosition(float __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setSpeed(float __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setWeight(float __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class AnimationTrack
	extends Object3D
{
	public static final int ALPHA =
		256;
	
	public static final int AMBIENT_COLOR =
		257;
	
	public static final int COLOR =
		258;
	
	public static final int CROP =
		259;
	
	public static final int DENSITY =
		260;
	
	public static final int DIFFUSE_COLOR =
		261;
	
	public static final int EMISSIVE_COLOR =
		262;
	
	public static final int FAR_DISTANCE =
		263;
	
	public static final int FIELD_OF_VIEW =
		264;
	
	public static final int INTENSITY =
		265;
	
	public static final int MORPH_WEIGHTS =
		266;
	
	public static final int NEAR_DISTANCE =
		267;
	
	public static final int ORIENTATION =
		268;
	
	public static final int PICKABILITY =
		269;
	
	public static final int SCALE =
		270;
	
	public static final int SHININESS =
		271;
	
	public static final int SPECULAR_COLOR =
		272;
	
	public static final int SPOT_ANGLE =
		273;
	
	public static final int SPOT_EXPONENT =
		274;
	
	public static final int TRANSLATION =
		275;
	
	public static final int VISIBILITY =
		276;
	
	public AnimationTrack(KeyframeSequence __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public AnimationController getController()
	{
		throw new todo.TODO();
	}
	
	public KeyframeSequence getKeyframeSequence()
	{
		throw new todo.TODO();
	}
	
	public int getTargetProperty()
	{
		throw new todo.TODO();
	}
	
	public void setController(AnimationController __a)
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Appearance.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Appearance
	extends Object3D
{
	public Appearance()
	{
		throw new todo.TODO();
	}
	
	public CompositingMode getCompositingMode()
	{
		throw new todo.TODO();
	}
	
	public Fog getFog()
	{
		throw new todo.TODO();
	}
	
	public int getLayer()
	{
		throw new todo.TODO();
	}
	
	public Material getMaterial()
	{
		throw new todo.TODO();
	}
	
	public PolygonMode getPolygonMode()
	{
		throw new todo.TODO();
	}
	
	public Texture2D getTexture(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setCompositingMode(CompositingMode __a)
	{
		throw new todo.TODO();
	}
	
	public void setFog(Fog __a)
	{
		throw new todo.TODO();
	}
	
	public void setLayer(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setMaterial(Material __a)
	{
		throw new todo.TODO();
	}
	
	public void setPolygonMode(PolygonMode __a)
	{
		throw new todo.TODO();
	}
	
	public void setTexture(int __a, Texture2D __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Background
	extends Object3D
{
	public static final int BORDER =
		32;
	
	public static final int REPEAT =
		33;
	
	public Background()
	{
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public int getCropHeight()
	{
		throw new todo.TODO();
	}
	
	public int getCropWidth()
	{
		throw new todo.TODO();
	}
	
	public int getCropX()
	{
		throw new todo.TODO();
	}
	
	public int getCropY()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public int getImageModeX()
	{
		throw new todo.TODO();
	}
	
	public int getImageModeY()
	{
		throw new todo.TODO();
	}
	
	public boolean isColorClearEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthClearEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setColorClearEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setCrop(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setDepthClearEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
	
	public void setImageMode(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Camera
	extends Node
{
	public static final int GENERIC =
		48;
	
	public static final int PARALLEL =
		49;
	
	public static final int PERSPECTIVE =
		50;
	
	public Camera()
	{
		throw new todo.TODO();
	}
	
	public int getProjection(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getProjection(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setGeneric(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setParallel(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void setPerspective(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class CompositingMode
	extends Object3D
{
	public static final int ALPHA =
		64;
	
	public static final int ALPHA_ADD =
		65;
	
	public static final int MODULATE =
		66;
	
	public static final int MODULATE_X2 =
		67;
	
	public static final int REPLACE =
		68;
	
	public CompositingMode()
	{
		throw new todo.TODO();
	}
	
	public float getAlphaThreshold()
	{
		throw new todo.TODO();
	}
	
	public int getBlending()
	{
		throw new todo.TODO();
	}
	
	public float getDepthOffsetFactor()
	{
		throw new todo.TODO();
	}
	
	public float getDepthOffsetUnits()
	{
		throw new todo.TODO();
	}
	
	public boolean isAlphaWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isColorWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthTestEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setAlphaThreshold(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setAlphaWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setBlending(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setColorWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setDepthOffset(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setDepthTestEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setDepthWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Fog.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Fog
	extends Object3D
{
	public static final int EXPONENTIAL =
		80;
	
	public static final int LINEAR =
		81;
	
	public Fog()
	{
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public float getDensity()
	{
		throw new todo.TODO();
	}
	
	public float getFarDistance()
	{
		throw new todo.TODO();
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public float getNearDistance()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setDensity(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setLinear(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;

import java.util.Hashtable;

public class Graphics3D
{
	public static final int ANTIALIAS =
		2;
	
	public static final int DITHER =
		4;
	
	public static final int OVERWRITE =
		16;
	
	public static final int TRUE_COLOR =
		8;
	
	private Graphics3D()
	{
		throw new todo.TODO();
	}
	
	public int addLight(Light __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void bindTarget(Object __a)
	{
		throw new todo.TODO();
	}
	
	public void bindTarget(Object __a, boolean __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void clear(Background __a)
	{
		throw new todo.TODO();
	}
	
	public Camera getCamera(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public float getDepthRangeFar()
	{
		throw new todo.TODO();
	}
	
	public float getDepthRangeNear()
	{
		throw new todo.TODO();
	}
	
	public int getHints()
	{
		throw new todo.TODO();
	}
	
	public Light getLight(int __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public int getLightCount()
	{
		throw new todo.TODO();
	}
	
	public Object getTarget()
	{
		throw new todo.TODO();
	}
	
	public int getViewportHeight()
	{
		throw new todo.TODO();
	}
	
	public int getViewportWidth()
	{
		throw new todo.TODO();
	}
	
	public int getViewportX()
	{
		throw new todo.TODO();
	}
	
	public int getViewportY()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthBufferEnabled()
	{
		throw new todo.TODO();
	}
	
	public void releaseTarget()
	{
		throw new todo.TODO();
	}
	
	public void render(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void render(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Transform __d)
	{
		throw new todo.TODO();
	}
	
	public void render(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Transform __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public void render(World __a)
	{
		throw new todo.TODO();
	}
	
	public void resetLights()
	{
		throw new todo.TODO();
	}
	
	public void setCamera(Camera __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void setDepthRange(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setLight(int __a, Light __b, Transform __c)
	{
		throw new todo.TODO();
	}
	
	public void setViewport(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public static final Graphics3D getInstance()
	{
		throw new todo.TODO();
	}
	
	public static final Hashtable getProperties()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Group
	extends Node
{
	public Group()
	{
		throw new todo.TODO();
	}
	
	public void addChild(Node __a)
	{
		throw new todo.TODO();
	}
	
	public Node getChild(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getChildCount()
	{
		throw new todo.TODO();
	}
	
	public boolean pick(int __a, float __b, float __c, float __d, float __e, 
		float __f, float __g, RayIntersection __h)
	{
		throw new todo.TODO();
	}
	
	public boolean pick(int __a, float __b, float __c, Camera __d, 
		RayIntersection __e)
	{
		throw new todo.TODO();
	}
	
	public void removeChild(Node __a)
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Image2D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Image2D
	extends Object3D
{
	public static final int ALPHA =
		96;
	
	public static final int LUMINANCE =
		97;
	
	public static final int LUMINANCE_ALPHA =
		98;
	
	public static final int RGB =
		99;
	
	public static final int RGBA =
		100;
	
	public Image2D(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public Image2D(int __a, int __b, int __c, byte[] __d)
	{
		throw new todo.TODO();
	}
	
	public Image2D(int __a, int __b, int __c, byte[] __d, byte[] __e)
	{
		throw new todo.TODO();
	}
	
	public Image2D(int __a, Object __b)
	{
		throw new todo.TODO();
	}
	
	public int getFormat()
	{
		throw new todo.TODO();
	}
	
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public boolean isMutable()
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, int __c, int __d, byte[] __e)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public abstract class IndexBuffer
	extends Object3D
{
	IndexBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract int getIndexCount();
	
	public abstract void getIndices(int[] __a);
}


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

package javax.microedition.m3g;


public class KeyframeSequence
	extends Object3D
{
	public static final int CONSTANT =
		192;
	
	public static final int LINEAR =
		176;
	
	public static final int LOOP =
		193;
	
	public static final int SLERP =
		177;
	
	public static final int SPLINE =
		178;
	
	public static final int SQUAD =
		179;
	
	public static final int STEP =
		180;
	
	public KeyframeSequence(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public int getComponentCount()
	{
		throw new todo.TODO();
	}
	
	public int getDuration()
	{
		throw new todo.TODO();
	}
	
	public int getInterpolationType()
	{
		throw new todo.TODO();
	}
	
	public int getKeyframe(int __a, float[] __b)
	{
		throw new todo.TODO();
	}
	
	public int getKeyframeCount()
	{
		throw new todo.TODO();
	}
	
	public int getRepeatMode()
	{
		throw new todo.TODO();
	}
	
	public int getValidRangeFirst()
	{
		throw new todo.TODO();
	}
	
	public int getValidRangeLast()
	{
		throw new todo.TODO();
	}
	
	public void setDuration(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setKeyframe(int __a, int __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public void setRepeatMode(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setValidRange(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Light
	extends Node
{
	public static final int AMBIENT =
		128;
	
	public static final int DIRECTIONAL =
		129;
	
	public static final int OMNI =
		130;
	
	public static final int SPOT =
		131;
	
	public Light()
	{
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public float getConstantAttenuation()
	{
		throw new todo.TODO();
	}
	
	public float getIntensity()
	{
		throw new todo.TODO();
	}
	
	public float getLinearAttenuation()
	{
		throw new todo.TODO();
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public float getQuadraticAttenuation()
	{
		throw new todo.TODO();
	}
	
	public float getSpotAngle()
	{
		throw new todo.TODO();
	}
	
	public float getSpotExponent()
	{
		throw new todo.TODO();
	}
	
	public void setAttenuation(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setIntensity(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setSpotAngle(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setSpotExponent(float __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;

import java.io.IOException;

public class Loader
{
	private Loader()
	{
		throw new todo.TODO();
	}
	
	public static Object3D[] load(byte[] __a, int __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Object3D[] load(String __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Material.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Material
	extends Object3D
{
	public static final int AMBIENT =
		1024;
	
	public static final int DIFFUSE =
		2048;
	
	public static final int EMISSIVE =
		4096;
	
	public static final int SPECULAR =
		8192;
	
	public Material()
	{
		throw new todo.TODO();
	}
	
	public int getColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getShininess()
	{
		throw new todo.TODO();
	}
	
	public boolean isVertexColorTrackingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setShininess(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setVertexColorTrackingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Mesh
	extends Node
{
	public Mesh(VertexBuffer __a, IndexBuffer[] __b, Appearance[] __c)
	{
		throw new todo.TODO();
	}
	
	public Mesh(VertexBuffer __a, IndexBuffer __b, Appearance __c)
	{
		throw new todo.TODO();
	}
	
	public Appearance getAppearance(int __a)
	{
		throw new todo.TODO();
	}
	
	public IndexBuffer getIndexBuffer(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSubmeshCount()
	{
		throw new todo.TODO();
	}
	
	public VertexBuffer getVertexBuffer()
	{
		throw new todo.TODO();
	}
	
	public void setAppearance(int __a, Appearance __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class MorphingMesh
	extends Mesh
{
	public MorphingMesh(VertexBuffer __a, VertexBuffer[] __b, IndexBuffer[] 
		__c, Appearance[] __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public MorphingMesh(VertexBuffer __a, VertexBuffer[] __b, IndexBuffer __c
		, Appearance __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public VertexBuffer getMorphTarget(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getMorphTargetCount()
	{
		throw new todo.TODO();
	}
	
	public void getWeights(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setWeights(float[] __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public abstract class Node
	extends Transformable
{
	public static final int NONE =
		144;
	
	public static final int ORIGIN =
		145;
	
	public static final int X_AXIS =
		146;
	
	public static final int Y_AXIS =
		147;
	
	public static final int Z_AXIS =
		148;
	
	Node()
	{
		throw new todo.TODO();
	}
	
	public final void align(Node __a)
	{
		throw new todo.TODO();
	}
	
	public Node getAlignmentReference(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getAlignmentTarget(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getAlphaFactor()
	{
		throw new todo.TODO();
	}
	
	public Node getParent()
	{
		throw new todo.TODO();
	}
	
	public int getScope()
	{
		throw new todo.TODO();
	}
	
	public boolean getTransformTo(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public boolean isPickingEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isRenderingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setAlignment(Node __a, int __b, Node __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setAlphaFactor(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setPickingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setRenderingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setScope(int __a)
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Object3D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class Object3D
{
	Object3D()
	{
		throw new todo.TODO();
	}
	
	public void addAnimationTrack(AnimationTrack __a)
	{
		throw new todo.TODO();
	}
	
	public final int animate(int __a)
	{
		throw new todo.TODO();
	}
	
	public final Object3D duplicate()
	{
		throw new todo.TODO();
	}
	
	public Object3D find(int __a)
	{
		throw new todo.TODO();
	}
	
	public AnimationTrack getAnimationTrack(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getAnimationTrackCount()
	{
		throw new todo.TODO();
	}
	
	public int getReferences(Object3D[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getUserID()
	{
		throw new todo.TODO();
	}
	
	public Object getUserObject()
	{
		throw new todo.TODO();
	}
	
	public void removeAnimationTrack(AnimationTrack __a)
	{
		throw new todo.TODO();
	}
	
	public void setUserID(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setUserObject(Object __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class PolygonMode
	extends Object3D
{
	public static final int CULL_BACK =
		160;
	
	public static final int CULL_FRONT =
		161;
	
	public static final int CULL_NONE =
		162;
	
	public static final int SHADE_FLAT =
		164;
	
	public static final int SHADE_SMOOTH =
		165;
	
	public static final int WINDING_CCW =
		168;
	
	public static final int WINDING_CW =
		169;
	
	public PolygonMode()
	{
		throw new todo.TODO();
	}
	
	public int getCulling()
	{
		throw new todo.TODO();
	}
	
	public int getShading()
	{
		throw new todo.TODO();
	}
	
	public int getWinding()
	{
		throw new todo.TODO();
	}
	
	public boolean isLocalCameraLightingEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isPerspectiveCorrectionEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isTwoSidedLightingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setCulling(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setLocalCameraLightingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setPerspectiveCorrectionEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setShading(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setTwoSidedLightingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setWinding(int __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class RayIntersection
{
	public RayIntersection()
	{
		throw new todo.TODO();
	}
	
	public float getDistance()
	{
		throw new todo.TODO();
	}
	
	public Node getIntersected()
	{
		throw new todo.TODO();
	}
	
	public float getNormalX()
	{
		throw new todo.TODO();
	}
	
	public float getNormalY()
	{
		throw new todo.TODO();
	}
	
	public float getNormalZ()
	{
		throw new todo.TODO();
	}
	
	public void getRay(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getSubmeshIndex()
	{
		throw new todo.TODO();
	}
	
	public float getTextureS(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getTextureT(int __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class SkinnedMesh
	extends Mesh
{
	public SkinnedMesh(VertexBuffer __a, IndexBuffer[] __b, Appearance[] __c,
		Group __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public SkinnedMesh(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Group __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public void addTransform(Node __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void getBoneTransform(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public int getBoneVertices(Node __a, int[] __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public Group getSkeleton()
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Sprite3D.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Sprite3D
	extends Node
{
	public Sprite3D(boolean __a, Image2D __b, Appearance __c)
	{
		throw new todo.TODO();
	}
	
	public Appearance getAppearance()
	{
		throw new todo.TODO();
	}
	
	public int getCropHeight()
	{
		throw new todo.TODO();
	}
	
	public int getCropWidth()
	{
		throw new todo.TODO();
	}
	
	public int getCropX()
	{
		throw new todo.TODO();
	}
	
	public int getCropY()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public boolean isScaled()
	{
		throw new todo.TODO();
	}
	
	public void setAppearance(Appearance __a)
	{
		throw new todo.TODO();
	}
	
	public void setCrop(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Texture2D
	extends Transformable
{
	public static final int FILTER_BASE_LEVEL =
		208;
	
	public static final int FILTER_LINEAR =
		209;
	
	public static final int FILTER_NEAREST =
		210;
	
	public static final int FUNC_ADD =
		224;
	
	public static final int FUNC_BLEND =
		225;
	
	public static final int FUNC_DECAL =
		226;
	
	public static final int FUNC_MODULATE =
		227;
	
	public static final int FUNC_REPLACE =
		228;
	
	public static final int WRAP_CLAMP =
		240;
	
	public static final int WRAP_REPEAT =
		241;
	
	public Texture2D(Image2D __a)
	{
		throw new todo.TODO();
	}
	
	public int getBlendColor()
	{
		throw new todo.TODO();
	}
	
	public int getBlending()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public int getImageFilter()
	{
		throw new todo.TODO();
	}
	
	public int getLevelFilter()
	{
		throw new todo.TODO();
	}
	
	public int getWrappingS()
	{
		throw new todo.TODO();
	}
	
	public int getWrappingT()
	{
		throw new todo.TODO();
	}
	
	public void setBlendColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setBlending(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFiltering(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
	
	public void setWrapping(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class Transform
{
	public Transform()
	{
		throw new todo.TODO();
	}
	
	public Transform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void get(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void invert()
	{
		throw new todo.TODO();
	}
	
	public void postMultiply(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void postRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void postRotateQuat(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void postScale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void postTranslate(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void set(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void set(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setIdentity()
	{
		throw new todo.TODO();
	}
	
	public void transform(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void transform(VertexArray __a, float[] __b, boolean __c)
	{
		throw new todo.TODO();
	}
	
	public void transpose()
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/Transformable.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class Transformable
	extends Object3D
{
	Transformable()
	{
		throw new todo.TODO();
	}
	
	public void getCompositeTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void getOrientation(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void getScale(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void getTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void getTranslation(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void postRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void preRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void scale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setOrientation(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void setScale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setTranslation(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void translate(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class TriangleStripArray
	extends IndexBuffer
{
	public TriangleStripArray(int[] __a, int[] __b)
	{
		throw new todo.TODO();
	}
	
	public TriangleStripArray(int __a, int[] __b)
	{
		throw new todo.TODO();
	}
	
	@Override
	public int getIndexCount()
	{
		throw new todo.TODO();
	}
	
	@Override
	public void getIndices(int[] __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class VertexArray
	extends Object3D
{
	public VertexArray(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void get(int __a, int __b, byte[] __c)
	{
		throw new todo.TODO();
	}
	
	public void get(int __a, int __b, short[] __c)
	{
		throw new todo.TODO();
	}
	
	public int getComponentCount()
	{
		throw new todo.TODO();
	}
	
	public int getComponentType()
	{
		throw new todo.TODO();
	}
	
	public int getVertexCount()
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, byte[] __c)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, short[] __c)
	{
		throw new todo.TODO();
	}
}


Added modules/m3g/src/main/java/javax/microedition/m3g/VertexBuffer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class VertexBuffer
	extends Object3D
{
	public VertexBuffer()
	{
		throw new todo.TODO();
	}
	
	public VertexArray getColors()
	{
		throw new todo.TODO();
	}
	
	public int getDefaultColor()
	{
		throw new todo.TODO();
	}
	
	public VertexArray getNormals()
	{
		throw new todo.TODO();
	}
	
	public VertexArray getPositions(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public VertexArray getTexCoords(int __a, float[] __b)
	{
		throw new todo.TODO();
	}
	
	public int getVertexCount()
	{
		throw new todo.TODO();
	}
	
	public void setColors(VertexArray __a)
	{
		throw new todo.TODO();
	}
	
	public void setDefaultColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setNormals(VertexArray __a)
	{
		throw new todo.TODO();
	}
	
	public void setPositions(VertexArray __a, float __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public void setTexCoords(int __a, VertexArray __b, float __c, float[] __d
		)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.m3g;


public class World
	extends Group
{
	public World()
	{
		throw new todo.TODO();
	}
	
	public Camera getActiveCamera()
	{
		throw new todo.TODO();
	}
	
	public Background getBackground()
	{
		throw new todo.TODO();
	}
	
	public void setActiveCamera(Camera __a)
	{
		throw new todo.TODO();
	}
	
	public void setBackground(Background __a)
	{
		throw new todo.TODO();
	}
}


Added modules/markdown-writer/build.gradle.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains a formatted markdown " +
	"writer which allows documents to be written to a standard stream yet " +
	"have state on which properties to apply to the output."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "CG"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Markdown Writer"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

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

package net.multiphasicapps.markdownwriter;

/**
 * This describes the type of text style that may be chosen for output.
 *
 * @since 2016/09/13
 */
public enum MarkdownTextStyle
{
	/** Normal style. */
	NORMAL(true),
	
	/** Strong. */
	STRONG(true),
	
	/** Emphasis. */
	EMPHASIS(true),
	
	/** Strong Emphasis. */
	STRONG_EMPHASIS(true),
	
	/** Source code. */
	CODE(false),
	
	/** End. */
	;
	
	/** Is this a normal text style? */
	protected final boolean normal;
	
	/**
	 * Initializes the style information.
	 *
	 * @param __n Is this style considered for non-code text.
	 * @since 2016/09/13
	 */
	MarkdownTextStyle(boolean __n)
	{
		this.normal = __n;
	}
	
	/**
	 * Is this style for normal text?
	 *
	 * @return {@code true} if the style is for normal text.
	 * @since 2016/09/13
	 */
	public final boolean isNormal()
	{
		return this.normal;
	}
}

Added modules/markdown-writer/src/main/java/net/multiphasicapps/markdownwriter/MarkdownWriter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Formatter;
import java.util.Objects;

/**
 * This is a class which writes markdown formatted text to the specified
 * {@link Appendable} which may be any implentation of one. This handle all
 * of the standard formatting details that markdown supports.
 *
 * This writer supports closing and flushing, however those operations will
 * only be performed on the wrapped {@link Appendable} if those also implement
 * such things.
 *
 * This class is not thread safe.
 *
 * @since 2016/09/13
 */
public class MarkdownWriter
	implements Appendable, Closeable
{
	/** Markdown right column limit. */
	public static final int RIGHT_COLUMN =
		76;
	
	/** Where text may be written to. */
	protected final Appendable append;
	
	/** Formatter to write output text. */
	protected final Formatter formatter;
	
	/** The current section being written. */
	volatile __Section__ _section;
	
	/** The current text column. */
	volatile int _column;
	
	/**
	 * Initializes the markdown writer.
	 *
	 * @param __a The appendable to send characters to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public MarkdownWriter(Appendable __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.append = __a;
		
		// Setup formatter
		this.formatter = new Formatter(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/13
	 */
	@Override
	public MarkdownWriter append(char __c)
		throws IOException
	{
		this.__put(__c, false);
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/13
	 */
	@Override
	public MarkdownWriter append(CharSequence __cs)
		throws IOException
	{
		return this.append(__cs, 0, __cs.length());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/13
	 */
	@Override
	public MarkdownWriter append(CharSequence __cs, int __s, int __e)
		throws IOException
	{
		for (int i = __s; i < __e; i++)
			this.__put(__cs.charAt(i), false);
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/13
	 */
	@Override
	public void close()
		throws IOException
	{
		// Flush before close
		try
		{
			this.flush();
		}
		
		// Ignore
		catch (IOException e)
		{
		}
		
		// Only close if it is closeable
		Appendable append = this.append;
		if (append instanceof Closeable)
			((Closeable)append).close();
	}
	
	/**
	 * Flushes this writer.
	 *
	 * @throws IOException If it could not be flushed.
	 * @since 2016/09/13
	 */
	public void flush()
		throws IOException
	{
		// Java ME has no Flushable so we only know of these two classes
		Appendable append = this.append;
		if (append instanceof OutputStream)
			((OutputStream)append).flush();
		else if (append instanceof Writer)
			((Writer)append).flush();
	}
	
	/**
	 * Prints the specified header into the output document.
	 *
	 * @param __abs If {@code true} then the header is at the specified level,
	 * otherwise if {@code false} it will be relative to the existing header
	 * level.
	 * @param __level If absolute then this level is set where the level is
	 * based on an index of one, otherwise this will be the relative header
	 * level adjustment from the current header level.
	 * @param __s The text to print.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public void header(boolean __abs, int __level, String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Setup section
		__SectionHeader__ header = new __SectionHeader__(this, __abs, __level);
		
		// Print header text
		this.append(__s);
		
		// Enter paragraph mode
		this.paragraph();
	}
	
	/**
	 * End a list.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void listEnd()
		throws IOException
	{
		// End the list by 
		__Section__ section = this._section;
		if (section instanceof __SectionList__)
		{
			// Manual end of section
			section.__endSection();
			
			// Go back to the section before this
			this._section = section._sectionbefore;
		}
	}
	
	/**
	 * Go the next item in the list.
	 *
	 * @throws IOException On write errros.
	 * @since 2016/10/01
	 */
	public void listNext()
		throws IOException
	{
		// Set new item on the list
		__Section__ section = this._section;
		if (section instanceof __SectionList__)
			((__SectionList__)section)._newitem = true;
	}
	
	/**
	 * Start a list.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void listStart()
		throws IOException
	{
		// Start section
		new __SectionUnorderedList__(this);
	}
	
	/**
	 * Enters paragraph mode which may be used .
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	public void paragraph()
		throws IOException
	{
		new __SectionParagraph__(this);
	}
	
	/**
	 * Prints a single character.
	 *
	 * @param __c The character to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	public void print(char __c)
		throws IOException
	{
		this.append(__c);
	}
	
	/**
	 * Prints the specified object.
	 *
	 * @param __o The object to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void print(Object __o)
		throws IOException
	{
		this.append(Objects.toString(__o));
	}
	
	/**
	 * Prints formatted text to the output.
	 *
	 * @param __f The format specifier.
	 * @param __args The format arguments.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public void printf(String __f, Object... __args)
		throws IOException, NullPointerException
	{
		// Check
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Format
		this.formatter.format(__f, __args);
	}
	
	/**
	 * Prints the end of the line.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void println()
		throws IOException
	{
		this.append('\n');
	}
	
	/**
	 * Prints the specified object followed by a new line.
	 *
	 * @param __o The object to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void println(Object __o)
		throws IOException
	{
		this.print(__o);
		this.println();
	}
	
	/**
	 * Prints a URI to the output document.
	 *
	 * @param __uri The URI to print.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// Prime
		this.__put('\0', false);
		
		// Print it out
		this.__put('<', true);
		this.append(__uri);
		this.__put('>', true);
	}
	
	/**
	 * Prints a URI to the output document with the given display text.
	 *
	 * @param __uri The URI to point to.
	 * @param __text The display text for the URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri, String __text)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null || __text == null)
			throw new NullPointerException("NARG");
		
		// Prime
		this.__put('\0', false);
		
		// Print it out
		this.__put('[', true);
		this.append(__text);
		this.__put(']', true);
		this.__put('(', true);
		this.__unescapedURI(__uri);
		this.__put(')', true);
	}
	
	/**
	 * Prints a URI to the output document with the given display text.
	 *
	 * @param __uri The URI to point to.
	 * @param __text The display text for the URI.
	 * @param __title The text text for the URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri, String __text, String __title)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null || __text == null || __title == null)
			throw new NullPointerException("NARG");
		
		// Prime
		this.__put('\0', false);
		
		// Print it out
		this.__put('[', true);
		this.append(__text);
		this.__put(']', true);
		this.__put('(', true);
		this.__unescapedURI(__uri);
		this.__put(' ', true);
		this.__put('"', true);
		this.append(__title);
		this.__put('"', true);
		this.__put(')', true);
	}
	
	/**
	 * Returns {@code true} if the specified character is to be escaped.
	 *
	 * @return {@code true} if the character must be escaped.
	 * @since 2016/10/02
	 */
	boolean __escaped(char __c)
	{
		return (__c == '[' || __c == '(' || __c == '*' || __c == '_' ||
			__c == '\\' || __c == '<' || (__c == '#' && this._column == 0));
	}
	
	/**
	 * Places a single character into the output sending the character to
	 * be printed to the currently being written to section.
	 *
	 * @param __c The character to put.
	 * @param __nospec If {@code true} then the character is not given
	 * special handling.
	 * @throws IOException On write errors.
	 * @since 2016/09/13
	 */
	void __put(char __c, boolean __nospec)
		throws IOException
	{
		// Ignore CR
		if (__c == '\r')
			return;
		
		// Direct place if no special handling
		if (__nospec)
		{
			// Ignore null
			if (__c == 0)
				return;
			
			// Add it
			this.append.append(__c);
			
			// Newline resets column
			int column = this._column;
			if (__c == '\n')
				this._column = (column = 0);
			
			// Otherwise it goes up
			else
				this._column = (++column);
			
			// If at the end, go to the next line
			if (column >= MarkdownWriter.RIGHT_COLUMN)
				this.__put('\n', true);
			
			// Done
			return;
		}
		
		// Need section to always exist
		__Section__ section = this._section;
		if (section == null)
			section = new __SectionParagraph__(this);
		
		// Character needs escaping?
		if (this.__escaped(__c))
			section.__process('\\');
		
		// Place character
		section.__process(__c);
	}
	
	/**
	 * Performs special handling for writing URI parts.
	 *
	 * @param __s The input URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/02
	 */
	void __unescapedURI(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Go through all
		int n = __s.length();
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Never escape underscore
			if (this.__escaped(c) || c == '"' || MarkdownWriter.__isWhitespace(c))
				if (c == '_')
					this.__put(c, true);
				
				// Percent encode anything else
				else
				{
					byte[] b = Character.toString(c).getBytes("utf-8");
					int q = b.length;
					this.__put('%', false);
					for (int l = 0; l < q; l++)
					{
						byte d = b[l];
						this.__put(Character.forDigit((d >>> 4) & 0xF, 16), false);
						this.__put(Character.forDigit(d & 0xF, 16), false);
					}
				}
			
			// Otherwise normal print
			else
				this.__put(c, false);
		}
	}
	
	/**
	 * Is this a whitespace character?
	 *
	 * @param __c The character to check.
	 * @return {@code true} if it is whitespace.
	 * @since 2016/10/02
	 */
	static boolean __isWhitespace(char __c)
	{
		return __c == ' ' || __c == '\t' || __c == '\n';
	}
}

Added modules/markdown-writer/src/main/java/net/multiphasicapps/markdownwriter/__SectionHeader__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This section is used for the printing of headers.
 *
 * @since 2016/10/02
 */
class __SectionHeader__
	extends __Section__
{
	/**
	 * Initializes the section header.
	 *
	 * @param __mkd The owning writer.
	 * @param __abs Absolutely set the specified level if {@code true},
	 * otherwise level adjustment will be relative.
	 * @param __level The level to set to if absolute or relative from a
	 * previous level.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionHeader__(MarkdownWriter __mdw, boolean __abs, int __level)
		throws IOException
	{
		super(__mdw);
		
		// Modify level
		int level = this._level;
		level = (__abs ? Math.max(1, __level) : Math.max(1, level + __level));
		this._level = level;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __endSection()
		throws IOException
	{
		super.__endSection();
		
		// Add newline after the first column
		MarkdownWriter writer = this.writer;
		if (writer._column > 0)
			writer.__put('\n', true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If on column zero, add the header bits
		MarkdownWriter writer = this.writer;
		int level = this._level;
		if (writer._column == 0)
		{
			for (int i = 0; i < level; i++)
				writer.__put('#', true);
			writer.__put(' ', true);
		}
		
		// Add character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

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

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is the base section for numerical values.
 *
 * @since 2016/10/02
 */
abstract class __SectionList__
	extends __Section__
{
	/** The current indentation level. */
	volatile int _indent;
	
	/** The character depth (characters used for the bullet). */
	volatile int _cdepth;
	
	/** Create new item entry? */
	volatile boolean _newitem =
		true;
	
	/**
	 * Initializes the base for lists.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionList__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
		
		// If the section before this one is a list then
		__Section__ sectionbefore = this._sectionbefore;
		if (sectionbefore instanceof __SectionList__)
		{
			__SectionList__ was = (__SectionList__)sectionbefore;
			this._indent = was._indent + 1 + was._cdepth;
		}
		
		// Otherwise, start a new list
		else
			this._indent = 1;
	}
	
	/**
	 * Prints the list characters.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	abstract void __listCharacters()
		throws IOException;
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If writing a new item, write it
		MarkdownWriter writer = this.writer;
		if (this._newitem)
		{
			// Add new line
			writer.__put('\n', true);
			
			// Indent with spaces first
			int indent = this._indent;
			for (int i = 0; i < indent; i++)
				writer.__put(' ', true);
			
			// Add list characters
			this.__listCharacters();
			
			// Add sapce
			writer.__put(' ', true);
			
			// Do not write any more new items
			this._newitem = false;
		}
		
		// Indent?
		if (writer._column == 0)
		{
			int indent = this._indent + 1 + this._cdepth;
			for (int i = 0; i < indent; i++)
				writer.__put(' ', true);
		}
		
		// Write normal character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

Added modules/markdown-writer/src/main/java/net/multiphasicapps/markdownwriter/__SectionParagraph__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is for writing normal text that exists within a paragraph.
 *
 * @since 2016/10/02
 */
class __SectionParagraph__
	extends __Section__
{
	/** Just started the paragraph? */
	volatile boolean _juststarted =
		true;
	
	/**
	 * Initializes the paragraph.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionParagraph__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __endSection()
		throws IOException
	{
		super.__endSection();
		
		// Add newline after the first column
		MarkdownWriter writer = this.writer;
		if (writer._column > 0)
			writer.__put('\n', true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If the paragraph just started then add a spacing newline before
		// its content
		MarkdownWriter writer = this.writer;
		if (this._juststarted)
		{
			// Write line
			writer.__put('\n', true);
			
			// No longer started
			this._juststarted = false;
		}
		
		// If this is whitespace then do not print it on the first column ever
		if (MarkdownWriter.__isWhitespace(__c) && writer._column == 0)
			return;
		
		// Write character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

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

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is the unordered list section which is used to place non-numbered
 * bullet point lists.
 *
 * @since 2016/10/02
 */
class __SectionUnorderedList__
	extends __SectionList__
{
	/**
	 * Initializes the unordered list section.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionUnorderedList__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
		
		// Single character is used
		this._cdepth = 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __listCharacters()
		throws IOException
	{
		this.writer.__put('*', true);
	}
}

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

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is the base class for all sections within the markdown writer, this is
 * used to modify how data is written to the output file when it is written.
 *
 * The constructor for a section will automatically set itself as the newest
 * section and initialize it from a previous one.
 *
 * @since 2016/10/02
 */
abstract class __Section__
{
	/** The target writer. */
	protected final MarkdownWriter writer;
	
	/** The section that was at the top. */
	final __Section__ _sectionbefore;
	
	/** The current text style to use. */
	volatile MarkdownTextStyle _style =
		MarkdownTextStyle.NORMAL;
	
	/** The section header level. */
	volatile int _level;
	
	/**
	 * Initializes a new section.
	 *
	 * @param __mdw The writer where characters are placed.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/02
	 */
	__Section__(MarkdownWriter __mdw)
		throws IOException, NullPointerException
	{
		// Check
		if (__mdw == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.writer = __mdw;
		
		// Is there anything above this?
		__Section__ _sectionbefore = __mdw._section;
		this._sectionbefore = _sectionbefore;
		
		// If there is a section before this then end this
		if (_sectionbefore != null)
			_sectionbefore.__endSection();
		
		// Set new section
		__mdw._section = this;
		
		// Set some basic details
		this._level = (_sectionbefore == null ? 1 : _sectionbefore._level);
	}
	
	/**
	 * Puts the specified character into the section as if it were written.
	 *
	 * @param __c The character to place.
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	abstract void __process(char __c)
		throws IOException;
	
	/**
	 * This may be replaced by sub-classes to end the specified section.
	 *
	 * Classes should always call the super-class method first.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	void __endSection()
		throws IOException
	{
	}
}

Added modules/markdown-writer/src/main/java/net/multiphasicapps/markdownwriter/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the markdown writer.
 *
 * @since 2016/09/13
 */

package net.multiphasicapps.markdownwriter;

Added modules/media-api/build.gradle.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains the implementation of " +
	"the MIDP 3.0 Media API which is also specified in JSR 135."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EA"
	swmType = JavaMEMidletType.API
	swmName = "Media API"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/media-api/src/main/java/cc/squirreljme/runtime/media/NullPlayer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.media;

import java.util.LinkedList;
import java.util.List;
import javax.microedition.media.Control;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.TimeBase;

/**
 * This is a player which does nothing.
 *
 * @since 2019/04/15
 */
public final class NullPlayer
	implements Player
{
	/** The mime type. */
	private final String mime;
	
	/** Listeners available. */
	private final List<PlayerListener> _listeners =
		new LinkedList<>();
	
	/** The timebase. */
	private TimeBase _timebase =
		Manager.getSystemTimeBase();
	
	/** The state of the player. */
	private volatile int _state = Player.UNREALIZED;
	
	/**
	 * Initializes the player.
	 *
	 * @param __mime The mime type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	public NullPlayer(String __mime)
		throws NullPointerException
	{
		if (__mime == null)
			throw new NullPointerException("NARG");
		
		this.mime = __mime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void addPlayerListener(PlayerListener __l)
	{
		// Ignore?
		if (__l == null)
			return;
		
		// {@squirreljme.error EA01 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA01");
		
		// Add unique listener
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			if (!listeners.contains(__l))
				listeners.add(__l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void close()
	{
		if (this._state != Player.CLOSED)
		{
			this._state = Player.CLOSED;
			
			// Send event
			this.__event(PlayerListener.CLOSED, null);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void deallocate()
	{
		// {@squirreljme.error EA03 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA03");
		
		if (this._state == Player.STARTED)
		{
			// Implicit stop state
			try
			{
				this.stop();
			}
			catch (MediaException e)
			{
				e.printStackTrace();
			}
			
			// Become realized
			this._state = Player.REALIZED;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final String getContentType()
	{
		return this.mime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final Control getControl(String __v)
	{
		// {@squirreljme.error AE07 No control specified.}
		if (__v == null)
			throw new IllegalArgumentException("AE07");
		
		if (__v.equals("VolumeControl") ||
			__v.equals("javax.microedition.media.control.VolumeControl"))
			return new NullVolumeControl();
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final Control[] getControls()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getDuration()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getMediaTime()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int getState()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final TimeBase getTimeBase()
	{
		return this._timebase;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void prefetch()
		throws MediaException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void realize()
		throws MediaException
	{
		// {@squirreljme.error EA04 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA04");
		
		if (this._state != Player.UNREALIZED)
			this._state = Player.REALIZED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void removePlayerListener(PlayerListener __l)
	{
		// Ignore?
		if (__l == null)
			return;
		
		// {@squirreljme.error EA02 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA02");
		
		// Remove it
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			listeners.remove(__l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void setLoopCount(int __a)
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long setMediaTime(long __a)
		throws MediaException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void setTimeBase(TimeBase __a)
		throws MediaException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void start()
		throws MediaException
	{
		// {@squirreljme.error EA05 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA05");
		
		if (this._state != Player.STARTED || this._state == Player.PREFETCHED)
		{
			this._state = Player.STARTED;
			
			// Send event
			this.__event(PlayerListener.STARTED,
				Long.valueOf(this._timebase.getTime()));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void stop()
		throws MediaException
	{
		// {@squirreljme.error EA06 Null Player has been closed.}
		if (this._state == Player.CLOSED)
			throw new IllegalStateException("EA06");
		
		if (this._state != Player.STARTED)
		{
			this._state = Player.PREFETCHED;
			
			// Send event
			this.__event(PlayerListener.STOPPED,
				Long.valueOf(this._timebase.getTime()));
		}
	}
	
	/**
	 * Sends an event to all listeners.
	 *
	 * @param __key The key used.
	 * @param __val The value used.
	 * @since 2019/06/28
	 */
	private final void __event(String __key, Object __val)
	{
		PlayerListener[] poke;
		
		// Get listeners to poke
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			poke = listeners.<PlayerListener>toArray(
				new PlayerListener[listeners.size()]);
		}
		
		// Poke them all
		for (PlayerListener pl : poke)
			try
			{
				pl.playerUpdate(this, __key, __val);
			}
			catch (Throwable t)
			{
				t.printStackTrace();
			}
	}
}

Added modules/media-api/src/main/java/cc/squirreljme/runtime/media/NullVolumeControl.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.media;

import javax.microedition.media.control.VolumeControl;

/**
 * This is a volume control which does nothing.
 *
 * @since 2019/06/29
 */
public final class NullVolumeControl
	implements VolumeControl
{
	/** Current volume level. */
	private int _level =
		100;
	
	/** Is muted? */
	private boolean _mute;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int getLevel()
	{
		return this._level;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final boolean isMuted()
	{
		return this._mute;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int setLevel(int __v)
	{
		this._level = (__v = (__v < 0 ? 0 : (__v > 100 ? 100 : __v)));
		return __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final void setMute(boolean __v)
	{
		this._mute = __v;
	}
}

Added modules/media-api/src/main/java/cc/squirreljme/runtime/media/SystemNanoTimeBase.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.media;

import javax.microedition.media.TimeBase;

/**
 * This is a time base which uses the System nano-time clock.
 *
 * @since 2019/04/15
 */
public final class SystemNanoTimeBase
	implements TimeBase
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getTime()
	{
		// Measured in microseconds
		return System.nanoTime() / 1000L;
	}
}

Added modules/media-api/src/main/java/cc/squirreljme/runtime/media/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the support for media and such.
 *
 * @since 2019/04/15
 */

package cc.squirreljme.runtime.media;

Added modules/media-api/src/main/java/javax/microedition/media/Control.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface Control
{
}


Added modules/media-api/src/main/java/javax/microedition/media/Controllable.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface Controllable
{
	Control getControl(String __a);
	
	Control[] getControls();
}


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

package javax.microedition.media;

import cc.squirreljme.runtime.media.NullPlayer;
import cc.squirreljme.runtime.media.SystemNanoTimeBase;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.media.protocol.DataSource;

public final class Manager
{
	public static final String MIDI_DEVICE_LOCATOR =
		"device://midi";
	
	public static final String TONE_DEVICE_LOCATOR =
		"device://tone";
	
	/**
	 * Not used.
	 *
	 * @since 2017/02/28
	 */
	private Manager()
	{
	}
	
	public static Player createPlayer(InputStream __a, String __b)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s, %s)%n", __a, __b);
		if (true)
			return new NullPlayer(__b);
		
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static Player createPlayer(String __a)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s)%n", __a);
		if (true)
			return new NullPlayer("application/octet-stream");
			
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static Player createPlayer(DataSource __a)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s)%n", __a);
		if (true)
			return new NullPlayer(__a.getContentType());
		
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static String[] getSupportedContentTypes(String __a)
	{
		todo.DEBUG.note("getSupportedContentTypes(%s)%n", __a);
		throw new todo.TODO();
	}
	
	public static String[] getSupportedProtocols(String __a)
	{
		todo.DEBUG.note("getSupportedProtocols(%s)%n", __a);
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default timebase.
	 *
	 * @return The default timebase.
	 * @since 2019/04/15
	 */
	public static TimeBase getSystemTimeBase()
	{
		return new SystemNanoTimeBase();
	}
	
	public static void playTone(int __a, int __b, int __c)
		throws MediaException
	{
		todo.DEBUG.note("playTone(%d, %d, %d)%n", __a, __b, __c);
		if (true)
			throw new MediaException("TODO");
		
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
}


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

package javax.microedition.media;

/**
 * This is thrown when there was a problem with the media.
 *
 * @since 2019/04/15
 */
public class MediaException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/04/15
	 */
	public MediaException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message to use.
	 * @since 2019/04/15
	 */
	public MediaException(String __m)
	{
		super(__m);
	}
}


Added modules/media-api/src/main/java/javax/microedition/media/Player.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;

public interface Player
	extends Controllable
{
	int CLOSED =
		0;
	
	int PREFETCHED =
		300;
	
	int REALIZED =
		200;
	
	int STARTED =
		400;
	
	long TIME_UNKNOWN =
		-1L;
	
	int UNREALIZED =
		100;
	
	void addPlayerListener(PlayerListener __a);
	
	void close();
	
	void deallocate();
	
	String getContentType();
	
	long getDuration();
	
	long getMediaTime();
	
	int getState();
	
	TimeBase getTimeBase();
	
	void prefetch()
		throws MediaException;
	
	void realize()
		throws MediaException;
	
	void removePlayerListener(PlayerListener __a);
	
	void setLoopCount(int __a);
	
	long setMediaTime(long __a)
		throws MediaException;
	
	void setTimeBase(TimeBase __a)
		throws MediaException;
	
	void start()
		throws MediaException;
	
	void stop()
		throws MediaException;
}


Added modules/media-api/src/main/java/javax/microedition/media/PlayerListener.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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface PlayerListener
{
	String BUFFERING_STARTED =
		"bufferingStarted";
	
	String BUFFERING_STOPPED =
		"bufferingStopped";
	
	String CLOSED =
		"closed";
	
	String DEVICE_AVAILABLE =
		"deviceAvailable";
	
	String DEVICE_UNAVAILABLE =
		"deviceUnavailable";
	
	String DURATION_UPDATED =
		"durationUpdated";
	
	String END_OF_MEDIA =
		"endOfMedia";
	
	String ERROR =
		"error";
	
	String RECORD_ERROR =
		"recordError";
	
	String RECORD_STARTED =
		"recordStarted";
	
	String RECORD_STOPPED =
		"recordStopped";
	
	String SIZE_CHANGED =
		"sizeChanged";
	
	String STARTED =
		"started";
	
	String STOPPED =
		"stopped";
	
	String STOPPED_AT_TIME =
		"stoppedAtTime";
	
	String VOLUME_CHANGED =
		"volumeChanged";
	
	void playerUpdate(Player __a, String __b, Object __c);
}


Added modules/media-api/src/main/java/javax/microedition/media/TimeBase.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface TimeBase
{
	long getTime();
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface FramePositioningControl
	extends Control
{
	long mapFrameToTime(int __a);
	
	int mapTimeToFrame(long __a);
	
	int seek(int __a);
	
	int skip(int __a);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface GUIControl
	extends Control
{
	int USE_GUI_PRIMITIVE =
		0;
	
	Object initDisplayMode(int __a, Object __b);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;
import javax.microedition.media.MediaException;

public interface MIDIControl
	extends Control
{
	int CONTROL_CHANGE =
		176;
	
	int NOTE_ON =
		144;
	
	int[] getBankList(boolean __a)
		throws MediaException;
	
	int getChannelVolume(int __a);
	
	String getKeyName(int __a, int __b, int __c)
		throws MediaException;
	
	int[] getProgram(int __a)
		throws MediaException;
	
	int[] getProgramList(int __a)
		throws MediaException;
	
	String getProgramName(int __a, int __b)
		throws MediaException;
	
	boolean isBankQuerySupported();
	
	int longMidiEvent(byte[] __a, int __b, int __c);
	
	void setChannelVolume(int __a, int __b);
	
	void setProgram(int __a, int __b, int __c);
	
	void shortMidiEvent(int __a, int __b, int __c);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface MetaDataControl
	extends Control
{
	String AUTHOR_KEY =
		"author";
	
	String COPYRIGHT_KEY =
		"copyright";
	
	String DATE_KEY =
		"date";
	
	String TITLE_KEY =
		"title";
	
	String getKeyValue(String __a);
	
	String[] getKeys();
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface PitchControl
	extends Control
{
	int getMaxPitch();
	
	int getMinPitch();
	
	int getPitch();
	
	int setPitch(int __a);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface RateControl
	extends Control
{
	int getMaxRate();
	
	int getMinRate();
	
	int getRate();
	
	int setRate(int __a);
}


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

package javax.microedition.media.control;

import java.io.IOException;
import java.io.OutputStream;
import javax.microedition.media.Control;
import javax.microedition.media.MediaException;

public interface RecordControl
	extends Control
{
	void commit()
		throws IOException;
	
	String getContentType();
	
	void reset()
		throws IOException;
	
	void setRecordLocation(String __a)
		throws IOException, MediaException;
	
	int setRecordSizeLimit(int __a)
		throws MediaException;
	
	void setRecordStream(OutputStream __a);
	
	void startRecord();
	
	void stopRecord();
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface StopTimeControl
	extends Control
{
	long RESET =
		9223372036854775807L;
	
	long getStopTime();
	
	void setStopTime(long __a);
}


Added modules/media-api/src/main/java/javax/microedition/media/control/TempoControl.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;


public interface TempoControl
	extends RateControl
{
	int getTempo();
	
	int setTempo(int __a);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface ToneControl
	extends Control
{
	byte BLOCK_END =
		-6;
	
	byte BLOCK_START =
		-5;
	
	byte C4 =
		60;
	
	byte PLAY_BLOCK =
		-7;
	
	byte REPEAT =
		-9;
	
	byte RESOLUTION =
		-4;
	
	byte SET_VOLUME =
		-8;
	
	byte SILENCE =
		-1;
	
	byte TEMPO =
		-3;
	
	byte VERSION =
		-2;
	
	void setSequence(byte[] __a);
}


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

package javax.microedition.media.control;

import javax.microedition.media.MediaException;

public interface VideoControl
	extends GUIControl
{
	int USE_DIRECT_VIDEO =
		1;
	
	int getDisplayHeight();
	
	int getDisplayWidth();
	
	int getDisplayX();
	
	int getDisplayY();
	
	byte[] getSnapshot(String __a)
		throws MediaException;
	
	int getSourceHeight();
	
	int getSourceWidth();
	
	Object initDisplayMode(int __a, Object __b);
	
	void setDisplayFullScreen(boolean __a)
		throws MediaException;
	
	void setDisplayLocation(int __a, int __b);
	
	void setDisplaySize(int __a, int __b)
		throws MediaException;
	
	void setVisible(boolean __a);
}


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

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface VolumeControl
	extends Control
{
	int getLevel();
	
	boolean isMuted();
	
	int setLevel(int __a);
	
	void setMute(boolean __a);
}


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

package javax.microedition.media.protocol;


public class ContentDescriptor
{
	public ContentDescriptor(String __a)
	{
		throw new todo.TODO();
	}
	
	public String getContentType()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.media.protocol;

import java.io.IOException;
import javax.microedition.media.Control;
import javax.microedition.media.Controllable;

public abstract class DataSource
	implements Controllable
{
	public DataSource(String __a)
	{
		throw new todo.TODO();
	}
	
	public abstract void connect()
		throws IOException;
	
	public abstract void disconnect();
	
	public abstract String getContentType();
	
	public abstract Control getControl(String __a);
	
	public abstract Control[] getControls();
	
	public abstract SourceStream[] getStreams();
	
	public abstract void start()
		throws IOException;
	
	public abstract void stop()
		throws IOException;
	
	public String getLocator()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.media.protocol;

import java.io.IOException;
import javax.microedition.media.Controllable;

public interface SourceStream
	extends Controllable
{
	int NOT_SEEKABLE =
		0;
	
	int RANDOM_ACCESSIBLE =
		2;
	
	int SEEKABLE_TO_START =
		1;
	
	ContentDescriptor getContentDescriptor();
	
	long getContentLength();
	
	int getSeekType();
	
	int getTransferSize();
	
	int read(byte[] __a, int __b, int __c)
		throws IOException;
	
	long seek(long __a)
		throws IOException;
	
	long tell();
}


Added modules/meep-cellular/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides an implementation which is used " +
	"to access cellular networks."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DH"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Cellular Networking"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.cellular;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-concurrency/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "The concurrency APIs allows multiple applications to run " +
	"at the same time."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DK"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Concurrency"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.concurrency;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-event/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides an interface which allows an " +
	"application to receive events from the system along withsending events " +
	"to other running applications."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DI"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Event Management"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.event;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-key/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains classes for handling key and other " +
	"user input events."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DB"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Key Events"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.key;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-key/src/main/java/javax/microedition/key/InputDevice.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.key;

public interface InputDevice
{
	void setKeyListener(KeyListener __l);

	String getId();

	boolean isHardwareAssigned();

	void setHardwareAssigned(boolean __h);
}

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

package javax.microedition.key;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/08/30
 */
public interface InputDeviceListener
{
	void hardwareStateChanged(InputDevice __dev, boolean __hw);

	void inputDeviceAdded(InputDevice __dev);

	void inputDeviceRemoved(InputDevice __dev);
}

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

package javax.microedition.key;

public interface KeyListener
{
	int DOWN =
		6;
		
	int KEY_BACKSPACE =
		8;
		
	int KEY_DELETE =
		127;
		
	int KEY_DOWN =
		-2;
		
	int KEY_ENTER =
		10;
		
	int KEY_ESCAPE =
		27;
		
	int KEY_LEFT =
		-3;
		
	int KEY_NUM0 =
		48;
		
	int KEY_NUM1 =
		49;
		
	int KEY_NUM2 =
		50;
		
	int KEY_NUM3 =
		51;
		
	int KEY_NUM4 =
		52;
		
	int KEY_NUM5 =
		53;
		
	int KEY_NUM6 =
		54;
		
	int KEY_NUM7 =
		55;
		
	int KEY_NUM8 =
		56;
		
	int KEY_NUM9 =
		57;
		
	int KEY_POUND =
		35;
		
	int KEY_RIGHT =
		-4;
		
	int KEY_SELECT =
		-5;
		
	int KEY_SPACE =
		32;
		
	int KEY_STAR =
		42;
		
	int KEY_TAB =
		9;
		
	int KEY_UP =
		-1;
		
	int LEFT =
		2;
		
	int MODIFIER_ALT =
		65536;
		
	int MODIFIER_CHR =
		8388608;
		
	int MODIFIER_COMMAND =
		4194304;
		
	int MODIFIER_CTRL =
		262144;
		
	int MODIFIER_MASK =
		13041664;
		
	int MODIFIER_SHIFT =
		131072;
		
	int RIGHT =
		5;
		
	int UP =
		1;

	void keyPressed(InputDevice __dev, int __code, int __mod);

	void keyReleased(InputDevice __dev, int __code, int __mod);

	void keyRepeated(InputDevice __dev, int __code, int __mod);
}

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

package javax.microedition.key;

import java.util.Iterator;

public class KeyManager
{
	/**
	 * Not used.
	 *
	 * @since 2016/08/30
	 */
	private KeyManager()
	{
	}
	
	public static Iterator<InputDevice> getInputDevices()
	{
		throw new todo.TODO();
	}

	public static Iterator<InputDevice> getHeadlessInputDevices()
	{
		throw new todo.TODO();
	}

	public static void addInputDeviceListener(InputDeviceListener __dl)
	{
		throw new todo.TODO();
	}

	public static void removeInputDeviceListener(InputDeviceListener __dl)
	{
		throw new todo.TODO();
	}

	public static void setGeneralKeyListener(KeyListener __kl)
	{
		throw new todo.TODO();
	}
}

Added modules/meep-key/src/main/java/javax/microedition/key/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the keyboard input interfaces.
 *
 * @since 2016/08/30
 */

package javax.microedition.key;

Added modules/meep-liblets/build.gradle.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides support for application suites and LIBlets."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DL"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Application Suites and LIBlets"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.liblets;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-lui/build.gradle.

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains the base support for the line " +
	"based interface."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DA"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Line Based Interface"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.lui;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-key")
	implementation project(":modules:collections")
	implementation project(":modules:gcf")
}

Added modules/meep-lui/src/main/java/cc/squirreljme/runtime/lui/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the interfaces which the MEEP LUI code uses to
 * implement line based user interface display drivers.
 *
 * @since 2016/09/07
 */

package cc.squirreljme.runtime.lui;

Added modules/meep-lui/src/main/java/javax/microedition/lui/Display.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lui;

import java.util.Iterator;

/**
 * This provides an interface to basic text based displays.
 *
 * There may be multiple displays associated with a device and the displays
 * that are available may change at any rate. It is possible for a display to
 * support user input, which in this case it will generate key events.
 *
 * A single hardware display may be shared by multiple instances of these
 * classes, which one is actually visible is implementation dependent.
 *
 * Primary displays are ones that will never be removed. Primary displays
 * are always listed first.
 *
 * Auxiliary displays are ones that may be dynamically added and removed.
 *
 * Set text on a display may be lost depending on the implementation such as
 * if it implements scrolling in a specific fashion or the text does not fit.
 * As such, obtained text may be what is visible or might be what was not
 * truncated when set. Thus if {@code "SquirrelJME"} was set to the display
 * and scrolling was enabled, then it might return that text or something
 * such as {@code "JMESquirrel"}. An exception to this is line breaks where
 * if a line contains too much text it flows onto the next line, in this case
 * the text is treated as a single line and the break is not in the returned
 * text. Setting of text may enable scrolling if it is available.
 *
 * Color selection should always be the closest matching color that is
 * supported on a given display.
 *
 * Internally to SquirrelJME, this class acts as a wrapper around display
 * driver interfaces which are implemented via the service loader.
 * If a display supports user input then it must implement
 * the {@link javax.microedition.key.InputDevice} interface.
 *
 * @since 2016/08/30
 */
public class Display
{
	/**
	 * This is used as the event name to indicate the lighting level.
	 *
	 * The value will be either {@link #LIGHTING_ON}, {@link #LIGHTING_OFF},
	 * or {@link #LIGHTING_DIM}.
	 */
	public static final String LIGHTING =
		"LIGHTING";
	
	/**
	 * This indicates that the light level is not fully bright nor off, but
	 * is somewhere inbetween.
	 */
	public static final int LIGHTING_DIM =
		2;
	
	/** This indicates that the light level for a display is zero (off). */
	public static final int LIGHTING_OFF =
		0;
	
	/** The indicates that the light level for a display is bright. */
	public static final int LIGHTING_ON =
		1;
	
	/**
	 * This is used to specify that any power saving actions for a given
	 * display are to be deferred for as long as possible to increase the
	 * amount of time that the display is visible for.
	 */
	public static final int MODE_ACTIVE =
		1;
	
	/**
	 * This is used to specify that the display may enter a power saving mode
	 * for example when the device is idle and no input has been generated.
	 */
	public static final int MODE_NORMAL =
		0;
	
	/** Internal lock. */
	private final Object _lock =
		new Object();
	
	/**
	 * Displays are internally managed by this class and as such cannot be
	 * constructed publically or by drivers.
	 *
	 * @since 2016/10/08
	 */
	Display()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the color which represents the color which is actually being
	 * display by a given display.
	 *
	 * If background colors are not supported then this returns the default
	 * background color.
	 *
	 * @return The closest matching background color.
	 * @since 2016/08/30
	 */
	public DisplayColor getBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of characters which appear on a single line.
	 *
	 * @return The characters per line.
	 * @since 2016/08/30
	 */
	public int getCharacterNumberPerLine()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reads all of the characters on a given display starting at index zero.
	 *
	 * If the array contains more characters than the display then the extra
	 * characters remain untouched.
	 *
	 * It is recommended to pass an array that is large enough to read all
	 * characters from the display.
	 *
	 * @param __o The output array to read characters into.
	 * @return The number of read characters.
	 * @throws ArrayIndexOutOfBoundsException If the array is too small to
	 * fit every character.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public int getChars(char[] __o)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Reads all of the characters on a given line starting at index zero.
	 *
	 * If the array contains more characters than the display then the extra
	 * characters remain untouched.
	 *
	 * It is recommended to pass an array that is large enough to read all
	 * characters from the display.
	 *
	 * @param __l The line number to get characters from.
	 * @param __o The output array to read characters into.
	 * @return The number of read characters.
	 * @throws ArrayIndexOutOfBoundsException If the array is too small to
	 * fit the entire line; or the line exceeds the bounds of the display.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public int getChars(int __l, char[] __o)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the text color that is currently used on the display. If text
	 * colors are not supported then the default color is returned.
	 *
	 * @return The text color which is used on the display.
	 * @since 2016/08/30
	 */
	public DisplayColor getCurrentTextColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default background color.
	 *
	 * @return The default background color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default lighting color.
	 *
	 * @return The default lighting color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultLightingColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default text color.
	 *
	 * @return The default text color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultTextColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of milliseconds between character shifts for the
	 * given line.
	 *
	 * If the display does not support horizontal scrolling then the value
	 * returned here is meaningless.
	 *
	 * @param __l The line to get the scrolling interval of.
	 * @return The scrolling interval.
	 * @throws ArrayIndexOutOfBoundsException If the specified line is not
	 * within the bounds of the display.
	 * @since 2016/08/30
	 */
	public int getHorizontalScrollingInterval(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the identification of the given display. It is recommended for
	 * the same hardware displays to return the same ID even if the given
	 * {@link Display} object has changed.
	 *
	 * @return The display identification.
	 * @since 2016/08/30
	 */
	public String getId()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current lighting color of the display. If lighting is not
	 * supported then this will return the default color.
	 *
	 * @return The currently set lighting color.
	 * @since 2016/08/30
	 */
	public DisplayColor getLightingColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of lines which are available for the display.
	 *
	 * @return The number of lines the display uses.
	 * @since 2016/08/30
	 */
	public int getNumberOfLines()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current text which has previously been set.
	 *
	 * @return The current text display.
	 * @since 2016/08/30
	 */
	public String getText()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current text which has previously been set on a given line.
	 *
	 * @param __l The line to get the text for.
	 * @return The text on the given line.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public String getText(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of milliseconds that must pass before lines are
	 * shifted. If vertical scrolling is not supported then the return value is
	 * meaningless.
	 *
	 * @return The interval used for vertical scrolling.
	 * @since 2016/08/30
	 */
	public int getVerticalScrollingInterval()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if background colors are supported.
	 *
	 * @return {@code true} if background colors are supported.
	 * @since 2016/08/30
	 */
	public boolean isBackgroundColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if this display is built-in and is not auxiliary
	 * meaning that the display will never be removed. Otherwise {@code false}
	 * indicates that it may disappear.
	 *
	 * @return {@code true} if the display is built-in.
	 * @since 2016/08/30
	 */
	public boolean isBuiltIn()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This returns {@code true} if the display has access to the underlying
	 * hardware, which means it is capable of receiving user input and is
	 * currently displayed to the user.
	 *
	 * @return {@code true} if the display has access to the underlying
	 * hardware.
	 * @since 2016/08/30
	 */
	public boolean isHardwareAssigned()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if the specified line has horizontal scrolling
	 * enabled. If horizontal scrolling is not enabled then the return value
	 * is meaningless.
	 *
	 * @param __l The line to check.
	 * @return {@code true} if horizontal scrolling is enabled for the given
	 * line.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public boolean isHorizontalScrollingEnabled(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if horizontal scrolling is supported on the
	 * display.
	 *
	 * @return {@code true} if horizontal scrolling is supported.
	 * @since 2016/08/30
	 */
	public boolean isHorizontalScrollingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns true if the color of the lighting color is able to be changed.
	 *
	 * @return {@code true} if the lighting color can be changed.
	 * @since 2016/08/30
	 */
	public boolean isLightingColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if lighting is supported.
	 *
	 * @return {@code true} if lighting is supported.
	 * @since 2016/08/30
	 */
	public boolean isLightingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if text colors are supported.
	 *
	 * @return {@code true} if text colors are supported.
	 * @since 2016/08/30
	 */
	public boolean isTextColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if vertical scrolling is enabled.
	 *
	 * @return {@code true} if vertical scrolling is enabled.
	 * @since 2016/08/30
	 */
	public boolean isVerticalScrollingEnabled()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if vertical scrolling is supported.
	 *
	 * @return {@code true} if vertical scrolling is supported.
	 * @since 2016/08/30
	 */
	public boolean isVerticalScrollingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the background color of the display. The closest matching color
	 * should be selected by the display.
	 *
	 * If lighting is supported then {@code __c} being set to {@code null}
	 * turns off the light. Otherwise the light is turned on when a color is
	 * set.
	 *
	 * @param __c The color to set.
	 * @return The color which was used by the display.
	 * @since 2016/08/30
	 */
	public DisplayColor setBackgroundColor(DisplayColor __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @since 2016/08/30
	 */
	public void setChars(char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException
	{
		this.setChars(__c, __o, __l, false, false);
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @since 2016/08/30
	 */
	public void setChars(char[] __c, int __o, int __l, boolean __blink,
		boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds; or the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setChars(int __ln, char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException
	{
		this.setChars(__ln, __c, __o, __l, false, false);
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds; or the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setChars(int __ln, char[] __c, int __o, int __l,
		boolean __blink, boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the color of the text on the display.
	 *
	 * @param __c The color to set.
	 * @return The actual color which has been set.
	 * @since 2016/08/30
	 */
	public DisplayColor setCurrentTextColor(DisplayColor __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Requests that a display should be assigned to the hardware so that it
	 * can be displayed and receive user input.
	 *
	 * @param __h If {@code true} then it should be assigned to the hardware,
	 * otherwise {@code false} may unassign it.
	 * @since 2016/08/30
	 */
	public void setHardwareAssigned(boolean __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables horizontal scrolling for a given line.
	 *
	 * If both directions of scrolling is supported then this scrolls left to
	 * right.
	 *
	 * @param __l The line to set scrolling for.
	 * @param __e If {@code true} then scrolling is enabled.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrolling(int __l, boolean __e)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables horizontal scrolling for a given line.
	 *
	 * @param __l The line to set scrolling for.
	 * @param __e If {@code true} then scrolling is enabled.
	 * @param __dir If {@code true} then text scrolls left to right while
	 * {@code false} means right to left.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrolling(int __l, boolean __e, boolean __dir)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the amount of time in milliseconds before the next character is
	 * shifted on the given line.
	 *
	 * @param __l The line to modify the scrolling interval for.
	 * @param __i The number of milliseconds to use for the interval, a value
	 * of zero indicates the fastest scrolling possible.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @throws IllegalArgumentException If the interval is negative.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrollingInterval(int __l, int __i)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the color of the light to use for the given display.
	 *
	 * If {@code null} is specified then the light is turned off, otherwise
	 * it is switched on.
	 *
	 * @param __l The color to use for the light.
	 * @return The actually used color.
	 * @since 2016/08/30
	 */
	public DisplayColor setLightingColor(DisplayColor __l)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __t The text to display.
	 * @since 2016/08/30
	 */
	public void setText(String __t)
	{
		this.setText(__t, false, false);
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __t The text to display.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @since 2016/08/30
	 */
	public void setText(String __t, boolean __blink, boolean __inverse)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __t The text to display.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setText(int __ln, String __t)
		throws ArrayIndexOutOfBoundsException
	{
		this.setText(__ln, __t, false, false);
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __t The text to display.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setText(int __ln, String __t, boolean __blink,
		boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables vertical scrolling.
	 *
	 * If either direction is supported then this scrolls top to bottom.
	 *
	 * @param __e If {@code true} then vertical scrolling is enabled.
	 * @since 2016/08/30
	 */
	public void setVerticalScrolling(boolean __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables vertical scrolling.
	 *
	 * @param __e If {@code true} then vertical scrolling is enabled.
	 * @param __dir If {@code true} then the display scrolls top to bottom,
	 * otherwise {@code false} scrolls bottom to top.
	 * @since 2016/08/30
	 */
	public void setVerticalScrolling(boolean __e, boolean __dir)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the vertical scrolling interval, the amount of time it takes before
	 * the next line is shifted.
	 *
	 * @param __ms The number of milliseconds to wait before lines are shifted.
	 * A value of {@code 0} indicates that the fastest scrolling should be
	 * used.
	 * @throws IllegalArgumentException If the interval is negative.
	 * @since 2016/08/30
	 */
	public void setVerticalScrollingInterval(int __ms)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is used to register a listener for when displays are added,
	 * removed, or their state has been changed.
	 *
	 * @param __l The listener to add, if it has already been added then this
	 * has no effect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public static void addDisplayListener(DisplayListener __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * This returns an iterator containing any displays which are available
	 * for usage. Primary displays are always returned first.
	 *
	 * The returned iterator will be empty if all displays are taken by other
	 * applications or if they are non-attached auxiliary displays.
	 *
	 * It is recommended to call {@link #isHardwareAssigned()} to determine
	 * if the display is associated with the underlying hardware.
	 *
	 * @param __ks If {@code true} then only displays which support key input
	 * events will be returned, otherwise all displays will be used.
	 * @return An iterator over the displays which are available, the returned
	 * iterator may be empty (if there are no displays) and will never contain
	 * the same display multiple times.
	 * @since 2016/08/30
	 */
	public static Iterator<Display> getDisplays(boolean __ks)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Removes the specified listener so that it no longer receives display
	 * events.
	 *
	 * @param __l The listener to remove, if it has never been added then this
	 * has no effect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public static void removeDisplayListener(DisplayListener __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

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

package javax.microedition.lui;

/**
 * This represents the capabilities that a display supports in hardware.
 *
 * @since 2016/08/30
 */
public enum DisplayCapability
{
	/** Supports background colors. */
	SUPPORTS_BACKGROUND_COLORS,
	
	/** Supports horizontal scrolling. */
	SUPPORTS_HORIZONTAL_SCROLLING,
	
	/** Supports key events. */
	SUPPORTS_KEY_EVENTS,
	
	/** Supports lighting (backlight). */
	SUPPORTS_LIGHTING,
	
	/** Supports lighting with different colors (backlight). */
	SUPPORTS_LIGHTING_COLORS,
	
	/** Supports text colors. */
	SUPPORTS_TEXT_COLORS,
	
	/** Supports vertical scrolling. */
	SUPPORTS_VERTICAL_SCROLLING,
	
	/** End. */
	;
}

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

package javax.microedition.lui;

/**
 * This represents a color to be used for text colors, background colors, and
 * lighting colors.
 *
 * @since 2016/08/30
 */
public class DisplayColor
{
	/** Color components. */
	private final int _rgb;
	
	/**
	 * Initializes the color using the given components, the components must
	 * be in the range of 0 through 255.
	 *
	 * @param __r Red color component.
	 * @param __g Green color component.
	 * @param __b Blue color component.
	 * @throws IllegalArgumentException If any component is outside of the
	 * range if {@code [0, 255]}.
	 * @since 2016/08/30
	 */
	public DisplayColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error DA01 Initialization of color values out of
		// range, they must be in the range of 0-255. (Red; Green; Blue)}
		if (__r < 0 || __r > 255 || __g < 0 || __g > 255 || __b < 0 ||
			__b > 255)
			throw new IllegalArgumentException(String.format("DA01 %d %d %d",
				__r, __g, __b));
		
		// Set
		this._rgb = (__r << 16) | (__g << 8) | __b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof DisplayColor))
			return false;
		
		// Cast and check
		DisplayColor o = (DisplayColor)__o;
		return this.getRedComponent() == o.getRedComponent() && this
			.getGreenComponent() == o.getGreenComponent() && this
			.getBlueComponent() == o.getBlueComponent();
	}
	
	/**
	 * Returns the blue component.
	 *
	 * @return The blue component.
	 * @since 2016/08/30
	 */
	public int getBlueComponent()
	{
		return (this._rgb & 0xFF);
	}
	
	/**
	 * Returns the green component.
	 *
	 * @return The green component.
	 * @since 2016/08/30
	 */
	public int getGreenComponent()
	{
		return ((this._rgb >>> 8) & 0xFF);
	}
	
	/**
	 * Returns the red component.
	 *
	 * @return The red component.
	 * @since 2016/08/30
	 */
	public int getRedComponent()
	{
		return ((this._rgb >>> 16) & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public int hashCode()
	{
		return this._rgb;
	}
}

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

package javax.microedition.lui;

/**
 * This is a listener which is associated with the {@link Display} class and
 * is called in the event that new displays are added or removed from a
 * device.
 *
 * @since 2016/08/30
 */
public interface DisplayListener
{
	/**
	 * This is called when a new display has been added to the device.
	 *
	 * @param __d The display which was added.
	 * @since 2016/08/30
	 */
	void displayAdded(Display __d);
	
	/**
	 * This is called when a display has been removed from the device, any
	 * actions on the display following this might not have any effect.
	 *
	 * @param __d The display which was removed.
	 * @since 2016/08/30
	 */
	void displayRemoved(Display __d);
	
	/**
	 * This is called when the state of a display changes in hardware.
	 *
	 * @param __d The display that changed state.
	 * @param __ns If {@code true} then the display was reassigned on the
	 * underlying hardware, if {@code false} then the display was unassigned.
	 * @since 2016/08/30
	 */
	void hardwareStateChanged(Display __d, boolean __ns);
}

Added modules/meep-lui/src/main/java/javax/microedition/lui/package-info.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the line based user interface which is used to provide a
 * terminal/console based interface with the user. This interface would be
 * used in situations where the graphical image based interface is not
 * supported.
 *
 * @since 2016/08/30
 */

package javax.microedition.lui;

Added modules/meep-midlet/build.gradle.

























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains the MIDlet interface which " +
	"acts as the main entry point for all MIDlets."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AD"
	swmType = JavaMEMidletType.API
	swmName = "MEEP MIDlet Interface"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.midlet;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:tool-manifest-reader")
	implementation project(":modules:strings")
	implementation project(":modules:collections")
}

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

package cc.squirreljme.runtime.midlet;

import javax.microedition.midlet.MIDlet;

/**
 * This is used to store the current MIDlet which is being run in the current
 * process.
 *
 * @since 2017/02/26
 */
public final class ActiveMidlet
{
	/** Lock to prevent multiple midlets from running. */
	private static final Object _ACTIVE_LOCK =
		new Object();
	
	/** Only a single midlet may run at a time. */
	private static volatile MIDlet _ACTIVE_MIDLET;
	
	/**
	 * Not used.
	 *
	 * @since 2017/02/26
	 */
	private ActiveMidlet()
	{
	}
	
	/**
	 * Returns the currently active midlet.
	 *
	 * @return The active midlet.
	 * @throws IllegalStateException If no midlet is set.
	 * @since 2017/02/26
	 */
	public static MIDlet get()
		throws IllegalStateException
	{
		MIDlet rv = ActiveMidlet.optional();
		
		// {@squirreljme.error AD01 No MIDlet is currently active.}
		if (rv == null)
			throw new IllegalStateException("AD01");
		
		return rv;
	}
	
	/**
	 * Returns the currently active midlet.
	 *
	 * @return The active midlet or {@code null} if none is active.
	 * @since 2019/04/14
	 */
	public static MIDlet optional()
		throws IllegalStateException
	{
		// Lock
		synchronized (ActiveMidlet._ACTIVE_LOCK)
		{
			return ActiveMidlet._ACTIVE_MIDLET;
		}
	}
	
	/**
	 * Sets the currently active midlet.
	 *
	 * @param __m The midlet to set.
	 * @throws IllegalStateException If a midlet is already set.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/26
	 */
	public static void set(MIDlet __m)
		throws IllegalStateException, NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Prevent multiple MIDlet instantiations
		synchronized (ActiveMidlet._ACTIVE_LOCK)
		{
			// {@squirreljme.error AD02 Only a single MIDlet may be active at
			// a time.}
			MIDlet active = ActiveMidlet._ACTIVE_MIDLET;
			if (active != null &&
				!(__m instanceof OverrideActiveMidletRestriction))
				throw new IllegalStateException("AD02");
			
			// Set active midlet
			ActiveMidlet._ACTIVE_MIDLET = __m;
		}
	}
}

Added modules/meep-midlet/src/main/java/cc/squirreljme/runtime/midlet/OverrideActiveMidletRestriction.java.












1
2
3
4
5
6
7
8
9
10
11
+
+
+
+
+
+
+
+
+
+
+
package cc.squirreljme.runtime.midlet;

/**
 * This overrides the active MIDlet restriction allowing it to replace
 * other active MIDlets, this should only be used for tests.
 *
 * @since 2020/02/23
 */
public interface OverrideActiveMidletRestriction
{
}

Added modules/meep-midlet/src/main/java/cc/squirreljme/runtime/midlet/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains SquirrelJME specific midlet code.
 *
 * @since 2016/10/16
 */

package cc.squirreljme.runtime.midlet;

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

package javax.microedition.midlet;

import java.security.BasicPermission;
import java.security.Permission;

public final class AutoStartPermission
	extends BasicPermission
{
	public AutoStartPermission()
	{
		super(null);
		throw new todo.TODO();
	}

	public boolean implies(Permission __p)
	{
		throw new todo.TODO();
	}
}

Added modules/meep-midlet/src/main/java/javax/microedition/midlet/MIDlet.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.midlet;

import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

public abstract class MIDlet
{
	/** This is the prefix used to override settings. */
	private static final String _APP_PROPERTY_OVERRIDE =
		"cc.squirreljme.runtime.midlet.override.";
	
	/** The cached manifest for obtaining properties. */
	private Reference<JavaManifest> _manifest;
	
	/** Is there no manifest? */
	private boolean _nomanifest;
	
	/**
	 * Initialize the MIDlet.
	 *
	 * @since 2017/02/08
	 */
	protected MIDlet()
	{
		// Set the active midlet to this one
		ActiveMidlet.set(this);
	}
	
	/**
	 * Signals that the MIDlet is in the destruction state.
	 *
	 * @param __uc Is is unconditional?
	 * @throws MIDletStateChangeException If the destruction might stop.
	 * @since 2020/02/29
	 */
	protected abstract void destroyApp(boolean __uc)
		throws MIDletStateChangeException;
	
	protected abstract void startApp()
		throws MIDletStateChangeException;
	
	/**
	 * Checks if the given permission is valid.
	 *
	 * Do not use this to check permissions.
	 *
	 * @param __p The permission to check.
	 * @return {@code 0} if permission is denied, {@code 1} if permitted,
	 * and {@code -1} if unknown.
	 * @throws IllegalStateException If this is a MIDP 3.0 application.
	 * @since 2019/05/05
	 */
	@Deprecated
	public final int checkPermission(String __p)
		throws IllegalStateException
	{
		// Ignore if null
		if (__p == null)
			return 1;
		
		// Not permitted on MIDP 3 or MEEP
		String profile = this.getAppProperty("microedition-profile");
		if (profile != null)
		{
			// Makes it easier to use
			profile = profile.toLowerCase();
			
			// {@squirreljme.error AD03 Cannot use check permission on
			// MIDP 3.0 or MEEP suite profiles.}
			if (profile.contains("midp-3") || profile.contains("meep"))
				throw new IllegalStateException("AD03");
		}
		
		// Do security check
		try
		{
			// If there is no security manager, just assume everything is
			// okay
			SecurityManager sm = System.getSecurityManager();
			if (sm == null)
				return 1;
			
			// Check it now
			sm.checkPermission(new RuntimePermission(__p));
			return 1;
		}
		catch (SecurityException e)
		{
			return 0;
		}
	}
	
	/**
	 * Obtains the value of a property for the current application. Properties
	 * are defined in the application descriptor along with the manifest file
	 * of the JAR.
	 *
	 * @param __p The property to obtain.
	 * @return The value of the given property or {@code null} if it is not
	 * defined.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/07
	 */
	public final String getAppProperty(String __p)
		throws NullPointerException
	{
		// Check
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Overridden property?
		JavaManifestKey key = new JavaManifestKey(__p);
		String val = System.getProperty(MIDlet._APP_PROPERTY_OVERRIDE + key);
		if (val != null)
			return val.trim();
		
		// If there is not manifest, ignore this step
		if (!this._nomanifest)
		{
			// Lookup JAR manifest
			Reference<JavaManifest> ref = this._manifest;
			JavaManifest manifest;
		
			// Cache it?
			if (ref == null || (null == (manifest = ref.get())))
			{
				// Some application properties are inside of the manifest so
				// check that
				InputStream is = this.getClass().getResourceAsStream(
					"META-INF/MANIFEST.MF");
				try
				{
					// Not found, force failure
					if (is == null)
						throw new IOException();
					
					// Load it
					manifest = new JavaManifest(is);
					
					// Store it
					this._manifest = new WeakReference<>(manifest);
				}
				
				// Does not exist or failed to read
				catch (IOException e)
				{
					this._nomanifest = true;
					manifest = null;
				}
			}
			
			// Try to get key value
			if (manifest != null)
			{
				String rv = manifest.getMainAttributes().get(
					new JavaManifestKey(__p));
				if (rv != null)
					return rv.trim();
			}
		}
		
		// Key not found or no manifest
		return null;
	}
	
	/**
	 * Used by the application to notify the MIDlet that it has entered the
	 * destroyed state and resources should be cleaned up and such. When this
	 * is called the program will be terminated.
	 *
	 * @since 2019/04/15
	 */
	public final void notifyDestroyed()
	{
		todo.DEBUG.note("Notification of destruction");
		
		// Kill the program
		System.exit(0);
	}
	
	/**
	 * Notifies that the application should be paused now.
	 *
	 * This does nothing on SquirrelJME.
	 *
	 * @since 2017/02/08
	 */
	@Deprecated
	public final void notifyPaused()
	{
	}
	
	/**
	 * This is code which should be called before the application is paused.
	 * 
	 * This does nothing on SquirrelJME.
	 *
	 * @since 2017/02/08
	 */
	@Deprecated
	public void pauseApp()
	{
	}
	
	public final boolean platformRequest(String __url)
		throws Exception
	{
		// Games from Konami require this to return true even though that means
		// the application should terminate after this point. This is handled
		// and does not thrown an exception on bad requests.
		// Returning false here will cause the games to not work.
		if ("hjoja".equals(__url))
			return true;
		
		// Debug
		todo.DEBUG.note("%s", __url);
		
		throw new todo.TODO();
	}
	
	@Deprecated
	public final void resumeRequest()
	{
		throw new todo.TODO();
	}
	
	public static String getAppProperty(String __name, String __vend,
		String __attrname, String __attrdelim)
		throws NullPointerException
	{
		if (__attrname == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

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

package javax.microedition.midlet;

public final class MIDletIdentity
{
	/**
	 * Internally intialized.
	 *
	 * @since 2016/08/30
	 */
	MIDletIdentity()
	{
		throw new todo.TODO();
	}
	
	public String getClient()
	{
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public String getVendor()
	{
		throw new todo.TODO();
	}
	
	public String getVersion()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.midlet;

/**
 * This must be thrown if the state change in a MIDlet has failed, however
 * it is deprecated and no longer should be used.
 *
 * @since 2019/09/25
 */
@Deprecated
public class MIDletStateChangeException
	extends Exception
{
	/**
	 * Initializes the exception with no message,
	 *
	 * @since 2019/09/25
	 */
	@Deprecated
	public MIDletStateChangeException()
	{
	}

	/**
	 * Initializes the exception with the given message,
	 *
	 * @param __s The message to use.
	 * @since 2019/09/25
	 */
	@Deprecated
	public MIDletStateChangeException(String __s)
	{
		super(__s);
	}
}

Added modules/meep-midlet/src/main/java/javax/microedition/midlet/__MainHandler__.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 javax.microedition.midlet;

import cc.squirreljme.runtime.cldc.Poking;

/**
 * This class
 *
 * @since 2020/02/29
 */
final class __MainHandler__
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @throws Throwable On any exception.
	 * @since 2020/02/29
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// {@squirreljme.error AD02 No main MIDlet class specified.}
		if (__args == null || __args.length < 1 || __args[0] == null)
			throw new IllegalArgumentException("AD02");
		
		// We might be on the emulator
		Poking.poke();
		
		// Locate the main class before we initialize it
		Class<?> classType;
		try
		{
			classType = Class.forName(__args[0]);
		}
		catch (ClassNotFoundException e)
		{
			// {@squirreljme.error AD03 Could not find main MIDlet. (Class)}
			throw new RuntimeException(String.format(
				"AD03 %s", __args[0]), e);
		}
		
		// Create instance of the MIDlet
		MIDlet instance;
		try
		{
			// Create it
			Object rawInstance = classType.newInstance();
			
			// Catch class casts here because if there is one while the
			// instance is being created it will not be erroneously caught
			try
			{
				instance = (MIDlet)rawInstance;
			}
			catch (ClassCastException e)
			{
				// {@squirreljme.error AD05 Class not a MIDlet.}
				throw new RuntimeException("AD05", e);
			}
		}
		catch (IllegalAccessException|InstantiationException e)
		{
			// {@squirreljme.error AD04 Could not instantiate class.}
			throw new RuntimeException("AD04", e);
		}
		
		// Start the MIDlet and perform any potential handling of it
		try
		{
			instance.startApp();
		}
		finally
		{
			// Always try to destroy the MIDlet
			try
			{
				instance.destroyApp(true);
			}
			catch (MIDletStateChangeException e)
			{
				// Ignore, but still print a trace
				e.printStackTrace(System.err);
			}
			
			// Application is gone now, exit
			instance.notifyDestroyed();
		}
	}
}

Added modules/meep-midlet/src/main/java/javax/microedition/midlet/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This containts the MIDlet interface.
 *
 * @since 2016/08/30
 */

package javax.microedition.midlet;

Added modules/meep-power/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides support for quering the current " +
	"electrical state of the device along with the setting of potential new " +
	"power modes."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DJ"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Power Management"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.power;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-provisioning/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This provides support for provisioning new " +
	"MIDlets and LIBlets which may exist on the network and can beseen in a " +
	"way as a remote application downloader and installerexcept by a more " +
	"concrete means. It is possible for applicationsto automatically be " +
	"updated."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DM"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Provisioning"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.provisioning;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-rms/build.gradle.



























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains the implementation of the " +
	"record management system which is used to manage records whichmay be " +
	"used instead of the filesystem (if a filesystem is notsupported)."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DC"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Record Management System"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.rms;;")
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:meep-midlet")
	implementation project(":modules:tool-manifest-writer")
	implementation project(":modules:meep-swm")
	implementation project(":modules:collections")
}

Added modules/meep-rms/src/main/java/cc/squirreljme/runtime/rms/BasicVinylLock.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
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

/**
 * This is a basic lock which is entirely managed within the current
 * application.
 *
 * @since 2018/12/14
 */
public final class BasicVinylLock
	implements VinylLock
{
	/** The state of the lock. */
	private volatile boolean _locked;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	public final void close()
	{
		synchronized (this)
		{
			this._locked = false;
		}
	}
	
	/**
	 * Locks this record so only a single set of actions can be performed on
	 * them, even for the same thread.
	 *
	 * @return {@code this}.
	 * @since 2018/12/14
	 */
	public final VinylLock lock()
	{
		for (;;)
			synchronized (this)
			{
				// Wait for the lock if it is locked
				if (this._locked)
				{
					try
					{
						this.wait();
					}
					catch (InterruptedException e)
					{
						// Ignore
					}
					
					// Try again
					continue;
				}
				
				// Otherwise lock and return self
				this._locked = true;
				return this;
			}
	}
}

Added modules/meep-rms/src/main/java/cc/squirreljme/runtime/rms/SuiteIdentifier.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.rms;

import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import javax.microedition.midlet.MIDlet;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskManager;

/**
 * This is used to help identify suites and such.
 *
 * @since 2019/04/14
 */
public final class SuiteIdentifier
{
	/** The identifier for the current suite. */
	private static long _CURRENT_ID;
	
	/** The current vendor. */
	private static String _CURRENT_VENDOR;
	
	/** The current name. */
	private static String _CURRENT_NAME;
	
	/**
	 * Not used.
	 *
	 * @since 2019/04/14
	 */
	private SuiteIdentifier()
	{
	}
	
	/**
	 * Returns the current identifier.
	 *
	 * @return The current identifier.
	 * @since 2019/04/14
	 */
	public static long currentIdentifier()
	{
		// Already been cached?
		long rv = SuiteIdentifier._CURRENT_ID;
		if (rv != 0)
			return rv;
		
		// Set, cache, and store
		SuiteIdentifier._CURRENT_ID = (rv = SuiteIdentifier.identifier(
			SuiteIdentifier.currentVendor(), SuiteIdentifier.currentName()));
		return rv;
	}
	
	/**
	 * Returns the current name.
	 *
	 * @return The current name.
	 * @since 2019/04/14
	 */
	public static String currentName()
	{
		String rv = SuiteIdentifier._CURRENT_NAME;
		if (rv != null)
			return rv;
		
		// Use task manager
		if (ApiLevel.minimumLevel(ApiLevel.UNDEFINED))
		{
			// Need to obtain the current suite
			TaskManager tm = ManagerFactory.getTaskManager();
			Task ct = tm.getCurrentTask();
			Suite su = ct.getSuite();
			
			// Get
			rv = su.getName();
		}
		
		// Try through the current MIDlet properties
		if (rv == null)
		{
			MIDlet mid = ActiveMidlet.optional();
			if (mid != null)
				rv = mid.getAppProperty("MIDlet-Name");
		}
		
		// Fallback
		if (rv == null)
			rv = "UndefinedName";
		
		// Cache and return
		SuiteIdentifier._CURRENT_NAME = rv;
		return rv;
	}
	
	/**
	 * Returns the current vendor.
	 *
	 * @return The current vendor.
	 * @since 2019/04/14
	 */
	public static String currentVendor()
	{
		String rv = SuiteIdentifier._CURRENT_VENDOR;
		if (rv != null)
			return rv;
		
		// Use task manager
		if (ApiLevel.minimumLevel(ApiLevel.UNDEFINED))
		{
			// Need to obtain the current suite
			TaskManager tm = ManagerFactory.getTaskManager();
			Task ct = tm.getCurrentTask();
			Suite su = ct.getSuite();
			
			// Get
			rv = su.getVendor();
		}
		
		// Try through the current MIDlet properties
		if (rv == null)
		{
			MIDlet mid = ActiveMidlet.optional();
			if (mid != null)
				rv = mid.getAppProperty("MIDlet-Vendor");
		}
		
		// Fallback
		if (rv == null)
			rv = "UndefinedVendor";
		
		// Cache and return
		SuiteIdentifier._CURRENT_VENDOR = rv;
		return rv;
	}
	
	/**
	 * Returns the suite identifier.
	 *
	 * @param __vend The vendor.
	 * @param __suite The suite.
	 * @return The identifier.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static long identifier(String __vend, String __suite)
		throws NullPointerException
	{
		if (__vend == null || __suite == null)
			throw new NullPointerException("NARG");
		
		return ((((long)__vend.hashCode()) & 0xFFFFFFFFL) << 32) |
			(((long)__suite.hashCode()) & 0xFFFFFFFFL);
	}
}

Added modules/meep-rms/src/main/java/cc/squirreljme/runtime/rms/TemporaryVinylRecord.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * This is a vinyl record which stores all of its data within in memory
 * buffers.
 *
 * @since 2018/12/13
 */
public final class TemporaryVinylRecord
	implements VinylRecord
{
	/** The lock for this record. */
	protected final BasicVinylLock lock =
		new BasicVinylLock();
	
	/** Tracks which are available. */
	private final Map<Integer, Volume> _volumes =
		new LinkedHashMap<>();
	
	/** Next ID for storage. */
	private volatile int _nextvid =
		1;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	public final VinylLock lock()
	{
		return this.lock.lock();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int pageAdd(int __vid, byte[] __b, int __o, int __l,
		int __tag)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Create new page
		int pid = vol._nextpid++;
		Page page;
		vol._pages.put(pid, (page = new Page(pid)));
		
		// Volume modified
		vol._modcount++;
		vol._modtime = System.currentTimeMillis();
		
		// Store page data, will return the PID or error
		return page.setData(__b, __o, __l, __tag);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageDelete(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return VinylRecord.ERROR_NO_PAGE;
		
		// Just remove it
		vol._pages.remove(__pid);
		
		// Return ID of the deleted page
		return __pid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int[] pageList(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return new int[]{VinylRecord.ERROR_NO_VOLUME};
		
		// Get page IDs
		Set<Integer> keys = vol._pages.keySet();
		int n = keys.size(),
			i = 0;
		int[] rv = new int[n];
		for (Integer v : keys)
			rv[i++] = v;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageNextId(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Return guessed next ID
		return vol._nextpid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int pageRead(int __vid, int __pid, byte[] __b, int __o,
		int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return VinylRecord.ERROR_NO_PAGE;
		
		// Determine read limit
		byte[] data = page._data;
		int pagelen = data.length;
		if (__l > pagelen)
			__l = pagelen;
		
		// Copy data
		for (int i = 0; i < __l; i++, __o++)
			__b[__o] = data[i];
		
		// All would have been read
		return __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageSet(int __vid, int __pid, byte[] __b, int __o,
		int __l, int __tag)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return VinylRecord.ERROR_NO_PAGE;
			
		// Volume modified
		vol._modcount++;
		vol._modtime = System.currentTimeMillis();
		
		// Store page data, will return the PID or error
		return page.setData(__b, __o, __l, __tag);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/01
	 */
	@Override
	public final int pageSize(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return VinylRecord.ERROR_NO_PAGE;
		
		// Return data length
		return page._data.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int pageTag(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return VinylRecord.ERROR_NO_PAGE;
		
		// Return page tag
		return page._tag;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int vinylSizeAvailable()
	{
		// This is technically limited by memory
		return (int)Math.min(Integer.MAX_VALUE,
			Runtime.getRuntime().freeMemory());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int volumeCreate(long __sid, String __n, boolean __wo)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Claim next ID
		int rv = this._nextvid++;
		
		// Make the track and store it
		this._volumes.put(rv, new Volume(rv, __sid, __n, __wo));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int[] volumeList()
	{
		Set<Integer> keys = this._volumes.keySet();
		
		// Setup basic integer array
		int n = keys.size();
		int[] rv = new int[n];
		
		// Fill in keys
		int at = 0;
		for (int v : keys)
			rv[at++] = v;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int volumeModCount(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		return vol._modcount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int volumeModTime(int __vid, long[] __time)
		throws NullPointerException
	{
		if (__time == null)
			throw new NullPointerException("NARG");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return VinylRecord.ERROR_NO_VOLUME;
		
		if (__time.length > 0)
			__time[0] = vol._modtime;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final String volumeName(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return null;
		return vol.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final boolean volumeOtherWritable(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return false;
		return vol.writeother;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final long volumeSuiteIdentifier(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return 0L;
		return vol.sid;
	}
	
	/**
	 * Represents a single page.
	 *
	 * @since 2019/04/15
	 */
	public static final class Page
	{
		/** The page ID. */
		protected final int pid;
		
		/** The page data. */
		volatile byte[] _data;
		
		/** The tag. */
		volatile int _tag;
		
		/**
		 * Initializes the page.
		 *
		 * @param __pid The page ID.
		 * @since 2019/04/15
		 */
		public Page(int __pid)
		{
			// Setup PID
			this.pid = __pid;
		}
		
		/**
		 * Sets the page data.
		 *
		 * @param __b The byte data.
		 * @param __o Offset into data.
		 * @param __l The length of data.
		 * @param __tag The tag for the page.
		 * @return The page ID or a negative value if an error.
		 * @throws IndexOutOfBoundsException If the offset and/or length
		 * exceed the array bounds.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/15
		 */
		public final int setData(byte[] __b, int __o, int __l, int __tag)
			throws IndexOutOfBoundsException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Create copy of the data
			try
			{
				// Allocate and copy data
				byte[] place = new byte[__l];
				for (int i = __o, o = 0; o < __l; i++, o++)
					place[o] = __b[i];
				
				// Store this data
				this._data = place;
			}
			
			// No memory to store this data?
			catch (OutOfMemoryError e)
			{
				return VinylRecord.ERROR_NO_MEMORY;
			}
			
			// Set tag
			this._tag = __tag;
			
			// Return PID
			return this.pid;
		}
	}
	
	/**
	 * Represents a single volume.
	 *
	 * @since 2019/04/14
	 */
	public static final class Volume
	{
		/** The volume ID. */
		protected final int vid;
		
		/** The suite identifier. */
		protected final long sid;
		
		/** The suite name. */
		protected final String name;
		
		/** Allow write by others? */
		protected final boolean writeother;
		
		/** Pages in this volume. */
		final Map<Integer, Page> _pages = 
			new LinkedHashMap<>();
		
		/** The next page ID. */
		volatile int _nextpid =
			1;
		
		/** Modification count. */
		volatile int _modcount =
			0;
		
		/** Modification time. */
		volatile long _modtime =
			System.currentTimeMillis();
		
		/**
		 * Initializes the volume.
		 *
		 * @param __vid The volume ID.
		 * @param __sid The suite identifier.
		 * @param __name The name of the record.
		 * @param __wo Allow write by others?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/14
		 */
		public Volume(int __vid, long __sid, String __name, boolean __wo)
			throws NullPointerException
		{
			if (__name == null)
				throw new NullPointerException("NARG");
			
			this.vid = __vid;
			this.sid = __sid;
			this.name = __name;
			this.writeother = __wo;
		}
	}
}

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

package cc.squirreljme.runtime.rms;

/**
 * This is a lock for a vinyl record which may be unlocked when closed.
 *
 * @since 2018/12/14
 */
public interface VinylLock
	extends AutoCloseable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	void close();
}

Added modules/meep-rms/src/main/java/cc/squirreljme/runtime/rms/VinylRecord.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

/**
 * This is a single record which stores multiple tracks of data.
 *
 * Vinyls have a single lock on them.
 *
 * @since 2018/12/13
 */
public interface VinylRecord
{
	/** No memory is available. */
	int ERROR_NO_MEMORY =
		-1;
	
	/** No such volume. */
	int ERROR_NO_VOLUME =
		-2;
	
	/** No such page. */
	int ERROR_NO_PAGE =
		-3;
	
	/**
	 * Locks this record so only a single set of actions can be performed on
	 * them, even for the same thread.
	 *
	 * @return The lock used to eventually unlock, to be used with
	 * try-with-resources.
	 * @since 2018/12/14
	 */
	VinylLock lock();
	
	/**
	 * Adds a page to the given volume.
	 *
	 * @param __vid The volume ID.
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return The ID of the newly created page.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	int pageAdd(int __vid, byte[] __b, int __o, int __l, int __tag)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Deletes the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The page that was deleted or an error.
	 * @since 2019/06/09
	 */
	int pageDelete(int __vid, int __pid);
	
	/**
	 * Returns the list of pages in the volume.
	 *
	 * @param __vid The volume ID.
	 * @return The list of records, if the volume is not valid then
	 * the first entry will be the error code.
	 * @since 2019/04/15
	 */
	int[] pageList(int __vid);
	
	/**
	 * Returns the ID of the next page ID that might be used.
	 *
	 * @param __vid The volume ID.
	 * @return The next page ID or an error.
	 * @since 2019/06/09
	 */
	int pageNextId(int __vid);
	
	/**
	 * Returns the data of the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @param __b The output buffer.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or an error otherwise.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	int pageRead(int __vid, int __pid, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Sets a page to the given value.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return Should be the ID of the same page, otherwise an error.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/09
	 */
	int pageSet(int __vid, int __pid, byte[] __b, int __o, int __l, int __tag)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Returns the size of the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The size of the page or an error otherwise.
	 * @since 2019/05/01
	 */
	int pageSize(int __vid, int __pid);
	
	/**
	 * Returns the tag of the page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The tag identifier.
	 * @since 2019/05/13
	 */
	int pageTag(int __vid, int __pid);
	
	/**
	 * Returns the amount of space available for this record.
	 *
	 * @return The available space count.
	 * @since 2019/05/13
	 */
	int vinylSizeAvailable();
	
	/**
	 * Creates a new record.
	 *
	 * @param __sid The suite identifier.
	 * @param __n The name of the suite.
	 * @param __wo Allow write other?
	 * @return The identifier of the suite.
	 * @since 2019/04/14
	 */
	int volumeCreate(long __sid, String __n, boolean __wo);
	
	/**
	 * Returns the list of all available stores.
	 *
	 * @return The list of available stores.
	 * @since 2019/04/14
	 */
	int[] volumeList();
	
	/**
	 * Returns the modification count of the volume.
	 *
	 * @param __vid The volume ID.
	 * @return The modification count or an error.
	 * @since 2019/05/13
	 */
	int volumeModCount(int __vid);
	
	/**
	 * Returns the modification time of the volume.
	 *
	 * @param __vid The volume ID.
	 * @param __time The output time.
	 * @return Zero or an error.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	int volumeModTime(int __vid, long[] __time)
		throws NullPointerException;
	
	/**
	 * Returns the name of the given record.
	 *
	 * @param __vid Volume ID.
	 * @return The name of the record or {@code null} if there is no name.
	 * @since 2019/04/14
	 */
	String volumeName(int __vid);
	
	/**
	 * Returns the suite identifier for the given record.
	 *
	 * @param __vid Volume ID.
	 * @return The suite identifier or {@code 0} if it is not valid.
	 * @since 2019/04/14
	 */
	long volumeSuiteIdentifier(int __vid);
	
	/**
	 * Returns if this volume is other writable.
	 *
	 * @param __vid The volume ID.
	 * @return If it is writable by others.
	 * @since 2019/04/15
	 */
	boolean volumeOtherWritable(int __vid);
}

Added modules/meep-rms/src/main/java/cc/squirreljme/runtime/rms/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the SquirrelJME specific interfaces for the record
 * management system.
 *
 * @since 2017/02/27
 */

package cc.squirreljme.runtime.rms;

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

package javax.microedition.rms;

/**
 * This is thrown when the ID for a record is not valid.
 *
 * @since 2017/02/26
 */
public class InvalidRecordIDException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public InvalidRecordIDException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public InvalidRecordIDException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.rms;

/**
 * This is an interface which defines a method for comparing records in an
 * implementation defined manner.
 *
 * As an example the comparator may be used by the {@link RecordEnumeration}
 * in the following manner:
 * {@code
 * RecordComparator comp = new CustomRecordComparator();
 * if (comp.compare(recordstore.getRecord(a), recordstore.getRecord(b)) ==
 *     RecordComparator.PRECEDES)
 *     return a;
 * }
 *
 * @see RecordEnumeration
 * @see RecordFilter
 * @since 2017/02/26
 */
public interface RecordComparator
{
	/** This represents two equal records. */
	int EQUIVALENT =
		0;
	
	/** This represents a record that follows another. */
	int FOLLOWS =
		1;
	
	/** This represents a record that precedes another. */
	int PRECEDES =
		-1;
	
	/**
	 * Compares the data in one record with the data in another record.
	 *
	 * @param __a The first record, the array must not be modified by the
	 * comparator.
	 * @param __b The second record, the array must not be modified by the
	 * comparator.
	 * @return The record comparison, one of {@link #EQUIVALENT},
	 * {@link #FOLLOWS}, or {@link #PRECEDES}.
	 * @since 2017/02/26
	 */
	int compare(byte[] __a, byte[] __b);
}

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

package javax.microedition.rms;

/**
 * This is used to enumerate over a record store and may travel in either
 * direction.
 *
 * If the {@link RecordStore} has been closed then
 * {@link RecordStoreNotOpenException} must be thrown even if it was later
 * re-opened. When closed the previous and next methods will return
 * {@code null}.
 *
 * If a {@link RecordStore} is modified during enumeration then some records
 * may become invalid, for this a {@link RecordListener} may be used to be
 * notified when records are added or removed.
 *
 * {@link RecordComparator} may be used to modify the iteration order and the
 * {@link RecordFilter} may be used to remove undesired entries.
 *
 * @see RecordFilter
 * @see RecordComparator
 * @since 2017/02/26
 */
public interface RecordEnumeration
{
	/**
	 * This should be called when the enumeration is no longer needed and as
	 * such it can free resources.
	 *
	 * @since 2017/02/26
	 */
	void destroy();
	
	/**
	 * This is used to quickly obtain the record at the specified index within
	 * this enumeration. When using this behavior it is recommended to not
	 * keep the enumeraton up to date, otherwise it is implementation defined.
	 *
	 * @param __i The index to get.
	 * @return The record ID.
	 * @throws IllegalArgumentException If the index is negative or is at
	 * least {@link #numRecords()}.
	 * @since 2017/02/26
	 */
	int getRecordId(int __i)
		throws IllegalArgumentException;
	
	/**
	 * Returns {@code true} if there is a next element.
	 *
	 * @return {@code true} if there is a next element.
	 * @since 2017/02/26
	 */
	boolean hasNextElement();
	
	/**
	 * Returns {@code true} if there is a previous element.
	 *
	 * @return {@code true} if there is a previous element.
	 * @since 2017/02/26
	 */
	boolean hasPreviousElement();
	
	/**
	 * Returns {@code true} if the enumeration is kept up to date with changes.
	 *
	 * @return {@code true} if the enumeration is kept up to date with changes.
	 * @since 2017/02/26
	 */
	boolean isKeptUpdated();
	
	/**
	 * This is used by the enumeration to specify that it should be kept up
	 * to date with any record changes.
	 *
	 * If set to {@code true} this also performs the equivalent call to
	 * {@link #rebuild()}.
	 *
	 * Note that keeping enumerations up to date may cause performance issues.
	 *
	 * @param __u If {@code true} then the enumeration is kept updated.
	 * @since 2017/02/26
	 */
	void keepUpdated(boolean __u);
	
	/**
	 * Returns a copy of the data contained in the next record. Changes to the
	 * returned array will not modify the data in the record.
	 *
	 * @return The data for the next record.
	 * @throws InvalidRecordIDException If the record is not valid.
	 * @throws RecordStoreException If another unspecified exception occurs.
	 * @throws RecordStoreNotOpenException This is called when the record store
	 * is no longer open.
	 * @since 2017/02/26
	 */
	byte[] nextRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException;
	
	/**
	 * Returns the identifier of the next record.
	 *
	 * @return The next record.
	 * @throws InvalidRecordIDException If there is no next record.
	 * @since 2017/02/26
	 */
	int nextRecordId()
		throws InvalidRecordIDException;
	
	/**
	 * Returns the number of records.
	 *
	 * @return The record count.
	 * @since 2020/02/16
	 */
	int numRecords();
	
	/**
	 * Returns a copy of the data contained in the previous record. Changes to
	 * the returned array will not modify the data in the record.
	 *
	 * @return The data for the previous record.
	 * @throws InvalidRecordIDException If the record is not valid.
	 * @throws RecordStoreException If another unspecified exception occurs.
	 * @throws RecordStoreNotOpenException This is called when the record store
	 * is no longer open.
	 * @since 2017/02/26
	 */
	byte[] previousRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException;
	
	/**
	 * Returns the identifier of the previous record.
	 *
	 * @return The previous record.
	 * @throws InvalidRecordIDException If there is no next record.
	 * @since 2017/02/26
	 */
	int previousRecordId()
		throws InvalidRecordIDException;
	
	/**
	 * Rebuilds the enumeration to reflect the most up to date state.
	 *
	 * @throws IllegalStateException If this enumeration was destroyed.
	 * @see #isKeptUpdated()
	 * @see #keepUpdated(boolean)
	 * @since 2017/02/26
	 */
	void rebuild()
		throws IllegalStateException;
	
	/**
	 * Repositions the enumeration so that the next element to be returned
	 * is the first element (and there is no previous element if that is
	 * called). The index will be reset back to zero.
	 *
	 * @since 2017/02/26
	 */
	void reset();
}

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

package javax.microedition.rms;

/**
 * This is used to filter through records which may exist within an enumerated
 * record set.
 *
 * @see RecordComparator
 * @see RecordEnumeration
 * @since 2017/02/26
 */
public interface RecordFilter
{
	/**
	 * Checks whether the given record is a match for the criteria of this
	 * filter.
	 *
	 * @param __b The record data to check, the array data must not be
	 * modified.
	 * @return {@code true} if the specified record is a match.
	 * @since 2017/02/26
	 */
	boolean matches(byte[] __b);
}

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

package javax.microedition.rms;

/**
 * This is used to be notified of changes which occur in a record store.
 *
 * @since 2017/02/26
 */
public interface RecordListener
{
	/**
	 * This is called when a record was added to the store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the added record.
	 * @since 2017/02/26
	 */
	void recordAdded(RecordStore __rs, int __id);
	
	/**
	 * This is called when a record was changed in a store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the changed record.
	 * @since 2017/02/26
	 */
	void recordChanged(RecordStore __rs, int __id);
	
	/**
	 * This is called when a record was deleted from a store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the deleted record, an attempt to use the record
	 * after it has been used is illegal will throw an
	 * {@link InvalidRecordIDException}.
	 * @since 2017/02/26
	 */
	void recordDeleted(RecordStore __rs, int __id);
}

Added modules/meep-rms/src/main/java/javax/microedition/rms/RecordStore.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

import cc.squirreljme.runtime.cldc.lang.ImplementationClass;
import cc.squirreljme.runtime.rms.SuiteIdentifier;
import cc.squirreljme.runtime.rms.TemporaryVinylRecord;
import cc.squirreljme.runtime.rms.VinylLock;
import cc.squirreljme.runtime.rms.VinylRecord;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.IdentityLinkedHashSet;

/**
 * This is a record store which may be used by an application to store
 * information about it in an implementation defined manner.
 *
 * Opened record stores have an open count, as such for every open operation
 * there must be a close operation.
 *
 * Whenever the record store is modified, the version number will be
 * incremented.
 *
 * Record stores may optionally permit other suites to access and potentially
 * write their records, otherwise only the current suite may modify its own
 * records.
 *
 * @since 2017/02/26
 */
public class RecordStore
	implements AutoCloseable
{
	/** Specifies that any suite may access the records. */
	public static final int AUTHMODE_ANY =
		1;
	
	/** Specifies that only record store creator may access the records. */
	public static final int AUTHMODE_PRIVATE =
		0;
	
	/** The vinyl record where everything is stored. */
	static final VinylRecord _VINYL;
	
	/** Existing record stores. */
	static final Map<Integer, RecordStore> _STORE_CACHE =
		new LinkedHashMap<>();
	
	/** Identity map for listeners */
	private final Set<RecordListener> _listeners =
		new IdentityLinkedHashSet<>();
	
	/** The volume ID. */
	private final int _vid;
	
	/** The name. */
	private final String _name;
	
	/** Write to this? */
	private final boolean _write;
	
	/** How many times has this been opened? */
	private volatile int _opens;
	
	/**
	 * Initializes the record store manager.
	 *
	 * @since 2017/02/27
	 */
	static
	{
		// See if there is a service, this will fall back to an implementation
		// that is not shared and will only exist as long as the current
		// program is running
		VinylRecord vr;
		try
		{
			String vclass = ImplementationClass.implementationClass(
				VinylRecord.class.getName());
			vr = (vclass == null ? new TemporaryVinylRecord() :
				(VinylRecord)Class.forName(vclass).newInstance());
		}
		
		// If it fails to initialize, just use a blank one
		catch (ClassNotFoundException|IllegalAccessException|
			InstantiationException e)
		{
			vr = new TemporaryVinylRecord();
		}
		
		// Set
		_VINYL = vr;
	}
	
	/**
	 * Initializes the access to the record store.
	 *
	 * @param __vid The volume ID.
	 * @param __name The name.
	 * @param __w Write to this?
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private RecordStore(int __vid, String __name, boolean __w)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this._vid = __vid;
		this._name = __name;
		this._write = __w;
		this._opens = 1;
	}
	
	/**
	 * Adds the specified record to the record store and returns the record
	 * id for the newly added record.
	 *
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return The record ID of the newly created record.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @throws RecordStoreException If some other error occurs.
	 * @throws RecordStoreFullException If there is not enough space to store
	 * the data.
	 * @since 2017/02/26
	 */
	public int addRecord(byte[] __b, int __o, int __l, int __tag)
		throws ArrayIndexOutOfBoundsException, NullPointerException,
			RecordStoreNotOpenException, RecordStoreException,
			RecordStoreFullException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error DC01 Cannot write record to read-only store.}
		if (!this._write)
			throw new RecordStoreException("DC01");
		
		// Used for later
		int rv;
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Add the page
			rv = vinyl.pageAdd(this._vid, __b, __o, __l, __tag);
			RecordStore.__checkError(rv);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordAdded(this, rv);
		return rv;
	}
	
	/**
	 * Calls {@code addRecord(__b, __o, __l, 0)}.
	 *
	 * @param __b As forwarded.
	 * @param __o As forwarded.
	 * @param __l As forwarded.
	 * @return As forwarded.
	 * @throws ArrayIndexOutOfBoundsException As forwarded.
	 * @throws NullPointerException As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @since 2017/02/26
	 */
	public int addRecord(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException,
			RecordStoreNotOpenException, RecordStoreException,
			RecordStoreFullException
	{
		return this.addRecord(__b, __o, __l, 0);
	}
	
	/**
	 * Adds a record listener to the given store to notify of when changes
	 * are made to records.
	 *
	 * If the record store is closed then this has no effect.
	 *
	 * @param __l The listener to call for changes, a listener which has
	 * already been added will not be added a second time.
	 * @since 2017/02/26
	 */
	public void addRecordListener(RecordListener __l)
	{
		// Ignore
		if (__l == null)
			return;
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// No effect if closed
			if (this._opens <= 0)
				return;
			
			// Add listener
			Set<RecordListener> listeners = this._listeners;
			synchronized (listeners)
			{
				listeners.add(__l);
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/26
	 */
	@Override
	public void close()
		throws RecordStoreNotOpenException, RecordStoreException
	{
		this.closeRecordStore();
	}
	
	/**
	 * Closes the record store.
	 *
	 * Note that due to the ability to have record stores opened multiple times
	 * the open count must reach zero before it is actually closed.
	 *
	 * When the store is fully closed all listeners will be removed.
	 *
	 * @throws RecordStoreNotOpenException If the record is not open.
	 * @throws RecordStoreException If there was an issue closing it.
	 * @since 2017/02/26
	 */
	public void closeRecordStore()
		throws RecordStoreNotOpenException, RecordStoreException
	{
		// Lock the record, so that only a single thread is messing with the
		// open counts and such
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// If closed then remove all the listeners
			if ((--this._opens) <= 0)
				this._listeners.clear();
		}
	}
	
	/**
	 * Deletes the specified record.
	 *
	 * @param __id The record to delete.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @throws RecordStoreException If there was an issue deleting the record.
	 * @throws SecurityException If the record cannot be deleted.
	 * @since 2017/02/26
	 */
	public void deleteRecord(int __id)
		throws InvalidRecordIDException, RecordStoreNotOpenException,
			RecordStoreException, SecurityException
	{
		// Used later
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Delete it
			int rv = vinyl.pageDelete(this._vid, __id);
			RecordStore.__checkError(rv);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordDeleted(this, __id);
	}
	
	/**
	 * Enumerates through the records that exist within this store.
	 *
	 * If a comparator is not specified then the traversal order is not
	 * defined.
	 *
	 * @param __f An optional filter used to filter records, may be
	 * {@code null}.
	 * @param __c An optional comparator used to modify the sort order, may
	 * be {@code null}.
	 * @param __ku If {@code true} then the enumeration is kept up to date.
	 * @param __tags The tags to use for basic filtering, if this is empty then
	 * an empty enumeration will be returned, if this is {@code null} then all
	 * tags will be selected.
	 * @return The enumeration over the records.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public RecordEnumeration enumerateRecords(RecordFilter __f,
		RecordComparator __c, boolean __ku, int[] __tags)
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Build one and perform a rebuild to initialize it
		__VolumeEnumeration__ rv = new __VolumeEnumeration__(this, __f,
			__c, __ku, __tags);
		rv.rebuild();
		
		// Use it
		return rv;
	}
	
	/**
	 * Calls {@code enumerateRecords(__f, __c, __ku, null)}.
	 *
	 * @param __f As forwarded.
	 * @param __c As forwarded.
	 * @param __ku As forwarded.
	 * @return As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @since 2017/02/26
	 */
	public RecordEnumeration enumerateRecords(RecordFilter __f,
		RecordComparator __c, boolean __ku)
		throws RecordStoreNotOpenException
	{
		return this.enumerateRecords(__f, __c, __ku, null);
	}
	
	/**
	 * Returns the last modification date of the record store.
	 *
	 * @return The last modification date of the record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public long getLastModified()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			long[] time = new long[1];
			int rv = vinyl.volumeModTime(this._vid, time);
			
			try
			{
				RecordStore.__checkError(rv);
			}
			catch (RecordStoreException e)
			{
				if (e instanceof RecordStoreNotOpenException)
					throw (RecordStoreNotOpenException)e;
				
				// {@squirreljme.error DC02 Could not get the record store
				// time.}
				throw new RuntimeException("DC02", e);
			}
			
			return time[0];
		}
	}
	
	/**
	 * Returns the name of the record store.
	 *
	 * @return The name of the record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public String getName()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		return this._name;
	}
	
	/**
	 * This returns the next record ID which would be used if a new record
	 * were to be added to this record store.
	 *
	 * The returned ID is only valid while the store remains open and before
	 * {@code addRecord()} is called.
	 *
	 * @return The next record ID.
	 * @throws RecordStoreException If there was another issue with the
	 * record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public int getNextRecordID()
		throws RecordStoreException, RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Get next ID as a guess
			int rv = vinyl.pageNextId(this._vid);
			RecordStore.__checkError(rv);
			
			return rv;
		}
	}
	
	/**
	 * Returns the number of records in this store.
	 *
	 * @return The number of records in this store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2019/05/09
	 */
	public int getNumRecords()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Get record list
			int[] pages = vinyl.pageList(this._vid);
			
			// Check for error
			if (pages.length > 0)
				try
				{
					RecordStore.__checkError(pages[0]);
				}
				catch (RecordStoreNotOpenException e)
				{
					throw e;
				}
				catch (RecordStoreException e)
				{
					// {@squirreljme.error DC03 Error getting list of
					// records.}
					RecordStoreNotOpenException t =
						new RecordStoreNotOpenException("DC03");
					t.initCause(e);
					throw t;
				}
			
			// Return array size
			return pages.length;
		}
	}
	
	/**
	 * Returns a copy of the data which is stored in the given record.
	 *
	 * @param __id The ID of the record to get.
	 * @return A copy of the data stored in this record, if there is no data
	 * then this will return {@code null}.
	 * @throws InvalidRecordIDException If the ID is not valid.
	 * @throws RecordStoreException If there is a problem with the record
	 * store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public byte[] getRecord(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// This volume
		int vid = this._vid;
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Need to know the size of the record
			int size = vinyl.pageSize(vid, __id);
			RecordStore.__checkError(size);
			
			// Allocate data to read from it
			byte[] rv = new byte[size];
			
			// Read data
			int read = vinyl.pageRead(vid, __id, rv, 0, size);
			RecordStore.__checkError(read);
			
			return rv;
		}
	}
	
	/**
	 * Fills the specified array with a copy of the data within the given
	 * record.
	 *
	 * @param __id The ID of the record to get.
	 * @param __b The array to write data to.
	 * @param __o The offset into the array.
	 * @return The number of bytes copied into the array.
	 * @throws ArrayIndexOutOfBoundsException If the offset is negative or
	 * the record data exceeds the size of the output array.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public int getRecord(int __id, byte[] __b, int __o)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreNotOpenException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// This volume
		int vid = this._vid;
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Need to know the size of the record
			int size = vinyl.pageSize(vid, __id);
			RecordStore.__checkError(size);
			
			// {@squirreljme.error DC04 The record does not fit into the
			// output.}
			if (size < 0 || (__o + size) > __b.length)
				throw new ArrayIndexOutOfBoundsException("DC04");
			
			// Read data
			int read = vinyl.pageRead(vid, __id, __b, __o, size);
			RecordStore.__checkError(read);
			
			// Size is used as the return value
			return size;
		}
	}
	
	/**
	 * Returns the size of the given record.
	 *
	 * @param __id The record ID to get the size for.
	 * @return The size of the given record.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getRecordSize(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Need to know the size of the record
			int size = vinyl.pageSize(this._vid, __id);
			RecordStore.__checkError(size);
			
			// Return it
			return size;
		}
	}
	
	/**
	 * Returns the record store information.
	 *
	 * @return The record store information.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public RecordStoreInfo getRecordStoreInfo()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Just quickly create
		return new RecordStoreInfo(this._vid);
	}
	
	/**
	 * Returns the size of the record store.
	 *
	 * @return The record store size, not to exceed {@link Integer#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	@Deprecated
	public int getSize()
		throws RecordStoreNotOpenException
	{
		return (int)Math.min(Integer.MAX_VALUE,
			this.getRecordStoreInfo().getSize());
	}
	
	/**
	 * Returns the available size of the record store.
	 *
	 * @return The available record store size, not to exceed
	 * {@link Integer#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	@Deprecated
	public int getSizeAvailable()
		throws RecordStoreNotOpenException
	{
		return (int)Math.min(Integer.MAX_VALUE,
			this.getRecordStoreInfo().getSizeAvailable());
	}
	
	/**
	 * Returns the tag of the given record.
	 *
	 * @param __id The record ID to get the tag for.
	 * @return The tag of the given record.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getTag(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Get and check tag
			int rv = vinyl.pageTag(this._vid, __id);
			RecordStore.__checkError(rv);
			
			return rv;
		}
	}
	
	/**
	 * Returns the version of the record store, this may be used to quickly
	 * determine if a store has been modified.
	 *
	 * @return The version of this record store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getVersion()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			int rv = vinyl.volumeModCount(this._vid);
			
			try
			{
				RecordStore.__checkError(rv);
			}
			catch (RecordStoreException e)
			{
				if (e instanceof RecordStoreNotOpenException)
					throw (RecordStoreNotOpenException)e;
				
				// {@squirreljme.error DC05 Could not get the record store
				// version.}
				throw new RuntimeException("DC05", e);
			}
			
			return rv;
		}
	}
	
	/**
	 * Removes the specified record listener, this has no effect if it has
	 * already been removed or was never added.
	 *
	 * @param __l The record listener to remove.
	 * @since 2017/02/26
	 */
	public void removeRecordListener(RecordListener __l)
	{
		// Ignore
		if (__l == null)
			return;
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// No effect if closed
			if (this._opens <= 0)
				return;
			
			// Remove listener
			Set<RecordListener> listeners = this._listeners;
			synchronized (listeners)
			{
				listeners.remove(__l);
			}
		}
	}
	
	/**
	 * Sets the mode of the record store which permits or denies other suites
	 * access to this record store.
	 *
	 * This may only operate on fully closed record stores and no other
	 * suites must have this record store open when this is called.
	 *
	 * @param __auth The authorization mode to use.
	 * @param __write Whether writing should be permitted.
	 * @throws IllegalArgumentException If the authorization mode is not
	 * valid.
	 * @throws IllegalStateException If the record store is opened by any
	 * application.
	 * @throws RecordStoreException If some other problem occurs with the
	 * record store.
	 * @throws SecurityException If changing the mode is not permitted.
	 * @since 2017/02/26
	 */
	public void setMode(int __auth, boolean __write)
		throws IllegalArgumentException, IllegalStateException,
			RecordStoreException, SecurityException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Sets the data for a record.
	 *
	 * @param __id The record ID to set.
	 * @param __b The input data.
	 * @param __o The offset into the array
	 * @param __l The number of bytes to write.
	 * @param __tag The new tag to set for the record, this replaces the
	 * old tag.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If another unspecified error happens.
	 * @throws RecordStoreFullException If there is not enough space to store
	 * the data.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public void setRecord(int __id, byte[] __b, int __o, int __l, int __tag)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotOpenException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error DC06 Cannot write record to read-only store.}
		if (!this._write)
			throw new RecordStoreException("DC06");
		
		// Used for later
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Set the page
			__id = vinyl.pageSet(this._vid, __id, __b, __o, __l, __tag);
			RecordStore.__checkError(__id);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordChanged(this, __id);
	}
	
	/**
	 * Calls {@code setRecord(__id, __b, __o, __l, getTag(__id))}.
	 *
	 * @param __id As forwarded.
	 * @param __b As forwarded.
	 * @param __o As forwarded.
	 * @param __l As forwarded.
	 * @throws ArrayIndexOutOfBoundsException As forwarded.
	 * @throws InvalidRecordIDException As forwarded.
	 * @throws NullPointerException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @since 2017/02/26
	 */
	public void setRecord(int __id, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotOpenException
	{
		this.setRecord(__id, __b, __o, __l, this.getTag(__id));
	}
	
	/**
	 * Checks that this record store is open.
	 *
	 * @throws RecordStoreNotOpenException If it is not open.
	 * @since 2019/04/15
	 */
	private final void __checkOpen()
		throws RecordStoreNotOpenException
	{
		// {@squirreljme.error DC07 This record store is not open.
		if (this._opens <= 0)
			throw new RecordStoreNotOpenException("DC07");
	}
	
	/**
	 * Lists the pages that exist within this record store.
	 *
	 * @return The page IDs.
	 * @since 2019/05/13
	 */
	final int[] __listPages()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			return vinyl.pageList(this._vid);
		}
	}
	
	/**
	 * Returns all of the listeners for this record store.
	 *
	 * @return The listeners.
	 * @since 2019/04/15
	 */
	private final RecordListener[] __listeners()
	{
		Set<RecordListener> listeners = this._listeners;
		return listeners.<RecordListener>toArray(
			new RecordListener[listeners.size()]);
	}
	
	/**
	 * Deletes the specified record store.
	 *
	 * Suites may only delete their own record store.
	 *
	 * This will not call
	 * {@link RecordListener#recordDeleted(RecordStore, int)}
	 * listeners associated with the given record store.
	 *
	 * @param __n The name of the record store to delete.
	 * @throws RecordStoreException If the record store cannot be deleted due
	 * to being owned by another suite or deletion is not possible.
	 * @throws RecordStoreNotFoundException If the given record store was not
	 * found.
	 * @since 2017/02/26
	 */
	public static void deleteRecordStore(String __n)
		throws NullPointerException, RecordStoreException,
			RecordStoreNotFoundException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Our suite identifier to find our own records
		long mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Try to locate our record
			int got = -1;
			for (int rid : vinyl.volumeList())
			{
				// Another suite's volume
				if (mysid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				// Found the record?
				if (__n.equals(vinyl.volumeName(rid)))
				{
					got = -1;
					break;
				}
			}
			
			// {@squirreljme.error DC08 Cannot delete the specified record
			// store because it does not exist. (The name of the store)}
			if (got == -1)
				throw new RecordStoreNotFoundException("DC08 " + __n);
			
			throw new todo.TODO();
		}
	}
	
	/**
	 * Returns the list of record stores that are available and owned by
	 * this suite.
	 *
	 * @return The list of available record stores, the order is unspecified
	 * and implementation dependent. If there are no records then {@code null}
	 * will be returned.
	 * @since 2017/02/26
	 */
	public static String[] listRecordStores()
	{
		// Our suite identifier to find our own records
		long mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			List<String> rv = new ArrayList<>();
			
			// Go through all IDs and locate record store info
			for (int rid : vinyl.volumeList())
			{
				// Do not add records which belong to another suite
				if (mysid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				rv.add(vinyl.volumeName(rid));
			}
			
			return rv.<String>toArray(new String[rv.size()]);
		}
	}
	
	/**
	 * Attempts to open and optionally create the record store for this midlet
	 * with the specified name.
	 *
	 * If a password is specified then the record store will be encrypted to
	 * prevent tampering.
	 *
	 * If the record store has already been opened then it will return a
	 * previously opened record store.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __create If {@code true} then if the record store does not
	 * exist it will be created.
	 * @param __auth The authorization mode of the record which may permit
	 * other applications to access this record. If the record already exists
	 * then this argument will be ignored.
	 * @param __write If {@code true} then the record store may be written to
	 * by other suites. If the record already exists then this argument will be
	 * ignored.
	 * @param __pass The password.
	 * @return The newly opened or created record store, if the record store
	 * is already open then it will return the already open one.
	 * @throws IllegalArgumentException If the name is not valid or the
	 * authorization mode is not valid.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreFullException If there is no space remaining.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create,
		int __auth, boolean __write, String __pass)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.__openRecordStore(__n,
			SuiteIdentifier.currentVendor(), SuiteIdentifier.currentName(),
			__create, __auth, __write, __pass);
	}
	
	/**
	 * Forwards to {@code openRecordStore(__n, __create, __auth, __write, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __create As forwarded.
	 * @param __auth As forwarded.
	 * @param __write As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create,
		int __auth, boolean __write)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.openRecordStore(__n, __create, __auth, __write, "");
	}
	
	/**
	 * Forwards to {@code openRecordStore(__n, __create, AUTHMODE_PRIVATE,
	 * true, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __create As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.openRecordStore(__n, __create,
			RecordStore.AUTHMODE_PRIVATE,
			true, "");
	}
	
	/**
	 * Attempts to open the record store created by another application.
	 *
	 * The record store must have been created with the {@link #AUTHMODE_ANY}
	 * authorization. If it is encrypted then the same password must be
	 * specified.
	 *
	 * If the vendor and suite is our own then this will be the same as
	 * calling: {@code openRecordStore(__n, false, AUTHMODE_PRIVATE, true,
	 * __pass)}.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __vend The vendor of the other suite.
	 * @param __suite The suite.
	 * @param __pass The password to the record store.
	 * @return The opened record store.
	 * @throws IllegalArgumentException If the name, vendor, or suite names
	 * are not valid.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, String __vend,
		String __suite, String __pass)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		return RecordStore.__openRecordStore(__n, __vend, __suite, false,
			RecordStore.AUTHMODE_ANY, false, __pass);
	}
	
	/**
	 * Calls {@code openRecordStore(__n, __vend, __suite, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __vend As forwarded.
	 * @param __suite As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, String __vend,
		String __suite)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		return RecordStore.openRecordStore(__n, __vend, __suite, "");
	}
	
	/**
	 * Checks for an error and throws an exception potentially.
	 *
	 * @param __id The ID to check, negative indicates error.
	 * @throws RecordStoreException If there is an error.
	 * @since 2019/05/01
	 */
	private static final void __checkError(int __id)
		throws RecordStoreException
	{
		// Error was detected
		if (__id < 0)
		{
			// {@squirreljme.error DC09 Could not add the record, there might
			// not be enough free space available.}
			if (__id == VinylRecord.ERROR_NO_MEMORY)
				throw new RecordStoreFullException("DC09");
			
			// {@squirreljme.error DC0a No such record store exists.}
			if (__id == VinylRecord.ERROR_NO_VOLUME)
				throw new RecordStoreNotFoundException("DC0a");
			
			// {@squirreljme.error DC0b No such record exists.}
			if (__id == VinylRecord.ERROR_NO_PAGE)
				throw new InvalidRecordIDException("DC0b");
			
			// {@squirreljme.error DC0c Unknown record store error. (Error)}
			throw new RecordStoreException("DC0c " + __id);
		}
	}
	
	/**
	 * Attempts to open and optionally create the record store for the
	 * specified MIDlet.
	 *
	 * If a password is specified then the record store will be encrypted to
	 * prevent tampering.
	 *
	 * If the record store has already been opened then it will return a
	 * previously opened record store.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __create If {@code true} then if the record store does not
	 * exist it will be created.
	 * @param __auth The authorization mode of the record which may permit
	 * other applications to access this record. If the record already exists
	 * then this argument will be ignored.
	 * @param __write If {@code true} then the record store may be written to
	 * by other suites. If the record already exists then this argument will be
	 * ignored.
	 * @return The newly opened or created record store, if the record store
	 * is already open then it will return the already open one.
	 * @throws IllegalArgumentException If the name is not valid or the
	 * authorization mode is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreFullException If there is no space remaining.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2018/12/15
	 */
	private static RecordStore __openRecordStore(String __name, String __vend,
		String __suite, boolean __create, int __auth, boolean __write,
		String __pass)
		throws IllegalArgumentException, NullPointerException,
			RecordStoreException, RecordStoreFullException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		if (__name == null || __vend == null || __suite == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DC0d The name is not valid.}
		int namelen = __name.length();
		if (namelen < 1 || namelen > 32)
			throw new IllegalArgumentException("DC0d " + __name);
		
		// Get identifier, used to find the record
		long sid = SuiteIdentifier.identifier(__vend, __suite),
			mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Go through all records and try to find a pre-existing one
			int rv = -1;
			for (int rid : vinyl.volumeList())
			{
				// Belongs to another suite?
				if (sid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				// Same name?
				if (__name.equals(vinyl.volumeName(rid)))
				{
					rv = rid;
					break;
				}
			}
			
			// Open a record which already exists
			if (rv >= 0)
			{
				// Use a pre-cached store
				Map<Integer, RecordStore> cache = RecordStore._STORE_CACHE;
				RecordStore rs = cache.get(rv);
				if (rs == null)
					cache.put(rv, (rs = new RecordStore(rv, __name,
						sid == mysid || vinyl.volumeOtherWritable(rv))));
				
				// Increment the open count
				rs._opens++;
				return rs;
			}
			
			// {@squirreljme.error DC0e Could not find the specified record
			// store. (The name; The vendor; The suite)}
			if (!__create)
				throw new RecordStoreNotFoundException(
					String.format("DC0e %s %s %s", __name, __vend, __suite));
			
			// {@squirreljme.error DC0f Could not create the record, it is
			// likely that there is not enough space remaining.}
			rv = vinyl.volumeCreate(sid, __name, __write);
			if (rv < 0)
				throw new RecordStoreFullException("DC0f");
			
			// Since we created it, we can just return the info
			return new RecordStore(rv, __name, sid == mysid || __write);
		}
	}
}

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

package javax.microedition.rms;

/**
 * General exception for record stores.
 *
 * @since 2017/02/26
 */
public class RecordStoreException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.rms;

/**
 * This is thrown when the operation could not be completed because the record
 * store is full.
 *
 * @since 2017/02/26
 */
public class RecordStoreFullException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreFullException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreFullException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.rms;

import cc.squirreljme.runtime.rms.VinylLock;
import cc.squirreljme.runtime.rms.VinylRecord;

/**
 * This stores information on a record store.
 *
 * @since 2017/02/26
 */
public final class RecordStoreInfo
{
	/** The volume ID. */
	private final int _vid;
	
	/**
	 * Used internally.
	 *
	 * @param __vid The volume ID.
	 * @since 2017/02/26
	 */
	RecordStoreInfo(int __vid)
	{
		this._vid = __vid;
	}
	
	/**
	 * Gets the authorization mode of the associated {@link RecordStore}.
	 *
	 * @return The authorization mode, one of
	 * {@link RecordStore#AUTHMODE_PRIVATE} or
	 * {@link RecordStore#AUTHMODE_ANY}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public int getAuthMode()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the size of the record store including any overhead it may
	 * have.
	 *
	 * @return The number of bytes the record store consumes, not to exceed
	 * {@link Long#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public long getSize()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of bytes which may be available for storage. This
	 * is only an estimate and the actual number may be higher or lower
	 * depending on overhead and storage requirements.
	 *
	 * @return The estimated number of bytes available for storage, not to
	 * exceed {@link Long#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public long getSizeAvailable()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			return vinyl.vinylSizeAvailable();
		}
	}
	
	/**
	 * Returns {@code true} if the record store is encrypted.
	 *
	 * @return {@code true} if the record store is encrypted.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public boolean isEncrypted()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if the record store can be written to by other
	 * suites. A value of {@code false} still specifies that the record may
	 * be written to by the current application.
	 *
	 * @return {@code true} if the record store can be written to by other
	 * suites.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public boolean isWriteable()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.rms;

/**
 * This is thrown when the record store is missing.
 *
 * @since 2017/02/26
 */
public class RecordStoreNotFoundException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreNotFoundException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.rms;

/**
 * This is thrown when an operation was attempted on a closed record store.
 *
 * @since 2017/02/26
 */
public class RecordStoreNotOpenException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreNotOpenException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreNotOpenException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.rms;

/**
 * This is called when there was an issue with storing or loading of an
 * encrypted data store.
 *
 * @since 2017/02/26
 */
public class SecureRecordStoreException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public SecureRecordStoreException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public SecureRecordStoreException(String __m)
	{
		super(__m);
	}
}

Added modules/meep-rms/src/main/java/javax/microedition/rms/__VolumeEnumeration__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 javax.microedition.rms;

import java.util.ArrayList;
import java.util.List;

/**
 * This is the internal enumeration over records.
 *
 * @since 2019/05/13
 */
final class __VolumeEnumeration__
	implements RecordEnumeration
{
	/** The used record store. */
	protected final RecordStore store;
	
	/** The filter. */
	protected final RecordFilter filter;
	
	/** The comparator. */
	protected final RecordComparator comparator;
	
	/** Keep this updated? */
	private boolean _keepupdated;
	
	/** Tags to match. */
	private int[] _tags;
	
	/** Is this destroyed? */
	private boolean _destroyed;
	
	/** Last modification count. */
	private int _lastmod =
		-1;
	
	/** Built page list. */
	private List<__Page__> _pages;
	
	/**
	 * Initializes the record store enumeration.
	 *
	 * @param __store The store to use.
	 * @param __f An optional filter used to filter records, may be
	 * {@code null}.
	 * @param __c An optional comparator used to modify the sort order, may
	 * be {@code null}.
	 * @param __ku If {@code true} then the enumeration is kept up to date.
	 * @param __tags The tags to use for basic filtering, if this is empty then
	 * an empty enumeration will be returned, if this is {@code null} then all
	 * tags will be selected.
	 * @return The enumeration over the records.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @throws NullPointerException If no backing store was used.
	 * @since 2019/05/13
	 */
	__VolumeEnumeration__(RecordStore __store, RecordFilter __f,
		RecordComparator __c, boolean __ku, int[] __tags)
		throws NullPointerException
	{
		if (__store == null)
			throw new NullPointerException("NARG");
		
		this.store = __store;
		this.filter = __f;
		this.comparator = __c;
		this._keepupdated = __ku;
		this._tags = (__tags == null ? null : __tags.clone());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void destroy()
	{
		if (this._destroyed)
			return;
		
		this._destroyed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int getRecordId(int __i)
		throws IllegalArgumentException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean hasNextElement()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean hasPreviousElement()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean isKeptUpdated()
	{
		return this._keepupdated;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void keepUpdated(boolean __u)
	{
		// Check for destruction
		this.__checkDestroy();
		
		this._keepupdated = __u;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final byte[] nextRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int nextRecordId()
		throws InvalidRecordIDException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/16
	 */
	@Override
	public final int numRecords()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final byte[] previousRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int previousRecordId()
		throws InvalidRecordIDException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void rebuild()
		throws IllegalStateException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Used in the rebuild
		RecordStore store = this.store;
		RecordFilter filter = this.filter;
		RecordComparator comparator = this.comparator;
		int[] tags = this._tags;
		
		// Could fail
		try
		{
			// Record store has not been modified, ignore
			int nowmod = store.getVersion();
			if (this._pages != null && nowmod == this._lastmod)
				return;
			
			// Get all the page IDs
			int[] pageids = store.__listPages();
			
			// Build an initial page table
			List<__Page__> pages = new ArrayList<>(pageids.length);
			for (int pid : pageids)
			{
				// Quick filter by tag?
				if (tags != null)
				{
					// Get page tag
					int ptag = store.getTag(pid);
					
					// Only accept tags in this array
					boolean got = false;
					for (int mt : tags)
						if (ptag == mt)
						{
							got = true;
							break;
						}
					
					// Completely missed?
					if (!got)
						continue;
				}
				
				// Filter this?
				if (filter != null)
					throw new todo.TODO();
			}
			
			// Sort the input pages by their data?
			if (comparator != null)
				throw new todo.TODO();
			
			// Set new version
			this._pages = pages;
			this._lastmod = nowmod;
		}
		
		// {@squirreljme.error DC0g Could not rebuild the enumeration.}
		catch (RecordStoreException e)
		{
			throw new RuntimeException("DC0g", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void reset()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * Checks if this has been destroyed.
	 *
	 * @throws IllegalStateException If this was destroyed.
	 * @since 2019/05/13
	 */
	private final void __checkDestroy()
		throws IllegalStateException
	{
		// {@squirreljme.error DC0h Record store enumeration has been
		// destoryed.}
		if (this._destroyed)
			throw new IllegalStateException("DC0h");
	}
	
	/**
	 * Check if a rebuild needs to be done.
	 *
	 * @throws IllegalStateException If the update check could not be made.
	 * @since 2019/05/13
	 */
	private final void __checkRebuild()
		throws IllegalStateException
	{
		// Could fail
		try
		{
			if (this._pages == null || (this._keepupdated &&
				this.store.getVersion() != this._lastmod))
				this.rebuild();
		}
		catch (RecordStoreException e)
		{
			// {@squirreljme.error DC0i Could not check for updates.}
			throw new IllegalStateException("DC0i", e);
		}
	}
	
	/**
	 * Represents a raw page ID.
	 *
	 * @since 2019/05/13
	 */
	private static final class __Page__
	{
		/** The ID. */
		public final int id;
		
		/**
		 * Initializes the page reference.
		 *
		 * @param __id The page ID.
		 * @since 2019/05/13
		 */
		public __Page__(int __id)
		{
			this.id = __id;
		}
	}
}

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

/**
 * This is the record management system which is used to store and obtain
 * records.
 *
 * Record stores must be able to be read and modified by multiple applications
 * concurrently while maintaining atomic access. Applications are permitted
 * to access records managed by other applications.
 *
 * This package is optional.
 *
 * @since 2017/02/26
 */

package javax.microedition.rms;

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

import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

/**
 * Tests that nothing is done on the record.
 *
 * @since 2018/12/13
 */
public class TestNothing
	extends __RecordTest__<Object>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/13
	 */
	@Override
	public Object test(RecordStore __rs)
		throws RecordStoreException
	{
		try (RecordStore rs = RecordStore.openRecordStore("rmstest",
			true))
		{
		}
		
		return null;
	}
}

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

import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Base class to wrap record store access, since it needs to be created and
 * deleted.
 *
 * @param <T> The return type.
 * @since 2018/12/13
 */
abstract class __RecordTest__<T>
	extends TestSupplier<T>
{
	/**
	 * Runs an RMS test on the given record store.
	 *
	 * @param __rs The input record store.
	 * @return The result of the test.
	 * @throws NullPointerException On null arguments.
	 * @throws Throwable On any exception.
	 * @since 2018/12/13
	 */
	public abstract T test(RecordStore __rs)
		throws NullPointerException, Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/13
	 */
	@Override
	public final T test()
		throws Throwable
	{
		// Try to delete a previously created record store
		try
		{
			RecordStore.deleteRecordStore("rms-test");
		}
		
		// Ignore this because it is expected
		catch (RecordStoreNotFoundException e)
		{
		}
		
		// Open the database y creating a new one
		try (RecordStore rs = RecordStore.openRecordStore("rms-test", true))
		{
			// Run test on it
			return this.test(rs);
		}
	}
}

Added modules/meep-rms/src/test/resources/TestNothing.in.



1
2
+
+
result: null
thrown: NoExceptionThrown

Added modules/meep-securityframework/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This is used to control and potentially grant " +
	"or deny access to specific features that applicationsmay use."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DO"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Security Framework"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.securityframework;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")
}

Added modules/meep-swm/build.gradle.




























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains the application management " +
	"system, this allows programs (provided they have the correct " +
	"permissions) to launch other programs and install new applications " +
	"which may have been sourced from other locations."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "DG"
	swmType = JavaMEMidletType.API
	swmName = "MEEP Application Management System"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.swm;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:collections")
	implementation project(":modules:meep-midlet")
	implementation project(":modules:strings")
	implementation project(":modules:tool-manifest-reader")
}

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

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the name of an API.
 *
 * @since 2017/11/30
 */
public final class APIName
	implements Comparable<APIName>
{
	/** The name of the API. */
	protected final String string;
	
	/**
	 * Initializes the API name from the given string.
	 *
	 * @param __n The name of the API.
	 * @throws InvalidSuiteException If the suite is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public APIName(String __n)
		throws InvalidSuiteException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Force all APIs to be uppercase
		__n = StringUtils.toUpperCaseNoLocale(__n);
		
		// {@squirreljme.error DG01 An illegal character was
		// specified in the API name. (The API name)}
		if (StringUtils.firstIndex("\0\r\n:;", __n) >= 0)
			throw new InvalidSuiteException(String.format("DG01 %s", __n));
		
		// {@squirreljme.error DG02 API name cannot be blank.}
		if (__n.length() <= 0)
			throw new InvalidSuiteException("DG02");
		
		this.string = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(APIName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof APIName))
			return false;
		
		return this.string.equals(((APIName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/ByteArrayJarStreamSupplier.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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * This class provides a stream of a JAR file through a byte array.
 *
 * @since 2017/12/28
 */
public final class ByteArrayJarStreamSupplier
	implements JarStreamSupplier
{
	/** The offset. */
	protected final int offset;
	
	/** The length. */
	protected final int length;
	
	/** The byte array. */
	private final byte[] _data;
	
	/**
	 * Initializes the stream supplier for a simple byte array.
	 *
	 * @param __b The byte array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public ByteArrayJarStreamSupplier(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this._data = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public InputStream get()
	{
		return new ByteArrayInputStream(this._data, this.offset, this.length);
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/Configuration.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
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
191
192
193
194
195
196
197
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a configuration such as CLDC which specifies which base
 * classes are available. Configurations may optionally be "compact" in which
 * they are a lighter version.
 *
 * @since 2016/12/14
 */
public final class Configuration
	implements Comparable<Configuration>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** Is this configuration compact? */
	protected final boolean compact;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the configuration using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite.
	 * @param __c If {@code true} then the configuration is compact.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Configuration(APIName __n, SuiteVersion __v, boolean __c)
		throws NullPointerException
	{
		if (__n == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __n;
		this.version = __v;
		this.compact = __c;
	}
	
	/**
	 * Initializes the configuration by parsing the given string.
	 *
	 * @param __n The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Configuration(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG02 Expected two or three fields for the
		// configuration. (The input string)}
		String[] fields = StringUtils.fieldSplit('-', __n);
		int fn = fields.length;
		if (fn != 2 && fn != 3)
			throw new InvalidSuiteException(String.format("AR02 %s", __n));
		
		// Potentially compact?
		this.compact = (fn > 2 &&
			0 == fields[2].compareToIgnoreCase("compact"));
		
		// Parse name and version
		this.name = new APIName(fields[0]);
		this.version = new SuiteVersion(fields[1]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(Configuration __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		rv = this.version.compareTo(__o.version);
		if (rv != 0)
			return rv;
		
		// Compact is before non-compact
		boolean a = this.compact,
			b = __o.compact;
		if (a != b)
			return (a ? -1 : 1);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Configuration))
			return false;
		
		Configuration o = (Configuration)__o;
		return this.name.equals(o.name) &&
			this.version.equals(o.version) &&
			this.compact == o.compact;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version) ^
			(this.compact ? 0xFFFFFFFF : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Configuration " +
				this.name + ":" + this.version +
				(this.compact ? "-compact" : "")));
		
		return rv;
	}
	
	/**
	 * Returns the version of this configuration.
	 *
	 * @return The configuration version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/DependencyInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.collections.EmptySet;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This contains the information which specifies all of the dependencies which
 * and application depends on.
 *
 * @since 2017/11/30
 */
public final class DependencyInfo
{
	/** The dependencies. */
	protected final Set<MarkedDependency> depends;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dependency information.
	 *
	 * @param __deps The dependencies to depend on.
	 * @since 2017/12/31
	 */
	public DependencyInfo(MarkedDependency... __deps)
	{
		this((__deps == null ? EmptySet.<MarkedDependency>empty() :
			Arrays.<MarkedDependency>asList(__deps)));
	}
	
	/**
	 * Initialzies the dependency information.
	 *
	 * @param __deps The dependencies to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public DependencyInfo(Collection<MarkedDependency> __deps)
		throws NullPointerException
	{
		if (__deps == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedDependency> depends = new LinkedHashSet<>();
		for (MarkedDependency d : __deps)
			if (d == null)
				throw new NullPointerException("NARG");
			else
				depends.add(d);
		this.depends = UnmodifiableSet.<MarkedDependency>of(depends);
	}
	
	/**
	 * Returns the dependency set.
	 *
	 * @return The dependency set.
	 * @since 2017/12/31
	 */
	public Set<MarkedDependency> dependencies()
	{
		return this.depends;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof DependencyInfo))
			return false;
		
		return this.depends.equals(((DependencyInfo)__o).depends);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.depends.hashCode();
	}
	
	/**
	 * Checks if the dependency information is empty.
	 *
	 * @return If the dependency info is empty.
	 * @since 2017/11/30
	 */
	public final boolean isEmpty()
	{
		return this.depends.isEmpty();
	}
	
	/**
	 * Matches this dependency information to see if any of the provided
	 * fields would statisfy the dependencies that are needed.
	 *
	 * @param __prov The provided information.
	 * @return The result of the match.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public final MatchResult match(ProvidedInfo __prov)
		throws NullPointerException
	{
		if (__prov == null)
			throw new NullPointerException("NARG");
		
		// Remove matching dependencies from the input while keeping the
		// matching ones
		Set<MarkedDependency> depends = new LinkedHashSet<>(this.depends),
			matched = new LinkedHashSet<>();
		for (MarkedProvided p : __prov.provided())
		{
			for (Iterator<MarkedDependency> it = depends.iterator();
				it.hasNext();)
			{
				MarkedDependency d = it.next();
				
				if (d.matchesProvided(p))
				{
					matched.add(d);
					it.remove();
				}
			}
		}
		
		return new MatchResult(new DependencyInfo(matched),
			new DependencyInfo(depends));
	}
	
	/**
	 * Returns dependency information which contains no optional
	 * dependencies.
	 *
	 * @return Dependency information with no optionals.
	 * @since 2017/11/30
	 */
	public final DependencyInfo noOptionals()
	{
		// Ignore if there are no dependencies
		Set<MarkedDependency> depends = this.depends;
		if (depends.isEmpty())
			return this;
		
		// Include only required dependencies
		Set<MarkedDependency> instead = new LinkedHashSet<>();
		for (MarkedDependency md : depends)
			if (!md.isOptional())
				instead.add(md);
		
		// There were no optional dependencies
		if (depends.size() == instead.size())
			return this;
		return new DependencyInfo(instead);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Dependencies:" +
				this.depends));
		
		return rv;
	}
	
	/**
	 * Parses the given suite information and returns the dependency
	 * information.
	 *
	 * @param __info The suite information to parse.
	 * @return The parsed dependency information.
	 * @throws InvalidSuiteException If the dependencies is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/20
	 */
	public static final DependencyInfo of(SuiteInfo __info)
		throws InvalidSuiteException, NullPointerException
	{
		if (__info == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedDependency> depends = new LinkedHashSet<>();
		JavaManifestAttributes attr = __info.manifest().getMainAttributes();
		String value;
		
		// The CLDC library to use
		value = attr.getValue("microedition-configuration");
		if (value != null)
		{
			value = value.trim();
			
			// Old software may rely on using 1.0 values when that is illegal
			if (value.equals("1.0"))
				depends.add(new Configuration("CLDC-1.0"));
			
			// Decode otherwise
			else
				depends.add(new Configuration(value.trim()));
		}
		
		// Profiles needed to run
		value = attr.getValue("microedition-profile");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
			{
				// Old software may rely on using the version directly
				if (s.equals("2.0"))
					depends.add(new Profile("MIDP-2.0"));
				
				// Decode otherwise
				else
					depends.add(new Profile(s));
			}
		
		// Parse entries in sequential order
		SuiteType type = __info.type();
		for (int i = 1; i >= 1; i++)
		{
			// Stop if no more values are read
			value = attr.getValue(type.dependencyKey(i));
			if (value == null)
				break;
			
			// Decode dependency
			depends.add(new SuiteDependency(value));
		}
		
		// Build
		return new DependencyInfo(depends);
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents an entry point of a JAR.
 *
 * @since 2017/08/20
 */
public final class EntryPoint
	implements Comparable<EntryPoint>
{
	/** The name of the entry point. */
	protected final String name;
	
	/** The entry point class. */
	protected final String entry;
	
	/** Is this a midlet? */
	protected final boolean ismidlet;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the entry point.
	 *
	 * @param __name The name of the entry point.
	 * @param __entry The class used for entry.
	 * @param __mid Is this a midlet launch?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	public EntryPoint(String __name, String __entry, boolean __mid)
		throws NullPointerException
	{
		// Check
		if (__name == null || __entry == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.entry = __entry;
		this.ismidlet = __mid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int compareTo(EntryPoint __o)
	{
		// Do non-midlets first
		boolean ma = this.ismidlet,
			mb = __o.ismidlet;
		if (ma != mb)
			if (!ma)
				return -1;
			else
				return 1;
		
		// Then the rest
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.entry.compareTo(__o.entry);
	}
	
	/**
	 * Returns the entry point class of the entry point.
	 *
	 * @return The entry point class.
	 * @since 2017/08/20
	 */
	public String entryPoint()
	{
		return this.entry;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof EntryPoint))
			return false;
		
		EntryPoint o = (EntryPoint)__o;
		return this.name.equals(o.name) &&
			this.entry.equals(o.entry) &&
			this.ismidlet == o.ismidlet;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.entry.hashCode() ^
			(this.ismidlet ? 1 : 0);
	}
	
	/**
	 * Is this a MIDlet?
	 *
	 * @return If this is a MIDlet or not.
	 * @since 2017/08/20
	 */
	public boolean isMidlet()
	{
		return this.ismidlet;
	}
	
	/**
	 * Returns the name of the entry point.
	 *
	 * @return The entry point name.
	 * @since 2017/08/20
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s (%s: %s)", this.name, (this.ismidlet ? "MIDlet" :
				"Classic"), this.entry)));
		
		return rv;
	}
}

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

package cc.squirreljme.runtime.swm;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This parses the entry points which are available for usage.
 *
 * @since 2017/08/20
 */
public class EntryPoints
	extends AbstractList<EntryPoint>
{
	/** Available entry points. */
	private final EntryPoint[] _entrypoints;
	
	/**
	 * Initializes the entry points the hosted launcher can find.
	 *
	 * @param __man The manifest to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public EntryPoints(JavaManifest __man)
		throws NullPointerException
	{
		this(__man.getMainAttributes());
	}
	
	/**
	 * Initializes the entry points the hosted launcher can find.
	 *
	 * @param __attr The attributes to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	public EntryPoints(JavaManifestAttributes __attr)
		throws NullPointerException
	{
		// Check
		if (__attr == null)
			throw new NullPointerException("NARG");
		
		// Target list
		List<EntryPoint> target = new ArrayList<>();
		
		// Parse main class first
		String oldclass = __attr.get(new JavaManifestKey("Main-Class"));
		if (oldclass != null)
			target.add(new EntryPoint("Command Line", oldclass, false));
		
		// Parse MIDlet identifiers next
		for (int i = 1; i >= 1; i++)
		{
			// These are always in sequence
			String midletval = __attr.get(new JavaManifestKey(
				String.format("MIDlet-%d", i)));
			if (midletval == null)
				break;
			
			// The MIDlet field is in 3 fields: name, icon, class
			// {@squirreljme.error DG03 Expected two commas in the MIDlet
			// field.}
			int pc = midletval.indexOf(','),
				sc = midletval.indexOf(',', Math.max(pc + 1, 0));
			if (pc < 0 || sc < 0)
				throw new RuntimeException("DG03");
		
			// Split fields
			target.add(new EntryPoint(midletval.substring(0, pc).trim(),
				midletval.substring(sc + 1).trim(), true));
		}
		
		// Finalize
		EntryPoint[] entrypoints = target.<EntryPoint>toArray(
			new EntryPoint[target.size()]);
		this._entrypoints = entrypoints;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public EntryPoint get(int __i)
	{
		return this._entrypoints[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int size()
	{
		return this._entrypoints.length;
	}
}

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

package cc.squirreljme.runtime.swm;

import java.io.OutputStream;
import java.util.Map;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * This interface is used for providing the ability to launch tasks.
 *
 * @since 2019/02/02
 */
public interface ExtendedTaskManager
{
	/**
	 * Attempts to create a task which runs the given suite.
	 *
	 * The task is created and is initially in the {@link TaskStatus#STARTING}
	 * state. If starting fails then it enters the
	 * {@link TaskStatus#START_FAILED} state.
	 *
	 * A suite may only be active once and cannot have multiple copies running
	 * at the same time. In the event that an application is already running it
	 * must be sent an event specifying an application re-launch.
	 *
	 * This is an extended method which allows more advanced control over the
	 * task such as including arguments, system properties, and potential
	 * output redirection.
	 *
	 * @param __s The suite to start, must be an application.
	 * @param __cn The class which extends
	 * {@link javax.microedition.midlet.MIDlet} and acts as the main entry
	 * point for the program.
	 * @param __sprops System properties to pass to the started task.
	 * @param __args Arguments to pass to the called program.
	 * @param __stdout Alternative {@link System#out}.
	 * @param __stderr Alternative {@link System#err}.
	 * @return The task which was created.
	 * @throws IllegalArgumentException If the suite is a library, the given
	 * class does not exist, or the given class does not extend
	 * {@link javax.microedition.midlet.MIDlet}.
	 * @throws IllegalStateException If the suite has been removed.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/02
	 */
	Task startTask(Suite __s, String __cn, Map<String, String> __sprops,
		String[] __args, OutputStream __stdout, OutputStream __stderr)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException;
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/InternalName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents an internal project name which is used by SquirrelJME.
 *
 * @since 2017/12/31
 */
public final class InternalName
	implements MarkedProvided
{
	/** The project name. */
	protected final String name;
	
	/**
	 * Initializes the internal name.
	 *
	 * @param __n The name to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public InternalName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof InternalName))
			return false;
		
		return this.name.equals(((InternalName)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Returns the internal name.
	 *
	 * @return The internal name.
	 * @since 2017/12/31
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/InvalidSuiteException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This is thrown when a midlet has an invalid property or is otherwise not
 * valid.
 *
 * @since 2017/11/23
 */
public class InvalidSuiteException
	extends IllegalArgumentException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/23
	 */
	public InvalidSuiteException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(Throwable __c)
	{
		super(__c);
	}
}

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

package cc.squirreljme.runtime.swm;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is used to obtain an input stream which contains JAR file data which
 * would then be passed through the JIT for recompilation.
 *
 * @since 2017/12/28
 */
public interface JarStreamSupplier
{
	/**
	 * Returns an input stream over the JAR data.
	 *
	 * @return The input stream over the JAR data.
	 * @throws IOException If it could not be obtained.
	 * @since 2017/12/28
	 */
	InputStream get()
		throws IOException;
}

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

package cc.squirreljme.runtime.swm;

/**
 * This interface is used for anything which represents a dependency and as
 * such can be used to check if a provided meets the conditions for a match.
 *
 * @since 2017/12/31
 */
public interface MarkedDependency
{
	/**
	 * Is this dependency optional?
	 *
	 * @return {@code true} if this dependency is optional.
	 * @since 2017/12/31
	 */
	boolean isOptional();
	
	/**
	 * Checks if this dependency matches the specified provision in that the
	 * provided entry is acceptable to be used for this dependency.
	 *
	 * @param __mp The provided to check.
	 * @return {@code true} if the provided is valid for this dependency.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException;
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/MarkedProvided.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This interface is associated with anything which can be a provided detail
 * for a dependency.
 *
 * @since 2017/12/31
 */
public interface MarkedProvided
{
}

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

package cc.squirreljme.runtime.swm;

/**
 * This class contains the results of a dependency match.
 *
 * @since 2017/11/30
 */
public final class MatchResult
{
	/** The matched results. */
	protected final DependencyInfo matched;
	
	/** The unmatched results. */
	protected final DependencyInfo unmatched;
	
	/**
	 * Initializes the match result.
	 *
	 * @param __matched The matched dependencies.
	 * @param __unmatched The unmatched dependencies.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public MatchResult(DependencyInfo __matched, DependencyInfo __unmatched)
		throws NullPointerException
	{
		if (__matched == null || __unmatched == null)
			throw new NullPointerException("NARG");
		
		this.matched = __matched;
		this.unmatched = __unmatched;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MatchResult))
			return false;
		
		MatchResult o = (MatchResult)__o;
		return this.matched.equals(o.matched) &&
			this.unmatched.equals(o.unmatched);
	}
	
	/**
	 * Returns {@code true} if there have been matches in the result.
	 *
	 * @return Has there been any matches?
	 * @since 2017/11/30
	 */
	public final boolean hasMatches()
	{
		return !this.matched.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.matched.hashCode() ^
			this.unmatched.hashCode();
	}
	
	/**
	 * Returns the dependency information which contains every dependency
	 * which has been matched.
	 *
	 * @return The dependency information containing only matched items.
	 * @since 2017/11/30
	 */
	public final DependencyInfo matched()
	{
		return this.matched;
	}
	
	/**
	 * Returns the dependency information which contains every dependency
	 * which has yet to be matched.
	 *
	 * @return The dependency information containing only unmatched items.
	 * @since 2017/11/30
	 */
	public final DependencyInfo unmatched()
	{
		return this.unmatched;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a profile that may be implemented, such as MIDP.
 *
 * @since 2016/12/14
 */
public final class Profile
	implements Comparable<Profile>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the profile using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite, this is optional.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/11/30
	 */
	public Profile(APIName __n, SuiteVersion __v)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.version = __v;
	}
	
	/**
	 * Initializes the profile by parsing the given string.
	 *
	 * @param __n The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Profile(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// No version specified
		int n = __n.length(),
			dx = __n.lastIndexOf('-');
		char c;
		if (dx < 0 || dx + 1 >= n || (c = __n.charAt(dx + 1)) < '0' || c > '9')
		{
			this.name = new APIName(__n);
			this.version = null;
		}
		
		// There is a version
		else
		{
			this.name = new APIName(__n.substring(0, dx));
			this.version = new SuiteVersion(__n.substring(dx + 1));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(Profile __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVersion a = this.version,
			b = __o.version;
		if ((a == null) != (b == null))
			return (a == null ? -1 : 1);
		else if (a != null)
			return a.compareTo(b);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Profile))
			return false;
		
		Profile o = (Profile)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Profile " +
				this.name + ":" + this.version));
		
		return rv;
	}
	
	/**
	 * Returns the version of this profile.
	 *
	 * @return The profile version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.collections.EmptySet;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This contains all of the information for dependencies which are provided
 * by an application or library.
 *
 * @since 2017/11/30
 */
public final class ProvidedInfo
{
	/** Provided fields. */
	protected final Set<MarkedProvided> provided;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the provided dependency info.
	 *
	 * @param __provs The provided set.
	 * @since 2017/12/31
	 */
	public ProvidedInfo(MarkedProvided... __provs)
	{
		this((__provs == null ? EmptySet.<MarkedProvided>empty() :
			Arrays.<MarkedProvided>asList(__provs)));
	}
	
	/**
	 * Initializes the provided dependency info.
	 *
	 * @param __provs The provided set.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public ProvidedInfo(Collection<MarkedProvided> __provs)
		throws NullPointerException
	{
		if (__provs == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedProvided> provided = new LinkedHashSet<>();
		for (MarkedProvided p : __provs)
			if (p == null)
				throw new NullPointerException("NARG");
			else
				provided.add(p);
		this.provided = UnmodifiableSet.<MarkedProvided>of(provided);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ProvidedInfo))
			return false;
		
		return this.provided.equals(((ProvidedInfo)__o).provided);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.provided.hashCode();
	}
	
	/**
	 * Returns the provided.
	 *
	 * @return The provided.
	 * @since 2017/12/31
	 */
	public final Set<MarkedProvided> provided()
	{
		return this.provided;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.provided.toString()));
		
		return rv;
	}
	
	/**
	 * Parses the given suite information and returns all of the provided
	 * resolutions for dependencies which are specified in the manifest.
	 *
	 * @param __info The suite information to parse.
	 * @return The parsed provided resolution information.
	 * @throws InvalidSuiteException If the manifest is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/20
	 */
	public static final ProvidedInfo of(SuiteInfo __info)
		throws InvalidSuiteException, NullPointerException
	{
		if (__info == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedProvided> provided = new LinkedHashSet<>();
		JavaManifestAttributes attr = __info.manifest().getMainAttributes();
		String value;
		
		// Defined configurations
		value = attr.getValue("X-SquirrelJME-DefinedConfigurations");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
				provided.add(new Configuration(s));
		
		// Defined profiles
		value = attr.getValue("X-SquirrelJME-DefinedProfiles");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
				provided.add(new Profile(s));
		
		// Defined standards
		value = attr.getValue("X-SquirrelJME-DefinedStandards");
		if (value != null)
			for (String s : StringUtils.basicSplit(",", value))
				provided.add(new Standard(s.trim()));
		
		// Has internal project name?
		String internalname = attr.getValue(
			"X-SquirrelJME-InternalProjectName");
		if (internalname != null)
			provided.add(new InternalName(internalname));
		
		// This provides a library or otherwise
		provided.add(new TypedSuite(__info.type(), __info.suite()));
		
		// Initialize
		return new ProvidedInfo(provided);
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/Standard.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a standard which is provided by an API.
 *
 * @since 2017/12/05
 */
public final class Standard
	implements Comparable<Standard>, MarkedProvided
{
	/** The standard name. */
	protected final SuiteName name;
	
	/** The vendor of the standard. */
	protected final SuiteVendor vendor;
	
	/** The version of the standard. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the standard using the given fields.
	 *
	 * @param __name The name of the standard.
	 * @param __vend The vendor of the standard.
	 * @param __vers The version of the standard.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/12/30
	 */
	public Standard(SuiteName __name, SuiteVendor __vend, SuiteVersion __vers)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.vendor = __vend;
		this.version = __vers;
	}
	
	/**
	 * Decodes the standard from the specified string.
	 *
	 * @param __s The string to decode the standard from.
	 * @throws InvalidSuiteException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public Standard(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG04 Expected input standard string to
		// contain three fields separated by semi-colon. (The input string)}
		String[] splice = StringUtils.fieldSplitAndTrim(';', __s);
		if (splice.length != 3)
			throw new InvalidSuiteException(String.format("DG04 %s", __s));
		
		// {@squirreljme.error DG05 Name in standard string is empty. (The
		// input string)}
		String name = splice[0];
		if (name.isEmpty())
			throw new InvalidSuiteException(String.format("DG05 %s", __s));
		this.name = new SuiteName(name);
		
		String vendor = splice[1];
		this.vendor = (vendor.isEmpty() ? null : new SuiteVendor(vendor));
		
		String version = splice[2];
		this.version = (version.isEmpty() ? null : new SuiteVersion(version));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int compareTo(Standard __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVendor aven = this.vendor,
			bven = __o.vendor;
		if ((aven == null) != (bven == null))
			return (aven == null ? -1 : 1);
		else if (aven != null)
		{
			rv = aven.compareTo(bven);
			if (rv != 0)
				return rv;
		}
			
		SuiteVersion aver = this.version,
			bver = __o.version;
		if ((aver == null) != (bver == null))
			return (aver == null ? -1 : 1);
		else if (aver != null)
			return aver.compareTo(bver);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Standard))
			return false;
		
		Standard o = (Standard)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * Returns the name of the API which is defined.
	 *
	 * @return The defined API name.
	 * @since 2017/12/30
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.name + ";" +
				Objects.toString(this.vendor, "") + ";" +
				Objects.toString(this.version, "")));
		
		return rv;
	}
	
	/**
	 * Returns the vendor of the standard.
	 *
	 * @return The vendor, may be {@code null} if no vendor was specified.
	 * @since 2017/12/30
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the version of the standard.
	 *
	 * @return The version, may be {@code null} if no version was specified.
	 * @since 2017/12/30
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/StandardName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents the name of a standard.
 *
 * @since 2017/12/05
 */
public final class StandardName
	implements Comparable<StandardName>
{
	/**
	 * Initializes the standard name.
	 *
	 * @param __s The name of the standard.
	 * @throws InvalidSuiteException If the name is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/05
	 */
	public StandardName(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public int compareTo(StandardName __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/SuiteDependency.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.collections.NaturalComparator;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a dependency that a LIBlet or MIDlet may depend on.
 *
 * @since 2017/02/22
 */
public final class SuiteDependency
	implements Comparable<SuiteDependency>, MarkedDependency
{
	/** The dependency type. */
	protected final SuiteDependencyType type;
	
	/** The dependency level. */
	protected final SuiteDependencyLevel level;
	
	/** The name. */
	protected final SuiteName name;
	
	/** The vendor. */
	protected final SuiteVendor vendor;
	
	/** The version range. */
	protected final SuiteVersionRange version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dependency which is parsed from the given input string.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteDependency(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error DG06 Expected four semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 4)
			throw new InvalidSuiteException(String.format(
				"AR06 %s", __s));
		
		// Split fields
		String intype = __s.substring(0, sc[0]).trim(),
			inlevel = __s.substring(sc[0] + 1, sc[1]).trim(),
			inname = __s.substring(sc[1] + 1, sc[2]).trim(),
			invendor = __s.substring(sc[2] + 1, sc[3]).trim(),
			inversion = __s.substring(sc[3] + 1).trim();
		
		// Required fields
		SuiteDependencyType type;
		this.type = (type = SuiteDependencyType.of(intype));
		this.level = SuiteDependencyLevel.of(inlevel);
		
		// Optional fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		// Check
		SuiteDependency.__check(type, this.level, name, vendor, version);
	}
	
	/**
	 * Initializes the depedency with the given type, level, and where the
	 * remainder of the dependencies are parsed from the specified string.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __s The string to decode for the remainder of the dependency.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error DG07 Expected two semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 2)
			throw new InvalidSuiteException(String.format(
				"AR07 %s", __s));
		
		// Split fields
		String inname = __s.substring(0, sc[0]).trim(),
			invendor = __s.substring(sc[0] + 1, sc[1]).trim(),
			inversion = __s.substring(sc[1] + 1).trim();
		
		// Parse areas fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		SuiteDependency.__check(__type, __level, name, vendor, version);
		
		// Set
		this.type = __type;
		this.level = __level;
	}
	
	/**
	 * Initializes the dependency using the given parameters.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException If no type and/or name were specified.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null)
			throw new NullPointerException("NARG");
		
		SuiteDependency.__check(__type, __level, __name, __vendor, __version);
		
		// Set
		this.type = __type;
		this.level = __level;
		this.name = __name;
		this.vendor = __vendor;
		this.version = __version;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public final int compareTo(SuiteDependency __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Type first
		int rv = this.type.compareTo(__d.type);
		if (rv != 0)
			return rv;
			
		// Optionality
		rv = this.level.compareTo(__d.level);
		if (rv != 0)
			return rv;
		
		// Name
		rv = Objects.<SuiteName>compare(this.name, __d.name,
			NaturalComparator.<SuiteName>instance());
		if (rv != 0)
			return rv;
		
		// Vendor
		rv = Objects.<SuiteVendor>compare(this.vendor, __d.vendor,
			NaturalComparator.<SuiteVendor>instance());
		if (rv != 0)
			return rv;
		
		// Version
		return Objects.<SuiteVersionRange>compare(this.version, __d.version,
			NaturalComparator.<SuiteVersionRange>instance());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteDependency))
			return false;
		
		// Compare
		SuiteDependency o = (SuiteDependency)__o;
		return this.type.equals(o.type) &&
			this.level.equals(o.level) &&
			Objects.equals(this.name, o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.level.hashCode() ^
			Objects.hashCode(this.name) ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/22
	 */
	@Override
	public boolean isOptional()
	{
		return this.level.isOptional();
	}
	
	/**
	 * Is this a required dependency?
	 *
	 * @return {@code true} if this is a required dependency.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this.level.isRequired();
	}
	
	/**
	 * Returns the dependency level.
	 *
	 * @return The dependency level.
	 * @since 2017/02/22
	 */
	public SuiteDependencyLevel level()
	{
		return this.level;
	}
	
	/**
	 * Returns the dependency name.
	 *
	 * @return The dependency name, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		SuiteDependencyType type = this.type;
		Class<?> mpclass = __mp.getClass();
		SuiteName name = this.name;
		SuiteVendor vendor = this.vendor;
		SuiteVersionRange version = this.version;
		
		// Depends
		switch (type)
		{
				// Proprietary match
			case PROPRIETARY:
				// Potential internal project name
				if (__mp instanceof InternalName)
				{
					String myname = name.toString();
					
					// Needs at sign
					int dxat;
					if ((dxat = myname.indexOf('@')) < 0)
						return false;
					
					// Prefix must be project reference
					if (!myname.substring(0, dxat).
						equals("squirreljme.project"))
						return false;
					
					// Otherwise the project name must match
					return myname.substring(dxat + 1).
						equals(((InternalName)__mp).name());
				}
				
				// No matches
				return false;
				
				// Library
			case LIBLET:
				// Typed suite information
				if (__mp instanceof TypedSuite)
				{
					TypedSuite other = (TypedSuite)__mp;
					SuiteIdentifier ident = other.suite();
					
					// Only match other libraries
					if (other.type() != SuiteType.LIBLET)
						return false;
					
					// Must match name
					if (!name.equals(ident.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(ident.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(ident.version()))
							return false;
					
					// Is okay!
					return true;
				}
				
				// Unknown
				else
					return false;
					
				// Standard
			case STANDARD:
				if (__mp instanceof Standard)
				{
					Standard other = (Standard)__mp;
					
					// Must match name
					if (!name.equals(other.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(other.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(other.version()))
							return false;
					
					// Matches!
					return true;
				}
				
				// Not a standard
				else
					return false;
				
				// {@squirreljme.error DG08 Illegal dependency check.
				// (The dependency type; The target class)}
			default:
				throw new RuntimeException(String.format("AR08 %s %s",
					type, mpclass));
		}
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * required.
	 *
	 * @return This dependency but required.
	 * @since 2017/11/26
	 */
	public SuiteDependency toRequired()
	{
		if (this.isRequired())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.REQUIRED,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * optional.
	 *
	 * @return This dependency but optional.
	 * @since 2017/11/26
	 */
	public SuiteDependency toOptional()
	{
		if (this.isOptional())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.OPTIONAL,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// These are optional
			SuiteName name = this.name;
			SuiteVendor vendor = this.vendor;
			SuiteVersionRange version = this.version;
			
			// Generate
			this._string = new WeakReference<>((rv = String.format(
				"%s;%s;%s;%s;%s", this.type, this.level,
				(name == null ? "" : name),
				(vendor == null ? "" : vendor),
				(version == null ? "" : version))));
		}
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the dependency type.
	 *
	 * @return The dependency type.
	 * @since 2017/02/22
	 */
	public SuiteDependencyType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the dependency vendor.
	 *
	 * @return The dependency vendor, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the dependency version.
	 *
	 * @return The dependency version, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange version()
	{
		return this.version;
	}
	
	/**
	 * Checks whether the provided parameters are correct.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @since 2017/11/26
	 */
	private static final void __check(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException
	{
		// {@squirreljme.error DG09 Dependencies on LIBlets must have the
		// name, vendor, and version set. (The type; The level; The name;
		// The vendor; The version)}
		if (__type == SuiteDependencyType.LIBLET && (__name == null ||
			__vendor == null || __version == null))
			throw new InvalidSuiteException(
				String.format("AR09 %s %s %s %s %s", __type, __level, __name,
					__vendor, __version));
	}
}

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

package cc.squirreljme.runtime.swm;

/**
 * This represents the level of the dependency.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyLevel
{
	/** Required. */
	REQUIRED,
	
	/** Optional. */
	OPTIONAL,
	
	/** End. */
	;
	
	/**
	 * Is this an optional dependency level?
	 *
	 * @return {@code true} if this is an optional dependency level.
	 * @since 2017/11/22
	 */
	public boolean isOptional()
	{
		return this == SuiteDependencyLevel.OPTIONAL;
	}
	
	/**
	 * Is this an required dependency level?
	 *
	 * @return {@code true} if this is an required dependency level.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this == SuiteDependencyLevel.REQUIRED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case REQUIRED:	return "required";
			case OPTIONAL:	return "optional";
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the dependency level based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency level for the given string.
	 * @throws IllegalArgumentException If the level is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyLevel of(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "required":	return SuiteDependencyLevel.REQUIRED;
			case "optional":	return SuiteDependencyLevel.OPTIONAL;
			
				// {@squirreljme.error DG82 Invalid dependency level. (Level)}
			default:
				throw new IllegalArgumentException(String.format(
					"DG82 %s", __s));
		}
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/SuiteDependencyType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents the type of the dependency that is to be included.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyType
{
	/** Liblet. */
	LIBLET,
	
	/** Standard. */
	STANDARD,
	
	/** Service. */
	SERVICE,
	
	/** Proprietary. */
	PROPRIETARY,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case LIBLET:		return "liblet";
			case STANDARD:		return "standard";
			case SERVICE:		return "service";
			case PROPRIETARY:	return "proprietary";
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the dependency type based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency type for the given string.
	 * @throws InvalidSuiteException If the dependency type is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyType of(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "liblet":		return SuiteDependencyType.LIBLET;
			case "standard":	return SuiteDependencyType.STANDARD;
			case "service":		return SuiteDependencyType.SERVICE;
			case "proprietary":	return SuiteDependencyType.PROPRIETARY;
			
				// {@squirreljme.error DG0a The specified string is not a valid
				// dependency type. (The input string)}
			default:
				throw new InvalidSuiteException(
					String.format("AR0a %s", __s));
		}
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is the identity for a midlet suite which contains a name, vendor,
 * and version.
 *
 * @since 2016/10/12
 */
public final class SuiteIdentifier
	implements Comparable<SuiteIdentifier>
{
	/** The suite name. */
	protected final SuiteName name;
	
	/** The suite vendor. */
	protected final SuiteVendor vendor;
	
	/** The suite version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __name The name of the suite.
	 * @param __ven The vendor of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteIdentifier(SuiteName __name, SuiteVendor __ven,
		SuiteVersion __ver)
		throws NullPointerException
	{
		this(__ven, __name, __ver);
	}
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __ven The vendor of the suite.
	 * @param __name The name of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteIdentifier(SuiteVendor __ven, SuiteName __name,
		SuiteVersion __ver)
		throws NullPointerException
	{
		// Check
		if (__ven == null || __name == null || __ver == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.vendor = __ven;
		this.version = __ver;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteIdentifier __o)
	{
		if (this == __o)
			return 0;
		
		// Compare name
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		// Then vendor
		rv = this.vendor.compareTo(__o.vendor);
		if (rv != 0)
			return rv;
		
		// Then the version last
		return this.version.compareTo(__o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteIdentifier))
			return false;
		
		return 0 == (this.compareTo((SuiteIdentifier)__o));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.vendor.hashCode() ^
			this.version.hashCode();
	}
	
	/**
	 * Returns the suite name.
	 *
	 * @return The suite name.
	 * @since 2016/10/12
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.vendor + ";" +
				this.name + ";" + this.version));
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the suite vendor.
	 *
	 * @return The suite vendor.
	 * @since 2016/10/12
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the suite version.
	 *
	 * @return The suite version.
	 * @since 2016/10/12
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/SuiteInfo.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
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
191
192
193
194
195
196
197
198
199
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This contains all of the information which is provided by a suite.
 *
 * @since 2017/11/30
 */
public final class SuiteInfo
{
	/** The manifest for this suite. */
	protected final JavaManifest manifest;
	
	/** The type of suite this is. */
	protected final SuiteType type;
	
	/** The suite name. */
	protected final SuiteName name;
	
	/** The suite vendor. */
	protected final SuiteVendor vendor;
	
	/** The suite version. */
	protected final SuiteVersion version;
	
	/** Required dependency information. */
	private Reference<DependencyInfo> _dependencies;
	
	/** Provided dependency information. */
	private Reference<ProvidedInfo> _provided;
	
	/** Suite cache. */
	private Reference<SuiteIdentifier> _suite;
	
	/**
	 * Initializes the suite information.
	 *
	 * @param __man The manifest making up the suite information.
	 * @throws InvalidSuiteException If the suite information is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public SuiteInfo(JavaManifest __man)
		throws InvalidSuiteException, NullPointerException
	{
		if (__man == null)
			throw new NullPointerException("NARG");
		
		this.manifest = __man;
		JavaManifestAttributes attr = __man.getMainAttributes();
		
		// First determine the type
		SuiteType type = SuiteType.ofManifest(__man);
		this.type = type;
		
		// {@squirreljme.error DG0b No suite name was specified.}
		SuiteName name = new SuiteName(
			Objects.<String>requireNonNull(attr.getValue(type.nameKey()),
			"AR0b"));
		this.name = name;
		
		// {@squirreljme.error DG0c No suite vendor was specified.}
		SuiteVendor vendor = new SuiteVendor(
			Objects.<String>requireNonNull(attr.getValue(type.vendorKey()),
			"AR0c"));
		this.vendor = vendor;
		
		// {@squirreljme.error DG0d No suite version was specified.}
		SuiteVersion version = new SuiteVersion(
			Objects.<String>requireNonNull(attr.getValue(type.versionKey()),
			"AR0d"));
		this.version = version;
	}
	
	/**
	 * Return the dependencies which are required by this suite.
	 *
	 * @return The dependencies required by this suite.
	 * @since 2017/12/04
	 */
	public final DependencyInfo dependencies()
	{
		Reference<DependencyInfo> ref = this._dependencies;
		DependencyInfo rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._dependencies = new WeakReference<>(
				(rv = DependencyInfo.of(this)));
		
		return rv;
	}
	
	/**
	 * Returns the manifest used for this suite.
	 *
	 * @return The manifest suite.
	 * @since 2017/12/05
	 */
	public final JavaManifest manifest()
	{
		return this.manifest;
	}
	
	/**
	 * Returns the suite name.
	 *
	 * @return The name.
	 * @since 2017/12/31
	 */
	public final SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the dependencies provided by this suite.
	 *
	 * @return The provided dependencies for this suite.
	 * @since 2017/12/04
	 */
	public final ProvidedInfo provided()
	{
		Reference<ProvidedInfo> ref = this._provided;
		ProvidedInfo rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._provided = new WeakReference<>(
				(rv = ProvidedInfo.of(this)));
		
		return rv;
	}
	
	/**
	 * Returns the suite for this.
	 *
	 * @return The suite.
	 * @since 2017/12/05
	 */
	public final SuiteIdentifier suite()
	{
		Reference<SuiteIdentifier> ref = this._suite;
		SuiteIdentifier rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._suite = new WeakReference<>((rv = new SuiteIdentifier(
				this.name, this.vendor, this.version)));
		
		return rv;
	}
	
	/**
	 * Returns the type of suite this is.
	 *
	 * @return The type of suite.
	 * @since 2017/12/04
	 */
	public final SuiteType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the suite vendor.
	 *
	 * @return The vendor.
	 * @since 2017/12/31
	 */
	public final SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the suite version.
	 *
	 * @return The version.
	 * @since 2017/12/31
	 */
	public final SuiteVersion version()
	{
		return this.version;
	}
}

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

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the name of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteName
	implements Comparable<SuiteName>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite name.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteName(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG0e An illegal character was
		// specified in the midlet suite name. (The midlet suite
		// name)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AR0e %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteName __o)
	{
		if (this == __o)
			return 0;
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteName))
			return false;
		
		return this.string.equals(((SuiteName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This represents the type of suite that a suite may be.
 *
 * @since 2017/12/04
 */
public enum SuiteType
{
	/** MIDlet. */
	MIDLET("MIDlet"),
	
	/** LIBlet. */
	LIBLET("LIBlet"),
	
	/** An API. */
	SQUIRRELJME_API("X-SquirrelJME-API"),
	
	/** End. */
	;
	
	/** The used prefix. */
	protected final String prefix;
	
	/** Manifest description key. */
	private Reference<JavaManifestKey> _description;
	
	/** Manifest name key. */
	private Reference<JavaManifestKey> _name;
	
	/** Manifest vendor key. */
	private Reference<JavaManifestKey> _vendor;
	
	/** Manifest version key. */
	private Reference<JavaManifestKey> _version;
	
	/**
	 * Initializes the type.
	 *
	 * @param __p The prefix which is used.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	SuiteType(String __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		this.prefix = __p;
	}
	
	/**
	 * Returns the key which is used to refer to dependencies.
	 *
	 * @param __i The index of the dependency to get.
	 * @return The key for the given dependency index.
	 * @since 2017/12/05
	 */
	public JavaManifestKey dependencyKey(int __i)
	{
		// {@squirreljme.error DG0f Cannot have a zero or negative dependency
		// index.}
		if (__i <= 0)
			throw new IllegalArgumentException("AR0f");
		
		return new JavaManifestKey(this.prefix + "-Dependency-" + __i);
	}
	
	/**
	 * Returns the manifest key used for the description.
	 *
	 * @return The description manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey descriptionKey()
	{
		Reference<JavaManifestKey> ref = this._description;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._description = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Description")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the name.
	 *
	 * @return The name manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey nameKey()
	{
		Reference<JavaManifestKey> ref = this._name;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._name = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Name")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the vendor.
	 *
	 * @return The vendor manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey vendorKey()
	{
		Reference<JavaManifestKey> ref = this._vendor;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._vendor = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Vendor")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the version.
	 *
	 * @return The version manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey versionKey()
	{
		Reference<JavaManifestKey> ref = this._version;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._version = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Version")));
		
		return rv;
	}
	
	/**
	 * Returns the suite type for the given manifest.
	 *
	 * @param __man The manifest to get the type from.
	 * @return The type of suite from the given manifest.
	 * @throws InvalidSuiteException If the type is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public static final SuiteType ofManifest(JavaManifest __man)
		throws InvalidSuiteException, NullPointerException
	{
		if (__man == null)
			throw new NullPointerException("NARG");
		
		JavaManifestAttributes attr = __man.getMainAttributes();
		for (SuiteType t : SuiteType.values())
			if (attr.definesValue(t.nameKey()))
				return t;
		
		// {@squirreljme.error DG0g Could not obtain the type of suite from
		// the input manifest.}
		throw new InvalidSuiteException("AR0g");
	}
}

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

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the vendor of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteVendor
	implements Comparable<SuiteVendor>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite vendor.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVendor(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DG0h An illegal character was
		// specified in the midlet suite vendor. (The midlet suite
		// vendor)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AD0d %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVendor __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVendor))
			return false;
		
		return this.string.equals(((SuiteVendor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/SuiteVersion.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a suite version.
 *
 * @since 2016/10/12
 */
public final class SuiteVersion
	implements Comparable<SuiteVersion>
{
	/** The minimum version number. */
	public static final SuiteVersion MIN_VERSION =
		new SuiteVersion(0, 0, 0);
	
	/** The maximum version number. */
	public static final SuiteVersion MAX_VERSION =
		new SuiteVersion(99, 99, 99);
	
	/** The major version. */
	protected final int major;
	
	/** The minor version. */
	protected final int minor;
	
	/** The release version. */
	protected final int release;
	
	/** The string representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the version.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If there are too many or too little
	 * version fields, they contain illegal charactes, or have an out of range
	 * value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		this(SuiteVersion.__decodeVersion(__v));
	}
	
	/**
	 * Initializes a Midlet version number from the specified array of
	 * integer values.
	 *
	 * @param __v The version triplet, up to the first three elements are
	 * used by the version number.
	 * @throws InvalidSuiteException If the version number has an out of
	 * range value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int[] __v)
		throws InvalidSuiteException, NullPointerException
	{
		this((__v.length > 0 ? __v[0] : 0),
			(__v.length > 1 ? __v[1] : 0),
			(__v.length > 2 ? __v[2] : 0));
	}
	
	/**
	 * Decodes the midlet version, optionally allowing it to a reverse
	 * operation of the {@link #hashCode()} method.
	 *
	 * @param __hash If {@code true} then the value to decode is treated as
	 * the hash code returned by this class.
	 * @param __maj If {@code __hash} is {@code true} then this is the hash
	 * code of a SuiteVersion, otherwise it is the major version number.
	 * @throws InvalidSuiteException If the version number has an out of
	 * range value.
	 * @since 2016/10/13
	 */
	public SuiteVersion(boolean __hash, int __maj)
		throws InvalidSuiteException
	{
		this((__hash ? __maj / 10000 : __maj),
			(__hash ? (__maj / 100) % 100 : 0),
			(__hash ? __maj % 100 : 0));
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj)
	{
		this(__maj, 0, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min)
	{
		this(__maj, __min, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @param __rel The release version.
	 * @throws InvalidSuiteException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min, int __rel)
		throws InvalidSuiteException
	{
		// {@squirreljme.error DG0i Input version number is out of range, only
		// 0 through 99 are valid. (The major version; The minor version; The
		// release version)}
		if (__maj < 0 || __maj > 99 || __min < 0 || __min > 99 ||
			__rel < 0 || __rel > 99)
			throw new InvalidSuiteException(String.format("AR0i %d %d %d",
				__maj, __min, __rel));
		
		// Set
		this.major = __maj;
		this.minor = __min;
		this.release = __rel;
	}
	
	/**
	 * Checks if this version at least the specified verison.
	 *
	 * @param __v The version to check against.
	 * @return {@code true} if this version is at least the other.
	 * @throws NullPointerException On nul arguments.
	 */
	public boolean atLeast(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Can compare the hashcodes
		return this.hashCode() >= __v.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVersion __o)
	{
		// Major first
		int amaj = this.major, bmaj = __o.major;
		int rv = amaj - bmaj;
		if (rv != 0)
			return rv;
		
		// Then minor
		int amin = this.minor, bmin = __o.minor;
		rv = amin - bmin;
		if (rv != 0)
			return rv;
		
		// Then release
		int arel = this.release, brel = __o.release;
		rv = arel - brel;
		if (rv != 0)
			return rv;
		
		// The same
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersion))
			return false;
		
		// Cast
		SuiteVersion o = (SuiteVersion)__o;
		return this.major == o.major &&
			this.minor == o.minor &&
			this.release == o.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return (this.major * 10000) +
			(this.minor * 100) +
			this.release;
	}
	
	/**
	 * Returns the major version.
	 *
	 * @return The major version.
	 * @since 2017/02/22
	 */
	public int major()
	{
		return this.major;
	}
	
	/**
	 * Returns the minor version.
	 *
	 * @return The minor version.
	 * @since 2017/02/22
	 */
	public int minor()
	{
		return this.minor;
	}
	
	/**
	 * Returns the release version.
	 *
	 * @return The release version.
	 * @since 2017/02/22
	 */
	public int release()
	{
		return this.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.major + "." +
				this.minor + "." + this.release));
		
		// Return it
		return rv;
	}
	
	/**
	 * Decodes the string based version number
	 *
	 * @param __v The input string.
	 * @return The version tuplet.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	private static final int[] __decodeVersion(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__v = __v.trim();
		
		// Output array
		int[] rv = new int[3];
		
		// Parse the input value
		int n = __v.length(), at = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i <= n; i++)
		{
			int c = (i == n ? -1 : __v.charAt(i));
			
			// Decimal point? or end
			if (c == '.' || c == -1)
			{
				rv[at++] = Integer.parseInt(sb.toString(), 10);
				
				// {@squirreljme.error DG0j Too many version fields in the
				// specified string. (The input string)}
				if (c != -1 && at >= 4)
					throw new InvalidSuiteException(String.format("AR0j %s",
						__v));
				
				// Clear
				sb.setLength(0);
			}
			
			// Add to string
			else if (c >= '0' && c <= '9')
				sb.append((char)c);
			
			// {@squirreljme.error DG0k An illegal character is in the
			// version string. (The input string; The illegal character)}
			else
				throw new InvalidSuiteException(String.format("AR0k %s %04x",
					__v, c));
		}
		
		// Return it
		return rv;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/SuiteVersionRange.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is used to handle version ranges that may be used for dependencies.
 *
 * Version ranges are inclusive.
 *
 * @since 2017/02/22
 */
public final class SuiteVersionRange
	implements Comparable<SuiteVersionRange>
{
	/** Any version. */
	public static final SuiteVersionRange ANY_VERSION =
		new SuiteVersionRange(SuiteVersion.MIN_VERSION,
			SuiteVersion.MAX_VERSION);
	
	/** The starting range, inclusive. */
	protected final SuiteVersion from;
	
	/** Tne ending range, inclusive. */
	protected final SuiteVersion to;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the range inclusively between the two given versions.
	 *
	 * @param __from The source version.
	 * @param __to The destination version.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(SuiteVersion __from, SuiteVersion __to)
		throws NullPointerException
	{
		// Check
		if (__from == null || __to == null)
			throw new NullPointerException("NARG");
		
		// Make sure from is always first
		if (__from.compareTo(__to) <= 0)
		{
			this.from = __from;
			this.to = __to;
		}
		
		// Swapped
		else
		{
			this.from = __to;
			this.to = __from;
		}
	}
	
	/**
	 * Parses the version range that is specified in the dependency of JAR
	 * files.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the range is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim
		__s = __s.trim();
		
		// {@squirreljme.error DG0l The version range cannot be blank.}
		int sl = __s.length();
		if (sl <= 0)
			throw new IllegalArgumentException("AR0l");
		
		// Get the last character
		char lc = __s.charAt(__s.length() - 1);
		
		// All versions following this.
		if (lc == '+')
		{
			this.from = new SuiteVersion(__s.substring(0, sl - 1));
			this.to = new SuiteVersion(99, 99, 99);
		}
		
		// All versions in the group
		else if (lc == '*')
		{
			// Get the last dot, if any
			int ld = __s.lastIndexOf('.');
			if (ld < 0)
			{
				// Any version, does not matter
				if (sl == 1)
				{
					this.from = new SuiteVersion(0);
					this.to = new SuiteVersion(99, 99, 99);
				}
				
				// {@squirreljme.error DG0m Major only wildcard versions must
				// be a single asterisk. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0m %s",
						__s));
			}
			
			// Parse otherwise, just count the number of dots to determine
			// how deep it goes
			else
			{
				// {@squirreljme.error DG0n The last dot in a wildcard must be
				// before the asterisk. (The input string)}
				if (ld != sl - 1)
					throw new InvalidSuiteException(String.format("AR0n %s",
						__s));
				
				// Source range is simple
				SuiteVersion ver = new SuiteVersion(
					__s.substring(0, sl - 2));
				this.from = ver;
				
				// Count dots, determines major/minor
				int numdots = 0;
				for (int i = 0; i < sl; i++)
					if (__s.charAt(i) == '.')
						numdots++;
				
				// minor and release wildcard
				if (numdots == 1)
					this.to = new SuiteVersion(ver.major(), 99, 99);
				
				// release ranged wildcard
				else if (numdots == 2)
					this.to = new SuiteVersion(ver.major(), ver.minor(), 99);
				
				// {@squirreljme.error DG0o There are too many decimal points
				// in the wildcard version string. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0o %s",
						__s));
			}
		}
		
		// Only this version
		else
		{
			SuiteVersion ver = new SuiteVersion(__s);
			this.from = ver;
			this.to = ver;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(SuiteVersionRange __o)
	{
		// From version is always first
		int rv = this.from.compareTo(__o.from);
		if (rv != 0)
			return rv;
		
		return this.to.compareTo(__o.to);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersionRange))
			return false;
		
		// Compare
		SuiteVersionRange o = (SuiteVersionRange)__o;
		return this.from.equals(o.from) && this.to.equals(o.to);
	}
	
	/**
	 * Returns the start of the range
	 *
	 * @return The range start.
	 * @since 2017/02/22
	 */
	public SuiteVersion from()
	{
		return this.from;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.to.hashCode() ^ (~this.from.hashCode());
	}
	
	/**
	 * Checks whether the specified version is in range.
	 *
	 * @param __v The version to check.
	 * @return {@code true} if it is in the range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public boolean inRange(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return __v.compareTo(this.from) >= 0 &&
			__v.compareTo(this.to) <= 0;
	}
	
	/**
	 * Checks whether the given version is within range of the other version.
	 *
	 * @param __r The other version range to check.
	 * @return If the other version range shares all or part of its range
	 * with this range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/27
	 */
	public boolean inRange(SuiteVersionRange __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the end of the range.
	 *
	 * @return The range end.
	 * @since 2017/02/22
	 */
	public SuiteVersion to()
	{
		return this.to;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Slowly build version
			StringBuilder sb = new StringBuilder();
			SuiteVersion from = this.from;
			SuiteVersion to = this.to;
			
			// Get all values
			int amaj = from.major(),
				amin = from.minor(),
				arel = from.release(),
				bmaj = to.major(),
				bmin = to.minor(),
				brel = to.release();
			
			// Pure wildcard
			if (amaj == 0 && amin == 0 && arel == 0 &&
				bmaj == 99 && bmin == 99 && brel == 99)
				sb.append('*');
			
			// Exact, subwildcard, or any following
			else
			{
				// Add major version
				sb.append(amaj);
				sb.append('.');
				
				// Wild card minor and release
				if (amin == 0 && arel == 0 && bmin == 99 && brel == 99)
					sb.append('*');
				
				// Not wild
				else
				{
					// Add version
					sb.append(amin);
					sb.append('.');
					
					// Wild card release
					if (arel == 0 && brel == 99)
						sb.append('*');
					
					// Would be exact (or plus)
					else
						sb.append(arel);
				}
			
				// Will be all versions following
				if (bmaj == 99 && bmin == 99 && brel == 99)
					sb.append('+');
			}
			
			// Store
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Returns a version which at most implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange atMost(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(SuiteVersion.MIN_VERSION, __v);
	}
	
	/**
	 * Returns a version which exactly implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange exactly(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(__v, __v);
	}
}

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

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a suite with an associated type.
 *
 * @since 2017/12/30
 */
public final class TypedSuite
	implements MarkedProvided
{
	/** The suite type. */
	protected final SuiteType type;
	
	/** The suite. */
	protected final SuiteIdentifier suite;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the typed suite.
	 *
	 * @param __type The type of suite.
	 * @param __suite The suite information.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public TypedSuite(SuiteType __type, SuiteIdentifier __suite)
		throws NullPointerException
	{
		if (__type == null || __suite == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.suite = __suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof TypedSuite))
			return false;
		
		TypedSuite o = (TypedSuite)__o;
		return this.type.equals(o.type) &&
			this.suite.equals(o.suite);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.suite.hashCode();
	}
	
	/**
	 * Returns the suite.
	 *
	 * @return The suite.
	 * @since 2017/12/30
	 */
	public SuiteIdentifier suite()
	{
		return this.suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.type + " " + this.suite));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/12/30
	 */
	public SuiteType type()
	{
		return this.type;
	}
}

Added modules/meep-swm/src/main/java/cc/squirreljme/runtime/swm/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SquirrelJME implementations of the classes needed
 * by the SWM sub-system.
 *
 * @since 2017/12/07
 */

package cc.squirreljme.runtime.swm;

Added modules/meep-swm/src/main/java/javax/microedition/swm/InstallErrorCodes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This enumeration contains the many ways which applications can be failed
 * to be installed.
 *
 * @since 2016/06/24
 */
@SuppressWarnings("FieldNamingConvention")
public enum InstallErrorCodes
{
	/** The applicaton is already installed. */
	ALREADY_INSTALLED,

	/** The dependency of an application is in conflict. */
	APP_INTEGRITY_FAILURE_DEPENDENCY_CONFLICT,

	/** The dependency of an application is mismatched. */
	APP_INTEGRITY_FAILURE_DEPENDENCY_MISMATCH,

	/** The hash sum of an application is invalid. */
	APP_INTEGRITY_FAILURE_HASH_MISMATCH,

	/** The application is blacklisted. */
	APPLICATION_BLACKLISTED,

	/** An attribute does not match. */
	ATTRIBUTE_MISMATCH,

	/** Could not authenticate. */
	AUTHENTICATION_FAILURE,

	/** Not authorized to install the application. */
	AUTHORIZATION_FAILURE,

	/** The certificate authority has been disabled. */
	CA_DISABLED,

	/** Installation cancelled. */
	CANCELLED,

	/** Cannot authenticate. */
	CANNOT_AUTH,

	/** A dependency eventually depends on itself. */
	CIRCULAR_COMPONENT_DEPENDENCY,

	/** The client requesting the program has been blacklisted. */
	CLIENT_BLACKLISTED,

	/** Dynamic componenent dependencies limit exceeded. */
	COMPONENT_DEPS_LIMIT_EXCEEDED,

	/** There is a conflict in a content handler. */
	CONTENT_HANDLER_CONFLICT,

	/** The hash sum of a dependency is mismatched. */
	CORRUPT_DEPENDENCY_HASH,

	/** The JAR is malformed. */
	CORRUPT_JAR,

	/** The certificate of the provider is malformed. */
	CORRUPT_PROVIDER_CERT,

	/** The signature of a JAR is incorrect. */
	CORRUPT_SIGNATURE,

	/** The JAR cannot run on this device. */
	DEVICE_INCOMPATIBLE,

	/** JAR or JAD has a duplicated key. */
	DUPLICATED_KEY,

	/** The certificate authority's key has expired. */
	EXPIRED_CA_KEY,

	/** The provider's certficate has expired. */
	EXPIRED_PROVIDER_CERT,

	/** Not enough space for installation. */
	INSUFFICIENT_STORAGE,

	/** The JAD type is not valid. */
	INVALID_JAD_TYPE,

	/** The JAD URL is not valid. */
	INVALID_JAD_URL,

	/** The JAR type is not valid. */
	INVALID_JAR_TYPE,

	/** The JAR URL is not valid. */
	INVALID_JAR_URL,

	/** Manifest contains an invalid key. */
	INVALID_KEY,

	/** Cannot load native libraries within a JAR. */
	INVALID_NATIVE_LIBRARY,

	/** Payment information incorrect. */
	INVALID_PAYMENT_INFO,

	/** The provider certificate is not valid. */
	INVALID_PROVIDER_CERT,

	/** The signature is not valid. */
	INVALID_SIGNATURE,

	/** The value of a manifest key is not correct. */
	INVALID_VALUE,

	/** The version format is not valid. */
	INVALID_VERSION,

	/** Failed to read or write the file. */
	IO_FILE_ERROR,

	/** Failed to read from or write to network. */
	IO_NETWORK_ERROR,

	/** The JAD URL has moved. */
	JAD_MOVED,

	/** The JAD was not found. */
	JAD_NOT_FOUND,

	/** The server hosting the JAD was not found. */
	JAD_SERVER_NOT_FOUND,

	/** JAR class file verification failed. */
	JAR_CLASSES_VERIFICATION_FAILED,

	/** The JAR is locked. */
	JAR_IS_LOCKED,

	/** The JAR was not found. */
	JAR_NOT_FOUND,

	/** The server containin the JAR was not found. */
	JAR_SERVER_NOT_FOUND,

	/** The JAR size is not correctly matched. */
	JAR_SIZE_MISMATCH,

	/** The name of a LIBlet collides with another LIBlet. */
	LIBLET_NAMESPACE_COLLISION,

	/** The configuration (MIDP, etc.) is missing from the manifest. */
	MISSING_CONFIGURATION,

	/** The hash code of a dependency is missing. */
	MISSING_DEPENDENCY_HASH,

	/** The JAD URL of a dependency is missing. */
	MISSING_DEPENDENCY_JAD_URL,

	/** The JAR size has not been specified. */
	MISSING_JAR_SIZE,

	/** The URL to the JAR has not been specified. */
	MISSING_JAR_URL,

	/** The profile (CLDC, etc.) is missing from the manifest. */
	MISSING_PROFILE,

	/** The provider certificate is missing. */
	MISSING_PROVIDER_CERT,

	/** No suite name was specified. */
	MISSING_SUITE_NAME,

	/** No vendor was specified. */
	MISSING_VENDOR,

	/** No version was specified. */
	MISSING_VERSION,

	/** The suite to be installed is newer than the current one. */
	NEW_VERSION,

	/** Not an error. */
	NO_ERROR,

	/** Another error occured. */
	OTHER_ERROR,

	/** Authetication with a proxy is required. */
	PROXY_AUTH,

	/** The push registration is not in the {@code MIDlet-n} attribute. */
	PUSH_CLASS_FAILURE,

	/** The push registration is already taken. */
	PUSH_DUP_FAILURE,

	/** The format of a push registration is not valid. */
	PUSH_FORMAT_FAILURE,

	/** The protocol of a push registration has failed. */
	PUSH_PROTO_FAILURE,

	/** The certificate has been revoked. */
	REVOKED_CERT,

	/** The name of the suite mismatches. */
	SUITE_NAME_MISMATCH,

	/** There are more properties than the available amount of memory. */
	TOO_MANY_PROPS,

	/** Trusted suites cannot be overwritten. */
	TRUSTED_OVERWRITE_FAILURE,

	/** Not authorized. */
	UNAUTHORIZED,

	/** Not authorized to install suits. */
	UNAUTHORIZED_INSTALL,

	/** Unknown certificate authority. */
	UNKNOWN_CA,

	/** Unknown certificate status. */
	UNKNOWN_CERT_STATUS,

	/** Certificate not supported. */
	UNSUPPORTED_CERT,

	/** Certificate character encoding not supported. */
	UNSUPPORTED_CHAR_ENCODING,

	/** Payment information not supported. */
	UNSUPPORTED_PAYMENT_INFO,

	/** The payment suite is not trusted. */
	UNTRUSTED_PAYMENT_SUITE,

	/** Vendor mismatched. */
	VENDOR_MISMATCH,

	/** Version mismatched. */
	VERSION_MISMATCH,

	/** End. */
	;
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/ManagerFactory.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This class provides static methods for obtaining the application suite and
 * task manager.
 *
 * @since 2016/06/24
 */
public class ManagerFactory
{
	/** Lock for initialization. */
	private static final Object _LOCK =
		new Object();
	
	/** The suite manager. */
	private static volatile SuiteManager _SUITE_MANAGER;
	
	/** The task manager. */
	private static volatile TaskManager _TASK_MANAGER;
	
	/**
	 * Returns an instance of the suite manager that the application may use
	 * to manage suites on the system.
	 *
	 * @return The manager which is used to manage suites installed on the
	 * system.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
	 * "manageSuite")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public static SuiteManager getSuiteManager()
		throws SecurityException
	{
		// Lazily initialize
		synchronized (ManagerFactory._LOCK)
		{
			SuiteManager rv = ManagerFactory._SUITE_MANAGER;
			if (rv == null)
				ManagerFactory._SUITE_MANAGER =
					(rv = new __SystemSuiteManager__());
			return rv;
		}
	}
	
	/**
	 * This returns an instance of the task manager which is used to start,
	 * stop, and enumerate currently running tasks.
	 *
	 * @return The manager which is used to manage tasks which are currently
	 * running.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageTask")} or {@code {@link SWMPermission}("crossClient",
	 * "manageTask")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public static TaskManager getTaskManager()
		throws SecurityException
	{
		// Lazily initialize so that the class is easier to bring up rather
		// than at class initialization time
		synchronized (ManagerFactory._LOCK)
		{
			TaskManager rv = ManagerFactory._TASK_MANAGER;
			if (rv == null)
				ManagerFactory._TASK_MANAGER =
					(rv = new __SystemTaskManager__());
			return rv;
		}
	}
}

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

package javax.microedition.swm;

import java.security.BasicPermission;

/**
 * This is a permission which is used and checked in the security manager
 * to verify that the specified permissions are available before the
 * application and task manager are used.
 *
 * {@code "client"} refers to applications which are assigned to the same
 * client.
 *
 * {@code "crossClient"} is usually assigned to the root client which allows
 * a client to control other clients.
 *
 * @since 2016/06/24
 */
public final class SWMPermission
	extends BasicPermission
{
	/**
	 * Initializes a new permission.
	 *
	 * @param __scope The scope.
	 * @param __actions The actions used. If an action is specified multiple
	 * times then it is ignored.
	 * @throws IllegalArgumentException If any action includes a string which
	 * is not permitted or if the scope is incorrect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	public SWMPermission(String __scope, String __actions)
		throws IllegalArgumentException, NullPointerException
	{
		super(__scope, __actions);
		
		// Check
		if (__scope == null || __actions == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/Suite.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.SuiteInfo;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import net.multiphasicapps.collections.EmptyIterator;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This represents an application suite.
 *
 * Created suites by default have their {@link SuiteStateFlag#AVAILABLE} and
 * {@link SuiteStateFlag#ENABLED} flags set.
 *
 * @since 2016/06/24
 */
public class Suite
{
	/** This is a suite that represents the system. */
	public static Suite SYSTEM_SUITE =
		new Suite(Suite.class);
	
	/** The name of this suite. */
	final String _name;
	
	/** The state lock. */
	private final Object _lock =
		new Object();
	
	/** Cached manifest information (longer lived). */
	private JavaManifest _manifest;
	
	/** Cached suite information (longer lived). */
	private SuiteInfo _suiteinfo;
	
	/** No manifest available for usage? */
	private volatile boolean _nomanifest;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the system suite.
	 *
	 * @param __cl Ignored parameter.
	 * @since 2017/12/08
	 */
	private Suite(Class<Suite> __cl)
	{
		this._name = null;
	}
	
	/**
	 * Initializes the suite.
	 *
	 * @param __n The name of this suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/08
	 */
	Suite(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this._name = __n;
		
		// Pre-cache the manifest and subsequently the suite info
		this.__suiteInfo();
	}
	
	/**
	 * Checks if two suites are equal to each other, they are equal when
	 * the vendor and name of the suite match.
	 *
	 * @param __o The object to compare against.
	 * @return {@code true} if this suite is equal to the other object.
	 * @since 2016/06/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Not another suite?
		if (!(__o instanceof Suite))
			return false;
		
		// Check
		Suite o = (Suite)__o;
		return Objects.equals(this.getName(), o.getName()) &&
			Objects.equals(this.getVendor(), o.getVendor());
	}
	
	/**
	 * Returns the list of attributes which are defined in the JAD or the
	 * manifest.
	 *
	 * @return The iterator of attributes. The system suite always returns
	 * an empty iteration.
	 * @since 2016/06/24
	 */
	public Iterator<String> getAttributes()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return EmptyIterator.<String>empty();
		
		Set<String> rv = new LinkedHashSet<>();
		for (JavaManifestKey k : this.__manifest().getMainAttributes().
			keySet())
			rv.add(k.toString());
		return rv.iterator();
		*/
	}
	
	/**
	 * Returns the value of an attribute.
	 *
	 * @param __a The name of the attribute to obtain a value for.
	 * @return The value of the given attribute or {@code null} if it was not
	 * found. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getAttributeValue(String __a)
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		// Requesting the JAR file this is associated with, this might be
		// used for an icon
		if ("x-squirreljme-jarfile".equalsIgnoreCase(__a))
			return this._name;
		
		// Just need to read the value from the manifest
		return this.__manifest().getMainAttributes().getValue(__a);
	}
	
	/**
	 * Returns the library suites which this suite depends on.
	 *
	 * @return The iterator over the suite dependencies. The system suite
	 * always returns an empty iterator.
	 * @since 2016/06/24
	 */
	public Iterator<Suite> getDependencies()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return EmptyIterator.<Suite>empty();
		
		List<Suite> rv = new ArrayList<>();
		
		// Use the suite manager to wrap suites so that a large number of
		// suites pointing to the same program are not created
		__SystemSuiteManager__ ssm =
			(__SystemSuiteManager__)ManagerFactory.getSuiteManager();
		LibrariesClient manager = ssm._manager;
		
		// Dependencies are internally provided in the control interface
		String val = program.controlGet(LibraryControlKey.DEPENDENCIES);
		if (val != null)
			for (String spl : StringUtils.fieldSplitAndTrim(' ', val))
			{
				int ddx = Integer.valueOf(spl);
				Library sp = manager.byIndex(Integer.parseInt(val));
				if (sp != null)
				{
					Suite su = ssm.__ofProgram(sp);
					if (su.getSuiteType() != SuiteType.SYSTEM)
						rv.add(su);
				}
			}
		
		return rv.iterator();
		*/
	}
	
	/**
	 * This returns the URL which a previously installed suite was downloaded
	 * from.
	 *
	 * @return The URL where the suite was downloaded from. If this is the
	 * system suite, the suite was pre-installed, or was installed using the
	 * raw byte array then this will return null.
	 * @since 2016/06/24
	 */
	public String getDownloadUrl()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return null;
		
		return program.controlGet(LibraryControlKey.DOWNLOAD_URL);
		*/
	}
	
	/**
	 * This returns the names of all classes which are specfied in the MIDlet
	 * attributes in the manifest. The sequence of classes should match the
	 * MIDlet order number.
	 *
	 * @return The names of classes that are specified in the MIDlet attributes
	 * in the manifest. The system suite always returns an empty iterator.
	 * @since 2016/06/24
	 */
	public Iterator<String> getMIDlets()
	{
		// System suite always returns null
		if (this._name == null)
			return EmptyIterator.<String>empty();
		
		JavaManifestAttributes attr = this.__manifest().getMainAttributes();
		
		// Load in all midlet descriptions
		List<String> rv = new LinkedList<>();
		for (int i = 1; i >= 1; i++)
		{
			// These are in the following format
			String maybe = attr.getValue("MIDlet-" + i);
			if (maybe == null)
				break;
			
			// The value is in the following format:
			// name, icon, entry point
			// We only care about the entry point
			int lm = maybe.lastIndexOf(',');
			if (lm < 0)
				continue;
			
			// Use trimmed string since there may be extra whitespace
			rv.add(maybe.substring(lm + 1).trim());
		}
		
		return rv.iterator();
	}
	
	/**
	 * Returns the name of this suite.
	 *
	 * @return The suite name. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getName()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().name().toString();
	}
	
	/**
	 * Returns the type of suite that this is.
	 *
	 * @return The type of suite this is. The system suite always returns
	 * {@link SuiteType#SYSTEM}.
	 * @since 2016/06/24
	 */
	public SuiteType getSuiteType()
	{
		// Is system suite
		if (this._name == null)
			return SuiteType.SYSTEM;
		
		// Depends on the type
		switch (this.__suiteInfo().type())
		{
			case MIDLET:
				return SuiteType.APPLICATION;
			
			case LIBLET:
				return SuiteType.LIBRARY;
			
				// Not a valid suite type, should end up always being
				// filtered
			case SQUIRRELJME_API:
				return SuiteType.INVALID;
				
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the vendor of this suite.
	 *
	 * @return The vendor of this suite. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getVendor()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().vendor().toString();
	}
	
	/**
	 * Returns the version of this suite.
	 *
	 * @return The version of this suite. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getVersion()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().version().toString();
	}
	
	/**
	 * Calculates the hash code of the given suite, the values are derived from
	 * the name and the vendor.
	 *
	 * @return The hash code.
	 * @since 2016/06/24
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this.getVendor()) ^
			Objects.hashCode(this.getName());
	}
	
	/**
	 * Returns {@code true} if this suite is installed.
	 *
	 * @return {@code true} if this suite is installed. The system suite always
	 * returns {@code true}.
	 * @since 2016/06/24
	 */
	public boolean isInstalled()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return true;
		
		return Boolean.valueOf(
			program.controlGet(LibraryControlKey.IS_INSTALLED));
		*/
	}
	
	/**
	 * Checks if the suite has the specified flag set.
	 *
	 * @param __f The flag to check.
	 * @return {@code true} if the flag is set.
	 * @since 2016/06/24
	 */
	public boolean isSuiteState(SuiteStateFlag __f)
	{
		throw new todo.TODO();
		/*
		// Null is never true
		if (__f == null)
			return false;
		
		// The system suite always has a fixed set of flags
		Library program = this._library;
		if (program == null)
			switch (__f)
			{
				case AVAILABLE:
				case ENABLED:
				case PREINSTALLED:
				case REMOVE_DENIED:
				case SYSTEM:
				case UPDATE_DENIED:
					return true;
				default:
					return false;
			}
		
		return Boolean.valueOf(program.controlGet(__f.__controlKey()));
		*/
	}
	
	/**
	 * Sets whether this suite is trusted or not.
	 *
	 * @return {@code true} if this suite is trusted. The system suite always
	 * returns {@code true}.
	 * @since 2016/06/24
	 */
	public boolean isTrusted()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return true;
		
		return Boolean.valueOf(
			program.controlGet(LibraryControlKey.IS_TRUSTED));
		*/
	}
	
	/**
	 * Sets the given flag to the suite.
	 *
	 * @param __f The flag to set.
	 * @param __v If the flag should be set or cleared.
	 * @throws IllegalArgumentException If an attempt was made to set the
	 * {@link SuiteStateFlag#SYSTEM} or {@link SuiteStateFlag#PREINSTALLED}
	 * flags.
	 * @throws IllegalStateException If the suite was removed or this is the
	 * system suite.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
	 * "manageSuite")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public void setSuiteStateFlag(SuiteStateFlag __f, boolean __v)
		throws IllegalArgumentException, IllegalStateException,
			SecurityException
	{
		// Ignore
		if (__f == null)
			return;
		
		throw new todo.TODO();
		/*
		// {@squirreljme.error DG0q The current suite has been removed.}
		if (!isInstalled())
			throw new IllegalStateException("DG0q");
		
		// {@squirreljme.error DG0r The given state flag cannot be set.
		// (The state flag)}
		if (__f == SuiteStateFlag.SYSTEM || __f == SuiteStateFlag.PREINSTALLED)
			throw new IllegalArgumentException(String.format("DG0r %s", __f));
		
		// Lock
		synchronized (this._lock)
		{
			// {@squirreljme.error DG0s Cannot change flags of the system
			// suite.}
			if (0 != (this._state & (1 << SuiteStateFlag.SYSTEM.ordinal())))
				throw new IllegalStateException("DG0s");
			
			// Get the required bit
			int bit = (1 << __f.SYSTEM.ordinal());
			
			// Set or clear?
			if (__v)
				this._state |= bit;
			else
				this._state &= bit;
		}
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = "Suite " + this.getName() + ":" + this.getVersion()));
		
		return rv;
	}
	
	/**
	 * Returns the suite manifest.
	 *
	 * @return The suite manifest.
	 * @since 2017/12/31
	 */
	final JavaManifest __manifest()
	{
		JavaManifest rv = this._manifest;
		if (rv != null)
			return rv;
		
		// Definitely does not exist
		if (this._nomanifest)
			rv = new JavaManifest();
		
		// Could exist, hopefully it does
		else
			try (InputStream in = ResourceInputStream.open(this._name,
				"META-INF/MANIFEST.MF"))
			{
				// Will keep trying to open resources, so just prevent
				// that from happening
				if (in == null)
				{
					rv = new JavaManifest();
					this._nomanifest = true;
				}
				
				// Load it in
				else
					rv = new JavaManifest(in);
			}
			catch (IOException e)
			{
				// Print the manifest issue
				e.printStackTrace();
				
				// Just say there is no manifest
				rv = new JavaManifest();
				this._nomanifest = true;
			}
		
		// Cache
		this._manifest = rv;
		
		return rv;
	}
	
	/**
	 * Returns a dependency match result which contains the results of a
	 * dependency match between the provided dependencies and the provided
	 * dependencies for this suite.
	 *
	 * This is taken from the SquirrelJME build system.
	 *
	 * @param __d The input dependencies to check.
	 * @return The result of the match.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/02
	 */
	final MatchResult __matchedDependencies(DependencyInfo __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		return __d.match(this.__suiteInfo().provided());
	}
	
	/**
	 * Returns the information about this suite.
	 *
	 * @return The suite information.
	 * @since 2017/12/31
	 */
	final SuiteInfo __suiteInfo()
	{
		SuiteInfo rv = this._suiteinfo;
		if (rv != null)
			return rv;
		
		// Load
		this._suiteinfo = (rv = new SuiteInfo(this.__manifest()));
		
		return rv;
	}
}

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

package javax.microedition.swm;

/**
 * This is a listener which is called when an application is currently being
 * installed, has finished installation, or failed to install.
 *
 * @since 2016/06/24
 */
public interface SuiteInstallListener
{
	/**
	 * This is called when an installation has finished for any reason, from
	 * success to failure.
	 *
	 * Before this is called, {@link #updateStatus(SuiteManagementTracker,
	 * SuiteInstallStage, int)} must be called with
	 * {@link SuiteInstallStage#DONE}.
	 *
	 * @param __ec The result of the installation attempt.
	 * @param __track The tracker which was created when an installation
	 * was started to be performed.
	 * @since 2016/06/24
	 */
	void installationDone(InstallErrorCodes __ec,
		SuiteManagementTracker __track);
	
	/**
	 * This is called when the current status of the installation of a suite
	 * has been updated. This may be used by a listener to provide a progress
	 * bar for example.
	 *
	 * @param __track The tracker which was created when an installation
	 * was started to be performed.
	 * @param __stage The current stage of the installation.
	 * @param __pct The amount of progress which has passed in this stage, this
	 * should be a value between zero and one hundred.
	 * @since 2016/06/24
	 */
	void updateStatus(SuiteManagementTracker __track,
		SuiteInstallStage __stage, int __pct);
}

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

package javax.microedition.swm;

/**
 * This represents the stage of an installation.
 *
 * @since 2016/06/24
 */
public enum SuiteInstallStage
{
	/** Installation finished. */
	DONE,
	
	/** Downloading document body. */
	DOWNLOAD_BODY,
	
	/** Downloading data. */
	DOWNLOAD_DATA,
	
	/** Downloading descriptor. */
	DOWNLOAD_DESCRIPTOR,
	
	/** Storing suite data. */
	STORING,
	
	/** Verifying the download. */
	VERIFYING,
	
	/** End. */
	;
}

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

package javax.microedition.swm;

import cc.squirreljme.runtime.swm.JarStreamSupplier;
import java.util.Set;
import net.multiphasicapps.collections.IdentityLinkedHashSet;

/**
 * This class is created when a suite is to be installed.
 *
 * @since 2016/06/24
 */
public final class SuiteInstaller
{
	/** The supplier for the JAR data. */
	final JarStreamSupplier _supplier;
	
	/** Listeners for suites. */
	final Set<SuiteInstallListener> _listeners =
		new IdentityLinkedHashSet<>();
	
	/**
	 * Internal use only.
	 *
	 * @param __sup The supplier for JAR files.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	SuiteInstaller(JarStreamSupplier __sup)
		throws NullPointerException
	{
		if (__sup == null)
			throw new NullPointerException("NARG");
		
		this._supplier = __sup;
	}
	
	/**
	 * Adds a suite installation listener which can be given status updates
	 * when a suite's installation status has changed.
	 *
	 * @param __sl The listener to add.
	 * @since 2016/06/24
	 */
	public final void addInstallationListener(SuiteInstallListener __sl)
	{
		// Ignore
		if (__sl == null)
			return;
		
		this._listeners.add(__sl);
	}
	
	/**
	 * Cancels the current installation.
	 *
	 * @since 2016/06/24
	 */
	public final void cancel()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Removes the given installation listener so that it no longer is notified
	 * of installation updates.
	 *
	 * @param __sl The listener to remove.
	 * @since 2016/06/24
	 */
	public final void removeInstallationListener(SuiteInstallListener __sl)
	{
		// Ignore
		if (__sl == null)
			return;
		
		this._listeners.remove(__sl);
	}
	
	/**
	 * Starts installation of the given suite.
	 *
	 * If this is called twice then the next installation attempt is
	 * enqueued regardless if the previous installation has succeeded or
	 * failed.
	 *
	 * If there is not enough permission to install the given suite then
	 * {@link InstallErrorCodes#UNAUTHORIZED_INSTALL} is set.
	 *
	 * @return The tracker for the given suite.
	 * @since 2016/06/24
	 */
	public final SuiteManagementTracker start()
	{
		return new __SuiteTracker__(this);
	}
}

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

package javax.microedition.swm;

/**
 * This interface is called when a suite has been installed, is being
 * installed, or has been removed.
 *
 * @since 2016/06/24
 */
public interface SuiteListener
{
	/**
	 * This is called when the installation state of a suite has been changed.
	 *
	 * If installation of a Suite has failed for any reason then
	 * {@link SuiteState#INSTALLATION_FAILED} must be called.
	 *
	 * @param __track This is either the tracker which was provided when an
	 * application was set for installation or an unspecified tracker in the
	 * event of a removal. In the event of removal it is likely that the
	 * tracker would not be the same one returned by an installation due to
	 * restarts of the virtual machine.
	 * @param __state The new state of the suite.
	 * @since 2016/06/24
	 */
	void notifySuiteStateChanged(SuiteManagementTracker __track,
		SuiteState __state);
}

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

package javax.microedition.swm;

import java.io.IOException;

/**
 * This is thrown when a suite cannot be removed, either because it is not
 * permitted or it is currently in use.
 *
 * @since 2016/06/24
 */
public class SuiteLockedException
	extends IOException
{
	/**
	 * Initializes the exception with no message.
	 *
	 * @since 2016/06/24
	 */
	public SuiteLockedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message.
	 *
	 * @param __s The message to use.
	 * @since 2016/06/24
	 */
	public SuiteLockedException(String __s)
	{
		super(__s);
	}
}

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

package javax.microedition.swm;

/**
 * This is used to track the the progress of a suite that is currently
 * being installed.
 *
 * @since 2016/06/24
 */
public abstract class SuiteManagementTracker
{
	/**
	 * Prevents implicit instantiation of trackers.
	 *
	 * @since 2016/06/24
	 */
	protected SuiteManagementTracker()
	{
	}
	
	/**
	 * Returns the suite that this tracker is assigned to or {@code null} if it
	 * is not install yet.
	 *
	 * @return The suite this tracker is assigned to or {@code null} if it
	 * has not yet been installed.
	 * @since 2016/06/24
	 */
	public abstract Suite getSuite();
}

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

package javax.microedition.swm;

import java.util.List;

/**
 * This interface is used to manage querying, installation, and removal of
 * Suites.
 *
 * @see ManagerFactory
 * @since 2016/06/24
 */
public interface SuiteManager
{
	/**
	 * Adds a listener which is used when the state of a suite has been changed
	 * such as when it has been installed or removed.
	 *
	 * @param __sl The listener to be added.
	 * @since 2016/06/24
	 */
	void addSuiteListener(SuiteListener __sl);
	
	/**
	 * Attempts to return an installed suite created by a specific vendor and
	 * which uses the given name.
	 *
	 * @param __vendor The vendor which created the given suite.
	 * @param __name The name of the suite.
	 * @return An instance of the given suite or {@code null} if it was not
	 * found.
	 * @since 2016/06/24
	 */
	Suite getSuite(String __vendor, String __name);
	
	/**
	 * Obtains an installer that would be used to install the given JAR file
	 * which is represented as raw byte data.
	 *
	 * The {@code {@link SWMPermission}("client", "installation")} or
	 * {@code {@link SWMPermission}("crossClient", "installation")} is checked
	 * before an installation is attempted.
	 *
	 * @param __b The raw JAR data.
	 * @param __o The offset to the start of the data.
	 * @param __l The length of the data.
	 * @param __ignuplock If {@code true} then the components of the suite
	 * will be updated without regards to synchronization, this is not
	 * recommended and {@code false} should always be used.
	 * @return An installer which represents this given installation.
	 * @throws IllegalArgumentException If the input buffer is null, empty, or
	 * the offset and length are negative or exceed the array bounds.
	 * @throws SecurityException If the current application is not permitted
	 * to install new suites.
	 * @since 2016/06/24
	 */
	SuiteInstaller getSuiteInstaller(byte[] __b, int __o, int __l,
		boolean __ignuplock)
		throws IllegalArgumentException, SecurityException;
	
	/**
	 * This attempts to install a suite which is specified at the given URL. It
	 * is implementation dependent on how the URL is handled, it may be a
	 * platform specific resource or a network resource.
	 *
	 * The {@code {@link SWMPermission}("client", "installation")} or
	 * {@code {@link SWMPermission}("crossClient", "installation")} is checked
	 * before an installation is attempted.
	 *
	 * @param __url The URL which refers to a suite to be installed.
	 * @param __ignuplock If {@code true} then the components of the suite
	 * will be updated without regards to synchronization, this is not
	 * recommended and {@code false} should always be used.
	 * @return The suite installer.
	 * @throws IllegalArgumentException If the URL is not valid or it could
	 * not be obtained.
	 * @throws SecurityException If the current application is not permitted
	 * to install new suites.
	 * @since 2016/06/24
	 */
	SuiteInstaller getSuiteInstaller(String __url, boolean __ignuplock)
		throws IllegalArgumentException, SecurityException;
	
	/**
	 * Returns a list of the suites tha are currently installed on the system.
	 *
	 * @param __t The type of suites to obtain, only
	 * {@link SuiteType#APPLICATION} and {@link SuiteType#LIBRARY} are valid.
	 * @return A list containing the suites which are currently installed,
	 * if there are no suites then this may be empty.
	 * @throws IllegalArgumentException If the requested type is neither
	 * an application or a library.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	List<Suite> getSuites(SuiteType __t)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Synchronously removes the given installed suite.
	 *
	 * Suites must be stopped before they can be used, a removal of a suite
	 * that is currently active cannot be performed.
	 *
	 * In situations where any resources of the suite are currently being used
	 * by an application, the removed suite must still make its resources
	 * accessible until all of them are released.
	 *
	 * If a suite was removed without issues then {@link Suite#isInstalled()}
	 * will return {@code false}.
	 *
	 * @param __s The suite to be removed.
	 * @param __ignuplock If {@code true} then the suite is removed regardless
	 * if it has the {@link SuiteStateFlag#REMOVE_DENIED} flag.
	 * @throws IllegalArgumentException If the suite has already been removed,
	 * or if the application is currently running and the application.
	 * @throws SuiteLockedException If the suite is locked and
	 * {@code __ignuplock} has been set to {@code false}. It should also be
	 * noted that it is possible for this to be thrown regardless of the
	 * parameter.
	 * @since 2016/06/24
	 */
	void removeSuite(Suite __s, boolean __ignuplock)
		throws IllegalArgumentException, SuiteLockedException;
	
	/**
	 * Removes a previously added suite listener so that it no longer is
	 * given any status updated when the state of a suite has changed.
	 *
	 * @param __sl The listener to remove.
	 * @since 2016/06/24
	 */
	void removeSuiteListener(SuiteListener __sl);
}

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

package javax.microedition.swm;

/**
 * This represents the state that a suite is in.
 *
 * @since 2016/06/24
 */
public enum SuiteState
{
	/** Installation failed. */
	INSTALLATION_FAILED,
	
	/** Installed. */
	INSTALLED,
	
	/** Currently being installed. */
	INSTALLING,
	
	/** Removed. */
	REMOVED,
	
	/** End. */
	;
}

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

package javax.microedition.swm;

/**
 * This represents a flag which may be associated with a suite.
 *
 * @since 2016/06/24
 */
public enum SuiteStateFlag
{
	/** Available. */
	AVAILABLE,
	
	/** Enabled, the application or library may be used. */
	ENABLED,
	
	/** The application or library is pre-installed with the system. */
	PREINSTALLED,
	
	/** Remove is not supported. */
	REMOVE_DENIED,
	
	/** A suite provided by the system. */
	SYSTEM,
	
	/** The suite cannot be updated. */
	UPDATE_DENIED,
	
	/** End. */
	;
}

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

package javax.microedition.swm;

/**
 * The type that a suite is.
 *
 * @since 2016/06/24
 */
public enum SuiteType
{
	/** An application (MIDlet). */
	APPLICATION,
	
	/** Invalid. */
	INVALID,
	
	/** A library (LIBlet). */
	LIBRARY,
	
	/** A system suite. */
	SYSTEM,
	
	/** End. */
	;
}

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

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import java.util.Objects;

/**
 * This describes a task which is currently running on the system. Each task
 * has a starting point which is a {@link javax.microedition.midlet.MIDlet}.
 *
 * System tasks cannot be started or stopped.
 *
 * @since 2016/06/24
 */
public final class Task
{
	/** The ID of the task. */
	final int _tid;
	
	/** The suite of this task. */
	final Suite _suite;
	
	/** The entry class of the task. */
	final String _entry;
	
	/**
	 * Initializes the task.
	 *
	 * @param __tid The task ID, zero is the system task.
	 * @param __s The suite used.
	 * @param __e The entry name of the task.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	Task(int __tid, Suite __s, String __e)
		throws NullPointerException
	{
		if (__s == null || __e == null)
			throw new NullPointerException("NARG");
		
		this._tid = __tid;
		this._suite = __s;
		this._entry = __e;
	}
	
	/**
	 * Checks if this task is the same as another task, tasks are equal if
	 * they share the same name.
	 *
	 * @param __o The other object.
	 * @return {@code true} if this is the same task.
	 * @since 2016/06/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Must be another task
		if (!(__o instanceof Task))
			return false;
		
		// Check
		Task o = (Task)__o;
		return Objects.equals(this.getSuite(), o.getSuite()) &&
			Objects.equals(this.getName(), o.getName());
	}
	
	/**
	 * Returns the estimated number of bytes that a task is using.
	 *
	 * @return The number of bytes the task is estimated to be using.
	 * @since 2016/06/24
	 */
	public int getHeapUse()
	{
		throw new todo.TODO();
		/*
		// Make sure the amount of memory used does not overflow ever
		long rv = this._task.metric(SystemTaskMetric.MEMORY_USED);
		if (rv < 0L)
			return 0;
		else if (rv > Integer.MAX_VALUE)
			return Integer.MAX_VALUE;
		return (int)rv;
		*/
	}
	
	/**
	 * Returns the name of the current task.
	 *
	 * @return The name of the task, system tasks always return {@code null}.
	 * @since 2016/06/24
	 */
	public String getName()
	{
		// System tasks have no name
		if (this.isSystemTask())
			return null;
		
		return this._entry;
	}
	
	/**
	 * Returns the priority of this task.
	 *
	 * @return The task priority.
	 * @since 2016/06/24
	 */
	public TaskPriority getPriority()
	{
		throw new todo.TODO();
		/*
		long rv = this._task.metric(SystemTaskMetric.PRIORITY);
		if (rv < 0L)
			return TaskPriority.MAX;
		else if (rv > 0L)
			return TaskPriority.MIN;
		return TaskPriority.NORM;
		*/
	}
	
	/**
	 * Returns the status of this task.
	 *
	 * @return The task status.
	 * @since 2016/06/24
	 */
	public TaskStatus getStatus()
	{
		// If the TID is negative then it failed to start
		int tid = this._tid;
		if (tid < 0)
			return TaskStatus.START_FAILED;
		
		return TaskStatus.__of(TaskAccess.taskStatus(tid));
	}
	
	/**
	 * Returns the suite that this task belongs to.
	 *
	 * @return The owning suite.
	 * @since 2016/06/24
	 */
	public Suite getSuite()
	{
		// All system tasks are hidden behind the system suite
		if (this.isSystemTask())
			return Suite.SYSTEM_SUITE;
		
		return this._suite;
	}
	
	/**
	 * Returns the hash code of this task, the hashcode is derived from the
	 * suite and the name.
	 *
	 * @return The hash code.
	 * @since 2016/06/24
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this.getSuite()) ^
			Objects.hashCode(this.getName());
	}
	
	/**
	 * Returns {@code true} if this is a system task.
	 *
	 * @return {@code true} if a system task.
	 * @since 2016/06/24
	 */
	public boolean isSystemTask()
	{
		// System task is always zero
		return this._tid == 0;
	}
}

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

package javax.microedition.swm;

/**
 * This is called when a task has changed status.
 *
 * @since 2016/06/24
 */
public interface TaskListener
{
	/**
	 * This is called when a task has changed status.
	 *
	 * @param __t The task which has had its status changed.
	 * @param __status The new status of the task.
	 * @since 2016/06/24
	 */
	void notifyStatusUpdate(Task __t, TaskStatus __status);
}

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

package javax.microedition.swm;

import java.util.List;

/**
 * This is an interface which is used to manage tasks. Tasks allow multiple
 * suites to be ran at the same time.
 *
 * @see ManagerFactory
 * @since 2016/06/24
 */
public interface TaskManager
{
	/**
	 * Adds the given task listener so that if the state of any task changes
	 * then the provided methods are called.
	 *
	 * @param __tl The listener for events.
	 * @since 2016/06/24
	 */
	void addTaskListener(TaskListener __tl);
	
	/**
	 * Returns the task which belongs to the caller of this method.
	 *
	 * @return The task of the current caller.
	 * @since 2016/06/24
	 */
	Task getCurrentTask();
	
	/**
	 * This returns the list of all running tasks on the system.
	 *
	 * @param __incsys If {@code true} then any tasks which are owned by the
	 * system are also returned.
	 * @return The list of tasks which currently exist within the virtual
	 * machine.
	 * @since 2016/06/24
	 */
	List<Task> getTaskList(boolean __incsys);
	
	/**
	 * Removes the given task listener so that it is no longer notified when
	 * the state of a task has changed.
	 *
	 * @param __tl The task listener to remove.
	 * @since 2016/06/24
	 */
	void removeTaskListener(TaskListener __tl);
	
	/**
	 * Sets the given task so that it appears at the foreground task which
	 * is running, this operation may fail.
	 *
	 * A task that is in the foreground is one which is visible and has
	 * input focus. It is possible that a call of this method will have no
	 * effect.
	 *
	 * @param __t The task to bring to the foreground.
	 * @return If {@code true} then the task was brought to the foreground.
	 * @throws IllegalArgumentException If the task is a system task.
	 * @since 2016/06/24
	 */
	boolean setForeground(Task __t)
		throws IllegalArgumentException;
	
	/**
	 * Attempts to set the priority of a given task. A call of this method
	 * may affect the amount of time slices which are available to a process
	 * or its resume priority in the event of cooperative multi-tasking.
	 *
	 * @param __t The task to change the priority of.
	 * @param __p The new priority of the given task.
	 * @return {@code true} if the priority of the given task has been
	 * changed.
	 * @throws IllegalArgumentException if the task is a system task.
	 * @since 2016/06/24
	 */
	boolean setPriority(Task __t, TaskPriority __p)
		throws IllegalArgumentException;
	
	/**
	 * Attempts to create a task which runs the given suite.
	 *
	 * The task is created and is initially in the {@link TaskStatus#STARTING}
	 * state. If starting fails then it enters the
	 * {@link TaskStatus#START_FAILED} state.
	 *
	 * A suite may only be active once and cannot have multiple copies running
	 * at the same time. In the event that an application is already running it
	 * must be sent an event specifying an application re-launch.
	 *
	 * @param __s The suite to start, must be an application.
	 * @param __cn The class which extends
	 * {@link javax.microedition.midlet.MIDlet} and acts as the main entry
	 * point for the program.
	 * @return The task which was created.
	 * @throws IllegalArgumentException If the suite is a library, the given
	 * class does not exist, or the given class does not extend
	 * {@link javax.microedition.midlet.MIDlet}.
	 * @throws IllegalStateException If the suite has been removed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	Task startTask(Suite __s, String __cn)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException;
	
	/**
	 * Attempts to stop the given task and destroy it so that it does not
	 * consume memory or execution cycles.
	 *
	 * @param __t The task to be stopped.
	 * @return {@code true} if the task has been stopped and destroyed.
	 * @throws IllegalArgumentException If the task has already stopped, has
	 * not yet been started, or has finished execution.
	 * @throws IllegalStateException If the task is a system task.
	 * @since 2016/06/24
	 */
	boolean stopTask(Task __t)
		throws IllegalArgumentException, IllegalStateException;
}

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

package javax.microedition.swm;

/**
 * This represents the priority of a task.
 *
 * @since 2016/06/24
 */
public enum TaskPriority
{
	/** Maximum priority. */
	MAX,
	
	/** Minimum priority. */
	MIN,
	
	/** Normal priority. */
	NORM,
	
	/** End. */
	;
}

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

package javax.microedition.swm;

/**
 * This represents the status of a task.
 *
 * @since 2016/06/24
 */
public enum TaskStatus
{
	/** Fatally exited. */
	EXITED_FATAL,
	
	/** Normal exit. */
	EXITED_REGULAR,
	
	/** Terminated. */
	EXITED_TERMINATED,
	
	/** Running. */
	RUNNING,
	
	/** Failed to start. */
	START_FAILED,
	
	/** Starting. */
	STARTING,
	
	/** End. */
	;
	
	/**
	 * Maps ordinal back into task status.
	 *
	 * @param __i Index to get.
	 * @return The task status.
	 * @since 2018/11/04
	 */
	static final TaskStatus __of(int __i)
	{
		switch (__i)
		{
			case 0: return TaskStatus.EXITED_FATAL;
			case 1: return TaskStatus.EXITED_REGULAR;
			case 2: return TaskStatus.EXITED_TERMINATED;
			case 3: return TaskStatus.RUNNING;
			case 4: return TaskStatus.START_FAILED;
			case 5: return TaskStatus.STARTING;
			
			default:
				return TaskStatus.EXITED_FATAL;
		}
	}
}

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

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.ConsoleCallback;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is a wrapper for when a task writes to its console, this will be
 * called which just forwards to the output stream specified.
 *
 * @since 2019/02/02
 */
final class __CCWrapper__
	implements ConsoleCallback
{
	/** The stream to forward to. */
	protected final OutputStream out;
	
	/**
	 * Initializes the wrapper to the given stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/02
	 */
	__CCWrapper__(OutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean close()
	{
		try
		{
			this.out.close();
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean flush()
	{
		try
		{
			this.out.flush();
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean write(byte[] __b, int __o, int __l)
	{
		try
		{
			this.out.write(__b, __o, __l);
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/__SuiteTracker__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.swm.JarStreamSupplier;
import java.util.Set;

/**
 * This performs the installation and tracks progress.
 *
 * @since 2017/12/28
 */
final class __SuiteTracker__
	extends SuiteManagementTracker
{
	/** Bytes per percent threshold. */
	private static final int _PERCENT_THRESHOLD =
		4096;
	
	/** The suite when it is installed. */
	volatile Suite _suite;
	
	/**
	 * Initializes the tracker.
	 *
	 * @param __i The owning installer.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__SuiteTracker__(SuiteInstaller __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// Setup thread which performs the actual installation
		Thread thread = new Thread(new __Runner__(this, __i),
			"SquirrelJME-Suite-Installer");
		thread.start();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/06/24
	 */
	@Override
	public Suite getSuite()
	{
		return this._suite;
	}
	
	/**
	 * This thread performs the installation.
	 *
	 * @since 2017/12/28
	 */
	private static final class __Runner__
		implements Runnable
	{
		/** The tracker which is given the suite when finished. */
		protected final __SuiteTracker__ tracker;
		
		/** The supplier for the JAR data. */
		protected final JarStreamSupplier supplier;
	
		/** Listeners for suites. */
		private final Set<SuiteInstallListener> _listeners;
		
		/**
		 * Initializes the runner.
		 *
		 * @param __tracker The tracker where the resulting suite is placed.
		 * @param __i The installer used.
		 * @throws NullPointerException On null arguments.
		 * @since 2017/12/28
		 */
		private __Runner__(__SuiteTracker__ __tracker, SuiteInstaller __i)
			throws NullPointerException
		{
			if (__tracker == null || __i == null)
				throw new NullPointerException("NARG");
			
			this.tracker = __tracker;
			this.supplier = __i._supplier;
			this._listeners = __i._listeners;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public void run()
		{
			try
			{
				throw new todo.TODO();
				/*
				// Read the JAR data stream 
				byte[] data;
				__update(SuiteInstallStage.DOWNLOAD_DATA, 0);
				try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
					InputStream is = this.supplier.get())
				{
					// Read in source data
					byte[] buf = new byte[512];
					for (int count = 0, last = 0;;)
					{
						int rc = is.read(buf);
					
						if (rc < 0)
							break;
					
						baos.write(buf, 0, rc);
					
						// Update progress for the first initial set of blocks
						if (last < 99)
						{
							count += rc;
							int now = count / _PERCENT_THRESHOLD;
							if (last != now && now <= 99)
							{
								__update(SuiteInstallStage.DOWNLOAD_DATA, now);
								last = now;
							}
						}
					}
				
					// Get the entire data buffer
					baos.flush();
					data = baos.toByteArray();
				}
			
				// Could not read the JAR
				catch (IOException e)
				{
					__done(InstallErrorCodes.IO_FILE_ERROR);
					return;
				}
				__update(SuiteInstallStage.DOWNLOAD_DATA, 100);
				
				// Need the library manager
				__SystemSuiteManager__ ssm =
					(__SystemSuiteManager__)ManagerFactory.getSuiteManager();
				LibrariesClient manager = ssm._manager;
			
				// Send it to the kernel
				__update(SuiteInstallStage.VERIFYING, 0);
				LibraryInstallationReport report = manager.install(
					data, 0, data.length);
			
				// Failed
				int error = report.error();
				if (error != 0)
				{
					// Determine the error code
					error--;
					InstallErrorCodes[] codes = InstallErrorCodes.values();
					InstallErrorCodes code = (error >= 0 &&
						error < codes.length ? codes[error] :
						InstallErrorCodes.OTHER_ERROR);
					
					// This will be the only chance to print the installation
					// report
					// {@squirreljme.error DG0t Failed to install the program
					// due to the specified error. (The error code; The more
					// detailed message associated with the error)}
					System.err.printf("DG0t %s %s%n", code, report.message());
					
					// Mark as done
					__done(code);
					return;
				}
			
				// Set the suite used
				this.tracker._suite = new Suite(report.library());
			
				// Did not fail, but report it anyway
				__update(SuiteInstallStage.VERIFYING, 100);
			
				// Finished
				__update(SuiteInstallStage.DONE, 100);
				__done(InstallErrorCodes.NO_ERROR);
				*/
			}
			
			// Oops
			catch (Throwable t)
			{
				// Just print the trace
				t.printStackTrace();
				
				// And use some other error code to indicate failure 
				this.__done(InstallErrorCodes.OTHER_ERROR);
			}
		}
		
		/**
		 * Called when installation has finished, potentially with an error.
		 *
		 * @param __code The error code.
		 * @since 2017/12/28
		 */
		private void __done(InstallErrorCodes __code)
		{
			__SuiteTracker__ tracker = this.tracker;
			for (SuiteInstallListener l : this._listeners)
				try
				{
					l.installationDone(__code, tracker);
				}
				catch (Exception e)
				{
				}
		}
		
		/**
		 * Updates the current install stage.
		 *
		 * @param __stage The current installation stage.
		 * @param __pct The percentage complete.
		 * @since 2017/12/28
		 */
		private void __update(SuiteInstallStage __stage, int __pct)
		{
			__SuiteTracker__ tracker = this.tracker;
			for (SuiteInstallListener l : this._listeners)
				try
				{
					l.updateStatus(tracker, __stage, __pct);
				}
				catch (Exception e)
				{
				}
		}
	}
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/__SystemSuiteManager__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.swm.ByteArrayJarStreamSupplier;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.InvalidSuiteException;
import cc.squirreljme.runtime.swm.MatchResult;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * This class manages the bridge for the suite manager to the native program
 * manager.
 *
 * @since 2017/12/08
 */
final class __SystemSuiteManager__
	implements SuiteManager
{
	/** Cache of suites which are available. */
	private static final Map<String, Suite> _SUITES =
		new HashMap<>();
	
	/** Internal lock for suite management. */
	protected final Object lock =
		new Object();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void addSuiteListener(SuiteListener __sl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public Suite getSuite(String __vendor, String __name)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public SuiteInstaller getSuiteInstaller(byte[] __b, int __o,
		int __l, boolean __ignuplock)
		throws IllegalArgumentException, SecurityException
	{
		return new SuiteInstaller(
			new ByteArrayJarStreamSupplier(__b, __o, __l));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public SuiteInstaller getSuiteInstaller(String __url,
		boolean __ignuplock)
		throws IllegalArgumentException, SecurityException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public List<Suite> getSuites(SuiteType __t)
		throws IllegalArgumentException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Go through suites and find suites to return
		List<Suite> rv = new ArrayList<>();
		for (Suite s : __SystemSuiteManager__.__allSuites())
			if (s.getSuiteType() == __t)
				rv.add(s);
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void removeSuite(Suite __s, boolean __ignuplock)
		throws IllegalArgumentException, SuiteLockedException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void removeSuiteListener(SuiteListener __sl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns all of the suites which are available.
	 *
	 * @return All of the available suites.
	 * @since 2018/10/30
	 */
	static List<Suite> __allSuites()
	{
		// Just get every suite
		List<Suite> rv = new ArrayList<>();
		for (String as : SuiteAccess.availableSuites())
		{
			// It is possible they might not load
			Suite s = __SystemSuiteManager__.__getSuite(as);
			if (s != null)
				rv.add(s);
		}
		
		return rv;
	}
	
	/**
	 * Gets the specified suite.
	 *
	 * @param __s The suite to get.
	 * @return The suite for the given name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/26
	 */
	static Suite __getSuite(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, Suite> suites = __SystemSuiteManager__._SUITES;
		synchronized (suites)
		{
			// Preloaded?
			Suite rv = suites.get(__s);
			if (rv != null)
				return rv;
			
			// Previously did not exist or failed to load
			if (suites.containsKey(__s))
				return null;
			
			try
			{
				// Cache the suite
				suites.put(__s, (rv = new Suite(__s)));
				return rv;
			}
			catch (InvalidSuiteException e)
			{
				// Debug it
				e.printStackTrace();
				
				// Just cache it as invalid
				suites.put(__s, null);
				return null;
			}
		}
	}
	
	/**
	 * Returns the suites which match the given dependency set.
	 *
	 * This is copied from the SquirrelJME build system.
	 *
	 * @param __set The set of dependencies to get.
	 * @param __opt If {@code true} include optional dependencies.
	 * @return Suites which statisfy the given dependencies.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/02
	 */
	static Suite[] __matchDependencies(DependencyInfo __set, boolean __opt)
		throws NullPointerException
	{
		if (__set == null)
			throw new NullPointerException("NARG");
		
		// Clear all optionals if they are not included
		if (!__opt)
			__set = __set.noOptionals();
		
		// No dependencies to search for
		if (__set.isEmpty())
			return new Suite[0];
		
		// Remember the original set for recursive dependency checks
		DependencyInfo original = __set;
		
		// The returning set
		Set<Suite> rv = new LinkedHashSet<>();
		
		// Go through all binaries and attempt to match
		for (Suite bin : __SystemSuiteManager__.__allSuites())
		{
			// Only consider matches
			MatchResult result = bin.__matchedDependencies(__set);
			if (!result.hasMatches())
				continue;
			
			// Use this as a dependency
			rv.add(bin);
			
			// Recursively go down
			for (Suite sub : __SystemSuiteManager__.__matchDependencies(
				bin.__suiteInfo().dependencies(), false))
				rv.add(sub);
			
			// Use remaining unmatched set
			__set = result.unmatched();
			
			// If the set was emptied then it will never have any more matches
			if (__set.isEmpty())
				break;
		}
		
		// {@squirreljme.error DG0u Could not locate the suite which
		// statifies the given dependency. (The dependency to look for)}
		if (rv.isEmpty())
			throw new RuntimeException(
				String.format("DG0u %s", __set));
		
		return rv.<Suite>toArray(new Suite[rv.size()]);
	}
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/__SystemTaskManager__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.swm.ExtendedTaskManager;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * This is the task manager which interfaces with the CLDC system support
 * methods to provide access to tasks and such.
 *
 * @since 2017/12/07
 */
final class __SystemTaskManager__
	implements ExtendedTaskManager, TaskManager
{
	/** Mapping of task IDs to tasks. */
	static final Map<Integer, Task> _TASKS =
		new HashMap<>();
	
	/** Internal lock for chore management. */
	protected final Object lock =
		new Object();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public void addTaskListener(TaskListener __tl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public Task getCurrentTask()
	{
		throw new todo.TODO();
		/*
		return this.__byId(APIAccessor.chores().currentId());
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public List<Task> getTaskList(boolean __incsys)
	{
		throw new todo.TODO();
		/*
		// Lock so that the task list is always up to date
		Task[] rv;
		synchronized (this.lock)
		{
			IntegerArray tids = SystemCall.EASY.taskList(__incsys);
			int n = tids.length();
			
			// Wrap all the tasks
			rv = new Task[n];
			for (int i = 0; i < n; i++)
				rv[i] = this.__ofTask(new WrappedTask(tids.get(i)));
		}
		
		// Wrap array instead of creating a new list for speed
		return Arrays.<Task>asList(rv);
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public void removeTaskListener(TaskListener __tl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean setForeground(Task __t)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean setPriority(Task __t, TaskPriority __p)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public Task startTask(Suite __s, String __cn)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		// Forward to the extended task start
		return this.startTask(__s, __cn, null, null, null, null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final Task startTask(Suite __s, String __cn,
		Map<String, String> __sprops, String[] __args, OutputStream __stdout,
		OutputStream __stderr)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__s == null || __cn == null)
			throw new NullPointerException("NARG");
		
		// Defensive copies
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// Make sure values are actually valid
		for (int i = 0, n = __args.length; i < n; i++)
			if (__args[i] == null)
				throw new NullPointerException("NARG");
		for (Map.Entry<String, String> e : __sprops.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			if (k == null || v == null)
				throw new NullPointerException("NARG");
		}
		
		// {@squirreljme.error DG0v Cannot start a non-application suite.}
		if (__s.getSuiteType() != SuiteType.APPLICATION)
			throw new IllegalArgumentException("DG0v");
		
		// Get all the suites that are available, since we need to determine
		// dependencies and such
		List<Suite> all = __SystemSuiteManager__.__allSuites();
		
		// Determine the suites which need to be loaded into the classpath
		// in order to run the given suite
		Suite[] depends = __SystemSuiteManager__.__matchDependencies(
			__s.__suiteInfo().dependencies(), false);
		
		// Load suite names since we need to build the class path
		int n = depends.length;
		String[] names = new String[n + 1];
		for (int i = 0; i < n; i++)
			names[i] = depends[i]._name;
		
		// Add our boot suite to the last entry
		names[n] = __s._name;
		
		// Debug
		todo.DEBUG.note("Suites: %s", Arrays.<String>asList(names));
		
		// SquirrelJME 0.3.0 allows system properties and alternative output
		// streams to be specified as well
		int tid;
		if (ApiLevel.minimumLevel(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV))
		{
			// Copy system properties to key/value pair array
			int spn = __sprops.size();
			String[] xprops = new String[spn * 2];
			Iterator<Map.Entry<String, String>> eit = __sprops.entrySet().
				iterator();
			for (int i = 0, o = 0; i < spn; i++, o += 2)
			{
				Map.Entry<String, String> e = eit.next();
				
				xprops[o] = e.getKey();
				xprops[o + 1] = e.getValue();
			}
			
			// Forward launch
			tid = TaskAccess.startTask(names, __cn, __args, xprops,
				(__stdout == null ? null : new __CCWrapper__(__stdout)),
				(__stderr == null ? null : new __CCWrapper__(__stderr)));
		}
		else
			tid = TaskAccess.startTask(names, __cn, __args);
		
		// It did not work
		if (tid < 0)
		{
			// {@squirreljme.error DG0w Invalid entry point was specified
			// when starting task. (The entry point)}
			if (tid == TaskAccess.ERROR_INVALID_ENTRY)
				throw new IllegalArgumentException("DG0w " + __cn);
			
			// {@squirreljme.error DG0x Could not launch the task because of
			// an unspecified error. (The error)}
			throw new IllegalArgumentException("DG0x " + tid);
		}
		
		// Debug
		todo.DEBUG.note("Created task with TID %d", tid);
		
		// Otherwise use cached form
		return this.__getTask(tid, __s, __cn);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean stopTask(Task __t)
		throws IllegalArgumentException, IllegalStateException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a task mapped to the given ID.
	 *
	 * @param __tid The task ID.
	 * @param __s The suite used.
	 * @param __n The starting class of the task, gives its name.
	 * @return The task for the task.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	static final Task __getTask(int __tid, Suite __s, String __n)
		throws NullPointerException
	{
		if (__s == null || __n == null)
			throw new NullPointerException("NARG");
		
		// Lock on the tasks
		Map<Integer, Task> tasks = __SystemTaskManager__._TASKS;
		synchronized (tasks)
		{
			// There should not be duplicates
			Integer k = __tid;
			Task rv = tasks.get(k);
			if (rv != null)
				throw new todo.OOPS();
			
			tasks.put(k, (rv = new Task(__tid, __s, __n)));
			return rv;
		}
	}
}

Added modules/meep-swm/src/main/java/javax/microedition/swm/package-info.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the suite and task managers. Suites are applications
 * which may be launched and represented as tasks. This essentially permits
 * multiple applications to run at the same time.
 *
 * @since 2016/06/24
 */

package javax.microedition.swm;

Added modules/midp-lcdui/build.gradle.




























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEStandard

description = "This contains the standard MIDP LCD User " +
 "Interface which uses graphical text, widgets, and images to interact " +
 "with the user. Unlike the MEEP Line User Interface, this requires a " +
 "much more capable graphical system."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EB"
	swmType = JavaMEMidletType.API
	swmName = "LCD UI"
	swmVendor = "Stephanie Gawroriski"
	definedStandards += new JavaMEStandard("microedition.lcdui;;")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-midlet")
	implementation project(":modules:gcf")
	implementation project(":modules:io")
	implementation project(":modules:collections")
}

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

package cc.squirreljme.runtime.lcdui;

/**
 * This represents the state of the display hardware.
 *
 * @since 2017/10/01
 */
public enum DisplayHardwareState
{
	/** Enabled. */
	ENABLED,
	
	/** Disabled. */
	DISABLED,
	
	/** Removed. */
	ABSENT,
	
	/** End. */
	;
	
	/**
	 * Is this forced to be disabled?
	 *
	 * @return If this is forced to be disabled.
	 * @since 2017/10/01
	 */
	public final boolean forceDisabled()
	{
		return this == DisplayHardwareState.DISABLED || this == DisplayHardwareState.ABSENT;
	}
}

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

package cc.squirreljme.runtime.lcdui;

import javax.microedition.lcdui.Display;

/**
 * This is used to determine the orientation of the display.
 *
 * @since 2017/10/27
 */
public enum DisplayOrientation
{
	/** Landscape. */
	LANDSCAPE,
	
	/** Landscape, rotated 180 degrees. */
	LANDSCAPE_180,
	
	/** Portrait. */
	PORTRAIT,
	
	/** Portrait, rotated 180 degrees. */
	PORTRAIT_180,
	
	/** End. */
	;
	
	/**
	 * Returns the value used in the LCDUI code.
	 *
	 * @return The LCDUI value.
	 * @since 2017/10/27
	 */
	public final int lcduiValue()
	{
		switch (this)
		{
			case LANDSCAPE:		return Display.ORIENTATION_LANDSCAPE;
			case LANDSCAPE_180:	return Display.ORIENTATION_LANDSCAPE_180;
			case PORTRAIT:		return Display.ORIENTATION_PORTRAIT;
			case PORTRAIT_180:	return Display.ORIENTATION_PORTRAIT_180;
			default:
				throw new todo.OOPS();
		}
	}
}

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

package cc.squirreljme.runtime.lcdui;

/**
 * This is the display state used for displays.
 *
 * @since 2017/05/24
 */
public enum DisplayState
{
	/** The background state. */
	BACKGROUND,
	
	/** The foregound state. */
	FOREGROUND,
	
	/** End. */
	;
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/ExtendedCapabilities.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui;

/**
 * Represents extended capabilities of the display.
 *
 * @since 2019/05/05
 */
public interface ExtendedCapabilities
{
	/** Does this support pointer events? */
	int SUPPORTS_POINTER_EVENTS =
		0x4000_0000;
}

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

package cc.squirreljme.runtime.lcdui;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation is used to specify that the given method is serialized and
 * will never be called in parallel ever by the LCDUI display driver.
 *
 * @since 2017/08/19
 */
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD})
public @interface SerializedEvent
{
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/CharSequenceDecoder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * This class is used to decode character sequences so that it is known which
 * parts of characters are what and which codepoints are to be attached to
 * text.
 *
 * @since 2017/10/21
 */
public final class CharSequenceDecoder
{
	/** The sequence to source from. */
	protected final CharSequence sequence;
	
	/** The position to end at. */
	protected final int end;
	
	/** The current marker position. */
	private volatile int _at;
	
	/** The next detail. */
	private volatile DecodedCharacter _next;
	
	/**
	 * Initializes the decoder for the given character sequence.
	 *
	 * @param __s The sequence to decode.
	 * @param __o The offset into the sequence.
	 * @param __l The number of characters to decode.
	 * @throws IndexOutOfBoundsException If the sequence is out of bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/21
	 */
	public CharSequenceDecoder(CharSequence __s, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Must be in bounds
		int sn = __s.length(),
			end = __o + __l;
		if (__o < 0 || __l < 0 || (end > sn))
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		this.sequence = __s;
		this.end = end;
		this._at = __o;
	}
	
	/**
	 * Returns the next codepoint that is at the base of the sequence in
	 * that it is the most important character.
	 *
	 * @return The next codepoint or {@code -1} if there are no more code
	 * points remaining.
	 * @since 2017/10/21
	 */
	public DecodedCharacter next()
	{
		// Peek first always
		this.peek();
		
		// Has been read already?
		DecodedCharacter rv = this._next;
		if (rv != null)
		{
			this._next = null;
			return rv;
		}
		
		// No more characters left
		return null;
	}
	
	/**
	 * This returns the character which follows the next character.
	 *
	 * @return The character which follows the next character or {@code null}
	 * if there is no next character.
	 * @since 2017/10/24
	 */
	public DecodedCharacter peek()
	{
		// Already peeked?
		DecodedCharacter rv = this._next;
		if (rv != null)
			return rv;
		
		// Detect no more characters
		int at = this._at,
			end = this.end;
		if (at >= end)
			return null;
		
		// Read the next codepoint
		CharSequence sequence = this.sequence;
		int codepoint = sequence.charAt(at);
		this._at = at + 1;
		
		// Build information
		rv = new DecodedCharacter(codepoint);
		this._next = rv;
		return rv;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/CommonColors.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * Common widget colors.
 *
 * @since 2018/12/02
 */
public interface CommonColors
{
	/** Default text color. */
	int DEFAULT_TEXT_COLOR =
		0xFF_000000;
	
	/** Default text background color. */
	int DEFAULT_TEXT_BACKGROUND_COLOR =
		0x00_FFFFFF;
	
	/** Border color. */
	int BORDER =
		0xFF_000000;
	
	/** Background color. */
	int BACKGROUND =
		0xFF_FFFFFF;
	
	/** Foreground color. */
	int FOREGROUND =
		0xFF_000000;
	
	/** Disabled background. */
	int DISABLED_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Disabled foreground. */
	int DISABLED_FOREGROUND =
		0xFF_3C3C3C;
	
	/** Highlighted border. */
	int HIGHLIGHTED_BORDER =
		0xFF_0000FF;
	
	/** Highlighted background. */
	int HIGHLIGHTED_BACKGROUND =
		0xFF_000080;
	
	/** Highlighted foreground. */
	int HIGHLIGHTED_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Disabled Highlighted background. */
	int DISABLED_HIGHLIGHTED_BORDER =
		0xFF_000000;
	
	/** Disabled Highlighted background. */
	int DISABLED_HIGHLIGHTED_BACKGROUND =
		0xFF_3C3C3C;
	
	/** Disabled Highlighted foreground. */
	int DISABLED_HIGHLIGHTED_FOREGROUND =
		0xFF_9C9C9C;
	
	/** Canvas background. */
	int CANVAS_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Command bar background. */
	int COMMANDBAR_BACKGROUND =
		0xFF_000000;
	
	/** Command bar foreground. */
	int COMMANDBAR_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Focused item color. */
	int FOCUSED_COLOR =
		0xFF_FFFF00;
	
	/** Secondary focused item color. */
	int FOCUSED_COLOR_TWO =
		0xFF_FF00FF;
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/CommonMetrics.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * Common widget metrics.
 *
 * @since 2018/12/02
 */
@Deprecated
public interface CommonMetrics
{
	/** Width of the scroll bar. */
	@Deprecated
	int SCROLLBAR_WIDTH =
		8;
	
	/** Command bar height. */
	@Deprecated
	int COMMANDBAR_HEIGHT =
		18;
	
	/** Command bar font size. */
	@Deprecated
	int COMMANDBAR_FONT_SIZE =
		16;
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/DecodedCharacter.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * This contains structured information on a character which has been
 * decoded. This is used for font rendering.
 *
 * @since 2017/10/24
 */
public final class DecodedCharacter
{
	/** The primary and visible codepoint. */
	public final int codepoint;
	
	/**
	 * Initializes the decoded character.
	 *
	 * @param __cp The code point of the character.
	 * @since 2017/10/24
	 */
	public DecodedCharacter(int __cp)
	{
		this.codepoint = __cp;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/EditableText.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

import javax.microedition.lcdui.TextField;

/**
 * This class is used to manage text, it manages the caret position.
 *
 * The maximum size for a text field may never be zero or less than that.
 *
 * All locks are performed on the current object.
 *
 * @see javax.microedition.lcdui.TextBox
 * @see javax.microedition.lcdui.TextEditor
 * @see javax.microedition.lcdui.TextField
 * @since 2017/10/20
 */
public final class EditableText
{
	/** The maximum constraint number. */
	private static final int _MAX_CONSTRAINT =
		TextField.CURRENCY;
	
	/** The valid constraint flag bits. */
	private static final int _VALID_CONSTRAINT_FLAG_BITS =
		TextField.INITIAL_CAPS_SENTENCE | TextField.INITIAL_CAPS_WORD |
		TextField.NON_PREDICTIVE | TextField.PASSWORD |
		TextField.SENSITIVE | TextField.UNEDITABLE;
	
	/** Internal lock for text thread safety. */
	protected final Object lock =
		new Object();
	
	/** The text contained within the field. */
	private final StringBuilder _value =
		new StringBuilder();
	
	/** The maximum length of the text field. */
	private volatile int _maxlength =
		Integer.MAX_VALUE;
	
	/** The current constraints. */
	private volatile int _constraints;
	
	/**
	 * Initializes the text field by setting every parameter at once.
	 *
	 * If the implementation does not support the specified number of
	 * characters then the input string will be truncated and no exception
	 * will be thrown provided the input is still valid.
	 *
	 * @param __t The text to initially set the field to,
	 * see {@link #setString(String)}.
	 * @param __ms The maximum amount of characters in the field,
	 * see {@link #setMaxSize(int)}.
	 * @param __c The constraints of the field,
	 * see {@link #setConstraints(int)}.
	 * @throws IllegalArgumentException If the maximum size is zero or less;
	 * the constraints is not valid; the text is not valid; or the text
	 * exceeds the maximum specified characters.
	 * @since 2017/10/20
	 */
	public void initialize(String __t, int __ms, int __c)
		throws IllegalArgumentException
	{
		// Lock
		synchronized (this.lock)
		{
			// Size and constraints are set first to make sure the string is
			// valid
			int n = this.setMaxSize(__ms);
			this.setConstraints(__c);
		
			// Set the string which validates the input
			// However if the constraints are smaller for the implementation
			// then no exception is thrown (just give the truncated string)
			if (__t != null)
				this.setString((n < __c ? __t.substring(0, n) : __t));
		}
	}
	
	/**
	 * Sets the constraints for this field according to the constraints which
	 * are available. If the current value is not valid under the constraints
	 * to be set then it is cleared.
	 *
	 * @param __c The constraints to set.
	 * @throws IllegalArgumentException If the input constraints are not
	 * valid.
	 * @since 2017/08/20
	 */
	public void setConstraints(int __c)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB01 The specified constraint type is not
		// valid. (The type)}
		int type = (__c & TextField.CONSTRAINT_MASK);
		if (type < 0 || type > EditableText._MAX_CONSTRAINT)
			throw new IllegalArgumentException(String.format("EB01 %d", type));
		
		// {@squirreljme.error EB02 The specified constraint flags are not
		// valid. (The constraint flags)}
		if (((__c ^ type) & ~EditableText._VALID_CONSTRAINT_FLAG_BITS) != 0)
			throw new IllegalArgumentException(String.format("EB02 %04x",
				__c >>> 16));
		
		// Lock
		synchronized (this.lock)
		{
			// If the new constraints are not valid then any previous text
			// is cleared
			StringBuilder value = this._value;
			if (!EditableText.__check(value, this._maxlength, __c))
			{
				value.setLength(0);
				return;
			}
			
			// Set
			this._constraints = __c;
		}
	}
	
	/**
	 * Sets the maximum size of the text field, if the value is larger than
	 * this value then it will be truncated.
	 *
	 * @param __ms The number of characters that can be placed in the field.
	 * @return The actual maximum capacity, this may be smaller than the
	 * input value.
	 * @throws IllegalArgumentException If the maximum size is not a non-zero
	 * positive value or if the value would not be valid after truncation if
	 * constraints are used.
	 * @since 2017/08/19
	 */
	public int setMaxSize(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB03 The maximum characters in the text field
		// cannot be zero or negative. (The maximum characters)}
		if (__ms <= 0)
			throw new IllegalArgumentException(String.format("EB03 %d", __ms));
		
		// Lock
		synchronized (this.lock)
		{
			// {@squirreljme.error EB04 Cannot set the maximum size because the
			// input text field would have an invalid value.}
			if (!EditableText.__check(this._value, __ms, this._constraints))
				throw new IllegalArgumentException("EB04");
		
			// Set, SquirrelJME does not have a fixed limit on the size of text
			// fields
			this._maxlength = __ms;
			return __ms;
		}
	}
	
	/**
	 * Sets the value of the text field.
	 *
	 * @param __s The value to set, if {@code null} then an empty string is
	 * used.
	 * @throws IllegalArgumentException If the input string is not within
	 * the constraints or character count limitations.
	 * @since 2017/08/20
	 */
	public void setString(String __s)
		throws IllegalArgumentException
	{
		// Null becomes empty
		if (__s == null)
			__s = "";
		
		// Lock
		synchronized (this.lock)
		{
			// {@squirreljme.error EB05 Cannot set the specified string
			// because it is not valid within the constraints.}
			if (!EditableText.__check(__s, this._maxlength, this._constraints))
				throw new IllegalArgumentException("EB05");
			
			// Set value
			StringBuilder value = this._value;
			value.setLength(0);
			value.append(__s);
		}
	}
	
	/**
	 * This checks the given sequence to make sure it is within the
	 * specified constraints.
	 *
	 * @param __cs The sequence to check.
	 * @param __ms The maximum number of characters to check.
	 * @param __c The constraints specifications.
	 * @return Whether or not the data is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	private static boolean __check(CharSequence __cs, int __ms, int __c)
		throws NullPointerException
	{
		// Check
		if (__cs == null)
			throw new NullPointerException("NARG");
		
		// No constraints used or the input string is empty
		// Empty strings are always valid because otherwise constructing
		// objects would always fail with illegal values
		int type = (__c & TextField.CONSTRAINT_MASK),
			n = __cs.length();
		if (type == TextField.ANY || n == 0)
			return true;
		
		// Depends on the type
		switch (type)
		{
				// Decimal value
			case TextField.CURRENCY:
			case TextField.DECIMAL:
				try
				{
					Double.valueOf(__cs.toString());
					return true;
				}
				catch (NumberFormatException e)
				{
					return false;
				}
				
				// Integer values only
			case TextField.NUMERIC:
				try
				{
					Integer.parseInt(__cs.toString());
					return true;
				}
				catch (NumberFormatException e)
				{
					return false;
				}
				
				// E-mail addresses and URLs allow everything
			case TextField.EMAILADDR:
			case TextField.URL:
				return true;
			
				// Unknown
			default:
				throw new todo.TODO();
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/TextStorage.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.common;

import java.util.Arrays;
import javax.microedition.lcdui.Font;

/**
 * Manages the storage for the text in multiple different arrays at once
 * for simplicity.
 *
 * @since 2018/11/30
 */
public final class TextStorage
{
	/** The number of characters to grow at a time. */
	public static final int GROWTH =
		16;
	
	/** Character storage. */
	public char[] chars =
		new char[0];
	
	/** Font storage. */
	public Font[] font =
		new Font[0];
	
	/** Color storage, zero is use default. */
	public int[] color =
		new int[0];
	
	/** X position. */
	public short[] x =
		new short[0];
	
	/** Y position. */
	public short[] y =
		new short[0];
	
	/** The number of stored characters and their attributes. */
	public int size;
	
	/** The limit of the arrays. */
	public int limit;
	
	/**
	 * Deletes space at the given index.
	 *
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the deletion index is out
	 * of bounds.
	 * @since 2018/12/02
	 */
	public final void delete(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Check bounds
		int size = this.size;
		if (__i < 0 || __i > size || __l < 0 || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Storage areas
		char[] chars = this.chars;
		Font[] font = this.font;
		int[] color = this.color;
		
		// Determine the new size
		int newsize = size - __l;
		
		// Move everything down from the higher point
		for (int o = __i, eo = __i + __l, i = eo; o < eo && i < size;
			o++, i++)
		{
			chars[o] = chars[i];
			font[o] = font[i];
			color[o] = color[i];
		}
		
		// Set new size
		this.size = newsize;
	}
	
	/**
	 * Inserts space to store the given length at the given index.
	 *
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the insertion index is negative
	 * or exceeds the size of the storage, or if the length is negative.
	 * @since 2018/11/30
	 */
	public final void insert(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		int size = this.size;
		if (__i < 0 || __i > size || __l < 0)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Storage areas
		char[] chars = this.chars;
		Font[] font = this.font;
		int[] color = this.color;
		short[] x = this.x;
		short[] y = this.y;
		
		// Need to grow the buffer?
		int newsize = size + __l,
			limit = this.limit;
		if (newsize > limit)
		{
			// Calculate a new limit with some extra room
			int newlimit = newsize + TextStorage.GROWTH;
			
			// Resize all the arrays
			this.chars = (chars = Arrays.copyOf(chars, newlimit));
			this.font = (font = Arrays.<Font>copyOf(font, newlimit));
			this.color = (color = Arrays.copyOf(color, newlimit));
			this.x = (x = Arrays.copyOf(x, newlimit));
			this.y = (y = Arrays.copyOf(y, newlimit));
			
			// Set new limit
			this.limit = (limit = newlimit);
		}
		
		// Move over all the entries to the index to make room for this
		// start from the very right end
		// X and Y are resized but their values are not moved around
		// because the insertion of new elements makes things dirty and
		// all of the X and Y values would be invalidated anyway
		for (int o = newsize - 1, i = size - 1; i >= __i; o--, i--)
		{
			chars[o] = chars[i];
			font[o] = font[i];
			color[o] = color[i];
		}
		
		// Set new size
		this.size = newsize;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/common/package-info.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This class contains common implementations of some LCDUI widgets which
 * some will share much of the same code. This eases documentation and has it
 * where less code is duplicated.
 *
 * @since 2017/10/20
 */

package cc.squirreljme.runtime.lcdui.common;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/event/EventTranslate.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

import javax.microedition.lcdui.Canvas;

/**
 * Used to translate key events and such.
 *
 * @since 2018/12/09
 */
public final class EventTranslate
{
	/**
	 * Not used.
	 *
	 * @since 2018/12/09
	 */
	private EventTranslate()
	{
	}
	
	/**
	 * Converts the given game action to a key code.
	 *
	 * @param __gc The game action to convert.
	 * @return The resulting key code or {@code 0} if the game action is not
	 * valid.
	 * @since 2019/04/14
	 */
	public static final int gameActionToKeyCode(int __gc)
	{
		// This performs the reverse of keyCodeToGameAction() except that
		// it maps game keys back to associated number keys.
		// [A ^ B] > [1 2 3]
		// [< F >] > [4 5 6]
		// [C v D] > [7 8 9]
		// [* 0 #] > [* 0 #]
		switch (__gc)
		{
			case Canvas.GAME_A:	return Canvas.KEY_NUM1;
			case Canvas.UP:		return Canvas.KEY_NUM2;
			case Canvas.GAME_B:	return Canvas.KEY_NUM3;
			case Canvas.LEFT:	return Canvas.KEY_NUM4;
			case Canvas.FIRE:	return Canvas.KEY_NUM5;
			case Canvas.RIGHT:	return Canvas.KEY_NUM6;
			case Canvas.GAME_C:	return Canvas.KEY_NUM7;
			case Canvas.DOWN:	return Canvas.KEY_NUM8;
			case Canvas.GAME_D:	return Canvas.KEY_NUM9;
		}
		
		return 0;
	}
	
	/**
	 * Converts the key code to a game action.
	 *
	 * @param __kc The key code.
	 * @return The game action or {@code 0} if it is not valid.
	 * @since 2018/12/09
	 */
	public static final int keyCodeToGameAction(int __kc)
	{
		// Game actions are mapped to physical keys such as left/right/up/down
		// and select. Also since some phones only have a dial pad this means
		// that game actions take up actual digits on the phone itself, so
		// this means we have to map those accordingly.
		// [1 2 3] > [A ^ B]
		// [4 5 6] > [< F >]
		// [7 8 9] > [C v D]
		// [* 0 #] > [* 0 #]
		switch (__kc)
		{
				// Map these to game keys using number pad layout
			case Canvas.KEY_NUM1:	return Canvas.GAME_A;
			case Canvas.KEY_NUM2:	return Canvas.UP;
			case Canvas.KEY_NUM3:	return Canvas.GAME_B;
			case Canvas.KEY_NUM4:	return Canvas.LEFT;
			case Canvas.KEY_NUM5:	return Canvas.FIRE;
			case Canvas.KEY_NUM6:	return Canvas.RIGHT;
			case Canvas.KEY_NUM7:	return Canvas.GAME_C;
			case Canvas.KEY_NUM8:	return Canvas.DOWN;
			case Canvas.KEY_NUM9:	return Canvas.GAME_D;
			
				// Arrow keys map to their direct game keys
			case Canvas.KEY_UP:		return Canvas.UP;
			case Canvas.KEY_DOWN:	return Canvas.DOWN;
			case Canvas.KEY_LEFT:	return Canvas.LEFT;
			case Canvas.KEY_RIGHT:	return Canvas.RIGHT;
			
				// Map space bar and enter to fire
			case ' ':
			case '\n':			return Canvas.FIRE;
			
				// Virtually mapped game keys, likely from a VM running on top
			case NonStandardKey.VGAME_UP:		return Canvas.UP;
			case NonStandardKey.VGAME_DOWN:		return Canvas.DOWN;
			case NonStandardKey.VGAME_LEFT:		return Canvas.LEFT;
			case NonStandardKey.VGAME_RIGHT:	return Canvas.RIGHT;
			case NonStandardKey.VGAME_FIRE:		return Canvas.FIRE;
			case NonStandardKey.VGAME_A:		return Canvas.GAME_A;
			case NonStandardKey.VGAME_B:		return Canvas.GAME_B;
			case NonStandardKey.VGAME_C:		return Canvas.GAME_C;
			case NonStandardKey.VGAME_D:		return Canvas.GAME_D;
			
				// Invalid
			default:
				return 0;
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/event/KeyNames.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

import javax.microedition.lcdui.Canvas;

/**
 * This is used to translate key codes into key names.
 *
 * @since 2017/02/12
 */
public final class KeyNames
{
	/**
	 * Not used.
	 *
	 * @since 2017/02/12
	 */
	private KeyNames()
	{
	}
	
	/**
	 * Returns the name of the given key.
	 *
	 * @param __c The keycode to get the name for.
	 * @return The name of the key.
	 * @throws IllegalArgumentException If the key is not valid.
	 * @since 2017/02/12
	 */
	public static String getKeyName(int __c)
		throws IllegalArgumentException
	{
		switch (__c)
		{
				// Unknown
			case NonStandardKey.UNKNOWN:	return "Unknown";
			
				// More friendly names
			case Canvas.KEY_BACKSPACE:		return "Backspace";
			case Canvas.KEY_DELETE:			return "Delete";
			case Canvas.KEY_DOWN:			return "Down";
			case Canvas.KEY_ENTER:			return "Enter";
			case Canvas.KEY_ESCAPE:			return "Escape";
			case Canvas.KEY_LEFT:			return "Left";
			case Canvas.KEY_RIGHT:			return "Right";
			case Canvas.KEY_SELECT:			return "Select";
			case Canvas.KEY_SPACE:			return "Space";
			case Canvas.KEY_TAB:			return "Tab";
			case Canvas.KEY_UP:				return "Up";
			
				// Dial keys
			case Canvas.KEY_STAR:			return "Star";
			case Canvas.KEY_POUND:			return "Pound";
			
				// Other keys
			case NonStandardKey.ALT:		return "Alt";
			case NonStandardKey.CAPSLOCK:	return "CapsLock";
			case NonStandardKey.CONTEXT_MENU:	return "ContextMenu";
			case NonStandardKey.CONTROL:	return "Control";
			case NonStandardKey.END:		return "End";
			case NonStandardKey.HOME:		return "Home";
			case NonStandardKey.INSERT:		return "Insert";
			case NonStandardKey.LOGO:		return "Logo";
			case NonStandardKey.META:		return "Meta";
			case NonStandardKey.NUMLOCK:	return "NumLock";
			case NonStandardKey.PAGE_UP:	return "PageUp";
			case NonStandardKey.PAGE_DOWN:	return "PageDown";
			case NonStandardKey.PAUSE:		return "Pause";
			case NonStandardKey.PRINTSCREEN:return "PrintScreen";
			case NonStandardKey.SCROLLLOCK:	return "ScrollLock";
			case NonStandardKey.SHIFT:		return "Shift";
			
				// Non-standard game keys (used by the VM perhaps)
			case NonStandardKey.VGAME_UP:	return "VirtualGameUp";
			case NonStandardKey.VGAME_DOWN:	return "VirtualGameDown";
			case NonStandardKey.VGAME_LEFT:	return "VirtualGameLeft";
			case NonStandardKey.VGAME_RIGHT:return "VirtualGameRight";
			case NonStandardKey.VGAME_FIRE:	return "VirtualGameFire";
			case NonStandardKey.VGAME_A:	return "VirtualGameA";
			case NonStandardKey.VGAME_B:	return "VirtualGameB";
			case NonStandardKey.VGAME_C:	return "VirtualGameC";
			case NonStandardKey.VGAME_D:	return "VirtualGameD";
			
				// Default character or unknown
			default:
				// These are purely valid characters
				if (__c > 0)
					return Character.valueOf((char)__c).toString();
				
				// {@squirreljme.error EB06 Cannot get the name for the given
				// key code because it is not known. (The key code)}
				throw new IllegalArgumentException(String.format("EB06 %d",
					__c));
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/event/NonStandardKey.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

/**
 * This byteerface contains identifiers for non-standard keys.
 *
 * @since 2017/02/12
 */
public interface NonStandardKey
{
	/** Unknown, zero is the invalid index so always make it known. */
	byte UNKNOWN =
		0;
	
	/** Game Up. */
	byte VGAME_UP =
		-9;
	
	/** Game Down. */
	byte VGAME_DOWN =
		-10;
	
	/** Game Left. */
	byte VGAME_LEFT =
		-11;
	
	/** Game Right. */
	byte VGAME_RIGHT =
		-12;
	
	/** Game fire. */
	byte VGAME_FIRE =
		-13;
	
	/** Game A. */
	byte VGAME_A =
		-14;
	
	/** Game B. */
	byte VGAME_B =
		-15;
	
	/** Game C. */
	byte VGAME_C =
		-16;
	
	/** Game D. */
	byte VGAME_D =
		-17;
	
	/** Shift. */
	byte SHIFT =
		-18;
	
	/** Control. */
	byte CONTROL =
		-19;
	
	/** Alt. */
	byte ALT =
		-20;
	
	/** Logo. */
	byte LOGO =
		-21;
	
	/** Caps lock. */
	byte CAPSLOCK =
		-22;
	
	/** Context menu. */
	byte CONTEXT_MENU =
		-23;
	
	/** Home. */
	byte HOME =
		-24;
	
	/** End. */
	byte END =
		-25;
	
	/** Page Up. */
	byte PAGE_UP =
		-26;
	
	/** Page Down. */
	byte PAGE_DOWN =
		-27;
	
	/** Meta. */
	byte META =
		-28;
	
	/** Numlock. */
	byte NUMLOCK =
		-29;
	
	/** Pause. */
	byte PAUSE =
		-30;
	
	/** Print Screen. */
	byte PRINTSCREEN =
		-31;
	
	/** Scroll lock. */
	byte SCROLLLOCK =
		-32;
	
	/** Insert. */
	byte INSERT =
		-33;
	
	/** F24. */
	byte F24 =
		-34;
	
	/** F1. */
	byte F1 = NonStandardKey.F24 - 24;
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/event/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains anything related to event handling for LCDUI.
 *
 * @since 2017/08/19
 */

package cc.squirreljme.runtime.lcdui.event;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/fbui/DrawingCanvas.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.Canvas;

/**
 * This is a drawing of a canvas.
 *
 * @since 2020/01/18
 */
public class DrawingCanvas
	extends UIDrawerState
{
	/** The canvas to draw. */
	protected final Canvas canvas;
	
	/**
	 * Initializes the drawer.
	 *
	 * @param __c The canvas to draw.
	 * @since 2020/01/18
	 */
	public DrawingCanvas(Canvas __c)
	{
		super(__c);
		
		this.canvas = __c;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/fbui/DrawingList.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.List;

/**
 * This is the drawing of a list.
 *
 * @since 2020/01/18
 */
public class DrawingList
	extends UIDrawerState
{
	/** The list to draw. */
	protected final List list;
	
	/**
	 * Initializes the drawer.
	 *
	 * @param __l The list to draw.
	 * @since 2020/01/18
	 */
	public DrawingList(List __l)
	{
		super(__l);
		
		this.list = __l;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/fbui/UIDrawerState.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.Displayable;

/**
 * This contains the state of a drawer.
 *
 * @since 2020/01/15
 */
public abstract class UIDrawerState
{
	/** The displayable to be drawn/interacted with. */
	protected final Displayable displayable;
	
	/**
	 * Initializes the drawer state.
	 *
	 * @param __d The displayable to draw.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public UIDrawerState(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this.displayable = __d;
	}
	
	/**
	 * Returns the content height of this state.
	 *
	 * @return The content height.
	 * @since 2020/01/15
	 */
	public final int contentHeight()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the content width of this state.
	 *
	 * @return The content width.
	 * @since 2020/01/15
	 */
	public final int contentWidth()
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/fbui/UIState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.fbui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.IPCCallback;
import cc.squirreljme.jvm.IPCManager;
import cc.squirreljme.jvm.SystemCallIndex;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

/**
 * This class contains the state of the user interface. It may call the native
 * frame buffer system calls to perform updates or otherwise.
 *
 * @since 2020/01/12
 */
public final class UIState
	implements IPCCallback
{
	/** User interface state. */
	private static UIState _UI_STATE;
	
	/** Get capabilities of the display. */
	protected final int capabilities;
	
	/** The format of the framebuffer. */
	protected final byte format;
	
	/** Is native IPC used for the framebuffer? */
	protected final boolean useipc;
	
	/** Has screen flipping capability. */
	protected final boolean canflip;
	
	/** Is this a color screen? */
	protected final boolean iscolor;
	
	/** The currently bound display. */
	protected Display display;
	
	/** The current drawable state. */
	protected UIDrawerState drawerstate;
	
	/**
	 * Only internally initialized.
	 *
	 * @since 2020/01/12
	 */
	private UIState()
	{
		// Get display format
		this.format = (byte)Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_FORMAT);
		
		// Get display capabilities
		int capabilities = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_GET_CAPABILITIES);
		this.capabilities = capabilities;
		
		// Quick capability setting
		this.useipc =
			((capabilities & Framebuffer.CAPABILITY_IPC_EVENTS) != 0);
		this.canflip = 
			((capabilities & Framebuffer.CAPABILITY_SCREEN_FLIP) != 0);
		this.iscolor =
			((capabilities & Framebuffer.CAPABILITY_COLOR) != 0);
		
		// Register callback for the UI so we get events and such
		// Note that even if we do event handling in this program because the
		// JVM does not have one, we still register for other portions using
		// them
		IPCManager.register(Framebuffer.IPC_ID, this);
	}
	
	/**
	 * Binds this display to the current state.
	 *
	 * @param __d The display to bind.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/12
	 */
	public final void bindDisplay(Display __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this.display = __d;
	}
	
	/**
	 * Returns the capabilities of the framebuffer.
	 *
	 * @return The framebuffer capabilities.
	 * @since 2020/01/15
	 */
	public final int capabilities()
	{
		return this.capabilities;
	}
	
	/**
	 * Is the display currently flipped?
	 *
	 * @return If the display is flipped.
	 * @since 2020/01/15
	 */
	public final boolean displayFlipped()
	{
		// If the display cannot be flipped, this always returns false
		if (!this.canflip)
			return false;
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current display height.
	 *
	 * @return The display height.
	 * @since 2020/01/15
	 */
	public final int displayHeight()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this a color display?
	 *
	 * @return If this is a color display.
	 * @since 2020/01/15
	 */
	public final boolean displayIsColor()
	{
		return this.iscolor;
	}
	
	/**
	 * Returns the number of unique colors.
	 *
	 * @return The number of unique colors.
	 * @since 2020/01/15
	 */
	public final int displayUniqueColors()
	{
		int format = this.format;
		switch (format)
		{
			case Framebuffer.FORMAT_INTEGER_RGB888:	return 16777216;
			case Framebuffer.FORMAT_BYTE_INDEXED:	return 256;
			case Framebuffer.FORMAT_SHORT_RGB565:	return 66560;
			case Framebuffer.FORMAT_PACKED_ONE:		return 2;
			case Framebuffer.FORMAT_PACKED_TWO:		return 4;
			case Framebuffer.FORMAT_PACKED_FOUR:	return 16;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the current display width.
	 *
	 * @return The display width.
	 * @since 2020/01/15
	 */
	public final int displayWidth()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current drawer state.
	 *
	 * @return The current drawer state.
	 * @since 2020/01/15
	 */
	public final UIDrawerState drawerState()
	{
		return this.drawerstate;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Requests that the display be repainted.
	 *
	 * @since 2020/01/15
	 */
	public final void repaint()
	{
		this.repaint(0, 0, this.displayWidth(), this.displayHeight());
	}
	
	/**
	 * Requests that the display be repainted.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2020/01/15
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		if (this.useipc)
			Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
				Framebuffer.CONTROL_REPAINT_REQUEST,
				__x, __y, __w, __h);
		
		// IPC not supported, so we manage our own event queue and such
		else
			throw new todo.TODO();
	}
	
	/**
	 * Sets the displayable to be drawn.
	 *
	 * @param __d The displayable to draw.
	 * @return The new drawing state.
	 * @since 2020/01/15
	 */
	public final UIDrawerState setDisplayable(Displayable __d)
	{
		UIDrawerState rv;
		
		// Nothing
		if (__d == null)
			rv = null;
			
		// List
		else if (__d instanceof List)
			rv = new DrawingList((List)__d);
		
		// Canvas
		else if (__d instanceof Canvas)
			rv = new DrawingCanvas((Canvas)__d);
		
		// Unknown
		else
			throw new todo.OOPS(__d.getClass().getName());
		
		// Set state and return
		this.drawerstate = rv;
		return rv;
	}
	
	/**
	 * Sets the system title.
	 *
	 * @param __s The title to set.
	 * @since 2020/01/15
	 */
	public final void setTitle(String __s)
	{
		char[] chars = (__s == null ? "SquirrelJME" : __s).toCharArray();
		
		// Tell the framebuffer to set the title as needed
		long pointer = Assembly.objectToPointer(chars);
		Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_SET_TITLE,
			Assembly.longUnpackHigh(pointer), Assembly.longUnpackLow(pointer));
		
		// Touch
		if (chars.length > 0)
			chars[0] = chars[0];
	}
	
	/**
	 * Returns the instance of the user interface state.
	 *
	 * @return The instance of the user interface state.
	 * @since 2020/01/12
	 */
	public static final UIState getInstance()
	{
		UIState rv = UIState._UI_STATE;
		if (rv != null)
			return rv;
		
		// We may need to create an instance
		synchronized (UIState.class)
		{
			// Try again
			rv = UIState._UI_STATE;
			if (rv != null)
				return rv;
			
			// Initialize new state
			UIState._UI_STATE = (rv = new UIState());
			
			return rv;
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/fbui/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This contains the Framebuffer UI engine.
 *
 * @since 2020/01/12
 */

package cc.squirreljme.runtime.lcdui.fbui;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/font/FontSizeConversion.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

import javax.microedition.lcdui.Font;

/**
 * This class provides static methods for the conversion of font sizes from
 * pixel sizes to logical sizes.
 *
 * @since 2018/11/24
 */
public final class FontSizeConversion
{
	/**
	 * Not used.
	 *
	 * @since 2018/11/24
	 */
	private FontSizeConversion()
	{
	}
	
	/**
	 * Converts the logical font size to pixel size.
	 *
	 * @param __lsz The logical font size.
	 * @return The pixel size.
	 * @throws IllegalArgumentException If the logical font size is not valid.
	 * @since 2018/11/24
	 */
	public static final int logicalSizeToPixelSize(int __lsz)
		throws IllegalArgumentException
	{
		switch (__lsz)
		{
			case Font.SIZE_SMALL:
				return 8;
			
			case Font.SIZE_MEDIUM:
				return 12;
			
			case Font.SIZE_LARGE:
				return 16;
			
				// {@squirreljme.error EB07 Invalid logical font size.}
			default:
				throw new IllegalArgumentException("EB07");
		}
	}
	
	/**
	 * Converts the pixel size to a logical font size.
	 *
	 * @param __psz The pixel font size.
	 * @return The logical size.
	 * @since 2018/11/24
	 */
	public static final int pixelSizeToLogicalSize(int __psz)
	{
		if (__psz < 10)
			return Font.SIZE_SMALL;
		else if (__psz < 14)
			return Font.SIZE_MEDIUM;
		return Font.SIZE_LARGE;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/font/SQFFont.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.lcdui.Font;

/**
 * This represents a SQF Font (SquirrelJME Font) which is a compacted and
 * simplified font representation that is made to be as simple as possible by
 * having the desired goals: small, low memory, easy to load.
 *
 * All fonts are ISO-8859-15, same sized cells for each characters although
 * their width can differ.
 *
 * The font is in the following format:
 *  - int8 pixelheight.
 *  - int8 ascent.
 *  - int8 descent.
 *  - int8 bytesperscan (The number of bytes per scanline).
 *  - int8[256] charwidths.
 *  - int8[256] isvalidchar.
 *  - uint[256 * bytesperscan * pixelheight] charbmp.
 *
 * @since 2018/11/27
 */
public final class SQFFont
{
	/** SQF Font data. */
	private static final Map<SQFFontSpecifier, SQFFont> _FONT_CACHE =
		new HashMap<>();
	
	/** The pixel height of the font. */
	public final byte pixelheight;
	
	/** The ascent of the font. */
	public final byte ascent;
	
	/** The maximum ascent of the font. */
	public final byte maxascent;
	
	/** The descent of the font. */
	public final byte descent;
	
	/** The bytes per scan. */
	public final byte bytesperscan;
	
	/** The bits per scan. */
	public final byte bitsperscan;
	
	/** The number of bytes that make up a character's bitmap. */
	public final int charbitmapsize;
	
	/**
	 * The leading of the font.
	 * It is unspecified what this value actually should be so for now it is
	 * just a constant.
	 */
	public final byte leading =
		2;
	
	/** Is this character valid? */
	private final boolean[] _isvalidchar;
	
	/** The character widths. */
	private final byte[] _charwidths;
	
	/** The character bitmap. */
	private final byte[] _charbmp;
	
	/**
	 * Initializes the SQF Font.
	 *
	 * @param __ph The pixel height.
	 * @param __a The ascent.
	 * @param __d The descent.
	 * @param __bps The bytes per scan.
	 * @param __cw Character widths.
	 * @param __ivc Is this a valid character?
	 * @param __bmp The bitmap data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	private SQFFont(byte __ph, byte __a, byte __d, byte __bps, byte[] __cw,
		boolean[] __ivc, byte[] __bmp)
		throws NullPointerException
	{
		if (__cw == null || __ivc == null || __bmp == null)
			throw new NullPointerException("NARG");
		
		this.pixelheight = __ph;
		this.ascent = __a;
		this.descent = __d;
		this.bytesperscan = __bps;
		this.bitsperscan = (byte)(__bps * 8);
		this._charwidths = __cw;
		this._isvalidchar = __ivc;
		this._charbmp = __bmp;
		this.charbitmapsize = __bps * __ph;
		
		// The maximum ascent is just the ascent since all SQFs have the
		// same properties
		this.maxascent = __a;
	}
	
	/**
	 * Returns the number of bytes each character requires to store its
	 * bitmap data.
	 *
	 * @return The character bitmap size.
	 * @since 2018/12/01
	 */
	public final int charBitmapSize()
	{
		return this.charbitmapsize;
	}
	
	/**
	 * Returns the width of the specified character.
	 *
	 * @param __c The character to get the width of.
	 * @return The width of the given character.
	 * @since 2018/11/30
	 */
	public final int charWidth(char __c)
	{
		byte[] charwidths = this._charwidths;
		if (__c > 256 || !this._isvalidchar[__c])
			return charwidths[0];
		return charwidths[__c];
	}
	
	/**
	 * Is the specified character valid?
	 *
	 * @param __c The character to check.
	 * @return If the character is valid.
	 * @since 2019/06/16
	 */
	public final boolean isValid(char __c)
	{
		if (__c > 256)
			return false;
		return this._isvalidchar[__c];
	}
	
	/**
	 * Loads the bitmap
	 *
	 * @param __c The character to get.
	 * @param __bmp The output bitmap.
	 * @return The bytes per scanline.
	 * @throws IndexOutOfBoundsException If the bitmap is out of bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public final int loadCharBitmap(char __c, byte[] __bmp)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Illegal character? Use the replacement
		if (__c > 256 || !this._isvalidchar[__c])
			__c = 0;
		
		// Need to know this to copy each scanline of the font
		int charbitmapsize = this.charbitmapsize;
		
		// Copy bitmap data
		byte[] charbmp = this._charbmp;
		for (int o = 0, i = __c * charbitmapsize; o < charbitmapsize; o++, i++)
			__bmp[o] = charbmp[i];
		
		// Return the bytes per scan
		return this.bytesperscan;
	}
	
	/**
	 * Prints the glyph data to the given stream.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public final void printGlyphs(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		int pixelheight = this.pixelheight,
			bytesperscan = this.bytesperscan,
			bitsperscan = this.bitsperscan;
		
		// Setup string builders to handle each line
		int pipecount = 0;
		StringBuilder[] sb = new StringBuilder[pixelheight + 1];
		for (int i = 0; i < pixelheight + 1; i++)
			sb[i] = new StringBuilder();
		
		// Print each character
		byte[] charwidths = this._charwidths,
			charbmp = this._charbmp;
		boolean[] isvalidchar = this._isvalidchar;
		for (int ch = 0; ch < 256; ch++)
		{
			// Ignore unspecified characters
			if (!isvalidchar[ch])
				continue;
			
			int charwidth = (int)charwidths[ch],
				gapw = charwidth + 1;
			
			// Force font to single character
			if (charwidth < 1)
				charwidth = 1;
			
			// Put description line
			sb[0].append(String.format(
				"%-" + charwidth + "." + charwidth + "s",
				String.format("%02x,%d", ch, charwidth)));
			sb[0].append('|');
			
			// Draw each line
			for (int y = 0; y < pixelheight; y++)
			{
				int p = (ch * bytesperscan * pixelheight) +
					(y * bytesperscan);
				
				// Draw each column into the buffers
				for (int x = 0; x < charwidth; x++)
					sb[y + 1].append(
						(((charbmp[p + (x >>> 3)] & (1 << (x & 0x7))) != 0) ?
						'#' : '.'));
				
				// End in pipe
				sb[y + 1].append('|');
			}
			
			// Draw string builders and clear
			pipecount += (charwidth + 1);
			if (pipecount >= 70)
			{
				// Clear out
				for (int i = 0, n = sb.length; i < n; i++)
				{
					__ps.println(sb[i]);
					sb[i].setLength(0);
				}
				
				// Reset for next time
				pipecount = 0;
			}
		}
		
		// Clear out
		if (pipecount > 0)
		{
			for (int i = 0, n = sb.length; i < n; i++)
				__ps.println(sb[i]);
		}
	}
	
	/**
	 * Caches the SQF font.
	 *
	 * @param __n The name of the font.
	 * @param __pxs The pixel size of the font.
	 * @return The font.
	 * @throws IllegalArgumentException If the font does not exist or is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public static final SQFFont cacheFont(String __n, int __pxs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");	
		
		// Build specifier
		SQFFontSpecifier spec = new SQFFontSpecifier(__n, __pxs);
		
		Map<SQFFontSpecifier, SQFFont> cache = SQFFont._FONT_CACHE;
		synchronized (cache)
		{
			// Already cached?
			SQFFont rv = cache.get(spec);
			if (rv != null)
				return rv;
			
			// Read the SQF Font
			try (InputStream in = SQFFont.class.getResourceAsStream(
				spec.toFileName()))
			{
				// {@squirreljme.error EB08 The font does not exist.
				// (The name; The pixel size)}
				if (in == null)
					throw new IllegalArgumentException(
						String.format("EB08 %s %d", __n, __pxs));
				
				// Read font data
				rv = SQFFont.read(in);
				
				// Cache the data
				cache.put(spec, rv);
			}
			
			// {@squirreljme.error EB09 Could not load the font data.
			// (The name; The pixel size)}
			catch (IOException e)
			{
				throw new IllegalArgumentException(
					String.format("EB09 %s %d", __n, __pxs), e);
			}
			
			// Use it!
			return rv;
		}
	}
	
	/**
	 * Caches the SQF font based on the passed font object.
	 *
	 * @param __f The font to cache.
	 * @return The SQF data for this font.
	 * @throws IllegalArgumentException If the font does not exist or is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public static final SQFFont cacheFont(Font __f)
		throws IllegalArgumentException, NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return SQFFont.cacheFont(__f.getFontName(), __f.getPixelSize());
	}
	
	/**
	 * Reads and returns a SQF Font.
	 *
	 * @param __in The input stream data.
	 * @return The decoded SQF Font.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final SQFFont read(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Makes it easier to handle things
		DataInputStream dis = new DataInputStream(__in);
		
		// Read fields
		byte pixelheight = dis.readByte(),
			ascent = dis.readByte(),
			descent = dis.readByte(),
			bytesperscan = dis.readByte();
		
		// Read the widths
		byte[] charwidths = new byte[256];
		dis.readFully(charwidths);
		
		// Valid characters?
		boolean[] isvalidchar = new boolean[256];
		for (int i = 0; i < 256; i++)
			if (dis.readByte() != 0)
				isvalidchar[i] = true;
		
		// Read the bitmaps
		byte[] charbmp = new byte[256 * bytesperscan * pixelheight];
		dis.readFully(charbmp);
		
		// Build font
		return new SQFFont(pixelheight, ascent, descent, bytesperscan,
			charwidths, isvalidchar, charbmp);
	}
	
	/**
	 * This maps the given character to the SQF character map.
	 *
	 * Since SQFs are ISO-8859-15, they do not map exactly to ISO-8859-1
	 * which may be the default encoding.
	 *
	 * @param __c The character to map.
	 * @return The mapped character.
	 * @since 2019/04/29
	 */
	public static final char mapChar(char __c)
	{
		switch (__c)
		{
				// Convert
			case 0x20AC:	return (char)0x00A4;
			case 0x0160:	return (char)0x00A6;
			case 0x0161:	return (char)0x00A8;
			case 0x017D:	return (char)0x00B4;
			case 0x017E:	return (char)0x00B8;
			case 0x0152:	return (char)0x00BC;
			case 0x0153:	return (char)0x00BD;
			case 0x0178:	return (char)0x00BE;
			
				// Map similar characters to others
			case 0x00A4:	return (char)0x20AC;
			case 0x00B4:	return '\'';
			case 0x00A6:	return '|';
			case 0x00A8:	return '"';
				
				// Cannot be mapped
			case 0x00B8:
			case 0x00BC:
			case 0x00BD:
			case 0x00BE:	return (char)0xFFFD;
		}
		
		// Mapped the same
		return __c;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/font/SQFFontSpecifier.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

/**
 * Specifier for SQF Fonts.
 *
 * @since 2018/12/01
 */
public final class SQFFontSpecifier
	implements Comparable<SQFFontSpecifier>
{
	/** The name of the font. */
	protected final String name;
	
	/** The pixel size of the font. */
	protected final int pixelsize;
	
	/** The hashcode cache. */
	private final int _hashcode;
	
	/**
	 * Initializes the font specifier.
	 *
	 * @param __name The font name.
	 * @param __pxs The pixel size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public SQFFontSpecifier(String __name, int __pxs)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.pixelsize = __pxs;
		this._hashcode = __name.hashCode() ^ __pxs;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final int compareTo(SQFFontSpecifier __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.pixelsize - __o.pixelsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof SQFFontSpecifier))
			return false;
		
		// Different hashcodes will never compare ever
		SQFFontSpecifier o = (SQFFontSpecifier)__o;
		if (this._hashcode != o._hashcode)
			return false;
		
		return this.pixelsize == o.pixelsize &&
			this.name.equals(o.name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final int hashCode()
	{
		return this._hashcode;
	}
	
	/**
	 * Returns the file name of the font.
	 *
	 * @return The filename.
	 * @since 2018/12/01
	 */
	public final String toFileName()
	{
		return String.format("%s-%d.sqf", this.name, this.pixelsize);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/font/package-info.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for fonts.
 *
 * Since it is really difficult to have fonts as part of displays, fonts are
 * completely separate which also allows for default fonts to be provided.
 *
 * @since 2017/10/01
 */

package cc.squirreljme.runtime.lcdui.font;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/AcceleratedGraphics.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;

/**
 * This class forwards graphics operations to the host native display API
 * which provides a single instance of accelerated graphics.
 *
 * @since 2018/11/19
 */
public final class AcceleratedGraphics
	extends SerializedGraphics
{
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object serialize(GraphicsFunction __func, Object... __args)
	{
		// Forward serialized arguments to the destination host
		return NativeDisplayAccess.accelGfxFunc(0,
			__func.ordinal(), __args);
	}
	
	/**
	 * Returns the instance for the given display ID.
	 *
	 * @return The accelerated graphics instance.
	 * @throws UnsupportedOperationException If accelerated graphics are not
	 * supported.
	 * @since 2018/11/19
	 */
	public static final AcceleratedGraphics instance()
		throws UnsupportedOperationException
	{
		// {@squirreljme.error EB0a Accelerated graphics operations are not
		// supported for this display. (The display ID)}
		if (!NativeDisplayAccess.accelGfx(0))
			throw new UnsupportedOperationException("EB0a " + 0);
		
		// Effectively has "new" state
		return new AcceleratedGraphics();
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/AdvancedBufferAdapter.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This is the base class for buffer adapters, instances of these classes are
 * used to translate the 32-bit integer format to lower quality buffer formats.
 *
 * @since 2019/03/24
 */
public abstract class AdvancedBufferAdapter
{
	/**
	 * Adapts the buffer data.
	 *
	 * @since 2019/03/24
	 */
	public abstract void adapt();
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/AdvancedFunction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This contains the various functions that may be set by
 * {@link AdvancedGraphics} and called accordingly when needed.
 *
 * All functions operate on pixels which are backed by a 32-bit integer
 * array.
 *
 * @since 2019/03/24
 */
public enum AdvancedFunction
{
	/** Do nothing. */
	NOP
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
		}
	},
	
	/** Fill rectangle, no blending. */
	FILLRECT_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int pac = __ag.paintcolorhigh;
			int[] buffer = __ag.buffer;
			int pitch = __ag.pitch,
				offset = __ag.offset,
				__x = __vi[0],
				__y = __vi[1],
				__ex = __vi[2],
				__ey = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			
			for (int y = __y; y < __ey; y++)
				for (int dest = offset + (y * pitch) + __x, pex = dest + __w;
					dest < pex; dest++)
					buffer[dest] = pac;
		}
	},
	
	/** Fill rectangle, with blending. */
	FILLRECT_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int pac = __ag.paintalphacolor;
			int[] buffer = __ag.buffer;
			int pitch = __ag.pitch,
				offset = __ag.offset,
				__x = __vi[0],
				__y = __vi[1],
				__ex = __vi[2],
				__ey = __vi[3],
				__w = __vi[4],
				__h = __vi[5],
				sa = __ag.paintalpha,
				na = (sa ^ 0xFF),
				srb = ((pac & 0xFF00FF) * sa),
				sgg = (((pac >>> 8) & 0xFF) * sa);
			
			// Blend each color
			int mod = 0;
			for (int y = __y; y < __ey; y++)
				for (int dest = offset + (y * pitch) + __x, pex = dest + __w;
					dest < pex; dest++)
				{
					int dcc = buffer[dest],
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					buffer[dest] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** Character bitmap, no blending. */
	CHARBITMAP_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __color = __vi[0] | 0xFF_000000,
				__dsx = __vi[1],
				__dsy = __vi[2],
				__bytesperscan = __vi[3],
				__scanoff = __vi[4],
				__scanlen = __vi[5],
				__lineoff = __vi[6],
				__linelen = __vi[7];
			byte[] __bmp = (byte[])__va[0];
			
			int[] data = __ag.buffer;
			int offset = __ag.offset,
				pitch = __ag.pitch;
			
			// Treat lens as end indexes
			int origscanlen = __scanlen;
			__scanlen += __scanoff;
			__linelen += __lineoff;
			
			// Remember the old scan offset, because we reset
			int resetscanoff = __scanoff;
			
			// Determine the draw pointer for this line
			int basep = offset + (__dsy * pitch) + __dsx;
			
			// Base source offset line according to the line offset
			int bi = __lineoff * __bytesperscan;
			
			// Drew each line
			for (; __lineoff < __linelen; __lineoff++, __dsy++)
			{
				// Reset parameters for this line
				int p = basep;
				__scanoff = resetscanoff;
				
				// Draw each scan from the bitmap
				for (; __scanoff < __scanlen; __scanoff++, p++)
				{
					// Get the byte that represents the scan here
					byte b = __bmp[bi + (__scanoff >>> 3)];	
					
					// If there is a pixel here, draw it
					if ((b & (1 << (__scanoff & 0x7))) != 0)
						data[p] = __color;
				}
				
				// Move the source and dest pointers to the next line
				basep += pitch;
				bi += __bytesperscan;
			}
		}
	},
	
	/** Character bitmap, with blending. */
	CHARBITMAP_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			AdvancedFunction.CHARBITMAP_NOBLEND.function(__ag, __vi, __va);
		}
	},
	
	/** Draw line, no blend or dots. */
	LINE_NOBLEND_NODOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintcolorhigh,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			for (;;)
			{
				// Nothing left to draw?
				if (__x1 >= __x2 &&
					((neg && __y1 <= __y2) || (!neg && __y1 >= __y2)))
					break;
				
				data[dest] = color;
				
				// Increase X
				int brr = err;
				if (brr > -dx)
				{
					err -= dy;
					__x1++;
					dest++;
				}
		
				// Increase Y
				if (brr < dy)
				{
					err += dx;
					__y1 += sy;
					dest += ssy;
				}
			}
		}
	},
	
	/** Draw line, no blend with dots. */
	LINE_NOBLEND_DOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintcolorhigh,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			/*for (boolean blip = true;; blip = !blip)*/
			for (int blip = 0, nblip = ~0;; nblip = blip, blip = ~blip)
			{
				// Nothing left to draw?
				if (__x1 >= __x2 &&
					((neg && __y1 <= __y2) || (!neg && __y1 >= __y2)))
					break;
				
				/*if (blip)
					data[dest] = color;*/
				data[dest] = (data[dest] & blip) | (color & nblip);
				
				// Increase X
				int brr = err;
				if (brr > -dx)
				{
					err -= dy;
					__x1++;
					dest++;
				}
		
				// Increase Y
				if (brr < dy)
				{
					err += dx;
					__y1 += sy;
					dest += ssy;
				}
			}
		}
	},
	
	/** Draw line, blend with no dots. */
	LINE_BLEND_NODOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			if (true)
			{
				AdvancedFunction.LINE_NOBLEND_NODOT.function(__ag, __vi, __va);
				return;
			}
			
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintalphacolor,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			throw new todo.TODO();
		}
	},
	
	/** Draw line, blend with dots. */
	LINE_BLEND_DOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			if (true)
			{
				AdvancedFunction.LINE_NOBLEND_DOT.function(__ag, __vi, __va);
				return;
			}
			
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintalphacolor,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			throw new todo.TODO();
		}
	},
	
	/** RGB Tile, no blending. */
	RGBTILE_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
					data[dp] = __b[src] | 0xFF_000000;
		}
	},
	
	/** RGB Tile, blending. */
	RGBTILE_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src] | 0xFF_000000,
						srb = ((pac & 0xFF00FF) * 0xFF),
						sgg = (((pac >>> 8) & 0xFF) * 0xFF),
						dcc = data[dp],
						xrb = (srb + ((dcc & 0xFF00FF) * 0x00)) >>> 8,
						xgg = (((sgg +
							(((dcc >>> 8) & 0xFF) * 0x00)) + 1) * 257) >>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** ARGB Tile, no blending. */
	ARGBTILE_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src],
						sa = pac >>> 24,
						na = (sa ^ 0xFF),
						srb = ((pac & 0xFF00FF) * sa),
						sgg = (((pac >>> 8) & 0xFF) * sa),
						dcc = data[dp] | 0xFF_000000,
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** ARGB Tile, blending. */
	ARGBTILE_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src],
						sa = pac >>> 24,
						na = (sa ^ 0xFF),
						srb = ((pac & 0xFF00FF) * sa),
						sgg = (((pac >>> 8) & 0xFF) * sa),
						dcc = data[dp],
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** End. */
	;
	
	/**
	 * Executes the graphics function.
	 *
	 * @param __ag The advanced graphics state.
	 * @param __vi Integer arguments.
	 * @param __va Object arguments.
	 * @since 2019/03/24
	 */
	public abstract void function(AdvancedGraphics __ag, int[] __vi,
		Object[] __va);
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/AdvancedGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;
import javax.microedition.lcdui.game.Sprite;

/**
 * This class contains the advanced graphics functions which uses
 * pre-determined functions to determine how to draw something.
 *
 * @since 2019/03/24
 */
public class AdvancedGraphics
	extends Graphics
{
	/** Clipping above. */
	private static final int _CLIP_ABOVE =
		1;
	
	/** Clipping below. */
	private static final int _CLIP_BELOW =
		2;
	
	/** Clip right. */
	private static final int _CLIP_RIGHT =
		4;
	
	/** Clip left. */
	private static final int _CLIP_LEFT =
		8;
	
	/** The array buffer. */
	protected final int[] buffer;
	
	/** The length of the buffer. */
	protected final int bufferlen;
	
	/** The width of the image. */
	protected final int width;
	
	/** The height of the image. */
	protected final int height;
	
	/** The pitch of the image. */
	protected final int pitch;
	
	/** The buffer offset. */
	protected final int offset;
	
	/** The number of elements that consist of pixel data. */
	protected final int numelements;
	
	/** Physical end of the buffer. */
	protected final int lastelement;
	
	/** Is there an alpha channel? */
	protected final boolean hasalphachannel;
	
	/** Absolute translated X coordinate. */
	protected final int abstransx;
	
	/** Absolute translated Y coordinate. */
	protected final int abstransy;
	
	/** The current stroke style. */
	protected int strokestyle;
	
	/** Is a dot stroke being used? */
	protected boolean dotstroke;
	
	/** Translated X coordinate. */
	protected int transx;
	
	/** Translated Y coordinate. */
	protected int transy;
	
	/** The starting X clip. */
	protected int clipsx;
	
	/** The starting Y clip. */
	protected int clipsy;
	
	/** The ending X clip. */
	protected int clipex;
	
	/** The ending Y clip. */
	protected int clipey;
	
	/** The clip width. */
	protected int clipw;
	
	/** The clip height. */
	protected int cliph;
	
	/** The current font, null means default. */
	protected Font font;
	
	/** The current blending mode. */
	protected int blendmode;
	
	/** Could blending be done? */
	protected boolean candoblending;
	
	/** Is blending actually going to be done? */
	protected boolean doblending;
	
	/** The current color. */
	protected int color;
	
	/** The painting alpha color. */
	protected int paintalpha;
	
	/** The color to use for painting. */
	protected int paintcolor;
	
	/** Paint color with the alpha channel set to the max. */
	protected int paintcolorhigh;
	
	/** The alpha color and normal color for painting. */
	protected int paintalphacolor;
	
	/** Function for filled rectangle. */
	protected AdvancedFunction funcfillrect;
	
	/** Function for drawing characters. */
	protected AdvancedFunction funccharbmp;
	
	/** Function for drawing lines. */
	protected AdvancedFunction funcline;
	
	/** RGB tile. */
	protected AdvancedFunction funcrgbtile;
	
	/** ARGB tile. */
	protected AdvancedFunction funcargbtile;
	
	/**
	 * Initializes the graphics.
	 *
	 * @param __buf The buffer.
	 * @param __alpha Does the buffer actually use the alpha channel?
	 * @param __aba Advanced buffer adapter, used to translate the internal
	 * integer based buffer to other formats.
	 * @param __w The image width.
	 * @param __h The image height.
	 * @param __p The image pitch.
	 * @param __o The buffer offset.
	 * @param __atx Absolute X translation.
	 * @param __aty Absolute Y translation.
	 * @throws IllegalArgumentException If the input parameters are not
	 * correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public AdvancedGraphics(int[] __buf, boolean __alpha,
		AdvancedBufferAdapter __aba,
		int __w, int __h, int __p, int __o, int __atx, int __aty)
		throws IllegalArgumentException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB0b Invalid width and/or height specified.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("EB0b");
		
		// {@squirreljme.error EB0c The pitch is less than the width.}
		if (__p < __w)
			throw new IllegalArgumentException("EB0c");
		
		// {@squirreljme.error EB0d The specified parameters exceed the bounds
		// of the array. (The width; The height; The offset; The pitch;
		// The array length; The number of elements in the image)}
		int numelements = (__p * __h),
			lastelement = __o + numelements,
			buflen = __buf.length;
		if (__o < 0 || lastelement > buflen)
			throw new ArrayIndexOutOfBoundsException(
				String.format("EB0d %d %d %d %d %d %d", __w, __h,
				__o, __p, buflen, numelements));
		
		// Set
		this.buffer = __buf;
		this.bufferlen = buflen;
		this.width = __w;
		this.height = __h;
		this.pitch = __p;
		this.offset = __o;
		this.numelements = numelements;
		this.lastelement = lastelement;
		this.hasalphachannel = __alpha;
		
		// Setup absolute translation and initialize the base translation
		// which is at the absolute origin
		this.abstransx = __atx;
		this.abstransy = __aty;
		this.transx = __atx;
		this.transy = __aty;
		
		// Initial clipping rectangle has the image bounds
		this.clipsx = 0;
		this.clipsy = 0;
		this.clipex = __w;
		this.clipey = __h;
		this.clipw = __w;
		this.cliph = __h;
		
		// Reset all initial functions
		this.resetParameters(true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		// Translate
		__x += this.transx;
		__y += this.transy;
		
		// Get right end coordinates
		int ex = __x + __w,
			ey = __y + __h;
		
		// Swap X if lower
		if (ex < __x)
		{
			int boop = __x;
			__x = ex;
			ex = boop;
		}
		
		// Same for Y
		if (ey < __y)
		{
			int boop = __y;
			__y = ey;
			ey = boop;
		}
		
		// Never go past the end of the viewport because pixels will never
		// be drawn in negative regions
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		// Additionally do not go past the edge ever that way the end
		// clipping point is always valid
		int width = this.width,
			height = this.height;
		if (ex > width)
			ex = width;
		if (ey > height)
			ey = height;
		
		// Get the old clipping bounds
		int oldclipsx = this.clipsx,
			oldclipsy = this.clipsy,
			oldclipex = this.clipex,
			oldclipey = this.clipey;
		
		// Only set the clipping bounds if they exceed the previous ones
		if (__x > oldclipsx)
			this.clipsx = (oldclipsx = __x);
		if (__y > oldclipsy)
			this.clipsy = (oldclipsy = __y);
		if (ex < oldclipex)
			this.clipex = (oldclipex = ex);
		if (ey < oldclipey)
			this.clipey = (oldclipey = ey);
		
		// Set width/height
		this.clipw = this.clipex - oldclipsx;
		this.cliph = this.clipey - oldclipsy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		// Need translation coordinates
		int tx = this.transx,
			ty = this.transy;
		
		// Image size
		int iw = this.width,
			ih = this.height;
		
		// Translate all coordinates
		__sx += tx;
		__sy += ty;
		__dx += tx;
		__dy += ty;
		
		// Perform needed anchoring
		if ((__anchor & Graphics.HCENTER) != 0)
			__dx -= (__w >> 1);
		else if ((__anchor & Graphics.RIGHT) != 0)
			__dx -= __w;
		if ((__anchor & Graphics.VCENTER) != 0)
			__dy -= (__h >> 1);
		else if ((__anchor & Graphics.BOTTOM) != 0)
			__dy -= __h;
		
		// End coordinates for both
		int sex = __sx + __w,
			sey = __sx + __h,
			dex = __dx + __w,
			dey = __dx + __h;
		
		// {@squirreljme.error EB0e Source region for area copy is out of
		// bounds.}
		if (__sx < 0 || __sy < 0 || sex > iw || sey > ih)
			throw new IllegalArgumentException("EB0e");
		
		this.__unimplemented(__dx, __dy, "copyArea");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		this.__unimplemented(__x, __y, "drawArc");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		this.__unimplemented(__x, __y, "drawARGB16");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawChar(char __s, int __x, int __y, int __anchor)
	{
		// Same as drawing strings
		this.drawString(new String(new char[]{__s}, 0, 1),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Same as drawing string
		this.drawString(new String(__s, __o, __l),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__i, 0, 0, __i.getWidth(), __i.getHeight(), 0,
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		// Translate all coordinates
		int transx = this.transx,
			transy = this.transy;
		__x1 += transx;
		__y1 += transy;
		__x2 += transx;
		__y2 += transy;
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex,
			clipey = this.clipey;
		
		// Perform Cohen-Sutherland line clipping
		for (;;)
		{
			// Determine points that lie outside the box
			int outa = AdvancedGraphics.__csOut(__x1, __y1,
					clipsx, clipsy, clipex - 1,clipey - 1),
				outb = AdvancedGraphics.__csOut(__x2, __y2, clipsx,
					clipsy, clipex - 1, clipey - 1);
			
			// Both points are outside the box, do nothing
			if ((outa & outb) != 0)
				return;
			
			// Both points are inside the box, use this line
			if (outa == 0 && outb == 0)
				break;
			
			// Only the second point is outside, swap the points so that the
			// first point is outside and the first is not
			if (outa == 0)
			{
				// Swap X
				int boop = __x1;
				__x1 = __x2;
				__x2 = boop;
				
				// Swap Y
				boop = __y1;
				__y1 = __y2;
				__y2 = boop;
				
				// Swap clip flags
				boop = outb;
				outb = outa;
				outa = boop;
			}
			
			// The point is clipped
			if (outa != 0)
			{
				// Differences of points
				int dx = __x2 - __x1,
					dy = __y2 - __y1;
				
				// Clips above the box
				if ((outa & AdvancedGraphics._CLIP_ABOVE) != 0)
				{
					__x1 += dx * (clipey - __y1) / dy;
					__y1 = clipey - 1;
				}
			
				// Clips below
				else if ((outa & AdvancedGraphics._CLIP_BELOW) != 0)
				{
					__x1 += dx * (clipsy - __y1) / dy;
					__y1 = clipsy;
				}
			
				// Clips the right side
				else if ((outa & AdvancedGraphics._CLIP_RIGHT) != 0)
				{
					__y1 += dy * (clipex - __x1) / dx;
					__x1 = clipex - 1;
				}
			
				// Clips the left side
				else if ((outa & AdvancedGraphics._CLIP_LEFT) != 0)
				{
					__y1 += dy * (clipsx - __x1) / dx;
					__x1 = clipsx;
				}
			}
		}
		
		// Have lines which always go to the right
		if (__x2 < __x1)
		{
			int boopx = __x1,
				boopy = __y1;
			__x1 = __x2;
			__y1 = __y2;
			__x2 = boopx;
			__y2 = boopy;
		}
		
		// The resulting line should never be out of bounds
		if (__x1 < clipsx || __x2 < clipsx || __y1 < clipsy || __y2 < clipsy ||
			__x1 > clipex || __x2 > clipex || __y1 > clipey || __y2 > clipey)
			return;
		
		// Forward depending on blending and/or dots
		try
		{
			this.funcline.function(this,
				new int[]{__x1, __y1, __x2, __y2},
				null);
		}
		
		// Exception happened when drawing a line
		catch (IndexOutOfBoundsException e)
		{
			todo.DEBUG.note("Line (%d, %d) -> (%d, %d)", __x1, __y1,
				__x2, __y2);
			e.printStackTrace();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Transform
		__x += this.transx;
		__y += this.transy;
		
		// Determine ending position
		int ex = __x + __w,
			ey = __y + __h;
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex,
			clipey = this.clipey;
		
		// Box is completely outside the bounds of the clip, do not draw
		if (ex < clipsx || __x >= clipex || ey < clipsy || __y >= clipey)
			return;
		
		// Determine sub-clipping area
		int subx = __x - clipsx,
			suby = __y - clipsy;
		
		// Clip into bounds
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		if (ex >= clipex)
			ex = clipex;
		if (ey >= clipey)
			ey = clipey;
		
		// New tile size
		int tw = ex - __x,
			th = ey - __y;
		
		// We might have multiplied alpha blending, or just normal blending
		// If __alpha is true then this is 32-bit RGBA!
		if (__alpha)
			this.funcargbtile.function(this,
				new int[]{__off, __scanlen, __x, __y, tw, th},
				new Object[]{__data});
		else
			this.funcrgbtile.function(this,
				new int[]{__off, __scanlen, __x, __y, tw, th},
				new Object[]{__data});
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		this.__unimplemented(__x, __y, "drawRGB16");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRect(int __x, int __y, int __w, int __h)
	{
		// The width and height are increased by a single pixel
		__w += 1;
		__h += 1;
		
		// For now just cheat and draw four lines
		int ex = __x + __w,
			ey = __y + __h;
		
		this.drawLine(__x, __y, ex, __y);
		this.drawLine(__x, ey, ex, ey);
		this.drawLine(__x, __y, __x, ey);
		this.drawLine(ex, __y, ex, ey);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.__drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wsrc, __hsrc, true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.__drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest, false);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		this.__unimplemented(__x, __y, "drawRoundRect");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__drawText(this.__buildText(__s), __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __s.length())
			throw new StringIndexOutOfBoundsException("IOOB");
		
		this.__drawText(this.__buildText(__s.substring(__o, __o + __l)),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		this.__drawText(__t, __x, __y, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		this.__unimplemented(__x, __y, "fillArc");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillRect(int __x, int __y, int __w, int __h)
	{
		// Get actual end points
		int ex = __x + __w,
			ey = __y + __h;
			
		// Translate all coordinates
		int transx = this.transx,
			transy = this.transy;
		__x += transx;
		__y += transy;
		ex += transx;
		ey += transy;
		
		// Force lower X
		if (ex < __x)
		{
			int boop = ex;
			ex = __x;
			__x = boop;
		}
		
		// Force lower Y
		if (ey < __y)
		{
			int boop = ey;
			ey = __y;
			__y = boop;
		}
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex - 1,
			clipey = this.clipey - 1;
		
		// Never clip past the left/top
		if (__x < clipsx)
			__x = clipsx;
		if (__y < clipsy)
			__y = clipsy;
		
		// Never clip past the right/bottom
		if (ex > clipex)
			ex = clipex;
		if (ey > clipey)
			ey = clipey;
		
		// Calculate actual dimensions used
		__w = ex - __x;
		__h = ey - __y;
		
		// Call function
		this.funcfillrect.function(this,
			new int[]{__x, __y, ex, ey, __w, __h},
			null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		this.__unimplemented(__x, __y, "fillRoundRect");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		this.__unimplemented(__x1, __y1, "fillTriangle");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getAlpha()
	{
		return (this.color >> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getAlphaColor()
	{
		return this.color;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getBlendingMode()
	{
		return this.blendmode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getBlueComponent()
	{
		return (this.color) & 0xFF;
	}
	
	/**
	 * Returns the element in the input array which represents the end of the
	 * clipping rectangle.
	 *
	 * @return The element which contains the end of the clipping rectangle.
	 * @since 2019/03/24
	 */
	public final int getClipElementEnd()
	{
		// Subtract one from the Y because it is on the next row
		return this.offset + (((this.pitch * (this.clipey - 1)) +
			(this.clipex)));
	}
	
	/**
	 * Returns the element in the input array which represents the start of
	 * the clipping rectangle.
	 *
	 * @return The element which contains the start of the clipping rectangle.
	 * @since 2019/03/24
	 */
	public final int getClipElementStart()
	{
		return this.offset + (((this.pitch * this.clipsy) + this.clipsx));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipHeight()
	{
		return this.cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipWidth()
	{
		return this.clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipX()
	{
		return this.clipsx - this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipY()
	{
		return this.clipsy - this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getColor()
	{
		return this.color & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getDisplayColor(int __rgb)
	{
		// Just use the original input color
		return __rgb | 0xFF_000000;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public Font getFont()
	{
		Font rv = this.font;
		if (rv == null)
			rv = Font.getDefaultFont();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getGrayScale()
	{
		return (this.getRedComponent() + this.getGreenComponent() + this
			.getBlueComponent()) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getGreenComponent()
	{
		return (this.color >> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getRedComponent()
	{
		return (this.color >> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getStrokeStyle()
	{
		return this.strokestyle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getTranslateX()
	{
		return this.transx - this.abstransx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getTranslateY()
	{
		return this.transy - this.abstransy;
	}
	
	/**
	 * Resets all parameters of the graphics output.
	 *
	 * @param __clip If {@code true} then the clip is also reset.
	 * @since 2019/03/24
	 */
	public void resetParameters(boolean __clip)
	{
		// Clear translation
		this.transx = this.abstransx;
		this.transy = this.abstransy;
	
		// Reset clip also
		if (__clip)
		{
			int width = this.width,
				height = this.height;
			
			this.clipsx = 0;
			this.clipsy = 0;
			this.clipex = width;
			this.clipey = height;
			this.clipw = width;
			this.cliph = height;
		}
		
		// Always reset these
		this.setAlphaColor(0xFF000000);
		this.setBlendingMode(Graphics.SRC_OVER);
		this.setStrokeStyle(Graphics.SOLID);
		this.setFont(null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.setAlphaColor(__a, this.getRedComponent(), this.getGreenComponent(),
			this.getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		// Set the original color directly
		this.color = __argb;
		
		// Determine if blending is to be performed or it is just directly
		// setting values, blending is only performed if the alpha channel
		// is not fully opaque and blending is permitted
		int alpha = (__argb >>> 24);
		boolean doblending = (this.candoblending && alpha != 0xFF);
		
		// Set internal blend mode
		this.doblending = doblending;
		
		// Set painting colors
		this.paintalpha = alpha;
		this.paintcolor = __argb & 0xFFFFFF;
		this.paintcolorhigh = __argb | 0xFF000000;
		this.paintalphacolor = __argb;
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0f Color out of range. (Alpha; Red; Green;
		// Blue)}
		if (__a < 0 || __a > 255 || __r < 0 || __r > 255 ||
			__g < 0 || __g > 255 || __b < 0 || __b > 255)
			throw new IllegalArgumentException(String.format(
				"EB0f %d %d %d %d", __a, __r, __g, __b));
		
		// Set
		this.setAlphaColor((__a << 24) | (__r << 16) | (__g << 8) | __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		boolean candoblending,
			oldcandoblending = this.candoblending;
		
		// Just use source pixels
		if (__m == Graphics.SRC)
		{
			// {@squirreljme.error EB0g Cannot set the overlay blending mode
			// because this graphics context does not have the alpha channel.}
			if (!this.hasalphachannel)
				throw new IllegalArgumentException("EB0g");
			
			candoblending = false;
		}
		
		// Perform blending since this is the default mode
		else if (__m == Graphics.SRC_OVER)
		{
			candoblending = true;
		}
		
		// {@squirreljme.error EB0h Unknown blending mode.}
		else
			throw new IllegalArgumentException("EB0h");
		
		// Set
		this.blendmode = __m;
		this.candoblending = candoblending;
		
		// If the blending mode has changed then possible blending tables
		// need to be recalculated accordingly
		if (candoblending != oldcandoblending)
			this.setAlphaColor(this.getAlphaColor());
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setClip(int __x, int __y, int __w, int __h)
	{
		// Translate
		__x += this.transx;
		__y += this.transy;
		
		// Get right end coordinates
		int ex = __x + __w,
			ey = __y + __h;
		
		// Swap X if lower
		if (ex < __x)
		{
			int boop = __x;
			__x = ex;
			ex = boop;
		}
		
		// Same for Y
		if (ey < __y)
		{
			int boop = __y;
			__y = ey;
			ey = boop;
		}
		
		// Never go past the end of the viewport because pixels will never
		// be drawn in negative regions
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		// Additionally do not go past the edge ever that way the end
		// clipping point is always valid
		int width = this.width,
			height = this.height;
		if (ex > width)
			ex = width;
		if (ey > height)
			ey = height;
		
		// Set
		this.clipsx = __x;
		this.clipsy = __y;
		this.clipex = ex;
		this.clipey = ey;
		
		// Set width/height
		this.clipw = ex - __x;
		this.cliph = ey - __y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setColor(int __rgb)
	{
		this.setAlphaColor((this.getAlphaColor() & 0xFF_000000) |
			(__rgb & 0x00_FFFFFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.setAlphaColor(this.getAlpha(), __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setFont(Font __a)
	{
		// Just set it
		this.font = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setGrayScale(int __v)
	{
		this.setAlphaColor(this.getAlpha(), __v, __v, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setStrokeStyle(int __a)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0i Illegal stroke style.}
		if (__a != Graphics.SOLID && __a != Graphics.DOTTED)
			throw new IllegalArgumentException("EB0i");
		
		// Set
		this.strokestyle = __a;
		this.dotstroke = (__a == Graphics.DOTTED);
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void translate(int __x, int __y)
	{
		this.transx += __x;
		this.transy += __y;
	}
	
	/**
	 * Builds and returns a text object for usage.
	 *
	 * @param __s The string used.
	 * @return A new text object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	private final Text __buildText(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Get the font, or fallback to the default if it was not set
		Font font = this.getFont();
		
		// Setup, use a zero height for now since it will be calculated after
		// the font and such has been set
		Text rv = new Text(__s,
			font.stringWidth(__s), 0);
		
		// Set text properties
		if (font != null)
			rv.setFont(font);
		rv.setForegroundColor(this.color);
		
		// Set the height to the required height of the box now that the
		// parameters have been set
		rv.setHeight(rv.getRequiredHeight());
		
		return rv;
	}
	
	/**
	 * Draws region.
	 *
	 * @param __src Source image.
	 * @param __xsrc X source.
	 * @param __ysrc Y source.
	 * @param __wsrc W source.
	 * @param __hsrc H source.
	 * @param __trans Translation.
	 * @param __xdest X destination.
	 * @param __ydest Y destination.
	 * @param __anch Anchor.
	 * @param __wdest W destination.
	 * @param __hdest H destination.
	 * @param __dswap Swap destinations on rotate?
	 * @throws IllegalArgumentException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/18
	 */
	private final void __drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest, boolean __dswap)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		// Is alpha used?
		boolean alpha = __src.hasAlpha();
		
		// Extract image pixel data
		int numpixels = __wsrc * __hsrc;
		int[] data = new int[numpixels];
		__src.getRGB(data, 0, __wsrc, __xsrc, __ysrc, __wsrc, __hsrc);
		
		// Perform the transformation, possibly returning a new data buffer
		int[] transdim = new int[]{__wsrc, __hsrc, __wdest, __hdest};
		data = this.__transform(__trans, data, __wsrc, __hsrc, transdim,
			__dswap);
		
		// Re-read the new image sizes!
		__wsrc = transdim[0];
		__hsrc = transdim[1];
		__wdest = transdim[2];
		__hdest = transdim[3];
		
		// Anchor horizontally?
		if ((__anch & Graphics.HCENTER) == Graphics.HCENTER)
			__xdest -= __wdest >> 1;
		
		// Anchor right?
		else if ((__anch & Graphics.RIGHT) == Graphics.RIGHT)
			__xdest -= __wdest;
		
		// Anchor middle?
		if ((__anch & Graphics.VCENTER) == Graphics.VCENTER)
			__ydest -= __hdest >> 1;
		
		// Anchor bottom?
		else if ((__anch & Graphics.BOTTOM) == Graphics.BOTTOM)
			__ydest -= __hdest;
		
		// If this is non-stretched we can just use the standard RGB
		// drawing function!
		if (__wsrc == __wdest && __hsrc == __hdest)
			this.drawRGB(data, 0, __wsrc, __xdest, __ydest, __wsrc, __hsrc,
				alpha);
		
		// Use stretchy draw
		else
			this.__drawRGBStretched(data, 0, __wsrc, __xdest, __ydest,
				__wsrc, __hsrc, alpha, __wdest, __hdest);
	}
	
	/**
	 * Draws stretched RGB.
	 *
	 * @param __data The data to draw.
	 * @param __off The offset into the array.
	 * @param __scanlen The scan length.
	 * @param __x X position.
	 * @param __y Y position.
	 * @param __wsrc Width of source.
	 * @param __hsrc Height of source.
	 * @param __alpha Use alpha channel?
	 * @param __wdest Width of destination.
	 * @param __hdest Height of destination.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private void __drawRGBStretched(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __wsrc, int __hsrc, boolean __alpha,
		int __wdest, int __hdest)
		throws NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		this.__unimplemented(__x, __y, "drawRGBStretched");
	}
	
	/**
	 * Draws the given text object.
	 *
	 * @param __t The text object to draw.
	 * @param __x The X position.
	 * @param __y The Y position.
	 * @param __anchor The, this just adjusts determines how the actual text
	 * box region is drawn. If baseline is used, Y is just offset by the
	 * baseline for the first character and not the entire block size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	final void __drawText(Text __t, int __x, int __y, int __anchor)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Translate to the displayed coordinate space
		__x += this.transx;
		__y += this.transy;
		
		// Setup text state
		__TextState__ ts = new __TextState__();
		
		// Anchoring
		ts.textw = __t.getWidth();
		ts.texth = __t.getHeight();
		if ((__anchor & Graphics.RIGHT) != 0)
			__x -= ts.textw;
		else if ((__anchor & Graphics.HCENTER) != 0)
			__x -= (ts.textw >> 1);
		if ((__anchor & Graphics.BOTTOM) != 0)
			__y -= ts.texth;
		else if ((__anchor & Graphics.VCENTER) != 0)
			__y -= (ts.texth >> 1);
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex - 1,
			clipey = this.clipey - 1;
		
		// Wanting to draw a bunch of text completely out of the clip? Ignore
		if (__x >= clipex || __y >= clipey)
			return;
		
		// Trying to draw the text completely out of the clip as well?
		ts.tex = __x + ts.textw;
		ts.tey = __y + ts.texth;
		if (ts.tex < clipsx || ts.tey < clipsy)
			return;
		
		// The text box acts as an extra clip, so force everything to clip
		// in there
		if (__x > clipsx)
			clipsx = __x;
		if (ts.tex < clipex)
			clipex = ts.tex;
		if (__y > clipsy)
			clipsy = __y;
		if (ts.tey < clipey)
			clipey = ts.tey;
		
		// Cache the default font in the event it is never changed ever
		Font lastfont = __t.getFont();
		SQFFont sqf = SQFFont.cacheFont(lastfont);
		byte[] bmp = new byte[sqf.charbitmapsize];
		int pixelheight = sqf.pixelheight,
			bitsperscan = sqf.bitsperscan;
		
		// Background color to use
		int bgcol = __t.getBackgroundColor();
		boolean hasbg = ((bgcol & 0xFF_000000) != 0);
		
		// Need to store the properties since drawing of the text will
		// change how characters are drawn
		ts.oldcolor = this.getAlphaColor();
		try
		{
			// Read in all the text characters
			int n = __t.getTextLength();
			String chars = __t.getText(0, n);
			
			// Draw each character according to their metrics
			for (int i = 0; i < n; i++)
			{
				// Ignore certain characters
				char c = chars.charAt(i);
				if (c == '\r' || c == '\n')
					continue;
				
				// Need to find the SQF for this font again?
				Font drawfont = __t.getFont(i);
				if (drawfont != lastfont)
				{
					lastfont = drawfont;
					sqf = SQFFont.cacheFont(lastfont);
					bmp = new byte[sqf.charbitmapsize];
					pixelheight = sqf.pixelheight;
					bitsperscan = sqf.bitsperscan;
				}
				
				// Get the metrics for the character
				__t.getCharExtent(i, ts.metrics);
				
				// Calculate the draw position of the character
				int dsx = __x + ts.metrics[0];
				int dsy = __y + ts.metrics[1];
				int dex = dsx + ts.metrics[2];
				int dey = dsy + ts.metrics[3];
				
				// Completely out of bounds, ignore because we cannot draw it
				// anyway
				if (dsx >= clipex || dex <= 0 ||
					dsy >= clipey || dey <= 0)
					continue;
				
				// Map character index to the SQF
				char mc = SQFFont.mapChar(c);
				
				// Base scan offsets and such
				int scanoff = 0,
					scanlen = sqf.charWidth(mc),
					lineoff = 0,
					linelen = pixelheight;
				
				// Off the left side?
				if (dsx < clipsx)
				{
					int diff = clipsx - dsx;
					scanoff += diff;
					scanlen -= diff;
					
					// Reset to clip bound
					dsx = clipsx;
				}
				
				// Off the right side
				if (dex > clipex)
					scanlen -= (dex - clipex);
				
				// Off the top?
				if (dsy < clipsy)
				{
					int diff = clipsy - dsy;
					lineoff += diff;
					linelen -= diff;
					
					// Reset to clip bound
					dsy = clipsy;
				}
				
				// Off the bottom
				if (dey > clipey)
					linelen -= (dey - clipey);
				
				// Load the character bitmap
				int bps = sqf.loadCharBitmap(mc, bmp);
				
				// Draw background?
				if (hasbg)
				{
					// Set needed color
					this.setAlphaColor(bgcol);
					
					// Perform draw operation
					this.funcfillrect.function(this, ts.loadIntArgs(dsx, dsy,
						dsx + (scanlen - scanoff), dsy + (linelen - lineoff),
						scanlen - scanoff, linelen - lineoff), ts.chobj);
				}
				
				// Set color to the foreground color of this character
				this.setAlphaColor(__t.getForegroundColor(i));
				
				// Setup the draw and do it
				this.funccharbmp.function(this, ts.loadIntArgs(this.color, dsx, dsy,
					bps, scanoff, scanlen, lineoff, linelen),
					ts.loadObject(bmp));
			}
		}
		
		// Just in case revert properties
		finally
		{
			this.setAlphaColor(ts.oldcolor);
		}
	}
	
	/**
	 * Draw a string which just says not implemented.
	 *
	 * @param __x X Coordinate.
	 * @param __y Y Coordinate.
	 * @param __txt The message text.
	 * @since 2019/03/25
	 */
	private final void __unimplemented(int __x, int __y, String __txt)
		throws NullPointerException
	{
		if (__txt == null)
			throw new NullPointerException("NARG");
		
		// Just draw crosshair and a string
		this.drawLine(__x - 5, __y, __x + 5, __y);
		this.drawLine(__x, __y - 5, __x, __y + 5);
		this.drawString(__txt, __x, __y, 0);
	}
	
	/**
	 * Updates the graphics drawing functions to what is needed.
	 *
	 * @since 2019/03/24
	 */
	private final void __updateFunctions()
	{
		boolean doblending = this.doblending,
			dotstroke = this.dotstroke;
		int blendmode = this.blendmode;
		
		// Blending
		if (doblending)
		{
			this.funcfillrect = AdvancedFunction.FILLRECT_BLEND;
			this.funccharbmp = AdvancedFunction.CHARBITMAP_BLEND;
			this.funcrgbtile = AdvancedFunction.RGBTILE_BLEND;
			this.funcargbtile = AdvancedFunction.ARGBTILE_BLEND;
			
			// Dotted
			if (dotstroke)
			{
				this.funcline = AdvancedFunction.LINE_BLEND_DOT;
			}
			
			// Not dotted
			else
			{
				this.funcline = AdvancedFunction.LINE_BLEND_NODOT;
			}
		}
		
		// Not blending
		else
		{
			this.funcfillrect = AdvancedFunction.FILLRECT_NOBLEND;
			this.funccharbmp = AdvancedFunction.CHARBITMAP_NOBLEND;
			this.funcrgbtile = AdvancedFunction.RGBTILE_NOBLEND;
			this.funcargbtile = AdvancedFunction.ARGBTILE_NOBLEND;
			
			// Dotted
			if (dotstroke)
			{
				this.funcline = AdvancedFunction.LINE_NOBLEND_DOT;
			}
			
			// Not dotted
			else
			{
				this.funcline = AdvancedFunction.LINE_NOBLEND_NODOT;
			}
		}
	}
	
	/**
	 * Determines the Cohen-Sutherland clipping flags.
	 *
	 * @param __x Input X coordinate.
	 * @param __y Input Y coordinate.
	 * @param __csx Clipping box starting X.
	 * @param __csy Clipping box starting Y.
	 * @param __cex Clipping box ending X.
	 * @param __cey Clipping box ending Y.
	 * @return The clipping bit flags.
	 * @since 2017/09/10
	 */
	private static final int __csOut(int __x, int __y, int __csx, int __csy,
		int __cex, int __cey)
	{
		int rv = 0;
		
		// Clips above or below?
		if (__y > __cey)
			rv |= AdvancedGraphics._CLIP_ABOVE;
		else if (__y < __csy)
			rv |= AdvancedGraphics._CLIP_BELOW;
		
		// Clips right or left?
		if (__x > __cex)
			rv |= AdvancedGraphics._CLIP_RIGHT;
		else if (__x < __csx)
			rv |= AdvancedGraphics._CLIP_LEFT;
		
		return rv;
	}
	
	/**
	 * Transforms the data in the buffer.
	 *
	 * @param __trans The transformation to perform.
	 * @param __data The input data.
	 * @param __wsrc The width of the source.
	 * @param __hsrc The width of the destination.
	 * @param __dimout Output dimensions.
	 * @param __dswap Swap destinations?
	 * @return The resulting data is translated, this may be the same as
	 * {@code __data}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private static final int[] __transform(int __trans, int[] __data,
		int __wsrc, int __hsrc, int[] __dimout, boolean __dswap)
		throws NullPointerException
	{
		if (__data == null || __dimout == null)
			throw new NullPointerException("NARG");
		
		// Destination width and height
		int wdest = __wsrc,
			hdest = __hsrc;
		
		// Determine the transformation functions to use. There are just three
		// primitive transformation functions: flip horizontally, then
		// flip vertically, then rotate 90 degrees clockwise. This handles
		// every transformation which fill every single bit.
		byte xform = 0;
		switch (__trans)
		{
			// These bits represent the stuff to do! == 0b9VH;
			case Sprite.TRANS_NONE:				xform = 0b000; break;
			case Sprite.TRANS_MIRROR:			xform = 0b001; break;
			case Sprite.TRANS_MIRROR_ROT180:	xform = 0b010; break;
			case Sprite.TRANS_ROT180:			xform = 0b011; break;
			case Sprite.TRANS_ROT90:			xform = 0b100; break;
			case Sprite.TRANS_MIRROR_ROT90:		xform = 0b101; break;
			case Sprite.TRANS_MIRROR_ROT270:	xform = 0b110; break;
			case Sprite.TRANS_ROT270:			xform = 0b111; break;
			// These bits represent the stuff to do! == 0b9VH;
		}
		
		// Mirror horizontally?
		if ((xform & 0b001) != 0)
			for (int y = 0; y < hdest; y++)
			{
				int dx = wdest * y,
					de = (dx + wdest) - 1;
				for (int x = 0, n = (wdest >> 1); x < n; x++)
				{
					int t = __data[de];
					__data[de--] = __data[dx];
					__data[dx++] = t;
				}
			}
		
		// Mirror vertically?
		if ((xform & 0b010) != 0)
			for (int ya = 0, yn = __hsrc >> 1; ya < yn; ya++)
			{
				int ra = __wsrc * ya,
					rb = (__wsrc * (__hsrc - ya)) - __wsrc;
				
				// Flip
				for (int x = 0; x < __wsrc; x++)
				{
					int t = __data[rb];
					__data[rb++] = __data[ra];
					__data[ra++] = t;
				}
			}
		
		// Rotate 90 degrees clockwise
		if ((xform & 0b100) != 0)
		{
			// Original copy
			int[] orig = __data.clone();
			
			// Swap the X and Y pixels first
			int ttop = hdest - 1;
			for (int y = 0; y < hdest; y++)
				for (int x = 0; x < wdest; x++)
				{
					int ps = (wdest * y) + x,
						pd = (hdest * x) + (ttop - y);
					
					__data[pd] = orig[ps];
				}
			
			// The output width and height are flipped
			__dimout[0] = hdest;
			__dimout[1] = wdest;
			
			// Swap destinations as well?
			if (__dswap)
			{
				int t = __dimout[2];
				__dimout[2] = __dimout[3];
				__dimout[3] = t;
			}
		}
		
		// Otherwise use the same target dimensions
		else
		{
			__dimout[0] = wdest;
			__dimout[1] = hdest;
		}
		
		// Return the data
		return __data;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/BasicForwardingGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This forwards all calls to the specified graphics object, this is used to
 * prevent malicious classes from changing the graphics canvases and items
 * draw to.
 *
 * @since 2016/10/10
 */
public class BasicForwardingGraphics
	extends Graphics
{
	/** The graphics to forward to. */
	protected final Graphics graphics;
	
	/**
	 * Initializes the forwarder.
	 *
	 * @param __g The graphics to draw to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/10
	 */
	BasicForwardingGraphics(Graphics __g)
		throws NullPointerException
	{
		// Check
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.graphics = __g;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void clipRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.clipRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void copyArea(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g)
	{
		this.graphics.copyArea(__a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		this.graphics.drawArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		this.graphics.drawARGB16(__data, __off, __scanlen, __x, __y, __w,
			__h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChar(char __a, int __b, int __c, int __d)
	{
		this.graphics.drawChar(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChars(char[] __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.drawChars(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawImage(Image __a, int __b, int __c, int __d)
	{
		this.graphics.drawImage(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawLine(int __a, int __b, int __c, int __d)
	{
		this.graphics.drawLine(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB(int[] __a, int __b, int __c, int __d, int __e,
		int __f, int __g, boolean __h)
	{
		this.graphics.drawRGB(__a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		this.graphics.drawRGB16(__data, __off, __scanlen, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.drawRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h, int __i)
	{
		this.graphics.drawRegion(__a, __b, __c, __d, __e, __f, __g, __h,
			__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __w, int __h, int __trans, int __xdest, int __ydest, int __anch,
		int __wdest, int __hdest)
	{
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __w, __h, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRoundRect(int __a, int __b, int __c, int __d,
		int __e,  int __f)
	{
		this.graphics.drawRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawString(String __a, int __b, int __c, int __d)
	{
		this.graphics.drawString(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawSubstring(String __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.drawSubstring(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		this.graphics.drawText(__t, __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		this.graphics.fillArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.fillRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRoundRect(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.fillRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillTriangle(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.fillTriangle(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getAlpha()
	{
		return this.graphics.getAlpha();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public int getAlphaColor()
	{
		return this.graphics.getAlphaColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlendingMode()
	{
		return this.graphics.getBlendingMode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlueComponent()
	{
		return this.graphics.getBlueComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipHeight()
	{
		return this.graphics.getClipHeight();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipWidth()
	{
		return this.graphics.getClipWidth();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipX()
	{
		return this.graphics.getClipX();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipY()
	{
		return this.graphics.getClipY();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getColor()
	{
		return this.graphics.getColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getDisplayColor(int __a)
	{
		return this.graphics.getDisplayColor(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public Font getFont()
	{
		return this.graphics.getFont();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGrayScale()
	{
		return this.graphics.getGrayScale();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGreenComponent()
	{
		return this.graphics.getGreenComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getRedComponent()
	{
		return this.graphics.getRedComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getStrokeStyle()
	{
		return this.graphics.getStrokeStyle();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateX()
	{
		return this.graphics.getTranslateX();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateY()
	{
		return this.graphics.getTranslateY();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlpha(int __a)
	{
		this.graphics.setAlpha(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		this.graphics.setAlphaColor(__argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
	{
		this.graphics.setAlphaColor(__a, __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setBlendingMode(int __m)
	{
		this.graphics.setBlendingMode(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setClip(int __a, int __b, int __c, int __d)
	{
		this.graphics.setClip(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a)
	{
		this.graphics.setColor(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a, int __b, int __c)
	{
		this.graphics.setColor(__a, __b, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setFont(Font __a)
	{
		this.graphics.setFont(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setGrayScale(int __a)
	{
		this.graphics.setGrayScale(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setStrokeStyle(int __a)
	{
		this.graphics.setStrokeStyle(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void translate(int __a, int __b)
	{
		this.graphics.translate(__a, __b);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/EnforcedDrawingAreaGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This is a graphics which enforces a translation and maximum drawing bounds
 * to a target graphics object.
 *
 * @since 2018/12/02
 */
public final class EnforcedDrawingAreaGraphics
	extends Graphics
{
	/** The graphics to draw into. */
	protected final Graphics graphics;
	
	/** The X translation. */
	protected final int x;
	
	/** The Y translation. */
	protected final int y;
	
	/** The width. */
	protected final int width;
	
	/** The height. */
	protected final int height;
	
	/** Draw X actual. */
	private int _dx;
	
	/** Draw Y actual. */
	private int _dy;
	
	/** Current X translation. */
	private int _transx;
	
	/** Current Y translation. */
	private int _transy;
	
	/** Clip X. */
	private int _clipx;
	
	/** Clip Y. */
	private int _clipy;
	
	/** Clip Width. */
	private int _clipw;
	
	/** Clip Height. */
	private int _cliph;
	
	/** Has this been initialized? */
	private boolean _beeninit;
	
	/**
	 * Initializes the enforced drawing area.
	 *
	 * @param __g The graphics to draw to.
	 * @param __x The X translation.
	 * @param __y The Y translation.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public EnforcedDrawingAreaGraphics(Graphics __g, int __x, int __y,
		int __w, int __h)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Clip in
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		this.graphics = __g;
		this.x = __x;
		this.y = __y;
		this.width = __w;
		this.height = __h;
		
		// Initialize our translation with our offsets
		this._transx = 0;
		this._transy = 0;
		this._dx = __x;
		this._dy = __y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void clipRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Translate
		__x += this._transx;
		__y += this._transy;
		
		// Our viewing area
		int vw = this.width,
			vh = this.height;
		
		// Calculate logical viewing area coordinates
		int lsx = __x,
			lsy = __y,
			lex = lsx + __w,
			ley = lsy + __h;
		
		// Get the original clipping bounds
		int csx = this._clipx,
			csy = this._clipy,
			cex = csx + this._clipw,
			cey = csy + this._cliph;
		
		// Clip coordinates via the old bounds
		if (lsx < csx)
			lsx = csx;
		if (lsy < csy)
			lsy = csy;
		if (lex > cex)
			lex = cex;
		if (ley > cey)
			ley = cey;
		
		// Determine logical clipping coordinates
		int clipx = lsx,
			clipy = lsy,
			clipw = lex - lsx,
			cliph = ley - lsy;
		
		// Store these for later clipRect() calls
		this._clipx = clipx;
		this._clipy = clipy;
		this._clipw = clipw;
		this._cliph = cliph;
		
		// Determine physical start coordinates
		int px = this.x + clipx,
			py = this.y + clipy;
		
		// Set the clipping area
		Graphics graphics = this.graphics;
		graphics.setClip(
			px - graphics.getTranslateX(), py - graphics.getTranslateY(),
			clipw, cliph);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.copyArea(this._dx + __sx, this._dy + __sy,
			__w, __h, this._dx + __dx, this._dy + __dy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawArc(this._dx + __x, this._dy + __y,
			__w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawARGB16(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawChar(char __s, int __x, int __y, int __anchor)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawChar(__s, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawChars(__s, __o, __l,
			this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawImage(__i, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawLine(this._dx + __x1, this._dy + __y1,
			this._dx + __x2, this._dy + __y2);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRGB(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h, __alpha);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRGB16(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRect(this._dx + __x, this._dy + __y,
			__w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc,
			__trans, this._dx + __xdest, this._dy + __ydest, __anch);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc,
			__trans, this._dx + __xdest, this._dy + __ydest, __anch,
			__wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRoundRect(this._dx + __x, this._dy + __y,
			__w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawString(__s, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawSubstring(__s, __o, __l,
			this._dx + __x, this._dy + __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawText(Text __t, int __x, int __y)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawText(__t, this._dx + __x, this._dy + __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillArc(this._dx + __x, this._dy + __y,
			__w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillRect(this._dx + __x, this._dy + __y,
			__w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillRoundRect(this._dx + __x, this._dy + __y,
			__w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		int x = this._transx, y = this._transy;
		this.graphics.fillTriangle(
			x + __x1, y + __y1,
			x + __x2, y + __y2,
			x + __x3, y + __y3);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getAlpha()
	{
		return this.graphics.getAlpha();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getAlphaColor()
	{
		return this.graphics.getAlphaColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getBlendingMode()
	{
		return this.graphics.getBlendingMode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getBlueComponent()
	{
		return this.graphics.getBlueComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipHeight()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipWidth()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipX()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipY()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getColor()
	{
		return this.graphics.getColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getDisplayColor(int __rgb)
	{
		return this.graphics.getDisplayColor(__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final Font getFont()
	{
		return this.graphics.getFont();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getGrayScale()
	{
		return this.graphics.getGrayScale();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getGreenComponent()
	{
		return this.graphics.getGreenComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getRedComponent()
	{
		return this.graphics.getRedComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getStrokeStyle()
	{
		return this.graphics.getStrokeStyle();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getTranslateX()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getTranslateY()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._transy;
	}
	
	/**
	 * Reclips the clipping area and sets up translation.
	 *
	 * @since 2018/12/02
	 */
	public final void initialize()
	{
		// Only initialize once
		if (this._beeninit)
			return;
		
		Graphics g = this.graphics;
		
		// Our viewing area
		int x = this.x,
			y = this.y,
			width = this.width,
			height = this.height;
		
		// Set new clipping area
		g.setClip(x, y, width, height);
		this._clipx = 0;
		this._clipy = 0;
		this._clipw = width;
		this._cliph = height;
		
		// Reset translation and draw position
		this._dx = x;
		this._dy = y;
		this._transx = 0;
		this._transy = 0;
		
		// Set as initialized
		this._beeninit = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.graphics.setAlpha(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlphaColor(int __argb)
	{
		this.graphics.setAlphaColor(__argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.graphics.setAlphaColor(__a, __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		this.graphics.setBlendingMode(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setClip(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Translate
		__x += this._transx;
		__y += this._transy;
		
		// Our viewing area
		int vw = this.width,
			vh = this.height;
		
		// Calculate logical viewing area coordinates
		int lsx = __x,
			lsy = __y,
			lex = lsx + __w,
			ley = lsy + __h;
		
		// Clip these coordinates into the logical viewing space
		if (lsx < 0)
			lsx = 0;
		if (lsy < 0)
			lsy = 0;
		if (lex > vw)
			lex = vw;
		if (ley > vh)
			ley = vh;
		
		// Determine logical clipping coordinates
		int clipx = lsx,
			clipy = lsy,
			clipw = lex - lsx,
			cliph = ley - lsy;
		
		// Store these for later clipRect() calls
		this._clipx = clipx;
		this._clipy = clipy;
		this._clipw = clipw;
		this._cliph = cliph;
		
		// Determine physical start coordinates
		int px = this.x + clipx,
			py = this.y + clipy;
		
		// Set the clipping area
		Graphics graphics = this.graphics;
		graphics.setClip(
			px - graphics.getTranslateX(), py - graphics.getTranslateY(),
			clipw, cliph);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setColor(int __rgb)
	{
		this.graphics.setColor(__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.graphics.setColor(__r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setFont(Font __f)
	{
		this.graphics.setFont(__f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setGrayScale(int __v)
	{
		this.graphics.setGrayScale(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setStrokeStyle(int __s)
		throws IllegalArgumentException
	{
		this.graphics.setStrokeStyle(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void translate(int __x, int __y)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Add our translation, we manage it ourselves
		int transx = this._transx + __x,
			transy = this._transy + __y;
		
		// Set our own translation but not to the target
		this._transx = transx;
		this._transy = transy;
		
		// Our draw offset is our offset and our own translation
		this._dx = this.x + transx;
		this._dy = this.y + transy;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/ForwardingGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This forwards graphical calls to the specified sub-class.
 *
 * This may be used to change for example the image to draw onto which will
 * have to be recreated if a canvas changes size.
 *
 * @since 2016/10/10
 */
public class ForwardingGraphics
	extends Graphics
{
	/** The graphics to forward to. */
	private Graphics _graphics;
	
	/** The blend mode. */
	private int _blendmode;

	/** The color. */
	private int _color;

	/** The font. */
	private Font _font;

	/** The clipping rectangle start. */
	private int _clipx, _clipy;
	
	/** The clip width. */
	private int _clipw =
		Integer.MAX_VALUE;
	
	/** The clip height. */
	private int _cliph =
		Integer.MAX_VALUE;

	/** The stroke. */
	private int _stroke;

	/** The translation coordinates. */
	private int _translatex, _translatey;
	
	/** Plain forwarder. */
	private Reference<Graphics> _plain;

	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		this.setClip(Math.max(__x, this.getClipX()),
			Math.max(__y, this.getClipY()),
			Math.min(__w, this.getClipWidth()),
			Math.min(__h, this.getClipHeight()));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void copyArea(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.copyArea(__a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawARGB16(__data, __off, __scanlen, __x, __y, __w,
			__h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChar(char __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawChar(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChars(char[] __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawChars(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawImage(Image __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawImage(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawLine(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawLine(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB(int[] __a, int __b, int __c, int __d, int __e,
		int __f, int __g, boolean __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRGB(__a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRGB16(__data, __off, __scanlen, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRect(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h, int __i)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRegion(__a, __b, __c, __d, __e, __f, __g, __h,
			__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __w, int __h, int __trans, int __xdest, int __ydest, int __anch,
		int __wdest, int __hdest)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRegion(__src, __xsrc, __ysrc, __w, __h, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRoundRect(int __a, int __b, int __c, int __d,
		int __e,  int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawString(String __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawString(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawSubstring(String __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawSubstring(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawText(__t, __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRect(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRoundRect(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillTriangle(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillTriangle(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Sets the graphics to forward to.
	 *
	 * The current graphical attributes will be copies to the target graphics
	 * if it has been set.
	 *
	 * @param __g Forwards to these graphics, {@code null} clears the
	 * forwarding.
	 * @since 2016/10/10
	 */
	public void forwardGraphics(Graphics __g)
	{
		// Set new
		this._graphics = __g;
		
		// Set all drawing state, so it appears seamless
		if (__g != null)
		{
			__g.setBlendingMode(this._blendmode);
			__g.setAlphaColor(this._color);
			__g.setFont(this._font);
			__g.setClip(this._clipx, this._clipy, this._clipw, this._clipy);
			__g.setStrokeStyle(this._stroke);
			__g.translate(this._translatex - __g.getTranslateX(),
				this._translatey - __g.getTranslateY());
		}
	}
	
	/**
	 * Creates a graphics instance which just forwards to this forwarder.
	 *
	 * @return The graphics which forwards to this.
	 * @since 2016/10/10
	 */
	public Graphics forwardPlainGraphics()
	{
		Reference<Graphics> ref = this._plain;
		Graphics rv;
		
		// Initialize?
		if (ref == null || null == (rv = ref.get()))
			this._plain = new WeakReference<>(
				rv = new BasicForwardingGraphics(this));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getAlpha()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getAlpha();
		
		// Stored?
		return (this._color >>> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public int getAlphaColor()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getAlpha();
		
		// Stored?
		return this._color;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlendingMode()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getBlendingMode();
		
		// Stored?
		return this._blendmode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlueComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getBlueComponent();
		
		// Stored?
		return this._color & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipHeight()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipHeight();
		
		// Stored?
		return this._cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipWidth()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipWidth();
		
		// Stored?
		return this._clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipX()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipX();
		
		// Stored?
		return this._clipx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipY()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipY();
		
		// Stored?
		return this._clipy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getColor()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getColor();
		
		// Stored?
		return this._color & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getDisplayColor(int __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getDisplayColor(__a);
		
		// Since no graphics is bound, this is unknown so return the original
		// value
		return __a & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public Font getFont()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getFont();
		
		// Stored?
		return this._font;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGrayScale()
	{
		// Average all channels
		return ((this.getRedComponent() & 0xFF) +
			(this.getGreenComponent() & 0xFF) +
			(this.getBlueComponent() & 0xFF)) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGreenComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getGreenComponent();
		
		// Stored?
		return (this._color >>> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getRedComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getRedComponent();
		
		// Stored?
		return (this._color >>> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getStrokeStyle()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getStrokeStyle();
		
		// Stored?
		return this._stroke;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateX()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getTranslateX();
		
		// Stored?
		return this._translatex;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateY()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getTranslateY();
		
		// Stored?
		return this._translatey;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlpha(int __a)
	{
		this.setAlphaColor(__a, this.getRedComponent(), this.getGreenComponent(),
			this.getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setAlphaColor(__argb);
		
		// Store
		this._color = __argb;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
	{
		this.setAlphaColor(((__a & 0xFF) << 24) |
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setBlendingMode(int __m)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setBlendingMode(__m);
		
		// Set
		this._blendmode = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setClip(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setClip(__a, __b, __c, __d);
		
		// Set
		this._clipx = __a;
		this._clipy = __b;
		this._clipw = __c;
		this._cliph = __d;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a)
	{
		this.setAlphaColor((__a & 0xFFFFFF) | ((this.getAlpha() & 0xFF) << 24));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a, int __b, int __c)
	{
		this.setAlphaColor(this.getAlpha(), __a, __b, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setFont(Font __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setFont(__a);
		
		// Store
		this._font = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setGrayScale(int __a)
	{
		this.setColor(__a, __a, __a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setStrokeStyle(int __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setStrokeStyle(__a);
		
		// Store
		this._stroke = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void translate(int __a, int __b)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.translate(__a, __b);
		
		// Store
		this._translatex = this.getTranslateX();
		this._translatey = this.getTranslateY();
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/GraphicsFunction.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This represents a graphical function.
 *
 * @since 2018/11/19
 */
public enum GraphicsFunction
{
	/** Set color. */
	SET_COLOR,
	
	/** Draw line. */
	DRAW_LINE,
	
	/** Get the X clip. */
	GET_CLIP_X,
	
	/** Get the Y clip. */
	GET_CLIP_Y,
	
	/** Get the width clip. */
	GET_CLIP_WIDTH,
	
	/** Get the height clip. */
	GET_CLIP_HEIGHT,
	
	/** Set the clip. */
	SET_CLIP,
	
	/** Draw rectangle. */
	DRAW_RECT,
	
	/** Get the alpha color. */
	GET_ALPHA_COLOR,
	
	/** Set the alpha color. */
	SET_ALPHA_COLOR,
	
	/** Fill rectangle. */
	FILL_RECT,
	
	/** Sets the fonts for the graphics. */
	SET_FONT,
	
	/** Gets the font to use for drawing. */
	GET_FONT,
	
	/** Draw sub-characters. */
	DRAW_SUB_CHARS,
	
	/** Draw text. */
	DRAW_TEXT,
	
	/** Get stroke style. */
	GET_STROKE_STYLE,
	
	/** Set stroke style. */
	SET_STROKE_STYLE,
	
	/** Copy area. */
	COPY_AREA,
	
	/** Draw arc. */
	DRAW_ARC,
	
	/** Draw ARGB16. */
	DRAW_ARGB16,
	
	/** Draw character. */
	DRAW_CHAR,
	
	/** Draw characters. */
	DRAW_CHARS,
	
	/** Draw RGB. */
	DRAW_RGB,
	
	/** Draw RGB16. */
	DRAW_RGB16,
	
	/** Draw round rectangle. */
	DRAW_ROUND_RECT,
	
	/** Fill arc. */
	FILL_ARC,
	
	/** Fill round rectangle. */
	FILL_ROUND_RECT,
	
	/** Fill triangle. */
	FILL_TRIANGLE,
	
	/** Get blending mode. */
	GET_BLENDING_MODE,
	
	/** Get display color. */
	GET_DISPLAY_COLOR,
	
	/** Set blending mode. */
	SET_BLENDING_MODE,
	
	/** Draw region. */
	DRAW_REGION,
	
	/** End. */
	;
	
	/**
	 * Returns the graphics function for the given ID.
	 *
	 * @param __id The ID to translate.
	 * @return The function for the ID.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2018/11/19
	 */
	public static GraphicsFunction of(int __id)
		throws IllegalArgumentException
	{
		// Depends
		switch (__id)
		{
			case 0:		return GraphicsFunction.SET_COLOR;
			case 1:		return GraphicsFunction.DRAW_LINE;
			case 2:		return GraphicsFunction.GET_CLIP_X;
			case 3:		return GraphicsFunction.GET_CLIP_Y;
			case 4:		return GraphicsFunction.GET_CLIP_WIDTH;
			case 5:		return GraphicsFunction.GET_CLIP_HEIGHT;
			case 6:		return GraphicsFunction.SET_CLIP;
			case 7:		return GraphicsFunction.DRAW_RECT;
			case 8:		return GraphicsFunction.GET_ALPHA_COLOR;
			case 9:		return GraphicsFunction.SET_ALPHA_COLOR;
			case 10:	return GraphicsFunction.FILL_RECT;
			case 11:	return GraphicsFunction.SET_FONT;
			case 12:	return GraphicsFunction.GET_FONT;
			case 13:	return GraphicsFunction.DRAW_SUB_CHARS;
			case 14:	return GraphicsFunction.DRAW_TEXT;
			case 15:	return GraphicsFunction.GET_STROKE_STYLE;
			case 16:	return GraphicsFunction.SET_STROKE_STYLE;
			case 17:	return GraphicsFunction.COPY_AREA;
			case 18:	return GraphicsFunction.DRAW_ARC;
			case 19:	return GraphicsFunction.DRAW_ARGB16;
			case 20:	return GraphicsFunction.DRAW_CHAR;
			case 21:	return GraphicsFunction.DRAW_CHARS;
			case 22:	return GraphicsFunction.DRAW_RGB;
			case 23:	return GraphicsFunction.DRAW_RGB16;
			case 24:	return GraphicsFunction.DRAW_ROUND_RECT;
			case 25:	return GraphicsFunction.FILL_ARC;
			case 26:	return GraphicsFunction.FILL_ROUND_RECT;
			case 27:	return GraphicsFunction.FILL_TRIANGLE;
			case 28:	return GraphicsFunction.GET_BLENDING_MODE;
			case 29:	return GraphicsFunction.GET_DISPLAY_COLOR;
			case 30:	return GraphicsFunction.SET_BLENDING_MODE;
			case 31:	return GraphicsFunction.DRAW_REGION;
				
				// {@squirreljme.error EB0j Invalid graphics function.
				// (The function ID)}
			default:
				throw new IllegalArgumentException("EB0j " + __id);
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/PixelFormat.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.jvm.Framebuffer;
import javax.microedition.lcdui.Graphics;

/**
 * This represents the pixel format that is used.
 *
 * @since 2018/03/24
 */
public enum PixelFormat
{
	/** Byte Packed Indexed, 1-bit. */
	BYTE_INDEXED1,
	
	/** Byte Packed Indexed, 2-bit. */
	BYTE_INDEXED2,
	
	/** Byte Packed Indexed, 4-bit. */
	BYTE_INDEXED4,
	
	/** Byte Indexed. */
	BYTE_INDEXED8,
	
	/** Byte RGB332. */
	BYTE_RGB332,
	
	/** Short Indexed. */
	SHORT_INDEXED16,
	
	/** Short ARGB4444. */
	SHORT_ARGB4444,
	
	/** Short RGB565. */
	SHORT_RGB565,
	
	/** Integer ARGB8888. */
	INTEGER_ARGB8888,
	
	/** Integer RGB888. */
	INTEGER_RGB888,
	
	/** End. */
	;
	
	/**
	 * Creates an array buffer which is capable of containing an image of
	 * the specified size.
	 *
	 * @param __p The buffer pitch.
	 * @param __h The buffer height.
	 * @return The created buffer.
	 * @since 2018/03/28
	 */
	public final Object createBuffer(int __p, int __h)
	{
		// Depends on the format
		int dim = __p * __h;
		switch (this)
		{
			case BYTE_INDEXED1:
				return new byte[dim / 8];
					
			case BYTE_INDEXED2:
				return new byte[dim / 4];
					
			case BYTE_INDEXED4:
				return new byte[dim / 2];
					
			case BYTE_INDEXED8:
			case BYTE_RGB332:
				return new byte[dim];
					
			case SHORT_INDEXED16:
			case SHORT_ARGB4444:
			case SHORT_RGB565:
				return new short[dim];
			
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return new int[dim];
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Creates the graphics object for drawing graphics, no absolute
	 * translation is used for the graphics.
	 *
	 * @param __buf The buffer to send the result into after drawing.
	 * @param __pal The palette to use for the remote buffer.
	 * @param __bw The buffer width.
	 * @param __bh The buffer height.
	 * @param __alpha Is an alpha channel being used?
	 * @param __pitch The number of elements for the width in the buffer.
	 * @param __offset The offset into the buffer to the actual image data.
	 * @return The graphics object for drawing graphics.
	 * @throws ClassCastException If the class type of the input pixels is not
	 * an array of the expected type.
	 * @throws NullPointerException On null arguments except for {@code __pal}
	 * unless an indexed mode is used.
	 * @since 2018/03/28
	 */
	public final Graphics createGraphics(Object __buf,
		int[] __pal, int __bw, int __bh, boolean __alpha, int __pitch,
		int __offset)
		throws ClassCastException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		return this.createGraphics(__buf, __pal, __bw, __bh, __alpha,
			__pitch, __offset, 0, 0);
	}
	
	/**
	 * Creates the graphics object for drawing graphics.
	 *
	 * @param __buf The buffer to send the result into after drawing.
	 * @param __pal The palette to use for the remote buffer.
	 * @param __bw The buffer width.
	 * @param __bh The buffer height.
	 * @param __alpha Is an alpha channel being used?
	 * @param __pitch The number of elements for the width in the buffer.
	 * @param __offset The offset into the buffer to the actual image data.
	 * @param __atx Absolute X translation.
	 * @param __aty Absolute Y translation.
	 * @return The graphics object for drawing graphics.
	 * @throws ClassCastException If the class type of the input pixels is not
	 * an array of the expected type.
	 * @throws NullPointerException On null arguments except for {@code __pal}
	 * unless an indexed mode is used.
	 * @since 2018/03/28
	 */
	public final Graphics createGraphics(Object __buf,
		int[] __pal, int __bw, int __bh, boolean __alpha, int __pitch,
		int __offset, int __atx, int __aty)
		throws ClassCastException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		// Initialize graphics according to the pixel type
		switch (this)
		{
			case INTEGER_ARGB8888:
				return new AdvancedGraphics((int[])__buf, true, null,
					__bw, __bh, __pitch, __offset, __atx, __aty);
			
			case INTEGER_RGB888:
				return new AdvancedGraphics((int[])__buf, false, null,
					__bw, __bh, __pitch, __offset, __atx, __aty);
			
			default:
				throw new todo.OOPS(this.toString());
		}
	}
	
	/**
	 * Returns the number of alpha levels.
	 *
	 * @return The number of alpha levels.
	 * @since 2019/05/05
	 */
	public final int numAlphaLevels()
	{
		switch (this)
		{
			case BYTE_INDEXED1:
			case BYTE_INDEXED2:
			case BYTE_INDEXED4:
			case BYTE_INDEXED8:
			case SHORT_INDEXED16:
			case BYTE_RGB332:
			case SHORT_RGB565:
			case INTEGER_RGB888:
				return 0;
				
			case SHORT_ARGB4444:
				return 16;
				
			case INTEGER_ARGB8888:
				return 256;
			
				// Unknown
			default:
				throw new todo.OOPS(this.name());
		}
	}
	
	/**
	 * Returns the number of possible colors.
	 *
	 * @return The number of possible colors.
	 * @since 2019/05/05
	 */
	public final int numColors()
	{
		switch (this)
		{
			case BYTE_INDEXED1:
				return 2;
				
			case BYTE_INDEXED2:
				return 4;
				
			case BYTE_INDEXED4:
				return 16;
				
			case BYTE_INDEXED8:
			case BYTE_RGB332:
				return 256;
				
			case SHORT_ARGB4444:
				return 4096;
				
			case SHORT_INDEXED16:
			case SHORT_RGB565:
				return 65536;
				
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return 16777216;
			
				// Unknown
			default:
				throw new todo.OOPS(this.name());
		}
	}
	
	/**
	 * Maps the pixel format ID to the pixel format type.
	 *
	 * @param __id The input ID.
	 * @return The pixel format for the ID.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2018/11/18
	 */
	public static final PixelFormat of(int __id)
		throws IllegalArgumentException
	{
		switch (__id)
		{
			case 0:		return PixelFormat.BYTE_INDEXED1;
			case 1:		return PixelFormat.BYTE_INDEXED2;
			case 2:		return PixelFormat.BYTE_INDEXED4;
			case 3:		return PixelFormat.BYTE_INDEXED8;
			case 4:		return PixelFormat.BYTE_RGB332;
			case 5:		return PixelFormat.SHORT_INDEXED16;
			case 6:		return PixelFormat.SHORT_ARGB4444;
			case 7:		return PixelFormat.SHORT_RGB565;
			case 8:		return PixelFormat.INTEGER_ARGB8888;
			case 9:		return PixelFormat.INTEGER_RGB888;
			
				// {@squirreljme.error EB0k Unknown pixel buffer format. (ID)}
			default:
				throw new IllegalArgumentException("EB0k " + __id);
		}
	}
	
	/**
	 * Returns the pixel format used for the native framebuffer.
	 *
	 * @param __id The format ID.
	 * @return The associated pixel format.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2020/01/12
	 */
	public static final PixelFormat ofFramebuffer(int __id)
		throws IllegalArgumentException
	{
		switch (__id)
		{
			case Framebuffer.FORMAT_INTEGER_RGB888:
				return PixelFormat.INTEGER_RGB888;
			
			case Framebuffer.FORMAT_BYTE_INDEXED:
				return PixelFormat.BYTE_INDEXED8;
			
			case Framebuffer.FORMAT_SHORT_RGB565:
				return PixelFormat.SHORT_RGB565;
			
			case Framebuffer.FORMAT_PACKED_ONE:
				return PixelFormat.BYTE_INDEXED1;
				
			case Framebuffer.FORMAT_PACKED_TWO:
				return PixelFormat.BYTE_INDEXED2;
				
			case Framebuffer.FORMAT_PACKED_FOUR:
				return PixelFormat.BYTE_INDEXED4;
			
				// {@squirreljme.error EB3a Unknown frame buffer pixel buffer
				// format. (ID}}
			default:
				throw new IllegalArgumentException("EB3a " + __id);
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/SerializedGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This class takes any input graphics operations that were performed for it,
 * serializing anything that was sent to it. The serialized graphics can be
 * forwarded somewhere for example for later deserialization.
 *
 * Translation is performed locally to the graphics and wherever the graphics
 * target is, it will not have translation forwarded and serialized to simplify
 * the target.
 *
 * @since 2018/11/19
 */
public abstract class SerializedGraphics
	extends Graphics
{
	/** X translation. */
	protected int transx;
	
	/** Y translation. */
	protected int transy;

	/**
	 * This method is called for any operation which serializes to graphics.
	 *
	 * @param __func The graphics operation to perform.
	 * @param __args The input arguments to the function.
	 * @return Any result from the operation.
	 * @since 2018/11/19
	 */
	public abstract Object serialize(GraphicsFunction __func,
		Object... __args);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Calculate the actual desired clip location
		int nx = __x + transx,
			ny = __y + transy,
			na = nx + __w,
			nb = ny + __h;
		
		// Get the current clip location
		int cx = this.__getClipX(),
			cy = this.__getClipY(),
			ca = cx + this.getClipWidth(),
			cb = cy + this.getClipHeight();
		
		// Use direct set clip but with the correct coordinates
		int bx = (nx > cx ? nx : cx),
			by = (ny > cy ? ny : cy);
		this.serialize(GraphicsFunction.SET_CLIP,
			bx,
			by,
			(na < ca ? na : ca) - bx,
			(nb < cb ? nb : cb) - by);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.COPY_AREA,
			__sx + transx, __sy + transy, __w, __h,
			__dx + transx, __dy + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ARC,
			__x + transx, __y + transy, __w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ARGB16,
			__data, __off, __scanlen, __x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawChar(char __s, int __x, int __y, int __anchor)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_CHAR,
			(int)__s, __x + transx, __y + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_CHARS,
			__s, __o, __l, __x + transx, __y + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__i, 0, 0, __i.getWidth(), __i.getHeight(), 0,
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_LINE,
			__x1 + transx, __y1 + transy, __x2 + transx, __y2 + transy);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RGB,
			__data, __off, __scanlen, __x + transx, __y + transy,
			__w, __h, (__alpha ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RGB16,
			__data, __off, __scanlen, __x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RECT,
			__x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wsrc, __hsrc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
			
		int transx = this.transx,
			transy = this.transy;
		
		// Extract image pixel data before sending over
		int numpixels = __wsrc * __hsrc;
		int[] data = new int[numpixels];
		__src.getRGB(data, 0, __wsrc, __xsrc, __ysrc, __wsrc, __hsrc);
		
		// {@squirreljme.error EB0l Illegal region draw.}
		int rv = (Integer)this.serialize(GraphicsFunction.DRAW_REGION,
			data, (__wsrc << 16) | __hsrc, __trans,
			__xdest + transx, __ydest + transy,
			__anch, (__wdest << 16) | __hdest);
		if (rv < 0)
			throw new IllegalArgumentException("EB0l");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ROUND_RECT,
			__x + transx, __y + transy, __w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Just pass the chars of the string since we cannot represent
		// string at all
		this.serialize(GraphicsFunction.DRAW_SUB_CHARS,
			__s.toCharArray(), 0, __s.length(), __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Just pass the chars of the string since we cannot represent
		// string at all
		this.serialize(GraphicsFunction.DRAW_SUB_CHARS,
			__s.toCharArray(), __o, __l, __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_TEXT,
			SerializedGraphics.textSerialize(__t), __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_ARC,
			__x, __y, __w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_RECT,
			__x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_ROUND_RECT,
			__x, __y, __w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_TRIANGLE,
			__x1, __y1, __x2, __y2, __x3, __y3);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getAlpha()
	{
		return (this.getAlphaColor() >> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getAlphaColor()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_ALPHA_COLOR);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getBlendingMode()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_BLENDING_MODE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getBlueComponent()
	{
		return (this.getAlphaColor()) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipHeight()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_HEIGHT);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipWidth()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_WIDTH);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipX()
	{
		return this.__getClipX() - this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipY()
	{
		return this.__getClipY() - this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getColor()
	{
		return this.getAlphaColor() & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getDisplayColor(int __rgb)
	{
		return (Integer)this.serialize(GraphicsFunction.GET_DISPLAY_COLOR,
			__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public Font getFont()
	{
		return SerializedGraphics.fontDeserialize(
			(byte[])this.serialize(GraphicsFunction.GET_FONT));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getGrayScale()
	{
		return (this.getRedComponent() + this.getGreenComponent() +
			this.getBlueComponent()) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getGreenComponent()
	{
		return (this.getAlphaColor() >> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getRedComponent()
	{
		return (this.getAlphaColor() >> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getStrokeStyle()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_STROKE_STYLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getTranslateX()
	{
		return this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getTranslateY()
	{
		return this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.setAlphaColor(__a, this.getRedComponent(),
			this.getGreenComponent(), this.getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		this.serialize(GraphicsFunction.SET_ALPHA_COLOR, __argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.serialize(GraphicsFunction.SET_ALPHA_COLOR,
			((__a & 0xFF) << 24) |
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0m Failed to set blending mode.}
		int okay = (Integer)this.serialize(GraphicsFunction.SET_BLENDING_MODE,
			__m);
		if (okay < 0)
			throw new IllegalArgumentException("EB0m");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setClip(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.SET_CLIP,
			__x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setColor(int __rgb)
	{
		this.serialize(GraphicsFunction.SET_COLOR, __rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.serialize(GraphicsFunction.SET_COLOR,
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setFont(Font __f)
	{
		// Default?
		if (__f == null)
			__f = Font.getDefaultFont();
		
		// Serialize it
		this.serialize(GraphicsFunction.SET_FONT,
			SerializedGraphics.fontSerialize(__f));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setGrayScale(int __v)
	{
		this.setAlphaColor(this.getAlpha(), __v, __v, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setStrokeStyle(int __s)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0n Failed to set stroke style.}
		int okay = (Integer)this.serialize(GraphicsFunction.SET_STROKE_STYLE,
			__s);
		if (okay < 0)
			throw new IllegalArgumentException("EB0n");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void translate(int __x, int __y)
	{
		this.transx += __x;
		this.transy += __y;
	}
	
	/**
	 * Returns the raw clipping X of the target.
	 *
	 * @return The target clipping.
	 * @since 2020/01/10
	 */
	private final int __getClipX()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_X);
	}
	
	/**
	 * Returns the raw clipping Y of the target.
	 *
	 * @return The target clipping.
	 * @since 2020/01/10
	 */
	private final int __getClipY()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_Y);
	}
	
	/**
	 * Deserializes the input operation arguments and performs the call on
	 * the destination graphics.
	 *
	 * @param __g The destination graphics object.
	 * @param __func The graphics function to call.
	 * @param __args Arguments to the function.
	 * @return The result of the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public static Object deserialize(Graphics __g, GraphicsFunction __func,
		Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		if (__g == null || __func == null)
			throw new NullPointerException("NARG");
		
		// Depends on the function
		switch (__func)
		{
			case SET_COLOR:
				__g.setColor(
					(Integer)__args[0]);
				return null;
			
			case DRAW_LINE:
				__g.drawLine(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
			
			case GET_CLIP_X:
				return __g.getClipX();
			
			case GET_CLIP_Y:
				return __g.getClipY();
			
			case GET_CLIP_WIDTH:
				return __g.getClipWidth();
			
			case GET_CLIP_HEIGHT:
				return __g.getClipHeight();
			
			case SET_CLIP:
				__g.setClip(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Draw rectangle
			case DRAW_RECT:
				__g.drawRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Get alpha color
			case GET_ALPHA_COLOR:
				return __g.getAlphaColor();
				
				// Set alpha color
			case SET_ALPHA_COLOR:
				__g.setAlphaColor((Integer)__args[0]);
				return null;
				
				// Fill rectangle
			case FILL_RECT:
				__g.fillRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Set font
			case SET_FONT:
				__g.setFont(SerializedGraphics.fontDeserialize(
					(byte[])__args[0]));
				return null;
				
				// Get font
			case GET_FONT:
				return SerializedGraphics.fontSerialize(__g.getFont());
				
				// Draw sub-characters
			case DRAW_SUB_CHARS:
				__g.drawChars(
					(char[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
				
				// Draw text
			case DRAW_TEXT:
				__g.drawText(
					SerializedGraphics.textDeserialize((byte[])__args[0]),
					(Integer)__args[1],
					(Integer)__args[2]);
				return null;
				
				// Get stroke style
			case GET_STROKE_STYLE:
				return __g.getStrokeStyle();
				
				// Set stroke style
			case SET_STROKE_STYLE:
				try
				{
					__g.setStrokeStyle((Integer)__args[0]);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
				
				// Copy area.
			case COPY_AREA:
				__g.copyArea(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw arc.
			case DRAW_ARC:
				__g.drawArc(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Draw ARGB16.
			case DRAW_ARGB16:
				__g.drawARGB16(
					(short[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw character.
			case DRAW_CHAR:
				__g.drawChar(
					(char)(((Integer)__args[0]).intValue()),
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
			
				// Draw characters.
			case DRAW_CHARS:
				__g.drawChars(
					(char[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Draw RGB.
			case DRAW_RGB:
				__g.drawRGB(
					(int[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6],
					(((Integer)__args[7]) != 0 ? true : false));
				return null;
			
				// Draw RGB16.
			case DRAW_RGB16:
				__g.drawRGB16(
					(short[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw round rectangle.
			case DRAW_ROUND_RECT:
				__g.drawRoundRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill arc.
			case FILL_ARC:
				__g.fillArc(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill round rectangle.
			case FILL_ROUND_RECT:
				__g.fillRoundRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill triangle.
			case FILL_TRIANGLE:
				__g.fillTriangle(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Get blending mode.
			case GET_BLENDING_MODE:
				return __g.getBlendingMode();
			
				// Get display color.
			case GET_DISPLAY_COLOR:
				return __g.getDisplayColor((Integer)__args[0]);
			
				// Set blending mode.
			case SET_BLENDING_MODE:
				try
				{
					__g.setBlendingMode((Integer)__args[0]);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
			
				// Draw region
			case DRAW_REGION:
				try
				{
					// Extract width/heights since they are combined here
					int sw = ((Integer)__args[1]) >>> 16,
						sh = ((Integer)__args[1]) & 0xFFFF,
						dw = ((Integer)__args[6]) >>> 16,
						dh = ((Integer)__args[6]) & 0xFFFF;
					
					// Note that the passed buffer only contains image data
					// from the source region, as such the source coordinates
					// will always be zero
					__g.drawRegion(Image.createRGBImage(
							(int[])__args[0], sw, sh, true),
						0, 0,
						sw, sh,
						(Integer)__args[2],
						(Integer)__args[3],
						(Integer)__args[4],
						(Integer)__args[5],
						dw, dh);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
			
			default:
				throw new todo.OOPS("" + __func);
		}
	}
	
	/**
	 * Deserializes the font.
	 *
	 * @param __b The input byte data.
	 * @return The resulting font.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Font fontDeserialize(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Deserialize all of the data
		try (ByteArrayInputStream bais = new ByteArrayInputStream(__b))
		{
			int style, pixelsize;
			String name;
			
			try (DataInputStream dis = new DataInputStream(bais))
			{
				style = dis.readInt();
				pixelsize = dis.readInt();
				name = dis.readUTF();
			}
			
			return Font.getFont(name, style, pixelsize);
		}
		
		// {@squirreljme.error EB0o Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0o", e);
		}
	}
	
	/**
	 * Deserializes the font.
	 *
	 * @param __dis The stream to read from.
	 * @return The deserialized font.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Font fontDeserialize(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read byte data
		int len = __dis.readUnsignedShort();
		byte[] ser = new byte[len];
		__dis.readFully(ser);
		return SerializedGraphics.fontDeserialize(ser);
	}
	
	/**
	 * Serializes the font.
	 *
	 * @param __f The font to serialize.
	 * @return The resulting byte data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static byte[] fontSerialize(Font __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Serialize all of the data
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(64))
		{
			try (DataOutputStream dos = new DataOutputStream(baos))
			{
				dos.writeInt(__f.getStyle());
				dos.writeInt(__f.getPixelSize());
				dos.writeUTF(__f.getFontName());
			}
			
			// Return it
			return baos.toByteArray();
		}
		
		// {@squirreljme.error EB0p Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0p", e);
		}
	}
	
	/**
	 * Serializes the font.
	 *
	 * @param __dos The stream to write to.
	 * @param __f The font to serialize.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static void fontSerialize(DataOutputStream __dos, Font __f)
		throws IOException, NullPointerException
	{
		if (__dos == null || __f == null)
			throw new NullPointerException("NARG");
		
		// Record data
		byte[] ser = SerializedGraphics.fontSerialize(__f);
		__dos.writeShort(ser.length);
		__dos.write(ser);
	}
	
	/**
	 * Deserializes the byte array to a {@link Text} object.
	 *
	 * @param __b The byte array to deserialize.
	 * @return The deserialized text.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Text textDeserialize(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Deserialize all of the data
		try (ByteArrayInputStream bais = new ByteArrayInputStream(__b))
		{
			Text rv = new Text();
			try (DataInputStream dis = new DataInputStream(bais))
			{
				rv.setWidth(dis.readInt());
				rv.setHeight(dis.readInt());
				rv.setAlignment(dis.readInt());
				rv.setBackgroundColor(dis.readInt());
				rv.setFont(SerializedGraphics.fontDeserialize(dis));
				rv.setForegroundColor(dis.readInt());
				rv.setIndent(dis.readInt());
				rv.setInitialDirection(dis.readInt());
				rv.setScrollOffset(dis.readInt());
				rv.setSpaceAbove(dis.readInt());
				rv.setSpaceBelow(dis.readInt());
				
				// Read length
				int n = dis.readInt();
				
				// Read in text string
				rv.insert(0, dis.readUTF());
				
				// Read all character properties
				for (int i = 0; i < n; i++)
				{
					rv.setForegroundColor(dis.readInt(), i, 1);
					
					// Was a font used?
					if (dis.readBoolean())
						rv.setFont(
							SerializedGraphics.fontDeserialize(dis), i, 1);
				}
				
				// And now that there is proper length
				rv.setCaret(dis.readInt());
				rv.setHighlight(dis.readInt(), dis.readInt());
			}
			
			// Return it
			return rv;
		}
		
		// {@squirreljme.error EB0q Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0q", e);
		}
	}
	
	/**
	 * Serializes the text object to a byte array.
	 *
	 * @param __t The text to serialize.
	 * @return The serialized byte array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static byte[] textSerialize(Text __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Serialize all of the data
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(4096))
		{
			try (DataOutputStream dos = new DataOutputStream(baos))
			{
				// Properties which do not need characters
				dos.writeInt(__t.getWidth());
				dos.writeInt(__t.getHeight());
				dos.writeInt(__t.getAlignment());
				dos.writeInt(__t.getBackgroundColor());
				SerializedGraphics.fontSerialize(dos, __t.getFont());
				dos.writeInt(__t.getForegroundColor());
				dos.writeInt(__t.getIndent());
				dos.writeInt(__t.getInitialDirection());
				dos.writeInt(__t.getScrollOffset());
				dos.writeInt(__t.getSpaceAbove());
				dos.writeInt(__t.getSpaceBelow());
				
				// Record length
				int n = __t.getTextLength();
				dos.writeInt(n);
				
				// Record the string
				dos.writeUTF(__t.getText(0, n));
				
				// Record all the character properties
				for (int i = 0; i < n; i++)
				{
					dos.writeInt(__t.getForegroundColor(i));
					
					// Font needs serialization
					Font f = __t.getFont(i);
					if (f == null)
						dos.writeBoolean(false);
					else
					{
						dos.writeBoolean(true);
						SerializedGraphics.fontSerialize(dos, f);
					}
				}
				
				// Depends on character stuff
				dos.writeInt(__t.getCaret());
				dos.writeInt(__t.getHighlightIndex());
				dos.writeInt(__t.getHighlightLength());
			}
			
			// Return it
			return baos.toByteArray();
		}
		
		// {@squirreljme.error EB0r Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0r", e);
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/__TextState__.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.gfx;

/**
 * This represents the state of the current text drawing.
 *
 * This is used to reduce pressure on the text drawing code because it is
 * complex.
 *
 * @since 2019/12/15
 */
final class __TextState__
{
	/** Metrics. */
	public final int[] metrics =
		new int[4];
	
	/** Integer arguments. */
	public final int[] chint =
		new int[8];
	
	/** Object argumnets. */
	public final Object[] chobj =
		new Object[1];
	
	/** The old color. */
	public int oldcolor;
	
	/** Text width/height. */
	public int textw, texth;
	
	/** Text end X/Y. */
	public int tex, tey;
	
	/**
	 * Loads integer arguments.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @param __c C.
	 * @param __d D.
	 * @param __e E.
	 * @param __f F.
	 * @return The integer array.
	 * @since 2019/12/15
	 */
	public final int[] loadIntArgs(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		int[] chint = this.chint;
		
		chint[0] = __a;
		chint[1] = __b;
		chint[2] = __c;
		chint[3] = __d;
		chint[4] = __e;
		chint[5] = __f;
		
		return chint;
	}
	
	/**
	 * Loads integer arguments.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @param __c C.
	 * @param __d D.
	 * @param __e E.
	 * @param __f F.
	 * @param __g G.
	 * @param __h H.
	 * @return The integer array.
	 * @since 2019/12/15
	 */
	public final int[] loadIntArgs(int __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h)
	{
		int[] chint = this.chint;
		
		chint[0] = __a;
		chint[1] = __b;
		chint[2] = __c;
		chint[3] = __d;
		chint[4] = __e;
		chint[5] = __f;
		chint[6] = __g;
		chint[7] = __h;
		
		return chint;
	}
	
	/**
	 * Loads object array.
	 *
	 * @param __a A.
	 * @return The object array.
	 * @since 2019/12/15
	 */
	public final Object[] loadObject(Object __a)
	{
		Object[] chobj = this.chobj;
		
		chobj[0] = __a;
		
		return chobj;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/gfx/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains implementations of the graphics drawing classes.
 *
 * @since 2017/08/19
 */

package cc.squirreljme.runtime.lcdui.gfx;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/ImageReaderDispatcher.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Image;

/**
 * This is used to dispatch to the correct parser when loading images.
 *
 * @since 2017/02/28
 */
public class ImageReaderDispatcher
{
	/**
	 * Not used.
	 *
	 * @since 2017/02/28
	 */
	private ImageReaderDispatcher()
	{
	}
	
	/**
	 * Parses the image stream.
	 *
	 * @param __is The stream to read from.
	 * @return The parsed image data.
	 * @throws IOException If it could not be parsed.
	 */
	public static Image parse(InputStream __is)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Mark header
		__is.mark(4);
		
		// Read in the header magic number
		int first = (__is.read() & 0xFF);
		int magic = (first << 24) |
			((__is.read() & 0xFF) << 16) |
			((__is.read() & 0xFF) << 8) |
			(__is.read() & 0xFF);
		
		// Reset for future read
		__is.reset();
		
		// GIF?
		if (magic == 0x47494638)
			throw new todo.TODO();
		
		// PNG?
		else if (magic == 0x89504E47)
			return new PNGReader(__is).parse();
		
		// JPEG?
		else if ((magic & 0xFFFFFF00) == 0xFFD8FF00)
			return new JPEGReader(__is).parse();
		
		// SVG?
		else if (first == '<')
			throw new todo.TODO();
		
		// XPM?
		else if (first == '/')
			return new XPMReader(__is).parse();
		
		// {@squirreljme.error EB0s Could not detect the image format used
		// specified by the starting byte. (The magic number; The first byte)}
		else
			throw new IOException(String.format("EB0s %08x %02x", magic,
				first));
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/JPEGReader.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.image;

import java.io.DataInputStream;
import java.io.InputStream;
import javax.microedition.lcdui.Image;

/**
 * This class is used to process JPEG image files.
 *
 * @since 2019/05/06
 */
public final class JPEGReader
{
	/** The input data. */
	protected final DataInputStream in;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public JPEGReader(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * Parses the JPEG.
	 *
	 * @return The resulting image.
	 * @since 2019/05/06
	 */
	public Image parse()
	{
		DataInputStream in = this.in;
		
		todo.TODO.note("Implement JPEG decoding");
		return Image.createRGBImage(new int[16], 4, 4, false);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/PNGReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.ChecksumInputStream;
import net.multiphasicapps.io.SizeLimitedInputStream;
import net.multiphasicapps.io.ZLibDecompressor;

/**
 * This class parses PNG images.
 *
 * PNG specifications:
 *  * http://www.libpng.org/pub/png/pngdocs.html
 *  * http://www.libpng.org/pub/png/spec/iso/index-object.html
 *  * https://www.w3.org/TR/PNG/
 *  * https://tools.ietf.org/html/rfc2083
 *
 * @since 2017/02/28
 */
public class PNGReader
{
	/** The input source. */
	protected final DataInputStream in;
	
	/** Image width. */
	private int _width;
	
	/** Scanline length. */
	private int _scanlen;
	
	/** Image height. */
	private int _height;
	
	/** The bit depth. */
	private int _bitdepth;
	
	/** The color type. */
	private int _colortype;
	
	/** Is adam7 interlacing being used? */
	private boolean _adamseven;
	
	/** RGB image data. */
	private int[] _argb;
	
	/** Palette data. */
	private int[] _palette;
	
	/** Was an alpha channel used? */
	private boolean _hasalpha;
	
	/** Initial value for read Y position, for multiple IDAT chunks. */
	private int _initvy;
	
	/** Initial value for read X position, for multiple IDAT chunks. */
	private int _initvx;
	
	/** The number of colors used. */
	private int _numcolors;
	
	/** The maximum number of permitted colors. */
	private int _maxcolors;
	
	/**
	 * Initializes the PNG parser.
	 *
	 * @param __in The input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public PNGReader(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * Parses the PNG image data.
	 *
	 * @return The read image.
	 * @throws IOException On read errors.
	 * @since 2017/02/28
	 */
	public Image parse()
		throws IOException
	{
		DataInputStream in = this.in;
		
		// {@squirreljme.error EB0t Illegal PNG magic number.}
		if (in.readUnsignedByte() != 137 ||
			in.readUnsignedByte() != 80 ||
			in.readUnsignedByte() != 78 ||
			in.readUnsignedByte() != 71 ||
			in.readUnsignedByte() != 13 ||
			in.readUnsignedByte() != 10 ||
			in.readUnsignedByte() != 26 ||
			in.readUnsignedByte() != 10)
			throw new IOException("EB0t");
		
		// Some J2ME games such as Bobby Carrot have invalid PNG files that
		// contain a tRNS chunk after the IDAT chunk. This violates the PNG
		// standard so the image chunk has to cached and process later,
		// otherwise the images will be corrupt.
		byte[] imagechunk = null;
		
		// Keep reading chunks in the file
		for (;;)
		{
			// {@squirreljme.erorr EB1l Length of chunk is negative.}
			int len = in.readInt();
			if (len < 0)
				throw new IOException("EB1l");
			
			// Setup data stream for reading packet data, do not propogate
			// close
			CRC32Calculator crc = new CRC32Calculator(true, true, 0x04C11DB7,
				0xFFFFFFFF, 0xFFFFFFFF);
			int lasttype = 0;
			try (DataInputStream data = new DataInputStream(
				new SizeLimitedInputStream(new ChecksumInputStream(crc, in),
				len + 4, true, false)))
			{
				// Read the packet type
				int type = data.readInt();
				lasttype = type;
				
				// End of PNG, stop processing
				if (type == 0x49454E44)
					break;
				
				// Depends on the type
				switch (type)
				{
						// Header
					case 0x49484452:
						this.__parseHeader(data);
						break;
						
						// Palette
					case 0x504c5445:
						this.__parsePalette(data, len);
						break;
						
						// Image data
					case 0x49444154:
						// There may be multiple consecutive IDAT chunks which
						// just continue where the previous one left off, so
						// just smash them together
						if (imagechunk != null)
						{
							// Read chunk data, decompress the data
							// additionally so that the decoder does not need
							// to worry about the data being compressed at
							// all...
							byte[] xtrachunk = PNGReader.__chunkLater(data);
							
							// Setup new array which contains the original
							// data but has more space
							int gn = imagechunk.length,
								xn = xtrachunk.length,
								nl = gn + xn;
							imagechunk = Arrays.copyOf(imagechunk, nl);
							
							// Write in all the data
							for (int i = 0, o = gn; i < xn; i++, o++)
								imagechunk[o] = xtrachunk[i];
						}
						
						// The first chunk
						else
							imagechunk = PNGReader.__chunkLater(data);
						break;
						
						// Transparency information
					case 0x74524E53:
						this.__parseAlpha(data, len);
						break;
					
						// Unknown, ignore
					default:
						break;
				}
			}
			
			// {@squirreljme.error EB0u CRC mismatch in PNG data chunk.
			// (Desired CRC; Actual CRC; Last chunk type read)}
			int want = in.readInt(),
				real = crc.checksum();
			if (want != real)
				throw new IOException(String.format("EB0u %08x %08x %08x",
					want, real, lasttype));
		}
		
		// {@squirreljme.error EB0v No image data has been loaded.}
		int[] argb = this._argb;
		if (argb == null)
			throw new IOException("EB0v");
		
		// Is an alpha channel being used?
		if (!this._hasalpha)
		{
			// Force all pixels to opaque
			for (int i = 0, n = argb.length; i < n; i++)
				argb[i] = 0xFF_000000;
			
			// Make all pixels opaque in the palette
			int[] palette = this._palette;
			if (palette != null)
				for (int i = 0, n = palette.length; i < n; i++)
					palette[i] |= 0xFF_000000;
		}
		
		// {@squirreljme.error EB0w Unsupported bit-depth. (The bitdepth)}
		int bitdepth = this._bitdepth;
		if (Integer.bitCount(bitdepth) != 1 || bitdepth > 8)
			throw new IOException("EB0w " + bitdepth);
		
		// {@squirreljme.error EB0x Adam7 interlacing not supported.}
		if (this._adamseven)
			throw new IOException("EB0x");
		
		// {@squirreljme.error EB0y Paletted PNG image has no palette.}
		if (this._colortype == 3 && this._palette == null)
			throw new IOException("EB0y");
		
		// Process the image chunk now that the other information was read
		// Note that the chunk needs to be unfiltered first
		try (InputStream data = new ByteArrayInputStream(this.__unfilter(
			new ZLibDecompressor(new ByteArrayInputStream(imagechunk)))))
		{
			int colortype = this._colortype;
			
			// Grayscale or Indexed
			if (colortype == 0 || colortype == 3)
				this.__pixelIndexed(data, (colortype == 3));
			
			// RGB(A)
			else if (colortype == 2 || colortype == 6)
				this.__pixelsRGB(data, (colortype == 6));
			
			// YA (Grayscale + Alpha)
			else
				this.__pixelsYA(data);
		}
		
		// Create image
		return Image.createRGBImage(argb, this._width, this._height,
			this._hasalpha);
	}
	
	/**
	 * Parses the alpha transparency data.
	 *
	 * @param __in The stream to read data from.
	 * @param __dlen The data length/
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __parseAlpha(DataInputStream __in, int __dlen)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		int[] palette = this._palette;
		int colortype = this._colortype,
			numpals = (palette != null ? palette.length : 0),
			numcolors = this._numcolors;
		
		// Force alpha channel to be set
		this._hasalpha = true;
		
		// Alpha values for grayscale or true-color
		if (colortype == 0)
		{
			// Read double-byte values
			for (int at = 0;;)
			{
				// Read in color
				int col = __in.read(),
					ign = __in.read();
				
				// EOF?
				if ((col | ign) < 0)
					break;
				
				// Find color to remove the alpha channel from the palette
				for (int p = 0; p < numpals; p++)
					if (palette[p] == col)
						palette[p] &= 0xFFFFFF;
			}
		}
		
		// Alpha values for indexed values
		else if (colortype == 3)
		{
			// Read as many entries as possible
			int i = 0;
			for (; i < numcolors; i++)
			{
				int val = __in.read();
				
				// Reached end of data, the rest are implied opaque
				if (val < 0)
					break;
				
				// Fill in color
				palette[i] |= ((val & 0xFF) << 24);
			}
			
			// The alpha data can be short, which means that all of
			// the following colors are fully opaque
			for (; i < numcolors; i++)
				palette[i] |= 0xFF_000000;
		}
	}
	
	/**
	 * Parses the PNG header.
	 *
	 * @param __in The stream to read data from.
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	private void __parseHeader(DataInputStream __in)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB0z Image has zero or negative width.
		// (The width)}
		int width = __in.readInt();
		if (width <= 0)
			throw new IOException(String.format("EB0z %d", width));
		this._width = width;
		
		// {@squirreljme.error EB10 Image has zero or negative height. (The
		// height)}
		int height = __in.readInt();
		if (height <= 0)
			throw new IOException(String.format("EB10 %d", height));
		this._height = height;
		
		// Debug
		todo.DEBUG.note("Size: %dx%d%n", width, height);
		
		// Read the bit depth and the color type
		int bitdepth = __in.readUnsignedByte(),
			colortype = __in.readUnsignedByte();
		
		// {@squirreljme.error EB11 Invalid PNG bit depth.
		// (The bit depth)}
		if (Integer.bitCount(bitdepth) != 1 || bitdepth < 0 || bitdepth > 16)
			throw new IOException(String.format("EB11 %d", bitdepth));
		
		// {@squirreljme.error EB12 Invalid PNG bit depth and color type
		// combination. (The color type; The bit depth)}
		if ((bitdepth < 8 && (colortype != 0 && colortype != 3)) ||
			(bitdepth > 8 && colortype != 3))
			throw new IOException(String.format("EB12 %d %d", colortype,
				bitdepth));
			
		// Set
		this._bitdepth = bitdepth;
		this._colortype = colortype;
		
		// These two color types have alpha, this field may be set later on
		// if a transparency chunk was found
		boolean hasalpha;
		this._hasalpha = (hasalpha = (colortype == 4 || colortype == 6));
		
		// Determine number of channels
		int channels = (colortype == 0 || colortype == 3 ? 1 :
			(colortype == 2 ? 3 :
			(colortype == 4 ? 2 :
			(colortype == 6 ? 4 : 1))));
		
		// Scan length, 7 extra bits are added for any needed padding if there
		// is any
		this._scanlen = ((width * channels * bitdepth) + 7) / 8;
		
		// {@squirreljme.error EB13 Only deflate compressed PNG images are
		// supported. (The compression method)}
		int compressionmethod = __in.readUnsignedByte();
		if (compressionmethod != 0)
			throw new IOException(String.format("EB13 %d", compressionmethod));
		
		// {@squirreljme.error EB14 Only adapative filtered PNGs are supported.
		// (The filter type)}
		int filter = __in.readUnsignedByte();
		if (filter != 0)
			throw new IOException(String.format("EB14 %d", filter));
		
		// {@squirreljme.error EB15 Unsupported PNG interlace method. (The
		// interlace type)}
		int interlace = __in.readUnsignedByte();
		if (interlace != 0 && interlace != 1)
			throw new IOException(String.format("EB15 %d", interlace));
		this._adamseven = (interlace == 1);
		
		// Allocate image buffer
		this._argb = new int[width * height];
		
		// If this is grayscale, then force a palette to be initialized so the
		// colors are more easily read without needing to process them further
		// So all values are treated as indexed
		if (colortype == 0)
		{
			// 2^d colors available
			int numcolors = (1 << bitdepth);
			
			// Build palette, force everything to opaque, it will be cleared
			// later
			int[] palette = new int[numcolors];
			for (int i = 0; i < numcolors; i++)
				palette[i] = ((int)(((double)i / (double)numcolors) * 255.0)) |
					0xFF_000000;
			
			// Set
			this._palette = palette;
		}
	}
	
	/**
	 * Parses the PNG palette.
	 *
	 * @param __in The stream to read data from.
	 * @param __len The length of the palette data.
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	private void __parsePalette(DataInputStream __in, int __len)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Ignore the palette if this is not an indexed image
		if (this._colortype != 3)
			return;
		
		// Read color color
		int numcolors = __len / 3,
			maxcolors = 1 << this._bitdepth;
		if (numcolors > maxcolors)
			numcolors = maxcolors;
		
		// Set
		this._numcolors = numcolors;
		this._maxcolors = maxcolors;
		
		// Load palette data, any remaining colors are left uninitialized and
		// are fully transparent or just black
		int[] palette = new int[maxcolors];
		this._palette = palette;
		for (int i = 0; i < numcolors; i++)
		{
			int r = __in.readUnsignedByte(),
				g = __in.readUnsignedByte(),
				b = __in.readUnsignedByte();
			
			// Fill in color
			palette[i] = (r << 16) | (g << 8) | b;
		}
	}
	
	/**
	 * Decodes grayscale/indexed image data.
	 *
	 * @param __dis Input Stream.
	 * @param __idx Indexed colors instead of just grayscale?
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelIndexed(InputStream __dis, boolean __idx)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
			
		int[] argb = this._argb;
		int[] palette = this._palette;
		int width = this._width,
			height = this._height,
			limit = width * height,
			bitdepth = this._bitdepth,
			bitmask = (1 << bitdepth) - 1,
			numpals = (palette != null ? palette.length : 0),
			hishift = (8 - bitdepth),
			himask = bitmask << hishift;
		
		// Read of multiple bits
		for (int o = 0;;)
		{
			// Read and check EOF
			int v = __dis.read();
			if (v < 0)
				break;
			
			// Handle each bit
			for (int b = 0; b < 8 && o < limit; b += bitdepth, v <<= bitdepth)
				argb[o++] = palette[((v & himask) >>> hishift) % numpals];
		}
	}
	
	/**
	 * Decodes RGB or RGBA image data.
	 *
	 * @param __dis Input Stream.
	 * @param __alpha RGBA is used?
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelsRGB(InputStream __dis, boolean __alpha)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Get output
		int[] argb = this._argb;
		int width = this._width,
			height = this._height,
			limit = width * height;
		
		// Keep reading in data
		for (int o = 0; o < limit; o++)
		{
			// Read in all values, the mask is used to keep the sign bit in
			// place but also cap the value to 255!
			int r = __dis.read() & 0x800000FF,
				g = __dis.read() & 0x800000FF,
				b = __dis.read() & 0x800000FF;
			int a = (__alpha ? (__dis.read() & 0x800000FF) : 0xFF);
			
			// Have any hit EOF? Just need to OR all the bits
			if ((r | g | b | a) < 0)
				break;
			
			// Write pixel
			argb[o] = (a << 24) | (r << 16) | (g << 8) | b;
		}
	}
	
	/**
	 * Decodes image data.
	 *
	 * @param __dis Input Stream.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelsYA(InputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Get output
		int[] argb = this._argb;
		int width = this._width,
			height = this._height,
			limit = width * height;
		
		// Keep reading in data
		for (int o = 0; o < limit;)
		{
			// Read in all values, the mask is used to keep the sign bit in
			// place but also cap the value to 255!
			int a = __dis.read() & 0x800000FF,
				y = __dis.read() & 0x800000FF;
			
			// Have any hit EOF? Just need to OR all the bits
			if ((a | y) < 0)
				break;
			
			// Write pixel
			argb[o++] = (a << 24) | (y << 16) | (y << 8) | y;
		}
	}
	
	/**
	 * Unfilters the PNG data.
	 *
	 * @param __in The stream to read from.
	 * @return The unfiltered data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final byte[] __unfilter(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need these
		int scanlen = this._scanlen,
			height = this._height;
		
		// Allocate buffer that will be returned, containing the unfiltered
		// data
		byte[] rv = new byte[scanlen * height];
		
		// Read the image scanline by scanline and process it
		for (int dy = 0; dy < height; dy++)
		{
			// Base output for this scanline
			int ibase = scanlen * dy;
			
			// At the start of every scanline is the filter type, which
			// describes how the data should be treated
			// {@squirreljme.error EB16 Unknown filter type. (The type; The
			// scanline base coordinate; The scan line length; Image size)}
			int type = __in.read();
			if (type < 0 || type > 4)
				throw new IOException(String.format(
					"EB16 %d (%d, %d) %d [%d, %d]",
					type, 0, dy, scanlen, this._width, height));
			
			// Go through each byte in the scanline
			for (int dx = 0; dx < scanlen; dx++)
			{
				// The current position in the buffer
				int di = ibase + dx;
				
				// The filter algorithm is a bit confusing and it uses the
				// prior and old pixel information, so according to the PNG
				// spec just to be easier to use the variables will be named
				// the same. Anywhere that bleeds off the image will always be
				// treated as zero.
				
				// The current byte being filtered
				int x = __in.read() & 0xFF,
				
				// The byte to the left of (x, y) [-1, 0]
					a = (dx <= 0 ? 0 : rv[di - 1]) & 0xFF,
				
				// The byte to the top of (x, y) [0, -1]
					b = (dy <= 0 ? 0 : rv[di - scanlen]) & 0xFF,
				
				// The byte to the top and left of (x, y) [-1, -1]
					c = ((dx <= 0 || dy <= 0) ? 0 :
						rv[(di - scanlen) - 1]) & 0xFF;
				
				// Depends on the decoding algorithm
				int res = 0;
				switch (type)
				{
						// None
					case 0:
						res = x;
						break;
						
						// Sub
					case 1:
						res = x + a;
						break;
						
						// Up
					case 2:
						res = x + b;
						break;
						
						// Average
					case 3:
						res = x + ((a + b) >>> 2);
						break;
						
						// Paeth, this probably is not correct
					case 4:
						{
							// Calculate these
							int p = a + b - c,
								pa = p - a,
								pb = p - b,
								pc = p - c;
							
							// Absolute values
							pa = (pa < 0 ? -pa : pa);
							pb = (pb < 0 ? -pb : pb);
							pc = (pc < 0 ? -pc : pc);
							
							// Perform some checks
							if (pa <= pb && pa <= pc)
								res = x + a;
							else if (pb <= pc)
								res = x + b;
							else
								res = x + c;
						}
						break;
				}
				
				// Set result
				rv[di] = (byte)res;
			}
		}
		
		return rv;
	}
	
	/**
	 * Reads all the input data and returns a byte array for the data, so it
	 * may be processed later.
	 *
	 * @param __dis The stream to read from.
	 * @return The read data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private static final byte[] __chunkLater(InputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read into this byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(512))
		{
			// Read loop
			byte[] buf = new byte[512];
			for (;;)
			{
				int rc = __dis.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Return the data
			return baos.toByteArray();
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/XPMReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import javax.microedition.lcdui.Image;

/**
 * This class is able to read XPM images.
 *
 * If the XPM is invalid then the read image data will not be correct.
 *
 * There are also limitations to the reader, only the last color key will be
 * used and it will be treated as a RGB hexadecimal color. Also the pixels
 * per character has a limit of 2 characters, any pixels with characters
 * codes beyond 2 character will only use the first 2.
 *
 * @since 2016/05/08
 */
public class XPMReader
{
	/** Source stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the XPM image reader.
	 *
	 * @param __is The input stream.
	 * @since 2016/05/08
	 */
	public XPMReader(InputStream __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		this.in = __is;
	}
	
	/**
	 * Reads the XPM image data from the specified input stream.
	 *
	 * @return The read image data.
	 * @throws IOException If the XPM is not valid.
	 * @since 2017/02/10
	 */
	public Image parse()
		throws IOException
	{
		InputStream in = this.in;
		
		// Create character stripper
		__CharStripper__ cs = new __CharStripper__(new InputStreamReader(in,
			"utf-8"));
		
		// Read the XPM header
		int[] header = this.__readHeader(cs);
		
		// Get dimensional data
		int width = Math.max(header[0], 1);
		int height = Math.max(header[1], 1);
		int numcolors = Math.max(header[2], 1);
		int pxchars = Math.max(header[3], 1);
		int hotx = header[4];
		int hoty = header[5];
		
		// Read the color table
		int[] codes = new int[numcolors];
		int[] palette = new int[numcolors];
		boolean alpha = this.__readColorTable(
			cs, codes, palette, numcolors, pxchars);
		
		// Target array
		int area = width * height;
		int[] data = new int[area];
		
		// Read pixels
		this.__readPixels(cs, width, height, data, pxchars, codes, palette);
		
		// Create image
		return Image.createRGBImage(data, width, height, alpha);
	}
	
	/**
	 * Decodes a color key value.
	 *
	 * @param __cs The input key value characters.
	 * @return The decoded color value.
	 * @since 2016/05/22
	 */
	private int __decodeColor(CharSequence __cs)
	{
		// Too short?
		int n = __cs.length();
		if (n <= 0)
			return 0x00_000000;
		
		// Must start with '#'
		if (__cs.charAt(0) != '#')
			return 0x00_000000;
		
		// Decode the first 8 digits
		int[] dig = new int[8];
		for (int i = 0, j = 1; i < 8 && j < n; i++, j++)
			dig[i] = Math.max(0, Character.digit(__cs.charAt(j), 16));
		
		// #rgb
		if (n == 4)
			return 0xFF_000000 |
				(dig[0] << 20) |
				(dig[0] << 16) |
				(dig[1] << 12) |
				(dig[1] << 8) |
				(dig[2] << 4) |
				(dig[2]);
		
		// #argb
		else if (n == 5)
			return (dig[0] << 28) |
				(dig[0] << 24) |
				(dig[1] << 20) |
				(dig[1] << 16) |
				(dig[2] << 12) |
				(dig[2] << 8) |
				(dig[3] << 4) |
				(dig[3]);
		
		// #rrggbb
		else if (n == 7)
			return 0xFF_000000 |
				(dig[0] << 20) |
				(dig[1] << 16) |
				(dig[2] << 12) |
				(dig[3] << 8) |
				(dig[4] << 4) |
				(dig[5]);
		
		// #aarrggbb
		else if (n == 9)
			return (dig[0] << 28) |
				(dig[1] << 24) |
				(dig[2] << 20) |
				(dig[3] << 16) |
				(dig[4] << 12) |
				(dig[5] << 8) |
				(dig[6] << 4) |
				(dig[7]);
		
		// Unknown
		else
			return 0x00_000000;
	}
	
	/**
	 * Locates a color for a given color.
	 *
	 * @param __c The code to find the color for.
	 * @param __codes The array of codes.
	 * @param __pal The color palette.
	 * @return The color code used.
	 * @since 2016/05/22
	 */
	private int __locateCode(int __c, int[] __codes, int[] __pal)
	{
		int at = Arrays.binarySearch(__codes, __c);
		if (at >= 0)
			return __pal[at];
		return 0;
	}
	
	/**
	 * Reads the color table of the XPM.
	 *
	 * @param __cs The source characters.
	 * @param __codes The output color codes.
	 * @param __palette The output color palette.
	 * @param __numcolors The number of colors used.
	 * @param __pxchars The number of characters per pixel.
	 * @return If an alpha channel was used.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private boolean __readColorTable(Reader __cs, int[] __codes,
		int[] __palette, int __numcolors, int __pxchars)
		throws IOException
	{
		// Had alpha?
		boolean hasalpha = false;
		
		// Decode the color palette
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < __numcolors; i++)
		{
			// Read new input string
			sb.setLength(0);
			this.__readLine(__cs, sb);
			
			// Ignore really short lines
			int n = sb.length();
			if (n < __pxchars)
				continue;
			
			// Set code to the given sequence
			int cx = 0;
			if (__pxchars >= 1)
				cx |= (int)sb.charAt(0);
			if (__pxchars >= 2)
				cx |= ((int)sb.charAt(1)) << 16;
			
			// Find the last color key value
			int s, e = n - 1;
			while (e >= __pxchars && sb.charAt(e) <= ' ')
			{
				e--;
				continue;
			}
			
			// Find the start of the color key
			s = e -1;
			while (s >= __pxchars && sb.charAt(s) > ' ')
			{
				s--;
				continue;
			}
			
			// Decode color, detect if there is a transparent pixel
			int col = this.__decodeColor(sb.subSequence(s + 1, e + 1));
			if ((col & 0xFF_000000) != 0xFF_000000)
				hasalpha = true;
			
			// Find the position to place the code at
			int at = Arrays.binarySearch(__codes, 0, i, cx);
			if (at < 0)
				at = -(at + 1);
			
			// Move all values up
			for (int j = i; j > at; j--)
			{
				__codes[j] = __codes[j - 1];
				__palette[j] = __palette[j - 1];
			}
			
			// Set the value
			__codes[at] = cx;
			__palette[at] = col;
		}
		
		// Return the alpha channel status
		return hasalpha;
	}
	
	/**
	 * Reads the XPM image heder.
	 *
	 * @param __r The source characters.
	 * @return The header values.
	 * @throws On read errors.
	 * @since 2016/05/22
	 */
	private int[] __readHeader(Reader __r)
		throws IOException
	{
		// Read XPM header
		int[] header = new int[7];
		for (int i = 0;; i++)
			if (this.__readInt(__r, header, Math.min(6, i)))
				break;
		
		// Return it
		return header;
	}
	
	/**
	 * Reads a single integer value from the input.
	 *
	 * @param __r The stream to read an integer from.
	 * @param __v The read value.
	 * @param __o The offset in the array index.
	 * @return {@code true} if the line or stream has ended.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private boolean __readInt(Reader __r, int[] __v, int __o)
		throws IOException
	{
		// Setup
		int val = 0;
		boolean neg = false;
		
		// Read character
		for (boolean first = true, startwhite = true;; first = false)
		{
			// Read
			int c = __r.read();
			
			// Ignore starting whitespace
			if (c == ' ' || c == '\t' || c == '\r')
				if (startwhite)
					continue;
			
			// No more whitespace to ignore
			startwhite = false;
			
			// EOF or EOL?
			if (c < 0)
			{
				__v[__o] = (neg ? -val : val);
				return true;
			}
			
			// Negative?
			if (first && c == '-')
			{
				neg = true;
				continue;
			}
			
			// As a digit
			int dig = Character.digit((char)c, 10);
			
			// If not a digit, stop
			if (dig < 0)
			{
				__v[__o] = (neg ? -val : val);
				return false;
			}
			
			// Shift up and add
			val *= 10;
			val += dig;
		}
	}
	
	/**
	 * Reads a single line into the given string builder.
	 *
	 * @param __r The stream to source characters from.
	 * @param __sb The buffer to store the temporary string data.
	 * @throws IOException On read errors.
	 * @since 2015/06/22
	 */
	private void __readLine(Reader __r, StringBuilder __sb)
		throws IOException
	{
		// Read until the end
		for (;;)
		{
			// Read character
			int c = __r.read();
			
			// End of stream or line?
			if (c < 0)
				return;
			
			// Append
			__sb.append((char)c);
		}
	}
	
	/**
	 * Reads the pixels from the XPM image.
	 *
	 * @param __cs The character source.
	 * @param __width The image width.
	 * @param __height The image height.
	 * @param __data The output data.
	 * @param __pxchars The characters per pixel.
	 * @param __codes The character codes.
	 * @param __palette The color palette.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private void __readPixels(Reader __cs, int __width, int __height,
		int[] __data, int __pxchars, int[] __codes, int[] __palette)
		throws IOException
	{
		// Read the XPM image data for each rows
		int lastcode = -1;
		int lastpall = -1;
__outer:
		for (int y = 0; y < __height; y++)
			for (int x = 0, z = (y * __width);; x++)
			{
				// Read color code
				int code = 0;
				for (int i = 0; i < __pxchars; i++)
				{
					// Read
					int c = __cs.read();
					
					// Next row?
					if (c == __CharStripper__.END_OF_LINE)
						continue __outer;
					
					// EOF?
					else if (c < 0)
						break __outer;
					
					// First read?
					if (i == 0)
						code = c;
					
					// Second read?
					else if (i == 1)
						code |= c << 16;
				}
				
				// Used this color just before? In solidly linear areas, this
				// reduces the need for constant binary searches and increases
				// the parsing speed slightly.
				if (code == lastcode)
					__data[z++] = lastpall;
				
				// Find the code used
				else
				{
					lastpall = this.__locateCode((lastcode = code), __codes,
						__palette);
					__data[z++] = lastpall;
				}
			}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/__CharStripper__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.IOException;
import java.io.Reader;

/**
 * This is a character stripper which is used to remove C/C++ comments and
 * return the series of strings between curly braces. This does not perform
 * tokenization to remain as simple and as fast as possible, so XPM images
 * which use the preprocessor will likely not load properly. The decoder
 * generally assumes that the XPM is well formed.
 *
 * If a comma appears inside of the string array, then the character that would
 * be returned in its place is {@link #END_OF_LINE} character. This is because
 * XPM is a line based format.
 *
 * @since 2016/05/22
 */
class __CharStripper__
	extends Reader
{
	/** Special end of line code. */
	public static final int END_OF_LINE =
		Integer.MIN_VALUE;
	
	/** Lock to make sure there is a consistent state. */
	protected final Object lock =
		new Object();
	
	/** The input reader. */
	protected final Reader in;
	
	/** The current comment type (0 = none, 1 = single, 2 = multi. */
	private volatile int _comment;
	
	/** In a string literal? */
	private volatile boolean _instring;
	
	/** In the XPM bracket data. */
	private volatile boolean _inbracket;
	
	/** End of XPM? */
	private volatile boolean _endxpm;
	
	/**
	 * Initializes the character stripper.
	 *
	 * @param __r The source to strip characters from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/22
	 */
	__CharStripper__(Reader __r)
		throws NullPointerException
	{
		// Check
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __r;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public void close()
		throws IOException
	{
		// Lock
		synchronized (this.lock)
		{
			this.in.close();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public int read()
		throws IOException
	{
		// Lock
		synchronized (this.lock)
		{
			// Read loop to find a valid character
			Reader in = this.in;
			for (;;)
			{
				// End of the XPM?
				if (this._endxpm)
					return -1;
				
				// Read single character
				int c = in.read();
				
				// EOF?
				if (c < 0)
					return -1;
				
				// In a multi-line comment?
				int comment = this._comment;
				if (comment == 2)
				{
					// If an asterisk, possible end of multi-line	
					if (c == '*')
					{
						c = in.read();
						
						// EOF?
						if (c < 0)
							return -1;
						
						// End of multi-line?
						if (c == '/')
							this._comment = 0;
					}
					
					continue;
				}
				
				// Single line comment
				else if (comment == 1)
				{
					// If \r or \n, end of comment
					if (c == '\r' || c == '\n')
						this._comment = 0;
					
					continue;
				}
				
				// In string?
				if (this._instring)
				{
					// Escape sequence?
					if (c == '\\')
					{
						// Get character
						c = in.read();
						
						// Depends on the character
						switch (c)
						{
							case 'a': return (char)0x07;
							case 'b': return (char)0x08;
							case 'f': return (char)0x0C;
							case 'n': return '\n';
							case 'r': return '\r';
							case 't': return '\t';
							case 'v': return (char)0x0B;
							case '\\': return '\\';
							case '\'': return '\'';
							case '"': return '"';
							case '?': return '?';
							
							case 'x':
								{
									// Read all chars as hex
									int x = Character.digit((char)in.read(),
										16);
									int y = Character.digit((char)in.read(),
										16);
									
									// If all are valid, use it
									if (x >= 0 && y >= 0)
										return (x << 4) | (y);
									continue;
								}
								
							case '0':
							case '1':
							case '2':
							case '3':
							case '4':
							case '5':
							case '6':
							case '7':
							case '8':
							case '9':
								{
									// Read all chars as octal
									int x = Character.digit((char)c, 8);
									int y = Character.digit((char)in.read(),
										8);
									int z = Character.digit((char)in.read(),
										8);
									
									// If all are valid, use it
									if (x >= 0 && y >= 0 && z >= 0)
										return (x << 6) | (y << 3) | (z);
									continue;
								}
							
								// Unknown, ignore
							default:
								continue;
						}
					}
					
					// End of string?
					else if (c == '"')
					{
						this._instring = false;
						continue;
					}
					
					// Normal character, use it
					else
						return c;
				}
				
				// Outside a string
				else
				{
					// Starting bracket
					if (c == '{')
					{
						// Set in bracket
						this._inbracket = true;
					}
					
					// Ending brakcet
					else if (c == '}')
					{
						// End the XPM but only if in a bracket
						if (this._inbracket)
						{
							this._endxpm = true;
							continue;
						}
					}
					
					// Start of a string?
					else if (c == '"')
						this._instring = true;
					
					// Possible start of comment?
					else if (c == '/')
					{
						// Read next
						c = in.read();
						
						// EOF?
						if (c < 0)
							return -1;
						
						// Single line comment?
						if (c == '/')
							this._comment = 1;
						
						// Multi-line comment?
						else if (c == '*')
							this._comment = 2;
						
						// Unknown, ignore
						else
							continue;
					}
					
					// String separator
					else if (c == ',')
					{
						// If in a bracket, return a special code
						if (this._inbracket)
							return __CharStripper__.END_OF_LINE;
						
						// Otherwise, ignore it
						continue;
					}
					
					// Unknown, ignore
					else
						continue;
				}
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public int read(char[] __b, int __o, int __l)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// Lock
		synchronized (this.lock)
		{
			// Read loop
			for (int i = 0; i < __l; i++)
				try
				{
					// Read single character
					int c = this.read();
				
					// EOF?
					if (c < 0)
						return (i > 0 ? i : -1);
				
					// Set
					__b[__o + i] = (char)c;
				}
			
				// Failed read
				catch (IOException e)
				{
					// If nothing read, fail
					if (i <= 0)
						throw e;
				
					// Otherwise return the read count
					return i;
				}
		
			// All characters read
			return __l;
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/image/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for reading images from various formats.
 *
 * @since 2017/10/26
 */

package cc.squirreljme.runtime.lcdui.image;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for LCDUI display engines.
 *
 * @since 2017/02/08
 */

package cc.squirreljme.runtime.lcdui;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/ActionMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.FileSelector;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TabbedPane;
import javax.microedition.lcdui.TextBox;

/**
 * This represents an action method which when a key is pressed or similar
 * then something is done.
 *
 * @since 2019/05/18
 */
public enum ActionMethod
{
	/** Alert. */
	ALERT
	{
	},
	
	/** Canvas. */
	CANVAS
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			// Normalize all key types to mobile cell phone format, if not
			// specified
			if (__ch == '#')
				__kc = Canvas.KEY_POUND;
			else if (__ch == '*')
				__kc = Canvas.KEY_STAR;
			else if (__ch >= '0' && __ch <= '9')
				__kc = Canvas.KEY_NUM0 + (__ch - '0');
				
			// If the key-code is not valid then ignore
			if (__kc == NonStandardKey.UNKNOWN)
				return false;
			
			// Depends on the action
			switch (__ty)
			{
				case NativeDisplayEventCallback.KEY_PRESSED:
					__d.keyPressed(__kc);
					break;
				
				case NativeDisplayEventCallback.KEY_REPEATED:
					__d.keyRepeated(__kc);
					break;
				
				case NativeDisplayEventCallback.KEY_RELEASED:
					__d.keyReleased(__kc);
					break;
				
				default:
					break;
			}
			
			// Do not force a repaint, up to the canvas
			return false;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean pointerEvent(Displayable __d, State __s, int __ty,
			int __x, int __y, int __time)
		{
			ExposedDisplayable displayable = (ExposedDisplayable)__d;
			
			// Depends on the type
			switch (__ty)
			{
				case NativeDisplayEventCallback.POINTER_PRESSED:
					displayable.pointerPressed(__x, __y);
					break;
				
				case NativeDisplayEventCallback.POINTER_RELEASED:
					displayable.pointerReleased(__x, __y);
					break;
				
				case NativeDisplayEventCallback.POINTER_DRAGGED:
					displayable.pointerDragged(__x, __y);
					break;
				
				default:
					break;
			}
			
			// Do not force a repaint, up to the canvas
			return false;
		}
	},
	
	/** File selector. */
	FILE_SELECTOR
	{
	},
	
	/** Form. */
	FORM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			return false;
		}
	},
	
	/** List. */
	LIST
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			List list = (List)__d;
			int n = list.size();
			int ltype = list.getType();
			
			// Ignore released keys
			if (__ty == NativeDisplayEventCallback.KEY_RELEASED)
				return false;
			
			// Quickly focus an item?
			int focusdx = __s.focusdx,
				wantdx = focusdx;
			if (__kc >= Canvas.KEY_NUM1 && __kc <= Canvas.KEY_NUM9)
				wantdx = __kc - Canvas.KEY_NUM1;
			
			// Handle key
			switch (EventTranslate.keyCodeToGameAction(__kc))
			{
					// Move up, ignore number input
				case Canvas.UP:
					wantdx = focusdx - 1;
					break;
				
					// Move down, ignore number input
				case Canvas.DOWN:
					wantdx = focusdx + 1;
					break;
					
					// Select item
				case Canvas.FIRE:
					// Only allow enabled items to have their selection state
					// adjusted
					if (focusdx >= 0 && focusdx < n && list.isEnabled(focusdx))
					{
						// Set new selection state, exclusive lists always
						// set a new element
						boolean nowsel = (!list.isSelected(focusdx) ||
							ltype == Choice.EXCLUSIVE ||
							ltype == Choice.IMPLICIT);
						
						// Set new state
						list.setSelectedIndex(focusdx, nowsel);
						
						// Implicit lists need their item to be specified
						if (ltype == Choice.IMPLICIT)
						{
							// Execute command when selection was changed?
							Command sc = list.getSelectCommand();
							if (sc != null)
							{
								CommandListener l = ((ExposedDisplayable)__d).
									getCommandListener();
								if (l != null)
									l.commandAction(sc, __d);
							}
						}
						
						// Should be repainted
						return true;
					}
					
					// Not to be repainted
					return false;
			}
			
			// Change of focus and it is valid?
			if (focusdx != wantdx && wantdx >= 0 && wantdx < n)
			{
				// Set new focus
				__s.focusdx = wantdx;
				
				// If this is an implicit list then automatically select
				// the given focused item
				if (list.getType() == Choice.IMPLICIT)
					list.setSelectedIndex(wantdx, true);
				
				// Repaint
				return true;
			}
			
			// Nothing happened
			return false;
		}
	},
	
	/** Tabbed Pane. */
	TABBED_PANE
	{
	},
	
	/** Text Box. */
	TEXT_BOX
	{
	},
	
	/** End. */
	;
	
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __c The command to execute.
	 * @return {@code true} if the command was handled.
	 * @since 2019/05/18
	 */
	public boolean command(Displayable __d, State __s, int __c)
	{
		return false;
	}
	
	/**
	 * Key action has been performed.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @return {@code true} if the display should be repainted.
	 * @since 2019/05/18
	 */
	public boolean keyEvent(Displayable __d, State __s, int __ty, int __kc,
		int __ch, int __time)
	{
		return false;
	}
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @return {@code true} if the display should be repainted.
	 * @since 2019/05/18
	 */
	public boolean pointerEvent(Displayable __d, State __s, int __ty, int __x,
		int __y, int __time)
	{
		return false;
	}
	
	/**
	 * Returns the action method for the given class.
	 *
	 * @param __cl The class to act for.
	 * @return The action method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/18
	 */
	public static final ActionMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (Alert.class.isAssignableFrom(__cl))
			return ActionMethod.ALERT;
		else if (Canvas.class.isAssignableFrom(__cl))
			return ActionMethod.CANVAS;
		else if (FileSelector.class.isAssignableFrom(__cl))
			return ActionMethod.FILE_SELECTOR;
		else if (Form.class.isAssignableFrom(__cl))
			return ActionMethod.FORM;
		else if (List.class.isAssignableFrom(__cl))
			return ActionMethod.LIST;
		else if (TabbedPane.class.isAssignableFrom(__cl))
			return ActionMethod.TABBED_PANE;
		else if (TextBox.class.isAssignableFrom(__cl))
			return ActionMethod.TEXT_BOX;
		
		// {@squirreljme.error EB17 Could not get the action method of the
		// given class. (The class)}
		throw new IllegalArgumentException("EB17 " + __cl);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/ActiveDisplay.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Text;
import javax.microedition.lcdui.Ticker;

/**
 * This contains the display display along with the internal image buffer.
 *
 * @since 2019/05/16
 */
public final class ActiveDisplay
{
	/** The width of the display. */
	protected final int width;
	
	/** The height of the display. */
	protected final int height;
	
	/** The displayable to draw. */
	volatile Displayable _current;
	
	/** The drawing method to use. */
	volatile DrawingMethod _drawing;
	
	/** The action method to use. */
	volatile ActionMethod _action;
	
	/** Current drawing state. */
	volatile State _state;
	
	/** Content X Area. */
	int _contentx;
	
	/** Content Y Area. */
	int _contenty;
	
	/** Width of the content area. */
	int _contentwidth;
	
	/** Height of the content area. */
	int _contentheight;
	
	/** The title to use. */
	String _title;
	
	/**
	 * Initializes the active display.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public ActiveDisplay(int __w, int __h)
	{
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Default content area size
		this._contentwidth = __w;
		this._contentheight = __h - (StandardMetrics.TITLE_BAR_HEIGHT +
			StandardMetrics.COMMAND_BAR_HEIGHT +
			StandardMetrics.TICKER_BAR_HEIGHT);
	}
	
	/**
	 * Activates the display.
	 *
	 * @param __d The displayable to be drawn when requested.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public final void activate(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// If the displayable has not changed, ignore
		Displayable current = this._current;
		if (current == __d)
			return;
		
		// Set
		this._current = __d;
		this._drawing = DrawingMethod.of(__d.getClass());
		this._action = ActionMethod.of(__d.getClass());
		this._state = ((ExposedDisplayable)__d)._dstate;
		
		// Realize the dimensions
		this.realize(PhoneUI._IGNORE_REALIZATION);
	}
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __c The command to execute.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean command(int __c)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Forward action, if it was not handled by this display then fallback
		// to the displayable commands
		CommandListener l = ((ExposedDisplayable)current).getCommandListener();
		if (!this._action.command(current, this._state, __c))
		{
			// Get all commands
			Command[] commands = current.getCommands();
			int numcommands = commands.length;
			
			// Call command function
			if (__c >= 0 && __c < numcommands)
			{
				// Run command
				l.commandAction(commands[__c], current);
				
				// Always redraw it
				return true;
			}
		}
		
		// Not handled
		return false;
	}
	
	/**
	 * Requests that the program be terminated.
	 *
	 * @since 2019/05/18
	 */
	public final void exitRequest()
	{
		// Ignore if nothing is set
		Displayable current = this._current;
		if (current == null)
			return;
		
		// Search through commands for an exit one to execute
		CommandListener l = ((ExposedDisplayable)current).getCommandListener();
		if (l != null)
			for (Command c : current.getCommands())
				if (c.getCommandType() == Command.EXIT)
				{
					// Execute command
					l.commandAction(c, current);
					
					// Done
					return;
				}
		
		// Otherwise just terminate the application
		System.exit(0);
	}
	
	/**
	 * Key action has been performed.
	 *
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean keyEvent(int __ty, int __kc, int __ch, int __time)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Execute command via function key?
		if (__ty == NativeDisplayEventCallback.KEY_PRESSED &&
			__kc >= NonStandardKey.F1 && __kc <= NonStandardKey.F24)
			return this.command(__kc - NonStandardKey.F1);
		
		// Forward action
		return this._action.keyEvent(current, this._state, __ty, __kc, __ch,
			__time);
	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __g The backend graphics to draw on.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public final void paint(Graphics __g, int __x, int __y, int __w, int __h)
	{
		// Get display details
		int dw = this.width,
			dh = this.height;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Realize new content area coordinates
		int[] ua = new int[4];
		if (this.realize(ua))
			current.sizeChanged(ua[2], ua[3]);
		
		// Extract coordinates
		int ux = ua[0],
			uy = ua[1],
			uw = ua[2],
			uh = ua[3];
		
		// If not full-screen, then draw title bar and maybe the command bar
		if (uh != dh)
		{
			// Remember default parameters
			Font oldfont = __g.getFont();
			int oldcolor = __g.getColor();
			
			// Draw background
			__g.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
			__g.fillRect(0, 0, dw, StandardMetrics.TITLE_BAR_HEIGHT);
			
			// Set font
			__g.setFont(Font.getFont("sansserif", 0,
				StandardMetrics.TITLE_BAR_HEIGHT));
			
			// Draw title text
			String title = this._title;
			__g.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
			__g.drawString(title, 0, 0, Graphics.TOP | Graphics.LEFT);
			__g.drawString(title, 1, 0, Graphics.TOP | Graphics.LEFT);
			
			// Draw the ticker?
			Ticker ticker = (current == null ? null : current.getTicker());
			if (ticker != null)
			{
				// Background
				__g.setColor(StandardMetrics.BACKGROUND_TICKER_COLOR);
				__g.fillRect(0, StandardMetrics.TITLE_BAR_HEIGHT,
					dw, StandardMetrics.TICKER_BAR_HEIGHT);
				
				// Draw ticker text
				__g.setColor(StandardMetrics.FOREGROUND_TICKER_COLOR);
				__g.drawString(ticker.getString(),
					0, StandardMetrics.TITLE_BAR_HEIGHT,
					Graphics.TOP | Graphics.LEFT);
			}
			
			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			if (numcommands > 0)
			{
				// Base Y position
				int cy = dh - StandardMetrics.COMMAND_BAR_HEIGHT;
				
				// Draw background
				__g.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
				__g.fillRect(0, cy, dw, StandardMetrics.COMMAND_BAR_HEIGHT);
				
				// Draw the first added command
				__g.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
				__g.drawString(commands[0].getLabel(), 0, cy,
					Graphics.TOP | Graphics.LEFT);
				
				// Draw second command?
				if (numcommands > 1)
					__g.drawString((numcommands == 2 ? commands[1].getLabel() :
						"Menu"), dw >> 1, cy, Graphics.TOP | Graphics.LEFT);
			}
			
			// Restore parameters
			__g.setFont(oldfont);
			__g.setColor(oldcolor);
		}
		
		// Setup enforced graphics
		Graphics ug = new EnforcedDrawingAreaGraphics(__g,
			ux, uy, uw, uh);
		
		// If nothing is being shown, just show the version info
		if (current == null)
		{
			// Draw box
			ug.setColor(0x0000FF);
			ug.fillRect(0, 0, uw, uh);
			
			// Draw some layout text
			ug.setColor(0xFFFF00);
			ug.setFont(Font.getFont("sansserif", 0, 16));
			ug.drawString("SquirrelJME " + SquirrelJME.RUNTIME_VERSION + "\n" +
				"(C) Stephanie Gawroriski\n" +
				"https://squirreljme.cc/\nLicensed w/ the GPLv3!", 0, 0, 0);
			ug.drawString("SquirrelJME", 1, 0, 0);
		}
		
		// Normal painting
		else
		{
			// If the displayable is transparent then, we fill in the
			// background for the application
			if (current.isTransparent())
			{
				// Use background color instead
				int oldcolor = ug.getColor();
				ug.setColor(StandardMetrics.TRANSPARENT_COLOR);
				
				// Fill
				ug.fillRect(0, 0, uw, uh);
				
				// Restore
				ug.setColor(oldcolor);
			}
			
			// Paint
			State state = this._state;
			try
			{
				this._drawing.paint((Displayable)current, state, ug, uw, uh);
			}
			
			// Completely messed up!
			catch (RuntimeException e)
			{
				try
				{
					// Draw text message
					Text message = new Text(String.format("%s: %s",
						e.getClass().getName(), e.getMessage()), uw, uh);
					
					// Set properties
					message.setBackgroundColor(
						StandardMetrics.itemBackgroundColor(true, true));
					message.setForegroundColor(
						StandardMetrics.itemForegroundColor(true, true));
					
					// Draw it now
					ug.drawText(message, 0, 0);
				}
				
				// Failed to draw the error?
				catch (RuntimeException f)
				{
					// Suppress it
					e.addSuppressed(f);
					
					// And print
					e.printStackTrace();
				}
				
				// Re-toss original exception
				throw e;
			}
			
			// Draw the focus box
			State.Box focusbox = state.focusbox;
			if (focusbox.x >= 0)
			{
				// Draw primary color
				ug.setColor(StandardMetrics.FOCUS_A_COLOR);
				ug.setAlpha(0x7F);
				ug.setStrokeStyle(Graphics.SOLID);
				ug.drawRect(focusbox.x, focusbox.y, focusbox.w, focusbox.h);
				
				// Draw secondary color
				ug.setColor(StandardMetrics.FOCUS_B_COLOR);
				ug.setAlpha(0xFF);
				ug.setStrokeStyle(Graphics.DOTTED);
				ug.drawRect(focusbox.x, focusbox.y, focusbox.w, focusbox.h);
				
				// Restore stroke
				ug.setStrokeStyle(Graphics.SOLID);
			}
		}
		
		// Clear clip for status symbols and focus
		__g.setClip(0, 0, dw, dh);
		
		// Switch to the symbol font
		Font sf = Font.getFont("symbol", 0, StandardMetrics.TITLE_BAR_HEIGHT);
		__g.setFont(sf);
		int xa = sf.charWidth('#'),
			sx = dw - 2;
	}
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean pointerEvent(int __ty, int __x, int __y, int __time)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Forward action, un-offset the coordinates so that they are within
		// the bounds of the content instead of just absolutely on the screen
		return this._action.pointerEvent(current, this._state, __ty,
			__x - this._contentx, __y - this._contenty, __time);
	}
	
	/**
	 * Realizes the size of the content area.
	 *
	 * @param __dims The output content area dimensions.
	 * @return {@code true} if the area has been resized.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public final boolean realize(int[] __dims)
		throws NullPointerException
	{
		if (__dims == null)
			throw new NullPointerException("NARG");
		
		// Screen size
		int dw = this.width,
			dh = this.height;
		
		// User area
		int ux, uy, uw, uh;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Full-screen uses the entire screen
		if (current != null && current.isFullscreen())
		{
			ux = 0;
			uy = 0;
			uw = dw;
			uh = dh;
		}
		
		// Otherwise, space is lost to the title bar and commands
		else
		{
			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			
			// Drawing the ticker?
			int drawticker = (current != null && current.getTicker() != null ?
				StandardMetrics.TICKER_BAR_HEIGHT : 0);
			
			// Clip dimensions
			ux = 0;
			uy = StandardMetrics.TITLE_BAR_HEIGHT + drawticker;
			uw = dw;
			uh = dh - (StandardMetrics.TITLE_BAR_HEIGHT +
				(numcommands > 0 ? StandardMetrics.COMMAND_BAR_HEIGHT : 0) +
				drawticker);
		}
		
		// Has the area changed?
		boolean rv = false;
		int oldux = this._contentx,
			olduy = this._contenty,
			olduw = this._contentwidth,
			olduh = this._contentheight;
		if (ux != oldux || uy != olduy || uw != olduw || uh != olduh)
		{
			// Did change
			rv = true;
			
			// Set new fields
			this._contentx = ux;
			this._contenty = uy;
			this._contentwidth = uw;
			this._contentheight = uh;
		}
		
		// Set output user area dimensions
		__dims[0] = ux;
		__dims[1] = uy;
		__dims[2] = uw;
		__dims[3] = uh;
		
		// Has this changed at all?
		return rv;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/DrawingItemMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

/**
 * The method used for drawing items.
 *
 * @since 2019/12/09
 */
public enum DrawingItemMethod
{
	/** Choice group. */
	CHOICE_GROUP
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Choice Group", __x, __y, Graphics.TOP);
		}
	},
	
	/** Custom item. */
	CUSTOM_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Custom Item", __x, __y, Graphics.TOP);
		}
	},
	
	/** Date field. */
	DATE_FIELD
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Date Field", __x, __y, Graphics.TOP);
		}
	},
	
	/** Gauge. */
	GAUGE
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Gauge", __x, __y, Graphics.TOP);
		}
	},
	
	/** Image item. */
	IMAGE_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Image Item", __x, __y, Graphics.TOP);
		}
	},
	
	/** Spacer. */
	SPACER
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Spacer", __x, __y, Graphics.TOP);
		}
	},
	
	/** String item. */
	STRING_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			StringItem item = (StringItem)__i;
			
			// Only draw text if it is to be displayed
			String text = item.getText();
			if (text != null)
			{
				// Set font to use
				__g.setFont(item.getFont());
				
				// Draw text
				__g.drawString(text, __x, __y, 0);
			}
		}
	},
	
	/** Text field. */
	TEXT_FIELD
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Text Field", __x, __y, Graphics.TOP);
		}
	},

	/** End. */
	;
	
	/**
	 * Paints the method.
	 *
	 * @param __d The displayable to be drawn.
	 * @param __i The item to draw.
	 * @param __s The draw state.
	 * @param __g The graphics to draw to.
	 * @param __x The X position.
	 * @param __y The Y position.
	 * @param __w The item width.
	 * @param __h The item height.
	 * @param __enb Is this enabled?
	 * @param __sel Is this selected?
	 * @since 2019/12/09
	 */
	public abstract void paint(Displayable __d, Item __i, State __s,
		Graphics __g, int __x, int __y, int __w, int __h, boolean __enb,
		boolean __sel);
	
	/**
	 * Returns the drawing method for the given class.
	 *
	 * @param __cl The class to draw for.
	 * @return The drawing method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/09
	 */
	public static final DrawingItemMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (ChoiceGroup.class.isAssignableFrom(__cl))
			return DrawingItemMethod.CHOICE_GROUP;
		else if (CustomItem.class.isAssignableFrom(__cl))
			return DrawingItemMethod.CUSTOM_ITEM;
		else if (DateField.class.isAssignableFrom(__cl))
			return DrawingItemMethod.DATE_FIELD;
		else if (Gauge.class.isAssignableFrom(__cl))
			return DrawingItemMethod.GAUGE;
		else if (ImageItem.class.isAssignableFrom(__cl))
			return DrawingItemMethod.IMAGE_ITEM;
		else if (Spacer.class.isAssignableFrom(__cl))
			return DrawingItemMethod.SPACER;
		else if (StringItem.class.isAssignableFrom(__cl))
			return DrawingItemMethod.STRING_ITEM;
		else if (TextField.class.isAssignableFrom(__cl))
			return DrawingItemMethod.TEXT_FIELD;
		
		// {@squirreljme.error EB39 Could not get the item drawing method of
		// the given class. (The class)}
		throw new IllegalArgumentException("EB39 " + __cl);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/DrawingMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.FileSelector;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TabbedPane;
import javax.microedition.lcdui.TextBox;

/**
 * This contains various drawing methods which modify how a display is
 * drawn.
 *
 * @since 2019/05/18
 */
public enum DrawingMethod
{
	/** Alert. */
	ALERT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("ALERT", 0, 0, 0);
		}
	},
	
	/** Canvas. */
	CANVAS
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			((ExposedDisplayable)__d).paint(__g);
		}
	},
	
	/** File selector. */
	FILE_SELECTOR
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("FILE_SELECTOR", 0, 0, 0);
		}
	},
	
	/** Form. */
	FORM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			Form form = (Form)__d;
			
			// Number of entries
			int n = form.size();
			
			// Working base coordinates for each item
			int dx = 0,
				dy = 0;
			
			// Font and height for labels
			Font labelfont = StandardMetrics.itemLabelFont();
			int labelh = labelfont.getHeight();
			
			// Draw each entry
			for (int i = 0; i < n; i++)
			{
				// Reset X draw
				dx = 0;
				
				// Get item here
				Item item = form.get(i);
				
				// Get item properties
				String il = item.getLabel();
				int iw = Math.min(__w, item.getPreferredWidth());
				int ih = item.getPreferredHeight();
				boolean ie = true;
				boolean is = false;
				
				// Fill background in
				__g.setAlphaColor(StandardMetrics.itemBackgroundColor(ie, is));
				__g.fillRect(dx, dy, iw, ih);
				
				// Set used color
				__g.setAlphaColor(StandardMetrics.itemForegroundColor(ie, is));
				
				// Draw label if one is used
				if (il != null)
				{
					// Draw label
					__g.setFont(labelfont);
					__g.drawString(il, dx, dy, Graphics.TOP);
					
					// Move to item area now
					dy += labelh;
				}
				
				// Draw the item
				DrawingItemMethod.of(item.getClass()).paint(__d, item, __s,
					__g, dx, dy, iw, ih, true, false);
				
				// Is this item being focused? Set the focus box on it
				/*if (item == form.getCurrent())
					__s.focusbox.set(dx, dy, iw - 2, ih - 2);*/
				
				// Move to next item
				dy += ih;
			}
		}
	},
	
	/** List. */
	LIST
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			List list = (List)__d;
			
			// Working base coordinates for each item
			int dx = 0,
				dy = 0;
			
			// Selected index
			int sel = list.getSelectedIndex();
			
			// Make sure focus is in bounds
			int focusdx = __s.focusdx;
			int n = list.size();
			if (focusdx < 0)
				focusdx = 0;
			else if (focusdx >= n)
				focusdx = n - 1;
			
			// Default font
			Font dfont = Font.getFont(StandardMetrics.LIST_ITEM_FONT, 0,
				StandardMetrics.LIST_ITEM_HEIGHT);
			
			// Draw all list items
			for (int i = 0; i < n; i++)
			{
				// Reset X draw
				dx = 0;
				
				// Get item properties
				String vs = list.getString(i);
				Image vi = list.getImage(i);
				Font vf = list.getFont(i);
				boolean ve = list.isEnabled(i);
				boolean vl = list.isSelected(i);
				
				// Use a default fallback font?
				if (vf == null)
					vf = dfont;
				
				// Height of this item
				int ih = vf.getPixelSize();
				
				// Increase height for the image size?
				if (vi != null)
				{
					int mh = vi.getHeight();
					if (mh > ih)
						ih = mh;
				}
				
				// Draw background
				__g.setColor(StandardMetrics.itemBackgroundColor(ve, vl));
				__g.fillRect(dx, dy,
					__w, ih);
				
				// Draw image?
				if (vi != null)
				{
					__g.drawImage(vi, dx, dy, Graphics.TOP | Graphics.LEFT);
					dx += vi.getWidth();
				}
				
				// Draw text
				__g.setColor(StandardMetrics.itemForegroundColor(ve, vl));
				__g.setFont(vf);
				__g.drawString(vs, dx, dy, Graphics.TOP | Graphics.LEFT);
				
				// Is this item being focused?
				if (focusdx == i)
					__s.focusbox.set(dx, dy, __w - 2, ih - 2);
				
				// Move to next item
				dy += ih;
			}
		}
	},
	
	/** Tabbed pane. */
	TABBED_PANE
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("TABBED_PANE", 0, 0, 0);
		}
	},
	
	/** Text box. */
	TEXT_BOX
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("TEXT_BOX", 0, 0, 0);
		}
	},
	
	/** End. */
	;
	
	/**
	 * Paints the method.
	 *
	 * @param __d The displayable to be drawn.
	 * @param __s The draw state.
	 * @param __g The graphics to draw to.
	 * @param __w The display width.
	 * @param __h The display height.
	 * @since 2019/05/18
	 */
	public abstract void paint(Displayable __d, State __s, Graphics __g,
		int __w, int __h);
	
	/**
	 * Returns the drawing method for the given class.
	 *
	 * @param __cl The class to draw for.
	 * @return The drawing method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/18
	 */
	public static final DrawingMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (Alert.class.isAssignableFrom(__cl))
			return DrawingMethod.ALERT;
		else if (Canvas.class.isAssignableFrom(__cl))
			return DrawingMethod.CANVAS;
		else if (FileSelector.class.isAssignableFrom(__cl))
			return DrawingMethod.FILE_SELECTOR;
		else if (Form.class.isAssignableFrom(__cl))
			return DrawingMethod.FORM;
		else if (List.class.isAssignableFrom(__cl))
			return DrawingMethod.LIST;
		else if (TabbedPane.class.isAssignableFrom(__cl))
			return DrawingMethod.TABBED_PANE;
		else if (TextBox.class.isAssignableFrom(__cl))
			return DrawingMethod.TEXT_BOX;
		
		// {@squirreljme.error EB18 Could not get the drawing method of the
		// given class. (The class)}
		throw new IllegalArgumentException("EB18 " + __cl);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/ExposedDisplayable.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
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
191
192
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Ticker;

/**
 * This is a base class for items which need to be exposed action wise and
 * such. All methods here by default do nothing.
 *
 * @since 2019/05/17
 */
public abstract class ExposedDisplayable
{
	/** Drawing/action state. */
	final State _dstate =
		new State();
	
	/**
	 * Returns the command listener.
	 *
	 * @return The command listener.
	 * @since 2019/05/18
	 */
	protected CommandListener getCommandListener()
	{
		return null;
	}
	
	/**
	 * Gets the commands which are available to use.
	 *
	 * @return The available commands.
	 * @since 2019/05/17
	 */
	protected Command[] getCommands()
	{
		return new Command[0];
	}
	
	/**
	 * Gets the ticker which is being shown on this displayable.
	 *
	 * @return The ticker being shown or {@code null} if there is none.
	 * @since 2019/05/18
	 */
	protected Ticker getTicker()
	{
		return null;
	}
	
	/**
	 * Is this widget a full-screen one?
	 *
	 * @return If this is full-screen or not.
	 * @since 2019/05/17
	 */
	protected boolean isFullscreen()
	{
		return false;
	}
	
	/**
	 * Is this display transparent?
	 *
	 * @return If the display is transparent.
	 * @since 2019/05/17
	 */
	protected boolean isTransparent()
	{
		return true;
	}
	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyPressed(int __code)
	{
	}
	
	/**
	 * This is called when a key has been released.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyReleased(int __code)
	{
	}
	
	/**
	 * This is called when a key has been repeated.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyRepeated(int __code)
	{
	}
	
	/**
	 * This is called when the displayable needs to be painted onto the
	 * screen.
	 *
	 * @param __g The graphics to draw into.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void paint(Graphics __g)
	{
	}
	
	/**
	 * This is called when the pointer is being dragged across the canvas, a
	 * drag is when there is movement 
	 *
	 * This requires that motion events are supported which can be known by
	 * calling {@link Canvas#hasPointerMotionEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerDragged(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been pressed on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link Canvas#hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2019/05/18
	 */
	@SerializedEvent
	protected void pointerPressed(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been released on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link Canvas#hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2019/05/18
	 */
	@SerializedEvent
	protected void pointerReleased(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the size of the displayable has changed.
	 *
	 * @param __w The new width of the displayable.
	 * @param __h The new heigh of the displayable.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/NativeUIBackend.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import cc.squirreljme.runtime.lcdui.gfx.AcceleratedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;

/**
 * This is a backend which utilizes the SquirrelJME UI interface for all of
 * the related drawing applications.
 *
 * @since 2019/05/16
 */
public final class NativeUIBackend
	implements NativeDisplayEventCallback, PhoneDisplayBackend
{
	/**
	 * {@squirreljme.property cc.squirreljme.lcdui.acceleration=bool
	 * Should accelerated graphics be used if it is available? This defaults
	 * to {@code true} and it is recommended it be used, otherwise it may be
	 * disabled if it causes issues with some software.}
	 */
	public static boolean USE_ACCELERATION =
		Boolean.valueOf(System.getProperty("cc.squirreljme.lcdui.acceleration",
		"true"));
	
	/** The native display ID. */
	protected final int nid;
	
	/** The pixel format of the buffer. */
	protected final PixelFormat pixelformat;
	
	/** The active display to use. */
	private volatile ActiveDisplay _activedisplay;
	
	/** The display width. */
	private int _width;
	
	/** The display height. */
	private int _height;
	
	/**
	 * Initializes the native UI backend using the given display ID.
	 *
	 * @param __nid The native display ID this uses.
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Throw an exception if this has failed
		int pft = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_FORMAT);
		SystemCallError.checkError(SystemCallIndex.FRAMEBUFFER);
		
		// Set pixel format
		this.pixelformat = PixelFormat.ofFramebuffer(pft);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void activate(ActiveDisplay __ad)
		throws NullPointerException
	{
		if (__ad == null)
			throw new NullPointerException("NARG");
		
		// Set the active display
		this._activedisplay = __ad;
		
		if (true)
			throw new todo.TODO();
		
		// Register self for event callbacks
		NativeDisplayAccess.registerEventCallback(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	public final int capabilities()
	{
		// Get native capabilities
		int fbcaps = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_GET_CAPABILITIES);
		
		// Translate to LCDUI capabilities
		int rv = 0;
		if ((fbcaps & Framebuffer.CAPABILITY_TOUCH) != 0)
			rv |= ExtendedCapabilities.SUPPORTS_POINTER_EVENTS |
				Display.SUPPORTS_INPUT_EVENTS;
		if ((fbcaps & Framebuffer.CAPABILITY_KEYBOARD) != 0)
			rv |= Display.SUPPORTS_INPUT_EVENTS;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void command(int __d, int __c)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.command(__c))
			this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void exitRequest(int __d)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// Forward
		this._activedisplay.exitRequest();
	}
	
	/**
	 * Returns the native display graphics.
	 *
	 * @param __a Output boolean if this is accelerated.
	 * @param __dims Screen dimensions.
	 * @return The graphics for this backend.
	 * @since 2019/05/16
	 */
	public final Graphics graphics(boolean[] __a, int[] __dims)
		throws NullPointerException
	{
		if (__dims == null)
			throw new NullPointerException("NARG");
		
		if (true)
			throw new todo.TODO();
		
		// Read width and height
		int[] params = NativeDisplayAccess.framebufferParameters(this.nid);
		int width = params[NativeDisplayAccess.PARAMETER_BUFFERWIDTH];
		int height = params[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT];
		
		// Set
		__dims[0] = width;
		__dims[1] = height;
		
		// Remember size
		this._width = width;
		this._height = height;
		
		// If acceleration is enabled, try to get accelerated graphics
		int nid = this.nid;
		if (NativeUIBackend.USE_ACCELERATION)
			try
			{
				// Try to get it
				Graphics rv = AcceleratedGraphics.instance();
				
				// Set acceleration flag
				if (__a != null && __a.length > 1)
					__a[0] = true;
				
				return rv;
			}
			catch (UnsupportedOperationException e)
			{
			}
			
		// Get data buffers and properties
		Object buf = NativeDisplayAccess.framebufferObject(nid);
		int[] pal = NativeDisplayAccess.framebufferPalette(nid);
		
		// Set parameters
		boolean alpha = params[NativeDisplayAccess.PARAMETER_ALPHA] != 0;
		int pitch = params[NativeDisplayAccess.PARAMETER_PITCH];
		int offset = params[NativeDisplayAccess.PARAMETER_OFFSET];
		int virtxorig = params[NativeDisplayAccess.PARAMETER_VIRTXOFF];
		int virtyorig = params[NativeDisplayAccess.PARAMETER_VIRTYOFF];
		
		// Create graphics from it
		return this.pixelformat.createGraphics(buf, pal, width, height,
			alpha, pitch, offset, virtxorig, virtyorig);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final boolean isUpsidedown()
	{
		if (true)
			throw new todo.TODO();
		
		return NativeDisplayAccess.isUpsideDown(this.nid);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.keyEvent(__ty, __kc, __ch, __time))
			this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void lostCallback()
	{
		if (true)
			throw new todo.TODO();
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// Paint whatever is in the active display
		ActiveDisplay ad = this._activedisplay;
		if (ad != null)
		{
			// Get screen graphics and dimensions
			int[] dims = new int[2];
			Graphics g = this.graphics(null, dims);
			
			// Get display size and desired display size
			int gw = dims[0],
				gh = dims[1],
				dw = ad.width,
				dh = ad.height;
			
			// Perform potential centering?
			/*if (gw > dw && gh > dh)
				g = new EnforcedDrawingAreaGraphics(g,
					(gw >> 1) - (dw >> 1), (gh >> 1) - (dh >> 1),
					dw, dh);*/
			
			// Set clipping area
			g.setClip(0, 0, dw, dh);
			
			// Perform painting operation
			ad.paint(g, __x, __y, __w, __h);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final PixelFormat pixelFormat()
	{
		return this.pixelformat;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.pointerEvent(__ty, __x, __y, __time))
			this.repaint();
	}
	
	/**
	 * Repaints the entire display.
	 *
	 * @since 2019/05/18
	 */
	public final void repaint()
	{
		if (true)
			throw new todo.TODO();
			
		NativeDisplayAccess.displayRepaint(this.nid,
			0, 0, this._width, this._height);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
			
		NativeDisplayAccess.displayRepaint(this.nid, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void shown(int __d, int __shown)
	{
		if (true)
			throw new todo.TODO();
			
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
			
		// Not our display?
		if (__d != this.nid)
			return;
		
		ActiveDisplay ad = this._activedisplay;
		if (ad != null)
		{
			int[] dm = new int[4];
			if (ad.realize(dm))
				((ExposedDisplayable)ad._current).sizeChanged(dm[2], dm[3]);
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/PhoneDisplayBackend.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
66
67
68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;

/**
 * This interface is used to represent the backend that the UI uses to draw
 * onto the target device. This may be an image or an actual UI.
 *
 * @since 2019/05/16
 */
public interface PhoneDisplayBackend
{
	/**
	 * Activates the display.
	 *
	 * @param __ad The active display to draw into.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	void activate(ActiveDisplay __ad)
		throws NullPointerException;
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @return The display capabilities.
	 * @since 2019/05/17
	 */
	int capabilities();
	
	/**
	 * Returns if the display is upside-down, this is used for orientation
	 * purposes.
	 *
	 * @return If the display is upside-down.
	 * @since 2019/05/16
	 */
	boolean isUpsidedown();
	
	/**
	 * Returns the pixel format of the display.
	 *
	 * @return The display pixel format.
	 * @since 2019/05/16
	 */
	PixelFormat pixelFormat();
	
	/**
	 * Specifies that the display should be repainted now.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	void repaint(int __x, int __y, int __w, int __h);
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/PhoneUI.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Displayable;

/**
 * This class contains the definition and holders for the phone based user
 * interface.
 *
 * @since 2019/05/16
 */
@Deprecated
public final class PhoneUI
{
	/** The width of the phone screen. */
	public static final int DEFAULT_SCREEN_WIDTH =
		240;
	
	/** The height of the phone screen. */
	public static final int DEFAULT_SCREEN_HEIGHT =
		320;
	
	/** Used to ignore realization. */
	static final int[] _IGNORE_REALIZATION =
		new int[4];
	
	/** The width of the phone screen. */
	public final int width;
	
	/** The height of the phone screen. */
	public final int height;
	
	/** The backend this UI uses. */
	protected final PhoneDisplayBackend backend;
	
	/** Active display image. */
	protected final ActiveDisplay activedisplay;
	
	/** The current displayable to show. */
	private Displayable _current;
	
	/** Should the display be repainted? */
	private volatile boolean _repaint;
	
	/**
	 * Initializes the base UI using the default screen size.
	 *
	 * @param __b The display backend to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public PhoneUI(PhoneDisplayBackend __b)
		throws NullPointerException
	{
		this(__b, PhoneUI.DEFAULT_SCREEN_WIDTH, PhoneUI.DEFAULT_SCREEN_HEIGHT);
	}
	
	/**
	 * Initializes the UI with the given screen width and height.
	 *
	 * @param __b The display backend to use.
	 * @param __sw The screen width.
	 * @param __sh The screen height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	public PhoneUI(PhoneDisplayBackend __b, int __sw, int __sh)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		this.backend = __b;
		this.width = (__sw = (__sw <= 0 ? PhoneUI.DEFAULT_SCREEN_WIDTH : __sw));
		this.height = (__sh = (__sh <= 0 ? PhoneUI.DEFAULT_SCREEN_HEIGHT : __sh));
		
		// Set active display
		ActiveDisplay activedisplay = new ActiveDisplay(__sw, __sh);
		this.activedisplay = activedisplay;
	}
	
	/**
	 * Returns the height of the content area.
	 *
	 * @return The content area height.
	 * @since 2019/05/16
	 */
	public final int contentHeight()
	{
		return this.activedisplay._contentheight;
	}
	
	/**
	 * Returns the width of the content area.
	 *
	 * @return The content area width.
	 * @since 2019/05/16
	 */
	public final int contentWidth()
	{
		return this.activedisplay._contentwidth;
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @since 2019/05/16
	 */
	public final void repaint()
	{
		this.repaint(0, 0, this.width, this.height);
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		// Realize active display size
		this.activedisplay.realize(PhoneUI._IGNORE_REALIZATION);
		
		// Repaint
		this.backend.repaint(__x, __y, __w, __h);
	}
	
	/**
	 * Sets the current displayable to be drawn.
	 *
	 * @param __d The displayable to draw.
	 * @since 2019/05/16
	 */
	public final void setCurrent(Displayable __d)
	{
		// Set
		this._current = __d;
		
		// Activate the display
		ActiveDisplay ad = this.activedisplay;
		ad.activate(__d);
		this.backend.activate(ad);
		
		// Repaint
		this.repaint();
	}
	
	/**
	 * Sets the title of what is displayed on the screen.
	 *
	 * @param __t The title to use, {@code null} uses a default title.
	 * @since 2019/05/16
	 */
	public final void setTitle(String __t)
	{
		// Default title?
		if (__t == null)
			__t = "SquirrelJME";
		
		// Set
		this.activedisplay._title = __t;
		
		// Repaint
		if (this._current != null)
			this.repaint();
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/StandardMetrics.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Font;

/**
 * This contains standard metrics for screen parts and such.
 *
 * @since 2019/05/16
 */
public final class StandardMetrics
{
	/** UI Font size. */
	public static final byte UI_FONT_SIZE =
		16;
	
	/** Height of the title bar. */
	public static final int TITLE_BAR_HEIGHT = StandardMetrics.UI_FONT_SIZE;
	
	/** Height of the command bar. */
	public static final int COMMAND_BAR_HEIGHT = StandardMetrics.UI_FONT_SIZE;
	
	/** The background bar color. */
	public static final int BACKGROUND_BAR_COLOR =
		0xFF_000000;
	
	/** The foreground bar color. */
	public static final int FOREGROUND_BAR_COLOR =
		0xFF_FFFFFF;
	
	/** Transparent background color. */
	public static final int TRANSPARENT_COLOR =
		0xFF_FFFFFF;
	
	/** Vibration symbol color. */
	public static final int VIBRATE_COLOR =
		0xFF_FF00FF;
	
	/** Height of the ticker bar. */
	public static final int TICKER_BAR_HEIGHT = StandardMetrics.UI_FONT_SIZE;
	
	/** Background color of the ticker bar. */
	public static final int BACKGROUND_TICKER_COLOR =
		0xFF_A6F6FF;
	
	/** Foreground color of the ticker bar. */
	public static final int FOREGROUND_TICKER_COLOR =
		0xFF_000000;
	
	/** The font used for list items. */
	public static final String LIST_ITEM_FONT =
		"sansserif";
	
	/** The height of list items. */
	public static final int LIST_ITEM_HEIGHT = StandardMetrics.UI_FONT_SIZE;
	
	/** Enabled normal foreground. */
	public static final int ENABLED_NORMAL_FOREGROUND =
		0xFF_000000;
	
	/** Enabled normal background. */
	public static final int ENABLED_NORMAL_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Enabled selected foreground. */
	public static final int ENABLED_SELECTED_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Enable selected background. */
	public static final int ENABLED_SELECTED_BACKGROUND =
		0xFF_000088;
	
	/** Disabled normal foreground. */
	public static final int DISABLED_NORMAL_FOREGROUND =
		0xFF_888888;
	
	/** Disabled normal background. */
	public static final int DISABLED_NORMAL_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Disabled selected foreground. */
	public static final int DISABLED_SELECTED_FOREGROUND =
		0xFF_AAAAAA;
	
	/** Disabled selected background. */
	public static final int DISABLED_SELECTED_BACKGROUND =
		0xFF_888888;
	
	/** The focus box color (A). */
	public static final int FOCUS_A_COLOR =
		0xFF_FF0000;
	
	/** The focus box color (B). */
	public static final int FOCUS_B_COLOR =
		0xFF_FFFF00;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/16
	 */
	private StandardMetrics()
	{
	}
	
	/**
	 * Returns the background color.
	 *
	 * @param __en Is this enabled?
	 * @param __sl Is this selected?
	 * @return The color to use.
	 * @since 2019/05/18
	 */
	public static final int itemBackgroundColor(boolean __en, boolean __sl)
	{
		if (__en)
			if (__sl)
				return StandardMetrics.ENABLED_SELECTED_BACKGROUND;
			else
				return StandardMetrics.ENABLED_NORMAL_BACKGROUND;
		else
			if (__sl)
				return StandardMetrics.DISABLED_SELECTED_BACKGROUND;
			else
				return StandardMetrics.DISABLED_NORMAL_BACKGROUND;
	}
	
	/**
	 * Returns the foreground color.
	 *
	 * @param __en Is this enabled?
	 * @param __sl Is this selected?
	 * @return The color to use.
	 * @since 2019/05/18
	 */
	public static final int itemForegroundColor(boolean __en, boolean __sl)
	{
		if (__en)
			if (__sl)
				return StandardMetrics.ENABLED_SELECTED_FOREGROUND;
			else
				return StandardMetrics.ENABLED_NORMAL_FOREGROUND;
		else
			if (__sl)
				return StandardMetrics.DISABLED_SELECTED_FOREGROUND;
			else
				return StandardMetrics.DISABLED_NORMAL_FOREGROUND;
	}
	
	/**
	 * Returns the item label font.
	 *
	 * @return The item label font.
	 * @since 2019/12/09
	 */
	public static final Font itemLabelFont()
	{
		return Font.getFont(StandardMetrics.LIST_ITEM_FONT, 0,
			StandardMetrics.LIST_ITEM_HEIGHT);
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/State.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.phoneui;

/**
 * This class contains the drawing state to modify what is on screen and
 * such.
 *
 * @since 2019/05/18
 */
public class State
{
	/** The focus index coordinates. */
	public final Box focusbox =
		new Box(-1, -1, 0, 0);
	
	/** The focused index. */
	public int focusdx;
	
	/**
	 * Represents a box.
	 *
	 * @since 2019/05/18
	 */
	public static final class Box
	{
		/** X coordinate. */
		public int x;
		
		/** Y coordinate. */
		public int y;
		
		/** Width. */
		public int w;
		
		/** Height. */
		public int h;
		
		/**
		 * Initializes a default box.
		 *
		 * @since 2019/05/18
		 */
		public Box()
		{
		}
		
		/**
		 * Initializes a box with the given coordinates and dimensions.
		 *
		 * @param __x X position.
		 * @param __y Y position.
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/05/18
		 */
		public Box(int __x, int __y, int __w, int __h)
		{
			this.x = __x;
			this.y = __y;
			this.w = __w;
			this.h = __h;
		}
		
		/**
		 * Sets all of the box coordinates.
		 *
		 * @param __x X position.
		 * @param __y Y position.
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/05/18
		 */
		public final void set(int __x, int __y, int __w, int __h)
		{
			this.x = __x;
			this.y = __y;
			this.w = __w;
			this.h = __h;
		}
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/phoneui/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains and defines a user-interface which is very much like
 * ancient mobile phones to allow for maximum application compatibility.
 *
 * @since 2019/05/16
 */

package cc.squirreljme.runtime.lcdui.phoneui;

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/vfb/FramebufferTitleListener.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.vfb;

/**
 * This interface is used to notify of any title updates that have been
 * performed.
 *
 * @since 2020/01/17
 */
public interface FramebufferTitleListener
{
	/**
	 * This is called when the title is updated.
	 *
	 * @param __s The title to set.
	 * @since 2020/01/17
	 */
	void titleUpdated(String __s);
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/vfb/VirtualFramebuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.vfb;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.IPCCallback;

/**
 * This is a virtual framebuffer which may be used by non-SquirrelJME JVMs and
 * by higher level JVMs to allow for IPC based graphics to be used.
 *
 * This assumes that event handling is used.
 *
 * @since 2019/12/28
 */
public final class VirtualFramebuffer
{
	/** The default width. */
	public static final int DEFAULT_WIDTH =
		320;
	
	/** The default height. */
	public static final int DEFAULT_HEIGHT =
		200;
	
	/** The callback to invoke with screen actions. */
	protected final IPCCallback ipc;
	
	/** The width. */
	protected final int width;
	
	/** The height. */
	protected final int height;
	
	/** The raw pixel data. */
	protected final int[] pixels;
	
	/** Title listener. */
	private FramebufferTitleListener _titlelistener;
	
	/**
	 * Initializes the virtual framebuffer.
	 *
	 * @param __ipc The callback to forward events to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebuffer(IPCCallback __ipc)
		throws NullPointerException
	{
		this(__ipc, VirtualFramebuffer.DEFAULT_WIDTH,
			VirtualFramebuffer.DEFAULT_HEIGHT);
	}
	
	/**
	 * Initializes the virtual framebuffer.
	 *
	 * @param __ipc The callback to forward events to.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebuffer(IPCCallback __ipc, int __w, int __h)
	{
		if (__ipc == null)
			throw new NullPointerException("NARG");
		
		// Set IPC to use
		this.ipc = __ipc;
		
		// Set size
		this.width = __w;
		this.height = __h;
		
		// Initialize raw pixel data
		this.pixels = new int[__w * __h];
	}
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __args The call arguments.
	 * @return The result of the property.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public final long framebufferControl(int... __args)
		throws NullPointerException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		// Depends on the length
		switch (__args.length)
		{
				// Nothing to do?
			case 0:
				return 0;
			
			case 1:
				return this.framebufferControl(
					__args[0],
					0, 0, 0, 0, 0, 0, 0, 0);
			
			case 2:
				return this.framebufferControl(
					__args[0],
					__args[1],
					0, 0, 0, 0, 0, 0, 0);
			
			case 3:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					0, 0, 0, 0, 0, 0);
			
			case 4:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					0, 0, 0, 0);
			
			case 5:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					0, 0, 0);
			
			case 6:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					0, 0);
			
			case 7:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					__args[6],
					0);
			
			case 8:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					__args[6],
					__args[7]);
			
			default:
				return 0;
		}
	}
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __pid The property ID.
	 * @param __a The call arguments.
	 * @param __b The call arguments.
	 * @param __c The call arguments.
	 * @param __d The call arguments.
	 * @param __e The call arguments.
	 * @param __f The call arguments.
	 * @param __g The call arguments.
	 * @return The result of the property.
	 * @throws IllegalArgumentException If the property was not known.
	 * @since 2019/12/28
	 */
	public final long framebufferControl(int __pid, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g)
		throws IllegalArgumentException
	{
		// Depends on the property
		switch (__pid)
		{
				// Raw address (since it is simulated, this is not set)
			case Framebuffer.CONTROL_ADDRESS:
				return 0;
				
				// Width and scanline length
			case Framebuffer.CONTROL_WIDTH:
			case Framebuffer.CONTROL_SCANLEN:
				return this.width;
				
				// Height
			case Framebuffer.CONTROL_HEIGHT:
				return this.height;
			
				// Flushes the display
			case Framebuffer.CONTROL_FLUSH:
				throw new todo.TODO();
				
				// Pixel format is always integer
			case Framebuffer.CONTROL_FORMAT:
				return Framebuffer.FORMAT_INTEGER_RGB888;
				
				// Scan line length in bytes
			case Framebuffer.CONTROL_SCANLEN_BYTES:
				return this.width * 4;
				
				// The number of bytes per pixel
			case Framebuffer.CONTROL_BYTES_PER_PIXEL:
				return 4;
				
				// Bits per pixel
			case Framebuffer.CONTROL_BITS_PER_PIXEL:
				return 32;
				
				// The number of pixels
			case Framebuffer.CONTROL_NUM_PIXELS:
				return this.width * this.height;
				
				// Backlight not supported
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_GET:
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_SET:
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_MAX:
				return 0;
				
				// Upload integer array
			case Framebuffer.CONTROL_UPLOAD_ARRAY_INT:
				throw new todo.TODO();
				
				// The backing array object
			case Framebuffer.CONTROL_BACKING_ARRAY_OBJECT:
				return Assembly.objectToPointer(this.pixels);
				
				// Returns the capabilities of the display.
			case Framebuffer.CONTROL_GET_CAPABILITIES:
				return Framebuffer.CAPABILITY_TOUCH |
					Framebuffer.CAPABILITY_KEYBOARD |
					Framebuffer.CAPABILITY_IPC_EVENTS |
					Framebuffer.CAPABILITY_COLOR;
				
				// Query acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_QUERY:
				throw new todo.TODO();
			
				// Perform acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_INVOKE:
				throw new todo.TODO();
				
				// Set title
			case Framebuffer.CONTROL_SET_TITLE:
				if (__a != 0)
				{
					FramebufferTitleListener tl = this._titlelistener;
					if (tl != null)
						tl.titleUpdated(
							new String((char[])Assembly.pointerToObject(__a)));
				}
				return 0;
				
				// {@squirreljme.error EB3b Unknown control property.}
			default:
				throw new IllegalArgumentException("EB3b");
		}
	}
	
	/**
	 * Returns the framebuffer pixels.
	 *
	 * @return The framebuffer pixels.
	 * @since 2020/01/18
	 */
	public final int[] pixels()
	{
		return this.pixels;
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/vfb/VirtualFramebufferCanvas.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.runtime.lcdui.vfb;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

/**
 * This is a virtualized framebuffer that provides a LCDUI canvas.
 *
 * @see VirtualFramebuffer
 * @since 2019/12/28
 */
public final class VirtualFramebufferCanvas
	extends Canvas
{
	/** The framebuffer to use. */
	protected final VirtualFramebuffer framebuffer;
	
	/**
	 * Initializes the framebuffer canvas.
	 *
	 * @param __fb The framebuffer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebufferCanvas(VirtualFramebuffer __fb)
		throws NullPointerException
	{
		if (__fb == null)
			throw new NullPointerException("NARG");
		
		this.framebuffer = __fb;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyPressed(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyReleased(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyRepeated(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void paint(Graphics __g)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerDragged(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerPressed(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerReleased(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void showNotify()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void sizeChanged(int __w, int __h)
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/cc/squirreljme/runtime/lcdui/vfb/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This contains an implementation of the SquirrelJME virtual framebuffer, it
 * provides a canvas and callback handler that can be used by virtual machines
 * using SquirrelJME to hook into its graphics callback system.
 *
 * @since 2019/12/28
 */

package cc.squirreljme.runtime.lcdui.vfb;

Added modules/midp-lcdui/src/main/java/com/nokia/mid/ui/DeviceControl.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.nokia.mid.ui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.DeviceFeedbackType;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is used to utilize special hardware that exists on the device for
 * user feedback.
 *
 * @since 2019/10/05
 */
public class DeviceControl
{
	/**
	 * Flashes the LED on the device.
	 *
	 * @param __ms The number of milliseconds to flash for.
	 * @throws IllegalArgumentException If the duration is negative.
	 * @since 2019/10/05
	 */
	public static void flashLights(long __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2z Cannot blink for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB2z");
		
		// Blink!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.BLINK_LED, ((__ms > (long)Integer.MAX_VALUE) ?
				Integer.MAX_VALUE : (int)__ms));
	}
	
	/**
	 * Sets the level of the backlight.
	 *
	 * @param __num The light number, this is always zero for the backlight.
	 * @param __lvl The level to set within the range of {@code [0, 100]}
	 * @throws IllegalArgumentException If the light number is not zero or
	 * the level is out of range.
	 * @since 2019/10/05
	 */
	public static void setLights(int __num, int __lvl)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB31 Only light number zero is supported.
		// (The light number)}
		if (__num != 0)
			throw new IllegalArgumentException("EB31 " + __num);
			
		// {@squirreljme.error EB32 Light level out of range. (The level)}
		if (__lvl < 0 || __lvl > 100)
			throw new IllegalArgumentException("EB32 " + __lvl);
		
		// Get maximum backlight level, stop if it is zero which means the
		// property is not supported or there is no backlight that can be
		// controlled
		int max = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_BACKLIGHT_LEVEL_MAX);
		if (max == 0)
			return;
		
		// Set the desired level as a percentage of the max
		int val = (max * __lvl) / 100;
		Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_BACKLIGHT_LEVEL_SET,
			(val < 0 ? 0 : (val > max ? max : val)));
	}
	
	/**
	 * Starts vibrating at the given frequency for the given duration.
	 *
	 * @param __freq The frequency of the vibration, must be in the range of
	 * {@code [0, 100]}.
	 * @param __ms The length to vibrate for in milliseconds.
	 * @throws IllegalArgumentException If the duration is negative or the
	 * frequency is out of range.
	 * @since 2019/10/05
	 */
	public static void startVibra(int __freq, long __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB33 Cannot vibrate for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB33");
		
		// {@squirreljme.error EB34 Frequency out of range. (The frequency)}
		if (__freq < 0 || __freq > 100)
			throw new IllegalArgumentException("EB34 " + __freq);
		
		// Vibrate!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, ((__ms > (long)Integer.MAX_VALUE) ?
				Integer.MAX_VALUE : (int)__ms));
	}
	
	/**
	 * Stops any vibration that is happening.
	 *
	 * @since 2019/10/05
	 */
	public static void stopVibra()
	{
		// Clear vibration
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, 0);
	}
}

Added modules/midp-lcdui/src/main/java/com/nokia/mid/ui/DirectGraphics.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.nokia.mid.ui;

/**
 * This interface provides direct framebuffer pixel access.
 *
 * @since 2019/10/07
 */
public interface DirectGraphics
{
}

Added modules/midp-lcdui/src/main/java/com/nokia/mid/ui/DirectUtils.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.nokia.mid.ui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This class acts as a placeholder for utility methods.
 *
 * @since 2019/10/07
 */
public class DirectUtils
{
	/**
	 * Creates a mutable image with the given ARGB color for all pixels.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @param __argb The ARGB color to do.
	 * @return The created mutable image.
	 * @throws IllegalArgumentException If the width and/or height or negative
	 * or exceed the array bounds.
	 * @since 2019/10/07
	 */
	public static Image createImage(int __w, int __h, int __argb)
		throws IllegalArgumentException
	{
		return Image.createImage(__w, __h, true, __argb);
	}
	
	/**
	 * Loads a mutable image from the specified byte array.
	 *
	 * @param __b The byte data.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The mutable image.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IllegalArgumentException If the image could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/07
	 */
	public static Image createImage(byte[] __b, int __o, int __l)
	{
		// Load the base image
		Image base = Image.createImage(__b, __o, __l);
		
		// Create blank mutable
		int w, h;
		Image mutable = Image.createImage(
			(w = base.getWidth()), (h = base.getHeight()),
			base.hasAlpha(), 0);
			
		// Setup graphics state, use SRC blending mode since it is just a
		// copy of the alpha channel data!
		Graphics g = mutable.getGraphics();
		g.setBlendingMode(Graphics.SRC);
		
		// Draw image on top
		g.drawRegion(base, 0, 0, w, h, 0, 0, 0, 0);
		
		// Use resulting image
		return mutable;
	}
	
	/**
	 * Returns an interface which wraps the given graphics and provides raw
	 * pixel data access to it.
	 *
	 * @param __g The graphics object to wrap.
	 * @return The direct graphics.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/07
	 */
	public static DirectGraphics getDirectGraphics(Graphics __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/com/nokia/mid/ui/FullCanvas.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.nokia.mid.ui;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * This the Nokia canvas, command buttons are forwarded to the key pressed
 * and released commands for the canvas.
 *
 * @since 2019/09/23
 */
public abstract class FullCanvas
	extends Canvas
{
	/** Virtual soft key 1. */
	private static final Command _SOFT1 =
		new Command("Soft1", Command.SCREEN, 0);
		
	/** Virtual soft key 2. */
	private static final Command _SOFT2 =
		new Command("Soft2", Command.SCREEN, 1);
		
	/** Virtual soft key 3. */
	private static final Command _SOFT3 =
		new Command("Soft3", Command.SCREEN, 2);
	
	/** Down arrow. */
	public static final int KEY_DOWN_ARROW =
		-2;
	
	/** End. */
	public static final int KEY_END =
		-11;
	
	/** Left arrow. */
	public static final int KEY_LEFT_ARROW =
		-3;
	
	/** Right arrow. */
	public static final int KEY_RIGHT_ARROW =
		-4;
	
	/** Send. */
	public static final int KEY_SEND =
		-10;
	
	/** Soft Key 1. */
	public static final int KEY_SOFTKEY1 =
		-6;
	
	/** Soft Key 2. */
	public static final int KEY_SOFTKEY2 =
		-7;
	
	/** Soft Key 3. */
	public static final int KEY_SOFTKEY3 =
		-5;
	
	/** Up Arrow. */
	public static final int KEY_UP_ARROW =
		-1;
	
	/**
	 * Initializes the base canvas and sets as full-screen.
	 *
	 * @since 2019/09/23
	 */
	@Deprecated
	public FullCanvas()
	{
		// Nokia API just says to call this instead, so this is done
		this.setFullScreenMode(true);
		
		// Since we need to simulate soft commands in the game, we have to
		// add our own commands and such to this.
		this.addCommand(FullCanvas._SOFT1);
		this.addCommand(FullCanvas._SOFT2);
		this.addCommand(FullCanvas._SOFT3);
		
		// Then use virtual command listener to forward
		this.setCommandListener(new __VirtualListener__());
	}
	
	/**
	 * Always throws {@link IllegalStateException} as commands are not
	 * supported in Nokia canvases.
	 *
	 * @param __c The command to add.
	 * @throws IllegalStateException Always.
	 * @since 2019/09/23
	 */
	@Override
	public void addCommand(Command __c)
	{
		// Since we are providing this special functionality we need to wrap
		// but still access these internal commands
		if (__c == FullCanvas._SOFT1 || __c == FullCanvas._SOFT2 ||
			__c == FullCanvas._SOFT3)
		{
			super.addCommand(__c);
			return;
		}
		
		// {@squirreljme.error EB2x Commands are not supported.}
		throw new IllegalStateException("EB2x");
	}
	
	/**
	 * Always throws {@link IllegalStateException} as commands are not
	 * supported in Nokia canvases.
	 *
	 * @param __l The command to add.
	 * @throws IllegalStateException Always.
	 * @since 2019/09/23
	 */
	@Override
	public void setCommandListener(CommandListener __l)
	{
		// Since this is virtualized, we do want to handle this one!
		if (__l instanceof __VirtualListener__)
		{
			super.setCommandListener(__l);
			return;
		}
		
		// {@squirreljme.error EB2y Commands are not supported.}
		throw new IllegalStateException("EB2y");
	}
	
	/**
	 * Command listener to forward keys to the canvas.
	 *
	 * @since 2019/09/23
	 */
	private static final class __VirtualListener__
		implements CommandListener
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/09/23
		 */
		@Override
		public final void commandAction(Command __c, Displayable __d)
		{
			// Do nothing if this is some other thing
			if (!(__d instanceof FullCanvas))
				return;
			
			// Determine code to use
			int code;
			if (__c == FullCanvas._SOFT1)
				code = FullCanvas.KEY_SOFTKEY1;
			else if (__c == FullCanvas._SOFT2)
				code = FullCanvas.KEY_SOFTKEY2;
			else if (__c == FullCanvas._SOFT3)
				code = FullCanvas.KEY_SOFTKEY3;
			
			// Unknown?
			else
				return;
			
			// Press and release, since that is all we can do really!
			FullCanvas fc = (FullCanvas)__d;
			fc.keyPressed(code);
			fc.keyReleased(code);
		}
	}
}

Added modules/midp-lcdui/src/main/java/com/nokia/mid/ui/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Nokia Proprietary Graphics Support.
 *
 * @since 2019/09/23
 */

package com.nokia.mid.ui;

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Alert.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Alert
	extends Screen
{
	/**
	 * This is delivered to a listener to specify that the alert has been
	 * dismissed.
	 */
	public static final Command DISMISS_COMMAND =
		new Command("Okay", Command.OK, 0, true);
	
	/** Specifies that the alert should last forever. */
	public static final int FOREVER =
		-2;
	
	/** The message to display. */
	volatile String _message;
	
	/** The image to use. */
	volatile Image _image;
	
	/** The type of alert this is. */
	volatile AlertType _type;
	
	/** The duration the alert should last in milliseconds. */
	volatile int _timeout = Alert.FOREVER;
	
	/**
	 * Initializes the alert with just a title.
	 *
	 * @param __title The title of the alert, may be {@code null}.
	 * @since 2017/02/28
	 */
	public Alert(String __title)
	{
		this(__title, null, null, null);
	}
	
	/**
	 * Initializes the alert with just a title, message, image, and type.
	 *
	 * @param __title The title of the alert, may be {@code null}.
	 * @param __message The message to show in the alert, may be {@code null}.
	 * @param __icon The icon to display, may be {@code null}.
	 * @param __type The type of this alert, may be {@code null}.
	 * @since 2017/02/28
	 */
	public Alert(String __title, String __message, Image __icon,
		AlertType __type)
	{
		this._message = __message;
		this._image = __icon;
		this._type = __type;
		
		// Set titles
		this._title = __title;
		if (__title != null)
			this._dtitle = __title;
	}
	
	@Override
	public void addCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public int getDefaultTimeout()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	public Gauge getIndicator()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public int getTimeout()
	{
		throw new todo.TODO();
	}
	
	public AlertType getType()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	@Override
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void setCommandListener(CommandListener __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this alert. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code alert.setImage(alert.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	public void setIndicator(Gauge __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the message which is used in the alert.
	 *
	 * @param __s The message to use.
	 * @since 2017/02/28
	 */
	public void setString(String __s)
	{
		throw new todo.TODO();
		/*
		this._message = __s;
		
		todo.DEBUG.note("Set alert message: %s%n", __s);
		*/
	}
	
	/**
	 * Sets the duration for which the alert should last.
	 *
	 * @param __ms The number of milliseconds to display the message for or
	 * {@link #FOREVER}.
	 * @throws IllegalArgumentException If the duration is not positive and is
	 * not {@link #FOREVER}.
	 * @since 2017/02/28
	 */
	public void setTimeout(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB19 The specified number of milliseconds is
		// negative. (The number of milliseconds specified)}
		if (__ms < 0 && __ms != Alert.FOREVER)
			throw new IllegalArgumentException(String.format("EB19 %d", __ms));
		
		// Set
		this._timeout = __ms;
	}
	
	/**
	 * Sets the type of this alert.
	 *
	 * @param __t The alert type, may be {@code null}.
	 * @since 2017/02/28
	 */
	public void setType(AlertType __t)
	{
		throw new todo.TODO();
		/*
		this._type = __t;
		*/
	}
}


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

package javax.microedition.lcdui;

/**
 * This is used as a modifier to alerts to specify the type of message it is
 * along with potentially providing a default sound or icon set.
 *
 * @since 2017/02/28
 */
public class AlertType
{
	/**
	 * This is used to specify that previously requested event is about to
	 * occur.
	 */
	public static final AlertType ALARM =
		new AlertType();
	
	/** This specified that an action has been performed. */
	public static final AlertType CONFIRMATION =
		new AlertType();
	
	/** This specifies an error. */
	public static final AlertType ERROR =
		new AlertType();
	
	/** This specified general information. */
	public static final AlertType INFO =
		new AlertType();
	
	/**
	 * This specifies a warning which may cause the user to proceed with
	 * caution.
	 */
	public static final AlertType WARNING =
		new AlertType();
	
	/**
	 * Initializes the alert type.
	 *
	 * @since 2017/0/228
	 */
	protected AlertType()
	{
	}
	
	public boolean playSound(Display __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui;

public class AnimatedImage
	extends Image
{
	public Image getFrame(int __i)
		throws IndexOutOfBoundsException
		
	{
		throw new todo.TODO();
	}
	
	public int getFrameDelay(int __i)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	public int getLoopCount()
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Canvas.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.KeyNames;
import cc.squirreljme.runtime.lcdui.fbui.UIState;

/**
 * The canvas acts as the base class for primary display interfaces that
 * require more customized draw handling.
 *
 * It is not recommended to use a lookup table between keycodes and actions at
 * initialization time. The reason for this is that it is possible for the
 * device to enter different modes or be associated with different
 * {@link Display}s which have different action mappings.
 *
 * @since 2016/10/08
 */
public abstract class Canvas
	extends Displayable
{
	public static final int ACTIONS_ALL =
		-2;
	
	public static final int ACTIONS_NAVIGATION =
		-1;
	
	public static final int ACTIONS_NONE =
		0;
	
	/** This is a game key for the down direction. */
	public static final int DOWN =
		6;
	
	/** This is a game key for the fire button. */
	public static final int FIRE =
		8;
	
	/** This is a game key for the A button. */
	public static final int GAME_A =
		9;
	
	/** This is a game key for the B button. */
	public static final int GAME_B =
		10;
	
	/** This is a game key for the C button. */
	public static final int GAME_C =
		11;
	
	/** This is a game key for the D button. */
	public static final int GAME_D =
		12;
	
	public static final int KEY_BACKSPACE =
		8;
	
	public static final int KEY_DELETE =
		127;
	
	public static final int KEY_DOWN =
		-2;
	
	public static final int KEY_ENTER =
		10;
	
	public static final int KEY_ESCAPE =
		27;
	
	public static final int KEY_LEFT =
		-3;
	
	public static final int KEY_NUM0 =
		48;
	
	public static final int KEY_NUM1 =
		49;
	
	public static final int KEY_NUM2 =
		50;
	
	public static final int KEY_NUM3 =
		51;
	
	public static final int KEY_NUM4 =
		52;
	
	public static final int KEY_NUM5 =
		53;
	
	public static final int KEY_NUM6 =
		54;
	
	public static final int KEY_NUM7 =
		55;
	
	public static final int KEY_NUM8 =
		56;
	
	public static final int KEY_NUM9 =
		57;
	
	public static final int KEY_POUND =
		35;
	
	public static final int KEY_RIGHT =
		-4;
	
	public static final int KEY_SELECT =
		-5;
	
	public static final int KEY_SPACE =
		32;
	
	public static final int KEY_STAR =
		42;
	
	public static final int KEY_TAB =
		9;
	
	/** The up arrow key. */
	public static final int KEY_UP =
		-1;
	
	/** This is a game key for the left direction. */
	public static final int LEFT =
		2;
	
	/** This is a game key for the right direction. */
	public static final int RIGHT =
		5;
	
	/** This is a game key for the up direction. */
	public static final int UP =
		1;
	
	/** The key listener to use. */
	private KeyListener _keylistener;
	
	/** Is the rendering transparent or opaque? */
	boolean _transparent;
	
	/** Should this be ran full-screen? */
	volatile boolean _isfullscreen;
	
	/** Service repaint counter. */
	volatile int _paintservice;
	
	/** Was a repaint requested? */
	volatile boolean _paintwanted;
	
	/**
	 * Initializes the base canvas.
	 *
	 * @since 2016/10/08
	 */
	protected Canvas()
	{
	}
	
	/**
	 * This is called when this is to be painted. The clipping area will
	 * be set to the area that needs updating and as such drawing should only
	 * occur within the region. Any pixels drawn outside of the clipping area
	 * might not be updated and may have no effect when drawing.
	 *
	 * If this is transparent then the background will automatically be filled
	 * appropriately with a color or image, otherwise in opaque mode it is
	 * assumed that pixels in the clipping region will be drawn on.
	 *
	 * @param __g The graphics to draw into.
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected abstract void paint(Graphics __g);
	
	/**
	 * Returns the action which is associated with the given key.
	 *
	 * @param __kc The key code to get the action for.
	 * @return The action associated with the given key or {@code 0} if no
	 * action is associated with the key.
	 * @throws IllegalArgumentException If the specified keycode is not valid.
	 * @since 2017/02/12
	 */
	public int getGameAction(int __kc)
		throws IllegalArgumentException
	{
		return EventTranslate.keyCodeToGameAction(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, this._isfullscreen);
	}
	
	/**
	 * Returns the key code for the given game action.
	 *
	 * @param __gc The game action to convert.
	 * @return The key code
	 * @throws IllegalArgumentException If the game action is not valid.
	 * @since 2019/04/14
	 */
	public int getKeyCode(int __gc)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1a The specified game action is not valid.}
		int rv = EventTranslate.gameActionToKeyCode(__gc);
		if (rv == 0)
			throw new IllegalArgumentException("EB1a " + __gc);
		return rv;
	}
	
	/**
	 * Returns the name for a key.
	 *
	 * @param __a The name to get the key for.
	 * @return The name of the given key.
	 * @throws IllegalArgumentException If the key is not valid.
	 * @since 2017/02/12
	 */
	public String getKeyName(int __a)
		throws IllegalArgumentException
	{
		return KeyNames.getKeyName(__a);
	}
	
	public int[] getSoftkeyLabelCoordinates(int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, this._isfullscreen);
	}
	
	/**
	 * This checks whether the display has the capability to handle pointer
	 * events.
	 *
	 * @return {@code true} if pointer events are available.
	 * @since 2017/02/12
	 */
	@Deprecated
	public boolean hasPointerEvents()
	{
		Display d = this._display;
		return (d != null ? d : Display.getDisplays(0)[0]).hasPointerEvents();
	}
	
	/**
	 * This checks whether the display has the capability to handle pointer
	 * motion events.
	 *
	 * @return {@code true} if pointer motion events are available.
	 * @since 2017/02/12
	 */
	@Deprecated
	public boolean hasPointerMotionEvents()
	{
		Display d = this._display;
		return (d != null ? d : Display.getDisplays(0)[0]).
			hasPointerMotionEvents();
	}
	
	/**
	 * Always returns {@code true} because all implementations must support
	 * repeat events.
	 *
	 * @return Always {@code true}.
	 * @since 2017/02/12
	 */
	public boolean hasRepeatEvents()
	{
		return true;
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected void hideNotify()
	{
		// Implemented by sub-classes
	}
	
	/**
	 * This method always returns {@code true} because all implementations
	 * must double buffer canvases.
	 *
	 * @return {@code true}.
	 * @since 2017/05/13
	 */
	public boolean isDoubleBuffered()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isFullscreen()
	{
		return this._isfullscreen;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isTransparent()
	{
		return this._transparent;
	}
	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyPressed(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when a key has been released.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyReleased(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when a key has been repeated.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyRepeated(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when the pointer is being dragged across the canvas, a
	 * drag is when there is movement 
	 *
	 * This requires that motion events are supported which can be known by
	 * calling {@link #hasPointerMotionEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerDragged(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been pressed on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerPressed(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been released on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerReleased(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * Equivalent to {@code repaint(0, 0, getWidth(), getHeight())}.
	 *
	 * @since 2017/02/10
	 */
	public final void repaint()
	{
		// A remote repaint call is performed for the canvas so it is
		// possible that the width/height are not valid. Internally the code
		// will clip the rectangle to be in bounds.
		this.repaint(0, 0, this.getWidth(), this.getHeight());
	}
	
	/**
	 * Requests that the specified region of the canvas be repainted.
	 *
	 * The clipping region when {@link #paint(Graphics)} is called will have
	 * its clip set to the region to be redrawn.
	 *
	 * It is unspecified whether the drawing operation will happen immedietely,
	 * be enqueued, or not happen at all (for example if the canvas is
	 * currently being painted).
	 *
	 * A width or height with a negative value or zero does nothing.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2017/02/10
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		// Do nothing
		if (__w <= 0 || __h <= 0)
			return;
		
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint(__x, __y, __w, __h);
	}
	
	/**
	 * This forces any pending repaint requests to be serviced immedietely,
	 * blocking until paint has been called. If the canvas is not visible on
	 * the display or if there are no pending repaints then this call does
	 * nothing.
	 *
	 * Note that if the caller of this method and the paint method uses a lock
	 * then a deadlock may occur.
	 *
	 * @since 2019/04/14
	 */
	public final void serviceRepaints()
	{
		// If a paint was not requested then do nothing
		if (!this._paintwanted)
			return;
		
		// Just wait until the service count changes
		int nowpsv = this._paintservice;
		while (nowpsv == this._paintservice)
			break;
	}
	
	/**
	 * This specifies that the canvas should enter full screen mode which
	 * takes up the maximum amount of space that is possible on the display.
	 *
	 * Note that this might not use the entire screen.
	 *
	 * This method may permit access to the framebuffer directly on the device
	 * which may enable accelerated drawing if supported by the underlying
	 * display engine.
	 *
	 * Note that the fullscreen mode is treated
	 *
	 * @param __f If {@code true} then fullscreen mode should be used.
	 * @since 2017/02/28
	 */
	public void setFullScreenMode(boolean __f)
	{
		// Do nothing if already fullscreen
		if (this._isfullscreen == __f)
			return;
		
		// Set new mode
		this._isfullscreen = __f;
		
		// Repaint the display if we have one so that it actually is used
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	/**
	 * Sets the key listener which is used to handle key events.
	 *
	 * If this is set then {@link #keyPressed(int)}, {@link #keyReleased(int)},
	 * and {@link #keyRepeated} will still be called.
	 *
	 * @param __kl The key listener to use, {@code null} clears it.
	 * @since 2017/02/12
	 */
	public void setKeyListener(KeyListener __kl)
	{
		this._keylistener = __kl;
	}
	
	/**
	 * Sets the painting mode of the canvas.
	 *
	 * If transparent mode is enabled, then the implementation (not the end
	 * developer) will fill the background with a suitable color or image
	 * (which is unspecified).
	 *
	 * If opaque mode (which is the default) is enabled then it will be
	 * assumed that {@link #repaint()} will cover every pixel and
	 * as such it will not be required for the background to be cleared or
	 * initialized.
	 *
	 * @param __opaque If {@code true} then opaque mode is enabled.
	 * @since 2017/02/12
	 */
	public void setPaintMode(boolean __opaque)
	{
		this._transparent = !__opaque;
	}
	
	public void setRequiredActions(int __actions)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is called when the canvas has been shown.
	 *
	 * @since 2018/12/02.
	 */
	@SerializedEvent
	protected void showNotify()
	{
		// Implemented by sub-classes
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/CanvasItem.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public abstract class CanvasItem
{
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public Object getParent()
	{
		throw new todo.TODO();
	}
	
	public int getPositionX()
	{
		throw new todo.TODO();
	}
	
	public int getPositionY()
	{
		throw new todo.TODO();
	}
	
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public int getZPosition()
	{
		throw new todo.TODO();
	}
	
	public void setParent(Object __p)
	{
		throw new todo.TODO();
	}
	
	public void setPositionX(int __x)
	{
		throw new todo.TODO();
	}
	
	public void setPositionY(int __y)
	{
		throw new todo.TODO();
	}
	
	public void setSize(int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __v)
	{
		throw new todo.TODO();
	}
	
	public void setZPosition(int __z)
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Choice.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;


public interface Choice
{
	int EXCLUSIVE =
		1;
	
	int IMPLICIT =
		3;
	
	int MULTIPLE =
		2;
	
	int POPUP =
		4;
	
	int TEXT_WRAP_DEFAULT =
		0;
	
	int TEXT_WRAP_OFF =
		2;
	
	int TEXT_WRAP_ON =
		1;
	
	int append(String __a, Image __b);
	
	void delete(int __a);
	
	void deleteAll();
	
	int getFitPolicy();
	
	Font getFont(int __a);
	
	Image getImage(int __a);
	
	int getSelectedFlags(boolean[] __a);
	
	int getSelectedIndex();
	
	String getString(int __a);
	
	void insert(int __a, String __b, Image __c);
	
	boolean isEnabled(int __i);
	
	boolean isSelected(int __a);
	
	void set(int __a, String __b, Image __c);
	
	void setEnabled(int __i, boolean __e);
	
	void setFitPolicy(int __a);
	
	void setFont(int __a, Font __b);
	
	void setSelectedFlags(boolean[] __a);
	
	void setSelectedIndex(int __a, boolean __b);
	
	int size();
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/ChoiceGroup.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.ArrayList;
import java.util.List;

/**
 * A choice group represents a selectable group of elements which may be
 * added to a {@link Form}. The number of selected choices may be limited to
 * one or multiple choices may be available.
 *
 * @since 2017/08/20
 */
public class ChoiceGroup
	extends Item
	implements Choice
{
	/** The minimum permitted type. */
	static final int _MIN_TYPE =
		Choice.EXCLUSIVE;
	
	/** The maximum permitted type. */
	static final int _MAX_TYPE =
		Choice.POPUP;
	
	/** Entries which are available in the group. */
	private final List<__ChoiceEntry__> _entries =
		new ArrayList<>();
	
	/** The valid choice selection type. */
	private final int _type;
	
	/**
	 * Initializes an empty choice group.
	 *
	 * @param __l The label for this group.
	 * @param __ct The type of choice selection to use.
	 * @throws IllegalArgumentException If the choice type is not valid or
	 * if {@link Choice#IMPLICIT} was specified.
	 * @since 2017/08/20
	 */
	public ChoiceGroup(String __l, int __ct)
		throws IllegalArgumentException
	{
		this(__l, __ct, new String[0], null);
	}
	
	/**
	 * Initializes an empty choice group.
	 *
	 * @param __l The label for this group.
	 * @param __ct The type of choice selection to use.
	 * @param __se The , this cannot be {@code null}
	 * @param __ie The images for each choice, this must either be {@code null}
	 * or be the exact same length as the input {@code __se}.
	 * @throws IllegalArgumentException If the choice type is not valid; 
	 * if {@link Choice#IMPLICIT} was specified; If the image array is not
	 * null and is not the same length as the string array.
	 * @throws NullPointerException If {@code __se} is {@code null} or it
	 * contains {@code null} elements; or if the string array contains null
	 * elements.
	 * @since 2017/08/20
	 */
	public ChoiceGroup(String __l, int __ct, String[] __se, Image[] __ie)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__se == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1b The image array does not have the same
		// length as the string array.}
		int n = __se.length;
		if (__ie != null && __ie.length != n)
			throw new IllegalArgumentException("EB1b");
		
		// {@squirreljme.error EB1c Invalid choice type specified for a
		// choice group. (The choice type)}
		if (__ct < ChoiceGroup._MIN_TYPE || __ct > ChoiceGroup._MAX_TYPE || __ct == Choice.IMPLICIT)
			throw new IllegalArgumentException(String.format("EB1c %d", __ct));
		
		// Set
		this.setLabel(__l);
		this._type = __ct;
		
		// Append all elements
		for (int i = 0; i < n; i++)
		{
			// {@squirreljme.error EB1d A string element contains a null
			// entry.}
			String s = __se[i];
			if (s == null)
				throw new NullPointerException("EB1d");
			
			// Add it
			this.append(s, (__ie != null ? __ie[i] : null));
		}
	}
	
	/**
	 * This appends a single choice.
	 *
	 * @param __s The string to display.
	 * @param __i The image to display, may be {@code null}.
	 * @return The index the element was added at.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/08/20
	 */
	public int append(String __s, Image __i)
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Just insert at the end
		int rv;
		this.insert((rv = this.size()), __s, __i);
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	public void deleteAll()
	{
		throw new todo.TODO();
	}
	
	public int getFitPolicy()
	{
		throw new todo.TODO();
	}
	
	public Font getFont(int __a)
	{
		throw new todo.TODO();
	}
	
	public Image getImage(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedIndex()
	{
		throw new todo.TODO();
	}
	
	public String getString(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This inserts the specified choice at the given index.
	 *
	 * Note that the documentation erroneously specifies that an exception
	 * will be thrown if {@code __v} is in the range of {@code [0, size()-1]},
	 * this is not the case and {@code size()} is a valid index.
	 *
	 * @param __v The index to insert the choice at.
	 * @param __s The string to display.
	 * @param __i The image to display, may be {@code null}.
	 * @throws IndexOutOfBoundsException If the index exceeds the bounds.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/08/21
	 */
	public void insert(int __v, String __s, Image __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1e Cannot insert choice at the specified
		// index because it is not within bounds. (The index to add at)}
		List<__ChoiceEntry__> entries = this._entries;
		if (__v < 0 || __v > entries.size())
			throw new IndexOutOfBoundsException(String.format("EB1e %d",
				__v));
		
		// Insert
		entries.add(__v, new __ChoiceEntry__(__s, __i));
	}
	
	public boolean isEnabled(int __i)
	{
		throw new todo.TODO();
	}
	
	public boolean isSelected(int __a)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	public void setEnabled(int __i, boolean __e)
	{
		throw new todo.TODO();
	}
	
	public void setFitPolicy(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFont(int __a, Font __b)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedIndex(int __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of choices which are in this group.
	 *
	 * @return The number of choices in this group.
	 * @since 2017/08/20
	 */
	public int size()
	{
		return this._entries.size();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Command.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public class Command
	extends __Action__
{ 
	/** Returns the user to the previous screen.. */
	public static final int BACK =
		2;
	
	/** Specified a standard negative to something on the screen. */
	public static final int CANCEL =
		3;
	
	/** A command that is used to exit the application. */
	public static final int EXIT =
		7;
	
	/** A request for on-line help. */
	public static final int HELP =
		5;
	
	/** System specific type. */
	public static final int ITEM =
		8;
	
	/** Specified as a standard affirmative to something on the screen. */
	public static final int OK =
		4;
	
	/** A command which pertains to the current screen. */
	public static final int SCREEN =
		1;
	
	/** A command which will stop an in-progress operation. */
	public static final int STOP =
		6;
	
	/** The first command type. */
	private static final int _FIRST_TYPE = Command.SCREEN;
	
	/** The last command type. */
	private static final int _LAST_TYPE = Command.ITEM;
	
	/** The command type. */
	final int _type;
	
	/** The priority. */
	@ImplementationNote("In SquirrelJME if the priority is " +
		"Integer.MAX_VALUE then it will not be displayed.")
	private final int _priority;
	
	/** Is this an implementation specific command with fixed text? */
	private final boolean _implspec;
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @param __implspec If true this is an implementation specific command
	 * which the returned labels are always blank except that internally they
	 * use the passed strings.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	Command(String __sl, int __type, int __pri, boolean __implspec)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, __implspec);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, String __ll, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __i The image used on the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, String __ll, Image __i, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, __ll, __i, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __i The image used on the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @param __implspec If true this is an implementation specific command
	 * which the returned labels are always blank except that internally they
	 * use the passed strings.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2018/03/29
	 */
	Command(String __sl, String __ll, Image __i, int __type, int __pri,
		boolean __implspec)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__sl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1f And invalid command type was specified.
		// (The command type)}
		if (__type < Command._FIRST_TYPE || __type > Command._LAST_TYPE)
			throw new IllegalArgumentException(
				String.format("EB1f %d", __type));
		
		// Set
		this._implspec = __implspec;
		this._type = __type;
		this._priority = __pri;
		
		// Part of action
		this._shortlabel = __sl;
		this._longlabel = __ll;
		this._image = __i;
	}
	
	/**
	 * Returns the type of command this is.
	 *
	 * @return The command type.
	 * @since 2018/03/31
	 */
	public int getCommandType()
	{
		return this._type;
	}
	
	public boolean getEnabled()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font that is used as a hint for rendering the text in
	 * a command, it may be disregarded by the implementation.
	 *
	 * @return The font that should be used as a hint.
	 * @since 2018/03/31
	 */
	public Font getFont()
	{
		throw new todo.TODO();
		/*
		return this._font;
		*/
	}
	
	/**
	 * Returns the image the command.
	 *
	 * @return The image of the command or {@code null} if it has none.
	 * @since 2018/03/29
	 */
	public Image getImage()
	{
		// Do not provide implementation specific images
		if (this._implspec)
			return null;
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label used for this command.
	 *
	 * @return The label used for the command.
	 * @since 2018/03/29
	 */
	public String getLabel()
	{
		// Do not provide implementation specific labels
		if (this._implspec)
			return "";
		
		return this._shortlabel;
	}
	
	/**
	 * Returns the long label of the command.
	 *
	 * @return The long label of the command or {@code null} if it has none.
	 * @since 2018/03/29
	 */
	public String getLongLabel()
	{
		// Do not provide implementation specific labels
		if (this._implspec)
			return null;
		
		return this._longlabel;
	}
	
	/**
	 * Returns the priority of the command.
	 *
	 * @return The command priority.
	 * @since 2018/12/03
	 */
	public int getPriority()
	{
		return this._priority;
	}
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e The new state of the parent.
	 * @since 2018/04/01
	 */
	@Override
	public void onParentEnabled(boolean __e)
	{
		// The default implementation does nothing
	}
	
	/**
	 * Sets whether this command is enabled or disabled.
	 *
	 * @param __e If the command is enabled or not.
	 * @since 2018/04/01
	 */
	public void setEnabled(boolean __e)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font used to be used as a hint when rendering the command.
	 *
	 * @param __f The font to use as a hint when rendering the command,
	 * {@code null} will use the default.
	 * @since 2018/03/31
	 */
	public void setFont(Font __f)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		// Just cache the font but do nothing as it is not supported in
		// SquirrelJME (it would complicate command handling) although it
		// could potentially be supported in the future for stuff such as
		// word processors and such
		this._font = __f;
		*/
	}
	
	/**
	 * Sets the image to be displayed for this command. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code command.setImage(command.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * Sets the label to be displayed.
	 *
	 * @param __s The label to display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/29
	 */
	public void setLabel(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		this.__setLabels(__s, this._longlabel, this._image);
		*/
	}
	
	/**
	 * Sets the long label of the command.
	 *
	 * @param __s The long label to use, {@code null} clears it.
	 * @since 2018/03/29
	 */
	public void setLongLabel(String __s)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		this.__setLabels(this._shortlabel, __s, this._image);
		*/
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/CommandLayoutPolicy.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface CommandLayoutPolicy
{
	void onCommandLayout(Displayable __disp);
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/CommandListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface CommandListener
{
	@SerializedEvent
	void commandAction(Command __a, Displayable __b);
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/CustomItem.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class CustomItem
	extends Item
{
	protected static final int KEY_PRESS =
		4;
	
	protected static final int KEY_RELEASE =
		8;
	
	protected static final int KEY_REPEAT =
		16;
	
	protected static final int NONE =
		0;
	
	protected static final int POINTER_DRAG =
		128;
	
	protected static final int POINTER_PRESS =
		32;
	
	protected static final int POINTER_RELEASE =
		64;
	
	protected static final int TRAVERSE_HORIZONTAL =
		1;
	
	protected static final int TRAVERSE_VERTICAL =
		2;
	
	/** Is the rendering transparent or opaque? */
	boolean _transparent;
	
	protected CustomItem(String __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected abstract int getMinContentHeight();
	
	@SerializedEvent
	protected abstract int getMinContentWidth();
	
	@SerializedEvent
	protected abstract int getPrefContentHeight(int __a);
	
	@SerializedEvent
	protected abstract int getPrefContentWidth(int __a);
	
	/**
	 * This is called when this is to be painted. The clipping area will
	 * be set to the area that needs updating and as such drawing should only
	 * occur within the region. Any pixels drawn outside of the clipping area
	 * might not be updated and may have no effect when drawing.
	 *
	 * If this is transparent then the background will automatically be filled
	 * appropriately with a color or image, otherwise in opaque mode it is
	 * assumed that pixels in the clipping region will be drawn on.
	 *
	 * @param __g The graphics to draw into.
	 * @param __w The width of the item.
	 * @param __h The height of the item.
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected abstract void paint(Graphics __g, int __w, int __h);
	
	public int getGameAction(int __a)
	{
		throw new todo.TODO();
	}
	
	protected final int getInteractionModes()
	{
		throw new todo.TODO();
	}
	
	public int getKeyCode(int __action)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected void hideNotify()
	{
		// Implemented by sub-classes
	}
	
	protected final void invalidate()
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyPressed(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyReleased(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyRepeated(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerDragged(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerPressed(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerReleased(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	protected final void repaint()
	{
		throw new todo.TODO();
	}
	
	protected final void repaint(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setKeyListener(KeyListener __kl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the painting mode of the canvas.
	 *
	 * If transparent mode is enabled, then the implementation (not the end
	 * developer) will fill the background with a suitable color or image
	 * (which is unspecified).
	 *
	 * If opaque mode (which is the default) is enabled then it will be
	 * assumed that {@link CustomItem#repaint()} will cover every pixel and as
	 * such it will not be required for the background to be cleared or
	 * initialized.
	 *
	 * @param __opaque If {@code true} then opaque mode is enabled.
	 * @since 2018/03/28
	 */
	public void setPaintMode(boolean __opaque)
	{
		this._transparent = !__opaque;
	}
	
	@SerializedEvent
	protected void showNotify()
	{
		// Implemented by sub-classes
	}
	
	@SerializedEvent
	protected void sizeChanged(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected boolean traverse(int __a, int __b, int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void traverseOut()
	{
		throw new todo.TODO();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/DateField.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.Date;
import java.util.TimeZone;

public class DateField
	extends Item
{
	public static final int DATE =
		1;
	
	public static final int DATE_TIME =
		3;
	
	public static final int TIME =
		2;
	
	/** The timezone to use. */
	private final TimeZone _zone;
	
	/**
	 * Initializes the date field with the default timezone.
	 *
	 * @param __l The label to use.
	 * @param __m The mode used.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2019/05/17
	 */
	public DateField(String __l, int __m)
		throws IllegalArgumentException
	{
		this(__l, __m, null);
	}
	
	/**
	 * Initializes the date field with the default timezone.
	 *
	 * @param __l The label to use.
	 * @param __m The mode used.
	 * @param __z The time zone to use, {@code null} is the default.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2019/05/17
	 */
	public DateField(String __l, int __m, TimeZone __z)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB1g Invalid date field mode. (The mode)}
		if (__m != DateField.DATE && __m != DateField.DATE_TIME && __m != DateField.TIME)
			throw new IllegalArgumentException("EB1g " + __m);
		
		this._zone = __z;
	}
	
	public Date getDate()
	{
		throw new todo.TODO();
	}
	
	public int getInputMode()
	{
		throw new todo.TODO();
	}
	
	public void setDate(Date __a)
	{
		throw new todo.TODO();
	}
	
	public void setInputMode(int __a)
	{
		throw new todo.TODO();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Display.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.DeviceFeedbackType;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.phoneui.StandardMetrics;
import cc.squirreljme.runtime.cldc.Poking;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.midlet.MIDlet;

public class Display
{
	public static final int ALERT =
		3;

	public static final int CHOICE_GROUP_ELEMENT =
		2;

	public static final int COLOR_BACKGROUND =
		0;

	public static final int COLOR_BORDER =
		4;

	public static final int COLOR_FOREGROUND =
		1;

	public static final int COLOR_HIGHLIGHTED_BACKGROUND =
		2;

	public static final int COLOR_HIGHLIGHTED_BORDER =
		5;

	public static final int COLOR_HIGHLIGHTED_FOREGROUND =
		3;

	public static final int COLOR_IDLE_BACKGROUND =
		6;

	public static final int COLOR_IDLE_FOREGROUND =
		7;

	public static final int COLOR_IDLE_HIGHLIGHTED_BACKGROUND =
		8;

	public static final int COLOR_IDLE_HIGHLIGHTED_FOREGROUND =
		9;

	public static final int COMMAND =
		5;

	public static final int DISPLAY_HARDWARE_ABSENT =
		2;

	public static final int DISPLAY_HARDWARE_DISABLED =
		1;

	public static final int DISPLAY_HARDWARE_ENABLED =
		0;

	public static final int LIST_ELEMENT =
		1;

	public static final int MENU =
		7;

	/** This is the activity mode that enables power saving inhibition. */
	public static final int MODE_ACTIVE =
		1;
	
	/** This is the activity mode that is the default behavior. */
	public static final int MODE_NORMAL =
		0;

	public static final int NOTIFICATION =
		6;

	public static final int ORIENTATION_LANDSCAPE =
		2;

	public static final int ORIENTATION_LANDSCAPE_180 =
		8;

	public static final int ORIENTATION_PORTRAIT =
		1;

	public static final int ORIENTATION_PORTRAIT_180 =
		4;

	public static final int SOFTKEY_BOTTOM =
		800;

	public static final int SOFTKEY_INDEX_MASK =
		15;

	public static final int SOFTKEY_LEFT =
		820;

	public static final int SOFTKEY_OFFSCREEN =
		880;

	public static final int SOFTKEY_RIGHT =
		860;

	public static final int SOFTKEY_TOP =
		840;

	public static final int STATE_BACKGROUND =
		0;

	public static final int STATE_FOREGROUND =
		2;

	public static final int STATE_VISIBLE =
		1;

	public static final int SUPPORTS_ALERTS =
		32;

	public static final int SUPPORTS_COMMANDS =
		2;

	public static final int SUPPORTS_FILESELECTORS =
		512;

	public static final int SUPPORTS_FORMS =
		4;

	public static final int SUPPORTS_IDLEITEM =
		2048;

	/** This specifies that the display supports user input. */
	public static final int SUPPORTS_INPUT_EVENTS =
		1;

	public static final int SUPPORTS_LISTS =
		64;

	public static final int SUPPORTS_MENUS =
		1024;

	public static final int SUPPORTS_ORIENTATION_LANDSCAPE =
		8192;

	public static final int SUPPORTS_ORIENTATION_LANDSCAPE180 =
		32768;

	public static final int SUPPORTS_ORIENTATION_PORTRAIT =
		4096;

	public static final int SUPPORTS_ORIENTATION_PORTRAIT180 =
		16384;

	public static final int SUPPORTS_TABBEDPANES =
		256;

	public static final int SUPPORTS_TEXTBOXES =
		128;

	public static final int SUPPORTS_TICKER =
		8;

	public static final int SUPPORTS_TITLE =
		16;

	public static final int TAB =
		4;
	
	/** The number of down keys to store, for a single hand. */
	private static final int _NUM_DOWNKEYS =
		5;
	
	/** Listeners for the display. */
	private static final List<DisplayListener> _LISTENERS =
		new ArrayList<>();
	
	/** The current display which was created. */
	private static Display _DISPLAY;
	
	/** The displayable to show. */
	private volatile Displayable _current;
	
	/** The displayable to show on exit. */
	private volatile Displayable _exit;
	
	/**
	 * Initializes the display instance.
	 *
	 * @since 2018/03/16
	 */
	Display()
	{
	}
	
	public void callSerially(Runnable __a)
	{
		// Note that the Runnable.run() will be called as if it were serialized
		// like everything else with @SerializedEvent
		throw new todo.TODO();
	}
	
	/**
	 * Flashes the display LED for the given number of milliseconds.
	 *
	 * In SquirrelJME this flashes an LED and not the back light, since it is
	 * not a popular means to notify the user and additionally due to
	 * medical concerns such as epilepsy.
	 *
	 * @param __ms The number of milliseconds to flash for.
	 * @return {@code true} if the backlight is controlled by the application
	 * and the display is in the foreground, otherwise {@code false}.
	 * @since 2019/10/05
	 */
	public boolean flashBacklight(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB30 Cannot blink for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB30");
		
		// Blink!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.BLINK_LED, __ms);
		
		// Only return true if no error was generated
		return (SystemCallError.NO_ERROR ==
			Assembly.sysCallV(SystemCallIndex.ERROR_GET,
				SystemCallIndex.DEVICE_FEEDBACK));
	}
	
	/**
	 * Returns the current activity mode that the display is within, if
	 * active mode is set then the display will inhibit power saving features.
	 *
	 * @return Either {@link #MODE_ACTIVE} or {@link #MODE_NORMAL}.
	 * @since 2016/10/08
	 */
	public int getActivityMode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the height of the image that should be used for the given
	 * display element.
	 *
	 * Valid elements are:
	 * {@link #LIST_ELEMENT},
	 * {@link #CHOICE_GROUP_ELEMENT},
	 * {@link #ALERT},
	 * {@link #TAB},
	 * {@link #COMMAND},
	 * {@link #NOTIFICATION}, and
	 * {@link #MENU}.
	 *
	 * @param __a If display element.
	 * @return The height of the image for that element.
	 * @throws IllegalArgumentException On null arguments.
	 * @since 2016/10/14
	 */
	public int getBestImageHeight(int __a)
		throws IllegalArgumentException
	{
		return this.__bestImageSize(__a, true);
	}
	
	/**
	 * Returns the width of the image that should be used for the given
	 * display element.
	 *
	 * Valid elements are:
	 * {@link #LIST_ELEMENT},
	 * {@link #CHOICE_GROUP_ELEMENT},
	 * {@link #ALERT},
	 * {@link #TAB},
	 * {@link #COMMAND},
	 * {@link #NOTIFICATION}, and
	 * {@link #MENU}.
	 *
	 * @param __a If display element.
	 * @return The width of the image for that element.
	 * @throws IllegalArgumentException On null arguments.
	 * @since 2016/10/14
	 */
	public int getBestImageWidth(int __a)
		throws IllegalArgumentException
	{
		return this.__bestImageSize(__a, false);
	}
	
	public int getBorderStyle(boolean __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This returns the capabilities that the display supports. This means that
	 * displays which do not support specific widget types can be known so that
	 * potential alternative handling may be performed.
	 *
	 * The capabilities are the constants starting with {@code SUPPORTS_}
	 *
	 * @return A bit field where set bits indicate supported capabilities, if
	 * {@code 0} is returned then only a {@link Canvas} is supported.
	 * @since 2016/10/08
	 */
	public int getCapabilities()
	{
		int caps = UIState.getInstance().capabilities();
		boolean hastouch = ((caps & Framebuffer.CAPABILITY_TOUCH) != 0);
		boolean hasinput = hastouch |
			((caps & Framebuffer.CAPABILITY_KEYBOARD) != 0);
		
		// Use the capabilities of the native display, but since SquirrelJME
		// manages pretty much everything in a framebuffer every display will
		// always have certain capabilities
		return (hasinput ? Display.SUPPORTS_INPUT_EVENTS : 0) |
			(hastouch ? ExtendedCapabilities.SUPPORTS_POINTER_EVENTS : 0) | Display.SUPPORTS_COMMANDS | Display.SUPPORTS_FORMS | Display.SUPPORTS_TICKER | Display.SUPPORTS_ALERTS | Display.SUPPORTS_LISTS | Display.SUPPORTS_TEXTBOXES | Display.SUPPORTS_FILESELECTORS | Display.SUPPORTS_TABBEDPANES | Display.SUPPORTS_MENUS;
	}
	
	/**
	 * Returns the color used for the specified interface item.
	 *
	 * The value values are:
	 * {@link #COLOR_BACKGROUND},
	 * {@link #COLOR_BORDER},
	 * {@link #COLOR_FOREGROUND},
	 * {@link #COLOR_HIGHLIGHTED_BACKGROUND},
	 * {@link #COLOR_HIGHLIGHTED_BORDER},
	 * {@link #COLOR_HIGHLIGHTED_FOREGROUND},
	 * {@link #COLOR_IDLE_BACKGROUND},
	 * {@link #COLOR_IDLE_FOREGROUND},
	 * {@link #COLOR_IDLE_HIGHLIGHTED_BACKGROUND}, and
	 * {@link #COLOR_IDLE_HIGHLIGHTED_FOREGROUND}
	 *
	 * @param __c The color to get.
	 * @return The ARGB color for the specified user interface item, it will
	 * be in the form of {@code 0x00RRGGBB}.
	 * @throws IllegalArgumentException If the specified color is not valid.
	 * @since 2016/10/14
	 */
	public int getColor(int __c)
		throws IllegalArgumentException
	{
		int rv;
		switch (__c)
		{
			case Display.COLOR_BORDER:
				rv = CommonColors.BORDER;
				break;
			
			case Display.COLOR_BACKGROUND:
			case Display.COLOR_IDLE_BACKGROUND:
				rv = CommonColors.BACKGROUND;
				break;
			
			case Display.COLOR_FOREGROUND:
			case Display.COLOR_IDLE_FOREGROUND:
				rv = CommonColors.FOREGROUND;
				break;
			
			case Display.COLOR_HIGHLIGHTED_BORDER:
				rv = CommonColors.HIGHLIGHTED_BORDER;
				break;
				
			case Display.COLOR_HIGHLIGHTED_BACKGROUND:
			case Display.COLOR_IDLE_HIGHLIGHTED_BACKGROUND:
				rv = CommonColors.HIGHLIGHTED_BACKGROUND;
				break;
			
			case Display.COLOR_HIGHLIGHTED_FOREGROUND:
			case Display.COLOR_IDLE_HIGHLIGHTED_FOREGROUND:
				rv = CommonColors.HIGHLIGHTED_FOREGROUND;
				break;
		
				// {@squirreljme.error EB1h Unknown color specifier. (The
				// color specifier)}
			default:
				throw new IllegalArgumentException("EB1h " + __c);
		}
		
		// Clip the alpha away
		return (rv & 0xFFFFFF);
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	public int[] getCommandPreferredPlacements(int __ct)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current displayable.
	 *
	 * @return The current displayable or {@code null} if it is not set.
	 * @since 2016/10/08
	 */
	public Displayable getCurrent()
	{
		return this._current;
	}
	
	public int getDisplayState()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the dot pitch of the display in microns (also known as
	 * micrometers or um).
	 *
	 * If pixels are not square then the pitch should be the average of the
	 * two.
	 *
	 * @return The dot pitch in microns.
	 * @since 2016/10/14
	 */
	public int getDotPitch()
	{
		throw new todo.TODO();
	}
	
	public int[] getExactPlacementPositions(int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current harware state.
	 *
	 * @return The hardware state.
	 * @since 2018/12/10
	 */
	public int getHardwareState()
	{
		throw new todo.TODO();
		/*
		if (__EventCallback__._CALLBACK._registered)
			return DISPLAY_HARDWARE_ENABLED;
		return DISPLAY_HARDWARE_DISABLED;
		*/
	}
	
	/**
	 * Returns the maximum height of the display.
	 *
	 * @return The maximum display height.
	 * @since 2016/10/14
	 */
	public int getHeight()
	{
		return UIState.getInstance().displayHeight();
	}
	
	public IdleItem getIdleItem()
	{
		throw new todo.TODO();
	}
	
	public int[] getMenuPreferredPlacements()
	{
		throw new todo.TODO();
	}
	
	public int[] getMenuSupportedPlacements()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current orientation of the display.
	 *
	 * @return The display orientation.
	 * @since 2017/10/27
	 */
	public int getOrientation()
	{
		// Landscape just means a longer width
		boolean landscape = this.getWidth() > this.getHeight();
		
		// If it is detected that the display is upsidedown, just say that
		// it was rotated 180 degrees
		if (UIState.getInstance().displayFlipped())
			if (landscape)
				return Display.ORIENTATION_LANDSCAPE_180;
			else
				return Display.ORIENTATION_PORTRAIT_180;
		else
			if (landscape)
				return Display.ORIENTATION_LANDSCAPE;
			else
				return Display.ORIENTATION_PORTRAIT;
	}
	
	/**
	 * Returns the maximum width of the display.
	 *
	 * @return The maximum display width.
	 * @since 2016/10/14
	 */
	public int getWidth()
	{
		return UIState.getInstance().displayWidth();
	}
	
	/**
	 * Are mouse/stylus press and release events supported?
	 *
	 * @return {@code true} if they are supported.
	 * @since 2016/10/14
	 */
	public boolean hasPointerEvents()
	{
		return 0 != (this.getCapabilities() &
			ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
	}
	
	/**
	 * Are mouse/stylus move/drag events supported?
	 *
	 * @return {@code true} if they are supported.
	 * @since 2016/10/14
	 */
	public boolean hasPointerMotionEvents()
	{
		return 0 != (this.getCapabilities() &
			ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
	}
	
	/**
	 * Is this display built into the device or is it an auxiliary display?
	 *
	 * @return {@code true} if it is built-in.
	 * @since 2016/10/14
	 */
	public boolean isBuiltIn()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is color supported by this display?
	 *
	 * @return {@code true} if color is supported.
	 * @since 2016/10/14
	 */
	public boolean isColor()
	{
		return UIState.getInstance().displayIsColor();
	}
	
	/**
	 * Returns the number of alpha-transparency levels.
	 *
	 * Alpha levels range from fully transparent to fully opaue.
	 *
	 * There will always be at least two levels.
	 *
	 * @return The alpha transparency levels.
	 * @since 2016/10/14
	 */
	public int numAlphaLevels()
	{
		// Always return 2 because SquirrelJME operates on a flat framebuffer
		// where there is no such thing as transparency
		return 2;
	}
	
	/**
	 * Returns the number of colors available to the display.
	 *
	 * Monochrome (black and white) displays only have two colors.
	 *
	 * There will always be at least two colors.
	 *
	 * @return The number of available colors.
	 * @since 2016/10/14
	 */
	public int numColors()
	{
		return UIState.getInstance().displayUniqueColors();
	}
	
	public void removeCurrent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the activity mode of the display. If active mode is set then
	 * power saving features are inhibited.
	 *
	 * @param __m The activity mode, either {@link #MODE_ACTIVE} or
	 * {@link #MODE_NORMAL}.
	 * @throws IllegalArgumentException If the specified mode is not valid.
	 * @since 2016/10/08
	 */
	public void setActivityMode(int __m)
		throws IllegalArgumentException
	{
		// Active?
		if (__m == Display.MODE_ACTIVE)
			throw new todo.TODO();
	
		// Normal
		else if (__m == Display.MODE_NORMAL)
			throw new todo.TODO();
	
		// {@squirreljme.error EB1i Unknown activity mode specified.}
		else
			throw new IllegalArgumentException("EB1i");
	}
	
	public void setCommandLayoutPolicy(CommandLayoutPolicy __clp)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Shows the given alert on this display, when the alert is finished the
	 * specified displayable is shown when it exits.
	 *
	 * This follows the same semantics as {@link #setCurrent(Displayable)}.
	 *
	 * @param __show The alert to show.
	 * @param __exit The displayable to show when the alert that is
	 * set is dismissed. This cannot be an {@link Alert}.
	 * @throws DisplayCapabilityException If the display cannot show the given
	 * displayable.
	 * @throws IllegalStateException If the display hardware is missing; If
	 * the displayables are associated with another display or tab pane; or
	 * the next displayable item is an alter.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/08
	 */
	public void setCurrent(Alert __show, Displayable __exit)
		throws DisplayCapabilityException, IllegalStateException,
			NullPointerException
	{
		// {@squirreljme.error EB1j Cannot show another alert when the alert
		// to show is cleared.}
		if (__exit instanceof Alert)
			throw new IllegalStateException("EB1j");
		
		// Check
		if (__show == null || __exit == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1k The displayable to show on exit after
		// showing an alert cannot be an alert.}
		if (__exit instanceof Alert)
			throw new IllegalStateException("EB1k");
		
		// Debug
		todo.DEBUG.note("Showing alert \"%s\"", __show._message);
		
		// Perform call on this display
		throw new todo.TODO();
		/*
		try
		{
			// Set widgets
			if (true)
				throw new todo.TODO();
			/*
			LcdServiceCall.<VoidType>call(VoidType.class,
				LcdFunction.WIDGET_ALERT_SHOW, this._handle,
				__show._handle, __exit._handle);
			* /
			
			// Hold onto these so they do not get GCed
			this._heldcurrent = __show;
			this._heldexit = __exit;
		}
		
		// {@squirreljme.error EB1l Could not set the alert and its exit
		// displayable because it is already set on a display.}
		catch (LcdWidgetOwnedException e)
		{
			throw new IllegalStateException("EB1l", e);
		}*/
	}
	
	/**
	 * Sets the current displayable to be displayed.
	 *
	 * If the value to be passed is an {@link Alert} then this acts as if
	 * {@code setCurrent(__show, getCurrent())} was called.
	 *
	 * The displayable if specified will be put into the foreground state.
	 *
	 * Note that it is unspecified when the displayable is made current, it may
	 * be done when this is called or it may be queued for later.
	 *
	 * @param __show The displayable to show, if {@code null} this tells the
	 * {@link Display} to enter the background state.
	 * @throws DisplayCapabilityException If the display cannot show the given
	 * displayable.
	 * @throws IllegalStateException If the display hardware is missing; If
	 * the displayable is associated with another display or tab pane.
	 * @since 2016/10/08
	 */
	public void setCurrent(Displayable __show)
		throws DisplayCapabilityException, IllegalStateException
	{
		// Enter background state?
		if (__show == null)
		{
			todo.TODO.note("Enter background state.");
			/*head.setState(DisplayState.BACKGROUND);*/
			return;
		}
		
		// If we are trying to show the same display, do nothing
		Displayable current = this._current;
		if (current == __show)
		{
			// If we just set current with no actual change, just make sure
			// our callback is the one which is registered so that way we
			// take control of the screen
			if (__show != null)
				this.__doShowCurrent(__show);
			
			return;
		}
		
		// If showing an alert, it gets displayed instead
		if (__show instanceof Alert)
		{
			this.setCurrent((Alert)__show, this.getCurrent());
			return;
		}
		
		// {@squirreljme.error EB1m The displayable to be displayed is already
		// being displayed.}
		if (__show._display != null)
			throw new IllegalStateException("EB1m");
		
		// Clear current's parent
		if (current != null)
		{
			// Stop showing
			current._isshown = false;
			current.hideNotify();
			
			// Not used anymore
			current._display = null;
		}
		
		// Set new parent
		__show._display = this;
		this._current = __show;
		
		// Do common showing stuff
		this.__doShowCurrent(__show);
	}
	
	public void setCurrentItem(Item __a)
	{
		throw new todo.TODO();
	}
	
	public void setIdleItem(IdleItem __i)
	{
		throw new todo.TODO();
	}
	
	public void setPreferredOrientation(int __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Attempts to vibrate the device for the given number of milliseconds.
	 *
	 * The values here only set the duration to vibrate for from the current
	 * point in time and will not increase the length of vibration.
	 *
	 * The return value will be {@code false} if the display is in the
	 * background, the device cannot vibrate, or the vibrator cannot be
	 * controlled.
	 *
	 * Note that excessive vibration may cause the battery life for a device to
	 * be lowered, thus it should be used sparingly.
	 *
	 * @param __d The number of milliseconds to vibrate for, if zero the
	 * vibrator will be switched off.
	 * @return {@code true} if the vibrator is controllable by this application
	 * and the display is active.
	 * @throws IllegalArgumentException If the duration is negative.
	 * @since 2017/02/26
	 */
	public boolean vibrate(int __d)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1n Cannot vibrate for a negative duration.}
		if (__d < 0)
			throw new IllegalArgumentException("EB1n");
		
		// Clear vibration
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, __d);
		
		// Only return true if no error was generated
		return (SystemCallError.NO_ERROR ==
			Assembly.sysCallV(SystemCallIndex.ERROR_GET,
				SystemCallIndex.DEVICE_FEEDBACK));
	}
	
	/**
	 * This wraps getting the best image size.
	 *
	 * @param __e The element to get it for.
	 * @param __h Return the height?
	 * @return The best image size.
	 * @throws IllegalArgumentException If the element type is not valid.
	 * @since 2016/10/14
	 */
	private int __bestImageSize(int __e, boolean __h)
		throws IllegalArgumentException
	{
		// Depends
		switch (__e)
		{
			case Display.LIST_ELEMENT:
				return StandardMetrics.LIST_ITEM_HEIGHT;
				
			case Display.CHOICE_GROUP_ELEMENT:
				throw new todo.TODO();
				
			case Display.ALERT:
				throw new todo.TODO();
				
			case Display.TAB:
				throw new todo.TODO();
				
			case Display.COMMAND:
				return StandardMetrics.COMMAND_BAR_HEIGHT;
				
			case Display.NOTIFICATION:
				throw new todo.TODO();
				
			case Display.MENU:
				return StandardMetrics.COMMAND_BAR_HEIGHT;
				
				// {@squirreljme.error EB1o Cannot get the best image size of
				// the specified element. (The element specifier)}
			default:
				throw new IllegalArgumentException(String.format("EB1o %d",
					__e));
		}
	}
	
	/**
	 * Do current show logic.
	 *
	 * @param __show The displayable to show.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	final void __doShowCurrent(Displayable __show)
		throws NullPointerException
	{	
		UIState uis = UIState.getInstance();
		
		// Always set as shown, easier to work with
		__show._isshown = true;
		
		// Set title of our display to the title of the Displayable
		uis.setTitle(__show._dtitle);
		
		// Set drawn displayable
		uis.setDisplayable(__show);
		
		// Callback when it is made visible
		__show.showNotify();
	}
	
	/**
	 * Adds the specified listener for changes to displays.
	 *
	 * The order in which listeners are executed in is
	 * implementation specified.
	 *
	 * @param __dl The listener to add.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static void addDisplayListener(DisplayListener __dl)
		throws NullPointerException
	{
		if (__dl == null)
			throw new NullPointerException("NARG");
		
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			// Do nothing if it is already in there
			for (int i = 0, n = listeners.size(); i < n; i++)
				if (listeners.get(i) == __dl)
					return;
			
			// Add it, if it is not there
			listeners.add(__dl);
		}
	}
	
	/**
	 * Obtains the display that is associated with the given MIDlet.
	 *
	 * @param __m The display to get the midlet for.
	 * @return The display for the given midlet.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/08
	 */
	public static Display getDisplay(MIDlet __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// First display already made?
		Display d = Display._DISPLAY;
		if (d != null)
			return d;
		
		// Use the first display that is available.
		// In the runtime, each program only ever gets a single MIDlet and
		// creating new MIDlets is illegal. Thus since getDisplays() has zero
		// be the return value for this method, that is used here.
		Display[] disp = Display.getDisplays(0);
		if (disp.length > 0)
			return disp[0];
		
		// {@squirreljme.error EB1p Could not get the display for the specified
		// MIDlet because no displays are available.}
		throw new IllegalStateException("EB1p");
	}
	
	/**
	 * Obtains the displays which have the given capability from all internal
	 * display providers.
	 *
	 * @param __caps The capabities to use, this is a bitfield and the values
	 * include all of the {@code SUPPORT_} prefixed constans. If {@code 0} is
	 * specified then capabilities are not checked.
	 * @return An array containing the displays with these capabilities.
	 * @since 2016/10/08
	 */
	public static Display[] getDisplays(int __caps)
	{
		// Poke the VM to initialize things potentially
		Poking.poke();
		
		// Create initial display?
		Display d = Display._DISPLAY;
		if (d == null)
			synchronized (Display.class)
			{
				d = Display._DISPLAY;
				if (d == null)
				{
					Display._DISPLAY = (d = new Display());
					
					// Just signify that the display was added here
					for (DisplayListener dl : Display.__listeners())
						dl.displayAdded(d);
				}
			}
		
		// Either the capabilities match or we do not care what the display
		// supports
		if (__caps == 0 || ((d.getCapabilities() & __caps) == __caps))
			return new Display[]{d};
		
		// {@squirreljme.error EB1q No displays are available.}
		throw new IllegalStateException("EB1q");
	}
	
	/**
	 * Removes the specified display listener so that it is no longer called
	 * when events occur.
	 *
	 * @param __dl The listener to remove.
	 * @throws IllegalStateException If the listener is not in the display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static void removeDisplayListener(DisplayListener __dl)
		throws IllegalStateException, NullPointerException
	{
		if (__dl == null)
			throw new NullPointerException("NARG");	
		
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			boolean didremove = false;
			for (int i = 0, n = listeners.size(); i < n; i++)
				if (listeners.get(i) == __dl)
				{
					listeners.remove(i);
					didremove = true;
				}
			
			// {@squirreljme.error EB1r The listener was never added to the
			// listener set.}
			if (!didremove)
				throw new IllegalStateException("EB1r");
		}
	}
	
	/**
	 * Returns an array of all the attached listeners.
	 *
	 * @return An array of listeners.
	 * @since 2018/03/24
	 */
	static DisplayListener[] __listeners()
	{
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			return listeners.<DisplayListener>toArray(new DisplayListener[
				listeners.size()]);
		}
	}
}

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

package javax.microedition.lcdui;

/**
 * This is thrown when an attempt is made to do something on a display which
 * does not support a given capability.
 *
 * @since 2018/11/17
 */
public class DisplayCapabilityException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/17
	 */
	public DisplayCapabilityException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/17
	 */
	public DisplayCapabilityException(String __m)
	{
		super(__m);
	}
}

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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface DisplayListener
{
	@SerializedEvent
	void displayAdded(Display __d);
	
	@SerializedEvent
	void displayStateChanged(Display __d, int __ns);
	
	@SerializedEvent
	void hardwareStateChanged(Display __d, int __ns);
	
	@SerializedEvent
	void orientationChanged(Display __d, int __no);
	
	@SerializedEvent
	void sizeChanged(Display __d, int __w, int __h);
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Displayable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.phoneui.ExposedDisplayable;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.midlet.MIDlet;

/**
 * A displayable is a primary container such as a form or a canvas that can be
 * set on a display. A display may only have a single displayable associated
 * with it and a displayable may only be associated with a single display.
 *
 * @since 2016/10/08
 */
public abstract class Displayable
	extends ExposedDisplayable
{
	/** Commands/Menus which have been added to the displayable. */
	final __VolatileList__<__Action__> _actions =
		new __VolatileList__<>();
	
	/** The display this is attached to, if any. */
	volatile Display _display;
	
	/** The command listener to call into when commands are generated. */
	volatile CommandListener _cmdlistener;
	
	/** The title of the displayable. */
	volatile String _title;
	
	/** Display title to use. */
	volatile String _dtitle;
	
	/** The ticker of the displayable. */
	volatile Ticker _ticker;
	
	/** Is this widget shown? */
	volatile boolean _isshown;
	
	/**
	 * Initializes the base displayable object.
	 *
	 * @since 2016/10/08
	 */
	Displayable()
	{
		// Use a default title for now
		this._dtitle = Displayable.__defaultTitle();
	}
	
	/**
	 * Returns the height of this displayable's content area in pixels (the
	 * area the developer can use).
	 *
	 * @return The current height of this displayable in pixels, if it is not
	 * visible then the default height is returned.
	 * @since 2017/02/08
	 */
	public abstract int getHeight();
	
	/**
	 * Returns the width of this displayable's content area in pixels (the
	 * area the developer can use).
	 *
	 * @return The current width of this displayable in pixels, if it is not
	 * visible then the default width is returned.
	 * @since 2017/02/08
	 */
	public abstract int getWidth();
	
	/**
	 * Adds the specified command to this displayable, if it was already added
	 * then there is no effect (object refefences are checked).
	 *
	 * @param __c The command to add.
	 * @throws DisplayCapabilityException If this is being displayed and
	 * the display does not support commands.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/17
	 */
	public void addCommand(Command __c)
		throws DisplayCapabilityException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1s The display does not support commands.}
		Display cd = this.getCurrentDisplay();
		if (cd != null)
			if ((cd.getCapabilities() & Display.SUPPORTS_COMMANDS) == 0)
				throw new DisplayCapabilityException("EB1s");
		
		// Add the command
		this._actions.addUniqueObjRef(__c);
		
		// Repaint display?
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public Command getCommand(int __p)
	{
		throw new todo.TODO();
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	protected CommandListener getCommandListener()
	{
		return this._cmdlistener;
	}
	
	/**
	 * Gets the commands which are available to use.
	 *
	 * @return The available commands.
	 * @since 2019/05/17
	 */
	public Command[] getCommands()
	{
		List<Command> rv = new ArrayList<>();
		for (__Action__ a : this._actions)
			if (a instanceof Command)
				rv.add((Command)a);
		return rv.<Command>toArray(new Command[rv.size()]);
	}
	
	/**
	 * Returns the display that is associated with this displayable.
	 *
	 * @return The owning display or {@code null} if not found.
	 * @since 2016/10/08
	 */
	public Display getCurrentDisplay()
	{
		return this._display;
	}
	
	public Menu getMenu(int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Gets the ticker which is being shown on this displayable.
	 *
	 * @return The ticker being shown or {@code null} if there is none.
	 * @since 2018/03/26
	 */
	public Ticker getTicker()
	{
		return this._ticker;
	}
	
	/**
	 * Returns the title of this displayable.
	 *
	 * @return The title of this displayable.
	 * @since 2016/10/08
	 */
	public String getTitle()
	{
		return this._title;
	}
	
	public void invalidateCommandLayout()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2019/05/18
	 */
	@SerializedEvent
	void hideNotify()
	{
	}
	
	/**
	 * Returns if this displayable is currently being shown.
	 *
	 * @return If the displayable is being shown.
	 * @since 2018/12/02
	 */
	public boolean isShown()
	{
		// Must be shown and have a parent, because anything without a
		// parent is invisible
		return this._isshown && this._display != null;
	}
	
	/**
	 * Removes the specified command. If the command is {@code null} or it
	 * has never been added, this does nothing. If a command is removed then
	 * the display will be updated.
	 *
	 * @param __c The command to remove.
	 * @since 2019/04/15
	 */
	public void removeCommand(Command __c)
	{
		if (__c == null)
			return;
		
		// Remove the command
		this._actions.remove(__c);
		
		// Repaint display?
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void removeCommandOrMenu(int __p)
	{
		throw new todo.TODO();
	}
	
	public void setCommand(Command __c, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setCommandLayoutPolicy(CommandLayoutPolicy __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the command listener for this given displayable.
	 *
	 * @param __l The listener to use for callbacks, if {@code null} this
	 * the listener is cleared.
	 * @since 2017/08/19
	 */
	public void setCommandListener(CommandListener __l)
	{
		this._cmdlistener = __l;
	}
	
	public void setMenu(Menu __m, int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets or clears the ticker to be shown on this displayable.
	 *
	 * @param __t The ticker to be shown on the displayable or {@code null}
	 * to clear it.
	 * @since 2018/03/26
	 */
	public void setTicker(Ticker __t)
	{
		// Removing old ticker?
		Ticker old = this._ticker;
		if (__t == null)
		{
			// Nothing to do?
			if (old == null)
				return;
			
			// Clear
			this._ticker = null;
			
			// Remove from display list
			old._displayables.remove(this);
		}
		
		// Setting the same ticker?
		else if (old == __t)
			return;
		
		// Add new ticker, note they can be associated with many displays
		else
		{
			// Add to displayable list
			__t._displayables.addUniqueObjRef(this);
			
			// Set
			this._ticker = __t;
			
			// Update display
			Display d = this._display;
			if (d != null)
				UIState.getInstance().repaint();
		}
	}
	
	/**
	 * Sets the title of this displayable.
	 *
	 * @param __t The title to use, {@code null} clears it.
	 * @since 2016/10/08
	 */
	public void setTitle(String __t)
	{
		// Cache it for later return
		this._title = __t;
		
		// If no title is being set, fallback to a default one (derived from
		// the suite)
		if (__t == null)
			__t = Displayable.__defaultTitle();
		
		// Store this
		this._dtitle = __t;
		
		// Set the title of the display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().setTitle(__t);
	}
	
	/**
	 * This is called when the canvas has been shown.
	 *
	 * @since 2018/05/18
	 */
	@SerializedEvent
	void showNotify()
	{
	}
	
	/**
	 * This is called when the size of the displayable has changed.
	 *
	 * @param __w The new width of the displayable.
	 * @param __h The new heigh of the displayable.
	 * @since 2016/10/10
	 */
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
		// Implemented by sub-classes
	}
	
	/**
	 * Returns a default title to use for the application.
	 *
	 * @return Application default title.
	 * @since 2019/05/16
	 */
	private static final String __defaultTitle()
	{
		// Try getting a sensible name from a system property
		MIDlet amid = ActiveMidlet.optional();
		if (amid != null)
		{
			// MIDlet Name
			String midname = amid.getAppProperty("midlet-name");
			if (midname != null)
				return midname;
			
			// Otherwise this might not be a MIDlet, so just use the main
			// class instead
			String midclass = amid.getAppProperty("main-class");
			if (midclass != null)
				return midclass;
		}
		
		// Fallback to just using SquirrelJME
		return "SquirrelJME";
	}
	
	/**
	 * Returns the displayable height.
	 *
	 * @param __d The displayable.
	 * @param __full Return the full screen?
	 * @return The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	static final int __getHeight(Displayable __d, boolean __full)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Use dimension from default display
		Display display = __d._display;
		if (display == null)
			return Display.getDisplays(0)[0].getHeight();
		
		// Use drawer width
		return UIState.getInstance().drawerState().contentHeight();
	}
	
	/**
	 * Returns the displayable width.
	 *
	 * @param __d The displayable.
	 * @param __full Return the full screen?
	 * @return The width.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	static final int __getWidth(Displayable __d, boolean __full)
	{
		if (__d == null)
			throw new NullPointerException("NARG");
			
		// Use dimension from default display
		Display display = __d._display;
		if (display == null)
			return Display.getDisplays(0)[0].getWidth();
		
		// Use drawer width
		return UIState.getInstance().drawerState().contentWidth();
	}
}


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

package javax.microedition.lcdui;

import java.io.IOException;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.StreamConnection;

public class FileSelector
	extends Screen
{
	/**
	 * This is used when the user has dismissed the file selector without
	 * having any file selected.
	 */
	public static final Command CANCEL_COMMAND =
		new Command("Cancel", Command.CANCEL, 1, true);
	
	/** This is used when the user has selected a file. */
	public static final Command OK_COMMAND =
		new Command("Select", Command.OK, 0, true);
	
	public static final int DIRECTORY_CREATE =
		3;
	
	public static final int DIRECTORY_SELECT =
		2;
	
	public static final int LOAD =
		0;
	
	public static final int SAVE =
		1;
	
	public FileSelector(String __title, int __mode)
	{
		throw new todo.TODO();
	}
	
	public String[] getFilterExtensions()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public String getURL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	public StreamConnection open(int __mode, boolean __to)
		throws ConnectionNotFoundException, IOException
	{
		throw new todo.TODO();
	}
	
	public void setFilterExtensions(String[] __ext)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __m)
	{
		throw new todo.TODO();
	}
	
	public void setURL(String __u)
		throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Font.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.font.FontSizeConversion;
import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * This class represents a font which is a representation of the glyphs which
 * are used to display text and pictographs.
 *
 * @since 2017/05/25
 */
public final class Font
{
	/** The monospace font. */
	public static final int FACE_MONOSPACE =
		32;
	
	/** Proportional fonts. */
	public static final int FACE_PROPORTIONAL =
		64;
	
	/** The system font. */
	public static final int FACE_SYSTEM =
		0;
	
	/** The font used for input text. */
	public static final int FONT_INPUT_TEXT =
		1;
	
	/** The text used to draw item and screen content, such as buttons. */
	public static final int FONT_STATIC_TEXT =
		0;
	
	/** The font used for unfocused text on the idle screen. */
	public static final int FONT_IDLE_TEXT =
		2;
	
	/** The font used for highlighted and focused text on the idle screen. */ 
	public static final int FONT_IDLE_HIGHLIGHTED_TEXT =
		3;
	
	/** Large font size. */
	public static final int SIZE_LARGE =
		16;
	
	/** Medium font size, this is the default. */
	public static final int SIZE_MEDIUM =
		0;
	
	/** Small font size. */
	public static final int SIZE_SMALL =
		8;
	
	/** Bold text. */
	public static final int STYLE_BOLD =
		1;
	
	/** Italic (slanted) text. */
	public static final int STYLE_ITALIC =
		2;
	
	/** Plain style text. */
	public static final int STYLE_PLAIN =
		0;
	
	/** Underlined text. */
	public static final int STYLE_UNDERLINED =
		4;
	
	/** The default font size. */
	private static final int _DEFAULT_FONT_SIZE =
		12;
	
	/** Built-in available fonts. */
	private static Font[] _BUILTIN_FONTS;
	
	/** The default font. */
	private static Font _DEFAULT_FONT;
	
	/** SQF font data. */
	private final SQFFont _sqf;
	
	/** The name of this font. */
	private final String _name;
	
	/** The style of this font. */
	private final int _style;
	
	/** The pixel size of the font. */
	private final int _pixelsize;
	
	/** The face of the font. */
	private final int _face;
	
	/** The height of the font, is pre-calculated. */
	private int _height =
		-1;
	
	/**
	 * Initializes the font.
	 *
	 * @param __n The name of this font.
	 * @param __st The style of this font.
	 * @param __px The pixel size of this font.
	 * @since 2017/10/20
	 */
	private Font(String __n, int __st, int __px)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this._name = __n;
		this._style = __st;
		this._pixelsize = __px;
		
		// Load SQF
		SQFFont sqf;
		this._sqf = (sqf = SQFFont.cacheFont(__n, __px));
		
		// Determine if the font is monospaced or proportional
		int totalwidth = 0;
		for (char c = 0; c < 128; c++)
			totalwidth += sqf.charWidth(c);
		this._face = ((totalwidth / 128) == sqf.charWidth('\0') ?
			Font.FACE_MONOSPACE : Font.FACE_PROPORTIONAL);
	}
	
	/**
	 * Returns the width of the specified character.
	 *
	 * @param __c The character to get the width of.
	 * @return The width of the given character.
	 * @since 2017/10/21
	 */
	public int charWidth(char __c)
	{
		return this._sqf.charWidth(SQFFont.mapChar(__c));
	}
	
	/**
	 * Returns the width of the specified charaters, as if it were drawn
	 * on the screen.
	 *
	 * @param __c The characters to check.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The width of the string.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public int charsWidth(char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		SQFFont sqf = this._sqf;
		
		// Calculate width
		int x = 0,
			max = 0;
		for (int i = 0; i < __l; i++)
		{
			char c = __c[__o++];
			
			// Ignore carriage returns
			if (c == '\r')
				continue;
			
			// Next line?
			else if (c == '\n')
			{
				if (x > max)
					max = x;
				x = 0;
			}
			
			// Add character
			else
				x += sqf.charWidth(SQFFont.mapChar(c));
		}
		
		// Return the higher of the two
		return (x > max ? x : max);
	}
	
	/**
	 * Derives a font using the given pixel size.
	 *
	 * @param __pxs The pixel size of the font.
	 * @return The derived font.
	 * @throws IllegalArgumentException If this font is a bitmap font and
	 * no font is available using that size.
	 * @since 2018/11/24
	 */
	public Font deriveFont(int __pxs)
		throws IllegalArgumentException
	{
		return this.deriveFont(this.getStyle(), __pxs);
	}
	
	/**
	 * Derives a font using the given style and pixel size.
	 *
	 * @param __style The style of the font.
	 * @param __pxs The pixel size of the font.
	 * @return The derived font.
	 * @throws IllegalArgumentException If this font is a bitmap font and
	 * no font is available using that size, or the style is not valid.
	 * @since 2018/11/24
	 */
	public Font deriveFont(int __style, int __pxs)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1t Invalid font style specified. (The style)}
		if ((__style & ~(Font.STYLE_PLAIN | Font.STYLE_UNDERLINED | Font.STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1t %d",
				__style));
		
		// Use default font size?
		if (__pxs == 0)
			__pxs = FontSizeConversion.logicalSizeToPixelSize(Font.SIZE_MEDIUM);
		
		// {@squirreljme.error EB1u The pixel size of a font cannot be
		// negative.}
		else if (__pxs < 0)
			throw new IllegalArgumentException("EB1u");
		
		// Same exact font?
		if (this._style == __style && this._pixelsize == __pxs)
			return this;
		
		// Create font handle
		return new Font(this._name, __style, __pxs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Same object?
		if (__o == this)
			return true;
		
		// Not a font?
		if (!(__o instanceof Font))
			return false;
		
		Font o = (Font)__o;
		return this._pixelsize == o._pixelsize &&
			this._style == o._style &&
			this._name.equals(o._name);
	}
	
	/**
	 * This returns the ascent of the font from the top of the line to the
	 * average point where the tops of characters are.
	 *
	 * @return The ascent of the font.
	 * @since 2017/10/24
	 */
	public int getAscent()
	{
		return this._sqf.ascent;
	}
	
	/**
	 * Returns the baseline position of the font which is the maximum baseline.
	 *
	 * @return The baseline of the font.
	 * @since 2018/11/29
	 */
	public int getBaselinePosition()
	{
		return this._sqf.maxascent;
	}
	
	/**
	 * This returns the descent of the font from the baseline of the font to
	 * the bottom of most alphanumeric characters.
	 *
	 * @return The descent of the font.
	 * @since 2017/10/24
	 */
	public int getDescent()
	{
		return this._sqf.descent;
	}
	
	/**
	 * Returns the face of the font.
	 *
	 * @return The font face.
	 * @since 2018/12/13
	 */
	public int getFace()
	{
		return this._face;
	}
	
	public String getFamily()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the name of this font.
	 *
	 * @return The font name.
	 * @since 2018/12/01
	 */
	public String getFontName()
	{
		return this._name;
	}
	
	/**
	 * Returns the standard height of a line for this font. This is equal
	 * to the sum of the leading, ascent, and the descent.
	 *
	 * @return The standard font height.
	 * @since 2017/10/20
	 */
	public int getHeight()
	{
		int height = this._height;
		if (height == -1)
			this._height = (height = this.getLeading() + this.getAscent() +
				this.getDescent());
		return height;
	}
	
	/**
	 * Returns the standard leading of the font in pixels. The leading is the
	 * standard number of pixels which are between each line. The space is
	 * reserved between the descent of the first line and the ascent of the
	 * next line.
	 *
	 * @return The standard leading.
	 * @since 2017/10/24
	 */
	public int getLeading()
	{
		return this._sqf.leading;
	}
	
	public int getMaxAscent()
	{
		throw new todo.TODO();
	}
	
	public int getMaxDescent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the size of this font in pixels.
	 *
	 * @return The font size in pixels.
	 * @since 2018/11/24
	 */
	public int getPixelSize()
	{
		return this._pixelsize;
	}
	
	/**
	 * Returns the logical size of the font.
	 *
	 * @return The logical font size.
	 * @since 2018/11/24
	 */
	public int getSize()
	{
		return FontSizeConversion.pixelSizeToLogicalSize(this._pixelsize);
	}
	
	/**
	 * Gets the style of the font.
	 *
	 * @return The style used.
	 * @since 2018/11/24
	 */
	public int getStyle()
	{
		return this._style;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/20
	 */
	@Override
	public int hashCode()
	{
		return this._name.hashCode() ^
			this._style ^
			this._pixelsize;
	}
	
	public boolean isBold()
	{
		throw new todo.TODO();
	}
	
	public boolean isItalic()
	{
		throw new todo.TODO();
	}
	
	public boolean isPlain()
	{
		throw new todo.TODO();
	}
	
	public boolean isUnderlined()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the width of the specified string in pixels.
	 *
	 * @param __s The string to get the width.
	 * @return The width of the string in pixels.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/21
	 */
	public int stringWidth(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		return this.substringWidth(__s, 0, __s.length());
	}
	
	/**
	 * Returns the width of the specified sub-string in pixels.
	 *
	 * @param __s The string to get the width.
	 * @param __o The offset into the string.
	 * @param __l The number of characters to count.
	 * @return The width of the string in pixels.
	 * @throws NullPointerException On null arguments.
	 * @throws StringIndexOutOfBoundsException If the string index is not
	 * within bounds.
	 * @since 2017/10/21
	 */
	public int substringWidth(String __s, int __o, int __l)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		try
		{
			SQFFont sqf = this._sqf;
			
			// Need to know the max width due to newlines
			int maxwidth = 0,
				curwidth = 0;
			for (int e = __o + __l; __o < e; __o++)
			{
				char c = __s.charAt(__o);
				if (c == '\r' || c == '\n')
				{
					// Only use longer lines
					if (curwidth > maxwidth)
						maxwidth = curwidth;
					
					// Reset because at start of line now
					curwidth = 0;
					continue;
				}
				
				// Add the character's width
				curwidth += sqf.charWidth(SQFFont.mapChar(c));
			}
			
			// Use the greater width
			if (curwidth > maxwidth)
				return curwidth;
			return maxwidth;
		}
		
		// For compatibility just wrap out of bounds, since it is
		// confusidly used
		catch (IndexOutOfBoundsException e)
		{
			StringIndexOutOfBoundsException t =
				new StringIndexOutOfBoundsException(e.getMessage());
			t.initCause(e);
			throw t;
		}
	}
	
	public static Font createFont(InputStream __data)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns all of the fonts which are available.
	 *
	 * @return All of the available fonts.
	 * @since 2018/11/24
	 */
	public static Font[] getAvailableFonts()
	{
		// Already read these fonts?
		Font[] rv = Font._BUILTIN_FONTS;
		if (rv != null)
			return rv.clone();
		
		// There are currently just three built-in fonts
		Font._BUILTIN_FONTS = (rv = new Font[]
			{
				new Font("sansserif", 0, Font._DEFAULT_FONT_SIZE),
				new Font("serif", 0, Font._DEFAULT_FONT_SIZE),
				new Font("monospace", 0, Font._DEFAULT_FONT_SIZE),
				new Font("symbol", 0, Font._DEFAULT_FONT_SIZE),
			});
		return rv.clone();
	}
	
	/**
	 * Returns all of the fonts which are available on the system using the
	 * standard font size.
	 *
	 * @param __style The style of the font, may be a combination of styles.
	 * @return An array of matching font and styles.
	 * @throws IllegalArgumentException If the parameters are not correct.
	 * @since 2017/05/25
	 */
	public static Font[] getAvailableFonts(int __style)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1v Invalid font style specified. (The style)}
		if ((__style & ~(Font.STYLE_PLAIN | Font.STYLE_UNDERLINED | Font.STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1v %d",
				__style));
		
		List<Font> rv = new ArrayList<>();
		for (Font f : Font.getAvailableFonts())
			try
			{
				rv.add(f.deriveFont(__style, f.getPixelSize()));
			}
			catch (IllegalArgumentException e)
			{
			}
		
		return rv.<Font>toArray(new Font[rv.size()]);
	}
	
	/**
	 * Returns all of the fonts which are available in the given format.
	 *
	 * @param __face The face type of the font.
	 * @param __style The style of the font.
	 * @param __pxs The pixel size of the font.
	 * @return The available fonts.
	 * @throws IllegalArgumentException If the parameters are not correct.
	 * @since 2018/11/24
	 */
	public static Font[] getAvailableFonts(int __face, int __style, int __pxs)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1w Invalid font style specified. (The style)}
		if ((__style & ~(Font.STYLE_PLAIN | Font.STYLE_UNDERLINED | Font.STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1w %d",
				__style));
		
		// Need to filter by face, then derive
		List<Font> rv = new ArrayList<>();
		for (Font f : Font.getAvailableFonts())
		{
			// Has the wrong face, ignore
			if (f.getFace() != __face)
				continue;
			
			// Derive it
			try
			{
				rv.add(f.deriveFont(__style, __pxs));
			}
			catch (IllegalArgumentException e)
			{
			}
		}
		
		return rv.<Font>toArray(new Font[rv.size()]);
	}
	
	/**
	 * Returns the default system font.
	 *
	 * @return The default system font.
	 * @since 2017/05/24
	 */
	public static Font getDefaultFont()
	{
		// 
		Font rv = Font._DEFAULT_FONT;
		if (rv != null)
			return rv;
		
		// Use the first found font as the default
		Font._DEFAULT_FONT = (rv = Font.getAvailableFonts()[0]);
		return rv;
	}
	
	/**
	 * Returns the font by the given specifier.
	 *
	 * @param __spec The specifier of the font to get.
	 * @return The font for the given specifier.
	 * @throws IllegalArgumentException If the specifier is not valid.
	 * @since 2018/11/24
	 */
	public static Font getFont(int __spec)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1x Invalid font specifiers. (The specifiers)}
		if (__spec != Font.FONT_INPUT_TEXT && __spec != Font.FONT_STATIC_TEXT &&
			__spec != Font.FONT_IDLE_TEXT && __spec != Font.FONT_IDLE_HIGHLIGHTED_TEXT)
			throw new IllegalArgumentException("EB1x " + __spec);
		
		// This is always the default font
		return Font.getDefaultFont();
	}
	
	/**
	 * Locates a font which matches the specified parameters the closest, a
	 * font will always be returned if the parameters do not match.
	 *
	 * @param __face The font face, this is a single value.
	 * @param __style The style of the font, this may be a combination of
	 * values.
	 * @param __size The size of the font, this is a single value.
	 * @return The nearest font which matches the specified parameters.
	 * @throws IllegalArgumentException If the input parameters are not valid.
	 * @since 2017/05/25
	 */
	public static Font getFont(int __face, int __style, int __size)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1y Invalid font face specified. (The face)}
		if ((__face & ~(Font.FACE_SYSTEM | Font.FACE_MONOSPACE | Font.FACE_PROPORTIONAL)) != 0
			|| Integer.bitCount(__face) > 1)
			throw new IllegalArgumentException(String.format("EB1y %d",
				__face));
		
		// {@squirreljme.error EB1z Invalid font size specified. (The size)}
		if ((__size & ~(Font.SIZE_SMALL | Font.SIZE_MEDIUM | Font.SIZE_LARGE)) != 0
			|| Integer.bitCount(__size) > 1)
			throw new IllegalArgumentException(String.format("EB1z %d",
				__size));
		
		// Get fonts that might exist
		Font[] scan = Font.getAvailableFonts(__face, __style,
			FontSizeConversion.logicalSizeToPixelSize(__size));
		
		// If no fonts were found, use a default font with a derived pixel
		// size as such
		if (scan.length == 0)
		{
			// Try to derive this font to the style and size, but if that
			// fails then just do the style
			Font d = Font.getDefaultFont();
			try
			{
				return d.deriveFont(__style,
					FontSizeConversion.logicalSizeToPixelSize(__size));
			}
			catch (IllegalArgumentException e)
			{
				try
				{
					return d.deriveFont(__style, d.getPixelSize());
				}
				catch (IllegalArgumentException f)
				{
					return d;
				}
			}
		}
		
		// Use the first font, since it should be correct hopefully
		return scan[0];
	}
	
	/**
	 * Returns a font which matches the given name.
	 *
	 * @param __name The name of the font to find.
	 * @param __style The style to use.
	 * @param __pxs The pixel size of the font.
	 * @return The font.
	 * @throws IllegalArgumentException If no font was found or the style
	 * and/or pixel size were not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static Font getFont(String __name, int __style, int __pxs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Find the font then derive it
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.deriveFont(__style, __pxs);
		
		// {@squirreljme.error EB20 Could not locate a font by the given
		// name. (The font name)}
		throw new IllegalArgumentException("EB20 " + __name);
	}
	
	/**
	 * Returns the pixel size of the given font.
	 *
	 * @param __name The name of the font.
	 * @return The pixel size of the font.
	 * @throws IllegalArgumentException If the font does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static int getPixelSize(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.getPixelSize();
		
		// {@squirreljme.error EB21 No font with the given name exists.
		// (The font name)}
		throw new IllegalArgumentException("EB21 " + __name);
	}
	
	/**
	 * Returns the style of the given font.
	 *
	 * @param __name The name of the font.
	 * @return The style of the font.
	 * @throws IllegalArgumentException If the font does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static int getStyle(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.getStyle();
		
		// {@squirreljme.error EB22 No font with the given name exists.
		// (The font name)}
		throw new IllegalArgumentException("EB2g " + __name);
	}
}


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

package javax.microedition.lcdui;

/**
 * This is thrown when the format of a font is not correct.
 *
 * @since 2018/11/23
 */
public class FontFormatException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/23
	 */
	public FontFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/23
	 */
	public FontFormatException(String __m)
	{
		super(__m);
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Form.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;

public class Form
	extends Screen
{
	/** Items on the form. */
	final __VolatileList__<Item> _items =
		new __VolatileList__<>();
	
	/**
	 * Initializes an empty form with an optionally specified title.
	 *
	 * @param __t The title of the form, may be {@code null}.
	 * @since 2017/08/19
	 */
	public Form(String __t)
	{
		this(__t, null);
	}
	
	/**
	 * Initializes a form with the given items and an optionally specified
	 * title.
	 *
	 * @param __t The title of the form, may be {@code null}.
	 * @param __i The items to add to the form.
	 * @throws IllegalStateException If an item in the form is already owned
	 * by another container.
	 * @throws NullPointerException If any element in {@code __i} is
	 * {@code null}.
	 * @since 2017/08/19
	 */
	public Form(String __t, Item[] __i)
		throws IllegalStateException, NullPointerException
	{
		// Forms just use the titles the same as Displayables
		try
		{
			this.setTitle(__t);
		}
		
		// Ignore this if it occurs so that constructing the form does not
		// end in failure
		catch (DisplayCapabilityException e)
		{
		}
		
		// Append items in order
		if (__i != null)
			for (Item i : __i)
			{
				// Check
				if (i == null)
					throw new NullPointerException("NARG");
				
				this.append(i);
			}
	}
	
	/**
	 * Appends the given string.
	 *
	 * @param __s The string.
	 * @return The index of the item.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		return this.append(new StringItem(null, __s));
	}
	
	/**
	 * Appends the given image.
	 *
	 * @param __i The image.
	 * @return The index of the item.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(Image __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return this.append(new ImageItem(null, __i, ImageItem.LAYOUT_DEFAULT,
			null));
	}
	
	/**
	 * Appends the given item to the form.
	 *
	 * @param __i The item to append.
	 * @return The index of the item.
	 * @throws IllegalStateException If the item is already associated with
	 * a form.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(Item __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB23 Cannot append an item which has already
		// be associated with a form.}
		if (__i._displayable != null)
			throw new IllegalStateException("EB23");
		__i._displayable = this;
		
		// Append item
		__VolatileList__<Item> items = this._items;
		int rv = items.append(__i);
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
		
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	public void deleteAll()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the given form item.
	 *
	 * @param __i The index to get.
	 * @return The item.
	 * @throws IndexOutOfBoundsException If the index is not within range.
	 * @since 2019/05/19
	 */
	public Item get(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i);
	}
	
	/**
	 * Returns the currently focused item in the form, or {@code null} if there
	 * is not item being focused.
	 *
	 * @return The current focus item.
	 * @since 2019/12/09
	 */
	public Item getCurrent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, false);
	}
	
	public FormLayoutPolicy getLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, false);
	}
	
	public void insert(int __a, Item __b)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, Item __b)
	{
		throw new todo.TODO();
	}
	
	public void setItemStateListener(ItemStateListener __a)
	{
		throw new todo.TODO();
	}
	
	public void setItemTraversalListener(ItemTraversalListener __itl)
	{
		throw new todo.TODO();
	}
	
	public void setLayoutPolicy(FormLayoutPolicy __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of items in the form.
	 *
	 * @return The number of form items.
	 * @since 2109/05/19
	 */
	public int size()
	{
		return this._items.size();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/FormLayoutPolicy.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class FormLayoutPolicy
{
	public static int DIRECTION_LTR =
		0;
	
	public static int DIRECTION_RTL =
		1;
	
	protected FormLayoutPolicy(Form __f)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected abstract void doLayout(int __vpx, int __vpy, int __vpw,
		int __vph, int[] __ts);
	
	protected abstract Item getTraverse(Item __i, int __dir);
	
	protected final Form getForm()
	{
		throw new todo.TODO();
	}
	
	protected final int getHeight(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getWidth(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getX(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getY(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final boolean isValid(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final void setPosition(Item __i, int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	protected final void setSize(Item __i, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	protected final void setValid(Item __i)
	{
		throw new todo.TODO();
	}
	
	public static final int getLayoutDirection()
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public class Gauge
	extends Item
{
	public static final int CONTINUOUS_IDLE =
		0;
	
	public static final int CONTINUOUS_RUNNING =
		2;
	
	public static final int INCREMENTAL_IDLE =
		1;
	
	public static final int INCREMENTAL_UPDATING =
		3;
	
	public static final int INDEFINITE =
		-1;
	
	/** Is this interactive? */
	final boolean _interactive;
	
	/** Maximum value. */
	volatile int _maxvalue;
	
	/** Current value. */
	volatile int _value;
	
	/**
	 * Initializes the gauge.
	 *
	 * @param __l The label.
	 * @param __int Can the user change the value?
	 * @param __max The maximum value.
	 * @param __iv The initial value.
	 * @throws IllegalArgumentException If the max value is not positive for
	 * interactive ranges, if the max value is not positive or
	 * {@link #INDEFINITE} for non-interactive ranges, or the initial value
	 * is not one of the special values if it is {@link #INDEFINITE}.
	 * @since 2019/05/17
	 */
	public Gauge(String __l, boolean __int, int __max, int __iv)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB24 An interactive gauge cannot have a negative
		// maximum value.}
		if (__int && __max < 0)
			throw new IllegalArgumentException("EB24");
		
		// {@squirreljme.error EB25 A non-interactive gauge cannot have a
		// negative value that is not indefinite.}
		if (!__int && !(__max >= 0 || __max == Gauge.INDEFINITE))
			throw new IllegalArgumentException("EB25");
		
		// {@squirreljme.error EB26 Invalid symbolism for indefinite range.}
		if (__max == Gauge.INDEFINITE && __iv != Gauge.CONTINUOUS_IDLE &&
			__iv != Gauge.CONTINUOUS_RUNNING && __iv != Gauge.INCREMENTAL_IDLE &&
			__iv != Gauge.INCREMENTAL_UPDATING)
			throw new IllegalArgumentException("EB26");
		
		this._interactive = __int;
		this._value = __iv;
		this._maxvalue = __max;
	}
	
	public int getIncrementValue()
	{
		throw new todo.TODO();
	}
	
	public int getMaxValue()
	{
		throw new todo.TODO();
	}
	
	public int getMinValue()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInteractive()
	{
		throw new todo.TODO();
	}
	
	public void setIncrementValue(int __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @throws IllegalArgumentException If this gauge is associated with an
	 * alert.
	 * @since 2019/05/17
	 */
	@Override
	public void setLabel(String __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB27 Cannot set the label of a gauge associated
		// with an alert.}
		if (this._displayable instanceof Alert)
			throw new IllegalArgumentException("EB27");
		
		// Use super logic
		super.setLabel(__l);
	}
	
	public void setMaxValue(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setMinValue(int __v)
	{
		throw new todo.TODO();
	}
	
	public void setValue(int __a)
	{
		throw new todo.TODO();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Graphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import javax.microedition.lcdui.game.Sprite;

/**
 * The class describes the interface that is used for drawing operations.
 *
 * When the clipping area is used, no pixels outside of it are drawn. This may
 * be used to draw special effects or have similar maskings.
 *
 * The anchor points {@link #BASELINE}, {@link #BOTTOM}, {@link #HCENTER},
 * {@link #LEFT}, {@link #RIGHT}, {@link #TOP}, and {@link #VCENTER} modify how
 * text and images are placed by allowing their placement positions to be
 * shifted accordingly.
 *
 * The default blending mode must be {@link #SRC_OVER}.
 *
 * An alpha value of {@code 255} means fully opaque (visible) while a value of
 * {@code 0} means transparent (invisible).
 *
 * @since 2017/02/09
 */
public abstract class Graphics
{
	/**
	 * This is the anchorpoint for the baseline of text. This is not valid for
	 * anything which is not text. The baseline is considered to be point where
	 * all letters rest on. The baseline is not the lowest point, so for
	 * letters such as {@code j} the baseline will be higher than the lowest
	 * point.
	 */
	public static final int BASELINE =
		64;
	
	/** The anchor point to position below the specified point. */
	public static final int BOTTOM =
		32;
	
	/** Dotted stroke line style. */
	public static final int DOTTED =
		1;
	
	/** The anchor point to position in the center horizontally. */
	public static final int HCENTER =
		1;
	
	/** The anchor point to position the item to the left. */
	public static final int LEFT =
		4;
	
	/** The anchor point to position the item on the right. */
	public static final int RIGHT =
		8;
	
	/** Solid stroke line style. */
	public static final int SOLID =
		0;
	
	/**
	 * The blending mode, the destination alpha becomes the source and as such
	 * the operation is a copy.
	 */
	public static final int SRC =
		1;
	
	/**
	 * The blending mode, the source alpha is a composited over the
	 * destination.
	 */
	public static final int SRC_OVER =
		0;
	
	/** The anchor point to position the item on the top. */
	public static final int TOP =
		16;
	
	/** The anchor point to position in the center vertically. */
	public static final int VCENTER =
		2;
	
	/**
	 * Base initialization of graphics sub-class.
	 *
	 * Note that extending this class is specific to SquirrelJME and that
	 * doing so will cause programs to only run on SquirrelJME.
	 *
	 * @since 2016/10/10
	 */
	protected Graphics()
	{
	}
	
	/**
	 * This reduces the clipping area of the drawing so that 
	 *
	 * This is only used to reduce the clipping area, to make it larger use
	 * {@link Graphics#setClip(int, int, int, int)}.
	 *
	 * @param __x The X coordinate of the clipping rectangle,
	 * will be translated.
	 * @param __y The Y coordinate of the clipping rectangle,
	 * will be translated.
	 * @param __w The width of the rectangle.
	 * @param __h The height of the rectangle.
	 * @since 2017/02/10
	 */
	public abstract void clipRect(int __x, int __y, int __w, int __h);
	
	/**
	 * This copies one region of the image to another region.
	 *
	 * Copying to a display device is not permitted because it may impact how
	 * double buffering is implemented, as such it is not supported.
	 *
	 * Pixels are copied directly and no alpha compositing is performed.
	 *
	 * If the source and destination overlap then it must be as if they did not
	 * overlap at all, this means that the destination will be an exact copy of
	 * the source.
	 *
	 * @param __sx The source X position, will be translated.
	 * @param __sy The source Y position, will be translated.
	 * @param __w The width to copy.
	 * @param __h The height to copy.
	 * @param __dx The destination X position, will be translated.
	 * @param __dy The destination Y position, will be translated.
	 * @param __anchor The anchor point of the destination.
	 * @throws IllegalArgumentException If the source region exceeds the size
	 * of the source image.
	 * @throws IllegalStateException If the destination is a display device.
	 * @since 2017/02/10
	 */
	public abstract void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException;
	
	/**
	 * This draws the outer edge of the ellipse from the given angles using
	 * the color, alpha, and stroke style.
	 *
	 * The coordinates are treated as if they were in a rectangular region. As
	 * such the center of the ellipse to draw the outline of is in the center
	 * of the specified rectangle.
	 *
	 * Note that no lines are drawn to the center point, so the shape does not
	 * result in a pie slice.
	 *
	 * The angles are in degrees and visually the angles match those of the
	 * unit circle correctly transformed to the output surface. As such, zero
	 * degrees has the point of {@code (__w, __h / 2)}, that is it points to
	 * the right. An angle at 45 degrees will always point to the top right
	 * corner.
	 *
	 * If the width or height are zero, then nothing is drawn. The arc will
	 * cover an area of {@code __w + 1} and {@code __h + 1}.
	 *
	 * @param __x The X position of the upper left corner, will be translated.
	 * @param __y The Y position of the upper left corner, will be translated.
	 * @param __w The width of the arc.
	 * @param __h The height of the arc.
	 * @param __sa The starting angle in degrees, 
	 * @param __aa The offset from the starting angle, negative values indicate
	 * clockwise direction while positive values are counter clockwise.
	 * @since 2017/02/10
	 */ 
	public abstract void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa);
	
	public abstract void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException;
	
	public abstract void drawChar(char __s, int __x, int __y, int __anchor);
	
	public abstract void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException;
	
	/**
	 * Draws the specified image.
	 *
	 * If this graphics object draws onto the source image then the result is
	 * undefined, {@link #copyArea(int, int, int, int, int, int, int)} should
	 * be used instead.
	 *
	 * @param __i The source image.
	 * @param __x The X position to draw at, is translated.
	 * @param __y The Y position to draw at, is translated.
	 * @param __anchor The anchor point of the image.
	 * @throws IllegalArgumentException If the anchor point is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public abstract void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Draws a line using the current color and stroke style.
	 *
	 * @param __x1 Starting X position.
	 * @param __y1 Starting Y position.
	 * @param __x2 Ending X position.
	 * @param __y2 Ending Y position.
	 * @since 2017/02/11
	 */
	public abstract void drawLine(int __x1, int __y1, int __x2, int __y2);
	
	public abstract void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException;
	
	public abstract void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException;
	
	public abstract void drawRect(int __x, int __y, int __w, int __h);
	
	/**
	 * Same as {@code drawRegion(__src, __xsrc __ysrc, __wsrc, __hsrc, __trans,
	 * __xdest, __ydest, __anch, __wsrc, __hsrc);}.
	 *
	 * @param __src The source image.
	 * @param __xsrc The source X position.
	 * @param __ysrc The source Y position.
	 * @param __wsrc The width of the source region.
	 * @param __hsrc The height of the source region.
	 * @param __trans Sprite translation and/or rotation, see {@link Sprite}.
	 * @param __xdest The destination X position, is translated..
	 * @param __ydest The destination Y position, is translated..
	 * @param __anch The anchor point.
	 * @throws IllegalArgumentException If the source is the destination
	 * image; the source region exceeds the image bounds; the sprite
	 * transformation is not valid; The anchor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11 
	 */
	public abstract void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Draws the specified region of the given image with potential scaling
	 * and transformations.
	 *
	 * @param __src The source image.
	 * @param __xsrc The source X position.
	 * @param __ysrc The source Y position.
	 * @param __wsrc The width of the source region.
	 * @param __hsrc The height of the source region.
	 * @param __trans Sprite translation and/or rotation, see {@link Sprite}.
	 * @param __xdest The destination X position, is translated..
	 * @param __ydest The destination Y position, is translated..
	 * @param __anch The anchor point.
	 * @param __wdest The destination width.
	 * @param __hdest The destination height.
	 * @throws IllegalArgumentException If the source is the destination
	 * image; the source region exceeds the image bounds; the sprite
	 * transformation is not valid; The anchor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11 
	 */
	public abstract void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException;
	
	public abstract void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah);
	
	/**
	 * Same as {@code drawSubstring(__s, 0, __s.length(), __x, __y, __anchor)}.
	 *
	 * @param __s The string to draw.
	 * @param __x The X position, will be translated.
	 * @param __y The Y position, will be translated.
	 * @param __anchor The anchor point.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/02/10
	 */
	public abstract void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException;
	
	public abstract void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException;
	
	public abstract void drawText(Text __t, int __x, int __y);
	
	/**
	 * This draws the filled slice of an ellipse (like a pie slice) from the
	 * given angles using the color, alpha, and stroke style.
	 *
	 * Unlike {@link #drawArc(int, int, int, int, int, int)}, the width and
	 * height are not increased by a single pixel.
	 *
	 * Otherwise, this follows the same set of rules as
	 * {@link #drawArc(int, int, int, int, int, int)}.
	 *
	 * @param __x The X position of the upper left corner, will be translated.
	 * @param __y The Y position of the upper left corner, will be translated.
	 * @param __w The width of the arc.
	 * @param __h The height of the arc.
	 * @param __sa The starting angle in degrees, 
	 * @param __aa The offset from the starting angle, negative values indicate
	 * clockwise direction while positive values are counter clockwise.
	 * @see #drawArc(int, int, int, int, int, int)
	 * @since 2017/02/10
	 */
	public abstract void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa);
	
	public abstract void fillRect(int __x, int __y, int __w, int __h);
	
	public abstract void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah);
	
	public abstract void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3);
	
	/**
	 * Returns the alpha component.
	 *
	 * @return The alpha in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getAlpha();
	
	/**
	 * Returns the color along with the alpha color. 
	 *
	 * @return The color in the form of {@code @0xAARRGGBB}.
	 * @since 2017/02/10
	 */
	public abstract int getAlphaColor();
	
	/**
	 * Returns the blending mode.
	 *
	 * @return The current blending mode.
	 * @since 2017/02/10
	 */
	public abstract int getBlendingMode();
	
	/**
	 * Returns the blue component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getBlueComponent();
	
	/**
	 * This returns the height of the clipping area.
	 *
	 * @return The clipping area height.
	 * @since 2017/02/10
	 */
	public abstract int getClipHeight();
	
	/**
	 * This returns the width of the clipping area.
	 *
	 * @return The clipping area width.
	 * @since 2017/02/10
	 */
	public abstract int getClipWidth();
	
	/**
	 * This returns the transformed X position of the clipping rectangle.
	 *
	 * @return The clipping area X coordinate, which is transformed.
	 * @since 2017/02/10
	 */
	public abstract int getClipX();
	
	/**
	 * This returns the transformed Y position of the clipping rectangle.
	 *
	 * @return The clipping area Y coordinate, which is transformed.
	 * @since 2017/02/10
	 */
	public abstract int getClipY();
	
	/**
	 * Returns the current color which has been set for drawing.
	 *
	 * @return The color in the form of {@code 0x00RRGGBB}, the upper bits
	 * for alpha will always be zero.
	 * @since 2017/02/10
	 */
	public abstract int getColor();
	
	/**
	 * This returns the actual color that would be drawn onto the given
	 * display if it were set.
	 *
	 * @param __rgb The color to use, the format is {@code 0xRRGGBB}.
	 * @return The color that will actually be drawn on the display.
	 * @since 2017/02/09
	 */
	public abstract int getDisplayColor(int __rgb);
	
	/**
	 * Returns the current font that is used for drawing characters.
	 *
	 * @return The current font that is used.
	 * @since 2017/02/10
	 */
	public abstract Font getFont();
	
	/**
	 * Returns the grayscale color component. If the current set color is not
	 * grayscale then it is unspecified how the grayscale color is derived (it
	 * may be a simple average or derived from display specific brightness
	 * values).
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getGrayScale();
	
	/**
	 * Returns the green component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getGreenComponent();
	
	/**
	 * Returns the red component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getRedComponent();
	
	/**
	 * Returns the current stroke style for lines which are drawn.
	 *
	 * @return The current stroke style.
	 * @since 2017/02/10
	 */
	public abstract int getStrokeStyle();
	
	/**
	 * Returns the X coordinate of the translated coordinate system.
	 *
	 * @return The X coordinate of the translated coordinate system.
	 * @since 2017/02/10
	 */
	public abstract int getTranslateX();
	
	/**
	 * Returns the Y coordinate of the translated coordinate system.
	 *
	 * @return The Y coordinate of the translated coordinate system.
	 * @since 2017/02/10
	 */
	public abstract int getTranslateY();
	
	/**
	 * Sets the alpha value to use for drawing.
	 *
	 * @param __a The alpha value to use.
	 * @throws IllegalArgumentException If the value is not in the range of
	 * {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract void setAlpha(int __a)
		throws IllegalArgumentException;
	
	/**
	 * Sets the alpha color to draw with along with the color to use.
	 *
	 * @param __argb The color in the form of {@code 0xAARRGGBB}.
	 * @since 2017/02/10
	 */
	public abstract void setAlphaColor(int __argb);
	
	/**
	 * Sets the color and alpha value to use for drawing.
	 *
	 * @param __a The alpha value.
	 * @param __r The red value.
	 * @param __g The green value.
	 * @param __b The blue value.
	 * @throws IllegalArgumentException If any component is not within the
	 * range of {@code [0, 255]}.
	 * @since 2017/02/09
	 */
	public abstract void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException;
	
	/**
	 * Sets the blending mode of the drawing operations.
	 *
	 * @param __m The mode of drawing to use.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2017/02/10
	 */
	public abstract void setBlendingMode(int __m)
		throws IllegalArgumentException;
	
	/**
	 * Sets the new clipping area of the destination image. The previous
	 * clipping area is replaced.
	 *
	 * @param __x The X coordinate, will be translated.
	 * @param __y The Y coordinate, will be translated.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2017/02/10
	 */
	public abstract void setClip(int __x, int __y, int __w, int __h);
	
	/**
	 * Sets the combined RGB value to use for drawing.
	 *
	 * @param __rgb The color to use, the format is {@code 0xRRGGBB}.
	 * @since 2017/02/09
	 */
	public abstract void setColor(int __rgb);
	
	/**
	 * Sets the color to use for drawing.
	 *
	 * @param __r The red value.
	 * @param __g The green value.
	 * @param __b The blue value.
	 * @throws IllegalArgumentException If any component is not within the
	 * range of {@code [0, 255]}.
	 * @since 2017/02/09
	 */
	public abstract void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException;
	
	/**
	 * Sets the font to use for drawing operations.
	 *
	 * @param __a The font to use for drawing, if {@code null} then the
	 * default font is used.
	 * @since 2017/02/09
	 */
	public abstract void setFont(Font __a);
	
	/**
	 * Sets a grayscale color which has all the red, green, and blue
	 * components set as the same value.
	 *
	 * @param __v The value to use for the color.
	 * @since 2017/02/09
	 */
	public abstract void setGrayScale(int __v);
	
	/**
	 * Sets the stroke style to use for lines.
	 *
	 * @param __a The stroke style, either {@link #SOLID} or {@link #DOTTED}.
	 * @throws IllegalArgumentException If the stroke is not valid.
	 * @since 2017/02/09
	 */
	public abstract void setStrokeStyle(int __a)
		throws IllegalArgumentException;
	
	/**
	 * Translates all coordinates so that they are offset by the given
	 * values, a previous translation is translated by the given coordinates.
	 *
	 * To set the absolute position of the translation the following may be
	 * performed:
	 * {@code translate(ax - getTranslateX(), ay - getTranslateY())}.
	 *
	 * The clipping area, if set, will not be transformed.
	 *
	 * @param __x The X value to use for the new origin.
	 * @param __y The Y value to use for the new origin.
	 * @since 2017/02/09
	 */
	public abstract void translate(int __x, int __y);
}


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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class IdleItem
	extends CustomItem
{
	protected IdleItem(String __label)
	{
		super(__label);
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void addedToDisplay(Display __d)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void removedFromDisplay(Display __d)
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Image.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import cc.squirreljme.runtime.lcdui.image.ImageReaderDispatcher;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Image
{
	/** The RGB image data. */
	private final int[] _data;
	
	/** Image width. */
	private final int _width;
	
	/** Image height. */
	private final int _height;
	
	/** Is this image mutable? */
	private final boolean _mutable;
	
	/** Does this have an alpha channel? */
	private final boolean _alpha;
	
	Image()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the image with the given settings.
	 *
	 * @param __data The image data, this is used directly.
	 * @param __w The image width.
	 * @param __h The image height.
	 * @param __mut If this image is mutable
	 * @param __alpha If this image has an alpha channel.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	Image(int[] __data, int __w, int __h, boolean __mut, boolean __alpha)
	{
		// Check
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._data = __data;
		this._width = __w;
		this._height = __h;
		this._mutable = __mut && !this.isAnimated() && !this.isScalable();
		this._alpha = __alpha;
		
		// If no alpha, set upper channel to full opaqueness
		if (!__alpha)
			for (int i = 0, n = __data.length; i < n; i++)
				__data[i] |= 0xFF000000;
	}
	
	public final void getARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This obtains the graphics interface which is used to draw on top of
	 * a mutable image.
	 *
	 * It defaults to:
	 * The clipping region covers the entire image.
	 * The color is a fully opaque black.
	 * The blending mode is {@link Graphics#SRC_OVER}.
	 * The stroke is {@link Graphics#SOLID}.
	 * The font is the default font.
	 * The coordinate origin is the top-left corner.
	 *
	 * The blending mode may only be changed to {@link Graphics#SRC} if the
	 * image has an alpha channel.
	 *
	 * @return A new graphics drawer.
	 * @throws IllegalStateException If the image is not mutable.
	 * @since 2017/02/10
	 */
	public final Graphics getGraphics()
		throws IllegalStateException
	{
		// {@squirreljme.error EB28 Cannot get mutable graphic operations for
		// an immutable image.}
		if (!this.isMutable())
			throw new IllegalStateException("EB28");
		
		// Create
		return new AdvancedGraphics(this._data, this._alpha, null, this._width,
			this._height, this._width, 0, 0, 0);
	}
	
	/**
	 * Returns the image height.
	 *
	 * @return The height of the image.
	 * @since 2017/02/10
	 */
	public final int getHeight()
	{
		return this._height;
	}
	
	/**
	 * Copies RGB image data from the source image.
	 *
	 * The source image data must be within the bounds of the image.
	 *
	 * All written pixels will have an alpha value regardless if the image has
	 * an alpha channel or not. In the case the image has no alpha channel then
	 * all read pixels will have a value of {@code 0xFF} as their alpha
	 * channel.
	 *
	 * @param __b The destination array.
	 * @param __o The offset into the array.
	 * @param __sl The scanline length of the destination array, this value may
	 * be negative to indicate that pixels are placed in reverse order.
	 * @param __x The source X position.
	 * @param __y The source Y position.
	 * @param __w The width to copy, if this is zero nothing is copied.
	 * @param __h The height to copy, if this is zero nothing is copied.
	 * @throws ArrayIndexOutOfBoundsException If writing to the destination
	 * buffer would result in a write that exceeds the bounds of the array.
	 * @throws IllegalArgumentException If the source X or Y position is
	 * negative; If the source region exceeds the image bounds; If the absolute
	 * value of the scanline length is lower than the width.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public final void getRGB(int[] __b, int __o, int __sl, int __x, int __y,
		int __w, int __h)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Do nothing
		if (__w <= 0 || __h <= 0)
			return;
		
		// Scalable images must be rasterized
		if (this.isScalable())
			throw new todo.TODO();
			
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB29 The source coordinates are negative.}
		if (__x < 0 || __y < 0)
			throw new IllegalArgumentException("EB29");
	
		// {@squirreljme.error EB2a The absolute value of the scanline length
		// exceeds the read width.}
		int absl = Math.abs(__sl);
		if (absl < __w)
			throw new IllegalArgumentException("EB2a");
		
		// {@squirreljme.error EB2b Reading of RGB data would exceed the bounds
		// out the output array.}
		int srcarea = __w * __h;
		int areasl = __sl * __h;
		if (__o < 0 || (__o + areasl) > __b.length || (__o + areasl) < 0)
			throw new ArrayIndexOutOfBoundsException("EB2b");
		
		// {@squirreljme.error EB2c The area to read exceeds the bounds of the
		// image.}
		int ex = __x + __w,
			ey = __y + __h;
		int iw = this._width,
			ih = this._height;
		if (ex > iw || ey > ih)
			throw new IllegalArgumentException("EB2c");
		
		// If the alpha channel is not used then all RGB data is forced to
		// be fully opaque
		int opqmask = (this._alpha ? 0 : 0xFF_000000);
		
		// Read image data
		int[] data = this._data;
		for (int sy = __y, wy = 0; sy < ey; sy++, wy++)
		{
			// Calculate offsets
			int srcoff = (iw * sy) + __x;
			int dstoff = __o + (wy * __sl);
			
			// Copy data
			for (int sx = __x; sx < ex; sx++)
				__b[dstoff++] = data[srcoff++] | opqmask;
		}
	}
	
	public final void getRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the image width.
	 *
	 * @return The width of the image.
	 * @since 2017/02/10
	 */
	public final int getWidth()
	{
		return this._width;
	}
	
	/**
	 * Returns {@code true} if this image has an alpha channel.
	 *
	 * @return {@code true} if this image has an alpha channel.
	 * @since 2017/02/10
	 */
	public final boolean hasAlpha()
	{
		return this._alpha;
	}
	
	/**
	 * Returns {@code true} if this image is animated.
	 *
	 * @return {@code true} if this image is animated.
	 * @since 2017/02/10
	 */
	public final boolean isAnimated()
	{
		return (this instanceof AnimatedImage);
	}
	
	/**
	 * Returns {@code true} if this image is mutable.
	 *
	 * @return {@code true} if this image is mutable.
	 * @since 2017/02/10
	 */
	public final boolean isMutable()
	{
		return this._mutable && !this.isAnimated() && !this.isScalable();
	}
	
	/**
	 * Returns {@code true} if this image is scalable.
	 *
	 * @return {@code true} if this image is scalable.
	 * @since 2017/02/10
	 */
	public final boolean isScalable()
	{
		return (this instanceof ScalableImage);
	}
	
	/**
	 * Loads the specified image from the specified byte array.
	 *
	 * @param __b The array to read from.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @return The loaded image.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IllegalArgumentException If the image could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return Image.createImage(new ByteArrayInputStream(__b, __o, __l));
		}
		
		// {@squirreljme.error EB2d Could not load the image data.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("EB2d", e);
		}
	}
	
	/**
	 * Same as {@code createImage(__w, __h, false, 0x00FFFFFF)}.
	 *
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @return The created image.
	 * @throws IllegalArgumentException If the requested image size has a zero
	 * or negative dimension.
	 * @since 2017/02/11
	 */
	public static Image createImage(int __w, int __h)
		throws IllegalArgumentException
	{
		return Image.createImage(__w, __h, false, 0x00FFFFFF);
	}
	
	/**
	 * Creates a mutable image that may or may not have an alpha channel.
	 *
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @param __alpha Whether it has an alpha channel.
	 * @param __c The initial color to fill.
	 * @return The created image.
	 * @throws IllegalArgumentException If the requested image size has a zero
	 * or negative dimension.
	 * @since 2017/02/11
	 */
	public static Image createImage(int __w, int __h, boolean __alpha, int __c)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2e Zero or negative image size requested.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("EB2e");
		
		// Setup buffer
		int area = __w * __h;
		int[] data = new int[area];
		
		// Fill with color
		for (int i = 0; i < area; i++)
			data[i] = __c;
		
		// Create
		return new Image(data, __w, __h, true, __alpha);
	}
	
	/**
	 * Loads the image from the specified input stream.
	 *
	 * @param __is The stream to read image data from.
	 * @return The parsed image.
	 * @throws IOException If the image could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(InputStream __is)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// If marking is supported, directly use the stream
		if (__is.markSupported())
			return ImageReaderDispatcher.parse(__is);
		
		// Load the entire image data into a buffer so that we can mark it
		byte[] copy;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			Math.max(__is.available(), 4096)))
		{
			// Copy the image data
			byte[] buf = new byte[512];
			for (;;)
			{
				int rc = __is.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Use copied data
			copy = baos.toByteArray();
		}
		
		// Parse the data now that it can be marked
		return ImageReaderDispatcher.parse(new ByteArrayInputStream(copy));
	}
	
	/**
	 * This loads the specified resource as an image.
	 *
	 * @param __s The string to load the resource for.
	 * @return The created image.
	 * @throws IOException If the resource does not exist or the image data
	 * could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Try loading it
		try (InputStream is = ActiveMidlet.get().getClass().
			getResourceAsStream(__s))
		{
			// {@squirreljme.error EB2f The specified resource does not
			// exist. (The resource name)}
			if (is == null)
				throw new IOException(String.format("EB2f %s", __s));
			
			return Image.createImage(is);
		}
	}
	
	/**
	 * Creates an immutable image which is an exact copy of the other image. If
	 * the other image is scalable it will be rasterized with whatever
	 * dimensions the other image has. If the specified image is immutable then
	 * it will be returned.
	 *
	 * @param __i The image to copy.
	 * @return The resulting copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/24
	 */
	public static Image createImage(Image __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// Needs to be rendered
		if (__i instanceof ScalableImage)
			throw new todo.TODO();
		
		// Same otherwise
		else if (!__i._mutable)
			return __i;
		
		// Copy and make this immutable
		return new Image(__i._data.clone(), __i._width, __i._height,
			false, __i._alpha);
	}
	
	public static Image createImage(Image __i, int __x, int __y,
		int __w, int __h, int __trans)
	{
		return Image.createImage(__i, __x, __y, __w, __h, __trans,
			__i.getWidth(), __i.getHeight());
	}
	
	public static Image createImage(Image __i, int __x, int __y, int __w,
		int __h, int __trans, int __iw, int __ih)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Creates an image from the specified ARGB pixel array.
	 *
	 * @param __rgb The ARGB or RGB image data to use as the image data.
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @param __alpha If {@code true} then the alpha is processed, otherwise
	 * all pixels are treated as fully opaque.
	 * @return The created image.
	 * @throws IllegalArgumentException If the width or height is negative.
	 * @throws IndexOutOfBoundsException If the input array is too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public static Image createRGBImage(int[] __rgb, int __w, int __h, boolean 
		__alpha)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__rgb == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB2g Invalid image size. (The width;
		// The height)}
		int area = __w * __h;
		if (__w <= 0 || __h <= 0 || area <= 0)
			throw new IllegalArgumentException(String.format("EB2g %d %d",
				__w, __h));
		
		// {@squirreljme.error EB2h The input integer buffer is shorter than
		// the specified area.}
		int rgblen;
		if ((rgblen = __rgb.length) < area)
			throw new IndexOutOfBoundsException("EB2h");
		
		// Use a cloned copy of the pixel data?
		if (rgblen == area)
			__rgb = __rgb.clone();
		
		// Otherwise initialize a new one
		else
		{
			int[] copy = new int[area];
			for (int i = 0; i < area; i++)
				copy[i] = __rgb[i];
			__rgb = copy;
		}
		
		// If there is no alpha channel, force all of it opaque
		if (!__alpha)
			for (int i = 0; i < area; i++)
				__rgb[i] |= 0xFF000000;
		
		// Setup image
		return new Image(__rgb, __w, __h, false, __alpha);
	}
}

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

package javax.microedition.lcdui;

public class ImageItem
	extends Item
{
	public static final int LAYOUT_CENTER =
		3;
	
	public static final int LAYOUT_DEFAULT =
		0;
	
	public static final int LAYOUT_LEFT =
		1;
	
	public static final int LAYOUT_NEWLINE_AFTER =
		512;
	
	public static final int LAYOUT_NEWLINE_BEFORE =
		256;
	
	public static final int LAYOUT_RIGHT =
		2;
	
	/** Apperance mode. */
	final int _amode;
	
	/** Cache of the used image. */
	private volatile Image _image;
	
	/** Alternative text. */
	private volatile String _alt;
	
	/**
	 * Initializes the image item.
	 *
	 * @param __l The label.
	 * @param __i The image.
	 * @param __lay The layout.
	 * @param __alt The alternative text.
	 * @throws IllegalArgumentException If the layout is not valid.
	 * @since 2019/05/17
	 */
	public ImageItem(String __l, Image __i, int __lay, String __alt)
		throws IllegalArgumentException
	{
		this(__l, __i, __lay, __alt, Item.PLAIN);
	}
	
	/**
	 * Initializes the image item.
	 *
	 * @param __l The label.
	 * @param __i The image.
	 * @param __lay The layout.
	 * @param __alt The alternative text.
	 * @param __am The appearance mode.
	 * @throws IllegalArgumentException If the layout is not valid.
	 * @since 2019/05/17
	 */
	public ImageItem(String __l, Image __i, int __lay, String __alt, int __am)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB2i The appearance mode is not valid.
		// (The appearance mode)}
		if (__am != Item.PLAIN && __am != Item.BUTTON && __am != Item.HYPERLINK)
			throw new IllegalArgumentException("EB2i " + __am);
		
		this._image = __i;
		this._alt = __alt;
		this._amode = __am;
		
		// Set the layout
		this.setLayout(__lay);
	}
	
	public String getAltText()
	{
		throw new todo.TODO();
	}
	
	public int getAppearanceMode()
	{
		throw new todo.TODO();
	}
	
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	public void setAltText(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this item. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code imageitem.setImage(imageitem.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	public void setLayout(int __lay)
		throws IllegalArgumentException
	{
		super.setLayout(__lay);
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Item.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;

public abstract class Item
{
	public static final int BUTTON =
		2;
	
	public static final int HYPERLINK =
		1;
	
	public static final int LAYOUT_2 =
		16384;
	
	public static final int LAYOUT_BOTTOM =
		32;
	
	public static final int LAYOUT_CENTER =
		3;
	
	public static final int LAYOUT_DEFAULT =
		0;
	
	public static final int LAYOUT_EXPAND =
		2048;
	
	public static final int LAYOUT_LEFT =
		1;
	
	public static final int LAYOUT_NEWLINE_AFTER =
		512;
	
	public static final int LAYOUT_NEWLINE_BEFORE =
		256;
	
	public static final int LAYOUT_RIGHT =
		2;
	
	public static final int LAYOUT_SHRINK =
		1024;
	
	public static final int LAYOUT_TOP =
		16;
	
	public static final int LAYOUT_VCENTER =
		48;
	
	public static final int LAYOUT_VEXPAND =
		8192;
	
	public static final int LAYOUT_VSHRINK =
		4096;
	
	public static final int PLAIN =
		0;
	
	/** The owning displayable. */
	volatile Displayable _displayable;
	
	/** The current layout of the item. */
	volatile int _layout = Item.LAYOUT_DEFAULT;
	
	/** The label of this item. */
	volatile String _label;
	
	/** The preferred width. */
	volatile int _preferredw =
		-1;
	
	/** The preferred height. */
	volatile int _preferredh =
		-1;
	
	/**
	 * Initializes the base item.
	 *
	 * @since 2017/08/19
	 */
	Item()
	{
	}
	
	/**
	 * Initializes the base item with some parameters.
	 *
	 * @param __l The label to use.
	 * @since 2019/05/17
	 */
	Item(String __l)
	{
		this._label = __l;
	}
	
	public void addCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public Command[] getCommands()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label of the item.
	 *
	 * @return The label item.
	 * @since 2019/12/09
	 */
	public String getLabel()
	{
		return this._label;
	}
	
	public int getLayout()
	{
		throw new todo.TODO();
	}
	
	public ItemLayoutHint getLayoutHint()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the minimum height of the item.
	 *
	 * @return The minimum height.
	 * @since 2019/12/09
	 */
	public int getMinimumHeight()
	{
		// {@squirreljme.error EB37 Minimum height must be implemented.
		// (The class name)}
		throw new RuntimeException("EB37 " + this.getClass().getName());
	}
	
	/**
	 * Returns the minimum width of the item.
	 *
	 * @return The minimum width.
	 * @since 2019/12/09
	 */
	public int getMinimumWidth()
	{
		// {@squirreljme.error EB38 Minimum width must be implemented.
		// (The class name)}
		throw new RuntimeException("EB38 " + this.getClass().getName());
	}
	
	/**
	 * Returns the preferred height of the item, this may be calculated.
	 *
	 * @return The preferred item height.
	 * @since 2019/12/09
	 */
	public int getPreferredHeight()
	{
		int rv = this._preferredh,
			mn = this.getMinimumHeight();
		return (mn > rv ? mn : rv);
	}
	
	/**
	 * Returns the preferred width of the item, this may be calculated.
	 *
	 * @return The preferred item width.
	 * @since 2019/12/09
	 */
	public int getPreferredWidth()
	{
		int rv = this._preferredw,
			mn = this.getMinimumWidth();
		return (mn > rv ? mn : rv);
	}
	
	public void notifyStateChanged()
	{
		throw new todo.TODO();
	}
	
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setCommand(Command __c, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setDefaultCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setItemCommandListener(ItemCommandListener __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the label of the item.
	 *
	 * @param __l The label of the item to set, may be {@code null} to clear
	 * the label.
	 * @since 2017/08/20
	 */
	public void setLabel(String __l)
	{
		this._label = __l;
		
		// Repaint the display
		Displayable displayable = this._displayable;
		if (displayable != null)
		{
			Display display = displayable._display;
			if (display != null)
				UIState.getInstance().repaint();
		}
	}
	
	/**
	 * Sets the layout.
	 *
	 * @param __lay The layout.
	 * @since 2019/05/17
	 */
	public void setLayout(int __lay)
	{
		this._layout = __lay;
	}
	
	public void setLayoutHint(ItemLayoutHint __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the preferred size of the item. This sets the size of an item where
	 * if it is higher than the minimum then it is used, otherwise the minimum
	 * is used.
	 *
	 * @param __w The width, or {@code -1} to use the minimum.
	 * @param __h The height, or {@code -1} to use the minimum.
	 * @throws IllegalArgumentException If the width and/or height are lower
	 * than {@code -1}.
	 * @throws IllegalStateException If this item is within an alert.
	 * @since 2019/12/09
	 */
	public void setPreferredSize(int __w, int __h)
		throws IllegalArgumentException, IllegalStateException
	{
		// {@squirreljme.error EB35 Invalid preferred size requested.}
		if (__w < -1 || __h < -1)
			throw new IllegalArgumentException("EB35");
		
		// {@squirreljme.error EB36 Cannot set preferred size of item within
		// an alert.}
		if (this._displayable instanceof Alert)
			throw new IllegalStateException("EB36");
		
		this._preferredw = __w;
		this._preferredh = __h;
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/ItemCommandListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemCommandListener
{
	@SerializedEvent
	void commandAction(Command __a, Item __b);
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/ItemLayoutHint.java.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface ItemLayoutHint
{
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/ItemStateListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemStateListener
{
	@SerializedEvent
	void itemStateChanged(Item __a);
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/ItemTraversalListener.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemTraversalListener
{
	@SerializedEvent
	void itemTraversedIn(Item __i);
	
	@SerializedEvent
	void itemTraversedOut(Item __i);
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/KeyListener.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This is the key listener interface which is used for a slightly more
 * advanced means of listening for and responding to key events.
 *
 * Unlike {@link Canvas} and {@link CustomItem}, the key code that is passed
 * to these methods will be modified by the key modifiers (this means that
 * if shift is held down then letters will be uppercase).
 *
 * @since 2017/02/12
 */
public interface KeyListener
{
	/** The chr alt modifier. */
	int MODIFIER_ALT =
		65536;

	/** The chr key modifier. */
	int MODIFIER_CHR =
		8388608;

	/** The command key modifier. */
	int MODIFIER_COMMAND =
		4194304;

	/** The ctrl key modifier. */
	int MODIFIER_CTRL =
		262144;

	/** The mask for modifiers. */
	int MODIFIER_MASK =
		13041664;

	/** The shift key modifier. */
	int MODIFIER_SHIFT =
		131072;
	
	/**
	 * Called when a key is pressed.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @since 2017/02/12
	 */
	void keyPressed(int __kc, int __km);
	
	/**
	 * Called when a key is released.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @since 2017/02/12
	 */
	void keyReleased(int __kc, int __km);
	
	/**
	 * Called when a key is repeated.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @since 2017/02/12
	 */
	void keyRepeated(int __kc, int __km);
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/List.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.lcdui.fbui.UIState;

public class List
	extends Screen
	implements Choice
{
	/** The default select command used for lists. */
	public static final Command SELECT_COMMAND =
		new Command("Select", Command.SCREEN, 0, true);
	
	/** Items on the list. */
	final __VolatileList__<__ChoiceEntry__> _items =
		new __VolatileList__<>();
	
	/** The type of list this is. */
	private final int _type;
	
	/** The focal index. */
	volatile int _focalindex;
	
	/** Selection command. */
	volatile Command _selcommand =
		List.SELECT_COMMAND;
	
	/**
	 * Initializes the list.
	 *
	 * @param __title The list title.
	 * @param __type The type of list this is.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @since 2018/11/16
	 */
	public List(String __title, int __type)
		throws IllegalArgumentException
	{
		this(__title, __type, new String[0], new Image[0]);
	}
	
	/**
	 * Initializes the list.
	 *
	 * @param __title The list title.
	 * @param __type The type of list this is.
	 * @param __strs The initial string elements to add.
	 * @param __imgs The initial image elements to add.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @throws NullPointerException If the string elements is null or contains
	 * a null element.
	 * @since 2018/11/16
	 */
	public List(String __title, int __type, String[] __strs, Image[] __imgs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__strs == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB2j String and image elements differ in
		// size.}
		if (__imgs != null && __strs.length != __imgs.length)
			throw new IllegalArgumentException("EB2j");
		
		// {@squirreljme.error EB2k Invalid list type. (The list type)}
		if (__type != Choice.IMPLICIT && __type != Choice.EXCLUSIVE &&
			__type != Choice.MULTIPLE)
			throw new IllegalArgumentException("EB2k " + __type);
		
		// Set
		this._title = __title;
		this._type = __type;
		
		// Append all of the items to the list
		for (int i = 0, n = __strs.length; i < n; i++)
			this.append(__strs[i], (__imgs == null ? null : __imgs[i]));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public int append(String __s, Image __i)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Append item
		__ChoiceEntry__ e;
		__VolatileList__<__ChoiceEntry__> items = this._items;
		int rv = items.append((e = new __ChoiceEntry__(__s, __i)));
		
		// If this is the only item and this is an exclusive list, select it
		int ltype = this._type;
		if (items.size() == 1 && (ltype == Choice.EXCLUSIVE ||
			ltype == Choice.IMPLICIT))
			e._selected = true;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
		
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Deletes all of the items in the list.
	 *
	 * @since 2018/11/17
	 */
	public void deleteAll()
	{
		this._items.clear();
	}
	
	public int getFitPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Gets the font for the given index.
	 *
	 * @param __i The index to get.
	 * @return The font of the index.
	 * @throws IndexOutOfBoundsException On null arguments.
	 * @since 2019/05/18
	 */
	public Font getFont(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._font;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, false);
	}
	
	/**
	 * Returns the image of the given index.
	 *
	 * @param __i The index to get.
	 * @return The image for this index.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2019/05/18
	 */
	public Image getImage(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._image;
	}
	
	/**
	 * Returns the command to use when an item is selected.
	 *
	 * @return The select command.
	 * @since 2019/05/18
	 */
	@ImplementationNote("This is a SquirrelJME specific method.")
	public Command getSelectCommand()
	{
		return this._selcommand;
	}
	
	public int getSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public int getSelectedIndex()
	{
		// Multiple choice is always invalid
		if (this._type == Choice.MULTIPLE)
			return -1;
		
		// Find the first entry!
		int at = 0;
		for (__ChoiceEntry__ e : this._items)
		{
			if (e._selected)
				return at;
			at++;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the string at the given index.
	 *
	 * @param __i The string to get.
	 * @return The string.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/18
	 */
	public String getString(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._string;
	}
	
	/**
	 * Returns the list type.
	 *
	 * @return The list type.
	 * @since 2019/05/18
	 */
	@ImplementationNote("This is a SquirrelJME specific method.")
	public int getType()
	{
		return this._type;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, false);
	}
	
	public void insert(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	public boolean isEnabled(int __i)
		throws IndexOutOfBoundsException
	{
		return !this._items.get(__i)._disabled;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	public boolean isSelected(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._selected;
	}
	
	@Override
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/09
	 */
	@Override
	public void setEnabled(int __i, boolean __e)
		throws IndexOutOfBoundsException
	{
		this._items.get(__i)._disabled = !__e;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void setFitPolicy(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font of the given item.
	 *
	 * @param __i The item to set.
	 * @param __f The font to use, {@code null} clears it and uses the default.
	 * @throws IndexOutOfBoundsException If the item is not within bounds.
	 * @since 2019/05/20
	 */
	public void setFont(int __i, Font __f)
		throws IndexOutOfBoundsException
	{
		this._items.get(__i)._font = __f;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void setSelectCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/09
	 */
	@Override
	public void setSelectedIndex(int __i, boolean __e)
		throws IndexOutOfBoundsException
	{
		// Check bounds
		__VolatileList__<__ChoiceEntry__> items = this._items;
		int n = items.size();
		if (__i < 0 || __i >= n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If deselecting or using this on multiple lists, just direct set
		if (!__e || this._type == Choice.MULTIPLE)
			items.get(__i)._selected = __e;
		
		// Otherwise only select the item that matches the index
		else
		{
			for (int i = 0; i < n; i++)
				this._items.get(i)._selected = (__i == i);
		}
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public int size()
	{
		return this._items.size();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Menu.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Menu
	extends __Action__
{
	/** The image used. */
	private volatile Image _image;
	
	public Menu(String __short, String __long, Image __i)
	{
		throw new todo.TODO();
	}
	
	public int append(Command __c)
	{
		throw new todo.TODO();
	}
	
	public int append(Menu __m)
	{
		throw new todo.TODO();
	}
	
	public Command getCommand(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font that is used as a hint for rendering the text in
	 * a menu, it may be disregarded by the implementation.
	 *
	 * @return The font that should be used as a hint.
	 * @since 2018/04/01
	 */
	public Font getFont()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the image the menu.
	 *
	 * @return The image of the command or {@code null} if it has none.
	 * @since 2018/04/01
	 */
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label used for this menu.
	 *
	 * @return The label used for the menu.
	 * @since 2018/04/01
	 */
	public String getLabel()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the long label of the menu.
	 *
	 * @return The long label of the menu or {@code null} if it has none.
	 * @since 2018/04/01
	 */
	public String getLongLabel()
	{
		throw new todo.TODO();
	}
	
	public Menu getMenu(int __i)
	{
		throw new todo.TODO();
	}
	
	public int getMenuDepth()
	{
		throw new todo.TODO();
	}
	
	public void insert(int __i, Command __c)
	{
		throw new todo.TODO();
	}
	
	public void insert(int __i, Menu __m)
	{
		throw new todo.TODO();
	}
	
	public boolean isCommand(int __i)
	{
		throw new todo.TODO();
	}
	
	public boolean isEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isVisible()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e The new state of the parent.
	 * @since 2018/04/01
	 */
	@Override
	public void onParentEnabled(boolean __e)
	{
		// The default implementation does nothing
	}
	
	public void remove(Command __c)
	{
		throw new todo.TODO();
	}
	
	public void remove(Menu __m)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets whether this menu is enabled or disabled.
	 *
	 * @param __e If the menu is enabled or not.
	 * @since 2018/04/01
	 */
	public void setEnabled(boolean __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font used to be used as a hint when rendering the menu.
	 *
	 * @param __f The font to use as a hint when rendering the menu,
	 * {@code null} will use the default.
	 * @since 2018/04/01
	 */
	public void setFont(Font __f)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this menu. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code menu.setImage(menu.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * Sets the label to be displayed.
	 *
	 * @param __s The label to display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/01
	 */
	public void setLabel(String __s)
	{
		throw new todo.TODO();
		/*
		this.__setLabels(__s, this._longlabel, this._image);
		*/
	}
	
	/**
	 * Sets the long label of the menu.
	 *
	 * @param __s The long label to use, {@code null} clears it.
	 * @since 2018/04/01
	 */
	public void setLongLabel(String __s)
	{
		throw new todo.TODO();
		/*
		this.__setLabels(this._shortlabel, __s, this._image);
		*/
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
	
	public static int getMaxMenuDepth()
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public class Notification
{
	/** Cache of the used label. */
	private volatile String _label;
	
	/** Cache of the used image. */
	private volatile Image _image;
	
	public Notification(NotificationType __t)
	{
		throw new todo.TODO();
	}
	
	public Notification(NotificationType __t, String __l)
	{
		throw new todo.TODO();
	}
	
	public Notification(NotificationType __t, String __l, Image __i)
	{
		throw new todo.TODO();
	}
	
	public long getTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public NotificationType getType()
	{
		throw new todo.TODO();
	}
	
	public void post(boolean __s)
	{
		todo.TODO.note("Update mutable image on post.");
		throw new todo.TODO();
	}
	
	public void post(boolean __s, int __dur)
	{
		todo.TODO.note("Update mutable image on post.");
		throw new todo.TODO();
	}
	
	public void remove()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this notification. If the image is
	 * mutable then this will take a snapshot of the image and use that
	 * snapshot instead of the normal image.
	 *
	 * A new snapshot is always taken when the post command is called.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	public void setLabel(String __l)
	{
		throw new todo.TODO();
	}
	
	public void setListener(NotificationListener __nl)
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public class NotificationException
	extends RuntimeException
{
	public NotificationException()
	{
	}
	
	public NotificationException(String __s)
	{
		super(__s);
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/NotificationListener.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface NotificationListener
{
	void notificationDismissed(Notification __n);
	
	void notificationSelected(Notification __n);
	
	void notificationTimeout(Notification __n);
}

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

package javax.microedition.lcdui;

public final class NotificationType
{
	public static final NotificationType CALL =
		new NotificationType(null, null);
	
	public static final NotificationType EMAIL =
		new NotificationType(null, null);
	
	public static final NotificationType IM =
		new NotificationType(null, null);
	
	public static final NotificationType MMS =
		new NotificationType(null, null);
	
	public static final NotificationType REMINDER =
		new NotificationType(null, null);
	
	public static final NotificationType SMS =
		new NotificationType(null, null);
	
	public NotificationType(String __dl, Image __di)
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public class ScalableImage
	extends Image
{
	ScalableImage()
	{
		throw new todo.TODO();
	}
	
	public final int getViewportHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getViewportWidth()
	{
		throw new todo.TODO();
	}
	
	public final void setHeight(int __h, boolean __mar)
	{
		throw new todo.TODO();
	}
	
	public final void setWidth(int __w, boolean __mar)
	{
		throw new todo.TODO();
	}
	
	public final void unbind()
	{
		throw new todo.TODO();
	}
	
	public static ScalableImage bind(Object __esi)
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

/**
 * This is the base class for all user interactable displays.
 *
 * It is only recommended to change the screen contents when it is not being
 * displayed.
 *
 * @since 2017/02/28
 */
public abstract class Screen
	extends Displayable
{
	/**
	 * Initializes the base screen.
	 *
	 * @since 2017/02/28
	 */
	Screen()
	{
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Spacer.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Spacer
	extends Item
{
	public Spacer(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Commands are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void addCommand(Command __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2l Cannot add commands for spacers.}
		throw new IllegalStateException("EB2l");
	}
	
	/**
	 * Commands are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void setDefaultCommand(Command __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2m Cannot set the default command for
		// spacers.}
		throw new IllegalStateException("EB2m");
	}
	
	/**
	 * Labels are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void setLabel(String __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2n Cannot set labels for spacers.}
		throw new IllegalStateException("EB2n");
	}
	
	public void setMinimumSize(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.phoneui.StandardMetrics;

public class StringItem
	extends Item
{
	/** Apperance mode. */
	final int _amode;
	
	/** The item text. */
	volatile String _text;
	
	/** The font to use. */
	volatile Font _font;
	
	/**
	 * Initializes the string item with the plain style.
	 *
	 * @param __l The label.
	 * @param __t The text.
	 * @since 2019/05/17
	 */
	public StringItem(String __l, String __t)
	{
		this(__l, __t, Item.PLAIN);
	}
	
	/**
	 * Initializes the string item with the plain style.
	 *
	 * @param __l The label.
	 * @param __t The text.
	 * @param __am The appearance mode.
	 * @throws IllegalArgumentException If the appearance mode is not valid.
	 * @since 2019/05/17
	 */
	public StringItem(String __l, String __t, int __am)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB2o The appearance mode is not valid.
		// (The appearance mode)}
		if (__am != Item.PLAIN && __am != Item.BUTTON && __am != Item.HYPERLINK)
			throw new IllegalArgumentException("EB2o " + __am);
		
		this._text = __t;
		this._amode = __am;
	}
	
	public int getAppearanceMode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font used to draw the item.
	 *
	 * @return The font used to draw the item.
	 * @since 2019/12/09
	 */
	public Font getFont()
	{
		Font rv = this._font;
		return (rv == null ? StandardMetrics.itemLabelFont() : rv);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/09
	 */
	@Override
	public int getMinimumHeight()
	{
		// Empty string needs no space
		String text = this.getText();
		if (text == null)
			return 0;
		
		return this.getFont().getHeight();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/09
	 */
	@Override
	public int getMinimumWidth()
	{
		// Empty string needs no space
		String text = this.getText();
		if (text == null)
			return 0;
		
		return this.getFont().stringWidth(text);
	}
	
	/**
	 * Returns the text content of this item.
	 *
	 * @return The text content.
	 * @since 2019/12/09
	 */
	public String getText()
	{
		return this._text;
	}
	
	public void setFont(Font __a)
	{
		throw new todo.TODO();
	}
	
	public void setText(String __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

/**
 * This interface is used as a callback when there has been a change to the
 * tabbed pane such as which screen has been made visible or ones which were
 * added or removed.
 *
 * @since 2018/03/29
 */
public interface TabListener
{
	/**
	 * This is called to specify that the given tab along with the screen
	 * has been added to the tabbed pane.
	 *
	 * @param __i The index where insertion is to occur.
	 * @param __tab The screen that was added to the tabbed pane.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	void tabAddedEvent(int __i, Screen __tab);
	
	/**
	 * This indicates when a new tab has been focused and will indicate the
	 * screen which now has focus.
	 *
	 * @param __tab The tab which now has focus.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	void tabChangeEvent(Screen __tab);
	
	/**
	 * This is called after a tab has been removed and only specifies the
	 * index of that tab.
	 *
	 * @param __i The tab that has been removed.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	void tabRemoveEvent(int __i);
}

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

package javax.microedition.lcdui;

public class TabbedPane
	extends Screen
{
	public TabbedPane(String __title, boolean __stringtab, boolean __suptitle)
	{
		throw new todo.TODO();
	}
	
	public void addTab(Screen __t, Image __i)
	{
		throw new todo.TODO();
	}
	
	public void addTabListener(TabListener __tl)
	{
		throw new todo.TODO();
	}
	
	public int getCount()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public Screen getScreen(int __i)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedIndex()
	{
		throw new todo.TODO();
	}
	
	public Image getTabIcon(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public void insertTab(int __i, Screen __t, Image __img)
	{
		throw new todo.TODO();
	}
	
	public void removeTab(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setFocus(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setTabIcon(int __i, Image __icon)
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public final class TableLayoutPolicy
	extends FormLayoutPolicy
{
	public TableLayoutPolicy(Form __f, int __cols)
	{
		super(__f);
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/07
	 */
	@Override
	protected void doLayout(int __vpx, int __vpy, int __vpw,
		int __vph, int[] __ts)
	{
		throw new todo.TODO();
	}
	
	public int getColumns()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/07
	 */
	@Override
	protected Item getTraverse(Item __i, int __dir)
	{
		throw new todo.TODO();
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Text.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.common.TextStorage;

/**
 * This text class is one which handles all of the text metrics and drawing and
 * such. It handles different fonts, colors, and styles on a per character
 * basis and performs all the needed operations to support text drawing.
 *
 * The color defaults to {@code Display.getColor(Display.COLOR_FOREGROUND)}.
 *
 * @since 2018/11/29
 */
public class Text
{
	public static final int ALIGN_CENTER =
		1;
	
	public static final int ALIGN_DEFAULT =
		4;
	
	public static final int ALIGN_JUSTIFY =
		3;
	
	public static final int ALIGN_LEFT =
		0;
	
	public static final int ALIGN_RIGHT =
		2;
	
	public static final int DIRECTION_LTR =
		10;
	
	public static final int DIRECTION_NEUTRAL =
		12;
	
	public static final int DIRECTION_RTL =
		11;
	
	/** Storage for the text. */
	private final TextStorage _storage =
		new TextStorage();
	
	/** The width. */
	private int _width;
	
	/** The height. */
	private int _height;
	
	/** The default font. */
	private Font _defaultfont =
		Font.getDefaultFont();
	
	/** The default foreground color. */
	private int _defaultcolor =
		CommonColors.DEFAULT_TEXT_COLOR;
	
	/** The background color. */
	private int _backgroundcolor =
		CommonColors.DEFAULT_TEXT_BACKGROUND_COLOR;
	
	/** The alignment. */
	private int _alignment;
	
	/** The caret position. */
	private int _caret =
		-1;
	
	/** The required display height, is cached. */
	private int _requiredheight;
	
	/** The required line count, is cached. */
	private int _requiredlines;
	
	/** Space above each line. */
	private int _spaceabove;
	
	/** Space below each line. */
	private int _spacebelow;
	
	/** The alignment of each line. */
	private int _align;
	
	/** Indentation. */
	private int _indentation;
	
	/** The direction of the text. */
	private int _direction = Text.DIRECTION_NEUTRAL;
	
	/** Scrolling offset (scrolled up by n pixels). */
	private int _scrolloffset;
	
	/** The highlight index. */
	private int _highlightdx =
		-1;
	
	/** The highlight length. */
	private int _highlightlen =
		0;
	
	/** Does character placement have to be updated. */
	private boolean _dirty;
	
	/**
	 * Initializes the text with no width or height.
	 *
	 * @since 2018/11/29
	 */
	public Text()
	{
		this("", 0, 0);
	}
	
	/**
	 * Initializes the text with the given width and height.
	 *
	 * @param __c The text to use.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalArgumentException If the width or height are negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public Text(String __c, int __w, int __h)
		throws IllegalArgumentException, NullPointerException
	{
		this(__c, 0, __c.length(), __w, __h);
	}
	
	/**
	 * Initializes the text with the given width and height.
	 *
	 * @param __c The text to use.
	 * @param __o The offset.
	 * @param __l The length.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalArgumentException If the width or height are negative.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public Text(String __c, int __o, int __l, int __w, int __h)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length())
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error EB2p The width and height cannot be negative
		// for text.}
		if (__w < 0 || __h < 0)
			throw new IllegalArgumentException("EB2p");
		
		// Set sizes first
		this._width = __w;
		this._height = __h;
		
		// Insert all of the text
		this.insert(0, __c.substring(__o, __o + __l));
	}
	
	/**
	 * Deletes the specified text.
	 *
	 * @param __i The index to start deletion at.
	 * @param __l The number of characters to delete.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/02
	 */
	public void delete(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Perform the delete
		this._storage.delete(__i, __l);
		
		// Deleting nothing?
		if (__l <= 0)
			return;
		
		// Mark dirty
		this._dirty = true;
		
		// Adjust the caret?
		int caret = this._caret;
		if (caret > __i)
			this._caret = caret - Math.max(__l - (caret - __i), __l);
	}
	
	/**
	 * Returns the alignment of the text.
	 *
	 * @return The text alignment.
	 * @since 2018/12/02
	 */
	public int getAlignment()
	{
		return this._alignment;
	}
	
	/**
	 * Returns the background color.
	 *
	 * @return The background color.
	 * @since 2018/12/02
	 */
	public int getBackgroundColor()
	{
		return this._backgroundcolor;
	}
	
	/**
	 * Returns the caret position.
	 *
	 * @return The caret position or {@code -1} if it is not used.
	 * @since 2018/12/02
	 */
	public int getCaret()
	{
		return this._caret;
	}
	
	/**
	 * Returns the extents of the given character.
	 *
	 * @param __i The character to get.
	 * @param __ext The extents of the character: x, y, width, height.
	 * @throws IllegalArgumentException If the extend array has a length less
	 * than four.
	 * @throws IndexOutOfBoundsException If the character index is out of
	 * bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public void getCharExtent(int __i, int[] __ext)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__ext == null)
			throw new NullPointerException("NARG");
			
		// Update
		if (this._dirty)
			this.__undirty();
		
		// Need to extract the character and font to determine the width and
		// the height of it
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Default font?
		Font font = storage.font[__i];
		if (font == null)
			font = this._defaultfont;
		
		// Set extents, the width and height come from the character data
		try
		{
			__ext[0] = storage.x[__i];
			__ext[1] = storage.y[__i];
			__ext[2] = font.charWidth(storage.chars[__i]);
			__ext[3] = font.getHeight();
		}
		catch (IndexOutOfBoundsException e)
		{
			// {@squirreljme.error EB2q Extent array length must at least
			// be 4.}
			if (__ext.length < 4)
				throw new IllegalArgumentException("EB2q");
		}
	}
	
	public int getCharIndex(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default font.
	 *
	 * @return The default font.
	 * @since 2018/12/01
	 */
	public Font getFont()
	{
		return this._defaultfont;
	}
	
	/**
	 * Returns the font which is used by the given character.
	 *
	 * @param __i The index of the character to get.
	 * @return The font for the given index.
	 * @throws IndexOutOfBoundsException If the index it outside of bounds.
	 * @since 2018/12/01
	 */
	public Font getFont(int __i)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Only if a font is set
		Font rv = storage.font[__i];
		if (rv != null)
			return rv;
		return this._defaultfont;
	}
	
	/**
	 * Returns the default foreground color.
	 *
	 * @return The default foreground color.
	 * @since 2018/12/02
	 */
	public int getForegroundColor()
	{
		return this._defaultcolor;
	}
	
	/**
	 * Gets the foreground color for a character.
	 *
	 * @param __i The character to get.
	 * @return The color for that character.
	 * @since 2018/12/01
	 */
	public int getForegroundColor(int __i)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Zero means that the default color is to be used
		int rv = storage.color[__i];
		if (rv != 0)
			return rv;
		return this._defaultcolor;
	}
	
	/**
	 * Returns the height of the text.
	 *
	 * @return The height of the text.
	 * @since 2018/12/01
	 */
	public int getHeight()
	{
		return this._height;
	}
	
	/**
	 * Returns the highlight index.
	 *
	 * @return The highlight index or {@code -1} if none.
	 * @since 2018/12/02
	 */
	public int getHighlightIndex()
	{
		return this._highlightdx;
	}
	
	/**
	 * Returns the length of highlighted characters.
	 *
	 * @return The number of characters highlighted, {@code 0} if none.
	 * @since 2018/12/02
	 */
	public int getHighlightLength()
	{
		return this._highlightlen;
	}
	
	/**
	 * Returns the current indentation.
	 *
	 * @return The indentation.
	 * @since 2018/12/02
	 */
	public int getIndent()
	{
		return this._indentation;
	}
	
	/**
	 * Returns the initial direction.
	 *
	 * @return The initial direction.
	 * @since 2018/12/02
	 */
	public int getInitialDirection()
	{
		return this._direction;
	}
	
	/**
	 * Returns the height which is required to completely display all of the
	 * text within.
	 *
	 * @return The required height to draw.
	 * @since 2018/12/01
	 */
	public int getRequiredHeight()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		return this._requiredheight;
	}
	
	/**
	 * Returns the number of lines which are required to display all of the
	 * text within.
	 *
	 * @return The number of lines which are required.
	 * @since 2018/12/01
	 */
	public int getRequiredLineCount()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		return this._requiredlines;
	}
	
	/**
	 * Returns the scroll offset.
	 *
	 * @return The scroll offset.
	 * @since 2018/12/02
	 */
	public int getScrollOffset()
	{
		return this._scrolloffset;
	}
	
	/**
	 * Returns the space above each line.
	 *
	 * @return The space above.
	 * @since 2018/12/02
	 */
	public int getSpaceAbove()
	{
		return this._spaceabove;
	}
	
	/**
	 * Returns the space below each line.
	 *
	 * @return The space below.
	 * @since 2018/12/02
	 */
	public int getSpaceBelow()
	{
		return this._spacebelow;
	}
	
	/**
	 * Returns the text contained within this object.
	 *
	 * @param __i The starting index.
	 * @param __l The length.
	 * @return The string for the text.
	 * @throws IndexOutOfBoundsException If the index and/or length exceed
	 * the text bounds.
	 * @since 2018/12/01
	 */
	public String getText(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// {@squirreljme.error EB2r Text outside of bounds. (The starting
		// index; The ending index; The size of the text)}
		int size = storage.size;
		if (__i < 0 || __l < 0 || (__i + __l) > size)
			throw new IndexOutOfBoundsException(
				String.format("EB2r %d %d %d", __i, __l, size));
		
		// Create string from it
		return new String(storage.chars, __i, __l);
	}
	
	/**
	 * Returns the length of this text object.
	 *
	 * @return The length of the text object.
	 * @since 2018/12/01
	 */
	public int getTextLength()
	{
		return this._storage.size;
	}
	
	/**
	 * Returns the width of this text.
	 *
	 * @return The text width.
	 * @since 2018/12/01
	 */
	public int getWidth()
	{
		return this._width;
	}
	
	/**
	 * Inserts the given string at the position.
	 *
	 * @param __i The index to insert at, the index is always forced within
	 * the bounds of the buffer (negative values are inserted at zero and
	 * positions greater than the size are inserted at the end).
	 * @param __s The stirng to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public void insert(int __i, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Ignore adding empty strings as there is no purpose to it
		if (__s.isEmpty())
			return;
		
		// The index is always in the bounds of the storage
		TextStorage storage = this._storage;
		if (__i < 0)
			__i = 0;
		else if (__i > storage.size)
			__i = storage.size;
		
		// Insert space to store the characters
		int sn = __s.length();
		storage.insert(__i, sn);
		
		// Set character data here
		char[] chars = storage.chars;
		for (int i = 0; i < sn; i++)
			chars[__i++] = __s.charAt(i);
		
		// Adjust the caret?
		int caret = this._caret;
		if (caret >= 0 && __i < caret)
			this._caret = caret + sn;
		
		// Becomes dirty
		this._dirty = true;
	}
	
	public int lastRenderedIndex()
	{
		throw new todo.TODO();
	}
	
	public void moveCaret(int __nl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the alignment of the text.
	 *
	 * @param __a If the alignment is not valid.
	 * @throws IllegalArgumentException If the alignment is not valid.
	 * @since 2018/12/02
	 */
	public void setAlignment(int __a)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2s Invalid alignment. (The alignment)}
		if (__a != Text.ALIGN_LEFT && __a != Text.ALIGN_CENTER && __a != Text.ALIGN_RIGHT &&
			__a != Text.ALIGN_JUSTIFY && __a != Text.ALIGN_DEFAULT)
			throw new IllegalArgumentException("EB2s " + __a);
		
		this._alignment = __a;
	}
	
	/**
	 * Sets the background color.
	 *
	 * @param __argb The color to use.
	 * @since 2018/12/02
	 */
	public void setBackgroundColor(int __argb)
	{
		this._backgroundcolor = __argb;
	}
	
	/**
	 * Sets the position of the caret.
	 *
	 * @param __i The position to use, {@code -1} clears the caret
	 * @throws IndexOutOfBoundsException If the caret is outside of the
	 * text bounds.
	 * @since 2018/12/02
	 */
	public void setCaret(int __i)
		throws IndexOutOfBoundsException
	{
		// Clear it
		if (__i == -1)
		{
			this._caret = -1;
			return;
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the default font to use when no font has been specified.
	 *
	 * @param __f The default font to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public void setFont(Font __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// If this is the same font, just ignore it
		Font olddefaultfont = this._defaultfont;
		if (__f.equals(olddefaultfont))
			return;
		
		// Changing the font becomes dirty since we need to measure the
		// metrics again
		this._defaultfont = __f;
		this._dirty = true;
	}
	
	/**
	 * Sets the font at the given positions.
	 *
	 * @param __f The font to set, {@code null} clears.
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the given range is out of bounds.
	 * @since 2018/12/02
	 */
	public void setFont(Font __f, int __i, int __l)
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		int size = storage.size;
		if (__i < 0 || __l < 0 || __i >= size || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		Font[] font = storage.font;
		for (int i = 0; i < __l; i++)
			font[__i++] = __f;
		
		// Is dirty now
		this._dirty = true;
	}
	
	/**
	 * Sets the default foreground color to use when drawing.
	 *
	 * @param __argb The color to use.
	 * @since 2018/12/01
	 */
	public void setForegroundColor(int __argb)
	{
		// This does not dirty anything because it is just a color change,
		// nothing needs to be recomputed
		this._defaultcolor = __argb;
	}
	
	/**
	 * Sets the color at the given positions.
	 *
	 * @param __argb The ARGB color, zero removes the color.
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the given range is out of bounds.
	 * @since 2018/12/02
	 */
	public void setForegroundColor(int __argb, int __i, int __l)
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		int size = storage.size;
		if (__i < 0 || __l < 0 || __i >= size || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		int[] color = storage.color;
		for (int i = 0; i < __l; i++)
			color[__i++] = __argb;
		
		// Is dirty now
		this._dirty = true;
	}
	
	/**
	 * Sets the height of the text.
	 *
	 * @param __h The new height.
	 * @throws IllegalArgumentException If the height is negative.
	 * @since 2018/12/01
	 */
	public void setHeight(int __h)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2t The height of a font cannot be
		// negative.}
		if (__h < 0)
			throw new IllegalArgumentException("EB2t");
		
		// Just set the height, we do not need to clear the dirty bit because
		// as long as the requiredheight is still within the height the text
		// fits
		this._height = __h;
	}
	
	/**
	 * Sets the highlight position.
	 *
	 * @param __i The starting index, {@code -1} clears the highlight.
	 * @param __l The number of characters to highlight.
	 * @throws IndexOutOfBoundsException If the index and/or length are out
	 * of bounds.
	 */
	public void setHighlight(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Clear it
		if (__i == -1)
		{
			this._highlightdx = -1;
			this._highlightlen = 0;
			return;
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the indentation.
	 *
	 * @param __i The indentation.
	 * @since 2018/12/02
	 */
	public void setIndent(int __i)
	{
		this._indentation = __i;
	}
	
	/**
	 * Sets the initial direction.
	 *
	 * @param __dir The initial direction.
	 * @throws IllegalArgumentException If the direction is not valid.
	 * @since 2018/12/02
	 */
	public void setInitialDirection(int __dir)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2u The direction to use. (The direction)}
		if (__dir != Text.DIRECTION_LTR && __dir != Text.DIRECTION_RTL &&
			__dir != Text.DIRECTION_NEUTRAL)
			throw new IllegalArgumentException("EB2u " + __dir);
		
		this._direction = __dir;
	}
	
	/**
	 * Sets the scroll offset.
	 *
	 * @param __o The offset.
	 * @since 2018/12/02
	 */
	public void setScrollOffset(int __o)
	{
		this._scrolloffset = __o;
	}
	
	/**
	 * Sets the space above each line.
	 *
	 * @param __sa The space above in pixels.
	 * @since 2018/12/02
	 */
	public void setSpaceAbove(int __sa)
	{
		this._spaceabove = __sa;
	}
	
	/**
	 * Sets the space below each line.
	 *
	 * @param __sb The space below in pixels.
	 * @since 2018/12/02
	 */
	public void setSpaceBelow(int __sb)
	{
		this._spacebelow = __sb;
	}
	
	/**
	 * Sets the width of this text to the specified width.
	 *
	 * @param __w The width to set.
	 * @throws IllegalArgumentException If the width is negative.
	 * @since 2018/11/30
	 */
	public void setWidth(int __w)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2v Cannot set the width to a negative value.}
		if (__w < 0)
			throw new IllegalArgumentException("EB2v");
		
		// Ignore on no changes
		int oldwidth = this._width;
		if (__w == oldwidth)
			return;
		
		// Set and mark dirty
		this._width = __w;
		this._dirty = true;
	}
	
	/**
	 * Returns whether all of the text fits within the bounds of the box.
	 *
	 * @return If all of the text fits within the bounds of the box.
	 * @since 2018/12/01
	 */
	public boolean textFits()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		// The text will fit if the height needed to display everything is at
		// or below the height of the actual box. This is to make height
		// changes not require a recalculate.
		return this._requiredheight <= this._height;
	}
	
	/**
	 * Undirties the text within and calculates all of the needed bounds and
	 * metrics for each character.
	 *
	 * @since 2018/12/01
	 */
	private final void __undirty()
	{
		if (!this._dirty)
			return;
		
		// Using this gobal stuff
		Font defaultfont = this._defaultfont;
		int width = this._width;
		int height = this._height;
		int spaceabove = this._spaceabove;
		int spacebelow = this._spacebelow;
		int align = this._align;
		int indentation = this._indentation;
		int direction = this._direction;
		int scrolloffset = this._scrolloffset;
		
		// If the direction is neutral, this just becomes the locale default
		// For now just treat it as LTR
		if (direction == Text.DIRECTION_NEUTRAL)
			direction = Text.DIRECTION_LTR;
		
		// Are we going right to left?
		boolean dortl = (direction == Text.DIRECTION_RTL);
		
		// Will use this storage stuff
		TextStorage storage = this._storage;
		char[] chars = storage.chars;
		Font[] font = storage.font;
		short[] cx = storage.x;
		short[] cy = storage.y;
		
		// The starting Y position is 
		// The starting X and Y position is always zero, when other alignments
		// and such are used they are calculated when the line ends
		// X is offset by the indentation and Y is offset by the scrolling
		int y = -scrolloffset + spaceabove,
			nexty = y;
		
		// X starts with indentation, but that might be modified in right
		// to left mode
		int x = (dortl ? width : indentation),
			startx = x;
		
		// Cache parameters of font
		Font lastfont = null;
		int fontheight = 0,
			fontascent = 0,
			fontdescent = 0;
		
		// For the end of line calculator, these are the indexes which are
		// used for each character
		int linedxstart = 0,
			linedxend = 0;
			
		// Redo handling of the current character, this will happen if
		// the line overflows
		boolean redo = false;
		
		// Go through and calculate every character line by line, carefully
		// handling alignment and justification
		// The line height is calculated so that if different fonts of
		// different sizes are on the same line, they all are on the baseline
		int linecount = 0,
			linemaxheight = 0,
			linemaxascent = 0,
			linemaxdescent = 0;
		for (int i = 0, n = storage.size; i <= n; i++)
		{
			// Since we need to handle line indentation, justification and
			// otherwise we need a flag to know when the next line was hit
			// to calculate
			// But the last character always has line stuff done to handle the
			// final alignment/directions and such
			// For now only the X positions are considered because
			boolean donextline = (i == n),
				wasnewlinech = false;
			if (!donextline)
			{
				// Need the character and font here, for metrics
				char ch = chars[i];
				Font f = font[i];
				if (f == null)
					f = defaultfont;
				
				// Font has changed?
				if (lastfont != f)
				{
					// Cache parameters
					fontheight = f.getHeight();
					fontascent = f.getAscent();
					fontdescent = f.getDescent();
					
					// Keep track so we do not need to update every time
					lastfont = f;
					
					// Properties of the line changed due to the font?
					// Cache them and check here accordingly
					if (fontascent > linemaxascent)
						linemaxascent = fontascent;
					if (fontheight > linemaxheight)
						linemaxheight = fontheight;
					if (fontdescent > linemaxdescent)
						linemaxdescent = fontdescent;
				}
				
				// Ignore carriage returns
				if (ch == '\r')
					continue;
				
				// Newlines do go to the next line, if a newline was detected
				// then the X position will be set to indentation, otherwise
				// zero.
				else if (ch == '\n')
				{
					donextline = true;
					wasnewlinech = true;
					
					// Clear a redo
					redo = false;
				}
				
				// Draw every other character
				else
				{
					// Get the properties of this character
					int chw = f.charWidth(ch);
					
					// Calculate draw position and the next X position
					// accordingly
					int dx, nx;
					if (dortl)
					{
						dx = x - chw;
						nx = dx;
					}
					else
					{
						dx = x;
						nx = x + chw;
					}
					
					// Character is still within the bounds?
					// Additionally if the X coordinate is at the start and
					// cannot even fit in the width just force it to be
					// placed
					if ((nx >= 0 && nx <= width) ||
						(x <= startx && x + chw <= width))
					{
						// Store current X position, this may change due to
						// right to left mode
						cx[i] = (short)dx;
						
						// Next character will be here
						x = nx;
						
						// Store the ascent of the character in the Y slot,
						// this is later used at end of line handler to
						// correctly place each character on the baseline
						cy[i] = (short)fontascent;
						
						// Clear a redo
						redo = false;
					}
					
					// Character exceeds the bounds, need to redo and handle
					// end of line
					else
					{
						// Redo should not be triggered twice, so just
						// clear it and never bother again
						if (redo)
						{
							redo = false;
							continue;
						}
						
						donextline = true;
						redo = true;
					}
				}
			}
			
			// End of line reached, handle alignment, justification, etc.
			// Perform any position updates as needed
			if (donextline)
			{
				// The line ends on this index (this is either strlen, a
				// newline, or a character placed on a newline so this is
				// always going to be exclusive)
				linedxend = i;
				
				// The next Y position is going to be the max font height
				// for this line.
				// An extra space above is only added if this was a newline,
				// so that way the next line has the actual space above
				nexty = y + linemaxheight + spacebelow +
					(wasnewlinech ? spaceabove : 0);
				
				// Calculate the correct Y position for each character
				for (int q = linedxstart; q < linedxend; q++)
				{
					// Get the original ascent of the character
					int origascent = cy[q];
					
					// The Y position is just the difference in space between
					// the line's max ascent and the character's actual ascent
					cy[q] = (short)(y + (linemaxascent - origascent));
				}
				
				// Handle non-default alignments
				if ((dortl && align != Text.ALIGN_RIGHT) ||
					(!dortl && align != Text.ALIGN_LEFT))
				{
					throw new todo.TODO();
				}
				
				// A line was here so the line count goes up
				linecount++;
				
				// If redoing this character, decrement i so that way it
				// negates the loop increment
				if (redo)
					i--;
				
				// The new start index
				linedxstart = i + 1;
				
				// Set the previously calculated Y position
				y = nexty;
				
				// Move X back
				x = startx;
			}
		}
		
		// Update other needed parameters
		// The required height is our nexty because either at the end or
		// a newline this will always be set
		this._requiredheight = nexty;
		this._requiredlines = linecount;
			
		// Has been updated, no longer dirty
		this._dirty = false;
	}
}

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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;

public class TextBox
	extends Screen
{
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	/**
	 * Initializes the text box.
	 *
	 * @param __title The title of the text box.
	 * @param __text The initial text in the box
	 * @param __max The maximum number of characters which may be specified in
	 * the text box.
	 * @param __con The constraints of the text box.
	 * @throws IllegalArgumentException See the exceptions for
	 * {@link EditableText#initialize(String, int, int)}.
	 * @since 2017/10/20
	 */
	public TextBox(String __title, String __text, int __max, int __con)
		throws IllegalArgumentException
	{
		// Set title if there is one
		if (__title != null)
			this.setTitle(__title);
		
		// Initialize editor with the given set of values
		this._editabletext.initialize(__text, __max, __con);
	}
	
	public void delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getChars(char[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	public void insert(char[] __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void insert(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaret(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setChars(char[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setConstraints(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setHighlight(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __a)
	{
		throw new todo.TODO();
	}
	
	public int setMaxSize(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setString(String __a)
	{
		throw new todo.TODO();
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;

public class TextEditor
	extends CanvasItem
{
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	public TextEditor(String __text, int __maxsz, int __cons, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	public void delete(int __o, int __l)
	{
		throw new todo.TODO();
	}
	
	public int getBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	public int getContentHeight()
	{
		throw new todo.TODO();
	}
	
	public boolean getFocus()
	{
		throw new todo.TODO();
	}
	
	public Font getFont()
	{
		throw new todo.TODO();
	}
	
	public int getForegroundColor()
	{
		throw new todo.TODO();
	}
	
	public int getHighlightColor()
	{
		throw new todo.TODO();
	}
	
	public int getLineMarginHeight()
	{
		throw new todo.TODO();
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getSelection()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public boolean getVisible()
	{
		throw new todo.TODO();
	}
	
	public int getVisibleContentPosition()
	{
		throw new todo.TODO();
	}
	
	public void insert(String __t, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setBackgroundColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaretPosition(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setConstraints(int __cons)
	{
		throw new todo.TODO();
	}
	
	public void setFocus(boolean __f)
	{
		throw new todo.TODO();
	}
	
	public void setFont(Font __f)
	{
		throw new todo.TODO();
	}
	
	public void setForegroundColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setHighlightColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __cs)
	{
		throw new todo.TODO();
	}
	
	public int setMaxSize(int __sz)
	{
		throw new todo.TODO();
	}
	
	public void setSelection(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setString(String __s)
	{
		throw new todo.TODO();
	}
	
	public void setTextEditorListener(TextEditorChangeListener __cl)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __v)
	{
		throw new todo.TODO();
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

public interface TextEditorChangeListener
{
	int ACTION_CARET_MOVE =
		4;
	
	int ACTION_CONTENT_CHANGE =
		1;
	
	int ACTION_DIRECTION_CHANGE =
		64;
	
	int ACTION_INPUT_MODE_CHANGE =
		128;
	
	int ACTION_LANGUAGE_CHANGE =
		256;
	
	int ACTION_TRAVERSE_NEXT =
		16;
	
	int ACTION_TRAVERSE_PREVIOUS =
		8;
	
	void inputAction(TextEditor __e, int __act);
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/TextField.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;

/**
 * This represents a field of editable or read-only text which may be placed
 * within a form.
 *
 * If constraints are used within the text field then the representation of
 * the text may change according to the constraints. Note that the character
 * size limits may hinder valid values to be constrained.
 *
 * @since 2017/08/20
 */
public class TextField
	extends Item
{
	/** This is a constraint which has no limitations. */
	public static final int ANY =
		0;
	
	/**
	 * This mask is used to split the constraint between the type and any
	 * flags which may be used.
	 */
	public static final int CONSTRAINT_MASK =
		65535;
	
	/**
	 * This constraint is used to specify that the value represents currency
	 * and that when it is drawn it will be rendered as the currency for the
	 * system's current locale.
	 *
	 * Value requirements are exactly the same as {@link #DECIMAL}.
	 */
	public static final int CURRENCY =
		6;
	
	/**
	 * This constraint is used to specify that the value represents a decimal
	 * value and the field value is required to be matching.
	 *
	 * For the actual value in the decimal field, it may only contain digits,
	 * a minus sign {@code -}, and the decimal point {@code .}.
	 *
	 * When rendering the value, the number will be formatted to the current
	 * system's locale.
	 */
	public static final int DECIMAL =
		5;
	
	/**
	 * A constraint which specifies that an e-mail address is being entered.
	 */
	public static final int EMAILADDR =
		1;
	
	/**
	 * This is a constraint flag which hints that the start of a sentence
	 * should start with a capital letter.
	 */
	public static final int INITIAL_CAPS_SENTENCE =
		2097152;
	
	/**
	 * This is a constraint flag which hints that the start of every word
	 * should be capitalized.
	 */
	public static final int INITIAL_CAPS_WORD =
		1048576;
	
	/**
	 * This is a constraint flags which indicates that what is to be input
	 * will not be found in common dictionaries for the system.
	 *
	 * An example usage for this, would be user names for accounts which might
	 * not match dictionary words.
	 */
	public static final int NON_PREDICTIVE =
		524288;
	
	/**
	 * This is a constraint which requires that only an integer value is used,
	 * the integer itself matches that of {@code int}. As such only digits and
	 * the minus sign {@code -} are permitted.
	 *
	 * The value will be presented in the system's current locale.
	 */
	public static final int NUMERIC =
		2;
	
	/**
	 * This is a constriant flag which masks any input character with a
	 * special symbol to obscure them with. This should be used for passwords
	 * and PIN numbers.
	 *
	 * If this is used then {@link #NON_PREDICTIVE} and {@link #SENSITIVE} are
	 * implicitely set along with {@link #INITIAL_CAPS_SENTENCE} and
	 * {@link #INITIAL_CAPS_WORD} are impliticely cleared.
	 */
	public static final int PASSWORD =
		65536;
	
	/**
	 * This is a constraint which allows input for a phone number.
	 *
	 * If a phone book is available then access to the phonebook to input a
	 * number automatically may be used when applicable.
	 *
	 * When rendered the value may be represented in a more friendly fashion
	 * depending on the phone number.
	 */
	public static final int PHONENUMBER =
		3;
	
	/**
	 * This is a constraint flag which specifies that the given text should
	 * never be stored into a dictionary for predictive and auto-completion
	 * uses. A social-security number or credit card number for example is
	 * something which is considered sensitive.
	 *
	 * On some systems with predictive text, typing in words that are not in
	 * the dictionary will often add them to the dictionary so that they can
	 * become available to learn new words. This prevents this behavior.
	 */
	public static final int SENSITIVE =
		262144;
	
	/**
	 * This is a constraint flag which specifies that the text field cannot
	 * be edited.
	 */
	public static final int UNEDITABLE =
		131072;
	
	/** This is a consraint which specifies that a URL is being inserted. */
	public static final int URL =
		4;
	
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	/**
	 * Initializes the text field.
	 *
	 * If the implementation does not support the specified number of
	 * characters then the input string will be truncated and no exception
	 * will be thrown provided the input is still valid.
	 *
	 * @param __l The label of the field.
	 * @param __t The text to initially set the field to,
	 * see {@link #setString(String)}.
	 * @param __ms The maximum amount of characters in the field,
	 * see {@link #setMaxSize(int)}.
	 * @param __c The constraints of the field,
	 * see {@link #setConstraints(int)}.
	 * @throws IllegalArgumentException If the maximum size is zero or less;
	 * the constraints is not valid; the text is not valid; or the text
	 * exceeds the maximum specified characters.
	 * @since 2017/08/19
	 */
	public TextField(String __l, String __t, int __ms, int __c)
		throws IllegalArgumentException
	{
		// Standard item properties
		this.setLabel(__l);
		
		// Initialize text area
		this._editabletext.initialize(__t, __ms, __c);
	}
	
	public void delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getChars(char[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public void insert(char[] __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void insert(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaret(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setChars(char[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the constraints for this field according to the constraints which
	 * are available. If the current value is not valid under the constraints
	 * to be set then it is cleared.
	 *
	 * @param __c The constraints to set.
	 * @throws IllegalArgumentException If the input constraints are not
	 * valid.
	 * @since 2017/08/20
	 */
	public void setConstraints(int __c)
		throws IllegalArgumentException
	{
		this._editabletext.setConstraints(__c);
	}
	
	public void setHighlight(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the maximum size of the text field, if the value is larger than
	 * this value then it will be truncated.
	 *
	 * @param __ms The number of characters that can be placed in the field.
	 * @return The actual maximum capacity, this may be smaller than the
	 * input value.
	 * @throws IllegalArgumentException If the maximum size is not a non-zero
	 * positive value or if the value would not be valid after truncation if
	 * constraints are used.
	 * @since 2017/08/19
	 */
	public int setMaxSize(int __ms)
		throws IllegalArgumentException
	{
		return this._editabletext.setMaxSize(__ms);
	}
	
	/**
	 * Sets the value of the text field.
	 *
	 * @param __s The value to set, if {@code null} then an empty string is
	 * used.
	 * @throws IllegalArgumentException If the input string is not within
	 * the constraints or character count limitations.
	 * @since 2017/08/20
	 */
	public void setString(String __s)
		throws IllegalArgumentException
	{
		this._editabletext.setString(__s);
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}

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

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;

/**
 * A ticker contains an infinitely scrolling message.
 *
 * Any {@link Displayable} may have tickers associated with them in which
 * they will be shown at the top of the screen accordingly. As such these can
 * be used to convey information as needed.
 *
 * @since 2018/03/26
 */
public class Ticker
{
	/** Displayables this ticker is attached to. */
	final __VolatileList__<Displayable> _displayables =
		new __VolatileList__<>();
	
	/** The text used. */
	volatile String _text;
	
	/**
	 * Initializes the ticker with the given string.
	 *
	 * @param __s The string to use for the ticker.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/26
	 */
	public Ticker(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Use internal title set
		this._text = __s;
	}
	
	/**
	 * Returns the string which is currently being displayed in the ticker.
	 *
	 * @return The string contained within the ticker.
	 * @since 2018/03/26
	 */
	public String getString()
	{
		return this._text;
	}
	
	/**
	 * Sets the string that is displayed within the ticker.
	 *
	 * @param __s The string to use for the ticker.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/26
	 */
	public void setString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set new
		this._text = __s;
		
		// Find a displayable which is showing this
		boolean isshown = false;
		for (Displayable di : this._displayables)
		{
			Display d = di._display;
			if (d != null)
				isshown = true;
		}
		
		// If this is being shown, then force the view to repaint
		UIState.getInstance().repaint();
	}
}


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

package javax.microedition.lcdui;

/**
 * This represents the base for an action which may be given a label, an
 * image, and could be enabled or disabled.
 *
 * @since 2018/03/31
 */
abstract class __Action__
{
	/** The image used. */
	volatile Image _image;
	
	/** The short label. */
	volatile String _shortlabel;
	
	/** The long label. */
	volatile String _longlabel;
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e If the parent is enabled or disabled.
	 * @since 2018/04/01
	 */
	abstract void onParentEnabled(boolean __e);
}

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

package javax.microedition.lcdui;

/**
 * This is a package public mutable class which represents single choices
 * within anything which uses choices.
 *
 * @since 2017/08/20
 */
final class __ChoiceEntry__
{
	/** The string to display for this choice. */
	volatile String _string;
	
	/** The image to display for this choice. */
	volatile Image _image;
	
	/** The font to use for this choice. */
	volatile Font _font;
	
	/** Is this entry selected? */
	volatile boolean _selected;
	
	/** Is this item disabled (is enabled by default)? */
	volatile boolean _disabled;
	
	/**
	 * Initializes a choice entry with default values.
	 *
	 * @param __s The string to display.
	 * @param __i The image to display.
	 * @since 2017/08/20
	 */
	__ChoiceEntry__(String __s, Image __i)
	{
		// Set
		this._string = __s;
		this._image = __i;
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/__GfxIPCDispatch__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 javax.microedition.lcdui;

import cc.squirreljme.jvm.IPCCallback;

/**
 * This is the graphics IPC handler which dispatches any events to the
 * appropriate widgets and such.
 *
 * @since 2019/12/28
 */
@Deprecated
class __GfxIPCDispatch__
	implements IPCCallback
{
	/** The instance of this. */
	private static __GfxIPCDispatch__ _INSTANCE;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Creates an instance of this class.
	 *
	 * @return The class instance.
	 * @since 2019/12/28
	 */
	static final __GfxIPCDispatch__ __instance()
	{
		__GfxIPCDispatch__ rv = __GfxIPCDispatch__._INSTANCE;
		if (rv == null)
			__GfxIPCDispatch__._INSTANCE = (rv = new __GfxIPCDispatch__());
		return rv;
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/__VolatileList__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/**
 * This is a list which is volatile but not synchronized but is backed by an
 * array, the array which as it is managed should always be atomic. So any
 * operation which returns an array should return one which is valid and
 * cannot be changed. If it is out of date then it is just out of date.
 *
 * The list is backed by an array.
 *
 * @param <T> The type of values to store.
 * @since 2018/11/17
 */
final class __VolatileList__<T>
	implements Iterable<T>
{
	/** The values in the list. */
	private volatile Object[] _values =
		new Object[0];
	
	/**
	 * Adds the specified value but only if it is a unique object reference
	 * in this list.
	 *
	 * @param __v The value to add.
	 * @since 2018/11/17
	 */
	public final void addUniqueObjRef(T __v)
	{
		Object[] values = this._values;
		
		// Already in the list? Do nothing
		for (Object v : values)
			if (v == __v)
				return;
		
		// Otherwise append
		this.append(__v);
	}
	
	/**
	 * Append the specified element to the list.
	 *
	 * @param __v The value to add.
	 * @return The index of this entry.
	 * @since 2018/11/17
	 */
	public final int append(T __v)
	{
		Object[] values = this._values;
		
		// Copy the array to increase the length
		int n = values.length;
		values = Arrays.<Object>copyOf(values, n + 1);
		
		// Store new value
		values[n] = __v;
		
		// Use this new array
		this._values = values;
		
		// Return the index of this entry
		return n;
	}
	
	/**
	 * Clears the list.
	 *
	 * @since 2018/11/17
	 */
	public final void clear()
	{
		this._values = new Object[0];
	}
	
	/**
	 * Gets the element at the given index.
	 *
	 * @param __i The index to get.
	 * @return The element.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/09
	 */
	@SuppressWarnings({"unchecked"})
	public final T get(int __i)
		throws IndexOutOfBoundsException
	{
		// Is this in bounds?
		Object[] values = this._values;
		if (__i < 0 || __i >= values.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		return (T)values[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final Iterator<T> iterator()
	{
		return (Iterator<T>)
			((Object)(Arrays.<Object>asList(this._values).iterator()));
	}
	
	/**
	 * Removes the specified item from the list.
	 *
	 * @param __v The item to remove.
	 * @return {@code true} if it was removed.
	 * @since 2019/04/15
	 */
	@SuppressWarnings({"unchecked"})
	public final boolean remove(T __v)
	{
		Object[] values = this._values;
		
		// Check if we have this item first
		int dx = 0, n = values.length;
		for (; dx < n; dx++)
		{
			Object t = values[dx];
			
			// No match
			if ((__v == null) != (t == null) || !Objects.equals(t, __v))
				continue;
			
			// Stop
			break;
		}
		
		// No match
		if (dx >= n)
			return false;
		
		// Setup new array and copy all elements before and after
		Object[] newvalues = new Object[n - 1];
		for (int i = 0; i < dx; i++)
			newvalues[i] = values[i];
		for (int i = dx + 1, o = dx; i < n; i++, o++)
			newvalues[o] = values[i];
			
		// Use this new array
		this._values = newvalues;
		
		// Was changed
		return true;
	}
	
	/**
	 * Returns the number of values.
	 *
	 * @return The number of values stored.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this._values.length;
	}
	
	/**
	 * Converts the values to an array of the specific type.
	 *
	 * @param __ov The output array.
	 * @return The output array, may be recreated if too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	@SuppressWarnings({"unchecked"})
	public final T[] toArray(T[] __ov)
		throws NullPointerException
	{
		if (__ov == null)
			throw new NullPointerException("NARG");
		
		// Get input values
		Object[] iv = this._values;
		int in = iv.length;
		
		// Too short of an array? Grow it
		int on = __ov.length;
		if (on < in)
			__ov = Arrays.<T>copyOf(__ov, in);
		
		// Copy values
		for (int i = 0; i < in; i++)
			__ov[i] = (T)iv[i];
		
		// And use the passed or recreated array
		return __ov;
	}
	
	/**
	 * Returns the values in the list.
	 *
	 * @return The list values.
	 * @since 2018/11/18
	 */
	public final Object[] values()
	{
		return this._values;
	}
	
	/**
	 * Returns the values in this list as a list.
	 *
	 * @return The list of values.
	 * @since 2018/12/09
	 */
	@SuppressWarnings({"unchecked"})
	public final List<T> valuesAsList()
	{
		return (List<T>)Arrays.<Object>asList(this._values);
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/game/GameCanvas.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.ForwardingGraphics;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public abstract class GameCanvas
	extends Canvas
{
	public static final int DOWN_PRESSED =
		64;
	
	public static final int FIRE_PRESSED =
		256;
	
	public static final int GAME_A_PRESSED =
		512;
	
	public static final int GAME_B_PRESSED =
		1024;
	
	public static final int GAME_C_PRESSED =
		2048;
	
	public static final int GAME_D_PRESSED =
		4096;
	
	public static final int LEFT_PRESSED =
		4;
	
	public static final int RIGHT_PRESSED =
		32;
	
	public static final int UP_PRESSED =
		2;
	
	/** Forwarding graphics target, since they draw to the same buffer. */
	private final ForwardingGraphics _forwardgfx =
		new ForwardingGraphics();
	
	/** Are game keys being suppressed?. */
	private volatile boolean _suppressgamekeys;
	
	/** Is the buffer preserved after a flush? */
	private volatile boolean _preservebuffer;
	
	/** The A buffer. */
	private volatile __Buffer__ _bufa;
	
	/** The B buffer. */
	private volatile __Buffer__ _bufb;
	
	/**
	 * Initializes the game canvas.
	 *
	 * The buffer is preserved by default.
	 *
	 * @param __supke If {@code true} then game key events are suppressed.
	 * @since 2016/10/08
	 */
	protected GameCanvas(boolean __supke)
	{
		this(__supke, true);
	}
	
	/**
	 * Initializes the game canvas.
	 *
	 * It may be an optimization if key events are suppressed if a canvas is
	 * only needed to draw and not receive user input. The only key events
	 * that are suppressed are game keys.
	 *
	 * @param __supke If {@code true} then game key events are suppressed.
	 * @param __preservebuf If {@code true} then the buffer is preserved after
	 * a flush, otherwise if {@code false} the buffer data will be undefined.
	 * @see Canvas
	 * @since 2016/10/08
	 */
	protected GameCanvas(boolean __supke, boolean __preservebuf)
	{
		// Set
		this._suppressgamekeys = __supke;
		this._preservebuffer = __preservebuf;
	}
	
	/**
	 * Flushes the full off-screen buffer to the display.
	 *
	 * @since 2017/02/08
	 */
	public void flushGraphics()
	{
		// Do nothing if this is not on a display
		if (this.getCurrentDisplay() == null)
			return;
		
		// Flip!
		this.__flip();
	}
	
	/**
	 * Flushes the specified off-screen buffer area to the display.
	 *
	 * @param __x The X position.
	 * @param __y The Y position.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalStateException If the buffer is preserved.
	 * @since 2017/02/28
	 */
	public void flushGraphics(int __x, int __y, int __w, int __h)
		throws IllegalStateException
	{
		// Nothing to flush
		if (__w <= 0 || __h <= 0)
			return;
		
		// Do nothing if this is not on a display
		if (this.getCurrentDisplay() == null)
			return;
		
		// {@squirreljme.error EB2w Cannot flush the graphics if the buffer
		// is not preserved.}
		if (!this._preservebuffer)
			throw new IllegalStateException("EB2w");
		
		// Flip!
		this.__flip();
	}
	
	/**
	 * This returns the off-screen buffer that is used by the game canvas to
	 * draw.
	 *
	 * @return The graphics object for the off-screen buffer.
	 * @since 2016/10/10
	 */
	protected Graphics getGraphics()
	{
		// Draw into the B buffer
		__Buffer__ buf = this._bufb;
		
		// Get device size
		int dw = this.getWidth(),
			dh = this.getHeight();
		
		// Force device size into bounds
		if (dw < 1)
			dw = 1;
		if (dh < 1)
			dh = 1;
		
		// Get buffer size
		int bw, bh;
		if (buf != null)
		{
			bw = buf._width;
			bh = buf._height;
		}
		else
			bw = bh = 0;
		
		// Recreate the buffer?
		if (buf == null || bw != dw || bh != dh)
		{
			// Create buffer
			buf = new __Buffer__(dw, dh);
			
			// Store buffer state
			this._bufb = buf;
		}
		
		// Create graphics to wrap it, alpha is not used!
		return new AdvancedGraphics(buf._pixels, false, null,
			dw, dh, dw, 0, 0, 0);
	}
	
	public int getKeyStates()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void paint(Graphics __g)
	{
		// Whatever is in the A buffer is drawn
		__Buffer__ buf = this._bufa;
		if (buf == null)
			return;
			
		// The fastest way to draw onto the screen is to do a direct draw
		// from the RGB pixel data
		int pw = buf._width;
		__g.drawRGB(buf._pixels, 0, pw, 0, 0, pw, buf._height, false);
	}
	
	/**
	 * Performs the graphics flip.
	 *
	 * @return The flipped graphics.
	 * @since 2019/06/30
	 */
	private final void __flip()
	{
		// Get both buffers
		__Buffer__ bufa = this._bufa,
			bufb = this._bufb;
		
		// If never drawn onto, ignore
		if (bufb == null)
			return;
		
		// Get buffer size
		int bw = bufb._width,
			bh = bufb._height;
		
		// Create buffer to copy to
		if (bufa == null || bufa._width != bw && bufa._height != bh)
		{
			bufa = new __Buffer__(bw, bh);
			this._bufa = bufa;
		}
		
		// Copy pixel data (use System since it may be a memory copy)
		System.arraycopy(bufb._pixels, 0,
			bufa._pixels, 0, bw * bh);
		
		// Signal and wait for refresh
		super.repaint(0, 0, bw, bh);
		super.serviceRepaints();
	}
	
	/**
	 * This represents a single buffer, since this class is double buffered.
	 *
	 * @since 2019/06/30
	 */
	private static final class __Buffer__
	{
		/** The buffer pixels. */
		final int[] _pixels;
		
		/** The width. */
		final int _width;
		
		/** The height. */
		final int _height;
		
		/**
		 * Initializes the buffer.
		 *
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/06/30
		 */
		__Buffer__(int __w, int __h)
		{
			this._width = (__w < 1 ? (__w = 1) : __w);
			this._height = (__h < 1 ? (__h = 1) : __h);
			this._pixels = new int[__w * __h];
		}
	}
}

Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/game/Layer.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;

public abstract class Layer
{
	Layer()
	{
		throw new todo.TODO();
	}
	
	public abstract void paint(Graphics __a);
	
	public final int getHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getWidth()
	{
		throw new todo.TODO();
	}
	
	public final int getX()
	{
		throw new todo.TODO();
	}
	
	public final int getY()
	{
		throw new todo.TODO();
	}
	
	public final boolean isVisible()
	{
		throw new todo.TODO();
	}
	
	public void move(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setPosition(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __a)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;

public class LayerManager
{
	public LayerManager()
	{
		throw new todo.TODO();
	}
	
	public void append(Layer __a)
	{
		throw new todo.TODO();
	}
	
	public Layer getLayerAt(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSize()
	{
		throw new todo.TODO();
	}
	
	public void insert(Layer __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void paint(Graphics __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void remove(Layer __a)
	{
		throw new todo.TODO();
	}
	
	public void setViewWindow(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
}


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

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Sprite
	extends Layer
{
	public static final int TRANS_MIRROR =
		2;
	
	public static final int TRANS_MIRROR_ROT180 =
		1;
	
	public static final int TRANS_MIRROR_ROT270 =
		4;
	
	public static final int TRANS_MIRROR_ROT90 =
		7;
	
	public static final int TRANS_NONE =
		0;
	
	public static final int TRANS_ROT180 =
		3;
	
	public static final int TRANS_ROT270 =
		6;
	
	public static final int TRANS_ROT90 =
		5;
	
	public Sprite(Image __a)
	{
		throw new todo.TODO();
	}
	
	public Sprite(Image __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public Sprite(Sprite __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(Image __a, int __b, int __c, boolean 
		__d)
	{
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(Sprite __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(TiledLayer __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	public void defineCollisionRectangle(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void defineReferencePixel(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final int getFrame()
	{
		throw new todo.TODO();
	}
	
	public int getFrameSequenceLength()
	{
		throw new todo.TODO();
	}
	
	public int getRawFrameCount()
	{
		throw new todo.TODO();
	}
	
	public int getRefPixelX()
	{
		throw new todo.TODO();
	}
	
	public int getRefPixelY()
	{
		throw new todo.TODO();
	}
	
	public void nextFrame()
	{
		throw new todo.TODO();
	}
	
	@Override
	public final void paint(Graphics __a)
	{
		throw new todo.TODO();
	}
	
	public void prevFrame()
	{
		throw new todo.TODO();
	}
	
	public void setCollisionAlpha(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFrame(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFrameSequence(int[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setRefPixelPosition(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setTransform(int __a)
	{
		throw new todo.TODO();
	}
}


Added modules/midp-lcdui/src/main/java/javax/microedition/lcdui/game/TiledLayer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class TiledLayer
	extends Layer
{
	public TiledLayer(int __a, int __b, Image __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public int createAnimatedTile(int __a)
	{
		throw new todo.TODO();
	}
	
	public void fillCells(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public int getAnimatedTile(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getCell(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final int getCellHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getCellWidth()
	{
		throw new todo.TODO();
	}
	
	public final int getColumns()
	{
		throw new todo.TODO();
	}
	
	public final int getRows()
	{
		throw new todo.TODO();
	}
	
	@Override
	public final void paint(Graphics __a)
	{
		throw new todo.TODO();
	}
	
	public void setAnimatedTile(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCell(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setStaticTileSet(Image __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
}


Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/monospace-12.sqf.__mime.



















































































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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 monospace-12.sqf
DAkDAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAQEBAQEBAAEAAAACgoAAAAAAAAAAAAACgofCgoKHwoK
AAAABA4VBQ4UFBUOBAAAEhUKCAQCChUJAAAADBIBAQIFFQkeAAAABAQAAAAA
AAAAAAAADAICAgICAgIMAAAABggICAgICAgGAAAAFQ4fDhUAAAAAAAAAAAAA
BAQfBAQAAAAAAAAAAAAAAAAMCAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAMAAAA
ABAQCAgEBAICAAAADhERFRUVEREOAAAABwQEBAQEBAQfAAAADhEQCAQCAQEf
AAAADhEQEA4QEBEOAAAAERERER8QEBAQAAAAHwEBDxAQEBEOAAAAHgEBAQ8R
EREOAAAAHxAQCAgEBAICAAAADhEREQ4REREOAAAADhERER4QEBAQAAAAAAAA
DAwAAAAMDAAAAAAADAwAAAAMCAAAABAIBAIECBAAAAAAAAAAAA4ADgAAAAAA
AAIECBAIBAIAAAAADhEQEAgEBAAEAAAADhEVFRUVHQEeAAAADhERER8RERER
AAAADxEREQ8REREPAAAAHgEBAQEBAQEeAAAADxEREREREREPAAAAHwEBAQcB
AQEfAAAAHwEBAQcBAQEBAAAAHgEBAR0REREOAAAAERERER8RERERAAAAHAgI
CAgICAgcAAAAEBAQEBAQEREOAAAAEREJBQMFCRERAAAAAQEBAQEBAQEfAAAA
GxUVERERERERAAAAERMTFRUVGRkRAAAADhEREREREREOAAAADxEREQ8BAQEB
AAAADhERERERFQkWAAAADxEREQ8JERERAAAADhEBAQ4QEBEOAAAAHwQEBAQE
BAQEAAAAEREREREREREOAAAAEREREREREhQYAAAAEREREREVFRUKAAAAEREK
BAQKERERAAAAERERCgQEBAQEAAAAHxAQCAQCAQEfAAAADgICAgICAgIOAAAA
AAEBAgIEBAgIAAAADggICAgICAgOAAAABAoRAAAAAAAAAAAAAAAAAAAAAAAf
AAAABAgAAAAAAAAAAAAAAAAAAA4REREuAAAAAQEBAQ8REREPAAAAAAAAABwC
AgIcAAAAEBAQEB4REREeAAAAAAAAAA4RDwEeAAAAABgEBA4EBAQEAAAAAAAA
AB4REREeEA8AAAEBAQ8RERERAAAAAAAEAAQEBAQEAAAAAAAIAAgICAgIBAAA
AAEBEREPERERAAAAAAQEBAQEBAQEAAAAAAAAAA8VFRUVAAAAAAAAAA8RERER
AAAAAAAAAA4REREOAAAAAAAAAA8REREPAQEAAAAAAB4REREeEBAAAAAAABwC
AgICAAAAAAAAAB4BDhAPAAAAAAAEBA4EBAQYAAAAAAAAABEREREOAAAAAAAA
ABEREhQYAAAAAAAAABERFRUKAAAAAAAAABEKBAoRAAAAAAAAABERER4QEA8A
AAAAAB8IBAIfAAAACAQEBAIEBAQIAAAACAgICAgICAgIAAAAAgQEBAgEBAQC
AAAAABYJAAAAAAAAAAAADB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAIAAgICAgICAgAAAAACBwKCgocCAAAGAQE
BA4EBAQeAAAADBICDwIPAhIMAAAAEREKBAQOBA4EAAAACgQeAQEOEBAPAAAA
HgEDDREWGBAPAAAACgQAABwCDBAOAAAADhEdExMTHREOAAAABAoKFAAeAAAA
AAAAACgUCgUKFCgAAAAAAAAAAB4QAAAAAAAAAAAAAA4AAAAAAAAAHiEnKycr
KyEeAAAAHgAAAAAAAAAAAAAACBQIAAAAAAAAAAAAAAAEBB8EBB8AAAAAHBAc
BBwAAAAAAAAAHBAYEBwAAAAAAAAACgQfEAgEAgEfAAAAAAAAAAAREREPAQEA
FhcXFhQUFBQUAAAAAAAAAAwMAAAAAAAACgQAAB4QDAIeAAAADAgIHAAAAAAA
AAAACBQIABwAAAAAAAAAAAUKFCgUCgUAAAAAHgUFBQ0FBQUeAAAAAAAAABoV
DQUaAAAAChEREQoEBAQEAAAAAAAEAAQEAgEREQ4AAgQADhERHxERAAAACAQA
DhERHxERAAAABAoADhERHxERAAAAFgkADhERHxERAAAACgAADhERHxERAAAA
BAoEDhERHxERAAAAHgUFBQ8FBQUdAAAAAB4BAQEBAQEeBAYAAgQAHgIOAgIe
AAAABAIAHgIOAgIeAAAABAoAHgIOAgIeAAAACgAAHgIOAgIeAAAAAgQABAQE
BAQEAAAACAQABAQEBAQEAAAABAoABAQEBAQEAAAACgAABAQEBAQEAAAADhIS
EhcSEhIOAAAAFgkAExMVFRkZAAAAAgQADhEREREOAAAACAQADhEREREOAAAA
BAoADhEREREOAAAAFgkADhEREREOAAAACgAADhEREREOAAAAAAAAEQoEChEA
AAAADhkZFRUVExMOAAAAAgQAEREREREOAAAACAQAEREREREOAAAABAoAERER
EREOAAAACgAAEREREREOAAAACAQAEREKBAQEAAAAAQEPERERDwEBAAAADhER
CQUJERENAAAAAAIEAA4REREuAAAAAAgEAA4REREuAAAAAAQKAA4REREuAAAA
ABYJAA4REREuAAAAAAAKAA4REREuAAAABAoEAA4REREuAAAAAAAAAAsUDgUa
AAAAAAAAAB4BAQEeBAYAAAQIABwSDgIcAAAAABAIABwSDgIcAAAAAAgUABwS
DgIcAAAAAAAUABwSDgIcAAAAAAACBAAEBAQEAAAAAAAIBAAEBAQEAAAAAAAE
CgAEBAQEAAAAAAAACgAEBAQEAAAAAAAYBwoREREOAAAAAAAWCQAPERERAAAA
AAAECAAMEhIMAAAAAAAIBAAMEhIMAAAAAAAECgAMEhIMAAAAAAAUCgAMEhIM
AAAAAAAAFAAMEhIMAAAAAAAABAAOAAQAAAAAAAAAAA4ZFRMOAAAAAAACBAAR
EREOAAAAAAAIBAAREREOAAAAAAAECgAREREOAAAAAAAACgAREREOAAAAAAAI
BAAREREeEA8AAAABAQ8REREPAQEAAAAACgAREREeEA8A
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/monospace-16.sqf.__mime.










































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 monospace-16.sqf
EA0DAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAIHDZrb293fzYcCAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAICAgICAgIAAAIAAAAAAAAZmZEAAAAAAAAAAAAAAAAAAAA
JCR+JCQkfiQkAAAAAAg+SQkJCT5ISEk+CAAAAAAAAABDIxAIBGJhAAAAAAAA
AAAAHiEBAgRKUSFeAAAAAAAICAAAAAAAAAAAAAAAAAAAIBAIBAQEBAQIECAA
AAAAAAQIECAgICAgEAgEAAAAAAAqHD4cKgAAAAAAAAAAAAAAAAAAAAgIPggI
AAAAAAAAAAAAAAAAAAAAABAQCAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAA
AAAAGBgAAAAAAEBAICAQEAgIBAQCAAAAAAA+QUFBSUlJQUFBPgAAAAAADwgI
CAgICAgICH8AAAAAAH9AQEBAfwEBAQF/AAAAAAB/QEBAQHxAQEBAfwAAAAAA
QUFBQUF/QEBAQEAAAAAAAH8BAQEBf0BAQEB/AAAAAAB/AQEBAX9BQUFBfwAA
AAAAf0BAQEBAQEBAQEAAAAAAAH9BQUFBf0FBQUF/AAAAAAB/QUFBQX9AQEBA
QAAAAAAAAAAAGBgAAAAAGBgAAAAAAAAAABgYAAAAABgYEAAAAAAgEAgEAgQI
ECAAAAAAAAAAAAAAAAA+AD4AAAAAAAAAAAIECBAgEAgEAgAAAAAAAAA8QkBA
OAgICAAIAAAAAAAAfkFdVVVVVVV9AX4AAAAAAD5BQUFBf0FBQUFBAAAAAAAf
IUFBQT9BQUFBPwAAAAAAPkFBAQEBAQEBQT4AAAAAAB8hQUFBQUFBQUE/AAAA
AAB/AQEBAQ8BAQEBfwAAAAAAfwEBAQEPAQEBAQEAAAAAAD5BAQEBAXlBQUE+
AAAAAABBQUFBQX9BQUFBQQAAAAAAfwgICAgICAgICH8AAAAAAEBAQEBAQEBB
QSIcAAAAAABBIREJBQMFCREhQQAAAAAAAQEBAQEBAQEBAX8AAAAAAEFjY1VV
SUlBQUFBAAAAAABBQ0NFRUlJUVFhYQAAAAAAHCJBQUFBQUFBIhwAAAAAAB8h
QUFBIR8BAQEBAAAAAAAcIkFBQUFBQVEiXIAAAAAAHyFBQUEhHyFBQUEAAAAA
AD5BAQEBPkBAQEE+AAAAAAB/CAgICAgICAgICAAAAAAAQUFBQUFBQUFBIhwA
AAAAAEFBQUFBQUFBIhQIAAAAAABBQUFBQUFJSUlVIgAAAAAAQUEiFBQIFBQi
QUEAAAAAAEFBQSIUCAgICAgIAAAAAAB/QEAgEAgEAgEBfwAAAAAAPAQEBAQE
BAQEBDwAAAAAAAICBAQICBAQICBAAAAAAAA8ICAgICAgICAgPAAAAAgUAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAACBAAAAAAAAAAAAAAAAAAAAAA
AAAAAD5BQH5BYV4AAAAAAAEBAQE9Q0FBQUE/AAAAAAAAAAAAPkEBAQFBPgAA
AAAAQEBAQH5BQUFBQX4AAAAAAAAAAAA+QUE/AUE+AAAAAAB4BAQEHwQEBAQE
BAAAAAAAAAAAAHxCQUFBQX5AQT4AAAEBAQEfIUFBQUFBAAAAAAAAAAgADAgI
CAgIHAAAAAAAAAAQABAQEBAQEBAIBgAAAAEBAQFBIREPESEhAAAAAAAAGBAQ
EBAQEBAQOAAAAAAAAAAAADZJSUlJSUkAAAAAAAAAAAAeIUFBQUFBAAAAAAAA
AAAAHCJBQUEiHAAAAAAAAAAAAB4hQUFBQT8BAQEAAAAAAAAcIkFBQUF+QEBA
AAAAAAAAPUMBAQEBAQAAAAAAAAAAAD5BAT5AQT4AAAAAAAAICAg+CAgICAgw
AAAAAAAAAAAAQUFBQUFBPgAAAAAAAAAAAEFBQSIiFAgAAAAAAAAAAABBQUEq
KhQUAAAAAAAAAAAAQSIUCBQiQQAAAAAAAAAAAEFBQUFBQX5AIB8AAAAAAAB/
QCAYBgF/AAAAAAA4BAQEBAIEBAQEOAAAAAAACAgICAgICAgICAgAAAAAABwg
ICAgQCAgICAcAAAAAAAAAEY5AAAAAAAAAAAAAAAACBw2a29vd382HAgAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgICAgI
CAgAAAAAAAgIPkkJCQlJPggIAAAAOEQEBB4EBAQEBH4AAAAAADhEAgIPAg8C
AkQ4AAAAAABBQUEiFAg+CD4ICAAAABQIAD5BAQE+QEBAQT4AAAAAAAA8QgI8
QkI8QEI8AAAAAAAAFAgAPkEBPkBBPgAAAAAAHCJBWUVFRVlBIhwAAAAMEBwU
HAAcAAAAAAAAAAAAAAAAUCgUCgUKFChQAAAAAAAAAAAAAAA+ICAAAAAAAAAA
AAAAAAA8AAAAAAAAAAAAAAAcIkFdVU1VVUEiHAAAAD4AAAAAAAAAAAAAAAAA
AAAIFAgAAAAAAAAAAAAAAAAAAAAAAAgIPggIAD4AAAAAAAwQCAQcAAAAAAAA
AAAAAAAMEAgQDAAAAAAAAAAAAAAAFAgAf0BAIBAIBAIBfwAAAAAAAAAAAABB
QUFBQT8BAQAAAC4vLy8uKCgoKCgoAAAAAAAAAAAAGBgAAAAAAAAAAAAAABQI
AD8gGAYBAT8AAAAMCAgIHAAAAAAAAAAAAAAACBQIABwAAAAAAAAAAAAAAAAA
AAUKFChQKBQKBQAAAAAAAHwKCQkJOQkJCQp8AAAAAAAAAAAANklJOQlJNgAA
AAAUAEFBQSIUCAgICAgAAAAAAAAAAAgACAgGAQEBIR4ABAgAHCJBQUF/QUFB
QQAAABAIABwiQUFBf0FBQUEAAAAUABwiQUFBf0FBQUFBAAAAJhkAHCJBQUF/
QUFBQQAAAAAUABwiQUFBf0FBQUEAAAAIFAgcIkFBQX9BQUFBAAAAAAB4DAoJ
CT8JCQkJeQAAAAAAPEIBAQEBAQEBQjwIDAAECAB/AQEBHwEBAQF/AAAAEAgA
fwEBAR8BAQEBfwAAAAgUAH8BAQEfAQEBAX8AAAAAFAB/AQEBHwEBAQF/AAAA
BAgAfwgICAgICAgIfwAAABAIAH8ICAgICAgICH8AAAAIFAB/CAgICAgICAh/
AAAAABQAfwgICAgICAgIfwAAAAAAHyFBQUFHQUFBQT8AAAAmGQBBQ0VFSUlR
UWFhAAAABAgAHCJBQUFBQUEiHAAAABAIABwiQUFBQUFBIhwAAAAIFAAcIkFB
QUFBQSIcAAAAJhkAHCJBQUFBQUEiHAAAAAAUABwiQUFBQUFBIhwAAAAAAAAA
IhQIFCIAAAAAAAAAAABcIlFJSUlJSUUiHQAAAAQIAEFBQUFBQUFBIhwAAAAQ
CABBQUFBQUFBQSIcAAAACBQAQUFBQUFBQUEiHAAAAAAUAEFBQUFBQUFBIhwA
AAAQCABBQSIUCAgICAgIAAAAAAACAj5CQkI+AgICAgAAAAAADhEhIRkFOUFB
QT0AAAAAAAAECAA+QUB+QWFeAAAAAAAAEAgAPkFAfkFhXgAAAAAAAAgUAD5B
QH5BYV4AAAAAAAAsEgA+QUB+QWFeAAAAAAAAABQAPkFAfkFhXgAAAAAAAAgU
CBwiIDwiMiwAAAAAAAAAAAA2SUg+CUk2AAAAAAAAAAAAPEIBAQFCPAgMAAAA
AAQIAD5BQT8BQT4AAAAAAAAQCAA+QUE/AUE+AAAAAAAABAoAPkFBPwFBPgAA
AAAAAAAUAD5BQT8BQT4AAAAAAAAECAAMCAgICAg+AAAAAAAAEAgADAgICAgI
PgAAAAAAAAgUAAwICAgICD4AAAAAAAAUAAAMCAgICAg+AAAAAAAANgkUPkFB
QUFBPgAAAAAAACwSAB4hQUFBQUEAAAAAAAAECAA+QUFBQUE+AAAAAAAAEAgA
PkFBQUFBPgAAAAAAAAQIAD5BQUFBQT4AAAAAAAAECAA+QUFBQUE+AAAAAAAA
BAgAPkFBQUFBPgAAAAAAAAAIAD4ACAAAAAAAAAAAAAAAAABeIVFJRUI9AAAA
AAAAAAQIAEFBQUFBPgAAAAAAAAAIBABBQUFBQT4AAAAAAAAACBQAQUFBQUE+
AAAAAAAAABAIAEFBQUFBPgAAAAAAAAAQCABBQUFBQX5AQD8AAAABAQE9Q0FB
QUM9AQEBAAAAAAAUAEFBQUFBfkBAPw==
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/monospace-8.sqf.__mime.




























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 monospace-8.sqf
CAYCAQUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDhsVFxsOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAABAQEBAAEAAAKCgAAAAAAAAofCgofCgAABA4FDhQO
AAAACQwGAwkAAAYJAgUJFgAABAQAAAAAAAAEAgICAgQAAAQICAgIBAAAFQ4V
AAAAAAAAAAQOBAAAAAAAAAAABAQAAAAADgAAAAAAAAAAAAQAAAgEBAICAQAA
BgkNCwkGAAAGBAQEBA4AAA8IDwEBDwAADwgOCAgPAAAJCQ8ICAgAAA8BDwgI
DwAADwEPCQkPAAAPCAgICAgAAA8JDwkJDwAADwkPCAgIAAAAAAQAAAQAAAAA
BAAABAQAAAgEAgQIAAAAAA4ADgAAAAACBAgEAgAABgkIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAOAQEBAQ4AAAcJCQkJBwAADwEBBwEPAAAPAQEH
AQEAAA4BAQ0JBgAACQkJDwkJAAAOBAQEBA4AAAwICAgJBgAACQkFAwUJAAAB
AQEBAQ8AABEbFREREQAACQsLDQ0JAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAADgQEBAQEAAAJCQkJCQYAAAkJCQkKBAAAERER
ERUKAAAJCQkGCQkAAAkJCQYEBAAADwgIBgEPAAAOAgICAg4AAAECAgQECAAA
DggICAgOAAAEChEAAAAAAAAAAAAAHwAAAgQAAAAAAAAADwgPCQ4AAAEBBwkJ
BwAAAAAOAQEOAAAICA4JCQ4AAAAGCQ8BDgAAAA4CBwICAAAADgkJCQ4IBwAB
AQcJCQAABAAGBAQOAAAEAAQEBAQEAwABCQkHCQAABgQEBAQOAAAACxUVFRUA
AAAHCQkJCQAAAAYJCQkGAAAABwkJCQcBAQAOCQkJDggIAAYJAQEBAAAADgEG
CAcAAAACDgICDAAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAADgIDAwIOAAAEBAQEBAQAAAcEDAwEBwAAAAAWCQAA
AAAOGxUXGw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABAAEBAQEAAQOBQUOBAAMEgcCAh8AABwCBwcCHAAAEQoOBA4EAAAK
BgEGCAcAAA4BBgYIBwAACgQOAQ4HAAAOERUTFQ4AAAYOAA4AAAAAABQKBQoU
AAAAAA8IAAAAAAAADgAAAAAADhMVExUOAAAPAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAAGCAQCDgAAAAYIBggGAAAACgQPBAIPAAAAAAkJCQcBABYXFxYUFAAA
AAAGBgAAAAAKBA4IBg4AAAYEBAQOAAAABAoEAA4AAAAABQoUCgUAAB4FDQUF
HgAAAB4VHQUeAAAKEQoEBAQAAAACAAIBCQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAACgUGCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUFDwUdAAAOAQEBAQ4E
BgIEDwcBDwAABAIPBwEPAAACBQ8HAQ8AAAoADwcBDwAAAgQOBAQOAAAIBA4E
BA4AAAQKDgQEDgAACgAOBAQOAAAGCgsKCgYAABYJCQsNCQAAAgQGCQkGAAAE
AgYJCQYAAAIFBgkJBgAAFgkGCQkGAAAKAAYJCQYAAAAACgQKAAAABg0NCwsG
AAACBAkJCQYAAAQCCQkJBgAABAoJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAGCQUJEQ0AAAIEBgkJFgAABAIGCQkWAAAECgYJCRYAABYJBgkJFgAA
CgAGCQkWAAAGCQYJCRYAAAAAHhUNHgAAAAAOAQEOBAYCBA4JBw4AAAQCDgkH
DgAABAoGCQcOAAAKAAYJBw4AAAIEAAQEBAAACAQABAQEAAAECgAEBAQAAAAK
AAQEBAAACgUGDQkGAAAWCQYJCQkAAAIEBgkJBgAABAIGCQkGAAAECgYJCQYA
ABYJBgkJBgAACgAGCQkGAAAABAAfAAQAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAACgAACQkGAAAIBAAJCQ4IBwAAAQcJCQcBCgAACQkOCAc=
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/sansserif-12.sqf.__mime.























































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 sansserif-12.sqf
DAkDAgoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBwYKCAID
AwYEAwQDBQYGBgYGBgYGBgYDAwUEBQYHBgYGBgYGBgYCBgcGCAYGBgYGBgYG
BggGBgYEBQQGBAMGBgUGBQUGBgIDBgIKBgYGBgUGBAYGBgYGBgQCBAYKAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBwgGBgUHBAcFAwcF
BAQDAwcGBgQFBAQHCAgGBgYGBgYGBwgFBQUFBQMCAwMHBgYGBgYGBgcGBgYG
BgUIBgYGBgYGCAUFBQUFAwIDAwYGBQUFBQUEBgYGBgYGBwYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAABAAEAAQABAAEAAQAAAAEAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAA
AAAAAAAAEgASAD8AEgASABIAPwASABIAAAAAAAAABAAOABUABQAOABQAFAAV
AA4ABAAAAAAABgGJAEkAJgAQAMgAJAEiAcEAAAAAAAAADAASAAEAAQACAEUA
KQARAC4AAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgABAAEAAQAB
AAEAAQABAAIAAAAAAAAAAQACAAIAAgACAAIAAgACAAEAAAAAAAAAFQAOAB8A
DgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAcAAgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAMAAwAAAAAAAAAIAAgABAAEAAIAAgABAAEAAAAA
AAAADgARABEAFQAVABUAEQARAA4AAAAAAAAABwAEAAQABAAEAAQABAAEAB8A
AAAAAAAADgARABAACAAEAAIAAQABAB8AAAAAAAAADgARABAAEAAOABAAEAAR
AA4AAAAAAAAAEQARABEAEQAfABAAEAAQABAAAAAAAAAAHwABAAEADwAQABAA
EAARAA4AAAAAAAAAHgABAAEAAQAPABEAEQARAA4AAAAAAAAAHwAQABAACAAI
AAQABAACAAIAAAAAAAAADgARABEAEQAOABEAEQARAA4AAAAAAAAADgARABEA
EQAeABAAEAAQABAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAMAAwAAAAAAAAAA
AAAAAwADAAAAAAAAAAMAAgAAAAAAAAAIAAQAAgABAAIABAAIAAAAAAAAAAAA
AAAAAAAAAAAHAAAABwAAAAAAAAAAAAAAAAABAAIABAAIAAQAAgABAAAAAAAA
AAAADgARABAAEAAIAAQABAAAAAQAAAAAAAAAHgAhAC0ALQAtAC0APQABAD4A
AAAAAAAADgARABEAEQAfABEAEQARABEAAAAAAAAADwARABEAEQAPABEAEQAR
AA8AAAAAAAAAHgABAAEAAQABAAEAAQABAB4AAAAAAAAADwARABEAEQARABEA
EQARAA8AAAAAAAAAHwABAAEAAQAHAAEAAQABAB8AAAAAAAAAHwABAAEAAQAH
AAEAAQABAAEAAAAAAAAAHgABAAEAAQAdABEAEQARAA4AAAAAAAAAEQARABEA
EQAfABEAEQARABEAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAEAAQ
ABAAEAAQABAAEQARAA4AAAAAAAAAIQARAAkABQADAAUACQARACEAAAAAAAAA
AQABAAEAAQABAAEAAQABAB8AAAAAAAAAYwBVAEkAQQBBAEEAQQBBAEEAAAAA
AAAAEQATABMAFQAVABUAGQAZABEAAAAAAAAADgARABEAEQARABEAEQARAA4A
AAAAAAAADwARABEAEQAPAAEAAQABAAEAAAAAAAAADgARABEAEQARABEAFQAJ
ABYAAAAAAAAADwARABEAEQAPAAkAEQARABEAAAAAAAAADgARAAEAAQAOABAA
EAARAA4AAAAAAAAAHwAEAAQABAAEAAQABAAEAAQAAAAAAAAAEQARABEAEQAR
ABEAEQARAA4AAAAAAAAAEQARABEAEQARABEAEgAUABgAAAAAAAAAQQBBAEEA
QQBBAEkASQBJADYAAAAAAAAAEQARAAoABAAEAAoAEQARABEAAAAAAAAAEQAR
ABEACgAEAAQABAAEAAQAAAAAAAAAHwAQABAACAAEAAIAAQABAB8AAAAAAAAA
BwABAAEAAQABAAEAAQABAAcAAAAAAAAAAAABAAEAAgACAAQABAAIAAgAAAAA
AAAABwAEAAQABAAEAAQABAAEAAcAAAAAAAAABAAKABEAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAOABEAEQARAC4AAAAAAAAAAQABAAEAAQAPABEA
EQARAA8AAAAAAAAAAAAAAAAAAAAOAAEAAQABAA4AAAAAAAAAEAAQABAAEAAe
ABEAEQARAB4AAAAAAAAAAAAAAAAAAAAOAAkABwABAA4AAAAAAAAAAAAMAAIA
AgAHAAIAAgACAAIAAAAAAAAAAAAAAAAAAAAeABEAEQARAB4AEAAPAAAAAAAB
AAEAAQAPABEAEQARABEAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAAAAAAAA
AAAAAAIAAAACAAIAAgACAAIAAQAAAAAAAAABAAEAEQARAA8AEQARABEAAAAA
AAAAAAABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAD/ABEBEQERAREB
AAAAAAAAAAAAAAAAAAAPABEAEQARABEAAAAAAAAAAAAAAAAAAAAOABEAEQAR
AA4AAAAAAAAAAAAAAAAAAAAPABEAEQARAA8AAQABAAAAAAAAAAAAAAAeABEA
EQARAB4AEAAQAAAAAAAAAAAAAAAOAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAe
AAEADgAQAA8AAAAAAAAAAAAAAAIAAgAHAAIAAgACAAwAAAAAAAAAAAAAAAAA
AAARABEAEQARAA4AAAAAAAAAAAAAAAAAAAARABEAEgAUABgAAAAAAAAAAAAA
AAAAAAARABEAFQAVAAoAAAAAAAAAAAAAAAAAAAARAAoABAAKABEAAAAAAAAA
AAAAAAAAAAARABEAEQAeABAAEAAPAAAAAAAAAAAAAAAfAAgABAACAB8AAAAA
AAAABAACAAIAAgABAAIAAgACAAQAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AAAAAAAAAQACAAIAAgAEAAIAAgACAAEAAAAAAAAAAAAWAAkAAAAAAAAAAAAA
AAAAAAAAAAAAEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAQABAAAAAAAAAAAA
BAAOAAUABQAFAA4ABAAAAAAADAACAAIAAgAHAAIAAgACAA8AAAAAAAAAHAAi
AAIADwACAA8AAgAiABwAAAAAAAAAQQBBACIAFAAIABwACAAcAAgAAAAAAAAA
CgAEAB4AAQABAA4AEAAQAA8AAAAAAAAAHgABAAMADQARABYAGAAQAA8AAAAA
AAAACgAEAAAAAAAOAAEABgAIAAcAAAAAAAAAHgAhAC0AIwAjACMALQAhAB4A
AAAAAAAAAgAFAAUACgAAAA8AAAAAAAAAAAAAAAAAAAAoABQACgAFAAoAFAAo
AAAAAAAAAAAAAAAAAAAAAAAPAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAA
AAAAAAAAAAAAAAAAHgAhACcAKwAnACsAKwAhAB4AAAAAAAAADwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AgAHAAIAAAAHAAAAAAAAAAAAAwACAAMAAQADAAAAAAAAAAAAAAAAAAAAAwAC
AAMAAgADAAAAAAAAAAAAAAAAAAAACgAEAD8AEAAIAAQAAgABAD8AAAAAAAAA
AAAAAAAAAAAAABEAEQARAA8AAQABAAAAFgAXABcAFgAUABQAFAAUABQAAAAA
AAAAAAAAAAAAAAAGAAYAAAAAAAAAAAAAAAAACgAEAAAAAAAPAAgABgABAA8A
AAAAAAAAAwACAAIABwAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAAAAAA
AAAAAAAAAAAAAAAFAAoAFAAoABQACgAFAAAAAAAAAAAAfgAJAAkACQA5AAkA
CQAJAH4AAAAAAAAAAAAAAAAAAAB2AEkAOQAJAHYAAAAAAAAACgARABEAEQAK
AAQABAAEAAQAAAAAAAAAAAAAAAQAAAAEAAQAAgABABEAEQAOAAAAAgAEAAAA
DgARABEAHwARABEAAAAAAAAACAAEAAAADgARABEAHwARABEAAAAAAAAABAAK
AAAADgARABEAHwARABEAAAAAAAAAFgAJAAAADgARABEAHwARABEAAAAAAAAA
CgAAAAAADgARABEAHwARABEAAAAAAAAABAAKAAQADgARABEAHwARABEAAAAA
AAAAfAAKAAkACQA/AAkACQAJAHkAAAAAAAAAAAAOAAEAAQABAAEAAQABAA4A
BAAGAAAAAgAEAAAADwABAAcAAQABAA8AAAAAAAAABAACAAAADwABAAcAAQAB
AA8AAAAAAAAABAAKAAAADwABAAcAAQABAA8AAAAAAAAACgAAAAAADwABAAcA
AQABAA8AAAAAAAAAAQACAAAAAgACAAIAAgACAAIAAAAAAAAAAgABAAAAAQAB
AAEAAQABAAEAAAAAAAAAAgAFAAAAAgACAAIAAgACAAIAAAAAAAAABQAAAAAA
AgACAAIAAgACAAIAAAAAAAAAHgAiACIAIgAnACIAIgAiAB4AAAAAAAAAFgAJ
AAAAEwATABUAFQAZABkAAAAAAAAAAgAEAAAADgARABEAEQARAA4AAAAAAAAA
CAAEAAAADgARABEAEQARAA4AAAAAAAAABAAKAAAADgARABEAEQARAA4AAAAA
AAAAFgAJAAAADgARABEAEQARAA4AAAAAAAAACgAAAAAADgARABEAEQARAA4A
AAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAHgAxACkAKQAlACUAJQAj
AB4AAAAAAAAAAgAEAAAAEQARABEAEQARAA4AAAAAAAAACAAEAAAAEQARABEA
EQARAA4AAAAAAAAABAAKAAAAEQARABEAEQARAA4AAAAAAAAACgAAAAAAEQAR
ABEAEQARAA4AAAAAAAAACAAEAAAAEQARAAoABAAEAAQAAAAAAAAAAQABAAcA
CQAJAAkABwABAAEAAAAAAAAADgARABEACQAFAAkAEQARAA0AAAAAAAAAAAAC
AAQAAAAOABEAEQARAC4AAAAAAAAAAAAIAAQAAAAOABEAEQARAC4AAAAAAAAA
AAAEAAoAAAAOABEAEQARAC4AAAAAAAAAAAAWAAkAAAAOABEAEQARAC4AAAAA
AAAAAAAAAAoAAAAOABEAEQARAC4AAAAAAAAABAAKAAQAAAAOABEAEQARAC4A
AAAAAAAAAAAAAAAAAAA3AEgAPgAJAHYAAAAAAAAAAAAAAAAAAAAOAAEAAQAB
AA4ABAAGAAAAAAACAAQAAAAOAAkABwABAA4AAAAAAAAAAAAIAAQAAAAOAAkA
BwABAA4AAAAAAAAAAAAEAAoAAAAOAAkABwABAA4AAAAAAAAAAAAAAAoAAAAO
AAkABwABAA4AAAAAAAAAAAAAAAEAAgAAAAIAAgACAAIAAAAAAAAAAAAAAAIA
AQAAAAEAAQABAAEAAAAAAAAAAAAAAAIABQAAAAIAAgACAAIAAAAAAAAAAAAA
AAAABQAAAAIAAgACAAIAAAAAAAAAAAAAABgABwAKABEAEQARAA4AAAAAAAAA
AAAAABYACQAAAA8AEQARABEAAAAAAAAAAAAAAAIABAAAAAYACQAJAAYAAAAA
AAAAAAAAAAQAAgAAAAYACQAJAAYAAAAAAAAAAAAAAAIABQAAAAYACQAJAAYA
AAAAAAAAAAAAAAoABQAAAAYACQAJAAYAAAAAAAAAAAAAAAAACgAAAAYACQAJ
AAYAAAAAAAAAAAAAAAAAAgAAAAcAAAACAAAAAAAAAAAAAAAAAAAAAAAOABkA
FQATAA4AAAAAAAAAAAAAAAIABAAAABEAEQARAA4AAAAAAAAAAAAAAAgABAAA
ABEAEQARAA4AAAAAAAAAAAAAAAQACgAAABEAEQARAA4AAAAAAAAAAAAAAAAA
CgAAABEAEQARAA4AAAAAAAAAAAAAAAgABAAAABEAEQARAB4AEAAPAAAAAAAA
AAEAAQAHAAkACQAJAAcAAQABAAAAAAAAAAAACgAAABEAEQARAB4AEAAPAAAA
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/sansserif-16.sqf.__mime.





































































































































































































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
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
191
192
193
194
195
196
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 sansserif-16.sqf
EA0DAg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAIFCggNCwME
BQcHAwUDCAcHBwcHBwcHBwcEBAcFBwgKCQkJCQkJCAgCCAgICQkJCAkICAkJ
CQsJCwsFCAUFBQQHCAcICAcICAMECAMNCAgICAcIBggICQkICAYDBggNAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgcICAsIBwgJBQkHBgkH
BQcFBQsICAUIBQUHCgwLCAkJCQkJCQoJCAgICAMDAwMJCQkJCQkJBwkJCQkJ
CQcJBwcHBwcHCwcICAgIAwMDAwgICAgICAgHCAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAAACAAcAD4AIwBdgN/B54D/AHYAHAA
IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAQABAAEAAQABAAEAAQAAAAAAAQAAAAAAAAAFAAUAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAD/ACQAJAAkAP8AJAAkACQAAAAA
AAAABAAEAB4AJQAFAAUABQAeACQAJAAkACUAHgAEAAQAAAAAAAAADAQSAhIB
jABAACAAEAOIBIQEAgMBAAAAAAAAAAAAAAA8AEIAAgACAAQACAAUAKIAQQCh
AB4BAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BAACAAEAAQABAAEAAQABAAEAAgAEAAAAAAAAAAAAAAABAAIABAAEAAQABAAE
AAQABAACAAEAAAAAAAAAFQAOAB8ADgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAQABAAfAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAwACAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAAg
ACAAEAAQAAgACAAEAAQAAgACAAEAAAAAAAAAAAAAAA4AEQARABEAFQAVABUA
EQARABEADgAAAAAAAAAAAAAABwAEAAQABAAEAAQABAAEAAQABAAfAAAAAAAA
AAAAAAAOABEAEAAQABAACAAEAAIAAQABAB8AAAAAAAAAAAAAAA4AEQAQABAA
EAAOABAAEAAQABEADgAAAAAAAAAAAAAAEQARABEAEQARAB8AEAAQABAAEAAQ
AAAAAAAAAAAAAAAfAAEAAQABAA8AEAAQABAAEAARAA4AAAAAAAAAAAAAAB4A
AQABAAEAAQAPABEAEQARABEADgAAAAAAAAAAAAAAHwAQABAAEAAQABAAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAOABEAEQARABEADgARABEAEQARAA4AAAAAAAAA
AAAAAA4AEQARABEAEQAeABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAMAAwAA
AAAAAAAAAAAAAwADAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAADAAMA
AgAAAAAAAAAAAAAAEAAIAAQAAgABAAIABAAIABAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAA8AAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAEAAgAEAAgAEAAIAAQA
AgABAAAAAAAAAAAAAAAAAB4AIQAgACAAIAAYAAQABAAAAAAABAAAAAAAAAAA
AAAAfgCBAJkApQClAKUApQClAHkAAQD+AAAAAAAAAAAAAAAcACIAQQBBAEEA
fwBBAEEAQQBBAEEAAAAAAAAAAAAAAB8AIQBBAEEAIQAfACEAQQBBAEEAPwAA
AAAAAAAAAAAAPABCAAEAAQABAAEAAQABAAEAQgA8AAAAAAAAAAAAAAAfACEA
QQBBAEEAQQBBAEEAQQBBAD8AAAAAAAAAAAAAAH8AAQABAAEAAQAPAAEAAQAB
AAEAfwAAAAAAAAAAAAAAfwABAAEAAQABAA8AAQABAAEAAQABAAAAAAAAAAAA
AAAeACEAAQABAAEAAQA5ACEAIQAhAB4AAAAAAAAAAAAAACEAIQAhACEAIQA/
ACEAIQAhACEAIQAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAAA
AAAAAAAAAAAgACAAIAAgACAAIAAgACEAIQAiABwAAAAAAAAAAAAAACEAIQAR
AAkABQADAAUACQARACEAIQAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AQA/AAAAAAAAAAAAAABBAGMAYwBVAFUASQBJAEEAQQBBAEEAAAAAAAAAAAAA
AEEAQwBDAEUARQBJAEkAUQBRAGEAYQAAAAAAAAAAAAAAHAAiAEEAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAPABEAIQAhACEAEQAPAAEAAQABAAEAAAAA
AAAAAAAAABwAIgBBAEEAQQBBAEEAQQBRACIAXACAAAAAAAAAAAAADwARACEA
IQAhABEADwARACEAIQAhAAAAAAAAAAAAAAAeACEAAQABAAEAHgAgACAAIAAh
AB4AAAAAAAAAAAAAAH8ACAAIAAgACAAIAAgACAAIAAgACAAAAAAAAAAAAAAA
QQBBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAAAAAAABBAEEAQQBBAEEAQQBB
AEEAIgAUAAgAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBEQERAaoARAAAAAAA
AAAAAAAAQQBBACIAFAAUAAgAFAAUACIAQQBBAAAAAAAAAAAAAAABAQEBggBE
ACgAEAAQABAAEAAQABAAAAAAAAAAAAAAAP8BAAGAAEAAIAAQAAgABAACAAEA
/wEAAAAAAAAAAAAABwABAAEAAQABAAEAAQABAAEAAQAHAAAAAAAAAAAAAAAB
AAEAAgACAAQABAAIAAgAEAAQACAAAAAAAAAAAAAAAAcABAAEAAQABAAEAAQA
BAAEAAQABwAAAAAAAAACAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAAAAAAAQACAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOABEAEQARABEAEQAu
AAAAAAAAAAAAAAABAAEAAQABAB0AIwAhACEAIQAhAB8AAAAAAAAAAAAAAAAA
AAAAAAAADgARAAEAAQABABEADgAAAAAAAAAAAAAAIAAgACAAIAA+ACEAIQAh
ACEAIQA+AAAAAAAAAAAAAAAAAAAAAAAAAB4AIQAhAB8AAQAhAB4AAAAAAAAA
AAAAABwAAgACAAIADwACAAIAAgACAAIAAgAAAAAAAAAAAAAAAAAAAAAAAAA+
ACEAIQAhACEAIQA+ACAAIQAeAAAAAAABAAEAAQABAA8AEQAhACEAIQAhACEA
AAAAAAAAAAAAAAAAAAABAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAA
AAQAAAAEAAQABAAEAAQABAAEAAIAAQAAAAAAAAABAAEAAQABACEAEQAJAAcA
CQARABEAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAA
AAAAAAAAAAAAAADOATECIQQhBCEEIQQhBAAAAAAAAAAAAAAAAAAAAAAAAA4A
EQAhACEAIQAhACEAAAAAAAAAAAAAAAAAAAAAAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAAAAAAeACEAIQAhACEAIQAfAAEAAQABAAAAAAAAAAAA
AAAAAB4AIQAhACEAIQAhAD4AIAAgACAAAAAAAAAAAAAAAAAADgARAAEAAQAB
AAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAeACEAAQAeACAAIQAeAAAAAAAAAAAA
AAAAAAIAAgACAA8AAgACAAIAAgACAAwAAAAAAAAAAAAAAAAAAAAAAAAAIQAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAAAAAAhACEAIQASABIADAAMAAAA
AAAAAAAAAAAAAAAAAAAAAEEAQQBBACoAKgAUABQAAAAAAAAAAAAAAAAAAAAA
AAAAQQAiABQACAAUACIAQQAAAAAAAAAAAAAAAAAAAAAAAAAhACEAIQAhACEA
IQA+ACAAIAAfAAAAAAAAAAAAAAAAAD8AIAAYAAYAAQABAD8AAAAAAAAAAAAA
AAwAAgACAAIAAgABAAIAAgACAAIADAAAAAAAAAAAAAAAAQABAAEAAQABAAEA
AQABAAEAAQABAAAAAAAAAAAAAAADAAQABAAEAAQACAAEAAQABAAEAAMAAAAA
AAAAAAAAAAAAAAAmABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABwAPgA
jAF2A38HngP8AdgAcAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAABAAAAAAABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAEAAQADgAV
AAUABQAFABUADgAEAAQAAAAAAAAAHAAiAAIAAgAPAAIAAgACAAIAAgA/AAAA
AAAAAAAAAAA8AEIAAQABAAcAAQAHAAEAAQBCADwAAAAAAAAAAAAAAAEBAQGC
AEQAKAAQAP4AEAD+ABAAEAAAAAAAAAAKAAQAAAAeACEAAQABAB4AIAAgACAA
IQAeAAAAAAAAAAAAAAAAAA4AEQABAA4AEQARAA4AEAARAA4AAAAAAAAAAAAA
AAAACgAEAAAAHgAhAAEAHgAgACEAHgAAAAAAAAAAAAAAHAAiAEEAWQBFAEUA
RQBZAEEAIgAcAAAAAAAAAAMABAAHAAUABwAAAAcAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAUAAoABQACgAFAAoAFAAoAFAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAB8AEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAABwAIgBBAF0AVQBNAFUAVQBBACIAHAAAAAAAAAAfAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAHwAEAAQAAAAfAAAAAAAAAAAA
AAADAAQAAgABAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMABAACAAQAAwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAQAAAA/wGAAEAAIAAQAAgABAACAAEA
/wEAAAAAAAAAAAAAAAAAAAAAAAAAACEAIQAhACEAIQAfAAEAAQAAAAAAAAAu
AC8ALwAvAC4AKAAoACgAKAAoACgAAAAAAAAAAAAAAAAAAAAAAAAABgAGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAUAAgAAAA/ACAAGAAGAAEAAQA/AAAAAAAA
AAMAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAoAFAAoAFAAKAAUAAoABQAA
AAAAAAAAAAAAAAD8ABIAEQARABEAcQARABEAEQASAPwAAAAAAAAAAAAAAAAA
AAAAAAAA7gERAhEC8QERABEC7gEAAAAAAAAAACgAAAABAQEBggBEACgAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAIAAYAAQABAAEAIQAeAAAA
BAAIAAAAHAAiAEEAQQBBAH8AQQBBAEEAQQAAAAAAAAAQAAgAAAAcACIAQQBB
AEEAfwBBAEEAQQBBAAAAAAAAABQAAAAcACIAQQBBAEEAfwBBAEEAQQBBAEEA
AAAAAAAAJgAZAAAAHAAiAEEAQQBBAH8AQQBBAEEAQQAAAAAAAAAAABQAAAAc
ACIAQQBBAEEAfwBBAEEAQQBBAAAAAAAAAAgAFAAIABwAIgBBAEEAQQB/AEEA
QQBBAEEAAAAAAAAAAAAAAP4AEQARABEAEQB/ABEAEQARABEA8QAAAAAAAAAA
AAAAPABCAAEAAQABAAEAAQABAAEAQgA8AAgADAAAAAQACAAAAD8AAQABAAEA
DwABAAEAAQABAD8AAAAAAAAAEAAIAAAAPwABAAEAAQAPAAEAAQABAAEAPwAA
AAAAAAAIABQAAAA/AAEAAQABAA8AAQABAAEAAQA/AAAAAAAAAAAAFAAAAD8A
AQABAAEADwABAAEAAQABAD8AAAAAAAAAAQACAAAAAQABAAEAAQABAAEAAQAB
AAEAAQAAAAAAAAACAAEAAAABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAEA
AgAAAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAACAAAAAQABAAEAAQAB
AAEAAQABAAEAAQAAAAAAAAAAAAAAHwAhAEEAQQBBAEcAQQBBAEEAQQA/AAAA
AAAAACYAGQAAAEEAQwBFAEUASQBJAFEAUQBhAGEAAAAAAAAABAAIAAAAHAAi
AEEAQQBBAEEAQQBBACIAHAAAAAAAAAAQAAgAAAAcACIAQQBBAEEAQQBBAEEA
IgAcAAAAAAAAAAgAFAAAABwAIgBBAEEAQQBBAEEAQQAiABwAAAAAAAAAJgAZ
AAAAHAAiAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQAAAAcACIAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAAAAA
AAAAAAAAAFwAIgBRAEkASQBJAEkASQBFACIAHQAAAAAAAAAEAAgAAABBAEEA
QQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAEEAQQBBAEEAQQBBAEEAQQAi
ABwAAAAAAAAACAAUAAAAQQBBAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQA
AABBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAEEAQQAiABQACAAI
AAgACAAIAAgAAAAAAAAAAAAAAAEAAQAPABEAEQARAA8AAQABAAEAAQAAAAAA
AAAAAAAADgARACEAIQAZAAUAOQBBAEEAQQA9AAAAAAAAAAAAAAAAAAIABAAA
AA4AEQARABEAEQARAC4AAAAAAAAAAAAAAAAACAAEAAAADgARABEAEQARABEA
LgAAAAAAAAAAAAAAAAAEAAoAAAAOABEAEQARABEAEQAuAAAAAAAAAAAAAAAA
ABYACQAAAA4AEQARABEAEQARAC4AAAAAAAAAAAAAAAAAAAAKAAAADgARABEA
EQARABEALgAAAAAAAAAAAAAAAAAEAAoABAAOABEAEQARABEAEQAuAAAAAAAA
AAAAAAAAAAAAAAAAAO4AEQEQAf4AEQAZAfYAAAAAAAAAAAAAAAAAAAAAAAAA
DgARAAEAAQABABEADgAEAAYAAAAAAAAAAAAEAAgAAAAeACEAIQAfAAEAIQAe
AAAAAAAAAAAAAAAAABAACAAAAB4AIQAhAB8AAQAhAB4AAAAAAAAAAAAAAAAA
BAAKAAAAHgAhACEAHwABACEAHgAAAAAAAAAAAAAAAAAAABQAAAAeACEAIQAf
AAEAIQAeAAAAAAAAAAAAAAAAAAAAAQAAAAEAAQABAAEAAQABAAEAAAAAAAAA
AAAAAAAAAgABAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAABAAIAAAAB
AAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAgAAAAEAAQABAAEAAQABAAEA
AAAAAAAAAAAAAAAANgAJABQAHgAhACEAIQAhACEAHgAAAAAAAAAAAAAAAAAW
AAkAAAAOABEAIQAhACEAIQAhAAAAAAAAAAAAAAAAAAQACAAAAB4AIQAhACEA
IQAhAB4AAAAAAAAAAAAAAAAACAAEAAAAHgAhACEAIQAhACEAHgAAAAAAAAAA
AAAAAAAEAAoAAAAeACEAIQAhACEAIQAeAAAAAAAAAAAAAAAAABYACQAAAB4A
IQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAKAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAQAAAAfAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAC4AEQApAC0AJQAiAB0AAAAAAAAAAAAAAAAAAAAEAAgAAAAhACEAIQAh
ACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAACEAIQAhACEAIQAeAAAAAAAAAAAA
AAAAAAAABAAKAAAAIQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAIAAQAAAAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAACEAIQAhACEAIQA+ACAA
IAAfAAAAAAAAAAEAAQABAB0AIwAhACEAIQAjAB0AAQABAAEAAAAAAAAAAAAA
ABQAAAAhACEAIQAhACEAPgAgACAAHwA=
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/sansserif-8.sqf.__mime.




























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 sansserif-8.sqf
CAYCAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBgQGBgID
AwYEAwMCBAQEBAQFBAUFBQUCAgQEBAUFBQUFBQQEBQUCBAUEBgYFBQUFBQQF
BQYGBgYDBAMEAwMFBQQFBQQFBQIDBQIHBQUFBQQFBAUFBgUFBQQCBAUGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBgYFBAQGBAYEBAYE
BAQDBAUEBgIEBAMGBgYGBAUFBQUFBQYFBAQEBAIDAwMGBQUFBQUFBAYFBQUF
BgQFBAQEBAQEBgQEBAQEAwIDAwQEBQUFBQUEBAUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDgobHwoOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQABAAAFBQAAAAAAAAofCh8KAAAABA4BBggH
AgAAEwsEGhkAAA4BAhUJFgAAAQEAAAAAAAACAQEBAQIAAAECAgICAQAAFQ4V
AAAAAAAAAgcCAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAEAAAQEAgIBAQAA
AgUFBQUCAAADAgICAgcAAAMEBAIBBwAAAwQCBAQDAAAMCgkPCAgAAAcBAwQE
AwAADgEHCQkGAAAPCAQEAgIAAAYJBgkJBgAABgkJDggHAAAAAQAAAQAAAAAB
AAAAAQEAAAQCAQIEAAAAAAcABwAAAAABAgQCAQAABwgIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAGAQEBAQYAAAcJCQkJBwAABwEDAQEHAAAHAQMB
AQEAAA4BAQ0JDgAACQkPCQkJAAABAQEBAQEAAAQEBAQFAgAACQUDAwUJAAAB
AQEBAQcAABEbFRUREQAAExMVFRkZAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAABwICAgICAAAJCQkJCQYAAAkJCQkKDAAAERER
ERUKAAARCgQEChEAABERCgQEBAAAHwgEAgEfAAADAQEBAQMAAAEBAgIEBAAA
AwICAgIDAAACBQAAAAAAAAAAAAAABwAAAQIAAAAAAAAAAAYJCRYAAAEBBwkJ
BwAAAAAGAQEGAAAICA4JCQ4AAAAGCQ8BDgAAAAwCBwICAAAAAA4JCQ4IBwEB
BwkJCQAAAAEAAQEBAAAAAgACAgIBAAEBCQcJCQAAAQEBAQEBAAAAAB8lJSUA
AAAABwkJCQAAAAAGCQkGAAAAAAcJCQcBAQAADgkJDggIAAAGAQEBAAAADgEG
CAcAAAACBwICBgAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAABgIDAwIGAAABAQEBAQEAAAMCBgYCAwAAAAoFAAAA
AAAOChsfCg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAQABAQEBAAQOBQUOBAAMAgcCAg8AAAwSBwIXDAAAEQoEDg4EAAAK
BA4DDAcAAAYBBgMEAwAABQIOAwwHAAAOERUTFQ4AAAMFBwAHAAAAABQKBQoU
AAAAAAcEAAAAAAAABwAAAAAADhMVExUOAAAHAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAADBAIBBwAAAAMEBwQDAAAACgQPBAIPAAAAAAAFBQcBABYXFhQUFAAA
AAAAAQAAAAAFAgcGAQcAAAMCBwAAAAAAAgUCBwAAAAAABQoUCgUAAB4FDQUF
HgAAAAA+GQk+AAAKEQoEBAQAAAACAAIBAQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAAEg0GCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUPBQUdAAAOAQEBAQ4E
BgIEBwMBBwAABAIHAwEHAAACBQcDAQcAAAUABwMBBwAAAQIBAQEBAAACAQIC
AgIAAAIFAgICAgAABQACAgICAAAOEhcSEg4AAAoFAAsNCQAAAgQGCQkGAAAE
AgYJCQYAAAQKBgkJBgAACgUGCQkGAAAKAAYJCQYAAAAABQIFAAAADhkVFRMO
AAACBAkJCQYAAAQCCQkJBgAAAgUJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAHCQUJEQ0AAAECAAYFCwAABAIABgULAAACBQAGBQsAAAoFAAYFCwAA
BQAABgULAAACBQIGBQsAAAAAHi0dMwAAAAAGAQEGAwACBAIFAwYAAAQCAgUD
BgAAAgUCBQMGAAAFAAIFAwYAAAECAAICAgAAAgEAAQEBAAACBQACAgIAAAUA
AAICAgAACgUMCwkGAAAKBQADBQUAAAECBgkJBgAABAIGCQkGAAAECgYJCQYA
AAoFBgkJBgAABQAGCQkGAAAAAgAHAAIAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAABQAACQkGAAAEAgAJCQ4IBwABBwkJBwEACgAACQkOCAc=
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/serif-12.sqf.__mime.























































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 serif-12.sqf
DAkDAgoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBwYKCAID
AwYEAwQDBQYGBgYGBgYGBgYDAwUEBQYHBgYGBgYGBgYEBgcGCAYGBgYGBgYG
BggHBwYEBQQGBAMGBwUGBQUGBgMDBgMKBgYGBgUGBAYGBgYGBgQCBAYKAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBwgGBgUHBAcFAwcF
BAQDAwcGBgQFBAQHCAgGBgYGBgYGBwgFBQUFBQMDAwMHBgYGBgYGBgcGBgYG
BgUIBgYGBgYGCAUFBQUFAwIDAwYGBQUFBQUEBgYGBgYGBwYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBEAA4AGQA2gD/AH4APAAYAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAABAAEAAQABAAEAAQAAAAEAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAA
AAAAAAAAEgASAD8AEgASABIAPwASABIAAAAAAAAABAAOABUABQAOABQAFAAV
AA4ABAAAAAAABgGJAEkAJgAQAMgAJAEiAcEAAAAAAAAADAASAAEAAQACAEUA
KQARAC4AAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgABAAEAAQAB
AAEAAQABAAIAAAAAAAAAAQACAAIAAgACAAIAAgACAAEAAAAAAAAAFQAOAB8A
DgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAcAAgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAMAAwAAAAAAAAAIAAgABAAEAAIAAgABAAEAAAAA
AAAADgARABEAFQAVABUAEQARAA4AAAAAAAAABwAEAAQABAAEAAQABAAEAB8A
AAAAAAAADgARABAACAAEAAIAAQABAB8AAAAAAAAADgARABAAEAAOABAAEAAR
AA4AAAAAAAAAEQARABEAEQAfABAAEAAQABAAAAAAAAAAHwABAAEADwAQABAA
EAARAA4AAAAAAAAAHgABAAEAAQAPABEAEQARAA4AAAAAAAAAHwAQABAACAAI
AAQABAACAAIAAAAAAAAADgARABEAEQAOABEAEQARAA4AAAAAAAAADgARABEA
EQAeABAAEAAQABAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAMAAwAAAAAAAAAA
AAAAAwADAAAAAAAAAAMAAgAAAAAAAAAIAAQAAgABAAIABAAIAAAAAAAAAAAA
AAAAAAAAAAAHAAAABwAAAAAAAAAAAAAAAAABAAIABAAIAAQAAgABAAAAAAAA
AAAADgARABAAEAAIAAQABAAAAAQAAAAAAAAAHgAhAC0ALQAtAC0APQABAD4A
AAAAAAAADAASABIAEgAeABIAEgASADMAAAAAAAAADwASABIAEgAOABIAEgAS
AA8AAAAAAAAAHgARAAEAAQABAAEAAQARAB4AAAAAAAAADwASABIAEgASABIA
EgASAA8AAAAAAAAAHwASAAIAAgAGAAIAAgASAB8AAAAAAAAAHwASAAIAAgAG
AAIAAgACAAMAAAAAAAAAHgARAAEAAQAdABEAEQARAA4AAAAAAAAAMwASABIA
EgAeABIAEgASADMAAAAAAAAABwACAAIAAgACAAIAAgACAAcAAAAAAAAAOAAQ
ABAAEAAQABAAEQARAA4AAAAAAAAAIwAiABIACgAGAAYACgASACMAAAAAAAAA
AwACAAIAAgACAAIAAgASAB4AAAAAAAAAYwBVAEkAQQBBAEEAQQBBAGMAAAAA
AAAAGQATABMAFQAVABUAGQAZABMAAAAAAAAADgARABEAEQARABEAEQARAA4A
AAAAAAAADwASABIAEgAOAAIAAgACAAMAAAAAAAAADgARABEAEQARABEAFQAJ
ABYAAAAAAAAADwASABIAEgAOAAoAEgASADMAAAAAAAAAHgARAAEAAQAOABAA
EAARAA8AAAAAAAAAHwAVAAQABAAEAAQABAAEAA4AAAAAAAAAGwARABEAEQAR
ABEAEQARAA4AAAAAAAAAGwARABEAEQARABEAEgAUABgAAAAAAAAAYwBBAEEA
QQBBAEkASQBJADYAAAAAAAAAdwAiABQACAAIABQAIgAiAHcAAAAAAAAAdwAi
ACIAFAAIAAgACAAIABwAAAAAAAAAHwARABAACAAEAAIAAQARAB8AAAAAAAAA
BwABAAEAAQABAAEAAQABAAcAAAAAAAAAAAABAAEAAgACAAQABAAIAAgAAAAA
AAAABwAEAAQABAAEAAQABAAEAAcAAAAAAAAABAAKABEAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAPABAAHwARAC4AAAAAAAAAAwACAAIAAgAOABIA
EgASAA8AAAAAAAAAAAAAAAAAAAAOAAkAAQAJAA4AAAAAAAAAMAAQABAAEAAe
ABEAEQARAD4AAAAAAAAAAAAAAAAAAAAOAAkABwABAA4AAAAAAAAAAAAMAAIA
AgAHAAIAAgACAAIAAAAAAAAAAAAAAAAAAAAeABEAEQARAB4AEAAPAAAAAAAD
AAIAAgAOABIAEgASADMAAAAAAAAAAAAAAAIAAAACAAIAAgACAAcAAAAAAAAA
AAAAAAIAAAACAAIAAgACAAIAAQAAAAAAAAADAAEAMQARAA8AEQARADMAAAAA
AAAAAAADAAIAAgACAAIAAgACAAcAAAAAAAAAAAAAAAAAAAD/ABIBEgESAbsD
AAAAAAAAAAAAAAAAAAAPABIAEgASADsAAAAAAAAAAAAAAAAAAAAOABEAEQAR
AA4AAAAAAAAAAAAAAAAAAAAPABIAEgASAA4AAgADAAAAAAAAAAAAAAA+ABEA
EQARAB4AEAAwAAAAAAAAAAAAAAAOAAkAAQABAAEAAAAAAAAAAAAAAAAAAAAe
AAEADgAQAA8AAAAAAAAAAAAAAAIAAgAHAAIAAgACAAwAAAAAAAAAAAAAAAAA
AAAbABEAEQARAA4AAAAAAAAAAAAAAAAAAAAbABEAEgAUABgAAAAAAAAAAAAA
AAAAAAAbABEAFQAVAAoAAAAAAAAAAAAAAAAAAAAbAAoABAAKABsAAAAAAAAA
AAAAAAAAAAAbABEAEQAeABAAEAAPAAAAAAAAAAAAAAAfAAkABAASAB8AAAAA
AAAABAACAAIAAgABAAIAAgACAAQAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AAAAAAAAAQACAAIAAgAEAAIAAgACAAEAAAAAAAAAAAAWAAkAAAAAAAAAAAAA
AAAAAAAAAAAAEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAQABAAAAAAAAAAAA
BAAOABUABQAVAA4ABAAAAAAADAACAAIAAgAHAAIAAgACAA8AAAAAAAAAHAAi
AAIADwACAA8AAgAiABwAAAAAAAAAQQBBACIAFAAIABwACAAcAAgAAAAAAAAA
CgAEAB4AEQABAA4AEAARAA8AAAAAAAAAHgARAAMADQARABYAGAARAA8AAAAA
AAAACgAEAAAAAAAOAAEABgAIAAcAAAAAAAAAHgAhAC0AIwAjACMALQAhAB4A
AAAAAAAAAgAFAAUACgAAAA8AAAAAAAAAAAAAAAAAAAAoABQACgAFAAoAFAAo
AAAAAAAAAAAAAAAAAAAAAAAPAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAA
AAAAAAAAAAAAAAAAHgAhACcAKwAnACsAKwAhAB4AAAAAAAAADwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AgAHAAIAAAAHAAAAAAAAAAAAAwACAAMAAQADAAAAAAAAAAAAAAAAAAAAAwAC
AAMAAgADAAAAAAAAAAAAAAAAAAAACgAEAD8AEAAIAAQAAgABAD8AAAAAAAAA
AAAAAAAAAAAAABEAEQARAA8AAQABAAAAFgAXABcAFgAUABQAFAAUABQAAAAA
AAAAAAAAAAAAAAAGAAYAAAAAAAAAAAAAAAAACgAEAAAAAAAPAAgABgABAA8A
AAAAAAAAAwACAAIABwAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAAAAAA
AAAAAAAAAAAAAAAFAAoAFAAoABQACgAFAAAAAAAAAAAAfgAJAAkACQA5AAkA
CQAJAH4AAAAAAAAAAAAAAAAAAAB2AEkAOQAJAHYAAAAAAAAACgARABEAEQAK
AAQABAAEAAQAAAAAAAAAAAAAAAQAAAAEAAQAAgABABEAEQAOAAAAAgAEAAAA
DAASABIAHgASADMAAAAAAAAACAAEAAAADAASABIAHgASADMAAAAAAAAABAAK
AAAADAASABIAHgASADMAAAAAAAAAFgAJAAAADAASABIAHgASADMAAAAAAAAA
CgAAAAAADAASABIAHgASADMAAAAAAAAABAAKAAQADAASABIAHgASADMAAAAA
AAAAfAAKAAkACQA/AAkACQAJAHkAAAAAAAAAAAAOAAEAAQABAAEAAQABAA4A
BAAGAAAAAgAEAAAADwACAAYAAgACAA8AAAAAAAAABAACAAAADwACAAYAAgAC
AA8AAAAAAAAABAAKAAAADwACAAYAAgACAA8AAAAAAAAACgAAAAAADwACAAYA
AgACAA8AAAAAAAAAAQACAAAABwACAAIAAgACAAcAAAAAAAAABAACAAAABwAC
AAIAAgACAAcAAAAAAAAAAgAFAAAABwACAAIAAgACAAcAAAAAAAAABQAAAAAA
BwACAAIAAgACAAcAAAAAAAAAHwAiACIAIgAnACIAIgAiAB8AAAAAAAAAFgAJ
AAAAGwATABUAFQAZABsAAAAAAAAAAgAEAAAADgARABEAEQARAA4AAAAAAAAA
CAAEAAAADgARABEAEQARAA4AAAAAAAAABAAKAAAADgARABEAEQARAA4AAAAA
AAAAFgAJAAAADgARABEAEQARAA4AAAAAAAAACgAAAAAADgARABEAEQARAA4A
AAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAHgAxACkAKQAlACUAJQAj
AB4AAAAAAAAAAgAEAAAAGwARABEAEQARAA4AAAAAAAAACAAEAAAAGwARABEA
EQARAA4AAAAAAAAABAAKAAAAGwARABEAEQARAA4AAAAAAAAACgAAAAAAGwAR
ABEAEQARAA4AAAAAAAAACAAEAAAAGwARAAoABAAEAA4AAAAAAAAAAQABAAcA
CQAJAAkABwABAAEAAAAAAAAADgARABEACQAFAAkAEQARAA0AAAAAAAAAAAAC
AAQAAAAPABAAHwARAC4AAAAAAAAAAAAIAAQAAAAPABAAHwARAC4AAAAAAAAA
AAAEAAoAAAAPABAAHwARAC4AAAAAAAAAAAAWAAkAAAAPABAAHwARAC4AAAAA
AAAAAAAAAAoAAAAPABAAHwARAC4AAAAAAAAABAAKAAQAAAAPABAAHwARAC4A
AAAAAAAAAAAAAAAAAAA3AEgAPgAJAHYAAAAAAAAAAAAAAAAAAAAOAAkAAQAJ
AA4ABAAGAAAAAAACAAQAAAAOAAkABwABAA4AAAAAAAAAAAAIAAQAAAAOAAkA
BwABAA4AAAAAAAAAAAAEAAoAAAAOAAkABwABAA4AAAAAAAAAAAAAAAoAAAAO
AAkABwABAA4AAAAAAAAAAAAAAAEAAgAAAAIAAgACAAcAAAAAAAAAAAAAAAIA
AQAAAAEAAQABAAMAAAAAAAAAAAAAAAIABQAAAAIAAgACAAcAAAAAAAAAAAAA
AAAABQAAAAIAAgACAAcAAAAAAAAAAAAAABgABwAKABEAEQARAA4AAAAAAAAA
AAAAABYACQAAAA8AEQARABsAAAAAAAAAAAAAAAIABAAAAAYACQAJAAYAAAAA
AAAAAAAAAAQAAgAAAAYACQAJAAYAAAAAAAAAAAAAAAIABQAAAAYACQAJAAYA
AAAAAAAAAAAAAAoABQAAAAYACQAJAAYAAAAAAAAAAAAAAAAACgAAAAYACQAJ
AAYAAAAAAAAAAAAAAAAAAgAAAAcAAAACAAAAAAAAAAAAAAAAAAAAAAAOABkA
FQATAA4AAAAAAAAAAAAAAAIABAAAABsAEQARAA4AAAAAAAAAAAAAAAgABAAA
ABsAEQARAA4AAAAAAAAAAAAAAAQACgAAABsAEQARAA4AAAAAAAAAAAAAAAAA
CgAAABsAEQARAA4AAAAAAAAAAAAAAAgABAAAABsAEQARAB4AEAAPAAAAAAAA
AAEAAQAHAAkACQAJAAcAAQABAAAAAAAAAAAACgAAABsAEQARAB4AEAAPAAAA
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/serif-16.sqf.__mime.





































































































































































































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
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
191
192
193
194
195
196
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 serif-16.sqf
EA0DAg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAIFCggNCwME
BQcHAwUDCAcHBwcHBwcHBwcEBAcFBwgKCQkJCQkJCAgECAkICQkJCAkICAkJ
CQsJCwsFCAUFBQQHCAcICAcICAQDCAMNCAgICAcIBggICQkICAYDBggNAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgcICAsIBwgJBQkHBgkH
BQcFBQsICAUIBQUHCgwLCAkJCQkJCQoJCAgICAUFBQUJCQkJCQkJBwkJCQkJ
CQcJBwcHBwcHCwcICAgIBAQEBAgICAgICAgHCAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAAACAAcAD4AIwBdgN/B54D/AHYAHAA
IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAQABAAEAAQABAAEAAQAAAAAAAQAAAAAAAAAFAAUAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAD/ACQAJAAkAP8AJAAkACQAAAAA
AAAABAAEAB4AJQAFAAUABQAeACQAJAAkACUAHgAEAAQAAAAAAAAADAQSAhIB
jABAACAAEAOIBIQEAgMBAAAAAAAAAAAAAAA8AEIAAgACAAQACAAUAKIAQQCh
AB4BAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BAACAAEAAQABAAEAAQABAAEAAgAEAAAAAAAAAAAAAAABAAIABAAEAAQABAAE
AAQABAACAAEAAAAAAAAAFQAOAB8ADgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAQABAAfAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAwACAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAAg
ACAAEAAQAAgACAAEAAQAAgACAAEAAAAAAAAAAAAAAA4AEQARABEAFQAVABUA
EQARABEADgAAAAAAAAAAAAAABwAEAAQABAAEAAQABAAEAAQABAAfAAAAAAAA
AAAAAAAOABEAEAAQABAACAAEAAIAAQABAB8AAAAAAAAAAAAAAA4AEQAQABAA
EAAOABAAEAAQABEADgAAAAAAAAAAAAAAEQARABEAEQARAB8AEAAQABAAEAAQ
AAAAAAAAAAAAAAAfAAEAAQABAA8AEAAQABAAEAARAA4AAAAAAAAAAAAAAB4A
AQABAAEAAQAPABEAEQARABEADgAAAAAAAAAAAAAAHwAQABAAEAAQABAAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAOABEAEQARABEADgARABEAEQARAA4AAAAAAAAA
AAAAAA4AEQARABEAEQAeABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAMAAwAA
AAAAAAAAAAAAAwADAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAADAAMA
AgAAAAAAAAAAAAAAEAAIAAQAAgABAAIABAAIABAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAA8AAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAEAAgAEAAgAEAAIAAQA
AgABAAAAAAAAAAAAAAAAAB4AIQAgACAAIAAYAAQABAAAAAAABAAAAAAAAAAA
AAAAfgCBAJkApQClAKUApQClAHkAAQD+AAAAAAAAAAAAAABgAFAASABIAEQA
RAB+AEIAQQBBAOMAAAAAAAAAAAAAAB8AIgBCAEIAIgAeACIAQgBCAEIAPwAA
AAAAAAAAAAAAPABCAMEAAQABAAEAAQABAMEAQgA8AAAAAAAAAAAAAAAfACIA
QgBCAEIAQgBCAEIAQgBCAD8AAAAAAAAAAAAAAH8AQgACAAIAEgAeABIAAgAC
AEIAfwAAAAAAAAAAAAAAfwBCAAIAAgASAB4AEgACAAIAAgAHAAAAAAAAAAAA
AAA+ACEAIQABAAEAAQA5ACEAIQAhAB4AAAAAAAAAAAAAAGMAIgAiACIAIgA+
ACIAIgAiACIAYwAAAAAAAAAAAAAABwACAAIAAgACAAIAAgACAAIAAgAHAAAA
AAAAAAAAAABwACAAIAAgACAAIAAgACEAIQAhAB8AAAAAAAAAAAAAAOMAQgAi
ABIACgAGAAoAEgAiAEIA4wAAAAAAAAAAAAAAAwABAAEAAQABAAEAAQABAAEA
IQA/AAAAAAAAAAAAAABBAGMAYwBVAFUASQBJAEEAQQBBAOMAAAAAAAAAAAAA
AOMAQwBDAEUARQBJAEkAUQBRAGEA4wAAAAAAAAAAAAAAHAAiAEEAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAPABIAIgAiACIAEgAOAAIAAgACAAcAAAAA
AAAAAAAAABwAIgBBAEEAQQBBAEEAQQBRACIAXACAAAAAAAAAAAAADwASACIA
IgAiABIADgASACIAIgB3AAAAAAAAAAAAAAA+ACEAAQABAAEAHgAgACAAIAAh
AB8AAAAAAAAAAAAAAH8ASQAIAAgACAAIAAgACAAIAAgAHAAAAAAAAAAAAAAA
4wBBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAAAAAAADjAEEAQQBBAEEAQQBB
AEEAIgAUAAgAAAAAAAAAAAAAAIMDAQEBAQEBAQEBAQEBEQERAaoARAAAAAAA
AAAAAAAAxwGCAEQAKAAoABAAKAAoAEQAggDHAQAAAAAAAAAAAACDAwEBggBE
ACgAEAAQABAAEAAQADgAAAAAAAAAAAAAAP8BAQGAAEAAIAAQAAgABAACAAEB
/wEAAAAAAAAAAAAABwABAAEAAQABAAEAAQABAAEAAQAHAAAAAAAAAAAAAAAB
AAEAAgACAAQABAAIAAgAEAAQACAAAAAAAAAAAAAAAAcABAAEAAQABAAEAAQA
BAAEAAQABwAAAAAAAAACAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAAAAAAAQACAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOABEAEAAeABEAGQA2
AAAAAAAAAAAAAAADAAIAAgACABoAJgAiACIAIgAiAB8AAAAAAAAAAAAAAAAA
AAAAAAAAHgARAAEAAQABABEAHgAAAAAAAAAAAAAAMAAQABAAEAAeABEAEQAR
ABEAEQA+AAAAAAAAAAAAAAAAAAAAAAAAAB4AIQAhAB8AAQAhAD4AAAAAAAAA
AAAAABwAEgACAAIADwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAB+
ACEAIQAhACEAPgAgACEAIQAfAAAAAAADAAIAAgACAA4AEgAiACIAIgAiAHcA
AAAAAAAAAAAAAAAAAAACAAAAAwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAAA
AAIAAAADAAIAAgACAAIAAgACAAEAAAAAAAAAAAAAAAMAAgACADIAEgAKAAYA
CgASADsAAAAAAAAAAAAAAAAAAwACAAIAAgACAAIAAgACAAIABwAAAAAAAAAA
AAAAAAAAAAAAAADNATMCIQQhBCEEIQRzDgAAAAAAAAAAAAAAAAAAAAAAAA0A
EwAhACEAIQAhAHMAAAAAAAAAAAAAAAAAAAAAAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAAAAAAfACIAIgAiACIAIgAeAAIAAgADAAAAAAAAAAAA
AAAAAD4AEQARABEAEQARAB4AEAAQADAAAAAAAAAAAAAAAAAADwASAAIAAgAC
AAIABwAAAAAAAAAAAAAAAAAAAAAAAAA+ACEAAQAeACAAIQAfAAAAAAAAAAAA
AAAAAA4AAgACAA8AAgACAAIAAgASAAwAAAAAAAAAAAAAAAAAAAAAAAAAcwAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAAAAABzACEAIQASABIADAAMAAAA
AAAAAAAAAAAAAAAAAAAAAOMAQQBBACoAKgAUABQAAAAAAAAAAAAAAAAAAAAA
AAAAYwAiABQACAAUACIAYwAAAAAAAAAAAAAAAAAAAAAAAABzACEAIQAhACEA
PgAgACAAIQAfAAAAAAAAAAAAAAAAAD8AIQAYAAYAAQAhAD8AAAAAAAAAAAAA
AAwAAgACAAIAAgABAAIAAgACAAIADAAAAAAAAAAAAAAAAQABAAEAAQABAAEA
AQABAAEAAQABAAAAAAAAAAAAAAADAAQABAAEAAQACAAEAAQABAAEAAMAAAAA
AAAAAAAAAAAAAAAmABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABwAPgA
jAF2A38HngP8AdgAcAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAABAAAAAAABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAEAAQADgAV
AAUABQAFABUADgAEAAQAAAAAAAAAHAAiAAIAAgAPAAIAAgACAAIAAgA/AAAA
AAAAAAAAAAA8AEIAAQABAAcAAQAHAAEAAQBCADwAAAAAAAAAAAAAAAEBAQGC
AEQAKAAQAP4AEAD+ABAAEAAAAAAAAAAKAAQAAAA+ACEAAQABAB4AIAAgACAA
IQAfAAAAAAAAAAAAAAAAAA4AEQABAA4AEQARAA4AEAARAA4AAAAAAAAAAAAA
AAAACgAEAAAAPgAhAAEAHgAgACEAHwAAAAAAAAAAAAAAHAAiAEEAWQBFAEUA
RQBZAEEAIgAcAAAAAAAAAAMABAAHAAUABwAAAAcAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAUAAoABQACgAFAAoAFAAoAFAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAB8AEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAABwAIgBBAF0AVQBNAFUAVQBBACIAHAAAAAAAAAAfAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAHwAEAAQAAAAfAAAAAAAAAAAA
AAADAAQAAgABAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMABAACAAQAAwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAQAAAA/wGBAEAAIAAQAAgABAACAAEB
/wEAAAAAAAAAAAAAAAAAAAAAAAAAACEAIQAhACEAIQB/AAEAAQAAAAAAAAAu
AC8ALwAvAC4AKAAoACgAKAAoACgAAAAAAAAAAAAAAAAAAAAAAAAABgAGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAUAAgAAAA/ACEAGAAGAAEAIQA/AAAAAAAA
AAMAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAoAFAAoAFAAKAAUAAoABQAA
AAAAAAAAAAAAAAD8AJIAEQARAFEAcQBRABEAEQCSAPwAAAAAAAAAAAAAAAAA
AAAAAAAA7gERAhEC8QERABEC7gMAAAAAAAAAACgAAAABAQEBggBEACgAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAIAAYAAQABAAEAIQAeAAAA
AAAQACAAAAAwACgAJAAkACIAPgAhACEAcwAAAAAAAAAAACAAEAAAADAAKAAk
ACQAIgA+ACEAIQBzAAAAAAAAAAAAEAAoAAAAMAAoACQAJAAiAD4AIQAhAHMA
AAAAAAAAAAAmABkAAAAwACgAJAAkACIAPgAhACEAcwAAAAAAAAAAAAAAKAAA
ADAAKAAkACQAIgA+ACEAIQBzAAAAAAAAABAAKAAQAAAAMAAoACQAJAAiAD4A
IQAhAHMAAAAAAAAAAAAAAPgAlAASABEAUQB/AFEAEQARAJEA8wAAAAAAAAAA
AAAAfABCAAEAAQABAAEAAQABAAEAQgB8AAgADAAAAAQACAAAAD8AIQABAAkA
DwAJAAEAAQAhAD8AAAAAAAAAEAAIAAAAPwAhAAEACQAPAAkAAQABACEAPwAA
AAAAAAAIABQAAAA/ACEAAQAJAA8ACQABAAEAIQA/AAAAAAAAAAAAFAAAAD8A
IQABAAkADwAJAAEAAQAhAD8AAAAAAAAAAQACAAAABwACAAIAAgACAAIAAgAC
AAIABwAAAAAAAAAEAAIAAAAHAAIAAgACAAIAAgACAAIAAgAHAAAAAAAAAAIA
BQAAAAcAAgACAAIAAgACAAIAAgACAAcAAAAAAAAAAAAFAAAABwACAAIAAgAC
AAIAAgACAAIABwAAAAAAAAAAAAAAHwAiAEIAQgBCAEcAQgBCAEIAQgA/AAAA
AAAAACYAGQAAAOMAQwBFAEUASQBJAFEAUQBhAOMAAAAAAAAABAAIAAAAHAAi
AEEAQQBBAEEAQQBBACIAHAAAAAAAAAAQAAgAAAAcACIAQQBBAEEAQQBBAEEA
IgAcAAAAAAAAAAgAFAAAABwAIgBBAEEAQQBBAEEAQQAiABwAAAAAAAAAJgAZ
AAAAHAAiAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQAAAAcACIAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAAAAA
AAAAAAAAAFwAIgBRAEkASQBJAEkASQBFACIAHQAAAAAAAAAEAAgAAADjAEEA
QQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAOMAQQBBAEEAQQBBAEEAQQAi
ABwAAAAAAAAACAAUAAAA4wBBAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQA
AADjAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAOMAQQAiABQACAAI
AAgACAAIABwAAAAAAAAAAAAAAAEAAQAPABEAEQARAA8AAQABAAEAAQAAAAAA
AAAAAAAADgARACEAIQAZAAUAOQBBAEEAQQA9AAAAAAAAAAAAAAAAAAIABAAA
AA4AEQAQAB4AEQAZADYAAAAAAAAAAAAAAAAACAAEAAAADgARABAAHgARABkA
NgAAAAAAAAAAAAAAAAAEAAoAAAAOABEAEAAeABEAGQA2AAAAAAAAAAAAAAAA
ABYACQAAAA4AEQAQAB4AEQAZADYAAAAAAAAAAAAAAAAAAAAKAAAADgARABAA
HgARABkANgAAAAAAAAAAAAAAAAAEAAoABAAOABEAEAAeABEAGQA2AAAAAAAA
AAAAAAAAAAAAAAAAAO4AEQEQAf4AEQAZAfcBAAAAAAAAAAAAAAAAAAAAAAAA
HgARAAEAAQABABEAHgAEAAYAAAAAAAAAAAAEAAgAAAAeACEAIQAfAAEAIQA+
AAAAAAAAAAAAAAAAABAACAAAAB4AIQAhAB8AAQAhAD4AAAAAAAAAAAAAAAAA
BAAKAAAAHgAhACEAHwABACEAPgAAAAAAAAAAAAAAAAAAABQAAAAeACEAIQAf
AAEAIQA+AAAAAAAAAAAAAAAAAAEAAgAAAAMAAgACAAIAAgACAAcAAAAAAAAA
AAAAAAAABAACAAAAAwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAACAAUAAAAD
AAIAAgACAAIAAgAHAAAAAAAAAAAAAAAAAAAABQAAAAMAAgACAAIAAgACAAcA
AAAAAAAAAAAAAAAANgAJABQAHgAhACEAIQAhACEAHgAAAAAAAAAAAAAAAAAW
AAkAAAAPABIAIgAiACIAIgB3AAAAAAAAAAAAAAAAAAQACAAAAB4AIQAhACEA
IQAhAB4AAAAAAAAAAAAAAAAACAAEAAAAHgAhACEAIQAhACEAHgAAAAAAAAAA
AAAAAAAEAAoAAAAeACEAIQAhACEAIQAeAAAAAAAAAAAAAAAAABYACQAAAB4A
IQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAKAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAQAAAAfAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAC4AEQApAC0AJQAiAB0AAAAAAAAAAAAAAAAAAAAEAAgAAABzACEAIQAh
ACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAAHMAIQAhACEAIQAeAAAAAAAAAAAA
AAAAAAAABAAKAAAAcwAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAIAAQAAABz
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAAHMAIQAhACEAPgAgACAA
IQAfAAAAAAAAAAEAAQABAB0AIwAhACEAIQAjAB0AAQABAAEAAAAAAAAAAAAA
ABQAAABzACEAIQAhAD4AIAAgACEAHwA=
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/serif-8.sqf.__mime.




























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 serif-8.sqf
CAYCAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgMEBgQGBgID
AwYEAwMCBAQEBAQFBAUFBQUCAgQEBAUFBQUFBQUFBQUDBAYEBwcFBgUGBQYG
BQYGBgYDBAMEAwMFBQQFBQQFBQMDBgMIBgUGBgYFBAYFBgUFBQQCBAUGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBgYFBAQGBAYEBAYE
BAQDBAUEBgIEBAMGBgYGBAUFBQUFBQYFBAQEBAIDAwMGBQUFBQUFBAYFBQUF
BgQFBAQEBAQEBgQEBAQEAwIDAwQEBQUFBQUEBAUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDgobHwoOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgICAgACAAAFBQAAAAAAAAofCh8KAAAABA4BBggH
AgAAEwsEGhkAAA4BAhUJFgAAAQEAAAAAAAACAQEBAQIAAAECAgICAQAAFQ4V
AAAAAAAAAgcCAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAEAAAQEAgIBAQAA
BgkNCwkGAAADAgICAgcAAAMEBAIBBwAAAwQCBAQDAAAMCgkPCAgAAAcBAwQE
AwAADgEHCQkGAAAPCAQEAgIAAAYJBgkJBgAABgkJDggHAAAAAQAAAQAAAAAB
AAAAAQEAAAQCAQIEAAAAAAcABwAAAAABAgQCAQAABwgIBgACAAAPCQ0NAQ8A
AAgMCg4JGwAABwoGCgoHAAAGCQEBCQYAAAcKCgoKBwAADwIGAgoPAAAPAgYC
AgMAAA4BAR0JDgAAGwkPCQkbAAAHAgICAgcAAA4EBAQFAgAAEwoGBgoTAAAB
AQEBAQcAAGM2KioiYwAAZyYqKjJzAAAGCQkJCQYAAA8SEg4CAwAABgkJCQUK
AAAPEhIOEjMAAA4JAgQJBwAAHxUEBAQOAAAbEREREQ4AABsJCQkKDAAAGxER
ERUKAAAbCgQEChsAABsRCgQEDgAAHwkEAhEfAAADAQEBAQMAAAEBAgIEBAAA
AwICAgIDAAACBQAAAAAAAAAAAAAABwAAAQIAAAAAAAAABwgOCRYAAAMCBgoK
BwAAAAYJAQkGAAAMBAYFBQ4AAAAGCQ8BDgAAAAwCBwIDAAAAAA4JCgwJBwMC
BgoKCwAAAAIAAwIHAAAAAgADAgIBAAMCEg4SEwAAAwICAgIHAAAAAD9KStsA
AAAADxISMwAAAAAGCQkGAAAAAA8SEg4CAwAAHgkJDggYAAANEgICAAAADgkG
CQcAAAACBwICBgAAAAAbEREOAAAAABsJCgQAAAAAGxEVCgAAAAAJBgYJAAAA
ABsJCQ4IBwAPCQYBDwAABgIDAwIGAAABAQEBAQEAAAMCBgYCAwAAAAoFAAAA
AAAOChsfCg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAQABAQEBAAQOBQUOBAAMAgcCAg8AAAwSBwIXDAAAEQoEDgQOBAAK
BA4BBggHAAYBAwUGBAMABQIGAQMEAwAOERUTFQ4AAAMFBwAHAAAAABQKBQoU
AAAAAAcEAAAAAAAABwAAAAAADhMVExUOAAAHAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAADBAIBBwAAAAMEBwQDAAAACgQPBAIPAAAAAAAFBQcBABYXFhQUFAAA
AAAAAQAAAAAFAgcGAQcAAAMCBwAAAAAAAgUCBwAAAAAABQoUCgUAAB4FDQUF
HgAAAAA+GQk+AAAKEQoEBAQAAAACAAIBAQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAAEg0GCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUPBQUdAAAOAQEBAQ4E
BgIEBwEDAQcABAIHAQMBBwACBQcBAwEHAAUABwEDAQcAAQIBAQEBAAACAQIC
AgIAAAIFAgICAgAABQACAgICAAAPEhcSEg8AAAoFAAsNCQAAAgQGCQkJBgAE
AgYJCQkGAAQKBgkJCQYACgUGCQkJBgAKAAYJCQkGAAAABQIFAAAADhkVFRMO
AAACBAkJCQkGAAQCCQkJCQYAAgUJCQkJBgAKAAkJCQkGAAgEEQoEBAQAAQcJ
CQcBAAAHCQUJEQ0AAAECAAYFCwAABAIABgULAAACBQAGBQsAAAoFAAYFCwAA
BQAABgULAAACBQIGBQsAAAAAHi0dMwAAAAAGAQEGAwACBAAHBQMGAAQCAAcF
AwYAAgUABwUDBgAFAAAHBQMGAAECAAICAgAAAgEAAQEBAAACBQACAgIAAAUA
AAICAgAACgUMCwkGAAAKBQADBQUAAAECBgkJBgAABAIGCQkGAAAECgYJCQYA
AAoFBgkJBgAABQAGCQkGAAAAAgAHAAIAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAABQAACQkGAAAEAgAJCQ4IBwABBwkJBwEACgAACQkOCAc=
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/symbol-12.sqf.__mime.



















































































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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 symbol-12.sqf
DAkDAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYGBgYGBgcG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAADgEPys1Kx4AAAAAAB4tPy0hNSseAAAAABIhEiESIRIA
AAAABA4VBQ4UFBUOBAAAEhUKCAQCChUJAAAADBIBAQIFFQkeAAAABAQAAAAA
AAAAAAAADAICAgICAgIMAAAABggICAgICAgGAAAAFQ4fDhUAAAAAAAAAAAAA
BAQfBAQAAAAAAAAAAAAAAAAMCAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAMAAAA
ABAQCAgEBAICAAAAAB8RMTExER8AAAAAAB8TMzMzEx8AAAAAAB8XNzc3Fx8A
AAAAAB8fPz8/Hx8AAAAABwICAAAAAAAAAAAABwICAAAAAAEBAAAABwICAAAE
BAUFAAAABwICEBAUFBUVAAAADhEREQ4REREOAAAADhERER4QEBAQAAAAAAAA
ACo9Ly0tAAAAAAAAACs9KykpAAAAAA4VHTEuKiI+AAAAAAAAAA4ADgAAAAAA
AAIECBAIBAIAAAAADhEQEAgEBAAEAAAADhEVFRUVHQEeAAAAAAAADBISDAAA
AAAAAAAAHhISHgAAAAAAAAAAHxEKBAAAAAAAAAAABAoRHwAAAAAAAAAYFBIU
GAAAAAAAAAAGChIKBgAAAAAAAAARCgQKEQAAAAAAAAAfERERHwAAAAAAHAgI
CAgICAgcAAAAEBAQEBAQEREOAAAAEREJBQMFCRERAAAAAQEBAQEBAQEfAAAA
GxUVERERERERAAAAERMTFRUVGRkRAAAADhEREREREREOAAAADxEREQ8BAQEB
AAAADhERERERFQkWAAAADxEREQ8JERERAAAADhEBAQ4QEBEOAAAAHwQEBAQE
BAQEAAAAEREREREREREOAAAAEREREREREhQYAAAAEREREREVFRUKAAAAEREK
BAQKERERAAAAERERCgQEBAQEAAAAHxAQCAQCAQEfAAAADgICAgICAgIOAAAA
AAEBAgIEBAgIAAAADggICAgICAgOAAAABAoRAAAAAAAAAAAAAAAAAAAAAAAf
AAAABAgAAAAAAAAAAAAAAAAADB4eDAAAAAAAAAAAHh4eHgAAAAAAAAAAHx8O
BAAAAAAAAAAABA4fHwAAAAAAAAAYHB4cGAAAAAAAAAAGDh4OBgAAAAAAAAAb
Hw4fGwAAAAAAAAAfFR8VHwAAAAAAAAAEAAQEBAQEAAAAAAAIAAgICAgIBAAA
AAEBEREPERERAAAAAAQEBAQEBAQEAAAAAAAAAA8VFRUVAAAAAAAAAA8RERER
AAAAAAAAAA4REREOAAAAAAAAAA8REREPAQEAAAAAAB4REREeEBAAAAAAABwC
AgICAAAAAAAAAB4BDhAPAAAAAAAEBA4EBAQYAAAAAAAAABEREREOAAAAAAAA
ABEREhQYAAAAAAAAABERFRUKAAAAAAAAABEKBAoRAAAAAAAAABERER4QEA8A
AAAAAB8IBAIfAAAACAQEBAIEBAQIAAAACAgICAgICAgIAAAAAgQEBAgEBAQC
AAAAABYJAAAAAAAAAAAADB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIHAAAAAAAA
AAIHAAIHAAAAAAIHAAIHAAIHAAAAOBAAAAAAAAAAAAAAOBAAAAAAAAIHAAAA
OBAAAAIHAAIHAAAAOBIHAAIHAAIHAAAAOBAAOBAAAAAAAAAAOBAAOBAAAAIH
AAAAOBAAOBIHAAIHAAAAOBIHOBIHAAIHAAAAOBAAOBAAOBAAAAAAcCAAcCAA
cCIHAAAAOBAAOBIHOBIHAAAAOBIHOBIHOBIHAAAAAAAEBB8EBB8AAAAADAAI
AAwAAAAAAAAADAAIAAwAAAAAAAAACgQfEAgEAgEfAAAAAAAAAAAREREPAQEA
FhcXFhQUFBQUAAAAAAAAAAwMAAAAAAAACgQAAB4QDAIeAAAADAgIHAAAAAAA
AAAACBQIABwAAAAAAAAAAAUKFCgUCgUAAAAAHgUFBQ0FBQUeAAAAAAAAABoV
DQUaAAAAChEREQoEBAQEAAAAAAAEAAQEAgEREQ4AAgQADhERHxERAAAACAQA
DhERHxERAAAABAoADhERHxERAAAAFgkADhERHxERAAAACgAADhERHxERAAAA
BAoEDhERHxERAAAAHgUFBQ8FBQUdAAAAAB4BAQEBAQEeBAYAAgQAHgIOAgIe
AAAABAIAHgIOAgIeAAAABAoAHgIOAgIeAAAACgAAHgIOAgIeAAAAAgQABAQE
BAQEAAAACAQABAQEBAQEAAAABAoABAQEBAQEAAAACgAABAQEBAQEAAAADhIS
EhcSEhIOAAAAFgkAExMVFRkZAAAAAgQADhEREREOAAAACAQADhEREREOAAAA
BAoADhEREREOAAAAFgkADhEREREOAAAACgAADhEREREOAAAAAAAAEQoEChEA
AAAADhkZFRUVExMOAAAAAgQAEREREREOAAAACAQAEREREREOAAAABAoAERER
EREOAAAACgAAEREREREOAAAACAQAEREKBAQEAAAAAQEPERERDwEBAAAADhER
CQUJERENAAAAAAIEAA4REREuAAAAAAgEAA4REREuAAAAAAQKAA4REREuAAAA
ABYJAA4REREuAAAAAAAKAA4REREuAAAABAoEAA4REREuAAAAAAAAAAsUDgUa
AAAAAAAAAB4BAQEeBAYAAAQIABwSDgIcAAAAABAIABwSDgIcAAAAAAgUABwS
DgIcAAAAAAAUABwSDgIcAAAAAAACBAAEBAQEAAAAAAAIBAAEBAQEAAAAAAAE
CgAEBAQEAAAAAAAACgAEBAQEAAAAAAAYBwoREREOAAAAAAAWCQAPERERAAAA
AAAECAAMEhIMAAAAAAAIBAAMEhIMAAAAAAAECgAMEhIMAAAAAAAUCgAMEhIM
AAAAAAAAFAAMEhIMAAAAAAAABAAOAAQAAAAAAAAAAA4ZFRMOAAAAAAACBAAR
EREOAAAAAAAIBAAREREOAAAAAAAECgAREREOAAAAAAAACgAREREOAAAAAAAI
BAAREREeEA8AAAABAQ8REREPAQEAAAAACgAREREeEA8A
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/symbol-16.sqf.__mime.










































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 symbol-16.sqf
EA0DAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAIHDZrb293fzYcCAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAQEAwCAj/q9Wr1YF+AAAAAH6Bvb29gZWplamVgX4AAAAkQoFC
JEKBQiRCgUIkAAAAAAg+SQkJCT5ISEk+CAAAAAAAAABDIxAIBGJhAAAAAAAA
AAAAHiEBAgRKUSFeAAAAAAAICAAAAAAAAAAAAAAAAAAAIBAIBAQEBAQIECAA
AAAAAAQIECAgICAgEAgEAAAAAAAqHD4cKgAAAAAAAAAAAAAAAAAAAAgIPggI
AAAAAAAAAAAAAAAAAAAAABAQCAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAA
AAAAGBgAAAAAAEBAICAQEAgIBAQCAAAAAAB/QUHBwcFBQX8AAAAAAAAAf0dD
x8PHQ0d/AAAAAAAAAH9fT9/P309ffwAAAAAAAAB/f3////9/f38AAAAAAAAA
QUFBQUF/QEBAQEAAAAAAAH8BAQEBf0BAQEB/AAAAAAB/AQEBAX9BQUFBfwAA
AAAAf0BAQEBAQEBAQEAAAAAAAH9BQUFBf0FBQUF/AAAAAAB/QUFBQX9AQEBA
QAAAAAAAAAAAGBgAAAAAGBgAAAAAAAAAABgYAAAAABgYEAAAAAAgEAgEAgQI
ECAAAAAAAAAAAAAAAAA+AD4AAAAAAAAAAAIECBAgEAgEAgAAAAAAAAA8QkBA
OAgICAAIAAAAAAAAfkFdVVVVVVV9AX4AAAAAAD5BQUFBf0FBQUFBAAAAAAAf
IUFBQT9BQUFBPwAAAAAAPkFBAQEBAQEBQT4AAAAAAB8hQUFBQUFBQUE/AAAA
AAB/AQEBAQ8BAQEBfwAAAAAAfwEBAQEPAQEBAQEAAAAAAD5BAQEBAXlBQUE+
AAAAAABBQUFBQX9BQUFBQQAAAAAAfwgICAgICAgICH8AAAAAAEBAQEBAQEBB
QSIcAAAAAABBIREJBQMFCREhQQAAAAAAAQEBAQEBAQEBAX8AAAAAAEFjY1VV
SUlBQUFBAAAAAABBQ0NFRUlJUVFhYQAAAAAAHCJBQUFBQUFBIhwAAAAAAB8h
QUFBIR8BAQEBAAAAAAAcIkFBQUFBQVEiXIAAAAAAHyFBQUEhHyFBQUEAAAAA
AD5BAQEBPkBAQEE+AAAAAAB/CAgICAgICAgICAAAAAAAQUFBQUFBQUFBIhwA
AAAAAEFBQUFBQUFBIhQIAAAAAABBQUFBQUFJSUlVIgAAAAAAQUEiFBQIFBQi
QUEAAAAAAEFBQSIUCAgICAgIAAAAAAB/QEAgEAgEAgEBfwAAAAAAPAQEBAQE
BAQEBDwAAAAAAAICBAQICBAQICBAAAAAAAA8ICAgICAgICAgPAAAAAgUAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAACBAAAAAAAAAAAAAAAAAAAAAA
AAAAAD5BQH5BYV4AAAAAAAEBAQE9Q0FBQUE/AAAAAAAAAAAAPkEBAQFBPgAA
AAAAQEBAQH5BQUFBQX4AAAAAAAAAAAA+QUE/AUE+AAAAAAB4BAQEHwQEBAQE
BAAAAAAAAAAAAHxCQUFBQX5AQT4AAAEBAQEfIUFBQUFBAAAAAAAAAAgADAgI
CAgIHAAAAAAAAAAQABAQEBAQEBAIBgAAAAEBAQFBIREPESEhAAAAAAAAGBAQ
EBAQEBAQOAAAAAAAAAAAADZJSUlJSUkAAAAAAAAAAAAeIUFBQUFBAAAAAAAA
AAAAHCJBQUEiHAAAAAAAAAAAAB4hQUFBQT8BAQEAAAAAAAAcIkFBQUF+QEBA
AAAAAAAAPUMBAQEBAQAAAAAAAAAAAD5BAT5AQT4AAAAAAAAICAg+CAgICAgw
AAAAAAAAAAAAQUFBQUFBPgAAAAAAAAAAAEFBQSIiFAgAAAAAAAAAAABBQUEq
KhQUAAAAAAAAAAAAQSIUCBQiQQAAAAAAAAAAAEFBQUFBQX5AIB8AAAAAAAB/
QCAYBgF/AAAAAAA4BAQEBAIEBAQEOAAAAAAACAgICAgICAgICAgAAAAAABwg
ICAgQCAgICAcAAAAAAAAAEY5AAAAAAAAAAAAAAAACBw2a29vd382HAgAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgICAgI
CAgAAAAAAAgIPkkJCQlJPggIAAAAOEQEBB4EBAQEBH4AAAAAADhEAgIPAg8C
AkQ4AAAAAABBQUEiFAg+CD4ICAAAABQIAD5BAQE+QEBAQT4AAAAAAAA8QgI8
QkI8QEI8AAAAAAAAFAgAPkEBPkBBPgAAAAAAHCJBWUVFRVlBIhwAAAAMEBwU
HAAcAAAAAAAAAAAAAAAAUCgUCgUKFChQAAAAAAAAAAAAAAA+ICAAAAAAAAAA
AAAAAAA8AAAAAAAAAAAAAAAcIkFdVU1VVUEiHAAAAD4AAAAAAAAAAAAAAAAA
AAAIFAgAAAAAAAAAAAAAAAAAAAAAAAgIPggIAD4AAAAAAAwQCAQcAAAAAAAA
AAAAAAAMEAgQDAAAAAAAAAAAAAAAFAgAf0BAIBAIBAIBfwAAAAAAAAAAAABB
QUFBQT8BAQAAAC4vLy8uKCgoKCgoAAAAAAAAAAAAGBgAAAAAAAAAAAAAABQI
AD8gGAYBAT8AAAAMCAgIHAAAAAAAAAAAAAAACBQIABwAAAAAAAAAAAAAAAAA
AAUKFChQKBQKBQAAAAAAAHwKCQkJOQkJCQp8AAAAAAAAAAAANklJOQlJNgAA
AAAUAEFBQSIUCAgICAgAAAAAAAAAAAgACAgGAQEBIR4ABAgAHCJBQUF/QUFB
QQAAABAIABwiQUFBf0FBQUEAAAAUABwiQUFBf0FBQUFBAAAAJhkAHCJBQUF/
QUFBQQAAAAAUABwiQUFBf0FBQUEAAAAIFAgcIkFBQX9BQUFBAAAAAAB4DAoJ
CT8JCQkJeQAAAAAAPEIBAQEBAQEBQjwIDAAECAB/AQEBHwEBAQF/AAAAEAgA
fwEBAR8BAQEBfwAAAAgUAH8BAQEfAQEBAX8AAAAAFAB/AQEBHwEBAQF/AAAA
BAgAfwgICAgICAgIfwAAABAIAH8ICAgICAgICH8AAAAIFAB/CAgICAgICAh/
AAAAABQAfwgICAgICAgIfwAAAAAAHyFBQUFHQUFBQT8AAAAmGQBBQ0VFSUlR
UWFhAAAABAgAHCJBQUFBQUEiHAAAABAIABwiQUFBQUFBIhwAAAAIFAAcIkFB
QUFBQSIcAAAAJhkAHCJBQUFBQUEiHAAAAAAUABwiQUFBQUFBIhwAAAAAAAAA
IhQIFCIAAAAAAAAAAABcIlFJSUlJSUUiHQAAAAQIAEFBQUFBQUFBIhwAAAAQ
CABBQUFBQUFBQSIcAAAACBQAQUFBQUFBQUEiHAAAAAAUAEFBQUFBQUFBIhwA
AAAQCABBQSIUCAgICAgIAAAAAAACAj5CQkI+AgICAgAAAAAADhEhIRkFOUFB
QT0AAAAAAAAECAA+QUB+QWFeAAAAAAAAEAgAPkFAfkFhXgAAAAAAAAgUAD5B
QH5BYV4AAAAAAAAsEgA+QUB+QWFeAAAAAAAAABQAPkFAfkFhXgAAAAAAAAgU
CBwiIDwiMiwAAAAAAAAAAAA2SUg+CUk2AAAAAAAAAAAAPEIBAQFCPAgMAAAA
AAQIAD5BQT8BQT4AAAAAAAAQCAA+QUE/AUE+AAAAAAAABAoAPkFBPwFBPgAA
AAAAAAAUAD5BQT8BQT4AAAAAAAAECAAMCAgICAg+AAAAAAAAEAgADAgICAgI
PgAAAAAAAAgUAAwICAgICD4AAAAAAAAUAAAMCAgICAg+AAAAAAAANgkUPkFB
QUFBPgAAAAAAACwSAB4hQUFBQUEAAAAAAAAECAA+QUFBQUE+AAAAAAAAEAgA
PkFBQUFBPgAAAAAAAAQIAD5BQUFBQT4AAAAAAAAECAA+QUFBQUE+AAAAAAAA
BAgAPkFBQUFBPgAAAAAAAAAIAD4ACAAAAAAAAAAAAAAAAABeIVFJRUI9AAAA
AAAAAAQIAEFBQUFBPgAAAAAAAAAIBABBQUFBQT4AAAAAAAAACBQAQUFBQUE+
AAAAAAAAABAIAEFBQUFBPgAAAAAAAAAQCABBQUFBQX5AQD8AAAABAQE9Q0FB
QUM9AQEBAAAAAAAUAEFBQUFBfkBAPw==
====

Added modules/midp-lcdui/src/main/resources/cc/squirreljme/runtime/lcdui/font/symbol-8.sqf.__mime.




























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 644 symbol-8.sqf
CAYCAQUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDhsVFxsOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAABAQEBAAEAAAKCgAAAAAAAAofCgofCgAABA4FDhQO
AAAACQwGAwkAAAYJAgUJFgAABAQAAAAAAAAEAgICAgQAAAQICAgIBAAAFQ4V
AAAAAAAAAAQOBAAAAAAAAAAABAQAAAAADgAAAAAAAAAAAAQAAAgEBAICAQAA
BgkNCwkGAAAGBAQEBA4AAA8IDwEBDwAADwgOCAgPAAAJCQ8ICAgAAA8BDwgI
DwAADwEPCQkPAAAPCAgICAgAAA8JDwkJDwAADwkPCAgIAAAAAAQAAAQAAAAA
BAAABAQAAAgEAgQIAAAAAA4ADgAAAAACBAgEAgAABgkIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAOAQEBAQ4AAAcJCQkJBwAADwEBBwEPAAAPAQEH
AQEAAA4BAQ0JBgAACQkJDwkJAAAOBAQEBA4AAAwICAgJBgAACQkFAwUJAAAB
AQEBAQ8AABEbFREREQAACQsLDQ0JAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAADgQEBAQEAAAJCQkJCQYAAAkJCQkKBAAAERER
ERUKAAAJCQkGCQkAAAkJCQYEBAAADwgIBgEPAAAOAgICAg4AAAECAgQECAAA
DggICAgOAAAEChEAAAAAAAAAAAAAHwAAAgQAAAAAAAAADwgPCQ4AAAEBBwkJ
BwAAAAAOAQEOAAAICA4JCQ4AAAAGCQ8BDgAAAA4CBwICAAAADgkJCQ4IBwAB
AQcJCQAABAAGBAQOAAAEAAQEBAQEAwABCQkHCQAABgQEBAQOAAAACxUVFRUA
AAAHCQkJCQAAAAYJCQkGAAAABwkJCQcBAQAOCQkJDggIAAYJAQEBAAAADgEG
CAcAAAACDgICDAAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAADgIDAwIOAAAEBAQEBAQAAAcEDAwEBwAAAAAWCQAA
AAAOGxUXGw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABAAEBAQEAAQOBQUOBAAMEgcCAh8AABwCBwcCHAAAEQoOBA4EAAAK
BgEGCAcAAA4BBgYIBwAACgQOAQ4HAAAOERUTFQ4AAAYOAA4AAAAAABQKBQoU
AAAAAA8IAAAAAAAADgAAAAAADhMVExUOAAAPAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAAGCAQCDgAAAAYIBggGAAAACgQPBAIPAAAAAAkJCQcBABYXFxYUFAAA
AAAGBgAAAAAKBA4IBg4AAAYEBAQOAAAABAoEAA4AAAAABQoUCgUAAB4FDQUF
HgAAAB4VHQUeAAAKEQoEBAQAAAACAAIBCQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAACgUGCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUFDwUdAAAOAQEBAQ4E
BgIEDwcBDwAABAIPBwEPAAACBQ8HAQ8AAAoADwcBDwAAAgQOBAQOAAAIBA4E
BA4AAAQKDgQEDgAACgAOBAQOAAAGCgsKCgYAABYJCQsNCQAAAgQGCQkGAAAE
AgYJCQYAAAIFBgkJBgAAFgkGCQkGAAAKAAYJCQYAAAAACgQKAAAABg0NCwsG
AAACBAkJCQYAAAQCCQkJBgAABAoJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAGCQUJEQ0AAAIEBgkJFgAABAIGCQkWAAAECgYJCRYAABYJBgkJFgAA
CgAGCQkWAAAGCQYJCRYAAAAAHhUNHgAAAAAOAQEOBAYCBA4JBw4AAAQCDgkH
DgAABAoGCQcOAAAKAAYJBw4AAAIEAAQEBAAACAQABAQEAAAECgAEBAQAAAAK
AAQEBAAACgUGDQkGAAAWCQYJCQkAAAIEBgkJBgAABAIGCQkGAAAECgYJCQYA
ABYJBgkJBgAACgAGCQkGAAAABAAfAAQAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAACgAACQkGAAAIBAAJCQ4IBwAAAQcJCQcBCgAACQkOCAc=
====

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

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that the display works.
 *
 * @since 2018/11/12
 */
public class TestDisplay
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/12
	 */
	@Override
	public void test()
	{
		__Utils__.getDisplay();
	}
}

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

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.InputStream;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that the fonts load.
 *
 * @since 2018/11/25
 */
public class TestFont
	extends TestRunnable
{
	/** The fonts to test reading. */
	private static final String[] _FONTS =
		{
			"monospace-8.sqf",
			"monospace-12.sqf",
			"monospace-16.sqf",
			"sansserif-8.sqf",
			"sansserif-12.sqf",
			"sansserif-16.sqf",
			"serif-8.sqf",
			"serif-12.sqf",
			"serif-16.sqf",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public void test()
	{
		for (String s : _FONTS)
			try (InputStream in = SQFFont.class.getResourceAsStream(s))
			{
				// Try to read
				SQFFont f = SQFFont.read(in);
				
				// Did read
				this.secondary(s, true);
			}
			catch (Throwable t)
			{
				this.secondary(s, t);
				
				t.printStackTrace();
			}
	}
}

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

import javax.microedition.lcdui.Display;
import net.multiphasicapps.tac.InvalidTestException;
import net.multiphasicapps.tac.UntestableException;

/**
 * Utilities for the LCDUI tests.
 *
 * @since 2019/03/04
 */
final class __Utils__
{
	/**
	 * Attempts to obtain the display, otherwise the test cannot be ran.
	 *
	 * @return The display to use.
	 * @throws InvalidTestException If the display could not be obtained.
	 * @since 2019/03/04
	 */
	public static final Display getDisplay()
		throws InvalidTestException
	{
		try
		{
			return Display.getDisplays(0)[0];
		}
		
		// No display possible?
		catch (Throwable e)
		{
			throw new UntestableException(e);
		}
	}
}

Added modules/midp-lcdui/src/test/java/display/TestDisplayInitialize.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 display;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Not Described
 *
 * @since 2020/02/29
 */
public class TestDisplayInitialize
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2020/02/29
	 */
	@Override
	public void test()
	{
		Display display = Display.getDisplay(this);
		
		display.setCurrent(new __BlankCanvas__());
	}
	
	/**
	 * Blank canvas, needed because the display appears when a displayable is
	 * added.
	 *
	 * @since 2020/02/29
	 */
	private static final class __BlankCanvas__
		extends Canvas
	{
		/**
		 * Initialization.
		 *
		 * @since 2020/02/29
		 */
		__BlankCanvas__()
		{
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2020/02/29
		 */
		@Override
		protected void paint(Graphics __g)
		{
			// Does nothing
		}
	}
}

Added modules/midp-lcdui/src/test/resources/TestDisplay.in.




1
2
3
+
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/midp-lcdui/src/test/resources/TestFont.in.













1
2
3
4
5
6
7
8
9
10
11
12
+
+
+
+
+
+
+
+
+
+
+
+
result: NoResult
thrown: NoExceptionThrown
secondary-monospace--16-dsqf: true
secondary-monospace--12-dsqf: true
secondary-monospace--8-dsqf: true
secondary-sansserif--16-dsqf: true
secondary-sansserif--12-dsqf: true
secondary-sansserif--8-dsqf: true
secondary-serif--16-dsqf: true
secondary-serif--12-dsqf: true
secondary-serif--8-dsqf: true

Added modules/midp-lcdui/src/test/resources/display/TestDisplayInitialize.in.



1
2
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/opengles/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains the base support needed " +
	"for OpenGL ES 1.1 functionality defined by JSR 239."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "EJ"
	swmType = JavaMEMidletType.API
	swmName = "OpenGL ES"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:midp-lcdui")
}

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

package cc.squirreljme.runtime.opengles;

import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.CanvasItem;

/**
 * This represents a display used by the OpenGL rasterizer.
 *
 * @since 2016/10/10
 */
public class DefaultDisplay
	extends EGLDisplay
{
	/** The native display object. */
	protected final Object nativedisplay;
	
	/** Was this display initialized? */
	volatile boolean _initialized;
	
	/**
	 * Initializes the OpenGL ES display.
	 *
	 * @param __nd The native display to use.
	 * @throws IllegalArgumentException If the native display is not of a
	 * compatible type.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/10
	 */
	public DefaultDisplay(Object __nd)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__nd == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EJ01 The specified class type cannot be used
		// as a display for OpenGL ES graphics. (The class type)}
		if (!(__nd instanceof Canvas || __nd instanceof CanvasItem))
			throw new IllegalArgumentException(String.format("EJ01 %s",
				__nd.getClass()));
		
		// Set
		this.nativedisplay = __nd;
	}
}

Added modules/opengles/src/main/java/cc/squirreljme/runtime/opengles/DefaultEGL.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.opengles;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;

/**
 * This is the SquirrelJME implementation of OpenGL ES which provides access
 * to implemented rasterizers via the service interface.
 *
 * @since 2016/10/10
 */
public class DefaultEGL
	implements EGL11
{
	/** The start of temporary enumerants. */
	public static final int TEMPORARY_ENUMERANT_START =
		24576;
	
	/** The end of temporary enumerants. */
	public static final int TEMPORARY_ENUMERANT_END =
		32767;
	
	/** The start of the SquirrelJME enumerant. */
	public static final int SQUIRRELJME_ENUMERANT_START =
		DefaultEGL.TEMPORARY_ENUMERANT_START;
	
	/** The end of the SquirrelJME enumerant. */
	public static final int SQUIRRELJME_ENUMERANT_END =
		DefaultEGL.SQUIRRELJME_ENUMERANT_START + 16;
	
	/** The OpenGL ES error code. */
	private volatile int _error =
		EGL11.EGL_SUCCESS;
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglBindTexImage(EGLDisplay __a, EGLSurface __b, 
		int __c)
	{
		throw new todo.TODO();
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglChooseConfig(EGLDisplay __disp, int[] __attrl,
		EGLConfig[] __confs, int __confssize, int[] __numconf)
		throws IllegalArgumentException
	{
		// If null, then it defaults to not caring about anything
		if (__attrl == null)
			__attrl = new int[]{EGL10.EGL_NONE};
		
		// {@squirreljme.error EJ02 No display was specified for choosing a
		// configuration.}
		if (__disp == null)
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ02");
		}
		
		// Configuration must be set
		if (__numconf == null)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			return false;
		}
		
		// {@squirreljme.error EJ03 The array containing the number of
		// configurations written has a length of zero.}
		if (__numconf.length < 1)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ03");
		}
		
		// {@squirreljme.error EJ04 Requested more configurations than what
		// may be output.}
		if (__confs != null && __confs.length < __confssize)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ04");
		}
		
		// Must be a SquirrelJME display
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			return false;
		}
		
		// Must be initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		if (!dd._initialized)
		{
			this._error = EGL10.EGL_NOT_INITIALIZED;
			return false;
		}
		
		// Find the end of the list
		int end = 0, atn = __attrl.length;
		for (int i = 0; i < atn; i++, end++)
			if (__attrl[i] == EGL10.EGL_NONE)
				break;
		
		// {@squirreljme.error EJ05 The attribute list does not end with
		// EGL_NONE.}
		if (end >= atn)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ05");
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglCopyBuffers(EGLDisplay __a, EGLSurface __b, 
		Object __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLContext eglCreateContext(EGLDisplay __a, EGLConfig __b
		, EGLContext __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreatePbufferSurface(EGLDisplay __a, 
		EGLConfig __b, int[] __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreatePixmapSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreateWindowSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglDestroyContext(EGLDisplay __a, EGLContext __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglDestroySurface(EGLDisplay __a, EGLSurface __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglGetConfigAttrib(EGLDisplay __a, EGLConfig __b,
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglGetConfigs(EGLDisplay __a, EGLConfig[] __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLContext eglGetCurrentContext()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLDisplay eglGetCurrentDisplay()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglGetCurrentSurface(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLDisplay eglGetDisplay(Object __nd)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ06 No native display was specified when
		// obtaining an OpenGL ES display.}
		if (__nd == null)
			throw new IllegalArgumentException("EJ06");
		
		// Just create a new display regardless of the native display object
		// used.
		return new DefaultDisplay(__nd);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int eglGetError()
	{
		int rv = this._error;
		this._error = EGL11.EGL_SUCCESS;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglInitialize(EGLDisplay __disp, int[] __ver)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ07 No display was specified.}
		if (__disp == null)
		{
			this._error = EGL11.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ07");
		}
		
		// {@squirreljme.error EJ08 An output version was specified, however
		// it has a length lower than two.}
		if (__ver != null && __ver.length < 2)
			throw new IllegalArgumentException("EJ08");
		
		// Not our kind of display?
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL11.EGL_BAD_DISPLAY;
			return false;
		}
		
		// Mark it as initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		dd._initialized = true;
		
		// Return version number?
		if (__ver != null)
		{
			__ver[0] = 1;
			__ver[1] = 1;
		}
		
		// Ok
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglMakeCurrent(EGLDisplay __a, EGLSurface __b, 
		EGLSurface __c, EGLContext __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglQueryContext(EGLDisplay __a, EGLContext __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/11
	 */
	@Override
	public String eglQueryString(EGLDisplay __disp, int __key)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ09 Cannot query string a null display.}
		if (__disp == null)
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ09");
		}
		
		// Must be our own display
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			return null;
		}
		
		// Must be initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		if (!dd._initialized)
		{
			this._error = EGL10.EGL_NOT_INITIALIZED;
			return null;
		}
		
		// Depends on the key
		switch (__key)
		{
				// Vendor
			case EGL10.EGL_VENDOR:
				return "Stephanie Gawroriski (Multi-Phasic Applications)";
			
				// Version
			case EGL10.EGL_VERSION:
				return "1.1 SquirrelJME";
			
				// No extensions are defined
			case EGL10.EGL_EXTENSIONS:
				return "";
				
				// Unknown
			default:
				this._error = EGL10.EGL_BAD_PARAMETER;
				return null;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglQuerySurface(EGLDisplay __a, EGLSurface __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglReleaseTexImage(EGLDisplay __a, EGLSurface __b
		, int __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSurfaceAttrib(EGLDisplay __a, EGLSurface __b, 
		int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSwapBuffers(EGLDisplay __a, EGLSurface __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSwapInterval(EGLDisplay __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglTerminate(EGLDisplay __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglWaitGL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglWaitNative(int __a, Object __b)
	{
		throw new todo.TODO();
	}
}

Added modules/opengles/src/main/java/cc/squirreljme/runtime/opengles/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the base support for OpenGL ES support on SquirrelJME.
 *
 * @since 2016/10/10
 */

package cc.squirreljme.runtime.opengles;

Added modules/opengles/src/main/java/javax/microedition/khronos/egl/EGL.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;


public interface EGL
{
}


Added modules/opengles/src/main/java/javax/microedition/khronos/egl/EGL10.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

import javax.microedition.khronos.opengles.GL;

/**
 * This interface defines the standard OpenGL ES definitions and methods.
 *
 * To initialize a display, {@link #eglGetDisplay(Object)} must be called
 * where the {@link Object} is an instance of
 * {@link javax.microedition.lcdui.Display}.
 *
 * OpenGL ES is utilized by calling
 * {@link EGL10#eglCreateWindowSurface(EGLDisplay, EGLConfig, Object, int[])}.
 * The {@link Object} parameter in this call represents a native surface to
 * draw onto. In this case, it is an instance of
 * {@link javax.microedition.lcdui.Graphics}.
 */
public interface EGL10
	extends EGL
{
	/**
	 * The minimum size in bits that the alpha buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	int EGL_ALPHA_SIZE =
		12321;
	
	int EGL_BAD_ACCESS =
		12290;
	
	int EGL_BAD_ALLOC =
		12291;
	
	int EGL_BAD_ATTRIBUTE =
		12292;
	
	int EGL_BAD_CONFIG =
		12293;
	
	int EGL_BAD_CONTEXT =
		12294;
	
	int EGL_BAD_CURRENT_SURFACE =
		12295;
	
	/** This is an error specifying that the given display is not valid. */
	int EGL_BAD_DISPLAY =
		12296;
	
	int EGL_BAD_MATCH =
		12297;
	
	int EGL_BAD_NATIVE_PIXMAP =
		12298;
	
	int EGL_BAD_NATIVE_WINDOW =
		12299;
	
	int EGL_BAD_PARAMETER =
		12300;
	
	int EGL_BAD_SURFACE =
		12301;
	
	/**
	 * The minimum size in bits that the blue buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	int EGL_BLUE_SIZE =
		12322;
	
	/**
	 * Attribute for the minimum desired size of the color buffer.
	 *
	 * Default 0.
	 */
	int EGL_BUFFER_SIZE =
		12320;
	
	/**
	 * Configurations may have caveats, as such this allows conifgurations
	 * with caveats to be selected.
	 *
	 * May be either {@link #EGL_SLOW_CONFIG}, {@link #EGL_NONE} to use one
	 * with no caveats, {@link #EGL_NON_CONFORMANT_CONFIG}, or
	 * {@link #EGL_DONT_CARE} if it does not matter.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_CONFIG_CAVEAT =
		12327;
	
	/**
	 * A precomposed OpenGL ES configuration to choose, if this is specified
	 * then all other attributes are ignored. The value is implementation
	 * dependent.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_CONFIG_ID =
		12328;
	
	int EGL_CORE_NATIVE_ENGINE =
		12379;
	
	/** This is used to signify that the default display should be used. */
	Object EGL_DEFAULT_DISPLAY =
		new Object();
	
	/**
	 * The minimum size in bits that the depth buffer must be.
	 *
	 * A value of zero means to not use this buffer.
	 *
	 * Default 0.
	 */
	int EGL_DEPTH_SIZE =
		12325;
	
	int EGL_DONT_CARE =
		-1;
	
	int EGL_DRAW =
		12377;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * extensions that are available to this OpenGL ES implementation.
	 */
	int EGL_EXTENSIONS =
		12373;
	
	int EGL_FALSE =
		0;
	
	/**
	 * The minimum size in bits that the green buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	int EGL_GREEN_SIZE =
		12323;
	
	int EGL_HEIGHT =
		12374;
	
	int EGL_LARGEST_PBUFFER =
		12376;
	
	/**
	 * The exact number of buffer-levels to use, positive values mean the given
	 * number of overlay buffers and negative values are mapped to underlay
	 * buffers. Level zero is the default framebuffer of the display.
	 *
	 * Default 0.
	 */
	int EGL_LEVEL =
		12329;
	
	int EGL_MAX_PBUFFER_HEIGHT =
		12330;
	
	int EGL_MAX_PBUFFER_PIXELS =
		12331;
	
	int EGL_MAX_PBUFFER_WIDTH =
		12332;
	
	/**
	 * Specifies configurations that allow native rendering onto the surface
	 * or not. {@link #EGL_DONT_CARE} can choose any, {@link #EGL_TRUE}
	 * chooses configurations that allow native rendering, and
	 * {@link #EGL_FALSE} choose configurations that disallow native
	 * rendering.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_NATIVE_RENDERABLE =
		12333;
	
	int EGL_NATIVE_VISUAL_ID =
		12334;
	
	/**
	 * A platform specified value or {@link #EGL_DONT_CARE}.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_NATIVE_VISUAL_TYPE =
		12335;
	
	int EGL_NONE =
		12344;
	
	int EGL_NON_CONFORMANT_CONFIG =
		12369;
	
	/** An error specifying that the display has not been initialized. */
	int EGL_NOT_INITIALIZED =
		12289;
	
	/** This represents a null context. */
	EGLContext EGL_NO_CONTEXT =
		new EGLContext()
		{
			/**
			 * {@inheritDoc}
			 * @since 2016/10/10
			 */
			@Override
			public GL getGL()
			{
				// {@squirreljme.error EJ0a Cannot get the GL instance of
				// a null context.}
				throw new RuntimeException("EJ0a");
			}
		};
	
	/** This represents a null display. */
	EGLDisplay EGL_NO_DISPLAY =
		new EGLDisplay()
		{
		};
	
	/** This represents a null surface. */
	EGLSurface EGL_NO_SURFACE =
		new EGLSurface()
		{
		};
	
	/**
	 * Specifies that the surface is capable of creating pixel buffer
	 * surfaces.
	 */
	int EGL_PBUFFER_BIT =
		1;
	
	/** Specifies that the surface is capable of creating pixmap surfaces. */
	int EGL_PIXMAP_BIT =
		2;
	
	int EGL_PRESERVED_RESOURCES =
		12336;
	
	int EGL_READ =
		12378;
	
	/**
	 * The minimum size in bits that the red buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	int EGL_RED_SIZE =
		12324;
	
	/**
	 * The minimum number of samples needed in the sample buffers.
	 *
	 * Default unspecified.
	 */
	int EGL_SAMPLES =
		12337;
	
	/**
	 * The minimum number of acceptable multi-sample buffers. Configurations
	 * that are closer to this value are preferred.
	 *
	 * Default 0.
	 */
	int EGL_SAMPLE_BUFFERS =
		12338;
	
	int EGL_SLOW_CONFIG =
		12368;
	
	/**
	 * The minimum size in bits that the stencil buffer must be.
	 *
	 * A value of zero means to not use this buffer.
	 *
	 * Default 0.
	 */
	int EGL_STENCIL_SIZE =
		12326;
	
	int EGL_SUCCESS =
		12288;
	
	/**
	 * Represents the type of surface to use, this is a bitmask. The valid
	 * bits are {@link #EGL_WINDOW_BIT}, {@link #EGL_PBUFFER_BIT}, and
	 * {@link #EGL_PIXMAP_BIT}.
	 *
	 * Default {@link #EGL_WINDOW_BIT}.
	 */
	int EGL_SURFACE_TYPE =
		12339;
	
	/**
	 * The transparent blue channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_TRANSPARENT_BLUE_VALUE =
		12341;
	
	/**
	 * The transparent green channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_TRANSPARENT_GREEN_VALUE =
		12342;
	
	/**
	 * The transparent red channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	int EGL_TRANSPARENT_RED_VALUE =
		12343;
	
	int EGL_TRANSPARENT_RGB =
		12370;
	
	/**
	 * The type of transparent framebuffer to use.
	 *
	 * May be {@link #EGL_NONE} then opaque framebuffers are used, otherwise
	 * {@link #EGL_TRANSPARENT_RGB} specifies that transparent framebuffers
	 * are used.
	 *
	 * Transparent framebuffers might not be supported.
	 *
	 * Default {@link #EGL_NONE}.
	 */
	int EGL_TRANSPARENT_TYPE =
		12340;
	
	int EGL_TRUE =
		1;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * OpenGL ES vendor.
	 */
	int EGL_VENDOR =
		12371;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * OpenGL ES version in the form of {@code major.minor vendor-specific}.
	 */
	int EGL_VERSION =
		12372;
	
	int EGL_WIDTH =
		12375;
	
	/** Supports creation of window surfaces. */
	int EGL_WINDOW_BIT =
		4;
	
	/**
	 * This returns an array of framebuffer configurations that match the
	 * given input attributes.
	 *
	 * This method attempts to match all of the attributes that were specified.
	 * All attributes start with a key and is followed by a value.
	 *
	 * If the attribute list is {@code null} or has {@link #EGL_NONE} as the
	 * first entry then all defaults are chosen and default selection is
	 * performed.
	 *
	 * Some values must match exactly while others may be bound to be at least
	 * or at most the given value.
	 *
	 * The possible values are:
	 * {@link #EGL_BUFFER_SIZE},
	 * {@link #EGL_RED_SIZE},
	 * {@link #EGL_GREEN_SIZE},
	 * {@link #EGL_BLUE_SIZE},
	 * {@link #EGL_CONFIG_CAVEAT},
	 * {@link #EGL_CONFIG_ID},
	 * {@link #EGL_DEPTH_SIZE},
	 * {@link #EGL_LEVEL},
	 * {@link #EGL_NATIVE_RENDERABLE},
	 * {@link #EGL_NATIVE_VISUAL_TYPE},
	 * {@link #EGL_SAMPLE_BUFFERS},
	 * {@link #EGL_STENCIL_SIZE},
	 * {@link #EGL_SURFACE_TYPE},
	 * {@link #EGL_TRANSPARENT_TYPE},
	 * {@link #EGL_TRANSPARENT_RED_VALUE},
	 * {@link #EGL_TRANSPARENT_GREEN_VALUE},
	 * {@link #EGL_TRANSPARENT_BLUE_VALUE},
	 * {@link EGL11#EGL_BIND_TO_TEXTURE_RGB},
	 * {@link EGL11#EGL_BIND_TO_TEXTURE_RGBA},
	 * {@link EGL11#EGL_MAX_SWAP_INTERVAL},
	 * {@link EGL11#EGL_MIN_SWAP_INTERVAL}
	 *
	 * Conifgurations are sorted in the following order:
	 *
	 * 1. {@link #EGL_CONFIG_CAVEAT} with the order: {@link #EGL_NONE},
	 *    {@link #EGL_SLOW_CONFIG}, then {@link #EGL_NON_CONFORMANT_CONFIG}.
	 * 2. The number of bits for the red, green, blue, and alpha channels,
	 *    higher is better. If the value is zero or {@link #EGL_DONT_CARE} then
	 *    it is not considered.
	 * 3. Smaller {@link #EGL_BUFFER_SIZE}.
	 * 4. Smaller {@link #EGL_SAMPLE_BUFFERS}.
	 * 5. Smaller {@link #EGL_DEPTH_SIZE}.
	 * 6. Smaller {@link #EGL_STENCIL_SIZE}.
	 * 7. Platform dependent {@link #EGL_NATIVE_VISUAL_TYPE}.
	 * 8. Smaller {@link #EGL_CONFIG_ID}.
	 * 9. Other attributes are not considered.
	 *
	 * The following errors are set:
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not valid.
	 * {@link #EGL_BAD_ATTRIBUTE} if an attribute is not valid.
	 * {@link #EGL_NOT_INITIALIZED} if the display is not initialized.
	 * {@link #EGL_BAD_PARAMETER} if {@code __numconf} is {@code null}.
	 *
	 * @param __disp The display to get a configuration for.
	 * @param __attrl The attributes to return a matching configuration for,
	 * must end with {@link #EGL_NONE}.
	 * @param __confs The output configuration array, if {@code null} then
	 * this returns the number of matching configurations.
	 * @param __confssize The number of configurations to write at the most.
	 * @param __numconf The number of configurations that were placed in the
	 * output configuration array.
	 * @return {@code true} if a configuration was found and no errors were
	 * generated. If {@code false} then the input arguments are not modified.
	 * @throws IllegalArgumentException If no display was specified; If the
	 * attribute list is not terminated with {@link #EGL_NONE}; If the
	 * configurations were not null and the array length is shorter than the
	 * specified size; The number of configurations is not null and the length
	 * is zero.
	 * @since 2016/10/11
	 */
	boolean eglChooseConfig(EGLDisplay __disp, int[] __attrl,
		EGLConfig[] __confs, int __confssize, int[] __numconf)
		throws IllegalArgumentException;
	
	boolean eglCopyBuffers(EGLDisplay __a, EGLSurface __b, Object __c);
	
	EGLContext eglCreateContext(EGLDisplay __a, EGLConfig __b, EGLContext __c,
		int[] __d);
	
	EGLSurface eglCreatePbufferSurface(EGLDisplay __a, EGLConfig __b,
		int[] __c);
	
	EGLSurface eglCreatePixmapSurface(EGLDisplay __a, EGLConfig __b,
		Object __c, int[] __d);
	
	EGLSurface eglCreateWindowSurface(EGLDisplay __a, EGLConfig __b,
		Object __c, int[] __d);
	
	boolean eglDestroyContext(EGLDisplay __a, EGLContext __b);
	
	boolean eglDestroySurface(EGLDisplay __a, EGLSurface __b);
	
	boolean eglGetConfigAttrib(EGLDisplay __a, EGLConfig __b, int __c,
		int[] __d);
	
	boolean eglGetConfigs(EGLDisplay __a, EGLConfig[] __b, int __c,
	 int[] __d);
	
	EGLContext eglGetCurrentContext();
	
	EGLDisplay eglGetCurrentDisplay();
	
	EGLSurface eglGetCurrentSurface(int __a);
	
	/**
	 * This creates a connection to the given native display.
	 *
	 * If the return of this method succeeds, then the display must be
	 * initialized by calling {@link #eglInitialize(EGLDisplay, int[])}.
	 *
	 * No error code is set.
	 *
	 * @param __nd The native display object to use, in SquirrelJME this will
	 * be an instance of {@link javax.microedition.lcdui.Display}. This may
	 * be {@link #EGL_DEFAULT_DISPLAY} to use the default display.
	 * @return The OpenGL ES Display for the given native display, or
	 * {@code EGL_NO_DISPLAY} is returned on error.
	 * @throws IllegalArgumentException If {@code __nd} is {@code null} or is
	 * not compatible with the OpenGL ES backend.
	 * @since 2016/10/10
	 */
	EGLDisplay eglGetDisplay(Object __nd)
		throws IllegalArgumentException;
	
	/**
	 * Returns the last error code that was emitted from the last operation
	 * that was called.
	 *
	 * After the call, it is reset to {@link #EGL_SUCCESS}.
	 *
	 * @return The error code.
	 * @since 2016/10/11
	 */
	int eglGetError();
	
	/**
	 * Initializes the OpenGL ES display and optionally returns the version
	 * number of OpenGL ES.
	 *
	 * If a display is already initialized then the version numbers are
	 * returned.
	 *
	 * If initialization fails, {@code false} is returned and the following
	 * errors may be set.
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not an EGL display
	 * connection.
	 * {@link #EGL_NOT_INITIALIZED} if initialization could not occur.
	 *
	 * {@link #eglTerminate(EGLDisplay)} is used to deinitialize a display
	 * and terminate the connection.
	 *
	 * @param __disp The display to initialize.
	 * @param __ver An optional array of at least length 2 where the first
	 * element is set to the major version number and the second element is set
	 * to the minor version number.
	 * @return {@code true} on success.
	 * @throws IllegalArgumentException If {@code __disp} is {@code null} or
	 * {@code __ver} is non-null and has a length lower than two.
	 * @since 2016/10/11
	 */
	boolean eglInitialize(EGLDisplay __disp, int[] __ver)
		throws IllegalArgumentException;
	
	boolean eglMakeCurrent(EGLDisplay __a, EGLSurface __b, EGLSurface __c,
		EGLContext __d);
	
	boolean eglQueryContext(EGLDisplay __a, EGLContext __b, int __c,
	 int[] __d);
	
	/**
	 * Queries an implementation specific string from the specified display.
	 *
	 * Valid keys are: {@link #EGL_VENDOR}, {@link #EGL_VERSION}, and
	 * {@link #EGL_EXTENSIONS}.
	 *
	 * The following errors may be set:
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not valid.
	 * {@link #EGL_NOT_INITIALIZED} if the display is not initialized.
	 * {@link #EGL_BAD_PARAMETER} if the name is not a valid value.
	 *
	 * @param __disp The display to query.
	 * @param __key The key value to obtain.
	 * @return The string value for the given display and variable or 
	 * {@code null} on failure.
	 * @throws IllegalArgumentException If {@code __disp} is {@code null}.
	 * @since 2016/10/11
	 */
	String eglQueryString(EGLDisplay __disp, int __key)
		throws IllegalArgumentException;
	
	boolean eglQuerySurface(EGLDisplay __a, EGLSurface __b, int __c,
	 int[] __d);
	
	boolean eglSwapBuffers(EGLDisplay __a, EGLSurface __b);
	
	boolean eglTerminate(EGLDisplay __a);
	
	boolean eglWaitGL();
	
	boolean eglWaitNative(int __a, Object __b);
}


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

package javax.microedition.khronos.egl;


public interface EGL11
	extends EGL10
{
	int EGL_BACK_BUFFER =
		12420;
	
	/**
	 * Specifies whether or not binding color buffers to RGB textures is
	 * supported. The value may be {@link EGL10#EGL_DONT_CARE},
	 * {@link EGL10#EGL_FALSE}, or {@link EGL10#EGL_TRUE}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	int EGL_BIND_TO_TEXTURE_RGB =
		12345;
	
	/**
	 * Specifies whether or not binding color buffers to RGBA textures is
	 * supported. The value may be {@link EGL10#EGL_DONT_CARE},
	 * {@link EGL10#EGL_FALSE}, or {@link EGL10#EGL_TRUE}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	int EGL_BIND_TO_TEXTURE_RGBA =
		12346;
	
	int EGL_CONTEXT_LOST =
		12302;
	
	/**
	 * The maximum value that may be passed to
	 * {@link #eglSwapInterval(EGLDisplay, int)}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	int EGL_MAX_SWAP_INTERVAL =
		12348;
	
	/**
	 * The minimum value that may be passed to
	 * {@link #eglSwapInterval(EGLDisplay, int)}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	int EGL_MIN_SWAP_INTERVAL =
		12347;
	
	int EGL_MIPMAP_LEVEL =
		12419;
	
	int EGL_MIPMAP_TEXTURE =
		12418;
	
	int EGL_NO_TEXTURE =
		12380;
	
	int EGL_TEXTURE_2D =
		12383;
	
	int EGL_TEXTURE_FORMAT =
		12416;
	
	int EGL_TEXTURE_RGB =
		12381;
	
	int EGL_TEXTURE_RGBA =
		12382;
	
	int EGL_TEXTURE_TARGET =
		12417;
	
	boolean eglBindTexImage(EGLDisplay __a, EGLSurface __b, int __c);
	
	boolean eglReleaseTexImage(EGLDisplay __a, EGLSurface __b, int __c);
	
	boolean eglSurfaceAttrib(EGLDisplay __a, EGLSurface __b, int __c,
	 int __d);
	
	boolean eglSwapInterval(EGLDisplay __a, int __b);
}


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

package javax.microedition.khronos.egl;

/**
 * This stores an OpenGL ES configuration.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLConfig
{
}


Added modules/opengles/src/main/java/javax/microedition/khronos/egl/EGLContext.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
66
67
68
69
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

import cc.squirreljme.runtime.opengles.DefaultEGL;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.khronos.opengles.GL;

/**
 * This class encapsulates the OpenGL context which is used to obtain instances
 * of OpenGL ES and OpenGL rasterizers.
 *
 * To create a context use {@link EGL10#eglCreateContext(EGLDisplay, EGLConfig,
 * EGLContext, int[])} method.
 *
 * To destroy a context use {@link EGL10#eglDestroyContext(EGLDisplay,
 * EGLContext)}.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLContext
{
	/** The single instance of EGL, shared by everything. */
	private static Reference<EGL> _EGL;
	
	/**
	 * Returns an instance of an object which is used to provide access to
	 * the underlying OpenGL ES rasterization API.
	 *
	 * @return The OpenGL ES rasterization API accessor.
	 * @since 2016/10/10
	 */
	public abstract GL getGL();
	
	/**
	 * This returns an instance of an object that implements the {@link EGL}
	 * interface which is used to initialize the rasterizer for drawing.
	 *
	 * @return An instance of the OpenGL ES rasterizer.
	 * @since 2016/10/10
	 */
	public static EGL getEGL()
	{
		// Get
		Reference<EGL> ref = EGLContext._EGL;
		EGL rv;
		
		// Create?
		if (ref == null || null == (rv = ref.get()))
			EGLContext._EGL = new WeakReference<>((rv = new DefaultEGL()));
		
		// Return it
		return rv;
	}
}


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

package javax.microedition.khronos.egl;

/**
 * This represents an OpenGL ES Display.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLDisplay
{
}


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

package javax.microedition.khronos.egl;

/**
 * This represents an OpenGL ES Surface.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLSurface
{
}


Added modules/opengles/src/main/java/javax/microedition/khronos/opengles/GL.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;


public interface GL
{
}


Added modules/opengles/src/main/java/javax/microedition/khronos/opengles/GL10.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

@SuppressWarnings("FieldNamingConvention")
public interface GL10
	extends GL
{
	int GL_ADD =
		260;
	
	int GL_ALIASED_LINE_WIDTH_RANGE =
		33902;
	
	int GL_ALIASED_POINT_SIZE_RANGE =
		33901;
	
	int GL_ALPHA =
		6406;
	
	int GL_ALPHA_BITS =
		3413;
	
	int GL_ALPHA_TEST =
		3008;
	
	int GL_ALWAYS =
		519;
	
	int GL_AMBIENT =
		4608;
	
	int GL_AMBIENT_AND_DIFFUSE =
		5634;
	
	int GL_AND =
		5377;
	
	int GL_AND_INVERTED =
		5380;
	
	int GL_AND_REVERSE =
		5378;
	
	int GL_BACK =
		1029;
	
	int GL_BLEND =
		3042;
	
	int GL_BLUE_BITS =
		3412;
	
	int GL_BYTE =
		5120;
	
	int GL_CCW =
		2305;
	
	int GL_CLAMP_TO_EDGE =
		33071;
	
	int GL_CLEAR =
		5376;
	
	int GL_COLOR_ARRAY =
		32886;
	
	int GL_COLOR_BUFFER_BIT =
		16384;
	
	int GL_COLOR_LOGIC_OP =
		3058;
	
	int GL_COLOR_MATERIAL =
		2903;
	
	int GL_COMPRESSED_TEXTURE_FORMATS =
		34467;
	
	int GL_CONSTANT_ATTENUATION =
		4615;
	
	int GL_COPY =
		5379;
	
	int GL_COPY_INVERTED =
		5388;
	
	int GL_CULL_FACE =
		2884;
	
	int GL_CW =
		2304;
	
	int GL_DECAL =
		8449;
	
	int GL_DECR =
		7683;
	
	int GL_DEPTH_BITS =
		3414;
	
	int GL_DEPTH_BUFFER_BIT =
		256;
	
	int GL_DEPTH_TEST =
		2929;
	
	int GL_DIFFUSE =
		4609;
	
	int GL_DITHER =
		3024;
	
	int GL_DONT_CARE =
		4352;
	
	int GL_DST_ALPHA =
		772;
	
	int GL_DST_COLOR =
		774;
	
	int GL_EMISSION =
		5632;
	
	int GL_EQUAL =
		514;
	
	int GL_EQUIV =
		5385;
	
	int GL_EXP =
		2048;
	
	int GL_EXP2 =
		2049;
	
	int GL_EXTENSIONS =
		7939;
	
	int GL_FALSE =
		0;
	
	int GL_FASTEST =
		4353;
	
	int GL_FIXED =
		5132;
	
	int GL_FLAT =
		7424;
	
	int GL_FLOAT =
		5126;
	
	int GL_FOG =
		2912;
	
	int GL_FOG_COLOR =
		2918;
	
	int GL_FOG_DENSITY =
		2914;
	
	int GL_FOG_END =
		2916;
	
	int GL_FOG_HINT =
		3156;
	
	int GL_FOG_MODE =
		2917;
	
	int GL_FOG_START =
		2915;
	
	int GL_FRONT =
		1028;
	
	int GL_FRONT_AND_BACK =
		1032;
	
	int GL_GEQUAL =
		518;
	
	int GL_GREATER =
		516;
	
	int GL_GREEN_BITS =
		3411;
	
	int GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES =
		35739;
	
	int GL_IMPLEMENTATION_COLOR_READ_TYPE_OES =
		35738;
	
	int GL_INCR =
		7682;
	
	int GL_INVALID_ENUM =
		1280;
	
	int GL_INVALID_OPERATION =
		1282;
	
	int GL_INVALID_VALUE =
		1281;
	
	int GL_INVERT =
		5386;
	
	int GL_KEEP =
		7680;
	
	int GL_LEQUAL =
		515;
	
	int GL_LESS =
		513;
	
	int GL_LIGHT0 =
		16384;
	
	int GL_LIGHT1 =
		16385;
	
	int GL_LIGHT2 =
		16386;
	
	int GL_LIGHT3 =
		16387;
	
	int GL_LIGHT4 =
		16388;
	
	int GL_LIGHT5 =
		16389;
	
	int GL_LIGHT6 =
		16390;
	
	int GL_LIGHT7 =
		16391;
	
	int GL_LIGHTING =
		2896;
	
	int GL_LIGHT_MODEL_AMBIENT =
		2899;
	
	int GL_LIGHT_MODEL_TWO_SIDE =
		2898;
	
	int GL_LINEAR =
		9729;
	
	int GL_LINEAR_ATTENUATION =
		4616;
	
	int GL_LINEAR_MIPMAP_LINEAR =
		9987;
	
	int GL_LINEAR_MIPMAP_NEAREST =
		9985;
	
	int GL_LINES =
		1;
	
	int GL_LINE_LOOP =
		2;
	
	int GL_LINE_SMOOTH =
		2848;
	
	int GL_LINE_SMOOTH_HINT =
		3154;
	
	int GL_LINE_STRIP =
		3;
	
	int GL_LUMINANCE =
		6409;
	
	int GL_LUMINANCE_ALPHA =
		6410;
	
	int GL_MAX_ELEMENTS_INDICES =
		33001;
	
	int GL_MAX_ELEMENTS_VERTICES =
		33000;
	
	int GL_MAX_LIGHTS =
		3377;
	
	int GL_MAX_MODELVIEW_STACK_DEPTH =
		3382;
	
	int GL_MAX_PROJECTION_STACK_DEPTH =
		3384;
	
	int GL_MAX_TEXTURE_SIZE =
		3379;
	
	int GL_MAX_TEXTURE_STACK_DEPTH =
		3385;
	
	int GL_MAX_TEXTURE_UNITS =
		34018;
	
	int GL_MAX_VIEWPORT_DIMS =
		3386;
	
	int GL_MODELVIEW =
		5888;
	
	int GL_MODULATE =
		8448;
	
	int GL_MULTISAMPLE =
		32925;
	
	int GL_NAND =
		5390;
	
	int GL_NEAREST =
		9728;
	
	int GL_NEAREST_MIPMAP_LINEAR =
		9986;
	
	int GL_NEAREST_MIPMAP_NEAREST =
		9984;
	
	int GL_NEVER =
		512;
	
	int GL_NICEST =
		4354;
	
	int GL_NOOP =
		5381;
	
	int GL_NOR =
		5384;
	
	int GL_NORMALIZE =
		2977;
	
	int GL_NORMAL_ARRAY =
		32885;
	
	int GL_NOTEQUAL =
		517;
	
	int GL_NO_ERROR =
		0;
	
	int GL_NUM_COMPRESSED_TEXTURE_FORMATS =
		34466;
	
	int GL_ONE =
		1;
	
	int GL_ONE_MINUS_DST_ALPHA =
		773;
	
	int GL_ONE_MINUS_DST_COLOR =
		775;
	
	int GL_ONE_MINUS_SRC_ALPHA =
		771;
	
	int GL_ONE_MINUS_SRC_COLOR =
		769;
	
	int GL_OR =
		5383;
	
	int GL_OR_INVERTED =
		5389;
	
	int GL_OR_REVERSE =
		5387;
	
	int GL_OUT_OF_MEMORY =
		1285;
	
	int GL_PACK_ALIGNMENT =
		3333;
	
	int GL_PALETTE4_R5_G6_B5_OES =
		35730;
	
	int GL_PALETTE4_RGB5_A1_OES =
		35732;
	
	int GL_PALETTE4_RGB8_OES =
		35728;
	
	int GL_PALETTE4_RGBA4_OES =
		35731;
	
	int GL_PALETTE4_RGBA8_OES =
		35729;
	
	int GL_PALETTE8_R5_G6_B5_OES =
		35735;
	
	int GL_PALETTE8_RGB5_A1_OES =
		35737;
	
	int GL_PALETTE8_RGB8_OES =
		35733;
	
	int GL_PALETTE8_RGBA4_OES =
		35736;
	
	int GL_PALETTE8_RGBA8_OES =
		35734;
	
	int GL_PERSPECTIVE_CORRECTION_HINT =
		3152;
	
	int GL_POINTS =
		0;
	
	int GL_POINT_SMOOTH =
		2832;
	
	int GL_POINT_SMOOTH_HINT =
		3153;
	
	int GL_POLYGON_OFFSET_FILL =
		32823;
	
	int GL_POLYGON_SMOOTH_HINT =
		3155;
	
	int GL_POSITION =
		4611;
	
	int GL_PROJECTION =
		5889;
	
	int GL_QUADRATIC_ATTENUATION =
		4617;
	
	int GL_RED_BITS =
		3410;
	
	int GL_RENDERER =
		7937;
	
	int GL_REPEAT =
		10497;
	
	int GL_REPLACE =
		7681;
	
	int GL_RESCALE_NORMAL =
		32826;
	
	int GL_RGB =
		6407;
	
	int GL_RGBA =
		6408;
	
	int GL_SAMPLE_ALPHA_TO_COVERAGE =
		32926;
	
	int GL_SAMPLE_ALPHA_TO_ONE =
		32927;
	
	int GL_SAMPLE_COVERAGE =
		32928;
	
	int GL_SCISSOR_TEST =
		3089;
	
	int GL_SET =
		5391;
	
	int GL_SHININESS =
		5633;
	
	int GL_SHORT =
		5122;
	
	int GL_SMOOTH =
		7425;
	
	int GL_SMOOTH_LINE_WIDTH_RANGE =
		2850;
	
	int GL_SMOOTH_POINT_SIZE_RANGE =
		2834;
	
	int GL_SPECULAR =
		4610;
	
	int GL_SPOT_CUTOFF =
		4614;
	
	int GL_SPOT_DIRECTION =
		4612;
	
	int GL_SPOT_EXPONENT =
		4613;
	
	int GL_SRC_ALPHA =
		770;
	
	int GL_SRC_ALPHA_SATURATE =
		776;
	
	int GL_SRC_COLOR =
		768;
	
	int GL_STACK_OVERFLOW =
		1283;
	
	int GL_STACK_UNDERFLOW =
		1284;
	
	int GL_STENCIL_BITS =
		3415;
	
	int GL_STENCIL_BUFFER_BIT =
		1024;
	
	int GL_STENCIL_TEST =
		2960;
	
	int GL_SUBPIXEL_BITS =
		3408;
	
	int GL_TEXTURE =
		5890;
	
	int GL_TEXTURE0 =
		33984;
	
	int GL_TEXTURE1 =
		33985;
	
	int GL_TEXTURE10 =
		33994;
	
	int GL_TEXTURE11 =
		33995;
	
	int GL_TEXTURE12 =
		33996;
	
	int GL_TEXTURE13 =
		33997;
	
	int GL_TEXTURE14 =
		33998;
	
	int GL_TEXTURE15 =
		33999;
	
	int GL_TEXTURE16 =
		34000;
	
	int GL_TEXTURE17 =
		34001;
	
	int GL_TEXTURE18 =
		34002;
	
	int GL_TEXTURE19 =
		34003;
	
	int GL_TEXTURE2 =
		33986;
	
	int GL_TEXTURE20 =
		34004;
	
	int GL_TEXTURE21 =
		34005;
	
	int GL_TEXTURE22 =
		34006;
	
	int GL_TEXTURE23 =
		34007;
	
	int GL_TEXTURE24 =
		34008;
	
	int GL_TEXTURE25 =
		34009;
	
	int GL_TEXTURE26 =
		34010;
	
	int GL_TEXTURE27 =
		34011;
	
	int GL_TEXTURE28 =
		34012;
	
	int GL_TEXTURE29 =
		34013;
	
	int GL_TEXTURE3 =
		33987;
	
	int GL_TEXTURE30 =
		34014;
	
	int GL_TEXTURE31 =
		34015;
	
	int GL_TEXTURE4 =
		33988;
	
	int GL_TEXTURE5 =
		33989;
	
	int GL_TEXTURE6 =
		33990;
	
	int GL_TEXTURE7 =
		33991;
	
	int GL_TEXTURE8 =
		33992;
	
	int GL_TEXTURE9 =
		33993;
	
	int GL_TEXTURE_2D =
		3553;
	
	int GL_TEXTURE_COORD_ARRAY =
		32888;
	
	int GL_TEXTURE_ENV =
		8960;
	
	int GL_TEXTURE_ENV_COLOR =
		8705;
	
	int GL_TEXTURE_ENV_MODE =
		8704;
	
	int GL_TEXTURE_MAG_FILTER =
		10240;
	
	int GL_TEXTURE_MIN_FILTER =
		10241;
	
	int GL_TEXTURE_WRAP_S =
		10242;
	
	int GL_TEXTURE_WRAP_T =
		10243;
	
	int GL_TRIANGLES =
		4;
	
	int GL_TRIANGLE_FAN =
		6;
	
	int GL_TRIANGLE_STRIP =
		5;
	
	int GL_TRUE =
		1;
	
	int GL_UNPACK_ALIGNMENT =
		3317;
	
	int GL_UNSIGNED_BYTE =
		5121;
	
	int GL_UNSIGNED_SHORT =
		5123;
	
	int GL_UNSIGNED_SHORT_4_4_4_4 =
		32819;
	
	int GL_UNSIGNED_SHORT_5_5_5_1 =
		32820;
	
	int GL_UNSIGNED_SHORT_5_6_5 =
		33635;
	
	int GL_VENDOR =
		7936;
	
	int GL_VERSION =
		7938;
	
	int GL_VERTEX_ARRAY =
		32884;
	
	int GL_XOR =
		5382;
	
	int GL_ZERO =
		0;
	
	void glActiveTexture(int __a);
	
	void glAlphaFunc(int __a, float __b);
	
	void glAlphaFuncx(int __a, int __b);
	
	void glBindTexture(int __a, int __b);
	
	void glBlendFunc(int __a, int __b);
	
	void glClear(int __a);
	
	void glClearColor(float __a, float __b, float __c, float __d);
	
	void glClearColorx(int __a, int __b, int __c, int __d);
	
	void glClearDepthf(float __a);
	
	void glClearDepthx(int __a);
	
	void glClearStencil(int __a);
	
	void glClientActiveTexture(int __a);
	
	void glColor4f(float __a, float __b, float __c, float __d);
	
	void glColor4x(int __a, int __b, int __c, int __d);
	
	void glColorMask(boolean __a, boolean __b, boolean __c, boolean __d);
	
	void glColorPointer(int __a, int __b, int __c, Buffer __d);
	
	void glCompressedTexImage2D(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g, Buffer __h);
	
	void glCompressedTexSubImage2D(int __a, int __b, int __c, int __d,
	 int __e,
		int __f, int __g, int __h, Buffer __i);
	
	void glCopyTexImage2D(int __a, int __b, int __c, int __d, int __e,
	 int __f,
		int __g, int __h);
	
	void glCopyTexSubImage2D(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g, int __h);
	
	void glCullFace(int __a);
	
	void glDeleteTextures(int __a, int[] __b, int __c);
	
	void glDeleteTextures(int __a, IntBuffer __b);
	
	void glDepthFunc(int __a);
	
	void glDepthMask(boolean __a);
	
	void glDepthRangef(float __a, float __b);
	
	void glDepthRangex(int __a, int __b);
	
	void glDisable(int __a);
	
	void glDisableClientState(int __a);
	
	void glDrawArrays(int __a, int __b, int __c);
	
	void glDrawElements(int __a, int __b, int __c, Buffer __d);
	
	void glEnable(int __a);
	
	void glEnableClientState(int __a);
	
	void glFinish();
	
	void glFlush();
	
	void glFogf(int __a, float __b);
	
	void glFogfv(int __a, float[] __b, int __c);
	
	void glFogfv(int __a, FloatBuffer __b);
	
	void glFogx(int __a, int __b);
	
	void glFogxv(int __a, int[] __b, int __c);
	
	void glFogxv(int __a, IntBuffer __b);
	
	void glFrontFace(int __a);
	
	void glFrustumf(float __a, float __b, float __c, float __d, float __e,
		float __f);
	
	void glFrustumx(int __a, int __b, int __c, int __d, int __e, int __f);
	
	void glGenTextures(int __a, int[] __b, int __c);
	
	void glGenTextures(int __a, IntBuffer __b);
	
	int glGetError();
	
	void glGetIntegerv(int __a, int[] __b, int __c);
	
	void glGetIntegerv(int __a, IntBuffer __b);
	
	String glGetString(int __a);
	
	void glHint(int __a, int __b);
	
	void glLightModelf(int __a, float __b);
	
	void glLightModelfv(int __a, float[] __b, int __c);
	
	void glLightModelfv(int __a, FloatBuffer __b);
	
	void glLightModelx(int __a, int __b);
	
	void glLightModelxv(int __a, int[] __b, int __c);
	
	void glLightModelxv(int __a, IntBuffer __b);
	
	void glLightf(int __a, int __b, float __c);
	
	void glLightfv(int __a, int __b, float[] __c, int __d);
	
	void glLightfv(int __a, int __b, FloatBuffer __c);
	
	void glLightx(int __a, int __b, int __c);
	
	void glLightxv(int __a, int __b, int[] __c, int __d);
	
	void glLightxv(int __a, int __b, IntBuffer __c);
	
	void glLineWidth(float __a);
	
	void glLineWidthx(int __a);
	
	void glLoadIdentity();
	
	void glLoadMatrixf(float[] __a, int __b);
	
	void glLoadMatrixf(FloatBuffer __a);
	
	void glLoadMatrixx(int[] __a, int __b);
	
	void glLoadMatrixx(IntBuffer __a);
	
	void glLogicOp(int __a);
	
	void glMaterialf(int __a, int __b, float __c);
	
	void glMaterialfv(int __a, int __b, float[] __c, int __d);
	
	void glMaterialfv(int __a, int __b, FloatBuffer __c);
	
	void glMaterialx(int __a, int __b, int __c);
	
	void glMaterialxv(int __a, int __b, int[] __c, int __d);
	
	void glMaterialxv(int __a, int __b, IntBuffer __c);
	
	void glMatrixMode(int __a);
	
	void glMultMatrixf(float[] __a, int __b);
	
	void glMultMatrixf(FloatBuffer __a);
	
	void glMultMatrixx(int[] __a, int __b);
	
	void glMultMatrixx(IntBuffer __a);
	
	void glMultiTexCoord4f(int __a, float __b, float __c, float __d,
	 float __e);
	
	void glMultiTexCoord4x(int __a, int __b, int __c, int __d, int __e);
	
	void glNormal3f(float __a, float __b, float __c);
	
	void glNormal3x(int __a, int __b, int __c);
	
	void glNormalPointer(int __a, int __b, Buffer __c);
	
	void glOrthof(float __a, float __b, float __c, float __d, float __e,
		float __f);
	
	void glOrthox(int __a, int __b, int __c, int __d, int __e, int __f);
	
	void glPixelStorei(int __a, int __b);
	
	void glPointSize(float __a);
	
	void glPointSizex(int __a);
	
	void glPolygonOffset(float __a, float __b);
	
	void glPolygonOffsetx(int __a, int __b);
	
	void glPopMatrix();
	
	void glPushMatrix();
	
	void glReadPixels(int __a, int __b, int __c, int __d, int __e, int __f,
		Buffer __g);
	
	void glRotatef(float __a, float __b, float __c, float __d);
	
	void glRotatex(int __a, int __b, int __c, int __d);
	
	void glSampleCoverage(float __a, boolean __b);
	
	void glSampleCoveragex(int __a, boolean __b);
	
	void glScalef(float __a, float __b, float __c);
	
	void glScalex(int __a, int __b, int __c);
	
	void glScissor(int __a, int __b, int __c, int __d);
	
	void glShadeModel(int __a);
	
	void glStencilFunc(int __a, int __b, int __c);
	
	void glStencilMask(int __a);
	
	void glStencilOp(int __a, int __b, int __c);
	
	void glTexCoordPointer(int __a, int __b, int __c, Buffer __d);
	
	void glTexEnvf(int __a, int __b, float __c);
	
	void glTexEnvfv(int __a, int __b, float[] __c, int __d);
	
	void glTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	void glTexEnvx(int __a, int __b, int __c);
	
	void glTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	void glTexEnvxv(int __a, int __b, IntBuffer __c);
	
	void glTexImage2D(int __a, int __b, int __c, int __d, int __e, int __f,
		int __g, int __h, Buffer __i);
	
	void glTexParameterf(int __a, int __b, float __c);
	
	void glTexParameterx(int __a, int __b, int __c);
	
	void glTexSubImage2D(int __a, int __b, int __c, int __d, int __e, int __f,
		int __g, int __h, Buffer __i);
	
	void glTranslatef(float __a, float __b, float __c);
	
	void glTranslatex(int __a, int __b, int __c);
	
	void glVertexPointer(int __a, int __b, int __c, Buffer __d);
	
	void glViewport(int __a, int __b, int __c, int __d);
}


Added modules/opengles/src/main/java/javax/microedition/khronos/opengles/GL10Ext.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;


public interface GL10Ext
	extends GL
{
	int glQueryMatrixxOES(int[] __a, int __b, int[] __c, int __d);
}


Added modules/opengles/src/main/java/javax/microedition/khronos/opengles/GL11.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

@SuppressWarnings("FieldNamingConvention")
public interface GL11
	extends GL10
{
	int GL_ACTIVE_TEXTURE =
		34016;
	
	int GL_ADD_SIGNED =
		34164;
	
	int GL_ALPHA_SCALE =
		3356;
	
	int GL_ALPHA_TEST_FUNC =
		3009;
	
	int GL_ALPHA_TEST_REF =
		3010;
	
	int GL_ARRAY_BUFFER =
		34962;
	
	int GL_ARRAY_BUFFER_BINDING =
		34964;
	
	int GL_BLEND_DST =
		3040;
	
	int GL_BLEND_SRC =
		3041;
	
	int GL_BUFFER_ACCESS =
		35003;
	
	int GL_BUFFER_SIZE =
		34660;
	
	int GL_BUFFER_USAGE =
		34661;
	
	int GL_CLIENT_ACTIVE_TEXTURE =
		34017;
	
	int GL_CLIP_PLANE0 =
		12288;
	
	int GL_CLIP_PLANE1 =
		12289;
	
	int GL_CLIP_PLANE2 =
		12290;
	
	int GL_CLIP_PLANE3 =
		12291;
	
	int GL_CLIP_PLANE4 =
		12292;
	
	int GL_CLIP_PLANE5 =
		12293;
	
	int GL_COLOR_ARRAY_BUFFER_BINDING =
		34968;
	
	int GL_COLOR_ARRAY_POINTER =
		32912;
	
	int GL_COLOR_ARRAY_SIZE =
		32897;
	
	int GL_COLOR_ARRAY_STRIDE =
		32899;
	
	int GL_COLOR_ARRAY_TYPE =
		32898;
	
	int GL_COLOR_CLEAR_VALUE =
		3106;
	
	int GL_COLOR_WRITEMASK =
		3107;
	
	int GL_COMBINE =
		34160;
	
	int GL_COMBINE_ALPHA =
		34162;
	
	int GL_COMBINE_RGB =
		34161;
	
	int GL_CONSTANT =
		34166;
	
	int GL_COORD_REPLACE_OES =
		34914;
	
	int GL_CULL_FACE_MODE =
		2885;
	
	int GL_CURRENT_COLOR =
		2816;
	
	int GL_CURRENT_NORMAL =
		2818;
	
	int GL_CURRENT_TEXTURE_COORDS =
		2819;
	
	int GL_DEPTH_CLEAR_VALUE =
		2931;
	
	int GL_DEPTH_FUNC =
		2932;
	
	int GL_DEPTH_RANGE =
		2928;
	
	int GL_DEPTH_WRITEMASK =
		2930;
	
	int GL_DOT3_RGB =
		34478;
	
	int GL_DOT3_RGBA =
		34479;
	
	int GL_DYNAMIC_DRAW =
		35048;
	
	int GL_ELEMENT_ARRAY_BUFFER =
		34963;
	
	int GL_ELEMENT_ARRAY_BUFFER_BINDING =
		34965;
	
	int GL_FRONT_FACE =
		2886;
	
	int GL_GENERATE_MIPMAP =
		33169;
	
	int GL_GENERATE_MIPMAP_HINT =
		33170;
	
	int GL_INTERPOLATE =
		34165;
	
	int GL_LINE_WIDTH =
		2849;
	
	int GL_LOGIC_OP_MODE =
		3056;
	
	int GL_MATRIX_MODE =
		2976;
	
	int GL_MAX_CLIP_PLANES =
		3378;
	
	int GL_MODELVIEW_MATRIX =
		2982;
	
	int GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES =
		35213;
	
	int GL_MODELVIEW_STACK_DEPTH =
		2979;
	
	int GL_NORMAL_ARRAY_BUFFER_BINDING =
		34967;
	
	int GL_NORMAL_ARRAY_POINTER =
		32911;
	
	int GL_NORMAL_ARRAY_STRIDE =
		32895;
	
	int GL_NORMAL_ARRAY_TYPE =
		32894;
	
	int GL_OPERAND0_ALPHA =
		34200;
	
	int GL_OPERAND0_RGB =
		34192;
	
	int GL_OPERAND1_ALPHA =
		34201;
	
	int GL_OPERAND1_RGB =
		34193;
	
	int GL_OPERAND2_ALPHA =
		34202;
	
	int GL_OPERAND2_RGB =
		34194;
	
	int GL_POINT_DISTANCE_ATTENUATION =
		33065;
	
	int GL_POINT_FADE_THRESHOLD_SIZE =
		33064;
	
	int GL_POINT_SIZE =
		2833;
	
	int GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES =
		35743;
	
	int GL_POINT_SIZE_ARRAY_OES =
		35740;
	
	int GL_POINT_SIZE_ARRAY_POINTER_OES =
		35212;
	
	int GL_POINT_SIZE_ARRAY_STRIDE_OES =
		35211;
	
	int GL_POINT_SIZE_ARRAY_TYPE_OES =
		35210;
	
	int GL_POINT_SIZE_MAX =
		33063;
	
	int GL_POINT_SIZE_MIN =
		33062;
	
	int GL_POINT_SPRITE_OES =
		34913;
	
	int GL_POLYGON_OFFSET_FACTOR =
		32824;
	
	int GL_POLYGON_OFFSET_UNITS =
		10752;
	
	int GL_PREVIOUS =
		34168;
	
	int GL_PRIMARY_COLOR =
		34167;
	
	int GL_PROJECTION_MATRIX =
		2983;
	
	int GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES =
		35214;
	
	int GL_PROJECTION_STACK_DEPTH =
		2980;
	
	int GL_RGB_SCALE =
		34163;
	
	int GL_SAMPLES =
		32937;
	
	int GL_SAMPLE_BUFFERS =
		32936;
	
	int GL_SAMPLE_COVERAGE_INVERT =
		32939;
	
	int GL_SAMPLE_COVERAGE_VALUE =
		32938;
	
	int GL_SCISSOR_BOX =
		3088;
	
	int GL_SHADE_MODEL =
		2900;
	
	int GL_SRC0_ALPHA =
		34184;
	
	int GL_SRC0_RGB =
		34176;
	
	int GL_SRC1_ALPHA =
		34185;
	
	int GL_SRC1_RGB =
		34177;
	
	int GL_SRC2_ALPHA =
		34186;
	
	int GL_SRC2_RGB =
		34178;
	
	int GL_STATIC_DRAW =
		35044;
	
	int GL_STENCIL_CLEAR_VALUE =
		2961;
	
	int GL_STENCIL_FAIL =
		2964;
	
	int GL_STENCIL_FUNC =
		2962;
	
	int GL_STENCIL_PASS_DEPTH_FAIL =
		2965;
	
	int GL_STENCIL_PASS_DEPTH_PASS =
		2966;
	
	int GL_STENCIL_REF =
		2967;
	
	int GL_STENCIL_VALUE_MASK =
		2963;
	
	int GL_STENCIL_WRITEMASK =
		2968;
	
	int GL_SUBTRACT =
		34023;
	
	int GL_TEXTURE_BINDING_2D =
		32873;
	
	int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING =
		34970;
	
	int GL_TEXTURE_COORD_ARRAY_POINTER =
		32914;
	
	int GL_TEXTURE_COORD_ARRAY_SIZE =
		32904;
	
	int GL_TEXTURE_COORD_ARRAY_STRIDE =
		32906;
	
	int GL_TEXTURE_COORD_ARRAY_TYPE =
		32905;
	
	int GL_TEXTURE_MATRIX =
		2984;
	
	int GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES =
		35215;
	
	int GL_TEXTURE_STACK_DEPTH =
		2981;
	
	int GL_VERTEX_ARRAY_BUFFER_BINDING =
		34966;
	
	int GL_VERTEX_ARRAY_POINTER =
		32910;
	
	int GL_VERTEX_ARRAY_SIZE =
		32890;
	
	int GL_VERTEX_ARRAY_STRIDE =
		32892;
	
	int GL_VERTEX_ARRAY_TYPE =
		32891;
	
	int GL_VIEWPORT =
		2978;
	
	int GL_WRITE_ONLY =
		35001;
	
	void glBindBuffer(int __a, int __b);
	
	void glBufferData(int __a, int __b, Buffer __c, int __d);
	
	void glBufferSubData(int __a, int __b, int __c, Buffer __d);
	
	void glClipPlanef(int __a, float[] __b, int __c);
	
	void glClipPlanef(int __a, FloatBuffer __b);
	
	void glClipPlanex(int __a, int[] __b, int __c);
	
	void glClipPlanex(int __a, IntBuffer __b);
	
	void glColor4ub(byte __a, byte __b, byte __c, byte __d);
	
	void glColorPointer(int __a, int __b, int __c, int __d);
	
	void glDeleteBuffers(int __a, int[] __b, int __c);
	
	void glDeleteBuffers(int __a, IntBuffer __b);
	
	void glDrawElements(int __a, int __b, int __c, int __d);
	
	void glGenBuffers(int __a, int[] __b, int __c);
	
	void glGenBuffers(int __a, IntBuffer __b);
	
	void glGetBooleanv(int __a, boolean[] __b, int __c);
	
	void glGetBooleanv(int __a, IntBuffer __b);
	
	void glGetBufferParameteriv(int __a, int __b, int[] __c, int __d);
	
	void glGetBufferParameteriv(int __a, int __b, IntBuffer __c);
	
	void glGetClipPlanef(int __a, float[] __b, int __c);
	
	void glGetClipPlanef(int __a, FloatBuffer __b);
	
	void glGetClipPlanex(int __a, int[] __b, int __c);
	
	void glGetClipPlanex(int __a, IntBuffer __b);
	
	void glGetFixedv(int __a, int[] __b, int __c);
	
	void glGetFixedv(int __a, IntBuffer __b);
	
	void glGetFloatv(int __a, float[] __b, int __c);
	
	void glGetFloatv(int __a, FloatBuffer __b);
	
	void glGetLightfv(int __a, int __b, float[] __c, int __d);
	
	void glGetLightfv(int __a, int __b, FloatBuffer __c);
	
	void glGetLightxv(int __a, int __b, int[] __c, int __d);
	
	void glGetLightxv(int __a, int __b, IntBuffer __c);
	
	void glGetMaterialfv(int __a, int __b, float[] __c, int __d);
	
	void glGetMaterialfv(int __a, int __b, FloatBuffer __c);
	
	void glGetMaterialxv(int __a, int __b, int[] __c, int __d);
	
	void glGetMaterialxv(int __a, int __b, IntBuffer __c);
	
	void glGetPointerv(int __a, Buffer[] __b);
	
	void glGetTexEnvfv(int __a, int __b, float[] __c, int __d);
	
	void glGetTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	void glGetTexEnviv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexEnviv(int __a, int __b, IntBuffer __c);
	
	void glGetTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexEnvxv(int __a, int __b, IntBuffer __c);
	
	void glGetTexParameterfv(int __a, int __b, float[] __c, int __d);
	
	void glGetTexParameterfv(int __a, int __b, FloatBuffer __c);
	
	void glGetTexParameteriv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexParameteriv(int __a, int __b, IntBuffer __c);
	
	void glGetTexParameterxv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexParameterxv(int __a, int __b, IntBuffer __c);
	
	boolean glIsBuffer(int __a);
	
	boolean glIsEnabled(int __a);
	
	boolean glIsTexture(int __a);
	
	void glNormalPointer(int __a, int __b, int __c);
	
	void glPointParameterf(int __a, float __b);
	
	void glPointParameterfv(int __a, float[] __b, int __c);
	
	void glPointParameterfv(int __a, FloatBuffer __b);
	
	void glPointParameterx(int __a, int __b);
	
	void glPointParameterxv(int __a, int[] __b, int __c);
	
	void glPointParameterxv(int __a, IntBuffer __b);
	
	void glPointSizePointerOES(int __a, int __b, int __c);
	
	void glPointSizePointerOES(int __a, int __b, Buffer __c);
	
	void glTexCoordPointer(int __a, int __b, int __c, int __d);
	
	void glTexEnvi(int __a, int __b, int __c);
	
	void glTexEnviv(int __a, int __b, int[] __c, int __d);
	
	void glTexEnviv(int __a, int __b, IntBuffer __c);
	
	void glTexParameterfv(int __a, int __b, float[] __c, int __d);
	
	void glTexParameterfv(int __a, int __b, FloatBuffer __c);
	
	void glTexParameteri(int __a, int __b, int __c);
	
	void glTexParameteriv(int __a, int __b, int[] __c, int __d);
	
	void glTexParameteriv(int __a, int __b, IntBuffer __c);
	
	void glTexParameterxv(int __a, int __b, int[] __c, int __d);
	
	void glTexParameterxv(int __a, int __b, IntBuffer __c);
	
	void glVertexPointer(int __a, int __b, int __c, int __d);
}


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

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

@SuppressWarnings({"FieldNamingConvention", "NewMethodNamingConvention"})
public interface GL11Ext
	extends GL
{
	int GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES =
		35742;
	
	int GL_MATRIX_INDEX_ARRAY_OES =
		34884;
	
	int GL_MATRIX_INDEX_ARRAY_POINTER_OES =
		34889;
	
	int GL_MATRIX_INDEX_ARRAY_SIZE_OES =
		34886;
	
	int GL_MATRIX_INDEX_ARRAY_STRIDE_OES =
		34888;
	
	int GL_MATRIX_INDEX_ARRAY_TYPE_OES =
		34887;
	
	int GL_MATRIX_PALETTE_OES =
		34880;
	
	int GL_MAX_PALETTE_MATRICES_OES =
		34882;
	
	int GL_MAX_VERTEX_UNITS_OES =
		34468;
	
	int GL_TEXTURE_CROP_RECT_OES =
		35741;
	
	int GL_WEIGHT_ARRAY_BUFFER_BINDING_OES =
		34974;
	
	int GL_WEIGHT_ARRAY_OES =
		34477;
	
	int GL_WEIGHT_ARRAY_POINTER_OES =
		34476;
	
	int GL_WEIGHT_ARRAY_SIZE_OES =
		34475;
	
	int GL_WEIGHT_ARRAY_STRIDE_OES =
		34474;
	
	int GL_WEIGHT_ARRAY_TYPE_OES =
		34473;
	
	void glCurrentPaletteMatrixOES(int __a);
	
	void glDrawTexfOES(float __a, float __b, float __c, float __d, float __e);
	
	void glDrawTexfvOES(float[] __a, int __b);
	
	void glDrawTexfvOES(FloatBuffer __a);
	
	void glDrawTexiOES(int __a, int __b, int __c, int __d, int __e);
	
	void glDrawTexivOES(int[] __a, int __b);
	
	void glDrawTexivOES(IntBuffer __a);
	
	void glDrawTexsOES(short __a, short __b, short __c, short __d, short __e);
	
	void glDrawTexsvOES(short[] __a, int __b);
	
	void glDrawTexsvOES(ShortBuffer __a);
	
	void glDrawTexxOES(int __a, int __b, int __c, int __d, int __e);
	
	void glDrawTexxvOES(int[] __a, int __b);
	
	void glDrawTexxvOES(IntBuffer __a);
	
	void glEnable(int __a);
	
	void glEnableClientState(int __a);
	
	void glLoadPaletteFromModelViewMatrixOES();
	
	void glMatrixIndexPointerOES(int __a, int __b, int __c, int __d);
	
	void glMatrixIndexPointerOES(int __a, int __b, int __c, Buffer __d);
	
	void glTexParameterfv(int __a, int __b, float[] __c, int __d);
	
	void glWeightPointerOES(int __a, int __b, int __c, int __d);
	
	void glWeightPointerOES(int __a, int __b, int __c, Buffer __d);
}


Added modules/opengles/src/main/java/javax/microedition/khronos/opengles/GL11ExtensionPack.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

@SuppressWarnings({"FieldNamingConvention", "NewMethodNamingConvention"})
public interface GL11ExtensionPack
	extends GL
{
	int GL_BLEND_DST_ALPHA =
		32970;
	
	int GL_BLEND_DST_RGB =
		32968;
	
	int GL_BLEND_EQUATION =
		32777;
	
	int GL_BLEND_EQUATION_ALPHA =
		34877;
	
	int GL_BLEND_EQUATION_RGB =
		32777;
	
	int GL_BLEND_SRC_ALPHA =
		32971;
	
	int GL_BLEND_SRC_RGB =
		32969;
	
	int GL_COLOR_ATTACHMENT0_OES =
		36064;
	
	int GL_COLOR_ATTACHMENT10_OES =
		36074;
	
	int GL_COLOR_ATTACHMENT11_OES =
		36075;
	
	int GL_COLOR_ATTACHMENT12_OES =
		36076;
	
	int GL_COLOR_ATTACHMENT13_OES =
		36077;
	
	int GL_COLOR_ATTACHMENT14_OES =
		36078;
	
	int GL_COLOR_ATTACHMENT15_OES =
		36079;
	
	int GL_COLOR_ATTACHMENT1_OES =
		36065;
	
	int GL_COLOR_ATTACHMENT2_OES =
		36066;
	
	int GL_COLOR_ATTACHMENT3_OES =
		36067;
	
	int GL_COLOR_ATTACHMENT4_OES =
		36068;
	
	int GL_COLOR_ATTACHMENT5_OES =
		36069;
	
	int GL_COLOR_ATTACHMENT6_OES =
		36070;
	
	int GL_COLOR_ATTACHMENT7_OES =
		36071;
	
	int GL_COLOR_ATTACHMENT8_OES =
		36072;
	
	int GL_COLOR_ATTACHMENT9_OES =
		36073;
	
	int GL_DECR_WRAP =
		34056;
	
	int GL_DEPTH_ATTACHMENT_OES =
		36096;
	
	int GL_DEPTH_COMPONENT =
		6402;
	
	int GL_DEPTH_COMPONENT16 =
		33189;
	
	int GL_DEPTH_COMPONENT24 =
		33190;
	
	int GL_DEPTH_COMPONENT32 =
		33191;
	
	int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES =
		36049;
	
	int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES =
		36048;
	
	int
		GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES =
		36051;
	
	int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES =
		36050;
	
	int GL_FRAMEBUFFER_BINDING_OES =
		36006;
	
	int GL_FRAMEBUFFER_COMPLETE_OES =
		36053;
	
	int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES =
		36054;
	
	int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES =
		36057;
	
	int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES =
		36059;
	
	int GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES =
		36058;
	
	int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES
		=
		36055;
	
	int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES =
		36060;
	
	int GL_FRAMEBUFFER_OES =
		36160;
	
	int GL_FRAMEBUFFER_UNSUPPORTED_OES =
		36061;
	
	int GL_FUNC_ADD =
		32774;
	
	int GL_FUNC_REVERSE_SUBTRACT =
		32779;
	
	int GL_FUNC_SUBTRACT =
		32778;
	
	int GL_INCR_WRAP =
		34055;
	
	int GL_INVALID_FRAMEBUFFER_OPERATION_OES =
		1286;
	
	int GL_MAX_COLOR_ATTACHMENTS_OES =
		36063;
	
	int GL_MAX_CUBE_MAP_TEXTURE_SIZE =
		34076;
	
	int GL_MAX_RENDERBUFFER_SIZE_OES =
		34024;
	
	int GL_MIRRORED_REPEAT =
		33648;
	
	int GL_NORMAL_MAP =
		34065;
	
	int GL_REFLECTION_MAP =
		34066;
	
	int GL_RENDERBUFFER_ALPHA_SIZE_OES =
		36179;
	
	int GL_RENDERBUFFER_BINDING_OES =
		36007;
	
	int GL_RENDERBUFFER_BLUE_SIZE_OES =
		36178;
	
	int GL_RENDERBUFFER_DEPTH_SIZE_OES =
		36180;
	
	int GL_RENDERBUFFER_GREEN_SIZE_OES =
		36177;
	
	int GL_RENDERBUFFER_HEIGHT_OES =
		36163;
	
	int GL_RENDERBUFFER_INTERNAL_FORMAT_OES =
		36164;
	
	int GL_RENDERBUFFER_OES =
		36161;
	
	int GL_RENDERBUFFER_RED_SIZE_OES =
		36176;
	
	int GL_RENDERBUFFER_STENCIL_SIZE_OES =
		36181;
	
	int GL_RENDERBUFFER_WIDTH_OES =
		36162;
	
	int GL_RGB565_OES =
		36194;
	
	int GL_RGB5_A1 =
		32855;
	
	int GL_RGB8 =
		32849;
	
	int GL_RGBA4 =
		32854;
	
	int GL_RGBA8 =
		32856;
	
	int GL_STENCIL_ATTACHMENT_OES =
		36128;
	
	int GL_STENCIL_INDEX =
		6401;
	
	int GL_STENCIL_INDEX1_OES =
		36166;
	
	int GL_STENCIL_INDEX4_OES =
		36167;
	
	int GL_STENCIL_INDEX8_OES =
		36168;
	
	int GL_STR =
		-1;
	
	int GL_TEXTURE_BINDING_CUBE_MAP =
		34068;
	
	int GL_TEXTURE_CUBE_MAP =
		34067;
	
	int GL_TEXTURE_CUBE_MAP_NEGATIVE_X =
		8318;
	
	int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y =
		8320;
	
	int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z =
		8322;
	
	int GL_TEXTURE_CUBE_MAP_POSITIVE_X =
		8317;
	
	int GL_TEXTURE_CUBE_MAP_POSITIVE_Y =
		8319;
	
	int GL_TEXTURE_CUBE_MAP_POSITIVE_Z =
		8321;
	
	int GL_TEXTURE_GEN_MODE =
		9472;
	
	int GL_TEXTURE_GEN_STR =
		36192;
	
	void glBindFramebufferOES(int __a, int __b);
	
	void glBindRenderbufferOES(int __a, int __b);
	
	void glBindTexture(int __a, int __b);
	
	void glBlendEquation(int __a);
	
	void glBlendEquationSeparate(int __a, int __b);
	
	void glBlendFuncSeparate(int __a, int __b, int __c, int __d);
	
	int glCheckFramebufferStatusOES(int __a);
	
	void glCompressedTexImage2D(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g, Buffer __h);
	
	void glCopyTexImage2D(int __a, int __b, int __c, int __d, int __e,
	 int __f,
		int __g, int __h);
	
	void glDeleteFramebuffersOES(int __a, int[] __b, int __c);
	
	void glDeleteFramebuffersOES(int __a, IntBuffer __b);
	
	void glDeleteRenderbuffersOES(int __a, int[] __b, int __c);
	
	void glDeleteRenderbuffersOES(int __a, IntBuffer __b);
	
	void glEnable(int __a);
	
	void glFramebufferRenderbufferOES(int __a, int __b, int __c, int __d);
	
	void glFramebufferTexture2DOES(int __a, int __b, int __c, int __d,
	 int __e);
	
	void glGenFramebuffersOES(int __a, int[] __b, int __c);
	
	void glGenFramebuffersOES(int __a, IntBuffer __b);
	
	void glGenRenderbuffersOES(int __a, int[] __b, int __c);
	
	void glGenRenderbuffersOES(int __a, IntBuffer __b);
	
	void glGenerateMipmapOES(int __a);
	
	void glGetFramebufferAttachmentParameterivOES(int __a, int __b, int __c,
		int[] __d, int __e);
	
	void glGetFramebufferAttachmentParameterivOES(int __a, int __b, int __c,
		IntBuffer __d);
	
	void glGetIntegerv(int __a, int[] __b, int __c);
	
	void glGetIntegerv(int __a, IntBuffer __b);
	
	void glGetRenderbufferParameterivOES(int __a, int __b, int[] __c,
	 int __d);
	
	void glGetRenderbufferParameterivOES(int __a, int __b, IntBuffer __c);
	
	void glGetTexGenfv(int __a, int __b, float[] __c, int __d);
	
	void glGetTexGenfv(int __a, int __b, FloatBuffer __c);
	
	void glGetTexGeniv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexGeniv(int __a, int __b, IntBuffer __c);
	
	void glGetTexGenxv(int __a, int __b, int[] __c, int __d);
	
	void glGetTexGenxv(int __a, int __b, IntBuffer __c);
	
	boolean glIsFramebufferOES(int __a);
	
	boolean glIsRenderbufferOES(int __a);
	
	void glRenderbufferStorageOES(int __a, int __b, int __c, int __d);
	
	void glStencilOp(int __a, int __b, int __c);
	
	void glTexEnvf(int __a, int __b, float __c);
	
	void glTexEnvfv(int __a, int __b, float[] __c, int __d);
	
	void glTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	void glTexEnvx(int __a, int __b, int __c);
	
	void glTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	void glTexEnvxv(int __a, int __b, IntBuffer __c);
	
	void glTexGenf(int __a, int __b, float __c);
	
	void glTexGenfv(int __a, int __b, float[] __c, int __d);
	
	void glTexGenfv(int __a, int __b, FloatBuffer __c);
	
	void glTexGeni(int __a, int __b, int __c);
	
	void glTexGeniv(int __a, int __b, int[] __c, int __d);
	
	void glTexGeniv(int __a, int __b, IntBuffer __c);
	
	void glTexGenx(int __a, int __b, int __c);
	
	void glTexGenxv(int __a, int __b, int[] __c, int __d);
	
	void glTexGenxv(int __a, int __b, IntBuffer __c);
	
	void glTexParameterf(int __a, int __b, float __c);
}


Added modules/profile-meep/build.gradle.









































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType
import cc.squirreljme.plugin.swm.JavaMEProfile

description = "This defines the MEEP profile and is a virtual project."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AR"
	swmType = JavaMEMidletType.API
	swmName = "MEEP 8.0 Profile"
	swmVendor = "Stephanie Gawroriski"
	definedProfiles += new JavaMEProfile("MIDP-1.0")
	definedProfiles += new JavaMEProfile("MIDP-2.0")
	definedProfiles += new JavaMEProfile("MIDP-2.1")
	definedProfiles += new JavaMEProfile("MIDP-3.0")
	definedProfiles += new JavaMEProfile("MIDP-3.1")
	definedProfiles += new JavaMEProfile("MEEP-8")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:gcf")
	implementation project(":modules:media-api")
	implementation project(":modules:meep-cellular")
	implementation project(":modules:meep-concurrency")
	implementation project(":modules:meep-event")
	implementation project(":modules:meep-key")
	implementation project(":modules:meep-liblets")
	implementation project(":modules:meep-lui")
	implementation project(":modules:meep-midlet")
	implementation project(":modules:meep-power")
	implementation project(":modules:meep-provisioning")
	implementation project(":modules:meep-rms")
	implementation project(":modules:meep-securityframework")
	implementation project(":modules:meep-swm")
	implementation project(":modules:midp-lcdui")
}

Added modules/squirrel-quarrel/build.gradle.


























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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidlet
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "A turn based strategy involving squirrels and " +
 "lots of acorns! Keep on your claws and horde them all!"
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BE"
	swmType = JavaMEMidletType.APPLICATION
	swmName = "Squirrel Quarrel"
	swmVendor = "Stephanie Gawroriski"
	midlets += new JavaMEMidlet("Squirrel Quarrel", "icon.xpm",
		"dev.shadowtail.squirrelquarrel.MainMidlet")
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:tool-manifest-reader")
	implementation project(":modules:midp-lcdui")
	implementation project(":modules:meep-midlet")
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/AIThinker.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which uses an artificial intelligence to gauge what
 * turns need to be done.
 *
 * @since 2019/07/01
 */
public final class AIThinker
	implements Thinker
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/CommandHandler.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

/**
 * This listens to commands within the game.
 *
 * @since 2019/12/25
 */
public final class CommandHandler
	implements CommandListener
{
	/** The command to exit the game. */
	public static final Command EXIT_COMMAND =
		new Command("Quit", Command.EXIT, 10);
	
	/** The game to interact with. */
	protected final Game game;
	
	/**
	 * Initializes the command handler.
	 *
	 * @param __g The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public CommandHandler(Game __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		this.game = __g;
	}
	
	/**
	 * Executes the given command.
	 *
	 * @param __c The command to execute.
	 * @since 2019/12/25
	 */
	public void commandAction(Command __c, Displayable __d)
	{
		// Exit the game?
		if (__c == CommandHandler.EXIT_COMMAND)
			System.exit(0);
		
		// The in-game menu was requested
		else if (__c == GameInterface.STATUS_COMMAND)
			__d.getCurrentDisplay().setCurrent(
				this.__makeStatusMenu((GameInterface)__d));
		
		// Returning to the game?
		else if (__c instanceof ReturnToGameCommand)
			__d.getCurrentDisplay().setCurrent(
				((ReturnToGameCommand)__c).gameinterface);
	}
	
	/**
	 * Makes and returns the status menu.
	 *
	 * @param __gi The game interface.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	private final Displayable __makeStatusMenu(GameInterface __gi)
		throws NullPointerException
	{
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		// Make a list to show status items
		List items = new List("Status", Choice.IMPLICIT);
		
		// For now add some dummy items
		items.append("P1: 9999 Acorns", PlayerIndex.of(0).colorBox());
		items.append("P2: 9999 Acorns", PlayerIndex.of(1).colorBox());
		items.append("P3: 9999 Acorns", PlayerIndex.of(2).colorBox());
		items.append("P4: 9999 Acorns", PlayerIndex.of(3).colorBox());
		items.append("Season: Spring Day 1", null);
		
		// Set commands for this list
		items.addCommand(new ReturnToGameCommand(__gi));
		items.addCommand(CommandHandler.EXIT_COMMAND);
		
		// Use self as the command listener
		items.setCommandListener(this);
		
		// Return the list
		return items;
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Game.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.util.Random;

/**
 * This class keeps track of the entire game state, such as active players,
 * artificial intelligence, the tile map, and the units.
 *
 * @since 2019/07/01
 */
public final class Game
{
	/** The random number generator. */
	public final Random random;
	
	/** The world map. */
	public final TileMap tilemap;
	
	/**
	 * Initializes the game.
	 *
	 * @param __seed The seed to use.
	 * @param __mapsize The size of the map.
	 * @param __numpl The number of players to use.
	 * @since 2019/07/01
	 */
	public Game(long __seed, MapSize __mapsize, int __numpl)
	{
		// Initialize RNG
		Random random;
		this.random = (random = new Random(__seed));
		
		// Initialize random map
		TileMap tilemap;
		this.tilemap = (tilemap = new TileMap(random, __mapsize, __numpl));
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/GameBuilder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.io.IOException;
import java.io.InputStream;
import java.util.Random;

/**
 * This is used to build games which can then be run and such.
 *
 * @since 2019/07/01
 */
public final class GameBuilder
{
	/** The game seed. */
	private volatile long _seed;
	
	/** The map size. */
	private volatile MapSize _mapsize;
	
	/** The number of players used. */
	private volatile int _numplayers;
	
	/**
	 * Initializes a base game builder.
	 *
	 * @since 2019/07/01
	 */
	public GameBuilder()
	{
		// Instead of using the time directly, derive it from a seed
		Random initseed = new Random((System.currentTimeMillis() * 37L) +
			System.nanoTime());
		this._seed = ((long)initseed.nextInt() << 32) ^ initseed.nextInt();
		
		// Set default parameters
		this._mapsize = MapSize.DEFAULT;
		this._numplayers = 2;
	}
	
	/**
	 * Builds the actual game.
	 *
	 * @return The resulting game.
	 * @since 2019/07/01
	 */
	public final Game build()
	{
		synchronized (this)
		{
			return new Game(this._seed,
				this._mapsize,
				this._numplayers);
		}
	}
	
	/**
	 * Sets the number of players in the game.
	 *
	 * @param __n The number of players to have.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the player count is out of range.
	 * @since 2019/07/01
	 */
	public final GameBuilder players(int __n)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE0s Out of range player count. (The count)}
		if (__n < 1 || __n > Players.MAX_PLAYERS)
			throw new IllegalArgumentException("BE0s " + __n);
		
		synchronized (this)
		{
			this._numplayers = __n;
			return this;
		}
	}
	
	/**
	 * Sets the seed to use for the game.
	 *
	 * @param __v The seed to use.
	 * @return {@code this}.
	 * @since 2019/07/01
	 */
	public final GameBuilder seed(long __v)
	{
		synchronized (this)
		{
			this._seed = __v;
			return this;
		}
	}
	
	/**
	 * Builds and plays back a game from a replay.
	 *
	 * @param __in The input stream.
	 * @return The resulting game.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public static final Game fromReplay(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/GameInterface.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Graphics;

/**
 * This is an interface to the game which allows it to be drawn and interacted
 * with accordingly. This is effectively just a canvas which draws the game
 * and such.
 *
 * @since 2019/07/01
 */
public final class GameInterface
	extends Canvas
{
	/** The menu command. */
	public static final Command STATUS_COMMAND =
		new Command("Status", Command.SCREEN, 0);
	
	/** The game this will be drawing and interacting with. */
	protected final Game game;
	
	/** The current cursor tile. */
	protected final MutablePoint cursor =
		new MutablePoint();
	
	/**
	 * Initializes the game interface.
	 *
	 * @param __g The game to interact with.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public GameInterface(Game __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Initialize variables
		this.game = __g;
		
		// Setup canvas view and such
		this.setTitle("Squirrel Quarrel");
		
		// Add menu command to access the in-game menu
		this.addCommand(GameInterface.STATUS_COMMAND);
		this.setCommandListener(new CommandHandler(__g));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyPressed(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyRepeated(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected final void paint(Graphics __g)
	{
		// Get game details to draw
		Game game = this.game;
		
		// Get the canvas dimensions
		int cw = this.getWidth(),
			ch = this.getHeight();
		
		// Draw the tile map
		this.__drawTiles(__g, cw, ch, game.tilemap);
	}
	
	/**
	 * Draws the underlying tilemap.
	 *
	 * @param __g The graphics to draw to.
	 * @param __cw The canvas width.
	 * @param __ch The canvas height.
	 * @param __tilemap The raw tile data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/02
	 */
	private final void __drawTiles(Graphics __g, int __cw, int __ch,
		TileMap __tilemap)
		throws NullPointerException
	{
		if (__g == null || __tilemap == null)
			throw new NullPointerException("NARG");
		
		// Size of the map in tiles
		int mtw = __tilemap.tilewidth,
			mth = __tilemap.tileheight;
		
		// Size of the view in tiles, an extra tile is given so that they are
		// not clipped off the right side at all!
		int vtw = (__cw + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS,
			vth = (__ch + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS;
		
		// Half of the view, used for centering and capping
		int vsw = vtw / 2,
			vsh = vth / 2;
		
		// Get the cursor position and determine how that is drawn, the view
		// is always centered on it for simplicity
		MutablePoint cursor = this.cursor;
		int cx = cursor.x,
			cy = cursor.y,
			vtx = cx - vsw,
			vty = cy - vsh;
		
		// Passed bounds on the right side?
		if (vtx + vtw > mtw)
			vtx = mtw - vtw;
		if (vty + mth > mth)
			vty = mth - vth;
		if (vtx < 0)
			vtx = 0;
		if (vty < 0)
			vty = 0;
		
		// End tile positions
		int etx = vtx + vtw,
			ety = vty + vth;
		if (etx > mtw)
			etx = mtw;
		if (ety > mth)
			ety = mth;
		
		// Get the background logical tile data
		byte[] tiles = __tilemap._tiles;
		
		// Draw all tiles in the region
		for (int y = vty; y < ety; y++)
		{
			// Logical tile Y on screen
			int ly = (y - vty) * TileMap.TILE_PIXELS;
			
			// Base byte position in array
			int bbase = y * mtw;
			
			// Scan in row
			for (int x = vtx; x < etx; x++)
			{
				// Determine logical screen position of file
				int lx = (x - vtx) * TileMap.TILE_PIXELS;
				
				// Get the byte code for this tile
				byte b = tiles[bbase + x];
				
				// Draw background tile
				__g.drawImage(TileMap.imageBackground(b), lx, ly, 0);
				
				// Draw a basic grid to make things a bit easier to see
				__g.setStrokeStyle(Graphics.DOTTED);
				__g.setColor(0x000000);
				__g.drawLine(lx, ly,
					lx + TileMap.TILE_PIXELS, ly);
				__g.drawLine(lx, ly,
					lx, ly + TileMap.TILE_PIXELS);
				
				// Draw cursor box?
				if (cx == x && cy == y)
				{
					// Draw solid line
					__g.setStrokeStyle(Graphics.SOLID);
					__g.setColor(0xFFFF00);
					__g.drawRect(lx, ly,
						TileMap.TILE_PIXELS - 2, TileMap.TILE_PIXELS - 2);
					
					// Dotted purple box
					__g.setStrokeStyle(Graphics.DOTTED);
					__g.setColor(0xFF00FF);
					__g.drawRect(lx, ly,
						TileMap.TILE_PIXELS - 2, TileMap.TILE_PIXELS - 2);
					
					// Make it solid again
					__g.setStrokeStyle(Graphics.SOLID);
				}
			}
		}
	}
	
	/**
	 * Handles the specified key.
	 *
	 * @param __kc The key code to handle.
	 * @since 2019/07/02
	 */
	private final void __inputKey(int __kc)
	{
		// Prefer pure game actions, if those are not available fallback to
		// the dial pad. Match traditional SquirrelJME game layout.
		int ga = this.getGameAction(__kc);
		if (ga == 0)
			switch (__kc)
			{
				case Canvas.KEY_NUM1: ga = Canvas.GAME_A; break;
				case Canvas.KEY_NUM2: ga = Canvas.UP; break;
				case Canvas.KEY_NUM3: ga = Canvas.GAME_B; break;
				
				case Canvas.KEY_NUM4: ga = Canvas.LEFT; break;
				case Canvas.KEY_NUM5: ga = Canvas.FIRE; break;
				case Canvas.KEY_NUM6: ga = Canvas.RIGHT; break;
				
				case Canvas.KEY_NUM7: ga = Canvas.GAME_C; break;
				case Canvas.KEY_NUM8: ga = Canvas.DOWN; break;
				case Canvas.KEY_NUM9: ga = Canvas.GAME_D; break;
			}
		
		// Ignore invalid actions
		if (ga == 0)
			return;
		
		// Stuff actions could be performed on
		MutablePoint cursor = this.cursor;
		Game game = this.game;
		TileMap tilemap = game.tilemap;
		
		// Perform the actions
		switch (ga)
		{
				// Cursor up
			case Canvas.UP:
				if (--cursor.y < 0)
					cursor.y = 0;
				break;
				
				// Cursor left
			case Canvas.LEFT:
				if (--cursor.x < 0)
					cursor.x = 0;
				break;
				
				// Cursor Right
			case Canvas.RIGHT:
				if (++cursor.x >= tilemap.tilewidth)
					cursor.x = tilemap.tilewidth - 1;
				break;
				
				// Cursor Down
			case Canvas.DOWN:
				if (++cursor.y >= tilemap.tileheight)
					cursor.y = tilemap.tileheight - 1;
				break;
		}
		
		// Do repaint the view!
		this.repaint();
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/MainMidlet.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Main entry point for the game.
 *
 * @since 2019/07/01
 */
public class MainMidlet
	extends MIDlet
{
	/** The instance of this MIDlet. */
	public static MIDlet INSTANCE;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Set instance
		MainMidlet.INSTANCE = this;
		
		// Setup base game builder
		GameBuilder gb = new GameBuilder();
		
		// Setup and show the game interface
		GameInterface gi = new GameInterface(gb.build());
		Display.getDisplay(this).setCurrent(gi);
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/MapSize.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * DESCRIBE THIS.
 *
 * @since 2019/07/01
 */
public enum MapSize
{
	/** Compact. */
	RIDICULOUSLY_TINY(10, 10),
	
	/** Tiny map size. */
	TINY(20, 20),
	
	/** Small. */
	SMALL(25, 25),
	
	/** Medium. */
	MEDIUM(30, 30),
	
	/** Large. */
	LARGE(40, 40),
	
	/** Ridiculous. */
	RIDICULOUSLY_LARGE(80, 80),
	
	/** End. */
	;
	
	/** The default map size to use. */
	public static final MapSize DEFAULT = MapSize.TINY;
	
	/** The map width. */
	public final int width;
	
	/** The map height. */
	public final int height;
	
	/**
	 * Initializes the map size.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/07/01
	 */
	MapSize(int __w, int __h)
	{
		this.width = __w;
		this.height = __h;
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/MutablePoint.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This represents a point which is mutable.
 *
 * @since 2019/07/02
 */
public final class MutablePoint
{
	/** X position. */
	public int x;
	
	/** Y position. */
	public int y;
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Player.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This represents a single player within the game, holding their current state
 * and the resources they have.
 *
 * @since 2019/07/01
 */
public final class Player
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/PlayerIndex.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.util.NoSuchElementException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;

/**
 * The represents the color of a player.
 *
 * The colors here are from Electronic Art's Accessibility account which
 * specify the set of colors which are best used for all kinds of color
 * blind users to they can differentiate between all the colors.
 *
 * https://twitter.com/ea_accessible/status/968592657848193024
 * https://twitter.com/ea_accessible/status/968595073184092160
 *
 * @since 2019/12/25
 */
public enum PlayerIndex
{
	/** Red. */
	RED("Red", 0xDE4949),
	
	/** Purple. */
	PURPLE("Purple", 0x533364),
	
	/** Green. */
	GREEN("Green", 0x30B06E),
	
	/** Blue. */
	BLUE("Blue", 0x33521E1),
	
	/** Yellow. */
	YELLOW("Yellow", 0xFFB937),
	
	/** Gray. */
	GRAY("Gray", 0x5A7D8B),
	
	/** End. */
	;
	
	/** The maximum number of players that can play at once. */
	public static final int MAX_PLAYERS =
		4;
	
	/** The number of player colors. */
	public static final int NUM_COLORS =
		6;
	
	/** Player 1. */
	public static final PlayerIndex P1 =
		PlayerIndex.RED;
	
	/** Player 2. */
	public static final PlayerIndex P2 =
		PlayerIndex.PURPLE;
	
	/** Player 3. */
	public static final PlayerIndex P3 =
		PlayerIndex.GREEN;
	
	/** Player 4. */
	public static final PlayerIndex P4 =
		PlayerIndex.BLUE;
	
	/** Creeps that just annoy you. */
	public static final PlayerIndex CREEPS =
		PlayerIndex.YELLOW;
	
	/** The neutral player. */
	public static final PlayerIndex NEUTRAL =
		PlayerIndex.GRAY;
	
	/** The ARGB color code. */
	public final int argb;
	
	/** The RGB color code. */
	public final int rgb;
	
	/** The color name. */
	public final String name;
	
	/** The colorbox. */
	private Image _colorbox;
	
	/**
	 * Initializes the color code.
	 *
	 * @param __name The name of the color.
	 * @param __rgb The RGB used for the player color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	PlayerIndex(String __name, int __rgb)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.argb = __rgb | 0xFF000000;
		this.rgb = __rgb & 0xFFFFFF;
	}
	
	/**
	 * Returns the color box for this player.
	 *
	 * @return The color box.
	 * @since 2019/12/26
	 */
	public final Image colorBox()
	{
		// Pre-made already?
		Image rv = this._colorbox;
		if (rv != null)
			return rv;
		
		Display d = Display.getDisplay(MainMidlet.INSTANCE);
		this._colorbox = (rv = Image.createImage(
			d.getBestImageWidth(Display.LIST_ELEMENT),
			d.getBestImageHeight(Display.LIST_ELEMENT), false, this.argb));
		return rv;
	}
	
	/**
	 * Returns the player index of the given index.
	 *
	 * @param __i The index.
	 * @return The player index.
	 * @throws NoSuchElementException If it was not found.
	 * @since 2019/12/26
	 */
	public static final PlayerIndex of(int __i)
		throws NoSuchElementException
	{
		switch (__i)
		{
			case 0:	return PlayerIndex.RED;
			case 1:	return PlayerIndex.PURPLE;
			case 2:	return PlayerIndex.GREEN;
			case 3:	return PlayerIndex.BLUE;
			case 4:	return PlayerIndex.YELLOW;
			case 5:	return PlayerIndex.GRAY;
			
				// {@squirreljme.error BE0u Invalid player index.}
			default:
				throw new NoSuchElementException("BE0u");
		}
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/PlayerThinker.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which is completely operated by a player inputting
 * into the phone pad.
 *
 * @since 2019/07/01
 */
public final class PlayerThinker
	implements Thinker
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Players.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This manages all of the players which are in the game and with their
 * associated state.
 *
 * @since 2019/07/01
 */
public final class Players
{
	/** Maximum number of supported players. */
	public static final int MAX_PLAYERS =
		4;
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/RemoteThinker.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which is purely remote based over the network.
 *
 * @since 2019/07/01
 */
public final class RemoteThinker
	implements Thinker
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/ReplayThinker.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which plays back from a replay or demo.
 *
 * @since 2019/07/01
 */
public final class ReplayThinker
	implements Thinker
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/ReturnToGameCommand.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Command;

/**
 * Handles returning to the game.
 *
 * @since 2019/12/25
 */
public final class ReturnToGameCommand
	extends Command
{
	/** The game interface. */
	protected final GameInterface gameinterface;
	
	/**
	 * Initializes the return to game.
	 *
	 * @param __gi The game interface.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public ReturnToGameCommand(GameInterface __gi)
		throws NullPointerException
	{
		super("Resume", Command.SCREEN, 0);
		
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		this.gameinterface = __gi;
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Thinker.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a basic thinker which tells units and such to do things.
 *
 * @since 2019/07/01
 */
public interface Thinker
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/TileMap.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import javax.microedition.lcdui.Image;

/**
 * This manages the world map which consists of tiles.
 *
 * @since 2019/07/01
 */
public final class TileMap
{
	/** Each tile is 16x16 pixels. */
	public static final int TILE_PIXELS =
		16;
	
	/** Mask for pixels. */
	public static final int TILE_PIXELS_MASK =
		15;
	
	/** The tile background mask. */
	public static final int TILE_BACKGOUND_MASK =
		0b0000_0011;
	
	/** Background tile images. */
	private static final Image[] _CACHE_BACKGROUND =
		new Image[4];
	
	/** The size of the map. */
	public final MapSize size;
	
	/** The width of the map in tiles. */
	public final int tilewidth;
	
	/** The height of the map in tiles. */
	public final int tileheight;
	
	/** The internal tile data. */
	final byte[] _tiles;
	
	/**
	 * Initializes the tile map.
	 *
	 * @param __rand The random level generator.
	 * @param __size The map size to use.
	 * @param __numpl The number of players to make room for.
	 * @throws IllegalArgumentException If the player count is zero or
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public TileMap(Random __rand, MapSize __size, int __numpl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__rand == null || __size == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0r Negative or zero players, there must be
		// at least one player. (The player count)}
		if (__numpl < 1)
			throw new IllegalArgumentException("BE0r " + __numpl);
		
		// Get and store size of the level
		int tilewidth = __size.width,
			tileheight = __size.height,
			tiledens = tilewidth * tileheight;
		this.size = __size;
		this.tilewidth = tilewidth;
		this.tileheight = tileheight;
		
		// Initialize data areas
		byte[] tiles = new byte[tiledens];
		this._tiles = tiles;
		
		for (int i = 0; i < tiledens; i++)
			tiles[i] = (byte)__rand.nextInt();
	}
	
	/**
	 * Looks into the cache and returns the specified image.
	 *
	 * @param __cache The cache to look in.
	 * @param __dx The index to cache.
	 * @param __prefix The resource prefix.
	 * @return The resulting image.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/02
	 */
	public static Image cacheImage(Image[] __cache, int __dx, String __prefix)
		throws NullPointerException
	{
		if (__cache == null || __prefix == null)
			throw new NullPointerException("NARG");
		
		// If the cache has the image, use it
		Image rv = __cache[__dx];
		if (rv != null)
			return rv;
		
		// Otherwise load it!
		try (InputStream in = TileMap.class.getResourceAsStream(
			__prefix + __dx + ".xpm"))
		{
			rv = Image.createImage(in);
		}
		
		// {@squirreljme.error BE0t Could not cache the image. (The index;
		// The prefix)}
		catch (IOException e)
		{
			throw new RuntimeException("BE0t " + __dx + " " + __prefix, e);
		}
		
		// Store into the cache then return
		__cache[__dx] = rv;
		return rv;
	}
	
	/**
	 * Gets the image used for the background.
	 *
	 * @param __b The tile data.
	 * @return The image to use.
	 * @since 2019/07/02
	 */
	public static Image imageBackground(byte __b)
	{
		// Read cached image
		return TileMap.cacheImage(
			TileMap._CACHE_BACKGROUND, __b & TileMap.TILE_BACKGOUND_MASK,
			"tile");
	}
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Unit.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This contains information on a single unit such as an active player moving
 * unit or a player building.
 *
 * @since 2019/07/01
 */
public final class Unit
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/Units.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This keeps track of all the units that are available in the game.
 *
 * @since 2019/07/01
 */
public final class Units
{
}

Added modules/squirrel-quarrel/src/main/java/dev/shadowtail/squirrelquarrel/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains Squirrel Quarrel, the acorn gathering strategy game!
 *
 * @since 2019/07/01
 */

package dev.shadowtail.squirrelquarrel;

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/game/EventSource.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This interface describes a source that is used for game events, that is
 * ones which control the various players including AIs.
 *
 * @since 2019/03/24
 */
public interface EventSource
{
}

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

package net.multiphasicapps.squirrelquarrel.game;

import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.player.Players;
import net.multiphasicapps.squirrelquarrel.units.SpawnPlacementType;
import net.multiphasicapps.squirrelquarrel.units.Unit;
import net.multiphasicapps.squirrelquarrel.units.UnitType;
import net.multiphasicapps.squirrelquarrel.units.Units;
import net.multiphasicapps.squirrelquarrel.util.GameRandom;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This class contains the state for a single game.
 *
 * @since 2017/02/08
 */
public class Game
{
	/** The player manager. */
	protected final Players players;
	
	/** The unit manager. */
	protected final Units units;
	
	/** Random number generator for games. */
	protected final GameRandom random;
	
	/** The level information. */
	protected final World world;
	
	/** The current game frame. */
	private volatile int _framenum;
	
	/** Has the initial game setup been booted? */
	private boolean _booted;
	
	/**
	 * Initializes a game with the default initialization rules.
	 *
	 * @since 2017/02/08
	 */
	public Game()
	{
		this(new InitialSettingsBuilder().build());
	}
	
	/**
	 * Initializes the game with the given initial settings.
	 *
	 * @param __is The settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	public Game(InitialSettings __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Setup random number generator
		this.random = new GameRandom(__is.seed());
		
		// Initialize the level using the initial settings
		this.world = new World(__is);
		
		// Initialize players
		this.players = new Players(__is);
		
		// Initialize units
		this.units = new Units(__is);
	}
	
	/**
	 * Returns the current game frame.
	 *
	 * @return The game frame.
	 * @since 2017/02/10
	 */
	public final int frameCount()
	{
		return this._framenum;
	}
	
	/**
	 * Returns the player manager.
	 *
	 * @return The player manager.
	 * @since 2018/03/19
	 */
	public final Players players()
	{
		return this.players;
	}
	
	/**
	 * Runs a single game frame.
	 *
	 * @since 2017/02/10
	 */
	public final void run()
	{
		// Get current frame
		int framenum = this._framenum;
		
		// On the first frame if the game is not booted, spawn everything
		// as needed so it is all done within the loop
		if (!this._booted)
		{
			this.__boot();
			this._booted = true;
		}
		
		// Run all the sub-logic
		this.world.run(framenum);
		this.units.run(framenum);
		this.players.run(framenum);
		
		// Increase the game frame
		this._framenum = framenum + 1;
	}
	
	/**
	 * Returns the world.
	 *
	 * @return The world.
	 * @since 2017/02/10
	 */
	public World world()
	{
		return this.world;
	}
	
	/**
	 * Boots the game spawning everything as needed.
	 *
	 * @since 2019/03/24
	 */
	private final void __boot()
	{
		Units units = this.units;
		Players players = this.players;
		
		// Create initial game units for players who are playing
		for (int i = 0, n = PlayerColor.NUM_COLORS; i < n; i++)
		{
			// Only if the player is playing
			Player p = players.get(i);
			if (p.isPlaying())
			{
				// Create building
				Unit base = units.createUnit(SpawnPlacementType.BUILDING,
					UnitType.CHLOROPHID_GARDEN, (Unit)null,
					64 + (128 * i), 64);
				
				// Create workers from the building
				todo.TODO.note("Spawn workers!");
			}
		}
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/game/GameLooper.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import java.io.InputStream;
import java.io.OutputStream;
import net.multiphasicapps.squirrelquarrel.ui.FrameSync;
import net.multiphasicapps.squirrelquarrel.util.ReplayEventSource;
import net.multiphasicapps.squirrelquarrel.util.ReplayInputStream;
import net.multiphasicapps.squirrelquarrel.util.ReplayOutputStream;

/**
 * This manages and runs the game loop.
 *
 * @since 2018/03/19
 */
public final class GameLooper
{
	/** The output for replay recordings. */
	protected final ReplayOutputStream record;
	
	/** The game to loop for. */
	protected final Game game;
	
	/** The source where events come from. */
	private EventSource _events;
	
	/** The speed the game runs at. */
	private volatile GameSpeed _speed =
		GameSpeed.NORMAL;
	
	/**
	 * Initializes the game looper with the default settings.
	 *
	 * @param __out The stream to write replay data to.
	 * @param __evs The source where events come from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameLooper(OutputStream __out, EventSource __evs)
		throws NullPointerException
	{
		this(__out, __evs, new InitialSettingsBuilder().build());
	}
	
	/**
	 * Initializes the game looper.
	 *
	 * @param __out The stream to write replay data to.
	 * @param __evs The source where events come from.
	 * @param __i The initial settings for the game.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameLooper(OutputStream __out, EventSource __evs,
		InitialSettings __i)
		throws NullPointerException
	{
		if (__out == null || __i == null)
			throw new NullPointerException("NARG");
		
		// Setup replay output for consistent game recording
		ReplayOutputStream record = new ReplayOutputStream(__out);
		this.record = record;
		__i.demoRecord(record);
		
		// Initialize the game with basic settings
		this.game = new Game(__i);
		
		// Set event source which is used per-frame to control players
		this._events = __evs;
	}
	
	/**
	 * Returns the event source in use.
	 *
	 * @return The event source in use.
	 * @since 2019/03/24
	 */
	public final EventSource eventSource()
	{
		return this._events;
	}
	
	/**
	 * Returns the game this provides a loop for.
	 *
	 * @return The game being looped.
	 * @since 2018/03/18
	 */
	public final Game game()
	{
		return this.game;
	}
	
	/**
	 * Runs multiple game frames.
	 *
	 * @param __fs Callback for when game frames are updated.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public void run(FrameSync __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		Game game = this.game;
		for (;;)
		{
			// Get the current game speed and entry time
			GameSpeed speed = this._speed;
			long enter = System.nanoTime();
			
			// Run a single game cycle
			int nowframe = game.frameCount();
			game.run();
			
			// Debug
			todo.DEBUG.note("Ran %d", nowframe);
			
			// Request a repaint if there is enough time to draw
			long exit = System.nanoTime();
			if ((exit - enter) < speed.nanoFrameTime())
				__fs.frameRepaintRequest(nowframe);
			
			// Delay thread for the next frame
			exit = System.nanoTime();
			long durr = (speed.nanoFrameTime() - (exit - enter)) / 1_000_000L;
			if (durr > 0)
				try
				{
					Thread.sleep(durr);
				}
				catch (InterruptedException e)
				{
				}
		}
	}
	
	/**
	 * Runs a single game frame.
	 *
	 * @since 2018/03/19
	 */
	public void runFrame()
	{
	}
	
	/**
	 * Sets the event source.
	 *
	 * @param __es The event source to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public final void setEventSource(EventSource __es)
		throws NullPointerException
	{
		if (__es == null)
			throw new NullPointerException("NARG");
		
		this._events = __es;
	}
	
	/**
	 * Initialize a game loop which either resumes the game from the given
	 * point or plays it back in a replay.
	 *
	 * @param __out The output for replay data.
	 * @param __rm How will the game be resumed?
	 * @param __in The input stream for replay/save data.
	 * @return The loop.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public static final GameLooper resume(OutputStream __out,
		ResumeMode __rm, InputStream __in)
		throws NullPointerException
	{
		if (__out == null || __rm == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Setup input replay strema
		ReplayInputStream replay = new ReplayInputStream(__in);
		
		// Read initial settings from the replay and initialize the game
		InitialSettings init = InitialSettings.demoReplay(replay);
		GameLooper rv = new GameLooper(__out,
			new ReplayEventSource(replay), init);
		
		return rv;
	}
}

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

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This represents the game speed which determines the amount of time between
 * frames.
 *
 * @since 2017/02/10
 */
public enum GameSpeed
{
	/** Slowest. */
	SLOWEST(167),
	
	/** Slower. */
	SLOWER(111),
	
	/** Slow. */
	SLOW(83),
	
	/** Normal. */
	NORMAL(67),
	
	/** Fast. */
	FAST(56),
	
	/** Faster. */
	FASTER(48),
	
	/** Fastest. */
	FASTEST(42),	
	
	/** End. */
	;
	
	/** The speed of normal. */
	private static final int _NORMAL_SPEED =
		67;
	
	/** Milliseconds between frames. */
	protected final int msbetweenframes;
	
	/** Nanoseconds between frames. */
	protected final int nsbetweenframes;
	
	/**
	 * Initializes the game speed.
	 *
	 * @param __msbf Milliseconds between frames.
	 * @since 2017/02/10
	 */
	GameSpeed(int __msbf)
	{
		this.msbetweenframes = __msbf;
		this.nsbetweenframes = __msbf * 1_000_000;
	}
	
	/**
	 * Returns the game speed which is faster than this one.
	 *
	 * @return The faster game speed.
	 * @since 2017/02/12
	 */
	public GameSpeed faster()
	{
		// Depends
		switch (this)
		{
			case SLOWEST:	return GameSpeed.SLOWER;
			case SLOWER:	return GameSpeed.SLOW;
			case SLOW:		return GameSpeed.NORMAL;
			case NORMAL:	return GameSpeed.FAST;
			case FAST:		return GameSpeed.FASTER;
			case FASTER:	return GameSpeed.FASTEST;
			default:
				return this;
		}
	}
	
	/**
	 * Returns the duration of a single frame in nanoseconds.
	 *
	 * @return The frame duration in nanoseconds.
	 * @since 2017/02/10
	 */
	public int nanoFrameTime()
	{
		return this.nsbetweenframes;
	}
	
	/**
	 * Returns the ratio this game speed and the normal game speed.
	 *
	 * @return The ratio between speeds.
	 * @since 2017/02/12
	 */
	public double ratio()
	{
		return (double)this.msbetweenframes / GameSpeed._NORMAL_SPEED;
	}
	
	/**
	 * Returns the game speed which is slower than this one.
	 *
	 * @return The slower game speed.
	 * @since 2017/02/12
	 */
	public GameSpeed slower()
	{
		// Depends
		switch (this)
		{
			case SLOWER:	return GameSpeed.SLOWEST;
			case SLOW:		return GameSpeed.SLOWER;
			case NORMAL:	return GameSpeed.SLOW;
			case FAST:		return GameSpeed.NORMAL;
			case FASTER:	return GameSpeed.FAST;
			case FASTEST:	return GameSpeed.FASTER;
			default:
				return this;
		}
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/game/InitialSettings.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.util.ReplayFormatException;
import net.multiphasicapps.squirrelquarrel.util.ReplayInputStream;
import net.multiphasicapps.squirrelquarrel.util.ReplayOutputStream;

/**
 * This contains the initial settings which is used to determine how to
 * generate and initialize the initial game.
 *
 * @since 2017/02/09
 */
public final class InitialSettings
{
	/** Magic number for initial settings. */
	private static final long _MAGIC_NUMBER =
		0x53715872FF00FFFFL;
	
	/** The width of the map in tiles. */
	protected final int mapwidth;
	
	/** The height of the map in tiles. */
	protected final int mapheight;
	
	/** The number of players playing the game. */
	protected final int players;
	
	/** The level seed. */
	protected final long seed;
	
	/** The timestamp the game started. */
	protected final long timestamp;
	
	/** How the teams are laid out. */
	private final int[] _teams;
	
	/**
	 * Initializes the initial settings.
	 *
	 * @param __b The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	InitialSettings(InitialSettingsBuilder __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.mapwidth = __b._mapwidth;
		this.mapheight = __b._mapheight;
		this.seed = __b._seed;
		this.timestamp = __b._timestamp;
		this.players = __b._players;
		this._teams = __b._teams.clone();
	}
	
	/**
	 * Writes the settings to the given replay output stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public final void demoRecord(ReplayOutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		int players;
		
		__out.writeLong(InitialSettings._MAGIC_NUMBER);
		__out.writeLong(this.timestamp);
		__out.writeLong(this.seed);
		__out.writeInt(this.mapwidth);
		__out.writeInt(this.mapheight);
		__out.writeByte((players = this.players));
		
		// Write team data
		int[] teams = this._teams;
		for (int i = 0; i < players; i++)
			__out.writeByte(teams[i]);
	}
	
	/**
	 * Returns the height of the map.
	 *
	 * @return The height of the map.
	 * @since 2017/02/10
	 */
	public final int mapHeight()
	{
		return this.mapheight;
	}
	
	/**
	 * Returns the width of the map.
	 *
	 * @return The width of the map.
	 * @since 2017/02/10
	 */
	public final int mapWidth()
	{
		return this.mapwidth;
	}
	
	/**
	 * Returns the number of players playing the game.
	 *
	 * @return The players playing the game.
	 * @since 2018/03/19
	 */
	public final int players()
	{
		return this.players;
	}
	
	/**
	 * Returns the seed for the map and game events.
	 *
	 * @return The game seed.
	 * @since 2017/02/10
	 */
	public final long seed()
	{
		return this.seed;
	}
	
	/**
	 * Returns the starting timestamp of the game.
	 *
	 * @return The starting timestamp of the game.
	 * @since 2018/03/19
	 */
	public final long startTimeMillis()
	{
		return this.timestamp;
	}
	
	/**
	 * Returns how the teams are laid out.
	 *
	 * @return The team layout.
	 * @since 2018/03/19
	 */
	public final int[] teams()
	{
		// Copy base teams first
		int[] teams = this._teams,
			rv = new int[PlayerColor.NUM_COLORS];
		for (int i = 0, n = teams.length; i < n; i++)
			rv[i] = teams[i];
		
		// Always place creeps and neutral players on their own team
		rv[PlayerColor.CREEPS.ordinal()] = PlayerColor.CREEPS.ordinal();
		rv[PlayerColor.NEUTRAL.ordinal()] = PlayerColor.NEUTRAL.ordinal();
		
		return rv;
	}
	
	/**
	 * Reads the initial settings from the replay input.
	 *
	 * @param __in The stream to read from.
	 * @return The initial settings.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public static final InitialSettings demoReplay(ReplayInputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE01 Invalid initial settings magic number.
		// (The read magic number)}
		long magic = __in.readLong();
		if (magic != InitialSettings._MAGIC_NUMBER)
			throw new ReplayFormatException(String.format("BE01 %08x", magic));
		
		int players;
		
		InitialSettingsBuilder rv = new InitialSettingsBuilder();
		
		rv.startTimeMillis(__in.readLong());
		rv.seed(__in.readLong());
		rv.mapSize(__in.readInt(), __in.readInt());
		rv.players((players = __in.readByte()));
		
		// Read in teams
		int[] teams = new int[players];
		for (int i = 0; i < players; i++)
			teams[i] = __in.readByte();
		rv.teams(teams);
		
		return rv.build();
	}
}

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

package net.multiphasicapps.squirrelquarrel.game;

import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;

/**
 * This is used to build the initial settings for the game.
 *
 * This class is not thread safe.
 *
 * @since 2017/02/09
 */
public class InitialSettingsBuilder
{
	/** How the teams are laid out. */
	final int[] _teams =
		new int[PlayerColor.MAX_PLAYERS];
	
	/** The time these settings were created. */
	volatile long _timestamp =
		System.currentTimeMillis();
	
	/** The width of the map in tiles. */
	volatile int _mapwidth =
		64;
	
	/** The height of the map in tiles. */
	volatile int _mapheight =
		64;
	
	/** The players playing in the game. */
	volatile int _players =
		2;
	
	/** The seed to use. */
	volatile long _seed =
		System.currentTimeMillis();
	
	/**
	 * Initializes some more complex settings.
	 *
	 * @since 2018/03/19
	 */
	{
		// Start off all players on their own team (FFA)
		int[] teams = this._teams;
		for (int i = 0, n = teams.length; i < n; i++)
			teams[i] = i;
	}
	
	/**
	 * Builds the settings.
	 *
	 * @return The resulting settings.
	 * @since 2017/02/09
	 */
	public InitialSettings build()
	{
		return new InitialSettings(this);
	}
	
	/**
	 * Sets the map size in tiles. If an input dimension is not valid then it
	 * will be corrected.
	 *
	 * @param __w The width of the map.
	 * @param __h The height of the map.
	 * @since 2017/02/10
	 */
	public void mapSize(int __w, int __h)
	{
		this._mapwidth = Math.max(MegaTile.TILES_PER_MEGA_TILE,
			(__w - (__w % MegaTile.TILES_PER_MEGA_TILE)));
		this._mapheight = Math.max(MegaTile.TILES_PER_MEGA_TILE,
			(__h - (__w % MegaTile.TILES_PER_MEGA_TILE)));
	}
	
	/**
	 * Sets the number of players that are playing in the game.
	 *
	 * @param __p The players that are playing in the game.
	 * @since 2018/03/19
	 */
	public void players(int __p)
	{
		// Allow one player in the event one wants to play alone for any given
		// reason
		this._players = Math.max(1, Math.min(PlayerColor.MAX_PLAYERS, __p));
	}
	
	/**
	 * Sets the seed to use for random generation.
	 *
	 * @param __s The seed to use.
	 * @since 2017/02/10
	 */
	public void seed(long __s)
	{
		this._seed = __s;
	}
	
	/**
	 * Sets the timestamp of the game start time.
	 *
	 * @param __t The time the game started.
	 * @since 2018/03/19
	 */
	public void startTimeMillis(long __t)
	{
		this._timestamp = __t;
	}
	
	/**
	 * Sets how the teams are to be laid out.
	 *
	 * @param __t Array containing the teams to be laid out.
	 * @since 2018/03/19
	 */
	public void teams(int... __t)
	{
		if (__t == null)
			__t = new int[0];
		
		// Store input values first
		int[] teams = this._teams;
		int n = __t.length;
		for (int i = 0; i < n; i++)
			teams[i] = __t[i];
		for (int i = n; i < PlayerColor.MAX_PLAYERS; i++)
			teams[i] = i;
		
		// Store values into a normalization map to correct indexes
		int next = 0;
		Map<Integer, Integer> normalize = new HashMap<>();
		for (int i = 0; i < PlayerColor.MAX_PLAYERS; i++)
		{
			Integer k = teams[i];
			if (!normalize.containsKey(k))
				normalize.put(k, i);
		}
		
		// Map all values to their normalized values
		for (int i = 0; i < PlayerColor.MAX_PLAYERS; i++)
			teams[i] = normalize.get(teams[i]);
	}
}

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

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This specifies how a game is to be resumed when an input stream is input.
 *
 * @since 2018/03/19
 */
public enum ResumeMode
{
	/** Treat it as a saved game. */
	SAVED_GAME,
	
	/** Treat it as a replay. */
	REPLAY,
	
	/** End. */
	;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/game/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the main game related functions.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.game;

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/lcdui/Automap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.squirrelquarrel.ui.Viewport;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This class is used to draw and update the automap which is used to give the
 * position of terrain and objects around the map. This class handles the
 * drawing aspects of it.
 *
 * @since 2017/02/12
 */
public class Automap
{
	/** The viewport which stores where the screen is looking. */
	protected final Viewport viewport;
	
	/** The level to draw on. */
	protected final World world;
	
	/** The background terrain image. */
	protected final Image terrain;
	
	/** The active image to draw of the automap. */
	protected final Image active;
	
	/** This is used much. */
	protected final Graphics graphics;
	
	/** The automap width. */
	protected final int width;
	
	/** The automap height. */
	protected final int height;
	
	/** The level width in pixels. */
	protected final int levelpxw;
	
	/** The level height in pixels. */
	protected final int levelpxh;
	
	/**
	 * Initializes the automap.
	 *
	 * @param __v The viewport into the game.
	 * @param __w The automap width.
	 * @param __h The automap height.
	 * @throws NullPointerException On null arguments
	 * @since 2017/02/12
	 */
	public Automap(Viewport __v, int __w, int __h)
		throws NullPointerException
	{
		throw new todo.TODO();
		/*
		// Check
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.gameinterface = __gi;
		this.width = __w;
		this.height = __h;
		
		// Save active image for later
		Image active = Image.createImage(__w, __h);
		this.active = active;
		this.graphics = active.getGraphics();
		
		// Get level size
		Level level = __gi.level();
		this.level = level;
		int levelpxw = level.pixelWidth(),
			levelpxh = level.pixelHeight();
		this.levelpxw = levelpxw;
		this.levelpxh = levelpxh;
		
		// However, initialize the terrain layer now
		Image terrain = Image.createImage(__w, __h);
		this.terrain = terrain;
		__drawLayer(terrain.getGraphics(), false);
		*/
	}
	
	/**
	 * Returns the height of the automap.
	 *
	 * @return The automap height.
	 * @since 2017/02/12
	 */
	public int height()
	{
		return this.height;
	}
	
	/**
	 * Updates the automap and returns it.
	 *
	 * @return The updated automap.
	 * @since 2017/02/12
	 */
	public Image update()
	{
		throw new todo.TODO();
		/*
		GameInterface gameinterface = this.gameinterface;
		Image terrain = this.terrain;
		Image active = this.active;
		Graphics graphics = this.graphics;
		int width = this.width,
			height = this.height,
			levelpxw = this.levelpxw,
			levelpxh = this.levelpxh;
		
		// Full alpha
		graphics.setAlpha(0xFF);
		
		// Draw the terrain over the map
		graphics.drawImage(terrain, 0, 0, 0);
		
		// Draw the fog
		__drawLayer(graphics, true);
		
		// Draw units
		graphics.setAlpha(0xFF);
		
		// Draw where the viewport is in the automap
		graphics.setAlpha(0xFF);
		graphics.setColor(0x00FFFF);
		int viewx = gameinterface.viewportX(),
			viewy = gameinterface.viewportY(),
			vieww = gameinterface.viewportWidth(),
			viewh = gameinterface.viewportHeight();
		double pvx = width * ((double)viewx / (double)levelpxw),
			pvy = height * ((double)viewy / (double)levelpxh),
			pvw = width * ((double)vieww / (double)levelpxw),
			pvh = height * ((double)viewh / (double)levelpxh);
		graphics.drawRect((int)pvx, (int)pvy, (int)pvw, (int)pvh);
		
		// Draw a nice border around the map
		graphics.setColor(0xFFFFFF);
		graphics.drawRect(0, 0, width - 2, height - 2);
		
		// Return the active map
		return this.active;
		*/
	}
	
	/**
	 * Returns the width of the automap.
	 *
	 * @return The automap width.
	 * @since 2017/02/12
	 */
	public int width()
	{
		return this.width;
	}
	
	/**
	 * Draws a layer on the specified graphics.
	 *
	 * @param __g The target graphics to draw on.
	 * @param __fog If {@code true} then fog is drawn instead of tiles.
	 * @since 2017/02/15
	 */
	private void __drawLayer(Graphics __g, boolean __fog)
		throws NullPointerException
	{
		throw new todo.TODO();
		/*
		// Check
		if (__g == null)
			throw new NullPointerException("NARG");
		
		Player player = this.gameinterface.player();
		Level level = this.level;
		int width = this.width,
			height = this.height,
			levelpxw = this.levelpxw,
			levelpxh = this.levelpxh;
		
		// If drawing fog, keep it light
		if (__fog)
			__g.setAlphaColor(0xAF000000);
		
		// Otherwise terrain is always visible
		else
			__g.setAlpha(0xFF);
		
		// Drawing loop
		for (double sy = 0, dy = 0, msx = (double)levelpxw / width,
			msy = (double)levelpxh / height, enddy = height,
			enddx = width; dy < enddy; sy += msy, dy += 1)
			for (double sx = 0, dx = 0; dx < enddx; sx += msx, dx += 1)
			{
				// Do not draw over revealed areas
				if (__fog)
				{
					if (level.pixelRevealed(player, (int)sx, (int)sy))
						continue;
				}
				
				// Use terrain color
				else
					__g.setColor(
						level.pixelTerrain((int)sx, (int)sy).color());
				
				// Draw single pixel as a line
				__g.drawLine((int)dx, (int)dy, (int)dx + 1, (int)dy);
			}
		*/
	}
}

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

package net.multiphasicapps.squirrelquarrel.lcdui;

import net.multiphasicapps.squirrelquarrel.game.EventSource;
import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;

/**
 * Event source which grabs from the player's controller.
 *
 * @since 2019/03/24
 */
public class ControllerEventSource
	implements EventSource
{
	/** Game to control. */
	protected final Game game;
	
	/** Split-screen to determine which player is doing the action. */
	protected final SplitScreen splitscreen;
	
	/**
	 * Initializes the event source.
	 *
	 * @param __g The game used.
	 * @param __ss The split-screen for play.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public ControllerEventSource(Game __g, SplitScreen __ss)
		throws NullPointerException
	{
		if (__g == null || __ss == null)
			throw new NullPointerException("NARG");
		
		this.game = __g;
		this.splitscreen = __ss;
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/lcdui/GameInputHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.KeyListener;
import net.multiphasicapps.squirrelquarrel.world.Tile;

/**
 * This handles the input for the game such as which keys are held down and
 * buttons for perfomring actions.
 *
 * @since 2017/02/12
 */
public class GameInputHandler
	implements KeyListener, Runnable
{
	/** The maximum number of supported game actions. */
	public static final int GAME_ACTION_COUNT =
		16;
	
	/** Level panning speed. */
	private static final int _PANNING_SPEED =
		Tile.PIXEL_SIZE / 2;
	
	/** The game keys which are held down. */
	protected final boolean[] gamekeys =
		new boolean[GameInputHandler.GAME_ACTION_COUNT];
	
	/** Is on the automap dragging? */
	private volatile boolean _ondragmap;
	
	/** Disable automap drag. */
	private volatile boolean _nomapdrag;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyPressed(int __code, int __mods)
	{
		throw new todo.TODO();
		/*
		// Parse key and set the game action as being pressed
		try
		{
			int ga = this.gameinterface.getGameAction(__code);
			if (ga >= 0 && ga < GAME_ACTION_COUNT)
				this.gamekeys[ga] = true;
		}
		
		// Ignore, not a valid game action
		catch (IllegalArgumentException e)
		{
		}*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyReleased(int __code, int __mods)
	{
		throw new todo.TODO();
		/*
		// Parse key and set the game action as being released
		GameInterface gameinterface = this.gameinterface;
		try
		{
			int ga = gameinterface.getGameAction(__code);
			if (ga >= 0 && ga < GAME_ACTION_COUNT)
				this.gamekeys[ga] = false;
		}
		
		// Ignore, not a valid game action
		catch (IllegalArgumentException e)
		{
		}
		
		// Increase the game speed
		if (__code == '=' || __code == '+')
			gameinterface.setGameSpeed(gameinterface.gameSpeed().faster());
		
		// Lower the game speed
		else if (__code == '-' || __code == '_')
			gameinterface.setGameSpeed(gameinterface.gameSpeed().slower());*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyRepeated(int __code, int __mods)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Call when the pointer is dragged.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerDragged(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		__checkAutomapDrag(true, __x, __y);*/
	}
	
	/**
	 * Call when the pointer is pressed.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerPressed(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		__checkAutomapDrag(false, __x, __y);*/
	}
	
	/**
	 * Call when the pointer is released.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerReleased(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		// Cannot be dragging on the map
		this._ondragmap = false;
		this._nomapdrag = false;*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void run()
	{
		throw new todo.TODO();
		/*
		GameInterface gameinterface = this.gameinterface;
		boolean[] gamekeys = this.gamekeys;
		
		// Pan the viewport?
		double gsratio = gameinterface.gameSpeed().ratio();
		double xpan = _PANNING_SPEED * (gamekeys[Canvas.LEFT] ? -gsratio :
			(gamekeys[Canvas.RIGHT] ? gsratio : 0)),
			ypan = _PANNING_SPEED * (gamekeys[Canvas.UP] ? -gsratio :
			(gamekeys[Canvas.DOWN] ? gsratio : 0));
		gameinterface.translateViewport((int)xpan, (int)ypan);*/
	}
	
	/**
	 * Checks for dragging on the automap.
	 *
	 * @param __x The cursor X position.
	 * @param __y The cursor Y position.
	 * @param __drag Is this a drag?
	 * @since 2017/02/13
	 */
	private void __checkAutomapDrag(boolean __drag, int __x, int __y)
	{
		throw new todo.TODO();
		/*
		// Get the automap
		GameInterface gameinterface = this.gameinterface;
		Automap automap = gameinterface.automap();
		int amw = automap.width(),
			amh = automap.height(),
			vw = gameinterface.viewportWidth(),
			vh = gameinterface.viewportHeight(),
			amby = (vh - amh);
		
		// If the cursor is where the automap would be
		// However, if the automap was dragged on, always drag
		if (this._ondragmap ||
			(__x >= 0 && __x < amw && __y >= amby && __y < vh))
		{
			// Press was not on the map, so do not drag even if it enters
			// range
			if (__drag && this._nomapdrag)
				return;
			
			Level level = gameinterface.level();
			int lpxw = level.pixelWidth(),
				lpxh = level.pixelHeight();
			
			// Calculate viewport position
			double vx = (__x) * ((double)lpxw / amw),
				vy = (__y - amby) * ((double)lpxh / amh);
			gameinterface.setViewport(
				((int)vx) - (vw / 2),
				((int)vy) - (vh / 2));
			
			// Keep dragging on the map
			this._ondragmap = true;
		}
		
		// Initial click outside of the map, do not drag on it
		else
		{
			if (!__drag)
				this._nomapdrag = true;
		}*/
	}
}

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

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import net.multiphasicapps.squirrelquarrel.game.EventSource;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.ui.FrameSync;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;

/**
 * This class provides an interface to the game, allowing for input to be
 * handled along with the game itself.
 *
 * @since 2017/02/08
 */
public final class GameInterface
	extends Canvas
	implements FrameSync
{
	/** The game being played. */
	protected final GameLooper looper;
	
	/** Splitscreen. */
	protected final SplitScreen splitscreen;
	
	/** The renderer for the game. */
	protected final Renderer renderer;
	
	/** Controller input. */
	protected final ControllerEventSource controller;
	
	/**
	 * Initializes the game interface.
	 *
	 * @param __g The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameInterface(GameLooper __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Setup details
		this.setTitle("Squirrel Quarrel");
		
		this.looper = __g;
		SplitScreen splitscreen;
		this.splitscreen = (splitscreen = new SplitScreen(__g));
		this.renderer = new Renderer(__g, splitscreen);
		
		// Setup basic controller events
		ControllerEventSource controller = new ControllerEventSource(
			__g.game(), splitscreen);
		this.controller = controller;
		
		// If there is no source for events, just use controller events
		// generated from the user
		EventSource eswas = __g.eventSource();
		if (eswas == null)
			__g.setEventSource(controller);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	public final void frameRepaintRequest(int __framenum)
	{
		// Just have it get repainted
		this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/18
	 */
	@Override
	public void paint(Graphics __g)
	{
		// Get the canvas size
		int cw = this.getWidth(),
			ch = this.getHeight();
		
		// Configure splitscreens
		SplitScreen splitscreen = this.splitscreen;
		splitscreen.configure(cw, ch);
		
		// Store the original clip
		int ox = __g.getClipX(),
			oy = __g.getClipY(),
			ow = __g.getClipWidth(),
			oh = __g.getClipHeight();
		
		// Draw every screen
		Renderer renderer = this.renderer;
		for (int i = 0, n = splitscreen.count(); i < n; i++)
		{
			// Restore drawing parameters
			__g.translate(-__g.getTranslateX(), -__g.getTranslateY());
			__g.setClip(ox, oy, ow, oh);
			
			// Draw the screen
			renderer.paint(splitscreen.get(i), __g);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerDragged(int __x, int __y)
	{
		todo.DEBUG.note("pointerDragged(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerPressed(int __x, int __y)
	{
		todo.DEBUG.note("pointerPressed(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerReleased(int __x, int __y)
	{
		todo.DEBUG.note("pointerReleased(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	protected void sizeChanged(int __w, int __h)
	{
		// Super-class might do some things
		super.sizeChanged(__w, __h);
		
		// Reconfigure the screens
		this.splitscreen.configure(__w, __h);
	}
}

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

package net.multiphasicapps.squirrelquarrel.lcdui;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.game.ResumeMode;

/**
 * This is the main midlet entry point for Squirrel Quarrel.
 *
 * @since 2017/02/08
 */
public class MainMidlet
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Get the display for this MIDlet
		Display disp = Display.getDisplay(this);
		
		// For initial testing purposes, this will setup and play a game
		// then once it finishes it will reload it and allow watching the
		// game which was just played
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			// Setup game with the loop
			GameLooper looper = new GameLooper(baos, null);
			
			// Setup game canvas with an initial game
			GameInterface gi = new GameInterface(looper);
			disp.setCurrent(gi);
			
			// Run the game itself until it terminates
			looper.run(gi);
			
			// When the game finishes just play it back and hope it worked!
			baos.flush();
			try (ByteArrayInputStream bais = new ByteArrayInputStream(
				baos.toByteArray()))
			{
				// Setup new loop resuming from the save game but using it
				// as a replay
				looper = GameLooper.resume(null, ResumeMode.REPLAY, bais);
				
				// Setup new canvas to show that game instead
				gi = new GameInterface(looper);
				disp.setCurrent(gi);
				
				// Run the game logic in that
				looper.run(gi);
			}
		}
		
		// {@squirreljme.error BE02 Failed to rea/write something.}
		catch (IOException e)
		{
			throw new RuntimeException("BE02", e);
		}
	}
}

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

package net.multiphasicapps.squirrelquarrel.lcdui;

import cc.squirreljme.runtime.lcdui.image.XPMReader;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;
import net.multiphasicapps.squirrelquarrel.world.TerrainType;
import net.multiphasicapps.squirrelquarrel.world.Tile;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This is used to cache mega tiles as single large images since drawing a
 * large image is faster than drawing many smaller images.
 *
 * @since 2017/02/11
 */
public class MegaTileCacher
{
	/** The cache of terrain tiles. */
	private static final Map<TerrainType, Reference<Image>> _TILE_CACHE =
		new HashMap<>();
	
	/** The level to cache for. */
	protected final World world;
	
	/** The cache of tiles. */
	protected final Map<MegaTile, Reference<Image>> cache =
		new HashMap<>();
	
	/**
	 * Initializes the mega tile cacher.
	 *
	 * @param __l The level to cache for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public MegaTileCacher(World __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.world = __l;
	}
	
	/**
	 * Caches the image for the given megatile.
	 *
	 * @param __x The X coordinate in megatiles.
	 * @param __y The Y coordinate in megatiles.
	 * @return The cached image for the given mega tile.
	 * @since 2017/02/11
	 */
	public Image cacheMegaTile(int __x, int __y)
	{
		return this.cacheMegaTile(this.world.megaTile(__x, __y));
	}
	
	/**
	 * Caches the image for the given megatile.
	 *
	 * @param __mt The mega tile to cache.
	 * @return The cached image for the given mega tile.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public Image cacheMegaTile(MegaTile __mt)
		throws NullPointerException
	{
		// Check
		if (__mt == null)
			throw new NullPointerException("NARG");
		
		Map<MegaTile, Reference<Image>> cache = this.cache;
		Reference<Image> ref = cache.get(__mt);
		Image rv = null;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Create image to draw on
			rv = Image.createImage(MegaTile.PIXEL_SIZE,
				MegaTile.PIXEL_SIZE);
			
			// Draw on it
			Graphics g = rv.getGraphics();
			
			// Do not need to check cache for the same tile
			TerrainType oldtype = null;
			Image tilepic = null;
			
			// Go through the megatile to draw
			for (int ty = 0, dy = 0; ty < MegaTile.TILES_PER_MEGA_TILE;
				ty++, dy += Tile.PIXEL_SIZE)
				for (int tx = 0, dx = 0; tx < MegaTile.TILES_PER_MEGA_TILE;
					tx++, dx += Tile.PIXEL_SIZE)
				{
					// If the terrain type is the same then use the existing
					// image of it rather than checking the cache every
					// single time
					TerrainType type = __mt.subTileTerrain(tx, ty);
					if (type != oldtype)
					{
						oldtype = type;
						tilepic = MegaTileCacher.__cacheTile(type);
					}
					
					// Draw it
					g.drawImage(tilepic, dx, dy, 0);
				}
			
			// Cache
			this.cache.put(__mt, new WeakReference<>(rv));
		}
		
		return rv;
	}
	
	/**
	 * Caches the specified tile.
	 *
	 * @param __t The terrain to get the image for.
	 * @return The image for the given terrain.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	private static final Image __cacheTile(TerrainType __t)
		throws NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Get ref
		Reference<Image> ref = MegaTileCacher._TILE_CACHE.get(__t);
		Image rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			try
			{
				MegaTileCacher._TILE_CACHE.put(__t, new WeakReference<>(
					(rv = new XPMReader(__t.imageStream()).parse())));
			}
			
			// {@squirreljme.error BE03 Failed to read the image data for the
			// specified file. (The terrain type)}
			catch (IOException e)
			{
				throw new RuntimeException(String.format("BE03 %s", __t), e);
			}
		
		return rv;
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/lcdui/Renderer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.Graphics;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.ui.GameScreen;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;

/**
 * This contains the renderer for the level and performs the actual drawing
 * of the game to the canvas.
 *
 * @since 2018/03/18
 */
public final class Renderer
{
	/** The game looper to draw. */
	protected final GameLooper looper;
	
	/** The splitscreens to have viewports for. */
	protected final SplitScreen splitscreen;
	
	/**
	 * Initializes the renderer.
	 *
	 * @param __g The game looper to use.
	 * @param __ss The splitscreen to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Renderer(GameLooper __g, SplitScreen __ss)
		throws NullPointerException
	{
		if (__g == null || __ss == null)
			throw new NullPointerException("NARG");
		
		this.looper = __g;
		this.splitscreen = __ss;
	}
	
	/**
	 * Paints the game to the given graphics.
	 *
	 * @param __scr The screen to draw for.
	 * @param __g The graphics to draw on.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/08
	 */
	public void paint(GameScreen __scr, Graphics __g)
		throws NullPointerException
	{
		if (__scr == null || __g == null)
			throw new NullPointerException("NARG");
		
		// Get basic information
		Player player = __scr.player();
		PlayerColor playercolor = player.color();
		int sx = __scr.x(),
			sy = __scr.y(),
			sw = __scr.width(),
			sh = __scr.height();
		
		/*
		// If already painting, do not duplicate a paint
		if (this._inpaint)
			return;
		this._inpaint = true;
		
		// Get the current frame the game is on
		Game game = this.game;
		this._renderframe = game.frameCount();
		Level level = game.level();
		int framenum = game.frameCount();
		Player viewplayer = this._viewplayer;
		
		// Get the viewport
		int viewx = this._viewx,
			viewy = this._viewy,
			vieww = this._vieww,
			viewh = this._viewh;
		
		// MegaTiles do not often change
		MegaTileCacher mtcacher = this.mtcacher;
		
		// Megatile draw loop
		int msx = this._msx,
			msy = this._msy,
			mex = this._mex,
			mey = this._mey;
		for (int my = msy,
			sy = mapToScreenY(my * MegaTile.MEGA_TILE_PIXEL_SIZE),
			bsx = mapToScreenX(msx * MegaTile.MEGA_TILE_PIXEL_SIZE);
			my < mey; my++, sy += MegaTile.MEGA_TILE_PIXEL_SIZE)
			for (int mx = msx, sx = bsx; mx < mex; mx++,
				sx += MegaTile.MEGA_TILE_PIXEL_SIZE)
			{
				// Get the megatile here
				MegaTile mt = level.megaTile(mx, my);
				
				// Draw it
				__g.drawImage(mtcacher.cacheMegaTile(mt), sx, sy, 0);
					
				// Draw units in this mega tile
				__drawUnits(__g, mt);
				
				// Setup flags for fog drawing
				__g.setColor(0x000000);
				__g.setStrokeStyle(Graphics.DOTTED);
				
				// Draw fog scanlines
				for (int sty = 0, psy = sy, bpsx = sx;
					sty < MegaTile.TILES_PER_MEGA_TILE;
					sty++, psy += MegaTile.TILE_PIXEL_SIZE)
					for (int stx = 0, psx = bpsx;
						stx < MegaTile.TILES_PER_MEGA_TILE;
						stx++, psx += MegaTile.TILE_PIXEL_SIZE)
					{
						// Ignore revealed tiles
						if (mt.subTileRevealed(viewplayer, stx, sty))
							continue;
						
						// Otherwise find the next revealed tile (or the end)
						int end;
						for (end = stx + 1; end < MegaTile.TILES_PER_MEGA_TILE;
							end++)
							if (mt.subTileRevealed(viewplayer, end, sty))
								break;
						
						// Draw dotted lines for fog
						int endpx = sx + (stx * MegaTile.TILE_PIXEL_SIZE) +
							(end * MegaTile.TILE_PIXEL_SIZE),
							endpy = psy + MegaTile.TILE_PIXEL_SIZE;
						for (int py = psy; py < endpy; py++)
						{
							// Lines off to the side can get clipped where the
							// dot patterns stop being correct
							int bx = (psx < 0 ? 0 : psx);
							__g.drawLine(bx + (py & 1), py, endpx, py);
						}
						
						// Set current spot to the end
						stx = end;
						psx = bpsx + (end * MegaTile.TILE_PIXEL_SIZE);
					}
			}
		
		// Reset translation for the HUD
		__g.translate(-__g.getTranslateX(), -__g.getTranslateY());
		
		// Draw the automap in the bottom left corner
		Image map = this.automap.update();
		__g.setAlpha(160);
		__g.drawImage(map, 0, viewh, Graphics.LEFT | Graphics.BOTTOM);
		
		// Draw debug image
		__g.setAlpha(255);
		Image debugimage = this.debugimage;
		int ww = debugimage.getWidth(), hh = debugimage.getHeight();
		int sx = 50 - 5, sy = 50 - 5,
			ex = sx + ((ww * 3) + 10), ey = sy + ((hh * 3) + 10);
		__g.drawRegion(debugimage, 0, 0, ww, hh, Sprite.TRANS_NONE,
			sx + 5, sy + 5, 0, ww * 3, hh * 3);
		__g.setColor(0xFF0000);
		__g.drawLine(sx, sy, ex, sy);
		__g.setColor(0x00FF00);
		__g.drawLine(ex, sy, ex, ey);
		__g.setColor(0x0000FF);
		__g.drawLine(ex, ey, sx, ey);
		__g.setColor(0xFFFF00);
		__g.drawLine(sx, ey, sx, sy);
		
		// No longer painting
		this._inpaint = false;
		*/
		
		// Draw the player's color around the screen
		__g.setColor(playercolor.rgb());
		__g.drawRect(sx, sy, sw - 2, sh - 2);
	}
	
	/**
	 * Draws units in this megatile.
	 *
	 * @param __g The target graphics.
	 * @param __mt The megatile to source from.
	 * @since 2017/02/17
	 */
	private void __drawUnits(Graphics __g, MegaTile __mt)
	{
		throw new todo.TODO();
		/*
		// Store the old clip
		int oldcx = __g.getClipX(),
			oldcy = __g.getClipY(),
			oldcw = __g.getClipWidth(),
			oldch = __g.getClipHeight();
		
		// Used for selection boxes
		__g.setColor(0xFFFF00);
		__g.setStrokeStyle(Graphics.SOLID);
		
		// Set new clipping so units are not drawn outside of the tile and
		// potentially into other tiles
		int mdx = mapToScreenX(__mt.x() * MegaTile.MEGA_TILE_PIXEL_SIZE),
			mdy = mapToScreenY(__mt.y() * MegaTile.MEGA_TILE_PIXEL_SIZE);
		__g.setClip(mdx, mdy, mdx + MegaTile.MEGA_TILE_PIXEL_SIZE,
			mdy + MegaTile.MEGA_TILE_PIXEL_SIZE);
		
		// Load units
		List<Unit.Pointer> drawunits = this._drawunits;
		drawunits.clear();
		__mt.loadLinkedUnits(drawunits);
		
		// Draw them
		for (int i = 0, n = drawunits.size(); i < n; i++)
			try
			{
				// Get unit, and its information
				Unit unit = drawunits.get(i).get();
				UnitType type = unit.type();
				if (type == null)
					continue;
				UnitInfo info = type.info();
				
				// Get draw position on the screen
				int dx = mapToScreenX(unit.centerX()),
					dy = mapToScreenY(unit.centerY());
				
				// Draw sprite
				__g.drawRect(dx - 10, dy - 10, 20, 20);
			}
			
			// Ignore due to threading potential
			catch (UnitDeletedException e)
			{
			}
		
		// Restore the old clip
		__g.setClip(oldcx, oldcy, oldcw, oldch);
		*/
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/lcdui/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the LCDUI front-end for Squirrel Quarrel.
 *
 * @since 2017/02/08
 */

package net.multiphasicapps.squirrelquarrel.lcdui;

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the implementation of the game, it is used as a
 * library which is implemented by front-ends.
 *
 * @since 2017/02/08
 */

package net.multiphasicapps.squirrelquarrel;

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

package net.multiphasicapps.squirrelquarrel.player;

/**
 * This represents a game player, where actions may be performed and such.
 *
 * @since 2017/02/13
 */
public final class Player
{
	/** The color of this player. */
	protected final PlayerColor color;
	
	/** The team of this player. */
	protected final PlayerColor team;
	
	/** Is this player playing? */
	protected final boolean playing;
	
	/** The vision mask for this player. */
	private volatile int _visionmask;
	
	/**
	 * Initializes the game player.
	 *
	 * @param __c The player color.
	 * @param __team The team this player is on.
	 * @param __playing Is this player playing?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/14
	 */
	public Player(PlayerColor __c, PlayerColor __team, boolean __playing)
		throws NullPointerException
	{
		// Check
		if (__c == null || __team == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.color = __c;
		this.team = __team;
		this.playing = __playing;
		
		// The player always has vision to self
		this._visionmask = __c.mask();
	}
	
	/**
	 * Returns the player color.
	 *
	 * @return The player color.
	 * @since 2017/02/14
	 */
	public final PlayerColor color()
	{
		return this.color;
	}
	
	/**
	 * Is this player playing?
	 *
	 * @return If this player is playing.
	 * @since 2018/03/19
	 */
	public final boolean isPlaying()
	{
		return this.playing;
	}
	
	/**
	 * Returns the team that this player is on.
	 *
	 * @return The team the player is on.
	 * @since 2018/03/19
	 */
	public final PlayerColor team()
	{
		return this.team;
	}
	
	/**
	 * This returns the mask that is used to check the vision bits.
	 *
	 * @return The bits used for vision.
	 * @since 2017/02/13
	 */
	public final int visionMask()
	{
		return this._visionmask;
	}
	
	/**
	 * Runs the player logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
	}
}

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

package net.multiphasicapps.squirrelquarrel.player;

/**
 * The represents the color of a player.
 *
 * The colors here are from Electronic Art's Accessibility account which
 * specify the set of colors which are best used for all kinds of color
 * blind users to they can differentiate between all the colors.
 *
 * https://twitter.com/ea_accessible/status/968592657848193024
 * https://twitter.com/ea_accessible/status/968595073184092160
 *
 * @since 2017/02/10
 */
public enum PlayerColor
{
	/** Red. */
	RED("Red", 0xDE4949),
	
	/** Yellow. */
	YELLOW("Yellow", 0xFFB937),
	
	/** Green. */
	GREEN("Green", 0x30B06E),
	
	/** Blue. */
	BLUE("Blue", 0x33521E1),
	
	/** Purple. */
	PURPLE("Purple", 0x533364),
	
	/** Gray. */
	GRAY("Gray", 0x5A7D8B),
	
	/** End. */
	;
	
	/** The maximum number of players that can play at once. */
	public static final int MAX_PLAYERS =
		4;
	
	/** The number of player colors. */
	public static final int NUM_COLORS =
		6;
	
	/** Creeps that just annoy you. */
	public static final PlayerColor CREEPS =
		PlayerColor.PURPLE;
	
	/** The neutral player. */
	public static final PlayerColor NEUTRAL =
		PlayerColor.GRAY;
	
	/** The ARGB color code. */
	protected final int argb;
	
	/** The RGB color code. */
	protected final int rgb;
	
	/** The color name. */
	protected final String name;
	
	/**
	 * Initializes the color code.
	 *
	 * @param __name The name of the color.
	 * @param __rgb The RGB used for the player color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	PlayerColor(String __name, int __rgb)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.argb = __rgb | 0xFF000000;
		this.rgb = __rgb & 0xFFFFFF;
	}
	
	/**
	 * The ARGB code for the player.
	 *
	 * @return The ARGB color.
	 * @since 2017/02/10
	 */
	public final int argb()
	{
		return this.argb;
	}
	
	/**
	 * The RGB code for the player.
	 *
	 * @return The RGB color.
	 * @since 2017/02/10
	 */
	public final int rgb()
	{
		return this.rgb;
	}
	
	/**
	 * Returns the mask that is used for the player.
	 *
	 * The mask is used for stuff such as alliances, vision, and detection.
	 *
	 * Players outside of the basic four players have no mask.
	 *
	 * @return The player mask.
	 * @since 2017/02/14
	 */
	public final int mask()
	{
		// Only use mask for players that are in the game
		int i = this.ordinal();
		if (i < PlayerColor.MAX_PLAYERS)
			return 1 << i;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
	
	/**
	 * This converts the player ordinal back into the player color.
	 *
	 * @param __i The ordinal.
	 * @return The player color for that ordinal.
	 * @since 2017/02/14
	 */
	public static final PlayerColor of(int __i)
	{
		// Depends
		switch (__i)
		{
				// Normal colors;
			case 0: return PlayerColor.RED;
			case 1: return PlayerColor.YELLOW;
			case 2: return PlayerColor.GREEN;
			case 3: return PlayerColor.BLUE;
			case 4: return PlayerColor.PURPLE;
			case 5: return PlayerColor.GRAY;
			
				// {@squirreljme.error BE04 Player index out of range. (The
				// player index)}
			default:
				throw new IllegalArgumentException(String.format("BE04 %d",
					__i));
		}
	}
}

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

package net.multiphasicapps.squirrelquarrel.player;

import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This manages the players which are in the game.
 *
 * @since 2018/03/18
 */
public final class Players
{
	/** Players in the game. */
	private final Player[] _players =
		new Player[PlayerColor.NUM_COLORS];
	
	/**
	 * Initializes the players.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Players(InitialSettings __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Needed to initialize the team a player is on
		int numplayers = __is.players();
		int[] teams = __is.teams();
		
		// Initialize players
		Player[] players = this._players;
		for (int i = 0, n = players.length; i < n; i++)
			players[i] = new Player(PlayerColor.of(i),
				PlayerColor.of(teams[i]), i < numplayers);
	}
	
	/**
	 * Returns the player by the given index.
	 *
	 * @param __i The index of the player to get.
	 * @return The player for the given index.
	 * @throws IllegalArgumentException If the index is not within bounds.
	 * @since 2017/02/14
	 */
	public Player get(int __i)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE05 Invalid player index. (The index)}
		if (__i < 0 || __i >= PlayerColor.NUM_COLORS)
			throw new IllegalArgumentException(String.format("BE05 %d", __i));
		
		return this._players[__i];
	}
	
	/**
	 * Returns the player by the given color.
	 *
	 * @param __p The color to get the player of.
	 * @return The player for the given color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/14
	 */
	public Player get(PlayerColor __p)
		throws NullPointerException
	{
		// Check
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return this._players[__p.ordinal()];
	}
	
	/**
	 * Runs each individual player.
	 *
	 * @param __framenum The current game frame.
	 * @since 2018/03/18
	 */
	public void run(int __framenum)
	{
		// Run the player logic for each player
		Player[] players = this._players;
		for (int i = 0, n = players.length; i < n; i++)
			players[i].run(__framenum);
	}
}

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

package net.multiphasicapps.squirrelquarrel.player;

/**
 * The represents the species which are available in the game.
 *
 * @since 2017/02/14
 */
public enum Species
{
	/** Not a major species. */
	NONE,
	
	/** Chlorophids, plant based species. */
	CHLOROPHID,
	
	/** End. */
	;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/player/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains player related classes.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.player;

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/ui/FrameSync.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

/**
 * This is implemented by classes that need to perform some actions after
 * a game frame has run.
 *
 * @since 2018/03/19
 */
public interface FrameSync
{
	/**
	 * This is called when the game has finished running the game logic
	 * and is requesting that the game be repainted accordingly.
	 *
	 * @param __framenum The frame which has just finished.
	 * @since 2018/03/19
	 */
	void frameRepaintRequest(int __framenum);
}

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

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This represents a single game screen which contains a viewport and
 * rendering information.
 *
 * @since 2018/03/19
 */
public final class GameScreen
{
	/** The game being looped. */
	protected final GameLooper looper;
	
	/** The player being drawn. */
	protected final Player player;
	
	/** The viewport for the screen. */
	protected final Viewport viewport;
	
	/** The screen X position. */
	private volatile int _sx;
	
	/** The screen Y position. */
	private volatile int _sy;
	
	/** The screen width. */
	private volatile int _sw;
	
	/** The screen height. */
	private volatile int _sh;
	
	/**
	 * Initializes this game screen.
	 *
	 * @param __g The game to draw.
	 * @param __p The player being drawn.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/03/19
	 */
	public GameScreen(GameLooper __g, Player __p)
		throws NullPointerException
	{
		if (__g == null || __p == null)
			throw new NullPointerException("NARG");
		
		this.looper = __g;
		this.player = __p;
		
		// Initialize the viewport
		World world = __g.game().world();
		this.viewport = new Viewport(world.pixelWidth(),
			world.pixelHeight());
	}
	
	/**
	 * Configures this screen.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/03/19
	 */
	public final void configure(int __x, int __y, int __w, int __h)
	{
		this._sx = __x;
		this._sy = __y;
		this._sw = __w;
		this._sh = __h;
		
		// Adjust the viewport accordingly
		this.viewport.setSize(__w, __h);
	}
	
	/**
	 * Returns the height.
	 *
	 * @return The height.
	 * @since 2018/03/22
	 */
	public final int height()
	{
		return this._sh;
	}
	
	/**
	 * Returns the player being drawn.
	 *
	 * @return The player to draw.
	 * @since 2018/03/22
	 */
	public final Player player()
	{
		return this.player;
	}
	
	/**
	 * Returns the viewport of the view.
	 *
	 * @return The game viewport.
	 * @since 2018/03/22
	 */
	public final Viewport viewport()
	{
		return this.viewport;
	}
	
	/**
	 * Returns the width.
	 *
	 * @return The width.
	 * @since 2018/03/22
	 */
	public final int width()
	{
		return this._sw;
	}
	
	/**
	 * Returns the X position.
	 *
	 * @return The X position.
	 * @since 2018/03/22
	 */
	public final int x()
	{
		return this._sx;
	}
	
	/**
	 * Returns the Y position.
	 *
	 * @return The Y position.
	 * @since 2018/03/22
	 */
	public final int y()
	{
		return this._sy;
	}
}

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

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.player.Players;

/**
 * This class is used to manage multiple screen spaces so that multiple players
 * can play on the same screen at once.
 *
 * @since 2018/03/19
 */
public final class SplitScreen
{
	/** Screens that may be visible. */
	private final GameScreen[] _screens =
		new GameScreen[PlayerColor.MAX_PLAYERS];
	
	/** The order of the screens. */
	private final PlayerColor[] _order =
		new PlayerColor[PlayerColor.MAX_PLAYERS];
	
	/** The number of visible screens. */
	private volatile int _numscreens =
		1;
	
	/** The width of the surface. */
	private volatile int _surfacew =
		1;
	
	/** The height of the surface. */
	private volatile int _surfaceh =
		1;
	
	/**
	 * Initializes the split screen.
	 *
	 * @param __loop The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/03/19
	 */
	public SplitScreen(GameLooper __loop)
		throws NullPointerException
	{
		if (__loop == null)
			throw new NullPointerException("NARG");
		
		Players players = __loop.game().players();
		
		GameScreen[] screens = this._screens;
		PlayerColor[] order = this._order;
		
		// Initialize each screen
		int playercount = 0;
		for (int i = 0, n = screens.length; i < n; i++)
		{
			Player p = players.get(i);
			order[i] = p.color();
			screens[i] = new GameScreen(__loop, p);
			if (p.isPlaying())
				playercount++;
		}
		this._numscreens = playercount;
	}
	
	/**
	 * Configure the screens for the given size.
	 *
	 * @param __w The screen width.
	 * @param __h The screen height.
	 * @since 2018/03/19
	 */
	public final void configure(int __w, int __h)
	{
		int numscreens = this._numscreens;
		GameScreen[] screens = this._screens;
		
		// Just get all the player screens for now
		GameScreen a = screens[0],
			b = screens[1],
			c = screens[2],
			d = screens[3];
		
		// These will be used
		int midx = __w >> 1,
			midy = __h >> 1;
		
		// Depends on the screen space
		switch (numscreens)
		{
				// Single player
			case 1:
				a.configure(0, 0, __w, __h);
				break;
				
				// Two players
			case 2:
				// Split vertically for wider screens
				if (__w > __h)
				{
					a.configure(0, 0, midx, __h);
					b.configure(midx, 0, midx, __h);
				}
				
				// Otherwise split horizontally
				else
				{
					a.configure(0, 0, __w, midy);
					b.configure(0, midy, __w, midy);
				}
				break;
				
				// 3/4 player split
			case 3:
			case 4:
			default:
				a.configure(0, 0, midx, midy);
				b.configure(midx, 0, midx, midy);
				c.configure(0, midy, midx, midy);
				d.configure(midx, midy, midx, midy);
				break;
		}
	}
	
	/**
	 * Returns the number of screens to draw.
	 *
	 * @return The screen count.
	 * @since 2018/03/22
	 */
	public final int count()
	{
		return this._numscreens;
	}
	
	/**
	 * Gets the screen from the given index.
	 *
	 * @param __i The screen to get.
	 * @return The given screen.
	 * @throws IndexOutOfBoundsException If the screen is outside of the
	 * player bounds.
	 * @since 2018/03/22
	 */
	public final GameScreen get(int __i)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE06 The game screen which was requested is
		// outside of the player bounds.}
		if (__i < 0 || __i >= this._numscreens)
			throw new IndexOutOfBoundsException("BE06");
		
		return this._screens[this._order[__i].ordinal()];
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/ui/Viewport.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.world.MegaTile;

/**
 * This represents a viewport into the level, it does not contain any
 * rendering information.
 *
 * @since 2018/03/18
 */
public final class Viewport
{
	/** The level width in pixels. */
	protected final int levelwidth;
	
	/** The level height in pixels. */
	protected final int levelheight;
	
	/** The viewport X position. */
	private volatile int _viewx;
	
	/** The viewport Y position. */
	private volatile int _viewy;
	
	/** The view width. */
	private volatile int _vieww;
	
	/** The view height. */
	private volatile int _viewh;
	
	/** The starting X megatile. */
	private volatile int _msx;
	
	/** The starting Y megatile. */
	private volatile int _msy;
	
	/** The ending X megatile. */
	private volatile int _mex;
	
	/** The ending Y megatile. */
	private volatile int _mey;
	
	/**
	 * Initializes the viewport information.
	 *
	 * @param __lw The level width.
	 * @param __lh The level height.
	 * @throws IllegalArgumentException If the width and/or height are zero or
	 * negative.
	 * @since 2018/03/18
	 */
	public Viewport(int __lw, int __lh)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE07 The viewport cannot have a negative size.}
		if (__lw <= 0 || __lh <= 0)
			throw new IllegalArgumentException("BE07");
		
		this.levelwidth = __lw;
		this.levelheight = __lh;
		
		// Use a default size for the viewport
		this.setSize(1, 1);
	}
	
	/**
	 * Converts a map X coordinate to a screen X coordinate.
	 *
	 * @param __x The input X coordinate.
	 * @return The output X coordinate.
	 * @since 2017/02/12
	 */
	public int mapToScreenX(int __x)
	{
		return __x - this._viewx;
	}
	
	/**
	 * Converts a map Y coordinate to a screen Y coordinate.
	 *
	 * @param __y The input Y coordinate.
	 * @return The output y coordinate.
	 * @since 2017/02/12
	 */
	public int mapToScreenY(int __y)
	{
		return __y - this._viewy;
	}
	
	/**
	 * Sets the viewport position.
	 *
	 * @param __x The absolute X position.
	 * @param __y The absolute Y position.
	 * @since 2017/02/10
	 */
	public void setViewport(int __x, int __y)
	{
		// Translate the viewport
		int viewx = __x,
			viewy = __y,
			vieww = this._vieww,
			viewh = this._viewh,
			levelpxw = this.levelwidth,
			levelpxh = this.levelheight;
		
		// Cap right side
		if (viewx + vieww >= levelpxw - 1)
			viewx = (levelpxw - vieww) - 1;
		
		// Cop bottom side
		if (viewy + viewh >= levelpxh - 1)
			viewy = (levelpxh - viewh) - 1;
		
		// Cap left side
		if (viewx < 0)
			viewx = 0;
		
		// Cap top
		if (viewy < 0)
			viewy = 0;
		
		// Set new viewport
		this._viewx = viewx;
		this._viewy = viewy;
		
		// Recalculate tiles in view
		int msx = this.screenToMapX(0) / MegaTile.PIXEL_SIZE,
			msy = this.screenToMapY(0) / MegaTile.PIXEL_SIZE,
			mex = (this.screenToMapX(vieww) / MegaTile.PIXEL_SIZE) + 1,
			mey = (this.screenToMapY(viewh) / MegaTile.PIXEL_SIZE) + 1;
		
		// Cap
		mex = Math.min(mex, levelpxw / MegaTile.PIXEL_SIZE);
		mey = Math.min(mey, levelpxh / MegaTile.PIXEL_SIZE);
		
		// Set
		this._msx = msx;
		this._msy = msy;
		this._mex = mex;
		this._mey = mey;
	}
	
	/**
	 * Converts a screen X coordinate to a map X coordinate.
	 *
	 * @param __x The input X coordinate.
	 * @return The output X coordinate.
	 * @since 2017/02/12
	 */
	public int screenToMapX(int __x)
	{
		return this._viewx + __x;
	}
	
	/**
	 * Converts a screen Y coordinate to a map Y coordinate.
	 *
	 * @param __y The input Y coordinate.
	 * @return The output y coordinate.
	 * @since 2017/02/12
	 */
	public int screenToMapY(int __y)
	{
		return this._viewy + __y;
	}
	
	/**
	 * Sets the size of the viewport
	 *
	 * @param __w The new width.
	 * @param __h The new height.
	 * @throws IllegalArgumentException If the width and/or height is zero
	 * or negative.
	 * @since 2017/02/10
	 */
	public void setSize(int __w, int __h)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE08 Cannot set the viewport size to be zero
		// or negative.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("BE08");
		
		// Correct the viewport
		this._vieww = __w;
		this._viewh = __h;
		this.translateViewport(0, 0);
	}
	
	/**
	 * Translates the viewport.
	 *
	 * @param __x The relative X translation.
	 * @param __y The relative Y translation.
	 * @since 2017/02/10
	 */
	public void translateViewport(int __x, int __y)
	{
		this.setViewport(this._viewx + __x, this._viewy + __y);
	}
	
	/**
	 * Returns the height of the viewport.
	 *
	 * @return The viewport height.
	 * @since 2017/02/12
	 */
	public int viewportHeight()
	{
		return this._viewh;
	}
	
	/**
	 * Returns the width of the viewport.
	 *
	 * @return The viewport width.
	 * @since 2017/02/12
	 */
	public int viewportWidth()
	{
		return this._vieww;
	}
	
	/**
	 * Returns the X position of the viewport.
	 *
	 * @return The viewport X position.
	 * @since 2017/02/12
	 */
	public int viewportX()
	{
		return this._viewx;
	}
	
	/**
	 * Returns the Y position of the viewport.
	 *
	 * @return The viewport Y position.
	 * @since 2017/02/12
	 */
	public int viewportY()
	{
		return this._viewy;
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/ui/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes which can be used in any UI sense.
 *
 * @since 2018/03/19
 */

package net.multiphasicapps.squirrelquarrel.ui;

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * The type of abilities available.
 *
 * @since 2019/03/24
 */
public enum AbilityType
{
	/** Regenerates HP. */
	REGENERATES_HP,
	
	/** End. */
	;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/units/BaseUnitInfo.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
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
191
192
193
194
195
196
197
198
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import net.multiphasicapps.squirrelquarrel.util.ConstantFixedPoint;
import net.multiphasicapps.squirrelquarrel.util.Dimension;
import net.multiphasicapps.squirrelquarrel.util.Point;
import net.multiphasicapps.squirrelquarrel.world.Tile;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This contains the base information about a unit which is fixed and never
 * changes.
 *
 * @since 2017/02/14
 */
public final class BaseUnitInfo
{
	/** The type ID of the unit. */
	public final int typeid;
	
	/** The name of the unit. */
	public final String name;
	
	/** Unit hitpoints. */
	public final int hp;
	
	/** Unit shields. */
	public final int shields;
	
	/** Armor. */
	public final int armor;
	
	/** Unit size. */
	public final UnitSize size;
	
	/** The cost in salt. */
	public final int salt;
	
	/** The cost in methane. */
	public final int methane;
	
	/** The build time in frames. */
	public final int buildtime;
	
	/** The supply provided. */
	public final int supplyprovided;
	
	/** The supply cost. */
	public final int supplycost;
	
	/** The dimension of the unit in pixels. */
	public final Dimension pixeldimension;
	
	/** The offset. */
	public final Point offset;
	
	/** Center point offset for the unit. */
	public final Point centerpointoffset;
	
	/** The center point offset used for buildings (based on tile grid). */
	public final Point buildingcenterpointoffset;
	
	/** The unit size in tiles (for buildings). */
	public final Dimension tiledimension;
	
	/** The dimenion of the unit in pixels matching the tiled size. */
	public final Dimension pixeltiledimension;
	
	/** The sight range. */
	public final int sight;
	
	/** The score for creating this unit. */
	public final int scorebuild;
	
	/** The score for destroying this unit. */
	public final int scoredestroy;
	
	/** The speed of this unit, in 16.16 fixed point. */
	public final ConstantFixedPoint speed;
	
	/**
	 * Initializes the unit information from the given manifest.
	 *
	 * @param __tid Unit type ID.
	 * @param __m The input unit manifest.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	BaseUnitInfo(int __tid, JavaManifest __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Type ID is used to modify unit details
		this.typeid = __tid;
		
		// Need the attributes!
		JavaManifestAttributes attr = __m.getMainAttributes();
		
		// Load these values directly
		this.name = attr.getValue("name", "Squirrels are cute!");
		this.hp = Integer.parseInt(
			attr.getValue("hp", "0"));
		this.shields = Integer.parseInt(
			attr.getValue("shields", "0"));
		this.armor = Integer.parseInt(
			attr.getValue("armor", "0"));
		this.salt = Integer.parseInt(
			attr.getValue("salt-cost", "0"));
		this.methane = Integer.parseInt(
			attr.getValue("methane-cost", "0"));
		this.buildtime = Integer.parseInt(
			attr.getValue("build-time", "0"));
		this.supplyprovided = Integer.parseInt(
			attr.getValue("supply-provided", "0"));
		this.supplycost = Integer.parseInt(
			attr.getValue("supply-cost", "0"));
		this.sight = Integer.parseInt(
			attr.getValue("sight", "0"));
		this.scorebuild = Integer.parseInt(
			attr.getValue("score-build", "0"));
		this.scoredestroy = Integer.parseInt(
			attr.getValue("score-destroy", "0"));
		this.speed = new ConstantFixedPoint(
			attr.getValue("speed", "0"));
		
		// Read dimensions
		Dimension pixeldimension;
		this.pixeldimension = (pixeldimension = new Dimension(
			attr.getValue("pixel-dimensions", "[0, 0]")));
		Point offset;
		this.offset = (offset = new Point(
			attr.getValue("pixel-offset", "(0, 0)")));
		
		// Parse size
		String vsize = attr.getValue("size", "small");
		switch (vsize)
		{
			case "small": this.size = UnitSize.SMALL; break;
			case "medium": this.size = UnitSize.MEDIUM; break;
			case "large": this.size = UnitSize.LARGE; break;
			
				// {@squirreljme.error BE09 Unknown unit size. (Unit size)}
			default:
				throw new RuntimeException(String.format("BE09 %s", vsize));
		}
		
		// Center point is just half the dimension
		this.centerpointoffset = new Point(pixeldimension.width / 2,
			pixeldimension.height / 2);
		
		// Get total size of unit in tiles, rounded up to the tile
		int pxw = (pixeldimension.width + offset.x +
				Tile.PIXEL_SIZE) & ~(Tile.PIXEL_MASK),
			pxh = (pixeldimension.height + offset.y +
				Tile.PIXEL_SIZE) & ~(Tile.PIXEL_MASK);
		
		// Determine tile dimension of unit
		Dimension tiledimension = new Dimension(
			pxw / Tile.PIXEL_SIZE,
			pxh / Tile.PIXEL_SIZE);
		this.tiledimension = tiledimension;
		this.pixeltiledimension = new Dimension(
			tiledimension.width / Tile.PIXEL_SIZE,
			tiledimension.height / Tile.PIXEL_SIZE);
		
		// Offset to the center of the building is in the center of
		// the tile dimensions
		this.buildingcenterpointoffset = new Point(pxw / 2, pxh / 2);
	}
	
	/**
	 * This performs the calculation of determining where a building should be
	 * placed. Building placement is aligned to the grid.
	 *
	 * @param __y If {@code true} then {@code __v} is a Y coordinate.
	 * @param __v The coordinate value.
	 * @return The center position of the building.
	 * @since 2017/02/17
	 */
	public int placeBuilding(boolean __y, int __v)
	{
		return __v;
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This class allows for the modification of unit information which is used
 * to manage such stuff as upgrades which happen over the course of the game.
 *
 * @since 2018/03/18
 */
public final class ModifiedUnitInfo
{
	/** Basic unit information. */
	protected final BaseUnitInfo base;
	
	/**
	 * Initializes the modified unit information.
	 *
	 * @param __i The base unit information.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ModifiedUnitInfo(BaseUnitInfo __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.base = __i;
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This indicates the of placement to be performed when placing a unit.
 *
 * @since 2017/02/16
 */
public enum SpawnPlacementType
{
	/** Forced placement, it is created regardless if it is valid or not. */
	FORCED,
	
	/** Unit should follow building spawn rules, aligned to grid. */
	BUILDING,
	
	/** Normal best fit unit spawning, a creator may be used as a factory. */
	NORMAL,
	
	/** End. */
	;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/units/Unit.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.lang.ref.Reference;

/**
 * This represents and holds information for a single unit in the game.
 *
 * @since 2017/02/14
 */
public final class Unit
{
	/** The ID of this unit. */
	protected final int id;
	
	/** The current unit type. */
	private UnitType _type;
	
	/** Was this unit deleted? */
	private boolean _deleted;
	
	/** Hitpoints of the current unit. */
	private int _hp;
	
	/** Unit shields. */
	private int _shields;
	
	/** Reference to this unit via pointer. */
	private Reference<UnitReference> _ref;
	
	/** Actual center position. */
	int _cx, _cy;
	
	/** Position of the unit in the map. */
	int _x1, _y1, _x2, _y2;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __id The ID of the unit.
	 * @since 2018/03/19
	 */
	public Unit(int __id)
	{
		this.id = __id;
	}
	
	/**
	 * Returns the center X position.
	 *
	 * @return The center X position.
	 * @since 2017/02/17
	 */
	public int centerX()
	{
		return this._cx;
	}
	
	/**
	 * Returns the center Y position.
	 *
	 * @return The center Y position.
	 * @since 2017/02/17
	 */
	public int centerY()
	{
		return this._cy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Unit))
			return false;
		
		return this.id == ((Unit)__o).id;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final int hashCode()
	{
		return this.id;
	}
	
	/**
	 * Returns the ID of this unit.
	 *
	 * @return The unit ID.
	 * @since 2018/03/19
	 */
	public final int id()
	{
		return this.id;
	}
	
	/**
	 * This morphs the current unit so that it is of the specified unit type.
	 * Certain aspects are transferred and translation whiles others may be
	 * reset.
	 *
	 * @param __t The unit type to morph to.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/15
	 */
	public void morph(UnitType __t)
		throws NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
		/*
		// {@squirreljme.error BE0a Cannot morph a linked unit.}
		if (this._islinked)
			throw new IllegalStateException("BE0a");
		
		// If the type remains the same, do nothing
		UnitType oldtype = this._type;
		if (oldtype == __t)
			return;
		
		// Get info, needed for some details
		UnitInfo oldinfo = this._info,
			newinfo = __t.info();
		
		// Set new type
		this._type = __t;
		this._info = newinfo;
		
		// No previous type, set details
		if (oldtype == null)
		{
			this._hp = newinfo.hp;
			this._shields = newinfo.shields;
		}
		
		// Average the stats so that the new health is a precentage of the
		// old health
		else
		{
			if (true)
				throw new todo.TODO();
			
			// Recenter
			__move(this._cx, this._cy);
		}
		*/
	}
	
	/**
	 * Returns a reference to this unit.
	 *
	 * @return The reference to this unit.
	 * @since 2018/03/19
	 */
	public final UnitReference reference()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Runs the unit logic.
	 *
	 * @param __framenum The frame number.
	 * @return {@code true} if the unit was deleted.
	 * @since 2017/02/14
	 */
	boolean run(int __framenum)
	{
		// If the unit was deleted, do nothing
		if (this._deleted)
			return true;
		
		throw new todo.TODO();
		/*
		// Do not think for units which are not linked, but do not delete them
		if (!this._islinked)
			return false;
		
		// Not deleted
		return false;*/
	}
	
	/**
	 * Returns the unit type.
	 *
	 * @return The unit type.
	 * @since 2017/02/17
	 */
	public UnitType type()
	{
		return this._type;
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This is thrown when the unit a pointer points to, has been deleted.
 *
 * @since 2017/02/14
 */
public class UnitDeletedException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/02/14
	 */
	public UnitDeletedException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This class is used to keep track of which units are near each other in
 * each of the given megatiles. This increases rendering speed since only units
 * that are linked into megatiles has to be used for the game logic.
 *
 * This does not need actual mega tile references, they just need to be
 * referred to by index.
 *
 * @since 2018/03/18
 */
public final class UnitLinker
{
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This is a reference which points to a unit, it is used to allow units to
 * refer to other units and having it where they can be referenced without
 * needing to handle unit removal themselves. Since units would be garbage
 * collected, it would be unspecified using references when units actually
 * go away.
 *
 * @since 2018/03/19
 */
public final class UnitReference
{
	/** The unit ID. */
	protected final int id;
	
	/** The referring unit. */
	private volatile Unit _unit;
	
	/**
	 * Initializes the reference to the given unit.
	 *
	 * @param __u The unit to link to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public UnitReference(Unit __u)
		throws NullPointerException
	{
		if (__u == null)
			throw new NullPointerException("NARG");
		
		this.id = __u.id();
		this._unit = __u;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof UnitReference))
			return false;
		
		return this.id == ((UnitReference)__o).id;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final int hashCode()
	{
		return this.id;
	}
	
	/**
	 * Returns the unit this is a reference to or {@code null} if it has been
	 * deleted/killed.
	 *
	 * @return The unit this points to or {@code null} if it has been
	 * deleted/killed.
	 * @since 2018/03/19
	 */
	public final Unit get()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This represents the size of a unit.
 *
 * @since 2017/02/16
 */
public enum UnitSize
{
	/** Small. */
	SMALL,
	
	/** Medium. */
	MEDIUM,
	
	/** Large. */
	LARGE,
	
	/** End. */
	;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/units/UnitType.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * These are the units which are available in the game and what are actively
 * used within the game.
 *
 * @since 2017/02/14
 */
public enum UnitType
{
	/** Starting location. */
	START_LOCATION,
	
	/** Chlorophid: Garden. */
	CHLOROPHID_GARDEN,
	
	/** End. */
	;
	
	/** Base unit information and its properties. */
	private BaseUnitInfo _info;
	
	/**
	 * Returns the information which is associated with the given unit.
	 *
	 * @return The unit information.
	 * @since 2017/02/14
	 */
	public BaseUnitInfo baseInfo()
	{
		// If the info has not been cached then load it
		BaseUnitInfo rv = this._info;
		if (rv == null)
			try (InputStream in = UnitType.class.getResourceAsStream(
				"/net/multiphasicapps/squirrelquarrel/data/units/" +
				this.name().toLowerCase() + "/info"))
			{
				// {@squirreljme.error BE0b Unit information for the given
				// unit does not exist. (The unit)}
				if (in == null)
					throw new RuntimeException("BE0b " + this);
				
				this._info = (rv = new BaseUnitInfo(this.ordinal(),
					new JavaManifest(in)));
			}
			
			// {@squirreljme.error BE0c Could not load unit information.}
			catch (IOException e)
			{
				throw new RuntimeException("BE0c", e);
			}
		
		return rv;
	}
}

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

package net.multiphasicapps.squirrelquarrel.units;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This class handles and manages all of the units in the game along with
 * their mega tile links.
 *
 * @since 2018/03/18
 */
public final class Units
{
	/** Linked units into mega tiles. */
	protected final UnitLinker linker =
		new UnitLinker();
	
	/** Units in the game. */
	private final List<Unit> _units =
		new ArrayList<>();
	
	/** The ID of the next unit to create. */
	private int _nextid;
	
	/**
	 * Initializes the units.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Units(InitialSettings __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
	}
	
	/**
	 * Creates a new unit.
	 *
	 * @param __spt How the unit should be placed on the map.
	 * @param __t The type of unit to spawn.
	 * @param __creator The creating unit, may be {@code null}.
	 * @param __x The target X position.
	 * @param __y The target Y position.
	 * @return The created unit or {@code null} if it could not be created.
	 * @throws NullPointerException If no spawn type or unit type was
	 * specified.
	 * @since 2017/02/16
	 */
	public final Unit createUnit(SpawnPlacementType __spt, UnitType __t,
		Unit __creator, int __x, int __y)
		throws NullPointerException
	{
		return this.createUnit(__spt, __t,
			(UnitReference)(__creator == null ? null : __creator.reference()),
			__x, __y);
	}
	
	/**
	 * Creates a new unit.
	 *
	 * @param __spt How the unit should be placed on the map.
	 * @param __t The type of unit to spawn.
	 * @param __creator The creating unit, may be {@code null}.
	 * @param __x The target center X position.
	 * @param __y The target center Y position.
	 * @return The created unit or {@code null} if it could not be created.
	 * @throws NullPointerException If no spawn type or unit type was
	 * specified.
	 * @since 2017/02/16
	 */
	public final Unit createUnit(SpawnPlacementType __spt, UnitType __t,
		UnitReference __creator, int __x, int __y)
		throws NullPointerException
	{
		// Check
		if (__spt == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Create new unit and add it to the list
		Unit rv;
		this._units.add((rv = new Unit(this._nextid++)));
		
		// Morph this unit to the resulting type
		rv.morph(__t);
		
		throw new todo.TODO();
		/*
		// Setup unit
		Unit rv = new Unit(this);
		UnitInfo info = __t.info();
		
		// Morph to the given unti type
		rv.morph(__t);
		
		// Determine the location where the unit is to be placed
		int px, py;
		switch (__spt)
		{
				// No restriction
			case FORCED:
				px = __x;
				py = __y;
				break;
				
				// Building, 
			case BUILDING:
				px = info.placeBuilding(false, __x);
				py = info.placeBuilding(true, __y);
				break;
				
				// Normal placement
			case NORMAL:
				throw new todo.TODO();
				
				// Unknown
			default:
				throw new todo.OOPS();
		}
		
		// Move unit to the specified position
		rv.__move(px, py);
		
		// Try to replace an existing null with this new unit
		List<Unit> units = this._units;
		boolean didset = false;
		for (int n = units.size(), i = n - 1; i >= 0; i++)
			if (units.get(i) == null)
			{
				units.set(i, rv);
				didset = true;
				break;
			}
		
		// Otherwise place at end
		if (!didset)
			units.add(rv);
		
		// Link unit into the map
		rv.__link(true);
		
		// Return it
		return rv;
		*/
	}
	
	/**
	 * Runs the unit logic.
	 *
	 * @param __frame The current game frame.
	 * @since 2018/03/18
	 */
	public void run(int __frame)
	{
		// Run the unit logic for every unit
		List<Unit> units = this._units;
		for (int i = 0, n = units.size(); i < n; i++)
			if (units.get(i).run(__frame))
				units.set(i, null);
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/units/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains unit related resources.
 *
 * @since 2017/02/14
 */

package net.multiphasicapps.squirrelquarrel.units;

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

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a constant fixed point number.
 *
 * @since 2018/03/18
 */
public final class ConstantFixedPoint
	implements Comparable<FixedPoint>, FixedPoint
{
	/** Bit shift. */
	public static final int SHIFT =
		16;
	
	/** Mask. */
	public static final int MASK =
		0xFFFF;
	
	/** The value. */
	private int _value;
	
	/**
	 * Initializes the fixed point value with the given whole number.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(int __whole)
	{
		this._value = __whole << ConstantFixedPoint.SHIFT;
	}
	
	/**
	 * Initializes the fixed point value with the given whole number and
	 * fraction.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @param __frac The fraction, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(int __whole, int __frac)
	{
		this._value = (__whole << ConstantFixedPoint.SHIFT) | (__frac & ConstantFixedPoint.MASK);
	}
	
	/**
	 * Initializes the fixed point value with the given fixed point value.
	 *
	 * @param __fp The fixed point number to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(FixedPoint __fp)
		throws NullPointerException
	{
		if (__fp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the given string and reads a fixed point value.
	 *
	 * @param __s The input string
	 * @throws IllegalArgumentException If the string is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int value;
		
		// Is a whole number
		int dot = __s.indexOf('.');
		if (dot < 0)
			value = Integer.parseInt(__s, 10) << ConstantFixedPoint.SHIFT;
		
		// Is fractional value
		else
			throw new todo.TODO();
		
		this._value = value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(FixedPoint __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int fraction()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int whole()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains immutable dimension information for width and height.
 *
 * @since 2017/02/17
 */
public final class Dimension
	implements Comparable<Dimension>
{
	/** Width. */
	public final int width;
	
	/** Height. */
	public final int height;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dimension.
	 *
	 * @param __w Width.
	 * @param __h Height.
	 * @since 2017/02/17
	 */
	public Dimension(int __w, int __h)
	{
		this.width = __w;
		this.height = __h;
	}
	
	/**
	 * Parses a dimension from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Dimension(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0d Dimension must start and end with square
		// brackets. (The input string)}
		if (!__s.startsWith("[") || !__s.endsWith("]"))
			throw new IllegalArgumentException("BE0d " + __s);
		
		// Trim those out
		__s = __s.substring(1, __s.length() - 1);
		
		// {@squirreljme.error BE0e Dimension must have a comma between the
		// units. (The input string)}
		int com = __s.indexOf(',');
		if (com < 0)
			throw new IllegalArgumentException("BE0e " + __s);
		
		this.width = Integer.parseInt(__s.substring(0, com).trim(), 10);
		this.height = Integer.parseInt(__s.substring(com + 1).trim(), 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Dimension __o)
	{
		int rv,
			aw = this.width,
			as = aw * this.height,
			bw = __o.width,
			bs = bw * __o.height;
		
		// Compare surface area first
		rv = as - bs;
		if (rv != 0)
			return rv;
		
		// Compare the width
		return aw - bw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Dimension))
			return false;
		
		Dimension o = (Dimension)__o;
		return this.width == o.width && this.height == o.height;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.width ^ ~(this.height);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("[%d, %d]", this.width, this.height));
		
		return rv;
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a fixed point number.
 *
 * @since 2018/03/18
 */
public interface FixedPoint
	extends Comparable<FixedPoint>
{
	/**
	 * Returns the fraction part.
	 *
	 * @return The fraction part.
	 * @since 2018/03/18
	 */
	int fraction();
	
	/**
	 * Returns the whole number part.
	 *
	 * @return The whole number part.
	 * @since 2018/03/18
	 */
	int whole();
}

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

package net.multiphasicapps.squirrelquarrel.util;

import java.util.Random;

/**
 * This is the random number generator, this allows the seed to be obtained
 * and set so that it is restored properly.
 *
 * {@squirreljme.error BE0f Floating point operations not supported.}
 *
 * @since 2017/02/10
 */
public class GameRandom
	extends Random
{
	/** The current seed. */
	protected volatile long seed;	
	
	/**
	 * Initializes the random number generator with the given seed.
	 *
	 * @param __s The seed to use.
	 * @since 2017/02/10
	 */
	public GameRandom(long __s)
	{
		this.setSeed(__s);
	}
	
	/**
	 * Returns the current raw seed value.
	 *
	 * @return The current raw seed value.
	 * @since 2017/02/10
	 */
	public long getRawSeed()
	{
		return this.seed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	protected int next(int __b)
	{
		// Setup new seed value
		long seed = this.seed;
		seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
		this.seed = seed;
		
		// Return from the old seed
		return (int)(seed >>> (48 - __b));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public double nextDouble()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public float nextFloat()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public double nextGaussian()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * Sets the current raw seed value.
	 *
	 * @param __s The raw seed value to use.
	 * @since 2017/02/10
	 */
	public void setRawSeed(long __s)
	{
		this.seed = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public void setSeed(long __s)
	{
		// Update
		this.seed = (__s ^ 0x5DEECE66DL) & ((1L << 48) - 1);
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a mutable fixed point number.
 *
 * @since 2018/03/18
 */
public final class MutableFixedPoint
	implements Comparable<FixedPoint>, FixedPoint
{
	/**
	 * Initializes the fixed point value with the given whole number.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(int __whole)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the fixed point value with the given whole number and
	 * fraction.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @param __frac The fraction, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(int __whole, int __frac)
	{
	}
	
	/**
	 * Initializes the fixed point value with the given fixed point value.
	 *
	 * @param __fp The fixed point number to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(FixedPoint __fp)
		throws NullPointerException
	{
		if (__fp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the given string and reads a fixed point value.
	 *
	 * @param __s The input string
	 * @throws IllegalArgumentException If the string is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(FixedPoint __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int fraction()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int whole()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is an immutable class which contains X and Y coordinates.
 *
 * @since 2017/02/17
 */
public final class Point
	implements Comparable<Point>
{
	/** X coordinate. */
	public final int x;
	
	/** Y coordinate. */
	public final int y;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the point.
	 *
	 * @param __x X coordinate.
	 * @param __y Y coordinate.
	 * @since 2017/02/17
	 */
	public Point(int __x, int __y)
	{
		this.x = __x;
		this.y = __y;
	}
	
	/**
	 * Parses a point from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Point(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0g Point must start and end with parenthesis.
		// (The input string)}
		if (!__s.startsWith("(") || !__s.endsWith(")"))
			throw new IllegalArgumentException("BE0g " + __s);
		
		// Trim those out
		__s = __s.substring(1, __s.length() - 1);
		
		// {@squirreljme.error BE0h Point must have a comma between the
		// units. (The input string)}
		int com = __s.indexOf(',');
		if (com < 0)
			throw new IllegalArgumentException("BE0h " + __s);
		
		this.x = Integer.parseInt(__s.substring(0, com).trim(), 10);
		this.y = Integer.parseInt(__s.substring(com + 1).trim(), 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Point __o)
	{
		int rv;
		
		// Compare x
		rv = this.x - __o.x;
		if (rv != 0)
			return rv;
		
		// Compare y
		return this.y - __o.y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Point))
			return false;
		
		Point o = (Point)__o;
		return this.x == o.x && this.y == o.y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.x ^ ~(this.y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("(%d, %d)", this.x, this.y));
		
		return rv;
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/util/Rectangle.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains an immutable rectangle which starts at a given point and has
 * a width and height.
 *
 * @since 2017/02/17
 */
public final class Rectangle
	implements Comparable<Rectangle>
{
	/** X position. */
	public final int x;
	
	/** Y position. */
	public final int y;
	
	/** Width. */
	public final int width;
	
	/** Height. */
	public final int height;
	
	/** String form. */
	private Reference<String> _string;
	
	/** As a point. */
	private Reference<Point> _point;
	
	/** As an end point. */
	private Reference<Point> _endpoint;
	
	/** As a dimension. */
	private Reference<Dimension> _dimension;
	
	/**
	 * Initializes the rectangle.
	 *
	 * @param __x X coordinate.
	 * @param __y Y coordinate.
	 * @param __w Width.
	 * @param __h Height.
	 * @since 2017/02/17
	 */
	public Rectangle(int __x, int __y, int __w, int __h)
	{
		this.x = __x;
		this.y = __y;
		this.width = __w;
		this.height = __h;
	}
	
	/**
	 * Parses a rectanle from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Rectangle(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Rectangle __o)
	{
		int rv,
			aw = this.width,
			as = aw * this.height,
			bw = __o.width,
			bs = bw * __o.height;
		
		// Compare x
		rv = this.x - __o.x;
		if (rv != 0)
			return rv;
		
		// Compare y
		rv = this.y - __o.y;
		if (rv != 0)
			return rv;
		
		// Compare surface area
		rv = as - bs;
		if (rv != 0)
			return rv;
		
		// Compare the width
		return aw - bw;
	}
	
	/**
	 * Returns this rectangle as a dimension.
	 *
	 * @return The dimension of this rectangle.
	 * @since 2017/02/17
	 */
	public Dimension dimension()
	{
		Reference<Dimension> ref = this._dimension;
		Dimension rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._dimension = new WeakReference<>(
				rv = new Dimension(this.width, this.height));
		
		return rv;
	}
	
	/**
	 * Returns this tne end point of this rectangle.
	 *
	 * @return The end point of this rectangle.
	 * @since 2017/02/17
	 */
	public Point endPoint()
	{
		Reference<Point> ref = this._endpoint;
		Point rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._endpoint = new WeakReference<>(
				rv = new Point(this.x + this.width, this.y + this.height));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Rectangle))
			return false;
		
		Rectangle o = (Rectangle)__o;
		return this.x == o.x && this.y == o.y &&
			this.width == o.width && this.height == o.height;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.x ^ ~(this.y) ^ this.width ^ ~(this.height);
	}
	
	/**
	 * Returns this rectangle as a point.
	 *
	 * @return The point of this rectangle.
	 * @since 2017/02/17
	 */
	public Point point()
	{
		Reference<Point> ref = this._point;
		Point rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._point = new WeakReference<>(rv = new Point(this.x, this.y));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("(%d, %d, %d, %d]", this.x, this.y,
					this.width, this.height));
		
		return rv;
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

import net.multiphasicapps.squirrelquarrel.game.EventSource;

/**
 * This is an event source which reads actions from replay data.
 *
 * @since 2019/03/24
 */
public final class ReplayEventSource
	implements EventSource
{
	/** The input replay stream. */
	protected final ReplayInputStream in;
	
	/**
	 * Initializes the event source.
	 *
	 * @param __in The input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public ReplayEventSource(ReplayInputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = __in;
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This is thrown when the format of a replay is incorrect.
 *
 * @since 2018/03/19
 */
public class ReplayFormatException
	extends ReplayIOException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/19
	 */
	public ReplayFormatException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This is thrown when a replay has failed to be read or written to.
 *
 * @since 2018/03/19
 */
public class ReplayIOException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/19
	 */
	public ReplayIOException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/19
	 */
	public ReplayIOException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayIOException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayIOException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * This allows for easier reading from the replay input without requiring that
 * {@link IOException} be caught each time.
 *
 * @since 2018/03/19
 */
public final class ReplayInputStream
{
	/** The stream to read from. */
	protected final DataInputStream in;
	
	/**
	 * Initializes the input stream.
	 *
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ReplayInputStream(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = (__in instanceof DataInputStream ? (DataInputStream)__in :
			new DataInputStream(__in));
	}
	
	/**
	 * Reads a byte value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final int readByte()
		throws ReplayIOException
	{
		try
		{
			return this.in.readByte();
		}
		
		// {@squirreljme.error BE0i Could not read byte from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0i", e);
		}
	}
	
	/**
	 * Reads an integer value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final int readInt()
		throws ReplayIOException
	{
		try
		{
			return this.in.readInt();
		}
		
		// {@squirreljme.error BE0j Could not read integer from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0j", e);
		}
	}
	
	/**
	 * Reads a long value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final long readLong()
		throws ReplayIOException
	{
		try
		{
			long rv = this.in.readInt();
			rv <<= 32;
			rv |= (this.in.readInt() & 0xFFFFFFFF);
			return rv;
		}
		
		// {@squirreljme.error BE0k Could not read long from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0k", e);
		}
	}
}

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

package net.multiphasicapps.squirrelquarrel.util;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This allows for easier writing to the replay output without requiring that
 * {@link IOException} be caught each time.
 *
 * @since 2018/03/19
 */
public final class ReplayOutputStream
{
	/** The stream to write to. */
	protected final DataOutputStream out;
	
	/**
	 * Initializes the output stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ReplayOutputStream(OutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = (__out instanceof DataOutputStream ?
			(DataOutputStream)__out : new DataOutputStream(__out));
	}
	
	/**
	 * Writes a byte value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeByte(int __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeByte(__v);
		}
		
		// {@squirreljme.error BE0l Could not write the byte value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0l %d", __v), e);
		}
	}
	
	/**
	 * Writes an integer value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeInt(int __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeInt(__v);
		}
		
		// {@squirreljme.error BE0m Could not write the integer value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0m %d", __v), e);
		}
	}
	
	/**
	 * Writes a long value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeLong(long __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeInt((int)(__v >> 32));
			this.out.writeInt((int)__v);
		}
		
		// {@squirreljme.error BE0n Could not write the long value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0n %d", __v), e);
		}
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/util/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains utilities that can be used for the game.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.util;

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

package net.multiphasicapps.squirrelquarrel.world;

/**
 * This represents a single mega tile which represents a small region in the
 * level.
 *
 * @since 2017/02/09
 */
public class MegaTile
{
	/** The number of frames which must pass before fog of war is cycled. */
	private static final int _FOG_OF_WAR_CYCLE_MASK =
		63;
	
	/** The number of tiles per mega tile. */
	public static final int TILES_PER_MEGA_TILE =
		8;
	
	/** The number of tiles in mega tiles. */
	public static final int TILES_IN_MEGA_TILE =
		64;
	
	/** The size of megatiles in pixels. */
	public static final int PIXEL_SIZE =
		256;
	
	/** The megatile index. */
	public final MegaTileIndex index;
	
	/** Megatile X position. */
	public final int megax;
	
	/** Megatile Y position. */
	public final int megay;
	
	/** Mega tile ordinal. */
	public final int megaordinal;
	
	/** Terrain information. */
	private final byte[] _terrain =
		new byte[MegaTile.TILES_IN_MEGA_TILE];
	
	/**
	 * This contains the first cycle for the fog of war. The fog of war acts
	 * in two cycles, so that previously revealed areas go away and new ones
	 * are set. This means that the fog of war does not need to be cleared
	 * every frame by units, only set. The fog is in two cycles because on a
	 * new cycle this array is cleared, and it would be possible for a unit to
	 * be blind while its logic is handled. Also fog of war updates do not need
	 * to be that instant.
	 */
	private final byte[] _fogcyclea =
		new byte[MegaTile.TILES_IN_MEGA_TILE];
	
	/** Fog of war second cycle. */
	private final byte[] _fogcycleb =
		new byte[MegaTile.TILES_IN_MEGA_TILE];
	
	/**
	 * Initializes a basic megatile.
	 *
	 * @param __mx Megatile X position.
	 * @param __my Megatile Y position.
	 * @param __mi The index.
	 * @since 2017/02/10
	 */
	public MegaTile(int __mx, int __my, int __mi)
	{
		// Set
		this.megax = __mx;
		this.megay = __my;
		this.megaordinal = __mi;
		this.index = new MegaTileIndex(__mx, __my, __mi);
		
		// Initialize it with some pattern
		byte[] terrain = this._terrain;
		for (int y = 0; y < MegaTile.TILES_PER_MEGA_TILE; y++)
			for (int x = 0; x < MegaTile.TILES_PER_MEGA_TILE; x++)
				terrain[(y * MegaTile.TILES_PER_MEGA_TILE) + x] =
					(byte)(((x + y) / 2) & 1);
	}
	
	/**
	 * Gets the terrain for the given sub-tile.
	 *
	 * @param __x The tile X position.
	 * @param __y The tile Y position.
	 * @return The terrain type for the given tile.
	 * @throws IndexOutOfBoundsException If the position is not in the megatile
	 * bounds.
	 * @since 2017/02/11
	 */
	public TerrainType subTileTerrain(int __x, int __y)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE0o Cannot get terrain because the tile is
		// out of range.}
		if (__x < 0 || __y < 0 || __x >= MegaTile.TILES_PER_MEGA_TILE ||
			__y >= MegaTile.TILES_PER_MEGA_TILE)
			throw new IndexOutOfBoundsException("BE0o");
		
		// Depends
		return TerrainType.of(
			this._terrain[(__y * MegaTile.TILES_PER_MEGA_TILE) + __x]);
	}
	
	/**
	 * Return the megatile X position.
	 *
	 * @return The X position of the megatile.
	 * @since 2017/02/17
	 */
	public int x()
	{
		return this.megax;
	}
	
	/**
	 * Return the megatile Y position.
	 *
	 * @return The Y position of the megatile.
	 * @since 2017/02/17
	 */
	public int y()
	{
		return this.megay;
	}
	
	/**
	 * Runs the megatile logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
		// Cycle the fog of war?
		if ((__frame & MegaTile._FOG_OF_WAR_CYCLE_MASK) == 0)
			this.__cycleFog();
	}
	
	/**
	 * This cycles the fog of war.
	 *
	 * @since 2017/02/14
	 */
	void __cycleFog()
	{
		// Transfer all fog state from the first cycle to the second
		byte[] fogcyclea = this._fogcyclea;
		byte[] fogcycleb = this._fogcyclea;
		for (int i = 0, n = MegaTile.TILES_IN_MEGA_TILE; i < n; i++)
		{
			// Set the second cycle to the first
			fogcycleb[i] = fogcyclea[i];
			
			// Clear the first
			fogcyclea[i] = 0;
		}
	}
}

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

package net.multiphasicapps.squirrelquarrel.world;

/**
 * This represents an index into a megatile.
 *
 * @since 2018/03/18
 */
public final class MegaTileIndex
	implements Comparable<MegaTileIndex>
{
	/** The x coordinate. */
	public final int x;
	
	/** The y coordinate. */
	public final int y;
	
	/** The ordinal index. */
	public final int ordinal;
	
	/**
	 * Initializes the mega tile index.
	 *
	 * @param __x The x coordinate.
	 * @param __y The y coordinate.
	 * @param __i The ordinal.
	 * @since 2018/03/18
	 */
	public MegaTileIndex(int __x, int __y, int __i)
	{
		this.x = __x;
		this.y = __y;
		this.ordinal = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(MegaTileIndex __o)
	{
		return this.ordinal - __o.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MegaTileIndex))
			return false;
		
		MegaTileIndex o = (MegaTileIndex)__o;
		return this.ordinal == o.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		return this.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Translates a position to the position ordinal.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @return The ordinal in the tile map.
	 * @since 2018/03/19
	 */
	public static final int positionToOrdinal(int __x, int __y)
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.squirrelquarrel.world;

import java.io.InputStream;

/**
 * This represents the type of terrain that is available for usage.
 *
 * @since 2017/02/10
 */
public enum TerrainType
{
	/** Grass. */
	GRASS(0x007F00),
	
	/** Dirt. */
	DIRT(0x6E370B),
	
	/** End. */
	;
	
	/** Cache of terrain types. */
	private static final TerrainType[] _VALUES = TerrainType.values();
	
	/** The terrain color. */
	protected final int color;
	
	/**
	 * Initializes the terrain type.
	 *
	 * @param __color The color used for this terrain.
	 * @since 2017/09/13
	 */
	TerrainType(int __color)
	{
		// Set
		this.color = __color;
	}
	
	/**
	 * Returns the color used for the terrain.
	 *
	 * @return The terrain color.
	 * @since 2017/02/13
	 */
	public int color()
	{
		return this.color;
	}
	
	/**
	 * Returns an input stream to the image data.
	 *
	 * @return The image data input stream.
	 * @throws RuntimeException If the data is missing.
	 * @since 2017/02/10
	 */
	public InputStream imageStream()
		throws RuntimeException
	{
		// {@squirreljme.error BE0p Could not get the tile image for the
		// given terrain. (The terrain type)}
		InputStream rv = TerrainType.class.getResourceAsStream(
			"images/terrain/" + TerrainType.__lower(this.name()) + ".xpm");
		if (rv == null)
			throw new RuntimeException(String.format("BE0p %s", this));
		return rv;
	}
	
	/**
	 * Returns the terrain type of the given ID.
	 *
	 * @param __i The ID of the terrain to return.
	 * @return The terrain type at this position.
	 * @since 2017/02/13
	 */
	public static TerrainType of(int __i)
	{
		return TerrainType._VALUES[__i];
	}
	
	/**
	 * Lowercases the specified string.
	 *
	 * @param __s The string to lowercase.
	 * @return The lowercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	static final String __lower(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Convert
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			if (c >= 'A' && c <= 'Z')
				c = (char)((c - 'A') + 'a');
			
			sb.append(c);
		}
		
		return sb.toString();
	}
}

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

package net.multiphasicapps.squirrelquarrel.world;

/**
 * This represents a single tile in the world.
 *
 * @since 2018/03/18
 */
public final class Tile
{
	/** The shift for pixels. */
	public static final int PIXEL_SHIFT =
		5;
	
	/** The size of tiles in pixels. */
	public static final int PIXEL_SIZE =
		32;
	
	/** The mas for pixels. */
	public static final int PIXEL_MASK =
		31;
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/world/World.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This stores the mega tiles within the level along with storing level related
 * data structures.
 *
 * @since 2017/02/09
 */
public class World
{
	/** The mega tile array. */
	protected final MegaTile[] _tiles;
	
	/** The width of the level in tiles. */
	protected final int tilew;
	
	/** The height of the level in tiles. */
	protected final int tileh;
	
	/** The width of the level in pixels. */
	protected final int pixelw;
	
	/** The height of the level in pixels. */
	protected final int pixelh;
	
	/** The width of the level in megatiles. */
	protected final int megaw;
	
	/** The height of the level in megatiles. */
	protected final int megah;
	
	/**
	 * Initializes the level with the given initial settings.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public World(InitialSettings __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Initialize the tile map
		int mw = __is.mapWidth(),
			mh = __is.mapHeight();
		this._tiles = this.__initTiles(mw, mh);
		
		// Store sizes
		this.tilew = mw;
		this.tileh = mh;
		this.megaw = mw / MegaTile.TILES_PER_MEGA_TILE;
		this.megah = mh / MegaTile.TILES_PER_MEGA_TILE;
		this.pixelw = mw * Tile.PIXEL_SIZE;
		this.pixelh = mh * Tile.PIXEL_SIZE;
	}
	
	/**
	 * Returns the megatile at the given megatile coordinates.
	 *
	 * @param __x The X coordinate in megatiles.
	 * @param __y The Y coordinate in megatiles.
	 * @return The megatile at the given coordinates.
	 * @throws IndexOutOfBoundsException If the megatile position is not
	 * within bounds.
	 * @since 2017/02/11
	 */
	public MegaTile megaTile(int __x, int __y)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE0q Megatile not in level range.}
		int megaw = this.megaw,
			megah = this.megah;
		if (__x < 0 || __y < 0 || __x >= megaw || __y >= megah)
			throw new IndexOutOfBoundsException("BE0q");
		
		// Get
		return this._tiles[(__y * megaw) + __x];
	}
	
	/**
	 * Returns the height of the map in megatiles.
	 *
	 * @return The map height in megatiles.
	 * @since 2017/02/12
	 */
	public int megaTileHeight()
	{
		return this.megah;
	}
	
	/**
	 * Returns the width of the map in megatiles.
	 *
	 * @return The map width in megatiles.
	 * @since 2017/02/12
	 */
	public int megaTileWidth()
	{
		return this.megaw;
	}
	
	/**
	 * Returns the height of the level in pixels.
	 *
	 * @return The height of the level in pixels.
	 * @since 2017/02/10
	 */
	public int pixelHeight()
	{
		return this.pixelh;
	}
	
	/**
	 * Returns the width of the level in pixels.
	 *
	 * @return The width of the level in pixels.
	 * @since 2017/02/10
	 */
	public int pixelWidth()
	{
		return this.pixelw;
	}
	
	/**
	 * Returns the terrain type at the given pixel
	 *
	 * @param __x The pixel X position.
	 * @param __y The pixel Y position.
	 * @return The terrain type for the given tile.
	 * @since 2017/02/13
	 */
	public TerrainType pixelTerrain(int __x, int __y)
	{
		return this.megaTile(
			World.pixelCoordToMegaTile(__x), World.pixelCoordToMegaTile(__y)).
			subTileTerrain(
				World.pixelCoordToSubTile(__x), World.pixelCoordToSubTile(__y));
	}
	
	/**
	 * Initializes the map tiles.
	 *
	 * @param __tw The tile width of the map.
	 * @param __th The tile height of the map.
	 * @return The initialized mega tiles.
	 * @since 2017/02/14
	 */
	private MegaTile[] __initTiles(int __tw, int __th)
	{
		int megaw = __tw / MegaTile.TILES_PER_MEGA_TILE;
		int megah = __th / MegaTile.TILES_PER_MEGA_TILE;
		
		// Initialize
		MegaTile[] tiles = new MegaTile[megaw * megah];
		for (int i = 0, n = tiles.length; i < n; i++)
			tiles[i] = new MegaTile(i % megaw, i / megaw, i);
		
		return tiles;
	}
	
	/**
	 * Runs the level logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
		// Run the megatile loop
		MegaTile[] tiles = this._tiles;
		for (int i = 0, n = tiles.length; i < n; i++)
			tiles[i].run(__frame);
	}
	
	/**
	 * Converts a pixel coordinate to a mega tile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToMegaTile(int __c)
	{
		return __c / MegaTile.PIXEL_SIZE;
	}
	
	/**
	 * Converts a pixel coordinate to a tile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToTile(int __c)
	{
		return __c / Tile.PIXEL_SIZE;
	}
	
	/**
	 * Converts a pixel coordinate to a sub tile in a megatile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToSubTile(int __c)
	{
		return (__c / Tile.PIXEL_SIZE) % MegaTile.TILES_PER_MEGA_TILE;
	}
}

Added modules/squirrel-quarrel/src/main/java/net/multiphasicapps/squirrelquarrel/world/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains anything which contains the world data.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.world;

Added modules/squirrel-quarrel/src/main/resources/dev/shadowtail/squirrelquarrel/tile0.xpm.

























































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char *dummy[]={
"16 16 101 2",
"#d c #00ff35",
".X c #01fc35",
".i c #01ff36",
"#H c #02fe37",
".O c #04f636",
"#I c #04ff38",
"#t c #05f938",
".E c #05ff39",
".N c #07fe3b",
".x c #07ff3b",
".c c #08a72a",
"#j c #08d733",
".Y c #08ff3b",
"#. c #09d534",
".9 c #09fa3b",
".t c #0ad033",
".# c #0bc733",
"#g c #0bcd33",
".F c #0bd936",
".l c #0cc433",
".R c #0cd536",
"#r c #0dbf33",
".y c #0dca34",
"#z c #0dcb34",
"#f c #0df73d",
"#E c #0fc235",
".S c #0fd438",
".Q c #10af32",
".5 c #10b432",
".d c #10b934",
"#c c #10c135",
"#B c #10dd3c",
".Z c #10e63c",
".D c #10ff41",
"#n c #11ad32",
"Qt c #11c137",
"#h c #11e03b",
".3 c #12a632",
"#C c #12a932",
"#a c #12b133",
"#w c #12c137",
".L c #12d23a",
".0 c #12d43b",
".P c #12ef40",
"#D c #12f241",
".W c #13a231",
"#u c #13a632",
".1 c #13c137",
".M c #13dd3d",
"#i c #13fe44",
"#x c #13ff44",
".e c #149d31",
".o c #149e31",
".H c #149f31",
"#y c #14a232",
".p c #14a833",
".h c #14ff45",
".u c #159e32",
"#s c #15a033",
"#m c #15a333",
".I c #15aa34",
".A c #15c43a",
".B c #169f33",
".n c #16a935",
".f c #179f34",
".4 c #17a435",
".w c #17cc3d",
".z c #18d13e",
".j c #1aa036",
"#v c #1ba839",
"#F c #1ca138",
"#q c #1ca238",
".8 c #1dee48",
".q c #1dff4c",
"#p c #21a23c",
"#l c #21e349",
"## c #21f64d",
"#b c #24a43f",
".b c #24aa40",
".v c #26f851",
".k c #28b045",
"#o c #2bd84f",
".K c #31d954",
".U c #32b64e",
".C c #38f05e",
".g c #3dae55",
".s c #41c85d",
".m c #44b15b",
".r c #46ff6c",
"#e c #4ad066",
"#G c #4ccf68",
".T c #4dcf68",
".J c #4ed069",
".7 c #51d46c",
".2 c #53bd6a",
".G c #54ff78",
".a c #59eb78",
".V c #5dca74",
"#A c #5efd7f",
".6 c #6ce485",
"#k c #7cfc97",
"Qt.#.a.a.b.a.a.c.d.e.f.g.a.h.i.j",
".k.l.j.a.a.m.c.a.n.o.p.a.a.q.j.r",
".s.j.t.a.u.a.c.c.c.c.v.j.w.c.x.c",
".j.y.z.A.j.c.j.B.j.C.D.E.j.F.G.c",
".H.I.J.j.K.c.c.L.M.N.O.j.P.j.a.j",
".Q.R.j.c.S.c.a.a.j.T.j.U.j.V.j.W",
".X.c.c.Y.Z.0.1.j.a.j.a.c.2.j.3.c",
".j.c.j.a.j.a.j.4.j.a.j.a.j.c.j.5",
".H.j.6.j.a.j.7.j.a.c.8.j.9.a.a.j",
".j#..j##.j#a.j#b.j#c.j#d.j.a.j#e",
"#f.j#g.j#h.a.a.j#i.j#j.j#k.j.a.j",
".j#l#m.a.a.a.j.a.j#n.j#o.j#p.j.a",
".a.a#q.a.a.j.a.j.i.j#r.a.e.j.a.j",
".j#b#s.a.j.a.j.a.j#t.j.e.o#u.a.a",
".c.j#v.j#w.j#x.j.a.j.a.a#y#z#A.j",
".j#B.a.a#C#D.j#E.j.a.a#F#G#H.j#I"};

Added modules/squirrel-quarrel/src/main/resources/dev/shadowtail/squirrelquarrel/tile1.xpm.


















































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char *dummy[]={
"16 16 254 2",
"bG c #395810",
"#n c #3e5e02",
".P c #415d02",
"b7 c #428114",
".K c #435702",
".Q c #445602",
"aO c #476701",
".u c #477702",
"bl c #4d550f",
".F c #4f5b02",
".G c #4f7402",
"bD c #506f0b",
".J c #516102",
".# c #517d0e",
"#4 c #525c01",
"bt c #526403",
"bp c #537502",
"aM c #554201",
"#S c #556402",
"aK c #584b04",
"bk c #585408",
"ar c #5c6702",
"a1 c #5d2b01",
"ah c #5d3201",
"a0 c #5d3401",
"aL c #5d4203",
"bo c #5d610e",
"#9 c #5d640f",
"a8 c #5d7509",
"bu c #5e5604",
"bI c #5e5c03",
"#. c #5f5d02",
"bE c #605302",
"aw c #605303",
".v c #606a02",
"a2 c #615a01",
"be c #615b01",
"ac c #617002",
"aT c #625103",
"ax c #625a01",
".4 c #625a02",
"#6 c #626b01",
"ai c #633001",
"bU c #637218",
"a7 c #638008",
"#W c #655404",
"#5 c #655f01",
"b2 c #656c03",
"az c #665e01",
"#q c #666402",
".p c #666c06",
"aN c #675d01",
"#H c #675e07",
"#C c #676302",
"#E c #67670c",
"a6 c #677104",
"bs c #684001",
"#m c #685d03",
".V c #686d02",
"bW c #687101",
".U c #687502",
"#0 c #693b02",
"#R c #695d02",
".o c #696412",
"#Z c #6a3802",
"bH c #6a4403",
".5 c #6a5b02",
"#r c #6a6b02",
".a c #6a6b0d",
".I c #6a6d03",
"#B c #6c5b02",
"bS c #6c6304",
"a5 c #6c690b",
"bF c #6d5707",
"aS c #6d670a",
"bA c #6e5f04",
"ay c #6f4701",
"#1 c #6f5403",
"#w c #6f5f02",
"bc c #6f6813",
"bq c #707e0d",
".L c #714a04",
"am c #716f1f",
".H c #718003",
"ak c #723701",
"bV c #727209",
"#Q c #727703",
"aB c #746e1d",
"bf c #749502",
"br c #764706",
"#7 c #766e02",
"ad c #767202",
".A c #775903",
"#G c #775b03",
".T c #77630c",
"bT c #776507",
"#h c #777502",
"#L c #784202",
"bd c #786402",
"#K c #795301",
"bJ c #795405",
"#b c #795e02",
"a9 c #796105",
"#V c #796106",
"bz c #796f05",
"aW c #7a7504",
"#M c #7b640b",
"#T c #7b6606",
"bQ c #7c4c04",
"b1 c #7c5503",
"by c #7c6c08",
"ag c #7c6f0a",
"a3 c #7c7403",
"#i c #7c7f04",
".E c #7d4f04",
"a# c #7d5105",
"ao c #7d5204",
".W c #7d5705",
"#u c #7d6d07",
"aE c #7e4e04",
"bM c #7e5304",
"b5 c #7f4b04",
"bN c #7f5104",
"bP c #7f5e04",
"aj c #7f5f01",
"aQ c #7f6f20",
"bX c #805807",
"as c #805c02",
"bx c #806106",
"aH c #806902",
"ba c #80760e",
"#c c #815e02",
".w c #816805",
"Qt c #816905",
".n c #816d07",
".r c #817813",
"aG c #824503",
".X c #825006",
".c c #825c0a",
"aD c #825d08",
".D c #826307",
"bZ c #82750e",
".Z c #827702",
"bm c #835608",
"av c #836507",
"bO c #836604",
"bj c #846507",
"#8 c #84650b",
"#D c #854702",
"bB c #855305",
"b3 c #855504",
"#x c #857908",
".9 c #863a02",
"at c #865d03",
"#I c #866606",
"bw c #866b09",
"b4 c #875604",
"#P c #875807",
"bi c #876008",
".x c #876706",
".N c #885d08",
"#s c #886505",
"bL c #886b05",
"ae c #895903",
"#A c #8a5405",
"#l c #8a5505",
"#j c #8a6f0d",
".y c #8b5207",
"bC c #8b5505",
"aR c #8b6d03",
".0 c #8b7205",
"#g c #8b7605",
"b# c #8c5608",
"#t c #8c6406",
".Y c #8c7902",
"bn c #8d5606",
"#o c #8e5a06",
"## c #8e6504",
"a. c #8e6f08",
"#p c #904b04",
".g c #906004",
".3 c #906204",
".j c #915c06",
".C c #915d07",
"#d c #916107",
".h c #916804",
".e c #91760d",
".m c #924905",
".l c #925a06",
".2 c #926109",
"bK c #926c12",
"bg c #928003",
"#v c #935e04",
"aa c #936806",
"#a c #936c06",
"aP c #936f03",
".i c #955f05",
"#U c #956c07",
".M c #956d07",
"bY c #956f0d",
".O c #965f05",
"ap c #975106",
"aC c #976309",
"#2 c #986b0c",
"#3 c #98700d",
".8 c #98730b",
"#F c #995805",
"aX c #9a5006",
"aZ c #9a5306",
".f c #9a5d06",
"b6 c #9a6108",
"#X c #9a6406",
".k c #9b5f08",
"a4 c #9b6609",
"al c #9b6b0f",
"bR c #9b6c0c",
"#J c #9b6f07",
".B c #9b750b",
"aU c #9c5d07",
".z c #9c6108",
"aF c #9d5f07",
"aq c #9d6207",
"ab c #9d6508",
"an c #9e6709",
"af c #9e670a",
"#N c #9e6b0b",
"#Y c #9e6d07",
".b c #9f670b",
".q c #9f6b07",
"aI c #9f7303",
".6 c #a06908",
"bh c #a06a0a",
".s c #a06a0b",
".R c #a06e08",
"b0 c #a15a06",
"aA c #a15b06",
"aY c #a2670b",
"bv c #a2680a",
"#f c #a26b0a",
"aJ c #a26c08",
"#k c #a36609",
"#y c #a3690a",
".d c #a36e0e",
"b. c #a46508",
"au c #a46608",
".t c #a4680a",
"aV c #a46d06",
".1 c #a55c09",
"#e c #a57209",
".S c #a57607",
".7 c #a66808",
"#O c #a6690a",
"#z c #a76708",
"bb c #a8780a",
"Qt.#.a.b.c.d.e.f.g.h.i.j.k.l.m.n",
".o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D",
".E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T",
".U.V.W.X.Y.Z.0.1.2.3.4.5.6.7.8.9",
"#.###a#b#c#d#e#f#g#h#i#j#k#l#m#n",
"#o#p#q#r#s#t#u#v#w#x#y#z#A#B#C#D",
"#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#T",
"#U#V#W#X#Y#Z#0#1#2#3#4#5#6#7#8#9",
"a.a#aaabacadaeafagahaiajakalaman",
"aoapaqarasatauavawaxayazaAaBaCaD",
"aEaFaGaHaIaJaKaLaMaNaOaPaQaRaSaT",
"aUaVaWaXaYaZa0a1a2a3a4a5a6a7a8a9",
"b.b#babbbcbdbebfbgbhbibjbkblbmbn",
".sbobpbqbrbsbtbubvbwbxbybzbAbBbC",
"bDbEbFbGbHbIbJafbKbLbMbNbObPbQbR",
"bSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7"};

Added modules/squirrel-quarrel/src/main/resources/dev/shadowtail/squirrelquarrel/tile2.xpm.




































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char *dummy[]={
"16 16 208 2",
"aW c #0019cf",
"a8 c #0019d0",
"aO c #001ad0",
".x c #001bcf",
"aF c #001dcf",
"aD c #001dd0",
".8 c #001ecf",
"bk c #001ed0",
".0 c #001fce",
"a. c #001fcf",
".3 c #001fd0",
"#3 c #0020cf",
"#k c #0020d0",
"#. c #0021ce",
"#r c #0021cf",
"#f c #0021d0",
".E c #0022cc",
"aY c #0022ce",
".O c #0022cf",
"#x c #0022d0",
".U c #0023ce",
"#m c #0023cf",
"#D c #0023d0",
"al c #0024ce",
"aj c #0024cf",
"ar c #0024d0",
".L c #0025cd",
".9 c #0025ce",
".i c #0026cc",
".w c #0026cd",
".Z c #0026cf",
"#P c #0026d0",
"ap c #0027cd",
".G c #0027ce",
"au c #0027cf",
"aX c #0028cc",
".F c #0029ce",
"#y c #0029d0",
".B c #002ace",
"#J c #002ad0",
".p c #002bc9",
"ay c #002bcd",
"#q c #002bcf",
"#2 c #002bd0",
"ah c #002ccf",
"#S c #002cd0",
"aT c #002dc4",
"#I c #002dce",
"#l c #002dcf",
"a5 c #002eb3",
"a# c #002ece",
"#c c #002ecf",
"ab c #002ed0",
".V c #002fc6",
".A c #002fcd",
".P c #002fcf",
".T c #0030cc",
"aL c #0030cd",
"a3 c #0030ce",
"#g c #0030d0",
"aA c #0031ca",
"#9 c #0031cf",
"aQ c #0032cc",
"#H c #0032ce",
"aB c #0032d0",
"#1 c #0033ce",
"#u c #0033cf",
"#C c #0033d0",
".Y c #0034c9",
"bb c #0034ca",
"#p c #0034cf",
"aI c #0035c7",
".K c #0035cb",
"#v c #0035cf",
"ad c #0035d0",
"az c #0036c3",
"a4 c #0036c7",
".j c #0036c8",
"aS c #0036c9",
"aw c #0036cc",
".7 c #0037cc",
"#b c #0037cf",
"aN c #0037d0",
"#e c #0038cd",
"#T c #0038cf",
".4 c #0038d0",
"#0 c #0039ce",
"#O c #0039d0",
"aU c #003ac3",
"b. c #003ac6",
"am c #003ace",
"#h c #003ad0",
".M c #003bc9",
"#t c #003bcd",
".r c #003bce",
"an c #003bcf",
"#Y c #003bd0",
"ax c #003cc9",
"as c #003cd0",
"be c #003dcd",
".c c #003dce",
"#K c #003dd0",
"a1 c #003ec2",
".H c #003ec5",
"#j c #003ecb",
".N c #003ecd",
"#4 c #003ed0",
".f c #003fc7",
"a2 c #003fc9",
".y c #003fcb",
"#Q c #003fcc",
".1 c #0040c7",
"aE c #0040cf",
"af c #0041cb",
"#Z c #0041cd",
"#R c #0041ce",
"aP c #0041cf",
"#o c #0042b9",
".l c #0042c2",
".v c #0042c4",
"aH c #0042c7",
".2 c #0042cb",
"aM c #0042cd",
"ae c #0042ce",
"#6 c #0042cf",
"#7 c #0043c8",
".S c #0043cc",
".5 c #0043cf",
"aR c #0044c2",
"ai c #0044cf",
".o c #0045c6",
"#8 c #0045ce",
"aK c #0046c9",
"#5 c #0046cf",
"aJ c #0047c2",
"aG c #0047c9",
"#w c #0047ce",
"#z c #0047cf",
"#V c #0047d0",
".g c #0048c1",
".h c #0048c4",
".q c #0048cc",
"#U c #0048d0",
"#a c #0049b3",
".m c #0049ca",
"aC c #004acc",
"aq c #004ace",
"aa c #004ad0",
".I c #004bb3",
".z c #004bca",
"#s c #004cc8",
"bg c #004cca",
"#G c #004cce",
"#F c #004ccf",
".X c #004db3",
"#N c #004ecd",
".J c #0050af",
".W c #0050b1",
"#A c #0050cb",
"#i c #0050cc",
".s c #0051cb",
"#W c #0051cf",
"#B c #0052b7",
"## c #0053b7",
"bf c #0053ce",
"bd c #0054c1",
"a9 c #0054c7",
"ak c #0054c9",
"#d c #0054ca",
".C c #0054cd",
"#X c #0055cd",
"av c #0056c6",
".# c #0057bd",
".6 c #0057ca",
"ac c #0057ce",
".k c #0058c5",
".e c #0058cb",
"ag c #0058cc",
".a c #0059a3",
"#n c #0059b2",
"bi c #0059bb",
"ba c #0059cc",
"b# c #0059ce",
"#L c #0059d0",
".b c #005ac0",
"aV c #005ac2",
".t c #005ac8",
"bj c #005acb",
"a7 c #005acd",
"aZ c #005ace",
"#M c #005bc0",
"bl c #005dbf",
"a6 c #005ec0",
".u c #005ec3",
"a0 c #005ec7",
"#E c #005ecb",
".d c #005ece",
"at c #005ecf",
"bn c #0060c1",
".R c #0061ce",
"Qt c #0062c9",
".Q c #0062cd",
".n c #0063cc",
".D c #0063ce",
"ao c #0063cf",
"bh c #0133bf",
"bm c #014ca1",
"bc c #0153b9",
"Qt.#.a.b.c.d.e.f.g.h.i.j.k.l.m.n",
".o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D",
".E.F.G.H.I.J.K.L.x.M.N.O.P.Q.R.S",
".T.U.V.W.X.Y.Z.0.1.2.3.4.5.6.7.8",
".9#.###a#b#c.G#d#e#f#g#h#i#j#k#l",
"#m#n#o#p#q#r#s#t#u.P#v#w.r#x#y#z",
"#A#B#e#C#D#E.r#F#G#H.c#I#J#K#L#y",
"#M#N#O#P#i#Q#R#b#S#T.9#y#J#U#V#W",
"#X#Y#x.N#Z#0#1#2#0#3#l#y#V#4#S#5",
"#6#f.N#7#8#9#q.5a.a#.B.4aa#Cabac",
"adaeafagah#uai.Oajakal#0amajanao",
"#capaqarasataua.avawaxayazaA.5aB",
"#3aCar#kaDaEaFaGaHaI.iaJaKahaFaL",
"aMaN#DaOaPaQaRaSaLaTaUaVaLaWaXaY",
"aZ#Sar#Ja0a1a2a3a4a5a6a7a8.Ga9b.",
"b#babbbcbdbebfbgbhbibj#Dbkblbmbn"};

Added modules/squirrel-quarrel/src/main/resources/dev/shadowtail/squirrelquarrel/tile3.xpm.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char *dummy[]={
"16 16 3 1",
". c #4e2e00",
"a c #885000",
"# c #e8dbbb",
"................",
".##############.",
".#aaaaaaaaaaaa#.",
".#a##########a#.",
".#a#aaaaaaaa#a#.",
".#a#a######a#a#.",
".#a#a#aaaa#a#a#.",
".#a#a#a##a#a#a#.",
".#a#a#a##a#a#a#.",
".#a#a#aaaa#a#a#.",
".#a#a######a#a#.",
".#a#aaaaaaaa#a#.",
".#a##########a#.",
".#aaaaaaaaaaaa#.",
".##############.",
"................"};

Added modules/squirrel-quarrel/src/main/resources/icon.xpm.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char *dummy[]={
"16 16 3 1",
"# c None",
". c None",
"a c #000000",
"................",
"#aaaaa###aaaaa##",
"#a######a#####a#",
"#a######a#####a#",
"#a######a#####a#",
"#a######a#####a#",
"#aaaaa##a#####a#",
"#####a##a#####a#",
"#####a##a#####a#",
"#####a##a###a#a#",
"#####a##a####a##",
"#aaaaa###aaaa#a#",
"###.....#######a",
"###......#######",
"................",
"................"};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/graphics/clock.xpm.


































































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * clock_xpm[] = {
"16 16 142 2",
"  	c #FD7FFD",
". 	c #FB7EFB",
"+ 	c #FF87FF",
"@ 	c #F57BF5",
"# 	c #E171E1",
"$ 	c #E573E5",
"% 	c #EF78EF",
"& 	c #F77CF7",
"* 	c #FF86FF",
"= 	c #FF80FF",
"- 	c #ED77ED",
"; 	c #DF70DF",
"> 	c #D56BD5",
", 	c #F37AF3",
"' 	c #FF92FF",
") 	c #FF13FF",
"! 	c #FF0DFF",
"~ 	c #FF03FF",
"{ 	c #FF07FF",
"] 	c #FB00FB",
"^ 	c #FF0BFF",
"/ 	c #FF00FF",
"( 	c #FF05FF",
"_ 	c #E700E7",
": 	c #EB00EB",
"< 	c #E900E9",
"[ 	c #EB76EB",
"} 	c #FF9BFF",
"| 	c #FF3FFF",
"1 	c #C925C9",
"2 	c #CF3DCF",
"3 	c #C927C9",
"4 	c #C821C8",
"5 	c #7F7F7F",
"6 	c #777777",
"7 	c #656666",
"8 	c #545455",
"9 	c #B400B4",
"0 	c #A400A4",
"a 	c #B300B3",
"b 	c #A800A8",
"c 	c #E975E9",
"d 	c #FFADFF",
"e 	c #FF39FF",
"f 	c #D043D0",
"g 	c #777776",
"h 	c #FFFFFF",
"i 	c #444444",
"j 	c #333233",
"k 	c #212221",
"l 	c #BF00BF",
"m 	c #C107C1",
"n 	c #FF84FF",
"o 	c #FFA4FF",
"p 	c #FF3DFF",
"q 	c #CB2FCB",
"r 	c #00FF00",
"s 	c #101110",
"t 	c #000000",
"u 	c #C71DC7",
"v 	c #FF1DFF",
"w 	c #FF95FF",
"x 	c #FFAEFF",
"y 	c #FF73FF",
"z 	c #D041D0",
"A 	c #00F500",
"B 	c #FEFEFF",
"C 	c #C823C8",
"D 	c #FF33FF",
"E 	c #FFABFF",
"F 	c #FF5DFF",
"G 	c #787778",
"H 	c #EEEEED",
"I 	c #FF35FF",
"J 	c #FF9DFF",
"K 	c #FFB3FF",
"L 	c #FF4DFF",
"M 	c #787878",
"N 	c #FB0000",
"O 	c #EB0000",
"P 	c #DDDDDD",
"Q 	c #CCCCCB",
"R 	c #FFA5FF",
"S 	c #FF55FF",
"T 	c #676667",
"U 	c #FF0000",
"V 	c #CCCCCC",
"W 	c #BBBBBB",
"X 	c #FF2DFF",
"Y 	c #FF8FFF",
"Z 	c #FF27FF",
"` 	c #565656",
" .	c #454545",
"..	c #EEEFEE",
"+.	c #DEDDDD",
"@.	c #CCCCCD",
"#.	c #BBBCBB",
"$.	c #FF15FF",
"%.	c #FF8AFF",
"&.	c #FF11FF",
"*.	c #C517C5",
"=.	c #343434",
"-.	c #EEEEEF",
";.	c #DDDDDE",
">.	c #BBBBBC",
",.	c #AAAAAA",
"'.	c #A200A2",
").	c #FF89FF",
"!.	c #F900F9",
"~.	c #232324",
"{.	c #121212",
"].	c #EEEFEF",
"^.	c #DEDEDD",
"/.	c #CDCDCD",
"(.	c #B100B1",
"_.	c #E500E5",
":.	c #C003C0",
"<.	c #010101",
"[.	c #CDCDCC",
"}.	c #BCBCBC",
"|.	c #B000B0",
"1.	c #F97DF9",
"2.	c #FF17FF",
"3.	c #BD00BD",
"4.	c #C515C5",
"5.	c #C105C1",
"6.	c #C71FC7",
"7.	c #C413C4",
"8.	c #C30DC3",
"9.	c #F179F1",
"0.	c #FF8BFF",
"a.	c #FF19FF",
"b.	c #FF29FF",
"c.	c #FF1FFF",
"d.	c #FF21FF",
"e.	c #FF1BFF",
"f.	c #FF8DFF",
"g.	c #FF8CFF",
"h.	c #FF8EFF",
"i.	c #FF90FF",
"j.	c #FF88FF",
"k.	c #FF83FF",
"  . + @ # $ % & * = & - ; # > , ",
"' ) ! ~ { ] ! ! ^ / ( / _ : < [ ",
"} | 1 2 3 4 5 6 7 8 9 0 a b _ c ",
"d e 2 f 5 5 g h h i j k l m / n ",
"o p q 5 5 h h r h h h s t u v w ",
"x y z 5 h h h r A h h B t C D } ",
"E F 5 G h h h r r h h H t t I J ",
"K L M h h h h t t N O P Q t e o ",
"R S T h h h h t t U P V W t X Y ",
"w Z `  .h h h h ..+.@.#.t t $.w ",
"%.&.*.=.h h h -.;.V >.,.t '.! ).",
"% !.a ~.{.h ].^./.W ,.t t (._.c ",
"& / :.a <.t t [.}.t t t |.9 : 1.",
"* 2.3.4.|.5.t t t t 4 6.7.8.!.9.",
"0./ { a.) ! a.&.( &.b.c.d.e.^ & ",
"f.g.h.Y Y i.j.%.f.g.Y Y k.).).* "};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/graphics/globe.xpm.












































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * globe_xpm[] = {
"16 16 184 2",
"  	c #7BF5F5",
". 	c #86FFFF",
"+ 	c #82FFFF",
"@ 	c #78EFEF",
"# 	c #7FFDFD",
"$ 	c #7CF7F7",
"% 	c #74E7E7",
"& 	c #89FFFF",
"* 	c #83FFFF",
"= 	c #05FFFF",
"- 	c #03FFFF",
"; 	c #23FFFF",
"> 	c #3DFFFF",
", 	c #2DFFFF",
"' 	c #19FFFF",
") 	c #0FFFFF",
"! 	c #00F3F3",
"~ 	c #00FBFB",
"{ 	c #09FFFF",
"] 	c #98FFFF",
"^ 	c #A6FFFF",
"/ 	c #11C4C4",
"( 	c #09C2C2",
"_ 	c #21C8C8",
": 	c #2BCACA",
"< 	c #1201B0",
"[ 	c #2716C5",
"} 	c #2A19C8",
"| 	c #2817C6",
"1 	c #13C4C4",
"2 	c #03C0C0",
"3 	c #17C5C5",
"4 	c #23C8C8",
"5 	c #2BFFFF",
"6 	c #99FFFF",
"7 	c #AFFFFF",
"8 	c #5BFFFF",
"9 	c #3BCECE",
"0 	c #49D2D2",
"a 	c #52C247",
"b 	c #4FC143",
"c 	c #1E0DBC",
"d 	c #3827D6",
"e 	c #6FCC65",
"f 	c #1706B5",
"g 	c #37A52C",
"h 	c #3EB831",
"i 	c #55D5D5",
"j 	c #4DFFFF",
"k 	c #ABFFFF",
"l 	c #B2FFFF",
"m 	c #5FFFFF",
"n 	c #53D4D4",
"o 	c #39AA2D",
"p 	c #67CA5D",
"q 	c #3524D3",
"r 	c #402FDE",
"s 	c #4231E0",
"t 	c #0D00AB",
"u 	c #1100AF",
"v 	c #54C348",
"w 	c #4EC142",
"x 	c #65FFFF",
"y 	c #A3FFFF",
"z 	c #4FD3D3",
"A 	c #3CB330",
"B 	c #339728",
"C 	c #349C29",
"D 	c #3A29D8",
"E 	c #4C3BEA",
"F 	c #3F2EDD",
"G 	c #78CF6F",
"H 	c #5BC550",
"I 	c #604FFE",
"J 	c #5DD7D7",
"K 	c #B6FFFF",
"L 	c #AAFFFF",
"M 	c #61FFFF",
"N 	c #2B1AC9",
"O 	c #5C4BFA",
"P 	c #4332E1",
"Q 	c #5342F1",
"R 	c #3FBB32",
"S 	c #4635E4",
"T 	c #329628",
"U 	c #53FFFF",
"V 	c #B4FFFF",
"W 	c #A1FFFF",
"X 	c #41FFFF",
"Y 	c #2615C4",
"Z 	c #7160FF",
"` 	c #5F4EFD",
" .	c #2C1BCA",
"..	c #3423D2",
"+.	c #6655FF",
"@.	c #45BD38",
"#.	c #3CB22F",
"$.	c #329527",
"%.	c #59FFFF",
"&.	c #9AFFFF",
"*.	c #8BFFFF",
"=.	c #13FFFF",
"-.	c #0200A0",
";.	c #1605B4",
">.	c #73CE6A",
",.	c #5948F7",
"'.	c #5B4AF9",
").	c #46BE3A",
"!.	c #66C95B",
"~.	c #3BB02F",
"{.	c #63C858",
"].	c #3FFFFF",
"^.	c #9EFFFF",
"/.	c #85FFFF",
"(.	c #0DFFFF",
"_.	c #297A20",
":.	c #287720",
"<.	c #301FCE",
"[.	c #4D3CEB",
"}.	c #6C5BFF",
"|.	c #6251FF",
"1.	c #174412",
"2.	c #12360E",
"3.	c #22661B",
"4.	c #1E5A18",
"5.	c #1BFFFF",
"6.	c #8AFFFF",
"7.	c #77EDED",
"8.	c #00F9F9",
"9.	c #0DC3C3",
"0.	c #36A02A",
"a.	c #1908B7",
"b.	c #1B0AB9",
"c.	c #5E4DFC",
"d.	c #8574FF",
"e.	c #7261FF",
"f.	c #1A4D14",
"g.	c #319227",
"h.	c #11FFFF",
"i.	c #79F1F1",
"j.	c #00BFBF",
"k.	c #37A32B",
"l.	c #3AAD2E",
"m.	c #2110BF",
"n.	c #4E3DEC",
"o.	c #8271FF",
"p.	c #7463FF",
"q.	c #3D2CDB",
"r.	c #200FBE",
"s.	c #48BE3B",
"t.	c #3AAC2E",
"u.	c #00ADAD",
"v.	c #00E1E1",
"w.	c #5DC652",
"x.	c #4CC040",
"y.	c #5A49F8",
"z.	c #6E5DFF",
"A.	c #0900A7",
"B.	c #42BC35",
"C.	c #00B6B6",
"D.	c #00FDFD",
"E.	c #8EFFFF",
"F.	c #29FFFF",
"G.	c #1FC7C7",
"H.	c #00B7B7",
"I.	c #6A59FF",
"J.	c #0F00AD",
"K.	c #1BC6C6",
"L.	c #07C1C1",
"M.	c #0BFFFF",
"N.	c #9FFFFF",
"O.	c #1DFFFF",
"P.	c #17FFFF",
"Q.	c #27FFFF",
"R.	c #2FFFFF",
"S.	c #3BFFFF",
"T.	c #25FFFF",
"U.	c #91FFFF",
"V.	c #90FFFF",
"W.	c #87FFFF",
"X.	c #8DFFFF",
"Y.	c #93FFFF",
"Z.	c #94FFFF",
"`.	c #8CFFFF",
"  . + @ + . # . # $   % % # . & ",
"* = - ; ; > , ' ) = = ! ~ { ; ] ",
"^ ; / ( _ : < [ } | 1 2 3 4 5 6 ",
"7 8 9 0 a b c d e f g h 0 i j k ",
"l m n o p h q r s t u v w i x y ",
"k 8 z A B C D E F v G H I J m K ",
"L M N B O P Q I F R a d S T U V ",
"W X Y D R w Z `  ...+.@.#.$.%.&.",
"*.=.-.;.s >.,.'.s ).!.~.H {.].^.",
"/.(._.:.<.[ [.}.|.1.2.3.g 4.5.6.",
"7.8.9.0.a.b.c.d.e.f.g.0.h 2 h.. ",
"i.! j.k.l.m.n.o.p.q.r.s.t.u.v.i.",
"& - ( 3 w.x.y.z.s A.< B.C.u.D.+ ",
"E.F.G.H.j.j.I.I q J.4 : K.L.M./.",
"N.O.= ~ =.P.' ; Q.R.S.T.P.F.) 6.",
"E.E.U.V.W.E.X.V.Y.Z.Y.&.6 U.*.`."};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/graphics/pepper.xpm.





































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * pepper_xpm[] = {
"16 16 113 2",
"  	c #FFFF91",
". 	c #FFFF94",
"+ 	c #FFFF8B",
"@ 	c #FFFF88",
"# 	c #FFFF8A",
"$ 	c #FFFF8F",
"% 	c #FFFF92",
"& 	c #FFFF85",
"* 	c #F9F97D",
"= 	c #FFFF82",
"- 	c #FBFB7E",
"; 	c #FFFF86",
"> 	c #FFFF84",
", 	c #FFFF0F",
"' 	c #FFFF09",
") 	c #FFFF21",
"! 	c #FFFF19",
"~ 	c #FFFF1F",
"{ 	c #FFFF27",
"] 	c #FFFF0D",
"^ 	c #FFFF1D",
"/ 	c #FFFF07",
"( 	c #FFFF23",
"_ 	c #FFFF8E",
": 	c #F3F37A",
"< 	c #FFFF17",
"[ 	c #C7C71D",
"} 	c #C6C619",
"| 	c #C8C821",
"1 	c #CACA2B",
"2 	c #CBCB2D",
"3 	c #C5C517",
"4 	c #CACA29",
"5 	c #C6C61B",
"6 	c #C9C925",
"7 	c #FFFF29",
"8 	c #FFFF97",
"9 	c #FFFF2B",
"0 	c #CCCC31",
"a 	c #09DE09",
"b 	c #CFCF3F",
"c 	c #CECE3B",
"d 	c #CECE39",
"e 	c #D1D145",
"f 	c #D7D75D",
"g 	c #D3D34D",
"h 	c #D1D147",
"i 	c #FFFF57",
"j 	c #FFFFA5",
"k 	c #FFFF89",
"l 	c #CBCB2F",
"m 	c #D4D451",
"n 	c #D5D555",
"o 	c #DADA69",
"p 	c #D8D863",
"q 	c #D8D861",
"r 	c #FFFF65",
"s 	c #FFFFAB",
"t 	c #FFFF93",
"u 	c #36DF00",
"v 	c #17E017",
"w 	c #CFCF3D",
"x 	c #D6D65B",
"y 	c #D7D75F",
"z 	c #FFFF71",
"A 	c #FFFFB2",
"B 	c #FFFF2D",
"C 	c #C10000",
"D 	c #DF0000",
"E 	c #D2D249",
"F 	c #D9D967",
"G 	c #FFFF5F",
"H 	c #FFFF99",
"I 	c #FFFF9F",
"J 	c #D3D34F",
"K 	c #D0D043",
"L 	c #FFFF9C",
"M 	c #FFFF45",
"N 	c #D2D24B",
"O 	c #CCCC33",
"P 	c #FFFF2F",
"Q 	c #FFFFA3",
"R 	c #FFFF5D",
"S 	c #A20000",
"T 	c #D0D041",
"U 	c #FFFF3D",
"V 	c #FFFF3F",
"W 	c #C8C823",
"X 	c #FFFF31",
"Y 	c #FFFF90",
"Z 	c #FFFF33",
"` 	c #C4C413",
" .	c #CDCD35",
"..	c #C4C411",
"+.	c #FFFF83",
"@.	c #FFFF13",
"#.	c #BFBF00",
"$.	c #B1B100",
"%.	c #C3C30F",
"&.	c #C5C515",
"*.	c #C2C20B",
"=.	c #C3C30D",
"-.	c #C7C71F",
";.	c #FDFD7F",
">.	c #EFEF78",
",.	c #FFFF00",
"'.	c #FFFF15",
").	c #FFFF0B",
"!.	c #FFFF1B",
"~.	c #FFFF03",
"{.	c #FFFF80",
"].	c #FFFF8C",
"^.	c #FFFF8D",
"  . . + @ # $ % + . & * = - ; > ",
"$ , ' ) ! ~ { ] , ^ / / ^ ] ( _ ",
": < [ [ } | 1 2 | 3 [ 4 5 6 7 8 ",
"@ 9 0 a b b c 6 d 1 e f g h i j ",
"k , 6 a a c l h m n o p q q r s ",
"t ( 2 u u v 0 c w b x m q y z A ",
"8 B e C D D E 0 w w c w n F G H ",
"I B c C D C e w J K d w E f i L ",
"s M N C D D O x b g g w b O P L ",
"Q R J C D D S m e T h d 6 4 U t ",
"8 V O C D D D S W 0 l N J E X + ",
"Y ~ 0 E S S D D D D D D K 0 Z $ ",
"k ) ` 6 1  .| C C C S D C ..' = ",
"+.@.#.$.3 %.&.%.` *.=.| 6 -.^ ;.",
">.,./ '.).).!., @.~.^ !.] < )   ",
"{.> +.; ].$ > k $ $ ^._ %   Y % "};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/graphics/salt.xpm.
















































































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * salt_xpm[] = {
"16 16 124 2",
"  	c #C8C8C8",
". 	c #C7C7C7",
"+ 	c #BFBFBF",
"@ 	c #C9C9C9",
"# 	c #C5C5C5",
"$ 	c #BEBEBE",
"% 	c #ADADAD",
"& 	c #CBCBCB",
"* 	c #D1D1D1",
"= 	c #CDCDCD",
"- 	c #CFCFCF",
"; 	c #D2D2D2",
"> 	c #D0D0D0",
", 	c #BBBBBB",
"' 	c #808080",
") 	c #858585",
"! 	c #8E8E8E",
"~ 	c #8B8B8B",
"{ 	c #878787",
"] 	c #888888",
"^ 	c #636363",
"/ 	c #747474",
"( 	c #898989",
"_ 	c #8A8A8A",
": 	c #959595",
"< 	c #979797",
"[ 	c #ACACAC",
"} 	c #6F6F6F",
"| 	c #3E3E3E",
"1 	c #434343",
"2 	c #424242",
"3 	c #454545",
"4 	c #F6F6F6",
"5 	c #FFFFFF",
"6 	c #404040",
"7 	c #3F3F3F",
"8 	c #444444",
"9 	c #797979",
"0 	c #B6B6B6",
"a 	c #9B9B9B",
"b 	c #666666",
"c 	c #3B3B3B",
"d 	c #363636",
"e 	c #E0E0E0",
"f 	c #EFEFEF",
"g 	c #F8F8F8",
"h 	c #373737",
"i 	c #3C3C3C",
"j 	c #FEFAFA",
"k 	c #A4A4A4",
"l 	c #7A7A7A",
"m 	c #505050",
"n 	c #565656",
"o 	c #F0F0F0",
"p 	c #F4F3F0",
"q 	c #F5F5F6",
"r 	c #D2D6D1",
"s 	c #C6C6C6",
"t 	c #4D4D4D",
"u 	c #5A5A5A",
"v 	c #FFFFF2",
"w 	c #EDEDED",
"x 	c #FFFFFC",
"y 	c #C1C1C1",
"z 	c #8F8F8F",
"A 	c #D5D5D5",
"B 	c #CACACA",
"C 	c #E6E6E6",
"D 	c #515151",
"E 	c #F8F6F9",
"F 	c #EFEDE9",
"G 	c #838383",
"H 	c #B5B5B5",
"I 	c #7B7B7B",
"J 	c #D9D9D9",
"K 	c #DBDBDB",
"L 	c #D7D7D7",
"M 	c #F5F5F5",
"N 	c #FCFCFC",
"O 	c #E7E8F1",
"P 	c #FBFBFB",
"Q 	c #FDFDFD",
"R 	c #909090",
"S 	c #A6A6A6",
"T 	c #F3F3F3",
"U 	c #E8E8E8",
"V 	c #E9E9E9",
"W 	c #DDDDDD",
"X 	c #FFFFFE",
"Y 	c #FAFAFA",
"Z 	c #575757",
"` 	c #CCCCCC",
" .	c #A9A9A9",
"..	c #7D7D7D",
"+.	c #E4E4E4",
"@.	c #E5E5E5",
"#.	c #EEEEEE",
"$.	c #ECECEC",
"%.	c #7E7E7E",
"&.	c #B9B9B9",
"*.	c #F7F7F7",
"=.	c #F2F2F2",
"-.	c #FAFAFB",
";.	c #4A4A4A",
">.	c #B3B3B3",
",.	c #4C4C4C",
"'.	c #DBEEEC",
").	c #D8D8D8",
"!.	c #8D8D8D",
"~.	c #B2B2B2",
"{.	c #414141",
"].	c #DCDDE7",
"^.	c #C3C3C3",
"/.	c #4E4E4E",
"(.	c #464646",
"_.	c #646464",
":.	c #5D5D5D",
"<.	c #6B6B6B",
"[.	c #949494",
"}.	c #8C8C8C",
"|.	c #989898",
"1.	c #939393",
"2.	c #969696",
"3.	c #CECECE",
"  . + . @ # $ % $ . & * = - ; > ",
", ' ) ! ~ { ] ^ / ) ( _ { : < . ",
"[ } | 1 2 3 4 5 5 6 7 8 3 8 9 0 ",
"a b c d c e f 5 g h i 7 6 j / . ",
"k l 2 i 7 5 5 5 5 m n o p q r s ",
"$ ) t ^ u 5 5 5 5 u 5 v 5 w x s ",
"y z A   B 5 g C 4 D E f g F G 0 ",
"H I J K - L M J N 5 O P Q g R - ",
"S T U V W C 5 L 5 5 X Y 5 Z _ ` ",
" ...T +.@.U w L #.5 5 5 $.m %.. ",
"&...1 o e T 5 *.=.5 -.*.;.m _ . ",
">...D ,.U *.5 5 5 5 '.).;.,.!.` ",
"~./ {.t #.e =.T 5 5 ].3 u b < - ",
"^.] /.(.m +.T T =.K n _.:.<.[.* ",
"& ' I ' ] G T T R }.|.1.2.~ ! 3.",
"s # y s # y . B   @ B 3.= = - > "};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/terrain/dirt.xpm.




































































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
66
67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * dirt_xpm[] = {
"32 32 32 1",
" 	c #733C0C",
".	c #763F0C",
"+	c #70390B",
"@	c #6E370B",
"#	c #743D0C",
"$	c #713A0B",
"%	c #6F380B",
"&	c #723B0B",
"*	c #79420C",
"=	c #7D460D",
"-	c #78410C",
";	c #753E0C",
">	c #7C450C",
",	c #7B440C",
"'	c #77400C",
")	c #7E470D",
"!	c #7A430C",
"~	c #7E470C",
"{	c #7F480D",
"]	c #824B0D",
"^	c #80490D",
"/	c #733C0B",
"(	c #814A0D",
"_	c #7C450D",
":	c #7A430D",
"<	c #79420D",
"[	c #7D460C",
"}	c #743D0B",
"|	c #7B440D",
"1	c #753E0B",
"2	c #834C0D",
"3	c #844D0E",
" .+@@.#$@%&*&@@& @@@=@@@@&@+-%+%",
";.+++>@#;..%&@;;+&%*#@,-.'%.-@'+",
" +++@*)&!&)&'&~++'#{-,;$]@%$*^!$",
"@$-*@/$*%~!,;#=!!!%.#$'#-,..;-@#",
"@$-''-$'+$>$@=#'@##%@@% #$+%$(^&",
"@  '-;!~#&'+$_*:;#$&$'*$@ ++*.*.",
"@@,-#$.#;.%(!';@#;@!+;>;#<[+.^@.",
"&@#@@+&@'<-;.%++;//,%-%.#%.!;=^+",
"#@%}#:&;@&)&[/++_,//,#;+++;&$_@&",
".'+'$$@-![^{># .; #- ;-%}*% $=;#",
"-@@% ,.,*$$&&;+!;'-#$$..})@.$:~@",
".}..$;'@*{@--+$/; $;+@@%&:!#!-)#",
"+-+ }+$+#!{;*$%}!#$@#%#|>'@$!@+;",
"@'@&&#&! '-#;;=,_;_@ &!%-$@@+=!@",
"@'$+@&$*%!+;+>; ,;-*&@;-*.'.!#%@",
"&-/@&&@*.@!-&%+%+$&+@$;+@{;-%%%@",
".@'*%@,!1>!,@@%/-$$$!)#%=;@!'$-%",
";#.@+@!)-)$),#%&_!$..,&''-.%+[{@",
"+.@%@@#<#@]{>#-${=%.~-;'([&+&=@$",
"@@$+@ % &*,($@)!'. =;%<@%',@+,{!",
"@$,%+ %##%(''*!%#|&${,@%+@%|#[*@",
"@@- /$),.--*;&{;;#(% }@%.{!&#=*@",
"@@@/$+'$%,{;'+{(! ...;&@(-!@,@##",
"@@=%%[;*%@;;&.+&.;-**@$)2 $!)+##",
"@;.;|.@$);;~@^#;.@##,,*..^-!,;_%",
"@@_;;!&=;!#;{',*.=,&3);+&.''-=&-",
"@@%%%#}@@#+& ;.@&~,/>@.&+;  +-.+",
"@%%';@;@@$$$+ ,!!=@@^{#,#'='@*!@",
"@!@+,[@+.'%-}.&&$*;  @%@|.*))$=*",
"@-##'&@>';,$*$; % ;++% '>..!@+!*",
"@@#@#% +(#@_@+;*#+$&&!1=!$@{ %++",
"@@@@+#@@$@@;),@@@%%=;;;,!>,,@&%+"};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/terrain/grass.xpm.























































































































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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * grass_xpm[] = {
"32 32 83 1",
" 	c #02B602",
".	c #02B702",
"+	c #02B302",
"@	c #02A902",
"#	c #02B802",
"$	c #01B601",
"%	c #01B201",
"&	c #01B801",
"*	c #01B701",
"=	c #01B301",
"-	c #01A501",
";	c #01A101",
">	c #02B002",
",	c #01A301",
"'	c #01AC01",
")	c #02AE02",
"!	c #02B502",
"~	c #02A502",
"{	c #009D00",
"]	c #01A801",
"^	c #01B501",
"/	c #01AD01",
"(	c #01B101",
"_	c #01A701",
":	c #01B001",
"<	c #00A200",
"[	c #01A001",
"}	c #009700",
"|	c #019901",
"1	c #01A401",
"2	c #02B102",
"3	c #01A201",
"4	c #02B202",
"5	c #01A901",
"6	c #00A100",
"7	c #019E01",
"8	c #01AE01",
"9	c #02AF02",
"0	c #02A802",
"a	c #019D01",
"b	c #02AB02",
"c	c #02AD02",
"d	c #009E00",
"e	c #02A702",
"f	c #009F00",
"g	c #01B401",
"h	c #02AA02",
"i	c #02AC02",
"j	c #00AB00",
"k	c #00B600",
"l	c #00B800",
"m	c #00B500",
"n	c #00B400",
"o	c #00B300",
"p	c #00B200",
"q	c #00A900",
"r	c #00AD00",
"s	c #00AE00",
"t	c #00AC00",
"u	c #00B100",
"v	c #00A600",
"w	c #00A700",
"x	c #00A800",
"y	c #01AA01",
"z	c #00A000",
"A	c #009A00",
"B	c #00B700",
"C	c #02B402",
"D	c #00AA00",
"E	c #00AF00",
"F	c #01A601",
"G	c #00B000",
"H	c #00A300",
"I	c #00A400",
"J	c #009800",
"K	c #00A500",
"L	c #01AF01",
"M	c #009900",
"N	c #009C00",
"O	c #009B00",
"P	c #009500",
"Q	c #01AB01",
"R	c #019F01",
" .+. @@ #$%&*=-;>,'.#.)@.#+!# @@",
"~ &${]^/$(_:-<;[}|!!!.1>2!34 @@!",
"~ %($^/5,_%{'6)7;; /8 9~0aa9~0@b",
" c-/$3d8{/5]$$*$   ,2 2+3@@1>b;e",
".15'%1%fg*^*&*$*$*552; #  hh!3!i",
"#2[:jjkklmnlmomnp$d=5%.  . .# . ",
" @[5qkrmkrkksnqpmg^<$^92@c2 .+hc",
"# $*kktnsruvm<wtrx^$$y;~;+)_>zA2",
"#^g^sqqkjpvkBqmsjx::_/(];]aC_2!#",
".%8yDkku6kkllBBkruy5;/$53!/ 4.##",
"48(-mlk<mBBllkrrmzv<zuB.  !.c2.#",
".$%8BllonpEBuv<Ekttqqrm*C4+95>F.",
".***lBBuGuum<Hxkrq<6vjsi$*/,/H5$",
"/'^&BGtkuHkwwmjmndnwqIm5$$<'5]F(",
"-C%guuxkqqoJKEdu<vtszGq(*$$*${8_",
"!>(guouBkkufn<GBo{qpKwwtmokmlm6r",
"#. 'mvkBGxIqurBk<stDHKrptksjku<k",
"##.$qplkw{<kuKkGr{IIdrrKKG6qukkB",
"&*LL^BBGMrkkdKkKKwvDDEGHrzDnwukv",
"&mfjGukKDEBBjjm{o{wqxqkGIuodDrKr",
"$6mkxoqwttuujDqvnG6r6wpHqpHsf6ww",
"$GBlkIqmsrDuKI<DrkmoxKu6plmEsqzA",
"(6klBtGKwrrtANE6mBo<xr{6HmEkkqqn",
"]xupokKumvoNOxn6ukqK6mzOuDsklBBB",
"{EIDkqKGrrsOOnqqkuwxvnqtK<rsuokG",
"]wfuBmzukksr6G6kk<jkm<GMOKKswxpv",
"$qKqkDqkBso6Emklmfjkm6Hf{{xqxDBn",
"&kx{kkkkDvmkw{ukwvmu6mkszxpqdrkI",
"&m{wptqtzmlpA<kBnxqrDkk{ptoqqkl$",
" rM66}MDDBBjDkkEq6EK<kkE6kmKtkn'",
"!p6{P{v6uku6mk6HJu6<EtrE<ks/Q-1<",
"8pKdukBkBlksGufmmlkkqqpdnG<$_R_$"};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/units/chlorophid_garden/info.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Manifest-Version: 1.0
name: Garden
hp: 1250
armor: 1
salt-cost: 300
build-time: 1800
supply-provided: 2
sight: 288
score-build: 300
score-destroy: 900
size: large
tile-dimensions: [4, 3]
pixel-dimensions: [99, 65]
pixel-offset: (15, 16)
abilities: regenerates_hp

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/units/start_location/idle0v.xpm.























































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/* XPM */
static char * idle0v_xpm[] = {
"64 48 3 1",
" 	c None",
".	c #000000",
"+	c #FF00FF",
"................................................................",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++......................................++++++++++++.",
".++++++++++++.                                    .++++++++++++.",
".++++++++++++..                                  ..++++++++++++.",
".+++++++++++++...                              ...+++++++++++++.",
".+++...+++++++++..                            ..+++++++++...+++.",
".+++. ..+++++++++..                          ..+++++++++.. .+++.",
".+++.  ...++++++++...                      ...++++++++...  .+++.",
".+++.    ..+++++++++..                    ..+++++++++..    .+++.",
".+++.     ..+++++++++..                  ..+++++++++..     .+++.",
".+++.      ...++++++++...              ...++++++++...      .+++.",
".+++.        ..+++++++++..            ..+++++++++..        .+++.",
".+++.         ..+++++++++..          ..+++++++++..         .+++.",
".+++.          ...++++++++...      ...++++++++...          .+++.",
".+++.            ..+++++++++..    ..+++++++++..            .+++.",
".+++.             ..+++++++++..  ..+++++++++..             .+++.",
".+++.              ...++++++++....++++++++...              .+++.",
".+++.                ..++++++++++++++++++..                .+++.",
".+++.                 ..++++++++++++++++..                 .+++.",
".+++.                  ...++++++++++++...                  .+++.",
".+++.                    .++++++++++++.                    .+++.",
".+++.                    .++++++++++++.                    .+++.",
".+++.                  ...++++++++++++...                  .+++.",
".+++.                 ..++++++++++++++++..                 .+++.",
".+++.                ..++++++++++++++++++..                .+++.",
".+++.              ...++++++++....++++++++...              .+++.",
".+++.             ..+++++++++..  ..+++++++++..             .+++.",
".+++.            ..+++++++++..    ..+++++++++..            .+++.",
".+++.          ...++++++++...      ...++++++++...          .+++.",
".+++.         ..+++++++++..          ..+++++++++..         .+++.",
".+++.        ..+++++++++..            ..+++++++++..        .+++.",
".+++.      ...++++++++...              ...++++++++...      .+++.",
".+++.     ..+++++++++..                  ..+++++++++..     .+++.",
".+++.    ..+++++++++..                    ..+++++++++..    .+++.",
".+++.  ...++++++++...                      ...++++++++...  .+++.",
".+++. ..+++++++++..                          ..+++++++++.. .+++.",
".+++...+++++++++..                            ..+++++++++...+++.",
".+++++++++++++...                              ...+++++++++++++.",
".++++++++++++..                                  ..++++++++++++.",
".++++++++++++.                                    .++++++++++++.",
".++++++++++++......................................++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
"................................................................"};

Added modules/squirrel-quarrel/src/main/resources/net/multiphasicapps/squirrelquarrel/data/units/start_location/info.






1
2
3
4
5
+
+
+
+
+
Manifest-Version: 1.0
hp: 1
pixel-dimensions: [97, 65]
pixel-offset: (16, 16)

Added modules/strings/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains basic string utilities " +
	"which are useful when parsing strings."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AM"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Basic String Utilities"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:collections")
}

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

package net.multiphasicapps.strings;

import java.util.Arrays;
import net.multiphasicapps.collections.IntegerList;

/**
 * This contains utilities which operate on character sequences.
 *
 * @since 2017/11/30
 */
public final class CharSequenceUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/30
	 */
	private CharSequenceUtils()
	{
	}
	
	/**
	 * Splits the specified character sequence using the given delimeter and
	 * returns all of the fields which are contained within. Extra whitespace
	 * within fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The sequence to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final CharSequence[] fieldSplit(char __delim,
		CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Get all indexes of that given character
		int[] ind = CharSequenceUtils.multipleIndexOf(__delim, __s);
		int delcount = ind.length;
		
		int n = delcount + 1;
		CharSequence[] rv = new CharSequence[n];
		for (int l = -1, r = 0, i = 0; i < n; i++, l++, r++)
			rv[i] = __s.subSequence((l >= 0 ? ind[l] + 1 : 0),
				(r < delcount ? ind[r] : __s.length()));
		
		return rv;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __s.length(); i < n; i++)
			if (__c == __s.charAt(i))
				return i;
		return -1;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// For optimization sort the input array to find characters faster
		__c = __c.clone();
		Arrays.sort(__c);
		
		// Forward to one which assumes sorted input
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		return CharSequenceUtils.firstIndex(__c.toCharArray(), __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Go through ever character
		for (int i = 0, n = __s.length(), y = __c.length; i < n; i++)
		{
			// Use binary search because it is faster than checking each
			// and every element
			char c = __s.charAt(i);
			if (Arrays.binarySearch(__c, c) >= 0)
				return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given sequence.
	 *
	 * @param __c The character to get the indexes for.
	 * @param __s The sequence to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		IntegerList list = new IntegerList();
		
		// Find every character index
		for (int i = 0, n = __s.length(), lastdx = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Add index to list if found
			if (c == __c)
				list.addInteger(i);
		}
		
		// Finish
		return list.toIntegerArray();
	}
}

Added modules/strings/src/main/java/net/multiphasicapps/strings/StringUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.strings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * This class contains static methods which can be used for manipulating
 * strings.
 *
 * @since 2017/11/23
 */
public final class StringUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/23
	 */
	private StringUtils()
	{
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(char[] __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Parse string
		boolean dows = true;
		int lastdelim = -2;
		for (int i = 0, n = __s.length(), mark = 0; i <= n; i++)
		{
			// -1 is a special delimeter for the end of string because
			// otherwise if the string does not end in a delimeter it will not
			// be found
			int c = (i == n ? -1 : __s.charAt(i));
			
			// Is this a delimeter
			if (c == lastdelim || c == -1 || StringUtils.__indexOf(__delim, (char)c) >= 0)
			{
				// Remember last delimeter for potential speed
				lastdelim = c;
				
				// If reading delimeters, clear flag and mark
				// to remember the current index
				if (dows)
				{
					dows = false;
					mark = i;
				}
				
				// Otherwise end of sequence, generate string
				else
				{
					// Split out
					__out.add(__s.substring(mark, i));
					
					// Switch to handling delimeters
					dows = true;
				}
			}
			
			// If reading delimeters, clear flag and mark
			// to remember the current index, is not delimeters
			// here
			else if (dows)
			{
				dows = false;
				mark = i;
			}
		}
		
		// Return output always
		return __out;
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(String __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		return StringUtils.basicSplit(__delim.toCharArray(), __s, __out);
	}
	
	/**
	 * Splits the given string using the specified delimeter.
	 *
	 * @param __delim The delimeter to use.
	 * @param __s The string to split.
	 * @return The split string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/23
	 */
	public static final String[] basicSplit(char __delim, String __s)
	{
		return StringUtils.basicSplit(new char[]{__delim}, __s);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(char[] __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		Collection<String> rv = StringUtils.basicSplit(__delim, __s,
			new ArrayList<String>());
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(String __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		return StringUtils.basicSplit(__delim.toCharArray(), __s);
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within, any leading and trailing
	 * whitespace is trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplitAndTrim(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Split and trim
		String[] rv = StringUtils.fieldSplit(__delim, __s);
		for (int i = 0, n = rv.length; i < n; i++)
			rv[i] = rv[i].trim();
		return rv;
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within. Extra whitespace within
	 * fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplit(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		CharSequence[] xrv = CharSequenceUtils.fieldSplit(__delim, __s);
		return Arrays.<String, CharSequence>copyOf(xrv, xrv.length,
			String[].class);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given string.
	 *
	 * @param __c The character to get the indexes for.
	 * @param __s The string to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.multipleIndexOf(__c, __s);
	}
	
	/**
	 * Converts the specified string to lowercase ignoring locale, this uses
	 * {@link Character#toLowerCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The lowercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toLowerCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toLowerCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Converts the specified string to uppercase ignoring locale, this uses
	 * {@link Character#toUpperCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The uppercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toUpperCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toUpperCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Searches the input array to see if the given character is within the
	 * array.
	 *
	 * @param __a The array to check.
	 * @param __c The character to find in the array.
	 * @return The index of the character or {@code -1} if it was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	private static final int __indexOf(char[] __a, char __c)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			if (__c == __a[i])
				return i;
		return -1;
	}
}

Added modules/strings/src/main/java/net/multiphasicapps/strings/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes for manipulating strings.
 *
 * @since 2017/11/23
 */

package net.multiphasicapps.strings;

Added modules/tac-runner/build.gradle.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This is a system which interacts with " +
	"SquirrelJME and is able to launch and execute various tests within " +
	"the environment automatically."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AI"
	swmType = JavaMEMidletType.API
	swmName = "TAC Runner"
	swmVendor = "Stephanie Gawroriski"
	mainClass = "net.multiphasicapps.tac.runner.Main"
}

dependencies
{
	implementation project(":modules:cldc-compact")
	implementation project(":modules:collections")
	implementation project(":modules:meep-swm")
}

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

package net.multiphasicapps.tac.runner;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteManager;
import javax.microedition.swm.SuiteType;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableCollection;

/**
 * This class loads and stores the database for the test system.
 *
 * @since 2018/10/17
 */
public final class Database
	implements Iterable<SingleUnit>
{
	/** Suite mappings by name. */
	private final Map<String, SingleUnit> _units;
	
	/**
	 * Initializes the database of units.
	 *
	 * @param __it The units to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	public Database(Iterable<SingleUnit> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		// Map units
		Map<String, SingleUnit> units = new SortedTreeMap<>();
		for (SingleUnit u : __it)
			if (u == null)
				throw new NullPointerException("NARG");
			else
				units.put(u.fullName(), u);
		
		this._units = units;		
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/17
	 */
	@Override
	public final Iterator<SingleUnit> iterator()
	{
		return UnmodifiableCollection.<SingleUnit>of(
			this._units.values()).iterator();
	}
	
	/**
	 * Builds the test database.
	 *
	 * @return The built test database.
	 * @since 2018/10/17
	 */
	public static final Database build()
	{
		List<SingleUnit> units = new LinkedList<>();
		
		// Need this to go through all the available suites for testing
		SuiteManager sm = ManagerFactory.getSuiteManager();
		for (Suite s : sm.getSuites(SuiteType.APPLICATION))
		{
			// This is not a test program for SquirrelJME, ignore
			if (!Boolean.valueOf(s.getAttributeValue("x-squirreljme-tests")))
				continue;
			
			// Load single units for tests
			for (Iterator<String> it = s.getMIDlets(); it.hasNext();)
				units.add(new SingleUnit(s, it.next()));
		}
		
		// Build the final database
		return new Database(units);
	}
}

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

package net.multiphasicapps.tac.runner;

import java.io.PrintStream;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

/**
 * Main entry class for the TAC runner system.
 *
 * @since 2018/10/17
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments, used to filter tests.
	 * @since 2018/10/17
	 */
	public static void main(String... __args)
	{
		// Load arguments
		if (__args == null)
			__args = new String[0];
		Deque<String> args = new LinkedList<>();
		for (String s : __args)
			if (s != null)
				args.add(s);
		
		// Load the database
		Database db = Database.build();
		
		// List tests?
		if ("-l".equals(args.peekFirst()))
		{
			// Remove it!
			args.pollFirst();
			
			// Banner to standard error
			System.err.println("Available tests:");
			
			// Output the tests to standard output
			PrintStream out = System.out;
			for (SingleUnit u : db)
				out.println(u.fullName());
			
			// Stop
			return;
		}
		
		// Running specific tests? These get crimped accordingly
		Set<String> specific = new HashSet<>(),
			endwild = new HashSet<>(),
			startwild = new HashSet<>();
		while (!args.isEmpty())
		{
			// Ignore nulls
			String s = args.pollFirst();
			if (s == null)
				continue;
			
			// Crimp to simplify it
			s = SingleUnit.__crimpName(s);
			
			// Ending wildcard? Run all tests
			if (s.endsWith("*"))
				endwild.add(s.substring(0, s.length() - 1));
			
			// Starts with wildcard?
			else if (s.startsWith("*"))
				startwild.add(s.substring(1));
			
			// Run specific test
			else
				specific.add(s);
		}
		
		// If there is no specific test, just ignore it
		if (specific.isEmpty())
			specific = null;
		if (endwild.isEmpty())
			endwild = null;
		if (startwild.isEmpty())
			startwild = null;
		
		// Checking for tests?
		boolean check = (specific != null || endwild != null ||
			startwild != null);
		
		// Report for tests to run
		Report report = new Report();
		
		// Run each test
		int total = 0,
			pass = 0,
			fail = 0;
		boolean hasfailed = false;
		for (SingleUnit su : db)
		{
			String fn = su.fullName();
			
			// Check if we want to run this test
			if (check)
			{
				boolean found = false;
				
				// Is this a specific test being run?
				if (specific != null && specific.contains(fn))
					found = true;
				
				// Ends in a wildcard? Run multiple tests?
				if (!found && endwild != null)
					for (String prefix : endwild)
						if (fn.startsWith(prefix))
						{
							found = true;
							break;
						}
				
				// Starts with a wildcard?
				if (!found && startwild != null)
					for (String suffix : startwild)
						if (fn.endsWith(suffix))
						{
							found = true;
							break;
						}
				
				// Not found, ignore!
				if (!found)
					continue;
			}
			
			// Run the test
			System.err.printf("Running %s...%n", fn);
			long startns = System.nanoTime();
			boolean passed = su.run();
			
			// Keep track
			total++;
			if (!passed)
			{
				fail++;
				hasfailed = true;
			}
			else
				pass++;
			
			// How long did this take?
			long durns = System.nanoTime() - startns;
			
			// Send to the report for later usage
			report.add(fn, passed, durns);
		}
		
		// Note it
		System.err.printf("Ran %d tests: %d passed, %d failed.%n",
			total, pass, fail);
		
		// Generate report
		report.generate(System.out, ReportType.JUNIT);
		
		// Exit with failure if there are bad tests
		if (hasfailed)
			System.exit(1);
	}
}

Added modules/tac-runner/src/main/java/net/multiphasicapps/tac/runner/Report.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import java.io.PrintStream;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This class contains the partial test report which contains all of the
 * information on which tests have passed and which have failed.
 *
 * @since 2019/01/23
 */
public final class Report
{
	/** Nanoseconds per second. */
	public static final double NANOS_PER_SECOND =
		1_000_000_000D;
		
	/** Properties to print. */
	private static final String[] _PROPERTIES =
		new String[]
		{
			"java.version",
			"java.vendor",
			"java.vendor.email",
			"java.vendor.url",
			"java.vm.name",
			"java.vm.version",
			"cc.squirreljme.apilevel",
			"java.vm.vendor",
			"java.vm.vendor.email",
			"java.vm.vendor.url",
			"java.runtime.name",
			"java.runtime.version",
			"os.name",
			"os.arch",
			"os.version",
			"microedition.locale",
			"microedition.profiles",
			"cc.squirreljme.vm.execpath",
			"cc.squirreljme.vm.freemem",
			"cc.squirreljme.vm.totalmem",
			"cc.squirreljme.vm.maxmem",
			"cc.squirreljme.debug",
		};
	
	/** Report mapping. */
	private final Map<String, ReportItem> _items =
		new SortedTreeMap<>();
	
	/** Number of tests ran. */
	private volatile int _numtests;
	
	/** Number of passes. */
	private volatile int _numpass;
	
	/** Number of failures. */
	private volatile int _numfail;
	
	/** The time spent running tests. */
	private volatile long _totalns;
	
	/**
	 * Adds a single test to the report.
	 *
	 * @param __n The test name.
	 * @param __p Did the test pass?
	 * @param __ns The duration of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void add(String __n, boolean __p, long __ns)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// Pass/fail counts
			this._numtests++;
			if (__p)
				this._numpass++;
			else
				this._numfail++;
			
			// Time spent in test
			this._totalns += __ns;
			
			// Add item
			this._items.put(__n, new ReportItem(__n, __p, __ns));
		}
	}
	
	/**
	 * Generates the test report.
	 *
	 * @param __out The stream to write to.
	 * @param __t The type to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void generate(PrintStream __out, ReportType __t)
		throws NullPointerException
	{
		if (__out == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Generate report depending on the format
		switch (__t)
		{
				// JUnit test report
			case JUNIT:
				this.generateJUnit(__out);
				break;
			
				// {@squirreljme.error AI01 Unknown report type.}
			default:
				throw new RuntimeException("AI01 " + __t);
		}
	}
	
	/**
	 * Generates a JUnit test report.
	 *
	 * JUnit test reports are XML based, which is quite complex however
	 * the test names and such are simple so we just need to output them
	 * correctly.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void generateJUnit(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		Map<String, ReportItem> items = this._items;
		int numtests = this._numtests,
			numpass = this._numpass,
			numfail = this._numfail;
		long totalns = this._totalns;
		
		// Lock
		synchronized (this)
		{
			// XML header
			__out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
			
			// Testsuites
			__out.printf("<testsuites failures=\"%d\" " +
				"tests=\"%d\" time=\"%s\">%n",
				numfail, numpass,
				Report.doubleToString(totalns / Report.NANOS_PER_SECOND));
			
			// There is just a single test suite
			__out.printf("<testsuite name=\"SquirrelJME\" " +
				"tests=\"%d\" failures=\"%d\" id=\"0\" time=\"%s\">%n",
				numtests, numfail,
				Report.doubleToString(totalns / Report.NANOS_PER_SECOND));
			
			// Dump environment showing the details of the VM, this is taken
			// from the hello demo. Just used to identify the VM and such.
			__out.println("<properties>");
			for (String p : Report._PROPERTIES)
				try
				{
					String v = System.getProperty(p);
					if (v != null)
						__out.printf("<property name=\"%s\" value=\"%s\" />%n",
							p, v.replace('"', '\''));
				}
				catch (SecurityException e)
				{
				}
			__out.println("</properties>");
			
			// Print every item
			for (ReportItem i : items.values())
			{
				__out.printf("<testcase name=\"%s\" " +
					"classname=\"%s\" status=\"%s\" time=\"%s\">%n",
					i.name, i.name, (i.passed ? "pass" : "fail"),
					Report.doubleToString(i.duration / Report.NANOS_PER_SECOND));
				
				// Failure gets a note attached
				if (!i.passed)
					__out.println("<failure message=\"Failed.\" />");

				// End
				__out.println("</testcase>");
			}
			
			// End everything
			__out.println("</testsuite>");
			__out.println("</testsuites>");
		}
	}
	
	/**
	 * Converts a double to a string. This is needed because at the time of
	 * this writing doubles are not supported in {@link java.util.Formatter}.
	 *
	 * @param __d The double to convert.
	 * @return The resulting string.
	 * @since 2019/01/23
	 */
	public static final String doubleToString(double __d)
	{
		// Add whole number portion (just cast to number value)
		StringBuilder sb = new StringBuilder();
		sb.append((long)__d);
		
		// Add decimal point
		sb.append(".");
		
		// Add some fraction parts
		long frac = ((long)(__d * 1000.0D)) % 1000L;
		if (frac < 0)
			frac = -frac;
		sb.append(String.format("%03d", frac));
		
		// Build it
		return sb.toString();
	}
}

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

package net.multiphasicapps.tac.runner;

/**
 * This represents a single report item.
 *
 * @since 2019/01/23
 */
public final class ReportItem
{
	/** The test name. */
	public final String name;
	
	/** Did this test pass? */
	public final boolean passed;
	
	/** Time spent in this test. */
	public final long duration;
	
	/**
	 * Initializes the report item.
	 *
	 * @param __n The test name.
	 * @param __p Did the test pass?
	 * @param __ns The duration of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public ReportItem(String __n, boolean __p, long __ns)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.passed = __p;
		this.duration = __ns;
	}
}

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

package net.multiphasicapps.tac.runner;

/**
 * Represents the type of report to make.
 *
 * @since 2019/01/23
 */
public enum ReportType
{
	/** JUnit XML Report. */
	JUNIT,
	
	/** End. */
	;
}

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

package net.multiphasicapps.tac.runner;

import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * This contains a single test unit which may be run accordingly.
 *
 * @since 2018/10/17
 */
public final class SingleUnit
{
	/** The full name for this suite. */
	protected final String fullname;
	
	/** The suite for this unit. */
	protected final Suite suite;
	
	/** The midlet for this unit. */
	protected final String midlet;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __s The suite of the unit.
	 * @param __m The unit midlet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	public SingleUnit(Suite __s, String __m)
		throws NullPointerException
	{
		if (__s == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.suite = __s;
		this.midlet = __m;
		
		// The MIDlet name can be quite long, so see if there is an internal
		// name for the project used by SquirrelJME
		String sqname = __s.getAttributeValue(
			"X-SquirrelJME-InternalProjectName");
		if (sqname == null)
			sqname = __s.getName();
		else if (sqname.endsWith(".test"))
			sqname = sqname.substring(0, sqname.length() - 5);
		
		// Setup full name
		this.fullname = SingleUnit.__crimpName(sqname) + "." +
			SingleUnit.__crimpName(__m);
	}
	
	/**
	 * The full name for this test.
	 *
	 * @return The full name for this test.
	 * @since 2018/10/29
	 */
	public final String fullName()
	{
		return this.fullname;
	}
	
	/**
	 * Runs the test.
	 *
	 * @return Whether the test was a success or not.
	 * @since 2018/10/17
	 */
	public final boolean run()
	{
		// Start task
		Task task = ManagerFactory.getTaskManager().startTask(
			this.suite, this.midlet);
		
		// Run the task task until it terminates
		for (long mswait = 100;; mswait = Math.min(mswait + 100, 1000))
		{
			// Check status
			TaskStatus status = task.getStatus();
			
			// Depends on the status
			switch (status)
			{
					// Success
				case EXITED_REGULAR:
					return true;
					
					// Failure
				case EXITED_FATAL:
				case EXITED_TERMINATED:
				case START_FAILED:
					return false;
					
					// Unhandled
				default:
					break;
			}
			
			// Wait for the task to do things before checking again
			try
			{
				Thread.sleep(mswait);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
	
	/**
	 * Crimps the name so it fits and is easier to type and such.
	 *
	 * @param __in The input name.
	 * @return The crimped name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	static final String __crimpName(String __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Strip and lowercase characters
		StringBuilder rv = new StringBuilder();
		for (int i = 0, n = __in.length(); i < n; i++)
		{
			char c = __in.charAt(i);
			
			// Lowercase capitals
			if (c >= 'A' && c <= 'Z')
				c = Character.toLowerCase(c);
			
			// Underscores to hyphens
			else if (c == '_')
				c = '-';
			
			// Ignore anything outside of this range
			else if (!((c >= 'a' && c <= 'z') ||
				(c >= '0' && c <= '9') ||
				c == '.' || c == '-' || c == '*'))
				continue;
			
			rv.append(c);
		}
		
		return rv.toString();
	}
}

Added modules/tac-runner/src/main/java/net/multiphasicapps/tac/runner/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the TAC runner which is used to search all of the
 * available suites on the system and be able to execute them as such.
 *
 * @since 2018/10/17
 */

package net.multiphasicapps.tac.runner;

Added modules/tac/build.gradle.





















































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project contains the testing, acceptance, "+
	"and comparison framework which is used to test and compare differring " +
	"executions of the virtual machine."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BU"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Testing Framework"
	swmVendor = "Stephanie Gawroriski"
}

// We need to compile a class but not write it to:
// /squirreljme/modules/tac/build/classes/java/main
sourceSets
{
	main
	{
		java
		{
			exclude "org/testng/internal/annotations/DisabledRetryAnalyzer.java"
			exclude "org/testng/annotations/CustomAttribute.java"
			exclude "org/testng/annotations/Test.java"
		}
	}
}

dependencies
{
	// We have some annotations we need the source for, but we do not want
	// these to stay at run-time
	compileOnly "org.testng:testng:7.1.0"

	implementation project(":modules:cldc-compact")
	implementation project(":modules:io")
	implementation project(":modules:meep-midlet")
	implementation project(":modules:tool-manifest-reader")
	implementation project(":modules:tool-manifest-writer")
	implementation project(":modules:collections")
}

jar
{
	// These are excluded because they are not needed by the source and are
	// part of TestNG
	exclude("org/testng/internal/annotations/DisabledRetryAnalyzer.class")
	exclude("org/testng/annotations/CustomAttribute.class")
	exclude("org/testng/annotations/Test.class")
}

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

package net.multiphasicapps.tac;

/**
 * This class contains helpers for data conversion.
 *
 * @since 2019/01/20
 */
public final class DataConversion
{
	/**
	 * Converts the character array to a char array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final char[] arrayCharacterToChar(Character[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		char[] rv = new char[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].charValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a byte array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final byte[] arrayNumberToByte(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		byte[] rv = new byte[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].byteValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a double array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final double[] arrayNumberToDouble(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		double[] rv = new double[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].doubleValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a float array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final float[] arrayNumberToFloat(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		float[] rv = new float[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].floatValue();
		return rv;
	}
	
	/**
	 * Converts the number array to an int array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final int[] arrayNumberToInt(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].intValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a long array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final long[] arrayNumberToLong(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		long[] rv = new long[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].longValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a short array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final short[] arrayNumberToShort(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		short[] rv = new short[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].shortValue();
		return rv;
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/DataDeserialization.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This class contains deserializers for data.
 *
 * @since 2019/01/20
 */
public final class DataDeserialization
{
	/**
	 * Decodes a key for a given secondary value.
	 *
	 * @param __key The key to decode.
	 * @return The decoded key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static final String decodeKey(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// Go through string and decode it
		int n;
		StringBuilder sb = new StringBuilder((n = __key.length()));
		boolean escaped = false;
		for (int i = 0; i < n; i++)
		{
			char c = __key.charAt(i);
			
			// Escaping?
			if (escaped)
			{
				// Determine replacement character
				switch (c)
				{
					case 'p':	c = '+'; break;
					case 'h':	c = '#'; break;
					case 'd':	c = '.'; break;
					case '-':	c = '-'; break;
				}
				sb.append(c);
				
				// Do not escape anymore
				escaped = false;
			}
			
			// Going to escape?
			else if (c == '-')
				escaped = true;
			
			// Pass as is
			else
				sb.append(c);
		}
		
		return sb.toString();
	}
	
	/**
	 * Decodes the given string from a manifest safe format to a string.
	 *
	 * @param __s The string to decode.
	 * @return The decoded string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static final String decodeString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		StringBuilder sb = new StringBuilder(__s.length());
		
		// Decode all input characters
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Ignore whitespace, since this could be an artifact of whitespace
			// used in the manifest
			if (c == ' ' || c == '\r' || c == '\n' || c == '\t')
				continue;
			
			// Escaped sequence requires parsing
			else if (c == '\\')
			{
				// Read the next character
				c = __s.charAt(++i);
				
				// Hex sequence for any character
				if (c == '@')
				{
					// Build string to decode hex sequence from
					StringBuilder sub = new StringBuilder(4);
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					
					// Decode character
					c = (char)(Integer.valueOf(sub.toString(), 16).intValue());
				}
				
				// Code for specific characters
				else
					switch (c)
					{
							// Unchanged
						case '\\':
						case '\"':
							break;
							
							// Space
						case '_':
							c = ' ';
							break;
							
							// Newline
						case 'n':
							c = '\n';
							break;
							
							// Carriage return
						case 'r':
							c = '\r';
							break;
							
							// Tab
						case 't':
							c = '\t';
							break;
							
							// Delete
						case 'd':
							c = (char)0x7F;
							break;
							
							// Open brace
						case '(':
							c = '{';
							break;
							
							// Closing brace
						case ')':
							c = '}';
							break;
						
							// Used to represent all the other upper
							// sequences
						default:
							if (c >= '0' && c <= '9')
								c = (char)(c - '0');
							else if (c >= 'A' && c <= 'Z')
								c = (char)((c - 'A') + 10);
							break;
					}
				
				// Append normalized
				sb.append(c);
			}
			
			// Not escaped
			else
				sb.append(c);
		}
		
		return sb.toString();
	}
	
	/**
	 * Converts the given string to an object.
	 *
	 * @param __s The object to convert.
	 * @return The converted object.
	 * @throws InvalidTestParameterException If the input could not be
	 * converted.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static final Object deserialize(String __s)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Basic conversions
		switch (__s)
		{
			case "null":
				return null;
			
			case "NoResult":
				return new __NoResult__();
			
			case "UndefinedResult":
				return new __UndefinedResult__();
			
			case "ExceptionThrown":
				return new __ExceptionThrown__();
			
			case "NoExceptionThrown":
				return new __NoExceptionThrown__();
			
			case "true":
				return Boolean.TRUE;
			
			case "false":
				return Boolean.FALSE;
			
			default:
				break;
		}
		
		// A string
		if (__s.startsWith("string:"))
			return DataDeserialization.decodeString(__s.substring(7));
		
		// Byte
		else if (__s.startsWith("byte:"))
			return Byte.valueOf(__s.substring(5));
			
		// Short
		else if (__s.startsWith("short:"))
			return Short.valueOf(__s.substring(6));
			
		// Char
		else if (__s.startsWith("char:"))
			return Character.valueOf(
				(char)Integer.valueOf(__s.substring(5)).intValue());
		
		// Integer
		else if (__s.startsWith("int:"))
			return Integer.valueOf(__s.substring(4));
		
		// Long
		else if (__s.startsWith("long:"))
			return Long.valueOf(__s.substring(5));
		
		// {@squirreljme.error BU01 The specified string cannot be converted
		// to an object because it an unknown representation, the conversion
		// is only one way. (The encoded data)}
		else if (__s.startsWith("other:"))
			throw new InvalidTestParameterException(
				String.format("BU01 %s", __s));
		
		// {@squirreljme.error BU02 The specified object cannot be
		// decoded because it is not known or does not support decoding.
		// (The encoded data)}
		else
			throw new InvalidTestParameterException(
				String.format("BU02 %s", __s));
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/DataSerialization.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This class contains serializers of data.
 *
 * @since 2019/01/20
 */
public final class DataSerialization
{
	/**
	 * Encodes key value.
	 *
	 * @param __key The key to encode.
	 * @return The resulting key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static final String encodeKey(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
			
		// Encode the key to allow for valid characters
		int n;
		StringBuilder sb = new StringBuilder((n = __key.length()));
		for (int i = 0; i < n; i++)
		{
			char c = __key.charAt(i);
			
			// Possibly re-encoded?
			boolean enc = false;
			if (c >= 'A' && c <= 'Z')
				c = Character.toLowerCase(c);
			
			// Re-encode?
			char redo = 0;
			switch (c)
			{
				case '+':	redo = 'p'; break;
				case '#':	redo = 'h'; break;
				case '.':	redo = 'd'; break;
				case '-':	redo = '-'; break;
			}
			
			// Was this value being re-encoded?
			if (redo != 0)
			{
				sb.append('-');
				sb.append(redo);
			}
			else
				sb.append(c);
		}
		
		// Use the encoded key
		return sb.toString();
	}
	
	/**
	 * Encodes the given string to a manifest safe format.
	 *
	 * @param __s The string to encode.
	 * @return The encoded string, {@code null} has a special value.
	 * @since 2018/10/06
	 */
	public static final String encodeString(String __s)
	{
		// Special value for null strings
		if (__s == null)
			return "\\NULL";
		
		// Encode characters to normalize them
		StringBuilder sb = new StringBuilder(__s.length());
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Is the character to be translated?
			boolean escape = false;
			switch (c)
			{
					// Just escape these
				case '\\':
				case '"':
					escape = true;
					break;
					
					// Make spaces just in the form of an underline to make
					// them more spacey but easier to see
				case ' ':
					escape = true;
					c = '_';
					break;
					
					// Newline
				case '\n':
					escape = true;
					c = 'n';
					break;
					
					// Carriage return
				case '\r':
					escape = true;
					c = 'r';
					break;
					
					// Tab
				case '\t':
					escape = true;
					c = 't';
					break;
					
					// Opening brace
				case '{':
					escape = true;
					c = '(';
					break;
					
					// Closing brace
				case '}':
					escape = true;
					c = ')';
					break;
					
					// Delete
				case 0x7F:
					escape = true;
					c = 'd';
					break;
				
				case 0x00:
				case 0x01:
				case 0x02:
				case 0x03:
				case 0x04:
				case 0x05:
				case 0x06:
				case 0x07:
				case 0x08:
				case 0x0b:
				case 0x0c:
				case 0x0e:
				case 0x1f:
				case 0x10:
				case 0x11:
				case 0x12:
				case 0x13:
				case 0x14:
				case 0x15:
				case 0x16:
				case 0x17:
				case 0x18:
				case 0x19:
				case 0x1a:
				case 0x1b:
				case 0x1c:
				case 0x1d:
				case 0x1e:
					escape = true;
					c = (char)((c < 10 ? '0' + c : 'A' + (c - 10)));
					break;
				
					// Not changed
				default:
					break;
			}
			
			// Character is out of range?
			if (c >= 0x7F)
				sb.append(String.format("\\@%04x", (int)c));
			
			// Append printable
			else
			{
				if (escape)
					sb.append('\\');
				sb.append(c);
			}
		}
		
		return sb.toString();
	}
	
	/**
	 * Serialize the given object to a string.
	 *
	 * @param __o The value to serialize.
	 * @return The resulting serialization.
	 * @since 2019/01/20
	 */
	public static final String serialize(Object __o)
	{
		// Null
		if (__o == null)
			return "null";
		
		// No result generated
		else if (__o instanceof __NoResult__)
			return "NoResult";
		
		// Undefined
		else if (__o instanceof __UndefinedResult__)
			return "UndefinedResult";
		
		// Exception was thrown
		else if (__o instanceof __ExceptionThrown__)
			return "ExceptionThrown";
		
		// No exception was thrown
		else if (__o instanceof __NoExceptionThrown__)
			return "NoExceptionThrown";
		
		// Boolean values
		else if (__o instanceof Boolean)
			return __o.toString();
		
		// String
		else if (__o instanceof String)
			return "string:" + DataSerialization.encodeString((String)__o);
		
		// Byte
		else if (__o instanceof Byte)
			return "byte:" + __o;
		
		// Short
		else if (__o instanceof Short)
			return "short:" + __o;
		
		// Character
		else if (__o instanceof Character)
			return "char:" + (int)((Character)__o).charValue();
		
		// Integer
		else if (__o instanceof Integer)
			return "int:" + __o;
		
		// Long
		else if (__o instanceof Long)
			return "long:" + __o;
		
		// Byte array
		else if ((__o instanceof byte[]) || __o instanceof Byte[])
		{
			// Convert first
			if (__o instanceof Byte[])
			{
				Byte[] a = (Byte[])__o;
				int n = a.length;
				byte[] b = new byte[n];
				for (int i = 0; i < n; i++)
				{
					Byte v = a[i];
					b[i] = (v == null ? 0 : v.byteValue());
				}
				__o = b;
			}
			
			// Print values
			byte[] a = (byte[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("byte[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// Short array
		else if ((__o instanceof short[]) || __o instanceof Short[])
		{
			// Convert first
			if (__o instanceof Short[])
			{
				Short[] a = (Short[])__o;
				int n = a.length;
				short[] b = new short[n];
				for (int i = 0; i < n; i++)
				{
					Short v = a[i];
					b[i] = (v == null ? 0 : v.shortValue());
				}
				__o = b;
			}
			
			// Print values
			short[] a = (short[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("short[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// Character array
		else if ((__o instanceof char[]) || __o instanceof Character[])
		{
			// Convert first
			if (__o instanceof Character[])
			{
				Character[] a = (Character[])__o;
				int n = a.length;
				char[] b = new char[n];
				for (int i = 0; i < n; i++)
				{
					Character v = a[i];
					b[i] = (v == null ? 0 : v.charValue());
				}
				__o = b;
			}
			
			// Print values
			char[] a = (char[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("char[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append((int)a[i]);
			}
			return sb.toString();
		}
		
		// Integer array
		else if ((__o instanceof int[]) || __o instanceof Integer[])
		{
			// Convert first
			if (__o instanceof Integer[])
			{
				Integer[] a = (Integer[])__o;
				int n = a.length;
				int[] b = new int[n];
				for (int i = 0; i < n; i++)
				{
					Integer v = a[i];
					b[i] = (v == null ? 0 : v.intValue());
				}
				__o = b;
			}
			
			// Print values
			int[] a = (int[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("int[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// String array
		else if (__o instanceof String[])
		{
			// Print values
			String[] a = (String[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("string[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(DataSerialization.encodeString(a[i]));
			}
			return sb.toString();
		}
		
		// Throwable, meta data is used
		else if (__o instanceof Throwable)
		{
			Throwable t = (Throwable)__o;
			
			StringBuilder sb = new StringBuilder("throwable:");
			
			// The last package to shorten the classes
			String lastpkg = "java.lang.";
			
			// Throwables may be of multiple class types and it usually is
			// expected that they are some base class. For example a class
			// can thrown some FooIndexOutOfBoundsException which is based
			// off IndexOutOfBoundsException, if the result expects the
			// base class then it must still pass. So store the entire class
			// tree.
			boolean comma = false;
			for (Class<?> x = t.getClass(); x != null && x != Object.class;
				x = x.getSuperclass())
			{
				// Clip off the package if it matches
				String clname = x.getName();
				if (clname.startsWith(lastpkg))
					clname = clname.substring(lastpkg.length());
				
				// Otherwise remember the package used
				else
				{
					int ld = clname.lastIndexOf('.');
					if (ld >= 0)
						lastpkg = clname.substring(0, ld + 1);
					
					// Maybe default package?
					else
						lastpkg = "";
				}
				
				// Split to encode multiple classes
				if (comma)
					sb.append(',');
				comma = true;
				
				// Append class name here
				sb.append(clname);
			}
			
			// For debug purposes, encode the message information
			String msg = t.getMessage();
			if (msg != null)
			{
				sb.append(':');
				sb.append(DataSerialization.encodeString(msg));
			}
			
			// Now metadata is included for this
			return sb.toString();
		}
		
		// Unrepresented object, just use its string representation in an
		// encoded form
		else
			return "other:" + __o.getClass().getName() + ":" +
				DataSerialization.encodeString(__o.toString());
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/DeadlockTimeout.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a thread which.
 *
 * @since 2019/05/09
 */
public final class DeadlockTimeout
	extends Thread
{
	/** Default deadlock time in milliseconds. */
	public static final int DEFAULT_TIMEOUT =
		30_000;
	
	/** The timeout time. */
	protected final long timeoutnano;
	
	/** Has this execution expired? */
	private volatile boolean _expired;
	
	/**
	 * Initializes a timeout thread.
	 *
	 * @since 2019/05/09
	 */
	public DeadlockTimeout()
	{
		this(DeadlockTimeout.DEFAULT_TIMEOUT);
	}
	
	/**
	 * Initializes a timeout thread for the given duration.
	 *
	 * @param __ms The timeout in milliseconds.
	 * @since 2019/05/09
	 */
	public DeadlockTimeout(int __ms)
	{
		super("TestDeadlockTimeout");
		
		__ms = (__ms <= 0 ? DeadlockTimeout.DEFAULT_TIMEOUT : __ms);
		
		this.timeoutnano = System.nanoTime() + (__ms * 1000000L);
	}
	
	/**
	 * Expires this timeout watch.
	 *
	 * @since 2019/05/09
	 */
	public final void expire()
	{
		// Set as expired
		this._expired = true;
		
		// Also interrupt the thread so it resumes
		this.interrupt();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void run()
	{
		// When does this time out?
		long timeoutnano = this.timeoutnano;
		
		// Expiration check loop
		for (;;)
		{
			// Watchdog has expired
			if (this._expired)
				break;
			
			// Has timed out?
			long now = System.nanoTime();
			if (now >= timeoutnano)
			{
				// Print a nasty message
				System.err.println("*** TEST TIMED OUT! ***");
				
				// Exit
				System.exit(-4);
				break;
			}
			
			// Sleep to wait for it
			try
			{
				// Calculate duration
				int durms = (int)((timeoutnano - now) / 1000000L);
				if (durms < 1)
					durms = 1;
				
				// Sleep
				Thread.sleep(durms);
			}
			
			// Ignore any interruptions, just re-run the loop
			catch (InterruptedException e)
			{
			}
		}
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is thrown when a test is not valid.
 *
 * @since 2018/10/06
 */
public class InvalidTestException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is thrown when the parameter of a test is not correct.
 *
 * @since 2018/10/06
 */
public class InvalidTestParameterException
	extends InvalidTestException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is thrown when the result of a test is not valid.
 *
 * @since 2018/10/06
 */
public class InvalidTestResultException
	extends InvalidTestException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestResultException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is a test which takes two parameters and produces no result.
 *
 * @param <A> The first argument type.
 * @param <B> The second argument type.
 * @since 2018/10/06
 */
public abstract class TestBiConsumer<A, B>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @param __b The second parameter.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test(A __a, B __b)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU03 Test takes two parameters.}
		if (__args.length != 2)
			throw new InvalidTestParameterException("BU03");
		
		// Run the test
		this.test((A)__args[0], (B)__args[1]);
		
		// No result is generated
		return new __NoResult__();
	}
}

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

package net.multiphasicapps.tac;

/**
 * This represents a test which takes two parameters and returns a result.
 *
 * @param <A> The first parameter type.
 * @param <B> The second parameter type.
 * @param <R> The result type.
 * @since 2018/10/06
 */
public abstract class TestBiFunction<A, B, R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @param __b The second parameter.
	 * @return The result
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test(A __a, B __b)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU04 Test takes two parameters.}
		if (__args.length != 2)
			throw new InvalidTestParameterException("BU04");
		
		// Run the test
		return this.test((A)__args[0], (B)__args[1]);
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestBoolean.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns a boolean.
 *
 * @since 2019/12/25
 */
public abstract class TestBoolean
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/25
	 */
	public abstract boolean test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0f Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0e");
		
		// Run the test
		return Boolean.valueOf(this.test());
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is a test which takes a single parameter and has no result.
 *
 * @param <A> The first argument type.
 * @since 2018/10/06
 */
public abstract class TestConsumer<A>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test(A __a)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU05 Test takes one parameter.}
		if (__args.length != 1)
			throw new InvalidTestParameterException("BU05");
		
		// Run the test
		this.test((A)__args[0]);
		
		// No result is generated
		return new __NoResult__();
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestExecution.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package net.multiphasicapps.tac;

import java.io.PrintStream;

/**
 * This represents the expected and resultant results of a test.
 *
 * @since 2020/02/23
 */
public final class TestExecution
{
	/** The status of the test. */
	public final TestStatus status;
	
	/** The class being tested. */
	public final Class<?> testClass;
	
	/** The result of the test. */
	public final TestResult result;
	
	/** The expected results of the test. */
	public final TestResult expected;
	
	/** The exception tossed, if there is one. */
	public final Object tossed;
	
	/**
	 * Initializes the test execution.
	 *
	 * @param __ts The test status.
	 * @param __tc The test class.
	 * @param __res The results of the test.
	 * @param __exp The expected results.
	 * @param __tossed Any exception that was tossed.
	 * @since 2020/02/23
	 */
	public TestExecution(TestStatus __ts, Class<?> __tc,
		TestResult __res, TestResult __exp, Object __tossed)
	{
		this.status = __ts;
		this.testClass = __tc;
		this.result = __res;
		this.expected = __exp;
		this.tossed = __tossed;
	}
	
	/**
	 * Prints the execution results.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/02/26
	 */
	public final void print(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
			
		switch (this.status)
		{
				// Test passed
			case SUCCESS:
				__ps.printf("%s: PASS %s%n",
					this.testClass, this.result);
				break;
			
				// Failed test, print results
			case FAILED:
				// Failure notice
				__ps.printf("%s: FAIL %s%n",
					this.testClass, this.result);
				
				// Print comparison to show what failed
				this.expected.printComparison(System.err,
					this.result);
				break;
			
			case TEST_EXCEPTION:
				// {@squirreljme.error BU0d The test failed to run properly.
				// (The given test)}
				__ps.printf("BU0d %s%n", this.testClass);
				break;
			
			case UNTESTABLE:
				// {@squirreljme.error BU0c Test could not be ran
				// potentially because a condition was not met. (Test class)}
				__ps.printf("BU0c %s%n", this.testClass);
				break;
		}
		
		// Print traces of unexpected exceptions
		if (this.status != TestStatus.FAILED &&
			this.tossed instanceof Throwable)
			((Throwable)this.tossed).printStackTrace(__ps);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/26
	 */
	@Override
	public final String toString()
	{
		StringBuilder sb = new StringBuilder();
		
		sb.append("{");
		
		sb.append("status=");
		sb.append(this.status);
		
		sb.append(", testClass=");
		sb.append(this.testClass.getName());
		
		sb.append(", result=");
		sb.append(this.result.toString());
		
		sb.append(", expected=");
		sb.append(this.expected.toString());
		
		Object tossed = this.tossed;
		if (tossed != null)
		{
			sb.append(", tossed=");
			sb.append(tossed.toString());
		}
		
		sb.append("}");
		
		return sb.toString();
	}
}

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

package net.multiphasicapps.tac;

/**
 * This represents a test which takes one parameter and returns a result.
 *
 * @param <A> The first parameter type.
 * @param <R> The result type.
 * @since 2018/10/06
 */
public abstract class TestFunction<A, R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test(A __a)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU06 Test takes one parameter.}
		if (__args.length != 1)
			throw new InvalidTestParameterException("BU06");
		
		// Run the test
		return this.test((A)__args[0]);
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestInteger.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns an integer.
 *
 * @since 2019/12/24
 */
public abstract class TestInteger
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/24
	 */
	public abstract int test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0e Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0e");
		
		// Run the test
		return Integer.valueOf(this.test());
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestInterface.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package net.multiphasicapps.tac;

import org.testng.annotations.Test;

/**
 * This is an interface for anything which is something that can be tested
 * within the SquirrelJME test framework.
 *
 * @since 2020/02/23
 */
public interface TestInterface
	extends Runnable
{
	/**
	 * {@inheritDoc}
	 * @since 2020/02/26
	 */
	@Override
	@Test
	void run();
	
	/**
	 * Runs the test.
	 *
	 * @param __mainargs Arguments to the test.
	 * @return The execution result of the test.
	 * @since 2020/02/23
	 */
	TestExecution runExecution(String... __mainargs);
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestLong.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns a long.
 *
 * @since 2019/12/24
 */
public abstract class TestLong
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/24
	 */
	public abstract long test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0A Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0A");
		
		// Run the test
		return Long.valueOf(this.test());
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestResult.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;

/**
 * This class contains an immutable result of the test.
 *
 * @since 2019/05/08
 */
public final class TestResult
{
	/** Return value result. */
	protected final String rvalue;
	
	/** Thrown value, if any. */
	protected final String tvalue;
	
	/** Secondary values. */
	private final Map<String, String> _secondary;
	
	/** Hashcode. */
	private int _hash;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the test result.
	 *
	 * @param __rv Return value.
	 * @param __tv Thrown value, if any.
	 * @param __sec Secondary values.
	 * @throws NullPointerException On null arguments or if any secondary
	 * contains a null value.
	 * @since 2019/05/09
	 */
	public TestResult(String __rv, String __tv, Map<String, String> __sec)
		throws NullPointerException
	{
		if (__rv == null || __tv == null || __sec == null)
			throw new NullPointerException("NARG");
		
		// These are simple
		this.rvalue = __rv;
		this.tvalue = __tv;
		
		// Copy map values over
		Map<String, String> to = new SortedTreeMap<>();
		for (Map.Entry<String, String> e : __sec.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			to.put(k, v);
		}
		
		// Just can use a linked map
		this._secondary = new LinkedHashMap<>(to);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof TestResult))
			return false;
		
		TestResult o = (TestResult)__o;
		return this.rvalue.equals(o.rvalue) &&
			this.tvalue.equals(o.tvalue) &&
			this._secondary.equals(o._secondary);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.rvalue.hashCode() ^
				this.tvalue.hashCode() ^ this._secondary.hashCode());
		return rv;
	}
	
	/**
	 * Checks if this result is satisfied by the other result, note that this
	 * is not the same as equality just a result for a test.
	 *
	 * @param __o The other result.
	 * @return If it is satisfied by it.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/03/01
	 */
	public final boolean isSatisfiedBy(TestResult __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Use test comparison (note is expected and actual)
		return TestResult.valueEquals(__o.rvalue, this.rvalue) &&
			TestResult.valueEquals(__o.tvalue, this.tvalue) &&
			TestResult.__equals(__o._secondary, this._secondary);
	}
	
	/**
	 * Prints the comparison of this result and the other result.
	 *
	 * @param __ps The stream to write to.
	 * @param __o The result to compare against.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void printComparison(PrintStream __ps, TestResult __o)
		throws NullPointerException
	{
		if (__o == null || __ps == null)
			throw new NullPointerException("NARG");
		
		// Return value
		TestResult.__printSingleCompare(__ps, "return",
			this.rvalue, __o.rvalue);
		
		// Thrown exception
		TestResult.__printSingleCompare(__ps, "thrown",
			this.tvalue, __o.tvalue);
		
		// Secondary value comparison, more complex since both maps might not
		// contain the same values
		Map<String, String> as = this._secondary,
			bs = __o._secondary;
		
		// Create merged key set so that all keys from both maps are used
		Set<String> merged = new SortedTreeSet<>();
		merged.addAll(as.keySet());
		merged.addAll(bs.keySet());
		
		// Do comparisons on all values
		for (String k : merged)
			TestResult.__printSingleCompare(__ps, k,
				as.get(k), bs.get(k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			
			// Return value
			sb.append("{rv=");
			sb.append(this.rvalue);
			
			// Thrown values
			sb.append(", tv=");
			sb.append(this.tvalue);
			
			// Only add secondaries if they exist
			Map<String, String> secondary = this._secondary;
			if (!secondary.isEmpty())
			{
				sb.append(", sv=");
				sb.append(secondary);
			}
			
			// Done
			sb.append('}');
			
			// Build and cache
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Writes the test result as a manifest in SquirrelJME's test format.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	public final void writeAsManifest(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Setup manifest
		MutableJavaManifest man = new MutableJavaManifest();
		MutableJavaManifestAttributes attr = man.getMainAttributes();
		
		// Add values to it
		attr.putValue("result", this.rvalue);
		attr.putValue("thrown", this.tvalue);
		for (Map.Entry<String, String> e : this._secondary.entrySet())
			attr.putValue(
				"secondary-" + DataSerialization.encodeKey(e.getKey()),
				e.getValue());
		
		// Write it
		man.write(__os);
	}
	
	/**
	 * Loads test results for the specified class.
	 *
	 * @param __cl The results to load.
	 * @return The results of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	public static final TestResult loadForClass(Class<?> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// We are going to recursively go up the class chain and load values
		// from the manifest into our result
		TestResultBuilder rv = new TestResultBuilder();
		for (Class<?> at = __cl; at != null; at = at.getSuperclass())
		{
			// Determine base name of the class
			String atname = at.getName();
			int ld = atname.lastIndexOf('.');
			String atbase = (ld < 0 ? atname : atname.substring(ld + 1));
			
			// Parse and handle manifest
			JavaManifest man;
			try (InputStream in = at.getResourceAsStream(atbase + ".in"))
			{
				// No manifest here, ignore
				if (in == null)
					continue;
				
				// Parse
				man = new JavaManifest(in);
			}
			
			// Ignore
			catch (IOException e)
			{
				continue;
			}
			
			// Work with attributes and decode them
			JavaManifestAttributes attr = man.getMainAttributes();
			for (Map.Entry<JavaManifestKey, String> e : attr.entrySet())
			{
				String ekey = e.getKey().toString().toLowerCase(),
					eval = e.getValue();
				
				// Depends on the encoded key
				switch (ekey)
				{
						// Returned value
					case "result":
						if (rv.getReturn() == null)
							rv.setReturnEncoded(eval);
						break;
					
						// Thrown value
					case "thrown":
						if (rv.getThrown() == null)
							rv.setThrownEncoded(eval);
						break;
						
						// Possibly handle secondary values
					default:
						if (ekey.startsWith("secondary-"))
						{
							String skey = DataDeserialization.decodeKey(
								ekey.substring(10));
							
							if (rv.getSecondary(skey) == null)
								rv.putSecondaryEncoded(skey, eval);
						}
						break;
				}
			}
		}
		
		// Done
		return rv.build();
	}
	
	/**
	 * Decodes a list of throwable and returns them.
	 *
	 * @param __ts The throwables to decode.
	 * @return The list of used throwables.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09 
	 */
	public static final List<String> throwableList(String __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BU07 Not a throwable.}
		if (!__ts.startsWith("throwable:"))
			throw new IllegalArgumentException("BU07");
		__ts = __ts.substring(10);
		
		// Snip off the optional debug message
		int lm = __ts.indexOf(':');
		if (lm >= 0)
			__ts = __ts.substring(0, lm);
		
		// Snip into string list, note that java.lang is initially implicit
		// and remaining values use a shortened form
		List<String> rv = new ArrayList<>();
		String baseform = "java.lang";
		for (int i = 0, n = __ts.length(); i < n;)
		{
			// Find split or where this ends
			int lc = __ts.indexOf(',', i);
			if (lc < 0)
				lc = n;
			
			// Snip this part out
			String sub = __ts.substring(i, lc);
			
			// Change of base?
			int ld = sub.lastIndexOf('.');
			if (ld >= 0)
			{
				baseform = sub.substring(0, ld);
				sub = sub.substring(ld + 1);
			}
			
			// Add full form
			rv.add(baseform + "." + sub);
			
			// Process next split
			i = lc + 1;
		}
		
		return rv;
	}
	
	/**
	 * Compares two value strings against each other.
	 *
	 * @param __act The actual value.
	 * @param __exp The expected value.
	 * @return If the strings are a match.
	 * @throws InvalidTestParameterException If a throwable is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static boolean valueEquals(String __act, String __exp)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__act == null || __exp == null)
			throw new NullPointerException("NARG");
		
		// Throwables are special cases since they represent multiple classes
		if (__act.startsWith("throwable:") && __exp.startsWith("throwable:"))
		{
			// Get all elements for both
			List<String> la = TestResult.throwableList(__act),
				lb = TestResult.throwableList(__exp);
			
			todo.DEBUG.note("%s ~~= %s", la, lb);
			
			// These are considered equal if they have anything in common
			la.retainAll(lb);
			return !la.isEmpty();
		}
		
		// Comparing against fudged long value (which is a plus or minus value)
		else if (__act.startsWith("long:") && __exp.startsWith("long-fudge:"))
		{
			// Parse actual value
			long act = Long.parseLong(__act.substring("long:".length()));
			
			// The expected value has a fudge
			int xfc = __exp.indexOf(':');
			int xlc = __exp.lastIndexOf(':');
			if (xlc == xfc)
				xlc = -1;
			
			// Parse values
			long exp = Long.parseLong(__exp.substring(xfc + 1,
				(xlc > 0 ? xlc : __exp.length())));
			long fudge = Math.abs((xlc > 0 ?
				Long.parseLong(__exp.substring(xlc + 1)) : 0));
			
			// Matches as long as we are within the fudge range
			return act == exp || (act >= (exp - fudge) && act <= (exp + fudge));
		}
		
		// Use normal string comparison
		return __exp.equals(__act);
	}
	
	/**
	 * Compares the map of strings to see that they are equal.
	 *
	 * @param __act The actual values.
	 * @param __exp The expected values.
	 * @return If the maps are a match.
	 * @throws InvalidTestParameterException If a throwable is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	private static boolean __equals(Map<String, String> __act,
		Map<String, String> __exp)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__act == null || __exp == null)
			throw new NullPointerException("NARG");
		
		// Compare from the first map
		for (Map.Entry<String, String> a : __act.entrySet())
		{
			String key = a.getKey();
			
			// Second is missing key
			if (!__exp.containsKey(key))
				return false;
			
			// Match value
			if (!TestResult.valueEquals(a.getValue(), __exp.get(key)))
				return false;
		}
		
		// Just scan through the keys in the second map, if any keys are
		// missing then extra keys were added
		for (String k : __exp.keySet())
			if (!__act.containsKey(k))
				return false;
		
		// Is a match
		return true;
	}
	
	/**
	 * Prints single comparison.
	 *
	 * @param __ps The stream to print to.
	 * @param __key The key being printed.
	 * @param __a The first value.
	 * @param __b The second value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	private static final void __printSingleCompare(PrintStream __ps,
		String __key, String __a, String __b)
		throws NullPointerException
	{
		if (__ps == null || __key == null)
			throw new NullPointerException("NARG");
		
		// Not the same?
		boolean equals;
		if (__a == null || __b == null)
			equals = Objects.equals(__a, __b);
		
		// Compare values otherwise
		else
			equals = TestResult.valueEquals(__a, __b);
		
		// Do not print null as is because it can be confused for actual null
		// values
		if (__a == null)
			__a = "-???-";
		if (__b == null)
			__b = "-???-";
		
		// Print out
		__ps.printf("\t%-15s %c %s %s%n", __key, (equals ? '=' : '!'),
			__a, __b);
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/TestResultBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.tac;

import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This is used to build {@link TestResult} and is used by the code which
 * loads expected results and builds results.
 *
 * @since 2019/05/08
 */
public final class TestResultBuilder
{
	/** Secondary test values. */
	private final Map<String, String> _secondary =
		new SortedTreeMap<>();
	
	/** Returned value. */
	private volatile String _rvalue;
	
	/** Thrown value. */
	private volatile String _tvalue;
	
	/**
	 * Builds the actual test result.
	 *
	 * @return The test result.
	 * @since 2019/05/09
	 */
	public final TestResult build()
	{
		// Lock
		synchronized (this)
		{
			// Fallback return value
			String rvalue = this._rvalue;
			if (rvalue == null)
				rvalue = "ResultWasNotSpecified";
				
			// Fallback throw value
			String tvalue = this._tvalue;
			if (tvalue == null)
				tvalue = "ExceptionWasNotSpecified";
			
			// Build result
			return new TestResult(rvalue, tvalue, this._secondary);
		}
	}
	
	/**
	 * Gets the return value.
	 *
	 * @return The return value.
	 * @since 2019/05/09
	 */
	public final String getReturn()
	{
		synchronized (this)
		{
			return this._rvalue;
		}
	}
	
	/**
	 * Returns the secondary value.
	 *
	 * @param __key The key to get.
	 * @return The value of the secondary or {@code null} if it was not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final String getSecondary(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			return this._secondary.get(__key.toLowerCase());
		}
	}
	
	/**
	 * Gets the exception value.
	 *
	 * @return The exception value.
	 * @since 2019/05/09
	 */
	public final String getThrown()
	{
		synchronized (this)
		{
			return this._tvalue;
		}
	}
	
	/**
	 * Stores a secondary test value which has already been encoded.
	 *
	 * @param __key The test key.
	 * @param __val The test value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void putSecondaryEncoded(String __key, String __val)
		throws NullPointerException
	{
		if (__key == null || __val == null)
			throw new NullPointerException("NARG");
		
		// Make it thread safe
		Map<String, String> secondary = this._secondary;
		synchronized (this)
		{
			// Use formatted values
			secondary.put(__key.toLowerCase(), __val);
			
			// Debug
			todo.DEBUG.note("%s=%s", __key, __val);
		}
	}
	
	/**
	 * Adds a secondary test value which is a result of something, the value
	 * is always encoded to a string form.
	 *
	 * @param __key The test key.
	 * @param __val The test value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void putSecondaryValue(String __key, Object __val)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// Encode the values
		this.putSecondaryEncoded(__key, DataSerialization.serialize(__val));
	}
	
	/**
	 * Sets the encoded return value.
	 *
	 * @param __val The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void setReturnEncoded(String __val)
		throws NullPointerException
	{
		if (__val == null)
			throw new NullPointerException("NARG");
		
		// Thread safe!
		synchronized (this)
		{
			this._rvalue = __val;
		}
	}
	
	/**
	 * Sets the return value.
	 *
	 * @param __val The value to use.
	 * @since 2019/05/09
	 */
	public final void setReturnValue(Object __val)
	{
		this.setReturnEncoded(DataSerialization.serialize(__val));
	}
	
	/**
	 * Sets the encoded thrown value.
	 *
	 * @param __val The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void setThrownEncoded(String __val)
		throws NullPointerException
	{
		if (__val == null)
			throw new NullPointerException("NARG");
		
		// Thread safe!
		synchronized (this)
		{
			this._tvalue = __val;
		}
	}
	
	/**
	 * Sets the thrown value.
	 *
	 * @param __val The value to use.
	 * @since 2019/05/09
	 */
	public final void setThrownValue(Object __val)
	{
		this.setThrownEncoded(DataSerialization.serialize(__val));
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is a test which has no input and produces no output, it just runs.
 *
 * @since 2018/10/06
 */
public abstract class TestRunnable
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU08 Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU08");
		
		// Run the test
		this.test();
		
		// No result is generated
		return new __NoResult__();
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is that status of a test.
 *
 * @since 2018/10/07
 */
public enum TestStatus
{
	/** Success. */
	SUCCESS,
	
	/** Failed. */
	FAILED,
	
	/** Failed due to test exception. */
	TEST_EXCEPTION,
	
	/** Test was not run yet. */
	NOT_RUN,
	
	/** Untestable. */
	UNTESTABLE,
	
	/** End. */
	;
}

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

package net.multiphasicapps.tac;

/**
 * This is a test which returns a result and has no parameters.
 *
 * @param <R> The return type.
 * @since 2018/10/06
 */
public abstract class TestSupplier<R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU09 Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU09");
		
		// Run the test
		return this.test();
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/ThrownTestExecution.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package net.multiphasicapps.tac;

/**
 * This is used to throw the test execution.
 *
 * @since 2020/02/26
 */
public class ThrownTestExecution
	extends RuntimeException
{
	/** The tossed execution. */
	public final TestExecution execution;
	
	/**
	 * Initializes the exception.
	 *
	 * @param __exec The execution to trace.
	 * @param __cause The cause of it.
	 * @since 2020/02/26
	 */
	public ThrownTestExecution(TestExecution __exec, Throwable __cause)
	{
		super((__exec == null ? "NULL" : __exec.toString()), __cause);
		
		this.execution = __exec;
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/UntestableException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is thrown when the test cannot be ran perhaps due to lack of support
 * or otherwise a virtual machine which does not support things.
 *
 * @since 2019/03/04
 */
public class UntestableException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/03/04
	 */
	public UntestableException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/03/04
	 */
	public UntestableException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/03/04
	 */
	public UntestableException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/03/04
	 */
	public UntestableException(Throwable __c)
	{
		super(__c);
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/__CoreTest__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.midlet.OverrideActiveMidletRestriction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.midlet.MIDlet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import org.testng.annotations.Test;

/**
 * This is the core test framework which handles reading test information and
 * parameters, it forwards internally to other classes which handle
 * parameters and such.
 *
 * @since 2018/10/06
 */
abstract class __CoreTest__
	extends MIDlet
	implements OverrideActiveMidletRestriction, TestInterface
{
	/** {@squirreljme.property test.dump=bool Dump test result manifests?} */
	public static final String DUMP_ACTUAL =
		"test.dump";
	
	/** Final result of the test, used during the test. */
	final TestResultBuilder _runresult =
		new TestResultBuilder();
	
	/** The status of the test. */
	volatile TestStatus _status =
		TestStatus.NOT_RUN;
	
	/**
	 * Runs the given test with the given arguments and resulting in the
	 * given result.
	 *
	 * @param __args The arguments to the test.
	 * @return The result of the test.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	abstract Object __runTest(Object... __args)
		throws Throwable;
	
	/**
	 * Tests the minimum API level.
	 *
	 * @param __lv The level to test.
	 * @throws InvalidTestException If the API level is not met.
	 * @since 2019/03/14
	 */
	@Deprecated
	public final void checkApiLevel(int __lv)
		throws InvalidTestException
	{
		// {@squirreljme.error BU0b Minimum API level has not been met.
		// (The required API level)}
		if (!ApiLevel.minimumLevel(__lv))
			throw new InvalidTestException(String.format("BU0b %x", __lv));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	protected final void destroyApp(boolean __u)
	{
		// Not used
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/23
	 */
	@Override
	@Test
	public final void run()
	{
		// Run our execution with the default arguments!
		TestExecution execution = this.runExecution();
		
		// Always print the result
		execution.print(System.err);
		
		// If the test did not pass, throw an exception
		if (execution.status != TestStatus.SUCCESS)
		{
			// If skippable, try throwing a TestNG skip exception if it exists
			if (execution.status == TestStatus.UNTESTABLE)
				try
				{
					Class<?> skippy = Class.forName(
						"org.testng.SkipException");
					
					// Create instance
					Object instance = skippy.newInstance();
					
					// If it is throwable, we throw it!
					if (instance instanceof RuntimeException)
					{
						RuntimeException re = (RuntimeException)instance;
						
						// So this way our information is not completely gone
						re.initCause(new ThrownTestExecution(
							execution, null));
						
						throw re;
					}
				}
				catch (ClassNotFoundException|InstantiationException|
					IllegalAccessException e)
				{
					// Ignore, treat as failure
				}
			
			Object tossed = execution.tossed;
			throw new ThrownTestExecution(execution,
				((tossed instanceof Throwable) ? (Throwable)tossed : null));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/23
	 */
	@SuppressWarnings("FeatureEnvy")
	@Override
	public final TestExecution runExecution(String... __mainargs)
	{
		// Use to name this test
		Class<?> self = this.getClass();
		String classname = self.getName();
		
		// Decode the expected result
		TestResult expected = TestResult.loadForClass(self);
		
		// Read the inputs for the test
		Object[] args = this.__parseInput(self, __mainargs);
		
		// This is the result of the test
		TestResultBuilder runresult = this._runresult;
		
		// Our test result
		TestStatus status = null;
		
		// Run the test, catch any exception to report it
		Object thrown = null;
		try
		{
			// Run the test
			runresult.setReturnValue(this.__runTest(args));
			runresult.setThrownValue((thrown = new __NoExceptionThrown__()));
		}
		
		// Cannot be tested
		catch (UntestableException e)
		{
			// Cannot be tested so it shall fail
			status = TestStatus.UNTESTABLE;
			thrown = e;
		}
		
		// Test failure
		catch (Throwable t)
		{
			// Errors are bad, stop testing and just fail here
			if (t instanceof Error)
				throw (Error)t;
			
			// The test parameter is not valid, so whoops!
			if (t instanceof InvalidTestException)
			{
				// Exception was thrown
				status = TestStatus.TEST_EXCEPTION;
				thrown = t;
			}
			
			// Normal test which threw a possibly valid exception
			else
			{
				runresult.setReturnValue(new __ExceptionThrown__());
				runresult.setThrownValue((thrown = t));
			}
		}
		
		// If the status is not yet known, do a comparison with the results to
		// see if there is a match
		TestResult result = runresult.build();
		if (status == null)
			status = (expected.isSatisfiedBy(result) ? TestStatus.SUCCESS :
				TestStatus.FAILED);
		
		// Store the status of the test that just ran
		this._status = status;
		
		// Return the result
		return new TestExecution(status, self, expected, result, thrown);
	}
	
	/**
	 * Runs the specified test using the given main arguments as if it
	 * were a program to be run, if any.
	 *
	 * This method will handle dead-locks and otherwise.
	 *
	 * @param __mainargs The main arguments to the test which allow parameters
	 * to be used accordingly.
	 * @since 2018/10/06
	 */
	public final void runTest(String... __mainargs)
	{
		if (__mainargs == null)
			__mainargs = new String[0];
		
		// Set a watchdog in case our test takes a very long time to execute
		DeadlockTimeout dtimeout = new DeadlockTimeout();
		dtimeout.start();
		
		// Remember the old output stream because it will be replaced with
		// stderr, this way when tests run they do not inadvertently output
		// to standard output. Standard output being printed to will mess up
		// the test results generated at the end of tac-runner
		PrintStream oldout = System.out;
		
		// Replace standard output from the test!
		TestExecution execution;
		try
		{
			// Set the output stream to standard error as noted above
			try
			{
				System.setOut(System.err);
			}
			catch (SecurityException e)
			{
				// Ignore, oh well
			}
			
			// Execute the test
			execution = this.runExecution(__mainargs);
		}
		finally
		{
			// Restore the old output stream
			try
			{
				System.setOut(oldout);
			}
			catch (SecurityException e)
			{
				// Ignore, things happen
			}
		}
		
		// Dump test result
		try
		{
			if (Boolean.getBoolean(__CoreTest__.DUMP_ACTUAL))
				execution.result.writeAsManifest(System.err);
		}
		catch (IOException|SecurityException e)
		{
			// Ignore, could not dump it?
		}
		
		// Set output according to the status
		execution.print(System.err);
		
		// Stop the watchdog so we do not exit
		dtimeout.expire();
	}
	
	/**
	 * Stores a secondary value which can be additionally used as test
	 * comparison.
	 *
	 * @param __key The key to check.
	 * @param __v The value to check.
	 * @throws NullPointerException If no key was specified.
	 * @since 2018/10/07
	 */
	public final void secondary(String __key, Object __v)
		throws NullPointerException
	{
		this._runresult.putSecondaryValue(__key, __v);
	}
	
	/**
	 * Runs the MIDlet, parses input test data then runs the test performing
	 * any test work that is needed.
	 *
	 * @since 2018/10/06
	 */
	@Override
	protected final void startApp()
	{
		// Just forward to run, no main arguments are used at all
		this.runTest((String[])null);
		
		// There is just a single program, so exit with the test status
		System.exit(this._status.ordinal());
	}
	
	/**
	 * Returns the test status.
	 *
	 * @return The test status.
	 * @since 2018/10/07
	 */
	public final TestStatus status()
	{
		return this._status;
	}
	
	/**
	 * Parses the input file for arguments.
	 *
	 * @param __class The class for this test, used to load off manifests.
	 * @param __mainargs Main program arguments.
	 * @return The input arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	private Object[] __parseInput(Class<?> __class, String[] __mainargs)
		throws NullPointerException
	{
		if (__class == null)
			throw new NullPointerException("NARG");
		
		__mainargs = (__mainargs == null ? new String[0] : __mainargs.clone());
		
		// This is used to determine the system property prefix along with
		// which class to use
		String classname = __class.getName();
		
		// Determine the base name which is used for resources
		int ld = classname.lastIndexOf('.');
		String basename = (ld < 0 ? classname : classname.substring(ld + 1));
		
		// The system property prefix is just the class name but lowercased
		String sysprefix = classname.toLowerCase();
		
		// Try to see if there are any arguments in the test file
		JavaManifestAttributes attr = null;
		try (InputStream in = __class.getResourceAsStream(basename + ".in"))
		{
			// If the input exists parse and extract the manifest attributes
			if (in != null)
				attr = new JavaManifest(in).getMainAttributes();
		}
		
		// Ignore
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		// Read argument values in this order, to allow new ones to be
		// specified accordingly: main arguments, system properties, the
		// default input manifest
		List<Object> rv = new ArrayList<>();
		for (int i = 1; i >= 1; i++)
		{
			String parse;
			
			// Main arguments first
			if (__mainargs != null && (i - 1) < __mainargs.length)
				parse = __mainargs[i - 1];
			
			// Use other default sources instead
			else
			{
				// System property
				String maybe = System.getProperty(sysprefix + "." + i);
				if (maybe != null)
					parse = maybe;
				
				// Otherwise just read a value from the manifest
				else if (attr != null)
					parse = attr.getValue("argument-" + i);
				
				// Nothing
				else
					parse = null;
			}
			
			// Nothing to parse
			if (parse == null)
				break;
			
			// Deserialize the argument value
			rv.add(DataDeserialization.deserialize(parse));
		}
		
		return rv.<Object>toArray(new Object[rv.size()]);
	}
}

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

package net.multiphasicapps.tac;

/**
 * This is an indicator that an exception was thrown.
 *
 * @since 2018/10/06
 */
final class __ExceptionThrown__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __ExceptionThrown__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "ExceptionThrown";
	}
}

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

package net.multiphasicapps.tac;

/**
 * Indicates that no exception was thrown.
 *
 * @since 2018/10/06
 */
final class __NoExceptionThrown__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __NoExceptionThrown__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "NoExceptionThrown";
	}
}

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

package net.multiphasicapps.tac;

/**
 * This represents no result.
 *
 * @since 2018/10/06
 */
final class __NoResult__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __NoResult__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "NoResult";
	}
}

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

package net.multiphasicapps.tac;

/**
 * This represents a result which has not been defined.
 *
 * @since 2018/10/06
 */
final class __UndefinedResult__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __UndefinedResult__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "UndefinedResult";
	}
}

Added modules/tac/src/main/java/net/multiphasicapps/tac/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package the the test framework.
 *
 * @since 2018/10/03
 */

package net.multiphasicapps.tac;

Added modules/tac/src/main/java/org/testng/annotations/CustomAttribute.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package org.testng.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Custom attributes for a test.
 *
 * @since 2020/02/26
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface CustomAttribute {
	/** @retrun The name of the attribute. */
	String name();
	
	/** @return The values of the attributes. */
	String[] values() default {};
}

Added modules/tac/src/main/java/org/testng/annotations/Test.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
package org.testng.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.testng.internal.annotations.DisabledRetryAnalyzer;

/**
 * Used to trick TestNG that this is a test to run.
 *
 * @since 2020/02/26
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface Test
{
	/** @return Always run the class? */
	boolean alwaysRun() default false;
	
	/** @return Custom attributes. */
	CustomAttribute[] attributes() default {};
	
	/** @return Data provider. */
	String dataProvider() default "";
	
	/** @return The class for the data provider. */
	Class<?> dataProviderClass() default Object.class;
	
	/** @return The groups this depends on. */
	String[] dependsOnGroups() default {};
	
	/** @return The methods this depends on. */
	String[] dependsOnMethods() default {};
	
	/** @return The test description. */
	String description() default "";
	
	/** @return Enabled by default. */
	boolean enabled() default true;
	
	/** @return The expected excpetions. */
	Class[] expectedExceptions() default {};
	
	/** @return Regular expression for the expected exception message. */
	String expectedExceptionsMessageRegExp() default ".*";
	
	/** @return Groups the test is under. */
	String[] groups() default {};
	
	/** @return Are missing dependencies ignored? */
	boolean ignoreMissingDependencies() default false;
	
	/** @return The number of times to invoke the method. */
	int invocationCount() default 1;
	
	/** @return How long before the invocation will time out. */
	long invocationTimeOut() default 0;
	
	/** @return The test priority. */
	int priority() default 0;
	
	/** @return Are the tests single threaded? */
	boolean singleThreaded() default false;
	
	/** @return Skip methods that fail to be invoked? */
	boolean skipFailedInvocations() default false;
	
	/** @return The expected percentage of passing tests. */
	int successPercentage() default 100;
	
	/** @return The name of the suite. */
	String suiteName() default "";
	
	/** @return THe test name. */
	String testName() default "";
	
	/** @return The size of the thread pool. */
	int threadPoolSize() default 0;
	
	/** @return Maximum amount of time the test should take. */
	long timeOut() default 0;
	
	/** @return How tests should be ran. */
	Class<?> retryAnalyzer() default DisabledRetryAnalyzer.class;
}

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

import net.multiphasicapps.tac.TestBiConsumer;

/**
 * Tests a basic bi consumer.
 *
 * @since 2018/10/06
 */
public class DoBiConsumer
	extends TestBiConsumer<String, Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test(String __s, Integer __i)
	{
		this.secondary("a", __s);
		this.secondary("b", __i);
	}
}

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

import net.multiphasicapps.tac.TestBiFunction;

/**
 * Tests a basic bi function.
 *
 * @since 2018/10/06
 */
public class DoBiFunction
	extends TestBiFunction<String, Integer, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test(String __s, Integer __i)
	{
		StringBuilder sb = new StringBuilder(__s + "..." + __i);
		sb.reverse();
		return sb.toString();
	}
}

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

import net.multiphasicapps.tac.TestConsumer;

/**
 * Tests a basic consumer.
 *
 * @since 2018/10/06
 */
public class DoConsumer
	extends TestConsumer<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test(String __s)
	{
		this.secondary("input", __s);
	}
}

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

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests a basic exception.
 *
 * @since 2018/10/06
 */
public class DoException
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test()
	{
		// Expected to fail
		throw new RuntimeException("Oopsie!");
	}
}

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

import net.multiphasicapps.tac.TestFunction;

/**
 * Tests a basic consumer.
 *
 * @since 2018/10/06
 */
public class DoFunction
	extends TestFunction<String, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test(String __s)
	{
		StringBuilder sb = new StringBuilder(__s);
		sb.reverse();
		return sb.toString();
	}
}

Added modules/tac/src/test/java/DoRunnable.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests a basic runnable.
 *
 * @since 2018/10/06
 */
public class DoRunnable
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test()
	{
	}
}

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

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests a basic supplier.
 *
 * @since 2018/10/06
 */
public class DoSupplier
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test()
	{
		return "Hello squirrels! We are so cute! <3";
	}
}

Added modules/tac/src/test/resources/DoBiConsumer.in.








1
2
3
4
5
6
7
+
+
+
+
+
+
+
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
argument-2: int:123456789
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
secondary-b: int:123456789

Added modules/tac/src/test/resources/DoBiFunction.in.






1
2
3
4
5
+
+
+
+
+
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
argument-2: int:123456789
result: string:987654321...3<\_!etuc\_os\_era\_eW\_!slerriuqs\_olleH
thrown: NoExceptionThrown

Added modules/tac/src/test/resources/DoConsumer.in.





1
2
3
4
+
+
+
+
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
result: NoResult
thrown: NoExceptionThrown
secondary-input: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3

Added modules/tac/src/test/resources/DoException.in.




1
2
3
+
+
+
result: ExceptionThrown
thrown: throwable:RuntimeException

Added modules/tac/src/test/resources/DoFunction.in.





1
2
3
4
+
+
+
+
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
result: string:3<\_!etuc\_os\_era\_eW\_!slerriuqs\_olleH
thrown: NoExceptionThrown

Added modules/tac/src/test/resources/DoRunnable.in.




1
2
3
+
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/tac/src/test/resources/DoSupplier.in.




1
2
3
+
+
+
result: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
thrown: NoExceptionThrown

Added modules/tool-classfile/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This contains support for reading class files."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "JC"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Class File Reader"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:collections")
	implementation project(":modules:io")
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/DualPoolEncodeResult.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This contains the result of an encoded dual-pool.
 *
 * @since 2019/07/17
 */
public final class DualPoolEncodeResult
{
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the result of the dual-encoder.
	 *
	 * @param __spo The static pool offset.
	 * @param __spz The static pool size.
	 * @param __rpo The run-time pool offset.
	 * @param __rpz The run-time pool size.
	 * @since 2019/07/17
	 */
	public DualPoolEncodeResult(int __spo, int __spz, int __rpo, int __rpz)
	{
		this.staticpooloff = __spo;
		this.staticpoolsize = __spz;
		this.runtimepooloff = __rpo;
		this.runtimepoolsize = __rpz;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/DualPoolEncoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.NotedString;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
 * @since 2019/07/17
 */
public final class DualPoolEncoder
{
	/** The size of the table entries. */
	public static final int TABLE_ENTRY_SIZE =
		8;
	
	/**
	 * Not used.
	 *
	 * @since 2019/07/17
	 */
	private DualPoolEncoder()
	{
	}
	
	/**
	 * Decodes the specified pool.
	 *
	 * @param __b The input byte array.
	 * @param __co The class pool offset.
	 * @param __cl The class pool length.
	 * @param __ro The run-time pool offset.
	 * @param __rl The run-time pool length.
	 * @return The resulting dual pool.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @throws IOException If the pool could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final DualClassRuntimePool decode(byte[] __b,
		int __co, int __cl, int __ro, int __rl)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// The resulting pool
		BasicPool classpool = null,
			runpool = null;
			
		// Read of both pools
		for (boolean isruntime = false;; isruntime = true)
		{
			// The base offset and length used, used to read entry data
			int baseoff = (isruntime ? __ro : __co);
			
			// Which stream to read main entries from?
			DataInputStream dis = new DataInputStream(
				new ByteArrayInputStream(__b, baseoff,
					(isruntime ? __rl : __cl)));
			
			// Read the entry count (first null entry), ignore padding
			dis.readByte();
			dis.readByte();
			dis.readShort();
			int poolsize = dis.readInt();
			
			// Target entries
			List<BasicPoolEntry> entries = new ArrayList<>(poolsize);
			
			// Initialize null entry
			entries.add(new BasicPoolEntry(0, null, new int[0]));
			
			// Read in every entry
			for (int i = 1; i < poolsize; i++)
			{
				// Read entry properties
				int tag = dis.readByte() & 0xFF,
					numparts = dis.readByte(),
					elen = dis.readUnsignedShort(),
					eoff = dis.readInt();
				
				// Read type information
				MinimizedPoolEntryType etype;
				try
				{
					etype = MinimizedPoolEntryType.of(tag);
				}
				catch (IllegalArgumentException e)
				{
					// {@squirreljme.error JC4i Invalid constant pool entry.}
					throw new InvalidClassFormatException("JC4i", e);
				}
				
				// {@squirreljme.error JC4j The specified type cannot be within
				// the current pool section. (The type; If this is the run-time
				// pool)}
				if (etype.isRuntime() != isruntime)
					throw new InvalidClassFormatException("JC4j " + etype +
						" " + isruntime);
				
				// Get reader for the entry data
				DataInputStream xd = new DataInputStream(
					new ByteArrayInputStream(__b, baseoff + eoff, elen));
				
				// Is this wide?
				boolean iswide = (numparts < 0);
				if (iswide)
					numparts = -numparts;
				
				// Resulting parts and value
				Object value;
				int[] parts = new int[numparts];
				
				// Depends on the type
				switch (etype)
				{
						// String
					case STRING:
						// Read hash code and length
						parts[0] = xd.readUnsignedShort();
						parts[1] = xd.readUnsignedShort();
						
						// Decode actual string
						value = xd.readUTF();
						break;
						
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_INFO_POINTER:
					case CLASS_NAME:
					case CLASS_NAMES:
					case CLASS_POOL:
					case INTEGER:
					case FLOAT:
					case LONG:
					case DOUBLE:
					case INVOKED_METHOD:
					case METHOD_DESCRIPTOR:
					case METHOD_INDEX:
					case NOTED_STRING:
					case USED_STRING:
						// Read parts
						if (iswide)
							for (int p = 0; p < numparts; p++)
								parts[p] = xd.readUnsignedShort();
						else
							for (int p = 0; p < numparts; p++)
								parts[p] = xd.readByte() & 0xFF;
						
						// Build value depending on the parts used
						switch (etype)
						{
								// Name of class, has extra meta-data
							case CLASS_NAME:
								value = new ClassName(entries.get(parts[0]).
									<String>value(String.class));
								break;
							
								// A list of class names
							case CLASS_NAMES:
								ClassName[] cnn = new ClassName[numparts];
								
								for (int j = 0; j < numparts; j++)
									cnn[j] = entries.get(parts[j]).
										<ClassName>value(ClassName.class);
								
								value = new ClassNames(cnn);
								break;
								
								// Raw integer value
							case INTEGER:
								value = ((parts[0] & 0xFFFF) << 16) |
									(parts[1] & 0xFFFF);
								break;
								
								// Raw float value
							case FLOAT:
								value = Float.intBitsToFloat(
									((parts[0] & 0xFFFF) << 16) |
									(parts[1] & 0xFFFF));
								break;
								
								// Raw long value
							case LONG:
								value = (((long)(((parts[0] & 0xFFFF) << 16) |
									((parts[1] & 0xFFFF))) &
										0xFFFFFFFFL) << 32L) |
									((long)(((parts[2] & 0xFFFF) << 16) |
									((parts[3] & 0xFFFF))) & 0xFFFFFFFFL);
								break;
								
								// Raw double value
							case DOUBLE:
								value = Double.longBitsToDouble(
									(((long)(((parts[0] & 0xFFFF) << 16) |
									((parts[1] & 0xFFFF))) &
										0xFFFFFFFFL) << 32L) |
									((long)(((parts[2] & 0xFFFF) << 16) |
									((parts[3] & 0xFFFF))) & 0xFFFFFFFFL));
								break;
								
								// Method descriptor, has extra meta-data
							case METHOD_DESCRIPTOR:
								value = new MethodDescriptor(
									entries.get(parts[0]).
									<String>value(String.class));
								break;
								
								// A field which has been accessed
							case ACCESSED_FIELD:
								value = new AccessedField(
									FieldAccessTime.of(parts[0]),
									FieldAccessType.of(parts[1]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[2]),
									classpool.<String>byIndex(
										String.class, parts[3]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[4]).field());
								break;
							
								// Class information point
							case CLASS_INFO_POINTER:
								value = new ClassInfoPointer(
									classpool.byIndex(parts[0]).
									<ClassName>value(ClassName.class));
								break;
								
								// Class run-time pool reference
							case CLASS_POOL:
								value = new ClassPool(
									classpool.byIndex(parts[0]).
									<ClassName>value(ClassName.class));
								break;
								
								// A method which has been invoked
							case INVOKED_METHOD:
								value = new InvokedMethod(
									InvokeType.of(parts[0]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[1]),
									classpool.<String>byIndex(String.class,
										parts[2]),
									classpool.<MethodDescriptor>byIndex(
										MethodDescriptor.class, parts[3]));
								break;
								
								// Method index in vtable
							case METHOD_INDEX:
								value = new MethodIndex(
									classpool.<ClassName>byIndex(
										ClassName.class, parts[1]),
									classpool.<String>byIndex(
										String.class, parts[2]),
									classpool.<MethodDescriptor>byIndex(
										MethodDescriptor.class, parts[3]));
								break;
								
								// Noted string
							case NOTED_STRING:
								value = new NotedString(
									classpool.byIndex(parts[0]).
									<String>value(String.class));
								break;
								
								// Used string
							case USED_STRING:
								value = new UsedString(
									classpool.byIndex(parts[0]).
									<String>value(String.class));
								break;
								
								// Unknown
							default:
								throw new todo.OOPS(etype.name());
						}
						break;
						
						// Unknown
					default:
						throw new todo.OOPS(etype.name());
				}
				
				// Record entry
				entries.add(new BasicPoolEntry(i, value, parts, eoff));
			}
			
			// Build pool
			BasicPool result = new BasicPool(entries);
			
			// Store pool in the right spot
			if (isruntime)
				runpool = result;
			else
				classpool = result;
			
			// Stop processing after the run-time is done
			if (isruntime)
				break;
		}
		
		// Finalize pool
		return new DualClassRuntimePool(classpool, runpool);
	}
	
	/**
	 * Encodes the dual pool to the given output stream and returns the
	 * result.
	 *
	 * @param __dp The dual-pool to encode.
	 * @param __out The stream to write to.
	 * @return The result with size information.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final DualPoolEncodeResult encode(
		DualClassRuntimePoolBuilder __dp, OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__dp == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Table sections are used for output
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Build sections for output
		TableSectionOutputStream.Section clssection = output.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		TableSectionOutputStream.Section runsection = output.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		
		// Write both of the pools
		for (boolean isruntime = false;; isruntime = true)
		{
			// Sub output which writes to the section
			TableSectionOutputStream sub = new TableSectionOutputStream();
			
			// Section containing the table of contents
			TableSectionOutputStream.Section toc = sub.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Are we encoding the static or run-time pool?
			BasicPoolBuilder pool = (isruntime ? __dp.runtimePool() :
				__dp.classPool());
			
			// The size of the pool, used for the first entry
			int poolsize = pool.size();
			
			// Write individual pool entries
			for (BasicPoolEntry e : pool)
			{
				// The first is always null and just contains some pool
				// information
				Object ev = e.value;
				if (e.index == 0)
				{
					// No tag, no parts, no size, entry count (offset)
					toc.write(0);
					toc.write(0);
					toc.writeShort(0);
					toc.writeInt(poolsize);
					
					// Skip
					continue;
				}
				
				// Determine the type of entry this is
				MinimizedPoolEntryType et =
					MinimizedPoolEntryType.ofClass(ev.getClass());
				
				// {@squirreljme.error JC4d Cannot store the given entry
				// because it not compatible with the static/run-time
				// state. (The pool type; The value type; Is the run-time
				// pool being processed?)}
				if (isruntime != et.isRuntime())
					throw new IllegalStateException("JC4d " +
						et + " " + ev + " " + isruntime);
				
				// Determine if the parts need to be wide
				short[] ep = e.parts();
				int epn = ep.length;
				boolean iswide = false;
				for (int j = 0; j < epn; j++)
				{
					int v = ep[j];
					if (v < 0 || v > 127)
						iswide = true;
				}
				
				// Encode the data into a section somewhere in this
				// sub-section
				TableSectionOutputStream.Section data = sub.addSection(
					TableSectionOutputStream.VARIABLE_SIZE, 4);
				data.write(DualPoolEncoder.encodeValue(et, ep, iswide, ev));
				
				// Write pool table entry
				toc.writeByte(et.ordinal());
				toc.writeByte((iswide ? -epn : epn));
				toc.writeSectionSizeShort(data);
				toc.writeSectionAddressInt(data);
			}
			
			// Write entire sub-section data to the target
			sub.writeTo((isruntime ? runsection : clssection));
			
			// Stop processing after the run-time is done
			if (isruntime)
				break;
		}
		
		// Write to the target stream
		output.writeTo(__out);
		
		// Return the location of the data, note that the addresses and
		// sizes would have been realized already
		return new DualPoolEncodeResult(
			output.sectionAddress(clssection), output.sectionSize(clssection),
			output.sectionAddress(runsection), output.sectionSize(runsection));
	}
	
	/**
	 * Encodes a layered pool from one class to another.
	 *
	 * @param __src The source pool.
	 * @param __onto The pool to layer on top of.
	 * @param __out The stream to write to.
	 * @return The result of the encoded pool data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public static final DualPoolEncodeResult encodeLayered(
		DualClassRuntimePoolBuilder __src, DualClassRuntimePoolBuilder __onto,
		OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__src == null || __onto == null || __out == null)
			throw new NullPointerException("NARG");
		
		// The resulting table
		TableSectionOutputStream table = new TableSectionOutputStream();
		
		// Process static entries
		TableSectionOutputStream.Section sl = table.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (BasicPoolEntry e : __src.classPool())
		{
			if (e.index == 0)
				sl.writeInt(__src.classPool().size());
			else
				sl.writeInt(__onto.add(false, e.value).index);
		}
		
		// Process run-time entries
		TableSectionOutputStream.Section rl = table.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (BasicPoolEntry e : __src.runtimePool())
		{
			if (e.index == 0)
				rl.writeInt(__src.runtimePool().size());
			else
				rl.writeInt(__onto.add(true, e.value).index);
		}
		
		// Write the encoded pool
		table.writeTo(__out);
		
		// Return the positions of everything
		return new DualPoolEncodeResult(
			table.sectionAddress(sl), -table.sectionSize(sl),
			table.sectionAddress(rl), -table.sectionSize(rl));
	}
	
	/**
	 * Encodes the pool value.
	 *
	 * @param __t The type to encode.
	 * @param __p The parts.
	 * @param __wide Are the parts wide?
	 * @param __v The value.
	 * @return The encoded value data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/20
	 */
	public static final byte[] encodeValue(MinimizedPoolEntryType __t,
		short[] __p, boolean __wide, Object __v)
		throws IOException, NullPointerException
	{
		if (__t == null || __p == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Output for this data
		TableSectionOutputStream output = new TableSectionOutputStream();
		TableSectionOutputStream.Section dos = output.addSection();
		
		// Depends on the type
		switch (__t)
		{
				// Encode strings into the pool
			case STRING:
				{
					// Record hashCode and the String size as simple
					// fields to read. Note that even though there is
					// the UTF length, the length of the actual string
					// could be useful. But only keep the lowest part
					// as that will be "good enough"
					dos.writeShort((short)__p[0]);
					dos.writeUnsignedShortChecked(__p[1]);
					
					// Write string UTF data
					dos.writeUTF((String)__v);
					
					// Write NUL terminator so it can be directly used
					// as a UTF-8 C pointer
					dos.writeByte(0);
				}
				break;
				
				// Everything else just consists of parts which are
				// either values to other indexes or an ordinal
			case ACCESSED_FIELD:
			case CLASS_INFO_POINTER:
			case CLASS_NAME:
			case CLASS_NAMES:
			case CLASS_POOL:
			case INTEGER:
			case FLOAT:
			case DOUBLE:
			case LONG:
			case INVOKED_METHOD:
			case METHOD_DESCRIPTOR:
			case METHOD_INDEX:
			case NOTED_STRING:
			case USED_STRING:
				if (__wide)
					for (int i = 0, n = __p.length; i < n; i++)
						dos.writeShortChecked(__p[i]);
				else
					for (int i = 0, n = __p.length; i < n; i++)
						dos.writeByte(__p[i]);
				break;
			
			default:
				throw new todo.OOPS(__t.name());
		}
		
		return output.toByteArray();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedClassFile.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This contains the minimized class file which is a smaller format of the
 * {@link net.multiphasicapps.classfile.ClassFile} that is more optimized to
 * virtual machines for usage.
 *
 * @since 2019/03/10
 */
public final class MinimizedClassFile
{
	/** Header. */
	public final MinimizedClassHeader header;
	
	/** Pool. */
	public final DualClassRuntimePool pool;
	
	/** Static fields. */
	private final MinimizedField[] _sfields;
	
	/** Instance fields. */
	private final MinimizedField[] _ifields;
	
	/** Static methods. */
	private final MinimizedMethod[] _smethods;
	
	/** Instance methods. */
	private final MinimizedMethod[] _imethods;
	
	/** Class flags. */
	private Reference<ClassFlags> _flags;
	
	/**
	 * Initializes the minimized class file.
	 *
	 * @param __h The header.
	 * @param __p The pool.
	 * @param __sf Static fields.
	 * @param __if Instance fields.
	 * @param __sm Static methods.
	 * @param __im Instance methods.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public MinimizedClassFile(MinimizedClassHeader __h,
		DualClassRuntimePool __p,
		MinimizedField[] __sf, MinimizedField[] __if,
		MinimizedMethod[] __sm, MinimizedMethod[] __im)
		throws NullPointerException
	{
		if (__h == null || __p == null || __sf == null || __if == null ||
			__sm == null || __im == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.header = __h;
		this.pool = __p;
		this._sfields = (__sf = __sf.clone());
		this._ifields = (__if = __if.clone());
		this._smethods = (__sm = __sm.clone());
		this._imethods = (__im = __im.clone());
		
		// Check for nulls
		for (Object[] va : new Object[][]{__sf, __if, __sm, __im})
			for (Object v : va)
				if (v == null)
					throw new NullPointerException("NARG");
	}
	
	/**
	 * Searches for a field by the given name and type.
	 *
	 * @param __is Search for static field?
	 * @param __n The name.
	 * @param __t The type.
	 * @return The field or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedField field(boolean __is, FieldName __n,
		FieldDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		return this.field(__is, new FieldNameAndType(__n, __t));
	}
	
	/**
	 * Searches for a field by the given name and type.
	 *
	 * @param __is Search for static field?
	 * @param __nat The name and type.
	 * @return The field or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedField field(boolean __is, FieldNameAndType __nat)
		throws NullPointerException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedField mf : (__is ? this._sfields : this._ifields))
			if (mf.name.equals(__nat.name()) && mf.type.equals(__nat.type()))
				return mf;
		
		return null;
	}
	
	/**
	 * Returns the fields in the class.
	 *
	 * @param __is If true then static fields are returned.
	 * @return The fields.
	 * @since 2019/04/17
	 */
	public final MinimizedField[] fields(boolean __is)
	{
		return (__is ? this._sfields.clone() : this._ifields.clone());
	}
	
	/**
	 * The class flags.
	 *
	 * @return The class flags.
	 * @since 2019/04/17
	 */
	public final ClassFlags flags()
	{
		Reference<ClassFlags> ref = this._flags;
		ClassFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new ClassFlags(this.header.classflags)));
		
		return rv;
	}
	
	/**
	 * Returns the names of all the interfaces.
	 *
	 * @return The interface names.
	 * @since 2019/04/17
	 */
	public final ClassNames interfaceNames()
	{
		int idx = this.header.classints;
		if (idx == 0)
			return new ClassNames();
		return this.pool.getByIndex(false, idx).
			<ClassNames>value(ClassNames.class);
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __n The name.
	 * @param __t The type, if {@code null} the type is ignored.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Static first, then instance methods
		MinimizedMethod rv = this.method(true, __n, __t);
		return (rv == null ? this.method(false, __n, __t) : rv);
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __is Search for static method?
	 * @param __n The name.
	 * @param __t The type, if {@code null} the type is ignored.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(boolean __is, MethodName __n,
		MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedMethod mm : (__is ? this._smethods : this._imethods))
			if (mm.name.equals(__n) && (__t == null || mm.type.equals(__t)))
				return mm;
		
		// Not found
		return null;
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __is Search for static method?
	 * @param __nat The name and type.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(boolean __is, MethodNameAndType __nat)
		throws NullPointerException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedMethod mm : (__is ? this._smethods : this._imethods))
			if (mm.name.equals(__nat.name()) && mm.type.equals(__nat.type()))
				return mm;
		
		return null;
	}
	
	/**
	 * Returns the methods in the class.
	 *
	 * @param __is If true then static methods are returned.
	 * @return The methods.
	 * @since 2019/04/17
	 */
	public final MinimizedMethod[] methods(boolean __is)
	{
		return (__is ? this._smethods.clone() : this._imethods.clone());
	}
	
	/**
	 * Returns the minimized constant pool.
	 *
	 * @return The minimized constant pool.
	 * @since 2019/04/17
	 */
	public final DualClassRuntimePool pool()
	{
		return this.pool;
	}
	
	/**
	 * Returns the super name of the current class.
	 *
	 * @return The class super name or {@code null} if there is none.
	 * @since 2019/04/17
	 */
	public final ClassName superName()
	{
		int sdx = this.header.classsuper;
		if (sdx == 0)
			return null;
		return this.pool.getByIndex(false, sdx).
			<ClassName>value(ClassName.class);
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The name of the current class.
	 * @since 2019/04/17
	 */
	public final ClassName thisName()
	{
		return this.pool.getByIndex(false, this.header.classname).
			<ClassName>value(ClassName.class);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The stream to decode from.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final MinimizedClassFile decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return MinimizedClassFile.decode(__is, null);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The stream to decode from.
	 * @param __ppool The parent pool, may be {@code null}.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final MinimizedClassFile decode(InputStream __is,
		DualClassRuntimePool __ppool)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Initialize byte array with guess to how many bytes can be read
		byte[] mcdata;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			Math.min(1048576, __is.available())))
		{
			// Read the entire header for the class
			for (int i = 0; i < MinimizedClassHeader.HEADER_SIZE_WITH_MAGIC;
				i++)
				baos.write(__is.read());
			
			// Read the data size to determine how much to read
			byte[] xhead = baos.toByteArray();
			int datasize = ((xhead[92] & 0xFF) << 24) |
				((xhead[93] & 0xFF) << 16) |
				((xhead[94] & 0xFF) << 8) |
				((xhead[95] & 0xFF));
			
			// Read all the data size bytes
			byte[] buf = new byte[512];
			for (int left = datasize; left > 0;)
			{
				int rc = __is.read(buf, 0, (512 < left ? 512 : left));
				
				// EOF?
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
				left -= rc;
			}
			
			// Finish off
			mcdata = baos.toByteArray();
		}
		
		// Decode now
		return MinimizedClassFile.decode(mcdata, __ppool);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The bytes to decode from.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final MinimizedClassFile decode(byte[] __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return MinimizedClassFile.decode(__is, null);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The bytes to decode from.
	 * @param __ppool The parent pool, may be {@code null}.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedClassFile decode(byte[] __is,
		DualClassRuntimePool __ppool)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Reading could fail
		try
		{
			// Read class header
			MinimizedClassHeader header = MinimizedClassHeader.decode(
				new ByteArrayInputStream(__is));
			
			// {@squirreljme.error JC01 Length of class file does not match
			// length of array. (The file length; The array length)}
			int fsz = header.filesize;
			if (fsz != __is.length)
				throw new InvalidClassFormatException("JC01 " + fsz +
					" " + __is.length);
			
			// {@squirreljme.error JC02 End of file magic number is invalid.
			// (The read magic number)}
			int endmagic;
			if (MinimizedClassHeader.END_MAGIC_NUMBER !=
				(endmagic = (((__is[fsz - 4] & 0xFF) << 24) |
				((__is[fsz - 3] & 0xFF) << 16) |
				((__is[fsz - 2] & 0xFF) << 8) |
				(__is[fsz - 1] & 0xFF))))
				throw new InvalidClassFormatException(
					String.format("JC02 %08x", endmagic));
			
			// Virtual constant pool which relies on a parent one
			DualClassRuntimePool pool;
			if (header.staticpoolsize < 0 || header.runtimepoolsize < 0)
			{
				// {@squirreljme.error JC4h No parent pool was specified.}
				if (__ppool == null)
					throw new NullPointerException("JC4h");
				
				throw new todo.TODO();
			}
			
			// Decode physical pool within the class
			else
			{
				pool = DualPoolEncoder.decode(__is,
					header.staticpooloff, header.staticpoolsize,
					header.runtimepooloff, header.runtimepoolsize);
			}
			
			// Read static and instance fields
			MinimizedField[] sfields = MinimizedField.decodeFields(
					header.sfcount, pool, __is, header.sfoff, header.sfsize),
				ifields = MinimizedField.decodeFields(
					header.ifcount, pool, __is, header.ifoff, header.ifsize);
			
			// Read static and instance methods
			MinimizedMethod[] smethods = MinimizedMethod.decodeMethods(
					header.smcount, pool, __is, header.smoff, header.smsize),
				imethods = MinimizedMethod.decodeMethods(
					header.imcount, pool, __is, header.imoff, header.imsize);
			
			// Build final class
			return new MinimizedClassFile(header, pool,
				sfields, ifields, smethods, imethods);
		}
		
		// {@squirreljme.error JC03 End of file reached before parsing the
		// file.}
		catch (EOFException e)
		{
			throw new InvalidClassFormatException("JC03", e); 
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedClassHeader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents the raw minimized header of a class.
 *
 * @since 2019/04/16
 */
public final class MinimizedClassHeader
{
	/** The magic number for the header. */
	public static final int MAGIC_NUMBER =
		0x00586572;
	
	/** Magic number for the end of file. */
	public static final int END_MAGIC_NUMBER =
		0x42796521;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		108;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		MinimizedClassHeader.HEADER_SIZE_WITHOUT_MAGIC + 4;
	
	/** Unused A. */
	public final int unuseda;
	
	/** The index of the method which is __start. */
	public final int startmethodindex;
	
	/** The data type of the class. */
	public final DataType datatype;
	
	/** Not used. */
	public final int unusedb;
	
	/** Class flags. */
	public final int classflags;
	
	/** Name of class. */
	public final int classname;
	
	/** Super class name. */
	public final int classsuper;
	
	/** Interfaces in class. */
	public final int classints;
	
	/** Class type. */
	public final int classtype;
	
	/** Class version. */
	public final int classvers;
	
	/** Class source filename. */
	public final int classsfn;
	
	/** Static field count. */
	public final int sfcount;
	
	/** Static field bytes. */
	public final int sfbytes;
	
	/** Static field objects. */
	public final int sfobjs;
	
	/** Instance field count. */
	public final int ifcount;
	
	/** Instance field bytes. */
	public final int ifbytes;
	
	/** Instance field objects. */
	public final int ifobjs;
	
	/** Static method count. */
	public final int smcount;
	
	/** Instance method count. */
	public final int imcount;
	
	/** Not used. */
	public final int unusedc;
	
	/** Not used. */
	public final int unusedd;
	
	/** Static field data offset. */
	public final int sfoff;
	
	/** Static field data size. */
	public final int sfsize;
	
	/** Instance field data offset. */
	public final int ifoff;
	
	/** Instance field data size. */
	public final int ifsize;
	
	/** Static method data offset. */
	public final int smoff;
	
	/** Static method data size. */
	public final int smsize;
	
	/** Instance method data offset. */
	public final int imoff;
	
	/** Instance method data size. */
	public final int imsize;
	
	/** High bits for UUID. */
	public final int uuidhi;
	
	/** Low bits for UUID. */
	public final int uuidlo;
	
	/** File size. */
	public final int filesize;
	
	/** Not used. */
	public final int unusede;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the class header.
	 *
	 * @param __vx The raw values.
	 * @since 2019/04/16
	 */
	public MinimizedClassHeader(int... __vx)
	{
		int at = 0;
		
		// Unused
		this.unuseda = __vx[at++];
		
		// Start method index
		this.startmethodindex = __vx[at++];
		
		// Data Type
		this.datatype = DataType.of(__vx[at++]);
		
		// Constant pool
		this.unusedb = __vx[at++];
		
		// Class information
		this.classflags = __vx[at++];
		this.classname = __vx[at++];
		this.classsuper = __vx[at++];
		this.classints = __vx[at++];
		this.classtype = __vx[at++];
		this.classvers = __vx[at++];
		this.classsfn = __vx[at++];

		// Static and instance fields
		this.sfcount = __vx[at++];
		this.sfbytes = __vx[at++];
		this.sfobjs = __vx[at++];
		this.ifcount = __vx[at++];
		this.ifbytes = __vx[at++];
		this.ifobjs = __vx[at++];

		// Static and instance methods
		this.smcount = __vx[at++];
		this.imcount = __vx[at++];

		// Not used
		this.unusedc = __vx[at++];
		this.unusedd = __vx[at++];
		
		// Static and instance field data
		this.sfoff = __vx[at++];
		this.sfsize = __vx[at++];
		this.ifoff = __vx[at++];
		this.ifsize = __vx[at++];
			
		// Static and instance method data
		this.smoff = __vx[at++];
		this.smsize = __vx[at++];
		this.imoff = __vx[at++];
		this.imsize = __vx[at++];
		
		// UUID
		this.uuidhi = __vx[at++];
		this.uuidlo = __vx[at++];
			
		// File size
		this.filesize = __vx[at++];
		
		// Not used
		this.unusede = __vx[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __vx[at++];
		this.staticpoolsize = __vx[at++];
		this.runtimepooloff = __vx[at++];
		this.runtimepoolsize = __vx[at++];
	}
	
	/**
	 * Decodes the minimized class header.
	 *
	 * @param __is The bytes to decode from.
	 * @return The resulting minimized class header.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedClassHeader decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		DataInputStream dis = new DataInputStream(__is);
		
		// {@squirreljme.error JC04 Invalid minimized class magic number.
		// (The magic number)}
		int readmagic;
		if (MinimizedClassHeader.MAGIC_NUMBER != (readmagic = dis.readInt()))
			throw new InvalidClassFormatException(String.format("JC04 %08x",
				readmagic));
		
		// Read in all the data
		return new MinimizedClassHeader(
			// Unused
			/* unuseda */ dis.readUnsignedShort(),
			
			// Start method index
			/* startmethodindex */ dis.readUnsignedByte(),
			
			// Data Type
			/* datatype */ dis.readUnsignedByte(),
			
			// Not used
			/* NOT USED */ dis.readUnsignedShort(),
			
			// Class header
			/* classflags */ dis.readInt(),
			/* classname */ dis.readUnsignedShort(),
			/* classsuper */ dis.readUnsignedShort(),
			/* classints */ dis.readUnsignedShort(),
			/* classtype */ dis.readUnsignedByte(),
			/* classvers */ dis.readUnsignedByte(),
			/* classsfn */ dis.readUnsignedShort(),
	
			// Static and instance fields
			/* sfcount */ dis.readUnsignedShort(),
			/* sfbytes */ dis.readUnsignedShort(),
			/* sfobjs */ dis.readUnsignedShort(),
			/* ifcount */ dis.readUnsignedShort(),
			/* ifbytes */ dis.readUnsignedShort(),
			/* ifobjs */ dis.readUnsignedShort(),
	
			// Static and instance methods
			/* smcount */ dis.readUnsignedShort(),
			/* imcount */ dis.readUnsignedShort(),
	
			// Not used
			/* NOT USED */ dis.readInt(),
			/* NOT USED */ dis.readInt(),
		
			// Static and instance field data
			/* sfoff */ dis.readInt(),
			/* sfbytes */ dis.readInt(),
			/* ifoff */ dis.readInt(),
			/* ifbytes */ dis.readInt(),
			
			// Static and instance method data
			/* smoff */ dis.readInt(),
			/* smbytes */ dis.readInt(),
			/* imoff */ dis.readInt(),
			/* imbytes */ dis.readInt(),
			
			// UUID
			/* uuidhi */ dis.readInt(),
			/* uuidlo */ dis.readInt(),
			
			// File size
			/* filesize */ dis.readInt(),
			
			// Not used
			/* NOT USED */ dis.readInt(),
			
			// Static and runtime pool
			/* staticpooloff */ dis.readInt(),
			/* staticpoolsize */ dis.readInt(),
			/* runtimepooloff */ dis.readInt(),
			/* runtimepoolsize */ dis.readInt());
	}	
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedField.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.xlate.DataType;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents a field which has been minimized.
 *
 * @since 2019/03/11
 */
public final class MinimizedField
{
	/** The flags for this field. */
	public final int flags;
	
	/** Offset to the field data. */
	public final int offset;
	
	/** The size of this field. */
	public final int size;
	
	/** The field name. */
	public final FieldName name;
	
	/** The field type. */
	public final FieldDescriptor type;
	
	/** The field value. */
	public final Object value;
	
	/** The data type. */
	public final DataType datatype;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Field flags. */
	private Reference<FieldFlags> _flags;
	
	/** Name and type. */
	private Reference<FieldNameAndType> _nat;
	
	/**
	 * Initializes the minimized field.
	 *
	 * @param __f The field flags.
	 * @param __o The offset.
	 * @param __s The size.
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @param __v The value of this field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/11
	 */
	public MinimizedField(int __f, int __o, int __s, FieldName __n,
		FieldDescriptor __t, Object __v)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.flags = __f;
		this.offset = __o;
		this.size = __s;
		this.name = __n;
		this.type = __t;
		this.value = __v;
		this.datatype = DataType.of(__t);
	}
	
	/**
	 * Returns the flags for this field.
	 *
	 * @return The flags for the field.
	 * @since 2019/04/18
	 */
	public final FieldFlags flags()
	{
		Reference<FieldFlags> ref = this._flags;
		FieldFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new FieldFlags(this.flags)));
		
		return rv;
	}
	
	/**
	 * Returns the name and type for this field.
	 *
	 * @return The name and type for this field.
	 * @since 2019/09/21
	 */
	public final FieldNameAndType nameAndType()
	{
		Reference<FieldNameAndType> ref = this._nat;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new FieldNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Field %s:%s @ %d (%d bytes), flags=%x, value=%s", this.name,
				this.type, this.offset, this.size, this.flags, this.value)));
		
		return rv;
	}
	
	/**
	 * Decodes the field data.
	 *
	 * @param __n The number of fields.
	 * @param __p The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded fields.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the fields could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedField[] decodeFields(int __n,
		DualClassRuntimePool __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedField[] rv = new MinimizedField[__n];
		
		// Read field data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				rv[i] = new MinimizedField(
					dis.readInt(),
					dis.readUnsignedShort(),
					dis.readUnsignedShort(),
					new FieldName(__p.getByIndex(false,
						dis.readUnsignedShort()).<String>value(String.class)),
					__p.getByIndex(false, dis.readUnsignedShort()).
						<ClassName>value(ClassName.class).field(),
					__p.getByIndex(false, dis.readUnsignedShort()).value);
				
				// Data type and padding, the data type here is determined by
				// the field so we do not need to use this pre-calculated
				// value
				dis.readUnsignedByte();
				dis.readUnsignedByte();
			}
		}
		
		// {@squirreljme.error JC05 Could not read field data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC05");
		}
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This represents a method which has been mimized.
 *
 * @since 2019/03/14
 */
public final class MinimizedMethod
{
	/** The size of encoded entries. */
	public static final int ENCODE_ENTRY_SIZE =
		20;
	
	/** Flags that are used for the method. */
	public final int flags;
	
	/** The index of this method in the instance table. */
	public final int index;
	
	/** The name of the method. */
	public final MethodName name;
	
	/** The type of the method. */
	public final MethodDescriptor type;
	
	/** The code offset. */
	public final int codeoffset;
	
	/** Translated method code. */
	final byte[] _code;
	
	/** Method flags. */
	private Reference<MethodFlags> _flags;
	
	/** Name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the minimized method.
	 *
	 * @param __f The method flags.
	 * @param __o Index in the method table for instances.
	 * @param __n The method name.
	 * @param __t The method type.
	 * @param __tc Transcoded instructions.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public MinimizedMethod(int __f, int __o,
		MethodName __n, MethodDescriptor __t, byte[] __tc)
		throws NullPointerException
	{
		this(__f, __o, __n, __t, __tc, 0);
	}
	
	/**
	 * Initializes the minimized method.
	 *
	 * @param __f The method flags.
	 * @param __o Index in the method table for instances.
	 * @param __n The method name.
	 * @param __t The method type.
	 * @param __tc Transcoded instructions.
	 * @param __co The code offset.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/14
	 */
	public MinimizedMethod(int __f, int __o,
		MethodName __n, MethodDescriptor __t, byte[] __tc, int __co)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.flags = __f;
		this.index = __o;
		this.name = __n;
		this.type = __t;
		this._code = (__tc == null ? new byte[0] : __tc.clone());
		this.codeoffset = __co;
	}
	
	/**
	 * Returns the method code.
	 *
	 * @return The method code.
	 * @since 2019/04/19
	 */
	public final byte[] code()
	{
		return this._code.clone();
	}
	
	/**
	 * Returns the flags for this method.
	 *
	 * @return The flags for the method.
	 * @since 2019/04/17
	 */
	public final MethodFlags flags()
	{
		Reference<MethodFlags> ref = this._flags;
		MethodFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new MethodFlags(this.flags)));
		
		return rv;
	}
	
	/**
	 * Returns the name and type for this method.
	 *
	 * @return The name and type for this method.
	 * @since 2019/05/26
	 */
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new MethodNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/24
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s:%s{flags=%x, dx=%d, co=%d}",
				this.name, this.type, this.flags, this.index,
				this.codeoffset)));
		
		return rv;
	}
	
	/**
	 * Decodes the method data.
	 *
	 * @param __n The number of methods.
	 * @param __p The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded methods.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the methods could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedMethod[] decodeMethods(int __n,
		DualClassRuntimePool __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedMethod[] rv = new MinimizedMethod[__n];
		
		// Read method data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				// Read in method information
				int flags = dis.readInt(),
					offset = dis.readUnsignedShort();
				MethodName name = new MethodName(
					__p.getByIndex(false, dis.readUnsignedShort()).
						<String>value(String.class));
				MethodDescriptor type =
					__p.getByIndex(false, dis.readUnsignedShort()).
						<MethodDescriptor>value(MethodDescriptor.class);
				int offcode = dis.readInt(), 
					lencode = dis.readInt();
				
				// Unused padding
				dis.readShort();
				
				// Read code?
				byte[] code = null;
				if (offcode > 0)
				{
					code = new byte[lencode];
					System.arraycopy(__b, __o + offcode, code, 0, lencode);
				}
				
				// Build method
				rv[i] = new MinimizedMethod(flags, offset, name, type,
					code, offcode);
			}
		}
		
		// {@squirreljme.error JC06 Could not read method data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC06");
		}
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedPool.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;

/**
 * This represents the minimized constant pool.
 *
 * @since 2019/04/16
 */
@Deprecated
public final class MinimizedPool
{
	/** Pool value offsets. */
	private final int[] _offsets;
	
	/** Entry types. */
	private final byte[] _types;
	
	/** Parts. */
	private final int[][] _parts;
	
	/** Values. */
	final Object[] _values;
	
	/**
	 * Initializes the minimized pool.
	 *
	 * @param __os Offsets to the individual pool entries.
	 * @param __ts Types.
	 * @param __ps Parts.
	 * @param __vs Values.
	 * @throws IllegalArgumentException If the arrays are of a different size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public MinimizedPool(int[] __os, byte[] __ts, int[][] __ps, Object[] __vs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__os == null || __ts == null || __ps == null || __vs == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC07  Input arrays are of a different length.
		// (The expected length)}
		int n = __ts.length;
		if (__os.length != n || __ps.length != n || __vs.length != n)
			throw new IllegalArgumentException("JC07 " + n);
		
		// Defensive copy each
		__os = __os.clone();
		__ts = __ts.clone();
		__ps = __ps.clone();
		__vs = __vs.clone();
		
		// Clone all elements in the parts
		for (int i = 0; i < n; i++)
		{
			int[] p = __ps[i];
			
			if (p == null)
				throw new NullPointerException("NARG");
			
			__ps[i] = p.clone();
		}
		
		// Check values for null, skip entry 0
		for (int i = 1; i < n; i++)
			if (__vs[i] == null)
				throw new NullPointerException("NARG");
		
		// Set
		this._offsets = __os;
		this._types = __ts;
		this._parts = __ps;
		this._values = __vs;
	}
	
	/**
	 * Gets the specified pool entry.
	 *
	 * @param __i The entry to get.
	 * @since 2019/04/17
	 */
	public final Object get(int __i)
	{
		return this._values[__i];
	}
	
	/**
	 * Gets the specified pool entry.
	 *
	 * @param <V> The type to get.
	 * @param __i The index of the entry.
	 * @param __cl The type to get.
	 * @return The pool entry value.
	 * @throws ClassCastException If the class is not compatible.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public final <V> V get(int __i, Class<V> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._values[__i]);
	}
	
	/**
	 * Returns the offset to the value of the entry within the pool.
	 *
	 * @param __i The index.
	 * @return The offset.
	 * @since 2019/05/01
	 */
	public final int offset(int __i)
	{
		return this._offsets[__i];
	}
	
	/**
	 * Returns the part at the given index.
	 *
	 * @param __i The pool entry to get.
	 * @param __p The part index.
	 * @return The part for this index.
	 * @since 2019/04/22
	 */
	public final int part(int __i, int __p)
	{
		return this._parts[__i][__p];
	}
	
	/**
	 * Returns the number of used parts.
	 *
	 * @param __i The index.
	 * @return The number of used parts.
	 * @since 2019/04/27
	 */
	public final int partCount(int __i)
	{
		return this._parts[__i].length;
	}
	
	/**
	 * Returns all of the available parts.
	 *
	 * @param __i The index.
	 * @return The parts for this index.
	 * @since 2019/04/30
	 */
	public final int[] parts(int __i)
	{
		return this._parts[__i].clone();
	}
	
	/**
	 * Returns the number of entries in the pool.
	 *
	 * @return The number of pool entries.
	 * @since 2019/04/17
	 */
	public final int size()
	{
		return this._types.length;
	}
	
	/**
	 * Returns the constant pool type.
	 *
	 * @param __i The index of the entry.
	 * @return The pool type.
	 * @since 2019/04/17
	 */
	public final MinimizedPoolEntryType type(int __i)
	{
		return MinimizedPoolEntryType.of(this._types[__i]);
	}
	
	/**
	 * Decodes the minimized constant pool.
	 *
	 * @param __n Number of entries in the pool.
	 * @param __is The bytes to decode from.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @return The resulting minimized pool.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	@Deprecated
	public static final MinimizedPool decode(int __n, byte[] __is, int __o,
		int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __is.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Types and offsets
		byte[] types = new byte[__n];
		int[] offsets = new int[__n];
		
		// Read the type and offset table
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__is, __o, __l)))
		{
			// Read type table
			for (int i = 0; i < __n; i++)
				types[i] = dis.readByte();
			
			// {@squirreljme.error JC08 First pool entry type is not zero.
			// (The type that was read)}
			if (types[0] != 0)
				throw new InvalidClassFormatException("JC08 " + types[0]);
			
			// {@squirreljme.error JC09 Pool uneven padding byte was not
			// 255. (The value it was; The following byte)}
			if ((__n & 1) != 0)
			{
				int val;
				if ((val = dis.readUnsignedByte()) != 0xFF)
					throw new InvalidClassFormatException("JC09 " + val + " " +
						dis.read());
			}
			
			// Read offsets into the structure
			for (int i = 0; i < __n; i++)
				offsets[i] = dis.readUnsignedShort();
		}
		
		// {@squirreljme.error JC0a Invalid read of pool data.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC0a", e);
		}
		
		// Output pool entry types, values, and parts
		int[][] parts = new int[__n][];
		Object[] values = new Object[__n];
		
		// Zero int for empty parts
		int[] nopart = new int[0];
		
		// Re-build individual pool entries
		Object[] entries = new Object[__n];
		for (int i = 0; i < __n; i++)
		{
			// Get type and pointer
			int rtype = types[i],
				ptr = offsets[i];
			
			// Is this wide?
			boolean iswide;
			if ((iswide = ((rtype & 0x80) != 0)))
			{
				rtype &= 0x7F;
				
				// Re-adjust type array since we use this for the type list
				types[i] = (byte)rtype;
			}
			
			// Read info
			int[] part = null;
			Object v = null;
			
			// It is easier to handle this as a stream of bytes
			try (DataInputStream dis = new DataInputStream(
				new ByteArrayInputStream(__is, __o + ptr, __l - ptr)))
			{
				// Depends on the type
				MinimizedPoolEntryType type = MinimizedPoolEntryType.of(rtype);
				switch (type)
				{
						// Null is nothing, so do not bother
					case NULL:
						// {@squirreljme.error JC0b NULL pool entry is only
						// permitted as the first type, the class file is
						// corrupt.}
						if (i != 0)
							throw new InvalidClassFormatException("JC0b");
						break;
						
						// Strings
					case STRING:
						part = new int[]{
								dis.readUnsignedShort(),
								dis.readUnsignedShort(),
							};
						v = dis.readUTF();
						break;
						
						// Integer
					case INTEGER:
						v = dis.readInt();
						break;
						
						// Float
					case FLOAT:
						v = Float.intBitsToFloat(dis.readInt());
						break;
						
						// Types which consist of parts
					case CLASS_NAME:
					case CLASS_NAMES:
					case CLASS_POOL:
					case ACCESSED_FIELD:
					case INVOKED_METHOD:
					case METHOD_DESCRIPTOR:
					case LONG:
					case DOUBLE:
					case USED_STRING:
					case METHOD_INDEX:
						// Wide parts
						if (iswide)
						{
							// Read length
							int np = dis.readUnsignedShort();
							
							// Read values
							part = new int[np];
							for (int j = 0; j < np; j++)
								part[j] = dis.readUnsignedShort();
						}
						
						// Narrow parts
						else
						{
							// Read length
							int np = dis.readUnsignedByte();
							
							// Read values
							part = new int[np];
							for (int j = 0; j < np; j++)
								part[j] = dis.readUnsignedByte();
						}
						
						// Now that the parts were read, we can build the
						// actual value
						switch (type)
						{
								// Class name
							case CLASS_NAME:
								v = new ClassName((String)values[part[0]]);
								break;
								
								// Names of classes
							case CLASS_NAMES:
								{
									// Number of class names
									int ncn = part.length;
									
									// Read class names
									ClassName[] names = new ClassName[ncn];
									for (int j = 0; j < ncn; j++)
										names[j] = (ClassName)values[part[j]];
									
									// Build names
									v = new ClassNames(names);
								}
								break;
							
								// The constant pool of a class
							case CLASS_POOL:
								v = new ClassPool((ClassName)values[part[0]]);
								break;
								
								// Field which was accessed
							case ACCESSED_FIELD:
								v = new AccessedField(
									FieldAccessTime.of(part[0]),
									FieldAccessType.of(part[1]),
									new FieldReference(
										(ClassName)values[part[2]],
										new FieldName((String)values[part[3]]),
										((ClassName)values[part[4]]).field()));
								break;
								
								// Invoked method
							case INVOKED_METHOD:
								v = new InvokedMethod(
									InvokeType.of(part[0]),
									new MethodHandle(
										(ClassName)values[part[1]],
										new MethodName(
											(String)values[part[2]]),
										(MethodDescriptor)values[part[3]]));
								break;
							
								// Method descriptor
							case METHOD_DESCRIPTOR:
								v = new MethodDescriptor(
									(String)values[part[0]]);
								break;
								
								// The method index
							case METHOD_INDEX:
								v = new MethodIndex(
									(ClassName)values[part[1]],
									new MethodName((String)values[part[2]]),
									(MethodDescriptor)values[part[3]]);
								break;
								
								// Long
							case LONG:
								v = (((long)(((Integer)values[part[0]])
										<< 32L)) |
									(((long)(((Integer)values[part[1]]) &
										0xFFFFFFFFL))));
								break;
								
								// Double
							case DOUBLE:
								v = Double.longBitsToDouble(
									(((long)(((Integer)values[part[0]])
										<< 32L)) |
									(((long)(((Integer)values[part[1]]) &
										0xFFFFFFFFL)))));
								break;
								
								// Used string
							case USED_STRING:
								v = new UsedString((String)values[part[0]]);
								break;
								
							default:
								throw new todo.OOPS(type.name());
						}
						break;
					
					default:
						throw new todo.OOPS(type.name());
				}
			}
			
			// {@squirreljme.error JC0c Invalid read of pool data.}
			catch (IllegalArgumentException|IOException e)
			{
				throw new InvalidClassFormatException("JC0c", e);
			}
			
			// Set data
			parts[i] = (part == null ? nopart : part);
			values[i] = v;
		}
		
		// Build
		return new MinimizedPool(offsets, types, parts, values);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedPoolBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;

/**
 * This class is used to build the constant pool for a minimized class.
 *
 * @since 2019/03/11
 */
@Deprecated
public final class MinimizedPoolBuilder
{
	/** Constant pool. */
	private final Map<Object, Integer> _pool =
		new LinkedHashMap<>();
	
	/** Parts list. */
	private final List<int[]> _parts =
		new ArrayList<>();
	
	/**
	 * Initializes the base pool.
	 *
	 * @since 2019/04/14
	 */
	{
		// Add null entry to mean nothing
		this._pool.put(null, 0);
		this._parts.add(new int[0]);
	}
	
	/**
	 * Adds the constant pool entry and returns the index to it.
	 *
	 * @param __v The entry to add.
	 * @return The index the entry is at.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public final int add(Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Field access
		if (__v instanceof AccessedField)
		{
			AccessedField af = (AccessedField)__v;
			FieldReference fr = af.field();
			return this.__add(__v,
				af.time().ordinal(),
				af.type().ordinal(),
				this.add(fr.className()),
				this.add(fr.memberName().toString()),
				this.add(fr.memberType().className()));
		}
		
		// Class name
		else if (__v instanceof ClassName)
		{
			// Write representation of array type and its component type to
			// make sure they are always added
			ClassName cn = (ClassName)__v;
			if (cn.isArray())
				return this.__add(__v,
					this.add(__v.toString()), this.add(cn.componentType()));
			
			// Not an array
			else
				return this.__add(__v,
					this.add(__v.toString()), 0);
		}
		
		// Class names
		else if (__v instanceof ClassNames)
		{
			// Adjust the value to map correctly
			ClassNames names = (ClassNames)__v;
			
			// Fill into indexes
			int n = names.size();
			int[] indexes = new int[n];
			for (int i = 0; i < n; i++)
				indexes[i] = this.add(names.get(i));
			
			// Add it now
			return this.__add(names, indexes);
		}
		
		// Record handle for the method
		else if (__v instanceof InvokedMethod)
		{
			InvokedMethod iv = (InvokedMethod)__v;
			MethodHandle mh = iv.handle();
			
			return this.__add(__v,
				iv.type().ordinal(),
				this.add(mh.outerClass()),
				this.add(mh.name().toString()),
				this.add(mh.descriptor()));
		}
		
		// Method descriptor, add parts of the descriptor naturally
		else if (__v instanceof MethodDescriptor)
		{
			MethodDescriptor md = (MethodDescriptor)__v;
			
			// Setup with initial string
			List<Integer> sub = new ArrayList<>();
			sub.add(this.add(__v.toString()));
			
			// Put in argument count
			FieldDescriptor[] args = md.arguments();
			sub.add(args.length);
			
			// Add return value
			FieldDescriptor rv = md.returnValue();
			sub.add((rv == null ? 0 : this.add(rv.className())));
			
			// Fill in arguments
			FieldDescriptor[] margs = md.arguments();
			for (FieldDescriptor marg : margs)
				sub.add(this.add(marg.className()));
			
			// Convert to integer
			int n = sub.size();
			int[] isubs = new int[n];
			for (int i = 0; i < n; i++)
				isubs[i] = sub.get(i);
			
			// Put in descriptor with all the pieces
			return this.__add(__v,
				isubs);
		}
		
		// Index of method
		else if (__v instanceof MethodIndex)
		{
			MethodIndex v = (MethodIndex)__v;
			return this.__add(__v,
				0x7FFF,
				this.add(v.inclass),
				this.add(v.name.toString()),
				this.add(v.type));
		}
		
		// Reference to constant pool table
		else if (__v instanceof ClassPool)
			return this.__add(__v,
				this.add(((ClassPool)__v).name));
		
		// String
		else if (__v instanceof String)
			return this.__add(__v,
				__v.hashCode() & 0xFFFF,
				((String)__v).length());
		
		// Primitives
		else if (__v instanceof Integer ||
			__v instanceof Float)
			return this.__add(__v);
		
		// Long
		else if (__v instanceof Long)
		{
			long v = (Long)__v;
			return this.__add(__v,
				this.add((int)(v >>> 32)),
				this.add((int)(v & 0xFFFFFFFF)));
		}
		
		// Double
		else if (__v instanceof Double)
		{
			long v = Double.doubleToRawLongBits((Double)__v);
			return this.__add(__v,
				this.add((int)(v >>> 32)),
				this.add((int)(v & 0xFFFFFFFF)));
		}
		
		// Used String
		else if (__v instanceof UsedString)
			return this.__add(__v,
				this.add(__v.toString()));
		
		// {@squirreljme.error JC0d Cannot add the specified entry to the
		// constant pool. (The class type)}
		else
			throw new IllegalArgumentException("JC0d " + __v.getClass());
	}
	
	/**
	 * Adds the entry to the pool and returns the passed value.
	 *
	 * @param __v The value to add.
	 * @return {@code __v}.
	 * @since 2019/04/14
	 */
	public final <V> V addSelf(V __v)
	{
		this.add(__v);
		return __v;
	}
	
	/**
	 * Gets the index of where the entry is stored in the pool.
	 *
	 * @param __v The entry to get.
	 * @return The index of the entry.
	 * @throws IllegalStateException If the entry is not in the pool.
	 * @since 2019/04/14
	 */
	public final int get(Object __v)
		throws IllegalStateException
	{
		Integer rv = this._pool.get(__v);
		if (rv == null)
			throw new IllegalStateException("JC3q " + __v);
		return rv;
	}
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @return The byte data representation.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes()
	{
		Map<Object, Integer> pool = this._pool;
		List<int[]> parts = this._parts;
		
		// Write data
		try
		{
			// Table type information
			ByteArrayOutputStream tbytes = new ByteArrayOutputStream();
			DataOutputStream tdos = new DataOutputStream(tbytes);
			
			// Table offset information
			ByteArrayOutputStream obytes = new ByteArrayOutputStream();
			DataOutputStream odos = new DataOutputStream(obytes);
			
			// Actual table data
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Guess where all the data will be written in the pool
			// tbytes + tdospadding + obytes
			int poolcount = pool.size();
			int reloff = poolcount + (poolcount & 1) + (poolcount * 2);
			
			// Write all the values in the pool, the value in the map is
			// ignored because that just stores the index identifier
			int pdx = 0;
			for (Map.Entry<Object, Integer> e: pool.entrySet())
			{
				Object value = e.getKey();
				
				// Get type and part information
				MinimizedPoolEntryType et = (pdx == 0 ?
					MinimizedPoolEntryType.NULL :
					MinimizedPoolEntryType.ofClass(value.getClass()));
				int[] part = parts.get(pdx++);
				
				// Have two pool entry formats, a wide one and a narrow one
				// This is to reduce the size of the constant pool in classes
				// where small values can be used instead
				// This adds extra types for parsing because otherwise having
				// variable ints and such will be very confusing and
				// complicated!
				int faketype = et.ordinal();
				switch (et)
				{
						// These are always fixed types and as such are never
						// wide
					case STRING:
					case INTEGER:
					case FLOAT:
						break;
					
						// If any reference part is outside of this basic
						// range then use wide values here
					default:
						// If there are lots of parts then this needs to take
						// up a larger area
						if (part.length > 127)
							faketype |= 0x80;
						
						// Scan parts
						for (int i : part)
							if (i < 0 || i > 127)
							{
								faketype |= 0x80;
								break;
							}
						break;
				}
				
				// Write entry type
				tdos.writeByte(faketype);
				
				// Align the data table to the nearest 4-byte boundary
				while (((reloff + ddos.size()) & 3) != 0)
					ddos.write(0);
				
				// Write position of the pool entry
				int dxo = reloff + ddos.size();
				odos.writeShort(Minimizer.__checkUShort(dxo));
				
				// Depends on the type used
				boolean iswide = ((faketype & 0x80) != 0);
				switch (et)
				{
					// This value should not be read
					case NULL:
						ddos.writeInt(0xFEFEFEFE);
						break;
					
						// String are special because they have actual
						// string data stored
					case STRING:
						{
							// Record hashCode and the String size as simple
							// fields to read. Note that even though there is
							// the UTF length, the length of the actual string
							// could be useful. But only keep the lowest part
							// as that will be "good enough"
							ddos.writeShort((short)part[0]);
							ddos.writeShort(Minimizer.__checkUShort(part[1]));
							
							// Write string UTF data
							ddos.writeUTF((String)value);
							
							// Write NUL terminator to make it C-like as
							// well
							ddos.write(0);
						}
						break;
						
						// Integer
					case INTEGER:
						ddos.writeInt((Integer)value);
						break;
						
						// Float
					case FLOAT:
						ddos.writeInt(
							Float.floatToRawIntBits((Float)value));
						break;
						
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_NAME:
					case CLASS_NAMES:
					case INVOKED_METHOD:
					case CLASS_POOL:
					case METHOD_DESCRIPTOR:
					case LONG:
					case DOUBLE:
					case USED_STRING:
					case METHOD_INDEX:
						{
							// Write number of parts
							int npart = part.length;
							if (iswide)
								ddos.writeShort(
									Minimizer.__checkUShort(npart));
							else
								ddos.writeByte(npart);
							
							// Write all the parts
							for (int i = 0; i < npart; i++)
								if (iswide)
									ddos.writeShort(Minimizer.__checkUShort(
										part[i]));
								else
									ddos.writeByte(part[i]);
						}
						break;
						
						// Should not occur
					default:
						throw new todo.OOPS(et.name());
				}
				
				// Round positions
				Minimizer.__dosRound(ddos);
			}
			
			// End of table padding for the type table?
			if ((poolcount & 1) != 0)
				tdos.writeByte(0xFF);
			
			// Merge the data bytes into the table then use the completed
			// table
			obytes.writeTo(tdos);
			dbytes.writeTo(tdos);
			return tbytes.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * Returns the pool size.
	 *
	 * @return The pool size.
	 * @since 2019/04/14
	 */
	public final int size()
	{
		return this._pool.size();
	}
	
	/**
	 * Internal add logic.
	 *
	 * @param __v The entry to add.
	 * @param __parts Parts which make up the entry.
	 * @return The index the entry is at.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	private final int __add(Object __v, int... __parts)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		Map<Object, Integer> pool = this._pool;
		
		// Does this entry pre-exist in the pool already?
		Integer pre = pool.get(__v);
		if (pre != null)
			return pre;
		
		// Otherwise it gets added at the end
		int rv = pool.size();
		pool.put(__v, rv);
		this._parts.add((__parts == null ? new int[0] : __parts.clone()));
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/MinimizedPoolEntryType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This represents the entry type in the pool.
 *
 * @since 2019/04/14
 */
public enum MinimizedPoolEntryType
{
	/** Nothing. */
	NULL,
	
	/** String. */
	STRING,
	
	/** Name of class. */
	CLASS_NAME,
	
	/** Class names (used for interfaces). */
	CLASS_NAMES,
	
	/** The constant pool for the given class. */
	CLASS_POOL,
	
	/** Accessed Field. */
	ACCESSED_FIELD,
	
	/** Invoked Method. */
	INVOKED_METHOD,
	
	/** Method Descriptor. */
	METHOD_DESCRIPTOR,
	
	/** Integer. */
	INTEGER,
	
	/** Float. */
	FLOAT,
	
	/** Long. */
	LONG,
	
	/** Double. */
	DOUBLE,
	
	/** A plain string that was used. */
	USED_STRING,
	
	/** The index of a method. */
	METHOD_INDEX,
	
	/** Class information. */
	CLASS_INFO_POINTER,
	
	/** A string which has been noted for debug purposes. */
	NOTED_STRING,
	
	/** End. */
	;
	
	/**
	 * Can this be in the runtime pool?
	 *
	 * @return If this can be in the runtime pool.
	 * @since 2019/07/20
	 */
	public final boolean isRuntime()
	{
		switch (this)
		{
			case NULL:
			case CLASS_INFO_POINTER:
			case CLASS_POOL:
			case ACCESSED_FIELD:
			case INVOKED_METHOD:
			case USED_STRING:
			case METHOD_INDEX:
			case NOTED_STRING:
				return true;
		}
		
		return false;
	}
	
	/**
	 * Can this be in the static pool?
	 *
	 * @return If this can be in the static pool.
	 * @since 2019/07/20
	 */
	public final boolean isStatic()
	{
		switch (this)
		{
			case NULL:
			case STRING:
			case CLASS_NAME:
			case CLASS_NAMES:
			case METHOD_DESCRIPTOR:
			case INTEGER:
			case FLOAT:
			case LONG:
			case DOUBLE:
				return true;
		}
		
		return false;
	}
	
	/**
	 * Returns the type for the specified index.
	 *
	 * @param __i The index to get.
	 * @return The type for this index.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @since 2019/04/17
	 */
	public static final MinimizedPoolEntryType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:		return MinimizedPoolEntryType.NULL;
			case 1:		return MinimizedPoolEntryType.STRING;
			case 2:		return MinimizedPoolEntryType.CLASS_NAME;
			case 3:		return MinimizedPoolEntryType.CLASS_NAMES;
			case 4:		return MinimizedPoolEntryType.CLASS_POOL;
			case 5:		return MinimizedPoolEntryType.ACCESSED_FIELD;
			case 6:		return MinimizedPoolEntryType.INVOKED_METHOD;
			case 7:		return MinimizedPoolEntryType.METHOD_DESCRIPTOR;
			case 8:		return MinimizedPoolEntryType.INTEGER;
			case 9:		return MinimizedPoolEntryType.FLOAT;
			case 10:	return MinimizedPoolEntryType.LONG;
			case 11:	return MinimizedPoolEntryType.DOUBLE;
			case 12:	return MinimizedPoolEntryType.USED_STRING;
			case 13:	return MinimizedPoolEntryType.METHOD_INDEX;
			case 14:	return MinimizedPoolEntryType.CLASS_INFO_POINTER;
			case 15:	return MinimizedPoolEntryType.NOTED_STRING;
		}
		
		// {@squirreljme.error JC0e Unknown pool type. (The type)}
		throw new IllegalArgumentException("JC0e " + __i);
	}
	
	/**
	 * Returns the entry type that is used for the specified class.
	 *
	 * @param __cl The class to check.
	 * @return The entry type for the class.
	 * @throws IllegalArgumentException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final MinimizedPoolEntryType ofClass(Class<?> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Easier to do it just by name
		switch (__cl.getName())
		{
			case "java.lang.String":
				return MinimizedPoolEntryType.STRING;
			case "java.lang.Integer":
				return MinimizedPoolEntryType.INTEGER;
			case "java.lang.Float":
				return MinimizedPoolEntryType.FLOAT;
			case "java.lang.Long":
				return MinimizedPoolEntryType.LONG;
			case "java.lang.Double":
				return MinimizedPoolEntryType.DOUBLE;
			case "dev.shadowtail.classfile.pool.AccessedField":
				return MinimizedPoolEntryType.ACCESSED_FIELD;
			case "dev.shadowtail.classfile.pool.ClassPool":
				return MinimizedPoolEntryType.CLASS_POOL;
			case "dev.shadowtail.classfile.pool.InvokedMethod":
				return MinimizedPoolEntryType.INVOKED_METHOD;
			case "net.multiphasicapps.classfile.ClassName":
				return MinimizedPoolEntryType.CLASS_NAME;
			case "net.multiphasicapps.classfile.ClassNames":
				return MinimizedPoolEntryType.CLASS_NAMES;
			case "List net.multiphasicapps.classfile.ClassName":
				return MinimizedPoolEntryType.CLASS_NAMES;
			case "net.multiphasicapps.classfile.MethodDescriptor":
				return MinimizedPoolEntryType.METHOD_DESCRIPTOR;
			case "dev.shadowtail.classfile.pool.UsedString":
				return MinimizedPoolEntryType.USED_STRING;
			case "dev.shadowtail.classfile.pool.MethodIndex":
				return MinimizedPoolEntryType.METHOD_INDEX;
			case "dev.shadowtail.classfile.pool.ClassInfoPointer":
				return MinimizedPoolEntryType.CLASS_INFO_POINTER;
			case "dev.shadowtail.classfile.pool.NotedString":
				return MinimizedPoolEntryType.NOTED_STRING;
			case "dev.shadowtail.classfile.pool.NullPoolEntry":
				return MinimizedPoolEntryType.NULL;
		}
		
		// {@squirreljme.error JC0f Class does not map to a pool entry
		// type. (The class)}
		throw new IllegalArgumentException("JC0f " + __cl);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/Minimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.RegisterList;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.xlate.DataType;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This takes an input class file and translates it to the minimized format
 * which is easier to use.
 *
 * @since 2019/03/10
 */
public final class Minimizer
{
	/** Counter for UUIDs. */
	private static volatile int _UUID_COUNTER =
		17;
	
	/** The class file to minimize. */
	protected final ClassFile input;
	
	/** The Jar or ROM backed pool, is optional. */
	protected final DualClassRuntimePoolBuilder jarpool;
	
	/** The local constant pool. */
	protected final DualClassRuntimePoolBuilder localpool =
		new DualClassRuntimePoolBuilder();
	
	/**
	 * Initializes the minimizer.
	 *
	 * @param __dp The dual constant pool to use, may be null.
	 * @param __cf The class to minimize.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	private Minimizer(DualClassRuntimePoolBuilder __dp, ClassFile __cf)
		throws NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		this.input = __cf;
		
		// This is the packing JAR/ROM pool, this may be null
		this.jarpool = __dp;
	}
	
	/**
	 * Performs the minimization process.
	 *
	 * @param __os The stream to write the result to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	private final void __run(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
			
		// The input class
		ClassFile input = this.input;
		
		// The output section
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// This is the relative pool that the class file uses
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Process all fields and methods
		__TempFields__[] fields = this.__doFields();
		__TempMethods__[] methods = this.__doMethods();
		
		// Initialize header section
		TableSectionOutputStream.Section header =
			output.addSection(MinimizedClassHeader.HEADER_SIZE_WITH_MAGIC);
		
		// Write magic number to specify this format
		header.writeInt(MinimizedClassHeader.MAGIC_NUMBER);
		
		// Unused, may be used later when needed
		header.writeShort(0);
		
		// The index of the instance method named __start
		header.writeByte(methods[1].findMethodIndex("__start"));
		
		// Data type of the class
		header.writeByte(DataType.of(input.thisName().field()).ordinal());
		
		// This may be null for Object
		ClassName supernamecn = input.superName();
		
		// Unused
		header.writeShort(0);
		
		// Store class information, such as the flags, name, superclass,
		// interfaces, class type, and version
		header.writeInt(input.flags().toJavaBits());
		header.writeUnsignedShortChecked(
			localpool.add(false, input.thisName()).index);
		header.writeUnsignedShortChecked((supernamecn == null ? 0 :
			localpool.add(false, supernamecn).index));
		header.writeUnsignedShortChecked(
			localpool.add(false, input.interfaceNames()).index);
		header.writeByte(input.type().ordinal());
		header.writeByte(input.version().ordinal());
		
		// Needed for debugging to figure out what file the class is in,
		// will be very useful
		String sfn = input.sourceFile();
		header.writeUnsignedShortChecked((sfn == null ? 0 :
			localpool.add(false, sfn).index));
		
		// Write static and instance field counts
		for (int i = 0; i < 2; i++)
		{
			__TempFields__ tf = fields[i];
			
			header.writeUnsignedShortChecked(tf._count);
			header.writeUnsignedShortChecked((tf._bytes + 3) & (~3));
			header.writeUnsignedShortChecked(tf._objects);
		}
		
		// Write static and instance method counts
		for (int i = 0; i < 2; i++)
		{
			__TempMethods__ tm = methods[i];
			
			header.writeUnsignedShortChecked(tm._count);
		}
		
		// Unused, the pool was here
		header.writeInt(0);
		header.writeInt(0);
		
		// Field locator
		for (int i = 0; i < 2; i++)
		{
			// Generate section
			TableSectionOutputStream.Section subsection =
				output.addSection(fields[i].getBytes(localpool), 4);
			
			// Write section details
			header.writeSectionAddressInt(subsection);
			header.writeSectionSizeInt(subsection);
		}
		
		// Method locator
		for (int i = 0; i < 2; i++)
		{
			// Generate section
			TableSectionOutputStream.Section subsection =
				output.addSection(methods[i].getBytes(localpool), 4);
			
			// Write section details
			header.writeSectionAddressInt(subsection);
			header.writeSectionSizeInt(subsection);
		}
		
		// Generate a UUID and write it
		long uuid = Minimizer.generateUUID();
		header.writeInt((int)(uuid >>> 32));
		header.writeInt((int)uuid);
		
		// Write absolute file size! This saves time in calculating how big
		// a file we have and we can just read that many bytes for all the
		// data areas or similar if needed
		header.writeFileSizeInt();
		
		// Not used anymore
		header.writeInt(0);
		
		// Where our pools are going
		TableSectionOutputStream.Section lpd = output.addSection();
		
		// Encode the local pool or the local pool on top of the JAR pool
		DualClassRuntimePoolBuilder jarpool = this.jarpool;
		DualPoolEncodeResult der = (jarpool == null ?
			DualPoolEncoder.encode(localpool, lpd) :
			DualPoolEncoder.encodeLayered(localpool, jarpool, lpd));
		
		// Static pool
		header.writeSectionAddressInt(lpd, der.staticpooloff);
		header.writeInt(der.staticpoolsize);
		
		// Run-time pool
		header.writeSectionAddressInt(lpd, der.runtimepooloff);
		header.writeInt(der.runtimepoolsize);
		
		// Write end magic number, which is at the end of the file
		TableSectionOutputStream.Section eofmagic = output.addSection(4);
		eofmagic.writeInt(MinimizedClassHeader.END_MAGIC_NUMBER);
		
		// Write resulting file
		output.writeTo(__os);
	}
	
	/**
	 * Process fields.
	 *
	 * @return The resulting fields, static and instance split into each.
	 * @since 2019/03/11
	 */
	private final __TempFields__[] __doFields()
	{
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Static and instance fields are split because they are stored
		// in different places
		__TempFields__[] rv = new __TempFields__[]{
			new __TempFields__(), new __TempFields__()};
		
		// Check if this is object or an array, so that special fields are
		// added
		boolean isobject = this.input.thisName().toString().
				equals("java/lang/Object"),
			isarray = this.input.thisName().isArray();
		
		// Perform some sorting to optimize slightly and make the layout a
		// bit friendlier
		List<Field> sorted = new ArrayList<>(this.input.fields());
		Collections.sort(sorted, new __MinimizerFieldSort__());
		
		// If this is an object, add the special class type (internal class
		// pointer) and the reference count. These are always in a fixed
		// order.
		if (isobject)
		{
			// (ClassInfo) Synthetic + Transient + Final
			sorted.add(0, new Field(new FieldFlags(0x1090),
				new FieldName("_class"),
				FieldDescriptor.INTEGER, null, null));
			
			// (Reference count) Synthetic + Transient + Volatile
			sorted.add(1, new Field(new FieldFlags(0x10c0),
				new FieldName("_refcount"),
				FieldDescriptor.INTEGER, null, null));
			
			// (monitor owning thread) Synthetic + Transient + Volatile
			sorted.add(2, new Field(new FieldFlags(0x10c0),
				new FieldName("_monitor"),
				FieldDescriptor.INTEGER, null, null));
			
			// (monitor enter count) Synthetic + Transient + Volatile
			sorted.add(3, new Field(new FieldFlags(0x10c0),
				new FieldName("_moncount"),
				FieldDescriptor.INTEGER, null, null));
		}
		
		// If an array, add the length of the array
		else if (isarray)
		{
			// Synthetic + Transient + Final
			sorted.add(0, new Field(new FieldFlags(0x1090),
				new FieldName("_length"),
				FieldDescriptor.INTEGER, null, null));
		}
		
		// Process each field
		for (Field f : sorted)
		{
			// These are stored in their own rows
			__TempFields__ temp = rv[(f.flags().isStatic() ? 0 : 1)];
			
			// Determine the size of this entry (and its alignment)
			PrimitiveType pt = f.type().primitiveType();
			int fsz = (pt == null ? 4 : pt.bytes());
			
			// If this is an object increase the object count, this is needed
			// by the garbage collector to determine the addresses to scan
			// However, the object class always has no objects in it
			if (!isobject && pt == null)
				temp._objects++;
			
			// Determine the base position and check if any alignment is needed
			// assuming types of a given size are always aligned
			int basep = (temp._bytes + (fsz - 1)) & ~(fsz - 1);
			
			// Constant value may be null, but if it is not then add it
			// to the pool
			ConstantValue cval = f.constantValue();
			
			// Add field properties
			localpool.add(false, f.name().toString());
			localpool.add(false, f.type().className());
			
			// Boxed value, if used
			if (cval != null)
				localpool.add(false, cval.boxedValue());
			
			// Build field information
			MinimizedField q;
			temp._fields.add((q = new MinimizedField(
				f.flags().toJavaBits(),
				basep,
				fsz,
				f.name(),
				f.type(),
				(cval == null ? null : cval.boxedValue()))));
			
			// Handle table sizes
			temp._bytes = basep + fsz;
			temp._count++;
		}
		
		// Align fields sizes to 4-bytes always so that the next class on
		// top of this has aligned field data
		for (__TempFields__ temp : rv)
			temp._bytes = (temp._bytes + 3) & ~3;
		
		// Return static and instance fields
		return rv;
	}
	
	/**
	 * Processes all methods within the class.
	 *
	 * @return The processed static and instance methods.
	 * @since 2019/03/13
	 */
	private final __TempMethods__[] __doMethods()
	{
		DualClassRuntimePoolBuilder localpool = this.localpool;
		ClassFile input = this.input;
		
		// Split static and instance methods to make them easier to locate
		// accordingly
		__TempMethods__[] rv = new __TempMethods__[]{
			new __TempMethods__(input.thisName()),
			new __TempMethods__(input.thisName())};
		
		// Process each method
		for (Method m : input.methods())
		{
			// These are stored in their own rows
			__TempMethods__ temp = rv[(m.flags().isStatic() ? 0 : 1)];
			
			// Need to translate and serialize the byte code into a register
			// form and remap any used references.
			MethodFlags mf = m.flags();
			byte[] transcode = null;
			if (!mf.isAbstract() && !mf.isNative())
			{
				// The minified classes use register code since it is easier
				// to handle by the VM
				NativeCode rc = m.nativeCode();
				
				// Encode data to bytes
				try
				{
					// Translate code
					transcode = this.__translateCode(rc);
				}
				
				// {@squirreljme.error JC0j Error during translation of the
				// specified method. (The current class; The method)}
				catch (InvalidClassFormatException e)
				{
					throw new InvalidClassFormatException("JC4s " +
						input.thisName() + " " + m.nameAndType(), e);
				}
				
				// {@squirreljme.error JC0k IOException translating code.}
				catch (IOException e)
				{
					throw new RuntimeException("JC0k", e);
				}
			}
			
			// Add name and type to the pool
			localpool.add(false, m.name().toString());
			localpool.add(false, m.type());
			
			// Add method
			MinimizedMethod q;
			temp._methods.add((q = new MinimizedMethod(mf.toJavaBits(),
				temp._count,
				m.name(),
				m.type(),
				transcode)));
			
			// Quick count for used methods
			temp._count++;
		}
		
		return rv;
	}
	
	/**
	 * Translates code.
	 *
	 * @param __rc The register code used.
	 * @param __dos The stream to write to.
	 * @return The resulting stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/23
	 */
	private final byte[] __translateCode(NativeCode __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		// Where stuff gets written to
		ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
		DataOutputStream dos = new DataOutputStream(baos);
		
		// Positions where all the instructions are in the byte array
		int cdn = __rc.length();
		int[] indexpos = new int[cdn];
		
		// Locations which have jump targets to be replaced
		List<__Jump__> jumpreps = new LinkedList<>();
		
		// Operations will reference this constant pool
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Go through each instruction
		for (int cdx = 0; cdx < cdn; cdx++)
		{
			// Get instruction here
			NativeInstruction i = __rc.get(cdx);
			
			// Record that the instruction is at this position
			int baseaddr;
			indexpos[cdx] = (baseaddr = dos.size());
			
			// Operation to handle
			int op = i.operation();
			
			// Write operation
			dos.write(op);
			
			// Encode arguments
			ArgumentFormat[] format = i.argumentFormat();
			for (int a = 0, an = i.argumentCount(),
				afn = format.length; a < an; a++)
			{
				// Read argument
				Object v = i.argument(a);
				
				// Write the format
				switch (format[a])
				{
						// Variable 16-bit unsigned integer
					case VUINT:
					case VUREG:
					case VPOOL:
					case VJUMP:
						// Remap value
						int vm = 0;
						switch (format[a])
						{
							case VPOOL:
								try
								{
									vm = localpool.add(true, v).index;
								}
								catch (IllegalArgumentException e)
								{
									// {@squirreljme.error JC4g Could not add
									// pool entry because it is not valid.
									// (The current instruction)}
									throw new InvalidClassFormatException(
										"JC4g " + i, e);
								}
								break;
								
							case VJUMP:
								{
									// Store for later modification
									jumpreps.add(new __Jump__(cdx, dos.size(),
										((InstructionJumpTarget)v).target()));
									
									// Do not know if the full address can fit
									vm = 32767;
								}
								break;
							
							case VUINT:
							case VUREG:
								vm = ((Number)v).intValue();
								break;
						}
						
						// Fits in 7-bit value
						if (vm >= 0 && vm <= 127)
							dos.write(vm);
						
						// Fits in 15-bit value
						else if (vm >= 128 && vm <= 32767)
						{
							dos.write(0x80 | (vm >> 8));
							dos.write(vm & 0xFF);
						}
						
						// {@squirreljme.error JC0l 15-bit integer out of
						// range. (The value; The instruction index; The
						// invalid instruction)}
						else
							throw new InvalidClassFormatException(
								"JC0l " + vm + " " + cdx + " " + i);
						break;
						
						// Register List
					case REGLIST:
						{
							// Scan register list to see if it is "wide", if
							// it is then the wide format is used
							RegisterList rl = (RegisterList)v;
							int rn = rl.size();
							boolean wide = (rn > 127);
							for (int r = 0; r < rn; r++)
							{
								int rv = rl.get(r);
								if (rv < 0 || rv > 127)
								{
									wide = true;
									break;
								}
							}
							
							// Wide
							if (wide)
							{
								// Count
								dos.write(0x80 | (rn >> 8));
								dos.write(rn & 0xFF);
								
								// Write as shorts
								for (int r = 0; r < rn; r++)
									dos.writeShort(rl.get(r));
							}
							
							// Narrow
							else
							{
								// Count
								dos.write(rn);
								
								// Write as bytes
								for (int r = 0; r < rn; r++)
									dos.write(rl.get(r));
							}
						}
						break;
						
						// 32-bit int
					case INT32:
						dos.writeInt(((Number)v).intValue());
						break;
					
						// 64-bit long
					case INT64:
						dos.writeLong(((Number)v).longValue());
						break;
					
						// 32-bit float
					case FLOAT32:
						dos.writeInt(Float.floatToRawIntBits(
							((Number)v).floatValue()));
						break;
					
						// 64-bit double
					case FLOAT64:
						dos.writeLong(Double.doubleToRawLongBits(
							((Number)v).doubleValue()));
						break;
					
						// Unknown
					default:
						throw new todo.OOPS(i.toString());
				}
			}
		}
		
		// Generate code array
		byte[] rv = baos.toByteArray();
		int codesize = rv.length;
		
		// Replace jumps
		for (__Jump__ j : jumpreps)
		{
			// Calculate target
			int cdx = j.cdx,
				ai = j.dss,
				origjt = j.jt,
				jt = indexpos[origjt] - indexpos[cdx];
			
			// Wide
			if ((rv[ai] & 0x80) != 0)
			{
				rv[ai] = (byte)(0x80 | (jt >> 8));
				rv[ai + 1] = (byte)(jt & 0xFF);
			}
			
			// Narrow
			else
				rv[ai] = (byte)jt;
		}
		
		// Return array
		return rv;
	}
	
	/**
	 * Generates a UUID to identify the minimized class.
	 *
	 * @return The generated UUID.
	 * @since 2019/04/27
	 */
	public static final long generateUUID()
	{
		// Hopefully this seed is good enough?
		Random rand = new Random(System.nanoTime() +
			(System.currentTimeMillis() << 24) + (++Minimizer._UUID_COUNTER));
		
		// Skip a random amount of values to run it for a bit
		for (int i = 0, n = rand.nextInt(32 + rand.nextInt(32)); i < n; i++)
			rand.nextInt();
		
		// Just use the next long value
		return rand.nextLong();
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class as a byte array.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final byte[] minimize(ClassFile __cf)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return Minimizer.minimize(null, __cf);
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __dp Dual constant pool, this may be {@code null}.
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class as a byte array.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final byte[] minimize(DualClassRuntimePoolBuilder __dp,
		ClassFile __cf)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		// Minimization is straight to a byte format so just read that in
		// again
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Output minimized code to the byte array
			Minimizer.minimize(__dp, __cf, baos);
			
			// The class data is in the resulting byte array
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the class file so that it is in a more compact format as
	 * needed.
	 *
	 * @param __cf The class file to minimize.
	 * @param __os The stream to write the minimized format to.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final void minimize(ClassFile __cf, OutputStream __os)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		Minimizer.minimize(null, __cf, __os);
	}
	
	/**
	 * Minimizes the class file so that it is in a more compact format as
	 * needed.
	 *
	 * @param __dp Dual constant pool, may be {@code null}.
	 * @param __cf The class file to minimize.
	 * @param __os The stream to write the minimized format to.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final void minimize(DualClassRuntimePoolBuilder __dp,
		ClassFile __cf, OutputStream __os)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__cf == null || __os == null)
			throw new NullPointerException("NARG");
		
		new Minimizer(__dp, __cf).__run(__os);
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final MinimizedClassFile minimizeAndDecode(ClassFile __cf)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		// Minimize raw byte array
		try
		{
			return MinimizedClassFile.decode(Minimizer.minimize(__cf));
		}
		
		// {@squirreljme.error JC0m Could not minimize class due to a read
		// or write error.}
		catch (IOException e)
		{
			throw new RuntimeException("JC0m", e);
		}
	}
	
	/**
	 * Writes variable size unsigned short, only 15-bits are possible to be
	 * written.
	 *
	 * @param __dos The stream to write to.
	 * @param __v The value to write.
	 * @throws IOException ON write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final void writeVUShort(DataOutputStream __dos, int __v)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Single byte form (7-bit)
		if (__v >= 0 && __v < 127)
			__dos.writeByte(__v);
		
		// Double byte form (15-bits)
		else if (__v >= 128 && __v < 32768)
		{
			__dos.writeByte(0x80 | (__v >>> 8));
			__dos.writeByte(__v & 0xFF);
		}
		
		// {@squirreljme.error JC0n Variable unsigned short out of range.
		// (The value)}
		else
			throw new InvalidClassFormatException("JC0n " + __v);
	}
	
	/**
	 * Checks that the unsigned short is in range.
	 *
	 * @param __v The value to check.
	 * @return {@code __v}.
	 * @throws InvalidClassFormatException If the short is out of range.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __checkUShort(int __v)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC0o Unsigned short out of range. (The value)}
		if (__v < 0 || __v > 65535)
			throw new InvalidClassFormatException("JC0o " + __v);
		return __v;
	}
	
	/**
	 * Compacts a table of shorts or bytes to a run-length encoded form.
	 *
	 * @param __st The input table.
	 * @param __bt The byte table.
	 * @return The resulting RLE encoded byte data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	@Deprecated
	private static final byte[] __compact(short[] __st, byte[] __bt)
		throws IOException, NullPointerException
	{
		if (__st == null && __bt == null)
			throw new NullPointerException("NARG");
		
		// Using shorts or bytes
		boolean shorts = (__st != null);
		int len = (shorts ? __st.length : __bt.length);
		
		// Target stream
		ByteArrayOutputStream baos = new ByteArrayOutputStream(len);
		DataOutputStream dos = new DataOutputStream(baos);
		
		// Go through every entry, compacting it accordingly
		int lastline = -1,
			lastpc = 0;
		for (int i = 0, n = len; i < n; i++)
		{
			int nowline = (shorts ? __st[i] : __bt[i]);
			
			// If there is a really long stretch of instructions which point
			// to the same exact data, force it to be reset so that way the
			// number table after this point is not complete garbage
			// Note that 255 is the end of data marker
			boolean force = ((i == 0) || ((i - lastpc) >= 254));
			
			// Line number has changed, need to encode the information
			if (force || nowline != lastline)
			{
				// Since multiple instruction addresses can share data info,
				// to reduce the size of the table just record an offset from
				// the last PC address
				// Just a single byte is used for the difference since in
				// general these ranges will be small
				int diff = i - lastpc;
				dos.write(diff);
				
				// Write data position here, just as a 16-bit value without
				// any different encoding since values can jump all over the
				// place
				if (shorts)
					dos.writeShort(nowline);
				else
					dos.writeByte(nowline);
				
				// For next time
				lastline = nowline;
				lastpc = i;
			}
		}
		
		// A difference of 255 means end of data
		dos.write(0xFF);
		
		// Return result
		return baos.toByteArray();
	}
	
	/**
	 * Pads the output stream.
	 *
	 * @param __dos The stream to pad.
	 * @return The current size of the output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __dosRound(DataOutputStream __dos)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Add padding
		while ((__dos.size() & 3) != 0)
			__dos.write(0);
		return __dos.size();
	}
	
	/**
	 * Adds length data to the relative offset.
	 *
	 * @param __rel Current relative offset.
	 * @param __v The offset to add.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __relAdd(int __rel, int __v)
	{
		__rel += __v;
		return (__rel + 3) & (~3);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/__Jump__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This represents a jump replacement.
 *
 * @since 2019/05/29
 */
final class __Jump__
{
	/** Instruction index. */
	public final int cdx;
	
	/** Data position size. */
	public final int dss;
	
	/** The jump target. */
	public final int jt;
	
	/**
	 * Initializes the jump target.
	 *
	 * @param __cdx The instruction index.
	 * @param __dss The DSS.
	 * @param __jt The jump target.
	 * @since 2019/05/29
	 */
	__Jump__(int __cdx, int __dss, int __jt)
	{
		this.cdx = __cdx;
		this.dss = __dss;
		this.jt = __jt;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/__MinimizerFieldSort__.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import java.util.Comparator;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * This is used to sort the input fields according to their size and type so
 * that they are grouped together and aligned together.
 *
 * Name sorting is used last.
 *
 * @since 2019/03/11
 */
final class __MinimizerFieldSort__
	implements Comparator<Field>
{
	/**
	 * Compares two fields.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @since 2019/03/11
	 */
	public int compare(Field __a, Field __b)
	{
		// Make objects always first so we can quickly scan through objects
		// when clearing references out
		PrimitiveType pa = __a.type().primitiveType(),
			pb = __b.type().primitiveType();
		if (pa == null && pb != null)
			return -1;
		else if (pa != null && pb == null)
			return 1;
		
		// Compare sizes first to force alignables to be close to each other
		// Make it so larger fields are always first since they take up the
		// most room, it is easier to compact smaller fields following because
		// it should take up less room
		int sa = (pa == null ? 4 : pa.bytes()),
			sb = (pb == null ? 4 : pb.bytes());
		int rv = sb - sa;
		if (rv != 0)
			return rv;
		
		// Then sort by the descriptor so like-types are close to each other
		rv = __a.type().compareTo(__b.type());
		if (rv != 0)
			return rv;
		
		// Then fallback to name
		return __a.name().compareTo(__b.name());
	}
}

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

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * Stores temporary field data as it is processed.
 *
 * @since 2019/03/11
 */
final class __TempFields__
{
	/** The fields in the table. */
	final List<MinimizedField> _fields =
		new ArrayList<>();
	
	/** The number of fields in the table. */
	int _count;
	
	/** The current byte size of the field table. */
	int _bytes;
	
	/** The total number of objects in the table. */
	int _objects;
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @param __pool The constant pool.
	 * @return The byte data representation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes(DualClassRuntimePoolBuilder __pool)
		throws NullPointerException
	{
		if (__pool == null)
			throw new NullPointerException("NARG");
		
		// The resulting table
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Write
		try
		{
			// Table of contents data
			TableSectionOutputStream.Section toc = output.addSection();
			
			// Actual table data
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Write field information
			for (MinimizedField m : this._fields)
			{
				// 16-bytes
				toc.writeInt(m.flags);
				toc.writeUnsignedShortChecked(m.offset);
				toc.writeUnsignedShortChecked(m.size);
				toc.writeUnsignedShortChecked(
					__pool.add(false, m.name.toString()).index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, m.type.className()).index);
				toc.writeUnsignedShortChecked((m.value == null ? 0 :
					__pool.add(false, m.value).index));
				toc.writeByte(m.datatype.ordinal());
				toc.writeByte(0);
			}
			
			// Write end of table
			toc.writeInt(0xFFFFFFFF);
			
			// Build output data
			return output.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
}

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

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * Contains temporary method information.
 *
 * @since 2019/03/13
 */
final class __TempMethods__
{
	/** The name of this class. */
	protected final ClassName classname;
	
	/** The methods in this table. */
	final List<MinimizedMethod> _methods =
		new ArrayList<>();
	
	/** The number of methods that are available. */
	int _count;
	
	/**
	 * Initializes.
	 *
	 * @param __cn The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	__TempMethods__(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
	}
	
	/**
	 * Finds the method by the given name.
	 *
	 * @param __name The name to locate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final int findMethodIndex(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		List<MinimizedMethod> methods = this._methods;
		for (int i = 0, n = methods.size(); i < n; i++)
			if (__name.equals(methods.get(i).nameAndType().name().toString()))
				return i;
		
		return -1;
	}
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @param __pool The constant pool.
	 * @return The byte data representation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes(DualClassRuntimePoolBuilder __pool)
		throws NullPointerException
	{
		if (__pool == null)
			throw new NullPointerException("NARG");
		
		// Build into sections
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Write
		MinimizedMethod current = null;
		try
		{
			// Methods to process
			List<MinimizedMethod> methods = this._methods;
			
			// Table of contents which represents each method
			TableSectionOutputStream.Section toc = output.addSection();
			
			// Format every method
			for (int i = 0, n = methods.size(); i < n; i++)
			{
				// Get the method to process
				current = methods.get(i);
				
				// Write all of the method code into its own section
				TableSectionOutputStream.Section codesection = null;
				byte[] rawcode = current._code;
				if (rawcode != null)
				{
					// Add aligned section for this code
					codesection = output.addSection(
						TableSectionOutputStream.VARIABLE_SIZE, 4);
					
					// Write all of the code here
					codesection.write(rawcode);
				}
				
				// Flags, name, and type
				toc.writeInt(current.flags);
				toc.writeUnsignedShortChecked(current.index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, current.name.toString()).index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, current.type).index);
				
				// Code section if one exists
				if (codesection != null)
				{
					toc.writeSectionAddressInt(codesection);
					toc.writeSectionSizeInt(codesection);
				}
				
				// There is no code
				else
				{
					toc.writeInt(0);
					toc.writeInt(0);
				}
				
				// Padding to align flags to int
				toc.writeShort(0);
			}
			
			// Write end of table
			toc.writeInt(0xFFFFFFFF);
			
			// Output as a byte array
			return output.toByteArray();
		}
		
		// {@squirreljme.error JC0p Could not process the method. (The method
		// this stopped at)}
		catch (InvalidClassFormatException|IOException e)
		{
			throw new InvalidClassFormatException("JC0p " + current, e);
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/mini/package-info.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the support for the creation of minitature (compressed)
 * classes which contain easy to read by computer formats and only the
 * required parts of the class that are used to execute code. It is meant to
 * be easier to use for virtual machines without needing to worry too much
 * about the class file format.
 *
 * @since 2019/03/10
 */

package dev.shadowtail.classfile.mini;

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/ArgumentFormat.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * This represents the type of argument that is used.
 *
 * @since 2019/04/16
 */
public enum ArgumentFormat
{
	/** Variable unsigned int. */
	VUINT,
	
	/** Variable register (unsigned int). */
	VUREG,
	
	/** Variable pool entry. */
	VPOOL,
	
	/** Variable jump entry. */
	VJUMP,
	
	/** Register list. */
	REGLIST,
	
	/** 32-bit integer. */
	INT32,
	
	/** 64-bit integer. */
	INT64,
	
	/** 32-bit float. */
	FLOAT32,
	
	/** 64-bit float. */
	FLOAT64,
	
	/** End. */
	;
	
	/**
	 * Returns an array of all the formats.
	 *
	 * @param __a The input formats.
	 * @return {@code __a}.
	 * @since 2019/04/16
	 */
	public static final ArgumentFormat[] of(ArgumentFormat... __a)
	{
		return (__a == null ? new ArgumentFormat[0] : __a);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/ClassAndLabel.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import net.multiphasicapps.classfile.ClassName;

/**
 * This stores a class and a label.
 *
 * @since 2019/04/13
 */
public final class ClassAndLabel
{
	/** The name of the class. */
	public final ClassName classname;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The class name.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public ClassAndLabel(ClassName __n, NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.classname = __n;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassAndLabel))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		ClassAndLabel o = (ClassAndLabel)__o;
		return this.classname.equals(o.classname) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.classname.hashCode() ^
				this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/ClassStackAndLabel.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.JavaStackState;
import java.lang.ref.Reference;
import net.multiphasicapps.classfile.ClassName;

/**
 * This stores a class, a stack state, and a label.
 *
 * @since 2019/04/11
 */
public final class ClassStackAndLabel
{
	/** The name of the class. */
	public final ClassName classname;
	
	/** The state of the resulting stack. */
	public final JavaStackState stack;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The class name.
	 * @param __s The stack state.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public ClassStackAndLabel(ClassName __n, JavaStackState __s,
		NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __s == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.classname = __n;
		this.stack = __s;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassStackAndLabel))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		ClassStackAndLabel o = (ClassStackAndLabel)__o;
		return this.classname.equals(o.classname) &&
			this.stack.equals(o.stack) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.classname.hashCode() ^
				this.stack.hashCode() ^ this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/EnqueueAndLabel.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import java.lang.ref.Reference;

/**
 * This contains an enqueue and a label.
 *
 * @since 2019/04/24
 */
public final class EnqueueAndLabel
{
	/** The enqueue. */
	public final JavaStackEnqueueList enqueue;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The enqueue used.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	public EnqueueAndLabel(JavaStackEnqueueList __n, NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.enqueue = __n;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof EnqueueAndLabel))
			return false;
		
		EnqueueAndLabel o = (EnqueueAndLabel)__o;
		return this.enqueue.equals(o.enqueue) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.enqueue.hashCode() ^
				this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/InvalidInstructionException.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 dev.shadowtail.classfile.nncc;

import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This is thrown when an instruction is not valid.
 *
 * @since 2019/06/13
 */
public class InvalidInstructionException
	extends InvalidClassFormatException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/06/13
	 */
	public InvalidInstructionException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(Throwable __c)
	{
		super(__c);
	}
}

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

package dev.shadowtail.classfile.nncc;

import java.util.Iterator;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This is similar to {@link ByteCode} except that it instead of using a
 * stack for intermediate Java operations, this instead uses registers. This
 * provides a more concise and easier to use format by virtual machines.
 *
 * @see ByteCode
 * @since 2019/03/09
 */
public final class NativeCode
	implements Iterable<NativeInstruction>
{
	/** The zero register. */
	public static final int ZERO_REGISTER =
		0;
	
	/** The return value register (two slots, 1 + 2). */
	public static final int RETURN_REGISTER =
		1;
	
	/** Second return register. */
	public static final int RETURN_TWO_REGISTER =
		2;
	
	/** The exception register. */
	public static final int EXCEPTION_REGISTER =
		3;
	
	/** The pointer containing static field data. */
	public static final int STATIC_FIELD_REGISTER =
		4;
	
	/** Register which represents the current thread of execution. */
	public static final int THREAD_REGISTER =
		5;
	
	/** Base for local registers (locals start here). */
	public static final int LOCAL_REGISTER_BASE =
		6;
	
	/** The register containing the constant pool. */
	public static final int POOL_REGISTER =
		6;
	
	/** The register which contains the next pool pointer to use. */
	public static final int NEXT_POOL_REGISTER =
		7;
	
	/** The register of the first argument. */
	public static final int ARGUMENT_REGISTER_BASE =
		8;
	
	/** Maximum number of registers possible to use. */
	public static final int MAX_REGISTERS =
		64;
	
	/** This bit XORed NEG bit == set, means memory access is volatile. */
	@Deprecated
	public static final int MEMORY_OFF_VOLATILE_BIT =
		0x80000000;
	
	/**
	 * This bit is just used to signal that the offset is negative. After the
	 * volatility has been determined, the volatile bit is set to the value
	 * of this bit then execution continues.
	 */
	public static final int MEMORY_OFF_NEG_BIT =
		0x40000000;
	
	/** Mask to access the offset value. */
	public static final int MEMORY_OFF_VALUE_MASK =
		0x7FFFFFFF;
	
	/** Instructions for this code. */
	private final NativeInstruction[] _instructions;
	
	/**
	 * Initializes the register code.
	 *
	 * @param __i The associated instructions.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeCode(NativeInstruction[] __i)
		throws NullPointerException
	{
		__i = (__i == null ? new NativeInstruction[0] : __i.clone());
		for (NativeInstruction i : __i)
			if (i == null)
				throw new NullPointerException("NARG");
		
		this._instructions = __i;
	}
	
	/**
	 * Gets the instruction at this index.
	 *
	 * @param __dx The index to get.
	 * @return The register at this index.
	 * @since 2019/03/26
	 */
	public final NativeInstruction get(int __dx)
	{
		return this._instructions[__dx];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/23
	 */
	@Override
	public final Iterator<NativeInstruction> iterator()
	{
		return UnmodifiableIterator.<NativeInstruction>of(
			this._instructions);
	}
	
	/**
	 * Returns the length of the register code.
	 *
	 * @return The register code length.
	 * @since 2019/03/26
	 */
	public final int length()
	{
		return this._instructions.length;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/NativeCodeBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.InstructionJumpTarget;

/**
 * This is used to build {@link NativeCode} and add instructions to it.
 *
 * @since 2019/03/16
 */
public final class NativeCodeBuilder
{
	/** Label positions. */
	final Map<NativeCodeLabel, Integer> _labels =
		new LinkedHashMap<>();
	
	/** Temporary instruction layout. */
	final Map<Integer, Point> _points =
		new LinkedHashMap<>();
	
	/** Next address to use. */
	int _nextaddr;
	
	/**
	 * Initializes the code builder at the default start address.
	 *
	 * @since 2019/03/22
	 */
	public NativeCodeBuilder()
	{
		this._nextaddr = 0;
	}
	
	/**
	 * Initializes the code builder at the given start address.
	 *
	 * @param __pc The address to start at.
	 * @since 2019/03/22
	 */
	public NativeCodeBuilder(int __pc)
	{
		this._nextaddr = __pc;
	}
	
	/**
	 * Adds a new instruction.
	 *
	 * @param __op The operation to add.
	 * @param __args The arguments to the operation.
	 * @return The resulting temporary instruction.
	 * @throws IllegalArgumentException If the argument count is incorrect.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/16
	 */
	public final NativeInstruction add(int __op, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		// Needed for argument format check
		ArgumentFormat[] afmt = NativeInstruction.argumentFormat(__op);
		int fnar = afmt.length;
		
		// Build instruction
		NativeInstruction rv = new NativeInstruction(__op, __args);
		
		// {@squirreljme.error JC0q Operation has an incorrect number of
		// arguments. (The instruction)}
		if (fnar != __args.length)
			throw new IllegalArgumentException("JC0q " + rv);
		
		// Check format
		for (int i = 0; i < fnar; i++)
		{
			// Cannot be null
			Object o = __args[i];
			if (o == null)
				throw new NullPointerException("NARG");
			
			// Integer value?
			int oi = ((o instanceof Number) ? ((Number)o).intValue() : -1);
			
			// Make sure values are good
			switch (afmt[i])
			{
					// {@squirreljme.error JC0r Use of register which is out
					// of range of the maximum register count.
					// (The instruction)}
				case VUREG:
					if (oi < 0 || oi >= NativeCode.MAX_REGISTERS)
						throw new IllegalArgumentException("JC0r " + rv);
					break;
				
					// {@squirreljme.error JC0s Cannot jump to a non-label.
					// (The instruction)}
				case VJUMP:
					if (!(o instanceof NativeCodeLabel))
						throw new IllegalArgumentException("JC0s " + rv);
					break;
			}
		}
		
		// Create instruction
		int atdx = this._nextaddr++;
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("@%d -> %s %s", atdx,
				NativeInstruction.mnemonic(__op), Arrays.asList(__args));
			
		// Store all information
		this._points.put(atdx, new Point(rv));
		return rv;
	}
	
	/**
	 * Adds a copy from one register to another.
	 *
	 * @param __from The source.
	 * @param __to The destination.
	 * @return The resulting instruction.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addCopy(int __from, int __to)
	{
		return this.add(NativeInstructionType.COPY,
			__from, __to);
	}
	
	/**
	 * Adds an integer comparison instruction.
	 *
	 * @param __ct The type of comparison to make
	 * @param __a The first register.
	 * @param __b The register to compare against.
	 * @param __jt The target of the jump.
	 * @return The resulting instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addIfICmp(CompareType __ct, int __a,
		int __b, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__ct == null || __jt == null)
			throw new NullPointerException("NARG");
		
		// Build operation
		return this.add(NativeInstructionType.IF_ICMP |
			__ct.ordinal(), __a, __b, __jt);
	}
	
	/**
	 * Adds a jump if the given register is not zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public final NativeInstruction addIfNonZero(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.NOT_EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is positive.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	public final NativeInstruction addIfPositive(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.GREATER_THAN, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addIfZero(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a goto which goes to the following location.
	 *
	 * @param __jt The target of the jump.
	 * @return The resulting instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addGoto(NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.TRUE, NativeCode.ZERO_REGISTER,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a math via constant operation.
	 *
	 * @param __jt The Java type.
	 * @param __mf The math function.
	 * @param __a Register A.
	 * @param __b Constant B.
	 * @param __c The result.
	 * @return The resulting register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/08
	 */
	public final NativeInstruction addMathConst(StackJavaType __jt,
		MathType __mf, int __a, Number __b, int __c)
		throws NullPointerException
	{
		if (__jt == null || __mf == null || __b == null)
			throw new NullPointerException("NARG");
		
		int op;
		switch (__jt)
		{
			case INTEGER:
				op = NativeInstructionType.MATH_CONST_INT;
				break;
				
				// {@squirreljme.error JC0t May only do math on integer.}
			case LONG:
			case FLOAT:
			case DOUBLE:
				throw new RuntimeException("JC0t");
			
			default:
				throw new todo.OOPS(__jt.name());
		}
		
		// Build operation
		int rop = op | __mf.ordinal();
		return this.add(rop, __a, __b, __c);
	}
	
	/**
	 * Adds a math via register operation.
	 *
	 * @param __jt The Java type.
	 * @param __mf The math function.
	 * @param __a Register A.
	 * @param __b Register B.
	 * @param __c The result.
	 * @return The resulting register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/08
	 */
	public final NativeInstruction addMathReg(StackJavaType __jt,
		MathType __mf, int __a, int __b, int __c)
		throws NullPointerException
	{
		if (__jt == null || __mf == null)
			throw new NullPointerException("NARG");
		
		int op;
		switch (__jt)
		{
			case INTEGER:
				op = NativeInstructionType.MATH_REG_INT;
				break;
				
				// {@squirreljme.error JC0u May only do math on integer.}
			case LONG:
			case FLOAT:
			case DOUBLE:
				throw new RuntimeException("JC0u");
			
			default:
				throw new todo.OOPS(__jt.name());
		}
		
		// Build operation
		int rop = op | __mf.ordinal();
		return this.add(rop, __a, __b, __c);
	}
	
	/**
	 * Adds memory offset by constant.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addMemoryOffConst(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0v Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0v");
		
		return this.add(NativeInstructionType.MEMORY_OFF_ICONST |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by constant, using Java format.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public final NativeInstruction addMemoryOffConstJava(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0w Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0w");
		
		return this.add(NativeInstructionType.MEMORY_OFF_ICONST_JAVA |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by register.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to load/store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addMemoryOffReg(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0x Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0x");
		
		// Generate
		return this.add(NativeInstructionType.MEMORY_OFF_REG |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by register, using Java format.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public final NativeInstruction addMemoryOffRegJava(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0y Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0y");
		
		// Generate
		return this.add(NativeInstructionType.MEMORY_OFF_REG_JAVA |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Builds the register code, all references to other portions in the
	 * code itself are resolved.
	 *
	 * @return The built register code.
	 * @since 2019/03/22
	 */
	public final NativeCode build()
	{
		// Labels which point to addresses
		Map<NativeCodeLabel, Integer> labels = this._labels;
		
		// If there are any jump points which refer to the instruction index
		// directly following it, then remove the jump.
		// Also possibly perform other modifications
		List<Point> in = new ArrayList<>(this._points.values());
		for (int i = in.size() - 1; i >= 0; i--)
		{
			// Get the instruction and its various properties
			Point point = in.get(i);
			NativeInstruction ri = point.instruction;
			int rie = ri.encoding();
			
			NativeCodeLabel jt = null;
			
			// Depends on the encoding
			switch (rie)
			{
				case NativeInstructionType.IF_ICMP:
					jt = (NativeCodeLabel)ri.argument(2);
					break;
					
					// Not a jump
				default:
					continue;
			}
			
			// Check if this points to the instruction directly following this.
			boolean ptonext = (jt != null && (i + 1) == labels.get(jt));
			
			// If it does point to the next instruction, we either delete it
			// or replace the instruction with another depending on ref_clear
			// and such
			if (ptonext)
			{
				// Remove this instruction, it is pointless
				in.remove(i);
				
				// Move all of the label values down
				for (Map.Entry<NativeCodeLabel, Integer> e :
					labels.entrySet())
				{
					int val = e.getValue();
					if (val > i)
						e.setValue(val - 1);
				}
			}
		}
		
		// Resulting tables of instructions
		int n = in.size();
		NativeInstruction[] tabni = new NativeInstruction[n];
		
		// Go through input instructions and map them to real instructions
		for (int i = 0; i < n; i++)
		{
			// Get input point
			Point point = in.get(i);
			
			// The instruction is re-processed potentially
			NativeInstruction inst = point.instruction;
			
			// Used to detect if the instruction actually changed
			boolean didchange = false;
			
			// Arguments may be re-translated if they contain jumps
			Object[] args = inst.arguments();
			for (int j = 0, jn = args.length; j < jn; j++)
			{
				Object a = args[j];
				
				// Map any labels to indexes
				if ((didchange |= (a instanceof NativeCodeLabel)))
				{
					// {@squirreljme.error JC0z The specified label was
					// never defined. (The label)}
					Integer rlp = labels.get((NativeCodeLabel)a);
					if (rlp == null)
						throw new IllegalArgumentException("JC0z " + a);
					
					args[j] = new InstructionJumpTarget(rlp);
				}
			}
			
			// If the instruction changed, use the new one
			tabni[i] = (didchange ? new NativeInstruction(inst.op, args) :
				inst);
		}
		
		// Build
		return new NativeCode(tabni);
	}
	
	/**
	 * Adds a label at the current position.
	 *
	 * @param __lo The locality.
	 * @param __dx The index.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(String __lo, int __dx)
	{
		return this.label(new NativeCodeLabel(__lo, __dx), this._nextaddr);
	}
	
	/**
	 * Adds a label.
	 *
	 * @param __lo The locality.
	 * @param __dx The index.
	 * @param __pc The address to target.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(String __lo, int __dx, int __pc)
	{
		return this.label(new NativeCodeLabel(__lo, __dx), __pc);
	}
	
	/**
	 * Adds a label at the current position.
	 *
	 * @param __l The label to add.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(NativeCodeLabel __l)
	{
		return this.label(__l, this._nextaddr);
	}
	
	/**
	 * Adds a label.
	 *
	 * @param __pc The address to target.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(NativeCodeLabel __l, int __pc)
	{
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("Label %s -> @%d", __l, __pc);
		
		// Add
		this._labels.put(__l, __pc);
		return __l;
	}
	
	/**
	 * Returns the target of the specified label.
	 *
	 * @param __n The label name.
	 * @param __dx The label index.
	 * @return The index of the instruction or {@code -1} if the label is not
	 * valid or the position is not yet known.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	public final int labelTarget(String __n, int __dx)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return this.labelTarget(new NativeCodeLabel(__n, __dx));
	}
	
	/**
	 * Returns the target of the specified label.
	 *
	 * @param __l The label to get the target of.
	 * @return The index of the instruction or {@code -1} if the label is not
	 * valid or the position is not yet known.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final int labelTarget(NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		Integer rv = this._labels.get(__l);
		return (rv == null ? -1 : rv);
	}
	
	/**
	 * This stores the information for a single point in the native code.
	 *
	 * @since 2019/04/26
	 */
	public static final class Point
	{
		/** The instruction used. */
		public final NativeInstruction instruction;
		
		/**
		 * Initializes the instruction point.
		 *
		 * @param __i The instruction.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/26
		 */
		public Point(NativeInstruction __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.instruction = __i;
		}
	}
}

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

package dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * Label which refers to a location in code.
 *
 * @since 2019/03/16
 */
public final class NativeCodeLabel
{
	/** The locality. */
	public final String locality;
	
	/** The associated address. */
	public final int address;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the lable.
	 *
	 * @param __l The locality.
	 * @param __a The address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/16
	 */
	public NativeCodeLabel(String __l, int __a)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.locality = __l;
		this.address = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof NativeCodeLabel))
			return false;
		
		NativeCodeLabel o = (NativeCodeLabel)__o;
		return this.locality.equals(o.locality) &&
			this.address == o.address;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final int hashCode()
	{
		return (~this.locality.hashCode()) - this.address;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "@" + this.locality +
				":" + this.address));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/NativeInstruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;

/**
 * This represents a single instruction.
 *
 * @since 2019/03/22
 */
public final class NativeInstruction
{
	/** The operation. */
	protected final int op;
	
	/** The arguments. */
	final Object[] _args;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the temporary instruction.
	 *
	 * @param __op The operation.
	 * @param __args The arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeInstruction(int __op, Object... __args)
		throws NullPointerException
	{
		this.op = __op;
		this._args = (__args =
			(__args == null ? new Object[0] : __args.clone()));
		
		for (Object o : __args)
			if (o == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * Initializes the temporary instruction.
	 *
	 * @param __op The operation.
	 * @param __args The arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeInstruction(int __op, Collection<Object> __args)
		throws NullPointerException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		this.op = __op;
		
		Object[] args = __args.<Object>toArray(new Object[__args.size()]);
		this._args = args;
		for (Object o : args)
			if (o == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param __i The index of the argument.
	 * @return The argument.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @since 2019/03/24
	 */
	public Object argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not of the given type.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/23
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2019/03/23
	 */
	public final int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * Returns the argument format for the instruction.
	 *
	 * @return The argument format.
	 * @since 2018/04/16
	 */
	public final ArgumentFormat[] argumentFormat()
	{
		return NativeInstruction.argumentFormat(this.op);
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * Returns the encoding of this instruction.
	 *
	 * @return The instruction encoding.
	 * @since 2019/03/27
	 */
	public final int encoding()
	{
		return NativeInstruction.encoding(this.op);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(this instanceof NativeInstruction))
			return false;
		
		NativeInstruction o = (NativeInstruction)__o;
		return this.hashCode() == o.hashCode() &&
			this.op == o.op &&
			Arrays.equals(this._args, o._args);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = (this.op ^
				Arrays.asList(this._args).hashCode()));
		return rv;
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2018/03/23
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).intValue();
	}
	
	/**
	 * Returns the operation this instruction performs.
	 *
	 * @return The operation performed.
	 * @since 2019/03/23
	 */
	public final int operation()
	{
		return this.op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not a number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2018/03/23
	 */
	public short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				NativeInstruction.mnemonic(this.op) + ":" +
				Arrays.asList(this._args)));
		
		return rv;
	}
	
	/**
	 * Returns the argument count of the operation.
	 *
	 * @param __op The operation to get the argument count of.
	 * @return The number of used arguments.
	 * @throws InvalidInstructionException If the encoding is not known.
	 * @since 2019/03/27
	 */
	public static final int argumentCount(int __op)
		throws InvalidInstructionException
	{
		// Depends on the encoding
		switch (NativeInstruction.encoding(__op))
		{
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return 0;
			
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
			case NativeInstructionType.COPY:
			case NativeInstructionType.INVOKE:
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.STORE_POOL:
			case NativeInstructionType.SYSTEM_CALL:
				return 2;
					
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
			case NativeInstructionType.DEBUG_POINT:
			case NativeInstructionType.IF_ICMP:
			case NativeInstructionType.IFEQ_CONST:
			case NativeInstructionType.LOAD_FROM_INTARRAY:
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MATH_CONST_INT:
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.MEMORY_OFF_ICONST:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
			case NativeInstructionType.STORE_TO_INTARRAY:
				return 3;
				
			case NativeInstructionType.DEBUG_ENTRY:
				return 4;
			
			case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
				return 5;
				
				// {@squirreljme.error JC10 Unknown instruction argument
				// count.}
			default:
				throw new InvalidInstructionException("JC10 " + __op);
		}
	}
	
	
	/**
	 * Returns the argument format for the instruction.
	 *
	 * @param __op The operation to get the encoding of.
	 * @return The argument format.
	 * @since 2018/04/16
	 */
	public static final ArgumentFormat[] argumentFormat(int __op)
	{
		switch (NativeInstruction.encoding(__op))
		{
				// []
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return ArgumentFormat.of();
				
				// [r16, reglist]
			case NativeInstructionType.SYSTEM_CALL:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.REGLIST);
				
				// [r16, r16]
			case NativeInstructionType.COPY:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG);
				
				// [r16, u16]
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
				
				// [p16, r16]
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.STORE_POOL:
				return ArgumentFormat.of(
					ArgumentFormat.VPOOL,
					ArgumentFormat.VUREG);
					
				// [p16, p16, p16, p16]
			case NativeInstructionType.DEBUG_ENTRY:
				return ArgumentFormat.of(
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL);
				
				// [u16, u16, u16]
			case NativeInstructionType.DEBUG_POINT:
				return ArgumentFormat.of(
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT);
				
				// [r16, r16, u16]
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
				
				// [r16, r16, r16]
			case NativeInstructionType.LOAD_FROM_INTARRAY:
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.STORE_TO_INTARRAY:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG);
			
				// [r16, i32, r16]
			case NativeInstructionType.MATH_CONST_INT:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32,
					ArgumentFormat.VUREG);
				
				// [r16, r16, i32]
			case NativeInstructionType.MEMORY_OFF_ICONST:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32);
				
				// [r16, r16, j16]
			case NativeInstructionType.IF_ICMP:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VJUMP);
			
				// [r16, i32, j16]
			case NativeInstructionType.IFEQ_CONST:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32,
					ArgumentFormat.VJUMP);
				
				// [reg w/ memaddr, reglist]
			case NativeInstructionType.INVOKE:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.REGLIST);
			
				// [r16 (check), r16 (get), r16 (set), r16 (addr), u16 (off)]
			case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
		}
		
		// {@squirreljme.error JC11 Invalid operation. (The operation)}
		throw new InvalidInstructionException("JC11 " +
			NativeInstruction.mnemonic(__op));
	}
	
	/**
	 * Returns the encoding of the given instruction.
	 *
	 * @param __op The operation to get the encoding of.
	 * @return The encoding for the given operation.
	 * @since 2019/03/24
	 */
	public static final int encoding(int __op)
	{
		// Special operations all use unique encodings so just return their
		// opcode, while all of the other operations use one of the pre-defined
		// encodings.
		int upper = __op & 0xF0;
		if (upper == NativeInstructionType.SPECIAL_A ||
			upper == NativeInstructionType.SPECIAL_B)
			return __op;
		
		// Plain
		return upper;
	}
	
	/**
	 * Returns the mnemonic of the given operation.
	 *
	 * @param __op The operation to get.
	 * @return The mnemonic for the operation.
	 * @since 2019/04/07
	 */
	public static final String mnemonic(int __op)
	{
		switch (NativeInstruction.encoding(__op))
		{
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MATH_CONST_INT:
				return StackJavaType.of((__op >> 4) & 0x3).name() +
					"_" +
					MathType.of(__op & 0x0F).name() +
					"_" +
					(((__op & 0x80) != 0) ? "CONST" : "REG");
			
			case NativeInstructionType.IF_ICMP:
				{
					CompareType ct = CompareType.of(__op & 0x07);
					if (ct == CompareType.TRUE)
						return "GOTO";
					else if (ct == CompareType.FALSE)
						return "NOP";
					else
						return "IF_ICMP_" + ct.name();
				}
				
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_ICONST:
				return "MEM_" +
					(((__op & 0x08) != 0) ? "LOAD" : "STORE") +
					"_" +
					DataType.of(__op & 0x07).name() +
					"_" +
					(((__op & 0x80) != 0) ? "ICONST" : "REG");
			
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
				return "MEM_" +
					(((__op & 0x08) != 0) ? "LOAD" : "STORE") +
					"_" +
					DataType.of(__op & 0x07).name() +
					"_" +
					(((__op & 0x80) != 0) ? "ICONST" : "REG") +
					"_JAVA";
				
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
				return "ATOMIC_INT_DECREMENT_AND_GET";
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
				return "ATOMIC_INT_INCREMENT";
			case NativeInstructionType.BREAKPOINT:		return "BREAKPOINT";
			case NativeInstructionType.COPY:			return "COPY";
			case NativeInstructionType.DEBUG_ENTRY:		return "DEBUG_ENTRY";
			case NativeInstructionType.DEBUG_EXIT:		return "DEBUG_EXIT";
			case NativeInstructionType.DEBUG_POINT:		return "DEBUG_POINT";
			case NativeInstructionType.IFEQ_CONST:		return "IFEQ_CONST";
			case NativeInstructionType.INVOKE:			return "INVOKE";
			case NativeInstructionType.LOAD_POOL:		return "LOAD_POOL";
			case NativeInstructionType.LOAD_FROM_INTARRAY:
				return "LOAD_FROM_INTARRAY";
			case NativeInstructionType.RETURN:			return "RETURN";
			case NativeInstructionType.STORE_POOL:		return "STORE_POOL";
			case NativeInstructionType.STORE_TO_INTARRAY:
				return "STORE_TO_INTARRAY";
			case NativeInstructionType.SYSTEM_CALL:		return "SYSTEM_CALL";
			
			default:
				return String.format("UNKNOWN_%02x", __op);
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/NativeInstructionType.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * This represents a type of native instruction. Virtually all instructions
 * except for the special instructions are composed of groups.
 *
 * @since 2019/04/06
 */
public interface NativeInstructionType
{
	/**
	 * Math, R=RR, Integer.
	 * {@code iiiiMMMM, r3 = r1 ? r2}.
	 */
	short MATH_REG_INT =
		0x00;
	
	/**
	 * Int comparison, then maybe jump.
	 * {@code iiiiRccc, if (r1 ? r2) jump->j3}.
	 */
	short IF_ICMP =
		0x10;
	
	/**
	 * Memory access, offset is in register.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	short MEMORY_OFF_REG =
		0x20;
	
	/**
	 * Memory access to big endian Java format, offset is in register.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	short MEMORY_OFF_REG_JAVA =
		0x30;
	
	/**
	 * Math, R=RC, Integer.
	 * {@code iiiiMMMM, r3 = r1 ? c2}.
	 */
	short MATH_CONST_INT =
		0x80;
	
	/**
	 * Memory access, offset is a constant.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	short MEMORY_OFF_ICONST =
		0xA0;
	
	/**
	 * Memory access to big endian Java format, offset is a constant.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	short MEMORY_OFF_ICONST_JAVA =
		0xB0;
	
	/**
	 * Special.
	 * {@code iiiixxxx}.
	 */
	short SPECIAL_A =
		0xE0;
	
	/**
	 * Special.
	 * {@code iiiixxxx}.
	 */
	short SPECIAL_B =
		0xF0;
	
	/** If equal to constant. */
	short IFEQ_CONST =
		0xE6;
	
	/** Debug entry to method. */
	short DEBUG_ENTRY =
		0xE8;
	
	/** Debug exit from method. */
	short DEBUG_EXIT =
		0xE9;
	
	/** Debug single point in method. */
	short DEBUG_POINT =
		0xEA;
	
	/**
	 * Return. 
	 * {@code iiiixxxx, return}.
	 */
	short RETURN =
		0xF3;
	
	/**
	 * Store to pool, note that at code gen time this is aliased.
	 * {@code iiiixxxx}.
	 */
	short STORE_POOL =
		0xF4;
	
	/** Store to integer array. */
	short STORE_TO_INTARRAY =
		0xF5;
	
	/**
	 * Invoke. 
	 * {@code iiiixxxx}.
	 */
	short INVOKE =
		0xF7;
	
	/** Copy value in register. */
	short COPY =
		0xF8;
	
	/** Atomically decrements a memory addres and gets the value. */
	short ATOMIC_INT_DECREMENT_AND_GET =
		0xF9;
	
	/** Atomically increments a memory address. */
	short ATOMIC_INT_INCREMENT =
		0xFA;
	
	/** System call. */
	short SYSTEM_CALL =
		0xFB;
	
	/** Atomic compare and set. */
	short ATOMIC_COMPARE_GET_AND_SET =
		0xFC;
	
	/**
	 * Load from pool, note that at code gen time this is aliased.
	 * {@code iiiixxxx}.
	 */
	short LOAD_POOL =
		0xFD;
	
	/** Load from integer array. */
	short LOAD_FROM_INTARRAY =
		0xFE;
	
	/**
	 * Compare and exchange. 
	 * {@code iiiixxxx}.
	 */
	short BREAKPOINT =
		0xFF;
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/NearNativeByteCodeHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import cc.squirreljme.jvm.ClassLoadingAdjustments;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallIndex;
import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.NotedString;
import dev.shadowtail.classfile.pool.NullPoolEntry;
import dev.shadowtail.classfile.pool.UsedString;
import dev.shadowtail.classfile.xlate.ByteCodeHandler;
import dev.shadowtail.classfile.xlate.ByteCodeState;
import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.ExceptionHandlerTransition;
import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import dev.shadowtail.classfile.xlate.JavaStackResult;
import dev.shadowtail.classfile.xlate.JavaStackState;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import dev.shadowtail.classfile.xlate.StateOperation;
import dev.shadowtail.classfile.xlate.StateOperations;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandler;
import net.multiphasicapps.classfile.ExceptionHandlerTable;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodReference;

/**
 * This contains the handler for the near native byte code.
 *
 * @since 2019/04/06
 */
public final class NearNativeByteCodeHandler
	implements ByteCodeHandler
{
	/** The jvm functions class. */
	public static final ClassName JVMFUNC_CLASS =
		new ClassName("cc/squirreljme/jvm/JVMFunction");
	
	/** State of the byte code. */
	public final ByteCodeState state =
		new ByteCodeState();
	
	/** Used to build native code. */
	protected final NativeCodeBuilder codebuilder =
		new NativeCodeBuilder();
	
	/** Default field access type, to determine how fields are accessed. */
	protected final FieldAccessTime defaultfieldaccesstime;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	
	/** Returning value? */
	protected final boolean isreturn;
	
	/** Returning wide value? */
	protected final boolean isreturnwide;
	
	/** Monitor target register used. */
	protected final int monitortarget;
	
	/** Volatile registers to use. */
	protected final VolatileRegisterStack volatiles;
	
	/** Standard exception handler table. */
	private final Map<ExceptionHandlerTransition, __EData__> _ehtable =
		new LinkedHashMap<>();
	
	/** Made exception table. */
	private final Map<ClassAndLabel, __EData__> _metable =
		new LinkedHashMap<>();
	
	/** The returns which have been performed. */
	private final List<JavaStackEnqueueList> _returns =
		new ArrayList<>();
	
	/** Java transition labels. */
	private final Map<StateOperationsAndTarget, __EData__> _transits =
		new LinkedHashMap<>();
	
	/** Reference clearing and jumping to label. */
	private final Map<EnqueueAndLabel, __EData__> _refcljumps =
		new LinkedHashMap<>();
	
	/** Last registers enqueued. */
	private JavaStackEnqueueList _lastenqueue;
	
	/** Next reference count/uncount ID number for jump. */
	private int _refclunk;
	
	/**
	 * Initializes the byte code handler.
	 *
	 * @param __bc The byte code.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public NearNativeByteCodeHandler(ByteCode __bc)
		throws NullPointerException
	{
		if (__bc == null)
			throw new NullPointerException("NARG");
		
		this.defaultfieldaccesstime = ((__bc.isInstanceInitializer() ||
			__bc.isStaticInitializer()) ? FieldAccessTime.INITIALIZER :
			FieldAccessTime.NORMAL);
		this.issynchronized = __bc.isSynchronized();
		this.isinstance = __bc.isInstance();
		
		// Determine monitor target register and the volatile base
		int volbase = NativeCode.ARGUMENT_REGISTER_BASE + 2 +
			__bc.maxLocals() + __bc.maxStack();
		this.monitortarget = volbase;
		this.volatiles = new VolatileRegisterStack(volbase + 1);
		
		// Returning values?
		this.isreturn = (__bc.type().returnValue() != null);
		this.isreturnwide = (this.isreturn && __bc.type().returnValue().isWide());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayLength(JavaStackResult.Input __in,
		JavaStackResult.Output __len)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// Read length
		codebuilder.addMemoryOffConst(DataType.INTEGER, true,
			__len.register,
			__in.register, Constants.ARRAY_LENGTH_OFFSET);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayLoad(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// Check array bounds
		this.__basicCheckArrayBound(__in.register, __dx.register);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// Grab some volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volaip = volatiles.get();
		
		// Determine array index position
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.MUL,
			__dx.register, __dt.size(), volaip);
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
			volaip, Constants.ARRAY_BASE_SIZE, volaip);
		
		// Use helper function
		if (__dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				__in.register, volaip);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
		}
		
		// Use native read
		else
			codebuilder.addMemoryOffReg(__dt, true,
				__v.register, __in.register, volaip);
		
		// Not used anymore
		volatiles.remove(volaip);
		
		// If reading an object reference count up!
		if (__dt == DataType.OBJECT)
			this.__refCount(__v.register);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayStore(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// Check array bounds
		this.__basicCheckArrayBound(__in.register, __dx.register);
		
		// Grab some volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volaip = volatiles.get();
		
		// Determine array index position
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.MUL,
			__dx.register, __dt.size(), volaip);
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
			volaip, Constants.ARRAY_BASE_SIZE, volaip);
		
		// If we are storing an object....
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __v.type.isObject()))
		{
			// Check if the array type is compatible
			this.__basicCheckArrayStore(__in.register, __v.register);
			
			// Count the object being stored
			this.__refCount(__v.register);
			
			// Read existing object so it can be uncounted later
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(DataType.INTEGER, true,
				voltemp, __in.register, volaip);
		}
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// Use helper function
		if (__dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.STATIC,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				__in.register, volaip, __v.register, __v.register + 1);
		}
		
		// Store value
		else
			codebuilder.addMemoryOffReg(__dt, false,
				__v.register, __in.register, volaip);
		
		// Reference uncount old value
		if (isobject)
		{
			// Uncount old
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// No longer used
		volatiles.remove(volaip);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doCheckCast(ClassName __cl, JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push reference
		this.__refPush();
		
		// If the value to be checked is null then we do not thrown an
		// exception, we just skip
		NativeCodeLabel nullskip = new NativeCodeLabel("checkcastnull",
			this._refclunk++);
		codebuilder.addIfZero(__v.register, nullskip);
		
		// Add cast check
		this.__basicCheckCCE(__v.register, __cl);
		
		// Null jump goes here
		codebuilder.label(nullskip);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// We do not need to uncount whatever was pushed in because it would
		// be immediately pushed back onto the stack. The counts should only
		// be lowered if ClassCastException is to be thrown. Because otherwise
		// we will just end up collecting things on a normal refclear
		this.__refReset();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/26
	 */
	@Override
	public final void doClassObjectLoad(ClassName __cl,
		JavaStackResult.Output __out)
	{
		this.__loadClassObject(__cl, __out.register);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doConvert(StackJavaType __as,
		JavaStackResult.Input __a, StackJavaType __bs,
		JavaStackResult.Output __b)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Doing just a copy
		if (__as == __bs)
		{
			int a = __a.register,
				b = __b.register;
			
			if (__as.isWide())
			{
				codebuilder.addCopy(a, b);
				codebuilder.addCopy(a + 1, b + 1);
			}
			else
				codebuilder.addCopy(a, b);
		}
		
		// Otherwise a conversion
		else
		{
			// Get the software math class for the source type
			ClassName smc = __as.softwareMathClass();
			
			// Invoke converter method (which might be wide)
			if (__as.isWide())
				this.__invokeStatic(InvokeType.SYSTEM, smc,
					"to" + __bs.boxedType(), "(II)" + __bs.signature(),
					__a.register, __a.register + 1);
			else
				this.__invokeStatic(InvokeType.SYSTEM, smc,
					"to" + __bs.boxedType(), "(I)" + __bs.signature(),
					__a.register);
			
			// Read out return value
			int a = NativeCode.RETURN_REGISTER,
				b = __b.register;
			if (__bs.isWide())
			{
				codebuilder.addCopy(a, b);
				codebuilder.addCopy(a + 1, b + 1);
			}
			else
				codebuilder.addCopy(a, b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doCopy(JavaStackResult.Input __in,
		JavaStackResult.Output __out)
	{
		// Push references, the dest may be overwritten
		this.__refPush();
		
		// Perform the copy, make sure to correctly handle wide copies!
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__in.type.isWide())
		{
			codebuilder.addCopy(__in.register, __out.register);
			codebuilder.addCopy(__in.register + 1, __out.register + 1);
		}
		else
			codebuilder.addCopy(__in.register, __out.register);
		
		// Clear references in the event it was overwritten
		this.__refClear();
	}
	
	/**
	 * Reads a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The output value.
	 * @since 2019/04/12
	 */
	public final void doFieldGet(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// The instance register
		int ireg = __i.register;
		
		// Cannot be null
		this.__basicCheckNPE(ireg);
		
		// Must be the given class
		if (!__i.isCompatible(__fr.className()))
			this.__basicCheckCCE(ireg, __fr.className());
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// Determine volatile registers
		VolatileRegisterStack volatiles = this.volatiles;
		int tempreg = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.INSTANCE, __fr, true), tempreg);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// Use helper function?
		if (dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				ireg, tempreg);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
		}
		
		// Read from memory
		else
			codebuilder.addMemoryOffReg(
				dt, true,
				__v.register, ireg, tempreg);
		
		// Count it up?
		if (__fr.memberType().isObject())
			this.__refCount(__v.register);
		
		// Not used anymore
		volatiles.remove(tempreg);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doFieldPut(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// The instance register
		int ireg = __i.register;
		
		// Cannot be null
		this.__basicCheckNPE(ireg);
		
		// Must be the given class
		if (!__i.isCompatible(__fr.className()))
			this.__basicCheckCCE(ireg, __fr.className());
			
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		this.state.canexception = false;
		
		// Get volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volfioff = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.INSTANCE, __fr, false),
			volfioff);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// If we are storing an object, we need to uncount the value already
		// in this field
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __fr.memberType().isObject()))
		{
			// Count our own reference up
			this.__refCount(__v.register);
			
			// Read the value of the field for later clear
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(
				dt, true,
				voltemp, ireg, volfioff);
		}
		
		// Use helper function?
		if (dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				ireg, volfioff, __v.register, __v.register + 1);
		}
		
		// Write to memory
		else
			codebuilder.addMemoryOffReg(
				dt, false,
				__v.register, ireg, volfioff);
		
		// If we stored an object, reference count the field after it has
		// been written to
		if (isobject)
		{
			// Uncount
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// No longer used
		volatiles.remove(volfioff);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doIfICmp(CompareType __ct, JavaStackResult.Input __a,
		JavaStackResult.Input __b, InstructionJumpTarget __ijt)
	{
		// Push references if needed
		this.__refPush();
		
		// Add comparison
		this.codebuilder.addIfICmp(__ct, __a.register, __b.register,
			this.__labelJava(__ijt));
		
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doInstanceOf(ClassName __cl,
		JavaStackResult.Input __v, JavaStackResult.Output __o)
	{
		// Push reference
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcldx = volatiles.get();
		
		// Load desired class index type
		this.__loadClassInfo(__cl, volwantcldx);
		
		// Invoke helper method
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmIsInstance", "(II)I", __v.register, volwantcldx);
		
		// Use result
		this.codebuilder.addCopy(NativeCode.RETURN_REGISTER, __o.register);
		
		// No longer needed
		volatiles.remove(volwantcldx);
		
		// Clear references in the event it was overwritten
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/10
	 */
	@Override
	public final void doInvoke(InvokeType __t, MethodReference __r,
		JavaStackResult.Output __out, JavaStackResult.Input... __in)
	{
		// Target class
		ClassName targetclass = __r.handle().outerClass();
		
		// Invocation of assembly method?
		if ("cc/squirreljme/jvm/Assembly".equals(
			targetclass.toString()))
		{
			// Forward
			this.__invokeAssembly(__r.handle().name(),
				__r.handle().descriptor(), __out, __in);
			
			// Do nothing else
			return;
		}
		
		// Code generator
		NativeCodeBuilder codebuilder = this.codebuilder;
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Push references
		this.__refPush();
		
		// Fill in call arguments
		List<Integer> callargs = new ArrayList<>(__in.length * 2);
		for (int i = 0, n = __in.length; i < n; i++)
		{
			// Add the input register
			JavaStackResult.Input in = __in[i];
			callargs.add(in.register);
			
			// But also if it is wide, we need to pass the other one or
			// else the value will be clipped
			if (in.type.isWide())
				callargs.add(in.register + 1);
		}
		
		// Actual arguments to the call
		RegisterList reglist = new RegisterList(callargs);
		
		// If invoking static method, use our helper method
		MethodHandle mh = __r.handle();
		if (__t == InvokeType.STATIC)
		{
			this.__invokeStatic(__t, mh.outerClass(), mh.name(),
				mh.descriptor(), reglist);
		}
		
		// Interface, special, or virtual
		else
		{
			// Check that the object is of the given class type and is not null
			int ireg = __in[0].register;
			this.__basicCheckNPE(ireg);
			
			// Check types if this is not compatible
			if (!__in[0].isCompatible(__r.handle().outerClass()))
				this.__basicCheckCCE(ireg, __r.handle().outerClass());
			
			// Invoking interface method
			if (__t == InvokeType.INTERFACE)
			{
				// Load the interface we are looking in
				int voliclass = volatiles.get();
				this.__loadClassInfo(__r.handle().outerClass(), voliclass);
				
				// Load the method index of the volatile method in question
				int volimethdx = volatiles.get();
				codebuilder.add(NativeInstructionType.LOAD_POOL,
					new MethodIndex(__r.handle().outerClass(),
						__r.handle().name(), __r.handle().descriptor()),
					volimethdx);
				
				// Use helper method to find the method pointer to invoke
				// for this interface (hi=pool, lo=pointer)
				this.__invokeStatic(InvokeType.SYSTEM,
					NearNativeByteCodeHandler.JVMFUNC_CLASS,
					"jvmInterfacePointer", "(III)J",
					ireg, voliclass, volimethdx);
				
				// We need to extract the pool pointer of the class we
				// are calling in so that nothing is horribly incorrect
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
					NativeCode.NEXT_POOL_REGISTER);
				
				// Invoke the pointer that this method returned
				codebuilder.add(NativeInstructionType.INVOKE,
					NativeCode.RETURN_REGISTER, reglist);
				
				// Cleanup
				volatiles.remove(voliclass);
				volatiles.remove(volimethdx);
			}
			
			// Special or virtual
			else
			{
				// Invoke instance method
				this.__invokeInstance(__t, mh.outerClass(), mh.name(),
					mh.descriptor(), reglist);
			}
		}
		
		// Check if exception occurred, before copying the return value!
		if (this.state.canexception)
		{
			// Exception check
			codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				this.__labelException());
			
			// We did the exception handling, so do not handle later
			this.state.canexception = false;
		}
		
		// Read in return value, it is just a copy
		if (__out != null)
		{
			int a = NativeCode.RETURN_REGISTER,
				b = __out.register;
			
			if (__out.type.isWide())
				codebuilder.addCopy(a + 1, b + 1);
			codebuilder.addCopy(a, b);
		}
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doLookupSwitch(JavaStackResult.Input __key,
		LookupSwitch __ls)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// The key register
		int keyreg = __key.register;
		
		// Generate checks for all keys
		int[] keys = __ls.keys();
		InstructionJumpTarget[] jumps = __ls.jumps();
		for (int i = 0, n = keys.length; i < n; i++)
			codebuilder.add(NativeInstructionType.IFEQ_CONST,
				keyreg, keys[i], this.__labelJava(jumps[i]));
		
		// Final case is the default jump
		codebuilder.addGoto(this.__labelJava(__ls.defaultJump()));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, JavaStackResult.Input __b,
		JavaStackResult.Output __c)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Integer math is supported natively
		if (__dt == StackJavaType.INTEGER)
		{
			// Check for division by zero, only the integer type can have this
			// done in code because the long can be handled by the software
			// math library code. Otherwise we would need to add more code to
			// the generator to handle this.
			if (__mt == MathType.DIV || __mt == MathType.REM)
			{
				// Perform divide by zero check
				this.__basicCheckDBZ(__b.register);
				
				// We already checked the only valid exceptions, so do not
				// perform later handling!
				this.state.canexception = false;
			}
			
			// Add math operation
			codebuilder.addMathReg(__dt, __mt, __a.register, __b.register,
				__c.register);
		}
		
		// Other kinds of math are done in software
		else
		{
			// Get the software math class for the type
			ClassName smc = __dt.softwareMathClass();
			
			// The function to call is just the lowercased enum
			String func = __mt.name().toLowerCase();
			
			// Remove the L/G from compare as that is only for float/double
			if (__dt == StackJavaType.LONG && func.startsWith("cmp"))
				func = "cmp";
			
			// Handling wide math?
			boolean iswide = __dt.isWide();
			
			// A, B, and C register
			int ah = __a.register,
				bh = __b.register,
				ch = __c.register;
			
			// Low registers
			int al = (ah == 0 ? 0 : ah + 1),
				bl = (bh == 0 ? 0 : bh + 1),
				cl = (ch == 0 ? 0 : ch + 1);
			
			// Determine the call signature
			String type = __mt.signature(__dt);
			RegisterList args;
			switch (__mt)
			{
				case NEG:
				case SIGNX8:
				case SIGNX16:
					if (iswide)
						args = new RegisterList(ah, al);
					else
						args = new RegisterList(ah);
					break;
				
				case SHL:
				case SHR:
				case USHR:
					if (iswide)
						args = new RegisterList(ah, al, bh);
					else
						args = new RegisterList(ah, bh);
					break;
				
				default:
					if (iswide)
						args = new RegisterList(ah, al, bh, bl);
					else
						args = new RegisterList(ah, bh);
					break;
			}
			
			// Perform the call
			this.__invokeStatic(InvokeType.SYSTEM, smc.toString(),
				func, type, args);
			
			// Read out return value
			if (iswide)
			{
				codebuilder.addCopy(NativeCode.RETURN_REGISTER, ch);
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, cl);
			}
			else
				codebuilder.addCopy(NativeCode.RETURN_REGISTER, ch);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, Number __b, JavaStackResult.Output __c)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// If we are dividing by zero just throw an exception
		if ((__dt == StackJavaType.INTEGER || __dt == StackJavaType.LONG) &&
			(__mt == MathType.DIV || __mt == MathType.REM))
			if (__b.longValue() == 0)
			{
				// Directly jump to the make exception handler
				codebuilder.addGoto(this.__labelMakeException(
					"java/lang/ArithmeticException"));
				
				// Already handled this
				this.state.canexception = false;
				
				// Since we are dividing by zero, never actually generate the
				// division code
				return;
			}
		
		// Integer math on constants is natively supported
		if (__dt == StackJavaType.INTEGER)
		{
			codebuilder.addMathConst(__dt, __mt, __a.register, __b,
				__c.register);
		}
		
		// Otherwise store the constant and then do register math on it
		else
		{
			// Need working registers, these must be next to each other!
			VolatileRegisterStack volatiles = this.volatiles;
			int volbh = -1, volbl = -7;
			while (volbl != (volbh + 1))
			{
				volbh = volatiles.get();
				volbl = volatiles.get();
			}
			
			// Read in raw value
			if (__b instanceof Float)
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, Float.floatToRawIntBits(__b.floatValue()), volbh);
			else if (__b instanceof Double)
			{
				long bits = Double.doubleToRawLongBits(__b.doubleValue());
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits >>> 32), volbh);
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits), volbl);
			}
			else
			{
				long bits = __b.longValue();
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits >>> 32), volbh);
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits), volbl);
			}
			
			// Same as register math except the constant value is
			// virtualized now
			this.doMath(__dt, __mt,
				__a, new JavaStackResult.Input(volbh, JavaType.INTEGER, true),
				__c);
			
			// Cleanup
			volatiles.remove(volbh);
			volatiles.remove(volbl);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doMonitor(boolean __enter, JavaStackResult.Input __o)
	{
		// Push reference
		this.__refPush();
		
		// Generate instruction
		this.__monitor(__enter, __o.register);
		
		// Clear reference
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/04
	 */
	@Override
	public final void doMultiANewArray(ClassName __cl, int __numdims,
		JavaStackResult.Output __o, JavaStackResult.Input... __dims)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassobj = volatiles.get();
		
		// Load the class we want to allocate
		this.__loadClassObject(__cl, volclassobj);
		
		// Determine the number of integer arguments to use, since we
		// are passing multiple arguments to multianewarray
		StringBuilder sb = new StringBuilder(__numdims);
		for (int i = 0; i < __numdims; i++)
			sb.append('I');
			
		// Build arguments to the method call (class, skip, args);
		List<Integer> rl = new ArrayList<>();
		rl.add(volclassobj);
		rl.add(0);
		for (int i = 0; i < __numdims; i++)
			rl.add(__dims[i].register);
		
		// Invoke array utility
		this.__invokeStatic(InvokeType.SYSTEM,
			"cc/squirreljme/runtime/cldc/lang/ArrayUtils", "multiANewArray",
			"(Ljava/lang/Class;I" + sb + ")Ljava/lang/Object;",
			new RegisterList(rl));
		
		// Use this result
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __o.register);
		
		// Not needed anymore
		volatiles.remove(volclassobj);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doNew(ClassName __cn, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need result register
		VolatileRegisterStack volatiles = this.volatiles;
		int volresult = volatiles.get();
		
		// Perform new invocation
		this.__invokeNew(__cn, volresult);
		
		// Check for out of memory
		this.__basicCheckOOM(volresult);
		
		// All the exceptions were checked
		this.state.canexception = false;
		
		// Copy to result
		codebuilder.addCopy(volresult, __out.register);
		
		// Not needed
		volatiles.remove(volresult);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doNewArray(ClassName __at,
		JavaStackResult.Input __len, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Check for negative array size
		this.__basicCheckNAS(__len.register);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassdx = volatiles.get(),
			volresult = volatiles.get();
		
		// Load the class data for the array type
		// If not a fixed class index, then rely on the value in the pool
		this.__loadClassInfo(__at, volclassdx);
		
		// Call internal handler, place into temporary for OOM check
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS, "jvmNewArray",
			"(II)I", volclassdx, __len.register);
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, volresult);
		
		// No longer needed
		volatiles.remove(volclassdx);
		
		// Check for out of memory
		this.__basicCheckOOM(volresult);
		
		// All the exceptions were checked
		this.state.canexception = false;
		
		// Place result in true location
		codebuilder.addCopy(volresult, __out.register);
		
		// Not needed
		volatiles.remove(volresult);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doPoolLoad(Object __v, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Loading string value?
		if (__v instanceof String)
		{
			// Need volatiles
			VolatileRegisterStack volatiles = this.volatiles;
			
			// Load the potentially cached string pointer
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				new UsedString((String)__v), __out.register);
			
			// Label to jump to if this string is already loaded
			NativeCodeLabel ispresent = new NativeCodeLabel("strloaded",
				this._refclunk++);
			codebuilder.addIfNonZero(__out.register, ispresent);
			
			// Load the noted string
			int volstrptr = volatiles.get();
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				new NotedString((String)__v), volstrptr);
				
			// Call internal string loader
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmLoadString", "(I)Ljava/lang/String;", volstrptr);
			
			// Cleanup
			volatiles.remove(volstrptr);
			
			// Store into the pull and copy the result as well
			codebuilder.add(NativeInstructionType.STORE_POOL,
				new UsedString((String)__v), NativeCode.RETURN_REGISTER);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER, __out.register);
			
			// String is loaded
			codebuilder.label(ispresent);
		}
		
		// Some other value
		else
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				__v, __out.register);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doReturn(JavaStackResult.Input __in)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// If we are returning an object, we need to reference count it up
		// so it does not get garbage collected as a return is happening
		if (__in != null && __in.isObject())
			this.__refCount(__in.register);
		
		// Uncount all references that need to be cleared out as we return
		for (int q : this.state.result.enqueue())
			this.__refUncount(q);
		
		// Copy the returning value at the end to increase it's lifetime
		// as much as possible. Otherwise if we copy too early to the return
		// register then future uncounts can completely trash the value
		if (__in != null)
		{
			int a = __in.register,
				b = NativeCode.RETURN_REGISTER;
			
			// Copy value to return register
			if (__in.type.isWide())
				codebuilder.addCopy(a + 1, b + 1);
			codebuilder.addCopy(a, b);
		}
		
		// Do the return
		this.__generateReturn();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doStateOperations(StateOperations __ops)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		// If there are no operations, just do not bother
		if (__ops.isEmpty())
			return;
		
		// Generate code for the operations
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (StateOperation op : __ops)
			switch (op.type)
			{
				case UNCOUNT:
					this.__refUncount(op.a);
					break;
				
				case COUNT:
					this.__refCount(op.a);
					break;
				
				case COPY:
					codebuilder.addCopy(op.a, op.b);
					break;
				
				case WIDE_COPY:
					codebuilder.addCopy(op.a, op.b);
					codebuilder.addCopy(op.a + 1, op.b + 1);
					break;
				
				default:
					throw new todo.OOPS();
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doStaticGet(FieldReference __fr,
		JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Ignore thrown exceptions because field access is checked at link
		// time
		this.state.canexception = false;
		
		// Push references
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volsfo = volatiles.get();
		
		// Read static offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.STATIC, __fr, true),
			volsfo);
		
		// The datatype used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// Use helper function?
		if (dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				NativeCode.STATIC_FIELD_REGISTER, volsfo);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
		}
		
		// Read from memory
		else
			codebuilder.addMemoryOffReg(
				dt, true,
				__v.register, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		
		// Count it up?
		if (__fr.memberType().isObject())
			this.__refCount(__v.register);
		
		// Not needed
		volatiles.remove(volsfo);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final void doStaticPut(FieldReference __fr,
		JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Ignore thrown exceptions because field access is checked at link
		// time
		this.state.canexception = false;

		// Push references
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volsfo = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.STATIC, __fr, false),
			volsfo);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// If we are storing an object, we need to uncount the value already
		// in this field
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __fr.memberType().isObject()))
		{
			// Count our own reference up
			this.__refCount(__v.register);
			
			// Read the value of the field for later clear
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(
				dt, true,
				voltemp, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		}
		
		// Use helper function?
		if (dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				NativeCode.STATIC_FIELD_REGISTER, volsfo,
				__v.register, __v.register + 1);
		}
		
		// Write to memory
		else
			codebuilder.addMemoryOffReg(
				dt, false,
				__v.register, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		
		// If we wrote an object, uncount the old destination after it
		// has been overwritten
		if (isobject)
		{
			// Uncount
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// Not needed
		volatiles.remove(volsfo);
		
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doThrow(JavaStackResult.Input __in)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Copy into the exception register
		codebuilder.addCopy(__in.register, NativeCode.EXCEPTION_REGISTER);
		
		// Clear the reference queue because this results in a net reference
		// count if this point is reached, however this is still needed for
		// the NPE check even though null values will never be counted
		this.__refReset();
		
		// Do not jump at this point, just return the exception check will be
		// flagged which will start the exception handling
		return;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void instructionFinish()
	{
		ByteCodeState state = this.state;
		
		// {@squirreljme.error JC12 Enqueues were not cleared, this is an
		// internal compiler error.}
		if (this._lastenqueue != null)
			throw new IllegalStateException("JC12");
		
		// An exception check was requested, do a check on the exception
		// register and jump if there is something there
		if (state.canexception)
			this.codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				this.__labelException());
		
		// If this instruction naturally flows into another, determine we
		// need to transition to that stack state in order to work properly
		// with any cached values
		if (state.instruction.hasNaturalFlow())
		{
			// Get following stack
			int followaddr = state.followaddr;
			JavaStackState nowstack = state.stack,
				followstack = state.stacks.get(followaddr);
			
			// If our current stack is not compatible with the target stack
			// then we need to transition to that state. However the Java label
			// code already handles transition, so do this to remove duplicate
			// code with just a minor jump around.
			// However if the next state is poisoned we do not do this because
			// we will just naturally transition to a pure de-cache at the
			// start of everything anyway.
			if (!nowstack.equals(followstack) &&
				!state.stackpoison.containsKey(followaddr))
				this.codebuilder.addGoto(
					this.__labelJava(new InstructionJumpTarget(followaddr)));
		}
		
		// Clear volatiles
		this.volatiles.clear();
	}
	
	/**
	 * Sets up before processing the instruction.
	 *
	 * @since 2019/04/07
	 */
	public final void instructionSetup()
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		ByteCodeState state = this.state;
		int addr = state.addr;
		
		// Clear volatiles
		this.volatiles.clear();
		
		// Entry point debugging
		if (addr == 0)
		{
			// Debug entry point
			codebuilder.add(NativeInstructionType.DEBUG_ENTRY,
				new NotedString(state.classname.toString()),
				new NotedString(state.methodname.toString()),
				new NotedString(state.methodtype.toString()),
				new NullPoolEntry());
			
			// Setup monitor entry
			if (this.issynchronized)
			{
				// Copy instance to monitor target
				if (this.isinstance)
					codebuilder.addCopy(state.stack.getLocal(0).register,
						this.monitortarget);
				
				// Load class object to monitor
				else
					this.__loadClassObject(state.classname,
						this.monitortarget);
				
				// Enter monitor on this
				this.__refCount(this.monitortarget);
				this.__monitor(true, this.monitortarget);
			}
		}
		
		// Debug single instruction point
		codebuilder.add(NativeInstructionType.DEBUG_POINT,
			state.line & 0x7FFF, state.instruction.operation() & 0xFF,
			state.instruction.address() & 0x7FFF);
		
		// Check if there are operations that need to be performed to make
		// sure the stack state is morphed into correctly
		StateOperations poison = state.stackpoison.get(addr);
		if (poison != null)
			this.doStateOperations(poison);
		
		// Setup a label for this current position, this is done after
		// potential flushing because it is assumed that the current state
		// is always valid even after a flush
		codebuilder.label("java", addr);
	}
	
	/**
	 * Returns the result of the translation.
	 *
	 * @return The translation result.
	 * @since 2019/04/07
	 */
	public final NativeCode result()
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		ByteCodeState state = this.state;
		List<JavaStackEnqueueList> returns = this._returns;
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Was an exception handler generated?
		boolean didehfall = false;
		
		// Generate reference clear jumps
		Map<EnqueueAndLabel, __EData__> refcljumps = this._refcljumps;
		for (Map.Entry<EnqueueAndLabel, __EData__> e : refcljumps.entrySet())
		{
			EnqueueAndLabel eql = e.getKey();
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 256);
			
			// Clear references
			JavaStackEnqueueList enq = eql.enqueue;
			for (int i = 0, n = enq.size(); i < n; i++)
				this.__refUncount(enq.get(i));
			
			// Then go to the target
			codebuilder.addGoto(eql.label);
		}
		
		// Generate make exception code
		Map<ClassAndLabel, __EData__> metable = this._metable;
		for (Map.Entry<ClassAndLabel, __EData__> e : metable.entrySet())
		{
			ClassAndLabel csl = e.getKey();
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 257);
			
			// Allocate class object, make sure it is not done in the exception
			// register because the method we call may end up just clearing it
			// and stopping if a make exception is done (because there is an
			// exception here).
			int exinst = volatiles.get();
			this.__invokeNew(csl.classname, exinst);
			
			// Initialize the exception
			this.__invokeInstance(InvokeType.SPECIAL, csl.classname, "<init>",
				"()V", new RegisterList(exinst));
			
			// Copy result into the exception register
			codebuilder.addCopy(exinst, NativeCode.EXCEPTION_REGISTER);
			
			// Done with this
			volatiles.remove(exinst);
			
			// Generate jump to exception handler
			codebuilder.addGoto(csl.label);
		}
		
		// Generate exception handler tables
		Map<ExceptionHandlerTransition, __EData__> ehtab = this._ehtable;
		for (Map.Entry<ExceptionHandlerTransition, __EData__> e :
			ehtab.entrySet())
		{
			ExceptionHandlerTransition ehtran = e.getKey();
			StateOperations sops = ehtran.handled;
			JavaStackEnqueueList enq = ehtran.nothandled;
			ExceptionHandlerTable ehtable = ehtran.table;
			
			// Label used for the jump target
			NativeCodeLabel lab = this.__useEDataAndGetLabel(e.getValue());
			this.__useEDataDebugPoint(e.getValue(), 258);
			
			// If the table is empty, just return
			if (ehtable.isEmpty())
			{
				// If we never saw a cleanup for this return yet we can
				// generate one here to be used for later points
				int rdx = returns.indexOf(enq);
				if (rdx < 0)
					codebuilder.label(lab,
						codebuilder.labelTarget(this.__generateReturn(enq)));
				
				// We can just alias this exception to the return point to
				// cleanup everything
				else
					codebuilder.label(lab,
						codebuilder.labelTarget("return", rdx));
				
				// Generate the next handler
				continue;
			}
			
			// Set label target for this one
			codebuilder.label(lab);
			
			// Go through and build the exception handler table
			for (ExceptionHandler eh : ehtable)
			{
				// Load the class type for the exception to check against
				int volehclassdx = volatiles.get();
				this.__loadClassInfo(eh.type(), volehclassdx);
				
				// Call instance handler check
				this.__invokeStatic(InvokeType.SYSTEM,
					NearNativeByteCodeHandler.JVMFUNC_CLASS,
					"jvmIsInstance", "(II)I",
					NativeCode.EXCEPTION_REGISTER, volehclassdx);
				
				// Cleanup
				volatiles.remove(volehclassdx);
				
				// If the return value is non-zero then it is an instance, in
				// which case we jump to the handler address.
				codebuilder.addIfNonZero(NativeCode.RETURN_REGISTER,
					this.__labelJavaTransition(sops,
						new InstructionJumpTarget(eh.handlerAddress())));
			}
			
			// No exception handler is available so, just fall through to the
			// caller as needed
			this.__generateReturn(enq);
			
			// Exception handler was generated
			didehfall = true;
		}
		
		// Generate transition labels
		Map<StateOperationsAndTarget, __EData__> trs = this._transits;
		for (Map.Entry<StateOperationsAndTarget, __EData__> e : trs.entrySet())
		{
			StateOperationsAndTarget sot = e.getKey();
			StateOperations ops = sot.operations;
			InstructionJumpTarget target = sot.target;
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 259);
			
			// Generate operations
			this.doStateOperations(ops);
			
			// Then just jump to the Java target
			codebuilder.addGoto(new NativeCodeLabel("java", target.target()));
		}
		
		return codebuilder.build();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/06
	 */
	@Override
	public final ByteCodeState state()
	{
		return this.state;
	}
	
	/**
	 * Checks if an array access is within bounds.
	 *
	 * @param __ir The instance register.
	 * @param __dxr The index register.
	 * @since 2019/04/27
	 */
	private final void __basicCheckArrayBound(int __ir, int __dxr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// This label is shared across many conditions
		NativeCodeLabel lab = this.__labelMakeException(
			"java/lang/ArrayIndexOutOfBoundsException");
		
		// If the index is negative then it is out of bounds
		codebuilder.addIfICmp(CompareType.LESS_THAN, __dxr, 0, lab);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volarraylen = volatiles.get();
		
		// Read length of array
		codebuilder.addMemoryOffConst(DataType.INTEGER, true,
			volarraylen,
			__ir, Constants.ARRAY_LENGTH_OFFSET);
		
		// If the index is greater or equal to the length then the access
		// is invalid
		codebuilder.addIfICmp(CompareType.GREATER_THAN_OR_EQUALS,
			__dxr, volarraylen, lab);
		
		// No longer needed
		volatiles.remove(volarraylen);
	}
	
	/**
	 * Checks if the target array can store this value.
	 *
	 * @param __ir The instance register.
	 * @param __vr The value register.
	 * @since 2019/04/27
	 */
	private final void __basicCheckArrayStore(int __ir, int __vr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Call helper class
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmCanArrayStore", "(II)I", __ir, __vr);
		
		// Was it invalid?
		codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelMakeException("java/lang/ArrayStoreException"));
	}
	
	/**
	 * Basic check if the instance is of the given class.
	 *
	 * @param __ir The register to check.
	 * @param __cl The class to check.
	 * @since 2019/04/22
	 */
	private final void __basicCheckCCE(int __ir, ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
			
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcldx = volatiles.get();
		
		// Load desired target class type
		this.__loadClassInfo(__cl, volwantcldx);
		
		// Call helper class
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmIsInstance", "(II)I", __ir, volwantcldx);
		
		// If the resulting method call returns zero then it is not an instance
		// of the given class. The return register is checked because the
		// value of that method will be placed there.
		codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelRefClearJump(this.__labelMakeException(
			"java/lang/ClassCastException")));
		
		// No longer needed
		volatiles.remove(volwantcldx);
	}
	
	/**
	 * Checks for divide by zero.
	 *
	 * @param __br The B register.
	 * @since 2019/06/24
	 */
	private final void __basicCheckDBZ(int __br)
	{
		// If the B register is zero, then we throw the exception
		this.codebuilder.addIfZero(__br, this.__labelMakeException(
			"java/lang/ArithmeticException"));
	}
	
	/**
	 * Checks that the given object is an array.
	 *
	 * @param __ir The type to check.
	 * @since 2019/04/27
	 */
	private final void __basicCheckIsArray(int __ir)
	{
		// Call internal helper
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS, "jvmIsArray",
			"(I)I", __ir);
		
		// If this is not an array, throw a class cast exception
		this.codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelRefClearJump(this.__labelMakeException(
			"java/lang/ClassCastException")));
	}
	
	/**
	 * Checks if the requested array allocation is negative.
	 *
	 * @param __lr The length register.
	 * @since 2019/06/28
	 */
	private final void __basicCheckNAS(int __lr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Check against less than zero
		codebuilder.addIfICmp(CompareType.LESS_THAN,
			__lr, NativeCode.ZERO_REGISTER, this.__labelRefClearJump(
			this.__labelMakeException(
				"java/lang/NegativeArraySizeException")));
	}
	
	/**
	 * Basic check if the instance is null.
	 *
	 * @param __ir The register to check.
	 * @since 2019/04/22
	 */
	private final void __basicCheckNPE(int __ir)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Just a plain zero check
		codebuilder.addIfZero(__ir, this.__labelRefClearJump(
			this.__labelMakeException("java/lang/NullPointerException")));
	}
	
	/**
	 * Checks if the given allocation ran out of memory.
	 *
	 * @param __ir The register to check.
	 * @since 2019/06/28
	 */
	private final void __basicCheckOOM(int __ir)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Just a plain zero check
		codebuilder.addIfZero(__ir, this.__labelRefClearJump(
			this.__labelMakeException("java/lang/OutOfMemoryError")));
	}
	
	/**
	 * Makes an EData for the current position and label.
	 *
	 * @param __lab The stored label.
	 * @return The made EData.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/26
	 */
	private final __EData__ __eData(NativeCodeLabel __lab)
		throws NullPointerException
	{
		if (__lab == null)
			throw new NullPointerException("NARG");
		
		ByteCodeState state = this.state;
		return new __EData__(state.addr, state.line,
			state.instruction.address(), state.instruction.operation(), __lab);
	}
	
	/**
	 * Generates an access to a field.
	 *
	 * @param __at The type of access to perform.
	 * @param __fr The reference to the field.
	 * @param __read Is a read being performed?
	 * @return The accessed field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	private final AccessedField __fieldAccess(FieldAccessType __at,
		FieldReference __fr, boolean __read)
		throws NullPointerException
	{
		if (__at == null || __fr == null)
			throw new NullPointerException("NARG");
		
		// Accessing final fields of another class will always be treated as
		// normal despite being in the constructor of a class
		if (!this.state.classname.equals(__fr.className()))
			return new AccessedField((__read ? FieldAccessTime.READ :
				FieldAccessTime.NORMAL), __at, __fr);
		return new AccessedField((__read ? FieldAccessTime.READ :
			this.defaultfieldaccesstime), __at, __fr);
	}
	
	/**
	 * Generates or jumps to another return point.
	 *
	 * @return The label to this return point.
	 * @since 2019/04/11
	 */
	private final NativeCodeLabel __generateReturn()
	{
		return this.__generateReturn(this.state.stack.possibleEnqueue());
	}
	
	/**
	 * Generates or jumps to another return point for the given enqueue.
	 *
	 * @param __eq The enqueue to return for.
	 * @return The label to this return point.
	 * @throws NullPointerException On null arguments.
	 * @return
	 */
	private final NativeCodeLabel __generateReturn(JavaStackEnqueueList __eq)
		throws NullPointerException
	{
		if (__eq == null)
			throw new NullPointerException("NARG");
		
		// Will be used to generate safe spots
		VolatileRegisterStack volatiles = this.volatiles;
		int ssh = -1,
			ssl = -1;
		
		// Find unique return point
		boolean freshdx;
		List<JavaStackEnqueueList> returns = this._returns;
		int dx = returns.indexOf(__eq);
		if ((freshdx = (dx < 0)))
			returns.add((dx = returns.size()), __eq);
		
		// Label used for return
		NativeCodeLabel lb = new NativeCodeLabel("return", dx);
		
		// If this was never added here, make sure a label exists
		if (freshdx)
			this.codebuilder.label(lb);
		
		// If the enqueue list is empty then the only thing we need to do
		// is generate a return instruction
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__eq.isEmpty())
		{
			// If this is synchronized, we need to exit the monitor
			if (this.issynchronized)
			{
				// Protect return value, if there is one
				if (this.isreturn)
				{
					ssh = volatiles.get();
					codebuilder.addCopy(NativeCode.RETURN_REGISTER, ssh);
				}
				
				// And wide value, if any
				if (this.isreturnwide)
				{
					ssl = volatiles.get();
					codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, ssl);
				}
				
				// Uncount and clear out
				this.__monitor(false, this.monitortarget);
				this.__refUncount(this.monitortarget);
				
				// Recover value, if any
				if (this.isreturn)
				{
					codebuilder.addCopy(ssh, NativeCode.RETURN_REGISTER);
					volatiles.remove(ssh);
				}
				
				// Recover wide, if any
				if (this.isreturnwide)
				{
					codebuilder.addCopy(ssl, NativeCode.RETURN_REGISTER + 1);
					volatiles.remove(ssl);
				}
			}
			
			// Debug exit
			codebuilder.add(NativeInstructionType.DEBUG_EXIT);
			
			// Since there is nothing to uncount, just return
			codebuilder.add(NativeInstructionType.RETURN);
			
			return lb;
		}
		
		// If we are not making a fresh index there more things to clear out
		// then just jump to the pre-existing return point
		if (!freshdx && __eq.size() > 1)
		{
			// Jump to label
			codebuilder.addGoto(lb);
			
			return lb;
		}
		
		// Protect return value, if there is one
		if (this.isreturn)
		{
			ssh = volatiles.get();
			codebuilder.addCopy(NativeCode.RETURN_REGISTER, ssh);
		}
		
		// And wide value, if any
		if (this.isreturnwide)
		{
			ssl = volatiles.get();
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, ssl);
		}
		
		// Since the enqueue list is not empty, we can just trim a register
		// from the top and recursively go down
		// So uncount the top
		this.__refUncount(__eq.top());
		
		// Recover value, if any
		if (this.isreturn)
		{
			codebuilder.addCopy(ssh, NativeCode.RETURN_REGISTER);
			volatiles.remove(ssh);
		}
		
		// Recover wide, if any
		if (this.isreturnwide)
		{
			codebuilder.addCopy(ssl, NativeCode.RETURN_REGISTER + 1);
			volatiles.remove(ssl);
		}
		
		// Recursively go down since the enqueues may possibly be shared, if
		// any of these enqueues were previously made then the recursive
		// call will just make a goto
		this.__generateReturn(__eq.trimTop());
		
		// Note that we do not return the recursive result because that
		// will be for another enqueue state
		return lb;
	}
	
	/**
	 * Invokes an assembly method.
	 *
	 * @param __name The method name.
	 * @param __type The method type.
	 * @param __out The result.
	 * @param __in The input.
	 * @throws NullPointerException If no name or type were specified.
	 * @since 2019/05/24
	 */
	private final void __invokeAssembly(MethodName __name,
		MethodDescriptor __type, JavaStackResult.Output __out,
		JavaStackResult.Input... __in)
		throws NullPointerException
	{
		if (__name == null || __type == null)
			throw new NullPointerException("NARG");
		
		// Code generator
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Force exception cancel for these operations
		this.state.canexception = false;
		
		// Depends on the assembly function
		String asmfunc;
		switch ((asmfunc = __name.toString()))
		{
				// Read lenght of array
			case "arrayLength":
				this.doArrayLength(__in[0], __out);
				break;
				
				// Atomic compare, get and set
			case "atomicCompareGetAndSet":
				codebuilder.add(
					NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET,
						__in[0].register,
						__out.register,
						__in[1].register,
						__in[2].register,
						0);
				break;
				
				// Atomic decrement and get
			case "atomicDecrementAndGet":
				codebuilder.add(
					NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
						__out.register,
						__in[0].register,
						0);
				break;
				
				// Atomic increment
			case "atomicIncrement":
				codebuilder.add(
					NativeInstructionType.ATOMIC_INT_INCREMENT,
						__in[0].register,
						0);
				break;
				
				// Breakpoint
			case "breakpoint":
				codebuilder.add(NativeInstructionType.BREAKPOINT);
				break;
				
				// Load boolean class
			case "classInfoOfBoolean":
				this.__loadClassInfo("boolean", __out.register);
				break;
				
				// Load byte class
			case "classInfoOfByte":
				this.__loadClassInfo("byte", __out.register);
				break;
				
				// Load short class
			case "classInfoOfShort":
				this.__loadClassInfo("short", __out.register);
				break;
				
				// Load character class
			case "classInfoOfCharacter":
				this.__loadClassInfo("char", __out.register);
				break;
				
				// Load int class
			case "classInfoOfInteger":
				this.__loadClassInfo("int", __out.register);
				break;
				
				// Load float class
			case "classInfoOfFloat":
				this.__loadClassInfo("float", __out.register);
				break;
				
				// Load long class
			case "classInfoOfLong":
				this.__loadClassInfo("long", __out.register);
				break;
				
				// Load double class
			case "classInfoOfDouble":
				this.__loadClassInfo("double", __out.register);
				break;
				
				// Long/Double bits
			case "doubleToRawLongBits":
			case "longBitsToDouble":
				if (__in[0].register != __out.register)
				{
					int a = __in[0].register,
						b = __out.register;
					
					codebuilder.addCopy(a, b);
					codebuilder.addCopy(a + 1, b + 1);
				}
				break;
				
				// Exception handling
			case "exceptionHandle":
				// This generates no actual codes to check the exception,
				// it just makes the exception check run so that they are
				// checked
				this.state.canexception = true;
				break;
				
				// Integer/Float bits
			case "floatToRawIntBits":
			case "intBitsToFloat":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// Invoke method (possibly return a value)
			case "invoke":
			case "invokeV":
			case "invokeVL":
				{
					// Invoked methods can thrown an exception, so do
					// checks! Otherwise the behavior we expect might not
					// happen
					this.state.canexception = true;
					
					// Build the register List
					List<Integer> args = new ArrayList<>();
					int n = __in.length;
					for (int i = 2; i < n; i++)
						args.add(__in[i].register);
					
					// Before we invoke we need to set the next pool so
					// execution is correct!
					codebuilder.addCopy(__in[1].register,
						NativeCode.NEXT_POOL_REGISTER);
					
					// Invoke pointer with arguments
					codebuilder.add(NativeInstructionType.INVOKE,
						__in[0].register, new RegisterList(args));
					
					// Copy return value?
					switch (asmfunc)
					{
						case "invokeV":
							codebuilder.addCopy(NativeCode.RETURN_REGISTER,
									__out.register);
							break;
							
						case "invokeVL":
							codebuilder.addCopy(NativeCode.RETURN_REGISTER,
									__out.register);
							codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
								__out.register + 1);
							break;
					}
				}
				break;
				
				// Double/Long pack
			case "doublePack":
			case "longPack":
				if (__in[1].register != __out.register + 1)
					codebuilder.addCopy(__in[1].register, __out.register + 1);
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
			
				// Long unpack high
			case "longUnpackHigh":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// Long unpack low
			case "longUnpackLow":
				if (__in[0].register + 1 != __out.register)
					codebuilder.addCopy(__in[0].register + 1, __out.register);
				break;
				
				// Read byte memory
			case "memReadByte":
				codebuilder.addMemoryOffReg(DataType.BYTE,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read int memory
			case "memReadInt":
				codebuilder.addMemoryOffReg(DataType.INTEGER,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read java int memory
			case "memReadJavaInt":
				codebuilder.addMemoryOffRegJava(DataType.INTEGER,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read short memory
			case "memReadJavaShort":
				codebuilder.addMemoryOffRegJava(DataType.SHORT,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read short memory
			case "memReadShort":
				codebuilder.addMemoryOffReg(DataType.SHORT,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Write byte memory
			case "memWriteByte":
				codebuilder.addMemoryOffReg(DataType.BYTE,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write int memory
			case "memWriteInt":
				codebuilder.addMemoryOffReg(DataType.INTEGER,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write Java int memory
			case "memWriteJavaInt":
				codebuilder.addMemoryOffRegJava(DataType.INTEGER,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write Java short memory
			case "memWriteJavaShort":
				codebuilder.addMemoryOffRegJava(DataType.SHORT,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write short memory
			case "memWriteShort":
				codebuilder.addMemoryOffReg(DataType.SHORT,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
			
				// object -> pointer
			case "objectToPointer":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// object -> pointer, with ref clear
			case "objectToPointerRefQueue":
				// Push references
				this.__refPush();
				
				// Do the copy
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				
				// Clear references
				this.__refClear();
				break;
			
				// pointer -> object (and variants)
			case "pointerToObject":
			case "pointerToClassInfo":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				
				// The returned object is electable for reference
				// counting so we need to count it up otherwise it will
				// be just freed (this is just a plain copy)
				this.__refCount(__out.register);
				break;
				
				// Reference count up
			case "refCount":
				this.__refCount(__in[0].register);
				break;
				
				// Reference count down
			case "refUncount":
				this.__refUncount(__in[0].register);
				break;
				
				// Return from frame
			case "returnFrame":
				// This may be a variant which returns multiple values
				switch (__type.toString())
				{
					case "(II)V":
						codebuilder.addCopy(__in[0].register,
							NativeCode.RETURN_REGISTER);
						codebuilder.addCopy(__in[1].register,
							NativeCode.RETURN_REGISTER + 1);
						break;
						
					case "(I)V":
						codebuilder.addCopy(__in[0].register,
							NativeCode.RETURN_REGISTER);
						break;
				}
				
				// Always return at the end
				this.__generateReturn();
				break;
				
				// Get the exception register
			case "specialGetExceptionRegister":
				codebuilder.addCopy(NativeCode.EXCEPTION_REGISTER,
					__out.register);
				break;
				
				// Gets the pool register
			case "specialGetPoolRegister":
				codebuilder.addCopy(NativeCode.POOL_REGISTER,
					__out.register);
				break;
				
				// Read return register
			case "specialGetReturnRegister":
			case "specialGetReturnHighRegister":
				codebuilder.addCopy(NativeCode.RETURN_REGISTER,
					__out.register);
				break;
				
				// Read return register (low value)
			case "specialGetReturnLowRegister":
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
					__out.register);
				break;
				
				// Get static field register
			case "specialGetStaticFieldRegister":
				codebuilder.addCopy(NativeCode.STATIC_FIELD_REGISTER,
					__out.register);
				break;
				
				// Get thread register
			case "specialGetThreadRegister":
				codebuilder.addCopy(NativeCode.THREAD_REGISTER,
					__out.register);
				break;
				
				// Set the exception register
			case "specialSetExceptionRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.EXCEPTION_REGISTER);
				break;
				
				// Set pool register
			case "specialSetPoolRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.POOL_REGISTER);
				break;
				
				// Set static field register
			case "specialSetStaticFieldRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.STATIC_FIELD_REGISTER);
				break;
				
				// Set thread register
			case "specialSetThreadRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.THREAD_REGISTER);
				break;
				
				// System calls
			case "sysCall":
			case "sysCallV":
				this.__invokeSysCall(false, false, __out, __in);
				break;
				
				// System calls (long return value)
			case "sysCallVL":
				this.__invokeSysCall(false, true, __out, __in);
				break;
				
				// Pure system calls
			case "sysCallP":
			case "sysCallPV":
				this.__invokeSysCall(true, false, __out, __in);
				break;
				
				// Pure system calls (long return value)
			case "sysCallPVL":
				this.__invokeSysCall(true, true, __out, __in);
				break;
			
			default:
				throw new todo.OOPS(asmfunc);
		}
	}
	
	/**
	 * Invokes instance method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeInstance(InvokeType __it, ClassName __cl,
		String __mn, String __mt, RegisterList __args)
		throws NullPointerException
	{
		this.__invokeInstance(__it, __cl, new MethodName(__mn),
			new MethodDescriptor(__mt), __args);
	}
	
	/**
	 * Invokes instance method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeInstance(InvokeType __it, ClassName __cl,
		MethodName __mn, MethodDescriptor __mt, RegisterList __args)
		throws NullPointerException
	{
		if (__it == null || __cl == null || __mn == null || __mt == null ||
			__args == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles to work with
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassid = volatiles.get(),
			volvtable = volatiles.get(),
			methodptr = volatiles.get(),
			volptable = volatiles.get();
		
		// Special invocation?
		boolean isspecial = (__it == InvokeType.SPECIAL);
		
		// Performing a special invoke which has some modified rules
		if (isspecial)
		{
			// Are we calling a constructor?
			boolean wantcons = __mn.isInstanceInitializer();
			
			// Is the target in this same class?
			boolean sameclass = __cl.equals(this.state.classname);
			
			// Use the exactly specified method if:
			//  * It is an initializer, we want to call that exact one
			//  * The target class is the same class of the current class
			//    being processed (private method)
			if (wantcons || sameclass)
				this.__loadClassInfo(__cl, volclassid);
			
			// Otherwise, we will be calling a super method so we need to load
			// the super class of our current class
			else
			{
				// Read the super class of our current class
				int volscfo = volatiles.get();
				codebuilder.add(NativeInstructionType.LOAD_POOL,
					new AccessedField(FieldAccessTime.NORMAL,
						FieldAccessType.INSTANCE,
					new FieldReference(
						new ClassName("cc/squirreljme/jvm/ClassInfo"),
						new FieldName("superclass"),
						new FieldDescriptor(
							"Lcc/squirreljme/jvm/ClassInfo;"))),
					volvtable);
				codebuilder.addMemoryOffReg(DataType.INTEGER, true,
					volclassid, volclassid, volscfo);
				
				// Cleanup
				volatiles.remove(volscfo);
			}
		}
		
		// Otherwise, we will purely act on the class of the instance type
		else
			codebuilder.addMemoryOffReg(DataType.INTEGER, true,
				volclassid, __args.get(0), Constants.OBJECT_CLASS_OFFSET);
		
		// Load the VTable (from the class we obtained above)
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("vtablevirtual"),
				new FieldDescriptor("[I"))),
			volvtable);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volvtable, volclassid, volvtable);
		
		// Load the pool table which is mapped with the vtable
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("vtablepool"),
				new FieldDescriptor("[I"))),
			volptable);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volptable, volclassid, volptable);
		
		// Method index
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new MethodIndex(__cl, __mn, __mt), methodptr);
			
		// Load from the pool table
		codebuilder.add(NativeInstructionType.LOAD_FROM_INTARRAY,
			NativeCode.NEXT_POOL_REGISTER, volptable, methodptr);
		
		// Load method pointer (from integer based array)
		codebuilder.add(NativeInstructionType.LOAD_FROM_INTARRAY,
			methodptr, volvtable, methodptr);
		
		// Invoke the method pointer
		codebuilder.add(NativeInstructionType.INVOKE,
			methodptr, __args);
		
		// Cleanup volatiles
		volatiles.remove(volclassid);
		volatiles.remove(volvtable);
		volatiles.remove(methodptr);
		volatiles.remove(volptable);
	}
	
	/**
	 * Allocates a new object.
	 *
	 * @param __cl The class to create.
	 * @param __out The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeNew(ClassName __cl, int __out)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need a volatile
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcl = volatiles.get();
		
		// Load class data
		this.__loadClassInfo(__cl, volwantcl);
		
		// Call allocator, copy to result
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS, "jvmNew",
			"(I)I", volwantcl);
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __out);
		
		// Not needed
		volatiles.remove(volwantcl);
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, String __cl,
		String __mn, String __mt, int... __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, new ClassName(__cl), new MethodName(__mn),
			new MethodDescriptor(__mt), new RegisterList(__args));
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, String __cl,
		String __mn, String __mt, RegisterList __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, new ClassName(__cl), new MethodName(__mn),
			new MethodDescriptor(__mt), __args);
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, ClassName __cl,
		String __mn, String __mt, int... __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, __cl, new MethodName(__mn),
			new MethodDescriptor(__mt), new RegisterList(__args));
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, ClassName __cl,
		MethodName __mn, MethodDescriptor __mt, RegisterList __args)
		throws NullPointerException
	{
		if (__it == null || __cl == null || __mn == null || __mt == null ||
			__args == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatile
		VolatileRegisterStack volatiles = this.volatiles;
		int volsmp = volatiles.get(),
			volexe = volatiles.get();
		
		// Load address of the target method
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new InvokedMethod((__it == InvokeType.SYSTEM ? InvokeType.STATIC :
			__it), new MethodHandle(__cl, __mn, __mt)), volsmp);
		
		// Load constant pool of the target class
		this.__loadClassPool(__cl, NativeCode.NEXT_POOL_REGISTER);
		
		// Create a backup of the exception register (system mode)
		if (__it == InvokeType.SYSTEM)
		{
			codebuilder.addCopy(NativeCode.EXCEPTION_REGISTER, volexe);
			codebuilder.addCopy(NativeCode.ZERO_REGISTER,
				NativeCode.EXCEPTION_REGISTER);
		}
		
		// Invoke the static pointer
		codebuilder.add(NativeInstructionType.INVOKE,
			volsmp, __args);
		
		// If the system invoke (which could be from special code) threw an
		// exception just replace our current exception with that one since
		// it definitely would be worse!
		if (__it == InvokeType.SYSTEM)
		{
			NativeCodeLabel doublefault = new NativeCodeLabel(
				"doublefault", this._refclunk++);
			codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				doublefault);
			
			// Restore our old exception register
			codebuilder.addCopy(volexe, NativeCode.EXCEPTION_REGISTER);
			
			// Target point for double fault
			codebuilder.label(doublefault);
		}
		
		// Not needed
		volatiles.remove(volexe);
		volatiles.remove(volsmp);
	}
	
	/**
	 * Invokes a system call, which can either be pure or unpure.
	 *
	 * @param __pure Is the system call pure?
	 * @param __long Is this a long system call?
	 * @param __out The return register, may be set.
	 * @param __in The input system call arguments.
	 * @since 2109/05/27
	 */
	private final void __invokeSysCall(boolean __pure, boolean __long,
		JavaStackResult.Output __out, JavaStackResult.Input... __in)
	{
		// Invoked methods can thrown an exception, so do
		// checks! Otherwise the behavior we expect might not
		// happen
		this.state.canexception = true;
		
		// Invoke of pure system call?
		if (__pure)
		{
			// Build the register List
			List<Integer> args = new ArrayList<>();
			int n = __in.length;
			for (int i = 1; i < n; i++)
				args.add(__in[i].register);
			
			// Perform the pure call
			this.codebuilder.add(NativeInstructionType.SYSTEM_CALL,
				__in[0].register, new RegisterList(args));
			
			// Need to store the return value of this call
			VolatileRegisterStack volatiles = this.volatiles;
			int rvlo = volatiles.get(),
				rvhi = volatiles.get();
			
			// Defensive copy of return value
			if (__out != null)
			{
				// Low
				this.codebuilder.addCopy(NativeCode.RETURN_REGISTER, rvlo);
				
				// High
				if (__long)
					this.codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, rvhi);
			}
			
			// Load the system call index for IPC exception store
			int ipcesid = volatiles.get();
			this.codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
				NativeCode.ZERO_REGISTER, SystemCallIndex.EXCEPTION_STORE,
				ipcesid);
			
			// Perform system call to clear and read exception
			this.codebuilder.add(NativeInstructionType.SYSTEM_CALL,
				ipcesid, new RegisterList(NativeCode.ZERO_REGISTER));
			
			// Quickly copy out exception value
			int eval = volatiles.get();
			this.codebuilder.addCopy(NativeCode.RETURN_REGISTER, eval);
			
			// If this value is set, then we fail
			this.codebuilder.addIfNonZero(eval,
				this.__labelMakeException("cc/squirreljme/jvm/IPCException"));
			
			// Copy out the moved out return values
			if (__out != null)
			{
				// Low value
				this.codebuilder.addCopy(rvlo, __out.register);
				
				// Possible high value
				if (__long)
					this.codebuilder.addCopy(rvhi, __out.register + 1);
			}
			
			// No longer needed
			volatiles.remove(eval);
			volatiles.remove(ipcesid);
			volatiles.remove(rvhi);
			volatiles.remove(rvlo);
		}
		
		// Unpure system call (possibly adapted by our own handler)
		else
		{
			// Since this is a standard invocation, we just pass all the
			// input arguments as is
			int n = __in.length;
			int[] args = new int[n];
			for (int i = 0; i < n; i++)
				args[i] = __in[i].register;
			
			// Perform the unpure call into the JVM helper
			this.__invokeStatic(InvokeType.SYSTEM,
				NearNativeByteCodeHandler.JVMFUNC_CLASS,
				"jvmSystemCall", "(SIIIIIIII)J", args);
				
			// Copy return value
			if (__out != null)
			{
				// Low value
				this.codebuilder.addCopy(NativeCode.RETURN_REGISTER,
					__out.register);
				
				// Possible high value
				if (__long)
					this.codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
						__out.register + 1);
			}
		}
	}
	
	/**
	 * Creates and stores an exception.
	 *
	 * @return The label to the exception.
	 * @since 2019/04/09
	 */
	private final NativeCodeLabel __labelException()
	{
		// Get both states for when an exception is handled (transition) and
		// for where it is not handled (full cleanup)
		ByteCodeState state = this.state;
		JavaStackResult handled = state.stack.doExceptionHandler(),
			nothandled = state.stack.doDestroy(false);
		
		// The byte code handler does not know about exception registers so
		// we need to add this operation in so it is handled correctly
		List<StateOperation> newsop = new ArrayList<>();
		for (StateOperation o : handled.operations())
			newsop.add(o);
		newsop.add(StateOperation.copy(false,
			NativeCode.EXCEPTION_REGISTER, handled.out(0).register));
		
		// Clear the exception register when it is handled, otherwise it
		// will just cause an exception fall off when the register is next
		// checked
		newsop.add(StateOperation.copy(false, NativeCode.ZERO_REGISTER,
			NativeCode.EXCEPTION_REGISTER));
		
		// Setup key
		ExceptionHandlerTransition key = new ExceptionHandlerTransition(
			new StateOperations(newsop), nothandled.enqueue(),
			state.exceptionranges.tableOf(state.addr));
		
		// Try to use an already existing point
		Map<ExceptionHandlerTransition, __EData__> ehtable = this._ehtable;
		__EData__ rv = ehtable.get(key);
		if (rv != null)
			return rv.label;
			
		// Build new data to record this point
		rv = this.__eData(new NativeCodeLabel("exception", ehtable.size()));
		ehtable.put(key, rv);
		
		// Return the created label (where the caller jumps to)
		return rv.label;
	}
	
	/**
	 * Makes a lable which goes from this address to the target address. If
	 * the target address is poisoned then the current stack will be adapted
	 * to the target state through a transition method. Otherwise if the target
	 * is not poisoned it will be a normal jump.
	 *
	 * @param __jt The jump target.
	 * @return The label of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	private final NativeCodeLabel __labelJava(InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		ByteCodeState state = this.state;
		JavaStackState sourcestack = state.stack;
		
		// If the target stack state matches the current state then no
		// adapting is required at all
		int target = __jt.target();
		JavaStackState targetstack = state.stacks.get(target);
		if (sourcestack.equals(targetstack))
			return new NativeCodeLabel("java", target);
		
		// Do a transition to the target stack
		return this.__labelJavaTransition(sourcestack.
			doTransition(targetstack).operations(), __jt);
	}
	
	/**
	 * Creates the actual label which is used for the state transition.
	 *
	 * @param __sops The operation to use.
	 * @param __jt The jump target in the Java address space.
	 * @return The label for this transition.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	private final NativeCodeLabel __labelJavaTransition(StateOperations __sops,
		InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__sops == null || __jt == null)
			throw new NullPointerException("NARG");
		
		// If no operations were generated then just use a normal jump since
		// there is no point in transitioning anyway
		if (__sops.isEmpty())
			return new NativeCodeLabel("java", __jt.target());
		
		// Setup key
		StateOperationsAndTarget key =
			new StateOperationsAndTarget(__sops, __jt);
		
		// Determine if such a transition was already done, since if the
		// transition is exactly the same we do not need to actually do
		// anything
		Map<StateOperationsAndTarget, __EData__> transits = this._transits;
		__EData__ rv = transits.get(key);
		if (rv != null)
			return rv.label;
		
		// Setup transition for later
		ByteCodeState state = this.state;
		rv = this.__eData(new NativeCodeLabel("transit", transits.size()));
		transits.put(key, rv);
		
		return rv.label;
	}
	
	/**
	 * Makes a label which creates the given exception then throws that
	 * exception.
	 *
	 * @param __cl The class to create.
	 * @return The label for that target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	private final NativeCodeLabel __labelMakeException(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Setup key, the label is the target to jump to after the exception
		// has been generated and a throw is performed
		ByteCodeState state = this.state;
		ClassAndLabel key = new ClassAndLabel(new ClassName(__cl),
			this.__labelException());
		
		// Look in the table to see if we made it before
		Map<ClassAndLabel, __EData__> metable = this._metable;
		__EData__ rv = metable.get(key);
		if (rv != null)
			return rv.label;
		
		// Build new data to record this point
		rv = this.__eData(new NativeCodeLabel("makeexception",
			metable.size()));
		metable.put(key, rv);
		
		// Return the created label (where the caller jumps to)
		return rv.label;
	}
	
	/**
	 * Creates a label to potentially reference clear and jumps to the given
	 * label. This uses the current ref queue table.
	 *
	 * @param __tl The target label.
	 * @return The transition label for reference clearing or {@code __tl}
	 * if there are no references to clear.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	private final NativeCodeLabel __labelRefClearJump(NativeCodeLabel __tl)
		throws NullPointerException
	{
		if (__tl == null)
			throw new NullPointerException("NARG");
		
		return this.__labelRefClearJump(this._lastenqueue, __tl);
	}
	
	/**
	 * Creates a label to potentially reference clear and jumps to the given
	 * label.
	 *
	 * @param __eql The reference queue label.
	 * @param __tl The target label.
	 * @return The transition label for reference clearing or {@code __tl}
	 * if there are no references to clear.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	private final NativeCodeLabel __labelRefClearJump(
		JavaStackEnqueueList __eql, NativeCodeLabel __tl)
		throws NullPointerException
	{
		if (__tl == null)
			throw new NullPointerException("NARG");
		
		// If not clearing anything, just return the target label
		if (__eql == null || __eql.isEmpty())
			return __tl;
		
		// Setup key
		EnqueueAndLabel key = new EnqueueAndLabel(__eql, __tl);
		
		// Did we make this before?
		Map<EnqueueAndLabel, __EData__> refcljumps = this._refcljumps;
		__EData__ rv = refcljumps.get(key);
		if (rv != null)
			return rv.label;
		
		// Setup new record
		ByteCodeState state = this.state;
		rv = this.__eData(new NativeCodeLabel("refclear", refcljumps.size()));
		refcljumps.put(key, rv);
		
		// Use the created label
		return rv.label;
	}
	
	/**
	 * Loads the class information for a class.
	 *
	 * @param __cl The class to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/19
	 */
	private final void __loadClassInfo(String __cl, int __r)
		throws NullPointerException
	{
		this.__loadClassInfo(new ClassName(__cl), __r);
	}
	
	/**
	 * Loads the class information for a class.
	 *
	 * @param __cl The class to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	private final void __loadClassInfo(ClassName __cl, int __r)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Used for loading code
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Attempt load to the target register
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new ClassInfoPointer(__cl), __r);
		
		// Detect classes which are dynamically initialized or self
		if (!ClassLoadingAdjustments.isDeferredLoad(this.state.classname.toString(),
			__cl.toString()))
			return;
		
		// If the class is already loaded do not try loading
		NativeCodeLabel isloaded = new NativeCodeLabel("ciisloaded",
			this._refclunk++);
		codebuilder.addIfNonZero(__r, isloaded);
		
		// Need register to load the class info
		VolatileRegisterStack volatiles = this.volatiles;
		int volnoted = volatiles.get();
		
		// Load the noted class name
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new NotedString(__cl.toString()), volnoted);
		
		// Initialize the class
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmInitClass", "(I)Lcc/squirreljme/jvm/ClassInfo;", volnoted);
		
		// Store the result of the init into the pool
		codebuilder.add(NativeInstructionType.STORE_POOL,
			new ClassInfoPointer(__cl), NativeCode.RETURN_REGISTER);
		
		// Use the value of it
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __r);
		
		// Cleanup
		volatiles.remove(volnoted);
		
		// End point is here
		codebuilder.label(isloaded);
	}
	
	/**
	 * Loads the Class object for the given class into the given register.
	 *
	 * @param __cl The class to load.
	 * @param __r The register to place it in.
	 * @since 2019/04/26
	 */
	private final void __loadClassObject(ClassName __cl, int __r)
	{
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Load the class info for the class
		int volcdvt = volatiles.get();
		this.__loadClassInfo(__cl, volcdvt);
		
		// Call internal class object loader
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmLoadClass", "(I)Ljava/lang/Class;", volcdvt);
		
		// Cleanup
		volatiles.remove(volcdvt);
		
		// Copy return value to the output register
		this.codebuilder.addCopy(NativeCode.RETURN_REGISTER, __r);
	}
	
	/**
	 * Loads the constant pool for the given class.
	 *
	 * @param __cl The class pool to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	private final void __loadClassPool(ClassName __cl, int __r)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Used for loading code
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Load class pool which may already be loaded
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new ClassPool(__cl), __r);
		
		// Detect classes which are dynamically initialized
		if (!ClassLoadingAdjustments.isDeferredLoad(this.state.classname.toString(),
			__cl.toString()))
			return;
		
		// Jump if the pool is already loaded
		NativeCodeLabel isloaded = new NativeCodeLabel("piisloaded",
			this._refclunk++);
		codebuilder.addIfNonZero(__r, isloaded);
		
		// Need volatile to get the class info
		VolatileRegisterStack volatiles = this.volatiles;
		int volcinfo = volatiles.get(),
			volpoolv = volatiles.get(),
			volscfo = volatiles.get();
		
		// Load the ClassInfo for the class we want
		this.__loadClassInfo(__cl, volcinfo);
		
		// Load pool pointer from this ClassInfo
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("pool"),
				new FieldDescriptor("I"))), volscfo);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volpoolv, volcinfo, volscfo);
		
		// Store it
		codebuilder.add(NativeInstructionType.STORE_POOL,
			new ClassPool(__cl), volpoolv);
		
		// Cleanup
		volatiles.remove(volcinfo);
		volatiles.remove(volpoolv);
		volatiles.remove(volscfo);
		
		// End point is here
		codebuilder.label(isloaded);
	}
	
	/**
	 * Enters the monitor.
	 *
	 * @param __enter Is the monitor being entered? 
	 * @param __r The register to enter a monitor for.
	 * @since 2019/04/26
	 */
	private final void __monitor(boolean __enter, int __r)
	{
		// Call helper method
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			(__enter ? "jvmMonitorEnter" : "jvmMonitorExit"), "(I)V", __r);
	}
	
	/**
	 * If anything has been previously pushed then generate code to clear it.
	 *
	 * @since 2019/03/30
	 */
	private final void __refClear()
	{
		// Do nothing if nothing has been enqueued
		JavaStackEnqueueList lastenqueue = this._lastenqueue;
		if (lastenqueue == null)
			return;
		
		// No need to clear anymore
		this.__refReset();
		
		// Un-count all of them accordingly
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (int i = 0, n = lastenqueue.size(); i < n; i++)
		{
			// Get the volatile to clear
			int v = lastenqueue.get(i);
			
			// Uncount this one
			this.__refUncount(v);
			
			// Free it for later usage
			volatiles.remove(v);
		}
	}
	
	/**
	 * Generates code to reference count the given register.
	 *
	 * @param __r The register to reference to count.
	 * @since 2019/04/25
	 */
	private final void __refCount(int __r)
	{
		// If the object is null then it will not be counted, this is skipped
		NativeCodeLabel ncj = new NativeCodeLabel("refnocount",
			this._refclunk++);
		
		// Do not do any counting if this is zero
		NativeCodeBuilder codebuilder = this.codebuilder;
		codebuilder.addIfZero(__r, ncj);
		
		// Add count
		codebuilder.add(NativeInstructionType.ATOMIC_INT_INCREMENT,
			__r, Constants.OBJECT_COUNT_OFFSET);
		
		// No count is jumped here
		codebuilder.label(ncj);
	}
	
	/**
	 * Generates code to enqueue registers, if there are any. This implicitly
	 * uses the registers from the state.
	 *
	 * @return True if the push list was not empty.
	 * @since 2019/04/10
	 */
	private final boolean __refPush()
		throws NullPointerException
	{
		return this.__refPush(this.state.result.enqueue());
	}
	
	/**
	 * Generates code to enqueue registers, if there are any.
	 *
	 * @param __r The registers to push.
	 * @return True if the push list was not empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	private final boolean __refPush(JavaStackEnqueueList __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// Nothing to enqueue?
		if (__r.isEmpty())
		{
			this.__refReset();
			return false;
		}
		
		// Place anything that is referenced into volatile registers
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Get a volatile register and copy into it, store the volatile
		int n = __r.size();
		int[] use = new int[n];
		for (int i = 0; i < n; i++)
		{
			// Get the volatile register to copy into
			int v = volatiles.get();
			
			// Copy to the volatile
			codebuilder.addCopy(__r.get(i), v);
			
			// Use this volatile register
			use[i] = v;
		}
		
		// We completely lose our original registers and instead use our new
		// set of volatiles for later clearing and removing
		// Note that we keep the same stack offset because it will match
		// exactly as the input (needed for exception handlers), even though
		// the registers might be all over the place.
		this._lastenqueue = new JavaStackEnqueueList(__r.stackstart, use);
		
		// Did enqueue something
		return true;
	}
	
	/**
	 * Resets the reference queue so nothing uses it.
	 *
	 * @since 2019/11/24
	 */
	private final void __refReset()
	{
		this._lastenqueue = null;
	}
	
	/**
	 * Generates code to reference uncount the given register.
	 *
	 * @param __r The register to reference to uncount.
	 * @since 2019/04/25
	 */
	private final void __refUncount(int __r)
	{
		// If the object is null then it will not be uncounted, this is skipped
		NativeCodeLabel ncj = new NativeCodeLabel("refnouncount",
			this._refclunk++);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volnowcount = volatiles.get();
		
		// Do not do any uncounting if this is null
		NativeCodeBuilder codebuilder = this.codebuilder;
		codebuilder.addIfZero(__r, ncj);
		
		// Add uncount
		codebuilder.add(NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
			volnowcount, __r, Constants.OBJECT_COUNT_OFFSET);
		
		// If the count is still positive, we do not GC
		codebuilder.addIfPositive(volnowcount, ncj);
		
		// Call garbage collect on object via helper
		this.__invokeStatic(InvokeType.SYSTEM,
			NearNativeByteCodeHandler.JVMFUNC_CLASS,
			"jvmGarbageCollectObject", "(I)V", __r);
		
		// Reset the variable to zero to prevent it from being used again
		codebuilder.addCopy(NativeCode.ZERO_REGISTER, __r);
		
		// No uncount or not GCed are jumped here
		codebuilder.label(ncj);
		
		// No longer needed
		volatiles.remove(volnowcount);
	}
	
	/**
	 * Uses the given EData and returns the used label.
	 *
	 * @param __ed The data to use.
	 * @return The label.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/25
	 */
	private final NativeCodeLabel __useEDataAndGetLabel(__EData__ __ed)
		throws NullPointerException
	{
		if (__ed == null)
			throw new NullPointerException("NARG");
		
		// Setup state
		ByteCodeState state = this.state;
		state.addr = __ed.addr;
		state.line = __ed.line;
		
		// And return the label
		return __ed.label;
	}
	
	/**
	 * Sets debug point information for edata.
	 *
	 * @param __ed The EData used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	private final void __useEDataDebugPoint(__EData__ __ed, int __jop)
		throws NullPointerException
	{
		if (__ed == null)
			throw new NullPointerException("NARG");
		
		// Add debug point (operation becomes debug point 1)
		this.codebuilder.add(NativeInstructionType.DEBUG_POINT,
			__ed.line & 0x7FFF, __jop,
			__ed.jpc & 0x7FFF);
	}
}

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

package dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Iterator;

/**
 * This represents a list of registers.
 *
 * @since 2019/03/22
 */
public final class RegisterList
{
	/** The registers used. */
	private final int[] _registers;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the list of registers.
	 *
	 * @param __r The registers to use.
	 * @since 2019/03/22
	 */
	public RegisterList(int... __r)
	{
		this._registers = (__r == null ? new int[0] : __r.clone());
	}
	
	/**
	 * Initializes the list of registers.
	 *
	 * @param __r The registers to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public RegisterList(Collection<Integer> __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		int n = __r.size();
		int[] regs = new int[n];
		Iterator<Integer> it = __r.iterator();
		for (int i = 0; i < n; i++)
			regs[i] = it.next();
		
		this._registers = regs;
	}
	
	/**
	 * Gets the register at the given index.
	 *
	 * @param __i The index to get.
	 * @return The register at the given index.
	 * @since 2019/03/26
	 */
	public final int get(int __i)
	{
		return this._registers[__i];
	}
	
	/**
	 * Returns the size of the list.
	 *
	 * @return The list size.
	 * @since 2019/03/26
	 */
	public final int size()
	{
		return this._registers.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Build list
			StringBuilder sb = new StringBuilder("R[");
			boolean comma = false;
			for (int i : this._registers)
			{
				if (comma)
					sb.append(", ");
				comma = true;
				
				sb.append(i);
			}
			sb.append(']');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/StateOperationsAndTarget.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.StateOperations;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.InstructionJumpTarget;

/**
 * This represents state operations and a target.
 *
 * @since 2019/04/12
 */
public final class StateOperationsAndTarget
{
	/** State Operations. */
	protected final StateOperations operations;
	
	/** Jump target. */
	protected final InstructionJumpTarget target;
	
	/** Hashcode. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the operations and target.
	 *
	 * @param __ops The operations.
	 * @param __t The target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperationsAndTarget(StateOperations __ops,
		InstructionJumpTarget __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.operations = __ops;
		this.target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof StateOperationsAndTarget))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		StateOperationsAndTarget o = (StateOperationsAndTarget)__o;
		return this.operations.equals(o.operations) &&
			this.target.equals(o.target);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.operations.hashCode() ^
				this.target.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.operations + "+@" +
				this.target));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/VolatileRegisterStack.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

import java.util.ArrayList;
import java.util.Collection;

/**
 * This is a stack which is used to manage which volatile registers are used.
 *
 * @since 2019/05/24
 */
public final class VolatileRegisterStack
{
	/** The base register. */
	protected final int base;
	
	/** Registers being used. */
	private final Collection<Integer> _used =
		new ArrayList<>();
	
	/**
	 * Initializes the volatile stack.
	 *
	 * @param __b The base register.
	 * @since 2019/05/25
	 */
	public VolatileRegisterStack(int __b)
	{
		this.base = __b;
	}
	
	/**
	 * Clears all of the used volatile reisters.
	 *
	 * @since 2019/05/25
	 */
	public final void clear()
	{
		this._used.clear();
	}
	
	/**
	 * Returns the next volatile register.
	 *
	 * @return The next volatile register.
	 * @throws IllegalStateException If no registers are available.
	 * @since 2019/05/24
	 */
	public final int get()
		throws IllegalStateException
	{
		// Find next register to use from the base, use any register which
		// was not previously recorded
		int at = this.base;
		Collection<Integer> used = this._used;
		while (used.contains(at))
			at++;
		
		// {@squirreljme.error JC4l Exceeded maximum permitted registers.
		// (The base register)}
		if (at >= NativeCode.MAX_REGISTERS)
			throw new IllegalStateException("JC4l " + this.base);
		
		// Record it
		used.add(at);
		return at;
	}
	
	/**
	 * Removes the given volatile register from usage.
	 *
	 * @param __r The register to remove.
	 * @throws IllegalStateException If it was never used.
	 * @since 2019/05/24
	 */
	public final void remove(int __r)
		throws IllegalStateException
	{
		// {@squirreljme.error JC13 Register to remove was never previously
		// returned or was removed multiple times. (The register)}
		if (!this._used.remove(__r))
			throw new IllegalStateException("JC13 " + __r);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/__Debug__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * Stores debug enabled flag.
 *
 * @since 2019/04/16
 */
final class __Debug__
{
	/** Debug enabled? */
	public static final boolean ENABLED;
	
	/**
	 * Gets the debug flag.
	 *
	 * @since 2019/04/16
	 */
	static
	{
		// Get property
		boolean en = false;
		try
		{
			// {@squirreljme.property dev.shadowtail.classfile.xlate.debug=pool
			// Sets whether the massive amounts of debug test should be
			// printed in all the native compiler codes.}
			en = Boolean.getBoolean("dev.shadowtail.classfile.nncc.debug");
		}
		catch (SecurityException e)
		{
		}
		
		// Set
		ENABLED = en;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/__EData__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * Exception storage data.
 *
 * @since 2019/04/11
 */
final class __EData__
{	
	/** The address. */
	public final int addr;
	
	/** The line. */
	public final int line;
	
	/** The Java operation. */
	public final int jop;
	
	/** The Java PC address. */
	public final int jpc;
	
	/** The used label. */
	public final NativeCodeLabel label;
	
	/**
	 * Initializes the data.
	 *
	 * @param __a The address.
	 * @param __ln The line.
	 * @param __jop The Java operation address.
	 * @param __jpc The Java PC address.
	 * @param __lab The label to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	__EData__(int __a, int __ln, int __jop, int __jpc, NativeCodeLabel __lab)
		throws NullPointerException
	{
		if (__lab == null)
			throw new NullPointerException("NARG");
		
		this.addr = __a;
		this.line = __ln;
		this.label = __lab;
		this.jop = __jop;
		this.jpc = __jpc;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/nncc/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the near-native code compiler and all of the
 * associated classes for its handling.
 *
 * @since 2019/04/06
 */

package dev.shadowtail.classfile.nncc;

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

package dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;

/**
 * This represents a field which has been accessed.
 *
 * @since 2019/03/24
 */
public final class AccessedField
{
	/** The field reference. */
	public final FieldReference field;
	
	/** The access time. */
	public final FieldAccessTime time;
	
	/** The access type. */
	public final FieldAccessType type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the accessed field.
	 *
	 * @param __ti The access time.
	 * @param __ty The access type.
	 * @param __cn The class name.
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public AccessedField(FieldAccessTime __ti, FieldAccessType __ty,
		ClassName __cn, String __fn, FieldDescriptor __fd)
		throws NullPointerException
	{
		this(__ti, __ty, new FieldReference(__cn, new FieldName(__fn), __fd));
	}
	
	/**
	 * Initializes the accessed field.
	 *
	 * @param __ti The access time.
	 * @param __ty The access type.
	 * @param __f The field to access.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public AccessedField(FieldAccessTime __ti, FieldAccessType __ty,
		FieldReference __f)
		throws NullPointerException
	{
		if (__ti == null || __ty == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.time = __ti;
		this.type = __ty;
		this.field = __f;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof AccessedField))
			return false;
		
		AccessedField o = (AccessedField)__o;
		return this.field.equals(o.field) &&
			this.time.equals(o.time) &&
			this.type.equals(o.type);
	}
	
	/**
	 * Returns the field reference.
	 *
	 * @return The field reference.
	 * @since 2019/03/26
	 */
	public final FieldReference field()
	{
		return this.field;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final int hashCode()
	{
		return this.field.hashCode() ^ this.time.hashCode() ^
			this.type.hashCode();
	}
	
	/**
	 * Returns the field access time.
	 *
	 * @return The access time.
	 * @since 2019/04/14
	 */
	public final FieldAccessTime time()
	{
		return this.time;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				this.time + "+" + this.type + "+" + this.field));
		
		return rv;
	}
	
	/**
	 * Returns the field access type.
	 *
	 * @return The access type.
	 * @since 2019/04/14
	 */
	public final FieldAccessType type()
	{
		return this.type;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/BasicPool.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This represents a basic constant pool.
 *
 * @since 2019/07/17
 */
public final class BasicPool
{
	/** Entries which exist in the constant pool. */
	private final Map<Object, BasicPoolEntry> _entries;
	
	/** Linear entries within the pool. */
	private final List<BasicPoolEntry> _linear;
	
	/**
	 * Input for the basic pool.
	 *
	 * @param __it The input entries.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public BasicPool(BasicPoolEntry... __it)
		throws NullPointerException
	{
		this(Arrays.<BasicPoolEntry>asList(__it));
	}
	
	/**
	 * Input for the basic pool.
	 *
	 * @param __it The input entries.
	 * @throws IllegalArgumentException If a pool entry was duplicated.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public BasicPool(Iterable<BasicPoolEntry> __it)
		throws IllegalArgumentException, NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		// Initial guessed size?
		int igs = ((__it instanceof Collection) ?
			((Collection)__it).size() : 16);
			
		// Where the entries go
		List<BasicPoolEntry> linear = new ArrayList<>(igs);
		Map<Object, BasicPoolEntry> entries = new LinkedHashMap<>();
		
		// Process entries
		for (BasicPoolEntry e : __it)
		{
			if (e == null)
				throw new NullPointerException("NARG");
			
			// Just add to the end of the list
			linear.add(e);
			
			// {@squirreljme.error JC4k Duplicated pool entry. (The entry)}
			if (null != entries.put(e.value, e))
				throw new IllegalArgumentException("JC4k " + e);
		}
		
		// Set
		this._entries = entries;
		this._linear = linear;
	}
	
	/**
	 * Gets the pool entry by index.
	 *
	 * @param __i The index to get.
	 * @return The index of the given entry.
	 * @throws IndexOutOfBoundsException If the entry is not within bounds.
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byIndex(int __i)
		throws IndexOutOfBoundsException
	{
		return this._linear.get(__i);
	}
	
	/**
	 * Gets the pool value by index.
	 *
	 * @param <T> The class type.
	 * @param __cl The class type.
	 * @param __i The index to get.
	 * @return The index of the given entry.
	 * @throws IndexOutOfBoundsException If the entry is not within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public final <T> T byIndex(Class<T> __cl, int __i)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.byIndex(__i).<T>value(__cl);
	}
	
	/**
	 * Gets the pool entry by value.
	 *
	 * @param __v The value to get.
	 * @return The entry or {@code null} if it was not found.
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byValue(Object __v)
		throws IndexOutOfBoundsException
	{
		return this._entries.get(__v);
	}
	
	/**
	 * Returns the size of the pool.
	 *
	 * @return The pool size.
	 * @since 2019/09/11
	 */
	public final int size()
	{
		return this._entries.size();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/BasicPoolBuilder.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This class is used to store and contain the basic constant pool which
 * consists of values, indexes, and parts.
 *
 * This class is thread safe.
 *
 * @since 2019/07/15
 */
public final class BasicPoolBuilder
	implements Iterable<BasicPoolEntry>
{
	/** Entries which exist in the constant pool. */
	protected final Map<Object, BasicPoolEntry> entries =
		new LinkedHashMap<>();
	
	/**
	 * Base pool initialization.
	 *
	 * @since 2019/07/15
	 */
	{
		// The first entry of the constant pool is always null!
		this.entries.put(null, new BasicPoolEntry(0, null, new int[0]));
	}
	
	/**
	 * Adds a basic entry.
	 *
	 * @param __v The value.
	 * @param __parts The parts to use.
	 * @return The entry for this value.
	 * @throws IllegalStateException If the entry already exists within
	 * the pool.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry add(Object __v, int... __parts)
		throws IllegalStateException
	{
		Map<Object, BasicPoolEntry> entries = this.entries;
		
		// Lock on self, since there could be multiple processing of pool
		// entries in the future
		synchronized (this)
		{
			// {@squirreljme.error JC4c The specified entry already exists
			// within the pool. (The entry being added)}
			if (entries.containsKey(__v))
				throw new IllegalStateException("JC4c " + __v);
			
			// Create, store, and use the new entry
			BasicPoolEntry rv;
			entries.put(__v, (rv = new BasicPoolEntry(
				entries.size(), __v, __parts)));
			return rv;
		}
	}
	
	/**
	 * Adds an already existing basic entry to this pool.
	 *
	 * @param __e The entry to add.
	 * @return The resulting basic entry which may be {@code __e} or another
	 * entry.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final BasicPoolEntry addEntry(BasicPoolEntry __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Adds an internal entry or returns the pre-existing value if it is
	 * already in the pool.
	 *
	 * @param __v The value.
	 * @param __parts The parts to use.
	 * @return The entry for this value.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry addOrGet(Object __v, int... __parts)
	{
		synchronized (this)
		{
			// If the entry already exists use it
			BasicPoolEntry rv = this.getByValue(__v);
			if (rv != null)
				return rv;
			
			// Otherwise add it
			return this.add(__v, __parts);
		}
	}
	
	/**
	 * Searches the constant pool and returns the entry at the given index.
	 *
	 * @param __dx The index to get.
	 * @return The entry at the given index or {@code null} if there is none.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry getByIndex(int __dx)
	{
		// Find matching index
		Map<Object, BasicPoolEntry> entries = this.entries;
		synchronized (this)
		{
			for (BasicPoolEntry e : entries.values())
				if (e.index == __dx)
					return e;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Gets the given entry by the key.
	 *
	 * @param __v The value to get.
	 * @return The entry for the value or {@code null} if it is not in the
	 * pool.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry getByValue(Object __v)
	{
		synchronized (this)
		{
			return this.entries.get(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/17
	 */
	@Override
	public final Iterator<BasicPoolEntry> iterator()
	{
		// Get elements
		BasicPoolEntry[] elems;
		synchronized (this)
		{
			Map<Object, BasicPoolEntry> entries = this.entries;
			elems = entries.values().toArray(
				new BasicPoolEntry[entries.size()]);
		}
		
		// Iterate over
		return UnmodifiableIterator.<BasicPoolEntry>of(elems);
	}
	
	/**
	 * Returns the size of the constant pool.
	 *
	 * @return The pool size.
	 * @since 2019/07/15
	 */
	public final int size()
	{
		synchronized (this)
		{
			return this.entries.size();
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/BasicPoolEntry.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;

/**
 * Represents an entry within the constant pool.
 *
 * @since 2019/07/15
 */
public final class BasicPoolEntry
{
	/** The index of this entry. */
	public final int index;
	
	/** Offset of this entry. */
	public final int offset;
	
	/** The value. */
	public final Object value;
	
	/** The parts. */
	private final short[] _parts;
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @since 2019/09/11
	 */
	public BasicPoolEntry(int __dx, Object __v, short[] __parts)
	{
		this.index = __dx;
		this.value = __v;
		this.offset = -1;
		this._parts = (__parts == null ? new short[0] : __parts.clone());
	}
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @since 2019/07/15
	 */
	public BasicPoolEntry(int __dx, Object __v, int[] __parts)
	{
		this(__dx, __v, __parts, -1);
	}
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @param __eoff The entry offset.
	 * @since 2019/09/14
	 */
	public BasicPoolEntry(int __dx, Object __v, int[] __parts, int __eoff)
	{
		this.index = __dx;
		this.value = __v;
		this.offset = __eoff;
		
		// Reduce parts to shorts
		int n = (__parts == null ? 0 : __parts.length);
		short[] parts = new short[n];
		for (int i = 0; i < n; i++)
			parts[i] = (short)__parts[i];
		this._parts = parts;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/08/25
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/08/25
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a single part value.
	 *
	 * @param __i The part index.
	 * @return The resulting part.
	 * @throws IndexOutOfBoundsException If the part index is not within
	 * bounds.
	 * @since 2019/09/14
	 */
	public final int part(int __i)
	{
		return this._parts[__i] & 0xFFFF;
	}
	
	/**
	 * Returns the parts used.
	 *
	 * @return The used parts.
	 * @since 2019/07/15
	 */
	public final short[] parts()
	{
		return this._parts.clone();
	}
	
	/**
	 * Returns the type of entry that this is.
	 *
	 * @return The entry type.
	 * @since 2019/09/14
	 */
	public final MinimizedPoolEntryType type()
	{
		Object value = this.value;
		if (value == null)
			return MinimizedPoolEntryType.NULL;
		return MinimizedPoolEntryType.ofClass(value.getClass());
	}
	
	/**
	 * Returns the value of this entry.
	 *
	 * @param <T> The type to use.
	 * @param __cl The class of this type.
	 * @return The resulting type.
	 * @throws ClassCastException If the class type is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/01
	 */
	public final <T> T value(Class<T> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this.value);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/ClassInfoPointer.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import net.multiphasicapps.classfile.ClassName;

/**
 * This represents a pointer to the specified class.
 *
 * @since 2019/09/07
 */
public final class ClassInfoPointer
{
	/** The class name to load for. */
	public final ClassName name;
	
	/**
	 * Initializes the class information pointer.
	 *
	 * @param __cl The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public ClassInfoPointer(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.name = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassInfoPointer))
			return false;
		
		return this.name.equals(((ClassInfoPointer)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/ClassPool.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import net.multiphasicapps.classfile.ClassName;

/**
 * Represents the constant pool of another class, used for loading.
 *
 * @since 2019/04/22
 */
public final class ClassPool
{
	/** The class name to load for. */
	public final ClassName name;
	
	/**
	 * Initializes the class pool.
	 *
	 * @param __cl The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	public ClassPool(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.name = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassPool))
			return false;
		
		return this.name.equals(((ClassPool)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/DualClassRuntimePool.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * This contains the dual class and run-time constant pool information, the
 * run-time relies on the main class one, however only the run-time one is
 * needed for execution.
 *
 * @since 2019/07/17
 */
public final class DualClassRuntimePool
{
	/** The class pool. */
	protected final BasicPool classpool;
	
	/** The run-time pool. */
	protected final BasicPool runpool;
	
	/**
	 * Initializes the dual class/run-time pool.
	 *
	 * @param __cl The class pool.
	 * @param __rt The run-time pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public DualClassRuntimePool(BasicPool __cl, BasicPool __rt)
		throws NullPointerException
	{
		if (__cl == null || __rt == null)
			throw new NullPointerException("NARG");
		
		this.classpool = __cl;
		this.runpool = __rt;
	}
	
	/**
	 * Returns the static class pool.
	 *
	 * @return The pool.
	 * @since 2019/09/14
	 */
	public final BasicPool classPool()
	{
		return this.classpool;
	}
	
	/**
	 * Loads a value from the pool by its index.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The entry for the given index.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * pool bounds.
	 * @since 2019/09/07
	 */
	public final BasicPoolEntry getByIndex(boolean __rt, int __dx)
		throws IndexOutOfBoundsException
	{
		return (__rt ? this.runpool : this.classpool).byIndex(__dx);
	}
	
	/**
	 * Loads a value from the pool by its value.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __v The value to get.
	 * @return The entry for the given value or {@code null} if not found.
	 * @since 2019/09/14
	 */
	public final BasicPoolEntry getByValue(boolean __rt, Object __v)
	{
		return (__rt ? this.runpool : this.classpool).byValue(__v);
	}
	
	/**
	 * Returns the runtime class pool.
	 *
	 * @return The pool.
	 * @since 2019/09/14
	 */
	public final BasicPool runtimePool()
	{
		return this.runpool;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/DualClassRuntimePoolBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;

/**
 * This is used as a builder for both class and run-time pools.
 *
 * @since 2019/07/17
 */
public final class DualClassRuntimePoolBuilder
{
	/** The class pool. */
	protected final BasicPoolBuilder classpool =
		new BasicPoolBuilder();
	
	/** The run-time pool. */
	protected final BasicPoolBuilder runpool =
		new BasicPoolBuilder();
	
	/**
	 * Adds the specified pool entry.
	 *
	 * @param __rt Place into the run-time pool?
	 * @param __v The value to store.
	 * @return The resulting pool entry.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final BasicPoolEntry add(boolean __rt, Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		if (__rt)
			return this.addRuntime(__v);
		return this.addStatic(__v);
	}
	
	/**
	 * Adds an entry to the run-time pool.
	 *
	 * @param __v The value to add.
	 * @return The entry which was created.
	 * @throws IllegalArgumentException If the value cannot be stored into
	 * the specified pool.
	 * @since 2019/09/01
	 */
	public final BasicPoolEntry addRuntime(Object __v)
		throws IllegalArgumentException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// The pool to be added to and the underlying static pool
		BasicPoolBuilder runpool = this.runpool,
			classpool = this.classpool;
		
		// Already within the pool?
		BasicPoolEntry rv = runpool.getByValue(__v);
		if (rv != null)
			return rv;
		
		// Depends on the type to be stored
		MinimizedPoolEntryType type;
		switch ((type = MinimizedPoolEntryType.ofClass(__v.getClass())))
		{
				// Null is always the first entry
			case NULL:
				return runpool.getByValue(null);
			
				// A field which has been accessed
			case ACCESSED_FIELD:
				AccessedField af = (AccessedField)__v;
				FieldReference fr = af.field();
				return runpool.add(__v,
					af.time().ordinal(),
					af.type().ordinal(),
					this.addStatic(fr.className()).index,
					this.addStatic(fr.memberName().toString()).index,
					this.addStatic(fr.memberType().className()).index);
			
				// Class information pointer
			case CLASS_INFO_POINTER:
				return runpool.add(__v,
					this.addStatic(((ClassInfoPointer)__v).name).index);
						
				// The constant pool of another (or current) class
			case CLASS_POOL:
				return runpool.add(__v,
					this.addStatic(((ClassPool)__v).name).index);
				
				// A method which has been invoked
			case INVOKED_METHOD:
				InvokedMethod iv = (InvokedMethod)__v;
				MethodHandle mh = iv.handle();
				
				return runpool.add(__v,
					iv.type().ordinal(),
					this.addStatic(mh.outerClass()).index,
					this.addStatic(mh.name().toString()).index,
					this.addStatic(mh.descriptor()).index);
				
				// The index of a method
			case METHOD_INDEX:
				MethodIndex v = (MethodIndex)__v;
				return runpool.add(__v,
					0x7FFF,
					this.addStatic(v.inclass).index,
					this.addStatic(v.name.toString()).index,
					this.addStatic(v.type).index);
				
				// A string that is noted for its value (debugging)
			case NOTED_STRING:
				return runpool.add(__v,
					this.addStatic(__v.toString()).index);
				
				// A string that is used
			case USED_STRING:
				return runpool.add(__v,
					this.addStatic(__v.toString()).index);
			
				// Unknown
			default:
				// {@squirreljme.error JC4f Invalid type in runtime pool.
				// (The type)}
				if (!type.isRuntime())
					throw new IllegalArgumentException("JC4f " + type);
				throw new todo.OOPS(type.name());
		}
	}
	
	/**
	 * Adds an entry to the static pool.
	 *
	 * @param __v The value to add.
	 * @return The entry which was created.
	 * @throws IllegalArgumentException If the value cannot be stored into
	 * the specified pool.
	 * @since 2019/09/01
	 */
	public final BasicPoolEntry addStatic(Object __v)
		throws IllegalArgumentException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// The pool to be added to
		BasicPoolBuilder classpool = this.classpool;
		
		// Already within the pool?
		BasicPoolEntry rv = classpool.getByValue(__v);
		if (rv != null)
			return rv;
		
		// Depends on the type to be stored
		MinimizedPoolEntryType type;
		switch ((type = MinimizedPoolEntryType.ofClass(__v.getClass())))
		{
			case INTEGER:
				int bi = (Integer)__v;
				return classpool.add(__v,
					(bi >> 16) & 0xFFFF,
					(bi) & 0xFFFF);
				
			case FLOAT:
				int bf = Float.floatToRawIntBits((Float)__v);
				return classpool.add(__v,
					(bf >> 16) & 0xFFFF,
					(bf) & 0xFFFF);
			
			case LONG:
				long l = (Long)__v;
				return classpool.add(__v,
					((int)(l >>> 48)) & 0xFFFF,
					((int)(l >>> 32)) & 0xFFFF,
					((int)(l >>> 16)) & 0xFFFF,
					((int)l) & 0xFFFF);
			
			case DOUBLE:
				long d = Double.doubleToRawLongBits((Double)__v);
				return classpool.add(__v,
					((int)(d >>> 48)) & 0xFFFF,
					((int)(d >>> 32)) & 0xFFFF,
					((int)(d >>> 16)) & 0xFFFF,
					((int)d) & 0xFFFF);
				
				// Name of class (used), the component type is recorded if
				// this is detected to be an array
			case CLASS_NAME:
				ClassName cn = (ClassName)__v;
				return classpool.add(__v,
					this.addStatic(cn.toString()).index,
					(!cn.isArray() ? 0 :
						this.addStatic(cn.componentType()).index));
				
				// List of class names (interfaces)
			case CLASS_NAMES:
				// Adjust the value to map correctly
				ClassNames names = (ClassNames)__v;
				
				// Fill into indexes
				int nn = names.size();
				int[] indexes = new int[nn];
				for (int i = 0; i < nn; i++)
					indexes[i] = this.addStatic(names.get(i)).index;
				
				// Add it now
				return classpool.add(names, indexes);
			
				// Descriptor of a method
			case METHOD_DESCRIPTOR:
				MethodDescriptor md = (MethodDescriptor)__v;
				
				// Need arguments to process them
				FieldDescriptor mrv = md.returnValue();
				FieldDescriptor[] args = md.arguments();
				
				// Argument set
				int[] isubs = new int[3 + args.length];
				
				// String, argument count, and return value
				isubs[0] = this.addStatic(__v.toString()).index;
				isubs[1] = args.length;
				isubs[2] = (mrv == null ? 0 :
					this.addStatic(mrv.className()).index);
				
				// Fill in arguments
				for (int q = 0, n = args.length; q < n; q++)
					isubs[3 + q] = this.addStatic(args[q].className()).index;
				
				// Put in descriptor with all the pieces
				return classpool.add(__v, isubs);
			
			case STRING:
				return classpool.add(__v,
					__v.hashCode() & 0xFFFF,
					((String)__v).length());
			
				// Unknown
			default:
				// {@squirreljme.error JC4e Invalid type in static pool.
				// (The type)}
				if (!type.isStatic())
					throw new IllegalArgumentException("JC4e " + type);
				throw new todo.OOPS(type.name());
		}
	}
	
	/**
	 * Builds this dual pool.
	 *
	 * @return The resulting dual pool.
	 * @since 2019/09/07
	 */
	public final DualClassRuntimePool build()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the static class pool.
	 *
	 * @return The pool.
	 * @since 2019/07/17
	 */
	public final BasicPoolBuilder classPool()
	{
		return this.classpool;
	}
	
	/**
	 * Returns the runtime class pool.
	 *
	 * @return The pool.
	 * @since 2019/07/17
	 */
	public final BasicPoolBuilder runtimePool()
	{
		return this.runpool;
	}
}

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

package dev.shadowtail.classfile.pool;

/**
 * This represents when a field is being accessed.
 *
 * @since 2019/03/24
 */
public enum FieldAccessTime
{
	/** Written by constructor or static initializer. */
	INITIALIZER,
	
	/** Written by non-constructor. */
	NORMAL,
	
	/** Read access. */
	READ,
	
	/** End. */
	;
	
	/**
	 * Returns the access time for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The access time.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final FieldAccessTime of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return FieldAccessTime.INITIALIZER;
			case 1: return FieldAccessTime.NORMAL;
			case 2: return FieldAccessTime.READ;
		}
		
		// {@squirreljme.error JC14 Unknown access time. (The index)}
		throw new IllegalArgumentException("JC14 " + __i);
	}
}

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

package dev.shadowtail.classfile.pool;

/**
 * Represents how a field is being accessed.
 *
 * @since 2019/03/24
 */
public enum FieldAccessType
{
	/** Static. */
	STATIC,
	
	/** Instance. */
	INSTANCE,
	
	/** End. */
	;
	
	/**
	 * Is this field access static?
	 *
	 * @return If this is a static field access.
	 * @since 2019/04/22
	 */
	public final boolean isStatic()
	{
		return this == FieldAccessType.STATIC;
	}
	
	/**
	 * Returns the access type for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The access type.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final FieldAccessType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return FieldAccessType.STATIC;
			case 1: return FieldAccessType.INSTANCE;
		}
		
		// {@squirreljme.error JC15 Unknown access type. (The index)}
		throw new IllegalArgumentException("JC15 " + __i);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/InvokeType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

/**
 * This represents the type of invocation that is performed.
 *
 * @since 2019/03/20
 */
public enum InvokeType
{
	/** Static invoke. */
	STATIC,
	
	/** Special invoke. */
	SPECIAL,
	
	/** Virtual. */
	VIRTUAL,
	
	/** Interface. */
	INTERFACE,
	
	/** System invocation type. */
	SYSTEM,
	
	/** End. */
	;
	
	/**
	 * Does this use an instance variable?
	 *
	 * @return If there is an instance variable that is used.
	 * @since 2019/03/20
	 */
	public final boolean hasInstance()
	{
		return !this.isStatic();
	}
	
	/**
	 * Is this a static invocation?
	 *
	 * @return If this is a static invocation.
	 * @since 2019/04/22
	 */
	public final boolean isStatic()
	{
		return this == InvokeType.STATIC || this == InvokeType.SYSTEM;
	}
	
	/**
	 * Returns the invocation type for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The invocation type.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final InvokeType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return InvokeType.STATIC;
			case 1: return InvokeType.SPECIAL;
			case 2: return InvokeType.VIRTUAL;
			case 3: return InvokeType.INTERFACE;
			case 4: return InvokeType.SYSTEM;
		}
		
		// {@squirreljme.error JC16 Unknown invocation type. (The index)}
		throw new IllegalArgumentException("JC16 " + __i);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/InvokedMethod.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
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
191
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;

/**
 * Represents a method to be invoked.
 *
 * @since 2019/03/21
 */
public final class InvokedMethod
{
	/** The type of method to invoke. */
	public final InvokeType type;
	
	/** The handle of the method being invoke. */
	public final MethodHandle handle;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	public InvokedMethod(InvokeType __t, String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(new ClassName(__cl),
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl, MethodName __mn,
		MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl, __mn, __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __h The handle of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/21
	 */
	public InvokedMethod(InvokeType __t, MethodHandle __h)
		throws NullPointerException
	{
		if (__t == null || __h == null)
			throw new NullPointerException("NARG");
		
		this.type = __t;
		this.handle = __h;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof InvokedMethod))
			return false;
		
		InvokedMethod o = (InvokedMethod)__o;
		return this.type.equals(o.type) &&
			this.handle.equals(o.handle);
	}
	
	/**
	 * Returns the method handle.
	 *
	 * @return The method handle.
	 * @since 2019/03/24
	 */
	public final MethodHandle handle()
	{
		return this.handle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/24
	 */
	@Override
	public final int hashCode()
	{
		return this.type.hashCode() ^ this.handle.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.type + "+" + this.handle));
		
		return rv;
	}
	
	/**
	 * Returns the invocation type.
	 *
	 * @return The invocation type.
	 * @since 2019/04/14
	 */
	public final InvokeType type()
	{
		return this.type;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/MethodIndex.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * Represents an index of a method in the method table of a class.
 *
 * @since 2019/04/30
 */
public final class MethodIndex
{
	/** The name of the class. */
	public final ClassName inclass;
	
	/** The method name. */
	public final MethodName name;
	
	/** The method type. */
	public final MethodDescriptor type;
	
	/** The hashcode. */
	private int _hash;
	
	/** The string form. */
	private Reference<String> _string;
	
	
	/**
	 * Initializes the index holder.
	 *
	 * @param __cl The class this is in.
	 * @param __n The name of the method.
	 * @param __t The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public MethodIndex(ClassName __cl, String __n, MethodDescriptor __t)
		throws NullPointerException
	{
		this(__cl, new MethodName(__n), __t);
	}
	
	/**
	 * Initializes the index holder.
	 *
	 * @param __cl The class this is in.
	 * @param __n The name of the method.
	 * @param __t The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	public MethodIndex(ClassName __cl, MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__cl == null || __n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MethodIndex))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		MethodIndex o = (MethodIndex)__o;
		return this.inclass.equals(o.inclass) &&
			this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.inclass.hashCode() ^
				this.name.hashCode() ^ this.type.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s::%s:%s", this.inclass, this.name, this.type)));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/NotedString.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
66
67
68
69
70
71
72
73
74
75
76
77
78
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * Noted string is similar to used string however it means it is just used
 * by its pointer data and not an actual string object which is initialized
 * for it. The noted string is generally used for debug purposes.
 *
 * @since 2019/09/11
 */
public final class NotedString
{
	/** The noted string. */
	public final String string;
	
	/**
	 * Initializes the noted string.
	 *
	 * @param __s The string to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public NotedString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof NotedString))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return this.string.equals(((NotedString)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final String toString()
	{
		return this.string;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/NullPoolEntry.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * This represents the null pool entry.
 *
 * @since 2019/09/22
 */
public final class NullPoolEntry
{
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		return (__o instanceof NullPoolEntry);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final String toString()
	{
		return "null";
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/UsedString.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
66
67
68
69
70
71
72
73
74
75
76
77
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * Represents a string which was used.
 *
 * @since 2019/04/27
 */
public final class UsedString
{
	/** The used string. */
	public final String string;
	
	/**
	 * Initializes the used string.
	 *
	 * @param __s The string to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public UsedString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof UsedString))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return this.string.equals(((UsedString)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final String toString()
	{
		return this.string;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/pool/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains all of the constant pool and runtime pool related
 * class.
 *
 * @since 2019/05/24
 */

package dev.shadowtail.classfile.pool;

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ByteCodeHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.pool.InvokeType;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodReference;

/**
 * This class is used by the byte code processor to handle all of the various
 * instructions and such.
 *
 * @since 2019/04/06
 */
public interface ByteCodeHandler
{
	/**
	 * Read length of array.
	 *
	 * @param __in The instance.
	 * @param __len The output length.
	 * @since 2019/04/12
	 */
	void doArrayLength(JavaStackResult.Input __in,
		JavaStackResult.Output __len);
	
	/**
	 * Load from array.
	 *
	 * @param __dt The type of data to load.
	 * @param __in The instance.
	 * @param __dx The index.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	void doArrayLoad(DataType __dt, JavaStackResult.Input __in,
		JavaStackResult.Input __dx, JavaStackResult.Output __v);
	
	/**
	 * Store into array.
	 *
	 * @param __dt The type of data to store.
	 * @param __in The instance.
	 * @param __dx The index.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	void doArrayStore(DataType __dt, JavaStackResult.Input __in,
		JavaStackResult.Input __dx, JavaStackResult.Input __v);
	
	/**
	 * Check that an object is of a given type or thrown exception.
	 *
	 * @param __cl The class to check.
	 * @param __v The object to check.
	 * @since 2019/04/12
	 */
	void doCheckCast(ClassName __cl, JavaStackResult.Input __v);
	
	/**
	 * Loads the class object of a class.
	 *
	 * @param __cl The class object to load.
	 * @param __out The output register.
	 * @since 2019/04/26
	 */
	void doClassObjectLoad(ClassName __cl, JavaStackResult.Output __out);
	
	/**
	 * Performs convert of value.
	 *
	 * @param __as The source type.
	 * @param __a The input.
	 * @param __bs The output type.
	 * @param __b The output.
	 * @since 2019/04/16
	 */
	void doConvert(StackJavaType __as, JavaStackResult.Input __a,
		StackJavaType __bs, JavaStackResult.Output __b);
	
	/**
	 * Performs a copy operation.
	 *
	 * @param __in The input.
	 * @param __out The output.
	 * @since 2019/04/07
	 */
	void doCopy(JavaStackResult.Input __in, JavaStackResult.Output __out);
	
	/**
	 * Reads a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The output value.
	 * @since 2019/04/12
	 */
	void doFieldGet(FieldReference __fr, JavaStackResult.Input __i,
		JavaStackResult.Output __v);
	
	/**
	 * Puts a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	void doFieldPut(FieldReference __fr, JavaStackResult.Input __i,
		JavaStackResult.Input __v);
	
	/**
	 * Compares two values and then possibly jumps.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @param __ijt The jump target.
	 * @since 2019/04/12
	 */
	void doIfICmp(CompareType __ct, JavaStackResult.Input __a,
		JavaStackResult.Input __b, InstructionJumpTarget __ijt);
	
	/**
	 * Invocation of a method.
	 *
	 * @param __t The type of invoke to be performed.
	 * @param __r The reference to the method.
	 * @param __out The output.
	 * @param __in The arguments to the method.
	 * @since 2019/04/10
	 */
	void doInvoke(InvokeType __t, MethodReference __r,
		JavaStackResult.Output __out, JavaStackResult.Input... __in);
	
	/**
	 * Check that an object is of a given type and sets the stack if it is.
	 *
	 * @param __cl The class to check.
	 * @param __v The object to check.
	 * @param __o The output.
	 * @since 2019/04/16
	 */
	void doInstanceOf(ClassName __cl, JavaStackResult.Input __v,
		JavaStackResult.Output __o);
	
	/**
	 * Generates a lookup on a lookup table then jumps to a target.
	 *
	 * @param __key The key to check against.
	 * @param __ls The lookup switch.
	 * @since 2019/04/16
	 */
	void doLookupSwitch(JavaStackResult.Input __key, LookupSwitch __ls);
	
	/**
	 * Performs math operation.
	 *
	 * @param __dt The type to operate on.
	 * @param __mt The math operation to perform.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Output.
	 * @since 2019/04/07
	 */
	void doMath(StackJavaType __dt, MathType __mt, JavaStackResult.Input __a,
		JavaStackResult.Input __b, JavaStackResult.Output __c);
	
	/**
	 * Performs math operation.
	 *
	 * @param __dt The type to operate on.
	 * @param __mt The math operation to perform.
	 * @param __a Argument A.
	 * @param __b Constant B.
	 * @param __c Output.
	 * @since 2019/04/07
	 */
	void doMath(StackJavaType __dt, MathType __mt, JavaStackResult.Input __a,
		Number __b, JavaStackResult.Output __c);
	
	/**
	 * Enter or exit the monitor.
	 *
	 * @param __enter Being entered?
	 * @param __o The object to enter or exit.
	 * @since 2019/04/16
	 */
	void doMonitor(boolean __enter, JavaStackResult.Input __o);
	
	/**
	 * Allocates multi-dimensional array.
	 *
	 * @param __cl The class name.
	 * @param __numdims The number of dimensions.
	 * @param __o The output value.
	 * @param __dims The input dimensions.
	 * @since 2019/05/04
	 */
	void doMultiANewArray(ClassName __cl, int __numdims,
		JavaStackResult.Output __o, JavaStackResult.Input... __dims);
	
	/**
	 * Allocates new class.
	 *
	 * @param __cn The class to allocate.
	 * @param __out The output.
	 * @since 2019/04/11
	 */
	void doNew(ClassName __cn, JavaStackResult.Output __out);
	
	/**
	 * Allocates a new array.
	 *
	 * @param __at The array type with all the needed dimensions.
	 * @param __len The length of the array.
	 * @param __out Where the array is to be stored.
	 * @since 2019/04/12
	 */
	void doNewArray(ClassName __at, JavaStackResult.Input __len,
		JavaStackResult.Output __out);
	
	/**
	 * Loads pool value.
	 *
	 * @param __v The value to load.
	 * @param __out The output.
	 * @since 2019/04/12
	 */
	void doPoolLoad(Object __v, JavaStackResult.Output __out);
	
	/**
	 * Return of value.
	 *
	 * @param __in The return value, {@code null} means no value was returned.
	 * @since 2019/04/11
	 */
	void doReturn(JavaStackResult.Input __in);
	
	/**
	 * Generates code for state operations.
	 *
	 * @param __ops The operations to perform.
	 * @since 2019/04/11
	 */
	void doStateOperations(StateOperations __ops);
	
	/**
	 * Reads a static field.
	 *
	 * @param __fr The field to read from.
	 * @param __v The output register.
	 * @since 2019/04/12
	 */
	void doStaticGet(FieldReference __fr, JavaStackResult.Output __v);
	
	/**
	 * Writes a static field.
	 *
	 * @param __fr The field to write to.
	 * @param __v The input register.
	 * @since 2019/04/13
	 */
	void doStaticPut(FieldReference __fr, JavaStackResult.Input __v);
	
	/**
	 * Throws the given object.
	 *
	 * @param __in The object to throw.
	 * @since 2019/04/12
	 */
	void doThrow(JavaStackResult.Input __in);
	
	/**
	 * Finishes handling the instruction operation.
	 *
	 * @since 2019/04/07
	 */
	void instructionFinish();
	
	/**
	 * Sets up before processing the instruction.
	 *
	 * @since 2019/04/07
	 */
	void instructionSetup();
	
	/**
	 * Returns the state of the byte code, this must always return the
	 * same object.
	 *
	 * @return The byte code state.
	 * @since 2019/04/06
	 */
	ByteCodeState state();
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ByteCodeProcessor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.pool.InvokeType;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.ConstantValueClass;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InstructionJumpTargets;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodReference;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;

/**
 * This class goes through the byte code for a method and then performs stack
 * and instruction work on it.
 *
 * @since 2019/04/06
 */
public final class ByteCodeProcessor
{
	/** The input byte code to be read. */
	protected final ByteCode bytecode;
	
	/** Handle for byte-code operations. */
	protected final ByteCodeHandler handler;
	
	/** The state of the byte code. */
	protected final ByteCodeState state;
	
	/** Stack map table, needed for local wiping. */
	protected final StackMapTable stackmaptable;
	
	/** Reverse jump table. */
	private final Map<Integer, InstructionJumpTargets> _revjumps;
	
	/** Jump targets for this instruction. */
	private InstructionJumpTargets _ijt;
	
	/** Flase is the preprocessor state, otherwise run the handler. */
	private boolean _dohandling;
	
	/** Is an exception possible. */
	private boolean _canexception;
	
	/**
	 * Initializes the byte code processor.
	 *
	 * @param __bc The target byte code.
	 * @param __h Handler for the byte code operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public ByteCodeProcessor(ByteCode __bc, ByteCodeHandler __h)
		throws NullPointerException
	{
		if (__bc == null || __h == null)
			throw new NullPointerException("NARG");
		
		this.bytecode = __bc;
		this.handler = __h;
		
		// The state is used to share between the processor and the handler
		ByteCodeState state = __h.state();
		this.state = state;
		
		// Load initial Java stack state from the initial stack map
		JavaStackState s;
		StackMapTable stackmaptable = __bc.stackMapTable();
		this.stackmaptable = stackmaptable;
		state.stack = (s = JavaStackState.of(stackmaptable.get(0),
			__bc.writtenLocals()));
		state.stacks.put(0, s);
		
		// Reverse jump table to detect jump backs
		this._revjumps = __bc.reverseJumpTargets();
		
		// Get details and names of the stuff
		state.classname = __bc.thisType();
		state.methodname = __bc.name();
		state.methodtype = __bc.type();
		
		// Store info
		state.exceptionranges = new ExceptionHandlerRanges(__bc);
	}
	
	/**
	 * Processes the byte code and calls the destination handler.
	 *
	 * @since 2019/04/06
	 */
	public final void process()
	{
		// Run process
		try
		{
			this.__aaaProcess();
		}
		
		// {@squirreljme.error JC17 Failed to process the byte code, this may
		// be due to an invalid class or an internal compiler error. (The
		// last processed instruction)}
		catch (InvalidClassFormatException|IllegalArgumentException|
			 IllegalStateException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC17 " + this.state, e);
		}
	}
	
	/**
	 * Processes the byte code and calls the destination handler.
	 *
	 * @since 2019/04/06
	 */
	private final void __aaaProcess()
	{
		ByteCode bytecode = this.bytecode;
		ByteCodeState state = this.state;
		ByteCodeHandler handler = this.handler;
		StackMapTable stackmaptable = this.stackmaptable;
		Map<Integer, JavaStackState> stacks = state.stacks;
		Map<Integer, StateOperations> stackpoison = state.stackpoison;
		
		// Go through each operation twice, performing pre-processing first
		// to make things a bit simpler and more well known when it comes
		// to caching.
		for (int pp = 0; pp < 2; pp++)
		{
			// Is handling to be done?
			boolean dohandling = (pp != 0);
			this._dohandling = dohandling;
			
			// Since this is the start, the last address needs to be reset
			// because it will be invalid!
			state.lastaddr = -1;
			state.followaddr = -1;
			
			// Process instruction
			Instruction lastinst = null;
			SimplifiedJavaInstruction lastsji = null;
			for (Instruction inst : bytecode)
			{
				// Translate to simple instruction for easier handling
				SimplifiedJavaInstruction sji =
					new SimplifiedJavaInstruction(inst);
				
				// Debug
				if (__Debug__.ENABLED)
					todo.DEBUG.note("%s %s (%s)", (dohandling ? "Handling" :
						"Preprocessing"), sji, inst);
				
				// Current instruction info
				state.instruction = inst;
				state.simplified = sji;
				
				// Store the last processed address
				state.lastaddr = state.addr;
				
				// Current processing this address
				int addr = inst.address();
				state.addr = addr;
				
				// Set line where this code was found
				state.line = bytecode.lineOfAddress(addr);
				
				// Following address, may be used to calculate if the stack
				// needs to be transitioned
				state.followaddr = bytecode.addressFollowing(addr);
				
				// These jump targets are used to map out the state of stacks
				// across various points
				InstructionJumpTargets ijt, rijt;
				this._ijt = (ijt = inst.jumpTargets());
				state.jumptargets = ijt;
				
				// Reverse jump targets are used to detect jumps to previous
				// addresses
				rijt = this._revjumps.get(addr);
				state.reversejumptargets = (rijt != null ? rijt :
					new InstructionJumpTargets());
				
				// Get the stack, which must exist
				JavaStackState stack = stacks.get(addr);
				if (stack == null)
				{
					// Some code generated by the older compilers ends up
					// defining parts of loops or exception handlers which
					// are defined but completely skipped via a goto, but they
					// are then taken back to this point. They should hopefully
					// have a stack map state defined for them, so just
					// initialize a blank state from that instead.
					StackMapTableState smts = stackmaptable.get(addr);
					if (smts != null)
						stack = JavaStackState.of(smts,
							this.bytecode.writtenLocals());
					
					// {@squirreljme.error JC18 No recorded stack state for
					// this position. (The address to check)}
					if (stack == null)
						throw new InvalidClassFormatException("JC18 " + addr);
				}
				
				// Load stack
				state.stack = stack;
				
				// Reset exception possibility, this is used to determine
				// if the stack update should actually accept exception
				// targets even if they are specified
				this._canexception = false;
				state.canexception = false;
				
				// Preprocessing operations
				if (!dohandling)
				{
					// If there is a stack map table, adjust types that are
					// used on the stack along with the removal of locals
					// and such
					StackMapTableState smts = stackmaptable.get(addr);
					if (smts != null)
					{
						// Debug
						if (__Debug__.ENABLED)
							todo.DEBUG.note("SMT BEF: %s", stack);
						
						stack = stack.filterByStackMap(smts);
						
						// Debug
						if (__Debug__.ENABLED)
							todo.DEBUG.note("SMT AFT: %s", stack);
					}
					
					// If we are jumping back to this instruction at any point
					// we need to flush the stack so that nothing is cached on
					// it. The resulting flushed stack is then used instead
					// Note that if we jump to ourselves we might have entered
					// with something cached and might end up using that when
					// we do not want to
					if (state.reversejumptargets.hasSameOrLaterAddress(addr))
					{
						// Perform a flush of the cache
						JavaStackResult fres = stack.doCacheFlush();
						
						// Set natural flow as poisoned, operations have to
						// be done to match the correct state
						StateOperations sops = fres.operations();
						if (!sops.isEmpty())
							stackpoison.put(addr, sops);
						
						// Use the result of the flush as the state instead so
						// that it propagates ahead from now on
						stack = fres.after();
					}
					
					// Was the stack changed?
					if (state.stack != stack)
						state.stack = stack;
				}
				
				// Handle instruction
				else
				{
					// Call pre-handler
					handler.instructionSetup();
					
					// If the stack has been adjusted for any reason, replace
					// the stored stack for this point
					JavaStackState mns = state.stack;
					if (!stack.equals(mns))
						stacks.put(addr, (stack = mns));
				}
				
				// Handle the operation
				switch (sji.operation())
				{
						// Object array load
					case InstructionIndex.AALOAD:
						this.__doArrayLoad(null);
						break;
						
						// Object array store
					case InstructionIndex.AASTORE:
						this.__doArrayStore(null);
						break;
						
						// Null constant
					case InstructionIndex.ACONST_NULL:
						this.__doAConstNull();
						break;
						
						// Allocate new array
					case InstructionIndex.ANEWARRAY:
						this.__doNewArray(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// Length of array
					case InstructionIndex.ARRAYLENGTH:
						this.__doArrayLength();
						break;
						
						// Throw exception
					case InstructionIndex.ATHROW:
						this.__doThrow();
						break;
						
						// Check that object is of a type, or fail
					case InstructionIndex.CHECKCAST:
						this.__doCheckCast(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// Convert data
					case SimplifiedJavaInstruction.CONVERT:
						this.__doConvert(sji.<StackJavaType>argument(0,
								StackJavaType.class),
							sji.<StackJavaType>argument(1,
								StackJavaType.class));
						break;
						
						// Get field
					case InstructionIndex.GETFIELD:
						this.__doFieldGet(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Get static
					case InstructionIndex.GETSTATIC:
						this.__doStaticGet(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Goto
					case InstructionIndex.GOTO:
						this.__doGoto(sji.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class));
						break;
						
						// If comparison against zero
					case SimplifiedJavaInstruction.IF:
						this.__doIf(sji.<DataType>argument(0, DataType.class),
							sji.<CompareType>argument(1, CompareType.class),
							sji.<InstructionJumpTarget>argument(2,
								InstructionJumpTarget.class));
						break;
						
						// Compare two values
					case SimplifiedJavaInstruction.IF_CMP:
						this.__doIfCmp(
							sji.<DataType>argument(0, DataType.class),
							sji.<CompareType>argument(1, CompareType.class),
							sji.<InstructionJumpTarget>argument(2,
								InstructionJumpTarget.class));
						break;
						
						// Increment local
					case InstructionIndex.IINC:
						this.__doIInc(sji.intArgument(0), sji.intArgument(1));
						break;
						
						// Invoke interface
					case InstructionIndex.INVOKEINTERFACE:
						this.__doInvoke(InvokeType.INTERFACE,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
					
						// Invoke special
					case InstructionIndex.INVOKESPECIAL:
						this.__doInvoke(InvokeType.SPECIAL,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
					
						// Invoke static
					case InstructionIndex.INVOKESTATIC:
						this.__doInvoke(InvokeType.STATIC,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
						
						// Invoke virtual
					case InstructionIndex.INVOKEVIRTUAL:
						this.__doInvoke(InvokeType.VIRTUAL,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
						
						// Checks that the given class is an instance of an
						// object.
					case InstructionIndex.INSTANCEOF:
						this.__doInstanceOf(sji.<ClassName>argument(0,
							ClassName.class));
						break;
					
						// Load constant
					case InstructionIndex.LDC:
						this.__doLdc(sji.<ConstantValue>argument(0,
							ConstantValue.class));
						break;
					
						// Load local variable to the stack
					case SimplifiedJavaInstruction.LOAD:
						this.__doLoad(sji.<DataType>argument(0,
							DataType.class), sji.intArgument(1));
						break;
						
						// Lookup switch
					case InstructionIndex.LOOKUPSWITCH:
						this.__doLookupSwitch(sji.<LookupSwitch>argument(0,
							LookupSwitch.class));
						break;
						
						// Math
					case SimplifiedJavaInstruction.MATH:
						this.__doMath(sji.<DataType>argument(0,
							DataType.class), sji.<MathType>argument(1,
								MathType.class));
						break;
						
						// Math with constant
					case SimplifiedJavaInstruction.MATH_CONST:
						this.__doMathConst(sji.<DataType>argument(0,
							DataType.class), sji.<MathType>argument(1,
								MathType.class), sji.<Number>argument(2,
									Number.class));
						break;
						
						// Enter monitor
					case InstructionIndex.MONITORENTER:
						this.__doMonitor(true);
						break;
						
						// Exit monitor
					case InstructionIndex.MONITOREXIT:
						this.__doMonitor(false);
						break;
					
						// Multiple new array
					case InstructionIndex.MULTIANEWARRAY:
						this.__doMultiANewArray(
							sji.<ClassName>argument(0, ClassName.class),
							sji.intArgument(1));
						break;
					
						// Create new instance of something
					case InstructionIndex.NEW:
						this.__doNew(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// This literally does nothing so no output code needs to
						// be generated at all
					case InstructionIndex.NOP:
						this.__doNop();
						break;
						
						// Primitive array load
					case SimplifiedJavaInstruction.PALOAD:
						this.__doArrayLoad(sji.<PrimitiveType>argument(0,
							PrimitiveType.class));
						break;
						
						// Primitive array store
					case SimplifiedJavaInstruction.PASTORE:
						this.__doArrayStore(sji.<PrimitiveType>argument(0,
							PrimitiveType.class));
						break;
					
						// Put of instance field
					case InstructionIndex.PUTFIELD:
						this.__doFieldPut(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Put static field
					case InstructionIndex.PUTSTATIC:
						this.__doStaticPut(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
					
						// Return from method, with no return value
					case InstructionIndex.RETURN:
						this.__doReturn(null);
						break;
					
						// Stack shuffle
					case SimplifiedJavaInstruction.STACKSHUFFLE:
						this.__doStackShuffle(
							sji.<JavaStackShuffleType>argument(0,
								JavaStackShuffleType.class));
						break;
					
						// Place stack variable into local
					case SimplifiedJavaInstruction.STORE:
						this.__doStore(sji.<DataType>argument(0,
							DataType.class), sji.intArgument(1));
						break;
						
						// Return value
					case SimplifiedJavaInstruction.VRETURN:
						this.__doReturn(sji.<DataType>argument(0,
							DataType.class).toJavaType());
						break;
					
						// Not yet implemented
					default:
						throw new todo.OOPS(
							sji.toString() + "/" + inst.toString());
				}
				
				// Call post-handler
				if (dohandling)
					handler.instructionFinish();
				
				// Set last
				lastsji = sji;
				lastinst = inst;
			}
		}
	}
	
	/**
	 * Pushes a null constant to the stack.
	 *
	 * @since 2019/04/16
	 */
	private final void __doAConstNull()
	{
		// -> [ref]
		JavaStackResult result = this.state.stack.doStack(0, JavaType.OBJECT);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doCopy(JavaStackResult.INPUT_ZERO, result.out(0));
	}
	
	/**
	 * Gets length of array.
	 *
	 * @since 2019/04/06
	 */
	private final void __doArrayLength()
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [array] -> [len]
		JavaStackResult result = this.state.stack.doStack(1, JavaType.INTEGER);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayLength(result.in(0), result.out(0));
	}
	
	/**
	 * Loads value from value.
	 *
	 * @param __pt The type to load, {@code null} is considered to be an
	 * object.
	 * @since 2019/04/06
	 */
	private final void __doArrayLoad(PrimitiveType __pt)
	{
		// An exception may be thrown
		this._canexception = true;
		
		// This is easily determined from the primitive type
		JavaType faketype;
		if (__pt != null)
			faketype = __pt.stackJavaType();
		
		// Otherwise, pop twice and see what the array is and work from
		// that
		else
		{
			// Pop two
			JavaStackResult wouldbe = this.state.stack.doStack(2);
			
			// Get the base type
			ClassName maybecl = wouldbe.in(0).type.type().className();
			
			// If this is an array then get the component type and work
			// from it, otherwise just assume it is Object since we could
			// not derive that info at all
			faketype = (maybecl.isArray() ?
				new JavaType(maybecl.componentType()) : JavaType.OBJECT);
		}
		
		// [array, index] -> [value]
		JavaStackResult result = this.state.stack.doStack(2, faketype);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayLoad(DataType.of(__pt), result.in(0),
			result.in(1), result.out(0));
	}
	
	/**
	 * Stores value into an array.
	 *
	 * @param __pt The type to store, {@code null} is considered to be an
	 * object.
	 * @since 2019/04/06
	 */
	private final void __doArrayStore(PrimitiveType __pt)
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [array, index, value]
		JavaStackResult result = this.state.stack.doStack(3);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayStore(DataType.of(__pt), result.in(0),
			result.in(1), result.in(2));
	}
	
	/**
	 * Checks that the object on the stack is of the given type.
	 *
	 * @param __cn The name of the class to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doCheckCast(ClassName __cn)
		throws NullPointerException
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [object] -> [object]
		JavaStackResult result = this.state.stack.doCheckCast(
			new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Do check cast
		this.handler.doCheckCast(__cn, result.in(0));
	}
	
	/**
	 * Converts from one Java type to another
	 *
	 * @param __from The source type.
	 * @param __to The destination type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doConvert(StackJavaType __from, StackJavaType __to)
		throws NullPointerException
	{
		if (__from == null || __to == null)
			throw new NullPointerException("NARG");
		
		// [from] -> [to]
		JavaStackResult result = this.state.stack.doStack(1, __to.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doConvert(__from, result.in(0), __to, result.out(0));
	}
	
	/**
	 * Reads a value from a field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doFieldGet(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [inst] -> [value]
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(1,
			new JavaType(__fr.memberType()));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doFieldGet(__fr, result.in(0), result.out(0));
	}
	
	/**
	 * Puts a value into a field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doFieldPut(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [inst, value] ->
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(2);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doFieldPut(__fr, result.in(0), result.in(1));
	}
	
	/**
	 * Goes to another address.
	 *
	 * @param __jt The target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doGoto(InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Do nothing!
		this.__update(this.state.stack.doNothing());
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Just do an always true comparison on the zero register
		this.handler.doIfICmp(CompareType.TRUE, JavaStackResult.INPUT_ZERO,
			JavaStackResult.INPUT_ZERO, __jt);
	}
	
	/**
	 * Performs if comparison against zero.
	 *
	 * @param __type The type to work with on the stack.
	 * @param __ct The comparison type.
	 * @param __ijt The instruction jump target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/05
	 */
	private final void __doIf(DataType __type, CompareType __ct,
		InstructionJumpTarget __ijt)
		throws NullPointerException
	{
		if (__type == null || __ct == null || __ijt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC19 Cannot compare float or double.}
		if (__type == DataType.FLOAT || __type == DataType.DOUBLE)
			throw new IllegalArgumentException("JC19");
		
		// [val] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doIfICmp(__ct, result.in(0), JavaStackResult.INPUT_ZERO,
			__ijt);
	}
	
	/**
	 * Performs if comparison of two values against each other.
	 *
	 * @param __type The type to work with on the stack.
	 * @param __ct The comparison type.
	 * @param __ijt The instruction jump target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doIfCmp(DataType __type, CompareType __ct,
		InstructionJumpTarget __ijt)
		throws NullPointerException
	{
		if (__type == null || __ct == null || __ijt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC1a Cannot compare float or double.}
		if (__type == DataType.FLOAT || __type == DataType.DOUBLE)
			throw new IllegalArgumentException("JC1a");
		
		// [a, b] ->
		JavaStackResult result = this.state.stack.doStack(2);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doIfICmp(__ct, result.in(0), result.in(1), __ijt);
	}
	
	/**
	 * Increments local variable.
	 *
	 * @param __l The local to increment.
	 * @param __v The value to increment by.
	 * @since 2019/04/06
	 */
	private final void __doIInc(int __l, int __v)
	{
		// Just write an integer to the integer so its state is known
		JavaStackResult result = this.state.stack.
			doLocalSet(JavaType.INTEGER, __l);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
			
		// There might be items on the stack which were cached and now no
		// longer are because they got pulverized, so de-cache those
		ByteCodeHandler handler = this.handler;
		handler.doStateOperations(result.operations());
		
		// Add value
		handler.doMath(StackJavaType.INTEGER, MathType.ADD,
			result.out(0).asInput(), __v,
			result.out(0));
	}
	
	/**
	 * Checks that the class is the given instance.
	 *
	 * @param __cl The class to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doInstanceOf(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// [object] -> [int]
		JavaStackResult result = this.state.stack.doStack(1, JavaType.INTEGER);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doInstanceOf(__cl, result.in(0), result.out(0));
	}
	
	/**
	 * Handles invocation of other methods.
	 *
	 * @param __t The type of invocation to perform.
	 * @param __r The method to invoke.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doInvoke(InvokeType __t, MethodReference __r)
		throws NullPointerException
	{
		if (__t == null || __r == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Return value type, if any
		MethodHandle mf = __r.handle();
		FieldDescriptor rv = mf.descriptor().returnValue();
		boolean hasrv = (rv != null);
		
		// The number of arguments to pop is the instance (if non-static) and
		// the number of arguments taken
		int popcount = (__t.hasInstance() ? 1 : 0) +
			mf.descriptor().argumentCount();
		
		// Perform stack operation
		ByteCodeState state = this.state;
		JavaStackResult result = (!hasrv ? state.stack.doStack(popcount) :
			state.stack.doStack(popcount, new JavaType(rv)));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doInvoke(__t, __r, (!hasrv ? null :
			result.out(0)), result.in());
	}
	
	/**
	 * Loads constant value onto the stack.
	 *
	 * @param __v The value to push.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doLdc(ConstantValue __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Get push properties
		JavaType jt = __v.type().javaType();
		
		// An exception is only throwable on classes, because the class
		// could potentially fail to initialize properly
		this._canexception = (__v instanceof ConstantValueClass);
		
		// Push to the stack this type, the result is always cached
		JavaStackResult result = this.state.stack.doStack(0, true, jt);
		this.__update(result);
		
		// Do not call generator, we just want the stack result
		if (!this._dohandling)
			return;
		
		// Call the appropriate handler
		ByteCodeHandler handler = this.handler;
		switch (__v.type())
		{
			case INTEGER:
				handler.doMath(StackJavaType.INTEGER, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Integer)__v.boxedValue(),
					result.out(0));
				break;
				
			case FLOAT:
				handler.doMath(StackJavaType.FLOAT, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Float)__v.boxedValue(),
					result.out(0));
				break;
			
			case LONG:
				handler.doMath(StackJavaType.LONG, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Long)__v.boxedValue(),
					result.out(0));
				break;
				
			case DOUBLE:
				handler.doMath(StackJavaType.DOUBLE, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Double)__v.boxedValue(),
					result.out(0));
				break;
			
			case STRING:
				handler.doPoolLoad(__v.boxedValue(), result.out(0));
				break;
				
			case CLASS:
				handler.doClassObjectLoad((ClassName)__v.boxedValue(),
					result.out(0));
				break;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Loads from a local and puts to the stack.
	 *
	 * @param __jt The type to push.
	 * @param __from The source local.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doLoad(DataType __jt, int __from)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Load from local variable
		JavaStackResult result = this.state.stack.doLocalLoad(__from);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Only perform the copy if the value is different, because otherwise
		// it would have just been cached
		if (result.in(0).register != result.out(0).register)
			this.handler.doCopy(result.in(0), result.out(0));
	}
	
	/**
	 * Handles lookup switch.
	 *
	 * @param __ls The switch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doLookupSwitch(LookupSwitch __ls)
		throws NullPointerException
	{
		if (__ls == null)
			throw new NullPointerException("NARG");
		
		// [key] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doLookupSwitch(result.in(0), __ls);
	}
	
	/**
	 * Performs math operation.
	 *
	 * @param __pt The primitive type.
	 * @param __mot The math operation type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doMath(DataType __pt, MathType __mot)
		throws NullPointerException
	{
		if (__pt == null || __mot == null)
			throw new NullPointerException("NARG");
		
		// We may throw an exception here if we divide by zero!
		if (__pt == DataType.INTEGER || __pt == DataType.LONG)
			if (__mot == MathType.DIV || __mot == MathType.REM)
				this._canexception = true;
		
		// [a, b] -> [result]
		JavaStackResult result = this.state.stack.doStack(2,
			__pt.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Perform the math
		this.handler.doMath(__pt.toStackJavaType(), __mot, result.in(0),
			result.in(1), result.out(0));
	}
	
	/**
	 * Performs math operation with constant.
	 *
	 * @param __pt The primitive type.
	 * @param __mot The math operation type.
	 * @param __c The constant.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doMathConst(DataType __pt, MathType __mot, Number __c)
		throws NullPointerException
	{
		if (__pt == null || __mot == null || __c == null)
			throw new NullPointerException("NARG");
		
		// [a, b] -> [result]
		JavaStackResult result = this.state.stack.doStack(1,
			__pt.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Monitor operation
		this.handler.doMath(__pt.toStackJavaType(), __mot, result.in(0),
			__c, result.out(0));
	}
	
	/**
	 * Enters or exits the monitor.
	 *
	 * @param __enter If the monitor is to be entered.
	 * @since 2019/04/16
	 */
	private final void __doMonitor(boolean __enter)
	{
		// Can toss exception
		this._canexception = true;
		
		// [object] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Monitor operation
		this.handler.doMonitor(__enter, result.in(0));
	}
	
	/**
	 * Allocate multi-dimensional array.
	 *
	 * @param __cl The class to allocate.
	 * @param __dims The number of dimensions to allocate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	private final void __doMultiANewArray(ClassName __cl, int __dims)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
			
		// Can toss exception
		this._canexception = true;
		
		// [__dims, ...] -> [object]
		JavaStackResult result = this.state.stack.doStack(__dims,
			new JavaType(__cl));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle array creation
		this.handler.doMultiANewArray(__cl, __dims, result.out(0),
			result.in());
	}
	
	/**
	 * Creates a new instance of the given class.
	 *
	 * @param __cn The class to create.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doNew(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Just the type is pushed to the stack
		JavaStackResult result = this.state.stack.
			doStack(0, new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doNew(__cn, result.out(0));
	}
	
	/**
	 * Allocates a new array.
	 *
	 * @param __cn The component type of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/05
	 */
	private final void __doNewArray(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Add dimension to the class since it lacks it
		__cn = __cn.addDimensions(1);
		
		// [len] -> [array]
		JavaStackResult result = this.state.stack.
			doStack(1, new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Generate
		this.handler.doNewArray(__cn, result.in(0), result.out(0));
	}
	
	/**
	 * Do nothing.
	 *
	 * @since 2019/04/07
	 */
	private final void __doNop()
	{
		// Just do nothing
		this.__update(this.state.stack.doNothing());
	}
	
	/**
	 * Handles returning.
	 *
	 * @param __rt The type to return, {@code null} means nothing is to be
	 * returned.
	 * @since 2019/04/03
	 */
	private final void __doReturn(JavaType __rt)
	{
		ByteCodeState state = this.state;
		
		// Destroy everything and bring destruction to the method!!!
		JavaStackResult result = state.stack.doDestroy(__rt != null);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Call handler
		this.handler.doReturn((__rt != null ? result.in(0) : null));
	}
	
	/**
	 * Performs shuffling of the stack.
	 *
	 * @param __st The type of shuffle to do.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doStackShuffle(JavaStackShuffleType __st)
		throws NullPointerException
	{
		if (__st == null)
			throw new NullPointerException("NARG");
		
		// Shuffle the stack
		JavaStackResult result = this.state.stack.doStackShuffle(__st);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Potentially run state operations as needed
		StateOperations ops = result.operations();
		if (!ops.isEmpty())
			this.handler.doStateOperations(ops);
	}
	
	/**
	 * Reads a value from a static field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doStaticGet(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [] -> [value]
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(0,
			new JavaType(__fr.memberType()));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doStaticGet(__fr, result.out(0));
	}
	
	/**
	 * Writes to static field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	private final void __doStaticPut(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [value] ->
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doStaticPut(__fr, result.in(0));
	}
	
	/**
	 * Stores an entry on the stack.
	 *
	 * @param __jt The type to pop.
	 * @param __to The destination local.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doStore(DataType __jt, int __to)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Store onto the stack, locals are never cached
		JavaStackResult result = this.state.stack.doLocalStore(__to);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// There might be items on the stack which were cached and now no
		// longer are because they got pulverized, so de-cache those
		ByteCodeHandler handler = this.handler;
		handler.doStateOperations(result.operations());
		
		// Perform plain copy
		handler.doCopy(result.in(0), result.out(0));
	}
	
	/**
	 * Performs a throw of an exception on the stack.
	 *
	 * @since 2019/04/05
	 */
	private final void __doThrow()
	{
		// An exception will be thrown
		this._canexception = true;
		
		// Pop item from the stack
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doThrow(result.in(0));
	}
	
	/**
	 * Updates the stack state and result.
	 *
	 * @param __jsr The stack result.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/07
	 */
	private final void __update(JavaStackResult __jsr)
		throws NullPointerException
	{
		if (__jsr == null)
			throw new NullPointerException("NARG");
		
		// The new stack state
		JavaStackState newstack = __jsr.after();
		
		// Needed for processing
		ByteCodeState state = this.state;
		Map<Integer, JavaStackState> stacks = state.stacks;
		int addr = state.addr;
		
		// Store result and the new stack
		state.result = __jsr;
		state.stack = newstack;
		
		// Can an exception handler be called?
		boolean canexception = this._canexception;
		state.canexception = canexception;
		
		// Target stack states are not touched in the normal handling state
		// because collisions and transitioning of states is handled in the
		// pre-processing step
		if (this._dohandling)
			return;
		
		// The result of the jump calculations may result in the stack
		// being poisoned potentially
		Map<Integer, StateOperations> stackpoison = state.stackpoison;
		Map<Integer, JavaStackEnqueueList> stackcollides = state.stackcollides;
		
		// Set target stack states for destinations of this instruction
		// Calculate the exception state only if it is needed
		JavaStackState hypoex = null;
		InstructionJumpTargets ijt = this._ijt;
		if (ijt != null && !ijt.isEmpty())
			for (int i = 0, n = ijt.size(); i < n; i++)
			{
				int jta = ijt.get(i).target();
				
				// If an exception is never thrown by the instruction being
				// processed then just ignore any exception points which may
				// be defined since they will have no effect
				boolean isexception = ijt.isException(i);
				if (!canexception && isexception)
					continue;
				
				// Lazily calculate the exception handler since it might
				// not always be needed
				if (isexception && hypoex == null)
					hypoex = newstack.doExceptionHandler(new JavaType(
						new ClassName("java/lang/Throwable"))).after();
				
				// The type of stack to target
				JavaStackState use = (isexception ? hypoex : newstack);
				
				// Is empty state, use this state because we defined it first
				JavaStackState dss = stacks.get(jta);
				if (dss == null)
					stacks.put(jta, use);
				
				// For later addresses which do not have an exact stack state
				// match, a partial un-cache will have to be used.
				// Note that jump backs are ignored here since those were
				// processed and we cannot adjust the states anymore
				else if (jta > addr && !use.canTransition(dss))
				{
					// Debug
					if (__Debug__.ENABLED)
					{
						todo.DEBUG.note("Transition is required! %d -> %d",
							addr, jta);
						todo.DEBUG.note("From: %s", use);
						todo.DEBUG.note("To  : %s", dss);
					}
					
					// Get pre-existing collision state here, if any
					JavaStackEnqueueList preq = stackcollides.get(jta);
					if (preq == null)
						preq = new JavaStackEnqueueList(0);
					
					// Merge these two register lists
					JavaStackEnqueueList mcol = JavaStackEnqueueList.merge(
						preq, use.cacheCollision(dss));
					
					// Store the resulting collision
					stacks.put(jta, (dss = dss.cacheClearState(mcol)));
					
					// Debug
					if (__Debug__.ENABLED)
						todo.DEBUG.note("Coll: %s", dss);
				}
			}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ByteCodeState.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionJumpTargets;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * This represents the state of the byte code.
 *
 * @since 2019/04/06
 */
public class ByteCodeState
{
	/** The positions of all the stack information. */
	public final Map<Integer, JavaStackState> stacks =
		new LinkedHashMap<>();
		
	/** Addresses where the natural entry to the operation is poisoned. */
	public final Map<Integer, StateOperations> stackpoison =
		new LinkedHashMap<>();
	
	/** Stack collisions when a jump to the target does collide. */
	public final Map<Integer, JavaStackEnqueueList> stackcollides =
		new LinkedHashMap<>();
	
	/** Java instruction. */
	public Instruction instruction;
	
	/** Simplified instruction. */
	public SimplifiedJavaInstruction simplified;
	
	/** The resulting stack. */
	public JavaStackState stack;
	
	/** The result of the operation. */
	public JavaStackResult result;
	
	/** Can an exception handler be called? */
	public boolean canexception;
	
	/** Class name. */
	public ClassName classname;
	
	/** The method descriptor. */
	public MethodDescriptor methodtype;
	
	/** The method name. */
	public MethodName methodname;
	
	/** Exception ranges. */
	public ExceptionHandlerRanges exceptionranges;
	
	/** The current source line being processed. */
	public int line =
		-1;
	
	/** The last address processed. */
	public int lastaddr =
		-1;
	
	/** The current address being processed. */
	public int addr =
		-1;
	
	/** The address of the following instruction. */
	public int followaddr =
		-1;
	
	/** Jump targets for the instruction. */
	public InstructionJumpTargets jumptargets;
	
	/** Reverse jump targets for this instruction. */
	public InstructionJumpTargets reversejumptargets;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public String toString()
	{
		return String.format("{i=%s, si=%s, jss=%s, jsr=%s, ce=%b, " +
			"ln=%d, la=%d, a=%d, fa=%d, jt=%s, rjt=%s, cl=%s, mn=%s, mt=%s}",
			this.instruction,
			this.simplified,
			this.stack,
			this.result,
			this.canexception,
			this.line,
			this.lastaddr,
			this.addr,
			this.followaddr,
			this.jumptargets,
			this.reversejumptargets,
			this.classname,
			this.methodname,
			this.methodtype);
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/CompareType.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
66
67
68
69
70
71
72
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.xlate;

/**
 * This represents the type of comparison to perform.
 *
 * @since 2019/03/26
 */
public enum CompareType
{
	/** Equals. */
	EQUALS,
	
	/** Not equals. */
	NOT_EQUALS,
	
	/** Less than. */
	LESS_THAN,
	
	/** Less or equals. */
	LESS_THAN_OR_EQUALS,
	
	/** Greater than. */
	GREATER_THAN,
	
	/** Greater or equals. */
	GREATER_THAN_OR_EQUALS,
	
	/** Always true. */
	TRUE,
	
	/** Always false. */
	FALSE,
	
	/** End. */
	;
	
	/**
	 * Returns the compare type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting compare type.
	 * @since 2019/04/08
	 */
	public static final CompareType of(int __i)
	{
		switch (__i)
		{
			case 0:		return CompareType.EQUALS;
			case 1:		return CompareType.NOT_EQUALS;
			case 2:		return CompareType.LESS_THAN;
			case 3:		return CompareType.LESS_THAN_OR_EQUALS;
			case 4:		return CompareType.GREATER_THAN;
			case 5:		return CompareType.GREATER_THAN_OR_EQUALS;
			case 6:		return CompareType.TRUE;
			case 7:		return CompareType.FALSE;
		}
		
		// {@squirreljme.error JC1b Invalid compare operation.}
		throw new IllegalArgumentException("JC1b");
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/DataType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * Represents the data type to use for read/write.
 *
 * @since 2019/03/24
 */
public enum DataType
{
	/** Object. */
	OBJECT,
	
	/** Byte. */
	BYTE,
	
	/** Short. */
	SHORT,
	
	/** Character. */
	CHARACTER,
	
	/** Integer. */
	INTEGER,
	
	/** Float. */
	FLOAT,
	
	/** Long. */
	LONG,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
	
	/**
	 * Is this a wide data type?
	 *
	 * @return If this is wide.
	 * @since 2019/04/20
	 */
	public final boolean isWide()
	{
		return (this == DataType.LONG || this == DataType.DOUBLE);
	}
	
	/**
	 * Returns the size of the data type.
	 *
	 * @return The data size type.
	 * @since 2019/04/20
	 */
	public final int size()
	{
		switch (this)
		{
			case BYTE:		return 1;
			case SHORT:
			case CHARACTER:	return 2;
			case INTEGER:
			case FLOAT:
			case OBJECT:	return 4;
			case LONG:
			case DOUBLE:	return 8;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns this as a basic Java type.
	 *
	 * @return The Java type of this.
	 * @since 2019/04/06
	 */
	public final JavaType toJavaType()
	{
		switch (this)
		{
			case OBJECT:	return JavaType.OBJECT;
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the stack Java type for this data type.
	 *
	 * @return The stack type for this Java type.
	 * @since 2019/04/12
	 */
	public final StackJavaType toStackJavaType()
	{
		switch (this)
		{
			case OBJECT:	
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return StackJavaType.INTEGER;
			case FLOAT:		return StackJavaType.FLOAT;
			case LONG:		return StackJavaType.LONG;
			case DOUBLE:	return StackJavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the data type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting compare type.
	 * @since 2019/04/08
	 */
	public static final DataType of(int __i)
	{
		switch (__i)
		{
			case 0:		return DataType.OBJECT;
			case 1:		return DataType.BYTE;
			case 2:		return DataType.SHORT;
			case 3:		return DataType.CHARACTER;
			case 4:		return DataType.INTEGER;
			case 5:		return DataType.FLOAT;
			case 6:		return DataType.LONG;
			case 7:		return DataType.DOUBLE;
		}
		
		// {@squirreljme.error JC1c Invalid data type.}
		throw new IllegalArgumentException("JC1c");
	}
	
	/**
	 * Returns the data type used for the primitive type.
	 *
	 * @param __t The type to use, {@code null} is treated as a pointer.
	 * @return The data type used.
	 * @since 2019/03/24
	 */
	public static final DataType of(PrimitiveType __t)
	{
		if (__t == null)
			return DataType.OBJECT;
		
		switch (__t)
		{
			case BOOLEAN:
			case BYTE:		return DataType.BYTE;
			case CHARACTER:	return DataType.CHARACTER;
			case SHORT:		return DataType.SHORT;
			case INTEGER:	return DataType.INTEGER;
			case LONG:		return DataType.LONG;
			case FLOAT:		return DataType.FLOAT;
			case DOUBLE:	return DataType.DOUBLE;
			
			default:
				throw new todo.OOPS(__t.name());
		}
	}
	
	/**
	 * Returns the data type of the given Java type.
	 *
	 * @param __t The type to get.
	 * @return The data type used for this type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/27
	 */
	public static final DataType of(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return DataType.of(__t.type().primitiveType());
	}
	
	/**
	 * Returns the data type of the given field descriptor.
	 *
	 * @param __t The type to get.
	 * @return The data type used for this type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public static final DataType of(FieldDescriptor __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return DataType.of(__t.primitiveType());
	}
	
	/**
	 * Returns the data type of the given stack type.
	 *
	 * @param __t The stack type used.
	 * @return The resulting data type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/27
	 */
	public static final DataType of(StackJavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		switch (__t)
		{
			case INTEGER:	return DataType.INTEGER;
			case FLOAT:		return DataType.FLOAT;
			case LONG:		return DataType.LONG;
			case DOUBLE:	return DataType.DOUBLE;
		}
		
		throw new todo.OOPS();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ExceptionClassEnqueueAndTable.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * Represents a class, enqueue, and exception table.
 *
 * @since 2019/04/03
 */
public final class ExceptionClassEnqueueAndTable
{
	/** The class name to use. */
	public final ClassName name;
	
	/** The exception combo to target. */
	public final ExceptionEnqueueAndTable enqueueandtable;
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __ops The enqueue.
	 * @param __t The exception table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassEnqueueAndTable(ClassName __n,
		JavaStackEnqueueList __ops, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		this(__n, new ExceptionEnqueueAndTable(__ops, __t));
	}
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __c The target for the exception handler.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassEnqueueAndTable(ClassName __n,
		ExceptionEnqueueAndTable __c)
		throws NullPointerException
	{
		if (__n == null || __c == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.enqueueandtable = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionClassEnqueueAndTable))
			return false;
		
		ExceptionClassEnqueueAndTable o = (ExceptionClassEnqueueAndTable)__o;
		return this.name.equals(o.name) &&
			this.enqueueandtable.equals(o.enqueueandtable);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^ this.enqueueandtable.hashCode();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ExceptionClassStackAndTable.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is used to specify a class which is created along with any associated
 * exception handlers as needed.
 *
 * @since 2019/04/02
 */
public final class ExceptionClassStackAndTable
{
	/** The class name to use. */
	public final ClassName name;
	
	/** The exception combo to target. */
	public final ExceptionStackAndTable stackandtable;
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __ops The stack state.
	 * @param __t The exception table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassStackAndTable(ClassName __n,
		JavaStackState __ops, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		this(__n, new ExceptionStackAndTable(__ops, __t));
	}
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __c The target for the exception handler.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/02
	 */
	public ExceptionClassStackAndTable(ClassName __n,
		ExceptionStackAndTable __c)
		throws NullPointerException
	{
		if (__n == null || __c == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.stackandtable = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/02
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionClassStackAndTable))
			return false;
		
		ExceptionClassStackAndTable o = (ExceptionClassStackAndTable)__o;
		return this.name.equals(o.name) &&
			this.stackandtable.equals(o.stackandtable);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/02
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^ this.stackandtable.hashCode();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ExceptionEnqueueAndTable.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is a combination of an enqueue and exception handler table.
 *
 * @since 2019/04/03
 */
public final class ExceptionEnqueueAndTable
{
	/** The enqueue of the stack. */
	public final JavaStackEnqueueList enqueue;
	
	/** The exception handle table. */
	public final ExceptionHandlerTable table;
	
	/**
	 * Initializes the exception combo.
	 *
	 * @param __ops The stack state.
	 * @param __t The table used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionEnqueueAndTable(JavaStackEnqueueList __ops,
		ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.enqueue = __ops;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionEnqueueAndTable))
			return false;
		
		ExceptionEnqueueAndTable o = (ExceptionEnqueueAndTable)__o;
		return this.enqueue.equals(o.enqueue) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final int hashCode()
	{
		return this.enqueue.hashCode() ^ this.table.hashCode();
	}
}

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

package dev.shadowtail.classfile.xlate;

import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;
import net.multiphasicapps.classfile.InstructionAddressRange;

/**
 * This class is used to keep track of the exceptions in the methods.
 *
 * @since 2019/03/21
 */
public final class ExceptionHandlerRanges
{
	/** The full table. */
	protected final ExceptionHandlerTable full;
	
	/** Ranges for exceptions mapped to specific ranges. */
	private final Map<InstructionAddressRange, ExceptionHandlerTable> _ranges;
	
	/**
	 * Initializes the exception tracker.
	 *
	 * @param __bc The source byte code.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/21
	 */
	public ExceptionHandlerRanges(ByteCode __bc)
		throws NullPointerException
	{
		if (__bc == null)
			throw new NullPointerException("NARG");
		
		// Get the complete exception handler table
		ExceptionHandlerTable full = __bc.exceptions();
		this.full = full;
		
		// Load the full exception table ranges, this is used to locate
		// which table belongs to what
		this._ranges = full.mappedUniqueRanges();
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("EHRanges: %s", this._ranges);
	}
	
	/**
	 * Creates a class, enqueue, and exception table representation.
	 *
	 * @param __cn The class name.
	 * @param __ops The enqueue state.
	 * @param __pc The address.
	 * @return The class, stack, and exception table
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public final ExceptionClassEnqueueAndTable classEnqueueAndTable(
		ClassName __cn, JavaStackEnqueueList __ops, int __pc)
		throws NullPointerException
	{
		if (__cn == null || __ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionClassEnqueueAndTable(__cn,
			this.enqueueAndTable(__ops, __pc));
	}
	
	/**
	 * Creates a class, stack, and exception table representation.
	 *
	 * @param __cn The class name.
	 * @param __ops The stack state.
	 * @param __pc The address.
	 * @return The class, stack, and exception table
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public final ExceptionClassStackAndTable classStackAndTable(
		ClassName __cn, JavaStackState __ops, int __pc)
		throws NullPointerException
	{
		if (__cn == null || __ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionClassStackAndTable(__cn,
			this.stackAndTable(__ops, __pc));
	}
	
	/**
	 * Creates a enqueue and table representation.
	 *
	 * @param __ops The object positions.
	 * @param __pc The PC address.
	 * @return The stack and table information.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final ExceptionEnqueueAndTable enqueueAndTable(
		JavaStackEnqueueList __ops, int __pc)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionEnqueueAndTable(__ops, this.tableOf(__pc));
	}
	
	/**
	 * Creates a stack and table representation.
	 *
	 * @param __ops The object positions.
	 * @param __pc The PC address.
	 * @return The stack and table information.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final ExceptionStackAndTable stackAndTable(JavaStackState __ops,
		int __pc)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionStackAndTable(__ops, this.tableOf(__pc));
	}
	
	/**
	 * Returns the table at the given PC address.
	 *
	 * @param __pc The address to get.
	 * @return The table at the given address.
	 * @since 2019/03/22
	 */
	public final ExceptionHandlerTable tableOf(int __pc)
	{
		ExceptionHandlerTable last = null;
		for (Map.Entry<InstructionAddressRange, ExceptionHandlerTable> e :
			this._ranges.entrySet())
		{
			if (e.getKey().inRange(__pc))
				return e.getValue();
			last = e.getValue();
		}
		
		// Always return the last table because the exception handlers might
		// not cover the entire method (in the case of where there are no
		// handlers, the blank table will be only at address 0 while the
		// remaining instructions are the end)
		return last;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ExceptionHandlerTransition.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This contains the information needed to transition into exception handlers.
 *
 * @since 2019/04/13
 */
public final class ExceptionHandlerTransition
{
	/** The operations to perform when the entry is being handled. */
	public final StateOperations handled;
	
	/** Cleanup for when there are no handlers and everything is tossed up. */
	public final JavaStackEnqueueList nothandled;
	
	/** The exception table. */
	public final ExceptionHandlerTable table;
	
	/** Hash code. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the information.
	 *
	 * @param __h The state operations for getting the stack working properly.
	 * @param __q The tossup enqueue table when nothing is handled.
	 * @param __t The exception handler table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public ExceptionHandlerTransition(StateOperations __h,
		JavaStackEnqueueList __q, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__h == null || __q == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.handled = __h;
		this.nothandled = __q;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof ExceptionHandlerTransition))
			return false;
		
		ExceptionHandlerTransition o = (ExceptionHandlerTransition)__o;
		return this.handled.equals(o.handled) &&
			this.nothandled.equals(o.nothandled) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.handled.hashCode() ^
				this.nothandled.hashCode() ^ this.table.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/ExceptionStackAndTable.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
66
67
68
69
70
71
72
73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is a combination of a stack and exception handler table.
 *
 * @since 2019/03/22
 */
public final class ExceptionStackAndTable
{
	/** The state of the stack. */
	public final JavaStackState stack;
	
	/** The exception handle table. */
	public final ExceptionHandlerTable table;
	
	/**
	 * Initializes the exception combo.
	 *
	 * @param __ops The stack state.
	 * @param __t The table used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public ExceptionStackAndTable(JavaStackState __ops,
		ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.stack = __ops;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionStackAndTable))
			return false;
		
		ExceptionStackAndTable o = (ExceptionStackAndTable)__o;
		return this.stack.equals(o.stack) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final int hashCode()
	{
		return this.stack.hashCode() ^ this.table.hashCode();
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/JavaStackEnqueueList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * This contains every register which can be cleared after the specified
 * operation completes. Enqueue lists are always sorted from lowest to
 * highest.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackEnqueueList
	implements Iterable<Integer>
{
	/** The index where the stack entries start. */
	public final int stackstart;
	
	/** Registers used. */
	private final int[] _registers;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hashcode. */
	private int _hash;
	
	/**
	 * Initializes the enqueue list.
	 *
	 * @param __ss The start of the stack.
	 * @param __rs The registers to enqueue.
	 * @since 2019/03/31
	 */
	public JavaStackEnqueueList(int __ss, int... __rs)
	{
		// Bin the registers into unique local and stack entries
		__rs = (__rs == null ? new int[0] : __rs.clone());
		Set<Integer> ll = new SortedTreeSet<>(),
			ls = new SortedTreeSet<>();
		for (int i = 0, n = __rs.length; i < n; i++)
		{
			int v = __rs[i];
			
			if (i < __ss)
				ll.add(v);
			else
				ls.add(v);
		}
		
		// Setup new resulting array
		int[] registers = new int[ll.size() + ls.size()];
		int at = 0;
		for (int v : ll)
			registers[at++] = v;
		for (int v : ls)
			registers[at++] = v;
		
		// Set
		this._registers = registers;
		this.stackstart = ll.size();
	}
	
	/**
	 * Initializes the enqueue list.
	 *
	 * @param __ss The start of the stack.
	 * @param __rs The registers to enqueue.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackEnqueueList(int __ss, Iterable<Integer> __rs)
		throws NullPointerException
	{
		if (__rs == null)
			throw new NullPointerException("NARG");
		
		// Copy input list
		List<Integer> inreg = new ArrayList<>();
		for (Integer i : __rs)
			inreg.add(i);
		
		// Bin the registers into unique local and stack entries
		Set<Integer> ll = new SortedTreeSet<>(),
			ls = new SortedTreeSet<>();
		for (int i = 0, n = inreg.size(); i < n; i++)
		{
			int v = inreg.get(i);
			
			if (i < __ss)
				ll.add(v);
			else
				ls.add(v);
		}
		
		// Setup new resulting array
		int[] registers = new int[ll.size() + ls.size()];
		int at = 0;
		for (int v : ll)
			registers[at++] = v;
		for (int v : ls)
			registers[at++] = v;
		
		// Set
		this._registers = registers;
		this.stackstart = ll.size();
	}
	
	/**
	 * Adds a single local variable to this enqueue.
	 *
	 * @param __r The register to add.
	 * @return The resulting enqueue.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList addLocal(int __r)
	{
		int[] orig = this._registers;
		int origss = this.stackstart;
		
		// Add entry to the start of the array
		int n = orig.length;
		int[] now = new int[n + 1];
		now[0] = __r;
		for (int i = 0, o = 1; i < n; i++, o++)
			now[o] = orig[i];
		
		// The stack is offset by one so the local is first
		return new JavaStackEnqueueList(origss + 1, now);
	}
	
	/**
	 * Adds a single local variable to this enqueue.
	 *
	 * @param __r The register to add.
	 * @return The resulting enqueue.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList addStack(int __r)
	{
		// Since stack items are last, the register can just be added at
		// the end
		int[] orig = this._registers;
		int n = orig.length;
		int[] now = Arrays.copyOf(orig, n + 1);
		now[n] = __r;
		
		// Just the new array is used
		return new JavaStackEnqueueList(this.stackstart, now);
	}
	
	/**
	 * Checks if the enqueue contains the given register.
	 *
	 * @param __r The register to check.
	 * @return If it is contained or not.
	 * @since 2019/04/13
	 */
	public final boolean contains(int __r)
	{
		for (int x : this._registers)
			return (x == __r);
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof JavaStackEnqueueList))
			return false;
		
		JavaStackEnqueueList o = (JavaStackEnqueueList)__o;
		if (this.hashCode() != o.hashCode())
			return false;
		
		return this.stackstart == o.stackstart &&
			Arrays.equals(this._registers, o._registers);
	}
	
	/**
	 * Gets the given entry.
	 *
	 * @param __i The index to get.
	 * @return The register at this index.
	 * @since 2019/03/30
	 */
	public final int get(int __i)
	{
		return this._registers[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
		{
			rv = ~this.stackstart;
			for (int i : this._registers)
				rv -= i;
			
			this._hash = rv;
		}
		return rv;
	}
	
	/**
	 * Returns if this is empty.
	 *
	 * @return If this is empty.
	 * @since 2019/03/30
	 */
	public final boolean isEmpty()
	{
		return this._registers.length == 0;
	}
	
	/**
	 * Checks if the given index refers to a local.
	 *
	 * @param __i The index to check.
	 * @return If it refers to a local.
	 * @since 2019/04/17
	 */
	public final boolean isLocal(int __i)
	{
		return __i < this.stackstart;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/06
	 */
	@Override
	public final Iterator<Integer> iterator()
	{
		return new __Iterator__(this._registers);
	}
	
	/**
	 * Returns an enqueue list which contains only locals.
	 *
	 * @return An enqueue list containing only locals.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList onlyLocals()
	{
		// Copy just up to the stack part
		int[] from = this._registers;
		int ss = this.stackstart;
		int[] rv = new int[ss];
		for (int i = 0; i < ss; i++)
			rv[i] = from[i];
		
		return new JavaStackEnqueueList(ss, rv);
	}
	
	/**
	 * Returns an enqueue list which contians only stack registers.
	 *
	 * @return An enqueue with only stack registers.
	 * @since 2019/04/03
	 */
	public final JavaStackEnqueueList onlyStack()
	{
		// Copy just up to the stack part
		int[] from = this._registers;
		int n = from.length,
			ss = this.stackstart;
		int[] rv = new int[n - ss];
		for (int i = ss, o = 0; i < n; i++, o++)
			rv[o] = from[i];
		
		return new JavaStackEnqueueList(0, rv);
	}
	
	/**
	 * Returns all of the registers that have been enqueued.
	 *
	 * @return The enqueued set of registers.
	 * @since 2019/03/30
	 */
	public final int[] registers()
	{
		return this._registers.clone();
	}
	
	/**
	 * Returns the number of entries here.
	 *
	 * @return The number of entries.
	 * @since 2019/03/30
	 */
	public final int size()
	{
		return this._registers.length;
	}
	
	/**
	 * Returns the top-most entry.
	 *
	 * @return The top most entry or {@code -1} if this is empty.
	 * @since 2019/03/30
	 */
	public final int top()
	{
		int[] registers = this._registers;
		int len = registers.length;
		
		if (len == 0)
			return -1;
		return registers[len - 1];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		StringBuilder sb = new StringBuilder("ENQ[");
		
		int stackstart = this.stackstart, dx = 0;
		boolean comma = false;
		for (int v : this._registers)
		{
			if (dx++ == stackstart)
				sb.append("| ");
			else if (comma)
				sb.append(", ");
			comma = true;
			
			sb.append(v);
		}
		if (dx == stackstart)
			sb.append('|');
		sb.append(']');
		
		return sb.toString();
	}
	
	/**
	 * Trims the top entry from the enqueue list and returns the new list
	 * with the top missing.
	 *
	 * @return The resulting list.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList trimTop()
	{
		// Do not trim empty pieces
		int[] from = this._registers;
		int n = from.length - 1;
		if (n < 0)
			return this;
		
		// Copy bits
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = from[i];
		
		return new JavaStackEnqueueList(this.stackstart, rv);
	}
	
	/**
	 * Merges both of these stack enqueue lists into one.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The merged result.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public static final JavaStackEnqueueList merge(JavaStackEnqueueList __a,
		JavaStackEnqueueList __b)
		throws NullPointerException
	{
		if (__a == null || __b == null)
			throw new NullPointerException("NARG");
		
		// If one side is empty just use the other
		if (__a.isEmpty())
			return __b;
		else if (__b.isEmpty())
			return __a;
		
		// Locals and stack entries
		List<Integer> locals = new ArrayList<>(),
			stack = new ArrayList<>();
		
		// Sort through them all
		for (JavaStackEnqueueList eq : new JavaStackEnqueueList[]{__a, __b})
			for (int i = 0, n = eq.size(); i < n; i++)
			{
				Integer r = eq.get(i);
				if (eq.isLocal(i))
					locals.add(r);
				else
					stack.add(r);
			}
		
		// Append stack entries to the locals
		int numlocals = locals.size();
		locals.addAll(stack);
		return new JavaStackEnqueueList(numlocals, locals);
	}
	
	/**
	 * Iterator over stack slots.
	 *
	 * @since 2019/04/06
	 */
	private static final class __Iterator__
		implements Iterator<Integer>
	{
		/** Input register. */
		private final int[] _registers;
		
		/** Current index. */
		private int _at;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __r The registers used.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/06
		 */
		private __Iterator__(int[] __r)
			throws NullPointerException
		{
			if (__r == null)
				throw new NullPointerException("NARG");
			
			this._registers = __r;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final boolean hasNext()
		{
			return (this._at < this._registers.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final Integer next()
		{
			int at = this._at;
			int[] registers = this._registers;
			
			if (at >= registers.length)
				throw new NoSuchElementException("NSEE");
			
			this._at = at + 1;
			return registers[at];
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/JavaStackEnqueueType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

/**
 * This represents the type of enqueue to perform.
 *
 * @since 2019/04/06
 */
public enum JavaStackEnqueueType
{
	/** Normal state. */
	NORMAL,
	
	/** Cached state. */
	CACHED,
	
	/** End. */
	;
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/JavaStackResult.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.JavaType;

/**
 * This represents the result of operations performed on the Java stack.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackResult
{
	/** Input to the zero register. */
	public static final JavaStackResult.Input INPUT_ZERO =
		new JavaStackResult.Input(0, JavaType.NOTHING, true);
	
	/** Output to the zero register. */
	public static final JavaStackResult.Output OUTPUT_ZERO =
		new JavaStackResult.Output(0, JavaType.NOTHING, true);
	
	/** The stack state before. */
	public final JavaStackState before;
	
	/** The stack state after. */
	public final JavaStackState after;
	
	/** Enqueue list. */
	public final JavaStackEnqueueList enqueue;
	
	/** State operations. */
	public final StateOperations ops;
	
	/** Input. */
	private final JavaStackResult.Input[] _in;
	
	/** Output. */
	private final JavaStackResult.Output[] _out;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the result of the operation
	 *
	 * @param __bs The previous stack state.
	 * @param __as The after (the new) stack state.
	 * @param __eq Enqueue list, may be {@code null}.
	 * @param __io Input/output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackResult(JavaStackState __bs, JavaStackState __as,
		JavaStackEnqueueList __eq, InputOutput... __io)
		throws NullPointerException
	{
		this(__bs, __as, __eq, (StateOperations)null, __io);
	}
	
	/**
	 * Initializes the result of the operation
	 *
	 * @param __bs The previous stack state.
	 * @param __as The after (the new) stack state.
	 * @param __eq Enqueue list, may be {@code null}.
	 * @param __ops State operations.
	 * @param __io Input/output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public JavaStackResult(JavaStackState __bs, JavaStackState __as,
		JavaStackEnqueueList __eq, StateOperations __ops, InputOutput... __io)
		throws NullPointerException
	{
		if (__bs == null || __as == null)
			throw new NullPointerException("NARG");
		
		// Sort through input/output and put into their own pile
		List<Input> in = new ArrayList<>();
		List<Output> out = new ArrayList<>();
		for (InputOutput x : (__io = (__io == null ?
			new InputOutput[0] : __io.clone())))
			if (x == null)
				throw new NullPointerException("NARG");
			else if (x instanceof Input)
				in.add((Input)x);
			else
				out.add((Output)x);
		
		this.before = __bs;
		this.after = __as;
		this.enqueue = (__eq == null ? new JavaStackEnqueueList(0) : __eq);
		this._in = in.<Input>toArray(new Input[in.size()]);
		this._out = out.<Output>toArray(new Output[out.size()]);
		this.ops = (__ops == null ? new StateOperations() : __ops);
		
		// Debug
		if (__Debug__.ENABLED)
		{
			todo.DEBUG.note("*** Stack Result ***");
			todo.DEBUG.note("BEF: %s", __bs);
			todo.DEBUG.note("AFT: %s", __as);
			if (__eq != null && !__eq.isEmpty())
				todo.DEBUG.note("ENQ: %s", __eq);
			todo.DEBUG.note("IN : %s", in);
			todo.DEBUG.note("OUT: %s", out);
			if (__ops != null && !__ops.isEmpty())
				todo.DEBUG.note("OPS: %s", __ops);
			todo.DEBUG.note("********************");
		}
	}
	
	/**
	 * Represents the new state after the operation was performed.
	 *
	 * @return The state that is the result of the operation.
	 * @since 2019/03/30
	 */
	public final JavaStackState after()
	{
		return this.after;
	}
	
	/**
	 * Represents the previous state which this was based off.
	 *
	 * @return The previous state this originated from.
	 * @since 2019/03/30
	 */
	public final JavaStackState before()
	{
		return this.before;
	}
	
	/**
	 * Returns the enqueue list which represents everything that is to be
	 * uncounted after the operation completes.
	 *
	 * @return The enqueue list, will be empty if there is nothing to
	 * enqueue.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList enqueue()
	{
		return this.enqueue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the input.
	 *
	 * @return The input.
	 * @since 2019/04/08
	 */
	public final JavaStackResult.Input[] in()
	{
		return this._in.clone();
	}
	
	/**
	 * Returns the information on the input.
	 *
	 * @param __i The input to get.
	 * @return The information on the input.
	 * @since 2019/03/30
	 */
	public final JavaStackResult.Input in(int __i)
	{
		return this._in[__i];
	}
	
	/**
	 * Returns the number of generated inputs.
	 *
	 * @return The input count.
	 * @since 2019/03/30
	 */
	public final int inCount()
	{
		return this._in.length;
	}
	
	/**
	 * The operations to be performed.
	 *
	 * @return The operations to perform.
	 * @since 2019/04/11
	 */
	public final StateOperations operations()
	{
		return this.ops;
	}
	
	/**
	 * Returns the output.
	 *
	 * @return The output.
	 * @since 2019/04/08
	 */
	public final JavaStackResult.Output[] out()
	{
		return this._out.clone();
	}
	
	/**
	 * Returns the information on the output.
	 *
	 * @param __i The output to get.
	 * @return The information on the output.
	 * @since 2019/03/30
	 */
	public final JavaStackResult.Output out(int __i)
	{
		return this._out[__i];
	}
	
	/**
	 * Returns the number of generated outputs.
	 *
	 * @return The output count.
	 * @since 2019/03/30
	 */
	public final int outCount()
	{
		return this._out.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Result:{bef=%s, aft=%s, enq=%s, in=%s, out=%s, ops=%s}",
				this.before, this.after, this.enqueue,
				Arrays.asList(this._in), Arrays.asList(this._out),
				this.ops)));
		
		return rv;
	}
	
	/**
	 * Makes an input.
	 *
	 * @param __i The info to base from.
	 * @return The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public static final Input makeInput(JavaStackState.Info __i)
		throws NullPointerException
	{
		return new Input(__i);
	}
	
	/**
	 * Makes an output.
	 *
	 * @param __i The info to base from.
	 * @return The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public static final Output makeOutput(JavaStackState.Info __i)
		throws NullPointerException
	{
		return new Output(__i);
	}
	
	/**
	 * Input information.
	 *
	 * @since 2019/03/30
	 */
	public static final class Input
		implements InputOutput
	{
		/** The register used for input. */
		public final int register;
		
		/** The type which was read. */
		public final JavaType type;
		
		/** Not counting? */
		public final boolean nocounting;
	
		/** String representation. */
		private Reference<String> _string;
		
		/**
		 * Initializes the input.
		 *
		 * @param __i The info to base off.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Input(JavaStackState.Info __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.register = __i.value;
			this.type = __i.type;
			this.nocounting = __i.nocounting;
		}
		
		/**
		 * Initializes the input.
		 *
		 * @param __r The register used.
		 * @param __t The type used.
		 * @param __nc Is not counting?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/08
		 */
		public Input(int __r, JavaType __t, boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.register = __r;
			this.type = __t;
			this.nocounting = __nc;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final boolean equals(Object __o)
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final int hashCode()
		{
			throw new todo.TODO();
		}
		
		/**
		 * Checks if the type is an array.
		 *
		 * @return True if the type is an array.
		 * @since 2019/05/25
		 */
		public final boolean isArray()
		{
			JavaType type = this.type;
			return type.isObject() && type.isArray();
		}
		
		/**
		 * Checks if this type is quickly compatible with the given class.
		 *
		 * @param __cl If this is compatible with the given class.
		 * @return True if this is quickly compatible.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/05/24
		 */
		public final boolean isCompatible(ClassName __cl)
			throws NullPointerException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			JavaType type = this.type;
			return (type.isObject() || type.isPrimitive()) &&
				__cl.equals(type.className());
		}
		
		/**
		 * Is this an object?
		 *
		 * @return If this is an object.
		 * @since 2019/06/12
		 */
		public final boolean isObject()
		{
			return this.type.isObject();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv = String.format(
					"In:{r=r%d, type=%s, flags=%s}",
					this.register, this.type, (this.nocounting ? "NC" : ""))));
			
			return rv;
		}
	}
	
	/**
	 * Used to flag input and output.
	 *
	 * @since 2019/03/31
	 */
	public interface InputOutput
	{
	}
	
	/**
	 * Output information.
	 *
	 * @since 2019/03/30
	 */
	public static final class Output
		implements InputOutput
	{
		/** The register used for output. */
		public final int register;
		
		/** The output type. */
		public final JavaType type;
		
		/** Not counting? */
		public final boolean nocounting;
	
		/** String representation. */
		private Reference<String> _string;
		
		/**
		 * Initializes the output.
		 *
		 * @param __i The info to base off.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Output(JavaStackState.Info __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.register = __i.value;
			this.type = __i.type;
			this.nocounting = __i.nocounting;
		}
		
		/**
		 * Initializes the output.
		 *
		 * @param __r The register used.
		 * @param __t The type used.
		 * @param __nc Is not counting?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/08
		 */
		public Output(int __r, JavaType __t, boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.register = __r;
			this.type = __t;
			this.nocounting = __nc;
		}
		
		/**
		 * Returns this output as an input.
		 *
		 * @return The input.
		 * @since 2019/04/12
		 */
		public final Input asInput()
		{
			return new Input(this.register, this.type, this.nocounting);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final boolean equals(Object __o)
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final int hashCode()
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv = String.format(
					"Out:{r=r%d, type=%s, flags=%s}",
					this.register, this.type, (this.nocounting ? "NC" : ""))));
			
			return rv;
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/JavaStackShuffleType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the type of stack shuffle to perform. Since these
 * operations depend on the types on the stack, this is used to contain the
 * information to simplify the operations.
 *
 * @since 2019/03/30
 */
public enum JavaStackShuffleType
{
	/** dup. */
	DUP("a:aa"),
	
	/** dup_x1. */
	DUP_X1("ba:aba"),
	
	/** dup_x2. */
	DUP_X2("cba:acba",
		"Ba:aBa"),
	
	/** dup2. */
	DUP2("ba:baba",
		"A:AA"),
	
	/** dup2_x1. */
	DUP2_X1("cba:bacba",
		"bA:AbA"),
	
	/** dup2_x2. */
	DUP2_X2("dcba:badcba",
		"cbA:AcbA",
		"Cba:baCba",
		"BA:ABA"),
	
	/** pop. */
	POP("a:"),
	
	/** pop2. */
	POP2("ba:",
		"A:"),
	
	/** swap. */
	SWAP("ba:ab"),
	
	/** End. */
	;
	
	/** Forms of this operation. */
	final Function[] _functions;
	
	/**
	 * Initialize the shuffle form information.
	 *
	 * The forms consist of characters for the various items on the stack.
	 * A lowercase letter represents a narrow type while a capital letter
	 * represents a wide type. Input and output is separated by a colon. The
	 * operation is just that whatever is pushed to the stack has the same
	 * value as the items removed from the stack.
	 *
	 * @param __fs The forms.
	 * @since 2019/04/01
	 */
	JavaStackShuffleType(String... __fs)
	{
		int n = __fs.length;
		Function[] functions = new Function[n];
		for (int i = 0; i < n; i++)
			functions[i] = Function.of(__fs[i]);
		this._functions = functions;
	}
	
	/**
	 * Contains information on how to push or pop operations.
	 *
	 * @since 2019/04/01
	 */
	public static final class Function
	{
		/** Input slots. */
		public final Slots in;
		
		/** Output slots. */
		public final Slots out;
		
		/** String reference. */
		private Reference<String> _string;
		
		/**
		 * Initializes the function.
		 *
		 * @param __in The input.
		 * @param __out The output.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public Function(Slots __in, Slots __out)
			throws NullPointerException
		{
			if (__in == null || __out == null)
				throw new NullPointerException("NARG");
			
			this.in = __in;
			this.out = __out;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/04
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv =
					"[" + this.in + " -> " + this.out + "]"));
			
			return rv;
		}
		
		/**
		 * Returns the function for the given string.
		 *
		 * @param __s The string to parse.
		 * @throws IllegalArgumentException If the function is not valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public static final Function of(String __s)
			throws IllegalArgumentException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error JC1d Expected colon in function form.}
			int col = __s.indexOf(':');
			if (col < 0)
				throw new IllegalArgumentException("JC1d");
			
			return new Function(new Slots(__s.substring(0, col)),
				new Slots(__s.substring(col + 1)));
		}
	}
	
	/**
	 * Represents the slots used for the stack.
	 *
	 * @since 2019/04/01
	 */
	public static final class Slots
	{
		/** The maximum push/pop count. */
		public final int max;
		
		/** The variable index, negative values mean top types. */
		final byte[] _var;
		
		/** Which slots are considered wide or not. */
		final boolean[] _wide;
		
		/** String reference. */
		private Reference<String> _string;
		
		/**
		 * Initializes the slots.
		 *
		 * @param __s The string source.
		 * @throws IllegalArgumentException If the slots are not valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public Slots(String __s)
			throws IllegalArgumentException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Determine the actual popping, with top types and such
			int n = __s.length(),
				max = 0;
			for (int i = 0; i < n; i++)
				if (Character.isUpperCase(__s.charAt(i)))
					max += 2;
				else
					max += 1;
			
			// Stores top and wide states
			byte[] var = new byte[max];
			boolean[] wide = new boolean[max];
			
			// Go through again and fill the output
			for (int i = 0, o = 0; i < n; i++)
			{
				char c = __s.charAt(i);
				boolean iswide = Character.isUpperCase(c);
				
				// Store information here
				var[o] = (byte)(Character.toLowerCase(c) - 'a');
				wide[o++] = iswide;
				
				// The tops of wide types are considered narrow but also have
				// no variable type
				if (iswide)
					var[o++] = -1;
			}
			
			// Store
			this.max = max;
			this._var = var;
			this._wide = wide;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/04
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
			{
				StringBuilder sb = new StringBuilder("[");
				
				// Convert back to close to the original form
				byte[] var = this._var;
				boolean[] wide = this._wide;
				for (int i = 0, n = this.max; i < n; i++)
				{
					int v = var[i];
					boolean w = wide[i];
					
					if (v < 0)
						sb.append('+');
					else
					{
						char c = (char)('a' + v);
						sb.append((w ? Character.toUpperCase(c) : c));
					}
				}
				
				// Finish and cache it
				sb.append(']');
				this._string = new WeakReference<>((rv = sb.toString()));
			}
			
			return rv;
		}
		
		/**
		 * Returns the variable to use.
		 *
		 * @param __i The index to get.
		 * @return The variable here, {@code -1} represents a top type.
		 * @since 2019/04/04
		 */
		public final int variable(int __i)
		{
			return this._var[__i];
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/JavaStackState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.nncc.NativeCode;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.StackMapTableEntry;
import net.multiphasicapps.classfile.StackMapTableState;

/**
 * This class contains the state of the Java stack, it is mostly used in
 * the generation of the register code as it handles caching as well.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackState
{
	/** The base register where arguments start. */
	public static final int BASE_REGISTER =
		NativeCode.ARGUMENT_REGISTER_BASE;
	
	/** The top of the stack. */
	public final int stacktop;
	
	/** Number of used registers. */
	public final int usedregisters;
	
	/** The local variables defined. */
	private final Info[] _locals;
	
	/** The stack variables. */
	private final Info[] _stack;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hash code. */
	private int _hash;
	
	/**
	 * Initializes the stack state, the state will be modified to ensure that
	 * it is correct for normalization purposes.
	 *
	 * @param __l The locals.
	 * @param __s The stack.
	 * @param __ss The top of the stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackState(Info[] __l, Info[] __s, int __ss)
		throws NullPointerException
	{
		if (__l == null || __s == null)
			throw new NullPointerException("NARG");
		
		for (Info i : (__l = __l.clone()))
			if (i == null)
				throw new NullPointerException("NARG");
		
		for (Info i : (__s = __s.clone()))
			if (i == null)
				throw new NullPointerException("NARG");
		
		// Make sure locals are correct
		for (int i = 0, n = __l.length; i < n; i++)
		{
			Info x = __l[i];
			
			// Checks if there is something here
			if (!x.type.isNothing())
			{
				// {@squirreljme.error JC1e Local variables cannot be an alias
				// of another variable. (The local)}
				if (x.value != x.register)
					throw new InvalidClassFormatException("JC1e " + x);
			}
		}
		
		// Correct pre-stack entries?
		for (int i = 0; i < __ss; i++)
		{
			Info x = __s[i];
			if (x.readonly)
				__s[i] = (x = new Info(x.register, x.type, x.value, false,
					x.nocounting));
			
			// Checks if there is something here
			if (!x.type.isNothing())
			{
				// {@squirreljme.error JC1f Stack variables cannot alias
				// variables at higher indexes. (The stack variable)}
				if (x.value > x.register)
					throw new InvalidClassFormatException("JC1f " + x);
			}
		}
		
		// Correct post-stack entries
		for (int i = __ss, n = __s.length; i < n; i++)
		{
			Info x = __s[i];
			if (!x.type.isNothing() || x.value != -1 || x.readonly ||
				x.nocounting)
				__s[i] = (x = new Info(x.register, JavaType.NOTHING, -1, false,
					false));
		}
		
		// Set
		this._locals = __l;
		this._stack = __s;
		this.stacktop = __ss;
		
		// Determine used registers
		int usedregisters = 0;
		for (Info i : __l)
			usedregisters = Math.max(usedregisters, i.register + 1);
		for (Info i : __s)
			usedregisters = Math.max(usedregisters, i.register + 1);
		this.usedregisters = usedregisters + 1;
	}
	
	/**
	 * Compare two stacks and returns a list of registers which have a
	 * compatible or transferable type but collide in their cached value. This
	 * does not check local variables, only stack entries.
	 *
	 * @param __ts The target stack.
	 * @return A list of registers which collide.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList cacheCollision(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// If the two stacks are e
		if (this.equals(__ts))
			return new JavaStackEnqueueList(0);
			
		// {@squirreljme.error JC1g A collision cannot be made where the
		// length of the stack differs. (The length of the source stack; The
		// length of the target stack)}
		int atop = this.stacktop,
			btop = __ts.stacktop;
		if (atop != btop)
			throw new InvalidClassFormatException("JC1g " + atop + " " + btop);
		
		// Registers which collide
		List<Integer> collides = new ArrayList<>();
		
		// Go through and determine which stack entries collide
		Info[] astk = this._stack,
			bstk = __ts._stack;
		for (int i = 0; i < atop; i++)
		{
			Info a = astk[i],
				b = bstk[i];
			
			// Entries which are the same would never collide
			if (a.equals(b))
				continue;
			
			// If either the source or the target or nothing then there can
			// be a transition, one will either be a set to zero or an uncount
			// if an object
			JavaType at = a.type,
				bt = b.type;
			if (at.isNothing() || bt.isNothing())
				continue;
			
			// The target entry is cached, but it has a value which does not
			// map to this register
			if (b.value != b.register && a.register != b.value)
				collides.add(b.register);
		}
		
		return new JavaStackEnqueueList(0, collides);
	}
	
	/**
	 * Returns the state which would be used if the specified registers were
	 * to have their caches cleared. Only the stack is considered as locals
	 * are never cached.
	 *
	 * @param __enq The registers to clear.
	 * @return The resulting stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackState cacheClearState(JavaStackEnqueueList __enq)
		throws NullPointerException
	{
		if (__enq == null)
			throw new NullPointerException("NARG");
		
		// If there is nothing to clear 
		if (__enq.isEmpty())
			return this;
		
		// Clear cache from these
		Info[] stack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Remove any cached slots
		for (int i = 0; i < stacktop; i++)
		{
			Info inf = stack[i];
			
			// This is to be uncached
			if (inf.value != inf.register && __enq.contains(inf.register))
				stack[i] = new Info(inf.register, inf.type, inf.register,
					false, inf.nocounting);
		}
		
		// Build it
		return new JavaStackState(this._locals, stack, stacktop);
	}
	
	/**
	 * Checks if transition can be made to the other state.
	 *
	 * @param __ts The state to check transition to.
	 * @return If it can transition.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final boolean canTransition(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// Transition is possible if there are no collisions
		return this.cacheCollision(__ts).isEmpty();
	}
	
	/**
	 * Performs a flush of the entire state removing all cached values.
	 *
	 * @return The result of the cache flush.
	 * @since 2019/04/11
	 */
	public final JavaStackResult doCacheFlush()
	{
		// This is just a transition to the non-cached state
		return this.doTransition(this.nonCached());
	}
	
	/**
	 * This handles logic used by check cast.
	 *
	 * @param __t The type to cast to.
	 * @return The result of the cast.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/12
	 */
	public final JavaStackResult doCheckCast(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
			
		// This is nearly the same
		Info[] newstack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Get item on the 
		Info topitem = newstack[stacktop - 1];
		
		// Same as the top item, but with a new type instead
		newstack[stacktop - 1] = new Info(
			topitem.register,
			__t,
			topitem.value,
			topitem.readonly,
			topitem.nocounting);
		
		// If the top-most item is counting, then enqueue it in the event
		// exceptions happen
		JavaStackEnqueueList enq;
		if (topitem.nocounting)
			enq = new JavaStackEnqueueList(0);
		else
			enq = new JavaStackEnqueueList(0, topitem.register);
		
		// Create the result
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop),
			enq,
			new StateOperations(),
			JavaStackResult.makeInput(topitem));
	}
	
	/**
	 * Destroys all local variables and stack variables returning the process
	 * that is needed to clear out the entire state.
	 *
	 * Any references that need to be cleared when the code completes will be
	 * placed in the enqueue list.
	 *
	 * @param __rv If true then a return value will be popped before everything
	 * is destroyed, this will be the single input available.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doDestroy(boolean __rv)
	{
		Info inf;
		Info[] locals = this._locals,
			stack = this._stack;
		int stacktop = this.stacktop;
		
		// Setup new locals
		Info[] newlocals = locals.clone();
		
		// Find locals to enqueue
		List<Integer> enqueue = new ArrayList<>();
		List<StateOperation> sops = new ArrayList<>();
		for (int i = 0, n = locals.length; i < n; i++)
		{
			inf = locals[i];
			
			// Enqueue?
			if (inf.canEnqueue())
				enqueue.add(inf.value);
			
			// Clear out
			newlocals[i] = inf.newTypeValue(JavaType.NOTHING, -1, false);
		}
		
		// Return value?
		List<JavaStackResult.InputOutput> io = new ArrayList<>();
		int newstacktop = stacktop;
		Info popped = null;
		if (__rv)
		{
			// Pop top item
			popped = stack[--newstacktop];
			if (popped.type.isTop())
				popped = stack[--newstacktop];
			
			// Add to input
			io.add(JavaStackResult.makeInput(popped));
		}
		
		// Enqueue stack items, they do not need clearing out because setting
		// a limiting top will auto-clear
		// If returning a value do not enqueue what is being returned
		// otherwise it might end up being garbage collected and returned
		int eqss = enqueue.size();
		for (int i = 0; i < newstacktop; i++)
		{
			inf = stack[i];
			
			if (inf.canEnqueue())
				enqueue.add(inf.value);
		}
		
		// If we are popping something, make sure the value that was popped
		// is never enqueued because if it was a cached local or stack entry
		// then it would have been hit by an uncount
		if (popped != null)
			enqueue.remove((Object)popped.value);
		
		// Create result
		return new JavaStackResult(this,
			new JavaStackState(newlocals, stack, 0),
			new JavaStackEnqueueList(eqss, enqueue),
			new StateOperations(sops),
			io.<JavaStackResult.InputOutput>toArray(
				new JavaStackResult.InputOutput[io.size()]));
	}
	
	/**
	 * Removes all stack variables and places a single entry on the stack
	 * for exception handling.
	 *
	 * The input is filled with the entire stack. The output is a single
	 * entry and contains the stack entry to place the value at. The single
	 * stack entry for the exception will never be cached to the exception
	 * register.
	 *
	 * @since 2019/04/13
	 */
	public final JavaStackResult doExceptionHandler()
	{
		return this.doExceptionHandler(JavaType.THROWABLE);
	}
	
	/**
	 * Removes all stack variables and places a single entry on the stack
	 * for exception handling.
	 *
	 * The input is filled with the entire stack. The output is a single
	 * entry and contains the stack entry to place the value at. The single
	 * stack entry for the exception will never be cached to the exception
	 * register.
	 *
	 * @param __t The type to push.
	 * @return The result of the operation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doExceptionHandler(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Enqueues and operations
		List<Integer> enq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Setup new stack
		int oldstacktop = this.stacktop;
		Info[] newstack = this._stack.clone();
		
		// Cleanup everything on the stack!
		for (int i = 0; i < oldstacktop; i++)
		{
			Info sit = newstack[i];
			
			// If there are objects here, then uncount them
			if (sit.canEnqueue())
			{
				enq.add(sit.value);
				ops.add(StateOperation.uncount(sit.value));
			}
		}
		
		// Setup new stack entry
		Info olddest = newstack[0],
			dest = newstack[0].newTypeValue(__t, olddest.register, false);
		newstack[0] = dest;
		
		// Build result, only stack items were enqueued so all entries are
		// stack entries
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, 1),
			new JavaStackEnqueueList(0, enq),
			new StateOperations(ops),
			JavaStackResult.makeOutput(dest));
	}
	
	/**
	 * Loads the specified local variable onto the stack.
	 *
	 * @param __i The local to load from.
	 * @return The result of the operation.
	 * @throws InvalidClassFormatException If the local is not valid or
	 * the stack overflows.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doLocalLoad(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC1h Load of local with no value.
		// (The index; The information about the source)}
		Info from = this._locals[__i];
		if (from.type.isNothing())
			throw new InvalidClassFormatException("JC1h " + __i + " " + from);
		
		// Space needed to be used on the stack
		JavaType type = from.type;
		boolean iswide = type.isWide();
		int space = (iswide ? 2 : 1);
		
		// {@squirreljme.error JC1i Stack would overflow loading local value.}
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		if (stacktop + space > stack.length)
			throw new InvalidClassFormatException("JC1i");
		
		// Setup new stack
		Info[] newstack = stack.clone();
		Info dest;
		newstack[stacktop] = (dest = stack[stacktop].newTypeValue(type,
			from.value, true));
		
		// Add top entry as well
		if (iswide)
			newstack[stacktop + 1] = stack[stacktop + 1].newTypeValue(
				type.topType(), from.value + 1, true);
		
		// Create resulting state
 		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop + space),
			null,
			JavaStackResult.makeInput(from),
			JavaStackResult.makeOutput(dest));
	}
	
	/**
	 * Sets a local variable.
	 *
	 * @param __jt The type of entry to set.
	 * @param __l The local to set.
	 * @return Return the result of the set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public final JavaStackResult doLocalSet(JavaType __jt, int __l)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
			
		Info[] locals = this._locals;
		
		// {@squirreljme.error JC1j Cannot write over a local variable which
		// is read-only. (The local)}
		Info olddest = locals[__l];
		if (olddest.readonly)
			throw new InvalidClassFormatException("JC1j " + olddest);
		
		// If the target local is an object it could be enqueued and it has
		// to be uncounted
		List<Integer> enq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		if (olddest.canEnqueue())
			enq.add(olddest.value);
		
		// If we are going to be writing over two locals we need to check
		// the other as well
		if (__jt.isWide())
		{
			// {@squirreljme.error JC1k Cannot write over a local variable
			// which is read-only. (The local)}
			Info wolddest = locals[__l + 1];
			if (wolddest.readonly)
				throw new InvalidClassFormatException("JC1k " + wolddest);
			
			// If the target local is an object it could be enqueued
			if (wolddest.canEnqueue())
				enq.add(wolddest.value);
		}
		
		// Go through the stack and uncache anything which refers to the
		// old destination by value
		Info[] newstack = this._stack.clone();
		int bumpreg = olddest.register,
			stacktop = this.stacktop;
		for (int i = 0; i < stacktop; i++)
		{
			Info ss = newstack[i];
			
			// If the value points to the local register then it is going to
			// be destroyed, so make sure the value is correctly restored and
			// the cached state of the stack is removed
			if (ss.value == bumpreg)
			{
				int ssreg = ss.register;
				JavaType sst = ss.type;
				
				// Copy the value from the local to the stack entry's true
				// register
				ops.add(new StateOperation((sst.isWide() ?
					StateOperation.Type.WIDE_COPY : StateOperation.Type.COPY),
					bumpreg, ssreg));
				
				// If the local is counted, then the destination spot on the
				// stack needs to be counted
				if (sst.isObject() && !olddest.nocounting)
					ops.add(new StateOperation(StateOperation.Type.COUNT,
						ssreg));
				
				// Then this slot on the stack becomes just a non-cached direct
				// value
				newstack[i] = new Info(ssreg, sst, ssreg, false,
					olddest.nocounting);
				
				// Also un-cache wide values, remember that longs and doubles
				// are never counted
				if (sst.isWide())
					newstack[i + 1] = new Info(ssreg + 1, sst.topType(),
						ssreg + 1, false, false);
			}
		}
		
		// Setup new base local, remember that locals are never aliased but
		// they might use no counting
		Info[] newlocals = locals.clone();
		Info pushed;
		newlocals[__l] = (pushed = olddest.newTypeValue(__jt,
			olddest.register, false));
		
		// Additionally push top type as well
		if (__jt.isWide())
			newlocals[__l + 1] = newlocals[__l + 1].newTypeValue(
				__jt.topType(), pushed.register + 1, false);
		
		// Create resulting state
 		return new JavaStackResult(this,
			new JavaStackState(newlocals, newstack, stacktop),
			new JavaStackEnqueueList(enq.size(), enq),
			new StateOperations(ops),
			JavaStackResult.makeOutput(pushed));
	}
	
	/**
	 * Writes into the specified local variable from the top-most stack entry.
	 *
	 * Locals which are written to are never cached and are exempt from
	 * any kind caching.
	 *
	 * @param __l The local to store.
	 * @return The result of the store.
	 * @throws InvalidClassFormatException If the local cannot be written to.
	 * @since 2019/04/02
	 */
	public final JavaStackResult doLocalStore(int __l)
		throws InvalidClassFormatException
	{
		// Pop the value to store from the stack
		JavaStackResult stackpop = this.doStack(1);
		JavaStackResult.Input popped = stackpop.in(0);
		
		// Then perform the store from this previous result
		JavaStackResult stacksto = stackpop.after().doLocalSet(
			popped.type, __l);
		
		// Copy old operations over to add more potentially
		List<StateOperation> lsops = new ArrayList<>();
		for (StateOperation sop : stacksto.operations())
			lsops.add(sop);
		
		// If we are storing an object, make sure it is counted
		JavaStackResult.Output out = stacksto.out(0);
		if (popped.isObject() && popped.nocounting)
			lsops.add(0, StateOperation.count(popped.register));
		
		// The two states are nearly combined but most of the result comes
		// from the actual push
		return new JavaStackResult(this,
			stacksto.after,
			stacksto.enqueue,
			new StateOperations(lsops),
			popped, out);
	}
	
	/**
	 * Does nothing, keeping the state exactly the same but producing a
	 * result.
	 *
	 * @return The result of doing nothing.
	 * @since 2019/04/07
	 */
	public final JavaStackResult doNothing()
	{
		return new JavaStackResult(this, this, null);
	}
	
	/**
	 * Pops a certain number of variables and then pushes the given types
	 * to the stack. Note that all results of this operation will treat
	 * all of the target stack operations as new freshly obtained values
	 * with no caching performed on them.
	 *
	 * @param __n The number of locals to pop.
	 * @param __t The types to push.
	 * @return The result of the operation.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStack(int __n, JavaType... __t)
	{
		return this.doStack(__n, false, __t);
	}
	
	/**
	 * Pops a certain number of variables and then pushes the given types
	 * to the stack, this may also force caching on pushed values. Note that
	 * all results of this operation will treat
	 * all of the target stack operations as new freshly obtained values
	 * with no caching performed on them.
	 *
	 * @param __n The number of locals to pop.
	 * @param __nc If true then all the values being pushed will not be
	 * reference countable.
	 * @param __pts The types to push.
	 * @return The result of the operation.
	 * @throws IllegalArgumentException If the local count is negative or an
	 * attempt is made to push a top or nothing type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStack(int __n, boolean __nc,
		JavaType... __pts)
		throws IllegalArgumentException, NullPointerException
	{
		// {@squirreljme.error JC1l Cannot pop a negative number of entries.}
		if (__n < 0)
			throw new IllegalArgumentException("JC1l");
		
		// Force blank types for pushing
		__pts = (__pts == null ? new JavaType[0] : __pts.clone());
		for (JavaType pt : __pts)
			if (pt == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error JC1m Cannot push nothing or top type.}
			else if (pt.isNothing() || pt.isTop())
				throw new IllegalArgumentException("JC1m");
		
		// Only the stack is operated on!
		Info[] stack = this._stack;
		int stacktop = this.stacktop,
			stacklimit = stack.length;
		
		// Enqueues to clear popped entries
		List<Integer> enqs = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Pop entries off the stack first
		List<Info> popped = new ArrayList<>();
		for (int i = 0; i < __n; i++)
		{
			// {@squirreljme.error JC1n Stack underflow.}
			if (stacktop <= 0)
				throw new IllegalArgumentException("JC1n");
			
			// Read top most entry, handle tops accordingly
			Info inf = stack[--stacktop];
			if (inf.type.isTop())
				inf = stack[--stacktop];
			
			// Only enqueue objects which are counting and which do not have
			// values of another register
			if (inf.canEnqueue())
				enqs.add(inf.value);
			
			// Was popped, so add to to the pop list
			popped.add(0, inf);
		}
		
		// Setup new stack for pushing
		Info[] newstack = stack.clone();
		
		// Push new entries to the stack
		List<Info> pushed = new ArrayList<>();
		for (JavaType pt : __pts)
		{
			// {@squirreljme.error JC1o Stack overflow. (Top; Limit)}
			if (stacktop >= stacklimit)
				throw new IllegalArgumentException("JC1o " + stacktop + " " +
					stacklimit);
			
			// Setup entry
			Info inf = newstack[stacktop];
			newstack[stacktop] = (inf = inf.newTypeValue(
				pt, inf.register, __nc));
			stacktop++;
			if (pt.isWide())
			{
				newstack[stacktop] = newstack[stacktop].newTypeValue(
					pt.topType(), inf.value + 1, __nc);
				stacktop++;
			}
			
			// Add to pushed set
			pushed.add(inf);
		}
		
		// Convert infos to I/O, note that there is a rare case in the compiler
		// where it nukes stack entries to nothing.
		List<JavaStackResult.InputOutput> ios = new ArrayList<>();
		for (Info i : popped)
			ios.add((i.isNothing() ? JavaStackResult.INPUT_ZERO :
				JavaStackResult.makeInput(i)));
		for (Info o : pushed)
			ios.add(JavaStackResult.makeOutput(o));
		
		// Build result
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop),
			new JavaStackEnqueueList(enqs.size(), enqs),
			new StateOperations(ops),
			ios.<JavaStackResult.InputOutput>toArray(
				new JavaStackResult.InputOutput[ios.size()]));
	}
	
	/**
	 * Performs the specified stack shuffling, which may be duplication or
	 * otherwise.
	 *
	 * @param __t The type of shuffle to perform.
	 * @return The result of the shuffle.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStackShuffle(JavaStackShuffleType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Input stack properties
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		
		// Find function
		JavaStackShuffleType.Function func = this.findShuffleFunction(__t);
		
		// Determine stack properties of the pop
		int maxpop = func.in.max,
			basetop = stacktop - maxpop;
		
		// Load section of stack to be popped
		List<Info> pops = new ArrayList<>(maxpop);
		for (int i = basetop; i < stacktop; i++)
			pops.add(stack[i]);
		
		// Input and output slots
		JavaStackShuffleType.Slots sin = func.in,
			sout = func.out;
		
		// Map virtual variables to entries on the input so we know what is
		// what. Also include the register values are stored at for caching.
		Map<Integer, Info> source = new LinkedHashMap<>();
		Map<Integer, Integer> storedat = new LinkedHashMap<>();
		for (int ldx = 0; ldx < maxpop; ldx++)
		{
			int var = sin._var[ldx];
			if (var >= 0)
			{
				source.put(var, pops.get(ldx));
				storedat.put(var, -1);
			}
		}
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("Source map: %s", source);
		
		// Number of entries to push
		int pushcount = sout.max;
		
		// Initialize new stack
		Info[] newstack = stack.clone();
		int newstacktop = basetop + pushcount;
		
		// Any enqueues and operations to perform
		List<Integer> enqs = new ArrayList<>();
		List<StateOperation> sops = new ArrayList<>();
		
		// For registers which have a value collision, they must be
		// pre-copied to temporary space
		int tempbase = this.usedregisters;
		Map<Integer, Integer> precopy = new LinkedHashMap<>();
		
		// Setup the new stack by pushing around
		for (int at = basetop, ldx = 0; ldx < pushcount; at++, ldx++)
		{
			// Pushing a top type?
			int vardx = sout._var[ldx];
			if (vardx < 0)
			{
				// Set the current to the appropriate top type of the entry
				// before this one
				Info prev = newstack[at - 1];
				newstack[at] = newstack[at].newTypeValue(prev.type.topType(),
					prev.value + 1, false);
				
				continue;
			}
			
			// Get the source info to use for this slot
			// Also the original destination
			Info ssl = source.get(vardx),
				ods = newstack[at];
				
			// Is this type wide?
			boolean iswide = ssl.type.isWide();
			
			// If the value was never used before, try to use the original
			// register for it
			int useval = storedat.get(vardx);
			if (useval < 0)
				useval = ssl.value;
			
			// Using the value position would violate the strict no-aliasing
			// of future registers
			if (useval > ods.register)
			{
				// Try to use an already copied value, if it has not yet had
				// a pre-copy then map it to the copied source instead
				Integer pre = precopy.get(useval);
				if (pre == null)
				{
					precopy.put(useval,
						(pre = (iswide ? -tempbase : tempbase)));
					tempbase += (iswide ? 2 : 1);
				}
				
				// The value to use is the destination register because it
				// will be copied
				useval = ods.register;
				sops.add(StateOperation.copy(iswide, Math.abs(pre), useval));
				
				// Debug
				if (__Debug__.ENABLED)
					todo.DEBUG.note("Pre %d -> %d", pre, useval);
			}
			
			// Set value as being stored here
			storedat.put(vardx, useval);
			
			// Setup slot
			newstack[at] = newstack[at].newTypeValue(ssl.type, useval,
				ssl.nocounting);
		}
		
		// Pre-copies which are needed, but make sure that the original
		// link order is maintained, negative premaps are treated as
		// being wide
		int vdat = 0;
		for (Map.Entry<Integer, Integer> e : precopy.entrySet())
			sops.add(vdat++, StateOperation.copy(
				e.getValue() < 0, e.getKey(), Math.abs(e.getValue())));
		
		// Build
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, newstacktop),
			new JavaStackEnqueueList(enqs.size(), enqs),
			new StateOperations(sops));
	}
	
	/**
	 * Throws a variable from the top of the stack and tosses it.
	 *
	 * @return The result of the throw.
	 * @since 2019/11/30
	 */
	public final JavaStackResult doThrow()
	{
		return this.doStack(1);
	}
	
	/**
	 * Transitions to the given stack state.
	 *
	 * @param __ts The target to transition.
	 * @return The result of the transition and the operations used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public final JavaStackResult doTransition(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// If this state is exactly the same as this one then no actual
		// transition work needs to be done, so no result is generated
		if (this.equals(__ts))
			return new JavaStackResult(this, this, null);
		
		// Debug
		if (__Debug__.ENABLED)
		{
			todo.DEBUG.note("Will transition the stack!");
			todo.DEBUG.note("From: %s", this);
			todo.DEBUG.note("To  : %s", __ts);
		}
		
		// {@squirreljme.error JC1p A transition cannot be made where the
		// length of the stack differs. (The length of the source stack; The
		// length of the target stack)}
		int atop = this.stacktop,
			btop = __ts.stacktop;
		if (atop != btop)
			throw new InvalidClassFormatException("JC1p " + atop + " " + btop);
		
		// Used to store operations and enqueues
		List<Integer> stackenq = new ArrayList<>(),
			localenq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Source and destination stacks
		Info[] asta = this._stack,
			bsta = __ts._stack,
			aloc = this._locals,
			bloc = __ts._locals;
		
		// Transition both the stack and the locals
		for (int z = 0; z < 2; z++)
		{
			Info[] ainf,
				binf;
			int cap;
			
			// Stack transition
			boolean isstack = (z == 0);
			if (isstack)
			{
				ainf = asta;
				binf = bsta;
				cap = atop;
			}
			
			// Local transition
			else
			{
				ainf = aloc;
				binf = bloc;
				cap = aloc.length;
			}
			
			// Go through and transition the locals
			for (int i = 0, n = cap; i < n; i++)
			{
				Info a = ainf[i],
					b = binf[i];
				
				// They are exactly the same, so nothing needs to be done
				if (a.equals(b))
					continue;
				
				// The source is nothing
				JavaType at = a.type,
					bt = b.type;
				if (at.isNothing())
				{
					// Transition to a non-nothing type, just copy zero to it
					if (!bt.isNothing())
						ops.add(StateOperation.copy(
							bt.isWide(), 0, b.value));
				}
				
				// If the target is transitioning to nothing, then it will be
				// removed
				else if (bt.isNothing())
				{
					// If the A local is an object that is countable, then just
					// uncount it
					if (a.canEnqueue())
					{
						localenq.add(a.value);
						ops.add(StateOperation.uncount(a.value));
					}
					
					// If this is a nothing being put on the stack put a
					// zero value there to wipe it!
					if (isstack)
						ops.add(StateOperation.copy(
							false, a.value, b.register));
				}
				
				// Check if the types and values are compatible
				else
				{
					// Transitioning from no-counting to counting means that A
					// was never counted
					if (!a.canEnqueue() && b.canEnqueue())
						ops.add(StateOperation.count(a.value));
					
					// Transition from non-compatible types means that a copy
					// from zero is performed
					if (at.isObject() != bt.isObject() ||
						(!at.isObject() && !at.equals(bt)))
						ops.add(StateOperation.copy(
							bt.isWide(), 0, b.value));
					
					// Copy to destination, if the values differ
					else if (a.value != b.value)
						ops.add(StateOperation.copy(
							at.isWide(), a.value, b.value));
					
					// Going from counting to no counting means we probably
					// have an extra count somewhere
					if (a.canEnqueue() && !b.canEnqueue())
						ops.add(StateOperation.uncount(b.value));
				}
			}
		}
		
		// Merge the enqueues for locals and the stack
		int eqsat = localenq.size();
		localenq.addAll(stackenq);
		
		// The transition results in the target stack so we do not need to
		// initialize it, however we do need enqueues and operations
		return new JavaStackResult(this, __ts,
			new JavaStackEnqueueList(eqsat, localenq),
			new StateOperations(ops));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaStackState))
			return false;
		
		// Faster to compare hashcodes first since there are lots of values
		JavaStackState o = (JavaStackState)__o;
		if (this.hashCode() != o.hashCode())
			return false;
		
		return this.stacktop == o.stacktop &&
			Arrays.equals(this._locals, o._locals) &&
			Arrays.equals(this._stack, o._stack);
	}
	
	/**
	 * Goes through the stack map and filters the locals and types so that
	 * they match what is in the stack map table.
	 *
	 * @param __smts The source stack map.
	 * @return The resulting stack which has been filtered.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackState filterByStackMap(StackMapTableState __smts)
		throws NullPointerException
	{
		if (__smts == null)
			throw new NullPointerException("NARG");
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("SMTS: %s", __smts);
			
		// Input stack properties
		Info[] locals = this._locals.clone(),
			stack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Used to just drop any changes if nothing changed
		boolean changed = false;
		
		// Filter local variables
		for (int i = 0, n = locals.length; i < n; i++)
		{
			// Get infos and state
			Info inf = locals[i];
			StackMapTableEntry sme = __smts.getLocal(i);
			
			// Type changed?
			if (!inf.type.equals(sme.type()))
			{
				// The local is being wiped away
				if (sme.type().isNothing())
					inf = new Info(inf.register, JavaType.NOTHING,
						inf.register, false, false);
				
				// Use this type instead
				else if (inf.type.isObject())
					inf = new Info(inf.register, sme.type(),
						inf.value, inf.readonly, inf.nocounting);
			}
			
			// Set if changed
			if (changed |= (locals[i] != inf))
				locals[i] = inf;
		}
		
		// Filter stack variables
		for (int i = 0; i < stacktop; i++)
		{
			// Get infos and state
			Info inf = stack[i];
			StackMapTableEntry sme = __smts.getStack(i);
			
			// Use type if the object is different
			if (!inf.type.equals(sme.type()) && inf.type.isObject())
				inf = new Info(inf.register, sme.type(),
					inf.value, inf.readonly, inf.nocounting);
			
			// Set if changed
			if (changed |= (stack[i] != inf))
				stack[i] = inf;
		}
		
		// Only return a new state if it actually changed
		if (changed)
			return new JavaStackState(locals, stack, stacktop);
		return this;
	}
	
	/**
	 * Locates the shuffle function that is used to pop from the stack
	 * accordingly to this stack state.
	 *
	 * @param __t The type of shuffle to perform.
	 * @return The matching shuffle function.
	 * @throws InvalidClassFormatException If the shuffle function was not
	 * found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	public final JavaStackShuffleType.Function findShuffleFunction(
		JavaStackShuffleType __t)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Input stack properties
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		
		// Working pop list when match is found
		int basetop = -1,
			maxpop = -1;
		
		// Search for the matching function to use for this state
		for (JavaStackShuffleType.Function tryf : __t._functions)
		{
			// Clear for run
			basetop = -1;
			
			// Input slots are used
			JavaStackShuffleType.Slots sls = tryf.in;
			
			// Too little on the stack to pop everything?
			maxpop = sls.max;
			basetop = stacktop - maxpop;
			if (basetop < 0)
				continue;
			
			// Go through slots and see if this is a match or not
			int at = basetop;
			for (int ldx = 0; at < stacktop; ldx++, at++)
			{
				Info i = stack[at];
				JavaType it = i.type;
				
				// Top-ness and wide-ness does not match
				if (it.isTop() != (sls._var[ldx] < 0) ||
					it.isWide() != sls._wide[ldx])
					break;
			}
			
			// If this index was reached then everything was valid
			if (at == stacktop)
				return tryf;
		}
		
		// {@squirreljme.error JC1q Could not find a match for performing
		// shuffled stack operations.}
		throw new InvalidClassFormatException("JC1q");
	}
	
	/**
	 * Obtains the given local.
	 *
	 * @param __i The local to obtain.
	 * @return The information for the local.
	 * @since 2019/03/30
	 */
	public final JavaStackState.Info getLocal(int __i)
	{
		return this._locals[__i];
	}
	
	/**
	 * Obtains the given stack entry.
	 *
	 * @param __i The stack entry to obtain.
	 * @return The information for the stack entry.
	 * @since 2019/03/30
	 */
	public final JavaStackState.Info getStack(int __i)
	{
		return this._stack[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		int hash = this._hash;
		if (hash == 0)
			this._hash = (hash = this.stacktop -
				Arrays.asList(this._locals).hashCode() ^
				Arrays.asList(this._stack).hashCode());
		return hash;
	}
	
	/**
	 * Returns the number of local used.
	 *
	 * @return The locals used.
	 * @since 2019/04/06
	 */
	public final int maxLocals()
	{
		return this._locals.length;
	}
	
	/**
	 * Returns the maximum stack size.
	 *
	 * @return The maximum stack size.
	 * @since 2019/04/06
	 */
	public final int maxStack()
	{
		return this._stack.length;
	}
	
	/**
	 * Returns the resulting stack state which would be as if nothing were
	 * cached.
	 *
	 * @return The non-cached stack state.
	 * @since 2019/04/11
	 */
	public final JavaStackState nonCached()
	{
		// Create new copies of the state
		int stacktop = this.stacktop;
		Info[] locals = this._locals.clone(),
			stack = this._stack.clone();
		
		// Un-cache locals
		for (int i = 0, n = locals.length; i < n; i++)
		{
			Info info = locals[i];
			
			// Read-only values are never un-cached
			if (info.readonly)
				continue;
			
			// Map value to the register
			locals[i] = info.newValue(info.register, false);
		}
		
		// Un-cache the stack
		for (int i = 0; i < stacktop; i++)
		{
			Info info = stack[i];
			stack[i] = info.newValue(info.register, false);
		}
		
		// Build, do not return the new object if it ends up being the same
		JavaStackState rv = new JavaStackState(locals, stack, stacktop);
		if (this.equals(rv))
			return this;
		return rv;
	}
	
	/**
	 * Returns all of the enqueues which are possible if the entire stack
	 * and locals were to be flushed.
	 *
	 * @return The maximum possible enqueue list.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList possibleEnqueue()
	{
		// This is the same as a destroy
		return this.doDestroy(false).enqueue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("State:{L=");
			
			// Add locals
			sb.append(Arrays.asList(this._locals));
			
			// Add stack entries
			Info[] stack = this._stack;
			sb.append(", S=[");
			for (int i = 0, n = this.stacktop; i < n; i++)
			{
				if (i > 0)
					sb.append(", ");
				sb.append(stack[i]);
			}
			sb.append("]}");
			
			// Build
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Initializes the stack state based off the given stack map table state,
	 * this should only be used for the initial seed of the stack state.
	 *
	 * @param __s The state to base off.
	 * @param __lw Local variables which have been written, this is used to
	 * set flags where locals are cached and can never be written to.
	 * @return The result stack state.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public static final JavaStackState of(StackMapTableState __s, int... __lw)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Optional, might not be specified, but also sort it for searching
		__lw = (__lw == null ? new int[0] : __lw.clone());
		Arrays.sort(__lw);
		
		// Get size of the entries
		int maxlocals = __s.maxLocals(),
			maxstack = __s.maxStack(),
			stacktop = __s.depth();
		
		// Force the stack to have at least a single entry for exception
		// handlers
		if (maxstack == 0)
			maxstack++;
		
		// Setup output infos
		Info[] locals = new Info[maxlocals],
			stack = new Info[maxstack];
		
		// Register position for the slot
		int rpos = JavaStackState.BASE_REGISTER;
		
		// Initialize locals
		for (int i = 0; i < maxlocals; i++)
		{
			StackMapTableEntry from = __s.getLocal(i);
			
			// This local is considered read-only if it is not written to
			boolean ro = !(Arrays.binarySearch(__lw, i) >= 0);
			
			// Is there a type here?
			JavaType t = from.type();
			
			// Setup info here
			locals[i] = new Info(rpos, t, (t.isNothing() ? -1 : rpos), ro, ro);
			rpos++;
		}
		
		// Initialize stack
		for (int i = 0; i < maxstack; i++)
		{
			// Past end of stack?
			if (i >= stacktop)
				stack[i] = new Info(rpos++, JavaType.NOTHING, -1, false,
					false);
			
			// Normal entry
			else
			{
				StackMapTableEntry from = __s.getStack(i);
				
				// Setup info here
				stack[i] = new Info(rpos, from.type(), rpos, false, false);
				rpos++;
			}
		}
		
		// Build it
		return new JavaStackState(locals, stack, stacktop);
	}
	
	/**
	 * Contains information on the individual stack slots.
	 *
	 * @since 2019/03/30
	 */
	public static final class Info
	{
		/** The register position. */
		public final int register;
		
		/** The type. */
		public final JavaType type;
		
		/** The value register. */
		public final int value;
		
		/** Is this read-only? */
		public final boolean readonly;
		
		/** Do not use counting. */
		public final boolean nocounting;
		
		/** String representation. */
		private Reference<String> _string;
		
		/** Hash. */
		private int _hash;
		
		/**
		 * Initializes the information.
		 *
		 * @param __rp The register.
		 * @param __t The type.
		 * @param __rv The value register.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Info(int __rp, JavaType __t, int __rv)
			throws NullPointerException
		{
			this(__rp, __t, __rv, false, false);
		}
		
		/**
		 * Initializes the information.
		 *
		 * @param __rp The register.
		 * @param __t The type.
		 * @param __rv The value register.
		 * @param __ro Is this read-only?
		 * @param __nc Is no counting to be used?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Info(int __rp, JavaType __t, int __rv, boolean __ro,
			boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			// If no value was set, just set it to the position
			if (!__t.isNothing() && __rv < 0)
				__rv = __rp;
			
			// Set
			this.register = __rp;
			this.type = __t;
			this.value = (__rv = (__t.isNothing() ? -1 : __rv));
			this.readonly = __ro;
			this.nocounting = __t.isObject() &&
				(__nc || __rp != __rv || __rv < 0);
		}
		
		/**
		 * Can this be enqueued?
		 *
		 * @return If this can be enqueued.
		 * @since 2019/03/31
		 */
		public final boolean canEnqueue()
		{
			if (this.nocounting)
				return false;
			
			return this.type.isObject() &&
				this.register == this.value;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final boolean equals(Object __o)
		{
			if (this == __o)
				return true;
			
			if (!(__o instanceof Info))
				return false;
			
			Info o = (Info)__o;
			if (this.hashCode() != o.hashCode())
				return false;
			
			return this.register == o.register &&
				this.type.equals(o.type) &&
				this.value == o.value &&
				this.readonly == o.readonly &&
				this.nocounting == o.nocounting;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final int hashCode()
		{
			int rv = this._hash;
			if (rv == 0)
				this._hash = (rv = this.register + this.type.hashCode() +
					this.value + (this.readonly ? 12873 : -18723) +
					(this.nocounting ? 987214 : -2143));
			return rv;
		}
		
		/**
		 * Is this the nothing type?
		 *
		 * @return If this is the nothing type.
		 * @since 2019/05/29
		 */
		public final boolean isNothing()
		{
			return this.type.isNothing();
		}
		
		/**
		 * Returns information with a new type and value.
		 *
		 * @param __t The type to use.
		 * @param __v The value to use.
		 * @param __nc Do not count this?
		 * @return The new information.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public final Info newTypeValue(JavaType __t, int __v, boolean __nc)
			throws NullPointerException
		{
			Info rv = new Info(this.register, __t, __v, false, __nc);
			if (this.equals(rv))
				return this;
			return rv;
		}
		
		/**
		 * Sets up info with a new value, using the same type.
		 *
		 * @param __v The new value.
		 * @param __nc Do not count this?
		 * @return The resulting value.
		 * @since 2019/04/11
		 */
		public final Info newValue(int __v, boolean __nc)
		{
			Info rv = new Info(this.register, this.type, __v, false, __nc);
			if (this.equals(rv))
				return this;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
			{
				int register = this.register;
				JavaType type = this.type;
				boolean ro = this.readonly,
					nc = this.nocounting;
				
				// Use a compact format for nothing
				if (type.isNothing())
					rv = "--(r" + register + ")";
				
				// Otherwise use a more compact form
				// Previously it was {V=r4 (r4), T=I, F=RONC}, however that
				// takes up too much room and is hard to read
				else
				{
					// If value == register, there is no point in duplicating
					int value = this.value;
					rv = String.format("%s:%s%s%s%s",
						(value != register ?
							("r" + value + "(" + register + ")") :
							("r" + value)),
						this.type, ((ro || nc) ? ":" : ""),
						(ro ? "R" : ""), (nc ? "N" : ""));
				}
				
				this._string = new WeakReference<>(rv);
			}
			
			return rv;
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/MathType.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

/**
 * This represents a math operation to be performed.
 *
 * @since 2019/04/03
 */
public enum MathType
{
	/** Add. */
	ADD,
	
	/** Subtract. */
	SUB,
	
	/** Multiply. */
	MUL,
	
	/** Divide. */
	DIV,
	
	/** Remainder. */
	REM,
	
	/** Negate. */
	NEG,
	
	/** Shift left. */
	SHL,
	
	/** Shift right. */
	SHR,
	
	/** Unsigned shift right. */
	USHR,
	
	/** And. */
	AND,
	
	/** Or. */
	OR,
	
	/** Xor. */
	XOR,
	
	/** Compare (float compare less). */
	CMPL,
	
	/** Compare (float compare greater). */
	CMPG,
	
	/** Sign 8-bit value. */
	SIGNX8,
	
	/** Sign 16-bit value. */
	SIGNX16,
	
	/** End. */
	;
	
	/**
	 * Returns the signature for the given math operation and type.
	 *
	 * @param __jt The type to use.
	 * @return The resulting signature.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public final String signature(StackJavaType __jt)
		throws NullPointerException
	{
		switch (this)
		{
			case CMPL:
			case CMPG:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(IIII)I";
					case FLOAT:		return "(II)I";
					case DOUBLE:	return "(IIII)I";
				}
				break;
			
			case NEG:
			case SIGNX8:
			case SIGNX16:
				switch (__jt)
				{
					case INTEGER:	return "(I)I";
					case LONG:		return "(II)J";
					case FLOAT:		return "(I)F";
					case DOUBLE:	return "(II)D";
				}
				break;
			
			case SHL:
			case SHR:
			case USHR:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(III)J";
					case FLOAT:		return "(II)F";
					case DOUBLE:	return "(III)D";
				}
				break;
			
			default:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(IIII)J";
					case FLOAT:		return "(II)F";
					case DOUBLE:	return "(IIII)D";
				}
				break;
		}
		
		throw new todo.OOPS(this + " " + __jt);
	}
	
	/**
	 * Returns the math type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting math type.
	 * @since 2019/04/08
	 */
	public static final MathType of(int __i)
	{
		switch (__i)
		{
			case 0:		return MathType.ADD;
			case 1:		return MathType.SUB;
			case 2:		return MathType.MUL;
			case 3:		return MathType.DIV;
			case 4:		return MathType.REM;
			case 5:		return MathType.NEG;
			case 6:		return MathType.SHL;
			case 7:		return MathType.SHR;
			case 8:		return MathType.USHR;
			case 9:		return MathType.AND;
			case 10:	return MathType.OR;
			case 11:	return MathType.XOR;
			case 12:	return MathType.CMPL;
			case 13:	return MathType.CMPG;
			case 14:	return MathType.SIGNX8;
			case 15:	return MathType.SIGNX16;
		}
		
		// {@squirreljme.error JC1r Invalid math operation.}
		throw new IllegalArgumentException("JC1r");
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/SimplifiedJavaInstruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValueDouble;
import net.multiphasicapps.classfile.ConstantValueFloat;
import net.multiphasicapps.classfile.ConstantValueInteger;
import net.multiphasicapps.classfile.ConstantValueLong;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InstructionMnemonics;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.classfile.TableSwitch;

/**
 * This represents a simplified Java instruction which modifies the operation
 * that was performed to combine and make it more aliased. The primary goal
 * of this class is to simplify the translator code so it does not have to know
 * about every operation.
 *
 * For example {@code ALOAD_2:[]} will become {@code ALOAD:[2]}.
 *
 * @since 2019/04/03
 */
public final class SimplifiedJavaInstruction
{
	/** Store operation. */
	public static final int STORE =
		-2;
	
	/** Load operation. */
	public static final int LOAD =
		-3;
	
	/** Value return operation. */
	public static final int VRETURN =
		-4;
	
	/** Math operation. */
	public static final int MATH =
		-5;
	
	/** If (zero) operation. */
	public static final int IF =
		-6;
	
	/** Value comparison. */
	public static final int IF_CMP =
		-7;
	
	/** Primitive array store. */
	public static final int PASTORE =
		-8;
	
	/** Primitive array load. */
	public static final int PALOAD =
		-9;
	
	/** Stack shuffle. */
	public static final int STACKSHUFFLE =
		-10;
	
	/** Convert. */
	public static final int CONVERT =
		-11;
	
	/** Perform math on constant. */
	public static final int MATH_CONST =
		-12;
	
	/** The operation. */
	protected final int op;
	
	/** The arguments. */
	private final Object[] _args;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Translates a regular instruction to a simplified instruction.
	 *
	 * @param __inst The instruction to translate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public SimplifiedJavaInstruction(Instruction __inst)
		throws NullPointerException
	{
		if (__inst == null)
			throw new NullPointerException("NARG");
		
		// Start with base operations
		int op = __inst.operation();
		Object[] args = __inst.arguments();
		
		// Possibly map the instruction
		int baseop = op;
		switch (op)
		{
			case InstructionIndex.ALOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.OBJECT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.OBJECT,
						baseop - InstructionIndex.ALOAD_0,
					};
				break;
				
			case InstructionIndex.ARETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.OBJECT,
					};
				break;
			
			case InstructionIndex.ASTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.OBJECT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.OBJECT,
						baseop - InstructionIndex.ASTORE_0,
					};
				break;
				
			case InstructionIndex.BALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.BYTE,
					};
				break;
				
			case InstructionIndex.BASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.BYTE,
					};
				break;
			
			case InstructionIndex.BIPUSH:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(__inst.byteArgument(0)),
					};
				break;
				
			case InstructionIndex.CALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.CHARACTER,
					};
				break;
				
			case InstructionIndex.CASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.CHARACTER,
					};
				break;
			
			case InstructionIndex.D2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.D2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.INTEGER,
					};
				break;
			
			case InstructionIndex.D2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.LONG,
					};
				break;
			
			case InstructionIndex.DADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.DALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.DOUBLE,
					};
				break;
				
			case InstructionIndex.DASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.DOUBLE,
					};
				break;
			
			case InstructionIndex.DCMPG:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.DCMPL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.CMPL,
					};
				break;
			
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueDouble(
							baseop - InstructionIndex.DCONST_0),
					};
				break;
				
			case InstructionIndex.DDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.DIV,
					};
				break;
			
			
			case InstructionIndex.DLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.DOUBLE,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.DOUBLE,
						baseop - InstructionIndex.DLOAD_0,
					};
				break;
			
			case InstructionIndex.DMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.DNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.NEG,
						Double.valueOf(0),
					};
				break;
				
			case InstructionIndex.DREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.REM,
					};
				break;
			
			case InstructionIndex.DRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.DOUBLE,
					};
				break;
			
			case InstructionIndex.DSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.DOUBLE,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.DOUBLE,
						baseop - InstructionIndex.DSTORE_0,
					};
				break;
			
			case InstructionIndex.DSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.SUB,
					};
				break;
			
			case InstructionIndex.DUP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP,
					};
				break;
			
			case InstructionIndex.DUP_X1:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP_X1,
					};
				break;
			
			case InstructionIndex.DUP_X2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP_X2,
					};
				break;
			
			case InstructionIndex.DUP2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2,
					};
				break;
			
			case InstructionIndex.DUP2_X1:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2_X1,
					};
				break;
			
			case InstructionIndex.DUP2_X2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2_X2,
					};
				break;
			
			case InstructionIndex.F2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.F2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.INTEGER,
					};
				break;
			
			case InstructionIndex.F2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.LONG,
					};
				break;
			
			case InstructionIndex.FADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.FALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.FLOAT,
					};
				break;
				
			case InstructionIndex.FASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.FLOAT,
					};
				break;
			
			case InstructionIndex.FCMPG:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.FCMPL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.CMPL,
					};
				break;
			
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueFloat(
							baseop - InstructionIndex.FCONST_0),
					};
				break;
				
			case InstructionIndex.FDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.DIV,
					};
				break;
			
			case InstructionIndex.FLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.FLOAT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.FLOAT,
						baseop - InstructionIndex.FLOAD_0,
					};
				break;
			
			case InstructionIndex.FMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.MUL,
					};
				break;
				
			case InstructionIndex.FREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.REM,
					};
				break;
			
			case InstructionIndex.FNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.NEG,
						Float.valueOf(0),
					};
				break;
				
			case InstructionIndex.FRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.FLOAT,
					};
				break;
			
			case InstructionIndex.FSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.FLOAT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.FLOAT,
						baseop - InstructionIndex.FSTORE_0,
					};
				break;
			
			case InstructionIndex.FSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.SUB,
					};
				break;
			
			case InstructionIndex.GOTO_W:
				op = InstructionIndex.GOTO;
				break;
				
			case InstructionIndex.I2B:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SIGNX8,
						0,
					};
				break;
				
			case InstructionIndex.I2C:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.AND,
						0xFFFF,
					};
				break;
				
			case InstructionIndex.I2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.I2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.I2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.LONG,
					};
				break;
				
			case InstructionIndex.I2S:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SIGNX16,
						0,
					};
				break;
				
			case InstructionIndex.IADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.IALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.INTEGER,
					};
				break;
				
			case InstructionIndex.IAND:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.AND,
					};
				break;
				
			case InstructionIndex.IASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.INTEGER,
					};
				break;
			
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(
							baseop - InstructionIndex.ICONST_0),
					};
				break;
				
			case InstructionIndex.IDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.DIV,
					};
				break;
				
			case InstructionIndex.IFEQ:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFGE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFGT:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFLE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFLT:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNONNULL:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNULL:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ACMPEQ:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ACMPNE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPEQ:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPGE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPGT:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPLE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPLT:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPNE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.ILOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.INTEGER,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.INTEGER,
						baseop - InstructionIndex.ILOAD_0,
					};
				break;
			
			case InstructionIndex.IMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.INEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.NEG,
						Integer.valueOf(0),
					};
				break;
				
			case InstructionIndex.IOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.OR,
					};
				break;
				
			case InstructionIndex.IREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.REM,
					};
				break;
				
			case InstructionIndex.IRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.INTEGER,
					};
				break;
			
			case InstructionIndex.ISHL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SHL,
					};
				break;
				
			case InstructionIndex.ISHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SHR,
					};
				break;
			
			case InstructionIndex.ISTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.INTEGER,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.INTEGER,
						baseop - InstructionIndex.ISTORE_0,
					};
				break;
			
			case InstructionIndex.ISUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SUB,
					};
				break;
				
			case InstructionIndex.IUSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.USHR,
					};
				break;
				
			case InstructionIndex.IXOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.XOR,
					};
				break;
				
			case InstructionIndex.L2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.L2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.L2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.INTEGER,
					};
				break;
				
			case InstructionIndex.LADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.LALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.LONG,
					};
				break;
				
			case InstructionIndex.LAND:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.AND,
					};
				break;
				
			case InstructionIndex.LASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.LONG,
					};
				break;
			
			case InstructionIndex.LCMP:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueLong(
							baseop - InstructionIndex.LCONST_0),
					};
				break;
			
			case InstructionIndex.LDC2_W:
			case InstructionIndex.LDC_W:
				op = InstructionIndex.LDC;
				break;
				
			case InstructionIndex.LDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.DIV,
					};
				break;
			
			case InstructionIndex.LLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.LONG,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.LONG,
						baseop - InstructionIndex.LLOAD_0,
					};
				break;
			
			case InstructionIndex.LMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.LNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.LONG,
						MathType.NEG,
						Long.valueOf(0),
					};
				break;
				
			case InstructionIndex.LOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.OR,
					};
				break;
				
			case InstructionIndex.LREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.REM,
					};
				break;
				
			case InstructionIndex.LRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.LONG,
					};
				break;
				
			case InstructionIndex.LSHL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SHL,
					};
				break;
				
			case InstructionIndex.LSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SHR,
					};
				break;
			
			case InstructionIndex.LSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.LONG,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.LONG,
						baseop - InstructionIndex.LSTORE_0,
					};
				break;
			
			case InstructionIndex.LSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SUB,
					};
				break;
				
			case InstructionIndex.LUSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.USHR,
					};
				break;
				
			case InstructionIndex.LXOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.XOR,
					};
				break;
			
				// Make all array allocations just use the class name
			case InstructionIndex.NEWARRAY:
				op = InstructionIndex.ANEWARRAY;
				args = new Object[]
					{
						ClassName.fromPrimitiveType(__inst.<PrimitiveType>
							argument(0, PrimitiveType.class)),
					};
				break;
			
			case InstructionIndex.POP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.POP,
					};
				break;
			
			case InstructionIndex.POP2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.POP2,
					};
				break;
				
			case InstructionIndex.SALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.SHORT,
					};
				break;
				
			case InstructionIndex.SASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.SHORT,
					};
				break;
			
			case InstructionIndex.SIPUSH:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(__inst.shortArgument(0)),
					};
				break;
			
			case InstructionIndex.SWAP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.SWAP,
					};
				break;
			
				// To reduce the number of handlers, convert table switches
				// to lookup switches
			case InstructionIndex.TABLESWITCH:
				op = InstructionIndex.LOOKUPSWITCH;
				args = new Object[]
					{
						__inst.<TableSwitch>argument(0, TableSwitch.class).
							asLookupSwitch(),
					};
				break;
			
			case InstructionIndex.WIDE_IINC:
				op = InstructionIndex.IINC;
				break;
		}
		
		// Store them
		this.op = op;
		this._args = args;
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param __i The index of the argument.
	 * @return The argument.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @since 2019/03/24
	 */
	public Object argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not of the given type.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2019/04/03
	 */
	public final int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).intValue();
	}
	
	/**
	 * Returns the potentially aliased operation.
	 *
	 * @return The operation.
	 * @since 2019/04/03
	 */
	public final int operation()
	{
		return this.op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not a number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				SimplifiedJavaInstruction.mnemonic(this.op) + ":" +
				Arrays.asList(this._args)));
		
		return rv;
	}
	
	/**
	 * Returns the mnemonic of the operation.
	 *
	 * @param __op The operation to obtain.
	 * @return The mnemonic for the string.
	 * @since 2019/04/03
	 */
	public static final String mnemonic(int __op)
	{
		switch (__op)
		{
			case SimplifiedJavaInstruction.STORE:			return "STORE";
			case SimplifiedJavaInstruction.LOAD:			return "LOAD";
			case SimplifiedJavaInstruction.VRETURN:		return "VRETURN";
			case SimplifiedJavaInstruction.MATH:			return "MATH";
			case SimplifiedJavaInstruction.IF:			return "IF";
			case SimplifiedJavaInstruction.IF_CMP:		return "IF_CMP";
			case SimplifiedJavaInstruction.PASTORE:		return "PASTORE";
			case SimplifiedJavaInstruction.PALOAD:		return "PALOAD";
			case SimplifiedJavaInstruction.STACKSHUFFLE:	return "STACKSHUFFLE";
			case SimplifiedJavaInstruction.CONVERT:		return "CONVERT";
			case SimplifiedJavaInstruction.MATH_CONST:	return "MATH_CONST";
			
				// Fallback to standard stuff
			default:
				return InstructionMnemonics.toString(__op);
		}
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/StackJavaType.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.JavaType;

/**
 * This represents a Java type as it would appear on the stack.
 *
 * @since 2019/04/07
 */
public enum StackJavaType
{
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
	
	/**
	 * Returns the boxed type.
	 *
	 * @return The boxed type.
	 * @since 2019/05/27
	 */
	public final String boxedType()
	{
		switch (this)
		{
			case INTEGER:	return "Integer";
			case LONG:		return "Long";
			case FLOAT:		return "Float";
			case DOUBLE:	return "Double";
		}
		
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the signature of this type.
	 *
	 * @return The type signature.
	 * @since 2019/06/21
	 */
	public final String signature()
	{
		switch (this)
		{
			case INTEGER:	return "I";
			case LONG:		return "J";
			case FLOAT:		return "F";
			case DOUBLE:	return "D";
		}
		
		throw new todo.OOPS();
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return If this is wide.
	 * @since 2019/04/20
	 */
	public final boolean isWide()
	{
		return (this == StackJavaType.LONG || this == StackJavaType.DOUBLE);
	}
	
	/**
	 * Returns the software math class.
	 *
	 * @return The software math class.
	 * @since 2019/05/27
	 */
	public final ClassName softwareMathClass()
	{
		String base;
		switch (this)
		{
			case INTEGER:	base = "SoftInteger"; break;
			case LONG:		base = "SoftLong"; break;
			case FLOAT:		base = "SoftFloat"; break;
			case DOUBLE:	base = "SoftDouble"; break;
			
			default:
				throw new todo.TODO();
		}
		
		return new ClassName("cc/squirreljme/jvm/" + base);
	}
	
	/**
	 * Returns this as a basic Java type.
	 *
	 * @return The Java type of this.
	 * @since 2019/04/16
	 */
	public final JavaType toJavaType()
	{
		switch (this)
		{
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the stack type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting stack type.
	 * @since 2019/04/08
	 */
	public static final StackJavaType of(int __i)
	{
		switch (__i)
		{
			case 0:		return StackJavaType.INTEGER;
			case 1:		return StackJavaType.LONG;
			case 2:		return StackJavaType.FLOAT;
			case 3:		return StackJavaType.DOUBLE;
		}
		
		// {@squirreljme.error JC1s Invalid stack Java type.}
		throw new IllegalArgumentException("JC1s");
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/StateOperation.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents an operation that needs to be performed during stack
 * transitions.
 *
 * @since 2019/04/11
 */
public final class StateOperation
{
	/** The type of operation to perform. */
	public final StateOperation.Type type;
	
	/** The A register. */
	public final int a;
	
	/** The B register. */
	public final int b;
	
	/** Hashcode. */
	private int _hash;
	
	/** String. */
	private Reference<String> _string;
	
	/**
	 * Initializes the state operation.
	 *
	 * @param __t The type.
	 * @param __a Register A.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public StateOperation(StateOperation.Type __t, int __a)
		throws NullPointerException
	{
		this(__t, __a, __a);
	}
	
	/**
	 * Initializes the state operation.
	 *
	 * @param __t The type.
	 * @param __a Register A.
	 * @param __b Register B.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public StateOperation(StateOperation.Type __t, int __a, int __b)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		this.type = __t;
		this.a = __a;
		this.b = __b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof StateOperation))
			return false;
		
		StateOperation o = (StateOperation)__o;
		return this.type.equals(o.type) &&
			this.a == o.a &&
			this.b == o.b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.type.hashCode() + this.a + this.b);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.type + "(" +
				this.a + ", " + this.b + ")"));
		
		return rv;
	}
	
	/**
	 * Creates a copy operation.
	 *
	 * @param __w Is this wide?
	 * @param __a The source.
	 * @param __b The destination.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation copy(boolean __w, int __a, int __b)
	{
		return new StateOperation((__w ? Type.WIDE_COPY : Type.COPY),
			__a, __b);
	}
	
	/**
	 * Creates a counting operation.
	 *
	 * @param __a The register to count.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation count(int __a)
	{
		return new StateOperation(Type.COUNT, __a);
	}
	
	/**
	 * Creates a uncounting operation.
	 *
	 * @param __a The register to uncount.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation uncount(int __a)
	{
		return new StateOperation(Type.UNCOUNT, __a);
	}
	
	/**
	 * Represents the type of operation to perform.
	 *
	 * @since 2019/04/11
	 */
	public enum Type
	{
		/** Count. */
		COUNT,
		
		/** Un-count. */
		UNCOUNT,
		
		/** Copy. */
		COPY,
		
		/** Wide copy. */
		WIDE_COPY,
		
		/** End. */
		;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/StateOperations.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This represents multiple state operations.
 *
 * @since 2019/04/12
 */
public final class StateOperations
	implements Iterable<StateOperation>
{
	/** The operations. */
	private final StateOperation[] _ops;
	
	/** The hash. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the state operations.
	 *
	 * @param __ops The operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperations(StateOperation... __ops)
		throws NullPointerException
	{
		for (StateOperation x : (__ops = (__ops == null ?
			new StateOperation[0] : __ops.clone())))
			if (x == null)
				throw new NullPointerException("NARG");
		
		this._ops = __ops;
	}
	
	/**
	 * Initializes the state operations.
	 *
	 * @param __ops The operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperations(Iterable<StateOperation> __ops)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		List<StateOperation> out = new ArrayList<>();
		for (StateOperation x : __ops)
			if (x == null)
				throw new NullPointerException("NARG");
			else
				out.add(x);
		
		this._ops = out.<StateOperation>toArray(
			new StateOperation[out.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof StateOperations))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return Arrays.equals(this._ops, ((StateOperations)__o)._ops);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = Arrays.asList(this._ops).hashCode());
		return rv;
	}
	
	/**
	 * Returns if this is empty is empty or not.
	 *
	 * @return If this is empty.
	 * @since 2019/04/12
	 */
	public final boolean isEmpty()
	{
		return this._ops.length <= 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final Iterator<StateOperation> iterator()
	{
		return UnmodifiableIterator.<StateOperation>of(this._ops);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				Arrays.asList(this._ops).toString()));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/__Debug__.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.classfile.xlate;

/**
 * Stores debug enabled flag.
 *
 * @since 2019/04/16
 */
final class __Debug__
{
	/** Debug enabled? */
	public static final boolean ENABLED;
	
	/**
	 * Gets the debug flag.
	 *
	 * @since 2019/04/16
	 */
	static
	{
		// Get property
		boolean en = false;
		try
		{
			// {@squirreljme.property dev.shadowtail.classfile.xlate.debug=pool
			// Sets whether the massive amounts of debug test should be
			// printed in all the translation codes.}
			en = Boolean.getBoolean("dev.shadowtail.classfile.xlate.debug");
		}
		catch (SecurityException e)
		{
		}
		
		// Set
		ENABLED = en;
	}
}

Added modules/tool-classfile/src/main/java/dev/shadowtail/classfile/xlate/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains utilities which can be used to translate classes
 * and such. This package is something which hopefully would reduce the
 * complexity and code duplication through various translators and such.
 *
 * @since 2019/04/06
 */

package dev.shadowtail.classfile.xlate;

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

package net.multiphasicapps.classfile;

/**
 * These are flags which are associated with accessible objects to determine
 * if they can be accessed from one location to another.
 *
 * @since 2016/05/12
 */
public interface AccessibleFlags
{
	/**
	 * Is the current accessible object package private?
	 *
	 * @return {@code true} if package private.
	 * @since 2016/05/12
	 */
	boolean isPackagePrivate();
	
	/**
	 * Is the current accessible object private?
	 *
	 * @return {@code true} if private.
	 * @since 2016/05/12
	 */
	boolean isPrivate();
	
	/**
	 * Is the current accessible object protected?
	 *
	 * @return {@code true} if protected.
	 * @since 2016/05/12
	 */
	boolean isProtected();
	
	/**
	 * Is the current accessible object public?
	 *
	 * @return {@code true} if public.
	 * @since 2016/05/12
	 */
	boolean isPublic();
}

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

package net.multiphasicapps.classfile;

/**
 * This represents any element which has been annotated.
 *
 * @since 2018/03/06
 */
public interface Annotated
{
	/**
	 * Returns all of the annotations which have been specified for this.
	 *
	 * @return The annotated elements.
	 * @since 2018/03/06
	 */
	AnnotationTable annotationTable();
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Annotation.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This represents an annotation which has values assigned to keys.
 *
 * @since 2018/06/16
 */
public final class Annotation
	implements AnnotationValue
{
	/** The type name of the annotation. */
	protected final ClassName typename;
	
	/** The values for the annotation. */
	private final Map<MethodName, AnnotationValue> _values =
		new LinkedHashMap<>();
	
	/**
	 * Initializes the annotation.
	 *
	 * @param __tn The type name to use.
	 * @param __vs The value mappings.
	 * @throws InvalidClassFormatException If an annotation key is duplicated.
	 * @throws NullPointerException On null arguments or if the value mappings
	 * contain a null value.
	 * @since 2018/09/01
	 */
	private Annotation(ClassName __tn, Map<MethodName, AnnotationValue> __vs)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__tn == null || __vs == null)
			throw new NullPointerException("NARG");
		
		this.typename = __tn;
		
		// Copy key and values over
		Map<MethodName, AnnotationValue> values = this._values;
		for (Map.Entry<MethodName, AnnotationValue> e : __vs.entrySet())
		{
			MethodName k = e.getKey();
			AnnotationValue v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException();
			
			// {@squirreljme.error JC1t Duplicate key within annotation. (The
			// key)}
			if (null != values.put(k, v))
				throw new InvalidClassFormatException(String.format(
					"JC1t %s", k));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the value for the given method name.
	 *
	 * @param __n The key to get the value for.
	 * @return The value of the given key.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public final AnnotationValue get(MethodName __n)
		throws NullPointerException
	{
		// Will never be found
		if (__n == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the key and value map.
	 *
	 * @return The key and value map.
	 * @since 2018/10/28
	 */
	public final Map<MethodName, AnnotationValue> keyValueMap()
	{
		return UnmodifiableMap.<MethodName, AnnotationValue>of(this._values);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the type of this annotation.
	 *
	 * @return The annotation type.
	 * @since 2018/06/16
	 */
	public final ClassName type()
	{
		return this.typename;
	}
	
	/**
	 * Decodes a single annotation from the input data stream and returns the
	 * parsed annotation.
	 *
	 * @param __pool The constant pool.
	 * @param __in The input stream to read from.
	 * @return The parsed annotation.
	 * @throws InvalidClassFormatException If the annotation is invalid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public static final Annotation parse(Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Read the type name, which is a class
		String rawtypename;
		ClassName typename = new FieldDescriptor((rawtypename = __pool.
			<UTFConstantEntry>get(UTFConstantEntry.class,
			__in.readUnsignedShort()).toString())).className();
		
		// {@squirreljme.error JC1u Annotation type is not correct. (The type)}
		if (typename == null)
			throw new InvalidClassFormatException(String.format("JC1u %s",
				rawtypename));
		
		// Read element table
		Map<MethodName, AnnotationValue> values = new LinkedHashMap<>();
		int n = __in.readUnsignedShort();
		for (int i = 0; i < n; i++)
			values.put(new MethodName(__pool.<UTFConstantEntry>get(
				UTFConstantEntry.class, __in.readUnsignedShort()).toString()),
				Annotation.parseValue(__pool, __in));
		
		return new Annotation(typename, values);
	}
	
	/**
	 * Parses a single annotation value.
	 *
	 * @param __pool The pool to read from.
	 * @param __in The input stream.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the value is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public static final AnnotationValue parseValue(Pool __pool,
		DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Read tag, which represents the type of things
		int tag = __in.readUnsignedByte();
		switch (tag)
		{
			case 'B':
			case 'C':
			case 'I':
			case 'S':
			case 'Z':
			case 'D':
			case 'F':
			case 'J':
				return new AnnotationValuePrimitive(
					__pool.<ConstantValueNumber>get(ConstantValueNumber.class,
					__in.readUnsignedShort()).number());
			
			case 's':
				return new AnnotationValueString(
					__pool.<ConstantValueString>get(ConstantValueString.class,
					__in.readUnsignedShort()).toString());
			
			case 'e':
				return new AnnotationValueEnum(
					new FieldDescriptor(__pool.<UTFConstantEntry>get(
						UTFConstantEntry.class, __in.readUnsignedShort()).
						toString()),
					new FieldName(__pool.<UTFConstantEntry>get(
						UTFConstantEntry.class, __in.readUnsignedShort()).
						toString()));
			
			case 'c':
				return new AnnotationValueClass(new FieldDescriptor(
					__pool.<UTFConstantEntry>get(UTFConstantEntry.class,
					__in.readUnsignedShort()).toString()));
			
			case '@':
				return Annotation.parse(__pool, __in);
			
			case '[':
				{
					// Read length
					int len = __in.readUnsignedShort();
					
					// Read in all values
					AnnotationValue[] values = new AnnotationValue[len];
					for (int i = 0; i < len; i++)
						values[i] = Annotation.parseValue(__pool, __in);
					
					// Build
					return new AnnotationValueArray(values);
				}
			
				// {@squirreljme.error JC1v Invalid tag specified in
				// annotation. (The tag used)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC1v %c", tag));
		}
	}
}

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

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This contains the annotation table which stores all of the annotation
 * information. No visibility information is stored because that is not needed
 * in SquirrelJME either by the run-time or the compiler.
 *
 * @since 2018/05/15
 */
public final class AnnotationTable
	implements Iterable<Annotation>
{
	/** The annotations which have been declared. */
	private final Map<ClassName, Annotation> _annotations;
	
	/**
	 * Initializes the annotation table.
	 *
	 * @param __e The input annotations.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AnnotationTable(Annotation... __e)
		throws InvalidClassFormatException, NullPointerException
	{
		this(Arrays.<Annotation>asList((__e != null ? __e :
			new Annotation[0])));
	}
	
	/**
	 * Initializes the annotation table.
	 *
	 * @param __e The input annotations.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AnnotationTable(Iterable<Annotation> __e)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		Map<ClassName, Annotation> rv = new LinkedHashMap<>();
		for (Annotation e : __e)
		{
			// {@squirreljme.error JC1w Duplicate annotation declared. (The
			// declared annotation)}
			ClassName name = e.type();
			if (rv.containsKey(name))
				throw new InvalidClassFormatException(String.format("JC1w %s",
					name));
			
			rv.put(name, e);
		}
		
		this._annotations = rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final Iterator<Annotation> iterator()
	{
		return UnmodifiableIterator.<Annotation>of(
			this._annotations.values());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Decodes the visible and invisible annotations that may exist for a
	 * class, field, or method.
	 *
	 * @param __pool The constant pool.
	 * @param __attrs The input attributes.
	 * @return The parsed annotation values.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static final AnnotationTable parse(Pool __pool,
		AttributeTable __attrs)
		throws IOException, NullPointerException
	{
		if (__pool == null || __attrs == null)
			throw new NullPointerException("NARG");
		
		// Parse visible then invisible annotations
		List<Annotation> rv = new ArrayList<>();
		for (int z = 0; z < 2; z++)
			try (DataInputStream di = __attrs.open((z == 0 ?
				"RuntimeVisibleAnnotations" : "RuntimeInvisibleAnnotations")))
			{
				if (di != null)
				{
					int n = di.readUnsignedShort();
					for (int i = 0; i < n; i++)
						rv.add(Annotation.parse(__pool, di));
				}
			}
		
		return new AnnotationTable(rv);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/AnnotationValue.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface represents any class which is able to be used as a value for
 * a given annotation.
 *
 * @since 2018/06/16
 */
public interface AnnotationValue
{
}

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

package net.multiphasicapps.classfile;

import java.util.AbstractList;
import java.util.List;
import java.util.RandomAccess;

/**
 * This represents an annotation value that is an array.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueArray
	extends AbstractList<AnnotationValue>
	implements AnnotationValue, List<AnnotationValue>, RandomAccess
{
	/** The elements of the array. */
	private final AnnotationValue[] _values;
	
	/**
	 * Initializes the values.
	 *
	 * @param __vs The input values.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueArray(AnnotationValue... __vs)
		throws NullPointerException
	{
		for (AnnotationValue v : (__vs = (__vs == null ?
			new AnnotationValue[0] : __vs.clone())))
			if (v == null)
				throw new NullPointerException("NARG");
		
		this._values = __vs;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final AnnotationValue get(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/AnnotationValueClass.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is an annotation value which represents a class.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueClass
	implements AnnotationValue
{
	/** The class name. */
	protected final FieldDescriptor name;
	
	/**
	 * Initializes the class annotation.
	 *
	 * @param __n The name used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueClass(FieldDescriptor __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/AnnotationValueEnum.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
66
67
68
69
70
71
72
73
74
75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is an annotation value which represents an enumeration.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueEnum
	implements AnnotationValue
{
	/** The type name. */
	protected final FieldDescriptor type;
	
	/** The enum name. */
	protected final FieldName name;
	
	/**
	 * Initializes the annotation enumeration value.
	 *
	 * @param __type The type used.
	 * @param __name The name of the enumeration key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueEnum(FieldDescriptor __type, FieldName __name)
		throws NullPointerException
	{
		if (__type == null || __name == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents an annotation value that represents a primitive constant.
 *
 * @since 2018/06/16
 */
public final class AnnotationValuePrimitive
	extends Number
	implements AnnotationValue
{
	/** The represented number value. */
	protected final Number value;
	
	/**
	 * Initializes the primitive value.
	 *
	 * @param __v The value used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValuePrimitive(Number __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final long longValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/AnnotationValueString.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an annotation value which is a string.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueString
	implements AnnotationValue
{
	/** The string value. */
	protected final String value;
	
	/**
	 * Initializes the string value.
	 *
	 * @param __v The value used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueString(String __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

/**
 * This represents a single attribute which exists within a class.
 *
 * @since 2018/05/14
 */
public final class Attribute
{
	/** The attribute name. */
	protected final String name;
	
	/** The attribute data. */
	private final byte[] _data;
	
	/**
	 * Initializes the attribute.
	 *
	 * @param __name The name of the attribute.
	 * @param __b The data that makes up the attribute.
	 * @param __o The offset to the attribute data.
	 * @param __l The number of bytes in the attribute.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public Attribute(String __name, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__name == null || __b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this.name = __name;
		
		// Copy the array
		byte[] clone = new byte[__l];
		System.arraycopy(__b, __o, clone, 0, __l);
		this._data = clone;
	}
	
	/**
	 * Returns a copy of the attribute bytes.
	 *
	 * @return The attribute bytes.
	 * @since 2018/05/15
	 */
	public final byte[] bytes()
	{
		return this._data.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the name of the attribute.
	 *
	 * @return The attribute name.
	 * @since 2018/05/14
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Opens the attribute as a stream of bytes.
	 *
	 * @return A stream over the bytes of the attribute.
	 * @since 2018/05/14
	 */
	public final DataInputStream open()
	{
		return new DataInputStream(new ByteArrayInputStream(this._data));
	}
	
	/**
	 * Returns the size of the attribute.
	 *
	 * @return The attribute size.
	 * @since 2018/05/14
	 */
	public final int size()
	{
		return this._data.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This represents the attribute table that exists within a class.
 *
 * @since 2018/05/14
 */
public final class AttributeTable
{
	/** The attribute table. */
	private final Map<String, Attribute> _attributes;
	
	/**
	 * Initializes the attribute table.
	 *
	 * @param __a The input attributes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AttributeTable(Attribute... __a)
		throws NullPointerException
	{
		this(Arrays.<Attribute>asList((__a != null ? __a :
			new Attribute[0])));
	}
	
	/**
	 * Initializes the attribute table.
	 *
	 * @param __a The input attributes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AttributeTable(Iterable<Attribute> __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Map<String, Attribute> attributes = new LinkedHashMap<>();
		for (Attribute a : __a)
		{
			if (a == null)
				throw new NullPointerException("NARG");
			
			String n = a.name();
			if (!attributes.containsKey(n))
				attributes.put(n, a);
		}
		this._attributes = attributes;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the attribute that uses the specified name.
	 *
	 * @param __n The name of the attribute to get.
	 * @return The specified attribute or {@code null} if it does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public final Attribute get(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return this._attributes.get(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Opens the attribute by the specified key.
	 *
	 * @param __n The name of the attribute to open.
	 * @return The stream to the given attribute or {@code null} if it is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public final DataInputStream open(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		Attribute a = this.get(__n);
		if (a == null)
			return null;
		return a.open();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of the attribute table.
	 *
	 * @return The attribute table length.
	 * @since 2018/05/14
	 */
	public final int size()
	{
		return this._attributes.size();
	}
	
	/**
	 * Parses the attribute table.
	 *
	 * @param __in The input stream.
	 * @param __pool The constant pool.
	 * @return The attribute table.
	 * @throws InvalidClassFormatException If the table is not correct.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static AttributeTable parse(Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__in == null || __pool == null)
			throw new NullPointerException("NARG");
		
		int n = __in.readUnsignedShort();
		Attribute[] rv = new Attribute[n];
		
		// Read each entry
		for (int i = 0; i < n; i++)
		{
			String name = __pool.<UTFConstantEntry>require(
				UTFConstantEntry.class, __in.readUnsignedShort()).toString();
			
			// {@squirreljme.error JC1x Attributes with a size larger than two
			// gigabytes are not supported.}
			int len = __in.readInt();
			if (len < 0)
				throw new InvalidClassFormatException("JC1x");
			
			byte[] data = new byte[len];
			__in.readFully(data);
			
			rv[i] = new Attribute(name, data, 0, len);
		}
		
		return new AttributeTable(rv);
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This represents a binary name which consists of a class which is
 * separted internally by forwarded slashes.
 *
 * @since 2017/09/27
 */
public final class BinaryName
	implements Comparable<BinaryName>
{
	/** The identifiers in the name. */
	private final ClassIdentifier[] _identifiers;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** The package this is in. */
	private Reference<BinaryName> _package;
	
	/**
	 * Initializes the binary name.
	 *
	 * @param __n The name to initialize.
	 * @throws InvalidClassFormatException If the binary name is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public BinaryName(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Split
		List<ClassIdentifier> id = new ArrayList<>();
		for (int i = 0, n = __n.length(); i < n;)
		{
			// Identifiers are always split by forward slashes like UNIX
			// paths
			int ns = __n.indexOf('/', i);
			if (ns < 0)
				ns = n;
			
			// Split in
			id.add(new ClassIdentifier(__n.substring(i, ns)));
			
			// Skip
			i = ns + 1;
		}
		
		this._identifiers = id.<ClassIdentifier>toArray(
			new ClassIdentifier[id.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int compareTo(BinaryName __o)
	{
		ClassIdentifier[] a = this._identifiers,
			b = __o._identifiers;
		
		// Compare lengths first
		int an = a.length,
			bn = b.length;
		int rv = an - bn;
		if (rv != 0)
			return rv;
		
		// Then individual units
		for (int i = 0; i < an; i++)
		{
			ClassIdentifier x = a[i],
				y = b[i];
			
			rv = x.compareTo(y);
			if (rv != 0)
				return rv;
		}
		
		// Matches
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof BinaryName))
			return false;
		
		BinaryName o = (BinaryName)__o;
		return Arrays.equals(this._identifiers, o._identifiers);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (ClassIdentifier i : this._identifiers)
			rv ^= i.hashCode();
		return rv;
	}
	
	/**
	 * Returns the binary name of the package this class is within.
	 *
	 * @return The binary name of the owning package.
	 * @since 2017/10/09
	 */
	public BinaryName inPackage()
	{
		Reference<BinaryName> ref = this._package;
		BinaryName rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			ClassIdentifier[] identifier = this._identifiers;
			
			for (int i = 0, n = identifier.length - 1; i < n; i++)
			{
				if (i > 0)
					sb.append('/');
				sb.append(identifier[i]);
			}
			
			this._package = new WeakReference<>(
				(rv = new BinaryName(sb.toString())));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			
			for (ClassIdentifier i : this._identifiers)
			{
				if (sb.length() > 0)
					sb.append('/');
				sb.append(i.identifier());
			}
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ByteCode.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This class represents the byte code within a method.
 *
 * @since 2017/10/09
 */
public final class ByteCode
	implements Iterable<Instruction>
{
	/** The code is always at this offset. */
	static final int _CODE_OFFSET =
		8;
	
	/** The maximum number of bytes the byte code may be. */
	private static final int _MAX_CODE_LENGTH =
		65535;
	
	/** The maximum number of stack entries. */
	protected final int maxstack;
	
	/** The maximum number of local entries. */
	protected final int maxlocals;
	
	/** The length of the method code in bytes. */
	protected final int codelen;
	
	/** The constant pool. */
	protected final Pool pool;
	
	/** The exceptions within this method. */
	protected final ExceptionHandlerTable exceptions;
	
	/** This type. */
	protected final ClassName thistype;
	
	/** The name of this method. */
	protected final MethodName methodname;
	
	/** Method type. */
	protected final MethodDescriptor methodtype;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	
	/** The input attribute code, used for instruction lookup. */
	private final byte[] _rawattributedata;
	
	/** The stack map table data. */
	private final byte[] _smtdata;
	
	/** Is the stack map table data new? */
	private final boolean _newsmtdata;
	
	/** The owning method reference. */
	private final Reference<Method> _methodref;
	
	/** Instruction lengths at each position. */
	private final int[] _lengths;
	
	/** The addresses of every instruction by index. */
	private final int[] _index;
	
	/** The line number table. */
	private final short[] _linenumbertable;
	
	/** The cache of instructions in the byte code. */
	private final Reference<Instruction>[] _icache;
	
	/** String representation of this byte code */
	private Reference<String> _string;
	
	/** The stack map table cache. */
	private Reference<StackMapTable> _smt;
	
	/**
	 * Initializes the byte code.
	 *
	 * @param __mr The owning method reference.
	 * @param __ca The raw code attribute data.
	 * @param __tt The this type.
	 * @param __mf Method flags.
	 * @throws InvalidClassFormatException If the byte code is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	ByteCode(Reference<Method> __mr, byte[] __ca, ClassName __tt,
		MethodFlags __mf)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__mr == null || __ca == null || __tt == null || __mf == null)
			throw new NullPointerException("NARG");
		
		// Needed
		Method method = __mr.get();
		
		// Set
		this._methodref = __mr;
		this._rawattributedata = __ca;
		this.issynchronized = __mf.isSynchronized();
		this.isinstance = !__mf.isStatic();
		
		// Is this an initializer method?
		this.methodname = method.name();
		this.methodtype = method.type();
		
		// If any IOExceptions are generated then the attribute is not valid
		Pool pool = method.pool();
		try (DataInputStream in = new DataInputStream(
			new ByteArrayInputStream(__ca)))
		{
			// The number of variables allocated to the method
			int maxstack = in.readUnsignedShort(),
				maxlocals = in.readUnsignedShort();
				
			// {@squirreljme.error JC1y The specified code length is not valid.
			// (The code length)}
			int codelen = in.readInt();
			if (codelen <= 0 || codelen > ByteCode._MAX_CODE_LENGTH)
				throw new InvalidClassFormatException(
					String.format("JC1y %d", codelen));
		
			// Ignore that many bytes
			for (int i = 0; i < codelen; i++)
				in.readByte();
			
			// Read exception handler table
			ExceptionHandlerTable eht = ExceptionHandlerTable.decode(in, pool,
				codelen);
			
			// The instruction index is used to lookup using a linear index
			// count rather than the potentially spaced out address lookup
			int[] index = new int[codelen];
			int indexat = 0;
		
			// Set all lengths initially to invalid positions, this used as a
			// quick marker to determine which positions have valid
			// instructions
			int[] lengths = new int[codelen];
			for (int i = 0; i < codelen; i++)
				lengths[i] = -1;
		
			// Determine instruction lengths for each position
			int[] ollastop = new int[]{-1};
			for (int i = 0, li = -1; i < codelen; li = i)
			{
				// Store address of instruction for an index based lookup
				index[indexat++] = i;
			
				// Store length
				int oplen;
				lengths[i] = (oplen = ByteCode.__opLength(__ca, i, ollastop));
			
				// {@squirreljme.error JC1z The operation exceeds the bounds of
				// the method byte code. (The operation pointer; The operation
				// length; The code length; The last operation pointer)}
				if ((i += oplen) > codelen)
					throw new InvalidClassFormatException(
						String.format("JC1z %d %d %d %d",
							i, oplen, codelen, li));
			}
			
			// The stack map table is used for verification
			byte[] smt = null;
			boolean smtnew = false;
			
			// Parse the attribute table
			AttributeTable attrs = AttributeTable.parse(pool, in);
			
			// Try using the newer stack map table, if that does not exist
			// then fallback to the old one
			Attribute attr = attrs.get("StackMapTable");
			if (attr != null)
			{
				smt = attr.bytes();
				smtnew = true;
			}
			else
			{
				attr = attrs.get("StackMap");
				if (attr != null)
				{
					smt = attr.bytes();
					smtnew = false;
				}
			}
			
			// If there is no stack map, then use a default one (which has
			// just no entries) which has an assumed state
			if (smt == null)
			{
				smt = new byte[2];
				smtnew = true;
			}
			
			// Initialize a blank line number table
			short[] lnt = new short[codelen];
			for (int i = 0; i < codelen; i++)
				lnt[i] = -1;
			
			// Parse the line number table for debug purposes
			attr = attrs.get("LineNumberTable");
			if (attr != null)
				try (DataInputStream ai = attr.open())
				{
					// Read entry count
					int n = ai.readUnsignedShort();
					
					// Read all the individual entries
					for (int i = 0; i < n; i++)
					{
						int pc = ai.readUnsignedShort(),
							line = ai.readUnsignedShort();
						
						// Failed to read the program address, this could be
						// a failure but instead just ignore it and continue
						// on
						if (pc < 0 || pc >= codelen)
							continue;
						
						// This gets handled later, but if there is more than
						// 65534 lines in a file then what is the programmer
						// even doing
						lnt[pc] = (short)line;
					}
				}
			
			// Can set fields now
			this.maxstack = maxstack;
			this.maxlocals = maxlocals;
			this.codelen = codelen;
			this.exceptions = eht;
			this.pool = pool;
			this.thistype = __tt;
			this._smtdata = smt;
			this._newsmtdata = smtnew;
			this._lengths = lengths;
			this._icache = ByteCode.__newCache(codelen);
			this._linenumbertable = lnt;
			
			// Store addresses for all the indexes
			if (indexat == codelen)
				this._index = index;
			else
				this._index = Arrays.copyOf(index, indexat);
		}
		
		// {@squirreljme.error JC20 Failed to read from the code attribute.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC20", e);
		}
	}
	
	/**
	 * Returns the address of the instruction following the specified one.
	 *
	 * @param __a The following address.
	 * @return The instruction address following the instruction at the
	 * specified address.
	 * @throws InvalidClassFormatException If the specified address
	 * is not valid.
	 * @since 2017/05/20
	 */
	public int addressFollowing(int __a)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC21 The instruction at the specified address is
		// not valid. (The address)}
		if (!this.isValidAddress(__a))
			throw new InvalidClassFormatException(
				String.format("JC21 %d", __a));
		
		return __a + this._lengths[__a];
	}
	
	/**
	 * Translates an address to an index.
	 *
	 * @param __a The address to translate.
	 * @return The index of the instruction or {@code -1} if it is not valid,
	 * if the address is the byte code length then the number of indexes is
	 * returned.
	 * @since 2017/08/02
	 */
	public int addressToIndex(int __a)
	{
		// Byte right at the end converts to the last index
		int[] index = this._index;
		if (__a == this.codelen)
			return index.length;
		
		// Not the end
		int rv = Arrays.binarySearch(index, __a);
		if (rv < 0)
			return -1;
		return rv;
	}
	
	/**
	 * Returns the exception handler table.
	 *
	 * @return The exception handler table.
	 * @since 2018/10/13
	 */
	public final ExceptionHandlerTable exceptions()
	{
		return this.exceptions;
	}
	
	/**
	 * Returns the instruction at the specified address.
	 *
	 * @param __a The address to get the instruction for.
	 * @return The represented instruction for the given address.
	 * @throws InvalidClassFormatException If the address is not valid.
	 * @since 2017/05/18
	 */
	public Instruction getByAddress(int __a)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC22 The instruction at the specified address is
		// not valid. (The address)}
		if (!this.isValidAddress(__a))
			throw new InvalidClassFormatException(
				String.format("JC22 %d", __a));
		
		Reference<Instruction>[] icache = this._icache;
		Reference<Instruction> ref = icache[__a];
		Instruction rv;
		
		if (ref == null || null == (rv = ref.get()))
			icache[__a] = new WeakReference<>((rv = new Instruction(
				this._rawattributedata, this.pool, __a, this.exceptions,
				this.stackMapTable(), this.addressFollowing(__a))));
		
		return rv;
	}
	
	/**
	 * Returns the instruction based on an index in the order it appears within
	 * the byte code rather than by address.
	 *
	 * @param __i The instruction index to get.
	 * @return The instruction at this index.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @since 2017/08/01
	 */
	public Instruction getByIndex(int __i)
		throws IndexOutOfBoundsException
	{
		// Check
		int[] index = this._index;
		if (__i < 0 || __i >= index.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.getByAddress(index[__i]);
	}
	
	/**
	 * Translates an index to an address.
	 *
	 * @param __i The index to translate.
	 * @return The address of the index or {@code -1} if it is not valid, if
	 * the index is the number of indexes then the length of the byte code in
	 * addresses is returned.
	 * @since 2017/08/02
	 */
	public int indexToAddress(int __i)
	{
		// Last index translates to the length of the byte code
		int[] index = this._index;
		int n = index.length;
		if (__i == n)
			return this.codelen;
		
		// Normal position
		if (__i < 0 || __i >= n)
			return -1;
		return index[__i];
	}
	
	/**
	 * Returns the number of instructions which are within this method.
	 *
	 * @return The number of instructions which are in the method.
	 * @since 2017/08/01
	 */
	public int instructionCount()
	{
		return this._index.length;
	}
	
	/**
	 * This returns an iterator over the instructions which are defined within
	 * this method.
	 *
	 * @return The iterator over byte code instructions.
	 * @since 2017/05/20
	 */
	public Iterator<Instruction> instructionIterator()
	{
		return new __InstructionIterator__();
	}
	
	/**
	 * Returns if this is an instance or not.
	 *
	 * @return If this is an instance.
	 * @since 2019/04/26
	 */
	public final boolean isInstance()
	{
		return this.isinstance;
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2019/03/24
	 */
	public final boolean isInstanceInitializer()
	{
		return this.methodname.isInstanceInitializer();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2019/03/24
	 */
	public final boolean isStaticInitializer()
	{
		return this.methodname.isStaticInitializer();
	}
	
	/**
	 * Is this method synchronized?
	 *
	 * @return If this is synchronized.
	 * @since 2019/04/26
	 */
	public final boolean isSynchronized()
	{
		return this.issynchronized;
	}
	
	/**
	 * Checks whether the given address is a valid instruction address.
	 *
	 * @param __a The address to check.
	 * @return {@code true} if the address is valid.
	 * @since 2017/05/18
	 */
	public boolean isValidAddress(int __a)
	{
		// Out of range
		if (__a < 0 || __a >= this.codelen)
			return false;
		
		// Has to have a positive non-zero length
		return (this._lengths[__a] > 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/17
	 */
	@Override
	public final Iterator<Instruction> iterator()
	{
		return this.instructionIterator();
	}
	
	/**
	 * Returns the jump targets for this byte code.
	 *
	 * @return The jump targets.
	 * @since 2019/03/30
	 */
	public final Map<Integer, InstructionJumpTargets> jumpTargets()
	{
		Map<Integer, InstructionJumpTargets> rv = new LinkedHashMap<>();
		
		// Just fill addresses with instruction info
		for (Instruction i : this)
			rv.put(i.address(), i.jumpTargets());
		
		return rv;
	}
	
	/**
	 * Returns the length of the byte code.
	 *
	 * @return The byte code length.
	 * @since 2017/05/20
	 */
	public int length()
	{
		return this.codelen;
	}
	
	/**
	 * Returns the line that the address is on, assuming the address is valid
	 * and there is line number information available.
	 *
	 * @param __a The address to lookup.
	 * @return The line of the address or a negative value if it is not valid
	 * or it is unknown.
	 * @since 2018/09/08
	 */
	public final int lineOfAddress(int __a)
	{
		// Scan through the table and try to find the line number for the given
		// address, the table is negative padded for unknown locations
		int codelen = this.codelen;
		short[] linenumbertable = this._linenumbertable;
		int negscandx = __a;
		for (int pc = __a; pc >= 0 && pc < codelen; pc--)
		{
			// Do not use this value if the line is not valid, scan backwards
			short clip = linenumbertable[pc];
			if (clip == -1)
				continue;
			
			// If the address we started at is not valid then a bunch of source
			// code is probably on the same line for a bunch of area so to
			// prevent any extra backscanning when this information is needed
			// cache it back into the table so it is used
			// Fill the entire table to our PC address so that way the entire
			// section is filled
			while (negscandx > pc)
				linenumbertable[negscandx--] = clip;
			
			// Sign extends to int, then removes the negative part so we can
			// recover the full 0-65534 range of the line table
			return (clip & 0xFFFF);
		}
		
		// Not known
		return -1;
	}
	
	/**
	 * Returns the maximum number of locals.
	 *
	 * @return The maximum number of locals.
	 * @since 2017/05/20
	 */
	public int maxLocals()
	{
		return this.maxlocals;
	}
	
	/**
	 * Returns the maximum size of the stack.
	 *
	 * @return The maximum stack size.
	 * @since 2017/05/20
	 */
	public int maxStack()
	{
		return this.maxstack;
	}
	
	/**
	 * Returns the name of this method.
	 *
	 * @return The method name.
	 * @since 2019/04/22
	 */
	public final MethodName name()
	{
		return this.methodname;
	}
	
	/**
	 * Returns the constant pool being used.
	 *
	 * @return The constant pool the method uses.
	 * @since 2017/05/20
	 */
	public Pool pool()
	{
		return this.pool;
	}
	
	/**
	 * Reads an unsigned short from the raw byte code at the given address.
	 *
	 * @param __addr The address to read from.
	 * @return The read unsigned short.
	 * @throws IndexOutOfBoundsException If the address is out of bounds.
	 * @since 2018/09/28
	 */
	public final int readRawCodeUnsignedShort(int __addr)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error JC23 Out of bounds read of unsigned short from
		// raw byte code. (The address)}
		if (__addr < 0 || __addr >= this.codelen - 1)
			throw new IndexOutOfBoundsException(
				String.format("JC23 %d", __addr));
		
		byte[] rad = this._rawattributedata;
		int d = __addr + ByteCode._CODE_OFFSET;
		return ((rad[d] & 0xFF) << 8) |
			(rad[d + 1] & 0xFF);
	}
	
	/**
	 * Returns the reverse jump targets, this essentially specifies the
	 * instructions and exception handlers at given points jump to the
	 * key addresses.
	 *
	 * @return The reverse jump targets.
	 * @since 2019/03/30
	 */
	public final Map<Integer, InstructionJumpTargets> reverseJumpTargets()
	{
		// Get the original jump table
		Map<Integer, InstructionJumpTargets> jumpmap = this.jumpTargets();
		
		// The target jump table has both normals and exceptions so it must
		// remember that state accordingly
		class Working
		{
			Set<InstructionJumpTarget> normal =
				new LinkedHashSet<>();
			
			Set<InstructionJumpTarget> exception =
				new LinkedHashSet<>();
		}
		Map<Integer, Working> works = new LinkedHashMap<>();
		
		// Go through all the original jump targets and add them
		for (Map.Entry<Integer, InstructionJumpTargets> e : jumpmap.entrySet())
		{
			InstructionJumpTarget addr = new InstructionJumpTarget(e.getKey());
			InstructionJumpTargets jumps = e.getValue();
			
			for (int i = 0, n = jumps.size(); i < n; i++)
			{
				int targ = jumps.get(i).target();
				boolean isex = jumps.isException(i);
				
				// Create work if missing
				Working work = works.get(targ);
				if (work == null)
					works.put(targ, (work = new Working()));
				
				// Add
				if (isex)
					work.exception.add(addr);
				else
					work.normal.add(addr);
			}
		}
		
		// Finalize for returning
		Map<Integer, InstructionJumpTargets> rv = new LinkedHashMap<>();
		for (Map.Entry<Integer, Working> e : works.entrySet())
		{
			Working work = e.getValue();
			Set<InstructionJumpTarget> nrm = work.normal,
				exe = work.exception;
			
			// Convert
			rv.put(e.getKey(), new InstructionJumpTargets(
				nrm.<InstructionJumpTarget>toArray(
					new InstructionJumpTarget[nrm.size()]),
				exe.<InstructionJumpTarget>toArray(
					new InstructionJumpTarget[exe.size()])));
		}
		
		return rv;
	}
	
	/**
	 * Returns the stack map table.
	 *
	 * @return The stack map table.
	 * @since 2017/10/15
	 */
	public StackMapTable stackMapTable()
	{
		Reference<StackMapTable> ref = this._smt;
		StackMapTable rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._smt = new WeakReference<>(rv = new __StackMapParser__(
				this.pool, this.__method(), this._newsmtdata, this._smtdata,
				this, new JavaType(this.thistype)).get());
		
		return rv;
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The current class name.
	 * @since 2019/03/24
	 */
	public final ClassName thisType()
	{
		return this.thistype;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("[");
			
			// Fill in instructions
			boolean comma = false;
			for (Iterator<Instruction> it = this.instructionIterator();
				 it.hasNext();)
			{
				if (comma)
					sb.append(", ");
				else
					comma = true;
				
				sb.append(it.next());
			}
			
			sb.append(']');
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Returns the method type.
	 *
	 * @return The method type.
	 * @since 2019/04/22
	 */
	public final MethodDescriptor type()
	{
		return this.methodtype;
	}
	
	/**
	 * Returns all of the local variables which are written to.
	 *
	 * @return The local variables which are written to.
	 * @since 2019/03/30
	 */
	public final int[] writtenLocals()
	{
		Set<Integer> written = new LinkedHashSet<>();
		
		// Go through all instructions and count anything which is written to
		for (Instruction inst : this)
		{
			// Anything which is wide hits the adjacent local as well
			boolean wide = false;
			
			// Only specific instructions will do so
			int hit, op;
			switch ((op = inst.operation()))
			{
				case InstructionIndex.ASTORE:
				case InstructionIndex.WIDE_ASTORE:
				case InstructionIndex.FSTORE:
				case InstructionIndex.WIDE_FSTORE:
				case InstructionIndex.IINC:
				case InstructionIndex.WIDE_IINC:
				case InstructionIndex.ISTORE:
				case InstructionIndex.WIDE_ISTORE:
					hit = inst.intArgument(0);
					break;
				
				case InstructionIndex.ASTORE_0:
				case InstructionIndex.ASTORE_1:
				case InstructionIndex.ASTORE_2:
				case InstructionIndex.ASTORE_3:
					hit = op - InstructionIndex.ASTORE_0;
					break;
				
				case InstructionIndex.DSTORE:
				case InstructionIndex.WIDE_DSTORE:
				case InstructionIndex.LSTORE:
				case InstructionIndex.WIDE_LSTORE:
					hit = inst.intArgument(0);
					wide = true;
					break;
				
				case InstructionIndex.DSTORE_0:
				case InstructionIndex.DSTORE_1:
				case InstructionIndex.DSTORE_2:
				case InstructionIndex.DSTORE_3:
					hit = op - InstructionIndex.DSTORE_0;
					wide = true;
					break;
				
				case InstructionIndex.FSTORE_0:
				case InstructionIndex.FSTORE_1:
				case InstructionIndex.FSTORE_2:
				case InstructionIndex.FSTORE_3:
					hit = op - InstructionIndex.FSTORE_0;
					break;
				
				case InstructionIndex.ISTORE_0:
				case InstructionIndex.ISTORE_1:
				case InstructionIndex.ISTORE_2:
				case InstructionIndex.ISTORE_3:
					hit = op - InstructionIndex.ISTORE_0;
					break;
				
				case InstructionIndex.LSTORE_0:
				case InstructionIndex.LSTORE_1:
				case InstructionIndex.LSTORE_2:
				case InstructionIndex.LSTORE_3:
					hit = op - InstructionIndex.LSTORE_0;
					wide = true;
					break;
				
				default:
					continue;
			}
			
			// Set local as being written to, handle wides as well
			written.add(hit);
			if (wide)
				written.add(hit + 1);
		}
		
		// Convert to array
		Integer[] from = written.<Integer>toArray(new Integer[written.size()]);
		int n = from.length;
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = from[i];
		return rv;
	}
	
	/**
	 * Returns the method which owns this byte code.
	 *
	 * @return The owning method.
	 * @since 2017/10/15
	 */
	private final Method __method()
	{
		// {@squirreljme.error JC24 The method owning this byte code has been
		// garbage collected.}
		Method rv = this._methodref.get();
		if (rv == null)
			throw new IllegalStateException("JC24");
		return rv;
	}
	
	/**
	 * Initializes a new cache array.
	 *
	 * @param __l The length of the array.
	 * @return The cache array.
	 * @since 2017/05/18
	 */
	@SuppressWarnings({"unchecked"})
	private static Reference<Instruction>[] __newCache(int __l)
	{
		return (Reference<Instruction>[])((Object)new Reference[__l]);
	}
	
	/**
	 * Returns the length of the operation at the given address.
	 *
	 * @param __code The method byte code.
	 * @param __a The address of the instruction to get the length of.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/17
	 */
	private static int __opLength(byte[] __code, int __a, int[] __last)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__code == null)
			throw new NullPointerException("NARG");
		
		// Base instruction length is always 1
		int rv = 1;
		
		// Real offset, since the code attribute is offset
		int aa = __a + ByteCode._CODE_OFFSET;
		
		// Read operation
		int op = (__code[aa] & 0xFF);
		if (op == InstructionIndex.WIDE)
		{
			// {@squirreljme.error JC25 The wide instruction cannot be the
			// last instruction in a method. (The address)}
			if (aa + 1 >= __code.length)
				throw new InvalidClassFormatException(
					String.format("JC25 %d", __a));
			
			op = (op << 8) | (__code[aa + 1] & 0xFF);
			rv = 2;
		}
		
		// Depends on the operation
		switch (op)
		{
				// {@squirreljme.error JC26 Unsupported instruction specified
				// in the method byte code. (The operation; The address)}
			case InstructionIndex.BREAKPOINT:
			case InstructionIndex.IMPDEP1:
			case InstructionIndex.IMPDEP2:
			case InstructionIndex.JSR:
			case InstructionIndex.JSR_W:
			case InstructionIndex.RET:
			case InstructionIndex.WIDE:
				throw new InvalidClassFormatException(
					String.format("JC26 %d %d", op, __a));
			
				// {@squirreljme.error JC27 Invokedynamic is not supported in
				// this virtual machine. (The address)}
			case InstructionIndex.INVOKEDYNAMIC:
				throw new InvalidClassFormatException(
					String.format("JC27 %d", __a));
				
				// Operands with no arguments
			case InstructionIndex.AALOAD:
			case InstructionIndex.AASTORE:
			case InstructionIndex.ACONST_NULL:
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
			case InstructionIndex.ARETURN:
			case InstructionIndex.ARRAYLENGTH:
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
			case InstructionIndex.ATHROW:
			case InstructionIndex.BALOAD:
			case InstructionIndex.BASTORE:
			case InstructionIndex.CALOAD:
			case InstructionIndex.CASTORE:
			case InstructionIndex.D2F:
			case InstructionIndex.D2I:
			case InstructionIndex.D2L:
			case InstructionIndex.DADD:
			case InstructionIndex.DALOAD:
			case InstructionIndex.DASTORE:
			case InstructionIndex.DCMPG:
			case InstructionIndex.DCMPL:
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
			case InstructionIndex.DDIV:
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
			case InstructionIndex.DMUL:
			case InstructionIndex.DNEG:
			case InstructionIndex.DREM:
			case InstructionIndex.DRETURN:
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
			case InstructionIndex.DSUB:
			case InstructionIndex.DUP:
			case InstructionIndex.DUP2:
			case InstructionIndex.DUP2_X1:
			case InstructionIndex.DUP2_X2:
			case InstructionIndex.DUP_X1:
			case InstructionIndex.DUP_X2:
			case InstructionIndex.F2D:
			case InstructionIndex.F2I:
			case InstructionIndex.F2L:
			case InstructionIndex.FADD:
			case InstructionIndex.FALOAD:
			case InstructionIndex.FASTORE:
			case InstructionIndex.FCMPG:
			case InstructionIndex.FCMPL:
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
			case InstructionIndex.FDIV:
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
			case InstructionIndex.FMUL:
			case InstructionIndex.FNEG:
			case InstructionIndex.FREM:
			case InstructionIndex.FRETURN:
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
			case InstructionIndex.FSUB:
			case InstructionIndex.I2B:
			case InstructionIndex.I2C:
			case InstructionIndex.I2D:
			case InstructionIndex.I2F:
			case InstructionIndex.I2L:
			case InstructionIndex.I2S:
			case InstructionIndex.IADD:
			case InstructionIndex.IALOAD:
			case InstructionIndex.IAND:
			case InstructionIndex.IASTORE:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.IDIV:
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
			case InstructionIndex.IMUL:
			case InstructionIndex.INEG:
			case InstructionIndex.IOR:
			case InstructionIndex.IREM:
			case InstructionIndex.IRETURN:
			case InstructionIndex.ISHL:
			case InstructionIndex.ISHR:
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
			case InstructionIndex.ISUB:
			case InstructionIndex.IUSHR:
			case InstructionIndex.IXOR:
			case InstructionIndex.L2D:
			case InstructionIndex.L2F:
			case InstructionIndex.L2I:
			case InstructionIndex.LADD:
			case InstructionIndex.LALOAD:
			case InstructionIndex.LAND:
			case InstructionIndex.LASTORE:
			case InstructionIndex.LCMP:
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
			case InstructionIndex.LDIV:
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
			case InstructionIndex.LMUL:
			case InstructionIndex.LNEG:
			case InstructionIndex.LOR:
			case InstructionIndex.LREM:
			case InstructionIndex.LRETURN:
			case InstructionIndex.LSHL:
			case InstructionIndex.LSHR:
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
			case InstructionIndex.LSUB:
			case InstructionIndex.LUSHR:
			case InstructionIndex.LXOR:
			case InstructionIndex.MONITORENTER:
			case InstructionIndex.MONITOREXIT:
			case InstructionIndex.NOP:
			case InstructionIndex.POP:
			case InstructionIndex.POP2:
			case InstructionIndex.RETURN:
			case InstructionIndex.SALOAD:
			case InstructionIndex.SASTORE:
			case InstructionIndex.SWAP:
				break;
				
				// An additional byte
			case InstructionIndex.ALOAD:
			case InstructionIndex.ASTORE:
			case InstructionIndex.BIPUSH:
			case InstructionIndex.DLOAD:
			case InstructionIndex.DSTORE:
			case InstructionIndex.FLOAD:
			case InstructionIndex.FSTORE:
			case InstructionIndex.ILOAD:
			case InstructionIndex.ISTORE:
			case InstructionIndex.LDC:
			case InstructionIndex.LLOAD:
			case InstructionIndex.LSTORE:
			case InstructionIndex.NEWARRAY:
				rv++;
				break;
				
				// Operations with two bytes following
			case InstructionIndex.ANEWARRAY:
			case InstructionIndex.CHECKCAST:
			case InstructionIndex.GETFIELD:
			case InstructionIndex.GETSTATIC:
			case InstructionIndex.GOTO:
			case InstructionIndex.IF_ACMPEQ:
			case InstructionIndex.IF_ACMPNE:
			case InstructionIndex.IFEQ:
			case InstructionIndex.IFGE:
			case InstructionIndex.IFGT:
			case InstructionIndex.IF_ICMPEQ:
			case InstructionIndex.IF_ICMPGE:
			case InstructionIndex.IF_ICMPGT:
			case InstructionIndex.IF_ICMPLE:
			case InstructionIndex.IF_ICMPLT:
			case InstructionIndex.IF_ICMPNE:
			case InstructionIndex.IFLE:
			case InstructionIndex.IFLT:
			case InstructionIndex.IFNE:
			case InstructionIndex.IFNONNULL:
			case InstructionIndex.IFNULL:
			case InstructionIndex.IINC:
			case InstructionIndex.INSTANCEOF:
			case InstructionIndex.INVOKESPECIAL:
			case InstructionIndex.INVOKESTATIC:
			case InstructionIndex.INVOKEVIRTUAL:
			case InstructionIndex.LDC2_W:
			case InstructionIndex.LDC_W:
			case InstructionIndex.NEW:
			case InstructionIndex.PUTFIELD:
			case InstructionIndex.PUTSTATIC:
			case InstructionIndex.SIPUSH:
			case InstructionIndex.WIDE_ALOAD:
			case InstructionIndex.WIDE_ASTORE:
			case InstructionIndex.WIDE_DLOAD:
			case InstructionIndex.WIDE_DSTORE:
			case InstructionIndex.WIDE_FLOAD:
			case InstructionIndex.WIDE_FSTORE:
			case InstructionIndex.WIDE_ILOAD:
			case InstructionIndex.WIDE_ISTORE:
			case InstructionIndex.WIDE_LLOAD:
			case InstructionIndex.WIDE_LSTORE:
				rv += 2;
				break;
				
				// Three bytes
			case InstructionIndex.INVOKEINTERFACE:
			case InstructionIndex.MULTIANEWARRAY:
				rv += 3;
				break;
				
				// Four bytes
			case InstructionIndex.GOTO_W:
			case InstructionIndex.WIDE_IINC:
				rv += 4;
				break;
			
				// Table switch, the length of this instruction varies due to
				// alignment and the count contained within
			case InstructionIndex.TABLESWITCH:
				//             tusaddr +4    +8
			    // +0          +4      +8    +12    [+16x4         ]...
				// op  x  x  x default lowdx highdx [(highdx-lowdx)]...
				//    op  x  x default lowdx highdx [(highdx-lowdx)]...
				//       op  x default lowdx highdx [(highdx-lowdx)]...
				//          op default lowdx highdx [(highdx-lowdx)]...
				// tuspadlen includes the opcode
				int tusaddr = ((aa + 4) & (~3)),
					tuspadlen = tusaddr - aa;
				rv = tuspadlen + 12 + (4 *
					(Instruction.__readInt(__code, tusaddr + 8) -
					Instruction.__readInt(__code, tusaddr + 4) + 1));
				break;
				
				// Lookup switch, the length of this instruction varies due to
				// alignment and the number of contained entries.
			case InstructionIndex.LOOKUPSWITCH:
				// The instruction is in this format:
				//             lusaddr +4    +8
				// +0          +4      +8    [+12x8       ]...
				// op  x  x  x default count [match offset]...
				//    op  x  x default count [match offset]...
				//       op  x default count [match offset]...
				//          op default count [match offset]...
				// luspadlen includes the opcode
				int lusaddr = ((aa + 4) & (~3)),
					luspadlen = lusaddr - aa;
				rv = luspadlen + 8 + (8 * Instruction.__readInt(__code,
					lusaddr + 4));
				break;
			
				// {@squirreljme.error JC28 Cannot get the length of the
				// specified operation because it is not valid. (The operation;
				// The address; The operation before this one)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC28 %d %d %d", op, __a,
					((__last != null && __last.length > 0) ? __last[0] : -1)));
		}
		
		// Set last
		if (__last != null && __last.length > 0)
			__last[0] = op;
		
		return rv;
	}
	
	/**
	 * This iterates over each byte code instruction.
	 *
	 * @since 2017/05/20
	 */
	private final class __InstructionIterator__
		implements Iterator<Instruction>
	{
		/** The code length. */
		protected final int codelen =
			ByteCode.this.codelen;
		
		/** The read address. */
		private int _at =
			0;
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public boolean hasNext()
		{
			return this._at < this.codelen;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public Instruction next()
			throws NoSuchElementException
		{
			// No more?
			if (!this.hasNext())
				throw new NoSuchElementException("NSEE");
			
			// Instruction at current pointer
			int at = this._at;
			Instruction rv = ByteCode.this.getByAddress(at);
			
			// Skip length of instruction
			this._at += ByteCode.this._lengths[at];
			
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public void remove()
			throws UnsupportedOperationException
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ClassFile.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.io.SizeLimitedInputStream;

/**
 * This represents a class file which was most likely derived from the binary
 * class file format of a class.
 *
 * @since 2017/09/26
 */
public final class ClassFile
	implements Annotated, HasAccessibleFlags
{
	/** The magic number of the class file. */
	private static final int _MAGIC_NUMBER =
		0xCAFEBABE;
	
	/** The version of this class. */
	protected final ClassVersion version;
	
	/** The flags for this class. */
	protected final ClassFlags classflags;
	
	/** The name of this class. */
	protected final ClassName thisname;
	
	/** The class this extends. */
	protected final ClassName supername;
	
	/** The annotation table of the class. */
	protected final AnnotationTable annotations;
	
	/** The referenced inner classes. */
	protected final InnerClasses innerclasses;
	
	/** The source file the class is in. */
	protected final String sourcefilename;
	
	/** The interfaces this class implements. */
	protected final ClassNames interfaces;
	
	/** The fields within this class. */
	private final Field[] _fields;
	
	/** The methods within this class. */
	private final Method[] _methods;
	
	/**
	 * Initializes the class file.
	 *
	 * @param __ver The version of the class.
	 * @param __cf The flags for this class.
	 * @param __tn The name of this class.
	 * @param __sn The class this class extends, may be {@code null}.
	 * @param __in The interfaces this class implements.
	 * @param __fs The fields in this class.
	 * @param __ms The methods in this class.
	 * @param __icl Defined inner classes.
	 * @param __at Annotations that are declared on the class.
	 * @param __sfn Source file name.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments, except for {@code __sn}.
	 * @since 2017/09/26
	 */
	ClassFile(ClassVersion __ver, ClassFlags __cf, ClassName __tn,
		ClassName __sn, ClassName[] __in, Field[] __fs, Method[] __ms,
		InnerClasses __icl, AnnotationTable __at, String __sfn)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__ver == null || __cf == null || __tn == null ||
			__in == null || __fs == null || __ms == null || __icl == null ||
			__at == null)
			throw new NullPointerException("NARG");
		
		// Check sub-arrays for null
		for (Object[] foo : new Object[][]{(__in = __in.clone()),
			(__fs = __fs.clone()), (__ms = __ms.clone())})
			for (Object f : foo)
				if (f == null)
					throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC29 Either Object has a superclass which it
		// cannot extend any class or any other class does not have a super
		// class. Additionally primitive types cannot have a super class.
		// (The current class name; The super class name; Object class name;
		// Is this primitive?)}
		ClassName objectcn = new ClassName("java/lang/Object");
		if ((__tn.isPrimitive() ||
			__tn.equals(objectcn)) != (__sn == null))
			throw new InvalidClassFormatException(String.format(
				"JC29 %s %s %s %s",
				__tn, __sn, objectcn, __tn.isPrimitive()));
		
		// Set
		this.version = __ver;
		this.classflags = __cf;
		this.thisname = __tn;
		this.supername = __sn;
		this.innerclasses = __icl;
		this.annotations = __at;
		this.interfaces = new ClassNames(__in);
		this._fields = __fs;
		this._methods = __ms;
		this.sourcefilename = __sfn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the fields within this class.
	 *
	 * @return The class fields.
	 * @since 2017/10/12
	 */
	public final List<Field> fields()
	{
		return UnmodifiableArrayList.<Field>of(this._fields);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public final ClassFlags flags()
	{
		return this.classflags;
	}
	
	/**
	 * Returns the inner classes.
	 *
	 * @return The inner classes.
	 * @since 2018/06/16
	 */
	public final InnerClasses innerClasses()
	{
		return this.innerclasses;
	}
	
	/**
	 * Returns the names of implemented interfaces.
	 *
	 * @return The implemented interface names.
	 * @since 2017/10/09
	 */
	public final ClassNames interfaceNames()
	{
		return this.interfaces;
	}
	
	/**
	 * Methods which exist within this class.
	 *
	 * @return The class methods.
	 * @since 2017/10/09
	 */
	public final Method[] methods()
	{
		return this._methods.clone();
	}
	
	/**
	 * Returns the source file the class is in.
	 *
	 * @return The source file the class is in or {@code null} if it is not
	 * in one.
	 * @since 2018/09/08
	 */
	public final String sourceFile()
	{
		return this.sourcefilename;
	}
	
	/**
	 * Returns the name of the super class.
	 *
	 * @return The name of the super class.
	 * @since 2017/10/09
	 */
	public final ClassName superName()
	{
		return this.supername;
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The current class name.
	 * @since 2017/10/02
	 */
	public final ClassName thisName()
	{
		return this.thisname;
	}
	
	/**
	 * Returns the type of class this is.
	 *
	 * @return The class type.
	 * @since 2018/05/14
	 */
	public final ClassType type()
	{
		ClassFlags flags = this.classflags;
		if (flags.isEnum())
			return ClassType.ENUM;
		else if (flags.isAnnotation())
			return ClassType.ANNOTATION;
		else if (flags.isInterface())
			return ClassType.INTERFACE;
		return ClassType.CLASS;
	}
	
	/**
	 * Returns the class version.
	 *
	 * @return The class version.
	 * @since 2019/04/14
	 */
	public final ClassVersion version()
	{
		return this.version;
	}
	
	/**
	 * Initializes a class file which is a special representation of the
	 * following field descriptor which is either an array or a primitive
	 * type.
	 *
	 * @param __d The descriptor to create a special class for.
	 * @return The generated class file from the specified descriptor.
	 * @throws IllegalArgumentException If the descriptor is not an array
	 * or a pritimive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	public static ClassFile special(FieldDescriptor __d)
		throws IllegalArgumentException, NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2a Cannot create a special class because it
		// is not an array or primitive type. (The descriptor)}
		if (!__d.isArray() && !__d.isPrimitive())
			throw new IllegalArgumentException(String.format("JC2a %s", __d));
		
		// Pre-composed parts to fake things
		ClassFlags cflags = new ClassFlags(ClassFlag.PUBLIC, ClassFlag.FINAL,
			ClassFlag.SUPER, ClassFlag.SYNTHETIC);
		Method[] methods = new Method[0];
		
		// Use the names of the types in the language
		ClassName name;
		boolean isprimitive;
		if ((isprimitive = __d.isPrimitive()))
			name = ClassName.fromPrimitiveType(__d.primitiveType());
		
		// Treat array as normal class name
		else
		{
			name = __d.className();
			
			// Create fake constant pool
			Pool fakepool = new Pool(
					null,
					new MethodReference(
						new ClassName("java/lang/Object"),
						new MethodName("clone"),
						new MethodDescriptor("()Ljava/lang/Object;"), false));
			
			// Faked Code attribute for the clone method
			byte[] fakeattr;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
				DataOutputStream dos = new DataOutputStream(baos))
			{
				// Max stack
				dos.writeShort(1);
				
				// Max locals
				dos.writeShort(1);
				
				// Code length
				dos.writeInt(5);
				
				// ALOAD_0
				dos.writeByte(0x2A);
				
				// INVOKESPECIAL : Object.clone()
				dos.writeByte(0xB7);
				dos.writeShort(1);
				
				// ARETURN
				dos.writeByte(0xB0);
				
				// No exceptions
				dos.writeShort(0);
				
				// No attributes
				dos.writeShort(0);
				
				// Build
				fakeattr = baos.toByteArray();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
			
			// Need to make virtual method called clone
			methods = new Method[]
				{
					new Method(ClassVersion.CLDC_8, cflags, __d.className(),
						fakepool, new MethodFlags(0x1001),
						new MethodName("clone"),
						new MethodDescriptor("()Ljava/lang/Object;"),
						fakeattr, new AnnotationTable()),
				};
		}
		
		// Build
		return new ClassFile(ClassVersion.MAX_VERSION, cflags, name,
			(isprimitive ? null : new ClassName("java/lang/Object")),
			new ClassName[0], new Field[0], methods, new InnerClasses(),
			new AnnotationTable(), "<special>");
	}
	
	/**
	 * This parses the input stream as a class file and returns the
	 * representation of that class file.
	 *
	 * @param __is The input stream to source classes from.
	 * @return The decoded class file.
	 * @throws InvalidClassFormatException If the class file is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/26
	 */
	public static ClassFile decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2b The magic number for the class is not
		// valid. (The read magic number; The expected magic number)}
		DataInputStream in = new DataInputStream(__is);
		int magic = in.readInt();
		if (magic != ClassFile._MAGIC_NUMBER)
			throw new InvalidClassFormatException(String.format(
				"JC2b %08x %08x", magic, ClassFile._MAGIC_NUMBER));
		
		// {@squirreljme.error JC2c The version number of the input class
		// file is not valid. (The version number)}
		int cver = in.readShort() | (in.readShort() << 16);
		ClassVersion version = ClassVersion.findVersion(cver);
		if (version == null)
			throw new InvalidClassFormatException(String.format("JC2c %d.%d",
				cver >>> 16, (cver & 0xFFFF)));
		
		// Decode the constant pool
		Pool pool = Pool.decode(in);
		
		// Decode flags
		ClassFlags classflags = new ClassFlags(in.readUnsignedShort());
		
		// Name of the current class
		ClassName thisname = pool.<ClassName>require(ClassName.class,
			in.readUnsignedShort());
		
		// Read super class
		ClassName supername = pool.<ClassName>get(ClassName.class,
			in.readUnsignedShort());
		
		// Read interfaces
		int icount = in.readUnsignedShort();
		ClassName[] interfaces = new ClassName[icount];
		for (int i = 0; i < icount; i++)
			interfaces[i] = pool.<ClassName>require(ClassName.class,
				in.readUnsignedShort());
		
		// Read fields
		Field[] fields = Field.decode(version, thisname, classflags, pool, in);
		
		// Read methods
		Method[] methods = Method.decode(version, thisname, classflags, pool,
			in);
		
		// Read in attributes
		AttributeTable attrs = AttributeTable.parse(pool, in);
		
		// Read annotation table, if it is valid and exists
		AnnotationTable annotations = AnnotationTable.parse(pool, attrs);
		
		// Parse inner classes
		InnerClasses innerclasses = InnerClasses.parse(pool, attrs);
		
		// {@squirreljme.error JC2d Expected end of the class to follow the
		// attributes in the class. (The name of this class)}
		if (in.read() >= 0)
			throw new InvalidClassFormatException(
				String.format("JC2d %s", thisname));
		
		// Source file name, if any
		Attribute attr = attrs.get("SourceFile");
		String sourcefilename = null;
		if (attr != null)
			try (DataInputStream ai = attr.open())
			{
				sourcefilename = pool.<UTFConstantEntry>require(
					UTFConstantEntry.class, ai.readUnsignedShort()).toString();
			}
		
		// Build
		return new ClassFile(version, classflags, thisname, supername,
			interfaces, fields, methods, innerclasses, annotations,
			sourcefilename);
	}
	
	/**
	 * Reads the next attribute from the class.
	 *
	 * @param __in The input stream where bytes come from.
	 * @param __pool The constant pool.
	 * @param __aname The output name of the attribute which was just read.
	 * @param __alens The length of the attribute.
	 * @return The stream to the attribute which just has been read.
	 * @throws IOException On read errors.
	 * @throws InvalidClassFormatException If the attribute is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/04/09
	 */
	@Deprecated
	static DataInputStream __nextAttribute(DataInputStream __in,
		Pool __pool, String[] __aname, int[] __alens)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__aname == null || __alens == null)
			throw new NullPointerException("NARG");
		
		// The name is not parsed here
		__aname[0] = __pool.<UTFConstantEntry>require(UTFConstantEntry.class,
			__in.readUnsignedShort()).toString();
		
		// {@squirreljme.error JC2e Attribute exceeds 2GiB in length. (The
		// size of the attribute)}
		int len = __in.readInt();
		if (len < 0)
			throw new InvalidClassFormatException(String.format("JC2e %d",
				len & 0xFFFFFFFFL));
		
		// Used as a hint
		__alens[0] = len;
		
		// Setup reader
		return new DataInputStream(new SizeLimitedInputStream(__in, len, true,
			false));
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ClassFlag.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
66
67
68
69
70
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which modify how a class is accessed and is behaved.
 *
 * @since 2016/04/23
 */
public enum ClassFlag
	implements Flag
{
	/** Public access. */
	PUBLIC,
	
	/** Final. */
	FINAL,
	
	/** Super. */
	SUPER,
	
	/** Interface. */
	INTERFACE,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Synthetic. */
	SYNTHETIC,
	
	/** Annotation. */
	ANNOTATION,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/13
	 */
	@Override
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case FINAL:			return 0x0010;
			case SUPER:			return 0x0020;
			case INTERFACE:		return 0x0200;
			case ABSTRACT:		return 0x0400;
			case SYNTHETIC:		return 0x1000;
			case ANNOTATION:	return 0x2000;
			case ENUM:			return 0x4000;
			default:
				throw new todo.OOPS();
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ClassFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the flags which a class may be.
 *
 * @since 2016/04/23
 */
public class ClassFlags
	extends Flags<ClassFlag>
	implements AccessibleFlags
{
	/**
	 * Initializes the class flags decoding from the specified bit field.
	 *
	 * @param __i The bit field to decode flags from.
	 * @since 2017/06/13
	 */
	public ClassFlags(int __i)
	{
		this(Flags.<ClassFlag>__decode(__i, ClassFlag.values()));
	}
	
	/**
	 * Initializes the class flags.
	 *
	 * @param __fl The class flags.
	 * @since 2016/04/23
	 */
	public ClassFlags(ClassFlag... __fl)
	{
		super(ClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Initializes the class flags.
	 *
	 * @param __fl The class flags.
	 * @since 2016/04/23
	 */
	public ClassFlags(Iterable<ClassFlag> __fl)
	{
		super(ClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Is this class abstract?
	 *
	 * @return {@code true} if it is abstract.
	 * @since 2016/03/15
	 */
	public final boolean isAbstract()
	{
		return this.contains(ClassFlag.ABSTRACT);
	}
	
	/**
	 * Is this an annotation?
	 *
	 * @return {@code true} if it is an annotation.
	 * @since 2016/03/15
	 */
	public final boolean isAnnotation()
	{
		return this.contains(ClassFlag.ANNOTATION);
	}
	
	/**
	 * Is this an enumeration?
	 *
	 * @return {@code true} if it is an enumeration.
	 * @since 2016/03/15
	 */
	public final boolean isEnum()
	{
		return this.contains(ClassFlag.ENUM);
	}
	
	/**
	 * Is this class final?
	 *
	 * @return {@code true} if it is final.
	 * @since 2016/03/15
	 */
	public final boolean isFinal()
	{
		return this.contains(ClassFlag.FINAL);
	}
	
	/**
	 * Is this an interface?
	 *
	 * @return {@code true} if an interface.
	 * @since 2016/03/15
	 */
	public final boolean isInterface()
	{
		return this.contains(ClassFlag.INTERFACE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/15
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !this.isPublic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public final boolean isPrivate()
	{
		// Classes are never private
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public final boolean isProtected()
	{
		// Classes are never protected
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/15
	 */
	@Override
	public final boolean isPublic()
	{
		return this.contains(ClassFlag.PUBLIC);
	}
	
	/**
	 * Is there special handling for super-class method calls?
	 *
	 * @return {@code true} if the super-class invocation special flag is set.
	 * @since 2016/03/15
	 */
	public final boolean isSpecialInvokeSpecial()
	{
		return this.contains(ClassFlag.SUPER);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @throws InvalidClassFormatException If they are not valid.
	 * @since 2016/04/23
	 */
	private final void __checkFlags()
		throws InvalidClassFormatException
	{
		// Interface?
		if (this.isInterface())
		{
			// {@squirreljme.error JC2f An interface must also be abstract.
			// (The class flags)}
			if (!this.isAbstract())
				throw new InvalidClassFormatException(
					String.format("JC2f %s", this));
			
			// {@squirreljme.error JC2g An interface cannot be {@code final} or
			// {@code enum} and it must not have the special flag set. (The
			// class flags)}
			if (this.isFinal() || this.isSpecialInvokeSpecial() || this.isEnum())
				throw new InvalidClassFormatException(
					String.format("JC2g %s", this));
		}
		
		// Normal class
		else
		{
			// {@squirreljme.error JC2h Annotations must be interfaces. (The
			// class flags)}
			if (this.isAnnotation())
				throw new InvalidClassFormatException(
					String.format("JC2h %s", this));
				
			// {@squirreljme.error JC2i A class cannot be both {@code abstract}
			// and {@code final}. (The class flags)}
			if (this.isAbstract() && this.isFinal())
				throw new InvalidClassFormatException(
					String.format("JC2i %s", this));
		}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This is used to identify the fragment of a class or package.
 *
 * @since 2017/09/27
 */
public final class ClassIdentifier
	extends Identifier
	implements Comparable<ClassIdentifier>
{
	/**
	 * Initializes the class name.
	 *
	 * @param __s The class name.
	 * @since 2017/09/27
	 */
	public ClassIdentifier(String __s)
	{
		super(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/02
	 */
	@Override
	public int compareTo(ClassIdentifier __o)
	{
		return this.toString().compareTo(__o.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof ClassIdentifier) && super.equals(__o);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ClassName.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.Objects;

/**
 * This represents the name of a class or array within the virtual machine.
 *
 * This class is immutable.
 *
 * @since 2017/09/27
 */
public class ClassName
	implements Comparable<ClassName>
{
	/** The binary name of the class. */
	protected final BinaryName binary;
	
	/** The field type of the class (for arrays). */
	protected final FieldDescriptor field;
	
	/** Is this considered primitive? */
	protected final boolean isprimitive;
	
	/**
	 * Initializes the class name.
	 *
	 * @param __n The input string.
	 * @throws InvalidClassFormatException If it is not a valid class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public ClassName(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Is an array?
		if (__n.startsWith("["))
		{
			this.binary = null;
			this.field = new FieldDescriptor(__n);
			this.isprimitive = false;
		}
		
		// Not an array
		else
		{
			this.binary = new BinaryName(__n);
			this.field = null;
			
			// Consider this a primitive type
			switch (__n)
			{
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
				case "long":
				case "float":
				case "double":
					this.isprimitive = true;
					break;
				
				default:
					this.isprimitive = false;
			}
		}
	}
	
	/**
	 * Adds dimensions to the class.
	 *
	 * @param __d The number of dimensions to add.
	 * @return The class with added dimensions.
	 * @throws IllegalArgumentException If the dimensions are negative.
	 * @since 2018/09/15
	 */
	public final ClassName addDimensions(int __d)
		throws IllegalArgumentException
	{
		if (__d == 0)
			return this;
		
		// {@squirreljme.error JC2j Cannot add negative dimensions.}
		if (__d < 0)
			throw new IllegalArgumentException("JC2j");
		
		// Going to be the same here but as a class name instead
		return this.field().addDimensions(__d).className();
	}
	
	/**
	 * Returns the binary name for this class.
	 *
	 * @return The class binary name or {@code null} if this is an array or
	 * primitive type.
	 * @since 2018/03/06
	 */
	public BinaryName binaryName()
	{
		return this.binary;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int compareTo(ClassName __o)
	{
		BinaryName ab = this.binary;
		if (ab != null)
		{
			BinaryName bb = __o.binary;
			if (bb == null)
				return -1;
			return ab.compareTo(bb);
		}
		
		FieldDescriptor af = this.field,
			bf = __o.field;
		if (bf == null)
			return 1;
		return af.compareTo(bf);
	}
	
	/**
	 * Returns the component type of this class name.
	 *
	 * @return The component type.
	 * @throws IllegalStateException If this is not an array.
	 * @since 2018/09/27
	 */
	public final ClassName componentType()
		throws IllegalStateException
	{
		// {@squirreljme.error JC2k This class is not an array, cannot get
		// the component type. (The name of this class)}
		if (!this.isArray())
			throw new IllegalStateException(String.format("JC2k %s", this));
		
		return this.field().componentType().className();
	}
	
	/**
	 * Returns the number of array dimensions that are used.
	 *
	 * @return The array dimensions.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		if (!this.isArray())
			return 0;
		return this.field().dimensions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof ClassName))
			return false;
		
		ClassName o = (ClassName)__o;
		return Objects.equals(this.binary, o.binary) &&
			Objects.equals(this.field, o.field);
	}
	
	/**
	 * Returns the field descriptor for this class.
	 *
	 * @return The class field descriptor.
	 * @since 2017/10/10
	 */
	public FieldDescriptor field()
	{
		// If this is a primitive type, treat as one
		BinaryName binary = this.binary;
		if (this.isprimitive)
			switch (binary.toString())
			{
				case "boolean":		return new FieldDescriptor("Z");
				case "byte":		return new FieldDescriptor("B");
				case "short":		return new FieldDescriptor("S");
				case "char":		return new FieldDescriptor("C");
				case "int":			return new FieldDescriptor("I");
				case "long":		return new FieldDescriptor("J");
				case "float":		return new FieldDescriptor("F");
				case "double":		return new FieldDescriptor("D");
				default:
					throw new RuntimeException("TODO");
			}
		
		// If just a binary name, convert
		if (binary != null)
			return new FieldDescriptor("L" + binary + ";");
		return this.field;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int hashCode()
	{
		BinaryName ab = this.binary;
		return (ab != null ? ab.hashCode() : this.field.hashCode());
	}
	
	/**
	 * Returns the package that this class is within. Primitive types and
	 * arrays are not part of any package.
	 *
	 * @return The package or {@code null} if it is not in the package.
	 * @since 2017/10/09
	 */
	public BinaryName inPackage()
	{
		BinaryName b = this.binary;
		if (b != null)
			return b.inPackage();
		return null;
	}
	
	/**
	 * Does this class refer to an array type?
	 *
	 * @return If this is an array type.
	 * @since 2017/10/08
	 */
	public boolean isArray()
	{
		FieldDescriptor field = this.field;
		return field != null && field.isArray();
	}
	
	/**
	 * Is the other class in the same package as this class?
	 *
	 * @param __b The other class to check.
	 * @return If the other class is in this same package.
	 * @since 2017/10/11
	 */
	public boolean isInSamePackage(ClassName __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return Objects.equals(this.inPackage(), __b.inPackage());
	}
	
	/**
	 * Does this class refer to a primitive type?
	 *
	 * @return If this is a primitive type.
	 * @since 2017/10/08
	 */
	public boolean isPrimitive()
	{
		FieldDescriptor field = this.field;
		return this.isprimitive || field != null && field.isPrimitive();
	}
	
	/**
	 * Returns the primitive type of this class, if there is one.
	 *
	 * @return The primitive type or {@code null} if it is not one.
	 * @since 2018/09/16
	 */
	public final PrimitiveType primitiveType()
	{
		if (!this.isPrimitive())
			return null;
		
		switch (this.binary.toString())
		{
			case "boolean":		return PrimitiveType.BOOLEAN;
			case "byte":		return PrimitiveType.BYTE;
			case "short":		return PrimitiveType.SHORT;
			case "char":		return PrimitiveType.CHARACTER;
			case "int":			return PrimitiveType.INTEGER;
			case "long":		return PrimitiveType.LONG;
			case "float":		return PrimitiveType.FLOAT;
			case "double":		return PrimitiveType.DOUBLE;
			default:
				throw new RuntimeException("TODO");
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public String toString()
	{
		BinaryName binary = this.binary;
		if (binary != null)
			return binary.toString();
		return this.field.toString();
	}
	
	/**
	 * Translates the primitive type to the given class type.
	 *
	 * @param __t The type to convert.
	 * @return The name of the class for this primitive.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public static final ClassName fromPrimitiveType(PrimitiveType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Depends on the primitive type
		switch (__t)
		{
			case BOOLEAN:
				return new ClassName("boolean");
			
			case BYTE:
				return new ClassName("byte");
			
			case SHORT:
				return new ClassName("short");
			
			case CHARACTER:
				return new ClassName("char");
			
			case INTEGER:
				return new ClassName("int");
			
			case LONG:
				return new ClassName("long");
			
			case FLOAT:
				return new ClassName("float");
			
			case DOUBLE:
				return new ClassName("double");
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Checks if this class name is valid or not.
	 *
	 * @param __cn The class-name to check.
	 * @return If it is valid or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public static final boolean isValidClassName(String __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		try
		{
			ClassName cn = new ClassName(__cn);
			return true;
		}
		catch (InvalidClassFormatException e)
		{
			return false;
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ClassNames.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractList;
import java.util.RandomAccess;

/**
 * Represents multiple class names.
 *
 * @since 2019/04/14
 */
public final class ClassNames
	extends AbstractList<ClassName>
	implements RandomAccess
{
	/** Names. */
	private final ClassName[] _names;
	
	/** Hash code. */
	private int _hash;
	
	/** String. */
	private Reference<String> _string;
	
	/**
	 * Initializes the class names.
	 *
	 * @param __n The names.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public ClassNames(ClassName... __n)
		throws NullPointerException
	{
		for (ClassName n : (__n =
			(__n == null ? new ClassName[0] : __n.clone())))
			if (n == null)
				throw new NullPointerException("NARG");
			
		this._names = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = super.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final ClassName get(int __i)
	{
		return this._names[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int size()
	{
		return this._names.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public ClassName[] toArray()
	{
		return this._names.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = super.toString()));
		
		return rv;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Returns the type of class this is.
 *
 * @since 2018/05/14
 */
public enum ClassType
{
	/** Normal class. */
	CLASS,
	
	/** Interface. */
	INTERFACE,
	
	/** Enumeration. */
	ENUM,
	
	/** Annotation. */
	ANNOTATION,
	
	/** End. */
	;
}

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

package net.multiphasicapps.classfile;

/**
 * This represents the class verion that a class may be.
 *
 * @since 2016/06/29
 */
public enum ClassVersion
{
	/** CLDC 1.0 (JSR 30). */
	CLDC_1((45 << 16) + 3, (47 << 16) - 1, false, false, false),
	
	/** CLDC 1.1 (JSR 139). */
	CLDC_1_1((47 << 16), (51 << 16) - 1, true, false, false),
	
	/** CLDC 8 (aka Java 7). */
	CLDC_8((51 << 16), (52 << 16), true, false, true),
	
	/** End. */
	;
	
	/** The minimum supported version. */
	public static final ClassVersion MIN_VERSION = ClassVersion.CLDC_1;
	
	/** The maximum supported version. */
	public static final ClassVersion MAX_VERSION = ClassVersion.CLDC_8;
	
	/** The version ID. */
	protected final int version;
	
	/** The maximum range of the version. */
	protected final int maxversion;
	
	/** Has floating point support? */
	protected final boolean hasfloat;
	
	/** Supports invokedynamic? */
	protected final boolean hasinvokedynamic;
	
	/** Use StackMapTable? */
	protected final boolean usestackmaptable;
	
	/**
	 * Initializes the version data.
	 *
	 * @param __vid The version ID.
	 * @param __vmx The max version identifier.
	 * @param __undef Is this version information undefined?
	 * @param __float Is floating point supported?
	 * @param __hasid Has invoke dynamic support?
	 * @param __usesmt Should the StackMapTable attribute be used?
	 * @since 2016/03/13
	 */
	ClassVersion(int __vid, int __vmx, boolean __float, boolean __hasid,
		boolean __usesmt)
	{
		// Set
		this.version = __vid;
		this.maxversion = __vmx;
		this.hasfloat = __float;
		this.hasinvokedynamic = __hasid;
		this.usestackmaptable = __usesmt;
	}
	
	/**
	 * Returns {@code true} if floating point is supported by the virtual
	 * machine.
	 *
	 * @return {@code true} if it is.
	 * @since 2016/03/13
	 */
	public boolean hasFloatingPoint()
	{
		return this.hasfloat;
	}
	
	/**
	 * Returns {@code true} if invokedynamic is supported by the virtual
	 * machine.
	 *
	 * @return {@code true} if it is.
	 * @since 2016/03/15
	 */
	public boolean hasInvokeDynamic()
	{
		return this.hasinvokedynamic;
	}
	
	/**
	 * Should the new StackMapTable attribute be used when veryifying the byte
	 * code of a class?
	 *
	 * @return {@code true} if the "StackMapTable" attribute should be parsed
	 * instead of "StackMap".
	 * @since 2016/03/20
	 */
	public boolean useStackMapTable()
	{
		return this.usestackmaptable;
	}
	
	/**
	 * Finds the best matching version with the given ID.
	 *
	 * @param __vid The version ID to get a match for.
	 * @return The matching class version or {@code null} if not found.
	 * @since 2016/03/13
	 */
	public static ClassVersion findVersion(int __vid)
	{
		// Go through all versions, find the best
		ClassVersion best = null;
		for (ClassVersion v : ClassVersion.values())
			if (__vid >= v.version && __vid <= v.maxversion)
				if (best == null || v.version > best.version)
					best = v;
		
		// Use the best (if any)
		return best;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents a constant value.
 *
 * @since 2018/05/16
 */
public abstract class ConstantValue
{
	/** The represented object. */
	protected final Object value;
	
	/** The value type. */
	protected final ConstantValueType type;
	
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @param __t The value type.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValue(Object __v, ConstantValueType __t)
		throws NullPointerException
	{
		if (__v == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
		this.type = __t;
	}
	
	/**
	 * Returns the value of the constant as a boxed object.
	 *
	 * @return The constant value in a boxed type.
	 * @since 2018/09/08
	 */
	public final Object boxedValue()
	{
		return this.value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ConstantValue))
			return false;
		
		ConstantValue o = (ConstantValue)__o;
		return this.value.equals(o.value) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final int hashCode()
	{
		return this.value.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final String toString()
	{
		return this.value.toString();
	}
	
	/**
	 * The type of value which is contained here.
	 *
	 * @return The constant value type.
	 * @since 2018/05/16
	 */
	public final ConstantValueType type()
	{
		return this.type;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents a constant value which is of a class.
 *
 * @since 2018/09/19
 */
public final class ConstantValueClass
	extends ConstantValue
{
	/**
	 * Initializes the class constant value.
	 *
	 * @param __cn The class constant.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	public ConstantValueClass(ClassName __cn)
		throws NullPointerException
	{
		super(__cn, ConstantValueType.CLASS);
	}
	
	/**
	 * Returns the class name.
	 *
	 * @return The class name.
	 * @since 2018/09/19
	 */
	public final ClassName className()
	{
		return (ClassName)this.value;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Represents a double constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueDouble
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueDouble(double __v)
	{
		super(__v, ConstantValueType.DOUBLE);
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Represents a float constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueFloat
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueFloat(float __v)
	{
		super(__v, ConstantValueType.FLOAT);
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Represents a constant integer value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueInteger
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueInteger(int __v)
	{
		super(__v, ConstantValueType.INTEGER);
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Represents a long constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueLong
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueLong(long __v)
	{
		super(__v, ConstantValueType.LONG);
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents a constant value which is a number.
 *
 * @since 2018/05/21
 */
public abstract class ConstantValueNumber
	extends ConstantValue
{
	/** The number used. */
	protected final Number value;
	
	/**
	 * Initializes the constant value that uses a number.
	 *
	 * @param __v The value.
	 * @param __t The type of value used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValueNumber(Number __v, ConstantValueType __t)
		throws NullPointerException
	{
		super(__v, __t);
		
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * Returns the double value.
	 *
	 * @return The double value.
	 * @since 2018/05/16
	 */
	public final double doubleValue()
	{
		return this.value.doubleValue();
	}
	
	/**
	 * Returns the float value.
	 *
	 * @return The float value.
	 * @since 2018/05/16
	 */
	public final float floatValue()
	{
		return this.value.floatValue();
	}
	
	/**
	 * Returns the integer value.
	 *
	 * @return The integer value.
	 * @since 2018/05/16
	 */
	public final int intValue()
	{
		return this.value.intValue();
	}
	
	/**
	 * Returns the long value.
	 *
	 * @return The long value.
	 * @since 2018/05/16
	 */
	public final long longValue()
	{
		return this.value.longValue();
	}
	
	/**
	 * Returns the value as a number.
	 *
	 * @return The number used.
	 * @since 2018/05/21
	 */
	public final Number number()
	{
		return this.value;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ConstantValueString.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a string constant value.
 *
 * @since 2018/05/21
 */
public class ConstantValueString
	extends ConstantValue
	implements CharSequence
{
	/** The used string. */
	protected final String value;
	
	/**
	 * Initializes the value.
	 *
	 * @param __s The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValueString(String __s)
		throws NullPointerException
	{
		super(__s, ConstantValueType.STRING);
		
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.value = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final char charAt(int __i)
	{
		return this.value.charAt(__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final int length()
	{
		return this.value.length();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final CharSequence subSequence(int __s, int __e)
	{
		// So the same class type is returned
		return new ConstantValueString(this.value.substring(__s, __e));
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This indicates the type that a constant value is.
 *
 * @since 2018/05/16
 */
public enum ConstantValueType
{
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** String. */
	STRING,
	
	/** Class. */
	CLASS,
	
	/** End. */
	;
	
	/**
	 * Checks if this value is compatible with the given field descriptor.
	 *
	 * @param __d The descriptor to check.
	 * @return If it is compatible.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public final boolean isCompatibleWith(FieldDescriptor __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		switch (this)
		{
			case INTEGER:
				if (!__d.isPrimitive())
					return false;
				switch (__d.primitiveType())
				{
					case BOOLEAN:
					case BYTE:
					case SHORT:
					case CHARACTER:
					case INTEGER:
						return true;
						
					default:
						return false;
				}
			
			case LONG:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.LONG);
			
			case FLOAT:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.FLOAT);
			
			case DOUBLE:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.DOUBLE);
			
			case STRING:
				return __d.isObject() &&
					"Ljava/lang/String;".equals(__d.toString()); 
			
			case CLASS:
				return __d.isObject() &&
					"Ljava/lang/Class;".equals(__d.toString());
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is this a narrow constant value?
	 *
	 * @return If this is a narrow constant value.
	 * @since 2108/09/08
	 */
	public final boolean isNarrow()
	{
		switch (this)
		{
			case INTEGER:
			case FLOAT:
			case STRING:
			case CLASS:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a wide constant value?
	 *
	 * @return If this is a wide constant value.
	 * @since 2108/09/08
	 */
	public final boolean isWide()
	{
		switch (this)
		{
			case LONG:
			case DOUBLE:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the Java type for the constant value.
	 *
	 * @return The Java type that is used.
	 * @since 2019/03/17
	 */
	public final JavaType javaType()
	{
		switch (this)
		{
			case INTEGER:	return JavaType.INTEGER;
			case LONG:		return JavaType.LONG;
			case FLOAT:		return JavaType.FLOAT;
			case DOUBLE:	return JavaType.DOUBLE;
			case STRING:	return new JavaType(new FieldDescriptor(
				"Ljava/lang/String;"));
			case CLASS:		return new JavaType(new FieldDescriptor(
				"Ljava/lang/Class;"));
			
			default:
				throw new todo.OOPS();
		}
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single exception handler.
 *
 * @since 2017/02/09
 */
public final class ExceptionHandler
{
	/** The start address. */
	protected final int startpc;
	
	/** The end address. */
	protected final int endpc;
	
	/** The handler address. */
	protected final int handlerpc;
	
	/** The class type to handle. */
	protected final ClassName type;
	
	/** The string representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the exception handler.
	 *
	 * @param __spc The start address.
	 * @param __epc The end address.
	 * @param __hpc The handler address.
	 * @param __cn The class to be handled.
	 * @throws InvalidClassFormatException If the addresses are not valid.
	 * @since 2017/02/09
	 */
	ExceptionHandler(int __spc, int __epc, int __hpc, ClassName __cn)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC2l An address is negative. (The start address;
		// The end address; The handler address)}
		if (__spc < 0 || __epc < 0 || __hpc < 0)
			throw new InvalidClassFormatException(
				String.format("JC2l %d %d %d", __spc, __epc, __hpc));
		
		// {@squirreljme.error JC2m The end address is at or before the start
		// address. (The start address; The end address)}
		if (__epc <= __spc)
			throw new InvalidClassFormatException(String.format("JC2m %d %d",
				__spc, __epc));
		
		// Set
		this.startpc = __spc;
		this.endpc = __epc;
		this.handlerpc = __hpc;
		this.type = (__cn == null ? new ClassName("java/lang/Throwable") :
			__cn);
	}
	
	/**
	 * Returns the end address.
	 *
	 * @return The end address.
	 * @since 2017/02/09
	 */
	public int endAddress()
	{
		return this.endpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof ExceptionHandler))
			return false;
		
		if (__o == this)
			return true;
		
		// Compare
		ExceptionHandler o = (ExceptionHandler)__o;
		return this.startpc == o.startpc &&
			this.endpc == o.endpc &&
			this.handlerpc == o.handlerpc &&
			Objects.equals(this.type, o.type);
	}
	
	/**
	 * Returns the handler address.
	 *
	 * @return The handler address.
	 * @since 2017/02/09
	 */
	public int handlerAddress()
	{
		return this.handlerpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public int hashCode()
	{
		return this.startpc ^ this.endpc ^ this.handlerpc ^
			Objects.hashCode(this.type);
	}
	
	/**
	 * Checks whether the address is in range of this exception handler, that
	 * it there is a handler for this instruction.
	 *
	 * @param __i The address to check.
	 * @return {@code true} if the address is in range.
	 * @since 2017/04/01
	 */
	public boolean inRange(int __i)
	{
		return __i >= this.startpc && __i < this.endpc;
	}
	
	/**
	 * Returns the range of this exception handler.
	 *
	 * @return The exception handler range.
	 * @since 2019/03/21
	 */
	public final InstructionAddressRange range()
	{
		return new InstructionAddressRange(this.startpc, this.endpc);
	}
	
	/**
	 * Returns the start address.
	 *
	 * @return The start address.
	 * @since 2017/02/09
	 */
	public int startAddress()
	{
		return this.startpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"{%d-%d > %d (%s)}", this.startpc, this.endpc, this.handlerpc,
				this.type)));
		
		return rv;
	}
	
	/**
	 * Returns the type of exception to handle.
	 *
	 * @return The type of exception to handle.
	 * @since 2017/02/09
	 */
	public ClassName type()
	{
		return this.type;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/ExceptionHandlerTable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This represents a every exception that exists within a method.
 *
 * @since 2017/02/09
 */
public final class ExceptionHandlerTable
	implements Iterable<ExceptionHandler>
{
	/** The exception handler table. */
	private final ExceptionHandler[] _table;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the exception handler table.
	 *
	 * @param __t The entries to handle.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	ExceptionHandlerTable(ExceptionHandler... __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Clone entries
		__t = __t.clone();
		for (ExceptionHandler e : __t)
			if (e == null)
				throw new NullPointerException("NARG");
		
		// Set
		this._table = __t;
	}
	
	/**
	 * Initializes the exception handler table.
	 *
	 * @param __t The entries to handle.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	ExceptionHandlerTable(Collection<ExceptionHandler> __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Copy array
		ExceptionHandler[] t = __t.<ExceptionHandler>toArray(
			new ExceptionHandler[__t.size()]);
		for (ExceptionHandler e : t)
			if (e == null)
				throw new NullPointerException("NARG");
		
		this._table = t;
	}
	
	/**
	 * Return all of the exception handlers which apply to the given address.
	 *
	 * @param __pc The address to use.
	 * @return An array containing the exceptions which handle for the given
	 * address.
	 * @since 2018/10/13
	 */
	public final ExceptionHandler[] at(int __pc)
	{
		List<ExceptionHandler> rv = new ArrayList<>();
		
		// Add any handlers which are in range
		for (ExceptionHandler e : this._table)
			if (e.inRange(__pc))
				rv.add(e);
		
		return rv.<ExceptionHandler>toArray(new ExceptionHandler[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ExceptionHandlerTable))
			return false;
		
		// The exception handler table has a strict order
		return Arrays.equals(this._table, ((ExceptionHandlerTable)__o)._table);
	}
	
	/**
	 * Returns the exception handler at the given index.
	 *
	 * @return The exception handler at the given index.
	 * @since 2017/02/09
	 */
	public final ExceptionHandler get(int __i)
	{
		return this._table[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int hashCode()
	{
		// Just add up all of the entries quickly
		int rv = 0;
		for (ExceptionHandler e : this._table)
			rv += e.hashCode();
		return rv;
	}
	
	/**
	 * Is this exception table empty?
	 *
	 * @return If the table is empty.
	 * @since 2019/03/22
	 */
	public final boolean isEmpty()
	{
		return this._table.length == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final Iterator<ExceptionHandler> iterator()
	{
		return UnmodifiableIterator.<ExceptionHandler>of(this._table);
	}
	
	/**
	 * Returns a map of all the ranges that exist within the exception table
	 * that are unique to each other.
	 *
	 * @return A mapping of ranges and table entries.
	 * @since 2019/03/21
	 */
	public final Map<InstructionAddressRange, ExceptionHandlerTable>
		mappedUniqueRanges()
	{
		Map<InstructionAddressRange, ExceptionHandlerTable> rv =
			new LinkedHashMap<>();
		
		// Start of range
		int rangestart = 0;
		ExceptionHandlerTable current = this.tableAt(0);
		
		// Go through all addresses in range
		// We include the end address because after that point there would
		// be no exception handlers after that point. This forces a range
		// to be specified where anything after this end point has no handlers
		int ma = this.maximumEndAddress();
		for (int i = 1; i <= ma; i++)
		{
			// Get table at this address
			ExceptionHandlerTable now = this.tableAt(i);
			
			// If the table is different, then a new range is used
			if (!current.equals(now))
			{
				// Store the range
				rv.put(new InstructionAddressRange(rangestart, i), current);
				
				// Set for next scan
				rangestart = i;
				current = now;
			}
		}
		
		// Always store the final range
		rv.put(new InstructionAddressRange(rangestart, ma), current);
		
		return rv;
	}
	
	/**
	 * Returns the maximum end address that is used in the table.
	 *
	 * @return The highest end address used in the table.
	 * @since 2019/03/21
	 */
	public final int maximumEndAddress()
	{
		int rv = 0;
		for (ExceptionHandler e : this._table)
		{
			int epc = e.endpc;
			if (epc > rv)
				rv = epc;
		}
		return rv;
	}
	
	/**
	 * Returns the maximum used start address in the table.
	 *
	 * @return The maximum start address.
	 * @since 2019/04/04
	 */
	public final int maximumStartAddress()
	{
		int rv = 0;
		for (ExceptionHandler e : this._table)
		{
			int spc = e.startpc;
			if (spc > rv)
				rv = spc;
		}
		return rv;
	}
	
	/**
	 * Returns the instruction range.
	 *
	 * @return The instruction range.
	 * @since 2019/03/21
	 */
	public final InstructionAddressRange range()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of exception handlers that exist.
	 *
	 * @return The total number of exception handlers.
	 * @since 2017/02/09
	 */
	public final int size()
	{
		return this._table.length;
	}
	
	/**
	 * Returns an exception handler table for the given address.
	 *
	 * @param __pc The address to get an exception handler table from.
	 * @return A table representing only the exceptions at a given address.
	 * @since 2019/03/21
	 */
	public final ExceptionHandlerTable tableAt(int __pc)
	{
		return new ExceptionHandlerTable(this.at(__pc));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Arrays.asList(this._table).toString()));
		
		return rv;
	}
	
	/**
	 * Parses the exception handler table.
	 *
	 * @param __is The input stream to read exceptions from.
	 * @param __pool The constant pool for class names.
	 * @param __len The length of the method in byte codes.
	 * @throws InvalidClassFormatException If the exception table is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	public static ExceptionHandlerTable decode(DataInputStream __is,
		Pool __pool, int __len)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__is == null || __pool == null)
			throw new NullPointerException("NARG");
		
		// Read exception table count
		int n = __is.readUnsignedShort();
		ExceptionHandler[] table = new ExceptionHandler[n];
		for (int i = 0; i < n; i++)
		{
			// Read values
			int spc = __is.readUnsignedShort();
			int epc = __is.readUnsignedShort();
			int hpc = __is.readUnsignedShort();
			ClassName type = __pool.<ClassName>get(ClassName.class,
				__is.readUnsignedShort());
			
			// {@squirreljme.error JC2n Address is outside of the bounds of the
			// method. (The start address; The end address; The handler
			// address; The code length)}
			if (spc >= __len || epc > __len || hpc >= __len)
				throw new InvalidClassFormatException(String.format(
					"JC2n %d %d %d %d", spc, epc, hpc, __len));
			
			// Setup exception
			table[i] = new ExceptionHandler(spc, epc, hpc, type);
		}
		
		// Setup
		return new ExceptionHandlerTable(table);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Field.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Set;

/**
 * This represents a field in a class which is used to store values either as
 * static instances or as instance variables outside of methods.
 *
 * @since 2017/09/30
 */
public final class Field
	extends Member
	implements Annotated, HasMemberFlags
{
	/** The flags for the field. */
	protected final FieldFlags flags;
	
	/** The name of the field. */
	protected final FieldName name;
	
	/** The descriptor of the field. */
	protected final FieldDescriptor type;
	
	/** The constant value, if there is none then this is {@code null}. */
	protected final ConstantValue constval;
	
	/** Annotated values. */
	protected final AnnotationTable annotations;
	
	/** Name and type reference. */
	private Reference<FieldNameAndType> _nameandtype;
	
	/**
	 * Initializes the field.
	 *
	 * @param __f The flags for the field.
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @param __cv The constant value of the field, may be {@code null}.
	 * @param __avs Annotated values.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws NullPointerException On null arguments, except for {@code __cv}.
	 * @since 2017/10/02
	 */
	public Field(FieldFlags __f, FieldName __n, FieldDescriptor __t,
		ConstantValue __cv, AnnotationTable __avs)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__f == null || __n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2o The constant value is not compatible with
		// the given field type. (The value; The value type; The field type)}
		if (__cv != null && !__cv.type().isCompatibleWith(__t))
			throw new InvalidClassFormatException(String.format(
				"JC2o %s %s %s", __cv, __cv.type(), __t));
		
		this.flags = __f;
		this.name = __n;
		this.type = __t;
		this.constval = __cv;
		this.annotations = (__avs == null ? new AnnotationTable() : __avs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the constant value of the field.
	 *
	 * @return The field constant value.
	 * @since 2018/05/14
	 */
	public final ConstantValue constantValue()
	{
		return this.constval;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public final FieldFlags flags()
	{
		return this.flags;
	}
	
	/**
	 * Returns the name of the field.
	 *
	 * @return The field name.
	 * @since 2018/05/14
	 */
	public final FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public final FieldNameAndType nameAndType()
	{
		Reference<FieldNameAndType> ref = this._nameandtype;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nameandtype = new WeakReference<>(
				rv = new FieldNameAndType(this.name, this.type));
		
		return rv;
	}
	
	/**
	 * Returns the field type.
	 *
	 * @return The field type.
	 * @since 2018/05/14
	 */
	public final FieldDescriptor type()
	{
		return this.type;
	}
	
	/**
	 * Decodes all fields from the input class data.
	 *
	 * @param __ver The version of the class.
	 * @param __tn The name of the owning class.
	 * @param __cf The flags for the owning class.
	 * @param __pool The constant pool for the class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/30
	 */
	public static Field[] decode(ClassVersion __ver, ClassName __tn,
		ClassFlags __cf, Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__ver == null || __tn == null || __cf == null || __pool == null ||
			__in == null)
			throw new NullPointerException("NARG");
		
		int nf = __in.readUnsignedShort();
		Field[] rv = new Field[nf];
		Set<NameAndType> dup = new HashSet<>();
		
		// Parse fields
		for (int i = 0; i < nf; i++)
		{
			FieldFlags flags = new FieldFlags(__cf, __in.readUnsignedShort());
			FieldName name = new FieldName(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			FieldDescriptor type = new FieldDescriptor(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// {@squirreljme.error JC2p A duplicate method exists within the
			// class. (The method name; The method descriptor)}
			if (!dup.add(new NameAndType(name.toString(), type.toString())))
				throw new InvalidClassFormatException(String.format(
					"JC2p %s %s", name, type));
			
			// Handle attributes
			AttributeTable attrs = AttributeTable.parse(__pool, __in);
			
			// Parse annotations
			AnnotationTable annotations = AnnotationTable.parse(__pool, attrs);
			
			// Parse constant value if there is one
			ConstantValue constval = null;
			Attribute cvalattr = attrs.get("ConstantValue");
			if (cvalattr != null)
				try (DataInputStream ai = cvalattr.open())
				{
					constval = __pool.<ConstantValue>require(
						ConstantValue.class, ai.readUnsignedShort());
				}
			
			// Create field
			rv[i] = new Field(flags, name, type, constval, annotations);
		}
		
		// All done!
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/FieldDescriptor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the type descriptor of a field.
 *
 * @since 2017/06/12
 */
public final class FieldDescriptor
	implements Comparable<FieldDescriptor>, MemberDescriptor
{
	/** The short type. */
	public static final FieldDescriptor SHORT =
		new FieldDescriptor("S");
	
	/** The integer type. */
	public static final FieldDescriptor INTEGER =
		new FieldDescriptor("I");
	
	/** String representation. */
	protected final String string;
	
	/** Is this a primitive type? */
	protected final boolean primitive;
	
	/** Array dimensions. */
	protected final int dimensions;
	
	/** The component type. */
	protected final FieldDescriptor component;
	
	/** The class this refers to. */
	protected final ClassName classname;
	
	/**
	 * Initializes the field descriptor.
	 *
	 * @param __n The field descriptor to decode.
	 * @throws InvalidClassFormatException If it is not a valid field descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public FieldDescriptor(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// {@squirreljme.error JC2q The field descriptor cannot be blank. (The
		// field descriptor)}
		int n = __n.length();
		if (n <= 0)
			throw new InvalidClassFormatException(
				String.format("JC2q %s", __n));
		
		// Depends on the first character
		char c = __n.charAt(0);
		switch (c)
		{
				// Primitive
			case 'B':
			case 'C':
			case 'D':
			case 'F':
			case 'I':
			case 'J':
			case 'S':
			case 'Z':
				this.primitive = true;
				this.dimensions = 0;
				this.component = null;
				this.classname = null;
				break;
			
				// Array
			case '[':
				this.primitive = false;
				this.classname = null;
				
				// Count dimensions
				int dims = 0;
				for (int i = 0; i < n; i++)
					if (__n.charAt(i) != '[')
						break;
					else
						dims++;
				this.dimensions = dims;
				
				// Parse component
				this.component = new FieldDescriptor(__n.substring(1));
				break;
				
				// Class
			case 'L':
				this.primitive = false;
				this.dimensions = 0;
				this.component = null;
				
				// {@squirreljme.error JC2r The field descriptor for a class
				// must end with a semicolon. (The field descriptor)}
				if (';' != __n.charAt(n - 1))
					throw new InvalidClassFormatException(
						String.format("JC2r %s", __n));
				
				// Decode
				this.classname = new ClassName(__n.substring(1, n - 1));
				break;
				
				// {@squirreljme.error JC2s The field descriptor is not valid.
				// (The field descriptor)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC2s %s", __n));
		}
	}
	
	/**
	 * Adds dimensions to the field descriptor.
	 *
	 * @param __d The number of dimensions to add.
	 * @return The field descriptor with added dimensions.
	 * @throws IllegalArgumentException If the dimensions are negative.
	 * @since 2018/09/15
	 */
	public final FieldDescriptor addDimensions(int __d)
		throws IllegalArgumentException
	{
		if (__d == 0)
			return this;
		
		// {@squirreljme.error JC2t Cannot add negative dimensions.}
		if (__d < 0)
			throw new IllegalArgumentException("JC2t");
		
		// Prepend string with brackets, to declare a new array
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < __d; i++)
			sb.append('[');
		
		// Rebuild field
		sb.append(this.toString());
		return new FieldDescriptor(sb.toString());
	}
	
	/**
	 * Returns the name of the used class.
	 *
	 * @return The used class or {@code null} if a class is not referred to and
	 * this is a primitive type.
	 * @since 2018/09/01
	 */
	public final ClassName className()
	{
		// If this is an array then the class name will be the array descriptor
		if (this.dimensions > 0)
			return new ClassName(this.toString());
		
		// Otherwise as normal class (or primitive representation)
		if (this.primitive)
			return ClassName.fromPrimitiveType(this.primitiveType());
		return this.classname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/02
	 */
	@Override
	public int compareTo(FieldDescriptor __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * Returns the component type of the array if this is one.
	 *
	 * @return The component type or {@code null} if this is not one.
	 * @since 2018/09/27
	 */
	public final FieldDescriptor componentType()
	{
		return this.component;
	}
	
	/**
	 * Returns the number of dimensions in this class.
	 *
	 * @return The number of dimensions in the class.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		return this.dimensions;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof FieldDescriptor))
			return false;
		
		return this.string.equals(((FieldDescriptor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Is this an array type?
	 *
	 * @return {@code true} if an array type.
	 * @since 2017/10/08
	 */
	public boolean isArray()
	{
		return this.component != null;
	}
	
	/**
	 * Is this a primitive type?
	 *
	 * @return {@code true} if this is a primitive type.
	 * @since 2017/07/28
	 */
	public boolean isPrimitive()
	{
		return this.primitive;
	}
	
	/**
	 * Is this an object type?
	 *
	 * @return If this is an object type.
	 * @since 2017/09/16
	 */
	public boolean isObject()
	{
		return !this.isPrimitive();
	}
	
	/**
	 * Returns if this is a wide field or not.
	 *
	 * @return If this is a wide field.
	 * @since 2019/02/05
	 */
	public final boolean isWide()
	{
		if (this.isObject())
			return false;
		switch (this.primitiveType())
		{
			case LONG:
			case DOUBLE:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the primitive type for this field.
	 *
	 * @return The primitive type to use or {@code null} if there is none.
	 * @since 2017/10/16
	 */
	public PrimitiveType primitiveType()
	{
		// Quick detect
		if (!this.primitive)
			return null;
		
		// Depends on the string
		switch (this.toString())
		{
			case "B": return PrimitiveType.BYTE;
			case "C": return PrimitiveType.CHARACTER;
			case "D": return PrimitiveType.DOUBLE;
			case "F": return PrimitiveType.FLOAT;
			case "I": return PrimitiveType.INTEGER;
			case "J": return PrimitiveType.LONG;
			case "S": return PrimitiveType.SHORT;
			case "Z": return PrimitiveType.BOOLEAN;
			default:
				return null;
		}
	}
	
	/**
	 * Returns the simple storage type of the field.
	 *
	 * @return The simple storage type for this field.
	 * @since 2018/09/15
	 */
	public final SimpleStorageType simpleStorageType()
	{
		// Objects
		if (this.isObject())
			return SimpleStorageType.OBJECT;
		
		// Primitive types, these are promoted
		switch (this.primitiveType())
		{
			case BOOLEAN:
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:
				return SimpleStorageType.INTEGER;
			
			case LONG:
				return SimpleStorageType.LONG;
			
			case FLOAT:
				return SimpleStorageType.FLOAT;
			
			case DOUBLE:
				return SimpleStorageType.DOUBLE;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the width of this field on the stack.
	 *
	 * @return The width of the field on the stack.
	 * @since 2019/02/05
	 */
	public final int stackWidth()
	{
		return (this.isWide() ? 2 : 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/FieldFlag.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
66
67
68
69
70
71
72
73
74
75
76
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which are associated with class fields.
 *
 * @since 2016/04/23
 */
public enum FieldFlag
	implements MemberFlag
{
	/** Public field. */
	PUBLIC,
	
	/** Private field. */
	PRIVATE,
	
	/** Protected field. */
	PROTECTED,
	
	/** Static field. */
	STATIC,
	
	/** Final field. */
	FINAL,
	
	/** Volatile field. */
	VOLATILE,
	
	/** Transient field. */
	TRANSIENT,
	
	/** Synthetic field. */
	SYNTHETIC,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * Returns the bit mask which is used for this flag.
	 *
	 * @return The bit mask used for the flag.
	 * @since 2017/07/07
	 */
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:	return 0x0001;
			case PRIVATE:	return 0x0002;
			case PROTECTED:	return 0x0004;
			case STATIC:	return 0x0008;
			case FINAL:		return 0x0010;
			case VOLATILE:	return 0x0040;
			case TRANSIENT:	return 0x0080;
			case SYNTHETIC:	return 0x1000;
			case ENUM:		return 0x4000;

			default:
				throw new todo.OOPS();
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/FieldFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represent the set of flags for fields.
 *
 * @since 2016/04/23
 */
public final class FieldFlags
	extends MemberFlags<FieldFlag>
	implements AccessibleFlags
{
	/**
	 * Decodes field flags from the bit field and performs no checking.
	 *
	 * @param __i The bitfield to decode.
	 * @since 2019/04/18
	 */
	public FieldFlags(int __i)
	{
		super(FieldFlag.class,
			Flags.<FieldFlag>__decode(__i, FieldFlag.values()));
	}
	
	/**
	 * Initializes the field flags.
	 *
	 * @param __oc The outer class.
	 * @param __fl The field flags.
	 * @since 2016/04/23
	 */
	public FieldFlags(ClassFlags __oc, FieldFlag... __fl)
	{
		super(FieldFlag.class, __fl);
		
		this.__checkFlags(__oc);
	}
	
	/**
	 * Initializes the field flags.
	 *
	 * @param __oc The outer class.
	 * @param __fl The field flags.
	 * @since 2016/04/23
	 */
	public FieldFlags(ClassFlags __oc, Iterable<FieldFlag> __fl)
	{
		super(FieldFlag.class, __fl);
		
		this.__checkFlags(__oc);
	}
	
	/**
	 * Decodes field flags from the bit field.
	 *
	 * @param __oc The outer class flags.
	 * @param __i The bitfield to decode.
	 * @since 2017/07/07
	 */
	public FieldFlags(ClassFlags __oc, int __i)
	{
		this(__oc, Flags.<FieldFlag>__decode(__i, FieldFlag.values()));
	}
	
	/**
	 * Returns {@code true} if this is an enumeration.
	 *
	 * @return {@code true} if an enumeration.
	 * @since 2016/03/20
	 */
	public boolean isEnum()
	{
		return this.contains(FieldFlag.ENUM);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isFinal()
	{
		return this.contains(FieldFlag.FINAL);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPrivate()
	{
		return this.contains(FieldFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isProtected()
	{
		return this.contains(FieldFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPublic()
	{
		return this.contains(FieldFlag.PUBLIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isStatic()
	{
		return this.contains(FieldFlag.STATIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isSynthetic()
	{
		return this.contains(FieldFlag.SYNTHETIC);
	}
	
	/**
	 * Returns {@code true} if this is transient.
	 *
	 * @return {@code true} if transient.
	 * @since 2016/03/20
	 */
	public boolean isTransient()
	{
		return this.contains(FieldFlag.TRANSIENT);
	}
	
	/**
	 * Returns {@code true} if this is volatile.
	 *
	 * @return {@code true} if volatile.
	 * @since 2016/03/20
	 */
	public boolean isVolatile()
	{
		return this.contains(FieldFlag.VOLATILE);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @param __oc The outer class.
	 * @throws InvalidClassFormatException If they are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	private final void __checkFlags(ClassFlags __oc)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__oc == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2u A field cannot be both {@code final} and
		// {@code volatile}. (The field flags)}
		if (this.isFinal() && this.isVolatile())
			throw new InvalidClassFormatException(
				String.format("JC2u %s", this));
		
		// If the class is an interface, some flags cannot be set
		if (__oc.isInterface())
			for (FieldFlag f : FieldFlag.values())
			{
				// Must have these
				boolean must = (f == FieldFlag.PUBLIC ||
					f == FieldFlag.STATIC || f == FieldFlag.FINAL);
				
				// Could have these
				boolean maybe = (f == FieldFlag.SYNTHETIC);
				
				// Is it set?
				boolean has = this.contains(f);
				
				// {@squirreljme.error JC2v Flags for interface field has an
				// incorrect set of flags. (The field flags)}
				if (must != has && !maybe)
					throw new InvalidClassFormatException(
						String.format("JC2v %s", this));
			}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents the name of a field. It has the same constraints as
 * identifiers.
 *
 * @since 2017/07/07
 */
public final class FieldName
	extends Identifier
	implements Comparable<FieldName>, MemberName
{
	/**
	 * Initializes the field name.
	 *
	 * @param __s The field name.
	 * @since 2017/07/07
	 */
	public FieldName(String __s)
	{
		super(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int compareTo(FieldName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof FieldName) && super.equals(__o);
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the name and type for a field.
 *
 * @since 2017/10/12
 */
public final class FieldNameAndType
	implements Comparable<FieldNameAndType>, MemberNameAndType
{
	/** The field name. */
	protected final FieldName name;
	
	/** The field type. */
	protected final FieldDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the field name and type.
	 *
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/12
	 */
	public FieldNameAndType(FieldName __n, FieldDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int compareTo(FieldNameAndType __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.type.toString().compareTo(__o.type.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof FieldNameAndType))
			return false;
		
		FieldNameAndType o = (FieldNameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s:%s",
				this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public FieldDescriptor type()
	{
		return this.type;
	}
}


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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This describes a reference to a field.
 *
 * @since 2017/06/12
 */
public final class FieldReference
	extends MemberReference
{
	/** The name of the field. */
	protected final FieldName name;
	
	/** The member type. */
	protected final FieldDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Name and type. */
	private Reference<FieldNameAndType> _nat;
	
	/**
	 * Initializes the field reference.
	 *
	 * @param __c The class the member resides in.
	 * @param __i The name of the member.
	 * @param __t The descriptor of the member.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public FieldReference(ClassName __c, FieldName __i, FieldDescriptor __t)
		throws NullPointerException
	{
		super(__c);
		
		// Check
		if (__t == null || __i == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __i;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof FieldReference))
			return false;
		
		FieldReference o = (FieldReference)__o;
		return this.classname.equals(o.classname) &&
			this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.classname.hashCode() ^
			this.name.hashCode() ^
			this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/08
	 */
	@Override
	public final FieldName memberName()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldNameAndType memberNameAndType()
	{
		Reference<FieldNameAndType> ref = this._nat;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new FieldNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldDescriptor memberType()
	{
		return this.type;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"field %s::%s %s", this.classname, this.name,
				this.type)));
		
		return rv;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This interface is used to flag the types used for flags.
 *
 * @since 2016/04/23
 */
public interface Flag
{
	/**
	 * Returns the bit mask of the given flag.
	 *
	 * @return The bit mask of the given flag.
	 * @since 2017/07/07
	 */
	int javaBitMask();
	
	/**
	 * Returns the flag ordinal.
	 *
	 * @return The ordinal of the flag.
	 * @since 2016/04/23
	 */
	int ordinal();
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Flags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * This is the base class for all flag collections.
 *
 * @param <F> The flag type.
 * @since 2016/04/23
 */
public abstract class Flags<F extends Flag>
	extends AbstractSet<F>
{
	/** The class type to use. */
	protected final Class<F> cast;
	
	/** The set ordinals. */
	protected final int setbits;
	
	/** The slower access set. */
	private final Set<F> _flags;
	
	/**
	 * Initializes the flag set.
	 *
	 * @param __cl The class type of the flag.
	 * @param __fl The input flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	Flags(Class<F> __cl, F[] __fl)
		throws NullPointerException
	{
		this(__cl, Arrays.<F>asList(__fl));
	}
	
	/**
	 * Initializes the flag set.
	 *
	 * @param __cl The class type of the flag.
	 * @param __fl The input flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	Flags(Class<F> __cl, Iterable<F> __fl)
	{
		// Check
		if (__cl == null || __fl == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.cast = __cl;
		
		// Go through all input flags
		Set<F> to = new HashSet<>();
		int bits = 0;
		for (F f : __fl)
		{
			// Get ordinal
			int o = f.ordinal();
			
			// Set it
			bits |= (1 << o);
			
			// Add to flag set
			to.add(f);
		}
		
		// Lock in
		this.setbits = bits;
		this._flags = to;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final boolean contains(Object __o)
	{
		if (!(__o instanceof Flag))
			return false;
		
		// Quick bit check?
		if (this.cast.isInstance(__o))
			return 0 != (this.setbits & (1 << (((Flag)__o).ordinal())));
		
		// Fallback
		return this._flags.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final Iterator<F> iterator()
	{
		return new __Iterator__<F>(this._flags.iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final int size()
	{
		return this._flags.size();
	}
	
	/**
	 * Converts the flags to Java bits.
	 *
	 * @return The Java bits.
	 * @since 2018/12/04
	 */
	public final int toJavaBits()
	{
		int rv = 0;
		
		for (Flag f : this)
			rv |= f.javaBitMask();
		
		return rv;
	}
	
	/**
	 * Decodes the specified bitfield and returns the used flags.
	 *
	 * @param <F> The type of flags to decode.
	 * @param __i The input bitfield.
	 * @param __f The flag values to decode.
	 * @return The flags specified in the bitfield.
	 * @throws InvalidClassFormatException If extra flags were specified.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/13
	 */
	static <F extends Flag> Iterable<F> __decode(int __i, F[] __f)
		throws InvalidClassFormatException, NullPointerException
	{
		// Find all matching flags in the bitfield
		List<F> fl = new ArrayList<>(__f.length);
		for (F f : __f)
		{
			int v = f.javaBitMask();
			if (0 != (__i & v))
			{
				fl.add(f);
				__i ^= v;
			}
		}
		
		// {@squirreljme.error JC2w An undefined flag has been specified.
		// (The extra bitfield flags)}
		if (__i != 0)
			throw new InvalidClassFormatException(
				String.format("JC2w %02x", __i));
		
		return fl;
	}
	
	/**
	 * Iterates over flags.
	 *
	 * @since 2017/01/28
	 */
	private static final class __Iterator__<F>
		implements Iterator<F>
	{
		/** The iterator used. */
		protected final Iterator<F> iterator;
		
		/**
		 * Wraps the iterator.
		 *
		 * @param __it The iterator to wrap.
		 * @since 2017/01/28
		 */
		private __Iterator__(Iterator<F> __it)
		{
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public F next()
		{
			return this.iterator.next();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents a single formal parameter which is used as input for a
 * method call.
 *
 * @since 2018/05/14
 */
public final class FormalParameter
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This class stores and represents the formal parameters of a method.
 *
 * @since 2018/05/14
 */
public final class FormalParameters
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This interface represents anything that has accessible flags.
 *
 * @since 2018/09/09
 */
public interface HasAccessibleFlags
{
	/**
	 * Returns accessible flags.
	 *
	 * @return The accessible flags.
	 * @since 2018/09/09
	 */
	AccessibleFlags flags();
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/HasMemberFlags.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents anything which has member flags.
 *
 * @since 2018/09/09
 */
public interface HasMemberFlags
	extends HasAccessibleFlags
{
	/**
	 * Returns member flags.
	 *
	 * @return The member flags.
	 * @since 2018/09/09
	 */
	@Override
	MemberFlags flags();
}

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

package net.multiphasicapps.classfile;

/**
 * This represents an identifier which acts as a name of a fragment of a class
 * or a member of a class.
 *
 * @since 2017/06/12
 */
public abstract class Identifier
{
	/** The string which makes up the identifier. */
	protected final String string;
	
	/**
	 * Initializes the identifier.
	 *
	 * @param __n The input identifier to decode.
	 * @throws InvalidClassFormatException If it is not a valid identifier.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	Identifier(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// Check characters
		for (int i = 0, n = __n.length(); i < n; i++)
		{
			char c = __n.charAt(i);
			
			// {@squirreljme.error JC2x The specified identifier contains an
			// invalid character. (The identifier)}
			if (c == '.' || c == ';' || c == '[' || c == '/')
				throw new InvalidClassFormatException(
					String.format("JC2x %s", __n));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Identifier))
			return false;
		
		return this.string.equals(((Identifier)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2017/10/02
	 */
	public final String identifier()
	{
		return this.string;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents an inner class that is contained within an outer class, it
 * is used by the compiler to determine how classes are contained within each
 * other.
 *
 * @since 2018/05/15
 */
public final class InnerClass
{
	/** The name of the inner class. */
	protected final ClassName name;
	
	/** The outer class this is contained within. */
	protected final ClassName outerclass;
	
	/** The simple name of the class as defined in the class. */
	protected final ClassIdentifier simplename;
	
	/** The flags for the inner class. */
	protected final InnerClassFlags flags;
	
	/**
	 * Initializes an anonymous inner class.
	 *
	 * @param __n The name of the class.
	 * @param __f The class flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public InnerClass(ClassName __n, InnerClassFlags __f)
		throws NullPointerException
	{
		if (__n == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.outerclass = null;
		this.simplename = null;
		this.flags = __f;
	}
	
	/**
	 * Initializes a standard inner class.
	 *
	 * @param __n The name of the class.
	 * @param __o The class this is a member of. If this is {@code null} then
	 * the class is either: a top-level class/interface, a local class (one
	 * that exists only in a method), or is a member of an anonymous class.
	 * @param __i The identifier used to name the class.
	 * @param __f The class flags.
	 * @since 2018/05/21
	 */
	public InnerClass(ClassName __n, ClassName __o, ClassIdentifier __i,
		InnerClassFlags __f)
	{
		this.name = __n;
		this.outerclass = __o;
		this.simplename = __i;
		this.flags = __f;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the flags for the inner class.
	 *
	 * @return The inner class flags.
	 * @since 2018/06/16
	 */
	public final InnerClassFlags flags()
	{
		return this.flags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this an anonymous class?
	 *
	 * @return Is this an anonymous class?
	 * @since 2018/06/16
	 */
	public final boolean isAnonymous()
	{
		return this.name != null &&
			this.outerclass == null &&
			this.simplename == null;
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The class name.
	 * @since 2018/06/16
	 */
	public final ClassName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the name of the outer class or {@code null} if it is anonymous.
	 *
	 * @return The name of the outer class or {@code null} if anonymous.
	 * @since 2018/06/16
	 */
	public final ClassName outerClass()
	{
		return this.outerclass;
	}
	
	/**
	 * Returns the simple name of the class.
	 *
	 * @return The simple name of the class.
	 * @since 2018/06/16
	 */
	public final ClassIdentifier simpleName()
	{
		return this.simplename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/InnerClassFlag.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a flag which may be associated with an inner class.
 *
 * @since 2018/05/15
 */
public enum InnerClassFlag
	implements Flag
{
	/** Public. */
	PUBLIC,
	
	/** Private. */
	PRIVATE,
	
	/** Protected. */
	PROTECTED,
	
	/** Static. */
	STATIC,
	
	/** Final. */
	FINAL,
	
	/** Interface. */
	INTERFACE,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Synthetic. */
	SYNTHETIC,
	
	/** Annotation. */
	ANNOTATION,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case PRIVATE:		return 0x0002;
			case PROTECTED:		return 0x0004;
			case STATIC:		return 0x0008;
			case FINAL:			return 0x0010;
			case INTERFACE:		return 0x0200;
			case ABSTRACT:		return 0x0400;
			case SYNTHETIC:		return 0x1000;
			case ANNOTATION:	return 0x2000;
			case ENUM:			return 0x4000;
			
			default:
				throw new todo.OOPS();
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/InnerClassFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a set of flags which are used as modifiers to inner classes.
 *
 * @since 2018/05/15
 */
public final class InnerClassFlags
	extends Flags<InnerClassFlag>
	implements AccessibleFlags
{
	/** Standard class flag representation. */
	private Reference<ClassFlags> _cflags;
	
	/**
	 * Initializes the inner class flags decoding from the specified bit field.
	 *
	 * @param __i The bit field to decode flags from.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(int __i)
	{
		this(Flags.<InnerClassFlag>__decode(__i, InnerClassFlag.values()));
	}
	
	/**
	 * Initializes the inner class flags.
	 *
	 * @param __fl The inner class flags.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(InnerClassFlag... __fl)
	{
		super(InnerClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Initializes the inner class flags.
	 *
	 * @param __fl The inner class flags.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(Iterable<InnerClassFlag> __fl)
	{
		super(InnerClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Returns the outer class representation for these flags.
	 *
	 * @return The outer class flag representation.
	 * @since 2018/05/21
	 */
	public final ClassFlags asClassFlags()
	{
		Reference<ClassFlags> ref = this._cflags;
		ClassFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			int mask = 0;
			for (InnerClassFlag i : this)
			{
				ClassFlag v;
				switch (i)
				{
					case PUBLIC:
						v = ClassFlag.PUBLIC;
						break;
						
					case FINAL:
						v = ClassFlag.FINAL;
						break;
						
					case INTERFACE:
						v = ClassFlag.INTERFACE;
						break;
						
					case ABSTRACT:
						v = ClassFlag.ABSTRACT;
						break;
						
					case SYNTHETIC:
						v = ClassFlag.SYNTHETIC;
						break;
						
					case ANNOTATION:
						v = ClassFlag.ANNOTATION;
						break;
						
					case ENUM:
						v = ClassFlag.ENUM;
						break;
					
					default:
						v = null;
						continue;
				}
				
				if (v != null)
					mask |= v.javaBitMask();
			}
			
			this._cflags = new WeakReference<>((rv = new ClassFlags(mask)));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !this.isPrivate() && !this.isProtected() && !this.isPublic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPrivate()
	{
		return this.contains(InnerClassFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isProtected()
	{
		return this.contains(InnerClassFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPublic()
	{
		return this.contains(InnerClassFlag.PUBLIC);
	}
	
	/**
	 * Checks that the inner class flags are valid.
	 *
	 * @throws InvalidClassFormatException If the inner class flags are not
	 * valid.
	 * @since 2018/05/15
	 */
	private final void __checkFlags()
		throws InvalidClassFormatException
	{
		// Construct class flags which checks if they are valid
		try
		{
			this.asClassFlags();
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error JC2y Inner class flags are not valid
			// because they would produce invalid standard outer class
			// flags. (The flags)}
			throw new InvalidClassFormatException(String.format("JC2y %s",
				this), e);
		}
		
		// {@squirreljme.error JC2z Multiple access modifiers, inner classes
		// can only be one or none of private, protected, or public.
		// (The flags)}
		int count = (this.isPublic() ? 1 : 0) +
			(this.isProtected() ? 1 : 0) +
			(this.isPrivate() ? 1 : 0);
		if (count > 1)
			throw new InvalidClassFormatException(String.format("JC2z %s",
				this));
	}
}

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

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This contains the table of inner class references.
 *
 * @since 2018/05/15
 */
public final class InnerClasses
	implements Iterable<InnerClass>
{
	/** The declared inner classes. */
	private final InnerClass[] _inners;
	
	/**
	 * Initializes the inner classes.
	 *
	 * @param __i The inner classes.
	 * @throws InvalidClassFormatException If the inner classes are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/16
	 */
	public InnerClasses(InnerClass... __i)
		throws InvalidClassFormatException, NullPointerException
	{
		this(Arrays.<InnerClass>asList((__i != null ? __i :
			new InnerClass[0])));
	}
	
	/**
	 * Initializes the inner classes.
	 *
	 * @param __i The inner classes.
	 * @throws InvalidClassFormatException If the inner classes are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/16
	 */
	public InnerClasses(Iterable<InnerClass> __i)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		List<InnerClass> rv = new ArrayList<>();
		for (InnerClass i : __i)
		{
			if (i == null)
				throw new NullPointerException("NARG");
			
			rv.add(i);
		}
		
		this._inners = rv.<InnerClass>toArray(new InnerClass[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final Iterator<InnerClass> iterator()
	{
		return UnmodifiableIterator.<InnerClass>of(this._inners);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses the information which pertains to the inner classes.
	 *
	 * @param __pool The constant pool.
	 * @param __attrs The input attributes.
	 * @return The parsed inner class information.
	 * @throws InvalidClassFormatException If the inner classes are not
	 * correct.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static final InnerClasses parse(Pool __pool,
		AttributeTable __attrs)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __attrs == null)
			throw new NullPointerException("NARG");
		
		// Only if the attribute exists
		Attribute attr = __attrs.get("InnerClasses");
		if (attr == null)
			return new InnerClasses();
		
		List<InnerClass> rv = new ArrayList<>();
		try (DataInputStream in = attr.open())
		{
			// Read each one
			int n = in.readUnsignedShort();
			for (int i = 0; i < n; i++)
			{
				ClassName innerclass = __pool.<ClassName>require(
					ClassName.class, in.readUnsignedShort());
				ClassName outerclass = __pool.<ClassName>get(
					ClassName.class, in.readUnsignedShort());
				
				UTFConstantEntry rawname = __pool.<UTFConstantEntry>get(
					UTFConstantEntry.class, in.readUnsignedShort());
				ClassIdentifier name = (rawname == null ? null :
					new ClassIdentifier(rawname.toString()));
				
				InnerClassFlags flags = new InnerClassFlags(
					in.readUnsignedShort());
				
				// Add them
				if (outerclass == null && name == null)
					rv.add(new InnerClass(innerclass, flags));
				else
				{
					rv.add(new InnerClass(innerclass, outerclass,
						name, flags));
				}
			}
		}
		
		return new InnerClasses(rv);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Instruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This represents a single instruction within the byte code.
 *
 * @since 2017/10/15
 */
public final class Instruction
{
	/** The instruction address. */
	protected final int address;
	
	/** The instruction operation. */
	protected final int op;
	
	/** Does this instruction naturally flow? */
	protected final boolean naturalflow;
	
	/** Stack map table entry for this instruction. */
	protected final StackMapTableState smtstate;
	
	/** Jump targets. */
	protected final InstructionJumpTargets jumptargets;
	
	/** Instruction arguments. */
	private final Object[] _args;
	
	/** String representation of the operation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the instruction information.
	 *
	 * @param __code The instruction bytes.
	 * @param __pool The constant pool.
	 * @param __a The instruction address.
	 * @param __eh Exception handler table.
	 * @param __smt The stack map table data.
	 * @param __af Address of the instruction which follows this.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/18
	 */
	Instruction(byte[] __code, Pool __pool, int __a,
		ExceptionHandlerTable __eh, StackMapTable __smt, int __af)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__code == null || __pool == null || __smt == null)
			throw new NullPointerException("NARG");
		
		// Get potential stack map entry for this instruction
		this.smtstate = __smt.get(__a);
		
		// Calculate real instruction address
		int aa = __a + ByteCode._CODE_OFFSET;
		
		// Read operation here
		int op = (__code[aa] & 0xFF),
			argbase = aa + 1;
		if (op == InstructionIndex.WIDE)
		{
			op = (op << 8) | (__code[aa + 1] & 0xFF);
			argbase++;
		}
		this.op = op;
		this.address = __a;
		
		// Depends on the operation
		Object[] args;
		boolean naturalflow;
		switch (op)
		{
				// No arguments and does not flow naturally
			case InstructionIndex.ATHROW:
			case InstructionIndex.ARETURN:
			case InstructionIndex.DRETURN:
			case InstructionIndex.FRETURN:
			case InstructionIndex.IRETURN:
			case InstructionIndex.LRETURN:
			case InstructionIndex.RETURN:
				args = new Object[0];
				naturalflow = false;
				break;
			
				// Operands with no arguments, natural flow
			case InstructionIndex.AALOAD:
			case InstructionIndex.AASTORE:
			case InstructionIndex.ACONST_NULL:
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
			case InstructionIndex.ARRAYLENGTH:
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
			case InstructionIndex.BALOAD:
			case InstructionIndex.BASTORE:
			case InstructionIndex.CALOAD:
			case InstructionIndex.CASTORE:
			case InstructionIndex.D2F:
			case InstructionIndex.D2I:
			case InstructionIndex.D2L:
			case InstructionIndex.DADD:
			case InstructionIndex.DALOAD:
			case InstructionIndex.DASTORE:
			case InstructionIndex.DCMPG:
			case InstructionIndex.DCMPL:
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
			case InstructionIndex.DDIV:
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
			case InstructionIndex.DMUL:
			case InstructionIndex.DNEG:
			case InstructionIndex.DREM:
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
			case InstructionIndex.DSUB:
			case InstructionIndex.DUP:
			case InstructionIndex.DUP2:
			case InstructionIndex.DUP2_X1:
			case InstructionIndex.DUP2_X2:
			case InstructionIndex.DUP_X1:
			case InstructionIndex.DUP_X2:
			case InstructionIndex.F2D:
			case InstructionIndex.F2I:
			case InstructionIndex.F2L:
			case InstructionIndex.FADD:
			case InstructionIndex.FALOAD:
			case InstructionIndex.FASTORE:
			case InstructionIndex.FCMPG:
			case InstructionIndex.FCMPL:
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
			case InstructionIndex.FDIV:
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
			case InstructionIndex.FMUL:
			case InstructionIndex.FNEG:
			case InstructionIndex.FREM:
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
			case InstructionIndex.FSUB:
			case InstructionIndex.I2B:
			case InstructionIndex.I2C:
			case InstructionIndex.I2D:
			case InstructionIndex.I2F:
			case InstructionIndex.I2L:
			case InstructionIndex.I2S:
			case InstructionIndex.IADD:
			case InstructionIndex.IALOAD:
			case InstructionIndex.IAND:
			case InstructionIndex.IASTORE:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.IDIV:
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
			case InstructionIndex.IMUL:
			case InstructionIndex.INEG:
			case InstructionIndex.IOR:
			case InstructionIndex.IREM:
			case InstructionIndex.ISHL:
			case InstructionIndex.ISHR:
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
			case InstructionIndex.ISUB:
			case InstructionIndex.IUSHR:
			case InstructionIndex.IXOR:
			case InstructionIndex.L2D:
			case InstructionIndex.L2F:
			case InstructionIndex.L2I:
			case InstructionIndex.LADD:
			case InstructionIndex.LALOAD:
			case InstructionIndex.LAND:
			case InstructionIndex.LASTORE:
			case InstructionIndex.LCMP:
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
			case InstructionIndex.LDIV:
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
			case InstructionIndex.LMUL:
			case InstructionIndex.LNEG:
			case InstructionIndex.LOR:
			case InstructionIndex.LREM:
			case InstructionIndex.LSHL:
			case InstructionIndex.LSHR:
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
			case InstructionIndex.LSUB:
			case InstructionIndex.LUSHR:
			case InstructionIndex.LXOR:
			case InstructionIndex.MONITORENTER:
			case InstructionIndex.MONITOREXIT:
			case InstructionIndex.NOP:
			case InstructionIndex.POP:
			case InstructionIndex.POP2:
			case InstructionIndex.SALOAD:
			case InstructionIndex.SASTORE:
			case InstructionIndex.SWAP:
				args = new Object[0];
				naturalflow = true;
				break;
				
				// Argument is a class
			case InstructionIndex.ANEWARRAY:
			case InstructionIndex.CHECKCAST:
			case InstructionIndex.INSTANCEOF:
			case InstructionIndex.NEW:
				naturalflow = true;
				args = new Object[]{__pool.<ClassName>require(ClassName.class,
					Instruction.__readUnsignedShort(__code, argbase))};
				break;
				
				// First value is a signed byte
			case InstructionIndex.BIPUSH:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readByte(__code, argbase)};
				break;
				
				// First value is an unsigned byte
			case InstructionIndex.ALOAD:
			case InstructionIndex.ILOAD:
			case InstructionIndex.LLOAD:
			case InstructionIndex.FLOAD:
			case InstructionIndex.DLOAD:
			case InstructionIndex.ASTORE:
			case InstructionIndex.ISTORE:
			case InstructionIndex.LSTORE:
			case InstructionIndex.FSTORE:
			case InstructionIndex.DSTORE:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedByte(__code, argbase)};
				break;
				
				// First value is a signed short
			case InstructionIndex.SIPUSH:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readShort(__code, argbase)};
				break;
				
				// Read or write of a field
			case InstructionIndex.GETSTATIC:
			case InstructionIndex.PUTSTATIC:
			case InstructionIndex.GETFIELD:
			case InstructionIndex.PUTFIELD:
				naturalflow = true;
				args = new Object[]{__pool.<FieldReference>require(
					FieldReference.class,
					Instruction.__readUnsignedShort(__code, argbase))};
				break;
				
				// Goto
			case InstructionIndex.GOTO:
				naturalflow = false;
				args = new Object[]{new InstructionJumpTarget(
					__a + Instruction.__readShort(__code, argbase))};
				break;
				
				// Increment local variable
			case InstructionIndex.IINC:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedByte(__code, argbase),
					Instruction.__readByte(__code, argbase + 1)};
				break;
				
				// Increment local variable (wide)
			case InstructionIndex.WIDE_IINC:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedShort(__code, argbase),
					Instruction.__readShort(__code, argbase + 2)};
				break;
				
				// Branches
			case InstructionIndex.IFNONNULL:
			case InstructionIndex.IFNULL:
			case InstructionIndex.IF_ACMPEQ:
			case InstructionIndex.IF_ACMPNE:
			case InstructionIndex.IF_ICMPEQ:
			case InstructionIndex.IF_ICMPNE:
			case InstructionIndex.IF_ICMPLT:
			case InstructionIndex.IF_ICMPGE:
			case InstructionIndex.IF_ICMPGT:
			case InstructionIndex.IF_ICMPLE:
			case InstructionIndex.IFEQ:
			case InstructionIndex.IFNE:
			case InstructionIndex.IFLT:
			case InstructionIndex.IFGE:
			case InstructionIndex.IFGT:
			case InstructionIndex.IFLE:
				naturalflow = true;
				args = new Object[]{new InstructionJumpTarget(
					__a + Instruction.__readShort(__code, argbase))};
				break;
				
				// Method invocations
			case InstructionIndex.INVOKEINTERFACE:
			case InstructionIndex.INVOKESPECIAL:
			case InstructionIndex.INVOKESTATIC:
			case InstructionIndex.INVOKEVIRTUAL:
				naturalflow = true;
				
				// Reference is in the constant pool
				MethodReference mr = __pool.<MethodReference>require(
					MethodReference.class,
					Instruction.__readUnsignedShort(__code, argbase));
				
				// {@squirreljme.error JC31 Invocation of method did not
				// have the matching interface/not-interface attribute.
				// (The operation; The address; The method reference)}
				if (mr.isInterface() !=
					(op == InstructionIndex.INVOKEINTERFACE))
					throw new InvalidClassFormatException(String.format(
						"JC31 %d %d %s", op, __a, mr));
				
				args = new Object[]{mr};
				break;
				
				// Load constant value
			case InstructionIndex.LDC:
			case InstructionIndex.LDC_W:
				naturalflow = true;
				
				// Could vary in type
				Object ldcv = __pool.<Object>require(Object.class,
					(op == InstructionIndex.LDC_W ?
					Instruction.__readUnsignedShort(__code, argbase) :
					Instruction.__readUnsignedByte(__code, argbase)));
				
				// Turn into a class value
				ConstantValue cvalue;
				if (ldcv instanceof ClassName)
					cvalue = new ConstantValueClass((ClassName)ldcv);
				else
					cvalue = (ConstantValue)ldcv;
				
				// {@squirreljme.error JC32 Cannot load a constant value which
				// is not of a narrow type. (The operation; The address; The
				// constant value)}
				if (!cvalue.type().isNarrow())
					throw new InvalidClassFormatException(String.format(
						"JC32 %d %d %s", op, __a, cvalue));
				
				// Just use this value
				args = new Object[]{cvalue};
				break;
				
				// Load wide constant value
			case InstructionIndex.LDC2_W:
				naturalflow = true;
				
				// Just will be a constant value type
				cvalue = __pool.<ConstantValue>require(
					ConstantValue.class,
					Instruction.__readUnsignedShort(__code, argbase));
				
				// {@squirreljme.error JC33 Cannot load a constant value which
				// is not of a wide type. (The operation; The address;
				// The constant value)}
				if (!cvalue.type().isWide())
					throw new InvalidClassFormatException(String.format(
						"JC33 %d %d %s", op, __a, cvalue));
				
				// Just use this value
				args = new Object[]{cvalue};
				break;
				
				// Allocate array of primitive type
			case InstructionIndex.NEWARRAY:
				naturalflow = true;
				
				// The primitive type depends
				PrimitiveType pt;
				int pd;
				switch ((pd = Instruction.__readUnsignedByte(__code, argbase)))
				{
					case 4:		pt = PrimitiveType.BOOLEAN; break;
					case 5:		pt = PrimitiveType.CHARACTER; break;
					case 6:		pt = PrimitiveType.FLOAT; break;
					case 7:		pt = PrimitiveType.DOUBLE; break;
					case 8:		pt = PrimitiveType.BYTE; break;
					case 9:		pt = PrimitiveType.SHORT; break;
					case 10:	pt = PrimitiveType.INTEGER; break;
					case 11:	pt = PrimitiveType.LONG; break;
					
						// {@squirreljme.error JC34 Unknown type specified for
						// new primitive array. (The operation; The address;
						// The type specifier)}
					default:
						throw new InvalidClassFormatException(String.format(
							"JC34 %d %d %d", op, __a, pd));
				}
				args = new Object[]{pt};
				break;
				
				// New multi-dimensional array
			case InstructionIndex.MULTIANEWARRAY:
				naturalflow = true;
				
				ClassName cname = __pool.<ClassName>require(ClassName.class,
					Instruction.__readUnsignedShort(__code, argbase));
				int dims = Instruction.__readUnsignedByte(__code,
					argbase + 2);
				
				// {@squirreljme.error JC35 Dimensions represented in type
				// is smaller than the represented dimensions.
				// (The operation; The address; The dimensions)}
				if (cname.dimensions() < dims)
					throw new InvalidClassFormatException(String.format(
						"JC35 %d %d %d", op, __a, dims));
				
				args = new Object[]{cname, dims};
				break;
			
				// Lookup switch lookup table
			case InstructionIndex.LOOKUPSWITCH:
				{
					// Determine the real address of the table
					int pa = ((aa + 4) & (~3));
					
					// Read in the default
					InstructionJumpTarget def = new InstructionJumpTarget(
						__a + Instruction.__readInt(__code, pa));
					
					// {@squirreljme.error JC36 Pair count for lookup switch
					// is negative. (The opcode; The address; The after padded
					// address; The read length)}
					int n = Instruction.__readInt(__code, pa + 4);
					if (n < 0)
						throw new InvalidClassFormatException(String.format(
							"JC36 %d %d %d %d", op, __a, pa, n));
					
					// Setup
					int[] keys = new int[n];
					InstructionJumpTarget[] jumps =
						new InstructionJumpTarget[n];
					
					// Load in tables
					for (int i = 0, ra = pa + 8; i < n; i++, ra += 8)
					{
						keys[i] = Instruction.__readInt(__code, ra);
						jumps[i] = new InstructionJumpTarget(
							__a + Instruction.__readInt(__code, ra + 4));
					}
					
					// Setup instruction properties
					naturalflow = true;
					args = new Object[]{new LookupSwitch(def, keys, jumps)};
				}
				break;
			
				// Table switch lookup table
			case InstructionIndex.TABLESWITCH:
				{
					// Determine the real address of the table
					int pa = ((aa + 4) & (~3));
					
					// Read in the default
					InstructionJumpTarget def = new InstructionJumpTarget(
						__a + Instruction.__readInt(__code, pa));
					
					// Read in low and high
					int lo = Instruction.__readInt(__code, pa + 4),
						hi = Instruction.__readInt(__code, pa + 8);
					
					// Read jump targets
					int n = (hi - lo) + 1;
					InstructionJumpTarget[] jumps =
						new InstructionJumpTarget[n];
					
					// Load in tables
					for (int i = 0, ra = pa + 12; i < n; i++, ra += 4)
						jumps[i] = new InstructionJumpTarget(
							__a + Instruction.__readInt(__code, ra));
					
					// Setup instruction properties
					naturalflow = true;
					args = new Object[]{new TableSwitch(def, lo, hi, jumps)};
				}
				break;
				
				// {@squirreljme.error JC37 The operation at the specified
				// address is not supported yet. (The operation; The name of
				// the operation; The address it is at)}
			default:
				throw new RuntimeException(String.format("JC37 %d %s %d",
					op, InstructionMnemonics.toString(op), __a));
		}
		
		// Set
		this._args = args;
		this.naturalflow = naturalflow;
		
		// Figure out normal jump targets
		Set<InstructionJumpTarget> normal = new LinkedHashSet<>();
		if (naturalflow)
			normal.add(new InstructionJumpTarget(__af));
		for (int i = 0, n = args.length; i < n; i++)
		{
			Object v = args[i];
			
			// Jump
			if (v instanceof InstructionJumpTarget)
				normal.add((InstructionJumpTarget)v);
			
			// A table
			else if (v instanceof IntMatchingJumpTable)
				for (InstructionJumpTarget j :
					((IntMatchingJumpTable)v).targets())
					normal.add(j);
		}
		
		// Determine exceptional jump targets
		Set<InstructionJumpTarget> exception = new LinkedHashSet<>();
		for (ExceptionHandler eh : __eh)
			if (eh.inRange(__a))
				exception.add(new InstructionJumpTarget(eh.handlerAddress()));
		
		// Set jump targets
		this.jumptargets = new InstructionJumpTargets(
			normal.<InstructionJumpTarget>toArray(
				new InstructionJumpTarget[normal.size()]),
			exception.<InstructionJumpTarget>toArray(
				new InstructionJumpTarget[exception.size()]));
	}
	
	/**
	 * Returns the address of this instruction.
	 *
	 * @return The instruction address.
	 * @since 2017/05/20
	 */
	public int address()
	{
		return this.address;
	}
	
	/**
	 * Returns the argument for this given instruction.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not castable.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/20
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2017/05/20
	 */
	public int count()
	{
		return this._args.length;
	}
	
	/**
	 * Returns {@code true} if the instruction has natural flow.
	 *
	 * @return The instruction flows to the next naturally.
	 * @since 2017/05/20
	 */
	public boolean hasNaturalFlow()
	{
		return this.naturalflow;
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an integer.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2017/09/02
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Integer>argument(__i, Integer.class).intValue();
	}
	
	/**
	 * Returns the jump targets for this instruction.
	 *
	 * @return The jump targets for this instruction.
	 * @since 2019/03/30
	 */
	public final InstructionJumpTargets jumpTargets()
	{
		return this.jumptargets;
	}
	
	/**
	 * Returns the mnemonic of this instruction.
	 *
	 * @return The instruction mnemonic.
	 * @since 2018/09/20
	 */
	public final String mnemonic()
	{
		return InstructionMnemonics.toString(this.op);
	}
	
	/**
	 * Returns the operation that this performs.
	 *
	 * @return The operation.
	 * @since 2017/05/20
	 */
	public int operation()
	{
		return this.op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public final short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * Returns the stack map table state for this entry.
	 *
	 * @return The stack map table state.
	 * @since 2017/10/16
	 */
	public StackMapTableState stackMapTableState()
	{
		return this.smtstate;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Address first
			StringBuilder sb = new StringBuilder("@");
			sb.append(this.address);
			
			// Then the operation
			sb.append('#');
			sb.append(InstructionMnemonics.toString(this.op));
			
			// Add marker if it flows naturally
			if (this.naturalflow)
				sb.append('~');
			
			// Then the arguments
			sb.append(":[");
			Object[] args = this._args;
			for (int i = 0, n = args.length; i < n; i++)
			{
				if (i > 0)
					sb.append(", ");
				sb.append(args[i]);
			}
			sb.append(']');
			
			// Cache
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Reads a signed byte from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	static final int __readByte(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		return (byte)Instruction.__readUnsignedByte(__a, __o);
	}
	
	/**
	 * Reads a signed int from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	static final int __readInt(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC38 Illegal int read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o + 3 >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC38 %d %d", __o, __a.length));
		
		return ((__a[__o] & 0xFF) << 24)  |
			((__a[__o + 1] & 0xFF) << 16)  |
			((__a[__o + 2] & 0xFF) << 8) |
			(__a[__o + 3] & 0xFF);
	}
	
	/**
	 * Reads a signed short from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	static final int __readShort(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		return (short)Instruction.__readUnsignedShort(__a, __o);
	}
	
	/**
	 * Reads an unsigned byte from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	static final int __readUnsignedByte(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC39 Illegal byte read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC39 %d %d", __o, __a.length));
		
		return (__a[__o] & 0xFF);
	}
	
	/**
	 * Reads an unsigned short from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/15
	 */
	static final int __readUnsignedShort(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3a Illegal short read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o + 1 >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC3a %d %d", __o, __a.length));
		
		return ((__a[__o] & 0xFF) << 8) | (__a[__o + 1] & 0xFF);
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a range of instruction addresses, the start is inclusive
 * and the end is exclusive.
 *
 * @since 2019/03/21
 */
public final class InstructionAddressRange
	implements Comparable<InstructionAddressRange>
{
	/** The start address. */
	protected final int start;
	
	/** The end address. */
	protected final int end;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the address range.
	 *
	 * @param __s The start address.
	 * @param __e The end address.
	 * @since 2019/03/21
	 */
	public InstructionAddressRange(int __s, int __e)
	{
		this.start = __s;
		this.end = __e;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int compareTo(InstructionAddressRange __b)
	{
		int rv = this.start - __b.start;
		if (rv != 0)
			return rv;
		
		return this.end - __b.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof InstructionAddressRange))
			return false;
		
		InstructionAddressRange o = (InstructionAddressRange)__o;
		return this.start == o.start &&
			this.end == o.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int hashCode()
	{
		return this.start ^ (~this.end);
	}
	
	/**
	 * Checks if the given address is in the range of this range.
	 *
	 * @param __pc The address to check.
	 * @return If the address is in range.
	 * @since 2019/03/22
	 */
	public final boolean inRange(int __pc)
	{
		return __pc >= this.start && __pc < this.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "@[" + this.start +
				"-" + this.end + ")"));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/InstructionIndex.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface contains instruction identification numbers which identify
 * opcodes based on their opcode ID.
 *
 * @since 2016/08/24
 */
public interface InstructionIndex
{
	/** NOP. */
	int NOP =
		0;

	/** ACONST_NULL. */
	int ACONST_NULL =
		1;

	/** ICONST_M1. */
	int ICONST_M1 =
		2;

	/** ICONST_0. */
	int ICONST_0 =
		3;

	/** ICONST_1. */
	int ICONST_1 =
		4;

	/** ICONST_2. */
	int ICONST_2 =
		5;

	/** ICONST_3. */
	int ICONST_3 =
		6;

	/** ICONST_4. */
	int ICONST_4 =
		7;

	/** ICONST_5. */
	int ICONST_5 =
		8;

	/** LCONST_0. */
	int LCONST_0 =
		9;

	/** LCONST_1. */
	int LCONST_1 =
		10;

	/** FCONST_0. */
	int FCONST_0 =
		11;

	/** FCONST_1. */
	int FCONST_1 =
		12;

	/** FCONST_2. */
	int FCONST_2 =
		13;

	/** DCONST_0. */
	int DCONST_0 =
		14;

	/** DCONST_1. */
	int DCONST_1 =
		15;

	/** BIPUSH. */
	int BIPUSH =
		16;

	/** SIPUSH. */
	int SIPUSH =
		17;

	/** LDC. */
	int LDC =
		18;

	/** LDC_W. */
	int LDC_W =
		19;

	/** LDC2_W. */
	int LDC2_W =
		20;

	/** ILOAD. */
	int ILOAD =
		21;

	/** LLOAD. */
	int LLOAD =
		22;

	/** FLOAD. */
	int FLOAD =
		23;

	/** DLOAD. */
	int DLOAD =
		24;

	/** ALOAD. */
	int ALOAD =
		25;

	/** ILOAD_0. */
	int ILOAD_0 =
		26;

	/** ILOAD_1. */
	int ILOAD_1 =
		27;

	/** ILOAD_2. */
	int ILOAD_2 =
		28;

	/** ILOAD_3. */
	int ILOAD_3 =
		29;

	/** LLOAD_0. */
	int LLOAD_0 =
		30;

	/** LLOAD_1. */
	int LLOAD_1 =
		31;

	/** LLOAD_2. */
	int LLOAD_2 =
		32;

	/** LLOAD_3. */
	int LLOAD_3 =
		33;

	/** FLOAD_0. */
	int FLOAD_0 =
		34;

	/** FLOAD_1. */
	int FLOAD_1 =
		35;

	/** FLOAD_2. */
	int FLOAD_2 =
		36;

	/** FLOAD_3. */
	int FLOAD_3 =
		37;

	/** DLOAD_0. */
	int DLOAD_0 =
		38;

	/** DLOAD_1. */
	int DLOAD_1 =
		39;

	/** DLOAD_2. */
	int DLOAD_2 =
		40;

	/** DLOAD_3. */
	int DLOAD_3 =
		41;

	/** ALOAD_0. */
	int ALOAD_0 =
		42;

	/** ALOAD_1. */
	int ALOAD_1 =
		43;

	/** ALOAD_2. */
	int ALOAD_2 =
		44;

	/** ALOAD_3. */
	int ALOAD_3 =
		45;

	/** IALOAD. */
	int IALOAD =
		46;

	/** LALOAD. */
	int LALOAD =
		47;

	/** FALOAD. */
	int FALOAD =
		48;

	/** DALOAD. */
	int DALOAD =
		49;

	/** AALOAD. */
	int AALOAD =
		50;

	/** BALOAD. */
	int BALOAD =
		51;

	/** CALOAD. */
	int CALOAD =
		52;

	/** SALOAD. */
	int SALOAD =
		53;

	/** ISTORE. */
	int ISTORE =
		54;

	/** LSTORE. */
	int LSTORE =
		55;

	/** FSTORE. */
	int FSTORE =
		56;

	/** DSTORE. */
	int DSTORE =
		57;

	/** ASTORE. */
	int ASTORE =
		58;

	/** ISTORE_0. */
	int ISTORE_0 =
		59;

	/** ISTORE_1. */
	int ISTORE_1 =
		60;

	/** ISTORE_2. */
	int ISTORE_2 =
		61;

	/** ISTORE_3. */
	int ISTORE_3 =
		62;

	/** LSTORE_0. */
	int LSTORE_0 =
		63;

	/** LSTORE_1. */
	int LSTORE_1 =
		64;

	/** LSTORE_2. */
	int LSTORE_2 =
		65;

	/** LSTORE_3. */
	int LSTORE_3 =
		66;

	/** FSTORE_0. */
	int FSTORE_0 =
		67;

	/** FSTORE_1. */
	int FSTORE_1 =
		68;

	/** FSTORE_2. */
	int FSTORE_2 =
		69;

	/** FSTORE_3. */
	int FSTORE_3 =
		70;

	/** DSTORE_0. */
	int DSTORE_0 =
		71;

	/** DSTORE_1. */
	int DSTORE_1 =
		72;

	/** DSTORE_2. */
	int DSTORE_2 =
		73;

	/** DSTORE_3. */
	int DSTORE_3 =
		74;

	/** ASTORE_0. */
	int ASTORE_0 =
		75;

	/** ASTORE_1. */
	int ASTORE_1 =
		76;

	/** ASTORE_2. */
	int ASTORE_2 =
		77;

	/** ASTORE_3. */
	int ASTORE_3 =
		78;

	/** IASTORE. */
	int IASTORE =
		79;

	/** LASTORE. */
	int LASTORE =
		80;

	/** FASTORE. */
	int FASTORE =
		81;

	/** DASTORE. */
	int DASTORE =
		82;

	/** AASTORE. */
	int AASTORE =
		83;

	/** BASTORE. */
	int BASTORE =
		84;

	/** CASTORE. */
	int CASTORE =
		85;

	/** SASTORE. */
	int SASTORE =
		86;

	/** POP. */
	int POP =
		87;

	/** POP2. */
	int POP2 =
		88;

	/** DUP. */
	int DUP =
		89;

	/** DUP_X1. */
	int DUP_X1 =
		90;

	/** DUP_X2. */
	int DUP_X2 =
		91;

	/** DUP2. */
	int DUP2 =
		92;

	/** DUP2_X1. */
	int DUP2_X1 =
		93;

	/** DUP2_X2. */
	int DUP2_X2 =
		94;

	/** SWAP. */
	int SWAP =
		95;

	/** IADD. */
	int IADD =
		96;

	/** LADD. */
	int LADD =
		97;

	/** FADD. */
	int FADD =
		98;

	/** DADD. */
	int DADD =
		99;

	/** ISUB. */
	int ISUB =
		100;

	/** LSUB. */
	int LSUB =
		101;

	/** FSUB. */
	int FSUB =
		102;

	/** DSUB. */
	int DSUB =
		103;

	/** IMUL. */
	int IMUL =
		104;

	/** LMUL. */
	int LMUL =
		105;

	/** FMUL. */
	int FMUL =
		106;

	/** DMUL. */
	int DMUL =
		107;

	/** IDIV. */
	int IDIV =
		108;

	/** LDIV. */
	int LDIV =
		109;

	/** FDIV. */
	int FDIV =
		110;

	/** DDIV. */
	int DDIV =
		111;

	/** IREM. */
	int IREM =
		112;

	/** LREM. */
	int LREM =
		113;

	/** FREM. */
	int FREM =
		114;

	/** DREM. */
	int DREM =
		115;

	/** INEG. */
	int INEG =
		116;

	/** LNEG. */
	int LNEG =
		117;

	/** FNEG. */
	int FNEG =
		118;

	/** DNEG. */
	int DNEG =
		119;

	/** ISHL. */
	int ISHL =
		120;

	/** LSHL. */
	int LSHL =
		121;

	/** ISHR. */
	int ISHR =
		122;

	/** LSHR. */
	int LSHR =
		123;

	/** IUSHR. */
	int IUSHR =
		124;

	/** LUSHR. */
	int LUSHR =
		125;

	/** IAND. */
	int IAND =
		126;

	/** LAND. */
	int LAND =
		127;

	/** IOR. */
	int IOR =
		128;

	/** LOR. */
	int LOR =
		129;

	/** IXOR. */
	int IXOR =
		130;

	/** LXOR. */
	int LXOR =
		131;

	/** IINC. */
	int IINC =
		132;

	/** I2L. */
	int I2L =
		133;

	/** I2F. */
	int I2F =
		134;

	/** I2D. */
	int I2D =
		135;

	/** L2I. */
	int L2I =
		136;

	/** L2F. */
	int L2F =
		137;

	/** L2D. */
	int L2D =
		138;

	/** F2I. */
	int F2I =
		139;

	/** F2L. */
	int F2L =
		140;

	/** F2D. */
	int F2D =
		141;

	/** D2I. */
	int D2I =
		142;

	/** D2L. */
	int D2L =
		143;

	/** D2F. */
	int D2F =
		144;

	/** I2B. */
	int I2B =
		145;

	/** I2C. */
	int I2C =
		146;

	/** I2S. */
	int I2S =
		147;

	/** LCMP. */
	int LCMP =
		148;

	/** FCMPL. */
	int FCMPL =
		149;

	/** FCMPG. */
	int FCMPG =
		150;

	/** DCMPL. */
	int DCMPL =
		151;

	/** DCMPG. */
	int DCMPG =
		152;

	/** IFEQ. */
	int IFEQ =
		153;

	/** IFNE. */
	int IFNE =
		154;

	/** IFLT. */
	int IFLT =
		155;

	/** IFGE. */
	int IFGE =
		156;

	/** IFGT. */
	int IFGT =
		157;

	/** IFLE. */
	int IFLE =
		158;

	/** IF_ICMPEQ. */
	int IF_ICMPEQ =
		159;

	/** IF_ICMPNE. */
	int IF_ICMPNE =
		160;

	/** IF_ICMPLT. */
	int IF_ICMPLT =
		161;

	/** IF_ICMPGE. */
	int IF_ICMPGE =
		162;

	/** IF_ICMPGT. */
	int IF_ICMPGT =
		163;

	/** IF_ICMPLE. */
	int IF_ICMPLE =
		164;

	/** IF_ACMPEQ. */
	int IF_ACMPEQ =
		165;

	/** IF_ACMPNE. */
	int IF_ACMPNE =
		166;

	/** GOTO. */
	int GOTO =
		167;

	/** JSR. */
	int JSR =
		168;

	/** RET. */
	int RET =
		169;

	/** TABLESWITCH. */
	int TABLESWITCH =
		170;

	/** LOOKUPSWITCH. */
	int LOOKUPSWITCH =
		171;

	/** IRETURN. */
	int IRETURN =
		172;

	/** LRETURN. */
	int LRETURN =
		173;

	/** FRETURN. */
	int FRETURN =
		174;

	/** DRETURN. */
	int DRETURN =
		175;

	/** ARETURN. */
	int ARETURN =
		176;

	/** RETURN. */
	int RETURN =
		177;

	/** GETSTATIC. */
	int GETSTATIC =
		178;

	/** PUTSTATIC. */
	int PUTSTATIC =
		179;

	/** GETFIELD. */
	int GETFIELD =
		180;

	/** PUTFIELD. */
	int PUTFIELD =
		181;

	/** INVOKEVIRTUAL. */
	int INVOKEVIRTUAL =
		182;

	/** INVOKESPECIAL. */
	int INVOKESPECIAL =
		183;

	/** INVOKESTATIC. */
	int INVOKESTATIC =
		184;

	/** INVOKEINTERFACE. */
	int INVOKEINTERFACE =
		185;

	/** INVOKEDYNAMIC. */
	int INVOKEDYNAMIC =
		186;

	/** NEW. */
	int NEW =
		187;

	/** NEWARRAY. */
	int NEWARRAY =
		188;

	/** ANEWARRAY. */
	int ANEWARRAY =
		189;

	/** ARRAYLENGTH. */
	int ARRAYLENGTH =
		190;

	/** ATHROW. */
	int ATHROW =
		191;

	/** CHECKCAST. */
	int CHECKCAST =
		192;

	/** INSTANCEOF. */
	int INSTANCEOF =
		193;

	/** MONITORENTER. */
	int MONITORENTER =
		194;

	/** MONITOREXIT. */
	int MONITOREXIT =
		195;

	/** WIDE. */
	int WIDE =
		196;

	/** MULTIANEWARRAY. */
	int MULTIANEWARRAY =
		197;

	/** IFNULL. */
	int IFNULL =
		198;

	/** IFNONNULL. */
	int IFNONNULL =
		199;

	/** GOTO_W. */
	int GOTO_W =
		200;

	/** JSR_W. */
	int JSR_W =
		201;

	/** BREAKPOINT. */
	int BREAKPOINT =
		202;

	/** IMPDEP1. */
	int IMPDEP1 =
		254;

	/** IMPDEP2. */
	int IMPDEP2 =
		255;

	/** Wide ALOAD. */
	int WIDE_ALOAD =
		(InstructionIndex.WIDE << 8) | InstructionIndex.ALOAD;

	/** Wide ILOAD. */
	int WIDE_ILOAD =
		(InstructionIndex.WIDE << 8) | InstructionIndex.ILOAD;

	/** Wide LLOAD. */
	int WIDE_LLOAD =
		(InstructionIndex.WIDE << 8) | InstructionIndex.LLOAD;

	/** Wide FLOAD. */
	int WIDE_FLOAD =
		(InstructionIndex.WIDE << 8) | InstructionIndex.FLOAD;

	/** Wide DLOAD. */
	int WIDE_DLOAD =
		(InstructionIndex.WIDE << 8) | InstructionIndex.DLOAD;

	/** Wide ASTORE. */
	int WIDE_ASTORE =
		(InstructionIndex.WIDE << 8) | InstructionIndex.ASTORE;

	/** Wide ISTORE. */
	int WIDE_ISTORE =
		(InstructionIndex.WIDE << 8) | InstructionIndex.ISTORE;

	/** Wide LSTORE. */
	int WIDE_LSTORE =
		(InstructionIndex.WIDE << 8) | InstructionIndex.LSTORE;

	/** Wide FSTORE. */
	int WIDE_FSTORE =
		(InstructionIndex.WIDE << 8) | InstructionIndex.FSTORE;

	/** Wide DSTORE. */
	int WIDE_DSTORE =
		(InstructionIndex.WIDE << 8) | InstructionIndex.DSTORE;
	
	/** Wide IINC. */
	int WIDE_IINC =
		(InstructionIndex.WIDE << 8) | InstructionIndex.IINC;
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a branch or jump target that may be used by instructions.
 *
 * @since 2018/09/15
 */
public final class InstructionJumpTarget
	implements Comparable<InstructionJumpTarget>
{
	/** The value. */
	protected final int target;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the jump target.
	 *
	 * @param __t The target.
	 * @throws IllegalArgumentException If the target is negative.
	 * @since 2018/09/15
	 */
	public InstructionJumpTarget(int __t)
		throws IllegalArgumentException
	{
		// {@squirreljme.error JC3b Jump target is negative. (The target)}
		if (__t < 0)
			throw new IllegalArgumentException(String.format("JC3b %d", __t));
		
		this.target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final int compareTo(InstructionJumpTarget __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		return this.target - __o.target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof InstructionJumpTarget))
			return false;
		
		return this.target == ((InstructionJumpTarget)__o).target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final int hashCode()
	{
		return this.target;
	}
	
	/**
	 * Returns the target address of the jump.
	 *
	 * @return The jump target address.
	 * @since 2018/09/15
	 */
	public final int target()
	{
		return this.target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = String.format("->@%d", this.target)));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/InstructionJumpTargets.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * This represents the targets of jumps that an instruction may jump to.
 *
 * @since 2019/03/30
 */
public final class InstructionJumpTargets
{
	/** Normal jumps. */
	private final InstructionJumpTarget[] _normal;
	
	/** Exceptional jumps. */
	private final InstructionJumpTarget[] _exception;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hashcode. */
	private int _hash;
	
	/**
	 * Initializes empty jump targets.
	 *
	 * @since 2019/04/11
	 */
	public InstructionJumpTargets()
	{
		this._normal = new InstructionJumpTarget[0];
		this._exception = new InstructionJumpTarget[0];
	}
	
	/**
	 * Initializes the jump targets.
	 * @param __n Normal jumps.
	 * @param __e Exceptional jumps.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public InstructionJumpTargets(InstructionJumpTarget[] __n,
		InstructionJumpTarget[] __e)
		throws NullPointerException
	{
		if (__n == null || __e == null)
			throw new NullPointerException("NARG");
		
		// Load into sorted sets
		Set<InstructionJumpTarget> nrm = new SortedTreeSet<>(),
			exe = new SortedTreeSet<>();
		
		// Add normals
		for (InstructionJumpTarget i : __n)
			if (i == null)
				throw new NullPointerException("NARG");
			else
				nrm.add(i);
		
		// Add exceptional
		for (InstructionJumpTarget i : __e)
			if (i == null)
				throw new NullPointerException("NARG");
			else
				exe.add(i);
		
		// Set
		this._normal = nrm.<InstructionJumpTarget>toArray(
			new InstructionJumpTarget[nrm.size()]);
		this._exception = exe.<InstructionJumpTarget>toArray(
			new InstructionJumpTarget[exe.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Obtains the given jump target.
	 *
	 * @param __i The index.
	 * @return The target jump target.
	 * @since 2019/03/31
	 */
	public final InstructionJumpTarget get(int __i)
	{
		InstructionJumpTarget[] normal = this._normal;
		int numnormal = normal.length;
		
		// Treat both arrays as a single part
		if (__i >= numnormal)
			return this._exception[__i - numnormal];
		return this._normal[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks if any of the jump targets has an address which follows the
	 * given address.
	 *
	 * @param __pc The address to check.
	 * @return True if any address in the jump targets has an address which
	 * is higher than this address.
	 * @since 2019/03/30
	 */
	public final boolean hasLaterAddress(int __pc)
	{
		for (int i = 0, n = this.size(); i < n; i++)
			if (this.get(i).target() > __pc)
				return true;
		
		return false;
	}
	
	/**
	 * Checks if any of the jump targets has an address which is or follows
	 * the given address.
	 *
	 * @param __pc The address to check.
	 * @return True if any address in the jump targets has an address which
	 * is the same or higher than this address.
	 * @since 2019/04/11
	 */
	public final boolean hasSameOrLaterAddress(int __pc)
	{
		for (int i = 0, n = this.size(); i < n; i++)
			if (this.get(i).target() >= __pc)
				return true;
		
		return false;
	}
	
	/**
	 * Returns if this is empty or not.
	 *
	 * @return If this is empty or not.
	 * @since 2019/03/31
	 */
	public final boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * Returns if this is an exception jump.
	 *
	 * @param __i The index to get.
	 * @return If this is an exception index.
	 * @since 2019/03/31
	 */
	public final boolean isException(int __i)
	{
		return __i >= this._normal.length;
	}
	
	/**
	 * Returns the number of jump targets.
	 *
	 * @return The number of jump targets.
	 * @since 2019/03/31
	 */
	public final int size()
	{
		return this._normal.length + this._exception.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				"[N:" + Arrays.asList(this._normal) +
				", E: " + Arrays.asList(this._exception) + "]"));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/InstructionMnemonics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This contains instruction mnemonics.
 *
 * @since 2017/05/20
 */
public final class InstructionMnemonics
{
	/**
	 * Not used.
	 *
	 * @since 2017/05/29
	 */
	private InstructionMnemonics()
	{
	}
	
	/**
	 * Returns the instruction mnemonic.
	 *
	 * @param __op The operation to get.
	 * @return The mnemonic for the instruction.
	 * @since 2017/05/20
	 */
	public static String toString(int __op)
	{
		switch (__op)
		{
			case InstructionIndex.NOP: return "NOP";
			case InstructionIndex.ACONST_NULL: return "ACONST_NULL";
			case InstructionIndex.ICONST_M1: return "ICONST_M1";
			case InstructionIndex.ICONST_0: return "ICONST_0";
			case InstructionIndex.ICONST_1: return "ICONST_1";
			case InstructionIndex.ICONST_2: return "ICONST_2";
			case InstructionIndex.ICONST_3: return "ICONST_3";
			case InstructionIndex.ICONST_4: return "ICONST_4";
			case InstructionIndex.ICONST_5: return "ICONST_5";
			case InstructionIndex.LCONST_0: return "LCONST_0";
			case InstructionIndex.LCONST_1: return "LCONST_1";
			case InstructionIndex.FCONST_0: return "FCONST_0";
			case InstructionIndex.FCONST_1: return "FCONST_1";
			case InstructionIndex.FCONST_2: return "FCONST_2";
			case InstructionIndex.DCONST_0: return "DCONST_0";
			case InstructionIndex.DCONST_1: return "DCONST_1";
			case InstructionIndex.BIPUSH: return "BIPUSH";
			case InstructionIndex.SIPUSH: return "SIPUSH";
			case InstructionIndex.LDC: return "LDC";
			case InstructionIndex.LDC_W: return "LDC_W";
			case InstructionIndex.LDC2_W: return "LDC2_W";
			case InstructionIndex.ILOAD: return "ILOAD";
			case InstructionIndex.LLOAD: return "LLOAD";
			case InstructionIndex.FLOAD: return "FLOAD";
			case InstructionIndex.DLOAD: return "DLOAD";
			case InstructionIndex.ALOAD: return "ALOAD";
			case InstructionIndex.ILOAD_0: return "ILOAD_0";
			case InstructionIndex.ILOAD_1: return "ILOAD_1";
			case InstructionIndex.ILOAD_2: return "ILOAD_2";
			case InstructionIndex.ILOAD_3: return "ILOAD_3";
			case InstructionIndex.LLOAD_0: return "LLOAD_0";
			case InstructionIndex.LLOAD_1: return "LLOAD_1";
			case InstructionIndex.LLOAD_2: return "LLOAD_2";
			case InstructionIndex.LLOAD_3: return "LLOAD_3";
			case InstructionIndex.FLOAD_0: return "FLOAD_0";
			case InstructionIndex.FLOAD_1: return "FLOAD_1";
			case InstructionIndex.FLOAD_2: return "FLOAD_2";
			case InstructionIndex.FLOAD_3: return "FLOAD_3";
			case InstructionIndex.DLOAD_0: return "DLOAD_0";
			case InstructionIndex.DLOAD_1: return "DLOAD_1";
			case InstructionIndex.DLOAD_2: return "DLOAD_2";
			case InstructionIndex.DLOAD_3: return "DLOAD_3";
			case InstructionIndex.ALOAD_0: return "ALOAD_0";
			case InstructionIndex.ALOAD_1: return "ALOAD_1";
			case InstructionIndex.ALOAD_2: return "ALOAD_2";
			case InstructionIndex.ALOAD_3: return "ALOAD_3";
			case InstructionIndex.IALOAD: return "IALOAD";
			case InstructionIndex.LALOAD: return "LALOAD";
			case InstructionIndex.FALOAD: return "FALOAD";
			case InstructionIndex.DALOAD: return "DALOAD";
			case InstructionIndex.AALOAD: return "AALOAD";
			case InstructionIndex.BALOAD: return "BALOAD";
			case InstructionIndex.CALOAD: return "CALOAD";
			case InstructionIndex.SALOAD: return "SALOAD";
			case InstructionIndex.ISTORE: return "ISTORE";
			case InstructionIndex.LSTORE: return "LSTORE";
			case InstructionIndex.FSTORE: return "FSTORE";
			case InstructionIndex.DSTORE: return "DSTORE";
			case InstructionIndex.ASTORE: return "ASTORE";
			case InstructionIndex.ISTORE_0: return "ISTORE_0";
			case InstructionIndex.ISTORE_1: return "ISTORE_1";
			case InstructionIndex.ISTORE_2: return "ISTORE_2";
			case InstructionIndex.ISTORE_3: return "ISTORE_3";
			case InstructionIndex.LSTORE_0: return "LSTORE_0";
			case InstructionIndex.LSTORE_1: return "LSTORE_1";
			case InstructionIndex.LSTORE_2: return "LSTORE_2";
			case InstructionIndex.LSTORE_3: return "LSTORE_3";
			case InstructionIndex.FSTORE_0: return "FSTORE_0";
			case InstructionIndex.FSTORE_1: return "FSTORE_1";
			case InstructionIndex.FSTORE_2: return "FSTORE_2";
			case InstructionIndex.FSTORE_3: return "FSTORE_3";
			case InstructionIndex.DSTORE_0: return "DSTORE_0";
			case InstructionIndex.DSTORE_1: return "DSTORE_1";
			case InstructionIndex.DSTORE_2: return "DSTORE_2";
			case InstructionIndex.DSTORE_3: return "DSTORE_3";
			case InstructionIndex.ASTORE_0: return "ASTORE_0";
			case InstructionIndex.ASTORE_1: return "ASTORE_1";
			case InstructionIndex.ASTORE_2: return "ASTORE_2";
			case InstructionIndex.ASTORE_3: return "ASTORE_3";
			case InstructionIndex.IASTORE: return "IASTORE";
			case InstructionIndex.LASTORE: return "LASTORE";
			case InstructionIndex.FASTORE: return "FASTORE";
			case InstructionIndex.DASTORE: return "DASTORE";
			case InstructionIndex.AASTORE: return "AASTORE";
			case InstructionIndex.BASTORE: return "BASTORE";
			case InstructionIndex.CASTORE: return "CASTORE";
			case InstructionIndex.SASTORE: return "SASTORE";
			case InstructionIndex.POP: return "POP";
			case InstructionIndex.POP2: return "POP2";
			case InstructionIndex.DUP: return "DUP";
			case InstructionIndex.DUP_X1: return "DUP_X1";
			case InstructionIndex.DUP_X2: return "DUP_X2";
			case InstructionIndex.DUP2: return "DUP2";
			case InstructionIndex.DUP2_X1: return "DUP2_X1";
			case InstructionIndex.DUP2_X2: return "DUP2_X2";
			case InstructionIndex.SWAP: return "SWAP";
			case InstructionIndex.IADD: return "IADD";
			case InstructionIndex.LADD: return "LADD";
			case InstructionIndex.FADD: return "FADD";
			case InstructionIndex.DADD: return "DADD";
			case InstructionIndex.ISUB: return "ISUB";
			case InstructionIndex.LSUB: return "LSUB";
			case InstructionIndex.FSUB: return "FSUB";
			case InstructionIndex.DSUB: return "DSUB";
			case InstructionIndex.IMUL: return "IMUL";
			case InstructionIndex.LMUL: return "LMUL";
			case InstructionIndex.FMUL: return "FMUL";
			case InstructionIndex.DMUL: return "DMUL";
			case InstructionIndex.IDIV: return "IDIV";
			case InstructionIndex.LDIV: return "LDIV";
			case InstructionIndex.FDIV: return "FDIV";
			case InstructionIndex.DDIV: return "DDIV";
			case InstructionIndex.IREM: return "IREM";
			case InstructionIndex.LREM: return "LREM";
			case InstructionIndex.FREM: return "FREM";
			case InstructionIndex.DREM: return "DREM";
			case InstructionIndex.INEG: return "INEG";
			case InstructionIndex.LNEG: return "LNEG";
			case InstructionIndex.FNEG: return "FNEG";
			case InstructionIndex.DNEG: return "DNEG";
			case InstructionIndex.ISHL: return "ISHL";
			case InstructionIndex.LSHL: return "LSHL";
			case InstructionIndex.ISHR: return "ISHR";
			case InstructionIndex.LSHR: return "LSHR";
			case InstructionIndex.IUSHR: return "IUSHR";
			case InstructionIndex.LUSHR: return "LUSHR";
			case InstructionIndex.IAND: return "IAND";
			case InstructionIndex.LAND: return "LAND";
			case InstructionIndex.IOR: return "IOR";
			case InstructionIndex.LOR: return "LOR";
			case InstructionIndex.IXOR: return "IXOR";
			case InstructionIndex.LXOR: return "LXOR";
			case InstructionIndex.IINC: return "IINC";
			case InstructionIndex.I2L: return "I2L";
			case InstructionIndex.I2F: return "I2F";
			case InstructionIndex.I2D: return "I2D";
			case InstructionIndex.L2I: return "L2I";
			case InstructionIndex.L2F: return "L2F";
			case InstructionIndex.L2D: return "L2D";
			case InstructionIndex.F2I: return "F2I";
			case InstructionIndex.F2L: return "F2L";
			case InstructionIndex.F2D: return "F2D";
			case InstructionIndex.D2I: return "D2I";
			case InstructionIndex.D2L: return "D2L";
			case InstructionIndex.D2F: return "D2F";
			case InstructionIndex.I2B: return "I2B";
			case InstructionIndex.I2C: return "I2C";
			case InstructionIndex.I2S: return "I2S";
			case InstructionIndex.LCMP: return "LCMP";
			case InstructionIndex.FCMPL: return "FCMPL";
			case InstructionIndex.FCMPG: return "FCMPG";
			case InstructionIndex.DCMPL: return "DCMPL";
			case InstructionIndex.DCMPG: return "DCMPG";
			case InstructionIndex.IFEQ: return "IFEQ";
			case InstructionIndex.IFNE: return "IFNE";
			case InstructionIndex.IFLT: return "IFLT";
			case InstructionIndex.IFGE: return "IFGE";
			case InstructionIndex.IFGT: return "IFGT";
			case InstructionIndex.IFLE: return "IFLE";
			case InstructionIndex.IF_ICMPEQ: return "IF_ICMPEQ";
			case InstructionIndex.IF_ICMPNE: return "IF_ICMPNE";
			case InstructionIndex.IF_ICMPLT: return "IF_ICMPLT";
			case InstructionIndex.IF_ICMPGE: return "IF_ICMPGE";
			case InstructionIndex.IF_ICMPGT: return "IF_ICMPGT";
			case InstructionIndex.IF_ICMPLE: return "IF_ICMPLE";
			case InstructionIndex.IF_ACMPEQ: return "IF_ACMPEQ";
			case InstructionIndex.IF_ACMPNE: return "IF_ACMPNE";
			case InstructionIndex.GOTO: return "GOTO";
			case InstructionIndex.JSR: return "JSR";
			case InstructionIndex.RET: return "RET";
			case InstructionIndex.TABLESWITCH: return "TABLESWITCH";
			case InstructionIndex.LOOKUPSWITCH: return "LOOKUPSWITCH";
			case InstructionIndex.IRETURN: return "IRETURN";
			case InstructionIndex.LRETURN: return "LRETURN";
			case InstructionIndex.FRETURN: return "FRETURN";
			case InstructionIndex.DRETURN: return "DRETURN";
			case InstructionIndex.ARETURN: return "ARETURN";
			case InstructionIndex.RETURN: return "RETURN";
			case InstructionIndex.GETSTATIC: return "GETSTATIC";
			case InstructionIndex.PUTSTATIC: return "PUTSTATIC";
			case InstructionIndex.GETFIELD: return "GETFIELD";
			case InstructionIndex.PUTFIELD: return "PUTFIELD";
			case InstructionIndex.INVOKEVIRTUAL: return "INVOKEVIRTUAL";
			case InstructionIndex.INVOKESPECIAL: return "INVOKESPECIAL";
			case InstructionIndex.INVOKESTATIC: return "INVOKESTATIC";
			case InstructionIndex.INVOKEINTERFACE: return "INVOKEINTERFACE";
			case InstructionIndex.INVOKEDYNAMIC: return "INVOKEDYNAMIC";
			case InstructionIndex.NEW: return "NEW";
			case InstructionIndex.NEWARRAY: return "NEWARRAY";
			case InstructionIndex.ANEWARRAY: return "ANEWARRAY";
			case InstructionIndex.ARRAYLENGTH: return "ARRAYLENGTH";
			case InstructionIndex.ATHROW: return "ATHROW";
			case InstructionIndex.CHECKCAST: return "CHECKCAST";
			case InstructionIndex.INSTANCEOF: return "INSTANCEOF";
			case InstructionIndex.MONITORENTER: return "MONITORENTER";
			case InstructionIndex.MONITOREXIT: return "MONITOREXIT";
			case InstructionIndex.WIDE: return "WIDE";
			case InstructionIndex.MULTIANEWARRAY: return "MULTIANEWARRAY";
			case InstructionIndex.IFNULL: return "IFNULL";
			case InstructionIndex.IFNONNULL: return "IFNONNULL";
			case InstructionIndex.GOTO_W: return "GOTO_W";
			case InstructionIndex.JSR_W: return "JSR_W";
			case InstructionIndex.BREAKPOINT: return "BREAKPOINT";
			case InstructionIndex.IMPDEP1: return "IMPDEP1";
			case InstructionIndex.IMPDEP2: return "IMPDEP2";
			case InstructionIndex.WIDE_ALOAD: return "WIDE_ALOAD";
			case InstructionIndex.WIDE_ILOAD: return "WIDE_ILOAD";
			case InstructionIndex.WIDE_LLOAD: return "WIDE_LLOAD";
			case InstructionIndex.WIDE_FLOAD: return "WIDE_FLOAD";
			case InstructionIndex.WIDE_DLOAD: return "WIDE_DLOAD";
			case InstructionIndex.WIDE_ASTORE: return "WIDE_ASTORE";
			case InstructionIndex.WIDE_ISTORE: return "WIDE_ISTORE";
			case InstructionIndex.WIDE_LSTORE: return "WIDE_LSTORE";
			case InstructionIndex.WIDE_FSTORE: return "WIDE_FSTORE";
			case InstructionIndex.WIDE_DSTORE: return "WIDE_DSTORE";
			case InstructionIndex.WIDE_IINC: return "WIDE_IINC";
			
				// Unknown
			default:
				return String.format("UNKNOWN_%04X", __op);
		}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This interface represents a jump table which matches based on an input
 * integer.
 *
 * @since 2018/09/20
 */
public interface IntMatchingJumpTable
{
	/**
	 * Matches the input key with the given jump target or returns the default.
	 *
	 * @param __k The key to match.
	 * @return The jump target for the match or the default if it was not
	 * found.
	 * @since 2018/09/20
	 */
	InstructionJumpTarget match(int __k);
	
	/**
	 * Returns all of the used jump targets.
	 *
	 * @return The used jump targets.
	 * @since 2019/03/31
	 */
	InstructionJumpTarget[] targets();
}

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

package net.multiphasicapps.classfile;

/**
 * This is thrown when the format of a class is not valid.
 *
 * @since 2017/09/27
 */
public class InvalidClassFormatException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(Throwable __c)
	{
		super(__c);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/JavaType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a type which may be used on the stack or within local
 * variables within the virtual machine.
 *
 * @since 2017/07/26
 */
public final class JavaType
{
	/** The top of a long. */
	public static final JavaType TOP_LONG =
		new JavaType(1);
	
	/** The top of a double. */
	public static final JavaType TOP_DOUBLE =
		new JavaType(2);
	
	/** Top of an undefined type. */
	public static final JavaType TOP_UNDEFINED =
		new JavaType(3);
	
	/** Nothing. */
	public static final JavaType NOTHING =
		new JavaType(4);
	
	/** Integer. */
	public static final JavaType INTEGER =
		new JavaType(new FieldDescriptor("I"));
	
	/** Long. */
	public static final JavaType LONG =
		new JavaType(new FieldDescriptor("J"));
	
	/** Float. */
	public static final JavaType FLOAT =
		new JavaType(new FieldDescriptor("F"));
	
	/** Double. */
	public static final JavaType DOUBLE =
		new JavaType(new FieldDescriptor("D"));
	
	/** Plain object. */
	public static final JavaType OBJECT =
		new JavaType(new FieldDescriptor("Ljava/lang/Object;"));
	
	/** Throwable. */
	public static final JavaType THROWABLE =
		new JavaType(new FieldDescriptor("Ljava/lang/Throwable;"));
	
	/** The type this refers to. */
	protected final FieldDescriptor type;
	
	/** Internal property. */
	private final int _internal;
	
	/** String representation of this table. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map type.
	 *
	 * @param __cn The name of the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public JavaType(ClassName __cn)
		throws NullPointerException
	{
		this(new FieldDescriptor((__cn.isArray() ? __cn.toString() :
			"L" + __cn + ";")));
	}
	
	/**
	 * Initializes the stack map type.
	 *
	 * @param __f The field type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public JavaType(FieldDescriptor __f)
		throws IllegalStateException, NullPointerException
	{
		// Check
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Promote to integer since the VM does not have a representation for
		// types smaller than int
		PrimitiveType p = __f.primitiveType();
		if (p != null && p.promotesToInt())
			__f = new FieldDescriptor("I");
		
		// Set
		this._internal = 0;
		this.type = __f;
	}
	
	/**
	 * Used internally to create special non-comparable types.
	 *
	 * @param __i Internal identifier.
	 * @throws RuntimeException If the internal value is zero.
	 * @since 2017/07/28
	 */
	private JavaType(int __i)
		throws RuntimeException
	{
		// Check
		if (__i == 0)
			throw new todo.OOPS();
		
		this._internal = __i;
		this.type = null;
	}
	
	/**
	 * Returns the class name of the type.
	 *
	 * @return The type class name.
	 * @since 2019/05/24
	 */
	public final ClassName className()
	{
		FieldDescriptor type = this.type;
		if (type == null)
			return null;
		return type.className();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof JavaType))
			return false;
		
		JavaType o = (JavaType)__o;
		return this._internal == o._internal &&
			Objects.equals(this.type, o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public int hashCode()
	{
		return this._internal ^ Objects.hashCode(this.type);
	}
	
	/**
	 * Is this an array type?
	 *
	 * @return True if this is an array.
	 * @since 2019/05/25
	 */
	public final boolean isArray()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isObject() && type.isArray());
	}
	
	/**
	 * Is this an object type?
	 *
	 * @return {@code true} if this is an object type.
	 * @since 2017/08/13
	 */
	public boolean isObject()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isObject());
	}
	
	/**
	 * Is this a primitive type?
	 *
	 * @return {@code true} if this is a primitive type.
	 * @since 2017/08/13
	 */
	public boolean isPrimitive()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isPrimitive());
	}
	
	/**
	 * Is this the nothing type?
	 *
	 * @return If this is the nothing type.
	 * @since 2017/10/20
	 */
	public boolean isNothing()
	{
		return this.equals(JavaType.NOTHING);
	}
	
	/**
	 * Is this a top type?
	 *
	 * @return If this is a top type or not.
	 * @since 2017/09/16
	 */
	public boolean isTop()
	{
		return this.equals(JavaType.TOP_LONG) || this.equals(JavaType.TOP_DOUBLE) || this
			.equals(
			JavaType.TOP_UNDEFINED);
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return {@code true} if the type is a wide type.
	 * @since 2017/07/28
	 */
	public boolean isWide()
	{
		FieldDescriptor type = this.type;
		if (type == null)
			return false;
		PrimitiveType pt = type.primitiveType();
		return pt != null && pt.isWide();
	}
	
	/**
	 * Returns the type that is used for the top type.
	 *
	 * @return The associated top type used for this type or {@code null} if
	 * there is none.
	 * @since 2017/07/28
	 */
	public JavaType topType()
	{
		PrimitiveType pt = this.type.primitiveType();
		if (pt == null)
			return null;
		
		switch (pt)
		{
			case LONG:		return JavaType.TOP_LONG;
			case DOUBLE:	return JavaType.TOP_DOUBLE;
			default:
				return null;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public String toString()
	{
		// Unknown
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Fixed type
			if (this.equals(JavaType.TOP_LONG))
				rv = "top-long";
			else if (this.equals(JavaType.TOP_DOUBLE))
				rv = "top-double";
			else if (this.equals(JavaType.TOP_UNDEFINED))
				rv = "top-undefined";
			else if (this.equals(JavaType.NOTHING))
				rv = "nothing";
			
			// Other
			else
				rv = this.type.toString();
			
			// Cache
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * Returns the type for this type.
	 *
	 * @return The type used.
	 * @since 2017/09/19
	 */
	public FieldDescriptor type()
	{
		return this.type;
	}
	
	/**
	 * Returns the width of the type.
	 *
	 * @return The width of the type.
	 * @since 2017/09/03
	 */
	public int width()
	{
		return (this.isWide() ? 2 : 1);
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/LookupSwitch.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/**
 * This class represents a lookup switch which is used to lookup indexes as a
 * jump table.
 *
 * @since 2018/09/20
 */
public final class LookupSwitch
	implements IntMatchingJumpTable
{
	/** The default target. */
	protected final InstructionJumpTarget defaultjump;
	
	/** The keys. */
	private final int[] _keys;
	
	/** The jump targets. */
	private final InstructionJumpTarget[] _jumps;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the lookup switch.
	 *
	 * @param __def The default address if no values match at all.
	 * @param __keys The keys to check, must be sorted.
	 * @param __jumps The jump targets.
	 * @throws IllegalArgumentException If the key and jump table length are
	 * difference lengths.
	 * @throws InvalidClassFormatException If the key table is not sorted.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public LookupSwitch(InstructionJumpTarget __def,
		int[] __keys, InstructionJumpTarget[] __jumps)
		throws IllegalArgumentException, InvalidClassFormatException,
			NullPointerException
	{
		if (__def == null || __keys == null || __jumps == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3c Key and jump table for lookup switch
		// table is of different lengths.}
		if (__keys.length != __jumps.length)
			throw new IllegalArgumentException("JC3c");
		
		// Defensive copy
		__keys = __keys.clone();
		__jumps = __jumps.clone();
		
		// Check for sorted
		long last = ((long)Integer.MIN_VALUE) - 1;
		for (int i = 0, n = __keys.length; i < n; i++)
		{
			// {@squirreljme.error JC3d Lookup switch key is not in sorted
			// order. (The index; The current key; The last key)}
			int k = __keys[i];
			if (k < last)
				throw new InvalidClassFormatException(
					String.format("JC3d %d %d %d", i, k, last));
			last = k;
			
			if (__jumps[i] == null)
				throw new NullPointerException("NARG");
		}
		
		this.defaultjump = __def;
		this._keys = __keys;
		this._jumps = __jumps;
	}
	
	/**
	 * Returns the default jump.
	 *
	 * @return The default jump.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget defaultJump()
	{
		return this.defaultjump;
	}
	
	/**
	 * Returns the jumps.
	 *
	 * @return The jumps.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget[] jumps()
	{
		return this._jumps.clone();
	}
	
	/**
	 * Returns the keys.
	 *
	 * @return The keys.
	 * @since 2019/04/16
	 */
	public final int[] keys()
	{
		return this._keys.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final InstructionJumpTarget match(int __k)
	{
		// Use binary search since all entries are sorted
		int dx = Arrays.binarySearch(this._keys, __k);
		
		// Match was found, use that result
		if (dx >= 0)
			return this._jumps[dx];
		
		// Not found
		return this.defaultjump;
	}
	
	/**
	 * Returns the size of the switch.
	 *
	 * @return The size.
	 * @since 2019/04/16
	 */
	public final int size()
	{
		return this._jumps.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/31
	 */
	@Override
	public final InstructionJumpTarget[] targets()
	{
		InstructionJumpTarget[] jumps = this._jumps;
		int n = jumps.length;
		
		// Start off array with the default jump
		InstructionJumpTarget[] rv = new InstructionJumpTarget[n + 1];
		rv[0] = this.defaultjump;
		
		// Add all the others
		for (int i = 0, o = 1; i < n; i++, o++)
			rv[o] = jumps[i];
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Set with default first
			StringBuilder sb = new StringBuilder("{default=");
			sb.append(this.defaultjump);
			
			// Add all matches and their targets
			int[] keys = this._keys;
			InstructionJumpTarget[] jumps = this._jumps;
			for (int i = 0, n = keys.length; i < n; i++)
			{
				sb.append(", ");
				
				sb.append(keys[i]);
				sb.append('=');
				sb.append(jumps[i]);
			}
			
			// Cleans
			sb.append('}');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents the base for members within classes.
 *
 * @since 2017/09/30
 */
public abstract class Member
	implements HasMemberFlags
{
	/**
	 * Initializes the base member.
	 *
	 * @since 2017/09/30
	 */
	Member()
	{
	}
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	public abstract MemberNameAndType nameAndType();
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MemberDescriptor.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents the type of the member.
 *
 * @since 2018/09/09
 */
public interface MemberDescriptor
{
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MemberFlag.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is a flagging interface for flags which are associated with members.
 *
 * @since 2016/04/23
 */
public interface MemberFlag
	extends Flag
{
}

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

package net.multiphasicapps.classfile;

/**
 * This is the base class for flags which are for member types.
 *
 * @param <F> The flag type.
 * @since 2016/04/23
 */
public abstract class MemberFlags<F extends MemberFlag>
	extends Flags<F>
	implements AccessibleFlags
{
	/**
	 * Initializes the member flags.
	 *
	 * @param __cl The required class type.
	 * @param __fl The flags used.
	 * @since 2016/04/23
	 */
	MemberFlags(Class<F> __cl, F[] __fl)
	{
		super(__cl, __fl);
	}
	
	/**
	 * Initializes the member flags.
	 *
	 * @param __cl The required class type.
	 * @param __fl The flags used.
	 * @since 2016/04/23
	 */
	MemberFlags(Class<F> __cl, Iterable<F> __fl)
	{
		super(__cl, __fl);
	}
	
	/**
	 * Returns {@code true} if this is final.
	 *
	 * @return {@code true} if final.
	 * @since 2016/03/20
	 */
	public abstract boolean isFinal();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isPrivate();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isProtected();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isPublic();
	
	/**
	 * Returns {@code true} if this is static.
	 *
	 * @return {@code true} if static.
	 * @since 2016/03/20
	 */
	public abstract boolean isStatic();
	
	/**
	 * Returns {@code true} if this is synthetic.
	 *
	 * @return {@code true} if synthetic.
	 * @since 2016/03/20
	 */
	public abstract boolean isSynthetic();
	
	/**
	 * Is this not static?
	 *
	 * @return If this is not static.
	 * @since 2018/09/09
	 */
	public final boolean isInstance()
	{
		return !this.isStatic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !this.isPublic() && !this.isProtected() && !this.isPrivate();
	}
}

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

package net.multiphasicapps.classfile;

/**
 * Represents the name of a member.
 *
 * @since 2018/09/09
 */
public interface MemberName
{
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2018/09/09
	 */
	String identifier();
}

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

package net.multiphasicapps.classfile;

/**
 * This represents something which is a member and has a member name and type.
 *
 * @since 2018/09/09
 */
public interface MemberNameAndType
{
	/**
	 * Returns the name of the member.
	 *
	 * @return The member name.
	 * @since 2018/09/09
	 */
	MemberName name();
	
	/**
	 * Returns the type of the member.
	 *
	 * @return The member type.
	 * @since 2018/09/09
	 */
	MemberDescriptor type();
}

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

package net.multiphasicapps.classfile;

/**
 * This is the base class for field and method references.
 *
 * @since 2017/06/12
 */
public abstract class MemberReference
{
	/** The class this refers to. */
	protected final ClassName classname;
	
	/**
	 * Initializes the base member reference.
	 *
	 * @param __c The class the member resides in.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	MemberReference(ClassName __c)
		throws NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.classname = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract boolean equals(Object __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * Returns the name of the member being referenced.
	 *
	 * @return The name of the referenced member.
	 * @since 2017/06/12
	 */
	public abstract Identifier memberName();
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	public abstract MemberNameAndType memberNameAndType();
	
	/**
	 * Returns the type of the member.
	 *
	 * @return The member type.
	 * @since 2018/09/09
	 */
	public abstract MemberDescriptor memberType();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract String toString();
	
	/**
	 * Returns the class the member exists within.
	 *
	 * @return The class containing the member.
	 * @since 2017/06/12
	 */
	public final ClassName className()
	{
		return this.classname;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Method.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NearNativeByteCodeHandler;
import dev.shadowtail.classfile.xlate.ByteCodeProcessor;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Set;

/**
 * This represents a method which is used to execute byte code.
 *
 * @since 2017/09/30
 */
public final class Method
	extends Member
	implements Annotated, HasMemberFlags
{
	/** The version of the class. */
	protected final ClassVersion version;
	
	/** The flags for class. */
	protected final ClassFlags classflags;
	
	/** The name of the current class. */
	protected final ClassName classname;
	
	/** The constant pool. */
	protected final Pool pool;
	
	/** The flags for the current method. */
	protected final MethodFlags methodflags;
	
	/** The name of the method. */
	protected final MethodName methodname;
	
	/** The type of the method. */
	protected final MethodDescriptor methodtype;
	
	/** Does this method have code? */
	protected final boolean hascode;
	
	/** Annotated values. */
	private final AnnotationTable annotations;
	
	/** The code attribute data, which is optional. */
	private final byte[] _rawcodeattr;
	
	/** The method byte code. */
	private Reference<ByteCode> _bytecode;
	
	/** Native code. */
	private Reference<NativeCode> _regcode;
	
	/** Name and type reference. */
	private Reference<MethodNameAndType> _nameandtype;
	
	/** The method index. */
	private Reference<MethodHandle> _index;
	
	/**
	 * Initializes the method.
	 *
	 * @param __ver The class version.
	 * @param __cf The class flags.
	 * @param __tn The name of the class.
	 * @param __pool The constant pool.
	 * @param __mf The method flags.
	 * @param __mn The name of the method.
	 * @param __mt The method type.
	 * @param __mc An optional byte array representing the code attribute, the
	 * value is used directly.
	 * @param __avs Annotations associated with this method.
	 * @throws NullPointerException On null arguments except for {@code __mc}.
	 * @since 2017/09/30
	 */
	Method(ClassVersion __ver, ClassFlags __cf, ClassName __tn, Pool __pool,
		MethodFlags __mf, MethodName __mn, MethodDescriptor __mt, byte[] __mc,
		AnnotationTable __avs)
		throws NullPointerException
	{
		if (__ver == null || __cf == null || __tn == null || __pool == null ||
			__mf == null || __mn == null || __mt == null || __avs == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.version = __ver;
		this.classflags = __cf;
		this.classname = __tn;
		this.pool = __pool;
		this.methodflags = __mf;
		this.methodname = __mn;
		this.methodtype = __mt;
		this.annotations = __avs;
		this._rawcodeattr = __mc;
		this.hascode = !__mf.isNative() && !__mf.isAbstract();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the byte code for this method.
	 *
	 * @return The byte code for this method or {@code null} if there is none.
	 * @throws InvalidClassFormatException If the byte code is not valid.
	 * @since 2017/10/09
	 */
	public final ByteCode byteCode()
		throws InvalidClassFormatException
	{
		// If there is no code atribute there is no byte code
		byte[] rawcodeattr = this._rawcodeattr;
		if (!this.hascode)
			return null;
		
		// Otherwise load a representation of it
		Reference<ByteCode> ref = this._bytecode;
		ByteCode rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._bytecode = new WeakReference<>((rv = new ByteCode(
				new WeakReference<>(this), this._rawcodeattr,
				this.classname, this.methodflags)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/11
	 */
	@Override
	public final MethodFlags flags()
	{
		return this.methodflags;
	}
	
	/**
	 * Returns the index of the method.
	 *
	 * @return The method index.
	 * @since 2017/10/14
	 */
	public final MethodHandle handle()
	{
		Reference<MethodHandle> ref = this._index;
		MethodHandle rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._index = new WeakReference<>(rv = new MethodHandle(
				this.classname, this.methodname, this.methodtype));
		
		return rv;
	}
	
	/**
	 * Returns if this method is effectively final, meaning that it cannot be
	 * replaced.
	 *
	 * @return If this method is effectively final or not.
	 * @since 2017/10/16
	 */
	public boolean isEffectivelyFinal()
	{
		return this.methodflags.isFinal() || this.classflags.isFinal();
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2018/09/03
	 */
	public final boolean isInstanceInitializer()
	{
		return this.methodname.isInstanceInitializer();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2018/09/03
	 */
	public final boolean isStaticInitializer()
	{
		return this.methodname.isStaticInitializer();
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2017/10/12
	 */
	public final MethodName name()
	{
		return this.methodname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nameandtype;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nameandtype = new WeakReference<>(
				rv = new MethodNameAndType(this.methodname, this.methodtype));
		
		return rv;
	}
	
	/**
	 * Returns the code of this method in a register based format that is
	 * more efficient than pure Java byte code.
	 *
	 * @return The code of this method in a register based format.
	 * @since 2019/03/09
	 */
	public final NativeCode nativeCode()
	{
		// Abstract and native methods have no code
		if (!this.hascode)
			return null;
		
		// Cache it
		Reference<NativeCode> ref = this._regcode;
		NativeCode rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			ByteCode bc = this.byteCode();
			
			// Process Code
			try
			{
				NearNativeByteCodeHandler nnbc =
					new NearNativeByteCodeHandler(bc);
				new ByteCodeProcessor(bc, nnbc).process();
				
				// Cache the result of it
				this._regcode = new WeakReference<>((rv = nnbc.result()));
			}
			
			// {@squirreljme.error JC3e Could not compile the native code for
			// the given method. (The class; Method name; Method type)}
			catch (InvalidClassFormatException e)
			{
				throw new InvalidClassFormatException(
					String.format("JC3e %s %s %s", this.classname,
						this.methodname, this.methodtype), e);
			}
		}
		
		return rv;
	}
	
	/**
	 * Returns the constant pool this method uses.
	 *
	 * @return The constant pool which is used.
	 * @since 2017/10/09
	 */
	public final Pool pool()
	{
		return this.pool;
	}
	
	/**
	 * Returns the method's type.
	 *
	 * @return The type of the method.
	 * @since 2017/10/16
	 */
	public final MethodDescriptor type()
	{
		return this.methodtype;
	}
	
	/**
	 * Decodes all methods from the input class data.
	 *
	 * @param __ver The version of the class.
	 * @param __tn The name of the owning class.
	 * @param __cf The flags for the owning class.
	 * @param __pool The constant pool for the class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/30
	 */
	public static Method[] decode(ClassVersion __ver, ClassName __tn,
		ClassFlags __cf, Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__ver == null || __tn == null || __cf == null || __pool == null ||
			__in == null)
			throw new NullPointerException("NARG");
		
		int nm = __in.readUnsignedShort();
		Method[] rv = new Method[nm];
		Set<NameAndType> dup = new HashSet<>();
		
		// Parse fields
		for (int i = 0; i < nm; i++)
		{
			// Read the flags but do not initialize them yet
			int rawflags = __in.readUnsignedShort();
			
			// Parse name, this is needed to see if it is a constructor
			MethodName name = new MethodName(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// Initialize the flags now that we know the class name, this way
			// we can determine if this is a constructor or not
			MethodFlags flags = new MethodFlags(__cf, name, rawflags);
			
			// Continue reading the type
			MethodDescriptor type = new MethodDescriptor(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// {@squirreljme.error JC3f A duplicate method exists within the
			// class. (The method name; The method descriptor)}
			if (!dup.add(new NameAndType(name.toString(), type.toString())))
				throw new InvalidClassFormatException(String.format(
					"JC3f %s %s", name, type));
			
			// Handle attributes
			AttributeTable attrs = AttributeTable.parse(__pool, __in);
			
			// Parse annotations
			AnnotationTable annotations = AnnotationTable.parse(__pool, attrs);
			
			// Get copy of the code attribute
			Attribute maybecode = attrs.get("Code");
			byte[] code = (maybecode == null ? null : maybecode.bytes());
			
			// {@squirreljme.error JC3g The specified method does not have
			// the correct matching for abstract and if code exists or not.
			// (The current
			// class; The method name; The method type; The method flags)}
			if ((code == null) != (flags.isAbstract() | flags.isNative()))
				throw new InvalidClassFormatException(String.format(
					"JC3g %s %s %s %s", __tn, name, type, flags));
			
			// Create
			rv[i] = new Method(__ver, __cf, __tn, __pool, flags, name, type,
				code, annotations);
		}
		
		// All done!
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MethodDescriptor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.ArrayList;
import java.util.List;

/**
 * This represents the type descriptor of a method.
 *
 * @since 2017/06/12
 */
public final class MethodDescriptor
	implements MemberDescriptor
{
	/** String representation of the descriptor. */
	protected final String string;
	
	/** The return value, null is void. */
	protected final FieldDescriptor rvalue;
	
	/** The arguments in the method. */
	private final FieldDescriptor[] _args;
	
	/**
	 * Initializes the descriptor with the given descriptors.
	 *
	 * @param __rv The return value.
	 * @param __args Arguments to the descriptor.
	 * @throws InvalidClassFormatException If the descriptor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	public MethodDescriptor(FieldDescriptor __rv, FieldDescriptor... __args)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__rv == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Need to build the string representation
		StringBuilder sb = new StringBuilder();
		sb.append('(');
		
		// Check for more nulls and build the string
		__args = __args.clone();
		for (FieldDescriptor f : __args)
		{
			if (f == null)
				throw new NullPointerException("NARG");
			
			sb.append(f.toString());
		}
		
		// Finish with the return value
		sb.append(')');
		sb.append((__rv == null ? "V" : __rv.toString()));
		
		// Set because these are copies
		this.rvalue = __rv;
		this._args = __args;
		this.string = sb.toString();
	}
	
	/**
	 * Initializes the method descriptor.
	 *
	 * @param __n The method descriptor to decode.
	 * @throws InvalidClassFormatException If it is not a valid method
	 * descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public MethodDescriptor(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// {@squirreljme.error JC3h Method descriptors must start with an open
		// parenthesis. (The method descriptor)}
		if (!__n.startsWith("("))
			throw new InvalidClassFormatException(
				String.format("JC3h %s", __n));
		
		// Parse all input arguments
		List<FieldDescriptor> args = new ArrayList<>();
		int i = 1, n = __n.length();
		for (; i < n;)
		{
			char c = __n.charAt(i);
			
			// End of descriptor arguments
			if (c == ')')
				break;
			
			// Skip array markers
			int at = i;
			for (; at < n; at++)
				if ('[' != __n.charAt(at))
					break;
			
			// {@squirreljme.error JC3i Reached end of descriptor parsing
			// arguments. (The method descriptor)}
			if (at >= n)
				throw new InvalidClassFormatException(
					String.format("JC3i %s", __n));
			
			// Find end sequence
			switch (__n.charAt(at))
			{
					// Primitive
				case 'B':
				case 'C':
				case 'D':
				case 'F':
				case 'I':
				case 'J':
				case 'S':
				case 'Z':
					break;
					
					// Class, find ;
				case 'L':
					for (; at < n; at++)
						if (';' == __n.charAt(at))
							break;
					break;
				
					// {@squirreljme.error JC3j Unknown field descriptor in
					// method descriptor argument. (The descriptor)}
				default:
					throw new InvalidClassFormatException(
						String.format("JC3j %s", __n));
			}
			
			// Parse field
			args.add(new FieldDescriptor(__n.substring(i, at + 1)));
			
			// Go to next field
			i = at + 1;
		}
		this._args = args.<FieldDescriptor>toArray(
			new FieldDescriptor[args.size()]);
		
		// Skip the ending parenthesis
		i++;
		
		// {@squirreljme.error JC3k The method descriptor has no return
		// value. (The method descriptor)}
		if (i >= n)
			throw new InvalidClassFormatException(
				String.format("JC3k %s", __n));
		
		// No return value?
		char c = __n.charAt(i);
		if (c == 'V' && (i + 1) == n)
			this.rvalue = null;
		
		// Parse as a field
		else
			this.rvalue = new FieldDescriptor(__n.substring(i));
	}
	
	/**
	 * Returns the argument of the given parameter number.
	 *
	 * @param __i The parameter to get the argument for.
	 * @throws IndexOutOfBoundsException If the argument is not within bounds.
	 * @since 2017/07/28
	 */
	public FieldDescriptor argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/14
	 */
	public FieldDescriptor[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Returns the number of arguments this descriptor has.
	 *
	 * @return The number of arguments this descriptor has.
	 * @since 2017/07/28
	 */
	public int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof MethodDescriptor))
			return false;
		
		return this.string.equals(((MethodDescriptor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Does this method have a return value?
	 *
	 * @return If the method has a return value.
	 * @since 2018/09/16
	 */
	public final boolean hasReturnValue()
	{
		return null != this.rvalue;
	}
	
	/**
	 * Returns the Java type stack for this descriptor.
	 * 
	 * @return The descriptor as it appears on the Java Stack.
	 * @since 2017/09/16
	 */
	public JavaType[] javaStack()
	{
		// Handle all arguments now
		int n = this.argumentCount();
		List<JavaType> rv = new ArrayList<>(n * 2);
		for (int i = 0; i < n; i++)
		{
			FieldDescriptor a;
			JavaType j;
			rv.add(j = new JavaType(a = this.argument(i)));
			
			// Add top of long/double but with unique distinct types
			if (j.isWide())
				rv.add(j.topType());
		}
		
		return rv.<JavaType>toArray(new JavaType[rv.size()]);
	}
	
	/**
	 * Returns the return value of this descriptor.
	 *
	 * @return The value returned in this descriptor or {@code null} if there
	 * is no return value.
	 * @since 2017/09/22
	 */
	public FieldDescriptor returnValue()
	{
		return this.rvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MethodFlag.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which are used by methods.
 *
 * @since 2016/04/23
 */
public enum MethodFlag
	implements MemberFlag
{
	/** Public method. */
	PUBLIC,
	
	/** Private method. */
	PRIVATE,
	
	/** Protected method. */
	PROTECTED,
	
	/** Static method. */
	STATIC,
	
	/** Final method. */
	FINAL,
	
	/** Synchronized method. */
	SYNCHRONIZED,
	
	/** Bridge method. */
	BRIDGE,
	
	/** Variable argument method. */
	VARARGS,
	
	/** Native method. */
	NATIVE,
	
	/** Abstract method. */
	ABSTRACT,
	
	/** Strict floating point method. */
	STRICT,
	
	/** Synthetic method. */
	SYNTHETIC,
	
	/** End. */
	;
	
	/**
	 * Returns the bit mask which is used for this flag.
	 *
	 * @return The bit mask used for the flag.
	 * @since 2017/07/07
	 */
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case PRIVATE:		return 0x0002;
			case PROTECTED:		return 0x0004;
			case STATIC:		return 0x0008;
			case FINAL:			return 0x0010;
			case SYNCHRONIZED:	return 0x0020;
			case BRIDGE:		return 0x0040;
			case VARARGS:		return 0x0080;
			case NATIVE:		return 0x0100;
			case ABSTRACT:		return 0x0400;
			case STRICT:		return 0x0800;
			case SYNTHETIC:		return 0x1000;

			default:
				throw new todo.OOPS();
		}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MethodFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the set of flags for methods.
 *
 * @since 2016/04/23
 */
public final class MethodFlags
	extends MemberFlags<MethodFlag>
{
	/**
	 * Initializes the method flags, with no checks performed on them.
	 *
	 * @param __i The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(int __i)
	{
		super(MethodFlag.class,
			Flags.<MethodFlag>__decode(__i, MethodFlag.values()));
	}
	
	/**
	 * Initializes the method flags.
	 *
	 * @param __oc The outer class.
	 * @param __mn The name of the method.
	 * @param __fl The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn, MethodFlag... __fl)
	{
		super(MethodFlag.class, __fl);
		
		this.__checkFlags(__oc, __mn);
	}
	
	/**
	 * Initializes the method flags.
	 *
	 * @param __oc The outer class.
	 * @param __mn The name of the method.
	 * @param __fl The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn,
		Iterable<MethodFlag> __fl)
	{
		super(MethodFlag.class, __fl);
		
		this.__checkFlags(__oc, __mn);
	}
	
	/**
	 * Decodes method flags from the bit field.
	 *
	 * @param __oc The outer class flags.
	 * @param __mn The name of the method.
	 * @param __i The bitfield to decode.
	 * @since 2017/07/07
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn, int __i)
	{
		this(__oc, __mn, Flags.<MethodFlag>__decode(__i, MethodFlag.values()));
	}
	
	/**
	 * Returns {@code true} if this is abstract.
	 *
	 * @return {@code true} if abstract.
	 * @since 2016/03/20
	 */
	public boolean isAbstract()
	{
		return this.contains(MethodFlag.ABSTRACT);
	}
	
	/**
	 * Returns {@code true} if this is a bridge method.
	 *
	 * @return {@code true} if a bridge method.
	 * @since 2016/03/20
	 */
	public boolean isBridge()
	{
		return this.contains(MethodFlag.BRIDGE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isFinal()
	{
		return this.contains(MethodFlag.FINAL);
	}
	
	/**
	 * Returns {@code true} if this is a native method.
	 *
	 * @return {@code true} if it is native.
	 * @since 2016/03/20
	 */
	public boolean isNative()
	{
		return this.contains(MethodFlag.NATIVE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPrivate()
	{
		return this.contains(MethodFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isProtected()
	{
		return this.contains(MethodFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPublic()
	{
		return this.contains(MethodFlag.PUBLIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isStatic()
	{
		return this.contains(MethodFlag.STATIC);
	}
	
	/**
	 * Returns {@code true} if this is strict.
	 *
	 * @return {@code true} if strict.
	 * @since 2016/03/20
	 */
	public boolean isStrict()
	{
		return this.contains(MethodFlag.STRICT);
	}
	
	/**
	 * Returns {@code true} if this is synchronized.
	 *
	 * @return {@code true} if synchronized.
	 * @since 2016/03/20
	 */
	public boolean isSynchronized()
	{
		return this.contains(MethodFlag.SYNCHRONIZED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isSynthetic()
	{
		return this.contains(MethodFlag.SYNTHETIC);
	}
	
	/**
	 * Returns {@code true} if this uses variable arguments.
	 *
	 * @return {@code true} if it uses variable arguments.
	 * @since 2016/03/20
	 */
	public boolean isVarArgs()
	{
		return this.contains(MethodFlag.VARARGS);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @param __oc The outer class.
	 * @param __mn The name of the method.
	 * @throws InvalidClassFormatException If they are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	private final void __checkFlags(ClassFlags __oc, MethodName __mn)
		throws InvalidClassFormatException
	{
		// Check
		if (__oc == null || __mn == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3l An {@code abstract} method cannot be
		// {@code private}, {@code static}, {@code final},
		// {@code synchronized}, {@code native}, or {@code strictfp}. (The
		// method flags)}
		if (this.isAbstract())
			if (this.isPrivate() || this.isStatic() || this.isFinal() || this
				.isSynchronized() || this.isNative() || this.isStrict())
				throw new InvalidClassFormatException(
					String.format("JC3l %s", this));
		
		// If the class is an interface it cannot have specific flags set
		// Ignore checking these interface flags if we are in an interface and
		// this is a static constructor because otherwise the check will fail
		// since there cannot be static items
		if (__oc.isInterface() && !__mn.isStaticInitializer())
			for (MethodFlag f : MethodFlag.values())
			{
				// Must have these
				boolean must = (f == MethodFlag.PUBLIC ||
					f == MethodFlag.ABSTRACT);
				
				// Could have these
				boolean maybe = (f == MethodFlag.SYNTHETIC ||
					f == MethodFlag.VARARGS || f == MethodFlag.BRIDGE);
				
				// Is it set?
				boolean has = this.contains(f);
				
				// {@squirreljme.error JC3m Flags for interface method has an
				// incorrect set of flags. (The method flags)}
				if (must != has && !maybe)
					throw new InvalidClassFormatException(
						String.format("JC3m %s", this));
			}
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MethodHandle.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a method's class, name, and type.
 *
 * @since 2017/09/16
 */
public final class MethodHandle
	implements Comparable<MethodHandle>
{
	/** The class the method is in. */
	protected final ClassName outerclass;
	
	/** The name of the method. */
	protected final MethodName name;
	
	/** The descriptor of the method. */
	protected final MethodDescriptor descriptor;
	
	/** Method name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the method handle.
	 *
	 * @param __cl The class the method is in.
	 * @param __n The name of the method.
	 * @param __d The descriptor of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/16
	 */
	public MethodHandle(ClassName __cl, MethodName __n, MethodDescriptor __d)
		throws NullPointerException
	{
		// Check
		if (__cl == null || __n == null || __d == null)
			throw new NullPointerException("NARG");
		
		this.outerclass = __cl;
		this.name = __n;
		this.descriptor = __d;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/14
	 */
	@Override
	public int compareTo(MethodHandle __o)
	{
		int rv;
		if ((rv = this.outerclass.compareTo(__o.outerclass)) != 0)
			return rv;
		if ((rv = this.name.compareTo(__o.name)) != 0)
			return rv;
		return this.descriptor.toString().compareTo(__o.descriptor.toString());
	}
	
	/**
	 * Returns the descriptor of the method.
	 *
	 * @return The method descriptor.
	 * @since 2017/09/16
	 */
	public MethodDescriptor descriptor()
	{
		return this.descriptor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof MethodHandle))
			return false;
		
		MethodHandle o = (MethodHandle)__o;
		return this.outerclass.equals(o.outerclass) &&
			this.name.equals(o.name) &&
			this.descriptor.equals(o.descriptor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public int hashCode()
	{
		return this.outerclass.hashCode() ^
			this.name.hashCode() ^
			this.descriptor.hashCode();
	}
	
	/**
	 * Returns {@code true} if this represents the instance initializer.
	 *
	 * @return {@code true} if this is the instance initializer.
	 * @since 2017/09/18
	 */
	public boolean isInstanceInitializer()
	{
		return this.name.isInstanceInitializer();
	}
	
	/**
	 * Returns the Java type stack for this handle.
	 * 
	 * @param __i If {@code true} then this is an instance invocation.
	 * @return The handle as it appears on the Java Stack.
	 * @since 2017/09/16
	 */
	public JavaType[] javaStack(boolean __i)
	{
		// No need to add current class type
		JavaType[] djs = this.descriptor.javaStack();
		if (!__i)
			return djs;
		
		// Just copy over
		int dn = djs.length;
		JavaType[] rv = new JavaType[dn + 1];
		rv[0] = new JavaType(this.outerclass);
		for (int i = 0, o = 1; i < dn; i++, o++)
			rv[o] = djs[i];
		
		return rv;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2017/09/16
	 */
	public MethodName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the name and type of the method.
	 *
	 * @return The method name and type.
	 * @since 2019/04/17
	 */
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>((rv = new MethodNameAndType(
				this.name, this.descriptor)));
		
		return rv;
	}
	
	/**
	 * Returns the class this is contained within.
	 *
	 * @return The outer class.
	 * @since 2017/09/16
	 */
	public ClassName outerClass()
	{
		return this.outerclass;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s::%s%s",
				this.outerclass, this.name, this.descriptor)));
		
		return rv;
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This represents the name of a method. This has the same constraints as the
 * identifier except it cannot contain the {@code <} or {@code >} symbols
 * unless it is {@code <init>} or {@code <clinit>}.
 *
 * @since 2017/07/07
 */
public final class MethodName
	extends Identifier
	implements Comparable<MethodName>, MemberName
{
	/**
	 * Initializes the method name.
	 *
	 * @param __s The method name.
	 * @throws InvalidClassFormatException If the method name is method valid.
	 * @since 2017/07/07
	 */
	public MethodName(String __s)
		throws InvalidClassFormatException
	{
		super(__s);
		
		// Cannot contain < or >
		if (!__s.equals("<init>") && !__s.equals("<clinit>"))
			for (int i = 0, n = __s.length(); i < n; i++)
			{
				char c = __s.charAt(i);
				
				// {@squirreljme.error JC3n Method names cannot contain less
				// than or greater than signs. (The method name)}
				if (c == '<' || c == '>')
					throw new InvalidClassFormatException(
						String.format("JC3n %s", __s));
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int compareTo(MethodName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof MethodName) && super.equals(__o);
	}
	
	/**
	 * Is this any initializer for a method.
	 *
	 * @return If this is any initializer method.
	 * @since 2017/10/12
	 */
	public boolean isAnyInitializer()
	{
		return this.isInstanceInitializer() || this.isStaticInitializer();
	}
	
	/**
	 * Returns {@code true} if this represents the instance initializer.
	 *
	 * @return {@code true} if this is the instance initializer.
	 * @since 2017/07/28
	 */
	public boolean isInstanceInitializer()
	{
		return this.string.equals("<init>");
	}
	
	/**
	 * Returns {@code true} if this represents the static initializer.
	 *
	 * @return {@code true} if this is the static initializer.
	 * @since 2017/07/28
	 */
	public boolean isStaticInitializer()
	{
		return this.string.equals("<clinit>");
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the name and type for a method.
 *
 * @since 2017/10/10
 */
public final class MethodNameAndType
	implements Comparable<MethodNameAndType>, MemberNameAndType
{
	/** The method name. */
	protected final MethodName name;
	
	/** The method type. */
	protected final MethodDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the method anme and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws InvalidClassFormatException If the method name and type are not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public MethodNameAndType(String __n, String __t)
		throws InvalidClassFormatException, NullPointerException
	{
		this(new MethodName(__n), new MethodDescriptor(__t));
	}
	
	/**
	 * Initializes the method anme and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws InvalidClassFormatException If the method name and type are not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/19
	 */
	public MethodNameAndType(String __n, MethodDescriptor __t)
		throws InvalidClassFormatException, NullPointerException
	{
		this(new MethodName(__n), __t);
	}
	
	/**
	 * Initializes the method name and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/10
	 */
	public MethodNameAndType(MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int compareTo(MethodNameAndType __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.type.toString().compareTo(__o.type.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof MethodNameAndType))
			return false;
		
		MethodNameAndType o = (MethodNameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public MethodName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s:%s",
				this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public MethodDescriptor type()
	{
		return this.type;
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This describes a reference to a method.
 *
 * @since 2017/06/12
 */
public final class MethodReference
	extends MemberReference
{
	/** The method handle. */
	protected final MethodHandle handle;
	
	/** Is this an interface? */
	protected final boolean isinterface;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/**
	 * Initializes the method reference.
	 *
	 * @param __h The handle of the class.
	 * @param __int Does this refer to an interface method?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/16
	 */
	public MethodReference(MethodHandle __h, boolean __int)
	{
		super(__h.outerClass());
		
		// Check
		if (__h == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.handle = __h;
		this.isinterface = __int;
	}
	
	/**
	 * Initializes the method reference.
	 *
	 * @param __c The class the member resides in.
	 * @param __i The name of the member.
	 * @param __t The descriptor of the member.
	 * @param __int Does this refer to an interface method?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public MethodReference(ClassName __c, MethodName __i,
		MethodDescriptor __t, boolean __int)
		throws NullPointerException
	{
		this(new MethodHandle(__c, __i, __t), __int);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof MethodReference))
			return false;
		
		MethodReference o = (MethodReference)__o;
		return this.handle.equals(o.handle) &&
			this.isinterface == o.isinterface;
	}
	
	/**
	 * Returns the method handle.
	 *
	 * @return The method handle.
	 * @since 2017/09/16
	 */
	public MethodHandle handle()
	{
		return this.handle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.handle.hashCode() ^ (this.isinterface ? 1 : 0);
	}
	
	/**
	 * Is this an interface method reference?
	 *
	 * @return {@code true} if a reference to an interface method.
	 * @since 2017/07/15
	 */
	public boolean isInterface()
	{
		return this.isinterface;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/08
	 */
	@Override
	public final MethodName memberName()
	{
		return this.handle.name();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodNameAndType memberNameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			MethodHandle handle = this.handle;
			this._nat = new WeakReference<>(
				(rv = new MethodNameAndType(handle.name(),
					handle.descriptor())));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodDescriptor memberType()
	{
		return this.handle.descriptor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%smethod %s",
				(this.isinterface ? "interface-" : ""), this.handle)));
		
		return rv;
	}
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This holds the name and type strings, the type descriptor is not checked.
 *
 * @since 2017/06/12
 */
public final class NameAndType
{
	/** The name. */
	protected final String name;
	
	/** The type. */
	protected final String type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the name and type information.
	 *
	 * @param __n The name.
	 * @param __t The type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public NameAndType(String __n, String __t)
		throws NullPointerException
	{
		// Check
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof NameAndType))
			return false;
		
		NameAndType o = (NameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2017/06/12
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.name + "." +
				this.type));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/06/12
	 */
	public String type()
	{
		return this.type;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/Pool.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.UTFDataFormatException;
import java.util.Arrays;

/**
 * This class decodes the constant pool and provides generic access to the
 * contents of it.
 *
 * @since 2017/06/08
 */
public final class Pool
{
	/** The UTF constant tag. */
	public static final int TAG_UTF8 =
		1;
	
	/** Integer constant. */
	public static final int TAG_INTEGER =
		3;
	
	/** Float constant. */
	public static final int TAG_FLOAT =
		4;
	
	/** Long constant. */
	public static final int TAG_LONG =
		5;
	
	/** Double constant. */
	public static final int TAG_DOUBLE =
		6;
	
	/** Reference to another class. */
	public static final int TAG_CLASS =
		7;
	
	/** String constant. */
	public static final int TAG_STRING =
		8;
	
	/** Field reference. */
	public static final int TAG_FIELDREF =
		9;
	
	/** Method reference. */
	public static final int TAG_METHODREF =
		10;
	
	/** Interface method reference. */
	public static final int TAG_INTERFACEMETHODREF =
		11;
	
	/** Name and type. */
	public static final int TAG_NAMEANDTYPE =
		12;
	
	/** Method handle (illegal). */
	public static final int TAG_METHODHANDLE =
		15;
	
	/** Method type (illegal). */
	public static final int TAG_METHODTYPE =
		16;
	
	/** Invoke dynamic call site (illegal). */
	public static final int TAG_INVOKEDYNAMIC =
		18;
	
	/** The top of a long/double. */
	public static final int TAG_WIDETOP =
		-1;
	
	/** Entries within the constant pool. */
	private final Object[] _entries;
	
	/**
	 * Parses and initializes the constant pool structures.
	 *
	 * @param __e The entries which make up the pool, this is used directly.
	 * @since 2017/06/08
	 */
	Pool(Object... __e)
	{
		this._entries = (__e == null ? new Object[0] : __e);
	}
	
	/**
	 * Obtains the entry at the specified index.
	 *
	 * @param <C> The type of class to get.
	 * @param __cl The type of class to get.
	 * @param __i The index of the entry to get.
	 * @return The entry at the specified position as the given class or
	 * {@code null} if it does not exist.
	 * @throws InvalidClassFormatException If the class type does not match or
	 * the pool index is out of range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/08
	 */
	public <C> C get(Class<C> __cl, int __i)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Short circuit, the zero entry is always nothing
		if (__i == 0)
			return null;
		
		// {@squirreljme.error JC3o The specified index is not within the bounds
		// of the constant pool. (The index of the entry)}
		Object[] entries = this._entries;
		if (__i < 0 || __i >= entries.length)
			throw new InvalidClassFormatException(
				String.format("JC3o %d", __i));
		
		// {@squirreljme.error JC3p The specified entry's class is not of the
		// expected class. (The index of the entry; The class the entry is; The
		// expected class)}
		Object val = entries[__i];
		if (val != null && !__cl.isInstance(val))
			throw new InvalidClassFormatException(
				String.format("JC3p %d %s %s", __i, val.getClass(), __cl));
		
		return __cl.cast(val);
	}
	
	/**
	 * This is similar to {@link #get(Class, int)} except that it is not valid
	 * if the entry is the {@code null} entry (the first one).
	 *
	 * @param <C> The type of class to get.
	 * @param __cl The type of class to get.
	 * @param __i The index of the entry to get.
	 * @return The entry at the specified position as the given class.
	 * @throws InvalidClassFormatException If the class type does not match,
	 * the pool index is out of range, or the entry is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/14
	 */
	public <C> C require(Class<C> __cl, int __i)
		throws InvalidClassFormatException, NullPointerException
	{
		// {@squirreljme.error JC3q Expected the specified constant pool entry
		// to not be the null entry. (The index; The expected class)}
		C rv = this.<C>get(__cl, __i);
		if (rv == null)
			throw new InvalidClassFormatException(
				String.format("JC3q %d %s", __i, __cl));
		return rv;
	}
	
	/**
	 * Decodes the constant pool.
	 *
	 * @param __in The input stream.
	 * @return The read constant pool.
	 * @throws InvalidClassFormatException If the constant pool is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public static Pool decode(DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read the raw constant pool contents first
		int count = __in.readUnsignedShort();
		int[] tags = new int[count];
		Object[] rawdata = new Object[count];
		for (int i = 1; i < count; i++)
		{
			// Read tag
			int tag = __in.readUnsignedByte();
			tags[i] = tag;
			
			// Parse tag data
			Object data;
			switch (tag)
			{
					// UTF-8 String
					// The string is wrapped in a wrapper class so that String
					// constants are actual String references. It is illegal for
					// UTF-8 constants to be directly used by the byte code so
					// this prevents their usage from occuring by causing a
					// class cast exception
				case Pool.TAG_UTF8:
					try
					{
						data = new UTFConstantEntry(__in.readUTF());
					}
					
					// {@squirreljme.error JC3r Modified UTF-8 data is not in
					// the correct format.}
					catch (UTFDataFormatException e)
					{
						throw new InvalidClassFormatException("JC3r", e);
					}
					break;
					
					// Reference to two entries
				case Pool.TAG_FIELDREF:
				case Pool.TAG_METHODREF:
				case Pool.TAG_INTERFACEMETHODREF:
				case Pool.TAG_NAMEANDTYPE:
					data = new int[]{__in.readUnsignedShort(),
						__in.readUnsignedShort()};
					break;
					
					// References to single entry
				case Pool.TAG_CLASS:
				case Pool.TAG_STRING:
					data = new int[]{__in.readUnsignedShort()};
					break;
					
					// Integer
				case Pool.TAG_INTEGER:
					data = new ConstantValueInteger(
						Integer.valueOf(__in.readInt()));
					break;
					
					// Long
				case Pool.TAG_LONG:
					data = new ConstantValueLong(
						Long.valueOf(__in.readLong()));
					break;
					
					// Float
				case Pool.TAG_FLOAT:
					data = new ConstantValueFloat(
						Float.valueOf(__in.readFloat()));
					break;
					
					// Double
				case Pool.TAG_DOUBLE:
					data = new ConstantValueDouble(
						Double.valueOf(__in.readDouble()));
					break;
					
					// {@squirreljme.error JC3s Java ME does not support
					// dynamic invocation (such as method handles or lambda
					// expressions).}
				case Pool.TAG_METHODHANDLE:
				case Pool.TAG_METHODTYPE:
				case Pool.TAG_INVOKEDYNAMIC:
					throw new InvalidClassFormatException("JC3s");
				
					// {@squirreljme.error JC3t Unknown tag type in the
					// constant pool. (The constant pool tag)}
				default:
					throw new InvalidClassFormatException(
						String.format("JC3t %d", tag));
			}
			rawdata[i] = data;
			
			// Skip long/double?
			if (tag == Pool.TAG_LONG || tag == Pool.TAG_DOUBLE)
			{
				rawdata[++i] = new WideConstantTopEntry();
				tags[i] = Pool.TAG_WIDETOP;
			}
		}
		
		// Go through tags again and initialize their raw data into type-safe
		// classes 
		Object[] entries = new Object[count];
		try
		{
			Pool.__initializeEntries(entries, tags, rawdata);
		}
		
		// {@squirreljme.error JC3u The constant pool is not valid.}
		catch (ClassCastException|IndexOutOfBoundsException|
			NullPointerException e)
		{
			throw new InvalidClassFormatException("JC3u", e);
		}
		
		// Setup
		return new Pool(entries);
	}
	
	/**
	 * This initializes the entries in the constant pool.
	 *
	 * @param __entries Output pool entries.
	 * @param __tags Constant pool tags for the entries.
	 * @param __rawdata The raw pool data.
	 * @throws InvalidClassFormatException If the entries are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	private static void __initializeEntries(Object[] __entries, int[] __tags,
		Object[] __rawdata)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__entries == null || __tags == null || __rawdata == null)
			throw new NullPointerException("NARG");
		
		// Instead of having a nested loop which goes through every entry
		// multiple times, the sequence entries should be parsed in is very
		// known with a direct line of dependencies. Entries with lower
		// sequences are only depended on. This saves an extra loop and makes
		// the code much cleaner for the most part.
		int count = __entries.length;
		int[] order = new int[count];
		for (int i = 0; i < count; i++)
		{
			int tag = __tags[i],
				sequence;
			
			// Determine the sequence based on the tag
			switch (tag)
			{
				case 0:
				case Pool.TAG_UTF8:
				case Pool.TAG_INTEGER:
				case Pool.TAG_FLOAT:
				case Pool.TAG_LONG:
				case Pool.TAG_DOUBLE:
				case Pool.TAG_WIDETOP:
					sequence = 0;
					break;
				
				case Pool.TAG_CLASS:
				case Pool.TAG_STRING:
					sequence = 1;
					break;
				
				case Pool.TAG_NAMEANDTYPE:
					sequence = 2;
					break;
				
				case Pool.TAG_FIELDREF:
				case Pool.TAG_METHODREF:
				case Pool.TAG_INTERFACEMETHODREF:
					sequence = 3;
					break;
					
				default:
					throw new todo.OOPS();
			}
			
			// Add to order
			order[i] = (sequence << 16) | i;
		}
		Arrays.sort(order);
		
		// Go through and process all of the entries now that their major
		// sequence order is known.
		for (int j = 0; j < count; j++)
		{
			int i = order[j] & 0xFFFF,
				tag = __tags[i];
			
			// Process tags
			Object in = __rawdata[i],
				out;
			switch (tag)
			{
					// These are copied directly
				case 0:
				case Pool.TAG_UTF8:
				case Pool.TAG_INTEGER:
				case Pool.TAG_FLOAT:
				case Pool.TAG_LONG:
				case Pool.TAG_DOUBLE:
				case Pool.TAG_WIDETOP:
					out = in;
					break;
					
					// Name of a class
				case Pool.TAG_CLASS:
					out = new ClassName(((UTFConstantEntry)
						__entries[((int[])in)[0]]).toString());
					break;
					
					// String constant
				case Pool.TAG_STRING:
					out = new ConstantValueString(
						((UTFConstantEntry)__entries[((int[])in)[0]]).
							toString());
					break;
					
					// Name and type information
				case Pool.TAG_NAMEANDTYPE:
					{
						int[] ina = (int[])in;
						out = new NameAndType(
							((UTFConstantEntry)__entries[ina[0]]).toString(),
							((UTFConstantEntry)__entries[ina[1]]).toString());
					}
					break;
					
					// Field and method references
				case Pool.TAG_FIELDREF:
				case Pool.TAG_METHODREF:
				case Pool.TAG_INTERFACEMETHODREF:
					{
						int[] ina = (int[])in;
						ClassName cn = (ClassName)__entries[ina[0]];
						NameAndType nat = (NameAndType)__entries[ina[1]];
						
						if (tag == Pool.TAG_FIELDREF)
							out = new FieldReference(cn,
								new FieldName(nat.name()),
								new FieldDescriptor(nat.type()));
						else
							out = new MethodReference(cn,
								new MethodName(nat.name()),
								new MethodDescriptor(nat.type()),
								tag == Pool.TAG_INTERFACEMETHODREF);
					}
					break;
				
					// Unhandled, should not happen
				default:
					throw new RuntimeException(String.format("OOPS %d", tag));
			}
			
			__entries[i] = out;
		}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * This enumeration represents a primitive type.
 *
 * @since 2017/10/16
 */
public enum PrimitiveType
{
	/** Byte. */
	BYTE,
	
	/** Character. */
	CHARACTER,
	
	/** Double. */
	DOUBLE,
	
	/** Float. */
	FLOAT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Short. */
	SHORT,
	
	/** Boolean. */
	BOOLEAN,
	
	/** End. */
	;
	
	/**
	 * The number of bytes needed to store this type.
	 *
	 * @return The number of bytes required to store data for this type.
	 * @since 2019/03/11
	 */
	public final int bytes()
	{
		switch (this)
		{
			case BOOLEAN:
			case BYTE:		return 1;
			case SHORT:
			case CHARACTER:	return 2;
			case INTEGER:
			case FLOAT:		return 4;
			case LONG:
			case DOUBLE:	return 8;
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return If this is a wide type.
	 * @since 2017/10/16
	 */
	public final boolean isWide()
	{
		return this == PrimitiveType.LONG || this == PrimitiveType.DOUBLE;
	}
	
	/**
	 * Does this type promote to int?
	 *
	 * @return If this type promotes to int.
	 * @since 2017/10/16
	 */
	public final boolean promotesToInt()
	{
		switch (this)
		{
			case BYTE:
			case CHARACTER:
			case SHORT:
			case BOOLEAN:
				return true;	
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the Java type this uses on the stack.
	 *
	 * @return The Java type this uses on the stack.
	 * @since 2019/04/02
	 */
	public final JavaType stackJavaType()
	{
		switch (this)
		{
			case BOOLEAN:
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the class name for the given type.
	 *
	 * @return The type's class name.
	 * @since 2019/03/24
	 */
	public final ClassName toClassName()
	{
		switch (this)
		{
			case BOOLEAN:	return new ClassName("boolean");
			case BYTE:		return new ClassName("byte");
			case SHORT:		return new ClassName("short");
			case CHARACTER:	return new ClassName("char");
			case INTEGER:	return new ClassName("int");
			case LONG:		return new ClassName("long");
			case FLOAT:		return new ClassName("float");
			case DOUBLE:	return new ClassName("double");
			
			default:
				throw new todo.OOPS(this.toString());
		}
	}
}

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

package net.multiphasicapps.classfile;

/**
 * The simple storage type of a field or other type.
 *
 * @since 2018/09/15
 */
public enum SimpleStorageType
{
	/** Object. */
	OBJECT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
}

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

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableIterator;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This is the stack map table which is used for verification purposes.
 *
 * @since 2017/10/09
 */
public final class StackMapTable
	implements Iterable<Map.Entry<Integer, StackMapTableState>>
{
	/** Stack map states. */
	private final Map<Integer, StackMapTableState> _states;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map table.
	 *
	 * @param __s The input states.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/16
	 */
	StackMapTable(Map<Integer, StackMapTableState> __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this._states = new SortedTreeMap<>(__s);
	}
	
	/**
	 * Returns the stack map table state for the given entry.
	 *
	 * @param __a The address to get.
	 * @return The state for the given address or {@code null} if it there is
	 * no entry.
	 * @since 2017/10/16
	 */
	public StackMapTableState get(int __a)
	{
		return this._states.get(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final Iterator<Map.Entry<Integer, StackMapTableState>> iterator()
	{
		return UnmodifiableIterator.<Map.Entry<Integer, StackMapTableState>>of(
			UnmodifiableMap.<Integer, StackMapTableState>of(
				this._states).entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this._states.toString()));
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/StackMapTableEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a single entry within the stack map table which may
 * additionally has a flag indicating if an entry is initialized or not.
 *
 * @since 2017/09/02
 */
public final class StackMapTableEntry
{
	/** The top of a long. */
	public static final StackMapTableEntry TOP_LONG =
		new StackMapTableEntry(JavaType.TOP_LONG, true);
	
	/** The top of a double. */
	public static final StackMapTableEntry TOP_DOUBLE =
		new StackMapTableEntry(JavaType.TOP_DOUBLE, true);
	
	/** Undefined top type. */
	public static final StackMapTableEntry TOP_UNDEFINED =
		new StackMapTableEntry(JavaType.TOP_UNDEFINED, true);
	
	/** Not used. */
	public static final StackMapTableEntry NOTHING =
		new StackMapTableEntry(JavaType.NOTHING, false);
	
	/** Integer. */
	public static final StackMapTableEntry INTEGER =
		new StackMapTableEntry(JavaType.INTEGER, true);
	
	/** Long. */
	public static final StackMapTableEntry LONG =
		new StackMapTableEntry(JavaType.LONG, true);
	
	/** Float. */
	public static final StackMapTableEntry FLOAT =
		new StackMapTableEntry(JavaType.FLOAT, true);
	
	/** Double. */
	public static final StackMapTableEntry DOUBLE =
		new StackMapTableEntry(JavaType.DOUBLE, true);
	
	/** The type. */
	protected final JavaType type;
	
	/** Is this type initialized? */
	protected final boolean isinitialized;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map entry.
	 *
	 * @param __t The type of variable to store.
	 * @param __init If {@code true} this variable is initialized.
	 * @throws InvalidClassFormatException If a non-object is set as not
	 * initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/02
	 */
	public StackMapTableEntry(JavaType __t, boolean __init)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Nothing can never be initialized
		if (__t.equals(JavaType.NOTHING))
		{
			// {@squirreljme.error JC3v The nothing type cannot be initialized.
			// (The type)}
			if (__init && __t.equals(JavaType.NOTHING))
				throw new InvalidClassFormatException(
					String.format("JI3w %s", __t));
		}
		
		// Otherwise only objects may be initialized
		else
		{
			// {@squirreljme.error JC3w Non-object types cannot be.
			// uninitialized (The type)}
			if (!__init && !__t.isObject())
				throw new InvalidClassFormatException(
					String.format("JC3w %s", __t));
		}
		
		// Set
		this.type = __t;
		this.isinitialized = __init;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof StackMapTableEntry))
			return false;
		
		StackMapTableEntry o = (StackMapTableEntry)__o;
		return this.type.equals(o.type) &&
			this.isinitialized == o.isinitialized;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^ (this.isinitialized ? 1 : 0);
	}
	
	/**
	 * Has this type been initialized?
	 *
	 * @return {@code true} if this type was initialized.
	 * @since 2017/08/13
	 */
	public boolean isInitialized()
	{
		return this.isinitialized;
	}
	
	/**
	 * Is this a top type?
	 *
	 * @return If this is a top type.
	 * @since 2018/09/23
	 */
	public final boolean isTop()
	{
		JavaType type = this.type;
		return type != null && type.isTop();
	}
	
	/**
	 * Does this represent a wide type?
	 *
	 * @return If this is a wide type.
	 * @since 2017/10/16
	 */
	public boolean isWide()
	{
		JavaType t = this.type;
		return t != null && t.isWide();
	}
	
	/**
	 * Returns the top type for this entry.
	 *
	 * @return The top type or {@code null} if there is none.
	 * @since 2018/09/22
	 */
	public final StackMapTableEntry topType()
	{
		if (this.equals(StackMapTableEntry.LONG))
			return StackMapTableEntry.TOP_LONG;
		else if (this.equals(StackMapTableEntry.DOUBLE))
			return StackMapTableEntry.TOP_DOUBLE;
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s%s",
				(this.isinitialized ? "" : "!"), this.type)));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/09/02
	 */
	public JavaType type()
	{
		return this.type;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/StackMapTableState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/**
 * This represents a single state within the stack map table which contains
 * a listing of all of the types used for local and stack variable along with
 * the current depth of the stack.
 *
 * @since 2017/07/28
 */
public final class StackMapTableState
{
	/** The depth of the stack. */
	protected final int depth;
	
	/** Local variables. */
	private final StackMapTableEntry[] _locals;
	
	/** Stack variables. */
	private final StackMapTableEntry[] _stack;
	
	/** String representation of this table. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map table state.
	 *
	 * @param __l Local variables.
	 * @param __s Stack variables.
	 * @param __d The depth of the stack.
	 * @throws InvalidClassFormatException If the state is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public StackMapTableState(StackMapTableEntry[] __l,
		StackMapTableEntry[] __s, int __d)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__l == null || __s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3x The depth of the stack is not within the
		// bounds of the stack. (The stack depth; The stack size)}
		int ns = __s.length;
		if (__d < 0 || __d > ns)
			throw new InvalidClassFormatException(
				String.format("JC3x %d %d", __d, ns));
		
		// Duplicate
		__l = __l.clone();
		__s = __s.clone();
		
		// Clear elements above the stack top
		for (int i = __d; i < ns; i++)
			__s[i] = null;
		
		// Verify each state
		StackMapTableState.__verify(__l);
		StackMapTableState.__verify(__s);
		
		// Set
		this._locals = __l;
		this._stack = __s;
		this.depth = __d;
	}
	
	/**
	 * Returns the depth of the stack.
	 *
	 * @return The stack depth.
	 * @since 2017/08/12
	 */
	public int depth()
	{
		return this.depth;
	}
	
	/**
	 * Obtains the local at the given index.
	 *
	 * @param __i The index to get.
	 * @return The type for the variable at the given index.
	 * @throws InvalidClassFormatException If the index is out of range.
	 * @since 2017/08/12
	 */
	public StackMapTableEntry getLocal(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC3y The specified local variable is out of
		// range. (The index)}
		StackMapTableEntry[] locals = this._locals;
		if (__i < 0 || __i >= locals.length)
			throw new InvalidClassFormatException(
				String.format("JC3y %d", __i));
		return locals[__i];
	}
	
	/**
	 * Obtains the stack at the given index.
	 *
	 * @param __i The index to get.
	 * @return The type for the variable at the given index.
	 * @throws InvalidClassFormatException If the index is out of range.
	 * @since 2017/08/12
	 */
	public StackMapTableEntry getStack(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC3z The specified stack variable is out of
		// range. (The index)}
		if (__i < 0 || __i >= this.depth)
			throw new InvalidClassFormatException(
				String.format("JC3z %d", __i));
		return this._stack[__i];
	}
	
	/**
	 * Returns the maximum number of local variables.
	 *
	 * @return The local variable count.
	 * @since 2019/02/17
	 */
	public final int maxLocals()
	{
		return this._locals.length;
	}
	
	/**
	 * Returns the maximum number of stack variables.
	 *
	 * @return The stack variable count.
	 * @since 2019/02/17
	 */
	public final int maxStack()
	{
		return this._stack.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("{locals=");
			StackMapTableState.__stringize(this._locals, sb);
			sb.append(", stack(");
			sb.append(this.depth);
			sb.append(")=");
			StackMapTableState.__stringize(this._stack, sb);
			sb.append("}");
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Stringizes the specified type array.
	 *
	 * @param __jt The type array to stringize.
	 * @param __sb The destination string builder.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	private static void __stringize(StackMapTableEntry[] __jt,
		StringBuilder __sb)
		throws NullPointerException
	{
		// Check
		if (__jt == null || __sb == null)
			throw new NullPointerException("NARG");
		
		// Open
		__sb.append('[');
		
		// Add
		for (int i = 0, n = __jt.length; i < n; i++)
		{
			if (i > 0)
				__sb.append(", ");
			
			__sb.append(__jt[i]);
		}
		
		// Close
		__sb.append(']');
	}
	
	/**
	 * Verifies the types within the map.
	 *
	 * @param __t The types to check.
	 * @throws InvalidClassFormatException If the type are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	private static void __verify(StackMapTableEntry[] __t)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Go through all entries, w acts as a kind of single entry stack which
		// is used to ensure that the tops of long/double are valid
		JavaType w = null;
		for (int i = 0, n = __t.length; i < n; i++)
		{
			StackMapTableEntry ea = __t[i];
			JavaType a = (ea != null ? ea.type() : null);
			
			// A wide type was pushed
			if (w != null)
			{
				// {@squirreljme.error JC40 The type at the read index does
				// not match the expected type following a wide type. (The wide
				// type; The expected type; The actual type; The input map)}
				JavaType t = w.topType();
				if (!t.equals(a))
					throw new InvalidClassFormatException(
						String.format("JC40 %s %s %s %s", w, t, a,
						Arrays.asList(__t)));
				
				// Clear
				w = null;
			}
			
			// No real checking has to be done unless it is a wide type
			else
			{
				if (a != null && a.isWide())
					w = a;
			}
		}
		
		// {@squirreljme.error JC41 Long or double appears at the end of the
		// type array and does not have a top associated with it.}
		if (w != null)
			throw new InvalidClassFormatException("JC41");
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/TableSwitch.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
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
191
192
193
194
195
196
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a table switch.
 *
 * @since 2018/09/20
 */
public final class TableSwitch
	implements IntMatchingJumpTable
{
	/** The default jump address. */
	protected final InstructionJumpTarget defaultjump;
	
	/** The low index. */
	protected final int low;
	
	/** The high index. */
	protected final int high;
	
	/** The jump targets. */
	private final InstructionJumpTarget[] _jumps;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the table switch.
	 *
	 * @param __def The default address.
	 * @param __lo The low address.
	 * @param __hi The high address.
	 * @param __jumps The jump offsets.
	 * @throws InvalidClassFormatException If the high is less than or equal
	 * to the low.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public TableSwitch(InstructionJumpTarget __def, int __lo, int __hi,
		InstructionJumpTarget[] __jumps)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__def == null || __jumps == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC42 Table switch high index is less than or
		// equal to the low index. (The low index; The high index)}
		if (__hi <= __lo)
			throw new InvalidClassFormatException(String.format("JC42 %d %d",
				__lo, __hi));
		
		// Check for null
		__jumps = __jumps.clone();
		for (InstructionJumpTarget j : __jumps)
			if (j == null)
				throw new NullPointerException("NARG");
		
		// Set
		this.low = __lo;
		this.high = __hi;
		this.defaultjump = __def;
		this._jumps = __jumps;
	}
	
	/**
	 * Converts this to a lookup switch.
	 *
	 * @return This table switch as a lookup switch.
	 * @since 2019/04/16
	 */
	public final LookupSwitch asLookupSwitch()
	{
		// These are needed to build keys
		InstructionJumpTarget[] jumps = this._jumps;
		int low = this.low,
			high = this.high,
			n = jumps.length;
		
		// Setup new key map, the jumps do not need to be adjusted because
		// they will map the same!
		int[] newkeys = new int[n];
		for (int o = 0, k = low; k <= high; k++, o++)
			newkeys[o] = k;
		
		// Build
		return new LookupSwitch(this.defaultjump, newkeys, jumps);
	}
	
	/**
	 * Returns the jumps.
	 *
	 * @return The jumps.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget[] jumps()
	{
		return this._jumps.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final InstructionJumpTarget match(int __k)
	{
		// Use default if out of bounds
		int low = this.low,
			high = this.high;
		if (__k < low || __k > high)
			return this.defaultjump;
		
		return this._jumps[__k - low];
	}
	
	/**
	 * Returns the size of the switch.
	 *
	 * @return The size.
	 * @since 2019/04/16
	 */
	public final int size()
	{
		return this._jumps.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/31
	 */
	@Override
	public final InstructionJumpTarget[] targets()
	{
		InstructionJumpTarget[] jumps = this._jumps;
		int n = jumps.length;
		
		// Start off array with the default jump
		InstructionJumpTarget[] rv = new InstructionJumpTarget[n + 1];
		rv[0] = this.defaultjump;
		
		// Add all the others
		for (int i = 0, o = 1; i < n; i++, o++)
			rv[o] = jumps[i];
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Set with default first
			StringBuilder sb = new StringBuilder("{default=");
			sb.append(this.defaultjump);
			
			// Add all matches and their targets
			InstructionJumpTarget[] jumps = this._jumps;
			for (int i = 0, n = jumps.length, v = this.low; i < n; i++, v++)
			{
				sb.append(", ");
				
				sb.append(v);
				sb.append('=');
				sb.append(jumps[i]);
			}
			
			// Cleans
			sb.append('}');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/UTFConstantEntry.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a UTF-8 constant pool entry.
 *
 * @since 2017/06/09
 */
public final class UTFConstantEntry
{
	/** The string representation. */
	protected final String string;
	
	/**
	 * Initializes the constant entry.
	 *
	 * @param __s The string used.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/09
	 */
	public UTFConstantEntry(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof UTFConstantEntry))
			return false;
		
		return this.string.equals(((UTFConstantEntry)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/WideConstantTopEntry.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an entry which is the top of a long or double so that the
 * space is not treated as {@code null} or the type of the base.
 *
 * @since 2017/06/09
 */
public final class WideConstantTopEntry
{
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/__StackMapParser__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This class is used to parse the stack map and initialize the initial
 * snapshot states for jump targets within the method.
 *
 * @since 2017/04/16
 */
final class __StackMapParser__
{
	/** The stream to decode from. */
	protected final DataInputStream in;
	
	/** The number of stack entries. */
	protected final int maxstack;
	
	/** The number of local entries. */
	protected final int maxlocals;
	
	/** The method byte code. */
	protected final ByteCode code;
	
	/** Constant pool. */
	protected final Pool pool;
	
	/** This type. */
	protected final JavaType thistype;
		
	/** Verification targets. */
	private final Map<Integer, StackMapTableState> _targets;
	
	/** The next stack state. */
	private final StackMapTableEntry[] _nextstack;
	
	/** The next local variable state. */
	private final StackMapTableEntry[] _nextlocals;
	
	/** The placement address. */
	private int _placeaddr;
	
	/** The top of the stack. */
	private int _stacktop;
	
	/**
	 * Initializes the stack map parser.
	 *
	 * @param __p The constant pool.
	 * @param __m The method this code exists within.
	 * @param __new Should the new stack map table format be used?
	 * @param __in The data for the stack map table.
	 * @param __bc The owning byte code.
	 * @param __tt This type.
	 * @throws InvalidClassFormatException If the stack map table is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/04/16
	 */
	__StackMapParser__(Pool __p, Method __m, boolean __new, byte[] __in,
		ByteCode __bc, JavaType __tt)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__p == null || __m == null || __in == null || __bc == null ||
			__tt == null)
			throw new NullPointerException("NARG");
		
		// Set
		DataInputStream xin;
		this.in = (xin = new DataInputStream(
			new ByteArrayInputStream(__in)));
		int maxstack = __bc.maxStack(),
			maxlocals = __bc.maxLocals();
		this.maxstack = maxstack;
		this.maxlocals = maxlocals;
		this.code = __bc;
		this.pool = __p;
		this.thistype = __tt;
		
		// This is used to set which variables appear next before a state is
		// constructed with them
		StackMapTableEntry[] nextstack, nextlocals;
		this._nextstack = (nextstack = new StackMapTableEntry[maxstack]);
		this._nextlocals = (nextlocals = new StackMapTableEntry[maxlocals]);
		
		// Setup initial state
		// {@squirreljme.error JC43 The arguments that are required for the
		// given method exceeds the maximum number of permitted local
		// variables. (The method in question; The required number of local
		// variables; The maximum number of local variables)}
		MethodHandle handle = __m.handle();
		boolean isinstance = !__m.flags().isStatic();
		JavaType[] jis = handle.javaStack(isinstance);
		int jn = jis.length;
		if (jn > maxlocals)
			throw new InvalidClassFormatException(
				String.format("JC43 %s %d %d", handle, jn, maxlocals));
		
		// Setup entries
		// If this is an instance initializer method then only the first
		// argument is not initialized
		boolean isiinit = isinstance && __m.name().isInstanceInitializer();
		for (int i = 0; i < jn; i++)
			nextlocals[i] = new StackMapTableEntry(jis[i],
				(isiinit ? (i != 0) : true));
		
		// Initialize entries with nothing
		for (int i = 0, n = nextstack.length; i < n; i++)
			if (nextstack[i] == null)
				nextstack[i] = StackMapTableEntry.NOTHING;
		for (int i = 0, n = nextlocals.length; i < n; i++)
			if (nextlocals[i] == null)
				nextlocals[i] = StackMapTableEntry.NOTHING;
		
		// Where states go
		Map<Integer, StackMapTableState> targets = new LinkedHashMap<>();
		this._targets = targets;
		
		// Record state
		this.__next(0, true, -1, -1);
		
		// Parse the stack map table
		try (DataInputStream in = xin)
		{
			// Parsing the class stack map table
			if (!__new)
			{
				// Read the number of entries in the table
				int ne = xin.readUnsignedShort();
			
				// All entries in the table are full frames
				for (int i = 0; i < ne; i++)
					this.__next(this.__oldStyle(), true, -1, i);
			}
		
			// The modern stack map table
			else
			{
				// Read the number of entries in the table
				int ne = xin.readUnsignedShort();
			
				// Read them all
				for (int i = 0; i < ne; i++)
				{
					// Read the frame type
					int type = xin.readUnsignedByte();
					int addr;
				
					// Full frame?
					if (type == 255)
						addr = this.__fullFrame();
				
					// Same frame?
					else if (type >= 0 && type <= 63)
						addr = this.__sameFrame(type);
				
					// Same locals but a single stack item
					else if (type >= 64 && type <= 127)
						addr = this.__sameLocalsSingleStack(type - 64);
				
					// Same locals, single stack item, explicit delta
					else if (type == 247)
						addr = this.__sameLocalsSingleStackExplicit();
				
					// Chopped frame
					else if (type >= 248 && type <= 250)
						addr = this.__choppedFrame(251 - type);
				
					// Same frame but with a supplied delta
					else if (type == 251)
						addr = this.__sameFrameDelta();
				
					// Appended frame
					else if (type >= 252 && type <= 254)
						addr = this.__appendFrame(type - 251);
				
					// {@squirreljme.error JC44 Unknown StackMapTable
					// verification type. (The verification type)}
					else
						throw new InvalidClassFormatException(
							String.format("JC44 %d", type));
					
					// Setup next
					this.__next(addr, false, type, i);
				}
			}
		}
		
		// {@squirreljme.error JC45 Failed to parse the stack map table.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC45", e);
		}
	}
	
	/**
	 * Returns the stack map table.
	 *
	 * @return The parsed stack map table.
	 * @since 2017/10/16
	 */
	public StackMapTable get()
	{
		return new StackMapTable(this._targets);
	}
	
	/**
	 * Append extra locals to the frame and clear the stack.
	 *
	 * @param __addlocs The number of local variables to add.
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __appendFrame(int __addlocs)
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Stack is cleared
		this._stacktop = 0;
		
		// Read in local variables
		StackMapTableEntry[] nextlocals = this._nextlocals;
		int n = this.maxlocals;
		for (int i = 0; __addlocs > 0 && i < n; i++)
		{
			// Get slot here
			StackMapTableEntry s = nextlocals[i];
			
			// If it is not empty, ignore it
			if (!s.equals(StackMapTableEntry.NOTHING))
				continue;
			
			// Set it
			StackMapTableEntry aa;
			nextlocals[i] = (aa = this.__loadInfo());
			__addlocs--;
			
			// If a wide element was added, then the next one becomes TOP
			if (aa.isWide())
				nextlocals[++i] = aa.topType();
		}
		
		// Error if added stuff remains
		// {@squirreljme.error JC46 Appending local variables to the frame
		// however there is no room to place them. (The remaining local count)}
		if (__addlocs != 0)
			throw new InvalidClassFormatException(
				String.format("JC46 %d", __addlocs));
		
		return rv;
	}
	
	/**
	 * Similar frame with no stack and the top few locals removed.
	 *
	 * @param __chops The number of variables which get chopped.
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __choppedFrame(int __chops)
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// No stack
		this._stacktop = 0;
		
		// Chop off some locals
		StackMapTableEntry[] nextlocals = this._nextlocals;
		int i, n = this.maxlocals;
		for (i = n - 1; __chops > 0 && i >= 0; i--)
		{
			// Get slot here
			StackMapTableEntry s = nextlocals[i];
			
			// If it is empty, ignore it
			if (s.equals(StackMapTableEntry.NOTHING))
				continue;
			
			// Clear top off, but only if it is not an undefined top
			if (s.isTop() && !s.equals(StackMapTableEntry.TOP_UNDEFINED))
				nextlocals[i--] = StackMapTableEntry.NOTHING;
			
			// Clear it
			nextlocals[i] = StackMapTableEntry.NOTHING;
			__chops--;
		}
		
		// Still chops left?
		// {@squirreljme.error JC47 Could not chop off all local variables
		// because there are no variables remaining to be chopped. (The
		// remaining variables to remove)}
		if (__chops != 0)
			throw new InvalidClassFormatException(
				String.format("JC47 %d", __chops));
		
		return rv;
	}
	
	/**
	 * This reads and parses the full stack frame.
	 *
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __fullFrame()
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Read in local variables
		int nl = in.readUnsignedShort();
		
		// {@squirreljme.error JC48 The number of specified local variables in
		// the full frame exceeds the maximum permitted local variable
		// count. (The read local variable count; The number of locals the
		// method uses)}
		int maxlocals = this.maxlocals,
			maxstack = this.maxstack;
		if (nl > maxlocals)
			throw new InvalidClassFormatException(
				String.format("JC48 %d %d", nl, maxlocals));
		int i, o;
		StackMapTableEntry[] nextlocals = this._nextlocals;
		for (i = 0, o = 0; i < nl; i++)
		{
			StackMapTableEntry e;
			nextlocals[o++] = (e = this.__loadInfo());
			
			// Add top?
			if (e.isWide())
				nextlocals[o++] = e.topType();
		}
		for (;o < maxlocals; o++)
			nextlocals[o] = StackMapTableEntry.NOTHING;
		
		// Read in stack variables
		StackMapTableEntry[] nextstack = this._nextstack;
		int ns = in.readUnsignedShort();
		for (i = 0, o = 0; i < ns; i++)
		{
			StackMapTableEntry e;
			nextstack[o++] = (e = this.__loadInfo());
			
			// Add top?
			if (e.isWide())
				nextstack[o++] = e.topType();
		}
		this._stacktop = o;
		
		return rv;
	}
	
	/**
	 * Loads type information for the stack.
	 *
	 * @return The type which was parsed.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private StackMapTableEntry __loadInfo()
		throws IOException
	{
		// Read the tag
		DataInputStream in = this.in;
		int tag = in.readUnsignedByte();
		
		// Depends on the tag
		switch (tag)
		{
				// Top
			case 0:
				return StackMapTableEntry.TOP_UNDEFINED;
				
				// Integer
			case 1:
				return StackMapTableEntry.INTEGER;
				
				// Float
			case 2:
				return StackMapTableEntry.FLOAT;
				
				// Double
			case 3:
				return StackMapTableEntry.DOUBLE;
				
				// Long
			case 4:
				return StackMapTableEntry.LONG;
				
				// Nothing
			case 5:
				return StackMapTableEntry.NOTHING;
				
				// Uninitialized this
			case 6:
				return new StackMapTableEntry(this.thistype, false);
				
				// Initialized object
			case 7:
				return new StackMapTableEntry(new JavaType(
					this.pool.<ClassName>get(ClassName.class,
					in.readUnsignedShort()).field()), true);
				
				// Uninitialized variable for a new instruction, the pc points
				// to the new instruction so the class must be read from
				// that instruction to determine the type of that actual
				// object
			case 8:
				return new StackMapTableEntry(new JavaType(this.pool.
					<ClassName>get(ClassName.class, this.code.
					readRawCodeUnsignedShort(in.readUnsignedShort() + 1))),
					false);
				
				// Unknown
			default:
				// {@squirreljme.error JC49 The verification tag in the
				// StackMap/StackMapTable attribute is not valid. (The tag)}
				throw new InvalidClassFormatException(
					String.format("JC49 %d", tag));
		}
	}
	
	/**
	 * Initializes the next state.
	 *
	 * @param __au The address offset.
	 * @param __abs Absolute position?
	 * @param __type The type of entry that was just handled, this is for
	 * debug purposes.
	 * @param __ne The entry number of this index.
	 * @return The state for the next address.
	 * @since 2016/05/20
	 */
	StackMapTableState __next(int __au, boolean __abs, int __type, int __ne)
	{
		// Where are we?
		int naddr = this._placeaddr;
		
		// Generate it
		StackMapTableState rv;
		try
		{
			rv = new StackMapTableState(this._nextlocals,
				this._nextstack, this._stacktop);
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error JC4a Invalid stack map table at the
			// specified address. (The address offset; Is the address offset
			// absolute?; The placement address; The type of entry which
			// was just handled, -1 means it was old-style or initial state.)}
			throw new InvalidClassFormatException(String.format(
				"JC4a %d %b %d %d", __au, __abs, naddr, __type), e);
		}
		
		// Set new placement address, the first is always absolute
		int pp = (__abs ? __au :
			naddr + (__au + (__ne == 0 ? 0 : 1)));
		this._placeaddr = pp;
	
		// {@squirreljme.error JC4b A duplicate stack map information for the
		// specified address has already been loaded. (The address; The
		// already existing information; The information to be placed there;
		// Absolute address?; Current address of parse; The address offset;
		// The parsed type)}
		// Note that the first instruction if it is a jump target may have an
		// explicit state even if it one is always defined implicitly, so
		// just ignore it
		Map<Integer, StackMapTableState> targets = this._targets;
		if (pp != 0 && targets.containsKey(pp))
			throw new IllegalStateException(String.format(
				"JC4b %d %s %s %b %d %d %d",
				pp, targets.get(pp), rv, __abs, naddr, __au, __type));
		targets.put(pp, rv);
		
		// Debug
		/*todo.DEBUG.note("Read state @%d: %s%n", pp, rv);*/
	
		// The stored state
		return rv;
	}
	
	/**
	 * Reads in an old style full frame.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __oldStyle()
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Read in local variables
		int nl = in.readUnsignedShort();
		StackMapTableEntry[] inlocals = new StackMapTableEntry[nl];
		for (int i = 0; i < nl; i++)
			inlocals[i] = this.__loadInfo();
		
		// Read in stack variables
		int ns = in.readUnsignedShort();
		StackMapTableEntry[] instack = new StackMapTableEntry[ns];
		for (int i = 0; i < ns; i++)
			instack[i] = this.__loadInfo();
		
		// Assign read local variables
		int lat = 0;
		StackMapTableEntry[] nextlocals = this._nextlocals;
		for (int i = 0; i < nl; i++)
		{
			// Copy in
			StackMapTableEntry e = inlocals[i];
			nextlocals[lat++] = e;
			
			// Handling wide type?
			if (e.isWide())
			{
				// Set top
				nextlocals[lat++] = e.topType();
				
				// If the top is explicit, then skip it
				if (i + 1 < nl && inlocals[i + 1].isTop())
					i++;
			}
		}
		
		// Assign read stack variables
		int sat = 0;
		StackMapTableEntry[] nextstack = this._nextstack;
		for (int i = 0; i < ns; i++)
		{
			// Copy in
			StackMapTableEntry e = instack[i];
			nextstack[sat++] = e;
			
			// Handling wide type?
			if (e.isWide())
			{
				// Set top
				nextstack[sat++] = e.topType();
				
				// If the top is explicit, then skip it
				if (i + 1 < ns && instack[i + 1].isTop())
					i++;
			}
		}
		
		// Stack depth is where the next stack would have been placed
		this._stacktop = sat;
		
		return rv;
	}
	
	/**
	 * The same frame is used with no changes.
	 *
	 * @param __delta The offset from the earlier offset.
	 * @return The address information.
	 * @since 2016/03/26
	 */
	private int __sameFrame(int __delta)
	{
		return __delta;
	}
	
	/**
	 * Same frame but with a supplied delta rather than using it with the type.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameFrameDelta()
		throws IOException
	{
		return this.in.readUnsignedShort();
	}
	
	/**
	 * Same locals but the stack has only a single entry.
	 *
	 * @param __delta The delta offset.
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameLocalsSingleStack(int __delta)
		throws IOException
	{
		// Load single entry
		StackMapTableEntry ent;
		this._nextstack[0] = (ent = this.__loadInfo());
		
		// If the entry is wide then the top type will not be specified as it
		// will be implicit, so we need to set the according type
		if (ent.isWide())
		{
			this._nextstack[1] = ent.topType();
			this._stacktop = 2;
		}
		
		// Only a single entry exists
		else
			this._stacktop = 1;
		
		return __delta;
	}
	
	/**
	 * Same locals but the stack has only a single entry, the delta offset
	 * is specified.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameLocalsSingleStackExplicit()
		throws IOException
	{
		return this.__sameLocalsSingleStack(this.in.readUnsignedShort());
	}
}

Added modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/package-info.java.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes which are used to represent class files
 * in an abstract structure format. None of the classes in this package perform
 * any JIT operation, it is only concerned with loading class files and
 * representing them.
 *
 * Structures are read, then they are compiled by the JIT.
 *
 * @since 2017/09/26
 */

package net.multiphasicapps.classfile;

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

import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that classes load properly.
 *
 * @since 2019/03/10
 */
public class TestClassLoad
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x))
			{
				ClassFile.decode(in);
			}
	}
}

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

import dev.shadowtail.classfile.mini.Minimizer;
import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that minimizing is performed properly and loading minimized classes
 * works as well.
 *
 * @since 2019/03/10
 */
public class TestMinimizedLoad
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x))
			{
				Minimizer.minimize(ClassFile.decode(in));
			}
	}
}

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

import dev.shadowtail.classfile.mini.Minimizer;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that minimizing is performed properly.
 *
 * @since 2019/03/10
 */
public class TestMinimizer
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x);
				ByteArrayOutputStream out = new ByteArrayOutputStream())
			{
				Minimizer.minimize(ClassFile.decode(in), out);
			}
	}
}

Added modules/tool-classfile/src/test/resources/ByteDeque.data.__mime.




























































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 640 ByteDeque.class
yv66vgAAADMBPAcAzAN/////CgBaAM0KADEAzgcAzwoABQDOCQBaANAJAFoA
0QcA0ggA0woACQDUCQBaANUKAFoA1gcA1wgA2AoADgDUBwDZCADaCgARANQJ
AFoA2wcA3AgA3QoAFQDUCgAFAN4JAFoA3wkAWgDgBwDhCgAbAM4KAFoA4ggA
4wkAWgDkCQBaAOUKAAUA5goABQDnBwBlCgAFAOgLAI8A6QsAjwDqCgDrAOwK
AAUA7QgA7goABQDvBwDwCgArAM4KAAUA8QgA8goAWgDzCAD0BwD1CgABAPYK
APcA+AgA+QgA+goAWgD7CgBaAPwHAP0IAP4KADgA1AoAWgD/CAEACgEBAQIK
AFoBAwoAWgEECgBaAQUKAFoBBgoAWgEHCgBaAQgKAFoBCQoAWgEKCAELCgBa
AQwKAFoBDQgBDggBDwoAWgEQCAERCAESCAETCQBaARQKAAUBFQsAyAEWCAEX
CgABARgKAAEBGQoAAQEaCgABARsHARwIAR0KAFcA1AcBHgEAC19CTE9DS19T
SVpFAQABSQEAC19CTE9DS19NQVNLAQAMX0JMT0NLX1NISUZUAQAIY2FwYWNp
dHkBAAdfYmxvY2tzAQAWTGphdmEvdXRpbC9MaW5rZWRMaXN0OwEACVNpZ25h
dHVyZQEAGkxqYXZhL3V0aWwvTGlua2VkTGlzdDxbQj47AQAFX3NvbG8BAAJb
QgEABl90b3RhbAEABV9oZWFkAQAFX3RhaWwBAAY8aW5pdD4BAAMoKVYBAARD
b2RlAQAPTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAE
dGhpcwEAIkxuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0J5dGVEZXF1ZTsBAAQo
SSlWAQAFX19jYXABAA1TdGFja01hcFRhYmxlAQAKRXhjZXB0aW9ucwEACGFk
ZEZpcnN0AQAEKEIpVgEAA19fYgEAAUIBAARzb2xvAQAFKFtCKVYBAAcoW0JJ
SSlWAQADX19vAQADX19sAQAFdG90YWwBAAhuZXd0b3RhbAEABmJsb2NrcwEA
Am5iAQAEaGVhZAEABHRhaWwBABZMb2NhbFZhcmlhYmxlVHlwZVRhYmxlAQAH
YWRkTGFzdAEAAmJsAQABaQEABWxpbWl0AQACYnMBAAJibQEABGxlZnQBAAJh
dAEACWF2YWlsYWJsZQEAAygpSQEABWNsZWFyBwEfAQALZGVsZXRlRmlyc3QB
AAQoSSlJAQAGbGFzdGJsAQABWgEAAnJjAQADZ2V0AQAEKEkpQgEAA19fYQEA
AnJ2AQAGKElbQilJAQAIKElbQklJKUkBAAhnZXRGaXJzdAEAAygpQgEABShb
QilJAQAHKFtCSUkpSQEAB2dldExhc3QBAAdpc0VtcHR5AQADKClaAQAKb2Zm
ZXJGaXJzdAEABChCKVoBAANpc2UBACFMamF2YS9sYW5nL0lsbGVnYWxTdGF0
ZUV4Y2VwdGlvbjsBAAUoW0IpWgEAByhbQklJKVoBAAlvZmZlckxhc3QBAAlw
ZWVrRmlyc3QBAAFlAQAiTGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0
aW9uOwEACHBlZWtMYXN0AQALcmVtb3ZlRmlyc3QBAANydmEBAANydmIBAApy
ZW1vdmVMYXN0AQADc2V0AQAEc2l6ZQEAC3RvQnl0ZUFycmF5AQAEKClbQgEA
AnN6AQAHd3JpdGVUbwEAGShMamF2YS9pby9PdXRwdXRTdHJlYW07KVYBAARf
X29zAQAWTGphdmEvaW8vT3V0cHV0U3RyZWFtOwcBIAEADV9fZ2V0T3JTZXRW
aWEBAAooWklbQklJWilJAQADbGl0AQAYTGphdmEvdXRpbC9MaXN0SXRlcmF0
b3I7AQAIYmFja3NraXABAAJpdAEAFExqYXZhL3V0aWwvSXRlcmF0b3I7AQAG
X19sYXN0AQAFX19zZXQBAAZibHNraXABAAVyaGVhZAEAHExqYXZhL3V0aWwv
TGlzdEl0ZXJhdG9yPFtCPjsBABhMamF2YS91dGlsL0l0ZXJhdG9yPFtCPjsH
ASEBAAg8Y2xpbml0PgEAClNvdXJjZUZpbGUBAA5CeXRlRGVxdWUuamF2YQEA
EWphdmEvbGFuZy9JbnRlZ2VyDABpAHAMAGkAagEAFGphdmEvdXRpbC9MaW5r
ZWRMaXN0DABgAGEMAGQAZQEAImphdmEvbGFuZy9JbGxlZ2FsQXJndW1lbnRF
eGNlcHRpb24BAARBRTAyDABpASIMAF8AXAwAdAB6AQAeamF2YS9sYW5nL051
bGxQb2ludGVyRXhjZXB0aW9uAQAETkFSRwEAI2phdmEvbGFuZy9JbmRleE91
dE9mQm91bmRzRXhjZXB0aW9uAQAEQkFPQgwAZgBcAQAfamF2YS9sYW5nL0ls
bGVnYWxTdGF0ZUV4Y2VwdGlvbgEABEFFMDMMALIAjQwAZwBcDABoAFwBAAl0
b2RvL1RPRE8MAIQAegEABEFFMDQMAFsAXAwAXQBcDACEASMMAJ8BJAwBJQEm
DAEnAKEMASgBJAcBKQwBKgErDACOAGoBAARBRTA1DACbASQBAAl0b2RvL09P
UFMMAK0BJAEABEFFMDYMAJUAmgEAB0FFMDcgJWQBABBqYXZhL2xhbmcvT2Jq
ZWN0DAEsAS0HAS4MAS8BMAEABEFFMDgBAApBRTA5ICVkICVkDAC7ALwMAJsA
ngEAIGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0aW9uAQAEQUUwYQwA
nwCeAQAEQUUwYgcBMQwBMgEzDACMAI0MAHQAdQwAogCnDACEAHUMAKgApwwA
mwCcDACfAJwMAK0AngEABEFFMGMMAJAAkQwAsACeAQAEQUUwZAEABEFFMGUM
ALEAmgEAB0FFMGYgJWQBAARBRTBnAQAKQUUwaCAlZCAlZAwAXgBcDAE0ATUM
ATYBJAEALG5ldC5tdWx0aXBoYXNpY2FwcHMudXRpbC5kYXRhZGVxdWUuYmxv
Y2tzaXplDAE3ATgMATkAjQwBOgCRDAE7AJEBABpqYXZhL2xhbmcvUnVudGlt
ZUV4Y2VwdGlvbgEAB0FFMDEgJWQBACBuZXQvbXVsdGlwaGFzaWNhcHBzL2lv
L0J5dGVEZXF1ZQEAEmphdmEvdXRpbC9JdGVyYXRvcgEAE2phdmEvaW8vSU9F
eGNlcHRpb24BABZqYXZhL3V0aWwvTGlzdEl0ZXJhdG9yAQAVKExqYXZhL2xh
bmcvU3RyaW5nOylWAQAVKExqYXZhL2xhbmcvT2JqZWN0OylWAQAUKClMamF2
YS9sYW5nL09iamVjdDsBAAhpdGVyYXRvcgEAFigpTGphdmEvdXRpbC9JdGVy
YXRvcjsBAAdoYXNOZXh0AQAEbmV4dAEAEGphdmEvdXRpbC9BcnJheXMBAARm
aWxsAQAGKFtCQilWAQAHdmFsdWVPZgEAFihJKUxqYXZhL2xhbmcvSW50ZWdl
cjsBABBqYXZhL2xhbmcvU3RyaW5nAQAGZm9ybWF0AQA5KExqYXZhL2xhbmcv
U3RyaW5nO1tMamF2YS9sYW5nL09iamVjdDspTGphdmEvbGFuZy9TdHJpbmc7
AQAOamF2YS9sYW5nL01hdGgBAANtYXgBAAUoSUkpSQEADGxpc3RJdGVyYXRv
cgEAGyhJKUxqYXZhL3V0aWwvTGlzdEl0ZXJhdG9yOwEACHByZXZpb3VzAQAK
Z2V0SW50ZWdlcgEAKChMamF2YS9sYW5nL1N0cmluZztJKUxqYXZhL2xhbmcv
SW50ZWdlcjsBAAhpbnRWYWx1ZQEAFW51bWJlck9mVHJhaWxpbmdaZXJvcwEA
CGJpdENvdW50ACEAWgAxAAAACQAaAFsAXAAAABoAXQBcAAAAGgBeAFwAAAAU
AF8AXAAAABIAYABhAAEAYgAAAAIAYwASAGQAZQAAAEIAZgBcAAAAQgBnAFwA
AABCAGgAXAAAACsAAQBpAGoAAQBrAAAANQACAAEAAAAHKhICtwADsQAAAAIA
bAAAAAoAAgAAAFsABgBcAG0AAAAMAAEAAAAHAG4AbwAAAAEAaQBwAAIAawAA
AIkAAwACAAAAKiq3AAQquwAFWbcABrUAByoEvAi1AAgbnAANuwAJWRIKtwAL
vyobtQAMsQAAAAMAbAAAAB4ABwAAAGcABAA3AA8AOwAWAGkAGgBqACQAbQAp
AG4AbQAAABYAAgAAACoAbgBvAAAAAAAqAHEAXAABAHIAAAANAAH/ACQAAgcA
WgEAAABzAAAABAABAAkAEQB0AHUAAgBrAAAAWwAEAAMAAAARKrQACE0sAxtU
KiwDBLYADbEAAAACAGwAAAASAAQAAAB7AAUAfAAJAH0AEAB+AG0AAAAgAAMA
AAARAG4AbwAAAAAAEQB2AHcAAQAFAAwAeABlAAIAcwAAAAQAAQAVABEAdAB5
AAIAawAAAEEABAACAAAACSorAyu+tgANsQAAAAIAbAAAAAoAAgAAAIwACACN
AG0AAAAWAAIAAAAJAG4AbwAAAAAACQB2AGUAAQBzAAAABgACABUADgARAHQA
egACAGsAAAFOAAMACgAAAHIrxwANuwAOWRIPtwAQvxybAA8dmwALHB1gK76k
AA27ABFZEhK3ABO/HZoABLEqtAAUNgQVBB1gNgUVBZsADBUFKrQADKQADbsA
FVkSFrcAF78qtAAHOgYZBrYAGDYHKrQAGTYIKrQAGjYJuwAbWbcAHL8AAAAE
AGwAAAA6AA4AAAChAAQAogAOAKMAHgCkACgApwAsAKgALQCsADMArQA5AK4A
RwCvAFEAsgBXALMAXgC0AGoAtgBtAAAAZgAKAAAAcgBuAG8AAAAAAHIAdgBl
AAEAAAByAHsAXAACAAAAcgB8AFwAAwAzAD8AfQBcAAQAOQA5AH4AXAAFAFcA
GwB/AGEABgBeABQAgABcAAcAZAAOAIEAXAAIAGoACACCAFwACQCDAAAADAAB
AFcAGwB/AGMABgByAAAADAAGDg8JBP0AGQEBCQBzAAAACAADABUAEQAOABEA
hAB1AAIAawAAAFsABAADAAAAESq0AAhNLAMbVCosAwS2AB2xAAAAAgBsAAAA
EgAEAAAAxAAFAMUACQDGABAAxwBtAAAAIAADAAAAEQBuAG8AAAAAABEAdgB3
AAEABQAMAHgAZQACAHMAAAAEAAEAFQARAIQAeQACAGsAAABBAAQAAgAAAAkq
KwMrvrYAHbEAAAACAGwAAAAKAAIAAADVAAgA1gBtAAAAFgACAAAACQBuAG8A
AAAAAAkAdgBlAAEAcwAAAAYAAgAVAA4AEQCEAHoAAgBrAAACmQAEABEAAADt
K8cADbsADlkSD7cAEL8cmwAPHZsACxwdYCu+pAANuwARWRIStwATvx2aAASx
KrQAFDYEFQQdYDYFFQWbAAwVBSq0AAykAA27ABVZEh63ABe/KrQABzoGGQa2
ABg2Byq0ABk2CCq0ABo2CbIAHzYKsgAgNgsdNgwcNg0VDJ4AZBUJmgATFQq8
CDoOGQYZDrYAIacADRkGtgAiwAAjOg4VChUJZDYPFQwVD6IABxUMNg8DNhAV
EBUPogAYGQ4VCYQJASsVDYQNATNUhBABp//nFQkVC342CRUMFQ9kNgyn/50q
FQW1ABQqFQm1ABqxAAAABABsAAAAigAiAAAA6gAEAOsADgDsAB4A7QAoAPAA
LADxAC0A9QAzAPYAOQD3AEcA+ABRAPsAVwD8AF4A/QBqAQAAbwEBAHQBAgB3
AQMAegEEAH8BCQCEAQsAigEMAJQBEQCeARQApQEVAKwBFgCwARkAugEaAMkB
GQDPAR0A1gEgAN0BIQDgASQA5gElAOwBJgBtAAAAtgASAIoACgCFAGUADgCz
ABwAhgBcABAAngA/AIUAZQAOAKUAOACHAFwADwAAAO0AbgBvAAAAAADtAHYA
ZQABAAAA7QB7AFwAAgAAAO0AfABcAAMAMwC6AH0AXAAEADkAtAB+AFwABQBX
AJYAfwBhAAYAXgCPAIAAXAAHAGQAiQCBAFwACABqAIMAggBcAAkAbwB+AIgA
XAAKAHQAeQCJAFwACwB3AHYAigBcAAwAegBzAIsAXAANAIMAAAAMAAEAVwCW
AH8AYwAGAHIAAAA8AA0ODwkE/QAZAQEJ/wAoAA4HAFoHACMBAQEBBwAFAQEB
AQEBAQAAGfwACQcAI/wAEQH8AAIB+gAb+QAQAHMAAAAIAAMAFQARAA4AEQCM
AI0AAQBrAAAALwABAAEAAAAFKrQAFKwAAAACAGwAAAAGAAEAAAEwAG0AAAAM
AAEAAAAFAG4AbwAAABEAjgBqAAEAawAAALkAAgAEAAAAOSoDtQAUKgO1ABkq
A7UAGiq0AAdMK7YAJE0suQAlAQCZABUsuQAmAQDAACNOLQO4ACen/+grtgAo
sQAAAAQAbAAAACIACAAAATsABQE8AAoBPQAPAUAAFAFBACwBQgA0AUMAOAFE
AG0AAAAgAAMALAAFAIUAZQADAAAAOQBuAG8AAAAUACUAfwBhAAEAgwAAAAwA
AQAUACUAfwBjAAEAcgAAAA4AAv0AGQcABQcAj/oAGgARAJAAkQACAGsAAAK7
AAMAEAAAAQobnAANuwARWRIptwATvxuaAAUDrCq0ABQ9HJoABQOsGxyiAAcb
pwAEHD4cHWQ2BCq0AAc6BRkFtgAYNgYqtAAZNgcqtAAaNggdNgmyAB82CrIA
IDYLFQmeAJQZBbYAKsAAIzoMFQYEoAAHBKcABAM2DRUNmQAVFQiaAAgVCqcA
BRUIFQdkpwAIFQoVB2Q2DhUJFQ6iAAcVCTYOFQ6cAAu7ACtZtwAsvwM2DxUP
FQ6iABIZDBUHhAcBA1SEDwGn/+0VBxULfjYHFQeZAA8VDZkAExUHFQigAAwZ
BbYALVeEBv8VCRUOZDYJp/9tFQSaAAkDWTYINgcqFQS1ABQqFQe1ABkqFQi1
ABodrAAAAAQAbAAAAJoAJgAAAVMABAFUAA4BVwASAVgAFAFbABkBXAAdAV0A
HwFgACoBYQAvAWQANQFlADwBZgBIAWkASwFqAFABawBVAWwAWgFvAGQBcABx
AXMAjwF0AJYBdQCaAXkAnwF6AKcBfQCxAX4AugF9AMABgQDHAYQA2AGGAN4B
hwDhAYsA6AGMAOsBjwDwAZAA9gGTAPwBlAECAZUBCAGYAG0AAACiABAAqgAW
AIYAXAAPAGQAhACFAGUADABxAHcAkgCTAA0AjwBZAJQAXAAOAAABCgBuAG8A
AAAAAQoAfABcAAEAGQDxAH0AXAACACoA4ACHAFwAAwAvANsAfgBcAAQANQDV
AH8AYQAFADwAzgCAAFwABgBCAMgAgQBcAAcASADCAIIAXAAIAEsAvwCKAFwA
CQBQALoAiABcAAoAVQC1AIkAXAALAIMAAAAMAAEANQDVAH8AYwAFAHIAAABF
ABQOBfwACgEIQAH/ACsADAcAWgEBAQEHAAUBAQEBAQEAAPwAGAcAI0AB/AAQ
AUEBBUQB/AAMAQz8AAIB+gAVFwj4AAkKAHMAAAAEAAEAEQARAJUAlgACAGsA
AACtAAcABAAAAD0bnAANuwARWRIutwATvyq0AAhNKhssAwS2AC8+HQSgAAcs
AzOsuwARWRIwBL0AMVkDG7gAMlO4ADO3ABO/AAAAAwBsAAAAHgAHAAABqAAE
AakADgGrABMBrAAcAa0AIQGuACUBsgBtAAAAKgAEAAAAPQBuAG8AAAAAAD0A
lwBcAAEAEwAqAHgAZQACABwAIQCYAFwAAwByAAAACgACDv0AFgcAIwEAcwAA
AAQAAQARABEAlQCZAAIAawAAAEgABQADAAAACiobLAMsvrYAL6wAAAACAGwA
AAAGAAEAAAHEAG0AAAAgAAMAAAAKAG4AbwAAAAAACgCXAFwAAQAAAAoAdgBl
AAIAcwAAAAYAAgARAA4AEQCVAJoAAgBrAAABQgAHAAYAAACHG5wADbsAEVkS
NLcAE78sxwANuwAOWRIPtwAQvx2bABEVBJsADB0VBGAsvqQADbsAEVkSErcA
E78qtAAUNgUbmwAJGxUFoQAjuwARWRI1Bb0AMVkDG7gAMlNZBBUFuAAyU7gA
M7cAE78VBZ0ABQOsKhsVBQR6ogAHBKcABAMbLB0VBAO3ADasAAAAAwBsAAAA
OgAOAAAB2gAEAdsADgHeABIB3wAcAeAALgHhADgB5gA+AecASAHoAFUB6QBh
AegAaAHsAG0B7QBvAfEAbQAAAD4ABgAAAIcAbgBvAAAAAACHAJcAXAABAAAA
hwB2AGUAAgAAAIcAewBcAAMAAACHAHwAXAAEAD4ASQB9AFwABQByAAAAJQAJ
Dg0RCfwADwEfBkwHAFr/AAAABgcAWgEHACMBAQEAAgcAWgEAcwAAAAYAAgAR
AA4AEQCbAJwAAgBrAAAAfQAEAAMAAAAgKrQACEwqKwMEtgA3PRwEoAAHKwMz
rLsAOFkSObcAOr8AAAADAGwAAAAWAAUAAAH+AAUB/wANAgAAEgIBABYCBQBt
AAAAIAADAAAAIABuAG8AAAAFABsAeABlAAEADQATAJgAXAACAHIAAAAJAAH9
ABYHACMBAHMAAAAEAAEAOAARAJsAnQACAGsAAAA9AAQAAgAAAAkqKwMrvrYA
N6wAAAACAGwAAAAGAAEAAAITAG0AAAAWAAIAAAAJAG4AbwAAAAAACQB2AGUA
AQBzAAAABAABAA4AEQCbAJ4AAgBrAAAAUQAFAAQAAAAJKgMrHB22AC+sAAAA
AgBsAAAABgABAAACJwBtAAAAKgAEAAAACQBuAG8AAAAAAAkAdgBlAAEAAAAJ
AHsAXAACAAAACQB8AFwAAwBzAAAABgACABEADgARAJ8AnAACAGsAAAB8AAQA
AwAAAB8qtAAITCorAwS2ADs9HJoABysDM6y7ADhZEjy3ADq/AAAAAwBsAAAA
FgAFAAACNAAFAjUADQI2ABECNwAVAjsAbQAAACAAAwAAAB8AbgBvAAAABQAa
AHgAZQABAA0AEgCYAFwAAgByAAAACQAB/QAVBwAjAQBzAAAABAABADgAEQCf
AJ0AAgBrAAAAPQAEAAIAAAAJKisDK762ADusAAAAAgBsAAAABgABAAACSQBt
AAAAFgACAAAACQBuAG8AAAAAAAkAdgBlAAEAcwAAAAQAAQAOABEAnwCeAAIA
awAAAIsABQAFAAAAJB2cAA27ABFZEhK3ABO/KrQAFDYEKgMVBB1kuAA9Kxwd
tgAvrAAAAAMAbAAAABIABAAAAl0ABAJeAA4CYQAUAmIAbQAAADQABQAAACQA
bgBvAAAAAAAkAHYAZQABAAAAJAB7AFwAAgAAACQAfABcAAMAFAAQAH0AXAAE
AHIAAAADAAEOAHMAAAAGAAIAEQAOABEAoAChAAEAawAAAEIAAQABAAAADSq2
AD6aAAcEpwAEA6wAAAADAGwAAAAGAAEAAAJtAG0AAAAMAAEAAAANAG4AbwAA
AHIAAAAFAAILQAEAEQCiAKMAAQBrAAAAaAACAAMAAAAKKhu2AD8ErE0DrAAB
AAAABgAHABUAAwBsAAAAEgAEAAACfgAFAn8ABwKDAAgChQBtAAAAIAADAAgA
AgCkAKUAAgAAAAoAbgBvAAAAAAAKAHYAdwABAHIAAAAGAAFHBwAVABEAogCm
AAIAawAAAD0ABAACAAAACSorAyu+tgBArAAAAAIAbAAAAAYAAQAAApYAbQAA
ABYAAgAAAAkAbgBvAAAAAAAJAHYAZQABAHMAAAAEAAEADgARAKIApwACAGsA
AAB/AAQABQAAAA0qKxwdtgANBKw6BAOsAAEAAAAIAAkAFQADAGwAAAASAAQA
AAKsAAcCrQAJArEACwKzAG0AAAA0AAUACwACAKQApQAEAAAADQBuAG8AAAAA
AA0AdgBlAAEAAAANAHsAXAACAAAADQB8AFwAAwByAAAABgABSQcAFQBzAAAA
BAABABEAEQCoAKMAAQBrAAAAaAACAAMAAAAKKhu2AEEErE0DrAABAAAABgAH
ABUAAwBsAAAAEgAEAAACxQAFAsYABwLKAAgCzABtAAAAIAADAAgAAgCkAKUA
AgAAAAoAbgBvAAAAAAAKAHYAdwABAHIAAAAGAAFHBwAVABEAqACmAAIAawAA
AD0ABAACAAAACSorAyu+tgBCrAAAAAIAbAAAAAYAAQAAAt0AbQAAABYAAgAA
AAkAbgBvAAAAAAAJAHYAZQABAHMAAAAEAAEADgARAKgApwACAGsAAAB/AAQA
BQAAAA0qKxwdtgAdBKw6BAOsAAEAAAAIAAkAFQADAGwAAAASAAQAAALzAAcC
9AAJAvgACwL6AG0AAAA0AAUACwACAKQApQAEAAAADQBuAG8AAAAAAA0AdgBl
AAEAAAANAHsAXAACAAAADQB8AFwAAwByAAAABgABSQcAFQBzAAAABAABABEA
EQCpAI0AAgBrAAAAXAACAAIAAAAMKrYAQxEA/36sTAKsAAEAAAAIAAkAOAAD
AGwAAAAOAAMAAAMMAAkDEAAKAxIAbQAAABYAAgAKAAIAqgCrAAEAAAAMAG4A
bwAAAHIAAAAGAAFJBwA4AHMAAAAEAAEAOAARAKwAjQACAGsAAABcAAIAAgAA
AAwqtgBEEQD/fqxMAqwAAQAAAAgACQA4AAMAbAAAAA4AAwAAAyQACQMoAAoD
KgBtAAAAFgACAAoAAgCqAKsAAQAAAAwAbgBvAAAAcgAAAAYAAUkHADgAcwAA
AAQAAQA4ABEArQCcAAIAawAAAH0ABAADAAAAICq0AAhMKisDBLYART0cBKAA
BysDM6y7ADhZEka3ADq/AAAAAwBsAAAAFgAFAAADOAAFAzkADQM6ABIDOwAW
Az8AbQAAACAAAwAAACAAbgBvAAAABQAbAHgAZQABAA0AEwCYAFwAAgByAAAA
CQAB/QAWBwAjAQBzAAAABAABADgAEQCtAJ0AAgBrAAAAPQAEAAIAAAAJKisD
K762AEWsAAAAAgBsAAAABgABAAADTQBtAAAAFgACAAAACQBuAG8AAAAAAAkA
dgBlAAEAcwAAAAQAAQAOABEArQCeAAIAawAAAQ0ABQAHAAAAXivHAA27AA5Z
Eg+3ABC/HJsADx2bAAscHWArvqQADbsAEVkSErcAE78dmgAFA6wqtAAUNgQV
BJoABQOsKgMrHB22AC82BSodtgBHNgYVBRUGnwALuwArWbcALL8VBawAAAAD
AGwAAAA6AA4AAANgAAQDYQAOA2IAHgNjACgDZgAsA2cALgNqADQDawA5A2wA
OwNvAEUDcABMA3QAUwN1AFsDeABtAAAASAAHAAAAXgBuAG8AAAAAAF4AdgBl
AAEAAABeAHsAXAACAAAAXgB8AFwAAwA0ACoAfQBcAAQARQAZAK4AXAAFAEwA
EgCvAFwABgByAAAADwAGDg8JBfwADAH9AB8BAQBzAAAABgACABEADgARALAA
nAACAGsAAAB9AAQAAwAAACAqtAAITCorAwS2AEg9HASgAAcrAzOsuwA4WRJJ
twA6vwAAAAMAbAAAABYABQAAA4UABQOGAA0DhwASA4gAFgOMAG0AAAAgAAMA
AAAgAG4AbwAAAAUAGwB4AGUAAQANABMAmABcAAIAcgAAAAkAAf0AFgcAIwEA
cwAAAAQAAQA4ABEAsACdAAIAawAAAD0ABAACAAAACSorAyu+tgBIrAAAAAIA
bAAAAAYAAQAAA5oAbQAAABYAAgAAAAkAbgBvAAAAAAAJAHYAZQABAHMAAAAE
AAEADgARALAAngACAGsAAACTAAMABAAAADArxwANuwAOWRIPtwAQvxybAA8d
mwALHB1gK76kAA27ABFZEhK3ABO/uwAbWbcAHL8AAAADAGwAAAAWAAUAAAOt
AAQDrgAOA68AHgOwACgDsgBtAAAAKgAEAAAAMABuAG8AAAAAADAAdgBlAAEA
AAAwAHsAXAACAAAAMAB8AFwAAwByAAAABQADDg8JAHMAAAAGAAIAEQAOABEA
sQCWAAIAawAAAK0ABwAEAAAAPRucAA27ABFZEkq3ABO/KrQACE0qGywDBLYA
Sz4dBKAABywDM6y7ABFZEkwEvQAxWQMbuAAyU7gAM7cAE78AAAADAGwAAAAe
AAcAAAPCAAQDwwAOA8UAEwPGABwDxwAhA8gAJQPMAG0AAAAqAAQAAAA9AG4A
bwAAAAAAPQCXAFwAAQATACoAeABlAAIAHAAhAJgAXAADAHIAAAAKAAIO/QAW
BwAjAQBzAAAABAABABEAEQCxAJkAAgBrAAAASAAFAAMAAAAKKhssAyy+tgBL
rAAAAAIAbAAAAAYAAQAAA94AbQAAACAAAwAAAAoAbgBvAAAAAAAKAJcAXAAB
AAAACgB2AGUAAgBzAAAABgACABEADgARALEAmgACAGsAAAFCAAcABgAAAIcb
nAANuwARWRJNtwATvyzHAA27AA5ZEg+3ABC/HZsAERUEmwAMHRUEYCy+pAAN
uwARWRIStwATvyq0ABQ2BRubAAkbFQWhACO7ABFZEk4FvQAxWQMbuAAyU1kE
FQW4ADJTuAAztwATvxUFnQAFA6wqGxUFBHqiAAcEpwAEAxssHRUEBLcANqwA
AAADAGwAAAA6AA4AAAP0AAQD9QAOA/gAEgP5ABwD+gAuA/sAOAQAAD4EAQBI
BAIAVQQDAGEEAgBoBAYAbQQHAG8ECwBtAAAAPgAGAAAAhwBuAG8AAAAAAIcA
lwBcAAEAAACHAHYAZQACAAAAhwB7AFwAAwAAAIcAfABcAAQAPgBJAH0AXAAF
AHIAAAAlAAkODREJ/AAPAR8GTAcAWv8AAAAGBwBaAQcAIwEBAQACBwBaAQBz
AAAABgACABEADgARALIAjQABAGsAAAAvAAEAAQAAAAUqtAAUrAAAAAIAbAAA
AAYAAQAABBYAbQAAAAwAAQAAAAUAbgBvAAAAEQCzALQAAQBrAAAAXgAFAAMA
AAAUKrYAPjwbvAhNKgMsAxu2AC9XLLAAAAACAGwAAAASAAQAAAQhAAUEIgAJ
BCMAEgQkAG0AAAAgAAMAAAAUAG4AbwAAAAUADwC1AFwAAQAJAAsAmABlAAIA
EQC2ALcAAgBrAAAAWwADAAIAAAAWK8cADbsADlkSD7cAEL+7ABtZtwAcvwAA
AAMAbAAAAA4AAwAABDMABAQ0AA4ENgBtAAAAFgACAAAAFgBuAG8AAAAAABYA
uAC5AAEAcgAAAAMAAQ4AcwAAAAYAAgC6AA4AEgC7ALwAAQBrAAAEHgAEABgA
AAFGKrQAFDYHKrQABzoIGQi2ABg2CSq0ABk2Ciq0ABo2C7IAHzYMsgAgNg0V
BxxkNg4VBRUOogAHFQU2DhUKHGCyAE96NhAbmQA4FQkEpAAyGQgVCbYAUDoR
GRE6DxUJFRBkNhIDNhMVExUSogARGRG5AFEBAFeEEwGn/+6nACIZCLYAJDoP
AzYRFREVEKIAERkPuQAmAQBXhBEBp//uFQocYBUNfjYRFQ42EhUENhMVEp4A
lBkPuQAmAQDAACM6FBkPuQAlAQCaAAcEpwAEAzYVFRWZAA0VC5kACBULpwAF
FQwVEWQ2FhUSFRaiAAcVEjYWFQaZACUDNhcVFxUWogAYGRQVEYQRAS0VE4QT
ATNUhBcBp//npwAiAzYXFRcVFqIAGC0VE4QTARkUFRGEEQEzVIQXAaf/5wM2
ERUSFRZkNhKn/20VDqwAAAAEAGwAAACqACoAAARLAAYETAAMBE0AEwROAB8E
TwAkBFAAKQRTAC8EVAA2BFUAOgRaAEQEWwBOBF8AVwRgAFsEYQBiBGIAbARj
AHQEYgB6BGQAfQRpAIQEagCOBGsAlgRqAJwEcQClBHQAqQR1AK0EdgCyBHkA
vgR8AM8EfwDlBIAA7ASBAPAEhAD1BIUA/wSGAQ4EhQEXBIoBIQSLATAEigE2
BI4BOQSRAUAEkgFDBJUAbQAAAS4AHgBlABUAhgBcABMAVwAjAL0AvgARAGIA
GAC/AFwAEgBbACIAwADBAA8AhwAVAIYAXAARAPgAHACGAFwAFwEaABwAhgBc
ABcAvgCCAIUAZQAUAM8AcQCSAJMAFQDlAFsAlABcABYAAAFGAG4AbwAAAAAB
RgDCAJMAAQAAAUYAlwBcAAIAAAFGAHYAZQADAAABRgB7AFwABAAAAUYAfABc
AAUAAAFGAMMAkwAGAAYBQAB9AFwABwAMAToAfwBhAAgAEwEzAIAAXAAJABkB
LQCBAFwACgAfAScAggBcAAsAJAEiAIgAXAAMACkBHQCJAFwADQAvARcAhwBc
AA4AhADCAMAAwQAPAEQBAgDEAFwAEAClAKEAxQBcABEAqQCdAIoAXAASAK0A
mQCLAFwAEwCDAAAAKgAEAFcAIwC9AMYAEQBbACIAwADHAA8ADAE6AH8AYwAI
AIQAwgDAAMcADwByAAAAsgAS/wA6AA8HAFoBAQcAIwEBAQEHAAUBAQEBAQEA
AP8AKgAUBwBaAQEHACMBAQEBBwAFAQEBAQEBBwCPAQcAyAEBAAD4ABT/AAIA
EQcAWgEBBwAjAQEBAQcABQEBAQEBAQABAAD/AAkAEgcAWgEBBwAjAQEBAQcA
BQEBAQEBAQcAjwEBAAD6ABT+ABABAQH8AB4HACNAAfwAEAFBAfwADwH8AAcB
+gAbAvwAAgH6ABv4AAwACADJAGoAAQBrAAAAiAAHAAAAAABJEAgSUhEAgLgA
U7YAVLgAPbMAH7IAHwRkswAgsgAfuABVswBPsgAfuABWBJ8AHbsAV1kSWAS9
ADFZA7IAH7gAMlO4ADO3AFm/sQAAAAIAbAAAACIACAAAACcABwAoABMALAAb
ADAAHgAxACQAUAAuAFEASABSAHIAAAAFAAH7AEgAAQDKAAAAAgDL
====

Added modules/tool-classfile/src/test/resources/InflaterInputStream.data.__mime.


















































































































































































































































































































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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
begin-base64 640 InflaterInputStream.class
yv66vgAAADMBswcBMwMAAIAACgABATQKAAEBNQoAaQE2BwE3CgAGATYJAAEB
OAkAAQE5CQABAToHATsKAAsBPAkAAQE9CQABAT4JAAEBPwkAAQFACQABAUEH
AUIIAUMKABIBRAkAAQFFBwFGCgAWAUcJAAEBSAkAAQFJCgAGAUoKALEBSwkA
AQFMCgABAU0HAU4IAU8KAB4BRAoABgFQCQABAVEJAAEBUgkAAQFTCQABAVQK
AAEBVQsAsgFWCQABAVcKAAYBWAoAAQFZCgABAVoKAAEBWwoAAQFcBwFdCAFe
BwFfCgBGAWAKAWEBYgoALgFECgABAWMKAAEBZAoAAQFlCgABAWYKAFQBZwoA
AQFoCgABAWkKAAEBaggBawoAAQFsBwFtCAFuCgAuAW8KAAEBcAoAAQFxCAFy
CQABAXMKAAEBdAcBdQOAAAAACAF2CQABAXcDAAD//wgBeAoAAQF5CgAWAXoH
AXsIAXwIAX0IAX4JAAEBfwoBAwGABwGBBwGCCgBUATYKAFUBgwoAVAGECQAB
AYUJAAEBhgkAAQGHBwCFCQABAYgKALEBTQgBiQoARgGKCAGLCAGMCAGNCgBU
AY4JAAEBjwkAAQGQCgAGAZEKABYBkgcBkwcBlAEADElubmVyQ2xhc3NlcwEA
DV9fQml0U291cmNlX18BABxfREVGQVVMVF9TTElESU5HX1dJTkRPV19TSVpF
AQABSQEADUNvbnN0YW50VmFsdWUBABRfVFlQRV9OT19DT01QUkVTU0lPTgMA
AAAAAQATX1RZUEVfRklYRURfSFVGRk1BTgMAAAABAQAVX1RZUEVfRFlOQU1J
Q19IVUZGTUFOAwAAAAIBAAtfVFlQRV9FUlJPUgMAAAADAQAJX01BWF9CSVRT
AwAAAA8BAA1fU0hVRkZMRV9CSVRTAQACW0kBAAJpbgEAFUxqYXZhL2lvL0lu
cHV0U3RyZWFtOwEABndpbmRvdwEAKkxuZXQvbXVsdGlwaGFzaWNhcHBzL2lv
L1NsaWRpbmdCeXRlV2luZG93OwEACG92ZXJmbG93AQAiTG5ldC9tdWx0aXBo
YXNpY2FwcHMvaW8vQnl0ZURlcXVlOwEACGNoZWNrc3VtAQAhTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vQ2hlY2tzdW07AQAFX3NvbG8BAAJbQgEAB19yZWFk
aW4BAApfYml0c291cmNlAQAiTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vQml0
U291cmNlOwEADF9yYXdjb2RlbGVucwEAD19yYXdsaXRkaXN0bGVucwEACF9i
bGNvdW50AQAJX25leHRjb2RlAQAPX2NvbXByZXNzZWRzaXplAQABSgEAEV91
bmNvbXByZXNzZWRzaXplAQAMX2NvZGVsZW50cmVlAQAZTGphdmEvbGFuZy9y
ZWYvUmVmZXJlbmNlOwEACVNpZ25hdHVyZQEAQkxqYXZhL2xhbmcvcmVmL1Jl
ZmVyZW5jZTxMbmV0L211bHRpcGhhc2ljYXBwcy9pby9IdWZmbWFuVHJlZUlu
dDs+OwEADF9saXRlcmFsdHJlZQEADV9kaXN0YW5jZXRyZWUBAAtfcmVhZHdp
bmRvdwEAHUxqYXZhL2xhbmcvcmVmL1JlZmVyZW5jZTxbQj47AQALX21pbml3
aW5kb3cBAAlfbWluaXNpemUBAAxfd3JpdGV3aW5kb3cBAApfd3JpdGVzaXpl
AQAEX2VvZgEAAVoBAAVfdGFyZwEACF90YXJnb2ZmAQAIX3RhcmdlbmQBAAY8
aW5pdD4BABgoTGphdmEvaW8vSW5wdXRTdHJlYW07KVYBAARDb2RlAQAPTGlu
ZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEALExu
ZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0luZmxhdGVySW5wdXRTdHJlYW07AQAE
X19pbgEACkV4Y2VwdGlvbnMBADkoTGphdmEvaW8vSW5wdXRTdHJlYW07TG5l
dC9tdWx0aXBoYXNpY2FwcHMvaW8vQ2hlY2tzdW07KVYBAARfX2NzAQAZKExq
YXZhL2lvL0lucHV0U3RyZWFtO0kpVgEABV9fc2xzAQA6KExqYXZhL2lvL0lu
cHV0U3RyZWFtO0lMbmV0L211bHRpcGhhc2ljYXBwcy9pby9DaGVja3N1bTsp
VgEACl9fY2hlY2tzdW0BAA1TdGFja01hcFRhYmxlBwGVBwGWAQAJYXZhaWxh
YmxlAQADKClJAQAFY2xvc2UBAAMoKVYBAA9jb21wcmVzc2VkQnl0ZXMBAAMo
KUoBAApkZXRlY3RzRU9GAQADKClaAQAEcmVhZAEAAnJ2AQAEc29sbwEABShb
QilJAQADX19iAQAHKFtCSUkpSQEABGJhc2UBAANfX28BAANfX2wBAAJibAEA
A292bgEAA292cgEAAWMBAANlb2YBABF1bmNvbXByZXNzZWRCeXRlcwEADF9f
ZGVjb21wcmVzcwEACGVudGVyb2ZmAQAIZmluYWxoaXQBAAR0eXBlAQATX19k
ZWNvbXByZXNzRHluYW1pYwEABGNvZGUBAAVkaGxpdAEABmRoZGlzdAEABmRo
Y2xlbgEAC2NvZGVsZW50cmVlAQAnTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8v
SHVmZm1hblRyZWVJbnQ7AQALbGl0ZXJhbHRyZWUBAAxkaXN0YW5jZXRyZWUB
ACJfX2RlY29tcHJlc3NEeW5hbWljTG9hZExpdERpc3RUcmVlAQB6KExuZXQv
bXVsdGlwaGFzaWNhcHBzL2lvL0h1ZmZtYW5UcmVlSW50O0lJTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7TG5ldC9tdWx0aXBoYXNp
Y2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7KVYBAAFpAQABbgEABG5leHQBAAFl
AQAiTGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0aW9uOwEACF9fY2x0
cmVlAQAHX19kaGxpdAEACF9fZGhkaXN0AQAHX19sdHJlZQEAB19fZHRyZWUB
AAV0b3RhbAEADnJhd2xpdGRpc3RsZW5zBwB7AQAeX19kZWNvbXByZXNzRHlu
YW1pY0xvYWRMZW5UcmVlAQAqKEkpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8v
SHVmZm1hblRyZWVJbnQ7AQAIX19kaGNsZW4BAAtyYXdjb2RlbGVucwEABmhz
Yml0cwEAEV9fZGVjb21wcmVzc0ZpeGVkAQAQX19kZWNvbXByZXNzTm9uZQEA
B21pbmlzdWIBAANsZW4BAANjb20BABJfX2RlY29tcHJlc3NXaW5kb3cBAAUo
SUkpVgEABm1heGxlbgEABWlvb2JlAQAlTGphdmEvbGFuZy9JbmRleE91dE9m
Qm91bmRzRXhjZXB0aW9uOwEAAXYBAAVfX2xlbgEABl9fZGlzdAEABHdpbmIB
ABBfX2hhbmRsZURpc3RhbmNlAQAEKEkpSQEABl9fY29kZQEACWV4dHJhYml0
cwEADl9faGFuZGxlTGVuZ3RoAQADX19jAQATX19vYnRhaW5Db2RlTGVuVHJl
ZQEAKSgpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7
AQADcmVmAQAWTG9jYWxWYXJpYWJsZVR5cGVUYWJsZQcBlwEAFF9fb2J0YWlu
RGlzdGFuY2VUcmVlAQATX19vYnRhaW5MaXRlcmFsVHJlZQEAEl9fb2J0YWlu
UmVhZFdpbmRvdwEABCgpW0IBAApfX3JlYWRCaXRzAQAFKElaKUkBAAJiYwEA
BnJlYWRpbgEAAnJjAQADX19uAQAFX19tc2IBAAptaW5pd2luZG93AQAIbWlu
aXNpemUBAA5fX3JlYWRDb2RlQml0cwEALShMbmV0L211bHRpcGhhc2ljYXBw
cy9pby9IdWZmbWFuVHJlZUludDtbSUkpSQEACWxhc3RsZW5keAEABnJlcHZh
bAEABnJlcGZvcgEAB19fY29kZXMBAAVfX291dAEABl9fbmV4dAEACGJhc2Vu
ZXh0AQASX19yZWFkRml4ZWRIdWZmbWFuAQAVX190aHVua0NvZGVMZW5ndGhU
cmVlAQBUKExuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0h1ZmZtYW5UcmVlSW50
O1tJSUkpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7
AQABcAEABGJpdHMBAAFxAQAGX190cmVlAQAGX19sZW5zAQAIYmxfY291bnQB
AAluZXh0X2NvZGUBAAdfX3dyaXRlAQAGKElJWilWAQABYgEAAUIBAAR0YXJn
AQAHdGFyZ29mZgEAB3RhcmdlbmQBAANfX3YBAAZfX2JpdHMBAARtYXNrAQAL
d3JpdGV3aW5kb3cBAAl3cml0ZXNpemUBAAg8Y2xpbml0PgEAClNvdXJjZUZp
bGUBABhJbmZsYXRlcklucHV0U3RyZWFtLmphdmEBACpuZXQvbXVsdGlwaGFz
aWNhcHBzL2lvL0luZmxhdGVySW5wdXRTdHJlYW0MAKEArAwAoQCuDAChALYB
ACBuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0J5dGVEZXF1ZQwAgACBDACEAIUM
AIYAhQEAOG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSW5mbGF0ZXJJbnB1dFN0
cmVhbSRfX0JpdFNvdXJjZV9fDAChAZgMAIcAiAwAiQB7DACKAHsMAIsAewwA
jAB7AQAeamF2YS9sYW5nL051bGxQb2ludGVyRXhjZXB0aW9uAQAETkFSRwwA
oQGZDAB8AH0BAChuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL1NsaWRpbmdCeXRl
V2luZG93DAChAZoMAH4AfwwAggCDDACzALQMALUAtgwAjQCODAC7AMABAChq
YXZhL2xhbmcvQXJyYXlJbmRleE91dE9mQm91bmRzRXhjZXB0aW9uAQAEQUlP
QgwBmwDADACcAJ0MAJ4AhQwAnwBuDACgAG4MAMoAtAwBnAGdDACPAI4MAZ4A
ugwBCAEJDADsALYMAOsAtgwAzgC2AQATamF2YS9pby9JT0V4Y2VwdGlvbgEA
B0JEMTUgJWQBABBqYXZhL2xhbmcvT2JqZWN0DAGfAaAHAaEMAaIBowwA5gDn
DAEFAQAMAQQBAAwA1wDYDAGkAaUMASQBJQwA/QD6DADwAPEBAAdCRDE2ICVk
DAERARIBACBqYXZhL3V0aWwvTm9TdWNoRWxlbWVudEV4Y2VwdGlvbgEABEJE
MTcMAKEBpgwBGwEcDAD/AQABAAdCRDE4ICVkDAB6AHsMARoAtAEAEWphdmEv
bGFuZy9JbnRlZ2VyAQAHQkQxOSAlZAwAmQBuAQAYQkQxYSAlMDR4ICUwNHgg
JTA0eCAlMDR4DAD5APoMAacBqAEAI2phdmEvbGFuZy9JbmRleE91dE9mQm91
bmRzRXhjZXB0aW9uAQAKQkQxYiAlZCAlZAEAB0JEMWMgJWQBAAdCRDFkICVk
DACQAJEMAacBqQEAJW5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRy
ZWVJbnQBABtqYXZhL2xhbmcvcmVmL1dlYWtSZWZlcmVuY2UMAKEBqgwBqwC2
DACVAJEMAJQAkQwAlgCRDACYAG4BAApCRDFlICVkICVkDAGsAPoBAAdCRDFm
ICVkAQAHQkQxZyAlZAEABEJEMWgMAa0BrgwAmgBuDACbAG4MAa8BsAwBsQGy
AQAvbmV0L211bHRpcGhhc2ljYXBwcy9pby9EZWNvbXByZXNzaW9uSW5wdXRT
dHJlYW0BACxuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0luZmxhdGVySW5wdXRT
dHJlYW0kMQEAE2phdmEvaW8vSW5wdXRTdHJlYW0BAB9uZXQvbXVsdGlwaGFz
aWNhcHBzL2lvL0NoZWNrc3VtAQAXamF2YS9sYW5nL3JlZi9SZWZlcmVuY2UB
AF0oTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSW5mbGF0ZXJJbnB1dFN0cmVh
bTtMbmV0L211bHRpcGhhc2ljYXBwcy9pby9JbmZsYXRlcklucHV0U3RyZWFt
JDE7KVYBABUoTGphdmEvbGFuZy9TdHJpbmc7KVYBAAQoSSlWAQALcmVtb3Zl
Rmlyc3QBAAVvZmZlcgEAByhbQklJKVYBAAdpc0VtcHR5AQAHdmFsdWVPZgEA
FihJKUxqYXZhL2xhbmcvSW50ZWdlcjsBABBqYXZhL2xhbmcvU3RyaW5nAQAG
Zm9ybWF0AQA5KExqYXZhL2xhbmcvU3RyaW5nO1tMamF2YS9sYW5nL09iamVj
dDspTGphdmEvbGFuZy9TdHJpbmc7AQAIZ2V0VmFsdWUBACUoTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vQml0U291cmNlOylJAQAqKExqYXZhL2xhbmcvU3Ry
aW5nO0xqYXZhL2xhbmcvVGhyb3dhYmxlOylWAQADZ2V0AQAIKElbQklJKVYB
ABQoKUxqYXZhL2xhbmcvT2JqZWN0OwEAFShMamF2YS9sYW5nL09iamVjdDsp
VgEABWNsZWFyAQAHcmV2ZXJzZQEAA2FkZAEABihJSUkpSQEACW9mZmVyTGFz
dAEABChCKVoBAAZhcHBlbmQBAAQoQilWACEAAQBpAAAAIAAaAG0AbgABAG8A
AAACAAIAGABwAG4AAQBvAAAAAgBxABgAcgBuAAEAbwAAAAIAcwAYAHQAbgAB
AG8AAAACAHUAGAB2AG4AAQBvAAAAAgB3ABoAeABuAAEAbwAAAAIAeQAaAHoA
ewAAABQAfAB9AAAAFAB+AH8AAAAUAIAAgQAAABQAggCDAAAAEgCEAIUAAAAS
AIYAhQAAABIAhwCIAAAAEgCJAHsAAAASAIoAewAAABIAiwB7AAAAEgCMAHsA
AAACAI0AjgAAAAIAjwCOAAAAAgCQAJEAAQCSAAAAAgCTAAIAlACRAAEAkgAA
AAIAkwACAJUAkQABAJIAAAACAJMAAgCWAJEAAQCSAAAAAgCXAAIAmABuAAAA
AgCZAG4AAAACAJoAbgAAAAIAmwBuAAAAAgCcAJ0AAAACAJ4AhQAAAAIAnwBu
AAAAAgCgAG4AAAAfAAEAoQCiAAIAowAAAEAAAwACAAAACCorEgK3AAOxAAAA
AgCkAAAACgACAAAApwAHAKgApQAAABYAAgAAAAgApgCnAAAAAAAIAKgAfQAB
AKkAAAAEAAEAEgABAKEAqgACAKMAAABLAAQAAwAAAAkqKxICLLcABLEAAAAC
AKQAAAAKAAIAAAC2AAgAtwClAAAAIAADAAAACQCmAKcAAAAAAAkAqAB9AAEA
AAAJAKsAgwACAKkAAAAEAAEAEgABAKEArAABAKMAAABKAAQAAwAAAAgqKxwB
twAEsQAAAAIApAAAAAoAAgAAAMQABwDFAKUAAAAgAAMAAAAIAKYApwAAAAAA
CACoAH0AAQAAAAgArQBuAAIAAQChAK4AAQCjAAABCQAFAAQAAABwKrcABSq7
AAZZtwAHtQAIKgS8CLUACSoHvAi1AAoquwALWSoBtwAMtQANKhATvAq1AA4q
EQFCvAq1AA8qEBC8CrUAECoQELwKtQARK8cADbsAElkSE7cAFL8qK7UAFSq7
ABZZHLcAF7UAGCottQAZsQAAAAMApAAAAD4ADwAAANcABABGAA8ATQAWAFEA
HQBVACoAXAAyAGMAOwBnAEMAawBLANkATwDaAFkA3QBeAN4AagDfAG8A4ACl
AAAAKgAEAAAAcACmAKcAAAAAAHAAqAB9AAEAAABwAK0AbgACAAAAcACvAIMA
AwCwAAAAEwAB/wBZAAQHAAEHALEBBwCyAAAAAQCzALQAAgCjAAAAMgABAAEA
AAAIKrQACLYAGqwAAAACAKQAAAAGAAEAAADsAKUAAAAMAAEAAAAIAKYApwAA
AKkAAAAEAAEALgABALUAtgACAKMAAAA2AAEAAQAAAAgqtAAVtgAbsQAAAAIA
pAAAAAoAAgAAAPgABwD5AKUAAAAMAAEAAAAIAKYApwAAAKkAAAAEAAEALgAB
ALcAuAABAKMAAAAvAAIAAQAAAAUqtAAcrQAAAAIApAAAAAYAAQAAAQIApQAA
AAwAAQAAAAUApgCnAAAAAQC5ALoAAQCjAAAALAABAAEAAAACBKwAAAACAKQA
AAAGAAEAAAEMAKUAAAAMAAEAAAACAKYApwAAAAEAuwC0AAIAowAAAIsABAAD
AAAAIiq0AAlMKisDBLYAHT0cnAAFHKwcmgAGp//uKwMzEQD/fqwAAAADAKQA
AAAeAAcAAAEYAAUBGwANAR4AEQEfABMBIgAXASMAGgEnAKUAAAAgAAMADQAV
ALwAbgACAAAAIgCmAKcAAAAFAB0AvQCFAAEAsAAAAA0AA/wABQcAXPwADQEG
AKkAAAAEAAEALgABALsAvgACAKMAAAA9AAQAAgAAAAkqKwMrvrYAHawAAAAC
AKQAAAAGAAEAAAEzAKUAAAAWAAIAAAAJAKYApwAAAAAACQC/AIUAAQCpAAAA
BgACAC4AEgABALsAwAACAKMAAAIZAAUADAAAAOArxwANuwASWRITtwAUvyu+
NgQcmwAPHZsACxwdYBUEpAANuwAeWRIftwAgvyq0AAg6BRkFtgAaNgYVBh2i
AAgVBqcABB02BxkFKxwdtgAhNggqtAAiNgkVCZoARxUIHaIAQSortQAjFQgd
ogA2KhwVCGBZNgq1ACQqFQodFQhkYLUAJSq3ACY2CxULnAALKgS1ACKnAA0V
CBULYDYIp//KKrQAGToKGQrGAA4ZCiscFQi5ACcEABUIngAPKlm0ACgVCIVh
tQAoFQiaABQVCZkADxkFtgApmQAHAqcABRUIrAAAAAMApAAAAG4AGwAAAUAA
BAFBAA4BQgASAUMAIgFEACwBSAAyAUkAOQFKAEcBSwBRAU8AVwFQAGIBUwBn
AVYAbQFaAHgBWwCDAVwAiQFfAI4BYQCTAWIAlgFmAJ0BZwCgAWsApgFsAKsB
bQC2AXAAuwFxAMcBdgClAAAAhAANAHUAKADBAG4ACgCJABQAvABuAAsAAADg
AKYApwAAAAAA4AC/AIUAAQAAAOAAwgBuAAIAAADgAMMAbgADABIAzgDEAG4A
BAAyAK4AgACBAAUAOQCnAMUAbgAGAEcAmQDGAG4ABwBRAI8AxwBuAAgAVwCJ
AMgAnQAJAKYAOgCCAIMACgCwAAAAKQAMDvwAEwEJ/QAXBwAGAUAB/gAhAQEB
/QAuAQH5AAn8ABUHALIQFUEBAKkAAAAIAAMAHgAuABIAAQDJALgAAQCjAAAA
LwACAAEAAAAFKrQAKK0AAAACAKQAAAAGAAEAAAGAAKUAAAAMAAEAAAAFAKYA
pwAAAAIAygC0AAIAowAAATkABwAFAAAAiSq0ACKZAAUCrCq0ACQ8KgQDtgAq
PSoFA7YAKj4dqgAAAAAANAAAAAAAAAADAAAAHwAAACYAAAAtAAAANCq3ACun
ACkqtwAspwAiKrcALacAG7sALlkSLwS9ADBZAx24ADFTuAAytwAzvyq0ACQb
ZDYEHJkAFCoEtQAiFQSaAAcCpwAFFQSsFQSsAAAAAwCkAAAASgASAAABjwAH
AZAACQGTAA4BlgAVAZkAHAGaADwBngBAAZ8AQwGjAEcBpABKAagATgGpAFEB
sABpAbUAcQG2AHUBuAB6AbkAhgG+AKUAAAA0AAUAAACJAKYApwAAAA4AewDL
AG4AAQAVAHQAzABuAAIAHABtAM0AbgADAHEAGAC8AG4ABACwAAAAFAAJCf4A
MgEBAQYGBhf8ABkBQQEAAKkAAAAEAAEALgACAM4AtgACAKMAAAGGAAcACAAA
AKsqCAO2ACoRAQFgPCoIA7YAKgRgPSoHA7YAKgdgPiodtwA0OgQqtwA1OgUq
twA2OgYqGQQbHBkFGQa3ADcZBSq0AA22ADg2BxUHmwAXFQcRAP+jAA8qFQcQ
CAO3ADmnAEsVBxEBAKAABLEVBxEBAaEAIRUHEQEdowAZKioVB7cAOhkGKrQA
DbYAOLcAO6cAHLsALlkSPAS9ADBZAxUHuAAxU7gAMrcAM7+n/5QAAAADAKQA
AABKABIAAAHLAAsBzAAUAc0AHQHQACQB0wAqAdQAMAHVADwB3ABHAd8AVAHg
AGAB4wBoAeQAaQHnAHkB6ACGAekAiQHoAI8B7gCoAe8ApQAAAFIACABHAGEA
zwBuAAcAAACrAKYApwAAAAsAoADQAG4AAQAUAJcA0QBuAAIAHQCOANIAbgAD
ACQAhwDTANQABAAqAIEA1QDUAAUAMAB7ANYA1AAGALAAAAAhAAX/ADwABwcA
AQEBAQcAVAcAVAcAVAAA/AAjAQgl+gAYAKkAAAAEAAEALgACANcA2AACAKMA
AAFrAAUACgAAAGkcHWA2Biq0AA86BwM2CBkHvjYJFQgVCaIADxkHFQgDT4QI
Aaf/8AM2CBUIFQaiABQVCCorGQcVCLcAPWA2CKf/66cAEToIuwAuWRI/GQi3
AEC/KhkEGQcDHLcAQVcqGQUZBxwdtwBBV7EAAQAmAEEARAA+AAMApAAAADYA
DQAAAgMABQIGAAsCBwAaAggAIAIHACYCDQAwAg4AQQIXAEQCFABGAhYAUgIa
AF0CGwBoAhwApQAAAHoADAAOABgA2QBuAAgAEwATANoAbgAJACkAGADbAG4A
CABGAAwA3ADdAAgAAABpAKYApwAAAAAAaQDeANQAAQAAAGkA3wBuAAIAAABp
AOAAbgADAAAAaQDhANQABAAAAGkA4gDUAAUABQBkAOMAbgAGAAsAXgDkAHsA
BwCwAAAALAAG/wATAAoHAAEHAFQBAQcAVAcAVAEHAOUBAQAA+QAS/AACAfoA
F0IHAD4NAKkAAAAEAAEALgACAOYA5wACAKMAAAErAAcABgAAAGwqtwBCTRsQ
E6QAG7sALlkSQwS9ADBZAxu4ADFTuAAytwAzvyq0AA5OAzYELb42BRUEFQWi
AA4tFQQDT4QEAaf/8bIARDoEAzYFFQUbogAWLRkEFQUuKgYDtgAqT4QFAaf/
6iosLQMtvrcAQbAAAAADAKQAAAAyAAwAAAIpAAUCLQALAi4AIwIzACgCNAA2
AjUAOwI0AEECOQBGAjoATwI7AFwCOgBiAj4ApQAAAFIACAArABYA2QBuAAQA
LwASANoAbgAFAEkAGQDbAG4ABQAAAGwApgCnAAAAAABsAOgAbgABAAUAZwDT
ANQAAgAoAEQA6QB7AAMARgAmAOoAewAEALAAAAAdAAX8ACMHAFT+AAsHAOUB
AfkAEf0ABwcA5QH6ABgAqQAAAAQAAQAuAAIA6wC2AAIAowAAAMAABwACAAAA
Wiq3AEU8G5sAFRsRAP+jAA4qGxAIA7cAOacAPxsRAQCgAASxGxEBAaEAGBsR
AR2jABEqKhu3ADoSR7cAO6cAG7sALlkSSAS9ADBZAxu4ADFTuAAytwAzv6f/
qQAAAAMApAAAACYACQAAAlAABQJTABACVAAbAlcAIgJYACMCWwAxAlwAPwJh
AFcCYgClAAAAFgACAAUAUgDPAG4AAQAAAFoApgCnAAAAsAAAAAwABQD8ABoB
Bxv6ABcAqQAAAAQAAQAuAAIA7AC2AAIAowAAARYACAAFAAAAfCq0AEkQB348
G54ACiobA7YAKlcqEBADtgAqPSoQEAO2ACo+HBJKgh2fADa7AC5ZEksHvQAw
WQMcuAAxU1kEHbgAMVNZBRwSSoK4ADFTWQYdEkqCuAAxU7gAMrcAM78DNgQV
BByiABcqKhAIA7YAKhAIA7cAOYQEAaf/6bEAAAADAKQAAAA2AA0AAAJwAAgC
cQAMAnIAEwJ1ABsCdgAjAnwAKwJ9ADgCfgBXAn0AXgKBAGcCggB1AoEAewKD
AKUAAAA0AAUAYQAaANkAbgAEAAAAfACmAKcAAAAIAHQA7QBuAAEAGwBhAO4A
bgACACMAWQDvAG4AAwCwAAAAEgAE/AATAf0ASgEB/AACAfoAGQCpAAAABAAB
AC4AAgDwAPEAAgCjAAABYAAHAAcAAAB0Khy3AEw9HBuiAAgcPqcABRs+HbwI
OgQqtAAYHBkEAx22AE2nACY6BbsALlkSTwW9ADBZAxy4ADFTWQQbuAAxU7gA
MhkFtwBAvwM2BQM2BhUFG6IAISoZBBUGMxAIA7cAOYQGARUGHaEABgM2BoQF
Aaf/37EAAQAXACMAJgBOAAMApAAAAEYAEQAAApEABgKWAAsClwAQApkAEgKc
ABcCnwAjAqkAJgKjACgCpwA1AqgAQAKnAEkCrQBVArAAYQKzAGoCtABtAq0A
cwK2AKUAAABcAAkADQADAPIAbgADACgAIQDzAPQABQBMACcA2QBuAAUATwAk
APUAbgAGAAAAdACmAKcAAAAAAHQA9gBuAAEAAAB0APcAbgACABIAYgDyAG4A
AwAXAF0A+ACFAAQAsAAAACQABxD8AAEB/wATAAUHAAEBAQEHAFwAAQcATiL9
AAUBAR35AAUAqQAAAAQAAQAuAAIA+QD6AAIAowAAARkABwAFAAAAaBsSR6AA
CioIBLYAKjwbEB2kABu7AC5ZElAEvQAwWQMbuAAxU7gAMrcAM78EPQM+HRui
ACIdBWwEZDYEFQSbAA0cBBUEeGA9pwAGhAIBhAMBp//fGwVsBGQ+HZ4ADBwq
HQO2ACpgPRysAAAAAwCkAAAAPgAPAAACxAAGAsUADQLJABMCygArAs0ALQLO
ADQC0gA7AtMAQALUAEoC1gBNAs4AUwLbAFkC3ABdAt0AZgLgAKUAAAA+AAYA
OwASAPUAbgAEAC8AJADZAG4AAwAAAGgApgCnAAAAAABoAPsAbgABAC0AOwC8
AG4AAgBZAA8A/ABuAAMAsAAAABcABw0d/QADAQH8ABoB+gAC+gAF/AASAQCp
AAAABAABAC4AAgD9APoAAgCjAAABNQAHAAYAAABzGxEBHaAABxEBAqwbEQEB
ZD0cnAAbuwAuWRJRBL0AMFkDG7gAMVO4ADK3ADO/Bj4DNgQVBByiACMVBAds
BGQ2BRUFngANHQQVBXhgPqcABoQDAYQEAaf/3RwHbARkNgQVBJ4AEB0qFQQD
tgAqWTYEYD4drAAAAAMApAAAAEIAEAAAAu4ABwLvAAsC8gARAvUAFQL2AC0C
+QAvAvoAOAL/AEADAABFAwEATwMDAFIC+gBYAwcAXwMIAGQDCQBxAwwApQAA
AEgABwBAABIA9QBuAAUAMgAmANkAbgAEAAAAcwCmAKcAAAAAAHMA/gBuAAEA
EQBiAMEAbgACAC8ARAC8AG4AAwBfABQA/ABuAAQAsAAAABoABwv8ACEB/QAE
AQH8ABwB+gAC+gAF/AAYAQCpAAAABAABAC4AAgD/AQAAAQCjAAAArgAFAAMA
AAAwKrQAUkwrxgAQASu2AFPAAFRZTaYAFyq7AFVZuwBUWbcAVllNtwBXtQBS
LLYAWCywAAAABACkAAAAFgAFAAADFwAFAxoAFgMbACoDHwAuAyAApQAAACoA
BAATAAMAvADUAAIAAAAwAKYApwAAAAUAKwEBAJEAAQAkAAwAvADUAAIBAgAA
AAwAAQAFACsBAQCTAAEAsAAAAA4AAvwAFgcBA/wAEwcAVAACAQQBAAABAKMA
AACuAAUAAwAAADAqtABZTCvGABABK7YAU8AAVFlNpgAXKrsAVVm7AFRZtwBW
WU23AFe1AFkstgBYLLAAAAAEAKQAAAAWAAUAAAMrAAUDLgAWAy8AKgMzAC4D
NAClAAAAKgAEABMAAwC8ANQAAgAAADAApgCnAAAABQArAQEAkQABACQADAC8
ANQAAgECAAAADAABAAUAKwEBAJMAAQCwAAAADgAC/AAWBwED/AATBwBUAAIB
BQEAAAEAowAAAK4ABQADAAAAMCq0AFpMK8YAEAErtgBTwABUWU2mABcquwBV
WbsAVFm3AFZZTbcAV7UAWiy2AFgssAAAAAQApAAAABYABQAAAz8ABQNCABYD
QwAqA0cALgNIAKUAAAAqAAQAEwADALwA1AACAAAAMACmAKcAAAAFACsBAQCR
AAEAJAAMALwA1AACAQIAAAAMAAEABQArAQEAkwABALAAAAAOAAL8ABYHAQP8
ABMHAFQAAgEGAQcAAQCjAAAApAAFAAMAAAAqKrQAW0wrxgAQASu2AFPAAFxZ
TaYAFSq7AFVZEQCAvAhZTbcAV7UAWyywAAAABACkAAAAEgAEAAADUwAFA1YA
FgNXACgDWgClAAAAKgAEABMAAwC8AIUAAgAAACoApgCnAAAABQAlAQEAkQAB
ACIACAC8AIUAAgECAAAADAABAAUAJQEBAJcAAQCwAAAADgAC/AAWBwED/AAR
BwBcAAABCAEJAAIAowAAAdkABwAJAAAAwhuaAAUDrCq0AF0+KrQASTYEFQQb
ogB+GxUEZBAIbDYFFQWaAAYENgUqtAAKOgYqtAAVGQYDFQW2AF42BxUHnAAj
uwAuWRJfBb0AMFkDFQS4ADFTWQQbuAAxU7gAMrcAM78DNggVCBUHogAbHRkG
FQgzEQD/fhUEeIA+hAQIhAgBp//kKlm0ABwVB4VhtQAcp/+CHQQbeARkfjYF
HRt8PhUEG2Q2BCodtQBdKhUEtQBJHJkADhUFuABgECAbZHysFQWsAAAAAwCk
AAAAcgAcAAADagAEA2sABgNuAAsDbwARA3IAFwN1ACADdgAlA3cAKAN6AC4D
ewA8A38AQQOAAFYDgQBaA4AAYQOEAGsDhgB6A4cAfQOEAIMDiwCPA4wAkgOP
AJsDlACfA5UApQOYAKoDmQCwA6AAtAOhAL8DpAClAAAAZgAKAGQAHwDZAG4A
CAAgAG8BCgBuAAUALgBhAQsAhQAGADwAUwEMAG4ABwAAAMIApgCnAAAAAADC
AQ0AbgABAAAAwgEOAJ0AAgALALcBDwBuAAMAEQCxARAAbgAEAJsAJwC8AG4A
BQCwAAAAIQAIBv0ACgEB/AAWAf0AOAcAXAH8AAIB+gAe+AAO/AAsAQCpAAAA
BAABAC4AAgERARIAAgCjAAACWQAHAAkAAADqK8YAByzHAA27ABJZEhO3ABS/
HTYEKyq0AA22ADg2BRUFmwAVFQUQEKIADiwdhAMBFQVPpwCyFQUQEKAAOR0E
ZDYIFQicABy7AC5ZEmEEvQAwWQMVCLgAMVO4ADK3ADO/LBUILjYGBioFA7YA
KmA2B6cATBUFEBGgABMDNgYGKgYDtgAqYDYHpwA1FQUQEqAAFQM2BhALKhAH
A7YAKmA2B6cAHLsALlkSYgS9ADBZAxUFuAAxU7gAMrcAM78DNggVCBUHogAR
LB2EAwEVBk+ECAGn/+6nABE6CLsALlkSYxkItwBAvx0VBGSsAAEAvADUANcA
TgADAKQAAAB2AB0AAAO4AAgDuQASA7wAFQO9AB8DwAArA8EANgPLAD0DzwBC
A9AARwPRAFUD0gBZA9EAYAPVAGYD2ABwA9kAcwPcAHoD3wB9A+IAigPmAJED
6QCUA+wAowPxALwD9wDGA/gAzgP3ANQEAADXA/wA2QP/AOUEBAClAAAArAAR
AEIALgETAG4ACABmAA0BFABuAAYAcAADARUAbgAHAH0ADQEUAG4ABgCHAAMB
FQBuAAcAlAAPARQAbgAGAKAAAwEVAG4ABwC/ABUA2QBuAAgA2QAMAPMA9AAI
ALwAKQEUAG4ABgC8ACkBFQBuAAcAAADqAKYApwAAAAAA6gEWANQAAQAAAOoB
FwB7AAIAAADqARgAbgADABUA1QEZAG4ABAAfAMsAzwBuAAUAsAAAACcADAgJ
/QAjAQH+ACkAAAH4ABIWGP0AGAEB/AACAfoAFEIHAE75AA0AqQAAAAYAAgAu
ABIAAgEaALQAAgCjAAABJAAEAAEAAACqKgQEtgAqmQBfKgQEtgAqmQBLKgQE
tgAqmQAPEQDAKhAGBLYAKmCsKgQEtgAqmQAOEQCgKggEtgAqYKwqBAS2ACqZ
AA4RAJAqBwS2ACpgrBEBGCoGBLYAKmCsEFAqEAYEtgAqYKwqBAS2ACqZAA4Q
ECoQBgS2ACpgrCoEBLYAKpkAICoEBLYAKpkADAMqBwS2ACpgrBEBECoGBLYA
KmCsEQEAKgcEtgAqYKwAAAADAKQAAABGABEAAAQXAAkEGAASBBkAGwQaACcE
HAAwBB0AOwQfAEQEIABPBCIAWgQkAGUEJgBuBCcAeQQpAIIEKgCLBCsAlAQt
AJ8ELwClAAAADAABAAAAqgCmAKcAAACwAAAACgAIJxMTCgoTGgoAqQAAAAQA
AQAuAAIBGwEcAAIAowAAAiIABwALAAAAxyzHAA27ABJZEhO3ABS/KrQAEDoF
KrQAEToGAzYHGQW+NggVBxUIogAVGQUVBwNPGQYVBwNPhAcBp//qAzYHHTYI
FQcVBKIAFxkFLBUILlwuBGBPhAcBhAgBp//oGQUDA08DNgcENggVCBAPowAe
FQcZBRUIBGQuYAR4NgcZBhUIFQdPhAgBp//hK7YAWAM2CB02CRUIFQSiAC4s
FQkuNgoVCpkAGisVCBkGFQpcLlsEYE8EFQp4BGS2AGRXhAgBhAkBp//RK7AA
AAADAKQAAABiABgAAAREAAQERQAOBEgAFARJABoESgApBEwALwRNADUESgA7
BFEASARSAFMEUQBcBFMAYQRXAGQEWABuBFoAfARbAIMEWACJBF8AjQRgAJoE
YwCgBGYApQRnALwEYADFBGsApQAAAKIAEAAdAB4A2QBuAAcAIgAZANoAbgAI
AD4AHgDZAG4ABwBBABsBHQBuAAgAZwAiAR4AbgAIAKAAHADuAG4ACgCQADUB
HwBuAAgAkwAyAR0AbgAJAAAAxwCmAKcAAAAAAMcBIADUAAEAAADHASEAewAC
AAAAxwDCAG4AAwAAAMcAwwBuAAQAFACzASIAewAFABoArQEjAHsABgBkAGMA
zwBuAAcAsAAAADkACg7/ABMACQcAAQcAVAcA5QEBBwDlBwDlAQEAAPkAGP0A
BQEB+QAa/QAKAQH6ACH9AAkBASj5AAgAqQAAAAQAAQASAAIBJAElAAIAowAA
AesAAwANAAAAqQQceARkNgQbFQR+PB2ZAA0buABgECAcZHw8KrQAZTYFKrQA
ZjYGFQUbFQR+FQZ4gDYFFQYcYDYGFQYQCKEAYCq0ACM6Byq0ACQ2CCq0ACU2
CSq0AAg6Ciq0ABg6CxUFkTYMFQUQCHw2BYQG+BUIFQmiABAZBxUIhAgBFQxU
pwALGQoVDLYAZ1cZCxUMtgBoFQYQCKL/yioVCLUAJCoVBbUAZSoVBrUAZrEA
AAADAKQAAABqABoAAAR7AAcEfgAMBH8AEASAABoEgwAgBIQAJgSHADIEiAA4
BIsAPwSOAEUEjwBLBJAAUQSTAFcElgBdBJwAYgSdAGkEngBsBKEAcwSiAIAE
pgCIBKkAjwSqAJYErQCcBLEAogSyAKgEswClAAAAhAANAGIALQEmAScADABF
AFcBKACFAAcASwBRASkAbgAIAFEASwEqAG4ACQBXAEUAgACBAAoAXQA/AH4A
fwALAAAAqQCmAKcAAAAAAKkBKwBuAAEAAACpASwAbgACAAAAqQEOAJ0AAwAH
AKIBLQBuAAQAIACJAS4AbgAFACYAgwEvAG4ABgCwAAAANgAF/AAaAf8AQgAM
BwABAQEBAQEBBwBcAQEHAAYHABYAAPwAIgEH/wATAAcHAAEBAQEBAQEAAACp
AAAABAABAC4ACAEwALYAAQCjAAAAhgAEAAAAAABuEBO8ClkDEBBPWQQQEU9Z
BRAST1kGA09ZBxAIT1kIEAdPWRAGEAlPWRAHEAZPWRAIEApPWRAJCE9ZEAoQ
C09ZEAsHT1kQDBAMT1kQDQZPWRAOEA1PWRAPBU9ZEBAQDk9ZEBEET1kQEhAP
T7MARLEAAAABAKQAAAAGAAEAAAA5AAIBMQAAAAIBMgBrAAAAEgACAGoAAAAA
EAgACwABAGwAEg==
====

Added modules/tool-classfile/src/test/resources/TestClassLoad.in.



1
2
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/tool-classfile/src/test/resources/TestMinimizedLoad.in.



1
2
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/tool-classfile/src/test/resources/TestMinimizer.in.



1
2
+
+
result: NoResult
thrown: NoExceptionThrown

Added modules/tool-jarfile/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project takes input Jar files and " +
	"compiles/converts them into a format that is more easily used by " +
	"SummerCoat and RatufaCoat."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BC"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Jar File Tools"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:tool-classfile")
	implementation project(":modules:common-vm")
	implementation project(":modules:io")
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/BootstrapState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.Constants;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.Minimizer;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This contains the state of the entire bootstrap, its memory and all of the
 * classes which may be loaded accordingly.
 *
 * @since 2019/09/14
 */
public final class BootstrapState
{
	/** The size of the static field area. */
	public static final int STATIC_FIELD_SIZE =
		8192;
	
	/** The initializer to use. */
	protected final Initializer initializer =
		new Initializer();
	
	/** Class information which has been loaded. */
	private final Map<ClassName, LoadedClassInfo> _classinfos =
		new LinkedHashMap<>();
	
	/** Reference to self. */
	private final Reference<BootstrapState> _selfref =
		new WeakReference<>(this);
	
	/** Intern strings. */
	private final Map<String, Integer> _interns =
		new HashMap<>();
	
	/** Static field pointer area. */
	private int _sfieldarea;
	
	/** Static field area next pointer. */
	private int _sfieldnext;
	
	/**
	 * Allocates static field space.
	 *
	 * @return The pointer to the static field area that was allocated.
	 * @throws IllegalArgumentException If the size is zero or negative.
	 * @since 2019/09/14
	 */
	public final int allocateStaticFieldSpace(int __sz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BC0e Cannot allocate negative static
		// field space.}
		if (__sz < 0)
			throw new IllegalArgumentException("BC0e");
		
		// Allocate area for static fields, if not done yet
		int sfieldarea = this.staticFieldAreaAddress();
		
		// Determine the space that is needed
		int sfieldnext = this._sfieldnext;
		int snext = sfieldnext + __sz;
		
		// {@squirreljme.error BC03 Ran out of static field space.}
		if (snext >= BootstrapState.STATIC_FIELD_SIZE)
			throw new RuntimeException("BC03");
			
		// Set next pointer area
		this._sfieldnext = snext;
		
		// Pointer is here
		return sfieldnext;
	}
	
	/**
	 * Builds a character array.
	 *
	 * @param __v The characters to build.
	 * @return The pointer to the char array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public final int buildCharArray(char... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
			
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// The number of elements to store
		int n = __v.length;
		
		// Return pointer
		int rv = this.reserveCharArray(n);
		
		// Write details of object
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			rv + Constants.OBJECT_CLASS_OFFSET,
			this.findClass("[C").infoPointer());
		initializer.memWriteInt(
			rv + Constants.OBJECT_COUNT_OFFSET,
			999999);
		initializer.memWriteInt(
			rv + Constants.ARRAY_LENGTH_OFFSET,
			n);
		
		// Write values in the array
		for (int i = 0, wp = rv + Constants.ARRAY_BASE_SIZE;
			i < n; i++, wp += 2)
			initializer.memWriteShort(null, wp, (short)__v[i]);
		
		return rv;
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(Modifier __m, int... __v)
		throws NullPointerException
	{
		return this.buildIntArray(new ClassName("[I"), __m, __v);
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(String __t, Modifier __m, int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		return this.buildIntArray(new ClassName(__t), __m, __v);
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(ClassName __t, Modifier __m, int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		return this.finalizeIntArray(this.reserveIntArray(__v.length),
			__t, __m, __v);
	}
	
	/**
	 * Returns an info pointer for the given class names.
	 *
	 * @param __cls The class names to get info pointers for.
	 * @return The pointer to the class info pointer list.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int classNamesInfoPointer(ClassNames __cls)
		throws NullPointerException
	{
		if (__cls == null)
			throw new NullPointerException("NARG");
		
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// Fill in values for pointers
		int n = __cls.size();
		int[] values = new int[n];
		for (int i = 0; i < n; i++)
			values[i] = this.findClass(__cls.get(i)).infoPointer();
		
		// Return array of these pointers
		return this.buildIntArray("[I", Modifier.RAM_OFFSET, values);
	}
	
	/**
	 * Finalizes the integer array by writing values over it.
	 *
	 * @param __p The array pointer.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int finalizeIntArray(int __p, Modifier __m, int... __v)
		throws NullPointerException
	{
		return this.finalizeIntArray(__p, new ClassName("[I"), __m, __v);
	}
	
	/**
	 * Finalizes the integer array by writing values over it.
	 *
	 * @param __p The array pointer.
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int finalizeIntArray(int __p, ClassName __t, Modifier __m,
		int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// Force a default modifier
		if (__m == null)
			__m = Modifier.NONE;
		
		// The number of elements to store
		int n = __v.length;
		
		// Write details of object
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			__p + Constants.OBJECT_CLASS_OFFSET,
			this.findClass(__t).infoPointer());
		initializer.memWriteInt(
			__p + Constants.OBJECT_COUNT_OFFSET,
			999999);
		initializer.memWriteInt(
			__p + Constants.ARRAY_LENGTH_OFFSET,
			n);
		
		// Write values in the array
		for (int i = 0, wp = __p + Constants.ARRAY_BASE_SIZE;
			i < n; i++, wp += 4)
			initializer.memWriteInt(__m, wp, __v[i]);
		
		return __p;
	}
	
	/**
	 * Finds the class which uses the given name.
	 *
	 * @param __cl The class name to find.
	 * @return The loaded class information.
	 * @throws InvalidClassFormatException If the class was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo findClass(String __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.findClass(new ClassName(__cl));
	}
	
	/**
	 * Finds the class which uses the given name.
	 *
	 * @param __cl The class name to find.
	 * @return The loaded class information.
	 * @throws InvalidClassFormatException If the class was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo findClass(ClassName __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Locate pre-loaded class
		Map<ClassName, LoadedClassInfo> classinfos = this._classinfos;
		LoadedClassInfo rv = classinfos.get(__cl);
		if (rv == null)
		{
			// Load special primitive and array types magically!
			if (__cl.isPrimitive() || __cl.isArray())
				classinfos.put(__cl, (rv = new LoadedClassInfo(
					Minimizer.minimizeAndDecode(
						ClassFile.special(__cl.field())), 0, this._selfref)));
			
			// {@squirreljme.error BC0c Could not find the specified class.
			// (The class name)}
			else
				throw new InvalidClassFormatException("BC0c " + __cl);
		}
		
		return rv;
	}
	
	/**
	 * Interns the given string.
	 *
	 * @param __s The string to intern.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public final int internString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// If it was loaded already, ignore
		Map<String, Integer> interns = this._interns;
		if (interns.containsKey(__s))
			return interns.get(__s);
		
		// Allocate string object
		LoadedClassInfo strci = this.findClass("java/lang/String");
		int strp = this.initializer.allocate(strci.allocationSize());
		
		// Cache it
		interns.put(__s, strp);
		
		// Setup class information
		this.initializer.memWriteInt(Modifier.RAM_OFFSET,
			strp + Constants.OBJECT_CLASS_OFFSET,
			strci.infoPointer());
		this.initializer.memWriteInt(
			strp + Constants.OBJECT_COUNT_OFFSET,
			999999);
		
		// Write pointer to character array data
		this.initializer.memWriteInt(Modifier.RAM_OFFSET,
			strp + strci.fieldInstanceOffset(
				new FieldName("_chars"),
				new FieldDescriptor("[C")),
			this.buildCharArray(__s.toCharArray()));
		
		// Use the string pointer
		return strp;
	}
	
	/**
	 * Loads the class file information.
	 *
	 * @param __b The class file data.
	 * @param __pos The position of the class file in ROM.
	 * @return The loaded class information
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo loadClassFile(byte[] __b, int __pos)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Decode it
		MinimizedClassFile cf = MinimizedClassFile.decode(__b);
		
		// Store loaded for later boot usage
		LoadedClassInfo rv;
		if (this._classinfos.put(cf.thisName(),
			(rv = new LoadedClassInfo(cf, __pos, this._selfref))) != null)
		{
			// {@squirreljme.error BC0b Class file has already been loaded.
			// (The class name)}
			throw new IllegalStateException("BC0b " + cf.thisName());
		}
		
		return rv;
	}
	
	/**
	 * Reserves a char array that can fit the specified number of characters.
	 *
	 * @param __n The length of the array.
	 * @return The pointer to the array.
	 * @since 2019/12/15
	 */
	public final int reserveCharArray(int __n)
	{
		return this.initializer.allocate(
			Constants.ARRAY_BASE_SIZE + (2 * __n));
	}
	
	/**
	 * Reserves an integer array that can fit the specified number of entries.
	 *
	 * @param __n The number of entries to reserve.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int reserveIntArray(int __n)
	{
		return this.initializer.allocate(
			Constants.ARRAY_BASE_SIZE + (4 * __n));
	}
	
	/**
	 * Returns the address of the static field area.
	 *
	 * @return The static field address area.
	 * @since 2019/09/14
	 */
	public final int staticFieldAreaAddress()
	{
		// Allocate area for static fields, if not done yet
		int sfieldarea = this._sfieldarea;
		if (sfieldarea <= 0)
			this._sfieldarea = (sfieldarea = this.initializer.allocate(
				BootstrapState.STATIC_FIELD_SIZE));
		
		return sfieldarea;
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/ClassNameAndMinimizedField.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import dev.shadowtail.classfile.mini.MinimizedField;
import net.multiphasicapps.classfile.ClassName;

/**
 * This contains a class and a minimized field.
 *
 * @since 2019/09/14
 */
public final class ClassNameAndMinimizedField
{
	/** The class name. */
	public final ClassName classname;
	
	/** The field. */
	public final MinimizedField field;
	
	/**
	 * Initializes the class name and field.
	 *
	 * @param __cn The class name.
	 * @param __mf The minimized field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public ClassNameAndMinimizedField(ClassName __cn, MinimizedField __mf)
		throws NullPointerException
	{
		if (__cn == null || __mf == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
		this.field = __mf;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/21
	 */
	@Override
	public final String toString()
	{
		return this.classname + ":" + this.field.nameAndType();
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/ClassNameAndMinimizedMethod.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import dev.shadowtail.classfile.mini.MinimizedMethod;
import net.multiphasicapps.classfile.ClassName;

/**
 * This contains a class and a minimized method.
 *
 * @since 2019/09/21
 */
public final class ClassNameAndMinimizedMethod
{
	/** The class name. */
	public final ClassName classname;
	
	/** The method. */
	public final MinimizedMethod method;
	
	/**
	 * Initializes the class name and method.
	 *
	 * @param __cn The class name.
	 * @param __mm The minimized method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/21
	 */
	public ClassNameAndMinimizedMethod(ClassName __cn, MinimizedMethod __mm)
		throws NullPointerException
	{
		if (__cn == null || __mm == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
		this.method = __mm;
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/Initializer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This is used to build the initialization sequence accordingly. It is used
 * determine the initial amount of memory needed along with all the various
 * actions which need to be performed at this point.
 *
 * The initializer starts with a memory sequence chunk which could later be
 * freed when it is no longer needed potentially.
 *
 * @since 2019/04/30
 */
public final class Initializer
{
	/** Memory chunk size offset. */
	public static final int CHUNK_SIZE_OFFSET =
		0;
	
	/** Next chunk address. */
	public static final int CHUNK_NEXT_OFFSET =
		4;
	
	/** The length of chunks. */
	public static final int CHUNK_LENGTH =
		8;
	
	/** Operations. */
	private final List<Operation> _ops =
		new ArrayList<>();
	
	/** Current allocated temporary space. */
	private byte[] _bytes = new byte[65536];
	
	/** Current size of the initializer. */
	private int _size =
		0;
	
	/**
	 * Allocates memory in the initialization sequence.
	 *
	 * @param __sz The number of bytes to allocate.
	 * @return The pointer address of the allocation.
	 * @since 2019/04/30
	 */
	public final int allocate(int __sz)
	{
		// Force minimum size, otherwise things will get very messed up
		if (__sz < 1)
			__sz = 1;
		
		// Round allocation to 4-bytes
		__sz = (__sz + 3) & (~3);
		
		// Calculate the next size of the boot area
		int nowat = this._size,
			chunksize = __sz + Initializer.CHUNK_LENGTH,
			nextat = nowat + chunksize;
		
		// If the memory space is too small, grow it
		byte[] bytes = this._bytes;
		if (nextat > bytes.length)
			this._bytes = (bytes = Arrays.copyOf(bytes, nextat + 2048));
		
		// The return address is after the chunk length
		int rv = nowat + Initializer.CHUNK_LENGTH;
		
		// Record size of chunk and the next chunk position in RAM
		this.memWriteInt(null,
			nowat + Initializer.CHUNK_SIZE_OFFSET, chunksize);
		this.memWriteInt(Modifier.RAM_OFFSET,
			nowat + Initializer.CHUNK_NEXT_OFFSET, nextat);
		
		// Continue at the end
		this._size = nextat;
		return rv;
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteByte(int __addr, int __v)
	{
		this.memWriteByte(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteByte(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m != null && __m != Modifier.NONE)
			this._ops.add(new Operation(__m, (byte)1, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr] = (byte)__v;
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteInt(int __addr, int __v)
	{
		this.memWriteInt(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteInt(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)4, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 24);
		bytes[__addr++] = (byte)(__v >>> 16);
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/05/25
	 */
	public final void memWriteLong(int __addr, long __v)
	{
		this.memWriteLong(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/05/25
	 */
	public final void memWriteLong(Modifier __m, int __addr, long __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)8, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 56L);
		bytes[__addr++] = (byte)(__v >>> 48L);
		bytes[__addr++] = (byte)(__v >>> 40L);
		bytes[__addr++] = (byte)(__v >>> 32L);
		bytes[__addr++] = (byte)(__v >>> 24L);
		bytes[__addr++] = (byte)(__v >>> 16L);
		bytes[__addr++] = (byte)(__v >>> 8L);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteShort(int __addr, int __v)
	{
		this.memWriteShort(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteShort(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)2, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Converts and builds the initializer sequence.
	 *
	 * @return The byte array representing the sequence.
	 * @since 2019/04/30
	 */
	public final byte[] toByteArray()
	{
		List<Operation> ops = this._ops;
		byte[] bytes = this._bytes;
		int size = this._size;
		
		// Round up to prevent uneven sizes
		size = (size + 3) & (~3);
		
		// Give extra bytes for the terminator chunk
		size += Initializer.CHUNK_LENGTH;
		
		// Write initializer RAM
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
			DataOutputStream dos = new DataOutputStream(baos))
		{
			// Write initializer memory chunk
			dos.writeInt(size);
			dos.write(bytes, 0, size);
			
			// Write out operations
			int n = ops.size();
			dos.writeInt(n);
			for (int i = 0; i < n; i++)
			{
				Operation op = ops.get(i);
				
				// Write operation tag and address offset
				dos.writeByte((op.size << 4) | (op.mod.ordinal()));
				dos.writeInt(op.addr);
				
				// Write the value
				Number v = op.value;
				switch (op.size)
				{
					case 1:
						dos.writeByte(v.byteValue());
						break;
						
					case 2:
						dos.writeShort(v.shortValue());
						break;
						
					case 4:
						dos.writeInt(v.intValue());
						break;
						
					case 8:
						dos.writeLong(v.longValue());
						break;
					
					default:
						throw new todo.OOPS();
				}
				
				// Debug
				if (JarMinimizer._ENABLE_DEBUG)
					todo.DEBUG.note("Op %-5d: %d@0x%08x = %d (%s)",
						i, op.size, op.addr, op.value, op.mod);
			}
			
			// End mark
			dos.writeInt(-1);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Wrote %d bytes, %d ops", dos.size(), n);
			
			// Done!
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BC01 Could not export boot area.}
		catch (IOException e)
		{
			throw new RuntimeException("BC01", e);
		}
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/JarMinimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.classfile.mini.DualPoolEncodeResult;
import dev.shadowtail.classfile.mini.DualPoolEncoder;
import dev.shadowtail.classfile.mini.Minimizer;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This class is responsible for creating minimized Jar files which will then
 * be built into a ROM and used by SummerCoat and RatufaCoat.
 *
 * @since 2019/04/27
 */
public final class JarMinimizer
{
	/**
	 * {@squirreljme.property dev.shadowtail.jarfile.debug=boolean
	 * Should debugging text be printed for the JAR minimizer?}
	 */
	static final boolean _ENABLE_DEBUG =
		Boolean.getBoolean("dev.shadowtail.jarfile.debug");
	
	/** The state of the bootstrap. */
	protected final BootstrapState bootstrap;
	
	/** Is this a boot JAR? */
	protected final boolean boot;
	
	/** The input JAR. */
	protected final VMClassLibrary input;
	
	/** The dual-combined constant pool. */
	protected final DualClassRuntimePoolBuilder dualpool;
	
	/** Are we using our own dual pool? */
	protected final boolean owndualpool;
	
	/** The resulting JAR header. */
	private MinimizedJarHeader _jheader;
	
	/**
	 * Initializes the minimizer worker.
	 *
	 * @param __dp The global dual constant pool, may be {@code null} to not
	 * use the pack-file global one.
	 * @param __boot Is this a boot JAR?
	 * @param __in The input library.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	private JarMinimizer(DualClassRuntimePoolBuilder __dp, boolean __boot,
		VMClassLibrary __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
			
		this.boot = __boot;
		this.input = __in;
		
		// Use the passed pool if it was passed, but otherwise just use one
		// in the event one was not passed through (uses our own pool)
		boolean owndualpool = (__boot ? false : (__dp == null));
		this.dualpool = (__boot ? null : (owndualpool ?
			new DualClassRuntimePoolBuilder() : __dp));
		this.owndualpool = owndualpool;
		
		// Setup bootstrap, but only if booting
		this.bootstrap = (__boot ? new BootstrapState() : null);
	}
	
	/**
	 * Processes the input JAR.
	 *
	 * @param __out The output.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	private final void __process(OutputStream __sout)
		throws IOException, NullPointerException
	{
		if (__sout == null)
			throw new NullPointerException("NARG");
		
		// The current state of the bootstrap
		BootstrapState bootstrap = this.bootstrap;
		Initializer initializer = (bootstrap == null ? null :
			bootstrap.initializer);
		
		// This is processed for all entries
		VMClassLibrary input = this.input;
		
		// Need list of resources to determine
		String[] rcnames = input.listResources();
		int numrc = rcnames.length;
		
		// Sort all the resources so that it is faster to find the entries
		Arrays.sort(rcnames);
		
		// Manifest offset and length
		int manifestoff = 0,
			manifestlen = 0;
		
		// Table of the entire JAR for writing
		TableSectionOutputStream out = new TableSectionOutputStream();
		
		// Start the header and table of contents
		// These are fixed size because the bootstrapper needs to know the
		// true pointer of the minified class file in the JAR
		TableSectionOutputStream.Section header = out.addSection(
			MinimizedJarHeader.HEADER_SIZE_WITH_MAGIC, 4);
		TableSectionOutputStream.Section toc = out.addSection(
			numrc * 16, 4);
		
		// Write base header and contents information
		header.writeInt(MinimizedJarHeader.MAGIC_NUMBER);
		header.writeInt(numrc);
		header.writeSectionAddressInt(toc);
		
		// The global dual-constant pool if one is available
		DualClassRuntimePoolBuilder dualpool = this.dualpool;
		
		// Buffer for byte copies
		byte[] copybuf = new byte[512];
		
		// Go through and add every resource
		for (int i = 0; i < numrc; i++)
		{
			// Resource to encode/copy
			String rc = rcnames[i];
			
			// Section to contain the data for this resource
			TableSectionOutputStream.Section rcdata = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Process the resource
			try (InputStream in = input.resourceAsStream(rc))
			{
				// Minimizing class file if it is a valid class
				if (rc.endsWith(".class") && ClassName.isValidClassName(
					rc.substring(0, rc.length() - 6)))
				{
					// Minimize the class
					byte[] bytes = Minimizer.minimize(dualpool,
						ClassFile.decode(in));
					
					// Write to ROM!
					rcdata.write(bytes);
					
					// Load class file if booting
					if (bootstrap != null)
						bootstrap.loadClassFile(bytes,
							out.sectionAddress(rcdata));
				}
				
				// Plain resource copy
				else
				{
					for (;;)
					{
						int ll = in.read(copybuf);
						
						// EOF?
						if (ll < 0)
							break;
						
						// Write
						rcdata.write(copybuf);
					}
				}
			}
			
			// Write the hash code of the entry name
			toc.writeInt(rc.hashCode());
			
			// Write name of the resource
			TableSectionOutputStream.Section rcname = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			rcname.writeUTF(rc);
			toc.writeSectionAddressInt(rcname);
			
			// Write position and size of the data
			toc.writeSectionAddressInt(rcdata);
			toc.writeSectionSizeInt(rcdata);
		}
		
		// Uncompressed and copied manifest?
		try (InputStream in = input.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// There is a manifest
			if (in != null)
			{
				TableSectionOutputStream.Section manifest = out.addSection(
					TableSectionOutputStream.VARIABLE_SIZE, 4);
				
				// Copy the manifest to an uncompressed section
				for (;;)
				{
					int ll = in.read(copybuf);
					
					// EOF?
					if (ll < 0)
						break;
					
					// Write
					manifest.write(copybuf);
				}
				
				// Manifest offset and length
				header.writeSectionAddressInt(manifest);
				header.writeSectionSizeInt(manifest);
			}
			
			// There is none
			else
			{
				header.writeInt(0);
				header.writeInt(0);
			}
		}
		
		// Doing bootstrapping?
		if (bootstrap != null)
		{
			// The class being booted
			LoadedClassInfo booting = bootstrap.findClass(
				"cc/squirreljme/jvm/boot/Bootstrap");
			
			// Get all the bootstrap information before it is written!
			int bootpool = booting.poolPointer();
			int bootsfbp = bootstrap.staticFieldAreaAddress();
			int bootmeth = booting.methodCodeAddress(
				new MethodName("__start"), null);
			int bootidba = bootstrap.findClass("[B").infoPointer();
			int bootidbd = bootstrap.findClass("[[B").infoPointer();
			
			// Get the handler for system calls and such
			LoadedClassInfo tshclass = bootstrap.findClass(
				"cc/squirreljme/jvm/boot/task/TaskSysCallHandler");
			int scmeth = tshclass.methodCodeAddress(
				new MethodName("taskSysCall"), null),
				scpool = tshclass.poolPointer();
			
			// Setup the BootRAM
			TableSectionOutputStream.Section bootram = out.addSection(
				bootstrap.initializer.toByteArray(), 4);
			
			// Boot memory offset, size
			header.writeSectionAddressInt(bootram);
			header.writeSectionSizeInt(bootram);
			
			// Pool, sfa, code
			header.writeInt(bootpool);
			header.writeInt(bootsfbp);
			header.writeInt(bootmeth);
			
			// System call SFP, handler, and pool
			header.writeInt(bootsfbp);
			header.writeInt(scmeth);
			header.writeInt(scpool);
			
			// classidba, classidbaa
			header.writeInt(bootidba);
			header.writeInt(bootidbd);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Boot entry: %d/0x%08x", bootmeth, bootmeth);
		}
		
		// No bootstrapping being done
		else
		{
			// Boot memory offset, size
			header.writeInt(0);
			header.writeInt(0);
			
			// Pool, sfa, code
			header.writeInt(0);
			header.writeInt(0);
			header.writeInt(0);
			
			// System call SFP, handler, and pool
			header.writeInt(0);
			header.writeInt(0);
			header.writeInt(0);
			
			// classidba, classidbaa
			header.writeInt(0);
			header.writeInt(0);
		}
		
		// Debug
		if (JarMinimizer._ENABLE_DEBUG)
			todo.DEBUG.note("Own pool=%s, dualpool=%s",
				this.owndualpool, dualpool);
		
		// We are using our own dual pool, so write it out as if it were
		// in the pack file. It is only local to this JAR.
		if (this.owndualpool && dualpool != null)
		{
			// Where our pools are going
			TableSectionOutputStream.Section lpd = out.addSection();
			
			// Encode the pools
			DualPoolEncodeResult der = DualPoolEncoder.encode(dualpool, lpd);
			
			// Static pool
			header.writeSectionAddressInt(lpd, der.staticpooloff);
			header.writeInt(der.staticpoolsize);
			
			// Run-time pool
			header.writeSectionAddressInt(lpd, der.runtimepooloff);
			header.writeInt(der.runtimepoolsize);
		}
		
		// We are using the global pack pool, so set special indicators
		// that we are doing as such! The minimized class will use special
		// a special aliased pool for the pack file.
		else
		{
			// Static pool offset and size
			header.writeInt(-1);
			header.writeInt(-1);
			
			// Runtime pool offset and size
			header.writeInt(-1);
			header.writeInt(-1);
		}
		
		// Since we need the header we need the byte array for the JAR
		byte[] jardata = out.toByteArray();
		
		// Get header for returning
		this._jheader = MinimizedJarHeader.decode(
			new ByteArrayInputStream(jardata));
		
		// Write to output
		__sout.write(jardata);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @return The resulting byte array of minimization.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final byte[] minimize(boolean __boot, VMClassLibrary __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Write to a temporary byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Perform minimization
			JarMinimizer.minimize(null, __boot, __in, baos, null);
			
			// Return the generated array
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final void minimize(boolean __boot, VMClassLibrary __in,
		OutputStream __out)
		throws IOException, NullPointerException
	{
		JarMinimizer.minimize(null, __boot, __in, __out, null);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @param __mjh The output JAR header.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final void minimize(boolean __boot, VMClassLibrary __in,
		OutputStream __out, MinimizedJarHeader[] __mjh)
		throws IOException, NullPointerException
	{
		JarMinimizer.minimize(null, __boot, __in, __out, __mjh);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __dp The dual-pool.
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @param __mjh The output JAR header.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final void minimize(DualClassRuntimePoolBuilder __dp,
		boolean __boot, VMClassLibrary __in, OutputStream __out,
		MinimizedJarHeader[] __mjh)
		throws IOException, NullPointerException
	{
		if (__in == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Use helper class
		JarMinimizer jm = new JarMinimizer(__dp, __boot, __in);
		jm.__process(__out);
		
		// Set header that was generated
		if (__mjh != null && __mjh.length > 0)
			__mjh[0] = jm._jheader;
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/LoadedClassInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.ClassInfo;
import cc.squirreljme.jvm.Constants;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.MinimizedField;
import dev.shadowtail.classfile.mini.MinimizedMethod;
import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;
import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.lang.ref.Reference;
import java.util.Deque;
import java.util.LinkedList;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * Boot information for a class.
 *
 * @since 2019/04/30
 */
public final class LoadedClassInfo
{
	/** The bootstrap reference. */
	private final Reference<BootstrapState> _bootstrap;
	
	/** The minimized class. */
	private final MinimizedClassFile _class;
	
	/** The offset to the class. */
	private final int _classoffset;
	
	/** The offset to the constant pool allocation. */
	private int _pooloffset =
		-1;
	
	/** Static memory offset. */
	private int _smemoff =
		-1;
	
	/** The class data V2 offset. */
	private int _classdata =
		-1;
	
	/** The size of instances for this class. */
	private int _allocsize;
	
	/** The base pointer position for fields. */
	private int _baseoff =
		-1;
	
	/** The VTable for this class. */
	private int _vtable =
		-1;
	
	/** The constant pool references for this class vtable. */
	private int _vtablepool =
		-1;
	
	/** The depth of this class. */
	private int _classdepth =
		-1;
	
	/**
	 * Initializes the boot info.
	 *
	 * @param __cl The class.
	 * @param __co The class offset.
	 * @param __bs The reference to the owning bootstrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	LoadedClassInfo(MinimizedClassFile __cl, int __co,
		Reference<BootstrapState> __bs)
		throws NullPointerException
	{
		if (__cl == null || __bs == null)
			throw new NullPointerException("NARG");
		
		this._class = __cl;
		this._classoffset = __co;
		this._bootstrap = __bs;
	}
	
	/**
	 * The allocated instance size.
	 *
	 * @return The allocated instance size.
	 * @since 2019/09/14
	 */
	public final int allocationSize()
	{
		// Pre-cached already?
		int rv = this._allocsize;
		if (rv > 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// This class is the size of the super class and our size
		ClassName supercl = this._class.superName();
		this._allocsize = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).allocationSize()) +
			this._class.header.ifbytes);
		
		return rv;
	}
	
	/**
	 * Return the base offset of this class.
	 *
	 * @return The base off of this class.
	 * @since 2019/09/14
	 */
	public final int baseOffset()
	{
		// Was already cached?
		int rv = this._baseoff;
		if (rv >= 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The base offset is the allocation size of the super-class
		ClassName supercl = this._class.superName();
		this._baseoff = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).allocationSize()));
		
		return rv;
	}
	
	/**
	 * Returns the depth of this class.
	 *
	 * @return The depth of this class.
	 * @since 2019/12/01
	 */
	public final int classDepth()
	{
		// Was already cached?
		int rv = this._classdepth;
		if (rv >= 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The class depth is just one added from the super-class
		ClassName supercl = this._class.superName();
		this._classdepth = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).classDepth() + 1));
		
		return rv;
	}
	
	/**
	 * Returns the instance offset of the field.
	 *
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @return The offset of the field.
	 * @throws InvalidClassFormatException If the field was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int fieldInstanceOffset(FieldName __fn, FieldDescriptor __fd)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__fn == null || __fd == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BC02 Could not locate instance field. (Class;
		// Field Name; Field Type)}
		MinimizedField mf = this._class.field(false, __fn, __fd);
		if (mf == null)
			throw new InvalidClassFormatException(
				String.format("BC02 %s %s %s", this._class.thisName(), __fn,
					__fd));
		
		// Determine offset to field
		return this.baseOffset() + mf.offset;
	}
	
	/**
	 * Returns the static offset of the field.
	 *
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @return The offset of the field.
	 * @throws InvalidClassFormatException If the field was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int fieldStaticOffset(FieldName __fn, FieldDescriptor __fd)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__fn == null || __fd == null)
			throw new NullPointerException("NARG");
		
		// Need the static field offset
		int smemoff = this.staticFieldOffset();
		
		// {@squirreljme.error BC04 Could not locate static field. (Class;
		// Field Name; Field Type)}
		MinimizedField mf = this._class.field(true, __fn, __fd);
		if (mf == null)
			throw new InvalidClassFormatException(
				String.format("BC04 %s %s %s", this._class.thisName(),
					__fn, __fd));
		
		// Return offset to it
		return smemoff + mf.offset;
	}
	
	/**
	 * Returns the pointer to the class information.
	 *
	 * @return The pointer to the class information.
	 * @since 2019/09/14
	 */
	public final int infoPointer()
	{
		// If it has already been initialized use it
		int rv = this._classdata;
		if (rv >= 0)
			return rv;
		
		// Get bootstrap and initializer
		BootstrapState bootstrap = this.__bootstrap();
		Initializer initializer = bootstrap.initializer;
		
		// Get the class info for class info
		LoadedClassInfo classinfoci =
			bootstrap.findClass("cc/squirreljme/jvm/ClassInfo");
		
		// Allocate pointer to the class data, then get the base pointer
		this._classdata = (rv = initializer.allocate(
			classinfoci.allocationSize()));
		
		// Load all fields into a queue for useful processing
		Deque<ClassNameAndMinimizedField> fieldq = new LinkedList<>();
		for (LoadedClassInfo atcl = classinfoci; atcl != null;
			atcl = atcl.superClass())
		{
			// Push all fields to queue
			for (MinimizedField mf : atcl._class.fields(false))
				fieldq.push(new ClassNameAndMinimizedField(
					atcl.thisName(), mf));
		}
		
		// This class information
		MinimizedClassFile mcf = this._class;
		ClassName thisname = mcf.thisName();
		
		// Fill in field data
		while (!fieldq.isEmpty())
		{
			// Get entry
			ClassNameAndMinimizedField cnmf = fieldq.pop();
			ClassName cn = cnmf.classname;
			MinimizedField mf = cnmf.field;
			
			// The write pointer of this data
			int wp = rv + bootstrap.findClass(cn).baseOffset() + mf.offset;
			
			// Depends on the key (specified where and its type)
			String key = mf.name + ":" + mf.type;
			switch (key)
			{
					// Base offset for the class
				case "base:I":
					initializer.memWriteInt(wp, this.baseOffset());
					break;
					
					// Cell size
				case "cellsize:I":
					{
						// Determine the cell size
						int cellsize;
						switch (thisname.toString())
						{
							case "byte":
							case "boolean":
							case "[Z":
							case "[B":
								cellsize = 1;
								break;
							
							case "short":
							case "char":
							case "[S":
							case "[C":
								cellsize = 2;
								break;
								
							case "long":
							case "double":
							case "[J":
							case "[D":
								cellsize = 8;
								break;
								
							default:
								cellsize = 4;
								break;
						}
						
						// Write
						initializer.memWriteInt(
							wp, cellsize);
					}
					break;
				
					// Class info reference
				case "_class:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, bootstrap.findClass(
							"cc/squirreljme/jvm/ClassInfo").infoPointer());
					break;
					
					// The depth of this class
				case "classdepth:I":
					initializer.memWriteInt(wp, this.classDepth());
					break;
					
					// Class<?> pointer, starts always at zero since it
					// is generated at run-time
				case "classobjptr:Ljava/lang/Class;":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Component class
				case "componentclass:Lcc/squirreljme/jvm/ClassInfo;":
					// Write class ID of component type
					if (thisname.isArray())
						initializer.memWriteInt(Modifier.RAM_OFFSET,
							wp, bootstrap.findClass(
								thisname.componentType()).infoPointer());
					
					// Write null pointer
					else
						initializer.memWriteInt(wp, 0);
					break;
					
					// Default new constructor
				case "defaultnew:I":
					try
					{
						initializer.memWriteInt(Modifier.JAR_OFFSET,
							wp, this.methodCodeAddress("<init>", "()V"));
					}
					catch (InvalidClassFormatException e)
					{
					}
					break;
					
					// Dimensions
				case "dimensions:I":
					initializer.memWriteInt(
						wp, thisname.dimensions());
					break;
					
					// Class info flags
				case "flags:I":
					{
						int flags = 0;
						
						// Is this array?
						if (thisname.isArray())
						{
							// Flag it
							flags |= Constants.CIF_IS_ARRAY;
							
							// Is its component an object as well?
							if (!thisname.componentType().isPrimitive())
								flags |= Constants.CIF_IS_ARRAY_OF_OBJECTS;
						}
						
						// Is this primitive?
						if (thisname.isPrimitive())
							flags |= Constants.CIF_IS_PRIMITIVE;
						
						// Write flags
						initializer.memWriteInt(wp, flags);
					}
					break;
						
						// Interface class information
					case "interfaceclasses:[Lcc/squirreljme/jvm/ClassInfo;":
						{
							// Get interfaces pointer list
							int xp = bootstrap.classNamesInfoPointer(
								mcf.interfaceNames());
								
							// Write pointer here
							initializer.memWriteInt(Modifier.RAM_OFFSET,
								wp, xp);
							
							// The interface names in the bootstrap is the
							// pointer to the ClassInfo, but as an int array
							// type instead of an object array type. But we
							// can just override it.
							initializer.memWriteInt(Modifier.RAM_OFFSET,
								xp + Constants.OBJECT_CLASS_OFFSET,
								bootstrap.findClass(
								"[Lcc/squirreljme/jvm/ClassInfo;").
								infoPointer());
						}
						break;
					
					// The JAR index, always zero for the bootstrap
				case "jardx:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Magic number
				case "magic:I":
					initializer.memWriteInt(
						wp, ClassInfo.MAGIC_NUMBER);
					break;
					
					// Pointer to the class data in ROM
				case "miniptr:I":
					initializer.memWriteInt(Modifier.JAR_OFFSET,
						wp, this.romOffset());
					break;
					
					// Monitor count
				case "_moncount:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Thread owning the monitor (which there is none)
				case "_monitor:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Pointer to the class name
				case "namep:I":
					initializer.memWriteInt(Modifier.JAR_OFFSET,
						wp, this.romOffset() + this.poolEntryOffset(
						this._class.thisName().toString()) + 4);
					break;
					
					// The number of available methods
				case "nummethods:I":
					initializer.memWriteInt(wp, this.methodSize());
					break;
					
					// The number of objects in this class
				case "numobjects:I":
					initializer.memWriteInt(
						wp, this._class.header.ifobjs);
					break;
					
				case "pool:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.poolPointer());
					break;
					
					// Reference count for this class data, should never
					// be freed
				case "_refcount:I":
					initializer.memWriteInt(
						wp, 999999);
					break;
					
					// Pointer to our own class info
				case "selfptr:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, rv);
					break;
					
					// Static field offset
				case "sfoffset:I":
					initializer.memWriteInt(
						wp, this.staticFieldOffset());
					break;
				
					// Allocation size of this class
				case "size:I":
					initializer.memWriteInt(wp, this.allocationSize());
					break;
					
					// Super class info
				case "superclass:Lcc/squirreljme/jvm/ClassInfo;":
					ClassName sn = mcf.superName();
					if (sn == null)
						initializer.memWriteInt(wp, 0);
					else
						initializer.memWriteInt(Modifier.RAM_OFFSET,
							wp, bootstrap.findClass(sn).infoPointer());
					break;
						
					// VTable for virtual calls
				case "vtablevirtual:[I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.vTables()[0]);
					break;
					
					// VTable for pool setting
				case "vtablepool:[I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.vTables()[1]);
					break;
					
					// Not handled yet!
				default:
					throw new todo.OOPS(key);
			}
		}
		
		// Return pointer to the data now
		return rv;
	}
	
	/**
	 * Returns the method base for the class.
	 *
	 * @return The method base.
	 * @since 2019/05/26
	 */
	public final int methodBase()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// If there is no super class then we just start at zero
		ClassName supername = this._class.superName();
		if (supername == null)
			return 0;
		
		// Otherwise it is the size of the super-class where we start from
		return bootstrap.findClass(supername).methodSize();
	}
	
	/**
	 * Returns the address of the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type, if {@code null} then the type is
	 * disregarded.
	 * @return The address of the given method.
	 * @since 2019/09/20
	 */
	public final int methodCodeAddress(String __mn, String __mt)
		throws NullPointerException
	{
		if (__mn == null)
			throw new NullPointerException("NARG");
		
		return this.methodCodeAddress(new MethodName(__mn),
			(__mt == null ? null : new MethodDescriptor(__mt)));
	}
	
	/**
	 * Returns the address of the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type, if {@code null} then the type is
	 * disregarded.
	 * @return The address of the given method.
	 * @since 2019/04/30
	 */
	public final int methodCodeAddress(MethodName __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		if (__mn == null)
			throw new NullPointerException("NARG");
		
		// Get class information
		MinimizedClassFile mcf = this._class;
		
		// Lookup static first
		MinimizedMethod mm = mcf.method(true, __mn, __mt);
		if (mm != null)
			return this._classoffset + mcf.header.smoff + mm.codeoffset;
		
		// Otherwise fallback to instance methods
		// {@squirreljme.error BC07 Could not locate the given method.
		// (The class; The name; The type)}
		mm = mcf.method(false, __mn, __mt);
		if (mm == null)
			throw new InvalidClassFormatException(
				String.format("BC07 %s %s %s", mcf.thisName(), __mn, __mt));
		return this._classoffset + mcf.header.imoff + mm.codeoffset;
	}
	
	/**
	 * Returns the method index for the given method.
	 *
	 * @param __mn The name of the method.
	 * @param __mt The descriptor of the method.
	 * @return The index of the given method.
	 * @since 2019/05/26
	 */
	public final int methodIndex(MethodName __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		if (__mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// Try to find the method
		MinimizedClassFile mcf = this._class;
		MinimizedMethod mm = mcf.method(false, __mn, __mt);
		if (mm == null)
		{
			// {@squirreljme.error BC08 Could not find the specified method.
			// (The method name; The method type)}
			ClassName scn = mcf.superName();
			if (scn == null)
				throw new InvalidClassFormatException(
					"BC08 " + __mn + " " + __mt);
			
			// See if the super class has it
			return this.__bootstrap().findClass(scn).methodIndex(__mn, __mt);
		}
		
		// Is the index offset from the method base of this class
		return this.methodBase() + mm.index;
	}
	
	/**
	 * Returns the number of methods to use in the method table.
	 *
	 * @return The method size.
	 * @since 2019/05/26
	 */
	public final int methodSize()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// We are working on this class
		MinimizedClassFile cf = this._class;
		
		// The base method count
		int self = cf.header.imcount;
		
		// If there is no super class it is just the count
		ClassName supername = cf.superName();
		if (supername == null)
			return self;
		
		// Otherwise include the super class count as well
		return bootstrap.findClass(supername).methodSize() + self;
	}
	
	/**
	 * Returns the pointer to the offset of the given pool value.
	 *
	 * @param __v The value to get.
	 * @return The offset of the given value.
	 * @since 2019/09/14
	 */
	public final int poolEntryOffset(Object __v)
	{
		// Need pool for this!
		DualClassRuntimePool pool = this._class.pool;
		
		// Flagged if this is in the runtime pool?
		boolean inruntime;
		
		// Try to find the value from some pool
		BasicPoolEntry entry = pool.getByValue(false, __v);
		if ((inruntime = (entry == null)))
			entry = pool.getByValue(true, __v);
		
		// {@squirreljme.error BC0f Value not found in any pool. (The value)}
		if (entry == null)
			throw new InvalidClassFormatException("BC0f " + __v);
		
		// The offset of this entry is based on where it was found!
		return (inruntime ? this._class.header.runtimepooloff :
			this._class.header.staticpooloff) + entry.offset;
	}
	
	/**
	 * Returns a pointer to the class's constant pool.
	 *
	 * @return The pointer to the class constant pool.
	 * @since 2019/09/14
	 */
	public final int poolPointer()
	{
		// Need the bootstrap!
		BootstrapState bootstrap = this.__bootstrap();
		
		// Name of this class
		ClassName thisname = this.thisName();
		
		// If this is a primitive type or an array then use the pool pointer
		// for Object since they are virtually treated as Object!
		if (thisname.isPrimitive() || thisname.isArray())
			return bootstrap.findClass("java/lang/Object").poolPointer();
		
		// Has this already been cached?
		int rv = this._pooloffset;
		if (rv >= 0)
			return rv;
		
		// Can use the initializer now
		Initializer initializer = bootstrap.initializer;
		
		// Get the constant pool for this class
		MinimizedClassFile miniclass = this._class;
		DualClassRuntimePool pool = miniclass.pool;
		
		// Extract both parts of the pool
		BasicPool clpool = pool.classPool(),
			rtpool = pool.runtimePool();
		
		// Absolute offsets for each pool (in the ROM)
		int classoffset = this._classoffset;
		int clpadd = classoffset + miniclass.header.staticpooloff,
			rtpadd = classoffset + miniclass.header.runtimepooloff;
		
		// We only need space to fit the run-time pool
		int n = rtpool.size();
		this._pooloffset = (rv = initializer.allocate(n * 4));
		
		// Process entries, zero is always null!
		for (int i = 1; i < n; i++)
		{
			// Get the entry here
			BasicPoolEntry entry = rtpool.byIndex(i);
			
			// The value to write in the slot
			Modifier mx;
			int vx;
			
			// Depends on the type of entry we are using
			MinimizedPoolEntryType type = entry.type();
			switch (type)
			{
					// Field which has been accessed
				case ACCESSED_FIELD:
					AccessedField af = entry.<AccessedField>value(
						AccessedField.class);
					
					// Static fields are based on the pointer
					if (af.type().isStatic())
					{
						mx = null;
						vx = bootstrap.findClass(af.field.className()).
							fieldStaticOffset(af.field.memberName(),
								af.field.memberType());
					}
					
					// Instance fields are offset from a class
					else
					{
						mx = null;
						vx = bootstrap.findClass(af.field.className()).
							fieldInstanceOffset(af.field.memberName(),
								af.field.memberType());
					}
					break;
				
					// Pointer to class information
				case CLASS_INFO_POINTER:
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.findClass(entry.<ClassInfoPointer>value(
						ClassInfoPointer.class).name).infoPointer();
					break;
					
					// Pointer to class constant pool
				case CLASS_POOL:
					ClassPool pl = entry.<ClassPool>value(ClassPool.class);
					
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.findClass(pl.name).poolPointer();
					break;
					
					// A method to be invoked, these are always direct pointer
					// references to methods
				case INVOKED_METHOD:
					InvokedMethod im = entry.<InvokedMethod>value(
						InvokedMethod.class);
					
					mx = Modifier.JAR_OFFSET;
					vx = bootstrap.findClass(im.handle.outerClass()).
						methodCodeAddress(im.handle.name(),
							im.handle.descriptor());
					break;
					
					// Index of method
				case METHOD_INDEX:
					MethodIndex mi = entry.<MethodIndex>value(
						MethodIndex.class);
					
					mx = null;
					vx = bootstrap.findClass(mi.inclass).methodIndex(
						mi.name, mi.type);
					break;
					
					// A pointer to a string in memory
				case NOTED_STRING:
					mx = Modifier.JAR_OFFSET;
					vx = clpadd + clpool.byIndex(entry.part(0)).offset + 4;
					break;
					
					// A string that is used, this is loaded at run-time
				case USED_STRING:
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.internString(entry.<UsedString>value(
						UsedString.class).toString());
					break;
					
				default:
					throw new todo.OOPS(type.name());
			}
			
			// Write value to the in-memory slot
			initializer.memWriteInt(mx, rv + (4 * i), vx);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Pool %s -> %08x = %08x", entry.value,
					rv + (4 * i), vx);
		}
		
		// Return the pointer where the pool was allocated
		return rv;
	}
	
	/**
	 * Returns the ROM offset of this class.
	 *
	 * @return The ROM offset of the class.
	 * @since 2019/09/14
	 */
	public final int romOffset()
	{
		return this._classoffset;
	}
	
	/**
	 * Returns the offset of the static field area.
	 *
	 * @return The pointer of this class static field area.
	 * @since 2019/12/14
	 */
	public final int staticFieldOffset()
	{
		// Do we need to allocate static field space for this class?
		int smemoff = this._smemoff;
		if (smemoff < 0)
		{
			// Need the bootstrap here
			BootstrapState bootstrap = this.__bootstrap();
			Initializer initializer = bootstrap.initializer;
			
			// Allocate memory
			smemoff = bootstrap.allocateStaticFieldSpace(
				this._class.header.sfsize);
			
			// Store
			this._smemoff = smemoff;
			
			// Initialize static field values
			int sfieldarea = bootstrap.staticFieldAreaAddress();
			for (MinimizedField mf : this._class.fields(true))
			{
				// No value here?
				Object val = mf.value;
				if (val == null)
					continue;
				
				// Write pointer for this field
				int wp = sfieldarea + smemoff + mf.offset;
				
				// Write constant value
				switch (mf.type.toString())
				{
					case "B":
					case "Z":
						initializer.memWriteByte(wp,
							((Number)val).byteValue());
						break;
					
					case "S":
					case "C":
						initializer.memWriteShort(wp,
							((Number)val).shortValue());
						break;
					
					case "I":
						initializer.memWriteInt(wp,
							((Number)val).intValue());
						break;
					
					case "J":
						initializer.memWriteLong(wp,
							((Number)val).longValue());
						break;
					
					case "F":
						initializer.memWriteInt(wp,
							Float.floatToRawIntBits(
								((Number)val).floatValue()));
						break;
					
					case "D":
						initializer.memWriteLong(wp,
							Double.doubleToRawLongBits(
								((Number)val).doubleValue()));
						break;
					
					case "Ljava/lang/String;":
						throw new todo.TODO("Write string");
					
						// Unknown
					default:
						throw new todo.OOPS(mf.type.toString());
				}
			}
		}
		
		return smemoff;
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The class super-class.
	 * @since 2019/09/21
	 */
	public final LoadedClassInfo superClass()
	{
		ClassName sn = this._class.superName();
		return (sn == null ? null : this.__bootstrap().findClass(sn));
	}
	
	/**
	 * Returns the name of the super class.
	 *
	 * @return The name of the super class.
	 * @since 2019/09/21
	 */
	public final ClassName superName()
	{
		return this._class.superName();
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/09/14
	 */
	public final ClassName thisName()
	{
		return this._class.thisName();
	}
	
	/**
	 * Returns the pointers to the class method execution pointers along with
	 * the required pool pointers.
	 *
	 * @return The method table pointer and the pool pointer table.
	 * @since 2019/09/14
	 */
	public final int[] vTables()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The current class information
		ClassName thisname = this._class.thisName();
		
		// Primitive types and array types do not exist so they just use the
		// same vtables as Object
		if (thisname.isPrimitive() || thisname.isArray())
			return bootstrap.findClass("java/lang/Object").vTables();
		
		// Did we already make the VTable for this? This will happen in the
		// event arrays or primitives are virtualized
		int rv = this._vtable;
		if (rv >= 0)
			return new int[]{rv, this._vtablepool};
		
		// Total methods to put together
		int count = this.methodSize();
		
		// Reserve and cache
		int pmptr = bootstrap.reserveIntArray(count),
			ppool = bootstrap.reserveIntArray(count);
		this._vtable = pmptr;
		this._vtablepool = ppool;
		
		// Resultant arrays
		int[] mptr = new int[count];
		int[] pool = new int[count];
		
		// Initially seed the arrays with pure virtual calls to make them
		// illegal to be called virtually (they could only be called statically
		// or otherwise).
		for (int i = 1,
			jpvc = bootstrap.findClass("cc/squirreljme/jvm/JVMFunction").
				methodCodeAddress("jvmPureVirtualCall", "()V"),
			jpvp = bootstrap.findClass("cc/squirreljme/jvm/JVMFunction").
				poolPointer(); i < count; i++)
		{
			mptr[i] = jpvc;
			pool[i] = jpvp;
		}
		
		// Put every class and method into a queue for processing
		Deque<ClassNameAndMinimizedMethod> process = new LinkedList<>();
		for (LoadedClassInfo at = this; at != null; at = at.superClass())
		{
			// Current class name is needed for object push
			ClassName tn = at.thisName();
			
			// Add all methods in there
			for (MinimizedMethod mm : at._class.methods(false))
				process.push(new ClassNameAndMinimizedMethod(tn, mm));
		}
		
		// Process every method
		while (!process.isEmpty())
		{
			// Take off class and extract pieces
			ClassNameAndMinimizedMethod atcnmm = process.pop();
			ClassName atcn = atcnmm.classname;
			MinimizedMethod atmm = atcnmm.method;
			
			// Is this a private method?
			boolean atmmisprivate = atmm.flags().isPrivate();
			
			// Find the loaded class this refers to
			LoadedClassInfo atci = bootstrap.findClass(atcn);
			
			// Find the index of this method in the method table;
			int mdx = atci.methodIndex(atmm.name, atmm.type);
			
			// For the appropriate method from the top
			for (LoadedClassInfo sc = this; sc != null; sc = sc.superClass())
			{
				// Location method here, if missing skip because it will be
				// in a super class
				MinimizedMethod scmm = sc._class.method(false,
					atmm.name, atmm.type);
				if (scmm == null)
					continue;
				
				// If we hit a private method in another class, stop
				if (scmm.flags().isPrivate() && atci != sc)
					break;
				
				// Link to this method and the pool it is in as well
				mptr[mdx] = sc.methodCodeAddress(atmm.name, atmm.type);
				pool[mdx] = sc.poolPointer();
				
				// Stop
				break;
			}
		}
		
		// Finalize and cache
		bootstrap.finalizeIntArray(pmptr, Modifier.JAR_OFFSET, mptr);
		bootstrap.finalizeIntArray(ppool, Modifier.RAM_OFFSET, pool);
		
		// Return them
		return new int[]{pmptr, ppool};
	}
	
	/**
	 * Returns the bootstrap.
	 *
	 * @return The bootstrap.
	 * @throws IllegalStateException If it was garbage collected.
	 * @since 2019/09/14
	 */
	private final BootstrapState __bootstrap()
		throws IllegalStateException
	{
		Reference<BootstrapState> ref = this._bootstrap;
		
		// {@squirreljme.error BC0d The bootstrap state was garbage collected,
		// therefor this class is no longer valid.}
		BootstrapState rv = ref.get();
		if (rv == null)
			throw new IllegalStateException("BC0d");
		
		return rv;
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/MinimizedJarHeader.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents the header for a minimized Jar file.
 *
 * @since 2019/04/27
 */
public final class MinimizedJarHeader
{
	/** Magic number for the JAR. */
	public static final int MAGIC_NUMBER =
		0x00456570;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		72;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		76;
	
	/** Size of table of contents entries. */
	public static final int TOC_ENTRY_SIZE =
		16;
	
	/** Number of resources. */
	public final int numrc;
	
	/** Table of contents offset. */
	public final int tocoffset;
	
	/** Manifest offset. */
	public final int manifestoff;
	
	/** Manifest length. */
	public final int manifestlen;
	
	/** Boot initializer offset. */
	public final int bootoffset;
	
	/** Boot initializer size. */
	public final int bootsize;
	
	/** The boot pool offset. */
	public final int bootpool;
	
	/** Static field basein RAM. */
	public final int bootsfieldbase;
	
	/** The start method offset. */
	public final int bootstart;
	
	/** System call static field pointer. */
	public final int syscallsfp;
	
	/** System call handler code address .*/
	public final int syscallhandler;
	
	/** System call pool address. */
	public final int syscallpool;
	
	/** The ClassInfo for {@code byte[]}. */
	public final int bootclassidba;
	
	/** The ClassInfo for {@code byte[][]}. */
	public final int bootclassidbaa;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the Jar header.
	 *
	 * @param __fs Fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public MinimizedJarHeader(int... __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		int at = 0;
		
		// Table of contents
		this.numrc = __fs[at++];
		this.tocoffset = __fs[at++];
		
		// The offset to the manifest and its length
		this.manifestoff = __fs[at++];
		this.manifestlen = __fs[at++];
		
		// Boot initializer
		this.bootoffset = __fs[at++];
		this.bootsize = __fs[at++];
		this.bootpool = __fs[at++];
		this.bootsfieldbase = __fs[at++];
		this.bootstart = __fs[at++];
		this.syscallsfp = __fs[at++];
		this.syscallhandler = __fs[at++];
		this.syscallpool = __fs[at++];
		this.bootclassidba = __fs[at++];
		this.bootclassidbaa = __fs[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __fs[at++];
		this.staticpoolsize = __fs[at++];
		this.runtimepooloff = __fs[at++];
		this.runtimepoolsize = __fs[at++];
	}
	
	/**
	 * Decodes the JAR header.
	 *
	 * @param __in The input stream.
	 * @return The resulting header.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final MinimizedJarHeader decode(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need to read fields
		DataInputStream din = new DataInputStream(__in);
		
		// {@squirreljme.error BC0a Invalid minimized Jar magic number.
		// (The read magic number; The expected magic number)}
		int wasmagic;
		if (MinimizedJarHeader.MAGIC_NUMBER != (wasmagic = din.readInt()))
			throw new InvalidClassFormatException(String.format(
				"BC0a %08x %08x", wasmagic, MinimizedJarHeader.MAGIC_NUMBER));
		
		// Build
		return new MinimizedJarHeader(
			/* numrc */ din.readInt(),
			/* tocoffset */ din.readInt(),
			
			// Manifest
			/* manifestoff */ din.readInt(),
			/* manifestlen */ din.readInt(),
			
			// Boot initializer
			/* bootoffset */ din.readInt(),
			/* bootsize */ din.readInt(),
			/* bootpool */ din.readInt(),
			/* bootsfieldbase */ din.readInt(),
			/* bootstart */ din.readInt(),
			/* syscallsfp */ din.readInt(),
			/* syscallhandler */ din.readInt(),
			/* syscallpool */ din.readInt(),
			/* bootclassidba */ din.readInt(),
			/* bootclassidbaa */ din.readInt(),
			
			// Static and runtime pool
			/* staticpooloff */ din.readInt(),
			/* staticpoolsize */ din.readInt(),
			/* runtimepooloff */ din.readInt(),
			/* runtimepoolsize */ din.readInt());
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/Modifier.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

/**
 * Represents the action modifier that is available.
 *
 * @since 2019/04/30
 */
public enum Modifier
{
	/** No modification to be done. */
	NONE,
	
	/** Offset by RAM address. */
	RAM_OFFSET,
	
	/** Offset by JAR address. */
	JAR_OFFSET,
	
	/** End. */
	;
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/Operation.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jarfile;

/**
 * Represents a memory operation to do.
 *
 * @since 2019/04/30
 */
public final class Operation
{
	/** The value modifier. */
	public final Modifier mod;
	
	/** Operation size. */
	public final int size;
	
	/** The address. */
	public final int addr;
	
	/** The value. */
	public final Number value;
	
	/**
	 * Initializes the operation.
	 *
	 * @param __m The modifier.
	 * @param __s The operation size.
	 * @param __a The address.
	 * @param __v The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	public Operation(Modifier __m, byte __s, int __a, Number __v)
		throws NullPointerException
	{
		if (__m == null || __v == null)
			throw new NullPointerException("NARG");
		
		this.mod = __m;
		this.size = __s;
		this.addr = __a;
		this.value = __v;
	}
}

Added modules/tool-jarfile/src/main/java/dev/shadowtail/jarfile/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Utilties for minimization and compaction of JARs into single JAR formats.
 *
 * @since 2019/04/27
 */

package dev.shadowtail.jarfile;

Added modules/tool-jdwp/build.gradle.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This contains the implementation of the JDWP " +
	"which enables JDWP-complaint debuggers to connect with SquirrelJME to " +
	"enable its debugging."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BH"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Java Debug Wire Protocol"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:gcf")
}

Added modules/tool-jdwp/src/main/java/dev/shadowtail/jdwp/CommandPacket.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jdwp;

/**
 * This represents a command packet which tells the other end that something
 * has happened or something should be done.
 *
 * @since 2019/05/16
 */
public final class CommandPacket
	extends Packet
{
}

Added modules/tool-jdwp/src/main/java/dev/shadowtail/jdwp/Packet.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jdwp;

/**
 * This is the base class representing a packet.
 *
 * @since 2019/05/16
 */
public abstract class Packet
{
}

Added modules/tool-jdwp/src/main/java/dev/shadowtail/jdwp/ReplyPacket.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.jdwp;

/**
 * This is a packet which represents a reply to a command.
 *
 * @since 2019/05/16
 */
public final class ReplyPacket
	extends Packet
{
}

Added modules/tool-jdwp/src/main/java/dev/shadowtail/jdwp/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contians the JDWP implementation which allows for debugging
 * Java applications running on SquirrelJME.
 *
 * @since 2019/05/16
 */

package dev.shadowtail.jdwp;

Added modules/tool-manifest-reader/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This provides a decoder for standardJava " +
	"manifest files."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BB"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Manifest File Decoder"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:collections")
}

Added modules/tool-manifest-reader/src/main/java/net/multiphasicapps/tool/manifest/JavaManifest.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This contains decoders for the standard Java manifest format.
 *
 * This class is immutable.
 *
 * @since 2016/05/20
 */
public final class JavaManifest
	extends AbstractMap<String, JavaManifestAttributes>
{
	/** Read a key. */
	private static final int _STAGE_KEY =
		0;
	
	/** Read a value (start). */
	private static final int _STAGE_VALUE_START =
		1;
	
	/** Read a value (padding). */
	private static final int _STAGE_VALUE_PADDING =
		2;
	
	/** Read a value (length). */
	private static final int _STAGE_VALUE_LINE =
		3;
	
	/** Potentially may be a continuation of a line. */
	private static final int _STAGE_VALUE_MIGHT_CONTINUE =
		4;
	
	/** The attributes defined in this manifest file. */
	protected final Map<String, JavaManifestAttributes> attributes;
	
	/**
	 * Initializes a blank manifest.
	 *
	 * @since 2018/02/10
	 */
	public JavaManifest()
	{
		// Initialize a blank set of main attributes
		Map<String, JavaManifestAttributes> backing =
			new HashMap<>();
		backing.put("", new JavaManifestAttributes());
		
		// Lock in the backing map
		this.attributes = UnmodifiableMap.<String, JavaManifestAttributes>
			of(backing);
	}
	
	/**
	 * Decodes the manifest from the given input stream, it is treated as
	 * UTF-8 as per the JAR specification.
	 *
	 * @param __is The input stream for the manifest data.
	 * @throws IOException On read errors.
	 * @throws JavaManifestException If the manifest is malformed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/20
	 */
	public JavaManifest(InputStream __is)
		throws IOException, JavaManifestException, NullPointerException
	{
		this(new BufferedReader(new InputStreamReader(__is, "utf-8")));
	}
	
	/**
	 * Decodes the manifest from the given reader.
	 *
	 * @param __r The characters which make up the manifest.
	 * @throws IOException On read errors.
	 * @throws JavaManifestException If the manifest is malformed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public JavaManifest(Reader __r)
		throws IOException, JavaManifestException, NullPointerException
	{
		// Check
		if (__r == null)
			throw new NullPointerException("NARG");
			
		// The backing map and temporary key/value pairs for each
		// attiribute set
		String curname = "";
		Map<String, JavaManifestAttributes> backing = new HashMap<>();
		Map<JavaManifestKey, String> working = new HashMap<>();
		
		// Read input file line by line, since it is more efficient than
		// character by character
		StringBuilder vsb = new StringBuilder(128);
		BufferedReader br = new BufferedReader(__r);
		for (String pln = null;;)
		{
			// End of EOF
			String ln = (pln != null ? pln : br.readLine());
			pln = null;
			if (ln == null)
				break;
			
			// If the line is blank, it starts a new attribute block
			if (ln.isEmpty())
			{
				// Store the current working set
				if (working != null)
				{
					backing.put(curname, new JavaManifestAttributes(working));
					
					// It was stored in the map, so forget it
					curname = null;
					working = null;
				}
				
				// Skip blank line
				continue;
			}
			
			// This will be a name: value line, so find the colon on it
			// {@squirreljme.error BB01 Expected colon to appear on the
			// manifest line, to split a name/value pair.}
			int col = ln.indexOf(':');
			if (col < 0)
				throw new JavaManifestException("BB01");
			
			// Read key and value
			String key = ln.substring(0, col);
			
			// {@squirreljme.error BB02 Manifest key contains an invalid
			// character.}
			for (int i = 0, n = key.length(); i < n; i++)
				if (!JavaManifest.__isKeyChar(key.charAt(i)))
					throw new JavaManifestException(
						String.format("BB02 %s", key));
			
			// Need to skip the actual colon
			col++;
			
			// Skip spaces at the start of the value line
			int n = ln.length();
			while (col < n && ln.charAt(col) == ' ')
				col++;
			
			// Place value as it is now into a temporary buffer
			vsb.append(ln, col, n);
			
			// Read the next line to determine if it is a continuation
			for (;;)
			{
				// Stop at EOF
				pln = br.readLine();
				if (pln == null)
					break;
				
				// If this is a non-continuation line, it will be a blank
				// line or some other value, so redo the loop
				if (!pln.startsWith(" "))
					break;
				
				// Stop at the first non-space
				int nsp = 1;
				for (n = pln.length(); nsp < n; nsp++)
					if (pln.charAt(nsp) != ' ')
						break;
				
				// Append split into the buffer
				vsb.append(pln, nsp, n);
				
				// Clear the line, so it is not repeated
				pln = null;
			}
			
			// Build key and value
			JavaManifestKey ak = new JavaManifestKey(key);
			String av = vsb.toString();
			
			// Was this the start of a new section?
			if (curname == null)
			{
				// {@squirreljme.error BB03 New section must start with
				// {@code Name: value}. (The input section)}
				if (!"name".equals(ak.string))
					throw new JavaManifestException("BB03 " + ak);
				
				// The current name becomes the value
				curname = av;
				
				// Empty map to store values into
				working = new HashMap<>();
			}
			
			// Otherwise, add to the map
			else
				working.put(ak, av);
			
			// Clear the value
			vsb.setLength(0);
		}
		
		// Make sure the attribute is added to the set
		if (working != null)
			backing.put(curname, new JavaManifestAttributes(working));
		
		// Lock in the backing map
		this.attributes = UnmodifiableMap.<String, JavaManifestAttributes>
			of(backing);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return this.attributes.containsKey(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public Set<Map.Entry<String, JavaManifestAttributes>> entrySet()
	{
		return this.attributes.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public JavaManifestAttributes get(Object __k)
	{
		return this.attributes.get(__k);
	}
	
	/**
	 * Returns the mapping of main attributes.
	 *
	 * @return The main attribute mapping.
	 * @since 2016/05/29
	 */
	public JavaManifestAttributes getMainAttributes()
	{
		return this.attributes.get("");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public int size()
	{
		return this.attributes.size();
	}
	
	/**
	 * Returns {@code true} if the specified character is an alpha-numeric
	 * character.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if an alpha-numeric character.
	 * @since 2016/05/29
	 */
	private static boolean __isAlphaNum(char __c)
	{
		return (__c >= 'A' && __c <= 'Z') ||
			(__c >= 'a' && __c <= 'z') ||
			(__c >= '0' && __c <= '9');
	}
	
	/**
	 * Returns {@code true} if the character is part of a character which would
	 * be used for key values.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if a key character.
	 * @since 2016/05/29
	 */
	private static boolean __isKeyChar(char __c)
	{
		return JavaManifest.__isAlphaNum(__c) || __c == '_' || __c == '-';
	}
	
	/**
	 * Returns {@code true} if the character is specified to be a newline
	 * character.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if the character specifies the next line.
	 * @since 2016/05/29
	 */
	private static boolean __isNewline(char __c)
	{
		return __c == '\r' || __c == '\n';
	}
}

Added modules/tool-manifest-reader/src/main/java/net/multiphasicapps/tool/manifest/JavaManifestAttributes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.EmptyMap;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This contains the attributes for a single section within the manifest file.
 *
 * This class is immutable.
 *
 * @since 2016/05/20
 */
public final class JavaManifestAttributes
	extends AbstractMap<JavaManifestKey, String>
{
	/** The key value pairs. */
	protected final Map<JavaManifestKey, String> pairs;
	
	/**
	 * Initializes empty manifest attributes.
	 *
	 * @since 2018/02/10
	 */
	JavaManifestAttributes()
	{
		this.pairs = EmptyMap.<JavaManifestKey, String>empty();
	}
	
	/**
	 * Initializes the manifest attributes.
	 *
	 * @param __from The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/20
	 */
	JavaManifestAttributes(Map<JavaManifestKey, String> __from)
		throws NullPointerException
	{
		// Check
		if (__from == null)
			throw new NullPointerException("NARG");
		
		// Copy
		this.pairs = UnmodifiableMap.<JavaManifestKey, String>of(
			new HashMap<>(__from));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return this.pairs.containsKey(__o);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/11/26
	 */
	public boolean definesValue(JavaManifestKey __k)
	{
		return this.containsKey(__k);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/11/26
	 */
	public boolean definesValue(String __k)
	{
		return this.containsKey(__k == null ? null : new JavaManifestKey(__k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public Set<Map.Entry<JavaManifestKey, String>> entrySet()
	{
		return this.pairs.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public String get(Object __o)
	{
		return this.pairs.get(__o);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __k The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public String getValue(JavaManifestKey __k)
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this.get(__k);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __s The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/21
	 */
	public String getValue(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Find it
		return this.get(new JavaManifestKey(__s));
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(JavaManifestKey __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(String __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public int size()
	{
		return this.pairs.size();
	}
}

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

package net.multiphasicapps.tool.manifest;

/**
 * This is thrown when the manifest is not valid.
 *
 * @since 2016/06/15
 */
public class JavaManifestException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2016/06/15
	 */
	public JavaManifestException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2016/06/15
	 */
	public JavaManifestException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2016/06/15
	 */
	public JavaManifestException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2016/06/15
	 */
	public JavaManifestException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.tool.manifest;

/**
 * This represents a key which is used in a manifest, it is case insensitive
 * when it comes to ASCII values.
 *
 * @since 2016/05/29
 */
public final class JavaManifestKey
{
	/** The used string. */
	protected final String string;
	
	/** The actual input string. */
	protected final String inputstring;
	
	/**
	 * Initializes the manifest key using the given string.
	 *
	 * @param __s The string to use for the manifest key.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/29
	 */
	public JavaManifestKey(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Lower-case all letters
		StringBuilder sb = new StringBuilder();
		for (int i = 0, n = __s.length(); i < n; i++)
			sb.append(JavaManifestKey.__toLower(__s.charAt(i)));
		this.string = sb.toString();
		
		// Remember input string for case purposes
		this.inputstring = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Is another key?
		if (__o instanceof JavaManifestKey)
			return this.__equals(((JavaManifestKey)__o).string);
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Returns the input string which was passed to this key, this string
	 * cannot be used for comparative purposes and it intended to be used
	 * for case matching in the output manifest.
	 *
	 * @return The input string.
	 * @since 2017/11/26
	 */
	public String inputString()
	{
		return this.inputstring;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
	
	/**
	 * Compares two strings checking for case insensitivity in the basic
	 * ASCII range.
	 *
	 * @param __b The other string to compare against.
	 * @return {@code true} if the strings are equal.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/29
	 */
	private boolean __equals(String __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Cache
		String a = this.string;
		
		// Get their lengths
		int na = a.length(),
			nb = __b.length();
		
		// Would not be equal
		if (na != nb)
			return false;
		
		// Check characters
		for (int i = 0; i < na; i++)
			if (JavaManifestKey.__toLower(a.charAt(i)) != JavaManifestKey
				.__toLower(__b.charAt(i)))
				return false;
		
		// Matches
		return true;
	}
	
	/**
	 * Converts the specified character to lower case.
	 *
	 * @param __c The character to lower case.
	 * @return The lowercased character or {@code __c} if it cannot be
	 * lowercased.
	 * @since 2016/05/29
	 */
	private static char __toLower(char __c)
	{
		if (__c >= 'A' && __c <= 'Z')
			return (char)('a' + (__c - 'A'));
		return __c;
	}
}

Added modules/tool-manifest-reader/src/main/java/net/multiphasicapps/tool/manifest/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the manifest decoder.
 *
 * @since 2016/05/20
 */

package net.multiphasicapps.tool.manifest;

Added modules/tool-manifest-writer/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project allows for creating standard " +
	"Java manifest files using a mutable class."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "AB"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Mutable Java Manifest"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:tool-manifest-reader")
}

Added modules/tool-manifest-writer/src/main/java/net/multiphasicapps/tool/manifest/writer/MutableJavaManifest.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest.writer;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestException;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This is a mutable version of {@link JavaManifest}.
 *
 * This class is not thread safe.
 *
 * @since 2016/09/19
 */
public class MutableJavaManifest
	extends AbstractMap<String, MutableJavaManifestAttributes>
{
	/** The maximum number of columns a manifest may have. */
	private static final int _COLUMN_LIMIT =
		71;
	
	/** Main attributes. */
	protected final Map<String, MutableJavaManifestAttributes> attributes =
		new LinkedHashMap<>();
	
	/**
	 * This initializes a new empty manifest.
	 *
	 * @since 2016/09/19
	 */
	public MutableJavaManifest()
	{
		// Always add a main attribute
		this.attributes.put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Initializes the mutable manifest using a copy of the data from an
	 * immutable manifest.
	 *
	 * @param __man The immutable manifest.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/26
	 */
	public MutableJavaManifest(JavaManifest __man)
		throws NullPointerException
	{
		// Check
		if (__man == null)
			throw new NullPointerException("NARG");
		
		// Go through and add
		for (Map.Entry<String, JavaManifestAttributes> e :
			__man.entrySet())
		{
			// Create new attribute set
			MutableJavaManifestAttributes attr;
			this.put(e.getKey(), (attr = new MutableJavaManifestAttributes()));
			
			// Copy values
			for (Map.Entry<JavaManifestKey, String> f :
				e.getValue().entrySet())
				attr.put(f.getKey(), f.getValue());
		}
		
		// If no main attributes were set then make sure they exist
		if (!this.containsKey(""))
			this.put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Initializes the mutable manifest using a copy of the data from the
	 * given mutable manifest.
	 *
	 * @param __man The mutable manifest to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/26
	 */
	public MutableJavaManifest(MutableJavaManifest __man)
		throws NullPointerException
	{
		// Check
		if (__man == null)
			throw new NullPointerException("NARG");
		
		// Go through and add
		for (Map.Entry<String, MutableJavaManifestAttributes> e :
			__man.entrySet())
		{
			// Create new attribute set
			MutableJavaManifestAttributes attr;
			this.put(e.getKey(), (attr = new MutableJavaManifestAttributes()));
			
			// Copy values
			for (Map.Entry<JavaManifestKey, String> f :
				e.getValue().entrySet())
				attr.put(f.getKey(), f.getValue());
		}
		
		// If no main attributes were set then make sure they exist
		if (!this.containsKey(""))
			this.put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Builds the specified manifest.
	 *
	 * @return The built manifest.
	 * @throws RuntimeException If the manifest could not be built.
	 * @since 2017/11/17
	 */
	public final JavaManifest build()
		throws RuntimeException
	{
		try
		{
			byte[] bytes;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
			{
				// Write to output
				this.write(baos);
			
				// Extract array
				bytes = baos.toByteArray();
			}
		
			// Read in manifest
			try (InputStream is = new ByteArrayInputStream(bytes))
			{
				return new JavaManifest(is);
			}
		}
		
		// {@squirreljme.error AB01 Failed to build the immutable manifest
		// from the mutable one.}
		catch (IOException e)
		{
			throw new JavaManifestException("AB01", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final Set<Map.Entry<String, MutableJavaManifestAttributes>>
		entrySet()
	{
		return this.attributes.entrySet();
	}
	
	/**
	 * Returns the mapping of main attributes.
	 *
	 * @return The main attribute mapping.
	 * @since 2016/09/19
	 */
	public final MutableJavaManifestAttributes getMainAttributes()
	{
		return this.get("");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final MutableJavaManifestAttributes put(String __k,
		MutableJavaManifestAttributes __v)
		throws NullPointerException
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AB02 The specified value is of the wrong
		// class type.}
		if (!(__v instanceof MutableJavaManifestAttributes))
			throw new ClassCastException("AB02");
		
		// Put
		return this.attributes.put(__k, __v);
	}
	
	/**
	 * Writes the manifest data to the given output stream.
	 *
	 * @param __os The stream to get the manifest data written to.
	 * @return {@code __os}.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	public final OutputStream write(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		this.write(new OutputStreamWriter(__os, "utf-8"));
		
		return __os;
	}
	
	/**
	 * Writes the manifest data to the given output stream.
	 *
	 * @param __os The stream to get the manifest data written to.
	 * @return {@code __os}.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	public final Appendable write(Appendable __os)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Write main attribute first
		this.__write(__os, this.getMainAttributes());
		
		// Write other attributes
		for (Map.Entry<String, MutableJavaManifestAttributes> e :
			this.attributes.entrySet())
		{
			// Ignore the main attribute
			String k = e.getKey();
			if (k.equals(""))
				continue;
			
			// Sub-attributes are always spaced after the previous one
			__os.append("\r\n");
			
			// Write the name
			this.__write(__os, "Name", k);
			
			// Write values
			this.__write(__os, e.getValue());
		}
		
		// Java ME has no flushable so we only know two classes which are
		if (__os instanceof OutputStream)
			((OutputStream)__os).flush();
		else if (__os instanceof Writer)
			((Writer)__os).flush();
		
		return __os;
	}
	
	/**
	 * Writes attributes to the output.
	 *
	 * @param __w The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	private void __write(Appendable __w, MutableJavaManifestAttributes __a)
		throws IOException, NullPointerException
	{
		// Check
		if (__w == null || __a == null)
			throw new NullPointerException("NARG");
		
		// The attribute version is always first
		JavaManifestKey verk = new JavaManifestKey("MANIFEST-VERSION");
		String ver = __a.get(verk);
		if (ver != null)
			this.__write(__w, "MANIFEST-VERSION", ver);
		else
			this.__write(__w, "MANIFEST-VERSION", "1.0");
		
		// Write all value
		for (Map.Entry<JavaManifestKey, String> e : __a.entrySet())
		{
			// Do not write the version twice
			JavaManifestKey k = e.getKey();
			if (verk.equals(k))
				continue;
			
			// Write pair
			this.__write(__w, k.inputString(), e.getValue());
		}
	}
	
	/**
	 * Writes the given key and value to the output.
	 *
	 * @param __w The stream to write to.
	 * @param __k The key to write.
	 * @param __v The value to write.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	private void __write(Appendable __w, String __k, String __v)
		throws IOException, NullPointerException
	{
		// Check
		if (__w == null || __k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write pair
		int col = 0;
		for (int z = 0; z < 2; z++)
		{
			String s = (z == 0 ? __k : __v);
			
			// Print it
			int n = s.length();
			for (int i = 0; i < n; i++)
			{
				// Ignore out of range characters
				char c = s.charAt(i);
				if (c < ' ')
					continue;
				
				// Would be on a new line?
				int nextcol = col + 1;
				boolean newline = false;
				if (nextcol >= MutableJavaManifest._COLUMN_LIMIT)
				{
					// If the current character is a space then it will
					// be lost on the following line.
					if (c == ' ')
						__w.append(' ');
					__w.append("\r\n");
					newline = true;
					
					// Indent next line with space as long as this is not
					// the last character being written
					__w.append(' ');
					
					// Set next column
					nextcol = 1;
				}
				
				// Write the character, but if a space was written early then
				// do not write it
				if ((c == ' ' && !newline) || c != ' ')
					__w.append(c);
				
				// Set new column
				col = nextcol;
			}
			
			// Add spacer
			if (z == 0)
			{
				__w.append(": ");
				col += 2;
			}
		}
		
		// Write newline
		__w.append("\r\n");
	}
}

Added modules/tool-manifest-writer/src/main/java/net/multiphasicapps/tool/manifest/writer/MutableJavaManifestAttributes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest.writer;

import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This is a mutable set of attributes which exist within a manifest.
 *
 * @since 2016/09/19
 */
public class MutableJavaManifestAttributes
	extends AbstractMap<JavaManifestKey, String>
{
	/** The manifest values. */
	protected final Map<JavaManifestKey, String> values =
		new LinkedHashMap<>();
	
	/**
	 * Initializes empty manifest attributes.
	 *
	 * @since 2017/11/19
	 */
	public MutableJavaManifestAttributes()
	{
	}
	
	/**
	 * Initializes the attributes with a copy of the other attributes.
	 *
	 * @param __a The attributes to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/19
	 */
	public MutableJavaManifestAttributes(JavaManifestAttributes __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.values.putAll(__a);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/12/04
	 */
	public boolean definesValue(JavaManifestKey __k)
	{
		return this.containsKey(__k);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/12/04
	 */
	public boolean definesValue(String __k)
	{
		return this.containsKey(__k == null ? null : new JavaManifestKey(__k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final Set<Map.Entry<JavaManifestKey, String>> entrySet()
	{
		return this.values.entrySet();
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __k The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public String getValue(JavaManifestKey __k)
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this.get(__k);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __s The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/21
	 */
	public String getValue(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Find it
		return this.get(new JavaManifestKey(__s));
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(JavaManifestKey __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(String __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public String put(JavaManifestKey __k, String __v)
		throws NullPointerException
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Forward
		return this.values.put(__k, __v);
	}
	
	/**
	 * Places the specified key with the given value into the manifest.
	 *
	 * @param __k The key to use.
	 * @param __v The value for that key.
	 * @return The old value.
	 * @since 2016/12/27
	 */
	public String putValue(String __k, String __v)
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Forward
		return this.put(new JavaManifestKey(__k), __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/29
	 */
	@Override
	public String remove(Object __k)
	{
		return this.values.remove(__k);
	}
}

Added modules/tool-manifest-writer/src/main/java/net/multiphasicapps/tool/manifest/writer/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This packages contains the classes to provide mutable manifests which may
 * be generated.
 *
 * @since 2016/12/26
 */

package net.multiphasicapps.tool.manifest.writer;

Added modules/tool-packfile/build.gradle.
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "This project is used to build the packed ROM " +
	"files needed by SummerCoat and RatufaCoat to function."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BI"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "Compiled JAR Packfile Support"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:common-vm")
	implementation project(":modules:tool-classfile")
	implementation project(":modules:tool-jarfile")
	implementation project(":modules:io")
}

Added modules/tool-packfile/src/main/java/dev/shadowtail/packfile/MinimizedPackHeader.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.packfile;

/**
 * This represents the header for a minimized pack file, it mostly just
 * represents a number of JAR files which are combined into one.
 *
 * @since 2019/05/28
 */
public final class MinimizedPackHeader
{
	/** Magic number for the pack file. */
	public static final int MAGIC_NUMBER =
		0x58455223;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		52;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		56;
	
	/** The offset to the BootJAR offset (which has BootRAM), with magic. */
	public static final int OFFSET_OF_BOOTJAROFFSET =
		16;
	
	/** The offset to the BootJAR size, with magic. */
	public static final int OFFSET_OF_BOOTJARSIZE =
		20;
	
	/** Size of individual table of contents entry. */
	public static final int TOC_ENTRY_SIZE =
		20;
	
	/** The number of jars in this packfile. (4) */
	public final int numjars;
	
	/** The offset to the table of contents. (8) */
	public final int tocoffset;
	
	/** The index of the JAR which should be the boot point. (12) */
	public final int bootjarindex;
	
	/** The offset into the packfile where the boot entry is. (16) */
	public final int bootjaroffset;
	
	/** The size of the boot jar. (20) */
	public final int bootjarsize;
	
	/** Initial class path library indexes. (24) */
	public final int booticpoffset;
	
	/** Initial class path library index count. (28) */
	public final int booticpsize;
	
	/** Initial main class to boot. (32) */
	public final int bootmainclass;
	
	/** Initial main entry type. (36) */
	public final int bootmaintype;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the pack header.
	 *
	 * @param __fs Fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/28
	 */
	public MinimizedPackHeader(int... __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		int at = 0;
		
		// Jar and table of contents
		this.numjars = __fs[at++];
		this.tocoffset = __fs[at++];
		
		// Boot JAR that may be specified
		this.bootjarindex = __fs[at++];
		this.bootjaroffset = __fs[at++];
		this.bootjarsize = __fs[at++];
		this.booticpoffset = __fs[at++];
		this.booticpsize = __fs[at++];
		this.bootmainclass = __fs[at++];
		this.bootmaintype = __fs[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __fs[at++];
		this.staticpoolsize = __fs[at++];
		this.runtimepooloff = __fs[at++];
		this.runtimepoolsize = __fs[at++];
	}
}

Added modules/tool-packfile/src/main/java/dev/shadowtail/packfile/PackMinimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.packfile;

import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.classfile.mini.DualPoolEncodeResult;
import dev.shadowtail.classfile.mini.DualPoolEncoder;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.jarfile.JarMinimizer;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This class is used to pack multiple JAR files into a single packed ROM, so
 * that it is all contained within a single unit.
 *
 * @since 2019/05/29
 */
public class PackMinimizer
{
	/**
	 * Minimizes the class library.
	 *
	 * @param __boot The boot class used for the entry point.
	 * @param __initcp The initial classpath, if any.
	 * @param __mainbc Main boot class.
	 * @param __libs The libraries to minimize.
	 * @return The resulting minimized pack file.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final byte[] minimize(String __boot,
		String[] __initcp, String __mainbc, boolean __ismid,
		VMClassLibrary... __libs)
		throws IOException, NullPointerException
	{
		if (__libs == null)
			throw new NullPointerException("NARG");
		
		// Write into resulting array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Minimize
			PackMinimizer.minimize(baos, __boot, __initcp, __mainbc, __ismid,
				__libs);
			
			// Return result
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the class library.
	 *
	 * @param __os The stream to write the minimized file to.
	 * @param __boot The boot class used for the entry point.
	 * @param __initcp Initial classpath.
	 * @param __mainbc Main boot class.
	 * @param __ismid Is this a MIDlet?
	 * @param __libs The libraries to minimize.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final void minimize(OutputStream __os, String __boot,
		String[] __initcp, String __mainbc, boolean __ismid,
		VMClassLibrary... __libs)
		throws IOException, NullPointerException
	{
		if (__os == null || __libs == null ||
			(__boot != null && (__initcp == null || __mainbc == null)))
			throw new NullPointerException("NARG");
		
		// Defensive copy and check for nulls
		__initcp = (__initcp == null ? new String[0] : __initcp.clone());
		for (int i = 0, n = __initcp.length; i < n; i++)
		{
			String vx = __initcp[i];
			
			if (vx == null)
				throw new NullPointerException("NARG");
			
			// Append JAR always
			if (!vx.endsWith(".jar"))
				__initcp[i] = vx + ".jar";
		}
		
		// Make sure it ends in JAR
		if (!__boot.endsWith(".jar"))
			__boot = __boot + ".jar";
		
		// Write ROM sections
		TableSectionOutputStream out = new TableSectionOutputStream();
		
		// Number of libraries to process
		int numlibs = __libs.length;
		
		// Initialize classpath indexes
		int numinitcp = __initcp.length;
		int[] cpdx = new int[numinitcp];
		
		// Header and table of contents sections
		TableSectionOutputStream.Section header = out.addSection(
			MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC, 4);
		TableSectionOutputStream.Section toc = out.addSection(
			MinimizedPackHeader.TOC_ENTRY_SIZE * numlibs, 4);
		
		// Setup dual-pool where all combined values are stored as needed
		DualClassRuntimePoolBuilder dualpool =
			new DualClassRuntimePoolBuilder();
		
		// Section of the boot JAR
		int bootjarindex = -1;
		TableSectionOutputStream.Section bootjarsection = null;
		
		// Go through each library, minimize and write!
		for (int i = 0; i < numlibs; i++)
		{
			VMClassLibrary lib = __libs[i];
			String name = lib.name();
			
			// Normalize extension
			if (!name.endsWith(".jar"))
				name = name + ".jar";
			
			// Find library used in the initial classpath
			for (int j = 0; j < numinitcp; j++)
				if (name.equals(__initcp[j]))
				{
					cpdx[j] = i;
					break;
				}
			
			// Write name of JAR
			TableSectionOutputStream.Section jname = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			jname.writeUTF(name);
			
			// Output JAR data
			TableSectionOutputStream.Section jdata = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Is this a boot library?
			boolean isboot;
			if ((isboot = name.equals(__boot)))
			{
				bootjarindex = i;
				bootjarsection = jdata;
			}
			
			// Writing could fail however, so this makes it easier to find
			// the location of that failure
			MinimizedJarHeader mjh;
			try
			{
				// Used to get the header
				MinimizedJarHeader[] mjha = new MinimizedJarHeader[1];
				
				// The boot JAR is completely stand-alone, so do not use
				// a global JAR pool for it.
				JarMinimizer.minimize((isboot ? null : dualpool), isboot, lib,
					jdata, mjha);
				
				// Get the generated header
				mjh = mjha[0];
			}
			
			// {@squirreljme.error BI01 Could not minimize the JAR due to
			// an invalid class file. (The name)}
			catch (InvalidClassFormatException e)
			{
				throw new InvalidClassFormatException("BI01 " + name, e);
			}
			
			// Write TOC details
			toc.writeSectionAddressInt(jname);
			toc.writeSectionAddressInt(jdata);
			toc.writeSectionSizeInt(jdata);
			
			// Write manifest details if it is valid
			if (mjh.manifestlen > 0)
			{
				toc.writeSectionAddressInt(jdata, mjh.manifestoff);
				toc.writeInt(mjh.manifestlen);
			}
			else
			{
				toc.writeInt(0);
				toc.writeInt(0);
			}
		}
		
		// Write header details
		header.writeInt(MinimizedPackHeader.MAGIC_NUMBER);
		header.writeInt(numlibs);
		header.writeInt(MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC);
		
		// Optional BootJAR information
		header.writeInt(bootjarindex);
		if (bootjarsection != null)
		{
			header.writeSectionAddressInt(bootjarsection);
			header.writeSectionSizeInt(bootjarsection);
		}
		else
		{
			header.writeInt(0);
			header.writeInt(0);
		}
		
		// Write initial classpath
		TableSectionOutputStream.Section icp = out.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (int i = 0; i < numinitcp; i++)
			icp.writeInt(cpdx[i]);
		
		// More boot information
		header.writeSectionAddressInt(icp);
		header.writeInt(numinitcp);
		
		// Main entry point name
		if (__mainbc == null)
		{
			header.writeInt(0);
			header.writeInt(0);
		}
		else
		{
			TableSectionOutputStream.Section mcl = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Main class
			mcl.writeUTF(__mainbc.replace('.', '/'));
			header.writeSectionAddressInt(mcl);
			
			// Is this a MIDlet?
			header.writeInt((__ismid ? 1 : -1));
		}
		
		// Encode the constant pools
		TableSectionOutputStream.Section lpd = out.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		DualPoolEncodeResult der = DualPoolEncoder.encode(dualpool, lpd);
		
		// Static pool
		header.writeSectionAddressInt(lpd, der.staticpooloff);
		header.writeInt(der.staticpoolsize);
		
		// Run-time pool
		header.writeSectionAddressInt(lpd, der.runtimepooloff);
		header.writeInt(der.runtimepoolsize);
		
		// Finish off
		out.writeTo(__os);
	}
}

Added modules/tool-packfile/src/main/java/dev/shadowtail/packfile/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the utilities for creating pack files which are
 * needed by SummerCoat and RatufaCoat to function.
 *
 * @since 2019/05/28
 */

package dev.shadowtail.packfile;

Added modules/vodafone-api/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "Proprietary Vodafone API"
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "LA"
	swmType = JavaMEMidletType.API
	swmName = "Vodafone API"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc-compact")

	implementation project(":modules:meep-midlet")
	implementation project(":modules:midp-lcdui")
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/ActionTable.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

import java.io.IOException;

public class ActionTable
{
    public ActionTable(byte[] var1)
	{
		throw new todo.TODO();
	}

    public ActionTable(String var1) throws IOException
	{
		throw new todo.TODO();
	}

    public final  int getNumAction()
	{
		throw new todo.TODO();
	}

    public final  int getNumFrame(int var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/AffineTrans.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

@SuppressWarnings("FieldNamingConvention")
public class AffineTrans
{
    public int m00;
    public int m01;
    public int m02;
    public int m03;
    public int m10;
    public int m11;
    public int m12;
    public int m13;
    public int m20;
    public int m21;
    public int m22;
    public int m23;

    public AffineTrans()
	{
		throw new todo.TODO();
	}

    public AffineTrans(int[][] var1)
	{
		throw new todo.TODO();
	}

    public void set(int[][] var1)
	{
		throw new todo.TODO();
	}

    public Vector3D transPoint(Vector3D var1)
	{
		throw new todo.TODO();
	}

    public void multiply(AffineTrans var1)
	{
		throw new todo.TODO();
	}

    public void multiply(AffineTrans var1, AffineTrans var2)
	{
		throw new todo.TODO();
	}

    public void rotationX(int var1)
	{
		throw new todo.TODO();
	}

    public void rotationY(int var1)
	{
		throw new todo.TODO();
	}

    public void rotationZ(int var1)
	{
		throw new todo.TODO();
	}

    public void rotationV(Vector3D var1, int var2)
	{
		throw new todo.TODO();
	}

    public void setViewTrans(Vector3D var1, Vector3D var2, Vector3D var3)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Effect3D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public class Effect3D
{
    public static final int NORMAL_SHADING = 0;
    public static final int TOON_SHADING = 1;

    public Effect3D()
	{
		throw new todo.TODO();
	}

    public Effect3D(Light var1, int var2, boolean var3, Texture var4)
	{
		throw new todo.TODO();
	}

    public Light getLight()
	{
		throw new todo.TODO();
	}

    public void setLight(Light var1)
	{
		throw new todo.TODO();
	}

    public int getShading()
	{
		throw new todo.TODO();
	}

    public void setShading(int var1)
	{
		throw new todo.TODO();
	}

    public int getThreshold()
	{
		throw new todo.TODO();
	}

    public int getThresholdHigh()
	{
		throw new todo.TODO();
	}

    public int getThresholdLow()
	{
		throw new todo.TODO();
	}

    public void setThreshold(int var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public boolean isSemiTransparentEnabled()
	{
		throw new todo.TODO();
	}

    public void setSemiTransparentEnabled(boolean var1)
	{
		throw new todo.TODO();
	}

    public Texture getSphereMap()
	{
		throw new todo.TODO();
	}

    public void setSphereMap(Texture var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Figure.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

import java.io.IOException;

public class Figure
{
    public Figure(byte[] var1)
	{
		throw new todo.TODO();
	}

    public Figure(String var1)
    	throws IOException
	{
		throw new todo.TODO();
	}

    public void setPosture(ActionTable var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public void setTexture(Texture var1)
	{
		throw new todo.TODO();
	}
}


Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/FigureLayout.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public class FigureLayout
{
    public FigureLayout()
	{
		throw new todo.TODO();
	}

    public FigureLayout(AffineTrans var1, int var2, int var3, int var4,
    	int var5)
	{
		throw new todo.TODO();
	}

    public AffineTrans getAffineTrans()
	{
		throw new todo.TODO();
	}

    public void setAffineTrans(AffineTrans var1)
	{
		throw new todo.TODO();
	}

    public int getScaleX()
	{
		throw new todo.TODO();
	}

    public int getScaleY()
	{
		throw new todo.TODO();
	}

    public void setScale(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public int getCenterX()
	{
		throw new todo.TODO();
	}

    public int getCenterY()
	{
		throw new todo.TODO();
	}

    public void setCenter(int var1, int var2)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Graphics3D.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public interface Graphics3D
{
    void drawFigure(Figure var1, int var2, int var3, FigureLayout var4,
    	Effect3D var5);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Light.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public class Light
{
    public Light()
	{
		throw new todo.TODO();
	}

    public Light(Vector3D var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public int getDirIntensity()
	{
		throw new todo.TODO();
	}

    public void setDirIntensity(int var1)
	{
		throw new todo.TODO();
	}

    public int getAmbIntensity()
	{
		throw new todo.TODO();
	}

    public void setAmbIntensity(int var1)
	{
		throw new todo.TODO();
	}

    public Vector3D getDirection()
	{
		throw new todo.TODO();
	}

    public void setDirection(Vector3D var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Texture.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

import java.io.IOException;

public class Texture {
    public Texture(byte[] var1, boolean var2)
	{
		throw new todo.TODO();
	}

    public Texture(String var1, boolean var2)
    	throws IOException
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Util3D.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public class Util3D
{
    public static final  int sqrt(int var0)
	{
		throw new todo.TODO();
	}

    public static final  int sin(int var0)
	{
		throw new todo.TODO();
	}

    public static final  int cos(int var0)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/j3d/Vector3D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.j3d;

public class Vector3D
{
    public int x;
    public int y;
    public int z;

    public Vector3D()
	{
		throw new todo.TODO();
	}

    public Vector3D(int var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public int getX()
	{
		throw new todo.TODO();
	}

    public int getY()
	{
		throw new todo.TODO();
	}

    public int getZ()
	{
		throw new todo.TODO();
	}

    public void setX(int var1)
	{
		throw new todo.TODO();
	}

    public void setY(int var1)
	{
		throw new todo.TODO();
	}

    public void setZ(int var1)
	{
		throw new todo.TODO();
	}

    public void set(int var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public void unit()
	{
		throw new todo.TODO();
	}

    public int innerProduct(Vector3D var1)
	{
		throw new todo.TODO();
	}

    public void outerProduct(Vector3D var1)
	{
		throw new todo.TODO();
	}

    public static  int innerProduct(Vector3D var0, Vector3D var1)
	{
		throw new todo.TODO();
	}

    public static  Vector3D outerProduct(Vector3D var0, Vector3D var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/graphics/sprite/SpriteCanvas.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.graphics.sprite;

import javax.microedition.lcdui.Canvas;

public abstract class SpriteCanvas
	extends Canvas
{
    public SpriteCanvas(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void createFrameBuffer(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void disposeFrameBuffer()
	{
		throw new todo.TODO();
	}

    public static  int getVirtualWidth()
	{
		throw new todo.TODO();
	}

    public static  int getVirtualHeight()
	{
		throw new todo.TODO();
	}

    public void setPalette(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void setPattern(int var1, byte[] var2)
	{
		throw new todo.TODO();
	}

    public static  short createCharacterCommand(int var0, boolean var1, int var2, boolean var3, boolean var4, int var5)
	{
		throw new todo.TODO();
	}

    public void drawSpriteChar(short var1, short var2, short var3)
	{
		throw new todo.TODO();
	}

    public void drawBackground(short var1, short var2, short var3)
	{
		throw new todo.TODO();
	}

    public void copyArea(int var1, int var2, int var3, int var4, int var5, int var6)
	{
		throw new todo.TODO();
	}

    public void copyFullScreen(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void drawFrameBuffer(int var1, int var2)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/midlet/ResidentMIDlet.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.midlet;

import com.vodafone.v10.system.device.MailListener;
import com.vodafone.v10.system.device.RingStateListener;
import com.vodafone.v10.system.device.ScheduledAlarmListener;
import com.vodafone.v10.system.device.TelephonyListener;
import javax.microedition.midlet.MIDlet;

public abstract class ResidentMIDlet
	extends MIDlet
	implements TelephonyListener, MailListener, ScheduledAlarmListener,
		RingStateListener
{
    protected ResidentMIDlet()
	{
		throw new todo.TODO();
	}

    public abstract void ring();

    public abstract void hungup();

    public abstract void received(int var1);

    public abstract void notice(String var1);

    public abstract void ringStarted();

    public abstract void ringStopped();
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/sound/Sound.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.sound;

import java.io.IOException;

public class Sound
{
    public Sound(String var1)
    	throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}

    public Sound(byte[] var1)
	{
		throw new todo.TODO();
	}

    public int getSize()
	{
		throw new todo.TODO();
	}

    public int getUseTracks()
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/sound/SoundEventType.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.sound;

public interface SoundEventType
{
    int EV_END = -1;
    int EV_LOOP = -2;
    int EV_PAUSE = -3;
    int EV_USER_0 = 0;
    int EV_USER_1 = 1;
    int EV_USER_2 = 2;
    int EV_USER_3 = 3;
    int EV_USER_4 = 4;
    int EV_USER_5 = 5;
    int EV_USER_6 = 6;
    int EV_USER_7 = 7;
    int EV_USER_8 = 8;
    int EV_USER_9 = 9;
    int EV_USER_10 = 10;
    int EV_USER_11 = 11;
    int EV_USER_12 = 12;
    int EV_USER_13 = 13;
    int EV_USER_14 = 14;
    int EV_USER_15 = 15;
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/sound/SoundPlayer.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.sound;

public class SoundPlayer
{
    public static  SoundPlayer getPlayer()
	{
		throw new todo.TODO();
	}

    public SoundTrack getTrack()
	{
		throw new todo.TODO();
	}

    public SoundTrack getTrack(int var1)
	{
		throw new todo.TODO();
	}

    public int getTrackCount()
	{
		throw new todo.TODO();
	}

    public void disposePlayer()
	{
		throw new todo.TODO();
	}

    public void disposeTrack(SoundTrack var1)
	{
		throw new todo.TODO();
	}

    public void kill()
	{
		throw new todo.TODO();
	}

    public void pause()
	{
		throw new todo.TODO();
	}

    public void resume()
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/sound/SoundTrack.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.sound;

public class SoundTrack
{
    public static final int NO_DATA = 0;
    public static final int READY = 1;
    public static final int PLAYING = 2;
    public static final int PAUSED = 3;

    public void setSound(Sound var1)
	{
		throw new todo.TODO();
	}

    public Sound getSound()
	{
		throw new todo.TODO();
	}

    public void removeSound()
	{
		throw new todo.TODO();
	}

    public void play()
	{
		throw new todo.TODO();
	}

    public void play(int var1)
	{
		throw new todo.TODO();
	}

    public void stop()
	{
		throw new todo.TODO();
	}

    public void pause()
	{
		throw new todo.TODO();
	}

    public void resume()
	{
		throw new todo.TODO();
	}

    public void mute(boolean var1)
	{
		throw new todo.TODO();
	}

    public int getState()
	{
		throw new todo.TODO();
	}

    public void setVolume(int var1)
	{
		throw new todo.TODO();
	}

    public int getVolume()
	{
		throw new todo.TODO();
	}

    public void setPanpot(int var1)
	{
		throw new todo.TODO();
	}

    public int getPanpot()
	{
		throw new todo.TODO();
	}

    public void setSubjectTo(SoundTrack var1)
	{
		throw new todo.TODO();
	}

    public SoundTrack getSyncMaster()
	{
		throw new todo.TODO();
	}

    public int getID()
	{
		throw new todo.TODO();
	}

    public void setEventListener(SoundTrackListener var1)
	{
		throw new todo.TODO();
	}

    public boolean isMute()
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/sound/SoundTrackListener.java.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.sound;

public interface SoundTrackListener
{
    void eventOccurred(int var1);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/device/DeviceControl.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.device;

public class DeviceControl {
    public static final int BATTERY = 1;
    public static final int FIELD_INTENSITY = 2;
    public static final int KEY_STATE = 3;
    public static final int VIBRATION = 4;
    public static final int BACK_LIGHT = 5;
    public static final int EIGHT_DIRECTIONS = 6;

    public static final  DeviceControl getDefaultDeviceControl()
	{
		throw new todo.TODO();
	}

    public int getDeviceState(int var1)
	{
		throw new todo.TODO();
	}

    public boolean isDeviceActive(int var1)
	{
		throw new todo.TODO();
	}

    public boolean setDeviceActive(int var1, boolean var2)
	{
		throw new todo.TODO();
	}

    public void blink(int var1, int var2, int var3)
	{
		throw new todo.TODO();
	}

    public boolean setKeyRepeatState(int var1, boolean var2)
	{
		throw new todo.TODO();
	}

    public boolean getKeyRepeatState(int var1)
	{
		throw new todo.TODO();
	}

    public static  void setMailListener(MailListener var0)
	{
		throw new todo.TODO();
	}

    public static  void setScheduledAlarmListener(ScheduledAlarmListener var0)
	{
		throw new todo.TODO();
	}

    public static  void setTelephonyListener(TelephonyListener var0)
	{
		throw new todo.TODO();
	}

    public static  void setRingStateListener(RingStateListener var0)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/device/MailListener.java.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.device;

public interface MailListener
{
    int SMS = 1;
    int MMS = 2;
    int CBS = 3;
    int WEB = 4;

    void received(int var1);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/device/RingStateListener.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.device;

public interface RingStateListener
{
    void ringStarted();

    void ringStopped();
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/device/ScheduledAlarmListener.java.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.device;

public interface ScheduledAlarmListener
{
    void notice(String var1);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/device/TelephonyListener.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.device;

public interface TelephonyListener
{
    void ring();

    void hungup();
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/ImageResourceOperator.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

class ImageResourceOperator implements ResourceOperator {
    public int getResourceType()
	{
		throw new todo.TODO();
	}

    public int getResourceCount()
	{
		throw new todo.TODO();
	}

    public int getResourceID(int var1)
	{
		throw new todo.TODO();
	}

    public String getResourceName(int var1)
	{
		throw new todo.TODO();
	}

    public String[] getResourceNames()
	{
		throw new todo.TODO();
	}

    public void setResourceByID(MediaPlayer var1, int var2)
	{
		throw new todo.TODO();
	}

    public void setResourceByTitle(MediaPlayer var1, String var2)
	{
		throw new todo.TODO();
	}

    public void setResource(MediaPlayer var1, int var2)
	{
		throw new todo.TODO();
	}

    public int getIndexOfResource(int var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/MediaPlayer.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public class MediaPlayer extends Canvas {
    public static final int NO_DATA = 0;
    public static final int READY = 1;
    public static final int PLAYING = 2;
    public static final int PAUSED = 3;
    public static final int ERROR = 65536;

    public MediaPlayer(byte[] var1) {
    }

    public MediaPlayer(String var1) throws IOException {
    }

    public void setMediaData(byte[] var1)
	{
		throw new todo.TODO();
	}

    public void setMediaData(String var1) throws IOException
	{
		throw new todo.TODO();
	}

    public int getState()
	{
		throw new todo.TODO();
	}

    public int getMediaWidth()
	{
		throw new todo.TODO();
	}

    public int getMediaHeight()
	{
		throw new todo.TODO();
	}

    public int getWidth()
	{
		throw new todo.TODO();
	}

    public int getHeight()
	{
		throw new todo.TODO();
	}

    public void setContentPos(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void play()
	{
		throw new todo.TODO();
	}

    public void play(boolean var1)
	{
		throw new todo.TODO();
	}

    public void stop()
	{
		throw new todo.TODO();
	}

    public void pause()
	{
		throw new todo.TODO();
	}

    public void resume()
	{
		throw new todo.TODO();
	}

    public void setMediaPlayerListener(MediaPlayerListener var1)
	{
		throw new todo.TODO();
	}

    protected  void paint(Graphics var1)
	{
		throw new todo.TODO();
	}

    protected  void showNotify()
	{
		throw new todo.TODO();
	}

    protected  void hideNotify()
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/MediaPlayerListener.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

public interface MediaPlayerListener {
    int PLAYED = 0;
    int STOPPED = 1;
    int PAUSED = 2;

    void mediaStateChanged(int var1);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/MelodyResourceOperator.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

class MelodyResourceOperator
	implements ResourceOperator
{
    public int getResourceType()
	{
		throw new todo.TODO();
	}

    public int getResourceCount()
	{
		throw new todo.TODO();
	}

    public int getResourceID(int var1)
	{
		throw new todo.TODO();
	}

    public String getResourceName(int var1)
	{
		throw new todo.TODO();
	}

    public String[] getResourceNames()
	{
		throw new todo.TODO();
	}

    public void setResourceByID(MediaPlayer var1, int var2)
	{
		throw new todo.TODO();
	}

    public void setResourceByTitle(MediaPlayer var1, String var2)
	{
		throw new todo.TODO();
	}

    public void setResource(MediaPlayer var1, int var2)
	{
		throw new todo.TODO();
	}

    public int getIndexOfResource(int var1)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/ResourceOperator.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

public interface ResourceOperator
{
    int getResourceType();

    int getResourceCount();

    int getResourceID(int var1);

    String getResourceName(int var1);

    String[] getResourceNames();

    void setResourceByID(MediaPlayer var1, int var2);

    void setResourceByTitle(MediaPlayer var1, String var2);

    void setResource(MediaPlayer var1, int var2);

    int getIndexOfResource(int var1);
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/system/media/ResourceOperatorManager.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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.system.media;

public class ResourceOperatorManager
{
    public static final int MELODY_RESOURCE = 0;
    public static final int IMAGE_RESOURCE = 1;

    public ResourceOperatorManager()
	{
		throw new todo.TODO();
	}

    public static  ResourceOperator getResourceOperator(int var0)
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/util/FixedPoint.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.util;

public class FixedPoint
{
    public FixedPoint()
	{
		throw new todo.TODO();
	}

    public FixedPoint(int var1)
	{
		throw new todo.TODO();
	}

    public int getInteger()
	{
		throw new todo.TODO();
	}

    public int getDecimal()
	{
		throw new todo.TODO();
	}

    public void setValue(int var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint add(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint add(int var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint subtract(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint subtract(int var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint multiply(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint multiply(int var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint divide(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint divide(int var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint sin(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint cos(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint tan(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint asin(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint acos(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint atan(FixedPoint var1)
	{
		throw new todo.TODO();
	}

    public FixedPoint sqrt()
	{
		throw new todo.TODO();
	}

    public FixedPoint inverse()
	{
		throw new todo.TODO();
	}

    public FixedPoint pow()
	{
		throw new todo.TODO();
	}

    public boolean isInfinite()
	{
		throw new todo.TODO();
	}

    public FixedPoint clone()
	{
		throw new todo.TODO();
	}

    public static  FixedPoint getPI()
	{
		throw new todo.TODO();
	}

    public static  FixedPoint getMaximum()
	{
		throw new todo.TODO();
	}

    public static  FixedPoint getMinimum()
	{
		throw new todo.TODO();
	}
}

Added modules/vodafone-api/src/main/java/com/vodafone/v10/util/Vector2D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 com.vodafone.v10.util;

public class Vector2D
{
    public Vector2D(FixedPoint var1, FixedPoint var2)
	{
		throw new todo.TODO();
	}

    public Vector2D(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public Vector2D()
	{
		throw new todo.TODO();
	}

    public void add(Vector2D var1)
	{
		throw new todo.TODO();
	}

    public void add(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void subtract(Vector2D var1)
	{
		throw new todo.TODO();
	}

    public void subtract(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void normalize()
	{
		throw new todo.TODO();
	}

    public static  FixedPoint innerProduct(Vector2D var0, Vector2D var1)
	{
		throw new todo.TODO();
	}

    public static  FixedPoint outerProduct(Vector2D var0, Vector2D var1)
	{
		throw new todo.TODO();
	}

    public void setValue(int var1, int var2)
	{
		throw new todo.TODO();
	}

    public void setValue(FixedPoint var1, FixedPoint var2)
	{
		throw new todo.TODO();
	}

    public FixedPoint getX()
	{
		throw new todo.TODO();
	}

    public FixedPoint getY()
	{
		throw new todo.TODO();
	}

    public Vector2D clone()
	{
		throw new todo.TODO();
	}
}

Added modules/zip/build.gradle.





















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import cc.squirreljme.plugin.swm.JavaMEMidletType

description = "The library contains the support for ZIP " +
	"files and any data interfaces needed for ZIP files."
version = rootProject.version

squirreljme
{
	javaDocErrorCode = "BF"
	swmType = JavaMEMidletType.LIBRARY
	swmName = "ZIP Support"
	swmVendor = "Stephanie Gawroriski"
}

dependencies
{
	implementation project(":modules:cldc")

	implementation project(":modules:io")
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/IBM437CodePage.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This contains methods for converting from the IBM 437 codepage to the UTF-16
 * which Java uses.
 *
 * @since 2016/03/07
 */
public final class IBM437CodePage
{
	/**
	 * Not initializes.
	 *
	 * @since 2016/03/07
	 */
	private IBM437CodePage()
	{
	}
	
	/**
	 * Translates the given byte to a character.
	 *
	 * @param __b Byte to translate.
	 * @return The translated value.
	 * @since 2016/03/07
	 */
	public static char byteToChar(byte __b)
	{
		return IBM437CodePage.byteToChar(((int)__b) & 0xFF);
	}
	
	/**
	 * Translates the given integer to a character.
	 *
	 * @param __b Integer to translate.
	 * @return The translated value.
	 * @throws IllegalArgumentException If the input byte is not in the range
	 * of [0, 255].
	 * @since 2016/03/07
	 */
	public static char byteToChar(int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BF01 Byte index is not within bounds.
		// (The byte)}
		if (__b < 0 || __b > 255)
			throw new IllegalArgumentException(String.format("BF01 %d", __b));
		
		// Lower ASCII is the same
		if (__b <= 127)
			return (char)__b;
		
		// Otherwise specific translation is used
		switch (__b)
		{
			case 128: return (char)0x00C7;
			case 129: return (char)0x00FC;
			case 130: return (char)0x00E9;
			case 131: return (char)0x00E2;
			case 132: return (char)0x00E4;
			case 133: return (char)0x00E0;
			case 134: return (char)0x00E5;
			case 135: return (char)0x00E7;
			case 136: return (char)0x00EA;
			case 137: return (char)0x00EB;
			case 138: return (char)0x00E8;
			case 139: return (char)0x00EF;
			case 140: return (char)0x00EE;
			case 141: return (char)0x00EC;
			case 142: return (char)0x00C4;
			case 143: return (char)0x00C5;
			case 144: return (char)0x00C9;
			case 145: return (char)0x00E6;
			case 146: return (char)0x00C6;
			case 147: return (char)0x00F4;
			case 148: return (char)0x00F6;
			case 149: return (char)0x00F2;
			case 150: return (char)0x00FB;
			case 151: return (char)0x00F9;
			case 152: return (char)0x00FF;
			case 153: return (char)0x00D6;
			case 154: return (char)0x00DC;
			case 155: return (char)0x00A2;
			case 156: return (char)0x00A3;
			case 157: return (char)0x00A5;
			case 158: return (char)0x20A7;
			case 159: return (char)0x0192;
			case 160: return (char)0x00E1;
			case 161: return (char)0x00ED;
			case 162: return (char)0x00F3;
			case 163: return (char)0x00FA;
			case 164: return (char)0x00F1;
			case 165: return (char)0x00D1;
			case 166: return (char)0x00AA;
			case 167: return (char)0x00BA;
			case 168: return (char)0x00BF;
			case 169: return (char)0x2310;
			case 170: return (char)0x00AC;
			case 171: return (char)0x00BD;
			case 172: return (char)0x00BC;
			case 173: return (char)0x00A1;
			case 174: return (char)0x00AB;
			case 175: return (char)0x00BB;
			case 176: return (char)0x2591;
			case 177: return (char)0x2592;
			case 178: return (char)0x2593;
			case 179: return (char)0x2502;
			case 180: return (char)0x2524;
			case 181: return (char)0x2561;
			case 182: return (char)0x2562;
			case 183: return (char)0x2556;
			case 184: return (char)0x2555;
			case 185: return (char)0x2563;
			case 186: return (char)0x2551;
			case 187: return (char)0x2557;
			case 188: return (char)0x255D;
			case 189: return (char)0x255C;
			case 190: return (char)0x255B;
			case 191: return (char)0x2510;
			case 192: return (char)0x2514;
			case 193: return (char)0x2534;
			case 194: return (char)0x252C;
			case 195: return (char)0x251C;
			case 196: return (char)0x2500;
			case 197: return (char)0x253C;
			case 198: return (char)0x255E;
			case 199: return (char)0x255F;
			case 200: return (char)0x255A;
			case 201: return (char)0x2554;
			case 202: return (char)0x2569;
			case 203: return (char)0x2566;
			case 204: return (char)0x2560;
			case 205: return (char)0x2550;
			case 206: return (char)0x256C;
			case 207: return (char)0x2567;
			case 208: return (char)0x2568;
			case 209: return (char)0x2564;
			case 210: return (char)0x2565;
			case 211: return (char)0x2559;
			case 212: return (char)0x2558;
			case 213: return (char)0x2552;
			case 214: return (char)0x2553;
			case 215: return (char)0x256B;
			case 216: return (char)0x256A;
			case 217: return (char)0x2518;
			case 218: return (char)0x250C;
			case 219: return (char)0x2588;
			case 220: return (char)0x2584;
			case 221: return (char)0x258C;
			case 222: return (char)0x2590;
			case 223: return (char)0x2580;
			case 224: return (char)0x03B1;
			case 225: return (char)0x00DF;
			case 226: return (char)0x0393;
			case 227: return (char)0x03C0;
			case 228: return (char)0x03A3;
			case 229: return (char)0x03C3;
			case 230: return (char)0x00B5;
			case 231: return (char)0x03C4;
			case 232: return (char)0x03A6;
			case 233: return (char)0x0398;
			case 234: return (char)0x03A9;
			case 235: return (char)0x03B4;
			case 236: return (char)0x221E;
			case 237: return (char)0x03C6;
			case 238: return (char)0x03B5;
			case 239: return (char)0x2229;
			case 240: return (char)0x2261;
			case 241: return (char)0x00B1;
			case 242: return (char)0x2265;
			case 243: return (char)0x2264;
			case 244: return (char)0x2320;
			case 245: return (char)0x2321;
			case 246: return (char)0x00F7;
			case 247: return (char)0x2248;
			case 248: return (char)0x00B0;
			case 249: return (char)0x2219;
			case 250: return (char)0x00B7;
			case 251: return (char)0x221A;
			case 252: return (char)0x207F;
			case 253: return (char)0x00B2;
			case 254: return (char)0x25A0;
			case 255: return (char)0x00A0;
			
				// Should not occur but in case it does
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Converts the input byte array to a string.
	 *
	 * @param __arr Input byte array containing IBM 437 characters.
	 * @param __off Offset from the start of the buffer to read from.
	 * @param __len The number of bytes to read.
	 * @throws IllegalArgumentException If the offset or length are negative,
	 * or the offset and the length exceeds the array size.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/07
	 */
	public static String toString(byte[] __arr, int __off, int __len)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__arr == null)
			throw new NullPointerException("NARG");
		if (__off < 0 || __len < 0 || (__off + __len) < 0 ||
			(__off + __len) > __arr.length)
			throw new IllegalArgumentException("BAOB");
		
		// Result is of the same size
		char[] rv = new char[__len];
		
		// Go through it
		for (int i = 0; i < __len; i++)
			rv[i] = IBM437CodePage.byteToChar(__arr[__off + i]);
		
		// Build it
		return new String(rv);
	}
}

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

package net.multiphasicapps.zip;

/**
 * This is used to describe the compatibility that attributes within the ZIP
 * file are compatible with.
 *
 * @since 2016/08/07
 */
public enum ZipAttributeCompatibility
{
	/** DOS. */
	DOS(0),
	
	/** Amiga. */
	AMIGA(1),
	
	/** OpenVMS. */
	OPENVMS(2),
	
	/** UNIX. */
	UNIX(3),
	
	/** VM/CMS. */
	VM_CMS(4),
	
	/** Atari ST. */
	ATARI_ST(5),
	
	/** OS/2. */
	OS_2(6),
	
	/** Mac OS (Classic). */
	MACOS(7),
	
	/** Z-System. */
	Z_SYSTEM(8),
	
	/** CP/M. */
	CP_M(9),
	
	/** NTFS. */
	NTFS(10),
	
	/** MVS. */
	MVS(11),
	
	/** VSE. */
	VSE(12),
	
	/** Acorn RISC. */
	ACORN_RISC(13),
	
	/** VFAT. */
	VFAT(14),
	
	/** MVS (alternate). */
	MVS_ALTERNATIVE(15),
	
	/** BeOS. */
	BEOS(16),
	
	/** Tandem. */
	TANDEM(17),
	
	/** OS/400. */
	OS_400(18),
	
	/** Mac OS X. */
	MACOSX(19),
	
	/** End. */
	;
	
	/** The compatibility identifier. */
	private int id;
	
	/**
	 * Initializes the base compatibility information.
	 *
	 * @param __id The identifier used.
	 * @since 2016/08/07
	 */
	ZipAttributeCompatibility(int __id)
	{
		this.id = __id;
	}
	
	/**
	 * Returns the version identifier.
	 *
	 * @return The version identifier.
	 * @since 2016/08/07
	 */
	public final int identifier()
	{
		return this.id;
	}
}

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

package net.multiphasicapps.zip;

/**
 * This class constants constants which are used to initialize the CRC
 * algorithm parameters.
 *
 * @since 2016/07/19
 */
public interface ZipCRCConstants
{
	/** The polynomial for the CRC algorithm. */
	int CRC_POLYNOMIAL =
		0x04C11DB7;
	
	/** The initial CRC remainder. */
	int CRC_REMAINDER =
		0xFFFFFFFF;
	
	/** The final XOR value. */
	int CRC_FINALXOR =
		0xFFFFFFFF;
	
	/** Reflect the data? */
	boolean CRC_REFLECT_DATA =
		true;
	
	/** Reflect the remainder? */
	boolean CRC_REFLECT_REMAINDER =
		true;
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/ZipCompressionType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import net.multiphasicapps.io.Checksum;
import net.multiphasicapps.io.ChecksumInputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.DecompressionInputStream;
import net.multiphasicapps.io.DeflaterOutputStream;
import net.multiphasicapps.io.InflaterInputStream;

/**
 * This represents the type of compression that is used in a ZIP file.
 *
 * @since 2016/07/15
 */
public enum ZipCompressionType
{
	/** Data is not compressed. */
	NO_COMPRESSION(10, 0),
	
	/** Deflate algorithm. */
	DEFLATE(20, 8),
	
	/** End. */
	;
	
	/** The default compression algorithm to use. */
	public static final ZipCompressionType DEFAULT_COMPRESSION =
		ZipCompressionType.DEFLATE;
	
	/** The version needed to extract. */
	protected final int extractversion;
	
	/** The compression method. */
	protected final int method;
	
	/**
	 * Initializes the enumeration.
	 *
	 * @param __xv The version needed to extract.
	 * @param __m The compression method identifier.
	 * @since 2016/07/15
	 */
	ZipCompressionType(int __xv, int __m)
	{
		this.extractversion = __xv;
		this.method = __m;
	}
	
	/**
	 * Returns the version which is needed to extract this data.
	 *
	 * @return The required version.
	 * @since 2016/07/15
	 */
	public final int extractVersion()
	{
		return this.extractversion;
	}
	
	/**
	 * Creates an input stream which wraps another for input which is used
	 * to read the associated data.
	 *
	 * @param __is The input stream to read from.
	 * @return An input stream for reading the data for this given
	 * compression method.
	 * @throws IOException If the stream could not be initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public final DecompressionInputStream inputStream(InputStream __is)
		throws IOException, NullPointerException
	{
		return this.inputStream(__is, null);
	}
	
	/**
	 * Creates an input stream which wraps another for input which is used
	 * to read the associated data.
	 *
	 * @param __is The input stream to read from.
	 * @param __cs An optional target checksum where the CRC for uncompressed
	 * data is stored.
	 * @return An input stream for reading the data for this given
	 * compression method.
	 * @throws IOException If the stream could not be initialized.
	 * @throws NullPointerException If no input stream was specified.
	 * @since 2016/08/22
	 */
	public final DecompressionInputStream inputStream(InputStream __is,
		Checksum __cs)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Depends on the compression
		switch (this)
		{
				// Just use the same stream
			case NO_COMPRESSION:
				return new __NoDecompressionInputStream__((__cs != null ?
					new ChecksumInputStream(__cs, __is) : __is));
			
				// Inflate
			case DEFLATE:
				return new InflaterInputStream(__is, __cs);
				
				// {@squirreljme.error BF02 Decompressing using the given
				// method is not supported. (The current compression method)}
			default:
				throw new IOException(String.format("BF02 %s", this));
		}
	}
	
	/**
	 * Returns the compression method.
	 *
	 * @return The compression method.
	 * @since 2016/07/15
	 */
	public final int method()
	{
		return this.method;
	}
	
	/**
	 * Creates an output stream which wraps another for output which is used
	 * to write the associated data. The default compression level is used.
	 *
	 * @param __os The output stream to write into.
	 * @return An output stream for writing the data for this given compression
	 * method.
	 * @throws IOException If the stream could not be created.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public final OutputStream outputStream(OutputStream __os)
		throws IOException, NullPointerException
	{
		return this.outputStream(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Creates an output stream which wraps another for output which is used
	 * to write the associated data.
	 *
	 * @param __os The output stream to write into.
	 * @param __cl The compression level to use.
	 * @return An output stream for writing the data for this given compression
	 * method.
	 * @throws IOException If the stream could not be created.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public final OutputStream outputStream(OutputStream __os,
		CompressionLevel __cl)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Depends on the compression
		switch (this)
		{
				// No compression, use the same stream
			case NO_COMPRESSION:
				return __os;
				
				// Inflate
			case DEFLATE:
				return new DeflaterOutputStream(__os, __cl);
			
				// {@squirreljme.error BF03 Compressing using the given
				// compression algorithm is not supported. (The compression
				// algorithm)}
			default:
				throw new IOException(String.format("BF03 %s", this));
		}
	}
	
	/**
	 * Returns the compression method identified by the given value.
	 *
	 * @param __m The compression method identifier.
	 * @return The compression type identifier for this method, or {@code null}
	 * if it is unknown.
	 * @since 2016/07/19
	 */
	public static ZipCompressionType forMethod(int __m)
	{
		switch (__m)
		{
			case 0: return ZipCompressionType.NO_COMPRESSION;
			case 8: return ZipCompressionType.DEFLATE;
			
				// Unknown
			default:
				return null;
		}
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/ZipEntryAttribute.java.























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This interface is used to represent an attribute which may be associated
 * with a ZIP entry (such as the creator and/or executable bit).
 *
 * @since 2016/08/07
 */
public interface ZipEntryAttribute
{
}

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

package net.multiphasicapps.zip;

import java.io.IOException;

/**
 * This is thrown when there is a problem with a ZIP file.
 *
 * @since 2016/08/02
 */
public class ZipException
	extends IOException
{
	/**
	 * Initializes exception with no message.
	 *
	 * @since 2016/08/02
	 */
	public ZipException()
	{
	}
	
	/**
	 * Initializes exception with the given message.
	 *
	 * @param __msg The exception message.
	 * @since 2016/08/02
	 */
	public ZipException(String __msg)
	{
		super(__msg);
	}
	
	/**
	 * Initializes exception with the given message and cause.
	 *
	 * @param __msg The exception message.
	 * @param __c The cause.
	 * @since 2016/08/02
	 */
	public ZipException(String __msg, Throwable __c)
	{
		super(__msg, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipException(Throwable __c)
	{
		super(__c);
	}
}

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

package net.multiphasicapps.zip;

/**
 * This represents UNIX access modes which may be declared in the ZIP.
 *
 * @since 2016/08/07
 */
public enum ZipUnixAccessMode
	implements ZipEntryAttribute
{
	/** User read. */
	USER_READ,
	
	/** User write. */
	USER_WRITE,
	
	/** User execute. */
	USER_EXECUTE,
	
	/** Group read. */
	GROUP_READ,
	
	/** Group write. */
	GROUP_WRITE,
	
	/** Group execute. */
	GROUP_EXECUTE,
	
	/** Other read. */
	OTHER_READ,
	
	/** Other write. */
	OTHER_WRITE,
	
	/** Other execute. */
	OTHER_EXECUTE,
	
	/** End. */
	;
}

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

package net.multiphasicapps.zip;

import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.io.DecompressionInputStream;

/**
 * This is an input stream which offers no compression but keeps count of
 * the read bytes.
 *
 * @since 2017/08/22
 */
class __NoDecompressionInputStream__
	extends DecompressionInputStream
{
	/** The stream to wrap. */
	protected final InputStream wrap;
	
	/** The number of read bytes. */
	private volatile long _count;
	
	/**
	 * Initializes the wrapping stream.
	 *
	 * @param __w The stream to read bytes from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/22
	 */
	__NoDecompressionInputStream__(InputStream __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.wrap = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.wrap.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		return this._count;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.wrap.read();
		if (rv >= 0)
			this._count++;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		int rc = this.wrap.read(__b);
		if (rc > 0)
			this._count += rc;
		
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		int rc = this.wrap.read(__b, __o, __l);
		if (rc > 0)
			this._count += rc;
		
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._count;
	}
}

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

package net.multiphasicapps.zip.blockreader;

import java.io.EOFException;
import java.io.IOException;

/**
 * This wraps an array and provides it to the block accessor interface so that
 * ZIP files may be read from arrays.
 *
 * @since 2016/12/27
 */
public class ArrayBlockAccessor
	implements BlockAccessor
{
	/** The internal buffer. */
	protected final byte[] buffer;
	
	/** The offset into the buffer. */
	protected final int offset;
	
	/** The number of bytes available. */
	protected final int length;
	
	/**
	 * Initializes the block accessor which uses the entire array.
	 *
	 * @param __b The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ArrayBlockAccessor(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length);
	}
	
	/**
	 * Initializes the block accessor which uses the entire array.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to make available.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ArrayBlockAccessor(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// Set
		this.buffer = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error BF04 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF04");
		
		// {@squirreljme.error BF05 Read past end of the block.}
		if (__addr > this.length)
			throw new EOFException("BF05");
		
		// Get
		return this.buffer[this.offset + (int)__addr];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error BF06 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF06");
		
		// After the end?
		int length = this.length;
		if (__addr >= length)
			return -1;
		
		// Number of bytes to actually read
		int addr = (int)__addr;
		int actual = Math.min(__l, length - addr);
		
		// Read bytes
		byte[] buffer = this.buffer;
		int offset = this.offset;
		for (int i = 0, s = offset + addr, d = __o; i < actual; i++, s++, d++)
			__b[d] = buffer[s];
		
		// Return the actual number of bytes read
		return actual;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
	{
		return this.length;
	}
}

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

package net.multiphasicapps.zip.blockreader;

import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;

/**
 * This interface is used to access the data in the ZIP file.
 *
 * @since 2016/12/27
 */
public interface BlockAccessor
	extends Closeable
{
	/**
	 * Reads a single byte.
	 *
	 * @param __addr The address to read from.
	 * @return The read byte.
	 * @throws EOFException If the read is past the end of file.
	 * @throws IOException On read/write errors.
	 * @since 2016/12/29
	 */
	byte read(long __addr)
		throws EOFException, IOException;
	
	/**
	 * Reads data from the block and writes to the destination array.
	 *
	 * @param __addr The address to start reading from.
	 * @param __b The destination array to write values to.
	 * @param __o The offset into the array.
	 * @param __l The maximum number of bytes to read.
	 * @return The number of bytes read or a negative value if the address
	 * exceeds the bounds of the block.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceeds the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException;
	
	/**
	 * Returns the number of bytes which are available for reading.
	 *
	 * @return The number of bytes in the block.
	 * @throws IOException If it could not be determined.
	 * @since 2016/12/27
	 */
	long size()
		throws IOException;
}

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

package net.multiphasicapps.zip.blockreader;

import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

/**
 * This wraps a file channel and provides block level access to it.
 *
 * @since 2016/12/27
 */
public class FileChannelBlockAccessor
	implements BlockAccessor
{
	/** The file channel to wrap. */
	protected final FileChannel channel;
	
	/**
	 * Initializes the block accessor for the given path.
	 *
	 * @param __p The path to open.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public FileChannelBlockAccessor(Path __p)
		throws IOException, NullPointerException
	{
		this(FileChannel.open(__p, StandardOpenOption.READ));
	}
	
	/**
	 * Initializes the block accessor for the file channel.
	 *
	 * @param __fc The channel to access data from.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public FileChannelBlockAccessor(FileChannel __fc)
		throws IOException, NullPointerException
	{
		// Check
		if (__fc == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.channel = __fc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.channel.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error BF07 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF07");
		
		// Just forward to the array variant
		byte[] val = new byte[1];
		int rv = this.read(__addr, val, 0, 1);
		
		// {@squirreljme.error BF08 Read past end of file.}
		if (rv < 0)
			throw new EOFException("BF08");
		
		return val[0];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error BF09 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF09");
		
		// Read until every byte has been read so that partial reads are not
		// returned
		ByteBuffer buf = ByteBuffer.wrap(__b, __o, __l);
		FileChannel channel = this.channel;
		int n;
		while (buf.hasRemaining())
			if (channel.read(buf, __addr + buf.position()) < 0)
				if ((n = buf.position()) <= 0)
					return -1;
				else
					return n;
		
		// Use the read position
		return buf.position();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
		throws IOException
	{
		return this.channel.size();
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/blockreader/ZipBlockEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.zip.IBM437CodePage;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipException;

/**
 * This represents a single entry within a ZIP file which may be opened.
 *
 * @since 2016/12/30
 */
public final class ZipBlockEntry
{
	/** Maximum version. */
	private static final int _MAX_CENTRAL_DIR_VERSION =
		20;
	
	/** The version which made the ZIP */
	private static final int _CENTRAL_DIRECTORY_MADE_BY_VERSION_OFFSET =
		4;
	
	/** The offset to the version needed to extract. */
	private static final int _CENTRAL_DIRECTORY_EXTRACT_VERSION_OFFSET =
		6;
	
	/** The offset of the general purpose flags. */
	private static final int _CENTRAL_DIRECTORY_FLAG_OFFSET =
		8;
	
	/** The offset to the method of compression. */
	private static final int _CENTRAL_DIRECTORY_METHOD_OFFSET =
		10;
	
	/** The offset to the CRC for data integrity. */
	private static final int _CENTRAL_DIRECTORY_CRC_OFFSET =
		16;
	
	/** The offset to the compressed size. */
	private static final int _CENTRAL_DIRECTORY_COMPRESSED_OFFSET =
		20;
	
	/** The offset to the uncompressed size. */
	private static final int _CENTRAL_DIRECTORY_UNCOMPRESSED_OFFSET =
		24;
	
	/** The offset to the file name length. */
	private static final int _CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET =
		28;
	
	/** The offset to the extra data length. */
	private static final int _CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET =
		ZipBlockEntry._CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET + 2;
	
	/** The offset to the comment length. */
	private static final int _CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET =
		ZipBlockEntry._CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET + 2;
	
	/** The relative offset to the local header. */
	private static final int _CENTRAL_DIRECTORY_LOCAL_HEADER_OFFSET =
		42;
	
	/** The minimum length of the central directory entry. */
	private static final int _CENTRAL_DIRECTORY_MIN_LENGTH =
		46;
	
	/** The local file header magic number. */
	private static final int _LOCAL_HEADER_MAGIC_NUMBER =
		0x04034B50;
	
	/** The offset to the file name length in the local header. */
	private static final int _LOCAL_HEADER_NAME_LENGTH_OFFSET =
		26;
	
	/** The offset to the comment length in the local header. */
	private static final int _LOCAL_HEADER_COMMENT_LENGTH_OFFSET =
		28;
	
	/** The local header minimum size. */
	private static final int _LOCAL_HEADER_MIN_LENGTH =
		30;
	
	/** General purpose flag: Is UTF-8 encoded filename/comment? */
	protected static final int GPF_ENCODING_UTF8 =
		(1 << 11);
	
	/** The owning reader. */
	protected final ZipBlockReader owner;
	
	/** The data accessor. */
	protected final BlockAccessor accessor;
	
	/** The position of this entry. */
	protected final long position;
	
	/** The name of this file. */
	private Reference<String> _name;
	
	/**
	 * Initializes the block entry.
	 *
	 * @param __br The owning block reader.
	 * @param __id The entry ID.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/30
	 */
	ZipBlockEntry(ZipBlockReader __br, int __id)
		throws NullPointerException
	{
		// Check
		if (__br == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.owner = __br;
		this.accessor = __br._accessor;
		
		// Get position
		this.position = __br._offsets[__id];
	}
	
	/**
	 * Returns {@code true} if the entry pertains to a directory.
	 *
	 * @return If it is a directory or not.
	 * @throws IOException On read errors.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2017/01/03
	 */
	public boolean isDirectory()
		throws IOException, ZipException
	{
		return this.__internalToString().endsWith("/");
	}
	
	/**
	 * Returns the time this entry was last modified.
	 *
	 * @return The last modified time or {@code Long.MIN_VALUE} if it is not
	 * valid.
	 * @since 2018/03/06
	 */
	public long lastModifiedTime()
	{
		return Long.MIN_VALUE;
	}
	
	/**
	 * Returns the name of this entry.
	 *
	 * @return The entry name.
	 * @since 2017/03/01
	 */
	public String name()
	{
		return this.toString();
	}
	
	/**
	 * Opens the input stream for this entry's data.
	 *
	 * @return The entry data.
	 * @throws IOException On read errors.
	 * @throws ZipException If it could not be opened.
	 * @since 2016/12/30
	 */
	public InputStream open()
		throws IOException, ZipException
	{
		// {@squirreljme.error BF0a Cannot open the entry because it is a
		// directory. (The name of the entry)}
		String s;
		if (this.isDirectory())
			throw new ZipException(String.format("BF0a %s", this.toString()));
		
		ZipBlockReader owner = this.owner;
		BlockAccessor accessor = this.accessor;
		long position = this.position;
		
		// {@squirreljme.error BF0b Could not read the central
		// directory data.}
		byte[] data = new byte[ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH];
		if (ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH != accessor.read(position,
			data, 0, ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH))
			throw new ZipException("BF0b");
		
		// The version needed to extract should not have the upper byte set
		// but some archive writing software sets the upper byte to match the
		// OS with the version in the made by bit.
		int ver = __ArrayData__.readUnsignedShort(
			ZipBlockEntry._CENTRAL_DIRECTORY_EXTRACT_VERSION_OFFSET, data),
			made = __ArrayData__.readUnsignedShort(
				ZipBlockEntry._CENTRAL_DIRECTORY_MADE_BY_VERSION_OFFSET, data);
		if ((ver & 0xFF00) != 0 && (made & 0xFF00) == (ver & 0xFF00))
			ver &= 0xFF;
		
		// {@squirreljme.error BF0c Cannot open the entry because it uses
		// too new of a version. (The version number)}
		if (ZipBlockEntry._MAX_CENTRAL_DIR_VERSION < ver)
			throw new ZipException(String.format("BF0c %d", ver));
		
		// Need these later to determine how much data is available and how it
		// is stored.
		int method = __ArrayData__.readUnsignedShort(
			ZipBlockEntry._CENTRAL_DIRECTORY_METHOD_OFFSET, data);
		int crc = __ArrayData__.readSignedInt(
			ZipBlockEntry._CENTRAL_DIRECTORY_CRC_OFFSET,
			data);
		long uncompressed = __ArrayData__.readUnsignedInt(
			ZipBlockEntry._CENTRAL_DIRECTORY_UNCOMPRESSED_OFFSET, data),
			compressed = __ArrayData__.readUnsignedInt(
				ZipBlockEntry._CENTRAL_DIRECTORY_COMPRESSED_OFFSET, data);
			
		// Determine the offset to the local header which precedes the data
		// of the entry
		long lhoffset = owner._zipbaseaddr + __ArrayData__.readUnsignedInt(
			ZipBlockEntry._CENTRAL_DIRECTORY_LOCAL_HEADER_OFFSET, data);
		
		// {@squirreljme.error BF0d Could not read the local file header from
		// the ZIP file.}
		byte[] header = new byte[ZipBlockEntry._LOCAL_HEADER_MIN_LENGTH];
		if (ZipBlockEntry._LOCAL_HEADER_MIN_LENGTH != accessor.read(lhoffset, header, 0,
			ZipBlockEntry._LOCAL_HEADER_MIN_LENGTH))
			throw new ZipException("BF0d");
		
		// {@squirreljme.error BF0e The magic number for the local file header
		// is not valid.}
		if (__ArrayData__.readSignedInt(0, header) != ZipBlockEntry._LOCAL_HEADER_MAGIC_NUMBER)
			throw new ZipException("BF0e");
		
		// Need to know the file name and comment lengths, since they may
		// differ in the local header for some reason
		int lhfnl = __ArrayData__.readUnsignedShort(
			ZipBlockEntry._LOCAL_HEADER_NAME_LENGTH_OFFSET, header),
			lhcml = __ArrayData__.readUnsignedShort(
				ZipBlockEntry._LOCAL_HEADER_COMMENT_LENGTH_OFFSET, header);
		
		// The base address of the data is after the local header position
		long database = lhoffset + ZipBlockEntry._LOCAL_HEADER_MIN_LENGTH + lhfnl + lhcml;
		
		// Get base stream before compression
		InputStream base = new __BlockAccessorRegionInputStream__(accessor,
			database, compressed);
		
		// {@squirreljme.error BF0f Unknown compression method for entry. (The
		// method identifier)}
		ZipCompressionType ztype = ZipCompressionType.forMethod(method);
		if (ztype == null)
			throw new ZipException(String.format("BF0f %d", method));
		
		// Wrap input so it may be read
		InputStream algo = ztype.inputStream(base);
		
		// Need to calculate the CRC for the stream of data
		return new __CRCInputStream__(algo, crc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/30
	 */
	@Override
	public String toString()
	{
		try
		{
			return this.__internalToString();
		}
			
		// {@squirreljme.error BF0g Could not read the name of the
		// entry.}
		catch (IOException e)
		{
			throw new RuntimeException("BF0g", e);
		}
	}
	
	/**
	 * Returns the internal representation of the string entry.
	 *
	 * @return The name of this entry.
	 * @throws IOException On read errors.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2017/01/03
	 */
	private final String __internalToString()
		throws IOException, ZipException
	{
		Reference<String> ref = this._name;
		String rv;
		
		// Need to load it?
		if (ref == null || null == (rv = ref.get()))
		{
			BlockAccessor accessor = this.accessor;
			long position = this.position;
			
			// {@squirreljme.error BF0h Could not read the central
			// directory data.}
			byte[] data = new byte[ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH];
			if (ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH != accessor.read(position,
				data, 0, ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH))
				throw new ZipException("BF0h");
			
			// Read file name length
			int fnl = __ArrayData__.readUnsignedShort(
				ZipBlockEntry._CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET, data);
			
			// {@squirreljme.error BF0i Could not read the file name.}
			byte[] rawname = new byte[fnl];
			if (fnl != accessor.read(
				position + ZipBlockEntry._CENTRAL_DIRECTORY_MIN_LENGTH, rawname, 0, fnl))
				throw new ZipException("BF0i");
			
			// UTF-8 Encoded?
			if ((__ArrayData__.readUnsignedShort(
				ZipBlockEntry._CENTRAL_DIRECTORY_FLAG_OFFSET, data) & ZipBlockEntry.GPF_ENCODING_UTF8) != 0)
				rv = new String(rawname, 0, fnl, "utf-8");
			
			// DOS codepage
			else
				rv = IBM437CodePage.toString(rawname, 0, fnl);
			
			// Store for later
			this._name = new WeakReference<>(rv);
		}
		
		return rv;
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/blockreader/ZipBlockReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.NoSuchElementException;
import net.multiphasicapps.zip.ZipException;

/**
 * This class is used to read ZIP files in a random access fashion.
 *
 * @since 2016/12/27
 */
public class ZipBlockReader
	implements Iterable<ZipBlockEntry>, Closeable
{
	/** The magic number for central directory items. */
	private static final int _CENTRAL_DIRECTORY_MAGIC_NUMBER =
		0x02014B50;
	
	/** The offset to the file name length. */
	private static final int _CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET =
		28;
	
	/** The offset to the extra data length. */
	private static final int _CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET =
		ZipBlockReader._CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET + 2;
	
	/** The offset to the comment length. */
	private static final int _CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET =
		ZipBlockReader._CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET + 2;
	
	/** The minimum length of the central directory entry. */
	private static final int _CENTRAL_DIRECTORY_MIN_LENGTH =
		46;
	
	/** The magic number for the end directory. */
	private static final int _END_DIRECTORY_MAGIC_NUMBER =
		0x06054B50;
	
	/** The offset to the field for the number of entries in this disk. */
	private static final int _END_DIRECTORY_DISK_ENTRIES_OFFSET =
		8;
	
	/** The offset to the size of the central directory. */
	private static final int _END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET =
		ZipBlockReader._END_DIRECTORY_DISK_ENTRIES_OFFSET + 4;
	
	/** The offset to the offset of the central directory. */
	private static final int _END_DIRECTORY_CENTRAL_DIR_OFFSET_OFFSET =
		ZipBlockReader._END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET + 4;
	
	/** The minimum length of the end central directory record. */
	private static final int _END_DIRECTORY_MIN_LENGTH =
		22;
	
	/** The maximum length of the end central directory record. */
	private static final int _END_DIRECTORY_MAX_LENGTH =
		ZipBlockReader._END_DIRECTORY_MIN_LENGTH + 65535;
	
	/** The accessor to use for ZIP files. */
	protected final BlockAccessor accessor;
	
	/** The number of entries in this ZIP. */
	protected final int numentries;
	
	/** The base address for the central directory. */
	protected final long cdirbase;
	
	/** The actual start position for the ZIP file. */
	final long _zipbaseaddr;
	
	/** The accessor to use for ZIP files. */
	final BlockAccessor _accessor;
	
	/** Central directory entry offsets. */
	final long[] _offsets;
	
	/** Entries within this ZIP file. */
	private final Reference<ZipBlockEntry>[] _entries;
	
	/**
	 * Accesses the given array as a ZIP file.
	 *
	 * @param __b The array to wrap.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(byte[] __b)
		throws IOException, NullPointerException
	{
		this(new ArrayBlockAccessor(__b));
	}
	
	/**
	 * Accesses the given range in the array as a ZIP file.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to make available.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		this(new ArrayBlockAccessor(__b, __o, __l));
	}
	
	/**
	 * Accesses the given ZIP file from the block accessor.
	 *
	 * @param __b The accessor to the ZIP data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(BlockAccessor __b)
		throws IOException, NullPointerException, ZipException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.accessor = __b;
		this._accessor = __b;
		
		// Locate the end of the central directory
		byte[] dirbytes = new byte[ZipBlockReader._END_DIRECTORY_MIN_LENGTH];
		long endat = ZipBlockReader.__locateCentralDirEnd(__b, dirbytes);
		
		// Get the number of entries which are in this disk and not in the
		// archive as a whole, since multi-archive ZIP files are not supported
		int numentries = __ArrayData__.readUnsignedShort(
			ZipBlockReader._END_DIRECTORY_DISK_ENTRIES_OFFSET, dirbytes);
		this.numentries = numentries;
		
		// Need the size of the central directory to determine where it
		// actually starts
		long csz = __b.size();
		long cdirsize = __ArrayData__.readUnsignedInt(
			ZipBlockReader._END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET, dirbytes);
		
		// This is the position of the start of the central directory
		long cdirbase = endat - cdirsize;
		this.cdirbase = cdirbase;
		
		// {@squirreljme.error BF0j The central directory is larger than the
		// ZIP file, the ZIP is truncated. (The central directory size; The
		// size of the ZIP file)}
		if (cdirsize > csz)
			throw new ZipException(String.format("BF0j %d %d", cdirsize, csz));
		
		// Determine the base address of the ZIP file since all entries
		// are relative from the start point
		long zipbaseaddr = csz - (__ArrayData__.readUnsignedInt(
			ZipBlockReader._END_DIRECTORY_CENTRAL_DIR_OFFSET_OFFSET, dirbytes) + cdirsize +
			(csz - endat));
		this._zipbaseaddr = zipbaseaddr;
		
		// {@squirreljme.error BF0k The base address of the ZIP file exceeds
		// the bound of the ZIP file. (The central directory size; The size of
		// the ZIP file)}
		if (zipbaseaddr < 0 || zipbaseaddr > csz)
			throw new ZipException(String.format("BF0k %d %d", zipbaseaddr,
				csz));
		
		// Setup entry list
		this._entries = ZipBlockReader.__newEntryReferenceList(numentries);
		
		// Initialize entry offsets
		this._offsets = this.__readOffsets();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.accessor.close();
	}
	
	/**
	 * Checks whether the ZIP file contains an entry with the given entry name.
	 *
	 * @param __s The name to check if it is contained within the ZIP.
	 * @return {@code true} If the ZIP contains an entry with this name.
	 * @throws IOException If the ZIP could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/30
	 */
	public boolean contains(String __s)
		throws IOException, NullPointerException
	{
		try
		{
			return this.get(__s) != null;
		}
		
		// Does not exist
		catch (ZipEntryNotFoundException e)
		{
			return false;
		}
	}
	
	/**
	 * Returns the entry which is associated with the given name.
	 *
	 * @return The entry for the given name.
	 * @throws IOException If there was an error reading the ZIP.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipEntryNotFoundException If the entry does not exist.
	 * @since 2016/12/30
	 */
	public ZipBlockEntry get(String __s)
		throws IOException, NullPointerException, ZipEntryNotFoundException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Use linear search since entries might be in any order
		for (ZipBlockEntry e : this)
			if (e.toString().equals(__s))
				return e;
		
		// {@squirreljme.error BF0l Could not find the entry with the
		// specified name. (The name of the entry)}
		throw new ZipEntryNotFoundException(String.format("BF0l %s", __s));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/30
	 */
	@Override
	public Iterator<ZipBlockEntry> iterator()
	{
		return new __Iterator__();
	}
	
	/**
	 * Opens the file with the given name from this ZIP file and returns the
	 * input stream for its data.
	 *
	 * @param __s The file to open.
	 * @return The input stream to the file.
	 * @throws IOException If the file could not be opened due to either a
	 * damaged ZIP file, failed read, or if it does not exist.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipEntryNotFoundException If the entry could not be found.
	 * @since 2016/12/30
	 */
	public InputStream open(String __s)
		throws IOException, NullPointerException, ZipEntryNotFoundException
	{
		// {@squirreljme.error BF0m The specified entry does not exist
		// within the ZIP file. (The entry name)}
		ZipBlockEntry ent = this.get(__s);
		if (ent == null)
			throw new ZipEntryNotFoundException(String.format("BF0m %s", __s));
		
		// Open it
		return ent.open();
	}
	
	/**
	 * Returns the number of entries in this ZIP file.
	 *
	 * @return The number of entries in the ZIP.
	 * @since 2016/12/30
	 */
	public int size()
	{
		return this.numentries;
	}
	
	/**
	 * Reads the offsets within the ZIP file for central directory items.
	 *
	 * @return The array of offsets.
	 * @throws IOException On read errors or the ZIP is not valid.
	 * @since 2016/12/31
	 */
	private long[] __readOffsets()
		throws IOException
	{
		// Setup return value
		int numentries = this.numentries;
		long[] rv = new long[numentries];
		
		// Read in every entry within the ZIP
		BlockAccessor accessor = this.accessor;
		long at = this.cdirbase;
		byte[] cdirent = new byte[ZipBlockReader._CENTRAL_DIRECTORY_MIN_LENGTH];
		for (int i = 0; i < numentries; i++)
		{
			// Entry is placed at this position
			rv[i] = at;
			
			// {@squirreljme.error BF0n Central directory extends past the end
			// of the file. (The current entry; The current read position; The
			// size of the file)}
			if (accessor.read(at, cdirent, 0,
				ZipBlockReader._CENTRAL_DIRECTORY_MIN_LENGTH) != ZipBlockReader._CENTRAL_DIRECTORY_MIN_LENGTH)
				throw new ZipException(String.format("BF0n %d %d %d", i, at,
					accessor.size()));
			
			// {@squirreljme.error BF0o The entry does not have a valid
			// magic number. (The entry index)}
			if (__ArrayData__.readSignedInt(0, cdirent) != ZipBlockReader._CENTRAL_DIRECTORY_MAGIC_NUMBER)
				throw new ZipException(String.format("BF0o %d", i));
			
			// Read lengths for file name, comment, and extra data
			int fnl = __ArrayData__.readUnsignedShort(
				ZipBlockReader._CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET, cdirent),
				cml = __ArrayData__.readUnsignedShort(
					ZipBlockReader._CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET, cdirent),
				edl = __ArrayData__.readUnsignedShort(
					ZipBlockReader._CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET, cdirent);
			
			// Next entry is just after this point
			at += fnl + cml + edl + ZipBlockReader._CENTRAL_DIRECTORY_MIN_LENGTH;
		}
		
		// Done
		return rv;
	}
	
	/**
	 * Locates the end of the central directory.
	 *
	 * @param __b The block accessor to search.
	 * @param __db The bytes that make up the end of the central directory.
	 * @return The position of the central directory end.
	 * @throws IOException On read errors or if the central directory could
	 * not be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/29
	 */
	private static final long __locateCentralDirEnd(BlockAccessor __b,
		byte[] __db)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null || __db == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF0p The file is too small to be a ZIP file.
		// (The size of file)}
		long size = __b.size();
		if (size < ZipBlockReader._END_DIRECTORY_MIN_LENGTH)
			throw new ZipException(String.format("BF0p %d", size));
		
		// Constantly search for the end of the central directory
		for (long at = size - ZipBlockReader._END_DIRECTORY_MIN_LENGTH, end =
			 Math.max(0, size - ZipBlockReader._END_DIRECTORY_MAX_LENGTH); at >= end; at--)
		{
			// Read single byte to determine if it might start a header
			byte b = __b.read(at);
			if (b != 0x50)
				continue;
			
			// Read entire buffer (but not the comment in)
			__b.read(at, __db, 0, ZipBlockReader._END_DIRECTORY_MIN_LENGTH);
			
			// Need to check the magic number
			if (__ArrayData__.readSignedInt(0, __db) != ZipBlockReader._END_DIRECTORY_MAGIC_NUMBER)
				continue;
			
			// Length must match the end also
			if (__ArrayData__.readUnsignedShort(
				ZipBlockReader._END_DIRECTORY_MIN_LENGTH - 2,
				__db) != (size - (at + ZipBlockReader._END_DIRECTORY_MIN_LENGTH)))
				continue;
			
			// Central directory is here
			return at;
		}
		
		// {@squirreljme.error BF0q Could not find the end of the central
		// directory in the ZIP file.}
		throw new ZipException("BF0q");
	}
	
	/**
	 * Creates a list of references.
	 *
	 * @param __n The number of elements in the list.
	 * @return The list.
	 * @since 2016/12/31
	 */
	@SuppressWarnings({"unchecked"})
	private static Reference<ZipBlockEntry>[] __newEntryReferenceList(
		int __n)
	{
		return (Reference<ZipBlockEntry>[])((Object)new Reference[__n]);
	}
	
	/**
	 * Iterates over entries within the ZIP.
	 *
	 * @since 2016/12/31
	 */
	private class __Iterator__
		implements Iterator<ZipBlockEntry>
	{
		/** Entry count. */
		protected final int numentries =
			ZipBlockReader.this.numentries;
		
		/** The next entry. */
		private volatile int _next =
			0;
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public boolean hasNext()
		{
			return (this._next < this.numentries);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public ZipBlockEntry next()
			throws NoSuchElementException
		{
			// No more entries?
			int next = this._next;
			if (next >= this.numentries)
				throw new NoSuchElementException("NSEE");
			
			// Next entry to read
			this._next = next + 1;
			
			// Parse and return entry
			Reference<ZipBlockEntry>[] entries = ZipBlockReader.this._entries;
			Reference<ZipBlockEntry> ref = entries[next];
			ZipBlockEntry rv;
			
			// Need to load the entry?
			if (ref == null || null == (rv = ref.get()))
				entries[next] = new WeakReference<>(
					(rv = new ZipBlockEntry(ZipBlockReader.this, next)));
			
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

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

package net.multiphasicapps.zip.blockreader;

import net.multiphasicapps.zip.ZipException;

/**
 * This is thrown when an entry within a ZIP file is not found.
 *
 * @since 2017/01/22
 */
public class ZipEntryNotFoundException
	extends ZipException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(Throwable __c)
	{
		super(__c);
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/blockreader/__ArrayData__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

/**
 * This class contains methods for reading data from arrays, all read values
 * are little endian.
 *
 * @since 2016/12/28
 */
final class __ArrayData__
{
	/**
	 * Reads a signed integer from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readSignedInt(int __off, byte[] __b)
	{
		return (__b[__off + 3] << 24) |
			((__b[__off + 2] & 0xFF) << 16) |
			((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads a signed short from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readSignedShort(int __off, byte[] __b)
	{
		return (__b[__off + 1] << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads an unsigned integer from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static long readUnsignedInt(int __off, byte[] __b)
	{
		return ((__b[__off + 3] & 0xFF) << 24) |
			((__b[__off + 2] & 0xFF) << 16) |
			((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads an unsigned short from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readUnsignedShort(int __off, byte[] __b)
	{
		return ((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
}

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

package net.multiphasicapps.zip.blockreader;

import java.io.IOException;
import java.io.InputStream;

/**
 * This is used to read directly from the block accessor.
 *
 * @since 2017/01/03
 */
class __BlockAccessorRegionInputStream__
	extends InputStream
{
	/** The accessor to read from. */
	protected final BlockAccessor accessor;
	
	/** The next position to read from. */
	private volatile long _next;
	
	/** The current number of bytes remaining. */
	private volatile long _rest;
	
	/**
	 * Initializes the block region input.
	 *
	 * @param __ba The block accessor to read data from.
	 * @param __start The start address of the read.
	 * @param __len The number of bytes to read.
	 * @throws IllegalArgumentException If the start and/or length are
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/01/03
	 */
	__BlockAccessorRegionInputStream__(BlockAccessor __ba, long __start,
		long __len)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__ba == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF0r The start position and length cannot be
		// negative.}
		if (__start < 0 || __len < 0)
			throw new IllegalArgumentException("BF0r");
		
		// Set
		this.accessor = __ba;
		this._next = __start;
		this._rest = __len;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int available()
		throws IOException
	{
		// Never exceed 2GiB
		return (int)Math.min(Math.max(0, this._rest), Integer.MAX_VALUE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int read()
		throws IOException
	{
		// Forward to multi-byte version
		byte[] b = new byte[1];
		for (;;)
		{
			int rv = this.read(b, 0, 1);
			
			// EOF?
			if (rv < 0)
				return -1;
			
			// Return value otherwise
			return b[0] & 0xFF;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// EOF?
		long rest = this._rest;
		if (rest <= 0)
			return -1;
		
		// Determine number of bytes to read
		long next = this._next;
		int desired = (int)Math.min(__l, rest);
		
		// Read in the data
		int actual = this.accessor.read(next, __b, __o, desired);
		
		// Set next position
		this._next = next + actual;
		this._rest = rest - actual;
		
		// Return the actual read count
		return actual;
	}
}

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

package net.multiphasicapps.zip.blockreader;

import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.zip.ZipCRCConstants;

/**
 * This is used to check that the CRC is valid.
 *
 * @since 2017/01/03
 */
class __CRCInputStream__
	extends InputStream
{
	/** The stream to source from. */
	protected final InputStream in;
	
	/** The final resulting CRC to use. */
	protected final int crc;
	
	/** CRC calculation. */
	protected final CRC32Calculator crccalc =
		new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
			ZipCRCConstants.CRC_REFLECT_REMAINDER,
			ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
			ZipCRCConstants.CRC_FINALXOR);
	
	/** The number of read bytes. */
	private volatile int _count;
	
	/**
	 * Calcualtes the CRC of another given input stream.
	 *
	 * @param __in The stream to read from.
	 * @param __crc The final CRC to calculate.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/01/03
	 */
	__CRCInputStream__(InputStream __in, int __crc)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __in;
		this.crc = __crc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int available()
		throws IOException
	{
		// Forward as it may be calculable
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public void close()
		throws IOException
	{
		// Forward
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int read()
		throws IOException
	{
		// Read in
		int rv = this.in.read();
		
		// EOF? Check CRC value
		CRC32Calculator crccalc = this.crccalc;
		if (rv < 0)
		{
			// {@squirreljme.error BF0s CRC mismatch. (The expected CRC; The
			// calculated CRC; The number of read bytes})
			int thiscrc = crccalc.checksum(), wantcrc = this.crc;
			if (thiscrc != wantcrc)
				throw new IOException(String.format("BF0s %08x %08x %d",
					wantcrc, thiscrc, this._count));
			
			// EOF
			return -1;
		}
		
		// Calculate
		crccalc.offer((byte)rv);
		this._count += 1;
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// Read in
		int rv = this.in.read(__b, __o, __l);
		
		// EOF? Check CRC value
		CRC32Calculator crccalc = this.crccalc;
		if (rv < 0)
		{
			// {@squirreljme.error BF0t CRC mismatch. (The expected CRC; The
			// calculated CRC; The number of read bytes})
			int thiscrc = crccalc.checksum(), wantcrc = this.crc;
			if (thiscrc != wantcrc)
				throw new IOException(String.format("BF0t %08x %08x %d",
					wantcrc, thiscrc, this._count));
			
			// EOF
			return -1;
		}
		
		// Calculate
		crccalc.offer(__b, __o, rv);
		this._count += rv;
		
		// Return
		return rv;
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/blockreader/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the code which is used to parse ZIP files in a random
 * access fashion.
 *
 * @since 2016/12/27
 */

package net.multiphasicapps.zip.blockreader;

Added modules/zip/src/main/java/net/multiphasicapps/zip/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains basic ZIP file support.
 *
 * @since 2016/07/15
 */

package net.multiphasicapps.zip;

Added modules/zip/src/main/java/net/multiphasicapps/zip/streamreader/ZipStreamEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamreader;

import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.DecompressionInputStream;
import net.multiphasicapps.io.DynamicHistoryInputStream;
import net.multiphasicapps.zip.ZipCRCConstants;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipException;

/**
 * This provides an interface to interact with a single entry within a ZIP
 * stream.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public final class ZipStreamEntry
	extends InputStream
{
	/** The maximum size the data descriptor can be (if there is one). */
	private static final int _MAX_DESCRIPTOR_SIZE =
		16;
	
	/** The descriptor size if there is no header. */
	private static final int _HEADERLESS_DESCRIPTOR_SIZE =
		12;
	
	/** Data descriptor magic number. */
	private static final int _DESCRIPTOR_MAGIC_NUMBER =
		0x08074B50;
	
	/** CRC calculation. */
	protected final CRC32Calculator crc =
		new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
			ZipCRCConstants.CRC_REFLECT_REMAINDER,
			ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
			ZipCRCConstants.CRC_FINALXOR);
	
	/** The owning stream reader. */
	protected final ZipStreamReader zipreader;
	
	/** The name of the file. */
	protected final String filename;
	
	/** The compression method. */
	protected final ZipCompressionType method;
	
	/** The dynamic input stream to read from. */
	protected final DynamicHistoryInputStream dhin;
	
	/** The compressed stream which also has counting. */
	protected final DecompressionInputStream cin;
	
	/** Is the content length undefined? */
	protected final boolean undefined;
	
	/** Is EOF detected? */
	protected final boolean detectseof;
	
	/** The expected CRC. */
	protected final int expectedcrc;
	
	/** The expected file uncompressed size. */
	protected final int expecteduncompsize;
	
	/** The expected file compressed size. */
	protected final int expectedcompsize;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** Used for peeking bytes to detect EOF. */
	private final byte[] _peeking;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/** The number of uncompressed bytes read. */
	private volatile long _readuncomp;
	
	/** Has EOF been reached? */
	private volatile boolean _eof;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __zsr The owning stream reader.
	 * @param __fn The name of the entry.
	 * @param __undef Is the size and CRC undefined?
	 * @param __crc The expected CRC.
	 * @param __comp The compressed size.
	 * @param __uncomp The uncompressed size.
	 * @param __method The compression method.
	 * @param __ins The input data source.
	 * @throws IOException If the decompressor could not be initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	ZipStreamEntry(ZipStreamReader __zsr, String __fn, boolean __undef,
		int __crc, int __comp, int __uncomp, ZipCompressionType __method,
		DynamicHistoryInputStream __ins)
		throws IOException, NullPointerException
	{
		// Check
		if (__zsr == null || __fn == null || __method == null ||
			__ins == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.zipreader = __zsr;
		this.filename = __fn;
		this.method = __method;
		this.dhin = __ins;
		DecompressionInputStream dis;
		this.cin = (dis = __method.inputStream(__ins, this.crc));
		this.undefined = __undef;
		this.detectseof = dis.detectsEOF();
		this.expectedcrc = __crc;
		this.expecteduncompsize = __uncomp;
		this.expectedcompsize = __comp;
		this._peeking = (__undef ?
			new byte[ZipStreamEntry._MAX_DESCRIPTOR_SIZE] : null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public void close()
		throws IOException
	{
		if (!this._closed)
		{
			// Mark closed
			this._closed = true;
			
			// Read all input bytes until EOF, except when EOF was already
			// reached
			if (!this._eof)
			{
				byte[] buf = new byte[4096];
				while (this.read(buf) >= 0)
					;
			}
			
			// Tell the ZIP reader that this entry is gone and the next
			// can be read
			this.zipreader.__closeEntry(this);
		}
	}
	
	/**
	 * Returns the compression type that the entry uses.
	 *
	 * @return The compression type.
	 * @since 2016/07/19
	 */
	public ZipCompressionType compressionType()
	{
		return this.method;
	}
	
	/**
	 * Returns the name of the entry.
	 *
	 * @return The entry name.
	 * @since 2016/07/19
	 */
	public String name()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = this.read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/02/29
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If EOF reached, do nothing
		if (this._eof)
			return -1;
		
		// Reading an undefined number of bytes?
		// If so then a data descriptor will need to be checked
		if (this.undefined)
		{
			// If EOF is detectable then read in the contents until such
			// things occur. Then read the data descriptor to verify that it
			// actually is correct
			if (this.detectseof)
				return this.__detectedRead(__b, __o, __l);
			
			// Otherwise, the input stream has to be peeked constantly to
			// detect the data descriptor.
			else
				return this.__probingRead(__b, __o, __l);
		}
		
		// Read of a defined number of bytes
		else
			return this.__definedRead(__b, __o, __l);
	}
	
	/**
	 * This is a read of input which has a defined size.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __definedRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Needed to check things
		DecompressionInputStream cin = this.cin;
		long cinusz = cin.uncompressedBytes(),
			cincsz = cin.compressedBytes();
		
		// Determine remaining counts
		int remun = (int)(this.expecteduncompsize - cinusz);
		int remco = (int)(this.expectedcompsize - cincsz);
		
		// Never read more than the maximum in unsigned bytes, however
		// we want to read as many compressed bytes as possible because streams
		// which are completely empty with otherwise never read the ending
		// bytes if the streams are empty.
		int rest = (remun == 0 ? remco : remun);
		if (__l > rest)
			__l = rest;
		
		// Read data
		int rc = this.cin.read(__b, __o, __l);
		
		// EOF reached?
		if (rc < 0)
		{
			// Mark EOF
			this._eof = true;
			
			// {@squirreljme.error BF0u Reached end of file in the entry
			// however the size it consumes and/or its CRC does not match
			// the expected values. (The expected CRC; The actual CRC;
			// The expected uncompressed size; The actual uncompressed
			// size; The expected compressed size; The actual compressed
			// size)}
			CRC32Calculator crc = this.crc;
			int expectedcrc = this.expectedcrc,
				expecteduncompsize = this.expecteduncompsize,
				expectedcompsize = this.expectedcompsize;
			if (expecteduncompsize != cinusz ||
				expectedcompsize != cincsz ||
				expectedcrc != crc.checksum())
				throw new ZipException(String.format(
					"BF0u %08x %08x %d %d %d %d", expectedcrc,
					crc.checksum(), expecteduncompsize, cinusz,
					expectedcompsize, cincsz));
			
			// Nothing read
			return -1;
		}
		
		// {@squirreljme.error BF72 While reading an exact-size entry no
		// compressed data was read and EOF was not returned, it is possible
		// that the ZIP is corrupted. (Expected compressed size; Currently
		// read uncompressed bytes/The expected uncompressed size; Currently
		// read compressed bytes/The expected compressed size; The file)}
		else if (rc == 0 && rest == 0)
			throw new ZipException(String.format("BF72 %d (%d/%d) (%d/%d) %s",
				this.expecteduncompsize, cinusz, this.expecteduncompsize,
				cincsz, this.expectedcompsize, this.filename));
		
		// Mark as read
		this._readuncomp += rc;
		return rc;
	}
	
	/**
	 * Read of undefined size data, but where the EOF is detectable.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __detectedRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		// This is as simple as reading the input bytes
		DecompressionInputStream cin = this.cin;
		int rc = cin.read(__b, __o, __l);
		
		// If EOF was not reached, then just return with the read bytes
		if (rc >= 0)
		{
			if (rc == 0 && this._eof)
				return -1;
			return rc;
		}
		
		// EOF was reached from the compressed stream, so the data descriptor
		// has to immedietly follow
		DynamicHistoryInputStream dhin = this.dhin;
		byte[] peeking = this._peeking;
		
		// Mark EOF so future reads fail
		this._eof = true;
		
		// {@squirreljme.error BF0v Could not find end of entry because the
		// entry exceeds the bounds of the ZIP file. (The number of read
		// bytes)}
		int probed = dhin.peek(0, peeking, 0,
			ZipStreamEntry._MAX_DESCRIPTOR_SIZE);
		if (probed < ZipStreamEntry._HEADERLESS_DESCRIPTOR_SIZE)
			throw new ZipException(String.format("BF0v %d", probed));
		
		// The specification says the descriptor is optional
		int offset = (ZipStreamEntry._DESCRIPTOR_MAGIC_NUMBER ==
			ZipStreamReader.__readInt(peeking, 0) ? 4 : 0);

		// Read descriptor fields
		int ddcrc = ZipStreamReader.__readInt(peeking, offset),
			ddcomp = ZipStreamReader.__readInt(peeking, offset + 4),
			dduncomp = ZipStreamReader.__readInt(peeking, offset + 8);

		// {@squirreljme.error BF0w Reached end of file in the entry
		// however the size it consumes and/or its CRC does not match
		// the expected values. (The expected CRC; The actual CRC;
		// The expected uncompressed size; The actual uncompressed
		// size; The expected compressed size; The actual compressed
		// size)}
		CRC32Calculator crc = this.crc;
		long cinusz = cin.uncompressedBytes(),
			cincsz = cin.compressedBytes();
		if (dduncomp != cinusz ||
			ddcomp != cincsz ||
			ddcrc != crc.checksum())
			throw new ZipException(String.format(
				"BF0w %08x %08x %d %d %d %d", ddcrc,
				crc.checksum(), dduncomp, cinusz,
				ddcomp, cincsz));
		
		// EOF is OK now
		return -1;
	}
	
	/**
	 * Read of undefined size data, however since the input is not known it
	 * must be probed for the end to be detected.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __probingRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		DynamicHistoryInputStream dhin = this.dhin;
		byte[] peeking = this._peeking;
		CRC32Calculator crc = this.crc;
		DecompressionInputStream cin = this.cin;
		
		// Due to the nature the end of a stream must be detected for this
		// data, the input must be read a single byte at a time which
		// introduces much overhead
		int d = 0;
		for (int i = __o, e = __o + __l; i < e; i++, d++)
		{
			// {@squirreljme.error BF0x Could not find end of entry because the
			// entry exceeds the bounds of the ZIP file. (The number of read
			// bytes)}
			int probed = dhin.peek(0, peeking, 0,
				ZipStreamEntry._MAX_DESCRIPTOR_SIZE);
			if (probed < ZipStreamEntry._HEADERLESS_DESCRIPTOR_SIZE)
				throw new ZipException(String.format("BF0x %d", probed));
		
			// According to the specification, the magic number is optional and
			// might not be specified
			// Regardless if it is or not, potentially skip it
			int offset = (ZipStreamEntry._DESCRIPTOR_MAGIC_NUMBER ==
				ZipStreamReader.__readInt(peeking, 0) ? 4 : 0);
		
			// Read descriptor fields
			int ddcrc = ZipStreamReader.__readInt(peeking, offset),
				ddcomp = ZipStreamReader.__readInt(peeking, offset + 4),
				dduncomp = ZipStreamReader.__readInt(peeking, offset + 8);
			
			// EOF occurs?
			if (ddcomp == cin.compressedBytes() &&
				dduncomp == cin.uncompressedBytes() &&
				ddcrc == crc.checksum())
			{
				// Mark EOF
				this._eof = true;
				return (d <= 0 ? -1 : d);
			}
			
			// {@squirreljme.error BF0y Reached end of file before the end
			// of the ZIP entry could be found.}
			int rc = cin.read();
			if (rc < 0)
				throw new ZipException("BF0y");
			__b[i] = (byte)rc; 
		}
		
		// Read count
		if (d == 0 && this._eof)
			return -1;
		return d;
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/streamreader/ZipStreamReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamreader;

import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.io.DataEndianess;
import net.multiphasicapps.io.DynamicHistoryInputStream;
import net.multiphasicapps.io.ExtendedDataInputStream;
import net.multiphasicapps.zip.IBM437CodePage;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipException;

/**
 * This class supports stream based reading of input ZIP files.
 *
 * Only files up to 2GiB in length are supported. If a data descriptor is
 * specified for entries then they must have the optional descriptor magic
 * number included.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public class ZipStreamReader
	implements Closeable
{
	/** The maximum support version for extracting. */
	private static final int _MAX_EXTRACT_VERSION =
		20;
	
	/** The minumum size of the local header. */
	private static final int _MINIMUM_HEADER_SIZE =
		30;
	
	/** The local header magic number. */
	private static final int _LOCAL_HEADER_MAGIC =
		0x04034B50;
	
	/** The dynamic history stream. */
	protected final DynamicHistoryInputStream input;
	
	/** This is used after an input structure is detected. */
	protected final ExtendedDataInputStream data;
	
	/** This can hold the local header except for the comment and filename. */
	private final byte[] _localheader =
		new byte[ZipStreamReader._MINIMUM_HEADER_SIZE];
	
	/** The current entry being read, cannot next entry if this is the case. */
	private volatile ZipStreamEntry _entry;
	
	/** End of file reached? */
	private volatile boolean _eof;
	
	/** Deferred exceptions, set after an entry read fails. */
	private volatile ZipException _defer;
	
	/**
	 * Initializes the reader for input ZIP file data.
	 *
	 * @param __is The input stream to source bytes from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public ZipStreamReader(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		DynamicHistoryInputStream q;
		this.input = (q = new DynamicHistoryInputStream(__is));
		ExtendedDataInputStream d;
		this.data = (d = new ExtendedDataInputStream(q));
		d.setEndianess(DataEndianess.LITTLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public void close()
		throws IOException
	{
		// Mark EOF
		this._eof = true;
		
		// Close the source
		this.input.close();
		this.data.close();
	}
	
	/**
	 * If an entry is detected and it could not be read, then this exception
	 * may be set to detect such events.
	 *
	 * @return The deferred exception or {@code null} if there is none.
	 * @since 2016/09/11
	 */
	public ZipException deferred()
	{
		ZipException rv = this._defer;
		this._defer = null;
		return rv;
	}
	
	/**
	 * Returns the next entry in the streamed ZIP file for {@code null} if no
	 * such entry exists.
	 *
	 * @return The next entry or {@code null} if there is none.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public ZipStreamEntry nextEntry()
		throws IOException
	{
		// {@squirreljme.error BF0z An entry is currently being read, it
		// must first be closed.}
		if (this._entry != null)
			throw new IOException("BF0z");
		
		// End of file reached?
		if (this._eof)
			return null;
		
		// Read until an entry is found
		DynamicHistoryInputStream input = this.input;
		ExtendedDataInputStream data = this.data;
		byte[] localheader = this._localheader;
		for (; !this._eof;)
		{
			// Peek the magic number
			int rhcount;
			try
			{
				rhcount = input.peek(0, localheader, 0, 4);
			}
			
			// {@squirreljme.error BF10 Could not peek the magic number.}
			catch (IndexOutOfBoundsException e)
			{
				throw new ZipException("BF10", e);
			}
		
			// Could not fit the magic number, treat as EOF
			if (rhcount < 4)
			{
				this._eof = true;
				return null;
			}
		
			// Does not match the magic number for local headers
			int lhskip = ZipStreamReader.__skipLocalHeader(localheader);
			
			// Not one
			if (lhskip > 0)
			{
				// Read
				try
				{
					data.readFully(localheader, 0, lhskip);
				}
				
				// End of file
				catch (EOFException e)
				{
					this._eof = true;
				}
				
				// Return null on the next loop
				continue;
			}
			
			// Read the rest of the header
			rhcount = input.peek(0, localheader);
			
			// EOF reached (cannot fit a local header in this many bytes)
			// Ignore the somewhat malformed ZIP since it could be part of
			// another file structure due to polyglots
			if (rhcount < ZipStreamReader._MINIMUM_HEADER_SIZE)
			{
				this._eof = true;
				return null;
			}
			
			// Deferred exception?
			ZipException defer = null;
			
			// Check the version needed for extracting
			// Note that some ZIP writing software sets the upper byte when it
			// should not. Since the made by version is not stored in the
			// local file header, the byte will just be stripped.
			int xver = ZipStreamReader.__readUnsignedShort(localheader, 4) & 0xFF;
			boolean deny = false;
			deny |= (xver < 0 || xver > ZipStreamReader._MAX_EXTRACT_VERSION);
			
			// {@squirreljme.error BF11 Zip version not suppored. (The
			// version)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF11 %d",
					xver));
			
			// Read bit flags
			int gpfs = ZipStreamReader.__readUnsignedShort(localheader, 6);
			boolean utf = (0 != (gpfs & (1 << 11)));
			boolean undefinedsize = (0 != (gpfs & (1 << 3)));
			
			// Cannot read encrypted entries
			deny |= (0 != (gpfs & 1));
			
			// {@squirreljme.error BF12 Encrypted entries not supported.}
			if (defer == null && deny)
				defer = new ZipException("BF12");
			
			// Read the compression method
			ZipCompressionType cmeth = ZipCompressionType.forMethod(
				ZipStreamReader.__readUnsignedShort(localheader, 8));
			deny |= (cmeth == null);
			
			// {@squirreljme.error BF13 Compression method not supported.
			// (The method)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF13 %s", cmeth));
			
			// Read CRC32
			int crc = ZipStreamReader.__readInt(localheader, 14);
			
			// Read Compressed size
			int csz = ZipStreamReader.__readInt(localheader, 18);
			if (!undefinedsize)
				deny |= (csz < 0);
			
			// Uncompressed size
			int usz = ZipStreamReader.__readInt(localheader, 22);
			if (!undefinedsize)
				deny |= (usz < 0);
			
			// {@squirreljme.error BF14 Entry exceeds 2GiB in size.
			// (The compressed size; The uncompressed size)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF14 %d %d", csz,
					usz));
			
			// File name length
			int fnl = ZipStreamReader.__readUnsignedShort(localheader, 26);
			
			// Comment length
			int cml = ZipStreamReader.__readUnsignedShort(localheader, 28);
			
			// If denying, read a single byte and try again, this could
			// just be very ZIP-like data or the local header number could
			// be a constant in an executable.
			if (deny)
			{
				// Defer the issue, if set
				if (defer != null)
					this._defer = defer;
				
				// Skip 4 bytes because the header was already read
				this.data.readFully(localheader, 0, 4);
				continue;
			}
			
			// Read the local header normally to consume it
			data.readFully(localheader);
			
			// Read the file name, if EOF was reached then ignore
			byte[] rawname = new byte[fnl];
			data.readFully(rawname);
			
			// If UTF-8 then use internal handling
			String filename;
			if (utf)
				filename = new String(rawname, 0, fnl, "utf-8");
		
			// Otherwise use codepage handling, Java ME only has two
			// character sets available
			else
				filename = IBM437CodePage.toString(rawname, 0, fnl);
			
			// Skip the comment
			data.readFully(localheader, 0, Math.min(cml,
				ZipStreamReader._MINIMUM_HEADER_SIZE));
			
			// Create entry so the data can actually be used
			ZipStreamEntry rv = new ZipStreamEntry(this, filename,
				undefinedsize, crc, csz, usz, cmeth, input);
			this._entry = rv;
			return rv;
		}
		
		// No entry
		this._eof = true;
		return null;
	}
	
	/**
	 * Closes an entry so that the next one can be read.
	 *
	 * @param __ent The entry to close.
	 * @throws IOException If it could not be closed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/20
	 */
	final void __closeEntry(ZipStreamEntry __ent)
		throws IOException, NullPointerException
	{
		// Check
		if (__ent == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF15 Close of an incorrect entry.}
		if (this._entry != __ent)
			throw new IOException("BF15");
		
		// Clear it
		this._entry = null;
	}
	
	/**
	 * Reads an unsigned integer value.
	 *
	 * @param __b The byte array to read from.
	 * @param __p The position to read from.
	 * @return The read value.
	 * @since 2016/07/19
	 */
	static int __readInt(byte[] __b, int __p)
	{
		return (__b[__p] & 0xFF) |
			((__b[__p + 1] & 0xFF) << 8) |
			((__b[__p + 2] & 0xFF) << 16) |
			((__b[__p + 3] & 0xFF) << 24);
	}
	
	/**
	 * Reads an unsigned short from the given byte array.
	 *
	 * @param __b The byte array to read from.
	 * @param __p The position to read from.
	 * @return The read value.
	 * @since 2016/07/19
	 */
	static int __readUnsignedShort(byte[] __b, int __p)
	{
		return (__b[__p] & 0xFF) |
			((__b[__p + 1] & 0xFF) << 8);
	}
	
	/**
	 * Checks if the specified buffer starts with the local header magic
	 * number and if not returns the number of bytes to skip.
	 *
	 * @param __b The bytes to check, from the zero index.
	 * @return Zero means this is the local header, otherwise a value up to 4.
	 * @since 2016/07/19
	 */
	private static int __skipLocalHeader(byte[] __b)
	{
		// Read values
		byte lha = __b[0], lhb = __b[1], lhc = __b[2], lhd = __b[3];
		
		// Is this the magic number?
		if (lha == 0x50 && lhb == 0x4B && lhc == 0x03 && lhd == 0x04)
			return 0;
		
		// Next byte over
		else if (lhb == 0x50 && lhc == 0x4B && lhd == 0x03)
			return 1;
		
		// Skip two bytes
		else if (lhc == 0x50 && lhd == 0x4B)
			return 2;
		
		// Last byte could be it
		if (lhd == 0x50)
			return 3;
		
		// None of them
		return 4;
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/streamreader/package-info.java.




















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the class which supports reading and handling streams of ZIP
 * files.
 *
 * @since 2016/07/19
 */

package net.multiphasicapps.zip.streamreader;

Added modules/zip/src/main/java/net/multiphasicapps/zip/streamwriter/ZipStreamWriter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamwriter;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.DataEndianess;
import net.multiphasicapps.io.ExtendedDataOutputStream;
import net.multiphasicapps.zip.ZipCRCConstants;
import net.multiphasicapps.zip.ZipCompressionType;

/**
 * This class is used to write to ZIP files in an unknown and stream based
 * manner where the size of the contents is completely unknown.
 *
 * When the stream is closed, the central directory of the ZIP file will be
 * written to the end of the file.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/09
 */
public class ZipStreamWriter
	implements Closeable
{
	/** The magic number for local files. */
	private static final int _LOCAL_FILE_MAGIC_NUMBER =
		0x04034B50;
	
	/** Data descriptor magic. */
	private static final int _DATA_DESCRIPTOR_MAGIC_NUMBER =
		0x08074B50;
	
	/** Central directory entry magic number. */
	private static final int _CENTRAL_DIRECTORY_MAGIC_NUMBER =
		0x02014B50;
	
	/** End of central directory magic number. */
	private static final int _END_DIRECTORY_MAGIC_NUMBER =
		0x06054B50;
	
	/** The maximum permitted file size. */
	private static final long _MAX_FILE_SIZE =
		0xFFFFFFFFL;
	
	/** General purpose flags for entries (use descriptor; UTF-8 names). */
	private static final int _GENERAL_PURPOSE_FLAGS =
		(1 << 3) | (1 << 11);
	
	/** The output stream to write to. */
	protected final ExtendedDataOutputStream output;
	
	/** Table of contents. */
	private final LinkedList<__TOCEntry__> _toc =
		new LinkedList<>();
	
	/** Was this stream closed? */
	private boolean _closed;
	
	/** The current entry output (the inner portion). */
	private __InnerOutputStream__ _inner;
	
	/** The current entry output (the outer portion). */
	private __OuterOutputStream__ _outer;
	
	/** The best version number. */
	private int _bestversion =
		Math.max(20, ZipCompressionType.DEFLATE.extractVersion());
	
	/**
	 * This initializes the stream for writing ZIP file data.
	 *
	 * @param __os The output stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/09
	 */
	public ZipStreamWriter(OutputStream __os)
		throws NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Create stream
		ExtendedDataOutputStream output;
		this.output = (output = new ExtendedDataOutputStream(__os));
		
		// Use little endian data by default
		output.setEndianess(DataEndianess.LITTLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/09
	 */
	@Override
	public void close()
		throws IOException
	{
		// Do nothing if already closed
		if (this._closed)
			return;
		
		// {@squirreljme.error BF16 Cannot close the ZIP writer because
		// an entry is still being written.}
		if (this._inner != null || this._outer != null)
			throw new IOException("BF16");
		
		// Mark closed to prevent failing closes from writing multiple
		// times
		this._closed = true;
		
		// Get output and the TOC entries
		ExtendedDataOutputStream output = this.output;
		LinkedList<__TOCEntry__> toc = this._toc;
		int numtoc = toc.size();
		
		// The position where the central directory starts
		long cdstart = output.size();
		
		// The current time all entries will use for their date
		// 0bhhhhh_mmmmmm_sssss
		// 0byyyyyy_mmmm_ddddd
		todo.TODO.note("Implement correct timestamp.");
		int time = 0b01111_011110_00000,
			date = 0b100110_0011_01000;
		
		// Write all entries
		int bestversion = this._bestversion;
		for (__TOCEntry__ entry : toc)
		{
			// The entry position
			long epos = output.size();
			
			if (epos > ZipStreamWriter._MAX_FILE_SIZE)
				throw new IOException();
			
			// Write directory header
			output.writeInt(ZipStreamWriter._CENTRAL_DIRECTORY_MAGIC_NUMBER);
			
			// The created by version (use the highest version)
			output.writeShort(bestversion);
			
			// Version needed to extract
			ZipCompressionType ecomp = entry._compression;
			output.writeShort(ecomp.extractVersion());
			
			// General purpose flags
			output.writeShort(ZipStreamWriter._GENERAL_PURPOSE_FLAGS);
			
			// Compression method
			output.writeShort(ecomp.method());
			
			// Date/time ZIP was created (closed)
			output.writeShort(time);
			output.writeShort(date);
			
			// CRC and sizes
			output.writeInt(entry._crc);
			output.writeInt((int)entry._compressed);
			output.writeInt((int)entry._uncompressed);
			
			// Write name length
			byte[] efn = entry._name;
			output.writeShort(efn.length);
			
			// No extra data
			output.writeShort(0);
			
			// No comment
			output.writeShort(0);
			
			// Always the first disk
			output.writeShort(0);
			
			// No iternal or external attributes
			output.writeShort(0);
			output.writeInt(0);
			
			// Relative offset to local header
			output.writeInt((int)entry._localposition);
			
			// Write file name
			output.write(efn);
		}
		
		// The position where it ends
		long cdend = output.size();
		
		// Write magic number
		output.writeInt(ZipStreamWriter._END_DIRECTORY_MAGIC_NUMBER);
		
		// Only a single disk is written
		output.writeShort(0);
		output.writeShort(0);
		
		// Number of entries on this disk and in all of them
		output.writeShort(numtoc);
		output.writeShort(numtoc);
		
		// The size of the central directory
		output.writeInt((int)(cdend - cdstart));
		
		// Offset to the central directory
		output.writeInt((int)cdstart);
		
		// No comment
		output.writeShort(0);
	}
	
	/**
	 * Flushes the output.
	 *
	 * @throws IOException If it could not be flushed.
	 * @since 2016/07/09
	 */
	public void flush()
		throws IOException
	{
		this.output.flush();
	}
	
	/**
	 * Starts writing a new entry in the output ZIP using the default
	 * compression.
	 *
	 * @param __name The name of the entry.
	 * @return An {@link OutputStream} which is used to write the ZIP file
	 * data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public OutputStream nextEntry(String __name)
		throws IOException, NullPointerException
	{
		return this.nextEntry(__name, ZipCompressionType.DEFAULT_COMPRESSION);
	}
	
	/**
	 * Starts writing a new entry in the output ZIP.
	 *
	 * @param __name The name of the entry.
	 * @param __comp The compression method used.
	 * @return An {@link OutputStream} which is used to write the ZIP file
	 * data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public OutputStream nextEntry(String __name, ZipCompressionType __comp)
		throws IOException, NullPointerException
	{
		// Check
		if (__name == null || __comp == null)
			throw new NullPointerException("NARG");
		
		// Lock
		LinkedList<__TOCEntry__> toc = this._toc;
		
		// {@squirreljme.error BF17 Cannot write new entry because the ZIP
		// has been closed.}
		if (this._closed)
			throw new IOException("BF17");
		
		// {@squirreljme.error BF18 Cannot create a new entry for output
		// because the previous entry has not be closed.}
		if (this._inner != null || this._outer != null)
			throw new IOException("BF18");
		
		// {@squirreljme.error BF19 A ZIP file cannot have more than
		// 65536 entries.}
		if (toc.size() >= 65535)
			throw new IOException("BF19");
		
		// {@squirreljme.error BF1a The length of the input file exceeds
		// 65535 UTF-8 characters. (The filename length)}
		byte[] utfname = __name.getBytes("utf-8");
		int fnn;
		if ((fnn = utfname.length) > 65535)
			throw new IOException(String.format("BF1a %d", fnn));
		
		// Setup contents
		__TOCEntry__ last = new __TOCEntry__(this.output.size(), utfname,
			__comp);
		toc.addLast(last);
		
		// Write ZIP header data
		ExtendedDataOutputStream output = this.output;
		output.writeInt(ZipStreamWriter._LOCAL_FILE_MAGIC_NUMBER);
		
		// Extract version
		output.writeShort(__comp.extractVersion());
		
		// General purpose flag
		output.writeShort(ZipStreamWriter._GENERAL_PURPOSE_FLAGS);
		
		// Method
		output.writeShort(__comp.method());
		
		// Modification date/time
		output.writeShort(0);
		output.writeShort(0);
		
		// CRC-32 and compress/uncompressed size are unknown
		output.writeInt(0);
		output.writeInt(0);
		output.writeInt(0);
		
		// Write file name bytes
		output.writeShort(fnn);
		
		// No extra field
		output.writeShort(0);
		
		// Write file name
		output.write(utfname);
		
		// Setup inner stream (for compressed size)
		__InnerOutputStream__ inner = new __InnerOutputStream__();
		
		// Wrap inner with the compression algorithm
		OutputStream wrapped = __comp.outputStream(inner);
		
		// Wrap that with the outer stream (uncompressed size)
		__OuterOutputStream__ outer = new __OuterOutputStream__(wrapped);
		
		// Set
		this._inner = inner;
		this._outer = outer;
		
		// Return the outer stream
		return outer;
	}
	
	/**
	 * Closes the current entry.
	 *
	 * @throws IOException If it could not be closed.
	 * @since 2016/07/15
	 */
	private void __closeEntry()
		throws IOException
	{
		// Lock
		LinkedList<__TOCEntry__> toc = this._toc;
		
		__InnerOutputStream__ inner = this._inner;
		__OuterOutputStream__ outer = this._outer;
		
		// {@squirreljme.error BF1b Cannot close entry because a current
		// one is not being used.}
		if (inner == null || outer == null)
			throw new IOException("BF1b");
		
		// Flush both sides
		inner.flush();
		outer.flush();
		
		// Need to fill the size information and CRC for later
		__TOCEntry__ last = toc.getLast();
		
		// Get sizes
		long uncomp = outer._size;
		long comp = inner._size;
		
		// {@squirreljme.error BF1c Either one or both of the compressed
		// or uncompressed file sizes exceeds 4GiB. (The uncompressed size;
		// The compressed size)}
		if (uncomp >= ZipStreamWriter._MAX_FILE_SIZE || comp >= ZipStreamWriter._MAX_FILE_SIZE)
			throw new IOException(String.format("BF1c %d %d", uncomp,
				comp));
		
		// Store sizes
		last._uncompressed = uncomp;
		last._compressed = comp;
		
		// Determine CRC
		int crc = outer.crccalc.checksum();
		last._crc = crc;
		
		// The magic number of the data descriptor is not needed, however
		// it helps prevent some abiguity when the input data stream is
		// not compressed and contains a ZIP file.
		ExtendedDataOutputStream output = this.output;
		output.writeInt(ZipStreamWriter._DATA_DESCRIPTOR_MAGIC_NUMBER);
		
		// Write CRC and sizes
		output.writeInt((int)crc);
		output.writeInt((int)comp);
		output.writeInt((int)uncomp);
		
		// Clear streams to allow for next entry
		this._inner = null;
		this._outer = null;
	}
	
	/**
	 * The inner and outer streams are very similar.
	 *
	 * @since 2016/07/15
	 */
	private abstract class __BaseOutputStream__
		extends OutputStream
	{
		/** The wrapped stream. */
		protected final OutputStream wrapped;
		
		/** Is the outer side finished? */
		protected boolean finished;
		
		/** The decompressed size. */
		volatile int _size;
		
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @param __os The output stream to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/07/15
		 */
		private __BaseOutputStream__(OutputStream __os)
			throws NullPointerException
		{
			// Check
			if (__os == null)
				throw new NullPointerException("NARG");
			
			// Set
			this.wrapped = __os;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public abstract void close()
			throws IOException;
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void flush()
			throws IOException
		{
			// Ignore if finished since the streams should be disconnected
			// at this time
			if (this.finished)
				return;
			
			// Forward flush
			this.wrapped.flush();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void write(int __b)
			throws IOException
		{
			// {@squirreljme.error BF1d Cannot write a single byte because
			// the stream is closed.}
			if (this.finished)
				throw new IOException("BF1d");
			
			// {@squirreljme.error BF1e Cannot write a single byte because
			// the ZIP entry would exceed 4GiB.}
			int oldsize = this._size, newsize = oldsize + 1;
			if (newsize < 0 || newsize < oldsize)
				throw new IOException("BF1e");
			
			// Write data and increase size
			this.wrapped.write(__b);
			this._size = newsize;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			// Check
			if (__b == null)
				throw new NullPointerException("NARG");
			int n = __b.length;
			if (__o < 0 || __l < 0 || (__o + __l) > n)
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BF1f Cannot write multiple bytes because
			// the stream is closed.}
			if (this.finished)
				throw new IOException("BF1f");
			
			// {@squirreljme.error BF1g Cannot write multiple bytes because
			// the ZIP entry would exceed 4GiB.}
			int oldsize = this._size, newsize = oldsize + __l;
			if (newsize < 0 || newsize < oldsize)
				throw new IOException("BF1g");
			
			// Write data and increase size
			this.wrapped.write(__b, __o, __l);
			this._size = newsize;
		}
	}
	
	/**
	 * This is an output stream which is used when writing an entry.
	 *
	 * @since 2016/07/15
	 */
	private final class __InnerOutputStream__
		extends __BaseOutputStream__
	{
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @since 2016/07/15
		 */
		private __InnerOutputStream__()
		{
			super(ZipStreamWriter.this.output);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public final void close()
			throws IOException
		{
			// Ignore if already finished
			if (this.finished)
				return;
			
			// Close and finish
			this.finished = true;
			ZipStreamWriter.this.__closeEntry();
		}
	}
	
	/**
	 * This is an output stream which is used when writing an entry.
	 *
	 * @since 2016/07/15
	 */
	private final class __OuterOutputStream__
		extends __BaseOutputStream__
	{
		/** CRC calculation. */
		protected final CRC32Calculator crccalc =
			new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
				ZipCRCConstants.CRC_REFLECT_REMAINDER,
				ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
				ZipCRCConstants.CRC_FINALXOR);
		
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @param __os The output stream to wrap.
		 * @since 2016/07/15
		 */
		private __OuterOutputStream__(OutputStream __os)
		{
			super(__os);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public final void close()
			throws IOException
		{
			// Ignore if already finished
			if (this.finished)
				return;
			
			// Close the wrapped stream
			this.finished = true;
			this.wrapped.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void flush()
			throws IOException
		{
			super.flush();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/16
		 */
		@Override
		public void write(int __b)
			throws IOException
		{
			// Send to output
			super.write(__b);
			
			// Calculate CRC
			this.crccalc.offer((byte)__b);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/16
		 */
		@Override
		public void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			// Send to output
			super.write(__b, __o, __l);
			
			// Calculate CRC
			this.crccalc.offer(__b, __o, __l);
		}
	}
}

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

package net.multiphasicapps.zip.streamwriter;

import net.multiphasicapps.zip.ZipCompressionType;

/**
 * This is used to store the temporary information which is used to later
 * write the central directory.
 *
 * @since 2016/07/15
 */
class __TOCEntry__
{
	/** The local file position. */
	final long _localposition;
	
	/** The name of the entry. */
	final byte[] _name;
	
	/** The compression type. */
	final ZipCompressionType _compression;
	
	/** The uncompressed size. */
	volatile long _uncompressed;
	
	/** The compressed size. */
	volatile long _compressed;
	
	/** The CRC32 of the entry. */
	volatile int _crc;
	
	/**
	 * Initializes the table of contents entry.
	 *
	 * @param __lfp The local file position.
	 * @param __name The file name.
	 * @param __comp The compression used.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	__TOCEntry__(long __lfp, byte[] __name, ZipCompressionType __comp)
		throws NullPointerException
	{
		// Check
		if (__name == null || __comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._localposition = __lfp;
		this._name = __name;
		this._compression = __comp;
	}
}

Added modules/zip/src/main/java/net/multiphasicapps/zip/streamwriter/package-info.java.






















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes which are used to write to ZIP files in a
 * stream based fashion. Entries are written one at a time and are directly
 * placed in the output stream. When the ZIP is closed the final index is
 * written.
 *
 * @since 2016/07/09
 */

package net.multiphasicapps.zip.streamwriter;

Changes to readme.mkd.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
57
58
59
60
61
62
63

64
65
66
67
68
69
70







-







 * [Contributing to SquirrelJME](contributing.mkd)
 * _End-User Documents_
   * [Building](building.mkd)
   * [Changelog](changelog.mkd)
   * [Compatibility](compatibility.mkd)
   * [History](history.mkd)
   * [Release Roadmap](route.mkd)
   * [Usage](usage.mkd)
 * _Developer Resources_
   * [CircleCI Status](
     https://circleci.com/gh/XerTheSquirrel/SquirrelJME/tree/trunk)
   * [Developer Guide](developer-guide.mkd)
   * [Developer Notes](assets/developer-notes/index.mkd)
   * [Design Document](design.mkd)
   * [Porting SquirrelJME](porting.mkd)

Deleted runt/TIMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Timespace-Title: Run Time
X-SquirrelJME-Timespace-Type: runtime
X-SquirrelJME-Timespace-Description: This contains everything which 
 should be available to the run-time for SquirrelJME.

Deleted runt/apis/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: APIs
X-SquirrelJME-Namespace-Type: api
X-SquirrelJME-Namespace-Description: This namespace contains 
 definitions and/or implementations of standard APIs.

Deleted runt/apis/cldc-compact.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/apis/cldc-compact.test/META-INF/services/util.serviceloader.ServiceThingy.

1
2
3



-
-
-
util.serviceloader.impls.CuteSquirrels
util.serviceloader.impls.ComfortableDrey
util.serviceloader.impls.StashTheAcorns

Deleted runt/apis/cldc-compact.test/io/TestReadLineEOF.in.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
result: int:5
thrown: NoExceptionThrown
secondary-line--1: string:Rodents\_are\_softly\_cute!
secondary-line--2: string:Squirrels!
secondary-line--3: string:Mice!
secondary-line--4: string:And\_rats!

Deleted runt/apis/cldc-compact.test/io/TestReadLineEOF.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















































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

package io;

import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests read line on EOF.
 *
 * @since 2018/12/08
 */
public class TestReadLineEOF
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(
			new ByteArrayInputStream(
			"Rodents are softly cute!\nSquirrels!\r\nMice!\rAnd rats!".
			getBytes("utf-8")), "utf-8"));
		
		String ln;
		int i = 1;
		while (null != (ln = br.readLine()))
			this.secondary("line-" + (i++), ln);
		
		return i;
	}
}

Deleted runt/apis/cldc-compact.test/io/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * IO Tests.
 *
 * @since 2018/12/08
 */

package io;

Deleted runt/apis/cldc-compact.test/lang/TestArray.in.

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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-boolean--0: false
secondary-boolean--1: true
secondary-boolean--2: false
secondary-boolean--3: false
secondary-boolean--4: true
secondary-boolean--5: false
secondary-boolean--6: false
secondary-boolean--7: false
secondary-byte--0: byte:10
secondary-byte--1: byte:79
secondary-byte--2: byte:46
secondary-byte--3: byte:95
secondary-byte--4: byte:-102
secondary-byte--5: byte:1
secondary-byte--6: byte:121
secondary-byte--7: byte:0
secondary-char--0: char:35618
secondary-char--1: char:2365
secondary-char--2: char:55767
secondary-char--3: char:32692
secondary-char--4: char:41045
secondary-char--5: char:62683
secondary-char--6: char:38834
secondary-char--7: char:12892
secondary-double--0: long:4602249605880005352
secondary-double--1: long:4604568770661008052
secondary-double--2: long:4605565894347753078
secondary-double--3: long:4606776481611615370
secondary-double--4: long:4604912020652972472
secondary-double--5: long:4605705353082206991
secondary-double--6: long:4592761750090831968
secondary-double--7: long:4605403023904893675
secondary-float--0: int:1054137296
secondary-float--1: int:1062125601
secondary-float--2: int:1055303542
secondary-float--3: int:1057111330
secondary-float--4: int:1062160289
secondary-float--5: int:1059716047
secondary-float--6: int:1064508947
secondary-float--7: int:1051431500
secondary-int--0: int:-540490261
secondary-int--1: int:7073627
secondary-int--2: int:-1882904776
secondary-int--3: int:2037297493
secondary-int--4: int:1647086087
secondary-int--5: int:-141001931
secondary-int--6: int:849191592
secondary-int--7: int:-1122918633
secondary-long--0: long:-4071615891382181537
secondary-long--1: long:5902863659456241668
secondary-long--2: long:-6162285531878494405
secondary-long--3: long:-1914963148333505296
secondary-long--4: long:-3532328660556861777
secondary-long--5: long:-4041979462155839005
secondary-long--6: long:-8032429601186284395
secondary-long--7: long:-574384260408492771
secondary-short--0: short:-1257
secondary-short--1: short:-17981
secondary-short--2: short:-3792
secondary-short--3: short:-8768
secondary-short--4: short:9375
secondary-short--5: short:-30486
secondary-short--6: short:25991
secondary-short--7: short:3726

Deleted runt/apis/cldc-compact.test/lang/TestArray.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
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
































































































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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that arrays work properly.
 *
 * @since 2018/11/14
 */
public class TestArray
	extends TestRunnable
{
	/** Storage count. */
	public static final int COUNT =
		8;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0x4C6F7665596F7521L);
		
		// Store values
		boolean az[] = new boolean[COUNT];
		for (int i = 0; i < COUNT; i++)
			az[i] = rand.nextBoolean();
		
		byte ab[] = new byte[COUNT];
		for (int i = 0; i < COUNT; i++)
			ab[i] = (byte)rand.nextInt();
		
		short as[] = new short[COUNT];
		for (int i = 0; i < COUNT; i++)
			as[i] = (short)rand.nextInt();
		
		char ac[] = new char[COUNT];
		for (int i = 0; i < COUNT; i++)
			ac[i] = (char)rand.nextInt();
		
		int ai[] = new int[COUNT];
		for (int i = 0; i < COUNT; i++)
			ai[i] = rand.nextInt();
		
		long al[] = new long[COUNT];
		for (int i = 0; i < COUNT; i++)
			al[i] = rand.nextLong();
		
		float af[] = new float[COUNT];
		for (int i = 0; i < COUNT; i++)
			af[i] = rand.nextFloat();
		
		double ad[] = new double[COUNT];
		for (int i = 0; i < COUNT; i++)
			ad[i] = rand.nextDouble();
		
		// Read all values
		for (int i = 0; i < COUNT; i++)
			this.secondary("boolean-" + i, az[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("byte-" + i, ab[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("short-" + i, as[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("char-" + i, ac[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("int-" + i, ai[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("long-" + i, al[i]);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("float-" + i, Float.floatToRawIntBits(af[i]));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary("double-" + i, Double.doubleToRawLongBits(ad[i]));
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestArrayClone.in.

1
2


-
-
result: true
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestArrayClone.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 lang;

import java.util.Arrays;
import net.multiphasicapps.tac.TestBoolean;

/**
 * This tests that array cloning is correct.
 *
 * @since 2019/12/25
 */
public class TestArrayClone
	extends TestBoolean
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public final boolean test()
	{
		// Setup new array
		int[] array = new int[12];
		for (int i = 0; i < 12; i++)
			array[i] = i;
		
		int[] cloned = array.clone();
		return Arrays.equals(array, cloned) && array != cloned;
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestBitCount.in.

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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: int:516
thrown: NoExceptionThrown
secondary---1311576848: int:17
secondary---1332382087: int:17
secondary---1340642358: int:16
secondary---1415577226: int:13
secondary---1423971382: int:20
secondary---1492189590: int:19
secondary---1551205178: int:16
secondary---1874748849: int:13
secondary---1880491709: int:19
secondary---2056315975: int:18
secondary---2068379663: int:16
secondary---289506626: int:23
secondary---333491629: int:17
secondary---439795945: int:19
secondary---458098343: int:18
secondary---516743031: int:12
secondary---610984458: int:20
secondary---668136350: int:13
secondary---727125616: int:14
secondary---758524624: int:15
secondary-1069159422: int:21
secondary-1141137495: int:10
secondary-1254667026: int:13
secondary-1695406993: int:16
secondary-181321777: int:12
secondary-1831602766: int:14
secondary-1883960650: int:15
secondary-1966145181: int:19
secondary-2126472996: int:20
secondary-27286603: int:11
secondary-36993251: int:13
secondary-993338671: int:17

Deleted runt/apis/cldc-compact.test/lang/TestBitCount.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



















































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

package lang;

import java.util.Random;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the number of bits in values.
 *
 * @since 2018/11/11
 */
public class TestBitCount
	extends TestSupplier<Integer>
{
	/** The number of values to count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		Random rand = new Random(0xDEADBEEF);
		
		int rv = 0;
		for (int i = 0; i < COUNT; i++)
		{
			int test = rand.nextInt(),
				bits = Integer.bitCount(test);
			
			this.secondary("" + test, bits);
			
			rv += bits;
		}
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestDivideByZero.in.

1
2
3



-
-
-
result: ExceptionThrown
thrown: throwable:ArithmeticException

Deleted runt/apis/cldc-compact.test/lang/TestDivideByZero.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

































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests division by zero.
 *
 * @since 2018/12/04
 */
public class TestDivideByZero
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Integer test()
	{
		return 42 / 0;
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestEnumValueOf.in.

1
2


-
-
result: string:ABYou\_are\_beautiful!You\_are\_wonderful!
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestEnumValueOf.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






































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

package lang;

import lang.extra.ABasicEnum;
import lang.extra.AClassEnum;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests enumerations.
 *
 * @since 2018/12/08
 */
public class TestEnumValueOf
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public String test()
	{
		return ABasicEnum.A.name() +
			Enum.<ABasicEnum>valueOf(ABasicEnum.class, "B") +
			AClassEnum.B.boop() +
			Enum.<AClassEnum>valueOf(AClassEnum.class, "C").boop();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestExceptionCatchUp.in.

1
2
3



-
-
-
result: ExceptionThrown
thrown: throwable:IllegalArgumentException

Deleted runt/apis/cldc-compact.test/lang/TestExceptionCatchUp.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





























































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

package lang;

import net.multiphasicapps.tac.TestSupplier;
import java.util.NoSuchElementException;

/**
 * Tests exceptions being caught in higher stack frames.
 *
 * @since 2018/12/06
 */
public class TestExceptionCatchUp
	extends TestSupplier<String>
{
	/**
	 * Throws an exception.
	 *
	 * @since 2018/12/06
	 */
	public final String levelA()
	{
		return this.levelB();
	}
	
	/**
	 * Throws an exception.
	 *
	 * @since 2018/12/06
	 */
	public final String levelB()
	{
		throw new NoSuchElementException("TEST");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String test()
	{
		try
		{
			return this.levelA();
		}
		catch (NoSuchElementException t)
		{
			throw new IllegalArgumentException(t);
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestHoldLock.in.

1
2
3
4
5





-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-before: false
secondary-during: true
secondary-after: false

Deleted runt/apis/cldc-compact.test/lang/TestHoldLock.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








































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that the current thread holds the lock.
 *
 * @since 2018/11/21
 */
public class TestHoldLock
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		this.secondary("before", Thread.holdsLock(this));
		
		synchronized (this)
		{
			this.secondary("during", Thread.holdsLock(this));
		}
		
		this.secondary("after", Thread.holdsLock(this));
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestInnerClassOnProtected.in.

1
2


-
-
result: int:1234
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestInnerClassOnProtected.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
























































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests a member inner class being able to access a protected member in the
 * parent class.
 *
 * @since 2018/10/13
 */
public class TestInnerClassOnProtected
	extends TestSupplier<Integer>
{
	/** The value to use. */
	protected int value;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public Integer test()
	{
		new Inner();
		return this.value;
	}
	
	/**
	 * Inner class.
	 *
	 * @since 2018/10/13
	 */
	public class Inner
	{
		/**
		 * Sets the value.
		 *
		 * @since 2018/10/13
		 */
		public Inner()
		{
			TestInnerClassOnProtected.this.value = 1234;
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestIntegerDecode.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: int:15882
thrown: NoExceptionThrown
secondary--h1234: int:4660
secondary--p-h1234: int:4660
secondary--p01234: int:668
secondary--p0x1234: int:4660
secondary--p1234: int:1234
secondary----h1234: int:-4660
secondary---01234: int:-668
secondary---0x1234: int:-4660
secondary---1234: int:-1234
secondary-01234: int:668
secondary-0x1234: int:4660
secondary-1234: int:1234

Deleted runt/apis/cldc-compact.test/lang/TestIntegerDecode.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






























































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests integer decoding.
 *
 * @since 2018/11/11
 */
public class TestIntegerDecode
	extends TestSupplier<Integer>
{
	/** Values to test. */
	private static final String[] _VALUES =
		new String[]
		{
			"0x1234",
			"0X1234",
			"#1234",
			"01234",
			"1234",
			"-0x1234",
			"-0X1234",
			"-#1234",
			"-01234",
			"-1234",
			"+0x1234",
			"+0X1234",
			"+#1234",
			"+01234",
			"+1234",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		int rv = 0;
		for (String s : _VALUES)
		{
			int v = Integer.decode(s);
			rv += v;
			this.secondary(s, v);
		}
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestIntegerParseIntOverflow.in.

1
2


-
-
result: string:23456789abcdefghijklmnopqrstuvwxyz\0
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestIntegerParseIntOverflow.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





















































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * This tests that {@link Integer#parseInt(int, int)} when the input value
 * overflows it throws an exception.
 *
 * @since 2018/10/13
 */
public class TestIntegerParseIntOverflow
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String test()
	{
		StringBuilder sb = new StringBuilder();
		
		// Check overflow for all radixes
		int rv = 0;
		for (int r = Character.MIN_RADIX; r <= Character.MAX_RADIX; r++)
			try
			{
				// This is a really long value which is valid for all radixes
				// it is either a 33-bit integer or log(33)??
				Integer.parseInt("-111111111111111111111111111111111", r);
				
				sb.append(Character.toUpperCase(
					Character.forDigit(r, Character.MAX_RADIX)));
			}
			catch (NumberFormatException e)
			{
				sb.append(Character.forDigit(r, Character.MAX_RADIX));
			}
		
		return sb.toString();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestIntegerParseIntOverflowMax.in.

1
2


-
-
result: string:23456789abcdefghijklmnopqrstuvwxyz\0
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestIntegerParseIntOverflowMax.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




























































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * This tests that {@link Integer#parseInt(int, int)} when the input value
 * overflows it throws an exception, but where each character is the max for
 * the given radix.
 *
 * @since 2018/10/13
 */
public class TestIntegerParseIntOverflowMax
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String test()
	{
		StringBuilder sb = new StringBuilder();
		
		// Check overflow for all radixes
		int rv = 0;
		for (int r = Character.MIN_RADIX; r <= Character.MAX_RADIX; r++)
			try
			{
				// This is a really long value which is valid for all radixes
				// it is either a 33-bit integer or log(33)??
				char c = Character.forDigit(r - 1, r);
				StringBuilder seq = new StringBuilder("-");
				for (int i = 0; i < 33; i++)
					seq.append(c);
				
				// Decode that max value
				Integer.parseInt(seq.toString(), r);
				
				sb.append(Character.toUpperCase(
					Character.forDigit(r, Character.MAX_RADIX)));
			}
			catch (NumberFormatException e)
			{
				sb.append(Character.forDigit(r, Character.MAX_RADIX));
			}
		
		return sb.toString();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestInvokePrivate.in.

1
2
3



-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-private: true

Deleted runt/apis/cldc-compact.test/lang/TestInvokePrivate.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











































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that private calls can be done.
 *
 * @since 2018/10/10
 */
public class TestInvokePrivate
	extends TestRunnable
{
	/**
	 * Private call.
	 *
	 * @since 2018/10/10
	 */
	private void doPrivate()
	{
		this.secondary("private", true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doPrivate();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestInvokePrivateInSuper.in.

1
2
3
4




-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-superprivate: true

Deleted runt/apis/cldc-compact.test/lang/TestInvokePrivateInSuper.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











































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

package lang;

/**
 * Tests calling a private method where the extending class also has a method
 * with the same name and descriptor, but is public.
 *
 * @since 2018/10/10
 */
public class TestInvokePrivateInSuper
	extends __InvokePrivateInSuper__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doSuper();
	}
	
	/**
	 * Private method in current class, named the same but is public since it
	 * was hidden in a super class.
	 *
	 * @since 2018/10/10
	 */
	public void doPrivate()
	{
		this.secondary("instanceprivatewascalled", false);
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestInvokeSuper.in.

1
2
3
4
5





-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-childbefore: true
secondary-super: true
secondary-childafter: true

Deleted runt/apis/cldc-compact.test/lang/TestInvokeSuper.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













































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

package lang;

/**
 * Tests that super calls can be done.
 *
 * @since 2018/10/10
 */
public class TestInvokeSuper
	extends __InvokeSuper__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void doSuper()
	{
		this.secondary("childbefore", true);
		
		super.doSuper();
		
		this.secondary("childafter", true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public void test()
	{
		this.doSuper();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestMathLog.in.

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










































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-random----1432335638160804534: long:-2251799813685248
secondary-random----1888909202756794383: long:-2251799813685248
secondary-random----1967517401509503925: long:-2251799813685248
secondary-random----2219394418870420802: long:-2251799813685248
secondary-random----2624158267349034417: long:-2251799813685248
secondary-random----3122980739108447343: long:-2251799813685248
secondary-random----3339783707453616697: long:-2251799813685248
secondary-random----5400592651466114974: long:-2251799813685248
secondary-random----5722537487475081571: long:-2251799813685248
secondary-random----6115910518010414781: long:-2251799813685248
secondary-random----6408905489149784990: long:-2251799813685248
secondary-random----6437715043167905200: long:-2251799813685248
secondary-random----7033748006474773329: long:-2251799813685248
secondary-random----7867116347168471483: long:-2251799813685248
secondary-random----8831809862686031823: long:-2251799813685248
secondary-random--1255568899445664322: long:-4575623698181355925
secondary-random--1434825769210690147: long:-4576075885753216990
secondary-random--158884801877076938: long:-4574139165859803029
secondary-random--2180097264311650148: long:-4578093203530993396
secondary-random--2343294179524792790: long:-4578535680152507644
secondary-random--3018518297123294602: long:-4580566804536331392
secondary-random--4266357105038578992: long:-4590800524580975423
secondary-random--4592004750388686064: long:-4611046322738335769
secondary-random--5388753842488376518: long:4638169200724828892
secondary-random--5404559425704385608: long:4638337402247354041
secondary-random--5662129423103150469: long:4639918514832386509
secondary-random--6377033640133724733: long:4643499723705780022
secondary-random--7197361914604609929: long:4645721385009566601
secondary-random--7843894698618392042: long:4647472167532842776
secondary-random--7866673980374278231: long:4647533729646704837
secondary-random--8572265387981001411: long:4648579681512836525
secondary-random--9133131972231561590: long:4649338522149113304
secondary-value----01: long:-2251799813685248
secondary-value----02: long:-2251799813685248
secondary-value--000: long:-4503599627370496
secondary-value--001: long:0
secondary-value--002: long:4604418534313441775
secondary-value--003: long:4607626529066517258
original-ulp-secondary-value--003: long:4607626529066517259
secondary-value--004: long:4608922133940812271
secondary-value--005: long:4609927083155361075
secondary-value--006: long:4610748186450599938
secondary-value--007: long:4611442419394828887
secondary-value--008: long:4611864904876141427
secondary-value--009: long:4612130128693887755
secondary-value--010: long:4612367379483415830
secondary-value--011: long:4612581998928541516
secondary-value--012: long:4612777931131035261
secondary-value--013: long:4612958171285261393
secondary-value--014: long:4613125047603149735
secondary-value--015: long:4613280405738309663
secondary-value--016: long:4613425733568182767
secondary-value--017: long:4613562248080293754
secondary-value--018: long:4613690957385929094
secondary-value--019: long:4613812705944711980
secondary-value--020: long:4613928208175457169
secondary-value--021: long:4614038073858043569
secondary-value--022: long:4614142827620582856
secondary-value--023: long:4614242924091257840
secondary-value--024: long:4614338759823076601
secondary-value--025: long:4614430682782731571
secondary-value--026: long:4614518999977302733
secondary-value--027: long:4614603983640822928
secondary-value--028: long:4614685876295191075
secondary-value--029: long:4614764894922604063
secondary-value--030: long:4614841234430351003
secondary-value--031: long:4614915070547274586
secondary-value--032: long:4614986562260224107
secondary-value--033: long:4615055853875476689
secondary-value--034: long:4615123076772335094
secondary-value--035: long:4615188350902465477
secondary-value--036: long:4615251786077970434
secondary-value--037: long:4615313483082942397
secondary-value--038: long:4615373534636753320
secondary-value--039: long:4615432026232196566
secondary-value--040: long:4615489036867498509
secondary-value--041: long:4615544639687928910
secondary-value--042: long:4615598902550084909
secondary-value--043: long:4615651888519769105
secondary-value--044: long:4615703656312624195
secondary-value--045: long:4615754260685244836
secondary-value--046: long:4615803752783299180
secondary-value--047: long:4615852180452208822
secondary-value--048: long:4615899588515117940
original-ulp-secondary-value--048: long:4615899588515117941
secondary-value--049: long:4615946019022199383
secondary-value--050: long:4615991511474772911
secondary-value--051: long:4616036103027228927
secondary-value--052: long:4616079828669344073
secondary-value--053: long:4616122721391230123
secondary-value--054: long:4616164812332864268
secondary-value--055: long:4616197874487328499
secondary-value--056: long:4616218161520995408
secondary-value--057: long:4616238089473202777
secondary-value--058: long:4616257670834701901
secondary-value--059: long:4616276917455628665
secondary-value--060: long:4616295840588575371
secondary-value--061: long:4616314450928102413
secondary-value--062: long:4616332758647037163
secondary-value--063: long:4616350773429868571
secondary-value--064: long:4616368504503511923
secondary-value--065: long:4616385960665688437
secondary-value--066: long:4616403150311138214
secondary-value--067: long:4616420081455862061
secondary-value--068: long:4616436761759567417
secondary-value--069: long:4616453198546475707
secondary-value--070: long:4616469398824632609
secondary-value--071: long:4616485369303848649
secondary-value--072: long:4616501116412385087
secondary-value--073: long:4616516646312488934
secondary-value--074: long:4616531964914871068
original-ulp-secondary-value--074: long:4616531964914871069
secondary-value--075: long:4616547077892212572
secondary-value--076: long:4616561990691776530
secondary-value--077: long:4616576708547195452
secondary-value--078: long:4616591236489498153
secondary-value--079: long:4616605579357434227
secondary-value--080: long:4616619741807149124
secondary-value--081: long:4616633728321258251
secondary-value--082: long:4616647543217364325
secondary-value--083: long:4616661190656058498
secondary-value--084: long:4616674674648442324
secondary-value--085: long:4616687999063204618
secondary-value--086: long:4616701167633284422
secondary-value--087: long:4616714183962148818
secondary-value--088: long:4616727051529711968
secondary-value--089: long:4616739773697919734
secondary-value--090: long:4616752353716022288
secondary-value--091: long:4616764794725555390
secondary-value--092: long:4616777099765049460
secondary-value--093: long:4616789271774484080
secondary-value--094: long:4616801313599504281
secondary-value--095: long:4616813227995413731
secondary-value--096: long:4616825017630958840
secondary-value--097: long:4616836685091916792
secondary-value--098: long:4616848232884499562
secondary-value--099: long:4616859663438585131
secondary-value--100: long:4616870979110786326
secondary-value--101: long:4616882182187366961
secondary-value--102: long:4616893274887014333
secondary-value--103: long:4616904259363476460
secondary-value--104: long:4616915137708071906
secondary-value--105: long:4616925911952079525
secondary-value--106: long:4616936584069014931
secondary-value--107: long:4616947155976800091
secondary-value--108: long:4616957629539832004
secondary-value--109: long:4616968006570956038
secondary-value--110: long:4616978288833349169
secondary-value--111: long:4616988478042317985
secondary-value--112: long:4616998575867016077
secondary-value--113: long:4617008583932085084
secondary-value--114: long:4617018503819223447
secondary-value--115: long:4617028337068686661
secondary-value--116: long:4617038085180722571
secondary-value--117: long:4617047749616945070
secondary-value--118: long:4617057331801649335
secondary-value--119: long:4617066833123071571
secondary-value--120: long:4617076254934596041
secondary-value--121: long:4617085598555912012
secondary-value--122: long:4617094865274123083
secondary-value--123: long:4617104056344811241
secondary-value--124: long:4617113172993057833
secondary-value--125: long:4617122216414423527
secondary-value--126: long:4617131187775889241
secondary-value--127: long:4617140088216759874
secondary-value--128: long:4617148918849532593


Deleted runt/apis/cldc-compact.test/lang/TestMathLog.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





















































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

package lang;

import net.multiphasicapps.tac.TestRunnable;
import java.util.Random;

/**
 * Tests the log of a number.
 *
 * @since 2018/11/03
 */
public class TestMathLog
	extends TestRunnable
{
	/** Random sequence count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	@SuppressWarnings({"deprecated"})
	public void test()
	{
		// Linear sequence of values
		for (int i = -2; i <= 128; i++)
			this.secondary(String.format("value-%03d", i),
				Double.doubleToRawLongBits(Math.log(i)));
		
		// Random sequence of bits, generate NaN and such
		Random rand = new Random(0xDEADBEEF);
		for (int i = 0; i < COUNT; i++)
		{
			long raw = rand.nextLong();
			this.secondary(String.format("random-%d", raw),
				Double.doubleToRawLongBits(Math.log(
					Double.longBitsToDouble(raw))));
		}
	}
}


Deleted runt/apis/cldc-compact.test/lang/TestMathSqrt.in.

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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-value----01: long:-2251799813685248
secondary-value----02: long:-2251799813685248
secondary-value--000: long:0
secondary-value--001: long:4607182418800017408
secondary-value--002: long:4609047870845172685
secondary-value--003: long:4610479282544200874
secondary-value--004: long:4611686018427387904
secondary-value--005: long:4612217596255138984
secondary-value--006: long:4612698179346440494
secondary-value--007: long:4613140121109330154
secondary-value--008: long:4613551470472543181
secondary-value--009: long:4613937818241073152
secondary-value--010: long:4614303235046005587
secondary-value--011: long:4614650793885003572
secondary-value--012: long:4614982882171571370
secondary-value--013: long:4615301398490339827
secondary-value--014: long:4615607882206429001
secondary-value--015: long:4615903601977413338
secondary-value--016: long:4616189618054758400
secondary-value--017: long:4616328222667173127
secondary-value--018: long:4616462807181782233
secondary-value--019: long:4616593702341856761
secondary-value--020: long:4616721195882509480
secondary-value--021: long:4616845539975437957
secondary-value--022: long:4616966957094426279
secondary-value--023: long:4617085644692718614
secondary-value--024: long:4617201778973810990
secondary-value--025: long:4617315517961601024
secondary-value--026: long:4617427004022730742
secondary-value--027: long:4617536365956053376
secondary-value--028: long:4617643720736700650
secondary-value--029: long:4617749174982072819
secondary-value--030: long:4617852826192094607
secondary-value--031: long:4617954763804819907
secondary-value--032: long:4618055070099913677
secondary-value--033: long:4618153820975976688
secondary-value--034: long:4618251086622598050
secondary-value--035: long:4618346932104053293
secondary-value--036: long:4618441417868443648
secondary-value--037: long:4618534600193596473
secondary-value--038: long:4618626531579070041
secondary-value--039: long:4618717261092017034
secondary-value--040: long:4618806834673376083
secondary-value--041: long:4618895295409815296
secondary-value--042: long:4618982683775996516
secondary-value--043: long:4619069037851025760
secondary-value--044: long:4619154393512374068
secondary-value--045: long:4619238784610070268
secondary-value--046: long:4619322243123564579
secondary-value--047: long:4619404799303324646
secondary-value--048: long:4619486481798941866
secondary-value--049: long:4619567317775286272
secondary-value--050: long:4619647333018045120
secondary-value--051: long:4619726552029807566
secondary-value--052: long:4619804998117710323
secondary-value--053: long:4619882693473532905
secondary-value--054: long:4619959659247022534
secondary-value--055: long:4620035915613135320
secondary-value--056: long:4620111481833799497
secondary-value--057: long:4620186376314736476
secondary-value--058: long:4620260616657814640
secondary-value--059: long:4620334219709357787
secondary-value--060: long:4620407201604783834
secondary-value--061: long:4620479577809908840
secondary-value--062: long:4620551363159215890
secondary-value--063: long:4620622571891357023
secondary-value--064: long:4620693217682128896
secondary-value--065: long:4620728265678633680
secondary-value--066: long:4620763045096241164
secondary-value--067: long:4620797562016421003
secondary-value--068: long:4620831822294543623
secondary-value--069: long:4620865831571476489
secondary-value--070: long:4620899595284426715
secondary-value--071: long:4620933118677089030
secondary-value--072: long:4620966406809152729
secondary-value--073: long:4620999464565216419
secondary-value--074: long:4621032296663155022
secondary-value--075: long:4621064907661979627
secondary-value--076: long:4621097301969227257
secondary-value--077: long:4621129483847914467
secondary-value--078: long:4621161457423085828
secondary-value--079: long:4621193226687985776
secondary-value--080: long:4621224795509879976
secondary-value--081: long:4621256167635550208
secondary-value--082: long:4621287346696484900
secondary-value--083: long:4621318336213785640
secondary-value--084: long:4621349139602808453
secondary-value--085: long:4621379760177557146
secondary-value--086: long:4621410201154844724
secondary-value--087: long:4621440465658237670
secondary-value--088: long:4621470556721796775
secondary-value--089: long:4621500477293627201
secondary-value--090: long:4621530230239249534
secondary-value--091: long:4621559818344802731
secondary-value--092: long:4621589244320089110
secondary-value--093: long:4621618510801470784
secondary-value--094: long:4621647620354626310
secondary-value--095: long:4621676575477175713
secondary-value--096: long:4621705378601181486
secondary-value--097: long:4621734032095532642
secondary-value--098: long:4621762538268218451
secondary-value--099: long:4621790899368498023
secondary-value--100: long:4621819117588971520
secondary-value--101: long:4621847195067558384
secondary-value--102: long:4621875133889387642
secondary-value--103: long:4621902936088605011
secondary-value--104: long:4621930603650101238
secondary-value--105: long:4621958138511165833
secondary-value--106: long:4621985542563070088
secondary-value--107: long:4622012817652583048
secondary-value--108: long:4622039965583423872
secondary-value--109: long:4622066988117653815
secondary-value--110: long:4622093886977010867
secondary-value--111: long:4622120663844189920
secondary-value--112: long:4622147320364071146
secondary-value--113: long:4622173858144899126
secondary-value--114: long:4622200278759415130
secondary-value--115: long:4622226583745944792
secondary-value--116: long:4622252774609443315
secondary-value--117: long:4622278852822500215
secondary-value--118: long:4622304819826305498
secondary-value--119: long:4622330677031579077
secondary-value--120: long:4622356425819465103
secondary-value--121: long:4622382067542392832
secondary-value--122: long:4622407603524905544
secondary-value--123: long:4622433035064458942
secondary-value--124: long:4622458363432190403
secondary-value--125: long:4622483589873660370
secondary-value--126: long:4622508715609567095
secondary-value--127: long:4622533741836435920
secondary-value--128: long:4622558669727284173
secondary-random----1432335638160804534: long:-2251799813685248
secondary-random----1888909202756794383: long:-2251799813685248
secondary-random----1967517401509503925: long:-2251799813685248
secondary-random----2219394418870420802: long:-2251799813685248
secondary-random----2624158267349034417: long:-2251799813685248
secondary-random----3122980739108447343: long:-2251799813685248
secondary-random----3339783707453616697: long:-2251799813685248
secondary-random----5400592651466114974: long:-2251799813685248
secondary-random----5722537487475081571: long:-2251799813685248
secondary-random----6115910518010414781: long:-2251799813685248
secondary-random----6408905489149784990: long:-2251799813685248
secondary-random----6437715043167905200: long:-2251799813685248
secondary-random----7033748006474773329: long:-2251799813685248
secondary-random----7867116347168471483: long:-2251799813685248
secondary-random----8831809862686031823: long:-2251799813685248
secondary-random--1255568899445664322: long:2931362841864629624
secondary-random--1434825769210690147: long:3020952646369542971
secondary-random--158884801877076938: long:2382994875329581799
secondary-random--2180097264311650148: long:3393322263858566792
secondary-random--2343294179524792790: long:3475077629777803516
secondary-random--3018518297123294602: long:3812650250847330100
secondary-random--4266357105038578992: long:4436719366953915272
secondary-random--4592004750388686064: long:4599421220444606324
secondary-random--5388753842488376518: long:4997901707625293227
secondary-random--5404559425704385608: long:5005532053458444485
secondary-random--5662129423103150469: long:5134625659391588651
secondary-random--6377033640133724733: long:5491730931508304087
secondary-random--7197361914604609929: long:5901998413481527113
secondary-random--7843894698618392042: long:6225333553435010730
secondary-random--7866673980374278231: long:6236909802700178660
secondary-random--8572265387981001411: long:6589639284353588013
secondary-random--9133131972231561590: long:6869795181514067063

Deleted runt/apis/cldc-compact.test/lang/TestMathSqrt.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



















































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

package lang;

import net.multiphasicapps.tac.TestRunnable;
import java.util.Random;

/**
 * Tests the square root of a number.
 *
 * @since 2018/11/03
 */
public class TestMathSqrt
	extends TestRunnable
{
	/** Random sequence count. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public void test()
	{
		// Linear sequence of values
		for (int i = -2; i <= 128; i++)
			this.secondary(String.format("value-%03d", i),
				Double.doubleToRawLongBits(Math.sqrt(i)));
		
		// Random sequence of bits, generate NaN and such
		Random rand = new Random(0xDEADBEEF);
		for (int i = 0; i < COUNT; i++)
		{
			long raw = rand.nextLong();
			this.secondary(String.format("random-%d", raw),
				Double.doubleToRawLongBits(Math.sqrt(
					Double.longBitsToDouble(raw))));
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestMonitorNotify.in.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-after--lock: int:7
secondary-before--lock: int:0
secondary-expected--resume: int:6
secondary-in--lock: int:1
secondary-sub--after--notify: int:4
secondary-sub--after--sleep: int:5
secondary-sub--in--lock: int:3
secondary-thread--created: int:2

Deleted runt/apis/cldc-compact.test/lang/TestMonitorNotify.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
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


















































































































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that monitor notification works.
 *
 * @since 2018/11/21
 */
public class TestMonitorNotify
	extends TestRunnable
{
	/** Counter. */
	volatile int _count;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		// Note
		this.secondary("before-lock", this._count++);
		
		// Lock the monitor for this
		synchronized (this)
		{
			// Note
			this.secondary("in-lock", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Sub__(), "MonitorNotifyTest");
			t.start();
			
			// Note
			this.secondary("thread-created", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				this.wait();
				
				// Note
				this.secondary("expected-resume", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock", this._count++);
	}
	
	/**
	 * Sub-thread which runs.
	 *
	 * @since 2018/11/21
	 */
	final class __Sub__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/21
		 */
		@Override
		public void run()
		{
			// Lock on that monitor
			TestMonitorNotify tmn = TestMonitorNotify.this;
			synchronized (tmn)
			{
				// Note
				tmn.secondary("sub-in-lock", tmn._count++);
				
				// Notify other thread
				tmn.notify();
				
				// Note
				tmn.secondary("sub-after-notify", tmn._count++);
				
				// Sleep for a bit, for sanity
				try
				{
					Thread.sleep(1000);
				}
				catch (InterruptedException e)
				{
				}
				
				// Sub continued
				tmn.secondary("sub-after-sleep", tmn._count++);
			}
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestMultiANewArray.in.

1
2
3
4




-
-
-
-
result: string:[[[Ljava.lang.Integer;
thrown: NoExceptionThrown
secondary-total: int:168

Deleted runt/apis/cldc-compact.test/lang/TestMultiANewArray.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


















































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests allocation of a multi-dimensional array.
 *
 * @since 2018/11/03
 */
public class TestMultiANewArray
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public String test()
	{
		// Allocate array
		Integer[][][] array = new Integer[6][7][4];
		
		// Determine the number of elements
		int total = 0;
		for (int i = 0, in = array.length; i < in; i++)
		{
			// Down to next level
			Integer[][] subi = array[i];
			for (int j = 0, jn = subi.length; j < jn; j++)
				total += subi[j].length;
		}
		
		// Is this time
		this.secondary("total", total);
		
		// Use the name of it
		return array.getClass().getName();
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestNewInstance.in.

1
2


-
-
result: string:Hello\_squirrels\_are\_cute!
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestNewInstance.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




















































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests new class instance.
 *
 * @since 2018/12/04
 */
public class TestNewInstance
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String test()
		throws Throwable
	{
		return SpawnedClass.class.newInstance().toString();
	}
	
	/**
	 * The class to be spawed.
	 *
	 * @since 2018/12/04
	 */
	public static final class SpawnedClass
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public String toString()
		{
			return "Hello squirrels are cute!";
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestStringIntern.in.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-cca: false
secondary-ccb: true
secondary-cna: false
secondary-cnb: false
secondary-cia: false
secondary-cib: true
secondary-cxa: false
secondary-cxb: true
secondary-iia: false
secondary-iib: true

Deleted runt/apis/cldc-compact.test/lang/TestStringIntern.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that string interning works properly.
 *
 * @since 2019/05/24
 */
public class TestStringIntern
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/24
	 */
	@Override
	public void test()
	{
		this.secondary("cca", "squirrel" == "acorn");
		this.secondary("ccb", "squirrel" == "squirrel");
		
		this.secondary("cna", "squirrel" == new String("acorn"));
		this.secondary("cnb", "squirrel" == new String("squirrel"));
		
		this.secondary("cia", "squirrel" == "acorn".intern());
		this.secondary("cib", "squirrel" == "squirrel".intern());
		
		this.secondary("cxa",
			"squirrel" == new String("acorn").intern());
		this.secondary("cxb",
			"squirrel" == new String("squirrel").intern());
			
		this.secondary("iia", "squirrel".intern() ==
			new String("acorn").intern());
		this.secondary("iib", "squirrel".intern() ==
			new String("squirrel").intern());
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestStringRegionMatches.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-adorablec: false
secondary-adorablei: true
secondary-arec: true
secondary-arei: true
secondary-helloc: false
secondary-helloi: true
secondary-neglenc: true
secondary-negleni: true
secondary-samec: true
secondary-samehalfc: true
secondary-samehalfi: true
secondary-samei: true
secondary-samenegac: false
secondary-samenegai: false
secondary-samenegbc: false
secondary-samenegbi: false
secondary-sameoverc: false
secondary-sameoveri: false
secondary-squirrelsc: false
secondary-squirrelsi: true

Deleted runt/apis/cldc-compact.test/lang/TestStringRegionMatches.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that {@link String#regionMatches(boolean, int, String, int, int, int)}
 * is working.
 *
 * @since 2020/01/18
 */
public class TestStringRegionMatches
	extends TestRunnable
{
	/** String A. */
	public static final String A =
		"Hello! Squirrels are adorable!";
	
	/** String B. */
	public static final String B =
		"AdoRable squirRels are hello!";
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/18
	 */
	@Override
	public void test()
	{
		for (boolean igncase = false;; igncase = true)
		{
			char key = (igncase ? 'i' : 'c');
			
			this.secondary("same" + key,
				A.regionMatches(igncase, 0, A, 0, A.length()));
				
			this.secondary("sameover" + key,
				A.regionMatches(igncase, 0, A, 0, A.length() + 3));
			this.secondary("samehalf" + key,
				A.regionMatches(igncase, 0, A, 0, A.length() / 2));
			
			this.secondary("neglen" + key,
				A.regionMatches(igncase, 0, A, 0, -3));
			
			this.secondary("samenega" + key,
				A.regionMatches(igncase, -7, A, 7, 9));
			this.secondary("samenegb" + key,
				A.regionMatches(igncase, 7, A, -7, 9));
			
			this.secondary("hello" + key,
				A.regionMatches(igncase, 0, B, 23, 5));
			this.secondary("squirrels" + key,
				A.regionMatches(igncase, 7, B, 9, 9));
			this.secondary("are" + key,
				A.regionMatches(igncase, 17, B, 19, 3));
			this.secondary("adorable" + key,
				A.regionMatches(igncase, 21, B, 0, 8));
			
			if (igncase)
				return;
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestStringTrim.in.

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:squirrels\_are\_cute
secondary-b: string:squirrels\_are\_cute
secondary-c: string:squirrels\_are\_cute
secondary-d: string:squirrels\_are\_cute
secondary-e: string:
secondary-f: string:

Deleted runt/apis/cldc-compact.test/lang/TestStringTrim.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






































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests string trim.
 *
 * @since 2018/12/05
 */
public class TestStringTrim
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void test()
	{
		this.secondary("a", "squirrels are cute".trim());
		this.secondary("b", "  \t      squirrels are cute".trim());
		this.secondary("c", "squirrels are cute    \t".trim());
		this.secondary("d", "       \tsquirrels are cute \t    ".trim());
		this.secondary("e", "           ".trim());
		this.secondary("f", "           ".trim());
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestSynchronizedMethod.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-after--lock: int:7
secondary-before--lock: int:0
secondary-expected--resume: int:6
secondary-in--lock: int:1
secondary-sub--after--notify: int:4
secondary-sub--after--sleep: int:5
secondary-sub--in--lock: int:3
secondary-thread--created: int:2
secondary-in--lock2: int:8
secondary-thread--created2: int:9
secondary-after--lock2: int:14
secondary-expected--resume2: int:13
secondary-sub--after--notify2: int:11
secondary-sub--after--sleep2: int:12
secondary-sub--in--lock2: int:10

Deleted runt/apis/cldc-compact.test/lang/TestSynchronizedMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202










































































































































































































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests synchronized methods.
 *
 * @since 2018/12/04
 */
public class TestSynchronizedMethod
	extends TestRunnable
{
	/** Counter. */
	volatile int _count;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/21
	 */
	@Override
	public void test()
	{
		// Note
		this.secondary("before-lock", this._count++);
		
		// Lock the monitor for this
		synchronized (this)
		{
			// Note
			this.secondary("in-lock", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Sub__(), "SynchronizedMethodTest");
			t.start();
			
			// Note
			this.secondary("thread-created", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				this.wait();
				
				// Note
				this.secondary("expected-resume", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock", this._count++);
		
		// Perform another test
		synchronized (TestSynchronizedMethod.class)
		{
			// Note
			this.secondary("in-lock2", this._count++);
			
			// Create new thread
			Thread t = new Thread(new __Cl__(), "SynchronizedMethodTest2");
			t.start();
			
			// Note
			this.secondary("thread-created2", this._count++);
			
			// Wait on monitor
			try
			{
				// Wait forever
				TestSynchronizedMethod.class.wait();
				
				// Note
				this.secondary("expected-resume2", this._count++);
			}
			
			// Interrupted?
			catch (InterruptedException e)
			{
				// Note
				this.secondary("interrupted2", this._count++);
			}
		}
		
		// Note
		this.secondary("after-lock2", this._count++);
	}
	
	/**
	 * Tests synchronized method.
	 *
	 * @since 2018/12/04
	 */
	public synchronized void testSomething()
	{
		// Note
		this.secondary("sub-in-lock", this._count++);
		
		// Notify other thread
		this.notify();
		
		// Note
		this.secondary("sub-after-notify", this._count++);
		
		// Sleep for a bit, for sanity
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Sub continued
		this.secondary("sub-after-sleep", this._count++);
	}
	
	/**
	 * Same as above, but static.
	 *
	 * @param __m The method to report to.
	 * @since 2018/12/04
	 */
	public static synchronized void testStatic(TestSynchronizedMethod __m)
	{
		// Note
		__m.secondary("sub-in-lock2", __m._count++);
		
		// Notify other thread
		TestSynchronizedMethod.class.notify();
		
		// Note
		__m.secondary("sub-after-notify2", __m._count++);
		
		// Sleep for a bit, for sanity
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Sub continued
		__m.secondary("sub-after-sleep2", __m._count++);
	}
	
	/**
	 * Sub-thread which runs on the class!
	 *
	 * @since 2018/12/04
	 */
	final class __Cl__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public void run()
		{
			TestSynchronizedMethod.testStatic(TestSynchronizedMethod.this);
		}
	}
	
	/**
	 * Sub-thread which runs.
	 *
	 * @since 2018/12/04
	 */
	final class __Sub__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/04
		 */
		@Override
		public void run()
		{
			TestSynchronizedMethod.this.testSomething();
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestThreadNew.in.

1
2
3



-
-
-
result: true
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/TestThreadNew.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
66
67
68
69





































































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests the creation of a new thread.
 *
 * @since 2018/11/20
 */
public class TestThreadNew
	extends TestSupplier<Boolean>
{
	/** Did things? */
	volatile boolean _didstuff;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public Boolean test()
	{
		// Create and start thread to set the boolean flag
		new Thread(new __Task__()).start();
		
		// Run thread and wait, this should result in did being performed
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
		}
		
		// Did stuff
		return this._didstuff;
	}
	
	/**
	 * The task to run.
	 *
	 * @since 2018/11/20
	 */
	final class __Task__
		implements Runnable
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/20
		 */
		@Override
		public void run()
		{
			// Just set as true!
			TestThreadNew.this._didstuff = true;
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestThrowInSynchronized.in.

1
2
3



-
-
-
result: ExceptionThrown
thrown: throwable:java.util.NoSuchElementException

Deleted runt/apis/cldc-compact.test/lang/TestThrowInSynchronized.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 lang;

import java.util.NoSuchElementException;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This ensures that throwing excpetions within synchronized methods works
 * properly.
 *
 * @since 2019/12/24
 */
public class TestThrowInSynchronized
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	public void test()
	{
		synchronized (new Object())
		{
			TestThrowInSynchronized.levelA(new Object());
		}
	}
	
	/**
	 * First level call.
	 *
	 * @param __v The value.
	 * @since 2019/12/24
	 */
	public static final void levelA(Object __v)
	{
		synchronized (__v)
		{
			TestThrowInSynchronized.levelB(__v);
		}
	}
	
	/**
	 * Second level call.
	 *
	 * @param __v The value.
	 * @since 2019/12/24
	 */
	public static final void levelB(Object __v)
	{
		synchronized (__v)
		{
			throw new NoSuchElementException();
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestTrailingZeros.in.

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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: int:962
thrown: NoExceptionThrown
secondary-b0: int:0
secondary-b1: int:1
secondary-b10: int:10
secondary-b11: int:11
secondary-b12: int:12
secondary-b13: int:13
secondary-b14: int:14
secondary-b15: int:15
secondary-b16: int:16
secondary-b17: int:17
secondary-b18: int:18
secondary-b19: int:19
secondary-b2: int:2
secondary-b20: int:20
secondary-b21: int:21
secondary-b22: int:22
secondary-b23: int:23
secondary-b24: int:24
secondary-b25: int:25
secondary-b26: int:26
secondary-b27: int:27
secondary-b28: int:28
secondary-b29: int:29
secondary-b3: int:3
secondary-b30: int:30
secondary-b4: int:4
secondary-b5: int:5
secondary-b6: int:6
secondary-b7: int:7
secondary-b8: int:8
secondary-b9: int:9
secondary-d0: int:0
secondary-d1: int:1
secondary-d10: int:10
secondary-d11: int:11
secondary-d12: int:12
secondary-d13: int:13
secondary-d14: int:14
secondary-d15: int:15
secondary-d16: int:16
secondary-d17: int:17
secondary-d18: int:18
secondary-d19: int:19
secondary-d2: int:2
secondary-d20: int:20
secondary-d21: int:21
secondary-d22: int:22
secondary-d23: int:23
secondary-d24: int:24
secondary-d25: int:25
secondary-d26: int:26
secondary-d27: int:27
secondary-d28: int:28
secondary-d29: int:29
secondary-d3: int:3
secondary-d30: int:30
secondary-d4: int:4
secondary-d5: int:5
secondary-d6: int:6
secondary-d7: int:7
secondary-d8: int:8
secondary-d9: int:9
secondary-zero: int:32


Deleted runt/apis/cldc-compact.test/lang/TestTrailingZeros.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






















































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests trailing zero count.
 *
 * @since 2018/11/11
 */
public class TestTrailingZeros
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
	{
		int rv = Integer.numberOfTrailingZeros(0);
		this.secondary("zero", rv);
		
		for (int i = 0; i < 31; i++)
		{
			int v = Integer.numberOfTrailingZeros(1 << i);
			
			this.secondary("b" + i, v);
			
			rv += v;
		}
		
		for (int i = 0; i < 31; i++)
		{
			int v = Integer.numberOfTrailingZeros(0xDEADBEEF << i);
			
			this.secondary("d" + i, v);
			
			rv += v;
		}
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestVMIndexOutOfBounds.in.

1
2


-
-
result: ExceptionThrown
thrown: throwable:ArrayIndexOutOfBoundsException

Deleted runt/apis/cldc-compact.test/lang/TestVMIndexOutOfBounds.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










































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

package lang;

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests that reading the array causes an out of bounds to occur.
 *
 * @since 2018/12/04
 */
public class TestVMIndexOutOfBounds
	extends TestSupplier<String>
{
	/** Strings to test. */
	private static final String[] _STRINGS =
		{
			"Squirrels are cute!",
			"They really are!",
			"So are red pandas!",
			"I love you so much!",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String test()
	{
		return _STRINGS[5];
	}
}

Deleted runt/apis/cldc-compact.test/lang/TestVMInterrupt.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-a--after--lock: int:1
secondary-a--after--wait: false
secondary-a--before--lock: int:0
secondary-a--before--wait: false
secondary-a--done: int:9
secondary-a--thread--created: int:2
secondary-a--was--interrupted: int:8
secondary-b--about--to--unlock: int:7
secondary-b--dosleep: int:5
secondary-b--in--lock: int:3
secondary-b--interrupt--a: int:4
secondary-b--sleepdone: int:6

Deleted runt/apis/cldc-compact.test/lang/TestVMInterrupt.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
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


























































































































































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests interrupted, monitors, and threads as well.
 *
 * @since 2018/11/20
 */
public class TestVMInterrupt
	extends TestRunnable
{
	/** The object to lock on. */
	protected final Object lock =
		new Object();
	
	/** The order of things, is a check for locks. */
	protected volatile int order;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public void test()
	{
		Thread self = Thread.currentThread();
		
		// Note
		this.secondary("a-before-lock", order++);
		
		// Lock on this object
		synchronized (this.lock)
		{
			// Note
			this.secondary("a-after-lock", order++);
			
			// Setup thread to run
			Thread runner = new Thread(new __Runner__(
				self), "VMInterruptChild");
			runner.start();
			
			// Note
			this.secondary("a-thread-created", order++);
			this.secondary("a-before-wait", self.isInterrupted());
			
			// Wait for a notification
			try
			{
				this.lock.wait();
				
				// Note
				this.secondary("a-was-not-interrupted", order++);
			}
			catch (InterruptedException e)
			{
				// Note
				this.secondary("a-was-interrupted", order++);
			}
			
			// Note
			this.secondary("a-after-wait", self.isInterrupted());
		}
		
		// Note
		this.secondary("a-done", order++);
	}
	
	/**
	 * Performs the second part of the test run.
	 *
	 * @since 2018/11/20
	 */
	final class __Runner__
		implements Runnable
	{
		/** The thread to signal. */
		protected final Thread signal;
		
		/**
		 * Initializes the runner.
		 *
		 * @param __t The thread to signal.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/20
		 */
		public __Runner__(Thread __t)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.signal = __t;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/20
		 */
		@Override
		public void run()
		{
			// Lock
			synchronized (TestVMInterrupt.this.lock)
			{
				// Note
				TestVMInterrupt.this.secondary("b-in-lock",
					TestVMInterrupt.this.order++);
				
				// Interrupt A
				this.signal.interrupt();
				
				// Note
				TestVMInterrupt.this.secondary("b-interrupt-a",
					TestVMInterrupt.this.order++);
				
				// Sleep for a bit
				try
				{
					// Note
					TestVMInterrupt.this.secondary("b-dosleep",
						TestVMInterrupt.this.order++);
					
					// Sleep for a bit longer than the main thread
					Thread.sleep(3000);
					
					// Note
					TestVMInterrupt.this.secondary("b-sleepdone",
						TestVMInterrupt.this.order++);
				}
				catch (InterruptedException e)
				{
					TestVMInterrupt.this.secondary("b-interrupted",
						TestVMInterrupt.this.order++);
				}
				
				// About to unlock
				TestVMInterrupt.this.secondary("b-about-to-unlock",
					TestVMInterrupt.this.order++);
			}
		}
	}
}

Deleted runt/apis/cldc-compact.test/lang/__InvokePrivateInSuper__.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












































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests calling a private method where the extending class also has a method
 * with the same name and descriptor, but is public.
 *
 * @since 2018/10/10
 */
abstract class __InvokePrivateInSuper__
	extends TestRunnable
{
	/**
	 * Super method call.
	 *
	 * @since 2018/10/10
	 */
	public final void doSuper()
	{
		this.doPrivate();
	}
	
	/**
	 * Private method in superclass.
	 *
	 * @since 2018/10/10
	 */
	private void doPrivate()
	{
		this.secondary("superprivate", true);
	}
}

Deleted runt/apis/cldc-compact.test/lang/__InvokeSuper__.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

































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

package lang;

import net.multiphasicapps.tac.TestRunnable;

/**
 * Super class to test execution with.
 *
 * @since 2018/10/10
 */
abstract class __InvokeSuper__
	extends TestRunnable
{
	/**
	 * Tests the super call.
	 *
	 * @since 2018/10/10
	 */
	public void doSuper()
	{
		this.secondary("super", true);
	}
}

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDup.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 TestDup.class
yv66vgAAAC4ADgEAFWxhbmcvYnl0ZWNvZGUvVGVzdER1cAEAClNvdXJjZUZp
bGUBAAY8aW5pdD4BAAMoKUkHAAEMAAMADQoACwAGAQAEQ29kZQEACVRlc3RE
dXAuagEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRlZ2VyBwAK
AQAEdGVzdAEAAygpVgAgAAUACwAAAAAAAgABAAMADQABAAgAAAASAAEAAQAA
AAYZALcAB7EAAAAAAAEADAAEAAEACAAAABIAAgABAAAABhEE0llgrAAAAAAA
AQACAAAAAgAJ
====

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDup.in.

1
2


-
-
result: int:2468
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDup.j.

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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDup
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 2
	
	sipush 1234
	
	dup
	
	iadd
	ireturn
.end method
	

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXOne.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 TestDupXOne.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUHAAUBAAY8aW5pdD4BAAMoKUkBABls
YW5nL2J5dGVjb2RlL1Rlc3REdXBYT25lDAADAAwKAAoABgEABENvZGUBACNu
ZXQvbXVsdGlwaGFzaWNhcHBzL3RhYy9UZXN0SW50ZWdlcgcACQEABHRlc3QB
AAMoKVYBAA1UZXN0RHVwWE9uZS5qACAAAgAKAAAAAAACAAEAAwAMAAEACAAA
ABIAAQABAAAABhkAtwAHsQAAAAAAAQALAAQAAQAIAAAAFgADAAEAAAAKEQTS
EQu4WmBgrAAAAAAAAQABAAAAAgAN
====

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXOne.in.

1
2


-
-
result: int:7234
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXOne.j.

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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXOne
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 3
	
	sipush 1234	; b
	sipush 3000	; a
	
	; b, a -> a, b, a
	dup_x1
	
	iadd		; b + a -> x [a, x]
	iadd		; a + x -> y [y]
	
	ireturn
.end method
	

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoIII.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 TestDupXTwoIII.class
yv66vgAAAC4ADgEAEFRlc3REdXBYVHdvSUlJLmoHAA0BAApTb3VyY2VGaWxl
AQAGPGluaXQ+AQADKClJDAAEAAwKAAoABgEABENvZGUBACNuZXQvbXVsdGlw
aGFzaWNhcHBzL3RhYy9UZXN0SW50ZWdlcgcACQEABHRlc3QBAAMoKVYBABxs
YW5nL2J5dGVjb2RlL1Rlc3REdXBYVHdvSUlJACAAAgAKAAAAAAACAAEABAAM
AAEACAAAABIAAQABAAAABhkAtwAHsQAAAAAAAQALAAUAAQAIAAAAGgAEAAEA
AAAOEQTSEQu4ER5hW2BgYKwAAAAAAAEAAwAAAAIAAQ==
====

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoIII.in.

1
2


-
-
result: int:19788
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoIII.j.

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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXTwoIII
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 4
	
	sipush 1234	; c
	sipush 3000	; b
	sipush 7777 ; a
	
	; c, b, a -> a, c, b, a
	dup_x2
	
	iadd		; b + a -> x [a, c, x]
	iadd		; c + x -> y [a, y]
	iadd		; a + y -> z [z]
	
	ireturn
.end method
	

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoJI.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 TestDupXTwoJI.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUBAAY8aW5pdD4BAAMoKUkMAAIACwoA
CAAEAQAEQ29kZQEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRl
Z2VyBwAHAQAEdGVzdAcADQEAAygpVgEAD1Rlc3REdXBYVHdvSkkuagEAG2xh
bmcvYnl0ZWNvZGUvVGVzdER1cFhUd29KSQAgAAoACAAAAAAAAgABAAIACwAB
AAYAAAASAAEAAQAAAAYZALcABbEAAAAAAAEACQADAAEABgAAABkABQABAAAA
DREE0oURC7hbhWGIYKwAAAAAAAEAAQAAAAIADA==
====

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoJI.in.

1
2


-
-
result: int:7234
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestDupXTwoJI.j.

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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestDupXTwoJI
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 5
	
	sipush 1234	; b
	i2l
	
	sipush 3000 ; a
	
	; J b, I a -> I a, J b, I a
	dup_x2
	
	i2l			; I a -> J a [I a, J b, J a]
	ladd		; J b + J a -> x [I a, J x]
	
	l2i			; J x -> I x [I a, I x]
	
	iadd		; I a + I x -> I y [I y]
	
	ireturn
.end method
	

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestSwap.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 TestSwap.class
yv66vgAAAC4ADgEAClNvdXJjZUZpbGUBAAY8aW5pdD4BAAMoKUkMAAIADAoA
CQAEAQAEQ29kZQEAI25ldC9tdWx0aXBoYXNpY2FwcHMvdGFjL1Rlc3RJbnRl
Z2VyBwALBwAHAQAEdGVzdAEAFmxhbmcvYnl0ZWNvZGUvVGVzdFN3YXABAAMo
KVYBAApUZXN0U3dhcC5qACAACAAJAAAAAAACAAEAAgAMAAEABgAAABIAAQAB
AAAABhkAtwAFsQAAAAAAAQAKAAMAAQAGAAAAFAACAAEAAAAIEQTSEQu4X6wA
AAAAAAEAAQAAAAIADQ==
====

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestSwap.in.

1
2


-
-
result: int:1234
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/lang/bytecode/TestSwap.j.

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: Jasmin; 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.
; ---------------------------------------------------------------------------

.class lang/bytecode/TestSwap
.super net/multiphasicapps/tac/TestInteger

.method public <init>()V
	aload 0
	invokenonvirtual net/multiphasicapps/tac/TestInteger/<init>()V
	return
.end method

.method public test()I
.limit stack 2
	
	sipush 1234	; b
	sipush 3000	; a
	
	; b, a -> a, b
	swap
	
	ireturn
.end method
	

Deleted runt/apis/cldc-compact.test/lang/extra/ABasicEnum.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
































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

package lang.extra;

/**
 * A basic enumeration.
 *
 * @since 2018/12/08
 */
public enum ABasicEnum
{
	/** A. */
	A,
	
	/** B. */
	B,
	
	/** C. */
	C,
	
	/** End. */
	;
}

Deleted runt/apis/cldc-compact.test/lang/extra/AClassEnum.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
66
67
68
69
70
71
72
73









































































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

package lang.extra;

/**
 * This is a class enumeration.
 *
 * @since 2018/12/08
 */
public enum AClassEnum
{
	/** A. */
	A
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "Love you!";
		}
	},
	
	/** B. */
	B
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "You are beautiful!";
		}
	},
	
	/** C. */
	C
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/12/08
		 */
		@Override
		public String boop()
		{
			return "You are wonderful!";
		}
	},
	
	/** End. */
	;
	
	/**
	 * Returns a message.
	 *
	 * @return A message.
	 * @since 2018/12/08
	 */
	public abstract String boop();
}

Deleted runt/apis/cldc-compact.test/lang/extra/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * Extra classes.
 *
 * @since 2018/12/08
 */

package lang.extra;

Deleted runt/apis/cldc-compact.test/lang/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * Java language tests.
 *
 * @since 2018/10/10
 */

package lang;

Deleted runt/apis/cldc-compact.test/squirreljme/TestPointerAccess.in.

1
2
3
4
5
6






-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-otpnotnull: true
secondary-sameobject: true
secondary-zeroisnull: true
secondary-nulliszero: true

Deleted runt/apis/cldc-compact.test/squirreljme/TestPointerAccess.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 squirreljme;

import cc.squirreljme.jvm.Assembly;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that pointer access makes sense.
 *
 * @since 2019/12/21
 */
public class TestPointerAccess
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public void test()
	{
		// Create a new object which we will get a pointer of
		Object object = new Object();
		
		// This object cannot be null
		int pointer = Assembly.objectToPointer(object);
		this.secondary("otpnotnull", pointer != 0); 
		
		// Reversing this operation should return the original object
		Object from = Assembly.pointerToObject(pointer);
		this.secondary("sameobject", object == from);
		
		// The zero pointer must be null
		Object ozero = Assembly.pointerToObject(0);
		this.secondary("zeroisnull", ozero == null);
		
		// The null object must be zero
		int pnull = Assembly.objectToPointer(null);
		this.secondary("nulliszero", pnull == 0);
	}
}

Deleted runt/apis/cldc-compact.test/squirreljme/TestSystemTime.in.

1
2
3
4




-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-mw: int:0
secondary-nm: int:0

Deleted runt/apis/cldc-compact.test/squirreljme/TestSystemTime.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 squirreljme;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that the system time can be obtained without error.
 *
 * @since 2019/05/23
 */
public class TestSystemTime
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/23
	 */
	@Override
	public void test()
	{
		Assembly.sysCall(SystemCallIndex.TIME_MILLI_WALL);
		this.secondary("mw", Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.TIME_MILLI_WALL));
		
		Assembly.sysCall(SystemCallIndex.TIME_NANO_MONO);
		this.secondary("nm", Assembly.sysCallV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.TIME_NANO_MONO));
	}
}

Deleted runt/apis/cldc-compact.test/squirreljme/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains tests for the SquirrelJME specific system interfaces
 * and system calls.
 *
 * @since 2019/05/23
 */

package squirreljme;

Deleted runt/apis/cldc-compact.test/util/TestArrayBinarySearch.in.

1
2
3



-
-
-
result: long:4611686018427387903
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/util/TestArrayBinarySearch.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package util;

import java.util.Arrays;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Test that binary search works properly.
 *
 * @since 2018/10/28
 */
public class TestArrayBinarySearch
	extends TestSupplier<Long>
{
	/** The array length. */
	public static final int LENGTH =
		31;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Long test()
	{
		long rv = 0;
		
		// Setup array with values
		int[] values = new int[LENGTH];
		for (int i = 0; i < LENGTH; i++)
			values[i] = i * 2;
		
		// Search for all values
		for (int i = 0; i < LENGTH * 2; i++)
		{
			// Find the value
			int res = Arrays.binarySearch(values, i);
			
			// Value is even, it will be in the array
			int want;
			if ((i & 1) == 0)
				want = i / 2;
			
			// Is odd, will not be in the array
			else
				want = -((i / 2) + 2);
			
			// Is this our expected value?
			if (res == want)
				rv |= (1L << (long)i);
		}
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact.test/util/TestArrayDequeDeque.in.

1

-
secondary-hashcode: int:1789447862

Deleted runt/apis/cldc-compact.test/util/TestArrayDequeDeque.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
































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

package util;

import java.util.ArrayDeque;

/**
 * Tests array deques.
 *
 * @since 2019/01/20
 */
public class TestArrayDequeDeque
	extends __TestDeque__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/01/20
	 */
	public TestArrayDequeDeque()
	{
		super(new ArrayDeque<Number>());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestArrayList.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.ArrayList;

/**
 * Tests array list.
 *
 * @since 2019/05/08
 */
public class TestArrayList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestArrayList()
	{
		super(new ArrayList<String>());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestHashMap.in.

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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-hashcode: int:5740575
secondary-initempty: true
secondary-initsize: int:0
secondary-firstcontained: true
secondary-firstvalue: string:Squirrels
secondary-firstcontainednew: true
secondary-firstvaluenew: string:Squirrels
secondary-firstsize: int:1
secondary-firsthassecond: false
secondary-secondcontained: true
secondary-secondvalue: string:Cute
secondary-secondsize: int:2
secondary-replaceput: string:Squirrels
secondary-replacevalue: string:Cute
secondary-replacesecondvalue: string:Cute
secondary-replacesize: int:2
secondary-dumpsize: int:130
secondary-ithasfirst: string:Cute
secondary-itafterhasfirst: false
secondary-itputfirstagain: null
secondary-removesecond: string:Cute
secondary-removesize: int:129
secondary-hasanother: string:Adorable
secondary-hasanothersize: int:130
secondary-clearsize: int:0
secondary-reusedcontained: true
secondary-reusedvalue: string:Squirrels
secondary-reusedcontainednew: true
secondary-reusedvaluenew: string:Squirrels
secondary-reusedsize: int:1
secondary-reusedhassecond: false

Deleted runt/apis/cldc-compact.test/util/TestHashMap.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
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







































































































































































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

package util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Tests that {@link HashMap} works properly.
 *
 * @since 2018/10/07
 */
public class TestHashMap
	extends TestRunnable
{
	/** The map to test on. */
	protected final Map<Integer, String> map;
	
	/**
	 * Initializes the test using the base map.
	 *
	 * @since 2018/11/05
	 */
	public TestHashMap()
	{
		this(new HashMap<Integer, String>());
	}
	
	/**
	 * Initializes the test using the given map.
	 *
	 * @param __m The map to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/05
	 */
	public TestHashMap(Map<Integer, String> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.map = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public void test()
	{
		// Initialize a map to work with
		Map<Integer, String> map = this.map;
		
		// Initial size and such
		this.secondary("initempty", map.isEmpty());
		this.secondary("initsize", map.size());
		
		// Some initial values to use
		Integer ka = Integer.valueOf(1989),
			kb = Integer.valueOf(2018);
		String va = "Squirrels",
			vb = "Cute";
		
		// Store into the map
		map.put(ka, va);
		
		// Some checks for that initial value
		this.secondary("firstcontained", map.containsKey(ka));
		this.secondary("firstvalue", map.get(ka));
		
		// Has the same equality, despite a different object?
		this.secondary("firstcontainednew",
			map.containsKey(new Integer(1989)));
		this.secondary("firstvaluenew",
			map.get(new Integer(1989)));
		this.secondary("firstsize", map.size());
		this.secondary("firsthassecond", map.containsKey(kb));
		
		// Add second value
		map.put(kb, vb);
		
		// Check for second value
		this.secondary("secondcontained", map.containsKey(kb));
		this.secondary("secondvalue", map.get(kb));
		this.secondary("secondsize", map.size());
		
		// Replace first value
		this.secondary("replaceput", map.put(ka, vb));
		
		// Checks for replaced value
		this.secondary("replacevalue", map.get(ka));
		this.secondary("replacesecondvalue", map.get(kb));
		this.secondary("replacesize", map.size());
		
		// Add in a bunch of values
		for (int i = 0; i < 128; i++)
			map.put(i, "" + i);
		
		// Hash map
		this.secondary("hashcode", map.hashCode());
		
		// Check the size
		this.secondary("dumpsize", map.size());
		
		// Search for entry by iterator
		for (Iterator<Map.Entry<Integer, String>> it =
			map.entrySet().iterator(); it.hasNext();)
		{
			Map.Entry<Integer, String> e = it.next();
			
			// Matches first value
			if (ka.equals(e.getKey()))
			{
				this.secondary("ithasfirst", e.getValue());
				
				// Remove it
				it.remove();
			}
		}
		
		// Must not have first value
		this.secondary("itafterhasfirst", map.containsKey(ka));
		this.secondary("itputfirstagain", map.put(ka, vb));
		
		// Remove second value
		this.secondary("removesecond", map.remove(kb));
		this.secondary("removesize", map.size());
		
		// Add new value
		map.put(-1, "Adorable");
		
		// Check that
		this.secondary("hasanother", map.get(-1));
		this.secondary("hasanothersize", map.size());
		
		// Empty the map
		map.clear();
		
		// Check that
		this.secondary("clearsize", map.size());
		
		// Store into the map again
		map.put(ka, va);
		
		// Reused values
		this.secondary("reusedcontained", map.containsKey(ka));
		this.secondary("reusedvalue", map.get(ka));
		this.secondary("reusedcontainednew",
			map.containsKey(new Integer(1989)));
		this.secondary("reusedvaluenew",
			map.get(new Integer(1989)));
		this.secondary("reusedsize", map.size());
		this.secondary("reusedhassecond", map.containsKey(kb));
	}
}

Deleted runt/apis/cldc-compact.test/util/TestHashMapNaN.in.

1
2


-
-
result: true
thrown: NoExceptionThrown

Deleted runt/apis/cldc-compact.test/util/TestHashMapNaN.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








































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

package util;

import net.multiphasicapps.tac.TestSupplier;
import java.util.HashMap;

/**
 * {@link HashMap}s can contain NaN.
 *
 * @since 2018/10/10
 */
public class TestHashMapNaN
	extends TestSupplier<Boolean>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public Boolean test()
	{
		// Initialize a map to work with
		HashMap<Float, String> map = new HashMap<>();
		
		// Store a NaN
		map.put(Float.NaN, "Squirrels are adorable!");
		
		return map.containsKey(Float.NaN);
	}
}

Deleted runt/apis/cldc-compact.test/util/TestHashtable.in.

1
2
3



-
-
-
secondary-nullkey: true
secondary-nullval: true
secondary-nullset: true

Deleted runt/apis/cldc-compact.test/util/TestHashtable.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
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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

/**
 * This is a test for {@link Hashtable}.
 *
 * @since 2019/05/05
 */
public class TestHashtable
	extends TestHashMap
{
	/**
	 * Initializes the test using the base map.
	 *
	 * @since 2019/05/05
	 */
	public TestHashtable()
	{
		this(new Hashtable<Integer, String>());
	}
	
	/**
	 * Initializes the test using the given map.
	 *
	 * @param __m The map to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public TestHashtable(Map<Integer, String> __m)
		throws NullPointerException
	{
		super(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void test()
	{
		// Run basic HashMap test
		super.test();
		
		// Initialize a map to work with
		Map<Integer, String> map = this.map;
		
		// Null key should fail
		boolean nullkey = false;
		try
		{
			map.put(null, "Hiya!");
		}
		catch (NullPointerException e)
		{
			nullkey = true;
		}
		this.secondary("nullkey", nullkey);
		
		// Null value should fail
		boolean nullval = false;
		try
		{
			map.put(9876, null);
		}
		catch (NullPointerException e)
		{
			nullval = true;
		}
		this.secondary("nullval", nullval);
		
		// Cannot set values via the iterator either
		Map.Entry<Integer, String> ent = map.entrySet().iterator().next();
		boolean nullset = false;
		try
		{
			ent.setValue(null);
		}
		catch (NullPointerException e)
		{
			nullset = true;
		}
		this.secondary("nullset", nullset);
	}
}

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashMap.in.

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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-acontentsa: string:\(1989=Cute,\_2018=Cute,\_0=0,\_1=1,\_2=2
 ,\_3=3,\_4=4,\_5=5,\_6=6,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_1
 3=13,\_14=14,\_15=15,\_16=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\
 _22=22,\_23=23,\_24=24,\_25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30
 ,\_31=31,\_32=32,\_33=33,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=
 39,\_40=40,\_41=41,\_42=42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_4
 8=48,\_49=49,\_50=50,\_51=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\
 _57=57,\_58=58,\_59=59,\_60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65
 ,\_66=66,\_67=67,\_68=68,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=
 74,\_75=75,\_76=76,\_77=77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_8
 3=83,\_84=84,\_85=85,\_86=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\
 _92=92,\_93=93,\_94=94,\_95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=1
 00,\_101=101,\_102=102,\_103=103,\_104=104,\_105=105,\_106=106,\_107=1
 07,\_108=108,\_109=109,\_110=110,\_111=111,\_112=112,\_113=113,\_114=1
 14,\_115=115,\_116=116,\_117=117,\_118=118,\_119=119,\_120=120,\_121=1
 21,\_122=122,\_123=123,\_124=124,\_125=125,\_126=126,\_127=127\)
secondary-acontentsb: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Cute,\_-1=Adorable\)
secondary-acontentsc: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Squirrels,\_-1=Adorable\
 )
secondary-adumpsize: int:130
secondary-afirstcontained: true
secondary-afirstcontainednew: true
secondary-afirsthassecond: false
secondary-afirstsize: int:1
secondary-afirstvalue: string:Squirrels
secondary-afirstvaluenew: string:Squirrels
secondary-ahasanother: string:Adorable
secondary-ahasanothersize: int:130
secondary-ahashcode: int:5740575
secondary-ainitempty: true
secondary-ainitsize: int:0
secondary-aitafterhasfirst: false
secondary-aithasfirst: string:Cute
secondary-aitputfirstagain: null
secondary-aremovesecond: string:Cute
secondary-aremovesize: int:129
secondary-areplaceput: string:Squirrels
secondary-areplacesecondvalue: string:Cute
secondary-areplacesize: int:2
secondary-areplacevalue: string:Cute
secondary-areusedcontained: true
secondary-areusedcontainednew: true
secondary-areusedhassecond: false
secondary-areusedsize: int:130
secondary-areusedvalue: string:Squirrels
secondary-areusedvaluenew: string:Squirrels
secondary-asecondcontained: true
secondary-asecondsize: int:2
secondary-asecondvalue: string:Cute
secondary-bcontentsa: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_1989=Cute,\_-1=Adorable,\_201
 8=Cute\)
secondary-bcontentsb: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_-1=Adorable,\_1989=Cute\)
secondary-bcontentsc: string:\(0=0,\_1=1,\_2=2,\_3=3,\_4=4,\_5=5,\_6=6
 ,\_7=7,\_8=8,\_9=9,\_10=10,\_11=11,\_12=12,\_13=13,\_14=14,\_15=15,\_1
 6=16,\_17=17,\_18=18,\_19=19,\_20=20,\_21=21,\_22=22,\_23=23,\_24=24,\
 _25=25,\_26=26,\_27=27,\_28=28,\_29=29,\_30=30,\_31=31,\_32=32,\_33=33
 ,\_34=34,\_35=35,\_36=36,\_37=37,\_38=38,\_39=39,\_40=40,\_41=41,\_42=
 42,\_43=43,\_44=44,\_45=45,\_46=46,\_47=47,\_48=48,\_49=49,\_50=50,\_5
 1=51,\_52=52,\_53=53,\_54=54,\_55=55,\_56=56,\_57=57,\_58=58,\_59=59,\
 _60=60,\_61=61,\_62=62,\_63=63,\_64=64,\_65=65,\_66=66,\_67=67,\_68=68
 ,\_69=69,\_70=70,\_71=71,\_72=72,\_73=73,\_74=74,\_75=75,\_76=76,\_77=
 77,\_78=78,\_79=79,\_80=80,\_81=81,\_82=82,\_83=83,\_84=84,\_85=85,\_8
 6=86,\_87=87,\_88=88,\_89=89,\_90=90,\_91=91,\_92=92,\_93=93,\_94=94,\
 _95=95,\_96=96,\_97=97,\_98=98,\_99=99,\_100=100,\_101=101,\_102=102,\
 _103=103,\_104=104,\_105=105,\_106=106,\_107=107,\_108=108,\_109=109,\
 _110=110,\_111=111,\_112=112,\_113=113,\_114=114,\_115=115,\_116=116,\
 _117=117,\_118=118,\_119=119,\_120=120,\_121=121,\_122=122,\_123=123,\
 _124=124,\_125=125,\_126=126,\_127=127,\_-1=Adorable,\_1989=Squirrels\
 )
secondary-bdumpsize: int:131
secondary-bfirstcontained: true
secondary-bfirstcontainednew: true
secondary-bfirsthassecond: false
secondary-bfirstsize: int:130
secondary-bfirstvalue: string:Squirrels
secondary-bfirstvaluenew: string:Squirrels
secondary-bhasanother: string:Adorable
secondary-bhasanothersize: int:130
secondary-bhashcode: int:845026398
secondary-binitempty: false
secondary-binitsize: int:130
secondary-bitafterhasfirst: false
secondary-bithasfirst: string:Cute
secondary-bitputfirstagain: null
secondary-bremovesecond: string:Cute
secondary-bremovesize: int:130
secondary-breplaceput: string:Squirrels
secondary-breplacesecondvalue: string:Cute
secondary-breplacesize: int:131
secondary-breplacevalue: string:Cute
secondary-breusedcontained: true
secondary-breusedcontainednew: true
secondary-breusedhassecond: false
secondary-breusedsize: int:130
secondary-breusedvalue: string:Squirrels
secondary-breusedvaluenew: string:Squirrels
secondary-bsecondcontained: true
secondary-bsecondsize: int:131
secondary-bsecondvalue: string:Cute

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashMap.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This is used to test that LinkedHashMap works.
 *
 * @since 2019/05/11
 */
public class TestLinkedHashMap
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public void test()
	{
		// Initialize a map to work with
		Map<Integer, String> map = new LinkedHashMap<>();
		
		// Go through this twice!
		for (char x = 'a'; x != 'c'; x = (char)(x + 1))
		{
			// Initial size and such
			this.secondary(x + "initempty", map.isEmpty());
			this.secondary(x + "initsize", map.size());
			
			// Some initial values to use
			Integer ka = Integer.valueOf(1989),
				kb = Integer.valueOf(2018);
			String va = "Squirrels",
				vb = "Cute";
			
			// Store into the map
			map.put(ka, va);
			
			// Some checks for that initial value
			this.secondary(x + "firstcontained", map.containsKey(ka));
			this.secondary(x + "firstvalue", map.get(ka));
			
			// Has the same equality, despite a different object?
			this.secondary(x + "firstcontainednew",
				map.containsKey(new Integer(1989)));
			this.secondary(x + "firstvaluenew",
				map.get(new Integer(1989)));
			this.secondary(x + "firstsize", map.size());
			this.secondary(x + "firsthassecond", map.containsKey(kb));
			
			// Add second value
			map.put(kb, vb);
			
			// Check for second value
			this.secondary(x + "secondcontained", map.containsKey(kb));
			this.secondary(x + "secondvalue", map.get(kb));
			this.secondary(x + "secondsize", map.size());
			
			// Replace first value
			this.secondary(x + "replaceput", map.put(ka, vb));
			
			// Checks for replaced value
			this.secondary(x + "replacevalue", map.get(ka));
			this.secondary(x + "replacesecondvalue", map.get(kb));
			this.secondary(x + "replacesize", map.size());
			
			// Add in a bunch of values
			for (int i = 0; i < 128; i++)
				map.put(i, "" + i);
			
			// Contents
			this.secondary(x + "contentsa", map.toString());
			
			// Hash map
			this.secondary(x + "hashcode", map.hashCode());
			
			// Check the size
			this.secondary(x + "dumpsize", map.size());
			
			// Search for entry by iterator
			for (Iterator<Map.Entry<Integer, String>> it =
				map.entrySet().iterator(); it.hasNext();)
			{
				Map.Entry<Integer, String> e = it.next();
				
				// Matches first value
				if (ka.equals(e.getKey()))
				{
					this.secondary(x + "ithasfirst", e.getValue());
					
					// Remove it
					it.remove();
				}
			}
			
			// Must not have first value
			this.secondary(x + "itafterhasfirst", map.containsKey(ka));
			this.secondary(x + "itputfirstagain", map.put(ka, vb));
			
			// Remove second value
			this.secondary(x + "removesecond", map.remove(kb));
			this.secondary(x + "removesize", map.size());
			
			// Add new value
			map.put(-1, "Adorable");
			
			// Check that
			this.secondary(x + "hasanother", map.get(-1));
			this.secondary(x + "hasanothersize", map.size());
			
			// Contents
			this.secondary(x + "contentsb", map.toString());
			
			// Store into the map again
			map.put(ka, va);
			
			// Reused values
			this.secondary(x + "reusedcontained", map.containsKey(ka));
			this.secondary(x + "reusedvalue", map.get(ka));
			this.secondary(x + "reusedcontainednew",
				map.containsKey(new Integer(1989)));
			this.secondary(x + "reusedvaluenew",
				map.get(new Integer(1989)));
			this.secondary(x + "reusedsize", map.size());
			this.secondary(x + "reusedhassecond", map.containsKey(kb));
			
			
			// Contents
			this.secondary(x + "contentsc", map.toString());
		}
	}
}

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashMapEldest.in.

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




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-eldest0add: int:0
secondary-eldest10add: int:5
secondary-eldest11key: int:0
secondary-eldest11val: string:Value0
secondary-eldest12add: int:6
secondary-eldest13key: int:0
secondary-eldest13val: string:Value0
secondary-eldest14add: int:7
secondary-eldest15key: int:0
secondary-eldest15val: string:Value0
secondary-eldest16add: int:8
secondary-eldest17key: int:0
secondary-eldest17val: string:Value0
secondary-eldest18add: int:9
secondary-eldest19key: int:0
secondary-eldest19val: string:Value0
secondary-eldest1key: int:0
secondary-eldest1val: string:Value0
secondary-eldest20add: int:10
secondary-eldest21key: int:0
secondary-eldest21val: string:Value0
secondary-eldest22add: int:11
secondary-eldest23key: int:1
secondary-eldest23val: string:Value1
secondary-eldest24add: int:12
secondary-eldest25key: int:2
secondary-eldest25val: string:Value2
secondary-eldest26add: int:13
secondary-eldest27key: int:3
secondary-eldest27val: string:Value3
secondary-eldest28add: int:14
secondary-eldest29key: int:4
secondary-eldest29val: string:Value4
secondary-eldest2add: int:1
secondary-eldest30add: int:15
secondary-eldest31key: int:5
secondary-eldest31val: string:Value5
secondary-eldest32add: int:16
secondary-eldest33key: int:6
secondary-eldest33val: string:Value6
secondary-eldest34add: int:17
secondary-eldest35key: int:7
secondary-eldest35val: string:Value7
secondary-eldest36add: int:18
secondary-eldest37key: int:8
secondary-eldest37val: string:Value8
secondary-eldest38add: int:19
secondary-eldest39key: int:9
secondary-eldest39val: string:Value9
secondary-eldest3key: int:0
secondary-eldest3val: string:Value0
secondary-eldest40add: int:20
secondary-eldest41key: int:10
secondary-eldest41val: string:Value10
secondary-eldest42add: int:21
secondary-eldest43key: int:11
secondary-eldest43val: string:Value11
secondary-eldest44add: int:22
secondary-eldest45key: int:12
secondary-eldest45val: string:Value12
secondary-eldest46add: int:23
secondary-eldest47key: int:13
secondary-eldest47val: string:Value13
secondary-eldest48add: int:24
secondary-eldest49key: int:14
secondary-eldest49val: string:Value14
secondary-eldest4add: int:2
secondary-eldest50add: int:25
secondary-eldest51key: int:15
secondary-eldest51val: string:Value15
secondary-eldest52add: int:26
secondary-eldest53key: int:16
secondary-eldest53val: string:Value16
secondary-eldest54add: int:27
secondary-eldest55key: int:17
secondary-eldest55val: string:Value17
secondary-eldest56add: int:28
secondary-eldest57key: int:18
secondary-eldest57val: string:Value18
secondary-eldest58add: int:29
secondary-eldest59key: int:19
secondary-eldest59val: string:Value19
secondary-eldest5key: int:0
secondary-eldest5val: string:Value0
secondary-eldest60add: int:30
secondary-eldest61key: int:20
secondary-eldest61val: string:Value20
secondary-eldest62add: int:31
secondary-eldest63key: int:21
secondary-eldest63val: string:Value21
secondary-eldest64add: int:32
secondary-eldest65key: int:22
secondary-eldest65val: string:Value22
secondary-eldest66add: int:33
secondary-eldest67key: int:23
secondary-eldest67val: string:Value23
secondary-eldest68add: int:34
secondary-eldest69key: int:24
secondary-eldest69val: string:Value24
secondary-eldest6add: int:3
secondary-eldest70add: int:35
secondary-eldest71key: int:25
secondary-eldest71val: string:Value25
secondary-eldest72add: int:36
secondary-eldest73key: int:26
secondary-eldest73val: string:Value26
secondary-eldest74add: int:37
secondary-eldest75key: int:27
secondary-eldest75val: string:Value27
secondary-eldest76add: int:38
secondary-eldest77key: int:28
secondary-eldest77val: string:Value28
secondary-eldest78add: int:39
secondary-eldest79key: int:29
secondary-eldest79val: string:Value29
secondary-eldest7key: int:0
secondary-eldest7val: string:Value0
secondary-eldest80add: int:40
secondary-eldest81key: int:30
secondary-eldest81val: string:Value30
secondary-eldest82add: int:41
secondary-eldest83key: int:31
secondary-eldest83val: string:Value31
secondary-eldest84add: int:42
secondary-eldest85key: int:32
secondary-eldest85val: string:Value32
secondary-eldest86add: int:43
secondary-eldest87key: int:33
secondary-eldest87val: string:Value33
secondary-eldest88add: int:44
secondary-eldest89key: int:34
secondary-eldest89val: string:Value34
secondary-eldest8add: int:4
secondary-eldest90add: int:45
secondary-eldest91key: int:35
secondary-eldest91val: string:Value35
secondary-eldest92add: int:46
secondary-eldest93key: int:36
secondary-eldest93val: string:Value36
secondary-eldest94add: int:47
secondary-eldest95key: int:37
secondary-eldest95val: string:Value37
secondary-eldest96add: int:48
secondary-eldest97key: int:38
secondary-eldest97val: string:Value38
secondary-eldest98add: int:49
secondary-eldest99key: int:39
secondary-eldest99val: string:Value39
secondary-eldest9key: int:0
secondary-eldest9val: string:Value0
secondary-ordkeys: int[10]:40,41,42,43,44,45,46,47,48,49
secondary-ordvals: string[10]:Value40,Value41,Value42,Value43,Value44,
 Value45,Value46,Value47,Value48,Value49

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashMapEldest.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Tests to ensure that the eldest entry removal works correctly.
 *
 * @since 2019/05/09
 */
public class TestLinkedHashMapEldest
	extends TestRunnable
{
	/** Maximum entries in the map. */
	public static final int MAX_ENTRIES = 10;
	
	/** Eldest order. */
	int _order;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public void test()
	{
		Map<Integer, String> map = new EldestMap();
		
		// Add a bunch of values
		for (int i = 0; i < MAX_ENTRIES * 5; i++)
		{
			// Used for ordering
			int order = TestLinkedHashMapEldest.this._order++;
			this.secondary("eldest" + order + "add", i);
			
			// Put in value
			map.put(i, "Value" + i);
		}
		
		// Array should be in same order!
		this.secondary("ordkeys",
			map.keySet().<Integer>toArray(new Integer[map.size()]));
		this.secondary("ordvals",
			map.values().<String>toArray(new String[map.size()]));
	}
	
	/**
	 * Map which overrides the eldest entry check.
	 *
	 * @since 2109/05/09
	 */
	public final class EldestMap
		extends LinkedHashMap<Integer, String>
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/09
		 */
		@Override
		protected boolean removeEldestEntry(Map.Entry<Integer, String> __e)
		{
			// Used to make sure the order is correct
			int order = TestLinkedHashMapEldest.this._order++;
			TestLinkedHashMapEldest.this.secondary(
				"eldest" + order + "key", __e.getKey());
			TestLinkedHashMapEldest.this.secondary(
				"eldest" + order + "val", __e.getValue());
			
			// This comes from the documentation example which specifies that
			// a value should be removed
			return this.size() > MAX_ENTRIES;
		}
	}
}

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashSet.in.

1
2
3
4




-
-
-
-
result: int:205464769
thrown: NoExceptionThrown
secondary-intotal: int:205464769
secondary-hashcode: int:205464769

Deleted runt/apis/cldc-compact.test/util/TestLinkedHashSet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































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

package util;

import net.multiphasicapps.tac.TestSupplier;
import java.util.LinkedHashSet;
import java.util.Random;
import java.util.Set;

/**
 * This tests that linked hash set works properly.
 *
 * @since 2018/11/02
 */
public class TestLinkedHashSet
	extends TestSupplier<Integer>
{
	/** Random key used. */
	public static final long KEY =
		0x537175697272656CL;
	
	/** Number of entries to test. */
	public static final int COUNT =
		128;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public Integer test()
	{
		// The set to test
		Set<Integer> links = new LinkedHashSet<>();
		
		// Add entries to the set
		Random rand = new Random(KEY);
		int intotal = 0;
		for (int i = 0; i < COUNT; i++)
		{
			// Generate and store total value
			int v = rand.nextInt();
			intotal += v;
			
			// Store in the map
			if (!links.add(v))
				this.secondary("duplicatekey", true);
		}
		
		// Mark expected value
		this.secondary("intotal", intotal);
		
		// Go through and re-add the same values which should result in the
		// same order
		rand = new Random(KEY);
		for (int i = 0; i < COUNT; i++)
			if (links.add(rand.nextInt()))
				this.secondary("readd" + i, true);
		
		// Go through iterator and match
		rand = new Random(KEY);
		int ittotal = 0;
		for (int i : links)
		{
			if (i != rand.nextInt())
				this.secondary("unmatched", true);
			
			ittotal += i;
		}
		
		// Hashcode
		this.secondary("hashcode", links.hashCode());
		
		return ittotal;
	}
}

Deleted runt/apis/cldc-compact.test/util/TestLinkedList.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.LinkedList;

/**
 * Tests linked list.
 *
 * @since 2019/05/08
 */
public class TestLinkedList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestLinkedList()
	{
		super(new LinkedList<String>());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestLinkedListDeque.in.

1

-
secondary-hashcode: int:1315173338

Deleted runt/apis/cldc-compact.test/util/TestLinkedListDeque.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

































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

package util;

import java.util.LinkedList;

/**
 * Tests linked lists.
 *
 * @since 2019/01/20
 */
public class TestLinkedListDeque
	extends __TestDeque__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/01/20
	 */
	public TestLinkedListDeque()
	{
		super(new LinkedList<Number>());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestRandom.in.

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



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-boolean--00: true
secondary-boolean--01: true
secondary-boolean--02: true
secondary-boolean--03: false
secondary-boolean--04: false
secondary-boolean--05: true
secondary-boolean--06: true
secondary-boolean--07: true
secondary-boolean--08: true
secondary-boolean--09: false
secondary-boolean--10: false
secondary-boolean--11: true
secondary-boolean--12: false
secondary-boolean--13: true
secondary-boolean--14: true
secondary-boolean--15: false
secondary-boolean--16: true
secondary-boolean--17: false
secondary-boolean--18: false
secondary-boolean--19: false
secondary-boolean--20: true
secondary-boolean--21: false
secondary-boolean--22: false
secondary-boolean--23: true
secondary-boolean--24: true
secondary-boolean--25: true
secondary-boolean--26: false
secondary-boolean--27: true
secondary-boolean--28: false
secondary-boolean--29: false
secondary-boolean--30: true
secondary-boolean--31: true
secondary-int--00: int:-128266353
secondary-int--01: int:1948586741
secondary-int--02: int:-737493750
secondary-int--03: int:-1691956655
secondary-int--04: int:981813466
secondary-int--05: int:-162976284
secondary-int--06: int:914154380
secondary-int--07: int:453943797
secondary-int--08: int:-1545361761
secondary-int--09: int:1742258951
secondary-int--10: int:1884219158
secondary-int--11: int:1240009219
secondary-int--12: int:-150729253
secondary-int--13: int:-103157653
secondary-int--14: int:1955413213
secondary-int--15: int:1734636865
secondary-int--16: int:1214260749
secondary-int--17: int:1428227275
secondary-int--18: int:1515069861
secondary-int--19: int:622848097
secondary-int--20: int:425202528
secondary-int--21: int:1696159965
secondary-int--22: int:1491573386
secondary-int--23: int:990471538
secondary-int--24: int:-2068721
secondary-int--25: int:-1104025112
secondary-int--26: int:-813810180
secondary-int--27: int:-1351411048
secondary-int--28: int:-2056461820
secondary-int--29: int:367036826
secondary-int--30: int:717818122
secondary-int--31: int:801130495
secondary-long--00: long:-3163983508611287273
secondary-long--01: long:1650222797263606028
secondary-long--02: long:6817728031649985877
secondary-long--03: long:-3610267759146193707
secondary-long--04: long:-2536078921006665050
secondary-long--05: long:-5303301747738367533
secondary-long--06: long:5521166055606326678
secondary-long--07: long:7264686321048172758
secondary-long--08: long:-7012317779647905034
secondary-long--09: long:7862271327053001528
secondary-long--10: long:-1901553912186736328
secondary-long--11: long:1119445396624625749
secondary-long--12: long:5235895235630161149
secondary-long--13: long:8069826110581587514
secondary-long--14: long:4458715635812528876
secondary-long--15: long:-4444455872085454437
secondary-long--16: long:3777918499557884613
secondary-long--17: long:3889224343776968970
secondary-long--18: long:-8667154457880916043
secondary-long--19: long:-4224915374486675610
secondary-long--20: long:6685784791951315435
secondary-long--21: long:-5103934627298473583
secondary-long--22: long:-6889010091118281366
secondary-long--23: long:5325327304787082085
secondary-long--24: long:5970574507478393377
secondary-long--25: long:8285736199708606439
secondary-long--26: long:7011400902825490744
secondary-long--27: long:-6505535853870468931
secondary-long--28: long:-7388450604473437268
secondary-long--29: long:-9133519556251469603
secondary-long--30: long:-8160769781198250467
secondary-long--31: long:3623915951947550343
secondary-range--00: int:0
secondary-range--01: int:0
secondary-range--02: int:1
secondary-range--03: int:1
secondary-range--04: int:2
secondary-range--05: int:1
secondary-range--06: int:5
secondary-range--07: int:4
secondary-range--08: int:7
secondary-range--09: int:8
secondary-range--10: int:0
secondary-range--11: int:2
secondary-range--12: int:3
secondary-range--13: int:3
secondary-range--14: int:7
secondary-range--15: int:12
secondary-range--16: int:8
secondary-range--17: int:9
secondary-range--18: int:7
secondary-range--19: int:15
secondary-range--20: int:11
secondary-range--21: int:16
secondary-range--22: int:10
secondary-range--23: int:17
secondary-range--24: int:18
secondary-range--25: int:24
secondary-range--26: int:6
secondary-range--27: int:1
secondary-range--28: int:3
secondary-range--29: int:0
secondary-range--30: int:11
secondary-range--31: int:26

Deleted runt/apis/cldc-compact.test/util/TestRandom.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






















































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

package util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.Random;

/**
 * Tests the random number generator, integer values only.
 *
 * @since 2018/11/02
 */
public class TestRandom
	extends TestRunnable
{
	/** Count for values. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0xCAFEBABE);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("boolean-%02d", i),
				rand.nextBoolean());
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("int-%02d", i),
				rand.nextInt());
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("long-%02d", i),
				rand.nextLong());
			
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("range-%02d", i),
				rand.nextInt(i + 1));
	}
}

Deleted runt/apis/cldc-compact.test/util/TestRandomFloat.in.

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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-double--00: long:4583909210855270848
secondary-double--01: long:4602738393933575197
secondary-double--02: long:4603742102265903055
secondary-double--03: long:4604590768449826100
secondary-double--04: long:4604613072216156731
secondary-double--05: long:4603238476080670868
secondary-double--06: long:4600290051921914700
secondary-double--07: long:4606717221631719828
secondary-double--08: long:4582504350769550560
secondary-double--09: long:4602152829906238736
secondary-double--10: long:4606772738959557498
secondary-double--11: long:4607057355126703601
secondary-double--12: long:4598489981875330452
secondary-double--13: long:4576807129618328640
secondary-double--14: long:4606376720726924374
secondary-double--15: long:4604315246192439139
secondary-double--16: long:4605311185659059328
secondary-double--17: long:4600375544876332514
secondary-double--18: long:4600953627928857584
secondary-double--19: long:4604075885202442894
secondary-double--20: long:4599595528618966298
secondary-double--21: long:4602009499117278822
secondary-double--22: long:4595423160873490792
secondary-double--23: long:4598336528600956288
secondary-double--24: long:4604181088498391135
secondary-double--25: long:4590756644732688040
secondary-double--26: long:4601747187517950818
secondary-double--27: long:4598024309499659892
secondary-double--28: long:4583584827350993536
secondary-double--29: long:4596064983813882400
secondary-double--30: long:4595798268525523916
secondary-double--31: long:4590286194157885920
secondary-float--00: int:1064428361
secondary-float--01: int:1056498462
secondary-float--02: int:1057309969
secondary-float--03: int:1027839328
secondary-float--04: int:1032745072
secondary-float--05: int:1031774640
secondary-float--06: int:1061677308
secondary-float--07: int:1064592218
secondary-float--08: int:1057850516
secondary-float--09: int:1050973560
secondary-float--10: int:1064445530
secondary-float--11: int:1060042316
secondary-float--12: int:1030816640
secondary-float--13: int:1063160622
secondary-float--14: int:1058726493
secondary-float--15: int:1052115186
secondary-float--16: int:1064119846
secondary-float--17: int:1054339600
secondary-float--18: int:1062701626
secondary-float--19: int:1031105824
secondary-float--20: int:1059194506
secondary-float--21: int:993181952
secondary-float--22: int:1057526466
secondary-float--23: int:1061922672
secondary-float--24: int:1057421954
secondary-float--25: int:1045750832
secondary-float--26: int:1058543673
secondary-float--27: int:1060877318
secondary-float--28: int:1058661909
secondary-float--29: int:1062276535
secondary-float--30: int:1062789292
secondary-float--31: int:1020083488
secondary-gauss--00: long:-4623803088418409174
secondary-gauss--01: long:4584133852783928400
secondary-gauss--02: long:-4627394787988143985
secondary-gauss--03: long:-4626611366287662152
secondary-gauss--04: long:4609881647929977493
secondary-gauss--05: long:-4617068582227882878
secondary-gauss--06: long:-4618958457578674353
secondary-gauss--07: long:4609087581065641843
secondary-gauss--08: long:4591487963111091550
secondary-gauss--09: long:4590448397979296854
secondary-gauss--10: long:-4632370091595809028
secondary-gauss--11: long:4608509811925940350
secondary-gauss--12: long:4602249218918814087
secondary-gauss--13: long:4590523063934368092
secondary-gauss--14: long:-4614310018215318234
secondary-gauss--15: long:-4617920598175668757
secondary-gauss--16: long:-4613994234367488310
secondary-gauss--17: long:-4621339478468475950
secondary-gauss--18: long:4608279811145892292
secondary-gauss--19: long:-4624123072180092538
secondary-gauss--20: long:4611752626028141074
secondary-gauss--21: long:4606682148419602193
secondary-gauss--22: long:4586613298334863399
secondary-gauss--23: long:-4628618392113107096
secondary-gauss--24: long:4604616087800580199
secondary-gauss--25: long:4606989109614282399
secondary-gauss--26: long:4606481251143648582
secondary-gauss--27: long:4605185051404723134
secondary-gauss--28: long:-4614152961942226543
secondary-gauss--29: long:-4616674189163974394
secondary-gauss--30: long:4599325178184023106
secondary-gauss--31: long:-4622107386309634845

Deleted runt/apis/cldc-compact.test/util/TestRandomFloat.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


















































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

package util;

import net.multiphasicapps.tac.TestRunnable;
import java.util.Random;

/**
 * Test random number generator, floating point values only.
 *
 * @since 2018/11/02
 */
public class TestRandomFloat
	extends TestRunnable
{
	/** Count for values. */
	public static final int COUNT =
		32;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public void test()
	{
		Random rand = new Random(0xCAFED00D);
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("double-%02d", i),
				Double.doubleToRawLongBits(rand.nextDouble()));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("float-%02d", i),
				Float.floatToRawIntBits(rand.nextFloat()));
		
		for (int i = 0; i < COUNT; i++)
			this.secondary(String.format("gauss-%02d", i),
				Double.doubleToRawLongBits(rand.nextGaussian()));
	}
}

Deleted runt/apis/cldc-compact.test/util/TestServiceLoader.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-again--util-dserviceloader-dimpls-dcomfortabledrey: string:A
 \_very\_comfortable\_drey!
secondary-again--util-dserviceloader-dimpls-dcutesquirrels: string:Cut
 e\_squirrels!
secondary-again--util-dserviceloader-dimpls-dstashtheacorns: string:St
 ash\_all\_the\_acorns!
secondary-cache--util-dserviceloader-dimpls-dcomfortabledrey: string:A
 \_very\_comfortable\_drey!
secondary-cache--util-dserviceloader-dimpls-dcutesquirrels: string:Cut
 e\_squirrels!
secondary-cache--util-dserviceloader-dimpls-dstashtheacorns: string:St
 ash\_all\_the\_acorns!
secondary-init--util-dserviceloader-dimpls-dcomfortabledrey: string:A\
 _very\_comfortable\_drey!
secondary-init--util-dserviceloader-dimpls-dcutesquirrels: string:Cute
 \_squirrels!
secondary-init--util-dserviceloader-dimpls-dstashtheacorns: string:Sta
 sh\_all\_the\_acorns!

Deleted runt/apis/cldc-compact.test/util/TestServiceLoader.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



















































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

package util;

import java.util.ServiceLoader;
import net.multiphasicapps.tac.TestRunnable;
import util.serviceloader.ServiceThingy;

/**
 * Tests the service loader.
 *
 * @since 2018/12/06
 */
public class TestServiceLoader
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public void test()
	{
		ServiceLoader<ServiceThingy> sl = ServiceLoader.<ServiceThingy>load(
			ServiceThingy.class);
		
		// Initial run
		for (ServiceThingy sv : sl)
			this.secondary("init-" + sv.getClass().getName(), sv.toString());
		
		// Cached run
		for (ServiceThingy sv : sl)
			this.secondary("cache-" + sv.getClass().getName(), sv.toString());
		
		// Clear cache
		sl.reload();
		
		// Should be fresh
		for (ServiceThingy sv : sl)
			this.secondary("again-" + sv.getClass().getName(), sv.toString());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestSorting.in.

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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-arraybyte01: byte[1]:-85
secondary-arraybyte02: byte[2]:-85,1
secondary-arraybyte03: byte[3]:-85,-57,1
secondary-arraybyte04: byte[4]:-85,-80,-57,1
secondary-arraybyte08: byte[8]:-113,-102,-92,-85,-80,-57,1,36
secondary-arraybyte13: byte[13]:-125,-113,-102,-94,-92,-85,-80,-61,-57
 ,1,17,36,47
secondary-arraybyte26: byte[26]:-125,-113,-102,-99,-94,-92,-92,-85,-80
 ,-75,-61,-57,-37,-31,-4,1,1,2,17,36,47,52,58,95,100,115
secondary-arraychar01: char[1]:26283
secondary-arraychar02: char[2]:26283,46337
secondary-arraychar03: char[3]:26283,46337,51911
secondary-arraychar04: char[4]:8880,26283,46337,51911
secondary-arraychar08: char[8]:410,8880,15268,26283,46337,51911,57124,
 59791
secondary-arraychar13: char[13]:410,785,4258,8880,15268,15919,26283,33
 987,46337,51911,52099,57124,59791
secondary-arraychar26: char[26]:410,785,1505,4258,4609,6003,6052,8880,
 15268,15919,19508,24415,26283,32731,33987,37301,40605,43772,46180,4633
 7,47674,51911,52099,56834,57124,59791
secondary-arrayint01: int[1]:-1442945365
secondary-arrayint02: int[2]:-1442945365,-1016548095
secondary-arrayint03: int[3]:-1442945365,-1016548095,1962592967
secondary-arrayint04: int[4]:-1442945365,-1016548095,1094656688,196259
 2967
secondary-arrayint08: int[8]:-1442945365,-1016548095,-458096230,930275
 108,1094656688,1677212580,1827465615,1962592967
secondary-arrayint13: int[13]:-1442945365,-1075280701,-1016548095,-458
 096230,930275108,1094656688,1543966882,1677212580,1827465615,185114577
 5,1962592967,2041709329,2105985923
secondary-arrayint26: int[26]:-2145218123,-1872816220,-1574936737,-144
 2945365,-1075280701,-1016548095,-458096230,-223996045,68659964,4926387
 21,505839579,823057922,930275108,1068715060,1094656688,1178377885,1543
 966882,1677212580,1754641508,1827465615,1851145775,1962592967,20417093
 29,2054142522,2092500449,2105985923
secondary-arrayobject01: int[1]:-1442945365
secondary-arrayobject02: int[2]:-1442945365,-1016548095
secondary-arrayobject03: int[3]:-1442945365,-1016548095,1962592967
secondary-arrayobject04: int[4]:-1442945365,-1016548095,1094656688,196
 2592967
secondary-arrayobject08: int[8]:-1442945365,-1016548095,-458096230,930
 275108,1094656688,1677212580,1827465615,1962592967
secondary-arrayobject13: int[13]:-1442945365,-1075280701,-1016548095,-
 458096230,930275108,1094656688,1543966882,1677212580,1827465615,185114
 5775,1962592967,2041709329,2105985923
secondary-arrayobject26: int[26]:-2145218123,-1872816220,-1574936737,-
 1442945365,-1075280701,-1016548095,-458096230,-223996045,68659964,4926
 38721,505839579,823057922,930275108,1068715060,1094656688,1178377885,1
 543966882,1677212580,1754641508,1827465615,1851145775,1962592967,20417
 09329,2054142522,2092500449,2105985923
secondary-arrayshort01: short[1]:26283
secondary-arrayshort02: short[2]:-19199,26283
secondary-arrayshort03: short[3]:-19199,-13625,26283
secondary-arrayshort04: short[4]:-19199,-13625,8880,26283
secondary-arrayshort08: short[8]:-19199,-13625,-8412,-5745,410,8880,15
 268,26283
secondary-arrayshort13: short[13]:-31549,-19199,-13625,-13437,-8412,-5
 745,410,785,4258,8880,15268,15919,26283
secondary-arrayshort26: short[26]:-31549,-28235,-24931,-21764,-19356,-
 19199,-17862,-13625,-13437,-8702,-8412,-5745,410,785,1505,4258,4609,60
 03,6052,8880,15268,15919,19508,24415,26283,32731
secondary-listarray01: int[1]:-1442945365
secondary-listarray02: int[2]:-1442945365,-1016548095
secondary-listarray03: int[3]:-1442945365,-1016548095,1962592967
secondary-listarray04: int[4]:-1442945365,-1016548095,1094656688,19625
 92967
secondary-listarray08: int[8]:-1442945365,-1016548095,-458096230,93027
 5108,1094656688,1677212580,1827465615,1962592967
secondary-listarray13: int[13]:-1442945365,-1075280701,-1016548095,-45
 8096230,930275108,1094656688,1543966882,1677212580,1827465615,18511457
 75,1962592967,2041709329,2105985923
secondary-listarray26: int[26]:-2145218123,-1872816220,-1574936737,-14
 42945365,-1075280701,-1016548095,-458096230,-223996045,68659964,492638
 721,505839579,823057922,930275108,1068715060,1094656688,1178377885,154
 3966882,1677212580,1754641508,1827465615,1851145775,1962592967,2041709
 329,2054142522,2092500449,2105985923
secondary-listlinked01: int[1]:-1442945365
secondary-listlinked02: int[2]:-1442945365,-1016548095
secondary-listlinked03: int[3]:-1442945365,-1016548095,1962592967
secondary-listlinked04: int[4]:-1442945365,-1016548095,1094656688,1962
 592967
secondary-listlinked08: int[8]:-1442945365,-1016548095,-458096230,9302
 75108,1094656688,1677212580,1827465615,1962592967
secondary-listlinked13: int[13]:-1442945365,-1075280701,-1016548095,-4
 58096230,930275108,1094656688,1543966882,1677212580,1827465615,1851145
 775,1962592967,2041709329,2105985923
secondary-listlinked26: int[26]:-2145218123,-1872816220,-1574936737,-1
 442945365,-1075280701,-1016548095,-458096230,-223996045,68659964,49263
 8721,505839579,823057922,930275108,1068715060,1094656688,1178377885,15
 43966882,1677212580,1754641508,1827465615,1851145775,1962592967,204170
 9329,2054142522,2092500449,2105985923

Deleted runt/apis/cldc-compact.test/util/TestSorting.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that arrays can be sorted.
 *
 * @since 2019/05/09
 */
public class TestSorting
	extends TestRunnable
{
	/** Random seed. */
	public static final int SEED =
		123456789;
	
	/** The number of elements to sort through. */
	private static final int[] _COUNTS =
		new int[]{1, 2, 3, 4, 8, 13, 26};
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public void test()
	{
		for (int c = 0, cn = _COUNTS.length; c < cn; c++)
		{
			Random rand;
			
			int count = _COUNTS[c];
			String cid = String.format("%02d", count);
		
			// Byte
			rand = new Random(SEED);
			byte[] ab = new byte[count];
			for (int i = 0; i < count; i++)
				ab[i] = (byte)rand.nextInt();
			Arrays.sort(ab);
			this.secondary("arraybyte" + cid, ab);
			
			// Short
			rand = new Random(SEED);
			short[] as = new short[count];
			for (int i = 0; i < count; i++)
				as[i] = (short)rand.nextInt();
			Arrays.sort(as);
			this.secondary("arrayshort" + cid, as);
			
			// Char
			rand = new Random(SEED);
			char[] ac = new char[count];
			for (int i = 0; i < count; i++)
				ac[i] = (char)rand.nextInt();
			Arrays.sort(ac);
			this.secondary("arraychar" + cid, ac);
			
			// Integer
			rand = new Random(SEED);
			int[] ai = new int[count];
			for (int i = 0; i < count; i++)
				ai[i] = rand.nextInt();
			Arrays.sort(ai);
			this.secondary("arrayint" + cid, ai);
			
			// Object (just integers)
			rand = new Random(SEED);
			Integer[] ao = new Integer[count];
			for (int i = 0; i < count; i++)
				ao[i] = rand.nextInt();
			Arrays.sort(ao);
			this.secondary("arrayobject" + cid, ao);
			
			// Array List
			rand = new Random(SEED);
			List<Integer> la = new ArrayList<>(count);
			for (int i = 0; i < count; i++)
				la.add(rand.nextInt());
			Collections.sort(la);
			this.secondary("listarray" + cid,
				la.<Integer>toArray(new Integer[count]));
			
			// Linked List
			rand = new Random(SEED);
			List<Integer> ll = new LinkedList<>();
			for (int i = 0; i < count; i++)
				ll.add(rand.nextInt());
			Collections.sort(ll);
			this.secondary("listlinked" + cid,
				ll.<Integer>toArray(new Integer[count]));
		}
	}
}

Deleted runt/apis/cldc-compact.test/util/TestStackAsList.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.Stack;

/**
 * Tests the stack class but solely to make sure that the {@link Vector} it
 * inherits from has not been broken.
 *
 * @since 2019/05/08
 */
public class TestStackAsList
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestStackAsList()
	{
		super(new Stack<String>());
	}
}

Deleted runt/apis/cldc-compact.test/util/TestVector.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.Vector;

/**
 * Tests the old-style vector.
 *
 * @since 2019/05/08
 */
public class TestVector
	extends __TestList__
{
	/**
	 * Initializes the test.
	 *
	 * @since 2019/05/08
	 */
	public TestVector()
	{
		super(new Vector<String>());
	}
}

Deleted runt/apis/cldc-compact.test/util/__TestDeque__.in.

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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-array: int[17]:1234,200,100,0,1,2,3,4,5,6,7,8,9,300,400,500,600
secondary-array2: int[10]:2,3,4,5,6,7,8,9,300,400
secondary-element: int:1
secondary-getfirst: int:200
secondary-getlast: int:400
secondary-init--add--0: true
secondary-init--add--1: true
secondary-init--add--2: true
secondary-init--add--3: true
secondary-init--add--4: true
secondary-init--add--5: true
secondary-init--add--6: true
secondary-init--add--7: true
secondary-init--add--8: true
secondary-init--add--9: true
secondary-iterator--ascending: int[17]:
 1234,200,100,0,1,2,3,4,5,6,7,8,9,300,400,500,600
secondary-iterator--descending: int[17]:
 600,500,400,300,9,8,7,6,5,4,3,2,1,0,100,200,1234
secondary-offer--first: true
secondary-offer--last: true
secondary-peek: int:1
secondary-peekfirst: int:100
secondary-peeklast: int:400
secondary-poll: int:0
secondary-pollfirst: int:200
secondary-polllast: int:500
secondary-pop: int:1
secondary-remove: int:100
secondary-removefirst: int:1234
secondary-removelast: int:600
secondary-size--a: int:12
secondary-size--b: int:17
secondary-remove--first--0: true
secondary-remove--first--10: false
secondary-remove--first--12: false
secondary-remove--first--14: false
secondary-remove--first--2: true
secondary-remove--first--4: true
secondary-remove--first--6: true
secondary-remove--first--8: true
secondary-remove--last--1: true
secondary-remove--last--11: false
secondary-remove--last--13: false
secondary-remove--last--3: true
secondary-remove--last--5: true
secondary-remove--last--7: true
secondary-remove--last--9: true
secondary-other--add--0: true
secondary-other--add--1: true
secondary-other--add--2: true
secondary-other--add--3: true
secondary-other--add--4: true
secondary-other--add--5: true
secondary-other--add--6: true
secondary-other--add--7: true
secondary-other--add--8: true
secondary-other--add--9: true
secondary-has14: false
secondary-has500: false
secondary-has7: true
secondary-array3: int[20]:2,3,4,5,6,7,8,9,300,400,0,1,2,3,4,5,6,7,8,9
secondary-array4: int[15]:3,5,7,9,300,400,1,2,3,4,5,6,7,8,9
secondary-array5: int[10]:3,5,7,9,300,400,2,4,6,8
secondary-array6: int[0]:
secondary-arrayover: int[34]:1234,200,100,0,1,2,3,4,5,6,7,8,
 9,300,400,500,600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
secondary-arraygrow: int[17]:1234,200,100,0,1,2,3,4,5,6,7,8,
 9,300,400,500,600

Deleted runt/apis/cldc-compact.test/util/__TestDeque__.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
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














































































































































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

package util;

import java.util.Deque;
import java.util.Iterator;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Performs tests on deques.
 *
 * @since 2019/01/20
 */
abstract class __TestDeque__
	extends TestRunnable
{
	/** The deque to test. */
	protected final Deque<Number> deque;
	
	/**
	 * Initializes the base test.
	 *
	 * @param __d The deque to test on.
	 * @since 2019/01/20
	 */
	public __TestDeque__(Deque<Number> __d)
	{
		this.deque = __d;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public void test()
	{
		Deque<Number> q = this.deque;
		
		// Add a bunch of numbers
		for (int i = 0; i < 10; i++)
			this.secondary("init-add-" + i, q.add(i));
		
		// Offer first values
		q.addFirst(100);
		this.secondary("offer-first", q.offerFirst(200));
		
		// Size of this
		this.secondary("size-a", q.size());
		
		// Offer last values
		q.addLast(300);
		this.secondary("offer-last", q.offerLast(400));
		
		// Queue
		q.add(500);
		q.offer(600);
		
		// Stack
		q.push(1234);
		
		// Size of this
		int size;
		this.secondary("size-b", (size = q.size()));
		
		// Get iterators from both positions
		int[] ita = new int[size];
		Iterator<Number> it = q.iterator();
		for (int i = 0; it.hasNext(); i++)
			ita[i] = it.next().intValue();
		this.secondary("iterator-ascending", ita);
		
		// And descend it
		it = q.descendingIterator();
		for (int i = 0; it.hasNext(); i++)
			ita[i] = it.next().intValue();
		this.secondary("iterator-descending", ita);
		
		// Hashcode
		this.secondary("hashcode", q.hashCode());
		
		// As array form
		this.secondary("array", q.<Integer>toArray(new Integer[q.size()]));
		this.secondary("arraygrow",
			q.<Integer>toArray(new Integer[q.size() / 2]));
		this.secondary("arrayover",
			q.<Integer>toArray(new Integer[q.size() + 17]));
		
		// Do removals
		this.secondary("removefirst", q.removeFirst());
		this.secondary("getfirst", q.getFirst());
		this.secondary("pollfirst", q.pollFirst());
		this.secondary("peekfirst", q.peekFirst());
		this.secondary("removelast", q.removeLast());
		this.secondary("polllast", q.pollLast());
		this.secondary("getlast", q.getLast());
		this.secondary("peeklast", q.peekLast());
		this.secondary("remove", q.remove());
		this.secondary("poll", q.poll());
		this.secondary("element", q.element());
		this.secondary("peek", q.peek());
		this.secondary("pop", q.pop());
		
		// Array form again
		this.secondary("array2", q.<Integer>toArray(new Integer[q.size()]));
		
		// Contains some things?
		this.secondary("has7", q.contains(7));
		this.secondary("has14", q.contains(14));
		this.secondary("has500", q.contains(500));
		
		// Add a bunch of numbers
		for (int i = 0; i < 10; i++)
			this.secondary("other-add-" + i, q.add(i));
			
		// Array form again!
		this.secondary("array3", q.<Integer>toArray(new Integer[q.size()]));
		
		// Remove first occurance of value
		for (int i = 0; i < 15; i += 2)
			this.secondary("remove-first-" + i, q.removeFirstOccurrence(i));
		this.secondary("array4", q.<Integer>toArray(new Integer[q.size()]));
		
		// Remove last occurance of value
		for (int i = 1; i < 15; i += 2)
			this.secondary("remove-last-" + i, q.removeLastOccurrence(i));
		this.secondary("array5", q.<Integer>toArray(new Integer[q.size()]));
		
		// Clear it
		q.clear();
		this.secondary("array6", q.<Integer>toArray(new Integer[q.size()]));
	}
}

Deleted runt/apis/cldc-compact.test/util/__TestList__.in.

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




































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
MANIFEST-VERSION: 1.0
result: NoResult
thrown: NoExceptionThrown
secondary-add1: true
secondary-add10: true
secondary-add11: true
secondary-add12: true
secondary-add13: true
secondary-add14: true
secondary-add15: true
secondary-add16: true
secondary-add17: true
secondary-add2: true
secondary-add3: true
secondary-add4: true
secondary-add5: true
secondary-add6: true
secondary-add7: true
secondary-add8: true
secondary-add9: true
secondary-addempty: false
secondary-addsize: int:4
secondary-array: string[13]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,Squi
 rrels!
secondary-arrayover: string[30]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,
 Squirrels!,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL
 ,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL,\NULL
secondary-arrowgrow: string[13]:Hello!,1,2,Xer!,6,8,10,11,13,14,16,17,
 Squirrels!
secondary-bulkempty: false
secondary-bulksize: int:19
secondary-clearempty: true
secondary-clearsize: int:0
secondary-get13: string:Is!
secondary-get17: string:16
secondary-get2: string:1
secondary-get29: throwable:IndexOutOfBoundsException,RuntimeException,
 Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_19
secondary-get6: string:Xer!
secondary-hascuteafter: false
secondary-hascutebefore: true
secondary-hashcode: int:1797125451
secondary-hasmoresquirrels: true
secondary-hasmoresquirrelsstill: true
secondary-initialioob: throwable:IndexOutOfBoundsException,RuntimeExce
 ption,Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_0
secondary-initialisempty: true
secondary-initialnocont: false
secondary-initialzerosize: int:0
secondary-itequal0: true
secondary-itequal1: true
secondary-itequal10: true
secondary-itequal11: true
secondary-itequal12: true
secondary-itequal13: true
secondary-itequal14: true
secondary-itequal15: true
secondary-itequal16: true
secondary-itequal17: true
secondary-itequal18: true
secondary-itequal2: true
secondary-itequal3: true
secondary-itequal4: true
secondary-itequal5: true
secondary-itequal6: true
secondary-itequal7: true
secondary-itequal8: true
secondary-itequal9: true
secondary-moresquirrels: true
secondary-noneleft: throwable:java.util.NoSuchElementException,java.la
 ng.RuntimeException,Exception,Throwable
secondary-previtequal0: true
secondary-previtequal1: true
secondary-previtequal10: true
secondary-previtequal11: true
secondary-previtequal12: true
secondary-previtequal13: true
secondary-previtequal14: true
secondary-previtequal15: true
secondary-previtequal2: true
secondary-previtequal3: true
secondary-previtequal4: true
secondary-previtequal5: true
secondary-previtequal6: true
secondary-previtequal7: true
secondary-previtequal8: true
secondary-previtequal9: true
secondary-prevnoneleft: throwable:java.util.NoSuchElementException,jav
 a.lang.RuntimeException,Exception,Throwable
secondary-removeempty: false
secondary-removeindex: string:Are!
secondary-removemoresquirrels: true
secondary-removesize: int:2
secondary-removevalue: true
secondary-set13: string:12
secondary-set29: throwable:IndexOutOfBoundsException,RuntimeException,
 Exception,Throwable:Index\_29\_out\_of\_bounds\_for\_length\_19
secondary-set6: string:5
secondary-stringform: string:[Hello!,\_1,\_2,\_Xer!,\_6,\_8,\_10,\_11,
 \_13,\_14,\_16,\_17,\_Squirrels!]

Deleted runt/apis/cldc-compact.test/util/__TestList__.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
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
191
192
193
194
195
196
197
198
199







































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 util;

import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import net.multiphasicapps.tac.TestRunnable;

/**
 * This tests that lists work correctly and do all the things they should do.
 *
 * @since 2019/05/08
 */
abstract class __TestList__
	extends TestRunnable
{
	/** The list being tested. */
	protected final List<String> list;
	
	/**
	 * Initializes the test with the list to work with.
	 *
	 * @param __l The list to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	__TestList__(List<String> __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.list = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public void test()
	{
		List<String> list = this.list;
		
		// Initial list is empty and has zero size
		this.secondary("initialzerosize", list.size());
		this.secondary("initialisempty", list.isEmpty());
		
		// Initial list does not contain value
		this.secondary("initialnocont", list.contains("Cutie squirrels!"));
		
		// Initial list throws IOOB
		try
		{
			this.secondary("initialioob", list.get(29));
		}
		catch (Throwable t)
		{
			this.secondary("initialioob", t);
		}
		
		// Add various entries to the list
		this.secondary("add1", list.add("Hello!"));
		this.secondary("add2", list.add("Squirrels!"));
		this.secondary("add3", list.add("Are!"));
		this.secondary("add4", list.add("Cute!"));
		
		// Must be the correct size
		this.secondary("addempty", list.isEmpty());
		this.secondary("addsize", list.size());
		
		// Remove the second element
		this.secondary("removeindex", list.remove(2));
		
		// Remove by value
		this.secondary("hascutebefore", list.contains("Cute!"));
		this.secondary("removevalue", list.remove("Cute!"));
		this.secondary("hascuteafter", list.contains("Cute!"));
		
		// Remove size
		this.secondary("removeempty", list.isEmpty());
		this.secondary("removesize", list.size());
		
		// Add a bunch of entries
		for (int i = 1; i <= 17; i++)
			this.secondary("add" + i, list.add(Integer.toString(i)));
		
		// Set some element values
		this.secondary("set6", list.set(6, "Xer!"));
		this.secondary("set13", list.set(13, "Is!"));
		try
		{
			this.secondary("set29", list.set(29, "Cute!"));
		}
		catch (Throwable t)
		{
			this.secondary("set29", t);
		}
		
		// Get some values
		this.secondary("get2", list.get(2));
		this.secondary("get6", list.get(6));
		this.secondary("get13", list.get(13));
		this.secondary("get17", list.get(17));
		try
		{
			this.secondary("get29", list.get(29));
		}
		catch (Throwable t)
		{
			this.secondary("get29", t);
		}
			
		// Count sizes more
		this.secondary("bulkempty", list.isEmpty());
		this.secondary("bulksize", list.size());
		
		// Add another squirrels, then remove it
		this.secondary("moresquirrels", list.add("Squirrels!"));
		this.secondary("hasmoresquirrels", list.contains("Squirrels!"));
		this.secondary("removemoresquirrels", list.remove("Squirrels!"));
		this.secondary("hasmoresquirrelsstill", list.contains("Squirrels!"));
		
		// Hashcode
		this.secondary("hashcode", list.hashCode());
		
		// Go through and check iteration sequence
		Object[] array = list.toArray();
		ListIterator<String> it = list.listIterator();
		for (int i = 0, n = array.length; i < n; i++)
		{
			// Must be equal
			this.secondary("itequal" + i, Objects.equals(array[i], it.next()));
			
			// Remove some elements
			if (i == 3 || i == 7 || i == 12)
				it.remove();
		}
		
		// The iterator should be at the end
		try
		{
			this.secondary("noneleft", it.next());
		}
		catch (Throwable t)
		{
			this.secondary("noneleft", t);
		}
		
		// Go back down the iterator
		array = list.toArray();
		for (int i = array.length - 1; i >= 0; i--)
		{
			// Must be equal
			this.secondary("previtequal" + i,
				Objects.equals(array[i], it.previous()));
			
			// Remove some elements
			if (i == 3 || i == 7 || i == 12)
				it.remove();
		}
		
		// The iterator should be at the end
		try
		{
			this.secondary("prevnoneleft", it.previous());
		}
		catch (Throwable t)
		{
			this.secondary("prevnoneleft", t);
		}
		
		// As array form
		this.secondary("array",
			list.<String>toArray(new String[list.size()]));
		this.secondary("arrowgrow",
			list.<String>toArray(new String[list.size() / 2]));
		this.secondary("arrayover",
			list.<String>toArray(new String[list.size() + 17]));
		
		// Check string result
		this.secondary("stringform", list.toString());
		
		// Clear and count size
		list.clear();
		this.secondary("clearempty", list.isEmpty());
		this.secondary("clearsize", list.size());
	}
}

Deleted runt/apis/cldc-compact.test/util/serviceloader/ServiceThingy.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















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

package util.serviceloader;

/**
 * A service thing that is supported.
 *
 * @since 2018/12/06
 */
public interface ServiceThingy
{
}

Deleted runt/apis/cldc-compact.test/util/serviceloader/impls/ComfortableDrey.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

































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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class ComfortableDrey
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "A very comfortable drey!";
	}
}

Deleted runt/apis/cldc-compact.test/util/serviceloader/impls/CuteSquirrels.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

































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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class CuteSquirrels
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "Cute squirrels!";
	}
}

Deleted runt/apis/cldc-compact.test/util/serviceloader/impls/StashTheAcorns.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

































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

package util.serviceloader.impls;

import util.serviceloader.ServiceThingy;

/**
 * Test service for the service loader.
 *
 * @since 2018/12/06
 */
public class StashTheAcorns
	implements ServiceThingy
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		return "Stash all the acorns!";
	}
}

Deleted runt/apis/cldc-compact.test/util/serviceloader/impls/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * Contains some implementations of services.
 *
 * @since 2018/12/06
 */

package util.serviceloader.impls;

Deleted runt/apis/cldc-compact.test/util/serviceloader/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * This package contains the classes used for service loader tests.
 *
 * @since 2018/12/06
 */

package util.serviceloader;

Deleted runt/apis/cldc-compact/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: a41e003e-598d-4ba0-a935-33b2cf30d9cb
X-SquirrelJME-Error: ZZ
X-SquirrelJME-Name: Connection Limited Device Configuration (Compact)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 1.8
X-SquirrelJME-Group: required
X-SquirrelJME-Description: This is the standard JavaME 8 Connection 
 Limited  Device Configuration which contains the core classes used 
 by Java ME.
X-SquirrelJME-NoDependsConfiguration: true
X-SquirrelJME-DefinedConfigurations: CLDC-1.8-Compact CLDC-1.1 
 CLDC-1.0

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/Assembly.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 class is used special by the compiler to transform all the various
 * operations into regular instructions rather than method calls.
 *
 * The compiler will take all of the method arguments and instead use their
 * inputs and outputs from the values of registers instead. However due to
 * this, this means that these instructions are purely primitive in that
 * they must not depend on any aspect of the virtual machine.
 *
 * @since 2019/04/20
 */
public final class Assembly
{
	/**
	 * Not used.
	 *
	 * @since 2019/04/20
	 */
	private Assembly()
	{
	}
	
	/**
	 * Returns the array length of the given object.
	 *
	 * @param __o The object to get the length of.
	 * @return The length of the array.
	 * @since 2019/05/24
	 */
	public static native int arrayLength(Object __o);
	
	/**
	 * Atomic comparison and set.
	 *
	 * @param __comp The value to compare and if matches, {@code __set} is
	 * written.
	 * @param __set The value to set if matched.
	 * @param __addr The address to write to.
	 * @return The value that was read before the set.
	 * @since 2019/07/01
	 */
	public static native int atomicCompareGetAndSet(int __comp, int __set,
		int __addr);
	
	/**
	 * Atomically decrements a value and returns the result.
	 *
	 * @param __addr The address to decrement.
	 * @return The get value.
	 * @since 2019/07/01
	 */
	public static native int atomicDecrementAndGet(int __addr);
	
	/**
	 * Atomically increments a value.
	 *
	 * @param __addr The address to increment.
	 * @since 2019/07/01
	 */
	public static native void atomicIncrement(int __addr);
	
	/**
	 * Trigger breakpoint within the virtual machine.
	 *
	 * @since 2019/04/21
	 */
	public static native void breakpoint();
	
	/**
	 * Returns the class info pointer of {@code boolean}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfBoolean();
	
	/**
	 * Returns the class info pointer of {@code byte}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfByte();
	
	/**
	 * Returns the class info pointer of {@code char}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfCharacter();
	
	/**
	 * Returns the class info pointer of {@code double}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfDouble();
	
	/**
	 * Returns the class info pointer of {@code float}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfFloat();
	
	/**
	 * Returns the class info pointer of {@code int}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfInteger();
	
	/**
	 * Returns the class info pointer of {@code long}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfLong();
	
	/**
	 * Returns the class info pointer of {@code short}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfShort();
	
	/**
	 * Packs the given two integers to a double value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2019/06/21
	 */
	public static native double doublePack(int __hi, int __lo);
	
	/**
	 * Double to raw long bits.
	 *
	 * @param __d The input double.
	 * @return The raw long bits.
	 * @since 2018/11/03
	 */
	public static native long doubleToRawLongBits(double __d);
	
	/**
	 * Performs explicit exception handling.
	 *
	 * @since 2019/04/28
	 */
	public static native void exceptionHandle();
	
	/**
	 * Float to raw int bits.
	 *
	 * @param __d The input float.
	 * @return The raw int bits.
	 * @since 2018/11/04
	 */
	public static native int floatToRawIntBits(float __f);
	
	/**
	 * Integer bits to float.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static native float intBitsToFloat(int __b);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a,
		int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a,
		int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool pointer to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Loads a value from the constant pool at the given index.
	 *
	 * @return The index of the value in the constant pool.
	 * @since 2019/04/28
	 */
	public static native int loadPool(int __i);
	
	/**
	 * Long bits to double.
	 *
	 * @param __b The input bits.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static native double longBitsToDouble(long __b);
	
	/**
	 * Packs the given two integers to a long value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The long value.
	 * @since 2019/06/21
	 */
	public static native long longPack(int __hi, int __lo);
	
	/**
	 * Unpack high value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackHigh(long __v);
	
	/**
	 * Unpack low value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackLow(long __v);
	
	/**
	 * Reads byte from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadByte(int __p, int __o);
	
	/**
	 * Reads integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/21
	 */
	public static native int memReadInt(int __p, int __o);
	
	/**
	 * Reads big endian Java integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaInt(int __p, int __o);
	
	/**
	 * Reads big endian Java short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaShort(int __p, int __o);
	
	/**
	 * Reads short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadShort(int __p, int __o);
	
	/**
	 * Writes byte to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteByte(int __p, int __o, int __v);
	
	/**
	 * Writes integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteInt(int __p, int __o, int __v);
	
	/**
	 * Writes big endian Java integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaInt(int __p, int __o, int __v);
	
	/**
	 * Writes big endian Java short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaShort(int __p, int __o, int __v);
	
	/**
	 * Writes short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteShort(int __p, int __o, int __v);
	
	/**
	 * Used to convert an object to a pointer.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native int objectToPointer(Object __o);
	
	/**
	 * Used to convert an object to a pointer, do use reference queing for it
	 * so that if the object is a candidate for reference counting it will
	 * be uncounted.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native int objectToPointerRefQueue(Object __o);
	
	/**
	 * Used to convert a pointer to an object.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native Object pointerToObject(int __p);
	
	/**
	 * Used to convert a pointer to a class info type.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native ClassInfo pointerToClassInfo(int __p);
	
	/**
	 * Perform reference counting logic on object.
	 *
	 * @param __p The object to count up.
	 * @since 2019/05/25
	 */
	public static native void refCount(int __p);
	
	/**
	 * Perform reference uncounting logic on object.
	 *
	 * @param __p The object to count down.
	 * @since 2019/05/25
	 */
	public static native void refUncount(int __p);
	
	/**
	 * Return from the current frame.
	 *
	 * @since 2019/04/21
	 */
	public static native void returnFrame();
	
	/**
	 * Returns from the current frame, returning the given value.
	 *
	 * @param __v The value to return.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __v);
	
	/**
	 * Returns from the current frame, returning both values.
	 *
	 * @param __h The high value.
	 * @param __l The low value.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __h, int __l);
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2019/04/28
	 */
	public static native int specialGetExceptionRegister();
	
	/**
	 * Returns the value of the current pool register.
	 *
	 * @return The value of the pool register.
	 * @since 2019/05/01
	 */
	public static native int specialGetPoolRegister();
	
	/**
	 * Returns the value of the return register, for long return values this
	 * is the first high register.
	 *
	 * @return The value of the return register.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnRegister();
	
	/**
	 * Returns the value of the return register, the first high value.
	 *
	 * @return The value of the return register, the first high value.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnHighRegister();
	
	/**
	 * Returns the value of the return register, the second low value.
	 *
	 * @return The value of the return register, the second low value.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnLowRegister();
	
	/**
	 * Reads the value of the static field register.
	 *
	 * @return The value of the static field register.
	 * @since 2019/04/22
	 */
	public static native int specialGetStaticFieldRegister();
	
	/**
	 * Returns the register representing the current thread.
	 *
	 * @return The current thread register.
	 * @since 2019/04/22
	 */
	public static native int specialGetThreadRegister();
	
	/**
	 * Sets the value of the exception register.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/28
	 */
	public static native void specialSetExceptionRegister(int __v);
	
	/**
	 * Sets the value of the constant pool register.
	 *
	 * @param __v The new value of the constant pool register.
	 * @since 2019/05/01
	 */
	public static native void specialSetPoolRegister(int __v);
	
	/**
	 * Sets the value of the static field register.
	 *
	 * @param __v The new value of the static field register.
	 * @since 2019/04/22
	 */
	public static native void specialSetStaticFieldRegister(int __v);
	
	/**
	 * Sets the current thread pointer.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/27
	 */
	public static native void specialSetThreadRegister(int __v);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/CallStackItem.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 single item within the call stack request.
 *
 * @since 2019/06/16
 */
public interface CallStackItem
{
	/** The class name. */
	public static final byte CLASS_NAME =
		0;
	
	/** The method name. */
	public static final byte METHOD_NAME =
		1;
	
	/** The method type. */
	public static final byte METHOD_TYPE =
		2;
	
	/** The current file. */
	public static final byte SOURCE_FILE =
		3;
	
	/** Source line. */
	public static final byte SOURCE_LINE =
		4;
	
	/** The PC address. */
	public static final byte PC_ADDRESS =
		5;
	
	/** Java operation. */
	public static final byte JAVA_OPERATION =
		6;
	
	/** Java PC address. */
	public static final byte JAVA_PC_ADDRESS =
		7;
	
	/** The current task ID. */
	public static final byte TASK_ID =
		8;
	
	/** The number of supported items. */
	public static final byte NUM_ITEMS =
		9;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/ClassInfo.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 contains class information which is used to define the information
 * that is needed to parse it properly.
 *
 * @since 2019/05/25
 */
public final class ClassInfo
{
	/** The magic number which should be used. */
	public static final int MAGIC_NUMBER =
		0x4C6F7665;
	
	/** Self pointer. */
	public final int selfptr;
	
	/** Magic number used to detect corruption. */
	public final int magic;
	
	/** Class information flags. */
	public final int flags;
	
	/** The pointer to the minimized class file. */
	public final int miniptr;
	
	/** The pointer to the class name. */
	public final int namep;
	
	/** The allocation size of this class. */
	public final int size;
	
	/** The base offset for fields in this class. */
	public final int base;
	
	/** The number of objects in the instance fields, for GC. */
	public final int numobjects;
	
	/** The dimensions this class uses, if it is an array. */
	public final int dimensions;
	
	/** The cell size of components if this is an array. */
	public final int cellsize;
	
	/** The super class data. */
	public final ClassInfo superclass;
	
	/** Interfaces. */
	public final ClassInfo[] interfaceclasses;
	
	/** The component class. */
	public final ClassInfo componentclass;
	
	/** Pointer to the class object. */
	public final Class<?> classobjptr;
	
	/** Virtual invoke VTable. */
	public final int[] vtablevirtual;
	
	/** Virtual invoke VTable pool entries. */
	public final int[] vtablepool;
	
	/** The pointer to the constant pool of this class. */
	public final int pool;
	
	/** The JAR this class is a part of. */
	public final int jardx;
	
	/** The total method count. */
	public final int nummethods;
	
	/** The depth of this class. */
	public final int classdepth;
	
	/** The static field pointer offset for the class. */
	public final int sfoffset;
	
	/** The pointer of the default constructor. */
	public final int defaultnew;
	
	/**
	 * Class information constructor.
	 *
	 * @param __sp Self pointer.
	 * @param __fl Class information flags.
	 * @param __minip Pointer to the hardware class data in ROM.
	 * @param __namep The name pointer.
	 * @param __sz The size of this class.
	 * @param __bz The base offset for fields.
	 * @param __no The number of objects in the field instance.
	 * @param __dim Dimensions.
	 * @param __csz Cell size.
	 * @param __scl The super class data.
	 * @param __icl Interface classes.
	 * @param __ccl Component class.
	 * @param __cop Pointer to the class object.
	 * @param __vtv Virtual invoke VTable address.
	 * @param __vtp Virtual invoke VTable pool addresses.
	 * @param __pool The pointer to the class constant pool.
	 * @param __jardx The JAR Index.
	 * @param __nm The number of methods that are used.
	 * @param __cd The class depth.
	 * @param __sfp The static field offset.
	 * @param __dn The default constructor.
	 * @since 2019/04/26
	 */
	public ClassInfo(int __sp, int __fl, int __minip, int __namep, int __sz,
		int __bz, int __no, int __dim, int __csz, ClassInfo __scl,
		ClassInfo[] __icl, ClassInfo __ccl, Class<?> __cop, int[] __vtv,
		int[] __vtp, int __pool, int __jardx, int __nm, int __cd, int __sfp,
		int __dn)
	{
		// Always implicitly set magic
		this.magic = MAGIC_NUMBER;
		
		// Set
		this.selfptr = __sp;
		this.flags = __fl;
		this.miniptr = __minip;
		this.namep = __namep;
		this.size = __sz;
		this.base = __bz;
		this.numobjects = __no;
		this.dimensions = __dim;
		this.cellsize = __csz;
		this.superclass = __scl;
		this.interfaceclasses = (__icl == null ? new ClassInfo[0] : __icl);
		this.componentclass = __ccl;
		this.classobjptr = __cop;
		this.vtablevirtual = (__vtv == null ? new int[0] : __vtv);
		this.vtablepool = (__vtp == null ? new int[0] : __vtp);
		this.pool = __pool;
		this.jardx = __jardx;
		this.nummethods = __nm;
		this.classdepth = __cd;
		this.sfoffset = __sfp;
		this.defaultnew = __dn;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/ClassLoadingAdjustments.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
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






































































































































































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

/**
 * Adjustments to class loading.
 *
 * @since 2019/12/15
 */
public final class ClassLoadingAdjustments
{
	/**
	 * Is this class deferred loaded?
	 *
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __cl)
		throws NullPointerException
	{
		switch (__cl)
		{
				// Primitive types
			case "boolean":
			case "byte":
			case "short":
			case "char":
			case "int":
			case "float":
			case "long":
			case "double":
			
				// Primitive array types
			case "[Z":
			case "[B":
			case "[S":
			case "[C":
			case "[I":
			case "[F":
			case "[J":
			case "[D":
				
				// Common Java objects
			case "java/io/IOException":
			case "java/io/PrintStream":
			case "java/lang/Appendable":
			case "java/lang/ArithmeticException":
			case "java/lang/ArrayIndexOutOfBoundsException":
			case "java/lang/AssertionError":
			case "java/lang/AutoCloseable":
			case "java/lang/Boolean":
			case "java/lang/Byte":
			case "java/lang/Character":
			case "java/lang/Class":
			case "java/lang/ClassCastException":
			case "java/lang/Cloneable":
			case "java/lang/Closeable":
			case "java/lang/Comparable":
			case "java/lang/Double":
			case "java/lang/Enum":
			case "java/lang/Error":
			case "java/lang/Float":
			case "java/lang/IllegalArgumentException":
			case "java/lang/IllegalMonitorStateException":
			case "java/lang/IllegalStateException":
			case "java/lang/IllegalThreadStateException":
			case "java/lang/IndexOutOfBoundsException":
			case "java/lang/Integer":
			case "java/lang/InterruptedException":
			case "java/lang/Long":
			case "java/lang/Math":
			case "java/lang/NegativeArraySizeException":
			case "java/lang/NoClassDefFoundError":
			case "java/lang/NoSuchElementException":
			case "java/lang/NullPointerException":
			case "java/lang/Number":
			case "java/lang/Object":
			case "java/lang/OutOfMemoryError":
			case "java/lang/Runtime":
			case "java/lang/RuntimeException":
			case "java/lang/Short":
			case "java/lang/String":
			case "java/lang/StringBuffer":
			case "java/lang/StringBuilder":
			case "java/lang/StringIndexOutOfBoundsException":
			case "java/lang/System":
			case "java/lang/Thread":
			case "java/lang/Throwable":
			case "java/lang/VirtualMachineError":
			case "java/lang/ref/Reference":
			case "java/lang/ref/ReferenceQueue":
			case "java/lang/ref/WeakReference":
			case "java/util/Deque":
			case "java/util/Formatter":
			case "java/util/Iterable":
			case "java/util/Iterator":
			case "java/util/List":
			case "java/util/Map":
			case "java/util/Objects":
			case "java/util/Queue":
			case "java/util/Random":
			case "java/util/Set":
			
				// SquirrelJME special classes
			case "cc/squirreljme/jvm/Assembly":
			case "cc/squirreljme/jvm/ClassInfo":
			case "cc/squirreljme/jvm/Constants":
			case "cc/squirreljme/jvm/IPCCallback":
			case "cc/squirreljme/jvm/IPCException":
			case "cc/squirreljme/jvm/IPCManager":
			case "cc/squirreljme/jvm/JVMFunction":
			case "cc/squirreljme/jvm/SoftDouble":
			case "cc/squirreljme/jvm/SoftFloat":
			case "cc/squirreljme/jvm/SoftInteger":
			case "cc/squirreljme/jvm/SoftLong":
			case "cc/squirreljme/jvm/SystemCallError":
			case "cc/squirreljme/jvm/SystemCallIndex":
			
				// Common array classes
			case "[Lcc/squirreljme/jvm/ClassInfo;":
			case "[Ljava/lang/String;":
				return false;
				
			default:
				return true;
		}
	}
	
	/**
	 * Is this class deferred loaded in relation to the current class?
	 *
	 * @param __self The current class.
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __self, String __cl)
		throws NullPointerException
	{
		if (__self == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Same class is never deferred
		if (__self.equals(__cl))
			return false;
		
		// Is within the same package?
		int ls = __self.lastIndexOf('/');
		if (ls >= 0 && __self.regionMatches(0, __cl, 0, ls))
			return false;
		
		// Use default defer logic
		return ClassLoadingAdjustments.isDeferredLoad(__cl);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/ConfigRomType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 an option in the configuration ROM.
 *
 * @since 2019/06/14
 */
public interface ConfigRomType
{
	/** End of configuration. */
	public static final byte END =
		0;
	
	/** Java VM Version. */
	public static final byte JAVA_VM_VERSION =
		1;
	
	/** Java VM Name. */
	public static final byte JAVA_VM_NAME =
		2;
	
	/** Java VM Vendor. */
	public static final byte JAVA_VM_VENDOR =
		3;
	
	/** Java VM E-Mail. */
	public static final byte JAVA_VM_EMAIL =
		4;
	
	/** Java VM URL. */
	public static final byte JAVA_VM_URL =
		5;
	
	/** The guest depth. */
	public static final byte GUEST_DEPTH =
		6;
	
	/** Main class. */
	public static final byte MAIN_CLASS =
		7;
	
	/** Main program arguments. */
	public static final byte MAIN_ARGUMENTS =
		8;
	
	/** Is this a MIDlet? */
	public static final byte IS_MIDLET =
		9;
	
	/** Define system propertly. */
	public static final byte DEFINE_PROPERTY =
		10;
	
	/** Classpath to use. */
	public static final byte CLASS_PATH =
		11;
	
	/** System call static field pointer. */
	public static final byte SYSCALL_STATIC_FIELD_POINTER =
		12;
	
	/** System call method pointer. */
	public static final byte SYSCALL_CODE_POINTER =
		13;
	
	/** System call pool pointer. */
	public static final byte SYSCALL_POOL_POINTER =
		14;
	
	/** Number of available options. */
	public static final byte NUM_OPTIONS =
		15;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/Constants.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































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

/**
 * Virtual machine constants.
 *
 * @since 2019/05/26
 */
public interface Constants
{
	/** The offset for the object's class type. */
	public static final byte OBJECT_CLASS_OFFSET =
		0;
	
	/** The offset for the object's reference count. */
	public static final byte OBJECT_COUNT_OFFSET =
		4;
	
	/** Object monitor owner offset. */
	public static final byte OBJECT_MONITOR_OFFSET =
		8;
	
	/** Object monitor count offset. */
	public static final byte OBJECT_MONITOR_COUNT_OFFSET =
		12;
	
	/** Base size for object types. */
	public static final byte OBJECT_BASE_SIZE =
		16;
	
	/** The offset for array length. */
	public static final byte ARRAY_LENGTH_OFFSET =
		16;
	
	/** The base size for arrays. */
	public static final byte ARRAY_BASE_SIZE =
		20;
	
	/** Constant pool cell size. */
	public static final byte POOL_CELL_SIZE =
		4;
	
	/** Bad magic number. */
	public static final int BAD_MAGIC =
		0xE7E5E7E4;
	
	/** Class info flag: Is array type? */
	public static final short CIF_IS_ARRAY =
		0x0001;
	
	/** Class info flag: Is array of objects? */
	public static final short CIF_IS_ARRAY_OF_OBJECTS =
		0x0002;
	
	/** Is this a primitive type? */
	public static final short CIF_IS_PRIMITIVE =
		0x0004;
	
	/** Offset for the configuration key. */
	public static final byte CONFIG_KEY_OFFSET =
		0;
	
	/** Offset for the configuration size. */
	public static final byte CONFIG_SIZE_OFFSET =
		2;
	
	/** Size of the header for configuration items. */
	public static final byte CONFIG_HEADER_SIZE =
		4;
	
	/** The thread ID for out-of-bound IPC events. */
	public static final int OOB_IPC_THREAD =
		0xFFFFFFFF;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/DefaultIPCRouter.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is a router which just forward IPC requests to the standard manager.
 *
 * @since 2019/12/28
 */
public final class DefaultIPCRouter
	implements IPCCallback
{
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		return IPCManager.ipcCall(__tid, __ipcid, __a, __b, __c, __d, __e,
			__f, __g, __h);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/DeviceFeedbackType.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 the type of feedback to perform for a device.
 *
 * @since 2019/10/05
 */
public interface DeviceFeedbackType
{
	/** Vibrate. */
	public static final byte VIBRATE =
		1;
	
	/** Blink/Pulse LED, be aware of conditions such as epilepsy. */
	public static final byte BLINK_LED =
		2;
	
	/** The number of feedback types. */
	public static final byte NUM_FEEDBACK_TYPES =
		3;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/Framebuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is used to get/set the property of the framebuffer.
 *
 * @since 2019/06/20
 */
public interface Framebuffer
{
	/**
	 * Returns the address of the framebuffer.
	 *
	 * @return The framebuffer address.
	 */
	public static final byte CONTROL_ADDRESS =
		1;
	
	/**
	 * Returns the width of the framebuffer.
	 *
	 * @return The framebuffer width.
	 */
	public static final byte CONTROL_WIDTH =
		2;
	
	/**
	 * Returns the height of the framebuffer.
	 *
	 * @return The framebuffer height.
	 */
	public static final byte CONTROL_HEIGHT =
		3;
	
	/**
	 * Returns the scanline length.
	 *
	 * @return The framebuffer scanline length.
	 */
	public static final byte CONTROL_SCANLEN =
		4;
	
	/**
	 * Flush the display because it has been drawn.
	 */
	public static final byte CONTROL_FLUSH =
		5;
	
	/**
	 * Returns the pixel format of the screen.
	 *
	 * @return The pixel format of the screen.
	 */
	public static final byte CONTROL_FORMAT =
		6;
	
	/**
	 * Returns the scanline length in bytes.
	 *
	 * @return The scanline length in bytes.
	 */
	public static final byte CONTROL_SCANLEN_BYTES =
		7;
	
	/**
	 * Returns the number of bytes per pixel.
	 *
	 * @return The bytes per pixel.
	 */
	public static final byte CONTROL_BYTES_PER_PIXEL =
		8;
	
	/**
	 * Returns the number of available pixels.
	 *
	 * @return The number of pixels.
	 */
	public static final byte CONTROL_NUM_PIXELS =
		9;
	
	/**
	 * Bits per pixel.
	 *
	 * @return The bits per pixel.
	 */
	public static final byte CONTROL_BITS_PER_PIXEL =
		10;
	
	/**
	 * Get backlight level.
	 *
	 * @return The current backlight level.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_GET =
		11;
	
	/**
	 * Set backlight level.
	 *
	 * @param 1 The level to set.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_SET =
		12;
	
	/**
	 * Maximum backlight level.
	 *
	 * @return The maximum backlight level.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_MAX =
		13;
	
	/**
	 * Uploads an integer array of pixel data to the framebuffer.
	 *
	 * @param 1 The address of the array to upload.
	 * @since 2019/12/21
	 */
	public static final byte CONTROL_UPLOAD_ARRAY_INT =
		14;
	
	/**
	 * The array which backs the framebuffer, if there is one.
	 *
	 * @return The backing array object, if there is one.
	 * @since 2019/12/28
	 */
	public static final byte CONTROL_BACKING_ARRAY_OBJECT =
		15;
		
	/**
	 * Returns the capabilities of the display.
	 *
	 * @return The display capabilities.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_GET_CAPABILITIES =
		16;
	
	/**
	 * Query acceleration function.
	 *
	 * @param 1 The graphics function.
	 * @return A non-zero value if this is supported.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_ACCEL_FUNC_QUERY =
		17;
	
	/**
	 * Perform acceleration function.
	 *
	 * @param 1 The graphics function.
	 * @param ... Parameters to the function.
	 * @return A value that is according to the invoked function, if it is
	 * supported or possible.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_ACCEL_FUNC_INVOKE =
		18;
	
	/**
	 * Requests that the framebuffer be repainted.
	 *
	 * @param 1 The X coordinate.
	 * @param 2 The Y coordinate.
	 * @param 3 The width.
	 * @param 4 The height.
	 * @return Returns {@code 0} if the repaint was not queued and it must be
	 * handled by the code running the application, 
	 * @since 2020/01/15
	 */
	public static final byte CONTROL_REPAINT_REQUEST =
		19;
	
	/**
	 * Sets the title of the framebuffer if applicable.
	 *
	 * @param 1 Character array buffer pointer.
	 * @since 2020/01/15
	 */
	public static final byte CONTROL_SET_TITLE =
		20;
	
	/** The number of framebuffer controls. */
	public static final byte NUM_CONTROLS =
		21;
	
	/** Screen is RGB 32-bit. */
	public static final byte FORMAT_INTEGER_RGB888 =
		0;
	
	/** Screen is 8-bit indexed. */
	public static final byte FORMAT_BYTE_INDEXED =
		1;
	
	/** Screen is 16-bit RGB565. */
	public static final byte FORMAT_SHORT_RGB565 =
		2;
	
	/** Screen is packed 1 bit values. */
	public static final byte FORMAT_PACKED_ONE =
		3;
	
	/** Screen is packed 2 bit values. */
	public static final byte FORMAT_PACKED_TWO =
		4;
	
	/** Screen is packed 4 bit values. */
	public static final byte FORMAT_PACKED_FOUR =
		5;
	
	/** Has touch-screen. */
	public static final byte CAPABILITY_TOUCH =
		0x01;
	
	/** Has keyboard. */
	public static final byte CAPABILITY_KEYBOARD =
		0x02;
	
	/** The JVM pushes to the IPC handler when events happen. */
	public static final byte CAPABILITY_IPC_EVENTS =
		0x04;
	
	/** Has screen flipping? */
	public static final byte CAPABILITY_SCREEN_FLIP =
		0x08;
	
	/** Screen has color that is not just a single shade. */
	public static final byte CAPABILITY_COLOR =
		0x10;
	
	/** Set color. */
	public static final byte ACCEL_FUNC_SET_COLOR =
		0;
	
	/** Draw line. */
	public static final byte ACCEL_FUNC_DRAW_LINE =
		1;
	
	/** Get the X clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_X =
		2;
	
	/** Get the Y clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_Y =
		3;
	
	/** Get the width clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_WIDTH =
		4;
	
	/** Get the height clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_HEIGHT =
		5;
	
	/** Set the clip. */
	public static final byte ACCEL_FUNC_SET_CLIP =
		6;
	
	/** Draw rectangle. */
	public static final byte ACCEL_FUNC_DRAW_RECT =
		7;
	
	/** Get the alpha color. */
	public static final byte ACCEL_FUNC_GET_ALPHA_COLOR =
		8;
	
	/** Set the alpha color. */
	public static final byte ACCEL_FUNC_SET_ALPHA_COLOR =
		9;
	
	/** Fill rectangle. */
	public static final byte ACCEL_FUNC_FILL_RECT =
		10;
	
	/** Sets the fonts for the graphics. */
	public static final byte ACCEL_FUNC_SET_FONT =
		11;
	
	/** Gets the font to use for drawing. */
	public static final byte ACCEL_FUNC_GET_FONT =
		12;
	
	/** Draw sub-characters. */
	public static final byte ACCEL_FUNC_DRAW_SUB_CHARS =
		13;
	
	/** Draw text. */
	public static final byte ACCEL_FUNC_DRAW_TEXT =
		14;
	
	/** Get stroke style. */
	public static final byte ACCEL_FUNC_GET_STROKE_STYLE =
		15;
	
	/** Set stroke style. */
	public static final byte ACCEL_FUNC_SET_STROKE_STYLE =
		16;
	
	/** Copy area. */
	public static final byte ACCEL_FUNC_COPY_AREA =
		17;
	
	/** Draw arc. */
	public static final byte ACCEL_FUNC_DRAW_ARC =
		18;
	
	/** Draw ARGB16. */
	public static final byte ACCEL_FUNC_DRAW_ARGB16 =
		19;
	
	/** Draw character. */
	public static final byte ACCEL_FUNC_DRAW_CHAR =
		20;
	
	/** Draw characters. */
	public static final byte ACCEL_FUNC_DRAW_CHARS =
		21;
	
	/** Draw RGB. */
	public static final byte ACCEL_FUNC_DRAW_RGB =
		22;
	
	/** Draw RGB16. */
	public static final byte ACCEL_FUNC_DRAW_RGB16 =
		23;
	
	/** Draw round rectangle. */
	public static final byte ACCEL_FUNC_DRAW_ROUND_RECT =
		24;
	
	/** Fill arc. */
	public static final byte ACCEL_FUNC_FILL_ARC =
		25;
	
	/** Fill round rectangle. */
	public static final byte ACCEL_FUNC_FILL_ROUND_RECT =
		26;
	
	/** Fill triangle. */
	public static final byte ACCEL_FUNC_FILL_TRIANGLE =
		27;
	
	/** Get blending mode. */
	public static final byte ACCEL_FUNC_GET_BLENDING_MODE =
		28;
	
	/** Get display color. */
	public static final byte ACCEL_FUNC_GET_DISPLAY_COLOR =
		29;
	
	/** Set blending mode. */
	public static final byte ACCEL_FUNC_SET_BLENDING_MODE =
		30;
	
	/** Draw region. */
	public static final byte ACCEL_FUNC_DRAW_REGION =
		31;
	
	/** Number of acceleration functions. */
	public static final byte NUM_ACCEL_FUNC =
		32;
	
	/** The IPC ID for the graphics callbacks. */
	public static final int IPC_ID =
		0x47665821;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/IPCCallback.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







































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

/**
 * Anything which would like to listen for IPCs must implement and register
 * this callback.
 *
 * @since 2019/12/28
 */
public interface IPCCallback
{
	/**
	 * Any classes which
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Argument C.
	 * @param __d Argument D.
	 * @param __e Argument E.
	 * @param __f Argument F.
	 * @param __g Argument G.
	 * @param __h Argument H.
	 * @return The result of the IPC call.
	 * @since 2019/12/28
	 */
	public abstract long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/IPCException.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is an exception which was thrown in a cross RPC call.
 *
 * @since 2019/12/28
 */
public class IPCException
	extends RuntimeException
{
	/** The class name note pointer. */
	protected final int classnotepointer;
	
	/**
	 * Initializes the exception with an unknown type.
	 *
	 * @since 2019/12/28
	 */
	public IPCException()
	{
		this.classnotepointer = 0;
	}
	
	/**
	 * Initializes the IPC Exception.
	 *
	 * @param __cnp The class note pointer which was used.
	 * @since 2019/12/28
	 */
	public IPCException(int __cnp)
	{
		this.classnotepointer = __cnp;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/IPCManager.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
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
































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util.HashMap;
import java.util.Map;

/**
 * This class is used to manage the IPC interface and allow any service to
 * register IPC messages and such.
 *
 * @since 2019/12/28
 */
public final class IPCManager
{
	/** Services that are available. */
	private static final Map<Integer, IPCCallback> _IPC_MAP =
		new HashMap<>();
	
	/**
	 * No instances of this class.
	 *
	 * @since 2019/12/28
	 */
	private IPCManager()
	{
	}
	
	/**
	 * This is the handler for IPC messages.
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Argument C.
	 * @param __d Argument D.
	 * @param __e Argument E.
	 * @param __f Argument F.
	 * @param __g Argument G.
	 * @param __h Argument H.
	 * @return The result of the IPC call.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		IPCCallback handler = null;
		
		// Find the IPC Callback handler
		Map<Integer, IPCCallback> ipcmap = _IPC_MAP;
		synchronized (ipcmap)
		{
			handler = ipcmap.get(__ipcid);
		}
		
		// Drop the call if there is no handler
		if (handler == null)
			return 0;
		
		// Perform the call
		return handler.ipcCall(__tid, __ipcid, __a, __b, __c, __d, __e, __f,
			__g, __h);
	}
	
	/**
	 * This is the handler for IPC messages, which performs unfolding
	 * accordingly.
	 *
	 * @param __tid The origin task ID.
	 * @param __v Input values.
	 * @return The result of the IPC call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int n = __v.length;
		return IPCManager.ipcCall(__tid,
			(0 < n ? __v[0] : 0),
			(1 < n ? __v[1] : 0),
			(2 < n ? __v[2] : 0),
			(3 < n ? __v[3] : 0),
			(4 < n ? __v[4] : 0),
			(5 < n ? __v[5] : 0),
			(6 < n ? __v[6] : 0),
			(7 < n ? __v[7] : 0),
			(8 < n ? __v[8] : 0));
	}
	
	/**
	 * This is the handler for IPC messages, which performs unfolding
	 * accordingly.
	 *
	 * @param __tid The origin task ID.
	 * @param __ipcid The ID number of the IPC interface.
	 * @param __v Input values.
	 * @return The result of the IPC call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final long ipcCall(int __tid, int __ipcid, int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int n = __v.length;
		return IPCManager.ipcCall(__tid,
			__ipcid,
			(0 < n ? __v[0] : 0),
			(1 < n ? __v[1] : 0),
			(2 < n ? __v[2] : 0),
			(3 < n ? __v[3] : 0),
			(4 < n ? __v[4] : 0),
			(5 < n ? __v[5] : 0),
			(6 < n ? __v[6] : 0),
			(7 < n ? __v[7] : 0));
	}
	
	/**
	 * Registers the given ID with the specified callback.
	 *
	 * @param __ipcid The IPC ID to listen on.
	 * @param __cb The callback for the IPC.
	 * @throws IllegalArgumentException If IPC ID is zero.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public static final void register(int __ipcid, IPCCallback __cb)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cb == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3u It is not valid to register the zero
		// IPC ID.}
		if (__ipcid == 0)
			throw new IllegalArgumentException("ZZ3u");
		
		// Lock and register
		Map<Integer, IPCCallback> ipcmap = _IPC_MAP;
		synchronized (ipcmap)
		{
			ipcmap.put(__ipcid, __cb);
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/JVMFunction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301













































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 class contains the functions of the virtual machine.
 *
 * @since 2019/05/25
 */
public final class JVMFunction
{
	/**
	 * 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
	 * be returned, otherwise {@code 0} will.
	 * @since 2019/04/27
	 */
	public static final int jvmCanArrayStore(int __p, int __v)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the component type of the array
	 *
	 * @param __clid The class ID
	 * @return The component type of the array or {@code 0} if it is not an
	 * array.
	 * @since 2019/04/27
	 */
	public static final int jvmComponentType(int __clid)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Performs aggressive garbage collection of the JVM heap to free as much
	 * memory as possible.
	 *
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollect()
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Garbage collects a single object.
	 *
	 * @param __p The object to garbage collect.
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the given class.
	 *
	 * @param __ns The noted string.
	 * @return The loaded class info.
	 * @since 2019/12/15
	 */
	public static final ClassInfo jvmInitClass(int __ns)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Searches the interface vtables for the class of object {@code __p}
	 * and searches for an interface implementation of class {@code __icl} and
	 * if one is found then the pointer for index {@code __mdx} is returned.
	 *
	 * @param __p The object to do a interface lookup on.
	 * @param __icl The interface class to find.
	 * @param __mdx The method index to relate to, of the interface class.
	 * @return The pointer to the code to be invoked in the low-word and the
	 * pool of the target class in the high-word.
	 * @since 2019/04/30
	 */
	public static final long jvmInterfacePointer(int __p, int __icl, int __mdx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
		// Assembly.longPack(hi, lo)
	}
	
	/**
	 * Checks whether the given pointer is an array.
	 *
	 * @param __p The pointer to check.
	 * @return Either {@code 1} if it is an array or {@code 0} if it is not.
	 * @since 2019/04/27
	 */
	public static final int jvmIsArray(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an instance of the given class.
	 *
	 * @param __p The pointer to check.
	 * @param __cldx The class index.
	 * @return Either {@code 1} if the class is an instance or {@code 0} if
	 * it is not.
	 * @since 2019/04/22
	 */
	public static final int jvmIsInstance(int __p, int __cldx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the {@link Class} instance for the given class info pointer,
	 * if none has been created yet then it will be created as needed.
	 *
	 * @param <T> The class type.
	 * @param __cldx The class index pointer.
	 * @return The resulting class.
	 * @since 2019/05/26
	 */
	public static final <T> Class<T> jvmLoadClass(int __cldx)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Loads a string from memory and returns an `intern()` string value.
	 *
	 * @param __p The pointer to load the string bytes from.
	 * @return The resulting string.
	 * @since 2019/05/26
	 */
	public static final String jvmLoadString(int __p)
	{
		// Zero will be the null pointer
		if (__p == 0)
			return null;
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Reads a long value from the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @return The read value.
	 * @since 2019/05/29
	 */
	public static final long jvmMemReadLong(int __addr, int __off)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __hv The high value.
	 * @param __lv The low value.
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, int __hv,
		int __lv)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __v The value
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, long __v)
	{
		JVMFunction.jvmMemWriteLong(__addr, __off,
			(int)(__v >>> 32), (int)__v);
	}
	
	/**
	 * Enters the monitor for the given object.
	 *
	 * @param __p The object to enter.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorEnter(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Exits the monitor for the given object.
	 *
	 * @param __p The object to exit.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorExit(int __p)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new object.
	 *
	 * @param __cl The class type.
	 * @return The resulting class pointer.
	 * @throws OutOfMemoryError If there is not enough memory to allocate the
	 * class.
	 * @since 2019/05/24
	 */
	public static final int jvmNew(int __cl)
		throws OutOfMemoryError
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Allocates a new array.
	 *
	 * @param __at The array type.
	 * @param __len The length of the array.
	 * @return The resulting array pointer.
	 * @throws NegativeArraySizeException If the array length is negative.
	 * @throws OutOfMemoryError If there is not enough memory to allocate the
	 * array.
	 * @since 2019/04/24
	 */
	public static final int jvmNewArray(int __at, int __len)
		throws NegativeArraySizeException, OutOfMemoryError
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * This handles an unpure system call which may modify the behavior of
	 * any system call which needs to be done. Some system calls might not be
	 * supported by the host machine or they might not make sense (such as
	 * garbage collection), so as such this allows their behavior to modified.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static final long jvmSystemCall(short __si, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		// Call pure form
		return Assembly.sysCallPVL(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SoftDouble.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211



















































































































































































































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

/**
 * Software math operations on 64-bit double.
 *
 * @since 2019/05/24
 */
public class SoftDouble
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftDouble()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double add(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double div(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double neg(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * ORs value, used for constants.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static double or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.doublePack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double rem(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double sub(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SoftFloat.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
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
191































































































































































































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

/**
 * Software math operations on 32-bit floats.
 *
 * @since 2019/05/24
 */
public class SoftFloat
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftFloat()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float add(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float div(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float mul(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float neg(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Ors a value, used for constant loading.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float or(int __a, int __b)
	{
		return Assembly.intBitsToFloat(__a | __b);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float rem(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float sub(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SoftInteger.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
66
67
68
69
70
71
72
73









































































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

/**
 * Software integer operations.
 *
 * @since 2019/05/27
 */
public class SoftInteger
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/27
	 */
	private SoftInteger()
	{
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		// If the integer has the sign bit, then it will be sign extended
		// meaning all the upper bits get set
		if ((__a & 0x80000000) != 0)
			return Assembly.longPack(0xFFFFFFFF, __a);
		
		// Otherwise the top is just zero
		else
			return Assembly.longPack(0, __a);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SoftLong.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407























































































































































































































































































































































































































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

/**
 * Software math operations on 64-bit integer types.
 *
 * @since 2019/05/24
 */
public final class SoftLong
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftLong()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long add(int __ah, int __al, int __bh, int __bl)
	{
		// Add the higher/lower parts
		int ch = __ah + __bh,
			cl = __al + __bl;
		
		// If the low addition carried a bit over, then set that bit in the
		// high part
		if ((cl + 0x80000000) < (__al + 0x80000000))
			ch++;
		
		// Return result
		return Assembly.longPack(ch, cl);
	}
	
	/**
	 * Ands two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long and(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah & __bh, __al & __bl);
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmp(int __ah, int __al, int __bh, int __bl)
	{
		// Compare high values firsts
		if (__ah < __bh)
			return -1;
		else if (__ah > __bh)
			return 1;
		
		// Compare low values with unsigned comparison
		__al += Integer.MIN_VALUE;
		__bl += Integer.MIN_VALUE;
		if (__al < __bl)
			return -1;
		else if (__al > __bl)
			return 1;
		return 0;
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long div(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(false, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long neg(int __ah, int __al)
	{
		// Negate and check for overflow
		int nh = (~__ah),
			nl = (~__al + 1);
		if (nl == 0)
			nh++;
		
		// Return result
		return Assembly.longPack(nh, nl);
	}
	
	/**
	 * Ors a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long rem(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(true, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Shifts value left by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shl(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the low bits to the high bits
		else if (__s >= 32)
			return Assembly.longPack(__al << (__s - 32), 0);
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah << __s) | (__al >>> (32 - __s)),
				(__al << __s));
	}
	
	/**
	 * Shifts value right by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack((__ah & 0x80000000) >> 31,
				__ah >> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long sub(int __ah, int __al, int __bh, int __bl)
	{
		// The same as add, but the second operand is negated
		long nb = SoftLong.neg(__bh, __bl);
		return SoftLong.add(__ah, __al,
			Assembly.longUnpackHigh(nb), Assembly.longUnpackLow(nb));
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		// Just return the low order bits
		return __al;
	}
	
	/**
	 * Shifts value bits right unsigned.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long ushr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack(0, __ah >>> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >>> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Xors two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long xor(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah ^ __bh, __al ^ __bl);
	}
	
	/**
	 * Divides and remainders two values.
	 *
	 * @param __dorem Return the remainder?
	 * @param __num The numerator.
	 * @param __den The denominator.
	 * @return The result.
	 * @since 2019/05/24
	 */
	private static long __div(boolean __dorem, long __num, long __den)
	{
		// Wikipedia (http://en.wikipedia.org/wiki/Division_%28digital%29)
		// if D == 0 then throw DivisionByZeroException end
		// Q := 0 # initialize quotient and remainder to zero
		// R := 0
		// for i = n-1...0 do  # " where n is no of bits "
		//   R := R << 1       # left-shift R by 1 bit
		//   R(0) := N(i)      # set the least-significant bit
		//              # of R equal to bit i of the numerator
		//   if R >= D then
		//     R = R - D
		//     Q(i) := 1
		//   end
		// end
		long inquot = 0, inrem = 0;
		boolean isneg;
		
		// Disallow division by zero
		if (__den == 0)
			return 0;
		
		// Negative?
		isneg = ((__num < 0 && __den >= 0) || (__num >= 0 && __den < 0));
		
		// Force Positive
		__num = (__num < 0 ? -__num : __num);
		__den = (__den < 0 ? -__den : __den);
		
		// Perform Math
		for (int i = 63; i >= 0; i--)
		{
			inrem <<= 1;
			inrem &= 0xFFFFFFFFFFFFFFFEL;
			inrem |= ((__num >>> i) & 1L);
			
			// Unsigned comparison
			if ((inrem + Long.MIN_VALUE) >= (__den + Long.MIN_VALUE))
			{
				inrem -= __den;
				inquot |= (1L << i);
			}
		}
		
		// Make Negative
		if (isneg)
			inquot = -inquot;
		
		// Return
		return (__dorem ? inrem : inquot);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SupervisorPropertyIndex.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 indicates an index for a supervisor register which is controlled and
 * only settable by the supervisor. It is used in system call handling and
 * otherwise.
 *
 * @since 2019/10/04
 */
public interface SupervisorPropertyIndex
{
	/** The static field register of the task syscall handler. */
	public static final byte TASK_SYSCALL_STATIC_FIELD_POINTER =
		1;
	
	/** The method pointer of the task syscall method. */
	public static final byte TASK_SYSCALL_METHOD_HANDLER =
		2;
	
	/** The pool pointer of the task syscall method. */
	public static final byte TASK_SYSCALL_METHOD_POOL_POINTER =
		3;
	
	/** The number of available properties. */
	public static final byte NUM_PROPERTIES =
		4;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallError.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
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
































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 interface contains the various error codes for all of the system calls.
 *
 * @since 2019/05/23
 */
public final class SystemCallError
{
	/** No error, or success. */
	public static final byte NO_ERROR =
		0;
	
	/** The system call is not supported. */
	public static final byte UNSUPPORTED_SYSTEM_CALL =
		-1;
	
	/** The pipe descriptor is not valid. */
	public static final byte PIPE_DESCRIPTOR_INVALID =
		-2;
	
	/** Write error when writing to the pipe. */
	public static final byte PIPE_DESCRIPTOR_BAD_WRITE =
		-3;
	
	/** Value out of range. */
	public static final byte VALUE_OUT_OF_RANGE =
		-4;
	
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;
	
	/** Interrupted. */
	public static final byte INTERRUPTED =
		-7;
	
	/** Unknown error. */
	public static final byte UNKNOWN =
		-8;
	
	/** End of file reached. */
	public static final byte END_OF_FILE =
		-9;
	
	/** Error with IPC Call. */
	public static final byte IPC_ERROR =
		-10;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}
	
	/**
	 * Checks if an error was set, if it was an exception is thrown.
	 *
	 * @param __si The system call to check.
	 * @throws SystemCallException If there was an error.
	 * @since 2020/01/12
	 */
	public static final void checkError(short __si)
		throws SystemCallException
	{
		int code = SystemCallError.getError(__si);
		if (code != NO_ERROR)
			throw new SystemCallException(__si, code);
	}
	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
	
	/**
	 * Converts the error to a string.
	 *
	 * @param __err The input error.
	 * @return The resulting string.
	 * @since 2020/01/12
	 */
	public static final String toString(int __err)
	{
		switch (__err)
		{
			case NO_ERROR:					return "NoError";
			case UNSUPPORTED_SYSTEM_CALL:	return "UnsupportedSystemCall";
			case PIPE_DESCRIPTOR_INVALID:	return "PDInvalid";
			case PIPE_DESCRIPTOR_BAD_WRITE:	return "PDBadWrite";
			case VALUE_OUT_OF_RANGE:		return "ValueOutOfRange";
			case NO_FRAMEBUFFER:			return "NoFramebuffer";
			case PERMISSION_DENIED:			return "PermissionDenied";
			case INTERRUPTED:				return "Interrupted";
			case UNKNOWN:					return "Unknown";
			case END_OF_FILE:				return "EndOfFile";
			case IPC_ERROR:					return "IPCError";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallException.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
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



























































































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

/**
 * Exception that may be thrown by {@link SystemCallError.checkError(int)}.
 *
 * @since 2020/01/12
 */
public class SystemCallException
	extends RuntimeException
{
	/** The system call ID. */
	public final int callid;
	
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec)
	{
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m)
	{
		super(__m);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m, Throwable __t)
	{
		super(__m, __t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, Throwable __t)
	{
		super(__t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/12
	 */
	@Override
	public String getMessage()
	{
		return "[SID=" + this.callid + ", ERR=" +
			SystemCallError.toString(this.code) + "]: " + super.getMessage();
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallIndex.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 contains the index of system calls.
 *
 * @since 2019/05/23
 */
public interface SystemCallIndex
{
	/**
	 * Checks if the system call is supported.
	 *
	 * @param 1 The system call index to query.
	 * @return Zero if not supported, otherwise a non-zero value.
	 */
	public static final byte QUERY_INDEX =
		0;
	
	/**
	 * Gets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @param 1 The system call index to query.
	 * @return The last error code, will be zero if the last command succeeded.
	 */
	public static final byte ERROR_GET =
		1;
	
	/**
	 * Sets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @param 1 The system call index to query.
	 * @param 2 The value to set error register to.
	 * @return Zero on success
	 */
	public static final byte ERROR_SET =
		2;
	
	/**
	 * Current wall clock milliseconds.
	 *
	 * @return The current milliseconds time.
	 */
	public static final byte TIME_MILLI_WALL =
		3;
	
	/**
	 * Returns the cross-IPC exception class which has been stored.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @return The exception which has been stored.
	 */
	public static final byte EXCEPTION_LOAD =
		4;
	
	/**
	 * Current monotonic clock nanoseconds (low).
	 *
	 * @return The monotonic nanoseconds time.
	 */
	public static final byte TIME_NANO_MONO =
		5;
	
	/**
	 * Stores the cross-IPC exception class for system call errors.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @param 1 The exception to store.
	 * @return The old value that was stored in the register.
	 */
	public static final byte EXCEPTION_STORE =
		6;
	
	/**
	 * VM Information: Free memory in bytes.
	 *
	 * @return The free memory amount in bytes.
	 */
	public static final byte VMI_MEM_FREE =
		7;
	
	/**
	 * VM Information: Used memory in bytes.
	 *
	 * @return The used memory amount in bytes.
	 */
	public static final byte VMI_MEM_USED =
		8;
	
	/**
	 * VM Information: Max memory in bytes.
	 *
	 * @return The max memory amount in bytes.
	 */
	public static final byte VMI_MEM_MAX =
		9;
	
	/**
	 * Suggests that the garbage collector should run, note that this may be
	 * a deferred operation and might not be immediate.
	 *
	 * @return Generally zero although any other value could be returned.
	 */
	public static final byte GARBAGE_COLLECT =
		10;
	
	/**
	 * Exits the VM with the given exit code.
	 *
	 * @param 1 The exit code to exit the process with.
	 * @return This generally does not return, if it does then the error code
	 * will likely specify why this failed.
	 */
	public static final byte EXIT =
		11;
	
	/**
	 * The API Level of the VM, this has been deprecated since the current
	 * SquirrelJME API specified in these system calls better handles various
	 * features.
	 *
	 * @return The API level of the virtual machine.
	 */
	@Deprecated
	public static final byte API_LEVEL =
		12;
	
	/**
	 * The pipe descriptor for stdin.
	 *
	 * @return The pipe descriptor for standard input.
	 */
	public static final byte PD_OF_STDIN =
		13;
	
	/**
	 * The pipe descriptor for stdout.
	 *
	 * @return The pipe descriptor for standard output.
	 */
	public static final byte PD_OF_STDOUT =
		14;
	
	/**
	 * The pipe descriptor for stderr.
	 *
	 * @return The pipe descriptor for standard error.
	 */
	public static final byte PD_OF_STDERR =
		15;
	
	/**
	 * Pipe descriptor: Write single byte.
	 *
	 * @param 1 The pipe descriptor.
	 * @param 2 The value of the byte to write, only the lowest 8-bits is used.
	 * @return The number of bytes written to the output, if this returns
	 * a value lower than zero then it indicates an error.
	 */
	public static final byte PD_WRITE_BYTE =
		16;
	
	/**
	 * Bulk sets the memory inside of a region, this follows the same pattern
	 * as C's {@code memset()} operation.
	 *
	 * @param 1 The address to set.
	 * @param 2 The value to set the region with.
	 * @param 3 The number of bytes to set.
	 * @return The number of bytes actually written, if this is zero then
	 * it is likely the system call is not supported.
	 */
	public static final byte MEM_SET =
		17;
	
	/**
	 * Bulk sets the memory inside of a region writing full integer values at
	 * a time which is generally faster, this follows the same pattern as C's
	 * {@code memset()} operation.
	 *
	 * @param 1 The address to set.
	 * @param 2 The value to set the region with.
	 * @param 3 The number of bytes to set, the lower 2-bits ({@code 0x3}) will
	 * be masked off so the length is always a multiple of four.
	 * @return The number of bytes actually written, if this is zero then
	 * it is likely the system call is not supported.
	 */
	public static final byte MEM_SET_INT =
		18;
	
	/**
	 * Get the height of the call stack.
	 *
	 * @return The height of the call stack.
	 */
	public static final byte CALL_STACK_HEIGHT =
		19;
	
	/**
	 * Gets the specified call stack item.
	 *
	 * @param 1 The number of frames from the top of the call stack to get the
	 * items for, zero will be the top-most item.
	 * @param 2 The item to obtain as specified in {@link CallStackItem}.
	 * @return The value of the item, if it is undefined or not supported
	 * then zero will be returned.
	 */
	public static final byte CALL_STACK_ITEM =
		20;
	
	/**
	 * Returns the string of the given pointer.
	 *
	 * @param 1 The pointer to the modified UTF encoded string.
	 * @return An instance of {@link String}.
	 */
	public static final byte LOAD_STRING =
		21;
	
	/**
	 * Fatal ToDo hit.
	 *
	 * @param 1 The code to use for the To Do.
	 * @return This should not return unless it is not supported.
	 */
	public static final byte FATAL_TODO =
		22;
	
	/**
	 * This is used to indicate that the supervisor booted correctly and that
	 * execution control is normal.
	 *
	 * @return Generally zero as no value is intended to be returned.
	 */
	public static final byte SUPERVISOR_BOOT_OKAY =
		23;
	
	/**
	 * Get, set, or change a property of the framebuffer, the properties which
	 * are defined are specified in {@link Framebuffer}.
	 *
	 * @param 1 The frame buffer property to select.
	 * @param ... Undefined, this depends on the property selected.
	 * @return Whatever value the frame buffer property will return.
	 */
	public static final byte FRAMEBUFFER =
		24;
	
	/**
	 * Returns the native byte order of the system the virtual machine is
	 * running on.
	 *
	 * @return Non-zero if little endian, otherwise zero will be big endian.
	 */
	public static final byte BYTE_ORDER_LITTLE =
		25;
	
	/**
	 * Returns the pointer to the option JAR data.
	 *
	 * @param 1 The option JAR slot to request.
	 * @return A pointer to the data or zero if there is no option JAR defined
	 * in the requested slot.
	 */
	public static final byte OPTION_JAR_DATA =
		26;
	
	/**
	 * Returns the size of the option JAR data.
	 *
	 * @param 1 The option JAR slot to request.
	 * @return The size of the specified option JAR or zero if there is no
	 * option JAR defined in the requested slot.
	 */
	public static final byte OPTION_JAR_SIZE =
		27;
	
	/**
	 * Loads the specified class.
	 *
	 * @param 1 The Modified UTF specifying the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_UTF =
		28;
	
	/**
	 * Loads the specified class.
	 *
	 * @param 1 A byte array encoded in UTF-8 which contains the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @param 1 The supervisor property to set.
	 * @param 2 The new value of the property.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @param 1 The supervisor property to get.
	 * @return The value of that property, error should be checked to ensure
	 * that it did not fail.
	 */
	public static final byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
	 *
	 * Only the supervisor is allowed to set tihus.
	 *
	 * @param 1 The task ID to set.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte FRAME_TASK_ID_SET =
		32;
	
	/**
	 * Gets the value of a thread register.
	 *
	 * @return The value of the task ID.
	 */
	public static final byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @param 1 The type of feedback to perform.
	 * @param 2 The duration of the feedback.
	 * @return Non-zero on success.
	 */
	public static final byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * @param 1 The number of milliseconds to sleep for.
	 * @param 2 The number of nanoseconds to sleep for.
	 * @return Returns zero unless sleep was interrupted.
	 */
	public static final byte SLEEP =
		35;
	
	/**
	 * If the framebuffer is shared with the console, this tells the console
	 * printer to not send messages to the screen as it will corrupt the
	 * display on the screen.
	 */
	public static final byte SQUELCH_FB_CONSOLE =
		36;
	
	/**
	 * Perform IPC call.
	 *
	 * @param 1 The task to call, {@code 0} is the supervisor.
	 * @param 2 The IPC identifier which specifies which service this was
	 * associated with.
	 * @param ... Any arguments to the call.
	 * @return The value returned from the remote call.
	 */
	public static final byte IPC_CALL =
		37;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		38;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/jvm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains SquirrelJME specific special functions which either
 * act on or modify how code is compiled for the JVM.
 *
 * @since 2019/05/25
 */

package cc.squirreljme.jvm;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/SquirrelJME.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
























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

package cc.squirreljme.runtime.cldc;

/**
 * Contains information on SquirrelJME.
 *
 * @since 2018/12/05
 */
public interface SquirrelJME
{
	/** The version of this SquirrelJME runtime. */
	public static final String RUNTIME_VERSION =
		"0.3.0";
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/annotation/Api.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



































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

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Indicates the API level of the native call.
 *
 * @since 2018/12/05
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface Api
{
	/** The API level. */
	int value();
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/annotation/ImplementationNote.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



































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

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is an implementation note annotation.
 *
 * @since 2018/09/09
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface ImplementationNote
{
	/** The note to be stored. */
	String value() default "";
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/annotation/ProgrammerTip.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




































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

package cc.squirreljme.runtime.cldc.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a tip to the programmer (along with the developers of SquirrelJME)
 * so things can be remembered easier.
 *
 * @since 2018/10/29
 */
@Documented
@Retention(value=RetentionPolicy.SOURCE)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface ProgrammerTip
{
	/** The note to be stored. */
	String value() default "";
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/annotation/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















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

/**
 * SquirrelJME specific annotations.
 *
 * @since 2018/03/05
 */

package cc.squirreljme.runtime.cldc.annotation;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/ConsoleCallback.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
















































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

package cc.squirreljme.runtime.cldc.asm;

import java.io.IOException;

/**
 * This is the callback used for the console.
 *
 * @since 2019/02/02
 */
public interface ConsoleCallback
{
	/**
	 * This is called when the stream has been closed.
	 *
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	public abstract boolean close();
	
	/**
	 * This is called when the callback is flushed.
	 *
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	public abstract boolean flush();
	
	/**
	 * Writes the specified bytes to the output.
	 *
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return {@code false} if an {@link IOException} occurred.
	 * @since 2019/02/02
	 */
	public abstract boolean write(byte[] __b, int __o, int __l);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/ConsoleOutput.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
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





































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Used for printing to the console.
 *
 * @since 2018/09/21
 */
public final class ConsoleOutput
{
	/** Standard output. */
	public static final int OUTPUT =
		1;
	
	/** Standard error. */
	public static final int ERROR =
		2;
	
	/** End of file. */
	public static final int ERROR_EOF =
		-1;
	
	/** Invalid file descriptor. */
	public static final int ERROR_INVALIDFD =
		-2;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/21
	 */
	private ConsoleOutput()
	{
	}
	
	/**
	 * Reads the display console, that is anything which was output to the
	 * console itself.
	 *
	 * @param __dim The output dimensions of the console, columns and rows.
	 * This array must always have a length of at least two.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes which were read, this will be the minimum
	 * of either {@code __dim[0] * __dim[1]} or {@code __l}. Zero may be
	 * returned if this is not supported.
	 * @since 2018/12/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int displayRead(int[] __dim,
		byte[] __b, int __o, int __l);
	
	/**
	 * Flushes the stream.
	 *
	 * @param __fd The file descriptor to flush.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int flush(int __fd);
	
	/**
	 * Writes the character to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __c The byte to write, only the lowest 8-bits are used.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/09/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int write(int __fd, int __c);
	
	/**
	 * Writes the given bytes to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int write(int __fd,
		byte[] __b, int __o, int __l);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
































































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to the native display system that is used by the
 * LCDUI code to display widgets and such to the screen. Any application may
 * access the screen directly and must manage exclusivity by itself if such a
 * thing is applicable for a single shared screen resource.
 *
 * @since 2018/11/09
 */
@Deprecated
public final class NativeDisplayAccess
{
	/** The number of parameters available. */
	@Deprecated
	public static final int NUM_PARAMETERS =
		8;
	
	/** The pixel format. */
	@Deprecated
	public static final int PARAMETER_PIXELFORMAT =
		0;
	
	/** The buffer width. */
	@Deprecated
	public static final int PARAMETER_BUFFERWIDTH =
		1;
	
	/** The buffer height. */
	@Deprecated
	public static final int PARAMETER_BUFFERHEIGHT =
		2;
	
	/** Alpha channel is used? */
	@Deprecated
	public static final int PARAMETER_ALPHA =
		3;
	
	/** Buffer pitch. */
	@Deprecated
	public static final int PARAMETER_PITCH =
		4;
	
	/** Buffer offset. */
	@Deprecated
	public static final int PARAMETER_OFFSET =
		5;
	
	/** Virtual X offset. */
	@Deprecated
	public static final int PARAMETER_VIRTXOFF =
		6;
	
	/** Virtual Y offset. */
	@Deprecated
	public static final int PARAMETER_VIRTYOFF =
		7;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/09
	 */
	@Deprecated
	private NativeDisplayAccess()
	{
	}
	
	/**
	 * Initialize and/or reset accelerated graphics operations.
	 *
	 * @param __id The display to initialize for.
	 * @return {@code true} if acceleration is supported.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native boolean accelGfx(int __id);
	
	/**
	 * Performs accelerated graphics operation.
	 *
	 * @param __id The display ID.
	 * @param __func The function to call.
	 * @param __args Arguments to the operation.
	 * @return The result of the operation.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native Object accelGfxFunc(int __id, int __func,
		Object... __args);
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @param __id The display ID.
	 * @return The capabilities of the display.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int capabilities(int __id);
	
	/**
	 * Requests that the display should be repainted.
	 *
	 * @param __id The display ID.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void displayRepaint(int __id,
		int __x, int __y, int __w, int __h);
	
	/**
	 * Returns the object representing the framebuffer data.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer array.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native Object framebufferObject(int __id);
	
	/**
	 * Returns the palette of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The palette of the framebuffer.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int[] framebufferPalette(int __id);
	
	/**
	 * Returns the parameters of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer parameters.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int[] framebufferParameters(int __id);
	
	/**
	 * Returns the state count of this framebuffer which is used to detect
	 * when the parameters have changed, where they must all be recalculated
	 * (that is the framebuffer wrapper must be recreated).
	 *
	 * @param __id The display ID.
	 * @return The state count for the framebuffer.
	 * @since 2018/12/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int framebufferStateCount(int __id);
	
	/**
	 * Is the specified display upsidedown?
	 *
	 * @param __id The ID of the display.
	 * @return If the display is upsidedown.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native boolean isUpsideDown(int __id);
	
	/**
	 * Returns the number of permanent displays which are currently attached to
	 * the system.
	 *
	 * @return The number of displays attached to the system.
	 * @since 2018/11/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int numDisplays();
	
	/**
	 * Registers the class to be called for when display events are to be
	 * called.
	 *
	 * @param __cb The callback.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void registerEventCallback(
		NativeDisplayEventCallback __cb);
	
	/**
	 * Sets the title of the display.
	 *
	 * @param __id The display ID.
	 * @param __t The title to use.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void setDisplayTitle(int __id, String __t);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/NativeDisplayEventCallback.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
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






















































































































































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

package cc.squirreljme.runtime.cldc.asm;

/**
 * For any native display event that occurs, this method is called back and
 * executed accordingly so that any events may be processed accordingly. This
 * is needed by some operating systems and devices where any access to the
 * native display must be done through this event loop. Most operating systems
 * have a UI event loop
 *
 * @since 2018/12/03
 */
@Deprecated
public interface NativeDisplayEventCallback
{
	/** Key pressed. */
	@Deprecated
	public static final int KEY_PRESSED =
		1;
	
	/** Key repeated. */
	@Deprecated
	public static final int KEY_REPEATED =
		2;
	
	/** Key released. */
	@Deprecated
	public static final int KEY_RELEASED =
		3;
	
	/** Pointer pressed. */
	@Deprecated
	public static final int POINTER_PRESSED =
		4;
	
	/** Pointer dragged. */
	@Deprecated
	public static final int POINTER_DRAGGED =
		5;
	
	/** Pointer released. */
	@Deprecated
	public static final int POINTER_RELEASED =
		6;
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __d The display to run the command on.
	 * @param __c The command to execute.
	 * @since 2018/12/03
	 */
	public abstract void command(int __d, int __c);
	
	/**
	 * Exit request generated for a display, this likely means the close
	 * button was pressed.
	 *
	 * Note that an exit might not happen if it is caught (like an exit
	 * dialog question or similar).
	 *
	 * @param __d The display which the close was performed on.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void exitRequest(int __d);
	
	/**
	 * Key action has been performed.
	 *
	 * @param __d The display ID.
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time);
	
	/**
	 * This is called when the callback has been lost, another task has claimed
	 * access to the display event handler. This should be called before
	 * a registration occurs.
	 *
	 * @since 2018/12/10
	 */
	@Deprecated
	public abstract void lostCallback();
	
	/**
	 * Paints the display.
	 *
	 * @param __d The display.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void paintDisplay(int __d, int __x, int __y,
		int __w, int __h);
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __d The display to have the end.
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time);
	
	/**
	 * Display has been shown or hidden.
	 *
	 * @param __d The display.
	 * @param __shown If this is non-zero the display is shown.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void shown(int __d, int __shown);
	
	/**
	 * Display size has changed.
	 *
	 * @param __d The display which has changed.
	 * @param __w The width of the display.
	 * @param __h The height of the display.
	 * @since 2018/12/03
	 */
	@Deprecated
	public abstract void sizeChanged(int __d, int __w, int __h);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/ObjectAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;
import cc.squirreljme.runtime.cldc.ref.PrimitiveWeakReference;

/**
 * This contains accessors for object information.
 *
 * @since 2018/09/22
 */
public final class ObjectAccess
{
	/** Monitor is not owned by this thread. */
	public static final int MONITOR_NOT_OWNED =
		-1;
	
	/** Monitor did not interrupt. */
	public static final int MONITOR_NOT_INTERRUPTED =
		0;
	
	/** Monitor did interrupt. */
	public static final int MONITOR_INTERRUPTED =
		1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/22
	 */
	private ObjectAccess()
	{
	}
	
	/**
	 * Allocates an object but does not construct it
	 *
	 * @param __cl The class to allocate.
	 * @return An object for the class, it is not initialized with a
	 * constructor. Returns {@code null} if no more memory is available.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object allocateObject(String __cl);
	
	/**
	 * Creates a new array of the given type, this is the actual array and
	 * not the component.
	 *
	 * @param __t The array type, not the component type.
	 * @param __l The array length.
	 * @return An array allocated to the given length.
	 * @since 2018/09/25
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object arrayNew(Class<?> __t, int __l);
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Class<?> classByName(String __s);
	
	/**
	 * Returns the class data which is attached to the given class object.
	 *
	 * @param __cl The class to get the data from.
	 * @return The resulting class data.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native ClassData classData(Class<?> __cl);
	
	/**
	 * Returns the class object for the given object.
	 *
	 * @param __v The object to get the class of.
	 * @return The class of the given object, or {@code null} if it has no
	 * class.
	 * @since 2018/09/22
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Class<?> classOf(Object __v);
	
	/**
	 * Checks if the given thread holds the given object in a lock.
	 *
	 * @param __ntid The native thread ID.
	 * @param __o The object to check.
	 * @return If the lock is held.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native boolean holdsLock(int __ntid, Object __o);
	
	/**
	 * Returns the identity hashcode of the object.
	 *
	 * @return The identity hashcode.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int identityHashCode(Object __o);
	
	/**
	 * Invokes the specified static method.
	 *
	 * @param __m The method to invoke.
	 * @param __args Arguments to the method, the parameters will be passed
	 * as-is and will not be unboxed, so the method must accept boxed values.
	 * @return The value to return from the method, {@code void} will return
	 * {@code null}.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object invokeStatic(StaticMethod __m,
		Object... __args);
	
	/**
	 * Notifies threads waiting on the monitor.
	 *
	 * @param __o The object to notify.
	 * @param __all Notify all threads?
	 * @return If the monitor was a success or not.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int monitorNotify(Object __o, boolean __all);
	
	/**
	 * Waits for a notification on a monitor.
	 *
	 * @param __o The object to wait on.
	 * @param __ms The milliseconds.
	 * @param __ns The nanoseconds.
	 * @return The wait status.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int monitorWait(Object __o, long __ms,
		int __ns);
	
	/**
	 * Creates a new primitive weak reference. Note that it is not valid to
	 * operate on this object as a normal object, it is a special
	 * representation.
	 *
	 * @return The primitive weak reference.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native PrimitiveReference newWeakReference();
	
	/**
	 * Gets the given reference.
	 *
	 * @param __r The reference to read from.
	 * @return The reference value, may be {@code null} if the input reference
	 * is not valid, it was garbage collected, or it was never set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native Object referenceGet(PrimitiveReference __r);
	
	/**
	 * Sets the given reference to the given value.
	 *
	 * @param __r The reference to set.
	 * @param __v The value to set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void referenceSet(PrimitiveReference __r,
		Object __v);
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param <C> The class to type this as.
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@SuppressWarnings({"unchecked"})
	public static final <C> Class<C> classByNameType(String __s)
	{
		return (Class<C>)((Object)ObjectAccess.classByName(__s));
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/ResourceAccess.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
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
















































































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to resources and their raw data streams.
 *
 * Access to resources relies on the suites, so the correct suite must be
 * specified. {@link Class#getResourceAsStream(String)} should handle this.
 *
 * @since 2018/10/07
 */
public final class ResourceAccess
{
	/** Resource does not exist. */
	public static final int OPEN_STATUS_NO_RESOURCE =
		-1;
	
	/** JAR does not exist. */
	public static final int OPEN_STATUS_NO_JAR =
		-2;
	
	/** IOException. */
	public static final int OPEN_STATUS_IOEXCEPTION =
		-3;
	
	/** Read returned EOF. */
	public static final int READ_STATUS_EOF =
		-1;
	
	/** Read returned unknown file descriptor. */
	public static final int READ_STATUS_UNKNOWN_FD =
		-2;
	
	/** Read returned IOException. */
	public static final int READ_STATUS_IOEXCEPTION =
		-3;
	
	/** Descriptor was not found. */
	public static final int CLOSE_STATUS_UNKNOWN_FD =
		-2;
	
	/** Close resulted in any IOException. */
	public static final int CLOSE_STATUS_IOEXCEPTION =
		-3;
	
	/**
	 * Returns the number of bytes which are known to be available. This is
	 * not required to be supported but is available for usage if it would
	 * result in optimization.
	 *
	 * If this is not supported by a resource then zero or a negative value
	 * may be returned.
	 *
	 * @param __fd The file descriptor to check.
	 * @return The number of available bytes.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int available(int __fd);
	
	/**
	 * Closes the given resource.
	 *
	 * @param __fd The resource descriptor to close.
	 * @return A negative value indicating the reason for the failure.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int close(int __fd);
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR the resource is in, this specifies the name of a
	 * suite.
	 * @param __res The name of the resource to load.
	 * @return The file descriptor or a negative value if it does not exist.
	 * If {@code -2} is returned that means there was an exception trying to
	 * load the resource.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int open(String __jar, String __res);
	
	/**
	 * Reads data from the given resource.
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative value if the end of
	 * stream was reached.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int read(int __fd, byte[] __b, int __o,
		int __l);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/StaticMethod.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















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

package cc.squirreljme.runtime.cldc.asm;

/**
 * This interface represents a static method which may be executed accordingly.
 *
 * @since 2018/11/20
 */
public interface StaticMethod
{
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/SuiteAccess.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
66
67
68
69
70
71
72
73
74
75
76












































































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

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to suites and other suites which are available for usage.
 *
 * @since 2018/10/26
 */
public class SuiteAccess
{
	/**
	 * Compile/install using data which was passed directly to the given
	 * byte array.
	 */
	public static final int WHERE_DIRECT =
		1;
	
	/**
	 * Compile/install using the given JAR suite specified as a string, this
	 * may be the same as a classpath value.
	 */
	public static final int WHERE_SUITE =
		2;
	
	/**
	 * Returns the suites which are available for usage.
	 *
	 * @return The suites which are available for usage.
	 * @since 2018/10/26
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String[] availableSuites();
	
	/**
	 * Returns the current classpath that is being used.
	 *
	 * @return The current classpath.
	 * @since 2018/12/06
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String[] currentClassPath();
	
	/**
	 * Specifies that the given JAR should be installed into the suite
	 * manager, it may be compiled first.
	 *
	 * @param __wh Where is this JAR located?
	 * @param __data Data which depends on the where parameter.
	 * @return The install status.
	 * @since 2019/04/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int installJar(int __wh, byte[] __data);
	
	/**
	 * Returns the last compile error which was set.
	 *
	 * @return The last compile error.
	 * @since 2019/04/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int lastCompileError();
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/SystemAccess.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to system related details.
 *
 * @since 2018/10/13
 */
public final class SystemAccess
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/13
	 */
	private SystemAccess()
	{
	}
	
	/**
	 * Returns the specified environment variable, it is unspecified and
	 * system dependent if variables are case sensitive or not. Locale may
	 * be considered by the host system additionally. If environment variables
	 * do not exist in the environment then only {@code null} will be
	 * returned.
	 *
	 * @param __e The environment variable to get.
	 * @return The value of that variable or {@code null} if it is not set.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String getEnv(String __e);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/SystemProperties.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
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













































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import cc.squirreljme.runtime.cldc.SquirrelJME;

/**
 * Access to system properties.
 *
 * @since 2018/09/20
 */
public final class SystemProperties
{
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private SystemProperties()
	{
	}
	
	/**
	 * Returns the approximated path where the VM's executable exists. This
	 * will be the actual JVM's JAR or EXE file.
	 *
	 * @return The approximated executable path or {@code null} if it is not
	 * known.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String executablePath();
	
	/**
	 * Returns the depth of the guests within the virtual machine.
	 *
	 * @return The number of guests.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int guestDepth();
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @since 2018/12/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native String implementationClass(String __n);
	
	/**
	 * Returns the e-mail to contact for the virtual machine.
	 *
	 * @return The contact e-mail for the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMEmail();
	
	/**
	 * Returns the name of the Java virtual machine.
	 *
	 * @return The name of the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMName();
	
	/**
	 * Returns the URL to the virtual machine's vendor's URL.
	 *
	 * @return The URL of the JVM's virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMURL();
	
	/**
	 * Returns the vendor of the Java virtual machine.
	 *
	 * @return The vendor of the Java virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMVendor();
	
	/**
	 * Returns the full version of the Java virtual machine.
	 *
	 * @return The full Java virtual machine version.
	 * @since 2017/08/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String javaVMVersion();
	
	/**
	 * Returns the type of operating SquirrelJME is running on.
	 *
	 * @return The type of operating system SquirrelJME is running on.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int operatingSystemType();
	
	/**
	 * Returns a system property for the given value.
	 *
	 * @param __k The key to get.
	 * @return The value of the property, will be {@code null} if it is not
	 * valid.
	 * @since 2018/09/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static native String systemProperty(String __k);
	
	/**
	 * Returns the version of the class libraries.
	 *
	 * @return The class library version.
	 * @since 2017/10/02
	 */
	public static String javaRuntimeVersion()
	{
		return SquirrelJME.RUNTIME_VERSION;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/TaskAccess.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
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

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to tasks which are running.
 *
 * @since 2018/11/04
 */
public final class TaskAccess
{
	/** The entry point is not valid. */
	public static final int ERROR_INVALID_ENTRY =
		-2;
	
	/** Library in the classpath is missing. */
	public static final int ERROR_MISSING_LIBRARY =
		-3;
	
	/** Exit code indicating bad task things. */
	public static final int EXIT_CODE_FATAL_EXCEPTION =
		127;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private TaskAccess()
	{
	}
	
	/**
	 * Returns the ID of the current thread.
	 *
	 * @return The current thread ID.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int currentThread();
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __tid The thread ID.
	 * @param __p The priority.
	 * @since 2018/12/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void setThreadPriority(int __tid, int __p);
	
	/**
	 * Signals a hardware interrupt on the given thread.
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native void signalInterrupt(int __tid);
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int startTask(String[] __cp, String __main,
		String[] __args);
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @param __sprops System properties in key/value pairs to pass to the
	 * target environment.
	 * @param __stdout Callback to receive standard output data, may be
	 * {@code null} to ignore.
	 * @param __stderr Callback to receive standard error data, may be
	 * {@code null} to ignore.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2019/02/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV)
	public static final native int startTask(String[] __cp, String __main,
		String[] __args, String[] __sprops, ConsoleCallback __stdout,
		ConsoleCallback __stderr);
	
	/**
	 * Starts the given thread.
	 *
	 * @param __t The thread which is to run, the execution point of the
	 * thread is the {@link Thread#__start()} method.
	 * @param __n The name hint of this thread.
	 * @return The thread ID.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int startThread(Thread __t, String __n);
	
	/**
	 * Returns the status of the target task.
	 *
	 * @param __tid The task to get the status of.
	 * @return The status for the given task.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final native int taskStatus(int __tid);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains static methods which in which invocations of methods
 * in the package are replaced by the compiler using native means.
 *
 * @since 2017/12/27
 */

package cc.squirreljme.runtime.cldc.asm;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/debug/CallTraceElement.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706


































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.debug;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single entry within the call stack. This is used for
 * debugging purposes to determine where code has thrown an exception.
 *
 * @since 2018/02/21
 */
public final class CallTraceElement
{
	/** The class name. */
	protected final String classname;
	
	/** The method name. */
	protected final String methodname;
	
	/** The method descriptor. */
	protected final String methoddescriptor;
	
	/** The execution pointer of the address. */
	protected final long address;
	
	/** The source code file. */
	protected final String file;
	
	/** The line in the file. */
	protected final int line;
	
	/** The Java byte code instruction. */
	protected final int jbcinst;
	
	/** The Java byte code address. */
	protected final int jbcaddr;
	
	/** The task ID. */
	protected final int taskid;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** At line form. */
	private Reference<String> _stringatl;
	
	/** Class header form. */
	private Reference<String> _stringclh;
	
	/** Hash code. */
	private int _hash;
	
	/**
	 * Initializes an empty call trace element.
	 *
	 * @since 2018/02/21
	 */
	public CallTraceElement()
	{
		this(null, null, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn)
	{
		this(__cl, __mn, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn, String __md)
	{
		this(__cl, __mn, __md, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @since 2018/02/21
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr)
	{
		this(__cl, __mn, __md, __addr, null, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @since 2018/04/02
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line)
	{
		this(__cl, __mn, __md, __addr, __file, __line, -1, -1);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @param __jbc The Java byte code instruction used.
	 * @param __jpc The Java PC address.
	 * @since 2019/04/26
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line, int __jbc, int __jpc)
	{
		this(__cl, __mn, __md, __addr, __file, __line, __jbc, __jpc, 0);
	}
	
	/**
	 * Initializes a call trace element.
	 *
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __md The method descriptor.
	 * @param __addr The address the method executes at.
	 * @param __file The file.
	 * @param __line The line in the file.
	 * @param __jbc The Java byte code instruction used.
	 * @param __jpc The Java PC address.
	 * @param __tid The task ID.
	 * @since 2019/10/05
	 */
	public CallTraceElement(String __cl, String __mn, String __md, long __addr,
		String __file, int __line, int __jbc, int __jpc, int __tid)
	{
		this.classname = __cl;
		this.methodname = __mn;
		this.methoddescriptor = __md;
		this.address = __addr;
		this.file = __file;
		this.line = __line;
		this.jbcinst = __jbc;
		this.jbcaddr = __jpc;
		this.taskid = __tid;
	}
	
	/**
	 * Returns the address of the element.
	 *
	 * @return The element address.
	 * @since 2018/03/15
	 */
	public final long address()
	{
		return this.address;
	}
	
	/**
	 * Returns the address of the instruction at the Java byte code position.
	 *
	 * @return The address of the instruction in Java byte code.
	 * @since 2019/04/26
	 */
	public final int byteCodeAddress()
	{
		return this.jbcaddr;
	}
	
	/**
	 * Returns the byte code instruction that was used for this.
	 *
	 * @return The used byte code instruction or {@code 0xFF} if it is not
	 * valid or specified.
	 * @since 2019/04/26
	 */
	public final int byteCodeInstruction()
	{
		return this.jbcinst & 0xFF;
	}
	
	/**
	 * Returns the name of the associated class.
	 *
	 * @return The associated class.
	 * @since 2018/03/15
	 */
	public final String className()
	{
		return this.classname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/02/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof CallTraceElement))
			return false;
		
		CallTraceElement o = (CallTraceElement)__o;
		return Objects.equals(this.classname, o.classname) &&
			Objects.equals(this.methodname, o.methodname) &&
			Objects.equals(this.methoddescriptor, o.methoddescriptor) &&
			Objects.equals(this.file, o.file) &&
			this.address == o.address &&
			this.line == o.line &&
			this.jbcinst == o.jbcinst &&
			this.jbcaddr == o.jbcaddr &&
			this.taskid == o.taskid;
	}
	
	/**
	 * Returns the source file.
	 *
	 * @return The source file.
	 * @since 2018/04/02
	 */
	public final String file()
	{
		return this.file;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/02/21
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
		{
			long address = this.address;
			this._hash = (rv = Objects.hashCode(this.classname) ^
				Objects.hashCode(this.methodname) ^
				Objects.hashCode(this.methoddescriptor) ^
				Objects.hashCode(this.file) ^
				(int)((address >>> 32) | address) ^
				~this.line +
				~this.jbcinst +
				~this.jbcaddr +
				~this.taskid);
		}
		return rv;
	}
	
	/**
	 * Returns the source file line.
	 *
	 * @return The source file line.
	 * @since 2018/04/02
	 */
	public final int line()
	{
		return this.line;
	}
	
	/**
	 * Returns the descriptor of the method.
	 *
	 * @return The method descriptor.
	 * @since 2018/03/15
	 */
	public final String methodDescriptor()
	{
		return this.methoddescriptor;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2018/03/15
	 */
	public final String methodName()
	{
		return this.methodname;
	}
	
	/**
	 * Formats the call trace element but having it only represent the method
	 * point without the class information.
	 *
	 * @return The at line string.
	 * @since 2019/05/11
	 */
	public final String toAtLineString()
	{
		Reference<String> ref = this._stringatl;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String methodname = this.methodname,
				methoddescriptor = this.methoddescriptor;
			long address = this.address;
			int line = this.line;
			int jbcinst = this.jbcinst & 0xFF;
			int jbcaddr = this.jbcaddr;
			int taskid = this.taskid;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			// Method name
			sb.append('.');
			sb.append((methodname == null ? "<unknown>" : methodname));
			
			// Method type
			if (methoddescriptor != null)
			{
				sb.append(':');
				sb.append(methoddescriptor);
			}
			
			// Task ID?
			if (taskid != 0)
			{
				sb.append(" T");
				sb.append(taskid);
			}
			
			// Execution address
			if (address != Long.MIN_VALUE)
			{
				sb.append(" @");
				
				// If the address is really high then it is very likely that
				// this is some RAM/ROM address rather than some easily read
				// index. This makes them more readable and understandable
				if (address > 4096)
				{
					sb.append(Long.toString(address, 16).toUpperCase());
					sb.append('h');
				}
				
				// Otherwise use an index
				else
					sb.append(address);
			}
			
			// File, Line, and/or Java instruction/address
			boolean hasline = (line >= 0),
				hasjbcinst = (jbcinst > 0xFF && jbcinst < 0xFF),
				hasjbcaddr = (jbcaddr >= 0);
			if (hasline || hasjbcinst || hasjbcaddr)
			{
				sb.append(" (");
				
				// Line
				boolean sp = false;
				if ((sp |= hasline))
				{
					sb.append(':');
					sb.append(line);
				}
				
				// Java instruction info
				if (hasjbcinst || hasjbcaddr)
				{
					// Using space?
					if (sp)
						sb.append(' ');
					
					// Used to indicate Java specific stuff
					sb.append('J');
					
					// Write instruction
					if (hasjbcinst)
						sb.append(jbcinst);
					
					// Write address of Java operation
					if (hasjbcaddr)
					{
						sb.append('@');
						sb.append(jbcaddr);
					}
				}
				
				sb.append(')');
			}
			
			this._stringatl = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Formats the call trace element but having it only represent the class.
	 *
	 * @return The class header string.
	 * @since 2019/05/11
	 */
	public final String toClassHeaderString()
	{
		Reference<String> ref = this._stringclh;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String classname = this.classname,
				file = this.file;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			// Class name
			sb.append((classname == null ? "<unknown>" : classname));
			
			// Is this in a file?
			boolean hasfile = (file != null);
			if (hasfile)
			{
				sb.append(" (");
				
				// File
				boolean sp = false;
				if ((sp |= hasfile))
					sb.append(file);
				
				sb.append(')');
			}
			
			this._stringclh = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/14
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Get all fields to determine how to print it pretty
			String classname = this.classname,
				methodname = this.methodname,
				methoddescriptor = this.methoddescriptor,
				file = this.file;
			long address = this.address;
			int line = this.line;
			int jbcinst = this.jbcinst & 0xFF;
			int jbcaddr = this.jbcaddr;
			int taskid = this.taskid;
			
			// Format it nicely
			StringBuilder sb = new StringBuilder();
			
			sb.append((classname == null ? "<unknown>" : classname));
			sb.append('.');
			sb.append((methodname == null ? "<unknown>" : methodname));
			
			if (methoddescriptor != null)
			{
				sb.append(':');
				sb.append(methoddescriptor);
			}
			
			// Task ID?
			if (taskid != 0)
			{
				sb.append(" T");
				sb.append(taskid);
			}
			
			if (address != Long.MIN_VALUE)
			{
				sb.append(" @");
				
				// If the address is really high then it is very likely that
				// this is some RAM/ROM address rather than some easily read
				// index. This makes them more readable and understandable
				if (address > 4096)
				{
					sb.append(Long.toString(address, 16).toUpperCase());
					sb.append('h');
				}
				
				// Otherwise use an index
				else
					sb.append(address);
			}
			
			// File, Line, and/or Java instruction/address
			boolean hasfile = (file != null),
				hasline = (line >= 0),
				hasjbcinst = (jbcinst > 0x00 && jbcinst < 0xFF),
				hasjbcaddr = (jbcaddr >= 0);
			if (hasfile || hasline || hasjbcinst || hasjbcaddr)
			{
				sb.append(" (");
				
				// File
				boolean sp = false;
				if ((sp |= hasfile))
					sb.append(file);
				
				// Line
				if ((sp |= hasline))
				{
					sb.append(':');
					sb.append(line);
				}
				
				// Java instruction info
				if (hasjbcinst || hasjbcaddr)
				{
					// Using space?
					if (sp)
						sb.append(' ');
					
					// Used to indicate Java specific stuff
					sb.append('J');
					
					// Write instruction
					if (hasjbcinst)
						sb.append(jbcinst);
					
					// Write address of Java operation
					if (hasjbcaddr)
					{
						sb.append('@');
						sb.append(jbcaddr);
					}
				}
				
				sb.append(')');
			}
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Obtains the current raw call trace which has not been resolved.
	 *
	 * @return The raw call trace.
	 * @since 2019/06/16
	 */
	public static final int[] traceRaw()
	{
		// Get the call height, ignore if not supported!
		int callheight = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_HEIGHT);
		if (callheight <= 0 || Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.CALL_STACK_HEIGHT) != SystemCallError.NO_ERROR)
			return new int[0];
		
		// Remove the top-most frame because it will be this method
		callheight--;
		
		// Get the call parameters
		int[] rv = new int[callheight * CallStackItem.NUM_ITEMS];
		for (int z = 0, base = 0; z < callheight; z++,
			base += CallStackItem.NUM_ITEMS)
			for (int i = 0; i < CallStackItem.NUM_ITEMS; i++)
			{
				// Get parameter
				int vx = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_ITEM,
					1 + z, i);
				
				// Nullify unknown or invalid parameters
				if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
					SystemCallIndex.CALL_STACK_ITEM) !=
					SystemCallError.NO_ERROR)
					vx = 0;
				
				// Fill in
				rv[base + i] = vx;
			}
		
		// Return the raw parameters
		return rv;
	}
	
	/**
	 * Resolves the specified call trace into call trace elements.
	 *
	 * @param __trace The trace to resolve.
	 * @return The resolved trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	public static final CallTraceElement[] traceResolve(int[] __trace)
		throws NullPointerException
	{
		if (__trace == null)
			throw new NullPointerException("NARG");
		
		// Get the call height
		int callheight = __trace.length / CallStackItem.NUM_ITEMS;
		
		// Process all the items
		CallTraceElement[] rv = new CallTraceElement[callheight];
		for (int z = 0, base = 0; z < callheight; z++,
			base += CallStackItem.NUM_ITEMS)
		{
			// Load class name
			int xcl = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.CLASS_NAME]);
			String scl = ((xcl == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xcl));
				
			// Load method name
			int xmn = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.METHOD_NAME]);
			String smn = ((xmn == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xmn));
			
			// Load method type
			int xmt = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.METHOD_NAME]);
			String smt = ((xmt == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xmt));
			
			// Load source file
			int xsf = Assembly.sysCallV(SystemCallIndex.LOAD_STRING,
				__trace[base + CallStackItem.SOURCE_FILE]);
			String ssf = ((xsf == 0 || Assembly.sysCallV(
				SystemCallIndex.ERROR_GET, SystemCallIndex.LOAD_STRING) !=
				SystemCallError.NO_ERROR) ?
				(String)null : (String)Assembly.pointerToObject(xsf));
			
			// The PC address
			int pcaddr = __trace[base + CallStackItem.PC_ADDRESS];
			
			// Task ID
			int tid = __trace[base + CallStackItem.TASK_ID];
			
			// Build elements
			rv[z] = new CallTraceElement(
				scl,
				smn,
				smt,
				(pcaddr == 0 ? -1 : pcaddr),
				ssf,
				__trace[base + CallStackItem.SOURCE_LINE],
				__trace[base + CallStackItem.JAVA_OPERATION],
				__trace[base + CallStackItem.JAVA_PC_ADDRESS],
				tid);
		}
		
		// Use the resolved form
		return rv;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/debug/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains debugging interfaces and classes used by SquirrelJME.
 *
 * @since 2018/02/21
 */

package cc.squirreljme.runtime.cldc.debug;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/BasicLocale.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Basic locale support.
 *
 * @since 2018/09/20
 */
public abstract class BasicLocale
	implements Locale
{
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public char toLowerCase(char __c)
	{
		if ((__c >= 'A' && __c <= 'Z') || (__c >= 0xC0 && __c <= 0xDE))
			return (char)(__c + 0x20);
		return __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/29
	 */
	@Override
	public char toUpperCase(char __c)
	{
		if ((__c >= 'a' && __c <= 'z') || (__c >= 0xE0 && __c <= 0xFE))
			return (char)(__c - 0x20);
		return __c;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/DefaultLocale.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 final 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();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/Locale.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 represents the interface used to perform locale based operations.
 *
 * @since 2018/09/20
 */
public interface Locale
{
	/**
	 * Converts the specified character to lowercase.
	 *
	 * @param __c The input character.
	 * @return The lowercased character.
	 * @since 2018/09/20
	 */
	public abstract char toLowerCase(char __c);
	
	/**
	 * Converts the specified character to uppercase.
	 *
	 * @param __c The input character.
	 * @return The uppercased character.
	 * @since 2018/09/28
	 */
	public abstract char toUpperCase(char __c);
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/LocaleEn.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * English locale support.
 *
 * @since 2018/09/20
 */
public class LocaleEn
	extends BasicLocale
{
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/LocaleEnUs.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * English in United States locale support.
 *
 * @since 2018/09/20
 */
public class LocaleEnUs
	extends LocaleEn
{
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/i18n/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Internationalization support classes.
 *
 * @since 2018/09/20
 */

package cc.squirreljme.runtime.cldc.i18n;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ASCIIDecoder.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Decoder for ASCII.
 *
 * @since 2018/12/23
 */
public final class ASCIIDecoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Negative values are 128 and up
		byte b = __b[__o];
		if (b < 0)
			return 0x1_0000 | 0xFFFD;
		return 0x1_0000 | (b & 0xFF);
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/12/23
	 */
	@Override
	public final String encodingName()
	{
		return "ascii";
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/12/23
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ASCIIEncoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This encodes ASCII.
 *
 * @since 2018/12/23
 */
public final class ASCIIEncoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x80)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/12/23
	 */
	@Override
	public final String encodingName()
	{
		return "ascii";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/23
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/CodecFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.io.UnsupportedEncodingException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains the code used to obtain the default encoding as well as
 * obtaining the encoder or decoder as needed.
 *
 * @since 2018/09/16
 */
public final class CodecFactory
{
	/** The encoding to use if it is unknown or not set anywhere. */
	public static final String FALLBACK_ENCODING =
		"utf-8";
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/16
	 */
	private CodecFactory()
	{
	}
	
	/**
	 * Returns a decoder for the given encoding.
	 *
	 * @param __enc The encoding to decode for.
	 * @return The decoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public static final Decoder decoder(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Normalization makes it easier to match
		switch ((__enc = CodecFactory.__normalizeEncodingName(__enc)))
		{
				// ASCII
			case "ascii":
				return new ASCIIDecoder();
				
				// IBM037
			case "ibm037":
				throw new todo.TODO();

				// ISO-8859-1
			case "iso-8859-1":
				return new ISO88591Decoder();
				
				// ISO-8859-15
			case "iso-8859-15":
				return new ISO885915Decoder();
				
				// UTF-8
			case "utf-8":
				return new UTF8Decoder();
			
				// {@squirreljme.error ZZ01 Unknown encoding. (The input
				// encoding)}
			default:
				throw new UnsupportedEncodingException(
					String.format("ZZ01 %s", __enc));
		}
	}
	
	/**
	 * Returns a decoder for the given encoding.
	 *
	 * @param __enc The encoding to decode for.
	 * @return The decoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws RuntimeException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public static final Decoder decoderUnchecked(String __enc)
		throws NullPointerException, RuntimeException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return CodecFactory.decoder(__enc);
		}
		
		// {@squirreljme.error ZZ02 Unknown or unsupported encoding.
		// (The encoding)}
		catch (UnsupportedEncodingException e)
		{
			throw new RuntimeException(String.format("ZZ02 %s", __enc), e);
		}
	}
	
	/**
	 * Returns the default decoder.
	 *
	 * @return The default decoder.
	 * @since 2018/10/13
	 */
	public static final Decoder defaultDecoder()
	{
		return CodecFactory.decoderUnchecked(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default system encoder.
	 *
	 * @return The default encoder.
	 * @since 2018/09/16
	 */
	public static final Encoder defaultEncoder()
	{
		return CodecFactory.encoderUnchecked(CodecFactory.defaultEncoding());
	}
	
	/**
	 * Returns the default encoding.
	 *
	 * @return The default encoding.
	 * @since 2018/09/16
	 */
	public static final String defaultEncoding()
	{
		// If no encoding has been set, fallback on one so it is always valid
		try
		{
			String rv = System.getProperty("microedition.encoding");
			if (rv == null)
				return CodecFactory.FALLBACK_ENCODING;
			return rv;
		}
		catch (SecurityException e)
		{
			return CodecFactory.FALLBACK_ENCODING;
		}
	}
	
	/**
	 * Returns the specified encoder.
	 *
	 * @param __enc The encoding to encode to.
	 * @return The encoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	public static final Encoder encoder(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Normalization makes it easier to match
		switch ((__enc = CodecFactory.__normalizeEncodingName(__enc)))
		{
				// ASCII
			case "ascii":
				return new ASCIIEncoder();
				
				// IBM037
			case "ibm037":
				return new IBM037Encoder();

				// ISO-8859-1
			case "iso-8859-1":
				return new ISO88591Encoder();
				
				// ISO-8859-15
			case "iso-8859-15":
				return new ISO885915Encoder();
				
				// UTF-8
			case "utf-8":
				return new UTF8Encoder();
			
				// {@squirreljme.error ZZ03 Unknown encoding. (The output
				// encoding)}
			default:
				throw new UnsupportedEncodingException(
					String.format("ZZ03 %s", __enc));
		}
	}
	
	/**
	 * Returns the specified encoder.
	 *
	 * @param __enc The encoding to encode to.
	 * @return The encoder for the given encoding.
	 * @throws NullPointerException On null arguments.
	 * @throws RuntimeException If the encoding is not valid.
	 * @since 2018/09/17
	 */
	public static final Encoder encoderUnchecked(String __enc)
		throws NullPointerException, RuntimeException
	{
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return CodecFactory.encoder(__enc);
		}
		
		// {@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
	 * returned.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	private static final String __normalizeEncodingName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Store original since it will be lowercase
		String orign = __n;
		
		// Lowercase and map values
		switch ((__n = __n.toLowerCase()))
		{
				// ASCII
			case "646":
			case "ansi_x3.4-1968":
			case "ansi_x3.4-1986":
			case "ascii":
			case "ascii7":
			case "cp367":
			case "csascii":
			case "ibm367":
			case "iso_646.irv:1983":
			case "iso_646.irv:1991":
			case "iso646-us":
			case "iso-ir-6":
			case "us":
			case "us-ascii":
				return "ascii";
				
				// IBM037
			case "037":
			case "cp037":
			case "cpibm37":
			case "cs-ebcdic-cp-ca":
			case "cs-ebcdic-cp-nl":
			case "cs-ebcdic-cp-us":
			case "cs-ebcdic-cp-wt":
			case "csibm037":
			case "ebcdic-cp-ca":
			case "ebcdic-cp-nl":
			case "ebcdic-cp-us":
			case "ebcdic-cp-wt":
			case "ibm037":
			case "ibm-037":
			case "ibm-37":
				return "ibm037";
			
				// ISO-8859-1
			case "819":
			case "8859_1":
			case "cp819":
			case "csisolatin1":
			case "ibm819":
			case "ibm-819":
			case "iso_8859_1":
			case "iso_8859-1":
			case "iso-8859-1":
			case "iso8859_1":
			case "iso8859-1":
			case "iso_8859-1:1987":
			case "iso-ir-100":
			case "l1":
			case "latin1":
				return "iso-8859-1";
			
				// UTF-8
			case "unicode-1-1-utf-8":
			case "utf8":
			case "utf-8":
				return "utf-8";
			
				// Unknown use original
			default:
				return orign;
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ConsoleOutputStream.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
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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.runtime.cldc.asm.ConsoleOutput;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This provides an output stream which writes to a console file descriptor.
 *
 * @since 2018/12/08
 */
public final class ConsoleOutputStream
	extends OutputStream
{
	/** the file descriptor to write to. */
	protected final int fd;
	
	/**
	 * Initializes the output stream.
	 *
	 * @param __fd The descriptor to write to.
	 * @since 2018/12/08
	 */
	public ConsoleOutputStream(int __fd)
	{
		this.fd = __fd;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public void flush()
		throws IOException
	{
		// {@squirreljme.error ZZ05 Could not flush the console.}
		if (ConsoleOutput.flush(this.fd) < 0)
			throw new IOException("ZZ05");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/06/16
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		// {@squirreljme.error ZZ06 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b) != 0)
			throw new IOException("ZZ06");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void write(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ07 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b, 0, __b.length) < 0)
			throw new IOException("ZZ07");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/05
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error ZZ08 Error writing to console.}
		if (ConsoleOutput.write(this.fd, __b, __o, __l) < 0)
			throw new IOException("ZZ08");
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/Decoder.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This is a decoder which is able to decode input characters and return
 * characters for the input sequence.
 *
 * @since 2018/10/13
 */
public interface Decoder
	extends NamedCodec
{
	/**
	 * Decodes the input bytes.
	 *
	 * @param __b The input byte array.
	 * @param __o The offset.
	 * @param __l The length. Due to the way the return value is used, the
	 * maximum supported length must be limited to 32,767 characters.
	 * @return The decoded character with the upper 16-bits specifying the
	 * number of read bytes, if a negative value is used it is a hint
	 * on the number of bytes needed to decode the character. Note that the
	 * hint may always be {@code -1} if in the event it will not be known how
	 * many bytes to read for a given character. The only result which will
	 * return the length in the upper bytes are sequences which generate
	 * characters, so incomplete sequences will always be negative. When
	 * casting the result to {@code char} the upper bits will be truncated.
	 * @throws IndexOutOfBoundsException If the offset and or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public abstract int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/Encoder.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This interface represents an encoder that is used to turn characters into
 * potentially multiple bytes.
 *
 * @since 2018/09/16
 */
public interface Encoder
	extends NamedCodec
{
	/**
	 * Encodes the given character and writes it to the output byte array.
	 *
	 * @param __c The character to encode.
	 * @param __b The output byte array.
	 * @param __o The offset to the array.
	 * @param __l The length of the area to write.
	 * @return The number of bytes written, {@code -1} means the character
	 * cannot be encoded because it will not fit in the buffer.
	 * @throws IndexOutOfBoundsException If the offset and or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/21
	 */
	public abstract int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/IBM037Encoder.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Encodes to EBCDIC IBM037.
 *
 * @since 2018/09/24
 */
public final class IBM037Encoder
	implements Encoder
{
	/** Mapping of char to byte. */
	private static final byte[] _MAP =
		new byte[]
		{
			0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, 16, 17,
			18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, 64, 90,
			127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97, -16,
			-15, -14, -13, -12, -11, -10, -9, -8, -7, 122, 94, 76, 126, 110,
			111, 124, -63, -62, -61, -60, -59, -58, -57, -56, -55, -47, -46,
			-45, -44, -43, -42, -41, -40, -39, -30, -29, -28, -27, -26, -25,
			-24, -23, -70, -32, -69, -80, 109, 121, -127, -126, -125, -124,
			-123, -122, -121, -120, -119, -111, -110, -109, -108, -107, -106,
			-105, -104, -103, -94, -93, -92, -91, -90, -89, -88, -87, -64, 79,
			-48, -95, 7, 32, 33, 34, 35, 36, 0, 6, 23, 40, 41, 42, 43, 44, 9,
			10, 27, 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,
			-1, 65, -86, 74, -79, -97, -78, 106, -75, -67, -76, -102, -118, 95,
			-54, -81, -68, -112, -113, -22, -6, -66, -96, -74, -77, -99, -38,
			-101, -117, -73, -72, -71, -85, 100, 101, 98, 102, 99, 103, -98,
			104, 116, 113, 114, 115, 120, 117, 118, 119, -84, 105, -19, -18,
			-21, -17, -20, -65, -128, -3, -2, -5, -4, -83, -82, 89, 68, 69, 66,
			70, 67, 71, -100, 72, 84, 81, 82, 83, 88, 85, 86, 87, -116, 73,
			-51, -50, -53, -49, -52, -31, 112, -35, -34, -37, -36, -115, -114,
			-33
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// Invalid characters are turned into question marks
		if (__c >= 0x100)
			__c = '?';
		
		// Map
		__b[__o] = _MAP[__c];
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "ibm037";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ISO885915Decoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.io;

/**
 * Decoder for ISO-8859-15.
 *
 * @since 2019/04/29
 */
public class ISO885915Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Remap some characters?
		int c = (__b[__o] & 0xFF);
		switch (c)
		{
			case 0x00A4:	c = 0x20AC; break;
			case 0x00A6:	c = 0x0160; break;
			case 0x00A8:	c = 0x0161; break;
			case 0x00B4:	c = 0x017D; break;
			case 0x00B8:	c = 0x017E; break;
			case 0x00BC:	c = 0x0152; break;
			case 0x00BD:	c = 0x0153; break;
			case 0x00BE:	c = 0x0178; break;
		}
		
		return 0x1_0000 | c;
	}
	
	/**
	 * {@inheritDc}
	 * @since 2019/04/29
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-15";
	}
	
	/**
	 * {@inheritDc}
	 * @since 2019/04/29
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ISO885915Encoder.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.io;

/**
 * Encodes character data to ISO-8859-15.
 *
 * @since 2019/04/29
 */
public final class ISO885915Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
			
		// Remap some characters?
		switch (__c)
		{
				// Convert
			case 0x20AC:	__c = (char)0x00A4; break;
			case 0x0160:	__c = (char)0x00A6; break;
			case 0x0161:	__c = (char)0x00A8; break;
			case 0x017D:	__c = (char)0x00B4; break;
			case 0x017E:	__c = (char)0x00B8; break;
			case 0x0152:	__c = (char)0x00BC; break;
			case 0x0153:	__c = (char)0x00BD; break;
			case 0x0178:	__c = (char)0x00BE; break;
			
				// Cannot be encoded
			case 0x00A4:
			case 0x00A6:
			case 0x00A8:
			case 0x00B4:
			case 0x00B8:
			case 0x00BC:
			case 0x00BD:
			case 0x00BE:	__c = (char)0xFFFD; break;
		}
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x100)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDc}
	 * @since 2019/04/29
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-15";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/29
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ISO88591Decoder.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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Decoder for ISO-8859-1.
 *
 * @since 2018/11/11
 */
public final class ISO88591Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		return 0x1_0000 | (__b[__o] & 0xFF);
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/11/11
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-1";
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/11/11
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ISO88591Encoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * Encodes character data to ISO-8859-1.
 *
 * @since 2018/09/20
 */
public final class ISO88591Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Always encodes to one character, so if one character cannot fit in
		// the buffer then fail
		if (__l < 1)
			return -1;
		
		// These characters are invalid, so they all become the replacement
		// character
		if (__c >= 0x100)
			__b[__o] = '?';
		
		// Encode as is
		else
			__b[__o] = (byte)__c;
		
		// Only single characters written
		return 1;
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "iso-8859-1";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/NamedCodec.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This is used to get the name of the encoder or decoder that was used.
 *
 * @since 2018/10/13
 */
public interface NamedCodec
{
	/**
	 * The average sequence length used for characters, used to estimate how
	 * big of an array to allocate for characters.
	 *
	 * @return The average sequence length.
	 * @since 2018/11/06
	 */
	public abstract double averageSequenceLength();
	
	/**
	 * Returns the name of the encoding.
	 *
	 * @return The encoding name.
	 * @since 2018/10/13
	 */
	public abstract String encodingName();
	
	/**
	 * Returns a hint which specifies the maximum length of a byte sequence
	 * for decoding.
	 *
	 * @return The maximum sequence length for decoding.
	 * @since 2018/10/13
	 */
	public abstract int maximumSequenceLength();
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/ResourceInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.io.InputStream;
import java.io.IOException;
import cc.squirreljme.runtime.cldc.asm.ResourceAccess;

/**
 * This input stream handles reading of resources.
 *
 * @since 2018/10/07
 */
public final class ResourceInputStream
	extends InputStream
{
	/** The file descriptor. */
	protected final int fd;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/**
	 * Initializes the resource input stream.
	 *
	 * @param __fd The file descriptor.
	 * @since 2018/10/07
	 */
	public ResourceInputStream(int __fd)
	{
		this.fd = __fd;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int available()
		throws IOException
	{
		// {@squirreljme.error ZZ09 Could not obtain the available
		// number of bytes left. (The error value)}
		int rv = ResourceAccess.available(this.fd);
		if (rv < 0)
			throw new IOException("ZZ09 " + rv);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Prevent double close of resources because the values may be
		// recycled
		if (!this._closed)
		{
			this._closed = true;
			
			// {@squirreljme.error ZZ0a Closing of resource resulted in an
			// IOException.}
			int rv;
			if ((rv = ResourceAccess.close(this.fd)) < 0)
				throw new IOException("ZZ0a " + rv);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read()
		throws IOException
	{
		byte[] rv = new byte[1];
		for (;;)
		{
			int code = this.read(rv, 0, 1);
			
			// Try again
			if (code == 0)
				continue;
			
			// EOF
			else if (code < 0)
				return -1;
			
			// Snip bits off
			return (rv[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If the stream has been closed it is probably not valid so always
		// return EOF
		if (this._closed)
			return -1;
		
		// Read from stream
		int rv = ResourceAccess.read(this.fd, __b, __o, __l);
		
		// If the end of stream was reached, so just close this stream so
		// that resources are free. Since resources always exist it is very
		// possible that they might not be closed because they are seen as
		// a free resource that has no implications if they are never closed.
		if (rv < 0)
		{
			// {@squirreljme.error ZZ0b Read of resource resulted in an
			// IOException.}
			IOException toss = (rv != ResourceAccess.READ_STATUS_EOF ?
				new IOException("ZZ0b " + rv) : null);
			
			// Close it to not claim resources
			try
			{
				this.close();
			}
			catch (IOException e)
			{
				// If closing caused an issue then
				if (toss != null)
					toss.addSuppressed(e);
				else
					toss = e;
			}
			
			// Either throw the exception or EOF
			if (toss != null)
				throw toss;
			return -1;
		}
		
		// Will be the number of read bytes
		return rv;
	}
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR to look within.
	 * @param __rc The name of the resource to open.
	 * @return The stream for the given resource or {@code null} if it does not
	 * exist.
	 * @since 2018/10/26
	 */
	public static final ResourceInputStream open(String __jar, String __rc)
		throws NullPointerException
	{
		if (__jar == null || __rc == null)
			throw new NullPointerException("NARG");
		
		// If no resource exists then
		int fd = ResourceAccess.open(__jar, __rc);
		if (fd < 0)
		{
			// Any other value besides this means some resource error
			if (fd != ResourceAccess.OPEN_STATUS_NO_RESOURCE)
				todo.DEBUG.note("RA.o(%s, %s) = %d", __jar, __rc, fd);
			return null;
		}
		
		// Otherwise read from that resource
		return new ResourceInputStream(fd);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/SecureByteArrayOutputStream.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is a {@link ByteArrayOutputStream} which does not expose the internal
 * buffer field via the {@link #writeTo(OutputStream)} method.
 *
 * @since 2018/01/15
 */
public final class SecureByteArrayOutputStream
	extends ByteArrayOutputStream
{
	/**
	 * Initializes using the default capacity.
	 *
	 * @since 2018/01/15
	 */
	public SecureByteArrayOutputStream()
	{
		super();
	}
	
	/**
	 * Initializes using the specified capacity.
	 *
	 * @param __n The number of bytes to store.
	 * @since 2018/01/15
	 */
	public SecureByteArrayOutputStream(int __n)
	{
		super(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/01/15
	 */
	@Override
	public void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/UTF8Decoder.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This class provides a decoder for UTF-8 bytes.
 *
 * @since 2018/10/13
 */
public final class UTF8Decoder
	implements Decoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.3333;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final int decode(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Not enough to decode a character
		if (__l <= 0)
			return -1;
		
		// Determine the length of the sequence
		byte a = __b[__o];
		int seqlen = 
			(((a & 0b1_0000000) == 0b0_0000000) ? 1 :
			(((a & 0b111_00000) == 0b110_00000) ? 2 :
			(((a & 0b1111_0000) == 0b1110_0000) ? 3 :
			(((a & 0b11111_000) == 0b11110_000) ? 4 :
			-1))));
		
		// Either some unknown sequence or it is a character after U+FFFF which
		// is not supported
		if (seqlen < 0 || seqlen == 4)
			return 0xFFFD | (seqlen > 0 ? (seqlen << 16) : 0x1_0000);
		
		// Cannot decode the entire sequence because there is not enough
		// room
		if (__l < seqlen)
			return -seqlen;
		
		// Decode the character
		switch (seqlen)
		{
				// U+0000 to U+007F
			case 1:
				return (a & 0xFF) | 0x1_0000;
				
				// U+0080 to U+07FF
			case 2:
				return (((__b[__o + 0] & 0b11111) << 6) |
					(__b[__o + 1] & 0b111111)) | 0x2_0000;
				
				// U+0800 to U+FFFF
			case 3:
				return (((__b[__o + 0] & 0b1111) << 12) |
					((__b[__o + 1] & 0b111111) << 6) |
					(__b[__o + 2] & 0b111111)) | 0x3_0000;
				
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "utf-8";
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/10/13
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 4;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/UTF8Encoder.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
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







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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;

/**
 * This encoder encodes input characters to standard UTF-8 sequences.
 *
 * Surrogate pairs will be encoded as 6 bytes.
 *
 * @since 2018/09/19
 */
public final class UTF8Encoder
	implements Encoder
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public final double averageSequenceLength()
	{
		return 1.3333;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public int encode(char __c, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// One byte
		if (__c >= 0x0000 && __c <= 0x007F)
		{
			if (__l < 1)
				return -1;
			
			__b[__o] = (byte)__c;
			
			return 1;
		}
		
		// Two Byte
		else if (__c >= 0x0080 && __c <= 0x07FF)
		{
			if (__l < 2)
				return -2;
			
			__b[__o + 0] = (byte)(((__c >>> 6) & 0b11111) | 0b110_00000); 
			__b[__o + 1] = (byte)((__c & 0b111111) | 0b10_000000);
			
			return 2;
		}
		
		// Three byte (__c >= 0x0800 && __c <= 0xFFFF)
		else
		{
			if (__l < 3)
				return -3;
				
			__b[__o + 0] = (byte)(((__c >>> 12) & 0b1111) | 0b1110_0000); 
			__b[__o + 1] = (byte)(((__c >>> 6) & 0b111111) | 0b10_000000);
			__b[__o + 2] = (byte)((__c & 0b111111) | 0b10_000000);
			
			return 3;
		}
	}
	
	/**
	 * {@inheritDc}
	 * @since 2018/10/13
	 */
	@Override
	public final String encodingName()
	{
		return "utf-8";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final int maximumSequenceLength()
	{
		return 4;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/io/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains I/O related classes.
 *
 * @since 2018/03/01
 */

package cc.squirreljme.runtime.cldc.io;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ApiLevel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * Provides access to the current API level.
 *
 * This is used for backwards compatibility.
 *
 * Levels are in the form of {@code 0M_mm_R_yyDDD} (Major version, minor
 * version, release version, year (20yy), day of year). This means they are
 * limited to the form of {@code [0-9].[0-99].[0-9] (Day [0-999] of 20[0-99])}.
 *
 * @since 2018/12/05
 */
public final class ApiLevel
{
	/** The current API level. */
	public static final int CURRENT_LEVEL =
		Assembly.sysCallV(SystemCallIndex.API_LEVEL);
	
	/** Undefined. */
	public static final int UNDEFINED =
		0x7FFFFFFF;
	
	/** SquirrelJME 0.2.0 (December 25, 2018). */
	public static final int LEVEL_SQUIRRELJME_0_2_0_20181225 =
		2_0_18359;
	
	/** SquirrelJME 0.3.0 (Development). */
	public static final int LEVEL_SQUIRRELJME_0_3_0_DEV =
		3_0_19001;
	
	/** SquirrelJME 0.4.0 (July 4, 2019). */
	public static final int LEVEL_SQUIRRELJME_0_4_0_20190704 =
		4_0_19185;
	
	/**
	 * Not used.
	 *
	 * @since 2018/12/05
	 */
	private ApiLevel()
	{
	}
	
	/**
	 * Converts an API level to a string.
	 *
	 * @param __l The input level.
	 * @return The string.
	 * @since 2018/12/05
	 */
	public static String levelToString(int __l)
	{
		return String.format("%d.%d.%d (Day %d of %d)",
			(__l / 100000000) % 10,
			(__l / 1000000) % 100,
			(__l / 100000) % 10,
			__l % 1000,
			2000 + ((__l / 1000) % 100));
	}
	
	/**
	 * Checks if the runtime API level is at a minimum this given level.
	 *
	 * @param __l The level to check.
	 * @return If the minimum level is met.
	 * @since 2019/02/02
	 */
	public static boolean minimumLevel(int __l)
	{
		return (CURRENT_LEVEL >= __l);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ArrayUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518






































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This method contains the code which is able to initialize multi-dimensional
 * arrays and perform other array related tasks.
 *
 * @since 2018/11/03
 */
public final class ArrayUtils
{
	/** Boolean array. */
	public static final byte ARRAY_BOOLEAN =
		1;
	
	/** Byte array. */
	public static final byte ARRAY_BYTE =
		2;
	
	/** Short array. */
	public static final byte ARRAY_SHORT =
		3;
	
	/** Character array. */
	public static final byte ARRAY_CHARACTER =
		4;
	
	/** Integer array. */
	public static final byte ARRAY_INTEGER =
		5;
	
	/** Long array. */
	public static final byte ARRAY_LONG =
		6;
	
	/** Float array. */
	public static final byte ARRAY_FLOAT =
		7;
	
	/** Double array. */
	public static final byte ARRAY_DOUBLE =
		8;
	
	/** Object array. */
	public static final byte ARRAY_OBJECT =
		9;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/03
	 */
	private ArrayUtils()
	{
	}
	
	/**
	 * Sets the value in the array.
	 *
	 * @param __a The array.
	 * @param __dx The index to set.
	 * @param __v The value to store.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @throws ClassCastException If the wrong class is used.
	 * @throws IllegalArgumentException If the argument is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final void arraySet(Object __a, int __dx, Object __v)
		throws ArrayIndexOutOfBoundsException, ClassCastException,
			IllegalArgumentException, NullPointerException
	{
		ArrayUtils.arraySet(ArrayUtils.arrayType(__a), __a, __dx, __v);
	}
	
	/**
	 * Sets the value in the array.
	 *
	 * @param __type The type of array used.
	 * @param __a The array.
	 * @param __dx The index to set.
	 * @param __v The value to store.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @throws ClassCastException If the wrong class is used.
	 * @throws IllegalArgumentException If the argument is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final void arraySet(int __type, Object __a, int __dx,
		Object __v)
		throws ArrayIndexOutOfBoundsException, ClassCastException,
			IllegalArgumentException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Depends on the type
		switch (__type)
		{
			case ARRAY_BOOLEAN:
				((boolean[])__a)[__dx] = ((Boolean)__v).booleanValue();
				break;
				
			case ARRAY_BYTE:
				((byte[])__a)[__dx] = ((Byte)__v).byteValue();
				break;
				
			case ARRAY_SHORT:
				((short[])__a)[__dx] = ((Short)__v).shortValue();
				break;
				
			case ARRAY_CHARACTER:
				((char[])__a)[__dx] = ((Character)__v).charValue();
				break;
				
			case ARRAY_INTEGER:
				((int[])__a)[__dx] = ((Integer)__v).intValue();
				break;
				
			case ARRAY_LONG:
				((long[])__a)[__dx] = ((Long)__v).longValue();
				break;
				
			case ARRAY_FLOAT:
				((float[])__a)[__dx] = ((Float)__v).floatValue();
				break;
				
			case ARRAY_DOUBLE:
				((double[])__a)[__dx] = ((Double)__v).doubleValue();
				break;
				
			case ARRAY_OBJECT:
				((Object[])__a)[__dx] = __v;
				break;
			
				// {@squirreljme.error ZZ0c Invalid array type.}
			default:
				throw new IllegalArgumentException("ZZ0c");
		}
	}
	
	/**
	 * Returns the type of array the object is.
	 *
	 * @param __a The array type.
	 * @throws IllegalArgumentException If not an array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final int arrayType(Object __a)
		throws IllegalArgumentException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		if (__a instanceof Object[])
			return ARRAY_OBJECT;
		else if (__a instanceof boolean[])
			return ARRAY_BOOLEAN;
		else if (__a instanceof byte[])
			return ARRAY_BYTE;
		else if (__a instanceof short[])
			return ARRAY_SHORT;
		else if (__a instanceof char[])
			return ARRAY_CHARACTER;
		else if (__a instanceof int[])
			return ARRAY_INTEGER;
		else if (__a instanceof long[])
			return ARRAY_LONG;
		else if (__a instanceof float[])
			return ARRAY_FLOAT;
		else if (__a instanceof double[])
			return ARRAY_DOUBLE;
		
		// {@squirreljme.error ZZ0d Invalid array type.}
		throw new IllegalArgumentException("ZZ0d");
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @param __i Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h, int __i)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h, __i});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __a Length of dimension.
	 * @param __b Length of dimension.
	 * @param __c Length of dimension.
	 * @param __d Length of dimension.
	 * @param __e Length of dimension.
	 * @param __f Length of dimension.
	 * @param __g Length of dimension.
	 * @param __h Length of dimension.
	 * @param __i Length of dimension.
	 * @param __j Length of dimension.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g,
		int __h, int __i, int __j)
		throws NegativeArraySizeException, NullPointerException
	{
		return ArrayUtils.multiANewArray(__type, __skip,
			new int[]{__a, __b, __c, __d, __e, __f, __g, __h, __i, __j});
	}
	
	/**
	 * Allocates a new multi-dimensional array.
	 *
	 * @param __type The type with minimum dimension sizes specified.
	 * @param __skip The initial number of dimensions to skip in the initial
	 * array.
	 * @param __dims The dimensions and the number of them to use.
	 * @return The allocated multi-dimensional array.
	 * @throws NegativeArraySizeException If an allocated array would be
	 * of a negative size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/03
	 */
	public static final Object multiANewArray(Class<?> __type, int __skip,
		int[] __dims)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__type == null || __dims == null)
			throw new NullPointerException("NARG");
		
		// Count the number of dimensions represented in the type
		String typename = __type.getName();
		int typedims = 0;
		while (typename.charAt(typedims) == '[')
			typedims++;
		
		// {@squirreljme.error ZZ0e Negative number of dimensions available
		// or input type is not correct for the array type.}
		int dims = __dims.length - __skip;
		if (__skip < 0 || dims <= 0 || typedims < dims)
			throw new IllegalArgumentException("ZZ0e");
		
		// Allocate array of this type
		int numelem = __dims[__skip];
		Object rv = ObjectAccess.arrayNew(__type, numelem);
		
		// Need to determine the type for setting
		int type = ArrayUtils.arrayType(rv);
		
		// The array has more dimensions which must be set
		if (dims > 1)
		{
			// Remove a single brace from the class to cut down its dimensions
			// Class names use dot forms, so refer to classes using the class
			// handler.
			Class<?> subtype;
			try
			{
				subtype = Class.forName(typename.substring(1));
			}
			
			// {@squirreljme.error ZZ0f Could not find the sub-type for
			// multi-dimensional array.}
			catch (ClassNotFoundException e)
			{
				throw new Error("ZZ0f", e);
			}
			
			// Skipping ahead by one
			int nxskip = __skip + 1;
			
			// Allocate
			for (int i = 0; i < numelem; i++)
				ArrayUtils.arraySet(type, rv, i,
					ArrayUtils.multiANewArray(subtype, nxskip, __dims));
		}
		
		return (Object)rv;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/BasicStaticMethod.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * This represents a basic static method.
 *
 * @since 2019/04/19
 */
public final class BasicStaticMethod
	implements StaticMethod
{
	/** The method index this refers to. */
	private final int _index;
	
	/**
	 * Internally initialized.
	 *
	 * @param __dx The method index.
	 * @since 2019/04/19
	 */
	private BasicStaticMethod(int __dx)
	{
		this._index = __dx;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ClassData.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * This class contains information that is needed by the class object.
 *
 * The purpose is to allow newer versions of the SquirrelJME library to be
 * used on older virtual machines so they can benefit from an updated library
 * without breaking backwards compatiblity by missing things.
 *
 * @since 2018/12/04
 */
@Deprecated
public abstract class ClassData
{
	/** The version of the class data. */
	public final byte version;
	
	/**
	 * Initializes the base class data.
	 *
	 * @param __v The version.
	 * @since 2018/12/04
	 */
	public ClassData(int __v)
	{
		this.version = (byte)__v;
	}
	
	/**
	 * Returns the binary name.
	 *
	 * @return The binary name.
	 * @since 2018/12/04
	 */
	public abstract String binaryName();
	
	/**
	 * Returns the component of the array.
	 *
	 * @return The array component.
	 * @since 2018/12/04
	 */
	public abstract Class<?> component();
	
	/**
	 * Returns the flags for the default constructor.
	 *
	 * @return The default constructor flags.
	 * @since 2018/12/04
	 */
	public abstract int defaultConstructorFlags();
	
	/**
	 * Returns the method which is used for the default constructor.
	 *
	 * @return The static method for the default constructor.
	 * @since 2018/12/04
	 */
	public abstract StaticMethod defaultConstructorMethod();
	
	/**
	 * Returns the number of dimensions for the array.
	 *
	 * @return The dimension count.
	 * @since 2018/12/04
	 */
	public abstract int dimensions();
	
	/**
	 * Method which returns the enumeration values, if an enum.
	 *
	 * @return The enumeration values getter.
	 * @since 2018/12/08
	 */
	public abstract StaticMethod enumValues();
	
	/**
	 * Returns the class flags.
	 *
	 * @return The class flags.
	 * @since 2018/12/04
	 */
	public abstract int flags();
	
	/**
	 * Returns the JAR this class is in.
	 *
	 * @return The JAR this class is in.
	 * @since 2018/12/04
	 */
	public abstract String inJar();
	
	/**
	 * Returns the the interfaces this class implements.
	 *
	 * @return The interface classes.
	 * @since 2018/12/04
	 */
	public abstract Class<?>[] interfaceClasses();
	
	/**
	 * Returns the super class.
	 *
	 * @return The super class.
	 * @since 2018/12/04
	 */
	public abstract Class<?> superClass();
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ClassDataV1.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
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
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.StaticMethod;

/**
 * Version 1 class data.
 *
 * @since 2018/12/04
 */
@Deprecated
public class ClassDataV1
	extends ClassData
{
	/** The super class of this class. */
	private final Class<?> _superclass;
	
	/** The interface classes of this class. */
	private final Class<?>[] _interfaceclasses;
	
	/** The component type. */
	private final Class<?> _component;
	
	/** The binary name of this class. */
	private final String _binaryname;
	
	/** Special class reference index. */
	private final int _specialindex;
	
	/** The number of dimensions. */
	private final int _dimensions;
	
	/** The JAR this class is in. */
	private final String _injar;
	
	/** Class flags. */
	private final int _flags;
	
	/** Default constructor flags. */
	private final int _defaultconflags;
	
	/** Default constructor method. */
	private final StaticMethod _defaultconmethod;
	
	/** Enumeration values. */
	private final StaticMethod _enumvalues;
	
	/**
	 * Version 1 constructor.
	 *
	 * @param __csi Class special index.
	 * @param __bn The binary name of this class.
	 * @param __sc Super classes.
	 * @param __ic Interface classes.
	 * @param __ij The JAR this class is in.
	 * @param __flags Class flags.
	 * @param __dcf Default constructor flag.
	 * @param __dcm Default constructor method.
	 * @param __efm The method used to fill enumerations.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/04
	 */
	public ClassDataV1(int __csi, String __bn, Class<?> __sc, Class<?>[] __ic,
		Class<?> __ct, String __ij, int __flags, int __dcf, StaticMethod __dcm,
		StaticMethod __efm)
		throws NullPointerException
	{
		super(1);
		
		if (__bn == null)
			throw new NullPointerException("NARG");
		
		this._specialindex = __csi;
		this._binaryname = __bn;
		this._superclass = __sc;
		this._interfaceclasses = __ic;
		this._component = __ct;
		this._injar = __ij;
		this._flags = __flags;
		this._defaultconflags = __dcf;
		this._defaultconmethod = __dcm;
		this._enumvalues = __efm;
		
		// Count dimensions, used for comparison purposes
		int dims = 0;
		for (; __bn.charAt(dims) == '['; dims++)
			;
		this._dimensions = dims;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String binaryName()
	{
		return this._binaryname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?> component()
	{
		return this._component;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int defaultConstructorFlags()
	{
		return this._defaultconflags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public StaticMethod defaultConstructorMethod()
	{
		return this._defaultconmethod;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int dimensions()
	{
		return this._dimensions;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public StaticMethod enumValues()
	{
		return this._enumvalues;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public int flags()
	{
		return this._flags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String inJar()
	{
		return this._injar;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?>[] interfaceClasses()
	{
		return this._interfaceclasses;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public Class<?> superClass()
	{
		return this._superclass;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ClassFlag.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This represent class flags and their values.
 *
 * @since 2018/12/04
 */
public interface ClassFlag
{
	/** Public. */
	public static final int PUBLIC =
		0x0001;
	
	/** Final. */
	public static final int FINAL =
		0x0010;
	
	/** Super. */
	public static final int SUPER =
		0x0020;
	
	/** Interface. */
	public static final int INTERFACE =
		0x0200;
	
	/** Abstract. */
	public static final int ABSTRACT =
		0x0400;
	
	/** Synthetic. */
	public static final int SYNTHETIC =
		0x1000;
	
	/** Annotation. */
	public static final int ANNOTATION =
		0x2000;
	
	/** Enum. */
	public static final int ENUM =
		0x4000;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/GuestDepth.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

/**
 * This class returns the current guest depth.
 *
 * @since 2018/11/04
 */
public final class GuestDepth
{
	/** The calculated guest depth. */
	private static int _DEPTH =
		-1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private GuestDepth()
	{
	}
	
	/**
	 * The guest depth for the virtual machine.
	 *
	 * @return The guest depth for the virtual machine.
	 * @since 2018/11/04
	 */
	public static final int guestDepth()
	{
		// Pre-cached depth?
		int rv = GuestDepth._DEPTH;
		if (rv >= 0)
			return rv;
		
		// System property will indicate the number of guests in the VM
		try
		{
			String prop = System.getProperty("cc.squirreljme.guests");
			if (prop == null)
				rv = 0;
			else
				rv = Integer.parseInt(prop);
		}
		
		// Cannot get property so it cannot be known
		catch (SecurityException|NumberFormatException e)
		{
			rv = 0;
		} 
		
		// Cache it for later
		GuestDepth._DEPTH = rv;
		return rv;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/ImplementationClass.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.SystemProperties;

/**
 * This is used to return an appropriate class to use for the implemenation
 * of something. This is similar to {@link java.util.ServiceLoader} except
 * that it is specific to the virtual machine itself.
 *
 * @since 2018/12/13
 */
public final class ImplementationClass
{
	/**
	 * Not used.
	 *
	 * @since 2018/12/17
	 */
	private ImplementationClass()
	{
	}
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/13
	 */
	public static final String implementationClass(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Check to see if there is a system property for the implementation
		// to allow it to be replaced
		try
		{
			String rv = System.getProperty("cc.squirreljme.implclass." + __n);
			if (rv != null)
				return rv;
		}
		catch (SecurityException e)
		{
		}
		
		// Otherwise use whatever the VM says to use
		return SystemProperties.implementationClass(__n);
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/OperatingSystemType.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the type of operating system SquirrelJME is running on.
 *
 * This enumeration is intended to make OS detection standard.
 *
 * @since 2018/01/13
 */
public interface OperatingSystemType
{
	/** Unknown. */
	public static final int UNKNOWN =
		0;
	
	/** Amiga. */
	public static final int AMIGA =
		1;
	
	/** Linux. */
	public static final int LINUX =
		2;
	
	/** Class Mac OS. */
	public static final int MAC_OS_CLASSIC =
		3;
	
	/** Mac OS X. */
	public static final int MAC_OS_X =
		4;
	
	/** MS-DOS and compatibles. */
	public static final int MS_DOS =
		5;
	
	/** Palm OS. */
	public static final int PALM_OS =
		6;
		
	/** Solaris. */
	public static final int SOLARIS =
		7;
	
	/** Windows 16-bit. */
	public static final int WINDOWS_WIN16 =
		8;
	
	/** Windows CE. */
	public static final int WINDOWS_CE =
		9;
	
	/** Windows 9x. */
	public static final int WINDOWS_9X =
		10;
	
	/** Windows NT. */
	public static final int WINDOWS_NT =
		11;
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/UncaughtExceptionHandler.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import java.io.PrintStream;

/**
 * This method is called when there has been an uncaught exception being
 * handled.
 *
 * @since 2018/10/29
 */
public final class UncaughtExceptionHandler
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/29
	 */
	private UncaughtExceptionHandler()
	{
	}
	
	/**
	 * Performs some default handling for exceptions that were not caught
	 * anywhere.
	 *
	 * @param __t The throwable to handle.
	 * @since 2018/10/29
	 */
	public static final void handle(Throwable __t)
	{
		// Make a nice and big banner on it
		PrintStream out = System.err;
		out.println("****************************************************");
		out.print("UNCAUGHT EXCEPTION IN THREAD: ");
		out.println(Thread.currentThread());
		
		if (__t != null)
			__t.printStackTrace(out);
		
		out.println("****************************************************");
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/lang/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * General language support and such.
 *
 * @since 2018/10/29
 */

package cc.squirreljme.runtime.cldc.lang;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/package-info.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for the CLDC runtime and contains the
 * classes and their implementations which are required and needed for the
 * run-time to operate properly.
 *
 * For security purposes, all classes which extend the abstract interfaces to
 * provide an API should and must have package private constructors so that
 * they can be initialized properly.
 *
 * @since 2017/11/10
 */

package cc.squirreljme.runtime.cldc;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/ref/PrimitiveReference.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.ref;

/**
 * Represents an internal primitive reference.
 *
 * @since 2018/09/23
 */
public interface PrimitiveReference
{
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/ref/PrimitiveWeakReference.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.ref;

/**
 * This represents a primitive weak reference which should be garbage
 * collected when it does not point to anything.
 *
 * @since 2018/09/23
 */
public interface PrimitiveWeakReference
	extends PrimitiveReference
{
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/ref/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support classes for garbage collector references and
 * such.
 *
 * @since 2018/09/23
 */

package cc.squirreljme.runtime.cldc.ref;

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/ByteIntegerArray.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

/**
 * Wraps a byte array to provide integer access to it.
 *
 * @since 2019/05/09
 */
public final class ByteIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final byte[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public ByteIntegerArray(byte[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (byte)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/CharacterIntegerArray.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This wraps a character array and provides integer access to it.
 *
 * @since 2018/10/28
 */
public final class CharacterIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final char[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public CharacterIntegerArray(char[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (char)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/DoubleArrayList.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code double} array.
 *
 * @since 2020/01/01
 */
public class DoubleArrayList
	extends AbstractList<Double>
{
	/** The backing array. */
	protected final double[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public DoubleArrayList(double[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public DoubleArrayList(double[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Double get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public double set(int __i, double __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Double set(int __i, Double __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		double[] array = this.array;
		double rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/FDMLMath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405





















































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This class contains math methods which are derived from the Freely
 * Distributed Math Library, which is written in C which is then translated
 * into Java. The conversion process is copy and pasted from the origin sources
 * and adapted to Java.
 *
 * The library is located at http://www.netlib.org/fdlibm/ and was
 * developed at Sun Microsystems, Inc.
 *
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 * Developed at SunSoft, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice 
 * is preserved.
 *
 * @since 2018/11/02
 */
@ImplementationNote("This code is derived from the Freely " +
	"Distributable Math Library (http://www.netlib.org/fdlibm/). " +
	"Additionally this class is strictfp to keep math consistent.")
public final strictfp class FDMLMath
{
	/** The sign bit value. */
	private static final int _SIGN =
		0x80000000;
	
	/** The zero value. */
	private static final double _ZERO =
		0.0;
	
	/** The one value. */
	private static final double _ONE =
		1.0;
	
	/** The tiniest value. */
	private static final double _TINY =
		1.0e-300;

	/** Ln2 high. */
	private static final double _LN2_HI =
		0x1.62e42feep-1;
	
	/** Ln2 Low. */
	private static final double _LN2_LO =
		0x1.a39ef35793c76p-33;
	
	/** 2^54. */
	private static final double _TWO54 =
		0x1.0p54;
	
	/** log(1). */
	private static final double _LG1 =
		0x1.5555555555593p-1;
	
	/** log(2). */
	private static final double _LG2 =
		0x1.999999997fa04p-2;
	
	/** log(3). */
	private static final double _LG3 =
		0x1.2492494229359p-2;
	
	/** log(4). */
	private static final double _LG4 =
		0x1.c71c51d8e78afp-3;
	
	/** log(5). */
	private static final double _LG5 =
		0x1.7466496cb03dep-3;
	
	/** log(6). */
	private static final double _LG6 =
		0x1.39a09d078c69fp-3;
	
	/** log(7). */
	private static final double _LG7 =
		0x1.2f112df3e5244p-3;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/02
	 */
	private FDMLMath()
	{
	}

	/**
	 * Logarithm of a number.
	 *
	 * @param __v The input value.
	 * @return The resulting logarithm value.
	 * @since 2018/11/02
	 */
	@ImplementationNote("Source http://www.netlib.org/fdlibm/e_log.c")
	public static double log(double __v)
	{
		double hfsq, f, s, z, R, w, t1, t2, dk;
		int k, hx, i, j;
		int uulx;

		// high and low word of __v
		hx = __hi(__v);
		uulx = __lo(__v);

		k = 0;
		
		// x < 2**-1022
		if (hx < 0x00100000)
		{
			// log(+-0)=-inf
			if (((hx & 0x7FFFFFFF) | uulx) == 0) 
				return -_TWO54 / _ZERO;
			
			// log(-#) = NaN
			if (hx < 0)
				return (__v - __v) / _ZERO;
			
			// subnormal number, scale up __v
			k -= 54;
			__v *= _TWO54;
			
			// high word of __v
			hx = __hi(__v);
		} 
		
		if (hx >= 0x7FF00000)
			return __v + __v;
		
		k += (hx >> 20) - 1023;
		hx &= 0x000FFFFF;
		i = (hx + 0x95F64) & 0x100000;
		
		// normalize x or x/2
		// __HI(__v) = hx | (i^0x3FF00000);
		__v = __compose(hx | (i ^ 0x3FF00000), __lo(__v));
		k += (i >> 20);
		f = __v - 1.0;
		
		// |f| < 2**-20
		if ((0x000FFFFF & (2 + hx)) < 3)
		{
			if (f == _ZERO)
				if (k == 0)
					return _ZERO;
				else
				{
					dk = (double)k;
					return dk * _LN2_HI + dk * _LN2_LO;
				}
			
			R = f * f * (0.5 - 0.33333333333333333 * f);
			if (k == 0)
				return f - R;
			else
			{
				dk = (double)k;
				return dk * _LN2_HI - ((R - dk * _LN2_LO) - f);
			}
		}
		
		s = f / (2.0 + f); 
		dk = (double)k;
		z = s * s;
		i = hx - 0x6147A;
		w = z * z;
		j = 0x6B851 - hx;
		t1 = w * (_LG2 + w * (_LG4 + w * _LG6)); 
		t2 = z * (_LG1 + w * (_LG3 + w * (_LG5 + w * _LG7))); 
		i |= j;
		R = t2 + t1;
		
		if (i > 0)
		{
			hfsq = 0.5 * f * f;
			if (k == 0)
				return f - (hfsq - s * (hfsq + R));
			else
				return dk * _LN2_HI -
					((hfsq - (s * (hfsq + R) + dk * _LN2_LO)) - f);
		}
		else
		{
			if (k == 0)
				return f - s * (f - R);
			else
				return dk * _LN2_HI - (( s * (f - R) - dk * _LN2_LO) - f);
		}
	}

	/**
	 * Square root of a number.
	 *
	 * @param __v The input value.
	 * @return The resulting square root value.
	 * @since 2018/11/02
	 */
	@ImplementationNote("Source: http://www.netlib.org/fdlibm/e_sqrt.c")
	public static double sqrt(double __v)
	{
		double z;
		int uur, uut1, uus1, uuix1, uuq1;
		int ix0, s0, q, m, t, i;

		// high and low word of __v
		ix0 = __hi(__v);
		uuix1 = __lo(__v);

		// Take care of Inf and NaN
		if ((ix0 & 0x7FF00000) == 0x7FF00000)
		{
			// sqrt(NaN)=NaN, sqrt(+inf)=+inf
			// sqrt(-inf)=sNaN
			return __v * __v + __v;
		}
		
		// take care of zero
		if (ix0 <= 0)
		{
			// sqrt(+-0) = +-0
			if (((ix0 & (~_SIGN)) | uuix1) == 0)
				return __v;
			
			// sqrt(-ve) = sNaN
			else if (ix0 < 0)
				return (__v - __v) / (__v - __v);
		}
		
		// normalize
		m = (ix0 >> 20);
		
		// subnormal __v
		if (m == 0)
		{
			while (ix0 == 0)
			{
				m -= 21;
				ix0 |= (uuix1 >>> 11);
				uuix1 <<= 21;
			}
			
			for (i = 0; (ix0 & 0x00100000) == 0; i++)
				ix0 <<= 1;
			
			m -= i - 1;
			ix0 |= (uuix1 >>> (32 - i));
			uuix1 <<= i;
		}
		
		// unbias exponent
		m -= 1023;
		ix0 = (ix0 & 0x000FFFFF) | 0x00100000;
		
		// odd m, double __v to make it even
		if ((m & 1) != 0)
		{
			ix0 += ix0 + ((uuix1 & _SIGN) >>> 31);
			uuix1 += uuix1;
		}
		
		// m = [m/2]
		m >>= 1;

		// generate sqrt(__v) bit by bit
		ix0 += ix0 + ((uuix1 & _SIGN) >>> 31);
		uuix1 += uuix1;
		
		// [q,q1] = sqrt(__v)
		q = uuq1 = s0 = uus1 = 0;
		
		// r = moving bit from right to left
		uur = 0x00200000;
		while (uur != 0)
		{
			t = s0 + uur;
			if (t <= ix0)
			{
				s0 = t + uur;
				ix0 -= t;
				q += uur;
			}
			ix0 += ix0 + ((uuix1 & _SIGN) >>> 31);
			uuix1 += uuix1;
			uur >>>= 1;
		}

		uur = _SIGN;
		while (uur != 0)
		{
			uut1 = uus1 + uur;
			t = s0;
			
			if ((t < ix0) || ((t == ix0) &&
				UnsignedInteger.compareSignedUnsigned(uut1, uuix1) <= 0))
			{
				uus1 = uut1 + uur;
				
				if (((uut1 & _SIGN) == _SIGN) && (uus1 & _SIGN) == 0)
					s0 += 1;
				
				ix0 -= t;
				
				if (UnsignedInteger.compareUnsigned(uuix1, uut1) < 0)
					ix0 -= 1;
				
				uuix1 -= uut1;
				uuq1 += uur;
			}
			
			ix0 += ix0 + ((uuix1 & _SIGN) >>> 31);
			uuix1 += uuix1;
			uur >>>= 1;
		}

		// use floating add to find out rounding direction
		if ((ix0 | uuix1) != 0)
		{
			// trigger inexact flag
			z = _ONE - _TINY;
			
			if (z >= _ONE)
			{
				z = _ONE + _TINY;
				if (uuq1 == 0xFFFFFFFF)
				{
					uuq1 = 0;
					q += 1;
				}
				else if (z > _ONE)
				{
					if (uuq1 == 0xFFFFFFFE)
						q += 1;
					uuq1 += 2;
				}
				else
					uuq1 += (uuq1 & 1);
			}
		}
		
		ix0 = (q >> 1) + 0x3FE00000;
		uuix1 = uuq1 >>> 1;
		
		if ((q & 1) == 1)
			uuix1 |= _SIGN;
		
		ix0 += (m << 20);
		
		return __compose(ix0, uuix1);
	}
	
	/**
	 * Compose high and low value to double.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2018/11/03
	 */
	private static final double __compose(int __hi, int __lo)
	{
		return Double.longBitsToDouble(
			(((long)__hi & 0xFFFFFFFFL) << 32) |
			((long)__lo & 0xFFFFFFFFL));
	}

	/**
	 * Returns the high word of the double.
	 *
	 * @param __v The input double.
	 * @return The high word of the double.
	 * @since 2018/11/03
	 */
	private static final int __hi(double __v)
	{
		return (int)(Double.doubleToRawLongBits(__v) >>> 32);
	}

	/**
	 * Returns the low word of the double.
	 *
	 * @param __v The input double.
	 * @return The low word of the double.
	 * @since 2018/11/03
	 */
	private static final int __lo(double __v)
	{
		return (int)(Double.doubleToRawLongBits(__v));
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/FloatArrayList.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code float} array.
 *
 * @since 2020/01/01
 */
public class FloatArrayList
	extends AbstractList<Float>
{
	/** The backing array. */
	protected final float[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public FloatArrayList(float[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public FloatArrayList(float[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Float get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public float set(int __i, float __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Float set(int __i, Float __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		float[] array = this.array;
		float rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/IntegerArray.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This interface represents integer arrays.
 *
 * @since 2018/10/28
 */
public interface IntegerArray
{
	/**
	 * Gets the value at the given index.
	 *
	 * @param __i The index to get.
	 * @return The value at the given index.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2018/10/28
	 */
	public abstract int get(int __i);
	
	/**
	 * Sets the value at the given index.
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2018/10/28
	 */
	public abstract void set(int __i, int __v);
	
	/**
	 * Returns the size of the array.
	 *
	 * @return The array size.
	 * @since 2018/10/28
	 */
	public abstract int size();
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/IntegerArrays.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
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




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This class contains utilities used for {@link IntegerArray}.
 *
 * @since 2018/10/28
 */
public final class IntegerArrays
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/28
	 */
	private IntegerArrays()
	{
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(IntegerArray __a, int __from, int __to,
		int __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Empty array, will always be at the 0th index
		int len = __from - __to;
		if (len == 0)
			return -1;
		
		// Array has a single element, so only check that
		else if (len == 1)
		{
			int pv = __a.get(__from);
			
			// Is same
			if (pv == __key)
				return __from;
			
			// Value is either the 0th or 1st element
			if (pv < __key)
				return -1;
			else
				return -2;
		}
		
		// Use the same index
		__to -= 1;
		
		// Search for element at the pivot first, stop if the from and to are
		// at the same points
		while (__from <= __to)
		{
			// Calculate the pivot and use its value
			int p = __from + (((__to - __from) + 1) >> 1),
				pv = __a.get(p);
			
			// Left of pivot?
			if (__key < pv)
				__to = p - 1;
			
			// Right of pivot?
			else if (__key > pv)
				__from = p + 1;
			
			// Match
			else
				return p;
		}
		
		return (-__from) - 1;
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The source array.
	 * @param __to The destination array.
	 * @throws ArrayIndexOutOfBoundsException If the from and/or to index
	 * exceed the array bounds.
	 * @throws IllegalArgumentException If the from index is greater than to
	 * index.
	 * @throws NullPointerException If no array was specified.
	 * @since 2018/10/28
	 */
	public static void sort(IntegerArray __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Pointless sort?
		int n = __to - __from;
		if (n == 0 || n == 1)
			return;
		
		// If only two values are being sorted, it is a simple swap check
		if (n == 2)
		{
			int ia = __from,
				ib = __from + 1;
				
			// Get both values
			int a = __a.get(ia),
				b = __a.get(ib);
			
			// If the second is lower than the first, we need to swap
			if (b < a)
			{
				__a.set(ia, b);
				__a.set(ib, a);
			}
			
			// Nothing else needs to be done
			return;
		}
		
		// Work down from the highest gap to the lowest
		for (int gap : ShellSort._GAPS)
		{
			// Gapped insertion sort
			for (int i = gap; i < n; i++)
			{
				// Use this to make a hole
				int temp = __a.get(__from + i);
				
				// Shift earlier gap elements down
				int j;
				for (j = i; j >= gap &&
						__a.get(__from + (j - gap)) > temp; j -= gap)
					__a.set(__from + j, __a.get(__from + (j - gap)));
				
				// Put in the correct position
				__a.set(__from + j, temp);
			}
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/IntegerIntegerArray.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * Wraps an integer array for access.
 *
 * @since 2018/10/28
 */
public final class IntegerIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final int[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public IntegerIntegerArray(int[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/IteratorToEnumeration.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.runtime.cldc.util;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This adapts an iterator to an enumeration.
 *
 * @param <E> The element type.
 * @since 2019/05/05
 */
public final class IteratorToEnumeration<E>
	implements Enumeration<E>
{
	/** The iterator to access. */
	private final Iterator<E> _it;
	
	/**
	 * Initializes the iterator adapter.
	 *
	 * @param __it The iterator to adapt.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public IteratorToEnumeration(Iterator<E> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this._it = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasMoreElements()
	{
		return this._it.hasNext();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final E nextElement()
		throws NoSuchElementException
	{
		return this._it.next();
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/LongArrayList.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractList;

/**
 * Provides a list view of a {@code long} array.
 *
 * @since 2020/01/01
 */
public class LongArrayList
	extends AbstractList<Long>
{
	/** The backing array. */
	protected final long[] array;
	
	/** The offset. */
	protected final int offset;
	
	/** The cached size. */
	protected final int size;
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public LongArrayList(long[] __a)
		throws NullPointerException
	{
		this(__a, 0, __a.length);
	}
	
	/**
	 * Initializes the long array view.
	 *
	 * @param __a The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/01
	 */
	public LongArrayList(long[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.array = __a;
		this.offset = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Long get(int __i)
	{
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this.array[this.offset + __i];
	}
	
	/**
	 * Sets the value of the given index,
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2020/01/01
	 */
	public long set(int __i, long __v)
		throws IndexOutOfBoundsException
	{
		return this.set(__i, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public Long set(int __i, Long __v)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __i >= this.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// The true index to access
		int truedx = this.offset + __i;
		
		// Get old value
		long[] array = this.array;
		long rv = array[truedx];
		
		// Set new value
		array[truedx] = __v;
		
		// Return the old value
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/01
	 */
	@Override
	public int size()
	{
		return this.size;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/NaturalComparator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Comparator;

/**
 * This is used to compare two values using their natural comparison.
 *
 * @since 2016/09/06
 */
public final class NaturalComparator<V>
	implements Comparator<V>
{
	/** The single instance. */
	private static Reference<NaturalComparator> _REF;
	
	/**
	 * Only one is ever needed.
	 *
	 * @since 2017/11/30
	 */
	private NaturalComparator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public int compare(V __a, V __b)
	{
		// Consider two nulls to be equal
		boolean na = (__a == null), nb = (__b == null);
		if (na && nb)
			return 0;
		
		// Nulls before non-null
		else if (na && !nb)
			return -1;
		else if (!na && nb)
			return 1;
		
		// Use standard comparison
		return ((Comparable<V>)__a).compareTo(__b);
	}
	
	/**
	 * Returns the natural comparator instance.
	 *
	 * @param <V> The type of value to compare.
	 * @return The instance of the natural comparator.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public static final <V> NaturalComparator<V> instance()
	{
		Reference<NaturalComparator> ref = _REF;
		NaturalComparator rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			_REF = new WeakReference<>((rv = new NaturalComparator()));
		
		// Return it
		return (NaturalComparator<V>)rv;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/ShellSort.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
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







































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/**
 * Shell sorting algorithm.
 *
 * @since 2019/05/10
 */
public class ShellSort
{
	/** Gaps used in shell sort. */
	static final int[] _GAPS =
		new int[]{701, 301, 132, 57, 23, 10, 4, 1};
	
	/**
	 * Sorts the specified collection.
	 *
	 * @param __a The collection to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __comp The comparator to use.
	 * @throws IndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no collection was specified.
	 * @since 2019/05/09
	 */
	public static final <T> void sort(List<T> __a,
		int __from, int __to, Comparator<? super T> __comp)
		throws IndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.size();
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		if (__from > __to)
			throw new IllegalArgumentException("IOOB");
		
		// Use natural comparator?
		if (__comp == null)
			__comp = NaturalComparator.<T>instance();
		
		// Pointless sort?
		int n = __to - __from;
		if (n == 0 || n == 1)
			return;
		
		// If the list is not random access, then there will be a great
		// penalty sorting it and this may result in quadratic performance loss
		if (!(__a instanceof RandomAccess))
		{
			// Setup duplicate
			List<T> dup = new ArrayList<>(n);
			
			// Copy values using source iterator (less CPU intensive)
			ListIterator<T> it = __a.listIterator(__from);
			for (int o = 0; o < n; o++)
				dup.add(it.next());
			
			// Sort this array
			ShellSort.<T>sort(dup, 0, n, __comp);
			
			// Our iterator should still be good, so we can go backwords
			// setting all the values in it
			for (int i = n - 1; i >= 0; i--)
			{
				it.previous();
				it.set(dup.get(i));
			}
			
			// Stop
			return;
		}
		
		// If only two values are being sorted, it is a simple swap check
		if (n == 2)
		{
			int ia = __from,
				ib = __from + 1;
				
			// Get both values
			T a = __a.get(ia),
				b = __a.get(ib);
			
			// If the second is lower than the first, we need to swap
			if (__comp.compare(b, a) < 0)
			{
				__a.set(ia, b);
				__a.set(ib, a);
			}
			
			// Nothing else needs to be done
			return;
		}
		
		// Work down from the highest gap to the lowest
		for (int gap : ShellSort._GAPS)
		{
			// Gapped insertion sort
			for (int i = gap; i < n; i++)
			{
				// Use this to make a hole
				T temp = __a.get(__from + i);
				
				// Shift earlier gap elements down
				int j;
				for (j = i; j >= gap && __comp.compare(
					__a.get(__from + (j - gap)), temp) > 0; j -= gap)
					__a.set(__from + j, __a.get(__from + (j - gap)));
				
				// Put in the correct position
				__a.set(__from + j, temp);
			}
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/ShortIntegerArray.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

/**
 * Wraps a short array to provide integer access to it.
 *
 * @since 2019/05/09
 */
public final class ShortIntegerArray
	implements IntegerArray
{
	/** The backed array. */
	protected final short[] array;
	
	/**
	 * Initializes the array wrapper.
	 *
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public ShortIntegerArray(short[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.array = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int get(int __i)
	{
		return this.array[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void set(int __i, int __v)
	{
		this.array[__i] = (short)__v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final int size()
	{
		return this.array.length;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySet.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * This is an entry set which is synchronized against a lock.
 *
 * @param <K> The entry keys.
 * @param <V> The entry values.
 * @since 2019/05/05
 */
public final class SynchronizedEntrySet<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<Map.Entry<K, V>> set;
	
	/**
	 * Initializes the synchronized entry set.
	 *
	 * @param __lock The locking object.
	 * @param __set The entry set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySet(Object __lock, Set<Map.Entry<K, V>> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<Map.Entry<K, V>> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedEntrySetIterator<K, V>(
				lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetIterator.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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This is a synchronized iterator over entry set iterators.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public class SynchronizedEntrySetIterator<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<Map.Entry<K, V>> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetIterator(Object __lock,
		Iterator<Map.Entry<K, V>> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Map.Entry<K, V> next()
		throws NoSuchElementException
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedMapEntry<K, V>(lock, this.iterator.next());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetIteratorNotNull.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
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































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This is a synchronized iterator over entry set iterators, null values are
 * not permitted.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public class SynchronizedEntrySetIteratorNotNull<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<Map.Entry<K, V>> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetIteratorNotNull(Object __lock,
		Iterator<Map.Entry<K, V>> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Map.Entry<K, V> next()
		throws NoSuchElementException
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedMapEntryNotNull<K, V>(lock,
				this.iterator.next());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedEntrySetNotNull.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * This is an entry set which is synchronized against a lock, null values
 * are not allowed.
 *
 * @param <K> The entry keys.
 * @param <V> The entry values.
 * @since 2019/05/05
 */
public final class SynchronizedEntrySetNotNull<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<Map.Entry<K, V>> set;
	
	/**
	 * Initializes the synchronized entry set.
	 *
	 * @param __lock The locking object.
	 * @param __set The entry set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedEntrySetNotNull(Object __lock,
		Set<Map.Entry<K, V>> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<Map.Entry<K, V>> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedEntrySetIteratorNotNull<K, V>(
				lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedIterator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator which locks on an object before accesses are made.
 *
 * @param <V> The type of values to iterate over.
 * @since 2019/05/05
 */
public final class SynchronizedIterator<V>
	implements Iterator<V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing iterator. */
	protected final Iterator<V> iterator;
	
	/**
	 * Initializes the synchronized iterator.
	 *
	 * @param __lock The locking object.
	 * @param __it The iterator object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedIterator(Object __lock, Iterator<V> __it)
		throws NullPointerException
	{
		if (__lock == null || __it == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.iterator = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean hasNext()
	{
		synchronized (this.lock)
		{
			return this.iterator.hasNext();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V next()
		throws NoSuchElementException
	{
		synchronized (this.lock)
		{
			return this.iterator.next();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final void remove()
		throws IllegalStateException, UnsupportedOperationException
	{
		synchronized (this.lock)
		{
			this.iterator.remove();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedMapEntry.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.Map;

/**
 * This is a synchronized map entry.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public final class SynchronizedMapEntry<K, V>
	implements Map.Entry<K, V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing entry. */
	protected final Map.Entry<K, V> entry;
	
	/**
	 * Initializes the synchronized entry.
	 *
	 * @param __lock The locking object.
	 * @param __ent The entry object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedMapEntry(Object __lock, Map.Entry<K, V> __ent)
		throws NullPointerException
	{
		if (__lock == null || __ent == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.entry = __ent;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		synchronized (this.lock)
		{
			return this.entry.equals(__o);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final K getKey()
	{
		synchronized (this.lock)
		{
			return this.entry.getKey();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V getValue()
	{
		synchronized (this.lock)
		{
			return this.entry.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int hashCode()
	{
		synchronized (this.lock)
		{
			return this.entry.hashCode();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V setValue(V __v)
	{
		synchronized (this.lock)
		{
			return this.entry.setValue(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final String toString()
	{
		synchronized (this.lock)
		{
			return this.entry.toString();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedMapEntryNotNull.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
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



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.Map;

/**
 * This is a synchronized map entry, null values are not permitted.
 *
 * @param <K> The key.
 * @param <V> The value.
 * @since 2019/05/05
 */
public final class SynchronizedMapEntryNotNull<K, V>
	implements Map.Entry<K, V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing entry. */
	protected final Map.Entry<K, V> entry;
	
	/**
	 * Initializes the synchronized entry.
	 *
	 * @param __lock The locking object.
	 * @param __ent The entry object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedMapEntryNotNull(Object __lock, Map.Entry<K, V> __ent)
		throws NullPointerException
	{
		if (__lock == null || __ent == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.entry = __ent;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		synchronized (this.lock)
		{
			return this.entry.equals(__o);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final K getKey()
	{
		synchronized (this.lock)
		{
			return this.entry.getKey();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final V getValue()
	{
		synchronized (this.lock)
		{
			return this.entry.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int hashCode()
	{
		synchronized (this.lock)
		{
			return this.entry.hashCode();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If this value is null.
	 * @since 2019/05/05
	 */
	@Override
	public final V setValue(V __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this.lock)
		{
			return this.entry.setValue(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final String toString()
	{
		synchronized (this.lock)
		{
			return this.entry.toString();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/SynchronizedSet.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which is synchronized against a lock.
 *
 * @param <V> The set value.
 * @since 2019/05/05
 */
public final class SynchronizedSet<V>
	extends AbstractSet<V>
{
	/** The locking object. */
	protected final Object lock;
	
	/** The backing set. */
	protected final Set<V> set;
	
	/**
	 * Initializes the synchronized set.
	 *
	 * @param __lock The locking object.
	 * @param __set The set object.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/05
	 */
	public SynchronizedSet(Object __lock, Set<V> __set)
		throws NullPointerException
	{
		if (__lock == null || __set == null)
			throw new NullPointerException("NARG");
		
		this.lock = __lock;
		this.set = __set;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final Iterator<V> iterator()
	{
		Object lock = this.lock;
		synchronized (lock)
		{
			return new SynchronizedIterator<V>(lock, this.set.iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public final int size()
	{
		synchronized (this.lock)
		{
			return this.set.size();
		}
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/UnsignedInteger.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
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










































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.util;

/**
 * This class manages a boxed like representation of unsigned integers.
 *
 * @since 2018/11/03
 */
public final class UnsignedInteger
	extends Number
	implements Comparable<UnsignedInteger>
{
	/** The stored value. */
	protected final int value;
	
	/**
	 * Initializes the unsigned integer.
	 *
	 * @param __v The value to use.
	 * @since 2018/11/03
	 */
	public UnsignedInteger(int __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int compareTo(UnsignedInteger __i)
	{
		return UnsignedInteger.compareUnsigned(this.value, __i.value);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public final long longValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Compares two signed values.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareSigned(int __a, int __b)
	{
		if (__a == __b)
			return 0;
		else if (__a < __b)
			return -1;
		else
			return 1;
	}
	
	/**
	 * Compares a signed and unsigned value.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareSignedUnsigned(int __a, int __ub)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Compares two unsigned values.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @return The resulting comparison.
	 * @since 2018/11/03
	 */
	public static final int compareUnsigned(int __a, int __b)
	{
		// Quick shortcut if they are the same number
		if (__a == __b)
			return 0;
		
		// Check if there is a sign bit
		boolean na = ((__a & 0x8000_0000) != 0),
			nb = ((__b & 0x8000_0000) != 0);
		
		// Comparison is the same as signed integers if the sign is the same
		// 0x80000000 == -2147483648
		// 0xFFFFFFFF == -1
		if (na == nb)
			return UnsignedInteger.compareSigned(__a, __b);
		
		// Only A has sign bit, it is always greater
		else if (na && !nb)
			return 1;
		
		// Only B has sign bit, it is always lesser
		else
			return -1;
	}
}

Deleted runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/util/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Utilities which could be reused, primarily used by {@link java.util}.
 *
 * @since 2018/10/28
 */

package cc.squirreljme.runtime.cldc.util;

Deleted runt/apis/cldc-compact/java/io/BufferedReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428












































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;
import java.util.Arrays;

/**
 * This is a reader which is backed by a buffer which should increase the
 * efficiency of read operations by allowing for bulk reads for easily.
 *
 * It is recommended to wrap these around {@link InputStreamReader} for
 * example due to that class not being efficient due to character conversions.
 *
 * @since 2018/11/22
 */
@ImplementationNote("This implementation uses a simple flat buffer with a " +
	"length and size.")
public class BufferedReader
	extends Reader
{
	/** Default buffer size. */
	private static final int _DEFAULT_SIZE =
		128;
	
	/** The buffer to source from. */
	private final Reader _in;
	
	/** The buffer, this is a linear buffer, null for close(). */
	private char[] _buf;
	
	/** The buffer limit. */
	private int _limit;
	
	/** The read position of the buffer (which one to read next). */
	private int _rp;
	
	/** The write position of the buffer (the valid characters). */
	private int _wp;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __r The reader to source from.
	 * @param __bs The size of the internal buffer.
	 * @throws IllegalArgumentException If the buffer size is zero or
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public BufferedReader(Reader __r, int __bs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0g Cannot have a zero or negative buffer
		// size.}
		if (__bs <= 0)
			throw new IllegalArgumentException("ZZ0g");
		
		this._in = __r;
		this._buf = new char[__bs];
		this._limit = __bs;
	}
	
	/**
	 * Initializes the buffer using a default buffer size.
	 *
	 * @param __r The reader to source from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public BufferedReader(Reader __r)
		throws NullPointerException
	{
		this(__r, _DEFAULT_SIZE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void close()
		throws IOException
	{
		// The buffer not existing indicates this is closed
		char[] buf = this._buf;
		if (buf != null)
			this._buf = null;
		
		// Close the underlying stream
		this._in.close();
	}
	
	@Override
	@ProgrammerTip("If the mark length is greater than the length of the " +
	 "internal buffer, it will be re-allocated to fit. Care must be taken " +
	 "depending on how large of a buffer is needed to be stored.")
	public void mark(int __l)
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public boolean markSupported()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read()
		throws IOException
	{
		// Has this been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// There are no characters in the buffer? Fill it
		int rp = this._rp;
		if (rp == this._wp)
		{
			// Read up to the limit
			int rc = this._in.read(buf, 0, this._limit);
			
			// EOF reached
			if (rc < 0)
				return -1;
			
			// Set new properties
			rp = 0;
			this._wp = rc;
		}
		
		// Read and return the next character
		int rv = buf[rp++];
		this._rp = rp;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read(char[] __c)
		throws IOException, NullPointerException
	{
		return this.read(__c, 0, __c.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLOS");
		
		// Number of characters read
		int rv = 0;
		int rp = this._rp,
			wp = this._wp;
		
		// Drain what remains of the buffer
		int left = wp - rp;
		if (left > 0)
		{
			int lim = (left < __l ? left : __l);
			
			for (; rv < lim; rv++)
				__c[__o++] = buf[rp++];
			
			// Invalidate the buffer
			if (rp == wp)
			{
				this._rp = 0;
				this._wp = 0;
			}
		}
		
		// Nothing was in the buffer, so read directly from the source
		// stream
		Reader in = this._in;
		while (rv < __l)
		{
			int rc = in.read();
			
			// EOF
			if (rc < 0)
				return (rv == 0 ? -1 : rv);
			
			// Add character
			__c[__o++] = (char)rc;
			rv++;
		}
		
		// Return the read count
		return rv;
	}
	
	/**
	 * Reads a line from the input and returns it.
	 *
	 * @return The line which was read, or {@code null} on EOF.
	 * @throws IOException On read errors.
	 * @since 2018/11/22
	 */
	public String readLine()
		throws IOException
	{
		// Has this been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// Read/write positions
		int rp = this._rp,
			wp = this._wp;
		
		// The line is potentially what is left in the buffer perhaps
		// But do not make a super tiny string builder, make a guess as to
		// what the average line length is.
		int diff = wp - rp;
		StringBuilder sb = new StringBuilder((diff > 64 ? diff : 64));
		
		// Continually read data
		Reader in = this._in;
		boolean wasinbuf = false;
		for (;;)
		{
			// Was newline read? Did we stop on a CR?
			boolean readnl = false,
				stoppedoncr = false,
				readeof = false;
			
			// Scan
			int ln = rp;
			if (ln < wp)
			{
				// Was something in the buffer?
				wasinbuf = true;
				
				while (ln < wp)
				{
					// Stop on end of line characters
					char c = buf[ln];
					if ((stoppedoncr = (c == '\r')) || c == '\n')
					{
						readnl = true;
						break;
					}
					
					// Keep going
					ln++;
				}
				
				// Append all the characters in this buffer
				sb.append(buf, rp, ln - rp);
				
				// Discard everything which was appended
				this._rp = (rp = ln);
			}
			
			// Ran out of characters to use?
			if (rp == wp)
			{
				// Read in new characters to the buffer
				int rc = in.read(buf, 0, this._limit);
				
				// EOF was reached, if the buffer was empty then nothing was
				// read anyway
				if (rc < 0)
				{
					// True EOF
					if (!wasinbuf && sb.length() == 0)
						return null;
					
					readeof = true;
				}
				
				// Set new properties
				this._rp = (rp = ln = 0);
				this._wp = (wp = (rc > 0 ? rc : 0));
			}
			
			// Eat newline?
			if (readnl)
			{
				// We stopped on a CR, need to check if the following character
				// is a newline. However since the CRLF pair can end on a
				// buffer read barrier, it must be checked to make sure
				// there is absolutely no connection still.
				if (stoppedoncr)
				{
					// There are characters left in the buffer
					int gap = ln + 1;
					if (gap < wp)
					{
						// Is a newline, so skip it
						if (buf[gap] == '\n')
							rp = ln + 2;
						
						// Otherwise do not
						else
							rp = ln + 1;
					}
					
					// Need to actually read a character, to see what it
					// is
					else
					{
						int rx = in.read();
						
						// If the character is not a newline and is not EOF
						// we will just place it in the buffer as if it
						// were a fresh buffer
						if (rx >= 0 && rx != '\n')
						{
							// Store character state
							buf[wp++] = (char)rx;
							this._rp = rp;
							this._wp = wp;
							
							// Do not do any more of our loop stuff
							break;
						}
						
						// We will be skipping a character in the buffer
						// anyway so ln == wp, so always just skip one
						rp = ln + 1;
					}
				}
				
				// Skip single character
				else
					rp = ln + 1;
				
				// Store the new read position
				this._rp = rp;
				
				// Stop
				break;
			}
			
			// Nothing else to do on EOF
			if (readeof)
				break;
		}
		
		// Use this line
		return sb.toString();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public boolean ready()
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLSD");
		
		// There are characters in the buffer or the stream itself is
		// ready
		return (this._rp < this._wp) || this._in.ready();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void reset()
		throws IOException
	{
		// Has been closed?
		char[] buf = this._buf;
		if (buf == null)
			throw new IOException("CLOS");
		
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/io/BufferedWriter.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This class buffers characters into an internal buffer so that they can be
 * written in bulk to the underlying stream. This increases performance and
 * is a more optimal operation because it writes multiple characters at once
 * instead of writing them one at a time.
 *
 * The default buffer size in SquirrelJME is very small due to potential memory
 * limitations.
 *
 * @since 2018/09/18
 */
@ImplementationNote("The buffer size is undefined in the class library, " +
	"therefor due to potential memory limitations the buffer size should " +
	"be kept small.")
public class BufferedWriter
	extends Writer
{
	/**
	 * This buffer size is kept small by default since having a large buffer
	 * for a memory contrained system is not really that important and will
	 * pretty much only be used by console output. So as such to prevent
	 * wasting memory with streams that will not likely be used for most
	 * programs (MIDlets) or they will be outputting characters anyway.
	 *
	 * It should be noted that Java SE uses a buffer size of 8KiB.
	 */
	private static final int _DEFAULT_BUFFER_SIZE =
		128;
	
	/** The writer to buffer at. */
	private final Writer _out;
	
	/**
	 * Initializes the buffered writer to the target writer using the default
	 * buffer size.
	 *
	 * @param __out The writer to buffer to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public BufferedWriter(Writer __out)
		throws NullPointerException
	{
		this(__out, BufferedWriter._DEFAULT_BUFFER_SIZE);
	}
	
	/**
	 * Initializes the buffered writer to the target writer using the given
	 * buffer size.
	 *
	 * @param __out The writer to buffer to.
	 * @param __bs The number of characters to store in the buffer before
	 * flushing.
	 * @throws IllegalArgumentException If the buffer size is less than or
	 * equal to zero.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public BufferedWriter(Writer __out, int __bs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0h Requested a buffer size that is zero or
		// negative. (The requested buffer size)}
		if (__bs <= 0)
			throw new IllegalArgumentException(String.format("ZZ0h %d", __bs));
		
		throw new todo.TODO();
	}
	
	/**
	 * Closes the stream, it is flushed first.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/09/18
	 */
	@Override
	public void close()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void flush()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Writes the value of {@code System.getProperty("line.separator")} to the
	 * stream.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/09/18
	 */
	public void newLine()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * This normally stores characters into the internal buffer, however if
	 * the length of the output is at least the size of the buffer then it
	 * will flush the buffer then write all the input characters.
	 *
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(char[] __b, int __o, int __l)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/18
	 */
	@Override
	public void write(String __s, int __o, int __l)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/io/ByteArrayInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is a class which reads from an input byte array and returns its data.
 *
 * @since 2018/11/11
 */
public class ByteArrayInputStream
	extends InputStream
{
	/** The buffer to read from. */
	protected byte[] buf;
	
	/** The number of bytes to read. */
	protected int count;
	
	/** The current mark. */
	protected int mark;
	
	/** The position within the byte array. */
	protected int pos;
	
	/**
	 * Wraps the specified byte array.
	 *
	 * @param __b The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ByteArrayInputStream(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length);
	}
	
	/**
	 * Wraps the specified byte array.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ByteArrayInputStream(byte[] __b, int __o, int __l)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		this.buf = __b;
		this.pos = __o;
		this.mark = __o;
		this.count = Math.min(__o + __l, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int available()
	{
		synchronized (this)
		{
			return Math.max(0, this.count - Math.max(0, this.pos));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void close()
		throws IOException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void mark(int __p)
	{
		synchronized (this)
		{
			this.mark = this.pos;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public boolean markSupported()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read()
	{
		synchronized (this)
		{
			int pos = this.pos,
				count = this.count;
			
			// EOF?
			if (pos >= count)
				return -1;
			
			// Read single byte
			int rv = this.buf[pos] & 0xFF;
			this.pos = pos + 1;
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public int read(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Only read this many bytes
		int len = __b.length;
		
		synchronized (this)
		{
			// Determine how many bytes we can read
			byte[] buf = this.buf;
			int pos = this.pos,
				count = this.count,
				read = count - pos;
			
			// Do not exceed this
			if (len < read)
				read = len;
			
			// Copy bytes
			for (int i = 0; i < len; i++)
				__b[i] = buf[pos++];
			
			// Store new position
			this.pos = pos;
			
			if (read == 0)
				return (pos >= count ? -1 : 0);
			return read;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			// Determine how many bytes we can read
			byte[] buf = this.buf;
			int pos = this.pos,
				count = this.count,
				read = count - pos;
			
			// Do not exceed this
			if (__l < read)
				read = __l;
			
			// Copy bytes
			for (int i = 0; i < read; i++)
				__b[__o++] = buf[pos++];
			
			// Store new position
			this.pos = pos;
			
			if (read == 0)
				return (pos >= count ? -1 : 0);
			return read;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public void reset()
	{
		synchronized (this)
		{
			this.pos = this.mark;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public long skip(long __n)
	{
		// Doing nothing?
		if (__n <= 0)
			return 0;
		
		synchronized (this)
		{
			int pos = this.pos,
				count = this.count,
				read = count - pos,
				newpos;
			
			// Reading less bytes than what is available
			if (__n < read)
				this.pos = (newpos = (int)(pos + __n));
			
			// No more bytes to read
			else
				this.pos = (newpos = count);
			
			return newpos - pos;
		}
	}
}

Deleted runt/apis/cldc-compact/java/io/ByteArrayOutputStream.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
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
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import java.util.Arrays;

/**
 * This an output stream which outputs any written bytes to a byte array.
 *
 * @since 2018/11/06
 */
public class ByteArrayOutputStream
	extends OutputStream
{
	/** The initial capacity. */
	private static final int _CAPACITY =
		32;
	
	/** The bytes in the buffer. */
	protected byte[] buf;
	
	/** The number of valid bytes in the buffer. */
	protected int count;
	
	/**
	 * Initializes the output stream using the default capacity of 32 bytes.
	 *
	 * @since 2018/11/06
	 */
	public ByteArrayOutputStream()
	{
		this(_CAPACITY);
	}
	
	/**
	 * Initializes the output stream using the given capacity.
	 *
	 * @param __cap The capacity to use.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/06
	 */
	public ByteArrayOutputStream(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ0i Cannot initialize output stream using a
		// negative capacity.}
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ0i");
		
		this.buf = new byte[__cap];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void close()
		throws IOException
	{
	}
	
	/**
	 * Resets the count back to zero while keeping the buffer, allowing it
	 * to be reused.
	 *
	 * @since 2018/11/06
	 */
	public void reset()
	{
		synchronized (this)
		{
			this.count = 0;
		}
	}
	
	/**
	 * Returns the number of bytes that are valid in the internal buffer.
	 *
	 * @return The number of bytes that are valid in the internal buffer.
	 * @since 2018/11/06
	 */
	public int size()
	{
		synchronized (this)
		{
			return this.count;
		}
	}
	
	/**
	 * Returns a newly allocated copy of the byte array.
	 *
	 * @return A copy of the byte array.
	 * @since 2018/11/06
	 */
	public byte[] toByteArray()
	{
		synchronized (this)
		{
			return Arrays.copyOf(this.buf, this.count);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public String toString()
	{
		synchronized (this)
		{
			return new String(this.buf, 0, this.count);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void write(int __b)
	{
		byte[] buf = this.buf;
		int count = this.count;
		
		synchronized (this)
		{
			// Not enough room? Increase buffer size
			if (count == buf.length)
				this.buf = (buf = Arrays.copyOf(buf, count + _CAPACITY));
			
			// Write byte at end position
			buf[count] = (byte)__b;
			this.count = count + 1;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/06
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		int bufn = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bufn)
			throw new IndexOutOfBoundsException("IOOB");
		
		byte[] buf = this.buf;
		int count = this.count;
		
		synchronized (this)
		{
			// Reallocate buffer if it cannot be store data
			int endcount = count + __l;
			if (endcount > buf.length)
				this.buf = (buf = Arrays.copyOf(buf, endcount + _CAPACITY));
			
			// Write bytes
			for (int i = 0; i < __l; i++)
				buf[count++] = __b[__o++];
			
			this.count = endcount;
		}
	}
	
	/**
	 * Writes the internal buffer to the given output stream.
	 *
	 * @param __os The output stream to write to.
	 * @throws IOException On write.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			__os.write(this.buf, 0, this.count);
		}
	}
}

Deleted runt/apis/cldc-compact/java/io/Closeable.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is attached to a resource which may be closed when it is no longer
 * required.
 *
 * Note that despite being similar to {@link AutoCloseable} there is a subtle
 * difference in that this class must never throw an {@link IOException} if the
 * resource is already closed and must have no effect.
 *
 * @since 2016/04/12
 */
public interface Closeable
	extends AutoCloseable
{
	/**
	 * Attempts to close the resource which may free other resources.
	 *
	 * Unlike {@link AutoCloseable}, if the resource is already closed then
	 * this method should have no effect and not throw a {@link IOException}.
	 *
	 * If it is possible, it is recommended to mark a resource as closed after
	 * freeing the resources before throwing an {@link IOException}. However,
	 * this case should only be considered if this is a top level resource
	 * which relies on no other {@link Closeable} resources.
	 *
	 * @throws IOException If there was an error closing this resource.
	 * @since 2016/04/12
	 */
	@Override
	public abstract void close()
		throws IOException;
}

Deleted runt/apis/cldc-compact/java/io/DataInput.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

public interface DataInput
{
	public abstract boolean readBoolean()
		throws IOException;
	
	public abstract byte readByte()
		throws IOException;
	
	public abstract char readChar()
		throws IOException;
	
	public abstract double readDouble()
		throws IOException;
	
	public abstract float readFloat()
		throws IOException;
	
	public abstract void readFully(byte[] __a)
		throws IOException;
	
	public abstract void readFully(byte[] __a, int __b, int __c)
		throws IOException;
	
	public abstract int readInt()
		throws IOException;
	
	public abstract long readLong()
		throws IOException;
	
	public abstract short readShort()
		throws IOException;
	
	public abstract String readUTF()
		throws IOException;
	
	public abstract int readUnsignedByte()
		throws IOException;
	
	public abstract int readUnsignedShort()
		throws IOException;
	
	public abstract int skipBytes(int __a)
		throws IOException;
}

Deleted runt/apis/cldc-compact/java/io/DataInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This class provides the ability to read binary data from a stream.
 *
 * All data which is read, is stored as big endian.
 *
 * @since 2018/12/01
 */
public class DataInputStream
	extends InputStream
	implements DataInput
{
	/** The wrapped stream. */
	protected final InputStream in;	
	
	/**
	 * Wraps the specified stream.
	 *
	 * @param __in The stream to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public DataInputStream(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException();
		
		// Set
		in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public void mark(int __rl)
	{
		this.in.mark(__rl);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public boolean markSupported()
	{
		return this.in.markSupported();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.in.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.in.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		return this.in.read(__b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final boolean readBoolean()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return (rv != 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final byte readByte()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return (byte)rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final char readChar()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (char)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	@Override
	public final double readDouble()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read(),
			e = in.read(),
			f = in.read(),
			g = in.read(),
			h = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d | e | f | g | h) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return Double.longBitsToDouble((((long)(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF))) << 32L) |
			(((long)((((e & 0xFF) << 24) |
			((f & 0xFF) << 16) |
			((g & 0xFF) << 8) |
			(h & 0xFF)))) & 0xFFFFFFFFL));
	}
	
	@Override
	public final float readFloat()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return Float.intBitsToFloat(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 3018/12/01
	 */
	@Override
	public final void readFully(byte[] __b)
		throws EOFException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		int rv = 0,
			bl = __b.length;
		
		// Constantly read in as many chunks as possible
		InputStream in = this.in;
		while (rv < bl)
		{
			// Read entire chunk
			int rc = in.read(__b, rv, bl - rv);
			
			// Reached EOF
			if (rc < 0)
				throw new EOFException("EOFF");
			
			// These many characters were read, we might try again
			rv += rc;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void readFully(byte[] __b, int __o, int __l)
		throws EOFException, IOException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		int rv = 0;
		
		// Constantly read in as many chunks as possible
		InputStream in = this.in;
		while (rv < __l)
		{
			// Read entire chunk
			int rc = in.read(__b, __o + rv, __l - rv);
			
			// Reached EOF
			if (rc < 0)
				throw new EOFException("EOFF");
			
			// These many characters were read, we might try again
			rv += rc;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readInt()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return ((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public final long readLong()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read(),
			c = in.read(),
			d = in.read(),
			e = in.read(),
			f = in.read(),
			g = in.read(),
			h = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b | c | d | e | f | g | h) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return ((((long)(((a & 0xFF) << 24) |
			((b & 0xFF) << 16) |
			((c & 0xFF) << 8) |
			(d & 0xFF))) << 32L) |
			(((long)(((e & 0xFF) << 24) |
			((f & 0xFF) << 16) |
			((g & 0xFF) << 8) |
			(h & 0xFF))) & 0xFFFFFFFFL));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final short readShort()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (short)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readUnsignedByte()
		throws EOFException, IOException
	{
		int rv = this.in.read();
		
		if (rv < 0)
			throw new EOFException("EOFF");
		
		return rv & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final int readUnsignedShort()
		throws EOFException, IOException
	{
		InputStream in = this.in;
		
		// Read all values
		int a = in.read(),
			b = in.read();
		
		// If any were negative then all will be with OR
		if ((a | b) < 0)
			throw new EOFException("EOFF");
		
		// Remap values
		return (int)(((a & 0xFF) << 8) |
			(b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final String readUTF()
		throws EOFException, IOException, UTFDataFormatException
	{
		return DataInputStream.readUTF(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public void reset()
		throws IOException
	{
		this.in.reset();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public long skip(long __n)
		throws IOException
	{
		if (__n < 0)
			return 0;
		
		return this.in.skip(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int skipBytes(int __n)
		throws IOException
	{
		// Try to read as many bytes as possible
		InputStream in = this.in;
		for (int i = 0; i < __n; i++)
			if (in.read() < 0)
				return i;
		
		// Read all the bytes
		return __n;
	}
	
	/**
	 * Reads a modified-UTF sequence from the input.
	 *
	 * @param __in The input.
	 * @return The decoded string.
	 * @throws EOFException On end of file.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @throws UTFDataFormatException If the input UTF data is not correct.
	 * @since 2018/12/03
	 */
	public static final String readUTF(DataInput __in)
		throws EOFException, IOException, NullPointerException,
			UTFDataFormatException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read length and setup buffer
		int len = __in.readUnsignedShort();
		char[] buf = new char[len];
		
		// Instead of calling read multiple times to get multiple bytes we
		// can just do a full read of the entire length. If the queue only
		// contains single byte characters then we end up in the fast route
		// otherwise once the queue is finished, we will start reading from
		// the stream
		byte[] queue = new byte[len];
		int queueat = 0;
		if (len > 0)
			__in.readFully(queue);
		
		// Read all encoded character data, if EOF ever happens it will be
		// generated for us
		for (int i = 0; i < len; i++)
		{
			// Read character
			int a = (queueat < len ? (queue[queueat++] & 0xFF) :
				__in.readUnsignedByte());
			
			// Single byte
			if ((a & 0b1000_0000) == 0b0000_0000)
			{
				// {@squirreljme.error ZZ0j The zero byte cannot be represented
				// with a zero value.}
				if (a == 0)
					throw new UTFDataFormatException("ZZ0j");
				
				buf[i] = (char)a;
			}
			
			// Double byte
			else if ((a & 0b1110_0000) == 0b1100_0000)
			{
				int b = (queueat < len ? (queue[queueat++] & 0xFF) :
					__in.readUnsignedByte());
				
				// {@squirreljme.error ZZ0k Invalid double byte character.
				// (The byte sequence)}
				if ((b & 0b1100_0000) != 0b1000_0000)
					throw new UTFDataFormatException(String.format(
						"ZZ0k %02x%02x", a, b));
				
				// Decode
				buf[i] = (char)(((a & 0x1F) << 6) | (b & 0x3F));
			}
			
			// Triple byte
			else if ((a & 0b1111_0000) == 0b1110_0000)
			{
				// Can we quickly read at least one byte from the stream?
				int b, c;
				if (queueat < len)
				{
					b = queue[queueat++] & 0xFF;
					c = (queueat < len ? (queue[queueat++] & 0xFF) :
						__in.readUnsignedByte());
				}
				
				// Nothing
				else
				{
					b = __in.readUnsignedByte();
					c = __in.readUnsignedByte();
				}
				
				// {@squirreljme.error ZZ0l Invalid double byte character.
				// (The byte sequence)}
				if (((b & 0b1100_0000) != 0b1000_0000) ||
					((c & 0b1100_0000) != 0b1000_0000))
					throw new UTFDataFormatException(String.format(
						"ZZ0l %02x%02x%02x", a, b, c));
				
				// Decode
				buf[i] = (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) |
					(c & 0x3F));
			}
			
			// {@squirreljme.error ZZ0m Invalid byte sequence. (The byte)}
			else
				throw new UTFDataFormatException(String.format("ZZ0m %02x",
					a));
		}
		
		// Convert to string
		return new String(buf);
	}
}

Deleted runt/apis/cldc-compact/java/io/DataOutput.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

public interface DataOutput
{
	public abstract void write(int __b)
		throws IOException;
	
	public abstract void write(byte[] __b)
		throws IOException, NullPointerException;
	
	public abstract void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException;
	
	public abstract void writeBoolean(boolean __v)
		throws IOException;
	
	public abstract void writeByte(int __v)
		throws IOException;
	
	public abstract void writeBytes(String __v)
		throws IOException, NullPointerException;
	
	public abstract void writeChar(int __v)
		throws IOException;
	
	public abstract void writeChars(String __v)
		throws IOException, NullPointerException;
	
	public abstract void writeDouble(double __v)
		throws IOException;
	
	public abstract void writeFloat(float __v)
		throws IOException;
	
	public abstract void writeInt(int __v)
		throws IOException;
	
	public abstract void writeLong(long __v)
		throws IOException;
	
	public abstract void writeShort(int __v)
		throws IOException;
	
	public abstract void writeUTF(String __v)
		throws IOException;
}

Deleted runt/apis/cldc-compact/java/io/DataOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357





































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This stream is capable of writing binary data to an output stream.
 *
 * @since 2018/11/18
 */
public class DataOutputStream
	extends OutputStream
	implements DataOutput
{
	/** The underlying stream to write to. */
	protected OutputStream out;
	
	/** The number of bytes written. */
	protected int written;
	
	/**
	 * Initializes the stream to write to the given destination.
	 *
	 * @param __o The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public DataOutputStream(OutputStream __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		this.out = __o;
	}
	
	@Override
	public void close()
		throws IOException
	{
		this.out.close();
	}
	
	@Override
	public void flush()
		throws IOException
	{
		this.out.flush();
	}
	
	/**
	 * Returns the current number of bytes which were written.
	 *
	 * @return The number of bytes which were written.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this.written;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(byte[] __b)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		synchronized (this)
		{
			this.out.write(__b, __o, __l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeBoolean(boolean __v)
		throws IOException
	{
		this.out.write((__v ? 1 : 0));
		this.written += 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeByte(int __v)
		throws IOException
	{
		this.out.write(__v);
		this.written += 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeBytes(String __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeChar(int __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeChars(String __v)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeDouble(double __v)
		throws IOException
	{
		long v = Double.doubleToRawLongBits(__v);
		
		OutputStream out = this.out;
		out.write((int)(v >> 56));
		out.write((int)(v >> 48));
		out.write((int)(v >> 40));
		out.write((int)(v >> 32));
		out.write((int)(v >> 24));
		out.write((int)(v >> 16));
		out.write((int)(v >> 8));
		out.write((int)(v));
		this.written += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeFloat(float __v)
		throws IOException
	{
		int v = Float.floatToRawIntBits(__v);
		
		OutputStream out = this.out;
		out.write(v >> 24);
		out.write(v >> 16);
		out.write(v >> 8);
		out.write(v);
		this.written += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeInt(int __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write(__v >> 24);
		out.write(__v >> 16);
		out.write(__v >> 8);
		out.write(__v);
		this.written += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeLong(long __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write((int)(__v >> 56));
		out.write((int)(__v >> 48));
		out.write((int)(__v >> 40));
		out.write((int)(__v >> 32));
		out.write((int)(__v >> 24));
		out.write((int)(__v >> 16));
		out.write((int)(__v >> 8));
		out.write((int)(__v));
		this.written += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeShort(int __v)
		throws IOException
	{
		OutputStream out = this.out;
		out.write(__v >> 8);
		out.write(__v);
		this.written += 2;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	public final void writeUTF(String __v)
		throws IOException, NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		OutputStream out = this.out;
		
		// Write length of string
		int n = __v.length();
		out.write(n >> 8);
		out.write(n);
		
		// Load string into character array to more quickly access it
		char[] chars = __v.toCharArray();
		
		// Write string contents in modified UTF-8
		int written = 2;
		for (int i = 0; i < n; i++)
		{
			char c = chars[i];
			
			// Single byte
			if (c >= 0x0001 && c <= 0x007F)
			{
				// As a sort of turbo mode, scan the string to see how many
				// single characters we can write all at once instead of
				// writing call so many times. Since most of the time these
				// single characters will be ones which are read
				int end = i + 1;
				for (; end < n; end++)
				{
					char d = chars[end];
					if (d == 0 || c > 0x007F)
						break;
				}
				
				// Just a single byte
				if (end == i)
				{
					out.write((byte)c);
					
					written += 1;
				}
				
				// Multiple bytes were so, convert and write in bulk
				else
				{
					int xl = end - i;
					
					// Convert to bytes
					byte[] chunk = new byte[xl];
					for (int o = 0; o < xl; o++, i++)
						chunk[o] = (byte)chars[i];
					
					// Write all at once
					out.write(chunk, 0, xl);
					
					written += xl;
				}
			}
			
			// Double byte
			// as: (char)(((a & 0x1F) << 6) | (b & 0x3F))
			else if (c == 0 || (c >= 0x0080 && c <= 0x07FF))
			{
				out.write(0b110_00000 | ((c >>> 6) & 0x1F));
				out.write(0b10_000000 | (c & 0x3F));
				
				written += 2;
			}
			
			// Triple byte
			// as: (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
			else
			{
				out.write(0b1110_0000 | ((c >>> 12) & 0x0F));
				out.write(0b10_000000 | ((c >>> 6) & 0x3F));
				out.write(0b10_000000 | (c & 0x3F));
				
				written += 3;
			}
		}
		
		// Record it
		this.written += written;
	}
}

Deleted runt/apis/cldc-compact/java/io/EOFException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This thrown when the end of file has been reached.
 *
 * @since 2018/12/08
 */
public class EOFException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public EOFException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public EOFException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/io/IOException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is thrown when there is a general input and/or output exception.
 *
 * @since 2018/12/08
 */
public class IOException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public IOException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public IOException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/08
	 */
	public IOException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/08
	 */
	public IOException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/io/InputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

/**
 * This is the base class for any input stream which is used for reading a
 * stream of bytes.
 *
 * @since 2019/01/20
 */
public abstract class InputStream
	implements Closeable
{
	/** The number of bytes to skip at a time. */
	private static final int _SKIP_LEN =
		256;
	
	/**
	 * Initializes the base input stream.
	 *
	 * @since 2018/10/13
	 */
	public InputStream()
	{
	}
	
	/**
	 * Reads a single byte from the input stream.
	 *
	 * @return The read unsigned byte value ({@code 0-255}) or {@code -1} if
	 * the end of stream has been reached.
	 * @throws IOException On read errors.
	 * @since 2018/11/06
	 */
	public abstract int read()
		throws IOException;
	
	/**
	 * Returns the number of bytes which can be read from the stream without
	 * blocking.
	 *
	 * @return The number of bytes which can be read.
	 * @throws IOException On read errors.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation always returns 0.")
	public int available()
		throws IOException
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public void close()
		throws IOException
	{
	}
	
	/**
	 * Marks the stream so that a future {@link #reset()} returns to the point
	 * that was marked, if it is still within the bounds of the read limit.
	 *
	 * After the limit has been reached, the mark may become invalidated.
	 *
	 * @param __l The number of bytes to store for later resets before the
	 * mark becomes invalid.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation does nothing.")
	public void mark(int __l)
	{
	}
	
	/**
	 * Returns whether or not marking is supported on the input stream.
	 *
	 * @return If marking is supported.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation always returns false.")
	public boolean markSupported()
	{
		return false;
	}
	
	/**
	 * Reads multiple bytes and stores them into the array.
	 *
	 * @param __b The destination array.
	 * @return The number of bytes read or {@code -1} if the end of stream has
	 * been reached.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// No bytes to read?
		int n = __b.length;
		if (n <= 0)
			return 0;
		
		// Read bytes into the array
		for (int i = 0, o = 0; i < n; i++)
		{
			int rv = this.read();
			
			// EOF?
			if (rv < 0)
				return (i == 0 ? -1 : i);
			
			__b[o++] = (byte)rv;
		}
		
		// Read all bytes
		return n;
	}
	
	/**
	 * Reads multiple bytes and stores them into the array.
	 *
	 * @param __b The destination array.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read or {@code -1} if the end of stream has
	 * been reached.
	 * @throws IndexOutOfBoundsException If the offset and/or length 
	 * negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// No bytes to read?
		if (__l <= 0)
			return 0;
		
		// Read bytes into the array
		for (int i = 0; i < __l; i++)
		{
			int rv = this.read();
			
			// EOF?
			if (rv < 0)
				return (i == 0 ? -1 : i);
			
			__b[__o++] = (byte)rv;
		}
		
		// Read all bytes
		return __l;
	}
	
	/**
	 * Resets the stream to a previously marked position.
	 *
	 * @throws IOException If marking is not supported or the mark has been
	 * invalidated by reading more than the limit bytes.
	 * @since 2019/01/20
	 */
	public void reset()
		throws IOException
	{
		// {@squirreljme.error ZZ0n Reset is not supported.}
		throw new IOException("ZZ0n");
	}
	
	/**
	 * Attemps to skip over the given number of bytes.
	 *
	 * It is not required for the actual number of bytes skipped to match the
	 * input amount, this could be specific to the input stream implementation
	 * or the end of file has been reached.
	 *
	 * @param __n The number of bytes to skip, if this value is negative then
	 * no bytes are skipped.
	 * @return The number of skipped bytes.
	 * @throws IOException On read errors.
	 * @since 2019/01/20
	 */
	@ProgrammerTip("The base implementation allocates an array and reads " +
		"into that array until all bytes have been skipped.")
	public long skip(long __n)
		throws IOException
	{
		// Not doing anything
		if (__n <= 0)
			return 0;
		
		// Keep reading bytes
		byte[] buf = new byte[_SKIP_LEN];
		long actual = 0;
		while (__n > 0)
		{
			// Only skip the small group
			int now = (int)(_SKIP_LEN < __n ? _SKIP_LEN : __n);
			
			// Try to skip these bytes
			int rv = this.read(buf, 0, now);
			
			// EOF?
			if (rv < 0)
				return actual;
			
			// Discard the bytes
			actual += rv;
			__n -= rv;
		}
		
		return actual;
	}
}

Deleted runt/apis/cldc-compact/java/io/InputStreamReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238














































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Decoder;

/**
 * This is a reader which adapts to an input stream and decodes the input
 * bytes into characters.
 *
 * @since 2018/10/13
 */
public class InputStreamReader
	extends Reader
{
	/** The input source. */
	private final InputStream _in;
	
	/** The decoder to use. */
	private final Decoder _decoder;
	
	/** The input read storage. */
	private final byte[] _store;
	
	/**
	 * Initializes the reader from the given input stream using the default
	 * encoding.
	 *
	 * @param __in The input byte source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public InputStreamReader(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this._in = __in;
		
		Decoder d;
		this._decoder = (d = CodecFactory.defaultDecoder());
		this._store = new byte[d.maximumSequenceLength()];
	}
	
	/**
	 * Initializes the reader from the given input stream using the default
	 * encoding.
	 *
	 * @param __in The input byte source.
	 * @param __enc The encoding to decode.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/10/13
	 */
	public InputStreamReader(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this._in = __in;
		
		Decoder d;
		this._decoder = (d = CodecFactory.decoder(__enc));
		this._store = new byte[d.maximumSequenceLength()];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public void close()
		throws IOException
	{
		this._in.close();
	}
	
	/**
	 * Returns the name of the encoding.
	 *
	 * @return The encoding name.
	 * @since 2018/12/08
	 */
	public String getEncoding()
	{
		return this._decoder.encodingName();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public int read()
		throws IOException
	{
		InputStream in = this._in;
		Decoder decoder = this._decoder;
		byte[] store = this._store;
		int storelen = 0,
			declimit = store.length;
		
		// Read characters
		for (;;)
		{
			// {@squirreljme.error ZZ0o Read of input byte sequence exceeded
			// the maximum specified sequence length. (The store length)}
			if (storelen >= declimit)
				throw new IOException("ZZ0o " + storelen);
			
			// Read byte from input stream
			int brc = in.read(store, storelen, 1);
			
			// Reached EOF from the input bytes
			if (brc < 0)
			{
				// No characters were read, so this is a complete EOF
				if (storelen <= 0)
					return -1;
				
				// Try to decode whatever was read, if it ends up not being
				// valid then just use the replacement character because it
				// probably got chopped off
				int cha = decoder.decode(store, 0, storelen);
				if (cha >= 0)
					return (char)cha;
				else
					return (char)0xFFFD;
			}
			
			// Increment the store length since bytes were read
			storelen++;
			
			// Try to decode a character, if it decodes to a valid character we
			// just store that
			int cha = decoder.decode(store, 0, storelen);
			if (cha >= 0)
				return (char)cha;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IOException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		InputStream in = this._in;
		Decoder decoder = this._decoder;
		byte[] store = this._store;
		int storelen = 0,
			declimit = store.length;
		
		int rv = 0,
			baseo = __o;
		for (int o = __o; rv < __l;)
		{
			// {@squirreljme.error ZZ0p Read of input byte sequence exceeded
			// the maximum specified sequence length. (The store length)}
			if (storelen >= declimit)
				throw new IOException("ZZ0p " + storelen);
			
			// Read byte from input stream
			int brc = in.read(store, storelen, 1);
			
			// Reached EOF from the input bytes
			if (brc < 0)
			{
				// No characters were read, so this is a complete EOF
				// However if there were characters sitting in the output we
				// need to return those
				if (storelen <= 0)
					return (rv > 0 ? rv : brc);
				
				// Try to decode whatever was read, if it ends up not being
				// valid then just use the replacement character because it
				// probably got chopped off
				int cha = decoder.decode(store, 0, storelen);
				if (cha >= 0)
					__c[o++] = (char)cha;
				else
					__c[o++] = (char)0xFFFD;
				rv++;
				
				// There could have been characters placed before this, so
				// this should be at least 1
				return rv;
			}
			
			// Increment the store length since bytes were read
			storelen++;
			
			// Try to decode a character, if it decodes to a valid character we
			// just store that
			int cha = decoder.decode(store, 0, storelen);
			if (cha >= 0)
			{
				__c[o++] = (char)cha;
				storelen = 0;
				rv++;
			}
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public boolean ready()
		throws IOException
	{
		// If the number of available bytes is at least the maximum sequence
		// length then we can read a single character without blocking
		return this._in.available() >= this._store.length;
	}
}

Deleted runt/apis/cldc-compact/java/io/InterruptedIOException.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is thrown when an I/O operation was interrupted.
 *
 * @since 2018/12/08
 */
public class InterruptedIOException
	extends IOException
{
	/** The number of bytes which were transferred. */
	public int bytesTransferred;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public InterruptedIOException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public InterruptedIOException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/io/OutputStream.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
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























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This class is the base class for all byte oriented output streams.
 *
 * @since 2016/04/16
 */
public abstract class OutputStream
	implements Closeable
{
	/**
	 * Initializes the base output stream.
	 *
	 * @since 2016/04/16
	 */
	public OutputStream()
	{
	}
	
	/**
	 * Writes a single byte to the output stream, the byte is in the range of
	 * 0 and 255. If the byte exceeds that range, then it must take the low
	 * order value and write that {@code __a & 0xFF}.
	 *
	 * @param __b The value the low order byte is derived from for output to
	 * this stream.
	 * @throws IOException On write errors.
	 * @since 2016/04/16
	 */
	public abstract void write(int __b)
		throws IOException;
	
	/**
	 * {@inheritDoc}
	 *
	 * If this method is not overridden by a sub-class then this does nothing.
	 *
	 * @since 2016/04/16
	 */
	@Override
	public void close()
		throws IOException
	{	
		// Does nothing
	}
	
	/**
	 * This is used to indicate that the stream should be flushed.
	 *
	 * If this method is not overridden by a sub-class then this does nothing.
	 *
	 * @since 2016/04/16
	 */
	public void flush()
		throws IOException
	{
		// Does nothing
	}
	
	/**
	 * Writes bytes from the given input array to this output stream.
	 *
	 * If this method is not overidden by a sub-class then this will call
	 * {@link #write(int)} for each byte in the buffer.
	 *
	 * @param __a The source byte array to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/16
	 */
	public void write(byte[] __a)
		throws IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Write all bytes
		for (int i = 0, n = __a.length; i < n; i++)
			this.write(__a[i]);
	}
	
	/**
	 * Writes multiple bytes from the specific array into this output stream.
	 *
	 * @param __a The array to source bytes from.
	 * @param __o The offset from the start of the array to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IndexOutOfBoundsException If the offset or length are negative;
	 * or the offset and the length exceeds the input array.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/16
	 */
	public void write(byte[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Write all bytes
		for (int i = 0; i < __l; i++)
			this.write(__a[__o + i]);
	}
}

Deleted runt/apis/cldc-compact/java/io/OutputStreamWriter.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Encoder;

public class OutputStreamWriter
	extends Writer
{
	public OutputStreamWriter(OutputStream __a, String __b)
		throws UnsupportedEncodingException
	{
		super();
		if (false)
			throw new UnsupportedEncodingException();
		throw new todo.TODO();
	}
	
	public OutputStreamWriter(OutputStream __a)
	{
		super();
		throw new todo.TODO();
	}
	
	@Override
	public void close()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void flush()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public String getEncoding()
	{
		throw new todo.TODO();
	}
	
	@Override
	public void write(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void write(char[] __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public void write(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/io/PrintStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869





































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Encoder;
import java.util.Formatter;

/**
 * This class is used to print translated and formatted text.
 *
 * No {@link IOException} is ever thrown by any of these methods, they are
 * handled and provided as an error flag which can be obtained. If
 * {@link InterruptedIOException} is thrown then the error state is not set,
 * any operations which cause this to occur will instead call
 * {@code Thread.currentThread().interrupt()}.
 *
 * Print streams may optionally have automatic flushing which will call
 * {@link #flush()} whenever a byte array is written or when it is detected
 * that {@code '\n'} is written. Internally the output is bufferred to optimize
 * for writing multiple characters at once rather than one at a time.
 *
 * If not specified, the current system encoding is used.
 *
 * Any characters which are written to the output will be encoded accordingly.
 *
 * @since 2018/09/16
 */
public class PrintStream
	extends OutputStream
	implements Appendable, Closeable
{
	/**
	 * This buffer size for this class has been chosen to be small, since in
	 * most cases this class will either not be used or will be outputting just
	 * text to the console. So since most consoles and most text will likely
	 * be 80 columns or less, this buffer size is enough to fit such a terminal
	 * but also give some extra room in the event of overflow.
	 */
	private static final int _BUFFER_SIZE =
		96;
	
	/** Threshold before a forced flush. */
	private static final int _THRESHOLD =
		90;
	
	/** The newline sequence. */
	private static final String _NEWLINE;
	
	/** The stream to write bytes to. */
	private final OutputStream _out;
	
	/** Is auto-flushing to be used? */
	private final boolean _autoflush;
	
	/** The encoder used to encode chars to bytes. */
	private final Encoder _encoder;
	
	/** Mini-byte buffer for encoded characters. */
	private final byte[] _minienc =
		new byte[8];
	
	/** The internal buffer. */
	private final byte[] _buf =
		new byte[_BUFFER_SIZE];
	
	/** The position the buffer is at. */
	private int _bat;
	
	/** Error state? */
	private boolean _inerror;
	
	/**
	 * Cache the line separator which is derived from the system properties.
	 *
	 * @since 2018/09/18
	 */
	static
	{
		String nl;
		try
		{
			nl = System.getProperty("line.separator");
		}
		catch (SecurityException e)
		{
			nl = "\n";
		}
		
		_NEWLINE = nl;
	}
	
	/**
	 * Writes to the given stream using the default encoding and with no
	 * auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out)
		throws NullPointerException
	{
		this(__out, false, CodecFactory.defaultEncoder());
	}
	
	/**
	 * Writes to the given stream using the default encoding and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out, boolean __autoflush)
		throws NullPointerException
	{
		this(__out, __autoflush, CodecFactory.defaultEncoder());
	}
	
	/**
	 * Writes to the given stream using the given encoding and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @param __enc The encoding to use.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	public PrintStream(OutputStream __out, boolean __autoflush, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(__out, __autoflush, CodecFactory.encoder(__enc));
	}
	
	/**
	 * Writes to the given stream using the given encoder and with the
	 * specified auto flushing.
	 *
	 * @param __out The stream to write to.
	 * @param __autoflush If auto flushing is to be enabled.
	 * @param __enc The encoder to use to encode characters to bytes.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/09/17
	 */
	private PrintStream(OutputStream __out, boolean __autoflush, Encoder __enc)
		throws NullPointerException
	{
		if (__out == null || __enc == null)
			throw new NullPointerException("NARG");
		
		this._out = __out;
		this._autoflush = __autoflush;
		this._encoder = __enc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(CharSequence __c)
	{
		this.print((__c == null ? "null" : __c.toString()));
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(CharSequence __c, int __s, int __e)
	{
		this.print((__c == null ? "null" :
			__c.subSequence(__s, __e).toString()));
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public PrintStream append(char __c)
	{
		this.print(__c);
		return this;
	}
	
	/**
	 * Flushes the stream and checks the error state.
	 *
	 * @return The current error state.
	 * @since 2019/06/21
	 */
	public boolean checkError()
	{
		synchronized (this)
		{
			this.__flush();
			return this._inerror;
		}
	}
	
	/**
	 * Clears the error state.
	 *
	 * @since 2019/06/21
	 */
	protected void clearError()
	{
		synchronized (this)
		{
			this._inerror = false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	public void close()
	{
		synchronized (this)
		{
			// Flush output
			this.__flush();
			
			// Close the stream
			try
			{
				this._out.close();
			}
			
			// Set error state?
			catch (IOException e)
			{
				this._inerror = true;
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public void flush()
	{
		synchronized (this)
		{
			this.__flush();
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public PrintStream format(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		return this.__printf(__fmt, __args);
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(boolean __v)
	{
		synchronized (this)
		{
			this.__print((__v ? "true" : "false"));
		}
	}
	
	/**
	 * Prints the specified character to the stream.
	 *
	 * @param __v The character to print.
	 * @since 2018/09/23
	 */
	public void print(char __v)
	{
		synchronized (this)
		{
			this.__writeChar(__v);
		}
	}
	
	/**
	 * Prints the specified integer to the stream.
	 *
	 * @param __v The value to print.
	 * @since 2018/11/04
	 */
	public void print(int __v)
	{
		synchronized (this)
		{
			this.__print(Integer.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(long __v)
	{
		synchronized (this)
		{
			this.__print(Long.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(float __v)
	{
		synchronized (this)
		{
			this.__print(Float.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(double __v)
	{
		synchronized (this)
		{
			this.__print(Double.toString(__v));
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public void print(char[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			for (int i = 0, n = __v.length; i < n; i++)
				this.__writeChar(__v[i]);
		}
	}
	
	/**
	 * Prints the specified string.
	 *
	 * @param __v The string to print, if {@code null} then {@code "null"} is
	 * printed.
	 * @since 2018/09/20
	 */
	public void print(String __v)
	{
		synchronized (this)
		{
			this.__print(__v);
		}
	}
	
	/**
	 * Prints the given value.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void print(Object __v)
	{
		synchronized (this)
		{
			this.__print((__v == null ? "null" : __v.toString()));
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public PrintStream printf(String __fmt, Object... __args)
	{
		return this.__printf(__fmt, __args);
	}
	
	/**
	 * Prints the end of line sequence that is used for the current platform.
	 *
	 * @return The end of line sequence.
	 * @since 2018/09/21
	 */
	public void println()
	{
		synchronized (this)
		{
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(boolean __v)
	{
		synchronized (this)
		{
			this.__print((__v ? "true" : "false"));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(char __v)
	{
		synchronized (this)
		{
			this.__writeChar(__v);
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(int __v)
	{
		synchronized (this)
		{
			this.__print(Integer.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(long __v)
	{
		synchronized (this)
		{
			this.__print(Long.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(float __v)
	{
		synchronized (this)
		{
			this.__print(Float.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @since 2019/06/21
	 */
	public void println(double __v)
	{
		synchronized (this)
		{
			this.__print(Double.toString(__v));
			this.__println();
		}
	}
	
	/**
	 * Prints the given value and ends the line.
	 *
	 * @param __v The value to print.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public void println(char[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			for (int i = 0, n = __v.length; i < n; i++)
				this.__writeChar(__v[i]);
			this.__println();
		}
	}
	
	/**
	 * Prints the given string to the output stream followed by a new line.
	 *
	 * @param __v The string to write.
	 * @since 2018/09/18
	 */
	public void println(String __v)
	{
		synchronized (this)
		{
			this.__print(__v);
			this.__println();
		}
	}
	
	/**
	 * Prints the given object to the output stream followed by a new line.
	 *
	 * @param __v The string to write.
	 * @since 2018/11/20
	 */
	public void println(Object __v)
	{
		synchronized (this)
		{
			this.__print((__v == null ? "null" : __v.toString()));
			this.__println();
		}
	}
	
	/**
	 * Sets the error state to on.
	 *
	 * @since 2019/06/21
	 */
	protected void setError()
	{
		this._inerror = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If newline is written, this will flush.")
	public void write(int __c)
	{
		// Is always in array form
		byte[] b = new byte[]{(byte)__c};
		
		// Forward
		synchronized (this)
		{
			this.__writeBytes(b, 0, 1);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If auto-flushing, this calls flush after writing.")
	public void write(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			this.__writeBytes(__b, 0, __b.length);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/21
	 */
	@Override
	@ImplementationNote("If auto-flushing, this calls flush after writing.")
	public void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			this.__writeBytes(__b, __o, __l);
		}
	}
	
	/**
	 * Flushes the stream to the output.
	 *
	 * @since 2018/09/21
	 */
	private final void __flush()
	{
		// Nothing to be written at all?
		int bat = this._bat;
		if (bat <= 0)
			return;
		
		// Write individual bytes and detect any exceptions
		OutputStream out = this._out;
		boolean oopsie = false;
		byte[] buf = this._buf;
		int bop = 0;
		for (bop = 0; bop < bat; bop++)
			try
			{
				out.write(buf[bop]);
			}
			catch (InterruptedIOException e)
			{
				// Just stop handling here and interrupt the thread
				Thread.currentThread().interrupt();
				break;
			}
			catch (IOException e)
			{
				oopsie = true;
				break;
			}
		
		// Could not flush to the output
		if (oopsie)
		{
			// Bring down the characters in the buffer so that they are not
			// just lost
			for (int i = bop, o = 0; i < bat; i++, o++)
				buf[o] = buf[i];
			this._bat = bat - bop;
			
			// Set error state
			this._inerror = true;
		}
		
		// Is perfectly fine, so "clear" the buffer
		else
			this._bat = 0;
	}
	
	/**
	 * Prints the specified string.
	 *
	 * @param __s The string to print, if {@code null} then {@code "null"} is
	 * printed.
	 * @since 2018/09/20
	 */
	private final void __print(String __s)
	{
		synchronized (this)
		{
			// Print null explicitely
			if (__s == null)
				__s = "null";
			
			for (int i = 0, n = __s.length(); i < n; i++)
				this.__writeChar(__s.charAt(i));
		}
	}
	
	/**
	 * Writes formatted text to the print stream, using the default locale.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the string contains illegal
	 * format specifiers.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	private final PrintStream __printf(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		if (__fmt == null)
			throw new NullPointerException("NARG");
		
		// Generate text to write into a string builder
		StringBuilder sb = new StringBuilder();
		try (Formatter f = new Formatter(sb))
		{
			f.format(__fmt, __args);
		}
		
		// Dump characters that were written into the string but without
		// turning it into an actual string, for memory purposes
		synchronized (this)
		{
			for (int i = 0, n = sb.length(); i < n; i++)
				this.__writeChar(sb.charAt(i));
		}
		
		return this;
	}
	
	/**
	 * Prints the end of line sequence that is used for the current platform.
	 *
	 * @return The end of line sequence.
	 * @since 2018/09/21
	 */
	private final void __println()
	{
		synchronized (this)
		{
			// If the newline character has not yet been set, use a fallback
			String nl = PrintStream._NEWLINE;
			if (nl == null)
				nl = "\n";
			
			// Write the ending
			for (int i = 0, n = nl.length(); i < n; i++)
				this.__writeChar(nl.charAt(i));
			
			// Flush the stream after every line printed, in the event the
			// system does not use a UNIX newline
			if (this._autoflush)
				this.flush();
		}
	}
	
	/**
	 * Writes multiple bytes to the output.
	 *
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	private final void __writeBytes(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Our current buffer state
		byte[] buf = this._buf;
		int bat = this._bat;
		
		// Auto-flush on any newlines?
		boolean autoflush = this._autoflush;
		
		// Copy bytes into the buffer
		boolean flush = false;
		for (int i = 0; i < __l; i++)
		{
			byte b = __b[i];
			
			// Fill into buffer
			buf[bat++] = b;
			
			// Auto-flushing on newline?
			if (autoflush && b == '\n')
				flush = true;
			
			// Force a flush?
			if (bat >= _THRESHOLD)
			{
				// Store at location, flush then reload it
				this._bat = bat;
				this.__flush();
				bat = this._bat;
			}
		}
		
		// Store changes
		this._bat = bat;
		
		// Perform a flush?
		if (flush || bat >= _THRESHOLD)
			this.__flush();
	}
	
	/**
	 * Writes a single character to the output, encoding it as required.
	 *
	 * @param __c The character to write.
	 * @since 2018/09/19
	 */
	private final void __writeChar(char __c)
	{
		// Encode bytes into the array
		byte[] minienc = this._minienc;
		int wc = this._encoder.encode(__c, minienc, 0, minienc.length);
		
		// {@squirreljme.error ZZ0q Did not expect the buffer to be out of
		// room.}
		if (wc < 0)
			throw new Error("ZZ0q");
		
		// Write them into the buffer
		this.__writeBytes(minienc, 0, wc);
	}
}

Deleted runt/apis/cldc-compact/java/io/Reader.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
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









































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public abstract class Reader
	implements Closeable
{
	/** The lock to use when performing read operations. */
	@ImplementationNote("This is only used with the skip() method.")
	protected Object lock;
	
	/**
	 * Initializes the base reader.
	 *
	 * @since 2018/10/13
	 */
	@ImplementationNote("The lock should be initialized to this, however " +
		"this would result in the reader itself never able to be freed " +
		"because it refers to itself.")
	protected Reader()
	{
		this.lock = null;
	}
	
	/**
	 * Initializes the reader to lock against the given object.
	 *
	 * @param __l The object to lock against.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	protected Reader(Object __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.lock = __l;
	}
	
	public abstract void close()
		throws IOException;
	
	/**
	 * Reads multiple characters.
	 *
	 * @param __c The output characters.
	 * @param __o The offset into the output.
	 * @param __l The number of characters to read.
	 * @return The number of read characters or {@code -1} on end of file.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public abstract int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException;
	
	public void mark(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean markSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reads a single character from the input.
	 *
	 * @return The character which was read or {@code -1} on end of file.
	 * @throws IOException On read errors.
	 * @since 2018/10/13
	 */
	public int read()
		throws IOException
	{
		// Try reading the character in a loop
		char[] buf = new char[1];
		for (;;)
		{
			int rc = this.read(buf, 0, 1);
			
			// Try to read character again
			if (rc == 0)
				continue;
			
			// EOF
			else if (rc < 0)
				return rc;
			
			return buf[0];
		}
	}
	
	/**
	 * Reads in multiple characters from the stream.
	 *
	 * @param __c The characters to read.
	 * @return The number of read characters.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public int read(char[] __c)
		throws IOException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		return this.read(__c, 0, __c.length);
	}
	
	public boolean ready()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void reset()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public long skip(long __a)
		throws IOException
	{
		// To prevent clashes when skipping characters
		synchronized (this.__lock())
		{
			if (false)
				throw new IOException();
			throw new todo.TODO();
		}
	}
	
	/**
	 * Returns the locking object.
	 *
	 * @return The locking object.
	 * @since 2018/10/13
	 */
	final Object __lock()
	{
		Object rv = this.lock;
		return (rv == null ? this : rv);
	}
}

Deleted runt/apis/cldc-compact/java/io/UTFDataFormatException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is thrown when the format of a UTF string is not correct.
 *
 * @since 2018/12/03
 */
public class UTFDataFormatException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/03
	 */
	public UTFDataFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given cause.
	 *
	 * @param __m The message to use.
	 * @since 2018/12/03
	 */
	public UTFDataFormatException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/io/UnsupportedEncodingException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

/**
 * This is thrown when the encoding is not supported.
 *
 * @since 2018/12/08
 */
public class UnsupportedEncodingException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public UnsupportedEncodingException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public UnsupportedEncodingException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/io/Writer.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
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





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.io;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public abstract class Writer
	implements Appendable, Closeable
{
	protected Object lock;
	
	protected Writer()
	{
		super();
		throw new todo.TODO();
	}
	
	protected Writer(Object __a)
	{
		super();
		throw new todo.TODO();
	}
	
	@Override
	public abstract void close()
		throws IOException;
	
	public abstract void flush()
		throws IOException;
	
	public abstract void write(char[] __a, int __b, int __c)
		throws IOException;
	
	@Override
	public Writer append(CharSequence __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public Writer append(CharSequence __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	@Override
	public Writer append(char __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(int __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(char[] __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(String __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void write(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/lang/Appendable.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.io.IOException;

/**
 * This is an appendable which is given characters and character sequences
 * to be written into the output.
 *
 * @since 2018/12/07
 */
public interface Appendable
{
	/**
	 * Appends a character sequence to the output.
	 *
	 * @param __c The sequence to append.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	public abstract Appendable append(CharSequence __c)
		throws IOException;
	
	/**
	 * Appends a character sequence to the output.
	 *
	 * @param __c The sequence to append.
	 * @param __s The start index.
	 * @param __e The end index.
	 * @throws IndexOutOfBoundsException If the start or end is outside of
	 * the bounds of the sequence, or the start exceeds the end.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	public abstract Appendable append(CharSequence __c, int __s, int __e)
		throws IndexOutOfBoundsException, IOException;
	
	/**
	 * Appends a single character to the output.
	 *
	 * @param __c The character to append.
	 * @throws IOException On write errors.
	 * @since 2018/12/07
	 */
	public abstract Appendable append(char __c)
		throws IOException;
}

Deleted runt/apis/cldc-compact/java/lang/ArithmeticException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when there is a divide by zero.
 *
 * @since 2018/12/04
 */
public class ArithmeticException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArithmeticException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public ArithmeticException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/ArrayIndexOutOfBoundsException.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an attempt is made to read from or write to an array
 * index which is out of bounds.
 *
 * @since 2018/12/04
 */
public class ArrayIndexOutOfBoundsException
	extends IndexOutOfBoundsException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initializes the exception with the index specified as the message and
	 * no cause.
	 *
	 * @param __i The out of bounds index.
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException(int __i)
	{
		// {@squirreljme.error ZZ0r Array index out of bounds. (The index)}
		super("ZZ0r " + __i);
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The exception message.
	 * @since 2018/12/04
	 */
	public ArrayIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/ArrayStoreException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the given value cannot be stored into the given array
 * because it is of the wrong type.
 *
 * @since 2018/12/04
 */
public class ArrayStoreException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArrayStoreException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public ArrayStoreException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/AssertionError.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
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










































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an assertion check fails.
 *
 * @since 2018/12/04
 */
public class AssertionError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public AssertionError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(Object __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(boolean __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(char __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(int __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(long __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(float __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public AssertionError(double __m)
	{
		super(AssertionError.__convert(__m));
	}
	
	/**
	 * Converts the given object to a string.
	 *
	 * @param __o The object to convert.
	 * @return The string form of the object.
	 * @since 2018/12/04
	 */
	private static final String __convert(Object __o)
	{
		if (__o == null)
			return "null";
		
		// Just make sure we can convert this
		try
		{
			return __o.toString();
		}
		
		// Could not convert
		catch (Throwable t)
		{
			// Debug it
			t.printStackTrace();
			
			// {@squirreljme.error ZZ0s Assertion string conversion failed
			// with no message.}
			String m = t.getMessage();
			return (m == null ? "ZZ0s" : m);
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/AutoCloseable.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface is used with the classes which are initialized in the
 * {@code try-with-resources} block, after the entire block has been finished
 * the {@link #close()} method is called automatically. This makes it much
 * simpler to free resources and no longer requires a {@code finally} with a
 * local variable mess to handle closing of streams.
 *
 * {@code
 *
 * try (FileInputStream fis = new FileInputStream("foo"))
 * {
 *     // fis is VISIBLE here.
 *     // Do stuff with file.
 * }
 * catch (IOException ioe)
 * {
 *     // fis is NOT VISIBLE here.
 *     // Handle exception or rethrow as needed
 * }
 * finally
 * {
 *     // fis is NOT VISIBLE here.
 *     // Other things to do regardless of success or an exception.
 * }
 * // The variable fis is NOT VISIBLE here and when this point of code has
 * // been reached, fis.close() would have been called.
 * 
 * }
 *
 * @see Closeable
 * @since 2015/03/23
 */
public interface AutoCloseable
{
	/**
	 * This releases all (or most) of the resources associated with
	 * an implementing class. When used with a try-with-resources block, this
	 * is automatically called after the scope of block has been left (it is
	 * executed after {@code finally}).
	 *
	 * It is recommended that a resource is actually closed (or at least
	 * marked as such) before an exception is thrown.
	 *
	 * Unlike {@link java.io.Closeable#close()} (and provided the class does
	 * not extend {@link java.io.Closeable}), calling this multiple times may
	 * produce side effects rather than doing nothing on a closed resource.
	 * However, it is stronly recommended and encouraged to follow the "do
	 * nothing when closed" behavior of {@link java.io.Closeable}.
	 *
	 * @throws Exception If there was an error closing the specified object.
	 * @since 2015/03/23
	 */
	public abstract void close()
		throws Exception;
}

Deleted runt/apis/cldc-compact/java/lang/Boolean.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
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
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This is a boxed boolean value.
 *
 * @since 2018/12/07
 */
public final class Boolean
	implements Comparable<Boolean>
{
	/** The false value. */
	public static final Boolean FALSE =
		new Boolean(false);
	
	/** The true value. */
	public static final Boolean TRUE =
		new Boolean(true);
	
	/** The class representing the primitive type. */
	public static final Class<Boolean> TYPE =
		ObjectAccess.<Boolean>classByNameType("boolean");
	
	/** The value of this boolean. */
	private final boolean _value;
	
	/**
	 * Initializes the boolean with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Boolean(boolean __v)
	{
		this._value = __v;
	}
	
	/**
	 * Initializes the boolean from the given string.
	 *
	 * @param __s String boolean representation.
	 * @since 2018/12/07
	 */
	public Boolean(String __s)
	{
		this(Boolean.valueOf(__s)._value);
	}
	
	/**
	 * Returns the value of this boolean.
	 *
	 * @return The boolean value.
	 * @since 2018/09/23
	 */
	public boolean booleanValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int compareTo(Boolean __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		boolean a = this._value,
			b = __o._value;
		
		if (a == b)
			return 0;
		else if (a)
			return 1;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Boolean))
			return false;
		
		return this._value == ((Boolean)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		return (this._value ? 1231 : 1237);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		return Boolean.toString(this._value);
	}
	
	/**
	 * Gets boolean value from the system property.
	 *
	 * @param __p The property to get.
	 * @return The value of the boolean.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If it is not permitted to get the property.
	 * @since 2018/12/07
	 */
	public static boolean getBoolean(String __p)
		throws NullPointerException, SecurityException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return Boolean.parseBoolean(System.getProperty(__p));
	}
	
	/**
	 * Parses the given boolean value without regards to case.
	 *
	 * @param __v The value to parse.
	 * @return The boolean of the parse.
	 * @since 2018/12/07
	 */
	public static boolean parseBoolean(String __v)
	{
		return (__v != null && __v.equalsIgnoreCase("true"));
	}
	
	/**
	 * Returns a string representing the given value.
	 *
	 * @param __a The boolean to represent.
	 * @return The string representation of the boolean.
	 * @since 2018/09/23
	 */
	public static String toString(boolean __a)
	{
		if (__a)
			return "true";
		return "false";
	}
	
	/**
	 * Boxes the given boolean value.
	 *
	 * @param __a The boolean to box.
	 * @return Either {@link #TRUE} or {@link #FALSE}.
	 * @since 2016/03/21
	 */
	public static Boolean valueOf(boolean __a)
	{
		if (__a)
			return TRUE;
		return FALSE;
	}
	
	/**
	 * Returns the value of the given boolean.
	 *
	 * @param __v The value to parse.
	 * @return The boolean value.
	 * @since 2018/12/07
	 */
	public static Boolean valueOf(String __v)
	{
		if (__v != null && __v.equalsIgnoreCase("true"))
			return TRUE;
		return FALSE;
	}
}

Deleted runt/apis/cldc-compact/java/lang/Byte.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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




















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a boxed byte value.
 *
 * @since 2018/12/07
 */
public final class Byte
	extends Number
	implements Comparable<Byte>
{
	/** The maximum value. */
	public static final byte MAX_VALUE =
		127;
	
	/** The minimum value. */
	public static final byte MIN_VALUE =
		-128;
	
	/** The number of bits in a byte. */
	public static final int SIZE =
		8;
	
	/** The class representing the primitive type. */
	public static final Class<Byte> TYPE =
		ObjectAccess.<Byte>classByNameType("byte");
	
	/** The value of the byte. */
	private final byte _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the boxed value.
	 *
	 * @param __v The value to store.
	 * @since 2018/11/14
	 */
	public Byte(byte __v)
	{
		this._value = __v;
	}
	
	/**
	 * Initializes the byte value from the string.
	 *
	 * @param __s The string to parse.
	 * @throws NumberFormatException If the string is not a valid number.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public Byte(String __s)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this._value = Byte.parseByte(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public byte byteValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int compareTo(Byte __o)
	{
		return this._value - __o._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public double doubleValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Byte))
			return false;
		
		return this._value == ((Byte)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public float floatValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int intValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public short shortValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Byte.toString(this._value)));
		
		return rv;
	}
	
	/**
	 * Decodes a byte value from the string in the same form as
	 * {@link Integer#decode(String)}.
	 *
	 * @param __s The string to decode.
	 * @return The byte value.
	 * @throws NumberFormatException If the value is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte decode(String __s)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0t Byte value out of bounds.}
		int val = Integer.decode(__s);
		if (val < MIN_VALUE || val > MAX_VALUE)
			throw new NumberFormatException("ZZ0t");
		
		return Byte.valueOf((byte)val);
	}
	
	/**
	 * Parses the given byte using the given radix.
	 *
	 * @param __s The string to parse.
	 * @param __r The radix of the value.
	 * @return The parsed value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static byte parseByte(String __s, int __r)
		throws NumberFormatException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0u Byte value out of range.}
		int val = Integer.parseInt(__s, __r);
		if (val < MIN_VALUE || val > MAX_VALUE)
			throw new NumberFormatException("ZZ0u");
		
		return (byte)val;
	}
	
	/**
	 * Parses the given string to a byte.
	 *
	 * @param __s The string to parse.
	 * @return The parsed value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static byte parseByte(String __s)
		throws NumberFormatException, NullPointerException
	{
		return Byte.parseByte(__s, 10);
	}
	
	/**
	 * Returns the string representation of the given byte value.
	 *
	 * @param __v The value to represent.
	 * @return The string value.
	 * @since 2018/11/14
	 */
	public static String toString(byte __v)
	{
		return Integer.toString(__v, 10);
	}
	
	/**
	 * Boxes the specified byte value.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/11/14
	 */
	public static Byte valueOf(byte __v)
	{
		return new Byte(__v);
	}
	
	/**
	 * Parses the string to the given byte value.
	 *
	 * @param __s The string to parse.
	 * @param __r The radix.
	 * @return The decoded value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte valueOf(String __s, int __r)
		throws NumberFormatException, NullPointerException
	{
		return new Byte(Byte.parseByte(__s, __r));
	}
	
	/**
	 * Parses the string to the given byte value.
	 *
	 * @param __s The string to parse.
	 * @return The decoded value.
	 * @throws NumberFormatException If the byte is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static Byte valueOf(String __s)
		throws NumberFormatException, NullPointerException
	{
		return new Byte(Byte.parseByte(__s, 10));
	}
}

Deleted runt/apis/cldc-compact/java/lang/CharSequence.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This represents a sequence of characters.
 *
 * @since 2018/12/07
 */
public interface CharSequence
{
	/**
	 * Returns the character at the given index.
	 *
	 * @param __i The index to get.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/07
	 */
	public abstract char charAt(int __i)
		throws IndexOutOfBoundsException;
	
	/**
	 * Returns the length of the character sequence.
	 *
	 * @return The length of the sequence.
	 * @since 2018/12/07
	 */
	public abstract int length();
	
	/**
	 * Returns a sub-sequence of this character sequence.
	 *
	 * @param __s The start index.
	 * @param __e The end index.
	 * @throws IndexOutOfBoundsException If the start or end exceed the
	 * sequence bounds or start is greater than end.
	 * @since 2018/12/07
	 */
	public abstract CharSequence subSequence(int __s, int __e)
		throws IndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public abstract String toString();
}

Deleted runt/apis/cldc-compact/java/lang/Character.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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






























































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.i18n.DefaultLocale;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is a boxed representation of {@link char}.
 *
 * @since 2018/10/13
 */
public final class Character
	implements Comparable<Character>
{
	/** The maximum radix for digit conversions. */
	public static final int MAX_RADIX =
		36;
	
	/** The maximum value for characters. */
	public static final char MAX_VALUE =
		65535;
	
	/** The minimum radix for digit conversions. */
	public static final int MIN_RADIX =
		2;
	
	/** The minimum value for characters. */
	public static final char MIN_VALUE =
		0;
	
	/** The number of bits used to represent a character. */
	public static final int SIZE =
		16;
	
	/** The class representing the primitive type. */
	public static final Class<Character> TYPE =
		ObjectAccess.<Character>classByNameType("char");
	
	/** The character value. */
	private final char _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the boxed character.
	 *
	 * @param __v The character to use.
	 * @since 2018/10/11
	 */
	public Character(char __v)
	{
		this._value = __v;
	}
	
	/**
	 * Returns the character value.
	 *
	 * @return The character value.
	 * @since 2018/10/11
	 */
	public char charValue()
	{
		return this._value;
	}
	
	/**
	 * This compares the numerical value for characters, it does not depend
	 * on locale at all.
	 *
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int compareTo(Character __o)
		throws NullPointerException
	{
		char a = this._value,
			b = __o._value;
		
		return a - b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Character))
			return false;
		
		return this._value == ((Character)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// We can represent a string for our single character as this
		// special sequence instead of just creating a new temporary string
		// just to store a single character or creating some kind of array.
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = new String(new char[]{this._value}, (short)0)));
		
		return rv;
	}
	
	/**
	 * Returns the digit for the given character and radix.
	 *
	 * @param __c The character to decode.
	 * @param __r The radix used.
	 * @return The digit for the given radix, if the character or the radix is
	 * not valid then {@code -1} is returned.
	 * @since 2018/10/13
	 */
	public static int digit(char __c, int __r)
	{
		// Invalid radix
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			return -1;
		
		// Decode character
		int rv;
		if (__c >= 'a' && __c <= 'z')
			rv = 10 + (__c - 'a');
		else if (__c >= 'A' && __c <= 'Z')
			rv = 10 + (__c - 'A');
		else if (__c >= '0' && __c <= '9')
			rv = __c - '0';
		
		// Not valid
		else
			return -1;
		
		// Out of bounds of the radix
		if (rv >= __r)
			return -1;
		return rv;
	}
	
	/**
	 * Returns the character for the given digit and radix.
	 *
	 * @param __dig The digit to convert to a character.
	 * @param __r The radix to use for conversion.
	 * @return The character for the digit or NUL if the digit is out of range
	 * or the radix is out of range.
	 * @since 2018/10/13
	 */
	public static char forDigit(int __dig, int __r)
	{
		if (__dig < 0 || __dig >= __r || __r < Character.MIN_RADIX ||
			__r > Character.MAX_RADIX)
			return '\0';
		
		if (__dig < 10)
			return (char)('0' + __dig);
		return (char)('a' + (__dig - 10));
	}
	
	/**
	 * Returns true if the character is a digit.
	 *
	 * @param __c The character to check.
	 * @return True if the character is a digit.
	 * @since 2018/12/08
	 */
	public static boolean isDigit(char __c)
	{
		return (__c >= '0' && __c <= '9');
	}
	
	/**
	 * Returns true if the character is an ISO control code.
	 *
	 * @param __c The character to check.
	 * @return True if the character is an ISO control code.
	 * @since 2018/12/08
	 */
	public static boolean isISOControl(char __c)
	{
		return (__c >= 0 && __c <= 0x1F) || (__c >= 0x7F && __c <= 0x9F);
	}
	
	/**
	 * Returns true if the character is lowercase.
	 *
	 * Java ME only supports the Latin-1 characters.
	 *
	 * @param __c The character to check.
	 * @return True if the character is lowercase.
	 * @since 2018/12/08
	 */
	public static boolean isLowerCase(char __c)
	{
		// 0xF7 is Divide
		return ((__c >= 'a' && __c <= 'z') ||
			(__c != 0xF7 && __c >= 0xDF && __c <= 0xFF));
	}
	
	/**
	 * Returns true if the character is a space character.
	 *
	 * @param __c The character to check.
	 * @return True if the character is a space character.
	 * @since 2018/12/08
	 */
	public static boolean isSpaceChar(char __c)
	{
		return (__c == 0x09 || __c == 0x0A || __c == 0x0C || __c == 0x0D ||
			__c == 0x20);
	}
	
	/**
	 * Returns true if the character is uppercase.
	 *
	 * Java ME only supports the Latin-1 characters.
	 *
	 * @param __c The character to check.
	 * @return True if the character is uppercase.
	 * @since 2018/12/08
	 */
	public static boolean isUpperCase(char __c)
	{
		// 0xD7 is multiply
		return (__c >= 'A' && __c <= 'Z') ||
			(__c != 0xD7 && __c >= 0xC0 && __c <= 0xDE);
	}
	
	/**
	 * Returns true if this is a whitespace character according to Java.
	 *
	 * @param __c The character to check.
	 * @return True if the character is whitespace.
	 * @since 2018/12/08
	 */
	public static boolean isWhitespace(char __c)
	{
		switch (__c)
		{
			case 0x00A0:
			case 0x2007:
			case 0x202F:
			case 0x0009:
			case 0x000A:
			case 0x000B:
			case 0x000C:
			case 0x000D:
			case 0x001C:
			case 0x001D:
			case 0x001E:
			case 0x001F:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @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.
	 * @since 2018/10/13
	 */
	public static String toString(char __c)
	{
		return new String(new char[]{__c}, (short)0);
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @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.
	 * @since 2018/10/11
	 */
	@ImplementationNote("This is not cached.")
	public static Character valueOf(char __v)
	{
		return new Character(__v);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Class.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540




























































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.ResourceAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import cc.squirreljme.runtime.cldc.lang.ClassFlag;

/**
 * This class is the in-language representation of a Java class, the CLDC
 * allows for minimal reflection via {@link Class#forName(String)} and
 * {@link Class#newInstance()}.
 *
 * @since 2018/12/08
 */
public final class Class<T>
{
	/** This is the prefix that is used for assertion checks. */
	private static final String _ASSERTION_PREFIX =
		"cc.squirreljme.runtime.noassert.";
	
	/** The class data storage. */
	final ClassData _data;
	
	/** Has the assertion status been checked already? */
	private volatile boolean _checkedassert;
	
	/** Is this class being asserted? */
	private volatile boolean _useassert;
	
	/** The display name of the class. */
	private Reference<String> _name;
	
	/** String representation of class. */
	private Reference<String> _string;
	
	/**
	 * Initializes the class with the class data.
	 *
	 * @param __d The data to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/04
	 */
	private Class(ClassData __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this._data = __d;
	}
	
	/**
	 * This checks whether the specified input class extends this class or
	 * implements an interface and then returns this class object which is
	 * "cast" to the specified type. Note that this does not change the
	 * returned value.
	 *
	 * @param <U> The sub-class to cast this class object to.
	 * @param __cl A class which is checked to see if it extends or implements
	 * this class.
	 * @return {@code this} except cast to the specified sub-class
	 * @throws ClassCastException If the specified class is not a sub-class of
	 * this class type.
	 * @throws NullPointerException On null arguments.
	 * @see Class#isAssignableFrom(Class)
	 * @since 2016/06/13
	 */
	@SuppressWarnings({"unchecked"})
	public <U> Class<? extends U> asSubclass(Class<U> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ0v The specifed class is not a sub-class
		// of this class. (The class being checked; The current class)}
		if (!this.isAssignableFrom(__cl))
			throw new ClassCastException(
				String.format("ZZ0v %s %s", __cl, this));
		
		return (Class<? extends U>)this;
	}
	
	/**
	 * Casts the object to this class, checking it.
	 *
	 * @param __o The object to cast.
	 * @return The casted object.
	 * @throws ClassCastException If the type is not matched.
	 * @since 2018/09/29
	 */
	@SuppressWarnings({"unchecked"})
	public T cast(Object __o)
		throws ClassCastException
	{
		// Null always casts OK
		if (__o == null)
			return null;
		
		// {@squirreljme.error ZZ0w The other class cannot be casted to this
		// class. (This class; The other class)}
		Class<?> other = __o.getClass();
		if (!this.isAssignableFrom(other))
			throw new ClassCastException("ZZ0w " + this.getName() + " " +
				other.getName());
		
		return (T)__o;
	}
	
	/**
	 * Returns whether or not assertions should be enabled in the specified
	 * class, this is used internally by the virtual machine to determine if
	 * assertions should fail or not.
	 *
	 * In SquirrelJME, this defaults to returning {@code true}. To disable
	 * assertions for a class or an entire package then the following system
	 * property may be specified to disable them:
	 * {@code cc.squirreljme.noassert.(package)(.class)=true}.
	 *
	 * @return In SquirrelJME this returns by default {@code true}, otherwise
	 * this may return {@code false} if they are disabled for a class.
	 * @since 2016/06/13
	 */
	public boolean desiredAssertionStatus()
	{
		// If assertions have been checked, they do not have to be rechecked
		if (this._checkedassert)
			return this._useassert;
		
		// Otherwise check it
		return __checkAssertionStatus();
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2018/09/22
	 */
	public String getName()
	{
		Reference<String> ref = this._name;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			String bn = this._data.binaryName();
			
			// Slashes become dots
			this._name = new WeakReference<>((rv = bn.replace('/', '.')));
		}
		
		return rv;
	}
	
	/**
	 * Obtains a resource from the classpath which exists within a JAR file,
	 * inside of a directory, or in a prepacked resource. If a resource needs
	 * to be obtain from another class which exists in another JAR file then
	 * this method must be called from a class in that JAR.
	 *
	 * In the Java ME environment, one should not rely on getting resources
	 * which are executable class files (files ending in .class). These class
	 * files may be deleted during native compilation. This however should not
	 * be relied upon.
	 *
	 * Using this method on the classes for primitive types ({@code int.class})
	 * and using a relative name will always result in the path being treated
	 * as absolute.
	 *
	 * Relative paths are converted to absolute paths by appending the name
	 * to the binary name of the class package.
	 *
	 * @param __name The name of the resource to find, if this starts with a
	 * forward slash {@code '/'} then it is treated as an absolute path.
	 * Otherwise a resource will be derived from the calling class.
	 * @return A stream to the given resource or {@code null} if one was not
	 * found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/01
	 */
	public InputStream getResourceAsStream(String __name)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Do not lookup blank resources
		if (__name.isEmpty())
			return null;
		
		// This is not within any JAR, so nothing will ever be found
		String injar = this._data.inJar();
		if (injar == null)
			return null;
		
		// Absolute paths are not translated
		String want;
		if (__name.startsWith("/"))
			want = __name.substring(1);
		
		// Otherwise append to the binary name
		else
		{
			// Has a package
			String pkg = this._data.binaryName();
			int ld = pkg.lastIndexOf('/');
			if (ld >= 0)
				want = pkg.substring(0, ld + 1) + __name;
			
			// Is in default package
			else
				want = __name;
		}
		
		// Open the resource, perhaps
		InputStream rv = ResourceInputStream.open(injar, want);
		if (rv != null)
			return rv;
		
		// Otherwise, do a traditional back to front search for the resource
		// since it might be in another JAR
		String[] classpath = SuiteAccess.currentClassPath();
		for (int i = classpath.length - 1; i >= 0; i--)
			if (null != (rv = ResourceInputStream.open(classpath[i], want)))
				return rv;
		
		// Not found
		return null;
	}
	
	/**
	 * Returns the class which is the superclass of this class.
	 *
	 * @return The superclass or {@code null} if there is none.
	 * @since 2017/03/29
	 */
	@SuppressWarnings({"unchecked"})
	public Class<? super T> getSuperclass()
	{
		return (Class<? super T>)((Object)this._data.superClass());
	}
	
	/**
	 * Returns {@code true} if this class represents an array type.
	 *
	 * @return {@code true} if this class represents an array type.
	 * @since 2016/06/16
	 */
	public boolean isArray()
	{
		// Guess what! Every array starts with with brackets so this is quite
		// easily something which can be determined from the classname
		return this._data.binaryName().startsWith("[");
	}
	
	/**
	 * Checks if the given class can be assigned to this one, the check is
	 * in the same order as {@link #instanceOf(Object)} that is
	 * {@code a.getClass().isAssignableFrom(b.getClass()) == (a instanceof b)}.
	 *
	 * @param __cl The other class type.
	 * @return If the otehr class can be assigned to this one.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/27
	 */
	public boolean isAssignableFrom(Class<?> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Go through target superclasses to find this class
		for (Class<?> r = __cl; r != null; r = r._data.superClass())
		{
			if (r == this)
				return true;
		
			// Go through interfaces for the class to find this class
			for (Class<?> i : r._data.interfaceClasses())
				if (i == this)
					return true;
		}
		
		// If this is an array and the other type is an array with the same
		// number of dimensions, then compare the base type so that say
		// Number[] is assignable from Integer[].
		int thisdims = this._data.dimensions(),
			otherdims = __cl._data.dimensions();
		if (thisdims > 0 && thisdims == otherdims)
			if (this.__rootType().isAssignableFrom(__cl.__rootType()))
				return true;
		
		// Not assignable
		return false;
	}
	
	/**
	 * Is this class an interface?
	 *
	 * @return If this is an interface.
	 * @since 2018/11/03
	 */
	public boolean isInterface()
	{
		return (this._data.flags() & ClassFlag.INTERFACE) != 0;
	}
	
	/**
	 * Checks if the given class is an instance of this class.
	 *
	 * @param __o The object to check.
	 * @return If the given object is an instance of this class.
	 * @since 2018/09/27
	 */
	public boolean isInstance(Object __o)
	{
		// Null will never be an instance
		if (__o == null)
			return false;
		
		// This is in the same form
		return this.isAssignableFrom(__o.getClass());
	}
	
	/**
	 * Constructs a new instance of this class.
	 *
	 * @throws InstantiationException If the default constructor cannot be
	 * accessed by the calling method.
	 * @throws IllegalAccessException If the class or constructor could not
	 * be accessed.
	 * @since 2018/12/04
	 */
	@SuppressWarnings({"unchecked"})
	public T newInstance()
		throws InstantiationException, IllegalAccessException
	{
		todo.TODO.note("Implement newInstance() access checks.");
		
		return (T)((Object)this.__newInstance());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Based on the binary name
			String binaryname = this._data.binaryName();
			switch (binaryname)
			{
					// Primitive types have the same binary name
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
				case "long":
				case "float":
				case "double":
					rv = binaryname;
					break;
				
					// Otherwise build a string
				default:
					rv = (this.isInterface() ? "interface " : "class ") +
						this.getName(); 
					break;
			}
			
			// Cache it
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * This checks whether assertions should be **disabled** for this class (or
	 * for the entire package).
	 *
	 * @return The assertions status to use.
	 * @since 2016/10/09
	 */
	private final boolean __checkAssertionStatus()
	{
		// Default to true
		boolean rv = true;
		
		// Determine class name
		String cn = this.getName();
		String prop = Class._ASSERTION_PREFIX + cn;
		
		// Disabled for this class?
		if (Boolean.getBoolean(prop))
			rv = false;
		
		// Disabled for this package?
		else
		{
			// Find last dot, if there is none then this is just the default
			// package so never bother checking the package
			int ld = cn.lastIndexOf('.');
			if (ld > 0 && Boolean.getBoolean(prop.substring(0,
				prop.length() - (cn.length() - ld))))
				rv = false;
		}
		
		// Set as marked
		this._checkedassert = true;
		this._useassert = rv;
		return rv;
	}
	
	/**
	 * Returns the class data.
	 *
	 * SpringCoat depends on this method to exist.
	 *
	 * @return The class data.
	 * @since 2018/12/05
	 */
	final ClassData __classData()
	{
		return this._data;
	}
	
	/**
	 * Constructs a new instance of this class.
	 *
	 * @throws InstantiationException If the default constructor cannot be
	 * accessed by the calling method.
	 * @throws IllegalAccessException If the class or constructor could not
	 * be accessed.
	 * @since 2018/12/04
	 */
	final Object __newInstance()
		throws InstantiationException, IllegalAccessException
	{
		// Get class details
		ClassData data = this._data;
		String binaryname = data.binaryName();
		
		// {@squirreljme.error ZZ0x Cannot construct new instance of class
		// because it has no default constructor.}
		StaticMethod sm = data.defaultConstructorMethod();
		if (sm == null)
			throw new InstantiationException("ZZ0x " + binaryname);
		
		// Allocate class instance
		Object rv = ObjectAccess.allocateObject(binaryname);
		
		// {@squirreljme.error ZZ0y Could not allocate new instance.}
		if (rv == null)
			throw new OutOfMemoryError("ZZ0y");
		
		// Call default constructor
		ObjectAccess.invokeStatic(sm, rv);
		
		// All done!
		return rv;
	}
	
	/**
	 * Returns the root type, the base of the component.
	 *
	 * @return The root type of this type.
	 * @since 2018/09/27
	 */
	private final Class<?> __rootType()
	{
		Class<?> rv = this;
		for (Class<?> r = this; r != null; r = r._data.component())
			rv = r;
		return rv;
	}
	
	/**
	 * Locates the class with the given name and returns it, otherwise an
	 * exception is thrown.
	 *
	 * The expected form of the class is a name as is mostly used in the
	 * Java language ({@code some.package.Foo}) and not one that is internal
	 * to the virtual machine except in the case of an array. Inner classes do
	 * not follow dot notation, an inner class is usually separated by a dollar
	 * sign '$'. For example {@code Map.Entry} is {@code java.util.Map$Entry}.
	 *
	 * If an array is requested then it must only be of a primitive type using
	 * a Java internal type descriptor.
	 *
	 * @param __n The name of the class to find.
	 * @return The class with the given name.
	 * @throws ClassNotFoundException If the given class was not found.
	 * @throws NullPointerException If no name was specified.
	 * @since 2016/03/01
	 */
	public static Class<?> forName(String __n)
		throws ClassNotFoundException
	{
		// No class specified
		if (__n == null)
			throw new NullPointerException();
		
		// The name will have to be converted to binary form since that is
		// what is internally used
		Class<?> rv = ObjectAccess.classByName(__n.replace('.', '/'));
		
		// {@squirreljme.error ZZ0z Could not find the specified class. (The
		// name of the class)}
		if (rv == null)
			throw new ClassNotFoundException(String.format("ZZ0z %s", __n));
		return rv;
	}
}

Deleted runt/apis/cldc-compact/java/lang/ClassCastException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a class cannot be cast to another class.
 *
 * @since 2018/12/04
 */
public class ClassCastException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassCastException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassCastException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/ClassFormatError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the format of a class is not valid.
 *
 * @since 2018/12/04
 */
public class ClassFormatError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassFormatError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassFormatError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/ClassNotFoundException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a class has not been found.
 *
 * @since 2018/12/04
 */
public class ClassNotFoundException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ClassNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public ClassNotFoundException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public ClassNotFoundException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * This returns the cause of the exception.
	 *
	 * @return The cause of the exception.
	 * @since 2018/12/04
	 */
	public Throwable getException()
	{
		return this.getCause();
	}
}

Deleted runt/apis/cldc-compact/java/lang/CloneNotSupportedException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when cloning is not supported for the given object.
 *
 * @since 2018/12/04
 */
public class CloneNotSupportedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Cloneable.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This represents an object which may be cloned via the {@link Object#clone()}
 * method.
 *
 * @since 2018/12/07
 */
public interface Cloneable
{
}

Deleted runt/apis/cldc-compact/java/lang/Comparable.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface is used to set two classes as being comparable to other
 * classes.
 *
 * It is not required to but comparisons performed by this interface should
 * be comparable to {@link Object#equals(Object)} so that
 * {@code a.equals(b) == (a.compareTo(b) == 0)}.
 *
 * It is recommended to implement this class so that
 * {@code a.compareTo(b) == -b.compareTo(a)} is true, this makes the
 * comparisons consistent. However this might not be feasible for speed
 * purposes so it is highly recommended to at least have comparible negative,
 * zero, and positive.
 *
 * @param <T> The type to compare.
 * @since 2018/09/19
 */
public interface Comparable<T>
{
	/**
	 * Compares this instance to the argument passed, 
	 *
	 * Note that {@code NullPointerException} should be thrown for {@code __b}
	 * since {@code __b.compareTo(this)} would thrown an exception.
	 *
	 * @param __b The object to compare against.
	 * @return The result of the comparison, negative values mean
	 * {@code this < __b}, zero means {@code this == __b}, and positive values
	 * mean {@code this > __b}.
	 * @since 2018/09/19
	 */
	public abstract int compareTo(T __b);
}


Deleted runt/apis/cldc-compact/java/lang/Deprecated.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which may be attached to classes, fields,
 * and methods to indicate that it should no longer be used in the future and
 * alternatives should be searched for and used instead.
 *
 * @since 2016/04/12
 */
@Documented
@Retention(value=RetentionPolicy.RUNTIME)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface Deprecated
{
}

Deleted runt/apis/cldc-compact/java/lang/Double.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237













































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

public final class Double
	extends Number
	implements Comparable<Double>
{
	public static final int MAX_EXPONENT =
		1023;
	
	public static final double MAX_VALUE =
		+0x1.FFFFFFFFFFFFFp1023D;
	
	public static final int MIN_EXPONENT =
		-1022;
	
	public static final double MIN_NORMAL =
		+0x1.0p-1022D;
	
	public static final double MIN_VALUE =
		+0x0.0000000000001p-1022D;
	
	public static final double NEGATIVE_INFINITY =
		-1.0D / 0.0D;
	
	public static final double NaN =
		0.0D / 0.0D;
	
	public static final double POSITIVE_INFINITY =
		1.0D / 0.0D;
	
	/** The number of bits double requires for storage. */
	public static final int SIZE =
		64;
	
	/** The class representing the primitive type. */
	public static final Class<Double> TYPE =
		ObjectAccess.<Double>classByNameType("double");
	
	/** The mask for NaN values. */
	private static final long _NAN_MASK =
		0b0111111111111000000000000000000000000000000000000000000000000000L;
	
	/** The value for this double. */
	private final double _value;
	
	public Double(double __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public Double(String __a)
		throws NumberFormatException
	{
		super();
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Double __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int hashCode()
	{
		long v = this.doubleToLongBits(this._value); 
		return (int)(v ^ (v >>> 32));
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInfinite()
	{
		throw new todo.TODO();
	}
	
	public boolean isNaN()
	{
		throw new todo.TODO();
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static int compare(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the bits which represent the double value with all NaN values
	 * collapsed into a single form.
	 *
	 * @param __v The input value.
	 * @return The bits for the value.
	 * @since 2018/11/04
	 */
	public static long doubleToLongBits(double __v)
	{
		long raw = Double.doubleToRawLongBits(__v);
		
		// Collapse all NaN values to a single form
		if ((raw & _NAN_MASK) == (_NAN_MASK))
			return _NAN_MASK;
		
		return raw;
	}
	
	/**
	 * Returns the raw bits which represent the double value.
	 *
	 * @param __v The input value.
	 * @return The raw bits for the value.
	 * @since 2018/11/03
	 */
	public static long doubleToRawLongBits(double __v)
	{
		return Assembly.doubleToRawLongBits(__v);
	}
	
	public static boolean isInfinite(double __a)
	{
		throw new todo.TODO();
	}
	
	public static boolean isNaN(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the given long bits to a double.
	 *
	 * Note that this value might be modified depending on the platform if
	 * the platform based conversion cannot handle signaling NaNs or illegal
	 * floating point values.
	 *
	 * @param __b The bits to convert.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static double longBitsToDouble(long __b)
	{
		return Assembly.longBitsToDouble(__b);
	}
	
	public static double parseDouble(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static String toString(double __a)
	{
		throw new todo.TODO();
	}
	
	public static Double valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Double valueOf(double __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/lang/Enum.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
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
191
192
193
194
195
196




































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.lang.ClassData;

/**
 * This is the base class for enum types.
 *
 * @param <E> The enum type.
 * @since 2018/09/24
 */
public abstract class Enum<E extends Enum<E>>
	implements Comparable<E>
{
	/** The name of the enum. */
	private final String _name;
	
	/** The ordinal of the enumeration. */
	private final int _ordinal;
	
	/**
	 * Initializes the enum properties.
	 *
	 * @param __s The enum name.
	 * @param __o The enum ordinal.
	 * @throws IllegalArgumentException If the ordinal is negative.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/24
	 */
	protected Enum(String __s, int __o)
		throws IllegalArgumentException, NullPointerException
	{
		// {@squirreljme.error ZZ10 Enum has no string.}
		if (__s == null)
			throw new NullPointerException("ZZ10");
		
		// {@squirreljme.error ZZ11 Enum has negative ordinal.}
		if (__o < 0)
			throw new IllegalArgumentException("ZZ11");
		
		this._name = __s;
		this._ordinal = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	protected final Object clone()
		throws CloneNotSupportedException
	{
		// {@squirreljme.error ZZ12 Enums cannot be cloned.}
		throw new CloneNotSupportedException("ZZ12");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int compareTo(E __o)
		throws ClassCastException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ13 Cannot compare enums of a different
		// type.}
		if (this.getDeclaringClass() != __o.getDeclaringClass())
			throw new ClassCastException("ZZ13");
		
		// Just ordinal subtraction
		return this.ordinal() - __o.ordinal();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class that declares this enum, this may be different from
	 * {@link Object#getClass()}.
	 *
	 * @return The declaring class of this enum.
	 * @since 2018/09/24
	 */
	@SuppressWarnings({"unchecked"})
	public final Class<E> getDeclaringClass()
	{
		// Enums are either directly extending or extending a base class which
		// then extends this class, so we just need to look a few places up
		// the tree
		Class<?> me = this.getClass(),
			ext = me.getSuperclass();
		if (ext == Enum.class)
			return (Class<E>)((Object)me);
		return (Class<E>)((Object)ext);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int hashCode()
	{
		return super.hashCode();
	}
	
	/**
	 * Returns the name of the constant.
	 *
	 * @return The constant name.
	 * @since 2018/09/24
	 */
	public final String name()
	{
		return this._name;
	}
	
	/**
	 * Returns the ordinal of the constant.
	 *
	 * @return The ordinal constant.
	 * @since 2018/09/24
	 */
	public final int ordinal()
	{
		return this._ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public String toString()
	{
		return this._name;
	}
	
	/**
	 * From the given enumeration, find a value which matches the given name.
	 *
	 * @param <T> The enumeration type to search in.
	 * @param __cl The class to lookup.
	 * @param __s The string to search for.
	 * @return The enumeration value.
	 * @throws IllegalArgumentException If the value was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static <T extends Enum<T>> T valueOf(Class<T> __cl, String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Get the data for this class because the enum information will be
		// in here somewhere
		ClassData data = ObjectAccess.classData(__cl);
		
		// {@squirreljme.error ZZ14 Cannot get the value of a non-enumeration
		// type or it has no implicit {@code values()} method.}
		StaticMethod getvalues = data.enumValues();
		if (getvalues == null)
			throw new ClassCastException("ZZ14");
		
		// Go through and check all the names
		for (Enum e : (Enum[])ObjectAccess.invokeStatic(getvalues))
			if (__s.equals(e.name()))
				return __cl.cast(e);
		
		// {@squirreljme.error ZZ15 Not an enumeration value. (The value)}
		throw new IllegalArgumentException(String.format("ZZ15 %s", __s));
	}
}

Deleted runt/apis/cldc-compact/java/lang/Error.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is the base class for non-checked errors.
 *
 * @since 2016/02/26
 */
public class Error
	extends Throwable
{
	/**
	 * Initializes the error with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Error()
	{
	}
	
	/**
	 * Initializes the error with a message and no cause.
	 *
	 * @param __m The message to use.
	 * @since 2018/09/16
	 */
	public Error(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with a message and the given cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause of this error.
	 * @since 2018/09/16
	 */
	public Error(String __m, Throwable __t)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with no message and the given cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause of this error.
	 * @since 2018/09/16
	 */
	public Error(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Exception.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * For any exceptions which extend this class and not {@link RuntimeException}
 * they will act as checked exceptions by the compiler, thus they will need
 * to be handled accordingly.
 *
 * @since 2018/09/16
 */
public class Exception
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Exception()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public Exception(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Float.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298










































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

public final class Float
	extends Number
	implements Comparable<Float>
{
	public static final int MAX_EXPONENT =
		127;
	
	public static final float MAX_VALUE =
		+0x1.FFFFFEp127F;
	
	public static final int MIN_EXPONENT =
		-126;
	
	public static final float MIN_NORMAL =
		+0x1.0p-126F;
	
	public static final float MIN_VALUE =
		+0x1.0p-149F;
	
	public static final float NEGATIVE_INFINITY =
		-1.0F / 0.0F;
	
	public static final float NaN =
		0.0F / 0.0F;
	
	public static final float POSITIVE_INFINITY =
		1.0F / 0.0F;
	
	/** The number of bits float requires for storage. */
	public static final int SIZE =
		32;
	
	/** The mask for NaN values. */
	private static final int _NAN_MASK =
		0b0111_1111_1000_0000_0000_0000_0000_0000;
	
	/** The class representing the primitive type. */
	public static final Class<Float> TYPE =
		JVMFunction.<Float>jvmLoadClass(Assembly.classInfoOfFloat());
	
	/** The stored value. */
	private final float _value;
	
	/**
	 * Stores the specified float.
	 *
	 * @param __v The value to store.
	 * @since 2018/11/04
	 */
	public Float(float __v)
	{
		this._value = __v;
	}
	
	public Float(double __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public Float(String __a)
		throws NumberFormatException
	{
		super();
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Float __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	@ProgrammerTip("NaN values are equal to each other, positive and " +
		"negative zero are not equal to each other.")
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Float))
			return false;
		
		float a = this._value,
			b = ((Float)__o)._value;
		
		// Both values are NaN, consider it equal
		if (Float.isNaN(a) && Float.isNaN(b))
			return true;
		
		// If both values are zero, the sign is important
		int ra = Float.floatToRawIntBits(a),
			rb = Float.floatToRawIntBits(b);
		if ((ra & 0x7FFFFFFF) == 0 && (rb & 0x7FFFFFFF) == 0)
			return ra == rb;
		
		// Otherwise standard comparison
		return a == b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public float floatValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int hashCode()
	{
		return Float.floatToIntBits(this._value);
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInfinite()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this the NaN value.
	 *
	 * @return If this is the NaN value.
	 * @since 2018/11/04
	 */
	public boolean isNaN()
	{
		return Float.isNaN(this._value);
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static int compare(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the specified float into its integer bit form with NaNs losing
	 * all their signaling and turning into non-signaling NaNs.
	 *
	 * @param __v The value the get the bit representation of.
	 * @return The bit representation of the float.
	 * @since 2018/11/04
	 */
	public static int floatToIntBits(float __v)
	{
		int raw = Float.floatToRawIntBits(__v);
		
		// Collapse all NaN values to a single form
		if ((raw & _NAN_MASK) == (_NAN_MASK))
			return _NAN_MASK;
		
		return raw;
	}
	
	/**
	 * Converts the specified float into its raw integer bit form.
	 *
	 * @param __v The input value.
	 * @return The bits that make up the float.
	 * @since 2018/11/04
	 */
	public static int floatToRawIntBits(float __v)
	{
		return Assembly.floatToRawIntBits(__v);
	}
	
	/**
	 * Converts the specified integer bits into a floating point value.
	 *
	 * Note that this value might be modified depending on the platform if
	 * the platform based conversion cannot handle signaling NaNs or illegal
	 * floating point values.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static float intBitsToFloat(int __b)
	{
		return Assembly.intBitsToFloat(__b);
	}
	
	public static boolean isInfinite(float __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is the specified value a NaN?
	 *
	 * @param __v The value to check.
	 * @return If it is NaN or not.
	 * @since 2018/11/04
	 */
	public static boolean isNaN(float __v)
	{
		return (Float.floatToRawIntBits(__v) & _NAN_MASK) == _NAN_MASK;
	}
	
	public static float parseFloat(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static String toString(float __a)
	{
		throw new todo.TODO();
	}
	
	public static Float valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the boxed representation of the given float.
	 *
	 * @param __v The float value.
	 * @return The boxed float.
	 * @since 2018/11/04
	 */
	public static Float valueOf(float __v)
	{
		return new Float(__v);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IllegalAccessException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when access is denied.
 *
 * @since 2018/12/04
 */
public class IllegalAccessException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalAccessException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalAccessException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IllegalArgumentException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the argument of a method is not correct.
 *
 * @since 2018/10/12
 */
public class IllegalArgumentException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public IllegalArgumentException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IllegalMonitorStateException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is usually thrown when an attempt is made to use a monitor which is
 * not owned by the current thread.
 *
 * @since 2018/12/04
 */
public class IllegalMonitorStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IllegalStateException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a certain state is invalid.
 *
 * @since 2018/12/04
 */
public class IllegalStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IllegalThreadStateException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the state of a thread is not valid.
 *
 * @since 2018/02/21
 */
public class IllegalThreadStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message.
	 *
	 * @since 2018/02/21
	 */
	public IllegalThreadStateException()
	{
	}
	
	/**
	 * Initializes the exception with the specified message.
	 *
	 * @param __m The message to use.
	 * @since 2018/02/21
	 */
	public IllegalThreadStateException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IncompatibleClassChangeError.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a class has changed and when that change is no longer
 * compatible.
 *
 * @since 2018/12/04
 */
public class IncompatibleClassChangeError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IncompatibleClassChangeError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public IncompatibleClassChangeError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/IndexOutOfBoundsException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an index which is not within bounds was accessed.
 *
 * @since 2018/09/16
 */
public class IndexOutOfBoundsException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public IndexOutOfBoundsException()
	{
		super();
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public IndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/InstantiationException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an instance could not be instantiated.
 *
 * @since 2018/12/04
 */
public class InstantiationException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public InstantiationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public InstantiationException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Integer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663























































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a boxed {@code int} value.
 *
 * @since 2019/05/11
 */
public final class Integer
	extends Number
	implements Comparable<Integer>
{
	/** The maximum value. */
	public static final int MAX_VALUE =
		2147483647;
	
	/** The minimum value. */
	public static final int MIN_VALUE =
		-2147483648;
	
	/** The number of bits this uses. */
	public static final int SIZE =
		32;
	
	/** The class type representing the primitive type. */
	public static final Class<Integer> TYPE =
		ObjectAccess.<Integer>classByNameType("int");
	
	/** The value of this integer. */
	private final int _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the integer with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Integer(int __v)
	{
		this._value = __v;
	}
	
	/**
	 * Parses the given string and initializes the integer value, it is
	 * parsed the same as {@code Integer.parseInt(__v, 10)}.
	 *
	 * @param __v The value to parse.
	 * @throws NullPointerException On null arguments.
	 * @throws NumberFormatException If the number is not valid.
	 * @since 2019/05/11
	 */
	public Integer(String __v)
		throws NullPointerException, NumberFormatException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this._value = Integer.parseInt(__v, 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public byte byteValue()
	{
		return (byte)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/10
	 */
	@Override
	public int compareTo(Integer __b)
	{
		int a = this._value,
			b = __b._value;
			
		if (a == b)
			return 0;
		else if (a < b)
			return -1;
		else
			return 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public double doubleValue()
	{
		return (double)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Integer))
			return false;
		
		return this._value == ((Integer)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public float floatValue()
	{
		return (float)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/02
	 */
	@Override
	public int hashCode()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/12
	 */
	@Override
	public int intValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/11
	 */
	@Override
	public short shortValue()
	{
		return (short)this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Integer.toString(this._value)));
		
		return rv;
	}
	
	/**
	 * Returns the number of bits which are in the value, this is the
	 * population count.
	 *
	 * @param __v The value to count.
	 * @return The number of bits set in the value.
	 * @since 2018/11/11
	 */
	public static int bitCount(int __v)
	{
		__v = __v - ((__v >>> 1) & 0x55555555);
		__v = (__v & 0x33333333) + ((__v >>> 2) & 0x33333333);
		return ((__v + (__v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24;
	}
	
	/**
	 * Decodes the input string for an integer value.
	 *
	 * There is an optional sign: {@code -} or {@code +}.
	 *
	 * Then the number may be prefixed by:
	 * {@code 0x}, {@code 0X}, or {@code #} for hexadecimal,
	 * {@code 0} for octal. If there is no prefix then the number is treated
	 * as decimal.
	 *
	 * @param __s The input string to decode.
	 * @return The decoded integer.
	 * @throws NullPointerException On null arguments.
	 * @throws NumberFormatException If the string is of an incorrect value.
	 * @since 2018/11/11
	 */
	public static Integer decode(String __s)
		throws NullPointerException, NumberFormatException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ16 Cannot decode an empty string.}
		if (__s.isEmpty())
			throw new NumberFormatException("ZZ16");
		
		// It may be changed!
		String orig = __s;
		
		// Check for sign, assume positive otherwise
		char sign = __s.charAt(0);
		if (sign != '-' && sign != '+')
			sign = '+';
		
		// Remove the sign
		else
			__s = __s.substring(1);
		
		// Which number format?
		int radix;
		if (__s.startsWith("0x") || __s.startsWith("0X"))
		{
			radix = 16;
			__s = __s.substring(2);
		}
		else if (__s.startsWith("#"))
		{
			radix = 16;
			__s = __s.substring(1);
		}
		else if (__s.startsWith("0"))
		{
			radix = 8;
			__s = __s.substring(1);
		}
		else
			radix = 10;
		
		// {@squirreljme.error ZZ17 Misplaced sign. (The input string)}
		if (__s.startsWith("-") || __s.startsWith("+"))
			throw new NumberFormatException("ZZ2p " + orig);
		
		// Decode value with radix
		try
		{
			return Integer.parseInt(sign + __s, radix);
		}
		
		// {@squirreljme.error ZZ18 Could not parse number. (The input string)}
		catch (NumberFormatException e)
		{
			RuntimeException t = new NumberFormatException("ZZ18 " + orig);
			t.initCause(e);
			throw t;
		}
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key)
		throws NumberFormatException, SecurityException
	{
		return Integer.getInteger(__key, null);
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @param __def The default value.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key, int __def)
		throws NumberFormatException, SecurityException
	{
		Integer rv = Integer.getInteger(__key, null);
		if (rv == null)
			return __def;
		return rv;
	}
	
	/**
	 * Obtains the integer value of a system property.
	 *
	 * @param __key The system property to get.
	 * @param __def The default value.
	 * @return The value or {@code null} if it is not an integer.
	 * @throws NumberFormatException If the property does not contain a
	 * valid number.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/11/11
	 */
	public static Integer getInteger(String __key, Integer __def)
		throws NumberFormatException, SecurityException
	{
		// If there is no property, use the default
		String prop = System.getProperty(__key);
		if (prop == null)
			return __def;
		
		// Otherwise decode the value
		return Integer.decode(prop);
	}
	
	public static int highestOneBit(int __a)
	{
		throw new todo.TODO();
	}
	
	public static int lowestOneBit(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of leading zeros in the bit representation.
	 *
	 * @param __v The value to process.
	 * @return The number of leading zeros.
	 * @since 2019/04/14
	 */
	public static int numberOfLeadingZeros(int __v)
	{
		// From https://stackoverflow.com/a/23857066/11286149
		__v = __v | (__v >>> 1);
		__v = __v | (__v >>> 2);
		__v = __v | (__v >>> 4);
		__v = __v | (__v >>> 8);
		__v = __v | (__v >>> 16);
		
		return Integer.bitCount(~__v);
	}
	
	/**
	 * Returns the number of zeros which trail on the right side.
	 *
	 * @param __v The value to check.
	 * @return The number of trailing zeros.
	 * @since 2018/11/11
	 */
	public static int numberOfTrailingZeros(int __v)
	{
		// c will be the number of zero bits on the right
		int c = 32;
		__v &= -__v;
		
		if ((__v) != 0)
			c--;
		
		if ((__v & 0x0000FFFF) != 0)
			c -= 16;
			
		if ((__v & 0x00FF00FF) != 0)
			c -= 8;
		
		if ((__v & 0x0F0F0F0F) != 0)
			c -= 4;
		
		if ((__v & 0x33333333) != 0)
			c -= 2;
		
		if ((__v & 0x55555555) != 0)
			c -= 1;
		
		return c;
	}
	
	/**
	 * Returns the value of the specified string using the given radix.
	 *
	 * @param __v The String to decode.
	 * @param __r The radix to use.
	 * @throws NumberFormatException If the string is not valid or the radix
	 * is outside of the valid bounds.
	 * @since 2018/10/12
	 */
	public static int parseInt(String __v, int __r)
		throws NumberFormatException
	{
		// {@squirreljme.error ZZ19 The radix is out of bounds. (The radix)}
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			throw new NumberFormatException("ZZ19 " + __r);
		
		// {@squirreljme.error ZZ1a String is null or has zero length.}
		int n = __v.length();
		if (__v == null || n <= 0)
			throw new NumberFormatException("ZZ1a");
		
		// Detect sign
		boolean neg = false,
			signed = false;
		char c = __v.charAt(0);
		if ((neg = (c == '-')) || c == '+')
			signed = true;
		
		// If the number is negative, instead of negating the value at the end
		// just subtract digits instead.
		int digsign = (neg ? -1 : 1);
		
		// Read all digits
		int rv = 0;
		for (int i = (signed ? 1 : 0); i < n; i++)
		{
			// Read character
			c = __v.charAt(i);
			
			// Convert to digit
			int dig = Character.digit(c, __r);
			
			// {@squirreljme.error ZZ1b Character out of range of radix.
			// (The input string; The out of range character)}
			if (dig < 0)
				throw new NumberFormatException("ZZ1b " + __v + " " + c);
			
			// {@squirreljme.error ZZ1c Input integer out of range of 32-bit
			// integer. (The input string)}
			int prod = rv * __r;
			if (rv != 0 && (neg ? (prod > rv) : (prod < rv)))
				throw new NumberFormatException("ZZ1c " + __v);
			
			// Add up
			rv = prod + (dig * digsign);
		}
		
		return rv;
	}
	
	/**
	 * Returns the value of the specified string.
	 *
	 * @param __v The String to decode.
	 * @throws NumberFormatException If the string is not valid.
	 * @since 2018/10/12
	 */
	public static int parseInt(String __v)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, 10);
	}
	
	/**
	 * Reverses all of the bits in the given integer.
	 *
	 * @param __i The input value.
	 * @return The integer but with the bits reversed.
	 * @since 2018/11/11
	 */
	@ImplementationNote("Taken from " +
		"<http://aggregate.org/MAGIC/#Bit%20Reversal>.")
	public static int reverse(int __i)
	{
		__i = (((__i & 0xAAAAAAAA) >>> 1) | ((__i & 0x55555555) << 1));
		__i = (((__i & 0xCCCCCCCC) >>> 2) | ((__i & 0x33333333) << 2));
		__i = (((__i & 0xF0F0F0F0) >>> 4) | ((__i & 0x0F0F0F0F) << 4));
		__i = (((__i & 0xFF00FF00) >>> 8) | ((__i & 0x00FF00FF) << 8));
		
		return ((__i >>> 16) | (__i << 16));
	}
	
	public static int reverseBytes(int __i)
	{
		throw new todo.TODO();
	}
	
	public static int rotateLeft(int __i, int __d)
	{
		throw new todo.TODO();
	}
	
	public static int rotateRight(int __i, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the sign of the given integer value, this will be {@code -1}
	 * for negative values, {@code 0} for zero, and {@code 1} for positive
	 * values.
	 *
	 * @param __v The value to get the sign for.
	 * @return The sign of the given value.
	 * @since 2019/05/11
	 */
	public static int signum(int __v)
	{
		if (__v < 0)
			return -1;
		else if (__v > 1)
			return 1;
		else
			return 0;
	}
	
	public static String toBinaryString(int __a)
	{
		throw new todo.TODO();
	}
	
	public static String toHexString(int __a)
	{
		throw new todo.TODO();
	}
	
	public static String toOctalString(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(int __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Calls {@link Integer#toStirng(long, int)} with a radix of 10.
	 *
	 * @param __v The input value.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(int __v)
	{
		return Integer.toString(__v, 10);
	}
	
	/**
	 * Returns the value of the specified string using the given radix.
	 *
	 * @param __v The String to decode.
	 * @param __r The radix to use.
	 * @throws NumberFormatException If the string is not valid or the radix
	 * is outside of the valid bounds.
	 * @since 2018/10/12
	 */
	public static Integer valueOf(String __v, int __r)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, __r);
	}
	
	/**
	 * Returns the value of the specified string.
	 *
	 * @param __v The String to decode.
	 * @throws NumberFormatException If the string is not valid.
	 * @since 2018/10/12
	 */
	public static Integer valueOf(String __v)
		throws NumberFormatException
	{
		return Integer.parseInt(__v, 10);
	}
	
	/**
	 * Returns a instance of the given value, this may be cached.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/09/23
	 */
	@ImplementationNote("This is not cached.")
	public static Integer valueOf(int __v)
	{
		return new Integer(__v);
	}
}

Deleted runt/apis/cldc-compact/java/lang/InterruptedException.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a thread is interrupted.
 *
 * Note that this does not clear the interrupt status of a thread.
 *
 * @since 2018/11/21
 */
public class InterruptedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/21
	 */
	public InterruptedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/21
	 */
	public InterruptedException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Iterable.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.util.Iterator;

/**
 * This represents a class which can be iterated through giving one or more
 * values.
 *
 * @param <T> The type this returns.
 * @since 2018/12/08
 */
public interface Iterable<T>
{
	/**
	 * Returns the iterator over the object.
	 *
	 * @return The object iterator.
	 * @since 2018/12/08
	 */
	public abstract Iterator<T> iterator();
}

Deleted runt/apis/cldc-compact/java/lang/LinkageError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a class could not be linked into the virtual machine.
 *
 * @since 2018/12/04
 */
public class LinkageError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public LinkageError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public LinkageError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Long.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389





































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

public final class Long
	extends Number
	implements Comparable<Long>
{
	/** The maximum value. */
	public static final long MAX_VALUE =
		9223372036854775807L;
	
	/** The minimum value. */
	public static final long MIN_VALUE =
		-9223372036854775808L;
	
	/** The size of the type in bits. */
	public static final int SIZE =
		64;
	
	/** The class representing the primitive long type. */
	public static final Class<Long> TYPE =
		ObjectAccess.<Long>classByNameType("long");
	
	/** The value of this long. */
	private final long _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Initializes the long with the given value.
	 *
	 * @param __v The value to use.
	 * @since 2018/09/23
	 */
	public Long(long __v)
	{
		this._value = __v;
	}
	
	public Long(String __a)
		throws NumberFormatException
	{
		super();
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Long __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Long))
			return false;
		
		return this._value == ((Long)__o)._value;
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/03
	 */
	@Override
	public long longValue()
	{
		return this._value;
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Long.toString(this._value)));
		
		return rv;
	}
	
	public static int bitCount(long __a)
	{
		throw new todo.TODO();
	}
	
	public static Long decode(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a)
	{
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static Long getLong(String __a, Long __b)
	{
		throw new todo.TODO();
	}
	
	public static long highestOneBit(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long lowestOneBit(long __a)
	{
		throw new todo.TODO();
	}
	
	public static int numberOfLeadingZeros(long __a)
	{
		throw new todo.TODO();
	}
	
	public static int numberOfTrailingZeros(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long parseLong(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static long parseLong(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static long reverse(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long reverseBytes(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long rotateLeft(long __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static long rotateRight(long __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static int signum(long __a)
	{
		throw new todo.TODO();
	}
	
	public static long sum(long __a, long __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a string of the given value in binary.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toBinaryString(long __v)
	{
		return Long.__unsignedString(__v, 2);
	}
	
	/**
	 * Returns a string of the given value in hexadecimal.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toHexString(long __v)
	{
		return Long.__unsignedString(__v, 16);
	}
	
	/**
	 * Returns a string of the given value in octal.
	 *
	 * @param __v The value.
	 * @return The representing string.
	 * @since 2019/12/25
	 */
	public static String toOctalString(long __v)
	{
		return Long.__unsignedString(__v, 8);
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(long __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Calls {@link Long#toStirng(long, int)} with a radix of 10.
	 *
	 * @param __v The input value.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(long __v)
	{
		return Long.toString(__v, 10);
	}
	
	public static Long valueOf(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Long valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Returns a instance of the given value, this may be cached.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/09/23
	 */
	@ImplementationNote("This is not cached.")
	public static Long valueOf(long __v)
	{
		return new Long(__v);
	}
	
	/**
	 * Returns an unsigned string of the given number and base.
	 *
	 * @param __v The value to translate.
	 * @param __b The number base.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	private static final String __unsignedString(long __v, int __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/cldc-compact/java/lang/Math.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.FDMLMath;

/**
 * This class contains mathematical functions.
 *
 * @since 2018/12/08
 */
@ImplementationNote("This class uses strict floating point.")
public strictfp final class Math
{
	/** E. */
	public static final double E =
		+0x1.5BF0A8B145769p1D;
	
	/** Pi. */
	public static final double PI =
		+0x1.921FB54442D18p1D;
	
	/**
	 * Not used.
	 *
	 * @since 2018/12/08
	 */
	private Math()
	{
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static int abs(int __v)
	{
		return (__v < 0 ? -__v : __v);
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static long abs(long __v)
	{
		return (__v < 0 ? -__v : __v);
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static float abs(float __v)
	{
		return Float.intBitsToFloat(0x7FFFFFFF & Float.floatToIntBits(__v));
	}
	
	/**
	 * Returns the absolute value.
	 *
	 * @return The absolute value.
	 * @since 2019/04/14
	 */
	public static double abs(double __v)
	{
		return Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL &
			Double.doubleToLongBits(__v));
	}
	
	public static double acos(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double asin(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double atan(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double atan2(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static double ceil(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double copySign(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static float copySign(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static double cos(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double floor(double __a)
	{
		throw new todo.TODO();
	}
	
	public static int getExponent(float __a)
	{
		throw new todo.TODO();
	}
	
	public static int getExponent(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the logarithm of the given number.
	 *
	 * This method does not exist in CLDC and is SquirrelJME specified.
	 *
	 * @param __v The value to get the logarithm from.
	 * @return The logarithm for the given value.
	 * @since 2018/11/03
	 */
	@Deprecated
	@ImplementationNote("This method does not exist in the CLDC library.")
	public static double log(double __v)
	{
		return FDMLMath.log(__v);
	}
	
	/**
	 * Returns the higher of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The higher value.
	 * @since 2018/09/29
	 */
	public static int max(int __a, int __b)
	{
		if (__a > __b)
			return __a;
		return __b;
	}
	
	public static long max(long __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static float max(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static double max(double __a, double __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/09/29
	 */
	public static int min(int __a, int __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static long min(long __a, long __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static float min(float __a, float __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/12/08
	 */
	public static double min(double __a, double __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
	
	public static double random()
	{
		throw new todo.TODO();
	}
	
	public static int round(float __a)
	{
		throw new todo.TODO();
	}
	
	public static long round(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double signum(double __a)
	{
		throw new todo.TODO();
	}
	
	public static float signum(float __a)
	{
		throw new todo.TODO();
	}
	
	public static double sin(double __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the square root of the given number.
	 *
	 * @return __v The value to get the square root for.
	 * @since 2018/11/03
	 */
	public static double sqrt(double __v)
	{
		return FDMLMath.sqrt(__v);
	}
	
	public static double tan(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double toDegrees(double __a)
	{
		throw new todo.TODO();
	}
	
	public static double toRadians(double __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/lang/NegativeArraySizeException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an attempt is made to allocate an array that is of a
 * negative size.
 *
 * @since 2018/09/22
 */
public class NegativeArraySizeException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/22
	 */
	public NegativeArraySizeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/22
	 */
	public NegativeArraySizeException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/NoClassDefFoundError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when no class definition was found.
 *
 * @since 2018/12/04
 */
public class NoClassDefFoundError
	extends LinkageError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NoClassDefFoundError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public NoClassDefFoundError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/NoSuchFieldError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a field in a class does not exist.
 *
 * @since 2018/12/04
 */
public class NoSuchFieldError
	extends IncompatibleClassChangeError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NoSuchFieldError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public NoSuchFieldError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/NullPointerException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown by the virtual machine when an attempt is made to read from
 * a reference which is {@code null}.
 *
 * @since 2016/02/26
 */
public class NullPointerException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public NullPointerException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public NullPointerException(String __m)
	{
		super(__m);
	}
}


Deleted runt/apis/cldc-compact/java/lang/Number.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * A number represents any kind of number which may be transformed to other
 * types for those numbers.
 *
 * Note that any of these methods may result in values which lose their sign,
 * significant bits, or the value itself. Most classes will likely implement
 * these using narrowing conversions that match the Java language.
 *
 * @since 2018/09/23
 */
public abstract class Number
{
	/**
	 * Initializes the base number.
	 *
	 * @since 2018/09/23
	 */
	public Number()
	{
	}
	
	/**
	 * Returns the value of this number converted as a double.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract double doubleValue();
	
	/**
	 * Returns the value of this number converted as a float.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract float floatValue();
	
	/**
	 * Returns the value of this number converted as an integer.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract int intValue();
	
	/**
	 * Returns the value of this number converted as a long.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public abstract long longValue();
	
	/**
	 * Returns the value of this number converted as a byte.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public byte byteValue()
	{
		return (byte)this.intValue();
	}
	
	/**
	 * Returns the value of this number converted as a short.
	 *
	 * @return The converted value of this number.
	 * @since 2018/09/23
	 */
	public short shortValue()
	{
		return (short)this.intValue();
	}
}

Deleted runt/apis/cldc-compact/java/lang/NumberFormatException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the format of a number is not correct.
 *
 * @since 2018/10/12
 */
public class NumberFormatException
	extends IllegalArgumentException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public NumberFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public NumberFormatException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Object.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * This class is the root of all class trees in Java.
 *
 * @since 2016/02/08
 */
@ImplementationNote("The Java compiler does not allow any final fields to " +
	"exist in Object and if they are set via assignment no code will be " +
	"generated for them, so as such Object effectively has no fields.")
public class Object
{
	/**
	 * Initializes the base object.
	 *
	 * @since 2018/09/09
	 */
	@ImplementationNote("The Java compiler does not allow final fields " +
		"in Object to be set, they are already treated as already being " +
		"set.")
	public Object()
	{
	}
	
	/**
	 * Clones the current copy creating a shallow copy of it if
	 * {@code Cloneable} is implemented, unless this method is overridden to
	 * perform class specific cloning.
	 *
	 * @throws CloneNotSupportedException If cloning is not supported by the
	 * current class, the default implementation always throws this if the
	 * {@link Cloneable} interface does not exist.
	 * @since 2016/02/08
	 */
	protected Object clone()
		throws CloneNotSupportedException
	{
		// If this is an array copy elements around
		Class<?> cl = this.getClass();
		if (cl.isArray())
		{
			// Need length of this array to recreate!
			int len = Assembly.arrayLength(this);
			
			// Allocate new array
			Object dest = ObjectAccess.arrayNew(cl, len);
			
			// Copy everything over
			System.arraycopy(this, 0, dest, 0, len);
			
			// This array was cloned
			return dest;
		}
		
		// {@squirreljme.error ZZ1d This object does not support being cloned.}
		throw new CloneNotSupportedException("ZZ1d");
	}
	
	/**
	 * Checks for equality between this object and another. Equality should be
	 * reflexive (equal to self), symmetric (a is equal to b as b is equal to
	 * a), transitive (a is equal to b, and b is equal to c, then a must be
	 * equal to c), and consistent (if no modifications to the object were made
	 * then it should return the same value returned as the previous call).
	 *
	 * If this method is overriden, then also override {@code hashCode()}.
	 *
	 * @return {@code true} if the two objects are equal.
	 * @since 2016/02/08
	 */
	public boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class object which is associated with this object, this is
	 * the class of the current object.
	 *
	 * @return The current class object.
	 * @since 2016/02/08
	 */
	public final Class<?> getClass()
	{
		return ObjectAccess.classOf(this);
	}
	
	/**
	 * Calculates the hash code for this object.
	 *
	 * If two objects are equal than they must have the same hash code,
	 * otherwise undefined behavior will occur with their potential usage.
	 *
	 * @return The hash code of this object.
	 * @since 2016/02/08
	 */
	public int hashCode()
	{
		return System.identityHashCode(this);
	}
	
	/**
	 * Notifies a single thread which is waiting on this monitor.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @since 2016/02/08
	 */
	public final void notify()
		throws IllegalMonitorStateException
	{
		// {@squirreljme.error ZZ1e This thread does not own the monitor for
		// this thread.}
		if (ObjectAccess.monitorNotify(this, false) < 0)
			throw new IllegalMonitorStateException("ZZ1e");
	}
	
	/**
	 * Notifies all threads which are waiting on this monitor.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @since 2016/02/09
	 */
	public final void notifyAll()
		throws IllegalMonitorStateException
	{
		// {@squirreljme.error ZZ1f This thread does not own the monitor for
		// this thread.}
		if (ObjectAccess.monitorNotify(this, true) < 0)
			throw new IllegalMonitorStateException("ZZ1f");
	}
	
	/**
	 * Returns the string representation of this object.
	 *
	 * The default implementation is {@code classname@hashcode}.
	 *
	 * @return The string representation of this object.
	 * @since 2016/02/09
	 */
	public String toString()
	{
		return this.getClass().getName() + "@" +
			Integer.toString(this.hashCode(), 16);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call.
	 *
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait()
		throws InterruptedException, IllegalMonitorStateException
	{
		this.wait(0, 0);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call, however it will
	 * stop after the given time has elapsed.
	 *
	 * @param __ms The milliseconds to wait for, if this is {@code 0} then this
	 * will wait forever.
	 * @throws IllegalArgumentException If any input time is negative.
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait(long __ms)
		throws IllegalArgumentException, IllegalMonitorStateException,
			InterruptedException
	{
		this.wait(__ms, 0);
	}
	
	/**
	 * Causes the current thread to wait on this object's monitor until
	 * {@link #notify()} or {@link #notifyAll()} has been call, however it will
	 * stop after the given time has elapsed.
	 *
	 * If both {@code __ms} and {@code __ns} are zero, then the wait will be
	 * forever.
	 *
	 * @param __ms The milliseconds to wait for, if this is {@code 0} then this
	 * will wait forever.
	 * @param __ns The number of nanoseconds to additionally wait for.
	 * @throws IllegalArgumentException If any input time is negative or
	 * {@code __ns} is not in the range [0, 999999].
	 * @throws IllegalMonitorStateException If the current thread does not own
	 * the monitor for this object.
	 * @throws InterruptedException If the current thread was interrupted
	 * during the wait.
	 * @since 2016/02/09
	 */
	public final void wait(long __ms, int __ns)
		throws IllegalArgumentException, IllegalMonitorStateException,
			InterruptedException
	{
		// Call wait, but return status can have multiple kind of things
		// going on
		switch (ObjectAccess.monitorWait(this, __ms, __ns))
		{
				// {@squirreljme.error ZZ1g Cannot wait on monitor because
				// this thread does not own the monitor.}
			case ObjectAccess.MONITOR_NOT_OWNED:
				throw new IllegalMonitorStateException("ZZ1g");
			
				// Not interrupted
			case ObjectAccess.MONITOR_NOT_INTERRUPTED:
				return;
			
				// {@squirreljme.error ZZ1h Wait operation has been
				// interrupted.}
			case ObjectAccess.MONITOR_INTERRUPTED:
				Thread.currentThread()._interrupted = false;
				throw new InterruptedException("ZZ1h");
				
				// Should not happen
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/OutOfMemoryError.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the virtual machine is out of memory.
 *
 * @since 2018/12/04
 */
public class OutOfMemoryError
	extends VirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public OutOfMemoryError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public OutOfMemoryError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Override.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which is attached to a method to indicate that
 * it overrides a method in the super class. When the compiler encounters
 * this, it makes sure that it actually overrides a method. If it does not
 * then a compilation error occurs. Using this all the time is recommended when
 * a method is intended to be overidden.
 *
 * As an example, if the base class has the following method:
 *
 * {@code
 * public static int foo(long __a);
 * }
 *
 * And a class which extends the base class has the following method:
 *
 * {@code
 * public static int foo(int __a);
 * }
 *
 * If it is intended to add a new {@code foo} which handles {@code int} instead
 * of {@code long} then this annotation should not be used, however it it is
 * intended to replace it (and specifying {@code int} was a mistake) then this
 * should be used.
 *
 * @since 2016/04/12
 */
@Target(value={ElementType.METHOD})
@Retention(value=RetentionPolicy.SOURCE)
public @interface Override
{
}


Deleted runt/apis/cldc-compact/java/lang/Runnable.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface should be used by any class which is intended and capable
 * of being run in its own thread (via {@link Thread(Runnable)}.
 *
 * When used with {@link Thread}, the method {@link #run()} will be executed
 * when the thread is started.
 *
 * @since 2018/09/19
 */
public interface Runnable
{
	/**
	 * Performs any action that is required as needed.
	 *
	 * @since 2018/09/19
	 */
	public abstract void run();
}

Deleted runt/apis/cldc-compact/java/lang/Runtime.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
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































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This class contains information about the host memory environment along
 * with providing methods to perform garbage collection and exit the
 * virtual machine.
 *
 * @since 2018/10/14
 */
public class Runtime
{
	/** There is only a single instance of the run-time. */
	private static final Runtime _INSTANCE =
		new Runtime();
	
	/**
	 * Not used.
	 *
	 * @since 2018/10/14
	 */
	private Runtime()
	{
	}
	
	/**
	 * Indicates that the application exits with the given code.
	 *
	 * @param __v The exit code, the value of this code may change according
	 * to the host operating system and the resulting process might not exit
	 * with the given code.
	 * @throws SecurityException If exiting is not permitted.
	 * @since 2017/02/08
	 */
	public void exit(int __v)
		throws SecurityException
	{
		// Check that we can exit
		System.getSecurityManager().checkExit(__v);
		
		// Then do the exit if no exception was thrown
		Assembly.sysCall(SystemCallIndex.EXIT, __v);
	}
	
	/**
	 * Returns the amount of memory that is free for the JVM to use.
	 *
	 * @return The amount of free memory.
	 * @since 2018/10/14
	 */
	public long freeMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_FREE);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_FREE))
			return Integer.MAX_VALUE;
		return rv;
	}
	
	/**
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public void gc()
	{
		Assembly.sysCall(SystemCallIndex.GARBAGE_COLLECT);
	}
	
	/**
	 * Returns the maximum amount of memory that the virtual machine will
	 * attempt to use, if there is no limit then {@link Long#MAX_VALUE} will
	 * be used.
	 *
	 * @return The maximum amount of memory available to the virtual machine.
	 * @since 2018/10/14
	 */
	public long maxMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_MAX);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_MAX))
			return Integer.MAX_VALUE;
		return rv;
	}
	
	/**
	 * Returns the total amount of memory that is being used by the virtual
	 * machine. This is a count of all the memory claimed by the virtual
	 * machine itself for its memory pools and such.
	 *
	 * @return The amount of memory being used by the virtual machine.
	 * @since 2018/10/14
	 */
	public long totalMemory()
	{
		int rv = Assembly.sysCallV(SystemCallIndex.VMI_MEM_USED);
		if (0 != SystemCallError.getError(SystemCallIndex.VMI_MEM_USED))
			return 0;
		return rv;
	}
	
	/**
	 * Returns the single instance of this class.
	 *
	 * Only a single runtime is valid and there will only be one.
	 *
	 * @since 2018/03/01
	 */
	public static Runtime getRuntime()
	{
		return Runtime._INSTANCE;
	}
}

Deleted runt/apis/cldc-compact/java/lang/RuntimeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This and all of its sub-classes represents exceptions which are unchecked
 * by the compiler.
 *
 * @since 2018/09/16
 */
public class RuntimeException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public RuntimeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public RuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public RuntimeException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public RuntimeException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/RuntimePermission.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.security.BasicPermission;

/**
 * This is a permission which may be available at runtime.
 *
 * The following permissions are available:
 * {@code "exitVM.(n)"} -- Exiting the VM with the given error code, if
 * an asterisk {@code '*'} is used then any exit code is specified.
 * {@code "setSecurityManager"} -- Setting a new security manager.
 * {@code "createSecurityManager"} -- Creating a new security manager.
 * {@code "setIO"} -- Setting {@link System#out} and {@link System#err}.
 * {@code "modifyThread"} -- Allows one to interrupt threads, set priority,
 * and rename them.
 *
 * @since 2018/09/18
 */
public final class RuntimePermission
	extends BasicPermission
{
	/**
	 * Initializes the permission.
	 *
	 * @param __name The name to check.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public RuntimePermission(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		super(__name);
		
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1i Runtime permission name cannot be empty.}
		if (__name.isEmpty())
			throw new IllegalArgumentException("ZZ1i");
	}
	
	/**
	 * Invokes {@code RuntimePermission(__name)}, the action is not used.
	 *
	 * @param __name The name to check.
	 * @param __act This is ignored.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public RuntimePermission(String __name, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		this(__name);
	}
}

Deleted runt/apis/cldc-compact/java/lang/SecurityException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the security manager has detected a security violation.
 *
 * @see SecurityManager
 * @since 2018/09/18
 */
public class SecurityException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/18
	 */
	public SecurityException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/18
	 */
	public SecurityException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/18
	 */
	public SecurityException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/18
	 */
	public SecurityException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/SecurityManager.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
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















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.security.AccessController;
import java.security.Permission;
import java.util.PropertyPermission;

public class SecurityManager
{
	/** The current security manager, defaults to the system one. */
	static volatile SecurityManager _CURRENT_MANAGER =
		new SecurityManager();
	
	/**
	 * Initializes the security manager, if a security manager already exists
	 * then the
	 *
	 * @throws SecurityException If the manager could not be created.
	 * @since 2018/09/18 
	 */
	public SecurityManager()
		throws SecurityException
	{
		// Lock on this class, since multiple threads cannot mess around with
		// this check
		synchronized (SecurityManager.class)
		{
			// If one already exists, check to see if it can be created first
			SecurityManager current = SecurityManager._CURRENT_MANAGER;
			if (current != null)
				current.checkPermission(
					new RuntimePermission("createSecurityManager"));
		}
	}
	
	public void checkAccept(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks if the given thread may be modified.
	 *
	 * @param __t The thread to check.
	 * @throws SecurityException If threads cannot be modified.
	 * @since 2018/11/21
	 */
	public void checkAccess(Thread __t)
		throws SecurityException
	{
		this.checkPermission(new RuntimePermission("modifyThread"));
	}
	
	public void checkConnect(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void checkDelete(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks that the virtual machine can exit with the given code.
	 *
	 * @param __code The exit code.
	 * @throws SecurityException If exit is not permitted.
	 * @since 2018/10/13
	 */
	public void checkExit(int __code)
		throws SecurityException
	{
		this.checkPermission(new RuntimePermission("exitVM." + __code));
	}
	
	public void checkListen(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given permission is permitted.
	 *
	 * @param __p The permission to check.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If permission is denied.
	 * @since 2018/09/18
	 */
	public void checkPermission(Permission __p)
		throws NullPointerException, SecurityException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		AccessController.checkPermission(__p);
	}
	
	/**
	 * Checks if the given system property can be accessed.
	 *
	 * @param __key The key to check.
	 * @throws IllegalArgumentException If the key is empty.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If access to the property is denied.
	 * @since 2018/09/18
	 */
	public void checkPropertyAccess(String __key)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1j Request to check access to system property
		// with an empty key.}
		if (__key.isEmpty())
			throw new IllegalArgumentException("ZZ1j");
		
		// Forward
		this.checkPermission(new PropertyPermission(__key, "read"));
	}
	
	public void checkRead(String __a)
	{
		throw new todo.TODO();
	}
	
	public void checkWrite(String __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/lang/Short.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210


















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

public final class Short
	extends Number
	implements Comparable<Short>
{
	public static final short MAX_VALUE =
		32767;
	
	public static final short MIN_VALUE =
		-32768;
	
	public static final int SIZE =
		16;
	
	/** The class representing the primitive type. */
	public static final Class<Short> TYPE =
		ObjectAccess.<Short>classByNameType("short");
	
	/** The value of this integer. */
	private final short _value;
	
	/** The string representation of this value. */
	private Reference<String> _string;
	
	/**
	 * Wraps the boxed value.
	 *
	 * @param __v The value to wrap.
	 * @since 2018/11/14
	 */
	public Short(short __v)
	{
		this._value = __v;
	}
	
	public Short(String __a)
		throws NumberFormatException
	{
		super();
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	@Override
	public byte byteValue()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Short __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public double doubleValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public float floatValue()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int intValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public long longValue()
	{
		throw new todo.TODO();
	}
	
	@Override
	public short shortValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Short.toString(this._value)));
		
		return rv;
	}
	
	public static Short decode(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short parseShort(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short parseShort(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static short reverseBytes(short __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the string representation of the short value.
	 *
	 * @param __v The value to represent.
	 * @return The string representation of it.
	 * @since 2018/11/14
	 */
	public static String toString(short __v)
	{
		return Integer.toString(__v, 10);
	}
	
	public static Short valueOf(String __a, int __b)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	public static Short valueOf(String __a)
		throws NumberFormatException
	{
		if (false)
			throw new NumberFormatException();
		throw new todo.TODO();
	}
	
	/**
	 * Boxes the given short value.
	 *
	 * @param __v The value to box.
	 * @return The boxed value.
	 * @since 2018/11/14
	 */
	public static Short valueOf(short __v)
	{
		return new Short(__v);
	}
	
	/**
	 * The {@link #TYPE} field is magically initialized by the virtual machine.
	 *
	 * @return {@link #TYPE}.
	 * @since 2016/06/16
	 */
	private static Class<Short> __getType()
	{
		return TYPE;
	}
}

Deleted runt/apis/cldc-compact/java/lang/String.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;
import cc.squirreljme.runtime.cldc.i18n.DefaultLocale;
import cc.squirreljme.runtime.cldc.i18n.Locale;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.Decoder;
import cc.squirreljme.runtime.cldc.io.Encoder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Formatter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.WeakHashMap;

/**
 * A {@link String} represents a sequence of characters which make up a group
 * of alphanumeric or other symbols and represents text.
 *
 * Note that only {@link #toLowerCase()} and {@link #toUpperCase()} take
 * locale into considering during their conversion.
 *
 * @since 2018/09/16
 */
public final class String
	implements Comparable<String>, CharSequence
{
	/** The minumum trim character. */
	private static final char _MIN_TRIM_CHAR =
		' ';
	
	/** Is this string already lowercased? */
	private static final short _QUICK_ISLOWER =
		0b0000_0000__0000_0001;
	
	/** Is this string already uppercased? */
	private static final short _QUICK_ISUPPER =
		0b0000_0000__0000_0010;
	
	/** String is already interned? */
	private static final short _QUICK_INTERN =
		0b0000_0000__0000_0100;
	
	/** Intern string table, weakly cached to reduce memory use. */
	private static final Collection<Reference<String>> _INTERNS =
		new LinkedList<>();
	
	/** String character data. */
	private final char[] _chars;
	
	/** Quick determination flags for speedy operations. */
	private volatile short _quickflags;
	
	/** The hash code for this string, is cached. */
	private int _hashcode;
	
	/**
	 * Initializes a new empty string.
	 *
	 * @since 2018/02/24
	 */
	public String()
	{
		this._chars = new char[0];
		this._quickflags = _QUICK_ISLOWER | _QUICK_ISUPPER;
		this._hashcode = 0;
	}
	
	/**
	 * Initializes a string which is an exact copy of the other string.
	 *
	 * @param __s The other string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	public String(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Just copies all the fields since they were pre-calculated already
		this._chars = __s._chars;
		this._quickflags = ((short)(__s._quickflags & (~_QUICK_INTERN)));
		this._hashcode = __s._hashcode;
	}
	
	/**
	 * Initializes a string which uses characters which are a copy of the given
	 * character array.
	 *
	 * @param __c The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public String(char[] __c)
		throws NullPointerException
	{
		this(__c, 0, __c.length);
	}
	
	/**
	 * Initializes a string which uses characters which are a copy of the given
	 * character array, using the offset and length.
	 *
	 * @param __c The characters to copy.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public String(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Copy characters
		char[] copy = new char[__l];
		for (int i = __o, o = 0; o < __l; i++, o++)
			copy[o] = __c[i];
		
		// Just use the copied buffer
		this._chars = copy;
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @param __e The encoding to use when decoding the bytes.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, int __o, int __l, String __e)
		throws IndexOutOfBoundsException, NullPointerException,
			UnsupportedEncodingException
	{
		this(__b, __o, __l, CodecFactory.decoder(__e));
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __e The encoding to use when decoding the bytes.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, String __e)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(__b, 0, __b.length, CodecFactory.decoder(__e));
	}
	
	/**
	 * Decodes the given bytes to a string using the default encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/06
	 */
	public String(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		this(__b, __o, __l, CodecFactory.defaultDecoder());
	}
	
	/**
	 * Decodes the given bytes to a string using the specified encoding.
	 *
	 * @param __b The input bytes to decode.
	 * @param __e The encoding to use when decoding the bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public String(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length, CodecFactory.defaultDecoder());
	}
	
	/**
	 * Initializes string from the given buffer.
	 *
	 * @param __a The input buffer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public String(StringBuffer __a)
		throws NullPointerException
	{
		this(__a.toString());
	}
	
	/**
	 * Initializes string from the given builder.
	 *
	 * @param __a The input builder.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public String(StringBuilder __a)
		throws NullPointerException
	{
		this(__a.toString());
	}
	
	/**
	 * Decodes the given bytes to a string using the specified decoder.
	 *
	 * @param __b The input bytes to decode.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to code.
	 * @param __dec The decoder to use for the input bytes.
	 * @throws IndexOutOfBoundsException If offset and/or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	private String(byte[] __b, int __o, int __l, Decoder __dec)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null || __dec == null)
			throw new NullPointerException("NARG");
		int bn = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bn)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup a temporary character array with average sequence length to
		// hopefully have enough room to store the decoded characters
		int cap = (int)(__l * __dec.averageSequenceLength()),
			at = 0;
		char[] out = new char[cap];
		
		// Start decoding input sequences
		for (int i = __o, e = i + __l; i < e;)
		{
			// Decode sequence (the decoded char is in the low 16-bits)
			int left = e - i,
				rc = __dec.decode(__b, i, left);
			
			// If there is not enough room to decode a sequence then store the
			// replacement character
			char ch;
			if (rc < 0)
			{
				ch = 0xFFFD;
				i = e;
			}
			
			// The lower 16-bits contains the character, the upper bytes
			// contains the number of characters read
			else
			{
				ch = (char)rc;
				i += (rc >> 16);
			}
			
			// Need to re-allocate?
			if (at >= cap)
				out = Arrays.copyOf(out, (cap += left));
			
			// Store
			out[at++] = ch;
		}
		
		// Just allocate an exact buffer since the estimate could have been off
		if (at != cap)
			out = Arrays.copyOf(out, at);
		this._chars = out;
	}
	
	/**
	 * Initializes the string using the given character data.
	 *
	 * @param __c Character data.
	 * @param __qf The quick flags to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	String(char[] __c, short __qf)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		this._chars = __c;
		this._quickflags = __qf;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public char charAt(int __i)
		throws IndexOutOfBoundsException
	{
		char[] chars = this._chars;
		if (__i < 0 || __i >= chars.length)
			throw new IndexOutOfBoundsException("IOOB " + __i);
		return chars[__i];
	}
	
	/**
	 * Compares the character values of this string and compares it to the
	 * character values of the other string.
	 *
	 * Smaller strings always precede longer strings.
	 *
	 * This is equivalent to the standard POSIX {@code strcmp()} with the "C"
	 * locale.
	 *
	 * Internally this does not handle the special variants of this class and
	 * is a general purpose method.
	 *
	 * @param __o The string to compare against.
	 * @return A negative value if this string precedes the other string, a
	 * positive value if this string procedes the other string, or zero if the
	 * strings are equal.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/02
	 */
	public int compareTo(String __o)
		throws NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Refers to the same exact string?
		if (this == __o)
			return 0;
		
		// Characters of both
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Get both string lengths
		int an = ac.length;
		int bn = bc.length;
		
		// Max comparison length
		int max = Math.min(an, bn);
		
		// Compare both strings
		for (int i = 0; i < max; i++)
		{
			// Get character difference
			int diff = ((int)ac[i]) - ((int)bc[i]);
			
			// If there is a difference, then return it
			if (diff != 0)
				return diff;
		}
		
		// Remaining comparison is the length parameter, shorter strings are
		// first
		return an - bn;
	}
	
	/**
	 * Compares two strings lexicographically without regards to case. This
	 * method does not take locale into account.
	 *
	 * @param __o The other string.
	 * @return The comparison of the string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public int compareToIgnoreCase(String __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Refers to the same exact string?
		if (this == __o)
			return 0;
		
		// Characters of both
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Get both string lengths
		int an = ac.length;
		int bn = bc.length;
		
		// Max comparison length
		int max = Math.min(an, bn);
		
		// Compare both strings
		for (int i = 0; i < max; i++)
		{
			// Get both characters and normalize case
			char ca = Character.toLowerCase(Character.toUpperCase(ac[i])),
				cb = Character.toLowerCase(Character.toUpperCase(bc[i]));
			
			// Get character difference
			int diff = ca - cb;
			
			// If there is a difference, then return it
			if (diff != 0)
				return diff;
		}
		
		// Remaining comparison is the length parameter, shorter strings are
		// first
		return an - bn;
	}
	
	/**
	 * Concatenates the given string to the end of this string.
	 *
	 * If the given string has a length of zero then this string is returned,
	 * otherwise if this string has a length of zero the given string is
	 * returned.
	 *
	 * @param __s The string to append to this string (returning a new string).
	 * @return The new string with the appended characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public String concat(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
			
		// Get both character sources
		char[] ac = this._chars,
			bc = __s._chars;
		
		// Lengths
		int an = ac.length,
			bn = bc.length;
		
		// One of the strings has no length, which means it will be a no-op
		if (an == 0)
			return __s;
		else if (bn == 0)
			return this;
		
		// Setup result
		int nl = an + bn;
		char[] rv = new char[nl];
		
		// Copy first part
		int o = 0;
		for (int i = 0; i < an; i++)
			rv[o++] = ac[i];
		
		// Copy second
		for (int i = 0; i < bn; i++)
			rv[o++] = bc[i];
		
		// Build string
		return new String(rv, (short)0);
	}
	
	/**
	 * Returns {@code true} if the string contains the given sequence.
	 *
	 * @param __b The sequence to find.
	 * @return If the string contains the given sequence or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/14
	 */
	public boolean contains(CharSequence __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// This is the same operation
		return this.__indexOf(__b, 0) >= 0;
	}
	
	/**
	 * Checks whether the content of this string is equal to the specified
	 * string buffer, the input buffer will be synchronized.
	 *
	 * @param __s The character sequence to check, this is synchronized.
	 * @return If the content equals the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public boolean contentEquals(StringBuffer __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// StringBuffers are synchronized and as such a lock is used to
		// prevent it from being changed.
		synchronized (__s)
		{
			return this.__contentEquals(__s);
		}
	}
	
	/**
	 * Checks whether the content of this string is equal to the specified
	 * character sequence.
	 *
	 * @param __s The character sequence to check, if it is a
	 * {@link StringBuffer} then it will be synchronized.
	 * @return If the content equals the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	public boolean contentEquals(CharSequence __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Synchronize on StringBuffers
		if (__s instanceof StringBuffer)
			return contentEquals((StringBuffer)__s);
		
		return __contentEquals(__s);
	}
	
	/**
	 * Tests if this string ends with the given string.
	 *
	 * @param __s The string to test.
	 * @return If this string ends with the other string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/20
	 */
	public boolean endsWith(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Character data
		char[] ac = this._chars,
			bc = __s._chars;
		
		// Lengths
		int na = ac.length,
			nb = bc.length;
		
		// If the other string is empty, it is always a match
		if (nb == 0)
			return true;
		
		// If our string is smaller than the other string then it will not
		// fit and as such, will not match
		if (na < nb)
			return false;
		
		// Check all characters at the end of the string, we fail if there is
		// a mismatch
		for (int ia = na - nb, ib = 0; ia < na; ia++, ib++)
			if (ac[ia] != bc[ib])
				return false;
		
		// Is a match since nothing failed!
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/21
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Short circuit match, the same string object is always equals
		if (this == __o)
			return true;
		
		// If not a string, fail
		if (!(__o instanceof String))
			return false;
		
		// Cast
		String o = (String)__o;
		
		// Quickly determine if the string is likely the same via the hashcode
		// This at best removes all loops and just results in a simple integer
		// comparison being used
		int an = this.hashCode(),
			bn = o.hashCode();
		if (an != bn)
			return false;
		
		// Character data
		char[] ac = this._chars,
			bc = o._chars;
		
		// If the length differs, they are not equal
		int n = ac.length;
		if (n != bc.length)
			return false;
		
		// Compare individual characters
		for (int i = 0; i < n; i++)
			if (ac[i] != bc[i])
				return false;
		
		// Would be a match!
		return true;
	}
	
	/**
	 * Checks if one string is equal to the other, ignoring case and ignoring
	 * any locale differences.
	 *
	 * A character is considered equal if they are the same character, the
	 * uppercase result of both characters is the same, or the lowercase
	 * result of each character is the same.
	 *
	 * @param __o The other string to check.
	 * @return If the two strings are equal.
	 * @since 2018/10/29
	 */
	@ProgrammerTip("Locale is not considered.")
	public boolean equalsIgnoreCase(String __o)
	{
		// Always false
		if (__o == null)
			return false;
		
		// Character data
		char[] ac = this._chars,
			bc = __o._chars;
		
		// Two strings of inequal length will never be the same
		int n = ac.length;
		if (n != bc.length)
			return false;
		
		// Check characters
		for (int i = 0; i < n; i++)
		{
			char a = Character.toLowerCase(Character.toUpperCase(ac[i])),
				b = Character.toLowerCase(Character.toUpperCase(bc[i]));
			
			// Is a different character?
			if (a != b)
				return false;
		}
		
		// The same
		return true;
	}
	
	/**
	 * Translates this string into a byte array using the default encoding.
	 *
	 * @return The resulting byte array.
	 * @since 2018/12/08
	 */
	public byte[] getBytes()
	{
		return this.__getBytes(CodecFactory.defaultEncoder());
	}
	
	/**
	 * Translates this string using into a byte array using the specified
	 * character encoding.
	 *
	 * @param __enc The character encoding to use.
	 * @return A byte array with the characters of this string converted to
	 * bytes.
	 * @throws NullPointerException If no encoding was specified.
	 * @throws UnsupportedEncodingException 
	 */
	public byte[] getBytes(String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		// Check
		if (__enc == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		try
		{
			return this.__getBytes(CodecFactory.encoder(__enc));
		}
		
		// {@squirreljme.error ZZ1k The specified encoding is not supported by
		// the virtual machine. (The encoding)}
		catch (UnsupportedEncodingException uee)
		{
			throw new AssertionError("ZZ1k " + __enc);
		}
	}
	
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public int hashCode()
	{
		// If the hashcode was already determined before then use that
		// cache
		int rv = this._hashcode;
		if (rv != 0)
			return rv;
		
		// Calculate the hashCode(), the JavaDoc gives the following formula:
		// == s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] .... yikes!
		char[] ch = this._chars;
		for (int i = 0, n = ch.length; i < n; i++)
			rv = ((rv << 5) - rv) + ch[i];
		
		// Cache hashcode for later
		this._hashcode = rv;
		return rv;
	}
	
	/**
	 * Searches the string for the given character and returns the index if it
	 * was found.
	 *
	 * @param __c The character to find.
	 * @return The character index or {@code -1} if it was not found.
	 * @since 2018/09/20
	 */
	public int indexOf(int __c)
	{
		return this.indexOf(__c, 0);
	}
	
	/**
	 * Searches the string for the given character starting from the given
	 * index and returns the index if it was found.
	 *
	 * @param __c The character to find.
	 * @param __i The index to start at, the values are capped within the
	 * string length.
	 * @return The character index or {@code -1} if it was not found.
	 * @since 2018/09/20
	 */
	public int indexOf(int __c, int __i)
	{
		char[] ch = this._chars;
		
		// Cap index
		int n = ch.length;
		if (__i < 0)
			__i = 0;
		
		for (int i = __i; i < n; i++)
			if (__c == ch[i])
				return i;
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/14
	 */
	public int indexOf(String __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.__indexOf(__b, 0);
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @param __i The starting index.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @since 2019/05/14
	 */
	public int indexOf(String __b, int __i)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.__indexOf(__b, __i);
	}
	
	/**
	 * This returns the unique string instance used for the current string, if
	 * the current string is not within the internal map then it is added. If
	 * it already exists in the map then that pre-existing value is returned.
	 * The purpose of this method is for potential optimizations where there
	 * are a large number of long-term string objects in memory which may be
	 * duplicated in many places (such as in a database). As such, only
	 * persistant strings should be interned, never short lived strings.
	 *
	 * Although this may be used for {@code ==} to work, it is not recommended
	 * to use this method for such things.
	 *
	 * @return The unique string instance.
	 * @since 2016/04/01
	 */
	@ImplementationNote("This method is a bit slow in SquirrelJME as it " +
		"will search a list of weak reference to string. So despite this " +
		"being a O(n) search it will allow any strings to be garbage " +
		"collected when no longer used. Also the collection is a LinkedList " +
		"since the __BucketMap__ is a complicated class. But do note that " +
		"String.equals() checks the hashCode() so in-depth searches will " +
		"only be performed for strings with the same hashCode().")
	public String intern()
	{
		// If this string is already interned then use this one instead
		// of searching through the map
		if ((this._quickflags & _QUICK_INTERN) != 0)
			return this;
		
		// Search for string in the collection
		Collection<Reference<String>> interns = _INTERNS;
		synchronized (interns)
		{
			// Same string that was internalized?
			Iterator<Reference<String>> it = interns.iterator();
			while (it.hasNext())
			{
				Reference<String> ref = it.next();
				
				// If the reference has been cleared, then delete it
				String oth = ref.get();
				if (oth == null)
				{
					it.remove();
					continue;
				}
				
				// If this matches the string, use that one
				if (this.equals(oth))
					return oth;
			}
			
			// Not in the table, so add it
			interns.add(new WeakReference<>(this));
			
			// Also flag that this has been interned
			this._quickflags |= _QUICK_INTERN;
			
			// This will be the intern string
			return this;
		}
	}
	
	/**
	 * Returns {@code true} if this string is empty.
	 *
	 * @return {@code true} if this string is empty.
	 * @since 2017/08/15
	 */
	public boolean isEmpty()
	{
		return this._chars.length == 0;
	}
	
	/**
	 * Returns the last occurance of the given character.
	 *
	 * @param __c The character to find.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c)
	{
		return this.lastIndexOf(__c, Integer.MAX_VALUE);
	}
	
	/**
	 * Returns the last occurance of the given character going backwards from
	 * the given index.
	 *
	 * @param __c The character to find.
	 * @param __dx The index to start at, this is clipped to within the
	 * string bounds accordingly although if it is negative no searching is
	 * done.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c, int __dx)
	{
		// Never going to find anything at all
		if (__dx < 0)
			return -1;
		
		// Cap index
		char[] ch = this._chars;
		int n = ch.length;
		if (__dx >= n)
			__dx = n - 1;
		
		for (; __dx >= 0; __dx--)
			if (__c == ch[__dx])
				return __dx;
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the last occurance of the given string.
	 *
	 * @param __c The string to find.
	 * @return The last occurance of the string or {@code -1} if it was
	 * not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public int lastIndexOf(String __s)
		throws NullPointerException
	{
		return this.lastIndexOf(__s, Integer.MAX_VALUE);
	}
	
	public int lastIndexOf(String __s, int __dx)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of this string.
	 *
	 * @return The length of this string.
	 * @since 2018/09/19
	 */
	public int length()
	{
		return this._chars.length;
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __toff The offset for this string.
	 * @param __b The other string to compare against.
	 * @param __boff The offset of the target string.
	 * @param __len The number of characters to compare.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(int __toff, String __b, int __boff, int __len)
	{
		return this.regionMatches(false, __toff, __b, __boff, __len);
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __igncase Is case to be ignored?
	 * @param __toff The offset for this string.
	 * @param __b The other string to compare against.
	 * @param __boff The offset of the target string.
	 * @param __len The number of characters to compare, if this is negative
	 * then this is treated as zero.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(boolean __igncase, int __toff, String __b,
		int __boff, int __len)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Automatically false
		if (__toff < 0 || __boff < 0 ||
			__toff + __len > this.length() || __boff + __len > __b.length())
			return false;
		
		// A quirk of the standard is that negative lengths are not an error
		// but are treated as matches
		if (__len < 0)
			return true;
		
		// Disregarding case
		if (__igncase)
			for (int i = 0; i < __len; i++, __toff++, __boff++)
			{
				char a = this.charAt(__toff),
					b = __b.charAt(__boff);
				
				if (Character.toLowerCase(a) != Character.toLowerCase(b) &&
					Character.toUpperCase(a) != Character.toUpperCase(b))
					return false;
			}
		
		// Regarding case
		else
			for (int i = 0; i < __len; i++, __toff++, __boff++)
				if (this.charAt(__toff) != __b.charAt(__boff))
					return false;
		
		// Matches
		return true;
	}
	
	/**
	 * Returns a string with all characters which match the starting character
	 * which are then replaced with the replacement character.
	 *
	 * @param __a The starting character.
	 * @param __b The replacement character.
	 * @since 2018/09/22
	 */
	public String replace(char __a, char __b)
	{
		// If a character is going to be replaced with itself then no
		// replacement has to actually be performed. Or if the original
		// character is not even in the string.
		if (__a == __b || this.indexOf(__a) < 0)
			return this;
		
		// Get source sequence
		char[] ch = this._chars;
		int n = ch.length;
		
		// Copy data into an array with translated characters
		char[] rv = new char[n];
		for (int i = 0; i < n; i++)
		{
			char c = ch[i];
			if (c == __a)
				c = __b;
			rv[i] = c;
		}
		
		// Build new string
		return new String(rv, (short)0);
	}
	
	/**
	 * Checks if this string starts with the other string at the given index.
	 *
	 * @param __s The string to check for a starting match.
	 * @param __sdx The starting index to start checking at.
	 * @return If this string starts with the given string.
	 * @throws IndexOutOfBoundsException
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public boolean startsWith(String __s, int __sdx)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1l Starting index in string is out of
		// bounds. (The starting index)}
		if (__sdx < 0)
			throw new IndexOutOfBoundsException(
				String.format("ZZ1l %d", __sdx));
		
		// Need to work on both sequences
		char[] ca = this._chars,
			cb = __s._chars;
		
		// If the second string is empty then it will always match
		int na = ca.length,
			nb = cb.length;
		if (nb == 0)
			return true;
		
		// The second string cannot even fit from this index so do not bother
		// checking anything
		if (__sdx + nb > na)
			return false;
		
		// Find false match
		for (int ia = __sdx, ib = 0; ib < nb; ia++, ib++)
			if (ca[ia] != cb[ib])
				return false;
		
		// False not found, so it matches
		return true;
	}
	
	/**
	 * Checks if this string starts with the other string.
	 *
	 * @param __s The string to check for a starting match.
	 * @return If this string starts with the given string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public boolean startsWith(String __s)
		throws NullPointerException
	{
		return this.startsWith(__s, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public CharSequence subSequence(int __s, int __e)
	{
		// Is the same code as substring
		return this.substring(__s, __e);
	}
	
	/**
	 * Returns a substring of this string starting at the given index.
	 *
	 * @param __s The index to start at.
	 * @return The sub-string for that index.
	 * @throws IndexOutOfBoundsException If the start is outside of the bounds.
	 * @since 2018/11/04
	 */
	public String substring(int __s)
		throws IndexOutOfBoundsException
	{
		// A substring starting at the zero character is the same
		if (__s == 0)
			return this;
		
		// Call other
		return this.substring(__s, this.length());
	}
	
	/**
	 * Returns a substring of this string.
	 *
	 * @param __s The starting index.
	 * @param __e The ending index.
	 * @throws IndexOutOfBoundsException If the string region is outside of
	 * bounds.
	 * @since 2018/09/29
	 */
	public String substring(int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// The entire string region requires no new string
		char[] ch = this._chars;
		int n = ch.length;
		if (__s == 0 && __e == n)
			return this;
		
		// A blank string with no characters
		if (__s == __e)
			return "";
		
		// {@squirreljme.error ZZ1m String substring is outside of bounds.
		// (The start index; The end index; The length)}
		if (__s < 0 || __s > __e || __e > n)
			throw new IndexOutOfBoundsException("ZZ1m " + __s + " " + __e +
				" " + n);
		
		// Derive sub-sequence
		int nl = __e - __s;
		char[] rv = new char[nl];
		for (int o = 0; o < nl; o++, __s++)
			rv[o] = ch[__s];
		
		// Build
		return new String(rv, (short)0);
	}
	
	/**
	 * Returns a character array which contains every character within this
	 * string.
	 *
	 * @return A character array containing the characters of this string.
	 * @since 2017/08/15
	 */
	public char[] toCharArray()
	{
		// Direct copy of the character array
		return this._chars.clone();
	}
	
	/**
	 * Translates this string to lowercase using the current locale.
	 *
	 * Java ME specifies that only Latin-1 characters are supported
	 *
	 * @return The lowercased result of this string.
	 * @since 2018/09/20
	 */
	public String toLowerCase()
	{
		// If this string is lowercased already do not mess with it
		if ((this._quickflags & String._QUICK_ISLOWER) != 0)
			return this;
		
		// Needed for case conversion
		char[] ch = this._chars;
		Locale locale = DefaultLocale.defaultLocale();
		
		// Setup new character array for the conversion
		int n = ch.length;
		char[] rv = new char[n];
		
		// Copy and convert characters
		boolean changed = false;
		for (int i = 0; i < n; i++)
		{
			char a = ch[i],
				b = locale.toLowerCase(a);
			
			// Detect if the string actually changed
			if (!changed && a != b)
				changed = true;
			
			rv[i] = b;
		}
		
		// String was unchanged, so forget about the array we just handled and
		// set that the string is lowercase
		if (!changed)
		{
			this._quickflags |= String._QUICK_ISLOWER;
			return this;
		}
		
		// New string will be lowercase, so ignore this operation
		return new String(rv, String._QUICK_ISLOWER);
	}
	
	/**
	 * Returns {@code this}.
	 *
	 * @return {@code this}.
	 * @since 2017/08/15
	 */
	@Override
	public String toString()
	{
		return this;
	}
	
	/**
	 * Translates this string to uppercase using the current locale.
	 *
	 * Java ME specifies that only Latin-1 characters are supported
	 *
	 * @return The uppercased result of this string.
	 * @since 2018/09/29
	 */
	public String toUpperCase()
	{
		// If this string is uppercased already do not mess with it
		if ((this._quickflags & String._QUICK_ISUPPER) != 0)
			return this;
		
		// Needed for case conversion
		char[] ch = this._chars;
		Locale locale = DefaultLocale.defaultLocale();
		
		// Setup new character array for the conversion
		int n = ch.length;
		char[] rv = new char[n];
		
		// Copy and convert characters
		boolean changed = false;
		for (int i = 0; i < n; i++)
		{
			char a = ch[i],
				b = locale.toUpperCase(a);
			
			// Detect if the string actually changed
			if (!changed && a != b)
				changed = true;
			
			rv[i] = b;
		}
		
		// String was unchanged, so forget about the array we just handled and
		// set that the string is lowercase
		if (!changed)
		{
			this._quickflags |= String._QUICK_ISUPPER;
			return this;
		}
		
		// New string will be uppercase, so ignore this operation
		return new String(rv, String._QUICK_ISUPPER);
	}
	
	/**
	 * This trims all of the low ASCII whitespace and control characters at
	 * the start and the end of this string and returns a new string with
	 * the trimmed whitespace.
	 *
	 * This does not handle any other potential characters which may act as
	 * whitespace in the high unicode range and only handles the first 32
	 * ASCII characters.
	 *
	 * @return A string with the whitespace trimmed, if the string does not
	 * start or end in whitespace then {@code this} is returned.
	 * @since 2016/04/20
	 */
	public String trim()
	{
		// Empty strings do not need trimming
		char[] ch = this._chars;
		int n = ch.length;
		if (n <= 0)
			return this;
		
		// Find starting trim position
		int s;
		for (s = 0; s < n && ch[s] <= _MIN_TRIM_CHAR; s++)
			;
		
		// Find ending trim position
		int e;
		for (e = n; e > s && ch[e - 1] <= _MIN_TRIM_CHAR; e--)
			;
		
		// Return trimmed variant of it
		return this.substring(s, e);
	}
	
	/**
	 * Checks to see if this string matches the target sequence.
	 *
	 * @param __s The input sequence to check against.
	 * @return If they are the same or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/15
	 */
	private final boolean __contentEquals(CharSequence __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// If the two have different lengths they will never be equal
		char[] ca = this._chars;
		int al = ca.length,
			bl = __s.length();
		if (al != bl)
			return false;
		
		// Check each character
		for (int i = 0; i < al; i++)
			if (ca[i] != __s.charAt(i))
				return false;
		
		// If reached, they are equal
		return true;
	}
	
	/**
	 * Returns the encoded byte sequence.
	 *
	 * @param __e The encoder to use when writing bytes.
	 * @return The bytes from this string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	private final byte[] __getBytes(Encoder __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		// Maximum size of sequences that can be encoded
		int msl;
		byte[] seq = new byte[(msl = __e.maximumSequenceLength())];
		
		// We operate directly on the sequence
		char[] ch = this._chars;
		int n = ch.length;
		
		// Write here
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			(int)(n * __e.averageSequenceLength())))
		{
			// Encode every character!
			for (int i = 0; i < n; i++)
			{
				int sz = __e.encode(ch[i], seq, 0, msl);
				
				// Should not occur
				if (sz < 0)
					throw new todo.OOPS();
				
				baos.write(seq, 0, sz);
			}
			
			// Use this byte array
			return baos.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the position where the given string is found.
	 *
	 * @param __b The sequence to find.
	 * @param __i The starting index.
	 * @return The index of the sequence or {@code -1} if it is not found.
	 * @since 2019/05/14
	 */
	private final int __indexOf(CharSequence __b, int __i)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Normalize position
		if (__i < 0)
			__i = 0;
		
		// If the sequence is empty, then it will always be a match
		char[] ca = this._chars;
		int an = ca.length,
			bn = __b.length();
		if (bn <= 0)
			return __i;
		
		// If the string is longer than ours, then it will never be a match
		if (bn > an - __i)
			return -1;
		
		// Do a long complicated loop matching, but we only need to check
		// for as long as the sequence can actually fit
__outer:
		for (int a = __i, lim = an - bn; a < lim; a++)
		{
			// Check sequence characters
			for (int x = a, b = 0; b < bn; x++, b++)
				if (ca[x] != __b.charAt(b))
					continue __outer;
			
			// Since the inner loop continues to the outer, if this was reached
			// then we know the full sequence was matched
			return a;
		}
		
		// Otherwise nothing was found because we tried every character
		return -1;
	}
	
	/**
	 * Invokes {@code String.valueOf(__c, __o, __l)}.
	 *
	 * @param __c The input character array to copy.
	 * @param __o The starting offset.
	 * @param __l The number of characters to copy.
	 * @return The result of the other call.
	 * @since 2016/06/13
	 */
	public static String copyValueOf(char[] __c, int __o, int __l)
	{
		return String.valueOf(__c, __o, __l);
	}
	
	/**
	 * Invokes {@code String.valueOf(__a)}.
	 *
	 * @param __c The input character array to copy.
	 * @return The result of the other call.
	 * @since 2016/06/13
	 */
	public static String copyValueOf(char[] __c)
	{
		return String.valueOf(__c);
	}
	
	/**
	 * Returns a formatted string using a temporary instance of the
	 * {@link Formatter} class.
	 *
	 * @param __fmt The format specifiers.
	 * @param __args The arguments to the formatter.
	 * @throws IllegalArgumentException If the format is not correct.
	 * @throws NullPointerException On null arguments.
	 * @see java.util.Formatter
	 * @since 2018/11/02
	 */
	public static String format(String __fmt, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		// Just forward everything to this formatter
		return new Formatter().format(__fmt, __args).toString();
	}
	
	/**
	 * Returns the value of the given object as a string.
	 *
	 * @param __a The object to get the string value of, if {@code null} then
	 * the string {@code "null"} is returned.
	 * @return The string value of the given object or {@code "null"}
	 * @since 2016/06/13
	 */
	public static String valueOf(Object __a)
	{
		// The value is a string already
		if (__a instanceof String)
			return (String)__a;
		
		// If null use null
		if (__a == null)
			return "null";
		
		// Just return the toString of the given object.
		return __a.toString();
	}
	
	/**
	 * Returns a string representation of the given character array.
	 *
	 * @param __a The array.
	 * @return The resulting string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public static String valueOf(char[] __a)
		throws NullPointerException
	{
		return String.valueOf(__a, 0, (__a != null ? __a.length : 0));
	}
	
	/**
	 * Returns a string representation of the given character array.
	 *
	 * @param __c The input array.
	 * @param __o The offset.
	 * @param __l The number of characters to set.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public static String valueOf(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return new String(__c, __o, __l);
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(boolean __a)
	{
		return Boolean.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(char __a)
	{
		return Character.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(int __a)
	{
		return Integer.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(long __a)
	{
		return Long.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(float __a)
	{
		return Float.valueOf(__a).toString();
	}
	
	/**
	 * Returns a string representation of the given value.
	 *
	 * @param __a The value.
	 * @return The resulting string.
	 * @since 2019/12/25
	 */
	public static String valueOf(double __a)
	{
		return Double.valueOf(__a).toString();
	}
}

Deleted runt/apis/cldc-compact/java/lang/StringBuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is a thread safe version of {@link StringBuilder}, to reduce the need
 * to document everything please see that documentation instead.
 *
 * The instance itself is used as the monitor.
 *
 * @see StringBuilder
 * @since 2018/12/09
 */
public final class StringBuffer
	implements Appendable, CharSequence
{
	/** The base buffer. */
	protected final StringBuilder builder;
	
	/**
	 * Initializes a blank string buffer.
	 *
	 * @since 2018/12/08
	 */
	public StringBuffer()
	{
		this.builder = new StringBuilder();
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(int __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(String __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * Initializes the string buffer using the given value.
	 *
	 * @param __a The value.
	 * @since 2018/12/08
	 */
	public StringBuffer(CharSequence __a)
	{
		this.builder = new StringBuilder(__a);
	}
	
	/**
	 * See {@link StringBuffer#append(Object)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(Object __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(String __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(StringBuffer)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(StringBuffer __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(CharSequence)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(CharSequence __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(CharSequence, int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(CharSequence __a, int __b, int __c)
	{
		synchronized (this)
		{
			this.builder.append(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char[])}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char[] __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char[], int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char[] __a, int __b, int __c)
	{
		synchronized (this)
		{
			this.builder.append(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(boolean)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(boolean __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(char __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(int __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(long)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(long __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(float)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(float __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#append(double)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer append(double __a)
	{
		synchronized (this)
		{
			this.builder.append(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#capacity()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int capacity()
	{
		synchronized (this)
		{
			return this.builder.capacity();
		}
	}
	
	/**
	 * See {@link StringBuffer#charAt(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public char charAt(int __a)
	{
		synchronized (this)
		{
			return this.builder.charAt(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#delete(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer delete(int __a, int __b)
	{
		synchronized (this)
		{
			this.builder.delete(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#deleteCharAt(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer deleteCharAt(int __a)
	{
		synchronized (this)
		{
			this.builder.deleteCharAt(__a);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#ensureCapacity(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void ensureCapacity(int __a)
	{
		synchronized (this)
		{
			this.builder.ensureCapacity(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#getChars(int, int, char[], int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		synchronized (this)
		{
			this.builder.getChars(__a, __b, __c, __d);
		}
	}
	
	/**
	 * See {@link StringBuffer#indexOf(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int indexOf(String __a)
	{
		synchronized (this)
		{
			return this.builder.indexOf(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#indexOf(String, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int indexOf(String __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.indexOf(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char[], int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char[] __b, int __c, int __d)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b, __c, __d);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, Object)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, Object __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, String __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char[])}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char[] __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, CharSequence)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, CharSequence __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, CharSequence, int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @param __d Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, CharSequence __b, int __c,
		int __d)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b, __c, __d);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, boolean)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, boolean __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, char __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, int __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, long)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, long __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, float)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, float __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#insert(int, double)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer insert(int __a, double __b)
	{
		synchronized (this)
		{
			this.builder.insert(__a, __b);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#lastIndexOf(String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int lastIndexOf(String __a)
	{
		synchronized (this)
		{
			return this.builder.lastIndexOf(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#lastIndexOf(String, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int lastIndexOf(String __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.lastIndexOf(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#length()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public int length()
	{
		synchronized (this)
		{
			return this.builder.length();
		}
	}
	
	/**
	 * See {@link StringBuffer#replace(int, int, String)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @param __c Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer replace(int __a, int __b, String __c)
	{
		synchronized (this)
		{
			this.builder.replace(__a, __b, __c);
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#reverse()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public StringBuffer reverse()
	{
		synchronized (this)
		{
			this.builder.reverse();
			return this;
		}
	}
	
	/**
	 * See {@link StringBuffer#setCharAt(int, char)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void setCharAt(int __a, char __b)
	{
		synchronized (this)
		{
			this.builder.setCharAt(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#setLength(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void setLength(int __a)
	{
		synchronized (this)
		{
			this.builder.setLength(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#subSequence(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public CharSequence subSequence(int __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.subSequence(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#substring(int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String substring(int __a)
	{
		synchronized (this)
		{
			return this.builder.substring(__a);
		}
	}
	
	/**
	 * See {@link StringBuffer#substring(int, int)}.
	 *
	 * @param __a Same as linked documentation.
	 * @param __b Same as linked documentation.
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String substring(int __a, int __b)
	{
		synchronized (this)
		{
			return this.builder.substring(__a, __b);
		}
	}
	
	/**
	 * See {@link StringBuffer#toString()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public String toString()
	{
		synchronized (this)
		{
			return this.builder.toString();
		}
	}
	
	/**
	 * See {@link StringBuffer#trimToSize()}.
	 *
	 * @return Same as linked documentation.
	 * @since 2018/12/08
	 */
	public void trimToSize()
	{
		synchronized (this)
		{
			this.builder.trimToSize();
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/StringBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782














































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This is a string which has a mutable buffer.
 *
 * This class is not thread safe, for that use {@link StringBuffer} instead.
 *
 * The default capacity of this builder is 16 characters.
 *
 * @since 2018/09/22
 */
public final class StringBuilder
	implements Appendable, CharSequence
{
	/** Default capacity of the internal array. */
	private static final int _DEFAULT_CAPACITY =
		16;
	
	/** The internal buffer for storing characters. */
	private char[] _buffer;
	
	/** The characters which are in the buffer. */
	private int _at;
	
	/** The limit of the string buffer. */
	private int _limit;
	
	/**
	 * Initializes with the default capacity.
	 *
	 * @since 2018/09/22
	 */
	public StringBuilder()
	{
		this(StringBuilder._DEFAULT_CAPACITY);
	}
	
	/**
	 * Initailizes with the given capacity.
	 *
	 * @param __c The initial capacity.
	 * @throws NegativeArraySizeException If the capacity is negative.
	 * @since 2018/09/22
	 */
	public StringBuilder(int __c)
		throws NegativeArraySizeException
	{
		// {@squirreljme.error ZZ1n The initial capacity cannot be negative.
		// (The initial capacity)}
		if (__c < 0)
			throw new NegativeArraySizeException(
				String.format("ZZ1n %d", __c));
		
		// Initialize buffer
		this._buffer = new char[__c];
		this._limit = __c;
	}
	
	/**
	 * Initializes with the initial characters given by the input sequence,
	 * the internal buffer is the default capacity plus the input string
	 * length.
	 *
	 * @param __s The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder(String __s)
		throws NullPointerException
	{
		this((CharSequence)__s);
	}
	
	/**
	 * Initializes with the initial characters given by the input sequence,
	 * the internal buffer is the default capacity plus the input string
	 * length.
	 *
	 * @param __s The characters to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder(CharSequence __cs)
	{
		if (__cs == null)
			throw new NullPointerException("NARG");
		
		// Initialize buffer with the default and the input sequence length
		this._buffer = new char[StringBuilder._DEFAULT_CAPACITY +
			__cs.length()];
		
		// Just append the sequence since the code is the same
		this.append(__cs);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(Object __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the given string.
	 *
	 * @param __v The string to append.
	 * @return {@code this}.
	 * @since 2018/09/22 
	 */
	public StringBuilder append(String __v)
	{
		if (__v == null)
			__v = "null";
		
		return this.append((CharSequence)__v, 0, __v.length());
	}
	
	/**
	 * Appends the given string buffer.
	 *
	 * @param __v The string buffer to append.
	 * @return {@code this}.
	 * @since 2018/09/22 
	 */
	public StringBuilder append(StringBuffer __v)
	{
		// Is null, cannot lock on it so just forward
		if (__v == null)
			return this.append("null");
		
		// Lock on the buffer because this is thread safe
		synchronized (__v)
		{
			return this.append((CharSequence)__v, 0, __v.length());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(CharSequence __v)
	{
		// Print null instead
		if (__v == null)
			__v = "null";
		
		return this.append(__v, 0, __v.length());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(CharSequence __v, int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// Print null?
		if (__v == null)
			__v = "null";
		
		// Check bounds
		int vn = __v.length();
		if (__s < 0 || __e < 0 || __e > vn || __s > __e)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Length to add
		int len = __e - __s;
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + len > limit ? this.__buffer(len) : this._buffer);
		
		// Place input characters at this point
		while (__s < __e)
			buffer[at++] = __v.charAt(__s++);
		
		// Set new size
		this._at = at;
		
		return this;
	}
	
	/**
	 * Appends the given characters to the string.
	 *
	 * @param __c The characters to append.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder append(char[] __c)
		throws NullPointerException
	{
		return this.append(__c, 0, __c.length);
	}
	
	/**
	 * Appends the given characters to the string.
	 *
	 * @param __c The characters to append.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public StringBuilder append(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + __l > limit ? this.__buffer(__l) : this._buffer);
		
		// Place input characters at this point
		for (int i = 0; i < __l; i++)
			buffer[at++] = __c[__o++];
		
		// Set new size
		this._at = at;
		
		return this;
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(boolean __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public StringBuilder append(char __v)
	{
		// Before we go deeper check if the buffer needs to grow
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + 1 > limit ? this.__buffer(1) : this._buffer);
		
		// Add to the end
		buffer[at] = __v;
		this._at = at + 1;
		
		// Self
		return this;
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(int __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(long __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(float __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Appends the value to the string.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2018/09/22
	 */
	public StringBuilder append(double __v)
	{
		return this.insert(this._at, __v);
	}
	
	/**
	 * Returns the current capacity of the internal buffer.
	 *
	 * @return The internal capacity.
	 * @since 2018/09/22
	 */
	public int capacity()
	{
		return this._buffer.length;
	}
	
	/**
	 * Returns the character at the given index.
	 *
	 * @param __dx The index.
	 * @return The character at the given index.
	 * @throws IndexOutOfBoundsException If the character is outside of
	 * bounds.
	 * @since 2018/09/29
	 */
	public char charAt(int __dx)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1o Out of bound access. (The index)}
		if (__dx < 0 || __dx >= this._at)
			throw new IndexOutOfBoundsException("ZZ1o " + __dx);
		
		return this._buffer[__dx];
	}
	
	public StringBuilder delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder deleteCharAt(int __a)
	{
		throw new todo.TODO();
	}
	
	public void ensureCapacity(int __a)
	{
		throw new todo.TODO();
	}
	
	public void getChars(int __a, int __b, char[] __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public int indexOf(String __a)
	{
		throw new todo.TODO();
	}
	
	public int indexOf(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder insert(int __a, char[] __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/29
	 */
	public StringBuilder insert(int __dx, Object __v)
	{
		return this.insert(__dx, (__v == null ? "null" : __v.toString()));
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws StringIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, String __v)
		throws StringIndexOutOfBoundsException
	{
		return this.insert(__dx, (CharSequence)__v);
	}
	
	public StringBuilder insert(int __a, char[] __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, CharSequence __v)
		throws IndexOutOfBoundsException
	{
		// Print null instead
		if (__v == null)
			__v = "null";
		
		return this.insert(__dx, __v, 0, __v.length());
	}
	
	/**
	 * Inserts the given value at the given position.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @param __s The start position.
	 * @param __e The end position.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/09/22
	 */
	public StringBuilder insert(int __dx, CharSequence __v, int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1p Cannot insert sequence at a negative
		// index.}
		if (__dx < 0)
			throw new IndexOutOfBoundsException("ZZ1p");
		
		// Check bounds
		int vn = __v.length();
		if (__s < 0 || __e < 0 || __e > vn || __s > __e)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Length to add
		int len = __e - __s;
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + len > limit ? this.__buffer(len) : this._buffer);
		
		// {@squirreljme.error ZZ1q The index of insertion exceeds the
		// length of the current string. (The insertion index; The string
		// length)}
		if (__dx > at)
			throw new IndexOutOfBoundsException(String.format("ZZ1q %d %d",
				__dx, at));
		
		// First move all characters on the right to the end so that this can
		// properly fit
		for (int i = at - 1, o = i + len; i >= __dx; i--, o--)
			buffer[o] = buffer[i];
		
		// Place input characters at this point
		while (__s < __e)
			buffer[__dx++] = __v.charAt(__s++);
		
		// Set new size
		this._at = at + len;
		
		return this;
	}
	
	public StringBuilder insert(int __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Inserts the given character into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, char __v)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1r Cannot insert sequence at a negative
		// index.}
		if (__dx < 0)
			throw new IndexOutOfBoundsException("ZZ1r");
		
		// Before we go deeper check if the buffer needs to grow
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + 1 > limit ? this.__buffer(1) : this._buffer);
		
		// {@squirreljme.error ZZ1s The index of insertion exceeds the
		// length of the current string. (The insertion index; The string
		// length)}
		if (__dx > at)
			throw new IndexOutOfBoundsException(String.format("ZZ1s %d %d",
				__dx, at));
		
		// First move all characters on the right to the end so that this can
		// properly fit
		for (int i = at - 1, o = i + 1; i >= __dx; i--, o--)
			buffer[o] = buffer[i];
		
		// Place input characters at this point
		buffer[__dx] = __v;
		
		// Set new size
		this._at = at + 1;
		
		return this;
	}
	
	/**
	 * Inserts the given value into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, int __v)
	{
		return this.insert(__dx, Long.valueOf(__v).toString());
	}
	
	/**
	 * Inserts the given value into the string at the given index.
	 *
	 * @param __dx The index to insert at.
	 * @param __v The value to insert.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2018/09/23
	 */
	public StringBuilder insert(int __dx, long __v)
	{
		return this.insert(__dx, Long.valueOf(__v).toString());
	}
	
	public StringBuilder insert(int __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public StringBuilder insert(int __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public int lastIndexOf(String __a)
	{
		throw new todo.TODO();
	}
	
	public int lastIndexOf(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of the string.
	 *
	 * @return The string length.
	 * @since 2018/09/29
	 */
	public int length()
	{
		return this._at;
	}
	
	public StringBuilder replace(int __a, int __b, String __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reverses all of the characters in the string.
	 *
	 * @return {@code this}.
	 * @since 2018/09/23
	 */
	public StringBuilder reverse()
	{
		// Get the buffer
		char[] buffer = this._buffer;
		int at = this._at;
		
		// Swap all the characters, a less than be because if it reaches the
		// center there will be no need to swap anything
		for (int a = 0, b = at - 1; a < b; a++, b--)
		{
			char x = buffer[a];
			buffer[a] = buffer[b];
			buffer[b] = x;
		}
		
		// Self
		return this;
	}
	
	public void setCharAt(int __dx, char __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the length of the internal buffer, either truncating it or
	 * padding it with NUL characters.
	 *
	 * @param __nl The new length.
	 * @throws IndexOutOfBoundsException If the length is negative.
	 * @since 2018/10/13
	 */
	@ImplementationNote("This does not actually even pad NULs it just " +
		"sets the length or regrows the buffer as needed.")
	public void setLength(int __nl)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1t Attempt to use a length of a negative
		// size.}
		if (__nl < 0)
			throw new IndexOutOfBoundsException("ZZ1t");
		
		// We only need to do something if we are going up, staying the same
		// or going down just sets a variable
		// If the buffer is resized, we do not need to pad for NUL characters
		// because it already has zero values
		int at = this._at;
		if (__nl > at)
			this.__buffer(__nl);
		
		// Set new length
		this._at = __nl;
	}
	
	/**
	 * Invokes {@code this.substring(__s, __e)}.
	 *
	 * @param __s The start.
	 * @param __e The end.
	 * @return The sub-sequence.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/11
	 */
	public CharSequence subSequence(int __s, int __e)
		throws IndexOutOfBoundsException
	{
		return this.substring(__s, __e);
	}
	
	/**
	 * Returns a string which is a substring of the given portion of the
	 * string.
	 *
	 * @param __s The start.
	 * @return The resulting sub-string.
	 * @throws StringIndexOutOfBoundsException If the specified positions
	 * are not within the string bounds.
	 * @since 2019/05/11
	 */
	public String substring(int __s)
		throws StringIndexOutOfBoundsException
	{
		return this.substring(__s, this.length());
	}
	
	/**
	 * Returns a string which is a substring of the given portion of the
	 * string.
	 *
	 * @param __s The start.
	 * @param __e The end.
	 * @return The resulting sub-string.
	 * @throws StringIndexOutOfBoundsException If the specified positions
	 * are not within the string bounds.
	 * @since 2019/05/11
	 */
	public String substring(int __s, int __e)
		throws StringIndexOutOfBoundsException
	{
		// {@squirreljme.error ZZ1u String index out of bounds.}
		int len = this._at;
		if (__s < 0 || __e < 0 || __s > __e || __s > len || __e > len)
			throw new StringIndexOutOfBoundsException("ZZ1u");
		
		// Would be an empty string
		if (__s == __e)
			return "";
		
		// Build string and operate directly on the buffer
		return new String(this._buffer, __s, __e - __s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/22
	 */
	@Override
	public String toString()
	{
		return new String(this._buffer, 0, this._at);
	}
	
	public void trimToSize()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Obtains the buffer, potentially resizing it to fit the given amount
	 * of characters.
	 *
	 * @param __l The number of characters to add.
	 * @return The buffer.
	 * @since 2018/09/23
	 */
	private final char[] __buffer(int __l)
	{
		// Get buffer properties
		char[] buffer = this._buffer;
		int limit = this._limit,
			at = this._at;
		
		// Need to resize the buffer to fit this?
		int nextat = at + __l;
		if (nextat > limit)
		{
			int newcapacity = nextat + StringBuilder._DEFAULT_CAPACITY;
			
			// Copy characters over
			char[] extra = new char[newcapacity];
			for (int i = 0; i < at; i++)
				extra[i] = buffer[i];
			
			this._buffer = (buffer = extra);
			this._limit = newcapacity;
		}
		
		return buffer;
	}
}

Deleted runt/apis/cldc-compact/java/lang/StringIndexOutOfBoundsException.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when an attempt is made to read from an index within a string
 * which is not within bounds.
 *
 * @since 2018/09/16
 */
public class StringIndexOutOfBoundsException
	extends IndexOutOfBoundsException
{
	/**
	 * Initializes the exception with no message and no cause.
	 *
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initailizes the exception with the given index with no cause.
	 *
	 * @param __dx The index to reference.
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException(int __dx)
	{
		// {@squirreljme.error ZZ1v String index out of bounds. (The index)}
		super("ZZ1v " + __dx);
	}
	
	/**
	 * Initializes the exception with given message and no cause.
	 *
	 * @param __m The message used.
	 * @since 2018/09/16
	 */
	public StringIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/SuppressWarnings.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Suppresses warnings that are generated by the compiler so that they do not
 * appear for the given method. Duplicates are permitted and values which are
 * unknown are ignored.
 *
 * The following warnings may have support to be disabled, although it is not
 * required: {@code all}, {@code boxing}, {@code cast}, {@code dep-ann},
 * {@code deprecation}, {@code fallthrough}, {@code finally}, {@code hiding},
 * {@code incomplete-switch}, {@code nls}, {@code null}, {@code rawtypes},
 * {@code restriction}, {@code serial}, {@code static-access},
 * {@code synthetic-access}, {@code unchecked},
 * {@code unqualified-field-access}, and {@code unused}.
 *
 * @since 2018/09/19
 */
@Target(value={ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
	ElementType.PARAMETER, ElementType.CONSTRUCTOR,
	ElementType.LOCAL_VARIABLE})
@Retention(value=RetentionPolicy.SOURCE)
public @interface SuppressWarnings
{
	/** The warnings that should be suppressed. */
	String[] value();
}

Deleted runt/apis/cldc-compact/java/lang/System.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546


































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.asm.ConsoleOutput;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.io.CodecFactory;
import cc.squirreljme.runtime.cldc.io.ConsoleOutputStream;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import java.io.OutputStream;
import java.io.PrintStream;
import java.security.Permission;

/**
 * This class contains methods which are used to interact with the system and
 * the environment.
 *
 * @since 2018/10/14
 */
public final class System
{
	/** Standard error stream (stderr). */
	public static final PrintStream err =
		new __CanSetPrintStream__(new PrintStream(
			new ConsoleOutputStream(ConsoleOutput.ERROR), true));
	
	/** Standard output stream (stdout). */
	public static final PrintStream out =
		new __CanSetPrintStream__(new PrintStream(
			new ConsoleOutputStream(ConsoleOutput.OUTPUT), true));
	
	/**
	 * Not used.
	 *
	 * @since 2018/03/01
	 */
	private System()
	{
	}
	
	/**
	 * Copies from the source array to the destination.
	 *
	 * @param __src The source array.
	 * @param __srcoff The source offset.
	 * @param __dest The destination array.
	 * @param __destoff The destination offset.
	 * @param __copylen The number of elements to copy.
	 * @throws ArrayStoreException If the destination array cannot contain
	 * the given data.
	 * @throws IndexOutOfBoundsException If the offset and or/lengths are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/27
	 */
	public static void arraycopy(Object __src, int __srcoff,
		Object __dest, int __destoff, int __copylen)
		throws ArrayStoreException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__src == null || __dest == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1w Negative offsets and/or length cannot be
		// specified. (The source offset; The destination offset; The copy
		// length)}
		if (__srcoff < 0 || __destoff < 0 || __copylen < 0)
			throw new IndexOutOfBoundsException(String.format("ZZ1w %d %d %d",
				__srcoff, __destoff, __copylen));
		
		// {@squirreljme.error ZZ1x Copy operation would exceed the bounds of
		// the array. (Source offset; Source length; Destination offset;
		// Destination length; The copy length)}
		int srclen = Assembly.arrayLength(__src),
			destlen = Assembly.arrayLength(__dest);
		if (__srcoff + __copylen > srclen ||
			__destoff + __copylen > destlen)
			throw new IndexOutOfBoundsException(String.format(
				"ZZ1x %d %d %d %d %d", __srcoff, srclen, __destoff, destlen,
				__copylen));
		
		// {@squirreljme.error ZZ1y The source array type is not compatible
		// with destination array. (The source array; The destination array)}
		if (!__dest.getClass().isAssignableFrom(__src.getClass()))
			throw new ArrayStoreException(String.format(
				"ZZ1y %s %s", __src, __dest));
		
		// These offsets for the loops are the same
		int i = __srcoff,
			o = __destoff,
			end = __srcoff + __copylen;
		
		// Copy depending on the type
		if (__src instanceof boolean[])
			for (boolean[] s = (boolean[])__src, d = (boolean[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof byte[])
			for (byte[] s = (byte[])__src, d = (byte[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof short[])
			for (short[] s = (short[])__src, d = (short[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof char[])
			for (char[] s = (char[])__src, d = (char[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof int[])
			for (int[] s = (int[])__src, d = (int[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof long[])
			for (long[] s = (long[])__src, d = (long[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof float[])
			for (float[] s = (float[])__src, d = (float[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else if (__src instanceof double[])
			for (double[] s = (double[])__src, d = (double[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
		else
			for (Object[] s = (Object[])__src, d = (Object[])__dest;
				i < end; i++, o++)
			d[o] = s[i];
	}
	
	/**
	 * Returns the current time on the system's clock in UTC since the epoch
	 * (January 1, 1970 UTC).
	 *
	 * Note that this clock is not monotonic in that if a system adjusts the
	 * system clock this method may return values lower than previous calls
	 * which are made.
	 *
	 * Depending on the host hardware and operating system, the granularity of
	 * this clock may or may not be accurate.
	 *
	 * @return The number of milliseconds since the epoch.
	 * @since 2017/11/10
	 */
	public static long currentTimeMillis()
	{
		// Returns the current time in UTC, not local time zone.
		return Assembly.sysCallPVL(SystemCallIndex.TIME_MILLI_WALL);
	}
	
	/**
	 * Indicates that the application exits with the given code.
	 *
	 * @param __e The exit code, the value of this code may change according
	 * to the host operating system and the resulting process might not exit
	 * with the given code.
	 * @since 2017/02/08
	 */
	public static void exit(int __e)
	{
		Runtime.getRuntime().exit(__e);
	}
	
	/**
	 * Indicates that the application should have garbage collection be
	 * performed. It is unspecified when garbage collection occurs.
	 *
	 * @since 2017/02/08
	 */
	public static void gc()
	{
		Runtime.getRuntime().gc();
	}
	
	/**
	 * This obtains the value of a system property (if one is set) and returns
	 * its value. System properties are declared by the system and are used
	 * by applications to potentially modify their behavior.
	 *
	 * {@squirreljme.property java.io.tmpdir This is the temporary directory
	 * which indicates where temporary files (those that are deleted after
	 * an unspecified duration) are to be placed. If there is no filesystem
	 * on the device then a blank string will always be returned.}
	 * {@squirreljme.property java.version This is the version of the virtual
	 * machine which the environment runs under.}
	 * {@squirreljme.property java.vendor This is the vendor of the virtual
	 * machine and specifies who wrote it.}
	 * {@squirreljme.property java.vendor.url This is a URL which usually
	 * points to the website of the vendor.}
	 * {@squirreljme.property line.separator This represents the line
	 * separation sequence that the host operating system uses for its native
	 * files. Generally it would either be {@code '\n'}, {@code '\r'}, or
	 * {@code "\r\n"), however retro-systems might use a different line ending
	 * sequence.}}
	 * {@squirreljme.property microedition.configuration This is the current
	 * configuration of CLDC library which indicates which primary classes
	 * are available to it. The values will either be {@code "CLDC-1.8"} for
	 * the complete set of APIs and {@code "CLDC-1.8-Compact"} for the compact
	 * set of APIs.}
	 * {@squirreljme.property microedition.deviceid.uuid This is the unique
	 * identifier to the current device that regardless of the number of
	 * reboots and reinitializations that occur, this should return the same
	 * value.}
	 * {@squirreljme.property microedition.encoding This is the character
	 * encoding that is used by default for specific methods when one has not
	 * been specified. On modern systems this is likely to be {@code "UTF-8},
	 * while on retro-devices and operating systems this will likely be an
	 * encoding starting with {@code "x-squirreljme"}. Please note that the
	 * default encoding might not be compatible with UTF-8 (and may possibly
	 * well be EBCDIC).}
	 * {@squirreljme.property microedition.hostname The host name of the
	 * current system that the virtual machine is running on as it appears
	 * to other machines on the network.}
	 * {@squirreljme.property microedition.locale The current locale that the
	 * library will use.}
	 * {@squirreljme.property microedition.platform This is the device that
	 * SquirrelJME is running on. It is in the format of
	 * {@code (Manufacturer)(DeviceModelNumber)[/version[/comments]]}. The
	 * manufacturer and device model number are concatenated with no spaces.}
	 * {@squirreljme.property microedition.profiles This is a space separated
	 * list of profiles which are supported by the run-time, an example
	 * value that may be returned is MIDP-3.0 representing that that specified
	 * standard is implemented.}
	 * {@squirreljme.property os.arch This is the architecture of the hardware
	 * that SquirrelJME is running on, the value is dependent on the platform
	 * itself. Note that architecture names use standard SquirrelJME
	 * architecture names.}
	 * {@squirreljme.property os.name This is the name of the operating system
	 * that SquirrelJME is running on, if SquirrelJME is the operating itself
	 * then this value will be {@code "squirreljme"}.}
	 * {@squirreljme.property os.version This is the version number of the
	 * host operating system. The returned value might not be a number and may
	 * be a string representing the host.}
	 * {@squirreljme.property user.dir This is the current working directory
	 * which indicates the location where non-absolute file paths are derived
	 * from. If there is no filesystem on the device then a blank string will
	 * always be returned.}
	 *
	 * @param __k The system property value to obtain.
	 * @return The value of the system property or {@code null} if it is not
	 * does not exist.
	 * @throws IllegalArgumentException If the key is empty.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current process is not permitted to
	 * access system properties or obtain the value of a specific property.
	 * @since 2016/05/21
	 */
	public static String getProperty(String __k)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		// Check
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ1z Cannot request a system property which has
		// a blank key.}
		if (__k.equals(""))
			throw new IllegalArgumentException("ZZ1z");
		
		// Short circuit for run-time detection
		if (__k.equals("cc.squirreljme.isruntime"))
			return "true";
		
		// Not allowed to do this?
		getSecurityManager().checkPropertyAccess(__k);
		
		// Depends on the property
		String rv;
		switch (__k)
		{
				// API level of SquirrelJME
			case "cc.squirreljme.apilevel":
				return ApiLevel.levelToString(ApiLevel.CURRENT_LEVEL);
			
				// SquirrelJME guest depth
			case "cc.squirreljme.guests":
				return Integer.toString(SystemProperties.guestDepth());
				
				// SquirrelJME VM executable path
			case "cc.squirreljme.vm.execpath":
				return SystemProperties.executablePath();
				
				// SquirrelJME free memory
			case "cc.squirreljme.vm.freemem":
				return Long.toString(Runtime.getRuntime().freeMemory());
				
				// SquirrelJME total memory
			case "cc.squirreljme.vm.totalmem":
				return Long.toString(Runtime.getRuntime().totalMemory());
				
				// SquirrelJME free memory
			case "cc.squirreljme.vm.maxmem":
				return Long.toString(Runtime.getRuntime().maxMemory());
			
				// The version of the Java virtual machine (fixed value)
			case "java.version":
				return "1.8.0";
				
				// The version of the JVM (full)
			case "java.vm.version":
				return SystemProperties.javaVMVersion();
				
				// The name of the JVM
			case "java.vm.name":
				return SystemProperties.javaVMName();
				
				// The vendor of the JVM
			case "java.vm.vendor":
				return SystemProperties.javaVMVendor();
			
				// The e-mail of the JVM
			case "java.vm.vendor.email":
				return SystemProperties.javaVMEmail();
			
				// The URL of the JVM
			case "java.vm.vendor.url":
				return SystemProperties.javaVMURL();
				
				// The vendor of the class libraries
			case "java.vendor":
				return "Stephanie Gawroriski";
				
				// Non-standard e-mail address
			case "java.vendor.email":
				return "xerthesquirrel@gmail.com";
				
				// The URL to the virtual machine's site
			case "java.vendor.url":
				return "http://squirreljme.cc/";
				
				// The name of the runtime library
			case "java.runtime.name":
				return "SquirrelJME";
				
				// The version of the run-time
			case "java.runtime.version":
				return SystemProperties.javaRuntimeVersion();
				
				// End of line character
			case "line.separator":
				rv = SystemProperties.systemProperty("line.separator");
				if (rv == null)
					return "\n";
				return rv;
				
				// The current configuration, must be set!
			case "microedition.configuration":
				rv = SystemProperties.systemProperty(
					"microedition.configuration");
				if (rv == null)
					try
					{
						Class<?> file = Class.forName("java.nio.FileSystem");
						if (file == null)
							return "CLDC-1.8-Compact";
						return "CLDC-1.8";
					}
					catch (ClassNotFoundException e)
					{
						return "CLDC-1.8-Compact";
					}
				return rv;
				
				// The current encoding
			case "microedition.encoding":
				rv = SystemProperties.systemProperty("microedition.encoding");
				if (rv == null)
					return CodecFactory.FALLBACK_ENCODING;
				return rv;
				
				// The current local, must be set!
			case "microedition.locale":
				rv = SystemProperties.systemProperty("microedition.locale");
				if (rv == null)
					return "en-US";
				return rv;
				
				// The current platform
			case "microedition.platform":
				return "SquirrelJME/" + SquirrelJME.RUNTIME_VERSION;
				
				// Unknown, use system call
			default:
				return SystemProperties.systemProperty(__k);
		}
	}
	
	/**
	 * Obtains the specified system property and if it has not been set then
	 * the default value will be returned instead.
	 *
	 * @param __k The system property to get.
	 * @param __d If the system property is not set (returns {@code null}
	 * then this value will be returned instead.
	 * @throws IllegalArgumentException If the requested system property is
	 * not valid (it is blank).
	 * @throws NullPointerException If no key was specified.
	 * @throws SecurityException If obtaining the given system property is
	 * not permitted.
	 * @since 2017/08/13
	 */
	public static String getProperty(String __k, String __d)
		throws IllegalArgumentException, NullPointerException,
			SecurityException
	{
		// Get it
		String rv = getProperty(__k);
		
		// If not set, return the default, otherwise the read value
		if (rv == null)
			return __d;
		return rv;
	}
	
	/**
	 * Returns the current security manager that is in use.
	 *
	 * @return The current security manager in use.
	 * @since 2018/09/18
	 */
	public static SecurityManager getSecurityManager()
	{
		// Lock because it is managed by that class for checking
		synchronized (SecurityManager.class)
		{
			return SecurityManager._CURRENT_MANAGER;
		}
	}
	
	/**
	 * This returns the identity hash code of the object. The identity hash
	 * code is randomly given by the virtual machine to an object. There is
	 * no definition on how the value is to be derived. It may be a unique
	 * object ID or it may be a memory address. Two objects may also share the
	 * same identity hash code.
	 *
	 * @param __o The input object to get the hash code for.
	 * @return The hash code which was given by the virtual machine, if the
	 * input is {@code null} then {@code 0} is returned.
	 * @since 2015/11/09
	 */
	public static int identityHashCode(Object __o)
	{
		// If null, this is zero
		if (__o == null)
			return 0;
		
		return ObjectAccess.identityHashCode(__o);
	}
	
	/**
	 * Returns the number of nanoseconds which have passed from a previously
	 * unspecified time. The returned value might not be accurate to the
	 * nanosecond. This clock is monotonic and does not suffer from time
	 * shifts caused by clock adjustments.
	 *
	 * The value returned here is specific to the current virtual machine and
	 * cannot be used elsewhere. Even two virtual machines running on the
	 * same system can use completely different values.
	 *
	 * After about 292 years (2 to the 63rd power nanoseconds) using signed
	 * comparison to calculate the amount of time that has passed will no
	 * longer function properly. For extremely long running processes it is
	 * recommended to treat the values as unsigned to extend past this limit
	 * or handle the overflow of the time value to represent any time
	 * quantity, this of course requires that time be checked every 292 or
	 * 584 years).
	 *
	 * @return The number of nanoseconds which have passed.
	 * @since 2016/06/16
	 */
	public static long nanoTime()
	{
		// Returns the current monotonic clock time
		return Assembly.sysCallPVL(SystemCallIndex.TIME_NANO_MONO);
	}
	
	/**
	 * Sets the new destination for standard error.
	 *
	 * Note that the {@link System#err} field is not changed, a wrapper class
	 * is used to prevent reflective abuse.
	 *
	 * @param __a The new stream to use when outputting values.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current program lacks the given
	 * permission to set the stream.
	 * @since 2016/03/17
	 */
	public static void setErr(PrintStream __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Not allowed to do this?
		getSecurityManager().checkPermission(new RuntimePermission("setIO"));
		
		// Use a wrapped class to prevent final abuse.
		((__CanSetPrintStream__)err).__set(__a);
	}
	
	/**
	 * Sets the new destination for standard output.
	 *
	 * Note that the {@link System#out} field is not changed, a wrapper class
	 * is used to prevent reflective abuse.
	 *
	 * @param __a The new stream to use when outputting values.
	 * @throws NullPointerException On null arguments.
	 * @throws SecurityException If the current program lacks the given
	 * permission to set the stream.
	 * @since 2016/03/17
	 */
	public static void setOut(PrintStream __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Not allowed to do this?
		getSecurityManager().checkPermission(new RuntimePermission("setIO"));
		
		// Use a wrapped class to prevent final abuse.
		((__CanSetPrintStream__)out).__set(__a);
	}
}

Deleted runt/apis/cldc-compact/java/lang/Thread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.asm.StaticMethod;
import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.UncaughtExceptionHandler;
import java.util.HashMap;
import java.util.Map;

/**
 * A thread represents literally a single stream of execution that can
 * execute concurrently (or not).
 *
 * SquirrelJME may be running with multiple threads executing at once or it
 * may also be executing cooperatively (only a single thread at a time). If
 * SquirrelJME is running cooperatively then only locking,
 * {@link Thread.sleep(long, int)}, or {@link Thread.yield()} will allow
 * another thread to run.
 *
 * @since 2018/12/07
 */
@ImplementationNote("Internally all threads start in the Thread.__start() " +
	"method which sets up the thread and such.")
public class Thread
	implements Runnable
{
	/** Use fake name for string? */
	private static final String _USE_FAKE_NAME =
		new String();
	
	/** Maximum supported priority. */
	public static final int MAX_PRIORITY =
		10;
	
	/** Minimum supported priority. */
	public static final int MIN_PRIORITY =
		1;
	
	/** Default priority. */
	public static final int NORM_PRIORITY =
		5;
	
	/** Start kind: Self Runnable */
	private static final int _START_SELF_RUNNABLE =
		1;
	
	/** Start kind: Specified Runnable. */
	private static final int _START_GIVEN_RUNNABLE =
		2;
	
	/** Start kind: MIDlet (construct then run startApp()). */
	private static final int _START_MIDLET =
		3;
	
	/** Start kind: main() method (is String[] argument). */
	private static final int _START_MAIN =
		4;
	
	/** Threads by virtual ID. */
	private static final Map<Integer, Thread> _BY_VIRTID =
		new HashMap<>();
	
	/** Threads by real ID. */
	private static final Map<Integer, Thread> _BY_REALID =
		new HashMap<>();
	
	/** The next virtual thread ID. */
	private static volatile int _NEXT_VIRTUAL_ID =
		0;
	
	/** The active number of threads. */
	private static volatile int _ACTIVE_THREADS;
	
	/** Which kind of start are we doing? */
	private final int _startkind;
	
	/** The method to execute. */
	private final StaticMethod _runmethod;
	
	/** The argument to the method. */
	private final Object _runargument;
	
	/** The virtual thread ID. */
	private final int _virtid;
	
	/** The real thread ID. */
	private volatile int _realid =
		-1;
	
	/** The name of this thread. */
	private volatile String _name;
	
	/** Has this thread been started? */
	private volatile boolean _started;
	
	/** Is this thread alive? */
	private volatile boolean _isalive;
	
	/** The priority of the thread. */
	private volatile int _priority =
		NORM_PRIORITY;
	
	/** Is this thread interrupted? */
	volatile boolean _interrupted;
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses a default thread name.
	 *
	 * @since 2018/11/17
	 */
	public Thread()
	{
		this(null, _USE_FAKE_NAME);
	}
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses a default thread name.
	 *
	 * @param __r The runnable to execute.
	 * @since 2018/11/17
	 */
	public Thread(Runnable __r)
	{
		this(__r, _USE_FAKE_NAME);
	}
	
	/**
	 * Initializes the thread which invokes this object's {@link #run()} and
	 * uses the specified thread name.
	 *
	 * @param __n The thread's name.
	 * @throws NullPointerException If the thread name is null.
	 * @since 2018/11/17
	 */
	public Thread(String __n)
		throws NullPointerException
	{
		this(null, __n);
	}
	
	/**
	 * Initializes the thread which invokes the given {@link Runnable} and uses
	 * the given name.
	 *
	 * @param __r The runnable to execute.
	 * @param __n The thread's name.
	 * @throws NullPointerException If the thread name is null.
	 * @since 2018/11/17
	 */
	public Thread(Runnable __r, String __n)
		throws NullPointerException
	{
		this(__n, (__r == null ? _START_SELF_RUNNABLE : _START_GIVEN_RUNNABLE),
			null, __r);
	}
	
	/**
	 * Initializes a thread which is registered in this constructor and
	 * additionally has the given name and real ID.
	 *
	 * The thread is started in the started state and technically is not
	 * removed ever. This is generally used by the native display thread
	 * since there has to be a thread running as the VM sees it otherwise
	 * things will break much. A thread started this way never terminates
	 * unless that termination is explicit.
	 *
	 * @param __n The thread name.
	 * @param __rid The real ID.
	 * @since 2018/12/03
	 */
	private Thread(int __rid, String __n)
	{
		this._startkind = -1;
		this._runmethod = null;
		this._runargument = null;
		this._realid = __rid;
		this._name = __n;
		this._started = true;
		this._isalive = true;
		
		// Obtain the next virtual ID to use
		int virtid;
		synchronized (Thread.class)
		{
			this._virtid = (virtid = _NEXT_VIRTUAL_ID++);
		}
		
		// Now register this thread in the main objects
		this.__registerThread();
	}
	
	/**
	 * Initializes the thread to execute the given static method.
	 *
	 * @param __n The name of the thread.
	 * @param __rk How is this method to be run?
	 * @param __mm The static method to call.
	 * @param __ma The argument to use.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/11/20
	 */
	private Thread(String __n, int __rk, StaticMethod __mm, Object __ma)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Obtain the next virtual ID to use
		int virtid;
		synchronized (Thread.class)
		{
			this._virtid = (virtid = _NEXT_VIRTUAL_ID++);
		}
		
		// Set
		this._name = (__n == _USE_FAKE_NAME ? "Thread-" + virtid : __n);
		this._startkind = __rk;
		this._runmethod = __mm;
		this._runargument = __ma;
		
		// The main thread is implicitly started
		boolean implicitstart = (__rk == _START_MAIN || __rk == _START_MIDLET);
		this._started = implicitstart;
	}
	
	/**
	 * Checks that the thread has access to perform some operations.
	 *
	 * @throws SecurityException If access is denied.
	 * @since 2018/11/21
	 */
	public final void checkAccess()
		throws SecurityException
	{
		SecurityManager sm = System.getSecurityManager();
		if (sm != null)
			sm.checkAccess(this);
	}
	
	/**
	 * Returns the ID of this thread.
	 *
	 * @return The thread ID.
	 * @since 2018/11/20
	 */
	public long getId()
	{
		return this._virtid;
	}
	
	/**
	 * Returns the name of this thread.
	 *
	 * @return The thread name.
	 * @since 2018/11/17
	 */
	public final String getName()
	{
		return this._name;
	}
	
	/**
	 * Returns the priority of the thread.
	 *
	 * @return The thread priority.
	 * @since 2018/12/07
	 */
	public final int getPriority()
	{
		return this._priority;
	}
	
	/**
	 * Interrupts the thread.
	 *
	 * @since 2018/11/21
	 */
	public void interrupt()
	{
		// Signal software interrupt
		this._interrupted = true;
		
		// Signal hardware interrupt
		int realid = this._realid;
		if (realid >= 0)
			TaskAccess.signalInterrupt(realid);
	}
	
	/**
	 * Is this thread currently alive?
	 *
	 * @return If this thread is alive.
	 * @since 2018/11/20
	 */
	public final boolean isAlive()
	{
		return this._isalive;
	}
	
	/**
	 * Is this thread interrupted?
	 *
	 * @return If this thread is interrupted.
	 * @since 2018/11/21
	 */
	public boolean isInterrupted()
	{
		return this._interrupted;
	}
	
	/**
	 * Waits forever for a thread to die or until interrupted.
	 *
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join()
		throws InterruptedException
	{
		this.join(0, 0);
	}
	
	/**
	 * Waits for a thread to die.
	 *
	 * @param __ms The milliseconds to wait for, if this is zero then this
	 * will wait forever.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join(long __ms)
		throws IllegalArgumentException, InterruptedException
	{
		this.join(__ms, 0);
	}
	
	/**
	 * Waits for a thread to die.
	 *
	 * If both milliseconds and nanoseconds are zero this will wait forever.
	 *
	 * @param __ms The milliseconds to wait for.
	 * @param __ns The nanoseconds to wait for.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/12/07
	 */
	public final void join(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// The end time, since our thread could be notified
		long end = (__ms == 0 && __ns == 0 ? Long.MAX_VALUE :
			System.nanoTime() + (__ms * 1_000_000L) + __ns);
		
		// Lock on self
		synchronized (this)
		{
			// Loop constantly until the thread is dead
			for (;;)
			{
				// Time ended?
				long now;
				if ((now = System.nanoTime()) >= end)
					return;
				
				// Did the thread die yet?
				if (this._started && !this._isalive)
					return;
				
				// Otherwise wait on our own monitor
				long diff = end - now;
				this.wait(diff / 1_000_000L, (int)(diff % 1_000_000L));
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	public void run()
	{
		// Does nothing
	}
	
	/**
	 * Sets the name of the thread.
	 *
	 * @param __n The new name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public final void setName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Check access first
		this.checkAccess();
		
		// Set new name
		synchronized (this)
		{
			this._name = __n;
		}
	}
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __p The thread priority.
	 * @throws IllegalArgumentException If the priority is not valid.
	 * @throws SecurityException If setting the priority is not permitted.
	 * @since 2018/12/07
	 */
	public final void setPriority(int __p)
		throws IllegalArgumentException, SecurityException
	{
		// {@squirreljme.error ZZ20 Invalid priority.}
		if (__p < MIN_PRIORITY || __p > MAX_PRIORITY)
			throw new IllegalArgumentException("ZZ20");
		
		// Check access
		this.checkAccess();
		
		// Store for later
		this._priority = __p;
		
		// Only set the priority if the thread is active
		int realid = this._realid;
		if (realid >= 0)
			TaskAccess.setThreadPriority(realid, __p);
	}
	
	/**
	 * Starts the specified thread.
	 *
	 * @throws IllegalThreadStateException 
	 * @since 2018/11/17
	 */
	public void start()
		throws IllegalThreadStateException
	{
		synchronized (this)
		{
			// {@squirreljme.error ZZ21 A thread may only be started once.}
			if (this._started)
				throw new IllegalThreadStateException("ZZ21");
			this._started = true;
			
			// Start the thread
			int realid = TaskAccess.startThread(this, this._name);
			this._realid = realid;
			
			// {@squirreljme.error ZZ22 Could not start the thread.}
			if (realid < 0)
				throw new RuntimeException("ZZ22");
			
			// Set the initial priority of the thread
			TaskAccess.setThreadPriority(realid, this._priority);
			this._isalive = true;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public String toString()
	{
		// JavaSE is in the format of `Thread[name,priority,group]` but
		// we do not have thread groups here
		return "Thread[" + this._name + "," + this._priority + "]";
	}
	
	/**
	 * Returns the number of threads which are currently alive.
	 *
	 * @return The number of alive threads.
	 * @since 2018/11/20
	 */
	public static int activeCount()
	{
		return Thread._ACTIVE_THREADS;
	}
	
	/**
	 * Returns the current thread.
	 *
	 * @return The current thread.
	 * @since 2018/11/20
	 */
	public static Thread currentThread()
	{
		int rid = TaskAccess.currentThread();
		
		// If the map is not initialized yet, ignore
		Map<Integer, Thread> byrealid = _BY_REALID;
		if (byrealid == null)
			return null;
		
		// Lock, it should be in the map
		synchronized (Thread.class)
		{
			return byrealid.get(rid);
		}
	}
	
	/**
	 * Checks if the current thread holds the monitor for the given object.
	 *
	 * @param __o The object to check.
	 * @return If the thread owns the monitor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public static boolean holdsLock(Object __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		return ObjectAccess.holdsLock(TaskAccess.currentThread(), __o);
	}
	
	/**
	 * Checks if the current thread was interrupted, if it was then the
	 * interrupt status will be cleared.
	 *
	 * @return If this thread was interrupted.
	 * @since 2018/11/21
	 */
	public static boolean interrupted()
	{
		Thread self = Thread.currentThread();
		
		// Check interrupt?
		boolean rv = self._interrupted;
		self._interrupted = false;
		return rv;
	}
	
	/**
	 * Causes the thread to sleep for the given amount of milliseconds.
	 *
	 * @param __ms The number of milliseconds to sleep for.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/11/04
	 */
	public static void sleep(long __ms)
		throws InterruptedException
	{
		Thread.sleep(__ms, 0);
	}
	
	/**
	 * Causes the thread to sleep for the given milliseconds and nanoseconds.
	 *
	 * @param __ms The milliseconds to sleep for.
	 * @param __ns The nanoseconds to sleep for, in the range of 0-999999.
	 * @throws IllegalArgumentException If the milliseconds and/or nanoseconds
	 * are out of range.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/11/04
	 */
	public static void sleep(long __ms, int __ns)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ23 Invalid sleep arguments.}
		if (__ms < 0 || __ns < 0 || __ns > 999999)
			throw new IllegalArgumentException("ZZ23");
		
		// Convert to integer but do not sleep for too long
		int ims = (__ms > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)__ms);
		
		// Perform sleep, if it was interrupted then the return status will
		// be non-zero!
		if (Assembly.sysCallV(SystemCallIndex.SLEEP, ims, __ns) != 0)
		{
			Thread.currentThread()._interrupted = false;
			
			// {@squirreljme.error ZZ24 Sleep was interrupted.}
			throw new InterruptedException("ZZ24");
		}
	}
	
	/**
	 * Yields the current thread giving up its execution slice, but allowing
	 * it to continue instantly resuming as needed.
	 *
	 * @since 2018/12/05
	 */
	public static void yield()
	{
		// Zero times means to yield
		Assembly.sysCallV(SystemCallIndex.SLEEP, 0, 0);
	}
	
	/**
	 * Registers this thread so that way it is in the thread list and can be
	 * obtained and such.
	 *
	 * @since 2018/12/03
	 */
	final void __registerThread()
	{
		// Lock
		synchronized (Thread.class)
		{
			// Increase the active thread count
			Thread._ACTIVE_THREADS++;
			
			// Add threads to the thread list
			Map<Integer, Thread> byvirtid = Thread._BY_VIRTID,
				byrealid = Thread._BY_REALID;
			byvirtid.put(this._virtid, this);
			byrealid.put(this._realid, this);
		}
	}
	
	/**
	 * Ends the current thread and cleans up its registration.
	 *
	 * @since 2018/12/03
	 */
	final void __revokeThread()
	{
		// Thread no longer alive
		this._isalive = false;
		
		// Lock
		synchronized (Thread.class)
		{
			// Decrease the active count
			Thread._ACTIVE_THREADS--;
			
			// Remove from the thread list
			Map<Integer, Thread> byvirtid = Thread._BY_VIRTID,
				byrealid = Thread._BY_REALID;
			byvirtid.remove(this._virtid);
			byrealid.remove(this._realid);
		}
		
		// Signal all threads which are waiting on a join for this thread
		// only
		synchronized (this)
		{
			this.notifyAll();
		}
		
		// Signal anything waiting on the class itself, to indicate that
		// a thread has finished
		int startkind = this._startkind;
		if (startkind != _START_MAIN && startkind != _START_MIDLET)
			synchronized (Thread.class)
			{
				Thread.class.notifyAll();
			}
	}
	
	/**
	 * This is the starting point for all threads, including the main thread
	 * and such.
	 *
	 * @throws IllegalThreadStateException If the thread has already been
	 * started.
	 * @since 2018/11/20
	 */
	@ImplementationNote("This is the starting point of all threads.")
	final void __start()
		throws IllegalThreadStateException
	{
		// Get the kind and determine if this is a main entry point
		int startkind = this._startkind;
		boolean ismain = (startkind == _START_MAIN ||
			startkind == _START_MIDLET);
		
		// We need to lock because the real ID might just not get assigned
		// yet here.
		int realid;
		int virtid = this._virtid;
		if (!ismain)
			synchronized (this)
			{
				// {@squirreljme.error ZZ25 Real ID has not been set yet while
				// in the lock, this should not occur unless the virtual
				// machine is very broken.}
				if ((realid = this._realid) < 0)
					throw new Error("ZZ25");
			}
		
		// Main thread, so set our real ID to the current thread the VM says
		// we are since it will still be negatively initialized 
		else
		{
			realid = TaskAccess.currentThread();
			this._realid = realid;
		}
		
		// The exit code is something that is only handled by the main thread
		// It will exit with the given code 
		int exitcode = 0;
		
		// Execution setup
		try
		{
			// Register this thread
			this.__registerThread();
				
			// Set the thread as alive
			this._isalive = true;
			
			// The main method and/or its arguments
			StaticMethod runmethod = this._runmethod;
			Object runargument = this._runargument;
			
			// How do we run this thread?
			switch (this._startkind)
			{
					// Start Runnable in this instance (extended from)
				case _START_SELF_RUNNABLE:
					this.run();
					break;
					
					// Start the given runnable
				case _START_GIVEN_RUNNABLE:
					((Runnable)runargument).run();
					break;
					
					// Start MIDlet, construct then startApp()
				case _START_MIDLET:
					ObjectAccess.invokeStatic(runmethod,
						ObjectAccess.classByName((String)runargument).
						__newInstance());
					break;
					
					// Start main(String[]) method
				case _START_MAIN:
					ObjectAccess.invokeStatic(runmethod, runargument);
					break;
					
					// Unknown
				default:
					throw new todo.OOPS();
			}
		}
		
		// Uncaught exception
		catch (Throwable t)
		{
			// Set the exit code for the process to some error number, if
			// the VM does not exit in this thread but exits in another
			// it would at least be set for the main thread
			// But this is only needed for the main thread
			if (ismain)
				exitcode = 127;
			
			// Handle uncaught exception
			UncaughtExceptionHandler.handle(t);
		}
		
		// Cleanup after the thread:
		//  * Signal joins (for those that are waiting)
		//  * Remove the thread from the thread list
		//  * Decrease the active count
		//  * Set thread as not alive
		finally
		{
			// Revoke this thread
			this.__revokeThread();
		}
		
		// If this is the main thread, wait for every other thread to
		// stop execution. This saves the VM execution code itself from
		// worrying about which threads are running or not.
		if (ismain)
		{
			// Wait for threads to go away
			for (;;)
			{
				// No threads are active, so that works
				if (Thread._ACTIVE_THREADS == 0)
					break;
				
				// Wait a bit until trying again, unless we get notified
				synchronized (Thread.class)
				{
					try
					{
						// Three seconds is short enough to not be forever
						// but long enough to where we can get a notify to
						// quit
						Thread.class.wait(3_000);
					}
					catch (InterruptedException e)
					{
					}
				}
			}
			
			// Exit the VM with our normal exit code, since no other
			// thread called exit at all for this point
			Assembly.sysCall(SystemCallIndex.EXIT, exitcode);
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/Throwable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482


































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * This class is the base class for all types which are thrown, itself being a
 * checked exception handled by the compiler.
 *
 * Each {@link Throwable} contains internal stack trace information which is
 * initialized when the {@link Throwable} is.
 *
 * A {@link Throwable} may have suppressed exceptions, which are exceptions
 * which may be added to a {@link Throwable} to indicate that there was an
 * exception that was caused in a try-with-resources when the resource was
 * attempted to be closed.
 *
 * @since 2018/09/15
 */
public class Throwable
{
	/** Exception message. */
	private static final int _TYPE_EXCEPTION =
		0;
	
	/** Caused by message. */
	private static final int _TYPE_CAUSED_BY =
		1;
	
	/** Suppressed message. */
	private static final int _TYPE_SUPPRESSED =
		2;
	
	/** The message for this exception. */
	private final String _message;
	
	/** Suppressed exceptions. */
	private volatile Throwable[] _suppressed;
	
	/** Was a cause initialized already? */
	private volatile boolean _initcause;
	
	/**
	 * The cause of this exception, note this is writeable because of
	 * {@link #initCause(Throwable)}. This is mostly just for older versions
	 * of the class library which did not have a cause specified in the
	 * constructor.
	 */
	private volatile Throwable _cause;
	
	/** The stack trace for this throwable (in raw form). */
	private volatile int[] _stack;
	
	/**
	 * Initializes a throwable with no cause or message.
	 *
	 * @since 2018/09/15
	 */
	public Throwable()
	{
		this(false, 2, null, null);
	}
	
	/**
	 * Initializes a throwable with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public Throwable(String __m)
	{
		this(false, 2, __m, null);
	}
	
	/**
	 * Initializes a throwable with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	public Throwable(Throwable __t)
	{
		this(true, 2, null, __t);
	}
	
	/**
	 * Initializes a throwable with the given cause and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	public Throwable(String __m, Throwable __t)
	{
		this(true, 2, __m, __t);
	}
	
	/**
	 * Since the cause can only be set once, this constructor needs to keep
	 * track of whether it was set by a constructor or not.
	 *
	 * @param __ic Is the cause initialized?
	 * @param __clip The number of stack trace entries to clip.
	 * @param __m The exception message.
	 * @param __t The cause.
	 * @since 2018/09/15
	 */
	private Throwable(boolean __ic, int __clip, String __m, Throwable __t)
	{
		// These are trivially set
		this._message = __m;
		this._cause = __t;
		this._initcause = __ic;
		
		// The stack trace is implicitly filled in by this constructor, it
		// matches the stack trace of the current thread of execution
		this._stack = this.__getStackTrace(this, __clip, true);
	}
	
	/**
	 * Adds a suppressed throwable which will be thrown alongside this
	 * throwable. This is mainly used with try-with-resources although a
	 * programmer may wish to add related throwables that additionally
	 * happened.
	 *
	 * This method is thread safe.
	 *
	 * @param __t The throwable to suppress.
	 * @throws IllegalArgumentException If the passed throwable is this.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final void addSuppressed(Throwable __t)
		throws IllegalArgumentException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ26 Cannot add a suppressed exception which
		// is this exception.}
		if (__t == this)
			throw new IllegalArgumentException("ZZ26");
		
		// Just lock on this to add suppressed exceptions, it is unspecified
		// where the lock is done, but this prevent creation of an object just
		// to hold a lock.
		synchronized (this)
		{
			// No suppressed exceptions were set, initialize
			Throwable[] suppressed = this._suppressed;
			if (suppressed == null)
				this._suppressed = new Throwable[]{__t};
			
			// Otherwise rebuild the array and add it
			else
			{
				int n = suppressed.length;
				Throwable[] copy = new Throwable[n + 1];
				for (int i = 0; i < n; i++)
					copy[i] = suppressed[i];
				copy[n] = __t;
				
				// Use this instead
				this._suppressed = copy;
			}
		}
	}
	
	/**
	 * Fills in the stack trace of this throwable for the current thread.
	 *
	 * @return {@code this}.
	 * @since 2018/09/15
	 */
	public Throwable fillInStackTrace()
	{
		// Get stack trace, ignore this method
		this._stack = this.__getStackTrace(this, 1, false);
		
		// Returns self
		return this;
	}
	
	/**
	 * Returns the throwable which caused this throwable to occur.
	 *
	 * @return The throwable which caused this throwable.
	 * @since 2018/09/15
	 */
	public Throwable getCause()
	{
		return this._cause;
	}
	
	/**
	 * Returns a potentially localized message for this throwable, the default
	 * implementation just returns {@link #getMessage()}.
	 *
	 * @return A localized message.
	 * @since 2018/09/15
	 */
	public String getLocalizedMessage()
	{
		return this.getMessage();
	}
	
	/**
	 * Returns the message which was set for this throwable, if one was set.
	 *
	 * @return The message for this throwable, may be {@code null} if one was
	 * not set.
	 * @since 2018/09/15
	 */
	public String getMessage()
	{
		return this._message;
	}
	
	/**
	 * Returns an array of all the throwables which were suppressed.
	 *
	 * This method is thread safe.
	 *
	 * @return An array of all the suppresed throwables.
	 * @since 2018/09/15
	 */
	public final Throwable[] getSuppressed()
	{
		// Since this is volatile we can just read whatever value is here
		// without needing to lock
		Throwable[] rv = this._suppressed;
		if (rv == null)
			return new Throwable[0];
		return rv.clone();
	}
	
	/**
	 * Initializes the cause of the throwable if it has not been set.
	 *
	 * Calls to {@link #initCause(Throwable)}, {@link #Throwable(Throwable)},
	 * or {@link #Throwable(String, Throwable)} will cause the cause to be
	 * initialized, preventing this from being called or called again.
	 *
	 * @param __t The cause of the throwable.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the cause is this throwable.
	 * @throws IllegalStateException If a cause has already been set.
	 * @since 2018/09/15
	 */
	public Throwable initCause(Throwable __t)
		throws IllegalArgumentException, IllegalStateException
	{
		// {@squirreljme.error ZZ27 Cannot initialize the cause of the
		// throwable with itself as the cause.}
		if (__t == this)
			throw new IllegalArgumentException("ZZ27");
		
		// {@squirreljme.error ZZ28 The cause of the throwable has already
		// been initialized.}
		if (this._initcause)
			throw new IllegalStateException("ZZ28");
		
		// Set
		this._initcause = true;
		this._cause = __t;
		
		return this;
	}
	
	/**
	 * Prints the stack trace to the standard error stream.
	 *
	 * @since 2018/09/15
	 */
	public void printStackTrace()
	{
		Throwable.__printStackTrace(this, System.err, 0, _TYPE_EXCEPTION);
	}
	
	/**
	 * Prints the stack trace to the specified stream.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public void printStackTrace(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		Throwable.__printStackTrace(this, __ps, 0, _TYPE_EXCEPTION);
	}
	
	/**
	 * Returns a string representation of this throwable.
	 *
	 * If there is a localized message, the form is `<class>: <message>`.
	 * If there is no message, the form is `<class>`. 
	 *
	 * @return A string representing this throwable.
	 * @since 2018/09/15
	 */
	@Override
	public String toString()
	{
		String clname = this.getClass().getName(),
			lm = this.getLocalizedMessage();
		
		if (lm == null)
			return clname;
		return clname + ": " + lm;
	}
	
	/**
	 * Obtains the stack trace for the current thread in raw format.
	 *
	 * @param __this The this throwable object.
	 * @param __clip The number of entries on the top to clip.
	 * @param __initclip Clip off initializers?
	 * @return The stack trace for the current stack.
	 * @throws IllegalArgumentException If the clip is negative.
	 * @since 2018/09/16
	 */
	private static int[] __getStackTrace(Throwable __this,
		int __clip, boolean __initclip)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ29 Cannot specify a negative clip for a
		// stack trace.}
		if (__clip < 0)
			throw new IllegalArgumentException("ZZ29");
		
		// Get the raw trace here
		int[] rawstack = CallTraceElement.traceRaw();
		
		// Just use the raw stack
		return rawstack;
	}
	
	/**
	 * Prints the indentation of the stack trace.
	 *
	 * @param __ps The stream to print to.
	 * @param __indent The current indentation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/11
	 */
	private static void __printStackIndent(PrintStream __ps, int __indent)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Doing nothing
		if (__indent == 0)
			return;
		
		// Base space indent
		__ps.print("  ");
		
		// Print bars for indentation level
		for (int i = 0; i < __indent; i++)
			__ps.print('|');
	}
	
	/**
	 * Prints the stack trace to the specified stream. This is internal so that
	 * one stack printing does not call the other since it is not specified if
	 * it actually does it.
	 *
	 * @param __t The throwable to print for.
	 * @param __ps The stream to print to.
	 * @param __indent The indentation level.
	 * @param __type The string type to use for the message base.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private static void __printStackTrace(Throwable __t, PrintStream __ps,
		int __indent, int __type)
		throws NullPointerException
	{
		if (__t == null || __ps == null)
			throw new NullPointerException("NARG");
		
		// Internally raw stacks are stored since that is the fastest way
		// to generate a stack trace, which will only be resolved when this
		// method is called to print.
		int[] rawstack = __t._stack;
		if (rawstack == null)
		{
			__ps.println("<No stack trace>");
			return;
		}
		
		// Resolve the stack trace so it is easier to work with
		CallTraceElement[] stack = CallTraceElement.traceResolve(rawstack);
		
		// Indent and print exception type
		Throwable.__printStackIndent(__ps, __indent);
		switch (__type)
		{
			case _TYPE_CAUSED_BY:
				__ps.print("> CAUSED BY ");
				break;
			
			case _TYPE_SUPPRESSED:
				__ps.print("> SUPPRESSED ");
				break;
			
			case _TYPE_EXCEPTION:
			default:
				__ps.print("EXCEPTION ");
				break;
		}
		
		// Then the string representation of it, which may be replaced
		__ps.println(__t.toString());
		
		// Increase indentation to get more bars
		__indent++;
		
		// The first entry is the top of the stack so it gets printed first 
		String wasclass = "<Unknown>";
		for (int i = 0, n = stack.length; i < n; i++)
		{
			// Ignore any elements that may happen to be null
			CallTraceElement e = stack[i];
			if (e == null)
				continue;
			
			// Get the element class, always make sure the class is valid
			// even if it is not known
			String nowclass = e.className();
			if (nowclass == null)
				nowclass = "<Unknown>";
			
			// If the class changed, specify that it has
			if (!nowclass.equals(wasclass))
			{
				// Indent
				Throwable.__printStackIndent(__ps, __indent);
				
				__ps.print(" IN ");
				__ps.println(e.toClassHeaderString());
				
				// Changed
				wasclass = nowclass;
			}
			
			// Indent and print the at line
			Throwable.__printStackIndent(__ps, __indent);
			__ps.print("- ");
			__ps.println(e.toAtLineString());
		}
		
		// Print cause of the exception
		Throwable cause = __t.getCause();
		if (cause != null)
			Throwable.__printStackTrace(cause, __ps, __indent,
				_TYPE_CAUSED_BY);
		
		// Print suppressed exceptions
		for (Throwable sup : __t.getSuppressed())
			Throwable.__printStackTrace(sup, __ps, __indent,
				_TYPE_SUPPRESSED);
	}
}

Deleted runt/apis/cldc-compact/java/lang/UnsupportedClassVersionError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the version of a class is not supported.
 *
 * @since 2018/12/04
 */
public class UnsupportedClassVersionError
	extends ClassFormatError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public UnsupportedClassVersionError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public UnsupportedClassVersionError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/UnsupportedOperationException.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

public class UnsupportedOperationException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public UnsupportedOperationException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/apis/cldc-compact/java/lang/VirtualMachineError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the virtual machine has encountered an error.
 *
 * @since 2018/12/04
 */
public class VirtualMachineError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public VirtualMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public VirtualMachineError(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/lang/__CanSetPrintStream__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
























































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.io.PrintStream;

/**
 * This is an internal {@link PrintStream} which can have the target stream
 * it writes to changed. This is to prevent abuse of using reflection to
 * change final values. Due to the potential to have extremely aggressive
 * optimization and romization, having it not do this would be dangerous
 * because in fully optimized code, the finals will NEVER change regardless
 * of how many times stream setting is called.
 *
 * @since 2016/03/17
 */
final class __CanSetPrintStream__
	extends PrintStream
{
	/** Internal lock. */
	protected final Object lock =
		new Object();
	
	/** Target output stream. */
	private volatile PrintStream _target;
	
	/**
	 * Initializes the settable proxy for the given stream as the default
	 * value.
	 *
	 * @param __def The initial stream to target.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/17
	 */
	__CanSetPrintStream__(PrintStream __def)
		throws NullPointerException
	{
		super(__def, true);
		
		// Check
		if (__def == null)
			throw new NullPointerException("NARG");
		
		// Set
		_target = __def;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(CharSequence __a)
	{
		// Lock
		synchronized (lock)
		{
			return _target.append(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(CharSequence __a, int __b, int __c)
	{
		// Lock
		synchronized (lock)
		{
			return _target.append(__a, __b, __c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream append(char __a)
	{
		// Lock
		synchronized (lock)
		{
			return _target.append(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public boolean checkError()
	{
		// Lock
		synchronized (lock)
		{
			return _target.checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void close()
	{
		// Lock
		synchronized (lock)
		{
			_target.close();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void flush()
	{
		// Lock
		synchronized (lock)
		{
			_target.flush();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream format(String __a, Object... __b)
	{
		// Lock
		synchronized (lock)
		{
			return _target.format(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(boolean __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(char __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(int __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(long __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(float __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(double __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(char[] __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(String __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void print(Object __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.print(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public PrintStream printf(String __a, Object... __b)
	{
		// Lock
		synchronized (lock)
		{
			return _target.printf(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println()
	{
		// Lock
		synchronized (lock)
		{
			_target.println();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(boolean __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(char __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(int __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(long __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(float __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(double __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(char[] __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(String __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void println(Object __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.println(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void write(int __a)
	{
		// Lock
		synchronized (lock)
		{
			_target.write(__a);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/17
	 */
	@Override
	public void write(byte[] __a, int __b, int __c)
	{
		// Lock
		synchronized (lock)
		{
			_target.write(__a, __b, __c);
		}
	}
	
	/**
	 * Sets the new stream to target.
	 *
	 * @param __ps The stream to target.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/17
	 */
	void __set(PrintStream __ps)
		throws NullPointerException
	{
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// If this is a can set stream then we likely tried to restore the
		// old output stream, so if we ever print anything again this will
		// fail completely with infinite recursion.
		while (__ps instanceof __CanSetPrintStream__)
			__ps = ((__CanSetPrintStream__)__ps)._target;
		
		// Lock
		synchronized (lock)
		{
			// Flush the current stream so any written bytes are written to
			// the output, so that they are not lost forever. However some
			// trickery could be done which causes flush to fail.
			try
			{
				this.flush();
			}
			
			// Completely ignore, also do not try printing the stack trace
			// because an infinite loop could occur.
			catch (Throwable t)
			{
			}
		
			// Change it
			this._target = __ps;
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/annotation/Annotation.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is the common interface in which all annotation types are inherited
 * from.
 *
 * If a random class or interface implements this interface and it is not an
 * annotation type, then it is not an annotation.
 *
 * @since 2014/10/13
 */
public interface Annotation
{
	/**
	 * Returns the annotation type used for this annotation.
	 *
	 * @return The annotation type.
	 * @since 2014/10/13
	 */
	public abstract Class<? extends Annotation> annotationType();
	
	/**
	 * Checks the logical equality to another annotation type, they are both
	 * considered to be equal when all of their members are equal and they are
	 * of the same type.
	 *
	 * Primitive types are checked directly except for floating point types
	 * which are equality checked through their wrapper classes.
	 *
	 * Floating point NaN values are considered to be equal, that is the
	 * {@code ==} operator is not used.
	 *
	 * {@link String}, {@link Class}, and enumerations are considered equal if
	 * their normal {@code equals()} evaluates to true.
	 *
	 * Two arrays are equal if {@code Arrays.equals(a, b)} evaluates to
	 * {@code true}.
	 *
	 * @param __o The other object to check against.
	 * @return {@code true} if they are logically equivalent.
	 * @since 2014/10/13
	 */
	public abstract boolean equals(Object __o);
	
	/**
	 * Calculates the hash code which is a sum of the hash codes of its members
	 * in a specifically defined pattern.
	 *
	 * The base hash code for a member is {@code (127 *
	 * ((String)memberName).hashCode()) ^ specialValue}. The variable
	 * {@code specialValue} is defined depending on the
	 * context. If it is a primitive type, then the hash code that would be
	 * returned if they were object types (their wrapper classes) is used. If
	 * an array then {@code Arrays.hashCode()} is used. Otherwise, it is the
	 * normal hashCode of the specified value.
	 *
	 * @return The hash code for this annotation.
	 * @since 2014/10/13
	 */
	public abstract int hashCode();
	
	/**
	 * Returns an implementation dependent string which represents the
	 * annotation and all of its values.
	 *
	 * @return The string representation of this annotation.
	 * @since 2014/10/13
	 */
	public abstract String toString();
}

Deleted runt/apis/cldc-compact/java/lang/annotation/Documented.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This indicates that the specified annotation should be documented by the
 * Java documentation tool whenever it is used.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Documented
{
}

Deleted runt/apis/cldc-compact/java/lang/annotation/ElementType.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the type of element that the annotation is permitted to be
 * attached to in the source code.
 *
 * @since 2014/10/13
 */
public enum ElementType
{
	/** Annotation types). */
	ANNOTATION_TYPE(),
	
	/** Constructors. */
	CONSTRUCTOR(),
	
	/** Fields. */
	FIELD(),
	
	/** Local variables. */
	LOCAL_VARIABLE(),
	
	/** Methods. */
	METHOD(),
	
	/** Packages. */
	PACKAGE(),
	
	/** Parameter of a method. */
	PARAMETER(),
	
	/** A class, interface, or enumeration. */
	TYPE(),
	
	/** End. */
	;
}

Deleted runt/apis/cldc-compact/java/lang/annotation/Inherited.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Indicates that the annotation type should automatically be inherited so that
 * the subclass type appears to have this annotation when it is requested. That
 * is, if an annotation with this annotation is requested it will keep going up
 * the superclasses until it is found.
 *
 * This only affects classes which use an annotation with this annotation, as
 * such interfaces are excluded.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Inherited
{
}

Deleted runt/apis/cldc-compact/java/lang/annotation/Retention.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is used to indicate how far into the compilation and runtime process
 * should keep a visible mark on an annotation.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Retention
{
	/**
	 * Specifies where the annotation exists during and after compilation of
	 * source code.
	 *
	 * @return The storage of the annotation.
	 * @see RetentionPolicy
	 * @since 2014/10/13
	 */
	RetentionPolicy value();
}

Deleted runt/apis/cldc-compact/java/lang/annotation/RetentionPolicy.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies how far through compilation and running of code that an annotation
 * should be visible.
 *
 * @since 2014/10/13
 */
public enum RetentionPolicy
{
	/** Kept after compilation, but not visible at runtime. */
	CLASS(),
	
	/** Kept after compilation and visible at runtime. */
	RUNTIME(),
	
	/** Removed after compilation, does not appear in the class file. */
	SOURCE(),
	
	/** End. */
	;
}

Deleted runt/apis/cldc-compact/java/lang/annotation/Target.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the context in which the annotation is valid.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Target
{
	/**
	 * A list of valid contexts where the annotation may be used.
	 *
	 * @return An array of permitted targets.
	 * @since 2014/10/13
	 */
	ElementType[] value();
}

Deleted runt/apis/cldc-compact/java/lang/ref/Reference.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
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



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.ref;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;

/**
 * This class represents references which may be referred to using various
 * different means of attachment, as such this family of classes integrates
 * with the garbage collector.
 *
 * @param <T> The type of object to store.
 * @since 2018/09/23
 */
public abstract class Reference<T>
{
	/** The primitive reference used to access the object. */
	private final PrimitiveReference _ref;
	
	/** The queue this reference is in, volatile to be clearned. */
	private volatile ReferenceQueue<? super T> _queue;
	
	/** Has this been enqueued? */
	private volatile boolean _enqueued;
	
	/**
	 * Initializes a reference pointing to the given object and an optionally
	 * specified queue to place this reference into when garbage collection
	 * occurs.
	 *
	 * @param __r The primitive reference storage.
	 * @param __v The object to point to, may be {@code null}.
	 * @param __q When the given object is garbage collected the specified
	 * queue will be given this reference (not {@link __v} itself}, may be
	 * {@code null}
	 * @since 2018/09/23
	 */
	Reference(PrimitiveReference __r, T __v, ReferenceQueue<? super T> __q)
	{
		// Set
		this._ref = __r;
		this._queue = __q;
		
		// Set primitive reference data
		ObjectAccess.referenceSet(__r, __v);
	}
	
	/**
	 * Clears this reference without placing it in the queue.
	 *
	 * @since 2018/09/23
	 */
	public void clear()
	{
		ObjectAccess.referenceSet(this._ref, null);
	}
	
	/**
	 * Places this reference in the queue.
	 *
	 * @return If it was added to the queue then this will return true,
	 * otherwise if there is no queue or it was already added this will
	 * return false.
	 * @since 2018/09/23
	 */
	public boolean enqueue()
	{
		// Already been enqueued
		ReferenceQueue<? super T> queue = this._queue;
		if (this._enqueued || queue == null)
			return false;
		
		// Enqueue it
		queue.__enqueue(this);
		
		// The queue is not needed anymore so there is no need to keep a
		// reference to it around, this will help remove circular references
		// if one forgets to drain the queues.
		this._enqueued = true;
		this._queue = null;
		
		// Was enqueued
		return true;
	}
	
	/**
	 * Returns the object that this reference refers to.
	 *
	 * @return The reference of this object.
	 * @since 2018/09/23
	 */
	@SuppressWarnings({"unchecked"})
	public T get()
	{
		// If the reference was cleared, enqueue it!
		Object rv = ObjectAccess.referenceGet(this._ref);
		if (rv == null)
			this.enqueue();
		
		return (T)rv;
	}
	
	/**
	 * Returns if this reference was enqueued into the reference queue.
	 *
	 * @return If this object was enqueued.
	 * @since 2018/09/23
	 */
	public boolean isEnqueued()
	{
		return this._enqueued;
	}
}

Deleted runt/apis/cldc-compact/java/lang/ref/ReferenceQueue.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.ref;

import java.util.Deque;
import java.util.LinkedList;

/**
 * This is a queue of references, when a reference is freed or detected to be
 * freed then the object references will be placed here.
 *
 * @param <T> The type of reference to store.
 * @since 2018/09/23
 */
public class ReferenceQueue<T>
{
	/** Internal queue of references. */
	private final Deque<Reference<? extends T>> _queue =
		new LinkedList<>();
	
	/**
	 * Initializes the queue.
	 *
	 * @since 2018/09/23
	 */
	public ReferenceQueue()
	{
	}
	
	/**
	 * Checks the queue and returns a reference immedietely if one is
	 * available.
	 *
	 * @return The next removed reference or {@code null} if there is none.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> poll()
	{
		// Lock and remove
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			return queue.poll();
		}
	}
	
	/**
	 * Removes the next reference from the queue for the given duration.
	 *
	 * @param __ms The number of milliseconds to wait, zero means to wait
	 * forever.
	 * @return The reference or {@code null} if the timeout was reached.
	 * @throws IllegalArgumentException If the timeout is negative.
	 * @throws InterruptedException If the thread was interrupted while
	 * waiting.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> remove(long __ms)
		throws IllegalArgumentException, InterruptedException
	{
		// {@squirreljme.error ZZ2a A negative timeout was specified.}
		if (__ms < 0)
			throw new IllegalArgumentException("ZZ2a");
		
		// A timeout of zero means to wait forever
		if (__ms == 0)
			return this.remove();
		
		// Determine the time to just stop waiting
		long endtime = System.nanoTime() + (__ms * 1_000_000L);
		
		// Lock on the queue
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			for (;;)
			{
				// Is there an item in the queue?
				Reference<? extends T> rv = queue.poll();
				if (rv != null)
					return rv;
				
				// No time left
				long difftime = (endtime - System.nanoTime()) / 1_000_000L;
				if (difftime <= 0)
					return null;
				
				// Wait for the time difference, InterruptedException drops
				// out if it occurs
				queue.wait(difftime);
			}
		}
	}
	
	/**
	 * Removes the next reference from the queue, waiting forever until there
	 * is one.
	 *
	 * @return The next reference in the queue.
	 * @throws InterruptedException If the thread was interrupted.
	 * @since 2018/09/23
	 */
	public Reference<? extends T> remove()
		throws InterruptedException
	{
		// Lock on the queue
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			for (;;)
			{
				// Is there an item in the queue?
				Reference<? extends T> rv = queue.poll();
				if (rv != null)
					return rv;
				
				// Otherwise wait for a signal, InterruptedException is tossed
				// on the outside
				queue.wait();
			}
		}
	}
	
	/**
	 * Enqueues the reference into this queue.
	 *
	 * @param __ref The reference to enqueue.
	 * @since 2018/09/23
	 */
	final void __enqueue(Reference<? extends T> __ref)
	{
		// Just ignore and do nothing
		if (__ref == null)
			return;
		
		// Lock on the queue to add it
		Deque<Reference<? extends T>> queue = this._queue;
		synchronized (queue)
		{
			queue.add(__ref);
			
			// Signal all waiting threads, one will grab it
			queue.notifyAll();
		}
	}
}

Deleted runt/apis/cldc-compact/java/lang/ref/WeakReference.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.ref;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;

/**
 * A weak reference is one which is garbage collected when there are no strong
 * references to it.
 *
 * @param <T> The type of object to store.
 * @since 2018/09/23
 */
public class WeakReference<T>
	extends Reference<T>
{
	/**
	 * Initializes a reference pointing to the given object.
	 *
	 * @param __v The object to point to, may be {@code null}.
	 * @since 2018/09/23
	 */
	public WeakReference(T __v)
	{
		super(ObjectAccess.newWeakReference(), __v, null);
	}
	
	/**
	 * Initializes a reference pointing to the given object and an optionally
	 * specified queue to place this reference into when garbage collection
	 * occurs.
	 *
	 * @param __v The object to point to, may be {@code null}.
	 * @param __q When the given object is garbage collected the specified
	 * queue will be given this reference (not {@link __v} itself}, may be
	 * {@code null}
	 * @since 2018/09/23
	 */
	public WeakReference(T __v, ReferenceQueue<? super T> __q)
	{
		super(ObjectAccess.newWeakReference(), __v, __q);
	}
}

Deleted runt/apis/cldc-compact/java/lang/ref/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes of reference and their utilities which are
 * utilized with garbage collection.
 *
 * @since 2018/09/23
 */

package java.lang.ref;

Deleted runt/apis/cldc-compact/java/net/BindException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

/**
 * This is thrown when an attempt to bind to a local address and/or port has
 * failed.
 *
 * @since 2018/12/08
 */
public class BindException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public BindException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public BindException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/net/ConnectException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

/**
 * This is thrown when a connection could not be made to a remote host.
 *
 * @since 2018/12/08
 */
public class ConnectException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public ConnectException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public ConnectException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/net/NoRouteToHostException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

/**
 * This is thrown when there is no route to the remote destination.
 *
 * @since 2018/12/08
 */
public class NoRouteToHostException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public NoRouteToHostException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public NoRouteToHostException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/net/PortUnreachableException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

/**
 * This is thrown when the remote system has a port which cannot be reached.
 *
 * @since 2018/12/08
 */
public class PortUnreachableException
	extends SocketException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public PortUnreachableException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public PortUnreachableException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/net/SocketException.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

import java.io.IOException;

/**
 * This is thrown for general socket exceptions.
 *
 * @since 2018/12/08
 */
public class SocketException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public SocketException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public SocketException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/net/UnknownHostException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.net;

import java.io.IOException;

/**
 * This is thrown when a host is looked up, however it is not valid.
 *
 * @since 2018/12/08
 */
public class UnknownHostException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public UnknownHostException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public UnknownHostException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/security/AccessControlException.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

/**
 * This is thrown when access to a system critical resource such as a file
 * or network stream is denied.
 *
 * @since 2018/09/18
 */
public class AccessControlException
	extends SecurityException
{
	/** The permission which was set, is optional. */
	private final Permission _permission;
	
	/**
	 * Initializes the exception with the given message with no permission or
	 * cause.
	 *
	 * @param __s The message.
	 * @param __p The permission.
	 * @since 2018/09/18
	 */
	public AccessControlException(String __s)
	{
		super(__s);
		
		this._permission = null;
	}
	
	/**
	 * Initializes the exception with the given message and permission, no
	 * cause is used.
	 *
	 * @param __s The message.
	 * @param __p The permission.
	 * @since 2018/09/18
	 */
	public AccessControlException(String __s, Permission __p)
	{
		super(__s);
		
		this._permission = __p;
	}
	
	/**
	 * Returns the permission that was specified, if one was.
	 *
	 * @return The specified permission or {@code null} if there was none.
	 * @since 2018/09/18
	 */
	public Permission getPermission()
	{
		return this._permission;
	}
}

Deleted runt/apis/cldc-compact/java/security/AccessController.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

/**
 * This is used for access control on resources that may be available at
 * run-time.
 *
 * @since 2018/09/18
 */
public final class AccessController
{
	/**
	 * Checks the specified permission.
	 *
	 * @param __p The permission to check.
	 * @throws AccessControlException If access is denied or the permission
	 * is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public static void checkPermission(Permission __p)
		throws AccessControlException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		todo.TODO.note("Check permission: %s", __p);
	}
}

Deleted runt/apis/cldc-compact/java/security/BasicPermission.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

public abstract class BasicPermission
	extends Permission
{
	/**
	 * Initializes the basic permission.
	 *
	 * @param __name The name of the permission.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/18
	 */
	public BasicPermission(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		super(__name);
		
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2b The name for basic permissions cannot
		// be empty.}
		if (__name.equals(""))
			throw new IllegalArgumentException("ZZ0z");
	}
	
	/**
	 * Initializes the basic permission.
	 *
	 * @param __name The name of the permission.
	 * @param __act The action to use, this is ignored for basic permissions.
	 * @throws IllegalArgumentException If name is empty.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/18
	 */
	public BasicPermission(String __name, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		this(__name);
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/security/Permission.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is the base class for all permissions.
 *
 * Permissions have a name and may have multiple actions.
 *
 * Actions are comma separated and they must be returned in a fixed order.
 *
 * @since 2018/12/08
 */
public abstract class Permission
{
	/** The permission name. */
	private final String _name;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the base permission.
	 *
	 * @param __name The name of the permission.
	 * @since 2018/09/18
	 */
	public Permission(String __name)
	{
		this._name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public abstract boolean equals(Object __a);
	
	/**
	 * Returns the actions which are performed on this permission.
	 *
	 * @return The actions performed on this permission.
	 * @since 2018/12/08
	 */
	public abstract String getActions();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * Checks if this permission implies the given permission.
	 *
	 * @param __p The other permission to check.
	 * @return If this permission implies the specified one.
	 * @since 2018/12/08
	 */
	public abstract boolean implies(Permission __p);
	
	/**
	 * Returns the name of this permission.
	 *
	 * @return The permission name.
	 * @since 2018/12/08
	 */
	public final String getName()
	{
		return this._name;
	}
	
	/**
	 * Returns an empty permission collection for this given permission or
	 * {@code null} if one is not defined. This collection may be used by
	 * permission implementation to check if there are any implied
	 * permissions via {@link #implies(Permission)}. If {@code null} is
	 * returned this means the caller may store this within any collection
	 * of permissions.
	 *
	 * The default implementation returns {@code null}.
	 *
	 * @return The permission collection.
	 * @since 2018/12/08
	 */
	public PermissionCollection newPermissionCollection()
	{
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
			"(\"" + this.getClass().getName() + "\" \"" + this._name + "\")"));
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact/java/security/PermissionCollection.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.security;

import java.util.Enumeration;

public abstract class PermissionCollection
{
	public PermissionCollection()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract void add(Permission __a);
	
	public abstract Enumeration<Permission> elements();
	
	public abstract boolean implies(Permission __a);
	
	public boolean isReadOnly()
	{
		throw new todo.TODO();
	}
	
	public void setReadOnly()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/AbstractCollection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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




















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a basic implementation of a {@link Collection}.
 *
 * Sub-classes are only required to implement {@link #iterator()} and
 * {@link #size()}.
 *
 * To support adding elements {@link add(Object)} must be implemented.
 *
 * To support removing elements {@link Iterator#remove()} must be implemented.
 *
 * @param <E> The element type.
 * @since 2018/09/15
 */
public abstract class AbstractCollection<E>
	implements Collection<E>
{
	/**
	 * Constructor which requires a sub-class to exist.
	 *
	 * @since 2018/09/15
	 */
	protected AbstractCollection()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public abstract Iterator<E> iterator();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public abstract int size();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean add(E __a)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public boolean addAll(Collection<? extends E> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Add but we also need to keep track if the underlying collection
		// was actually changed
		boolean changed = false;
		for (E e : __c)
			changed |= this.add(e);
		
		return changed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			// Remove is always after a next
			it.next();
			it.remove();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean contains(Object __v)
	{
		// Slow as it checks each entry
		for (E e : this)
			if (__v == null ? e == null : __v.equals(e))
				return true;
		
		// Not found
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean containsAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Check each entry
		int total = 0,
			found = 0;
		for (Object e : __c)
		{
			total++;
			if (this.contains(e))
				found++;
			
			// Entry is missing so this will later return false
			else
				return false;
		}
		
		return found == total;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean remove(Object __v)
	{
		// Find it and remove it
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			if (__v == null ? e == null : __v.equals(e))
			{
				it.remove();
				return true;
			}
		}
		
		// No changes
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean removeAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Remove things through our own iterator
		boolean did = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			
			// If it is in the collection, remove it
			if (__c.contains(e))
			{
				it.remove();
				did = true;
			}
		}
		
		return did;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public boolean retainAll(Collection<?> __c)
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Remove things through our own iterator
		boolean did = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			E e = it.next();
			
			// If it is not in the collection, remove it
			if (!__c.contains(e))
			{
				it.remove();
				did = true;
			}
		}
		
		return did;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public Object[] toArray()
	{
		int n = this.size();
		Object[] rv = new Object[n];
		int i = 0;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
			rv[i++] = it.next();
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public <T> T[] toArray(T[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Use to check or create a new array of the given type
		int size = this.size();
		
		// Only copy elements if there are any to copy, prevents creation
		// of the iterator
		if (size > 0)
		{
			// If the array is too small, reallocate it to fit
			if (__v.length < size)
				__v = Arrays.<T>copyOf(__v, size);
			
			// Copy elements based on the iteration order, just ignore the
			// class and hope it works
			int o = 0;
			for (E e : this)
				__v[o++] = (T)e;
		}
		
		// The element at the end of the array, if there is room is set to
		// null
		if (__v.length > size)
			__v[size] = null;
		
		return __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder("[");
		
		// Build string
		boolean comma = false;
		for (Iterator<E> it = this.iterator(); it.hasNext();)
		{
			// Add comma
			if (comma)
				sb.append(", ");
			comma = true;
			
			// Add item
			sb.append(it.next());
		}
		
		sb.append("]");
		return sb.toString();
	}
}

Deleted runt/apis/cldc-compact/java/util/AbstractList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.annotation.ProgrammerTip;

/**
 * This is the base class for all list types.
 *
 * @since 2018/12/07
 */
public abstract class AbstractList<E>
	extends AbstractCollection<E>
	implements List<E>
{
	/**
	 * The modification count of this list, used to detect situations
	 * where a list was modified while it was being iterated.
	 */
	protected transient int modCount;
	
	/**
	 * Constructor requiring sub-classing.
	 *
	 * @since 2018/09/15
	 */
	protected AbstractList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public abstract E get(int __i)
		throws IndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public boolean add(E __v)
	{
		int oldsize = this.size();
		this.add(oldsize, __v);
		return this.size() != oldsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for variable sized lists.")
	public void add(int __a, E __b)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		int n = this.size();
		if (__i < 0 || __i > n)
			throw new IndexOutOfBoundsException("NARG");
		
		// Add all elements
		for (E e : __c)
			this.add(__i++, e);
		
		// If the size changed the list was modified
		return this.size() != n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void clear()
	{
		this.removeRange(0, this.size());
	}
	
	/**
	 * This method follows the contract of the {@link List#equals(Object)}
	 * method.
	 *
	 * @param __o The object to compare against.
	 * @return If the specified object is a list and is equal to this list.
	 * @see List#equals(Object)
	 * @since 2017/11/21
	 */
	@Override
	@ImplementationNote("This method considers if the source and target " +
		"lists are RandomAccess, for more optimized comparison.")
	public boolean equals(Object __o)
	{
		// Same object, no point in comparing against self
		if (this == __o)
			return true;
		
		// The other object must be a list
		if (!(__o instanceof List))
			return false;
		
		// If either (or both) lists are not random access then it is possible
		// that there is a penalty in determining the size of the list, so
		// single entries must be considered via the iterators.
		List<?> o = (List<?>)__o;
		if (!(this instanceof RandomAccess) || !(o instanceof RandomAccess))
		{
			// Need both iterators
			Iterator<?> ai = this.iterator(),
				bi = o.iterator();
			
			// The lists may have infinite length
			while (true)
			{
				// If one list ends before the other then they are not equal
				boolean anext;
				if ((anext = ai.hasNext()) != bi.hasNext())
					return false;
				
				// Both are empty at the same time, same length
				if (!anext)
					return true;
				
				// Need these
				Object a = ai.next(),
					b = bi.next();
				
				// Nulls compare the same, but fail on mismatches
				if (a == null)
					if (b == null)
						continue;
					else
						return false;
				
				// This call should check b for null
				else if (!a.equals(b))
					return false;
			}
		}
		
		// Otherwise, a size comparison is likely not to be costly.
		else
		{
			// Equal lists always have the same size
			int an = this.size(),
				bn = o.size();
			if (an != bn)
				return false;
			
			for (int i = 0; i < an; i++)
			{
				Object a = this.get(i),
					b = o.get(i);
				
				// Nulls compare the same, but fail on mismatches
				if (a == null)
					if (b == null)
						continue;
					else
						return false;
				
				// This call should check b for null
				else if (!a.equals(b))
					return false;
			}
			
			// If this point reached, the lists are equal
			return true;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		int rv = 1;
		for (E e : this)
			rv = 31 * rv + (e == null ? 0 : e.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int indexOf(Object __v)
	{
		for (int i = 0, n = this.size(); i < n; i++)
		{
			E e = this.get(i);
			if ((__v == null ? e == null : __v.equals(e)))
				return i;
		}
		
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Iterator<E> iterator()
	{
		return new __AbstractListListIterator__<E>(this, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int lastIndexOf(Object __v)
	{
		for (int i = this.size() - 1; i >= 0; i--)
		{
			E e = this.get(i);
			if ((__v == null ? e == null : __v.equals(e)))
				return i;
		}
		
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public ListIterator<E> listIterator()
	{
		return this.listIterator(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public ListIterator<E> listIterator(int __i)
	{
		return new __AbstractListListIterator__<E>(this, __i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for variable sized lists.")
	public E remove(int __i)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Removes elements from the given inclusive range to the given exclusive
	 * range.
	 *
	 * The basic implementation of this method uses the list iterator until
	 * the from index is reached, once it has been reached it will remove
	 * the given number of elements. Therefor
	 *
	 * @param __from The first element to remove, inclusive.
	 * @param __to The last element to remove, exclusive.
	 * @since 2018/10/29
	 */
	@ProgrammerTip("The basic implementation of this method is not " +
		"efficient at all, it should be reimplemented if removal is a " +
		"busy operation.")
	protected void removeRange(int __from, int __to)
	{
		int left = __to - __from;
		ListIterator<E> li = this.listIterator(__from);
		while (left > 0)
		{
			if (!li.hasNext())
				break;
			
			// Get and remove
			li.next();
			li.remove();
			left--;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	@ProgrammerTip("Implement for modifiable lists.")
	public E set(int __i, E __v)
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/30
	 */
	@Override
	public List<E> subList(int __from, int __to)
		throws IllegalArgumentException, IndexOutOfBoundsException
	{
		return new __AbstractListSubList__<E>(this, __from, __to);
	}
}

Deleted runt/apis/cldc-compact/java/util/AbstractMap.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
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
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public abstract class AbstractMap<K, V>
	implements Map<K, V>
{
	protected AbstractMap()
	{
	}
	
	public abstract Set<Map.Entry<K, V>> entrySet();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		this.entrySet().clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	protected Object clone()
		throws CloneNotSupportedException
	{
		return (AbstractMap<?, ?>)super.clone();
	}
	
	public boolean containsKey(Object __a)
	{
		throw new todo.TODO();
	}
	
	public boolean containsValue(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public V get(Object __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (Map.Entry<K, V> e : this.entrySet())
			rv += e.hashCode();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public Set<K> keySet()
	{
		return new __AbstractMapKeySet__<K, V>(this);
	}
	
	public V put(K __a, V __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public void putAll(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Copy everything
		for (Map.Entry<? extends K, ? extends V> e : __m.entrySet())
			this.put(e.getKey(), e.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public V remove(Object __k)
	{
		// Linearly search through the hash map to remove the key
		for (Iterator<Map.Entry<K, V>> it = this.entrySet().iterator();
			it.hasNext();)
		{
			Map.Entry<K, V> e = it.next();
			
			// If the key matches, then it is removed
			if (Objects.equals(e.getKey(), __k))
			{
				V rv = e.getValue();
				it.remove();
				return rv;
			}
		}
		
		// If this point was reached, there is no matching key
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int size()
	{
		return this.entrySet().size();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder("{");
		
		// Go through and append
		boolean comma = false;
		for (Map.Entry<?, ?> e : this.entrySet())
		{
			// Space comma
			if (comma)
				sb.append(", ");
			comma = true;
			
			// Key is equal to the value
			sb.append(e.getKey());
			sb.append('=');
			sb.append(e.getValue());
		}
		
		sb.append('}');
		return sb.toString();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public Collection<V> values()
	{
		return new __AbstractMapValues__<K, V>(this);
	}
}


Deleted runt/apis/cldc-compact/java/util/AbstractSequentialList.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is the base list for classes which are optimized for sequential and
 * not randomized access.
 *
 * @param <E> The element to store in the list.
 * @since 2018/10/29
 */
public abstract class AbstractSequentialList<E>
	extends AbstractList<E>
{
	/**
	 * Initializes the base sequential list.
	 *
	 * @since 2018/10/29
	 */
	protected AbstractSequentialList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public abstract ListIterator<E> listIterator(int __i);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void add(int __i, E __v)
	{
		// Just adds the entry at the given position
		this.listIterator(__i).add(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		boolean mod = false;
		ListIterator<E> li = this.listIterator(__i);
		for (E e : __c)
		{
			li.add(e);
			li.next();
			
			// Modified
			mod = true;
		}
		
		return mod;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E get(int __i)
	{
		return this.listIterator(__i).next();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public Iterator<E> iterator()
	{
		return this.listIterator(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E remove(int __i)
	{
		ListIterator<E> li = this.listIterator(__i);
		E rv = li.next();
		li.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public E set(int __i, E __v)
	{
		ListIterator<E> li = this.listIterator(__i);
		E rv = li.next();
		li.set(__v);
		return rv;
	}
}

Deleted runt/apis/cldc-compact/java/util/AbstractSet.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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is an abstract set which provides only a few more methods than the
 * base collection class.
 *
 * @param <E> The storage type.
 * @since 2018/12/07
 */
public abstract class AbstractSet<E>
	extends AbstractCollection<E>
	implements Set<E>
{
	/**
	 * Requires that the class be extended.
	 *
	 * @since 2018/10/10
	 */
	protected AbstractSet()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Set))
			return false;
		
		// Compare size first
		Set<?> o = (Set<?>)__o;
		if (this.size() != o.size())
			return false;
		
		// Just check if this set contains everything in the other set
		return this.containsAll(o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (E e : this)
			rv += (e == null ? 0 : e.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public boolean removeAll(Collection<?> __c)
		throws NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Iterate over our set and remove
		boolean did = false;
		if (this.size() <= __c.size())
		{
			for (Iterator<E> it = this.iterator(); it.hasNext();)
			{
				E e = it.next();
				
				if (__c.contains(e))
				{
					it.remove();
					did = true;
				}
			}
		}
		
		// Iterate over the other set and remove from ours
		else
		{
			for (Iterator<?> it = __c.iterator(); it.hasNext();)
			{
				Object e = it.next();
				
				if (this.contains(e))
				{
					this.remove(e);
					did = true;
				}
			}
		}
		
		return did;
	}
}

Deleted runt/apis/cldc-compact/java/util/ArrayDeque.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
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
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public class ArrayDeque<E>
	extends AbstractCollection<E>
	implements Deque<E>, Cloneable
{
	public ArrayDeque()
	{
		super();
		throw new todo.TODO();
	}
	
	public ArrayDeque(int __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public ArrayDeque(Collection<? extends E> __a)
	{
		super();
		throw new todo.TODO();
	}
	
	@Override
	public boolean add(E __a)
	{
		throw new todo.TODO();
	}
	
	public void addFirst(E __a)
	{
		throw new todo.TODO();
	}
	
	public void addLast(E __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}
	
	@Override
	public ArrayDeque<E> clone()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean contains(Object __a)
	{
		throw new todo.TODO();
	}
	
	public Iterator<E> descendingIterator()
	{
		throw new todo.TODO();
	}
	
	public E element()
	{
		throw new todo.TODO();
	}
	
	public E getFirst()
	{
		throw new todo.TODO();
	}
	
	public E getLast()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Iterator<E> iterator()
	{
		throw new todo.TODO();
	}
	
	public boolean offer(E __a)
	{
		throw new todo.TODO();
	}
	
	public boolean offerFirst(E __a)
	{
		throw new todo.TODO();
	}
	
	public boolean offerLast(E __a)
	{
		throw new todo.TODO();
	}
	
	public E peek()
	{
		throw new todo.TODO();
	}
	
	public E peekFirst()
	{
		throw new todo.TODO();
	}
	
	public E peekLast()
	{
		throw new todo.TODO();
	}
	
	public E poll()
	{
		throw new todo.TODO();
	}
	
	public E pollFirst()
	{
		throw new todo.TODO();
	}
	
	public E pollLast()
	{
		throw new todo.TODO();
	}
	
	public E pop()
	{
		throw new todo.TODO();
	}
	
	public void push(E __a)
	{
		throw new todo.TODO();
	}
	
	public E remove()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean remove(Object __a)
	{
		throw new todo.TODO();
	}
	
	public E removeFirst()
	{
		throw new todo.TODO();
	}
	
	public boolean removeFirstOccurrence(Object __a)
	{
		throw new todo.TODO();
	}
	
	public E removeLast()
	{
		throw new todo.TODO();
	}
	
	public boolean removeLastOccurrence(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public int size()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/ArrayList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285





























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a resizeable list which is backed by an array.
 *
 * This class is not thread safe, for a thread safe version see {@link Vector}.
 *
 * If a modification is detected in the iterator then
 * {@link #ConcurrentModificationException} is thrown as soon as possible.
 *
 * @param <E> The element type.
 * @see Vector
 * @since 2018/09/15
 */
public class ArrayList<E>
	extends AbstractList<E>
	implements List<E>, RandomAccess, Cloneable
{
	/** Capacity growth size. */
	private static final int _GROWTH =
		8;
	
	/** Elements in the list. */
	private E[] _elements;
	
	/** The number of elements in the list. */
	private int _size;
	
	/**
	 * Initializes a list which has an initial capacity of 10.
	 *
	 * @since 2018/09/15
	 */
	public ArrayList()
	{
		this(10);
	}
	
	/**
	 * Initializes a list which has the specified capacity.
	 *
	 * @param __cap The initial capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/09/15
	 */
	@SuppressWarnings({"unchecked"})
	public ArrayList(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ2e Attempt to initialize array list with
		// a negative capacity. (The capicity)}
		if (__cap < 0)
			throw new IllegalArgumentException(
				String.format("ZZ2e %d", __cap));
		
		this._elements = (E[])new Object[__cap];
	}
	
	/**
	 * Initializes a list which has all the elements of the given collection
	 * in its iteration order.
	 *
	 * @param __o The other collection.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	@SuppressWarnings({"unchecked"})
	public ArrayList(Collection<? extends E> __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Initial capacity is the size of the other collection
		this._elements = (E[])new Object[__o.size()];
		
		// And then add everything
		this.addAll(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public void add(int __i, E __v)
		throws IndexOutOfBoundsException
	{
		int size = this._size;
		if (__i < 0 || __i > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		E[] elements = this._elements;
		int cap = elements.length,
			nextsize = size + 1;
		
		// Cannot fit in this array
		E[] source = elements;
		if (nextsize > cap)
		{
			// Grow the list by a bit
			int newcap = nextsize + _GROWTH;
			elements = (E[])new Object[newcap];
			
			// Copy old stuff over, but only up to the index as needed
			for (int i = 0; i < __i; i++)
				elements[i] = source[i];
		}
		
		// Move down to fit
		for (int i = size - 1, o = size; o > __i; i--, o--)
			elements[o] = source[i];
		
		// Store data here
		elements[__i] = __v;
		
		// Store new information
		this._size = nextsize;
		if (elements != source)
			this._elements = elements;
		
		// Structurally modified
		this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public void clear()
	{
		// Clear the entire array so things get collected
		E[] elements = this._elements;
		int size = this._size;
		for (int i = 0; i < size; i++)
			elements[i] = null;
		
		// Keep the backing array, just clear the size
		this._size = 0;
		
		// Structurally modified
		this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/07
	 */
	@Override
	public Object clone()
	{
		return new ArrayList<>(this);
	}
	
	/**
	 * Ensures that the given number of elements can fit in the list.
	 *
	 * @param __n The number of elements.
	 * @since 2019/05/14
	 */
	@SuppressWarnings({"unchecked"})
	public void ensureCapacity(int __n)
	{
		// Pointless
		if (__n <= 0)
			return;
		
		// Meets or exceeds the desired capacity?
		E[] elements = this._elements;
		int nowl = elements.length;
		if (__n <= nowl)
			return;
		
		// Copy values over
		E[] extra = (E[])new Object[__n];
		for (int i = 0; i < nowl; i++)
			extra[i] = elements[i];
		
		// Set
		this._elements = extra;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public E get(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this._elements[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/12
	 */
	@Override
	public E remove(int __i)
		throws IndexOutOfBoundsException
	{
		// Out of bounds?
		int size = this._size;
		if (__i < 0 || __i >= size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get the old element first
		E[] elements = this._elements;
		E rv = elements[__i];
		
		// Copy all of the elements down
		for (int o = __i, i = __i + 1; i < size; o++, i++)
			elements[o] = elements[i];
		elements[size - 1] = null;
		
		// Set new size
		this._size = size - 1;
		
		// Structurally modified
		this.modCount++;
		
		// And the old element
		return rv;
	}
	
	@Override
	protected void removeRange(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/10
	 */
	@Override
	public E set(int __i, E __v)
	{
		// Out of bounds?
		int size = this._size;
		if (__i < 0 || __i >= size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Read old value
		E[] elements = this._elements;
		E rv = elements[__i];
		
		// Set new value
		elements[__i] = __v;
		
		// Return old
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	public void trimToSize()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Arrays.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.asm.ObjectAccess;
import cc.squirreljme.runtime.cldc.util.ByteIntegerArray;
import cc.squirreljme.runtime.cldc.util.CharacterIntegerArray;
import cc.squirreljme.runtime.cldc.util.DoubleArrayList;
import cc.squirreljme.runtime.cldc.util.FloatArrayList;
import cc.squirreljme.runtime.cldc.util.IntegerArray;
import cc.squirreljme.runtime.cldc.util.IntegerArrays;
import cc.squirreljme.runtime.cldc.util.IntegerIntegerArray;
import cc.squirreljme.runtime.cldc.util.LongArrayList;
import cc.squirreljme.runtime.cldc.util.ShellSort;
import cc.squirreljme.runtime.cldc.util.ShortIntegerArray;

/**
 * This class contains utility methods which operate on arrays.
 *
 * {@squirreljme.error ZZ2f The sort range exceeds the array bounds.}
 * {@squirreljme.error ZZ2g The from index exceeds the to index.}
 *
 * @since 2016/09/30
 */
public class Arrays
{
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private Arrays()
	{
	}
	
	/**
	 * Wraps the specified array allowing access to its data as a fixed size
	 * list. The returned {@link List} will have {@link RandomAccess}
	 * implemented.
	 *
	 * @param <T> The type of values contained within the array.
	 * @param __a The array to wrap.
	 * @return The specified array wrapped in a {@link List}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/31
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> List<T> asList(T... __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		return new __ArraysList__<T>(__a);
	}
	
	public static int binarySearch(long[] __a, long __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(long[] __a, int __b, int __c, long __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(int[] __a, int __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(int[] __a, int __from, int __to, int __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new IntegerIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(short[] __a, short __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(short[] __a, int __from, int __to,
		short __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new ShortIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(char[] __a, char __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/28
	 */
	public static int binarySearch(char[] __a, int __from, int __to,
		char __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new CharacterIntegerArray(__a),
			__from, __to, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(byte[] __a, byte __key)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return Arrays.binarySearch(__a, 0, __a.length, __key);
	}
	
	/**
	 * Searches the given sorted array for the given element.
	 *
	 * @param __a The sorted array to search.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __key The key to locate.
	 * @return The index of the given key or {@code (-(insertion point) - 1)}
	 * indicating where the element would be found.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index exceed
	 * the bounds of the array.
	 * @throws IllegalArgumentException If the from index is higher than the
	 * to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static int binarySearch(byte[] __a, int __from, int __to,
		byte __key)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		return IntegerArrays.binarySearch(new ByteIntegerArray(__a),
			__from, __to, __key);
	}
	
	public static int binarySearch(double[] __a, double __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(double[] __a, int __b, int __c, double __d)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(float[] __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(float[] __a, int __b, int __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(Object[] __a, Object __b)
	{
		throw new todo.TODO();
	}
	
	public static int binarySearch(Object[] __a, int __b, int __c, Object __d)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(T[] __a, T __b, Comparator<? super T>
		__c)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(T[] __a, int __b, int __c, T __d,
		Comparator<? super T> __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a copy of the given array but using the specified type.
	 *
	 * @param <T> The resulting type of the array to use.
	 * @param __src The source array.
	 * @param __newlen The new length of the array.
	 * @return The copy of the array with the new length and type.
	 * @throws ArrayStoreException If an element being copied from the source
	 * array is not compatible with the destination array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> T[] copyOf(T[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		return Arrays.<T, T>copyOf(__src, __newlen,
			(Class<T[]>)__src.getClass());
	}
	
	/**
	 * Returns a copy of the given array but using the specified type.
	 *
	 * @param <T> The resulting type of the array to use.
	 * @param <U> The input array type.
	 * @param __src The source array.
	 * @param __newlen The new length of the array.
	 * @param __targettype The type type.
	 * @return The copy of the array with the new length and type.
	 * @throws ArrayStoreException If an element being copied from the source
	 * array is not compatible with the destination array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	@SuppressWarnings({"unchecked"})
	public static <T, U> T[] copyOf(U[] __src, int __newlen,
		Class<? extends T[]> __targettype)
		throws ArrayStoreException, NegativeArraySizeException,
			NullPointerException
	{
		if (__src == null || __targettype == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		// Allocate array in the target type
		Object[] rv = (Object[])ObjectAccess.arrayNew(__targettype, __newlen);
		
		// Copy source to destination
		for (int i = 0, n = Math.min(__src.length, __newlen); i < n; i++)
			rv[i] = __src[i];
		
		return (T[])rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static byte[] copyOf(byte[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		byte[] rv = new byte[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static short[] copyOf(short[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		short[] rv = new short[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static int[] copyOf(int[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		int[] rv = new int[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static long[] copyOf(long[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		long[] rv = new long[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static char[] copyOf(char[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		char[] rv = new char[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static float[] copyOf(float[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		float[] rv = new float[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static double[] copyOf(double[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		double[] rv = new double[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Returns a new copy of the given array of the given length.
	 *
	 * @param __src The array to copy.
	 * @param __newlen The new length of the array.
	 * @throws NegativeArraySizeException If the new length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static boolean[] copyOf(boolean[] __src, int __newlen)
		throws NegativeArraySizeException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		if (__newlen < 0)
			throw new NegativeArraySizeException("NASE");
		
		boolean[] rv = new boolean[__newlen];
		for (int i = 0, n = Math.min(__newlen, __src.length); i < n; i++)
			rv[i] = __src[i];
		
		return rv;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(long[] __a, long[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(int[] __a, int[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(short[] __a, short[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(char[] __a, char[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(byte[] __a, byte[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(boolean[] __a, boolean[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(double[] __a, double[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(float[] __a, float[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (__a[i] != __b[i])
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Checks if both arrays are equal to each other.
	 *
	 * @param __a The first array.
	 * @param __b The second array.
	 * @return If the two arrays are equal.
	 * @since 2019/01/24
	 */
	public static boolean equals(Object[] __a, Object[] __b)
	{
		// Same reference or both null is equal
		if (__a == __b)
			return true;
		
		// Either one is null
		if (__a == null || __b == null)
			return false;
		
		// Differing lengths?
		int na = __a.length,
			nb = __b.length;
		if (na != nb)
			return false;
		
		for (int i = 0; i < na; i++)
			if (!Objects.equals(__a[i], __b[i]))
				return false;
		
		// No mismatches
		return true;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(long[] __a, long __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(int[] __a, int __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(short[] __a, short __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(char[] __a, char __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(byte[] __a, byte __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(boolean[] __a, boolean __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(double[] __a, double __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(float[] __a, float __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Fills the array with the given value.
	 *
	 * @param __a The array to fill.
	 * @param __v The value to store.
	 * @throws NullPointerException If the array is null.
	 * @since 2020/01/01
	 */
	public static void fill(Object[] __a, Object __v)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			__a[i] = __v;
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(int[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(int[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		IntegerArrays.sort(new IntegerIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(long[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		Arrays.sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(long[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Long>sort(new LongArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(short[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(short[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new ShortIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(char[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The source array.
	 * @param __to The destination array.
	 * @throws ArrayIndexOutOfBoundsException If the from and/or to index
	 * exceed the array bounds.
	 * @throws IllegalArgumentException If the from index is greater than to
	 * index.
	 * @throws NullPointerException If no array was specified.
	 * @since 2018/10/28
	 */
	public static void sort(char[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new CharacterIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(byte[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(byte[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Use common sorting code
		IntegerArrays.sort(new ByteIntegerArray(__a), __from, __to);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(float[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(float[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Float>sort(new FloatArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(double[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		sort(__a, 0, __a.length);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2020/01/01
	 */
	public static void sort(double[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		int an = __a.length;
		if (__from < 0 || __to > an)
			throw new ArrayIndexOutOfBoundsException("ZZ04");
		if (__from > __to)
			throw new IllegalArgumentException("ZZ2g");
		
		// Pointless sort?
		if (__from == __to)
			return;
		
		// Non-common sort, use a helper wrapper
		ShellSort.<Double>sort(new DoubleArrayList(__a), __from, __to, null);
	}
	
	/**
	 * Sorts the specified array using the natural {@link Comparator}.
	 *
	 * @param __a The array to sort.
	 * @throws NullPointerException If no array was specified.
	 * @since 2016/09/30
	 */
	public static void sort(Object[] __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");	
		
		Arrays.<Object>sort(__a, 0, __a.length, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static void sort(Object[] __a, int __from, int __to)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		Arrays.<Object>sort(__a, __from, __to, null);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __comp The comparator to use.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static <T> void sort(T[] __a, Comparator<? super T> __comp)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Arrays.<T>sort(__a, 0, __a.length, __comp);
	}
	
	/**
	 * Sorts the specified array.
	 *
	 * @param __a The array to sort.
	 * @param __from The from index.
	 * @param __to The to index.
	 * @param __comp The comparator to use.
	 * @throws ArrayIndexOutOfBoundsException If the from or to index are
	 * outside of bounds.
	 * @throws IllegalArgumentException If the from address is greater than
	 * the to address.
	 * @throws NullPointerException If no array was specified.
	 * @since 2019/05/09
	 */
	public static <T> void sort(T[] __a, int __from, int __to,
		Comparator<? super T> __comp)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// The thrown exception may need to be remapped
		try
		{
			ShellSort.<T>sort(Arrays.<T>asList(__a), __from, __to, __comp);
		}
		
		// {@squirreljme.error ZZ2h Out of bounds access when sorting array.}
		catch (IndexOutOfBoundsException e)
		{
			if (e instanceof ArrayIndexOutOfBoundsException)
				throw e;
			
			RuntimeException t = new ArrayIndexOutOfBoundsException("ZZ2h");
			t.initCause(e);
			throw t;
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/Calendar.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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






















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public abstract class Calendar
	implements Cloneable, Comparable<Calendar>
{
	public static final int AM =
		0;
	
	public static final int AM_PM =
		9;
	
	public static final int APRIL =
		3;
	
	public static final int AUGUST =
		7;
	
	public static final int DATE =
		5;
	
	public static final int DAY_OF_MONTH =
		5;
	
	public static final int DAY_OF_WEEK =
		7;
	
	public static final int DAY_OF_WEEK_IN_MONTH =
		8;
	
	public static final int DAY_OF_YEAR =
		6;
	
	public static final int DECEMBER =
		11;
	
	public static final int DST_OFFSET =
		16;
	
	public static final int ERA =
		0;
	
	public static final int FEBRUARY =
		1;
	
	public static final int FIELD_COUNT =
		17;
	
	public static final int FRIDAY =
		6;
	
	public static final int HOUR =
		10;
	
	public static final int HOUR_OF_DAY =
		11;
	
	public static final int JANUARY =
		0;
	
	public static final int JULY =
		6;
	
	public static final int JUNE =
		5;
	
	public static final int MARCH =
		2;
	
	public static final int MAY =
		4;
	
	public static final int MILLISECOND =
		14;
	
	public static final int MINUTE =
		12;
	
	public static final int MONDAY =
		2;
	
	public static final int MONTH =
		2;
	
	public static final int NOVEMBER =
		10;
	
	public static final int OCTOBER =
		9;
	
	public static final int PM =
		1;
	
	public static final int SATURDAY =
		7;
	
	public static final int SECOND =
		13;
	
	public static final int SEPTEMBER =
		8;
	
	public static final int SUNDAY =
		1;
	
	public static final int THURSDAY =
		5;
	
	public static final int TUESDAY =
		3;
	
	public static final int UNDECIMBER =
		12;
	
	public static final int WEDNESDAY =
		4;
	
	public static final int WEEK_OF_MONTH =
		4;
	
	public static final int WEEK_OF_YEAR =
		3;
	
	public static final int YEAR =
		1;
	
	public static final int ZONE_OFFSET =
		15;
	
	protected boolean areFieldsSet;
	
	protected int[] fields;
	
	protected boolean[] isSet;
	
	protected boolean isTimeSet;
	
	protected long time;
	
	protected Calendar()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract void add(int __a, int __b);
	
	protected abstract void computeFields();
	
	protected abstract void computeTime();
	
	public abstract int getGreatestMinimum(int __a);
	
	public abstract int getLeastMaximum(int __a);
	
	public abstract int getMaximum(int __a);
	
	public abstract int getMinimum(int __a);
	
	public abstract void roll(int __a, boolean __b);
	
	public boolean after(Object __a)
	{
		throw new todo.TODO();
	}
	
	public boolean before(Object __a)
	{
		throw new todo.TODO();
	}
	
	public final void clear()
	{
		throw new todo.TODO();
	}
	
	public final void clear(int __a)
	{
		throw new todo.TODO();
	}
	
	public Object clone()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(Calendar __a)
	{
		throw new todo.TODO();
	}
	
	protected void complete()
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int get(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getActualMaximum(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getActualMinimum(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getFirstDayOfWeek()
	{
		throw new todo.TODO();
	}
	
	public int getMinimalDaysInFirstWeek()
	{
		throw new todo.TODO();
	}
	
	public final Date getTime()
	{
		throw new todo.TODO();
	}
	
	public long getTimeInMillis()
	{
		throw new todo.TODO();
	}
	
	public TimeZone getTimeZone()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	protected final int internalGet(int __a)
	{
		throw new todo.TODO();
	}
	
	public boolean isLenient()
	{
		throw new todo.TODO();
	}
	
	public final boolean isSet(int __a)
	{
		throw new todo.TODO();
	}
	
	public void roll(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public final void set(int __a, int __b, int __c, int __d, int __e, int
		__f)
	{
		throw new todo.TODO();
	}
	
	public void setFirstDayOfWeek(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setLenient(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setMinimalDaysInFirstWeek(int __a)
	{
		throw new todo.TODO();
	}
	
	public final void setTime(Date __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeInMillis(long __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeZone(TimeZone __a)
	{
		throw new todo.TODO();
	}
	
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static Calendar getInstance()
	{
		throw new todo.TODO();
	}
	
	public static Calendar getInstance(TimeZone __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Collection.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Collection<E>
	extends Iterable<E>
{
	public abstract boolean add(E __a);
	
	public abstract boolean addAll(Collection<? extends E> __a);
	
	public abstract void clear();
	
	public abstract boolean contains(Object __a);
	
	public abstract boolean containsAll(Collection<?> __a);
	
	@Override
	public abstract boolean equals(Object __a);
	
	@Override
	public abstract int hashCode();
	
	public abstract boolean isEmpty();
	
	public abstract Iterator<E> iterator();
	
	public abstract boolean remove(Object __a);
	
	public abstract boolean removeAll(Collection<?> __a);
	
	public abstract boolean retainAll(Collection<?> __a);
	
	public abstract int size();
	
	public abstract Object[] toArray();
	
	public abstract <T> T[] toArray(T[] __v)
		throws NullPointerException;
}

Deleted runt/apis/cldc-compact/java/util/Collections.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
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




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.util.ShellSort;

public class Collections
{
	private Collections()
	{
		super();
		throw new todo.TODO();
	}
	
	@SuppressWarnings({"unchecked"})
	public static <T> boolean addAll(Collection<? super T> __a, T... __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(List<? extends Comparable<? super T>>
		__a, T __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> int binarySearch(List<? extends T> __a, T __b,
		Comparator<? super T> __c)
	{
		throw new todo.TODO();
	}
	
	public static <T> void copy(List<? super T> __a, List<? extends T> __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean disjoint(Collection<?> __a, Collection<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> Enumeration<T> enumeration(Collection<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> void fill(List<? super T> __a, T __b)
	{
		throw new todo.TODO();
	}
	
	public static int frequency(Collection<?> __a, Object __b)
	{
		throw new todo.TODO();
	}
	
	public static int indexOfSubList(List<?> __a, List<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static int lastIndexOfSubList(List<?> __a, List<?> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> ArrayList<T> list(Enumeration<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T extends Object & Comparable<? super T>> T max(Collection
		<? extends T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> T max(Collection<? extends T> __a, Comparator<? super T
		> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T extends Object & Comparable<? super T>> T min(Collection
		<? extends T> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> T min(Collection<? extends T> __a, Comparator<? super T
		> __b)
	{
		throw new todo.TODO();
	}
	
	public static <T> boolean replaceAll(List<T> __a, T __b, T __c)
	{
		throw new todo.TODO();
	}
	
	public static void reverse(List<?> __a)
	{
		throw new todo.TODO();
	}
	
	public static <T> Comparator<T> reverseOrder()
	{
		throw new todo.TODO();
	}
	
	public static <T> Comparator<T> reverseOrder(Comparator<T> __a)
	{
		throw new todo.TODO();
	}
	
	public static void rotate(List<?> __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public static void shuffle(List<?> __a)
	{
		throw new todo.TODO();
	}
	
	public static void shuffle(List<?> __a, Random __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sorts the specified list.
	 *
	 * @param <T> The type of values to sort.
	 * @param __a The list to sort.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	public static <T extends Comparable<? super T>> void sort(List<T> __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		ShellSort.<T>sort(__a, 0, __a.size(), null);
	}
	
	/**
	 * Sorts the specified list.
	 *
	 * @param <T> The type of values to sort.
	 * @param __a The list to sort.
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/10
	 */
	public static <T> void sort(List<T> __a, Comparator<? super T> __comp)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		ShellSort.<T>sort(__a, 0, __a.size(), __comp);
	}
	
	public static void swap(List<?> __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Comparator.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Comparator<T>
{
	public abstract int compare(T __a, T __b);
	
	/**
	 * Generally this should return {@code true} if a given comparison results
	 * in a value of {@code 0}.
	 *
	 * {@inheritDoc}
	 * @since 2016/04/12
	 */
	@Override
	public abstract boolean equals(Object __a);
}

Deleted runt/apis/cldc-compact/java/util/ConcurrentModificationException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is thrown when through iteration the structure of the collection
 * was modified between iterations.
 *
 * @since 2018/12/08
 */
public class ConcurrentModificationException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/08
	 */
	public ConcurrentModificationException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/08
	 */
	public ConcurrentModificationException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/util/Date.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
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








































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a simplified time and date.
 *
 * The epoch is the same as {@link System#currentTimeMillis()} and is from
 * January 1, 1970 at 00:00 GMT.
 *
 * @since 2019/12/25
 */
public class Date
	implements Cloneable, Comparable<Date>
{
	/** The current Java time. */
	private transient long _javatime;
	
	/**
	 * Initializes this date at the current system time.
	 *
	 * @since 2019/12/25
	 */
	public Date()
	{
		this(System.currentTimeMillis());
	}
	
	/**
	 * Initializes the date to the given time.
	 *
	 * @param __time The time to set.
	 * @since 2019/12/25
	 */
	public Date(long __time)
	{
		this._javatime = __time;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public Object clone()
	{
		return new Date(((Date)this)._javatime);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public int compareTo(Date __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		long a = this._javatime,
			b = __b._javatime;
		
		return (a < b ? -1 : (a > b ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(this instanceof Date))
			return false;
		
		return this._javatime == ((Date)__o)._javatime;
	}
	
	/**
	 * Returns the number of milliseconds since the epoch.
	 *
	 * @return The number of milliseconds since the epoch.
	 * @since 2019/12/25
	 */
	public long getTime()
	{
		return this._javatime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public int hashCode()
	{
		long javatime = this._javatime;
		return (int)(javatime ^ (javatime >>> 32));
	}
	
	/**
	 * Sets the current time.
	 *
	 * @param __v The time to set.
	 * @since 2019/12/25
	 */
	public void setTime(long __v)
	{
		this._javatime = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	public String toString()
	{
		// "dow mon dd hh:mm:ss zzz yyyy"
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Deque.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Deque<E>
	extends Queue<E>
{
	public abstract boolean add(E __a);
	
	public abstract void addFirst(E __a);
	
	public abstract void addLast(E __a);
	
	public abstract boolean contains(Object __a);
	
	public abstract Iterator<E> descendingIterator();
	
	public abstract E element();
	
	public abstract E getFirst();
	
	public abstract E getLast();
	
	public abstract Iterator<E> iterator();
	
	public abstract boolean offer(E __a);
	
	public abstract boolean offerFirst(E __a);
	
	public abstract boolean offerLast(E __a);
	
	public abstract E peek();
	
	public abstract E peekFirst();
	
	public abstract E peekLast();
	
	public abstract E poll();
	
	public abstract E pollFirst();
	
	public abstract E pollLast();
	
	public abstract E pop();
	
	public abstract void push(E __a);
	
	public abstract E remove();
	
	public abstract boolean remove(Object __a);
	
	public abstract E removeFirst();
	
	public abstract boolean removeFirstOccurrence(Object __a);
	
	public abstract E removeLast();
	
	public abstract boolean removeLastOccurrence(Object __a);
	
	public abstract int size();
}

Deleted runt/apis/cldc-compact/java/util/EmptyStackException.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is thrown when the stack is empty.
 *
 * @since 2018/11/29
 */
public class EmptyStackException
	extends RuntimeException
{
}

Deleted runt/apis/cldc-compact/java/util/Enumeration.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is an old class which duplicates the functionality of {@link Iterator}
 * without having support for removal.
 *
 * Generally, {@link Enumeration}s are not meant to be shared across threads.
 *
 * It is recommended to use {@link Iterator} when writing new code. However
 * this class exists for backwards compatibility with J2ME environments.
 *
 * @param <E> The type of value to iterate over.
 * @see Iterator
 * @since 2016/04/12
 */
public interface Enumeration<E>
{
	/**
	 * Returns {@code true} if there are more elements in the enumeration.
	 *
	 * @return {@code true} if there are more elements available.
	 * @since 2016/04/12
	 */
	public abstract boolean hasMoreElements();
	
	/**
	 * Returns the next element in the enumeration.
	 *
	 * @return The next element.
	 * @throws NoSuchElementException If no more elements remain.
	 * @since 2016/04/12
	 */
	public abstract E nextElement()
		throws NoSuchElementException;
}

Deleted runt/apis/cldc-compact/java/util/EventListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This class must be implemented by anything that listens for events.
 *
 * @since 2016/06/23
 */
public interface EventListener
{
}

Deleted runt/apis/cldc-compact/java/util/EventObject.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * The class which all event objects shall be derived from.
 *
 * @since 2019/01/20
 */
public class EventObject
{
	/** The source of the event. */
	private Object _source;
	
	/**
	 * Initializes the object.
	 *
	 * @param __s The source of the event.
	 * @throws IllegalArgumentException If no source was specified.
	 * @since 2019/01/20
	 */
	@ImplementationNote("Throwing IllegalArgumentException is intended.")
	public EventObject(Object __s)
		throws IllegalArgumentException
	{
		if (__s == null)
			throw new IllegalArgumentException("NARG");
		
		this._source = __s;
	}
	
	/**
	 * Returns the source object.
	 *
	 * @return The source object.
	 * @since 2019/01/20
	 */
	public Object getSource()
	{
		return this._source;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public String toString()
	{
		// Matches what Java SE returns
		return this.getClass().getName() + "[source=" + this._source + "]";
	}
}

Deleted runt/apis/cldc-compact/java/util/Formatter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729

























































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

/**
 * This class implements C-style {@code printf()} formatted for text, it is
 * inspired by the C language but it does not match it exactly and this is
 * far more strict in what it requires.
 *
 * Format specifiers start with the {@code '%'} character which defines a
 * sequence accordingly. The format specifiers are in the following format:
 * {@code %[argument_index$][flags][width][.precision]conversion}. Any fields
 * within brackets are optional. For any specifiers which do not conform to
 * arguments, their format is {@code %[flags][width]conversion}.
 *
 * {@code argument_index$} specifies which argument to take the value from,
 * this allows one to use an alternative order. If this is not specified then
 * the order is implied based on the argument order for any specifiers which
 * do not use an argument index. This means that:
 * {@code format("%7$d %d %6$d %d %% %d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)} will
 * print {@code "7 1 6 2 % 3"}.
 *
 * {@code flags} specifies special flags which are used to modify how the
 * printing is done. The following flags are used:
 *
 *  - {@code '-'} -- Left justified
 *    (general, char, int, float, date).
 *  - {@code '#'} -- Conversion dependent alternate form
 *    (general, int (only: o, x, X), float).
 *  - {@code '+'} -- Include a sign always
 *    (int, float).
 *  - {@code ' '} -- Include leading space for positive values
 *    (int, float).
 *  - {@code '0'} -- Zero padding
 *    (int, float).
 *  - {@code ','} -- Use locale specific grouping separators
 *    (int (only: d), float).
 *  - {@code '('} -- Negative values are enclosed in parenthesis
 *    (int, float).
 *
 * {@code width} is a positive decimal integer which specifies the minimum
 * amount of space the text will take up, it will be aligned accordingly
 * depending on the flags used.
 *
 * {@code precision} is a positive decimal integer which specified a limit
 * on the output, this depends on the format specifier.
 *
 * {@code conversion} is the symbol which determines how the input is to be
 * formatted.
 *
 * @since 2018/09/23
 */
@ImplementationNote("")
public final class Formatter
	implements Closeable
{
	/** The newline sequence. */
	private static final String _NEWLINE;
	
	/** The appendable to write to. */
	private final Appendable _out;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/** The IOException if any was generated. */
	private IOException _ioe;
	
	/**
	 * Cache the line separator which is derived from the system properties.
	 *
	 * @since 2018/10/10
	 */
	static
	{
		String nl;
		try
		{
			nl = System.getProperty("line.separator");
		}
		catch (SecurityException e)
		{
			nl = "\n";
		}
		
		_NEWLINE = nl;
	}
	
	/**
	 * Initializes a formatter which uses an internal {@link StringBuilder}.
	 *
	 * @since 2018/09/23
	 */
	public Formatter()
	{
		this._out = new StringBuilder();
	}
	
	/**
	 * Initializes the formatter writing to the given output.
	 *
	 * @param __a The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	public Formatter(Appendable __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this._out = __a;
	}
	
	/**
	 * Initializes the formatter writing to the given output.
	 *
	 * @param __ps The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	public Formatter(PrintStream __ps)
		throws NullPointerException
	{
		this((Appendable)__ps);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public void close()
	{
		// No effect?
		if (this._closed)
			return;
		
		// Set closed
		this._closed = true;
		
		// Can only be done if it is closeable
		Appendable out = this._out;
		if (out instanceof Closeable)
			try
			{
				((Closeable)out).close();
			}
			catch (IOException e)
			{
				this._ioe = e;
			}
	}
	
	/**
	 * Flushes the output formatter, if it is flushable.
	 *
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	public void flush()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2i The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2i");
		
		// Java ME has no Flushable interface so only certain classes have
		// the flush method
		try
		{
			Appendable out = this._out;
			if (out instanceof OutputStream)
				((OutputStream)out).flush();
			else if (out instanceof Writer)
				((Writer)out).flush();
		}
		
		// {@squirreljme.error ZZ2j Could not flush the formatter.}
		catch (IOException e)
		{
			throw new RuntimeException("ZZ2j", e);
		}
	}
	
	/**
	 * Prints formatted text to the output.
	 *
	 * @param __fmt The format specified.
	 * @param __args The input arguments.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the format specifiers are not
	 * valid.
	 * @throws IllegalStateException If this formatter has been closed.
	 * @throws NullPointerException If no format was specified.
	 * @since 2018/09/23
	 */
	public Formatter format(String __fmt, Object... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__fmt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2k This formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2k");
		
		// Force this to exist
		if (__args == null)
			__args = new Object[0];
		
		// Global state needed for argument handling.
		__PrintFGlobal__ pg = new __PrintFGlobal__(__args);
		
		// Writing to the appendable may cause an exception to occur
		try
		{
			// Process input characters
			Appendable out = this._out;
			for (int i = 0, n = __fmt.length(), next = 0; i < n; i = next)
			{
				char c = __fmt.charAt(i);
				
				// Just a normal character
				if (c != '%')
				{
					out.append(c);
					
					// Just skip the single character
					next = i + 1;;
					continue;
				}
				
				// It is simpler to handle the parsing of the specifier in
				// another method due to loops and variables
				__PrintFState__ pf = new __PrintFState__(pg);
				next = this.__specifier(pf, i, __fmt);
				
				// Handle output of the specifier
				this.__output(out, pf);
			}
		}
		
		// Catch any exception
		catch (IOException e)
		{
			this._ioe = e;
		}
		
		return this;
	}
	
	/**
	 * Returns the last {@link IOException} that was thrown by the output.
	 *
	 * @return The last exception thrown or {@code null} if one was never
	 * thrown.
	 * @since 2018/09/23
	 */
	public IOException ioException()
	{
		return this._ioe;
	}
	
	/**
	 * Returns the output.
	 *
	 * @return The output.
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	public Appendable out()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2l The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2l");
		
		return this._out;
	}
	
	/**
	 * This performs {@code this.out().toString()} and returns that result, as
	 * such the value here might not match what was written into the string.
	 *
	 * @return The string from the output.
	 * @throws IllegalStateException If this formatter was closed.
	 * @since 2018/09/23
	 */
	@Override
	public String toString()
		throws IllegalStateException
	{
		// {@squirreljme.error ZZ2m The formatter has been closed.}
		if (this._closed)
			throw new IllegalStateException("ZZ2m");
		
		return this._out.toString();
	}
	
	/**
	 * Formats integer number in decimal format.
	 *
	 * @param __pf The state used.
	 * @param __n The number used.
	 * @return The formatted integer number.
	 * @throws NullPointerException If no state is specified.
	 * @since 2018/11/03
	 */
	private static String __formatDecimalInt(__PrintFState__ __pf, Number __n)
		throws NullPointerException
	{
		if (__pf == null)
			throw new NullPointerException("NARG");
		
		// Null is used.
		if (__n == null)
			return null;
		
		// {@squirreljme.error ZZ3s Decimal integers cannot have an
		// alternative form.}
		if (__pf.__hasFlag(__PrintFFlag__.ALTERNATIVE_FORM))
			throw new IllegalArgumentException("ZZ3s");
		
		// Generate base number
		long value = __n.longValue();
		boolean neg = (value < 0);
		StringBuilder base = new StringBuilder(Long.toString(value));
		
		// Use local digit grouping
		if (__pf.__hasFlag(__PrintFFlag__.LOCALE_GROUPING))
			throw new todo.TODO();
		
		// Negative values can have flags (note negatives are always signed)
		boolean signed = neg;
		if (neg)
		{
			// Use parenthesis for negative instead
			if (__pf.__hasFlag(__PrintFFlag__.NEGATIVE_PARENTHESIS))
			{
				// Replace the sign with open parenthesis
				base.setCharAt(0, '(');
				
				// And add parenthesis to the end
				base.append(')');
			}
		}
		
		// Positive values have some flags
		else
		{
			// Always use the sign
			if (signed |= __pf.__hasFlag(__PrintFFlag__.ALWAYS_SIGNED))
				base.insert(0, '+');
			
			// Space for positive value
			else if (signed |= __pf.__hasFlag(
				__PrintFFlag__.SPACE_FOR_POSITIVE))
				base.insert(0, ' ');
		}
		
		// Padding with zero? Remember if there is a sign in place
		if (__pf.__hasFlag(__PrintFFlag__.ZERO_PADDED))
			for (int w = __pf.__width(), idx = (signed ? 1 : 0);
				base.length() < w;)
				base.insert(idx, '0');
		
		// Use this result
		return base.toString();
	}
	
	/**
	 * Formats other unsigned value.
	 *
	 * @param __pf Printing state.
	 * @param __n The number to print.
	 * @param __base The number's base.
	 * @throws 
	 */
	private static String __formatOtherUnsignedInt(__PrintFState__ __pf,
		Number __n, int __base)
		throws NullPointerException
	{
		if (__pf == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3t Invalid flag specified for unsigned
		// formatted value.}
		if (__pf.__hasFlag(__PrintFFlag__.LOCALE_GROUPING) ||
			__pf.__hasFlag(__PrintFFlag__.NEGATIVE_PARENTHESIS) ||
			__pf.__hasFlag(__PrintFFlag__.ALWAYS_SIGNED) ||
			__pf.__hasFlag(__PrintFFlag__.SPACE_FOR_POSITIVE))
			throw new IllegalArgumentException("ZZ3t");
		
		// Get the long value of the given value, because it is limited to
		// the precision (byte:-2 becomes 0xFE)
		long input;
		if (__n instanceof Byte)
			input = __n.byteValue() & 0xFF;
		else if (__n instanceof Short)
			input = __n.shortValue() & 0xFFFF;
		else if (__n instanceof Integer)
			input = __n.intValue() & 0xFFFFFFFF;
		else
			input = __n.longValue();
		
		// Bit shift and mask used for the value
		int shift, mask;
		switch (__pf._conv)
		{
			case OCTAL_INTEGER:
				mask = 0x7;
				shift = 3;
				break;
			
			default:
			case HEXADECIMAL_INTEGER:
				mask = 0xF;
				shift = 4;
				break;
		}
		
		// Build the output number, constantly shift it until it is zero
		StringBuilder out = new StringBuilder();
		for (long rest = input; rest != 0; rest >>>= shift)
		{
			// Mask out the value
			int val = (int)(rest & mask);
			
			// Add the character for this digit
			out.append(Character.forDigit(val, __base));
		}
		
		// Pad the remaining space with zero
		if (__pf.__hasFlag(__PrintFFlag__.ZERO_PADDED))
			for (int i = out.length(), n = __pf.__width(); i < n; i++)
				out.append('0');
		
		// Place in the alternative form somewhere
		if (__pf.__hasFlag(__PrintFFlag__.ALTERNATIVE_FORM))
		{
			// The length of the string
			int len = out.length();
			
			// Hex
			if (__base == 16)
			{
				// If the last two characters are zero, set the one before
				// last to X
				if (len >= 2 && out.charAt(len - 1) == '0' &&
					out.charAt(len - 2) == '0')
					out.setCharAt(len - 2, 'x');
				
				// If the last character is zero, then make it x and append
				// zero
				else if (len >= 1 && out.charAt(len - 1) == '0')
				{
					out.setCharAt(len - 1, 'x');
					out.append('0');
				}
				
				// Otherwise append 0x (reversed)
				else
				{
					out.append('x');
					out.append('0');
				}
			}
			
			// Octal
			else if (__base == 8)
			{
				// If the last character is not zero, then add zero to the end
				if (len < 1 && out.charAt(len - 1) != '0')
					out.append('0');
			}
		}
		
		// Reverse string because it is in the other order
		out.reverse();
		
		// Use it
		return out.toString();
	}
	
	/**
	 * Outputs to the state to the appendable.
	 *
	 * @param __out The output appendable.
	 * @param __pf The standard state.
	 * @throws IllegalArgumentException If the format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/28
	 */
	private static void __output(Appendable __out, __PrintFState__ __pf)
		throws IllegalArgumentException, IOException, NullPointerException
	{
		if (__out == null || __pf == null)
			throw new NullPointerException("NARG");
			
		__PrintFConversion__ conv = __pf._conv;
		__PrintFCategory__ cat = conv.__category();
		
		// Depends on the conversion
		String append;
		switch (conv)
		{
				// Newline sequence
			case NEWLINE:
				append = Formatter._NEWLINE;
				break;
				
				// Boolean
			case BOOLEAN:
				append = __pf.<Boolean>__argument(Boolean.class,
					Boolean.FALSE).toString();
				break;
				
				// Single character
			case CHARACTER:
				Character cha = __pf.<Character>__argument(Character.class);
				append = (cha == null ? "null" : cha.toString());
				break;
				
				// Octal 
			case OCTAL_INTEGER:
				append = Formatter.__formatOtherUnsignedInt(__pf,
					__pf.<Number>__argument(Number.class), 8);
				break;
			
				// Decimal Integer
			case DECIMAL_INTEGER:
				append = Formatter.__formatDecimalInt(__pf,
					__pf.<Number>__argument(Number.class));
				break;
				
				// Hexadecimal Integer
			case HEXADECIMAL_INTEGER:
				append = Formatter.__formatOtherUnsignedInt(__pf,
					__pf.<Number>__argument(Number.class), 16);
				break;
			
				// Simple string conversion
			case STRING:
				append = __pf.<Object>__argument(Object.class, "null").
					toString();
				break;
			
				// {@squirreljme.error ZZ2n Unimplemented conversion.
				// (The conversion)}
			default:
				throw new todo.TODO("ZZ2n " + conv);
		}
		
		// Convert to uppercase
		if (__pf._upper)
			append = append.toUpperCase();
		
		// General items may be reduced by the precision, at most
		if (cat == __PrintFCategory__.GENERAL)
		{
			int precision = __pf._precision;
			if (precision >= 0)
				append = append.substring(0,
					Math.min(precision, append.length()));
		}
		
		// Width is either higher of the input width or the string length
		int strlen = append.length(),
			width = Math.max(strlen, __pf._width),
			padding = width - strlen;
		
		// Right justification spaces?
		boolean isleft = __pf.__isLeftJustified();
		if (!isleft)
			for (int i = 0; i < padding; i++)
				__out.append(' ');
		
		// Send the string in
		__out.append(append);
		
		// Left justification spaces?
		if (isleft)
			for (int i = 0; i < padding; i++)
				__out.append(' ');
	}
	
	/**
	 * Parses the specifier in the input format.
	 *
	 * This parses the following, just returning that information:
	 * {@code %[argument_index$][flags][width][.precision]conversion}.
	 *
	 * @param __pf The PrintF state.
	 * @param __base The base character index.
	 * @param __fmt The format specifiers.
	 * @return The index where the format specifier ends, this is so the
	 * calling loop can properly set its counter.
	 * @throws IllegalArgumentException If the format specifiers are not
	 * correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/23
	 */
	private static int __specifier(__PrintFState__ __pf, int __base,
		String __fmt)
		throws IllegalArgumentException, NullPointerException
	{
		if (__pf == null || __fmt == null)
			throw new NullPointerException("NARG");
		
		// Length of the format
		int fmtlen = __fmt.length();
		
		// The specifier could be too short! So handle these cases and make
		// sure the exception of the right type
		int at = __base + 1;
		try
		{
			char c = __fmt.charAt(at);
			
			// The first might be a number specifying the argument index to use
			// Note that zero is NOT included because it would be parsed as
			// a flag, additionally argument indexes are 1-based!
			if (c >= '1' && c <= '9')
			{
				// Read the entire number
				int base = at;
				for (;;)
				{
					c = __fmt.charAt(at);
					if (c >= '0' && c <= '9')
						at++;
					else
						break;
				}
				
				// Parse value
				int val = Integer.valueOf(__fmt.substring(base, at));
				
				// If there is a dollar sign, this is going to be the
				// argument index
				if (__fmt.charAt(at) == '$')
				{
					__pf.__setArgumentIndex(val);
					
					// Skip the dollar
					at++;
				}
				
				// Otherwise this is the width
				else
					__pf.__setWidth(val);
			}
			
			// Parse flags, but only if no width was specified
			if (!__pf.__hasWidth())
				for (c = __fmt.charAt(at); __pf.__setFlag(c);
					at++, c = __fmt.charAt(at))
					;
			
			// Parse width
			c = __fmt.charAt(at);
			if (!__pf.__hasWidth() && c >= '1' && c <= '9')
			{
				// Read the entire number
				int base = at;
				for (;;)
				{
					c = __fmt.charAt(at);
					if (c >= '0' && c <= '9')
						at++;
					else
						break;
				}
				
				// Set width
				__pf.__setWidth(Integer.valueOf(__fmt.substring(base, at)));
			}
			
			// Parse precision
			c = __fmt.charAt(at);
			if (c == '.')
				throw new todo.TODO();
			
			// Parse the conversion
			c = __fmt.charAt(at);
			if (c == 't' || c == 'T')
			{
				__pf.__setConversion(c, __fmt.charAt(at + 1));
				at++; 
			}
			else
				__pf.__setConversion(c, -1);
			
			// Skip conversion character
			at++;
		}
		
		// {@squirreljme.error ZZ2o Could not parse the format specifier
		// properly. (The string with the specifier sequence)}
		catch (IndexOutOfBoundsException|NumberFormatException e)
		{
			throw new IllegalArgumentException("ZZ2o " +
				__fmt.substring(__base, Math.min(at, __fmt.length())), e);
		}
		
		// Return the new ending index, after everything was parsed
		return at;
	}
}

Deleted runt/apis/cldc-compact/java/util/HashMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This is a hash table where keys are mapped to values.
 *
 * This class is not thread safe.
 *
 * If keys are added or removed during iteration then
 * {@link ConcurrentModificationException} will be thrown.
 *
 * @since 2018/10/07
 */
public class HashMap<K, V>
	extends AbstractMap<K, V>
	implements Map<K, V>, Cloneable
{
	/** Internal map. */
	final __BucketMap__<K, V> _map;
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/10/07
	 */
	public HashMap(int __cap, float __load)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			false, __cap, __load);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/10/07
	 */
	public HashMap(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			__cap);
	}
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @since 2018/10/07
	 */
	public HashMap()
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap));
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public HashMap(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the map
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __m.size()));
		
		// Put all entries
		this.putAll(__m);
	}
	
	/**
	 * Initializes the map with the given capacity and load factor in the
	 * given access order.
	 *
	 * This is an internal constructor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @param __ao Is access order used?
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	HashMap(int __cap, float __load, boolean __ao)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>((this instanceof LinkedHashMap),
			__ao, __cap, __load);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * Returns a shallow copy of this map which just shares the same key and
	 * value mappings, the actual keys and values are not cloned.
	 *
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		try
		{
			// Create a new instance of this class to put into, since the class
			// is always of the same type
			Map<K, V> copy = (Map<K, V>)this.getClass().newInstance();
			
			// Copy all the elements over
			copy.putAll(this);
			
			return copy;
		}
		
		// Oops
		catch (IllegalAccessException|InstantiationException e)
		{
			// {@squirreljme.error ZZ2p Could not clone the map.}
			throw new RuntimeException("ZZ2p", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/26
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return null != this._map.getEntry(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public Set<Map.Entry<K, V>> entrySet()
	{
		return this._map.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public V get(Object __k)
	{
		__BucketMapEntry__<K, V> e = this._map.getEntry(__k);
		if (e == null)
			return null;
		return e.getValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/07
	 */
	@Override
	public V put(K __k, V __v)
	{
		// Just operates on that key
		return this._map.putEntry(__k).setValue(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public V remove(Object __k)
	{
		return this._map.remove(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}


Deleted runt/apis/cldc-compact/java/util/HashSet.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
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


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

public class HashSet<E>
	extends AbstractSet<E>
	implements Set<E>, Cloneable
{
	/** Internal map. */
	private final __BucketMap__<E, Object> _map;
	
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	public HashSet(int __cap, float __load)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet), false, __cap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/01
	 */
	public HashSet(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet), __cap);
	}
	
	/**
	 * Initializes the set with the default capacity and load factor.
	 *
	 * @since 2018/11/01
	 */
	public HashSet()
	{
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet));
	}
	
	/**
	 * Initializes a set which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input set.
	 *
	 * @param __s The set to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public HashSet(Collection<? extends E> __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the set
		this._map = new __BucketMap__<E, Object>(
			(this instanceof LinkedHashSet),
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __s.size()));
		
		// Add all entries
		this.addAll(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public boolean add(E __v)
	{
		// The set has been modified only if the special taken value was
		// set to null (it will become non-null)
		__BucketMapEntry__<E, Object> e = this._map.putEntry(__v);
		return (e.setValue(__BucketMap__._TAKEN) == null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * Returns a shallow copy of this map which just shares the same key and
	 * value mappings, the actual keys and values are not cloned.
	 *
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		try
		{
			// Create a new instance of this class to put into, since the class
			// is always of the same type
			Set<E> copy = (Set<E>)this.getClass().newInstance();
			
			// Copy all the elements over
			copy.addAll(this);
			
			return copy;
		}
		
		// Oops
		catch (IllegalAccessException|InstantiationException e)
		{
			// {@squirreljme.error ZZ2q Could not clone the map.}
			throw new RuntimeException("ZZ2q", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public boolean contains(Object __v)
	{
		return null != this._map.getEntry(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public Iterator<E> iterator()
	{
		return this._map.keySet().iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public boolean remove(Object __v)
	{
		// Return true if there was an entry for this key
		__BucketMapEntry__<E, Object> rv = this._map.removeEntry(__v, false);
		return rv != null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

Deleted runt/apis/cldc-compact/java/util/Hashtable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438






















































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.IteratorToEnumeration;
import cc.squirreljme.runtime.cldc.util.SynchronizedEntrySet;
import cc.squirreljme.runtime.cldc.util.SynchronizedEntrySetNotNull;
import cc.squirreljme.runtime.cldc.util.SynchronizedSet;

/**
 * This is similar to {@link HashMap} except that it is thread safe and does
 * not permit null keys or values.
 *
 * @since 2019/05/05
 */
public class Hashtable<K, V>
	implements Map<K, V>, Cloneable
{
	/** Internal map. */
	private final __BucketMap__<K, V> _map;
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/05
	 */
	public Hashtable(int __cap, float __load)
	{
		this._map = new __BucketMap__<K, V>(false, false, __cap, __load);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/05
	 */
	public Hashtable(int __cap)
		throws IllegalArgumentException
	{
		this._map = new __BucketMap__<K, V>(false, __cap);
	}
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @since 2019/05/05
	 */
	public Hashtable()
	{
		this._map = new __BucketMap__<K, V>(false);
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException If {@code __m} is null or it contains
	 * null keys or values.
	 * @since 2018/10/07
	 */
	public Hashtable(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Capacity is just the number of entries in the map
		this._map = new __BucketMap__<K, V>(false,
			Math.max(__BucketMap__._DEFAULT_CAPACITY, __m.size()));
		
		// Put all entries
		this.putAll(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void clear()
	{
		synchronized (this)
		{
			this._map.clear();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	@ImplementationNote("This creates a new instance of this class and " +
		"then places all the entries into it.")
	public Object clone()
	{
		synchronized (this)
		{
			try
			{
				// Create a new instance of this class to put into, since the
				// class is always of the same type
				Map<K, V> copy = (Map<K, V>)this.getClass().newInstance();
				
				// Copy all the elements over
				copy.putAll(this);
				
				return copy;
			}
			
			// Oops
			catch (IllegalAccessException|InstantiationException e)
			{
				// {@squirreljme.error ZZ2r Could not clone the hashtable.}
				throw new RuntimeException("ZZ2r", e);
			}
		}
	}
	
	/**
	 * Checks if the map contains the specified value.
	 *
	 * @param __v The value to check.
	 * @return If the map contains the value or not.
	 * @since 2019/05/05
	 */
	public boolean contains(Object __v)
	{
		synchronized (this)
		{
			return this.values().contains(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		synchronized (this)
		{
			return null != this._map.getEntry(__k);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean containsValue(Object __v)
	{
		synchronized (this)
		{
			return this.values().contains(__v);
		}
	}
	
	/**
	 * Returns an enumeration over the elements.
	 *
	 * @return The enumerator over the elements.
	 * @sine 2019/05/05
	 */
	public Enumeration<V> elements()
	{
		synchronized (this)
		{
			return new IteratorToEnumeration<V>(this.values().iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public Set<Map.Entry<K, V>> entrySet()
	{
		synchronized (this)
		{
			return new SynchronizedEntrySetNotNull<K, V>(this,
				this._map.entrySet());
		}
	}
	
	@Override
	public boolean equals(Object __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If the requested key is null.
	 * @since 2019/05/05
	 */
	@Override
	public V get(Object __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			__BucketMapEntry__<K, V> e = this._map.getEntry(__k);
			if (e == null)
				return null;
			return e.getValue();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public int hashCode()
	{
		synchronized (this)
		{
			int rv = 0;
			for (Map.Entry<K, V> e : this.entrySet())
				rv += e.hashCode();
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public boolean isEmpty()
	{
		synchronized (this)
		{
			return this._map.isEmpty();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public Set<K> keySet()
	{
		return new __AbstractMapKeySet__<K, V>(this);
	}
	
	/**
	 * Returns an enumeration over the keys.
	 *
	 * @return The key enumeration.
	 * @since 2019/05/05
	 */
	public Enumeration<K> keys()
	{
		synchronized (this)
		{
			return new IteratorToEnumeration<K>(this.keySet().iterator());
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If the key or value is null.
	 * @since 2019/05/05
	 */
	@Override
	public V put(K __k, V __v)
		throws NullPointerException
	{
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		__BucketMap__<K, V> map = this._map;
		synchronized (this)
		{
			// To detect rehashing
			int numrehash = map._numrehash;
			
			// Set value, remember old one
			V rv = this._map.putEntry(__k).setValue(__v);
			
			// If the map was ever rehashed, then call this method
			if (map._numrehash != numrehash)
				this.rehash();
			
			// Done
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public void putAll(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// Copy everything
			for (Map.Entry<? extends K, ? extends V> e : __m.entrySet())
				this.put(e.getKey(), e.getValue());
		}
	}
	
	/**
	 * This reorganizes and reorders the entries internally in the hash map,
	 * this is called automatically when the map has been reordered.
	 *
	 * @since 2019/05/05
	 */
	@ImplementationNote("In SquirrelJME this has no actual effect because " +
		"it is internally handled, however code might rely on overriding " +
		"this method to determine when the map has been rehashed.")
	protected void rehash()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @throws NullPointerException If a null key was specified.
	 * @since 2019/05/05
	 */
	@Override
	public V remove(Object __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		__BucketMap__<K, V> map = this._map;
		synchronized (this)
		{
			// To detect rehashing
			int numrehash = map._numrehash;
			
			// Remove key
			V rv = this._map.remove(__k);
			
			// If the map was ever rehashed, then call this method
			if (map._numrehash != numrehash)
				this.rehash();
			
			// Done
			return rv;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public int size()
	{
		synchronized (this)
		{
			return this._map.size();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public String toString()
	{
		synchronized (this)
		{
			StringBuilder sb = new StringBuilder("{");
			
			// Go through and append
			boolean comma = false;
			for (Map.Entry<?, ?> e : this.entrySet())
			{
				// Space comma
				if (comma)
					sb.append(", ");
				comma = true;
				
				// Key is equal to the value
				sb.append(e.getKey());
				sb.append('=');
				sb.append(e.getValue());
			}
			
			sb.append('}');
			return sb.toString();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/05
	 */
	@Override
	public Collection<V> values()
	{
		return new __AbstractMapValues__<K, V>(this);
	}
}

Deleted runt/apis/cldc-compact/java/util/Iterator.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




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This provides support for linear iteration through unspecified elements.
 *
 * Generally, {@link Iterator}s are not meant to be shared across threads.
 *
 * This class should be used instead of {@link Enumeration}.
 *
 * @param <E> The element to iterate over.
 * @see Iterable
 * @since 2016/04/12
 */
public interface Iterator<E>
{
	/**
	 * Returns {@code true} if there are more elements in the iteration
	 * sequence.
	 *
	 * @return {@code true} if more elements are available, otherwise
	 * {@code false}.
	 * @since 2016/04/12
	 */
	public abstract boolean hasNext();
	
	/**
	 * Returns the next element in the iteration or throws an exception if
	 * there are none remaining.
	 *
	 * @return The next element in the iteration.
	 * @throws NoSuchElementException If no more elements are available.
	 * @since 2016/04/12
	 */
	public abstract E next()
		throws NoSuchElementException;
	
	/**
	 * This removes the last element which was returned by {@link #next()}. If
	 * removal is supported then it may only be performed once per call to
	 * {@link #next()}.
	 *
	 * @throws IllegalStateException If the object returned by {@code #next()}
	 * was already removed or said method was never called.
	 * @throws UnsupportedOperationException If removal of elements is not
	 * supported by this iteration.
	 * @since 2016/04/12
	 */
	public abstract void remove()
		throws IllegalStateException, UnsupportedOperationException;
}

Deleted runt/apis/cldc-compact/java/util/LinkedHashMap.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
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










































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a map which is backed by a hash table except that the iterator
 * order is in the order of which elements were added first.
 *
 * Otherwise this class is exactly the same as {@link HashMap}.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @see HashMap
 * @since 2019/05/09
 */
public class LinkedHashMap<K, V>
	extends HashMap<K, V>
	implements Map<K, V>
{
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __cap, float __load)
		throws IllegalArgumentException
	{
		super(__cap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __initcap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __initcap)
		throws IllegalArgumentException
	{
		super(__initcap);
	}
	
	/**
	 * Initializes an empty map.
	 *
	 * @since 2019/05/09
	 */
	public LinkedHashMap()
	{
	}
	
	/**
	 * Initializes a map which is a copy of the other map.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		super(__m);
	}
	
	/**
	 * Initializes the set with the given capacity and load factor, but the
	 * may be ordered based on what is first accessed.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @param __ao If the iterator should always return the same order for
	 * accesses.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2019/05/09
	 */
	public LinkedHashMap(int __cap, float __load, boolean __ao)
	{
		super(__cap, __load, __ao);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public V put(K __k, V __v)
	{
		__BucketMap__<K, V> map = this._map;
		
		// Put entry into the map and store the old value
		__BucketMapEntry__<K, V> entry = map.putEntry(__k);
		V rv = entry.setValue(__v);
		
		// Remove the eldest entry (which is the oldest/first item in the map)
		__BucketMapEntry__<K, V> eldest = map._links.peekFirst();
		if (eldest != null && this.removeEldestEntry(eldest))
			map.removeEntry(eldest.getKey(), false);
		
		// Return the former value
		return rv;
	}
	
	/**
	 * After a {@code put} or {@code putAll} operation this will be called with
	 * the eldest entry to determine if it should be removed or not. This may
	 * be used for cache purposes.
	 *
	 * The default implementation returns {@code false}.
	 *
	 * If the implementation of this method modifies the map then this should
	 * always return {@code null}.
	 *
	 * @param __e The entry being 
	 * @since 2019/05/09
	 */
	protected boolean removeEldestEntry(Map.Entry<K, V> __e)
	{
		return false;
	}
}

Deleted runt/apis/cldc-compact/java/util/LinkedHashSet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a set which is backed by a hash table except that the iterator
 * order is in the order of which elements were added first.
 *
 * Otherwise this class is exactly the same as {@link HashSet}.
 *
 * @param <E> The element type to store.
 * @see HashSet
 * @since 2018/11/01
 */
public class LinkedHashSet<E>
	extends HashSet<E>
	implements Set<E>, Cloneable
{
	/**
	 * Initializes the set with the given capacity and load factor.
	 *
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/11/01
	 */
	public LinkedHashSet(int __initcap, float __load)
		throws IllegalArgumentException
	{
		super(__initcap, __load);
	}
	
	/**
	 * Initializes the set with the given capacity and the default load factor.
	 *
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/11/01
	 */
	public LinkedHashSet(int __initcap)
		throws IllegalArgumentException
	{
		super(__initcap);
	}
	
	/**
	 * Initializes the set with the default capacity and load factor.
	 *
	 * @since 2018/11/01
	 */
	public LinkedHashSet()
	{
		super();
	}
	
	/**
	 * Initializes a set which is a copy of the other set.
	 *
	 * The default load factor is used and the capacity is set to the
	 * capacity of the input set.
	 *
	 * @param __s The set to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public LinkedHashSet(Collection<? extends E> __s)
	{
		super(__s);
	}
}

Deleted runt/apis/cldc-compact/java/util/LinkedList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441

























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * A linked list is a list of items which are held together using chains. Each
 * value for an element is placed within a chain link which is then held to
 * other links in the chain. This is a doubly linked list.
 *
 * This class has efficient insertion and removal via the iterator interfaces.
 *
 * Random access is not efficient and the further away the element is from the
 * initial sequence the more elements will need to be skipped to access the
 * data.
 *
 * This class is not thread safe.
 *
 * @param <E> The type of element to store.
 * @since 2016/09/05
 */
@ImplementationNote("For simplicity this uses base anchor nodes for the " +
	"head and tail of the list.")
public class LinkedList<E>
	extends AbstractSequentialList<E>
	implements List<E>, Deque<E>, Cloneable
{
	/** The list head. */
	final __Link__<E> _head =
		new __Link__<E>(null, null, null);
	
	/** The list tail, this gets linked into the head. */
	final __Link__<E> _tail =
		new __Link__<E>(this._head, null, null);
		
	/** The number of entries in the list. */
	int _size;
	
	/**
	 * Initializes a linked list with no entries.
	 *
	 * @since 2016/09/05
	 */
	public LinkedList()
	{
	}
	
	/**
	 * Initializes a linked list which contains a copy of all of the elements
	 * of the other collection in its iterator order.
	 *
	 * @param __a The collection to copy elements from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/05
	 */
	public LinkedList(Collection<? extends E> __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Just call addAll
		this.addAll(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void addFirst(E __v)
	{
		this.add(0, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void addLast(E __v)
	{
		this.add(this._size, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/05
	 */
	@Override
	public void clear()
	{
		// Since there are anchor entries used for the linked list we can just
		// set the anchor points to each other
		__Link__<E> head = this._head,
			tail = this._tail;
		head._next = tail;
		tail._prev = head;
		
		// Clear size
		this._size = 0;
		
		// List was modified
		LinkedList.this.modCount++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public Object clone()
	{
		return new LinkedList<>(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public Iterator<E> descendingIterator()
	{
		return new __DescendingIteratorViaListIterator__<E>(
			new __LinkedListListIterator__<E>(this, this._size));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E element()
		throws NoSuchElementException
	{
		return this.getFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E getFirst()
		throws NoSuchElementException
	{
		// {@squirreljme.error ZZ2s Cannot get the first element because the
		// linked list is empty.}
		if (this._size == 0)
			throw new NoSuchElementException("ZZ2s");
		
		// One forward from the head
		return this._head._next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E getLast()
	{
		// {@squirreljme.error ZZ2t Cannot get the last element because the
		// linked list is empty.}
		int sz;
		if ((sz = this._size) == 0)
			throw new NoSuchElementException("ZZ2t");
		
		// Just one back from the tail
		return this._tail._prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public ListIterator<E> listIterator(int __i)
	{
		return new __LinkedListListIterator__<E>(this, __i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean offer(E __v)
	{
		return offerLast(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean offerFirst(E __v)
	{
		// There are no capacity restrictions
		this.add(0, __v);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public boolean offerLast(E __v)
	{
		// There are no capacity restrictions
		this.add(this._size, __v);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peek()
	{
		return this.peekFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peekFirst()
	{
		// Return null on empty list
		if (this._size == 0)
			return null;
		
		// One forward from the head
		return this._head._next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E peekLast()
	{
		// Return null if the list is empty
		int sz;
		if ((sz = _size) == 0)
			return null;
		
		// Just one back from the tail
		return this._tail._prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E poll()
	{
		return this.pollFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pollFirst()
	{
		if (this._size == 0)
			return null;
		
		ListIterator<E> it = this.listIterator(0);
		
		// Remove the first element
		E rv = it.next();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pollLast()
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(this._size);
		
		// Remove the last element
		E rv = it.previous();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E pop()
	{
		return this.removeFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public void push(E __v)
	{
		this.addFirst(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E remove()
	{
		return this.removeFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E removeFirst()
		throws NoSuchElementException
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(0);
		
		// Remove the first element
		E rv = it.next();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean removeFirstOccurrence(Object __a)
	{
		// Start at the start of the list and remove the first match
		Iterator<E> rover = iterator();
		while (rover.hasNext())
		{
			E v = rover.next();
			
			// If this is the same object then remove it
			if (Objects.equals(v, __a))
			{
				rover.remove();
				return true;
			}
		}
		
		// Nothing was removed
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public E removeLast()
	{
		if (this._size == 0)
			throw new NoSuchElementException("NSEE");
		
		ListIterator<E> it = this.listIterator(this._size);
		
		// Remove the last element
		E rv = it.previous();
		it.remove();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public boolean removeLastOccurrence(Object __a)
	{
		// Start at the end of the list and remove the first match
		ListIterator<E> rover = listIterator(_size);
		while (rover.hasPrevious())
		{
			E v = rover.previous();
			
			// If this is the same object then remove it
			if (Objects.equals(v, __a))
			{
				rover.remove();
				return true;
			}
		}
		
		// Nothing was removed
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/05
	 */
	@Override
	public int size()
	{
		return this._size;
	}
}

Deleted runt/apis/cldc-compact/java/util/List.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface List<E>
	extends Collection<E>
{
	public abstract boolean add(E __a);
	
	public abstract void add(int __a, E __b);
	
	public abstract boolean addAll(Collection<? extends E> __a);
	
	public abstract boolean addAll(int __a, Collection<? extends E> __b);
	
	public abstract void clear();
	
	public abstract boolean contains(Object __a);
	
	public abstract boolean containsAll(Collection<?> __a);
	
	@Override
	public abstract boolean equals(Object __a);
	
	/**
	 * Gets the value at the specified index.
	 *
	 * @param __i The index to get.
	 * @return The value at this index.
	 * @throws IndexOutOfBoundsException If the index it out of bounds for the
	 * list.
	 * @since 2018/12/07
	 */
	public abstract E get(int __i)
		throws IndexOutOfBoundsException;
	
	@Override
	public abstract int hashCode();
	
	public abstract int indexOf(Object __a);
	
	public abstract boolean isEmpty();
	
	public abstract Iterator<E> iterator();
	
	public abstract int lastIndexOf(Object __a);
	
	public abstract ListIterator<E> listIterator();
	
	public abstract ListIterator<E> listIterator(int __a);
	
	public abstract boolean remove(Object __a);
	
	public abstract E remove(int __a);
	
	public abstract boolean removeAll(Collection<?> __a);
	
	public abstract boolean retainAll(Collection<?> __a);
	
	public abstract E set(int __a, E __b);
	
	public abstract int size();
	
	public abstract List<E> subList(int __a, int __b);
	
	public abstract Object[] toArray();
	
	public abstract <T> T[] toArray(T[] __a);
}

Deleted runt/apis/cldc-compact/java/util/ListIterator.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface ListIterator<E>
	extends Iterator<E>
{
	public abstract void add(E __v);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public abstract boolean hasNext();
	
	public abstract boolean hasPrevious();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public abstract E next();
	
	public abstract int nextIndex();
	
	public abstract E previous();
	
	public abstract int previousIndex();
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public abstract void remove();
	
	public abstract void set(E __v);
}

Deleted runt/apis/cldc-compact/java/util/Map.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




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Map<K, V>
{
	public abstract void clear();
	
	public abstract boolean containsKey(Object __a);
	
	public abstract boolean containsValue(Object __a);
	
	public abstract Set<Map.Entry<K, V>> entrySet();
	
	@Override
	public abstract boolean equals(Object __a);
	
	public abstract V get(Object __a);
	
	@Override
	public abstract int hashCode();
	
	public abstract boolean isEmpty();
	
	public abstract Set<K> keySet();
	
	public abstract V put(K __a, V __b);
	
	public abstract void putAll(Map<? extends K, ? extends V> __a);
	
	public abstract V remove(Object __a);
	
	public abstract int size();
	
	public abstract Collection<V> values();
	
	public static interface Entry<K, V>
	{
		@Override
		public abstract boolean equals(Object __a);
		
		public abstract K getKey();
		
		public abstract V getValue();
		
		@Override
		public abstract int hashCode();
		
		public abstract V setValue(V __a);
	}
}

Deleted runt/apis/cldc-compact/java/util/NoSuchElementException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is thrown when no element exists, usually from an {@link Iterator}.
 *
 * @since 2018/10/29
 */
public class NoSuchElementException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/29
	 */
	public NoSuchElementException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/29
	 */
	public NoSuchElementException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/cldc-compact/java/util/Objects.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
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
















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;

/**
 * This class provides utility methods which are usually able to handle null
 * values.
 *
 * @since 2016/04/12
 */
public final class Objects
{
	/**
	 * Should not be called at all.
	 *
	 * @since 2016/04/12
	 */
	private Objects()
	{
		throw new todo.OOPS();
	}
	
	/**
	 * This compares two values and possibly may compare it with the given
	 * {@link Comparator}. First, if the input objects are identical (in that
	 * {@code __a == __b} is performed) then {@code 0} is returned. Otherwise,
	 * the values are passed to the specified {@link Comparator}.
	 *
	 * A {@link NullPointerException} may be thrown by the comparator.
	 *
	 * @param <T> The type of value to compare.
	 * @param __a The first value.
	 * @param __b The second value.
	 * @param __c The comparator to use.
	 * @return {@code 0} if {@code __a == __b}, otherwise the value returned
	 * from the {@link Comparator}.
	 * @throws NullPointerException If the objects are not the same object
	 * reference and there is no {@link Comparator}. May also be thrown if the
	 * comparator is unable to handle {@code null} arguments.
	 * @since 2016/04/12
	 */
	public static <T> int compare(T __a, T __b, Comparator<? super T> __c)
		throws NullPointerException
	{
		// The same object?
		if (__a == __b)
			return 0;
		
		// Compare otherwise
		if (__c == null)
			throw new NullPointerException("NARG");
		return __c.compare(__a, __b);
	}
	
	/**
	 * Checks whether two objects are equal to each other, if one of the
	 * values is {@code null} then this returns {@code false}, otherwise
	 * equality is checked. If both values are {@code null} then {@code true}
	 * is returned.
	 *
	 * @param __a The object which gets {@link Object#equals(Object)} called.
	 * @param __b The parameter to that call.
	 * @return {@code true} if they are both equal or both {@code null}.
	 * @since 2016/04/12
	 */
	public static boolean equals(Object __a, Object __b)
	{
		// Same instance or both are null
		if (__a == __b)
			return true;
		
		// Left side is null and right is not, so not the same
		else if (__a == null)
			return false;
		
		// Use standard comparison
		return __a.equals(__b);
	}
	
	/**
	 * Returns the hash code of the given object or {@code 0} if it is
	 * {@code null}.
	 *
	 * @param __a The object to get the hashcode of.
	 * @return The object's hash code or {@code 0} if it is {@code null}.
	 * @since 2016/04/12
	 */
	public static int hashCode(Object __a)
	{
		if (__a == null)
			return 0;
		return __a.hashCode();
	}
	
	/**
	 * Checks whether the given input value is not {@code null} and then
	 * returns it, otherwise this throws {@link NullPointerException}.
	 *
	 * @param <T> The type of value to return.
	 * @param __a The value to return.
	 * @return {@code __a}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/12
	 */
	public static <T> T requireNonNull(T __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		return __a;
	}
	
	/**
	 * Checks whether the given input value is not {@code null} and then
	 * returns it, otherwise this throws a {@link NullPointerException} with
	 * the given message.
	 *
	 * @param <T> The type of value to return.
	 * @param __a The value to return.
	 * @return {@code __a}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/12
	 */
	public static <T> T requireNonNull(T __a, String __b)
	{
		// Check
		if (__a == null)
			throw new NullPointerException((__b != null ? __b : "NARG"));
		return __a;
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code "null"} is returned.
	 *
	 * @param __a The value to get the string of.
	 * @return The string of the given value or {@code "null"} if the input is
	 * {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a)
	{
		if (__a == null)
			return "null";
		return __a.toString();
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code __b} is returned.
	 *
	 * @param __a The object to get the string of.
	 * @param __b The value to return if {@code __a} is {@code null}.
	 * @return The string represention of {@code __a} or else {@code __b} if
	 * the input is {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a, String __b)
	{
		if (__a == null)
			return __b;
		return __a.toString();
	}
}

Deleted runt/apis/cldc-compact/java/util/PropertyPermission.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import java.security.BasicPermission;
import java.security.Permission;
import java.security.PermissionCollection;

/**
 * This permission is used to specify access to a system property.
 *
 * Property names come in two formats: A fully specified string which matches
 * the key, or if it ends in asterisk {@code '*'} it will be a wildcard match
 * at the base string. Note that only the last character is considered if this
 * is a wildcard match.
 *
 * The following permissions are available:
 * {@code "read"} -- Read access to the property.
 * {@code "write"} -- Write access to the property.
 *
 * Multiple permissions may be specified, separated by comma.
 *
 * @since 2018/09/18
 */
public final class PropertyPermission
	extends BasicPermission
{
	/** The key to check or the prefix if a wildcard. */
	private final String _key;
	
	/** If this is a wildcard permission. */
	private final boolean _iswildcard;
	
	/** Is this read permission? */
	private final boolean _isread;
	
	/** Is this write permission? */
	private final boolean _iswrite;
	
	/**
	 * Initializes the permission.
	 *
	 * @param __key The key to check.
	 * @param __act The action on the key.
	 * @throws IllegalArgumentException If the action is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	public PropertyPermission(String __key, String __act)
		throws IllegalArgumentException, NullPointerException
	{
		super(__key, __act);
		
		if (__key == null || __act == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ2x Property permission key cannot be
		// negative.}
		if (__key.isEmpty())
			throw new IllegalArgumentException("ZZ2x");
		
		// Setup key first
		this._key = __key;
		this._iswildcard = (__key.charAt(__key.length() - 1) == '*');
		
		// Convert action to lowercase first
		__act = __act.toLowerCase();
		
		// This field is split with commas and may contain read or write
		boolean r = false,
			w = false;
		for (int i = 0, n = __act.length(); i < n;)
		{
			// Find the next comma, if there is none use the end of string
			int dx = __act.indexOf(',', i);
			if (dx < 0)
				dx = n;
			
			// Determine which action to take
			String sub;
			switch ((sub = __act.substring(i, dx)))
			{
				case "read":
					r = true;
					break;
				
				case "write":
					w = true;
					break;
				
					// {@squirreljme.error ZZ2y The specified action is not
					// valid for property permissions. (The action; The input
					// actions)}
				default:
					throw new IllegalArgumentException(
						String.format("ZZ2y %s %s", sub, __act));
			}
			
			// Remember to skip the comma, if there is one
			i = dx + 1;
		}
		
		// Read or writing?
		this._isread = r;
		this._iswrite = w;
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Queue.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Queue<E>
	extends Collection<E>
{
	public abstract boolean add(E __a);
	
	public abstract E element();
	
	public abstract boolean offer(E __a);
	
	public abstract E peek();
	
	public abstract E poll();
	
	public abstract E remove();
}

Deleted runt/apis/cldc-compact/java/util/Random.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251



























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.util.FDMLMath;

/**
 * This is an insecure pseudo-random number generator.
 *
 * This class is thread safe however if multiple threads are using a single
 * instance then it is undefined if their order is the same.
 *
 * @since 2018/11/02
 */
@ImplementationNote("This code essentially is a copy and paste from the " +
	"library documentation since it must always be the same exact code. " +
	"Since there is only one way to implement this class it should be " +
	"legal to do so for compatibility purposes.")
public class Random
{
	/** The current seed value. */
	private long _seed;
	
	/** The next gaussian value. */
	private double _nextg;
	
	/** Has next next gaussian value? */
	private boolean _hasnng;
	
	/**
	 * Initializes the random number generator using an unspecified and
	 * potentially different key per construction.
	 *
	 * @since 2018/11/02
	 */
	public Random()
	{
		this(System.currentTimeMillis() +
			System.nanoTime());
	}
	
	/**
	 * Initializes the random number generator with the given seed.
	 *
	 * @param __seed The seed to initialize with.
	 * @since 2018/11/02
	 */
	public Random(long __seed)
	{
		this.setSeed(__seed);
	}
	
	/**
	 * Generates the next pseudorandom number, this method is used by every
	 * other method in this class. As such this is the only method that has
	 * to be changed if the internal algorithm is to be changed.
	 *
	 * @param __bits The number of bits to return.
	 * @since 2018/11/02
	 */
	protected int next(int __bits)
	{
		// This has to be atomic
		synchronized (this)
		{
			// Update the seed
			long seed = (this._seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
			this._seed = seed;
			
			return (int)(seed >>> (48 - __bits));
		}
	}
	
	/**
	 * Returns the next boolean value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public boolean nextBoolean()
	{
		return this.next(1) != 0;
	}
	
	/**
	 * Generates random bytes and places them into the array.
	 *
	 * @param __a The output array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/02
	 */
	public void nextBytes(byte[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, l = __a.length; i < l;)
			for (int r = this.nextInt(), n = Math.min(l - i, 4); n-- > 0;
				r >>= 8)
				__a[i++] = (byte)r;
	}
	
	/**
	 * Returns the next double value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public double nextDouble()
	{
		return (((long)this.next(26) << 27) + this.next(27)) /
			(double)(1L << 53);
	}
	
	/**
	 * Returns the next float value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public float nextFloat()
	{
		return this.next(24) / ((float)(1 << 24));
	}
	
	/**
	 * Return the next gaussian value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public double nextGaussian()
	{
		synchronized (this)
		{
			// If there was already a cached value, use it
			boolean hasnng = this._hasnng;
			if (hasnng)
			{
				this._hasnng = false;
				return this._nextg;
			}
			
			// Otherwise generate it
			else
			{
				double v1, v2, s;
				do
				{
					// Between -1.0 and 1.0
					v1 = 2 * nextDouble() - 1;
					v2 = 2 * nextDouble() - 1;

					s = v1 * v1 + v2 * v2;
				} while (s >= 1 || s == 0);
				
				double multiplier =
					FDMLMath.sqrt(-2 * FDMLMath.log(s) / s);
				
				// Store for next time
				this._nextg = v2 * multiplier;
				this._hasnng = true;
				
				// Return generated value
				return v1 * multiplier;
			}
		}
	}
	
	/**
	 * Returns the next int value.
	 *
	 * @return The next value.
	 * @since 2018/11/02
	 */
	public int nextInt()
	{
		return this.next(32);
	}
	
	/**
	 * Returns the next int value between inclusive 0 and exclusive
	 * {@code __cap}.
	 *
	 * @param __cap The exclusive value to end at.
	 * @return The next value.
	 * @throws IllegalArgumentException If the cap is zero or negative.
	 * @since 2018/11/02
	 */
	public int nextInt(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ2z Cap value must be a positive integer}
		if (__cap <= 0)
			throw new IllegalArgumentException("ZZ2z");
		
		// Cap is a power of two
		if ((__cap & -__cap) == __cap)
			return (int)((__cap * (long)this.next(31)) >> 31);
		
		// Otherwise calculate based on values in the range
		int bits, val;
		do
		{
			bits = this.next(31);
			val = bits % __cap;
		} while (bits - val + (__cap - 1) < 0);
		
		return val;
	}
	
	/**
	 * Returns the next long value.
	 *
	 * @return The next long value.
	 * @since 2018/11/02
	 */
	public long nextLong()
	{
		return ((long)this.next(32) << 32) + this.next(32);
	}
	
	/**
	 * Sets the seed for this random number generator.
	 *
	 * This is an atomic operation.
	 *
	 * @param __seed The seed to use.
	 * @since 2018/11/02
	 */
	public void setSeed(long __seed)
	{
		synchronized (this)
		{
			this._seed = (__seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
			this._hasnng = false;
		}
	}
}


Deleted runt/apis/cldc-compact/java/util/RandomAccess.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a collection which may be randomly accessed without
 * additional cost.
 *
 * @since 2018/12/08
 */
public interface RandomAccess
{
}

Deleted runt/apis/cldc-compact/java/util/ServiceConfigurationError.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is thrown when a service has not been configured properly.
 *
 * @since 2018/12/06
 */
public class ServiceConfigurationError
	extends Error
{
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/06
	 */
	public ServiceConfigurationError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the error with a message and the given cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause of this error.
	 * @since 2018/12/06
	 */
	public ServiceConfigurationError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
}

Deleted runt/apis/cldc-compact/java/util/ServiceLoader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422






































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.asm.ResourceAccess;
import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.util.LinkedHashSet;

/**
 * The service loader is used to lookup services which may be defined in the
 * classpath.
 *
 * Services are stored as a list of class in resources within the JAR, these
 * services lists are declared in files specifying the class name. So the
 * format is {@code META-INF/services/fully.qualified.class.name}.
 *
 * The iterator may throw {@code ServiceConfigurationError}.
 *
 * @param <S> The class to provide a service for.
 * @since 2018/12/06
 */
public final class ServiceLoader<S>
	implements Iterable<S>
{
	/** The class to search for. */
	private final Class<S> _search;
	
	/** The service cache. */
	private final __Cache__<S> _cache =
		new __Cache__<S>();
	
	/**
	 * Initializes the service loader.
	 *
	 * @param __cl The class to search.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/06
	 */
	private ServiceLoader(Class<S> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this._search = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public Iterator<S> iterator()
	{
		Class<S> search = this._search;
		__Cache__<S> cache = this._cache;
		
		// Use the cached array?
		Object[] use = cache._cache;
		if (use != null)
			return new __CachedIterator__<S>(search, use);
		
		// Cache it
		else
			return new __FreshIterator__<S>(search, cache);
	}
	
	/**
	 * Clears the cache of services.
	 *
	 * @since 2018/12/06
	 */
	public void reload()
	{
		// Clear the cache
		this._cache._cache = null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public String toString()
	{
		// Just matches what Java SE gives
		return "java.util.ServiceLoader[" + this._search.getName() + "]";
	}
	
	/**
	 * Create a service loader for the given class.
	 *
	 * @param __cl The class to load a service for.
	 * @return The service loader for this class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/06
	 */
	public static <S> ServiceLoader<S> load(Class<S> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return new ServiceLoader<S>(__cl);
	}
	
	/**
	 * Cache for the service loader.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __Cache__<S>
	{
		/** The cache of services. */
		volatile Object[] _cache;
	}
	
	/**
	 * Iterator over the cached set.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __CachedIterator__<S>
		implements Iterator<S>
	{
		/** The search class. */
		private final Class<S> _search;
		
		/** The array to use for this. */
		private final Object[] _items;
		
		/** The next index. */
		private int _next;
		
		/**
		 * Wraps the given array and provides an iterator of it.
		 *
		 * @param __s The search class.
		 * @param __it The iterator to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/12/06
		 */
		__CachedIterator__(Class<S> __s, Object[] __it)
			throws NullPointerException
		{
			if (__s == null || __it == null)
				throw new NullPointerException("NARG");
			
			this._search = __s;
			this._items = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final boolean hasNext()
		{
			return this._next < this._items.length;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final S next()
		{
			Object[] items = this._items;
			int next = this._next;
			
			// No more?
			if (next >= items.length)
				throw new NoSuchElementException("NSEE");
			
			// Get and iterator
			Object rv = items[next];
			this._next = next + 1;
			return this._search.cast(rv);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * Iterator over a fresh search pouring into the cache.
	 *
	 * @param <S> The class type.
	 * @since 2018/12/06
	 */
	private static final class __FreshIterator__<S>
		implements Iterator<S>
	{
		/** The search class. */
		private final Class<S> _search;
		
		/** The cache to put in. */
		private final __Cache__<S> _cache;
		
		/** Temporary cache building. */
		private final List<Object> _cachebuild =
			new ArrayList<>();
		
		/** Suites left to parse. */
		private final Queue<String> _suites =
			new LinkedList<>();
		
		/** Classes left to create and scan. */
		private final Queue<String> _classes =
			new LinkedList<>();
		
		/** The next service to run. */
		private S _next;
		
		/** Is this finished? */
		private boolean _finished;
		
		/**
		 * Initializes the iterator for fresh service lookup.
		 *
		 * @param __s The search class.
		 * @param __c The cache class.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/12/06
		 */
		__FreshIterator__(Class<S> __s, __Cache__<S> __c)
			throws NullPointerException
		{
			if (__s == null || __c == null)
				throw new NullPointerException("NARG");
			
			this._search = __s;
			this._cache = __c;
			
			// Seed suites left with the
			Queue<String> suites = this._suites;
			for (String s : SuiteAccess.currentClassPath())
				suites.add(s);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final boolean hasNext()
		{
			// If already finished, nothing can be done
			if (this._finished)
				return false;
			
			// Already cached?
			if (this._next != null)
				return true;
			
			Queue<String> suites = this._suites;
			Queue<String> classes = this._classes;
			
			// Loops until an element was found
			for (;;)
			{
				// If there is an entry in the class list, try to load that
				// class
				String maybe = classes.poll();
				if (maybe != null)
				{
					// Try to load this class
					try
					{
						// If this fails an exception is thrown
						Class<?> cl = Class.forName(maybe);
						
						// Try to create a new instance since this is new,
						// any exceptions thrown cause errors
						Object rv = cl.newInstance();
						
						// Cache this instance for later
						this._cachebuild.add(rv);
						
						// Cast this class
						this._next = this._search.cast(rv);
						return true;
					}
					
					// {@squirreljme.error ZZ30 Could not load the service
					// class.}
					catch (ClassCastException|IllegalAccessException|
						InstantiationException|ClassNotFoundException e)
					{
						throw new ServiceConfigurationError("ZZ30", e);
					}
				}
				
				// Nothing is in the classes, so we need to pull a suite
				// resource
				String pull = suites.poll();
				if (pull == null)
				{
					// Mark as finished
					this._finished = true;
					
					// Store in the cache for later since it is all done
					// now
					List<Object> cb = this._cachebuild;
					this._cache._cache = cb.<Object>toArray(
						new Object[cb.size()]);
					
					// Clear from this iterator
					cb.clear();
					
					// Nothing else to do
					return false;
				}
				
				// Could services list
				else
				{
					// Load resources
					try (InputStream in = ResourceInputStream.open(pull,
						"META-INF/services/" + this._search.getName()))
					{
						// Ignore unknown resources
						if (in == null)
							continue;
						
						// Read by line
						Set<String> pushy = new LinkedHashSet<>();
						try (BufferedReader br = new BufferedReader(
							new InputStreamReader(in, "utf-8")))
						{
							for (;;)
							{
								// Stop on EOF
								String ln = br.readLine();
								if (ln == null)
									break;
								
								// Trim the line
								ln = ln.trim();
								
								// Ignore blank lines
								if (ln.isEmpty())
									continue;
								
								// Ignore comments
								if (ln.startsWith("#"))
									continue;
								
								// Add otherwise
								pushy.add(ln);
							}
						}
						
						// Add unique entries
						for (String ln : pushy)
							classes.add(ln);
					}
					
					// {@squirreljme.error ZZ31 Could not read the services
					// list}
					catch (IOException e)
					{
						throw new ServiceConfigurationError("ZZ31", e);
					}
				}
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final S next()
		{
			// Cache
			if (!this.hasNext())
				throw new NoSuchElementException("NSEE");
			
			// Return the cached element
			S rv = this._next;
			this._next = null;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/Set.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public interface Set<E>
	extends Collection<E>
{
	@Override
	public abstract boolean add(E __a);
	
	@Override
	public abstract boolean addAll(Collection<? extends E> __a);
	
	@Override
	public abstract void clear();
	
	@Override
	public abstract boolean contains(Object __a);
	
	@Override
	public abstract boolean containsAll(Collection<?> __a);
	
	@Override
	public abstract boolean equals(Object __a);
	
	@Override
	public abstract int hashCode();
	
	@Override
	public abstract boolean isEmpty();
	
	@Override
	public abstract Iterator<E> iterator();
	
	@Override
	public abstract boolean remove(Object __a);
	
	@Override
	public abstract boolean removeAll(Collection<?> __a);
	
	@Override
	public abstract boolean retainAll(Collection<?> __a);
	
	@Override
	public abstract int size();
	
	@Override
	public abstract Object[] toArray();
	
	@Override
	public abstract <T> T[] toArray(T[] __a);
}


Deleted runt/apis/cldc-compact/java/util/Stack.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * This is a last-in-first-out, this uses {@link Vector} as a base and provides
 * operations for pushing and popping.
 *
 * It is recommended to use {@link LinkedList} or {@link ArrayDeque} as they
 * are newer classes.
 *
 * @since 2019/05/08
 */
public class Stack<E>
	extends Vector<E>
{
	public boolean empty()
	{
		throw new todo.TODO();
	}
	
	public E peek()
	{
		throw new todo.TODO();
	}
	
	public E pop()
	{
		throw new todo.TODO();
	}
	
	public E push(E __item)
	{
		throw new todo.TODO();
	}
	
	public int search(Object __o)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/StringTokenizer.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public class StringTokenizer
	implements Enumeration<Object>
{
	public StringTokenizer(String __a, String __b, boolean __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public StringTokenizer(String __a, String __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public StringTokenizer(String __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public int countTokens()
	{
		throw new todo.TODO();
	}
	
	public boolean hasMoreElements()
	{
		throw new todo.TODO();
	}
	
	public boolean hasMoreTokens()
	{
		throw new todo.TODO();
	}
	
	public Object nextElement()
	{
		throw new todo.TODO();
	}
	
	public String nextToken()
	{
		throw new todo.TODO();
	}
	
	public String nextToken(String __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/TimeZone.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

public abstract class TimeZone
	implements Cloneable
{
	public static final int LONG =
		1;
	
	public static final int SHORT =
		0;
	
	public TimeZone()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract int getOffset(int __a, int __b, int __c, int __d, int __e
		, int __f);
	
	public abstract int getRawOffset();
	
	public abstract boolean inDaylightTime(Date __a);
	
	public abstract void setRawOffset(int __a);
	
	public abstract boolean useDaylightTime();
	
	@Override
	public Object clone()
	{
		throw new todo.TODO();
	}
	
	public int getDSTSavings()
	{
		throw new todo.TODO();
	}
	
	public final String getDisplayName()
	{
		throw new todo.TODO();
	}
	
	public final String getDisplayName(boolean __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public String getID()
	{
		throw new todo.TODO();
	}
	
	public int getOffset(long __a)
	{
		throw new todo.TODO();
	}
	
	public boolean hasSameRules(TimeZone __a)
	{
		throw new todo.TODO();
	}
	
	public void setID(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] getAvailableIDs(int __a)
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static String[] getAvailableIDs()
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static TimeZone getDefault()
	{
		throw new todo.TODO();
	}
	
	public static TimeZone getTimeZone(String __a)
	{
		synchronized (TimeZone.class)
		{
			throw new todo.TODO();
		}
	}
	
	public static void setDefault(TimeZone __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/Timer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222






























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * The timer class is used to schedule events for the future which may
 * repeatedly happen or may happen once.
 *
 * This class is thread safe and multiple threads may interact with this
 * class.
 *
 * This class is not real-time and offers no gaurantee that tasks will execute
 * on time.
 *
 * All instances of this class create a background thread.
 *
 * @since 2018/12/11
 */
public class Timer
{
	/** The thread which runs the task of running things. */
	final __TimerThread__ _thread;
	
	/**
	 * Initializes a timer.
	 *
	 * @since 2018/12/11
	 */
	public Timer()
	{
		this("TimerThread");
	}
	
	/**
	 * Initializes a timer with a thread using the given name.
	 *
	 * @param __s The name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public Timer(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Setup thread and start it
		__TimerThread__ thread;
		this._thread = (thread = new __TimerThread__(__s));
		thread.start();
	}
	
	/**
	 * Cancels the timer and all of its events.
	 *
	 * @since 2018/12/11
	 */
	public void cancel()
	{
		__TimerThread__ thread = this._thread;
		synchronized (thread)
		{
			// Cancel and interrupt the thread so it checks and wakes up
			if (!thread._cancel)
			{
				thread._cancel = true;
				thread.interrupt();
			}
		}
	}
	
	/**
	 * Purges all of the cancelled tasks so that they become garbage collected.
	 *
	 * @since 2018/12/11
	 */
	public void purge()
	{
		// Lock to prevent adds
		__TimerThread__ thread = this._thread;
		synchronized (thread)
		{
			// Remove every task which has been cancelled
			for (Iterator<TimerTask> it = thread._tasks.iterator();
				it.hasNext();)
				if (it.next()._cancel)
					it.remove();
		}
	}
	
	/**
	 * Schedules a task to run once at the given time.
	 *
	 * @param __task The task to run.
	 * @param __time The time when the task should run.
	 * @throws IllegalArgumentException If the date is negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, Date __time)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __time, false, false, 0);
	}
	
	/**
	 * Schedules a task to run multiple times starting at the given date and
	 * executing every period.
	 *
	 * @param __task The task to run.
	 * @param __time The time when the task should run.
	 * @param __period The duration of time between each invocation.
	 * @throws IllegalArgumentException If the date is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, Date __time, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __time, true, false, __period);
	}
	
	/**
	 * Schedules a task to run once at the given time.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @throws IllegalArgumentException If the delay is negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, long __delay)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, false, false, 0);
	}
	
	/**
	 * Schedules a task to run once at the given time repeating for the given
	 * period.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @param __period The delay before each subsequence execution.
	 * @throws IllegalArgumentException If the delay is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void schedule(TimerTask __task, long __delay, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, true, false, __period);
	}
	
	/**
	 * Schedules a task to run multiple times starting at the given date and
	 * executing every period, the tasks are scheduled again at the start of
	 * each execution rather than the end.
	 *
	 * @param __task The task to run.
	 * @param __time The time when the task should run.
	 * @param __period The duration of time between each invocation.
	 * @throws IllegalArgumentException If the date is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void scheduleAtFixedRate(TimerTask __task, Date __first,
		long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __first, true, true, __period);
	}
	
	/**
	 * Schedules a task to run once at the given time repeating for the given
	 * period, execution is scheduled from the start of execution.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before this task runs.
	 * @param __period The delay before each subsequence execution.
	 * @throws IllegalArgumentException If the delay is negative or the period
	 * is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	public void scheduleAtFixedRate(TimerTask __task, long __delay,
		long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		this._thread.__schedule(__task, __delay, true, true, __period);
	}
}

Deleted runt/apis/cldc-compact/java/util/TimerTask.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a tasks which can be run within a timer.
 *
 * @since 2018/12/11
 */
public abstract class TimerTask
	implements Runnable
{
	/** Indicates the task has been cancelled. */
	volatile boolean _cancel;
	
	/** The scheduled time for the task, undefined at first. */
	volatile long _schedtime =
		Long.MIN_VALUE;
	
	/** The last run time. */
	volatile long _lastrun =
		Long.MIN_VALUE;
	
	/** Is this being run? */
	volatile boolean _inrun;
	
	/** Was this scheduled? */
	volatile boolean _scheduled;
	
	/** Is this a repeated execution? */
	volatile boolean _repeated;
	
	/** Fixed repeat? */
	volatile boolean _fixed;
	
	/** The period. */
	volatile long _period;
	
	/**
	 * Initializes the base timer task.
	 *
	 * @since 2018/12/11
	 */
	protected TimerTask()
	{
	}
	
	/**
	 * Cancels this task so that it no longer runs.
	 *
	 * @return This will return true if a future execution was canceled.
	 * @since 2018/12/11
	 */
	public boolean cancel()
	{
		// Was already canceled
		if (this._cancel)
			return false;
		
		this._cancel = true;
		return this._repeated || this._scheduled;
	}
	
	/**
	 * Returns the scheduled execution time.
	 *
	 * If this task has not been scheduled, this value is undefined.
	 *
	 * @return The scheduled execution time.
	 * @since 2018/12/11
	 */
	public long scheduledExcutionTime()
	{
		if (this._inrun)
			return this._lastrun;
		return this._schedtime;
	}
}

Deleted runt/apis/cldc-compact/java/util/Vector.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669





























































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import cc.squirreljme.runtime.cldc.util.IteratorToEnumeration;
import cc.squirreljme.runtime.cldc.util.SynchronizedIterator;

/**
 * This is similar to {@link ArrayList} except that it is synchronized and
 * thread-safe by default.
 *
 * @see ArrayList
 * @since 2019/05/13
 */
public class Vector<E>
	extends AbstractList<E>
	implements RandomAccess, Cloneable
{
	/** The number of elements to add if the size is too small. */
	protected int capacityIncrement;
	
	/** The number of elements in the vector. */
	protected int elementCount;
	
	/** The elements in the vector. */
	protected Object[] elementData;
	
	/**
	 * Initializes the vector using the specified initial capacity.
	 *
	 * @param __cap The initial capacity.
	 * @param __inc The capacity increment.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/13
	 */
	public Vector(int __cap, int __inc)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ32 Initial capacity cannot be negative.
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ32");
		
		this.elementData = new Object[__cap];
		this.capacityIncrement = (__inc < 0 ? 0 : __inc);
	}
	
	/**
	 * Initializes the vector using the specified initial capacity.
	 *
	 * @param __cap The initial capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2019/05/13
	 */
	public Vector(int __cap)
		throws IllegalArgumentException
	{
		this(__cap, 0);
	}
	
	/**
	 * Initializes the vector.
	 *
	 * @since 2019/05/13
	 */
	public Vector()
	{
		this(10, 0);
	}
	
	public Vector(Collection<? extends E> __a)
	{
		super();
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public void add(int __i, E __v)
	{
		synchronized (this)
		{
			int size = this.elementCount;
			if (__i < 0 || __i > size)
				throw new IndexOutOfBoundsException("IOOB");
			
			Object[] elements = this.elementData;
			int cap = elements.length,
				nextsize = size + 1;
			
			// Cannot fit in this array
			Object[] source = elements;
			if (nextsize > cap)
			{
				// Grow the list by a bit
				int newcap = nextsize + Math.max(1, this.capacityIncrement);
				elements = new Object[newcap];
				
				// Copy old stuff over, but only up to the index as needed
				for (int i = 0; i < __i; i++)
					elements[i] = source[i];
			}
			
			// Move down to fit
			for (int i = size - 1, o = size; o > __i; i--, o--)
				elements[o] = source[i];
			
			// Store data here
			elements[__i] = __v;
			
			// Store new information
			this.elementCount = nextsize;
			if (elements != source)
				this.elementData = elements;
			
			// Structurally modified
			this.modCount++;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public boolean addAll(Collection<? extends E> __c)
	{
		synchronized (this)
		{
			return super.addAll(__c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public boolean addAll(int __i, Collection<? extends E> __c)
	{
		synchronized (this)
		{
			return super.addAll(__i, __c);
		}
	}
	
	/**
	 * Adds an element to the end of the vector.
	 *
	 * @param __v The element to add.
	 * @since 2019/05/14
	 */
	public void addElement(E __v)
	{
		synchronized (this)
		{
			this.add(__v);
		}
	}
	
	public int capacity()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public void clear()
	{
		synchronized (this)
		{
			// Wipe the length
			this.elementCount = 0;
			
			// And wipe the array
			Object[] elements = this.elementData;
			for (int i = 0, n = elements.length; i < n; i++)
				elements[i] = null;
		}
	}
	
	@Override
	public Object clone()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	@Override
	public boolean contains(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsAll(Collection<?> __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Copies this vector to the given array.
	 *
	 * @param __a The target array.
	 * @throws ArrayStoreException If the array cannot store the vector
	 * values.
	 * @throws IndexOutOfBoundsException If the array is too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/24
	 */
	public void copyInto(Object[] __a)
		throws ArrayStoreException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// {@squirreljme.error ZZ3q The destination array is too small.}
			int n = this.elementCount;
			if (n > __a.length)
				throw new IndexOutOfBoundsException("ZZ3q");
			
			// Copy into
			Object[] elements = this.elementData;
			for (int i = 0; i < n; i++)
				__a[i] = elements[i];
		}
	}
	
	/**
	 * Returns the element at the given index.
	 *
	 * @param __i The element index.
	 * @return The element.
	 * @since 2019/05/14
	 */
	public E elementAt(int __i)
	{
		synchronized (this)
		{
			return this.get(__i);
		}
	}
	
	/**
	 * Returns an enumeration over the elements.
	 *
	 * @return The element enumeration.
	 * @since 2019/05/14
	 */
	public Enumeration<E> elements()
	{
		return new IteratorToEnumeration<E>(this.iterator());
	}
	
	/**
	 * Ensures that the vector can store the given number of elements.
	 *
	 * @param __n The element capacity.
	 * @since 2019/05/14
	 */
	public void ensureCapacity(int __n)
	{
		synchronized (this)
		{
			// Pointless
			if (__n <= 0)
				return;
			
			// Meets or exceeds the desired capacity?
			Object[] elements = this.elementData;
			int nowl = elements.length;
			if (__n <= nowl)
				return;
			
			// Copy values over
			Object[] extra = new Object[__n];
			for (int i = 0; i < nowl; i++)
				extra[i] = elements[i];
			
			// Set
			this.elementData = extra;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean equals(Object __o)
	{
		synchronized (this)
		{
			return super.equals(__o);
		}
	}
	
	/**
	 * Returns the first element in the vector.
	 *
	 * @return The first element.
	 * @throws NoSuchElementException If the vector is empty.
	 * @since 2019/05/14
	 */
	@SuppressWarnings({"unchecked"})
	public E firstElement()
		throws NoSuchElementException
	{
		synchronized (this)
		{
			if (this.elementCount <= 0)
				throw new NoSuchElementException("NSEE");
			
			return (E)this.elementData[0];
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E get(int __i)
	{
		synchronized (this)
		{
			if (__i < 0 || __i >= this.elementCount)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			return (E)this.elementData[__i];
		}
	}
	
	@Override
	public int hashCode()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public int indexOf(Object __v)
	{
		synchronized (this)
		{
			return super.indexOf(__v);
		}
	}
	
	public int indexOf(Object __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public void insertElementAt(E __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	public Iterator<E> iterator()
	{
		synchronized (this)
		{
			return new SynchronizedIterator<E>(this, super.iterator());
		}
	}
	
	public E lastElement()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	@Override
	public int lastIndexOf(Object __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public int lastIndexOf(Object __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean remove(Object __v)
	{
		synchronized (this)
		{
			return super.remove(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E remove(int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			// Out of bounds?
			int size = this.elementCount;
			if (__i < 0 || __i >= size)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			// Get the old element first
			Object[] elements = this.elementData;
			Object rv = elements[__i];
			
			// Copy all of the elements down
			for (int o = __i, i = __i + 1; i < size; o++, i++)
				elements[o] = elements[i];
			elements[size - 1] = null;
			
			// Set new size
			this.elementCount = size - 1;
			
			// And the old element
			return (E)rv;
		}
	}
	
	@Override
	public boolean removeAll(Collection<?> __a)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Removes all elements in the vector.
	 *
	 * @since 2019/05/14
	 */
	public void removeAllElements()
	{
		synchronized (this)
		{
			this.clear();
		}
	}
	
	/**
	 * Removes the given value from the list.
	 *
	 * @param __v The value to remove.
	 * @return If it was removed.
	 * @since 2019/05/19
	 */
	public boolean removeElement(Object __v)
	{
		synchronized (this)
		{
			return this.remove(__v);
		}
	}
	
	/**
	 * Removes the element at the given index.
	 *
	 * @param __i The index to remove.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/19
	 */
	public void removeElementAt(int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			this.remove(__i);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	protected void removeRange(int __a, int __b)
	{
		synchronized (this)
		{
			super.removeRange(__a, __b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public boolean retainAll(Collection<?> __c)
	{
		synchronized (this)
		{
			return super.retainAll(__c);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public E set(int __i, E __v)
	{
		synchronized (this)
		{
			// Out of bounds?
			int size = this.elementCount;
			if (__i < 0 || __i >= size)
				throw new ArrayIndexOutOfBoundsException("IOOB");
			
			// Read old value
			Object[] elements = this.elementData;
			E rv = (E)elements[__i];
			
			// Set new value
			elements[__i] = __v;
			
			// Return old
			return rv;
		}
	}
	
	/**
	 * Sets the element at the given index, note that compared to
	 * {@link #set(int, E)} the parameters are reversed.
	 *
	 * @param __v The value to set.
	 * @param __i The index to set.
	 * @throws ArrayIndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/14
	 */
	public void setElementAt(E __v, int __i)
		throws ArrayIndexOutOfBoundsException
	{
		synchronized (this)
		{
			this.set(__i, __v);
		}
	}
	
	/**
	 * Sets the size of this vector so that it has the given number of
	 * elements.
	 *
	 * @param __n The number of elements the vector should be.
	 * @throws ArrayIndexOutOfBoundsException If the size is negative.
	 * @since 2019/05/14
	 */
	public void setSize(int __n)
		throws ArrayIndexOutOfBoundsException
	{
		if (__n < 0)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		synchronized (this)
		{
			// Ensure elements can fit first
			this.ensureCapacity(__n);
			
			// Null out any extra elements
			int count = this.elementCount;
			Object[] elements = this.elementData;
			for (int i = count; i < __n; i++)
				elements[i] = null;
			
			// Set new count
			this.elementCount = __n;
			
			// Modified
			this.modCount++;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public int size()
	{
		synchronized (this)
		{
			return this.elementCount;
		}
	}
	
	@Override
	public List<E> subList(int __a, int __b)
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
	
	public void trimToSize()
	{
		synchronized (this)
		{
			throw new todo.TODO();
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/WeakHashMap.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
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























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

public class WeakHashMap<K, V>
	extends AbstractMap<K, V>
	implements Map<K, V>
{
	/** The default capacity. */
	private static final int _DEFAULT_CAPACITY =
		16;
	
	/** The default load factor. */
	private static final float _DEFAULT_LOAD =
		0.75F;
	
	/** The load factor. */
	private final float _load;
	
	/** This is used to clear keys when they are collected. */
	private final ReferenceQueue<K> _rq =
		new ReferenceQueue<>();
	
	/**
	 * Initializes the weak hash map with the given initial capacity and load
	 * factor.
	 *
	 * @param __icap The initial capacity.
	 * @param __load The initial load factor.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2016/04/19
	 */
	public WeakHashMap(int __icap, float __load)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ33 The initial capacity of the weak
		// hash map is negative. (The negative initial capacity)}
		if (__icap < 0)
			throw new IllegalArgumentException(String.format("ZZ33 %d",
				__icap));
		
		// {@squirreljme.error ZZ34 The load factor of the weak hash map is
		// not positive. (The non-positive load factor)}
		if (__load <= 0.0F)
			throw new IllegalArgumentException(String.format("ZZ34 %f",
				__load));
		
		// Setup
		_load = __load;
	}
	
	/**
	 * Initializes the weak hash map with the given initial capacity.
	 *
	 * @param __icap The initial weak hash map capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2016/04/19
	 */
	public WeakHashMap(int __icap)
		throws IllegalArgumentException
	{
		this(__icap, _DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the weak hash map with the default initial capacity and load
	 * factor.
	 *
	 * @since 2016/04/19
	 */
	public WeakHashMap()
	{
		this(_DEFAULT_CAPACITY, _DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the weak hash map with the default initial capacity and load
	 * factor and then copies the keys and values of the given map to this one.
	 *
	 * @param __a The map to source entries from.
	 * @throws NullPointerException If no map was specified.
	 * @since 2016/04/19
	 */
	public WeakHashMap(Map<? extends K, ? extends V> __a)
	{
		// {@squirreljme.error ZZ35 No map to copy data from was specified.}
		if (__a == null)
			throw new NullPointerException("ZZ35");
		
		// Setup initial map
		_load = _DEFAULT_LOAD;
		
		// Add all entries to it
		for (Map.Entry<? extends K, ? extends V> e : __a.entrySet())
			put(e.getKey(), e.getValue());
	}
	
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsKey(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean containsValue(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		throw new todo.TODO();
	}
	
	@Override
	public V get(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Set<K> keySet()
	{
		throw new todo.TODO();
	}
	
	@Override
	public V put(K __a, V __b)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void putAll(Map<? extends K, ? extends V> __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public V remove(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public int size()
	{
		throw new todo.TODO();
	}
	
	@Override
	public Collection<V> values()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/__AbstractListListIterator__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238














































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * List iterator which can go forwards and backwards through this abstract
 * list. Indexed elements are used here, not sequential lists.
 *
 * @param <E> The element type.
 * @since 2018/10/28
 */
final class __AbstractListListIterator__<E>
	implements ListIterator<E>
{
	/** The owning list. */
	protected final AbstractList<E> owner;
	
	/** The next element to be returned. */
	private int _next;
	
	/** The current modification count, to detect modifications. */
	private int _atmod;
	
	/** The index to be removed. */
	private int _rmdx =
		-1;
	
	/**
	 * Initializes the list iterator.
	 *
	 * @param __owner The owner of this list.
	 * @param __i The index to use.
	 * @throws IndexOutOfBoundsException If the index is outside the list
	 * bounds.
	 * @since 2018/10/28
	 */
	__AbstractListListIterator__(AbstractList<E> __owner, int __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__owner == null)
			throw new NullPointerException("NARG");
		
		if (__i < 0 || __i > __owner.size())
			throw new IndexOutOfBoundsException("IOOB");
		
		this.owner = __owner;
		this._next = __i;
		this._atmod = __owner.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void add(E __a)
	{
		// Check modification
		this.__checkConcurrent();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final boolean hasNext()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There are elements as long as the next one is below the size
		return this._next < this.owner.size();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final boolean hasPrevious()
	{
		// Check modification
		this.__checkConcurrent();
		
		// As long as this is not the first element there will be
		// previous ones
		return this._next > 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E next()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// End of list?
		int next = this._next;
		if (this._next >= this.owner.size())
			throw new NoSuchElementException("NSEE");
		
		// Get this element
		E rv = this.owner.get(next);
		
		// Next one is after this, also the element to be removed is set
		// by this method
		this._rmdx = next;
		this._next = next + 1;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int nextIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		return this._next;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E previous()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// End of list?
		int next = this._next;
		if (this._next <= 0)
			throw new NoSuchElementException("NSEE");
		
		// Get this element
		int eldx = next - 1;
		E rv = this.owner.get(eldx);
		
		// The element to remove is the one we just got and the next one
		// is one down the list
		this._rmdx = eldx;
		this._next = eldx;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final int previousIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// If next is zero then this would be -1
		return this._next - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void remove()
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2c No previously returned element was
		// iterated, it was already removed, or an element was added.}
		int rmdx = this._rmdx;
		if (rmdx < 0)
			throw new IllegalStateException("ZZ2c");
		
		// Remove this index
		this._rmdx = -1;
		this.owner.remove(rmdx);
		
		// Next element would be moved down
		int next = this._next;
		if (next > rmdx)
			this._next = next - 1;
		
		// Set new modification count
		this._atmod = this.owner.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final void set(E __v)
	{
		// Check modification
		this.__checkConcurrent();
		
		throw new todo.TODO();
	}
	
	/**
	 * Checks if the list was concurrently modified.
	 *
	 * @throws ConcurrentModificationException If it was modified.
	 * @since 2018/10/29
	 */
	private final void __checkConcurrent()
		throws ConcurrentModificationException
	{
		// {@squirreljme.error ZZ2d List has been concurrently modified.}
		if (this._atmod != this.owner.modCount)
			throw new ConcurrentModificationException("ZZ2d");
	}
}

Deleted runt/apis/cldc-compact/java/util/__AbstractListSubList__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * This is a sub-list of an abstract list
 *
 * @param <E> The type of value being stored
 * @since 2019/11/30
 */
final class __AbstractListSubList__<E>
	extends AbstractList<E>
{
	/**
	 * Initializes the abstract sub-list.
	 *
	 * @param __list The list to wrap.
	 * @param __from The index to start from.
	 * @param __to The index to end at.
	 * @throws IllegalArgumentException If the end point is before the start.
	 * @throws IndexOutOfBoundsException If the from is negative or the to
	 * exceeds the list size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	__AbstractListSubList__(AbstractList<E> __list, int __from, int __to)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__list == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3r End point is before starting point.}
		if (__from > __to)
			throw new IllegalArgumentException("ZZ3r");
		
		// Check bounds
		int size = this.size();
		if (__from < 0 || __to > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
	
	@Override
	public final void add(int __a, E __b)
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E get(int __i)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E set(int __i, E __v)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	@Override
	public final E remove(int __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/__AbstractMapKeySet__.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is the key set for an abstract map.
 *
 * @param <K> The key type.
 * @param <V> The value stored.
 * @since 2018/10/10
 */
final class __AbstractMapKeySet__<K, V>
	extends AbstractSet<K>
{
	/** The backing map. */
	protected final Map<K, V> map;
	
	/**
	 * Initializes the set.
	 *
	 * @param __map The backing map
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/01
	 */
	__AbstractMapKeySet__(Map<K, V> __map)
		throws NullPointerException
	{
		if (__map == null)
			throw new NullPointerException("NARG");
		
		this.map = __map;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final boolean contains(Object __o)
	{
		return this.map.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public final Iterator<K> iterator()
	{
		return new __Iterator__<K, V>(this.map.entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/10
	 */
	@Override
	public final int size()
	{
		return this.map.size();
	}
	
	/**
	 * This is the iterator over the map's key set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2018/11/01
	 */
	static final class __Iterator__<K, V>
		implements Iterator<K>
	{
		/** The entry set iterator. */
		protected final Iterator<Map.Entry<K, V>> iterator;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __it The backing iterator.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/01
		 */
		__Iterator__(Iterator<Map.Entry<K, V>> __it)
			throws NullPointerException
		{
			if (__it == null)
				throw new NullPointerException("NARG");
			
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public K next()
			throws NoSuchElementException
		{
			return this.iterator.next().getKey();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public void remove()
		{
			this.iterator.remove();
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__AbstractMapValues__.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is the value set for an abstract map.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/29
 */
final class __AbstractMapValues__<K, V>
	extends AbstractCollection<V>
{
	/** The backing map. */
	protected final Map<K, V> map;
	
	/**
	 * Initializes the set.
	 *
	 * @param __map The backing map
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/01
	 */
	__AbstractMapValues__(Map<K, V> __map)
		throws NullPointerException
	{
		if (__map == null)
			throw new NullPointerException("NARG");
		
		this.map = __map;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final boolean contains(Object __o)
	{
		return this.map.containsValue(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/19
	 */
	@Override
	public final Iterator<V> iterator()
	{
		return new __Iterator__<K, V>(this.map.entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/19
	 */
	@Override
	public final int size()
	{
		return this.map.size();
	}
	
	/**
	 * This is the iterator over the map's value set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2018/11/01
	 */
	static final class __Iterator__<K, V>
		implements Iterator<V>
	{
		/** The entry set iterator. */
		protected final Iterator<Map.Entry<K, V>> iterator;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __it The backing iterator.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/01
		 */
		__Iterator__(Iterator<Map.Entry<K, V>> __it)
			throws NullPointerException
		{
			if (__it == null)
				throw new NullPointerException("NARG");
			
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public V next()
			throws NoSuchElementException
		{
			return this.iterator.next().getValue();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public void remove()
		{
			this.iterator.remove();
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__ArraysList__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This wraps the given array as a list for {@link Arrays#asList(Object[])}.
 *
 * @since 2016/08/31
 */
final class __ArraysList__<T>
	extends AbstractList<T>
	implements RandomAccess
{
	/** The array length. */
	protected final int length;
	
	/** The wrapped array. */
	private final T[] _wrapped;
	
	/**
	 * Initializes the wrapped array.
	 *
	 * @param __v The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/31
	 */
	__ArraysList__(T[] __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._wrapped = __v;
		this.length = __v.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public T get(int __i)
	{
		return this._wrapped[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public T set(int __i, T __v)
	{
		T[] wrapped = this._wrapped;
		T rv = wrapped[__i];
		wrapped[__i] = __v;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/31
	 */
	@Override
	public int size()
	{
		return this.length;
	}
}

Deleted runt/apis/cldc-compact/java/util/__BlockSort__.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This class provides the block sort algorithm used to sort items.
 *
 * https://en.wikipedia.org/wiki/Block_sort
 *
 * @since 2018/10/26
 */
final class __BlockSort__
{
	/**
	 * Sorts the given list using block sort.
	 *
	 * @param <T> The type to use.
	 * @param __a The list to sort.
	 * @param __from From index.
	 * @param __to To index.
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/16
	 */
	public static <T> void sort(List<T> __a, int __from, int __to,
		Comparator<? super T> __comp)
		throws NullPointerException
	{
		if (__a == null || __comp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc-compact/java/util/__BucketMapEntry__.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a single entry within the bucket map.
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/07
 */
final class __BucketMapEntry__<K, V>
	implements Map.Entry<K, V>
{
	/** The key. */
	final K _key;
	
	/** The key hashcode. */
	final int _keyhash;
	
	/** The value here. */
	V _value;		
	
	/**
	 * Initializes the entry.
	 *
	 * @param __k The key.
	 * @since 2018/10/08
	 */
	__BucketMapEntry__(K __k)
	{
		this._key = __k;
		this._keyhash = (__k == null ? 0 : __k.hashCode());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Map.Entry))
			return false;
		
		Map.Entry<?, ?> o = (Map.Entry<?, ?>)__o;
		return Objects.equals(this._key, o.getKey()) &&
			Objects.equals(this._value, o.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final K getKey()
	{
		return this._key;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final V getValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final int hashCode()
	{
		V value = this._value;
		return this._keyhash ^ (value == null ? 0 : value.hashCode());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final V setValue(V __v)
	{
		V rv = this._value;
		this._value = __v;
		return rv;
	}
}

Deleted runt/apis/cldc-compact/java/util/__BucketMap__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828




























































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a bucket map which acts as the raw internal hash table
 * implementation.
 *
 * @see HashMap
 * @see HashSet
 * @see LinkedHashMap
 * @see LinkedHashSet
 * @param <K> The key type.
 * @param <V> The value type.
 * @since 2018/10/07
 */
final class __BucketMap__<K, V>
	extends AbstractMap<K, V>
{
	/** Special holder for when backing for a set. */
	static final Object _TAKEN =
		new Object();
	
	/** The default capacity. */
	static final int _DEFAULT_CAPACITY =
		16;
	
	/** The default load factor. */
	static final float _DEFAULT_LOAD =
		0.75F;
	
	/** Is this bucket map ordered? */
	protected final boolean ordered;
	
	/** Is this bucket map in accessed order? */
	protected final boolean accessorder;
	
	/** Track put order? */
	protected final boolean trackputorder;
	
	/** The load factor. */
	protected final float loadfactor;
	
	/** Linked order of entries. */
	final LinkedList<__BucketMapEntry__<K, V>> _links;
	
	/** The entry chains for each element. */
	__BucketMapEntry__<K, V>[][] _buckets;
	
	/** The hashcode divisor for buckets. */
	int _bucketdiv;
	
	/** The number of elements in the map. */
	int _size;
	
	/** The current capacity. */
	int _capacity;
	
	/** The size threshold before a rebuild is done. */
	int _loadthreshold;
	
	/** Modification count. */
	int _modcount;
	
	/** The rehash count. */
	int _numrehash;
	
	/**
	 * Initializes the map with the default capacity and load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o)
	{
		this(__o, false, __BucketMap__._DEFAULT_CAPACITY,
			__BucketMap__._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the map with the given capacity and the default load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @param __cap The capacity used.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o, int __cap)
	{
		this(__o, false, __cap, __BucketMap__._DEFAULT_LOAD);
	}
	
	/**
	 * Initializes the map with the given capacity and load factor.
	 *
	 * @param __o Is the backing iterator ordered?
	 * @param __ao Is access order used additionally?
	 * @param __cap The capacity used.
	 * @param __load The load factor used.
	 * @throws IllegalArgumentException If the capacity is negative or the
	 * load factor is not positive.
	 * @since 2018/10/07
	 */
	__BucketMap__(boolean __o, boolean __ao, int __cap, float __load)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ36 The initial capacity of the map cannot be
		// negative.}
		if (__cap < 0)
			throw new IllegalArgumentException("ZZ36");
		
		// {@squirreljme.error ZZ37 The load factor must be a positive value.}
		if (__load <= 0.0F)
			throw new IllegalArgumentException("ZZ37");
		
		this.ordered = __o;
		this.accessorder = (__ao = (__o && __ao));
		this.trackputorder = (__o && !__ao);
		this.loadfactor = __load;
		this._buckets = __BucketMap__.<K, V>__newBucket(__cap);
		this._bucketdiv = __cap;
		this._capacity = __cap;
		this._loadthreshold = (int)(__cap * __load);
		
		// Set linked list for ordered storage if it is used
		this._links = ((__o || __ao) ?
			new LinkedList<__BucketMapEntry__<K, V>>() : null);
	}
	
	/**
	 * Gets the entry for the given key.
	 *
	 * @param __k The key to get.
	 * @return The entry for the given or {@code null} if none exists.
	 * @since 2018/10/08
	 */
	public final __BucketMapEntry__<K, V> getEntry(Object __k)
	{
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % this._bucketdiv;
		
		// If the chain does not exist then do not bother at all
		__BucketMapEntry__<K, V>[] chain = this._buckets[div];
		if (chain == null)
			return null;
		
		// Go through the chain and find the matching entry
		for (__BucketMapEntry__<K, V> e : chain)
		{
			// Ignore blank entries
			if (e == null)
				continue;
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found
			if (Objects.equals(e._key, __k))
			{
				// In access order?
				if (this.accessorder)
					throw new todo.TODO();	
				
				return e;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/01
	 */
	@Override
	public final Set<Map.Entry<K, V>> entrySet()
	{
		return new __EntrySet__();
	}
	
	/**
	 * Returns the chain that the hashed object is within for the bucket.
	 *
	 * @param __k The key.
	 * @return The key for the given entry.
	 * @since 2018/10/07
	 */
	public final __BucketMapEntry__<K, V> putEntry(K __k)
	{
		__BucketMapEntry__<K, V>[][] buckets = this._buckets;
		int bucketdiv = this._bucketdiv;
		
		// Used to determine if we rebuild
		int size = this._size,
			nextsize = size + 1;
		
		// Hypothetically putting a new entry could cause the threshold to be
		// hit, so just in this case a new entry would be put so rebuild
		// the hash table. The buckets need to remain the same object
		// references for iteration.
		if (nextsize >= this._loadthreshold)
		{
			// Increase rehash count
			this._numrehash++;
			
			// Double the number of buckets
			int newbucketdiv = (bucketdiv * 2);
			__BucketMapEntry__<K, V>[][] newbuckets =
				__BucketMap__.<K, V>__newBucket(newbucketdiv);
			
			// Go through every source bucket and redistribute entries
			for (int i = 0; i < bucketdiv; i++)
			{
				// Ignore empty chains
				__BucketMapEntry__<K, V>[] chain = buckets[i];
				if (chain == null)
					continue;
				
				// Go through chain and re-add entries, we do not need to
				// worry about object equality since if something is in the
				// map it is already unique!
				for (__BucketMapEntry__<K, V> e : chain)
				{
					// Was an entry which was removed, ignore
					if (e == null)
						continue;
					
					// Determine the new placement for it
					int hash = e._keyhash,
						div = (hash & 0x7FFF_FFFF) % newbucketdiv;
					
					// Get the new chain for it
					__BucketMapEntry__<K, V>[] newchain = newbuckets[div];
					if (newchain == null)
						newchain = __BucketMap__.<K, V>__newChain(1);
					else
					{
						// Need to setup new chain
						int cn = newchain.length;
						__BucketMapEntry__<K, V>[] newnewchain =
							__BucketMap__.<K, V>__newChain(cn + 1);
						
						// Copy all the old chain stuff over
						for (int j = 0; j < cn; j++)
							newnewchain[j] = newchain[j];
						
						// Use this chain
						newchain = newnewchain;
					}
					
					// Store entry in the last spot
					newchain[newchain.length - 1] = e;
					
					// New chain was created so update it naturally
					newbuckets[div] = newchain;
				}
			}
			
			// Map was modified, in case hashCode() fails!
			this._modcount++;
			
			// Store new data for later
			this._buckets = newbuckets;
			this._bucketdiv = newbucketdiv;
			this._capacity = newbucketdiv;
			this._loadthreshold = (int)(newbucketdiv * this.loadfactor);
			
			// Use these new properties and continue on
			buckets = newbuckets;
			bucketdiv = newbucketdiv;
		}
		
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % bucketdiv;
		
		// This will be set depending on the situation
		__BucketMapEntry__<K, V> rv;
		
		// No entries exist in the chain, we can just create one
		__BucketMapEntry__<K, V>[] chain = buckets[div];
		if (chain == null)
		{
			// Setup chain
			chain = __BucketMap__.<K, V>__newChain(1);
			buckets[div] = chain;
			
			// Fill
			chain[0] = (rv = new __BucketMapEntry__<K, V>(__k));
			
			// Add to order?
			if (this.trackputorder)
				this._links.add(rv);
			
			// Map is modified
			this._modcount++;
			
			// Size would have been increased at this point
			this._size = nextsize;
			
			return rv;
		}
		
		// Go through and find if there was a pre-existing item
		int nulldx = -1,
			n = chain.length;
		for (int i = 0; i < n; i++)
		{
			__BucketMapEntry__<K, V> e = chain[i];
			
			// If no entry is here remember this blank spot in the event
			// nothing is ever found
			if (e == null)
			{
				if (nulldx < 0)
					nulldx = i;
				continue;
			}
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found
			if (Objects.equals(__k, e._key))
				return e;
		}
		
		// Found a blank spot, we can just put the entry here
		if (nulldx >= 0)
			chain[nulldx] = (rv = new __BucketMapEntry__<K, V>(__k));
		
		// Otherwise, increase the chain and use that instead
		else
		{
			// Copy the old chain over
			__BucketMapEntry__<K, V>[] dup =
				__BucketMap__.<K, V>__newChain(n + 1);
			for (int i = 0; i < n; i++)
				dup[i] = chain[i];
			
			// Set at end
			dup[n] = (rv = new __BucketMapEntry__<K, V>(__k));
			
			// Use this chain again
			buckets[div] = dup;
		}
		
		// Map has been modified
		this._modcount++;
		
		// Add to order?
		if (this.trackputorder)
			this._links.add(rv);
		
		// Size would have been increased at this point
		this._size = nextsize;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public final V remove(Object __k)
	{
		__BucketMapEntry__<K, V> rv = this.removeEntry(__k, false);
		if (rv != null)
			return rv._value;
		return null;
	}
	
	/**
	 * Removes the specified key from this map.
	 *
	 * Note that because iterators need to keep the same order, the entries
	 * cannot be shuffled or the map rebuilt.
	 *
	 * @param __k The key to remove.
	 * @param __preunlinked If this is true then the link chain will not have
	 * the entry removed by this method, it is assumed it was already
	 * removed by an iterator.
	 * @return The removed map entry or {@code null} if one did not exist.
	 * @since 2018/11/04
	 */
	public final __BucketMapEntry__<K, V> removeEntry(Object __k,
		boolean __preunlinked)
	{
		// Where to look in the table?
		int hash = (__k == null ? 0 : __k.hashCode());
		int div = (hash & 0x7FFF_FFFF) % this._bucketdiv;
		
		// If the chain does not exist then do not bother at all
		__BucketMapEntry__<K, V>[] chain = this._buckets[div];
		if (chain == null)
			return null;
		
		// Go through the chain and find the matching entry
		for (int i = 0, n = chain.length; i < n; i++)
		{
			// Ignore blank entries
			__BucketMapEntry__<K, V> e = chain[i];
			if (e == null)
				continue;
			
			// Has the wrong hashcode
			if (hash != e._keyhash)
				continue;
			
			// If the objects actually match, it is found so it must be
			// removed
			if (Objects.equals(e._key, __k))
			{
				// Removing an entry from the chain is as simple as just
				// setting it to null. We do not need to move entries around
				// since that can be a bit slow
				chain[i] = null;
				
				// If this was not pre-unlinked from the iterator call then
				// it will be removed from the chain accordingly
				if (!__preunlinked)
				{
					Collection<__BucketMapEntry__<K, V>> links = this._links;
					if (links != null)
						links.remove(e);
				}	
				
				// Size goes down
				this._size--;
				
				// Map has been modified
				this._modcount++;
				
				// This entry was removed, so it gets returned by the map
				return e;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/08
	 */
	@Override
	public final int size()
	{
		return this._size;
	}
	
	/**
	 * Clears the bucket map.
	 *
	 * @since 2018/11/05
	 */
	final void __clear()
	{
		// Set all buckets to null so they are empty
		__BucketMapEntry__<K, V>[][] buckets = this._buckets;
		for (int i = 0, n = buckets.length; i < n; i++)
			buckets[i] = null;
		
		// Set size to zero
		this._size = 0;
		
		// Clear the linked list if there is one
		LinkedList<__BucketMapEntry__<K, V>> links = this._links;
		if (links != null)
			links.clear();
		
		// Modification count goes up
		this._modcount++;
	}
	
	/**
	 * Return the iterator over the map entries.
	 *
	 * @return The map iterator.
	 * @since 2018/11/01
	 */
	final Iterator<Map.Entry<K, V>> __iterator()
	{
		if (__BucketMap__.this.ordered)
			return new __IteratorLinkedOrder__();
		return new __IteratorBucketOrder__();
	}
	
	/**
	 * Creates a new bucket array.
	 *
	 * @param <K> Key type.
	 * @param <V> Value type.
	 * @param __n The length.
	 * @return The array.
	 * @since 2018/10/08
	 */
	@SuppressWarnings({"unchecked"})
	private static <K, V> __BucketMapEntry__<K, V>[][] __newBucket(int __n)
	{
		return (__BucketMapEntry__<K, V>[][])
			((Object)new __BucketMapEntry__[__n][]);
	}
	
	/**
	 * Creates a new chain array.
	 *
	 * @param <K> Key type.
	 * @param <V> Value type.
	 * @param __n The length.
	 * @return The array.
	 * @since 2018/10/08
	 */
	@SuppressWarnings({"unchecked"})
	private static <K, V> __BucketMapEntry__<K, V>[] __newChain(int __n)
	{
		return (__BucketMapEntry__<K, V>[])
			((Object)new __BucketMapEntry__[__n]);
	}
	
	/**
	 * Implements the entry set over the map, this iterates in a given order.
	 *
	 * @since 2018/11/01
	 */
	final class __EntrySet__
		extends AbstractSet<Map.Entry<K, V>>
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final void clear()
		{
			__BucketMap__.this.__clear();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final Iterator<Map.Entry<K, V>> iterator()
		{
			return __BucketMap__.this.__iterator();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final int size()
		{
			return __BucketMap__.this._size;
		}
	}
	
	/**
	 * Base iterator.
	 *
	 * @since 2018/11/01
	 */
	abstract class __IteratorBase__
		implements Iterator<Map.Entry<K, V>>
	{
		/** The mod init this iterator is at, to detect modifications. */
		int _atmod =
			__BucketMap__.this._modcount;
		
		/**
		 * Checks if the map's internal structure modification count has
		 * changed.
		 *
		 * @throws ConcurrentModificationException If the map was modified.
		 * @since 2018/10/13
		 */
		final void __checkModified()
			throws ConcurrentModificationException
		{
			// {@squirreljme.error ZZ38 Backing map has been modified.}
			if (this._atmod != __BucketMap__.this._modcount)
				throw new ConcurrentModificationException("ZZ38");
		}
	}
	
	/**
	 * Iterator over the entries in this map.
	 *
	 * @since 2018/10/13
	 */
	final class __IteratorBucketOrder__
		extends __IteratorBase__
	{
		/** The current bucket this is at. */
		int _bucketat;
		
		/** The current chain link this is at. */
		int _chainat;
		
		/** The cached next entry. */
		__BucketMapEntry__<K, V> _next;
		
		/** The last entry. */
		__BucketMapEntry__<K, V> _last;
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final boolean hasNext()
		{
			// Check modification
			this.__checkModified();
			
			// Already cached, do not need to check anything more
			if (this._next != null)
				return true;
			
			// No more buckets remain?
			int bucketat = this._bucketat,
				bucketdiv = __BucketMap__.this._bucketdiv;
			if (bucketat >= bucketdiv)
				return false;
			
			// Get the current chain
			__BucketMapEntry__<K, V>[][] buckets = __BucketMap__.this._buckets;
			
			// We can store the current location parameters at the end rather
			// than every time (keeps everything in locals)
			int chainat = this._chainat;
			try
			{
				// We might try looking at the next bucket if we reach the end
				// of this chain.
				for (;;)
				{
					__BucketMapEntry__<K, V>[] chain = buckets[bucketat];
					
					// No more chain links remain? Or there is no chain?
					int chaindiv = (chain == null ? -1 : chain.length);
					if (chainat >= chaindiv)
					{
						// Reset to start of next bucket
						bucketat++;
						chainat = 0;
						
						// No more buckets to look in
						if (bucketat >= bucketdiv)
							return false;
						
						// Try again
						continue;
					}
					
					// Will use the next chain
					int oldchainat = chainat++;
					
					// If no link was here try again
					__BucketMapEntry__<K, V> link = chain[oldchainat];
					if (link == null)
						continue;
					
					// Cache that link for returning
					this._next = link;
					return true;
				}
			}
			
			// Store properties
			finally
			{
				this._bucketat = bucketat;
				this._chainat = chainat;
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final Map.Entry<K, V> next()
			throws NoSuchElementException
		{
			// {@squirreljme.error ZZ39 Map has no more entries remaining.}
			if (!this.hasNext())
				throw new NoSuchElementException("ZZ39");
			
			// hasNext() caches this
			__BucketMapEntry__<K, V> rv = this._next;
			this._next = null;
			this._last = rv;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/10/13
		 */
		@Override
		public final void remove()
		{
			// Check modification
			this.__checkModified();
			
			// No last element was nexted
			__BucketMapEntry__<K, V> last = this._last;
			if (last == null)
				throw new IllegalStateException("NSEE");
			
			// Remove from the map but we never unlinked it, so if there is
			// a link it will be scanned and removed accordingly
			if (__BucketMap__.this.removeEntry(last.getKey(), false) != last)
				throw new todo.OOPS();
			
			// The map likely was structurally modified so use the new state
			this._atmod = __BucketMap__.this._modcount;
		}
	}
	
	/**
	 * Iterator over the linked order in this map.
	 *
	 * @since 2018/11/01
	 */
	final class __IteratorLinkedOrder__
		extends __IteratorBase__
	{
		/** The iterator for entries in linked order. */
		final Iterator<__BucketMapEntry__<K, V>> _iterator =
			__BucketMap__.this._links.iterator();
		
		/** The last returned entry, for removal. */
		__BucketMapEntry__<K, V> _last;
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final boolean hasNext()
		{
			// Check for modification
			this.__checkModified();
			
			// Just if it has a next anyway
			return this._iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final Map.Entry<K, V> next()
		{
			// Check for modification
			this.__checkModified();
			
			// Use the direct next entry
			__BucketMapEntry__<K, V> rv = this._iterator.next();
			this._last = rv;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/01
		 */
		@Override
		public final void remove()
		{
			// Check for modification
			this.__checkModified();
			
			// No last element was nexted
			__BucketMapEntry__<K, V> last = this._last;
			if (last == null)
				throw new IllegalStateException("NSEE");
			
			// Clear last because it will be invalid
			this._last = null;
			
			// Try removing it from the link first, if the state is bad then
			// we cannot remove the link. Has to be removed from the iterator
			// because otherwise there will be a concurrent modification
			// exception thrown when modification is detected.
			try
			{
				this._iterator.remove();
			}
			
			// Just rethrow this, this means the entry was already removed
			catch (IllegalStateException e)
			{
				throw e;
			}
			
			// Otherwise, remove the entry from the map but hint that it was
			// already removed from the ordered list
			// The entry being mismatched to the key should not happen ever
			// but if it does then something is very wrong
			if (__BucketMap__.this.removeEntry(last.getKey(), true) != last)
				throw new todo.OOPS();
			
			// The map likely was structurally modified so use the new state
			this._atmod = __BucketMap__.this._modcount;
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__DescendingIteratorViaListIterator__.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * Descending iterator over the linked list.
 *
 * @param <E> The class type.
 * @since 2019/01/20
 */
final class __DescendingIteratorViaListIterator__<E>
	implements Iterator<E>
{
	/** The list iterator to use. */
	protected final ListIterator<E> it;
	
	/**
	 * Initializes the descending iterator.
	 *
	 * @param __it The input iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/20
	 */
	__DescendingIteratorViaListIterator__(ListIterator<E> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this.it = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final boolean hasNext()
	{
		return this.it.hasPrevious();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final E next()
	{
		return this.it.previous();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/20
	 */
	@Override
	public final void remove()
	{
		this.it.remove();
	}
}

Deleted runt/apis/cldc-compact/java/util/__Link__.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * Represents a single link in the linked list. This is just a basic
 * structure like object with public fields for simple access.
 *
 * @param <E> The type to store.
 * @since 2018/10/29
 */
final class __Link__<E>
{
	/** The previous link. */
	__Link__<E> _prev;
	
	/** The next link. */
	__Link__<E> _next;
	
	/** The value to store. */
	E _value;
	
	/**
	 * Initializes the new link and links into the chain.
	 *
	 * @param __prev The previous link to link in.
	 * @param __v The value to use.
	 * @param __next The next link to link in.
	 * @since 2018/10/29
	 */
	__Link__(__Link__<E> __prev, E __v, __Link__<E> __next)
	{
		// Set value first
		this._value = __v;
		
		// Link into previous chain
		this._prev = __prev;
		if (__prev != null)
			__prev._next = this;
		
		// Link into next chain
		this._next = __next;
		if (__next != null)
			__next._prev = this;
	}
}

Deleted runt/apis/cldc-compact/java/util/__LinkedListListIterator__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315



























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;


/**
 * The list iterator for this linked list.
 *
 * @param <E> The types of values to store.
 * @since 2018/10/29
 */
final class __LinkedListListIterator__<E>
	implements ListIterator<E>
{
	/** The owning linked list. */
	protected final LinkedList<E> list;
	
	/** The virtualized index for the list (estimated). */
	private int _vdx;
	
	/** Last virtualized index. */
	private int _lastvdx;
	
	/** The current link the list is at. */
	private __Link__<E> _next;
	
	/** The last element, for removal or setting */
	private __Link__<E> _last;
	
	/** The current modification count, to detect modifications. */
	private int _atmod;
	
	/**
	 * Initializes the iterator starting at the given index.
	 *
	 * @param __list The linked list this interfaces with.
	 * @param __i The index to start at.
	 * @throws IndexOutOfBoundsException If the index is outside of the
	 * list bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	__LinkedListListIterator__(LinkedList<E> __list, int __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__list == null)
			throw new NullPointerException("NARG");
		
		int size = __list._size;
		if (__i < 0 || __i > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Closer to the start of the list
		__Link__<E> rover;
		if (__i < (size >> 1))
		{
			rover = __list._head;
			
			for (int i = -1; i < __i; i++)
				rover = rover._next;
		}
		
		// Closer to the end of the list
		else
		{
			rover = __list._tail;
			
			for (int i = size; i > __i; i--)
				rover = rover._prev;
		}
		
		// Store start information
		this.list = __list;
		this._next = rover;
		this._vdx = __i;
		this._atmod = __list.modCount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void add(E __v)
	{
		// Check modification
		this.__checkConcurrent();
		
		// These will both be adjusted
		int vdx = this._vdx;
		__Link__<E> next = this._next;
		
		// The documentation specifies that the object is inserted
		// before the implicit cursor, which means the next call to
		// previous will return the new element. Next would just return
		// the same element no matter how many elements are added.
		// So it is inserted between the previous and our current next
		new __Link__<E>(next._prev, __v, next);
		
		// Since we inserted an item, vdx goes up
		this._vdx++;
		
		// Size also goes up
		this.list._size++;
		
		// Set list as being modified and update our count to match
		this._atmod = ++this.list.modCount;
		
		// Cannot remove or set
		this._last = null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final boolean hasNext()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There is a next as long as the current element is before the
		// size
		return this._vdx < this.list._size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final boolean hasPrevious()
	{
		// Check modification
		this.__checkConcurrent();
		
		// There is a previous as long as this is not the first element
		return this._vdx > 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/28
	 */
	@Override
	public final E next()
		throws NoSuchElementException
	{
		// Check modification
		this.__checkConcurrent();
		
		// We are at the tail node, do nothing
		__Link__<E> next = this._next;
		if (next == this.list._tail)
			throw new NoSuchElementException("NSEE");
		
		// Removal and set can be done on this
		this._last = next;
		
		// Iterate and record for the next element
		this._lastvdx = this._vdx++;
		this._next = next._next;
		
		// Return the current value
		return next._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final int nextIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// Virtual index should match this one
		return this._vdx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final E previous()
	{
		// Check modification
		this.__checkConcurrent();
		
		// We are at the head node, do nothing
		__Link__<E> next = this._next;
		if (next._prev == this.list._head)
			throw new NoSuchElementException("NSEE");
		
		// Move to previous
		__Link__<E> prev = next._prev;
		
		// Removal is done on this
		this._last = prev;
		
		// Move index back
		this._lastvdx = --this._vdx;
		this._next = prev;
		
		// Use previous value
		return prev._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final int previousIndex()
	{
		// Check modification
		this.__checkConcurrent();
		
		// Should be the previous virtual index
		return this._vdx - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void remove()
		throws IllegalStateException
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2u Cannot remove the element from the
		// linked list because there was no previous call to next or
		// previous, or add was called.}
		__Link__<E> last = this._last;
		if (last == null)
			throw new IllegalStateException("ZZ2u");
		
		// Only removed once
		this._last = null;
		
		// Just link the previous and next entries to the others and
		// drop this link
		last._prev._next = last._next;
		last._next._prev = last._prev;
		
		// If the next entry is after this point then it will needs its
		// index dropped
		int vdx = this._vdx,
			lastvdx = this._lastvdx;
		if (vdx > lastvdx)
			this._vdx = vdx - 1;
		
		// Set list as being modified and update our count to match
		this._atmod = ++this.list.modCount;
		
		// Size goes down
		this.list._size--;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public final void set(E __v)
		throws IllegalStateException
	{
		// Check modification
		this.__checkConcurrent();
		
		// {@squirreljme.error ZZ2v Cannot set the element from the
		// linked list because there was no previous call to next or
		// previous, or add was called.}
		__Link__<E> last = this._last;
		if (last == null)
			throw new IllegalStateException("ZZ2v");
		
		// Just set it
		last._value = __v;
	}
	
	/**
	 * Checks if the list was concurrently modified.
	 *
	 * @throws ConcurrentModificationException If it was modified.
	 * @since 2018/10/29
	 */
	private final void __checkConcurrent()
		throws ConcurrentModificationException
	{
		// {@squirreljme.error ZZ2w List has been concurrently modified.}
		if (this._atmod != this.list.modCount)
		{
			// Just empty these out so they are never used again
			this._next = null;
			this._last = null;
			
			// Fail
			throw new ConcurrentModificationException("ZZ2w");
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__PrintFCategory__.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * Represents the category of the conversion.
 *
 * @since 2018/09/29
 */
enum __PrintFCategory__
{
	/** General. */
	GENERAL,
	
	/** Character. */
	CHARACTER,
	
	/** Integral. */
	INTEGRAL,
	
	/** Floating point. */
	FLOATING_POINT,
	
	/** Date/Time. */
	DATE_TIME,
	
	/** Percent. */
	PERCENT,
	
	/** Line Separator. */
	LINE_SEPARATOR,
	
	/** End. */
	;
	
	/**
	 * Is the specified flag valid?
	 *
	 * @param __f The flag to check.
	 * @return If it is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		switch (this)
		{
				// May only be left justified
			case CHARACTER:
			case DATE_TIME:
			case GENERAL:
				return __f == __PrintFFlag__.LEFT_JUSTIFIED;
				
				// Anything is valid
			case INTEGRAL:
				return true;
				
				// Not valid at all
			case PERCENT:
			case LINE_SEPARATOR:
				return false;
				
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is the precision valid?
	 *
	 * @return Is the precision valid?
	 * @since 2018/09/29
	 */
	final boolean __hasPrecision()
	{
		switch (this)
		{
			case GENERAL:
			case FLOATING_POINT:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is the width valid?
	 *
	 * @return If the width is valid.
	 * @since 2018/09/29
	 */
	final boolean __hasWidth()
	{
		return this != LINE_SEPARATOR;
	}
}

Deleted runt/apis/cldc-compact/java/util/__PrintFConversion__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324




































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This represents a conversion that can be used for formatted printing.
 *
 * @since 2018/09/28
 */
enum __PrintFConversion__
{
	/** Literal percent. */
	PERCENT,
	
	/** Newline. */
	NEWLINE,
	
	/** Boolean. */
	BOOLEAN,
	
	/** Hashcode. */
	HASHCODE,
	
	/** String. */
	STRING,
	
	/** Character. */
	CHARACTER,
	
	/** Decimal Integer. */
	DECIMAL_INTEGER,
	
	/** Octal Integer. */
	OCTAL_INTEGER,
	
	/** Hexadecimal Integer. */
	HEXADECIMAL_INTEGER,
	
	/** Scientific decimal floating point. */
	SCIENTIFIC_DECIMAL_FLOAT,
	
	/** Decimal floating point. */
	NORMAL_DECIMAL_FLOAT,
	
	/** Floating point in scientific or normal mode. */
	SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT,
	
	/** Hour: 00 - 23. */
	TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO,
	
	/** Hour: 01 - 12. */
	TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO,
	
	/** Hour: 0 - 24. */
	TIME_MILITARY_HOUR,
	
	/** Hour: 1 - 12. */
	TIME_STANDARD_HOUR,
	
	/** Minute: 00 - 59. */
	TIME_MINUTE,
	
	/** Seconds: 00 - 60 (60 for leap seconds). */
	TIME_SECONDS,
	
	/** Milliseconds: 000 - 999. */
	TIME_MILLISECONDS,
	
	/** Locale based am or pm. */
	TIME_AM_PM,
	
	/** RFC 822 zone offset from GMT, such as -0800 for the current zone. */
	TIME_ZONE_RFC822_OFFSET,
	
	/** The abbreviation for this timezone. */
	TIME_ZONE_ABBREVIATION,
	
	/** Seconds since UNIX Epoch. */
	TIME_UNIX_SECONDS,
	
	/** Milliseconds since UNIX Epoch. */
	TIME_UNIX_MILLISECONDS,
	
	/** Local abbreviated month: Jan, Feb. */
	DATE_ABBREVIATED_MONTH_NAME,
	
	/** Local short name of the day of week: Sun, Mon. */
	DATE_ABBREVIATED_DAY_NAME,
	
	/** Century, two digits with leading zero: 00 - 99. */
	DATE_CENTURY_TWO_DIGIT_LEADING_ZERO,
	
	/** Year formatted with at least four digits. */
	DATE_YEAR_FOUR_DIGITS,
	
	/** Last two digits of the year. */
	DATE_YEAR_LAST_TWO_DIGITS,
	
	/** Day of year, with leading zeros as needed: 001 - 366. */
	DATE_DAY_OF_YEAR,
	
	/** Month with two digits with leading zero: 01 - 13. */
	DATE_MONTH_TWO_DIGIT_LEADING_ZERO,
	
	/** Day of month, two digits with leading zero: 01 - 31. */
	DATE_DAY_TWO_DIGIT_LEADING_ZERO,
	
	/** Day of month: 1 - 31. */
	DATE_DAY,
	
	/** 24-hour clock format: %tH:%tM. */
	DATE_TIME_MILITARY,
	
	/** 24-hour clock format with seconds: %tH:%tM:%tS. */
	DATE_TIME_MILITARY_WITH_SECONDS,
	
	/** 12-hour clock format with seconds: %tI:%tM:%tS %Tp. */
	DATE_TIME_STANDARD,
	
	/** Date formatted as %tm/%td/%ty. */
	DATE_MONTH_DAY_YEAR,
	
	/** ISO 8601 Date: %tY-%tm-%td. */
	DATE_ISO8601,
	
	/** Date and time as: %ta %tb %td %tT %tZ %tY. */
	DATE_LONG_FORMAT,
	
	/** End. */
	;
	
	/**
	 * Returns the category of this conversion.
	 *
	 * @return The conversion category.
	 * @since 2018/09/29
	 */
	final __PrintFCategory__ __category()
	{
		switch (this)
		{
			case PERCENT:
				return __PrintFCategory__.PERCENT;
			
			case NEWLINE:
				return __PrintFCategory__.LINE_SEPARATOR;
			
			case BOOLEAN:
			case HASHCODE:
			case STRING:
				return __PrintFCategory__.GENERAL;
				
			case CHARACTER:
				return __PrintFCategory__.CHARACTER;
				
			case DECIMAL_INTEGER:
			case OCTAL_INTEGER:
			case HEXADECIMAL_INTEGER:
				return __PrintFCategory__.INTEGRAL;
				
			case SCIENTIFIC_DECIMAL_FLOAT:
			case NORMAL_DECIMAL_FLOAT:
			case SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT:
				return __PrintFCategory__.FLOATING_POINT;
				
			case TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO:
			case TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO:
			case TIME_MILITARY_HOUR:
			case TIME_STANDARD_HOUR:
			case TIME_MINUTE:
			case TIME_SECONDS:
			case TIME_MILLISECONDS:
			case TIME_AM_PM:
			case TIME_ZONE_RFC822_OFFSET:
			case TIME_ZONE_ABBREVIATION:
			case TIME_UNIX_SECONDS:
			case TIME_UNIX_MILLISECONDS:
			case DATE_ABBREVIATED_MONTH_NAME:
			case DATE_ABBREVIATED_DAY_NAME:
			case DATE_CENTURY_TWO_DIGIT_LEADING_ZERO:
			case DATE_YEAR_FOUR_DIGITS:
			case DATE_YEAR_LAST_TWO_DIGITS:
			case DATE_DAY_OF_YEAR:
			case DATE_MONTH_TWO_DIGIT_LEADING_ZERO:
			case DATE_DAY_TWO_DIGIT_LEADING_ZERO:
			case DATE_DAY:
			case DATE_TIME_MILITARY:
			case DATE_TIME_MILITARY_WITH_SECONDS:
			case DATE_TIME_STANDARD:
			case DATE_MONTH_DAY_YEAR:
			case DATE_ISO8601:
			case DATE_LONG_FORMAT:
				return __PrintFCategory__.DATE_TIME;
				
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is the specified flag valid?
	 *
	 * @param __f The flag to check.
	 * @return If it is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// If the category does not have it then it will never have it
		__PrintFCategory__ cat = this.__category();
		if (!cat.__hasFlag(__f))
			return false;
		
		// Only this category has exclusions
		if (cat == __PrintFCategory__.INTEGRAL)
			switch (__f)
			{
					// Only valid for octal and hex ints
				case ALTERNATIVE_FORM:
					return this == OCTAL_INTEGER ||
						this == HEXADECIMAL_INTEGER;
				
					// Only valid for decimal ints
				case LOCALE_GROUPING:
					return this == DECIMAL_INTEGER;
				
				default:
					break;
			}
		
		// Is valid!
		return true;
	}
	
	/**
	 * Returns the conversion that is used for the characters.
	 *
	 * @param __f The first character.
	 * @param __s The second character.
	 * @return The conversion or {@code null} if it is not valid.
	 * @since 2018/09/28
	 */
	static final __PrintFConversion__ __decode(int __f, int __s)
	{
		// There are a ton of date formats, so just if a date is used do
		// not bother
		if (__f != 't' && __f != 'T')
			switch (__f)
			{
				case '%':	return PERCENT;
				case 'n':	return NEWLINE;
				case 'B':
				case 'b':	return BOOLEAN;
				case 'H':
				case 'h':	return HASHCODE;
				case 'S':
				case 's':	return STRING;
				case 'C':
				case 'c':	return CHARACTER;
				case 'd':	return DECIMAL_INTEGER;
				case 'o':	return OCTAL_INTEGER;
				case 'X':
				case 'x':	return HEXADECIMAL_INTEGER;
				case 'E':
				case 'e':	return SCIENTIFIC_DECIMAL_FLOAT;
				case 'f':	return NORMAL_DECIMAL_FLOAT;
				case 'G':
				case 'g':	return SCIENTIFIC_OR_NORMAL_DECIMAL_FLOAT;
				
				default:
					return null;
			}
		
		// A date format
		switch (__s)
		{
			case 'H':	return TIME_MILITARY_HOUR_TWO_DIGIT_LEADING_ZERO;
			case 'I':	return TIME_STANDARD_HOUR_TWO_DIGIT_LEADING_ZERO;
			case 'k':	return TIME_MILITARY_HOUR;
			case 'l':	return TIME_STANDARD_HOUR;
			case 'M':	return TIME_MINUTE;
			case 'S':	return TIME_SECONDS;
			case 'L':	return TIME_MILLISECONDS;
			case 'p':	return TIME_AM_PM;
			case 'z':	return TIME_ZONE_RFC822_OFFSET;
			case 'Z':	return TIME_ZONE_ABBREVIATION;
			case 's':	return TIME_UNIX_SECONDS;
			case 'Q':	return TIME_UNIX_MILLISECONDS;
			case 'h':
			case 'b':	return DATE_ABBREVIATED_MONTH_NAME;
			case 'a':	return DATE_ABBREVIATED_DAY_NAME;
			case 'C':	return DATE_CENTURY_TWO_DIGIT_LEADING_ZERO;
			case 'Y':	return DATE_YEAR_FOUR_DIGITS;
			case 'y':	return DATE_YEAR_LAST_TWO_DIGITS;
			case 'j':	return DATE_DAY_OF_YEAR;
			case 'm':	return DATE_MONTH_TWO_DIGIT_LEADING_ZERO;
			case 'd':	return DATE_DAY_TWO_DIGIT_LEADING_ZERO;
			case 'e':	return DATE_DAY;
			case 'R':	return DATE_TIME_MILITARY;
			case 'T':	return DATE_TIME_MILITARY_WITH_SECONDS;
			case 'r':	return DATE_TIME_STANDARD;
			case 'D':	return DATE_MONTH_DAY_YEAR;
			case 'F':	return DATE_ISO8601;
			case 'c':	return DATE_LONG_FORMAT;
		
			default:
				return null;
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__PrintFFlag__.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
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



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * PrintF flags which may exist to be used.
 *
 * @since 2018/09/24
 */
enum __PrintFFlag__
{
	/** Left justification. */
	LEFT_JUSTIFIED,
	
	/** Alternative form. */
	ALTERNATIVE_FORM,
	
	/** Include sign always. */
	ALWAYS_SIGNED,
	
	/** Padded sign with space. */
	SPACE_FOR_POSITIVE,
	
	/** Zero padded. */
	ZERO_PADDED,
	
	/** Locale specific grouping specifiers. */
	LOCALE_GROUPING,
	
	/** Negative numbers in parenthesis. */
	NEGATIVE_PARENTHESIS,
	
	/** End. */
	;
	
	/** Internal values. */
	private static final __PrintFFlag__[] _VALUES =
		__PrintFFlag__.values();
	
	/** The number of flags used. */
	public static final int COUNT =
		__PrintFFlag__._VALUES.length;
	
	/**
	 * Returns the value for the given ordinal/
	 *
	 * @param __i The ordinal.
	 * @return The flag.
	 * @throws IndexOutOfBoundsException If the ordinal is out of range.
	 * @since 2018/09/29
	 */
	public static final __PrintFFlag__ valueOf(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= __PrintFFlag__.COUNT)
			throw new IndexOutOfBoundsException("IOOB");
		return __PrintFFlag__._VALUES[__i];
	}
	
	/**
	 * Decodes the given character to a flag.
	 *
	 * @param __c The character to decode.
	 * @return The flag for the character or {@code null} if it is not valid.
	 * @since 2018/09/24
	 */
	static final __PrintFFlag__ __decode(char __c)
	{
		switch (__c)
		{
			case '-':	return __PrintFFlag__.LEFT_JUSTIFIED;
			case '#':	return __PrintFFlag__.ALTERNATIVE_FORM;
			case '+':	return __PrintFFlag__.ALWAYS_SIGNED;
			case ' ':	return __PrintFFlag__.SPACE_FOR_POSITIVE;
			case '0':	return __PrintFFlag__.ZERO_PADDED;
			case ',':	return __PrintFFlag__.LOCALE_GROUPING;
			case '(':	return __PrintFFlag__.NEGATIVE_PARENTHESIS;
			default:
				return null;
		}
	}
}

Deleted runt/apis/cldc-compact/java/util/__PrintFGlobal__.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * Global PrintF state.
 *
 * @since 2018/09/28
 */
final class __PrintFGlobal__
{
	/** Arguments. */
	final Object[] _args;
	
	/** Linear index, used to implicitly define which argument to use. */
	int _lineardx;
	
	/**
	 * Initializes the global state.
	 *
	 * @param __args The arguments.
	 * @since 2018/09/29
	 */
	__PrintFGlobal__(Object... __args)
	{
		this._args = (__args == null ? new Object[0] : __args);
	}
}

Deleted runt/apis/cldc-compact/java/util/__PrintFState__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327







































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This stores the state for printf parsing.
 *
 * @since 2018/09/24
 */
final class __PrintFState__
{
	/** Global state. */
	final __PrintFGlobal__ _global;
	
	/** Flags specified. */
	final boolean[] _flags =
		new boolean[__PrintFFlag__.COUNT];
	
	/** The argument index. */
	int _argdx =
		-1;
	
	/** The width. */
	int _width =
		-1;
	
	/** The precision. */
	int _precision =
		-1;
	
	/** The conversion used. */
	__PrintFConversion__ _conv;
	
	/** Is the conversion to be uppercase? */
	boolean _upper;
	
	/**
	 * Initializes the state.
	 *
	 * @param __pg The state.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/29
	 */
	__PrintFState__(__PrintFGlobal__ __pg)
		throws NullPointerException
	{
		if (__pg == null)
			throw new NullPointerException("NARG");
		
		this._global = __pg;
	}
	
	/**
	 * Returns the specified argument.
	 *
	 * @param <C> The return type.
	 * @param __i The index.
	 * @return The argument value.
	 * @throws IllegalArgumentException If the argument is not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/09/29
	 */
	final <C> C __argument(Class<C> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3a Null argument was passed.}
		C rv = this.<C>__argument(__cl, null);
		if (rv == null)
			throw new NullPointerException("ZZ3a");
		return rv;
	}
	
	/**
	 * Returns the specified argument.
	 *
	 * @param <C> The return type.
	 * @param __i The index.
	 * @param __def The default value, if the input is null then this will
	 * be returned.
	 * @return The argument value or the default if it was null.
	 * @throws IllegalArgumentException If the argument is not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/09/29
	 */
	final <C> C __argument(Class<C> __cl, C __def)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		__PrintFGlobal__ global = this._global;
		
		// Determine the argument index to use, if the argument was not
		// explicitely passed then it is tracked manually
		int argdx = this._argdx,
			usedx = (argdx < 0 ? global._lineardx++ : argdx - 1);
		
		// {@squirreljme.error ZZ3b Request to use argument which is not
		// within the bounds of the input arguments. (The argument index)}
		Object[] args = global._args;
		if (usedx < 0 || usedx >= args.length)
			throw new IllegalArgumentException("ZZ3b " + (usedx + 1));
		
		// Return default value if one was used and there was no value here
		Object rv = args[usedx];
		if (rv == null)
			return __def;
		
		// {@squirreljme.error ZZ3c Expected argument of one class however it
		// was instead another class. (The requested class; The actual class)}
		if (!__cl.isInstance(rv))
			throw new IllegalArgumentException("ZZ3c " + __cl + " " +
				rv.getClass());
		
		return __cl.cast(rv);
	}
	
	/**
	 * Is the given flag used?
	 *
	 * @param __f The flag to use.
	 * @return If the flag is used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/03
	 */
	final boolean __hasFlag(__PrintFFlag__ __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return this._flags[__f.ordinal()];
	}
	
	/**
	 * Was a width specified?
	 *
	 * @return If a width was specified.
	 * @since 2018/09/24
	 */
	final boolean __hasWidth()
	{
		return this._width >= 1;
	}
	
	/**
	 * Is this left justified?
	 *
	 * @return If this is left justified.
	 * @since 2018/09/29
	 */
	final boolean __isLeftJustified()
	{
		return this._flags[__PrintFFlag__.LEFT_JUSTIFIED.ordinal()];
	}
	
	/**
	 * Sets the argument index.
	 *
	 * @param __dx The index to set.
	 * @throws IllegalArgumentException If the index is not valid.
	 * @since 2018/09/24
	 */
	final void __setArgumentIndex(int __dx)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3d Argument index already set or is of an
		// invalid value. (The index used)}
		if (__dx <= 0 || this._argdx >= 1)
			throw new IllegalArgumentException("ZZ3d " + __dx);
		
		this._argdx = __dx;
	}
	
	/**
	 * Sets the conversion.
	 *
	 * @param __p The primary conversion.
	 * @param __s The secondary conversion.
	 * @throws IllegalArgumentException If the conversion is not valid.
	 * @since 2018/09/28
	 */
	final void __setConversion(int __p, int __s)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3e The conversion has already been specified.}
		if (this._conv != null)
			throw new IllegalArgumentException("ZZ3e");
		
		// {@squirreljme.error ZZ3f Invalid conversion specified. (The first
		// character; The second character)}
		__PrintFConversion__ conv = __PrintFConversion__.__decode(__p, __s);
		if (conv == null)
			throw new IllegalArgumentException("ZZ3f " + (char)__p + " " +
				(char)(__s < 0 ? ' ' : __s));
		
		// Set
		this._conv = conv;
		
		// Uppercase conversion?
		switch (__p)
		{
			case 'B':
			case 'H':
			case 'S':
			case 'C':
			case 'X':
			case 'E':
			case 'G':
			case 'T':
				this._upper = true;
				break;
			
			default:
				break;
		}
		
		// Need this to do sanity checks
		__PrintFCategory__ cat = conv.__category();
		
		// {@squirreljme.error ZZ3g The specified flag cannot be specified
		// for the given conversion. (The conversion; The flag)}
		boolean[] flags = this._flags;
		for (int i = 0, n = __PrintFFlag__.COUNT; i < n; i++)
		{
			__PrintFFlag__ flag = __PrintFFlag__.valueOf(i);
			if (flags[i] && !conv.__hasFlag(flag))
				throw new IllegalArgumentException("ZZ3g " + conv + " " +
					flag);
		}
		
		// {@squirreljme.error ZZ3h Width cannot be specified for the given
		// convesion. (The conversion)}
		if (this._width > 0 && !cat.__hasWidth())
			throw new IllegalArgumentException("ZZ3h " + conv);
		
		// {@squirreljme.error ZZ3i Precision cannot be specified for the
		// given conversion. (The conversion)}
		if (this._precision > 0 && !cat.__hasPrecision())
			throw new IllegalArgumentException("ZZ3i " + conv);
	}
	
	/**
	 * Sets the specified flag.
	 *
	 * @param __c The flag to set.
	 * @return If the flag is valid.
	 * @throws IllegalArgumentException If the flag was duplicated.
	 * @since 2018/09/24
	 */
	final boolean __setFlag(char __c)
		throws IllegalArgumentException
	{
		// Is this flag one that exists?
		__PrintFFlag__ f = __PrintFFlag__.__decode(__c);
		if (f == null)
			return false;
		
		boolean[] flags = this._flags;
		
		// There may be a duplicate flag
		int ord = f.ordinal();
		if (flags[ord])
			throw new IllegalArgumentException("ZZ1p " + __c);
		
		// {@squirreljme.error ZZ3j Always signed and space for positive values
		// cannot be combined for format flags.}
		if ((f == __PrintFFlag__.ALWAYS_SIGNED &&
			flags[__PrintFFlag__.SPACE_FOR_POSITIVE.ordinal()]) ||
			(f == __PrintFFlag__.SPACE_FOR_POSITIVE &&
			flags[__PrintFFlag__.ALWAYS_SIGNED.ordinal()]))
			throw new IllegalArgumentException("ZZ3j");
		
		// Use it
		flags[ord] = true;
		return true;
	}
	
	/**
	 * Sets the width.
	 *
	 * @param __w The width to use.
	 * @throws IllegalArgumentException If the width is not valid.
	 * @since 2018/09/24
	 */
	final void __setWidth(int __w)
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3k Width already or is of an invalid value.
		// (The width used)}
		if (__w <= 0 || this._width >= 1)
			throw new IllegalArgumentException("ZZ3k " + __w);
		
		this._width = __w;
	}
	
	/**
	 * Returns the width.
	 *
	 * @return The width.
	 * @throws IllegalArgumentException If it was not specified.
	 * @since 2018/11/03
	 */
	final int __width()
		throws IllegalArgumentException
	{
		// {@squirreljme.error ZZ3l No width was specified where one was
		// expected.}
		int rv = this._width;
		if (rv < 0)
			throw new IllegalArgumentException("ZZ3l");
		
		return rv;
	}
}

Deleted runt/apis/cldc-compact/java/util/__TaskSchedComparator__.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * Comparator for task scheduling.
 *
 * @since 2018/12/11
 */
@Deprecated
final class __TaskSchedComparator__
	implements Comparator<TimerTask>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final int compare(TimerTask __a, TimerTask __b)
	{
		long diff = (__a._schedtime - __b._schedtime);
		if (diff == 0)
			return 0;
		else if (diff < 0)
			return -1;
		return 1;
	}
}

Deleted runt/apis/cldc-compact/java/util/__TimerThread__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292




































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.util;

/**
 * This is a thread which provides the basis for the timer.
 *
 * @since 2018/12/11
 */
final class __TimerThread__
	extends Thread
{
	/**
	 * Tasks which may be running, note that this is not a binary heap as
	 * Java SE says since there should not be thousands of running tasks.
	 * This is Java ME and timers are less likely to be heavy.
	 */
	final List<TimerTask> _tasks =
		new ArrayList<>();
	
	/** Cancel execution? */
	volatile boolean _cancel;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __n The thread name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	__TimerThread__(String __n)
		throws NullPointerException
	{
		super(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final void run()
	{
		List<TimerTask> tasks = this._tasks;
		
		// Constantly loop on our own look since we will mess with things
		for (;;)
			synchronized (this)
			{
				if (this._cancel)
				{
					// Set all tasks to cancel
					for (TimerTask t : tasks)
						t._cancel = true;
					
					// Clear all the tasks, because we no longer need them
					tasks.clear();
					
					// And just stop executing
					return;
				}
				
				// Task to run
				TimerTask execute = null;
				
				// Need to determine how long to wait to run a task for
				try
				{
					// If there are no tasks to run, then we wait forever
					if (tasks.isEmpty())
						this.wait();
					
					// Otherwise see how long we need to wait
					else
					{
						// Need to determine if we are running this task
						// or just waiting
						TimerTask next = tasks.get(0);
						long now = System.currentTimeMillis(),
							sched = next._schedtime;
						
						// We cancelled the task, so remove and do not bother
						// at all
						if (next._cancel)
						{
							tasks.remove(0);
							continue;
						}
						
						// We can execute it!
						else if (sched <= now)
						{
							execute = next;
							tasks.remove(0);
						}
						
						// Wait around for it to happen, but another event
						// could come before this!
						else
							this.wait(sched - now);
					}
				}
				
				// If interrupted, try another run of the loop
				catch (InterruptedException e)
				{
					continue;
				}
				
				// Execute if things are to be done
				if (execute != null)
				{
					// We need to set the last one because fixed scheduling
					// will set a new schedule time while delayed will wait
					// on that
					long schedtime = execute._schedtime;
					execute._lastrun = schedtime;
					
					// Fixed scheduling has it where the next event gets the
					// period added to the scheduling time. This way if the
					// task runs too slowly it gets built up.
					boolean repeated = execute._repeated,
						fixed = execute._fixed;
					long period = execute._period;
					if (repeated && fixed)
						schedtime += period;
					
					// Execute the task
					execute._inrun = true;
					try
					{
						execute.run();
					}
					catch (Throwable t)
					{
						// Ignore
						t.printStackTrace();
					}
					execute._inrun = false;
					
					// Repeat as long as the task is not cancelled
					if (repeated && !execute._cancel)
					{
						// If not fixed use delay from the end of this
						// execution
						if (!fixed)
							schedtime = System.currentTimeMillis() + period;
						
						// Schedule for re-execution
						execute._schedtime = schedtime;
						this.__addTask(execute);
					}
				}
			}
	}
	
	/**
	 * Adds the specified task.
	 *
	 * @param __task The task to add.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/12
	 */
	private void __addTask(TimerTask __task)
		throws NullPointerException
	{
		if (__task == null)
			throw new NullPointerException("NARG");
		
		List<TimerTask> tasks = this._tasks;
		
		// Add task to the task list, but in task sorted order
		// It is always inserted into the correct location
		int dx = (tasks.isEmpty() ? 0 :
			Collections.<TimerTask>binarySearch(tasks,
			__task, new __TaskSchedComparator__()));
		if (dx < 0)
			dx = (-(dx) - 1);
		
		// Add task at the index we found it should be at
		tasks.add(dx, __task);
	}
	
	/**
	 * Schedules the task.
	 *
	 * @param __task The task to run.
	 * @param __first The time when the task should run.
	 * @param __rep Repeat the task?
	 * @param __fixed Fixed delays from execution?
	 * @param __period The period between each repetition.
	 * @throws IllegalArgumentException If the date is negative or the
	 * period is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	void __schedule(TimerTask __task, Date __first,
		boolean __rep, boolean __fixed, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__task == null || __first == null)
			throw new NullPointerException("NARG");
		
		// Need to determine when 
		long datemilli = __first.getTime(),
			nowtime = System.currentTimeMillis(),
			diff = datemilli - nowtime;
		
		// {@squirreljme.error ZZ3m Cannot use a date which is far into the
		// past.}
		if (datemilli < 0)
			throw new IllegalArgumentException("ZZ3m");
		
		// Schedule immedietly?
		if (diff < 0)
			diff = 0;
		
		// Forward since we use fixed delay schedule
		this.__schedule(__task, diff, __rep, __fixed, __period);
	}
	
	/**
	 * Schedules the task.
	 *
	 * @param __task The task to run.
	 * @param __delay The delay before the first invocation.
	 * @param __rep Repeat the task?
	 * @param __fixed Fixed delays from execution?
	 * @param __period The period between each repetition.
	 * @throws IllegalArgumentException If the delay is negative or the
	 * period is zero or negative.
	 * @throws IllegalStateException If a task was already scheduled, a task
	 * was cancelled, or this timer was cancelled.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	void __schedule(TimerTask __task, long __delay,
		boolean __rep, boolean __fixed, long __period)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__task == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZZ3n The delay cannot be negative.}
		if (__delay < 0)
			throw new IllegalArgumentException("ZZ3n");
		
		// {@squirreljme.error ZZ3o The period cannot be zero or negative.}
		if (__rep && __period <= 0)
			throw new IllegalArgumentException("ZZ3o");
		
		// When is the time to be scheduled?
		long now = System.currentTimeMillis(),
			sched = now + __delay;
		
		// Lock on self
		List<TimerTask> tasks = this._tasks;
		synchronized (this)
		{
			// {@squirreljme.error ZZ3p Cannot add a task to a timer which
			// was cancelled or a task which was cancelled.}
			if (this._cancel || __task._cancel)
				throw new IllegalStateException("ZZ3p");
			
			// Set task properties
			__task._schedtime = sched;
			__task._scheduled = true;
			__task._repeated = __rep;
			__task._fixed = __fixed;
			__task._period = __period;
			
			// Add the task
			this.__addTask(__task);
			
			// And notify that there is a new task in place
			this.notifyAll();
		}
	}
}

Deleted runt/apis/cldc-compact/todo/DEBUG.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package todo;

import java.io.PrintStream;

/**
 * This class contains static methods for debug printing messages as needed.
 *
 * @since 2018/04/09
 */
public final class DEBUG
{
	/**
	 * Not used.
	 *
	 * @since 2018/04/09
	 */
	private DEBUG()
	{
	}
	
	/**
	 * Prints a debug note to standard error about something that is
	 * incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/09
	 */
	public static final void note(String __fmt, Object... __args)
	{
		TODO.__note("DBUG", __fmt, __args);
	}
}

Deleted runt/apis/cldc-compact/todo/OOPS.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
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





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import java.io.PrintStream;

/**
 * This is an error which is thrown when a condition which should not occur
 * occurs.
 *
 * @since 2018/11/25
 */
public class OOPS
	extends Error
{
	/**
	 * Generates an oops with no message.
	 *
	 * @since 2018/11/25
	 */
	public OOPS()
	{
		this(null, null);
	}
	
	/**
	 * Generates an oops with the given message.
	 *
	 * @param __m The message to use.
	 * @since 2018/11/25
	 */
	public OOPS(String __m)
	{
		this(__m, null);
	}
	
	/**
	 * Generates an oops with the given cause.
	 *
	 * @param __t The cause to use.
	 * @since 2018/11/25
	 */
	public OOPS(Throwable __t)
	{
		this(null, __t);
	}
	
	/**
	 * Generates an oops with the given message and cause.
	 *
	 * @param __m The message to use.
	 * @param __t The cause.
	 * @since 2018/11/25
	 */
	public OOPS(String __m, Throwable __t)
	{
		super(__m, __t);
		
		// Detect OOPSes/TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			// Top banner
			ps.println("****************************************************");
			ps.print("OOPS CONDITION WAS MET: ");
			if (__m != null)
				ps.print(__m);
			ps.println();
			
			// Print the current thread
			ps.print("IN THREAD: ");
			ps.println(Thread.currentThread());
			
			// Spacer
			ps.println();
			
			// Print the trace
			this.printStackTrace(ps);
			
			// Ending banner
			ps.println("****************************************************");
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		
		// {@squirreljme.property
		// cc.squirreljme.nooopsexit=(boolean)
		// If this is {@code true} then the OOPS exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.nooopsexit")))
			try
			{
				System.exit(125);
			}
		
			// Ignore
			catch (SecurityException e)
			{
			}
	}
}

Deleted runt/apis/cldc-compact/todo/TODO.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459











































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import java.io.PrintStream;

/**
 * This exception is thrown.
 *
 * When constructed, this exception does not normall finish execution.
 *
 * @since 2017/02/28
 */
public class TODO
	extends Error
{
	/** Debug by default? */
	private static final boolean _DEFAULT_DEBUG =
		true;
	
	/** Should messages be squelched? */
	private static final boolean _SQUELCH;
	
	/** Used to detect TODOs recursively being called. */
	static volatile boolean _DOUBLE_TRIP;
	
	/** Suppress infinite note TODOs being printed over and over. */
	private static volatile boolean _notelock;
	
	/** The number of suppressed note TODOs. */
	private static volatile int _supressednotes;
	
	/**
	 * Checks if debug messages should be printed.
	 *
	 * @since 2018/11/04
	 */
	static
	{
		boolean debug;
		try
		{
			// {@squirreljme.property cc.squirreljme.debug Set to a boolean
			// value (true or false) which specifies whether todo and debug
			// messages should be printed to the console.}
			debug = Boolean.valueOf(
				System.getProperty("cc.squirreljme.debug",
				Boolean.valueOf(_DEFAULT_DEBUG).toString()));
		}
		
		// Cannot access properties so use the default
		catch (SecurityException e)
		{
			debug = _DEFAULT_DEBUG;
		}
		
		// Squelch based on reverse debug
		_SQUELCH = !debug;
	}
	
	/**
	 * Initializes the exception, prints the trace, and exits the program.
	 *
	 * @since 2017/02/28
	 */
	public TODO()
	{
		this(null);
	}
	
	/**
	 * Initializes the exception, prints the trace, and exits the program.
	 *
	 * @param __s Message input.
	 * @since 2018/09/29
	 */
	public TODO(String __s)
	{
		super(__s);
		
		// Detect TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			ps.println("****************************************************");
			ps.print("INCOMPLETE CODE HAS BEEN REACHED: ");
			if (__s != null)
				ps.print(__s);
			ps.println();
			
			// Print the current thread
			ps.print("IN THREAD: ");
			ps.println(Thread.currentThread());
			
			// Spacer
			ps.println();
			
			// Print the trace
			this.printStackTrace(ps);
			
			// Ending banner
			ps.println("****************************************************");
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			Assembly.sysCallP(SystemCallIndex.FATAL_TODO);
		
		// {@squirreljme.property
		// cc.squirreljme.notodoexit=(boolean)
		// If this is {@code true} then the ToDo exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.notodoexit")))
			try
			{
				System.exit(126);
			}
		
			// Ignore
			catch (SecurityException e)
			{
			}
	}
	
	/**
	 * Specifies that the integer value is missing.
	 *
	 * @return An integer, but is not returned from.
	 * @since 2017/10/27
	 */
	public static final int missingInteger()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Specifies that the object value is missing.
	 *
	 * @param <T> The object to miss.
	 * @return Should return that object, but never does.
	 * @since 2017/10/24
	 */
	public static final <T> T missingObject()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Prints a note to standard error about something that is incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/02
	 */
	public static final void note(String __fmt, Object... __args)
	{
		TODO.__note("TODO", __fmt, __args);
	}
	
	/**
	 * Formats a call trace element in a condensed form.
	 *
	 * @param __e The element to print out.
	 * @return The condensed string.
	 * @since 2018/05/03
	 */
	static final String __formatCondensedTrace(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String cn = __e.className(),
			mn = __e.methodName(),
			md = __e.methodDescriptor(),
			fi = __e.file();
		long ad = __e.address();
		int ln = __e.line();
		
		StringBuilder sb = new StringBuilder();
		
		// Location
		if (cn != null)
		{
			// Get identifier part
			int ld = cn.lastIndexOf('.');
			if (ld < 0)
				if ((ld = cn.lastIndexOf('/')) < 0)
					ld = 0;
			
			// Print slimmed down packages since they could be guessed
			for (int i = 0, n = cn.length(); i >= 0 && i < n;)
			{
				// Before the last dot, print single and skip ahead
				if (i < ld)
				{
					sb.append(cn.charAt(i));
					
					int ldi = cn.indexOf('.', i);
					if (ldi < 0)
						ldi = cn.indexOf('/', i);
					
					i = ldi + 1;
				}
				
				// Finish string
				else
				{
					if (i > 0)
						sb.append('.');
					sb.append(cn.substring(i));
					break;
				}
			}
		}
		sb.append("::");
		if (mn != null)
			sb.append(mn);
		/*if (md != null)
			sb.append(md);*/
		
		// Address, if it is valid
		if (ad != -1L)
		{
			sb.append(" @ ");
			sb.append(Long.toString(ad, 16).toUpperCase());
			sb.append("h");
		}
		
		// Add file/line information if it is valid
		if (fi != null)
		{
			sb.append(" (");
			
			// Use blank class name if not specified
			if (cn == null)
				cn = "";
			
			// The class will end with the Java extension
			int ld = cn.lastIndexOf('.');
			if (ld < 0)
				ld = cn.lastIndexOf('/');
			if (ld >= 0)
				cn = cn.substring(ld + 1);
			
			// Determine how many charcters the class name and the file
			// name have in common, so that it can be shortened
			int deep = 0;
			for (int n = Math.min(cn.length(), fi.length()); deep < n; deep++)
				if (cn.charAt(deep) != fi.charAt(deep))
					break;
			
			// Use whole name
			if (deep == 0)
				sb.append(fi);
			
			// Use fragment
			else
			{
				// But only if it does not end in .java, this makes it
				// implied since it is always around
				String sub = fi.substring(deep);
				if (!sub.equals(".java"))
				{
					sb.append('*');
					sb.append(sub);
				}
			}
			
			if (ln >= 0)
			{
				sb.append(':');
				sb.append(ln);
			}
			
			sb.append(')');
		}
		
		return sb.toString();
	}
	
	/**
	 * Formats the call trace element.
	 *
	 * @param __e The element to format.
	 * @return The formatted string.
	 * @since 2018/04/02
	 */
	static final String __formatTrace(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String cn = __e.className(),
			mn = __e.methodName(),
			md = __e.methodDescriptor(),
			fi = __e.file();
		long ad = __e.address();
		int ln = __e.line();
		
		StringBuilder sb = new StringBuilder();
		
		// Location
		if (cn != null)
			sb.append(cn);
		sb.append("::");
		if (mn != null)
			sb.append(mn);
		
		if (md != null)
			sb.append(md);
		
		// Address, if it is valid
		if (ad != -1L)
		{
			sb.append(" @ ");
			sb.append(ad);
		}
		
		// Add file/line information if it is valid
		if (fi != null)
		{
			sb.append(" (");
			sb.append(fi);
			
			if (ln >= 0)
			{
				sb.append(':');
				sb.append(ln);
			}
			
			sb.append(')');
		}
		
		return sb.toString();
	}
	
	
	/**
	 * Prints a note to standard error about something that is incomplete.
	 *
	 * @param __fmt The format string.
	 * @param __args The arguments to the call.
	 * @since 2018/04/02
	 */
	static final void __note(String __pfx, String __fmt, Object... __args)
	{
		// If messages are squelched, ignore anything output
		if (_SQUELCH)
			return;
		
		// Only print if the stream is valid
		PrintStream ps = System.err;
		if (ps == null)
			return;
		
		// Prevent infinite recursion when printing notes because things might
		// get stuck here if code that this method calls ends up calling
		// things
		boolean printy = false;
		synchronized (TODO.class)
		{
			// Use simple lock counter
			if (!TODO._notelock)
				try
				{
					// Lock note
					TODO._notelock = true;
					printy = true;
				}
				finally
				{
				}
			
			// Add marker for suppressed notes
			else
				TODO._supressednotes++;
		}
		
		// Print it out?
		if (printy)
			try
			{
				ps.print(__pfx);
				ps.print(GuestDepth.guestDepth());
				ps.print(' ');
				ps.print(TODO.__formatCondensedTrace(TODO.__where()));
				ps.print(" -- ");
				
				ps.printf(__fmt, __args);
				
				// Add markers to indicate the number of notes which were
				// suppressed
				int suppressed = TODO._supressednotes;
				TODO._supressednotes = 0;
				for (int i = 0; i < suppressed; i++)
					ps.print('^');
				
				ps.println();
			}
			finally
			{
				// In case of exceptions, this will always be unlocked
				TODO._notelock = false;
			}
	}
	
	/**
	 * Determines where the code is in the call stack.
	 *
	 * @return The call trace element for the current location.
	 * @since 2018/04/02
	 */
	static final CallTraceElement __where()
	{
		// For the SquirrelJME runtime, use the debug stuff to get the
		// current call trace
		CallTraceElement[] stack = CallTraceElement.traceResolve(
			CallTraceElement.traceRaw());
		
		// Get the first one which is not in this class
		for (CallTraceElement e : stack)
		{
			String cn = e.className();
			if (cn == null)
				cn = "<unknown>";
			
			if (!cn.startsWith("todo/"))
				return e;
		}
		
		// Unknown
		return new CallTraceElement();
	}
}

Deleted runt/apis/cldc-compact/todo/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the exception indicating that incomplete code has been
 * reached.
 *
 * @since 2017/02/28
 */

package todo;

Deleted runt/apis/cldc/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: cb4e0a64-b9d8-4899-995c-fcdce1749288
X-SquirrelJME-Error: ZY
X-SquirrelJME-Name: Connection Limited Device Configuration
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 1.8
X-SquirrelJME-Description: This is the standard Java ME 8 Connection 
 Limited Device Configuration which contains the full set of classes 
 used by JavaME.
Microedition-Configuration: CLDC-1.8-Compact
X-SquirrelJME-DefinedConfigurations: CLDC-1.8

Deleted runt/apis/cldc/cc/squirreljme/runtime/cldc/full/NullFileSystem.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
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








































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.full;

import java.io.Closeable;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * This is a file system which is completely nullary.
 *
 * @since 2019/12/22
 */
public final class NullFileSystem
	extends FileSystem
{
	/** The instance of this filesystem. */
	public static final NullFileSystem INSTANCE =
		new NullFileSystem();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Has no effect
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterable<FileStore> getFileStores()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getPath(String __base, String... __more)
		throws NullPointerException
	{
		if (__base == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error ZY01 The null filesystem only supports a single
		// path element.}
		if (!__base.equals(NullPath.ONLY_PATH_STRING))
			throw new InvalidPathException(__base, "ZY01");
		
		// {@squirreljme.error ZY02 Additional null path elements must be
		// blank or null.}
		if (__more != null)
			for (String m : __more)
				if (m != null && !m.isEmpty())
					throw new InvalidPathException(m, "ZY02");
		
		return NullPath.INSTANCE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterable<Path> getRootDirectories()
	{
		// There is only a single null root
		return Arrays.<Path>asList(this.getPath("null:$"));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final String getSeparator()
	{
		// Null file system uses dollar signs as paths
		return "$";
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isOpen()
	{
		// Always is open
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isReadOnly()
	{
		// File system is always read-only
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Set<String> supportedFileAttributeViews()
	{
		// No attributes are supported
		return new HashSet<>();
	}
}

Deleted runt/apis/cldc/cc/squirreljme/runtime/cldc/full/NullPath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285





























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.cldc.full;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.LinkOption;
import java.util.Iterator;

/**
 * This represents a null path.
 *
 * @since 2019/12/22
 */
public class NullPath
	implements Path
{
	/** The only valid path permitted. */
	public static final String ONLY_PATH_STRING =
		"null:$";
	
	/** The instance of this class. */
	public static final Path INSTANCE =
		new NullPath();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int compareTo(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean endsWith(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean endsWith(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getFileName()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final FileSystem getFileSystem()
	{
		return NullFileSystem.INSTANCE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getName(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int getNameCount()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getParent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path getRoot()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean isAbsolute()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Iterator<Path> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path normalize()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path relativize(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolve(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolve(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolveSibling(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path resolveSibling(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean startsWith(Path __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final boolean startsWith(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path subpath(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path toAbsolutePath()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final Path toRealPath(LinkOption... __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/cc/squirreljme/runtime/cldc/full/StandardPaths.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310






















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.full;

import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

/**
 * This class contains the standard set of paths which is where SquirrelJME's
 * data is stored.
 *
 * @since 2018/01/13
 */
public final class StandardPaths
{
	/**
	 * {@squirreljme.property cc.squirreljme.home=path
	 * This specifies the singular base for where the user configuration,
	 * library, and cache data is stored.}
	 */
	public static final String HOME_PROPERTY =
		"cc.squirreljme.home";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_HOME=path
	 * This specifies the singular base for where the user configuration,
	 * library, and cache data is stored.}
	 */
	public static final String HOME_ENV =
		"SQUIRRELJME_HOME";
	
	/**
	 * {@squirreljme.property cc.squirreljme.path.config=path
	 * This specifies the location where configuration files are stored.}
	 */
	public static final String CONFIG_PATH_PROPERTY =
		"cc.squirreljme.path.config";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_CONFIG_PATH=path
	 * This specifies the location where configuration files are stored.}
	 */
	public static final String CONFIG_PATH_ENV =
		"SQUIRRELJME_CONFIG_PATH";
	
	/**
	 * {@squirreljme.property cc.squirreljme.path.data=path
	 * This specifies the location where data files are stored.}
	 */
	public static final String DATA_PATH_PROPERTY =
		"cc.squirreljme.path.data";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_DATA_PATH=path
	 * This specifies the location where data files are stored.}
	 */
	public static final String DATA_PATH_ENV =
		"SQUIRRELJME_DATA_PATH";
	/**
	 * {@squirreljme.property cc.squirreljme.path.cache=path
	 * This specifies the location where cache files are stored.}
	 */
	public static final String CACHE_PATH_PROPERTY =
		"cc.squirreljme.path.cache";
	
	/**
	 * {@squirreljme.env SQUIRRELJME_CACHE_PATH=path
	 * This specifies the location where cache files are stored.}
	 */
	public static final String CACHE_PATH_ENV =
		"SQUIRRELJME_CACHE_PATH";
	
	/** Determines the default paths to use. */
	public static final StandardPaths DEFAULT =
		__defaultPaths();
	
	/** The configuration path. */
	protected final Path config;
	
	/** The data path. */
	protected final Path data;
	
	/** The cache path. */
	protected final Path cache;
	
	/** Library path. */
	private Reference<Path> _libpath;
	
	/**
	 * Initializes a standard path using the specified path as a base for
	 * the required directories.
	 *
	 * @param __p The base path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/13
	 */
	public StandardPaths(Path __p)
		throws NullPointerException
	{
		this(__p.resolve("config"), __p.resolve("data"), __p.resolve("cache"));
	}
	
	/**
	 * Initializes the standard path set.
	 *
	 * @param __conf The configuration directory.
	 * @param __data The data directory.
	 * @param __cache The cache directory.
	 * @throws NullPointerException On null arguments.
	 * @sicne 2018/01/13
	 */
	public StandardPaths(Path __conf, Path __data, Path __cache)
		throws NullPointerException
	{
		if (__conf == null || __data == null || __cache == null)
			throw new NullPointerException("NARG");
		
		this.config = __conf;
		this.data = __data;
		this.cache = __cache;
	}
	
	/**
	 * Returns the library path where JARs are installed.
	 *
	 * @return The JAR installation path.
	 * @since 2018/02/10
	 */
	public final Path libraryPath()
	{
		Reference<Path> ref = this._libpath;
		Path rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._libpath = new WeakReference<>(
				(rv = this.data.resolve("lib")));
		
		return rv;
	}
	
	/**
	 * Determines how to get the default paths.
	 *
	 * @return The set of standard paths.
	 * @since 2018/01/13
	 */
	private static StandardPaths __defaultPaths()
	{
		Path[] rv = null;
		
		// Using a basic home path
		String basichome = Objects.toString(System.getProperty(HOME_PROPERTY),
			SystemAccess.getEnv(HOME_ENV));
		if (basichome != null)
			rv = new Path[]{Paths.get(basichome)};
		
		// If no basic path was used, detect more paths
		if (rv == null)
		{
			rv = __defaultPathsOs();
			
			// Still could not be used?
			if (rv == null)
				rv = new Path[]{StandardPaths.__getPropertyPath("user.dir").
					resolve("squirreljme")};
		}
		
		// If only a single path is returned then expand it to
		// multiple ones
		if (rv.length == 1)
		{
			Path base = rv[0];
			rv = new Path[]
				{
					base.resolve("config"),
					base.resolve("data"),
					base.resolve("cache"),
				};
		}
		
		// Setup paths
		return new StandardPaths(
			__triple(rv[0], System.getProperty(CONFIG_PATH_PROPERTY),
				SystemAccess.getEnv(CONFIG_PATH_ENV)),
			__triple(rv[1], System.getProperty(DATA_PATH_PROPERTY),
				SystemAccess.getEnv(DATA_PATH_ENV)),
			__triple(rv[2], System.getProperty(CACHE_PATH_PROPERTY),
				SystemAccess.getEnv(CACHE_PATH_ENV)));
	}
	
	/**
	 * Use paths specific to the operation system.
	 *
	 * @return The set of paths, either 1 for singular or 3 for config, data,
	 * and cache.
	 * @since 2018/01/31
	 */
	private static Path[] __defaultPathsOs()
	{
		// Based on OS
		int ostype = SystemProperties.operatingSystemType();
		
		// These may be used by either OS
		Path userhome = StandardPaths.__getPropertyPath("user.home");
		Path userdir = StandardPaths.__getPropertyPath("user.dir");
		
		if (true)
			throw new todo.TODO();
		
		// Unix systems
		if (false)
		{
			Path[] rv = new Path[]
				{
					StandardPaths.__getEnv("XDG_CONFIG_HOME"),
					StandardPaths.__getEnv("XDG_DATA_HOME"),
					StandardPaths.__getEnv("XDG_CACHE_HOME"),
				};
			
			if (rv[0] == null)
				rv[0] = userhome.resolve(".config").resolve("squirreljme");
			
			if (rv[1] == null)
				rv[1] = userhome.resolve(".local").resolve("share").
					resolve("squirreljme");
			
			if (rv[2] == null)
				rv[2] = userhome.resolve(".cache").resolve("squirreljme");
			
			return rv;
		}
		
		// Unknown
		return null;
	}
	
	/**
	 * Returns the path of an environment variable.
	 *
	 * @param __s The environment variable to get.
	 * @return The path of the property or {@code null} if it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/02/09
	 */
	private static Path __getEnv(String __s)
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		String v = SystemAccess.getEnv(__s);
		if (v != null)
			return Paths.get(v);
		return null;
	}
	
	/**
	 * Returns the path of a system property.
	 *
	 * @param __s The system property to get.
	 * @return The path of the property or {@code null} if it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/13
	 */
	private static Path __getPropertyPath(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		String v = System.getProperty(__s);
		if (v != null)
			return Paths.get(v);
		return null;
	}
	
	/**
	 * Prefers path A, then B, and if neither the default is used.
	 *
	 * @param __default The default path.
	 * @param __a The first path.
	 * @param __b The second path.
	 * @return The path to use.
	 * @since 2018/01/31
	 */
	private static Path __triple(Path __default, String __a, String __b)
	{
		if (__a != null)
			return Paths.get(__a);
		
		else if (__b != null)
			return Paths.get(__b);
		
		return __default;
	}
}

Deleted runt/apis/cldc/cc/squirreljme/runtime/cldc/full/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package is the base for full CLDC support.
 *
 * @since 2018/10/14
 */

package cc.squirreljme.runtime.cldc.full;

Deleted runt/apis/cldc/java/nio/Buffer.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class Buffer
{
	Buffer()
	{
		super();
		throw new todo.TODO();
	}
	
	public final int capacity()
	{
		throw new todo.TODO();
	}
	
	public final Buffer clear()
	{
		throw new todo.TODO();
	}
	
	public final Buffer flip()
	{
		throw new todo.TODO();
	}
	
	public final boolean hasRemaining()
	{
		throw new todo.TODO();
	}
	
	public final int limit()
	{
		throw new todo.TODO();
	}
	
	public final Buffer limit(int __a)
	{
		throw new todo.TODO();
	}
	
	public final int position()
	{
		throw new todo.TODO();
	}
	
	public final Buffer position(int __a)
	{
		throw new todo.TODO();
	}
	
	public final int remaining()
	{
		throw new todo.TODO();
	}
	
	public final Buffer rewind()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/cldc/java/nio/ByteBuffer.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
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

























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class ByteBuffer
	extends Buffer
	implements Comparable<ByteBuffer>
{
	ByteBuffer()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract FloatBuffer asFloatBuffer();
	
	public abstract IntBuffer asIntBuffer();
	
	public abstract ShortBuffer asShortBuffer();
	
	public abstract byte get();
	
	public abstract byte get(int __a);
	
	public abstract float getFloat();
	
	public abstract float getFloat(int __a);
	
	public abstract int getInt();
	
	public abstract int getInt(int __a);
	
	public abstract short getShort();
	
	public abstract short getShort(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteBuffer put(byte __a);
	
	public abstract ByteBuffer put(int __a, byte __b);
	
	public abstract ByteBuffer putFloat(float __a);
	
	public abstract ByteBuffer putFloat(int __a, float __b);
	
	public abstract ByteBuffer putInt(int __a);
	
	public abstract ByteBuffer putInt(int __a, int __b);
	
	public abstract ByteBuffer putShort(short __a);
	
	public abstract ByteBuffer putShort(int __a, short __b);
	
	public abstract ByteBuffer slice();
	
	public final byte[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(ByteBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer get(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer get(byte[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public final ByteOrder order()
	{
		throw new todo.TODO();
	}
	
	public final ByteBuffer order(ByteOrder __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer put(ByteBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public ByteBuffer put(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final ByteBuffer put(byte[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer allocateDirect(int __a)
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer wrap(byte[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static ByteBuffer wrap(byte[] __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/ByteOrder.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

/**
 * This represents the byte order that data may be in.
 *
 * @since 2016/02/27
 */
public final class ByteOrder
{
	/** Big endian byte order. */
	public static final ByteOrder BIG_ENDIAN =
		new ByteOrder("BIG_ENDIAN");
	
	/** Little endian byte order. */
	public static final ByteOrder LITTLE_ENDIAN =
		new ByteOrder("LITTLE_ENDIAN");
	
	/** The string representing the byte order. */
	private final String _string;
	
	/**
	 * Initializes the byte order.
	 *
	 * @param __str String pertaining to the order.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/27
	 */
	private ByteOrder(String __str)
		throws NullPointerException
	{
		// Check
		if (__str == null)
			throw new NullPointerException();
		
		// Set
		_string = __str;
	}
	
	/**
	 * Returns the string representing the byte order, either
	 * {@code BIG_ENDIAN} or {@code LITTLE_ENDIAN}.
	 *
	 * @return The byte order's string.
	 * @since 2016/02/27
	 */
	@Override
	public String toString()
	{
		return _string;
	}
	
	public static ByteOrder nativeOrder()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/FloatBuffer.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class FloatBuffer
	extends Buffer
	implements Comparable<FloatBuffer>
{
	FloatBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract float get();
	
	public abstract float get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract FloatBuffer put(float __a);
	
	public abstract FloatBuffer put(int __a, float __b);
	
	public abstract FloatBuffer slice();
	
	public final float[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(FloatBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer get(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer get(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer put(FloatBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public FloatBuffer put(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final FloatBuffer put(float[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static FloatBuffer wrap(float[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static FloatBuffer wrap(float[] __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/cldc/java/nio/IntBuffer.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class IntBuffer
	extends Buffer
	implements Comparable<IntBuffer>
{
	IntBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract int get();
	
	public abstract int get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract IntBuffer put(int __a);
	
	public abstract IntBuffer put(int __a, int __b);
	
	public abstract IntBuffer slice();
	
	public final int[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(IntBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer get(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer get(int[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public IntBuffer put(IntBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public IntBuffer put(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final IntBuffer put(int[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static IntBuffer wrap(int[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static IntBuffer wrap(int[] __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/ShortBuffer.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio;

public abstract class ShortBuffer
	extends Buffer
	implements Comparable<ShortBuffer>
{
	ShortBuffer()
	{
		throw new todo.TODO();
	}
	
	public abstract short get();
	
	public abstract short get(int __a);
	
	public abstract boolean isDirect();
	
	public abstract ByteOrder order();
	
	public abstract ShortBuffer put(short __a);
	
	public abstract ShortBuffer put(int __a, short __b);
	
	public abstract ShortBuffer slice();
	
	public final short[] array()
	{
		throw new todo.TODO();
	}
	
	public final int arrayOffset()
	{
		throw new todo.TODO();
	}
	
	public int compareTo(ShortBuffer __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer get(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer get(short[] __a)
	{
		throw new todo.TODO();
	}
	
	public final boolean hasArray()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer put(ShortBuffer __a)
	{
		throw new todo.TODO();
	}
	
	public ShortBuffer put(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public final ShortBuffer put(short[] __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static ShortBuffer wrap(short[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public static ShortBuffer wrap(short[] __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/cldc/java/nio/channels/ByteChannel.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

public interface ByteChannel
	extends ReadableByteChannel, WritableByteChannel
{
}

Deleted runt/apis/cldc/java/nio/channels/Channel.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.Closeable;
import java.io.IOException;

public interface Channel
	extends Closeable
{
	public abstract void close()
		throws IOException;
	
	public abstract boolean isOpen();
}

Deleted runt/apis/cldc/java/nio/channels/Channels.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.InputStream;
import java.io.OutputStream;

public final class Channels
{
	private Channels()
	{
		super();
		throw new todo.TODO();
	}
	
	public static ReadableByteChannel newChannel(InputStream __a)
	{
		throw new todo.TODO();
	}
	
	public static WritableByteChannel newChannel(OutputStream __a)
	{
		throw new todo.TODO();
	}
	
	public static InputStream newInputStream(ReadableByteChannel __a)
	{
		throw new todo.TODO();
	}
	
	public static OutputStream newOutputStream(WritableByteChannel __a)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/channels/ClosedChannelException.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;

public class ClosedChannelException
	extends IOException
{
	public ClosedChannelException()
	{
		super();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/channels/FileChannel.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.util.Set;

public abstract class FileChannel
	extends Object
	implements SeekableByteChannel
{
	protected FileChannel()
	{
		throw new todo.TODO();
	}
	
	public abstract void force(boolean __a)
		throws IOException;
	
	public abstract long position()
		throws IOException;
	
	public abstract FileChannel position(long __a)
		throws IOException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException;
	
	public abstract int read(ByteBuffer __a, long __b)
		throws IOException;
	
	public abstract long size()
		throws IOException;
	
	public abstract FileChannel truncate(long __a)
		throws IOException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException;
	
	public abstract int write(ByteBuffer __a, long __b)
		throws IOException;
	
	public static FileChannel open(Path __a, Set<? extends OpenOption> __b,
		FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileChannel open(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/channels/ReadableByteChannel.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface ReadableByteChannel
	extends Channel
{
	public abstract int read(ByteBuffer __a)
		throws IOException;
}


Deleted runt/apis/cldc/java/nio/channels/SeekableByteChannel.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface SeekableByteChannel
	extends ByteChannel
{
	public abstract long position()
		throws IOException;
	
	public abstract SeekableByteChannel position(long __a)
		throws IOException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException;
	
	public abstract long size()
		throws IOException;
	
	public abstract SeekableByteChannel truncate(long __a)
		throws IOException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException;
}


Deleted runt/apis/cldc/java/nio/channels/WritableByteChannel.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.channels;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface WritableByteChannel
	extends Channel
{
	public abstract int write(ByteBuffer __a)
		throws IOException;
}

Deleted runt/apis/cldc/java/nio/file/CopyOption.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public interface CopyOption
{
}

Deleted runt/apis/cldc/java/nio/file/DirectoryStream.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;

public interface DirectoryStream<T>
	extends Closeable, Iterable<T>
{
	public abstract Iterator<T> iterator();
	
	public static interface Filter<T>
	{
		public abstract boolean accept(T __a)
			throws IOException;
	}
}

Deleted runt/apis/cldc/java/nio/file/FileAlreadyExistsException.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public class FileAlreadyExistsException
	extends FileSystemException
{
	public FileAlreadyExistsException(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public FileAlreadyExistsException(String __a, String __b, String __c)
	{
		super((String)null);
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/FileStore.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.IOException;

public abstract class FileStore
{
	protected FileStore()
	{
		throw new todo.TODO();
	}
	
	public abstract Object getAttribute(String __a)
		throws IOException;
	
	public abstract long getTotalSpace()
		throws IOException;
	
	public abstract long getUnallocatedSpace()
		throws IOException;
	
	public abstract long getUsableSpace()
		throws IOException;
	
	public abstract boolean isReadOnly();
	
	public abstract String name();
	
	public abstract boolean supportsFileAttributeView(String __a);
	
	public abstract String type();
}


Deleted runt/apis/cldc/java/nio/file/FileSystem.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.Closeable;
import java.io.IOException;
import java.util.Set;

public abstract class FileSystem
	implements Closeable
{
	/**
	 * Base constructor.
	 *
	 * @since 2019/12/22
	 */
	protected FileSystem()
	{
	}
	
	public abstract void close()
		throws IOException;
	
	public abstract Iterable<FileStore> getFileStores();
	
	public abstract Path getPath(String __a, String... __b);
	
	public abstract Iterable<Path> getRootDirectories();
	
	public abstract String getSeparator();
	
	public abstract boolean isOpen();
	
	public abstract boolean isReadOnly();
	
	public abstract Set<String> supportedFileAttributeViews();
}

Deleted runt/apis/cldc/java/nio/file/FileSystemException.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.IOException;

public class FileSystemException
	extends IOException
{
	public FileSystemException(String __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public FileSystemException(String __a, String __b, String __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public String getFile()
	{
		throw new todo.TODO();
	}
	
	public String getMessage()
	{
		throw new todo.TODO();
	}
	
	public String getOtherFile()
	{
		throw new todo.TODO();
	}
	
	public String getReason()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/FileSystems.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import cc.squirreljme.runtime.cldc.full.NullFileSystem;

/**
 * This contains a static method which is used to obtain the default filesystem
 * which is used by SquirrelJME's native filesystem interface.
 *
 * @since 2017/06/12
 */
public final class FileSystems
{
	/**
	 * Not used.
	 *
	 * @since 2017/06/12
	 */
	private FileSystems()
	{
	}
	
	/**
	 * This returns the default filesystem which is used by the system to
	 * access the filesystem.
	 *
	 * @return The system's default filesystem.
	 * @since 2017/06/12
	 */
	public static FileSystem getDefault()
	{
		todo.DEBUG.note("Implement FileSystem support!");
		return NullFileSystem.INSTANCE;
	}
}

Deleted runt/apis/cldc/java/nio/file/Files.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298










































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileTime;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class Files
{
	private Files()
	{
		super();
		throw new todo.TODO();
	}
	
	public static Path copy(Path __a, Path __b, CopyOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createDirectories(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createDirectory(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createFile(Path __a, FileAttribute<?>... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempDirectory(Path __a, String __b,
		FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempDirectory(String __a, FileAttribute<?>...
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempFile(Path __a, String __b, String __c,
		FileAttribute<?>... __d)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path createTempFile(String __a, String __b, FileAttribute
		<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static void delete(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean deleteIfExists(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean exists(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static Object getAttribute(Path __a, String __b, LinkOption... __c
		)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileStore getFileStore(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static FileTime getLastModifiedTime(Path __a, LinkOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isDirectory(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean isHidden(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isReadable(Path __a)
	{
		throw new todo.TODO();
	}
	
	public static boolean isRegularFile(Path __p)
	{
		throw new todo.TODO();
	}
	
	public static boolean isSameFile(Path __a, Path __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean isWritable(Path __a)
	{
		throw new todo.TODO();
	}
	
	public static Path move(Path __a, Path __b, CopyOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SeekableByteChannel newByteChannel(Path __a, Set<? extends
		OpenOption> __b, FileAttribute<?>... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SeekableByteChannel newByteChannel(Path __a, OpenOption...
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a, String
		__b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DirectoryStream<Path> newDirectoryStream(Path __a,
		DirectoryStream.Filter<? super Path> __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static InputStream newInputStream(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static OutputStream newOutputStream(Path __a, OpenOption... __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean notExists(Path __a, LinkOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static <A extends BasicFileAttributes> A readAttributes(Path __a,
		Class<A> __b, LinkOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Map<String, Object> readAttributes(Path __a, String __b,
		LinkOption... __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path setAttribute(Path __a, String __b, Object __c,
		LinkOption... __d)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Path setLastModifiedTime(Path __a, FileTime __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static long size(Path __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/InvalidPathException.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
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





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

/**
 * This indicates that the given path is not valid.
 *
 * @since 2019/12/22
 */
public class InvalidPathException
	extends IllegalArgumentException
{
	/** The input. */
	private transient final String _input;
	
	/** The reason. */
	private transient final String _reason;
	
	/** The index. */
	private transient final int _index;
	
	/**
	 * Initializes the exception.
	 *
	 * @param __in The input string.
	 * @param __reason The reason for the failure.
	 * @param __index The index of the failure, {@code -1} if not known.
	 * @throws IllegalArgumentException If the index is less than {@code -1}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public InvalidPathException(String __in, String __reason, int __index)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __reason == null)
			throw new NullPointerException("NARG");
		
		// @{squirreljme.error ZY04 Invalid path index specified for
		// exception. (Index)}
		if (__index < -1)
			throw new IllegalArgumentException("ZY04 " + __index);
		
		this._input = __in;
		this._reason = __reason;
		this._index = __index;
	}
	
	/**
	 * Initializes the exception.
	 *
	 * @param __in The input string.
	 * @param __reason The reason for the failure.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public InvalidPathException(String __in, String __reason)
		throws NullPointerException
	{
		this(__in, __reason, -1);
	}
	
	/**
	 * Returns the index where the error occurred.
	 *
	 * @return The index where the error occurred, or {@code -1} if it is not
	 * known.
	 * @since 2019/12/22
	 */
	public int getIndex()
	{
		return this._index;
	}
	
	/**
	 * Returns the input path.
	 *
	 * @return The input path.
	 * @since 2019/12/22
	 */
	public String getInput()
	{
		return this._input;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/22
	 */
	@Override
	public String getMessage()
	{
		// This is specifically specified by the documentation
		int index = this._index;
		return this._reason + ": " + this._input +
			(index > -1 ? " at index " + index : "");
	}
	
	/**
	 * Returns the reason the path is not valid.
	 *
	 * @return The reason the path is not valid.
	 * @since 2019/12/22
	 */
	public String getReason()
	{
		return this._reason;
	}
}

Deleted runt/apis/cldc/java/nio/file/LinkOption.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public enum LinkOption
	implements OpenOption, CopyOption
{
	NOFOLLOW_LINKS(),
	
	/** End. */
	;
	
	private LinkOption()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/NoSuchFileException.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public class NoSuchFileException
	extends FileSystemException
{
	public NoSuchFileException(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public NoSuchFileException(String __a, String __b, String __c)
	{
		super((String)null);
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/OpenOption.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public interface OpenOption
{
}

Deleted runt/apis/cldc/java/nio/file/Path.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

import java.io.IOException;
import java.util.Iterator;

public interface Path
	extends Comparable<Path>, Iterable<Path>
{
	public abstract int compareTo(Path __a);
	
	public abstract boolean endsWith(Path __a);
	
	public abstract boolean endsWith(String __a);
	
	@Override
	public abstract boolean equals(Object __a);
	
	public abstract Path getFileName();
	
	public abstract FileSystem getFileSystem();
	
	public abstract Path getName(int __a);
	
	public abstract int getNameCount();
	
	public abstract Path getParent();
	
	public abstract Path getRoot();
	
	@Override
	public abstract int hashCode();
	
	public abstract boolean isAbsolute();
	
	public abstract Iterator<Path> iterator();
	
	public abstract Path normalize();
	
	public abstract Path relativize(Path __a);
	
	public abstract Path resolve(Path __a);
	
	public abstract Path resolve(String __a);
	
	public abstract Path resolveSibling(Path __a);
	
	public abstract Path resolveSibling(String __a);
	
	public abstract boolean startsWith(Path __a);
	
	public abstract boolean startsWith(String __a);
	
	public abstract Path subpath(int __a, int __b);
	
	public abstract Path toAbsolutePath();
	
	public abstract Path toRealPath(LinkOption... __a)
		throws IOException;
	
	@Override
	public abstract String toString();
}

Deleted runt/apis/cldc/java/nio/file/Paths.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

/**
 * This class provides a single static method which is used to create instances
 * of {@link Path} which represent native filesystem paths.
 *
 * @since 2017/06/12
 */
public final class Paths
{
	/**
	 * Not used.
	 *
	 * @since 2017/06/12
	 */
	private Paths()
	{
	}
	
	/**
	 * This creates a representation of a native filesystem path. It has the
	 * same function and rules as {@link FileSystem#getPath(String, String)}.
	 *
	 * @param __a The first path fragment.
	 * @param __b The optional remaining path fragments.
	 * @return The native representation of the native filesystem path.
	 * @throws InvalidPathException If the specified path cannot be represented
	 * on the native system.
	 * @since 2017/06/12
	 */
	public static Path get(String __a, String... __b)
		throws InvalidPathException
	{
		return FileSystems.getDefault().getPath(__a, __b);
	}
}

Deleted runt/apis/cldc/java/nio/file/StandardCopyOption.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public enum StandardCopyOption
	implements CopyOption
{
	ATOMIC_MOVE,
	
	COPY_ATTRIBUTES,
	
	REPLACE_EXISTING,
	
	/** End. */
	;
}

Deleted runt/apis/cldc/java/nio/file/StandardOpenOption.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file;

public enum StandardOpenOption
	implements OpenOption
{
	APPEND(),
	
	CREATE(),
	
	CREATE_NEW(),
	
	DELETE_ON_CLOSE(),
	
	DSYNC(),
	
	READ(),
	
	SPARSE(),
	
	SYNC(),
	
	TRUNCATE_EXISTING(),
	
	WRITE(),
	
	/** End. */
	;
	
	private StandardOpenOption()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/cldc/java/nio/file/attribute/BasicFileAttributes.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file.attribute;

public interface BasicFileAttributes
{
	public abstract FileTime creationTime();
	
	public abstract boolean isDirectory();
	
	public abstract boolean isOther();
	
	public abstract boolean isRegularFile();
	
	public abstract boolean isSymbolicLink();
	
	public abstract FileTime lastAccessTime();
	
	public abstract FileTime lastModifiedTime();
	
	public abstract long size();
}


Deleted runt/apis/cldc/java/nio/file/attribute/FileAttribute.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file.attribute;

public interface FileAttribute<T>
{
	public abstract String name();
	
	public abstract T value();
}

Deleted runt/apis/cldc/java/nio/file/attribute/FileTime.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.nio.file.attribute;

public final class FileTime
	implements Comparable<FileTime>
{
	private FileTime()
	{
		super();
		throw new todo.TODO();
	}
	
	public int compareTo(FileTime __a)
	{
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public long toMillis()
	{
		throw new todo.TODO();
	}
	
	public String toString()
	{
		throw new todo.TODO();
	}
	
	public static FileTime fromMillis(long __v)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/dio-adc/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (ADC)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to analog to digital con
 verters.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CV
X-SquirrelJME-DefinedStandards: dio.adc;;1.0.1
X-SquirrelJME-UUID: ee88b4c5-ed8c-4465-805b-84b0ac6984f0
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-adc/jdk/dio/adc/ADCChannel.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface ADCChannel
	extends Device<ADCChannel>, BufferAccess<IntBuffer>
{
	public abstract int acquire()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void acquire(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int getMaxSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMinSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMinValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract double getVRefValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setSamplingInterval(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startAcquisition(IntBuffer __a, 
		AcquisitionRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void startAcquisition(IntBuffer __a, IntBuffer __b, 
		AcquisitionRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void startMonitoring(int __a, int __b, MonitoringListener
		__c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stopAcquisition()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stopMonitoring()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-adc/jdk/dio/adc/ADCChannelConfig.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
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




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class ADCChannelConfig
	implements DeviceConfig<ADCChannel>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public ADCChannelConfig(int __a, int __b, int __c, int __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public ADCChannelConfig(String __a, int __b, int __c, int __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getResolution()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingInterval()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingTime()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static ADCChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public ADCChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setResolution(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingInterval(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingTime(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-adc/jdk/dio/adc/ADCPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import jdk.dio.DevicePermission;

public class ADCPermission
	extends DevicePermission
{
	public ADCPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public ADCPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-adc/jdk/dio/adc/AcquisitionRoundListener.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import java.nio.IntBuffer;
import jdk.dio.InputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface AcquisitionRoundListener
	extends InputRoundListener<ADCChannel, IntBuffer>
{
	public abstract void failed(Throwable __a, ADCChannel __b);
	
	public abstract void inputRoundCompleted(RoundCompletionEvent<ADCChannel,
		IntBuffer> __a);
}


Deleted runt/apis/dio-adc/jdk/dio/adc/InvalidInputSamplingRateException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;


public class InvalidInputSamplingRateException
	extends RuntimeException
{
	public InvalidInputSamplingRateException()
	{
		super();
		throw new todo.TODO();
	}
	
	public InvalidInputSamplingRateException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-adc/jdk/dio/adc/MonitoringEvent.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import jdk.dio.DeviceEvent;

public class MonitoringEvent
	extends DeviceEvent<ADCChannel>
{
	public static final int BACK_TO_RANGE =
		1;
	
	public static final int OUT_OF_RANGE =
		0;
	
	public MonitoringEvent(ADCChannel __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public MonitoringEvent(ADCChannel __a, int __b, int __c, long __d, int 
		__e)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-adc/jdk/dio/adc/MonitoringListener.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.adc;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface MonitoringListener
	extends DeviceEventListener, AsyncErrorHandler<ADCChannel>
{
	public abstract void failed(Throwable __a, ADCChannel __b);
	
	public abstract void thresholdReached(MonitoringEvent __a);
}


Deleted runt/apis/dio-adc/jdk/dio/adc/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to analog to digital converters.
 *
 * @since 2016/06/23
 */

package jdk.dio.adc;

Deleted runt/apis/dio-atcmd/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (AT Device)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to devices which use the
  standard AT command set.
X-SquirrelJME-Depends: dio dio-modem
X-SquirrelJME-Error: CZ
X-SquirrelJME-DefinedStandards: dio.atcmd;;1.0.1
X-SquirrelJME-UUID: e7560687-abe6-428c-88cd-ec2ab5aa7640
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/ATDevice.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface ATDevice
	extends Device<ATDevice>
{
	@Deprecated
	public abstract void abortCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void close()
		throws IOException;
	
	@Deprecated
	public abstract void escapeToCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMaxCommandLength()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract boolean isConnected()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract boolean isInCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract DataConnection openDataConnection(String __a, 
		CommandResponseHandler __b, DataConnectionHandler __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract String sendCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void sendCommand(String __a, CommandResponseHandler __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setUnsolicitedResponseHandler(
		UnsolicitedResponseHandler __a)
		throws IOException, ClosedDeviceException;
	
	public abstract String tryAbortCommand(String __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract String tryEscapeToCommandMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/ATDeviceConfig.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class ATDeviceConfig
	implements DeviceConfig<ATDevice>, DeviceConfig.HardwareAddressing
{
	public ATDeviceConfig(String __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public ATDeviceConfig(int __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static ATDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/ATModem.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import jdk.dio.modem.ModemSignalsControl;

public interface ATModem
	extends ATDevice, ModemSignalsControl<ATModem>
{
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/ATPermission.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import jdk.dio.DevicePermission;

public class ATPermission
	extends DevicePermission
{
	public static final String DATA =
		"data";
	
	public ATPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public ATPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/CommandResponseHandler.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface CommandResponseHandler
{
	public abstract String processResponse(ATDevice __a, String __b);
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/DataConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;

import java.nio.channels.ByteChannel;

public interface DataConnection
	extends ByteChannel
{
	public abstract ATDevice getDevice();
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/DataConnectionHandler.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface DataConnectionHandler
{
	public abstract void handleClosedDataConnection(ATDevice __a, 
		DataConnection __b);
	
	public abstract void handleOpenedDataConnection(ATDevice __a, 
		DataConnection __b);
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/UnsolicitedResponseHandler.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.atcmd;


public interface UnsolicitedResponseHandler
{
	public abstract void processResponse(ATDevice __a, String __b);
}


Deleted runt/apis/dio-atcmd/jdk/dio/atcmd/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for AT command devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.atcmd;

Deleted runt/apis/dio-counter/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (Counters)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to hardware counters.
X-SquirrelJME-Depends: dio dio-gpio
X-SquirrelJME-Error: DQ
X-SquirrelJME-DefinedStandards: dio.counter;;1.0.1
X-SquirrelJME-UUID: be0423c3-2f29-4dec-abf1-d6385cdfd723
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/dio-counter/jdk/dio/counter/CounterPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.counter;

import jdk.dio.DevicePermission;

public class CounterPermission
	extends DevicePermission
{
	public CounterPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public CounterPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-counter/jdk/dio/counter/CountingEvent.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.counter;

import jdk.dio.DeviceEvent;

public class CountingEvent
	extends DeviceEvent<PulseCounter>
{
	public static final int INTERVAL_EXPIRED =
		1;
	
	public static final int TERMINAL_VALUE_REACHED =
		0;
	
	public CountingEvent(PulseCounter __a, int __b, int __c, long __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public CountingEvent(PulseCounter __a, int __b, int __c, long __d, long 
		__e, int __f)
	{
		super();
		throw new todo.TODO();
	}
	
	public long getInterval()
	{
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-counter/jdk/dio/counter/CountingListener.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.counter;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface CountingListener
	extends DeviceEventListener, AsyncErrorHandler<PulseCounter>
{
	public abstract void countValueAvailable(CountingEvent __a);
	
	public abstract void failed(Throwable __a, PulseCounter __b);
}


Deleted runt/apis/dio-counter/jdk/dio/counter/PulseCounter.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.counter;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.UnavailableDeviceException;

public interface PulseCounter
	extends Device<PulseCounter>
{
	public abstract int getCount()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract GPIOPin getSource();
	
	public abstract void resetCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void resumeCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startCounting(int __a, long __b, CountingListener 
		__c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stopCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void suspendCounting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-counter/jdk/dio/counter/PulseCounterConfig.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.counter;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.gpio.GPIOPinConfig;

public final class PulseCounterConfig
	implements DeviceConfig<PulseCounter>, DeviceConfig.HardwareAddressing
{
	public static final int TYPE_FALLING_EDGE_ONLY =
		0;
	
	public static final int TYPE_NEGATIVE_PULSE =
		3;
	
	public static final int TYPE_POSITIVE_PULSE =
		2;
	
	public static final int TYPE_RISING_EDGE_ONLY =
		1;
	
	@Deprecated
	public PulseCounterConfig(int __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(int __a, int __b, int __c, GPIOPinConfig __d)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(String __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PulseCounterConfig(String __a, int __b, int __c, GPIOPinConfig __d
		)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin getSource()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig getSourceConfig()
	{
		throw new todo.TODO();
	}
	
	public int getType()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static PulseCounterConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public PulseCounterConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSourceConfig(GPIOPinConfig __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setType(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-counter/jdk/dio/counter/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to hardware counters.
 *
 * @since 2016/06/23
 */

package jdk.dio.counter;

Deleted runt/apis/dio-dac/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (DAC)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to digital to analog con
 verters.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CW
X-SquirrelJME-DefinedStandards: dio.dac;;1.0.1
X-SquirrelJME-UUID: d5bbdfa5-192a-4921-b48a-08ecc15e8499
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-dac/jdk/dio/dac/DACChannel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface DACChannel
	extends Device<DACChannel>, BufferAccess<IntBuffer>
{
	public abstract void generate(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void generate(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int getMaxSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMinSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMinValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getSamplingInterval()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract double getVRefValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setSamplingInterval(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startGeneration(IntBuffer __a, 
		GenerationRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void startGeneration(IntBuffer __a, IntBuffer __b, 
		GenerationRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void stopGeneration()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-dac/jdk/dio/dac/DACChannelConfig.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class DACChannelConfig
	implements DeviceConfig<DACChannel>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public DACChannelConfig(int __a, int __b, int __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public DACChannelConfig(String __a, int __b, int __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getResolution()
	{
		throw new todo.TODO();
	}
	
	public int getSamplingInterval()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static DACChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public DACChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setResolution(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setSamplingInterval(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-dac/jdk/dio/dac/DACPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;

import jdk.dio.DevicePermission;

public class DACPermission
	extends DevicePermission
{
	public DACPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public DACPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-dac/jdk/dio/dac/GenerationRoundListener.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;

import java.nio.IntBuffer;
import jdk.dio.OutputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface GenerationRoundListener
	extends OutputRoundListener<DACChannel, IntBuffer>
{
	public abstract void failed(Throwable __a, DACChannel __b);
	
	public abstract void outputRoundCompleted(RoundCompletionEvent<DACChannel
		, IntBuffer> __a);
}


Deleted runt/apis/dio-dac/jdk/dio/dac/InvalidOutputSamplingRateException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.dac;


public class InvalidOutputSamplingRateException
	extends RuntimeException
{
	public InvalidOutputSamplingRateException()
	{
		super();
		throw new todo.TODO();
	}
	
	public InvalidOutputSamplingRateException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-dac/jdk/dio/dac/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to digital to analog converters.
 *
 * @since 2016/06/23
 */

package jdk.dio.dac;

Deleted runt/apis/dio-generic/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (Generic)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to generic devices.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: DS
X-SquirrelJME-DefinedStandards: dio.generic;;1.0.1
X-SquirrelJME-UUID: 8ea65d38-ad58-4ce8-9b02-1ca66a7d8adf
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-generic/jdk/dio/generic/GenericBufferIODevice.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface GenericBufferIODevice
	extends GenericDevice, ByteChannel, BufferAccess<ByteBuffer>
{
	public abstract int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericDevice.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GenericDevice
	extends Device<GenericDevice>
{
	public abstract <T> T getControl(GenericDeviceControl<T> __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract <T> void setControl(GenericDeviceControl<T> __a, T __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setEventListener(int __a, GenericEventListener __b)
		throws IOException, ClosedDeviceException;
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericDeviceConfig.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GenericDeviceConfig
	implements DeviceConfig<GenericDevice>, DeviceConfig.HardwareAddressing
{
	@Deprecated
	public GenericDeviceConfig(int __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public GenericDeviceConfig(String __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GenericDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public GenericDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericDeviceControl.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;


public class GenericDeviceControl<T>
{
	public GenericDeviceControl(int __a, Class<T> __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
	
	public Class<T> getType()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericEvent.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import jdk.dio.DeviceEvent;

public class GenericEvent
	extends DeviceEvent<GenericDevice>
{
	public static final int INPUT_BUFFER_OVERRUN =
		1;
	
	public static final int INPUT_DATA_AVAILABLE =
		0;
	
	public static final int OUTPUT_BUFFER_EMPTY =
		2;
	
	public GenericEvent(GenericDevice __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public GenericEvent(GenericDevice __a, int __b, long __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericEventListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import jdk.dio.DeviceEventListener;

public interface GenericEventListener
	extends DeviceEventListener
{
	public abstract void eventDispatched(GenericEvent __a);
}


Deleted runt/apis/dio-generic/jdk/dio/generic/GenericPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.generic;

import jdk.dio.DevicePermission;

public class GenericPermission
	extends DevicePermission
{
	public GenericPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GenericPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-generic/jdk/dio/generic/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to generic devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.generic;

Deleted runt/apis/dio-gpio/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (GPIO)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to GPIO pins.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CS
X-SquirrelJME-DefinedStandards: dio.gpio;;1.0.1
X-SquirrelJME-UUID: 2edaf7ea-cdf1-497f-80d0-2a738759b21f
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPin.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GPIOPin
	extends Device<GPIOPin>
{
	public static final int INPUT =
		0;
	
	public static final int OUTPUT =
		1;
	
	public abstract int getDirection()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getTrigger()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract boolean getValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setDirection(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setInputListener(PinListener __a)
		throws IOException, ClosedDeviceException;
	
	public abstract void setTrigger(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setValue(boolean __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPinConfig.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
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
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GPIOPinConfig
	implements DeviceConfig<GPIOPin>, DeviceConfig.HardwareAddressing
{
	public static final int DIR_BOTH_INIT_INPUT =
		2;
	
	public static final int DIR_BOTH_INIT_OUTPUT =
		3;
	
	public static final int DIR_INPUT_ONLY =
		0;
	
	public static final int DIR_OUTPUT_ONLY =
		1;
	
	public static final int MODE_INPUT_PULL_DOWN =
		2;
	
	public static final int MODE_INPUT_PULL_UP =
		1;
	
	public static final int MODE_OUTPUT_OPEN_DRAIN =
		8;
	
	public static final int MODE_OUTPUT_PUSH_PULL =
		4;
	
	public static final int TRIGGER_BOTH_EDGES =
		3;
	
	public static final int TRIGGER_BOTH_LEVELS =
		6;
	
	public static final int TRIGGER_FALLING_EDGE =
		1;
	
	public static final int TRIGGER_HIGH_LEVEL =
		4;
	
	public static final int TRIGGER_LOW_LEVEL =
		5;
	
	public static final int TRIGGER_NONE =
		0;
	
	public static final int TRIGGER_RISING_EDGE =
		2;
	
	@Deprecated
	public GPIOPinConfig(int __a, int __b, int __c, int __d, int __e, boolean
		__f)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPinConfig(String __a, int __b, int __c, int __d, int __e, 
		boolean __f)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getDirection()
	{
		throw new todo.TODO();
	}
	
	public int getDriveMode()
	{
		throw new todo.TODO();
	}
	
	public boolean getInitValue()
	{
		throw new todo.TODO();
	}
	
	public int getPinNumber()
	{
		throw new todo.TODO();
	}
	
	public int getTrigger()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GPIOPinConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public GPIOPinConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDirection(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDriveMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInitValue(boolean __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPinNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setTrigger(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPinPermission.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DevicePermission;

public class GPIOPinPermission
	extends DevicePermission
{
	public static final String SET_DIRECTION =
		"setdirection";
	
	public GPIOPinPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GPIOPinPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPort.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface GPIOPort
	extends Device<GPIOPort>
{
	public static final int INPUT =
		0;
	
	public static final int OUTPUT =
		1;
	
	public abstract int getDirection()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMaxValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract GPIOPin[] getPins();
	
	public abstract int getValue()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setDirection(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setInputListener(PortListener __a)
		throws IOException, ClosedDeviceException;
	
	public abstract void setValue(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPortConfig.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class GPIOPortConfig
	implements DeviceConfig<GPIOPort>
{
	public static final int DIR_BOTH_INIT_INPUT =
		2;
	
	public static final int DIR_BOTH_INIT_OUTPUT =
		3;
	
	public static final int DIR_INPUT_ONLY =
		0;
	
	public static final int DIR_OUTPUT_ONLY =
		1;
	
	public GPIOPortConfig(int __a, int __b, GPIOPinConfig... __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getDirection()
	{
		throw new todo.TODO();
	}
	
	public int getInitValue()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig[] getPinConfigs()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin[] getPins()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static GPIOPortConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/GPIOPortPermission.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DevicePermission;

public class GPIOPortPermission
	extends DevicePermission
{
	public static final String SET_DIRECTION =
		"setdirection";
	
	public GPIOPortPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public GPIOPortPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/PinEvent.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DeviceEvent;

public class PinEvent
	extends DeviceEvent<GPIOPin>
{
	public PinEvent(GPIOPin __a, boolean __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public PinEvent(GPIOPin __a, boolean __b, long __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean getValue()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/PinListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DeviceEventListener;

public interface PinListener
	extends DeviceEventListener
{
	public abstract void valueChanged(PinEvent __a);
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/PortEvent.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;

import jdk.dio.DeviceEvent;

public class PortEvent
	extends DeviceEvent<GPIOPort>
{
	public PortEvent(GPIOPort __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public PortEvent(GPIOPort __a, int __b, long __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/PortListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.gpio;


public interface PortListener
{
	public abstract void valueChanged(PortEvent __a);
}


Deleted runt/apis/dio-gpio/jdk/dio/gpio/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains generic GPIO interfaces.
 *
 * @since 2016/06/23
 */

package jdk.dio.gpio;

Deleted runt/apis/dio-i2cbus/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (I2C)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to the I2C bus.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CT
X-SquirrelJME-DefinedStandards: dio.i2cbus;;1.0.1
X-SquirrelJME-UUID: 0d788331-6b08-45b6-a506-bb61efe926a9
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-i2cbus/jdk/dio/i2cbus/I2CCombinedMessage.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.i2cbus;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface I2CCombinedMessage
{
	public abstract I2CCombinedMessage appendRead(I2CDevice __a, ByteBuffer 
		__b)
		throws IOException, ClosedDeviceException;
	
	public abstract I2CCombinedMessage appendRead(I2CDevice __a, int __b, 
		ByteBuffer __c)
		throws IOException, ClosedDeviceException;
	
	public abstract I2CCombinedMessage appendWrite(I2CDevice __a, ByteBuffer 
		__b)
		throws IOException, ClosedDeviceException;
	
	public abstract int[] transfer()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-i2cbus/jdk/dio/i2cbus/I2CDevice.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.i2cbus;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface I2CDevice
	extends Device<I2CDevice>, ByteChannel, BufferAccess<ByteBuffer>
{
	public abstract I2CDevice.Bus getBus()
		throws IOException;
	
	public abstract int read()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(int __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(int __a, int __b, int __c, ByteBuffer __d)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void write(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int write(int __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public static interface Bus
	{
		public abstract I2CCombinedMessage createCombinedMessage();
	}
}


Deleted runt/apis/dio-i2cbus/jdk/dio/i2cbus/I2CDeviceConfig.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
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



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.i2cbus;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class I2CDeviceConfig
	implements DeviceConfig<I2CDevice>, DeviceConfig.HardwareAddressing
{
	public static final int ADDR_SIZE_10 =
		10;
	
	public static final int ADDR_SIZE_7 =
		7;
	
	@Deprecated
	public I2CDeviceConfig(int __a, int __b, int __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public I2CDeviceConfig(String __a, int __b, int __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getAddress()
	{
		throw new todo.TODO();
	}
	
	public int getAddressSize()
	{
		throw new todo.TODO();
	}
	
	public int getClockFrequency()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static I2CDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public I2CDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setAddress(int __a, int __b)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockFrequency(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-i2cbus/jdk/dio/i2cbus/I2CPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.i2cbus;

import jdk.dio.DevicePermission;

public class I2CPermission
	extends DevicePermission
{
	public I2CPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public I2CPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-i2cbus/jdk/dio/i2cbus/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides interfaces to interact with the I2C bu.
 *
 * @since 2016/06/23
 */

package jdk.dio.i2cbus;

Deleted runt/apis/dio-mmio/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (MMIO)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to memory mapped I/O dev
 ices.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: DT
X-SquirrelJME-DefinedStandards: dio.mmio;;1.0.1
X-SquirrelJME-UUID: 2ca1c809-eca9-41ae-94d3-b4f850a6b14f
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-mmio/jdk/dio/mmio/AccessOutOfBoundsException.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class AccessOutOfBoundsException
{
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/MMIODevice.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface MMIODevice
	extends Device<MMIODevice>
{
	public abstract RawBlock getAsRawBlock()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract RawBlock getBlock(String __n)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void setMMIOEventListener(int __evid, int __cdx,
		ByteBuffer __cbuf, MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
	
	public abstract void setMMIOEventListener(int __evid,
		MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
	
	public abstract void setMMIOEventListener(int __evid, String __cn,
		MMIOEventListener __el)
		throws ClosedDeviceException, IOException;
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/MMIODeviceConfig.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIODeviceConfig
{
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/MMIOEvent.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIOEvent
{
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/MMIOEventListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

import jdk.dio.DeviceEventListener;

public interface MMIOEventListener
	extends DeviceEventListener
{
	public abstract void eventDispatched(MMIOEvent __e);
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/MMIOPermission.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/06/23
 */
public class MMIOPermission
{
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/RawBlock.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface RawBlock
	extends RawMemory
{
	public abstract ByteBuffer asDirectBuffer()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/RawMemory.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

public interface RawMemory
{
	public abstract String getName();
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/RawRegister.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.mmio;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface RawRegister<T extends Number>
	extends RawMemory
{
	public abstract void and(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void clearBit(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void clearBits(T __mask)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract T get()
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract Class<T> getType();
	
	public abstract boolean isBitSet(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void or(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void set(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void setBit(int __dx)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void setBits(T __mask)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
	
	public abstract void xor(T __v)
		throws ClosedDeviceException, IOException, UnavailableDeviceException;
}

Deleted runt/apis/dio-mmio/jdk/dio/mmio/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to memory mapped input and output.
 *
 * @since 2016/06/23
 */

package jdk.dio.mmio;

Deleted runt/apis/dio-modem/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (Modems)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to dial-up modems.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CY
X-SquirrelJME-DefinedStandards: dio.modem;;1.0.1
X-SquirrelJME-UUID: 7dd14ab6-78db-43ae-8d62-78f6b94103e2
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-modem/jdk/dio/modem/ModemSignalEvent.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.modem;

import jdk.dio.Device;
import jdk.dio.DeviceEvent;

public class ModemSignalEvent<P extends Device<? super P>>
	extends DeviceEvent<P>
{
	protected int signalID;
	
	protected boolean signalState;
	
	public ModemSignalEvent(P __a, int __b, boolean __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public ModemSignalEvent(P __a, int __b, boolean __c, long __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getSignalID()
	{
		throw new todo.TODO();
	}
	
	public boolean getSignalState()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-modem/jdk/dio/modem/ModemSignalListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.modem;

import jdk.dio.Device;
import jdk.dio.DeviceEventListener;

public interface ModemSignalListener<P extends Device<? super P>>
	extends DeviceEventListener
{
	public abstract void signalStateChanged(ModemSignalEvent<P> __a);
}


Deleted runt/apis/dio-modem/jdk/dio/modem/ModemSignalsControl.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.modem;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface ModemSignalsControl<P extends Device<? super P>>
{
	public static final int CTS_SIGNAL =
		32;
	
	public static final int DCD_SIGNAL =
		2;
	
	public static final int DSR_SIGNAL =
		4;
	
	public static final int DTR_SIGNAL =
		1;
	
	public static final int RI_SIGNAL =
		8;
	
	public static final int RTS_SIGNAL =
		16;
	
	public abstract boolean getSignalState(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setSignalChangeListener(ModemSignalListener<P> __a, 
		int __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setSignalState(int __a, boolean __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-modem/jdk/dio/modem/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for modems.
 *
 * @since 2016/06/23
 */

package jdk.dio.modem;

Deleted runt/apis/dio-pwm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (PWM)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to PWM devices.
X-SquirrelJME-Depends: dio dio-gpio
X-SquirrelJME-Error: DR
X-SquirrelJME-DefinedStandards: dio.pwm;;1.0.1
X-SquirrelJME-UUID: 8e9685ee-2479-4d22-b5f7-12358d385225
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/dio-pwm/jdk/dio/pwm/GenerationEvent.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import jdk.dio.DeviceEvent;

public class GenerationEvent
	extends DeviceEvent<PWMChannel>
{
	public GenerationEvent(PWMChannel __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public GenerationEvent(PWMChannel __a, int __b, long __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getPulseCount()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/GenerationListener.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import jdk.dio.AsyncErrorHandler;
import jdk.dio.DeviceEventListener;

public interface GenerationListener
	extends DeviceEventListener, AsyncErrorHandler<PWMChannel>
{
	public abstract void failed(Throwable __a, PWMChannel __b);
	
	public abstract void pulseGenerationCompleted(GenerationEvent __a);
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/GenerationRoundListener.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import java.nio.IntBuffer;
import jdk.dio.OutputRoundListener;
import jdk.dio.RoundCompletionEvent;

public interface GenerationRoundListener
	extends OutputRoundListener<PWMChannel, IntBuffer>
{
	public abstract void failed(Throwable __a, PWMChannel __b);
	
	public abstract void outputRoundCompleted(RoundCompletionEvent<PWMChannel
		, IntBuffer> __a);
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/InvalidPulseRateException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;


public class InvalidPulseRateException
	extends RuntimeException
{
	public InvalidPulseRateException()
	{
		super();
		throw new todo.TODO();
	}
	
	public InvalidPulseRateException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/PWMChannel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import java.io.IOException;
import java.nio.IntBuffer;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface PWMChannel
	extends Device<PWMChannel>, BufferAccess<IntBuffer>
{
	public abstract void generate(int __a, int __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void generate(IntBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int getMaxPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getMinPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract GPIOPin getOutput();
	
	public abstract int getPulsePeriod()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract double getScaleFactor()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setPulsePeriod(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setScaleFactor(double __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startGeneration(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startGeneration(int __a, int __b, GenerationListener
		__c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startGeneration(IntBuffer __a, 
		GenerationRoundListener __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void startGeneration(IntBuffer __a, IntBuffer __b, 
		GenerationRoundListener __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void stopGeneration()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/PWMChannelConfig.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;
import jdk.dio.gpio.GPIOPin;
import jdk.dio.gpio.GPIOPinConfig;

public final class PWMChannelConfig
	implements DeviceConfig<PWMChannel>, DeviceConfig.HardwareAddressing
{
	public static final int ALIGN_CENTER =
		0;
	
	public static final int ALIGN_LEFT =
		1;
	
	public static final int ALIGN_RIGHT =
		2;
	
	public static final int IDLE_STATE_HIGH =
		0;
	
	public static final int IDLE_STATE_LOW =
		1;
	
	@Deprecated
	public PWMChannelConfig(int __a, int __b, int __c, int __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(int __a, int __b, int __c, int __d, int __e, 
		GPIOPinConfig __f)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(String __a, int __b, int __c, int __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public PWMChannelConfig(String __a, int __b, int __c, int __d, int __e, 
		GPIOPinConfig __f)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getIdleState()
	{
		throw new todo.TODO();
	}
	
	@Deprecated
	public GPIOPin getOutput()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public GPIOPinConfig getOutputConfig()
	{
		throw new todo.TODO();
	}
	
	public int getPulseAlignment()
	{
		throw new todo.TODO();
	}
	
	public int getPulsePeriod()
	{
		throw new todo.TODO();
	}
	
	public double getScaleFactor()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static PWMChannelConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public PWMChannelConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setIdleState(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputConfig(GPIOPinConfig __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPulseAlignment(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setPulsePeriod(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setScaleFactor(double __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/PWMPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.pwm;

import jdk.dio.DevicePermission;

public class PWMPermission
	extends DevicePermission
{
	public PWMPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public PWMPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-pwm/jdk/dio/pwm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to PWM devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.pwm;

Deleted runt/apis/dio-spibus/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (SPI)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to the SPI bus.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: CU
X-SquirrelJME-DefinedStandards: dio.spibus;;1.0.1
X-SquirrelJME-UUID: a1890b74-ba77-4661-8e2a-020d36bfba34
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-spibus/jdk/dio/spibus/InvalidWordLengthException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;


public class InvalidWordLengthException
	extends RuntimeException
{
	public InvalidWordLengthException()
	{
		super();
		throw new todo.TODO();
	}
	
	public InvalidWordLengthException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-spibus/jdk/dio/spibus/SPICompositeMessage.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;

import java.io.IOException;
import java.nio.ByteBuffer;
import jdk.dio.ClosedDeviceException;
import jdk.dio.UnavailableDeviceException;

public interface SPICompositeMessage
{
	public abstract SPICompositeMessage appendDelay(int __a)
		throws IOException, ClosedDeviceException;
	
	public abstract SPICompositeMessage appendRead(ByteBuffer __a)
		throws IOException, ClosedDeviceException;
	
	public abstract SPICompositeMessage appendRead(int __a, ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	public abstract SPICompositeMessage appendWrite(ByteBuffer __a)
		throws IOException, ClosedDeviceException;
	
	public abstract SPICompositeMessage appendWriteAndRead(ByteBuffer __a, 
		ByteBuffer __b)
		throws IOException, ClosedDeviceException;
	
	public abstract SPICompositeMessage appendWriteAndRead(ByteBuffer __a, 
		int __b, ByteBuffer __c)
		throws IOException, ClosedDeviceException;
	
	public abstract SPIDevice getTargetedDevice();
	
	public abstract int[] transfer()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-spibus/jdk/dio/spibus/SPIDevice.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedByteOrderException;

public interface SPIDevice
	extends Device<SPIDevice>, ByteChannel, BufferAccess<ByteBuffer>
{
	public abstract SPICompositeMessage createCompositeMessage();
	
	public abstract int getWordLength()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int read(int __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract void write(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int writeAndRead(ByteBuffer __a, ByteBuffer __b)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int writeAndRead(ByteBuffer __a, int __b, ByteBuffer __c)
		throws IOException, UnavailableDeviceException, 
			UnsupportedByteOrderException, ClosedDeviceException;
	
	public abstract int writeAndRead(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-spibus/jdk/dio/spibus/SPIDeviceConfig.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203











































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class SPIDeviceConfig
	implements DeviceConfig<SPIDevice>, DeviceConfig.HardwareAddressing
{
	public static final int CS_ACTIVE_HIGH =
		0;
	
	public static final int CS_ACTIVE_LOW =
		1;
	
	public static final int CS_NOT_CONTROLLED =
		2;
	
	@Deprecated
	public SPIDeviceConfig(int __a, int __b, int __c, int __d, int __e, int 
		__f)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(int __a, int __b, int __c, int __d, int __e, int 
		__f, int __g)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(String __a, int __b, int __c, int __d, int __e, 
		int __f)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public SPIDeviceConfig(String __a, int __b, int __c, int __d, int __e, 
		int __f, int __g)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getAddress()
	{
		throw new todo.TODO();
	}
	
	public int getBitOrdering()
	{
		throw new todo.TODO();
	}
	
	public int getCSActiveLevel()
	{
		throw new todo.TODO();
	}
	
	public int getClockFrequency()
	{
		throw new todo.TODO();
	}
	
	public int getClockMode()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getWordLength()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static SPIDeviceConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public SPIDeviceConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setAddress(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setBitOrdering(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setCSActiveLevel(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockFrequency(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setClockMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setWordLength(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-spibus/jdk/dio/spibus/SPIPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spibus;

import jdk.dio.DevicePermission;

public class SPIPermission
	extends DevicePermission
{
	public SPIPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public SPIPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-spibus/jdk/dio/spibus/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to the SPI Bus.
 *
 * @since 2016/06/23
 */

package jdk.dio.spibus;

Deleted runt/apis/dio-uart/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (UART)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to serial UARTs.
X-SquirrelJME-Depends: dio dio-modem
X-SquirrelJME-Error: CX
X-SquirrelJME-DefinedStandards: dio.uart;;1.0.1
X-SquirrelJME-UUID: dc4c49eb-90b2-4845-9a87-bba0d21e2160
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/dio-uart/jdk/dio/uart/ModemUART.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.modem.ModemSignalsControl;

public interface ModemUART
	extends UART, ModemSignalsControl<ModemUART>
{
}


Deleted runt/apis/dio-uart/jdk/dio/uart/UART.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import jdk.dio.BufferAccess;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.InputRoundListener;
import jdk.dio.OutputRoundListener;
import jdk.dio.UnavailableDeviceException;

public interface UART
	extends Device<UART>, ByteChannel, BufferAccess<ByteBuffer>
{
	public abstract void generateBreak(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getBaudRate()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getDataBits()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getFlowControlMode()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getParity()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getReceiveTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getReceiveTriggerLevel()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int getStopBits()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int read(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setBaudRate(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setDataBits(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setEventListener(int __a, UARTEventListener __b)
		throws IOException, ClosedDeviceException;
	
	public abstract void setFlowControlMode(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setParity(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setReceiveTimeout(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setReceiveTriggerLevel(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void setStopBits(int __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startReading(ByteBuffer __a, InputRoundListener<UART
		, ByteBuffer> __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startReading(ByteBuffer __a, ByteBuffer __b, 
		InputRoundListener<UART, ByteBuffer> __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startWriting(ByteBuffer __a, OutputRoundListener<
		UART, ByteBuffer> __b)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void startWriting(ByteBuffer __a, ByteBuffer __b, 
		OutputRoundListener<UART, ByteBuffer> __c)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stopReading()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stopWriting()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract int write(ByteBuffer __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-uart/jdk/dio/uart/UARTConfig.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class UARTConfig
	implements DeviceConfig<UART>, DeviceConfig.HardwareAddressing
{
	public static final int DATABITS_5 =
		5;
	
	public static final int DATABITS_6 =
		6;
	
	public static final int DATABITS_7 =
		7;
	
	public static final int DATABITS_8 =
		8;
	
	public static final int DATABITS_9 =
		9;
	
	public static final int FLOWCONTROL_NONE =
		0;
	
	public static final int FLOWCONTROL_RTSCTS_IN =
		1;
	
	public static final int FLOWCONTROL_RTSCTS_OUT =
		2;
	
	public static final int FLOWCONTROL_XONXOFF_IN =
		4;
	
	public static final int FLOWCONTROL_XONXOFF_OUT =
		8;
	
	public static final int PARITY_EVEN =
		2;
	
	public static final int PARITY_MARK =
		3;
	
	public static final int PARITY_NONE =
		0;
	
	public static final int PARITY_ODD =
		1;
	
	public static final int PARITY_SPACE =
		4;
	
	public static final int STOPBITS_1 =
		1;
	
	public static final int STOPBITS_1_5 =
		2;
	
	public static final int STOPBITS_2 =
		3;
	
	@Deprecated
	public UARTConfig(int __a, int __b, int __c, int __d, int __e, int __f, 
		int __g)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(int __a, int __b, int __c, int __d, int __e, int __f, 
		int __g, int __h, int __i)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(String __a, int __b, int __c, int __d, int __e, int __f
		, int __g)
	{
		super();
		throw new todo.TODO();
	}
	
	@Deprecated
	public UARTConfig(String __a, int __b, int __c, int __d, int __e, int __f
		, int __g, int __h, int __i)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public int getBaudRate()
	{
		throw new todo.TODO();
	}
	
	public int getChannelNumber()
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getDataBits()
	{
		throw new todo.TODO();
	}
	
	public int getFlowControlMode()
	{
		throw new todo.TODO();
	}
	
	public int getInputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getOutputBufferSize()
	{
		throw new todo.TODO();
	}
	
	public int getParity()
	{
		throw new todo.TODO();
	}
	
	public int getStopBits()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static UARTConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static final class Builder
	{
		public Builder()
		{
			super();
			throw new todo.TODO();
		}
		
		public UARTConfig build()
		{
			throw new todo.TODO();
		}
		
		public Builder setBaudRate(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setChannelNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerName(String __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setControllerNumber(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setDataBits(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setFlowControlMode(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setInputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setOutputBufferSize(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setParity(int __a)
		{
			throw new todo.TODO();
		}
		
		public Builder setStopBits(int __a)
		{
			throw new todo.TODO();
		}
	}
}


Deleted runt/apis/dio-uart/jdk/dio/uart/UARTEvent.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.DeviceEvent;

public class UARTEvent
	extends DeviceEvent<UART>
{
	public static final int BREAK_INTERRUPT =
		4;
	
	public static final int FRAMING_ERROR =
		16;
	
	public static final int INPUT_BUFFER_OVERRUN =
		1;
	
	public static final int INPUT_DATA_AVAILABLE =
		0;
	
	public static final int OUTPUT_BUFFER_EMPTY =
		2;
	
	public static final int PARITY_ERROR =
		8;
	
	public UARTEvent(UART __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public UARTEvent(UART __a, int __b, long __c, int __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getID()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-uart/jdk/dio/uart/UARTEventListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.DeviceEventListener;

public interface UARTEventListener
	extends DeviceEventListener
{
	public abstract void eventDispatched(UARTEvent __a);
}


Deleted runt/apis/dio-uart/jdk/dio/uart/UARTPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.uart;

import jdk.dio.DevicePermission;

public class UARTPermission
	extends DevicePermission
{
	public UARTPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public UARTPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-uart/jdk/dio/uart/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides access to UARTs.
 *
 * @since 2016/06/23
 */

package jdk.dio.uart;

Deleted runt/apis/dio-watchdog/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O (Watchdog)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides access to the watchdog.
X-SquirrelJME-Depends: dio
X-SquirrelJME-Error: DP
X-SquirrelJME-DefinedStandards: dio.watchdog;;1.0.1
X-SquirrelJME-UUID: 0b4cb53e-3479-4133-b6f3-9de977c1e8db
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/dio-watchdog/jdk/dio/watchdog/WatchdogTimer.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.watchdog;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.UnavailableDeviceException;

public interface WatchdogTimer
	extends Device<WatchdogTimer>
{
	public abstract boolean causedLastReboot()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract long getMaxTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract long getTimeout()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void refresh()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void start(long __a)
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract void stop()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
}


Deleted runt/apis/dio-watchdog/jdk/dio/watchdog/WatchdogTimerConfig.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.watchdog;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import jdk.dio.DeviceConfig;

public final class WatchdogTimerConfig
	implements DeviceConfig<WatchdogTimer>, DeviceConfig.HardwareAddressing
{
	public WatchdogTimerConfig(String __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public WatchdogTimerConfig(int __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getControllerName()
	{
		throw new todo.TODO();
	}
	
	public int getControllerNumber()
	{
		throw new todo.TODO();
	}
	
	public int getTimerNumber()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public int serialize(OutputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static WatchdogTimerConfig deserialize(InputStream __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-watchdog/jdk/dio/watchdog/WatchdogTimerPermission.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.watchdog;

import jdk.dio.DevicePermission;

public class WatchdogTimerPermission
	extends DevicePermission
{
	public WatchdogTimerPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public WatchdogTimerPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio-watchdog/jdk/dio/watchdog/WindowedWatchdogTimer.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.watchdog;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;

public interface WindowedWatchdogTimer
	extends WatchdogTimer
{
	public abstract long getClosedWindowTimeout()
		throws IOException, ClosedDeviceException;
	
	public abstract void start(long __a)
		throws IOException, ClosedDeviceException;
	
	public abstract void start(long __a, long __b)
		throws IOException, ClosedDeviceException;
}


Deleted runt/apis/dio-watchdog/jdk/dio/watchdog/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides access to watchdog interfaces.
 *
 * @since 2016/06/23
 */

package jdk.dio.watchdog;

Deleted runt/apis/dio/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: JavaME 8 Device I/O
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides the base support for devices 
 that may be provided by an implementation.
X-SquirrelJME-Depends: cldc
X-SquirrelJME-Error: CR
X-SquirrelJME-DefinedStandards: dio;;1.0.1
X-SquirrelJME-UUID: b45e9ac9-53bc-4e2a-9265-b5b5bca3d482
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/dio/jdk/dio/AsyncErrorHandler.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public interface AsyncErrorHandler<P extends Device<? super P>>
{
	public abstract void failed(Throwable __a, P __b);
}


Deleted runt/apis/dio/jdk/dio/BufferAccess.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;
import java.nio.Buffer;
import java.nio.ByteBuffer;

public interface BufferAccess<B extends Buffer>
{
	public abstract B getInputBuffer()
		throws ClosedDeviceException, IOException;
	
	public abstract B getOutputBuffer()
		throws ClosedDeviceException, IOException;
	
	public abstract B prepareBuffer(ByteBuffer __a, int __b)
		throws IOException, ClosedDeviceException;
}


Deleted runt/apis/dio/jdk/dio/ClosedDeviceException.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.channels.ClosedChannelException;

public class ClosedDeviceException
	extends ClosedChannelException
{
	public ClosedDeviceException()
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/Device.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;
import java.nio.ByteOrder;
import java.nio.channels.Channel;

public interface Device<P extends Device<? super P>>
	extends Channel
{
	public static final int BIG_ENDIAN =
		1;
	
	public static final int LITTLE_ENDIAN =
		0;
	
	public static final int MIXED_ENDIAN =
		2;
	
	public abstract void close()
		throws IOException;
	
	public abstract ByteOrder getByteOrder()
		throws IOException, UnavailableDeviceException, 
			ClosedDeviceException;
	
	public abstract <U extends P> DeviceDescriptor<U> getDescriptor();
	
	public abstract boolean isOpen();
	
	public abstract void tryLock(int __a)
		throws UnavailableDeviceException, ClosedDeviceException, 
			IOException;
	
	public abstract void unlock()
		throws IOException;
}


Deleted runt/apis/dio/jdk/dio/DeviceAlreadyExistsException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class DeviceAlreadyExistsException
	extends DeviceException
{
	public DeviceAlreadyExistsException()
	{
		super();
		throw new todo.TODO();
	}
	
	public DeviceAlreadyExistsException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceConfig.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;
import java.io.OutputStream;

public interface DeviceConfig<P extends Device<? super P>>
{
	@Deprecated
	public static final int DEFAULT =
		-1;
	
	public static final int UNASSIGNED =
		-1;
	
	public abstract int serialize(OutputStream __a)
		throws IOException;
	
	public static interface HardwareAddressing
	{
		public abstract String getControllerName();
		
		public abstract int getControllerNumber();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceDescriptor.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public interface DeviceDescriptor<P extends Device<? super P>>
{
	public static final int UNDEFINED_ID =
		-1;
	
	public abstract <C extends DeviceConfig<? super P>> C getConfiguration();
	
	public abstract int getID();
	
	public abstract Class<P> getInterface();
	
	public abstract String getName();
	
	public abstract String[] getProperties();
}


Deleted runt/apis/dio/jdk/dio/DeviceEvent.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public abstract class DeviceEvent<P extends Device<? super P>>
{
	protected int count;
	
	protected P device;
	
	protected long lastTimeStamp;
	
	protected int lastTimeStampMicros;
	
	protected long timeStamp;
	
	protected int timeStampMicros;
	
	public DeviceEvent()
	{
		super();
		throw new todo.TODO();
	}
	
	public final int getCount()
	{
		throw new todo.TODO();
	}
	
	public final P getDevice()
	{
		throw new todo.TODO();
	}
	
	public final long getLastTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public final int getLastTimeStampMicros()
	{
		throw new todo.TODO();
	}
	
	public final long getTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public final int getTimeStampMicros()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceEventListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public interface DeviceEventListener
{
}


Deleted runt/apis/dio/jdk/dio/DeviceException.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;

public class DeviceException
	extends IOException
{
	public DeviceException()
	{
		super();
		throw new todo.TODO();
	}
	
	public DeviceException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259



































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;
import java.util.Iterator;

public class DeviceManager
{
	public static final int EXCLUSIVE =
		1;
	
	public static final int SHARED =
		2;
	
	public static final int UNSPECIFIED_ID =
		-1;
	
	private DeviceManager()
	{
		super();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> void addRegistrationListener(
		RegistrationListener<P> __a, Class<P> __b)
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> Iterator<DeviceDescriptor<P>>
		list()
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> Iterator<DeviceDescriptor<P>>
		list(Class<P> __a)
	{
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(Class<P> __a, 
		DeviceConfig<? super P> __b)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(Class<P> __a, 
		DeviceConfig<? super P> __b, int __c)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a)
		throws IOException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, Class<P> __b)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, Class<P> __b,
		int __c)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException, 
			UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(int __a, int __b)
		throws IOException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(DeviceConfig<? super P
		> __a)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(DeviceConfig<? super P
		> __a, int __b)
		throws IOException, InvalidDeviceConfigException, 
			UnsupportedDeviceTypeException, DeviceNotFoundException, 
			UnavailableDeviceException, UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(String __a, Class<P> 
		__b, int __c, String... __d)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException, 
			UnsupportedAccessModeException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new UnsupportedAccessModeException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> P open(String __a, Class<P> 
		__b, String... __c)
		throws IOException, UnsupportedDeviceTypeException, 
			DeviceNotFoundException, UnavailableDeviceException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new UnavailableDeviceException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> int register(int __a, Class<P
		> __b, DeviceConfig<? super P> __c, String __d, String... __e)
		throws IOException, UnsupportedDeviceTypeException, 
			InvalidDeviceConfigException, DeviceNotFoundException, 
			DeviceAlreadyExistsException
	{
		if (false)
			throw new IOException();
		if (false)
			throw new UnsupportedDeviceTypeException();
		if (false)
			throw new InvalidDeviceConfigException();
		if (false)
			throw new DeviceNotFoundException();
		if (false)
			throw new DeviceAlreadyExistsException();
		throw new todo.TODO();
	}
	
	public static <P extends Device<? super P>> void 
		removeRegistrationListener(RegistrationListener<P> __a, Class<P> __b)
	{
		throw new todo.TODO();
	}
	
	public static void unregister(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceMgmtPermission.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




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.security.Permission;
import java.security.PermissionCollection;

public class DeviceMgmtPermission
	extends Permission
{
	public static final String OPEN =
		"open";
	
	public static final String REGISTER =
		"register";
	
	public static final String UNREGISTER =
		"unregister";
	
	public DeviceMgmtPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DeviceNotFoundException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class DeviceNotFoundException
	extends DeviceException
{
	public DeviceNotFoundException()
	{
		super();
		throw new todo.TODO();
	}
	
	public DeviceNotFoundException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/DevicePermission.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.security.Permission;
import java.security.PermissionCollection;

public abstract class DevicePermission
	extends Permission
{
	public static final String OPEN =
		"open";
	
	public static final String POWER_MANAGE =
		"powermanage";
	
	public DevicePermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public DevicePermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
	
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/InputRoundListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.Buffer;

public interface InputRoundListener<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEventListener, AsyncErrorHandler<P>
{
	public abstract void inputRoundCompleted(RoundCompletionEvent<P, B> __a);
}


Deleted runt/apis/dio/jdk/dio/InvalidDeviceConfigException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class InvalidDeviceConfigException
	extends DeviceException
{
	public InvalidDeviceConfigException()
	{
		super();
		throw new todo.TODO();
	}
	
	public InvalidDeviceConfigException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/OutputRoundListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.Buffer;

public interface OutputRoundListener<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEventListener, AsyncErrorHandler<P>
{
	public abstract void outputRoundCompleted(RoundCompletionEvent<P, B> __a
		);
}


Deleted runt/apis/dio/jdk/dio/RegistrationEvent.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.util.EventObject;

public class RegistrationEvent<P extends Device<? super P>>
	extends EventObject
{
	public RegistrationEvent(String __a, DeviceDescriptor<P> __b)
	{
		super((Object)null);
		throw new todo.TODO();
	}
	
	public RegistrationEvent(DeviceDescriptor<P> __a)
	{
		super((Object)null);
		throw new todo.TODO();
	}
	
	public DeviceDescriptor<P> getDescriptor()
	{
		throw new todo.TODO();
	}
	
	public String getInitiator()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/RegistrationListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.util.EventListener;

public interface RegistrationListener<P extends Device<? super P>>
	extends EventListener
{
	public abstract void deviceRegistered(RegistrationEvent<P> __a);
	
	public abstract void deviceUnregistered(RegistrationEvent<P> __a);
}


Deleted runt/apis/dio/jdk/dio/RoundCompletionEvent.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




























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.nio.Buffer;

public class RoundCompletionEvent<P extends Device<? super P>, B extends 
	Buffer>
	extends DeviceEvent<P>
{
	public RoundCompletionEvent(P __a, B __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, long __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, boolean __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public RoundCompletionEvent(P __a, B __b, int __c, boolean __d, long __e,
		int __f)
	{
		super();
		throw new todo.TODO();
	}
	
	public B getBuffer()
	{
		throw new todo.TODO();
	}
	
	public int getNumber()
	{
		throw new todo.TODO();
	}
	
	public boolean isOnError()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/Transactional.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;

import java.io.IOException;

public interface Transactional
{
	public abstract void begin()
		throws ClosedDeviceException, IOException;
	
	public abstract void end()
		throws ClosedDeviceException, IOException;
}


Deleted runt/apis/dio/jdk/dio/UnavailableDeviceException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class UnavailableDeviceException
	extends DeviceException
{
	public UnavailableDeviceException()
	{
		super();
		throw new todo.TODO();
	}
	
	public UnavailableDeviceException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/UnsupportedAccessModeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class UnsupportedAccessModeException
	extends DeviceException
{
	public UnsupportedAccessModeException()
	{
		super();
		throw new todo.TODO();
	}
	
	public UnsupportedAccessModeException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/UnsupportedByteOrderException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class UnsupportedByteOrderException
	extends DeviceException
{
	public UnsupportedByteOrderException()
	{
		super();
		throw new todo.TODO();
	}
	
	public UnsupportedByteOrderException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/UnsupportedDeviceTypeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio;


public class UnsupportedDeviceTypeException
	extends DeviceException
{
	public UnsupportedDeviceTypeException()
	{
		super();
		throw new todo.TODO();
	}
	
	public UnsupportedDeviceTypeException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the base package for the device I/O support.
 *
 * @since 2016/06/23
 */

package jdk.dio;

Deleted runt/apis/dio/jdk/dio/power/PowerManaged.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.power;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;

public interface PowerManaged
{
	public static final int LOWEST_POWER =
		4;
	
	public static final int LOW_POWER =
		2;
	
	public static final int POWER_OFF =
		8;
	
	public static final int POWER_ON =
		1;
	
	public static final long UNLIMITED_DURATION =
		-1L;
	
	public abstract void disablePowerSaving()
		throws IOException, ClosedDeviceException;
	
	public abstract void enablePowerSaving(int __a)
		throws IOException, ClosedDeviceException;
	
	public abstract void enablePowerSaving(int __a, PowerSavingHandler __b)
		throws IOException, ClosedDeviceException;
	
	public abstract PowerManaged.Group getGroup()
		throws IOException, ClosedDeviceException;
	
	public abstract int getPowerState()
		throws IOException, ClosedDeviceException;
	
	public abstract long requestPowerStateChange(int __a, long __b)
		throws IOException, ClosedDeviceException;
	
	public static interface Group
	{
		public abstract boolean contains(PowerManaged __a)
			throws IOException, ClosedDeviceException;
		
		public abstract void setPowerSavingHandler(PowerSavingHandler __a
			)
			throws IOException, ClosedDeviceException;
	}
}


Deleted runt/apis/dio/jdk/dio/power/PowerSavingHandler.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.power;

import jdk.dio.Device;

public interface PowerSavingHandler
{
	public abstract <P extends Device<? super P>> void handlePowerStateChange
		(P __a, PowerManaged.Group __b, int __c, int __d, long __e);
	
	public abstract <P extends Device<? super P>> long 
		handlePowerStateChangeRequest(P __a, PowerManaged.Group __b, int __c,
		int __d, long __e);
}


Deleted runt/apis/dio/jdk/dio/power/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains interfaces related to power management of devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.power;

Deleted runt/apis/dio/jdk/dio/spi/AbstractDevice.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spi;

import java.io.IOException;
import jdk.dio.ClosedDeviceException;
import jdk.dio.Device;
import jdk.dio.DeviceDescriptor;
import jdk.dio.UnavailableDeviceException;

public abstract class AbstractDevice<P extends Device<? super P>>
	implements Device<P>
{
	public AbstractDevice()
	{
		super();
		throw new todo.TODO();
	}
	
	public final <U extends P> DeviceDescriptor<U> getDescriptor()
	{
		throw new todo.TODO();
	}
	
	public void tryLock(int __a)
		throws UnavailableDeviceException, ClosedDeviceException, 
			IOException
	{
		if (false)
			throw new UnavailableDeviceException();
		if (false)
			throw new ClosedDeviceException();
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public void unlock()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/dio/jdk/dio/spi/DeviceProvider.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package jdk.dio.spi;

import java.io.InputStream;
import java.io.IOException;
import jdk.dio.Device;
import jdk.dio.DeviceConfig;
import jdk.dio.DeviceNotFoundException;
import jdk.dio.InvalidDeviceConfigException;
import jdk.dio.UnavailableDeviceException;
import jdk.dio.UnsupportedAccessModeException;

public interface DeviceProvider<P extends Device<? super P>>
{
	public abstract DeviceConfig<? super P> deserialize(InputStream __a)
		throws IOException;
	
	public abstract Class<? extends DeviceConfig<? super P>> getConfigType();
	
	public abstract Class<P> getType();
	
	public abstract boolean matches(String[] __a);
	
	public abstract AbstractDevice<? super P> open(DeviceConfig<? super P> 
		__a, String[] __b, int __c)
		throws DeviceNotFoundException, UnavailableDeviceException, 
			InvalidDeviceConfigException, UnsupportedAccessModeException, 
			IOException;
}


Deleted runt/apis/dio/jdk/dio/spi/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This provides service management support for devices.
 *
 * @since 2016/06/23
 */

package jdk.dio.spi;

Deleted runt/apis/gcf/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: Generic Connection Framework
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: meep-midlet
X-SquirrelJME-Description: This projects contains the Generic 
 connection framework which is used to create connections to other 
 resources.
X-SquirrelJME-Error: EC
X-SquirrelJME-UUID: 1358142d-037f-4421-9a52-0534764a45d3
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/ConnectionStateTracker.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This is a tracker for the connection state.
 *
 * @since 2019/05/13
 */
public final class ConnectionStateTracker
{
	/** Has the input been closed? */
	boolean _inclosed;
	
	/** Has the output been closed? */
	boolean _outclosed;
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/FileAddress.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This is an address which represents a file.
 *
 * @since 2019/05/06
 */
public final class FileAddress
	implements SocketAddress
{
	/** The file. */
	public final String file;
	
	/**
	 * Initializes the file address.
	 *
	 * @param __p The file path.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public FileAddress(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Decode the path
		this.file = FileAddress.stringDecode(__p);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final String toString()
	{
		return this.file;
	}
	
	/**
	 * Decodes the specified string to handle the path.
	 *
	 * @param __p The path.
	 * @return The decoded path.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final String stringDecode(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Build new decoded path
		StringBuilder sb = new StringBuilder();
		for (int i = 0, n = __p.length(); i < n;)
		{
			int c = __p.charAt(i++);
			
			// Potentially condense slashes
			if (c == '/')
			{
				// Do not condense
				int sbl = sb.length();
				if (sbl > 0 && sb.charAt(sbl - 1) == '/')
					continue;
				
				// Add slash
				sb.append('/');
			}
			
			// Percent encoded
			else if (c == '%')
			{
				throw new todo.TODO();
			}
			
			// Directly usable
			else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
				(c >= '0' && c <= '9') || c == ':' || c == '@' || c == '-' ||
				c == '.' || c == '_' || c == '~' || c == '!' || c == '$' ||
				c == '&' || c == '\'' || c == '(' || c == ')' || c == '*' ||
				c == '+' || c == ',' || c == ';' || c == '=')
				sb.append((char)c);
			
			// {@squirreljme.error EC01 Path contains invalid character.
			// (The path)}
			else
				throw new IllegalArgumentException("EC01 " + __p);
		}
		
		// Done
		return sb.toString();
	}
	
	/**
	 * Decodes and build the file address.
	 *
	 * @param __p The string address.
	 * @return The resulting file address.
	 * @throws IllegalArgumentException If the path is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final FileAddress of(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return new FileAddress(__p);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPAddress.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
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

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This represents an IP address.
 *
 * @since 2019/05/06
 */
public final class HTTPAddress
	implements SocketAddress
{
	/** The IP Address. */
	public final IPAddress ipaddr;
	
	/** The file. */
	public final FileAddress file;
	
	/** The query. */
	public final String query;
	
	/** The fragment. */
	public final String fragment;
	
	/**
	 * Initializes the HTTP Address.
	 *
	 * @param __ip The IP address.
	 * @param __file The file.
	 * @param __query The query, may be {@code null}.
	 * @param __frag The fragment, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public HTTPAddress(IPAddress __ip, FileAddress __file, String __query,
		String __frag)
		throws NullPointerException
	{
		if (__ip == null || __file == null)
			throw new NullPointerException("NARG");
		
		this.ipaddr = __ip;
		this.file = __file;
		this.query = __query;
		this.fragment = __frag;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Decodes an address from the URI part.
	 *
	 * @param __p The part to decode from.
	 * @return The HTTP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final HTTPAddress fromUriPart(String __p)
		throws IllegalArgumentException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EC02 HTTP address must start with double
		// slash. (The URI part)}
		if (!__p.startsWith("//"))
			throw new IllegalArgumentException("EC02 " + __p);
		__p = __p.substring(2);
		
		// Debug
		todo.DEBUG.note("Decode %s", __p);
		
		// Only contains the host part
		int sl = __p.indexOf('/');
		if (sl < 0)
			return new HTTPAddress(IPAddress.of(__p), FileAddress.of("/"),
				null, null);
		
		// Parse host portion
		IPAddress ipaddr = IPAddress.of(__p.substring(0, sl));
		
		// Parse remaining part, but keep the slash
		__p = __p.substring(sl);
		
		// Parse fragment
		String fragment;
		int fl = __p.indexOf('#');
		if (fl >= 0)
			throw new todo.TODO();
		
		// No fragment used
		else
			fragment = null;
		
		// Parse query
		String query;
		int ql = __p.indexOf('?');
		if (ql >= 0)
			throw new todo.TODO();
		
		// No query used
		else
			query = null;
		
		// Build remaining address
		return new HTTPAddress(ipaddr, FileAddress.of(__p), query, fragment);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPAgent.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.SocketConnection;

/**
 * This class manages the HTTP connection data and is able to encode and
 * establish a connection.
 *
 * @since 2019/05/13
 */
public final class HTTPAgent
	implements HTTPSignalListener
{
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** The state tracker. */
	protected final HTTPStateTracker tracker;
	
	/** The HTTP response. */
	HTTPResponse _response;
	
	/**
	 * Initializes the HTTP agent.
	 *
	 * @param __addr The address.
	 * @param __t The state tracker.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPAgent(HTTPAddress __addr, HTTPStateTracker __t)
		throws NullPointerException
	{
		if (__addr == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.address = __addr;
		this.tracker = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void requestReady(byte[] __data)
		throws IOException, NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Debug
		todo.DEBUG.note(" -> %d", __data.length);
		
		// Open connection to remote server
		byte[] response;
		try (SocketConnection socket = (SocketConnection)Connector.open(
			"socket://" + this.address.ipaddr))
		{
			// Connect to remote system and send all the HTTP data and
			// read it as well
			try (OutputStream out = socket.openOutputStream();
				InputStream in = socket.openInputStream())
			{
				// Write and send data
				out.write(__data, 0, __data.length);
				out.flush();
				
				// Read response data
				try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
					Math.max(1024, in.available())))
				{
					// Copy all input data
					byte[] buf = new byte[512];
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
					
					// Store for later decode
					response = baos.toByteArray();
				}
			}
		}
		
		// Failed read/write
		catch (IOException e)
		{
			// Debug
			e.printStackTrace();
			
			throw e;
		}
		
		// Parse the input
		this._response = HTTPResponse.parse(response);
		
		// Enter the connected state
		this.tracker._state = HTTPState.CONNECTED;
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPClientConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476




























































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.SocketConnection;
import javax.microedition.io.StreamConnection;

/**
 * This is a connection to a remote HTTP server, this runs off an existing
 * socket since it may be SSL encrypted. SquirrelJME does all the HTTP
 * handling since it could just be based on any existing stream connection
 * and does not need any other library.
 *
 * @since 2019/05/06
 */
public class HTTPClientConnection
	implements HttpConnection
{
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** Tracker for the HTTP state. */
	protected final HTTPStateTracker tracker =
		new HTTPStateTracker();
	
	/** The target HTTP agent which contains the response. */
	protected final HTTPAgent agent;
	
	/** Request builder for outgoing connections. */
	private HTTPRequestBuilder _request;
	
	/**
	 * Initializes the HTTP connection.
	 *
	 * @param __addr The address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public HTTPClientConnection(HTTPAddress __addr)
		throws NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		this.address = __addr;
		
		// Setup agents and handlers
		HTTPStateTracker tracker = this.tracker;
		HTTPAgent agent = new HTTPAgent(__addr, tracker);
		this.agent = agent;
		
		// Setup builder for the requests
		this._request = new HTTPRequestBuilder(__addr, tracker, agent);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Transition to the closed state
		this.tracker._state = HTTPState.CLOSED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final AccessPoint getAccessPoint()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getDate()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getEncoding()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getExpiration()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getFile()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderField(String __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderField(int __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getHeaderFieldDate(String __a, long __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getHeaderFieldInt(String __a, int __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHeaderFieldKey(int __a)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getHost()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getLastModified()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final long getLength()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getPort()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getProtocol()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getQuery()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRef()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRequestMethod()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getRequestProperty(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getResponseCode()
		throws IOException
	{
		return this.__response().header.code;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getResponseMessage()
		throws IOException
	{
		return this.__response().header.message;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getType()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getURL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataInputStream openDataInputStream()
		throws IOException
	{
		return new DataInputStream(this.openInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataOutputStream openDataOutputStream()
		throws IOException
	{
		return new DataOutputStream(this.openOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final InputStream openInputStream()
		throws IOException
	{
		// The response is the direct stream of the body
		return this.__response().inputStream();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final OutputStream openOutputStream()
		throws IOException
	{
		// This is the request stream directly
		return this.__request();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setRequestMethod(String __m)
		throws IOException, NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.__request().setRequestMethod(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setRequestProperty(String __k, String __v)
		throws IOException, NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.__request().setRequestProperty(__k, __v);
	}
	
	/**
	 * Attempts to obtain the request.
	 *
	 * @return The request information.
	 * @throws IOException If the connection was closed or is in connected
	 * state.
	 * @since 2019/05/13
	 */
	private final HTTPRequestBuilder __request()
		throws IOException
	{
		// {@squirreljme.error EC03 Cannot access the request
		if (this.tracker._state != HTTPState.SETUP)
		{
			// Clear before it is thrown
			this._request = null;
			
			// Toss
			throw new IOException("EC03");
		}
		
		// Return the request value
		return this._request;
	}
	
	/**
	 * Returns the response.
	 *
	 * @return The response.
	 * @throws IOException If the response could not be returned.
	 * @since 2019/05/13
	 */
	private HTTPResponse __response()
		throws IOException
	{
		HTTPAgent agent = this.agent;
		
		// Depends on the state
		HTTPStateTracker tracker = this.tracker;
		switch (tracker._state)
		{
				// Need to connect to the server, fall through to get the
				// agent response. Closing the request will send the HTTP
				// data over and load the server response
			case SETUP:
				this.__request().close();
			
				// Agent already has the response
			case CONNECTED:
			case CLOSED:
				return agent._response;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Connects to the given address using the given stream.
	 *
	 * @param __addr The address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final HTTPClientConnection connect(HTTPAddress __addr)
		throws NullPointerException
	{
		if (__addr == null)
			throw new NullPointerException("NARG");
		
		return new HTTPClientConnection(__addr);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPRequestBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266










































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This is used for building HTTP requests which will build the request to use
 * for the server.
 *
 * @since 2019/05/12
 */
public final class HTTPRequestBuilder
	extends OutputStream
{
	/** The user agent SquirrelJME uses. */
	public static final String USER_AGENT =
		"SquirrelJME/" + SquirrelJME.RUNTIME_VERSION + " " +
		"Configuration/CLDC-1.0 Configuration/CLDC-1.1 " +
		"Configuration/CLDC-1.8 Profile/MIDP-1.0 Profile/MIDP-2.0 " +
		"Profile/MIDP-2.1 Profile/MIDP-3.0 Profile/MEEP-8.0";
	
	/** The remote address. */
	protected final HTTPAddress address;
	
	/** The listener when the connection is closed. */
	protected final HTTPSignalListener listener;
	
	/** State tracker for connections. */
	protected final HTTPStateTracker tracker;
	
	/** Byte data output. */
	private final ByteArrayOutputStream _bytes =
		new ByteArrayOutputStream();
	
	/** Request properties. */
	private final Map<String, String> _rqprops =
		new LinkedHashMap<>();
	
	/** The connection method. */
	private String _rqmethod =
		"GET";
	
	/**
	 * Initializes the request builder.
	 *
	 * @param __addr The remote address.
	 * @param __st State tracker for HTTP connections.
	 * @param __l The agent listener.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPRequestBuilder(HTTPAddress __addr, HTTPStateTracker __st,
		HTTPSignalListener __l)
		throws NullPointerException
	{
		if (__l == null || __st == null || __addr == null)
			throw new NullPointerException("NARG");
		
		this.listener = __l;
		this.tracker = __st;
		this.address = __addr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Only close once
		if (this.tracker._state != HTTPState.SETUP)
			return;
		
		// Send the agent out request bytes
		this.listener.requestReady(this.getBytes());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// {@squirreljme.error EC04 Cannot flush closed HTTP stream.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC04");
		
		// Note
		todo.TODO.note("Implement HTTP Flush");
	}
	
	/**
	 * Builds the bytes for the request.
	 *
	 * @return The bytes to send down the stream.
	 * @throws IOException If they could not be set.
	 * @since 2019/05/13
	 */
	public final byte[] getBytes()
		throws IOException
	{
		HTTPAddress address = this.address;
		
		// Build output
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Get any written data
			byte[] bytes = this._bytes.toByteArray();
			
			// Print header data, note that CRLF is used everywhere regardless
			// of whether the system uses it or not
			try (PrintStream ps = new PrintStream(baos, true, "utf-8"))
			{
				// HTTP header
				ps.printf("%s %s HTTP/1.1\r\n",
					this._rqmethod, address.file);
				
				// Add some implicit properties
				Map<String, String> rqp = new LinkedHashMap<>(this._rqprops);
				rqp.put("host", address.ipaddr.hostname);
				
				// If the user agent was specified, add to it or set one
				String ua = rqp.get("user-agent");
				rqp.put("user-agent", (ua == null ? USER_AGENT :
					ua + USER_AGENT));
				
				// Is content being specified?
				if (bytes != null)
					rqp.put("content-length", Integer.toString(bytes.length));
				
				// Write headers
				for (Map.Entry<String, String> e : rqp.entrySet())
					ps.printf("%s: %s\r\n", e.getKey(), e.getValue());
				
				// End of header
				ps.print("\r\n");
				
				// Flush to make sure nothing is buffered
				ps.flush();
			}
			
			// Write any data
			if (bytes != null)
				baos.write(bytes, 0, bytes.length);
			
			// Build
			return baos.toByteArray();
		}
	}
	
	/**
	 * Sets the request method to use.
	 *
	 * @param __m The method to use.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If no method was specified.
	 * @since 2019/05/13
	 */
	public final void setRequestMethod(String __m)
		throws IOException, NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._rqmethod = __m.toUpperCase();
	}
	
	/**
	 * Adds or replaces an existing request property, note that for multiple
	 * request property specifications they need to manually be comma
	 * separated.
	 *
	 * @param __k The request header key.
	 * @param __v The value to use, {@code null} clears.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If the key was null.
	 * @since 2019/05/13
	 */
	public final void setRequestProperty(String __k, String __v)
		throws IOException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		// All fields are case insensitive, so lowercase them!
		__k = __k.toLowerCase();
		
		// Clear?
		Map<String, String> rqprops = this._rqprops;
		if (__v == null)
			rqprops.remove(__k);
		
		// Otherwise add
		else
			rqprops.put(__k, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error EC05 Cannot write more HTTP data.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC05");
		
		// Write to bytes
		this._bytes.write(__b);
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __a)
		throws IOException, NullPointerException
	{
		this.write(__a, 0, __a.length);
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final void write(byte[] __a, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error EC06 Cannot write more HTTP data.}
		if (this.tracker._state != HTTPState.SETUP)
			throw new IOException("EC06");
		
		// Write to bytes
		this._bytes.write(__a, __o, __l);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPResponse.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
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



































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;

/**
 * This contains the response of the HTTP request.
 *
 * @since 2019/05/13
 */
public final class HTTPResponse
{
	/** The header. */
	public final HTTPResponseHeader header;
	
	/** The data bytes. */
	private final byte[] _data;
	
	/**
	 * Initializes the response.
	 *
	 * @param __h The header.
	 * @param __d The data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPResponse(HTTPResponseHeader __h, byte[] __d)
		throws NullPointerException
	{
		if (__h == null || __d == null)
			throw new NullPointerException("NARG");
		
		this.header = __h;
		this._data = __d.clone();
	}
	
	/**
	 * Returns the input stream of the body data.
	 *
	 * @return The input stream for the body.
	 * @since 2019/05/13
	 */
	public final InputStream inputStream()
	{
		return new ByteArrayInputStream(this._data);
	}
	
	/**
	 * Parses the HTTP response.
	 *
	 * @param __b The input bytes.
	 * @return The parsed response.
	 * @throws IOException If the response is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponse parse(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return HTTPResponse.parse(new ByteArrayInputStream(__b));
	}
	
	/**
	 * Parses the HTTP response.
	 *
	 * @param __in The input bytes.
	 * @return The parsed response.
	 * @throws IOException If the response is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponse parse(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse the header first
		HTTPResponseHeader header = HTTPResponseHeader.parse(__in);
		
		// Decode content length
		int length;
		try
		{
			// Decode length
			String rl = header.header("content-length");
			if (rl != null)
				length = Integer.parseInt(rl, 10);
			
			// Variable length...
			else
				length = -1;
		}
		
		// {@squirreljme.error EC07 Invalid content length.}
		catch (NumberFormatException e)
		{
			throw new IOException("EC07", e);
		}
		
		// Length of specific size
		byte[] bytes;
		if (length >= 0)
		{
			bytes = new byte[length];
			for (int at = 0; at < length;)
			{
				int rc = __in.read(bytes, at, length - at);
				
				// {@squirreljme.error EC08 The HTTP body was too small. (The
				// read length; The expected size)}
				if (rc < 0)
					throw new IOException("EC08 " + at + " " + length);
				
				// Move at up
				at += rc;
			}
		}
		
		// Variable length
		else
		{
			// Read in all the data
			byte[] buf = new byte[512];
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
			{
				for (;;)
				{
					int rc = __in.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Done
				bytes = baos.toByteArray();
			}
		}
		
		// Debug
		todo.DEBUG.note(" <- %d", bytes.length);
		
		// Build response
		return new HTTPResponse(header, bytes);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPResponseHeader.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
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
191
192
193
194
195
196
197
198






































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.InputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This contains the HTTP response header.
 *
 * @since 2019/05/13
 */
public final class HTTPResponseHeader
{
	/** The response code. */
	public final int code;
	
	/** The response message. */
	public final String message;
	
	/** Header key/values. */
	private final Map<String, String> _headers;
	
	/**
	 * Initializes the response header.
	 *
	 * @param __rcode The response code.
	 * @param __rmesg The response message.
	 * @param __hkvs Header key/value pairs.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public HTTPResponseHeader(int __rcode, String __rmesg,
		Map<String, String> __hkvs)
		throws NullPointerException
	{
		if (__rmesg == null || __hkvs == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.code = __rcode;
		this.message = __rmesg;
		
		// Copy header values
		Map<String, String> headers = new LinkedHashMap<>();
		for (Map.Entry<String, String> e : __hkvs.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			headers.put(k.trim().toLowerCase(),
				v.trim().toLowerCase());
		}
		this._headers = headers;
	}
	
	/**
	 * Obtains the specified header value.
	 *
	 * @param __k The header to get.
	 * @return The header value or {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public final String header(String __k)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this._headers.get(__k.toLowerCase());
	}
	
	/**
	 * Decodes the HTTP response header.
	 *
	 * @param __in The input bytes.
	 * @return The response header.
	 * @throws IOException On read errors or if the header is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public static final HTTPResponseHeader parse(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// HTTP headers
		int rcode = -1;
		String rmesg = "";
		Map<String, String> headers = new LinkedHashMap<>();
		
		// Decode the header line by line
		StringBuilder sb = new StringBuilder();
		for (int ln = 0;; ln++)
		{
			// Clear line
			sb.setLength(0);
			
			// Read until CRLF
			boolean cr = false;
			for (;;)
			{
				int c = __in.read();
				
				// EOF?
				if (c < 0)
					break;
				
				// Flag CR
				if (c == '\r')
					cr = true;
				
				// Read CRLF, line is complete?
				else if (cr && c == '\n')
					break;
				
				// Just another character
				else
				{
					sb.append((char)c);
					cr = false;
				}
			}
			
			// End of header?
			if (sb.length() <= 0)
				break;
			
			// Decode status line?
			String line = sb.toString();
			if (ln == 0)
			{
				// {@squirreljme.error EC09 Invalid status line. (The line)}
				if (!line.startsWith("HTTP/1.0 ") &&
					!line.startsWith("HTTP/1.1 "))
					throw new IOException("EC09 " + line);
				
				// Clip off
				line = line.substring(9);
				
				try
				{
					// Code and response message
					int sp = line.indexOf(' ');
					if (sp >= 0)
					{
						rcode = Integer.parseInt(line.substring(0, sp), 10);
						rmesg = line.substring(sp + 1);
					}
					
					// Just the code
					else
					{
						rcode = Integer.parseInt(line.substring(0, sp), 10);
						rmesg = "";
					}
				}
				
				// {@squirreljme.error EC0a Invalid HTTP status code. (Line)}
				catch (NumberFormatException e)
				{
					throw new IOException("EC0a " + line);
				}
			}
			
			// A header key/value otherwise
			else
			{
				// {@squirreljme.error EC0b Invalid header pair. (The line)}
				int lc = line.indexOf(':');
				if (lc < 0)
					throw new IOException("EC0b " + line);
				
				// Put in header
				headers.put(line.substring(0, lc),
					line.substring(lc + 1));
			}
		}
		
		// Build headed
		return new HTTPResponseHeader(rcode, rmesg, headers);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPSignalListener.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.IOException;

/**
 * This interface is used to signal changes in the HTTP state such as
 * when a connection should be made.
 *
 * @since 2019/05/13
 */
public interface HTTPSignalListener
{
	/**
	 * Tells the other end that the HTTP request data is ready.
	 *
	 * @param __data The data of the request.
	 * @throws IOException If the request could not be sent.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public abstract void requestReady(byte[] __data)
		throws IOException, NullPointerException;
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPState.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This represents a state of the HTTP connection.
 *
 * @since 2019/05/12
 */
public enum HTTPState
{
	/** Setup, before a connection is made. */
	SETUP,
	
	/** Connected to remote HTTP server. */
	CONNECTED,
	
	/** Connection is closed. */
	CLOSED,
	
	/** End. */
	;
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/HTTPStateTracker.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This is used to track the state of the HTTP connection since it must be
 * shared across many classes for HTTP.
 *
 * @since 2019/05/13
 */
public final class HTTPStateTracker
{
	/** The state of this connection. */
	HTTPState _state =
		HTTPState.SETUP;
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/IPAddress.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228




































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is an immutable class which represents an IP address and possibly the
 * port.
 *
 * @since 2019/05/06
 */
public final class IPAddress
	implements SocketAddress
{
	/** System assigned port. */
	public static final int ASSIGNED_PORT =
		-1;
	
	/** The hostname. */
	public final String hostname;
	
	/** The port. */
	public final int port;
	
	/** The string reference. */
	private Reference<String> _string;
	
	/**
	 * Initializes the address.
	 *
	 * @param __h The hostname, may be {@code null}.
	 * @param __p The port, may be {@link ASSIGNED_PORT}.
	 * @throws IllegalArgumentException If the hostname or port is not valid.
	 * @since 2019/05/06
	 */
	public IPAddress(String __h, int __p)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EC0c IP port out of range. (The port)}
		if (__p != ASSIGNED_PORT && __p < 0 || __p > 65535)
			throw new IllegalArgumentException("EC0c " + __p);
		
		// {@squirreljme.error EC0d No IP address was specified.}
		if (__h == null && __p == ASSIGNED_PORT)
			throw new IllegalArgumentException("EC0d");
		
		// Validate hostname
		if (__h != null)
		{
			// Make it lowercase
			__h = __h.toLowerCase();
			
			// Is this an IPv6 address?
			boolean isvsix;
			String checkpart;
			if ((isvsix = __h.startsWith("[")))
			{
				// {@squirreljme.error EC0e IPv6 address must end in bracket.
				// (The hostname)}
				if (!__h.endsWith("]"))
					throw new IllegalArgumentException("EC0e " + __h);
				
				// Only check the insides
				checkpart = __h.substring(1, __h.length() - 1);
			}
			
			// Not one
			else
				checkpart = __h;
			
			// Check characters
			for (int i = 0, n = checkpart.length(); i < n; i++)
			{
				int c = checkpart.charAt(i);
				
				// {@squirreljme.error EC0f Hostname has an invalid
				// character. (The hostname)}
				if (!((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
					c == '-' || c == '.' || (isvsix && c == ':')))
					throw new IllegalArgumentException("EC0f " + __h);
			}
		}
		
		// Set
		this.hostname = __h;
		this.port = __p;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this a server connection?
	 *
	 * @return If this is a server connection.
	 * @since 2019/05/06
	 */
	public final boolean isServer()
	{
		return this.hostname == null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			String hostname = this.hostname;
			int port = this.port;
			
			// Include the port or not?
			if (hostname == null)
				rv = ":" + port;
			else if (port == ASSIGNED_PORT)
				rv = hostname;
			else
				rv = hostname + ":" + port;
			
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * Creates an address from a URI part.
	 *
	 * @param __part The URI part.
	 * @return The resulting IP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final IPAddress fromUriPart(String __part)
		throws IllegalArgumentException, NullPointerException
	{
		if (__part == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EC0g IP Address must start with double
		// slash. (The URI part)}
		if (!__part.startsWith("//"))
			throw new IllegalArgumentException("EC0g " + __part);
		
		// Parse
		return IPAddress.of(__part.substring(2));
	}
	
	/**
	 * Creates an address from the given string.
	 *
	 * @param __s The input string
	 * @return The resulting IP address.
	 * @throws IllegalArgumentException If the address is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public static final IPAddress of(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// The port could be weird
		try
		{
			// Need to detect that an IPv6 address is being used
			int col = __s.lastIndexOf(':'),
				eb = __s.lastIndexOf(']');
			if (eb >= 0 && eb > col)
				col = -1;
			
			// Just has a hostname?
			if (col < 0)
				return new IPAddress(__s, ASSIGNED_PORT);
			
			// Just has the port
			else if (col == 0)
				return new IPAddress(null,
					Integer.parseInt(__s.substring(1), 10));
			
			// Has both
			else
				return new IPAddress(__s.substring(0, col),
					Integer.parseInt(__s.substring(col + 1), 10));
		}
		
		// {@squirreljme.error EC0h Invalid port number. (The URI part)}
		catch (NumberFormatException e)
		{
			throw new IllegalArgumentException("EC0h " + __s, e);
		}
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/IPConnectionFactory.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import java.io.IOException;
import java.util.ServiceLoader;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.SocketConnection;

/**
 * This factory is used in the creation of IP based connections thus allowing
 * SquirrelJME access to the internet.
 *
 * @since 2019/05/12
 */
public abstract class IPConnectionFactory
{
	/** The existing connection factory. */
	private static volatile IPConnectionFactory _FACTORY;
	
	/**
	 * Resolves the specified IP address.
	 *
	 * @param __addr The IP address.
	 * @throws ConnectionNotFoundException If the host was not found.
	 * @throws IOException If the address could not resolved.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public abstract IPAddress resolveAddress(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException;
	
	/**
	 * Opens a TCP client connection to the remote address.
	 *
	 * @param __addr The address to connect to.
	 * @return The connection.
	 * @throws ConnectionNotFoundException If the connection was not found.
	 * @throws IOException On connection issues.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public abstract TCPClientConnection tcpClientConnect(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException;
	
	/**
	 * Returns the factory which manages IP based connections.
	 *
	 * @return The IP connection factory.
	 * @since 2019/05/12
	 */
	public static IPConnectionFactory factory()
	{
		// Already created?
		IPConnectionFactory rv = IPConnectionFactory._FACTORY;
		
		// Create factory?
		if (rv == null)
			synchronized (IPConnectionFactory.class)
			{
				// Check for double create
				rv = IPConnectionFactory._FACTORY;
				if (rv != null)
					return rv;
				
				// Use implementation for this
				String ipf = SystemProperties.implementationClass(
					"cc.squirreljme.runtime.gcf.IPConnectionFactory");
				if (ipf != null)
					try
					{
						rv = (IPConnectionFactory)Class.forName(ipf).
							newInstance();
					}
					catch (ClassNotFoundException|InstantiationException|
						IllegalAccessException e)
					{
						e.printStackTrace();
					}
				
				// Use the first found service
				if (rv == null)
					for (IPConnectionFactory mb : ServiceLoader.
						<IPConnectionFactory>load(IPConnectionFactory.class))
					{
						rv = mb;
						break;
					}
				
				// Fallback to no connection factory (IP not supported)
				if (rv == null)
					rv = new NullIPConnectionFactory();
				
				// Use it for later and return
				IPConnectionFactory._FACTORY = rv;
			}
		
		return rv;
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/NullIPConnectionFactory.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.IOException;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.SocketConnection;

/**
 * This is a connection factory which does not support any IP based
 * connections. Any attempt to open any kind of connection will result in
 * a connection not being made.
 *
 * @since 2019/05/12
 */
public final class NullIPConnectionFactory
	extends IPConnectionFactory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final IPAddress resolveAddress(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0i Host name resolution not supported.}
		throw new ConnectionNotFoundException("EC0i");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/12
	 */
	@Override
	public final TCPClientConnection tcpClientConnect(IPAddress __addr)
		throws ConnectionNotFoundException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0j TCP client connections are not
		// supported.}
		throw new ConnectionNotFoundException("EC0j");
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/SocketAddress.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

/**
 * This interface represents a generic address type.
 *
 * @since 2019/05/06
 */
public interface SocketAddress
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public abstract boolean equals(Object __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public abstract String toString();
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/TCPClientConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324




































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.AccessPoint;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.SocketConnection;

/**
 * This is a connection to a remote TCP server as a client.
 *
 * @since 2019/05/06
 */
public abstract class TCPClientConnection
	implements SocketConnection
{
	/** The used IP address. */
	protected final IPAddress ipaddr;
	
	/** State tracker. */
	protected final ConnectionStateTracker tracker =
		new ConnectionStateTracker();
	
	/**
	 * Initializes the TCP client connection.
	 *
	 * @param __ip The IP to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/12
	 */
	public TCPClientConnection(IPAddress __ip)
		throws NullPointerException
	{
		if (__ip == null)
			throw new NullPointerException("NARG");
		
		this.ipaddr = __ip;
	}
	
	/**
	 * Performs connection close.
	 *
	 * @throws IOException If it could not be closed.
	 * @since 2019/05/13
	 */
	protected abstract void doClose()
		throws IOException;
	
	/**
	 * Performs the actual input stream open.
	 *
	 * @return The resulting stream.
	 * @throws IOException If it could not be opened.
	 * @since 2019/05/13
	 */
	protected abstract InputStream doOpenInputStream()
		throws IOException;
	
	/**
	 * Performs the actual output stream open.
	 *
	 * @return The resulting stream.
	 * @throws IOException If it could not be opened.
	 * @since 2019/05/13
	 */
	protected abstract OutputStream doOpenOutputStream()
		throws IOException;
	
	/**
	 * Sets an option for the socket.
	 *
	 * @param __o The option to use.
	 * @param __v The value to use.
	 * @throws IllegalArgumentException If the option is not valid.
	 * @throws IOException If it could not be set.
	 * @since 2019/05/12
	 */
	protected abstract void doSetSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Tracker knows if the streams have been closed...
		ConnectionStateTracker tracker = this.tracker;
		
		// Close input
		IOException supin = null;
		if (!tracker._inclosed)
			try
			{
				this.openInputStream().close();
			}
			catch (IOException e)
			{
				supin = e;
			}
		
		// Close output
		IOException supout = null;
		if (!tracker._outclosed)
			try
			{
				this.openOutputStream().close();
			}
			catch (IOException e)
			{
				supout = e;
			}
		
		// Forward close
		IOException supclo = null;
		try
		{
			this.doClose();
		}
		catch (IOException e)
		{
			supclo = e;
		}
		
		// Set tracker as closed
		tracker._inclosed = true;
		tracker._outclosed = true;
		
		// Exceptions were thrown?
		if (supin != null || supout != null || supclo != null)
		{
			// {@squirreljme.error EC0k The connection could not be closed
			// properly.}
			IOException t = new IOException("EC0k");
			
			// Add suppressed exceptions
			if (supin != null)
				t.addSuppressed(supin);
			if (supout != null)
				t.addSuppressed(supout);
			if (supclo != null)
				t.addSuppressed(supclo);
			
			// Toss it
			throw t;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final AccessPoint getAccessPoint()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getAddress()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final String getLocalAddress()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getLocalPort()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getPort()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final int getSocketOption(byte __o)
		throws IllegalArgumentException, IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataInputStream openDataInputStream()
		throws IOException
	{
		return new DataInputStream(this.openInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final DataOutputStream openDataOutputStream()
		throws IOException
	{
		return new DataOutputStream(this.openOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final InputStream openInputStream()
		throws IOException
	{
		// {@squirreljme.error EC0l The input has been closed.}
		ConnectionStateTracker tracker = this.tracker;
		if (tracker._inclosed)
			throw new IOException("EC0l");
		return new TrackedInputStream(tracker, this.doOpenInputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final OutputStream openOutputStream()
		throws IOException
	{
		// {@squirreljme.error EC0m The output has been closed.}
		ConnectionStateTracker tracker = this.tracker;
		if (tracker._outclosed)
			throw new IOException("EC0m");
		return new TrackedOutputStream(tracker, this.doOpenOutputStream());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public final void setSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException
	{
		// {@squirreljme.error EC0n Invalid socket option. (The option)}
		if (__o != KEEPALIVE || __o != LINGER || __o != SNDBUF ||
			__o != RCVBUF || __o != DELAY || __o != TIMEOUT)
			throw new IllegalArgumentException("EC0n " + __o);
		
		// Check options
		switch (__o)
		{
			case LINGER:
				// {@squirreljme.error EC0o Linger cannot be negative.
				// (The requested linger)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0o " + __v);
				break;
			
			case RCVBUF:
			case SNDBUF:
				// {@squirreljme.error EC0p Send/receive buffer size cannot
				// be negative. (The requested buffer size)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0p " + __v);
				break;
			
			case TIMEOUT:
				// {@squirreljme.error EC0q Timeout cannot be negative.
				// (The requested timeout)}
				if (__v < 0)
					throw new IllegalArgumentException("EC0q " + __v);
				break;
		}
		
		// Forward
		this.doSetSocketOption(__o, __v);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/TrackedInputStream.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
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







































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is an input which tracks if it has been closed, if EOF is read from
 * a stream then it will automatically be closed.
 *
 * @since 2019/05/13
 */
public final class TrackedInputStream
	extends InputStream
{
	/** The tracker used. */
	protected final ConnectionStateTracker tracker;
	
	/** The wrapped stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the tracked stream.
	 *
	 * @param __t The tracker.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public TrackedInputStream(ConnectionStateTracker __t, InputStream __in)
		throws NullPointerException
	{
		if (__t == null || __in == null)
			throw new NullPointerException("NARG");
		
		this.tracker = __t;
		this.in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int available()
		throws IOException
	{
		// {@squirreljme.error EC0r The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0r");
		
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Always close the input
		this.in.close();
		
		// Set stream as closed
		this.tracker._inclosed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read()
		throws IOException
	{
		// {@squirreljme.error EC0s The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0s");
		
		// Read data
		int rv = this.in.read();
		if (rv < 0)
			this.close();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		// {@squirreljme.error EC0t The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0t");
		
		// Read data
		int rv = this.in.read(__b);
		if (rv < 0)
			this.close();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		// {@squirreljme.error EC0u The input has been closed.}
		if (this.tracker._inclosed)
			throw new IOException("EC0u");
		
		// Read data
		int rv = this.in.read(__b, __o, __l);
		if (rv < 0)
			this.close();
		return rv;
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/TrackedOutputStream.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
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































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.gcf;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which keeps track if the connection has been
 * closed or not.
 *
 * @since 2019/05/13
 */
public final class TrackedOutputStream
	extends OutputStream
{
	/** The tracker used. */
	protected final ConnectionStateTracker tracker;
	
	/** The wrapped stream. */
	protected final OutputStream out;
	
	/**
	 * Initializes the tracked stream.
	 *
	 * @param __t The tracker.
	 * @param __out The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public TrackedOutputStream(ConnectionStateTracker __t, OutputStream __out)
		throws NullPointerException
	{
		if (__t == null || __out == null)
			throw new NullPointerException("NARG");
		
		this.tracker = __t;
		this.out = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Always close the output
		this.out.close();
		
		// Set stream as closed
		this.tracker._outclosed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// {@squirreljme.error EC0v The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0v");
		
		// Forward
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error EC0w The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0w");
		
		// Forward
		this.out.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		// {@squirreljme.error EC0x The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0x");
		
		// Forward
		this.out.write(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// {@squirreljme.error EC0y The output has been closed.}
		if (this.tracker._outclosed)
			throw new IOException("EC0y");
		
		// Forward
		this.out.write(__b, __o, __l);
	}
}

Deleted runt/apis/gcf/cc/squirreljme/runtime/gcf/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the default implementation of the GCF classes.
 *
 * @since 2016/10/12
 */

package cc.squirreljme.gcf;

Deleted runt/apis/gcf/javax/microedition/io/AccessPoint.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public class AccessPoint
{
	public AccessPoint()
	{
		super();
		throw new todo.TODO();
	}
	
	public void addListener(AccessPointListener __a)
	{
		throw new todo.TODO();
	}
	
	public boolean connect()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnect()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public NetworkInterface getNetworkInterface()
	{
		throw new todo.TODO();
	}
	
	public String getProperty(String __a)
	{
		throw new todo.TODO();
	}
	
	public String[] getPropertyNames()
	{
		throw new todo.TODO();
	}
	
	public String[] getPropertyValues(String __a)
	{
		throw new todo.TODO();
	}
	
	public int getTimeout()
	{
		throw new todo.TODO();
	}
	
	public String getType()
	{
		throw new todo.TODO();
	}
	
	public boolean isConnected()
	{
		throw new todo.TODO();
	}
	
	public boolean isRemovable()
	{
		throw new todo.TODO();
	}
	
	public void removeListener(AccessPointListener __a)
	{
		throw new todo.TODO();
	}
	
	public void setTimeout(int __a)
	{
		throw new todo.TODO();
	}
	
	public static AccessPoint[] getAccessPoints(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public static AccessPoint of(String __a, ConnectionOption... __b)
	{
		throw new todo.TODO();
	}
	
	public static boolean remove(AccessPoint __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/AccessPointListener.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.util.EventListener;

public interface AccessPointListener
	extends EventListener
{
	public static final int EVENT_TYPE_CONNECTED =
		0;
	
	public static final int EVENT_TYPE_DISCONNECTED =
		1;
	
	public static final int EVENT_TYPE_REMOVED =
		2;
	
	public abstract void notifyEvent(AccessPoint __a, int __b);
}


Deleted runt/apis/gcf/javax/microedition/io/AccessPointPermission.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.BasicPermission;
import java.security.Permission;

public final class AccessPointPermission
	extends BasicPermission
{
	public AccessPointPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/CommConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface CommConnection
	extends StreamConnection
{
	public abstract int getBaudRate();
	
	public abstract int setBaudRate(int __a);
}


Deleted runt/apis/gcf/javax/microedition/io/CommProtocolPermission.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class CommProtocolPermission
	extends GCFPermission
{
	public CommProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/Connection.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.Closeable;
import java.io.IOException;

/**
 * This is the base class for all connection types.
 *
 * @since 2019/05/06
 */
public interface Connection
	extends Closeable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/05/06
	 */
	@Override
	public abstract void close()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/ConnectionNotFoundException.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

/**
 * This is thrown when the connection was not available.
 *
 * @since 2019/05/06
 */
public class ConnectionNotFoundException
	extends IOException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/06
	 */
	public ConnectionNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/06
	 */
	public ConnectionNotFoundException(String __m)
	{
		super(__m);
	}
}


Deleted runt/apis/gcf/javax/microedition/io/ConnectionOption.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public class ConnectionOption<T>
{
	public ConnectionOption(String __a, T __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public T getValue()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/Connector.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429













































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import cc.squirreljme.runtime.gcf.HTTPAddress;
import cc.squirreljme.runtime.gcf.HTTPClientConnection;
import cc.squirreljme.runtime.gcf.IPAddress;
import cc.squirreljme.runtime.gcf.IPConnectionFactory;
import cc.squirreljme.runtime.gcf.TCPClientConnection;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This class is used to create new connections via the generic connection
 * framework. All connection resources are URIs which describe the resource
 * to be accessed.
 *
 * @since 2016/10/12
 */
public class Connector
{
	/** Access mode to allow reading from the connection stream. */
	public static final int READ =
		1;
	
	/** Access mode to allow for writing to the connection stream. */
	public static final int WRITE =
		2;
	
	/** Access mode to allow for read and writing from/to the stream. */
	public static final int READ_WRITE =
		READ | WRITE;
	
	/**
	 * Not used.
	 *
	 * @since 2016/10/12
	 */
	private Connector()
	{
	}
	
	public static long getBytesRead(Connection __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static long getBytesWritten(Connection __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	/**
	 * This checks whether the specified protocol is supported.
	 *
	 * @param __uri The scheme to check if it is supported, if there is a colon
	 * then only the characters up to the first colon are used.
	 * @param __server If {@code true} then check for support for being a
	 * server.
	 * @return {@code true} if the protocol is supported.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public static boolean isProtocolSupported(String __uri, boolean __server)
		throws NullPointerException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// Only use up to the colon, if one exists
		int fc = __uri.indexOf(':');
		if (fc > 0)
			__uri = __uri.substring(0, fc);
		
		// Only these protocols are handled
		switch (__uri)
		{
				// Does not matter
			case "comm":
			case "datagram":
			case "dtls":
			case "file":
			case "imc":
			case "multicast":
			case "socket":
			case "ssl":
				return true;
			
				// Client only
			case "http":
			case "https":
				return !__server;
			
				// Unknown
			default:
				return false;
		}
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, READ_WRITE, false, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri)
		throws IOException
	{
		return open(__uri, READ_WRITE, false, (ConnectionOption<?>[])null);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, READ_WRITE, false, __opts)}.
	 *
	 * @param __uri As forwarded.
	 * @param __opts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, ConnectionOption<?>... __opts)
		throws IOException
	{
		return open(__uri, READ_WRITE, false, __opts);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, false, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode)
		throws IOException
	{
		return open(__uri, __mode, false, (ConnectionOption<?>[])null);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, false, __opts)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @param __opts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode,
		ConnectionOption<?>... __opts)
		throws IOException
	{
		return open(__uri, __mode, false, __opts);
	}
	
	/**
	 * Invokes:
	 * {@code open(__uri, __mode, __timeouts, (ConnectionOption<?>[])null)}.
	 *
	 * @param __uri As forwarded.
	 * @param __mode As forwarded.
	 * @param __timeouts As forwarded.
	 * @return As forwarded.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode, boolean __timeouts)
		throws IOException
	{
		return open(__uri, __mode, __timeouts, (ConnectionOption<?>[])null);
	}
	
	/**
	 * This opens and creates a connection to the specified resource which is
	 * named by the URI.
	 *
	 * @param __uri The URI to open.
	 * @param __mode The open mode of the socket.
	 * @param __timeouts This is a hint to the connection system that it is
	 * acceptable for {@link InterruptedIOException}s to be generated. This
	 * is not required to be followed.
	 * @param __opts Options which modify the properties of a stream.
	 * @throws ConnectionNotFoundException Either the protocol is not supported
	 * or the target to connect to could not be located.
	 * @throws IllegalArgumentException If a parameter is not valid.
	 * @throws IOException On other unspecified exceptions.
	 * @throws NullPointerException If no URI was specified.
	 * @throws SecurityException If access to the protocol is not permitted.
	 * @since 2016/10/12
	 */
	public static Connection open(String __uri, int __mode, boolean __timeouts,
		ConnectionOption<?>... __opts)
		throws ConnectionNotFoundException, IllegalArgumentException,
			IOException, NullPointerException, SecurityException
	{
		// Debug
		todo.DEBUG.note("Open %s", __uri);
		
		// Used to debug connections
		try
		{
			return Connector.__open(__uri, __mode, __timeouts, __opts);
		}
		
		// Print the exception
		catch (IllegalArgumentException|
			IOException|NullPointerException|SecurityException e)
		{
			e.printStackTrace();
			
			throw e;
		}
	}
	
	/**
	 * Invokes {@code new DataInputStream(openInputStream(__uri))}.
	 *
	 * @param __uri The URI to open.
	 * @return The data stream.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static DataInputStream openDataInputStream(String __uri)
		throws IOException
	{
		return new DataInputStream(openInputStream(__uri));
	}
	
	/**
	 * Invokes {@code new DataOutputStream(openOutputStream(__uri))}.
	 *
	 * @param __uri The URI to open.
	 * @return The data stream.
	 * @throws IOException As forwarded.
	 * @since 2016/10/12
	 */
	public static DataOutputStream openDataOutputStream(String __uri)
		throws IOException
	{
		return new DataOutputStream(openOutputStream(__uri));
	}
	
	/**
	 * This opens a connection, obtains the input stream, then closes the
	 * connection.
	 *
	 * @return An input stream for the given connection.
	 * @throws IllegalArgumentException If the connection is not an
	 * {@link InputConnection}.
	 * @throws IOException On open errors.
	 * @since 2016/10/12
	 */
	public static InputStream openInputStream(String __uri)
		throws IllegalArgumentException, IOException
	{
		// Open it, then close it
		try (Connection c = open(__uri))
		{
			// {@squirreljme.error EC0z The specified URI is not an input
			// connection. (The URI)}
			if (!(c instanceof InputConnection))
				throw new IllegalArgumentException(String.format("EC0z %s",
					__uri));
			
			// Open it
			return ((InputConnection)c).openInputStream();
		}
	}
	
	/**
	 * This opens a connection, obtains the output stream, then closes the
	 * connection.
	 *
	 * @return An output stream for the given connection.
	 * @throws IllegalArgumentException If the connection is not an
	 * {@link OutputConnection}.
	 * @throws IOException On open errors.
	 * @since 2016/10/12
	 */
	public static OutputStream openOutputStream(String __uri)
		throws IllegalArgumentException, IOException
	{
		// Open it, then close it
		try (Connection c = open(__uri))
		{
			// {@squirreljme.error EC10 The specified URI is not an output
			// connection. (The URI)}
			if (!(c instanceof OutputConnection))
				throw new IllegalArgumentException(String.format("EC10 %s",
					__uri));
			
			// Open it
			return ((OutputConnection)c).openOutputStream();
		}
	}
	
	/**
	 * This opens and creates a connection to the specified resource which is
	 * named by the URI.
	 *
	 * @param __uri The URI to open.
	 * @param __mode The open mode of the socket.
	 * @param __timeouts This is a hint to the connection system that it is
	 * acceptable for {@link InterruptedIOException}s to be generated. This
	 * is not required to be followed.
	 * @param __opts Options which modify the properties of a stream.
	 * @throws ConnectionNotFoundException Either the protocol is not supported
	 * or the target to connect to could not be located.
	 * @throws IllegalArgumentException If a parameter is not valid.
	 * @throws IOException On other unspecified exceptions.
	 * @throws NullPointerException If no URI was specified.
	 * @throws SecurityException If access to the protocol is not permitted.
	 * @since 2016/10/12
	 */
	private static Connection __open(String __uri, int __mode,
		boolean __timeouts, ConnectionOption<?>... __opts)
		throws ConnectionNotFoundException, IllegalArgumentException,
			IOException, NullPointerException, SecurityException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// If missing, create
		if (__opts == null)
			__opts = new ConnectionOption<?>[0];
		
		// {@squirreljme.error EC11 The URI does not have a scheme. (The URI)}
		int fc = __uri.indexOf(':');
		if (fc < 0)
			throw new IllegalArgumentException(String.format("EC11 %s",
				__uri));
		String scheme = __uri.substring(0, fc),
			part = __uri.substring(fc + 1);
		
		// Sockets of a given protocol must be of a given class type
		switch (scheme)
		{
				// Communication port, which may be a modem
			case "comm":
				throw new todo.TODO();
				
				// UDP datagrams
			case "datagram":
				throw new todo.TODO();
				
				// SSL UDP datagrams
			case "dtls":
				throw new todo.TODO();
				
				// Local Files
			case "file":
				throw new todo.TODO();
				
				// HTTP
			case "http":
				return HTTPClientConnection.connect(
					HTTPAddress.fromUriPart(part));
				
				// HTTPS
			case "https":
				throw new todo.TODO();
				
				// Intermidlet communication
			case "imc":
				throw new todo.TODO();
				
				// UDP Multicast
			case "multicast":
				throw new todo.TODO();
				
				// TCP Socket
			case "socket":
				{
					// Decode address
					IPAddress addr = IPAddress.fromUriPart(part);
					
					// Creating server
					if (addr.isServer())
						throw new todo.TODO();
					
					// Creating client
					else
					{
						IPConnectionFactory pf = IPConnectionFactory.factory();
						return pf.tcpClientConnect(pf.resolveAddress(addr));
					}
				}
				
				// SSL/TLS TCP Socket
			case "ssl":
				throw new todo.TODO();
				
				// {@squirreljme.error EC12 Unhandled URI protocol. (The URI)}.
			default:
				throw new ConnectionNotFoundException(String.format("EC12 %s",
					__uri));
		}
	}
}


Deleted runt/apis/gcf/javax/microedition/io/ContentConnection.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface ContentConnection
	extends StreamConnection
{
	public abstract String getEncoding();
	
	public abstract long getLength();
	
	public abstract String getType();
}


Deleted runt/apis/gcf/javax/microedition/io/DTLSProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class DTLSProtocolPermission
	extends GCFPermission
{
	public DTLSProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/Datagram.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public interface Datagram
	extends DataInput, DataOutput
{
	public abstract String getAddress();
	
	public abstract byte[] getData();
	
	public abstract int getLength();
	
	public abstract int getOffset();
	
	public abstract void reset();
	
	public abstract void setAddress(String __a)
		throws IOException;
	
	public abstract void setAddress(Datagram __a);
	
	public abstract void setData(byte[] __a, int __b, int __c);
	
	public abstract void setLength(int __a);
}


Deleted runt/apis/gcf/javax/microedition/io/DatagramConnection.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface DatagramConnection
	extends Connection
{
	public abstract AccessPoint[] getAccessPoints()
		throws IOException;
	
	public abstract int getMaximumLength()
		throws IOException;
	
	public abstract int getNominalLength()
		throws IOException;
	
	public abstract Datagram newDatagram(int __a)
		throws IOException;
	
	public abstract Datagram newDatagram(int __a, String __b)
		throws IOException;
	
	public abstract Datagram newDatagram(byte[] __a, int __b)
		throws IOException;
	
	public abstract Datagram newDatagram(byte[] __a, int __b, String __c)
		throws IOException;
	
	public abstract void receive(Datagram __a)
		throws IOException;
	
	public abstract void send(Datagram __a)
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/DatagramProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class DatagramProtocolPermission
	extends GCFPermission
{
	public DatagramProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/FileProtocolPermission.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class FileProtocolPermission
	extends GCFPermission
{
	public FileProtocolPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/GCFPermission.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public abstract class GCFPermission
	extends Permission
{
	public GCFPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	public String getProtocol()
	{
		throw new todo.TODO();
	}
	
	public String getURI()
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/HttpConnection.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

/**
 * This is a connection which enables HTTP based API access.
 *
 * This connection is within three states:
 *  - SETUP where the connection is being setup.
 *  - CONNECTED where the connection has been made.
 *  - CLOSED where the connection has been completed and closed.
 *
 * The {@link openOutputStream} and {@link openDataOutputStream} may only be
 * called when in the SETUP state, when either of these streams are closed
 * the connection will transition to the connected state. Additionally if
 * the state transitions to the CONNECTED state for any reason then the stream
 * will be implicitly closed and its data will be used.
 *
 * @since 2019/05/12
 */
public interface HttpConnection
	extends ContentConnection
{
	public static final String CONNECT =
		"CONNECT";
	
	public static final String DELETE =
		"DELETE";
	
	public static final String GET =
		"GET";
	
	public static final String HEAD =
		"HEAD";
	
	public static final int HTTP_ACCEPTED =
		202;
	
	public static final int HTTP_BAD_GATEWAY =
		502;
	
	public static final int HTTP_BAD_METHOD =
		405;
	
	public static final int HTTP_BAD_REQUEST =
		400;
	
	public static final int HTTP_CLIENT_TIMEOUT =
		408;
	
	public static final int HTTP_CONFLICT =
		409;
	
	public static final int HTTP_CREATED =
		201;
	
	public static final int HTTP_ENTITY_TOO_LARGE =
		413;
	
	public static final int HTTP_EXPECT_FAILED =
		417;
	
	public static final int HTTP_FORBIDDEN =
		403;
	
	public static final int HTTP_GATEWAY_TIMEOUT =
		504;
	
	public static final int HTTP_GONE =
		410;
	
	public static final int HTTP_INTERNAL_ERROR =
		500;
	
	public static final int HTTP_LENGTH_REQUIRED =
		411;
	
	public static final int HTTP_MOVED_PERM =
		301;
	
	public static final int HTTP_MOVED_TEMP =
		302;
	
	public static final int HTTP_MULT_CHOICE =
		300;
	
	public static final int HTTP_NOT_ACCEPTABLE =
		406;
	
	public static final int HTTP_NOT_AUTHORITATIVE =
		203;
	
	public static final int HTTP_NOT_FOUND =
		404;
	
	public static final int HTTP_NOT_IMPLEMENTED =
		501;
	
	public static final int HTTP_NOT_MODIFIED =
		304;
	
	public static final int HTTP_NO_CONTENT =
		204;
	
	public static final int HTTP_OK =
		200;
	
	public static final int HTTP_PARTIAL =
		206;
	
	public static final int HTTP_PAYMENT_REQUIRED =
		402;
	
	public static final int HTTP_PRECON_FAILED =
		412;
	
	public static final int HTTP_PROXY_AUTH =
		407;
	
	public static final int HTTP_REQ_TOO_LONG =
		414;
	
	public static final int HTTP_RESET =
		205;
	
	public static final int HTTP_SEE_OTHER =
		303;
	
	public static final int HTTP_TEMP_REDIRECT =
		307;
	
	public static final int HTTP_UNAUTHORIZED =
		401;
	
	public static final int HTTP_UNAVAILABLE =
		503;
	
	public static final int HTTP_UNSUPPORTED_RANGE =
		416;
	
	public static final int HTTP_UNSUPPORTED_TYPE =
		415;
	
	public static final int HTTP_USE_PROXY =
		305;
	
	public static final int HTTP_VERSION =
		505;
	
	public static final String OPTIONS =
		"OPTIONS";
	
	public static final String POST =
		"POST";
	
	public static final String PUT =
		"PUT";
	
	public static final String TRACE =
		"TRACE";
	
	public abstract AccessPoint getAccessPoint()
		throws IOException;
	
	public abstract long getDate()
		throws IOException;
	
	public abstract long getExpiration()
		throws IOException;
	
	public abstract String getFile();
	
	public abstract String getHeaderField(String __a)
		throws IOException;
	
	public abstract String getHeaderField(int __a)
		throws IOException;
	
	public abstract long getHeaderFieldDate(String __a, long __b)
		throws IOException;
	
	public abstract int getHeaderFieldInt(String __a, int __b)
		throws IOException;
	
	public abstract String getHeaderFieldKey(int __a)
		throws IOException;
	
	public abstract String getHost();
	
	public abstract long getLastModified()
		throws IOException;
	
	public abstract int getPort();
	
	public abstract String getProtocol();
	
	public abstract String getQuery();
	
	public abstract String getRef();
	
	public abstract String getRequestMethod();
	
	public abstract String getRequestProperty(String __a);
	
	public abstract int getResponseCode()
		throws IOException;
	
	public abstract String getResponseMessage()
		throws IOException;
	
	public abstract String getURL();
	
	/**
	 * Sets the request method to use.
	 *
	 * @param __m The method to use.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If no method was specified.
	 * @since 2019/05/12
	 */
	public abstract void setRequestMethod(String __m)
		throws IOException, NullPointerException;
	
	/**
	 * Adds or replaces an existing request property, note that for multiple
	 * request property specifications they need to manually be comma
	 * separated.
	 *
	 * @param __k The request header key.
	 * @param __v The value to use, {@code null} clears.
	 * @throws IOException If this is not in the setup phase.
	 * @throws NullPointerException If the key was null.
	 * @since 2019/05/12
	 */
	public abstract void setRequestProperty(String __k, String __v)
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/HttpProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class HttpProtocolPermission
	extends GCFPermission
{
	public HttpProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/HttpsConnection.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface HttpsConnection
	extends HttpConnection
{
	public abstract int getPort();
	
	public abstract SecurityInfo getSecurityInfo()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/HttpsProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class HttpsProtocolPermission
	extends GCFPermission
{
	public HttpsProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/IMCConnection.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import javax.microedition.midlet.MIDletIdentity;

public interface IMCConnection
	extends StreamConnection
{
	public abstract MIDletIdentity getRemoteIdentity();
	
	public abstract String getRequestedServerVersion();
	
	public abstract String getServerName();
}


Deleted runt/apis/gcf/javax/microedition/io/IMCServerConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface IMCServerConnection
	extends StreamConnectionNotifier
{
	public abstract String getName();
	
	public abstract String getVersion();
}


Deleted runt/apis/gcf/javax/microedition/io/InputConnection.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;

public interface InputConnection
	extends Connection
{
	public abstract DataInputStream openDataInputStream()
		throws IOException;
	
	public abstract InputStream openInputStream()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/ModemConnection.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface ModemConnection
	extends CommConnection
{
	public static final int DCD_SIGNAL =
		2;
	
	public static final int DSR_SIGNAL =
		4;
	
	public static final int DTR_SIGNAL =
		1;
	
	public static final int INPUT_MODE =
		0;
	
	public static final int OUTPUT_MODE =
		1;
	
	public static final int RI_SIGNAL =
		8;
	
	public static final int UNSUPPORTED =
		-1;
	
	public abstract void addListener(ModemListener __a, int __b);
	
	public abstract int getLineMode(int __a);
	
	public abstract boolean getLineState(int __a)
		throws IOException;
	
	public abstract void removeListener(ModemListener __a);
	
	public abstract void setLineState(int __a, boolean __b)
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/ModemListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.util.EventListener;

public interface ModemListener
	extends EventListener
{
	public abstract void signalChanged(ModemConnection __a, int __b, boolean 
		__c);
}


Deleted runt/apis/gcf/javax/microedition/io/MulticastProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class MulticastProtocolPermission
	extends GCFPermission
{
	public MulticastProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/NetworkInterface.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public class NetworkInterface
{
	public NetworkInterface()
	{
		super();
		throw new todo.TODO();
	}
	
	public void connect(AccessPoint __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnect(AccessPoint __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public boolean disconnectAll()
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public AccessPoint[] getConnectedAccessPoints()
	{
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public String getType()
	{
		throw new todo.TODO();
	}
	
	public boolean isRoaming()
	{
		throw new todo.TODO();
	}
	
	public boolean supportsConcurrentAccessPoints()
	{
		throw new todo.TODO();
	}
	
	public static NetworkInterface[] getNetworkInterfaces(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] getNetworkTypes()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/NetworkUtilities.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;
import java.net.UnknownHostException;

public class NetworkUtilities
{
	public NetworkUtilities()
	{
		super();
		throw new todo.TODO();
	}
	
	public static String getByName(String __a)
		throws UnknownHostException
	{
		if (false)
			throw new UnknownHostException();
		throw new todo.TODO();
	}
	
	public static String getCanonicalHostName(String __a)
		throws IllegalArgumentException, UnknownHostException
	{
		if (false)
			throw new IllegalArgumentException();
		if (false)
			throw new UnknownHostException();
		throw new todo.TODO();
	}
	
	public static boolean isReachable(String __a, int __b, int __c)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/OutputConnection.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public interface OutputConnection
	extends Connection
{
	public abstract DataOutputStream openDataOutputStream()
		throws IOException;
	
	public abstract OutputStream openOutputStream()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/PushRegistry.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public class PushRegistry
{
	public PushRegistry()
	{
		super();
		throw new todo.TODO();
	}
	
	public static String getFilter(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String getMIDlet(String __a)
	{
		throw new todo.TODO();
	}
	
	public static String[] listConnections(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public static long registerAlarm(String __a, long __b)
		throws ClassNotFoundException, ConnectionNotFoundException
	{
		if (false)
			throw new ClassNotFoundException();
		if (false)
			throw new ConnectionNotFoundException();
		throw new todo.TODO();
	}
	
	public static void registerConnection(String __a, String __b, String __c)
		throws ClassNotFoundException, IOException
	{
		if (false)
			throw new ClassNotFoundException();
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static boolean unregisterConnection(String __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/PushRegistryPermission.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;
import java.security.PermissionCollection;

public final class PushRegistryPermission
	extends Permission
{
	public PushRegistryPermission(String __a, String __b)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public PermissionCollection newPermissionCollection()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/SSLProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class SSLProtocolPermission
	extends GCFPermission
{
	public SSLProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/SecureConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SecureConnection
	extends SocketConnection
{
	public abstract SecurityInfo getSecurityInfo()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/SecureDatagramConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SecureDatagramConnection
	extends UDPDatagramConnection
{
	public abstract SecurityInfo getSecurityInfo()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/SecureServerConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface SecureServerConnection
	extends ServerSocketConnection
{
}


Deleted runt/apis/gcf/javax/microedition/io/SecurityInfo.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import javax.microedition.pki.Certificate;

public interface SecurityInfo
{
	public abstract String getCipherSuite();
	
	public abstract Certificate getClientCertificate();
	
	public abstract String getProtocolName();
	
	public abstract String getProtocolVersion();
	
	public abstract Certificate getServerCertificate();
}


Deleted runt/apis/gcf/javax/microedition/io/ServerSocketConnection.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface ServerSocketConnection
	extends StreamConnectionNotifier
{
	public abstract AccessPoint[] getAccessPoints()
		throws IOException;
	
	public abstract String getLocalAddress()
		throws IOException;
	
	public abstract int getLocalPort()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/SocketConnection.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface SocketConnection
	extends StreamConnection
{
	/** Use the nagle algorithm? Zero disables, non-zero enables. */
	public static final byte DELAY =
		0;
	
	/** Keep connections alive? Zero disables, non-zero enables. */
	public static final byte KEEPALIVE =
		2;
	
	/**
	 * Time to wait in seconds before closing connections. Zero disables and
	 * only positive values are used.
	 */
	public static final byte LINGER =
		1;
	
	/** Receive buffer size? Zero is default, only positive is permitted. */
	public static final byte RCVBUF =
		3;
	
	/** Send buffer size? Zero is default, only positive is permitted. */
	public static final byte SNDBUF =
		4;
	
	/**
	 * Sets the timeout on blocking read/write. Zero is default, otherwise a
	 * positive value in milliseconds.
	 */
	public static final byte TIMEOUT =
		5;
	
	public abstract AccessPoint getAccessPoint()
		throws IOException;
	
	public abstract String getAddress()
		throws IOException;
	
	public abstract String getLocalAddress()
		throws IOException;
	
	public abstract int getLocalPort()
		throws IOException;
	
	public abstract int getPort()
		throws IOException;
	
	public abstract int getSocketOption(byte __o)
		throws IllegalArgumentException, IOException;
	
	/**
	 * Sets an option for the socket.
	 *
	 * @param __o The option to use.
	 * @param __v The value to use.
	 * @throws IllegalArgumentException If the option is not valid.
	 * @throws IOException If it could not be set.
	 * @since 2019/05/12
	 */
	public abstract void setSocketOption(byte __o, int __v)
		throws IllegalArgumentException, IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/SocketProtocolPermission.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.security.Permission;

public final class SocketProtocolPermission
	extends GCFPermission
{
	public SocketProtocolPermission(String __a)
	{
		super((String)null);
		throw new todo.TODO();
	}
	
	@Override
	public boolean equals(Object __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public String getActions()
	{
		throw new todo.TODO();
	}
	
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	@Override
	public boolean implies(Permission __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/StreamConnection.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;


public interface StreamConnection
	extends InputConnection, OutputConnection
{
}


Deleted runt/apis/gcf/javax/microedition/io/StreamConnectionNotifier.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface StreamConnectionNotifier
	extends Connection
{
	public abstract StreamConnection acceptAndOpen()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/UDPDatagramConnection.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface UDPDatagramConnection
	extends DatagramConnection
{
	public abstract String getLocalAddress()
		throws IOException;
	
	public abstract int getLocalPort()
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/UDPMulticastConnection.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io;

import java.io.IOException;

public interface UDPMulticastConnection
	extends UDPDatagramConnection
{
	public abstract int getTimeToLive()
		throws IOException;
	
	public abstract boolean isDisableLoopback()
		throws IOException;
	
	public abstract boolean isJoinSupported();
	
	public abstract void join(String __a)
		throws IOException;
	
	public abstract void leave(String __a)
		throws IOException;
	
	public abstract void receive(Datagram __a)
		throws IOException;
	
	public abstract void send(Datagram __a)
		throws IOException;
	
	public abstract void setDisableLoopback(boolean __a)
		throws IOException;
	
	public abstract void setTimeToLive(int __a)
		throws IOException;
}


Deleted runt/apis/gcf/javax/microedition/io/file/ConnectionClosedException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io.file;


public class ConnectionClosedException
	extends RuntimeException
{
	public ConnectionClosedException()
	{
		super();
		throw new todo.TODO();
	}
	
	public ConnectionClosedException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/io/file/FileConnection.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io.file;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.microedition.io.StreamConnection;

public interface FileConnection
	extends StreamConnection
{
	public abstract long availableSize();
	
	public abstract boolean canRead();
	
	public abstract boolean canWrite();
	
	public abstract void create()
		throws IOException;
	
	public abstract void delete()
		throws IOException;
	
	public abstract long directorySize(boolean __a)
		throws IOException;
	
	public abstract boolean exists();
	
	public abstract long fileSize()
		throws IOException;
	
	public abstract String getName();
	
	public abstract String getPath();
	
	public abstract String getURL();
	
	public abstract boolean isDirectory();
	
	public abstract boolean isHidden();
	
	public abstract boolean isOpen();
	
	public abstract long lastModified();
	
	public abstract Enumeration list()
		throws IOException;
	
	public abstract Enumeration list(String __a, boolean __b)
		throws IOException;
	
	public abstract void mkdir()
		throws IOException;
	
	public abstract DataInputStream openDataInputStream()
		throws IOException;
	
	public abstract DataOutputStream openDataOutputStream()
		throws IOException;
	
	public abstract InputStream openInputStream()
		throws IOException;
	
	public abstract OutputStream openOutputStream()
		throws IOException;
	
	public abstract OutputStream openOutputStream(long __a)
		throws IOException;
	
	public abstract void rename(String __a)
		throws IOException;
	
	public abstract void setFileConnection(String __a)
		throws IOException;
	
	public abstract void setHidden(boolean __a)
		throws IOException;
	
	public abstract void setReadable(boolean __a)
		throws IOException;
	
	public abstract void setWritable(boolean __a)
		throws IOException;
	
	public abstract long totalSize();
	
	public abstract void truncate(long __a)
		throws IOException;
	
	public abstract long usedSize();
}


Deleted runt/apis/gcf/javax/microedition/io/file/FileSystemListener.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io.file;


public interface FileSystemListener
{
	public static final int ROOT_ADDED =
		0;
	
	public static final int ROOT_REMOVED =
		1;
	
	public abstract void rootChanged(int __a, String __b);
}


Deleted runt/apis/gcf/javax/microedition/io/file/IllegalModeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.io.file;


public class IllegalModeException
	extends RuntimeException
{
	public IllegalModeException()
	{
		super();
		throw new todo.TODO();
	}
	
	public IllegalModeException(String __a)
	{
		super();
		throw new todo.TODO();
	}
}


Deleted runt/apis/gcf/javax/microedition/pki/Certificate.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.pki;


public interface Certificate
{
	public abstract String getIssuer();
	
	public abstract long getNotAfter();
	
	public abstract long getNotBefore();
	
	public abstract String getSerialNumber();
	
	public abstract String getSigAlgName();
	
	public abstract String getSubject();
	
	public abstract String getType();
	
	public abstract String getVersion();
}


Deleted runt/apis/gcf/javax/microedition/pki/CertificateException.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.pki;

import java.io.IOException;

public class CertificateException
	extends IOException
{
	public static final byte BAD_EXTENSIONS =
		1;
	
	public static final byte BROKEN_CHAIN =
		11;
	
	public static final byte CERTIFICATE_CHAIN_TOO_LONG =
		2;
	
	public static final byte EXPIRED =
		3;
	
	public static final byte INAPPROPRIATE_KEY_USAGE =
		10;
	
	public static final byte MISSING_SIGNATURE =
		5;
	
	public static final byte NOT_YET_VALID =
		6;
	
	public static final byte ROOT_CA_EXPIRED =
		12;
	
	public static final byte SITENAME_MISMATCH =
		7;
	
	public static final byte UNAUTHORIZED_INTERMEDIATE_CA =
		4;
	
	public static final byte UNRECOGNIZED_ISSUER =
		8;
	
	public static final byte UNSUPPORTED_PUBLIC_KEY_TYPE =
		13;
	
	public static final byte UNSUPPORTED_SIGALG =
		9;
	
	public static final byte VERIFICATION_FAILED =
		14;
	
	public CertificateException(Certificate __a, byte __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public CertificateException(String __a, Certificate __b, byte __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Certificate getCertificate()
	{
		throw new todo.TODO();
	}
	
	public byte getReason()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: Mobile 3D Graphics API
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains an implementation of the J2ME 
 Mobile 3D Graphics API. In SquirrelJME it utilizes OpenGL ES to perform
  the rendering as required.
X-SquirrelJME-Depends: opengles
X-SquirrelJME-Error: EK
X-SquirrelJME-UUID: f9f9a2bc-de6e-4225-82c1-47b5b0523e77
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/m3g/javax/microedition/m3g/AnimationController.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class AnimationController
	extends Object3D
{
	public AnimationController()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getActiveIntervalEnd()
	{
		throw new todo.TODO();
	}
	
	public int getActiveIntervalStart()
	{
		throw new todo.TODO();
	}
	
	public float getPosition(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getRefWorldTime()
	{
		throw new todo.TODO();
	}
	
	public float getSpeed()
	{
		throw new todo.TODO();
	}
	
	public float getWeight()
	{
		throw new todo.TODO();
	}
	
	public void setActiveInterval(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setPosition(float __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setSpeed(float __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setWeight(float __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/AnimationTrack.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
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











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class AnimationTrack
	extends Object3D
{
	public static final int ALPHA =
		256;
	
	public static final int AMBIENT_COLOR =
		257;
	
	public static final int COLOR =
		258;
	
	public static final int CROP =
		259;
	
	public static final int DENSITY =
		260;
	
	public static final int DIFFUSE_COLOR =
		261;
	
	public static final int EMISSIVE_COLOR =
		262;
	
	public static final int FAR_DISTANCE =
		263;
	
	public static final int FIELD_OF_VIEW =
		264;
	
	public static final int INTENSITY =
		265;
	
	public static final int MORPH_WEIGHTS =
		266;
	
	public static final int NEAR_DISTANCE =
		267;
	
	public static final int ORIENTATION =
		268;
	
	public static final int PICKABILITY =
		269;
	
	public static final int SCALE =
		270;
	
	public static final int SHININESS =
		271;
	
	public static final int SPECULAR_COLOR =
		272;
	
	public static final int SPOT_ANGLE =
		273;
	
	public static final int SPOT_EXPONENT =
		274;
	
	public static final int TRANSLATION =
		275;
	
	public static final int VISIBILITY =
		276;
	
	public AnimationTrack(KeyframeSequence __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public AnimationController getController()
	{
		throw new todo.TODO();
	}
	
	public KeyframeSequence getKeyframeSequence()
	{
		throw new todo.TODO();
	}
	
	public int getTargetProperty()
	{
		throw new todo.TODO();
	}
	
	public void setController(AnimationController __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Appearance.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Appearance
	extends Object3D
{
	public Appearance()
	{
		super();
		throw new todo.TODO();
	}
	
	public CompositingMode getCompositingMode()
	{
		throw new todo.TODO();
	}
	
	public Fog getFog()
	{
		throw new todo.TODO();
	}
	
	public int getLayer()
	{
		throw new todo.TODO();
	}
	
	public Material getMaterial()
	{
		throw new todo.TODO();
	}
	
	public PolygonMode getPolygonMode()
	{
		throw new todo.TODO();
	}
	
	public Texture2D getTexture(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setCompositingMode(CompositingMode __a)
	{
		throw new todo.TODO();
	}
	
	public void setFog(Fog __a)
	{
		throw new todo.TODO();
	}
	
	public void setLayer(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setMaterial(Material __a)
	{
		throw new todo.TODO();
	}
	
	public void setPolygonMode(PolygonMode __a)
	{
		throw new todo.TODO();
	}
	
	public void setTexture(int __a, Texture2D __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Background.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Background
	extends Object3D
{
	public static final int BORDER =
		32;
	
	public static final int REPEAT =
		33;
	
	public Background()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public int getCropHeight()
	{
		throw new todo.TODO();
	}
	
	public int getCropWidth()
	{
		throw new todo.TODO();
	}
	
	public int getCropX()
	{
		throw new todo.TODO();
	}
	
	public int getCropY()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public int getImageModeX()
	{
		throw new todo.TODO();
	}
	
	public int getImageModeY()
	{
		throw new todo.TODO();
	}
	
	public boolean isColorClearEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthClearEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setColorClearEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setCrop(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setDepthClearEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
	
	public void setImageMode(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Camera.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


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Camera
	extends Node
{
	public static final int GENERIC =
		48;
	
	public static final int PARALLEL =
		49;
	
	public static final int PERSPECTIVE =
		50;
	
	public Camera()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getProjection(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getProjection(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setGeneric(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setParallel(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void setPerspective(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/CompositingMode.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class CompositingMode
	extends Object3D
{
	public static final int ALPHA =
		64;
	
	public static final int ALPHA_ADD =
		65;
	
	public static final int MODULATE =
		66;
	
	public static final int MODULATE_X2 =
		67;
	
	public static final int REPLACE =
		68;
	
	public CompositingMode()
	{
		super();
		throw new todo.TODO();
	}
	
	public float getAlphaThreshold()
	{
		throw new todo.TODO();
	}
	
	public int getBlending()
	{
		throw new todo.TODO();
	}
	
	public float getDepthOffsetFactor()
	{
		throw new todo.TODO();
	}
	
	public float getDepthOffsetUnits()
	{
		throw new todo.TODO();
	}
	
	public boolean isAlphaWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isColorWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthTestEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthWriteEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setAlphaThreshold(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setAlphaWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setBlending(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setColorWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setDepthOffset(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setDepthTestEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setDepthWriteEnable(boolean __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Fog.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Fog
	extends Object3D
{
	public static final int EXPONENTIAL =
		80;
	
	public static final int LINEAR =
		81;
	
	public Fog()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public float getDensity()
	{
		throw new todo.TODO();
	}
	
	public float getFarDistance()
	{
		throw new todo.TODO();
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public float getNearDistance()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setDensity(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setLinear(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Graphics3D.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
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


















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;

import java.util.Hashtable;

public class Graphics3D
{
	public static final int ANTIALIAS =
		2;
	
	public static final int DITHER =
		4;
	
	public static final int OVERWRITE =
		16;
	
	public static final int TRUE_COLOR =
		8;
	
	private Graphics3D()
	{
		super();
		throw new todo.TODO();
	}
	
	public int addLight(Light __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void bindTarget(Object __a)
	{
		throw new todo.TODO();
	}
	
	public void bindTarget(Object __a, boolean __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void clear(Background __a)
	{
		throw new todo.TODO();
	}
	
	public Camera getCamera(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public float getDepthRangeFar()
	{
		throw new todo.TODO();
	}
	
	public float getDepthRangeNear()
	{
		throw new todo.TODO();
	}
	
	public int getHints()
	{
		throw new todo.TODO();
	}
	
	public Light getLight(int __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public int getLightCount()
	{
		throw new todo.TODO();
	}
	
	public Object getTarget()
	{
		throw new todo.TODO();
	}
	
	public int getViewportHeight()
	{
		throw new todo.TODO();
	}
	
	public int getViewportWidth()
	{
		throw new todo.TODO();
	}
	
	public int getViewportX()
	{
		throw new todo.TODO();
	}
	
	public int getViewportY()
	{
		throw new todo.TODO();
	}
	
	public boolean isDepthBufferEnabled()
	{
		throw new todo.TODO();
	}
	
	public void releaseTarget()
	{
		throw new todo.TODO();
	}
	
	public void render(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void render(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Transform __d)
	{
		throw new todo.TODO();
	}
	
	public void render(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Transform __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public void render(World __a)
	{
		throw new todo.TODO();
	}
	
	public void resetLights()
	{
		throw new todo.TODO();
	}
	
	public void setCamera(Camera __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public void setDepthRange(float __a, float __b)
	{
		throw new todo.TODO();
	}
	
	public void setLight(int __a, Light __b, Transform __c)
	{
		throw new todo.TODO();
	}
	
	public void setViewport(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public static final Graphics3D getInstance()
	{
		throw new todo.TODO();
	}
	
	public static final Hashtable getProperties()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Group.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Group
	extends Node
{
	public Group()
	{
		super();
		throw new todo.TODO();
	}
	
	public void addChild(Node __a)
	{
		throw new todo.TODO();
	}
	
	public Node getChild(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getChildCount()
	{
		throw new todo.TODO();
	}
	
	public boolean pick(int __a, float __b, float __c, float __d, float __e, 
		float __f, float __g, RayIntersection __h)
	{
		throw new todo.TODO();
	}
	
	public boolean pick(int __a, float __b, float __c, Camera __d, 
		RayIntersection __e)
	{
		throw new todo.TODO();
	}
	
	public void removeChild(Node __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Image2D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Image2D
	extends Object3D
{
	public static final int ALPHA =
		96;
	
	public static final int LUMINANCE =
		97;
	
	public static final int LUMINANCE_ALPHA =
		98;
	
	public static final int RGB =
		99;
	
	public static final int RGBA =
		100;
	
	public Image2D(int __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Image2D(int __a, int __b, int __c, byte[] __d)
	{
		super();
		throw new todo.TODO();
	}
	
	public Image2D(int __a, int __b, int __c, byte[] __d, byte[] __e)
	{
		super();
		throw new todo.TODO();
	}
	
	public Image2D(int __a, Object __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getFormat()
	{
		throw new todo.TODO();
	}
	
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public boolean isMutable()
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, int __c, int __d, byte[] __e)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/IndexBuffer.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class IndexBuffer
	extends Object3D
{
	IndexBuffer()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract int getIndexCount();
	
	public abstract void getIndices(int[] __a);
}


Deleted runt/apis/m3g/javax/microedition/m3g/KeyframeSequence.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class KeyframeSequence
	extends Object3D
{
	public static final int CONSTANT =
		192;
	
	public static final int LINEAR =
		176;
	
	public static final int LOOP =
		193;
	
	public static final int SLERP =
		177;
	
	public static final int SPLINE =
		178;
	
	public static final int SQUAD =
		179;
	
	public static final int STEP =
		180;
	
	public KeyframeSequence(int __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getComponentCount()
	{
		throw new todo.TODO();
	}
	
	public int getDuration()
	{
		throw new todo.TODO();
	}
	
	public int getInterpolationType()
	{
		throw new todo.TODO();
	}
	
	public int getKeyframe(int __a, float[] __b)
	{
		throw new todo.TODO();
	}
	
	public int getKeyframeCount()
	{
		throw new todo.TODO();
	}
	
	public int getRepeatMode()
	{
		throw new todo.TODO();
	}
	
	public int getValidRangeFirst()
	{
		throw new todo.TODO();
	}
	
	public int getValidRangeLast()
	{
		throw new todo.TODO();
	}
	
	public void setDuration(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setKeyframe(int __a, int __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public void setRepeatMode(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setValidRange(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Light.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
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










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Light
	extends Node
{
	public static final int AMBIENT =
		128;
	
	public static final int DIRECTIONAL =
		129;
	
	public static final int OMNI =
		130;
	
	public static final int SPOT =
		131;
	
	public Light()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getColor()
	{
		throw new todo.TODO();
	}
	
	public float getConstantAttenuation()
	{
		throw new todo.TODO();
	}
	
	public float getIntensity()
	{
		throw new todo.TODO();
	}
	
	public float getLinearAttenuation()
	{
		throw new todo.TODO();
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public float getQuadraticAttenuation()
	{
		throw new todo.TODO();
	}
	
	public float getSpotAngle()
	{
		throw new todo.TODO();
	}
	
	public float getSpotExponent()
	{
		throw new todo.TODO();
	}
	
	public void setAttenuation(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setIntensity(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setSpotAngle(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setSpotExponent(float __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Loader.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;

import java.io.IOException;

public class Loader
{
	private Loader()
	{
		super();
		throw new todo.TODO();
	}
	
	public static Object3D[] load(byte[] __a, int __b)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
	
	public static Object3D[] load(String __a)
		throws IOException
	{
		if (false)
			throw new IOException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Material.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Material
	extends Object3D
{
	public static final int AMBIENT =
		1024;
	
	public static final int DIFFUSE =
		2048;
	
	public static final int EMISSIVE =
		4096;
	
	public static final int SPECULAR =
		8192;
	
	public Material()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getShininess()
	{
		throw new todo.TODO();
	}
	
	public boolean isVertexColorTrackingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setColor(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setShininess(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setVertexColorTrackingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Mesh.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Mesh
	extends Node
{
	public Mesh(VertexBuffer __a, IndexBuffer[] __b, Appearance[] __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Mesh(VertexBuffer __a, IndexBuffer __b, Appearance __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Appearance getAppearance(int __a)
	{
		throw new todo.TODO();
	}
	
	public IndexBuffer getIndexBuffer(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSubmeshCount()
	{
		throw new todo.TODO();
	}
	
	public VertexBuffer getVertexBuffer()
	{
		throw new todo.TODO();
	}
	
	public void setAppearance(int __a, Appearance __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/MorphingMesh.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class MorphingMesh
	extends Mesh
{
	public MorphingMesh(VertexBuffer __a, VertexBuffer[] __b, IndexBuffer[] 
		__c, Appearance[] __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public MorphingMesh(VertexBuffer __a, VertexBuffer[] __b, IndexBuffer __c
		, Appearance __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public VertexBuffer getMorphTarget(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getMorphTargetCount()
	{
		throw new todo.TODO();
	}
	
	public void getWeights(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setWeights(float[] __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Node.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class Node
	extends Transformable
{
	public static final int NONE =
		144;
	
	public static final int ORIGIN =
		145;
	
	public static final int X_AXIS =
		146;
	
	public static final int Y_AXIS =
		147;
	
	public static final int Z_AXIS =
		148;
	
	Node()
	{
		super();
		throw new todo.TODO();
	}
	
	public final void align(Node __a)
	{
		throw new todo.TODO();
	}
	
	public Node getAlignmentReference(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getAlignmentTarget(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getAlphaFactor()
	{
		throw new todo.TODO();
	}
	
	public Node getParent()
	{
		throw new todo.TODO();
	}
	
	public int getScope()
	{
		throw new todo.TODO();
	}
	
	public boolean getTransformTo(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public boolean isPickingEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isRenderingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setAlignment(Node __a, int __b, Node __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setAlphaFactor(float __a)
	{
		throw new todo.TODO();
	}
	
	public void setPickingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setRenderingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setScope(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Object3D.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class Object3D
{
	Object3D()
	{
		super();
		throw new todo.TODO();
	}
	
	public void addAnimationTrack(AnimationTrack __a)
	{
		throw new todo.TODO();
	}
	
	public final int animate(int __a)
	{
		throw new todo.TODO();
	}
	
	public final Object3D duplicate()
	{
		throw new todo.TODO();
	}
	
	public Object3D find(int __a)
	{
		throw new todo.TODO();
	}
	
	public AnimationTrack getAnimationTrack(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getAnimationTrackCount()
	{
		throw new todo.TODO();
	}
	
	public int getReferences(Object3D[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getUserID()
	{
		throw new todo.TODO();
	}
	
	public Object getUserObject()
	{
		throw new todo.TODO();
	}
	
	public void removeAnimationTrack(AnimationTrack __a)
	{
		throw new todo.TODO();
	}
	
	public void setUserID(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setUserObject(Object __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/PolygonMode.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class PolygonMode
	extends Object3D
{
	public static final int CULL_BACK =
		160;
	
	public static final int CULL_FRONT =
		161;
	
	public static final int CULL_NONE =
		162;
	
	public static final int SHADE_FLAT =
		164;
	
	public static final int SHADE_SMOOTH =
		165;
	
	public static final int WINDING_CCW =
		168;
	
	public static final int WINDING_CW =
		169;
	
	public PolygonMode()
	{
		super();
		throw new todo.TODO();
	}
	
	public int getCulling()
	{
		throw new todo.TODO();
	}
	
	public int getShading()
	{
		throw new todo.TODO();
	}
	
	public int getWinding()
	{
		throw new todo.TODO();
	}
	
	public boolean isLocalCameraLightingEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isPerspectiveCorrectionEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isTwoSidedLightingEnabled()
	{
		throw new todo.TODO();
	}
	
	public void setCulling(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setLocalCameraLightingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setPerspectiveCorrectionEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setShading(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setTwoSidedLightingEnable(boolean __a)
	{
		throw new todo.TODO();
	}
	
	public void setWinding(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/RayIntersection.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class RayIntersection
{
	public RayIntersection()
	{
		super();
		throw new todo.TODO();
	}
	
	public float getDistance()
	{
		throw new todo.TODO();
	}
	
	public Node getIntersected()
	{
		throw new todo.TODO();
	}
	
	public float getNormalX()
	{
		throw new todo.TODO();
	}
	
	public float getNormalY()
	{
		throw new todo.TODO();
	}
	
	public float getNormalZ()
	{
		throw new todo.TODO();
	}
	
	public void getRay(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getSubmeshIndex()
	{
		throw new todo.TODO();
	}
	
	public float getTextureS(int __a)
	{
		throw new todo.TODO();
	}
	
	public float getTextureT(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/SkinnedMesh.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class SkinnedMesh
	extends Mesh
{
	public SkinnedMesh(VertexBuffer __a, IndexBuffer[] __b, Appearance[] __c,
		Group __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public SkinnedMesh(VertexBuffer __a, IndexBuffer __b, Appearance __c, 
		Group __d)
	{
		super((VertexBuffer)null, (IndexBuffer[])null, (Appearance[])null
			);
		throw new todo.TODO();
	}
	
	public void addTransform(Node __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void getBoneTransform(Node __a, Transform __b)
	{
		throw new todo.TODO();
	}
	
	public int getBoneVertices(Node __a, int[] __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public Group getSkeleton()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Sprite3D.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Sprite3D
	extends Node
{
	public Sprite3D(boolean __a, Image2D __b, Appearance __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Appearance getAppearance()
	{
		throw new todo.TODO();
	}
	
	public int getCropHeight()
	{
		throw new todo.TODO();
	}
	
	public int getCropWidth()
	{
		throw new todo.TODO();
	}
	
	public int getCropX()
	{
		throw new todo.TODO();
	}
	
	public int getCropY()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public boolean isScaled()
	{
		throw new todo.TODO();
	}
	
	public void setAppearance(Appearance __a)
	{
		throw new todo.TODO();
	}
	
	public void setCrop(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Texture2D.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Texture2D
	extends Transformable
{
	public static final int FILTER_BASE_LEVEL =
		208;
	
	public static final int FILTER_LINEAR =
		209;
	
	public static final int FILTER_NEAREST =
		210;
	
	public static final int FUNC_ADD =
		224;
	
	public static final int FUNC_BLEND =
		225;
	
	public static final int FUNC_DECAL =
		226;
	
	public static final int FUNC_MODULATE =
		227;
	
	public static final int FUNC_REPLACE =
		228;
	
	public static final int WRAP_CLAMP =
		240;
	
	public static final int WRAP_REPEAT =
		241;
	
	public Texture2D(Image2D __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public int getBlendColor()
	{
		throw new todo.TODO();
	}
	
	public int getBlending()
	{
		throw new todo.TODO();
	}
	
	public Image2D getImage()
	{
		throw new todo.TODO();
	}
	
	public int getImageFilter()
	{
		throw new todo.TODO();
	}
	
	public int getLevelFilter()
	{
		throw new todo.TODO();
	}
	
	public int getWrappingS()
	{
		throw new todo.TODO();
	}
	
	public int getWrappingT()
	{
		throw new todo.TODO();
	}
	
	public void setBlendColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setBlending(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFiltering(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image2D __a)
	{
		throw new todo.TODO();
	}
	
	public void setWrapping(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Transform.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
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






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class Transform
{
	public Transform()
	{
		super();
		throw new todo.TODO();
	}
	
	public Transform(Transform __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public void get(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void invert()
	{
		throw new todo.TODO();
	}
	
	public void postMultiply(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void postRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void postRotateQuat(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void postScale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void postTranslate(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void set(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void set(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setIdentity()
	{
		throw new todo.TODO();
	}
	
	public void transform(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void transform(VertexArray __a, float[] __b, boolean __c)
	{
		throw new todo.TODO();
	}
	
	public void transpose()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/Transformable.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public abstract class Transformable
	extends Object3D
{
	Transformable()
	{
		super();
		throw new todo.TODO();
	}
	
	public void getCompositeTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void getOrientation(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void getScale(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void getTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void getTranslation(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public void postRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void preRotate(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void scale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setOrientation(float __a, float __b, float __c, float __d)
	{
		throw new todo.TODO();
	}
	
	public void setScale(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void setTransform(Transform __a)
	{
		throw new todo.TODO();
	}
	
	public void setTranslation(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
	
	public void translate(float __a, float __b, float __c)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/TriangleStripArray.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class TriangleStripArray
	extends IndexBuffer
{
	public TriangleStripArray(int[] __a, int[] __b)
	{
		super();
		throw new todo.TODO();
	}
	
	public TriangleStripArray(int __a, int[] __b)
	{
		super();
		throw new todo.TODO();
	}
	
	@Override
	public int getIndexCount()
	{
		throw new todo.TODO();
	}
	
	@Override
	public void getIndices(int[] __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/VertexArray.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class VertexArray
	extends Object3D
{
	public VertexArray(int __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public void get(int __a, int __b, byte[] __c)
	{
		throw new todo.TODO();
	}
	
	public void get(int __a, int __b, short[] __c)
	{
		throw new todo.TODO();
	}
	
	public int getComponentCount()
	{
		throw new todo.TODO();
	}
	
	public int getComponentType()
	{
		throw new todo.TODO();
	}
	
	public int getVertexCount()
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, byte[] __c)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, int __b, short[] __c)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/VertexBuffer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class VertexBuffer
	extends Object3D
{
	public VertexBuffer()
	{
		super();
		throw new todo.TODO();
	}
	
	public VertexArray getColors()
	{
		throw new todo.TODO();
	}
	
	public int getDefaultColor()
	{
		throw new todo.TODO();
	}
	
	public VertexArray getNormals()
	{
		throw new todo.TODO();
	}
	
	public VertexArray getPositions(float[] __a)
	{
		throw new todo.TODO();
	}
	
	public VertexArray getTexCoords(int __a, float[] __b)
	{
		throw new todo.TODO();
	}
	
	public int getVertexCount()
	{
		throw new todo.TODO();
	}
	
	public void setColors(VertexArray __a)
	{
		throw new todo.TODO();
	}
	
	public void setDefaultColor(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setNormals(VertexArray __a)
	{
		throw new todo.TODO();
	}
	
	public void setPositions(VertexArray __a, float __b, float[] __c)
	{
		throw new todo.TODO();
	}
	
	public void setTexCoords(int __a, VertexArray __b, float __c, float[] __d
		)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/m3g/javax/microedition/m3g/World.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.m3g;


public class World
	extends Group
{
	public World()
	{
		super();
		throw new todo.TODO();
	}
	
	public Camera getActiveCamera()
	{
		throw new todo.TODO();
	}
	
	public Background getBackground()
	{
		throw new todo.TODO();
	}
	
	public void setActiveCamera(Camera __a)
	{
		throw new todo.TODO();
	}
	
	public void setBackground(Background __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/media-api/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: Media API
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the implementation of 
 the MIDP 3.0 Media API which is also specified in JSR 135.
X-SquirrelJME-Error: EA
X-SquirrelJME-UUID: 1be6eb96-52e4-4762-a1d0-5dd95e0c9f39
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/media-api/cc/squirreljme/runtime/media/NullPlayer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360








































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.media;

import java.util.LinkedList;
import java.util.List;
import javax.microedition.media.Control;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.TimeBase;

/**
 * This is a player which does nothing.
 *
 * @since 2019/04/15
 */
public final class NullPlayer
	implements Player
{
	/** The mime type. */
	private final String mime;
	
	/** Listeners available. */
	private final List<PlayerListener> _listeners =
		new LinkedList<>();
	
	/** The timebase. */
	private TimeBase _timebase =
		Manager.getSystemTimeBase();
	
	/** The state of the player. */
	private volatile int _state =
		UNREALIZED;
	
	/**
	 * Initializes the player.
	 *
	 * @param __mime The mime type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	public NullPlayer(String __mime)
		throws NullPointerException
	{
		if (__mime == null)
			throw new NullPointerException("NARG");
		
		this.mime = __mime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void addPlayerListener(PlayerListener __l)
	{
		// Ignore?
		if (__l == null)
			return;
		
		// {@squirreljme.error EA01 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA01");
		
		// Add unique listener
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			if (!listeners.contains(__l))
				listeners.add(__l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void close()
	{
		if (this._state != CLOSED)
		{
			this._state = CLOSED;
			
			// Send event
			this.__event(PlayerListener.CLOSED, null);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void deallocate()
	{
		// {@squirreljme.error EA03 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA03");
		
		if (this._state == STARTED)
		{
			// Implicit stop state
			try
			{
				this.stop();
			}
			catch (MediaException e)
			{
				e.printStackTrace();
			}
			
			// Become realized
			this._state = REALIZED;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final String getContentType()
	{
		return this.mime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final Control getControl(String __v)
	{
		// {@squirreljme.error AE07 No control specified.}
		if (__v == null)
			throw new IllegalArgumentException("AE07");
		
		if (__v.equals("VolumeControl") ||
			__v.equals("javax.microedition.media.control.VolumeControl"))
			return new NullVolumeControl();
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final Control[] getControls()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getDuration()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getMediaTime()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int getState()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final TimeBase getTimeBase()
	{
		return this._timebase;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void prefetch()
		throws MediaException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void realize()
		throws MediaException
	{
		// {@squirreljme.error EA04 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA04");
		
		if (this._state != UNREALIZED)
			this._state = REALIZED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void removePlayerListener(PlayerListener __l)
	{
		// Ignore?
		if (__l == null)
			return;
		
		// {@squirreljme.error EA02 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA02");
		
		// Remove it
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			listeners.remove(__l);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void setLoopCount(int __a)
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long setMediaTime(long __a)
		throws MediaException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void setTimeBase(TimeBase __a)
		throws MediaException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void start()
		throws MediaException
	{
		// {@squirreljme.error EA05 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA05");
		
		if (this._state != STARTED || this._state == PREFETCHED)
		{
			this._state = STARTED;
			
			// Send event
			this.__event(PlayerListener.STARTED,
				Long.valueOf(this._timebase.getTime()));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final void stop()
		throws MediaException
	{
		// {@squirreljme.error EA06 Null Player has been closed.}
		if (this._state == CLOSED)
			throw new IllegalStateException("EA06");
		
		if (this._state != STARTED)
		{
			this._state = PREFETCHED;
			
			// Send event
			this.__event(PlayerListener.STOPPED,
				Long.valueOf(this._timebase.getTime()));
		}
	}
	
	/**
	 * Sends an event to all listeners.
	 *
	 * @param __key The key used.
	 * @param __val The value used.
	 * @since 2019/06/28
	 */
	private final void __event(String __key, Object __val)
	{
		PlayerListener[] poke;
		
		// Get listeners to poke
		List<PlayerListener> listeners = this._listeners;
		synchronized (listeners)
		{
			poke = listeners.<PlayerListener>toArray(
				new PlayerListener[listeners.size()]);
		}
		
		// Poke them all
		for (PlayerListener pl : poke)
			try
			{
				pl.playerUpdate(this, __key, __val);
			}
			catch (Throwable t)
			{
				t.printStackTrace();
			}
	}
}

Deleted runt/apis/media-api/cc/squirreljme/runtime/media/NullVolumeControl.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.media;

import javax.microedition.media.control.VolumeControl;

/**
 * This is a volume control which does nothing.
 *
 * @since 2019/06/29
 */
public final class NullVolumeControl
	implements VolumeControl
{
	/** Current volume level. */
	private int _level =
		100;
	
	/** Is muted? */
	private boolean _mute;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int getLevel()
	{
		return this._level;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final boolean isMuted()
	{
		return this._mute;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final int setLevel(int __v)
	{
		this._level = (__v = (__v < 0 ? 0 : (__v > 100 ? 100 : __v)));
		return __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final void setMute(boolean __v)
	{
		this._mute = __v;
	}
}

Deleted runt/apis/media-api/cc/squirreljme/runtime/media/SystemNanoTimeBase.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.media;

import javax.microedition.media.TimeBase;

/**
 * This is a time base which uses the System nano-time clock.
 *
 * @since 2019/04/15
 */
public final class SystemNanoTimeBase
	implements TimeBase
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final long getTime()
	{
		// Measured in microseconds
		return System.nanoTime() / 1000L;
	}
}

Deleted runt/apis/media-api/cc/squirreljme/runtime/media/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the support for media and such.
 *
 * @since 2019/04/15
 */

package cc.squirreljme.runtime.media;

Deleted runt/apis/media-api/javax/microedition/media/Control.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface Control
{
}


Deleted runt/apis/media-api/javax/microedition/media/Controllable.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface Controllable
{
	public abstract Control getControl(String __a);
	
	public abstract Control[] getControls();
}


Deleted runt/apis/media-api/javax/microedition/media/Manager.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;

import cc.squirreljme.runtime.media.NullPlayer;
import cc.squirreljme.runtime.media.SystemNanoTimeBase;
import java.io.InputStream;
import java.io.IOException;
import javax.microedition.media.protocol.DataSource;

public final class Manager
{
	public static final String MIDI_DEVICE_LOCATOR =
		"device://midi";
	
	public static final String TONE_DEVICE_LOCATOR =
		"device://tone";
	
	/**
	 * Not used.
	 *
	 * @since 2017/02/28
	 */
	private Manager()
	{
	}
	
	public static Player createPlayer(InputStream __a, String __b)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s, %s)%n", __a, __b);
		if (true)
			return new NullPlayer(__b);
		
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static Player createPlayer(String __a)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s)%n", __a);
		if (true)
			return new NullPlayer("application/octet-stream");
			
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static Player createPlayer(DataSource __a)
		throws IOException, MediaException
	{
		todo.TODO.note("createPlayer(%s)%n", __a);
		if (true)
			return new NullPlayer(__a.getContentType());
		
		if (false)
			throw new IOException();
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
	
	public static String[] getSupportedContentTypes(String __a)
	{
		todo.DEBUG.note("getSupportedContentTypes(%s)%n", __a);
		throw new todo.TODO();
	}
	
	public static String[] getSupportedProtocols(String __a)
	{
		todo.DEBUG.note("getSupportedProtocols(%s)%n", __a);
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default timebase.
	 *
	 * @return The default timebase.
	 * @since 2019/04/15
	 */
	public static TimeBase getSystemTimeBase()
	{
		return new SystemNanoTimeBase();
	}
	
	public static void playTone(int __a, int __b, int __c)
		throws MediaException
	{
		todo.DEBUG.note("playTone(%d, %d, %d)%n", __a, __b, __c);
		if (true)
			throw new MediaException("TODO");
		
		if (false)
			throw new MediaException();
		throw new todo.TODO();
	}
}


Deleted runt/apis/media-api/javax/microedition/media/MediaException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;

/**
 * This is thrown when there was a problem with the media.
 *
 * @since 2019/04/15
 */
public class MediaException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/04/15
	 */
	public MediaException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message to use.
	 * @since 2019/04/15
	 */
	public MediaException(String __m)
	{
		super(__m);
	}
}


Deleted runt/apis/media-api/javax/microedition/media/Player.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;

public interface Player
	extends Controllable
{
	public static final int CLOSED =
		0;
	
	public static final int PREFETCHED =
		300;
	
	public static final int REALIZED =
		200;
	
	public static final int STARTED =
		400;
	
	public static final long TIME_UNKNOWN =
		-1L;
	
	public static final int UNREALIZED =
		100;
	
	public abstract void addPlayerListener(PlayerListener __a);
	
	public abstract void close();
	
	public abstract void deallocate();
	
	public abstract String getContentType();
	
	public abstract long getDuration();
	
	public abstract long getMediaTime();
	
	public abstract int getState();
	
	public abstract TimeBase getTimeBase();
	
	public abstract void prefetch()
		throws MediaException;
	
	public abstract void realize()
		throws MediaException;
	
	public abstract void removePlayerListener(PlayerListener __a);
	
	public abstract void setLoopCount(int __a);
	
	public abstract long setMediaTime(long __a)
		throws MediaException;
	
	public abstract void setTimeBase(TimeBase __a)
		throws MediaException;
	
	public abstract void start()
		throws MediaException;
	
	public abstract void stop()
		throws MediaException;
}


Deleted runt/apis/media-api/javax/microedition/media/PlayerListener.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface PlayerListener
{
	public static final String BUFFERING_STARTED =
		"bufferingStarted";
	
	public static final String BUFFERING_STOPPED =
		"bufferingStopped";
	
	public static final String CLOSED =
		"closed";
	
	public static final String DEVICE_AVAILABLE =
		"deviceAvailable";
	
	public static final String DEVICE_UNAVAILABLE =
		"deviceUnavailable";
	
	public static final String DURATION_UPDATED =
		"durationUpdated";
	
	public static final String END_OF_MEDIA =
		"endOfMedia";
	
	public static final String ERROR =
		"error";
	
	public static final String RECORD_ERROR =
		"recordError";
	
	public static final String RECORD_STARTED =
		"recordStarted";
	
	public static final String RECORD_STOPPED =
		"recordStopped";
	
	public static final String SIZE_CHANGED =
		"sizeChanged";
	
	public static final String STARTED =
		"started";
	
	public static final String STOPPED =
		"stopped";
	
	public static final String STOPPED_AT_TIME =
		"stoppedAtTime";
	
	public static final String VOLUME_CHANGED =
		"volumeChanged";
	
	public abstract void playerUpdate(Player __a, String __b, Object __c);
}


Deleted runt/apis/media-api/javax/microedition/media/TimeBase.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media;


public interface TimeBase
{
	public abstract long getTime();
}


Deleted runt/apis/media-api/javax/microedition/media/control/FramePositioningControl.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface FramePositioningControl
	extends Control
{
	public abstract long mapFrameToTime(int __a);
	
	public abstract int mapTimeToFrame(long __a);
	
	public abstract int seek(int __a);
	
	public abstract int skip(int __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/GUIControl.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface GUIControl
	extends Control
{
	public static final int USE_GUI_PRIMITIVE =
		0;
	
	public abstract Object initDisplayMode(int __a, Object __b);
}


Deleted runt/apis/media-api/javax/microedition/media/control/MIDIControl.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;
import javax.microedition.media.MediaException;

public interface MIDIControl
	extends Control
{
	public static final int CONTROL_CHANGE =
		176;
	
	public static final int NOTE_ON =
		144;
	
	public abstract int[] getBankList(boolean __a)
		throws MediaException;
	
	public abstract int getChannelVolume(int __a);
	
	public abstract String getKeyName(int __a, int __b, int __c)
		throws MediaException;
	
	public abstract int[] getProgram(int __a)
		throws MediaException;
	
	public abstract int[] getProgramList(int __a)
		throws MediaException;
	
	public abstract String getProgramName(int __a, int __b)
		throws MediaException;
	
	public abstract boolean isBankQuerySupported();
	
	public abstract int longMidiEvent(byte[] __a, int __b, int __c);
	
	public abstract void setChannelVolume(int __a, int __b);
	
	public abstract void setProgram(int __a, int __b, int __c);
	
	public abstract void shortMidiEvent(int __a, int __b, int __c);
}


Deleted runt/apis/media-api/javax/microedition/media/control/MetaDataControl.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface MetaDataControl
	extends Control
{
	public static final String AUTHOR_KEY =
		"author";
	
	public static final String COPYRIGHT_KEY =
		"copyright";
	
	public static final String DATE_KEY =
		"date";
	
	public static final String TITLE_KEY =
		"title";
	
	public abstract String getKeyValue(String __a);
	
	public abstract String[] getKeys();
}


Deleted runt/apis/media-api/javax/microedition/media/control/PitchControl.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface PitchControl
	extends Control
{
	public abstract int getMaxPitch();
	
	public abstract int getMinPitch();
	
	public abstract int getPitch();
	
	public abstract int setPitch(int __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/RateControl.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface RateControl
	extends Control
{
	public abstract int getMaxRate();
	
	public abstract int getMinRate();
	
	public abstract int getRate();
	
	public abstract int setRate(int __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/RecordControl.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import java.io.IOException;
import java.io.OutputStream;
import javax.microedition.media.Control;
import javax.microedition.media.MediaException;

public interface RecordControl
	extends Control
{
	public abstract void commit()
		throws IOException;
	
	public abstract String getContentType();
	
	public abstract void reset()
		throws IOException;
	
	public abstract void setRecordLocation(String __a)
		throws IOException, MediaException;
	
	public abstract int setRecordSizeLimit(int __a)
		throws MediaException;
	
	public abstract void setRecordStream(OutputStream __a);
	
	public abstract void startRecord();
	
	public abstract void stopRecord();
}


Deleted runt/apis/media-api/javax/microedition/media/control/StopTimeControl.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface StopTimeControl
	extends Control
{
	public static final long RESET =
		9223372036854775807L;
	
	public abstract long getStopTime();
	
	public abstract void setStopTime(long __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/TempoControl.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;


public interface TempoControl
	extends RateControl
{
	public abstract int getTempo();
	
	public abstract int setTempo(int __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/ToneControl.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface ToneControl
	extends Control
{
	public static final byte BLOCK_END =
		-6;
	
	public static final byte BLOCK_START =
		-5;
	
	public static final byte C4 =
		60;
	
	public static final byte PLAY_BLOCK =
		-7;
	
	public static final byte REPEAT =
		-9;
	
	public static final byte RESOLUTION =
		-4;
	
	public static final byte SET_VOLUME =
		-8;
	
	public static final byte SILENCE =
		-1;
	
	public static final byte TEMPO =
		-3;
	
	public static final byte VERSION =
		-2;
	
	public abstract void setSequence(byte[] __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/VideoControl.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.MediaException;

public interface VideoControl
	extends GUIControl
{
	public static final int USE_DIRECT_VIDEO =
		1;
	
	public abstract int getDisplayHeight();
	
	public abstract int getDisplayWidth();
	
	public abstract int getDisplayX();
	
	public abstract int getDisplayY();
	
	public abstract byte[] getSnapshot(String __a)
		throws MediaException;
	
	public abstract int getSourceHeight();
	
	public abstract int getSourceWidth();
	
	public abstract Object initDisplayMode(int __a, Object __b);
	
	public abstract void setDisplayFullScreen(boolean __a)
		throws MediaException;
	
	public abstract void setDisplayLocation(int __a, int __b);
	
	public abstract void setDisplaySize(int __a, int __b)
		throws MediaException;
	
	public abstract void setVisible(boolean __a);
}


Deleted runt/apis/media-api/javax/microedition/media/control/VolumeControl.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.control;

import javax.microedition.media.Control;

public interface VolumeControl
	extends Control
{
	public abstract int getLevel();
	
	public abstract boolean isMuted();
	
	public abstract int setLevel(int __a);
	
	public abstract void setMute(boolean __a);
}


Deleted runt/apis/media-api/javax/microedition/media/protocol/ContentDescriptor.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.protocol;


public class ContentDescriptor
{
	public ContentDescriptor(String __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public String getContentType()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/media-api/javax/microedition/media/protocol/DataSource.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.protocol;

import java.io.IOException;
import javax.microedition.media.Control;
import javax.microedition.media.Controllable;

public abstract class DataSource
	implements Controllable
{
	public DataSource(String __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract void connect()
		throws IOException;
	
	public abstract void disconnect();
	
	public abstract String getContentType();
	
	public abstract Control getControl(String __a);
	
	public abstract Control[] getControls();
	
	public abstract SourceStream[] getStreams();
	
	public abstract void start()
		throws IOException;
	
	public abstract void stop()
		throws IOException;
	
	public String getLocator()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/media-api/javax/microedition/media/protocol/SourceStream.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.media.protocol;

import java.io.IOException;
import javax.microedition.media.Controllable;

public interface SourceStream
	extends Controllable
{
	public static final int NOT_SEEKABLE =
		0;
	
	public static final int RANDOM_ACCESSIBLE =
		2;
	
	public static final int SEEKABLE_TO_START =
		1;
	
	public abstract ContentDescriptor getContentDescriptor();
	
	public abstract long getContentLength();
	
	public abstract int getSeekType();
	
	public abstract int getTransferSize();
	
	public abstract int read(byte[] __a, int __b, int __c)
		throws IOException;
	
	public abstract long seek(long __a)
		throws IOException;
	
	public abstract long tell();
}


Deleted runt/apis/meep-cellular/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Cellular Networking
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides an implementation which is used
  to access cellular networks.
X-SquirrelJME-Error: DH
X-SquirrelJME-DefinedStandards: microedition.cellular;;
X-SquirrelJME-UUID: eac4a39d-b264-44ca-9e77-38a96a6e30cc
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-concurrency/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Concurrency
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: The concurrency APIs allows multiple 
 applications to run at the same time.
X-SquirrelJME-Error: DK
X-SquirrelJME-DefinedStandards: microedition.concurrency;;
X-SquirrelJME-UUID: 70d937c9-e6d1-4618-a299-8182ea5e612e
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-event/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Event Management
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides an interface which allows an 
 application to receive events from the system along withsending events 
 to other running applications.
X-SquirrelJME-Error: DI
X-SquirrelJME-DefinedStandards: microedition.event;;
X-SquirrelJME-UUID: a4f80eca-c186-420b-b160-e47e612695a1
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-key/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Key Events
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains classes for handling key and 
 other user input events.
X-SquirrelJME-Error: DB
X-SquirrelJME-DefinedStandards: microedition.key;;
X-SquirrelJME-UUID: 90e52d37-a976-4f38-a194-9c65d34b6615
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-key/javax/microedition/key/InputDevice.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.key;

public interface InputDevice
{
	public abstract void setKeyListener(KeyListener __l);

	public abstract String getId();

	public abstract boolean isHardwareAssigned();

	public abstract void setHardwareAssigned(boolean __h);
}

Deleted runt/apis/meep-key/javax/microedition/key/InputDeviceListener.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.key;

/**
 * DESCRIBE THIS.
 *
 * @since 2016/08/30
 */
public interface InputDeviceListener
{
	public abstract void hardwareStateChanged(InputDevice __dev, boolean __hw);

	public abstract void inputDeviceAdded(InputDevice __dev);

	public abstract void inputDeviceRemoved(InputDevice __dev);
}

Deleted runt/apis/meep-key/javax/microedition/key/KeyListener.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
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
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.key;

public interface KeyListener
{
	public static final int DOWN =
		6;
		
	public static final int KEY_BACKSPACE =
		8;
		
	public static final int KEY_DELETE =
		127;
		
	public static final int KEY_DOWN =
		-2;
		
	public static final int KEY_ENTER =
		10;
		
	public static final int KEY_ESCAPE =
		27;
		
	public static final int KEY_LEFT =
		-3;
		
	public static final int KEY_NUM0 =
		48;
		
	public static final int KEY_NUM1 =
		49;
		
	public static final int KEY_NUM2 =
		50;
		
	public static final int KEY_NUM3 =
		51;
		
	public static final int KEY_NUM4 =
		52;
		
	public static final int KEY_NUM5 =
		53;
		
	public static final int KEY_NUM6 =
		54;
		
	public static final int KEY_NUM7 =
		55;
		
	public static final int KEY_NUM8 =
		56;
		
	public static final int KEY_NUM9 =
		57;
		
	public static final int KEY_POUND =
		35;
		
	public static final int KEY_RIGHT =
		-4;
		
	public static final int KEY_SELECT =
		-5;
		
	public static final int KEY_SPACE =
		32;
		
	public static final int KEY_STAR =
		42;
		
	public static final int KEY_TAB =
		9;
		
	public static final int KEY_UP =
		-1;
		
	public static final int LEFT =
		2;
		
	public static final int MODIFIER_ALT =
		65536;
		
	public static final int MODIFIER_CHR =
		8388608;
		
	public static final int MODIFIER_COMMAND =
		4194304;
		
	public static final int MODIFIER_CTRL =
		262144;
		
	public static final int MODIFIER_MASK =
		13041664;
		
	public static final int MODIFIER_SHIFT =
		131072;
		
	public static final int RIGHT =
		5;
		
	public static final int UP =
		1;

	public abstract void keyPressed(InputDevice __dev, int __code, int __mod);

	public abstract void keyReleased(InputDevice __dev, int __code, int __mod);

	public abstract void keyRepeated(InputDevice __dev, int __code, int __mod);
}

Deleted runt/apis/meep-key/javax/microedition/key/KeyManager.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.key;

import java.util.Iterator;

public class KeyManager
{
	/**
	 * Not used.
	 *
	 * @since 2016/08/30
	 */
	private KeyManager()
	{
	}
	
	public static Iterator<InputDevice> getInputDevices()
	{
		throw new todo.TODO();
	}

	public static Iterator<InputDevice> getHeadlessInputDevices()
	{
		throw new todo.TODO();
	}

	public static void addInputDeviceListener(InputDeviceListener __dl)
	{
		throw new todo.TODO();
	}

	public static void removeInputDeviceListener(InputDeviceListener __dl)
	{
		throw new todo.TODO();
	}

	public static void setGeneralKeyListener(KeyListener __kl)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-key/javax/microedition/key/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the keyboard input interfaces.
 *
 * @since 2016/08/30
 */

package javax.microedition.key;

Deleted runt/apis/meep-liblets/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Application Suites and LIBlets
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides support for application suites 
 and LIBlets.
X-SquirrelJME-Error: DL
X-SquirrelJME-DefinedStandards: microedition.liblets;;
X-SquirrelJME-UUID: aa14fb14-9806-40b6-9e27-6cc15cc2b457
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-lui/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Line Based Interface
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the base support for the line 
 based interface.
X-SquirrelJME-Depends: meep-key collections gcf
X-SquirrelJME-Error: DA
X-SquirrelJME-DefinedStandards: microedition.lui;;
X-SquirrelJME-UUID: 67a3561d-4c0d-495e-b4b6-6ec07a9ed71b
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-lui/cc/squirreljme/runtime/lui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the interfaces which the MEEP LUI code uses to
 * implement line based user interface display drivers.
 *
 * @since 2016/09/07
 */

package cc.squirreljme.runtime.lui;

Deleted runt/apis/meep-lui/javax/microedition/lui/Display.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796




























































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lui;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import net.multiphasicapps.collections.EmptyIterator;

/**
 * This provides an interface to basic text based displays.
 *
 * There may be multiple displays associated with a device and the displays
 * that are available may change at any rate. It is possible for a display to
 * support user input, which in this case it will generate key events.
 *
 * A single hardware display may be shared by multiple instances of these
 * classes, which one is actually visible is implementation dependent.
 *
 * Primary displays are ones that will never be removed. Primary displays
 * are always listed first.
 *
 * Auxiliary displays are ones that may be dynamically added and removed.
 *
 * Set text on a display may be lost depending on the implementation such as
 * if it implements scrolling in a specific fashion or the text does not fit.
 * As such, obtained text may be what is visible or might be what was not
 * truncated when set. Thus if {@code "SquirrelJME"} was set to the display
 * and scrolling was enabled, then it might return that text or something
 * such as {@code "JMESquirrel"}. An exception to this is line breaks where
 * if a line contains too much text it flows onto the next line, in this case
 * the text is treated as a single line and the break is not in the returned
 * text. Setting of text may enable scrolling if it is available.
 *
 * Color selection should always be the closest matching color that is
 * supported on a given display.
 *
 * Internally to SquirrelJME, this class acts as a wrapper around display
 * driver interfaces which are implemented via the service loader.
 * If a display supports user input then it must implement
 * the {@link javax.microedition.key.InputDevice} interface.
 *
 * @since 2016/08/30
 */
public class Display
{
	/**
	 * This is used as the event name to indicate the lighting level.
	 *
	 * The value will be either {@link #LIGHTING_ON}, {@link #LIGHTING_OFF},
	 * or {@link #LIGHTING_DIM}.
	 */
	public static final String LIGHTING =
		"LIGHTING";
	
	/**
	 * This indicates that the light level is not fully bright nor off, but
	 * is somewhere inbetween.
	 */
	public static final int LIGHTING_DIM =
		2;
	
	/** This indicates that the light level for a display is zero (off). */
	public static final int LIGHTING_OFF =
		0;
	
	/** The indicates that the light level for a display is bright. */
	public static final int LIGHTING_ON =
		1;
	
	/**
	 * This is used to specify that any power saving actions for a given
	 * display are to be deferred for as long as possible to increase the
	 * amount of time that the display is visible for.
	 */
	public static final int MODE_ACTIVE =
		1;
	
	/**
	 * This is used to specify that the display may enter a power saving mode
	 * for example when the device is idle and no input has been generated.
	 */
	public static final int MODE_NORMAL =
		0;
	
	/** Internal lock. */
	private final Object _lock =
		new Object();
	
	/**
	 * Displays are internally managed by this class and as such cannot be
	 * constructed publically or by drivers.
	 *
	 * @since 2016/10/08
	 */
	Display()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the color which represents the color which is actually being
	 * display by a given display.
	 *
	 * If background colors are not supported then this returns the default
	 * background color.
	 *
	 * @return The closest matching background color.
	 * @since 2016/08/30
	 */
	public DisplayColor getBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of characters which appear on a single line.
	 *
	 * @return The characters per line.
	 * @since 2016/08/30
	 */
	public int getCharacterNumberPerLine()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Reads all of the characters on a given display starting at index zero.
	 *
	 * If the array contains more characters than the display then the extra
	 * characters remain untouched.
	 *
	 * It is recommended to pass an array that is large enough to read all
	 * characters from the display.
	 *
	 * @param __o The output array to read characters into.
	 * @return The number of read characters.
	 * @throws ArrayIndexOutOfBoundsException If the array is too small to
	 * fit every character.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public int getChars(char[] __o)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Reads all of the characters on a given line starting at index zero.
	 *
	 * If the array contains more characters than the display then the extra
	 * characters remain untouched.
	 *
	 * It is recommended to pass an array that is large enough to read all
	 * characters from the display.
	 *
	 * @param __l The line number to get characters from.
	 * @param __o The output array to read characters into.
	 * @return The number of read characters.
	 * @throws ArrayIndexOutOfBoundsException If the array is too small to
	 * fit the entire line; or the line exceeds the bounds of the display.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public int getChars(int __l, char[] __o)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__o == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the text color that is currently used on the display. If text
	 * colors are not supported then the default color is returned.
	 *
	 * @return The text color which is used on the display.
	 * @since 2016/08/30
	 */
	public DisplayColor getCurrentTextColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default background color.
	 *
	 * @return The default background color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default lighting color.
	 *
	 * @return The default lighting color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultLightingColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default text color.
	 *
	 * @return The default text color.
	 * @since 2016/08/30
	 */
	public DisplayColor getDefaultTextColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of milliseconds between character shifts for the
	 * given line.
	 *
	 * If the display does not support horizontal scrolling then the value
	 * returned here is meaningless.
	 *
	 * @param __l The line to get the scrolling interval of.
	 * @throws ArrayIndexOutOfBoundsException If the specified line is not
	 * within the bounds of the display.
	 * @since 2016/08/30
	 */
	public int getHorizontalScrollingInterval(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the identification of the given display. It is recommended for
	 * the same hardware displays to return the same ID even if the given
	 * {@link Display} object has changed.
	 *
	 * @return The display identification.
	 * @since 2016/08/30
	 */
	public String getId()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current lighting color of the display. If lighting is not
	 * supported then this will return the default color.
	 *
	 * @return The currently set lighting color.
	 * @since 2016/08/30
	 */
	public DisplayColor getLightingColor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of lines which are available for the display.
	 *
	 * @return The number of lines the display uses.
	 * @since 2016/08/30
	 */
	public int getNumberOfLines()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current text which has previously been set.
	 *
	 * @return The current text display.
	 * @since 2016/08/30
	 */
	public String getText()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current text which has previously been set on a given line.
	 *
	 * @param __l The line to get the text for.
	 * @return The text on the given line.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public String getText(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of milliseconds that must pass before lines are
	 * shifted. If vertical scrolling is not supported then the return value is
	 * meaningless.
	 *
	 * @return The interval used for vertical scrolling.
	 * @since 2016/08/30
	 */
	public int getVerticalScrollingInterval()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if background colors are supported.
	 *
	 * @return {@code true} if background colors are supported.
	 * @since 2016/08/30
	 */
	public boolean isBackgroundColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if this display is built-in and is not auxiliary
	 * meaning that the display will never be removed. Otherwise {@code false}
	 * indicates that it may disappear.
	 *
	 * @return {@code true} if the display is built-in.
	 * @since 2016/08/30
	 */
	public boolean isBuiltIn()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This returns {@code true} if the display has access to the underlying
	 * hardware, which means it is capable of receiving user input and is
	 * currently displayed to the user.
	 *
	 * @return {@code true} if the display has access to the underlying
	 * hardware.
	 * @since 2016/08/30
	 */
	public boolean isHardwareAssigned()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if the specified line has horizontal scrolling
	 * enabled. If horizontal scrolling is not enabled then the return value
	 * is meaningless.
	 *
	 * @param __l The line to check.
	 * @return {@code true} if horizontal scrolling is enabled for the given
	 * line.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public boolean isHorizontalScrollingEnabled(int __l)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if horizontal scrolling is supported on the
	 * display.
	 *
	 * @return {@code true} if horizontal scrolling is supported.
	 * @since 2016/08/30
	 */
	public boolean isHorizontalScrollingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns true if the color of the lighting color is able to be changed.
	 *
	 * @return {@code true} if the lighting color can be changed.
	 * @since 2016/08/30
	 */
	public boolean isLightingColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if lighting is supported.
	 *
	 * @return {@code true} if lighting is supported.
	 * @since 2016/08/30
	 */
	public boolean isLightingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if text colors are supported.
	 *
	 * @return {@code true} if text colors are supported.
	 * @since 2016/08/30
	 */
	public boolean isTextColorsSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if vertical scrolling is enabled.
	 *
	 * @return {@code true} if vertical scrolling is enabled.
	 * @since 2016/08/30
	 */
	public boolean isVerticalScrollingEnabled()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if vertical scrolling is supported.
	 *
	 * @return {@code true} if vertical scrolling is supported.
	 * @since 2016/08/30
	 */
	public boolean isVerticalScrollingSupported()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the background color of the display. The closest matching color
	 * should be selected by the display.
	 *
	 * If lighting is supported then {@code __c} being set to {@code null}
	 * turns off the light. Otherwise the light is turned on when a color is
	 * set.
	 *
	 * @param __c The color to set.
	 * @return The color which was used by the display.
	 * @since 2016/08/30
	 */
	public DisplayColor setBackgroundColor(DisplayColor __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @since 2016/08/30
	 */
	public void setChars(char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException
	{
		setChars(__c, __o, __l, false, false);
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @since 2016/08/30
	 */
	public void setChars(char[] __c, int __o, int __l, boolean __blink,
		boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds; or the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setChars(int __ln, char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException
	{
		setChars(__ln, __c, __o, __l, false, false);
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __c The charactes to use.
	 * @param __o The offset in the charater array.
	 * @param __l The number of characters to write.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds; or the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setChars(int __ln, char[] __c, int __o, int __l,
		boolean __blink, boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the color of the text on the display.
	 *
	 * @param __c The color to set.
	 * @return The actual color which has been set.
	 * @since 2016/08/30
	 */
	public DisplayColor setCurrentTextColor(DisplayColor __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Requests that a display should be assigned to the hardware so that it
	 * can be displayed and receive user input.
	 *
	 * @param __h If {@code true} then it should be assigned to the hardware,
	 * otherwise {@code false} may unassign it.
	 * @since 2016/08/30
	 */
	public void setHardwareAssigned(boolean __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables horizontal scrolling for a given line.
	 *
	 * If both directions of scrolling is supported then this scrolls left to
	 * right.
	 *
	 * @param __l The line to set scrolling for.
	 * @param __e If {@code true} then scrolling is enabled.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrolling(int __l, boolean __e)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables horizontal scrolling for a given line.
	 *
	 * @param __l The line to set scrolling for.
	 * @param __e If {@code true} then scrolling is enabled.
	 * @param __dir If {@code true} then text scrolls left to right while
	 * {@code false} means right to left.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrolling(int __l, boolean __e, boolean __dir)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the amount of time in milliseconds before the next character is
	 * shifted on the given line.
	 *
	 * @param __l The line to modify the scrolling interval for.
	 * @param __i The number of milliseconds to use for the interval, a value
	 * of zero indicates the fastest scrolling possible.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within the
	 * bounds of the display.
	 * @throws IllegalArgumentException If the interval is negative.
	 * @since 2016/08/30
	 */
	public void setHorizontalScrollingInterval(int __l, int __i)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the color of the light to use for the given display.
	 *
	 * If {@code null} is specified then the light is turned off, otherwise
	 * it is switched on.
	 *
	 * @param __c The color to use for the light.
	 * @return The actually used color.
	 * @since 2016/08/30
	 */
	public DisplayColor setLightingColor(DisplayColor __l)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __t The text to display.
	 * @since 2016/08/30
	 */
	public void setText(String __t)
	{
		setText(__t, false, false);
	}
	
	/**
	 * Sets the characters used on the display. The entire display is used.
	 *
	 * @param __t The text to display.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @since 2016/08/30
	 */
	public void setText(String __t, boolean __blink, boolean __inverse)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __t The text to display.
	 * @throws ArrayIndexOutOfBoundsException If the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setText(int __ln, String __t)
		throws ArrayIndexOutOfBoundsException
	{
		setText(__ln, __t, false, false);
	}
	
	/**
	 * Sets the characters used on the display, on the given line.
	 *
	 * @param __ln The line to set text for.
	 * @param __t The text to display.
	 * @param __blink Should characters blink, if supported?
	 * @param __inverse Should characters be inverted, if supported?
	 * @throws ArrayIndexOutOfBoundsException If the line is not within
	 * bounds of the display.
	 * @since 2016/08/30
	 */
	public void setText(int __ln, String __t, boolean __blink,
		boolean __inverse)
		throws ArrayIndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables vertical scrolling.
	 *
	 * If either direction is supported then this scrolls top to bottom.
	 *
	 * @param __e If {@code true} then vertical scrolling is enabled.
	 * @since 2016/08/30
	 */
	public void setVerticalScrolling(boolean __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Enables or disables vertical scrolling.
	 *
	 * @param __e If {@code true} then vertical scrolling is enabled.
	 * @param __dir If {@code true} then the display scrolls top to bottom,
	 * otherwise {@code false} scrolls bottom to top.
	 * @since 2016/08/30
	 */
	public void setVerticalScrolling(boolean __e, boolean __dir)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the vertical scrolling interval, the amount of time it takes before
	 * the next line is shifted.
	 *
	 * @param __ms The number of milliseconds to wait before lines are shifted.
	 * A value of {@code 0} indicates that the fastest scrolling should be
	 * used.
	 * @throws IllegalArgumentException If the interval is negative.
	 * @since 2016/08/30
	 */
	public void setVerticalScrollingInterval(int __ms)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is used to register a listener for when displays are added,
	 * removed, or their state has been changed.
	 *
	 * @param __l The listener to add, if it has already been added then this
	 * has no effect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public static void addDisplayListener(DisplayListener __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * This returns an iterator containing any displays which are available
	 * for usage. Primary displays are always returned first.
	 *
	 * The returned iterator will be empty if all displays are taken by other
	 * applications or if they are non-attached auxiliary displays.
	 *
	 * It is recommended to call {@link #isHardwareAssigned()} to determine
	 * if the display is associated with the underlying hardware.
	 *
	 * @param __ks If {@code true} then only displays which support key input
	 * events will be returned, otherwise all displays will be used.
	 * @return An iterator over the displays which are available, the returned
	 * iterator may be empty (if there are no displays) and will never contain
	 * the same display multiple times.
	 * @since 2016/08/30
	 */
	public static Iterator<Display> getDisplays(boolean __ks)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Removes the specified listener so that it no longer receives display
	 * events.
	 *
	 * @param __l The listener to remove, if it has never been added then this
	 * has no effect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/30
	 */
	public static void removeDisplayListener(DisplayListener __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-lui/javax/microedition/lui/DisplayCapability.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lui;

/**
 * This represents the capabilities that a display supports in hardware.
 *
 * @since 2016/08/30
 */
public enum DisplayCapability
{
	/** Supports background colors. */
	SUPPORTS_BACKGROUND_COLORS,
	
	/** Supports horizontal scrolling. */
	SUPPORTS_HORIZONTAL_SCROLLING,
	
	/** Supports key events. */
	SUPPORTS_KEY_EVENTS,
	
	/** Supports lighting (backlight). */
	SUPPORTS_LIGHTING,
	
	/** Supports lighting with different colors (backlight). */
	SUPPORTS_LIGHTING_COLORS,
	
	/** Supports text colors. */
	SUPPORTS_TEXT_COLORS,
	
	/** Supports vertical scrolling. */
	SUPPORTS_VERTICAL_SCROLLING,
	
	/** End. */
	;
}

Deleted runt/apis/meep-lui/javax/microedition/lui/DisplayColor.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lui;

/**
 * This represents a color to be used for text colors, background colors, and
 * lighting colors.
 *
 * @since 2016/08/30
 */
public class DisplayColor
{
	/** Color components. */
	private final int _rgb;
	
	/**
	 * Initializes the color using the given components, the components must
	 * be in the range of 0 through 255.
	 *
	 * @param __r Red color component.
	 * @param __g Green color component.
	 * @param __b Blue color component.
	 * @throws IllegalArgumentException If any component is outside of the
	 * range if {@code [0, 255]}.
	 * @since 2016/08/30
	 */
	public DisplayColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error DA01 Initialization of color values out of
		// range, they must be in the range of 0-255. (Red; Green; Blue)}
		if (__r < 0 || __r > 255 || __g < 0 || __g > 255 || __b < 0 ||
			__b > 255)
			throw new IllegalArgumentException(String.format("DA01 %d %d %d",
				__r, __g, __b));
		
		// Set
		this._rgb = (__r << 16) | (__g << 8) | __b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof DisplayColor))
			return false;
		
		// Cast and check
		DisplayColor o = (DisplayColor)__o;
		return getRedComponent() == o.getRedComponent() &&
			getGreenComponent() == o.getGreenComponent() &&
			getBlueComponent() == o.getBlueComponent();
	}
	
	/**
	 * Returns the blue component.
	 *
	 * @return The blue component.
	 * @since 2016/08/30
	 */
	public int getBlueComponent()
	{
		return (this._rgb & 0xFF);
	}
	
	/**
	 * Returns the green component.
	 *
	 * @return The green component.
	 * @since 2016/08/30
	 */
	public int getGreenComponent()
	{
		return ((this._rgb >>> 8) & 0xFF);
	}
	
	/**
	 * Returns the red component.
	 *
	 * @return The red component.
	 * @since 2016/08/30
	 */
	public int getRedComponent()
	{
		return ((this._rgb >>> 16) & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public int hashCode()
	{
		return this._rgb;
	}
}

Deleted runt/apis/meep-lui/javax/microedition/lui/DisplayListener.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lui;

/**
 * This is a listener which is associated with the {@link Display} class and
 * is called in the event that new displays are added or removed from a
 * device.
 *
 * @since 2016/08/30
 */
public interface DisplayListener
{
	/**
	 * This is called when a new display has been added to the device.
	 *
	 * @param __d The display which was added.
	 * @since 2016/08/30
	 */
	public abstract void displayAdded(Display __d);
	
	/**
	 * This is called when a display has been removed from the device, any
	 * actions on the display following this might not have any effect.
	 *
	 * @param __d The display which was removed.
	 * @since 2016/08/30
	 */
	public abstract void displayRemoved(Display __d);
	
	/**
	 * This is called when the state of a display changes in hardware.
	 *
	 * @param __ns If {@code true} then the display was reassigned on the
	 * underlying hardware, if {@code false} then the display was unassigned.
	 * @since 2016/08/30
	 */
	public abstract void hardwareStateChanged(Display __d, boolean __ns);
}

Deleted runt/apis/meep-lui/javax/microedition/lui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the line based user interface which is used to provide a
 * terminal/console based interface with the user. This interface would be
 * used in situations where the graphical image based interface is not
 * supported.
 *
 * @since 2016/08/30
 */

package javax.microedition.lui;

Deleted runt/apis/meep-midlet/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP MIDlet Interface
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the MIDlet interface which 
 acts as the main entry point for all MIDlets.
X-SquirrelJME-Error: AD
X-SquirrelJME-Group: required
X-SquirrelJME-DefinedStandards: microedition.midlet;;
X-SquirrelJME-UUID: 1d9e3c4f-b0ec-4e83-b656-0454dd661868
X-SquirrelJME-Depends: tool-manifest-reader strings collections
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-midlet/cc/squirreljme/runtime/midlet/ActiveMidlet.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
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







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.midlet;

import javax.microedition.midlet.MIDlet;

/**
 * This is used to store the current MIDlet which is being run in the current
 * process.
 *
 * @since 2017/02/26
 */
public final class ActiveMidlet
{
	/** Lock to prevent multiple midlets from running. */
	private static final Object _ACTIVE_LOCK =
		new Object();
	
	/** Only a single midlet may run at a time. */
	private static volatile MIDlet _ACTIVE_MIDLET;
	
	/**
	 * Not used.
	 *
	 * @since 2017/02/26
	 */
	private ActiveMidlet()
	{
	}
	
	/**
	 * Returns the currently active midlet.
	 *
	 * @return The active midlet.
	 * @throws IllegalStateException If no midlet is set.
	 * @since 2017/02/26
	 */
	public static MIDlet get()
		throws IllegalStateException
	{
		MIDlet rv = ActiveMidlet.optional();
		
		// {@squirreljme.error AD01 No MIDlet is currently active.}
		if (rv == null)
			throw new IllegalStateException("AD01");
		
		return rv;
	}
	
	/**
	 * Returns the currently active midlet.
	 *
	 * @return The active midlet or {@code null} if none is active.
	 * @since 2019/04/14
	 */
	public static MIDlet optional()
		throws IllegalStateException
	{
		// Lock
		synchronized (_ACTIVE_LOCK)
		{
			return _ACTIVE_MIDLET;
		}
	}
	
	/**
	 * Sets the currently active midlet.
	 *
	 * @param __m The midlet to set.
	 * @throws IllegalStateException If a midlet is already set.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/26
	 */
	public static void set(MIDlet __m)
		throws IllegalStateException, NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Prevent multiple MIDlet launches
		synchronized (_ACTIVE_LOCK)
		{
			// {@squirreljme.error AD02 Only a single MIDlet may be active at
			// a time.}
			MIDlet active = _ACTIVE_MIDLET;
			if (active != null)
				throw new IllegalStateException("AD02");
			
			// Set active midlet
			_ACTIVE_MIDLET = __m;
		}
	}
}

Deleted runt/apis/meep-midlet/cc/squirreljme/runtime/midlet/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains SquirrelJME specific midlet code.
 *
 * @since 2016/10/16
 */

package cc.squirreljme.runtime.midlet;

Deleted runt/apis/meep-midlet/javax/microedition/midlet/AutoStartPermission.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.midlet;

import java.security.BasicPermission;
import java.security.Permission;

public final class AutoStartPermission
	extends BasicPermission
{
	public AutoStartPermission()
	{
		super(null);
		throw new todo.TODO();
	}

	public boolean implies(Permission __p)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-midlet/javax/microedition/midlet/MIDlet.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245





















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.midlet;

import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

public abstract class MIDlet
{
	/** This is the prefix used to override settings. */
	private static final String _APP_PROPERTY_OVERRIDE =
		"cc.squirreljme.runtime.midlet.override.";
	
	/** The cached manifest for obtaining properties. */
	private Reference<JavaManifest> _manifest;
	
	/** Is there no manifest? */
	private boolean _nomanifest;
	
	/**
	 * Initialize the MIDlet.
	 *
	 * @since 2017/02/08
	 */
	protected MIDlet()
	{
		// Set the active midlet to this one
		ActiveMidlet.set(this);
	}
	
	protected abstract void destroyApp(boolean __uc)
		throws MIDletStateChangeException;
	
	protected abstract void startApp()
		throws MIDletStateChangeException;
	
	/**
	 * Checks if the given permission is valid.
	 *
	 * Do not use this to check permissions.
	 *
	 * @param __p The permission to check.
	 * @return {@code 0} if permission is denied, {@code 1} if permitted,
	 * and {@code -1} if unknown.
	 * @throws IllegalStateException If this is a MIDP 3.0 application.
	 * @since 2019/05/05
	 */
	@Deprecated
	public final int checkPermission(String __p)
		throws IllegalStateException
	{
		// Ignore if null
		if (__p == null)
			return 1;
		
		// Not permitted on MIDP 3 or MEEP
		String profile = this.getAppProperty("microedition-profile");
		if (profile != null)
		{
			// Makes it easier to use
			profile = profile.toLowerCase();
			
			// {@squirreljme.error AD03 Cannot use check permission on
			// MIDP 3.0 or MEEP suite profiles.}
			if (profile.contains("midp-3") || profile.contains("meep"))
				throw new IllegalStateException("AD03");
		}
		
		// Do security check
		try
		{
			// If there is no security manager, just assume everything is
			// okay
			SecurityManager sm = System.getSecurityManager();
			if (sm == null)
				return 1;
			
			// Check it now
			sm.checkPermission(new RuntimePermission(__p));
			return 1;
		}
		catch (SecurityException e)
		{
			return 0;
		}
	}
	
	/**
	 * Obtains the value of a property for the current application. Properties
	 * are defined in the application descriptor along with the manifest file
	 * of the JAR.
	 *
	 * @param __p The property to obtain.
	 * @return The value of the given property or {@code null} if it is not
	 * defined.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/07
	 */
	public final String getAppProperty(String __p)
		throws NullPointerException
	{
		// Check
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Overridden property?
		JavaManifestKey key = new JavaManifestKey(__p);
		String val = System.getProperty(_APP_PROPERTY_OVERRIDE + key);
		if (val != null)
			return val.trim();
		
		// If there is not manifest, ignore this step
		if (!this._nomanifest)
		{
			// Lookup JAR manifest
			Reference<JavaManifest> ref = this._manifest;
			JavaManifest manifest;
		
			// Cache it?
			if (ref == null || (null == (manifest = ref.get())))
			{
				// Some application properties are inside of the manifest so
				// check that
				InputStream is = this.getClass().getResourceAsStream(
					"META-INF/MANIFEST.MF");
				try
				{
					// Not found, force failure
					if (is == null)
						throw new IOException();
					
					// Load it
					manifest = new JavaManifest(is);
					
					// Store it
					this._manifest = new WeakReference<>(manifest);
				}
				
				// Does not exist or failed to read
				catch (IOException e)
				{
					this._nomanifest = true;
					manifest = null;
				}
			}
			
			// Try to get key value
			if (manifest != null)
			{
				String rv = manifest.getMainAttributes().get(
					new JavaManifestKey(__p));
				if (rv != null)
					return rv.trim();
			}
		}
		
		// Key not found or no manifest
		return null;
	}
	
	/**
	 * Used by the application to notify the MIDlet that it is being destroyed
	 * and resources should be cleaned up and such. When this is called the
	 * program will be terminated.
	 *
	 * @since 2019/04/15
	 */
	public final void notifyDestroyed()
	{
		todo.DEBUG.note("Notification of destruction");
		
		// Kill the program
		System.exit(0);
	}
	
	/**
	 * Notifies that the application should be paused now.
	 *
	 * This does nothing on SquirrelJME.
	 *
	 * @since 2017/02/08
	 */
	@Deprecated
	public final void notifyPaused()
	{
	}
	
	/**
	 * This is code which should be called before the application is paused.
	 * 
	 * This does nothing on SquirrelJME.
	 *
	 * @since 2017/02/08
	 */
	@Deprecated
	public void pauseApp()
	{
	}
	
	public final boolean platformRequest(String __url)
		throws Exception
	{
		// Games from Konami require this to return true even though that means
		// the application should terminate after this point. This is handled
		// and does not thrown an exception on bad requests.
		// Returning false here will cause the games to not work.
		if ("hjoja".equals(__url))
			return true;
		
		// Debug
		todo.DEBUG.note("%s", __url);
		
		throw new todo.TODO();
	}
	
	@Deprecated
	public final void resumeRequest()
	{
		throw new todo.TODO();
	}
	
	public static String getAppProperty(String __name, String __vend,
		String __attrname, String __attrdelim)
		throws NullPointerException
	{
		if (__attrname == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-midlet/javax/microedition/midlet/MIDletIdentity.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.midlet;

public final class MIDletIdentity
{
	/**
	 * Internally intialized.
	 *
	 * @since 2016/08/30
	 */
	MIDletIdentity()
	{
		throw new todo.TODO();
	}
	
	public String getClient()
	{
		throw new todo.TODO();
	}
	
	public String getName()
	{
		throw new todo.TODO();
	}
	
	public String getVendor()
	{
		throw new todo.TODO();
	}
	
	public String getVersion()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/30
	 */
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-midlet/javax/microedition/midlet/MIDletStateChangeException.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.midlet;

/**
 * This must be thrown if the state change in a MIDlet has failed, however
 * it is deprecated and no longer should be used.
 *
 * @since 2019/09/25
 */
@Deprecated
public class MIDletStateChangeException
	extends Exception
{
	/**
	 * Initializes the exception with no message,
	 *
	 * @since 2019/09/25
	 */
	@Deprecated
	public MIDletStateChangeException()
	{
		super();
	}

	/**
	 * Initializes the exception with the given message,
	 *
	 * @param __s The message to use.
	 * @since 2019/09/25
	 */
	@Deprecated
	public MIDletStateChangeException(String __s)
	{
		super(__s);
	}
}

Deleted runt/apis/meep-midlet/javax/microedition/midlet/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This containts the MIDlet interface.
 *
 * @since 2016/08/30
 */

package javax.microedition.midlet;

Deleted runt/apis/meep-power/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Power Management
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides support for quering the current
  electrical state of the device along with the setting of potential new
  power modes.
X-SquirrelJME-Error: DJ
X-SquirrelJME-DefinedStandards: microedition.power;;
X-SquirrelJME-UUID: 0962c312-3747-4111-8cae-1f133045cec6
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-provisioning/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Provisioning
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides support for provisioning new 
 MIDlets and LIBlets which may exist on the network and can beseen in a 
 way as a remote application downloader and installerexcept by a more 
 concrete means. It is possible for applicationsto automatically be upda
 ted.
X-SquirrelJME-Error: DM
X-SquirrelJME-DefinedStandards: microedition.provisioning;;
X-SquirrelJME-UUID: 98ab129b-9ad6-4546-9782-9ef69c8f237a
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-rms.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/apis/meep-rms.test/TestNothing.in.

1
2


-
-
result: null
thrown: NoExceptionThrown

Deleted runt/apis/meep-rms.test/TestNothing.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import javax.microedition.rms.RecordStore;

import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

/**
 * Tests that nothing is done on the record.
 *
 * @since 2018/12/13
 */
public class TestNothing
	extends __RecordTest__<Object>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/13
	 */
	@Override
	public Object test(RecordStore __rs)
		throws RecordStoreException
	{
		try (RecordStore rs = RecordStore.openRecordStore("rmstest", true))
		{
		}
		
		return null;
	}
}

Deleted runt/apis/meep-rms.test/__RecordTest__.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;
import net.multiphasicapps.tac.TestSupplier;

/**
 * Base class to wrap record store access, since it needs to be created and
 * deleted.
 *
 * @param <T> The return type.
 * @since 2018/12/13
 */
abstract class __RecordTest__<T>
	extends TestSupplier<T>
{
	/**
	 * Runs an RMS test on the given record store.
	 *
	 * @param __rs The input record store.
	 * @return The result of the test.
	 * @throws NullPointerException On null arguments.
	 * @throws Throwable On any exception.
	 * @since 2018/12/13
	 */
	public abstract T test(RecordStore __rs)
		throws NullPointerException, Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/13
	 */
	@Override
	public final T test()
		throws Throwable
	{
		// Try to delete a previously created record store
		try
		{
			RecordStore.deleteRecordStore("rms-test");
		}
		
		// Ignore this because it is expected
		catch (RecordStoreNotFoundException e)
		{
		}
		
		// Open the database y creating a new one
		try (RecordStore rs = RecordStore.openRecordStore("rms-test", true))
		{
			// Run test on it
			return this.test(rs);
		}
	}
}

Deleted runt/apis/meep-rms/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Record Management System
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the implementation of the 
 record management system which is used to manage records whichmay be 
 used instead of the filesystem (if a filesystem is notsupported).
X-SquirrelJME-Error: DC
X-SquirrelJME-DefinedStandards: microedition.rms;;
X-SquirrelJME-UUID: e4276324-c1ea-4e3e-b264-ffac3b0e235d
X-SquirrelJME-Depends: meep-midlet tool-manifest-writer 
 meep-swm
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/BasicVinylLock.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

/**
 * This is a basic lock which is entirely managed within the current
 * application.
 *
 * @since 2018/12/14
 */
public final class BasicVinylLock
	implements VinylLock
{
	/** The state of the lock. */
	private volatile boolean _locked;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	public final void close()
	{
		synchronized (this)
		{
			this._locked = false;
		}
	}
	
	/**
	 * Locks this record so only a single set of actions can be performed on
	 * them, even for the same thread.
	 *
	 * @return {@code this}.
	 * @since 2018/12/14
	 */
	public final VinylLock lock()
	{
		for (;;)
			synchronized (this)
			{
				// Wait for the lock if it is locked
				if (this._locked)
				{
					try
					{
						this.wait();
					}
					catch (InterruptedException e)
					{
						// Ignore
					}
					
					// Try again
					continue;
				}
				
				// Otherwise lock and return self
				this._locked = true;
				return this;
			}
	}
}

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/SuiteIdentifier.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
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





































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.rms;

import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import javax.microedition.midlet.MIDlet;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskManager;

/**
 * This is used to help identify suites and such.
 *
 * @since 2019/04/14
 */
public final class SuiteIdentifier
{
	/** The identifier for the current suite. */
	private static long _CURRENT_ID;
	
	/** The current vendor. */
	private static String _CURRENT_VENDOR;
	
	/** The current name. */
	private static String _CURRENT_NAME;
	
	/**
	 * Not used.
	 *
	 * @since 2019/04/14
	 */
	private SuiteIdentifier()
	{
	}
	
	/**
	 * Returns the current identifier.
	 *
	 * @return The current identifier.
	 * @since 2019/04/14
	 */
	public static long currentIdentifier()
	{
		// Already been cached?
		long rv = _CURRENT_ID;
		if (rv != 0)
			return rv;
		
		// Set, cache, and store
		_CURRENT_ID = (rv = SuiteIdentifier.identifier(
			SuiteIdentifier.currentVendor(), SuiteIdentifier.currentName()));
		return rv;
	}
	
	/**
	 * Returns the current name.
	 *
	 * @return The current name.
	 * @since 2019/04/14
	 */
	public static String currentName()
	{
		String rv = _CURRENT_NAME;
		if (rv != null)
			return rv;
		
		// Use task manager
		if (ApiLevel.minimumLevel(ApiLevel.UNDEFINED))
		{
			// Need to obtain the current suite
			TaskManager tm = ManagerFactory.getTaskManager();
			Task ct = tm.getCurrentTask();
			Suite su = ct.getSuite();
			
			// Get
			rv = su.getName();
		}
		
		// Try through the current MIDlet properties
		if (rv == null)
		{
			MIDlet mid = ActiveMidlet.optional();
			if (mid != null)
				rv = mid.getAppProperty("MIDlet-Name");
		}
		
		// Fallback
		if (rv == null)
			rv = "UndefinedName";
		
		// Cache and return
		_CURRENT_NAME = rv;
		return rv;
	}
	
	/**
	 * Returns the current vendor.
	 *
	 * @return The current vendor.
	 * @since 2019/04/14
	 */
	public static String currentVendor()
	{
		String rv = _CURRENT_VENDOR;
		if (rv != null)
			return rv;
		
		// Use task manager
		if (ApiLevel.minimumLevel(ApiLevel.UNDEFINED))
		{
			// Need to obtain the current suite
			TaskManager tm = ManagerFactory.getTaskManager();
			Task ct = tm.getCurrentTask();
			Suite su = ct.getSuite();
			
			// Get
			rv = su.getVendor();
		}
		
		// Try through the current MIDlet properties
		if (rv == null)
		{
			MIDlet mid = ActiveMidlet.optional();
			if (mid != null)
				rv = mid.getAppProperty("MIDlet-Vendor");
		}
		
		// Fallback
		if (rv == null)
			rv = "UndefinedVendor";
		
		// Cache and return
		_CURRENT_VENDOR = rv;
		return rv;
	}
	
	/**
	 * Returns the suite identifier.
	 *
	 * @param __vend The vendor.
	 * @param __suite The suite.
	 * @return The identifier.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static long identifier(String __vend, String __suite)
		throws NullPointerException
	{
		if (__vend == null || __suite == null)
			throw new NullPointerException("NARG");
		
		return ((((long)__vend.hashCode()) & 0xFFFFFFFFL) << 32) |
			(((long)__suite.hashCode()) & 0xFFFFFFFFL);
	}
}

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/TemporaryVinylRecord.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516




































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * This is a vinyl record which stores all of its data within in memory
 * buffers.
 *
 * @since 2018/12/13
 */
public final class TemporaryVinylRecord
	implements VinylRecord
{
	/** The lock for this record. */
	protected final BasicVinylLock lock =
		new BasicVinylLock();
	
	/** Tracks which are available. */
	private final Map<Integer, Volume> _volumes =
		new LinkedHashMap<>();
	
	/** Next ID for storage. */
	private volatile int _nextvid =
		1;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	public final VinylLock lock()
	{
		return this.lock.lock();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int pageAdd(int __vid, byte[] __b, int __o, int __l,
		int __tag)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Create new page
		int pid = vol._nextpid++;
		Page page;
		vol._pages.put(pid, (page = new Page(pid)));
		
		// Volume modified
		vol._modcount++;
		vol._modtime = System.currentTimeMillis();
		
		// Store page data, will return the PID or error
		return page.setData(__b, __o, __l, __tag);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageDelete(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return ERROR_NO_PAGE;
		
		// Just remove it
		vol._pages.remove(__pid);
		
		// Return ID of the deleted page
		return __pid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final int[] pageList(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return new int[]{ERROR_NO_VOLUME};
		
		// Get page IDs
		Set<Integer> keys = vol._pages.keySet();
		int n = keys.size(),
			i = 0;
		int[] rv = new int[n];
		for (Integer v : keys)
			rv[i++] = v;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageNextId(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Return guessed next ID
		return vol._nextpid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int pageRead(int __vid, int __pid, byte[] __b, int __o,
		int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return ERROR_NO_PAGE;
		
		// Determine read limit
		byte[] data = page._data;
		int pagelen = data.length;
		if (__l > pagelen)
			__l = pagelen;
		
		// Copy data
		for (int i = 0; i < __l; i++, __o++)
			__b[__o] = data[i];
		
		// All would have been read
		return __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int pageSet(int __vid, int __pid, byte[] __b, int __o,
		int __l, int __tag)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return ERROR_NO_PAGE;
			
		// Volume modified
		vol._modcount++;
		vol._modtime = System.currentTimeMillis();
		
		// Store page data, will return the PID or error
		return page.setData(__b, __o, __l, __tag);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/01
	 */
	@Override
	public final int pageSize(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return ERROR_NO_PAGE;
		
		// Return data length
		return page._data.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int pageTag(int __vid, int __pid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		// Locate the page
		Page page = vol._pages.get(__pid);
		if (page == null)
			return ERROR_NO_PAGE;
		
		// Return page tag
		return page._tag;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int vinylSizeAvailable()
	{
		// This is technically limited by memory
		return (int)Math.min(Integer.MAX_VALUE,
			Runtime.getRuntime().freeMemory());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int volumeCreate(long __sid, String __n, boolean __wo)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Claim next ID
		int rv = this._nextvid++;
		
		// Make the track and store it
		this._volumes.put(rv, new Volume(rv, __sid, __n, __wo));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int[] volumeList()
	{
		Set<Integer> keys = this._volumes.keySet();
		
		// Setup basic integer array
		int n = keys.size();
		int[] rv = new int[n];
		
		// Fill in keys
		int at = 0;
		for (int v : keys)
			rv[at++] = v;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int volumeModCount(int __vid)
	{
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		return vol._modcount;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/09
	 */
	@Override
	public final int volumeModTime(int __vid, long[] __time)
		throws NullPointerException
	{
		if (__time == null)
			throw new NullPointerException("NARG");
		
		// Locate the volume
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return ERROR_NO_VOLUME;
		
		if (__time.length > 0)
			__time[0] = vol._modtime;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final String volumeName(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return null;
		return vol.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	public final boolean volumeOtherWritable(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return false;
		return vol.writeother;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final long volumeSuiteIdentifier(int __vid)
	{
		Volume vol = this._volumes.get(__vid);
		if (vol == null)
			return 0L;
		return vol.sid;
	}
	
	/**
	 * Represents a single page.
	 *
	 * @since 2019/04/15
	 */
	public static final class Page
	{
		/** The page ID. */
		protected final int pid;
		
		/** The page data. */
		volatile byte[] _data;
		
		/** The tag. */
		volatile int _tag;
		
		/**
		 * Initializes the page.
		 *
		 * @param __pid The page ID.
		 * @since 2019/04/15
		 */
		public Page(int __pid)
		{
			// Setup PID
			this.pid = __pid;
		}
		
		/**
		 * Sets the page data.
		 *
		 * @param __pid The page ID.
		 * @param __b The data.
		 * @param __o Offset into data.
		 * @param __l The length of data.
		 * @return The page ID or a negative value if an error.
		 * @throws IndexOutOfBoundsException If the offset and/or length
		 * exceed the array bounds.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/15
		 */
		public final int setData(byte[] __b, int __o, int __l, int __tag)
			throws IndexOutOfBoundsException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Create copy of the data
			try
			{
				// Allocate and copy data
				byte[] place = new byte[__l];
				for (int i = __o, o = 0; o < __l; i++, o++)
					place[o] = __b[i];
				
				// Store this data
				this._data = place;
			}
			
			// No memory to store this data?
			catch (OutOfMemoryError e)
			{
				return ERROR_NO_MEMORY;
			}
			
			// Set tag
			this._tag = __tag;
			
			// Return PID
			return this.pid;
		}
	}
	
	/**
	 * Represents a single volume.
	 *
	 * @since 2019/04/14
	 */
	public static final class Volume
	{
		/** The volume ID. */
		protected final int vid;
		
		/** The suite identifier. */
		protected final long sid;
		
		/** The suite name. */
		protected final String name;
		
		/** Allow write by others? */
		protected final boolean writeother;
		
		/** Pages in this volume. */
		final Map<Integer, Page> _pages = 
			new LinkedHashMap<>();
		
		/** The next page ID. */
		volatile int _nextpid =
			1;
		
		/** Modification count. */
		volatile int _modcount =
			0;
		
		/** Modification time. */
		volatile long _modtime =
			System.currentTimeMillis();
		
		/**
		 * Initializes the volume.
		 *
		 * @param __rid The volume ID.
		 * @param __sid The suite identifier.
		 * @param __name The name of the record.
		 * @param __wo Allow write by others?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/14
		 */
		public Volume(int __vid, long __sid, String __name, boolean __wo)
			throws NullPointerException
		{
			if (__name == null)
				throw new NullPointerException("NARG");
			
			this.vid = __vid;
			this.sid = __sid;
			this.name = __name;
			this.writeother = __wo;
		}
	}
}

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/VinylLock.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

/**
 * This is a lock for a vinyl record which may be unlocked when closed.
 *
 * @since 2018/12/14
 */
public interface VinylLock
	extends AutoCloseable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/14
	 */
	@Override
	public abstract void close();
}

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/VinylRecord.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.rms;

/**
 * This is a single record which stores multiple tracks of data.
 *
 * Vinyls have a single lock on them.
 *
 * @since 2018/12/13
 */
public interface VinylRecord
{
	/** No memory is available. */
	public static final int ERROR_NO_MEMORY =
		-1;
	
	/** No such volume. */
	public static final int ERROR_NO_VOLUME =
		-2;
	
	/** No such page. */
	public static final int ERROR_NO_PAGE =
		-3;
	
	/**
	 * Locks this record so only a single set of actions can be performed on
	 * them, even for the same thread.
	 *
	 * @return The lock used to eventually unlock, to be used with
	 * try-with-resources.
	 * @since 2018/12/14
	 */
	public abstract VinylLock lock();
	
	/**
	 * Adds a page to the given volume.
	 *
	 * @param __vid The volume ID.
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return The ID of the newly created page.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	public abstract int pageAdd(int __vid, byte[] __b, int __o, int __l,
		int __tag)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Deletes the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The page that was deleted or an error.
	 * @since 2019/06/09
	 */
	public abstract int pageDelete(int __vid, int __pid);
	
	/**
	 * Returns the list of pages in the volume.
	 *
	 * @param __vid The volume ID.
	 * @return The list of records, if the volume is not valid then
	 * the first entry will be the error code.
	 * @since 2019/04/15
	 */
	public abstract int[] pageList(int __vid);
	
	/**
	 * Returns the ID of the next page ID that might be used.
	 *
	 * @param __vid The volume ID.
	 * @return The next page ID or an error.
	 * @since 2019/06/09
	 */
	public abstract int pageNextId(int __vid);
	
	/**
	 * Returns the data of the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @param __b The output buffer.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or an error otherwise.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public abstract int pageRead(int __vid, int __pid, byte[] __b, int __o,
		int __l)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Sets a page to the given value.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return Should be the ID of the same page, otherwise an error.
	 * @throws IndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/09
	 */
	public abstract int pageSet(int __vid, int __pid, byte[] __b, int __o,
		int __l, int __tag)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Returns the size of the given page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The size of the page or an error otherwise.
	 * @since 2019/05/01
	 */
	public abstract int pageSize(int __vid, int __pid);
	
	/**
	 * Returns the tag of the page.
	 *
	 * @param __vid The volume ID.
	 * @param __pid The page ID.
	 * @return The tag identifier.
	 * @since 2019/05/13
	 */
	public abstract int pageTag(int __vid, int __pid);
	
	/**
	 * Returns the amount of space available for this record.
	 *
	 * @return The available space count.
	 * @since 2019/05/13
	 */
	public abstract int vinylSizeAvailable();
	
	/**
	 * Creates a new record.
	 *
	 * @param __sid The suite identifier.
	 * @param __n The name of the suite.
	 * @param __wo Allow write other?
	 * @return The identifier of the suite.
	 * @since 2019/04/14
	 */
	public abstract int volumeCreate(long __sid, String __n, boolean __wo);
	
	/**
	 * Returns the list of all available stores.
	 *
	 * @return The list of available stores.
	 * @since 2019/04/14
	 */
	public abstract int[] volumeList();
	
	/**
	 * Returns the modification count of the volume.
	 *
	 * @param __vid The volume ID.
	 * @return The modification count or an error.
	 * @since 2019/05/13
	 */
	public abstract int volumeModCount(int __vid);
	
	/**
	 * Returns the modification time of the volume.
	 *
	 * @param __vid The volume ID.
	 * @param __time The output time.
	 * @return Zero or an error.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/13
	 */
	public abstract int volumeModTime(int __vid, long[] __time)
		throws NullPointerException;
	
	/**
	 * Returns the name of the given record.
	 *
	 * @param __vid Volume ID.
	 * @return The name of the record or {@code null} if there is no name.
	 * @since 2019/04/14
	 */
	public abstract String volumeName(int __vid);
	
	/**
	 * Returns the suite identifier for the given record.
	 *
	 * @param __vid Volume ID.
	 * @return The suite identifier or {@code 0} if it is not valid.
	 * @since 2019/04/14
	 */
	public abstract long volumeSuiteIdentifier(int __vid);
	
	/**
	 * Returns if this volume is other writable.
	 *
	 * @param __vid The volume ID.
	 * @return If it is writable by others.
	 * @since 2019/04/15
	 */
	public abstract boolean volumeOtherWritable(int __vid);
}

Deleted runt/apis/meep-rms/cc/squirreljme/runtime/rms/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the SquirrelJME specific interfaces for the record
 * management system.
 *
 * @since 2017/02/27
 */

package cc.squirreljme.runtime.rms;

Deleted runt/apis/meep-rms/javax/microedition/rms/InvalidRecordIDException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is thrown when the ID for a record is not valid.
 *
 * @since 2017/02/26
 */
public class InvalidRecordIDException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public InvalidRecordIDException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public InvalidRecordIDException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordComparator.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is an interface which defines a method for comparing records in an
 * implementation defined manner.
 *
 * As an example the comparator may be used by the {@link RecordEnumeration}
 * in the following manner:
 * {@code
 * RecordComparator comp = new CustomRecordComparator();
 * if (comp.compare(recordstore.getRecord(a), recordstore.getRecord(b)) ==
 *     RecordComparator.PRECEDES)
 *     return a;
 * }
 *
 * @see RecordEnumeration
 * @see RecordFilter
 * @since 2017/02/26
 */
public interface RecordComparator
{
	/** This represents two equal records. */
	public static final int EQUIVALENT =
		0;
	
	/** This represents a record that follows another. */
	public static final int FOLLOWS =
		1;
	
	/** This represents a record that precedes another. */
	public static final int PRECEDES =
		-1;
	
	/**
	 * Compares the data in one record with the data in another record.
	 *
	 * @param __a The first record, the array must not be modified by the
	 * comparator.
	 * @param __b The second record, the array must not be modified by the
	 * comparator.
	 * @return The record comparison, one of {@link #EQUIVALENT},
	 * {@link #FOLLOWS}, or {@link #PRECEDES}.
	 * @since 2017/02/26
	 */
	public abstract int compare(byte[] __a, byte[] __b);
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordEnumeration.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
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




































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is used to enumerate over a record store and may travel in either
 * direction.
 *
 * If the {@link RecordStore} has been closed then
 * {@link RecordStoreNotOpenException} must be thrown even if it was later
 * re-opened. When closed the previous and next methods will return
 * {@code null}.
 *
 * If a {@link RecordStore} is modified during enumeration then some records
 * may become invalid, for this a {@link RecordListener} may be used to be
 * notified when records are added or removed.
 *
 * {@link RecordComparator} may be used to modify the iteration order and the
 * {@link RecordFilter} may be used to remove undesired entries.
 *
 * @see RecordFilter
 * @see RecordComparator
 * @since 2017/02/26
 */
public interface RecordEnumeration
{
	/**
	 * This should be called when the enumeration is no longer needed and as
	 * such it can free resources.
	 *
	 * @since 2017/02/26
	 */
	public abstract void destroy();
	
	/**
	 * This is used to quickly obtain the record at the specified index within
	 * this enumeration. When using this behavior it is recommended to not
	 * keep the enumeraton up to date, otherwise it is implementation defined.
	 *
	 * @param __i The index to get.
	 * @throws IllegalArgumentException If the index is negative or is at
	 * least {@link #numRecords()}.
	 * @since 2017/02/26
	 */
	public abstract int getRecordId(int __i)
		throws IllegalArgumentException;
	
	/**
	 * Returns {@code true} if there is a next element.
	 *
	 * @return {@code true} if there is a next element.
	 * @since 2017/02/26
	 */
	public abstract boolean hasNextElement();
	
	/**
	 * Returns {@code true} if there is a previous element.
	 *
	 * @return {@code true} if there is a previous element.
	 * @since 2017/02/26
	 */
	public abstract boolean hasPreviousElement();
	
	/**
	 * Returns {@code true} if the enumeration is kept up to date with changes.
	 *
	 * @return {@code true} if the enumeration is kept up to date with changes.
	 * @since 2017/02/26
	 */
	public abstract boolean isKeptUpdated();
	
	/**
	 * This is used by the enumeration to specify that it should be kept up
	 * to date with any record changes.
	 *
	 * If set to {@code true} this also performs the equivalent call to
	 * {@link #rebuild()}.
	 *
	 * Note that keeping enumerations up to date may cause performance issues.
	 *
	 * @param __u If {@code true} then the enumeration is kept updated.
	 * @since 2017/02/26
	 */
	public abstract void keepUpdated(boolean __u);
	
	/**
	 * Returns a copy of the data contained in the next record. Changes to the
	 * returned array will not modify the data in the record.
	 *
	 * @return The data for the next record.
	 * @throws InvalidRecordIDException If the record is not valid.
	 * @throws RecordStoreException If another unspecified exception occurs.
	 * @throws RecordStoreNotOpenException This is called when the record store
	 * is no longer open.
	 * @since 2017/02/26
	 */
	public abstract byte[] nextRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException;
	
	/**
	 * Returns the identifier of the next record.
	 *
	 * @return The next record.
	 * @throws InvalidRecordIDException If there is no next record.
	 * @since 2017/02/26
	 */
	public abstract int nextRecordId()
		throws InvalidRecordIDException;
	
	/**
	 * Returns a copy of the data contained in the previous record. Changes to
	 * the returned array will not modify the data in the record.
	 *
	 * @return The data for the previous record.
	 * @throws InvalidRecordIDException If the record is not valid.
	 * @throws RecordStoreException If another unspecified exception occurs.
	 * @throws RecordStoreNotOpenException This is called when the record store
	 * is no longer open.
	 * @since 2017/02/26
	 */
	public abstract byte[] previousRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException;
	
	/**
	 * Returns the identifier of the previous record.
	 *
	 * @return The previous record.
	 * @throws InvalidRecordIDException If there is no next record.
	 * @since 2017/02/26
	 */
	public abstract int previousRecordId()
		throws InvalidRecordIDException;
	
	/**
	 * Rebuilds the enumeration to reflect the most up to date state.
	 *
	 * @throws IllegalStateException If this enumeration was destroyed.
	 * @see #isKeptUpdated()
	 * @see #keepUpdated(boolean)
	 * @since 2017/02/26
	 */
	public abstract void rebuild()
		throws IllegalStateException;
	
	/**
	 * Repositions the enumeration so that the next element to be returned
	 * is the first element (and there is no previous element if that is
	 * called). The index will be reset back to zero.
	 *
	 * @since 2017/02/26
	 */
	public abstract void reset();
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordFilter.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is used to filter through records which may exist within an enumerated
 * record set.
 *
 * @see RecordComparator
 * @see RecordEnumeration
 * @since 2017/02/26
 */
public interface RecordFilter
{
	/**
	 * Checks whether the given record is a match for the criteria of this
	 * filter.
	 *
	 * @param __b The record data to check, the array data must not be
	 * modified.
	 * @return {@code true} if the specified record is a match.
	 * @since 2017/02/26
	 */
	public abstract boolean matches(byte[] __b);
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordListener.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is used to be notified of changes which occur in a record store.
 *
 * @since 2017/02/26
 */
public interface RecordListener
{
	/**
	 * This is called when a record was added to the store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the added record.
	 * @since 2017/02/26
	 */
	public abstract void recordAdded(RecordStore __rs, int __id);
	
	/**
	 * This is called when a record was changed in a store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the changed record.
	 * @since 2017/02/26
	 */
	public abstract void recordChanged(RecordStore __rs, int __id);
	
	/**
	 * This is called when a record was deleted from a store.
	 *
	 * @param __rs The record store the change was made in.
	 * @param __id The ID of the deleted record, an attempt to use the record
	 * after it has been used is illegal will throw an
	 * {@link InvalidRecordIDException}.
	 * @since 2017/02/26
	 */
	public abstract void recordDeleted(RecordStore __rs, int __id);
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStore.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309





























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

import cc.squirreljme.runtime.cldc.lang.ImplementationClass;
import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import cc.squirreljme.runtime.rms.VinylLock;
import cc.squirreljme.runtime.rms.VinylRecord;
import cc.squirreljme.runtime.rms.SuiteIdentifier;
import cc.squirreljme.runtime.rms.TemporaryVinylRecord;
import cc.squirreljme.runtime.swm.SuiteName;
import cc.squirreljme.runtime.swm.SuiteVendor;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.microedition.midlet.MIDlet;
import net.multiphasicapps.collections.IdentityLinkedHashSet;

/**
 * This is a record store which may be used by an application to store
 * information about it in an implementation defined manner.
 *
 * Opened record stores have an open count, as such for every open operation
 * there must be a close operation.
 *
 * Whenever the record store is modified, the version number will be
 * incremented.
 *
 * Record stores may optionally permit other suites to access and potentially
 * write their records, otherwise only the current suite may modify its own
 * records.
 *
 * @since 2017/02/26
 */
public class RecordStore
	implements AutoCloseable
{
	/** Specifies that any suite may access the records. */
	public static final int AUTHMODE_ANY =
		1;
	
	/** Specifies that only record store creator may access the records. */
	public static final int AUTHMODE_PRIVATE =
		0;
	
	/** The vinyl record where everything is stored. */
	static final VinylRecord _VINYL;
	
	/** Existing record stores. */
	static final Map<Integer, RecordStore> _STORE_CACHE =
		new LinkedHashMap<>();
	
	/** Identity map for listeners */
	private final Set<RecordListener> _listeners =
		new IdentityLinkedHashSet<>();
	
	/** The volume ID. */
	private final int _vid;
	
	/** The name. */
	private final String _name;
	
	/** Write to this? */
	private final boolean _write;
	
	/** How many times has this been opened? */
	private volatile int _opens;
	
	/**
	 * Initializes the record store manager.
	 *
	 * @since 2017/02/27
	 */
	static
	{
		// See if there is a service, this will fall back to an implementation
		// that is not shared and will only exist as long as the current
		// program is running
		VinylRecord vr;
		try
		{
			String vclass = ImplementationClass.implementationClass(
				VinylRecord.class.getName());
			vr = (vclass == null ? new TemporaryVinylRecord() :
				(VinylRecord)Class.forName(vclass).newInstance());
		}
		
		// If it fails to initialize, just use a blank one
		catch (ClassNotFoundException|IllegalAccessException|
			InstantiationException e)
		{
			vr = new TemporaryVinylRecord();
		}
		
		// Set
		_VINYL = vr;
	}
	
	/**
	 * Initializes the access to the record store.
	 *
	 * @param __vid The volume ID.
	 * @param __name The name.
	 * @param __w Write to this?
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private RecordStore(int __vid, String __name, boolean __w)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this._vid = __vid;
		this._name = __name;
		this._write = __w;
		this._opens = 1;
	}
	
	/**
	 * Adds the specified record to the record store and returns the record
	 * id for the newly added record.
	 *
	 * @param __b The data to store.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @param __tag The tag to identify the given record with.
	 * @return The record ID of the newly created record.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @throws RecordStoreException If some other error occurs.
	 * @throws RecordStoreFullException If there is not enough space to store
	 * the data.
	 * @since 2017/02/26
	 */
	public int addRecord(byte[] __b, int __o, int __l, int __tag)
		throws ArrayIndexOutOfBoundsException, NullPointerException,
			RecordStoreNotOpenException, RecordStoreException,
			RecordStoreFullException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error DC01 Cannot write record to read-only store.}
		if (!this._write)
			throw new RecordStoreException("DC01");
		
		// Used for later
		int rv;
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Add the page
			rv = vinyl.pageAdd(this._vid, __b, __o, __l, __tag);
			RecordStore.__checkError(rv);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordAdded(this, rv);
		return rv;
	}
	
	/**
	 * Calls {@code addRecord(__b, __o, __l, 0)}.
	 *
	 * @param __b As forwarded.
	 * @param __o As forwarded.
	 * @param __l As forwarded.
	 * @return As forwarded.
	 * @throws ArrayIndexOutOfBoundsException As forwarded.
	 * @throws NullPointerException As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @since 2017/02/26
	 */
	public int addRecord(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException,
			RecordStoreNotOpenException, RecordStoreException,
			RecordStoreFullException
	{
		return this.addRecord(__b, __o, __l, 0);
	}
	
	/**
	 * Adds a record listener to the given store to notify of when changes
	 * are made to records.
	 *
	 * If the record store is closed then this has no effect.
	 *
	 * @param __l The listener to call for changes, a listener which has
	 * already been added will not be added a second time.
	 * @since 2017/02/26
	 */
	public void addRecordListener(RecordListener __l)
	{
		// Ignore
		if (__l == null)
			return;
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// No effect if closed
			if (this._opens <= 0)
				return;
			
			// Add listener
			Set<RecordListener> listeners = this._listeners;
			synchronized (listeners)
			{
				listeners.add(__l);
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/26
	 */
	@Override
	public void close()
		throws RecordStoreNotOpenException, RecordStoreException
	{
		this.closeRecordStore();
	}
	
	/**
	 * Closes the record store.
	 *
	 * Note that due to the ability to have record stores opened multiple times
	 * the open count must reach zero before it is actually closed.
	 *
	 * When the store is fully closed all listeners will be removed.
	 *
	 * @throws RecordStoreNotOpenException If the record is not open.
	 * @throws RecordStoreException If there was an issue closing it.
	 * @since 2017/02/26
	 */
	public void closeRecordStore()
		throws RecordStoreNotOpenException, RecordStoreException
	{
		// Lock the record, so that only a single thread is messing with the
		// open counts and such
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// If closed then remove all the listeners
			if ((--this._opens) <= 0)
				this._listeners.clear();
		}
	}
	
	/**
	 * Deletes the specified record.
	 *
	 * @param __id The record to delete.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @throws RecordStoreException If there was an issue deleting the record.
	 * @throws SecurityException If the record cannot be deleted.
	 * @since 2017/02/26
	 */
	public void deleteRecord(int __id)
		throws InvalidRecordIDException, RecordStoreNotOpenException,
			RecordStoreException, SecurityException
	{
		// Used later
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Delete it
			int rv = vinyl.pageDelete(this._vid, __id);
			RecordStore.__checkError(rv);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordDeleted(this, __id);
	}
	
	/**
	 * Enumerates through the records that exist within this store.
	 *
	 * If a comparator is not specified then the traversal order is not
	 * defined.
	 *
	 * @param __f An optional filter used to filter records, may be
	 * {@code null}.
	 * @param __c An optional comparator used to modify the sort order, may
	 * be {@code null}.
	 * @param __ku If {@code true} then the enumeration is kept up to date.
	 * @param __tags The tags to use for basic filtering, if this is empty then
	 * an empty enumeration will be returned, if this is {@code null} then all
	 * tags will be selected.
	 * @return The enumeration over the records.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public RecordEnumeration enumerateRecords(RecordFilter __f,
		RecordComparator __c, boolean __ku, int[] __tags)
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Build one and perform a rebuild to initialize it
		__VolumeEnumeration__ rv = new __VolumeEnumeration__(this, __f,
			__c, __ku, __tags);
		rv.rebuild();
		
		// Use it
		return rv;
	}
	
	/**
	 * Calls {@code enumerateRecords(__f, __c, __ku, null)}.
	 *
	 * @param __f As forwarded.
	 * @param __c As forwarded.
	 * @param __ku As forwarded.
	 * @return As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @since 2017/02/26
	 */
	public RecordEnumeration enumerateRecords(RecordFilter __f,
		RecordComparator __c, boolean __ku)
		throws RecordStoreNotOpenException
	{
		return this.enumerateRecords(__f, __c, __ku, null);
	}
	
	/**
	 * Returns the last modification date of the record store.
	 *
	 * @return The last modification date of the record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public long getLastModified()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			long[] time = new long[1];
			int rv = vinyl.volumeModTime(this._vid, time);
			
			try
			{
				RecordStore.__checkError(rv);
			}
			catch (RecordStoreException e)
			{
				if (e instanceof RecordStoreNotOpenException)
					throw (RecordStoreNotOpenException)e;
				
				// {@squirreljme.error DC02 Could not get the record store
				// time.}
				throw new RuntimeException("DC02", e);
			}
			
			return time[0];
		}
	}
	
	/**
	 * Returns the name of the record store.
	 *
	 * @return The name of the record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public String getName()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		return this._name;
	}
	
	/**
	 * This returns the next record ID which would be used if a new record
	 * were to be added to this record store.
	 *
	 * The returned ID is only valid while the store remains open and before
	 * {@code addRecord()} is called.
	 *
	 * @return The next record ID.
	 * @throws RecordStoreException If there was another issue with the
	 * record store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public int getNextRecordID()
		throws RecordStoreException, RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Get next ID as a guess
			int rv = vinyl.pageNextId(this._vid);
			RecordStore.__checkError(rv);
			
			return rv;
		}
	}
	
	/**
	 * Returns the number of records in this store.
	 *
	 * @return The number of records in this store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2019/05/09
	 */
	public int getNumRecords()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Get record list
			int[] pages = vinyl.pageList(this._vid);
			
			// Check for error
			if (pages.length > 0)
				try
				{
					RecordStore.__checkError(pages[0]);
				}
				catch (RecordStoreNotOpenException e)
				{
					throw e;
				}
				catch (RecordStoreException e)
				{
					// {@squirreljme.error DC03 Error getting list of
					// records.}
					RecordStoreNotOpenException t =
						new RecordStoreNotOpenException("DC03");
					t.initCause(e);
					throw t;
				}
			
			// Return array size
			return pages.length;
		}
	}
	
	/**
	 * Returns a copy of the data which is stored in the given record.
	 *
	 * @param __id The ID of the record to get.
	 * @return A copy of the data stored in this record, if there is no data
	 * then this will return {@code null}.
	 * @throws InvalidRecordIDException If the ID is not valid.
	 * @throws RecordStoreException If there is a problem with the record
	 * store.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @since 2017/02/26
	 */
	public byte[] getRecord(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// This volume
		int vid = this._vid;
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Need to know the size of the record
			int size = vinyl.pageSize(vid, __id);
			RecordStore.__checkError(size);
			
			// Allocate data to read from it
			byte[] rv = new byte[size];
			
			// Read data
			int read = vinyl.pageRead(vid, __id, rv, 0, size);
			RecordStore.__checkError(read);
			
			return rv;
		}
	}
	
	/**
	 * Fills the specified array with a copy of the data within the given
	 * record.
	 *
	 * @param __id The ID of the record to get.
	 * @param __b The array to write data to.
	 * @param __o The offset into the array.
	 * @return The number of bytes copied into the array.
	 * @throws ArrayIndexOutOfBoundsException If the offset is negative or
	 * the record data exceeds the size of the output array.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public int getRecord(int __id, byte[] __b, int __o)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreNotOpenException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// This volume
		int vid = this._vid;
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Need to know the size of the record
			int size = vinyl.pageSize(vid, __id);
			RecordStore.__checkError(size);
			
			// {@squirreljme.error DC04 The record does not fit into the
			// output.}
			if (size < 0 || (__o + size) > __b.length)
				throw new ArrayIndexOutOfBoundsException("DC04");
			
			// Read data
			int read = vinyl.pageRead(vid, __id, __b, __o, size);
			RecordStore.__checkError(read);
			
			// Size is used as the return value
			return size;
		}
	}
	
	/**
	 * Returns the size of the given record.
	 *
	 * @param __id The record ID to get the size for.
	 * @return The size of the given record.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getRecordSize(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Need to know the size of the record
			int size = vinyl.pageSize(this._vid, __id);
			RecordStore.__checkError(size);
			
			// Return it
			return size;
		}
	}
	
	/**
	 * Returns the record store information.
	 *
	 * @return The record store information.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public RecordStoreInfo getRecordStoreInfo()
		throws RecordStoreNotOpenException
	{
		// Check open
		this.__checkOpen();
		
		// Just quickly create
		return new RecordStoreInfo(this._vid);
	}
	
	/**
	 * Returns the size of the record store.
	 *
	 * @return The record store size, not to exceed {@link Integer#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	@Deprecated
	public int getSize()
		throws RecordStoreNotOpenException
	{
		return (int)Math.min(Integer.MAX_VALUE,
			getRecordStoreInfo().getSize());
	}
	
	/**
	 * Returns the available size of the record store.
	 *
	 * @return The available record store size, not to exceed
	 * {@link Integer#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	@Deprecated
	public int getSizeAvailable()
		throws RecordStoreNotOpenException
	{
		return (int)Math.min(Integer.MAX_VALUE,
			getRecordStoreInfo().getSizeAvailable());
	}
	
	/**
	 * Returns the tag of the given record.
	 *
	 * @param __id The record ID to get the tag for.
	 * @return The tag of the given record.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws RecordStoreException If another problem occurs with the record
	 * store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getTag(int __id)
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Get and check tag
			int rv = vinyl.pageTag(this._vid, __id);
			RecordStore.__checkError(rv);
			
			return rv;
		}
	}
	
	/**
	 * Returns the version of the record store, this may be used to quickly
	 * determine if a store has been modified.
	 *
	 * @return The version of this record store.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2016/02/26
	 */
	public int getVersion()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			int rv = vinyl.volumeModCount(this._vid);
			
			try
			{
				RecordStore.__checkError(rv);
			}
			catch (RecordStoreException e)
			{
				if (e instanceof RecordStoreNotOpenException)
					throw (RecordStoreNotOpenException)e;
				
				// {@squirreljme.error DC05 Could not get the record store
				// version.}
				throw new RuntimeException("DC05", e);
			}
			
			return rv;
		}
	}
	
	/**
	 * Removes the specified record listener, this has no effect if it has
	 * already been removed or was never added.
	 *
	 * @param __l The record listener to remove.
	 * @since 2017/02/26
	 */
	public void removeRecordListener(RecordListener __l)
	{
		// Ignore
		if (__l == null)
			return;
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// No effect if closed
			if (this._opens <= 0)
				return;
			
			// Remove listener
			Set<RecordListener> listeners = this._listeners;
			synchronized (listeners)
			{
				listeners.remove(__l);
			}
		}
	}
	
	/**
	 * Sets the mode of the record store which permits or denies other suites
	 * access to this record store.
	 *
	 * This may only operate on fully closed record stores and no other
	 * suites must have this record store open when this is called.
	 *
	 * @param __auth The authorization mode to use.
	 * @param __write Whether writing should be permitted.
	 * @throws IllegalArgumentException If the authorization mode is not
	 * valid.
	 * @throws IllegalStateException If the record store is opened by any
	 * application.
	 * @throws RecordStoreException If some other problem occurs with the
	 * record store.
	 * @throws SecurityException If changing the mode is not permitted.
	 * @since 2017/02/26
	 */
	public void setMode(int __auth, boolean __write)
		throws IllegalArgumentException, IllegalStateException,
			RecordStoreException, SecurityException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			throw new todo.TODO();
		}
	}
	
	/**
	 * Sets the data for a record.
	 *
	 * @param __id The record ID to set.
	 * @param __b The input data.
	 * @param __o The offset into the array
	 * @param __l The number of bytes to write.
	 * @param __tag The new tag to set for the record, this replaces the
	 * old tag.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidRecordIDException If the record ID is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If another unspecified error happens.
	 * @throws RecordStoreFullException If there is not enough space to store
	 * the data.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public void setRecord(int __id, byte[] __b, int __o, int __l, int __tag)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotOpenException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error DC06 Cannot write record to read-only store.}
		if (!this._write)
			throw new RecordStoreException("DC06");
		
		// Used for later
		RecordListener[] listeners = this.__listeners();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			// Set the page
			__id = vinyl.pageSet(this._vid, __id, __b, __o, __l, __tag);
			RecordStore.__checkError(__id);
		}
		
		// Report to the listeners
		for (RecordListener l : listeners)
			l.recordChanged(this, __id);
	}
	
	/**
	 * Calls {@code setRecord(__id, __b, __o, __l, getTag(__id))}.
	 *
	 * @param __id As forwarded.
	 * @param __b As forwarded.
	 * @param __o As forwarded.
	 * @param __l As forwarded.
	 * @throws ArrayIndexOutOfBoundsException As forwarded.
	 * @throws InvalidRecordIDException As forwarded.
	 * @throws NullPointerException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotOpenException As forwarded.
	 * @since 2017/02/26
	 */
	public void setRecord(int __id, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, InvalidRecordIDException,
			NullPointerException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotOpenException
	{
		this.setRecord(__id, __b, __o, __l, this.getTag(__id));
	}
	
	/**
	 * Checks that this record store is open.
	 *
	 * @throws RecordStoreNotOpenException If it is not open.
	 * @since 2019/04/15
	 */
	private final void __checkOpen()
		throws RecordStoreNotOpenException
	{
		// {@squirreljme.error DC07 This record store is not open.
		if (this._opens <= 0)
			throw new RecordStoreNotOpenException("DC07");
	}
	
	/**
	 * Lists the pages that exist within this record store.
	 *
	 * @return The page IDs.
	 * @since 2019/05/13
	 */
	final int[] __listPages()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Check open
			this.__checkOpen();
			
			return vinyl.pageList(this._vid);
		}
	}
	
	/**
	 * Returns all of the listeners for this record store.
	 *
	 * @return The listeners.
	 * @since 2019/04/15
	 */
	private final RecordListener[] __listeners()
	{
		Set<RecordListener> listeners = this._listeners;
		return listeners.<RecordListener>toArray(
			new RecordListener[listeners.size()]);
	}
	
	/**
	 * Deletes the specified record store.
	 *
	 * Suites may only delete their own record store.
	 *
	 * This will not call {@link RecordListener#recordDelete(RecordStore, int)}
	 * listeners associated with the given record store.
	 *
	 * @param __n The name of the record store to delete.
	 * @throws RecordStoreException If the record store cannot be deleted due
	 * to being owned by another suite or deletion is not possible.
	 * @throws RecordStoreNotFoundException If the given record store was not
	 * found.
	 * @since 2017/02/26
	 */
	public static void deleteRecordStore(String __n)
		throws NullPointerException, RecordStoreException,
			RecordStoreNotFoundException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Our suite identifier to find our own records
		long mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Try to locate our record
			int got = -1;
			for (int rid : vinyl.volumeList())
			{
				// Another suite's volume
				if (mysid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				// Found the record?
				if (__n.equals(vinyl.volumeName(rid)))
				{
					got = -1;
					break;
				}
			}
			
			// {@squirreljme.error DC08 Cannot delete the specified record
			// store because it does not exist. (The name of the store)}
			if (got == -1)
				throw new RecordStoreNotFoundException("DC08 " + __n);
			
			throw new todo.TODO();
		}
	}
	
	/**
	 * Returns the list of record stores that are available and owned by
	 * this suite.
	 *
	 * @return The list of available record stores, the order is unspecified
	 * and implementation dependent. If there are no records then {@code null}
	 * will be returned.
	 * @since 2017/02/26
	 */
	public static String[] listRecordStores()
	{
		// Our suite identifier to find our own records
		long mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			List<String> rv = new ArrayList<>();
			
			// Go through all IDs and locate record store info
			for (int rid : vinyl.volumeList())
			{
				// Do not add records which belong to another suite
				if (mysid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				rv.add(vinyl.volumeName(rid));
			}
			
			return rv.<String>toArray(new String[rv.size()]);
		}
	}
	
	/**
	 * Attempts to open and optionally create the record store for this midlet
	 * with the specified name.
	 *
	 * If a password is specified then the record store will be encrypted to
	 * prevent tampering.
	 *
	 * If the record store has already been opened then it will return a
	 * previously opened record store.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __create If {@code true} then if the record store does not
	 * exist it will be created.
	 * @param __auth The authorization mode of the record which may permit
	 * other applications to access this record. If the record already exists
	 * then this argument will be ignored.
	 * @param __write If {@code true} then the record store may be written to
	 * by other suites. If the record already exists then this argument will be
	 * ignored.
	 * @return The newly opened or created record store, if the record store
	 * is already open then it will return the already open one.
	 * @throws IllegalArgumentException If the name is not valid or the
	 * authorization mode is not valid.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreFullException If there is no space remaining.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create,
		int __auth, boolean __write, String __pass)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.__openRecordStore(__n,
			SuiteIdentifier.currentVendor(), SuiteIdentifier.currentName(),
			__create, __auth, __write, __pass);
	}
	
	/**
	 * Forwards to {@code openRecordStore(__n, __create, __auth, __write, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __create As forwarded.
	 * @param __auth As forwarded.
	 * @param __write As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create,
		int __auth, boolean __write)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.openRecordStore(__n, __create, __auth, __write, "");
	}
	
	/**
	 * Forwards to {@code openRecordStore(__n, __create, AUTHMODE_PRIVATE,
	 * true, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __create As forwarded.
	 * @param __auth As forwarded.
	 * @param __write As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreFullException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, boolean __create)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreFullException, RecordStoreNotFoundException,
			SecureRecordStoreException, SecurityException
	{
		return RecordStore.openRecordStore(__n, __create, AUTHMODE_PRIVATE,
			true, "");
	}
	
	/**
	 * Attempts to open the record store created by another application.
	 *
	 * The record store must have been created with the {@link #AUTHMODE_ANY}
	 * authorization. If it is encrypted then the same password must be
	 * specified.
	 *
	 * If the vendor and suite is our own then this will be the same as
	 * calling: {@code openRecordStore(__n, false, AUTHMODE_PRIVATE, true,
	 * __pass)}.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __vend The vendor of the other suite.
	 * @param __name The name of the other suite.
	 * @return The opened record store.
	 * @throws IllegalArgumentException If the name, vendor, or suite names
	 * are not valid.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, String __vend,
		String __suite, String __pass)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		return RecordStore.__openRecordStore(__n, __vend, __suite, false,
			AUTHMODE_ANY, false, __pass);
	}
	
	/**
	 * Calls {@code openRecordStore(__n, __vend, __suite, "")}.
	 *
	 * @param __n As forwarded.
	 * @param __vend As forwarded.
	 * @param __name As forwarded.
	 * @return As forwarded.
	 * @throws IllegalArgumentException As forwarded.
	 * @throws RecordStoreException As forwarded.
	 * @throws RecordStoreNotFoundException As forwarded.
	 * @throws SecureRecordStoreException As forwarded.
	 * @throws SecurityException As forwarded.
	 * @since 2017/02/26
	 */
	public static RecordStore openRecordStore(String __n, String __vend,
		String __suite)
		throws IllegalArgumentException, RecordStoreException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		return RecordStore.openRecordStore(__n, __vend, __suite, "");
	}
	
	/**
	 * Checks for an error and throws an exception potentially.
	 *
	 * @param __id The ID to check, negative indicates error.
	 * @throws RecordStoreException If there is an error.
	 * @since 2019/05/01
	 */
	private static final void __checkError(int __id)
		throws RecordStoreException
	{
		// Error was detected
		if (__id < 0)
		{
			// {@squirreljme.error DC09 Could not add the record, there might
			// not be enough free space available.}
			if (__id == VinylRecord.ERROR_NO_MEMORY)
				throw new RecordStoreFullException("DC09");
			
			// {@squirreljme.error DC0a No such record store exists.}
			if (__id == VinylRecord.ERROR_NO_VOLUME)
				throw new RecordStoreNotFoundException("DC0a");
			
			// {@squirreljme.error DC0b No such record exists.}
			if (__id == VinylRecord.ERROR_NO_PAGE)
				throw new InvalidRecordIDException("DC0b");
			
			// {@squirreljme.error DC0c Unknown record store error. (Error)}
			throw new RecordStoreException("DC0c " + __id);
		}
	}
	
	/**
	 * Attempts to open and optionally create the record store for the
	 * specified MIDlet.
	 *
	 * If a password is specified then the record store will be encrypted to
	 * prevent tampering.
	 *
	 * If the record store has already been opened then it will return a
	 * previously opened record store.
	 *
	 * @param __n The name of the record store, must consist of 1 to 32
	 * Unicode characters.
	 * @param __create If {@code true} then if the record store does not
	 * exist it will be created.
	 * @param __auth The authorization mode of the record which may permit
	 * other applications to access this record. If the record already exists
	 * then this argument will be ignored.
	 * @param __write If {@code true} then the record store may be written to
	 * by other suites. If the record already exists then this argument will be
	 * ignored.
	 * @return The newly opened or created record store, if the record store
	 * is already open then it will return the already open one.
	 * @throws IllegalArgumentException If the name is not valid or the
	 * authorization mode is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws RecordStoreException If it could not be opened for another
	 * reason.
	 * @throws RecordStoreFullException If there is no space remaining.
	 * @throws RecordStoreNotFoundException If the record store could not be
	 * located.
	 * @throws SecureRecordStoreException The secured record could not be
	 * initialized.
	 * @throws SecurityException If the encryption password does not
	 * match an existing password.
	 * @since 2018/12/15
	 */
	private static RecordStore __openRecordStore(String __name, String __vend,
		String __suite, boolean __create, int __auth, boolean __write,
		String __pass)
		throws IllegalArgumentException, NullPointerException,
			RecordStoreException, RecordStoreFullException,
			RecordStoreNotFoundException, SecureRecordStoreException,
			SecurityException
	{
		if (__name == null || __vend == null || __suite == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error DC0d The name is not valid.}
		int namelen = __name.length();
		if (namelen < 1 || namelen > 32)
			throw new IllegalArgumentException("DC0d " + __name);
		
		// Get identifier, used to find the record
		long sid = SuiteIdentifier.identifier(__vend, __suite),
			mysid = SuiteIdentifier.currentIdentifier();
		
		// Lock
		VinylRecord vinyl = _VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			// Go through all records and try to find a pre-existing one
			int rv = -1;
			for (int rid : vinyl.volumeList())
			{
				// Belongs to another suite?
				if (sid != vinyl.volumeSuiteIdentifier(rid))
					continue;
				
				// Same name?
				if (__name.equals(vinyl.volumeName(rid)))
				{
					rv = rid;
					break;
				}
			}
			
			// Open a record which already exists
			if (rv >= 0)
			{
				// Use a pre-cached store
				Map<Integer, RecordStore> cache = _STORE_CACHE;
				RecordStore rs = cache.get(rv);
				if (rs == null)
					cache.put(rv, (rs = new RecordStore(rv, __name,
						sid == mysid || vinyl.volumeOtherWritable(rv))));
				
				// Increment the open count
				rs._opens++;
				return rs;
			}
			
			// {@squirreljme.error DC0e Could not find the specified record
			// store. (The name; The vendor; The suite)}
			if (!__create)
				throw new RecordStoreNotFoundException(
					String.format("DC0e %s %s %s", __name, __vend, __suite));
			
			// {@squirreljme.error DC0f Could not create the record, it is
			// likely that there is not enough space remaining.}
			rv = vinyl.volumeCreate(sid, __name, __write);
			if (rv < 0)
				throw new RecordStoreFullException("DC0f");
			
			// Since we created it, we can just return the info
			return new RecordStore(rv, __name, sid == mysid || __write);
		}
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStoreException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * General exception for record stores.
 *
 * @since 2017/02/26
 */
public class RecordStoreException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStoreFullException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is thrown when the operation could not be completed because the record
 * store is full.
 *
 * @since 2017/02/26
 */
public class RecordStoreFullException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreFullException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreFullException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStoreInfo.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
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





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

import cc.squirreljme.runtime.rms.VinylLock;
import cc.squirreljme.runtime.rms.VinylRecord;

/**
 * This stores information on a record store.
 *
 * @since 2017/02/26
 */
public final class RecordStoreInfo
{
	/** The volume ID. */
	private final int _vid;
	
	/**
	 * Used internally.
	 *
	 * @param __vid The volume ID.
	 * @since 2017/02/26
	 */
	RecordStoreInfo(int __vid)
	{
		this._vid = __vid;
	}
	
	/**
	 * Gets the authorization mode of the associated {@link RecordStore}.
	 *
	 * @return The authorization mode, one of
	 * {@link RecordStore#AUTHMODE_PRIVATE} or
	 * {@link RecordStore#AUTHMODE_ANY}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public int getAuthMode()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the size of the record store including any overhead it may
	 * have.
	 *
	 * @return The number of bytes the record store consumes, not to exceed
	 * {@link Long#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public long getSize()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of bytes which may be available for storage. This
	 * is only an estimate and the actual number may be higher or lower
	 * depending on overhead and storage requirements.
	 *
	 * @return The estimated number of bytes available for storage, not to
	 * exceed {@link Long#MAX_VALUE}.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public long getSizeAvailable()
		throws RecordStoreNotOpenException
	{
		// Lock
		VinylRecord vinyl = RecordStore._VINYL;
		try (VinylLock lock = vinyl.lock())
		{
			return vinyl.vinylSizeAvailable();
		}
	}
	
	/**
	 * Returns {@code true} if the record store is encrypted.
	 *
	 * @return {@code true} if the record store is encrypted.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public boolean isEncrypted()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns {@code true} if the record store can be written to by other
	 * suites. A value of {@code false} still specifies that the record may
	 * be written to by the current application.
	 *
	 * @return {@code true} if the record store can be written to by other
	 * suites.
	 * @throws RecordStoreNotOpenException If the record store is not open.
	 * @since 2017/02/26
	 */
	public boolean isWriteable()
		throws RecordStoreNotOpenException
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStoreNotFoundException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is thrown when the record store is missing.
 *
 * @since 2017/02/26
 */
public class RecordStoreNotFoundException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreNotFoundException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreNotFoundException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/RecordStoreNotOpenException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is thrown when an operation was attempted on a closed record store.
 *
 * @since 2017/02/26
 */
public class RecordStoreNotOpenException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public RecordStoreNotOpenException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public RecordStoreNotOpenException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/SecureRecordStoreException.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.rms;

/**
 * This is called when there was an issue with storing or loading of an
 * encrypted data store.
 *
 * @since 2017/02/26
 */
public class SecureRecordStoreException
	extends RecordStoreException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2017/02/26
	 */
	public SecureRecordStoreException()
	{
	}
	
	/**
	 * Initializes the exception with a message except without a cause.
	 *
	 * @param __m The exception message.
	 * @since 2017/02/26
	 */
	public SecureRecordStoreException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/__VolumeEnumeration__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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

































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 javax.microedition.rms;

import cc.squirreljme.runtime.rms.VinylLock;
import cc.squirreljme.runtime.rms.VinylRecord;
import java.util.ArrayList;
import java.util.List;

/**
 * This is the internal enumeration over records.
 *
 * @since 2019/05/13
 */
final class __VolumeEnumeration__
	implements RecordEnumeration
{
	/** The used record store. */
	protected final RecordStore store;
	
	/** The filter. */
	protected final RecordFilter filter;
	
	/** The comparator. */
	protected final RecordComparator comparator;
	
	/** Keep this updated? */
	private boolean _keepupdated;
	
	/** Tags to match. */
	private int[] _tags;
	
	/** Is this destroyed? */
	private boolean _destroyed;
	
	/** Last modification count. */
	private int _lastmod =
		-1;
	
	/** Built page list. */
	private List<__Page__> _pages;
	
	/**
	 * Initializes the record store enumeration.
	 *
	 * @param __store The store to use.
	 * @param __f An optional filter used to filter records, may be
	 * {@code null}.
	 * @param __c An optional comparator used to modify the sort order, may
	 * be {@code null}.
	 * @param __ku If {@code true} then the enumeration is kept up to date.
	 * @param __tags The tags to use for basic filtering, if this is empty then
	 * an empty enumeration will be returned, if this is {@code null} then all
	 * tags will be selected.
	 * @return The enumeration over the records.
	 * @throws RecordStoreNotOpenException If this record store is not open.
	 * @throws NullPointerException If no backing store was used.
	 * @since 2019/05/13
	 */
	__VolumeEnumeration__(RecordStore __store, RecordFilter __f,
		RecordComparator __c, boolean __ku, int[] __tags)
		throws NullPointerException
	{
		if (__store == null)
			throw new NullPointerException("NARG");
		
		this.store = __store;
		this.filter = __f;
		this.comparator = __c;
		this._keepupdated = __ku;
		this._tags = (__tags == null ? null : __tags.clone());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void destroy()
	{
		if (this._destroyed)
			return;
		
		this._destroyed = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int getRecordId(int __i)
		throws IllegalArgumentException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean hasNextElement()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean hasPreviousElement()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final boolean isKeptUpdated()
	{
		return this._keepupdated;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void keepUpdated(boolean __u)
	{
		// Check for destruction
		this.__checkDestroy();
		
		this._keepupdated = __u;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final byte[] nextRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int nextRecordId()
		throws InvalidRecordIDException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final byte[] previousRecord()
		throws InvalidRecordIDException, RecordStoreException,
			RecordStoreNotOpenException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final int previousRecordId()
		throws InvalidRecordIDException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void rebuild()
		throws IllegalStateException
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Used in the rebuild
		RecordStore store = this.store;
		RecordFilter filter = this.filter;
		RecordComparator comparator = this.comparator;
		int[] tags = this._tags;
		
		// Could fail
		try
		{
			// Record store has not been modified, ignore
			int nowmod = store.getVersion();
			if (this._pages != null && nowmod == this._lastmod)
				return;
			
			// Get all the page IDs
			int[] pageids = store.__listPages();
			
			// Build an initial page table
			List<__Page__> pages = new ArrayList<>(pageids.length);
			for (int pid : pageids)
			{
				// Quick filter by tag?
				if (tags != null)
				{
					// Get page tag
					int ptag = store.getTag(pid);
					
					// Only accept tags in this array
					boolean got = false;
					for (int mt : tags)
						if (ptag == mt)
						{
							got = true;
							break;
						}
					
					// Completely missed?
					if (!got)
						continue;
				}
				
				// Filter this?
				if (filter != null)
					throw new todo.TODO();
			}
			
			// Sort the input pages by their data?
			if (comparator != null)
				throw new todo.TODO();
			
			// Set new version
			this._pages = pages;
			this._lastmod = nowmod;
		}
		
		// {@squirreljme.error DC0g Could not rebuild the enumeration.}
		catch (RecordStoreException e)
		{
			throw new RuntimeException("DC0g", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/13
	 */
	@Override
	public final void reset()
	{
		// Check for destruction
		this.__checkDestroy();
		
		// Check for rebuild
		this.__checkRebuild();
		
		throw new todo.TODO();
	}
	
	/**
	 * Checks if this has been destroyed.
	 *
	 * @throws IllegalStateException If this was destroyed.
	 * @since 2019/05/13
	 */
	private final void __checkDestroy()
		throws IllegalStateException
	{
		// {@squirreljme.error DC0h Record store enumeration has been
		// destoryed.}
		if (this._destroyed)
			throw new IllegalStateException("DC0h");
	}
	
	/**
	 * Check if a rebuild needs to be done.
	 *
	 * @throws IllegalStateException If the update check could not be made.
	 * @since 2019/05/13
	 */
	private final void __checkRebuild()
		throws IllegalStateException
	{
		// Could fail
		try
		{
			if (this._pages == null || (this._keepupdated &&
				this.store.getVersion() != this._lastmod))
				this.rebuild();
		}
		catch (RecordStoreException e)
		{
			// {@squirreljme.error DC0i Could not check for updates.}
			throw new IllegalStateException("DC0i", e);
		}
	}
	
	/**
	 * Represents a raw page ID.
	 *
	 * @since 2019/05/13
	 */
	private static final class __Page__
	{
		/** The ID. */
		public final int id;
		
		/**
		 * Initializes the page reference.
		 *
		 * @param __id The page ID.
		 * @since 2019/05/13
		 */
		public __Page__(int __id)
		{
			this.id = __id;
		}
	}
}

Deleted runt/apis/meep-rms/javax/microedition/rms/package-info.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This is the record management system which is used to store and obtain
 * records.
 *
 * Record stores must be able to be read and modified by multiple applications
 * concurrently while maintaining atomic access. Applications are permitted
 * to access records managed by other applications.
 *
 * This package is optional.
 *
 * @since 2017/02/26
 */

package javax.microedition.rms;

Deleted runt/apis/meep-securityframework/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: MEEP Security Framework
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This is used to control and potentially grant
  or deny access to specific features that applicationsmay use.
X-SquirrelJME-Error: DO
X-SquirrelJME-DefinedStandards: microedition.securityframework;;
X-SquirrelJME-UUID: f0dbaace-ab99-4e1c-b967-959d8fa4b70a
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-swm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Name: MEEP Application Management System
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the application management 
 system, this allows programs (provided they have the correct 
 permissions) to launch other programs and install new applications 
 which may have been sourced from other locations.
X-SquirrelJME-Depends: collections meep-midlet
X-SquirrelJME-Error: DG
X-SquirrelJME-DefinedStandards: microedition.swm;;
X-SquirrelJME-UUID: 30e471c6-3fd7-4c78-b97e-0d6e3af8d0e1
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/APIName.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
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





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the name of an API.
 *
 * @since 2017/11/30
 */
public final class APIName
	implements Comparable<APIName>
{
	/** The name of the API. */
	protected final String string;
	
	/**
	 * Initializes the API name from the given string.
	 *
	 * @param __n The name of the API.
	 * @throws InvalidSuiteException If the suite is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public APIName(String __n)
		throws InvalidSuiteException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Force all APIs to be uppercase
		__n = StringUtils.toUpperCaseNoLocale(__n);
		
		// {@squirreljme.error AR01 An illegal character was
		// specified in the API name. (The API name)
		if (StringUtils.firstIndex("\0\r\n:;", __n) >= 0)
			throw new InvalidSuiteException(String.format("AR01 %s", __n));
		
		// {@squirreljme.error DG02 API name cannot be blank.}
		if (__n.length() <= 0)
			throw new InvalidSuiteException("DG02");
		
		this.string = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(APIName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof APIName))
			return false;
		
		return this.string.equals(((APIName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/ByteArrayJarStreamSupplier.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * This class provides a stream of a JAR file through a byte array.
 *
 * @since 2017/12/28
 */
public final class ByteArrayJarStreamSupplier
	implements JarStreamSupplier
{
	/** The offset. */
	protected final int offset;
	
	/** The length. */
	protected final int length;
	
	/** The byte array. */
	private final byte[] _data;
	
	/**
	 * Initializes the stream supplier for a simple byte array.
	 *
	 * @param __b The byte array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public ByteArrayJarStreamSupplier(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this._data = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public InputStream get()
	{
		return new ByteArrayInputStream(this._data, this.offset, this.length);
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/Configuration.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
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
191
192
193
194
195
196
197
198






































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a configuration such as CLDC which specifies which base
 * classes are available. Configurations may optionally be "compact" in which
 * they are a lighter version.
 *
 * @since 2016/12/14
 */
public final class Configuration
	implements Comparable<Configuration>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** Is this configuration compact? */
	protected final boolean compact;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the configuration using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite.
	 * @param __c If {@code true} then the configuration is compact.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Configuration(APIName __n, SuiteVersion __v, boolean __c)
		throws NullPointerException
	{
		if (__n == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __n;
		this.version = __v;
		this.compact = __c;
	}
	
	/**
	 * Initializes the configuration by parsing the given string.
	 *
	 * @param __s The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Configuration(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AR02 Expected two or three fields for the
		// configuration. (The input string)}
		String[] fields = StringUtils.fieldSplit('-', __n);
		int fn = fields.length;
		if (fn != 2 && fn != 3)
			throw new InvalidSuiteException(String.format("AR02 %s", __n));
		
		// Potentially compact?
		this.compact = (fn > 2 &&
			0 == fields[2].compareToIgnoreCase("compact"));
		
		// Parse name and version
		this.name = new APIName(fields[0]);
		this.version = new SuiteVersion(fields[1]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(Configuration __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		rv = this.version.compareTo(__o.version);
		if (rv != 0)
			return rv;
		
		// Compact is before non-compact
		boolean a = this.compact,
			b = __o.compact;
		if (a != b)
			return (a ? -1 : 1);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Configuration))
			return false;
		
		Configuration o = (Configuration)__o;
		return this.name.equals(o.name) &&
			this.version.equals(o.version) &&
			this.compact == o.compact;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version) ^
			(this.compact ? 0xFFFFFFFF : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Configuration " +
				this.name + ":" + this.version +
				(this.compact ? "-compact" : "")));
		
		return rv;
	}
	
	/**
	 * Returns the version of this configuration.
	 *
	 * @return The configuration version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/DependencyInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.collections.ArrayUtils;
import net.multiphasicapps.collections.EmptySet;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This contains the information which specifies all of the dependencies which
 * and application depends on.
 *
 * @since 2017/11/30
 */
public final class DependencyInfo
{
	/** The dependencies. */
	protected final Set<MarkedDependency> depends;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dependency information.
	 *
	 * @param __deps The dependencies to depend on.
	 * @since 2017/12/31
	 */
	public DependencyInfo(MarkedDependency... __deps)
	{
		this((__deps == null ? EmptySet.<MarkedDependency>empty() :
			Arrays.<MarkedDependency>asList(__deps)));
	}
	
	/**
	 * Initialzies the dependency information.
	 *
	 * @param __deps The dependencies to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public DependencyInfo(Collection<MarkedDependency> __deps)
		throws NullPointerException
	{
		if (__deps == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedDependency> depends = new LinkedHashSet<>();
		for (MarkedDependency d : __deps)
			if (d == null)
				throw new NullPointerException("NARG");
			else
				depends.add(d);
		this.depends = UnmodifiableSet.<MarkedDependency>of(depends);
	}
	
	/**
	 * Returns the dependency set.
	 *
	 * @return The dependency set.
	 * @since 2017/12/31
	 */
	public Set<MarkedDependency> dependencies()
	{
		return this.depends;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof DependencyInfo))
			return false;
		
		return this.depends.equals(((DependencyInfo)__o).depends);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.depends.hashCode();
	}
	
	/**
	 * Checks if the dependency information is empty.
	 *
	 * @return If the dependency info is empty.
	 * @since 2017/11/30
	 */
	public final boolean isEmpty()
	{
		return this.depends.isEmpty();
	}
	
	/**
	 * Matches this dependency information to see if any of the provided
	 * fields would statisfy the dependencies that are needed.
	 *
	 * @param __prov The provided information.
	 * @return The result of the match.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public final MatchResult match(ProvidedInfo __prov)
		throws NullPointerException
	{
		if (__prov == null)
			throw new NullPointerException("NARG");
		
		// Remove matching dependencies from the input while keeping the
		// matching ones
		Set<MarkedDependency> depends = new LinkedHashSet<>(this.depends),
			matched = new LinkedHashSet<>();
		for (MarkedProvided p : __prov.provided())
		{
			for (Iterator<MarkedDependency> it = depends.iterator();
				it.hasNext();)
			{
				MarkedDependency d = it.next();
				
				if (d.matchesProvided(p))
				{
					matched.add(d);
					it.remove();
				}
			}
		}
		
		return new MatchResult(new DependencyInfo(matched),
			new DependencyInfo(depends));
	}
	
	/**
	 * Returns dependency information which contains no optional
	 * dependencies.
	 *
	 * @return Dependency information with no optionals.
	 * @since 2017/11/30
	 */
	public final DependencyInfo noOptionals()
	{
		// Ignore if there are no dependencies
		Set<MarkedDependency> depends = this.depends;
		if (depends.isEmpty())
			return this;
		
		// Include only required dependencies
		Set<MarkedDependency> instead = new LinkedHashSet<>();
		for (MarkedDependency md : depends)
			if (!md.isOptional())
				instead.add(md);
		
		// There were no optional dependencies
		if (depends.size() == instead.size())
			return this;
		return new DependencyInfo(instead);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Dependencies:" +
				this.depends));
		
		return rv;
	}
	
	/**
	 * Parses the given suite information and returns the dependency
	 * information.
	 *
	 * @param __info The suite information to parse.
	 * @return The parsed dependency information.
	 * @throws InvalidSuiteException If the dependencies is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/20
	 */
	public static final DependencyInfo of(SuiteInfo __info)
		throws InvalidSuiteException, NullPointerException
	{
		if (__info == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedDependency> depends = new LinkedHashSet<>();
		JavaManifestAttributes attr = __info.manifest().getMainAttributes();
		String value;
		
		// The CLDC library to use
		value = attr.getValue("microedition-configuration");
		if (value != null)
		{
			value = value.trim();
			
			// Old software may rely on using 1.0 values when that is illegal
			if (value.equals("1.0"))
				depends.add(new Configuration("CLDC-1.0"));
			
			// Decode otherwise
			else
				depends.add(new Configuration(value.trim()));
		}
		
		// Profiles needed to run
		value = attr.getValue("microedition-profile");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
			{
				// Old software may rely on using the version directly
				if (s.equals("2.0"))
					depends.add(new Profile("MIDP-2.0"));
				
				// Decode otherwise
				else
					depends.add(new Profile(s));
			}
		
		// Parse entries in sequential order
		SuiteType type = __info.type();
		for (int i = 1; i >= 1; i++)
		{
			// Stop if no more values are read
			value = attr.getValue(type.dependencyKey(i));
			if (value == null)
				break;
			
			// Decode dependency
			depends.add(new SuiteDependency(value));
		}
		
		// Build
		return new DependencyInfo(depends);
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/EntryPoint.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents an entry point of a JAR.
 *
 * @since 2017/08/20
 */
public final class EntryPoint
	implements Comparable<EntryPoint>
{
	/** The name of the entry point. */
	protected final String name;
	
	/** The entry point class. */
	protected final String entry;
	
	/** Is this a midlet? */
	protected final boolean ismidlet;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the entry point.
	 *
	 * @param __name The name of the entry point.
	 * @param __entry The class used for entry.
	 * @param __mid Is this a midlet launch?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	public EntryPoint(String __name, String __entry, boolean __mid)
		throws NullPointerException
	{
		// Check
		if (__name == null || __entry == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.entry = __entry;
		this.ismidlet = __mid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int compareTo(EntryPoint __o)
	{
		// Do non-midlets first
		boolean ma = this.ismidlet,
			mb = __o.ismidlet;
		if (ma != mb)
			if (!ma)
				return -1;
			else
				return 1;
		
		// Then the rest
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.entry.compareTo(__o.entry);
	}
	
	/**
	 * Returns the entry point class of the entry point.
	 *
	 * @return The entry point class.
	 * @since 2017/08/20
	 */
	public String entryPoint()
	{
		return this.entry;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof EntryPoint))
			return false;
		
		EntryPoint o = (EntryPoint)__o;
		return this.name.equals(o.name) &&
			this.entry.equals(o.entry) &&
			this.ismidlet == o.ismidlet;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.entry.hashCode() ^
			(this.ismidlet ? 1 : 0);
	}
	
	/**
	 * Is this a MIDlet?
	 *
	 * @return If this is a MIDlet or not.
	 * @since 2017/08/20
	 */
	public boolean isMidlet()
	{
		return this.ismidlet;
	}
	
	/**
	 * Returns the name of the entry point.
	 *
	 * @return The entry point name.
	 * @since 2017/08/20
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s (%s: %s)", this.name, (this.ismidlet ? "MIDlet" :
				"Classic"), this.entry)));
		
		return rv;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/EntryPoints.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
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




















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This parses the entry points which are available for usage.
 *
 * @since 2017/08/20
 */
public class EntryPoints
	extends AbstractList<EntryPoint>
{
	/** Available entry points. */
	private final EntryPoint[] _entrypoints;
	
	/**
	 * Initializes the entry points the hosted launcher can find.
	 *
	 * @param __man The manifest to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public EntryPoints(JavaManifest __man)
		throws NullPointerException
	{
		this(__man.getMainAttributes());
	}
	
	/**
	 * Initializes the entry points the hosted launcher can find.
	 *
	 * @param __attr The attributes to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	public EntryPoints(JavaManifestAttributes __attr)
		throws NullPointerException
	{
		// Check
		if (__attr == null)
			throw new NullPointerException("NARG");
		
		// Target list
		List<EntryPoint> target = new ArrayList<>();
		
		// Parse main class first
		String oldclass = __attr.get(new JavaManifestKey("Main-Class"));
		if (oldclass != null)
			target.add(new EntryPoint("Command Line", oldclass, false));
		
		// Parse MIDlet identifiers next
		for (int i = 1; i >= 1; i++)
		{
			// These are always in sequence
			String midletval = __attr.get(new JavaManifestKey(
				String.format("MIDlet-%d", i)));
			if (midletval == null)
				break;
			
			// The MIDlet field is in 3 fields: name, icon, class
			// {@squirreljme.error AR03 Expected two commas in the MIDlet
			// field.}
			int pc = midletval.indexOf(','),
				sc = midletval.indexOf(',', Math.max(pc + 1, 0));
			if (pc < 0 || sc < 0)
				throw new RuntimeException("AR03");
		
			// Split fields
			target.add(new EntryPoint(midletval.substring(0, pc).trim(),
				midletval.substring(sc + 1).trim(), true));
		}
		
		// Finalize
		EntryPoint[] entrypoints = target.<EntryPoint>toArray(
			new EntryPoint[target.size()]);
		this._entrypoints = entrypoints;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public EntryPoint get(int __i)
	{
		return this._entrypoints[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/20
	 */
	@Override
	public int size()
	{
		return this._entrypoints.length;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/ExtendedTaskManager.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.io.OutputStream;
import java.util.Map;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;

/**
 * This interface is used for providing the ability to launch tasks.
 *
 * @since 2019/02/02
 */
public interface ExtendedTaskManager
{
	/**
	 * Attempts to create a task which runs the given suite.
	 *
	 * The task is created and is initially in the {@link TaskStatus#STARTING}
	 * state. If starting fails then it enters the
	 * {@link TaskStatus#START_FAILED} state.
	 *
	 * A suite may only be active once and cannot have multiple copies running
	 * at the same time. In the event that an application is already running it
	 * must be sent an event specifying an application re-launch.
	 *
	 * This is an extended method which allows more advanced control over the
	 * task such as including arguments, system properties, and potential
	 * output redirection.
	 *
	 * @param __s The suite to start, must be an application.
	 * @param __cn The class which extends
	 * {@link javax.microedition.midlet.MIDlet} and acts as the main entry
	 * point for the program.
	 * @param __sprops System properties to pass to the started task.
	 * @param __args Arguments to pass to the called program.
	 * @param __stdout Alternative {@link System#out}.
	 * @param __stderr Alternative {@link System#err}.
	 * @return The task which was created.
	 * @throws IllegalArgumentException If the suite is a library, the given
	 * class does not exist, or the given class does not extend
	 * {@link javax.microedition.midlet.MIDlet}.
	 * @throws IllegalStateException If the suite has been removed.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/02
	 */
	public abstract Task startTask(Suite __s, String __cn,
		Map<String, String> __sprops, String[] __args, OutputStream __stdout,
		OutputStream __stderr)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException;
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/InternalName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents an internal project name which is used by SquirrelJME.
 *
 * @since 2017/12/31
 */
public final class InternalName
	implements MarkedProvided
{
	/** The project name. */
	protected final String name;
	
	/**
	 * Initializes the internal name.
	 *
	 * @param __n The name to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public InternalName(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof InternalName))
			return false;
		
		return this.name.equals(((InternalName)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Returns the internal name.
	 *
	 * @return The internal name.
	 * @since 2017/12/31
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/InvalidSuiteException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This is thrown when a midlet has an invalid property or is otherwise not
 * valid.
 *
 * @since 2017/11/23
 */
public class InvalidSuiteException
	extends IllegalArgumentException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/23
	 */
	public InvalidSuiteException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/23
	 */
	public InvalidSuiteException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/JarStreamSupplier.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is used to obtain an input stream which contains JAR file data which
 * would then be passed through the JIT for recompilation.
 *
 * @since 2017/12/28
 */
public interface JarStreamSupplier
{
	/**
	 * Returns an input stream over the JAR data.
	 *
	 * @return The input stream over the JAR data.
	 * @throws IOException If it could not be obtained.
	 * @since 2017/12/28
	 */
	public abstract InputStream get()
		throws IOException;
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/MarkedDependency.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This interface is used for anything which represents a dependency and as
 * such can be used to check if a provided meets the conditions for a match.
 *
 * @since 2017/12/31
 */
public interface MarkedDependency
{
	/**
	 * Is this dependency optional?
	 *
	 * @return {@code true} if this dependency is optional.
	 * @since 2017/12/31
	 */
	public abstract boolean isOptional();
	
	/**
	 * Checks if this dependency matches the specified provision in that the
	 * provided entry is acceptable to be used for this dependency.
	 *
	 * @param __mp The provided to check.
	 * @return {@code true} if the provided is valid for this dependency.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public abstract boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException;
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/MarkedProvided.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This interface is associated with anything which can be a provided detail
 * for a dependency.
 *
 * @since 2017/12/31
 */
public interface MarkedProvided
{
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/MatchResult.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
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



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import net.multiphasicapps.collections.EmptySet;

/**
 * This class contains the results of a dependency match.
 *
 * @since 2017/11/30
 */
public final class MatchResult
{
	/** The matched results. */
	protected final DependencyInfo matched;
	
	/** The unmatched results. */
	protected final DependencyInfo unmatched;
	
	/**
	 * Initializes the match result.
	 *
	 * @param __matched The matched dependencies.
	 * @param __unmatched The unmatched dependencies.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public MatchResult(DependencyInfo __matched, DependencyInfo __unmatched)
		throws NullPointerException
	{
		if (__matched == null || __unmatched == null)
			throw new NullPointerException("NARG");
		
		this.matched = __matched;
		this.unmatched = __unmatched;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MatchResult))
			return false;
		
		MatchResult o = (MatchResult)__o;
		return this.matched.equals(o.matched) &&
			this.unmatched.equals(o.unmatched);
	}
	
	/**
	 * Returns {@code true} if there have been matches in the result.
	 *
	 * @return Has there been any matches?
	 * @since 2017/11/30
	 */
	public final boolean hasMatches()
	{
		return !this.matched.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.matched.hashCode() ^
			this.unmatched.hashCode();
	}
	
	/**
	 * Returns the dependency information which contains every dependency
	 * which has been matched.
	 *
	 * @return The dependency information containing only matched items.
	 * @since 2017/11/30
	 */
	public final DependencyInfo matched()
	{
		return this.matched;
	}
	
	/**
	 * Returns the dependency information which contains every dependency
	 * which has yet to be matched.
	 *
	 * @return The dependency information containing only unmatched items.
	 * @since 2017/11/30
	 */
	public final DependencyInfo unmatched()
	{
		return this.unmatched;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/Profile.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
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


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a profile that may be implemented, such as MIDP.
 *
 * @since 2016/12/14
 */
public final class Profile
	implements Comparable<Profile>, MarkedDependency, MarkedProvided
{
	/** Name. */
	protected final APIName name;
	
	/** Version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the profile using the given API name and version.
	 *
	 * @param __n The name to use.
	 * @param __v The version of the suite, this is optional.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/11/30
	 */
	public Profile(APIName __n, SuiteVersion __v)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.version = __v;
	}
	
	/**
	 * Initializes the profile by parsing the given string.
	 *
	 * @param __s The string to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public Profile(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// No version specified
		int n = __n.length(),
			dx = __n.lastIndexOf('-');
		char c;
		if (dx < 0 || dx + 1 >= n || (c = __n.charAt(dx + 1)) < '0' || c > '9')
		{
			this.name = new APIName(__n);
			this.version = null;
		}
		
		// There is a version
		else
		{
			this.name = new APIName(__n.substring(0, dx));
			this.version = new SuiteVersion(__n.substring(dx + 1));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(Profile __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVersion a = this.version,
			b = __o.version;
		if ((a == null) != (b == null))
			return (a == null ? -1 : 1);
		else if (a != null)
			return a.compareTo(b);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Profile))
			return false;
		
		Profile o = (Profile)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean isOptional()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		return this.equals(__mp);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public String toString()
	{
		
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "Profile " +
				this.name + ":" + this.version));
		
		return rv;
	}
	
	/**
	 * Returns the version of this profile.
	 *
	 * @return The profile version.
	 * @since 2017/12/05
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/ProvidedInfo.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
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





















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.collections.ArrayUtils;
import net.multiphasicapps.collections.EmptySet;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This contains all of the information for dependencies which are provided
 * by an application or library.
 *
 * @since 2017/11/30
 */
public final class ProvidedInfo
{
	/** Provided fields. */
	protected final Set<MarkedProvided> provided;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the provided dependency info.
	 *
	 * @param __provs The provided set.
	 * @since 2017/12/31
	 */
	public ProvidedInfo(MarkedProvided... __provs)
	{
		this((__provs == null ? EmptySet.<MarkedProvided>empty() :
			Arrays.<MarkedProvided>asList(__provs)));
	}
	
	/**
	 * Initializes the provided dependency info.
	 *
	 * @param __provs The provided set.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/31
	 */
	public ProvidedInfo(Collection<MarkedProvided> __provs)
		throws NullPointerException
	{
		if (__provs == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedProvided> provided = new LinkedHashSet<>();
		for (MarkedProvided p : __provs)
			if (p == null)
				throw new NullPointerException("NARG");
			else
				provided.add(p);
		this.provided = UnmodifiableSet.<MarkedProvided>of(provided);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ProvidedInfo))
			return false;
		
		return this.provided.equals(((ProvidedInfo)__o).provided);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final int hashCode()
	{
		return this.provided.hashCode();
	}
	
	/**
	 * Returns the provided.
	 *
	 * @return The provided.
	 * @since 2017/12/31
	 */
	public final Set<MarkedProvided> provided()
	{
		return this.provided;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.provided.toString()));
		
		return rv;
	}
	
	/**
	 * Parses the given suite information and returns all of the provided
	 * resolutions for dependencies which are specified in the manifest.
	 *
	 * @param __info The suite information to parse.
	 * @return The parsed provided resolution information.
	 * @throws InvalidSuiteException If the manifest is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/20
	 */
	public static final ProvidedInfo of(SuiteInfo __info)
		throws InvalidSuiteException, NullPointerException
	{
		if (__info == null)
			throw new NullPointerException("NARG");
		
		Set<MarkedProvided> provided = new LinkedHashSet<>();
		JavaManifestAttributes attr = __info.manifest().getMainAttributes();
		String value;
		
		// Defined configurations
		value = attr.getValue("X-SquirrelJME-DefinedConfigurations");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
				provided.add(new Configuration(s));
		
		// Defined profiles
		value = attr.getValue("X-SquirrelJME-DefinedProfiles");
		if (value != null)
			for (String s : StringUtils.basicSplit(" \t", value))
				provided.add(new Profile(s));
		
		// Defined standards
		value = attr.getValue("X-SquirrelJME-DefinedStandards");
		if (value != null)
			for (String s : StringUtils.basicSplit(",", value))
				provided.add(new Standard(s.trim()));
		
		// Has internal project name?
		String internalname = attr.getValue(
			"X-SquirrelJME-InternalProjectName");
		if (internalname != null)
			provided.add(new InternalName(internalname));
		
		// This provides a library or otherwise
		provided.add(new TypedSuite(__info.type(), __info.suite()));
		
		// Initialize
		return new ProvidedInfo(provided);
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/Standard.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a standard which is provided by an API.
 *
 * @since 2017/12/05
 */
public final class Standard
	implements Comparable<Standard>, MarkedProvided
{
	/** The standard name. */
	protected final SuiteName name;
	
	/** The vendor of the standard. */
	protected final SuiteVendor vendor;
	
	/** The version of the standard. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the standard using the given fields.
	 *
	 * @param __name The name of the standard.
	 * @param __vend The vendor of the standard.
	 * @param __vers The version of the standard.
	 * @throws NullPointerException If no name was specified.
	 * @since 2017/12/30
	 */
	public Standard(SuiteName __name, SuiteVendor __vend, SuiteVersion __vers)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.vendor = __vend;
		this.version = __vers;
	}
	
	/**
	 * Decodes the standard from the specified string.
	 *
	 * @param __s The string to decode the standard from.
	 * @throws InvalidSuiteException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public Standard(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AR04 Expected input standard string to
		// contain three fields separated by semi-colon. (The input string)}
		String[] splice = StringUtils.fieldSplitAndTrim(';', __s);
		if (splice.length != 3)
			throw new InvalidSuiteException(String.format("AR04 %s", __s));
		
		// {@squirreljme.error AR05 Name in standard string is empty. (The
		// input string)}
		String name = splice[0];
		if (name.isEmpty())
			throw new InvalidSuiteException(String.format("AR05 %s", __s));
		this.name = new SuiteName(name);
		
		String vendor = splice[1];
		this.vendor = (vendor.isEmpty() ? null : new SuiteVendor(vendor));
		
		String version = splice[2];
		this.version = (version.isEmpty() ? null : new SuiteVersion(version));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int compareTo(Standard __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		SuiteVendor aven = this.vendor,
			bven = __o.vendor;
		if ((aven == null) != (bven == null))
			return (aven == null ? -1 : 1);
		else if (aven != null)
		{
			rv = aven.compareTo(bven);
			if (rv != 0)
				return rv;
		}
			
		SuiteVersion aver = this.version,
			bver = __o.version;
		if ((aver == null) != (bver == null))
			return (aver == null ? -1 : 1);
		else if (aver != null)
			return aver.compareTo(bver);
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Standard))
			return false;
		
		Standard o = (Standard)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * Returns the name of the API which is defined.
	 *
	 * @return The defined API name.
	 * @since 2017/12/30
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.name + ";" +
				Objects.toString(this.vendor, "") + ";" +
				Objects.toString(this.version, "")));
		
		return rv;
	}
	
	/**
	 * Returns the vendor of the standard.
	 *
	 * @return The vendor, may be {@code null} if no vendor was specified.
	 * @since 2017/12/30
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the version of the standard.
	 *
	 * @return The version, may be {@code null} if no version was specified.
	 * @since 2017/12/30
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/StandardName.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents the name of a standard.
 *
 * @since 2017/12/05
 */
public final class StandardName
	implements Comparable<StandardName>
{
	/**
	 * Initializes the standard name.
	 *
	 * @param __s The name of the standard.
	 * @throws InvalidSuiteException If the name is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/05
	 */
	public StandardName(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public int compareTo(StandardName __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/05
	 */
	@Override
	public String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteDependency.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535























































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.collections.NaturalComparator;
import net.multiphasicapps.strings.StringUtils;

/**
 * This represents a dependency that a LIBlet or MIDlet may depend on.
 *
 * @since 2017/02/22
 */
public final class SuiteDependency
	implements Comparable<SuiteDependency>, MarkedDependency
{
	/** The dependency type. */
	protected final SuiteDependencyType type;
	
	/** The dependency level. */
	protected final SuiteDependencyLevel level;
	
	/** The name. */
	protected final SuiteName name;
	
	/** The vendor. */
	protected final SuiteVendor vendor;
	
	/** The version range. */
	protected final SuiteVersionRange version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dependency which is parsed from the given input string.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteDependency(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error AR06 Expected four semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 4)
			throw new InvalidSuiteException(String.format(
				"AR06 %s", __s));
		
		// Split fields
		String intype = __s.substring(0, sc[0]).trim(),
			inlevel = __s.substring(sc[0] + 1, sc[1]).trim(),
			inname = __s.substring(sc[1] + 1, sc[2]).trim(),
			invendor = __s.substring(sc[2] + 1, sc[3]).trim(),
			inversion = __s.substring(sc[3] + 1).trim();
		
		// Required fields
		SuiteDependencyType type;
		this.type = (type = SuiteDependencyType.of(intype));
		this.level = SuiteDependencyLevel.of(inlevel);
		
		// Optional fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		// Check
		__check(type, level, name, vendor, version);
	}
	
	/**
	 * Initializes the depedency with the given type, level, and where the
	 * remainder of the dependencies are parsed from the specified string.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __s The string to decode for the remainder of the dependency.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, String __s)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__s = __s.trim();
		
		// Extract all semicolon positions
		int[] sc = StringUtils.multipleIndexOf(';', __s);
		
		// {@squirreljme.error AR07 Expected two semi-colons in the
		// dependency field. (The input dependency)}
		if (sc.length != 2)
			throw new InvalidSuiteException(String.format(
				"AR07 %s", __s));
		
		// Split fields
		String inname = __s.substring(0, sc[0]).trim(),
			invendor = __s.substring(sc[0] + 1, sc[1]).trim(),
			inversion = __s.substring(sc[1] + 1).trim();
		
		// Parse areas fields
		SuiteName name;
		SuiteVendor vendor;
		SuiteVersionRange version;
		this.name = (name = (inname.isEmpty() ? null :
			new SuiteName(inname)));
		this.vendor = (vendor = (invendor.isEmpty() ? null :
			new SuiteVendor(invendor)));
		this.version = (version = (inversion.isEmpty() ? null :
			new SuiteVersionRange(inversion)));
		
		__check(__type, __level, name, vendor, version);
		
		// Set
		this.type = __type;
		this.level = __level;
	}
	
	/**
	 * Initializes the dependency using the given parameters.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @throws NullPointerException If no type and/or name were specified.
	 * @since 2017/11/26
	 */
	public SuiteDependency(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException, NullPointerException
	{
		if (__type == null || __level == null)
			throw new NullPointerException("NARG");
		
		__check(__type, __level, __name, __vendor, __version);
		
		// Set
		this.type = __type;
		this.level = __level;
		this.name = __name;
		this.vendor = __vendor;
		this.version = __version;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public final int compareTo(SuiteDependency __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Type first
		int rv = this.type.compareTo(__d.type);
		if (rv != 0)
			return rv;
			
		// Optionality
		rv = this.level.compareTo(__d.level);
		if (rv != 0)
			return rv;
		
		// Name
		rv = Objects.<SuiteName>compare(this.name, __d.name,
			NaturalComparator.<SuiteName>instance());
		if (rv != 0)
			return rv;
		
		// Vendor
		rv = Objects.<SuiteVendor>compare(this.vendor, __d.vendor,
			NaturalComparator.<SuiteVendor>instance());
		if (rv != 0)
			return rv;
		
		// Version
		return Objects.<SuiteVersionRange>compare(this.version, __d.version,
			NaturalComparator.<SuiteVersionRange>instance());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteDependency))
			return false;
		
		// Compare
		SuiteDependency o = (SuiteDependency)__o;
		return this.type.equals(o.type) &&
			this.level.equals(o.level) &&
			Objects.equals(this.name, o.name) &&
			Objects.equals(this.vendor, o.vendor) &&
			Objects.equals(this.version, o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.level.hashCode() ^
			Objects.hashCode(this.name) ^
			Objects.hashCode(this.vendor) ^
			Objects.hashCode(this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/22
	 */
	@Override
	public boolean isOptional()
	{
		return this.level.isOptional();
	}
	
	/**
	 * Is this a required dependency?
	 *
	 * @return {@code true} if this is a required dependency.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this.level.isRequired();
	}
	
	/**
	 * Returns the dependency level.
	 *
	 * @return The dependency level.
	 * @since 2017/02/22
	 */
	public SuiteDependencyLevel level()
	{
		return this.level;
	}
	
	/**
	 * Returns the dependency name.
	 *
	 * @return The dependency name, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/31
	 */
	@Override
	public boolean matchesProvided(MarkedProvided __mp)
		throws NullPointerException
	{
		if (__mp == null)
			throw new NullPointerException("NARG");
		
		SuiteDependencyType type = this.type;
		Class<?> mpclass = __mp.getClass();
		SuiteName name = this.name;
		SuiteVendor vendor = this.vendor;
		SuiteVersionRange version = this.version;
		
		// Depends
		switch (type)
		{
				// Proprietary match
			case PROPRIETARY:
				// Potential internal project name
				if (__mp instanceof InternalName)
				{
					String myname = name.toString();
					
					// Needs at sign
					int dxat;
					if ((dxat = myname.indexOf('@')) < 0)
						return false;
					
					// Prefix must be project reference
					if (!myname.substring(0, dxat).
						equals("squirreljme.project"))
						return false;
					
					// Otherwise the project name must match
					return myname.substring(dxat + 1).
						equals(((InternalName)__mp).name());
				}
				
				// No matches
				return false;
				
				// Library
			case LIBLET:
				// Typed suite information
				if (__mp instanceof TypedSuite)
				{
					TypedSuite other = (TypedSuite)__mp;
					SuiteIdentifier ident = other.suite();
					
					// Only match other libraries
					if (other.type() != SuiteType.LIBLET)
						return false;
					
					// Must match name
					if (!name.equals(ident.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(ident.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(ident.version()))
							return false;
					
					// Is okay!
					return true;
				}
				
				// Unknown
				else
					return false;
					
				// Standard
			case STANDARD:
				if (__mp instanceof Standard)
				{
					Standard other = (Standard)__mp;
					
					// Must match name
					if (!name.equals(other.name()))
						return false;
					
					// Match vendor if specified
					if (vendor != null)
						if (!vendor.equals(other.vendor()))
							return false;
					
					// Check if version in range if specified
					if (version != null)
						if (!version.inRange(other.version()))
							return false;
					
					// Matches!
					return true;
				}
				
				// Not a standard
				else
					return false;
				
				// {@squirreljme.error AR08 Illegal dependency check.
				// (The dependency type; The target class)}
			default:
				throw new RuntimeException(String.format("AR08 %s %s",
					type, mpclass));
		}
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * required.
	 *
	 * @return This dependency but required.
	 * @since 2017/11/26
	 */
	public SuiteDependency toRequired()
	{
		if (isRequired())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.REQUIRED,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * Returns a dependency which is the same as this one except that it is
	 * optional.
	 *
	 * @return This dependency but optional.
	 * @since 2017/11/26
	 */
	public SuiteDependency toOptional()
	{
		if (isOptional())
			return this;
		return new SuiteDependency(this.type, SuiteDependencyLevel.OPTIONAL,
			this.name, this.vendor, this.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// These are optional
			SuiteName name = this.name;
			SuiteVendor vendor = this.vendor;
			SuiteVersionRange version = this.version;
			
			// Generate
			this._string = new WeakReference<>((rv = String.format(
				"%s;%s;%s;%s;%s", this.type, this.level,
				(name == null ? "" : name),
				(vendor == null ? "" : vendor),
				(version == null ? "" : version))));
		}
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the dependency type.
	 *
	 * @return The dependency type.
	 * @since 2017/02/22
	 */
	public SuiteDependencyType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the dependency vendor.
	 *
	 * @return The dependency vendor, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the dependency version.
	 *
	 * @return The dependency version, may be {@code null}.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange version()
	{
		return this.version;
	}
	
	/**
	 * Checks whether the provided parameters are correct.
	 *
	 * @param __type The type of dependency this is.
	 * @param __level The level of the dependency.
	 * @param __name The name.
	 * @param __vendor The vendor.
	 * @param __version The version.
	 * @throws InvalidSuiteException If the input parameters are not valid.
	 * @since 2017/11/26
	 */
	private static final void __check(SuiteDependencyType __type,
		SuiteDependencyLevel __level, SuiteName __name,
		SuiteVendor __vendor, SuiteVersionRange __version)
		throws InvalidSuiteException
	{
		// {@squirreljme.error AR09 Dependencies on LIBlets must have the
		// name, vendor, and version set. (The type; The level; The name;
		// The vendor; The version)}
		if (__type == SuiteDependencyType.LIBLET && (__name == null ||
			__vendor == null || __version == null))
			throw new InvalidSuiteException(
				String.format("AR09 %s %s %s %s %s", __type, __level, __name,
					__vendor, __version));
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteDependencyLevel.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
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































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents the level of the dependency.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyLevel
{
	/** Required. */
	REQUIRED,
	
	/** Optional. */
	OPTIONAL,
	
	/** End. */
	;
	
	/**
	 * Is this an optional dependency level?
	 *
	 * @return {@code true} if this is an optional dependency level.
	 * @since 2017/11/22
	 */
	public boolean isOptional()
	{
		return this == OPTIONAL;
	}
	
	/**
	 * Is this an required dependency level?
	 *
	 * @return {@code true} if this is an required dependency level.
	 * @since 2017/11/22
	 */
	public boolean isRequired()
	{
		return this == REQUIRED;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case REQUIRED:	return "required";
			case OPTIONAL:	return "optional";
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the dependency level based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency level for the given string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyLevel of(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "required":	return REQUIRED;
			case "optional":	return OPTIONAL;
			
				// Should not happen
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteDependencyType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

/**
 * This represents the type of the dependency that is to be included.
 *
 * @since 2017/02/22
 */
public enum SuiteDependencyType
{
	/** Liblet. */
	LIBLET,
	
	/** Standard. */
	STANDARD,
	
	/** Service. */
	SERVICE,
	
	/** Proprietary. */
	PROPRIETARY,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Convert string
		switch (this)
		{
			case LIBLET:		return "liblet";
			case STANDARD:		return "standard";
			case SERVICE:		return "service";
			case PROPRIETARY:	return "proprietary";
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the dependency type based on the input string.
	 *
	 * @param __s The input string to parse.
	 * @return The dependency type for the given string.
	 * @throws InvalidSuiteException If the dependency type is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public static SuiteDependencyType of(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__s.trim())
		{
			case "liblet":		return LIBLET;
			case "standard":	return STANDARD;
			case "service":		return SERVICE;
			case "proprietary":	return PROPRIETARY;
			
				// {@squirreljme.error AR0a The specified string is not a valid
				// dependency type. (The input string)}
			default:
				throw new InvalidSuiteException(
					String.format("AR0a %s", __s));
		}
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteIdentifier.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
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





















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is the identity for a midlet suite which contains a name, vendor,
 * and version.
 *
 * @since 2016/10/12
 */
public final class SuiteIdentifier
	implements Comparable<SuiteIdentifier>
{
	/** The suite name. */
	protected final SuiteName name;
	
	/** The suite vendor. */
	protected final SuiteVendor vendor;
	
	/** The suite version. */
	protected final SuiteVersion version;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __name The name of the suite.
	 * @param __vendor The vendor of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteIdentifier(SuiteName __name, SuiteVendor __ven,
		SuiteVersion __ver)
		throws NullPointerException
	{
		this(__ven, __name, __ver);
	}
	
	/**
	 * Initializes the suite identifier.
	 *
	 * @param __vendor The vendor of the suite.
	 * @param __name The name of the suite.
	 * @param __ver The version of the suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteIdentifier(SuiteVendor __ven, SuiteName __name,
		SuiteVersion __ver)
		throws NullPointerException
	{
		// Check
		if (__ven == null || __name == null || __ver == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.vendor = __ven;
		this.version = __ver;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteIdentifier __o)
	{
		if (this == __o)
			return 0;
		
		// Compare name
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		
		// Then vendor
		rv = this.vendor.compareTo(__o.vendor);
		if (rv != 0)
			return rv;
		
		// Then the version last
		return this.version.compareTo(__o.version);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteIdentifier))
			return false;
		
		return 0 == (compareTo((SuiteIdentifier)__o));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.vendor.hashCode() ^
			this.version.hashCode();
	}
	
	/**
	 * Returns the suite name.
	 *
	 * @return The suite name.
	 * @since 2016/10/12
	 */
	public SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.vendor + ";" +
				this.name + ";" + this.version));
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the suite vendor.
	 *
	 * @return The suite vendor.
	 * @since 2016/10/12
	 */
	public SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the suite version.
	 *
	 * @return The suite version.
	 * @since 2016/10/12
	 */
	public SuiteVersion version()
	{
		return this.version;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteInfo.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
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
191
192
193
194
195
196
197
198
199
200








































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This contains all of the information which is provided by a suite.
 *
 * @since 2017/11/30
 */
public final class SuiteInfo
{
	/** The manifest for this suite. */
	protected final JavaManifest manifest;
	
	/** The type of suite this is. */
	protected final SuiteType type;
	
	/** The suite name. */
	protected final SuiteName name;
	
	/** The suite vendor. */
	protected final SuiteVendor vendor;
	
	/** The suite version. */
	protected final SuiteVersion version;
	
	/** Required dependency information. */
	private Reference<DependencyInfo> _dependencies;
	
	/** Provided dependency information. */
	private Reference<ProvidedInfo> _provided;
	
	/** Suite cache. */
	private Reference<SuiteIdentifier> _suite;
	
	/**
	 * Initializes the suite information.
	 *
	 * @param __man The manifest making up the suite information.
	 * @throws InvalidSuiteException If the suite information is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public SuiteInfo(JavaManifest __man)
		throws InvalidSuiteException, NullPointerException
	{
		if (__man == null)
			throw new NullPointerException("NARG");
		
		this.manifest = __man;
		JavaManifestAttributes attr = __man.getMainAttributes();
		
		// First determine the type
		SuiteType type = SuiteType.ofManifest(__man);
		this.type = type;
		
		// {@squirreljme.error AR0b No suite name was specified.}
		SuiteName name = new SuiteName(
			Objects.<String>requireNonNull(attr.getValue(type.nameKey()),
			"AR0b"));
		this.name = name;
		
		// {@squirreljme.error AR0c No suite vendor was specified.}
		SuiteVendor vendor = new SuiteVendor(
			Objects.<String>requireNonNull(attr.getValue(type.vendorKey()),
			"AR0c"));
		this.vendor = vendor;
		
		// {@squirreljme.error AR0d No suite version was specified.}
		SuiteVersion version = new SuiteVersion(
			Objects.<String>requireNonNull(attr.getValue(type.versionKey()),
			"AR0d"));
		this.version = version;
	}
	
	/**
	 * Return the dependencies which are required by this suite.
	 *
	 * @return The dependencies required by this suite.
	 * @since 2017/12/04
	 */
	public final DependencyInfo dependencies()
	{
		Reference<DependencyInfo> ref = this._dependencies;
		DependencyInfo rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._dependencies = new WeakReference<>(
				(rv = DependencyInfo.of(this)));
		
		return rv;
	}
	
	/**
	 * Returns the manifest used for this suite.
	 *
	 * @return The manifest suite.
	 * @since 2017/12/05
	 */
	public final JavaManifest manifest()
	{
		return this.manifest;
	}
	
	/**
	 * Returns the suite name.
	 *
	 * @return The name.
	 * @since 2017/12/31
	 */
	public final SuiteName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the dependencies provided by this suite.
	 *
	 * @return The provided dependencies for this suite.
	 * @since 2017/12/04
	 */
	public final ProvidedInfo provided()
	{
		Reference<ProvidedInfo> ref = this._provided;
		ProvidedInfo rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._provided = new WeakReference<>(
				(rv = ProvidedInfo.of(this)));
		
		return rv;
	}
	
	/**
	 * Returns the suite for this.
	 *
	 * @return The suite.
	 * @since 2017/12/05
	 */
	public final SuiteIdentifier suite()
	{
		Reference<SuiteIdentifier> ref = this._suite;
		SuiteIdentifier rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._suite = new WeakReference<>((rv = new SuiteIdentifier(
				this.name, this.vendor, this.version)));
		
		return rv;
	}
	
	/**
	 * Returns the type of suite this is.
	 *
	 * @return The type of suite.
	 * @since 2017/12/04
	 */
	public final SuiteType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the suite vendor.
	 *
	 * @return The vendor.
	 * @since 2017/12/31
	 */
	public final SuiteVendor vendor()
	{
		return this.vendor;
	}
	
	/**
	 * Returns the suite version.
	 *
	 * @return The version.
	 * @since 2017/12/31
	 */
	public final SuiteVersion version()
	{
		return this.version;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteName.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
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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the name of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteName
	implements Comparable<SuiteName>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite name.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteName(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AR0e An illegal character was
		// specified in the midlet suite name. (The midlet suite
		// name)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AR0e %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteName __o)
	{
		if (this == __o)
			return 0;
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Check
		if (!(__o instanceof SuiteName))
			return false;
		
		return this.string.equals(((SuiteName)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteType.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
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























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This represents the type of suite that a suite may be.
 *
 * @since 2017/12/04
 */
public enum SuiteType
{
	/** MIDlet. */
	MIDLET("MIDlet"),
	
	/** LIBlet. */
	LIBLET("LIBlet"),
	
	/** An API. */
	SQUIRRELJME_API("X-SquirrelJME-API"),
	
	/** End. */
	;
	
	/** The used prefix. */
	protected final String prefix;
	
	/** Manifest description key. */
	private Reference<JavaManifestKey> _description;
	
	/** Manifest name key. */
	private Reference<JavaManifestKey> _name;
	
	/** Manifest vendor key. */
	private Reference<JavaManifestKey> _vendor;
	
	/** Manifest version key. */
	private Reference<JavaManifestKey> _version;
	
	/**
	 * Initializes the type.
	 *
	 * @param __p The prefix which is used.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	private SuiteType(String __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		this.prefix = __p;
	}
	
	/**
	 * Returns the key which is used to refer to dependencies.
	 *
	 * @param __i The index of the dependency to get.
	 * @return The key for the given dependency index.
	 * @since 2017/12/05
	 */
	public JavaManifestKey dependencyKey(int __i)
	{
		// {@squirreljme.error AR0f Cannot have a zero or negative dependency
		// index.}
		if (__i <= 0)
			throw new IllegalArgumentException("AR0f");
		
		return new JavaManifestKey(this.prefix + "-Dependency-" + __i);
	}
	
	/**
	 * Returns the manifest key used for the description.
	 *
	 * @return The description manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey descriptionKey()
	{
		Reference<JavaManifestKey> ref = this._description;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._description = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Description")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the name.
	 *
	 * @return The name manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey nameKey()
	{
		Reference<JavaManifestKey> ref = this._name;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._name = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Name")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the vendor.
	 *
	 * @return The vendor manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey vendorKey()
	{
		Reference<JavaManifestKey> ref = this._vendor;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._vendor = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Vendor")));
		
		return rv;
	}
	
	/**
	 * Returns the manifest key used for the version.
	 *
	 * @return The version manifest key.
	 * @since 2017/12/04
	 */
	public JavaManifestKey versionKey()
	{
		Reference<JavaManifestKey> ref = this._version;
		JavaManifestKey rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._version = new WeakReference<>(
				(rv = new JavaManifestKey(this.prefix + "-Version")));
		
		return rv;
	}
	
	/**
	 * Returns the suite type for the given manifest.
	 *
	 * @param __man The manifest to get the type from.
	 * @return The type of suite from the given manifest.
	 * @throws InvalidSuiteException If the type is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public static final SuiteType ofManifest(JavaManifest __man)
		throws InvalidSuiteException, NullPointerException
	{
		if (__man == null)
			throw new NullPointerException("NARG");
		
		JavaManifestAttributes attr = __man.getMainAttributes();
		for (SuiteType t : SuiteType.values())
			if (attr.definesValue(t.nameKey()))
				return t;
		
		// {@squirreljme.error AR0g Could not obtain the type of suite from
		// the input manifest.}
		throw new InvalidSuiteException("AR0g");
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteVendor.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
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






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import net.multiphasicapps.strings.StringUtils;

/**
 * This represents the vendor of a midlet suite.
 *
 * @since 2016/10/12
 */
public final class SuiteVendor
	implements Comparable<SuiteVendor>
{
	/** String value. */
	protected final String string;
	
	/**
	 * Initializes the suite vendor.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVendor(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AR0h An illegal character was
		// specified in the midlet suite vendor. (The midlet suite
		// vendor)}
		if (StringUtils.firstIndex("\0\r\n:;", __v) >= 0)
			throw new InvalidSuiteException(String.format("AD0d %s", __v));
		
		this.string = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVendor __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVendor))
			return false;
		
		return this.string.equals(((SuiteVendor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteVersion.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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



















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a midlet version.
 *
 * @since 2016/10/12
 */
public final class SuiteVersion
	implements Comparable<SuiteVersion>
{
	/** The minimum version number. */
	public static final SuiteVersion MIN_VERSION =
		new SuiteVersion(0, 0, 0);
	
	/** The maximum version number. */
	public static final SuiteVersion MAX_VERSION =
		new SuiteVersion(99, 99, 99);
	
	/** The major version. */
	protected final int major;
	
	/** The minor version. */
	protected final int minor;
	
	/** The release version. */
	protected final int release;
	
	/** The string representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the version.
	 *
	 * @param __v The value to parse.
	 * @throws InvalidSuiteException If there are too many or too little
	 * version fields, they contain illegal charactes, or have an out of range
	 * value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		this(__decodeVersion(__v));
	}
	
	/**
	 * Initializes a Midlet version number from the specified array of
	 * integer values.
	 *
	 * @param __v The version triplet, up to the first three elements are
	 * used by the version number.
	 * @throws InvalidSuiteException If the version number has an out of
	 * range value.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int[] __v)
		throws InvalidSuiteException, NullPointerException
	{
		this((__v.length > 0 ? __v[0] : 0),
			(__v.length > 1 ? __v[1] : 0),
			(__v.length > 2 ? __v[2] : 0));
	}
	
	/**
	 * Decodes the midlet version, optionally allowing it to a reverse
	 * operation of the {@link #hashCode()} method.
	 *
	 * @param __hash If {@code true} then the value to decode is treated as
	 * the hash code returned by this class.
	 * @param __maj If {@code __hash} is {@code true} then this is the hash
	 * code of a SuiteVersion, otherwise it is the major version number.
	 * @throws InvalidSuiteException If the version number has an out of
	 * range value.
	 * @since 2016/10/13
	 */
	public SuiteVersion(boolean __hash, int __maj)
		throws InvalidSuiteException
	{
		this((__hash ? __maj / 10000 : __maj),
			(__hash ? (__maj / 100) % 100 : 0),
			(__hash ? __maj % 100 : 0));
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj)
	{
		this(__maj, 0, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @throws IllegalArgumentException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min)
	{
		this(__maj, __min, 0);
	}
	
	/**
	 * Initializes the version.
	 *
	 * @param __maj The major version.
	 * @param __min The minor version.
	 * @param __rel The release version.
	 * @throws InvalidSuiteException If any value is out of range.
	 * @since 2016/10/12
	 */
	public SuiteVersion(int __maj, int __min, int __rel)
		throws InvalidSuiteException
	{
		// {@squirreljme.error AR0i Input version number is out of range, only
		// 0 through 99 are valid. (The major version; The minor version; The
		// release version)}
		if (__maj < 0 || __maj > 99 || __min < 0 || __min > 99 ||
			__rel < 0 || __rel > 99)
			throw new InvalidSuiteException(String.format("AR0i %d %d %d",
				__maj, __min, __rel));
		
		// Set
		this.major = __maj;
		this.minor = __min;
		this.release = __rel;
	}
	
	/**
	 * Checks if this version at least the specified verison.
	 *
	 * @param __v The version to check against.
	 * @return {@code true} if this version is at least the other.
	 * @throws NullPointerException On nul arguments.
	 */
	public boolean atLeast(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Can compare the hashcodes
		return hashCode() >= __v.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int compareTo(SuiteVersion __o)
	{
		// Major first
		int amaj = this.major, bmaj = __o.major;
		int rv = amaj - bmaj;
		if (rv != 0)
			return rv;
		
		// Then minor
		int amin = this.minor, bmin = __o.minor;
		rv = amin - bmin;
		if (rv != 0)
			return rv;
		
		// Then release
		int arel = this.release, brel = __o.release;
		rv = arel - brel;
		if (rv != 0)
			return rv;
		
		// The same
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersion))
			return false;
		
		// Cast
		SuiteVersion o = (SuiteVersion)__o;
		return this.major == o.major &&
			this.minor == o.minor &&
			this.release == o.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public int hashCode()
	{
		return (this.major * 10000) +
			(this.minor * 100) +
			this.release;
	}
	
	/**
	 * Returns the major version.
	 *
	 * @return The major version.
	 * @since 2017/02/22
	 */
	public int major()
	{
		return this.major;
	}
	
	/**
	 * Returns the minor version.
	 *
	 * @return The minor version.
	 * @since 2017/02/22
	 */
	public int minor()
	{
		return this.minor;
	}
	
	/**
	 * Returns the release version.
	 *
	 * @return The release version.
	 * @since 2017/02/22
	 */
	public int release()
	{
		return this.release;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/12
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.major + "." +
				this.minor + "." + this.release));
		
		// Return it
		return rv;
	}
	
	/**
	 * Decodes the string based version number
	 *
	 * @param __v The input string.
	 * @return The version tuplet.
	 * @throws InvalidSuiteException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/12
	 */
	private static final int[] __decodeVersion(String __v)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Trim whitespace
		__v = __v.trim();
		
		// Output array
		int[] rv = new int[3];
		
		// Parse the input value
		int n = __v.length(), at = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i <= n; i++)
		{
			int c = (i == n ? -1 : __v.charAt(i));
			
			// Decimal point? or end
			if (c == '.' || c == -1)
			{
				rv[at++] = Integer.parseInt(sb.toString(), 10);
				
				// {@squirreljme.error AR0j Too many version fields in the
				// specified string. (The input string)}
				if (c != -1 && at >= 4)
					throw new InvalidSuiteException(String.format("AR0j %s",
						__v));
				
				// Clear
				sb.setLength(0);
			}
			
			// Add to string
			else if (c >= '0' && c <= '9')
				sb.append((char)c);
			
			// {@squirreljme.error AR0k An illegal character is in the
			// version string. (The input string; The illegal character)}
			else
				throw new InvalidSuiteException(String.format("AR0k %s %04x",
					__v, c));
		}
		
		// Return it
		return rv;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/SuiteVersionRange.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is used to handle version ranges that may be used for dependencies.
 *
 * Version ranges are inclusive.
 *
 * @since 2017/02/22
 */
public final class SuiteVersionRange
	implements Comparable<SuiteVersionRange>
{
	/** Any version. */
	public static final SuiteVersionRange ANY_VERSION =
		new SuiteVersionRange(SuiteVersion.MIN_VERSION,
			SuiteVersion.MAX_VERSION);
	
	/** The starting range, inclusive. */
	protected final SuiteVersion from;
	
	/** Tne ending range, inclusive. */
	protected final SuiteVersion to;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the range inclusively between the two given versions.
	 *
	 * @param __from The source version.
	 * @param __to The destination version.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(SuiteVersion __from, SuiteVersion __to)
		throws NullPointerException
	{
		// Check
		if (__from == null || __to == null)
			throw new NullPointerException("NARG");
		
		// Make sure from is always first
		if (__from.compareTo(__to) <= 0)
		{
			this.from = __from;
			this.to = __to;
		}
		
		// Swapped
		else
		{
			this.from = __to;
			this.to = __from;
		}
	}
	
	/**
	 * Parses the version range that is specified in the dependency of JAR
	 * files.
	 *
	 * @param __s The string to parse.
	 * @throws InvalidSuiteException If the range is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public SuiteVersionRange(String __s)
		throws InvalidSuiteException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Trim
		__s = __s.trim();
		
		// {@squirreljme.error AR0l The version range cannot be blank.}
		int sl = __s.length();
		if (sl <= 0)
			throw new IllegalArgumentException("AR0l");
		
		// Get the last character
		char lc = __s.charAt(__s.length() - 1);
		
		// All versions following this.
		if (lc == '+')
		{
			this.from = new SuiteVersion(__s.substring(0, sl - 1));
			this.to = new SuiteVersion(99, 99, 99);
		}
		
		// All versions in the group
		else if (lc == '*')
		{
			// Get the last dot, if any
			int ld = __s.lastIndexOf('.');
			if (ld < 0)
			{
				// Any version, does not matter
				if (sl == 1)
				{
					this.from = new SuiteVersion(0);
					this.to = new SuiteVersion(99, 99, 99);
				}
				
				// {@squirreljme.error AR0m Major only wildcard versions must
				// be a single asterisk. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0m %s",
						__s));
			}
			
			// Parse otherwise, just count the number of dots to determine
			// how deep it goes
			else
			{
				// {@squirreljme.error AR0n The last dot in a wildcard must be
				// before the asterisk. (The input string)}
				if (ld != sl - 1)
					throw new InvalidSuiteException(String.format("AR0n %s",
						__s));
				
				// Source range is simple
				SuiteVersion ver = new SuiteVersion(
					__s.substring(0, sl - 2));
				this.from = ver;
				
				// Count dots, determines major/minor
				int numdots = 0;
				for (int i = 0; i < sl; i++)
					if (__s.charAt(i) == '.')
						numdots++;
				
				// minor and release wildcard
				if (numdots == 1)
					this.to = new SuiteVersion(ver.major(), 99, 99);
				
				// release ranged wildcard
				else if (numdots == 2)
					this.to = new SuiteVersion(ver.major(), ver.minor(), 99);
				
				// {@squirreljme.error AR0o There are too many decimal points
				// in the wildcard version string. (The input string)}
				else
					throw new InvalidSuiteException(String.format("AR0o %s",
						__s));
			}
		}
		
		// Only this version
		else
		{
			SuiteVersion ver = new SuiteVersion(__s);
			this.from = ver;
			this.to = ver;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/30
	 */
	@Override
	public int compareTo(SuiteVersionRange __o)
	{
		// From version is always first
		int rv = this.from.compareTo(__o.from);
		if (rv != 0)
			return rv;
		
		return this.to.compareTo(__o.to);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof SuiteVersionRange))
			return false;
		
		// Compare
		SuiteVersionRange o = (SuiteVersionRange)__o;
		return this.from.equals(o.from) && this.to.equals(o.to);
	}
	
	/**
	 * Returns the start of the range
	 *
	 * @return The range start.
	 * @since 2017/02/22
	 */
	public SuiteVersion from()
	{
		return this.from;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public int hashCode()
	{
		return this.to.hashCode() ^ (~this.from.hashCode());
	}
	
	/**
	 * Checks whether the specified version is in range.
	 *
	 * @param __v The version to check.
	 * @return {@code true} if it is in the range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/22
	 */
	public boolean inRange(SuiteVersion __v)
		throws NullPointerException
	{
		// Check
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return __v.compareTo(this.from) >= 0 &&
			__v.compareTo(this.to) <= 0;
	}
	
	/**
	 * Checks whether the given version is within range of the other version.
	 *
	 * @param __r The other version range to check.
	 * @return If the other version range shares all or part of its range
	 * with this range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/27
	 */
	public boolean inRange(SuiteVersionRange __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the end of the range.
	 *
	 * @return The range end.
	 * @since 2017/02/22
	 */
	public SuiteVersion to()
	{
		return this.to;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/22
	 */
	@Override
	public String toString()
	{
		// Get
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Slowly build version
			StringBuilder sb = new StringBuilder();
			SuiteVersion from = this.from;
			SuiteVersion to = this.to;
			
			// Get all values
			int amaj = from.major(),
				amin = from.minor(),
				arel = from.release(),
				bmaj = to.major(),
				bmin = to.minor(),
				brel = to.release();
			
			// Pure wildcard
			if (amaj == 0 && amin == 0 && arel == 0 &&
				bmaj == 99 && bmin == 99 && brel == 99)
				sb.append('*');
			
			// Exact, subwildcard, or any following
			else
			{
				// Add major version
				sb.append(amaj);
				sb.append('.');
				
				// Wild card minor and release
				if (amin == 0 && arel == 0 && bmin == 99 && brel == 99)
					sb.append('*');
				
				// Not wild
				else
				{
					// Add version
					sb.append(amin);
					sb.append('.');
					
					// Wild card release
					if (arel == 0 && brel == 99)
						sb.append('*');
					
					// Would be exact (or plus)
					else
						sb.append(arel);
				}
			
				// Will be all versions following
				if (bmaj == 99 && bmin == 99 && brel == 99)
					sb.append('+');
			}
			
			// Store
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Returns a version which at most implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange atMost(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(SuiteVersion.MIN_VERSION, __v);
	}
	
	/**
	 * Returns a version which exactly implements the given version.
	 *
	 * @param __v The version.
	 * @return The resulting version range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final SuiteVersionRange exactly(SuiteVersion __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return new SuiteVersionRange(__v, __v);
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/TypedSuite.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
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























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.swm;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a suite with an associated type.
 *
 * @since 2017/12/30
 */
public final class TypedSuite
	implements MarkedProvided
{
	/** The suite type. */
	protected final SuiteType type;
	
	/** The suite. */
	protected final SuiteIdentifier suite;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the typed suite.
	 *
	 * @param __type The type of suite.
	 * @param __suite The suite information.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/30
	 */
	public TypedSuite(SuiteType __type, SuiteIdentifier __suite)
		throws NullPointerException
	{
		if (__type == null || __suite == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.suite = __suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof TypedSuite))
			return false;
		
		TypedSuite o = (TypedSuite)__o;
		return this.type.equals(o.type) &&
			this.suite.equals(o.suite);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^
			this.suite.hashCode();
	}
	
	/**
	 * Returns the suite.
	 *
	 * @return The suite.
	 * @since 2017/12/30
	 */
	public SuiteIdentifier suite()
	{
		return this.suite;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/30
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.type + " " + this.suite));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/12/30
	 */
	public SuiteType type()
	{
		return this.type;
	}
}

Deleted runt/apis/meep-swm/cc/squirreljme/runtime/swm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SquirrelJME implementations of the classes needed
 * by the SWM sub-system.
 *
 * @since 2017/12/07
 */

package cc.squirreljme.runtime.swm;

Deleted runt/apis/meep-swm/javax/microedition/swm/InstallErrorCodes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258


































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This enumeration contains the many ways which applications can be failed
 * to be installed.
 *
 * @since 2016/06/24
 */
public enum InstallErrorCodes
{
	/** The applicaton is already installed. */
	ALREADY_INSTALLED,

	/** The dependency of an application is in conflict. */
	APP_INTEGRITY_FAILURE_DEPENDENCY_CONFLICT,

	/** The dependency of an application is mismatched. */
	APP_INTEGRITY_FAILURE_DEPENDENCY_MISMATCH,

	/** The hash sum of an application is invalid. */
	APP_INTEGRITY_FAILURE_HASH_MISMATCH,

	/** The application is blacklisted. */
	APPLICATION_BLACKLISTED,

	/** An attribute does not match. */
	ATTRIBUTE_MISMATCH,

	/** Could not authenticate. */
	AUTHENTICATION_FAILURE,

	/** Not authorized to install the application. */
	AUTHORIZATION_FAILURE,

	/** The certificate authority has been disabled. */
	CA_DISABLED,

	/** Installation cancelled. */
	CANCELLED,

	/** Cannot authenticate. */
	CANNOT_AUTH,

	/** A dependency eventually depends on itself. */
	CIRCULAR_COMPONENT_DEPENDENCY,

	/** The client requesting the program has been blacklisted. */
	CLIENT_BLACKLISTED,

	/** Dynamic componenent dependencies limit exceeded. */
	COMPONENT_DEPS_LIMIT_EXCEEDED,

	/** There is a conflict in a content handler. */
	CONTENT_HANDLER_CONFLICT,

	/** The hash sum of a dependency is mismatched. */
	CORRUPT_DEPENDENCY_HASH,

	/** The JAR is malformed. */
	CORRUPT_JAR,

	/** The certificate of the provider is malformed. */
	CORRUPT_PROVIDER_CERT,

	/** The signature of a JAR is incorrect. */
	CORRUPT_SIGNATURE,

	/** The JAR cannot run on this device. */
	DEVICE_INCOMPATIBLE,

	/** JAR or JAD has a duplicated key. */
	DUPLICATED_KEY,

	/** The certificate authority's key has expired. */
	EXPIRED_CA_KEY,

	/** The provider's certficate has expired. */
	EXPIRED_PROVIDER_CERT,

	/** Not enough space for installation. */
	INSUFFICIENT_STORAGE,

	/** The JAD type is not valid. */
	INVALID_JAD_TYPE,

	/** The JAD URL is not valid. */
	INVALID_JAD_URL,

	/** The JAR type is not valid. */
	INVALID_JAR_TYPE,

	/** The JAR URL is not valid. */
	INVALID_JAR_URL,

	/** Manifest contains an invalid key. */
	INVALID_KEY,

	/** Cannot load native libraries within a JAR. */
	INVALID_NATIVE_LIBRARY,

	/** Payment information incorrect. */
	INVALID_PAYMENT_INFO,

	/** The provider certificate is not valid. */
	INVALID_PROVIDER_CERT,

	/** The signature is not valid. */
	INVALID_SIGNATURE,

	/** The value of a manifest key is not correct. */
	INVALID_VALUE,

	/** The version format is not valid. */
	INVALID_VERSION,

	/** Failed to read or write the file. */
	IO_FILE_ERROR,

	/** Failed to read from or write to network. */
	IO_NETWORK_ERROR,

	/** The JAD URL has moved. */
	JAD_MOVED,

	/** The JAD was not found. */
	JAD_NOT_FOUND,

	/** The server hosting the JAD was not found. */
	JAD_SERVER_NOT_FOUND,

	/** JAR class file verification failed. */
	JAR_CLASSES_VERIFICATION_FAILED,

	/** The JAR is locked. */
	JAR_IS_LOCKED,

	/** The JAR was not found. */
	JAR_NOT_FOUND,

	/** The server containin the JAR was not found. */
	JAR_SERVER_NOT_FOUND,

	/** The JAR size is not correctly matched. */
	JAR_SIZE_MISMATCH,

	/** The name of a LIBlet collides with another LIBlet. */
	LIBLET_NAMESPACE_COLLISION,

	/** The configuration (MIDP, etc.) is missing from the manifest. */
	MISSING_CONFIGURATION,

	/** The hash code of a dependency is missing. */
	MISSING_DEPENDENCY_HASH,

	/** The JAD URL of a dependency is missing. */
	MISSING_DEPENDENCY_JAD_URL,

	/** The JAR size has not been specified. */
	MISSING_JAR_SIZE,

	/** The URL to the JAR has not been specified. */
	MISSING_JAR_URL,

	/** The profile (CLDC, etc.) is missing from the manifest. */
	MISSING_PROFILE,

	/** The provider certificate is missing. */
	MISSING_PROVIDER_CERT,

	/** No suite name was specified. */
	MISSING_SUITE_NAME,

	/** No vendor was specified. */
	MISSING_VENDOR,

	/** No version was specified. */
	MISSING_VERSION,

	/** The suite to be installed is newer than the current one. */
	NEW_VERSION,

	/** Not an error. */
	NO_ERROR,

	/** Another error occured. */
	OTHER_ERROR,

	/** Authetication with a proxy is required. */
	PROXY_AUTH,

	/** The push registration is not in the {@code MIDlet-n} attribute. */
	PUSH_CLASS_FAILURE,

	/** The push registration is already taken. */
	PUSH_DUP_FAILURE,

	/** The format of a push registration is not valid. */
	PUSH_FORMAT_FAILURE,

	/** The protocol of a push registration has failed. */
	PUSH_PROTO_FAILURE,

	/** The certificate has been revoked. */
	REVOKED_CERT,

	/** The name of the suite mismatches. */
	SUITE_NAME_MISMATCH,

	/** There are more properties than the available amount of memory. */
	TOO_MANY_PROPS,

	/** Trusted suites cannot be overwritten. */
	TRUSTED_OVERWRITE_FAILURE,

	/** Not authorized. */
	UNAUTHORIZED,

	/** Not authorized to install suits. */
	UNAUTHORIZED_INSTALL,

	/** Unknown certificate authority. */
	UNKNOWN_CA,

	/** Unknown certificate status. */
	UNKNOWN_CERT_STATUS,

	/** Certificate not supported. */
	UNSUPPORTED_CERT,

	/** Certificate character encoding not supported. */
	UNSUPPORTED_CHAR_ENCODING,

	/** Payment information not supported. */
	UNSUPPORTED_PAYMENT_INFO,

	/** The payment suite is not trusted. */
	UNTRUSTED_PAYMENT_SUITE,

	/** Vendor mismatched. */
	VENDOR_MISMATCH,

	/** Version mismatched. */
	VERSION_MISMATCH,

	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/ManagerFactory.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This class provides static methods for obtaining the application suite and
 * task manager.
 *
 * @since 2016/06/24
 */
public class ManagerFactory
{
	/** Lock for initialization. */
	private static final Object _LOCK =
		new Object();
	
	/** The suite manager. */
	private static volatile SuiteManager _SUITE_MANAGER;
	
	/** The task manager. */
	private static volatile TaskManager _TASK_MANAGER;
	
	/**
	 * Returns an instance of the suite manager that the application may use
	 * to manage suites on the system.
	 *
	 * @return The manager which is used to manage suites installed on the
	 * system.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
	 * "manageSuite")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public static SuiteManager getSuiteManager()
		throws SecurityException
	{
		// Lazily initialize
		synchronized (ManagerFactory._LOCK)
		{
			SuiteManager rv = ManagerFactory._SUITE_MANAGER;
			if (rv == null)
				ManagerFactory._SUITE_MANAGER =
					(rv = new __SystemSuiteManager__());
			return rv;
		}
	}
	
	/**
	 * This returns an instance of the task manager which is used to start,
	 * stop, and enumerate currently running tasks.
	 *
	 * @return The manager which is used to manage tasks which are currently
	 * running.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageTask")} or {@code {@link SWMPermission}("crossClient",
	 * "manageTask")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public static TaskManager getTaskManager()
		throws SecurityException
	{
		// Lazily initialize so that the class is easier to bring up rather
		// than at class initialization time
		synchronized (ManagerFactory._LOCK)
		{
			TaskManager rv = ManagerFactory._TASK_MANAGER;
			if (rv == null)
				ManagerFactory._TASK_MANAGER =
					(rv = new __SystemTaskManager__());
			return rv;
		}
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SWMPermission.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import java.security.BasicPermission;

/**
 * This is a permission which is used and checked in the security manager
 * to verify that the specified permissions are available before the
 * application and task manager are used.
 *
 * {@code "client"} refers to applications which are assigned to the same
 * client.
 *
 * {@code "crossClient"} is usually assigned to the root client which allows
 * a client to control other clients.
 *
 * @since 2016/06/24
 */
public final class SWMPermission
	extends BasicPermission
{
	/**
	 * Initializes a new permission.
	 *
	 * @param __scope The scope.
	 * @param __actions The actions used. If an action is specified multiple
	 * times then it is ignored.
	 * @throws IllegalArgumentException If any action includes a string which
	 * is not permitted or if the scope is incorrect.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	public SWMPermission(String __scope, String __actions)
		throws IllegalArgumentException, NullPointerException
	{
		super(__scope, __actions);
		
		// Check
		if (__scope == null || __actions == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/Suite.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
























































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import cc.squirreljme.runtime.swm.SuiteInfo;
import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.multiphasicapps.collections.EmptyIterator;
import net.multiphasicapps.strings.StringUtils;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This represents an application suite.
 *
 * Created suites by default have their {@link SuiteStateFlag#AVAILABLE} and
 * {@link SuiteStateFlag#ENABLED} flags set.
 *
 * @since 2016/06/24
 */
public class Suite
{
	/** This is a suite that represents the system. */
	public static Suite SYSTEM_SUITE =
		new Suite(Suite.class);
	
	/** The name of this suite. */
	final String _name;
	
	/** The state lock. */
	private final Object _lock =
		new Object();
	
	/** Cached manifest information (longer lived). */
	private JavaManifest _manifest;
	
	/** Cached suite information (longer lived). */
	private SuiteInfo _suiteinfo;
	
	/** No manifest available for usage? */
	private volatile boolean _nomanifest;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the system suite.
	 *
	 * @param __cl Ignored parameter.
	 * @since 2017/12/08
	 */
	private Suite(Class<Suite> __cl)
	{
		this._name = null;
	}
	
	/**
	 * Initializes the suite.
	 *
	 * @param __n The name of this suite.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/08
	 */
	Suite(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this._name = __n;
		
		// Pre-cache the manifest and subsequently the suite info
		this.__suiteInfo();
	}
	
	/**
	 * Checks if two suites are equal to each other, they are equal when
	 * the vendor and name of the suite match.
	 *
	 * @param __o The object to compare against.
	 * @return {@code true} if this suite is equal to the other object.
	 * @since 2016/06/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Not another suite?
		if (!(__o instanceof Suite))
			return false;
		
		// Check
		Suite o = (Suite)__o;
		return Objects.equals(getName(), o.getName()) &&
			Objects.equals(getVendor(), o.getVendor());
	}
	
	/**
	 * Returns the list of attributes which are defined in the JAD or the
	 * manifest.
	 *
	 * @return The iterator of attributes. The system suite always returns
	 * an empty iteration.
	 * @since 2016/06/24
	 */
	public Iterator<String> getAttributes()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return EmptyIterator.<String>empty();
		
		Set<String> rv = new LinkedHashSet<>();
		for (JavaManifestKey k : this.__manifest().getMainAttributes().
			keySet())
			rv.add(k.toString());
		return rv.iterator();
		*/
	}
	
	/**
	 * Returns the value of an attribute.
	 *
	 * @param __a The name of the attribute to obtain a value for.
	 * @return The value of the given attribute or {@code null} if it was not
	 * found. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getAttributeValue(String __a)
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		// Requesting the JAR file this is associated with, this might be
		// used for an icon
		if ("x-squirreljme-jarfile".equalsIgnoreCase(__a))
			return this._name;
		
		// Just need to read the value from the manifest
		return this.__manifest().getMainAttributes().getValue(__a);
	}
	
	/**
	 * Returns the library suites which this suite depends on.
	 *
	 * @return The iterator over the suite dependencies. The system suite
	 * always returns an empty iterator.
	 * @since 2016/06/24
	 */
	public Iterator<Suite> getDependencies()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return EmptyIterator.<Suite>empty();
		
		List<Suite> rv = new ArrayList<>();
		
		// Use the suite manager to wrap suites so that a large number of
		// suites pointing to the same program are not created
		__SystemSuiteManager__ ssm =
			(__SystemSuiteManager__)ManagerFactory.getSuiteManager();
		LibrariesClient manager = ssm._manager;
		
		// Dependencies are internally provided in the control interface
		String val = program.controlGet(LibraryControlKey.DEPENDENCIES);
		if (val != null)
			for (String spl : StringUtils.fieldSplitAndTrim(' ', val))
			{
				int ddx = Integer.valueOf(spl);
				Library sp = manager.byIndex(Integer.parseInt(val));
				if (sp != null)
				{
					Suite su = ssm.__ofProgram(sp);
					if (su.getSuiteType() != SuiteType.SYSTEM)
						rv.add(su);
				}
			}
		
		return rv.iterator();
		*/
	}
	
	/**
	 * This returns the URL which a previously installed suite was downloaded
	 * from.
	 *
	 * @return The URL where the suite was downloaded from. If this is the
	 * system suite, the suite was pre-installed, or was installed using the
	 * raw byte array then this will return null.
	 * @since 2016/06/24
	 */
	public String getDownloadUrl()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return null;
		
		return program.controlGet(LibraryControlKey.DOWNLOAD_URL);
		*/
	}
	
	/**
	 * This returns the names of all classes which are specfied in the MIDlet
	 * attributes in the manifest. The sequence of classes should match the
	 * MIDlet order number.
	 *
	 * @return The names of classes that are specified in the MIDlet attributes
	 * in the manifest. The system suite always returns an empty iterator.
	 * @since 2016/06/24
	 */
	public Iterator<String> getMIDlets()
	{
		// System suite always returns null
		if (this._name == null)
			return EmptyIterator.<String>empty();
		
		JavaManifestAttributes attr = this.__manifest().getMainAttributes();
		
		// Load in all midlet descriptions
		List<String> rv = new LinkedList<>();
		for (int i = 1; i >= 1; i++)
		{
			// These are in the following format
			String maybe = attr.getValue("MIDlet-" + i);
			if (maybe == null)
				break;
			
			// The value is in the following format:
			// name, icon, entry point
			// We only care about the entry point
			int lm = maybe.lastIndexOf(',');
			if (lm < 0)
				continue;
			
			// Use trimmed string since there may be extra whitespace
			rv.add(maybe.substring(lm + 1).trim());
		}
		
		return rv.iterator();
	}
	
	/**
	 * Returns the name of this suite.
	 *
	 * @return The suite name. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getName()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().name().toString();
	}
	
	/**
	 * Returns the type of suite that this is.
	 *
	 * @return The type of suite this is. The system suite always returns
	 * {@link SuiteType#SYSTEM}.
	 * @since 2016/06/24
	 */
	public SuiteType getSuiteType()
	{
		// Is system suite
		if (this._name == null)
			return SuiteType.SYSTEM;
		
		// Depends on the type
		switch (this.__suiteInfo().type())
		{
			case MIDLET:
				return SuiteType.APPLICATION;
			
			case LIBLET:
				return SuiteType.LIBRARY;
			
				// Not a valid suite type, should end up always being
				// filtered
			case SQUIRRELJME_API:
				return SuiteType.INVALID;
				
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the vendor of this suite.
	 *
	 * @return The vendor of this suite. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getVendor()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().vendor().toString();
	}
	
	/**
	 * Returns the version of this suite.
	 *
	 * @return The version of this suite. The system suite always returns null.
	 * @since 2016/06/24
	 */
	public String getVersion()
	{
		// System suite always returns null
		if (this._name == null)
			return null;
		
		return this.__suiteInfo().version().toString();
	}
	
	/**
	 * Calculates the hash code of the given suite, the values are derived from
	 * the name and the vendor.
	 *
	 * @return The hash code.
	 * @since 2016/06/24
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this.getVendor()) ^
			Objects.hashCode(this.getName());
	}
	
	/**
	 * Returns {@code true} if this suite is installed.
	 *
	 * @return {@code true} if this suite is installed. The system suite always
	 * returns {@code true}.
	 * @since 2016/06/24
	 */
	public boolean isInstalled()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return true;
		
		return Boolean.valueOf(
			program.controlGet(LibraryControlKey.IS_INSTALLED));
		*/
	}
	
	/**
	 * Checks if the suite has the specified flag set.
	 *
	 * @param __f The flag to check.
	 * @return {@code true} if the flag is set.
	 * @since 2016/06/24
	 */
	public boolean isSuiteState(SuiteStateFlag __f)
	{
		throw new todo.TODO();
		/*
		// Null is never true
		if (__f == null)
			return false;
		
		// The system suite always has a fixed set of flags
		Library program = this._library;
		if (program == null)
			switch (__f)
			{
				case AVAILABLE:
				case ENABLED:
				case PREINSTALLED:
				case REMOVE_DENIED:
				case SYSTEM:
				case UPDATE_DENIED:
					return true;
				default:
					return false;
			}
		
		return Boolean.valueOf(program.controlGet(__f.__controlKey()));
		*/
	}
	
	/**
	 * Sets whether this suite is trusted or not.
	 *
	 * @return {@code true} if this suite is trusted. The system suite always
	 * returns {@code true}.
	 * @since 2016/06/24
	 */
	public boolean isTrusted()
	{
		throw new todo.TODO();
		/*
		Library program = this._library;
		if (program == null)
			return true;
		
		return Boolean.valueOf(
			program.controlGet(LibraryControlKey.IS_TRUSTED));
		*/
	}
	
	/**
	 * Sets the given flag to the suite.
	 *
	 * @param __f The flag to set.
	 * @param __v If the flag should be set or cleared.
	 * @throws IllegalArgumentException If an attempt was made to set the
	 * {@link SuiteStateFlag#SYSTEM} or {@link SuiteStateFlag#PREINSTALLED}
	 * flags.
	 * @throws IllegalStateException If the suite was removed or this is the
	 * system suite.
	 * @throws SecurityException If the {@code {@link SWMPermission}("client",
	 * "manageSuite")} or {@code {@link SWMPermission}("crossClient",
	 * "manageSuite")} permission is not permitted.
	 * @since 2016/06/24
	 */
	public void setSuiteStateFlag(SuiteStateFlag __f, boolean __v)
		throws IllegalArgumentException, IllegalStateException,
			SecurityException
	{
		// Ignore
		if (__f == null)
			return;
		
		throw new todo.TODO();
		/*
		// {@squirreljme.error DG0q The current suite has been removed.}
		if (!isInstalled())
			throw new IllegalStateException("DG0q");
		
		// {@squirreljme.error DG0r The given state flag cannot be set.
		// (The state flag)}
		if (__f == SuiteStateFlag.SYSTEM || __f == SuiteStateFlag.PREINSTALLED)
			throw new IllegalArgumentException(String.format("DG0r %s", __f));
		
		// Lock
		synchronized (this._lock)
		{
			// {@squirreljme.error DG0s Cannot change flags of the system
			// suite.}
			if (0 != (this._state & (1 << SuiteStateFlag.SYSTEM.ordinal())))
				throw new IllegalStateException("DG0s");
			
			// Get the required bit
			int bit = (1 << __f.SYSTEM.ordinal());
			
			// Set or clear?
			if (__v)
				this._state |= bit;
			else
				this._state &= bit;
		}
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = "Suite " + this.getName() + ":" + this.getVersion()));
		
		return rv;
	}
	
	/**
	 * Returns the suite manifest.
	 *
	 * @return The suite manifest.
	 * @since 2017/12/31
	 */
	final JavaManifest __manifest()
	{
		JavaManifest rv = this._manifest;
		if (rv != null)
			return rv;
		
		// Definitely does not exist
		if (this._nomanifest)
			rv = new JavaManifest();
		
		// Could exist, hopefully it does
		else
			try (InputStream in = ResourceInputStream.open(this._name,
				"META-INF/MANIFEST.MF"))
			{
				// Will keep trying to open resources, so just prevent
				// that from happening
				if (in == null)
				{
					rv = new JavaManifest();
					this._nomanifest = true;
				}
				
				// Load it in
				else
					rv = new JavaManifest(in);
			}
			catch (IOException e)
			{
				// Print the manifest issue
				e.printStackTrace();
				
				// Just say there is no manifest
				rv = new JavaManifest();
				this._nomanifest = true;
			}
		
		// Cache
		this._manifest = rv;
		
		return rv;
	}
	
	/**
	 * Returns a dependency match result which contains the results of a
	 * dependency match between the provided dependencies and the provided
	 * dependencies for this suite.
	 *
	 * This is taken from the SquirrelJME build system.
	 *
	 * @param __d The input dependencies to check.
	 * @return The result of the match.
	 * @throws NullPointerException On null arguments.
	 * @sine 2018/11/02
	 */
	final MatchResult __matchedDependencies(DependencyInfo __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		return __d.match(this.__suiteInfo().provided());
	}
	
	/**
	 * Returns the information about this suite.
	 *
	 * @return The suite information.
	 * @since 2017/12/31
	 */
	final SuiteInfo __suiteInfo()
	{
		SuiteInfo rv = this._suiteinfo;
		if (rv != null)
			return rv;
		
		// Load
		this._suiteinfo = (rv = new SuiteInfo(this.__manifest()));
		
		return rv;
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteInstallListener.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This is a listener which is called when an application is currently being
 * installed, has finished installation, or failed to install.
 *
 * @since 2016/06/24
 */
public interface SuiteInstallListener
{
	/**
	 * This is called when an installation has finished for any reason, from
	 * success to failure.
	 *
	 * Before this is called, {@link #updateStatus(SuiteManagementTracker,
	 * SuiteInstallStage, int)} must be called with
	 * {@link SuiteInstallStage#DONE}.
	 *
	 * @param __ec The result of the installation attempt.
	 * @param __track The tracker which was created when an installation
	 * was started to be performed.
	 * @since 2016/06/24
	 */
	public abstract void installationDone(InstallErrorCodes __ec,
		SuiteManagementTracker __track);
	
	/**
	 * This is called when the current status of the installation of a suite
	 * has been updated. This may be used by a listener to provide a progress
	 * bar for example.
	 *
	 * @param __track The tracker which was created when an installation
	 * was started to be performed.
	 * @param __stage The current stage of the installation.
	 * @param __pct The amount of progress which has passed in this stage, this
	 * should be a value between zero and one hundred.
	 * @since 2016/06/24
	 */
	public abstract void updateStatus(SuiteManagementTracker __track,
		SuiteInstallStage __stage, int __pct);
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteInstallStage.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This represents the stage of an installation.
 *
 * @since 2016/06/24
 */
public enum SuiteInstallStage
{
	/** Installation finished. */
	DONE,
	
	/** Downloading document body. */
	DOWNLOAD_BODY,
	
	/** Downloading data. */
	DOWNLOAD_DATA,
	
	/** Downloading descriptor. */
	DOWNLOAD_DESCRIPTOR,
	
	/** Storing suite data. */
	STORING,
	
	/** Verifying the download. */
	VERIFYING,
	
	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteInstaller.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
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











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.swm.JarStreamSupplier;
import java.util.Set;
import net.multiphasicapps.collections.IdentityLinkedHashSet;

/**
 * This class is created when a suite is to be installed.
 *
 * @since 2016/06/24
 */
public final class SuiteInstaller
{
	/** The supplier for the JAR data. */
	final JarStreamSupplier _supplier;
	
	/** Listeners for suites. */
	final Set<SuiteInstallListener> _listeners =
		new IdentityLinkedHashSet<>();
	
	/**
	 * Internal use only.
	 *
	 * @param __sup The supplier for JAR files.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	SuiteInstaller(JarStreamSupplier __sup)
		throws NullPointerException
	{
		if (__sup == null)
			throw new NullPointerException("NARG");
		
		this._supplier = __sup;
	}
	
	/**
	 * Adds a suite installation listener which can be given status updates
	 * when a suite's installation status has changed.
	 *
	 * @param __sl The listener to add.
	 * @since 2016/06/24
	 */
	public final void addInstallationListener(SuiteInstallListener __sl)
	{
		// Ignore
		if (__sl == null)
			return;
		
		this._listeners.add(__sl);
	}
	
	/**
	 * Cancels the current installation.
	 *
	 * @since 2016/06/24
	 */
	public final void cancel()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Removes the given installation listener so that it no longer is notified
	 * of installation updates.
	 *
	 * @param __sl The listener to remove.
	 * @since 2016/06/24
	 */
	public final void removeInstallationListener(SuiteInstallListener __sl)
	{
		// Ignore
		if (__sl == null)
			return;
		
		this._listeners.remove(__sl);
	}
	
	/**
	 * Starts installation of the given suite.
	 *
	 * If this is called twice then the next installation attempt is
	 * enqueued regardless if the previous installation has succeeded or
	 * failed.
	 *
	 * If there is not enough permission to install the given suite then
	 * {@link InstallErrorCodes.UNAUTHORIZED_INSTALL} is set.
	 *
	 * @return The tracker for the given suite.
	 * @since 2016/06/24
	 */
	public final SuiteManagementTracker start()
	{
		return new __SuiteTracker__(this);
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteListener.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This interface is called when a suite has been installed, is being
 * installed, or has been removed.
 *
 * @since 2016/06/24
 */
public interface SuiteListener
{
	/**
	 * This is called when the installation state of a suite has been changed.
	 *
	 * If installation of a Suite has failed for any reason then
	 * {@link SuiteState#INSTALLATION_FAILED} must be called.
	 *
	 * @param __track This is either the tracker which was provided when an
	 * application was set for installation or an unspecified tracker in the
	 * event of a removal. In the event of removal it is likely that the
	 * tracker would not be the same one returned by an installation due to
	 * restarts of the virtual machine.
	 * @param __state The new state of the suite.
	 * @since 2016/06/24
	 */
	public abstract void notifySuiteStateChanged(
		SuiteManagementTracker __track, SuiteState __state);
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteLockedException.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import java.io.IOException;

/**
 * This is thrown when a suite cannot be removed, either because it is not
 * permitted or it is currently in use.
 *
 * @since 2016/06/24
 */
public class SuiteLockedException
	extends IOException
{
	/**
	 * Initializes the exception with no message.
	 *
	 * @since 2016/06/24
	 */
	public SuiteLockedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message.
	 *
	 * @param __s The message to use.
	 * @since 2016/06/24
	 */
	public SuiteLockedException(String __s)
	{
		super(__s);
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteManagementTracker.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This is used to track the the progress of a suite that is currently
 * being installed.
 *
 * @since 2016/06/24
 */
public abstract class SuiteManagementTracker
{
	/**
	 * Prevents implicit instantiation of trackers.
	 *
	 * @since 2016/06/24
	 */
	protected SuiteManagementTracker()
	{
	}
	
	/**
	 * Returns the suite that this tracker is assigned to or {@code null} if it
	 * is not install yet.
	 *
	 * @return The suite this tracker is assigned to or {@code null} if it
	 * has not yet been installed.
	 * @since 2016/06/24
	 */
	public abstract Suite getSuite();
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteManager.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
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
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import java.util.List;

/**
 * This interface is used to manage querying, installation, and removal of
 * Suites.
 *
 * @see ManagerFactory
 * @since 2016/06/24
 */
public interface SuiteManager
{
	/**
	 * Adds a listener which is used when the state of a suite has been changed
	 * such as when it has been installed or removed.
	 *
	 * @param __sl The listener to be added.
	 * @since 2016/06/24
	 */
	public abstract void addSuiteListener(SuiteListener __sl);
	
	/**
	 * Attempts to return an installed suite created by a specific vendor and
	 * which uses the given name.
	 *
	 * @param __vendor The vendor which created the given suite.
	 * @param __name The name of the suite.
	 * @return An instance of the given suite or {@code null} if it was not
	 * found.
	 * @since 2016/06/24
	 */
	public abstract Suite getSuite(String __vendor, String __name);
	
	/**
	 * Obtains an installer that would be used to install the given JAR file
	 * which is represented as raw byte data.
	 *
	 * The {@code {@link SWMPermission}("client", "installation")} or
	 * {@code {@link SWMPermission}("crossClient", "installation")} is checked
	 * before an installation is attempted.
	 *
	 * @param __b The raw JAR data.
	 * @param __o The offset to the start of the data.
	 * @param __l The length of the data.
	 * @param __ignuplock If {@code true} then the components of the suite
	 * will be updated without regards to synchronization, this is not
	 * recommended and {@code false} should always be used.
	 * @return An installer which represents this given installation.
	 * @throws IllegalArgumentException If the input buffer is null, empty, or
	 * the offset and length are negative or exceed the array bounds.
	 * @throws SecurityException If the current application is not permitted
	 * to install new suites.
	 * @since 2016/06/24
	 */
	public abstract SuiteInstaller getSuiteInstaller(byte[] __b, int __o,
		int __l, boolean __ignuplock)
		throws IllegalArgumentException, SecurityException;
	
	/**
	 * This attempts to install a suite which is specified at the given URL. It
	 * is implementation dependent on how the URL is handled, it may be a
	 * platform specific resource or a network resource.
	 *
	 * The {@code {@link SWMPermission}("client", "installation")} or
	 * {@code {@link SWMPermission}("crossClient", "installation")} is checked
	 * before an installation is attempted.
	 *
	 * @param __url The URL which refers to a suite to be installed.
	 * @param __ignuplock If {@code true} then the components of the suite
	 * will be updated without regards to synchronization, this is not
	 * recommended and {@code false} should always be used.
	 * @throws IllegalArgumentException If the URL is not valid or it could
	 * not be obtained.
	 * @throws SecurityException If the current application is not permitted
	 * to install new suites.
	 * @since 2016/06/24
	 */
	public abstract SuiteInstaller getSuiteInstaller(String __url,
		boolean __ignuplock)
		throws IllegalArgumentException, SecurityException;
	
	/**
	 * Returns a list of the suites tha are currently installed on the system.
	 *
	 * @param __t The type of suites to obtain, only
	 * {@link SuiteType#APPLICATION} and {@link SuiteType#LIBRARY} are valid.
	 * @return A list containing the suites which are currently installed,
	 * if there are no suites then this may be empty.
	 * @throws IllegalArgumentException If the requested type is neither
	 * an application or a library.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	public abstract List<Suite> getSuites(SuiteType __t)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Synchronously removes the given installed suite.
	 *
	 * Suites must be stopped before they can be used, a removal of a suite
	 * that is currently active cannot be performed.
	 *
	 * In situations where any resources of the suite are currently being used
	 * by an application, the removed suite must still make its resources
	 * accessible until all of them are released.
	 *
	 * If a suite was removed without issues then {@link Suite#isInstalled()}
	 * will return {@code false}.
	 *
	 * @param __s The suite to be removed.
	 * @param __ignuplock If {@code true} then the suite is removed regardless
	 * if it has the {@link SuiteStateFlag#REMOVE_DENIED} flag.
	 * @throws IllegalArgumentException If the suite has already been removed,
	 * or if the application is currently running and the application.
	 * @throws SuiteLockedException If the suite is locked and
	 * {@code __ignuplock} has been set to {@code false}. It should also be
	 * noted that it is possible for this to be thrown regardless of the
	 * parameter.
	 * @since 2016/06/24
	 */
	public abstract void removeSuite(Suite __s, boolean __ignuplock)
		throws IllegalArgumentException, SuiteLockedException;
	
	/**
	 * Removes a previously added suite listener so that it no longer is
	 * given any status updated when the state of a suite has changed.
	 *
	 * @param __sl The listener to remove.
	 * @since 2016/06/24
	 */
	public abstract void removeSuiteListener(SuiteListener __sl);
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteState.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This represents the state that a suite is in.
 *
 * @since 2016/06/24
 */
public enum SuiteState
{
	/** Installation failed. */
	INSTALLATION_FAILED,
	
	/** Installed. */
	INSTALLED,
	
	/** Currently being installed. */
	INSTALLING,
	
	/** Removed. */
	REMOVED,
	
	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteStateFlag.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This represents a flag which may be associated with a suite.
 *
 * @since 2016/06/24
 */
public enum SuiteStateFlag
{
	/** Available. */
	AVAILABLE,
	
	/** Enabled, the application or library may be used. */
	ENABLED,
	
	/** The application or library is pre-installed with the system. */
	PREINSTALLED,
	
	/** Remove is not supported. */
	REMOVE_DENIED,
	
	/** A suite provided by the system. */
	SYSTEM,
	
	/** The suite cannot be updated. */
	UPDATE_DENIED,
	
	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/SuiteType.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * The type that a suite is.
 *
 * @since 2016/06/24
 */
public enum SuiteType
{
	/** An application (MIDlet). */
	APPLICATION,
	
	/** Invalid. */
	INVALID,
	
	/** A library (LIBlet). */
	LIBRARY,
	
	/** A system suite. */
	SYSTEM,
	
	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/Task.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
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
191
192
































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This describes a task which is currently running on the system. Each task
 * has a starting point which is a {@link javax.microedition.midlet.MIDlet}.
 *
 * System tasks cannot be started or stopped.
 *
 * @since 2016/06/24
 */
public final class Task
{
	/** The ID of the task. */
	final int _tid;
	
	/** The suite of this task. */
	final Suite _suite;
	
	/** The entry class of the task. */
	final String _entry;
	
	/**
	 * Initializes the task.
	 *
	 * @param __tid The task ID, zero is the system task.
	 * @param __s The suite used.
	 * @param __e The entry name of the task.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	Task(int __tid, Suite __s, String __e)
		throws NullPointerException
	{
		if (__s == null || __e == null)
			throw new NullPointerException("NARG");
		
		this._tid = __tid;
		this._suite = __s;
		this._entry = __e;
	}
	
	/**
	 * Checks if this task is the same as another task, tasks are equal if
	 * they share the same name.
	 *
	 * @param __o The other object.
	 * @return {@code true} if this is the same task.
	 * @sicne 2016/06/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		// Must be another task
		if (!(__o instanceof Task))
			return false;
		
		// Check
		Task o = (Task)__o;
		return Objects.equals(this.getSuite(), o.getSuite()) &&
			Objects.equals(this.getName(), o.getName());
	}
	
	/**
	 * Returns the estimated number of bytes that a task is using.
	 *
	 * @return The number of bytes the task is estimated to be using.
	 * @since 2016/06/24
	 */
	public int getHeapUse()
	{
		throw new todo.TODO();
		/*
		// Make sure the amount of memory used does not overflow ever
		long rv = this._task.metric(SystemTaskMetric.MEMORY_USED);
		if (rv < 0L)
			return 0;
		else if (rv > Integer.MAX_VALUE)
			return Integer.MAX_VALUE;
		return (int)rv;
		*/
	}
	
	/**
	 * Returns the name of the current task.
	 *
	 * @return The name of the task, system tasks always return {@code null}.
	 * @since 2016/06/24
	 */
	public String getName()
	{
		// System tasks have no name
		if (this.isSystemTask())
			return null;
		
		return this._entry;
	}
	
	/**
	 * Returns the priority of this task.
	 *
	 * @return The task priority.
	 * @since 2016/06/24
	 */
	public TaskPriority getPriority()
	{
		throw new todo.TODO();
		/*
		long rv = this._task.metric(SystemTaskMetric.PRIORITY);
		if (rv < 0L)
			return TaskPriority.MAX;
		else if (rv > 0L)
			return TaskPriority.MIN;
		return TaskPriority.NORM;
		*/
	}
	
	/**
	 * Returns the status of this task.
	 *
	 * @return The task status.
	 * @since 2016/06/24
	 */
	public TaskStatus getStatus()
	{
		// If the TID is negative then it failed to start
		int tid = this._tid;
		if (tid < 0)
			return TaskStatus.START_FAILED;
		
		return TaskStatus.__of(TaskAccess.taskStatus(tid));
	}
	
	/**
	 * Returns the suite that this task belongs to.
	 *
	 * @return The owning suite.
	 * @since 2016/06/24
	 */
	public Suite getSuite()
	{
		// All system tasks are hidden behind the system suite
		if (this.isSystemTask())
			return Suite.SYSTEM_SUITE;
		
		return this._suite;
	}
	
	/**
	 * Returns the hash code of this task, the hashcode is derived from the
	 * suite and the name.
	 *
	 * @return The hash code.
	 * @since 2016/06/24
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this.getSuite()) ^
			Objects.hashCode(this.getName());
	}
	
	/**
	 * Returns {@code true} if this is a system task.
	 *
	 * @return {@code true} if a system task.
	 * @since 2016/06/24
	 */
	public boolean isSystemTask()
	{
		// System task is always zero
		return this._tid == 0;
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/TaskListener.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This is called when a task has changed status.
 *
 * @since 2016/06/24
 */
public interface TaskListener
{
	/**
	 * This is called when a task has changed status.
	 *
	 * @param __t The task which has had its status changed.
	 * @param __status The new status of the task.
	 * @since 2016/06/24
	 */
	public abstract void notifyStatusUpdate(Task __t, TaskStatus __status);
}

Deleted runt/apis/meep-swm/javax/microedition/swm/TaskManager.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import java.util.List;

/**
 * This is an interface which is used to manage tasks. Tasks allow multiple
 * suites to be ran at the same time.
 *
 * @see ManagerFactory
 * @since 2016/06/24
 */
public interface TaskManager
{
	/**
	 * Adds the given task listener so that if the state of any task changes
	 * then the provided methods are called.
	 *
	 * @param __tl The listener for events.
	 * @since 2016/06/24
	 */
	public abstract void addTaskListener(TaskListener __tl);
	
	/**
	 * Returns the task which belongs to the caller of this method.
	 *
	 * @return The task of the current caller.
	 * @since 2016/06/24
	 */
	public abstract Task getCurrentTask();
	
	/**
	 * This returns the list of all running tasks on the system.
	 *
	 * @param __incsys If {@code true} then any tasks which are owned by the
	 * system are also returned.
	 * @return The list of tasks which currently exist within the virtual
	 * machine.
	 * @since 2016/06/24
	 */
	public abstract List<Task> getTaskList(boolean __incsys);
	
	/**
	 * Removes the given task listener so that it is no longer notified when
	 * the state of a task has changed.
	 *
	 * @param __tl The task listener to remove.
	 * @since 2016/06/24
	 */
	public abstract void removeTaskListener(TaskListener __tl);
	
	/**
	 * Sets the given task so that it appears at the foreground task which
	 * is running, this operation may fail.
	 *
	 * A task that is in the foreground is one which is visible and has
	 * input focus. It is possible that a call of this method will have no
	 * effect.
	 *
	 * @param __t The task to bring to the foreground.
	 * @return If {@code true} then the task was brought to the foreground.
	 * @throws IllegalArgumentException If the task is a system task.
	 * @since 2016/06/24
	 */
	public abstract boolean setForeground(Task __t)
		throws IllegalArgumentException;
	
	/**
	 * Attempts to set the priority of a given task. A call of this method
	 * may affect the amount of time slices which are available to a process
	 * or its resume priority in the event of cooperative multi-tasking.
	 *
	 * @param __t The task to change the priority of.
	 * @param __p The new priority of the given task.
	 * @return {@code true} if the priority of the given task has been
	 * changed.
	 * @throws IllegalArgumentException if the task is a system task.
	 * @since 2016/06/24
	 */
	public abstract boolean setPriority(Task __t, TaskPriority __p)
		throws IllegalArgumentException;
	
	/**
	 * Attempts to create a task which runs the given suite.
	 *
	 * The task is created and is initially in the {@link TaskStatus#STARTING}
	 * state. If starting fails then it enters the
	 * {@link TaskStatus#START_FAILED} state.
	 *
	 * A suite may only be active once and cannot have multiple copies running
	 * at the same time. In the event that an application is already running it
	 * must be sent an event specifying an application re-launch.
	 *
	 * @param __s The suite to start, must be an application.
	 * @param __cn The class which extends
	 * {@link javax.microedition.midlet.MIDlet} and acts as the main entry
	 * point for the program.
	 * @return The task which was created.
	 * @throws IllegalArgumentException If the suite is a library, the given
	 * class does not exist, or the given class does not extend
	 * {@link javax.microedition.midlet.MIDlet}.
	 * @throws IllegalStateException If the suite has been removed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/06/24
	 */
	public abstract Task startTask(Suite __s, String __cn)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException;
	
	/**
	 * Attempts to stop the given task and destroy it so that it does not
	 * consume memory or execution cycles.
	 *
	 * @param __t The task to be stopped.
	 * @return {@code true} if the task has been stopped and destroyed.
	 * @throws IllegalArgumentException If the task has already stopped, has
	 * not yet been started, or has finished execution.
	 * @throws IllegalStateException If the task is a system task.
	 * @since 2016/06/24
	 */
	public abstract boolean stopTask(Task __t)
		throws IllegalArgumentException, IllegalStateException;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/TaskPriority.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This represents the priority of a task.
 *
 * @since 2016/06/24
 */
public enum TaskPriority
{
	/** Maximum priority. */
	MAX,
	
	/** Minimum priority. */
	MIN,
	
	/** Normal priority. */
	NORM,
	
	/** End. */
	;
}

Deleted runt/apis/meep-swm/javax/microedition/swm/TaskStatus.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

/**
 * This represents the status of a task.
 *
 * @since 2016/06/24
 */
public enum TaskStatus
{
	/** Fatally exited. */
	EXITED_FATAL,
	
	/** Normal exit. */
	EXITED_REGULAR,
	
	/** Terminated. */
	EXITED_TERMINATED,
	
	/** Running. */
	RUNNING,
	
	/** Failed to start. */
	START_FAILED,
	
	/** Starting. */
	STARTING,
	
	/** End. */
	;
	
	/**
	 * Maps ordinal back into task status.
	 *
	 * @param __i Index to get.
	 * @return The task status.
	 * @since 2018/11/04
	 */
	static final TaskStatus __of(int __i)
	{
		switch (__i)
		{
			case 0: return EXITED_FATAL;
			case 1: return EXITED_REGULAR;
			case 2: return EXITED_TERMINATED;
			case 3: return RUNNING;
			case 4: return START_FAILED;
			case 5: return STARTING;
			
			default:
				return EXITED_FATAL;
		}
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/__CCWrapper__.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
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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.ConsoleCallback;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is a wrapper for when a task writes to its console, this will be
 * called which just forwards to the output stream specified.
 *
 * @since 2019/02/02
 */
final class __CCWrapper__
	implements ConsoleCallback
{
	/** The stream to forward to. */
	protected final OutputStream out;
	
	/**
	 * Initializes the wrapper to the given stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/02
	 */
	__CCWrapper__(OutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean close()
	{
		try
		{
			this.out.close();
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean flush()
	{
		try
		{
			this.out.flush();
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final boolean write(byte[] __b, int __o, int __l)
	{
		try
		{
			this.out.write(__b, __o, __l);
			return true;
		}
		catch (IOException e)
		{
			return false;
		}
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/__SuiteTracker__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.swm.JarStreamSupplier;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Set;

/**
 * This performs the installation and tracks progress.
 *
 * @since 2017/12/28
 */
final class __SuiteTracker__
	extends SuiteManagementTracker
{
	/** Bytes per percent threshold. */
	private static final int _PERCENT_THRESHOLD =
		4096;
	
	/** The suite when it is installed. */
	volatile Suite _suite;
	
	/**
	 * Initializes the tracker.
	 *
	 * @param __i The owning installer.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__SuiteTracker__(SuiteInstaller __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// Setup thread which performs the actual installation
		Thread thread = new Thread(new __Runner__(this, __i),
			"SquirrelJME-Suite-Installer");
		thread.start();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/06/24
	 */
	@Override
	public Suite getSuite()
	{
		return this._suite;
	}
	
	/**
	 * This thread performs the installation.
	 *
	 * @since 2017/12/28
	 */
	private static final class __Runner__
		implements Runnable
	{
		/** The tracker which is given the suite when finished. */
		protected final __SuiteTracker__ tracker;
		
		/** The supplier for the JAR data. */
		protected final JarStreamSupplier supplier;
	
		/** Listeners for suites. */
		private final Set<SuiteInstallListener> _listeners;
		
		/**
		 * Initializes the runner.
		 *
		 * @param __tracker The tracker where the resulting suite is placed.
		 * @param __i The installer used.
		 * @throws NullPointerException On null arguments.
		 * @since 2017/12/28
		 */
		private __Runner__(__SuiteTracker__ __tracker, SuiteInstaller __i)
			throws NullPointerException
		{
			if (__tracker == null || __i == null)
				throw new NullPointerException("NARG");
			
			this.tracker = __tracker;
			this.supplier = __i._supplier;
			this._listeners = __i._listeners;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public void run()
		{
			try
			{
				throw new todo.TODO();
				/*
				// Read the JAR data stream 
				byte[] data;
				__update(SuiteInstallStage.DOWNLOAD_DATA, 0);
				try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
					InputStream is = this.supplier.get())
				{
					// Read in source data
					byte[] buf = new byte[512];
					for (int count = 0, last = 0;;)
					{
						int rc = is.read(buf);
					
						if (rc < 0)
							break;
					
						baos.write(buf, 0, rc);
					
						// Update progress for the first initial set of blocks
						if (last < 99)
						{
							count += rc;
							int now = count / _PERCENT_THRESHOLD;
							if (last != now && now <= 99)
							{
								__update(SuiteInstallStage.DOWNLOAD_DATA, now);
								last = now;
							}
						}
					}
				
					// Get the entire data buffer
					baos.flush();
					data = baos.toByteArray();
				}
			
				// Could not read the JAR
				catch (IOException e)
				{
					__done(InstallErrorCodes.IO_FILE_ERROR);
					return;
				}
				__update(SuiteInstallStage.DOWNLOAD_DATA, 100);
				
				// Need the library manager
				__SystemSuiteManager__ ssm =
					(__SystemSuiteManager__)ManagerFactory.getSuiteManager();
				LibrariesClient manager = ssm._manager;
			
				// Send it to the kernel
				__update(SuiteInstallStage.VERIFYING, 0);
				LibraryInstallationReport report = manager.install(
					data, 0, data.length);
			
				// Failed
				int error = report.error();
				if (error != 0)
				{
					// Determine the error code
					error--;
					InstallErrorCodes[] codes = InstallErrorCodes.values();
					InstallErrorCodes code = (error >= 0 &&
						error < codes.length ? codes[error] :
						InstallErrorCodes.OTHER_ERROR);
					
					// This will be the only chance to print the installation
					// report
					// {@squirreljme.error DG0t Failed to install the program
					// due to the specified error. (The error code; The more
					// detailed message associated with the error)}
					System.err.printf("DG0t %s %s%n", code, report.message());
					
					// Mark as done
					__done(code);
					return;
				}
			
				// Set the suite used
				this.tracker._suite = new Suite(report.library());
			
				// Did not fail, but report it anyway
				__update(SuiteInstallStage.VERIFYING, 100);
			
				// Finished
				__update(SuiteInstallStage.DONE, 100);
				__done(InstallErrorCodes.NO_ERROR);
				*/
			}
			
			// Oops
			catch (Throwable t)
			{
				// Just print the trace
				t.printStackTrace();
				
				// And use some other error code to indicate failure 
				__done(InstallErrorCodes.OTHER_ERROR);
			}
		}
		
		/**
		 * Called when installation has finished, potentially with an error.
		 *
		 * @param __code The error code.
		 * @since 2017/12/28
		 */
		private void __done(InstallErrorCodes __code)
		{
			__SuiteTracker__ tracker = this.tracker;
			for (SuiteInstallListener l : this._listeners)
				try
				{
					l.installationDone(__code, tracker);
				}
				catch (Exception e)
				{
				}
		}
		
		/**
		 * Updates the current install stage.
		 *
		 * @param __stage The current installation stage.
		 * @param __pct The percentage complete.
		 * @since 2017/12/28
		 */
		private void __update(SuiteInstallStage __stage, int __pct)
		{
			__SuiteTracker__ tracker = this.tracker;
			for (SuiteInstallListener l : this._listeners)
				try
				{
					l.updateStatus(tracker, __stage, __pct);
				}
				catch (Exception e)
				{
				}
		}
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/__SystemSuiteManager__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262






































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.swm.ByteArrayJarStreamSupplier;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.InvalidSuiteException;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import cc.squirreljme.runtime.cldc.asm.SuiteAccess;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;

/**
 * This class manages the bridge for the suite manager to the native program
 * manager.
 *
 * @since 2017/12/08
 */
final class __SystemSuiteManager__
	implements SuiteManager
{
	/** Cache of suites which are available. */
	private static final Map<String, Suite> _SUITES =
		new HashMap<>();
	
	/** Internal lock for suite management. */
	protected final Object lock =
		new Object();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void addSuiteListener(SuiteListener __sl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public Suite getSuite(String __vendor, String __name)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public SuiteInstaller getSuiteInstaller(byte[] __b, int __o,
		int __l, boolean __ignuplock)
		throws IllegalArgumentException, SecurityException
	{
		return new SuiteInstaller(
			new ByteArrayJarStreamSupplier(__b, __o, __l));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public SuiteInstaller getSuiteInstaller(String __url,
		boolean __ignuplock)
		throws IllegalArgumentException, SecurityException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public List<Suite> getSuites(SuiteType __t)
		throws IllegalArgumentException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Go through suites and find suites to return
		List<Suite> rv = new ArrayList<>();
		for (Suite s : __SystemSuiteManager__.__allSuites())
			if (s.getSuiteType() == __t)
				rv.add(s);
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void removeSuite(Suite __s, boolean __ignuplock)
		throws IllegalArgumentException, SuiteLockedException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/08
	 */
	@Override
	public void removeSuiteListener(SuiteListener __sl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns all of the suites which are available.
	 *
	 * @return All of the available suites.
	 * @since 2018/10/30
	 */
	static List<Suite> __allSuites()
	{
		// Just get every suite
		List<Suite> rv = new ArrayList<>();
		for (String as : SuiteAccess.availableSuites())
		{
			// It is possible they might not load
			Suite s = __SystemSuiteManager__.__getSuite(as);
			if (s != null)
				rv.add(s);
		}
		
		return rv;
	}
	
	/**
	 * Gets the specified suite.
	 *
	 * @param __s The suite to get.
	 * @return The suite for the given name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/26
	 */
	static Suite __getSuite(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, Suite> suites = __SystemSuiteManager__._SUITES;
		synchronized (suites)
		{
			// Preloaded?
			Suite rv = suites.get(__s);
			if (rv != null)
				return rv;
			
			// Previously did not exist or failed to load
			if (suites.containsKey(__s))
				return null;
			
			try
			{
				// Cache the suite
				suites.put(__s, (rv = new Suite(__s)));
				return rv;
			}
			catch (InvalidSuiteException e)
			{
				// Debug it
				e.printStackTrace();
				
				// Just cache it as invalid
				suites.put(__s, null);
				return null;
			}
		}
	}
	
	/**
	 * Returns the suites which match the given dependency set.
	 *
	 * This is copied from the SquirrelJME build system.
	 *
	 * @param __set The set of dependencies to get.
	 * @param __opt If {@code true} include optional dependencies.
	 * @return Suites which statisfy the given dependencies.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/02
	 */
	static Suite[] __matchDependencies(DependencyInfo __set, boolean __opt)
		throws NullPointerException
	{
		if (__set == null)
			throw new NullPointerException("NARG");
		
		// Clear all optionals if they are not included
		if (!__opt)
			__set = __set.noOptionals();
		
		// No dependencies to search for
		if (__set.isEmpty())
			return new Suite[0];
		
		// Remember the original set for recursive dependency checks
		DependencyInfo original = __set;
		
		// The returning set
		Set<Suite> rv = new LinkedHashSet<>();
		
		// Go through all binaries and attempt to match
		for (Suite bin : __SystemSuiteManager__.__allSuites())
		{
			// Only consider matches
			MatchResult result = bin.__matchedDependencies(__set);
			if (!result.hasMatches())
				continue;
			
			// Use this as a dependency
			rv.add(bin);
			
			// Recursively go down
			for (Suite sub : __SystemSuiteManager__.__matchDependencies(
				bin.__suiteInfo().dependencies(), false))
				rv.add(sub);
			
			// Use remaining unmatched set
			__set = result.unmatched();
			
			// If the set was emptied then it will never have any more matches
			if (__set.isEmpty())
				break;
		}
		
		// {@squirreljme.error DG0u Could not locate the suite which
		// statifies the given dependency. (The dependency to look for)}
		if (rv.isEmpty())
			throw new RuntimeException(
				String.format("DG0u %s", __set));
		
		return rv.<Suite>toArray(new Suite[rv.size()]);
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/__SystemTaskManager__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289

































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.swm;

import cc.squirreljme.runtime.cldc.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.swm.DependencyInfo;
import cc.squirreljme.runtime.swm.ExtendedTaskManager;
import cc.squirreljme.runtime.swm.MatchResult;
import cc.squirreljme.runtime.swm.ProvidedInfo;
import java.io.OutputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * This is the task manager which interfaces with the CLDC system support
 * methods to provide access to tasks and such.
 *
 * @since 2017/12/07
 */
final class __SystemTaskManager__
	implements ExtendedTaskManager, TaskManager
{
	/** Mapping of task IDs to tasks. */
	static final Map<Integer, Task> _TASKS =
		new HashMap<>();
	
	/** Internal lock for chore management. */
	protected final Object lock =
		new Object();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public void addTaskListener(TaskListener __tl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public Task getCurrentTask()
	{
		throw new todo.TODO();
		/*
		return this.__byId(APIAccessor.chores().currentId());
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public List<Task> getTaskList(boolean __incsys)
	{
		throw new todo.TODO();
		/*
		// Lock so that the task list is always up to date
		Task[] rv;
		synchronized (this.lock)
		{
			IntegerArray tids = SystemCall.EASY.taskList(__incsys);
			int n = tids.length();
			
			// Wrap all the tasks
			rv = new Task[n];
			for (int i = 0; i < n; i++)
				rv[i] = this.__ofTask(new WrappedTask(tids.get(i)));
		}
		
		// Wrap array instead of creating a new list for speed
		return Arrays.<Task>asList(rv);
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public void removeTaskListener(TaskListener __tl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean setForeground(Task __t)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean setPriority(Task __t, TaskPriority __p)
		throws IllegalArgumentException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/29
	 */
	@Override
	public Task startTask(Suite __s, String __cn)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		// Forward to the extended task start
		return this.startTask(__s, __cn, null, null, null, null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/02
	 */
	@Override
	public final Task startTask(Suite __s, String __cn,
		Map<String, String> __sprops, String[] __args, OutputStream __stdout,
		OutputStream __stderr)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException
	{
		if (__s == null || __cn == null)
			throw new NullPointerException("NARG");
		
		// Defensive copies
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// Make sure values are actually valid
		for (int i = 0, n = __args.length; i < n; i++)
			if (__args[i] == null)
				throw new NullPointerException("NARG");
		for (Map.Entry<String, String> e : __sprops.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			if (k == null || v == null)
				throw new NullPointerException("NARG");
		}
		
		// {@squirreljme.error DG0v Cannot start a non-application suite.}
		if (__s.getSuiteType() != SuiteType.APPLICATION)
			throw new IllegalArgumentException("DG0v");
		
		// Get all the suites that are available, since we need to determine
		// dependencies and such
		List<Suite> all = __SystemSuiteManager__.__allSuites();
		
		// Determine the suites which need to be loaded into the classpath
		// in order to run the given suite
		Suite[] depends = __SystemSuiteManager__.__matchDependencies(
			__s.__suiteInfo().dependencies(), false);
		
		// Load suite names since we need to build the class path
		int n = depends.length;
		String[] names = new String[n + 1];
		for (int i = 0; i < n; i++)
			names[i] = depends[i]._name;
		
		// Add our boot suite to the last entry
		names[n] = __s._name;
		
		// Debug
		todo.DEBUG.note("Suites: %s", Arrays.<String>asList(names));
		
		// SquirrelJME 0.3.0 allows system properties and alternative output
		// streams to be specified as well
		int tid;
		if (ApiLevel.minimumLevel(ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV))
		{
			// Copy system properties to key/value pair array
			int spn = __sprops.size();
			String[] xprops = new String[spn * 2];
			Iterator<Map.Entry<String, String>> eit = __sprops.entrySet().
				iterator();
			for (int i = 0, o = 0; i < spn; i++, o += 2)
			{
				Map.Entry<String, String> e = eit.next();
				
				xprops[o] = e.getKey();
				xprops[o + 1] = e.getValue();
			}
			
			// Forward launch
			tid = TaskAccess.startTask(names, __cn, __args, xprops,
				(__stdout == null ? null : new __CCWrapper__(__stdout)),
				(__stderr == null ? null : new __CCWrapper__(__stderr)));
		}
		else
			tid = TaskAccess.startTask(names, __cn, __args);
		
		// It did not work
		if (tid < 0)
		{
			// {@squirreljme.error DG0w Invalid entry point was specified
			// when starting task. (The entry point)}
			if (tid == TaskAccess.ERROR_INVALID_ENTRY)
				throw new IllegalArgumentException("DG0w " + __cn);
			
			// {@squirreljme.error DG0x Could not launch the task because of
			// an unspecified error. (The error)}
			throw new IllegalArgumentException("DG0x " + tid);
		}
		
		// Debug
		todo.DEBUG.note("Created task with TID %d", tid);
		
		// Otherwise use cached form
		return this.__getTask(tid, __s, __cn);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/07
	 */
	@Override
	public boolean stopTask(Task __t)
		throws IllegalArgumentException, IllegalStateException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a task mapped to the given ID.
	 *
	 * @param __tid The task ID.
	 * @param __s The suite used.
	 * @param __n The starting class of the task, gives its name.
	 * @return The task for the task.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	static final Task __getTask(int __tid, Suite __s, String __n)
		throws NullPointerException
	{
		if (__s == null || __n == null)
			throw new NullPointerException("NARG");
		
		// Lock on the tasks
		Map<Integer, Task> tasks = _TASKS;
		synchronized (tasks)
		{
			// There should not be duplicates
			Integer k = __tid;
			Task rv = tasks.get(k);
			if (rv != null)
				throw new todo.OOPS();
			
			tasks.put(k, (rv = new Task(__tid, __s, __n)));
			return rv;
		}
	}
}

Deleted runt/apis/meep-swm/javax/microedition/swm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the suite and task managers. Suites are applications
 * which may be launched and represented as tasks. This essentially permits
 * multiple applications to run at the same time.
 *
 * @since 2016/06/24
 */

package javax.microedition.swm;

Deleted runt/apis/midp-lcdui.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/apis/midp-lcdui.test/TestDisplay.in.

1
2
3



-
-
-
result: NoResult
thrown: NoExceptionThrown

Deleted runt/apis/midp-lcdui.test/TestDisplay.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestRunnable;

import javax.microedition.lcdui.Display;

/**
 * Tests that the display works.
 *
 * @since 2018/11/12
 */
public class TestDisplay
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/12
	 */
	@Override
	public void test()
	{
		__Utils__.getDisplay();
	}
}

Deleted runt/apis/midp-lcdui.test/TestFont.in.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
result: NoResult
thrown: NoExceptionThrown
secondary-monospace--16-dsqf: true
secondary-monospace--12-dsqf: true
secondary-monospace--8-dsqf: true
secondary-sansserif--16-dsqf: true
secondary-sansserif--12-dsqf: true
secondary-sansserif--8-dsqf: true
secondary-serif--16-dsqf: true
secondary-serif--12-dsqf: true
secondary-serif--8-dsqf: true

Deleted runt/apis/midp-lcdui.test/TestFont.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.InputStream;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that the fonts load.
 *
 * @since 2018/11/25
 */
public class TestFont
	extends TestRunnable
{
	/** The fonts to test reading. */
	private static final String[] _FONTS =
		{
			"monospace-8.sqf",
			"monospace-12.sqf",
			"monospace-16.sqf",
			"sansserif-8.sqf",
			"sansserif-12.sqf",
			"sansserif-16.sqf",
			"serif-8.sqf",
			"serif-12.sqf",
			"serif-16.sqf",
		};
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public void test()
	{
		for (String s : _FONTS)
			try (InputStream in = SQFFont.class.getResourceAsStream(s))
			{
				// Try to read
				SQFFont f = SQFFont.read(in);
				
				// Did read
				this.secondary(s, true);
			}
			catch (Throwable t)
			{
				this.secondary(s, t);
				
				t.printStackTrace();
			}
	}
}

Deleted runt/apis/midp-lcdui.test/__Utils__.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import javax.microedition.lcdui.Display;
import net.multiphasicapps.tac.InvalidTestException;
import net.multiphasicapps.tac.UntestableException;

/**
 * Utilities for the LCDUI tests.
 *
 * @since 2019/03/04
 */
final class __Utils__
{
	/**
	 * Attempts to obtain the display, otherwise the test cannot be ran.
	 *
	 * @return The display to use.
	 * @throws InvalidTestException If the display could not be obtained.
	 * @since 2019/03/04
	 */
	public static final Display getDisplay()
		throws InvalidTestException
	{
		try
		{
			return Display.getDisplays(0)[0];
		}
		
		// No display possible?
		catch (Throwable e)
		{
			throw new UntestableException(e);
		}
	}
}

Deleted runt/apis/midp-lcdui/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: LCDUI
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the standard MIDP LCD User 
 Interface which uses graphical text, widgets, and images to interact 
 with the user. Unlike the MEEP Line User Interface, this requires a 
 much more capable graphical system.
X-SquirrelJME-Depends: meep-midlet gcf io collections
X-SquirrelJME-Error: EB
X-SquirrelJME-DefinedStandards: microedition.lcdui;;
X-SquirrelJME-UUID: bdd52a0a-1d53-4d80-b54d-6ab5316603f9
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/DisplayHardwareState.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui;

/**
 * This represents the state of the display hardware.
 *
 * @since 2017/10/01
 */
public enum DisplayHardwareState
{
	/** Enabled. */
	ENABLED,
	
	/** Disabled. */
	DISABLED,
	
	/** Removed. */
	ABSENT,
	
	/** End. */
	;
	
	/**
	 * Is this forced to be disabled?
	 *
	 * @return If this is forced to be disabled.
	 * @since 2017/10/01
	 */
	public final boolean forceDisabled()
	{
		return this == DISABLED || this == ABSENT;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/DisplayOrientation.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui;

import javax.microedition.lcdui.Display;

/**
 * This is used to determine the orientation of the display.
 *
 * @since 2017/10/27
 */
public enum DisplayOrientation
{
	/** Landscape. */
	LANDSCAPE,
	
	/** Landscape, rotated 180 degrees. */
	LANDSCAPE_180,
	
	/** Portrait. */
	PORTRAIT,
	
	/** Portrait, rotated 180 degrees. */
	PORTRAIT_180,
	
	/** End. */
	;
	
	/**
	 * Returns the value used in the LCDUI code.
	 *
	 * @return The LCDUI value.
	 * @since 2017/10/27
	 */
	public final int lcduiValue()
	{
		switch (this)
		{
			case LANDSCAPE:		return Display.ORIENTATION_LANDSCAPE;
			case LANDSCAPE_180:	return Display.ORIENTATION_LANDSCAPE_180;
			case PORTRAIT:		return Display.ORIENTATION_PORTRAIT;
			case PORTRAIT_180:	return Display.ORIENTATION_PORTRAIT_180;
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/DisplayState.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui;

/**
 * This is the display state used for displays.
 *
 * @since 2017/05/24
 */
public enum DisplayState
{
	/** The background state. */
	BACKGROUND,
	
	/** The foregound state. */
	FOREGROUND,
	
	/** End. */
	;
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/ExtendedCapabilities.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui;

/**
 * Represents extended capabilities of the display.
 *
 * @since 2019/05/05
 */
public interface ExtendedCapabilities
{
	/** Does this support pointer events? */
	public static final int SUPPORTS_POINTER_EVENTS =
		0x4000_0000;
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/SerializedEvent.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation is used to specify that the given method is serialized and
 * will never be called in parallel ever by the LCDUI display driver.
 *
 * @since 2017/08/19
 */
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD})
public @interface SerializedEvent
{
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/CharSequenceDecoder.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * This class is used to decode character sequences so that it is known which
 * parts of characters are what and which codepoints are to be attached to
 * text.
 *
 * @since 2017/10/21
 */
public final class CharSequenceDecoder
{
	/** The sequence to source from. */
	protected final CharSequence sequence;
	
	/** The position to end at. */
	protected final int end;
	
	/** The current marker position. */
	private volatile int _at;
	
	/** The next detail. */
	private volatile DecodedCharacter _next;
	
	/**
	 * Initializes the decoder for the given character sequence.
	 *
	 * @param __s The sequence to decode.
	 * @param __o The offset into the sequence.
	 * @param __l The number of characters to decode.
	 * @throws IndexOutOfBoundsException If the sequence is out of bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/21
	 */
	public CharSequenceDecoder(CharSequence __s, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Must be in bounds
		int sn = __s.length(),
			end = __o + __l;
		if (__o < 0 || __l < 0 || (end > sn))
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		this.sequence = __s;
		this.end = end;
		this._at = __o;
	}
	
	/**
	 * Returns the next codepoint that is at the base of the sequence in
	 * that it is the most important character.
	 *
	 * @return The next codepoint or {@code -1} if there are no more code
	 * points remaining.
	 * @since 2017/10/21
	 */
	public DecodedCharacter next()
	{
		// Peek first always
		peek();
		
		// Has been read already?
		DecodedCharacter rv = this._next;
		if (rv != null)
		{
			this._next = null;
			return rv;
		}
		
		// No more characters left
		return null;
	}
	
	/**
	 * This returns the character which follows the next character.
	 *
	 * @return The character which follows the next character or {@code null}
	 * if there is no next character.
	 * @since 2017/10/24
	 */
	public DecodedCharacter peek()
	{
		// Already peeked?
		DecodedCharacter rv = this._next;
		if (rv != null)
			return rv;
		
		// Detect no more characters
		int at = this._at,
			end = this.end;
		if (at >= end)
			return null;
		
		// Read the next codepoint
		CharSequence sequence = this.sequence;
		int codepoint = sequence.charAt(at);
		this._at = at + 1;
		
		// Build information
		rv = new DecodedCharacter(codepoint);
		this._next = rv;
		return rv;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/CommonColors.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * Common widget colors.
 *
 * @since 2018/12/02
 */
public interface CommonColors
{
	/** Default text color. */
	public static final int DEFAULT_TEXT_COLOR =
		0xFF_000000;
	
	/** Default text background color. */
	public static final int DEFAULT_TEXT_BACKGROUND_COLOR =
		0x00_FFFFFF;
	
	/** Border color. */
	public static final int BORDER =
		0xFF_000000;
	
	/** Background color. */
	public static final int BACKGROUND =
		0xFF_FFFFFF;
	
	/** Foreground color. */
	public static final int FOREGROUND =
		0xFF_000000;
	
	/** Disabled background. */
	public static final int DISABLED_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Disabled foreground. */
	public static final int DISABLED_FOREGROUND =
		0xFF_3C3C3C;
	
	/** Highlighted border. */
	public static final int HIGHLIGHTED_BORDER =
		0xFF_0000FF;
	
	/** Highlighted background. */
	public static final int HIGHLIGHTED_BACKGROUND =
		0xFF_000080;
	
	/** Highlighted foreground. */
	public static final int HIGHLIGHTED_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Disabled Highlighted background. */
	public static final int DISABLED_HIGHLIGHTED_BORDER =
		0xFF_000000;
	
	/** Disabled Highlighted background. */
	public static final int DISABLED_HIGHLIGHTED_BACKGROUND =
		0xFF_3C3C3C;
	
	/** Disabled Highlighted foreground. */
	public static final int DISABLED_HIGHLIGHTED_FOREGROUND =
		0xFF_9C9C9C;
	
	/** Canvas background. */
	public static final int CANVAS_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Command bar background. */
	public static final int COMMANDBAR_BACKGROUND =
		0xFF_000000;
	
	/** Command bar foreground. */
	public static final int COMMANDBAR_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Focused item color. */
	public static final int FOCUSED_COLOR =
		0xFF_FFFF00;
	
	/** Secondary focused item color. */
	public static final int FOCUSED_COLOR_TWO =
		0xFF_FF00FF;
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/CommonMetrics.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * Common widget metrics.
 *
 * @since 2018/12/02
 */
@Deprecated
public interface CommonMetrics
{
	/** Width of the scroll bar. */
	@Deprecated
	public static final int SCROLLBAR_WIDTH =
		8;
	
	/** Command bar height. */
	@Deprecated
	public static final int COMMANDBAR_HEIGHT =
		18;
	
	/** Command bar font size. */
	@Deprecated
	public static final int COMMANDBAR_FONT_SIZE =
		16;
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/DecodedCharacter.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

/**
 * This contains structured information on a character which has been
 * decoded. This is used for font rendering.
 *
 * @since 2017/10/24
 */
public final class DecodedCharacter
{
	/** The primary and visible codepoint. */
	public final int codepoint;
	
	/**
	 * Initializes the decoded character.
	 *
	 * @param __cp The code point of the character.
	 * @since 2017/10/24
	 */
	public DecodedCharacter(int __cp)
	{
		this.codepoint = __cp;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/EditableText.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264








































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.common;

import javax.microedition.lcdui.TextField;

/**
 * This class is used to manage text, it manages the caret position.
 *
 * The maximum size for a text field may never be zero or less than that.
 *
 * All locks are performed on the current object.
 *
 * @see javax.microedition.lcdui.TextBox
 * @see javax.microedition.lcdui.TextEditor
 * @see javax.microedition.lcdui.TextField
 * @since 2017/10/20
 */
public final class EditableText
{
	/** The maximum constraint number. */
	private static final int _MAX_CONSTRAINT =
		TextField.CURRENCY;
	
	/** The valid constraint flag bits. */
	private static final int _VALID_CONSTRAINT_FLAG_BITS =
		TextField.INITIAL_CAPS_SENTENCE | TextField.INITIAL_CAPS_WORD |
		TextField.NON_PREDICTIVE | TextField.PASSWORD |
		TextField.SENSITIVE | TextField.UNEDITABLE;
	
	/** Internal lock for text thread safety. */
	protected final Object lock =
		new Object();
	
	/** The text contained within the field. */
	private final StringBuilder _value =
		new StringBuilder();
	
	/** The maximum length of the text field. */
	private volatile int _maxlength =
		Integer.MAX_VALUE;
	
	/** The current constraints. */
	private volatile int _constraints;
	
	/**
	 * Initializes the text field by setting every parameter at once.
	 *
	 * If the implementation does not support the specified number of
	 * characters then the input string will be truncated and no exception
	 * will be thrown provided the input is still valid.
	 *
	 * @param __t The text to initially set the field to,
	 * see {@link #setString(String)}.
	 * @param __ms The maximum amount of characters in the field,
	 * see {@link #setMaxSize(int)}.
	 * @param __c The constraints of the field,
	 * see {@link #setConstraints(int)}.
	 * @throws IllegalArgumentException If the maximum size is zero or less;
	 * the constraints is not valid; the text is not valid; or the text
	 * exceeds the maximum specified characters.
	 * @since 2017/10/20
	 */
	public void initialize(String __t, int __ms, int __c)
		throws IllegalArgumentException
	{
		// Lock
		synchronized (this.lock)
		{
			// Size and constraints are set first to make sure the string is
			// valid
			int n = setMaxSize(__ms);
			setConstraints(__c);
		
			// Set the string which validates the input
			// However if the constraints are smaller for the implementation
			// then no exception is thrown (just give the truncated string)
			if (__t != null)
				setString((n < __c ? __t.substring(0, n) : __t));
		}
	}
	
	/**
	 * Sets the constraints for this field according to the constraints which
	 * are available. If the current value is not valid under the constraints
	 * to be set then it is cleared.
	 *
	 * @param __c The constraints to set.
	 * @throws IllegalArgumentException If the input constraints are not
	 * valid.
	 * @since 2017/08/20
	 */
	public void setConstraints(int __c)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB01 The specified constraint type is not
		// valid. (The type)}
		int type = (__c & TextField.CONSTRAINT_MASK);
		if (type < 0 || type > _MAX_CONSTRAINT)
			throw new IllegalArgumentException(String.format("EB01 %d", type));
		
		// {@squirreljme.error EB02 The specified constraint flags are not
		// valid. (The constraint flags)}
		if (((__c ^ type) & ~_VALID_CONSTRAINT_FLAG_BITS) != 0)
			throw new IllegalArgumentException(String.format("EB02 %04x",
				__c >>> 16));
		
		// Lock
		synchronized (this.lock)
		{
			// If the new constraints are not valid then any previous text
			// is cleared
			StringBuilder value = this._value;
			if (!__check(value, this._maxlength, __c))
			{
				value.setLength(0);
				return;
			}
			
			// Set
			this._constraints = __c;
		}
	}
	
	/**
	 * Sets the maximum size of the text field, if the value is larger than
	 * this value then it will be truncated.
	 *
	 * @param __ms The number of characters that can be placed in the field.
	 * @return The actual maximum capacity, this may be smaller than the
	 * input value.
	 * @throws IllegalArgumentException If the maximum size is not a non-zero
	 * positive value or if the value would not be valid after truncation if
	 * constraints are used.
	 * @since 2017/08/19
	 */
	public int setMaxSize(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB03 The maximum characters in the text field
		// cannot be zero or negative. (The maximum characters)}
		if (__ms <= 0)
			throw new IllegalArgumentException(String.format("EB03 %d", __ms));
		
		// Lock
		synchronized (this.lock)
		{
			// {@squirreljme.error EB04 Cannot set the maximum size because the
			// input text field would have an invalid value.}
			if (!__check(this._value, __ms, this._constraints))
				throw new IllegalArgumentException("EB04");
		
			// Set, SquirrelJME does not have a fixed limit on the size of text
			// fields
			this._maxlength = __ms;
			return __ms;
		}
	}
	
	/**
	 * Sets the value of the text field.
	 *
	 * @param __s The value to set, if {@code null} then an empty string is
	 * used.
	 * @throws IllegalArgumentException If the input string is not within
	 * the constraints or character count limitations.
	 * @since 2017/08/20
	 */
	public void setString(String __s)
		throws IllegalArgumentException
	{
		// Null becomes empty
		if (__s == null)
			__s = "";
		
		// Lock
		synchronized (this.lock)
		{
			// {@squirreljme.error EB05 Cannot set the specified string
			// because it is not valid within the constraints.}
			if (!__check(__s, this._maxlength, this._constraints))
				throw new IllegalArgumentException("EB05");
			
			// Set value
			StringBuilder value = this._value;
			value.setLength(0);
			value.append(__s);
		}
	}
	
	/**
	 * This checks the given sequence to make sure it is within the
	 * specified constraints.
	 *
	 * @param __cs The sequence to check.
	 * @param __ms The maximum number of characters to check.
	 * @param __c The constraints specifications.
	 * @return Whether or not the data is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/20
	 */
	private static boolean __check(CharSequence __cs, int __ms, int __c)
		throws NullPointerException
	{
		// Check
		if (__cs == null)
			throw new NullPointerException("NARG");
		
		// No constraints used or the input string is empty
		// Empty strings are always valid because otherwise constructing
		// objects would always fail with illegal values
		int type = (__c & TextField.CONSTRAINT_MASK),
			n = __cs.length();
		if (type == TextField.ANY || n == 0)
			return true;
		
		// Depends on the type
		switch (type)
		{
				// Decimal value
			case TextField.CURRENCY:
			case TextField.DECIMAL:
				try
				{
					Double.valueOf(__cs.toString());
					return true;
				}
				catch (NumberFormatException e)
				{
					return false;
				}
				
				// Integer values only
			case TextField.NUMERIC:
				try
				{
					Integer.parseInt(__cs.toString());
					return true;
				}
				catch (NumberFormatException e)
				{
					return false;
				}
				
				// E-mail addresses and URLs allow everything
			case TextField.EMAILADDR:
			case TextField.URL:
				return true;
			
				// Unknown
			default:
				throw new todo.TODO();
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/TextStorage.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.common;

import javax.microedition.lcdui.Font;
import java.util.Arrays;

/**
 * Manages the storage for the text in multiple different arrays at once
 * for simplicity.
 *
 * @since 2018/11/30
 */
public final class TextStorage
{
	/** The number of characters to grow at a time. */
	public static final int GROWTH =
		16;
	
	/** Character storage. */
	public char[] chars =
		new char[0];
	
	/** Font storage. */
	public Font[] font =
		new Font[0];
	
	/** Color storage, zero is use default. */
	public int[] color =
		new int[0];
	
	/** X position. */
	public short[] x =
		new short[0];
	
	/** Y position. */
	public short[] y =
		new short[0];
	
	/** The number of stored characters and their attributes. */
	public int size;
	
	/** The limit of the arrays. */
	public int limit;
	
	/**
	 * Deletes space at the given index.
	 *
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the deletion index is out
	 * of bounds.
	 * @since 2018/12/02
	 */
	public final void delete(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Check bounds
		int size = this.size;
		if (__i < 0 || __i > size || __l < 0 || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Storage areas
		char[] chars = this.chars;
		Font[] font = this.font;
		int[] color = this.color;
		
		// Determine the new size
		int newsize = size - __l;
		
		// Move everything down from the higher point
		for (int o = __i, eo = __i + __l, i = eo; o < eo && i < size;
			o++, i++)
		{
			chars[o] = chars[i];
			font[o] = font[i];
			color[o] = color[i];
		}
		
		// Set new size
		this.size = newsize;
	}
	
	/**
	 * Inserts space to store the given length at the given index.
	 *
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the insertion index is negative
	 * or exceeds the size of the storage, or if the length is negative.
	 * @since 2018/11/30
	 */
	public final void insert(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		int size = this.size;
		if (__i < 0 || __i > size || __l < 0)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Storage areas
		char[] chars = this.chars;
		Font[] font = this.font;
		int[] color = this.color;
		short[] x = this.x;
		short[] y = this.y;
		
		// Need to grow the buffer?
		int newsize = size + __l,
			limit = this.limit;
		if (newsize > limit)
		{
			// Calculate a new limit with some extra room
			int newlimit = newsize + GROWTH;
			
			// Resize all the arrays
			this.chars = (chars = Arrays.copyOf(chars, newlimit));
			this.font = (font = Arrays.<Font>copyOf(font, newlimit));
			this.color = (color = Arrays.copyOf(color, newlimit));
			this.x = (x = Arrays.copyOf(x, newlimit));
			this.y = (y = Arrays.copyOf(y, newlimit));
			
			// Set new limit
			this.limit = (limit = newlimit);
		}
		
		// Move over all the entries to the index to make room for this
		// start from the very right end
		// X and Y are resized but their values are not moved around
		// because the insertion of new elements makes things dirty and
		// all of the X and Y values would be invalidated anyway
		for (int o = newsize - 1, i = size - 1; i >= __i; o--, i--)
		{
			chars[o] = chars[i];
			font[o] = font[i];
			color[o] = color[i];
		}
		
		// Set new size
		this.size = newsize;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/common/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This class contains common implementations of some LCDUI widgets which
 * some will share much of the same code. This eases documentation and has it
 * where less code is duplicated.
 *
 * @since 2017/10/20
 */

package cc.squirreljme.runtime.lcdui.common;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/event/EventTranslate.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
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
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import javax.microedition.lcdui.Canvas;

/**
 * Used to translate key events and such.
 *
 * @since 2018/12/09
 */
public final class EventTranslate
{
	/**
	 * Not used.
	 *
	 * @since 2018/12/09
	 */
	private EventTranslate()
	{
	}
	
	/**
	 * Converts the given game action to a key code.
	 *
	 * @param __gc The game action to convert.
	 * @return The resulting key code or {@code 0} if the game action is not
	 * valid.
	 * @since 2019/04/14
	 */
	public static final int gameActionToKeyCode(int __gc)
	{
		// This performs the reverse of keyCodeToGameAction() except that
		// it maps game keys back to associated number keys.
		// [A ^ B] > [1 2 3]
		// [< F >] > [4 5 6]
		// [C v D] > [7 8 9]
		// [* 0 #] > [* 0 #]
		switch (__gc)
		{
			case Canvas.GAME_A:	return Canvas.KEY_NUM1;
			case Canvas.UP:		return Canvas.KEY_NUM2;
			case Canvas.GAME_B:	return Canvas.KEY_NUM3;
			case Canvas.LEFT:	return Canvas.KEY_NUM4;
			case Canvas.FIRE:	return Canvas.KEY_NUM5;
			case Canvas.RIGHT:	return Canvas.KEY_NUM6;
			case Canvas.GAME_C:	return Canvas.KEY_NUM7;
			case Canvas.DOWN:	return Canvas.KEY_NUM8;
			case Canvas.GAME_D:	return Canvas.KEY_NUM9;
		}
		
		return 0;
	}
	
	/**
	 * Converts the key code to a game action.
	 *
	 * @param __kc The key code.
	 * @return The game action or {@code 0} if it is not valid.
	 * @since 2018/12/09
	 */
	public static final int keyCodeToGameAction(int __kc)
	{
		// Game actions are mapped to physical keys such as left/right/up/down
		// and select. Also since some phones only have a dial pad this means
		// that game actions take up actual digits on the phone itself, so
		// this means we have to map those accordingly.
		// [1 2 3] > [A ^ B]
		// [4 5 6] > [< F >]
		// [7 8 9] > [C v D]
		// [* 0 #] > [* 0 #]
		switch (__kc)
		{
				// Map these to game keys using number pad layout
			case Canvas.KEY_NUM1:	return Canvas.GAME_A;
			case Canvas.KEY_NUM2:	return Canvas.UP;
			case Canvas.KEY_NUM3:	return Canvas.GAME_B;
			case Canvas.KEY_NUM4:	return Canvas.LEFT;
			case Canvas.KEY_NUM5:	return Canvas.FIRE;
			case Canvas.KEY_NUM6:	return Canvas.RIGHT;
			case Canvas.KEY_NUM7:	return Canvas.GAME_C;
			case Canvas.KEY_NUM8:	return Canvas.DOWN;
			case Canvas.KEY_NUM9:	return Canvas.GAME_D;
			
				// Arrow keys map to their direct game keys
			case Canvas.KEY_UP:		return Canvas.UP;
			case Canvas.KEY_DOWN:	return Canvas.DOWN;
			case Canvas.KEY_LEFT:	return Canvas.LEFT;
			case Canvas.KEY_RIGHT:	return Canvas.RIGHT;
			
				// Map space bar and enter to fire
			case ' ':
			case '\n':			return Canvas.FIRE;
			
				// Virtually mapped game keys, likely from a VM running on top
			case NonStandardKey.VGAME_UP:		return Canvas.UP;
			case NonStandardKey.VGAME_DOWN:		return Canvas.DOWN;
			case NonStandardKey.VGAME_LEFT:		return Canvas.LEFT;
			case NonStandardKey.VGAME_RIGHT:	return Canvas.RIGHT;
			case NonStandardKey.VGAME_FIRE:		return Canvas.FIRE;
			case NonStandardKey.VGAME_A:		return Canvas.GAME_A;
			case NonStandardKey.VGAME_B:		return Canvas.GAME_B;
			case NonStandardKey.VGAME_C:		return Canvas.GAME_C;
			case NonStandardKey.VGAME_D:		return Canvas.GAME_D;
			
				// Invalid
			default:
				return 0;
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/event/KeyNames.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
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










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

import javax.microedition.lcdui.Canvas;

/**
 * This is used to translate key codes into key names.
 *
 * @since 2017/02/12
 */
public final class KeyNames
{
	/**
	 * Not used.
	 *
	 * @since 2017/02/12
	 */
	private KeyNames()
	{
	}
	
	/**
	 * Returns the name of the given key.
	 *
	 * @param __c The keycode to get the name for.
	 * @return The name of the key.
	 * @throws IllegalArgumentException If the key is not valid.
	 * @since 2017/02/12
	 */
	public static String getKeyName(int __c)
		throws IllegalArgumentException
	{
		switch (__c)
		{
				// Unknown
			case NonStandardKey.UNKNOWN:	return "Unknown";
			
				// More friendly names
			case Canvas.KEY_BACKSPACE:		return "Backspace";
			case Canvas.KEY_DELETE:			return "Delete";
			case Canvas.KEY_DOWN:			return "Down";
			case Canvas.KEY_ENTER:			return "Enter";
			case Canvas.KEY_ESCAPE:			return "Escape";
			case Canvas.KEY_LEFT:			return "Left";
			case Canvas.KEY_RIGHT:			return "Right";
			case Canvas.KEY_SELECT:			return "Select";
			case Canvas.KEY_SPACE:			return "Space";
			case Canvas.KEY_TAB:			return "Tab";
			case Canvas.KEY_UP:				return "Up";
			
				// Dial keys
			case Canvas.KEY_STAR:			return "Star";
			case Canvas.KEY_POUND:			return "Pound";
			
				// Other keys
			case NonStandardKey.ALT:		return "Alt";
			case NonStandardKey.CAPSLOCK:	return "CapsLock";
			case NonStandardKey.CONTEXT_MENU:	return "ContextMenu";
			case NonStandardKey.CONTROL:	return "Control";
			case NonStandardKey.END:		return "End";
			case NonStandardKey.HOME:		return "Home";
			case NonStandardKey.INSERT:		return "Insert";
			case NonStandardKey.LOGO:		return "Logo";
			case NonStandardKey.META:		return "Meta";
			case NonStandardKey.NUMLOCK:	return "NumLock";
			case NonStandardKey.PAGE_UP:	return "PageUp";
			case NonStandardKey.PAGE_DOWN:	return "PageDown";
			case NonStandardKey.PAUSE:		return "Pause";
			case NonStandardKey.PRINTSCREEN:return "PrintScreen";
			case NonStandardKey.SCROLLLOCK:	return "ScrollLock";
			case NonStandardKey.SHIFT:		return "Shift";
			
				// Non-standard game keys (used by the VM perhaps)
			case NonStandardKey.VGAME_UP:	return "VirtualGameUp";
			case NonStandardKey.VGAME_DOWN:	return "VirtualGameDown";
			case NonStandardKey.VGAME_LEFT:	return "VirtualGameLeft";
			case NonStandardKey.VGAME_RIGHT:return "VirtualGameRight";
			case NonStandardKey.VGAME_FIRE:	return "VirtualGameFire";
			case NonStandardKey.VGAME_A:	return "VirtualGameA";
			case NonStandardKey.VGAME_B:	return "VirtualGameB";
			case NonStandardKey.VGAME_C:	return "VirtualGameC";
			case NonStandardKey.VGAME_D:	return "VirtualGameD";
			
				// Default character or unknown
			default:
				// These are purely valid characters
				if (__c > 0)
					return Character.valueOf((char)__c).toString();
				
				// {@squirreljme.error EB06 Cannot get the name for the given
				// key code because it is not known. (The key code)}
				throw new IllegalArgumentException(String.format("EB06 %d",
					__c));
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/event/NonStandardKey.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
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




































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.event;

/**
 * This byteerface contains identifiers for non-standard keys.
 *
 * @since 2017/02/12
 */
public interface NonStandardKey
{
	/** Unknown, zero is the invalid index so always make it known. */
	public static final byte UNKNOWN =
		0;
	
	/** Game Up. */
	public static final byte VGAME_UP =
		-9;
	
	/** Game Down. */
	public static final byte VGAME_DOWN =
		-10;
	
	/** Game Left. */
	public static final byte VGAME_LEFT =
		-11;
	
	/** Game Right. */
	public static final byte VGAME_RIGHT =
		-12;
	
	/** Game fire. */
	public static final byte VGAME_FIRE =
		-13;
	
	/** Game A. */
	public static final byte VGAME_A =
		-14;
	
	/** Game B. */
	public static final byte VGAME_B =
		-15;
	
	/** Game C. */
	public static final byte VGAME_C =
		-16;
	
	/** Game D. */
	public static final byte VGAME_D =
		-17;
	
	/** Shift. */
	public static final byte SHIFT =
		-18;
	
	/** Control. */
	public static final byte CONTROL =
		-19;
	
	/** Alt. */
	public static final byte ALT =
		-20;
	
	/** Logo. */
	public static final byte LOGO =
		-21;
	
	/** Caps lock. */
	public static final byte CAPSLOCK =
		-22;
	
	/** Context menu. */
	public static final byte CONTEXT_MENU =
		-23;
	
	/** Home. */
	public static final byte HOME =
		-24;
	
	/** End. */
	public static final byte END =
		-25;
	
	/** Page Up. */
	public static final byte PAGE_UP =
		-26;
	
	/** Page Down. */
	public static final byte PAGE_DOWN =
		-27;
	
	/** Meta. */
	public static final byte META =
		-28;
	
	/** Numlock. */
	public static final byte NUMLOCK =
		-29;
	
	/** Pause. */
	public static final byte PAUSE =
		-30;
	
	/** Print Screen. */
	public static final byte PRINTSCREEN =
		-31;
	
	/** Scroll lock. */
	public static final byte SCROLLLOCK =
		-32;
	
	/** Insert. */
	public static final byte INSERT =
		-33;
	
	/** F24. */
	public static final byte F24 =
		-34;
	
	/** F1. */
	public static final byte F1 =
		F24 - 24;
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/event/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains anything related to event handling for LCDUI.
 *
 * @since 2017/08/19
 */

package cc.squirreljme.runtime.lcdui.event;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/fbui/DrawingCanvas.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.Canvas;

/**
 * This is a drawing of a canvas.
 *
 * @since 2020/01/18
 */
public class DrawingCanvas
	extends UIDrawerState
{
	/** The canvas to draw. */
	protected final Canvas canvas;
	
	/**
	 * Initializes the drawer.
	 *
	 * @param __c The canvas to draw.
	 * @since 2020/01/18
	 */
	public DrawingCanvas(Canvas __c)
	{
		super(__c);
		
		this.canvas = __c;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/fbui/DrawingList.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.List;

/**
 * This is the drawing of a list.
 *
 * @since 2020/01/18
 */
public class DrawingList
	extends UIDrawerState
{
	/** The list to draw. */
	protected final List list;
	
	/**
	 * Initializes the drawer.
	 *
	 * @param __l The list to draw.
	 * @since 2020/01/18
	 */
	public DrawingList(List __l)
	{
		super(__l);
		
		this.list = __l;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/fbui/UIDrawerState.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.fbui;

import javax.microedition.lcdui.Displayable;

/**
 * This contains the state of a drawer.
 *
 * @since 2020/01/15
 */
public abstract class UIDrawerState
{
	/** The displayable to be drawn/interacted with. */
	protected final Displayable displayable;
	
	/**
	 * Initializes the drawer state.
	 *
	 * @param __d The displayable to draw.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public UIDrawerState(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this.displayable = __d;
	}
	
	/**
	 * Returns the content height of this state.
	 *
	 * @return The content height.
	 * @since 2020/01/15
	 */
	public final int contentHeight()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the content width of this state.
	 *
	 * @return The content width.
	 * @since 2020/01/15
	 */
	public final int contentWidth()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/fbui/UIState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315



























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.fbui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.IPCCallback;
import cc.squirreljme.jvm.IPCManager;
import cc.squirreljme.jvm.SystemCallIndex;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

/**
 * This class contains the state of the user interface. It may call the native
 * frame buffer system calls to perform updates or otherwise.
 *
 * @since 2020/01/12
 */
public final class UIState
	implements IPCCallback
{
	/** User interface state. */
	private static UIState _UI_STATE;
	
	/** Get capabilities of the display. */
	protected final int capabilities;
	
	/** The format of the framebuffer. */
	protected final byte format;
	
	/** Is native IPC used for the framebuffer? */
	protected final boolean useipc;
	
	/** Has screen flipping capability. */
	protected final boolean canflip;
	
	/** Is this a color screen? */
	protected final boolean iscolor;
	
	/** The currently bound display. */
	protected Display display;
	
	/** The current drawable state. */
	protected UIDrawerState drawerstate;
	
	/**
	 * Only internally initialized.
	 *
	 * @since 2020/01/12
	 */
	private UIState()
	{
		// Get display format
		this.format = (byte)Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_FORMAT);
		
		// Get display capabilities
		int capabilities = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_GET_CAPABILITIES);
		this.capabilities = capabilities;
		
		// Quick capability setting
		this.useipc =
			((capabilities & Framebuffer.CAPABILITY_IPC_EVENTS) != 0);
		this.canflip = 
			((capabilities & Framebuffer.CAPABILITY_SCREEN_FLIP) != 0);
		this.iscolor =
			((capabilities & Framebuffer.CAPABILITY_COLOR) != 0);
		
		// Register callback for the UI so we get events and such
		// Note that even if we do event handling in this program because the
		// JVM does not have one, we still register for other portions using
		// them
		IPCManager.register(Framebuffer.IPC_ID, this);
	}
	
	/**
	 * Binds this display to the current state.
	 *
	 * @param __d The display to bind.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/12
	 */
	public final void bindDisplay(Display __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		this.display = __d;
	}
	
	/**
	 * Returns the capabilities of the framebuffer.
	 *
	 * @return The framebuffer capabilities.
	 * @since 2020/01/15
	 */
	public final int capabilities()
	{
		return this.capabilities;
	}
	
	/**
	 * Is the display currently flipped?
	 *
	 * @return If the display is flipped.
	 * @since 2020/01/15
	 */
	public final boolean displayFlipped()
	{
		// If the display cannot be flipped, this always returns false
		if (!this.canflip)
			return false;
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current display height.
	 *
	 * @return The display height.
	 * @since 2020/01/15
	 */
	public final int displayHeight()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this a color display?
	 *
	 * @return If this is a color display.
	 * @since 2020/01/15
	 */
	public final boolean displayIsColor()
	{
		return this.iscolor;
	}
	
	/**
	 * Returns the number of unique colors.
	 *
	 * @return The number of unique colors.
	 * @since 2020/01/15
	 */
	public final int displayUniqueColors()
	{
		int format = this.format;
		switch (format)
		{
			case Framebuffer.FORMAT_INTEGER_RGB888:	return 16777216;
			case Framebuffer.FORMAT_BYTE_INDEXED:	return 256;
			case Framebuffer.FORMAT_SHORT_RGB565:	return 66560;
			case Framebuffer.FORMAT_PACKED_ONE:		return 2;
			case Framebuffer.FORMAT_PACKED_TWO:		return 4;
			case Framebuffer.FORMAT_PACKED_FOUR:	return 16;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the current display width.
	 *
	 * @return The display width.
	 * @since 2020/01/15
	 */
	public final int displayWidth()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current drawer state.
	 *
	 * @return The current drawer state.
	 * @since 2020/01/15
	 */
	public final UIDrawerState drawerState()
	{
		return this.drawerstate;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Requests that the display be repainted.
	 *
	 * @since 2020/01/15
	 */
	public final void repaint()
	{
		this.repaint(0, 0, this.displayWidth(), this.displayHeight());
	}
	
	/**
	 * Requests that the display be repainted.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2020/01/15
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		if (this.useipc)
			Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
				Framebuffer.CONTROL_REPAINT_REQUEST,
				__x, __y, __w, __h);
		
		// IPC not supported, so we manage our own event queue and such
		else
			throw new todo.TODO();
	}
	
	/**
	 * Sets the displayable to be drawn.
	 *
	 * @param __d The displayable to draw.
	 * @return The new drawing state.
	 * @since 2020/01/15
	 */
	public final UIDrawerState setDisplayable(Displayable __d)
	{
		UIDrawerState rv;
		
		// Nothing
		if (__d == null)
			rv = null;
			
		// List
		else if (__d instanceof List)
			rv = new DrawingList((List)__d);
		
		// Canvas
		else if (__d instanceof Canvas)
			rv = new DrawingCanvas((Canvas)__d);
		
		// Unknown
		else
			throw new todo.OOPS(__d.getClass().getName());
		
		// Set state and return
		this.drawerstate = rv;
		return rv;
	}
	
	/**
	 * Sets the system title.
	 *
	 * @param __s The title to set.
	 * @since 2020/01/15
	 */
	public final void setTitle(String __s)
	{
		char[] chars = (__s == null ? "SquirrelJME" : __s).toCharArray();
		
		// Tell the framebuffer to set the title as needed
		Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_SET_TITLE, Assembly.objectToPointer(chars));
		
		// Touch
		if (chars.length > 0)
			chars[0] = chars[0];
	}
	
	/**
	 * Returns the instance of the user interface state.
	 *
	 * @return The instance of the user interface state.
	 * @since 2020/01/12
	 */
	public static final UIState getInstance()
	{
		UIState rv = UIState._UI_STATE;
		if (rv != null)
			return rv;
		
		// We may need to create an instance
		synchronized (UIState.class)
		{
			// Try again
			rv = UIState._UI_STATE;
			if (rv != null)
				return rv;
			
			// Initialize new state
			UIState._UI_STATE = (rv = new UIState());
			
			return rv;
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/fbui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This contains the Framebuffer UI engine.
 *
 * @since 2020/01/12
 */

package cc.squirreljme.runtime.lcdui.fbui;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/FontSizeConversion.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

import javax.microedition.lcdui.Font;

/**
 * This class provides static methods for the conversion of font sizes from
 * pixel sizes to logical sizes.
 *
 * @since 2018/11/24
 */
public final class FontSizeConversion
{
	/**
	 * Not used.
	 *
	 * @since 2018/11/24
	 */
	private FontSizeConversion()
	{
	}
	
	/**
	 * Converts the logical font size to pixel size.
	 *
	 * @param __lsz The logical font size.
	 * @return The pixel size.
	 * @throws IllegalArgumentException If the logical font size is not valid.
	 * @since 2018/11/24
	 */
	public static final int logicalSizeToPixelSize(int __lsz)
		throws IllegalArgumentException
	{
		switch (__lsz)
		{
			case Font.SIZE_SMALL:
				return 8;
			
			case Font.SIZE_MEDIUM:
				return 12;
			
			case Font.SIZE_LARGE:
				return 16;
			
				// {@squirreljme.error EB07 Invalid logical font size.}
			default:
				throw new IllegalArgumentException("EB07");
		}
	}
	
	/**
	 * Converts the pixel size to a logical font size.
	 *
	 * @param __psz The pixel font size.
	 * @return The logical size.
	 * @since 2018/11/24
	 */
	public static final int pixelSizeToLogicalSize(int __psz)
	{
		if (__psz < 10)
			return Font.SIZE_SMALL;
		else if (__psz < 14)
			return Font.SIZE_MEDIUM;
		return Font.SIZE_LARGE;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/SQFFont.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436




















































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.lcdui.Font;

/**
 * This represents a SQF Font (SquirrelJME Font) which is a compacted and
 * simplified font representation that is made to be as simple as possible by
 * having the desired goals: small, low memory, easy to load.
 *
 * All fonts are ISO-8859-15, same sized cells for each characters although
 * their width can differ.
 *
 * The font is in the following format:
 *  - int8 pixelheight.
 *  - int8 ascent.
 *  - int8 descent.
 *  - int8 bytesperscan (The number of bytes per scanline).
 *  - int8[256] charwidths.
 *  - int8[256] isvalidchar.
 *  - uint[256 * bytesperscan * pixelheight] charbmp.
 *
 * @since 2018/11/27
 */
public final class SQFFont
{
	/** SQF Font data. */
	private static final Map<SQFFontSpecifier, SQFFont> _FONT_CACHE =
		new HashMap<>();
	
	/** The pixel height of the font. */
	public final byte pixelheight;
	
	/** The ascent of the font. */
	public final byte ascent;
	
	/** The maximum ascent of the font. */
	public final byte maxascent;
	
	/** The descent of the font. */
	public final byte descent;
	
	/** The bytes per scan. */
	public final byte bytesperscan;
	
	/** The bits per scan. */
	public final byte bitsperscan;
	
	/** The number of bytes that make up a character's bitmap. */
	public final int charbitmapsize;
	
	/**
	 * The leading of the font.
	 * It is unspecified what this value actually should be so for now it is
	 * just a constant.
	 */
	public final byte leading =
		2;
	
	/** Is this character valid? */
	private final boolean[] _isvalidchar;
	
	/** The character widths. */
	private final byte[] _charwidths;
	
	/** The character bitmap. */
	private final byte[] _charbmp;
	
	/**
	 * Initializes the SQF Font.
	 *
	 * @param __ph The pixel height.
	 * @param __a The ascent.
	 * @param __d The descent.
	 * @param __bps The bytes per scan.
	 * @param __cw Character widths.
	 * @param __ivc Is this a valid character?
	 * @param __bmp The bitmap data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	private SQFFont(byte __ph, byte __a, byte __d, byte __bps, byte[] __cw,
		boolean[] __ivc, byte[] __bmp)
		throws NullPointerException
	{
		if (__cw == null || __ivc == null || __bmp == null)
			throw new NullPointerException("NARG");
		
		this.pixelheight = __ph;
		this.ascent = __a;
		this.descent = __d;
		this.bytesperscan = __bps;
		this.bitsperscan = (byte)(__bps * 8);
		this._charwidths = __cw;
		this._isvalidchar = __ivc;
		this._charbmp = __bmp;
		this.charbitmapsize = __bps * __ph;
		
		// The maximum ascent is just the ascent since all SQFs have the
		// same properties
		this.maxascent = __a;
	}
	
	/**
	 * Returns the number of bytes each character requires to store its
	 * bitmap data.
	 *
	 * @return The character bitmap size.
	 * @since 2018/12/01
	 */
	public final int charBitmapSize()
	{
		return this.charbitmapsize;
	}
	
	/**
	 * Returns the width of the specified character.
	 *
	 * @param __c The character to get the width of.
	 * @return The width of the given character.
	 * @since 2018/11/30
	 */
	public final int charWidth(char __c)
	{
		byte[] charwidths = this._charwidths;
		if (__c > 256 || !this._isvalidchar[__c])
			return charwidths[0];
		return charwidths[__c];
	}
	
	/**
	 * Is the specified character valid?
	 *
	 * @param __c The character to check.
	 * @return If the character is valid.
	 * @since 2019/06/16
	 */
	public final boolean isValid(char __c)
	{
		if (__c > 256)
			return false;
		return this._isvalidchar[__c];
	}
	
	/**
	 * Loads the bitmap
	 *
	 * @param __c The character to get.
	 * @param __bmp The output bitmap.
	 * @return The bytes per scanline.
	 * @throws IndexOutOfBoundsException If the bitmap is out of bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public final int loadCharBitmap(char __c, byte[] __bmp)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Illegal character? Use the replacement
		if (__c > 256 || !this._isvalidchar[__c])
			__c = 0;
		
		// Need to know this to copy each scanline of the font
		int charbitmapsize = this.charbitmapsize;
		
		// Copy bitmap data
		byte[] charbmp = this._charbmp;
		for (int o = 0, i = __c * charbitmapsize; o < charbitmapsize; o++, i++)
			__bmp[o] = charbmp[i];
		
		// Return the bytes per scan
		return this.bytesperscan;
	}
	
	/**
	 * Prints the glyph data to the given stream.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public final void printGlyphs(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		int pixelheight = this.pixelheight,
			bytesperscan = this.bytesperscan,
			bitsperscan = this.bitsperscan;
		
		// Setup string builders to handle each line
		int pipecount = 0;
		StringBuilder[] sb = new StringBuilder[pixelheight + 1];
		for (int i = 0; i < pixelheight + 1; i++)
			sb[i] = new StringBuilder();
		
		// Print each character
		byte[] charwidths = this._charwidths,
			charbmp = this._charbmp;
		boolean[] isvalidchar = this._isvalidchar;
		for (int ch = 0; ch < 256; ch++)
		{
			// Ignore unspecified characters
			if (!isvalidchar[ch])
				continue;
			
			int charwidth = (int)charwidths[ch],
				gapw = charwidth + 1;
			
			// Force font to single character
			if (charwidth < 1)
				charwidth = 1;
			
			// Put description line
			sb[0].append(String.format(
				"%-" + charwidth + "." + charwidth + "s",
				String.format("%02x,%d", ch, charwidth)));
			sb[0].append('|');
			
			// Draw each line
			for (int y = 0; y < pixelheight; y++)
			{
				int p = (ch * bytesperscan * pixelheight) +
					(y * bytesperscan);
				
				// Draw each column into the buffers
				for (int x = 0; x < charwidth; x++)
					sb[y + 1].append(
						(((charbmp[p + (x >>> 3)] & (1 << (x & 0x7))) != 0) ?
						'#' : '.'));
				
				// End in pipe
				sb[y + 1].append('|');
			}
			
			// Draw string builders and clear
			pipecount += (charwidth + 1);
			if (pipecount >= 70)
			{
				// Clear out
				for (int i = 0, n = sb.length; i < n; i++)
				{
					__ps.println(sb[i]);
					sb[i].setLength(0);
				}
				
				// Reset for next time
				pipecount = 0;
			}
		}
		
		// Clear out
		if (pipecount > 0)
		{
			for (int i = 0, n = sb.length; i < n; i++)
				__ps.println(sb[i]);
		}
	}
	
	/**
	 * Caches the SQF font.
	 *
	 * @param __n The name of the font.
	 * @param __pxs The pixel size of the font.
	 * @return The font.
	 * @throws IllegalArgumentException If the font does not exist or is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public static final SQFFont cacheFont(String __n, int __pxs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");	
		
		// Build specifier
		SQFFontSpecifier spec = new SQFFontSpecifier(__n, __pxs);
		
		Map<SQFFontSpecifier, SQFFont> cache = _FONT_CACHE;
		synchronized (cache)
		{
			// Already cached?
			SQFFont rv = cache.get(spec);
			if (rv != null)
				return rv;
			
			// Read the SQF Font
			try (InputStream in = SQFFont.class.getResourceAsStream(
				spec.toFileName()))
			{
				// {@squirreljme.error EB08 The font does not exist.
				// (The name; The pixel size)}
				if (in == null)
					throw new IllegalArgumentException(
						String.format("EB08 %s %d", __n, __pxs));
				
				// Read font data
				rv = SQFFont.read(in);
				
				// Cache the data
				cache.put(spec, rv);
			}
			
			// {@squirreljme.error EB09 Could not load the font data.
			// (The name; The pixel size)}
			catch (IOException e)
			{
				throw new IllegalArgumentException(
					String.format("EB09 %s %d", __n, __pxs), e);
			}
			
			// Use it!
			return rv;
		}
	}
	
	/**
	 * Caches the SQF font based on the passed font object.
	 *
	 * @param __f The font to cache.
	 * @return The SQF data for this font.
	 * @throws IllegalArgumentException If the font does not exist or is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public static final SQFFont cacheFont(Font __f)
		throws IllegalArgumentException, NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return SQFFont.cacheFont(__f.getFontName(), __f.getPixelSize());
	}
	
	/**
	 * Reads and returns a SQF Font.
	 *
	 * @param __in The input stream data.
	 * @return The decoded SQF Font.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final SQFFont read(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Makes it easier to handle things
		DataInputStream dis = new DataInputStream(__in);
		
		// Read fields
		byte pixelheight = dis.readByte(),
			ascent = dis.readByte(),
			descent = dis.readByte(),
			bytesperscan = dis.readByte();
		
		// Read the widths
		byte[] charwidths = new byte[256];
		dis.readFully(charwidths);
		
		// Valid characters?
		boolean[] isvalidchar = new boolean[256];
		for (int i = 0; i < 256; i++)
			if (dis.readByte() != 0)
				isvalidchar[i] = true;
		
		// Read the bitmaps
		byte[] charbmp = new byte[256 * bytesperscan * pixelheight];
		dis.readFully(charbmp);
		
		// Build font
		return new SQFFont(pixelheight, ascent, descent, bytesperscan,
			charwidths, isvalidchar, charbmp);
	}
	
	/**
	 * This maps the given character to the SQF character map.
	 *
	 * Since SQFs are ISO-8859-15, they do not map exactly to ISO-8859-1
	 * which may be the default encoding.
	 *
	 * @param __c The character to map.
	 * @return The mapped character.
	 * @since 2019/04/29
	 */
	public static final char mapChar(char __c)
	{
		switch (__c)
		{
				// Convert
			case 0x20AC:	return (char)0x00A4;
			case 0x0160:	return (char)0x00A6;
			case 0x0161:	return (char)0x00A8;
			case 0x017D:	return (char)0x00B4;
			case 0x017E:	return (char)0x00B8;
			case 0x0152:	return (char)0x00BC;
			case 0x0153:	return (char)0x00BD;
			case 0x0178:	return (char)0x00BE;
			
				// Map similar characters to others
			case 0x00A4:	return (char)0x20AC;
			case 0x00B4:	return '\'';
			case 0x00A6:	return '|';
			case 0x00A8:	return '"';
				
				// Cannot be mapped
			case 0x00B8:
			case 0x00BC:
			case 0x00BD:
			case 0x00BE:	return (char)0xFFFD;
		}
		
		// Mapped the same
		return __c;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/SQFFontSpecifier.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.font;

/**
 * Specifier for SQF Fonts.
 *
 * @since 2018/12/01
 */
public final class SQFFontSpecifier
	implements Comparable<SQFFontSpecifier>
{
	/** The name of the font. */
	protected final String name;
	
	/** The pixel size of the font. */
	protected final int pixelsize;
	
	/** The hashcode cache. */
	private final int _hashcode;
	
	/**
	 * Initializes the font specifier.
	 *
	 * @param __name The font name.
	 * @param __pxs The pixel size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public SQFFontSpecifier(String __name, int __pxs)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.pixelsize = __pxs;
		this._hashcode = __name.hashCode() ^ __pxs;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final int compareTo(SQFFontSpecifier __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.pixelsize - __o.pixelsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof SQFFontSpecifier))
			return false;
		
		// Different hashcodes will never compare ever
		SQFFontSpecifier o = (SQFFontSpecifier)__o;
		if (this._hashcode != o._hashcode)
			return false;
		
		return this.pixelsize == o.pixelsize &&
			this.name.equals(o.name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public final int hashCode()
	{
		return this._hashcode;
	}
	
	/**
	 * Returns the file name of the font.
	 *
	 * @return The filename.
	 * @since 2018/12/01
	 */
	public final String toFileName()
	{
		return String.format("%s-%d.sqf", this.name, this.pixelsize);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/monospace-12.sqf.__mime.

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 monospace-12.sqf
DAkDAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAQEBAQEBAAEAAAACgoAAAAAAAAAAAAACgofCgoKHwoK
AAAABA4VBQ4UFBUOBAAAEhUKCAQCChUJAAAADBIBAQIFFQkeAAAABAQAAAAA
AAAAAAAADAICAgICAgIMAAAABggICAgICAgGAAAAFQ4fDhUAAAAAAAAAAAAA
BAQfBAQAAAAAAAAAAAAAAAAMCAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAMAAAA
ABAQCAgEBAICAAAADhERFRUVEREOAAAABwQEBAQEBAQfAAAADhEQCAQCAQEf
AAAADhEQEA4QEBEOAAAAERERER8QEBAQAAAAHwEBDxAQEBEOAAAAHgEBAQ8R
EREOAAAAHxAQCAgEBAICAAAADhEREQ4REREOAAAADhERER4QEBAQAAAAAAAA
DAwAAAAMDAAAAAAADAwAAAAMCAAAABAIBAIECBAAAAAAAAAAAA4ADgAAAAAA
AAIECBAIBAIAAAAADhEQEAgEBAAEAAAADhEVFRUVHQEeAAAADhERER8RERER
AAAADxEREQ8REREPAAAAHgEBAQEBAQEeAAAADxEREREREREPAAAAHwEBAQcB
AQEfAAAAHwEBAQcBAQEBAAAAHgEBAR0REREOAAAAERERER8RERERAAAAHAgI
CAgICAgcAAAAEBAQEBAQEREOAAAAEREJBQMFCRERAAAAAQEBAQEBAQEfAAAA
GxUVERERERERAAAAERMTFRUVGRkRAAAADhEREREREREOAAAADxEREQ8BAQEB
AAAADhERERERFQkWAAAADxEREQ8JERERAAAADhEBAQ4QEBEOAAAAHwQEBAQE
BAQEAAAAEREREREREREOAAAAEREREREREhQYAAAAEREREREVFRUKAAAAEREK
BAQKERERAAAAERERCgQEBAQEAAAAHxAQCAQCAQEfAAAADgICAgICAgIOAAAA
AAEBAgIEBAgIAAAADggICAgICAgOAAAABAoRAAAAAAAAAAAAAAAAAAAAAAAf
AAAABAgAAAAAAAAAAAAAAAAAAA4REREuAAAAAQEBAQ8REREPAAAAAAAAABwC
AgIcAAAAEBAQEB4REREeAAAAAAAAAA4RDwEeAAAAABgEBA4EBAQEAAAAAAAA
AB4REREeEA8AAAEBAQ8RERERAAAAAAAEAAQEBAQEAAAAAAAIAAgICAgIBAAA
AAEBEREPERERAAAAAAQEBAQEBAQEAAAAAAAAAA8VFRUVAAAAAAAAAA8RERER
AAAAAAAAAA4REREOAAAAAAAAAA8REREPAQEAAAAAAB4REREeEBAAAAAAABwC
AgICAAAAAAAAAB4BDhAPAAAAAAAEBA4EBAQYAAAAAAAAABEREREOAAAAAAAA
ABEREhQYAAAAAAAAABERFRUKAAAAAAAAABEKBAoRAAAAAAAAABERER4QEA8A
AAAAAB8IBAIfAAAACAQEBAIEBAQIAAAACAgICAgICAgIAAAAAgQEBAgEBAQC
AAAAABYJAAAAAAAAAAAADB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAIAAgICAgICAgAAAAACBwKCgocCAAAGAQE
BA4EBAQeAAAADBICDwIPAhIMAAAAEREKBAQOBA4EAAAACgQeAQEOEBAPAAAA
HgEDDREWGBAPAAAACgQAABwCDBAOAAAADhEdExMTHREOAAAABAoKFAAeAAAA
AAAAACgUCgUKFCgAAAAAAAAAAB4QAAAAAAAAAAAAAA4AAAAAAAAAHiEnKycr
KyEeAAAAHgAAAAAAAAAAAAAACBQIAAAAAAAAAAAAAAAEBB8EBB8AAAAAHBAc
BBwAAAAAAAAAHBAYEBwAAAAAAAAACgQfEAgEAgEfAAAAAAAAAAAREREPAQEA
FhcXFhQUFBQUAAAAAAAAAAwMAAAAAAAACgQAAB4QDAIeAAAADAgIHAAAAAAA
AAAACBQIABwAAAAAAAAAAAUKFCgUCgUAAAAAHgUFBQ0FBQUeAAAAAAAAABoV
DQUaAAAAChEREQoEBAQEAAAAAAAEAAQEAgEREQ4AAgQADhERHxERAAAACAQA
DhERHxERAAAABAoADhERHxERAAAAFgkADhERHxERAAAACgAADhERHxERAAAA
BAoEDhERHxERAAAAHgUFBQ8FBQUdAAAAAB4BAQEBAQEeBAYAAgQAHgIOAgIe
AAAABAIAHgIOAgIeAAAABAoAHgIOAgIeAAAACgAAHgIOAgIeAAAAAgQABAQE
BAQEAAAACAQABAQEBAQEAAAABAoABAQEBAQEAAAACgAABAQEBAQEAAAADhIS
EhcSEhIOAAAAFgkAExMVFRkZAAAAAgQADhEREREOAAAACAQADhEREREOAAAA
BAoADhEREREOAAAAFgkADhEREREOAAAACgAADhEREREOAAAAAAAAEQoEChEA
AAAADhkZFRUVExMOAAAAAgQAEREREREOAAAACAQAEREREREOAAAABAoAERER
EREOAAAACgAAEREREREOAAAACAQAEREKBAQEAAAAAQEPERERDwEBAAAADhER
CQUJERENAAAAAAIEAA4REREuAAAAAAgEAA4REREuAAAAAAQKAA4REREuAAAA
ABYJAA4REREuAAAAAAAKAA4REREuAAAABAoEAA4REREuAAAAAAAAAAsUDgUa
AAAAAAAAAB4BAQEeBAYAAAQIABwSDgIcAAAAABAIABwSDgIcAAAAAAgUABwS
DgIcAAAAAAAUABwSDgIcAAAAAAACBAAEBAQEAAAAAAAIBAAEBAQEAAAAAAAE
CgAEBAQEAAAAAAAACgAEBAQEAAAAAAAYBwoREREOAAAAAAAWCQAPERERAAAA
AAAECAAMEhIMAAAAAAAIBAAMEhIMAAAAAAAECgAMEhIMAAAAAAAUCgAMEhIM
AAAAAAAAFAAMEhIMAAAAAAAABAAOAAQAAAAAAAAAAA4ZFRMOAAAAAAACBAAR
EREOAAAAAAAIBAAREREOAAAAAAAECgAREREOAAAAAAAACgAREREOAAAAAAAI
BAAREREeEA8AAAABAQ8REREPAQEAAAAACgAREREeEA8A
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/monospace-16.sqf.__mime.

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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 monospace-16.sqf
EA0DAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAIHDZrb293fzYcCAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAICAgICAgIAAAIAAAAAAAAZmZEAAAAAAAAAAAAAAAAAAAA
JCR+JCQkfiQkAAAAAAg+SQkJCT5ISEk+CAAAAAAAAABDIxAIBGJhAAAAAAAA
AAAAHiEBAgRKUSFeAAAAAAAICAAAAAAAAAAAAAAAAAAAIBAIBAQEBAQIECAA
AAAAAAQIECAgICAgEAgEAAAAAAAqHD4cKgAAAAAAAAAAAAAAAAAAAAgIPggI
AAAAAAAAAAAAAAAAAAAAABAQCAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAA
AAAAGBgAAAAAAEBAICAQEAgIBAQCAAAAAAA+QUFBSUlJQUFBPgAAAAAADwgI
CAgICAgICH8AAAAAAH9AQEBAfwEBAQF/AAAAAAB/QEBAQHxAQEBAfwAAAAAA
QUFBQUF/QEBAQEAAAAAAAH8BAQEBf0BAQEB/AAAAAAB/AQEBAX9BQUFBfwAA
AAAAf0BAQEBAQEBAQEAAAAAAAH9BQUFBf0FBQUF/AAAAAAB/QUFBQX9AQEBA
QAAAAAAAAAAAGBgAAAAAGBgAAAAAAAAAABgYAAAAABgYEAAAAAAgEAgEAgQI
ECAAAAAAAAAAAAAAAAA+AD4AAAAAAAAAAAIECBAgEAgEAgAAAAAAAAA8QkBA
OAgICAAIAAAAAAAAfkFdVVVVVVV9AX4AAAAAAD5BQUFBf0FBQUFBAAAAAAAf
IUFBQT9BQUFBPwAAAAAAPkFBAQEBAQEBQT4AAAAAAB8hQUFBQUFBQUE/AAAA
AAB/AQEBAQ8BAQEBfwAAAAAAfwEBAQEPAQEBAQEAAAAAAD5BAQEBAXlBQUE+
AAAAAABBQUFBQX9BQUFBQQAAAAAAfwgICAgICAgICH8AAAAAAEBAQEBAQEBB
QSIcAAAAAABBIREJBQMFCREhQQAAAAAAAQEBAQEBAQEBAX8AAAAAAEFjY1VV
SUlBQUFBAAAAAABBQ0NFRUlJUVFhYQAAAAAAHCJBQUFBQUFBIhwAAAAAAB8h
QUFBIR8BAQEBAAAAAAAcIkFBQUFBQVEiXIAAAAAAHyFBQUEhHyFBQUEAAAAA
AD5BAQEBPkBAQEE+AAAAAAB/CAgICAgICAgICAAAAAAAQUFBQUFBQUFBIhwA
AAAAAEFBQUFBQUFBIhQIAAAAAABBQUFBQUFJSUlVIgAAAAAAQUEiFBQIFBQi
QUEAAAAAAEFBQSIUCAgICAgIAAAAAAB/QEAgEAgEAgEBfwAAAAAAPAQEBAQE
BAQEBDwAAAAAAAICBAQICBAQICBAAAAAAAA8ICAgICAgICAgPAAAAAgUAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAACBAAAAAAAAAAAAAAAAAAAAAA
AAAAAD5BQH5BYV4AAAAAAAEBAQE9Q0FBQUE/AAAAAAAAAAAAPkEBAQFBPgAA
AAAAQEBAQH5BQUFBQX4AAAAAAAAAAAA+QUE/AUE+AAAAAAB4BAQEHwQEBAQE
BAAAAAAAAAAAAHxCQUFBQX5AQT4AAAEBAQEfIUFBQUFBAAAAAAAAAAgADAgI
CAgIHAAAAAAAAAAQABAQEBAQEBAIBgAAAAEBAQFBIREPESEhAAAAAAAAGBAQ
EBAQEBAQOAAAAAAAAAAAADZJSUlJSUkAAAAAAAAAAAAeIUFBQUFBAAAAAAAA
AAAAHCJBQUEiHAAAAAAAAAAAAB4hQUFBQT8BAQEAAAAAAAAcIkFBQUF+QEBA
AAAAAAAAPUMBAQEBAQAAAAAAAAAAAD5BAT5AQT4AAAAAAAAICAg+CAgICAgw
AAAAAAAAAAAAQUFBQUFBPgAAAAAAAAAAAEFBQSIiFAgAAAAAAAAAAABBQUEq
KhQUAAAAAAAAAAAAQSIUCBQiQQAAAAAAAAAAAEFBQUFBQX5AIB8AAAAAAAB/
QCAYBgF/AAAAAAA4BAQEBAIEBAQEOAAAAAAACAgICAgICAgICAgAAAAAABwg
ICAgQCAgICAcAAAAAAAAAEY5AAAAAAAAAAAAAAAACBw2a29vd382HAgAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgICAgI
CAgAAAAAAAgIPkkJCQlJPggIAAAAOEQEBB4EBAQEBH4AAAAAADhEAgIPAg8C
AkQ4AAAAAABBQUEiFAg+CD4ICAAAABQIAD5BAQE+QEBAQT4AAAAAAAA8QgI8
QkI8QEI8AAAAAAAAFAgAPkEBPkBBPgAAAAAAHCJBWUVFRVlBIhwAAAAMEBwU
HAAcAAAAAAAAAAAAAAAAUCgUCgUKFChQAAAAAAAAAAAAAAA+ICAAAAAAAAAA
AAAAAAA8AAAAAAAAAAAAAAAcIkFdVU1VVUEiHAAAAD4AAAAAAAAAAAAAAAAA
AAAIFAgAAAAAAAAAAAAAAAAAAAAAAAgIPggIAD4AAAAAAAwQCAQcAAAAAAAA
AAAAAAAMEAgQDAAAAAAAAAAAAAAAFAgAf0BAIBAIBAIBfwAAAAAAAAAAAABB
QUFBQT8BAQAAAC4vLy8uKCgoKCgoAAAAAAAAAAAAGBgAAAAAAAAAAAAAABQI
AD8gGAYBAT8AAAAMCAgIHAAAAAAAAAAAAAAACBQIABwAAAAAAAAAAAAAAAAA
AAUKFChQKBQKBQAAAAAAAHwKCQkJOQkJCQp8AAAAAAAAAAAANklJOQlJNgAA
AAAUAEFBQSIUCAgICAgAAAAAAAAAAAgACAgGAQEBIR4ABAgAHCJBQUF/QUFB
QQAAABAIABwiQUFBf0FBQUEAAAAUABwiQUFBf0FBQUFBAAAAJhkAHCJBQUF/
QUFBQQAAAAAUABwiQUFBf0FBQUEAAAAIFAgcIkFBQX9BQUFBAAAAAAB4DAoJ
CT8JCQkJeQAAAAAAPEIBAQEBAQEBQjwIDAAECAB/AQEBHwEBAQF/AAAAEAgA
fwEBAR8BAQEBfwAAAAgUAH8BAQEfAQEBAX8AAAAAFAB/AQEBHwEBAQF/AAAA
BAgAfwgICAgICAgIfwAAABAIAH8ICAgICAgICH8AAAAIFAB/CAgICAgICAh/
AAAAABQAfwgICAgICAgIfwAAAAAAHyFBQUFHQUFBQT8AAAAmGQBBQ0VFSUlR
UWFhAAAABAgAHCJBQUFBQUEiHAAAABAIABwiQUFBQUFBIhwAAAAIFAAcIkFB
QUFBQSIcAAAAJhkAHCJBQUFBQUEiHAAAAAAUABwiQUFBQUFBIhwAAAAAAAAA
IhQIFCIAAAAAAAAAAABcIlFJSUlJSUUiHQAAAAQIAEFBQUFBQUFBIhwAAAAQ
CABBQUFBQUFBQSIcAAAACBQAQUFBQUFBQUEiHAAAAAAUAEFBQUFBQUFBIhwA
AAAQCABBQSIUCAgICAgIAAAAAAACAj5CQkI+AgICAgAAAAAADhEhIRkFOUFB
QT0AAAAAAAAECAA+QUB+QWFeAAAAAAAAEAgAPkFAfkFhXgAAAAAAAAgUAD5B
QH5BYV4AAAAAAAAsEgA+QUB+QWFeAAAAAAAAABQAPkFAfkFhXgAAAAAAAAgU
CBwiIDwiMiwAAAAAAAAAAAA2SUg+CUk2AAAAAAAAAAAAPEIBAQFCPAgMAAAA
AAQIAD5BQT8BQT4AAAAAAAAQCAA+QUE/AUE+AAAAAAAABAoAPkFBPwFBPgAA
AAAAAAAUAD5BQT8BQT4AAAAAAAAECAAMCAgICAg+AAAAAAAAEAgADAgICAgI
PgAAAAAAAAgUAAwICAgICD4AAAAAAAAUAAAMCAgICAg+AAAAAAAANgkUPkFB
QUFBPgAAAAAAACwSAB4hQUFBQUEAAAAAAAAECAA+QUFBQUE+AAAAAAAAEAgA
PkFBQUFBPgAAAAAAAAQIAD5BQUFBQT4AAAAAAAAECAA+QUFBQUE+AAAAAAAA
BAgAPkFBQUFBPgAAAAAAAAAIAD4ACAAAAAAAAAAAAAAAAABeIVFJRUI9AAAA
AAAAAAQIAEFBQUFBPgAAAAAAAAAIBABBQUFBQT4AAAAAAAAACBQAQUFBQUE+
AAAAAAAAABAIAEFBQUFBPgAAAAAAAAAQCABBQUFBQX5AQD8AAAABAQE9Q0FB
QUM9AQEBAAAAAAAUAEFBQUFBfkBAPw==
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/monospace-8.sqf.__mime.

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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 monospace-8.sqf
CAYCAQUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDhsVFxsOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAABAQEBAAEAAAKCgAAAAAAAAofCgofCgAABA4FDhQO
AAAACQwGAwkAAAYJAgUJFgAABAQAAAAAAAAEAgICAgQAAAQICAgIBAAAFQ4V
AAAAAAAAAAQOBAAAAAAAAAAABAQAAAAADgAAAAAAAAAAAAQAAAgEBAICAQAA
BgkNCwkGAAAGBAQEBA4AAA8IDwEBDwAADwgOCAgPAAAJCQ8ICAgAAA8BDwgI
DwAADwEPCQkPAAAPCAgICAgAAA8JDwkJDwAADwkPCAgIAAAAAAQAAAQAAAAA
BAAABAQAAAgEAgQIAAAAAA4ADgAAAAACBAgEAgAABgkIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAOAQEBAQ4AAAcJCQkJBwAADwEBBwEPAAAPAQEH
AQEAAA4BAQ0JBgAACQkJDwkJAAAOBAQEBA4AAAwICAgJBgAACQkFAwUJAAAB
AQEBAQ8AABEbFREREQAACQsLDQ0JAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAADgQEBAQEAAAJCQkJCQYAAAkJCQkKBAAAERER
ERUKAAAJCQkGCQkAAAkJCQYEBAAADwgIBgEPAAAOAgICAg4AAAECAgQECAAA
DggICAgOAAAEChEAAAAAAAAAAAAAHwAAAgQAAAAAAAAADwgPCQ4AAAEBBwkJ
BwAAAAAOAQEOAAAICA4JCQ4AAAAGCQ8BDgAAAA4CBwICAAAADgkJCQ4IBwAB
AQcJCQAABAAGBAQOAAAEAAQEBAQEAwABCQkHCQAABgQEBAQOAAAACxUVFRUA
AAAHCQkJCQAAAAYJCQkGAAAABwkJCQcBAQAOCQkJDggIAAYJAQEBAAAADgEG
CAcAAAACDgICDAAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAADgIDAwIOAAAEBAQEBAQAAAcEDAwEBwAAAAAWCQAA
AAAOGxUXGw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABAAEBAQEAAQOBQUOBAAMEgcCAh8AABwCBwcCHAAAEQoOBA4EAAAK
BgEGCAcAAA4BBgYIBwAACgQOAQ4HAAAOERUTFQ4AAAYOAA4AAAAAABQKBQoU
AAAAAA8IAAAAAAAADgAAAAAADhMVExUOAAAPAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAAGCAQCDgAAAAYIBggGAAAACgQPBAIPAAAAAAkJCQcBABYXFxYUFAAA
AAAGBgAAAAAKBA4IBg4AAAYEBAQOAAAABAoEAA4AAAAABQoUCgUAAB4FDQUF
HgAAAB4VHQUeAAAKEQoEBAQAAAACAAIBCQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAACgUGCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUFDwUdAAAOAQEBAQ4E
BgIEDwcBDwAABAIPBwEPAAACBQ8HAQ8AAAoADwcBDwAAAgQOBAQOAAAIBA4E
BA4AAAQKDgQEDgAACgAOBAQOAAAGCgsKCgYAABYJCQsNCQAAAgQGCQkGAAAE
AgYJCQYAAAIFBgkJBgAAFgkGCQkGAAAKAAYJCQYAAAAACgQKAAAABg0NCwsG
AAACBAkJCQYAAAQCCQkJBgAABAoJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAGCQUJEQ0AAAIEBgkJFgAABAIGCQkWAAAECgYJCRYAABYJBgkJFgAA
CgAGCQkWAAAGCQYJCRYAAAAAHhUNHgAAAAAOAQEOBAYCBA4JBw4AAAQCDgkH
DgAABAoGCQcOAAAKAAYJBw4AAAIEAAQEBAAACAQABAQEAAAECgAEBAQAAAAK
AAQEBAAACgUGDQkGAAAWCQYJCQkAAAIEBgkJBgAABAIGCQkGAAAECgYJCQYA
ABYJBgkJBgAACgAGCQkGAAAABAAfAAQAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAACgAACQkGAAAIBAAJCQ4IBwAAAQcJCQcBCgAACQkOCAc=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for fonts.
 *
 * Since it is really difficult to have fonts as part of displays, fonts are
 * completely separate which also allows for default fonts to be provided.
 *
 * @since 2017/10/01
 */

package cc.squirreljme.runtime.lcdui.font;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/sansserif-12.sqf.__mime.

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
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






















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 sansserif-12.sqf
DAkDAgoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBwYKCAID
AwYEAwQDBQYGBgYGBgYGBgYDAwUEBQYHBgYGBgYGBgYCBgcGCAYGBgYGBgYG
BggGBgYEBQQGBAMGBgUGBQUGBgIDBgIKBgYGBgUGBAYGBgYGBgQCBAYKAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBwgGBgUHBAcFAwcF
BAQDAwcGBgQFBAQHCAgGBgYGBgYGBwgFBQUFBQMCAwMHBgYGBgYGBgcGBgYG
BgUIBgYGBgYGCAUFBQUFAwIDAwYGBQUFBQUEBgYGBgYGBwYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAABAAEAAQABAAEAAQAAAAEAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAA
AAAAAAAAEgASAD8AEgASABIAPwASABIAAAAAAAAABAAOABUABQAOABQAFAAV
AA4ABAAAAAAABgGJAEkAJgAQAMgAJAEiAcEAAAAAAAAADAASAAEAAQACAEUA
KQARAC4AAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgABAAEAAQAB
AAEAAQABAAIAAAAAAAAAAQACAAIAAgACAAIAAgACAAEAAAAAAAAAFQAOAB8A
DgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAcAAgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAMAAwAAAAAAAAAIAAgABAAEAAIAAgABAAEAAAAA
AAAADgARABEAFQAVABUAEQARAA4AAAAAAAAABwAEAAQABAAEAAQABAAEAB8A
AAAAAAAADgARABAACAAEAAIAAQABAB8AAAAAAAAADgARABAAEAAOABAAEAAR
AA4AAAAAAAAAEQARABEAEQAfABAAEAAQABAAAAAAAAAAHwABAAEADwAQABAA
EAARAA4AAAAAAAAAHgABAAEAAQAPABEAEQARAA4AAAAAAAAAHwAQABAACAAI
AAQABAACAAIAAAAAAAAADgARABEAEQAOABEAEQARAA4AAAAAAAAADgARABEA
EQAeABAAEAAQABAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAMAAwAAAAAAAAAA
AAAAAwADAAAAAAAAAAMAAgAAAAAAAAAIAAQAAgABAAIABAAIAAAAAAAAAAAA
AAAAAAAAAAAHAAAABwAAAAAAAAAAAAAAAAABAAIABAAIAAQAAgABAAAAAAAA
AAAADgARABAAEAAIAAQABAAAAAQAAAAAAAAAHgAhAC0ALQAtAC0APQABAD4A
AAAAAAAADgARABEAEQAfABEAEQARABEAAAAAAAAADwARABEAEQAPABEAEQAR
AA8AAAAAAAAAHgABAAEAAQABAAEAAQABAB4AAAAAAAAADwARABEAEQARABEA
EQARAA8AAAAAAAAAHwABAAEAAQAHAAEAAQABAB8AAAAAAAAAHwABAAEAAQAH
AAEAAQABAAEAAAAAAAAAHgABAAEAAQAdABEAEQARAA4AAAAAAAAAEQARABEA
EQAfABEAEQARABEAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAEAAQ
ABAAEAAQABAAEQARAA4AAAAAAAAAIQARAAkABQADAAUACQARACEAAAAAAAAA
AQABAAEAAQABAAEAAQABAB8AAAAAAAAAYwBVAEkAQQBBAEEAQQBBAEEAAAAA
AAAAEQATABMAFQAVABUAGQAZABEAAAAAAAAADgARABEAEQARABEAEQARAA4A
AAAAAAAADwARABEAEQAPAAEAAQABAAEAAAAAAAAADgARABEAEQARABEAFQAJ
ABYAAAAAAAAADwARABEAEQAPAAkAEQARABEAAAAAAAAADgARAAEAAQAOABAA
EAARAA4AAAAAAAAAHwAEAAQABAAEAAQABAAEAAQAAAAAAAAAEQARABEAEQAR
ABEAEQARAA4AAAAAAAAAEQARABEAEQARABEAEgAUABgAAAAAAAAAQQBBAEEA
QQBBAEkASQBJADYAAAAAAAAAEQARAAoABAAEAAoAEQARABEAAAAAAAAAEQAR
ABEACgAEAAQABAAEAAQAAAAAAAAAHwAQABAACAAEAAIAAQABAB8AAAAAAAAA
BwABAAEAAQABAAEAAQABAAcAAAAAAAAAAAABAAEAAgACAAQABAAIAAgAAAAA
AAAABwAEAAQABAAEAAQABAAEAAcAAAAAAAAABAAKABEAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAOABEAEQARAC4AAAAAAAAAAQABAAEAAQAPABEA
EQARAA8AAAAAAAAAAAAAAAAAAAAOAAEAAQABAA4AAAAAAAAAEAAQABAAEAAe
ABEAEQARAB4AAAAAAAAAAAAAAAAAAAAOAAkABwABAA4AAAAAAAAAAAAMAAIA
AgAHAAIAAgACAAIAAAAAAAAAAAAAAAAAAAAeABEAEQARAB4AEAAPAAAAAAAB
AAEAAQAPABEAEQARABEAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAAAAAAAA
AAAAAAIAAAACAAIAAgACAAIAAQAAAAAAAAABAAEAEQARAA8AEQARABEAAAAA
AAAAAAABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAD/ABEBEQERAREB
AAAAAAAAAAAAAAAAAAAPABEAEQARABEAAAAAAAAAAAAAAAAAAAAOABEAEQAR
AA4AAAAAAAAAAAAAAAAAAAAPABEAEQARAA8AAQABAAAAAAAAAAAAAAAeABEA
EQARAB4AEAAQAAAAAAAAAAAAAAAOAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAe
AAEADgAQAA8AAAAAAAAAAAAAAAIAAgAHAAIAAgACAAwAAAAAAAAAAAAAAAAA
AAARABEAEQARAA4AAAAAAAAAAAAAAAAAAAARABEAEgAUABgAAAAAAAAAAAAA
AAAAAAARABEAFQAVAAoAAAAAAAAAAAAAAAAAAAARAAoABAAKABEAAAAAAAAA
AAAAAAAAAAARABEAEQAeABAAEAAPAAAAAAAAAAAAAAAfAAgABAACAB8AAAAA
AAAABAACAAIAAgABAAIAAgACAAQAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AAAAAAAAAQACAAIAAgAEAAIAAgACAAEAAAAAAAAAAAAWAAkAAAAAAAAAAAAA
AAAAAAAAAAAAEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAQABAAAAAAAAAAAA
BAAOAAUABQAFAA4ABAAAAAAADAACAAIAAgAHAAIAAgACAA8AAAAAAAAAHAAi
AAIADwACAA8AAgAiABwAAAAAAAAAQQBBACIAFAAIABwACAAcAAgAAAAAAAAA
CgAEAB4AAQABAA4AEAAQAA8AAAAAAAAAHgABAAMADQARABYAGAAQAA8AAAAA
AAAACgAEAAAAAAAOAAEABgAIAAcAAAAAAAAAHgAhAC0AIwAjACMALQAhAB4A
AAAAAAAAAgAFAAUACgAAAA8AAAAAAAAAAAAAAAAAAAAoABQACgAFAAoAFAAo
AAAAAAAAAAAAAAAAAAAAAAAPAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAA
AAAAAAAAAAAAAAAAHgAhACcAKwAnACsAKwAhAB4AAAAAAAAADwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AgAHAAIAAAAHAAAAAAAAAAAAAwACAAMAAQADAAAAAAAAAAAAAAAAAAAAAwAC
AAMAAgADAAAAAAAAAAAAAAAAAAAACgAEAD8AEAAIAAQAAgABAD8AAAAAAAAA
AAAAAAAAAAAAABEAEQARAA8AAQABAAAAFgAXABcAFgAUABQAFAAUABQAAAAA
AAAAAAAAAAAAAAAGAAYAAAAAAAAAAAAAAAAACgAEAAAAAAAPAAgABgABAA8A
AAAAAAAAAwACAAIABwAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAAAAAA
AAAAAAAAAAAAAAAFAAoAFAAoABQACgAFAAAAAAAAAAAAfgAJAAkACQA5AAkA
CQAJAH4AAAAAAAAAAAAAAAAAAAB2AEkAOQAJAHYAAAAAAAAACgARABEAEQAK
AAQABAAEAAQAAAAAAAAAAAAAAAQAAAAEAAQAAgABABEAEQAOAAAAAgAEAAAA
DgARABEAHwARABEAAAAAAAAACAAEAAAADgARABEAHwARABEAAAAAAAAABAAK
AAAADgARABEAHwARABEAAAAAAAAAFgAJAAAADgARABEAHwARABEAAAAAAAAA
CgAAAAAADgARABEAHwARABEAAAAAAAAABAAKAAQADgARABEAHwARABEAAAAA
AAAAfAAKAAkACQA/AAkACQAJAHkAAAAAAAAAAAAOAAEAAQABAAEAAQABAA4A
BAAGAAAAAgAEAAAADwABAAcAAQABAA8AAAAAAAAABAACAAAADwABAAcAAQAB
AA8AAAAAAAAABAAKAAAADwABAAcAAQABAA8AAAAAAAAACgAAAAAADwABAAcA
AQABAA8AAAAAAAAAAQACAAAAAgACAAIAAgACAAIAAAAAAAAAAgABAAAAAQAB
AAEAAQABAAEAAAAAAAAAAgAFAAAAAgACAAIAAgACAAIAAAAAAAAABQAAAAAA
AgACAAIAAgACAAIAAAAAAAAAHgAiACIAIgAnACIAIgAiAB4AAAAAAAAAFgAJ
AAAAEwATABUAFQAZABkAAAAAAAAAAgAEAAAADgARABEAEQARAA4AAAAAAAAA
CAAEAAAADgARABEAEQARAA4AAAAAAAAABAAKAAAADgARABEAEQARAA4AAAAA
AAAAFgAJAAAADgARABEAEQARAA4AAAAAAAAACgAAAAAADgARABEAEQARAA4A
AAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAHgAxACkAKQAlACUAJQAj
AB4AAAAAAAAAAgAEAAAAEQARABEAEQARAA4AAAAAAAAACAAEAAAAEQARABEA
EQARAA4AAAAAAAAABAAKAAAAEQARABEAEQARAA4AAAAAAAAACgAAAAAAEQAR
ABEAEQARAA4AAAAAAAAACAAEAAAAEQARAAoABAAEAAQAAAAAAAAAAQABAAcA
CQAJAAkABwABAAEAAAAAAAAADgARABEACQAFAAkAEQARAA0AAAAAAAAAAAAC
AAQAAAAOABEAEQARAC4AAAAAAAAAAAAIAAQAAAAOABEAEQARAC4AAAAAAAAA
AAAEAAoAAAAOABEAEQARAC4AAAAAAAAAAAAWAAkAAAAOABEAEQARAC4AAAAA
AAAAAAAAAAoAAAAOABEAEQARAC4AAAAAAAAABAAKAAQAAAAOABEAEQARAC4A
AAAAAAAAAAAAAAAAAAA3AEgAPgAJAHYAAAAAAAAAAAAAAAAAAAAOAAEAAQAB
AA4ABAAGAAAAAAACAAQAAAAOAAkABwABAA4AAAAAAAAAAAAIAAQAAAAOAAkA
BwABAA4AAAAAAAAAAAAEAAoAAAAOAAkABwABAA4AAAAAAAAAAAAAAAoAAAAO
AAkABwABAA4AAAAAAAAAAAAAAAEAAgAAAAIAAgACAAIAAAAAAAAAAAAAAAIA
AQAAAAEAAQABAAEAAAAAAAAAAAAAAAIABQAAAAIAAgACAAIAAAAAAAAAAAAA
AAAABQAAAAIAAgACAAIAAAAAAAAAAAAAABgABwAKABEAEQARAA4AAAAAAAAA
AAAAABYACQAAAA8AEQARABEAAAAAAAAAAAAAAAIABAAAAAYACQAJAAYAAAAA
AAAAAAAAAAQAAgAAAAYACQAJAAYAAAAAAAAAAAAAAAIABQAAAAYACQAJAAYA
AAAAAAAAAAAAAAoABQAAAAYACQAJAAYAAAAAAAAAAAAAAAAACgAAAAYACQAJ
AAYAAAAAAAAAAAAAAAAAAgAAAAcAAAACAAAAAAAAAAAAAAAAAAAAAAAOABkA
FQATAA4AAAAAAAAAAAAAAAIABAAAABEAEQARAA4AAAAAAAAAAAAAAAgABAAA
ABEAEQARAA4AAAAAAAAAAAAAAAQACgAAABEAEQARAA4AAAAAAAAAAAAAAAAA
CgAAABEAEQARAA4AAAAAAAAAAAAAAAgABAAAABEAEQARAB4AEAAPAAAAAAAA
AAEAAQAHAAkACQAJAAcAAQABAAAAAAAAAAAACgAAABEAEQARAB4AEAAPAAAA
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/sansserif-16.sqf.__mime.

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
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
191
192
193
194
195
196




































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 sansserif-16.sqf
EA0DAg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAIFCggNCwME
BQcHAwUDCAcHBwcHBwcHBwcEBAcFBwgKCQkJCQkJCAgCCAgICQkJCAkICAkJ
CQsJCwsFCAUFBQQHCAcICAcICAMECAMNCAgICAcIBggICQkICAYDBggNAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgcICAsIBwgJBQkHBgkH
BQcFBQsICAUIBQUHCgwLCAkJCQkJCQoJCAgICAMDAwMJCQkJCQkJBwkJCQkJ
CQcJBwcHBwcHCwcICAgIAwMDAwgICAgICAgHCAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAAACAAcAD4AIwBdgN/B54D/AHYAHAA
IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAQABAAEAAQABAAEAAQAAAAAAAQAAAAAAAAAFAAUAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAD/ACQAJAAkAP8AJAAkACQAAAAA
AAAABAAEAB4AJQAFAAUABQAeACQAJAAkACUAHgAEAAQAAAAAAAAADAQSAhIB
jABAACAAEAOIBIQEAgMBAAAAAAAAAAAAAAA8AEIAAgACAAQACAAUAKIAQQCh
AB4BAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BAACAAEAAQABAAEAAQABAAEAAgAEAAAAAAAAAAAAAAABAAIABAAEAAQABAAE
AAQABAACAAEAAAAAAAAAFQAOAB8ADgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAQABAAfAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAwACAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAAg
ACAAEAAQAAgACAAEAAQAAgACAAEAAAAAAAAAAAAAAA4AEQARABEAFQAVABUA
EQARABEADgAAAAAAAAAAAAAABwAEAAQABAAEAAQABAAEAAQABAAfAAAAAAAA
AAAAAAAOABEAEAAQABAACAAEAAIAAQABAB8AAAAAAAAAAAAAAA4AEQAQABAA
EAAOABAAEAAQABEADgAAAAAAAAAAAAAAEQARABEAEQARAB8AEAAQABAAEAAQ
AAAAAAAAAAAAAAAfAAEAAQABAA8AEAAQABAAEAARAA4AAAAAAAAAAAAAAB4A
AQABAAEAAQAPABEAEQARABEADgAAAAAAAAAAAAAAHwAQABAAEAAQABAAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAOABEAEQARABEADgARABEAEQARAA4AAAAAAAAA
AAAAAA4AEQARABEAEQAeABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAMAAwAA
AAAAAAAAAAAAAwADAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAADAAMA
AgAAAAAAAAAAAAAAEAAIAAQAAgABAAIABAAIABAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAA8AAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAEAAgAEAAgAEAAIAAQA
AgABAAAAAAAAAAAAAAAAAB4AIQAgACAAIAAYAAQABAAAAAAABAAAAAAAAAAA
AAAAfgCBAJkApQClAKUApQClAHkAAQD+AAAAAAAAAAAAAAAcACIAQQBBAEEA
fwBBAEEAQQBBAEEAAAAAAAAAAAAAAB8AIQBBAEEAIQAfACEAQQBBAEEAPwAA
AAAAAAAAAAAAPABCAAEAAQABAAEAAQABAAEAQgA8AAAAAAAAAAAAAAAfACEA
QQBBAEEAQQBBAEEAQQBBAD8AAAAAAAAAAAAAAH8AAQABAAEAAQAPAAEAAQAB
AAEAfwAAAAAAAAAAAAAAfwABAAEAAQABAA8AAQABAAEAAQABAAAAAAAAAAAA
AAAeACEAAQABAAEAAQA5ACEAIQAhAB4AAAAAAAAAAAAAACEAIQAhACEAIQA/
ACEAIQAhACEAIQAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAAA
AAAAAAAAAAAgACAAIAAgACAAIAAgACEAIQAiABwAAAAAAAAAAAAAACEAIQAR
AAkABQADAAUACQARACEAIQAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AQA/AAAAAAAAAAAAAABBAGMAYwBVAFUASQBJAEEAQQBBAEEAAAAAAAAAAAAA
AEEAQwBDAEUARQBJAEkAUQBRAGEAYQAAAAAAAAAAAAAAHAAiAEEAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAPABEAIQAhACEAEQAPAAEAAQABAAEAAAAA
AAAAAAAAABwAIgBBAEEAQQBBAEEAQQBRACIAXACAAAAAAAAAAAAADwARACEA
IQAhABEADwARACEAIQAhAAAAAAAAAAAAAAAeACEAAQABAAEAHgAgACAAIAAh
AB4AAAAAAAAAAAAAAH8ACAAIAAgACAAIAAgACAAIAAgACAAAAAAAAAAAAAAA
QQBBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAAAAAAABBAEEAQQBBAEEAQQBB
AEEAIgAUAAgAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBEQERAaoARAAAAAAA
AAAAAAAAQQBBACIAFAAUAAgAFAAUACIAQQBBAAAAAAAAAAAAAAABAQEBggBE
ACgAEAAQABAAEAAQABAAAAAAAAAAAAAAAP8BAAGAAEAAIAAQAAgABAACAAEA
/wEAAAAAAAAAAAAABwABAAEAAQABAAEAAQABAAEAAQAHAAAAAAAAAAAAAAAB
AAEAAgACAAQABAAIAAgAEAAQACAAAAAAAAAAAAAAAAcABAAEAAQABAAEAAQA
BAAEAAQABwAAAAAAAAACAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAAAAAAAQACAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOABEAEQARABEAEQAu
AAAAAAAAAAAAAAABAAEAAQABAB0AIwAhACEAIQAhAB8AAAAAAAAAAAAAAAAA
AAAAAAAADgARAAEAAQABABEADgAAAAAAAAAAAAAAIAAgACAAIAA+ACEAIQAh
ACEAIQA+AAAAAAAAAAAAAAAAAAAAAAAAAB4AIQAhAB8AAQAhAB4AAAAAAAAA
AAAAABwAAgACAAIADwACAAIAAgACAAIAAgAAAAAAAAAAAAAAAAAAAAAAAAA+
ACEAIQAhACEAIQA+ACAAIQAeAAAAAAABAAEAAQABAA8AEQAhACEAIQAhACEA
AAAAAAAAAAAAAAAAAAABAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAA
AAQAAAAEAAQABAAEAAQABAAEAAIAAQAAAAAAAAABAAEAAQABACEAEQAJAAcA
CQARABEAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAA
AAAAAAAAAAAAAADOATECIQQhBCEEIQQhBAAAAAAAAAAAAAAAAAAAAAAAAA4A
EQAhACEAIQAhACEAAAAAAAAAAAAAAAAAAAAAAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAAAAAAeACEAIQAhACEAIQAfAAEAAQABAAAAAAAAAAAA
AAAAAB4AIQAhACEAIQAhAD4AIAAgACAAAAAAAAAAAAAAAAAADgARAAEAAQAB
AAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAeACEAAQAeACAAIQAeAAAAAAAAAAAA
AAAAAAIAAgACAA8AAgACAAIAAgACAAwAAAAAAAAAAAAAAAAAAAAAAAAAIQAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAAAAAAhACEAIQASABIADAAMAAAA
AAAAAAAAAAAAAAAAAAAAAEEAQQBBACoAKgAUABQAAAAAAAAAAAAAAAAAAAAA
AAAAQQAiABQACAAUACIAQQAAAAAAAAAAAAAAAAAAAAAAAAAhACEAIQAhACEA
IQA+ACAAIAAfAAAAAAAAAAAAAAAAAD8AIAAYAAYAAQABAD8AAAAAAAAAAAAA
AAwAAgACAAIAAgABAAIAAgACAAIADAAAAAAAAAAAAAAAAQABAAEAAQABAAEA
AQABAAEAAQABAAAAAAAAAAAAAAADAAQABAAEAAQACAAEAAQABAAEAAMAAAAA
AAAAAAAAAAAAAAAmABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABwAPgA
jAF2A38HngP8AdgAcAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAABAAAAAAABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAEAAQADgAV
AAUABQAFABUADgAEAAQAAAAAAAAAHAAiAAIAAgAPAAIAAgACAAIAAgA/AAAA
AAAAAAAAAAA8AEIAAQABAAcAAQAHAAEAAQBCADwAAAAAAAAAAAAAAAEBAQGC
AEQAKAAQAP4AEAD+ABAAEAAAAAAAAAAKAAQAAAAeACEAAQABAB4AIAAgACAA
IQAeAAAAAAAAAAAAAAAAAA4AEQABAA4AEQARAA4AEAARAA4AAAAAAAAAAAAA
AAAACgAEAAAAHgAhAAEAHgAgACEAHgAAAAAAAAAAAAAAHAAiAEEAWQBFAEUA
RQBZAEEAIgAcAAAAAAAAAAMABAAHAAUABwAAAAcAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAUAAoABQACgAFAAoAFAAoAFAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAB8AEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAABwAIgBBAF0AVQBNAFUAVQBBACIAHAAAAAAAAAAfAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAHwAEAAQAAAAfAAAAAAAAAAAA
AAADAAQAAgABAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMABAACAAQAAwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAQAAAA/wGAAEAAIAAQAAgABAACAAEA
/wEAAAAAAAAAAAAAAAAAAAAAAAAAACEAIQAhACEAIQAfAAEAAQAAAAAAAAAu
AC8ALwAvAC4AKAAoACgAKAAoACgAAAAAAAAAAAAAAAAAAAAAAAAABgAGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAUAAgAAAA/ACAAGAAGAAEAAQA/AAAAAAAA
AAMAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAoAFAAoAFAAKAAUAAoABQAA
AAAAAAAAAAAAAAD8ABIAEQARABEAcQARABEAEQASAPwAAAAAAAAAAAAAAAAA
AAAAAAAA7gERAhEC8QERABEC7gEAAAAAAAAAACgAAAABAQEBggBEACgAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAIAAYAAQABAAEAIQAeAAAA
BAAIAAAAHAAiAEEAQQBBAH8AQQBBAEEAQQAAAAAAAAAQAAgAAAAcACIAQQBB
AEEAfwBBAEEAQQBBAAAAAAAAABQAAAAcACIAQQBBAEEAfwBBAEEAQQBBAEEA
AAAAAAAAJgAZAAAAHAAiAEEAQQBBAH8AQQBBAEEAQQAAAAAAAAAAABQAAAAc
ACIAQQBBAEEAfwBBAEEAQQBBAAAAAAAAAAgAFAAIABwAIgBBAEEAQQB/AEEA
QQBBAEEAAAAAAAAAAAAAAP4AEQARABEAEQB/ABEAEQARABEA8QAAAAAAAAAA
AAAAPABCAAEAAQABAAEAAQABAAEAQgA8AAgADAAAAAQACAAAAD8AAQABAAEA
DwABAAEAAQABAD8AAAAAAAAAEAAIAAAAPwABAAEAAQAPAAEAAQABAAEAPwAA
AAAAAAAIABQAAAA/AAEAAQABAA8AAQABAAEAAQA/AAAAAAAAAAAAFAAAAD8A
AQABAAEADwABAAEAAQABAD8AAAAAAAAAAQACAAAAAQABAAEAAQABAAEAAQAB
AAEAAQAAAAAAAAACAAEAAAABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAEA
AgAAAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAACAAAAAQABAAEAAQAB
AAEAAQABAAEAAQAAAAAAAAAAAAAAHwAhAEEAQQBBAEcAQQBBAEEAQQA/AAAA
AAAAACYAGQAAAEEAQwBFAEUASQBJAFEAUQBhAGEAAAAAAAAABAAIAAAAHAAi
AEEAQQBBAEEAQQBBACIAHAAAAAAAAAAQAAgAAAAcACIAQQBBAEEAQQBBAEEA
IgAcAAAAAAAAAAgAFAAAABwAIgBBAEEAQQBBAEEAQQAiABwAAAAAAAAAJgAZ
AAAAHAAiAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQAAAAcACIAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAAAAA
AAAAAAAAAFwAIgBRAEkASQBJAEkASQBFACIAHQAAAAAAAAAEAAgAAABBAEEA
QQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAEEAQQBBAEEAQQBBAEEAQQAi
ABwAAAAAAAAACAAUAAAAQQBBAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQA
AABBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAEEAQQAiABQACAAI
AAgACAAIAAgAAAAAAAAAAAAAAAEAAQAPABEAEQARAA8AAQABAAEAAQAAAAAA
AAAAAAAADgARACEAIQAZAAUAOQBBAEEAQQA9AAAAAAAAAAAAAAAAAAIABAAA
AA4AEQARABEAEQARAC4AAAAAAAAAAAAAAAAACAAEAAAADgARABEAEQARABEA
LgAAAAAAAAAAAAAAAAAEAAoAAAAOABEAEQARABEAEQAuAAAAAAAAAAAAAAAA
ABYACQAAAA4AEQARABEAEQARAC4AAAAAAAAAAAAAAAAAAAAKAAAADgARABEA
EQARABEALgAAAAAAAAAAAAAAAAAEAAoABAAOABEAEQARABEAEQAuAAAAAAAA
AAAAAAAAAAAAAAAAAO4AEQEQAf4AEQAZAfYAAAAAAAAAAAAAAAAAAAAAAAAA
DgARAAEAAQABABEADgAEAAYAAAAAAAAAAAAEAAgAAAAeACEAIQAfAAEAIQAe
AAAAAAAAAAAAAAAAABAACAAAAB4AIQAhAB8AAQAhAB4AAAAAAAAAAAAAAAAA
BAAKAAAAHgAhACEAHwABACEAHgAAAAAAAAAAAAAAAAAAABQAAAAeACEAIQAf
AAEAIQAeAAAAAAAAAAAAAAAAAAAAAQAAAAEAAQABAAEAAQABAAEAAAAAAAAA
AAAAAAAAAgABAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAABAAIAAAAB
AAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAgAAAAEAAQABAAEAAQABAAEA
AAAAAAAAAAAAAAAANgAJABQAHgAhACEAIQAhACEAHgAAAAAAAAAAAAAAAAAW
AAkAAAAOABEAIQAhACEAIQAhAAAAAAAAAAAAAAAAAAQACAAAAB4AIQAhACEA
IQAhAB4AAAAAAAAAAAAAAAAACAAEAAAAHgAhACEAIQAhACEAHgAAAAAAAAAA
AAAAAAAEAAoAAAAeACEAIQAhACEAIQAeAAAAAAAAAAAAAAAAABYACQAAAB4A
IQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAKAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAQAAAAfAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAC4AEQApAC0AJQAiAB0AAAAAAAAAAAAAAAAAAAAEAAgAAAAhACEAIQAh
ACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAACEAIQAhACEAIQAeAAAAAAAAAAAA
AAAAAAAABAAKAAAAIQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAIAAQAAAAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAACEAIQAhACEAIQA+ACAA
IAAfAAAAAAAAAAEAAQABAB0AIwAhACEAIQAjAB0AAQABAAEAAAAAAAAAAAAA
ABQAAAAhACEAIQAhACEAPgAgACAAHwA=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/sansserif-8.sqf.__mime.

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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 sansserif-8.sqf
CAYCAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBgQGBgID
AwYEAwMCBAQEBAQFBAUFBQUCAgQEBAUFBQUFBQQEBQUCBAUEBgYFBQUFBQQF
BQYGBgYDBAMEAwMFBQQFBQQFBQIDBQIHBQUFBQQFBAUFBgUFBQQCBAUGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBgYFBAQGBAYEBAYE
BAQDBAUEBgIEBAMGBgYGBAUFBQUFBQYFBAQEBAIDAwMGBQUFBQUFBAYFBQUF
BgQFBAQEBAQEBgQEBAQEAwIDAwQEBQUFBQUEBAUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDgobHwoOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQABAAAFBQAAAAAAAAofCh8KAAAABA4BBggH
AgAAEwsEGhkAAA4BAhUJFgAAAQEAAAAAAAACAQEBAQIAAAECAgICAQAAFQ4V
AAAAAAAAAgcCAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAEAAAQEAgIBAQAA
AgUFBQUCAAADAgICAgcAAAMEBAIBBwAAAwQCBAQDAAAMCgkPCAgAAAcBAwQE
AwAADgEHCQkGAAAPCAQEAgIAAAYJBgkJBgAABgkJDggHAAAAAQAAAQAAAAAB
AAAAAQEAAAQCAQIEAAAAAAcABwAAAAABAgQCAQAABwgIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAGAQEBAQYAAAcJCQkJBwAABwEDAQEHAAAHAQMB
AQEAAA4BAQ0JDgAACQkPCQkJAAABAQEBAQEAAAQEBAQFAgAACQUDAwUJAAAB
AQEBAQcAABEbFRUREQAAExMVFRkZAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAABwICAgICAAAJCQkJCQYAAAkJCQkKDAAAERER
ERUKAAARCgQEChEAABERCgQEBAAAHwgEAgEfAAADAQEBAQMAAAEBAgIEBAAA
AwICAgIDAAACBQAAAAAAAAAAAAAABwAAAQIAAAAAAAAAAAYJCRYAAAEBBwkJ
BwAAAAAGAQEGAAAICA4JCQ4AAAAGCQ8BDgAAAAwCBwICAAAAAA4JCQ4IBwEB
BwkJCQAAAAEAAQEBAAAAAgACAgIBAAEBCQcJCQAAAQEBAQEBAAAAAB8lJSUA
AAAABwkJCQAAAAAGCQkGAAAAAAcJCQcBAQAADgkJDggIAAAGAQEBAAAADgEG
CAcAAAACBwICBgAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAABgIDAwIGAAABAQEBAQEAAAMCBgYCAwAAAAoFAAAA
AAAOChsfCg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAQABAQEBAAQOBQUOBAAMAgcCAg8AAAwSBwIXDAAAEQoEDg4EAAAK
BA4DDAcAAAYBBgMEAwAABQIOAwwHAAAOERUTFQ4AAAMFBwAHAAAAABQKBQoU
AAAAAAcEAAAAAAAABwAAAAAADhMVExUOAAAHAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAADBAIBBwAAAAMEBwQDAAAACgQPBAIPAAAAAAAFBQcBABYXFhQUFAAA
AAAAAQAAAAAFAgcGAQcAAAMCBwAAAAAAAgUCBwAAAAAABQoUCgUAAB4FDQUF
HgAAAAA+GQk+AAAKEQoEBAQAAAACAAIBAQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAAEg0GCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUPBQUdAAAOAQEBAQ4E
BgIEBwMBBwAABAIHAwEHAAACBQcDAQcAAAUABwMBBwAAAQIBAQEBAAACAQIC
AgIAAAIFAgICAgAABQACAgICAAAOEhcSEg4AAAoFAAsNCQAAAgQGCQkGAAAE
AgYJCQYAAAQKBgkJBgAACgUGCQkGAAAKAAYJCQYAAAAABQIFAAAADhkVFRMO
AAACBAkJCQYAAAQCCQkJBgAAAgUJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAHCQUJEQ0AAAECAAYFCwAABAIABgULAAACBQAGBQsAAAoFAAYFCwAA
BQAABgULAAACBQIGBQsAAAAAHi0dMwAAAAAGAQEGAwACBAIFAwYAAAQCAgUD
BgAAAgUCBQMGAAAFAAIFAwYAAAECAAICAgAAAgEAAQEBAAACBQACAgIAAAUA
AAICAgAACgUMCwkGAAAKBQADBQUAAAECBgkJBgAABAIGCQkGAAAECgYJCQYA
AAoFBgkJBgAABQAGCQkGAAAAAgAHAAIAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAABQAACQkGAAAEAgAJCQ4IBwABBwkJBwEACgAACQkOCAc=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/serif-12.sqf.__mime.

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
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






















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 serif-12.sqf
DAkDAgoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIEBwYKCAID
AwYEAwQDBQYGBgYGBgYGBgYDAwUEBQYHBgYGBgYGBgYEBgcGCAYGBgYGBgYG
BggHBwYEBQQGBAMGBwUGBQUGBgMDBgMKBgYGBgUGBAYGBgYGBgQCBAYKAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBwgGBgUHBAcFAwcF
BAQDAwcGBgQFBAQHCAgGBgYGBgYGBwgFBQUFBQMDAwMHBgYGBgYGBgcGBgYG
BgUIBgYGBgYGCAUFBQUFAwIDAwYGBQUFBQUEBgYGBgYGBwYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBEAA4AGQA2gD/AH4APAAYAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAABAAEAAQABAAEAAQAAAAEAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAA
AAAAAAAAEgASAD8AEgASABIAPwASABIAAAAAAAAABAAOABUABQAOABQAFAAV
AA4ABAAAAAAABgGJAEkAJgAQAMgAJAEiAcEAAAAAAAAADAASAAEAAQACAEUA
KQARAC4AAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgABAAEAAQAB
AAEAAQABAAIAAAAAAAAAAQACAAIAAgACAAIAAgACAAEAAAAAAAAAFQAOAB8A
DgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAcAAgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAMAAwAAAAAAAAAIAAgABAAEAAIAAgABAAEAAAAA
AAAADgARABEAFQAVABUAEQARAA4AAAAAAAAABwAEAAQABAAEAAQABAAEAB8A
AAAAAAAADgARABAACAAEAAIAAQABAB8AAAAAAAAADgARABAAEAAOABAAEAAR
AA4AAAAAAAAAEQARABEAEQAfABAAEAAQABAAAAAAAAAAHwABAAEADwAQABAA
EAARAA4AAAAAAAAAHgABAAEAAQAPABEAEQARAA4AAAAAAAAAHwAQABAACAAI
AAQABAACAAIAAAAAAAAADgARABEAEQAOABEAEQARAA4AAAAAAAAADgARABEA
EQAeABAAEAAQABAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAMAAwAAAAAAAAAA
AAAAAwADAAAAAAAAAAMAAgAAAAAAAAAIAAQAAgABAAIABAAIAAAAAAAAAAAA
AAAAAAAAAAAHAAAABwAAAAAAAAAAAAAAAAABAAIABAAIAAQAAgABAAAAAAAA
AAAADgARABAAEAAIAAQABAAAAAQAAAAAAAAAHgAhAC0ALQAtAC0APQABAD4A
AAAAAAAADAASABIAEgAeABIAEgASADMAAAAAAAAADwASABIAEgAOABIAEgAS
AA8AAAAAAAAAHgARAAEAAQABAAEAAQARAB4AAAAAAAAADwASABIAEgASABIA
EgASAA8AAAAAAAAAHwASAAIAAgAGAAIAAgASAB8AAAAAAAAAHwASAAIAAgAG
AAIAAgACAAMAAAAAAAAAHgARAAEAAQAdABEAEQARAA4AAAAAAAAAMwASABIA
EgAeABIAEgASADMAAAAAAAAABwACAAIAAgACAAIAAgACAAcAAAAAAAAAOAAQ
ABAAEAAQABAAEQARAA4AAAAAAAAAIwAiABIACgAGAAYACgASACMAAAAAAAAA
AwACAAIAAgACAAIAAgASAB4AAAAAAAAAYwBVAEkAQQBBAEEAQQBBAGMAAAAA
AAAAGQATABMAFQAVABUAGQAZABMAAAAAAAAADgARABEAEQARABEAEQARAA4A
AAAAAAAADwASABIAEgAOAAIAAgACAAMAAAAAAAAADgARABEAEQARABEAFQAJ
ABYAAAAAAAAADwASABIAEgAOAAoAEgASADMAAAAAAAAAHgARAAEAAQAOABAA
EAARAA8AAAAAAAAAHwAVAAQABAAEAAQABAAEAA4AAAAAAAAAGwARABEAEQAR
ABEAEQARAA4AAAAAAAAAGwARABEAEQARABEAEgAUABgAAAAAAAAAYwBBAEEA
QQBBAEkASQBJADYAAAAAAAAAdwAiABQACAAIABQAIgAiAHcAAAAAAAAAdwAi
ACIAFAAIAAgACAAIABwAAAAAAAAAHwARABAACAAEAAIAAQARAB8AAAAAAAAA
BwABAAEAAQABAAEAAQABAAcAAAAAAAAAAAABAAEAAgACAAQABAAIAAgAAAAA
AAAABwAEAAQABAAEAAQABAAEAAcAAAAAAAAABAAKABEAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAPABAAHwARAC4AAAAAAAAAAwACAAIAAgAOABIA
EgASAA8AAAAAAAAAAAAAAAAAAAAOAAkAAQAJAA4AAAAAAAAAMAAQABAAEAAe
ABEAEQARAD4AAAAAAAAAAAAAAAAAAAAOAAkABwABAA4AAAAAAAAAAAAMAAIA
AgAHAAIAAgACAAIAAAAAAAAAAAAAAAAAAAAeABEAEQARAB4AEAAPAAAAAAAD
AAIAAgAOABIAEgASADMAAAAAAAAAAAAAAAIAAAACAAIAAgACAAcAAAAAAAAA
AAAAAAIAAAACAAIAAgACAAIAAQAAAAAAAAADAAEAMQARAA8AEQARADMAAAAA
AAAAAAADAAIAAgACAAIAAgACAAcAAAAAAAAAAAAAAAAAAAD/ABIBEgESAbsD
AAAAAAAAAAAAAAAAAAAPABIAEgASADsAAAAAAAAAAAAAAAAAAAAOABEAEQAR
AA4AAAAAAAAAAAAAAAAAAAAPABIAEgASAA4AAgADAAAAAAAAAAAAAAA+ABEA
EQARAB4AEAAwAAAAAAAAAAAAAAAOAAkAAQABAAEAAAAAAAAAAAAAAAAAAAAe
AAEADgAQAA8AAAAAAAAAAAAAAAIAAgAHAAIAAgACAAwAAAAAAAAAAAAAAAAA
AAAbABEAEQARAA4AAAAAAAAAAAAAAAAAAAAbABEAEgAUABgAAAAAAAAAAAAA
AAAAAAAbABEAFQAVAAoAAAAAAAAAAAAAAAAAAAAbAAoABAAKABsAAAAAAAAA
AAAAAAAAAAAbABEAEQAeABAAEAAPAAAAAAAAAAAAAAAfAAkABAASAB8AAAAA
AAAABAACAAIAAgABAAIAAgACAAQAAAAAAAAAAQABAAEAAQABAAEAAQABAAEA
AAAAAAAAAQACAAIAAgAEAAIAAgACAAEAAAAAAAAAAAAWAAkAAAAAAAAAAAAA
AAAAAAAAAAAAEAA4AGwA1gDfAe4AfAAoABAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAEAAQABAAEAAQABAAAAAAAAAAAA
BAAOABUABQAVAA4ABAAAAAAADAACAAIAAgAHAAIAAgACAA8AAAAAAAAAHAAi
AAIADwACAA8AAgAiABwAAAAAAAAAQQBBACIAFAAIABwACAAcAAgAAAAAAAAA
CgAEAB4AEQABAA4AEAARAA8AAAAAAAAAHgARAAMADQARABYAGAARAA8AAAAA
AAAACgAEAAAAAAAOAAEABgAIAAcAAAAAAAAAHgAhAC0AIwAjACMALQAhAB4A
AAAAAAAAAgAFAAUACgAAAA8AAAAAAAAAAAAAAAAAAAAoABQACgAFAAoAFAAo
AAAAAAAAAAAAAAAAAAAAAAAPAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAA
AAAAAAAAAAAAAAAAHgAhACcAKwAnACsAKwAhAB4AAAAAAAAADwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AgAHAAIAAAAHAAAAAAAAAAAAAwACAAMAAQADAAAAAAAAAAAAAAAAAAAAAwAC
AAMAAgADAAAAAAAAAAAAAAAAAAAACgAEAD8AEAAIAAQAAgABAD8AAAAAAAAA
AAAAAAAAAAAAABEAEQARAA8AAQABAAAAFgAXABcAFgAUABQAFAAUABQAAAAA
AAAAAAAAAAAAAAAGAAYAAAAAAAAAAAAAAAAACgAEAAAAAAAPAAgABgABAA8A
AAAAAAAAAwACAAIABwAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAAAAAA
AAAAAAAAAAAAAAAFAAoAFAAoABQACgAFAAAAAAAAAAAAfgAJAAkACQA5AAkA
CQAJAH4AAAAAAAAAAAAAAAAAAAB2AEkAOQAJAHYAAAAAAAAACgARABEAEQAK
AAQABAAEAAQAAAAAAAAAAAAAAAQAAAAEAAQAAgABABEAEQAOAAAAAgAEAAAA
DAASABIAHgASADMAAAAAAAAACAAEAAAADAASABIAHgASADMAAAAAAAAABAAK
AAAADAASABIAHgASADMAAAAAAAAAFgAJAAAADAASABIAHgASADMAAAAAAAAA
CgAAAAAADAASABIAHgASADMAAAAAAAAABAAKAAQADAASABIAHgASADMAAAAA
AAAAfAAKAAkACQA/AAkACQAJAHkAAAAAAAAAAAAOAAEAAQABAAEAAQABAA4A
BAAGAAAAAgAEAAAADwACAAYAAgACAA8AAAAAAAAABAACAAAADwACAAYAAgAC
AA8AAAAAAAAABAAKAAAADwACAAYAAgACAA8AAAAAAAAACgAAAAAADwACAAYA
AgACAA8AAAAAAAAAAQACAAAABwACAAIAAgACAAcAAAAAAAAABAACAAAABwAC
AAIAAgACAAcAAAAAAAAAAgAFAAAABwACAAIAAgACAAcAAAAAAAAABQAAAAAA
BwACAAIAAgACAAcAAAAAAAAAHwAiACIAIgAnACIAIgAiAB8AAAAAAAAAFgAJ
AAAAGwATABUAFQAZABsAAAAAAAAAAgAEAAAADgARABEAEQARAA4AAAAAAAAA
CAAEAAAADgARABEAEQARAA4AAAAAAAAABAAKAAAADgARABEAEQARAA4AAAAA
AAAAFgAJAAAADgARABEAEQARAA4AAAAAAAAACgAAAAAADgARABEAEQARAA4A
AAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAHgAxACkAKQAlACUAJQAj
AB4AAAAAAAAAAgAEAAAAGwARABEAEQARAA4AAAAAAAAACAAEAAAAGwARABEA
EQARAA4AAAAAAAAABAAKAAAAGwARABEAEQARAA4AAAAAAAAACgAAAAAAGwAR
ABEAEQARAA4AAAAAAAAACAAEAAAAGwARAAoABAAEAA4AAAAAAAAAAQABAAcA
CQAJAAkABwABAAEAAAAAAAAADgARABEACQAFAAkAEQARAA0AAAAAAAAAAAAC
AAQAAAAPABAAHwARAC4AAAAAAAAAAAAIAAQAAAAPABAAHwARAC4AAAAAAAAA
AAAEAAoAAAAPABAAHwARAC4AAAAAAAAAAAAWAAkAAAAPABAAHwARAC4AAAAA
AAAAAAAAAAoAAAAPABAAHwARAC4AAAAAAAAABAAKAAQAAAAPABAAHwARAC4A
AAAAAAAAAAAAAAAAAAA3AEgAPgAJAHYAAAAAAAAAAAAAAAAAAAAOAAkAAQAJ
AA4ABAAGAAAAAAACAAQAAAAOAAkABwABAA4AAAAAAAAAAAAIAAQAAAAOAAkA
BwABAA4AAAAAAAAAAAAEAAoAAAAOAAkABwABAA4AAAAAAAAAAAAAAAoAAAAO
AAkABwABAA4AAAAAAAAAAAAAAAEAAgAAAAIAAgACAAcAAAAAAAAAAAAAAAIA
AQAAAAEAAQABAAMAAAAAAAAAAAAAAAIABQAAAAIAAgACAAcAAAAAAAAAAAAA
AAAABQAAAAIAAgACAAcAAAAAAAAAAAAAABgABwAKABEAEQARAA4AAAAAAAAA
AAAAABYACQAAAA8AEQARABsAAAAAAAAAAAAAAAIABAAAAAYACQAJAAYAAAAA
AAAAAAAAAAQAAgAAAAYACQAJAAYAAAAAAAAAAAAAAAIABQAAAAYACQAJAAYA
AAAAAAAAAAAAAAoABQAAAAYACQAJAAYAAAAAAAAAAAAAAAAACgAAAAYACQAJ
AAYAAAAAAAAAAAAAAAAAAgAAAAcAAAACAAAAAAAAAAAAAAAAAAAAAAAOABkA
FQATAA4AAAAAAAAAAAAAAAIABAAAABsAEQARAA4AAAAAAAAAAAAAAAgABAAA
ABsAEQARAA4AAAAAAAAAAAAAAAQACgAAABsAEQARAA4AAAAAAAAAAAAAAAAA
CgAAABsAEQARAA4AAAAAAAAAAAAAAAgABAAAABsAEQARAB4AEAAPAAAAAAAA
AAEAAQAHAAkACQAJAAcAAQABAAAAAAAAAAAACgAAABsAEQARAB4AEAAPAAAA
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/serif-16.sqf.__mime.

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
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
191
192
193
194
195
196




































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 serif-16.sqf
EA0DAg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAIFCggNCwME
BQcHAwUDCAcHBwcHBwcHBwcEBAcFBwgKCQkJCQkJCAgECAkICQkJCAkICAkJ
CQsJCwsFCAUFBQQHCAcICAcICAQDCAMNCAgICAcIBggICQkICAYDBggNAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgcICAsIBwgJBQkHBgkH
BQcFBQsICAUIBQUHCgwLCAkJCQkJCQoJCAgICAUFBQUJCQkJCQkJBwkJCQkJ
CQcJBwcHBwcHCwcICAgIBAQEBAgICAgICAgHCAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAAACAAcAD4AIwBdgN/B54D/AHYAHAA
IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAQABAAEAAQABAAEAAQAAAAAAAQAAAAAAAAAFAAUAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAD/ACQAJAAkAP8AJAAkACQAAAAA
AAAABAAEAB4AJQAFAAUABQAeACQAJAAkACUAHgAEAAQAAAAAAAAADAQSAhIB
jABAACAAEAOIBIQEAgMBAAAAAAAAAAAAAAA8AEIAAgACAAQACAAUAKIAQQCh
AB4BAAAAAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BAACAAEAAQABAAEAAQABAAEAAgAEAAAAAAAAAAAAAAABAAIABAAEAAQABAAE
AAQABAACAAEAAAAAAAAAFQAOAB8ADgAVAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAQABAAfAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAMAAwACAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAAg
ACAAEAAQAAgACAAEAAQAAgACAAEAAAAAAAAAAAAAAA4AEQARABEAFQAVABUA
EQARABEADgAAAAAAAAAAAAAABwAEAAQABAAEAAQABAAEAAQABAAfAAAAAAAA
AAAAAAAOABEAEAAQABAACAAEAAIAAQABAB8AAAAAAAAAAAAAAA4AEQAQABAA
EAAOABAAEAAQABEADgAAAAAAAAAAAAAAEQARABEAEQARAB8AEAAQABAAEAAQ
AAAAAAAAAAAAAAAfAAEAAQABAA8AEAAQABAAEAARAA4AAAAAAAAAAAAAAB4A
AQABAAEAAQAPABEAEQARABEADgAAAAAAAAAAAAAAHwAQABAAEAAQABAAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAOABEAEQARABEADgARABEAEQARAA4AAAAAAAAA
AAAAAA4AEQARABEAEQAeABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAMAAwAA
AAAAAAAAAAAAAwADAAAAAAAAAAAAAAAAAAAAAwADAAAAAAAAAAAAAAADAAMA
AgAAAAAAAAAAAAAAEAAIAAQAAgABAAIABAAIABAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAA8AAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAEAAgAEAAgAEAAIAAQA
AgABAAAAAAAAAAAAAAAAAB4AIQAgACAAIAAYAAQABAAAAAAABAAAAAAAAAAA
AAAAfgCBAJkApQClAKUApQClAHkAAQD+AAAAAAAAAAAAAABgAFAASABIAEQA
RAB+AEIAQQBBAOMAAAAAAAAAAAAAAB8AIgBCAEIAIgAeACIAQgBCAEIAPwAA
AAAAAAAAAAAAPABCAMEAAQABAAEAAQABAMEAQgA8AAAAAAAAAAAAAAAfACIA
QgBCAEIAQgBCAEIAQgBCAD8AAAAAAAAAAAAAAH8AQgACAAIAEgAeABIAAgAC
AEIAfwAAAAAAAAAAAAAAfwBCAAIAAgASAB4AEgACAAIAAgAHAAAAAAAAAAAA
AAA+ACEAIQABAAEAAQA5ACEAIQAhAB4AAAAAAAAAAAAAAGMAIgAiACIAIgA+
ACIAIgAiACIAYwAAAAAAAAAAAAAABwACAAIAAgACAAIAAgACAAIAAgAHAAAA
AAAAAAAAAABwACAAIAAgACAAIAAgACEAIQAhAB8AAAAAAAAAAAAAAOMAQgAi
ABIACgAGAAoAEgAiAEIA4wAAAAAAAAAAAAAAAwABAAEAAQABAAEAAQABAAEA
IQA/AAAAAAAAAAAAAABBAGMAYwBVAFUASQBJAEEAQQBBAOMAAAAAAAAAAAAA
AOMAQwBDAEUARQBJAEkAUQBRAGEA4wAAAAAAAAAAAAAAHAAiAEEAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAPABIAIgAiACIAEgAOAAIAAgACAAcAAAAA
AAAAAAAAABwAIgBBAEEAQQBBAEEAQQBRACIAXACAAAAAAAAAAAAADwASACIA
IgAiABIADgASACIAIgB3AAAAAAAAAAAAAAA+ACEAAQABAAEAHgAgACAAIAAh
AB8AAAAAAAAAAAAAAH8ASQAIAAgACAAIAAgACAAIAAgAHAAAAAAAAAAAAAAA
4wBBAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAAAAAAADjAEEAQQBBAEEAQQBB
AEEAIgAUAAgAAAAAAAAAAAAAAIMDAQEBAQEBAQEBAQEBEQERAaoARAAAAAAA
AAAAAAAAxwGCAEQAKAAoABAAKAAoAEQAggDHAQAAAAAAAAAAAACDAwEBggBE
ACgAEAAQABAAEAAQADgAAAAAAAAAAAAAAP8BAQGAAEAAIAAQAAgABAACAAEB
/wEAAAAAAAAAAAAABwABAAEAAQABAAEAAQABAAEAAQAHAAAAAAAAAAAAAAAB
AAEAAgACAAQABAAIAAgAEAAQACAAAAAAAAAAAAAAAAcABAAEAAQABAAEAAQA
BAAEAAQABwAAAAAAAAACAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAAAAAAAQACAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOABEAEAAeABEAGQA2
AAAAAAAAAAAAAAADAAIAAgACABoAJgAiACIAIgAiAB8AAAAAAAAAAAAAAAAA
AAAAAAAAHgARAAEAAQABABEAHgAAAAAAAAAAAAAAMAAQABAAEAAeABEAEQAR
ABEAEQA+AAAAAAAAAAAAAAAAAAAAAAAAAB4AIQAhAB8AAQAhAD4AAAAAAAAA
AAAAABwAEgACAAIADwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAB+
ACEAIQAhACEAPgAgACEAIQAfAAAAAAADAAIAAgACAA4AEgAiACIAIgAiAHcA
AAAAAAAAAAAAAAAAAAACAAAAAwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAAA
AAIAAAADAAIAAgACAAIAAgACAAEAAAAAAAAAAAAAAAMAAgACADIAEgAKAAYA
CgASADsAAAAAAAAAAAAAAAAAAwACAAIAAgACAAIAAgACAAIABwAAAAAAAAAA
AAAAAAAAAAAAAADNATMCIQQhBCEEIQRzDgAAAAAAAAAAAAAAAAAAAAAAAA0A
EwAhACEAIQAhAHMAAAAAAAAAAAAAAAAAAAAAAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAAAAAAfACIAIgAiACIAIgAeAAIAAgADAAAAAAAAAAAA
AAAAAD4AEQARABEAEQARAB4AEAAQADAAAAAAAAAAAAAAAAAADwASAAIAAgAC
AAIABwAAAAAAAAAAAAAAAAAAAAAAAAA+ACEAAQAeACAAIQAfAAAAAAAAAAAA
AAAAAA4AAgACAA8AAgACAAIAAgASAAwAAAAAAAAAAAAAAAAAAAAAAAAAcwAh
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAAAAABzACEAIQASABIADAAMAAAA
AAAAAAAAAAAAAAAAAAAAAOMAQQBBACoAKgAUABQAAAAAAAAAAAAAAAAAAAAA
AAAAYwAiABQACAAUACIAYwAAAAAAAAAAAAAAAAAAAAAAAABzACEAIQAhACEA
PgAgACAAIQAfAAAAAAAAAAAAAAAAAD8AIQAYAAYAAQAhAD8AAAAAAAAAAAAA
AAwAAgACAAIAAgABAAIAAgACAAIADAAAAAAAAAAAAAAAAQABAAEAAQABAAEA
AQABAAEAAQABAAAAAAAAAAAAAAADAAQABAAEAAQACAAEAAQABAAEAAMAAAAA
AAAAAAAAAAAAAAAmABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABwAPgA
jAF2A38HngP8AdgAcAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAABAAAAAAABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAEAAQADgAV
AAUABQAFABUADgAEAAQAAAAAAAAAHAAiAAIAAgAPAAIAAgACAAIAAgA/AAAA
AAAAAAAAAAA8AEIAAQABAAcAAQAHAAEAAQBCADwAAAAAAAAAAAAAAAEBAQGC
AEQAKAAQAP4AEAD+ABAAEAAAAAAAAAAKAAQAAAA+ACEAAQABAB4AIAAgACAA
IQAfAAAAAAAAAAAAAAAAAA4AEQABAA4AEQARAA4AEAARAA4AAAAAAAAAAAAA
AAAACgAEAAAAPgAhAAEAHgAgACEAHwAAAAAAAAAAAAAAHAAiAEEAWQBFAEUA
RQBZAEEAIgAcAAAAAAAAAAMABAAHAAUABwAAAAcAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAUAAoABQACgAFAAoAFAAoAFAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAB8AEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAABwAIgBBAF0AVQBNAFUAVQBBACIAHAAAAAAAAAAfAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABQACAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAHwAEAAQAAAAfAAAAAAAAAAAA
AAADAAQAAgABAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMABAACAAQAAwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAQAAAA/wGBAEAAIAAQAAgABAACAAEB
/wEAAAAAAAAAAAAAAAAAAAAAAAAAACEAIQAhACEAIQB/AAEAAQAAAAAAAAAu
AC8ALwAvAC4AKAAoACgAKAAoACgAAAAAAAAAAAAAAAAAAAAAAAAABgAGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAUAAgAAAA/ACEAGAAGAAEAIQA/AAAAAAAA
AAMAAgACAAIABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAFAAIAAAAHAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAoAFAAoAFAAKAAUAAoABQAA
AAAAAAAAAAAAAAD8AJIAEQARAFEAcQBRABEAEQCSAPwAAAAAAAAAAAAAAAAA
AAAAAAAA7gERAhEC8QERABEC7gMAAAAAAAAAACgAAAABAQEBggBEACgAEAAQ
ABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAIAAYAAQABAAEAIQAeAAAA
AAAQACAAAAAwACgAJAAkACIAPgAhACEAcwAAAAAAAAAAACAAEAAAADAAKAAk
ACQAIgA+ACEAIQBzAAAAAAAAAAAAEAAoAAAAMAAoACQAJAAiAD4AIQAhAHMA
AAAAAAAAAAAmABkAAAAwACgAJAAkACIAPgAhACEAcwAAAAAAAAAAAAAAKAAA
ADAAKAAkACQAIgA+ACEAIQBzAAAAAAAAABAAKAAQAAAAMAAoACQAJAAiAD4A
IQAhAHMAAAAAAAAAAAAAAPgAlAASABEAUQB/AFEAEQARAJEA8wAAAAAAAAAA
AAAAfABCAAEAAQABAAEAAQABAAEAQgB8AAgADAAAAAQACAAAAD8AIQABAAkA
DwAJAAEAAQAhAD8AAAAAAAAAEAAIAAAAPwAhAAEACQAPAAkAAQABACEAPwAA
AAAAAAAIABQAAAA/ACEAAQAJAA8ACQABAAEAIQA/AAAAAAAAAAAAFAAAAD8A
IQABAAkADwAJAAEAAQAhAD8AAAAAAAAAAQACAAAABwACAAIAAgACAAIAAgAC
AAIABwAAAAAAAAAEAAIAAAAHAAIAAgACAAIAAgACAAIAAgAHAAAAAAAAAAIA
BQAAAAcAAgACAAIAAgACAAIAAgACAAcAAAAAAAAAAAAFAAAABwACAAIAAgAC
AAIAAgACAAIABwAAAAAAAAAAAAAAHwAiAEIAQgBCAEcAQgBCAEIAQgA/AAAA
AAAAACYAGQAAAOMAQwBFAEUASQBJAFEAUQBhAOMAAAAAAAAABAAIAAAAHAAi
AEEAQQBBAEEAQQBBACIAHAAAAAAAAAAQAAgAAAAcACIAQQBBAEEAQQBBAEEA
IgAcAAAAAAAAAAgAFAAAABwAIgBBAEEAQQBBAEEAQQAiABwAAAAAAAAAJgAZ
AAAAHAAiAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQAAAAcACIAQQBBAEEA
QQBBAEEAIgAcAAAAAAAAAAAAAAAAAAAAEQAKAAQACgARAAAAAAAAAAAAAAAA
AAAAAAAAAFwAIgBRAEkASQBJAEkASQBFACIAHQAAAAAAAAAEAAgAAADjAEEA
QQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAOMAQQBBAEEAQQBBAEEAQQAi
ABwAAAAAAAAACAAUAAAA4wBBAEEAQQBBAEEAQQBBACIAHAAAAAAAAAAAABQA
AADjAEEAQQBBAEEAQQBBAEEAIgAcAAAAAAAAABAACAAAAOMAQQAiABQACAAI
AAgACAAIABwAAAAAAAAAAAAAAAEAAQAPABEAEQARAA8AAQABAAEAAQAAAAAA
AAAAAAAADgARACEAIQAZAAUAOQBBAEEAQQA9AAAAAAAAAAAAAAAAAAIABAAA
AA4AEQAQAB4AEQAZADYAAAAAAAAAAAAAAAAACAAEAAAADgARABAAHgARABkA
NgAAAAAAAAAAAAAAAAAEAAoAAAAOABEAEAAeABEAGQA2AAAAAAAAAAAAAAAA
ABYACQAAAA4AEQAQAB4AEQAZADYAAAAAAAAAAAAAAAAAAAAKAAAADgARABAA
HgARABkANgAAAAAAAAAAAAAAAAAEAAoABAAOABEAEAAeABEAGQA2AAAAAAAA
AAAAAAAAAAAAAAAAAO4AEQEQAf4AEQAZAfcBAAAAAAAAAAAAAAAAAAAAAAAA
HgARAAEAAQABABEAHgAEAAYAAAAAAAAAAAAEAAgAAAAeACEAIQAfAAEAIQA+
AAAAAAAAAAAAAAAAABAACAAAAB4AIQAhAB8AAQAhAD4AAAAAAAAAAAAAAAAA
BAAKAAAAHgAhACEAHwABACEAPgAAAAAAAAAAAAAAAAAAABQAAAAeACEAIQAf
AAEAIQA+AAAAAAAAAAAAAAAAAAEAAgAAAAMAAgACAAIAAgACAAcAAAAAAAAA
AAAAAAAABAACAAAAAwACAAIAAgACAAIABwAAAAAAAAAAAAAAAAACAAUAAAAD
AAIAAgACAAIAAgAHAAAAAAAAAAAAAAAAAAAABQAAAAMAAgACAAIAAgACAAcA
AAAAAAAAAAAAAAAANgAJABQAHgAhACEAIQAhACEAHgAAAAAAAAAAAAAAAAAW
AAkAAAAPABIAIgAiACIAIgB3AAAAAAAAAAAAAAAAAAQACAAAAB4AIQAhACEA
IQAhAB4AAAAAAAAAAAAAAAAACAAEAAAAHgAhACEAIQAhACEAHgAAAAAAAAAA
AAAAAAAEAAoAAAAeACEAIQAhACEAIQAeAAAAAAAAAAAAAAAAABYACQAAAB4A
IQAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAKAAAAHgAhACEAIQAhACEAHgAA
AAAAAAAAAAAAAAAAAAQAAAAfAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAC4AEQApAC0AJQAiAB0AAAAAAAAAAAAAAAAAAAAEAAgAAABzACEAIQAh
ACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAAHMAIQAhACEAIQAeAAAAAAAAAAAA
AAAAAAAABAAKAAAAcwAhACEAIQAhAB4AAAAAAAAAAAAAAAAAAAAIAAQAAABz
ACEAIQAhACEAHgAAAAAAAAAAAAAAAAAAAAgABAAAAHMAIQAhACEAPgAgACAA
IQAfAAAAAAAAAAEAAQABAB0AIwAhACEAIQAjAB0AAQABAAEAAAAAAAAAAAAA
ABQAAABzACEAIQAhAD4AIAAgACEAHwA=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/serif-8.sqf.__mime.

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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 serif-8.sqf
CAYCAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgMEBgQGBgID
AwYEAwMCBAQEBAQFBAUFBQUCAgQEBAUFBQUFBQUFBQUDBAYEBwcFBgUGBQYG
BQYGBgYDBAMEAwMFBQQFBQQFBQMDBgMIBgUGBgYFBAYFBgUFBQQCBAUGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgUFBgYFBAQGBAYEBAYE
BAQDBAUEBgIEBAMGBgYGBAUFBQUFBQYFBAQEBAIDAwMGBQUFBQUFBAYFBQUF
BgQFBAQEBAQEBgQEBAQEAwIDAwQEBQUFBQUEBAUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDgobHwoOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAgICAgACAAAFBQAAAAAAAAofCh8KAAAABA4BBggH
AgAAEwsEGhkAAA4BAhUJFgAAAQEAAAAAAAACAQEBAQIAAAECAgICAQAAFQ4V
AAAAAAAAAgcCAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAEAAAQEAgIBAQAA
BgkNCwkGAAADAgICAgcAAAMEBAIBBwAAAwQCBAQDAAAMCgkPCAgAAAcBAwQE
AwAADgEHCQkGAAAPCAQEAgIAAAYJBgkJBgAABgkJDggHAAAAAQAAAQAAAAAB
AAAAAQEAAAQCAQIEAAAAAAcABwAAAAABAgQCAQAABwgIBgACAAAPCQ0NAQ8A
AAgMCg4JGwAABwoGCgoHAAAGCQEBCQYAAAcKCgoKBwAADwIGAgoPAAAPAgYC
AgMAAA4BAR0JDgAAGwkPCQkbAAAHAgICAgcAAA4EBAQFAgAAEwoGBgoTAAAB
AQEBAQcAAGM2KioiYwAAZyYqKjJzAAAGCQkJCQYAAA8SEg4CAwAABgkJCQUK
AAAPEhIOEjMAAA4JAgQJBwAAHxUEBAQOAAAbEREREQ4AABsJCQkKDAAAGxER
ERUKAAAbCgQEChsAABsRCgQEDgAAHwkEAhEfAAADAQEBAQMAAAEBAgIEBAAA
AwICAgIDAAACBQAAAAAAAAAAAAAABwAAAQIAAAAAAAAABwgOCRYAAAMCBgoK
BwAAAAYJAQkGAAAMBAYFBQ4AAAAGCQ8BDgAAAAwCBwIDAAAAAA4JCgwJBwMC
BgoKCwAAAAIAAwIHAAAAAgADAgIBAAMCEg4SEwAAAwICAgIHAAAAAD9KStsA
AAAADxISMwAAAAAGCQkGAAAAAA8SEg4CAwAAHgkJDggYAAANEgICAAAADgkG
CQcAAAACBwICBgAAAAAbEREOAAAAABsJCgQAAAAAGxEVCgAAAAAJBgYJAAAA
ABsJCQ4IBwAPCQYBDwAABgIDAwIGAAABAQEBAQEAAAMCBgYCAwAAAAoFAAAA
AAAOChsfCg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAQABAQEBAAQOBQUOBAAMAgcCAg8AAAwSBwIXDAAAEQoEDgQOBAAK
BA4BBggHAAYBAwUGBAMABQIGAQMEAwAOERUTFQ4AAAMFBwAHAAAAABQKBQoU
AAAAAAcEAAAAAAAABwAAAAAADhMVExUOAAAHAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAADBAIBBwAAAAMEBwQDAAAACgQPBAIPAAAAAAAFBQcBABYXFhQUFAAA
AAAAAQAAAAAFAgcGAQcAAAMCBwAAAAAAAgUCBwAAAAAABQoUCgUAAB4FDQUF
HgAAAAA+GQk+AAAKEQoEBAQAAAACAAIBAQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAAEg0GCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUPBQUdAAAOAQEBAQ4E
BgIEBwEDAQcABAIHAQMBBwACBQcBAwEHAAUABwEDAQcAAQIBAQEBAAACAQIC
AgIAAAIFAgICAgAABQACAgICAAAPEhcSEg8AAAoFAAsNCQAAAgQGCQkJBgAE
AgYJCQkGAAQKBgkJCQYACgUGCQkJBgAKAAYJCQkGAAAABQIFAAAADhkVFRMO
AAACBAkJCQkGAAQCCQkJCQYAAgUJCQkJBgAKAAkJCQkGAAgEEQoEBAQAAQcJ
CQcBAAAHCQUJEQ0AAAECAAYFCwAABAIABgULAAACBQAGBQsAAAoFAAYFCwAA
BQAABgULAAACBQIGBQsAAAAAHi0dMwAAAAAGAQEGAwACBAAHBQMGAAQCAAcF
AwYAAgUABwUDBgAFAAAHBQMGAAECAAICAgAAAgEAAQEBAAACBQACAgIAAAUA
AAICAgAACgUMCwkGAAAKBQADBQUAAAECBgkJBgAABAIGCQkGAAAECgYJCQYA
AAoFBgkJBgAABQAGCQkGAAAAAgAHAAIAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAABQAACQkGAAAEAgAJCQ4IBwABBwkJBwEACgAACQkOCAc=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/symbol-12.sqf.__mime.

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 symbol-12.sqf
DAkDAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgYGBgYGBgYGBgYGBgcG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAADgEPys1Kx4AAAAAAB4tPy0hNSseAAAAABIhEiESIRIA
AAAABA4VBQ4UFBUOBAAAEhUKCAQCChUJAAAADBIBAQIFFQkeAAAABAQAAAAA
AAAAAAAADAICAgICAgIMAAAABggICAgICAgGAAAAFQ4fDhUAAAAAAAAAAAAA
BAQfBAQAAAAAAAAAAAAAAAAMCAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAMAAAA
ABAQCAgEBAICAAAAAB8RMTExER8AAAAAAB8TMzMzEx8AAAAAAB8XNzc3Fx8A
AAAAAB8fPz8/Hx8AAAAABwICAAAAAAAAAAAABwICAAAAAAEBAAAABwICAAAE
BAUFAAAABwICEBAUFBUVAAAADhEREQ4REREOAAAADhERER4QEBAQAAAAAAAA
ACo9Ly0tAAAAAAAAACs9KykpAAAAAA4VHTEuKiI+AAAAAAAAAA4ADgAAAAAA
AAIECBAIBAIAAAAADhEQEAgEBAAEAAAADhEVFRUVHQEeAAAAAAAADBISDAAA
AAAAAAAAHhISHgAAAAAAAAAAHxEKBAAAAAAAAAAABAoRHwAAAAAAAAAYFBIU
GAAAAAAAAAAGChIKBgAAAAAAAAARCgQKEQAAAAAAAAAfERERHwAAAAAAHAgI
CAgICAgcAAAAEBAQEBAQEREOAAAAEREJBQMFCRERAAAAAQEBAQEBAQEfAAAA
GxUVERERERERAAAAERMTFRUVGRkRAAAADhEREREREREOAAAADxEREQ8BAQEB
AAAADhERERERFQkWAAAADxEREQ8JERERAAAADhEBAQ4QEBEOAAAAHwQEBAQE
BAQEAAAAEREREREREREOAAAAEREREREREhQYAAAAEREREREVFRUKAAAAEREK
BAQKERERAAAAERERCgQEBAQEAAAAHxAQCAQCAQEfAAAADgICAgICAgIOAAAA
AAEBAgIEBAgIAAAADggICAgICAgOAAAABAoRAAAAAAAAAAAAAAAAAAAAAAAf
AAAABAgAAAAAAAAAAAAAAAAADB4eDAAAAAAAAAAAHh4eHgAAAAAAAAAAHx8O
BAAAAAAAAAAABA4fHwAAAAAAAAAYHB4cGAAAAAAAAAAGDh4OBgAAAAAAAAAb
Hw4fGwAAAAAAAAAfFR8VHwAAAAAAAAAEAAQEBAQEAAAAAAAIAAgICAgIBAAA
AAEBEREPERERAAAAAAQEBAQEBAQEAAAAAAAAAA8VFRUVAAAAAAAAAA8RERER
AAAAAAAAAA4REREOAAAAAAAAAA8REREPAQEAAAAAAB4REREeEBAAAAAAABwC
AgICAAAAAAAAAB4BDhAPAAAAAAAEBA4EBAQYAAAAAAAAABEREREOAAAAAAAA
ABEREhQYAAAAAAAAABERFRUKAAAAAAAAABEKBAoRAAAAAAAAABERER4QEA8A
AAAAAB8IBAIfAAAACAQEBAIEBAQIAAAACAgICAgICAgIAAAAAgQEBAgEBAQC
AAAAABYJAAAAAAAAAAAADB4zLTc/Nx4MAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIHAAAAAAAA
AAIHAAIHAAAAAAIHAAIHAAIHAAAAOBAAAAAAAAAAAAAAOBAAAAAAAAIHAAAA
OBAAAAIHAAIHAAAAOBIHAAIHAAIHAAAAOBAAOBAAAAAAAAAAOBAAOBAAAAIH
AAAAOBAAOBIHAAIHAAAAOBIHOBIHAAIHAAAAOBAAOBAAOBAAAAAAcCAAcCAA
cCIHAAAAOBAAOBIHOBIHAAAAOBIHOBIHOBIHAAAAAAAEBB8EBB8AAAAADAAI
AAwAAAAAAAAADAAIAAwAAAAAAAAACgQfEAgEAgEfAAAAAAAAAAAREREPAQEA
FhcXFhQUFBQUAAAAAAAAAAwMAAAAAAAACgQAAB4QDAIeAAAADAgIHAAAAAAA
AAAACBQIABwAAAAAAAAAAAUKFCgUCgUAAAAAHgUFBQ0FBQUeAAAAAAAAABoV
DQUaAAAAChEREQoEBAQEAAAAAAAEAAQEAgEREQ4AAgQADhERHxERAAAACAQA
DhERHxERAAAABAoADhERHxERAAAAFgkADhERHxERAAAACgAADhERHxERAAAA
BAoEDhERHxERAAAAHgUFBQ8FBQUdAAAAAB4BAQEBAQEeBAYAAgQAHgIOAgIe
AAAABAIAHgIOAgIeAAAABAoAHgIOAgIeAAAACgAAHgIOAgIeAAAAAgQABAQE
BAQEAAAACAQABAQEBAQEAAAABAoABAQEBAQEAAAACgAABAQEBAQEAAAADhIS
EhcSEhIOAAAAFgkAExMVFRkZAAAAAgQADhEREREOAAAACAQADhEREREOAAAA
BAoADhEREREOAAAAFgkADhEREREOAAAACgAADhEREREOAAAAAAAAEQoEChEA
AAAADhkZFRUVExMOAAAAAgQAEREREREOAAAACAQAEREREREOAAAABAoAERER
EREOAAAACgAAEREREREOAAAACAQAEREKBAQEAAAAAQEPERERDwEBAAAADhER
CQUJERENAAAAAAIEAA4REREuAAAAAAgEAA4REREuAAAAAAQKAA4REREuAAAA
ABYJAA4REREuAAAAAAAKAA4REREuAAAABAoEAA4REREuAAAAAAAAAAsUDgUa
AAAAAAAAAB4BAQEeBAYAAAQIABwSDgIcAAAAABAIABwSDgIcAAAAAAgUABwS
DgIcAAAAAAAUABwSDgIcAAAAAAACBAAEBAQEAAAAAAAIBAAEBAQEAAAAAAAE
CgAEBAQEAAAAAAAACgAEBAQEAAAAAAAYBwoREREOAAAAAAAWCQAPERERAAAA
AAAECAAMEhIMAAAAAAAIBAAMEhIMAAAAAAAECgAMEhIMAAAAAAAUCgAMEhIM
AAAAAAAAFAAMEhIMAAAAAAAABAAOAAQAAAAAAAAAAA4ZFRMOAAAAAAACBAAR
EREOAAAAAAAIBAAREREOAAAAAAAECgAREREOAAAAAAAACgAREREOAAAAAAAI
BAAREREeEA8AAAABAQ8REREPAQEAAAAACgAREREeEA8A
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/symbol-16.sqf.__mime.

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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 symbol-16.sqf
EA0DAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAIHDZrb293fzYcCAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAQEAwCAj/q9Wr1YF+AAAAAH6Bvb29gZWplamVgX4AAAAkQoFC
JEKBQiRCgUIkAAAAAAg+SQkJCT5ISEk+CAAAAAAAAABDIxAIBGJhAAAAAAAA
AAAAHiEBAgRKUSFeAAAAAAAICAAAAAAAAAAAAAAAAAAAIBAIBAQEBAQIECAA
AAAAAAQIECAgICAgEAgEAAAAAAAqHD4cKgAAAAAAAAAAAAAAAAAAAAgIPggI
AAAAAAAAAAAAAAAAAAAAABAQCAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAA
AAAAGBgAAAAAAEBAICAQEAgIBAQCAAAAAAB/QUHBwcFBQX8AAAAAAAAAf0dD
x8PHQ0d/AAAAAAAAAH9fT9/P309ffwAAAAAAAAB/f3////9/f38AAAAAAAAA
QUFBQUF/QEBAQEAAAAAAAH8BAQEBf0BAQEB/AAAAAAB/AQEBAX9BQUFBfwAA
AAAAf0BAQEBAQEBAQEAAAAAAAH9BQUFBf0FBQUF/AAAAAAB/QUFBQX9AQEBA
QAAAAAAAAAAAGBgAAAAAGBgAAAAAAAAAABgYAAAAABgYEAAAAAAgEAgEAgQI
ECAAAAAAAAAAAAAAAAA+AD4AAAAAAAAAAAIECBAgEAgEAgAAAAAAAAA8QkBA
OAgICAAIAAAAAAAAfkFdVVVVVVV9AX4AAAAAAD5BQUFBf0FBQUFBAAAAAAAf
IUFBQT9BQUFBPwAAAAAAPkFBAQEBAQEBQT4AAAAAAB8hQUFBQUFBQUE/AAAA
AAB/AQEBAQ8BAQEBfwAAAAAAfwEBAQEPAQEBAQEAAAAAAD5BAQEBAXlBQUE+
AAAAAABBQUFBQX9BQUFBQQAAAAAAfwgICAgICAgICH8AAAAAAEBAQEBAQEBB
QSIcAAAAAABBIREJBQMFCREhQQAAAAAAAQEBAQEBAQEBAX8AAAAAAEFjY1VV
SUlBQUFBAAAAAABBQ0NFRUlJUVFhYQAAAAAAHCJBQUFBQUFBIhwAAAAAAB8h
QUFBIR8BAQEBAAAAAAAcIkFBQUFBQVEiXIAAAAAAHyFBQUEhHyFBQUEAAAAA
AD5BAQEBPkBAQEE+AAAAAAB/CAgICAgICAgICAAAAAAAQUFBQUFBQUFBIhwA
AAAAAEFBQUFBQUFBIhQIAAAAAABBQUFBQUFJSUlVIgAAAAAAQUEiFBQIFBQi
QUEAAAAAAEFBQSIUCAgICAgIAAAAAAB/QEAgEAgEAgEBfwAAAAAAPAQEBAQE
BAQEBDwAAAAAAAICBAQICBAQICBAAAAAAAA8ICAgICAgICAgPAAAAAgUAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAACBAAAAAAAAAAAAAAAAAAAAAA
AAAAAD5BQH5BYV4AAAAAAAEBAQE9Q0FBQUE/AAAAAAAAAAAAPkEBAQFBPgAA
AAAAQEBAQH5BQUFBQX4AAAAAAAAAAAA+QUE/AUE+AAAAAAB4BAQEHwQEBAQE
BAAAAAAAAAAAAHxCQUFBQX5AQT4AAAEBAQEfIUFBQUFBAAAAAAAAAAgADAgI
CAgIHAAAAAAAAAAQABAQEBAQEBAIBgAAAAEBAQFBIREPESEhAAAAAAAAGBAQ
EBAQEBAQOAAAAAAAAAAAADZJSUlJSUkAAAAAAAAAAAAeIUFBQUFBAAAAAAAA
AAAAHCJBQUEiHAAAAAAAAAAAAB4hQUFBQT8BAQEAAAAAAAAcIkFBQUF+QEBA
AAAAAAAAPUMBAQEBAQAAAAAAAAAAAD5BAT5AQT4AAAAAAAAICAg+CAgICAgw
AAAAAAAAAAAAQUFBQUFBPgAAAAAAAAAAAEFBQSIiFAgAAAAAAAAAAABBQUEq
KhQUAAAAAAAAAAAAQSIUCBQiQQAAAAAAAAAAAEFBQUFBQX5AIB8AAAAAAAB/
QCAYBgF/AAAAAAA4BAQEBAIEBAQEOAAAAAAACAgICAgICAgICAgAAAAAABwg
ICAgQCAgICAcAAAAAAAAAEY5AAAAAAAAAAAAAAAACBw2a29vd382HAgAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgICAgI
CAgAAAAAAAgIPkkJCQlJPggIAAAAOEQEBB4EBAQEBH4AAAAAADhEAgIPAg8C
AkQ4AAAAAABBQUEiFAg+CD4ICAAAABQIAD5BAQE+QEBAQT4AAAAAAAA8QgI8
QkI8QEI8AAAAAAAAFAgAPkEBPkBBPgAAAAAAHCJBWUVFRVlBIhwAAAAMEBwU
HAAcAAAAAAAAAAAAAAAAUCgUCgUKFChQAAAAAAAAAAAAAAA+ICAAAAAAAAAA
AAAAAAA8AAAAAAAAAAAAAAAcIkFdVU1VVUEiHAAAAD4AAAAAAAAAAAAAAAAA
AAAIFAgAAAAAAAAAAAAAAAAAAAAAAAgIPggIAD4AAAAAAAwQCAQcAAAAAAAA
AAAAAAAMEAgQDAAAAAAAAAAAAAAAFAgAf0BAIBAIBAIBfwAAAAAAAAAAAABB
QUFBQT8BAQAAAC4vLy8uKCgoKCgoAAAAAAAAAAAAGBgAAAAAAAAAAAAAABQI
AD8gGAYBAT8AAAAMCAgIHAAAAAAAAAAAAAAACBQIABwAAAAAAAAAAAAAAAAA
AAUKFChQKBQKBQAAAAAAAHwKCQkJOQkJCQp8AAAAAAAAAAAANklJOQlJNgAA
AAAUAEFBQSIUCAgICAgAAAAAAAAAAAgACAgGAQEBIR4ABAgAHCJBQUF/QUFB
QQAAABAIABwiQUFBf0FBQUEAAAAUABwiQUFBf0FBQUFBAAAAJhkAHCJBQUF/
QUFBQQAAAAAUABwiQUFBf0FBQUEAAAAIFAgcIkFBQX9BQUFBAAAAAAB4DAoJ
CT8JCQkJeQAAAAAAPEIBAQEBAQEBQjwIDAAECAB/AQEBHwEBAQF/AAAAEAgA
fwEBAR8BAQEBfwAAAAgUAH8BAQEfAQEBAX8AAAAAFAB/AQEBHwEBAQF/AAAA
BAgAfwgICAgICAgIfwAAABAIAH8ICAgICAgICH8AAAAIFAB/CAgICAgICAh/
AAAAABQAfwgICAgICAgIfwAAAAAAHyFBQUFHQUFBQT8AAAAmGQBBQ0VFSUlR
UWFhAAAABAgAHCJBQUFBQUEiHAAAABAIABwiQUFBQUFBIhwAAAAIFAAcIkFB
QUFBQSIcAAAAJhkAHCJBQUFBQUEiHAAAAAAUABwiQUFBQUFBIhwAAAAAAAAA
IhQIFCIAAAAAAAAAAABcIlFJSUlJSUUiHQAAAAQIAEFBQUFBQUFBIhwAAAAQ
CABBQUFBQUFBQSIcAAAACBQAQUFBQUFBQUEiHAAAAAAUAEFBQUFBQUFBIhwA
AAAQCABBQSIUCAgICAgIAAAAAAACAj5CQkI+AgICAgAAAAAADhEhIRkFOUFB
QT0AAAAAAAAECAA+QUB+QWFeAAAAAAAAEAgAPkFAfkFhXgAAAAAAAAgUAD5B
QH5BYV4AAAAAAAAsEgA+QUB+QWFeAAAAAAAAABQAPkFAfkFhXgAAAAAAAAgU
CBwiIDwiMiwAAAAAAAAAAAA2SUg+CUk2AAAAAAAAAAAAPEIBAQFCPAgMAAAA
AAQIAD5BQT8BQT4AAAAAAAAQCAA+QUE/AUE+AAAAAAAABAoAPkFBPwFBPgAA
AAAAAAAUAD5BQT8BQT4AAAAAAAAECAAMCAgICAg+AAAAAAAAEAgADAgICAgI
PgAAAAAAAAgUAAwICAgICD4AAAAAAAAUAAAMCAgICAg+AAAAAAAANgkUPkFB
QUFBPgAAAAAAACwSAB4hQUFBQUEAAAAAAAAECAA+QUFBQUE+AAAAAAAAEAgA
PkFBQUFBPgAAAAAAAAQIAD5BQUFBQT4AAAAAAAAECAA+QUFBQUE+AAAAAAAA
BAgAPkFBQUFBPgAAAAAAAAAIAD4ACAAAAAAAAAAAAAAAAABeIVFJRUI9AAAA
AAAAAAQIAEFBQUFBPgAAAAAAAAAIBABBQUFBQT4AAAAAAAAACBQAQUFBQUE+
AAAAAAAAABAIAEFBQUFBPgAAAAAAAAAQCABBQUFBQX5AQD8AAAABAQE9Q0FB
QUM9AQEBAAAAAAAUAEFBQUFBfkBAPw==
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/font/symbol-8.sqf.__mime.

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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 symbol-8.sqf
CAYCAQUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUBAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBDhsVFxsOAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAABAQEBAAEAAAKCgAAAAAAAAofCgofCgAABA4FDhQO
AAAACQwGAwkAAAYJAgUJFgAABAQAAAAAAAAEAgICAgQAAAQICAgIBAAAFQ4V
AAAAAAAAAAQOBAAAAAAAAAAABAQAAAAADgAAAAAAAAAAAAQAAAgEBAICAQAA
BgkNCwkGAAAGBAQEBA4AAA8IDwEBDwAADwgOCAgPAAAJCQ8ICAgAAA8BDwgI
DwAADwEPCQkPAAAPCAgICAgAAA8JDwkJDwAADwkPCAgIAAAAAAQAAAQAAAAA
BAAABAQAAAgEAgQIAAAAAA4ADgAAAAACBAgEAgAABgkIBgACAAAPCQ0NAQ8A
AAYJCQ8JCQAABwkHCQkHAAAOAQEBAQ4AAAcJCQkJBwAADwEBBwEPAAAPAQEH
AQEAAA4BAQ0JBgAACQkJDwkJAAAOBAQEBA4AAAwICAgJBgAACQkFAwUJAAAB
AQEBAQ8AABEbFREREQAACQsLDQ0JAAAGCQkJCQYAAAcJCQcBAQAABgkJCQUK
AAAHCQkHCQkAAA4BBggIBwAADgQEBAQEAAAJCQkJCQYAAAkJCQkKBAAAERER
ERUKAAAJCQkGCQkAAAkJCQYEBAAADwgIBgEPAAAOAgICAg4AAAECAgQECAAA
DggICAgOAAAEChEAAAAAAAAAAAAAHwAAAgQAAAAAAAAADwgPCQ4AAAEBBwkJ
BwAAAAAOAQEOAAAICA4JCQ4AAAAGCQ8BDgAAAA4CBwICAAAADgkJCQ4IBwAB
AQcJCQAABAAGBAQOAAAEAAQEBAQEAwABCQkHCQAABgQEBAQOAAAACxUVFRUA
AAAHCQkJCQAAAAYJCQkGAAAABwkJCQcBAQAOCQkJDggIAAYJAQEBAAAADgEG
CAcAAAACDgICDAAAAAAJCQkGAAAAAAkJCgQAAAAAEREVCgAAAAAJBgYJAAAA
AAkJCQ4IBwAPCAYBDwAADgIDAwIOAAAEBAQEBAQAAAcEDAwEBwAAAAAWCQAA
AAAOGxUXGw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABAAEBAQEAAQOBQUOBAAMEgcCAh8AABwCBwcCHAAAEQoOBA4EAAAK
BgEGCAcAAA4BBgYIBwAACgQOAQ4HAAAOERUTFQ4AAAYOAA4AAAAAABQKBQoU
AAAAAA8IAAAAAAAADgAAAAAADhMVExUOAAAPAAAAAAAAAAIFAgAAAAAAAAIH
AgcAAAAGCAQCDgAAAAYIBggGAAAACgQPBAIPAAAAAAkJCQcBABYXFxYUFAAA
AAAGBgAAAAAKBA4IBg4AAAYEBAQOAAAABAoEAA4AAAAABQoUCgUAAB4FDQUF
HgAAAB4VHQUeAAAKEQoEBAQAAAACAAIBCQYAAgQGCQ8JAAAEAgYJDwkAAAQK
BgkPCQAACgUGCQ8JAAAKAAYJDwkAAAYJBgkPCQAAHgUFDwUdAAAOAQEBAQ4E
BgIEDwcBDwAABAIPBwEPAAACBQ8HAQ8AAAoADwcBDwAAAgQOBAQOAAAIBA4E
BA4AAAQKDgQEDgAACgAOBAQOAAAGCgsKCgYAABYJCQsNCQAAAgQGCQkGAAAE
AgYJCQYAAAIFBgkJBgAAFgkGCQkGAAAKAAYJCQYAAAAACgQKAAAABg0NCwsG
AAACBAkJCQYAAAQCCQkJBgAABAoJCQkGAAAKAAkJCQYAAAgEEQoEBAAAAQcJ
CQcBAAAGCQUJEQ0AAAIEBgkJFgAABAIGCQkWAAAECgYJCRYAABYJBgkJFgAA
CgAGCQkWAAAGCQYJCRYAAAAAHhUNHgAAAAAOAQEOBAYCBA4JBw4AAAQCDgkH
DgAABAoGCQcOAAAKAAYJBw4AAAIEAAQEBAAACAQABAQEAAAECgAEBAQAAAAK
AAQEBAAACgUGDQkGAAAWCQYJCQkAAAIEBgkJBgAABAIGCQkGAAAECgYJCQYA
ABYJBgkJBgAACgAGCQkGAAAABAAfAAQAAAAABg0LBgAAAgQACQkGAAAEAgAJ
CQYAAAQKAAkJBgAACgAACQkGAAAIBAAJCQ4IBwAAAQcJCQcBCgAACQkOCAc=
====

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/AcceleratedGraphics.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This class forwards graphics operations to the host native display API
 * which provides a single instance of accelerated graphics.
 *
 * @since 2018/11/19
 */
public final class AcceleratedGraphics
	extends SerializedGraphics
{
	/**
	 * Initializes for the given display.
	 *
	 * @since 2018/11/19
	 */
	public AcceleratedGraphics()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object serialize(GraphicsFunction __func, Object... __args)
	{
		// Forward serialized arguments to the destination host
		return NativeDisplayAccess.accelGfxFunc(0,
			__func.ordinal(), __args);
	}
	
	/**
	 * Returns the instance for the given display ID.
	 *
	 * @param __did The display ID.
	 * @return The accelerated graphics instance.
	 * @throws UnsupportedOperationException If accelerated graphics are not
	 * supported.
	 * @since 2018/11/19
	 */
	public static final AcceleratedGraphics instance()
		throws UnsupportedOperationException
	{
		// {@squirreljme.error EB0a Accelerated graphics operations are not
		// supported for this display. (The display ID)}
		if (!NativeDisplayAccess.accelGfx(0))
			throw new UnsupportedOperationException("EB0a " + 0);
		
		// Effectively has "new" state
		return new AcceleratedGraphics();
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/AdvancedBufferAdapter.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This is the base class for buffer adapters, instances of these classes are
 * used to translate the 32-bit integer format to lower quality buffer formats.
 *
 * @since 2019/03/24
 */
public abstract class AdvancedBufferAdapter
{
	/**
	 * Adapts the buffer data.
	 *
	 * @since 2019/03/24
	 */
	public abstract void adapt();
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/AdvancedFunction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558














































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This contains the various functions that may be set by
 * {@link AdvancedGraphics} and called accordingly when needed.
 *
 * All functions operate on pixels which are backed by a 32-bit integer
 * array.
 *
 * @since 2019/03/24
 */
public enum AdvancedFunction
{
	/** Do nothing. */
	NOP
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
		}
	},
	
	/** Fill rectangle, no blending. */
	FILLRECT_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int pac = __ag.paintcolorhigh;
			int[] buffer = __ag.buffer;
			int pitch = __ag.pitch,
				offset = __ag.offset,
				__x = __vi[0],
				__y = __vi[1],
				__ex = __vi[2],
				__ey = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			
			for (int y = __y; y < __ey; y++)
				for (int dest = offset + (y * pitch) + __x, pex = dest + __w;
					dest < pex; dest++)
					buffer[dest] = pac;
		}
	},
	
	/** Fill rectangle, with blending. */
	FILLRECT_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int pac = __ag.paintalphacolor;
			int[] buffer = __ag.buffer;
			int pitch = __ag.pitch,
				offset = __ag.offset,
				__x = __vi[0],
				__y = __vi[1],
				__ex = __vi[2],
				__ey = __vi[3],
				__w = __vi[4],
				__h = __vi[5],
				sa = __ag.paintalpha,
				na = (sa ^ 0xFF),
				srb = ((pac & 0xFF00FF) * sa),
				sgg = (((pac >>> 8) & 0xFF) * sa);
			
			// Blend each color
			int mod = 0;
			for (int y = __y; y < __ey; y++)
				for (int dest = offset + (y * pitch) + __x, pex = dest + __w;
					dest < pex; dest++)
				{
					int dcc = buffer[dest],
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					buffer[dest] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** Character bitmap, no blending. */
	CHARBITMAP_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __color = __vi[0] | 0xFF_000000,
				__dsx = __vi[1],
				__dsy = __vi[2],
				__bytesperscan = __vi[3],
				__scanoff = __vi[4],
				__scanlen = __vi[5],
				__lineoff = __vi[6],
				__linelen = __vi[7];
			byte[] __bmp = (byte[])__va[0];
			
			int[] data = __ag.buffer;
			int offset = __ag.offset,
				pitch = __ag.pitch;
			
			// Treat lens as end indexes
			int origscanlen = __scanlen;
			__scanlen += __scanoff;
			__linelen += __lineoff;
			
			// Remember the old scan offset, because we reset
			int resetscanoff = __scanoff;
			
			// Determine the draw pointer for this line
			int basep = offset + (__dsy * pitch) + __dsx;
			
			// Base source offset line according to the line offset
			int bi = __lineoff * __bytesperscan;
			
			// Drew each line
			for (; __lineoff < __linelen; __lineoff++, __dsy++)
			{
				// Reset parameters for this line
				int p = basep;
				__scanoff = resetscanoff;
				
				// Draw each scan from the bitmap
				for (; __scanoff < __scanlen; __scanoff++, p++)
				{
					// Get the byte that represents the scan here
					byte b = __bmp[bi + (__scanoff >>> 3)];	
					
					// If there is a pixel here, draw it
					if ((b & (1 << (__scanoff & 0x7))) != 0)
						data[p] = __color;
				}
				
				// Move the source and dest pointers to the next line
				basep += pitch;
				bi += __bytesperscan;
			}
		}
	},
	
	/** Character bitmap, with blending. */
	CHARBITMAP_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			AdvancedFunction.CHARBITMAP_NOBLEND.function(__ag, __vi, __va);
		}
	},
	
	/** Draw line, no blend or dots. */
	LINE_NOBLEND_NODOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintcolorhigh,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			for (;;)
			{
				// Nothing left to draw?
				if (__x1 >= __x2 &&
					((neg && __y1 <= __y2) || (!neg && __y1 >= __y2)))
					break;
				
				data[dest] = color;
				
				// Increase X
				int brr = err;
				if (brr > -dx)
				{
					err -= dy;
					__x1++;
					dest++;
				}
		
				// Increase Y
				if (brr < dy)
				{
					err += dx;
					__y1 += sy;
					dest += ssy;
				}
			}
		}
	},
	
	/** Draw line, no blend with dots. */
	LINE_NOBLEND_DOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintcolorhigh,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			/*for (boolean blip = true;; blip = !blip)*/
			for (int blip = 0, nblip = ~0;; nblip = blip, blip = ~blip)
			{
				// Nothing left to draw?
				if (__x1 >= __x2 &&
					((neg && __y1 <= __y2) || (!neg && __y1 >= __y2)))
					break;
				
				/*if (blip)
					data[dest] = color;*/
				data[dest] = (data[dest] & blip) | (color & nblip);
				
				// Increase X
				int brr = err;
				if (brr > -dx)
				{
					err -= dy;
					__x1++;
					dest++;
				}
		
				// Increase Y
				if (brr < dy)
				{
					err += dx;
					__y1 += sy;
					dest += ssy;
				}
			}
		}
	},
	
	/** Draw line, blend with no dots. */
	LINE_BLEND_NODOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			if (true)
			{
				AdvancedFunction.LINE_NOBLEND_NODOT.function(__ag, __vi, __va);
				return;
			}
			
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintalphacolor,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			throw new todo.TODO();
		}
	},
	
	/** Draw line, blend with dots. */
	LINE_BLEND_DOT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			// Not implemented, use basic function
			if (true)
			{
				AdvancedFunction.LINE_NOBLEND_DOT.function(__ag, __vi, __va);
				return;
			}
			
			int __x1 = __vi[0],
				__y1 = __vi[1],
				__x2 = __vi[2],
				__y2 = __vi[3];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch,
				dx = __x2 - __x1;
			
			int dy = __y2 - __y1;
			boolean neg;
			if ((neg = dy < 0))
				dy = -dy;	
			
			int sy = (__y1 < __y2 ? 1 : -1),
				ssy = iw * sy,
				err = (dx > dy ? dx : -dy) >> 2,
				color = __ag.paintalphacolor,
				dest = __ag.offset + (iw * __y1) + __x1;
			
			throw new todo.TODO();
		}
	},
	
	/** RGB Tile, no blending. */
	RGBTILE_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
					data[dp] = __b[src] | 0xFF_000000;
		}
	},
	
	/** RGB Tile, blending. */
	RGBTILE_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src] | 0xFF_000000,
						srb = ((pac & 0xFF00FF) * 0xFF),
						sgg = (((pac >>> 8) & 0xFF) * 0xFF),
						dcc = data[dp],
						xrb = (srb + ((dcc & 0xFF00FF) * 0x00)) >>> 8,
						xgg = (((sgg +
							(((dcc >>> 8) & 0xFF) * 0x00)) + 1) * 257) >>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** ARGB Tile, no blending. */
	ARGBTILE_NOBLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src],
						sa = pac >>> 24,
						na = (sa ^ 0xFF),
						srb = ((pac & 0xFF00FF) * sa),
						sgg = (((pac >>> 8) & 0xFF) * sa),
						dcc = data[dp] | 0xFF_000000,
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** ARGB Tile, blending. */
	ARGBTILE_BLEND
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/03/24
		 */
		public void function(AdvancedGraphics __ag, int[] __vi, Object[] __va)
		{
			int __o = __vi[0],
				__l = __vi[1],
				__x = __vi[2],
				__y = __vi[3],
				__w = __vi[4],
				__h = __vi[5];
			int[] __b = (int[])__va[0];
			
			int[] data = __ag.buffer;
			int iw = __ag.pitch;
			
			// The distance from the end of a row to the scanline, this way the
			// source variable does not need an extra copy
			int eosa = __l - __w;
			
			// Draw tile data
			int dest = __ag.offset + (__y * iw) + __x, src = 0, ey = __y + __h;
			for (; __y < ey; __y++, dest += iw, src += eosa)
				for (int spend = src + __w, dp = dest; src < spend;
					dp++, src++)
				{
					int pac = __b[src],
						sa = pac >>> 24,
						na = (sa ^ 0xFF),
						srb = ((pac & 0xFF00FF) * sa),
						sgg = (((pac >>> 8) & 0xFF) * sa),
						dcc = data[dp],
						xrb = (srb + ((dcc & 0xFF00FF) * na)) >>> 8,
						xgg = (((sgg + (((dcc >>> 8) & 0xFF) * na)) + 1) * 257)
							>>> 16;
					
					data[dp] = ((xrb & 0xFF00FF) | ((xgg & 0xFF) << 8));
				}
		}
	},
	
	/** End. */
	;
	
	/**
	 * Executes the graphics function.
	 *
	 * @param __ag The advanced graphics state.
	 * @param __vi Integer arguments.
	 * @param __va Object arguments.
	 * @since 2019/03/24
	 */
	public abstract void function(AdvancedGraphics __ag, int[] __vi,
		Object[] __va);
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/AdvancedGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This class contains the advanced graphics functions which uses
 * pre-determined functions to determine how to draw something.
 *
 * @since 2019/03/24
 */
public class AdvancedGraphics
	extends Graphics
{
	/** Clipping above. */
	private static final int _CLIP_ABOVE =
		1;
	
	/** Clipping below. */
	private static final int _CLIP_BELOW =
		2;
	
	/** Clip right. */
	private static final int _CLIP_RIGHT =
		4;
	
	/** Clip left. */
	private static final int _CLIP_LEFT =
		8;
	
	/** The array buffer. */
	protected final int[] buffer;
	
	/** The length of the buffer. */
	protected final int bufferlen;
	
	/** The width of the image. */
	protected final int width;
	
	/** The height of the image. */
	protected final int height;
	
	/** The pitch of the image. */
	protected final int pitch;
	
	/** The buffer offset. */
	protected final int offset;
	
	/** The number of elements that consist of pixel data. */
	protected final int numelements;
	
	/** Physical end of the buffer. */
	protected final int lastelement;
	
	/** Is there an alpha channel? */
	protected final boolean hasalphachannel;
	
	/** Absolute translated X coordinate. */
	protected final int abstransx;
	
	/** Absolute translated Y coordinate. */
	protected final int abstransy;
	
	/** The current stroke style. */
	protected int strokestyle;
	
	/** Is a dot stroke being used? */
	protected boolean dotstroke;
	
	/** Translated X coordinate. */
	protected int transx;
	
	/** Translated Y coordinate. */
	protected int transy;
	
	/** The starting X clip. */
	protected int clipsx;
	
	/** The starting Y clip. */
	protected int clipsy;
	
	/** The ending X clip. */
	protected int clipex;
	
	/** The ending Y clip. */
	protected int clipey;
	
	/** The clip width. */
	protected int clipw;
	
	/** The clip height. */
	protected int cliph;
	
	/** The current font, null means default. */
	protected Font font;
	
	/** The current blending mode. */
	protected int blendmode;
	
	/** Could blending be done? */
	protected boolean candoblending;
	
	/** Is blending actually going to be done? */
	protected boolean doblending;
	
	/** The current color. */
	protected int color;
	
	/** The painting alpha color. */
	protected int paintalpha;
	
	/** The color to use for painting. */
	protected int paintcolor;
	
	/** Paint color with the alpha channel set to the max. */
	protected int paintcolorhigh;
	
	/** The alpha color and normal color for painting. */
	protected int paintalphacolor;
	
	/** Function for filled rectangle. */
	protected AdvancedFunction funcfillrect;
	
	/** Function for drawing characters. */
	protected AdvancedFunction funccharbmp;
	
	/** Function for drawing lines. */
	protected AdvancedFunction funcline;
	
	/** RGB tile. */
	protected AdvancedFunction funcrgbtile;
	
	/** ARGB tile. */
	protected AdvancedFunction funcargbtile;
	
	/**
	 * Initializes the graphics.
	 *
	 * @param __buf The buffer.
	 * @param __alpha Does the buffer actually use the alpha channel?
	 * @param __aba Advanced buffer adapter, used to translate the internal
	 * integer based buffer to other formats.
	 * @param __w The image width.
	 * @param __h The image height.
	 * @param __p The image pitch.
	 * @param __o The buffer offset.
	 * @param __atx Absolute X translation.
	 * @param __aty Absolute Y translation.
	 * @throws IllegalArgumentException If the input parameters are not
	 * correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public AdvancedGraphics(int[] __buf, boolean __alpha,
		AdvancedBufferAdapter __aba,
		int __w, int __h, int __p, int __o, int __atx, int __aty)
		throws IllegalArgumentException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB0b Invalid width and/or height specified.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("EB0b");
		
		// {@squirreljme.error EB0c The pitch is less than the width.}
		if (__p < __w)
			throw new IllegalArgumentException("EB0c");
		
		// {@squirreljme.error EB0d The specified parameters exceed the bounds
		// of the array. (The width; The height; The offset; The pitch;
		// The array length; The number of elements in the image)}
		int numelements = (__p * __h),
			lastelement = __o + numelements,
			buflen = __buf.length;
		if (__o < 0 || lastelement > buflen)
			throw new ArrayIndexOutOfBoundsException(
				String.format("EB0d %d %d %d %d %d %d", __w, __h,
				__o, __p, buflen, numelements));
		
		// Set
		this.buffer = __buf;
		this.bufferlen = buflen;
		this.width = __w;
		this.height = __h;
		this.pitch = __p;
		this.offset = __o;
		this.numelements = numelements;
		this.lastelement = lastelement;
		this.hasalphachannel = __alpha;
		
		// Setup absolute translation and initialize the base translation
		// which is at the absolute origin
		this.abstransx = __atx;
		this.abstransy = __aty;
		this.transx = __atx;
		this.transy = __aty;
		
		// Initial clipping rectangle has the image bounds
		this.clipsx = 0;
		this.clipsy = 0;
		this.clipex = __w;
		this.clipey = __h;
		this.clipw = __w;
		this.cliph = __h;
		
		// Reset all initial functions
		this.resetParameters(true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		// Translate
		__x += this.transx;
		__y += this.transy;
		
		// Get right end coordinates
		int ex = __x + __w,
			ey = __y + __h;
		
		// Swap X if lower
		if (ex < __x)
		{
			int boop = __x;
			__x = ex;
			ex = boop;
		}
		
		// Same for Y
		if (ey < __y)
		{
			int boop = __y;
			__y = ey;
			ey = boop;
		}
		
		// Never go past the end of the viewport because pixels will never
		// be drawn in negative regions
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		// Additionally do not go past the edge ever that way the end
		// clipping point is always valid
		int width = this.width,
			height = this.height;
		if (ex > width)
			ex = width;
		if (ey > height)
			ey = height;
		
		// Get the old clipping bounds
		int oldclipsx = this.clipsx,
			oldclipsy = this.clipsy,
			oldclipex = this.clipex,
			oldclipey = this.clipey;
		
		// Only set the clipping bounds if they exceed the previous ones
		if (__x > oldclipsx)
			this.clipsx = (oldclipsx = __x);
		if (__y > oldclipsy)
			this.clipsy = (oldclipsy = __y);
		if (ex < oldclipex)
			this.clipex = (oldclipex = ex);
		if (ey < oldclipey)
			this.clipey = (oldclipey = ey);
		
		// Set width/height
		this.clipw = clipex - oldclipsx;
		this.cliph = clipey - oldclipsy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		// Need translation coordinates
		int tx = this.transx,
			ty = this.transy;
		
		// Image size
		int iw = this.width,
			ih = this.height;
		
		// Translate all coordinates
		__sx += tx;
		__sy += ty;
		__dx += tx;
		__dy += ty;
		
		// Perform needed anchoring
		if ((__anchor & Graphics.HCENTER) != 0)
			__dx -= (__w >> 1);
		else if ((__anchor & Graphics.RIGHT) != 0)
			__dx -= __w;
		if ((__anchor & Graphics.VCENTER) != 0)
			__dy -= (__h >> 1);
		else if ((__anchor & Graphics.BOTTOM) != 0)
			__dy -= __h;
		
		// End coordinates for both
		int sex = __sx + __w,
			sey = __sx + __h,
			dex = __dx + __w,
			dey = __dx + __h;
		
		// {@squirreljme.error EB0e Source region for area copy is out of
		// bounds.}
		if (__sx < 0 || __sy < 0 || sex > iw || sey > ih)
			throw new IllegalArgumentException("EB0e");
		
		this.__unimplemented(__dx, __dy, "copyArea");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		this.__unimplemented(__x, __y, "drawArc");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		this.__unimplemented(__x, __y, "drawARGB16");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawChar(char __s, int __x, int __y, int __anchor)
	{
		// Same as drawing strings
		this.drawString(new String(new char[]{__s}, 0, 1),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Same as drawing string
		this.drawString(new String(__s, __o, __l),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__i, 0, 0, __i.getWidth(), __i.getHeight(), 0,
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		// Translate all coordinates
		int transx = this.transx,
			transy = this.transy;
		__x1 += transx;
		__y1 += transy;
		__x2 += transx;
		__y2 += transy;
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex,
			clipey = this.clipey;
		
		// Perform Cohen-Sutherland line clipping
		for (;;)
		{
			// Determine points that lie outside the box
			int outa = AdvancedGraphics.__csOut(__x1, __y1,
					clipsx, clipsy, clipex - 1,clipey - 1),
				outb = AdvancedGraphics.__csOut(__x2, __y2, clipsx,
					clipsy, clipex - 1, clipey - 1);
			
			// Both points are outside the box, do nothing
			if ((outa & outb) != 0)
				return;
			
			// Both points are inside the box, use this line
			if (outa == 0 && outb == 0)
				break;
			
			// Only the second point is outside, swap the points so that the
			// first point is outside and the first is not
			if (outa == 0)
			{
				// Swap X
				int boop = __x1;
				__x1 = __x2;
				__x2 = boop;
				
				// Swap Y
				boop = __y1;
				__y1 = __y2;
				__y2 = boop;
				
				// Swap clip flags
				boop = outb;
				outb = outa;
				outa = boop;
			}
			
			// The point is clipped
			if (outa != 0)
			{
				// Differences of points
				int dx = __x2 - __x1,
					dy = __y2 - __y1;
				
				// Clips above the box
				if ((outa & _CLIP_ABOVE) != 0)
				{
					__x1 += dx * (clipey - __y1) / dy;
					__y1 = clipey - 1;
				}
			
				// Clips below
				else if ((outa & _CLIP_BELOW) != 0)
				{
					__x1 += dx * (clipsy - __y1) / dy;
					__y1 = clipsy;
				}
			
				// Clips the right side
				else if ((outa & _CLIP_RIGHT) != 0)
				{
					__y1 += dy * (clipex - __x1) / dx;
					__x1 = clipex - 1;
				}
			
				// Clips the left side
				else if ((outa & _CLIP_LEFT) != 0)
				{
					__y1 += dy * (clipsx - __x1) / dx;
					__x1 = clipsx;
				}
			}
		}
		
		// Have lines which always go to the right
		if (__x2 < __x1)
		{
			int boopx = __x1,
				boopy = __y1;
			__x1 = __x2;
			__y1 = __y2;
			__x2 = boopx;
			__y2 = boopy;
		}
		
		// The resulting line should never be out of bounds
		if (__x1 < clipsx || __x2 < clipsx || __y1 < clipsy || __y2 < clipsy ||
			__x1 > clipex || __x2 > clipex || __y1 > clipey || __y2 > clipey)
			return;
		
		// Forward depending on blending and/or dots
		try
		{
			this.funcline.function(this,
				new int[]{__x1, __y1, __x2, __y2},
				null);
		}
		
		// Exception happened when drawing a line
		catch (IndexOutOfBoundsException e)
		{
			todo.DEBUG.note("Line (%d, %d) -> (%d, %d)", __x1, __y1,
				__x2, __y2);
			e.printStackTrace();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Transform
		__x += this.transx;
		__y += this.transy;
		
		// Determine ending position
		int ex = __x + __w,
			ey = __y + __h;
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex,
			clipey = this.clipey;
		
		// Box is completely outside the bounds of the clip, do not draw
		if (ex < clipsx || __x >= clipex || ey < clipsy || __y >= clipey)
			return;
		
		// Determine sub-clipping area
		int subx = __x - clipsx,
			suby = __y - clipsy;
		
		// Clip into bounds
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		if (ex >= clipex)
			ex = clipex;
		if (ey >= clipey)
			ey = clipey;
		
		// New tile size
		int tw = ex - __x,
			th = ey - __y;
		
		// We might have multiplied alpha blending, or just normal blending
		// If __alpha is true then this is 32-bit RGBA!
		if (__alpha)
			this.funcargbtile.function(this,
				new int[]{__off, __scanlen, __x, __y, tw, th},
				new Object[]{__data});
		else
			this.funcrgbtile.function(this,
				new int[]{__off, __scanlen, __x, __y, tw, th},
				new Object[]{__data});
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		this.__unimplemented(__x, __y, "drawRGB16");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRect(int __x, int __y, int __w, int __h)
	{
		// The width and height are increased by a single pixel
		__w += 1;
		__h += 1;
		
		// For now just cheat and draw four lines
		int ex = __x + __w,
			ey = __y + __h;
		
		this.drawLine(__x, __y, ex, __y);
		this.drawLine(__x, ey, ex, ey);
		this.drawLine(__x, __y, __x, ey);
		this.drawLine(ex, __y, ex, ey);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.__drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wsrc, __hsrc, true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.__drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest, false);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		this.__unimplemented(__x, __y, "drawRoundRect");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__drawText(this.__buildText(__s), __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __s.length())
			throw new StringIndexOutOfBoundsException("IOOB");
		
		this.__drawText(this.__buildText(__s.substring(__o, __o + __l)),
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		this.__drawText(__t, __x, __y, 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		this.__unimplemented(__x, __y, "fillArc");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillRect(int __x, int __y, int __w, int __h)
	{
		// Get actual end points
		int ex = __x + __w,
			ey = __y + __h;
			
		// Translate all coordinates
		int transx = this.transx,
			transy = this.transy;
		__x += transx;
		__y += transy;
		ex += transx;
		ey += transy;
		
		// Force lower X
		if (ex < __x)
		{
			int boop = ex;
			ex = __x;
			__x = boop;
		}
		
		// Force lower Y
		if (ey < __y)
		{
			int boop = ey;
			ey = __y;
			__y = boop;
		}
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex - 1,
			clipey = this.clipey - 1;
		
		// Never clip past the left/top
		if (__x < clipsx)
			__x = clipsx;
		if (__y < clipsy)
			__y = clipsy;
		
		// Never clip past the right/bottom
		if (ex > clipex)
			ex = clipex;
		if (ey > clipey)
			ey = clipey;
		
		// Calculate actual dimensions used
		__w = ex - __x;
		__h = ey - __y;
		
		// Call function
		this.funcfillrect.function(this,
			new int[]{__x, __y, ex, ey, __w, __h},
			null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		this.__unimplemented(__x, __y, "fillRoundRect");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		this.__unimplemented(__x1, __y1, "fillTriangle");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getAlpha()
	{
		return (this.color >> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getAlphaColor()
	{
		return this.color;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getBlendingMode()
	{
		return this.blendmode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getBlueComponent()
	{
		return (this.color) & 0xFF;
	}
	
	/**
	 * Returns the element in the input array which represents the end of the
	 * clipping rectangle.
	 *
	 * @return The element which contains the end of the clipping rectangle.
	 * @since 2019/03/24
	 */
	public final int getClipElementEnd()
	{
		// Subtract one from the Y because it is on the next row
		return this.offset + (((this.pitch * (this.clipey - 1)) +
			(this.clipex)));
	}
	
	/**
	 * Returns the element in the input array which represents the start of
	 * the clipping rectangle.
	 *
	 * @return The element which contains the start of the clipping rectangle.
	 * @since 2019/03/24
	 */
	public final int getClipElementStart()
	{
		return this.offset + (((this.pitch * this.clipsy) + this.clipsx));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipHeight()
	{
		return this.cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipWidth()
	{
		return this.clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipX()
	{
		return this.clipsx - this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getClipY()
	{
		return this.clipsy - this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getColor()
	{
		return this.color & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getDisplayColor(int __rgb)
	{
		// Just use the original input color
		return __rgb | 0xFF_000000;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public Font getFont()
	{
		Font rv = this.font;
		if (rv == null)
			rv = Font.getDefaultFont();
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getGrayScale()
	{
		return (getRedComponent() + getGreenComponent() +
			getBlueComponent()) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getGreenComponent()
	{
		return (this.color >> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getRedComponent()
	{
		return (this.color >> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getStrokeStyle()
	{
		return this.strokestyle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getTranslateX()
	{
		return this.transx - this.abstransx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public int getTranslateY()
	{
		return this.transy - this.abstransy;
	}
	
	/**
	 * Resets all parameters of the graphics output.
	 *
	 * @param __clip If {@code true} then the clip is also reset.
	 * @since 2019/03/24
	 */
	public void resetParameters(boolean __clip)
	{
		// Clear translation
		this.transx = this.abstransx;
		this.transy = this.abstransy;
	
		// Reset clip also
		if (__clip)
		{
			int width = this.width,
				height = this.height;
			
			this.clipsx = 0;
			this.clipsy = 0;
			this.clipex = width;
			this.clipey = height;
			this.clipw = width;
			this.cliph = height;
		}
		
		// Always reset these
		this.setAlphaColor(0xFF000000);
		this.setBlendingMode(SRC_OVER);
		this.setStrokeStyle(SOLID);
		this.setFont(null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.setAlphaColor(__a, getRedComponent(), getGreenComponent(),
			getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		// Set the original color directly
		this.color = __argb;
		
		// Determine if blending is to be performed or it is just directly
		// setting values, blending is only performed if the alpha channel
		// is not fully opaque and blending is permitted
		int alpha = (__argb >>> 24);
		boolean doblending = (this.candoblending && alpha != 0xFF);
		
		// Set internal blend mode
		this.doblending = doblending;
		
		// Set painting colors
		this.paintalpha = alpha;
		this.paintcolor = __argb & 0xFFFFFF;
		this.paintcolorhigh = __argb | 0xFF000000;
		this.paintalphacolor = __argb;
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0f Color out of range. (Alpha; Red; Green;
		// Blue)}
		if (__a < 0 || __a > 255 || __r < 0 || __r > 255 ||
			__g < 0 || __g > 255 || __b < 0 || __b > 255)
			throw new IllegalArgumentException(String.format(
				"EB0f %d %d %d %d", __a, __r, __g, __b));
		
		// Set
		this.setAlphaColor((__a << 24) | (__r << 16) | (__g << 8) | __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		boolean candoblending,
			oldcandoblending = this.candoblending;
		
		// Just use source pixels
		if (__m == SRC)
		{
			// {@squirreljme.error EB0g Cannot set the overlay blending mode
			// because this graphics context does not have the alpha channel.}
			if (!this.hasalphachannel)
				throw new IllegalArgumentException("EB0g");
			
			candoblending = false;
		}
		
		// Perform blending since this is the default mode
		else if (__m == SRC_OVER)
		{
			candoblending = true;
		}
		
		// {@squirreljme.error EB0h Unknown blending mode.}
		else
			throw new IllegalArgumentException("EB0h");
		
		// Set
		this.blendmode = __m;
		this.candoblending = candoblending;
		
		// If the blending mode has changed then possible blending tables
		// need to be recalculated accordingly
		if (candoblending != oldcandoblending)
			this.setAlphaColor(this.getAlphaColor());
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setClip(int __x, int __y, int __w, int __h)
	{
		// Translate
		__x += this.transx;
		__y += this.transy;
		
		// Get right end coordinates
		int ex = __x + __w,
			ey = __y + __h;
		
		// Swap X if lower
		if (ex < __x)
		{
			int boop = __x;
			__x = ex;
			ex = boop;
		}
		
		// Same for Y
		if (ey < __y)
		{
			int boop = __y;
			__y = ey;
			ey = boop;
		}
		
		// Never go past the end of the viewport because pixels will never
		// be drawn in negative regions
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		// Additionally do not go past the edge ever that way the end
		// clipping point is always valid
		int width = this.width,
			height = this.height;
		if (ex > width)
			ex = width;
		if (ey > height)
			ey = height;
		
		// Set
		this.clipsx = __x;
		this.clipsy = __y;
		this.clipex = ex;
		this.clipey = ey;
		
		// Set width/height
		this.clipw = ex - __x;
		this.cliph = ey - __y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setColor(int __rgb)
	{
		this.setAlphaColor((this.getAlphaColor() & 0xFF_000000) |
			(__rgb & 0x00_FFFFFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.setAlphaColor(getAlpha(), __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setFont(Font __a)
	{
		// Just set it
		this.font = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setGrayScale(int __v)
	{
		this.setAlphaColor(getAlpha(), __v, __v, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void setStrokeStyle(int __a)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0i Illegal stroke style.}
		if (__a != SOLID && __a != DOTTED)
			throw new IllegalArgumentException("EB0i");
		
		// Set
		this.strokestyle = __a;
		this.dotstroke = (__a == DOTTED);
		
		// Update functions
		this.__updateFunctions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public void translate(int __x, int __y)
	{
		this.transx += __x;
		this.transy += __y;
	}
	
	/**
	 * Builds and returns a text object for usage.
	 *
	 * @param __s The string used.
	 * @return A new text object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	private final Text __buildText(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Get the font, or fallback to the default if it was not set
		Font font = this.getFont();
		
		// Setup, use a zero height for now since it will be calculated after
		// the font and such has been set
		Text rv = new Text(__s,
			font.stringWidth(__s), 0);
		
		// Set text properties
		if (font != null)
			rv.setFont(font);
		rv.setForegroundColor(this.color);
		
		// Set the height to the required height of the box now that the
		// parameters have been set
		rv.setHeight(rv.getRequiredHeight());
		
		return rv;
	}
	
	/**
	 * Draws region.
	 *
	 * @param __src Source image.
	 * @param __xsrc X source.
	 * @param __ysrc Y source.
	 * @param __wsrc W source.
	 * @param __hsrc H source.
	 * @param __trans Translation.
	 * @param __xdest X destination.
	 * @param __ydest Y destination.
	 * @param __anch Anchor.
	 * @param __wdest W destination.
	 * @param __hdest H destination.
	 * @param __dswap Swap destinations on rotate?
	 * @throws IllegalArgumentException If the input is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/18
	 */
	private final void __drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest, boolean __dswap)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		// Is alpha used?
		boolean alpha = __src.hasAlpha();
		
		// Extract image pixel data
		int numpixels = __wsrc * __hsrc;
		int[] data = new int[numpixels];
		__src.getRGB(data, 0, __wsrc, __xsrc, __ysrc, __wsrc, __hsrc);
		
		// Perform the transformation, possibly returning a new data buffer
		int[] transdim = new int[]{__wsrc, __hsrc, __wdest, __hdest};
		data = this.__transform(__trans, data, __wsrc, __hsrc, transdim,
			__dswap);
		
		// Re-read the new image sizes!
		__wsrc = transdim[0];
		__hsrc = transdim[1];
		__wdest = transdim[2];
		__hdest = transdim[3];
		
		// Anchor horizontally?
		if ((__anch & HCENTER) == HCENTER)
			__xdest -= __wdest >> 1;
		
		// Anchor right?
		else if ((__anch & RIGHT) == RIGHT)
			__xdest -= __wdest;
		
		// Anchor middle?
		if ((__anch & VCENTER) == VCENTER)
			__ydest -= __hdest >> 1;
		
		// Anchor bottom?
		else if ((__anch & BOTTOM) == BOTTOM)
			__ydest -= __hdest;
		
		// If this is non-stretched we can just use the standard RGB
		// drawing function!
		if (__wsrc == __wdest && __hsrc == __hdest)
			this.drawRGB(data, 0, __wsrc, __xdest, __ydest, __wsrc, __hsrc,
				alpha);
		
		// Use stretchy draw
		else
			this.__drawRGBStretched(data, 0, __wsrc, __xdest, __ydest,
				__wsrc, __hsrc, alpha, __wdest, __hdest);
	}
	
	/**
	 * Draws stretched RGB.
	 *
	 * @param __data The data to draw.
	 * @param __off The offset into the array.
	 * @param __scanlen The scan length.
	 * @param __x X position.
	 * @param __y Y position.
	 * @param __wsrc Width of source.
	 * @param __hsrc Height of source.
	 * @param __alpha Use alpha channel?
	 * @param __wdest Width of destination.
	 * @param __hdest Height of destination.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private void __drawRGBStretched(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __wsrc, int __hsrc, boolean __alpha,
		int __wdest, int __hdest)
		throws NullPointerException
	{
		if (__data == null)
			throw new NullPointerException("NARG");
		
		this.__unimplemented(__x, __y, "drawRGBStretched");
	}
	
	/**
	 * Draws the given text object.
	 *
	 * @param __t The text object to draw.
	 * @param __x The X position.
	 * @param __y The Y position.
	 * @param __anchor The, this just adjusts determines how the actual text
	 * box region is drawn. If baseline is used, Y is just offset by the
	 * baseline for the first character and not the entire block size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	final void __drawText(Text __t, int __x, int __y, int __anchor)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Translate to the displayed coordinate space
		__x += this.transx;
		__y += this.transy;
		
		// Setup text state
		__TextState__ ts = new __TextState__();
		
		// Anchoring
		ts.textw = __t.getWidth();
		ts.texth = __t.getHeight();
		if ((__anchor & Graphics.RIGHT) != 0)
			__x -= ts.textw;
		else if ((__anchor & Graphics.HCENTER) != 0)
			__x -= (ts.textw >> 1);
		if ((__anchor & Graphics.BOTTOM) != 0)
			__y -= ts.texth;
		else if ((__anchor & Graphics.VCENTER) != 0)
			__y -= (ts.texth >> 1);
		
		// Get clipping region
		int clipsx = this.clipsx,
			clipsy = this.clipsy,
			clipex = this.clipex - 1,
			clipey = this.clipey - 1;
		
		// Wanting to draw a bunch of text completely out of the clip? Ignore
		if (__x >= clipex || __y >= clipey)
			return;
		
		// Trying to draw the text completely out of the clip as well?
		ts.tex = __x + ts.textw;
		ts.tey = __y + ts.texth;
		if (ts.tex < clipsx || ts.tey < clipsy)
			return;
		
		// The text box acts as an extra clip, so force everything to clip
		// in there
		if (__x > clipsx)
			clipsx = __x;
		if (ts.tex < clipex)
			clipex = ts.tex;
		if (__y > clipsy)
			clipsy = __y;
		if (ts.tey < clipey)
			clipey = ts.tey;
		
		// Cache the default font in the event it is never changed ever
		Font lastfont = __t.getFont();
		SQFFont sqf = SQFFont.cacheFont(lastfont);
		byte[] bmp = new byte[sqf.charbitmapsize];
		int pixelheight = sqf.pixelheight,
			bitsperscan = sqf.bitsperscan;
		
		// Background color to use
		int bgcol = __t.getBackgroundColor();
		boolean hasbg = ((bgcol & 0xFF_000000) != 0);
		
		// Need to store the properties since drawing of the text will
		// change how characters are drawn
		ts.oldcolor = this.getAlphaColor();
		try
		{
			// Read in all the text characters
			int n = __t.getTextLength();
			String chars = __t.getText(0, n);
			
			// Draw each character according to their metrics
			for (int i = 0; i < n; i++)
			{
				// Ignore certain characters
				char c = chars.charAt(i);
				if (c == '\r' || c == '\n')
					continue;
				
				// Need to find the SQF for this font again?
				Font drawfont = __t.getFont(i);
				if (drawfont != lastfont)
				{
					lastfont = drawfont;
					sqf = SQFFont.cacheFont(lastfont);
					bmp = new byte[sqf.charbitmapsize];
					pixelheight = sqf.pixelheight;
					bitsperscan = sqf.bitsperscan;
				}
				
				// Get the metrics for the character
				__t.getCharExtent(i, ts.metrics);
				
				// Calculate the draw position of the character
				int dsx = __x + ts.metrics[0];
				int dsy = __y + ts.metrics[1];
				int dex = dsx + ts.metrics[2];
				int dey = dsy + ts.metrics[3];
				
				// Completely out of bounds, ignore because we cannot draw it
				// anyway
				if (dsx >= clipex || dex <= 0 ||
					dsy >= clipey || dey <= 0)
					continue;
				
				// Map character index to the SQF
				char mc = SQFFont.mapChar(c);
				
				// Base scan offsets and such
				int scanoff = 0,
					scanlen = sqf.charWidth(mc),
					lineoff = 0,
					linelen = pixelheight;
				
				// Off the left side?
				if (dsx < clipsx)
				{
					int diff = clipsx - dsx;
					scanoff += diff;
					scanlen -= diff;
					
					// Reset to clip bound
					dsx = clipsx;
				}
				
				// Off the right side
				if (dex > clipex)
					scanlen -= (dex - clipex);
				
				// Off the top?
				if (dsy < clipsy)
				{
					int diff = clipsy - dsy;
					lineoff += diff;
					linelen -= diff;
					
					// Reset to clip bound
					dsy = clipsy;
				}
				
				// Off the bottom
				if (dey > clipey)
					linelen -= (dey - clipey);
				
				// Load the character bitmap
				int bps = sqf.loadCharBitmap(mc, bmp);
				
				// Draw background?
				if (hasbg)
				{
					// Set needed color
					this.setAlphaColor(bgcol);
					
					// Perform draw operation
					this.funcfillrect.function(this, ts.loadIntArgs(dsx, dsy,
						dsx + (scanlen - scanoff), dsy + (linelen - lineoff),
						scanlen - scanoff, linelen - lineoff), ts.chobj);
				}
				
				// Set color to the foreground color of this character
				this.setAlphaColor(__t.getForegroundColor(i));
				
				// Setup the draw and do it
				this.funccharbmp.function(this, ts.loadIntArgs(color, dsx, dsy,
					bps, scanoff, scanlen, lineoff, linelen),
					ts.loadObject(bmp));
			}
		}
		
		// Just in case revert properties
		finally
		{
			this.setAlphaColor(ts.oldcolor);
		}
	}
	
	/**
	 * Draw a string which just says not implemented.
	 *
	 * @param __x X Coordinate.
	 * @param __y Y Coordinate.
	 * @param __txt The message text.
	 * @since 2019/03/25
	 */
	private final void __unimplemented(int __x, int __y, String __txt)
		throws NullPointerException
	{
		if (__txt == null)
			throw new NullPointerException("NARG");
		
		// Just draw crosshair and a string
		this.drawLine(__x - 5, __y, __x + 5, __y);
		this.drawLine(__x, __y - 5, __x, __y + 5);
		this.drawString(__txt, __x, __y, 0);
	}
	
	/**
	 * Updates the graphics drawing functions to what is needed.
	 *
	 * @since 2019/03/24
	 */
	private final void __updateFunctions()
	{
		boolean doblending = this.doblending,
			dotstroke = this.dotstroke;
		int blendmode = this.blendmode;
		
		// Blending
		if (doblending)
		{
			this.funcfillrect = AdvancedFunction.FILLRECT_BLEND;
			this.funccharbmp = AdvancedFunction.CHARBITMAP_BLEND;
			this.funcrgbtile = AdvancedFunction.RGBTILE_BLEND;
			this.funcargbtile = AdvancedFunction.ARGBTILE_BLEND;
			
			// Dotted
			if (dotstroke)
			{
				this.funcline = AdvancedFunction.LINE_BLEND_DOT;
			}
			
			// Not dotted
			else
			{
				this.funcline = AdvancedFunction.LINE_BLEND_NODOT;
			}
		}
		
		// Not blending
		else
		{
			this.funcfillrect = AdvancedFunction.FILLRECT_NOBLEND;
			this.funccharbmp = AdvancedFunction.CHARBITMAP_NOBLEND;
			this.funcrgbtile = AdvancedFunction.RGBTILE_NOBLEND;
			this.funcargbtile = AdvancedFunction.ARGBTILE_NOBLEND;
			
			// Dotted
			if (dotstroke)
			{
				this.funcline = AdvancedFunction.LINE_NOBLEND_DOT;
			}
			
			// Not dotted
			else
			{
				this.funcline = AdvancedFunction.LINE_NOBLEND_NODOT;
			}
		}
	}
	
	/**
	 * Determines the Cohen-Sutherland clipping flags.
	 *
	 * @param __x Input X coordinate.
	 * @param __y Input Y coordinate.
	 * @param __csx Clipping box starting X.
	 * @param __csy Clipping box starting Y.
	 * @param __cex Clipping box ending X.
	 * @param __cey Clipping box ending Y.
	 * @return The clipping bit flags.
	 * @since 2017/09/10
	 */
	private static final int __csOut(int __x, int __y, int __csx, int __csy,
		int __cex, int __cey)
	{
		int rv = 0;
		
		// Clips above or below?
		if (__y > __cey)
			rv |= _CLIP_ABOVE;
		else if (__y < __csy)
			rv |= _CLIP_BELOW;
		
		// Clips right or left?
		if (__x > __cex)
			rv |= _CLIP_RIGHT;
		else if (__x < __csx)
			rv |= _CLIP_LEFT;
		
		return rv;
	}
	
	/**
	 * Transforms the data in the buffer.
	 *
	 * @param __trans The transformation to perform.
	 * @param __data The input data.
	 * @param __wsrc The width of the source.
	 * @param __hsrc The width of the destination.
	 * @param __dimout Output dimensions.
	 * @param __dswap Swap destinations?
	 * @return The resulting data is translated, this may be the same as
	 * {@code __data}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private static final int[] __transform(int __trans, int[] __data,
		int __wsrc, int __hsrc, int[] __dimout, boolean __dswap)
		throws NullPointerException
	{
		if (__data == null || __dimout == null)
			throw new NullPointerException("NARG");
		
		// Destination width and height
		int wdest = __wsrc,
			hdest = __hsrc;
		
		// Determine the transformation functions to use. There are just three
		// primitive transformation functions: flip horizontally, then
		// flip vertically, then rotate 90 degrees clockwise. This handles
		// every transformation which fill every single bit.
		byte xform = 0;
		switch (__trans)
		{
			// These bits represent the stuff to do! == 0b9VH;
			case Sprite.TRANS_NONE:				xform = 0b000; break;
			case Sprite.TRANS_MIRROR:			xform = 0b001; break;
			case Sprite.TRANS_MIRROR_ROT180:	xform = 0b010; break;
			case Sprite.TRANS_ROT180:			xform = 0b011; break;
			case Sprite.TRANS_ROT90:			xform = 0b100; break;
			case Sprite.TRANS_MIRROR_ROT90:		xform = 0b101; break;
			case Sprite.TRANS_MIRROR_ROT270:	xform = 0b110; break;
			case Sprite.TRANS_ROT270:			xform = 0b111; break;
			// These bits represent the stuff to do! == 0b9VH;
		}
		
		// Mirror horizontally?
		if ((xform & 0b001) != 0)
			for (int y = 0; y < hdest; y++)
			{
				int dx = wdest * y,
					de = (dx + wdest) - 1;
				for (int x = 0, n = (wdest >> 1); x < n; x++)
				{
					int t = __data[de];
					__data[de--] = __data[dx];
					__data[dx++] = t;
				}
			}
		
		// Mirror vertically?
		if ((xform & 0b010) != 0)
			for (int ya = 0, yn = __hsrc >> 1; ya < yn; ya++)
			{
				int ra = __wsrc * ya,
					rb = (__wsrc * (__hsrc - ya)) - __wsrc;
				
				// Flip
				for (int x = 0; x < __wsrc; x++)
				{
					int t = __data[rb];
					__data[rb++] = __data[ra];
					__data[ra++] = t;
				}
			}
		
		// Rotate 90 degrees clockwise
		if ((xform & 0b100) != 0)
		{
			// Original copy
			int[] orig = __data.clone();
			
			// Swap the X and Y pixels first
			int ttop = hdest - 1;
			for (int y = 0; y < hdest; y++)
				for (int x = 0; x < wdest; x++)
				{
					int ps = (wdest * y) + x,
						pd = (hdest * x) + (ttop - y);
					
					__data[pd] = orig[ps];
				}
			
			// The output width and height are flipped
			__dimout[0] = hdest;
			__dimout[1] = wdest;
			
			// Swap destinations as well?
			if (__dswap)
			{
				int t = __dimout[2];
				__dimout[2] = __dimout[3];
				__dimout[3] = t;
			}
		}
		
		// Otherwise use the same target dimensions
		else
		{
			__dimout[0] = wdest;
			__dimout[1] = hdest;
		}
		
		// Return the data
		return __data;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/BasicForwardingGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556












































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This forwards all calls to the specified graphics object, this is used to
 * prevent malicious classes from changing the graphics canvases and items
 * draw to.
 *
 * @since 2016/10/10
 */
public class BasicForwardingGraphics
	extends Graphics
{
	/** The graphics to forward to. */
	protected final Graphics graphics;
	
	/**
	 * Initializes the forwarder.
	 *
	 * @param __g The graphics to draw to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/10
	 */
	BasicForwardingGraphics(Graphics __g)
		throws NullPointerException
	{
		// Check
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.graphics = __g;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void clipRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.clipRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void copyArea(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g)
	{
		this.graphics.copyArea(__a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		this.graphics.drawArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		this.graphics.drawARGB16(__data, __off, __scanlen, __x, __y, __w,
			__h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChar(char __a, int __b, int __c, int __d)
	{
		this.graphics.drawChar(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChars(char[] __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.drawChars(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawImage(Image __a, int __b, int __c, int __d)
	{
		this.graphics.drawImage(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawLine(int __a, int __b, int __c, int __d)
	{
		this.graphics.drawLine(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB(int[] __a, int __b, int __c, int __d, int __e,
		int __f, int __g, boolean __h)
	{
		this.graphics.drawRGB(__a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		this.graphics.drawRGB16(__data, __off, __scanlen, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.drawRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h, int __i)
	{
		this.graphics.drawRegion(__a, __b, __c, __d, __e, __f, __g, __h,
			__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __w, int __h, int __trans, int __xdest, int __ydest, int __anch,
		int __wdest, int __hdest)
	{
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __w, __h, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRoundRect(int __a, int __b, int __c, int __d,
		int __e,  int __f)
	{
		this.graphics.drawRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawString(String __a, int __b, int __c, int __d)
	{
		this.graphics.drawString(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawSubstring(String __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.drawSubstring(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		this.graphics.drawText(__t, __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		this.graphics.fillArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRect(int __a, int __b, int __c, int __d)
	{
		this.graphics.fillRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRoundRect(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.fillRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillTriangle(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		this.graphics.fillTriangle(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getAlpha()
	{
		return this.graphics.getAlpha();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public int getAlphaColor()
	{
		return this.graphics.getAlphaColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlendingMode()
	{
		return this.graphics.getBlendingMode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlueComponent()
	{
		return this.graphics.getBlueComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipHeight()
	{
		return this.graphics.getClipHeight();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipWidth()
	{
		return this.graphics.getClipWidth();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipX()
	{
		return this.graphics.getClipX();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipY()
	{
		return this.graphics.getClipY();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getColor()
	{
		return this.graphics.getColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getDisplayColor(int __a)
	{
		return this.graphics.getDisplayColor(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public Font getFont()
	{
		return this.graphics.getFont();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGrayScale()
	{
		return this.graphics.getGrayScale();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGreenComponent()
	{
		return this.graphics.getGreenComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getRedComponent()
	{
		return this.graphics.getRedComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getStrokeStyle()
	{
		return this.graphics.getStrokeStyle();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateX()
	{
		return this.graphics.getTranslateX();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateY()
	{
		return this.graphics.getTranslateY();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlpha(int __a)
	{
		this.graphics.setAlpha(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		this.graphics.setAlphaColor(__argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
	{
		this.graphics.setAlphaColor(__a, __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setBlendingMode(int __m)
	{
		this.graphics.setBlendingMode(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setClip(int __a, int __b, int __c, int __d)
	{
		this.graphics.setClip(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a)
	{
		this.graphics.setColor(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a, int __b, int __c)
	{
		this.graphics.setColor(__a, __b, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setFont(Font __a)
	{
		this.graphics.setFont(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setGrayScale(int __a)
	{
		this.graphics.setGrayScale(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setStrokeStyle(int __a)
	{
		this.graphics.setStrokeStyle(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void translate(int __a, int __b)
	{
		this.graphics.translate(__a, __b);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/EnforcedDrawingAreaGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907











































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This is a graphics which enforces a translation and maximum drawing bounds
 * to a target graphics object.
 *
 * @since 2018/12/02
 */
public final class EnforcedDrawingAreaGraphics
	extends Graphics
{
	/** The graphics to draw into. */
	protected final Graphics graphics;
	
	/** The X translation. */
	protected final int x;
	
	/** The Y translation. */
	protected final int y;
	
	/** The width. */
	protected final int width;
	
	/** The height. */
	protected final int height;
	
	/** Draw X actual. */
	private int _dx;
	
	/** Draw Y actual. */
	private int _dy;
	
	/** Current X translation. */
	private int _transx;
	
	/** Current Y translation. */
	private int _transy;
	
	/** Clip X. */
	private int _clipx;
	
	/** Clip Y. */
	private int _clipy;
	
	/** Clip Width. */
	private int _clipw;
	
	/** Clip Height. */
	private int _cliph;
	
	/** Has this been initialized? */
	private boolean _beeninit;
	
	/**
	 * Initializes the enforced drawing area.
	 *
	 * @param __g The graphics to draw to.
	 * @param __x The X translation.
	 * @param __y The Y translation.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public EnforcedDrawingAreaGraphics(Graphics __g, int __x, int __y,
		int __w, int __h)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Clip in
		if (__x < 0)
			__x = 0;
		if (__y < 0)
			__y = 0;
		
		this.graphics = __g;
		this.x = __x;
		this.y = __y;
		this.width = __w;
		this.height = __h;
		
		// Initialize our translation with our offsets
		this._transx = 0;
		this._transy = 0;
		this._dx = __x;
		this._dy = __y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void clipRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Translate
		__x += this._transx;
		__y += this._transy;
		
		// Our viewing area
		int vw = this.width,
			vh = this.height;
		
		// Calculate logical viewing area coordinates
		int lsx = __x,
			lsy = __y,
			lex = lsx + __w,
			ley = lsy + __h;
		
		// Get the original clipping bounds
		int csx = this._clipx,
			csy = this._clipy,
			cex = csx + this._clipw,
			cey = csy + this._cliph;
		
		// Clip coordinates via the old bounds
		if (lsx < csx)
			lsx = csx;
		if (lsy < csy)
			lsy = csy;
		if (lex > cex)
			lex = cex;
		if (ley > cey)
			ley = cey;
		
		// Determine logical clipping coordinates
		int clipx = lsx,
			clipy = lsy,
			clipw = lex - lsx,
			cliph = ley - lsy;
		
		// Store these for later clipRect() calls
		this._clipx = clipx;
		this._clipy = clipy;
		this._clipw = clipw;
		this._cliph = cliph;
		
		// Determine physical start coordinates
		int px = this.x + clipx,
			py = this.y + clipy;
		
		// Set the clipping area
		Graphics graphics = this.graphics;
		graphics.setClip(
			px - graphics.getTranslateX(), py - graphics.getTranslateY(),
			clipw, cliph);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.copyArea(this._dx + __sx, this._dy + __sy,
			__w, __h, this._dx + __dx, this._dy + __dy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawArc(this._dx + __x, this._dy + __y,
			__w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawARGB16(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawChar(char __s, int __x, int __y, int __anchor)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawChar(__s, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawChars(__s, __o, __l,
			this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawImage(__i, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawLine(this._dx + __x1, this._dy + __y1,
			this._dx + __x2, this._dy + __y2);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRGB(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h, __alpha);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRGB16(__data, __off, __scanlen,
			this._dx + __x, this._dy + __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRect(this._dx + __x, this._dy + __y,
			__w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc,
			__trans, this._dx + __xdest, this._dy + __ydest, __anch);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc,
			__trans, this._dx + __xdest, this._dy + __ydest, __anch,
			__wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawRoundRect(this._dx + __x, this._dy + __y,
			__w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawString(__s, this._dx + __x, this._dy + __y,
			__anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawSubstring(__s, __o, __l,
			this._dx + __x, this._dy + __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void drawText(Text __t, int __x, int __y)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.drawText(__t, this._dx + __x, this._dy + __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillArc(this._dx + __x, this._dy + __y,
			__w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillRect(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillRect(this._dx + __x, this._dy + __y,
			__w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		this.graphics.fillRoundRect(this._dx + __x, this._dy + __y,
			__w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		int x = this._transx, y = this._transy;
		this.graphics.fillTriangle(
			x + __x1, y + __y1,
			x + __x2, y + __y2,
			x + __x3, y + __y3);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getAlpha()
	{
		return this.graphics.getAlpha();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getAlphaColor()
	{
		return this.graphics.getAlphaColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getBlendingMode()
	{
		return this.graphics.getBlendingMode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getBlueComponent()
	{
		return this.graphics.getBlueComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipHeight()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipWidth()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipX()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getClipY()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._clipy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getColor()
	{
		return this.graphics.getColor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getDisplayColor(int __rgb)
	{
		return this.graphics.getDisplayColor(__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final Font getFont()
	{
		return this.graphics.getFont();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getGrayScale()
	{
		return this.graphics.getGrayScale();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getGreenComponent()
	{
		return this.graphics.getGreenComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getRedComponent()
	{
		return this.graphics.getRedComponent();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getStrokeStyle()
	{
		return this.graphics.getStrokeStyle();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getTranslateX()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final int getTranslateY()
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		return this._transy;
	}
	
	/**
	 * Reclips the clipping area and sets up translation.
	 *
	 * @since 2018/12/02
	 */
	public final void initialize()
	{
		// Only initialize once
		if (this._beeninit)
			return;
		
		Graphics g = this.graphics;
		
		// Our viewing area
		int x = this.x,
			y = this.y,
			width = this.width,
			height = this.height;
		
		// Set new clipping area
		g.setClip(x, y, width, height);
		this._clipx = 0;
		this._clipy = 0;
		this._clipw = width;
		this._cliph = height;
		
		// Reset translation and draw position
		this._dx = x;
		this._dy = y;
		this._transx = 0;
		this._transy = 0;
		
		// Set as initialized
		this._beeninit = true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.graphics.setAlpha(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlphaColor(int __argb)
	{
		this.graphics.setAlphaColor(__argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.graphics.setAlphaColor(__a, __r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		this.graphics.setBlendingMode(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setClip(int __x, int __y, int __w, int __h)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Translate
		__x += this._transx;
		__y += this._transy;
		
		// Our viewing area
		int vw = this.width,
			vh = this.height;
		
		// Calculate logical viewing area coordinates
		int lsx = __x,
			lsy = __y,
			lex = lsx + __w,
			ley = lsy + __h;
		
		// Clip these coordinates into the logical viewing space
		if (lsx < 0)
			lsx = 0;
		if (lsy < 0)
			lsy = 0;
		if (lex > vw)
			lex = vw;
		if (ley > vh)
			ley = vh;
		
		// Determine logical clipping coordinates
		int clipx = lsx,
			clipy = lsy,
			clipw = lex - lsx,
			cliph = ley - lsy;
		
		// Store these for later clipRect() calls
		this._clipx = clipx;
		this._clipy = clipy;
		this._clipw = clipw;
		this._cliph = cliph;
		
		// Determine physical start coordinates
		int px = this.x + clipx,
			py = this.y + clipy;
		
		// Set the clipping area
		Graphics graphics = this.graphics;
		graphics.setClip(
			px - graphics.getTranslateX(), py - graphics.getTranslateY(),
			clipw, cliph);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setColor(int __rgb)
	{
		this.graphics.setColor(__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.graphics.setColor(__r, __g, __b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setFont(Font __f)
	{
		this.graphics.setFont(__f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setGrayScale(int __v)
	{
		this.graphics.setGrayScale(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void setStrokeStyle(int __s)
		throws IllegalArgumentException
	{
		this.graphics.setStrokeStyle(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void translate(int __x, int __y)
	{
		// Initialize?
		if (!this._beeninit)
			this.initialize();
		
		// Add our translation, we manage it ourselves
		int transx = this._transx + __x,
			transy = this._transy + __y;
		
		// Set our own translation but not to the target
		this._transx = transx;
		this._transy = transy;
		
		// Our draw offset is our offset and our own translation
		this._dx = this.x + transx;
		this._dy = this.y + transy;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/ForwardingGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782














































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This forwards graphical calls to the specified sub-class.
 *
 * This may be used to change for example the image to draw onto which will
 * have to be recreated if a canvas changes size.
 *
 * @since 2016/10/10
 */
public class ForwardingGraphics
	extends Graphics
{
	/** The graphics to forward to. */
	private Graphics _graphics;
	
	/** The blend mode. */
	private int _blendmode;

	/** The color. */
	private int _color;

	/** The font. */
	private Font _font;

	/** The clipping rectangle start. */
	private int _clipx, _clipy;
	
	/** The clip width. */
	private int _clipw =
		Integer.MAX_VALUE;
	
	/** The clip height. */
	private int _cliph =
		Integer.MAX_VALUE;

	/** The stroke. */
	private int _stroke;

	/** The translation coordinates. */
	private int _translatex, _translatey;
	
	/** Plain forwarder. */
	private Reference<Graphics> _plain;

	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		setClip(Math.max(__x, getClipX()),
			Math.max(__y, getClipY()),
			Math.min(__w, getClipWidth()),
			Math.min(__h, getClipHeight()));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void copyArea(int __a, int __b, int __c, int __d, int __e,
		int __f, int __g)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.copyArea(__a, __b, __c, __d, __e, __f, __g);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawARGB16(__data, __off, __scanlen, __x, __y, __w,
			__h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChar(char __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawChar(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawChars(char[] __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawChars(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawImage(Image __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawImage(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawLine(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawLine(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB(int[] __a, int __b, int __c, int __d, int __e,
		int __f, int __g, boolean __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRGB(__a, __b, __c, __d, __e, __f, __g, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRGB16(__data, __off, __scanlen, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRect(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h, int __i)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRegion(__a, __b, __c, __d, __e, __f, __g, __h,
			__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __w, int __h, int __trans, int __xdest, int __ydest, int __anch,
		int __wdest, int __hdest)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRegion(__src, __xsrc, __ysrc, __w, __h, __trans,
			__xdest, __ydest, __anch, __wdest, __hdest);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawRoundRect(int __a, int __b, int __c, int __d,
		int __e,  int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawString(String __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawString(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawSubstring(String __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawSubstring(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.drawText(__t, __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillArc(int __a, int __b, int __c, int __d, int __e,
		int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillArc(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRect(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillRect(__a, __b, __c, __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillRoundRect(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillRoundRect(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void fillTriangle(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.fillTriangle(__a, __b, __c, __d, __e, __f);
	}
	
	/**
	 * Sets the graphics to forward to.
	 *
	 * The current graphical attributes will be copies to the target graphics
	 * if it has been set.
	 *
	 * @param __g Forwards to these graphics, {@code null} clears the
	 * forwarding.
	 * @since 2016/10/10
	 */
	public void forwardGraphics(Graphics __g)
	{
		// Set new
		this._graphics = __g;
		
		// Set all drawing state, so it appears seamless
		if (__g != null)
		{
			__g.setBlendingMode(this._blendmode);
			__g.setAlphaColor(this._color);
			__g.setFont(this._font);
			__g.setClip(this._clipx, this._clipy, this._clipw, this._clipy);
			__g.setStrokeStyle(this._stroke);
			__g.translate(this._translatex - __g.getTranslateX(),
				this._translatey - __g.getTranslateY());
		}
	}
	
	/**
	 * Creates a graphics instance which just forwards to this forwarder.
	 *
	 * @return The graphics which forwards to this.
	 * @since 2016/10/10
	 */
	public Graphics forwardPlainGraphics()
	{
		Reference<Graphics> ref = this._plain;
		Graphics rv;
		
		// Initialize?
		if (ref == null || null == (rv = ref.get()))
			this._plain = new WeakReference<>(
				rv = new BasicForwardingGraphics(this));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getAlpha()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getAlpha();
		
		// Stored?
		return (this._color >>> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public int getAlphaColor()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getAlpha();
		
		// Stored?
		return this._color;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlendingMode()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getBlendingMode();
		
		// Stored?
		return this._blendmode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getBlueComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getBlueComponent();
		
		// Stored?
		return this._color & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipHeight()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipHeight();
		
		// Stored?
		return this._cliph;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipWidth()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipWidth();
		
		// Stored?
		return this._clipw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipX()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipX();
		
		// Stored?
		return this._clipx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getClipY()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getClipY();
		
		// Stored?
		return this._clipy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getColor()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getColor();
		
		// Stored?
		return this._color & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getDisplayColor(int __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getDisplayColor(__a);
		
		// Since no graphics is bound, this is unknown so return the original
		// value
		return __a & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public Font getFont()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getFont();
		
		// Stored?
		return this._font;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGrayScale()
	{
		// Average all channels
		return ((getRedComponent() & 0xFF) +
			(getGreenComponent() & 0xFF) +
			(getBlueComponent() & 0xFF)) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getGreenComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getGreenComponent();
		
		// Stored?
		return (this._color >>> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getRedComponent()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getRedComponent();
		
		// Stored?
		return (this._color >>> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getStrokeStyle()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getStrokeStyle();
		
		// Stored?
		return this._stroke;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateX()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getTranslateX();
		
		// Stored?
		return this._translatex;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int getTranslateY()
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			return graphics.getTranslateY();
		
		// Stored?
		return this._translatey;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlpha(int __a)
	{
		setAlphaColor(__a, getRedComponent(), getGreenComponent(),
			getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setAlphaColor(__argb);
		
		// Store
		this._color = __argb;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
	{
		setAlphaColor(((__a & 0xFF) << 24) |
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setBlendingMode(int __m)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setBlendingMode(__m);
		
		// Set
		this._blendmode = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setClip(int __a, int __b, int __c, int __d)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setClip(__a, __b, __c, __d);
		
		// Set
		this._clipx = __a;
		this._clipy = __b;
		this._clipw = __c;
		this._cliph = __d;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a)
	{
		setAlphaColor((__a & 0xFFFFFF) | ((getAlpha() & 0xFF) << 24));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setColor(int __a, int __b, int __c)
	{
		setAlphaColor(getAlpha(), __a, __b, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setFont(Font __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setFont(__a);
		
		// Store
		this._font = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setGrayScale(int __a)
	{
		setColor(__a, __a, __a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void setStrokeStyle(int __a)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.setStrokeStyle(__a);
		
		// Store
		this._stroke = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void translate(int __a, int __b)
	{
		Graphics graphics = this._graphics;
		if (graphics != null)
			graphics.translate(__a, __b);
		
		// Store
		this._translatex = getTranslateX();
		this._translatey = getTranslateY();
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/GraphicsFunction.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

/**
 * This represents a graphical function.
 *
 * @since 2018/11/19
 */
public enum GraphicsFunction
{
	/** Set color. */
	SET_COLOR,
	
	/** Draw line. */
	DRAW_LINE,
	
	/** Get the X clip. */
	GET_CLIP_X,
	
	/** Get the Y clip. */
	GET_CLIP_Y,
	
	/** Get the width clip. */
	GET_CLIP_WIDTH,
	
	/** Get the height clip. */
	GET_CLIP_HEIGHT,
	
	/** Set the clip. */
	SET_CLIP,
	
	/** Draw rectangle. */
	DRAW_RECT,
	
	/** Get the alpha color. */
	GET_ALPHA_COLOR,
	
	/** Set the alpha color. */
	SET_ALPHA_COLOR,
	
	/** Fill rectangle. */
	FILL_RECT,
	
	/** Sets the fonts for the graphics. */
	SET_FONT,
	
	/** Gets the font to use for drawing. */
	GET_FONT,
	
	/** Draw sub-characters. */
	DRAW_SUB_CHARS,
	
	/** Draw text. */
	DRAW_TEXT,
	
	/** Get stroke style. */
	GET_STROKE_STYLE,
	
	/** Set stroke style. */
	SET_STROKE_STYLE,
	
	/** Copy area. */
	COPY_AREA,
	
	/** Draw arc. */
	DRAW_ARC,
	
	/** Draw ARGB16. */
	DRAW_ARGB16,
	
	/** Draw character. */
	DRAW_CHAR,
	
	/** Draw characters. */
	DRAW_CHARS,
	
	/** Draw RGB. */
	DRAW_RGB,
	
	/** Draw RGB16. */
	DRAW_RGB16,
	
	/** Draw round rectangle. */
	DRAW_ROUND_RECT,
	
	/** Fill arc. */
	FILL_ARC,
	
	/** Fill round rectangle. */
	FILL_ROUND_RECT,
	
	/** Fill triangle. */
	FILL_TRIANGLE,
	
	/** Get blending mode. */
	GET_BLENDING_MODE,
	
	/** Get display color. */
	GET_DISPLAY_COLOR,
	
	/** Set blending mode. */
	SET_BLENDING_MODE,
	
	/** Draw region. */
	DRAW_REGION,
	
	/** End. */
	;
	
	/**
	 * Returns the graphics function for the given ID.
	 *
	 * @param __id The ID to translate.
	 * @return The function for the ID.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2018/11/19
	 */
	public static GraphicsFunction of(int __id)
		throws IllegalArgumentException
	{
		// Depends
		switch (__id)
		{
			case 0:		return SET_COLOR;
			case 1:		return DRAW_LINE;
			case 2:		return GET_CLIP_X;
			case 3:		return GET_CLIP_Y;
			case 4:		return GET_CLIP_WIDTH;
			case 5:		return GET_CLIP_HEIGHT;
			case 6:		return SET_CLIP;
			case 7:		return DRAW_RECT;
			case 8:		return GET_ALPHA_COLOR;
			case 9:		return SET_ALPHA_COLOR;
			case 10:	return FILL_RECT;
			case 11:	return SET_FONT;
			case 12:	return GET_FONT;
			case 13:	return DRAW_SUB_CHARS;
			case 14:	return DRAW_TEXT;
			case 15:	return GET_STROKE_STYLE;
			case 16:	return SET_STROKE_STYLE;
			case 17:	return COPY_AREA;
			case 18:	return DRAW_ARC;
			case 19:	return DRAW_ARGB16;
			case 20:	return DRAW_CHAR;
			case 21:	return DRAW_CHARS;
			case 22:	return DRAW_RGB;
			case 23:	return DRAW_RGB16;
			case 24:	return DRAW_ROUND_RECT;
			case 25:	return FILL_ARC;
			case 26:	return FILL_ROUND_RECT;
			case 27:	return FILL_TRIANGLE;
			case 28:	return GET_BLENDING_MODE;
			case 29:	return GET_DISPLAY_COLOR;
			case 30:	return SET_BLENDING_MODE;
			case 31:	return DRAW_REGION;
				
				// {@squirreljme.error EB0j Invalid graphics function.
				// (The function ID)}
			default:
				throw new IllegalArgumentException("EB0j " + __id);
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/PixelFormat.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.jvm.Framebuffer;
import javax.microedition.lcdui.Graphics;

/**
 * This represents the pixel format that is used.
 *
 * @since 2018/03/24
 */
public enum PixelFormat
{
	/** Byte Packed Indexed, 1-bit. */
	BYTE_INDEXED1,
	
	/** Byte Packed Indexed, 2-bit. */
	BYTE_INDEXED2,
	
	/** Byte Packed Indexed, 4-bit. */
	BYTE_INDEXED4,
	
	/** Byte Indexed. */
	BYTE_INDEXED8,
	
	/** Byte RGB332. */
	BYTE_RGB332,
	
	/** Short Indexed. */
	SHORT_INDEXED16,
	
	/** Short ARGB4444. */
	SHORT_ARGB4444,
	
	/** Short RGB565. */
	SHORT_RGB565,
	
	/** Integer ARGB8888. */
	INTEGER_ARGB8888,
	
	/** Integer RGB888. */
	INTEGER_RGB888,
	
	/** End. */
	;
	
	/**
	 * Creates an array buffer which is capable of containing an image of
	 * the specified size.
	 *
	 * @param __p The buffer pitch.
	 * @param __h The buffer height.
	 * @since 2018/03/28
	 */
	public final Object createBuffer(int __p, int __h)
	{
		// Depends on the format
		int dim = __p * __h;
		switch (this)
		{
			case BYTE_INDEXED1:
				return new byte[dim / 8];
					
			case BYTE_INDEXED2:
				return new byte[dim / 4];
					
			case BYTE_INDEXED4:
				return new byte[dim / 2];
					
			case BYTE_INDEXED8:
			case BYTE_RGB332:
				return new byte[dim];
					
			case SHORT_INDEXED16:
			case SHORT_ARGB4444:
			case SHORT_RGB565:
				return new short[dim];
			
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return new int[dim];
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Creates the graphics object for drawing graphics, no absolute
	 * translation is used for the graphics.
	 *
	 * @param __buf The buffer to send the result into after drawing.
	 * @param __pal The palette to use for the remote buffer.
	 * @param __bw The buffer width.
	 * @param __bh The buffer height.
	 * @param __alpha Is an alpha channel being used?
	 * @param __pitch The number of elements for the width in the buffer.
	 * @param __offset The offset into the buffer to the actual image data.
	 * @return The graphics object for drawing graphics.
	 * @throws ClassCastException If the class type of the input pixels is not
	 * an array of the expected type.
	 * @throws NullPointerException On null arguments except for {@code __pal}
	 * unless an indexed mode is used.
	 * @since 2018/03/28
	 */
	public final Graphics createGraphics(Object __buf,
		int[] __pal, int __bw, int __bh, boolean __alpha, int __pitch,
		int __offset)
		throws ClassCastException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		return this.createGraphics(__buf, __pal, __bw, __bh, __alpha,
			__pitch, __offset, 0, 0);
	}
	
	/**
	 * Creates the graphics object for drawing graphics.
	 *
	 * @param __buf The buffer to send the result into after drawing.
	 * @param __pal The palette to use for the remote buffer.
	 * @param __bw The buffer width.
	 * @param __bh The buffer height.
	 * @param __alpha Is an alpha channel being used?
	 * @param __pitch The number of elements for the width in the buffer.
	 * @param __offset The offset into the buffer to the actual image data.
	 * @param __atx Absolute X translation.
	 * @param __aty Absolute Y translation.
	 * @return The graphics object for drawing graphics.
	 * @throws ClassCastException If the class type of the input pixels is not
	 * an array of the expected type.
	 * @throws NullPointerException On null arguments except for {@code __pal}
	 * unless an indexed mode is used.
	 * @since 2018/03/28
	 */
	public final Graphics createGraphics(Object __buf,
		int[] __pal, int __bw, int __bh, boolean __alpha, int __pitch,
		int __offset, int __atx, int __aty)
		throws ClassCastException, NullPointerException
	{
		if (__buf == null)
			throw new NullPointerException("NARG");
		
		// Initialize graphics according to the pixel type
		switch (this)
		{
			case INTEGER_ARGB8888:
				return new AdvancedGraphics((int[])__buf, true, null,
					__bw, __bh, __pitch, __offset, __atx, __aty);
			
			case INTEGER_RGB888:
				return new AdvancedGraphics((int[])__buf, false, null,
					__bw, __bh, __pitch, __offset, __atx, __aty);
			
			default:
				throw new todo.OOPS(this.toString());
		}
	}
	
	/**
	 * Returns the number of alpha levels.
	 *
	 * @return The number of alpha levels.
	 * @since 2019/05/05
	 */
	public final int numAlphaLevels()
	{
		switch (this)
		{
			case BYTE_INDEXED1:
			case BYTE_INDEXED2:
			case BYTE_INDEXED4:
			case BYTE_INDEXED8:
			case SHORT_INDEXED16:
			case BYTE_RGB332:
			case SHORT_RGB565:
			case INTEGER_RGB888:
				return 0;
				
			case SHORT_ARGB4444:
				return 16;
				
			case INTEGER_ARGB8888:
				return 256;
			
				// Unknown
			default:
				throw new todo.OOPS(this.name());
		}
	}
	
	/**
	 * Returns the number of possible colors.
	 *
	 * @return The number of possible colors.
	 * @since 2019/05/05
	 */
	public final int numColors()
	{
		switch (this)
		{
			case BYTE_INDEXED1:
				return 2;
				
			case BYTE_INDEXED2:
				return 4;
				
			case BYTE_INDEXED4:
				return 16;
				
			case BYTE_INDEXED8:
			case BYTE_RGB332:
				return 256;
				
			case SHORT_ARGB4444:
				return 4096;
				
			case SHORT_INDEXED16:
			case SHORT_RGB565:
				return 65536;
				
			case INTEGER_ARGB8888:
			case INTEGER_RGB888:
				return 16777216;
			
				// Unknown
			default:
				throw new todo.OOPS(this.name());
		}
	}
	
	/**
	 * Maps the pixel format ID to the pixel format type.
	 *
	 * @param __id The input ID.
	 * @return The pixel format for the ID.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2018/11/18
	 */
	public static final PixelFormat of(int __id)
		throws IllegalArgumentException
	{
		switch (__id)
		{
			case 0:		return BYTE_INDEXED1;
			case 1:		return BYTE_INDEXED2;
			case 2:		return BYTE_INDEXED4;
			case 3:		return BYTE_INDEXED8;
			case 4:		return BYTE_RGB332;
			case 5:		return SHORT_INDEXED16;
			case 6:		return SHORT_ARGB4444;
			case 7:		return SHORT_RGB565;
			case 8:		return INTEGER_ARGB8888;
			case 9:		return INTEGER_RGB888;
			
				// {@squirreljme.error EB0k Unknown pixel buffer format. (ID)}
			default:
				throw new IllegalArgumentException("EB0k " + __id);
		}
	}
	
	/**
	 * Returns the pixel format used for the native framebuffer.
	 *
	 * @param __id The format ID.
	 * @return The associated pixel format.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2020/01/12
	 */
	public static final PixelFormat ofFramebuffer(int __id)
		throws IllegalArgumentException
	{
		switch (__id)
		{
			case Framebuffer.FORMAT_INTEGER_RGB888:
				return INTEGER_RGB888;
			
			case Framebuffer.FORMAT_BYTE_INDEXED:
				return BYTE_INDEXED8;
			
			case Framebuffer.FORMAT_SHORT_RGB565:
				return SHORT_RGB565;
			
			case Framebuffer.FORMAT_PACKED_ONE:
				return BYTE_INDEXED1;
				
			case Framebuffer.FORMAT_PACKED_TWO:
				return BYTE_INDEXED2;
				
			case Framebuffer.FORMAT_PACKED_FOUR:
				return BYTE_INDEXED4;
			
				// {@squirreljme.error EB3a Unknown frame buffer pixel buffer
				// format. (ID}}
			default:
				throw new IllegalArgumentException("EB3a " + __id);
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/SerializedGraphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;

/**
 * This class takes any input graphics operations that were performed for it,
 * serializing anything that was sent to it. The serialized graphics can be
 * forwarded somewhere for example for later deserialization.
 *
 * Translation is performed locally to the graphics and wherever the graphics
 * target is, it will not have translation forwarded and serialized to simplify
 * the target.
 *
 * @since 2018/11/19
 */
public abstract class SerializedGraphics
	extends Graphics
{
	/** X translation. */
	protected int transx;
	
	/** Y translation. */
	protected int transy;

	/**
	 * This method is called for any operation which serializes to graphics.
	 *
	 * @param __func The graphics operation to perform.
	 * @param __args The input arguments to the function.
	 * @return Any result from the operation.
	 * @since 2018/11/19
	 */
	public abstract Object serialize(GraphicsFunction __func,
		Object... __args);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void clipRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Calculate the actual desired clip location
		int nx = __x + transx,
			ny = __y + transy,
			na = nx + __w,
			nb = ny + __h;
		
		// Get the current clip location
		int cx = this.__getClipX(),
			cy = this.__getClipY(),
			ca = cx + this.getClipWidth(),
			cb = cy + this.getClipHeight();
		
		// Use direct set clip but with the correct coordinates
		int bx = (nx > cx ? nx : cx),
			by = (ny > cy ? ny : cy);
		this.serialize(GraphicsFunction.SET_CLIP,
			bx,
			by,
			(na < ca ? na : ca) - bx,
			(nb < cb ? nb : cb) - by);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.COPY_AREA,
			__sx + transx, __sy + transy, __w, __h,
			__dx + transx, __dy + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ARC,
			__x + transx, __y + transy, __w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ARGB16,
			__data, __off, __scanlen, __x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawChar(char __s, int __x, int __y, int __anchor)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_CHAR,
			(int)__s, __x + transx, __y + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_CHARS,
			__s, __o, __l, __x + transx, __y + transy, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__i, 0, 0, __i.getWidth(), __i.getHeight(), 0,
			__x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawLine(int __x1, int __y1, int __x2, int __y2)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_LINE,
			__x1 + transx, __y1 + transy, __x2 + transx, __y2 + transy);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RGB,
			__data, __off, __scanlen, __x + transx, __y + transy,
			__w, __h, (__alpha ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RGB16,
			__data, __off, __scanlen, __x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_RECT,
			__x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
		
		this.drawRegion(__src, __xsrc, __ysrc, __wsrc, __hsrc, __trans,
			__xdest, __ydest, __anch, __wsrc, __hsrc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException
	{
		if (__src == null)
			throw new NullPointerException("NARG");
			
		int transx = this.transx,
			transy = this.transy;
		
		// Extract image pixel data before sending over
		int numpixels = __wsrc * __hsrc;
		int[] data = new int[numpixels];
		__src.getRGB(data, 0, __wsrc, __xsrc, __ysrc, __wsrc, __hsrc);
		
		// {@squirreljme.error EB0l Illegal region draw.}
		int rv = (Integer)this.serialize(GraphicsFunction.DRAW_REGION,
			data, (__wsrc << 16) | __hsrc, __trans,
			__xdest + transx, __ydest + transy,
			__anch, (__wdest << 16) | __hdest);
		if (rv < 0)
			throw new IllegalArgumentException("EB0l");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_ROUND_RECT,
			__x + transx, __y + transy, __w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Just pass the chars of the string since we cannot represent
		// string at all
		this.serialize(GraphicsFunction.DRAW_SUB_CHARS,
			__s.toCharArray(), 0, __s.length(), __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		int transx = this.transx,
			transy = this.transy;
		
		// Just pass the chars of the string since we cannot represent
		// string at all
		this.serialize(GraphicsFunction.DRAW_SUB_CHARS,
			__s.toCharArray(), __o, __l, __x, __y, __anchor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void drawText(Text __t, int __x, int __y)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.DRAW_TEXT,
			SerializedGraphics.textSerialize(__t), __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_ARC,
			__x, __y, __w, __h, __sa, __aa);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillRect(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_RECT,
			__x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_ROUND_RECT,
			__x, __y, __w, __h, __aw, __ah);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.FILL_TRIANGLE,
			__x1, __y1, __x2, __y2, __x3, __y3);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getAlpha()
	{
		return (this.getAlphaColor() >> 24) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getAlphaColor()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_ALPHA_COLOR);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getBlendingMode()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_BLENDING_MODE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getBlueComponent()
	{
		return (this.getAlphaColor()) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipHeight()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_HEIGHT);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipWidth()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_WIDTH);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipX()
	{
		return this.__getClipX() - this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getClipY()
	{
		return this.__getClipY() - this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getColor()
	{
		return this.getAlphaColor() & 0xFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getDisplayColor(int __rgb)
	{
		return (Integer)this.serialize(GraphicsFunction.GET_DISPLAY_COLOR,
			__rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public Font getFont()
	{
		return SerializedGraphics.fontDeserialize(
			(byte[])this.serialize(GraphicsFunction.GET_FONT));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getGrayScale()
	{
		return (this.getRedComponent() + this.getGreenComponent() +
			this.getBlueComponent()) / 3;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getGreenComponent()
	{
		return (this.getAlphaColor() >> 8) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getRedComponent()
	{
		return (this.getAlphaColor() >> 16) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getStrokeStyle()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_STROKE_STYLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getTranslateX()
	{
		return this.transx;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public int getTranslateY()
	{
		return this.transy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlpha(int __a)
		throws IllegalArgumentException
	{
		this.setAlphaColor(__a, this.getRedComponent(),
			this.getGreenComponent(), this.getBlueComponent());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlphaColor(int __argb)
	{
		this.serialize(GraphicsFunction.SET_ALPHA_COLOR, __argb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.serialize(GraphicsFunction.SET_ALPHA_COLOR,
			((__a & 0xFF) << 24) |
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setBlendingMode(int __m)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0m Failed to set blending mode.}
		int okay = (Integer)this.serialize(GraphicsFunction.SET_BLENDING_MODE,
			__m);
		if (okay < 0)
			throw new IllegalArgumentException("EB0m");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setClip(int __x, int __y, int __w, int __h)
	{
		int transx = this.transx,
			transy = this.transy;
		
		this.serialize(GraphicsFunction.SET_CLIP,
			__x + transx, __y + transy, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setColor(int __rgb)
	{
		this.serialize(GraphicsFunction.SET_COLOR, __rgb);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException
	{
		this.serialize(GraphicsFunction.SET_COLOR,
			((__r & 0xFF) << 16) |
			((__g & 0xFF) << 8) |
			(__b & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setFont(Font __f)
	{
		// Default?
		if (__f == null)
			__f = Font.getDefaultFont();
		
		// Serialize it
		this.serialize(GraphicsFunction.SET_FONT,
			SerializedGraphics.fontSerialize(__f));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setGrayScale(int __v)
	{
		this.setAlphaColor(this.getAlpha(), __v, __v, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void setStrokeStyle(int __s)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB0n Failed to set stroke style.}
		int okay = (Integer)this.serialize(GraphicsFunction.SET_STROKE_STYLE,
			__s);
		if (okay < 0)
			throw new IllegalArgumentException("EB0n");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public void translate(int __x, int __y)
	{
		this.transx += __x;
		this.transy += __y;
	}
	
	/**
	 * Returns the raw clipping X of the target.
	 *
	 * @return The target clipping.
	 * @since 2020/01/10
	 */
	private final int __getClipX()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_X);
	}
	
	/**
	 * Returns the raw clipping Y of the target.
	 *
	 * @return The target clipping.
	 * @since 2020/01/10
	 */
	private final int __getClipY()
	{
		return (Integer)this.serialize(GraphicsFunction.GET_CLIP_Y);
	}
	
	/**
	 * Deserializes the input operation arguments and performs the call on
	 * the destination graphics.
	 *
	 * @param __g The destination graphics object.
	 * @param __func The graphics function to call.
	 * @param __args Arguments to the function.
	 * @return The result of the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public static Object deserialize(Graphics __g, GraphicsFunction __func,
		Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		if (__g == null || __func == null)
			throw new NullPointerException("NARG");
		
		// Depends on the function
		switch (__func)
		{
			case SET_COLOR:
				__g.setColor(
					(Integer)__args[0]);
				return null;
			
			case DRAW_LINE:
				__g.drawLine(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
			
			case GET_CLIP_X:
				return __g.getClipX();
			
			case GET_CLIP_Y:
				return __g.getClipY();
			
			case GET_CLIP_WIDTH:
				return __g.getClipWidth();
			
			case GET_CLIP_HEIGHT:
				return __g.getClipHeight();
			
			case SET_CLIP:
				__g.setClip(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Draw rectangle
			case DRAW_RECT:
				__g.drawRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Get alpha color
			case GET_ALPHA_COLOR:
				return __g.getAlphaColor();
				
				// Set alpha color
			case SET_ALPHA_COLOR:
				__g.setAlphaColor((Integer)__args[0]);
				return null;
				
				// Fill rectangle
			case FILL_RECT:
				__g.fillRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
				
				// Set font
			case SET_FONT:
				__g.setFont(SerializedGraphics.fontDeserialize(
					(byte[])__args[0]));
				return null;
				
				// Get font
			case GET_FONT:
				return SerializedGraphics.fontSerialize(__g.getFont());
				
				// Draw sub-characters
			case DRAW_SUB_CHARS:
				__g.drawChars(
					(char[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
				
				// Draw text
			case DRAW_TEXT:
				__g.drawText(
					SerializedGraphics.textDeserialize((byte[])__args[0]),
					(Integer)__args[1],
					(Integer)__args[2]);
				return null;
				
				// Get stroke style
			case GET_STROKE_STYLE:
				return __g.getStrokeStyle();
				
				// Set stroke style
			case SET_STROKE_STYLE:
				try
				{
					__g.setStrokeStyle((Integer)__args[0]);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
				
				// Copy area.
			case COPY_AREA:
				__g.copyArea(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw arc.
			case DRAW_ARC:
				__g.drawArc(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Draw ARGB16.
			case DRAW_ARGB16:
				__g.drawARGB16(
					(short[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw character.
			case DRAW_CHAR:
				__g.drawChar(
					(char)(((Integer)__args[0]).intValue()),
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3]);
				return null;
			
				// Draw characters.
			case DRAW_CHARS:
				__g.drawChars(
					(char[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Draw RGB.
			case DRAW_RGB:
				__g.drawRGB(
					(int[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6],
					(((Integer)__args[7]) != 0 ? true : false));
				return null;
			
				// Draw RGB16.
			case DRAW_RGB16:
				__g.drawRGB16(
					(short[])__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5],
					(Integer)__args[6]);
				return null;
			
				// Draw round rectangle.
			case DRAW_ROUND_RECT:
				__g.drawRoundRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill arc.
			case FILL_ARC:
				__g.fillArc(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill round rectangle.
			case FILL_ROUND_RECT:
				__g.fillRoundRect(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Fill triangle.
			case FILL_TRIANGLE:
				__g.fillTriangle(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4],
					(Integer)__args[5]);
				return null;
			
				// Get blending mode.
			case GET_BLENDING_MODE:
				return __g.getBlendingMode();
			
				// Get display color.
			case GET_DISPLAY_COLOR:
				return __g.getDisplayColor((Integer)__args[0]);
			
				// Set blending mode.
			case SET_BLENDING_MODE:
				try
				{
					__g.setBlendingMode((Integer)__args[0]);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
			
				// Draw region
			case DRAW_REGION:
				try
				{
					// Extract width/heights since they are combined here
					int sw = ((Integer)__args[1]) >>> 16,
						sh = ((Integer)__args[1]) & 0xFFFF,
						dw = ((Integer)__args[6]) >>> 16,
						dh = ((Integer)__args[6]) & 0xFFFF;
					
					// Note that the passed buffer only contains image data
					// from the source region, as such the source coordinates
					// will always be zero
					__g.drawRegion(Image.createRGBImage(
							(int[])__args[0], sw, sh, true),
						0, 0,
						sw, sh,
						(Integer)__args[2],
						(Integer)__args[3],
						(Integer)__args[4],
						(Integer)__args[5],
						dw, dh);
				}
				catch (IllegalArgumentException e)
				{
					return -1;
				}
				return 0;
			
			default:
				throw new todo.OOPS("" + __func);
		}
	}
	
	/**
	 * Deserializes the font.
	 *
	 * @param __b The input byte data.
	 * @return The resulting font.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Font fontDeserialize(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Deserialize all of the data
		try (ByteArrayInputStream bais = new ByteArrayInputStream(__b))
		{
			int style, pixelsize;
			String name;
			
			try (DataInputStream dis = new DataInputStream(bais))
			{
				style = dis.readInt();
				pixelsize = dis.readInt();
				name = dis.readUTF();
			}
			
			return Font.getFont(name, style, pixelsize);
		}
		
		// {@squirreljme.error EB0o Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0o", e);
		}
	}
	
	/**
	 * Deserializes the font.
	 *
	 * @param __dis The stream to read from.
	 * @return The deserialized font.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Font fontDeserialize(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read byte data
		int len = __dis.readUnsignedShort();
		byte[] ser = new byte[len];
		__dis.readFully(ser);
		return SerializedGraphics.fontDeserialize(ser);
	}
	
	/**
	 * Serializes the font.
	 *
	 * @param __f The font to serialize.
	 * @return The resulting byte data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static byte[] fontSerialize(Font __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Serialize all of the data
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(64))
		{
			try (DataOutputStream dos = new DataOutputStream(baos))
			{
				dos.writeInt(__f.getStyle());
				dos.writeInt(__f.getPixelSize());
				dos.writeUTF(__f.getFontName());
			}
			
			// Return it
			return baos.toByteArray();
		}
		
		// {@squirreljme.error EB0p Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0p", e);
		}
	}
	
	/**
	 * Serializes the font.
	 *
	 * @param __dos The stream to write to.
	 * @param __f The font to serialize.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static void fontSerialize(DataOutputStream __dos, Font __f)
		throws IOException, NullPointerException
	{
		if (__dos == null || __f == null)
			throw new NullPointerException("NARG");
		
		// Record data
		byte[] ser = SerializedGraphics.fontSerialize(__f);
		__dos.writeShort(ser.length);
		__dos.write(ser);
	}
	
	/**
	 * Deserializes the byte array to a {@link Text} object.
	 *
	 * @param __b The byte array to deserialize.
	 * @return The deserialized text.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static Text textDeserialize(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Deserialize all of the data
		try (ByteArrayInputStream bais = new ByteArrayInputStream(__b))
		{
			Text rv = new Text();
			try (DataInputStream dis = new DataInputStream(bais))
			{
				rv.setWidth(dis.readInt());
				rv.setHeight(dis.readInt());
				rv.setAlignment(dis.readInt());
				rv.setBackgroundColor(dis.readInt());
				rv.setFont(SerializedGraphics.fontDeserialize(dis));
				rv.setForegroundColor(dis.readInt());
				rv.setIndent(dis.readInt());
				rv.setInitialDirection(dis.readInt());
				rv.setScrollOffset(dis.readInt());
				rv.setSpaceAbove(dis.readInt());
				rv.setSpaceBelow(dis.readInt());
				
				// Read length
				int n = dis.readInt();
				
				// Read in text string
				rv.insert(0, dis.readUTF());
				
				// Read all character properties
				for (int i = 0; i < n; i++)
				{
					rv.setForegroundColor(dis.readInt(), i, 1);
					
					// Was a font used?
					if (dis.readBoolean())
						rv.setFont(
							SerializedGraphics.fontDeserialize(dis), i, 1);
				}
				
				// And now that there is proper length
				rv.setCaret(dis.readInt());
				rv.setHighlight(dis.readInt(), dis.readInt());
			}
			
			// Return it
			return rv;
		}
		
		// {@squirreljme.error EB0q Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0q", e);
		}
	}
	
	/**
	 * Serializes the text object to a byte array.
	 *
	 * @param __t The text to serialize.
	 * @return The serialized byte array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/02
	 */
	public static byte[] textSerialize(Text __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Serialize all of the data
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(4096))
		{
			try (DataOutputStream dos = new DataOutputStream(baos))
			{
				// Properties which do not need characters
				dos.writeInt(__t.getWidth());
				dos.writeInt(__t.getHeight());
				dos.writeInt(__t.getAlignment());
				dos.writeInt(__t.getBackgroundColor());
				SerializedGraphics.fontSerialize(dos, __t.getFont());
				dos.writeInt(__t.getForegroundColor());
				dos.writeInt(__t.getIndent());
				dos.writeInt(__t.getInitialDirection());
				dos.writeInt(__t.getScrollOffset());
				dos.writeInt(__t.getSpaceAbove());
				dos.writeInt(__t.getSpaceBelow());
				
				// Record length
				int n = __t.getTextLength();
				dos.writeInt(n);
				
				// Record the string
				dos.writeUTF(__t.getText(0, n));
				
				// Record all the character properties
				for (int i = 0; i < n; i++)
				{
					dos.writeInt(__t.getForegroundColor(i));
					
					// Font needs serialization
					Font f = __t.getFont(i);
					if (f == null)
						dos.writeBoolean(false);
					else
					{
						dos.writeBoolean(true);
						SerializedGraphics.fontSerialize(dos, f);
					}
				}
				
				// Depends on character stuff
				dos.writeInt(__t.getCaret());
				dos.writeInt(__t.getHighlightIndex());
				dos.writeInt(__t.getHighlightLength());
			}
			
			// Return it
			return baos.toByteArray();
		}
		
		// {@squirreljme.error EB0r Could not serialize the text object.}
		catch (IOException e)
		{
			throw new RuntimeException("EB0r", e);
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/__TextState__.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
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





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.gfx;

/**
 * This represents the state of the current text drawing.
 *
 * This is used to reduce pressure on the text drawing code because it is
 * complex.
 *
 * @since 2019/12/15
 */
final class __TextState__
{
	/** Metrics. */
	public final int[] metrics =
		new int[4];
	
	/** Integer arguments. */
	public final int[] chint =
		new int[8];
	
	/** Object argumnets. */
	public final Object[] chobj =
		new Object[1];
	
	/** The old color. */
	public int oldcolor;
	
	/** Text width/height. */
	public int textw, texth;
	
	/** Text end X/Y. */
	public int tex, tey;
	
	/**
	 * Loads integer arguments.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @param __c C.
	 * @param __d D.
	 * @param __e E.
	 * @param __f F.
	 * @return The integer array.
	 * @since 2019/12/15
	 */
	public final int[] loadIntArgs(int __a, int __b, int __c, int __d,
		int __e, int __f)
	{
		int[] chint = this.chint;
		
		chint[0] = __a;
		chint[1] = __b;
		chint[2] = __c;
		chint[3] = __d;
		chint[4] = __e;
		chint[5] = __f;
		
		return chint;
	}
	
	/**
	 * Loads integer arguments.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @param __c C.
	 * @param __d D.
	 * @param __e E.
	 * @param __f F.
	 * @param __g G.
	 * @param __h H.
	 * @return The integer array.
	 * @since 2019/12/15
	 */
	public final int[] loadIntArgs(int __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h)
	{
		int[] chint = this.chint;
		
		chint[0] = __a;
		chint[1] = __b;
		chint[2] = __c;
		chint[3] = __d;
		chint[4] = __e;
		chint[5] = __f;
		chint[6] = __g;
		chint[7] = __h;
		
		return chint;
	}
	
	/**
	 * Loads object array.
	 *
	 * @param __a A.
	 * @return The object array.
	 * @since 2019/12/15
	 */
	public final Object[] loadObject(Object __a)
	{
		Object[] chobj = this.chobj;
		
		chobj[0] = __a;
		
		return chobj;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains implementations of the graphics drawing classes.
 *
 * @since 2017/08/19
 */

package cc.squirreljme.runtime.lcdui.gfx;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/ImageReaderDispatcher.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import javax.microedition.lcdui.Image;

/**
 * This is used to dispatch to the correct parser when loading images.
 *
 * @since 2017/02/28
 */
public class ImageReaderDispatcher
{
	/**
	 * Not used.
	 *
	 * @since 2017/02/28
	 */
	private ImageReaderDispatcher()
	{
	}
	
	/**
	 * Parses the image stream.
	 *
	 * @param __is The stream to read from.
	 * @return The parsed image data.
	 * @throws IOException If it could not be parsed.
	 */
	public static Image parse(InputStream __is)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Mark header
		__is.mark(4);
		
		// Read in the header magic number
		int first = (__is.read() & 0xFF);
		int magic = (first << 24) |
			((__is.read() & 0xFF) << 16) |
			((__is.read() & 0xFF) << 8) |
			(__is.read() & 0xFF);
		
		// Reset for future read
		__is.reset();
		
		// GIF?
		if (magic == 0x47494638)
			throw new todo.TODO();
		
		// PNG?
		else if (magic == 0x89504E47)
			return new PNGReader(__is).parse();
		
		// JPEG?
		else if ((magic & 0xFFFFFF00) == 0xFFD8FF00)
			return new JPEGReader(__is).parse();
		
		// SVG?
		else if (first == '<')
			throw new todo.TODO();
		
		// XPM?
		else if (first == '/')
			return new XPMReader(__is).parse();
		
		// {@squirreljme.error EB0s Could not detect the image format used
		// specified by the starting byte. (The magic number; The first byte)}
		else
			throw new IOException(String.format("EB0s %08x %02x", magic,
				first));
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/JPEGReader.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


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.image;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import javax.microedition.lcdui.Image;

/**
 * This class is used to process JPEG image files.
 *
 * @since 2019/05/06
 */
public final class JPEGReader
{
	/** The input data. */
	protected final DataInputStream in;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public JPEGReader(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * Parses the JPEG.
	 *
	 * @return The resulting image.
	 * @throws IOException On read errors.
	 * @since 2019/05/06
	 */
	public Image parse()
	{
		DataInputStream in = this.in;
		
		todo.TODO.note("Implement JPEG decoding");
		return Image.createRGBImage(new int[16], 4, 4, false);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/PNGReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769

































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Arrays;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.io.ChecksumInputStream;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.InflaterInputStream;
import net.multiphasicapps.io.SizeLimitedInputStream;
import net.multiphasicapps.io.ZLibDecompressor;

/**
 * This class parses PNG images.
 *
 * PNG specifications:
 * {@link http://www.libpng.org/pub/png/pngdocs.html}
 * {@link http://www.libpng.org/pub/png/spec/iso/index-object.html}
 * {@link https://www.w3.org/TR/PNG/}
 * {@link https://tools.ietf.org/html/rfc2083}
 *
 * @since 2017/02/28
 */
public class PNGReader
{
	/** The input source. */
	protected final DataInputStream in;
	
	/** Image width. */
	private int _width;
	
	/** Scanline length. */
	private int _scanlen;
	
	/** Image height. */
	private int _height;
	
	/** The bit depth. */
	private int _bitdepth;
	
	/** The color type. */
	private int _colortype;
	
	/** Is adam7 interlacing being used? */
	private boolean _adamseven;
	
	/** RGB image data. */
	private int[] _argb;
	
	/** Palette data. */
	private int[] _palette;
	
	/** Was an alpha channel used? */
	private boolean _hasalpha;
	
	/** Initial value for read Y position, for multiple IDAT chunks. */
	private int _initvy;
	
	/** Initial value for read X position, for multiple IDAT chunks. */
	private int _initvx;
	
	/** The number of colors used. */
	private int _numcolors;
	
	/** The maximum number of permitted colors. */
	private int _maxcolors;
	
	/**
	 * Initializes the PNG parser.
	 *
	 * @param __in The input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public PNGReader(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * Parses the PNG image data.
	 *
	 * @return The read image.
	 * @since 2017/02/28
	 */
	public Image parse()
		throws IOException
	{
		DataInputStream in = this.in;
		
		// {@squirreljme.error EB0t Illegal PNG magic number.}
		if (in.readUnsignedByte() != 137 ||
			in.readUnsignedByte() != 80 ||
			in.readUnsignedByte() != 78 ||
			in.readUnsignedByte() != 71 ||
			in.readUnsignedByte() != 13 ||
			in.readUnsignedByte() != 10 ||
			in.readUnsignedByte() != 26 ||
			in.readUnsignedByte() != 10)
			throw new IOException("EB0t");
		
		// Some J2ME games such as Bobby Carrot have invalid PNG files that
		// contain a tRNS chunk after the IDAT chunk. This violates the PNG
		// standard so the image chunk has to cached and process later,
		// otherwise the images will be corrupt.
		byte[] imagechunk = null;
		
		// Keep reading chunks in the file
		for (;;)
		{
			// {@squirreljme.erorr EB1l Length of chunk is negative.}
			int len = in.readInt();
			if (len < 0)
				throw new IOException("EB1l");
			
			// Setup data stream for reading packet data, do not propogate
			// close
			CRC32Calculator crc = new CRC32Calculator(true, true, 0x04C11DB7,
				0xFFFFFFFF, 0xFFFFFFFF);
			int lasttype = 0;
			try (DataInputStream data = new DataInputStream(
				new SizeLimitedInputStream(new ChecksumInputStream(crc, in),
				len + 4, true, false)))
			{
				// Read the packet type
				int type = data.readInt();
				lasttype = type;
				
				// End of PNG, stop processing
				if (type == 0x49454E44)
					break;
				
				// Depends on the type
				switch (type)
				{
						// Header
					case 0x49484452:
						__parseHeader(data);
						break;
						
						// Palette
					case 0x504c5445:
						__parsePalette(data, len);
						break;
						
						// Image data
					case 0x49444154:
						// There may be multiple consecutive IDAT chunks which
						// just continue where the previous one left off, so
						// just smash them together
						if (imagechunk != null)
						{
							// Read chunk data, decompress the data
							// additionally so that the decoder does not need
							// to worry about the data being compressed at
							// all...
							byte[] xtrachunk = PNGReader.__chunkLater(data);
							
							// Setup new array which contains the original
							// data but has more space
							int gn = imagechunk.length,
								xn = xtrachunk.length,
								nl = gn + xn;
							imagechunk = Arrays.copyOf(imagechunk, nl);
							
							// Write in all the data
							for (int i = 0, o = gn; i < xn; i++, o++)
								imagechunk[o] = xtrachunk[i];
						}
						
						// The first chunk
						else
							imagechunk = PNGReader.__chunkLater(data);
						break;
						
						// Transparency information
					case 0x74524E53:
						this.__parseAlpha(data, len);
						break;
					
						// Unknown, ignore
					default:
						break;
				}
			}
			
			// {@squirreljme.error EB0u CRC mismatch in PNG data chunk.
			// (Desired CRC; Actual CRC; Last chunk type read)}
			int want = in.readInt(),
				real = crc.checksum();
			if (want != real)
				throw new IOException(String.format("EB0u %08x %08x %08x",
					want, real, lasttype));
		}
		
		// {@squirreljme.error EB0v No image data has been loaded.}
		int[] argb = this._argb;
		if (argb == null)
			throw new IOException("EB0v");
		
		// Is an alpha channel being used?
		if (!this._hasalpha)
		{
			// Force all pixels to opaque
			for (int i = 0, n = argb.length; i < n; i++)
				argb[i] = 0xFF_000000;
			
			// Make all pixels opaque in the palette
			int[] palette = this._palette;
			if (palette != null)
				for (int i = 0, n = palette.length; i < n; i++)
					palette[i] |= 0xFF_000000;
		}
		
		// {@squirreljme.error EB0w Unsupported bit-depth. (The bitdepth)}
		int bitdepth = this._bitdepth;
		if (Integer.bitCount(bitdepth) != 1 || bitdepth > 8)
			throw new IOException("EB0w " + bitdepth);
		
		// {@squirreljme.error EB0x Adam7 interlacing not supported.}
		if (this._adamseven)
			throw new IOException("EB0x");
		
		// {@squirreljme.error EB0y Paletted PNG image has no palette.}
		if (this._colortype == 3 && this._palette == null)
			throw new IOException("EB0y");
		
		// Process the image chunk now that the other information was read
		// Note that the chunk needs to be unfiltered first
		try (InputStream data = new ByteArrayInputStream(this.__unfilter(
			new ZLibDecompressor(new ByteArrayInputStream(imagechunk)))))
		{
			int colortype = this._colortype;
			
			// Grayscale or Indexed
			if (colortype == 0 || colortype == 3)
				this.__pixelIndexed(data, (colortype == 3));
			
			// RGB(A)
			else if (colortype == 2 || colortype == 6)
				this.__pixelsRGB(data, (colortype == 6));
			
			// YA (Grayscale + Alpha)
			else
				this.__pixelsYA(data);
		}
		
		// Create image
		return Image.createRGBImage(argb, this._width, this._height,
			this._hasalpha);
	}
	
	/**
	 * Parses the alpha transparency data.
	 *
	 * @param __in The stream to read data from.
	 * @param __dlen The data length/
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __parseAlpha(DataInputStream __in, int __dlen)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		int[] palette = this._palette;
		int colortype = this._colortype,
			numpals = (palette != null ? palette.length : 0),
			numcolors = this._numcolors;
		
		// Force alpha channel to be set
		this._hasalpha = true;
		
		// Alpha values for grayscale or true-color
		if (colortype == 0)
		{
			// Read double-byte values
			for (int at = 0;;)
			{
				// Read in color
				int col = __in.read(),
					ign = __in.read();
				
				// EOF?
				if ((col | ign) < 0)
					break;
				
				// Find color to remove the alpha channel from the palette
				for (int p = 0; p < numpals; p++)
					if (palette[p] == col)
						palette[p] &= 0xFFFFFF;
			}
		}
		
		// Alpha values for indexed values
		else if (colortype == 3)
		{
			// Read as many entries as possible
			int i = 0;
			for (; i < numcolors; i++)
			{
				int val = __in.read();
				
				// Reached end of data, the rest are implied opaque
				if (val < 0)
					break;
				
				// Fill in color
				palette[i] |= ((val & 0xFF) << 24);
			}
			
			// The alpha data can be short, which means that all of
			// the following colors are fully opaque
			for (; i < numcolors; i++)
				palette[i] |= 0xFF_000000;
		}
	}
	
	/**
	 * Parses the PNG header.
	 *
	 * @param __in The stream to read data from.
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	private void __parseHeader(DataInputStream __in)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB0z Image has zero or negative width.
		// (The width)}
		int width = __in.readInt();
		if (width <= 0)
			throw new IOException(String.format("EB0z %d", width));
		this._width = width;
		
		// {@squirreljme.error EB10 Image has zero or negative height. (The
		// height)}
		int height = __in.readInt();
		if (height <= 0)
			throw new IOException(String.format("EB10 %d", height));
		this._height = height;
		
		// Debug
		todo.DEBUG.note("Size: %dx%d%n", width, height);
		
		// Read the bit depth and the color type
		int bitdepth = __in.readUnsignedByte(),
			colortype = __in.readUnsignedByte();
		
		// {@squirreljme.error EB11 Invalid PNG bit depth.
		// (The bit depth)}
		if (Integer.bitCount(bitdepth) != 1 || bitdepth < 0 || bitdepth > 16)
			throw new IOException(String.format("EB11 %d", bitdepth));
		
		// {@squirreljme.error EB12 Invalid PNG bit depth and color type
		// combination. (The color type; The bit depth)}
		if ((bitdepth < 8 && (colortype != 0 && colortype != 3)) ||
			(bitdepth > 8 && colortype != 3))
			throw new IOException(String.format("EB12 %d %d", colortype,
				bitdepth));
			
		// Set
		this._bitdepth = bitdepth;
		this._colortype = colortype;
		
		// These two color types have alpha, this field may be set later on
		// if a transparency chunk was found
		boolean hasalpha;
		this._hasalpha = (hasalpha = (colortype == 4 || colortype == 6));
		
		// Determine number of channels
		int channels = (colortype == 0 || colortype == 3 ? 1 :
			(colortype == 2 ? 3 :
			(colortype == 4 ? 2 :
			(colortype == 6 ? 4 : 1))));
		
		// Scan length, 7 extra bits are added for any needed padding if there
		// is any
		this._scanlen = ((width * channels * bitdepth) + 7) / 8;
		
		// {@squirreljme.error EB13 Only deflate compressed PNG images are
		// supported. (The compression method)}
		int compressionmethod = __in.readUnsignedByte();
		if (compressionmethod != 0)
			throw new IOException(String.format("EB13 %d", compressionmethod));
		
		// {@squirreljme.error EB14 Only adapative filtered PNGs are supported.
		// (The filter type)}
		int filter = __in.readUnsignedByte();
		if (filter != 0)
			throw new IOException(String.format("EB14 %d", filter));
		
		// {@squirreljme.error EB15 Unsupported PNG interlace method. (The
		// interlace type)}
		int interlace = __in.readUnsignedByte();
		if (interlace != 0 && interlace != 1)
			throw new IOException(String.format("EB15 %d", interlace));
		this._adamseven = (interlace == 1);
		
		// Allocate image buffer
		this._argb = new int[width * height];
		
		// If this is grayscale, then force a palette to be initialized so the
		// colors are more easily read without needing to process them further
		// So all values are treated as indexed
		if (colortype == 0)
		{
			// 2^d colors available
			int numcolors = (1 << bitdepth);
			
			// Build palette, force everything to opaque, it will be cleared
			// later
			int[] palette = new int[numcolors];
			for (int i = 0; i < numcolors; i++)
				palette[i] = ((int)(((double)i / (double)numcolors) * 255.0)) |
					0xFF_000000;
			
			// Set
			this._palette = palette;
		}
	}
	
	/**
	 * Parses the PNG palette.
	 *
	 * @param __in The stream to read data from.
	 * @param __len The length of the palette data.
	 * @throws IOException On parse errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	private void __parsePalette(DataInputStream __in, int __len)
		throws IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Ignore the palette if this is not an indexed image
		if (this._colortype != 3)
			return;
		
		// Read color color
		int numcolors = __len / 3,
			maxcolors = 1 << this._bitdepth;
		if (numcolors > maxcolors)
			numcolors = maxcolors;
		
		// Set
		this._numcolors = numcolors;
		this._maxcolors = maxcolors;
		
		// Load palette data, any remaining colors are left uninitialized and
		// are fully transparent or just black
		int[] palette = new int[maxcolors];
		this._palette = palette;
		for (int i = 0; i < numcolors; i++)
		{
			int r = __in.readUnsignedByte(),
				g = __in.readUnsignedByte(),
				b = __in.readUnsignedByte();
			
			// Fill in color
			palette[i] = (r << 16) | (g << 8) | b;
		}
	}
	
	/**
	 * Decodes grayscale/indexed image data.
	 *
	 * @param __dis Input Stream.
	 * @param __idx Indexed colors instead of just grayscale?
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelIndexed(InputStream __dis, boolean __idx)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
			
		int[] argb = this._argb;
		int[] palette = this._palette;
		int width = this._width,
			height = this._height,
			limit = width * height,
			bitdepth = this._bitdepth,
			bitmask = (1 << bitdepth) - 1,
			numpals = (palette != null ? palette.length : 0),
			hishift = (8 - bitdepth),
			himask = bitmask << hishift;
		
		// Read of multiple bits
		for (int o = 0;;)
		{
			// Read and check EOF
			int v = __dis.read();
			if (v < 0)
				break;
			
			// Handle each bit
			for (int b = 0; b < 8 && o < limit; b += bitdepth, v <<= bitdepth)
				argb[o++] = palette[((v & himask) >>> hishift) % numpals];
		}
	}
	
	/**
	 * Decodes RGB or RGBA image data.
	 *
	 * @param __dis Input Stream.
	 * @param __alpha RGBA is used?
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelsRGB(InputStream __dis, boolean __alpha)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Get output
		int[] argb = this._argb;
		int width = this._width,
			height = this._height,
			limit = width * height;
		
		// Keep reading in data
		for (int o = 0; o < limit; o++)
		{
			// Read in all values, the mask is used to keep the sign bit in
			// place but also cap the value to 255!
			int r = __dis.read() & 0x800000FF,
				g = __dis.read() & 0x800000FF,
				b = __dis.read() & 0x800000FF;
			int a = (__alpha ? (__dis.read() & 0x800000FF) : 0xFF);
			
			// Have any hit EOF? Just need to OR all the bits
			if ((r | g | b | a) < 0)
				break;
			
			// Write pixel
			argb[o] = (a << 24) | (r << 16) | (g << 8) | b;
		}
	}
	
	/**
	 * Decodes image data.
	 *
	 * @param __dis Input Stream.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final void __pixelsYA(InputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Get output
		int[] argb = this._argb;
		int width = this._width,
			height = this._height,
			limit = width * height;
		
		// Keep reading in data
		for (int o = 0; o < limit;)
		{
			// Read in all values, the mask is used to keep the sign bit in
			// place but also cap the value to 255!
			int a = __dis.read() & 0x800000FF,
				y = __dis.read() & 0x800000FF;
			
			// Have any hit EOF? Just need to OR all the bits
			if ((a | y) < 0)
				break;
			
			// Write pixel
			argb[o++] = (a << 24) | (y << 16) | (y << 8) | y;
		}
	}
	
	/**
	 * Unfilters the PNG data.
	 *
	 * @param __in The stream to read from.
	 * @return The unfiltered data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	private final byte[] __unfilter(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need these
		int scanlen = this._scanlen,
			height = this._height;
		
		// Allocate buffer that will be returned, containing the unfiltered
		// data
		byte[] rv = new byte[scanlen * height];
		
		// Read the image scanline by scanline and process it
		for (int dy = 0; dy < height; dy++)
		{
			// Base output for this scanline
			int ibase = scanlen * dy;
			
			// At the start of every scanline is the filter type, which
			// describes how the data should be treated
			// {@squirreljme.error EB16 Unknown filter type. (The type; The
			// scanline base coordinate; The scan line length; Image size)}
			int type = __in.read();
			if (type < 0 || type > 4)
				throw new IOException(String.format(
					"EB16 %d (%d, %d) %d [%d, %d]",
					type, 0, dy, scanlen, this._width, height));
			
			// Go through each byte in the scanline
			for (int dx = 0; dx < scanlen; dx++)
			{
				// The current position in the buffer
				int di = ibase + dx;
				
				// The filter algorithm is a bit confusing and it uses the
				// prior and old pixel information, so according to the PNG
				// spec just to be easier to use the variables will be named
				// the same. Anywhere that bleeds off the image will always be
				// treated as zero.
				
				// The current byte being filtered
				int x = __in.read() & 0xFF,
				
				// The byte to the left of (x, y) [-1, 0]
					a = (dx <= 0 ? 0 : rv[di - 1]) & 0xFF,
				
				// The byte to the top of (x, y) [0, -1]
					b = (dy <= 0 ? 0 : rv[di - scanlen]) & 0xFF,
				
				// The byte to the top and left of (x, y) [-1, -1]
					c = ((dx <= 0 || dy <= 0) ? 0 :
						rv[(di - scanlen) - 1]) & 0xFF;
				
				// Depends on the decoding algorithm
				int res = 0;
				switch (type)
				{
						// None
					case 0:
						res = x;
						break;
						
						// Sub
					case 1:
						res = x + a;
						break;
						
						// Up
					case 2:
						res = x + b;
						break;
						
						// Average
					case 3:
						res = x + ((a + b) >>> 2);
						break;
						
						// Paeth, this probably is not correct
					case 4:
						{
							// Calculate these
							int p = a + b - c,
								pa = p - a,
								pb = p - b,
								pc = p - c;
							
							// Absolute values
							pa = (pa < 0 ? -pa : pa);
							pb = (pb < 0 ? -pb : pb);
							pc = (pc < 0 ? -pc : pc);
							
							// Perform some checks
							if (pa <= pb && pa <= pc)
								res = x + a;
							else if (pb <= pc)
								res = x + b;
							else
								res = x + c;
						}
						break;
				}
				
				// Set result
				rv[di] = (byte)res;
			}
		}
		
		return rv;
	}
	
	/**
	 * Reads all the input data and returns a byte array for the data, so it
	 * may be processed later.
	 *
	 * @param __dis The stream to read from.
	 * @return The read data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private static final byte[] __chunkLater(InputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read into this byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(512))
		{
			// Read loop
			byte[] buf = new byte[512];
			for (;;)
			{
				int rc = __dis.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Return the data
			return baos.toByteArray();
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/XPMReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436




















































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
import javax.microedition.lcdui.Image;

/**
 * This class is able to read XPM images.
 *
 * If the XPM is invalid then the read image data will not be correct.
 *
 * There are also limitations to the reader, only the last color key will be
 * used and it will be treated as a RGB hexadecimal color. Also the pixels
 * per character has a limit of 2 characters, any pixels with characters
 * codes beyond 2 character will only use the first 2.
 *
 * @since 2016/05/08
 */
public class XPMReader
{
	/** Source stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the XPM image reader.
	 *
	 * @since 2016/05/08
	 */
	public XPMReader(InputStream __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		this.in = __is;
	}
	
	/**
	 * Reads the XPM image data from the specified input stream.
	 *
	 * @param __is The stream to read XPM data from.
	 * @return The read image data.
	 * @throws IOException If the XPM is not valid.
	 * @since 2017/02/10
	 */
	public Image parse()
		throws IOException
	{
		InputStream in = this.in;
		
		// Create character stripper
		__CharStripper__ cs = new __CharStripper__(new InputStreamReader(in,
			"utf-8"));
		
		// Read the XPM header
		int[] header = __readHeader(cs);
		
		// Get dimensional data
		int width = Math.max(header[0], 1);
		int height = Math.max(header[1], 1);
		int numcolors = Math.max(header[2], 1);
		int pxchars = Math.max(header[3], 1);
		int hotx = header[4];
		int hoty = header[5];
		
		// Read the color table
		int[] codes = new int[numcolors];
		int[] palette = new int[numcolors];
		boolean alpha = this.__readColorTable(
			cs, codes, palette, numcolors, pxchars);
		
		// Target array
		int area = width * height;
		int[] data = new int[area];
		
		// Read pixels
		__readPixels(cs, width, height, data, pxchars, codes, palette);
		
		// Create image
		return Image.createRGBImage(data, width, height, alpha);
	}
	
	/**
	 * Decodes a color key value.
	 *
	 * @param __cs The input key value characters.
	 * @return The decoded color value.
	 * @since 2016/05/22
	 */
	private int __decodeColor(CharSequence __cs)
	{
		// Too short?
		int n = __cs.length();
		if (n <= 0)
			return 0x00_000000;
		
		// Must start with '#'
		if (__cs.charAt(0) != '#')
			return 0x00_000000;
		
		// Decode the first 8 digits
		int[] dig = new int[8];
		for (int i = 0, j = 1; i < 8 && j < n; i++, j++)
			dig[i] = Math.max(0, Character.digit(__cs.charAt(j), 16));
		
		// #rgb
		if (n == 4)
			return 0xFF_000000 |
				(dig[0] << 20) |
				(dig[0] << 16) |
				(dig[1] << 12) |
				(dig[1] << 8) |
				(dig[2] << 4) |
				(dig[2]);
		
		// #argb
		else if (n == 5)
			return (dig[0] << 28) |
				(dig[0] << 24) |
				(dig[1] << 20) |
				(dig[1] << 16) |
				(dig[2] << 12) |
				(dig[2] << 8) |
				(dig[3] << 4) |
				(dig[3]);
		
		// #rrggbb
		else if (n == 7)
			return 0xFF_000000 |
				(dig[0] << 20) |
				(dig[1] << 16) |
				(dig[2] << 12) |
				(dig[3] << 8) |
				(dig[4] << 4) |
				(dig[5]);
		
		// #aarrggbb
		else if (n == 9)
			return (dig[0] << 28) |
				(dig[1] << 24) |
				(dig[2] << 20) |
				(dig[3] << 16) |
				(dig[4] << 12) |
				(dig[5] << 8) |
				(dig[6] << 4) |
				(dig[7]);
		
		// Unknown
		else
			return 0x00_000000;
	}
	
	/**
	 * Locates a color for a given color.
	 *
	 * @param __c The code to find the color for.
	 * @param __codes The array of codes.
	 * @param __pal The color palette.
	 * @return The color code used.
	 * @since 2016/05/22
	 */
	private int __locateCode(int __c, int[] __codes, int[] __pal)
	{
		int at = Arrays.binarySearch(__codes, __c);
		if (at >= 0)
			return __pal[at];
		return 0;
	}
	
	/**
	 * Reads the color table of the XPM.
	 *
	 * @param __cs The source characters.
	 * @param __codes The output color codes.
	 * @param __palette The output color palette.
	 * @param __numcolors The number of colors used.
	 * @param __pxchars The number of characters per pixel.
	 * @return If an alpha channel was used.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private boolean __readColorTable(Reader __cs, int[] __codes,
		int[] __palette, int __numcolors, int __pxchars)
		throws IOException
	{
		// Had alpha?
		boolean hasalpha = false;
		
		// Decode the color palette
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < __numcolors; i++)
		{
			// Read new input string
			sb.setLength(0);
			__readLine(__cs, sb);
			
			// Ignore really short lines
			int n = sb.length();
			if (n < __pxchars)
				continue;
			
			// Set code to the given sequence
			int cx = 0;
			if (__pxchars >= 1)
				cx |= (int)sb.charAt(0);
			if (__pxchars >= 2)
				cx |= ((int)sb.charAt(1)) << 16;
			
			// Find the last color key value
			int s, e = n - 1;
			while (e >= __pxchars && sb.charAt(e) <= ' ')
			{
				e--;
				continue;
			}
			
			// Find the start of the color key
			s = e -1;
			while (s >= __pxchars && sb.charAt(s) > ' ')
			{
				s--;
				continue;
			}
			
			// Decode color, detect if there is a transparent pixel
			int col = __decodeColor(sb.subSequence(s + 1, e + 1));
			if ((col & 0xFF_000000) != 0xFF_000000)
				hasalpha = true;
			
			// Find the position to place the code at
			int at = Arrays.binarySearch(__codes, 0, i, cx);
			if (at < 0)
				at = -(at + 1);
			
			// Move all values up
			for (int j = i; j > at; j--)
			{
				__codes[j] = __codes[j - 1];
				__palette[j] = __palette[j - 1];
			}
			
			// Set the value
			__codes[at] = cx;
			__palette[at] = col;
		}
		
		// Return the alpha channel status
		return hasalpha;
	}
	
	/**
	 * Reads the XPM image heder.
	 *
	 * @param __r The source characters.
	 * @return The header values.
	 * @throws On read errors.
	 * @since 2016/05/22
	 */
	private int[] __readHeader(Reader __r)
		throws IOException
	{
		// Read XPM header
		int[] header = new int[7];
		for (int i = 0;; i++)
			if (__readInt(__r, header, Math.min(6, i)))
				break;
		
		// Return it
		return header;
	}
	
	/**
	 * Reads a single integer value from the input.
	 *
	 * @param __r The stream to read an integer from.
	 * @param __v The read value.
	 * @param __o The offset in the array index.
	 * @return {@code true} if the line or stream has ended.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private boolean __readInt(Reader __r, int[] __v, int __o)
		throws IOException
	{
		// Setup
		int val = 0;
		boolean neg = false;
		
		// Read character
		for (boolean first = true, startwhite = true;; first = false)
		{
			// Read
			int c = __r.read();
			
			// Ignore starting whitespace
			if (c == ' ' || c == '\t' || c == '\r')
				if (startwhite)
					continue;
			
			// No more whitespace to ignore
			startwhite = false;
			
			// EOF or EOL?
			if (c < 0)
			{
				__v[__o] = (neg ? -val : val);
				return true;
			}
			
			// Negative?
			if (first && c == '-')
			{
				neg = true;
				continue;
			}
			
			// As a digit
			int dig = Character.digit((char)c, 10);
			
			// If not a digit, stop
			if (dig < 0)
			{
				__v[__o] = (neg ? -val : val);
				return false;
			}
			
			// Shift up and add
			val *= 10;
			val += dig;
		}
	}
	
	/**
	 * Reads a single line into the given string builder.
	 *
	 * @param __r The stream to source characters from.
	 * @param __sb The buffer to store the temporary string data.
	 * @throws IOException On read errors.
	 * @since 2015/06/22
	 */
	private void __readLine(Reader __r, StringBuilder __sb)
		throws IOException
	{
		// Read until the end
		for (;;)
		{
			// Read character
			int c = __r.read();
			
			// End of stream or line?
			if (c < 0)
				return;
			
			// Append
			__sb.append((char)c);
		}
	}
	
	/**
	 * Reads the pixels from the XPM image.
	 *
	 * @param __cs The character source.
	 * @param __width The image width.
	 * @param __height The image height.
	 * @param __data The output data.
	 * @param __pxchars The characters per pixel.
	 * @param __codes The character codes.
	 * @param __palette The color palette.
	 * @throws IOException On read errors.
	 * @since 2016/05/22
	 */
	private void __readPixels(Reader __cs, int __width, int __height,
		int[] __data, int __pxchars, int[] __codes, int[] __palette)
		throws IOException
	{
		// Read the XPM image data for each rows
		int lastcode = -1;
		int lastpall = -1;
__outer:
		for (int y = 0; y < __height; y++)
			for (int x = 0, z = (y * __width);; x++)
			{
				// Read color code
				int code = 0;
				for (int i = 0; i < __pxchars; i++)
				{
					// Read
					int c = __cs.read();
					
					// Next row?
					if (c == __CharStripper__.END_OF_LINE)
						continue __outer;
					
					// EOF?
					else if (c < 0)
						break __outer;
					
					// First read?
					if (i == 0)
						code = c;
					
					// Second read?
					else if (i == 1)
						code |= c << 16;
				}
				
				// Used this color just before? In solidly linear areas, this
				// reduces the need for constant binary searches and increases
				// the parsing speed slightly.
				if (code == lastcode)
					__data[z++] = lastpall;
				
				// Find the code used
				else
				{
					lastpall = __locateCode((lastcode = code), __codes,
						__palette);
					__data[z++] = lastpall;
				}
			}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/__CharStripper__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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





















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.image;

import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;

/**
 * This is a character stripper which is used to remove C/C++ comments and
 * return the series of strings between curly braces. This does not perform
 * tokenization to remain as simple and as fast as possible, so XPM images
 * which use the preprocessor will likely not load properly. The decoder
 * generally assumes that the XPM is well formed.
 *
 * If a comma appears inside of the string array, then the character that would
 * be returned in its place is {@link #END_OF_LINE} character. This is because
 * XPM is a line based format.
 *
 * @since 2016/05/22
 */
class __CharStripper__
	extends Reader
{
	/** Special end of line code. */
	public static final int END_OF_LINE =
		Integer.MIN_VALUE;
	
	/** Lock to make sure there is a consistent state. */
	protected final Object lock =
		new Object();
	
	/** The input reader. */
	protected final Reader in;
	
	/** The current comment type (0 = none, 1 = single, 2 = multi. */
	private volatile int _comment;
	
	/** In a string literal? */
	private volatile boolean _instring;
	
	/** In the XPM bracket data. */
	private volatile boolean _inbracket;
	
	/** End of XPM? */
	private volatile boolean _endxpm;
	
	/**
	 * Initializes the character stripper.
	 *
	 * @param __r The source to strip characters from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/22
	 */
	__CharStripper__(Reader __r)
		throws NullPointerException
	{
		// Check
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __r;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public void close()
		throws IOException
	{
		// Lock
		synchronized (this.lock)
		{
			this.in.close();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public int read()
		throws IOException
	{
		// Lock
		synchronized (this.lock)
		{
			// Read loop to find a valid character
			Reader in = this.in;
			for (;;)
			{
				// End of the XPM?
				if (this._endxpm)
					return -1;
				
				// Read single character
				int c = in.read();
				
				// EOF?
				if (c < 0)
					return -1;
				
				// In a multi-line comment?
				int comment = this._comment;
				if (comment == 2)
				{
					// If an asterisk, possible end of multi-line	
					if (c == '*')
					{
						c = in.read();
						
						// EOF?
						if (c < 0)
							return -1;
						
						// End of multi-line?
						if (c == '/')
							this._comment = 0;
					}
					
					continue;
				}
				
				// Single line comment
				else if (comment == 1)
				{
					// If \r or \n, end of comment
					if (c == '\r' || c == '\n')
						this._comment = 0;
					
					continue;
				}
				
				// In string?
				if (this._instring)
				{
					// Escape sequence?
					if (c == '\\')
					{
						// Get character
						c = in.read();
						
						// Depends on the character
						switch (c)
						{
							case 'a': return (char)0x07;
							case 'b': return (char)0x08;
							case 'f': return (char)0x0C;
							case 'n': return '\n';
							case 'r': return '\r';
							case 't': return '\t';
							case 'v': return (char)0x0B;
							case '\\': return '\\';
							case '\'': return '\'';
							case '"': return '"';
							case '?': return '?';
							
							case 'x':
								{
									// Read all chars as hex
									int x = Character.digit((char)in.read(),
										16);
									int y = Character.digit((char)in.read(),
										16);
									
									// If all are valid, use it
									if (x >= 0 && y >= 0)
										return (x << 4) | (y);
									continue;
								}
								
							case '0':
							case '1':
							case '2':
							case '3':
							case '4':
							case '5':
							case '6':
							case '7':
							case '8':
							case '9':
								{
									// Read all chars as octal
									int x = Character.digit((char)c, 8);
									int y = Character.digit((char)in.read(),
										8);
									int z = Character.digit((char)in.read(),
										8);
									
									// If all are valid, use it
									if (x >= 0 && y >= 0 && z >= 0)
										return (x << 6) | (y << 3) | (z);
									continue;
								}
							
								// Unknown, ignore
							default:
								continue;
						}
					}
					
					// End of string?
					else if (c == '"')
					{
						this._instring = false;
						continue;
					}
					
					// Normal character, use it
					else
						return c;
				}
				
				// Outside a string
				else
				{
					// Starting bracket
					if (c == '{')
					{
						// Set in bracket
						this._inbracket = true;
					}
					
					// Ending brakcet
					else if (c == '}')
					{
						// End the XPM but only if in a bracket
						if (this._inbracket)
						{
							this._endxpm = true;
							continue;
						}
					}
					
					// Start of a string?
					else if (c == '"')
						this._instring = true;
					
					// Possible start of comment?
					else if (c == '/')
					{
						// Read next
						c = in.read();
						
						// EOF?
						if (c < 0)
							return -1;
						
						// Single line comment?
						if (c == '/')
							this._comment = 1;
						
						// Multi-line comment?
						else if (c == '*')
							this._comment = 2;
						
						// Unknown, ignore
						else
							continue;
					}
					
					// String separator
					else if (c == ',')
					{
						// If in a bracket, return a special code
						if (this._inbracket)
							return END_OF_LINE;
						
						// Otherwise, ignore it
						continue;
					}
					
					// Unknown, ignore
					else
						continue;
				}
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/22
	 */
	@Override
	public int read(char[] __b, int __o, int __l)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// Lock
		synchronized (this.lock)
		{
			// Read loop
			for (int i = 0; i < __l; i++)
				try
				{
					// Read single character
					int c = read();
				
					// EOF?
					if (c < 0)
						return (i > 0 ? i : -1);
				
					// Set
					__b[__o + i] = (char)c;
				}
			
				// Failed read
				catch (IOException e)
				{
					// If nothing read, fail
					if (i <= 0)
						throw e;
				
					// Otherwise return the read count
					return i;
				}
		
			// All characters read
			return __l;
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/image/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains support for reading images from various formats.
 *
 * @since 2017/10/26
 */

package cc.squirreljme.runtime.lcdui.image;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package provides support for LCDUI display engines.
 *
 * @since 2017/02/08
 */

package cc.squirreljme.runtime.lcdui;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ActionMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.KeyNames;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.FileSelector;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TabbedPane;
import javax.microedition.lcdui.TextBox;

/**
 * This represents an action method which when a key is pressed or similar
 * then something is done.
 *
 * @since 2019/05/18
 */
public enum ActionMethod
{
	/** Alert. */
	ALERT
	{
	},
	
	/** Canvas. */
	CANVAS
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			// Normalize all key types to mobile cell phone format, if not
			// specified
			if (__ch == '#')
				__kc = Canvas.KEY_POUND;
			else if (__ch == '*')
				__kc = Canvas.KEY_STAR;
			else if (__ch >= '0' && __ch <= '9')
				__kc = Canvas.KEY_NUM0 + (__ch - '0');
				
			// If the key-code is not valid then ignore
			if (__kc == NonStandardKey.UNKNOWN)
				return false;
			
			// Depends on the action
			switch (__ty)
			{
				case NativeDisplayEventCallback.KEY_PRESSED:
					__d.keyPressed(__kc);
					break;
				
				case NativeDisplayEventCallback.KEY_REPEATED:
					__d.keyRepeated(__kc);
					break;
				
				case NativeDisplayEventCallback.KEY_RELEASED:
					__d.keyReleased(__kc);
					break;
				
				default:
					break;
			}
			
			// Do not force a repaint, up to the canvas
			return false;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean pointerEvent(Displayable __d, State __s, int __ty,
			int __x, int __y, int __time)
		{
			ExposedDisplayable displayable = (ExposedDisplayable)__d;
			
			// Depends on the type
			switch (__ty)
			{
				case NativeDisplayEventCallback.POINTER_PRESSED:
					displayable.pointerPressed(__x, __y);
					break;
				
				case NativeDisplayEventCallback.POINTER_RELEASED:
					displayable.pointerReleased(__x, __y);
					break;
				
				case NativeDisplayEventCallback.POINTER_DRAGGED:
					displayable.pointerDragged(__x, __y);
					break;
				
				default:
					break;
			}
			
			// Do not force a repaint, up to the canvas
			return false;
		}
	},
	
	/** File selector. */
	FILE_SELECTOR
	{
	},
	
	/** Form. */
	FORM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			return false;
		}
	},
	
	/** List. */
	LIST
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final boolean keyEvent(Displayable __d, State __s, int __ty,
			int __kc, int __ch, int __time)
		{
			List list = (List)__d;
			int n = list.size();
			int ltype = list.getType();
			
			// Ignore released keys
			if (__ty == NativeDisplayEventCallback.KEY_RELEASED)
				return false;
			
			// Quickly focus an item?
			int focusdx = __s.focusdx,
				wantdx = focusdx;
			if (__kc >= Canvas.KEY_NUM1 && __kc <= Canvas.KEY_NUM9)
				wantdx = __kc - Canvas.KEY_NUM1;
			
			// Handle key
			switch (EventTranslate.keyCodeToGameAction(__kc))
			{
					// Move up, ignore number input
				case Canvas.UP:
					wantdx = focusdx - 1;
					break;
				
					// Move down, ignore number input
				case Canvas.DOWN:
					wantdx = focusdx + 1;
					break;
					
					// Select item
				case Canvas.FIRE:
					// Only allow enabled items to have their selection state
					// adjusted
					if (focusdx >= 0 && focusdx < n && list.isEnabled(focusdx))
					{
						// Set new selection state, exclusive lists always
						// set a new element
						boolean nowsel = (!list.isSelected(focusdx) ||
							ltype == Choice.EXCLUSIVE ||
							ltype == Choice.IMPLICIT);
						
						// Set new state
						list.setSelectedIndex(focusdx, nowsel);
						
						// Implicit lists need their item to be specified
						if (ltype == Choice.IMPLICIT)
						{
							// Execute command when selection was changed?
							Command sc = list.getSelectCommand();
							if (sc != null)
							{
								CommandListener l = ((ExposedDisplayable)__d).
									getCommandListener();
								if (l != null)
									l.commandAction(sc, __d);
							}
						}
						
						// Should be repainted
						return true;
					}
					
					// Not to be repainted
					return false;
			}
			
			// Change of focus and it is valid?
			if (focusdx != wantdx && wantdx >= 0 && wantdx < n)
			{
				// Set new focus
				__s.focusdx = wantdx;
				
				// If this is an implicit list then automatically select
				// the given focused item
				if (list.getType() == Choice.IMPLICIT)
					list.setSelectedIndex(wantdx, true);
				
				// Repaint
				return true;
			}
			
			// Nothing happened
			return false;
		}
	},
	
	/** Tabbed Pane. */
	TABBED_PANE
	{
	},
	
	/** Text Box. */
	TEXT_BOX
	{
	},
	
	/** End. */
	;
	
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __c The command to execute.
	 * @return {@code true} if the command was handled.
	 * @since 2019/05/18
	 */
	public boolean command(Displayable __d, State __s, int __c)
	{
		return false;
	}
	
	/**
	 * Key action has been performed.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @return {@code true} if the display should be repainted.
	 * @since 2019/05/18
	 */
	public boolean keyEvent(Displayable __d, State __s, int __ty, int __kc,
		int __ch, int __time)
	{
		return false;
	}
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __d The displayable.
	 * @param __s The state.
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @return {@code true} if the display should be repainted.
	 * @since 2019/05/18
	 */
	public boolean pointerEvent(Displayable __d, State __s, int __ty, int __x,
		int __y, int __time)
	{
		return false;
	}
	
	/**
	 * Returns the action method for the given class.
	 *
	 * @param __cl The class to act for.
	 * @return The action method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/18
	 */
	public static final ActionMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (Alert.class.isAssignableFrom(__cl))
			return ALERT;
		else if (Canvas.class.isAssignableFrom(__cl))
			return CANVAS;
		else if (FileSelector.class.isAssignableFrom(__cl))
			return FILE_SELECTOR;
		else if (Form.class.isAssignableFrom(__cl))
			return FORM;
		else if (List.class.isAssignableFrom(__cl))
			return LIST;
		else if (TabbedPane.class.isAssignableFrom(__cl))
			return TABBED_PANE;
		else if (TextBox.class.isAssignableFrom(__cl))
			return TEXT_BOX;
		
		// {@squirreljme.error EB17 Could not get the action method of the
		// given class. (The class)}
		throw new IllegalArgumentException("EB17 " + __cl);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ActiveDisplay.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521









































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Text;
import javax.microedition.lcdui.Ticker;
import java.util.Arrays;

/**
 * This contains the display display along with the internal image buffer.
 *
 * @since 2019/05/16
 */
public final class ActiveDisplay
{
	/** The width of the display. */
	protected final int width;
	
	/** The height of the display. */
	protected final int height;
	
	/** The displayable to draw. */
	volatile Displayable _current;
	
	/** The drawing method to use. */
	volatile DrawingMethod _drawing;
	
	/** The action method to use. */
	volatile ActionMethod _action;
	
	/** Current drawing state. */
	volatile State _state;
	
	/** Content X Area. */
	int _contentx;
	
	/** Content Y Area. */
	int _contenty;
	
	/** Width of the content area. */
	int _contentwidth;
	
	/** Height of the content area. */
	int _contentheight;
	
	/** The title to use. */
	String _title;
	
	/**
	 * Initializes the active display.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public ActiveDisplay(int __w, int __h)
	{
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Default content area size
		this._contentwidth = __w;
		this._contentheight = __h - (StandardMetrics.TITLE_BAR_HEIGHT +
			StandardMetrics.COMMAND_BAR_HEIGHT +
			StandardMetrics.TICKER_BAR_HEIGHT);
	}
	
	/**
	 * Activates the display.
	 *
	 * @param __d The displayable to be drawn when requested.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public final void activate(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// If the displayable has not changed, ignore
		Displayable current = this._current;
		if (current == __d)
			return;
		
		// Set
		this._current = __d;
		this._drawing = DrawingMethod.of(__d.getClass());
		this._action = ActionMethod.of(__d.getClass());
		this._state = ((ExposedDisplayable)__d)._dstate;
		
		// Realize the dimensions
		this.realize(PhoneUI._IGNORE_REALIZATION);
	}
	
	/**
	 * Executes the numbered command on the given display.
	 *
	 * @param __c The command to execute.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean command(int __c)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Forward action, if it was not handled by this display then fallback
		// to the displayable commands
		CommandListener l = ((ExposedDisplayable)current).getCommandListener();
		if (!this._action.command(current, this._state, __c))
		{
			// Get all commands
			Command[] commands = current.getCommands();
			int numcommands = commands.length;
			
			// Call command function
			if (__c >= 0 && __c < numcommands)
			{
				// Run command
				l.commandAction(commands[__c], current);
				
				// Always redraw it
				return true;
			}
		}
		
		// Not handled
		return false;
	}
	
	/**
	 * Requests that the program be terminated.
	 *
	 * @since 2019/05/18
	 */
	public final void exitRequest()
	{
		// Ignore if nothing is set
		Displayable current = this._current;
		if (current == null)
			return;
		
		// Search through commands for an exit one to execute
		CommandListener l = ((ExposedDisplayable)current).getCommandListener();
		if (l != null)
			for (Command c : current.getCommands())
				if (c.getCommandType() == Command.EXIT)
				{
					// Execute command
					l.commandAction(c, current);
					
					// Done
					return;
				}
		
		// Otherwise just terminate the application
		System.exit(0);
	}
	
	/**
	 * Key action has been performed.
	 *
	 * @param __d The display ID.
	 * @param __ty The type of key event.
	 * @param __kc The key code.
	 * @param __ch The key character, {@code -1} is not valid.
	 * @param __time Timecode.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean keyEvent(int __ty, int __kc, int __ch, int __time)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Execute command via function key?
		if (__ty == NativeDisplayEventCallback.KEY_PRESSED &&
			__kc >= NonStandardKey.F1 && __kc <= NonStandardKey.F24)
			return this.command(__kc - NonStandardKey.F1);
		
		// Forward action
		return this._action.keyEvent(current, this._state, __ty, __kc, __ch,
			__time);
	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __g The backend graphics to draw on.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public final void paint(Graphics __g, int __x, int __y, int __w, int __h)
	{
		// Get display details
		int dw = this.width,
			dh = this.height;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Realize new content area coordinates
		int[] ua = new int[4];
		if (this.realize(ua))
			current.sizeChanged(ua[2], ua[3]);
		
		// Extract coordinates
		int ux = ua[0],
			uy = ua[1],
			uw = ua[2],
			uh = ua[3];
		
		// If not full-screen, then draw title bar and maybe the command bar
		if (uh != dh)
		{
			// Remember default parameters
			Font oldfont = __g.getFont();
			int oldcolor = __g.getColor();
			
			// Draw background
			__g.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
			__g.fillRect(0, 0, dw, StandardMetrics.TITLE_BAR_HEIGHT);
			
			// Set font
			__g.setFont(Font.getFont("sansserif", 0,
				StandardMetrics.TITLE_BAR_HEIGHT));
			
			// Draw title text
			String title = this._title;
			__g.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
			__g.drawString(title, 0, 0, Graphics.TOP | Graphics.LEFT);
			__g.drawString(title, 1, 0, Graphics.TOP | Graphics.LEFT);
			
			// Draw the ticker?
			Ticker ticker = (current == null ? null : current.getTicker());
			if (ticker != null)
			{
				// Background
				__g.setColor(StandardMetrics.BACKGROUND_TICKER_COLOR);
				__g.fillRect(0, StandardMetrics.TITLE_BAR_HEIGHT,
					dw, StandardMetrics.TICKER_BAR_HEIGHT);
				
				// Draw ticker text
				__g.setColor(StandardMetrics.FOREGROUND_TICKER_COLOR);
				__g.drawString(ticker.getString(),
					0, StandardMetrics.TITLE_BAR_HEIGHT,
					Graphics.TOP | Graphics.LEFT);
			}
			
			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			if (numcommands > 0)
			{
				// Base Y position
				int cy = dh - StandardMetrics.COMMAND_BAR_HEIGHT;
				
				// Draw background
				__g.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
				__g.fillRect(0, cy, dw, StandardMetrics.COMMAND_BAR_HEIGHT);
				
				// Draw the first added command
				__g.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
				__g.drawString(commands[0].getLabel(), 0, cy,
					Graphics.TOP | Graphics.LEFT);
				
				// Draw second command?
				if (numcommands > 1)
					__g.drawString((numcommands == 2 ? commands[1].getLabel() :
						"Menu"), dw >> 1, cy, Graphics.TOP | Graphics.LEFT);
			}
			
			// Restore parameters
			__g.setFont(oldfont);
			__g.setColor(oldcolor);
		}
		
		// Setup enforced graphics
		Graphics ug = new EnforcedDrawingAreaGraphics(__g,
			ux, uy, uw, uh);
		
		// If nothing is being shown, just show the version info
		if (current == null)
		{
			// Draw box
			ug.setColor(0x0000FF);
			ug.fillRect(0, 0, uw, uh);
			
			// Draw some layout text
			ug.setColor(0xFFFF00);
			ug.setFont(Font.getFont("sansserif", 0, 16));
			ug.drawString("SquirrelJME " + SquirrelJME.RUNTIME_VERSION + "\n" +
				"(C) Stephanie Gawroriski\n" +
				"https://squirreljme.cc/\nLicensed w/ the GPLv3!", 0, 0, 0);
			ug.drawString("SquirrelJME", 1, 0, 0);
		}
		
		// Normal painting
		else
		{
			// If the displayable is transparent then, we fill in the
			// background for the application
			if (current.isTransparent())
			{
				// Use background color instead
				int oldcolor = ug.getColor();
				ug.setColor(StandardMetrics.TRANSPARENT_COLOR);
				
				// Fill
				ug.fillRect(0, 0, uw, uh);
				
				// Restore
				ug.setColor(oldcolor);
			}
			
			// Paint
			State state = this._state;
			try
			{
				this._drawing.paint((Displayable)current, state, ug, uw, uh);
			}
			
			// Completely messed up!
			catch (RuntimeException e)
			{
				try
				{
					// Draw text message
					Text message = new Text(String.format("%s: %s",
						e.getClass().getName(), e.getMessage()), uw, uh);
					
					// Set properties
					message.setBackgroundColor(
						StandardMetrics.itemBackgroundColor(true, true));
					message.setForegroundColor(
						StandardMetrics.itemForegroundColor(true, true));
					
					// Draw it now
					ug.drawText(message, 0, 0);
				}
				
				// Failed to draw the error?
				catch (RuntimeException f)
				{
					// Suppress it
					e.addSuppressed(f);
					
					// And print
					e.printStackTrace();
				}
				
				// Re-toss original exception
				throw e;
			}
			
			// Draw the focus box
			State.Box focusbox = state.focusbox;
			if (focusbox.x >= 0)
			{
				// Draw primary color
				ug.setColor(StandardMetrics.FOCUS_A_COLOR);
				ug.setAlpha(0x7F);
				ug.setStrokeStyle(Graphics.SOLID);
				ug.drawRect(focusbox.x, focusbox.y, focusbox.w, focusbox.h);
				
				// Draw secondary color
				ug.setColor(StandardMetrics.FOCUS_B_COLOR);
				ug.setAlpha(0xFF);
				ug.setStrokeStyle(Graphics.DOTTED);
				ug.drawRect(focusbox.x, focusbox.y, focusbox.w, focusbox.h);
				
				// Restore stroke
				ug.setStrokeStyle(Graphics.SOLID);
			}
		}
		
		// Clear clip for status symbols and focus
		__g.setClip(0, 0, dw, dh);
		
		// Switch to the symbol font
		Font sf = Font.getFont("symbol", 0, StandardMetrics.TITLE_BAR_HEIGHT);
		__g.setFont(sf);
		int xa = sf.charWidth('#'),
			sx = dw - 2;
	}
	
	/**
	 * Pointer event has occured.
	 *
	 * @param __ty The type of pointer event.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __time Timecode.
	 * @return If the display should be repainted.
	 * @since 2019/05/18
	 */
	public final boolean pointerEvent(int __ty, int __x, int __y, int __time)
	{
		// Display must be active
		Displayable current = this._current;
		if (current == null)
			return false;
		
		// Forward action, un-offset the coordinates so that they are within
		// the bounds of the content instead of just absolutely on the screen
		return this._action.pointerEvent(current, this._state, __ty,
			__x - this._contentx, __y - this._contenty, __time);
	}
	
	/**
	 * Realizes the size of the content area.
	 *
	 * @param __dims The output content area dimensions.
	 * @return {@code true} if the area has been resized.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public final boolean realize(int[] __dims)
		throws NullPointerException
	{
		if (__dims == null)
			throw new NullPointerException("NARG");
		
		// Screen size
		int dw = this.width,
			dh = this.height;
		
		// User area
		int ux, uy, uw, uh;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Full-screen uses the entire screen
		if (current != null && current.isFullscreen())
		{
			ux = 0;
			uy = 0;
			uw = dw;
			uh = dh;
		}
		
		// Otherwise, space is lost to the title bar and commands
		else
		{
			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			
			// Drawing the ticker?
			int drawticker = (current != null && current.getTicker() != null ?
				StandardMetrics.TICKER_BAR_HEIGHT : 0);
			
			// Clip dimensions
			ux = 0;
			uy = StandardMetrics.TITLE_BAR_HEIGHT + drawticker;
			uw = dw;
			uh = dh - (StandardMetrics.TITLE_BAR_HEIGHT +
				(numcommands > 0 ? StandardMetrics.COMMAND_BAR_HEIGHT : 0) +
				drawticker);
		}
		
		// Has the area changed?
		boolean rv = false;
		int oldux = this._contentx,
			olduy = this._contenty,
			olduw = this._contentwidth,
			olduh = this._contentheight;
		if (ux != oldux || uy != olduy || uw != olduw || uh != olduh)
		{
			// Did change
			rv = true;
			
			// Set new fields
			this._contentx = ux;
			this._contenty = uy;
			this._contentwidth = uw;
			this._contentheight = uh;
		}
		
		// Set output user area dimensions
		__dims[0] = ux;
		__dims[1] = uy;
		__dims[2] = uw;
		__dims[3] = uh;
		
		// Has this changed at all?
		return rv;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/DrawingItemMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217

























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

/**
 * The method used for drawing items.
 *
 * @since 2019/12/09
 */
public enum DrawingItemMethod
{
	/** Choice group. */
	CHOICE_GROUP
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Choice Group", __x, __y, Graphics.TOP);
		}
	},
	
	/** Custom item. */
	CUSTOM_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Custom Item", __x, __y, Graphics.TOP);
		}
	},
	
	/** Date field. */
	DATE_FIELD
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Date Field", __x, __y, Graphics.TOP);
		}
	},
	
	/** Gauge. */
	GAUGE
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Gauge", __x, __y, Graphics.TOP);
		}
	},
	
	/** Image item. */
	IMAGE_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Image Item", __x, __y, Graphics.TOP);
		}
	},
	
	/** Spacer. */
	SPACER
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Spacer", __x, __y, Graphics.TOP);
		}
	},
	
	/** String item. */
	STRING_ITEM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			StringItem item = (StringItem)__i;
			
			// Only draw text if it is to be displayed
			String text = item.getText();
			if (text != null)
			{
				// Set font to use
				__g.setFont(item.getFont());
				
				// Draw text
				__g.drawString(text, __x, __y, 0);
			}
		}
	},
	
	/** Text field. */
	TEXT_FIELD
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/12/09
		 */
		@Override
		public void paint(Displayable __d, Item __i, State __s, Graphics __g,
			int __x, int __y, int __w, int __h, boolean __enb, boolean __sel)
		{
			__g.drawString("Text Field", __x, __y, Graphics.TOP);
		}
	},

	/** End. */
	;
	
	/**
	 * Paints the method.
	 *
	 * @param __d The displayable to be drawn.
	 * @param __i The item to draw.
	 * @param __s The draw state.
	 * @param __g The graphics to draw to.
	 * @param __x The X position.
	 * @param __h The Y position.
	 * @param __w The item width.
	 * @param __h The item height.
	 * @param __enb Is this enabled?
	 * @param __sel Is this selected?
	 * @since 2019/12/09
	 */
	public abstract void paint(Displayable __d, Item __i, State __s,
		Graphics __g, int __x, int __y, int __w, int __h, boolean __enb,
		boolean __sel);
	
	/**
	 * Returns the drawing method for the given class.
	 *
	 * @param __cl The class to draw for.
	 * @return The drawing method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/09
	 */
	public static final DrawingItemMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (ChoiceGroup.class.isAssignableFrom(__cl))
			return CHOICE_GROUP;
		else if (CustomItem.class.isAssignableFrom(__cl))
			return CUSTOM_ITEM;
		else if (DateField.class.isAssignableFrom(__cl))
			return DATE_FIELD;
		else if (Gauge.class.isAssignableFrom(__cl))
			return GAUGE;
		else if (ImageItem.class.isAssignableFrom(__cl))
			return IMAGE_ITEM;
		else if (Spacer.class.isAssignableFrom(__cl))
			return SPACER;
		else if (StringItem.class.isAssignableFrom(__cl))
			return STRING_ITEM;
		else if (TextField.class.isAssignableFrom(__cl))
			return TEXT_FIELD;
		
		// {@squirreljme.error EB39 Could not get the item drawing method of
		// the given class. (The class)}
		throw new IllegalArgumentException("EB39 " + __cl);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/DrawingMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315



























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.FileSelector;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TabbedPane;
import javax.microedition.lcdui.TextBox;

/**
 * This contains various drawing methods which modify how a display is
 * drawn.
 *
 * @since 2019/05/18
 */
public enum DrawingMethod
{
	/** Alert. */
	ALERT
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("ALERT", 0, 0, 0);
		}
	},
	
	/** Canvas. */
	CANVAS
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			((ExposedDisplayable)__d).paint(__g);
		}
	},
	
	/** File selector. */
	FILE_SELECTOR
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("FILE_SELECTOR", 0, 0, 0);
		}
	},
	
	/** Form. */
	FORM
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			Form form = (Form)__d;
			
			// Number of entries
			int n = form.size();
			
			// Working base coordinates for each item
			int dx = 0,
				dy = 0;
			
			// Font and height for labels
			Font labelfont = StandardMetrics.itemLabelFont();
			int labelh = labelfont.getHeight();
			
			// Draw each entry
			for (int i = 0; i < n; i++)
			{
				// Reset X draw
				dx = 0;
				
				// Get item here
				Item item = form.get(i);
				
				// Get item properties
				String il = item.getLabel();
				int iw = Math.min(__w, item.getPreferredWidth());
				int ih = item.getPreferredHeight();
				boolean ie = true;
				boolean is = false;
				
				// Fill background in
				__g.setAlphaColor(StandardMetrics.itemBackgroundColor(ie, is));
				__g.fillRect(dx, dy, iw, ih);
				
				// Set used color
				__g.setAlphaColor(StandardMetrics.itemForegroundColor(ie, is));
				
				// Draw label if one is used
				if (il != null)
				{
					// Draw label
					__g.setFont(labelfont);
					__g.drawString(il, dx, dy, Graphics.TOP);
					
					// Move to item area now
					dy += labelh;
				}
				
				// Draw the item
				DrawingItemMethod.of(item.getClass()).paint(__d, item, __s,
					__g, dx, dy, iw, ih, true, false);
				
				// Is this item being focused? Set the focus box on it
				/*if (item == form.getCurrent())
					__s.focusbox.set(dx, dy, iw - 2, ih - 2);*/
				
				// Move to next item
				dy += ih;
			}
		}
	},
	
	/** List. */
	LIST
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			List list = (List)__d;
			
			// Working base coordinates for each item
			int dx = 0,
				dy = 0;
			
			// Selected index
			int sel = list.getSelectedIndex();
			
			// Make sure focus is in bounds
			int focusdx = __s.focusdx;
			int n = list.size();
			if (focusdx < 0)
				focusdx = 0;
			else if (focusdx >= n)
				focusdx = n - 1;
			
			// Default font
			Font dfont = Font.getFont(StandardMetrics.LIST_ITEM_FONT, 0,
				StandardMetrics.LIST_ITEM_HEIGHT);
			
			// Draw all list items
			for (int i = 0; i < n; i++)
			{
				// Reset X draw
				dx = 0;
				
				// Get item properties
				String vs = list.getString(i);
				Image vi = list.getImage(i);
				Font vf = list.getFont(i);
				boolean ve = list.isEnabled(i);
				boolean vl = list.isSelected(i);
				
				// Use a default fallback font?
				if (vf == null)
					vf = dfont;
				
				// Height of this item
				int ih = vf.getPixelSize();
				
				// Increase height for the image size?
				if (vi != null)
				{
					int mh = vi.getHeight();
					if (mh > ih)
						ih = mh;
				}
				
				// Draw background
				__g.setColor(StandardMetrics.itemBackgroundColor(ve, vl));
				__g.fillRect(dx, dy,
					__w, ih);
				
				// Draw image?
				if (vi != null)
				{
					__g.drawImage(vi, dx, dy, Graphics.TOP | Graphics.LEFT);
					dx += vi.getWidth();
				}
				
				// Draw text
				__g.setColor(StandardMetrics.itemForegroundColor(ve, vl));
				__g.setFont(vf);
				__g.drawString(vs, dx, dy, Graphics.TOP | Graphics.LEFT);
				
				// Is this item being focused?
				if (focusdx == i)
					__s.focusbox.set(dx, dy, __w - 2, ih - 2);
				
				// Move to next item
				dy += ih;
			}
		}
	},
	
	/** Tabbed pane. */
	TABBED_PANE
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("TABBED_PANE", 0, 0, 0);
		}
	},
	
	/** Text box. */
	TEXT_BOX
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/05/18
		 */
		@Override
		public final void paint(Displayable __d, State __s, Graphics __g,
			int __w, int __h)
		{
			__g.drawString("TEXT_BOX", 0, 0, 0);
		}
	},
	
	/** End. */
	;
	
	/**
	 * Paints the method.
	 *
	 * @param __d The displayable to be drawn.
	 * @param __s The draw state.
	 * @param __g The graphics to draw to.
	 * @param __w The display width.
	 * @param __h The display height.
	 * @since 2019/05/18
	 */
	public abstract void paint(Displayable __d, State __s, Graphics __g,
		int __w, int __h);
	
	/**
	 * Returns the drawing method for the given class.
	 *
	 * @param __cl The class to draw for.
	 * @return The drawing method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/18
	 */
	public static final DrawingMethod of(Class<?> __cl)
		throws NullPointerException
	{
		if (Alert.class.isAssignableFrom(__cl))
			return ALERT;
		else if (Canvas.class.isAssignableFrom(__cl))
			return CANVAS;
		else if (FileSelector.class.isAssignableFrom(__cl))
			return FILE_SELECTOR;
		else if (Form.class.isAssignableFrom(__cl))
			return FORM;
		else if (List.class.isAssignableFrom(__cl))
			return LIST;
		else if (TabbedPane.class.isAssignableFrom(__cl))
			return TABBED_PANE;
		else if (TextBox.class.isAssignableFrom(__cl))
			return TEXT_BOX;
		
		// {@squirreljme.error EB18 Could not get the drawing method of the
		// given class. (The class)}
		throw new IllegalArgumentException("EB18 " + __cl);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ExposedDisplayable.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
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
191































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Ticker;

/**
 * This is a base class for items which need to be exposed action wise and
 * such. All methods here by default do nothing.
 *
 * @since 2019/05/17
 */
public abstract class ExposedDisplayable
{
	/** Drawing/action state. */
	final State _dstate =
		new State();
	
	/**
	 * Returns the command listener.
	 *
	 * @return The command listener.
	 * @since 2019/05/18
	 */
	protected CommandListener getCommandListener()
	{
		return null;
	}
	
	/**
	 * Gets the commands which are available to use.
	 *
	 * @return The available commands.
	 * @since 2019/05/17
	 */
	protected Command[] getCommands()
	{
		return new Command[0];
	}
	
	/**
	 * Gets the ticker which is being shown on this displayable.
	 *
	 * @return The ticker being shown or {@code null} if there is none.
	 * @since 2019/05/18
	 */
	protected Ticker getTicker()
	{
		return null;
	}
	
	/**
	 * Is this widget a full-screen one?
	 *
	 * @return If this is full-screen or not.
	 * @since 2019/05/17
	 */
	protected boolean isFullscreen()
	{
		return false;
	}
	
	/**
	 * Is this display transparent?
	 *
	 * @return If the display is transparent.
	 * @since 2019/05/17
	 */
	protected boolean isTransparent()
	{
		return true;
	}
	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyPressed(int __code)
	{
	}
	
	/**
	 * This is called when a key has been released.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyReleased(int __code)
	{
	}
	
	/**
	 * This is called when a key has been repeated.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void keyRepeated(int __code)
	{
	}
	
	/**
	 * This is called when the displayable needs to be painted onto the
	 * screen.
	 *
	 * @param __g The graphics to draw into.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void paint(Graphics __g)
	{
	}
	
	/**
	 * This is called when the pointer is being dragged across the canvas, a
	 * drag is when there is movement 
	 *
	 * This requires that motion events are supported which can be known by
	 * calling {@link #hasPointerMotionEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerDragged(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been pressed on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2019/05/18
	 */
	@SerializedEvent
	protected void pointerPressed(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been released on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2019/05/18
	 */
	@SerializedEvent
	protected void pointerReleased(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the size of the displayable has changed.
	 *
	 * @param __w The new width of the displayable.
	 * @param __h The new heigh of the displayable.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/NativeUIBackend.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426










































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import cc.squirreljme.runtime.lcdui.gfx.AcceleratedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This is a backend which utilizes the SquirrelJME UI interface for all of
 * the related drawing applications.
 *
 * @since 2019/05/16
 */
public final class NativeUIBackend
	implements NativeDisplayEventCallback, PhoneDisplayBackend
{
	/**
	 * {@squirreljme.property cc.squirreljme.lcdui.acceleration=bool
	 * Should accelerated graphics be used if it is available? This defaults
	 * to {@code true} and it is recommended it be used, otherwise it may be
	 * disabled if it causes issues with some software.}
	 */
	public static boolean USE_ACCELERATION =
		Boolean.valueOf(System.getProperty("cc.squirreljme.lcdui.acceleration",
		"true"));
	
	/** The native display ID. */
	protected final int nid;
	
	/** The pixel format of the buffer. */
	protected final PixelFormat pixelformat;
	
	/** The active display to use. */
	private volatile ActiveDisplay _activedisplay;
	
	/** The display width. */
	private int _width;
	
	/** The display height. */
	private int _height;
	
	/**
	 * Initializes the native UI backend using the given display ID.
	 *
	 * @param __nid The native display ID this uses.
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Throw an exception if this has failed
		int pft = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_FORMAT);
		SystemCallError.checkError(SystemCallIndex.FRAMEBUFFER);
		
		// Set pixel format
		this.pixelformat = PixelFormat.ofFramebuffer(pft);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void activate(ActiveDisplay __ad)
		throws NullPointerException
	{
		if (__ad == null)
			throw new NullPointerException("NARG");
		
		// Set the active display
		this._activedisplay = __ad;
		
		if (true)
			throw new todo.TODO();
		
		// Register self for event callbacks
		NativeDisplayAccess.registerEventCallback(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	public final int capabilities()
	{
		// Get native capabilities
		int fbcaps = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_GET_CAPABILITIES);
		
		// Translate to LCDUI capabilities
		int rv = 0;
		if ((fbcaps & Framebuffer.CAPABILITY_TOUCH) != 0)
			rv |= ExtendedCapabilities.SUPPORTS_POINTER_EVENTS |
				Display.SUPPORTS_INPUT_EVENTS;
		if ((fbcaps & Framebuffer.CAPABILITY_KEYBOARD) != 0)
			rv |= Display.SUPPORTS_INPUT_EVENTS;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void command(int __d, int __c)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.command(__c))
			this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void exitRequest(int __d)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// Forward
		this._activedisplay.exitRequest();
	}
	
	/**
	 * Returns the native display graphics.
	 *
	 * @param __a Output boolean if this is accelerated.
	 * @param __dims Screen dimensions.
	 * @since 2019/05/16
	 */
	public final Graphics graphics(boolean[] __a, int[] __dims)
		throws NullPointerException
	{
		if (__dims == null)
			throw new NullPointerException("NARG");
		
		if (true)
			throw new todo.TODO();
		
		// Read width and height
		int[] params = NativeDisplayAccess.framebufferParameters(nid);
		int width = params[NativeDisplayAccess.PARAMETER_BUFFERWIDTH];
		int height = params[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT];
		
		// Set
		__dims[0] = width;
		__dims[1] = height;
		
		// Remember size
		this._width = width;
		this._height = height;
		
		// If acceleration is enabled, try to get accelerated graphics
		int nid = this.nid;
		if (USE_ACCELERATION)
			try
			{
				// Try to get it
				Graphics rv = AcceleratedGraphics.instance();
				
				// Set acceleration flag
				if (__a != null && __a.length > 1)
					__a[0] = true;
				
				return rv;
			}
			catch (UnsupportedOperationException e)
			{
			}
			
		// Get data buffers and properties
		Object buf = NativeDisplayAccess.framebufferObject(nid);
		int[] pal = NativeDisplayAccess.framebufferPalette(nid);
		
		// Set parameters
		boolean alpha = params[NativeDisplayAccess.PARAMETER_ALPHA] != 0;
		int pitch = params[NativeDisplayAccess.PARAMETER_PITCH];
		int offset = params[NativeDisplayAccess.PARAMETER_OFFSET];
		int virtxorig = params[NativeDisplayAccess.PARAMETER_VIRTXOFF];
		int virtyorig = params[NativeDisplayAccess.PARAMETER_VIRTYOFF];
		
		// Create graphics from it
		return this.pixelformat.createGraphics(buf, pal, width, height,
			alpha, pitch, offset, virtxorig, virtyorig);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final boolean isUpsidedown()
	{
		if (true)
			throw new todo.TODO();
		
		return NativeDisplayAccess.isUpsideDown(this.nid);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.keyEvent(__ty, __kc, __ch, __time))
			this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void lostCallback()
	{
		if (true)
			throw new todo.TODO();
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// Paint whatever is in the active display
		ActiveDisplay ad = this._activedisplay;
		if (ad != null)
		{
			// Get screen graphics and dimensions
			int[] dims = new int[2];
			Graphics g = this.graphics(null, dims);
			
			// Get display size and desired display size
			int gw = dims[0],
				gh = dims[1],
				dw = ad.width,
				dh = ad.height;
			
			// Perform potential centering?
			/*if (gw > dw && gh > dh)
				g = new EnforcedDrawingAreaGraphics(g,
					(gw >> 1) - (dw >> 1), (gh >> 1) - (dh >> 1),
					dw, dh);*/
			
			// Set clipping area
			g.setClip(0, 0, dw, dh);
			
			// Perform painting operation
			ad.paint(g, __x, __y, __w, __h);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final PixelFormat pixelFormat()
	{
		return this.pixelformat;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{
		if (true)
			throw new todo.TODO();
		
		// Not our display?
		if (__d != this.nid)
			return;
		
		// No display active?
		ActiveDisplay activedisplay = this._activedisplay;
		if (activedisplay == null)
			return;
		
		// Forward
		if (activedisplay.pointerEvent(__ty, __x, __y, __time))
			this.repaint();
	}
	
	/**
	 * Repaints the entire display.
	 *
	 * @since 2019/05/18
	 */
	public final void repaint()
	{
		if (true)
			throw new todo.TODO();
			
		NativeDisplayAccess.displayRepaint(this.nid,
			0, 0, this._width, this._height);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
			
		NativeDisplayAccess.displayRepaint(this.nid, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void shown(int __d, int __shown)
	{
		if (true)
			throw new todo.TODO();
			
		// Not our display?
		if (__d != this.nid)
			return;
		
		todo.TODO.note("Implement");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{
		if (true)
			throw new todo.TODO();
			
		// Not our display?
		if (__d != this.nid)
			return;
		
		ActiveDisplay ad = this._activedisplay;
		if (ad != null)
		{
			int[] dm = new int[4];
			if (ad.realize(dm))
				((ExposedDisplayable)ad._current).sizeChanged(dm[2], dm[3]);
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/PhoneDisplayBackend.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;

/**
 * This interface is used to represent the backend that the UI uses to draw
 * onto the target device. This may be an image or an actual UI.
 *
 * @since 2019/05/16
 */
public interface PhoneDisplayBackend
{
	/**
	 * Activates the display.
	 *
	 * @param __ad The active display to draw into.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public abstract void activate(ActiveDisplay __ad)
		throws NullPointerException;
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @return The display capabilities.
	 * @since 2019/05/17
	 */
	public abstract int capabilities();
	
	/**
	 * Returns if the display is upside-down, this is used for orientation
	 * purposes.
	 *
	 * @return If the display is upside-down.
	 * @since 2019/05/16
	 */
	public abstract boolean isUpsidedown();
	
	/**
	 * Returns the pixel format of the display.
	 *
	 * @return The display pixel format.
	 * @since 2019/05/16
	 */
	public abstract PixelFormat pixelFormat();
	
	/**
	 * Specifies that the display should be repainted now.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public abstract void repaint(int __x, int __y, int __w, int __h);
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/PhoneUI.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
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






















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This class contains the definition and holders for the phone based user
 * interface.
 *
 * @since 2019/05/16
 */
@Deprecated
public final class PhoneUI
{
	/** The width of the phone screen. */
	public static final int DEFAULT_SCREEN_WIDTH =
		240;
	
	/** The height of the phone screen. */
	public static final int DEFAULT_SCREEN_HEIGHT =
		320;
	
	/** Used to ignore realization. */
	static final int[] _IGNORE_REALIZATION =
		new int[4];
	
	/** The width of the phone screen. */
	public final int width;
	
	/** The height of the phone screen. */
	public final int height;
	
	/** The backend this UI uses. */
	protected final PhoneDisplayBackend backend;
	
	/** Active display image. */
	protected final ActiveDisplay activedisplay;
	
	/** The current displayable to show. */
	private Displayable _current;
	
	/** Should the display be repainted? */
	private volatile boolean _repaint;
	
	/**
	 * Initializes the base UI using the default screen size.
	 *
	 * @param __b The display backend to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public PhoneUI(PhoneDisplayBackend __b)
		throws NullPointerException
	{
		this(__b, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
	}
	
	/**
	 * Initializes the UI with the given screen width and height.
	 *
	 * @param __b The display backend to use.
	 * @param __sw The screen width.
	 * @param __sh The screen height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	public PhoneUI(PhoneDisplayBackend __b, int __sw, int __sh)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		this.backend = __b;
		this.width = (__sw = (__sw <= 0 ? DEFAULT_SCREEN_WIDTH : __sw));
		this.height = (__sh = (__sh <= 0 ? DEFAULT_SCREEN_HEIGHT : __sh));
		
		// Set active display
		ActiveDisplay activedisplay = new ActiveDisplay(__sw, __sh);
		this.activedisplay = activedisplay;
	}
	
	/**
	 * Returns the height of the content area.
	 *
	 * @return The content area height.
	 * @since 2019/05/16
	 */
	public final int contentHeight()
	{
		return this.activedisplay._contentheight;
	}
	
	/**
	 * Returns the width of the content area.
	 *
	 * @return The content area width.
	 * @since 2019/05/16
	 */
	public final int contentWidth()
	{
		return this.activedisplay._contentwidth;
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @since 2019/05/16
	 */
	public final void repaint()
	{
		this.repaint(0, 0, this.width, this.height);
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		// Realize active display size
		this.activedisplay.realize(PhoneUI._IGNORE_REALIZATION);
		
		// Repaint
		this.backend.repaint(__x, __y, __w, __h);
	}
	
	/**
	 * Sets the current displayable to be drawn.
	 *
	 * @param __d The displayable to draw.
	 * @since 2019/05/16
	 */
	public final void setCurrent(Displayable __d)
	{
		// Set
		this._current = __d;
		
		// Activate the display
		ActiveDisplay ad = this.activedisplay;
		ad.activate(__d);
		this.backend.activate(ad);
		
		// Repaint
		this.repaint();
	}
	
	/**
	 * Sets the title of what is displayed on the screen.
	 *
	 * @param __t The title to use, {@code null} uses a default title.
	 * @since 2019/05/16
	 */
	public final void setTitle(String __t)
	{
		// Default title?
		if (__t == null)
			__t = "SquirrelJME";
		
		// Set
		this.activedisplay._title = __t;
		
		// Repaint
		if (this._current != null)
			this.repaint();
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/StandardMetrics.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

import javax.microedition.lcdui.Font;

/**
 * This contains standard metrics for screen parts and such.
 *
 * @since 2019/05/16
 */
public final class StandardMetrics
{
	/** UI Font size. */
	public static final byte UI_FONT_SIZE =
		16;
	
	/** Height of the title bar. */
	public static final int TITLE_BAR_HEIGHT =
		UI_FONT_SIZE;
	
	/** Height of the command bar. */
	public static final int COMMAND_BAR_HEIGHT =
		UI_FONT_SIZE;
	
	/** The background bar color. */
	public static final int BACKGROUND_BAR_COLOR =
		0xFF_000000;
	
	/** The foreground bar color. */
	public static final int FOREGROUND_BAR_COLOR =
		0xFF_FFFFFF;
	
	/** Transparent background color. */
	public static final int TRANSPARENT_COLOR =
		0xFF_FFFFFF;
	
	/** Vibration symbol color. */
	public static final int VIBRATE_COLOR =
		0xFF_FF00FF;
	
	/** Height of the ticker bar. */
	public static final int TICKER_BAR_HEIGHT =
		UI_FONT_SIZE;
	
	/** Background color of the ticker bar. */
	public static final int BACKGROUND_TICKER_COLOR =
		0xFF_A6F6FF;
	
	/** Foreground color of the ticker bar. */
	public static final int FOREGROUND_TICKER_COLOR =
		0xFF_000000;
	
	/** The font used for list items. */
	public static final String LIST_ITEM_FONT =
		"sansserif";
	
	/** The height of list items. */
	public static final int LIST_ITEM_HEIGHT =
		UI_FONT_SIZE;
	
	/** Enabled normal foreground. */
	public static final int ENABLED_NORMAL_FOREGROUND =
		0xFF_000000;
	
	/** Enabled normal background. */
	public static final int ENABLED_NORMAL_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Enabled selected foreground. */
	public static final int ENABLED_SELECTED_FOREGROUND =
		0xFF_FFFFFF;
	
	/** Enable selected background. */
	public static final int ENABLED_SELECTED_BACKGROUND =
		0xFF_000088;
	
	/** Disabled normal foreground. */
	public static final int DISABLED_NORMAL_FOREGROUND =
		0xFF_888888;
	
	/** Disabled normal background. */
	public static final int DISABLED_NORMAL_BACKGROUND =
		0xFF_FFFFFF;
	
	/** Disabled selected foreground. */
	public static final int DISABLED_SELECTED_FOREGROUND =
		0xFF_AAAAAA;
	
	/** Disabled selected background. */
	public static final int DISABLED_SELECTED_BACKGROUND =
		0xFF_888888;
	
	/** The focus box color (A). */
	public static final int FOCUS_A_COLOR =
		0xFF_FF0000;
	
	/** The focus box color (B). */
	public static final int FOCUS_B_COLOR =
		0xFF_FFFF00;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/16
	 */
	private StandardMetrics()
	{
	}
	
	/**
	 * Returns the background color.
	 *
	 * @param __en Is this enabled?
	 * @param __sl Is this selected?
	 * @return The color to use.
	 * @since 2019/05/18
	 */
	public static final int itemBackgroundColor(boolean __en, boolean __sl)
	{
		if (__en)
			if (__sl)
				return ENABLED_SELECTED_BACKGROUND;
			else
				return ENABLED_NORMAL_BACKGROUND;
		else
			if (__sl)
				return DISABLED_SELECTED_BACKGROUND;
			else
				return DISABLED_NORMAL_BACKGROUND;
	}
	
	/**
	 * Returns the foreground color.
	 *
	 * @param __en Is this enabled?
	 * @param __sl Is this selected?
	 * @return The color to use.
	 * @since 2019/05/18
	 */
	public static final int itemForegroundColor(boolean __en, boolean __sl)
	{
		if (__en)
			if (__sl)
				return ENABLED_SELECTED_FOREGROUND;
			else
				return ENABLED_NORMAL_FOREGROUND;
		else
			if (__sl)
				return DISABLED_SELECTED_FOREGROUND;
			else
				return DISABLED_NORMAL_FOREGROUND;
	}
	
	/**
	 * Returns the item label font.
	 *
	 * @return The item label font.
	 * @since 2019/12/09
	 */
	public static final Font itemLabelFont()
	{
		return Font.getFont(LIST_ITEM_FONT, 0, LIST_ITEM_HEIGHT);
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/State.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
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


























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.phoneui;

/**
 * This class contains the drawing state to modify what is on screen and
 * such.
 *
 * @since 2019/05/18
 */
public class State
{
	/** The focus index coordinates. */
	public final Box focusbox =
		new Box(-1, -1, 0, 0);
	
	/** The focused index. */
	public int focusdx;
	
	/**
	 * Represents a box.
	 *
	 * @since 2019/05/18
	 */
	public static final class Box
	{
		/** X coordinate. */
		public int x;
		
		/** Y coordinate. */
		public int y;
		
		/** Width. */
		public int w;
		
		/** Height. */
		public int h;
		
		/**
		 * Initializes a default box.
		 *
		 * @since 2019/05/18
		 */
		public Box()
		{
		}
		
		/**
		 * Initializes a box with the given coordinates and dimensions.
		 *
		 * @param __x X position.
		 * @param __y Y position.
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/05/18
		 */
		public Box(int __x, int __y, int __w, int __h)
		{
			this.x = __x;
			this.y = __y;
			this.w = __w;
			this.h = __h;
		}
		
		/**
		 * Sets all of the box coordinates.
		 *
		 * @param __x X position.
		 * @param __y Y position.
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/05/18
		 */
		public final void set(int __x, int __y, int __w, int __h)
		{
			this.x = __x;
			this.y = __y;
			this.w = __w;
			this.h = __h;
		}
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains and defines a user-interface which is very much like
 * ancient mobile phones to allow for maximum application compatibility.
 *
 * @since 2019/05/16
 */

package cc.squirreljme.runtime.lcdui.phoneui;

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/vfb/FramebufferTitleListener.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.vfb;

/**
 * This interface is used to notify of any title updates that have been
 * performed.
 *
 * @since 2020/01/17
 */
public interface FramebufferTitleListener
{
	/**
	 * This is called when the title is updated.
	 *
	 * @param __s The title to set.
	 * @since 2020/01/17
	 */
	public abstract void titleUpdated(String __s);
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/vfb/VirtualFramebuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290


































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.vfb;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.IPCCallback;

/**
 * This is a virtual framebuffer which may be used by non-SquirrelJME JVMs and
 * by higher level JVMs to allow for IPC based graphics to be used.
 *
 * This assumes that event handling is used.
 *
 * @since 2019/12/28
 */
public final class VirtualFramebuffer
{
	/** The default width. */
	public static final int DEFAULT_WIDTH =
		320;
	
	/** The default height. */
	public static final int DEFAULT_HEIGHT =
		200;
	
	/** The callback to invoke with screen actions. */
	protected final IPCCallback ipc;
	
	/** The width. */
	protected final int width;
	
	/** The height. */
	protected final int height;
	
	/** The raw pixel data. */
	protected final int[] pixels;
	
	/** Title listener. */
	private FramebufferTitleListener _titlelistener;
	
	/**
	 * Initializes the virtual framebuffer.
	 *
	 * @param __ipc The callback to forward events to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebuffer(IPCCallback __ipc)
		throws NullPointerException
	{
		this(__ipc, DEFAULT_WIDTH, DEFAULT_HEIGHT);
	}
	
	/**
	 * Initializes the virtual framebuffer.
	 *
	 * @param __ipc The callback to forward events to.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebuffer(IPCCallback __ipc, int __w, int __h)
	{
		if (__ipc == null)
			throw new NullPointerException("NARG");
		
		// Set IPC to use
		this.ipc = __ipc;
		
		// Set size
		this.width = __w;
		this.height = __h;
		
		// Initialize raw pixel data
		this.pixels = new int[__w * __h];
	}
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __args The call arguments.
	 * @return The result of the property.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public final long framebufferControl(int... __args)
		throws NullPointerException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		// Depends on the length
		switch (__args.length)
		{
				// Nothing to do?
			case 0:
				return 0;
			
			case 1:
				return this.framebufferControl(
					__args[0],
					0, 0, 0, 0, 0, 0, 0, 0);
			
			case 2:
				return this.framebufferControl(
					__args[0],
					__args[1],
					0, 0, 0, 0, 0, 0, 0);
			
			case 3:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					0, 0, 0, 0, 0, 0);
			
			case 4:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					0, 0, 0, 0);
			
			case 5:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					0, 0, 0);
			
			case 6:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					0, 0);
			
			case 7:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					__args[6],
					0);
			
			case 8:
				return this.framebufferControl(
					__args[0],
					__args[1],
					__args[2],
					__args[3],
					__args[4],
					__args[5],
					__args[6],
					__args[7]);
			
			default:
				return 0;
		}
	}
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __pid The property ID.
	 * @param __args The call arguments.
	 * @return The result of the property.
	 * @throws IllegalArgumentException If the property was not known.
	 * @since 2019/12/28
	 */
	public final long framebufferControl(int __pid, int __a, int __b, int __c,
		int __d, int __e, int __g, int __h)
		throws IllegalArgumentException
	{
		// Depends on the property
		switch (__pid)
		{
				// Raw address (since it is simulated, this is not set)
			case Framebuffer.CONTROL_ADDRESS:
				return 0;
				
				// Width and scanline length
			case Framebuffer.CONTROL_WIDTH:
			case Framebuffer.CONTROL_SCANLEN:
				return this.width;
				
				// Height
			case Framebuffer.CONTROL_HEIGHT:
				return this.height;
			
				// Flushes the display
			case Framebuffer.CONTROL_FLUSH:
				throw new todo.TODO();
				
				// Pixel format is always integer
			case Framebuffer.CONTROL_FORMAT:
				return Framebuffer.FORMAT_INTEGER_RGB888;
				
				// Scan line length in bytes
			case Framebuffer.CONTROL_SCANLEN_BYTES:
				return this.width * 4;
				
				// The number of bytes per pixel
			case Framebuffer.CONTROL_BYTES_PER_PIXEL:
				return 4;
				
				// Bits per pixel
			case Framebuffer.CONTROL_BITS_PER_PIXEL:
				return 32;
				
				// The number of pixels
			case Framebuffer.CONTROL_NUM_PIXELS:
				return this.width * this.height;
				
				// Backlight not supported
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_GET:
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_SET:
			case Framebuffer.CONTROL_BACKLIGHT_LEVEL_MAX:
				return 0;
				
				// Upload integer array
			case Framebuffer.CONTROL_UPLOAD_ARRAY_INT:
				throw new todo.TODO();
				
				// The backing array object
			case Framebuffer.CONTROL_BACKING_ARRAY_OBJECT:
				return Assembly.objectToPointer(this.pixels);
				
				// Returns the capabilities of the display.
			case Framebuffer.CONTROL_GET_CAPABILITIES:
				return Framebuffer.CAPABILITY_TOUCH |
					Framebuffer.CAPABILITY_KEYBOARD |
					Framebuffer.CAPABILITY_IPC_EVENTS |
					Framebuffer.CAPABILITY_COLOR;
				
				// Query acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_QUERY:
				throw new todo.TODO();
			
				// Perform acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_INVOKE:
				throw new todo.TODO();
				
				// Set title
			case Framebuffer.CONTROL_SET_TITLE:
				if (__a != 0)
				{
					FramebufferTitleListener tl = this._titlelistener;
					if (tl != null)
						tl.titleUpdated(
							new String((char[])Assembly.pointerToObject(__a)));
				}
				return 0;
				
				// {@squirreljme.error EB3b Unknown control property.}
			default:
				throw new IllegalArgumentException("EB3b");
		}
	}
	
	/**
	 * Returns the framebuffer pixels.
	 *
	 * @return The framebuffer pixels.
	 * @since 2020/01/18
	 */
	public final int[] pixels()
	{
		return this.pixels;
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/vfb/VirtualFramebufferCanvas.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
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






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.lcdui.vfb;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This is a virtualized framebuffer that provides a LCDUI canvas.
 *
 * @see VirtualFramebuffer
 * @since 2019/12/28
 */
public final class VirtualFramebufferCanvas
	extends Canvas
{
	/** The framebuffer to use. */
	protected final VirtualFramebuffer framebuffer;
	
	/**
	 * Initializes the framebuffer canvas.
	 *
	 * @param __fb The framebuffer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/28
	 */
	public VirtualFramebufferCanvas(VirtualFramebuffer __fb)
		throws NullPointerException
	{
		if (__fb == null)
			throw new NullPointerException("NARG");
		
		this.framebuffer = __fb;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyPressed(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyReleased(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void keyRepeated(int __kc)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void paint(Graphics __g)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerDragged(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerPressed(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void pointerReleased(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void showNotify()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/28
	 */
	@Override
	public final void sizeChanged(int __w, int __h)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/vfb/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This contains an implementation of the SquirrelJME virtual framebuffer, it
 * provides a canvas and callback handler that can be used by virtual machines
 * using SquirrelJME to hook into its graphics callback system.
 *
 * @since 2019/12/28
 */

package cc.squirreljme.runtime.lcdui.vfb;

Deleted runt/apis/midp-lcdui/com/nokia/mid/ui/DeviceControl.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 com.nokia.mid.ui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.DeviceFeedbackType;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is used to utilize special hardware that exists on the device for
 * user feedback.
 *
 * @since 2019/10/05
 */
public class DeviceControl
{
	/**
	 * Flashes the LED on the device.
	 *
	 * @param __ms The number of milliseconds to flash for.
	 * @throws IllegalArgumentException If the duration is negative.
	 * @since 2019/10/05
	 */
	public static void flashLights(long __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2z Cannot blink for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB2z");
		
		// Blink!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.BLINK_LED, ((__ms > (long)Integer.MAX_VALUE) ?
				Integer.MAX_VALUE : (int)__ms));
	}
	
	/**
	 * Sets the level of the backlight.
	 *
	 * @param __num The light number, this is always zero for the backlight.
	 * @param __lvl The level to set within the range of {@code [0, 100]}
	 * @throws IllegalArgumentException If the light number is not zero or
	 * the level is out of range.
	 * @since 2019/10/05
	 */
	public static void setLights(int __num, int __lvl)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB31 Only light number zero is supported.
		// (The light number)}
		if (__num != 0)
			throw new IllegalArgumentException("EB31 " + __num);
			
		// {@squirreljme.error EB32 Light level out of range. (The level)}
		if (__lvl < 0 || __lvl > 100)
			throw new IllegalArgumentException("EB32 " + __lvl);
		
		// Get maximum backlight level, stop if it is zero which means the
		// property is not supported or there is no backlight that can be
		// controlled
		int max = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_BACKLIGHT_LEVEL_MAX);
		if (max == 0)
			return;
		
		// Set the desired level as a percentage of the max
		int val = (max * __lvl) / 100;
		Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_BACKLIGHT_LEVEL_SET,
			(val < 0 ? 0 : (val > max ? max : val)));
	}
	
	/**
	 * Starts vibrating at the given frequency for the given duration.
	 *
	 * @param __freq The frequency of the vibration, must be in the range of
	 * {@code [0, 100]}.
	 * @param __ms The length to vibrate for in milliseconds.
	 * @throws IllegalArgumentException If the duration is negative or the
	 * frequency is out of range.
	 * @since 2019/10/05
	 */
	public static void startVibra(int __freq, long __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB33 Cannot vibrate for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB33");
		
		// {@squirreljme.error EB34 Frequency out of range. (The frequency)}
		if (__freq < 0 || __freq > 100)
			throw new IllegalArgumentException("EB34 " + __freq);
		
		// Vibrate!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, ((__ms > (long)Integer.MAX_VALUE) ?
				Integer.MAX_VALUE : (int)__ms));
	}
	
	/**
	 * Stops any vibration that is happening.
	 *
	 * @since 2019/10/05
	 */
	public static void stopVibra()
	{
		// Clear vibration
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, 0);
	}
}

Deleted runt/apis/midp-lcdui/com/nokia/mid/ui/DirectGraphics.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 com.nokia.mid.ui;

/**
 * This interface provides direct framebuffer pixel access.
 *
 * @since 2019/10/07
 */
public interface DirectGraphics
{
}

Deleted runt/apis/midp-lcdui/com/nokia/mid/ui/DirectUtils.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 com.nokia.mid.ui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This class acts as a placeholder for utility methods.
 *
 * @since 2019/10/07
 */
public class DirectUtils
{
	/**
	 * Creates a mutable image with the given ARGB color for all pixels.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @param __argb The ARGB color to do.
	 * @return The created mutable image.
	 * @throws IllegalArgumentException If the width and/or height or negative
	 * or exceed the array bounds.
	 * @since 2019/10/07
	 */
	public static Image createImage(int __w, int __h, int __argb)
		throws IllegalArgumentException
	{
		return Image.createImage(__w, __h, true, __argb);
	}
	
	/**
	 * Loads a mutable image from the specified byte array.
	 *
	 * @param __b The byte data.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The mutable image.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IllegalArgumentException If the image could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/07
	 */
	public static Image createImage(byte[] __b, int __o, int __l)
	{
		// Load the base image
		Image base = Image.createImage(__b, __o, __l);
		
		// Create blank mutable
		int w, h;
		Image mutable = Image.createImage(
			(w = base.getWidth()), (h = base.getHeight()),
			base.hasAlpha(), 0);
			
		// Setup graphics state, use SRC blending mode since it is just a
		// copy of the alpha channel data!
		Graphics g = mutable.getGraphics();
		g.setBlendingMode(Graphics.SRC);
		
		// Draw image on top
		g.drawRegion(base, 0, 0, w, h, 0, 0, 0, 0);
		
		// Use resulting image
		return mutable;
	}
	
	/**
	 * Returns an interface which wraps the given graphics and provides raw
	 * pixel data access to it.
	 *
	 * @param __g The graphics object to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/07
	 */
	public static DirectGraphics getDirectGraphics(Graphics __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/com/nokia/mid/ui/FullCanvas.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
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




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 com.nokia.mid.ui;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * This the Nokia canvas, command buttons are forwarded to the key pressed
 * and released commands for the canvas.
 *
 * @since 2019/09/23
 */
public abstract class FullCanvas
	extends Canvas
{
	/** Virtual soft key 1. */
	private static final Command _SOFT1 =
		new Command("Soft1", Command.SCREEN, 0);
		
	/** Virtual soft key 2. */
	private static final Command _SOFT2 =
		new Command("Soft2", Command.SCREEN, 1);
		
	/** Virtual soft key 3. */
	private static final Command _SOFT3 =
		new Command("Soft3", Command.SCREEN, 2);
	
	/** Down arrow. */
	public static final int KEY_DOWN_ARROW =
		-2;
	
	/** End. */
	public static final int KEY_END =
		-11;
	
	/** Left arrow. */
	public static final int KEY_LEFT_ARROW =
		-3;
	
	/** Right arrow. */
	public static final int KEY_RIGHT_ARROW =
		-4;
	
	/** Send. */
	public static final int KEY_SEND =
		-10;
	
	/** Soft Key 1. */
	public static final int KEY_SOFTKEY1 =
		-6;
	
	/** Soft Key 2. */
	public static final int KEY_SOFTKEY2 =
		-7;
	
	/** Soft Key 3. */
	public static final int KEY_SOFTKEY3 =
		-5;
	
	/** Up Arrow. */
	public static final int KEY_UP_ARROW =
		-1;
	
	/**
	 * Initializes the base canvas and sets as full-screen.
	 *
	 * @since 2019/09/23
	 */
	@Deprecated
	public FullCanvas()
	{
		// Nokia API just says to call this instead, so this is done
		this.setFullScreenMode(true);
		
		// Since we need to simulate soft commands in the game, we have to
		// add our own commands and such to this.
		this.addCommand(FullCanvas._SOFT1);
		this.addCommand(FullCanvas._SOFT2);
		this.addCommand(FullCanvas._SOFT3);
		
		// Then use virtual command listener to forward
		this.setCommandListener(new __VirtualListener__());
	}
	
	/**
	 * Always throws {@link IllegalStateException} as commands are not
	 * supported in Nokia canvases.
	 *
	 * @param __c The command to add.
	 * @throws IllegalStateException Always.
	 * @since 2019/09/23
	 */
	@Override
	public void addCommand(Command __c)
	{
		// Since we are providing this special functionality we need to wrap
		// but still access these internal commands
		if (__c == FullCanvas._SOFT1 || __c == FullCanvas._SOFT2 ||
			__c == FullCanvas._SOFT3)
		{
			super.addCommand(__c);
			return;
		}
		
		// {@squirreljme.error EB2x Commands are not supported.}
		throw new IllegalStateException("EB2x");
	}
	
	/**
	 * Always throws {@link IllegalStateException} as commands are not
	 * supported in Nokia canvases.
	 *
	 * @param __l The command to add.
	 * @throws IllegalStateException Always.
	 * @since 2019/09/23
	 */
	@Override
	public void setCommandListener(CommandListener __l)
	{
		// Since this is virtualized, we do want to handle this one!
		if (__l instanceof __VirtualListener__)
		{
			super.setCommandListener(__l);
			return;
		}
		
		// {@squirreljme.error EB2y Commands are not supported.}
		throw new IllegalStateException("EB2y");
	}
	
	/**
	 * Command listener to forward keys to the canvas.
	 *
	 * @since 2019/09/23
	 */
	private static final class __VirtualListener__
		implements CommandListener
	{
		/**
		 * {@inheritDoc}
		 * @since 2019/09/23
		 */
		@Override
		public final void commandAction(Command __c, Displayable __d)
		{
			// Do nothing if this is some other thing
			if (!(__d instanceof FullCanvas))
				return;
			
			// Determine code to use
			int code;
			if (__c == FullCanvas._SOFT1)
				code = FullCanvas.KEY_SOFTKEY1;
			else if (__c == FullCanvas._SOFT2)
				code = FullCanvas.KEY_SOFTKEY2;
			else if (__c == FullCanvas._SOFT3)
				code = FullCanvas.KEY_SOFTKEY3;
			
			// Unknown?
			else
				return;
			
			// Press and release, since that is all we can do really!
			FullCanvas fc = (FullCanvas)__d;
			fc.keyPressed(code);
			fc.keyReleased(code);
		}
	}
}

Deleted runt/apis/midp-lcdui/com/nokia/mid/ui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Nokia Proprietary Graphics Support.
 *
 * @since 2019/09/23
 */

package com.nokia.mid.ui;

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Alert.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228




































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Alert
	extends Screen
{
	/**
	 * This is delivered to a listener to specify that the alert has been
	 * dismissed.
	 */
	public static final Command DISMISS_COMMAND =
		new Command("Okay", Command.OK, 0, true);
	
	/** Specifies that the alert should last forever. */
	public static final int FOREVER =
		-2;
	
	/** The message to display. */
	volatile String _message;
	
	/** The image to use. */
	volatile Image _image;
	
	/** The type of alert this is. */
	volatile AlertType _type;
	
	/** The duration the alert should last in milliseconds. */
	volatile int _timeout =
		FOREVER;
	
	/**
	 * Initializes the alert with just a title.
	 *
	 * @param __title The title of the alert, may be {@code null}.
	 * @since 2017/02/28
	 */
	public Alert(String __title)
	{
		this(__title, null, null, null);
	}
	
	/**
	 * Initializes the alert with just a title, message, image, and type.
	 *
	 * @param __title The title of the alert, may be {@code null}.
	 * @param __message The message to show in the alert, may be {@code null}.
	 * @param __icon The icon to display, may be {@code null}.
	 * @param __type The type of this alert, may be {@code null}.
	 * @since 2017/02/28
	 */
	public Alert(String __title, String __message, Image __icon,
		AlertType __type)
	{
		this._message = __message;
		this._image = __icon;
		this._type = __type;
		
		// Set titles
		this._title = __title;
		if (__title != null)
			this._dtitle = __title;
	}
	
	@Override
	public void addCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public int getDefaultTimeout()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	public Gauge getIndicator()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public int getTimeout()
	{
		throw new todo.TODO();
	}
	
	public AlertType getType()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	@Override
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	@Override
	public void setCommandListener(CommandListener __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this alert. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code alert.setImage(alert.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	public void setIndicator(Gauge __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the message which is used in the alert.
	 *
	 * @param __s The message to use.
	 * @since 2017/02/28
	 */
	public void setString(String __s)
	{
		throw new todo.TODO();
		/*
		this._message = __s;
		
		todo.DEBUG.note("Set alert message: %s%n", __s);
		*/
	}
	
	/**
	 * Sets the duration for which the alert should last.
	 *
	 * @param __ms The number of milliseconds to display the message for or
	 * {@link #FOREVER}.
	 * @throws IllegalArgumentException If the duration is not positive and is
	 * not {@link #FOREVER}.
	 * @since 2017/02/28
	 */
	public void setTimeout(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB19 The specified number of milliseconds is
		// negative. (The number of milliseconds specified)}
		if (__ms < 0 && __ms != FOREVER)
			throw new IllegalArgumentException(String.format("EB19 %d", __ms));
		
		// Set
		this._timeout = __ms;
	}
	
	/**
	 * Sets the type of this alert.
	 *
	 * @param __t The alert type, may be {@code null}.
	 * @since 2017/02/28
	 */
	public void setType(AlertType __t)
	{
		throw new todo.TODO();
		/*
		this._type = __t;
		*/
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/AlertType.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This is used as a modifier to alerts to specify the type of message it is
 * along with potentially providing a default sound or icon set.
 *
 * @since 2017/02/28
 */
public class AlertType
{
	/**
	 * This is used to specify that previously requested event is about to
	 * occur.
	 */
	public static final AlertType ALARM =
		new AlertType();
	
	/** This specified that an action has been performed. */
	public static final AlertType CONFIRMATION =
		new AlertType();
	
	/** This specifies an error. */
	public static final AlertType ERROR =
		new AlertType();
	
	/** This specified general information. */
	public static final AlertType INFO =
		new AlertType();
	
	/**
	 * This specifies a warning which may cause the user to proceed with
	 * caution.
	 */
	public static final AlertType WARNING =
		new AlertType();
	
	/**
	 * Initializes the alert type.
	 *
	 * @since 2017/0/228
	 */
	protected AlertType()
	{
	}
	
	public boolean playSound(Display __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/AnimatedImage.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class AnimatedImage
	extends Image
{
	public Image getFrame(int __i)
		throws IndexOutOfBoundsException
		
	{
		throw new todo.TODO();
	}
	
	public int getFrameDelay(int __i)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	public int getLoopCount()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Canvas.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593

















































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.KeyNames;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

/**
 * The canvas acts as the base class for primary display interfaces that
 * require more customized draw handling.
 *
 * It is not recommended to use a lookup table between keycodes and actions at
 * initialization time. The reason for this is that it is possible for the
 * device to enter different modes or be associated with different
 * {@link Display}s which have different action mappings.
 *
 * @since 2016/10/08
 */
public abstract class Canvas
	extends Displayable
{
	public static final int ACTIONS_ALL =
		-2;
	
	public static final int ACTIONS_NAVIGATION =
		-1;
	
	public static final int ACTIONS_NONE =
		0;
	
	/** This is a game key for the down direction. */
	public static final int DOWN =
		6;
	
	/** This is a game key for the fire button. */
	public static final int FIRE =
		8;
	
	/** This is a game key for the A button. */
	public static final int GAME_A =
		9;
	
	/** This is a game key for the B button. */
	public static final int GAME_B =
		10;
	
	/** This is a game key for the C button. */
	public static final int GAME_C =
		11;
	
	/** This is a game key for the D button. */
	public static final int GAME_D =
		12;
	
	public static final int KEY_BACKSPACE =
		8;
	
	public static final int KEY_DELETE =
		127;
	
	public static final int KEY_DOWN =
		-2;
	
	public static final int KEY_ENTER =
		10;
	
	public static final int KEY_ESCAPE =
		27;
	
	public static final int KEY_LEFT =
		-3;
	
	public static final int KEY_NUM0 =
		48;
	
	public static final int KEY_NUM1 =
		49;
	
	public static final int KEY_NUM2 =
		50;
	
	public static final int KEY_NUM3 =
		51;
	
	public static final int KEY_NUM4 =
		52;
	
	public static final int KEY_NUM5 =
		53;
	
	public static final int KEY_NUM6 =
		54;
	
	public static final int KEY_NUM7 =
		55;
	
	public static final int KEY_NUM8 =
		56;
	
	public static final int KEY_NUM9 =
		57;
	
	public static final int KEY_POUND =
		35;
	
	public static final int KEY_RIGHT =
		-4;
	
	public static final int KEY_SELECT =
		-5;
	
	public static final int KEY_SPACE =
		32;
	
	public static final int KEY_STAR =
		42;
	
	public static final int KEY_TAB =
		9;
	
	/** The up arrow key. */
	public static final int KEY_UP =
		-1;
	
	/** This is a game key for the left direction. */
	public static final int LEFT =
		2;
	
	/** This is a game key for the right direction. */
	public static final int RIGHT =
		5;
	
	/** This is a game key for the up direction. */
	public static final int UP =
		1;
	
	/** The key listener to use. */
	private KeyListener _keylistener;
	
	/** Is the rendering transparent or opaque? */
	boolean _transparent;
	
	/** Should this be ran full-screen? */
	volatile boolean _isfullscreen;
	
	/** Service repaint counter. */
	volatile int _paintservice;
	
	/** Was a repaint requested? */
	volatile boolean _paintwanted;
	
	/**
	 * Initializes the base canvas.
	 *
	 * @since 2016/10/08
	 */
	protected Canvas()
	{
	}
	
	/**
	 * This is called when this is to be painted. The clipping area will
	 * be set to the area that needs updating and as such drawing should only
	 * occur within the region. Any pixels drawn outside of the clipping area
	 * might not be updated and may have no effect when drawing.
	 *
	 * If this is transparent then the background will automatically be filled
	 * appropriately with a color or image, otherwise in opaque mode it is
	 * assumed that pixels in the clipping region will be drawn on.
	 *
	 * @param __g The graphics to draw into.
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected abstract void paint(Graphics __g);
	
	/**
	 * Returns the action which is associated with the given key.
	 *
	 * @param __kc The key code to get the action for.
	 * @return The action associated with the given key or {@code 0} if no
	 * action is associated with the key.
	 * @throws IllegalArgumentException If the specified keycode is not valid.
	 * @since 2017/02/12
	 */
	public int getGameAction(int __kc)
		throws IllegalArgumentException
	{
		return EventTranslate.keyCodeToGameAction(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, this._isfullscreen);
	}
	
	/**
	 * Returns the key code for the given game action.
	 *
	 * @param __gc The game action to convert.
	 * @return The key code
	 * @throws IllegalArgumentException If the game action is not valid.
	 * @since 2019/04/14
	 */
	public int getKeyCode(int __gc)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1a The specified game action is not valid.}
		int rv = EventTranslate.gameActionToKeyCode(__gc);
		if (rv == 0)
			throw new IllegalArgumentException("EB1a " + __gc);
		return rv;
	}
	
	/**
	 * Returns the name for a key.
	 *
	 * @param __a The name to get the key for.
	 * @return The name of the given key.
	 * @throws IllegalArgumentException If the key is not valid.
	 * @since 2017/02/12
	 */
	public String getKeyName(int __a)
		throws IllegalArgumentException
	{
		return KeyNames.getKeyName(__a);
	}
	
	public int[] getSoftkeyLabelCoordinates(int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, this._isfullscreen);
	}
	
	/**
	 * This checks whether the display has the capability to handle pointer
	 * events.
	 *
	 * @return {@code true} if pointer events are available.
	 * @since 2017/02/12
	 */
	@Deprecated
	public boolean hasPointerEvents()
	{
		Display d = this._display;
		return (d != null ? d : Display.getDisplays(0)[0]).hasPointerEvents();
	}
	
	/**
	 * This checks whether the display has the capability to handle pointer
	 * motion events.
	 *
	 * @return {@code true} if pointer motion events are available.
	 * @since 2017/02/12
	 */
	@Deprecated
	public boolean hasPointerMotionEvents()
	{
		Display d = this._display;
		return (d != null ? d : Display.getDisplays(0)[0]).
			hasPointerMotionEvents();
	}
	
	/**
	 * Always returns {@code true} because all implementations must support
	 * repeat events.
	 *
	 * @return Always {@code true}.
	 * @since 2017/02/12
	 */
	public boolean hasRepeatEvents()
	{
		return true;
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected void hideNotify()
	{
		// Implemented by sub-classes
	}
	
	/**
	 * This method always returns {@code true} because all implementations
	 * must double buffer canvases.
	 *
	 * @return {@code true}.
	 * @since 2017/05/13
	 */
	public boolean isDoubleBuffered()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isFullscreen()
	{
		return this._isfullscreen;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isTransparent()
	{
		return this._transparent;
	}
	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyPressed(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when a key has been released.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyReleased(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when a key has been repeated.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void keyRepeated(int __code)
	{
		// Does nothing, implemented by sub-classes
	}
	
	/**
	 * This is called when the pointer is being dragged across the canvas, a
	 * drag is when there is movement 
	 *
	 * This requires that motion events are supported which can be known by
	 * calling {@link #hasPointerMotionEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerDragged(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been pressed on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerPressed(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * This is called when the pointer has been released on the canvas.
	 *
	 * This requires that pointer events are supported which can be known by
	 * calling {@link #hasPointerEvents()}.
	 *
	 * @param __x The X coordinate of the pointer, on the canvas origin.
	 * @param __y The Y coordinate of the pointer, on the canvas origin.
	 * @since 2017/02/12
	 */
	@SerializedEvent
	protected void pointerReleased(int __x, int __y)
	{
		// Does nothing by default
	}
	
	/**
	 * Equivalent to {@code repaint(0, 0, getWidth(), getHeight())}.
	 *
	 * @since 2017/02/10
	 */
	public final void repaint()
	{
		// A remote repaint call is performed for the canvas so it is
		// possible that the width/height are not valid. Internally the code
		// will clip the rectangle to be in bounds.
		this.repaint(0, 0, this.getWidth(), this.getHeight());
	}
	
	/**
	 * Requests that the specified region of the canvas be repainted.
	 *
	 * The clipping region when {@link #paint()} is called will have its clip
	 * set to the region to be redrawn.
	 *
	 * It is unspecified whether the drawing operation will happen immedietely,
	 * be enqueued, or not happen at all (for example if the canvas is
	 * currently being painted).
	 *
	 * A width or height with a negative value or zero does nothing.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2017/02/10
	 */
	public final void repaint(int __x, int __y, int __w, int __h)
	{
		// Do nothing
		if (__w <= 0 || __h <= 0)
			return;
		
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint(__x, __y, __w, __h);
	}
	
	/**
	 * This forces any pending repaint requests to be serviced immedietely,
	 * blocking until paint has been called. If the canvas is not visible on
	 * the display or if there are no pending repaints then this call does
	 * nothing.
	 *
	 * Note that if the caller of this method and the paint method uses a lock
	 * then a deadlock may occur.
	 *
	 * @since 2019/04/14
	 */
	public final void serviceRepaints()
	{
		// If a paint was not requested then do nothing
		if (!this._paintwanted)
			return;
		
		// Just wait until the service count changes
		int nowpsv = this._paintservice;
		while (nowpsv == this._paintservice)
			break;
	}
	
	/**
	 * This specifies that the canvas should enter full screen mode which
	 * takes up the maximum amount of space that is possible on the display.
	 *
	 * Note that this might not use the entire screen.
	 *
	 * This method may permit access to the framebuffer directly on the device
	 * which may enable accelerated drawing if supported by the underlying
	 * display engine.
	 *
	 * Note that the fullscreen mode is treated
	 *
	 * @param __f If {@code true} then fullscreen mode should be used.
	 * @since 2017/02/28
	 */
	public void setFullScreenMode(boolean __f)
	{
		// Do nothing if already fullscreen
		if (this._isfullscreen == __f)
			return;
		
		// Set new mode
		this._isfullscreen = __f;
		
		// Repaint the display if we have one so that it actually is used
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	/**
	 * Sets the key listener which is used to handle key events.
	 *
	 * If this is set then {@link #keyPressed(int)}, {@link #keyReleased(int)},
	 * and {@link #keyRepeated} will still be called.
	 *
	 * @param __kl The key listener to use, {@code null} clears it.
	 * @since 2017/02/12
	 */
	public void setKeyListener(KeyListener __kl)
	{
		this._keylistener = __kl;
	}
	
	/**
	 * Sets the painting mode of the canvas.
	 *
	 * If transparent mode is enabled, then the implementation (not the end
	 * developer) will fill the background with a suitable color or image
	 * (which is unspecified).
	 *
	 * If opaque mode (which is the default) is enabled then it will be
	 * assumed that {@link #repaint(Graphics)} will cover every pixel and as
	 * such it will not be required for the background to be cleared or
	 * initialized.
	 *
	 * @param __opaque If {@code true} then opaque mode is enabled.
	 * @since 2017/02/12
	 */
	public void setPaintMode(boolean __opaque)
	{
		this._transparent = !__opaque;
	}
	
	public void setRequiredActions(int __actions)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is called when the canvas has been shown.
	 *
	 * @since 2018/12/02.
	 */
	@SerializedEvent
	protected void showNotify()
	{
		// Implemented by sub-classes
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/CanvasItem.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public abstract class CanvasItem
{
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public Object getParent()
	{
		throw new todo.TODO();
	}
	
	public int getPositionX()
	{
		throw new todo.TODO();
	}
	
	public int getPositionY()
	{
		throw new todo.TODO();
	}
	
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public int getZPosition()
	{
		throw new todo.TODO();
	}
	
	public void setParent(Object __p)
	{
		throw new todo.TODO();
	}
	
	public void setPositionX(int __x)
	{
		throw new todo.TODO();
	}
	
	public void setPositionY(int __y)
	{
		throw new todo.TODO();
	}
	
	public void setSize(int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __v)
	{
		throw new todo.TODO();
	}
	
	public void setZPosition(int __z)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Choice.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;


public interface Choice
{
	public static final int EXCLUSIVE =
		1;
	
	public static final int IMPLICIT =
		3;
	
	public static final int MULTIPLE =
		2;
	
	public static final int POPUP =
		4;
	
	public static final int TEXT_WRAP_DEFAULT =
		0;
	
	public static final int TEXT_WRAP_OFF =
		2;
	
	public static final int TEXT_WRAP_ON =
		1;
	
	public abstract int append(String __a, Image __b);
	
	public abstract void delete(int __a);
	
	public abstract void deleteAll();
	
	public abstract int getFitPolicy();
	
	public abstract Font getFont(int __a);
	
	public abstract Image getImage(int __a);
	
	public abstract int getSelectedFlags(boolean[] __a);
	
	public abstract int getSelectedIndex();
	
	public abstract String getString(int __a);
	
	public abstract void insert(int __a, String __b, Image __c);
	
	public abstract boolean isEnabled(int __i);
	
	public abstract boolean isSelected(int __a);
	
	public abstract void set(int __a, String __b, Image __c);
	
	public abstract void setEnabled(int __i, boolean __e);
	
	public abstract void setFitPolicy(int __a);
	
	public abstract void setFont(int __a, Font __b);
	
	public abstract void setSelectedFlags(boolean[] __a);
	
	public abstract void setSelectedIndex(int __a, boolean __b);
	
	public abstract int size();
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ChoiceGroup.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254






























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.ArrayList;
import java.util.List;

/**
 * A choice group represents a selectable group of elements which may be
 * added to a {@link Form}. The number of selected choices may be limited to
 * one or multiple choices may be available.
 *
 * @since 2017/08/20
 */
public class ChoiceGroup
	extends Item
	implements Choice
{
	/** The minimum permitted type. */
	static final int _MIN_TYPE =
		Choice.EXCLUSIVE;
	
	/** The maximum permitted type. */
	static final int _MAX_TYPE =
		Choice.POPUP;
	
	/** Entries which are available in the group. */
	private final List<__ChoiceEntry__> _entries =
		new ArrayList<>();
	
	/** The valid choice selection type. */
	private final int _type;
	
	/**
	 * Initializes an empty choice group.
	 *
	 * @param __l The label for this group.
	 * @param __ct The type of choice selection to use.
	 * @throws IllegalArgumentException If the choice type is not valid or
	 * if {@link Choice#IMPLICIT} was specified.
	 * @since 2017/08/20
	 */
	public ChoiceGroup(String __l, int __ct)
		throws IllegalArgumentException
	{
		this(__l, __ct, new String[0], null);
	}
	
	/**
	 * Initializes an empty choice group.
	 *
	 * @param __l The label for this group.
	 * @param __ct The type of choice selection to use.
	 * @param __se The , this cannot be {@code null}
	 * @param __ie The images for each choice, this must either be {@code null}
	 * or be the exact same length as the input {@code __se}.
	 * @throws IllegalArgumentException If the choice type is not valid; 
	 * if {@link Choice#IMPLICIT} was specified; If the image array is not
	 * null and is not the same length as the string array.
	 * @throws NullPointerException If {@code __se} is {@code null} or it
	 * contains {@code null} elements; or if the string array contains null
	 * elements.
	 * @since 2017/08/20
	 */
	public ChoiceGroup(String __l, int __ct, String[] __se, Image[] __ie)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__se == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1b The image array does not have the same
		// length as the string array.}
		int n = __se.length;
		if (__ie != null && __ie.length != n)
			throw new IllegalArgumentException("EB1b");
		
		// {@squirreljme.error EB1c Invalid choice type specified for a
		// choice group. (The choice type)}
		if (__ct < _MIN_TYPE || __ct > _MAX_TYPE || __ct == IMPLICIT)
			throw new IllegalArgumentException(String.format("EB1c %d", __ct));
		
		// Set
		setLabel(__l);
		this._type = __ct;
		
		// Append all elements
		for (int i = 0; i < n; i++)
		{
			// {@squirreljme.error EB1d A string element contains a null
			// entry.}
			String s = __se[i];
			if (s == null)
				throw new NullPointerException("EB1d");
			
			// Add it
			append(s, (__ie != null ? __ie[i] : null));
		}
	}
	
	/**
	 * This appends a single choice.
	 *
	 * @param __s The string to display.
	 * @param __i The image to display, may be {@code null}.
	 * @return The index the element was added at.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/08/20
	 */
	public int append(String __s, Image __i)
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Just insert at the end
		int rv;
		this.insert((rv = size()), __s, __i);
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	public void deleteAll()
	{
		throw new todo.TODO();
	}
	
	public int getFitPolicy()
	{
		throw new todo.TODO();
	}
	
	public Font getFont(int __a)
	{
		throw new todo.TODO();
	}
	
	public Image getImage(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedIndex()
	{
		throw new todo.TODO();
	}
	
	public String getString(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This inserts the specified choice at the given index.
	 *
	 * Note that the documentation erroneously specifies that an exception
	 * will be thrown if {@code __v} is in the range of {@code [0, size()-1]},
	 * this is not the case and {@code size()} is a valid index.
	 *
	 * @param __v The index to insert the choice at.
	 * @param __s The string to display.
	 * @param __i The image to display, may be {@code null}.
	 * @throws IndexOutOfBoundsException If the index exceeds the bounds.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/08/21
	 */
	public void insert(int __v, String __s, Image __i)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1e Cannot insert choice at the specified
		// index because it is not within bounds. (The index to add at)}
		List<__ChoiceEntry__> entries = this._entries;
		if (__v < 0 || __v > entries.size())
			throw new IndexOutOfBoundsException(String.format("EB1e %d",
				__v));
		
		// Insert
		entries.add(__v, new __ChoiceEntry__(__s, __i));
	}
	
	public boolean isEnabled(int __i)
	{
		throw new todo.TODO();
	}
	
	public boolean isSelected(int __a)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	public void setEnabled(int __i, boolean __e)
	{
		throw new todo.TODO();
	}
	
	public void setFitPolicy(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFont(int __a, Font __b)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedIndex(int __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of choices which are in this group.
	 *
	 * @return The number of choices in this group.
	 * @since 2017/08/20
	 */
	public int size()
	{
		return this._entries.size();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Command.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388




































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.common.CommonMetrics;

public class Command
	extends __Action__
{ 
	/** Returns the user to the previous screen.. */
	public static final int BACK =
		2;
	
	/** Specified a standard negative to something on the screen. */
	public static final int CANCEL =
		3;
	
	/** A command that is used to exit the application. */
	public static final int EXIT =
		7;
	
	/** A request for on-line help. */
	public static final int HELP =
		5;
	
	/** System specific type. */
	public static final int ITEM =
		8;
	
	/** Specified as a standard affirmative to something on the screen. */
	public static final int OK =
		4;
	
	/** A command which pertains to the current screen. */
	public static final int SCREEN =
		1;
	
	/** A command which will stop an in-progress operation. */
	public static final int STOP =
		6;
	
	/** The first command type. */
	private static final int _FIRST_TYPE =
		SCREEN;
	
	/** The last command type. */
	private static final int _LAST_TYPE =
		ITEM;
	
	/** The command type. */
	final int _type;
	
	/** The priority. */
	@ImplementationNote("In SquirrelJME if the priority is " +
		"Integer.MAX_VALUE then it will not be displayed.")
	private final int _priority;
	
	/** Is this an implementation specific command with fixed text? */
	private final boolean _implspec;
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @param __implspec If true this is an implementation specific command
	 * which the returned labels are always blank except that internally they
	 * use the passed strings.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	Command(String __sl, int __type, int __pri, boolean __implspec)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, __implspec);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, String __ll, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, null, null, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __i The image used on the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2017/02/28
	 */
	public Command(String __sl, String __ll, Image __i, int __type, int __pri)
		throws IllegalArgumentException, NullPointerException
	{
		this(__sl, __ll, __i, __type, __pri, false);
	}
	
	/**
	 * Creates a new command with the specified parameters.
	 *
	 * @param __sl The short label of the command.
	 * @param __ll The long label of the command, may be {@code null}.
	 * @param __i The image used on the command, may be {@code null}.
	 * @param __type The type of command this is.
	 * @param __pri The priority of the command.
	 * @param __implspec If true this is an implementation specific command
	 * which the returned labels are always blank except that internally they
	 * use the passed strings.
	 * @throws IllegalArgumentException If the command type is not valid.
	 * @throws NullPointerException If no short label was specified.
	 * @since 2018/03/29
	 */
	Command(String __sl, String __ll, Image __i, int __type, int __pri,
		boolean __implspec)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__sl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1f And invalid command type was specified.
		// (The command type)}
		if (__type < Command._FIRST_TYPE || __type > Command._LAST_TYPE)
			throw new IllegalArgumentException(
				String.format("EB1f %d", __type));
		
		// Set
		this._implspec = __implspec;
		this._type = __type;
		this._priority = __pri;
		
		// Part of action
		this._shortlabel = __sl;
		this._longlabel = __ll;
		this._image = __i;
	}
	
	/**
	 * Returns the type of command this is.
	 *
	 * @return The command type.
	 * @since 2018/03/31
	 */
	public int getCommandType()
	{
		return this._type;
	}
	
	public boolean getEnabled()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font that is used as a hint for rendering the text in
	 * a command, it may be disregarded by the implementation.
	 *
	 * @return The font that should be used as a hint.
	 * @since 2018/03/31
	 */
	public Font getFont()
	{
		throw new todo.TODO();
		/*
		return this._font;
		*/
	}
	
	/**
	 * Returns the image the command.
	 *
	 * @return The image of the command or {@code null} if it has none.
	 * @since 2018/03/29
	 */
	public Image getImage()
	{
		// Do not provide implementation specific images
		if (this._implspec)
			return null;
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label used for this command.
	 *
	 * @return The label used for the command.
	 * @since 2018/03/29
	 */
	public String getLabel()
	{
		// Do not provide implementation specific labels
		if (this._implspec)
			return "";
		
		return this._shortlabel;
	}
	
	/**
	 * Returns the long label of the command.
	 *
	 * @return The long label of the command or {@code null} if it has none.
	 * @since 2018/03/29
	 */
	public String getLongLabel()
	{
		// Do not provide implementation specific labels
		if (this._implspec)
			return null;
		
		return this._longlabel;
	}
	
	/**
	 * Returns the priority of the command.
	 *
	 * @return The command priority.
	 * @since 2018/12/03
	 */
	public int getPriority()
	{
		return this._priority;
	}
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e The new state of the parent.
	 * @since 2018/04/01
	 */
	@Override
	public void onParentEnabled(boolean __e)
	{
		// The default implementation does nothing
	}
	
	/**
	 * Sets whether this command is enabled or disabled.
	 *
	 * @param __e If the command is enabled or not.
	 * @since 2018/04/01
	 */
	public void setEnabled(boolean __e)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font used to be used as a hint when rendering the command.
	 *
	 * @param __f The font to use as a hint when rendering the command,
	 * {@code null} will use the default.
	 * @since 2018/03/31
	 */
	public void setFont(Font __f)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		// Just cache the font but do nothing as it is not supported in
		// SquirrelJME (it would complicate command handling) although it
		// could potentially be supported in the future for stuff such as
		// word processors and such
		this._font = __f;
		*/
	}
	
	/**
	 * Sets the image to be displayed for this command. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code command.setImage(command.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * Sets the label to be displayed.
	 *
	 * @param __s The label to display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/29
	 */
	public void setLabel(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		this.__setLabels(__s, this._longlabel, this._image);
		*/
	}
	
	/**
	 * Sets the long label of the command.
	 *
	 * @param __s The long label to use, {@code null} clears it.
	 * @since 2018/03/29
	 */
	public void setLongLabel(String __s)
	{
		// Do nothing for implementation specific commands
		if (this._implspec)
			return;
		
		throw new todo.TODO();
		/*
		this.__setLabels(this._shortlabel, __s, this._image);
		*/
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/CommandLayoutPolicy.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface CommandLayoutPolicy
{
	public abstract void onCommandLayout(Displayable __disp);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/CommandListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface CommandListener
{
	@SerializedEvent
	public abstract void commandAction(Command __a, Displayable __b);
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/CustomItem.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212




















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class CustomItem
	extends Item
{
	protected static final int KEY_PRESS =
		4;
	
	protected static final int KEY_RELEASE =
		8;
	
	protected static final int KEY_REPEAT =
		16;
	
	protected static final int NONE =
		0;
	
	protected static final int POINTER_DRAG =
		128;
	
	protected static final int POINTER_PRESS =
		32;
	
	protected static final int POINTER_RELEASE =
		64;
	
	protected static final int TRAVERSE_HORIZONTAL =
		1;
	
	protected static final int TRAVERSE_VERTICAL =
		2;
	
	/** Is the rendering transparent or opaque? */
	boolean _transparent;
	
	protected CustomItem(String __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected abstract int getMinContentHeight();
	
	@SerializedEvent
	protected abstract int getMinContentWidth();
	
	@SerializedEvent
	protected abstract int getPrefContentHeight(int __a);
	
	@SerializedEvent
	protected abstract int getPrefContentWidth(int __a);
	
	/**
	 * This is called when this is to be painted. The clipping area will
	 * be set to the area that needs updating and as such drawing should only
	 * occur within the region. Any pixels drawn outside of the clipping area
	 * might not be updated and may have no effect when drawing.
	 *
	 * If this is transparent then the background will automatically be filled
	 * appropriately with a color or image, otherwise in opaque mode it is
	 * assumed that pixels in the clipping region will be drawn on.
	 *
	 * @param __g The graphics to draw into.
	 * @param __w The width of the item.
	 * @param __h The height of the item.
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected abstract void paint(Graphics __g, int __w, int __h);
	
	public int getGameAction(int __a)
	{
		throw new todo.TODO();
	}
	
	protected final int getInteractionModes()
	{
		throw new todo.TODO();
	}
	
	public int getKeyCode(int __action)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2018/03/28
	 */
	@SerializedEvent
	protected void hideNotify()
	{
		// Implemented by sub-classes
	}
	
	protected final void invalidate()
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyPressed(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyReleased(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void keyRepeated(int __a)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerDragged(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerPressed(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void pointerReleased(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	protected final void repaint()
	{
		throw new todo.TODO();
	}
	
	protected final void repaint(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void setKeyListener(KeyListener __kl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the painting mode of the canvas.
	 *
	 * If transparent mode is enabled, then the implementation (not the end
	 * developer) will fill the background with a suitable color or image
	 * (which is unspecified).
	 *
	 * If opaque mode (which is the default) is enabled then it will be
	 * assumed that {@link #repaint(Graphics)} will cover every pixel and as
	 * such it will not be required for the background to be cleared or
	 * initialized.
	 *
	 * @param __opaque If {@code true} then opaque mode is enabled.
	 * @since 2018/03/28
	 */
	public void setPaintMode(boolean __opaque)
	{
		this._transparent = !__opaque;
	}
	
	@SerializedEvent
	protected void showNotify()
	{
		// Implemented by sub-classes
	}
	
	@SerializedEvent
	protected void sizeChanged(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected boolean traverse(int __a, int __b, int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void traverseOut()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/DateField.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import java.util.Date;
import java.util.TimeZone;

public class DateField
	extends Item
{
	public static final int DATE =
		1;
	
	public static final int DATE_TIME =
		3;
	
	public static final int TIME =
		2;
	
	/** The timezone to use. */
	private final TimeZone _zone;
	
	/**
	 * Initializes the date field with the default timezone.
	 *
	 * @param __l The label to use.
	 * @param __m The mode used.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2019/05/17
	 */
	public DateField(String __l, int __m)
		throws IllegalArgumentException
	{
		this(__l, __m, null);
	}
	
	/**
	 * Initializes the date field with the default timezone.
	 *
	 * @param __l The label to use.
	 * @param __m The mode used.
	 * @param __z The time zone to use, {@code null} is the default.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2019/05/17
	 */
	public DateField(String __l, int __m, TimeZone __z)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB1g Invalid date field mode. (The mode)}
		if (__m != DATE && __m != DATE_TIME && __m != TIME)
			throw new IllegalArgumentException("EB1g " + __m);
		
		this._zone = __z;
	}
	
	public Date getDate()
	{
		throw new todo.TODO();
	}
	
	public int getInputMode()
	{
		throw new todo.TODO();
	}
	
	public void setDate(Date __a)
	{
		throw new todo.TODO();
	}
	
	public void setInputMode(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Display.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070














































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.DeviceFeedbackType;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.IPCManager;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.common.CommonMetrics;
import cc.squirreljme.runtime.lcdui.DisplayOrientation;
import cc.squirreljme.runtime.lcdui.DisplayState;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.phoneui.NativeUIBackend;
import cc.squirreljme.runtime.lcdui.phoneui.PhoneDisplayBackend;
import cc.squirreljme.runtime.lcdui.phoneui.PhoneUI;
import cc.squirreljme.runtime.lcdui.phoneui.StandardMetrics;
import cc.squirreljme.runtime.lcdui.SerializedEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.microedition.midlet.MIDlet;

public class Display
{
	public static final int ALERT =
		3;

	public static final int CHOICE_GROUP_ELEMENT =
		2;

	public static final int COLOR_BACKGROUND =
		0;

	public static final int COLOR_BORDER =
		4;

	public static final int COLOR_FOREGROUND =
		1;

	public static final int COLOR_HIGHLIGHTED_BACKGROUND =
		2;

	public static final int COLOR_HIGHLIGHTED_BORDER =
		5;

	public static final int COLOR_HIGHLIGHTED_FOREGROUND =
		3;

	public static final int COLOR_IDLE_BACKGROUND =
		6;

	public static final int COLOR_IDLE_FOREGROUND =
		7;

	public static final int COLOR_IDLE_HIGHLIGHTED_BACKGROUND =
		8;

	public static final int COLOR_IDLE_HIGHLIGHTED_FOREGROUND =
		9;

	public static final int COMMAND =
		5;

	public static final int DISPLAY_HARDWARE_ABSENT =
		2;

	public static final int DISPLAY_HARDWARE_DISABLED =
		1;

	public static final int DISPLAY_HARDWARE_ENABLED =
		0;

	public static final int LIST_ELEMENT =
		1;

	public static final int MENU =
		7;

	/** This is the activity mode that enables power saving inhibition. */
	public static final int MODE_ACTIVE =
		1;
	
	/** This is the activity mode that is the default behavior. */
	public static final int MODE_NORMAL =
		0;

	public static final int NOTIFICATION =
		6;

	public static final int ORIENTATION_LANDSCAPE =
		2;

	public static final int ORIENTATION_LANDSCAPE_180 =
		8;

	public static final int ORIENTATION_PORTRAIT =
		1;

	public static final int ORIENTATION_PORTRAIT_180 =
		4;

	public static final int SOFTKEY_BOTTOM =
		800;

	public static final int SOFTKEY_INDEX_MASK =
		15;

	public static final int SOFTKEY_LEFT =
		820;

	public static final int SOFTKEY_OFFSCREEN =
		880;

	public static final int SOFTKEY_RIGHT =
		860;

	public static final int SOFTKEY_TOP =
		840;

	public static final int STATE_BACKGROUND =
		0;

	public static final int STATE_FOREGROUND =
		2;

	public static final int STATE_VISIBLE =
		1;

	public static final int SUPPORTS_ALERTS =
		32;

	public static final int SUPPORTS_COMMANDS =
		2;

	public static final int SUPPORTS_FILESELECTORS =
		512;

	public static final int SUPPORTS_FORMS =
		4;

	public static final int SUPPORTS_IDLEITEM =
		2048;

	/** This specifies that the display supports user input. */
	public static final int SUPPORTS_INPUT_EVENTS =
		1;

	public static final int SUPPORTS_LISTS =
		64;

	public static final int SUPPORTS_MENUS =
		1024;

	public static final int SUPPORTS_ORIENTATION_LANDSCAPE =
		8192;

	public static final int SUPPORTS_ORIENTATION_LANDSCAPE180 =
		32768;

	public static final int SUPPORTS_ORIENTATION_PORTRAIT =
		4096;

	public static final int SUPPORTS_ORIENTATION_PORTRAIT180 =
		16384;

	public static final int SUPPORTS_TABBEDPANES =
		256;

	public static final int SUPPORTS_TEXTBOXES =
		128;

	public static final int SUPPORTS_TICKER =
		8;

	public static final int SUPPORTS_TITLE =
		16;

	public static final int TAB =
		4;
	
	/** The number of down keys to store, for a single hand. */
	private static final int _NUM_DOWNKEYS =
		5;
	
	/** Listeners for the display. */
	private static final List<DisplayListener> _LISTENERS =
		new ArrayList<>();
	
	/** The current display which was created. */
	private static Display _DISPLAY;
	
	/** The displayable to show. */
	private volatile Displayable _current;
	
	/** The displayable to show on exit. */
	private volatile Displayable _exit;
	
	/**
	 * Initializes the display instance.
	 *
	 * @since 2018/03/16
	 */
	Display()
	{
	}
	
	public void callSerially(Runnable __a)
	{
		// Note that the Runnable.run() will be called as if it were serialized
		// like everything else with @SerializedEvent
		throw new todo.TODO();
	}
	
	/**
	 * Flashes the display LED for the given number of milliseconds.
	 *
	 * In SquirrelJME this flashes an LED and not the back light, since it is
	 * not a popular means to notify the user and additionally due to
	 * medical concerns such as epilepsy.
	 *
	 * @param __ms The number of milliseconds to flash for.
	 * @return {@code true} if the backlight is controlled by the application
	 * and the display is in the foreground, otherwise {@code false}.
	 * @since 2019/10/05
	 */
	public boolean flashBacklight(int __ms)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB30 Cannot blink for a negative duration.}
		if (__ms < 0)
			throw new IllegalArgumentException("EB30");
		
		// Blink!
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.BLINK_LED, __ms);
		
		// Only return true if no error was generated
		return (SystemCallError.NO_ERROR ==
			Assembly.sysCallV(SystemCallIndex.ERROR_GET,
				SystemCallIndex.DEVICE_FEEDBACK));
	}
	
	/**
	 * Returns the current activity mode that the display is within, if
	 * active mode is set then the display will inhibit power saving features.
	 *
	 * @return Either {@link #MODE_ACTIVE} or {@link #MODE_NORMAL}.
	 * @since 2016/10/08
	 */
	public int getActivityMode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the height of the image that should be used for the given
	 * display element.
	 *
	 * Valid elements are:
	 * {@link #LIST_ELEMENT},
	 * {@link #CHOICE_GROUP_ELEMENT},
	 * {@link #ALERT},
	 * {@link #TAB},
	 * {@link #COMMAND},
	 * {@link #NOTIFICATION}, and
	 * {@link #MENU}.
	 *
	 * @param __a If display element.
	 * @return The height of the image for that element.
	 * @throws IllegalArgumentException On null arguments.
	 * @since 2016/10/14
	 */
	public int getBestImageHeight(int __a)
		throws IllegalArgumentException
	{
		return __bestImageSize(__a, true);
	}
	
	/**
	 * Returns the width of the image that should be used for the given
	 * display element.
	 *
	 * Valid elements are:
	 * {@link #LIST_ELEMENT},
	 * {@link #CHOICE_GROUP_ELEMENT},
	 * {@link #ALERT},
	 * {@link #TAB},
	 * {@link #COMMAND},
	 * {@link #NOTIFICATION}, and
	 * {@link #MENU}.
	 *
	 * @param __a If display element.
	 * @return The width of the image for that element.
	 * @throws IllegalArgumentException On null arguments.
	 * @since 2016/10/14
	 */
	public int getBestImageWidth(int __a)
		throws IllegalArgumentException
	{
		return __bestImageSize(__a, false);
	}
	
	public int getBorderStyle(boolean __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This returns the capabilities that the display supports. This means that
	 * displays which do not support specific widget types can be known so that
	 * potential alternative handling may be performed.
	 *
	 * The capabilities are the constants starting with {@code SUPPORTS_}
	 *
	 * @return A bit field where set bits indicate supported capabilities, if
	 * {@code 0} is returned then only a {@link Canvas} is supported.
	 * @since 2016/10/08
	 */
	public int getCapabilities()
	{
		int caps = UIState.getInstance().capabilities();
		boolean hastouch = ((caps & Framebuffer.CAPABILITY_TOUCH) != 0);
		boolean hasinput = hastouch |
			((caps & Framebuffer.CAPABILITY_KEYBOARD) != 0);
		
		// Use the capabilities of the native display, but since SquirrelJME
		// manages pretty much everything in a framebuffer every display will
		// always have certain capabilities
		return (hasinput ? SUPPORTS_INPUT_EVENTS : 0) |
			(hastouch ? ExtendedCapabilities.SUPPORTS_POINTER_EVENTS : 0) |
			SUPPORTS_COMMANDS | SUPPORTS_FORMS | SUPPORTS_TICKER |
			SUPPORTS_ALERTS | SUPPORTS_LISTS | SUPPORTS_TEXTBOXES |
			SUPPORTS_FILESELECTORS | SUPPORTS_TABBEDPANES |
			SUPPORTS_MENUS;
	}
	
	/**
	 * Returns the color used for the specified interface item.
	 *
	 * The value values are:
	 * {@link #COLOR_BACKGROUND},
	 * {@link #COLOR_BORDER},
	 * {@link #COLOR_FOREGROUND},
	 * {@link #COLOR_HIGHLIGHTED_BACKGROUND},
	 * {@link #COLOR_HIGHLIGHTED_BORDER},
	 * {@link #COLOR_HIGHLIGHTED_FOREGROUND},
	 * {@link #COLOR_IDLE_BACKGROUND},
	 * {@link #COLOR_IDLE_FOREGROUND},
	 * {@link #COLOR_IDLE_HIGHLIGHTED_BACKGROUND}, and
	 * {@link #COLOR_IDLE_HIGHLIGHTED_FOREGROUND}
	 *
	 * @param __c The color to get.
	 * @return The ARGB color for the specified user interface item, it will
	 * be in the form of {@code 0x00RRGGBB}.
	 * @throws IllegalArgumentException If the specified color is not valid.
	 * @since 2016/10/14
	 */
	public int getColor(int __c)
		throws IllegalArgumentException
	{
		int rv;
		switch (__c)
		{
			case COLOR_BORDER:
				rv = CommonColors.BORDER;
				break;
			
			case COLOR_BACKGROUND:
			case COLOR_IDLE_BACKGROUND:
				rv = CommonColors.BACKGROUND;
				break;
			
			case COLOR_FOREGROUND:
			case COLOR_IDLE_FOREGROUND:
				rv = CommonColors.FOREGROUND;
				break;
			
			case COLOR_HIGHLIGHTED_BORDER:
				rv = CommonColors.HIGHLIGHTED_BORDER;
				break;
				
			case COLOR_HIGHLIGHTED_BACKGROUND:
			case COLOR_IDLE_HIGHLIGHTED_BACKGROUND:
				rv = CommonColors.HIGHLIGHTED_BACKGROUND;
				break;
			
			case COLOR_HIGHLIGHTED_FOREGROUND:
			case COLOR_IDLE_HIGHLIGHTED_FOREGROUND:
				rv = CommonColors.HIGHLIGHTED_FOREGROUND;
				break;
		
				// {@squirreljme.error EB1h Unknown color specifier. (The
				// color specifier)}
			default:
				throw new IllegalArgumentException("EB1h " + __c);
		}
		
		// Clip the alpha away
		return (rv & 0xFFFFFF);
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	public int[] getCommandPreferredPlacements(int __ct)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current displayable.
	 *
	 * @return The current displayable or {@code null} if it is not set.
	 * @since 2016/10/08
	 */
	public Displayable getCurrent()
	{
		return this._current;
	}
	
	public int getDisplayState()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the dot pitch of the display in microns (also known as
	 * micrometers or um).
	 *
	 * If pixels are not square then the pitch should be the average of the
	 * two.
	 *
	 * @return The dot pitch in microns.
	 * @since 2016/10/14
	 */
	public int getDotPitch()
	{
		throw new todo.TODO();
	}
	
	public int[] getExactPlacementPositions(int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current harware state.
	 *
	 * @return The hardware state.
	 * @since 2018/12/10
	 */
	public int getHardwareState()
	{
		throw new todo.TODO();
		/*
		if (__EventCallback__._CALLBACK._registered)
			return DISPLAY_HARDWARE_ENABLED;
		return DISPLAY_HARDWARE_DISABLED;
		*/
	}
	
	/**
	 * Returns the maximum height of the display.
	 *
	 * @return The maximum display height.
	 * @since 2016/10/14
	 */
	public int getHeight()
	{
		return UIState.getInstance().displayHeight();
	}
	
	public IdleItem getIdleItem()
	{
		throw new todo.TODO();
	}
	
	public int[] getMenuPreferredPlacements()
	{
		throw new todo.TODO();
	}
	
	public int[] getMenuSupportedPlacements()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the current orientation of the display.
	 *
	 * @return The display orientation.
	 * @since 2017/10/27
	 */
	public int getOrientation()
	{
		// Landscape just means a longer width
		boolean landscape = this.getWidth() > this.getHeight();
		
		// If it is detected that the display is upsidedown, just say that
		// it was rotated 180 degrees
		if (UIState.getInstance().displayFlipped())
			if (landscape)
				return ORIENTATION_LANDSCAPE_180;
			else
				return ORIENTATION_PORTRAIT_180;
		else
			if (landscape)
				return ORIENTATION_LANDSCAPE;
			else
				return ORIENTATION_PORTRAIT;
	}
	
	/**
	 * Returns the maximum width of the display.
	 *
	 * @retrn The maximum display width.
	 * @since 2016/10/14
	 */
	public int getWidth()
	{
		return UIState.getInstance().displayWidth();
	}
	
	/**
	 * Are mouse/stylus press and release events supported?
	 *
	 * @return {@code true} if they are supported.
	 * @since 2016/10/14
	 */
	public boolean hasPointerEvents()
	{
		return 0 != (this.getCapabilities() &
			ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
	}
	
	/**
	 * Are mouse/stylus move/drag events supported?
	 *
	 * @return {@code true} if they are supported.
	 * @since 2016/10/14
	 */
	public boolean hasPointerMotionEvents()
	{
		return 0 != (this.getCapabilities() &
			ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
	}
	
	/**
	 * Is this display built into the device or is it an auxiliary display?
	 *
	 * @return {@code true} if it is built-in.
	 * @since 2016/10/14
	 */
	public boolean isBuiltIn()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is color supported by this display?
	 *
	 * @return {@code true} if color is supported.
	 * @since 2016/10/14
	 */
	public boolean isColor()
	{
		return UIState.getInstance().displayIsColor();
	}
	
	/**
	 * Returns the number of alpha-transparency levels.
	 *
	 * Alpha levels range from fully transparent to fully opaue.
	 *
	 * There will always be at least two levels.
	 *
	 * @return The alpha transparency levels.
	 * @since 2016/10/14
	 */
	public int numAlphaLevels()
	{
		// Always return 2 because SquirrelJME operates on a flat framebuffer
		// where there is no such thing as transparency
		return 2;
	}
	
	/**
	 * Returns the number of colors available to the display.
	 *
	 * Monochrome (black and white) displays only have two colors.
	 *
	 * There will always be at least two colors.
	 *
	 * @return The number of available colors.
	 * @since 2016/10/14
	 */
	public int numColors()
	{
		return UIState.getInstance().displayUniqueColors();
	}
	
	public void removeCurrent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the activity mode of the display. If active mode is set then
	 * power saving features are inhibited.
	 *
	 * @param __m The activity mode, either {@link #MODE_ACTIVE} or
	 * {@link #MODE_NORMAL}.
	 * @throws IllegalArgumentException If the specified mode is not valid.
	 * @since 2016/10/08
	 */
	public void setActivityMode(int __m)
		throws IllegalArgumentException
	{
		// Active?
		if (__m == MODE_ACTIVE)
			throw new todo.TODO();
	
		// Normal
		else if (__m == MODE_NORMAL)
			throw new todo.TODO();
	
		// {@squirreljme.error EB1i Unknown activity mode specified.}
		else
			throw new IllegalArgumentException("EB1i");
	}
	
	public void setCommandLayoutPolicy(CommandLayoutPolicy __clp)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Shows the given alert on this display, when the alert is finished the
	 * specified displayable is shown when it exits.
	 *
	 * This follows the same semantics as {@link #setCurrent(Displayable)}.
	 *
	 * @param __show The alert to show.
	 * @param __exit The displayable to show when the alert that is
	 * set is dismissed. This cannot be an {@link Alert}.
	 * @throws DisplayCapabilityException If the display cannot show the given
	 * displayable.
	 * @throws IllegalStateException If the display hardware is missing; If
	 * the displayables are associated with another display or tab pane; or
	 * the next displayable item is an alter.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/08
	 */
	public void setCurrent(Alert __show, Displayable __exit)
		throws DisplayCapabilityException, IllegalStateException,
			NullPointerException
	{
		// {@squirreljme.error EB1j Cannot show another alert when the alert
		// to show is cleared.}
		if (__exit instanceof Alert)
			throw new IllegalStateException("EB1j");
		
		// Check
		if (__show == null || __exit == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1k The displayable to show on exit after
		// showing an alert cannot be an alert.}
		if (__exit instanceof Alert)
			throw new IllegalStateException("EB1k");
		
		// Debug
		todo.DEBUG.note("Showing alert \"%s\"", __show._message);
		
		// Perform call on this display
		throw new todo.TODO();
		/*
		try
		{
			// Set widgets
			if (true)
				throw new todo.TODO();
			/*
			LcdServiceCall.<VoidType>call(VoidType.class,
				LcdFunction.WIDGET_ALERT_SHOW, this._handle,
				__show._handle, __exit._handle);
			* /
			
			// Hold onto these so they do not get GCed
			this._heldcurrent = __show;
			this._heldexit = __exit;
		}
		
		// {@squirreljme.error EB1l Could not set the alert and its exit
		// displayable because it is already set on a display.}
		catch (LcdWidgetOwnedException e)
		{
			throw new IllegalStateException("EB1l", e);
		}*/
	}
	
	/**
	 * Sets the current displayable to be displayed.
	 *
	 * If the value to be passed is an {@link Alert} then this acts as if
	 * {@code setCurrent(__show, getCurrent())} was called.
	 *
	 * The displayable if specified will be put into the foreground state.
	 *
	 * Note that it is unspecified when the displayable is made current, it may
	 * be done when this is called or it may be queued for later.
	 *
	 * @param __show The displayable to show, if {@code null} this tells the
	 * {@link Display} to enter the background state.
	 * @throws DisplayCapabilityException If the display cannot show the given
	 * displayable.
	 * @throws IllegalStateException If the display hardware is missing; If
	 * the displayable is associated with another display or tab pane.
	 * @since 2016/10/08
	 */
	public void setCurrent(Displayable __show)
		throws DisplayCapabilityException, IllegalStateException
	{
		// Enter background state?
		if (__show == null)
		{
			todo.TODO.note("Enter background state.");
			/*head.setState(DisplayState.BACKGROUND);*/
			return;
		}
		
		// If we are trying to show the same display, do nothing
		Displayable current = this._current;
		if (current == __show)
		{
			// If we just set current with no actual change, just make sure
			// our callback is the one which is registered so that way we
			// take control of the screen
			if (__show != null)
				this.__doShowCurrent(__show);
			
			return;
		}
		
		// If showing an alert, it gets displayed instead
		if (__show instanceof Alert)
		{
			this.setCurrent((Alert)__show, this.getCurrent());
			return;
		}
		
		// {@squirreljme.error EB1m The displayable to be displayed is already
		// being displayed.}
		if (__show._display != null)
			throw new IllegalStateException("EB1m");
		
		// Clear current's parent
		if (current != null)
		{
			// Stop showing
			current._isshown = false;
			current.hideNotify();
			
			// Not used anymore
			current._display = null;
		}
		
		// Set new parent
		__show._display = this;
		this._current = __show;
		
		// Do common showing stuff
		this.__doShowCurrent(__show);
	}
	
	public void setCurrentItem(Item __a)
	{
		throw new todo.TODO();
	}
	
	public void setIdleItem(IdleItem __i)
	{
		throw new todo.TODO();
	}
	
	public void setPreferredOrientation(int __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Attempts to vibrate the device for the given number of milliseconds.
	 *
	 * The values here only set the duration to vibrate for from the current
	 * point in time and will not increase the length of vibration.
	 *
	 * The return value will be {@code false} if the display is in the
	 * background, the device cannot vibrate, or the vibrator cannot be
	 * controlled.
	 *
	 * Note that excessive vibration may cause the battery life for a device to
	 * be lowered, thus it should be used sparingly.
	 *
	 * @param __d The number of milliseconds to vibrate for, if zero the
	 * vibrator will be switched off.
	 * @return {@code true} if the vibrator is controllable by this application
	 * and the display is active.
	 * @throws IllegalArgumentException If the duration is negative.
	 * @since 2017/02/26
	 */
	public boolean vibrate(int __d)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1n Cannot vibrate for a negative duration.}
		if (__d < 0)
			throw new IllegalArgumentException("EB1n");
		
		// Clear vibration
		Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
			DeviceFeedbackType.VIBRATE, __d);
		
		// Only return true if no error was generated
		return (SystemCallError.NO_ERROR ==
			Assembly.sysCallV(SystemCallIndex.ERROR_GET,
				SystemCallIndex.DEVICE_FEEDBACK));
	}
	
	/**
	 * This wraps getting the best image size.
	 *
	 * @param __e The element to get it for.
	 * @param __h Return the height?
	 * @return The best image size.
	 * @throws IllegalArgumentException If the element type is not valid.
	 * @since 2016/10/14
	 */
	private int __bestImageSize(int __e, boolean __h)
		throws IllegalArgumentException
	{
		// Depends
		switch (__e)
		{
			case LIST_ELEMENT:
				return StandardMetrics.LIST_ITEM_HEIGHT;
				
			case CHOICE_GROUP_ELEMENT:
				throw new todo.TODO();
				
			case ALERT:
				throw new todo.TODO();
				
			case TAB:
				throw new todo.TODO();
				
			case COMMAND:
				return StandardMetrics.COMMAND_BAR_HEIGHT;
				
			case NOTIFICATION:
				throw new todo.TODO();
				
			case MENU:
				return StandardMetrics.COMMAND_BAR_HEIGHT;
				
				// {@squirreljme.error EB1o Cannot get the best image size of
				// the specified element. (The element specifier)}
			default:
				throw new IllegalArgumentException(String.format("EB1o %d",
					__e));
		}
	}
	
	/**
	 * Do current show logic.
	 *
	 * @param __show The displayable to show.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	final void __doShowCurrent(Displayable __show)
		throws NullPointerException
	{	
		UIState uis = UIState.getInstance();
		
		// Always set as shown, easier to work with
		__show._isshown = true;
		
		// Set title of our display to the title of the Displayable
		uis.setTitle(__show._dtitle);
		
		// Set drawn displayable
		uis.setDisplayable(__show);
		
		// Callback when it is made visible
		__show.showNotify();
	}
	
	/**
	 * Adds the specified listener for changes to displays.
	 *
	 * The order in which listeners are executed in is
	 * implementation specified.
	 *
	 * @param __dl The listener to add.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static void addDisplayListener(DisplayListener __dl)
		throws NullPointerException
	{
		if (__dl == null)
			throw new NullPointerException("NARG");
		
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			// Do nothing if it is already in there
			for (int i = 0, n = listeners.size(); i < n; i++)
				if (listeners.get(i) == __dl)
					return;
			
			// Add it, if it is not there
			listeners.add(__dl);
		}
	}
	
	/**
	 * Obtains the display that is associated with the given MIDlet.
	 *
	 * @param __m The display to get the midlet for.
	 * @return The display for the given midlet.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/08
	 */
	public static Display getDisplay(MIDlet __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// First display already made?
		Display d = Display._DISPLAY;
		if (d != null)
			return d;
		
		// Use the first display that is available.
		// In the runtime, each program only ever gets a single MIDlet and
		// creating new MIDlets is illegal. Thus since getDisplays() has zero
		// be the return value for this method, that is used here.
		Display[] disp = getDisplays(0);
		if (disp.length > 0)
			return disp[0];
		
		// {@squirreljme.error EB1p Could not get the display for the specified
		// MIDlet because no displays are available.}
		throw new IllegalStateException("EB1p");
	}
	
	/**
	 * Obtains the displays which have the given capability from all internal
	 * display providers.
	 *
	 * @param __caps The capabities to use, this is a bitfield and the values
	 * include all of the {@code SUPPORT_} prefixed constans. If {@code 0} is
	 * specified then capabilities are not checked.
	 * @return An array containing the displays with these capabilities.
	 * @since 2016/10/08
	 */
	public static Display[] getDisplays(int __caps)
	{
		// Create initial display?
		Display d = Display._DISPLAY;
		if (d == null)
			synchronized (Display.class)
			{
				d = Display._DISPLAY;
				if (d == null)
				{
					Display._DISPLAY = (d = new Display());
					
					// Just signify that the display was added here
					for (DisplayListener dl : Display.__listeners())
						dl.displayAdded(d);
				}
			}
		
		// Either the capabilities match or we do not care what the display
		// supports
		if (__caps == 0 || ((d.getCapabilities() & __caps) == __caps))
			return new Display[]{d};
		
		// {@squirreljme.error EB1q No displays are available.}
		throw new IllegalStateException("EB1q");
	}
	
	/**
	 * Removes the specified display listener so that it is no longer called
	 * when events occur.
	 *
	 * @param __dl The listener to remove.
	 * @throws IllegalStateException If the listener is not in the display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/24
	 */
	public static void removeDisplayListener(DisplayListener __dl)
		throws IllegalStateException, NullPointerException
	{
		if (__dl == null)
			throw new NullPointerException("NARG");	
		
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			boolean didremove = false;
			for (int i = 0, n = listeners.size(); i < n; i++)
				if (listeners.get(i) == __dl)
				{
					listeners.remove(i);
					didremove = true;
				}
			
			// {@squirreljme.error EB1r The listener was never added to the
			// listener set.}
			if (!didremove)
				throw new IllegalStateException("EB1r");
		}
	}
	
	/**
	 * Returns an array of all the attached listeners.
	 *
	 * @return An array of listeners.
	 * @since 2018/03/24
	 */
	static DisplayListener[] __listeners()
	{
		List<DisplayListener> listeners = Display._LISTENERS;
		synchronized (listeners)
		{
			return listeners.<DisplayListener>toArray(new DisplayListener[
				listeners.size()]);
		}
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/DisplayCapabilityException.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This is thrown when an attempt is made to do something on a display which
 * does not support a given capability.
 *
 * @since 2018/11/17
 */
public class DisplayCapabilityException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/17
	 */
	public DisplayCapabilityException()
	{
		super();
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/17
	 */
	public DisplayCapabilityException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/DisplayListener.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface DisplayListener
{
	@SerializedEvent
	public abstract void displayAdded(Display __d);
	
	@SerializedEvent
	public abstract void displayStateChanged(Display __d, int __ns);
	
	@SerializedEvent
	public abstract void hardwareStateChanged(Display __d, int __ns);
	
	@SerializedEvent
	public abstract void orientationChanged(Display __d, int __no);
	
	@SerializedEvent
	public abstract void sizeChanged(Display __d, int __w, int __h);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Displayable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442


























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.phoneui.ExposedDisplayable;
import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.midlet.MIDlet;

/**
 * A displayable is a primary container such as a form or a canvas that can be
 * set on a display. A display may only have a single displayable associated
 * with it and a displayable may only be associated with a single display.
 *
 * @since 2016/10/08
 */
public abstract class Displayable
	extends ExposedDisplayable
{
	/** Commands/Menus which have been added to the displayable. */
	final __VolatileList__<__Action__> _actions =
		new __VolatileList__<>();
	
	/** The display this is attached to, if any. */
	volatile Display _display;
	
	/** The command listener to call into when commands are generated. */
	volatile CommandListener _cmdlistener;
	
	/** The title of the displayable. */
	volatile String _title;
	
	/** Display title to use. */
	volatile String _dtitle;
	
	/** The ticker of the displayable. */
	volatile Ticker _ticker;
	
	/** Is this widget shown? */
	volatile boolean _isshown;
	
	/**
	 * Initializes the base displayable object.
	 *
	 * @since 2016/10/08
	 */
	Displayable()
	{
		// Use a default title for now
		this._dtitle = Displayable.__defaultTitle();
	}
	
	/**
	 * Returns the height of this displayable's content area in pixels (the
	 * area the developer can use).
	 *
	 * @return The current height of this displayable in pixels, if it is not
	 * visible then the default height is returned.
	 * @since 2017/02/08
	 */
	public abstract int getHeight();
	
	/**
	 * Returns the width of this displayable's content area in pixels (the
	 * area the developer can use).
	 *
	 * @return The current width of this displayable in pixels, if it is not
	 * visible then the default width is returned.
	 * @since 2017/02/08
	 */
	public abstract int getWidth();
	
	/**
	 * Adds the specified command to this displayable, if it was already added
	 * then there is no effect (object refefences are checked).
	 *
	 * @param __c The command to add.
	 * @throws DisplayCapabilityException If this is being displayed and
	 * the display does not support commands.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/17
	 */
	public void addCommand(Command __c)
		throws DisplayCapabilityException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB1s The display does not support commands.}
		Display cd = this.getCurrentDisplay();
		if (cd != null)
			if ((cd.getCapabilities() & Display.SUPPORTS_COMMANDS) == 0)
				throw new DisplayCapabilityException("EB1s");
		
		// Add the command
		this._actions.addUniqueObjRef(__c);
		
		// Repaint display?
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public Command getCommand(int __p)
	{
		throw new todo.TODO();
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	protected CommandListener getCommandListener()
	{
		return this._cmdlistener;
	}
	
	/**
	 * Gets the commands which are available to use.
	 *
	 * @return The available commands.
	 * @since 2019/05/17
	 */
	public Command[] getCommands()
	{
		List<Command> rv = new ArrayList<>();
		for (__Action__ a : this._actions)
			if (a instanceof Command)
				rv.add((Command)a);
		return rv.<Command>toArray(new Command[rv.size()]);
	}
	
	/**
	 * Returns the display that is associated with this displayable.
	 *
	 * @return The owning display or {@code null} if not found.
	 * @since 2016/10/08
	 */
	public Display getCurrentDisplay()
	{
		return this._display;
	}
	
	public Menu getMenu(int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Gets the ticker which is being shown on this displayable.
	 *
	 * @return The ticker being shown or {@code null} if there is none.
	 * @since 2018/03/26
	 */
	public Ticker getTicker()
	{
		return this._ticker;
	}
	
	/**
	 * Returns the title of this displayable.
	 *
	 * @return The title of this displayable.
	 * @since 2016/10/08
	 */
	public String getTitle()
	{
		return this._title;
	}
	
	public void invalidateCommandLayout()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This method is called after this has been hidden from the display,
	 * whether it was removed or concealed. This can be used to stop timers
	 * for example since they might not be needed when this is not visible.
	 *
	 * @since 2019/05/18
	 */
	@SerializedEvent
	void hideNotify()
	{
	}
	
	/**
	 * Returns if this displayable is currently being shown.
	 *
	 * @return If the displayable is being shown.
	 * @since 2018/12/02
	 */
	public boolean isShown()
	{
		// Must be shown and have a parent, because anything without a
		// parent is invisible
		return this._isshown && this._display != null;
	}
	
	/**
	 * Removes the specified command. If the command is {@code null} or it
	 * has never been added, this does nothing. If a command is removed then
	 * the display will be updated.
	 *
	 * @param __c The command to remove.
	 * @since 2019/04/15
	 */
	public void removeCommand(Command __c)
	{
		if (__c == null)
			return;
		
		// Remove the command
		this._actions.remove(__c);
		
		// Repaint display?
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void removeCommandOrMenu(int __p)
	{
		throw new todo.TODO();
	}
	
	public void setCommand(Command __c, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setCommandLayoutPolicy(CommandLayoutPolicy __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the command listener for this given displayable.
	 *
	 * @param __l The listener to use for callbacks, if {@code null} this
	 * the listener is cleared.
	 * @since 2017/08/19
	 */
	public void setCommandListener(CommandListener __l)
	{
		this._cmdlistener = __l;
	}
	
	public void setMenu(Menu __m, int __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets or clears the ticker to be shown on this displayable.
	 *
	 * @param __t The ticker to be shown on the displayable or {@code null}
	 * to clear it.
	 * @since 2018/03/26
	 */
	public void setTicker(Ticker __t)
	{
		// Removing old ticker?
		Ticker old = this._ticker;
		if (__t == null)
		{
			// Nothing to do?
			if (old == null)
				return;
			
			// Clear
			this._ticker = null;
			
			// Remove from display list
			old._displayables.remove(this);
		}
		
		// Setting the same ticker?
		else if (old == __t)
			return;
		
		// Add new ticker, note they can be associated with many displays
		else
		{
			// Add to displayable list
			__t._displayables.addUniqueObjRef(this);
			
			// Set
			this._ticker = __t;
			
			// Update display
			Display d = this._display;
			if (d != null)
				UIState.getInstance().repaint();
		}
	}
	
	/**
	 * Sets the title of this displayable.
	 *
	 * @param __t The title to use, {@code null} clears it.
	 * @since 2016/10/08
	 */
	public void setTitle(String __t)
	{
		// Cache it for later return
		this._title = __t;
		
		// If no title is being set, fallback to a default one (derived from
		// the suite)
		if (__t == null)
			__t = Displayable.__defaultTitle();
		
		// Store this
		this._dtitle = __t;
		
		// Set the title of the display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().setTitle(__t);
	}
	
	/**
	 * This is called when the canvas has been shown.
	 *
	 * @since 2018/05/18
	 */
	@SerializedEvent
	void showNotify()
	{
	}
	
	/**
	 * This is called when the size of the displayable has changed.
	 *
	 * @param __w The new width of the displayable.
	 * @param __h The new heigh of the displayable.
	 * @since 2016/10/10
	 */
	@SerializedEvent
	protected void sizeChanged(int __w, int __h)
	{
		// Implemented by sub-classes
	}
	
	/**
	 * Returns a default title to use for the application.
	 *
	 * @return Application default title.
	 * @since 2019/05/16
	 */
	private static final String __defaultTitle()
	{
		// Try getting a sensible name from a system property
		MIDlet amid = ActiveMidlet.optional();
		if (amid != null)
		{
			// MIDlet Name
			String midname = amid.getAppProperty("midlet-name");
			if (midname != null)
				return midname;
			
			// Otherwise this might not be a MIDlet, so just use the main
			// class instead
			String midclass = amid.getAppProperty("main-class");
			if (midclass != null)
				return midclass;
		}
		
		// Fallback to just using SquirrelJME
		return "SquirrelJME";
	}
	
	/**
	 * Returns the displayable height.
	 *
	 * @param __d The displayable.
	 * @param __full Return the full screen?
	 * @return The height.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	static final int __getHeight(Displayable __d, boolean __full)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Use dimension from default display
		Display display = __d._display;
		if (display == null)
			return Display.getDisplays(0)[0].getHeight();
		
		// Use drawer width
		return UIState.getInstance().drawerState().contentHeight();
	}
	
	/**
	 * Returns the displayable width.
	 *
	 * @param __d The displayable.
	 * @param __full Return the full screen?
	 * @return The width.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	static final int __getWidth(Displayable __d, boolean __full)
	{
		if (__d == null)
			throw new NullPointerException("NARG");
			
		// Use dimension from default display
		Display display = __d._display;
		if (display == null)
			return Display.getDisplays(0)[0].getWidth();
		
		// Use drawer width
		return UIState.getInstance().drawerState().contentWidth();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/FileSelector.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.io.IOException;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.StreamConnection;

public class FileSelector
	extends Screen
{
	/**
	 * This is used when the user has dismissed the file selector without
	 * having any file selected.
	 */
	public static final Command CANCEL_COMMAND =
		new Command("Cancel", Command.CANCEL, 1, true);
	
	/** This is used when the user has selected a file. */
	public static final Command OK_COMMAND =
		new Command("Select", Command.OK, 0, true);
	
	public static final int DIRECTORY_CREATE =
		3;
	
	public static final int DIRECTORY_SELECT =
		2;
	
	public static final int LOAD =
		0;
	
	public static final int SAVE =
		1;
	
	public FileSelector(String __title, int __mode)
	{
		throw new todo.TODO();
	}
	
	public String[] getFilterExtensions()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public int getMode()
	{
		throw new todo.TODO();
	}
	
	public String getURL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	public StreamConnection open(int __mode, boolean __to)
		throws ConnectionNotFoundException, IOException
	{
		throw new todo.TODO();
	}
	
	public void setFilterExtensions(String[] __ext)
	{
		throw new todo.TODO();
	}
	
	public void setMode(int __m)
	{
		throw new todo.TODO();
	}
	
	public void setURL(String __u)
		throws IOException
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Font.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796




























































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.font.FontSizeConversion;
import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

/**
 * This class represents a font which is a representation of the glyphs which
 * are used to display text and pictographs.
 *
 * @since 2017/05/25
 */
public final class Font
{
	/** The monospace font. */
	public static final int FACE_MONOSPACE =
		32;
	
	/** Proportional fonts. */
	public static final int FACE_PROPORTIONAL =
		64;
	
	/** The system font. */
	public static final int FACE_SYSTEM =
		0;
	
	/** The font used for input text. */
	public static final int FONT_INPUT_TEXT =
		1;
	
	/** The text used to draw item and screen content, such as buttons. */
	public static final int FONT_STATIC_TEXT =
		0;
	
	/** The font used for unfocused text on the idle screen. */
	public static final int FONT_IDLE_TEXT =
		2;
	
	/** The font used for highlighted and focused text on the idle screen. */ 
	public static final int FONT_IDLE_HIGHLIGHTED_TEXT =
		3;
	
	/** Large font size. */
	public static final int SIZE_LARGE =
		16;
	
	/** Medium font size, this is the default. */
	public static final int SIZE_MEDIUM =
		0;
	
	/** Small font size. */
	public static final int SIZE_SMALL =
		8;
	
	/** Bold text. */
	public static final int STYLE_BOLD =
		1;
	
	/** Italic (slanted) text. */
	public static final int STYLE_ITALIC =
		2;
	
	/** Plain style text. */
	public static final int STYLE_PLAIN =
		0;
	
	/** Underlined text. */
	public static final int STYLE_UNDERLINED =
		4;
	
	/** The default font size. */
	private static final int _DEFAULT_FONT_SIZE =
		12;
	
	/** Built-in available fonts. */
	private static Font[] _BUILTIN_FONTS;
	
	/** The default font. */
	private static Font _DEFAULT_FONT;
	
	/** SQF font data. */
	private final SQFFont _sqf;
	
	/** The name of this font. */
	private final String _name;
	
	/** The style of this font. */
	private final int _style;
	
	/** The pixel size of the font. */
	private final int _pixelsize;
	
	/** The face of the font. */
	private final int _face;
	
	/** The height of the font, is pre-calculated. */
	private int _height =
		-1;
	
	/**
	 * Initializes the font.
	 *
	 * @param __n The name of this font.
	 * @param __st The style of this font.
	 * @param __px The pixel size of this font.
	 * @since 2017/10/20
	 */
	private Font(String __n, int __st, int __px)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this._name = __n;
		this._style = __st;
		this._pixelsize = __px;
		
		// Load SQF
		SQFFont sqf;
		this._sqf = (sqf = SQFFont.cacheFont(__n, __px));
		
		// Determine if the font is monospaced or proportional
		int totalwidth = 0;
		for (char c = 0; c < 128; c++)
			totalwidth += sqf.charWidth(c);
		this._face = ((totalwidth / 128) == sqf.charWidth('\0') ?
			FACE_MONOSPACE : FACE_PROPORTIONAL);
	}
	
	/**
	 * Returns the width of the specified character.
	 *
	 * @param __c The character to get the width of.
	 * @return The width of the given character.
	 * @since 2017/10/21
	 */
	public int charWidth(char __c)
	{
		return this._sqf.charWidth(SQFFont.mapChar(__c));
	}
	
	/**
	 * Returns the width of the specified charaters, as if it were drawn
	 * on the screen.
	 *
	 * @param __c The characters to check.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The width of the string.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/06
	 */
	public int charsWidth(char[] __c, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		SQFFont sqf = this._sqf;
		
		// Calculate width
		int x = 0,
			max = 0;
		for (int i = 0; i < __l; i++)
		{
			char c = __c[__o++];
			
			// Ignore carriage returns
			if (c == '\r')
				continue;
			
			// Next line?
			else if (c == '\n')
			{
				if (x > max)
					max = x;
				x = 0;
			}
			
			// Add character
			else
				x += sqf.charWidth(SQFFont.mapChar(c));
		}
		
		// Return the higher of the two
		return (x > max ? x : max);
	}
	
	/**
	 * Derives a font using the given pixel size.
	 *
	 * @param __pxs The pixel size of the font.
	 * @return The derived font.
	 * @throws IllegalArgumentException If this font is a bitmap font and
	 * no font is available using that size.
	 * @since 2018/11/24
	 */
	public Font deriveFont(int __pxs)
		throws IllegalArgumentException
	{
		return this.deriveFont(this.getStyle(), __pxs);
	}
	
	/**
	 * Derives a font using the given style and pixel size.
	 *
	 * @param __style The style of the font.
	 * @param __pxs The pixel size of the font.
	 * @return The derived font.
	 * @throws IllegalArgumentException If this font is a bitmap font and
	 * no font is available using that size, or the style is not valid.
	 * @since 2018/11/24
	 */
	public Font deriveFont(int __style, int __pxs)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1t Invalid font style specified. (The style)}
		if ((__style & ~(STYLE_PLAIN | STYLE_UNDERLINED | STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1t %d",
				__style));
		
		// Use default font size?
		if (__pxs == 0)
			__pxs = FontSizeConversion.logicalSizeToPixelSize(SIZE_MEDIUM);
		
		// {@squirreljme.error EB1u The pixel size of a font cannot be
		// negative.}
		else if (__pxs < 0)
			throw new IllegalArgumentException("EB1u");
		
		// Same exact font?
		if (this._style == __style && this._pixelsize == __pxs)
			return this;
		
		// Create font handle
		return new Font(this._name, __style, __pxs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Same object?
		if (__o == this)
			return true;
		
		// Not a font?
		if (!(__o instanceof Font))
			return false;
		
		Font o = (Font)__o;
		return this._pixelsize == o._pixelsize &&
			this._style == o._style &&
			this._name.equals(o._name);
	}
	
	/**
	 * This returns the ascent of the font from the top of the line to the
	 * average point where the tops of characters are.
	 *
	 * @return The ascent of the font.
	 * @since 2017/10/24
	 */
	public int getAscent()
	{
		return this._sqf.ascent;
	}
	
	/**
	 * Returns the baseline position of the font which is the maximum baseline.
	 *
	 * @return The baseline of the font.
	 * @since 2018/11/29
	 */
	public int getBaselinePosition()
	{
		return this._sqf.maxascent;
	}
	
	/**
	 * This returns the descent of the font from the baseline of the font to
	 * the bottom of most alphanumeric characters.
	 *
	 * @return The descent of the font.
	 * @since 2017/10/24
	 */
	public int getDescent()
	{
		return this._sqf.descent;
	}
	
	/**
	 * Returns the face of the font.
	 *
	 * @return The font face.
	 * @since 2018/12/13
	 */
	public int getFace()
	{
		return this._face;
	}
	
	public String getFamily()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the name of this font.
	 *
	 * @return The font name.
	 * @since 2018/12/01
	 */
	public String getFontName()
	{
		return this._name;
	}
	
	/**
	 * Returns the standard height of a line for this font. This is equal
	 * to the sum of the leading, ascent, and the descent.
	 *
	 * @return The standard font height.
	 * @since 2017/10/20
	 */
	public int getHeight()
	{
		int height = this._height;
		if (height == -1)
			this._height = (height = this.getLeading() + this.getAscent() +
				this.getDescent());
		return height;
	}
	
	/**
	 * Returns the standard leading of the font in pixels. The leading is the
	 * standard number of pixels which are between each line. The space is
	 * reserved between the descent of the first line and the ascent of the
	 * next line.
	 *
	 * @return The standard leading.
	 * @since 2017/10/24
	 */
	public int getLeading()
	{
		return this._sqf.leading;
	}
	
	public int getMaxAscent()
	{
		throw new todo.TODO();
	}
	
	public int getMaxDescent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the size of this font in pixels.
	 *
	 * @return The font size in pixels.
	 * @since 2018/11/24
	 */
	public int getPixelSize()
	{
		return this._pixelsize;
	}
	
	/**
	 * Returns the logical size of the font.
	 *
	 * @return The logical font size.
	 * @since 2018/11/24
	 */
	public int getSize()
	{
		return FontSizeConversion.pixelSizeToLogicalSize(this._pixelsize);
	}
	
	/**
	 * Gets the style of the font.
	 *
	 * @return The style used.
	 * @since 2018/11/24
	 */
	public int getStyle()
	{
		return this._style;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/20
	 */
	@Override
	public int hashCode()
	{
		return this._name.hashCode() ^
			this._style ^
			this._pixelsize;
	}
	
	public boolean isBold()
	{
		throw new todo.TODO();
	}
	
	public boolean isItalic()
	{
		throw new todo.TODO();
	}
	
	public boolean isPlain()
	{
		throw new todo.TODO();
	}
	
	public boolean isUnderlined()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the width of the specified string in pixels.
	 *
	 * @param __s The string to get the width.
	 * @return The width of the string in pixels.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/21
	 */
	public int stringWidth(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		return this.substringWidth(__s, 0, __s.length());
	}
	
	/**
	 * Returns the width of the specified sub-string in pixels.
	 *
	 * @param __s The string to get the width.
	 * @param __o The offset into the string.
	 * @param __l The number of characters to count.
	 * @return The width of the string in pixels.
	 * @throws NullPointerException On null arguments.
	 * @throws StringIndexOutOfBoundsException If the string index is not
	 * within bounds.
	 * @since 2017/10/21
	 */
	public int substringWidth(String __s, int __o, int __l)
		throws NullPointerException, StringIndexOutOfBoundsException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		try
		{
			SQFFont sqf = this._sqf;
			
			// Need to know the max width due to newlines
			int maxwidth = 0,
				curwidth = 0;
			for (int e = __o + __l; __o < e; __o++)
			{
				char c = __s.charAt(__o);
				if (c == '\r' || c == '\n')
				{
					// Only use longer lines
					if (curwidth > maxwidth)
						maxwidth = curwidth;
					
					// Reset because at start of line now
					curwidth = 0;
					continue;
				}
				
				// Add the character's width
				curwidth += sqf.charWidth(SQFFont.mapChar(c));
			}
			
			// Use the greater width
			if (curwidth > maxwidth)
				return curwidth;
			return maxwidth;
		}
		
		// For compatibility just wrap out of bounds, since it is
		// confusidly used
		catch (IndexOutOfBoundsException e)
		{
			StringIndexOutOfBoundsException t =
				new StringIndexOutOfBoundsException(e.getMessage());
			t.initCause(e);
			throw t;
		}
	}
	
	public static Font createFont(InputStream __data)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns all of the fonts which are available.
	 *
	 * @return All of the available fonts.
	 * @since 2018/11/24
	 */
	public static Font[] getAvailableFonts()
	{
		// Already read these fonts?
		Font[] rv = _BUILTIN_FONTS;
		if (rv != null)
			return rv.clone();
		
		// There are currently just three built-in fonts
		_BUILTIN_FONTS = (rv = new Font[]
			{
				new Font("sansserif", 0, _DEFAULT_FONT_SIZE),
				new Font("serif", 0, _DEFAULT_FONT_SIZE),
				new Font("monospace", 0, _DEFAULT_FONT_SIZE),
				new Font("symbol", 0, _DEFAULT_FONT_SIZE),
			});
		return rv.clone();
	}
	
	/**
	 * Returns all of the fonts which are available on the system using the
	 * standard font size.
	 *
	 * @param __style The style of the font, may be a combination of styles.
	 * @return An array of matching font and styles.
	 * @throws IllegalArgumentException If the parameters are not correct.
	 * @since 2017/05/25
	 */
	public static Font[] getAvailableFonts(int __style)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1v Invalid font style specified. (The style)}
		if ((__style & ~(STYLE_PLAIN | STYLE_UNDERLINED | STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1v %d",
				__style));
		
		List<Font> rv = new ArrayList<>();
		for (Font f : Font.getAvailableFonts())
			try
			{
				rv.add(f.deriveFont(__style, f.getPixelSize()));
			}
			catch (IllegalArgumentException e)
			{
			}
		
		return rv.<Font>toArray(new Font[rv.size()]);
	}
	
	/**
	 * Returns all of the fonts which are available in the given format.
	 *
	 * @param __face The face type of the font.
	 * @param __style The style of the font.
	 * @param __pxs The pixel size of the font.
	 * @throws IllegalArgumentException If the parameters are not correct.
	 * @since 2018/11/24
	 */
	public static Font[] getAvailableFonts(int __face, int __style, int __pxs)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1w Invalid font style specified. (The style)}
		if ((__style & ~(STYLE_PLAIN | STYLE_UNDERLINED | STYLE_BOLD)) != 0)
			throw new IllegalArgumentException(String.format("EB1w %d",
				__style));
		
		// Need to filter by face, then derive
		List<Font> rv = new ArrayList<>();
		for (Font f : Font.getAvailableFonts())
		{
			// Has the wrong face, ignore
			if (f.getFace() != __face)
				continue;
			
			// Derive it
			try
			{
				rv.add(f.deriveFont(__style, __pxs));
			}
			catch (IllegalArgumentException e)
			{
			}
		}
		
		return rv.<Font>toArray(new Font[rv.size()]);
	}
	
	/**
	 * Returns the default system font.
	 *
	 * @return The default system font.
	 * @since 2017/05/24
	 */
	public static Font getDefaultFont()
	{
		// 
		Font rv = _DEFAULT_FONT;
		if (rv != null)
			return rv;
		
		// Use the first found font as the default
		_DEFAULT_FONT = (rv = Font.getAvailableFonts()[0]);
		return rv;
	}
	
	/**
	 * Returns the font by the given specifier.
	 *
	 * @param __spec The specifier of the font to get.
	 * @return The font for the given specifier.
	 * @throws IllegalArgumentException If the specifier is not valid.
	 * @since 2018/11/24
	 */
	public static Font getFont(int __spec)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1x Invalid font specifiers. (The specifiers)}
		if (__spec != FONT_INPUT_TEXT && __spec != FONT_STATIC_TEXT &&
			__spec != FONT_IDLE_TEXT && __spec != FONT_IDLE_HIGHLIGHTED_TEXT)
			throw new IllegalArgumentException("EB1x " + __spec);
		
		// This is always the default font
		return Font.getDefaultFont();
	}
	
	/**
	 * Locates a font which matches the specified parameters the closest, a
	 * font will always be returned if the parameters do not match.
	 *
	 * @param __face The font face, this is a single value.
	 * @param __style The style of the font, this may be a combination of
	 * values.
	 * @param __size The size of the font, this is a single value.
	 * @return The nearest font which matches the specified parameters.
	 * @throws IllegalArgumentException If the input parameters are not valid.
	 * @since 2017/05/25
	 */
	public static Font getFont(int __face, int __style, int __size)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB1y Invalid font face specified. (The face)}
		if ((__face & ~(FACE_SYSTEM | FACE_MONOSPACE | FACE_PROPORTIONAL)) != 0
			|| Integer.bitCount(__face) > 1)
			throw new IllegalArgumentException(String.format("EB1y %d",
				__face));
		
		// {@squirreljme.error EB1z Invalid font size specified. (The size)}
		if ((__size & ~(SIZE_SMALL | SIZE_MEDIUM | SIZE_LARGE)) != 0
			|| Integer.bitCount(__size) > 1)
			throw new IllegalArgumentException(String.format("EB1z %d",
				__size));
		
		// Get fonts that might exist
		Font[] scan = Font.getAvailableFonts(__face, __style,
			FontSizeConversion.logicalSizeToPixelSize(__size));
		
		// If no fonts were found, use a default font with a derived pixel
		// size as such
		if (scan.length == 0)
		{
			// Try to derive this font to the style and size, but if that
			// fails then just do the style
			Font d = Font.getDefaultFont();
			try
			{
				return d.deriveFont(__style,
					FontSizeConversion.logicalSizeToPixelSize(__size));
			}
			catch (IllegalArgumentException e)
			{
				try
				{
					return d.deriveFont(__style, d.getPixelSize());
				}
				catch (IllegalArgumentException f)
				{
					return d;
				}
			}
		}
		
		// Use the first font, since it should be correct hopefully
		return scan[0];
	}
	
	/**
	 * Returns a font which matches the given name.
	 *
	 * @param __name The name of the font to find.
	 * @param __style The style to use.
	 * @param __pxs The pixel size of the font.
	 * @return The font.
	 * @throws IllegalArgumentException If no font was found or the style
	 * and/or pixel size were not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static Font getFont(String __name, int __style, int __pxs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Find the font then derive it
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.deriveFont(__style, __pxs);
		
		// {@squirreljme.error EB20 Could not locate a font by the given
		// name. (The font name)}
		throw new IllegalArgumentException("EB20 " + __name);
	}
	
	/**
	 * Returns the pixel size of the given font.
	 *
	 * @param __name The name of the font.
	 * @return The pixel size of the font.
	 * @throws IllegalArgumentException If the font does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static int getPixelSize(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.getPixelSize();
		
		// {@squirreljme.error EB21 No font with the given name exists.
		// (The font name)}
		throw new IllegalArgumentException("EB21 " + __name);
	}
	
	/**
	 * Returns the style of the given font.
	 *
	 * @param __name The name of the font.
	 * @return The style of the font.
	 * @throws IllegalArgumentException If the font does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/24
	 */
	public static int getStyle(String __name)
		throws IllegalArgumentException, NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		for (Font f : Font.getAvailableFonts())
			if (__name.equals(f.getFontName()))
				return f.getStyle();
		
		// {@squirreljme.error EB22 No font with the given name exists.
		// (The font name)}
		throw new IllegalArgumentException("EB2g " + __name);
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/FontFormatException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This is thrown when the format of a font is not correct.
 *
 * @since 2018/11/23
 */
public class FontFormatException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/23
	 */
	public FontFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/23
	 */
	public FontFormatException(String __m)
	{
		super(__m);
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Form.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;

public class Form
	extends Screen
{
	/** Items on the form. */
	final __VolatileList__<Item> _items =
		new __VolatileList__<>();
	
	/**
	 * Initializes an empty form with an optionally specified title.
	 *
	 * @param __t The title of the form, may be {@code null}.
	 * @since 2017/08/19
	 */
	public Form(String __t)
	{
		this(__t, null);
	}
	
	/**
	 * Initializes a form with the given items and an optionally specified
	 * title.
	 *
	 * @param __t The title of the form, may be {@code null}.
	 * @param __i The items to add to the form.
	 * @throws IllegalStateException If an item in the form is already owned
	 * by another container.
	 * @throws NullPointerException If any element in {@code __i} is
	 * {@code null}.
	 * @since 2017/08/19
	 */
	public Form(String __t, Item[] __i)
		throws IllegalStateException, NullPointerException
	{
		// Forms just use the titles the same as Displayables
		try
		{
			this.setTitle(__t);
		}
		
		// Ignore this if it occurs so that constructing the form does not
		// end in failure
		catch (DisplayCapabilityException e)
		{
		}
		
		// Append items in order
		if (__i != null)
			for (Item i : __i)
			{
				// Check
				if (i == null)
					throw new NullPointerException("NARG");
				
				this.append(i);
			}
	}
	
	/**
	 * Appends the given string.
	 *
	 * @param __s The string.
	 * @return The index of the item.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		return this.append(new StringItem(null, __s));
	}
	
	/**
	 * Appends the given image.
	 *
	 * @param __i The image.
	 * @return The index of the item.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(Image __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return this.append(new ImageItem(null, __i, ImageItem.LAYOUT_DEFAULT,
			null));
	}
	
	/**
	 * Appends the given item to the form.
	 *
	 * @param __i The item to append.
	 * @return The index of the item.
	 * @throws IllegalStateException If the item is already associated with
	 * a form.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public int append(Item __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB23 Cannot append an item which has already
		// be associated with a form.}
		if (__i._displayable != null)
			throw new IllegalStateException("EB23");
		__i._displayable = this;
		
		// Append item
		__VolatileList__<Item> items = this._items;
		int rv = items.append(__i);
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
		
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	public void deleteAll()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the given form item.
	 *
	 * @param __i The index to get.
	 * @return The item.
	 * @throws IndexOutOfBoundsException If the index is not within range.
	 * @since 2019/05/19
	 */
	public Item get(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i);
	}
	
	/**
	 * Returns the currently focused item in the form, or {@code null} if there
	 * is not item being focused.
	 *
	 * @return The current focus item.
	 * @since 2019/12/09
	 */
	public Item getCurrent()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, false);
	}
	
	public FormLayoutPolicy getLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, false);
	}
	
	public void insert(int __a, Item __b)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, Item __b)
	{
		throw new todo.TODO();
	}
	
	public void setItemStateListener(ItemStateListener __a)
	{
		throw new todo.TODO();
	}
	
	public void setItemTraversalListener(ItemTraversalListener __itl)
	{
		throw new todo.TODO();
	}
	
	public void setLayoutPolicy(FormLayoutPolicy __p)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of items in the form.
	 *
	 * @return The number of form items.
	 * @since 2109/05/19
	 */
	public int size()
	{
		return this._items.size();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/FormLayoutPolicy.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class FormLayoutPolicy
{
	public static int DIRECTION_LTR =
		0;
	
	public static int DIRECTION_RTL =
		1;
	
	protected FormLayoutPolicy(Form __f)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected abstract void doLayout(int __vpx, int __vpy, int __vpw,
		int __vph, int[] __ts);
	
	protected abstract Item getTraverse(Item __i, int __dir);
	
	protected final Form getForm()
	{
		throw new todo.TODO();
	}
	
	protected final int getHeight(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getWidth(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getX(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final int getY(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final boolean isValid(Item __i)
	{
		throw new todo.TODO();
	}
	
	protected final void setPosition(Item __i, int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	protected final void setSize(Item __i, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	protected final void setValid(Item __i)
	{
		throw new todo.TODO();
	}
	
	public static final int getLayoutDirection()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Gauge.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class Gauge
	extends Item
{
	public static final int CONTINUOUS_IDLE =
		0;
	
	public static final int CONTINUOUS_RUNNING =
		2;
	
	public static final int INCREMENTAL_IDLE =
		1;
	
	public static final int INCREMENTAL_UPDATING =
		3;
	
	public static final int INDEFINITE =
		-1;
	
	/** Is this interactive? */
	final boolean _interactive;
	
	/** Maximum value. */
	volatile int _maxvalue;
	
	/** Current value. */
	volatile int _value;
	
	/**
	 * Initializes the gauge.
	 *
	 * @param __l The label.
	 * @param __int Can the user change the value?
	 * @param __max The maximum value.
	 * @param __iv The initial value.
	 * @throws IllegalArgumentException If the max value is not positive for
	 * interactive ranges, if the max value is not positive or
	 * {@link #INDEFINITE} for non-interactive ranges, or the initial value
	 * is not one of the special values if it is {@link #INDEFINITE}.
	 * @since 2019/05/17
	 */
	public Gauge(String __l, boolean __int, int __max, int __iv)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB24 An interactive gauge cannot have a negative
		// maximum value.}
		if (__int && __max < 0)
			throw new IllegalArgumentException("EB24");
		
		// {@squirreljme.error EB25 A non-interactive gauge cannot have a
		// negative value that is not indefinite.}
		if (!__int && !(__max >= 0 || __max == INDEFINITE))
			throw new IllegalArgumentException("EB25");
		
		// {@squirreljme.error EB26 Invalid symbolism for indefinite range.}
		if (__max == INDEFINITE && __iv != CONTINUOUS_IDLE &&
			__iv != CONTINUOUS_RUNNING && __iv != INCREMENTAL_IDLE &&
			__iv != INCREMENTAL_UPDATING)
			throw new IllegalArgumentException("EB26");
		
		this._interactive = __int;
		this._value = __iv;
		this._maxvalue = __max;
	}
	
	public int getIncrementValue()
	{
		throw new todo.TODO();
	}
	
	public int getMaxValue()
	{
		throw new todo.TODO();
	}
	
	public int getMinValue()
	{
		throw new todo.TODO();
	}
	
	public int getValue()
	{
		throw new todo.TODO();
	}
	
	public boolean isInteractive()
	{
		throw new todo.TODO();
	}
	
	public void setIncrementValue(int __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @throws IllegalArgumentException If this gauge is associated with an
	 * alert.
	 * @since 2019/05/17
	 */
	@Override
	public void setLabel(String __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB27 Cannot set the label of a gauge associated
		// with an alert.}
		if (this._displayable instanceof Alert)
			throw new IllegalArgumentException("EB27");
		
		// Use super logic
		super.setLabel(__l);
	}
	
	public void setMaxValue(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setMinValue(int __v)
	{
		throw new todo.TODO();
	}
	
	public void setValue(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Graphics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593

















































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * The class describes the interface that is used for drawing operations.
 *
 * When the clipping area is used, no pixels outside of it are drawn. This may
 * be used to draw special effects or have similar maskings.
 *
 * The anchor points {@link #BASELINE}, {@link #BOTTOM}, {@link #HCENTER},
 * {@link #LEFT}, {@link #RIGHT}, {@link #TOP}, and {@link #VCENTER} modify how
 * text and images are placed by allowing their placement positions to be
 * shifted accordingly.
 *
 * The default blending mode must be {@link #SRC_OVER}.
 *
 * An alpha value of {@code 255} means fully opaque (visible) while a value of
 * {@code 0} means transparent (invisible).
 *
 * @since 2017/02/09
 */
public abstract class Graphics
{
	/**
	 * This is the anchorpoint for the baseline of text. This is not valid for
	 * anything which is not text. The baseline is considered to be point where
	 * all letters rest on. The baseline is not the lowest point, so for
	 * letters such as {@code j} the baseline will be higher than the lowest
	 * point.
	 */
	public static final int BASELINE =
		64;
	
	/** The anchor point to position below the specified point. */
	public static final int BOTTOM =
		32;
	
	/** Dotted stroke line style. */
	public static final int DOTTED =
		1;
	
	/** The anchor point to position in the center horizontally. */
	public static final int HCENTER =
		1;
	
	/** The anchor point to position the item to the left. */
	public static final int LEFT =
		4;
	
	/** The anchor point to position the item on the right. */
	public static final int RIGHT =
		8;
	
	/** Solid stroke line style. */
	public static final int SOLID =
		0;
	
	/**
	 * The blending mode, the destination alpha becomes the source and as such
	 * the operation is a copy.
	 */
	public static final int SRC =
		1;
	
	/**
	 * The blending mode, the source alpha is a composited over the
	 * destination.
	 */
	public static final int SRC_OVER =
		0;
	
	/** The anchor point to position the item on the top. */
	public static final int TOP =
		16;
	
	/** The anchor point to position in the center vertically. */
	public static final int VCENTER =
		2;
	
	/**
	 * Base initialization of graphics sub-class.
	 *
	 * Note that extending this class is specific to SquirrelJME and that
	 * doing so will cause programs to only run on SquirrelJME.
	 *
	 * @since 2016/10/10
	 */
	protected Graphics()
	{
	}
	
	/**
	 * This reduces the clipping area of the drawing so that 
	 *
	 * This is only used to reduce the clipping area, to make it larger use
	 * {@link #setClip(int, int, int int)}.
	 *
	 * @param __x The X coordinate of the clipping rectangle,
	 * will be translated.
	 * @param __y The Y coordinate of the clipping rectangle,
	 * will be translated.
	 * @param __w The width of the rectangle.
	 * @param __h The height of the rectangle.
	 * @since 2017/02/10
	 */
	public abstract void clipRect(int __x, int __y, int __w, int __h);
	
	/**
	 * This copies one region of the image to another region.
	 *
	 * Copying to a display device is not permitted because it may impact how
	 * double buffering is implemented, as such it is not supported.
	 *
	 * Pixels are copied directly and no alpha compositing is performed.
	 *
	 * If the source and destination overlap then it must be as if they did not
	 * overlap at all, this means that the destination will be an exact copy of
	 * the source.
	 *
	 * @param __sx The source X position, will be translated.
	 * @param __sy The source Y position, will be translated.
	 * @param __w The width to copy.
	 * @param __h The height to copy.
	 * @param __dx The destination X position, will be translated.
	 * @param __dy The destination Y position, will be translated.
	 * @param __anchor The anchor point of the destination.
	 * @throws IllegalArgumentException If the source region exceeds the size
	 * of the source image.
	 * @throws IllegalStateException If the destination is a display device.
	 * @since 2017/02/10
	 */
	public abstract void copyArea(int __sx, int __sy, int __w, int __h,
		int __dx, int __dy, int __anchor)
		throws IllegalArgumentException, IllegalStateException;
	
	/**
	 * This draws the outer edge of the ellipse from the given angles using
	 * the color, alpha, and stroke style.
	 *
	 * The coordinates are treated as if they were in a rectangular region. As
	 * such the center of the ellipse to draw the outline of is in the center
	 * of the specified rectangle.
	 *
	 * Note that no lines are drawn to the center point, so the shape does not
	 * result in a pie slice.
	 *
	 * The angles are in degrees and visually the angles match those of the
	 * unit circle correctly transformed to the output surface. As such, zero
	 * degrees has the point of {@code (__w, __h / 2)}, that is it points to
	 * the right. An angle at 45 degrees will always point to the top right
	 * corner.
	 *
	 * If the width or height are zero, then nothing is drawn. The arc will
	 * cover an area of {@code __w + 1} and {@code __h + 1}.
	 *
	 * @param __x The X position of the upper left corner, will be translated.
	 * @param __y The Y position of the upper left corner, will be translated.
	 * @param __w The width of the arc.
	 * @param __h The height of the arc.
	 * @param __sa The starting angle in degrees, 
	 * @param __aa The offset from the starting angle, negative values indicate
	 * clockwise direction while positive values are counter clockwise.
	 * @since 2017/02/10
	 */ 
	public abstract void drawArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa);
	
	public abstract void drawARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException;
	
	public abstract void drawChar(char __s, int __x, int __y, int __anchor);
	
	public abstract void drawChars(char[] __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException;
	
	/**
	 * Draws the specified image.
	 *
	 * If this graphics object draws onto the source image then the result is
	 * undefined, {@link copyArea(int, int, int, int, int, int, int)} should
	 * be used instead.
	 *
	 * @param __i The source image.
	 * @param __x The X position to draw at, is translated.
	 * @param __y The Y position to draw at, is translated.
	 * @param __anchor The anchor point of the image.
	 * @throws IllegalArgumentException If the anchor point is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public abstract void drawImage(Image __i, int __x, int __y, int __anchor)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Draws a line using the current color and stroke style.
	 *
	 * @param __x1 Starting X position.
	 * @param __y1 Starting Y position.
	 * @param __x2 Ending X position.
	 * @param __y2 Ending Y position.
	 * @since 2017/02/11
	 */
	public abstract void drawLine(int __x1, int __y1, int __x2, int __y2);
	
	public abstract void drawRGB(int[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h, boolean __alpha)
		throws NullPointerException;
	
	public abstract void drawRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
		throws NullPointerException;
	
	public abstract void drawRect(int __x, int __y, int __w, int __h);
	
	/**
	 * Same as {@code drawRegion(__src, __xsrc __ysrc, __wsrc, __hsrc, __trans,
	 * __xdest, __ydest, __anch, __wsrc, __hsrc);}.
	 *
	 * @param __src The source image.
	 * @param __xsrc The source X position.
	 * @param __ysrc The source Y position.
	 * @param __wsrc The width of the source region.
	 * @param __hsrc The height of the source region.
	 * @param __trans Sprite translation and/or rotation, see {@link Sprite}.
	 * @param __xdest The destination X position, is translated..
	 * @param __ydest The destination Y position, is translated..
	 * @param __anch The anchor point.
	 * @throws IllegalArgumentException If the source is the destination
	 * image; the source region exceeds the image bounds; the sprite
	 * transformation is not valid; The anchor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11 
	 */
	public abstract void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch)
		throws IllegalArgumentException, NullPointerException;
	
	/**
	 * Draws the specified region of the given image with potential scaling
	 * and transformations.
	 *
	 * @param __src The source image.
	 * @param __xsrc The source X position.
	 * @param __ysrc The source Y position.
	 * @param __wsrc The width of the source region.
	 * @param __hsrc The height of the source region.
	 * @param __trans Sprite translation and/or rotation, see {@link Sprite}.
	 * @param __xdest The destination X position, is translated..
	 * @param __ydest The destination Y position, is translated..
	 * @param __anch The anchor point.
	 * @param __wdest The destination width.
	 * @param __hdest The destination height.
	 * @throws IllegalArgumentException If the source is the destination
	 * image; the source region exceeds the image bounds; the sprite
	 * transformation is not valid; The anchor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11 
	 */
	public abstract void drawRegion(Image __src, int __xsrc, int __ysrc,
		int __wsrc, int __hsrc, int __trans, int __xdest, int __ydest,
		int __anch, int __wdest, int __hdest)
		throws IllegalArgumentException, NullPointerException;
	
	public abstract void drawRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah);
	
	/**
	 * Same as {@code drawSubstring(__s, 0, __s.length(), __x, __y, __anchor)}.
	 *
	 * @param __s The string to draw.
	 * @param __x The X position, will be translated.
	 * @param __y The Y position, will be translated.
	 * @param __anchor The anchor point.
	 * @throws NullPointerException If no string was specified.
	 * @since 2017/02/10
	 */
	public abstract void drawString(String __s, int __x, int __y,
		int __anchor)
		throws NullPointerException;
	
	public abstract void drawSubstring(String __s, int __o, int __l, int __x,
		int __y, int __anchor)
		throws NullPointerException, StringIndexOutOfBoundsException;
	
	public abstract void drawText(Text __t, int __x, int __y);
	
	/**
	 * This draws the filled slice of an ellipse (like a pie slice) from the
	 * given angles using the color, alpha, and stroke style.
	 *
	 * Unlike {@link #drawArc(int, int, int, int, int, int)}, the width and
	 * height are not increased by a single pixel.
	 *
	 * Otherwise, this follows the same set of rules as
	 * {@link #drawArc(int, int, int, int, int, int)}.
	 *
	 * @param __x The X position of the upper left corner, will be translated.
	 * @param __y The Y position of the upper left corner, will be translated.
	 * @param __w The width of the arc.
	 * @param __h The height of the arc.
	 * @param __sa The starting angle in degrees, 
	 * @param __aa The offset from the starting angle, negative values indicate
	 * clockwise direction while positive values are counter clockwise.
	 * @see drawArc(int, int, int, int, int, int)
	 * @since 2017/02/10
	 */
	public abstract void fillArc(int __x, int __y, int __w, int __h, int __sa,
		int __aa);
	
	public abstract void fillRect(int __x, int __y, int __w, int __h);
	
	public abstract void fillRoundRect(int __x, int __y, int __w, int __h,
		int __aw, int __ah);
	
	public abstract void fillTriangle(int __x1, int __y1, int __x2, int __y2,
		int __x3, int __y3);
	
	/**
	 * Returns the alpha component.
	 *
	 * @return The alpha in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getAlpha();
	
	/**
	 * Returns the color along with the alpha color. 
	 *
	 * @return The color in the form of {@link @0xAARRGGBB}.
	 * @since 2017/02/10
	 */
	public abstract int getAlphaColor();
	
	/**
	 * Returns the blending mode.
	 *
	 * @return The current blending mode.
	 * @since 2017/02/10
	 */
	public abstract int getBlendingMode();
	
	/**
	 * Returns the blue component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getBlueComponent();
	
	/**
	 * This returns the height of the clipping area.
	 *
	 * @return The clipping area height.
	 * @since 2017/02/10
	 */
	public abstract int getClipHeight();
	
	/**
	 * This returns the width of the clipping area.
	 *
	 * @return The clipping area width.
	 * @since 2017/02/10
	 */
	public abstract int getClipWidth();
	
	/**
	 * This returns the transformed X position of the clipping rectangle.
	 *
	 * @return The clipping area X coordinate, which is transformed.
	 * @since 2017/02/10
	 */
	public abstract int getClipX();
	
	/**
	 * This returns the transformed Y position of the clipping rectangle.
	 *
	 * @return The clipping area Y coordinate, which is transformed.
	 * @since 2017/02/10
	 */
	public abstract int getClipY();
	
	/**
	 * Returns the current color which has been set for drawing.
	 *
	 * @return The color in the form of {@code 0x00RRGGBB}, the upper bits
	 * for alpha will always be zero.
	 * @since 2017/02/10
	 */
	public abstract int getColor();
	
	/**
	 * This returns the actual color that would be drawn onto the given
	 * display if it were set.
	 *
	 * @param __rgb The color to use, the format is {@code 0xRRGGBB}.
	 * @return The color that will actually be drawn on the display.
	 * @since 2017/02/09
	 */
	public abstract int getDisplayColor(int __rgb);
	
	/**
	 * Returns the current font that is used for drawing characters.
	 *
	 * @return The current font that is used.
	 * @since 2017/02/10
	 */
	public abstract Font getFont();
	
	/**
	 * Returns the grayscale color component. If the current set color is not
	 * grayscale then it is unspecified how the grayscale color is derived (it
	 * may be a simple average or derived from display specific brightness
	 * values).
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getGrayScale();
	
	/**
	 * Returns the green component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getGreenComponent();
	
	/**
	 * Returns the red component.
	 *
	 * @return The color in the range of {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract int getRedComponent();
	
	/**
	 * Returns the current stroke style for lines which are drawn.
	 *
	 * @return The current stroke style.
	 * @since 2017/02/10
	 */
	public abstract int getStrokeStyle();
	
	/**
	 * Returns the X coordinate of the translated coordinate system.
	 *
	 * @return The X coordinate of the translated coordinate system.
	 * @since 2017/02/10
	 */
	public abstract int getTranslateX();
	
	/**
	 * Returns the Y coordinate of the translated coordinate system.
	 *
	 * @return The Y coordinate of the translated coordinate system.
	 * @since 2017/02/10
	 */
	public abstract int getTranslateY();
	
	/**
	 * Sets the alpha value to use for drawing.
	 *
	 * @param __a The alpha value to use.
	 * @throws IllegalArgumentException If the value is not in the range of
	 * {@code [0, 255]}.
	 * @since 2017/02/10
	 */
	public abstract void setAlpha(int __a)
		throws IllegalArgumentException;
	
	/**
	 * Sets the alpha color to draw with along with the color to use.
	 *
	 * @param __argb The color in the form of {@link 0xAARRGGBB}.
	 * @since 2017/02/10
	 */
	public abstract void setAlphaColor(int __argb);
	
	/**
	 * Sets the color and alpha value to use for drawing.
	 *
	 * @param __a The alpha value.
	 * @param __r The red value.
	 * @param __g The green value.
	 * @param __b The blue value.
	 * @throws IllegalArgumentException If any component is not within the
	 * range of {@code [0, 255]}.
	 * @since 2017/02/09
	 */
	public abstract void setAlphaColor(int __a, int __r, int __g, int __b)
		throws IllegalArgumentException;
	
	/**
	 * Sets the blending mode of the drawing operations.
	 *
	 * @param __m The mode of drawing to use.
	 * @throws IllegalArgumentException If the mode is not valid.
	 * @since 2017/02/10
	 */
	public abstract void setBlendingMode(int __m)
		throws IllegalArgumentException;
	
	/**
	 * Sets the new clipping area of the destination image. The previous
	 * clipping area is replaced.
	 *
	 * @param __x The X coordinate, will be translated.
	 * @param __y The Y coordinate, will be translated.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2017/02/10
	 */
	public abstract void setClip(int __x, int __y, int __w, int __h);
	
	/**
	 * Sets the combined RGB value to use for drawing.
	 *
	 * @param __rgb The color to use, the format is {@code 0xRRGGBB}.
	 * @since 2017/02/09
	 */
	public abstract void setColor(int __rgb);
	
	/**
	 * Sets the color to use for drawing.
	 *
	 * @param __r The red value.
	 * @param __g The green value.
	 * @param __b The blue value.
	 * @throws IllegalArgumentException If any component is not within the
	 * range of {@code [0, 255]}.
	 * @since 2017/02/09
	 */
	public abstract void setColor(int __r, int __g, int __b)
		throws IllegalArgumentException;
	
	/**
	 * Sets the font to use for drawing operations.
	 *
	 * @param __a The font to use for drawing, if {@code null} then the
	 * default font is used.
	 * @since 2017/02/09
	 */
	public abstract void setFont(Font __a);
	
	/**
	 * Sets a grayscale color which has all the red, green, and blue
	 * components set as the same value.
	 *
	 * @param __v The value to use for the color.
	 * @since 2017/02/09
	 */
	public abstract void setGrayScale(int __v);
	
	/**
	 * Sets the stroke style to use for lines.
	 *
	 * @param __a The stroke style, either {@link #SOLID} or {@link #DOTTED}.
	 * @throws IllegalArgumentException If the stroke is not valid.
	 * @since 2017/02/09
	 */
	public abstract void setStrokeStyle(int __a)
		throws IllegalArgumentException;
	
	/**
	 * Translates all coordinates so that they are offset by the given
	 * values, a previous translation is translated by the given coordinates.
	 *
	 * To set the absolute position of the translation the following may be
	 * performed:
	 * {@code translate(ax - getTranslateX(), ay - getTranslateY())}.
	 *
	 * The clipping area, if set, will not be transformed.
	 *
	 * @param __x The X value to use for the new origin.
	 * @param __y The Y value to use for the new origin.
	 * @since 2017/02/09
	 */
	public abstract void translate(int __x, int __y);
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/IdleItem.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class IdleItem
	extends CustomItem
{
	protected IdleItem(String __label)
	{
		super(__label);
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void addedToDisplay(Display __d)
	{
		throw new todo.TODO();
	}
	
	@SerializedEvent
	protected void removedFromDisplay(Display __d)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Image.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521









































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import cc.squirreljme.runtime.lcdui.image.ImageReaderDispatcher;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;

public class Image
{
	/** The RGB image data. */
	private final int[] _data;
	
	/** Image width. */
	private final int _width;
	
	/** Image height. */
	private final int _height;
	
	/** Is this image mutable? */
	private final boolean _mutable;
	
	/** Does this have an alpha channel? */
	private final boolean _alpha;
	
	Image()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the image with the given settings.
	 *
	 * @parma __data The image data, this is used directly.
	 * @param __w The image width.
	 * @param __h The image height.
	 * @param __mut If this image is mutable
	 * @param __alpha If this image has an alpha channel.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	Image(int[] __data, int __w, int __h, boolean __mut, boolean __alpha)
	{
		// Check
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._data = __data;
		this._width = __w;
		this._height = __h;
		this._mutable = __mut && !isAnimated() && !isScalable();
		this._alpha = __alpha;
		
		// If no alpha, set upper channel to full opaqueness
		if (!__alpha)
			for (int i = 0, n = __data.length; i < n; i++)
				__data[i] |= 0xFF000000;
	}
	
	public final void getARGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * This obtains the graphics interface which is used to draw on top of
	 * a mutable image.
	 *
	 * It defaults to:
	 * The clipping region covers the entire image.
	 * The color is a fully opaque black.
	 * The blending mode is {@link Graphics#SRC_OVER}.
	 * The stroke is {@link Graphics#SOLID}.
	 * The font is the default font.
	 * The coordinate origin is the top-left corner.
	 *
	 * The blending mode may only be changed to {@link Graphics#SRC} if the
	 * image has an alpha channel.
	 *
	 * @return A new graphics drawer.
	 * @throws IllegalStateException If the image is not mutable.
	 * @since 2017/02/10
	 */
	public final Graphics getGraphics()
		throws IllegalStateException
	{
		// {@squirreljme.error EB28 Cannot get mutable graphic operations for
		// an immutable image.}
		if (!isMutable())
			throw new IllegalStateException("EB28");
		
		// Create
		return new AdvancedGraphics(this._data, this._alpha, null, this._width,
			this._height, this._width, 0, 0, 0);
	}
	
	/**
	 * Returns the image height.
	 *
	 * @return The height of the image.
	 * @since 2017/02/10
	 */
	public final int getHeight()
	{
		return this._height;
	}
	
	/**
	 * Copies RGB image data from the source image.
	 *
	 * The source image data must be within the bounds of the image.
	 *
	 * All written pixels will have an alpha value regardless if the image has
	 * an alpha channel or not. In the case the image has no alpha channel then
	 * all read pixels will have a value of {@code 0xFF} as their alpha
	 * channel.
	 *
	 * @param __b The destination array.
	 * @param __o The offset into the array.
	 * @param __sl The scanline length of the destination array, this value may
	 * be negative to indicate that pixels are placed in reverse order.
	 * @param __x The source X position.
	 * @param __y The source Y position.
	 * @param __w The width to copy, if this is zero nothing is copied.
	 * @param __h The height to copy, if this is zero nothing is copied.
	 * @throws ArrayIndexOutOfBoundsException If writing to the destination
	 * buffer would result in a write that exceeds the bounds of the array.
	 * @throws IllegalArgumentException If the source X or Y position is
	 * negative; If the source region exceeds the image bounds; If the absolute
	 * value of the scanline length is lower than the width.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public final void getRGB(int[] __b, int __o, int __sl, int __x, int __y,
		int __w, int __h)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Do nothing
		if (__w <= 0 || __h <= 0)
			return;
		
		// Scalable images must be rasterized
		if (isScalable())
			throw new todo.TODO();
			
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB29 The source coordinates are negative.}
		if (__x < 0 || __y < 0)
			throw new IllegalArgumentException("EB29");
	
		// {@squirreljme.error EB2a The absolute value of the scanline length
		// exceeds the read width.}
		int absl = Math.abs(__sl);
		if (absl < __w)
			throw new IllegalArgumentException("EB2a");
		
		// {@squirreljme.error EB2b Reading of RGB data would exceed the bounds
		// out the output array.}
		int srcarea = __w * __h;
		int areasl = __sl * __h;
		if (__o < 0 || (__o + areasl) > __b.length || (__o + areasl) < 0)
			throw new ArrayIndexOutOfBoundsException("EB2b");
		
		// {@squirreljme.error EB2c The area to read exceeds the bounds of the
		// image.}
		int ex = __x + __w,
			ey = __y + __h;
		int iw = this._width,
			ih = this._height;
		if (ex > iw || ey > ih)
			throw new IllegalArgumentException("EB2c");
		
		// If the alpha channel is not used then all RGB data is forced to
		// be fully opaque
		int opqmask = (this._alpha ? 0 : 0xFF_000000);
		
		// Read image data
		int[] data = this._data;
		for (int sy = __y, wy = 0; sy < ey; sy++, wy++)
		{
			// Calculate offsets
			int srcoff = (iw * sy) + __x;
			int dstoff = __o + (wy * __sl);
			
			// Copy data
			for (int sx = __x; sx < ex; sx++)
				__b[dstoff++] = data[srcoff++] | opqmask;
		}
	}
	
	public final void getRGB16(short[] __data, int __off, int __scanlen,
		int __x, int __y, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the image width.
	 *
	 * @return The width of the image.
	 * @since 2017/02/10
	 */
	public final int getWidth()
	{
		return this._width;
	}
	
	/**
	 * Returns {@code true} if this image has an alpha channel.
	 *
	 * @return {@code true} if this image has an alpha channel.
	 * @since 2017/02/10
	 */
	public final boolean hasAlpha()
	{
		return this._alpha;
	}
	
	/**
	 * Returns {@code true} if this image is animated.
	 *
	 * @return {@code true} if this image is animated.
	 * @since 2017/02/10
	 */
	public final boolean isAnimated()
	{
		return (this instanceof AnimatedImage);
	}
	
	/**
	 * Returns {@code true} if this image is mutable.
	 *
	 * @return {@code true} if this image is mutable.
	 * @since 2017/02/10
	 */
	public final boolean isMutable()
	{
		return this._mutable && !isAnimated() && !isScalable();
	}
	
	/**
	 * Returns {@code true} if this image is scalable.
	 *
	 * @return {@code true} if this image is scalable.
	 * @since 2017/02/10
	 */
	public final boolean isScalable()
	{
		return (this instanceof ScalableImage);
	}
	
	/**
	 * Loads the specified image from the specified byte array.
	 *
	 * @param __b The array to read from.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @return The loaded image.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws IllegalArgumentException If the image could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Could fail
		try
		{
			return createImage(new ByteArrayInputStream(__b, __o, __l));
		}
		
		// {@squirreljme.error EB2d Could not load the image data.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("EB2d", e);
		}
	}
	
	/**
	 * Same as {@code createImage(__w, __h, false, 0x00FFFFFF)}.
	 *
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @return The created image.
	 * @throws IllegalArgumentException If the requested image size has a zero
	 * or negative dimension.
	 * @since 2017/02/11
	 */
	public static Image createImage(int __w, int __h)
		throws IllegalArgumentException
	{
		return createImage(__w, __h, false, 0x00FFFFFF);
	}
	
	/**
	 * Creates a mutable image that may or may not have an alpha channel.
	 *
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @param __alpha Whether it has an alpha channel.
	 * @param __c The initial color to fill.
	 * @return The created image.
	 * @throws IllegalArgumentException If the requested image size has a zero
	 * or negative dimension.
	 * @since 2017/02/11
	 */
	public static Image createImage(int __w, int __h, boolean __alpha, int __c)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2e Zero or negative image size requested.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("EB2e");
		
		// Setup buffer
		int area = __w * __h;
		int[] data = new int[area];
		
		// Fill with color
		for (int i = 0; i < area; i++)
			data[i] = __c;
		
		// Create
		return new Image(data, __w, __h, true, __alpha);
	}
	
	/**
	 * Loads the image from the specified input stream.
	 *
	 * @param __is The stream to read image data from.
	 * @throws IOException If the image could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(InputStream __is)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// If marking is supported, directly use the stream
		if (__is.markSupported())
			return ImageReaderDispatcher.parse(__is);
		
		// Load the entire image data into a buffer so that we can mark it
		byte[] copy;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			Math.max(__is.available(), 4096)))
		{
			// Copy the image data
			byte[] buf = new byte[512];
			for (;;)
			{
				int rc = __is.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Use copied data
			copy = baos.toByteArray();
		}
		
		// Parse the data now that it can be marked
		return ImageReaderDispatcher.parse(new ByteArrayInputStream(copy));
	}
	
	/**
	 * This loads the specified resource as an image.
	 *
	 * @param __s The string to load the resource for.
	 * @throws IOException If the resource does not exist or the image data
	 * could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public static Image createImage(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Try loading it
		try (InputStream is = ActiveMidlet.get().getClass().
			getResourceAsStream(__s))
		{
			// {@squirreljme.error EB2f The specified resource does not
			// exist. (The resource name)}
			if (is == null)
				throw new IOException(String.format("EB2f %s", __s));
			
			return createImage(is);
		}
	}
	
	/**
	 * Creates an immutable image which is an exact copy of the other image. If
	 * the other image is scalable it will be rasterized with whatever
	 * dimensions the other image has. If the specified image is immutable then
	 * it will be returned.
	 *
	 * @param __i The image to copy.
	 * @return The resulting copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/24
	 */
	public static Image createImage(Image __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		// Needs to be rendered
		if (__i instanceof ScalableImage)
			throw new todo.TODO();
		
		// Same otherwise
		else if (!__i._mutable)
			return __i;
		
		// Copy and make this immutable
		return new Image(__i._data.clone(), __i._width, __i._height,
			false, __i._alpha);
	}
	
	public static Image createImage(Image __i, int __x, int __y,
		int __w, int __h, int __trans)
	{
		return Image.createImage(__i, __x, __y, __w, __h, __trans);
	}
	
	public static Image createImage(Image __i, int __x, int __y, int __w,
		int __h, int __trans, int __iw, int __ih)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Creates an image from the specified ARGB pixel array.
	 *
	 * @param __rgb The ARGB or RGB image data to use as the image data.
	 * @param __w The width of the image.
	 * @param __h The height of the image.
	 * @param __alpha If {@code true} then the alpha is processed, otherwise
	 * all pixels are treated as fully opaque.
	 * @since 2017/02/10
	 */
	public static Image createRGBImage(int[] __rgb, int __w, int __h, boolean 
		__alpha)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__rgb == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB2g Invalid image size. (The width;
		// The height)}
		int area = __w * __h;
		if (__w <= 0 || __h <= 0 || area <= 0)
			throw new IllegalArgumentException(String.format("EB2g %d %d",
				__w, __h));
		
		// {@squirreljme.error EB2h The input integer buffer is shorter than
		// the specified area.}
		int rgblen;
		if ((rgblen = __rgb.length) < area)
			throw new IndexOutOfBoundsException("EB2h");
		
		// Use a cloned copy of the pixel data?
		if (rgblen == area)
			__rgb = __rgb.clone();
		
		// Otherwise initialize a new one
		else
		{
			int[] copy = new int[area];
			for (int i = 0; i < area; i++)
				copy[i] = __rgb[i];
			__rgb = copy;
		}
		
		// If there is no alpha channel, force all of it opaque
		if (!__alpha)
			for (int i = 0; i < area; i++)
				__rgb[i] |= 0xFF000000;
		
		// Setup image
		return new Image(__rgb, __w, __h, false, __alpha);
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ImageItem.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class ImageItem
	extends Item
{
	public static final int LAYOUT_CENTER =
		3;
	
	public static final int LAYOUT_DEFAULT =
		0;
	
	public static final int LAYOUT_LEFT =
		1;
	
	public static final int LAYOUT_NEWLINE_AFTER =
		512;
	
	public static final int LAYOUT_NEWLINE_BEFORE =
		256;
	
	public static final int LAYOUT_RIGHT =
		2;
	
	/** Apperance mode. */
	final int _amode;
	
	/** Cache of the used image. */
	private volatile Image _image;
	
	/** Alternative text. */
	private volatile String _alt;
	
	/**
	 * Initializes the image item.
	 *
	 * @param __l The label.
	 * @param __i The image.
	 * @param __lay The layout.
	 * @param __alt The alternative text.
	 * @throws IllegalArgumentException If the layout is not valid.
	 * @since 2019/05/17
	 */
	public ImageItem(String __l, Image __i, int __lay, String __alt)
		throws IllegalArgumentException
	{
		this(__l, __i, __lay, __alt, PLAIN);
	}
	
	/**
	 * Initializes the image item.
	 *
	 * @param __l The label.
	 * @param __i The image.
	 * @param __lay The layout.
	 * @param __alt The alternative text.
	 * @param __am The appearance mode.
	 * @throws IllegalArgumentException If the layout is not valid.
	 * @since 2019/05/17
	 */
	public ImageItem(String __l, Image __i, int __lay, String __alt, int __am)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB2i The appearance mode is not valid.
		// (The appearance mode)}
		if (__am != PLAIN && __am != BUTTON && __am != HYPERLINK)
			throw new IllegalArgumentException("EB2i " + __am);
		
		this._image = __i;
		this._alt = __alt;
		this._amode = __am;
		
		// Set the layout
		this.setLayout(__lay);
	}
	
	public String getAltText()
	{
		throw new todo.TODO();
	}
	
	public int getAppearanceMode()
	{
		throw new todo.TODO();
	}
	
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	public void setAltText(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this item. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code imageitem.setImage(imageitem.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	public void setLayout(int __lay)
		throws IllegalArgumentException
	{
		super.setLayout(__lay);
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Item.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281

























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

public abstract class Item
{
	public static final int BUTTON =
		2;
	
	public static final int HYPERLINK =
		1;
	
	public static final int LAYOUT_2 =
		16384;
	
	public static final int LAYOUT_BOTTOM =
		32;
	
	public static final int LAYOUT_CENTER =
		3;
	
	public static final int LAYOUT_DEFAULT =
		0;
	
	public static final int LAYOUT_EXPAND =
		2048;
	
	public static final int LAYOUT_LEFT =
		1;
	
	public static final int LAYOUT_NEWLINE_AFTER =
		512;
	
	public static final int LAYOUT_NEWLINE_BEFORE =
		256;
	
	public static final int LAYOUT_RIGHT =
		2;
	
	public static final int LAYOUT_SHRINK =
		1024;
	
	public static final int LAYOUT_TOP =
		16;
	
	public static final int LAYOUT_VCENTER =
		48;
	
	public static final int LAYOUT_VEXPAND =
		8192;
	
	public static final int LAYOUT_VSHRINK =
		4096;
	
	public static final int PLAIN =
		0;
	
	/** The owning displayable. */
	volatile Displayable _displayable;
	
	/** The current layout of the item. */
	volatile int _layout =
		LAYOUT_DEFAULT;
	
	/** The label of this item. */
	volatile String _label;
	
	/** The preferred width. */
	volatile int _preferredw =
		-1;
	
	/** The preferred height. */
	volatile int _preferredh =
		-1;
	
	/**
	 * Initializes the base item.
	 *
	 * @since 2017/08/19
	 */
	Item()
	{
	}
	
	/**
	 * Initializes the base item with some parameters.
	 *
	 * @param __l The label to use.
	 * @since 2019/05/17
	 */
	Item(String __l)
	{
		this._label = __l;
	}
	
	public void addCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public Command[] getCommands()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label of the item.
	 *
	 * @return The label item.
	 * @since 2019/12/09
	 */
	public String getLabel()
	{
		return this._label;
	}
	
	public int getLayout()
	{
		throw new todo.TODO();
	}
	
	public ItemLayoutHint getLayoutHint()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the minimum height of the item.
	 *
	 * @return The minimum height.
	 * @since 2019/12/09
	 */
	public int getMinimumHeight()
	{
		// {@squirreljme.error EB37 Minimum height must be implemented.
		// (The class name)}
		throw new RuntimeException("EB37 " + this.getClass().getName());
	}
	
	/**
	 * Returns the minimum width of the item.
	 *
	 * @return The minimum width.
	 * @since 2019/12/09
	 */
	public int getMinimumWidth()
	{
		// {@squirreljme.error EB38 Minimum width must be implemented.
		// (The class name)}
		throw new RuntimeException("EB38 " + this.getClass().getName());
	}
	
	/**
	 * Returns the preferred height of the item, this may be calculated.
	 *
	 * @return The preferred item height.
	 * @since 2019/12/09
	 */
	public int getPreferredHeight()
	{
		int rv = this._preferredh,
			mn = this.getMinimumHeight();
		return (mn > rv ? mn : rv);
	}
	
	/**
	 * Returns the preferred width of the item, this may be calculated.
	 *
	 * @return The preferred item width.
	 * @since 2019/12/09
	 */
	public int getPreferredWidth()
	{
		int rv = this._preferredw,
			mn = this.getMinimumWidth();
		return (mn > rv ? mn : rv);
	}
	
	public void notifyStateChanged()
	{
		throw new todo.TODO();
	}
	
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setCommand(Command __c, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setDefaultCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setItemCommandListener(ItemCommandListener __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the label of the item.
	 *
	 * @param __l The label of the item to set, may be {@code null} to clear
	 * the label.
	 * @since 2017/08/20
	 */
	public void setLabel(String __l)
	{
		this._label = __l;
		
		// Repaint the display
		Displayable displayable = this._displayable;
		if (displayable != null)
		{
			Display display = displayable._display;
			if (display != null)
				UIState.getInstance().repaint();
		}
	}
	
	/**
	 * Sets the layout.
	 *
	 * @param __lay The layout.
	 * @since 2019/05/17
	 */
	public void setLayout(int __lay)
	{
		this._layout = __lay;
	}
	
	public void setLayoutHint(ItemLayoutHint __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the preferred size of the item. This sets the size of an item where
	 * if it is higher than the minimum then it is used, otherwise the minimum
	 * is used.
	 *
	 * @param __w The width, or {@code -1} to use the minimum.
	 * @param __h The height, or {@code -1} to use the minimum.
	 * @throws IllegalArgumentException If the width and/or height are lower
	 * than {@code -1}.
	 * @throws IllegalStateException If this item is within an alert.
	 * @since 2019/12/09
	 */
	public void setPreferredSize(int __w, int __h)
		throws IllegalArgumentException, IllegalStateException
	{
		// {@squirreljme.error EB35 Invalid preferred size requested.}
		if (__w < -1 || __h < -1)
			throw new IllegalArgumentException("EB35");
		
		// {@squirreljme.error EB36 Cannot set preferred size of item within
		// an alert.}
		if (this._displayable instanceof Alert)
			throw new IllegalStateException("EB36");
		
		this._preferredw = __w;
		this._preferredh = __h;
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ItemCommandListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemCommandListener
{
	@SerializedEvent
	public abstract void commandAction(Command __a, Item __b);
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ItemLayoutHint.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface ItemLayoutHint
{
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ItemStateListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemStateListener
{
	@SerializedEvent
	public abstract void itemStateChanged(Item __a);
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ItemTraversalListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public interface ItemTraversalListener
{
	@SerializedEvent
	public abstract void itemTraversedIn(Item __i);
	
	@SerializedEvent
	public abstract void itemTraversedOut(Item __i);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/KeyListener.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This is the key listener interface which is used for a slightly more
 * advanced means of listening for and responding to key events.
 *
 * Unlike {@link Canvas} and {@link CustomItem}, the key code that is passed
 * to these methods will be modified by the key modifiers (this means that
 * if shift is held down then letters will be uppercase).
 *
 * @since 2017/02/12
 */
public interface KeyListener
{
	/** The chr alt modifier. */
	public static final int MODIFIER_ALT =
		65536;

	/** The chr key modifier. */
	public static final int MODIFIER_CHR =
		8388608;

	/** The command key modifier. */
	public static final int MODIFIER_COMMAND =
		4194304;

	/** The ctrl key modifier. */
	public static final int MODIFIER_CTRL =
		262144;

	/** The mask for modifiers. */
	public static final int MODIFIER_MASK =
		13041664;

	/** The shift key modifier. */
	public static final int MODIFIER_SHIFT =
		131072;
	
	/**
	 * Called when a key is pressed.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @sicne 2017/02/12
	 */
	public abstract void keyPressed(int __kc, int __km);
	
	/**
	 * Called when a key is released.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @sicne 2017/02/12
	 */
	public abstract void keyReleased(int __kc, int __km);
	
	/**
	 * Called when a key is repeated.
	 *
	 * @param __kc The key code.
	 * @param __km The modifiers to the key.
	 * @sicne 2017/02/12
	 */
	public abstract void keyRepeated(int __kc, int __km);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/List.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387



































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.common.CommonMetrics;
import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class List
	extends Screen
	implements Choice
{
	/** The default select command used for lists. */
	public static final Command SELECT_COMMAND =
		new Command("Select", Command.SCREEN, 0, true);
	
	/** Items on the list. */
	final __VolatileList__<__ChoiceEntry__> _items =
		new __VolatileList__<>();
	
	/** The type of list this is. */
	private final int _type;
	
	/** The focal index. */
	volatile int _focalindex;
	
	/** Selection command. */
	volatile Command _selcommand =
		List.SELECT_COMMAND;
	
	/**
	 * Initializes the list.
	 *
	 * @param __title The list title.
	 * @param __type The type of list this is.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @since 2018/11/16
	 */
	public List(String __title, int __type)
		throws IllegalArgumentException
	{
		this(__title, __type, new String[0], new Image[0]);
	}
	
	/**
	 * Initializes the list.
	 *
	 * @param __title The list title.
	 * @param __type The type of list this is.
	 * @param __strs The initial string elements to add.
	 * @param __imgs The initial image elements to add.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @throws NullPointerException If the string elements is null or contains
	 * a null element.
	 * @since 2018/11/16
	 */
	public List(String __title, int __type, String[] __strs, Image[] __imgs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__strs == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EB2j String and image elements differ in
		// size.}
		if (__imgs != null && __strs.length != __imgs.length)
			throw new IllegalArgumentException("EB2j");
		
		// {@squirreljme.error EB2k Invalid list type. (The list type)}
		if (__type != Choice.IMPLICIT && __type != Choice.EXCLUSIVE &&
			__type != Choice.MULTIPLE)
			throw new IllegalArgumentException("EB2k " + __type);
		
		// Set
		this._title = __title;
		this._type = __type;
		
		// Append all of the items to the list
		for (int i = 0, n = __strs.length; i < n; i++)
			this.append(__strs[i], (__imgs == null ? null : __imgs[i]));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	public int append(String __s, Image __i)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Append item
		__ChoiceEntry__ e;
		__VolatileList__<__ChoiceEntry__> items = this._items;
		int rv = items.append((e = new __ChoiceEntry__(__s, __i)));
		
		// If this is the only item and this is an exclusive list, select it
		int ltype = this._type;
		if (items.size() == 1 && (ltype == Choice.EXCLUSIVE ||
			ltype == Choice.IMPLICIT))
			e._selected = true;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
		
		return rv;
	}
	
	public void delete(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Deletes all of the items in the list.
	 *
	 * @since 2018/11/17
	 */
	public void deleteAll()
	{
		this._items.clear();
	}
	
	public int getFitPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Gets the font for the given index.
	 *
	 * @param __i The index to get.
	 * @return The font of the index.
	 * @throws IndexOutOfBoundsException On null arguments.
	 * @since 2019/05/18
	 */
	public Font getFont(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._font;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		return Displayable.__getHeight(this, false);
	}
	
	/**
	 * Returns the image of the given index.
	 *
	 * @param __i The index to get.
	 * @return The image for this index.
	 * @throws IndexOutOfBoundsException If the index is not valid.
	 * @since 2019/05/18
	 */
	public Image getImage(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._image;
	}
	
	/**
	 * Returns the command to use when an item is selected.
	 *
	 * @return The select command.
	 * @since 2019/05/18
	 */
	@ImplementationNote("This is a SquirrelJME specific method.")
	public Command getSelectCommand()
	{
		return this._selcommand;
	}
	
	public int getSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public int getSelectedIndex()
	{
		// Multiple choice is always invalid
		if (this._type == Choice.MULTIPLE)
			return -1;
		
		// Find the first entry!
		int at = 0;
		for (__ChoiceEntry__ e : this._items)
		{
			if (e._selected)
				return at;
			at++;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the string at the given index.
	 *
	 * @param __i The string to get.
	 * @return The string.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2019/05/18
	 */
	public String getString(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._string;
	}
	
	/**
	 * Returns the list type.
	 *
	 * @return The list type.
	 * @since 2019/05/18
	 */
	@ImplementationNote("This is a SquirrelJME specific method.")
	public int getType()
	{
		return this._type;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		return Displayable.__getWidth(this, false);
	}
	
	public void insert(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	public boolean isEnabled(int __i)
		throws IndexOutOfBoundsException
	{
		return !this._items.get(__i)._disabled;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/18
	 */
	@Override
	public boolean isSelected(int __i)
		throws IndexOutOfBoundsException
	{
		return this._items.get(__i)._selected;
	}
	
	@Override
	public void removeCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void set(int __a, String __b, Image __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/09
	 */
	@Override
	public void setEnabled(int __i, boolean __e)
		throws IndexOutOfBoundsException
	{
		this._items.get(__i)._disabled = !__e;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void setFitPolicy(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font of the given item.
	 *
	 * @param __i The item to set.
	 * @param __f The font to use, {@code null} clears it and uses the default.
	 * @throws IndexOutOfBoundsException If the item is not within bounds.
	 * @since 2019/05/20
	 */
	public void setFont(int __i, Font __f)
		throws IndexOutOfBoundsException
	{
		this._items.get(__i)._font = __f;
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	public void setSelectCommand(Command __a)
	{
		throw new todo.TODO();
	}
	
	public void setSelectedFlags(boolean[] __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/09
	 */
	@Override
	public void setSelectedIndex(int __i, boolean __e)
		throws IndexOutOfBoundsException
	{
		// Check bounds
		__VolatileList__<__ChoiceEntry__> items = this._items;
		int n = items.size();
		if (__i < 0 || __i >= n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If deselecting or using this on multiple lists, just direct set
		if (!__e || this._type == MULTIPLE)
			items.get(__i)._selected = __e;
		
		// Otherwise only select the item that matches the index
		else
		{
			for (int i = 0; i < n; i++)
				this._items.get(i)._selected = (__i == i);
		}
		
		// Update display
		Display d = this._display;
		if (d != null)
			UIState.getInstance().repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public int size()
	{
		return this._items.size();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Menu.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227



































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Menu
	extends __Action__
{
	/** The image used. */
	private volatile Image _image;
	
	public Menu(String __short, String __long, Image __i)
	{
		throw new todo.TODO();
	}
	
	public int append(Command __c)
	{
		throw new todo.TODO();
	}
	
	public int append(Menu __m)
	{
		throw new todo.TODO();
	}
	
	public Command getCommand(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font that is used as a hint for rendering the text in
	 * a menu, it may be disregarded by the implementation.
	 *
	 * @return The font that should be used as a hint.
	 * @since 2018/04/01
	 */
	public Font getFont()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the image the menu.
	 *
	 * @return The image of the command or {@code null} if it has none.
	 * @since 2018/04/01
	 */
	public Image getImage()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the label used for this menu.
	 *
	 * @return The label used for the menu.
	 * @since 2018/04/01
	 */
	public String getLabel()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the long label of the menu.
	 *
	 * @return The long label of the menu or {@code null} if it has none.
	 * @since 2018/04/01
	 */
	public String getLongLabel()
	{
		throw new todo.TODO();
	}
	
	public Menu getMenu(int __i)
	{
		throw new todo.TODO();
	}
	
	public int getMenuDepth()
	{
		throw new todo.TODO();
	}
	
	public void insert(int __i, Command __c)
	{
		throw new todo.TODO();
	}
	
	public void insert(int __i, Menu __m)
	{
		throw new todo.TODO();
	}
	
	public boolean isCommand(int __i)
	{
		throw new todo.TODO();
	}
	
	public boolean isEnabled()
	{
		throw new todo.TODO();
	}
	
	public boolean isVisible()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e The new state of the parent.
	 * @since 2018/04/01
	 */
	@Override
	public void onParentEnabled(boolean __e)
	{
		// The default implementation does nothing
	}
	
	public void remove(Command __c)
	{
		throw new todo.TODO();
	}
	
	public void remove(Menu __m)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets whether this menu is enabled or disabled.
	 *
	 * @param __e If the menu is enabled or not.
	 * @since 2018/04/01
	 */
	public void setEnabled(boolean __e)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the font used to be used as a hint when rendering the menu.
	 *
	 * @param __f The font to use as a hint when rendering the menu,
	 * {@code null} will use the default.
	 * @since 2018/04/01
	 */
	public void setFont(Font __f)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this menu. If the image is mutable
	 * then this will take a snapshot of the image and use that snapshot
	 * instead of the normal image.
	 *
	 * A new snapshot from a mutable image can be created by performing:
	 * {@code menu.setImage(menu.getImage())}.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	/**
	 * Sets the label to be displayed.
	 *
	 * @param __s The label to display.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/01
	 */
	public void setLabel(String __s)
	{
		throw new todo.TODO();
		/*
		this.__setLabels(__s, this._longlabel, this._image);
		*/
	}
	
	/**
	 * Sets the long label of the menu.
	 *
	 * @param __s The long label to use, {@code null} clears it.
	 * @since 2018/04/01
	 */
	public void setLongLabel(String __s)
	{
		throw new todo.TODO();
		/*
		this.__setLabels(this._shortlabel, __s, this._image);
		*/
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
	
	public static int getMaxMenuDepth()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Notification.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class Notification
{
	/** Cache of the used label. */
	private volatile String _label;
	
	/** Cache of the used image. */
	private volatile Image _image;
	
	public Notification(NotificationType __t)
	{
		throw new todo.TODO();
	}
	
	public Notification(NotificationType __t, String __l)
	{
		throw new todo.TODO();
	}
	
	public Notification(NotificationType __t, String __l, Image __i)
	{
		throw new todo.TODO();
	}
	
	public long getTimeStamp()
	{
		throw new todo.TODO();
	}
	
	public NotificationType getType()
	{
		throw new todo.TODO();
	}
	
	public void post(boolean __s)
	{
		todo.TODO.note("Update mutable image on post.");
		throw new todo.TODO();
	}
	
	public void post(boolean __s, int __dur)
	{
		todo.TODO.note("Update mutable image on post.");
		throw new todo.TODO();
	}
	
	public void remove()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the image to be displayed for this notification. If the image is
	 * mutable then this will take a snapshot of the image and use that
	 * snapshot instead of the normal image.
	 *
	 * A new snapshot is always taken when the post command is called.
	 *
	 * @param __i The image to set or {@code null} to clear it.
	 * @since 2018/04/06
	 */
	public void setImage(Image __i)
	{
		throw new todo.TODO();
		/*
		Image clone = (__i != null && __i.isMutable() ?
			Image.createImage(__i) : __i);
		LcdServiceCall.voidCall(LcdFunction.SET_IMAGE, this._handle,
			(__i == null ? -1 : __i._handle),
			(clone == null ? -1 : clone._handle));
		this._image = __i;
		*/
	}
	
	public void setLabel(String __l)
	{
		throw new todo.TODO();
	}
	
	public void setListener(NotificationListener __nl)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/NotificationException.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class NotificationException
	extends RuntimeException
{
	public NotificationException()
	{
		super();
	}
	
	public NotificationException(String __s)
	{
		super(__s);
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/NotificationListener.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface NotificationListener
{
	public abstract void notificationDismissed(Notification __n);
	
	public abstract void notificationSelected(Notification __n);
	
	public abstract void notificationTimeout(Notification __n);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/NotificationType.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public final class NotificationType
{
	public static final NotificationType CALL =
		new NotificationType(null, null);
	
	public static final NotificationType EMAIL =
		new NotificationType(null, null);
	
	public static final NotificationType IM =
		new NotificationType(null, null);
	
	public static final NotificationType MMS =
		new NotificationType(null, null);
	
	public static final NotificationType REMINDER =
		new NotificationType(null, null);
	
	public static final NotificationType SMS =
		new NotificationType(null, null);
	
	public NotificationType(String __dl, Image __di)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/ScalableImage.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public class ScalableImage
	extends Image
{
	ScalableImage()
	{
		throw new todo.TODO();
	}
	
	public final int getViewportHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getViewportWidth()
	{
		throw new todo.TODO();
	}
	
	public final void setHeight(int __h, boolean __mar)
	{
		throw new todo.TODO();
	}
	
	public final void setWidth(int __w, boolean __mar)
	{
		throw new todo.TODO();
	}
	
	public final void unbind()
	{
		throw new todo.TODO();
	}
	
	public static ScalableImage bind(Object __esi)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Screen.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

/**
 * This is the base class for all user interactable displays.
 *
 * It is only recommended to change the screen contents when it is not being
 * displayed.
 *
 * @since 2017/02/28
 */
public abstract class Screen
	extends Displayable
{
	/**
	 * Initializes the base screen.
	 *
	 * @since 2017/02/28
	 */
	Screen()
	{
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Spacer.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class Spacer
	extends Item
{
	public Spacer(int __a, int __b)
	{
		super();
		throw new todo.TODO();
	}
	
	/**
	 * Commands are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void addCommand(Command __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2l Cannot add commands for spacers.}
		throw new IllegalStateException("EB2l");
	}
	
	/**
	 * Commands are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void setDefaultCommand(Command __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2m Cannot set the default command for
		// spacers.}
		throw new IllegalStateException("EB2m");
	}
	
	/**
	 * Labels are not supported for this item.
	 *
	 * @param __a Ignored.
	 * @throws IllegalStateException Always.
	 * @since 2018/04/06
	 */
	@Override
	public void setLabel(String __a)
		throws IllegalStateException
	{
		// {@squirreljme.error EB2n Cannot set labels for spacers.}
		throw new IllegalStateException("EB2n");
	}
	
	public void setMinimumSize(int __a, int __b)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/StringItem.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
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



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.phoneui.StandardMetrics;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class StringItem
	extends Item
{
	/** Apperance mode. */
	final int _amode;
	
	/** The item text. */
	volatile String _text;
	
	/** The font to use. */
	volatile Font _font;
	
	/**
	 * Initializes the string item with the plain style.
	 *
	 * @param __l The label.
	 * @param __t The text.
	 * @since 2019/05/17
	 */
	public StringItem(String __l, String __t)
	{
		this(__l, __t, PLAIN);
	}
	
	/**
	 * Initializes the string item with the plain style.
	 *
	 * @param __l The label.
	 * @param __t The text.
	 * @throws IllegalArgumentException If the appearance mode is not valid.
	 * @since 2019/05/17
	 */
	public StringItem(String __l, String __t, int __am)
		throws IllegalArgumentException
	{
		super(__l);
		
		// {@squirreljme.error EB2o The appearance mode is not valid.
		// (The appearance mode)}
		if (__am != PLAIN && __am != BUTTON && __am != HYPERLINK)
			throw new IllegalArgumentException("EB2o " + __am);
		
		this._text = __t;
		this._amode = __am;
	}
	
	public int getAppearanceMode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the font used to draw the item.
	 *
	 * @return The font used to draw the item.
	 * @since 2019/12/09
	 */
	public Font getFont()
	{
		Font rv = this._font;
		return (rv == null ? StandardMetrics.itemLabelFont() : rv);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/09
	 */
	@Override
	public int getMinimumHeight()
	{
		// Empty string needs no space
		String text = this.getText();
		if (text == null)
			return 0;
		
		return this.getFont().getHeight();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/09
	 */
	@Override
	public int getMinimumWidth()
	{
		// Empty string needs no space
		String text = this.getText();
		if (text == null)
			return 0;
		
		return this.getFont().stringWidth(text);
	}
	
	/**
	 * Returns the text content of this item.
	 *
	 * @return The text content.
	 * @since 2019/12/09
	 */
	public String getText()
	{
		return this._text;
	}
	
	public void setFont(Font __a)
	{
		throw new todo.TODO();
	}
	
	public void setText(String __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TabListener.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;

/**
 * This interface is used as a callback when there has been a change to the
 * tabbed pane such as which screen has been made visible or ones which were
 * added or removed.
 *
 * @since 2018/03/29
 */
public interface TabListener
{
	/**
	 * This is called to specify that the given tab along with the screen
	 * has been added to the tabbed pane.
	 *
	 * @param __i The index where insertion is to occur.
	 * @param __tab The screen that was added to the tabbed pane.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	public abstract void tabAddedEvent(int __i, Screen __tab);
	
	/**
	 * This indicates when a new tab has been focused and will indicate the
	 * screen which now has focus.
	 *
	 * @param __tab The tab which now has focus.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	public abstract void tabChangeEvent(Screen __tab);
	
	/**
	 * This is called after a tab has been removed and only specifies the
	 * index of that tab.
	 *
	 * @param __i The tab that has been removed.
	 * @since 2018/03/29
	 */
	@SerializedEvent
	public abstract void tabRemoveEvent(int __i);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TabbedPane.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
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






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.ArrayList;
import java.util.List;

public class TabbedPane
	extends Screen
{
	public TabbedPane(String __title, boolean __stringtab, boolean __suptitle)
	{
		throw new todo.TODO();
	}
	
	public void addTab(Screen __t, Image __i)
	{
		throw new todo.TODO();
	}
	
	public void addTabListener(TabListener __tl)
	{
		throw new todo.TODO();
	}
	
	public int getCount()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
	}
	
	public Screen getScreen(int __i)
	{
		throw new todo.TODO();
	}
	
	public int getSelectedIndex()
	{
		throw new todo.TODO();
	}
	
	public Image getTabIcon(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
	}
	
	public void insertTab(int __i, Screen __t, Image __img)
	{
		throw new todo.TODO();
	}
	
	public void removeTab(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setFocus(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setTabIcon(int __i, Image __icon)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TableLayoutPolicy.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public final class TableLayoutPolicy
	extends FormLayoutPolicy
{
	public TableLayoutPolicy(Form __f, int __cols)
	{
		super(__f);
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/07
	 */
	@Override
	protected void doLayout(int __vpx, int __vpy, int __vpw,
		int __vph, int[] __ts)
	{
		throw new todo.TODO();
	}
	
	public int getColumns()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/07
	 */
	@Override
	protected Item getTraverse(Item __i, int __dir)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Text.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.common.TextStorage;
import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import java.util.Arrays;

/**
 * This text class is one which handles all of the text metrics and drawing and
 * such. It handles different fonts, colors, and styles on a per character
 * basis and performs all the needed operations to support text drawing.
 *
 * The color defaults to {@code Display.getColor(Display.COLOR_FOREGROUND)}.
 *
 * @since 2018/11/29
 */
public class Text
{
	public static final int ALIGN_CENTER =
		1;
	
	public static final int ALIGN_DEFAULT =
		4;
	
	public static final int ALIGN_JUSTIFY =
		3;
	
	public static final int ALIGN_LEFT =
		0;
	
	public static final int ALIGN_RIGHT =
		2;
	
	public static final int DIRECTION_LTR =
		10;
	
	public static final int DIRECTION_NEUTRAL =
		12;
	
	public static final int DIRECTION_RTL =
		11;
	
	/** Storage for the text. */
	private final TextStorage _storage =
		new TextStorage();
	
	/** The width. */
	private int _width;
	
	/** The height. */
	private int _height;
	
	/** The default font. */
	private Font _defaultfont =
		Font.getDefaultFont();
	
	/** The default foreground color. */
	private int _defaultcolor =
		CommonColors.DEFAULT_TEXT_COLOR;
	
	/** The background color. */
	private int _backgroundcolor =
		CommonColors.DEFAULT_TEXT_BACKGROUND_COLOR;
	
	/** The alignment. */
	private int _alignment;
	
	/** The caret position. */
	private int _caret =
		-1;
	
	/** The required display height, is cached. */
	private int _requiredheight;
	
	/** The required line count, is cached. */
	private int _requiredlines;
	
	/** Space above each line. */
	private int _spaceabove;
	
	/** Space below each line. */
	private int _spacebelow;
	
	/** The alignment of each line. */
	private int _align;
	
	/** Indentation. */
	private int _indentation;
	
	/** The direction of the text. */
	private int _direction =
		DIRECTION_NEUTRAL;
	
	/** Scrolling offset (scrolled up by n pixels). */
	private int _scrolloffset;
	
	/** The highlight index. */
	private int _highlightdx =
		-1;
	
	/** The highlight length. */
	private int _highlightlen =
		0;
	
	/** Does character placement have to be updated. */
	private boolean _dirty;
	
	/**
	 * Initializes the text with no width or height.
	 *
	 * @since 2018/11/29
	 */
	public Text()
	{
		this("", 0, 0);
	}
	
	/**
	 * Initializes the text with the given width and height.
	 *
	 * @param __c The text to use.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalArgumentException If the width or height are negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public Text(String __c, int __w, int __h)
		throws IllegalArgumentException, NullPointerException
	{
		this(__c, 0, __c.length(), __w, __h);
	}
	
	/**
	 * Initializes the text with the given width and height.
	 *
	 * @param __c The text to use.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalArgumentException If the width or height are negative.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public Text(String __c, int __o, int __l, int __w, int __h)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length())
			throw new IndexOutOfBoundsException("IOOB");
		
		// {@squirreljme.error EB2p The width and height cannot be negative
		// for text.}
		if (__w < 0 || __h < 0)
			throw new IllegalArgumentException("EB2p");
		
		// Set sizes first
		this._width = __w;
		this._height = __h;
		
		// Insert all of the text
		this.insert(0, __c.substring(__o, __o + __l));
	}
	
	/**
	 * Deletes the specified text.
	 *
	 * @param __i The index to start deletion at.
	 * @param __l The number of characters to delete.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/02
	 */
	public void delete(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Perform the delete
		this._storage.delete(__i, __l);
		
		// Deleting nothing?
		if (__l <= 0)
			return;
		
		// Mark dirty
		this._dirty = true;
		
		// Adjust the caret?
		int caret = this._caret;
		if (caret > __i)
			this._caret = caret - Math.max(__l - (caret - __i), __l);
	}
	
	/**
	 * Returns the alignment of the text.
	 *
	 * @return The text alignment.
	 * @since 2018/12/02
	 */
	public int getAlignment()
	{
		return this._alignment;
	}
	
	/**
	 * Returns the background color.
	 *
	 * @return The background color.
	 * @since 2018/12/02
	 */
	public int getBackgroundColor()
	{
		return this._backgroundcolor;
	}
	
	/**
	 * Returns the caret position.
	 *
	 * @return The caret position or {@code -1} if it is not used.
	 * @since 2018/12/02
	 */
	public int getCaret()
	{
		return this._caret;
	}
	
	/**
	 * Returns the extents of the given character.
	 *
	 * @param __i The character to get.
	 * @param __ext The extents of the character: x, y, width, height.
	 * @throws IllegalArgumentException If the extend array has a length less
	 * than four.
	 * @throws IndexOutOfBoundsException If the character index is out of
	 * bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/01
	 */
	public void getCharExtent(int __i, int[] __ext)
		throws IllegalArgumentException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__ext == null)
			throw new NullPointerException("NARG");
			
		// Update
		if (this._dirty)
			this.__undirty();
		
		// Need to extract the character and font to determine the width and
		// the height of it
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Default font?
		Font font = storage.font[__i];
		if (font == null)
			font = this._defaultfont;
		
		// Set extents, the width and height come from the character data
		try
		{
			__ext[0] = storage.x[__i];
			__ext[1] = storage.y[__i];
			__ext[2] = font.charWidth(storage.chars[__i]);
			__ext[3] = font.getHeight();
		}
		catch (IndexOutOfBoundsException e)
		{
			// {@squirreljme.error EB2q Extent array length must at least
			// be 4.}
			if (__ext.length < 4)
				throw new IllegalArgumentException("EB2q");
		}
	}
	
	public int getCharIndex(int __x, int __y)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the default font.
	 *
	 * @return The default font.
	 * @since 2018/12/01
	 */
	public Font getFont()
	{
		return this._defaultfont;
	}
	
	/**
	 * Returns the font which is used by the given character.
	 *
	 * @param __i The index of the character to get.
	 * @return The font for the given index.
	 * @throws IndexOutOfBoundsException If the index it outside of bounds.
	 * @since 2018/12/01
	 */
	public Font getFont(int __i)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Only if a font is set
		Font rv = storage.font[__i];
		if (rv != null)
			return rv;
		return this._defaultfont;
	}
	
	/**
	 * Returns the default foreground color.
	 *
	 * @return The default foreground color.
	 * @since 2018/12/02
	 */
	public int getForegroundColor()
	{
		return this._defaultcolor;
	}
	
	/**
	 * Gets the foreground color for a character.
	 *
	 * @param __i The character to get.
	 * @return The color for that character.
	 * @since 2018/12/01
	 */
	public int getForegroundColor(int __i)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		if (__i >= storage.size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Zero means that the default color is to be used
		int rv = storage.color[__i];
		if (rv != 0)
			return rv;
		return this._defaultcolor;
	}
	
	/**
	 * Returns the height of the text.
	 *
	 * @return The height of the text.
	 * @since 2018/12/01
	 */
	public int getHeight()
	{
		return this._height;
	}
	
	/**
	 * Returns the highlight index.
	 *
	 * @return The highlight index or {@code -1} if none.
	 * @since 2018/12/02
	 */
	public int getHighlightIndex()
	{
		return this._highlightdx;
	}
	
	/**
	 * Returns the length of highlighted characters.
	 *
	 * @return The number of characters highlighted, {@code 0} if none.
	 * @since 2018/12/02
	 */
	public int getHighlightLength()
	{
		return this._highlightlen;
	}
	
	/**
	 * Returns the current indentation.
	 *
	 * @return The indentation.
	 * @since 2018/12/02
	 */
	public int getIndent()
	{
		return this._indentation;
	}
	
	/**
	 * Returns the initial direction.
	 *
	 * @return The initial direction.
	 * @since 2018/12/02
	 */
	public int getInitialDirection()
	{
		return this._direction;
	}
	
	/**
	 * Returns the height which is required to completely display all of the
	 * text within.
	 *
	 * @return The required height to draw.
	 * @since 2018/12/01
	 */
	public int getRequiredHeight()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		return this._requiredheight;
	}
	
	/**
	 * Returns the number of lines which are required to display all of the
	 * text within.
	 *
	 * @return The number of lines which are required.
	 * @since 2018/12/01
	 */
	public int getRequiredLineCount()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		return this._requiredlines;
	}
	
	/**
	 * Returns the scroll offset.
	 *
	 * @return The scroll offset.
	 * @since 2018/12/02
	 */
	public int getScrollOffset()
	{
		return this._scrolloffset;
	}
	
	/**
	 * Returns the space above each line.
	 *
	 * @return The space above.
	 * @since 2018/12/02
	 */
	public int getSpaceAbove()
	{
		return this._spaceabove;
	}
	
	/**
	 * Returns the space below each line.
	 *
	 * @return The space below.
	 * @since 2018/12/02
	 */
	public int getSpaceBelow()
	{
		return this._spacebelow;
	}
	
	/**
	 * Returns the text contained within this object.
	 *
	 * @param __i The starting index.
	 * @param __l The length.
	 * @return The string for the text.
	 * @throws IndexOutOfBoundsException If the index and/or length exceed
	 * the text bounds.
	 * @since 2018/12/01
	 */
	public String getText(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		TextStorage storage = this._storage;
		
		// {@squirreljme.error EB2r Text outside of bounds. (The starting
		// index; The ending index; The size of the text)}
		int size = storage.size;
		if (__i < 0 || __l < 0 || (__i + __l) > size)
			throw new IndexOutOfBoundsException(
				String.format("EB2r %d %d %d", __i, __l, size));
		
		// Create string from it
		return new String(storage.chars, __i, __l);
	}
	
	/**
	 * Returns the length of this text object.
	 *
	 * @return The length of the text object.
	 * @since 2018/12/01
	 */
	public int getTextLength()
	{
		return this._storage.size;
	}
	
	/**
	 * Returns the width of this text.
	 *
	 * @return The text width.
	 * @since 2018/12/01
	 */
	public int getWidth()
	{
		return this._width;
	}
	
	/**
	 * Inserts the given string at the position.
	 *
	 * @param __i The index to insert at, the index is always forced within
	 * the bounds of the buffer (negative values are inserted at zero and
	 * positions greater than the size are inserted at the end).
	 * @param __s The stirng to index.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public void insert(int __i, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Ignore adding empty strings as there is no purpose to it
		if (__s.isEmpty())
			return;
		
		// The index is always in the bounds of the storage
		TextStorage storage = this._storage;
		if (__i < 0)
			__i = 0;
		else if (__i > storage.size)
			__i = storage.size;
		
		// Insert space to store the characters
		int sn = __s.length();
		storage.insert(__i, sn);
		
		// Set character data here
		char[] chars = storage.chars;
		for (int i = 0; i < sn; i++)
			chars[__i++] = __s.charAt(i);
		
		// Adjust the caret?
		int caret = this._caret;
		if (caret >= 0 && __i < caret)
			this._caret = caret + sn;
		
		// Becomes dirty
		this._dirty = true;
	}
	
	public int lastRenderedIndex()
	{
		throw new todo.TODO();
	}
	
	public void moveCaret(int __nl)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the alignment of the text.
	 *
	 * @param __a If the alignment is not valid.
	 * @throws IllegalArgumentException If the alignment is not valid.
	 * @since 2018/12/02
	 */
	public void setAlignment(int __a)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2s Invalid alignment. (The alignment)}
		if (__a != ALIGN_LEFT && __a != ALIGN_CENTER && __a != ALIGN_RIGHT &&
			__a != ALIGN_JUSTIFY && __a != ALIGN_DEFAULT)
			throw new IllegalArgumentException("EB2s " + __a);
		
		this._alignment = __a;
	}
	
	/**
	 * Sets the background color.
	 *
	 * @param __argb The color to use.
	 * @since 2018/12/02
	 */
	public void setBackgroundColor(int __argb)
	{
		this._backgroundcolor = __argb;
	}
	
	/**
	 * Sets the position of the caret.
	 *
	 * @param __i The position to use, {@code -1} clears the caret
	 * @throws IndexOutOfBoundsException If the caret is outside of the
	 * text bounds.
	 * @since 2018/12/02
	 */
	public void setCaret(int __i)
		throws IndexOutOfBoundsException
	{
		// Clear it
		if (__i == -1)
		{
			this._caret = -1;
			return;
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the default font to use when no font has been specified.
	 *
	 * @param __f The default font to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public void setFont(Font __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// If this is the same font, just ignore it
		Font olddefaultfont = this._defaultfont;
		if (__f.equals(olddefaultfont))
			return;
		
		// Changing the font becomes dirty since we need to measure the
		// metrics again
		this._defaultfont = __f;
		this._dirty = true;
	}
	
	/**
	 * Sets the font at the given positions.
	 *
	 * @param __f The font to set, {@code null} clears.
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the given range is out of bounds.
	 * @since 2018/12/02
	 */
	public void setFont(Font __f, int __i, int __l)
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		int size = storage.size;
		if (__i < 0 || __l < 0 || __i >= size || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		Font[] font = storage.font;
		for (int i = 0; i < __l; i++)
			font[__i++] = __f;
		
		// Is dirty now
		this._dirty = true;
	}
	
	/**
	 * Sets the default foreground color to use when drawing.
	 *
	 * @param __argb The color to use.
	 * @since 2018/12/01
	 */
	public void setForegroundColor(int __argb)
	{
		// This does not dirty anything because it is just a color change,
		// nothing needs to be recomputed
		this._defaultcolor = __argb;
	}
	
	/**
	 * Sets the color at the given positions.
	 *
	 * @param __argb The ARGB color, zero removes the color.
	 * @param __i The index.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the given range is out of bounds.
	 * @since 2018/12/02
	 */
	public void setForegroundColor(int __argb, int __i, int __l)
	{
		TextStorage storage = this._storage;
		
		// Exceeds storage size?
		int size = storage.size;
		if (__i < 0 || __l < 0 || __i >= size || (__i + __l) > size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Set
		int[] color = storage.color;
		for (int i = 0; i < __l; i++)
			color[__i++] = __argb;
		
		// Is dirty now
		this._dirty = true;
	}
	
	/**
	 * Sets the height of the text.
	 *
	 * @param __h The new height.
	 * @throws IllegalArgumentException If the height is negative.
	 * @since 2018/12/01
	 */
	public void setHeight(int __h)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2t The height of a font cannot be
		// negative.}
		if (__h < 0)
			throw new IllegalArgumentException("EB2t");
		
		// Just set the height, we do not need to clear the dirty bit because
		// as long as the requiredheight is still within the height the text
		// fits
		this._height = __h;
	}
	
	/**
	 * Sets the highlight position.
	 *
	 * @param __i The starting index, {@code -1} clears the highlight.
	 * @param __l The number of characters to highlight.
	 * @throws IndexOutOfBoundsException If the index and/or length are out
	 * of bounds.
	 */
	public void setHighlight(int __i, int __l)
		throws IndexOutOfBoundsException
	{
		// Clear it
		if (__i == -1)
		{
			this._highlightdx = -1;
			this._highlightlen = 0;
			return;
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the indentation.
	 *
	 * @param __i The indentation.
	 * @since 2018/12/02
	 */
	public void setIndent(int __i)
	{
		this._indentation = __i;
	}
	
	/**
	 * Sets the initial direction.
	 *
	 * @param __dir The initial direction.
	 * @throws IllegalArgumentException If the direction is not valid.
	 * @since 2018/12/02
	 */
	public void setInitialDirection(int __dir)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2u The direction to use. (The direction)}
		if (__dir != DIRECTION_LTR && __dir != DIRECTION_RTL &&
			__dir != DIRECTION_NEUTRAL)
			throw new IllegalArgumentException("EB2u " + __dir);
		
		this._direction = __dir;
	}
	
	/**
	 * Sets the scroll offset.
	 *
	 * @param __o The offset.
	 * @since 2018/12/02
	 */
	public void setScrollOffset(int __o)
	{
		this._scrolloffset = __o;
	}
	
	/**
	 * Sets the space above each line.
	 *
	 * @param __sa The space above in pixels.
	 * @since 2018/12/02
	 */
	public void setSpaceAbove(int __sa)
	{
		this._spaceabove = __sa;
	}
	
	/**
	 * Sets the space below each line.
	 *
	 * @param __sb The space below in pixels.
	 * @since 2018/12/02
	 */
	public void setSpaceBelow(int __sb)
	{
		this._spacebelow = __sb;
	}
	
	/**
	 * Sets the width of this text to the specified width.
	 *
	 * @param __w The width to set.
	 * @throws IllegalArgumentException If the width is negative.
	 * @since 2018/11/30
	 */
	public void setWidth(int __w)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EB2v Cannot set the width to a negative value.}
		if (__w < 0)
			throw new IllegalArgumentException("EB2v");
		
		// Ignore on no changes
		int oldwidth = this._width;
		if (__w == oldwidth)
			return;
		
		// Set and mark dirty
		this._width = __w;
		this._dirty = true;
	}
	
	/**
	 * Returns whether all of the text fits within the bounds of the box.
	 *
	 * @return If all of the text fits within the bounds of the box.
	 * @since 2018/12/01
	 */
	public boolean textFits()
	{
		// Update
		if (this._dirty)
			this.__undirty();
		
		// The text will fit if the height needed to display everything is at
		// or below the height of the actual box. This is to make height
		// changes not require a recalculate.
		return this._requiredheight <= this._height;
	}
	
	/**
	 * Undirties the text within and calculates all of the needed bounds and
	 * metrics for each character.
	 *
	 * @since 2018/12/01
	 */
	private final void __undirty()
	{
		if (!this._dirty)
			return;
		
		// Using this gobal stuff
		Font defaultfont = this._defaultfont;
		int width = this._width;
		int height = this._height;
		int spaceabove = this._spaceabove;
		int spacebelow = this._spacebelow;
		int align = this._align;
		int indentation = this._indentation;
		int direction = this._direction;
		int scrolloffset = this._scrolloffset;
		
		// If the direction is neutral, this just becomes the locale default
		// For now just treat it as LTR
		if (direction == DIRECTION_NEUTRAL)
			direction = DIRECTION_LTR;
		
		// Are we going right to left?
		boolean dortl = (direction == DIRECTION_RTL);
		
		// Will use this storage stuff
		TextStorage storage = this._storage;
		char[] chars = storage.chars;
		Font[] font = storage.font;
		short[] cx = storage.x;
		short[] cy = storage.y;
		
		// The starting Y position is 
		// The starting X and Y position is always zero, when other alignments
		// and such are used they are calculated when the line ends
		// X is offset by the indentation and Y is offset by the scrolling
		int y = -scrolloffset + spaceabove,
			nexty = y;
		
		// X starts with indentation, but that might be modified in right
		// to left mode
		int x = (dortl ? width : indentation),
			startx = x;
		
		// Cache parameters of font
		Font lastfont = null;
		int fontheight = 0,
			fontascent = 0,
			fontdescent = 0;
		
		// For the end of line calculator, these are the indexes which are
		// used for each character
		int linedxstart = 0,
			linedxend = 0;
			
		// Redo handling of the current character, this will happen if
		// the line overflows
		boolean redo = false;
		
		// Go through and calculate every character line by line, carefully
		// handling alignment and justification
		// The line height is calculated so that if different fonts of
		// different sizes are on the same line, they all are on the baseline
		int linecount = 0,
			linemaxheight = 0,
			linemaxascent = 0,
			linemaxdescent = 0;
		for (int i = 0, n = storage.size; i <= n; i++)
		{
			// Since we need to handle line indentation, justification and
			// otherwise we need a flag to know when the next line was hit
			// to calculate
			// But the last character always has line stuff done to handle the
			// final alignment/directions and such
			// For now only the X positions are considered because
			boolean donextline = (i == n),
				wasnewlinech = false;
			if (!donextline)
			{
				// Need the character and font here, for metrics
				char ch = chars[i];
				Font f = font[i];
				if (f == null)
					f = defaultfont;
				
				// Font has changed?
				if (lastfont != f)
				{
					// Cache parameters
					fontheight = f.getHeight();
					fontascent = f.getAscent();
					fontdescent = f.getDescent();
					
					// Keep track so we do not need to update every time
					lastfont = f;
					
					// Properties of the line changed due to the font?
					// Cache them and check here accordingly
					if (fontascent > linemaxascent)
						linemaxascent = fontascent;
					if (fontheight > linemaxheight)
						linemaxheight = fontheight;
					if (fontdescent > linemaxdescent)
						linemaxdescent = fontdescent;
				}
				
				// Ignore carriage returns
				if (ch == '\r')
					continue;
				
				// Newlines do go to the next line, if a newline was detected
				// then the X position will be set to indentation, otherwise
				// zero.
				else if (ch == '\n')
				{
					donextline = true;
					wasnewlinech = true;
					
					// Clear a redo
					redo = false;
				}
				
				// Draw every other character
				else
				{
					// Get the properties of this character
					int chw = f.charWidth(ch);
					
					// Calculate draw position and the next X position
					// accordingly
					int dx, nx;
					if (dortl)
					{
						dx = x - chw;
						nx = dx;
					}
					else
					{
						dx = x;
						nx = x + chw;
					}
					
					// Character is still within the bounds?
					// Additionally if the X coordinate is at the start and
					// cannot even fit in the width just force it to be
					// placed
					if ((nx >= 0 && nx <= width) ||
						(x <= startx && x + chw <= width))
					{
						// Store current X position, this may change due to
						// right to left mode
						cx[i] = (short)dx;
						
						// Next character will be here
						x = nx;
						
						// Store the ascent of the character in the Y slot,
						// this is later used at end of line handler to
						// correctly place each character on the baseline
						cy[i] = (short)fontascent;
						
						// Clear a redo
						redo = false;
					}
					
					// Character exceeds the bounds, need to redo and handle
					// end of line
					else
					{
						// Redo should not be triggered twice, so just
						// clear it and never bother again
						if (redo)
						{
							redo = false;
							continue;
						}
						
						donextline = true;
						redo = true;
					}
				}
			}
			
			// End of line reached, handle alignment, justification, etc.
			// Perform any position updates as needed
			if (donextline)
			{
				// The line ends on this index (this is either strlen, a
				// newline, or a character placed on a newline so this is
				// always going to be exclusive)
				linedxend = i;
				
				// The next Y position is going to be the max font height
				// for this line.
				// An extra space above is only added if this was a newline,
				// so that way the next line has the actual space above
				nexty = y + linemaxheight + spacebelow +
					(wasnewlinech ? spaceabove : 0);
				
				// Calculate the correct Y position for each character
				for (int q = linedxstart; q < linedxend; q++)
				{
					// Get the original ascent of the character
					int origascent = cy[q];
					
					// The Y position is just the difference in space between
					// the line's max ascent and the character's actual ascent
					cy[q] = (short)(y + (linemaxascent - origascent));
				}
				
				// Handle non-default alignments
				if ((dortl && align != ALIGN_RIGHT) ||
					(!dortl && align != ALIGN_LEFT))
				{
					throw new todo.TODO();
				}
				
				// A line was here so the line count goes up
				linecount++;
				
				// If redoing this character, decrement i so that way it
				// negates the loop increment
				if (redo)
					i--;
				
				// The new start index
				linedxstart = i + 1;
				
				// Set the previously calculated Y position
				y = nexty;
				
				// Move X back
				x = startx;
			}
		}
		
		// Update other needed parameters
		// The required height is our nexty because either at the end or
		// a newline this will always be set
		this._requiredheight = nexty;
		this._requiredlines = linecount;
			
		// Has been updated, no longer dirty
		this._dirty = false;
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TextBox.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
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

























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

public class TextBox
	extends Screen
{
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	/**
	 * Initializes the text box.
	 *
	 * @param __title The title of the text box.
	 * @param __text The initial text in the box
	 * @param __max The maximum number of characters which may be specified in
	 * the text box.
	 * @param __con The constraints of the text box.
	 * @throws IllegalArgumentException See the exceptions for
	 * {@link EditableText#initialize(String, int, int)}.
	 * @since 2017/10/20
	 */
	public TextBox(String __title, String __text, int __max, int __con)
		throws IllegalArgumentException
	{
		// Set title if there is one
		if (__title != null)
			setTitle(__title);
		
		// Initialize editor with the given set of values
		this._editabletext.initialize(__text, __max, __con);
	}
	
	public void delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getChars(char[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getHeight()
	{
		throw new todo.TODO();
		/*
		return this.__defaultHeight();
		*/
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/24
	 */
	@Override
	public int getWidth()
	{
		throw new todo.TODO();
		/*
		return this.__defaultWidth();
		*/
	}
	
	public void insert(char[] __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void insert(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaret(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setChars(char[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setConstraints(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setHighlight(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __a)
	{
		throw new todo.TODO();
	}
	
	public int setMaxSize(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setString(String __a)
	{
		throw new todo.TODO();
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TextEditor.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
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

















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;

public class TextEditor
	extends CanvasItem
{
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	public TextEditor(String __text, int __maxsz, int __cons, int __w, int __h)
	{
		throw new todo.TODO();
	}
	
	public void delete(int __o, int __l)
	{
		throw new todo.TODO();
	}
	
	public int getBackgroundColor()
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	public int getContentHeight()
	{
		throw new todo.TODO();
	}
	
	public boolean getFocus()
	{
		throw new todo.TODO();
	}
	
	public Font getFont()
	{
		throw new todo.TODO();
	}
	
	public int getForegroundColor()
	{
		throw new todo.TODO();
	}
	
	public int getHighlightColor()
	{
		throw new todo.TODO();
	}
	
	public int getLineMarginHeight()
	{
		throw new todo.TODO();
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getSelection()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public boolean getVisible()
	{
		throw new todo.TODO();
	}
	
	public int getVisibleContentPosition()
	{
		throw new todo.TODO();
	}
	
	public void insert(String __t, int __p)
	{
		throw new todo.TODO();
	}
	
	public void setBackgroundColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaretPosition(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setConstraints(int __cons)
	{
		throw new todo.TODO();
	}
	
	public void setFocus(boolean __f)
	{
		throw new todo.TODO();
	}
	
	public void setFont(Font __f)
	{
		throw new todo.TODO();
	}
	
	public void setForegroundColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setHighlightColor(int __a, int __r, int __g, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __cs)
	{
		throw new todo.TODO();
	}
	
	public int setMaxSize(int __sz)
	{
		throw new todo.TODO();
	}
	
	public void setSelection(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setString(String __s)
	{
		throw new todo.TODO();
	}
	
	public void setTextEditorListener(TextEditorChangeListener __cl)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __v)
	{
		throw new todo.TODO();
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TextEditorChangeListener.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

public interface TextEditorChangeListener
{
	public static final int ACTION_CARET_MOVE =
		4;
	
	public static final int ACTION_CONTENT_CHANGE =
		1;
	
	public static final int ACTION_DIRECTION_CHANGE =
		64;
	
	public static final int ACTION_INPUT_MODE_CHANGE =
		128;
	
	public static final int ACTION_LANGUAGE_CHANGE =
		256;
	
	public static final int ACTION_TRAVERSE_NEXT =
		16;
	
	public static final int ACTION_TRAVERSE_PREVIOUS =
		8;
	
	public abstract void inputAction(TextEditor __e, int __act);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/TextField.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297









































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.EditableText;

/**
 * This represents a field of editable or read-only text which may be placed
 * within a form.
 *
 * If constraints are used within the text field then the representation of
 * the text may change according to the constraints. Note that the character
 * size limits may hinder valid values to be constrained.
 *
 * @since 2017/08/20
 */
public class TextField
	extends Item
{
	/** This is a constraint which has no limitations. */
	public static final int ANY =
		0;
	
	/**
	 * This mask is used to split the constraint between the type and any
	 * flags which may be used.
	 */
	public static final int CONSTRAINT_MASK =
		65535;
	
	/**
	 * This constraint is used to specify that the value represents currency
	 * and that when it is drawn it will be rendered as the currency for the
	 * system's current locale.
	 *
	 * Value requirements are exactly the same as {@link #DECIMAL}.
	 */
	public static final int CURRENCY =
		6;
	
	/**
	 * This constraint is used to specify that the value represents a decimal
	 * value and the field value is required to be matching.
	 *
	 * For the actual value in the decimal field, it may only contain digits,
	 * a minus sign {@code -}, and the decimal point {@code .}.
	 *
	 * When rendering the value, the number will be formatted to the current
	 * system's locale.
	 */
	public static final int DECIMAL =
		5;
	
	/**
	 * A constraint which specifies that an e-mail address is being entered.
	 */
	public static final int EMAILADDR =
		1;
	
	/**
	 * This is a constraint flag which hints that the start of a sentence
	 * should start with a capital letter.
	 */
	public static final int INITIAL_CAPS_SENTENCE =
		2097152;
	
	/**
	 * This is a constraint flag which hints that the start of every word
	 * should be capitalized.
	 */
	public static final int INITIAL_CAPS_WORD =
		1048576;
	
	/**
	 * This is a constraint flags which indicates that what is to be input
	 * will not be found in common dictionaries for the system.
	 *
	 * An example usage for this, would be user names for accounts which might
	 * not match dictionary words.
	 */
	public static final int NON_PREDICTIVE =
		524288;
	
	/**
	 * This is a constraint which requires that only an integer value is used,
	 * the integer itself matches that of {@code int}. As such only digits and
	 * the minus sign {@code -} are permitted.
	 *
	 * The value will be presented in the system's current locale.
	 */
	public static final int NUMERIC =
		2;
	
	/**
	 * This is a constriant flag which masks any input character with a
	 * special symbol to obscure them with. This should be used for passwords
	 * and PIN numbers.
	 *
	 * If this is used then {@link #NON_PREDICTIVE} and {@link #SENSITIVE} are
	 * implicitely set along with {@link #INITIAL_CAPS_SENTENCE} and
	 * {@link #INITIAL_CAPS_WORD} are impliticely cleared.
	 */
	public static final int PASSWORD =
		65536;
	
	/**
	 * This is a constraint which allows input for a phone number.
	 *
	 * If a phone book is available then access to the phonebook to input a
	 * number automatically may be used when applicable.
	 *
	 * When rendered the value may be represented in a more friendly fashion
	 * depending on the phone number.
	 */
	public static final int PHONENUMBER =
		3;
	
	/**
	 * This is a constraint flag which specifies that the given text should
	 * never be stored into a dictionary for predictive and auto-completion
	 * uses. A social-security number or credit card number for example is
	 * something which is considered sensitive.
	 *
	 * On some systems with predictive text, typing in words that are not in
	 * the dictionary will often add them to the dictionary so that they can
	 * become available to learn new words. This prevents this behavior.
	 */
	public static final int SENSITIVE =
		262144;
	
	/**
	 * This is a constraint flag which specifies that the text field cannot
	 * be edited.
	 */
	public static final int UNEDITABLE =
		131072;
	
	/** This is a consraint which specifies that a URL is being inserted. */
	public static final int URL =
		4;
	
	/** The common text editor this is associated with. */
	private final EditableText _editabletext =
		new EditableText();
	
	/**
	 * Initializes the text field.
	 *
	 * If the implementation does not support the specified number of
	 * characters then the input string will be truncated and no exception
	 * will be thrown provided the input is still valid.
	 *
	 * @param __l The label of the field.
	 * @param __t The text to initially set the field to,
	 * see {@link #setString(String)}.
	 * @param __ms The maximum amount of characters in the field,
	 * see {@link #setMaxSize(int)}.
	 * @param __c The constraints of the field,
	 * see {@link #setConstraints(int)}.
	 * @throws IllegalArgumentException If the maximum size is zero or less;
	 * the constraints is not valid; the text is not valid; or the text
	 * exceeds the maximum specified characters.
	 * @since 2017/08/19
	 */
	public TextField(String __l, String __t, int __ms, int __c)
		throws IllegalArgumentException
	{
		// Standard item properties
		setLabel(__l);
		
		// Initialize text area
		this._editabletext.initialize(__t, __ms, __c);
	}
	
	public void delete(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public int getCaretPosition()
	{
		throw new todo.TODO();
	}
	
	public int getChars(char[] __a)
	{
		throw new todo.TODO();
	}
	
	public int getConstraints()
	{
		throw new todo.TODO();
	}
	
	public int getMaxSize()
	{
		throw new todo.TODO();
	}
	
	public String getString()
	{
		throw new todo.TODO();
	}
	
	public void insert(char[] __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void insert(String __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCaret(int __i)
	{
		throw new todo.TODO();
	}
	
	public void setChars(char[] __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the constraints for this field according to the constraints which
	 * are available. If the current value is not valid under the constraints
	 * to be set then it is cleared.
	 *
	 * @param __c The constraints to set.
	 * @throws IllegalArgumentException If the input constraints are not
	 * valid.
	 * @since 2017/08/20
	 */
	public void setConstraints(int __c)
		throws IllegalArgumentException
	{
		this._editabletext.setConstraints(__c);
	}
	
	public void setHighlight(int __i, int __l)
	{
		throw new todo.TODO();
	}
	
	public void setInitialInputMode(String __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Sets the maximum size of the text field, if the value is larger than
	 * this value then it will be truncated.
	 *
	 * @param __ms The number of characters that can be placed in the field.
	 * @return The actual maximum capacity, this may be smaller than the
	 * input value.
	 * @throws IllegalArgumentException If the maximum size is not a non-zero
	 * positive value or if the value would not be valid after truncation if
	 * constraints are used.
	 * @since 2017/08/19
	 */
	public int setMaxSize(int __ms)
		throws IllegalArgumentException
	{
		return this._editabletext.setMaxSize(__ms);
	}
	
	/**
	 * Sets the value of the text field.
	 *
	 * @param __s The value to set, if {@code null} then an empty string is
	 * used.
	 * @throws IllegalArgumentException If the input string is not within
	 * the constraints or character count limitations.
	 * @since 2017/08/20
	 */
	public void setString(String __s)
		throws IllegalArgumentException
	{
		this._editabletext.setString(__s);
	}
	
	public int size()
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/Ticker.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.fbui.UIState;
import cc.squirreljme.runtime.lcdui.SerializedEvent;

/**
 * A ticker contains an infinitely scrolling message.
 *
 * Any {@link Displayable} may have tickers associated with them in which
 * they will be shown at the top of the screen accordingly. As such these can
 * be used to convey information as needed.
 *
 * @since 2018/03/26
 */
public class Ticker
{
	/** Displayables this ticker is attached to. */
	final __VolatileList__<Displayable> _displayables =
		new __VolatileList__<>();
	
	/** The text used. */
	volatile String _text;
	
	/**
	 * Initializes the ticker with the given string.
	 *
	 * @param __s The string to use for the ticker.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/26
	 */
	public Ticker(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Use internal title set
		this._text = __s;
	}
	
	/**
	 * Returns the string which is currently being displayed in the ticker.
	 *
	 * @return The string contained within the ticker.
	 * @since 2018/03/26
	 */
	public String getString()
	{
		return this._text;
	}
	
	/**
	 * Sets the string that is displayed within the ticker.
	 *
	 * @param __s The string to use for the ticker.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/26
	 */
	public void setString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set new
		this._text = __s;
		
		// Find a displayable which is showing this
		boolean isshown = false;
		for (Displayable di : this._displayables)
		{
			Display d = di._display;
			if (d != null)
				isshown = true;
		}
		
		// If this is being shown, then force the view to repaint
		UIState.getInstance().repaint();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/__Action__.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

/**
 * This represents the base for an action which may be given a label, an
 * image, and could be enabled or disabled.
 *
 * @since 2018/03/31
 */
abstract class __Action__
{
	/** The image used. */
	volatile Image _image;
	
	/** The short label. */
	volatile String _shortlabel;
	
	/** The long label. */
	volatile String _longlabel;
	
	/**
	 * This is called when the enabled state of the parent has changed.
	 *
	 * @param __e If the parent is enabled or disabled.
	 * @since 2018/04/01
	 */
	abstract void onParentEnabled(boolean __e);
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/__ChoiceEntry__.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.lcdui.common.CommonColors;

/**
 * This is a package public mutable class which represents single choices
 * within anything which uses choices.
 *
 * @since 2017/08/20
 */
final class __ChoiceEntry__
{
	/** The string to display for this choice. */
	volatile String _string;
	
	/** The image to display for this choice. */
	volatile Image _image;
	
	/** The font to use for this choice. */
	volatile Font _font;
	
	/** Is this entry selected? */
	volatile boolean _selected;
	
	/** Is this item disabled (is enabled by default)? */
	volatile boolean _disabled;
	
	/**
	 * Initializes a choice entry with default values.
	 *
	 * @param __s The string to display.
	 * @param __i The image to display.
	 * @since 2017/08/20
	 */
	__ChoiceEntry__(String __s, Image __i)
	{
		// Set
		this._string = __s;
		this._image = __i;
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/__GfxIPCDispatch__.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 javax.microedition.lcdui;

import cc.squirreljme.jvm.IPCCallback;

/**
 * This is the graphics IPC handler which dispatches any events to the
 * appropriate widgets and such.
 *
 * @since 2019/12/28
 */
@Deprecated
class __GfxIPCDispatch__
	implements IPCCallback
{
	/** The instance of this. */
	private static __GfxIPCDispatch__ _INSTANCE;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/28
	 */
	@Override
	public final long ipcCall(int __tid, int __ipcid, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Creates an instance of this class.
	 *
	 * @return The class instance.
	 * @since 2019/12/28
	 */
	static final __GfxIPCDispatch__ __instance()
	{
		__GfxIPCDispatch__ rv = _INSTANCE;
		if (rv == null)
			_INSTANCE = (rv = new __GfxIPCDispatch__());
		return rv;
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/__VolatileList__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233









































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/**
 * This is a list which is volatile but not synchronized but is backed by an
 * array, the array which as it is managed should always be atomic. So any
 * operation which returns an array should return one which is valid and
 * cannot be changed. If it is out of date then it is just out of date.
 *
 * The list is backed by an array.
 *
 * @param <T> The type of values to store.
 * @since 2018/11/17
 */
final class __VolatileList__<T>
	implements Iterable<T>
{
	/** The values in the list. */
	private volatile Object[] _values =
		new Object[0];
	
	/**
	 * Adds the specified value but only if it is a unique object reference
	 * in this list.
	 *
	 * @param __v The value to add.
	 * @since 2018/11/17
	 */
	public final void addUniqueObjRef(T __v)
	{
		Object[] values = this._values;
		
		// Already in the list? Do nothing
		for (Object v : values)
			if (v == __v)
				return;
		
		// Otherwise append
		this.append(__v);
	}
	
	/**
	 * Append the specified element to the list.
	 *
	 * @param __v The value to add.
	 * @return The index of this entry.
	 * @since 2018/11/17
	 */
	public final int append(T __v)
	{
		Object[] values = this._values;
		
		// Copy the array to increase the length
		int n = values.length;
		values = Arrays.<Object>copyOf(values, n + 1);
		
		// Store new value
		values[n] = __v;
		
		// Use this new array
		this._values = values;
		
		// Return the index of this entry
		return n;
	}
	
	/**
	 * Clears the list.
	 *
	 * @since 2018/11/17
	 */
	public final void clear()
	{
		this._values = new Object[0];
	}
	
	/**
	 * Gets the element at the given index.
	 *
	 * @param __i The index to get.
	 * @return The element.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @since 2018/12/09
	 */
	@SuppressWarnings({"unchecked"})
	public final T get(int __i)
		throws IndexOutOfBoundsException
	{
		// Is this in bounds?
		Object[] values = this._values;
		if (__i < 0 || __i >= values.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		return (T)values[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/18
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final Iterator<T> iterator()
	{
		return (Iterator<T>)
			((Object)(Arrays.<Object>asList(this._values).iterator()));
	}
	
	/**
	 * Removes the specified item from the list.
	 *
	 * @param __v The item to remove.
	 * @return {@code true} if it was removed.
	 * @since 2019/04/15
	 */
	@SuppressWarnings({"unchecked"})
	public final boolean remove(T __v)
	{
		Object[] values = this._values;
		
		// Check if we have this item first
		int dx = 0, n = values.length;
		for (; dx < n; dx++)
		{
			Object t = values[dx];
			
			// No match
			if ((__v == null) != (t == null) || !Objects.equals(t, __v))
				continue;
			
			// Stop
			break;
		}
		
		// No match
		if (dx >= n)
			return false;
		
		// Setup new array and copy all elements before and after
		Object[] newvalues = new Object[n - 1];
		for (int i = 0; i < dx; i++)
			newvalues[i] = values[i];
		for (int i = dx + 1, o = dx; i < n; i++, o++)
			newvalues[o] = values[i];
			
		// Use this new array
		this._values = newvalues;
		
		// Was changed
		return true;
	}
	
	/**
	 * Returns the number of values.
	 *
	 * @return The number of values stored.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this._values.length;
	}
	
	/**
	 * Converts the values to an array of the specific type.
	 *
	 * @param __ov The output array.
	 * @return The output array, may be recreated if too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	@SuppressWarnings({"unchecked"})
	public final T[] toArray(T[] __ov)
		throws NullPointerException
	{
		if (__ov == null)
			throw new NullPointerException("NARG");
		
		// Get input values
		Object[] iv = this._values;
		int in = iv.length;
		
		// Too short of an array? Grow it
		int on = __ov.length;
		if (on < in)
			__ov = Arrays.<T>copyOf(__ov, in);
		
		// Copy values
		for (int i = 0; i < in; i++)
			__ov[i] = (T)iv[i];
		
		// And use the passed or recreated array
		return __ov;
	}
	
	/**
	 * Returns the values in the list.
	 *
	 * @return The list values.
	 * @since 2018/11/18
	 */
	public final Object[] values()
	{
		return this._values;
	}
	
	/**
	 * Returns the values in this list as a list.
	 *
	 * @return The list of values.
	 * @since 2018/12/09
	 */
	@SuppressWarnings({"unchecked"})
	public final List<T> valuesAsList()
	{
		return (List<T>)Arrays.<Object>asList(this._values);
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/game/GameCanvas.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.ForwardingGraphics;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public abstract class GameCanvas
	extends Canvas
{
	public static final int DOWN_PRESSED =
		64;
	
	public static final int FIRE_PRESSED =
		256;
	
	public static final int GAME_A_PRESSED =
		512;
	
	public static final int GAME_B_PRESSED =
		1024;
	
	public static final int GAME_C_PRESSED =
		2048;
	
	public static final int GAME_D_PRESSED =
		4096;
	
	public static final int LEFT_PRESSED =
		4;
	
	public static final int RIGHT_PRESSED =
		32;
	
	public static final int UP_PRESSED =
		2;
	
	/** Forwarding graphics target, since they draw to the same buffer. */
	private final ForwardingGraphics _forwardgfx =
		new ForwardingGraphics();
	
	/** Are game keys being suppressed?. */
	private volatile boolean _suppressgamekeys;
	
	/** Is the buffer preserved after a flush? */
	private volatile boolean _preservebuffer;
	
	/** The A buffer. */
	private volatile __Buffer__ _bufa;
	
	/** The B buffer. */
	private volatile __Buffer__ _bufb;
	
	/**
	 * Initializes the game canvas.
	 *
	 * The buffer is preserved by default.
	 *
	 * @param __supke If {@code true} then game key events are suppressed.
	 * @since 2016/10/08
	 */
	protected GameCanvas(boolean __supke)
	{
		this(__supke, true);
	}
	
	/**
	 * Initializes the game canvas.
	 *
	 * It may be an optimization if key events are suppressed if a canvas is
	 * only needed to draw and not receive user input. The only key events
	 * that are suppressed are game keys.
	 *
	 * @param __supke If {@code true} then game key events are suppressed.
	 * @param __preservebuf If {@code true} then the buffer is preserved after
	 * a flush, otherwise if {@code false} the buffer data will be undefined.
	 * @see Canvas
	 * @since 2016/10/08
	 */
	protected GameCanvas(boolean __supke, boolean __preservebuf)
	{
		// Set
		this._suppressgamekeys = __supke;
		this._preservebuffer = __preservebuf;
	}
	
	/**
	 * Flushes the full off-screen buffer to the display.
	 *
	 * @since 2017/02/08
	 */
	public void flushGraphics()
	{
		// Do nothing if this is not on a display
		if (this.getCurrentDisplay() == null)
			return;
		
		// Flip!
		this.__flip();
	}
	
	/**
	 * Flushes the specified off-screen buffer area to the display.
	 *
	 * @param __x The X position.
	 * @param __y The Y position.
	 * @param __w The width.
	 * @param __h The height.
	 * @throws IllegalStateException If the buffer is preserved.
	 * @since 2017/02/28
	 */
	public void flushGraphics(int __x, int __y, int __w, int __h)
		throws IllegalStateException
	{
		// Nothing to flush
		if (__w <= 0 || __h <= 0)
			return;
		
		// Do nothing if this is not on a display
		if (this.getCurrentDisplay() == null)
			return;
		
		// {@squirreljme.error EB2w Cannot flush the graphics if the buffer
		// is not preserved.}
		if (!this._preservebuffer)
			throw new IllegalStateException("EB2w");
		
		// Flip!
		this.__flip();
	}
	
	/**
	 * This returns the off-screen buffer that is used by the game canvas to
	 * draw.
	 *
	 * @return The graphics object for the off-screen buffer.
	 * @since 2016/10/10
	 */
	protected Graphics getGraphics()
	{
		// Draw into the B buffer
		__Buffer__ buf = this._bufb;
		
		// Get device size
		int dw = this.getWidth(),
			dh = this.getHeight();
		
		// Force device size into bounds
		if (dw < 1)
			dw = 1;
		if (dh < 1)
			dh = 1;
		
		// Get buffer size
		int bw, bh;
		if (buf != null)
		{
			bw = buf._width;
			bh = buf._height;
		}
		else
			bw = bh = 0;
		
		// Recreate the buffer?
		if (buf == null || bw != dw || bh != dh)
		{
			// Create buffer
			buf = new __Buffer__(dw, dh);
			
			// Store buffer state
			this._bufb = buf;
		}
		
		// Create graphics to wrap it, alpha is not used!
		return new AdvancedGraphics(buf._pixels, false, null,
			dw, dh, dw, 0, 0, 0);
	}
	
	public int getKeyStates()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public void paint(Graphics __g)
	{
		// Whatever is in the A buffer is drawn
		__Buffer__ buf = this._bufa;
		if (buf == null)
			return;
			
		// The fastest way to draw onto the screen is to do a direct draw
		// from the RGB pixel data
		int pw = buf._width;
		__g.drawRGB(buf._pixels, 0, pw, 0, 0, pw, buf._height, false);
	}
	
	/**
	 * Performs the graphics flip.
	 *
	 * @return The flipped graphics.
	 * @since 2019/06/30
	 */
	private final void __flip()
	{
		// Get both buffers
		__Buffer__ bufa = this._bufa,
			bufb = this._bufb;
		
		// If never drawn onto, ignore
		if (bufb == null)
			return;
		
		// Get buffer size
		int bw = bufb._width,
			bh = bufb._height;
		
		// Create buffer to copy to
		if (bufa == null || bufa._width != bw && bufa._height != bh)
		{
			bufa = new __Buffer__(bw, bh);
			this._bufa = bufa;
		}
		
		// Copy pixel data (use System since it may be a memory copy)
		System.arraycopy(bufb._pixels, 0,
			bufa._pixels, 0, bw * bh);
		
		// Signal and wait for refresh
		super.repaint(0, 0, bw, bh);
		super.serviceRepaints();
	}
	
	/**
	 * This represents a single buffer, since this class is double buffered.
	 *
	 * @since 2019/06/30
	 */
	private static final class __Buffer__
	{
		/** The buffer pixels. */
		final int[] _pixels;
		
		/** The width. */
		final int _width;
		
		/** The height. */
		final int _height;
		
		/**
		 * Initializes the buffer.
		 *
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2019/06/30
		 */
		__Buffer__(int __w, int __h)
		{
			this._width = (__w < 1 ? (__w = 1) : __w);
			this._height = (__h < 1 ? (__h = 1) : __h);
			this._pixels = new int[__w * __h];
		}
	}
}

Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/game/Layer.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;

public abstract class Layer
{
	Layer()
	{
		super();
		throw new todo.TODO();
	}
	
	public abstract void paint(Graphics __a);
	
	public final int getHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getWidth()
	{
		throw new todo.TODO();
	}
	
	public final int getX()
	{
		throw new todo.TODO();
	}
	
	public final int getY()
	{
		throw new todo.TODO();
	}
	
	public final boolean isVisible()
	{
		throw new todo.TODO();
	}
	
	public void move(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setPosition(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setVisible(boolean __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/game/LayerManager.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;

public class LayerManager
{
	public LayerManager()
	{
		super();
		throw new todo.TODO();
	}
	
	public void append(Layer __a)
	{
		throw new todo.TODO();
	}
	
	public Layer getLayerAt(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getSize()
	{
		throw new todo.TODO();
	}
	
	public void insert(Layer __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void paint(Graphics __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void remove(Layer __a)
	{
		throw new todo.TODO();
	}
	
	public void setViewWindow(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/game/Sprite.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
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































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Sprite
	extends Layer
{
	public static final int TRANS_MIRROR =
		2;
	
	public static final int TRANS_MIRROR_ROT180 =
		1;
	
	public static final int TRANS_MIRROR_ROT270 =
		4;
	
	public static final int TRANS_MIRROR_ROT90 =
		7;
	
	public static final int TRANS_NONE =
		0;
	
	public static final int TRANS_ROT180 =
		3;
	
	public static final int TRANS_ROT270 =
		6;
	
	public static final int TRANS_ROT90 =
		5;
	
	public Sprite(Image __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public Sprite(Image __a, int __b, int __c)
	{
		super();
		throw new todo.TODO();
	}
	
	public Sprite(Sprite __a)
	{
		super();
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(Image __a, int __b, int __c, boolean 
		__d)
	{
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(Sprite __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	public final boolean collidesWith(TiledLayer __a, boolean __b)
	{
		throw new todo.TODO();
	}
	
	public void defineCollisionRectangle(int __a, int __b, int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	public void defineReferencePixel(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final int getFrame()
	{
		throw new todo.TODO();
	}
	
	public int getFrameSequenceLength()
	{
		throw new todo.TODO();
	}
	
	public int getRawFrameCount()
	{
		throw new todo.TODO();
	}
	
	public int getRefPixelX()
	{
		throw new todo.TODO();
	}
	
	public int getRefPixelY()
	{
		throw new todo.TODO();
	}
	
	public void nextFrame()
	{
		throw new todo.TODO();
	}
	
	@Override
	public final void paint(Graphics __a)
	{
		throw new todo.TODO();
	}
	
	public void prevFrame()
	{
		throw new todo.TODO();
	}
	
	public void setCollisionAlpha(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFrame(int __a)
	{
		throw new todo.TODO();
	}
	
	public void setFrameSequence(int[] __a)
	{
		throw new todo.TODO();
	}
	
	public void setImage(Image __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setRefPixelPosition(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setTransform(int __a)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/midp-lcdui/javax/microedition/lcdui/game/TiledLayer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class TiledLayer
	extends Layer
{
	public TiledLayer(int __a, int __b, Image __c, int __d, int __e)
	{
		super();
		throw new todo.TODO();
	}
	
	public int createAnimatedTile(int __a)
	{
		throw new todo.TODO();
	}
	
	public void fillCells(int __a, int __b, int __c, int __d, int __e)
	{
		throw new todo.TODO();
	}
	
	public int getAnimatedTile(int __a)
	{
		throw new todo.TODO();
	}
	
	public int getCell(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public final int getCellHeight()
	{
		throw new todo.TODO();
	}
	
	public final int getCellWidth()
	{
		throw new todo.TODO();
	}
	
	public final int getColumns()
	{
		throw new todo.TODO();
	}
	
	public final int getRows()
	{
		throw new todo.TODO();
	}
	
	@Override
	public final void paint(Graphics __a)
	{
		throw new todo.TODO();
	}
	
	public void setAnimatedTile(int __a, int __b)
	{
		throw new todo.TODO();
	}
	
	public void setCell(int __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
	
	public void setStaticTileSet(Image __a, int __b, int __c)
	{
		throw new todo.TODO();
	}
}


Deleted runt/apis/opengles/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: OpenGL ES
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the base support needed
  for OpenGL ES 1.1 functionality defined by JSR 239.
X-SquirrelJME-Depends: midp-lcdui
X-SquirrelJME-Error: EJ
X-SquirrelJME-UUID: d46fcedc-9cdd-4315-87a5-6ecb1dafc2a7
Microedition-Configuration: CLDC-1.8

Deleted runt/apis/opengles/cc/squirreljme/runtime/opengles/DefaultDisplay.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.opengles;

import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.CanvasItem;

/**
 * This represents a display used by the OpenGL rasterizer.
 *
 * @since 2016/10/10
 */
public class DefaultDisplay
	extends EGLDisplay
{
	/** The native display object. */
	protected final Object nativedisplay;
	
	/** Was this display initialized? */
	volatile boolean _initialized;
	
	/**
	 * Initializes the OpenGL ES display.
	 *
	 * @param __nd The native display to use.
	 * @throws IllegalArgumentException If the native display is not of a
	 * compatible type.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/10
	 */
	public DefaultDisplay(Object __nd)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__nd == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error EJ01 The specified class type cannot be used
		// as a display for OpenGL ES graphics. (The class type)}
		if (!(__nd instanceof Canvas || __nd instanceof CanvasItem))
			throw new IllegalArgumentException(String.format("EJ01 %s",
				__nd.getClass()));
		
		// Set
		this.nativedisplay = __nd;
	}
}

Deleted runt/apis/opengles/cc/squirreljme/runtime/opengles/DefaultEGL.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492












































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.opengles;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;

/**
 * This is the SquirrelJME implementation of OpenGL ES which provides access
 * to implemented rasterizers via the service interface.
 *
 * @since 2016/10/10
 */
public class DefaultEGL
	implements EGL11
{
	/** The start of temporary enumerants. */
	public static final int TEMPORARY_ENUMERANT_START =
		24576;
	
	/** The end of temporary enumerants. */
	public static final int TEMPORARY_ENUMERANT_END =
		32767;
	
	/** The start of the SquirrelJME enumerant. */
	public static final int SQUIRRELJME_ENUMERANT_START =
		TEMPORARY_ENUMERANT_START;
	
	/** The end of the SquirrelJME enumerant. */
	public static final int SQUIRRELJME_ENUMERANT_END =
		SQUIRRELJME_ENUMERANT_START + 16;
	
	/** The OpenGL ES error code. */
	private volatile int _error =
		EGL11.EGL_SUCCESS;
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglBindTexImage(EGLDisplay __a, EGLSurface __b, 
		int __c)
	{
		throw new todo.TODO();
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglChooseConfig(EGLDisplay __disp, int[] __attrl,
		EGLConfig[] __confs, int __confssize, int[] __numconf)
		throws IllegalArgumentException
	{
		// If null, then it defaults to not caring about anything
		if (__attrl == null)
			__attrl = new int[]{EGL10.EGL_NONE};
		
		// {@squirreljme.error EJ02 No display was specified for choosing a
		// configuration.}
		if (__disp == null)
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ02");
		}
		
		// Configuration must be set
		if (__numconf == null)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			return false;
		}
		
		// {@squirreljme.error EJ03 The array containing the number of
		// configurations written has a length of zero.}
		if (__numconf.length < 1)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ03");
		}
		
		// {@squirreljme.error EJ04 Requested more configurations than what
		// may be output.}
		if (__confs != null && __confs.length < __confssize)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ04");
		}
		
		// Must be a SquirrelJME display
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			return false;
		}
		
		// Must be initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		if (!dd._initialized)
		{
			this._error = EGL10.EGL_NOT_INITIALIZED;
			return false;
		}
		
		// Find the end of the list
		int end = 0, atn = __attrl.length;
		for (int i = 0; i < atn; i++, end++)
			if (__attrl[i] == EGL10.EGL_NONE)
				break;
		
		// {@squirreljme.error EJ05 The attribute list does not end with
		// EGL_NONE.}
		if (end >= atn)
		{
			this._error = EGL10.EGL_BAD_PARAMETER;
			throw new IllegalArgumentException("EJ05");
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglCopyBuffers(EGLDisplay __a, EGLSurface __b, 
		Object __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLContext eglCreateContext(EGLDisplay __a, EGLConfig __b
		, EGLContext __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreatePbufferSurface(EGLDisplay __a, 
		EGLConfig __b, int[] __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreatePixmapSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglCreateWindowSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglDestroyContext(EGLDisplay __a, EGLContext __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglDestroySurface(EGLDisplay __a, EGLSurface __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglGetConfigAttrib(EGLDisplay __a, EGLConfig __b,
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglGetConfigs(EGLDisplay __a, EGLConfig[] __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLContext eglGetCurrentContext()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLDisplay eglGetCurrentDisplay()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLSurface eglGetCurrentSurface(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public EGLDisplay eglGetDisplay(Object __nd)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ06 No native display was specified when
		// obtaining an OpenGL ES display.}
		if (__nd == null)
			throw new IllegalArgumentException("EJ06");
		
		// Just create a new display regardless of the native display object
		// used.
		return new DefaultDisplay(__nd);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public int eglGetError()
	{
		int rv = this._error;
		this._error = EGL11.EGL_SUCCESS;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglInitialize(EGLDisplay __disp, int[] __ver)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ07 No display was specified.}
		if (__disp == null)
		{
			this._error = EGL11.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ07");
		}
		
		// {@squirreljme.error EJ08 An output version was specified, however
		// it has a length lower than two.}
		if (__ver != null && __ver.length < 2)
			throw new IllegalArgumentException("EJ08");
		
		// Not our kind of display?
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL11.EGL_BAD_DISPLAY;
			return false;
		}
		
		// Mark it as initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		dd._initialized = true;
		
		// Return version number?
		if (__ver != null)
		{
			__ver[0] = 1;
			__ver[1] = 1;
		}
		
		// Ok
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglMakeCurrent(EGLDisplay __a, EGLSurface __b, 
		EGLSurface __c, EGLContext __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglQueryContext(EGLDisplay __a, EGLContext __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/11
	 */
	@Override
	public String eglQueryString(EGLDisplay __disp, int __key)
		throws IllegalArgumentException
	{
		// {@squirreljme.error EJ09 Cannot query string a null display.}
		if (__disp == null)
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			throw new IllegalArgumentException("EJ09");
		}
		
		// Must be our own display
		if (!(__disp instanceof DefaultDisplay))
		{
			this._error = EGL10.EGL_BAD_DISPLAY;
			return null;
		}
		
		// Must be initialized
		DefaultDisplay dd = (DefaultDisplay)__disp;
		if (!dd._initialized)
		{
			this._error = EGL10.EGL_NOT_INITIALIZED;
			return null;
		}
		
		// Depends on the key
		switch (__key)
		{
				// Vendor
			case EGL10.EGL_VENDOR:
				return "Stephanie Gawroriski (Multi-Phasic Applications)";
			
				// Version
			case EGL10.EGL_VERSION:
				return "1.1 SquirrelJME";
			
				// No extensions are defined
			case EGL10.EGL_EXTENSIONS:
				return "";
				
				// Unknown
			default:
				this._error = EGL10.EGL_BAD_PARAMETER;
				return null;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglQuerySurface(EGLDisplay __a, EGLSurface __b, 
		int __c, int[] __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglReleaseTexImage(EGLDisplay __a, EGLSurface __b
		, int __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSurfaceAttrib(EGLDisplay __a, EGLSurface __b, 
		int __c, int __d)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSwapBuffers(EGLDisplay __a, EGLSurface __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglSwapInterval(EGLDisplay __a, int __b)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglTerminate(EGLDisplay __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglWaitGL()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/10
	 */
	@Override
	public boolean eglWaitNative(int __a, Object __b)
	{
		throw new todo.TODO();
	}
}

Deleted runt/apis/opengles/cc/squirreljme/runtime/opengles/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the base support for OpenGL ES support on SquirrelJME.
 *
 * @since 2016/10/10
 */

package cc.squirreljme.runtime.opengles;

Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGL.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;


public interface EGL
{
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGL10.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610


































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

import javax.microedition.khronos.opengles.GL;

/**
 * This interface defines the standard OpenGL ES definitions and methods.
 *
 * To initialize a display, {@link #eglGetDisplay(Object)} must be called
 * where the {@link Object} is an instance of
 * {@link javax.microedition.lcdui.Display}.
 *
 * OpenGL ES is utilized by calling
 * {@link #eglCreateWindowSurface(EGLDisplay, EGLConfig, Object, int[]). The
 * {@link Object} parameter in this call represents a native surface to draw
 * onto. In this case, it is an instance of
 * {@link javax.microedition.lcdui.Graphics}.
 */
public interface EGL10
	extends EGL
{
	/**
	 * The minimum size in bits that the alpha buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	public static final int EGL_ALPHA_SIZE =
		12321;
	
	public static final int EGL_BAD_ACCESS =
		12290;
	
	public static final int EGL_BAD_ALLOC =
		12291;
	
	public static final int EGL_BAD_ATTRIBUTE =
		12292;
	
	public static final int EGL_BAD_CONFIG =
		12293;
	
	public static final int EGL_BAD_CONTEXT =
		12294;
	
	public static final int EGL_BAD_CURRENT_SURFACE =
		12295;
	
	/** This is an error specifying that the given display is not valid. */
	public static final int EGL_BAD_DISPLAY =
		12296;
	
	public static final int EGL_BAD_MATCH =
		12297;
	
	public static final int EGL_BAD_NATIVE_PIXMAP =
		12298;
	
	public static final int EGL_BAD_NATIVE_WINDOW =
		12299;
	
	public static final int EGL_BAD_PARAMETER =
		12300;
	
	public static final int EGL_BAD_SURFACE =
		12301;
	
	/**
	 * The minimum size in bits that the blue buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	public static final int EGL_BLUE_SIZE =
		12322;
	
	/**
	 * Attribute for the minimum desired size of the color buffer.
	 *
	 * Default 0.
	 */
	public static final int EGL_BUFFER_SIZE =
		12320;
	
	/**
	 * Configurations may have caveats, as such this allows conifgurations
	 * with caveats to be selected.
	 *
	 * May be either {@link #EGL_SLOW_CONFIG}, {@link #EGL_NONE} to use one
	 * with no caveats, {@link #EGL_NON_CONFORMANT_CONFIG}, or
	 * {@link #EGL_DONT_CARE} if it does not matter.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_CONFIG_CAVEAT =
		12327;
	
	/**
	 * A precomposed OpenGL ES configuration to choose, if this is specified
	 * then all other attributes are ignored. The value is implementation
	 * dependent.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_CONFIG_ID =
		12328;
	
	public static final int EGL_CORE_NATIVE_ENGINE =
		12379;
	
	/** This is used to signify that the default display should be used. */
	public static final Object EGL_DEFAULT_DISPLAY =
		new Object();
	
	/**
	 * The minimum size in bits that the depth buffer must be.
	 *
	 * A value of zero means to not use this buffer.
	 *
	 * Default 0.
	 */
	public static final int EGL_DEPTH_SIZE =
		12325;
	
	public static final int EGL_DONT_CARE =
		-1;
	
	public static final int EGL_DRAW =
		12377;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * extensions that are available to this OpenGL ES implementation.
	 */
	public static final int EGL_EXTENSIONS =
		12373;
	
	public static final int EGL_FALSE =
		0;
	
	/**
	 * The minimum size in bits that the green buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	public static final int EGL_GREEN_SIZE =
		12323;
	
	public static final int EGL_HEIGHT =
		12374;
	
	public static final int EGL_LARGEST_PBUFFER =
		12376;
	
	/**
	 * The exact number of buffer-levels to use, positive values mean the given
	 * number of overlay buffers and negative values are mapped to underlay
	 * buffers. Level zero is the default framebuffer of the display.
	 *
	 * Default 0.
	 */
	public static final int EGL_LEVEL =
		12329;
	
	public static final int EGL_MAX_PBUFFER_HEIGHT =
		12330;
	
	public static final int EGL_MAX_PBUFFER_PIXELS =
		12331;
	
	public static final int EGL_MAX_PBUFFER_WIDTH =
		12332;
	
	/**
	 * Specifies configurations that allow native rendering onto the surface
	 * or not. {@link #EGL_DONT_CARE} can choose any, {@link #EGL_TRUE}
	 * chooses configurations that allow native rendering, and
	 * {@link #EGL_FALSE} choose configurations that disallow native
	 * rendering.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_NATIVE_RENDERABLE =
		12333;
	
	public static final int EGL_NATIVE_VISUAL_ID =
		12334;
	
	/**
	 * A platform specified value or {@link #EGL_DONT_CARE}.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_NATIVE_VISUAL_TYPE =
		12335;
	
	public static final int EGL_NONE =
		12344;
	
	public static final int EGL_NON_CONFORMANT_CONFIG =
		12369;
	
	/** An error specifying that the display has not been initialized. */
	public static final int EGL_NOT_INITIALIZED =
		12289;
	
	/** This represents a null context. */
	public static final EGLContext EGL_NO_CONTEXT =
		new EGLContext()
		{
			/**
			 * {@inheritDoc}
			 * @since 2016/10/10
			 */
			@Override
			public GL getGL()
			{
				// {@squirreljme.error EJ0a Cannot get the GL instance of
				// a null context.}
				throw new RuntimeException("EJ0a");
			}
		};
	
	/** This represents a null display. */
	public static final EGLDisplay EGL_NO_DISPLAY =
		new EGLDisplay()
		{
		};
	
	/** This represents a null surface. */
	public static final EGLSurface EGL_NO_SURFACE =
		new EGLSurface()
		{
		};
	
	/**
	 * Specifies that the surface is capable of creating pixel buffer
	 * surfaces.
	 */
	public static final int EGL_PBUFFER_BIT =
		1;
	
	/** Specifies that the surface is capable of creating pixmap surfaces. */
	public static final int EGL_PIXMAP_BIT =
		2;
	
	public static final int EGL_PRESERVED_RESOURCES =
		12336;
	
	public static final int EGL_READ =
		12378;
	
	/**
	 * The minimum size in bits that the red buffer/channel must be.
	 *
	 * A value of zero means to prefer the smallest buffer, while a positive
	 * value selects the highest available buffer size.
	 *
	 * Default 0.
	 */
	public static final int EGL_RED_SIZE =
		12324;
	
	/**
	 * The minimum number of samples needed in the sample buffers.
	 *
	 * Default unspecified.
	 */
	public static final int EGL_SAMPLES =
		12337;
	
	/**
	 * The minimum number of acceptable multi-sample buffers. Configurations
	 * that are closer to this value are preferred.
	 *
	 * Default 0.
	 */
	public static final int EGL_SAMPLE_BUFFERS =
		12338;
	
	public static final int EGL_SLOW_CONFIG =
		12368;
	
	/**
	 * The minimum size in bits that the stencil buffer must be.
	 *
	 * A value of zero means to not use this buffer.
	 *
	 * Default 0.
	 */
	public static final int EGL_STENCIL_SIZE =
		12326;
	
	public static final int EGL_SUCCESS =
		12288;
	
	/**
	 * Represents the type of surface to use, this is a bitmask. The valid
	 * bits are {@link #EGL_WINDOW_BIT}, {@link #EGL_PBUFFER_BIT}, and
	 * {@link #EGL_PIXMAP_BIT}.
	 *
	 * Default {@link #EGL_WINDOW_BIT}.
	 */
	public static final int EGL_SURFACE_TYPE =
		12339;
	
	/**
	 * The transparent blue channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_TRANSPARENT_BLUE_VALUE =
		12341;
	
	/**
	 * The transparent green channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_TRANSPARENT_GREEN_VALUE =
		12342;
	
	/**
	 * The transparent red channel value to use. The value must be between
	 * {@code 0} and the maximum range for the given channel. Only
	 * configurations that use this specific color for transparent values will
	 * be considered.
	 *
	 * Default {@link #EGL_DONT_CARE}.
	 */
	public static final int EGL_TRANSPARENT_RED_VALUE =
		12343;
	
	public static final int EGL_TRANSPARENT_RGB =
		12370;
	
	/**
	 * The type of transparent framebuffer to use.
	 *
	 * May be {@link #EGL_NONE} then opaque framebuffers are used, otherwise
	 * {@link #EGL_TRANSPARENT_RGB} specifies that transparent framebuffers
	 * are used.
	 *
	 * Transparent framebuffers might not be supported.
	 *
	 * Default {@link #EGL_NONE}.
	 */
	public static final int EGL_TRANSPARENT_TYPE =
		12340;
	
	public static final int EGL_TRUE =
		1;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * OpenGL ES vendor.
	 */
	public static final int EGL_VENDOR =
		12371;
	
	/**
	 * A value for {@link #eglQueryString(EGLDisplay, int)} that requests the
	 * OpenGL ES version in the form of {@code major.minor vendor-specific}.
	 */
	public static final int EGL_VERSION =
		12372;
	
	public static final int EGL_WIDTH =
		12375;
	
	/** Supports creation of window surfaces. */
	public static final int EGL_WINDOW_BIT =
		4;
	
	/**
	 * This returns an array of framebuffer configurations that match the
	 * given input attributes.
	 *
	 * This method attempts to match all of the attributes that were specified.
	 * All attributes start with a key and is followed by a value.
	 *
	 * If the attribute list is {@code null} or has {@link #EGL_NONE} as the
	 * first entry then all defaults are chosen and default selection is
	 * performed.
	 *
	 * Some values must match exactly while others may be bound to be at least
	 * or at most the given value.
	 *
	 * The possible values are:
	 * {@link #EGL_BUFFER_SIZE},
	 * {@link #EGL_RED_SIZE},
	 * {@link #EGL_GREEN_SIZE},
	 * {@link #EGL_BLUE_SIZE},
	 * {@link #EGL_CONFIG_CAVEAT},
	 * {@link #EGL_CONFIG_ID},
	 * {@link #EGL_DEPTH_SIZE},
	 * {@link #EGL_LEVEL},
	 * {@link #EGL_NATIVE_RENDERABLE},
	 * {@link #EGL_NATIVE_VISUAL_TYPE},
	 * {@link #EGL_SAMPLE_BUFFERS},
	 * {@link #EGL_STENCIL_SIZE},
	 * {@link #EGL_SURFACE_TYPE},
	 * {@link #EGL_TRANSPARENT_TYPE},
	 * {@link #EGL_TRANSPARENT_RED_VALUE},
	 * {@link #EGL_TRANSPARENT_GREEN_VALUE},
	 * {@link #EGL_TRANSPARENT_BLUE_VALUE},
	 * {@link EGL11#EGL_BIND_TO_TEXTURE_RGB},
	 * {@link EGL11#EGL_BING_TO_TEXTURE_RGBA},
	 * {@link EGL11#EGL_MAX_SWAP_INTERVAL},
	 * {@link EGL11#EGL_MIN_SWAP_INTERVAL}
	 *
	 * Conifgurations are sorted in the following order:
	 *
	 * 1. {@link #EGL_CONFIG_CAVEAT} with the order: {@link #EGL_NONE},
	 *    {@link #EGL_SLOW_CONFIG}, then {@link #EGL_NON_CONFORMANT_CONFIG}.
	 * 2. The number of bits for the red, green, blue, and alpha channels,
	 *    higher is better. If the value is zero or {@link #EGL_DONT_CARE} then
	 *    it is not considered.
	 * 3. Smaller {@link #EGL_BUFFER_SIZE}.
	 * 4. Smaller {@link #EGL_SAMPLE_BUFFERS}.
	 * 5. Smaller {@link #EGL_DEPTH_SIZE}.
	 * 6. Smaller {@link #EGL_STENCIL_SIZE}.
	 * 7. Platform dependent {@link #EGL_NATIVE_VISUAL_TYPE}.
	 * 8. Smaller {@link EGL_CONFIG_ID}.
	 * 9. Other attributes are not considered.
	 *
	 * The following errors are set:
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not valid.
	 * {@link #EGL_BAD_ATTRIBUTE} if an attribute is not valid.
	 * {@link #EGL_NOT_INITIALIZED} if the display is not initialized.
	 * {@link #EGL_BAD_PARAMETER} if {@code __numconf} is {@code null}.
	 *
	 * @param __disp The display to get a configuration for.
	 * @param __attrl The attributes to return a matching configuration for,
	 * must end with {@link #EGL_NONE}.
	 * @param __confs The output configuration array, if {@code null} then
	 * this returns the number of matching configurations.
	 * @param __confssize The number of configurations to write at the most.
	 * @param __numconf The number of configurations that were placed in the
	 * output configuration array.
	 * @return {@code true} if a configuration was found and no errors were
	 * generated. If {@code false} then the input arguments are not modified.
	 * @throws IllegalArgumentException If no display was specified; If the
	 * attribute list is not terminated with {@link #EGL_NONE}; If the
	 * configurations were not null and the array length is shorter than the
	 * specified size; The number of configurations is not null and the length
	 * is zero.
	 * @since 2016/10/11
	 */
	public abstract boolean eglChooseConfig(EGLDisplay __disp, int[] __attrl,
		EGLConfig[] __confs, int __confssize, int[] __numconf)
		throws IllegalArgumentException;
	
	public abstract boolean eglCopyBuffers(EGLDisplay __a, EGLSurface __b, 
		Object __c);
	
	public abstract EGLContext eglCreateContext(EGLDisplay __a, EGLConfig __b
		, EGLContext __c, int[] __d);
	
	public abstract EGLSurface eglCreatePbufferSurface(EGLDisplay __a, 
		EGLConfig __b, int[] __c);
	
	public abstract EGLSurface eglCreatePixmapSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d);
	
	public abstract EGLSurface eglCreateWindowSurface(EGLDisplay __a, 
		EGLConfig __b, Object __c, int[] __d);
	
	public abstract boolean eglDestroyContext(EGLDisplay __a, EGLContext __b
		);
	
	public abstract boolean eglDestroySurface(EGLDisplay __a, EGLSurface __b
		);
	
	public abstract boolean eglGetConfigAttrib(EGLDisplay __a, EGLConfig __b,
		int __c, int[] __d);
	
	public abstract boolean eglGetConfigs(EGLDisplay __a, EGLConfig[] __b, 
		int __c, int[] __d);
	
	public abstract EGLContext eglGetCurrentContext();
	
	public abstract EGLDisplay eglGetCurrentDisplay();
	
	public abstract EGLSurface eglGetCurrentSurface(int __a);
	
	/**
	 * This creates a connection to the given native display.
	 *
	 * If the return of this method succeeds, then the display must be
	 * initialized by calling {@link #eglInitialize(EGLDisplay, int[])}.
	 *
	 * No error code is set.
	 *
	 * @param __nd The native display object to use, in SquirrelJME this will
	 * be an instance of {@link javax.microedition.lcdui.Display}. This may
	 * be {@link #EGL_DEFAULT_DISPLAY} to use the default display.
	 * @return The OpenGL ES Display for the given native display, or
	 * {@code EGL_NO_DISPLAY} is returned on error.
	 * @throws IllegalArgumentException If {@code __nd} is {@code null} or is
	 * not compatible with the OpenGL ES backend.
	 * @since 2016/10/10
	 */
	public abstract EGLDisplay eglGetDisplay(Object __nd)
		throws IllegalArgumentException;
	
	/**
	 * Returns the last error code that was emitted from the last operation
	 * that was called.
	 *
	 * After the call, it is reset to {@link #EGL_SUCCESS}.
	 *
	 * @return The error code.
	 * @since 2016/10/11
	 */
	public abstract int eglGetError();
	
	/**
	 * Initializes the OpenGL ES display and optionally returns the version
	 * number of OpenGL ES.
	 *
	 * If a display is already initialized then the version numbers are
	 * returned.
	 *
	 * If initialization fails, {@code false} is returned and the following
	 * errors may be set.
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not an EGL display
	 * connection.
	 * {@link #EGL_NOT_INITIALIZED} if initialization could not occur.
	 *
	 * {@link #eglTerminate(EGLDisplay)} is used to deinitialize a display
	 * and terminate the connection.
	 *
	 * @param __disp The display to initialize.
	 * @param __ver An optional array of at least length 2 where the first
	 * element is set to the major version number and the second element is set
	 * to the minor version number.
	 * @return {@code true} on success.
	 * @throws IllegalArgumentException If {@code __disp} is {@code null} or
	 * {@code __ver} is non-null and has a length lower than two.
	 * @since 2016/10/11
	 */
	public abstract boolean eglInitialize(EGLDisplay __disp, int[] __ver)
		throws IllegalArgumentException;
	
	public abstract boolean eglMakeCurrent(EGLDisplay __a, EGLSurface __b, 
		EGLSurface __c, EGLContext __d);
	
	public abstract boolean eglQueryContext(EGLDisplay __a, EGLContext __b, 
		int __c, int[] __d);
	
	/**
	 * Queries an implementation specific string from the specified display.
	 *
	 * Valid keys are: {@link #EGL_VENDOR}, {@link #EGL_VERSION}, and
	 * {@link #EGL_EXTENSIONS}.
	 *
	 * The following errors may be set:
	 *
	 * {@link #EGL_BAD_DISPLAY} if the display is not valid.
	 * {@link #EGL_NOT_INITIALIZED} if the display is not initialized.
	 * {@link #EGL_BAD_PARAMETER} if the name is not a valid value.
	 *
	 * @param __disp The display to query.
	 * @param __key The key value to obtain.
	 * @return The string value for the given display and variable or 
	 * {@code null} on failure.
	 * @throws IllegalArgumentException If {@code __disp} is {@code null}.
	 * @since 2016/10/11
	 */
	public abstract String eglQueryString(EGLDisplay __disp, int __key)
		throws IllegalArgumentException;
	
	public abstract boolean eglQuerySurface(EGLDisplay __a, EGLSurface __b, 
		int __c, int[] __d);
	
	public abstract boolean eglSwapBuffers(EGLDisplay __a, EGLSurface __b);
	
	public abstract boolean eglTerminate(EGLDisplay __a);
	
	public abstract boolean eglWaitGL();
	
	public abstract boolean eglWaitNative(int __a, Object __b);
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGL11.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;


public interface EGL11
	extends EGL10
{
	public static final int EGL_BACK_BUFFER =
		12420;
	
	/**
	 * Specifies whether or not binding color buffers to RGB textures is
	 * supported. The value may be {@link EGL10#EGL_DONT_CARE},
	 * {@link EGL10#EGL_FALSE}, or {@link EGL10#EGL_TRUE}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	public static final int EGL_BIND_TO_TEXTURE_RGB =
		12345;
	
	/**
	 * Specifies whether or not binding color buffers to RGBA textures is
	 * supported. The value may be {@link EGL10#EGL_DONT_CARE},
	 * {@link EGL10#EGL_FALSE}, or {@link EGL10#EGL_TRUE}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	public static final int EGL_BIND_TO_TEXTURE_RGBA =
		12346;
	
	public static final int EGL_CONTEXT_LOST =
		12302;
	
	/**
	 * The maximum value that may be passed to
	 * {@link #eglSwapInterval(EGLDisplay, int)}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	public static final int EGL_MAX_SWAP_INTERVAL =
		12348;
	
	/**
	 * The minimum value that may be passed to
	 * {@link #eglSwapInterval(EGLDisplay, int)}.
	 *
	 * Default {@link EGL10#EGL_DONT_CARE}.
	 */
	public static final int EGL_MIN_SWAP_INTERVAL =
		12347;
	
	public static final int EGL_MIPMAP_LEVEL =
		12419;
	
	public static final int EGL_MIPMAP_TEXTURE =
		12418;
	
	public static final int EGL_NO_TEXTURE =
		12380;
	
	public static final int EGL_TEXTURE_2D =
		12383;
	
	public static final int EGL_TEXTURE_FORMAT =
		12416;
	
	public static final int EGL_TEXTURE_RGB =
		12381;
	
	public static final int EGL_TEXTURE_RGBA =
		12382;
	
	public static final int EGL_TEXTURE_TARGET =
		12417;
	
	public abstract boolean eglBindTexImage(EGLDisplay __a, EGLSurface __b, 
		int __c);
	
	public abstract boolean eglReleaseTexImage(EGLDisplay __a, EGLSurface __b
		, int __c);
	
	public abstract boolean eglSurfaceAttrib(EGLDisplay __a, EGLSurface __b, 
		int __c, int __d);
	
	public abstract boolean eglSwapInterval(EGLDisplay __a, int __b);
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGLConfig.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

/**
 * This stores an OpenGL ES configuration.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLConfig
{
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGLContext.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

import cc.squirreljme.runtime.opengles.DefaultEGL;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.khronos.opengles.GL;

/**
 * This class encapsulates the OpenGL context which is used to obtain instances
 * of OpenGL ES and OpenGL rasterizers.
 *
 * To create a context use {@link EGL10#eglCreateContext(EGLDisplay, EGLConfig,
 * EGLContext, int[])} method.
 *
 * To destroy a context use {@link EGL10#eglDestroyContext(EGLDisplay,
 * EGLContext}.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLContext
{
	/** The single instance of EGL, shared by everything. */
	private static Reference<EGL> _EGL;
	
	/**
	 * Returns an instance of an object which is used to provide access to
	 * the underlying OpenGL ES rasterization API.
	 *
	 * @return The OpenGL ES rasterization API accessor.
	 * @since 2016/10/10
	 */
	public abstract GL getGL();
	
	/**
	 * This returns an instance of an object that implements the {@link EGL}
	 * interface which is used to initialize the rasterizer for drawing.
	 *
	 * @return An instance of the OpenGL ES rasterizer.
	 * @since 2016/10/10
	 */
	public static EGL getEGL()
	{
		// Get
		Reference<EGL> ref = EGLContext._EGL;
		EGL rv;
		
		// Create?
		if (ref == null || null == (rv = ref.get()))
			EGLContext._EGL = new WeakReference<>((rv = new DefaultEGL()));
		
		// Return it
		return rv;
	}
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGLDisplay.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

/**
 * This represents an OpenGL ES Display.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLDisplay
{
}


Deleted runt/apis/opengles/javax/microedition/khronos/egl/EGLSurface.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.egl;

/**
 * This represents an OpenGL ES Surface.
 *
 * For compatibility with the standard API this class should not be extended,
 * unless the class extending is internal to SquirrelJME.
 *
 * @since 2016/10/10
 */
public abstract class EGLSurface
{
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;


public interface GL
{
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL10.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

public interface GL10
	extends GL
{
	public static final int GL_ADD =
		260;
	
	public static final int GL_ALIASED_LINE_WIDTH_RANGE =
		33902;
	
	public static final int GL_ALIASED_POINT_SIZE_RANGE =
		33901;
	
	public static final int GL_ALPHA =
		6406;
	
	public static final int GL_ALPHA_BITS =
		3413;
	
	public static final int GL_ALPHA_TEST =
		3008;
	
	public static final int GL_ALWAYS =
		519;
	
	public static final int GL_AMBIENT =
		4608;
	
	public static final int GL_AMBIENT_AND_DIFFUSE =
		5634;
	
	public static final int GL_AND =
		5377;
	
	public static final int GL_AND_INVERTED =
		5380;
	
	public static final int GL_AND_REVERSE =
		5378;
	
	public static final int GL_BACK =
		1029;
	
	public static final int GL_BLEND =
		3042;
	
	public static final int GL_BLUE_BITS =
		3412;
	
	public static final int GL_BYTE =
		5120;
	
	public static final int GL_CCW =
		2305;
	
	public static final int GL_CLAMP_TO_EDGE =
		33071;
	
	public static final int GL_CLEAR =
		5376;
	
	public static final int GL_COLOR_ARRAY =
		32886;
	
	public static final int GL_COLOR_BUFFER_BIT =
		16384;
	
	public static final int GL_COLOR_LOGIC_OP =
		3058;
	
	public static final int GL_COLOR_MATERIAL =
		2903;
	
	public static final int GL_COMPRESSED_TEXTURE_FORMATS =
		34467;
	
	public static final int GL_CONSTANT_ATTENUATION =
		4615;
	
	public static final int GL_COPY =
		5379;
	
	public static final int GL_COPY_INVERTED =
		5388;
	
	public static final int GL_CULL_FACE =
		2884;
	
	public static final int GL_CW =
		2304;
	
	public static final int GL_DECAL =
		8449;
	
	public static final int GL_DECR =
		7683;
	
	public static final int GL_DEPTH_BITS =
		3414;
	
	public static final int GL_DEPTH_BUFFER_BIT =
		256;
	
	public static final int GL_DEPTH_TEST =
		2929;
	
	public static final int GL_DIFFUSE =
		4609;
	
	public static final int GL_DITHER =
		3024;
	
	public static final int GL_DONT_CARE =
		4352;
	
	public static final int GL_DST_ALPHA =
		772;
	
	public static final int GL_DST_COLOR =
		774;
	
	public static final int GL_EMISSION =
		5632;
	
	public static final int GL_EQUAL =
		514;
	
	public static final int GL_EQUIV =
		5385;
	
	public static final int GL_EXP =
		2048;
	
	public static final int GL_EXP2 =
		2049;
	
	public static final int GL_EXTENSIONS =
		7939;
	
	public static final int GL_FALSE =
		0;
	
	public static final int GL_FASTEST =
		4353;
	
	public static final int GL_FIXED =
		5132;
	
	public static final int GL_FLAT =
		7424;
	
	public static final int GL_FLOAT =
		5126;
	
	public static final int GL_FOG =
		2912;
	
	public static final int GL_FOG_COLOR =
		2918;
	
	public static final int GL_FOG_DENSITY =
		2914;
	
	public static final int GL_FOG_END =
		2916;
	
	public static final int GL_FOG_HINT =
		3156;
	
	public static final int GL_FOG_MODE =
		2917;
	
	public static final int GL_FOG_START =
		2915;
	
	public static final int GL_FRONT =
		1028;
	
	public static final int GL_FRONT_AND_BACK =
		1032;
	
	public static final int GL_GEQUAL =
		518;
	
	public static final int GL_GREATER =
		516;
	
	public static final int GL_GREEN_BITS =
		3411;
	
	public static final int GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES =
		35739;
	
	public static final int GL_IMPLEMENTATION_COLOR_READ_TYPE_OES =
		35738;
	
	public static final int GL_INCR =
		7682;
	
	public static final int GL_INVALID_ENUM =
		1280;
	
	public static final int GL_INVALID_OPERATION =
		1282;
	
	public static final int GL_INVALID_VALUE =
		1281;
	
	public static final int GL_INVERT =
		5386;
	
	public static final int GL_KEEP =
		7680;
	
	public static final int GL_LEQUAL =
		515;
	
	public static final int GL_LESS =
		513;
	
	public static final int GL_LIGHT0 =
		16384;
	
	public static final int GL_LIGHT1 =
		16385;
	
	public static final int GL_LIGHT2 =
		16386;
	
	public static final int GL_LIGHT3 =
		16387;
	
	public static final int GL_LIGHT4 =
		16388;
	
	public static final int GL_LIGHT5 =
		16389;
	
	public static final int GL_LIGHT6 =
		16390;
	
	public static final int GL_LIGHT7 =
		16391;
	
	public static final int GL_LIGHTING =
		2896;
	
	public static final int GL_LIGHT_MODEL_AMBIENT =
		2899;
	
	public static final int GL_LIGHT_MODEL_TWO_SIDE =
		2898;
	
	public static final int GL_LINEAR =
		9729;
	
	public static final int GL_LINEAR_ATTENUATION =
		4616;
	
	public static final int GL_LINEAR_MIPMAP_LINEAR =
		9987;
	
	public static final int GL_LINEAR_MIPMAP_NEAREST =
		9985;
	
	public static final int GL_LINES =
		1;
	
	public static final int GL_LINE_LOOP =
		2;
	
	public static final int GL_LINE_SMOOTH =
		2848;
	
	public static final int GL_LINE_SMOOTH_HINT =
		3154;
	
	public static final int GL_LINE_STRIP =
		3;
	
	public static final int GL_LUMINANCE =
		6409;
	
	public static final int GL_LUMINANCE_ALPHA =
		6410;
	
	public static final int GL_MAX_ELEMENTS_INDICES =
		33001;
	
	public static final int GL_MAX_ELEMENTS_VERTICES =
		33000;
	
	public static final int GL_MAX_LIGHTS =
		3377;
	
	public static final int GL_MAX_MODELVIEW_STACK_DEPTH =
		3382;
	
	public static final int GL_MAX_PROJECTION_STACK_DEPTH =
		3384;
	
	public static final int GL_MAX_TEXTURE_SIZE =
		3379;
	
	public static final int GL_MAX_TEXTURE_STACK_DEPTH =
		3385;
	
	public static final int GL_MAX_TEXTURE_UNITS =
		34018;
	
	public static final int GL_MAX_VIEWPORT_DIMS =
		3386;
	
	public static final int GL_MODELVIEW =
		5888;
	
	public static final int GL_MODULATE =
		8448;
	
	public static final int GL_MULTISAMPLE =
		32925;
	
	public static final int GL_NAND =
		5390;
	
	public static final int GL_NEAREST =
		9728;
	
	public static final int GL_NEAREST_MIPMAP_LINEAR =
		9986;
	
	public static final int GL_NEAREST_MIPMAP_NEAREST =
		9984;
	
	public static final int GL_NEVER =
		512;
	
	public static final int GL_NICEST =
		4354;
	
	public static final int GL_NOOP =
		5381;
	
	public static final int GL_NOR =
		5384;
	
	public static final int GL_NORMALIZE =
		2977;
	
	public static final int GL_NORMAL_ARRAY =
		32885;
	
	public static final int GL_NOTEQUAL =
		517;
	
	public static final int GL_NO_ERROR =
		0;
	
	public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS =
		34466;
	
	public static final int GL_ONE =
		1;
	
	public static final int GL_ONE_MINUS_DST_ALPHA =
		773;
	
	public static final int GL_ONE_MINUS_DST_COLOR =
		775;
	
	public static final int GL_ONE_MINUS_SRC_ALPHA =
		771;
	
	public static final int GL_ONE_MINUS_SRC_COLOR =
		769;
	
	public static final int GL_OR =
		5383;
	
	public static final int GL_OR_INVERTED =
		5389;
	
	public static final int GL_OR_REVERSE =
		5387;
	
	public static final int GL_OUT_OF_MEMORY =
		1285;
	
	public static final int GL_PACK_ALIGNMENT =
		3333;
	
	public static final int GL_PALETTE4_R5_G6_B5_OES =
		35730;
	
	public static final int GL_PALETTE4_RGB5_A1_OES =
		35732;
	
	public static final int GL_PALETTE4_RGB8_OES =
		35728;
	
	public static final int GL_PALETTE4_RGBA4_OES =
		35731;
	
	public static final int GL_PALETTE4_RGBA8_OES =
		35729;
	
	public static final int GL_PALETTE8_R5_G6_B5_OES =
		35735;
	
	public static final int GL_PALETTE8_RGB5_A1_OES =
		35737;
	
	public static final int GL_PALETTE8_RGB8_OES =
		35733;
	
	public static final int GL_PALETTE8_RGBA4_OES =
		35736;
	
	public static final int GL_PALETTE8_RGBA8_OES =
		35734;
	
	public static final int GL_PERSPECTIVE_CORRECTION_HINT =
		3152;
	
	public static final int GL_POINTS =
		0;
	
	public static final int GL_POINT_SMOOTH =
		2832;
	
	public static final int GL_POINT_SMOOTH_HINT =
		3153;
	
	public static final int GL_POLYGON_OFFSET_FILL =
		32823;
	
	public static final int GL_POLYGON_SMOOTH_HINT =
		3155;
	
	public static final int GL_POSITION =
		4611;
	
	public static final int GL_PROJECTION =
		5889;
	
	public static final int GL_QUADRATIC_ATTENUATION =
		4617;
	
	public static final int GL_RED_BITS =
		3410;
	
	public static final int GL_RENDERER =
		7937;
	
	public static final int GL_REPEAT =
		10497;
	
	public static final int GL_REPLACE =
		7681;
	
	public static final int GL_RESCALE_NORMAL =
		32826;
	
	public static final int GL_RGB =
		6407;
	
	public static final int GL_RGBA =
		6408;
	
	public static final int GL_SAMPLE_ALPHA_TO_COVERAGE =
		32926;
	
	public static final int GL_SAMPLE_ALPHA_TO_ONE =
		32927;
	
	public static final int GL_SAMPLE_COVERAGE =
		32928;
	
	public static final int GL_SCISSOR_TEST =
		3089;
	
	public static final int GL_SET =
		5391;
	
	public static final int GL_SHININESS =
		5633;
	
	public static final int GL_SHORT =
		5122;
	
	public static final int GL_SMOOTH =
		7425;
	
	public static final int GL_SMOOTH_LINE_WIDTH_RANGE =
		2850;
	
	public static final int GL_SMOOTH_POINT_SIZE_RANGE =
		2834;
	
	public static final int GL_SPECULAR =
		4610;
	
	public static final int GL_SPOT_CUTOFF =
		4614;
	
	public static final int GL_SPOT_DIRECTION =
		4612;
	
	public static final int GL_SPOT_EXPONENT =
		4613;
	
	public static final int GL_SRC_ALPHA =
		770;
	
	public static final int GL_SRC_ALPHA_SATURATE =
		776;
	
	public static final int GL_SRC_COLOR =
		768;
	
	public static final int GL_STACK_OVERFLOW =
		1283;
	
	public static final int GL_STACK_UNDERFLOW =
		1284;
	
	public static final int GL_STENCIL_BITS =
		3415;
	
	public static final int GL_STENCIL_BUFFER_BIT =
		1024;
	
	public static final int GL_STENCIL_TEST =
		2960;
	
	public static final int GL_SUBPIXEL_BITS =
		3408;
	
	public static final int GL_TEXTURE =
		5890;
	
	public static final int GL_TEXTURE0 =
		33984;
	
	public static final int GL_TEXTURE1 =
		33985;
	
	public static final int GL_TEXTURE10 =
		33994;
	
	public static final int GL_TEXTURE11 =
		33995;
	
	public static final int GL_TEXTURE12 =
		33996;
	
	public static final int GL_TEXTURE13 =
		33997;
	
	public static final int GL_TEXTURE14 =
		33998;
	
	public static final int GL_TEXTURE15 =
		33999;
	
	public static final int GL_TEXTURE16 =
		34000;
	
	public static final int GL_TEXTURE17 =
		34001;
	
	public static final int GL_TEXTURE18 =
		34002;
	
	public static final int GL_TEXTURE19 =
		34003;
	
	public static final int GL_TEXTURE2 =
		33986;
	
	public static final int GL_TEXTURE20 =
		34004;
	
	public static final int GL_TEXTURE21 =
		34005;
	
	public static final int GL_TEXTURE22 =
		34006;
	
	public static final int GL_TEXTURE23 =
		34007;
	
	public static final int GL_TEXTURE24 =
		34008;
	
	public static final int GL_TEXTURE25 =
		34009;
	
	public static final int GL_TEXTURE26 =
		34010;
	
	public static final int GL_TEXTURE27 =
		34011;
	
	public static final int GL_TEXTURE28 =
		34012;
	
	public static final int GL_TEXTURE29 =
		34013;
	
	public static final int GL_TEXTURE3 =
		33987;
	
	public static final int GL_TEXTURE30 =
		34014;
	
	public static final int GL_TEXTURE31 =
		34015;
	
	public static final int GL_TEXTURE4 =
		33988;
	
	public static final int GL_TEXTURE5 =
		33989;
	
	public static final int GL_TEXTURE6 =
		33990;
	
	public static final int GL_TEXTURE7 =
		33991;
	
	public static final int GL_TEXTURE8 =
		33992;
	
	public static final int GL_TEXTURE9 =
		33993;
	
	public static final int GL_TEXTURE_2D =
		3553;
	
	public static final int GL_TEXTURE_COORD_ARRAY =
		32888;
	
	public static final int GL_TEXTURE_ENV =
		8960;
	
	public static final int GL_TEXTURE_ENV_COLOR =
		8705;
	
	public static final int GL_TEXTURE_ENV_MODE =
		8704;
	
	public static final int GL_TEXTURE_MAG_FILTER =
		10240;
	
	public static final int GL_TEXTURE_MIN_FILTER =
		10241;
	
	public static final int GL_TEXTURE_WRAP_S =
		10242;
	
	public static final int GL_TEXTURE_WRAP_T =
		10243;
	
	public static final int GL_TRIANGLES =
		4;
	
	public static final int GL_TRIANGLE_FAN =
		6;
	
	public static final int GL_TRIANGLE_STRIP =
		5;
	
	public static final int GL_TRUE =
		1;
	
	public static final int GL_UNPACK_ALIGNMENT =
		3317;
	
	public static final int GL_UNSIGNED_BYTE =
		5121;
	
	public static final int GL_UNSIGNED_SHORT =
		5123;
	
	public static final int GL_UNSIGNED_SHORT_4_4_4_4 =
		32819;
	
	public static final int GL_UNSIGNED_SHORT_5_5_5_1 =
		32820;
	
	public static final int GL_UNSIGNED_SHORT_5_6_5 =
		33635;
	
	public static final int GL_VENDOR =
		7936;
	
	public static final int GL_VERSION =
		7938;
	
	public static final int GL_VERTEX_ARRAY =
		32884;
	
	public static final int GL_XOR =
		5382;
	
	public static final int GL_ZERO =
		0;
	
	public abstract void glActiveTexture(int __a);
	
	public abstract void glAlphaFunc(int __a, float __b);
	
	public abstract void glAlphaFuncx(int __a, int __b);
	
	public abstract void glBindTexture(int __a, int __b);
	
	public abstract void glBlendFunc(int __a, int __b);
	
	public abstract void glClear(int __a);
	
	public abstract void glClearColor(float __a, float __b, float __c, float 
		__d);
	
	public abstract void glClearColorx(int __a, int __b, int __c, int __d);
	
	public abstract void glClearDepthf(float __a);
	
	public abstract void glClearDepthx(int __a);
	
	public abstract void glClearStencil(int __a);
	
	public abstract void glClientActiveTexture(int __a);
	
	public abstract void glColor4f(float __a, float __b, float __c, float __d
		);
	
	public abstract void glColor4x(int __a, int __b, int __c, int __d);
	
	public abstract void glColorMask(boolean __a, boolean __b, boolean __c, 
		boolean __d);
	
	public abstract void glColorPointer(int __a, int __b, int __c, Buffer __d
		);
	
	public abstract void glCompressedTexImage2D(int __a, int __b, int __c, 
		int __d, int __e, int __f, int __g, Buffer __h);
	
	public abstract void glCompressedTexSubImage2D(int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h, Buffer __i);
	
	public abstract void glCopyTexImage2D(int __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h);
	
	public abstract void glCopyTexSubImage2D(int __a, int __b, int __c, int 
		__d, int __e, int __f, int __g, int __h);
	
	public abstract void glCullFace(int __a);
	
	public abstract void glDeleteTextures(int __a, int[] __b, int __c);
	
	public abstract void glDeleteTextures(int __a, IntBuffer __b);
	
	public abstract void glDepthFunc(int __a);
	
	public abstract void glDepthMask(boolean __a);
	
	public abstract void glDepthRangef(float __a, float __b);
	
	public abstract void glDepthRangex(int __a, int __b);
	
	public abstract void glDisable(int __a);
	
	public abstract void glDisableClientState(int __a);
	
	public abstract void glDrawArrays(int __a, int __b, int __c);
	
	public abstract void glDrawElements(int __a, int __b, int __c, Buffer __d
		);
	
	public abstract void glEnable(int __a);
	
	public abstract void glEnableClientState(int __a);
	
	public abstract void glFinish();
	
	public abstract void glFlush();
	
	public abstract void glFogf(int __a, float __b);
	
	public abstract void glFogfv(int __a, float[] __b, int __c);
	
	public abstract void glFogfv(int __a, FloatBuffer __b);
	
	public abstract void glFogx(int __a, int __b);
	
	public abstract void glFogxv(int __a, int[] __b, int __c);
	
	public abstract void glFogxv(int __a, IntBuffer __b);
	
	public abstract void glFrontFace(int __a);
	
	public abstract void glFrustumf(float __a, float __b, float __c, float 
		__d, float __e, float __f);
	
	public abstract void glFrustumx(int __a, int __b, int __c, int __d, int 
		__e, int __f);
	
	public abstract void glGenTextures(int __a, int[] __b, int __c);
	
	public abstract void glGenTextures(int __a, IntBuffer __b);
	
	public abstract int glGetError();
	
	public abstract void glGetIntegerv(int __a, int[] __b, int __c);
	
	public abstract void glGetIntegerv(int __a, IntBuffer __b);
	
	public abstract String glGetString(int __a);
	
	public abstract void glHint(int __a, int __b);
	
	public abstract void glLightModelf(int __a, float __b);
	
	public abstract void glLightModelfv(int __a, float[] __b, int __c);
	
	public abstract void glLightModelfv(int __a, FloatBuffer __b);
	
	public abstract void glLightModelx(int __a, int __b);
	
	public abstract void glLightModelxv(int __a, int[] __b, int __c);
	
	public abstract void glLightModelxv(int __a, IntBuffer __b);
	
	public abstract void glLightf(int __a, int __b, float __c);
	
	public abstract void glLightfv(int __a, int __b, float[] __c, int __d);
	
	public abstract void glLightfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glLightx(int __a, int __b, int __c);
	
	public abstract void glLightxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glLightxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glLineWidth(float __a);
	
	public abstract void glLineWidthx(int __a);
	
	public abstract void glLoadIdentity();
	
	public abstract void glLoadMatrixf(float[] __a, int __b);
	
	public abstract void glLoadMatrixf(FloatBuffer __a);
	
	public abstract void glLoadMatrixx(int[] __a, int __b);
	
	public abstract void glLoadMatrixx(IntBuffer __a);
	
	public abstract void glLogicOp(int __a);
	
	public abstract void glMaterialf(int __a, int __b, float __c);
	
	public abstract void glMaterialfv(int __a, int __b, float[] __c, int __d
		);
	
	public abstract void glMaterialfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glMaterialx(int __a, int __b, int __c);
	
	public abstract void glMaterialxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glMaterialxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glMatrixMode(int __a);
	
	public abstract void glMultMatrixf(float[] __a, int __b);
	
	public abstract void glMultMatrixf(FloatBuffer __a);
	
	public abstract void glMultMatrixx(int[] __a, int __b);
	
	public abstract void glMultMatrixx(IntBuffer __a);
	
	public abstract void glMultiTexCoord4f(int __a, float __b, float __c, 
		float __d, float __e);
	
	public abstract void glMultiTexCoord4x(int __a, int __b, int __c, int __d
		, int __e);
	
	public abstract void glNormal3f(float __a, float __b, float __c);
	
	public abstract void glNormal3x(int __a, int __b, int __c);
	
	public abstract void glNormalPointer(int __a, int __b, Buffer __c);
	
	public abstract void glOrthof(float __a, float __b, float __c, float __d,
		float __e, float __f);
	
	public abstract void glOrthox(int __a, int __b, int __c, int __d, int __e
		, int __f);
	
	public abstract void glPixelStorei(int __a, int __b);
	
	public abstract void glPointSize(float __a);
	
	public abstract void glPointSizex(int __a);
	
	public abstract void glPolygonOffset(float __a, float __b);
	
	public abstract void glPolygonOffsetx(int __a, int __b);
	
	public abstract void glPopMatrix();
	
	public abstract void glPushMatrix();
	
	public abstract void glReadPixels(int __a, int __b, int __c, int __d, int
		__e, int __f, Buffer __g);
	
	public abstract void glRotatef(float __a, float __b, float __c, float __d
		);
	
	public abstract void glRotatex(int __a, int __b, int __c, int __d);
	
	public abstract void glSampleCoverage(float __a, boolean __b);
	
	public abstract void glSampleCoveragex(int __a, boolean __b);
	
	public abstract void glScalef(float __a, float __b, float __c);
	
	public abstract void glScalex(int __a, int __b, int __c);
	
	public abstract void glScissor(int __a, int __b, int __c, int __d);
	
	public abstract void glShadeModel(int __a);
	
	public abstract void glStencilFunc(int __a, int __b, int __c);
	
	public abstract void glStencilMask(int __a);
	
	public abstract void glStencilOp(int __a, int __b, int __c);
	
	public abstract void glTexCoordPointer(int __a, int __b, int __c, Buffer 
		__d);
	
	public abstract void glTexEnvf(int __a, int __b, float __c);
	
	public abstract void glTexEnvfv(int __a, int __b, float[] __c, int __d);
	
	public abstract void glTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glTexEnvx(int __a, int __b, int __c);
	
	public abstract void glTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glTexEnvxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexImage2D(int __a, int __b, int __c, int __d, int
		__e, int __f, int __g, int __h, Buffer __i);
	
	public abstract void glTexParameterf(int __a, int __b, float __c);
	
	public abstract void glTexParameterx(int __a, int __b, int __c);
	
	public abstract void glTexSubImage2D(int __a, int __b, int __c, int __d, 
		int __e, int __f, int __g, int __h, Buffer __i);
	
	public abstract void glTranslatef(float __a, float __b, float __c);
	
	public abstract void glTranslatex(int __a, int __b, int __c);
	
	public abstract void glVertexPointer(int __a, int __b, int __c, Buffer 
		__d);
	
	public abstract void glViewport(int __a, int __b, int __c, int __d);
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL10Ext.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;


public interface GL10Ext
	extends GL
{
	public abstract int glQueryMatrixxOES(int[] __a, int __b, int[] __c, int 
		__d);
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL11.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546


































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

public interface GL11
	extends GL10
{
	public static final int GL_ACTIVE_TEXTURE =
		34016;
	
	public static final int GL_ADD_SIGNED =
		34164;
	
	public static final int GL_ALPHA_SCALE =
		3356;
	
	public static final int GL_ALPHA_TEST_FUNC =
		3009;
	
	public static final int GL_ALPHA_TEST_REF =
		3010;
	
	public static final int GL_ARRAY_BUFFER =
		34962;
	
	public static final int GL_ARRAY_BUFFER_BINDING =
		34964;
	
	public static final int GL_BLEND_DST =
		3040;
	
	public static final int GL_BLEND_SRC =
		3041;
	
	public static final int GL_BUFFER_ACCESS =
		35003;
	
	public static final int GL_BUFFER_SIZE =
		34660;
	
	public static final int GL_BUFFER_USAGE =
		34661;
	
	public static final int GL_CLIENT_ACTIVE_TEXTURE =
		34017;
	
	public static final int GL_CLIP_PLANE0 =
		12288;
	
	public static final int GL_CLIP_PLANE1 =
		12289;
	
	public static final int GL_CLIP_PLANE2 =
		12290;
	
	public static final int GL_CLIP_PLANE3 =
		12291;
	
	public static final int GL_CLIP_PLANE4 =
		12292;
	
	public static final int GL_CLIP_PLANE5 =
		12293;
	
	public static final int GL_COLOR_ARRAY_BUFFER_BINDING =
		34968;
	
	public static final int GL_COLOR_ARRAY_POINTER =
		32912;
	
	public static final int GL_COLOR_ARRAY_SIZE =
		32897;
	
	public static final int GL_COLOR_ARRAY_STRIDE =
		32899;
	
	public static final int GL_COLOR_ARRAY_TYPE =
		32898;
	
	public static final int GL_COLOR_CLEAR_VALUE =
		3106;
	
	public static final int GL_COLOR_WRITEMASK =
		3107;
	
	public static final int GL_COMBINE =
		34160;
	
	public static final int GL_COMBINE_ALPHA =
		34162;
	
	public static final int GL_COMBINE_RGB =
		34161;
	
	public static final int GL_CONSTANT =
		34166;
	
	public static final int GL_COORD_REPLACE_OES =
		34914;
	
	public static final int GL_CULL_FACE_MODE =
		2885;
	
	public static final int GL_CURRENT_COLOR =
		2816;
	
	public static final int GL_CURRENT_NORMAL =
		2818;
	
	public static final int GL_CURRENT_TEXTURE_COORDS =
		2819;
	
	public static final int GL_DEPTH_CLEAR_VALUE =
		2931;
	
	public static final int GL_DEPTH_FUNC =
		2932;
	
	public static final int GL_DEPTH_RANGE =
		2928;
	
	public static final int GL_DEPTH_WRITEMASK =
		2930;
	
	public static final int GL_DOT3_RGB =
		34478;
	
	public static final int GL_DOT3_RGBA =
		34479;
	
	public static final int GL_DYNAMIC_DRAW =
		35048;
	
	public static final int GL_ELEMENT_ARRAY_BUFFER =
		34963;
	
	public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING =
		34965;
	
	public static final int GL_FRONT_FACE =
		2886;
	
	public static final int GL_GENERATE_MIPMAP =
		33169;
	
	public static final int GL_GENERATE_MIPMAP_HINT =
		33170;
	
	public static final int GL_INTERPOLATE =
		34165;
	
	public static final int GL_LINE_WIDTH =
		2849;
	
	public static final int GL_LOGIC_OP_MODE =
		3056;
	
	public static final int GL_MATRIX_MODE =
		2976;
	
	public static final int GL_MAX_CLIP_PLANES =
		3378;
	
	public static final int GL_MODELVIEW_MATRIX =
		2982;
	
	public static final int GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES =
		35213;
	
	public static final int GL_MODELVIEW_STACK_DEPTH =
		2979;
	
	public static final int GL_NORMAL_ARRAY_BUFFER_BINDING =
		34967;
	
	public static final int GL_NORMAL_ARRAY_POINTER =
		32911;
	
	public static final int GL_NORMAL_ARRAY_STRIDE =
		32895;
	
	public static final int GL_NORMAL_ARRAY_TYPE =
		32894;
	
	public static final int GL_OPERAND0_ALPHA =
		34200;
	
	public static final int GL_OPERAND0_RGB =
		34192;
	
	public static final int GL_OPERAND1_ALPHA =
		34201;
	
	public static final int GL_OPERAND1_RGB =
		34193;
	
	public static final int GL_OPERAND2_ALPHA =
		34202;
	
	public static final int GL_OPERAND2_RGB =
		34194;
	
	public static final int GL_POINT_DISTANCE_ATTENUATION =
		33065;
	
	public static final int GL_POINT_FADE_THRESHOLD_SIZE =
		33064;
	
	public static final int GL_POINT_SIZE =
		2833;
	
	public static final int GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES =
		35743;
	
	public static final int GL_POINT_SIZE_ARRAY_OES =
		35740;
	
	public static final int GL_POINT_SIZE_ARRAY_POINTER_OES =
		35212;
	
	public static final int GL_POINT_SIZE_ARRAY_STRIDE_OES =
		35211;
	
	public static final int GL_POINT_SIZE_ARRAY_TYPE_OES =
		35210;
	
	public static final int GL_POINT_SIZE_MAX =
		33063;
	
	public static final int GL_POINT_SIZE_MIN =
		33062;
	
	public static final int GL_POINT_SPRITE_OES =
		34913;
	
	public static final int GL_POLYGON_OFFSET_FACTOR =
		32824;
	
	public static final int GL_POLYGON_OFFSET_UNITS =
		10752;
	
	public static final int GL_PREVIOUS =
		34168;
	
	public static final int GL_PRIMARY_COLOR =
		34167;
	
	public static final int GL_PROJECTION_MATRIX =
		2983;
	
	public static final int GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES =
		35214;
	
	public static final int GL_PROJECTION_STACK_DEPTH =
		2980;
	
	public static final int GL_RGB_SCALE =
		34163;
	
	public static final int GL_SAMPLES =
		32937;
	
	public static final int GL_SAMPLE_BUFFERS =
		32936;
	
	public static final int GL_SAMPLE_COVERAGE_INVERT =
		32939;
	
	public static final int GL_SAMPLE_COVERAGE_VALUE =
		32938;
	
	public static final int GL_SCISSOR_BOX =
		3088;
	
	public static final int GL_SHADE_MODEL =
		2900;
	
	public static final int GL_SRC0_ALPHA =
		34184;
	
	public static final int GL_SRC0_RGB =
		34176;
	
	public static final int GL_SRC1_ALPHA =
		34185;
	
	public static final int GL_SRC1_RGB =
		34177;
	
	public static final int GL_SRC2_ALPHA =
		34186;
	
	public static final int GL_SRC2_RGB =
		34178;
	
	public static final int GL_STATIC_DRAW =
		35044;
	
	public static final int GL_STENCIL_CLEAR_VALUE =
		2961;
	
	public static final int GL_STENCIL_FAIL =
		2964;
	
	public static final int GL_STENCIL_FUNC =
		2962;
	
	public static final int GL_STENCIL_PASS_DEPTH_FAIL =
		2965;
	
	public static final int GL_STENCIL_PASS_DEPTH_PASS =
		2966;
	
	public static final int GL_STENCIL_REF =
		2967;
	
	public static final int GL_STENCIL_VALUE_MASK =
		2963;
	
	public static final int GL_STENCIL_WRITEMASK =
		2968;
	
	public static final int GL_SUBTRACT =
		34023;
	
	public static final int GL_TEXTURE_BINDING_2D =
		32873;
	
	public static final int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING =
		34970;
	
	public static final int GL_TEXTURE_COORD_ARRAY_POINTER =
		32914;
	
	public static final int GL_TEXTURE_COORD_ARRAY_SIZE =
		32904;
	
	public static final int GL_TEXTURE_COORD_ARRAY_STRIDE =
		32906;
	
	public static final int GL_TEXTURE_COORD_ARRAY_TYPE =
		32905;
	
	public static final int GL_TEXTURE_MATRIX =
		2984;
	
	public static final int GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES =
		35215;
	
	public static final int GL_TEXTURE_STACK_DEPTH =
		2981;
	
	public static final int GL_VERTEX_ARRAY_BUFFER_BINDING =
		34966;
	
	public static final int GL_VERTEX_ARRAY_POINTER =
		32910;
	
	public static final int GL_VERTEX_ARRAY_SIZE =
		32890;
	
	public static final int GL_VERTEX_ARRAY_STRIDE =
		32892;
	
	public static final int GL_VERTEX_ARRAY_TYPE =
		32891;
	
	public static final int GL_VIEWPORT =
		2978;
	
	public static final int GL_WRITE_ONLY =
		35001;
	
	public abstract void glBindBuffer(int __a, int __b);
	
	public abstract void glBufferData(int __a, int __b, Buffer __c, int __d);
	
	public abstract void glBufferSubData(int __a, int __b, int __c, Buffer 
		__d);
	
	public abstract void glClipPlanef(int __a, float[] __b, int __c);
	
	public abstract void glClipPlanef(int __a, FloatBuffer __b);
	
	public abstract void glClipPlanex(int __a, int[] __b, int __c);
	
	public abstract void glClipPlanex(int __a, IntBuffer __b);
	
	public abstract void glColor4ub(byte __a, byte __b, byte __c, byte __d);
	
	public abstract void glColorPointer(int __a, int __b, int __c, int __d);
	
	public abstract void glDeleteBuffers(int __a, int[] __b, int __c);
	
	public abstract void glDeleteBuffers(int __a, IntBuffer __b);
	
	public abstract void glDrawElements(int __a, int __b, int __c, int __d);
	
	public abstract void glGenBuffers(int __a, int[] __b, int __c);
	
	public abstract void glGenBuffers(int __a, IntBuffer __b);
	
	public abstract void glGetBooleanv(int __a, boolean[] __b, int __c);
	
	public abstract void glGetBooleanv(int __a, IntBuffer __b);
	
	public abstract void glGetBufferParameteriv(int __a, int __b, int[] __c, 
		int __d);
	
	public abstract void glGetBufferParameteriv(int __a, int __b, IntBuffer 
		__c);
	
	public abstract void glGetClipPlanef(int __a, float[] __b, int __c);
	
	public abstract void glGetClipPlanef(int __a, FloatBuffer __b);
	
	public abstract void glGetClipPlanex(int __a, int[] __b, int __c);
	
	public abstract void glGetClipPlanex(int __a, IntBuffer __b);
	
	public abstract void glGetFixedv(int __a, int[] __b, int __c);
	
	public abstract void glGetFixedv(int __a, IntBuffer __b);
	
	public abstract void glGetFloatv(int __a, float[] __b, int __c);
	
	public abstract void glGetFloatv(int __a, FloatBuffer __b);
	
	public abstract void glGetLightfv(int __a, int __b, float[] __c, int __d
		);
	
	public abstract void glGetLightfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glGetLightxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glGetLightxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glGetMaterialfv(int __a, int __b, float[] __c, int 
		__d);
	
	public abstract void glGetMaterialfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glGetMaterialxv(int __a, int __b, int[] __c, int __d
		);
	
	public abstract void glGetMaterialxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glGetPointerv(int __a, Buffer[] __b);
	
	public abstract void glGetTexEnvfv(int __a, int __b, float[] __c, int __d
		);
	
	public abstract void glGetTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glGetTexEnviv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glGetTexEnviv(int __a, int __b, IntBuffer __c);
	
	public abstract void glGetTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glGetTexEnvxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glGetTexParameterfv(int __a, int __b, float[] __c, 
		int __d);
	
	public abstract void glGetTexParameterfv(int __a, int __b, FloatBuffer 
		__c);
	
	public abstract void glGetTexParameteriv(int __a, int __b, int[] __c, int
		__d);
	
	public abstract void glGetTexParameteriv(int __a, int __b, IntBuffer __c
		);
	
	public abstract void glGetTexParameterxv(int __a, int __b, int[] __c, int
		__d);
	
	public abstract void glGetTexParameterxv(int __a, int __b, IntBuffer __c
		);
	
	public abstract boolean glIsBuffer(int __a);
	
	public abstract boolean glIsEnabled(int __a);
	
	public abstract boolean glIsTexture(int __a);
	
	public abstract void glNormalPointer(int __a, int __b, int __c);
	
	public abstract void glPointParameterf(int __a, float __b);
	
	public abstract void glPointParameterfv(int __a, float[] __b, int __c);
	
	public abstract void glPointParameterfv(int __a, FloatBuffer __b);
	
	public abstract void glPointParameterx(int __a, int __b);
	
	public abstract void glPointParameterxv(int __a, int[] __b, int __c);
	
	public abstract void glPointParameterxv(int __a, IntBuffer __b);
	
	public abstract void glPointSizePointerOES(int __a, int __b, int __c);
	
	public abstract void glPointSizePointerOES(int __a, int __b, Buffer __c);
	
	public abstract void glTexCoordPointer(int __a, int __b, int __c, int __d
		);
	
	public abstract void glTexEnvi(int __a, int __b, int __c);
	
	public abstract void glTexEnviv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glTexEnviv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexParameterfv(int __a, int __b, float[] __c, int 
		__d);
	
	public abstract void glTexParameterfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glTexParameteri(int __a, int __b, int __c);
	
	public abstract void glTexParameteriv(int __a, int __b, int[] __c, int 
		__d);
	
	public abstract void glTexParameteriv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexParameterxv(int __a, int __b, int[] __c, int 
		__d);
	
	public abstract void glTexParameterxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glVertexPointer(int __a, int __b, int __c, int __d);
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL11Ext.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

public interface GL11Ext
	extends GL
{
	public static final int GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES =
		35742;
	
	public static final int GL_MATRIX_INDEX_ARRAY_OES =
		34884;
	
	public static final int GL_MATRIX_INDEX_ARRAY_POINTER_OES =
		34889;
	
	public static final int GL_MATRIX_INDEX_ARRAY_SIZE_OES =
		34886;
	
	public static final int GL_MATRIX_INDEX_ARRAY_STRIDE_OES =
		34888;
	
	public static final int GL_MATRIX_INDEX_ARRAY_TYPE_OES =
		34887;
	
	public static final int GL_MATRIX_PALETTE_OES =
		34880;
	
	public static final int GL_MAX_PALETTE_MATRICES_OES =
		34882;
	
	public static final int GL_MAX_VERTEX_UNITS_OES =
		34468;
	
	public static final int GL_TEXTURE_CROP_RECT_OES =
		35741;
	
	public static final int GL_WEIGHT_ARRAY_BUFFER_BINDING_OES =
		34974;
	
	public static final int GL_WEIGHT_ARRAY_OES =
		34477;
	
	public static final int GL_WEIGHT_ARRAY_POINTER_OES =
		34476;
	
	public static final int GL_WEIGHT_ARRAY_SIZE_OES =
		34475;
	
	public static final int GL_WEIGHT_ARRAY_STRIDE_OES =
		34474;
	
	public static final int GL_WEIGHT_ARRAY_TYPE_OES =
		34473;
	
	public abstract void glCurrentPaletteMatrixOES(int __a);
	
	public abstract void glDrawTexfOES(float __a, float __b, float __c, float
		__d, float __e);
	
	public abstract void glDrawTexfvOES(float[] __a, int __b);
	
	public abstract void glDrawTexfvOES(FloatBuffer __a);
	
	public abstract void glDrawTexiOES(int __a, int __b, int __c, int __d, 
		int __e);
	
	public abstract void glDrawTexivOES(int[] __a, int __b);
	
	public abstract void glDrawTexivOES(IntBuffer __a);
	
	public abstract void glDrawTexsOES(short __a, short __b, short __c, short
		__d, short __e);
	
	public abstract void glDrawTexsvOES(short[] __a, int __b);
	
	public abstract void glDrawTexsvOES(ShortBuffer __a);
	
	public abstract void glDrawTexxOES(int __a, int __b, int __c, int __d, 
		int __e);
	
	public abstract void glDrawTexxvOES(int[] __a, int __b);
	
	public abstract void glDrawTexxvOES(IntBuffer __a);
	
	public abstract void glEnable(int __a);
	
	public abstract void glEnableClientState(int __a);
	
	public abstract void glLoadPaletteFromModelViewMatrixOES();
	
	public abstract void glMatrixIndexPointerOES(int __a, int __b, int __c, 
		int __d);
	
	public abstract void glMatrixIndexPointerOES(int __a, int __b, int __c, 
		Buffer __d);
	
	public abstract void glTexParameterfv(int __a, int __b, float[] __c, int 
		__d);
	
	public abstract void glWeightPointerOES(int __a, int __b, int __c, int 
		__d);
	
	public abstract void glWeightPointerOES(int __a, int __b, int __c, Buffer
		__d);
}


Deleted runt/apis/opengles/javax/microedition/khronos/opengles/GL11ExtensionPack.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
















































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.khronos.opengles;

import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

public interface GL11ExtensionPack
	extends GL
{
	public static final int GL_BLEND_DST_ALPHA =
		32970;
	
	public static final int GL_BLEND_DST_RGB =
		32968;
	
	public static final int GL_BLEND_EQUATION =
		32777;
	
	public static final int GL_BLEND_EQUATION_ALPHA =
		34877;
	
	public static final int GL_BLEND_EQUATION_RGB =
		32777;
	
	public static final int GL_BLEND_SRC_ALPHA =
		32971;
	
	public static final int GL_BLEND_SRC_RGB =
		32969;
	
	public static final int GL_COLOR_ATTACHMENT0_OES =
		36064;
	
	public static final int GL_COLOR_ATTACHMENT10_OES =
		36074;
	
	public static final int GL_COLOR_ATTACHMENT11_OES =
		36075;
	
	public static final int GL_COLOR_ATTACHMENT12_OES =
		36076;
	
	public static final int GL_COLOR_ATTACHMENT13_OES =
		36077;
	
	public static final int GL_COLOR_ATTACHMENT14_OES =
		36078;
	
	public static final int GL_COLOR_ATTACHMENT15_OES =
		36079;
	
	public static final int GL_COLOR_ATTACHMENT1_OES =
		36065;
	
	public static final int GL_COLOR_ATTACHMENT2_OES =
		36066;
	
	public static final int GL_COLOR_ATTACHMENT3_OES =
		36067;
	
	public static final int GL_COLOR_ATTACHMENT4_OES =
		36068;
	
	public static final int GL_COLOR_ATTACHMENT5_OES =
		36069;
	
	public static final int GL_COLOR_ATTACHMENT6_OES =
		36070;
	
	public static final int GL_COLOR_ATTACHMENT7_OES =
		36071;
	
	public static final int GL_COLOR_ATTACHMENT8_OES =
		36072;
	
	public static final int GL_COLOR_ATTACHMENT9_OES =
		36073;
	
	public static final int GL_DECR_WRAP =
		34056;
	
	public static final int GL_DEPTH_ATTACHMENT_OES =
		36096;
	
	public static final int GL_DEPTH_COMPONENT =
		6402;
	
	public static final int GL_DEPTH_COMPONENT16 =
		33189;
	
	public static final int GL_DEPTH_COMPONENT24 =
		33190;
	
	public static final int GL_DEPTH_COMPONENT32 =
		33191;
	
	public static final int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES =
		36049;
	
	public static final int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES =
		36048;
	
	public static final int 
		GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES =
		36051;
	
	public static final int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES =
		36050;
	
	public static final int GL_FRAMEBUFFER_BINDING_OES =
		36006;
	
	public static final int GL_FRAMEBUFFER_COMPLETE_OES =
		36053;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES =
		36054;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES =
		36057;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES =
		36059;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES =
		36058;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 
		=
		36055;
	
	public static final int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES =
		36060;
	
	public static final int GL_FRAMEBUFFER_OES =
		36160;
	
	public static final int GL_FRAMEBUFFER_UNSUPPORTED_OES =
		36061;
	
	public static final int GL_FUNC_ADD =
		32774;
	
	public static final int GL_FUNC_REVERSE_SUBTRACT =
		32779;
	
	public static final int GL_FUNC_SUBTRACT =
		32778;
	
	public static final int GL_INCR_WRAP =
		34055;
	
	public static final int GL_INVALID_FRAMEBUFFER_OPERATION_OES =
		1286;
	
	public static final int GL_MAX_COLOR_ATTACHMENTS_OES =
		36063;
	
	public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE =
		34076;
	
	public static final int GL_MAX_RENDERBUFFER_SIZE_OES =
		34024;
	
	public static final int GL_MIRRORED_REPEAT =
		33648;
	
	public static final int GL_NORMAL_MAP =
		34065;
	
	public static final int GL_REFLECTION_MAP =
		34066;
	
	public static final int GL_RENDERBUFFER_ALPHA_SIZE_OES =
		36179;
	
	public static final int GL_RENDERBUFFER_BINDING_OES =
		36007;
	
	public static final int GL_RENDERBUFFER_BLUE_SIZE_OES =
		36178;
	
	public static final int GL_RENDERBUFFER_DEPTH_SIZE_OES =
		36180;
	
	public static final int GL_RENDERBUFFER_GREEN_SIZE_OES =
		36177;
	
	public static final int GL_RENDERBUFFER_HEIGHT_OES =
		36163;
	
	public static final int GL_RENDERBUFFER_INTERNAL_FORMAT_OES =
		36164;
	
	public static final int GL_RENDERBUFFER_OES =
		36161;
	
	public static final int GL_RENDERBUFFER_RED_SIZE_OES =
		36176;
	
	public static final int GL_RENDERBUFFER_STENCIL_SIZE_OES =
		36181;
	
	public static final int GL_RENDERBUFFER_WIDTH_OES =
		36162;
	
	public static final int GL_RGB565_OES =
		36194;
	
	public static final int GL_RGB5_A1 =
		32855;
	
	public static final int GL_RGB8 =
		32849;
	
	public static final int GL_RGBA4 =
		32854;
	
	public static final int GL_RGBA8 =
		32856;
	
	public static final int GL_STENCIL_ATTACHMENT_OES =
		36128;
	
	public static final int GL_STENCIL_INDEX =
		6401;
	
	public static final int GL_STENCIL_INDEX1_OES =
		36166;
	
	public static final int GL_STENCIL_INDEX4_OES =
		36167;
	
	public static final int GL_STENCIL_INDEX8_OES =
		36168;
	
	public static final int GL_STR =
		-1;
	
	public static final int GL_TEXTURE_BINDING_CUBE_MAP =
		34068;
	
	public static final int GL_TEXTURE_CUBE_MAP =
		34067;
	
	public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X =
		8318;
	
	public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y =
		8320;
	
	public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z =
		8322;
	
	public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X =
		8317;
	
	public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y =
		8319;
	
	public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z =
		8321;
	
	public static final int GL_TEXTURE_GEN_MODE =
		9472;
	
	public static final int GL_TEXTURE_GEN_STR =
		36192;
	
	public abstract void glBindFramebufferOES(int __a, int __b);
	
	public abstract void glBindRenderbufferOES(int __a, int __b);
	
	public abstract void glBindTexture(int __a, int __b);
	
	public abstract void glBlendEquation(int __a);
	
	public abstract void glBlendEquationSeparate(int __a, int __b);
	
	public abstract void glBlendFuncSeparate(int __a, int __b, int __c, int 
		__d);
	
	public abstract int glCheckFramebufferStatusOES(int __a);
	
	public abstract void glCompressedTexImage2D(int __a, int __b, int __c, 
		int __d, int __e, int __f, int __g, Buffer __h);
	
	public abstract void glCopyTexImage2D(int __a, int __b, int __c, int __d,
		int __e, int __f, int __g, int __h);
	
	public abstract void glDeleteFramebuffersOES(int __a, int[] __b, int __c
		);
	
	public abstract void glDeleteFramebuffersOES(int __a, IntBuffer __b);
	
	public abstract void glDeleteRenderbuffersOES(int __a, int[] __b, int __c
		);
	
	public abstract void glDeleteRenderbuffersOES(int __a, IntBuffer __b);
	
	public abstract void glEnable(int __a);
	
	public abstract void glFramebufferRenderbufferOES(int __a, int __b, int 
		__c, int __d);
	
	public abstract void glFramebufferTexture2DOES(int __a, int __b, int __c,
		int __d, int __e);
	
	public abstract void glGenFramebuffersOES(int __a, int[] __b, int __c);
	
	public abstract void glGenFramebuffersOES(int __a, IntBuffer __b);
	
	public abstract void glGenRenderbuffersOES(int __a, int[] __b, int __c);
	
	public abstract void glGenRenderbuffersOES(int __a, IntBuffer __b);
	
	public abstract void glGenerateMipmapOES(int __a);
	
	public abstract void glGetFramebufferAttachmentParameterivOES(int __a, 
		int __b, int __c, int[] __d, int __e);
	
	public abstract void glGetFramebufferAttachmentParameterivOES(int __a, 
		int __b, int __c, IntBuffer __d);
	
	public abstract void glGetIntegerv(int __a, int[] __b, int __c);
	
	public abstract void glGetIntegerv(int __a, IntBuffer __b);
	
	public abstract void glGetRenderbufferParameterivOES(int __a, int __b, 
		int[] __c, int __d);
	
	public abstract void glGetRenderbufferParameterivOES(int __a, int __b, 
		IntBuffer __c);
	
	public abstract void glGetTexGenfv(int __a, int __b, float[] __c, int __d
		);
	
	public abstract void glGetTexGenfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glGetTexGeniv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glGetTexGeniv(int __a, int __b, IntBuffer __c);
	
	public abstract void glGetTexGenxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glGetTexGenxv(int __a, int __b, IntBuffer __c);
	
	public abstract boolean glIsFramebufferOES(int __a);
	
	public abstract boolean glIsRenderbufferOES(int __a);
	
	public abstract void glRenderbufferStorageOES(int __a, int __b, int __c, 
		int __d);
	
	public abstract void glStencilOp(int __a, int __b, int __c);
	
	public abstract void glTexEnvf(int __a, int __b, float __c);
	
	public abstract void glTexEnvfv(int __a, int __b, float[] __c, int __d);
	
	public abstract void glTexEnvfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glTexEnvx(int __a, int __b, int __c);
	
	public abstract void glTexEnvxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glTexEnvxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexGenf(int __a, int __b, float __c);
	
	public abstract void glTexGenfv(int __a, int __b, float[] __c, int __d);
	
	public abstract void glTexGenfv(int __a, int __b, FloatBuffer __c);
	
	public abstract void glTexGeni(int __a, int __b, int __c);
	
	public abstract void glTexGeniv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glTexGeniv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexGenx(int __a, int __b, int __c);
	
	public abstract void glTexGenxv(int __a, int __b, int[] __c, int __d);
	
	public abstract void glTexGenxv(int __a, int __b, IntBuffer __c);
	
	public abstract void glTexParameterf(int __a, int __b, float __c);
}


Deleted runt/klib/NAMESPACE.MF.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Kernel Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: This contains kernel libraries which 
 may be included but which should not be part of the user level system. 
 The libraries here are for system use only.

Deleted runt/klib/profile-meep/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: a825a13b-6c9e-4429-ae36-6f878abc1f6f
X-SquirrelJME-Error: AR
X-SquirrelJME-Name: MEEP 8.0 Profile
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This defines the MEEP profile and is a 
 virtual project depends on others.
X-SquirrelJME-DefinedProfiles: MIDP-1.0 MIDP-2.0 MIDP-2.1 MIDP-3.0 
 MIDP-3.1 MEEP-8
X-SquirrelJME-Depends: gcf media-api meep-cellular meep-concurrency 
 meep-event meep-key meep-liblets meep-lui meep-midlet meep-power 
 meep-provisioning meep-rms meep-securityframework meep-swm 
 midp-lcdui
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/klib/supervisor/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: aad0dd9a-2cd6-4577-b085-6ad567d71bab
X-SquirrelJME-Error: SV
X-SquirrelJME-Name: SquirrelJME Supervisor
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This package contains the SquirrelJME 
 supervisor which is a very small and standalone implementation of 
 the basic libraries to be as small and as minimal as possible. It 
 is responsible for the internal JVM operations.
X-SquirrelJME-NoDependsConfiguration: true

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Allocator.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455







































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 contains the static memory allocator.
 *
 * @since 2019/05/26
 */
public final class Allocator
{
	/** Chunk is an object. */
	public static final byte CHUNK_BIT_IS_OBJECT =
		0x01;
	
	/** Constant pool. */
	public static final byte CHUNK_BIT_IS_POOL =
		0x02;
	
	/** Tag value bits mask. */
	public static final int CHUNK_BITS_VALUE_MASK =
		0x0F;
	
	/** Shift for the chunk tag. */
	public static final byte CHUNK_TAG_SHIFT =
		24;
	
	/** Memory free tag (all bits set). */
	public static final int CHUNK_TAG_FREE =
		0xFF000000;
	
	/** Chunk tag mask. */
	public static final int CHUNK_TAG_MASK =
		0xFF000000;
	
	/** The chunk size mask. */
	public static final int CHUNK_SIZE_MASK =
		0x00FFFFFF;
	
	/** Chunk size limit, lower than the cap to allow for chunk area. */
	public static final int CHUNK_SIZE_LIMIT =
		16777200;
	
	/** Memory chunk size offset. */
	public static final byte CHUNK_SIZE_OFFSET =
		0;
	
	/** Next chunk address. */
	public static final byte CHUNK_NEXT_OFFSET =
		4;
	
	/** The length of chunks. */
	public static final byte CHUNK_LENGTH =
		8;
	
	/** Extra size to add that must be hit before a chunk is split. */
	public static final byte SPLIT_REQUIREMENT =
		16;
	
	/** The base RAM address. */
	private static volatile int _rambase;
	
	/** The locking pointer address. */
	private static volatile int _lockptr;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/26
	 */
	private Allocator()
	{
	}
	
	/**
	 * Allocates the given number of bytes.
	 *
	 * @param __tag The tag to use, only the lowest 8-bits are used.
	 * @param __sz The number of bytes to allocate.
	 * @return The address of the allocated data or {@code 0} if there is
	 * not enough memory remaining.
	 * @since 2019/10/19
	 */
	public static final int allocate(int __tag, int __sz)
	{
		// Determine the special locking key to use, never let this be zero!
		int key = Allocator.__giveLockKey();
		
		// Try locking the pointer
		int lp = Allocator._lockptr;
		try
		{
			// Lock using our special key, which will never be zero!
			// Spin-lock so this is executed as fast as possible!
			while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
				continue;
			
			// Fall into the allocation without lock
			return Allocator.allocateWithoutLock(__tag, __sz);
		}
		
		// Clear the lock always
		finally
		{
			// Clear out lock, if not matched then something is wrong!
			int old;
			if (key != (old = Assembly.atomicCompareGetAndSet(key, 0, lp)))
			{
				// Another allocation took our lock??
				todo.DEBUG.code('a', 'l', old);
				Assembly.breakpoint();
				
				// {@squirreljme.error SV0j Another allocation took the lock
				// from us?}
				throw new VirtualMachineError("SV0j");
			}
		}
	}
	
	/**
	 * Allocates the given number of bytes, no locking is performed at all.
	 *
	 * @param __tag The tag to use, only the lowest 8-bits are used.
	 * @param __sz The number of bytes to allocate.
	 * @return The address of the allocated data or {@code 0} if there is
	 * not enough memory remaining.
	 * @since 2019/05/26
	 */
	public static final int allocateWithoutLock(int __tag, int __sz)
	{
		// The number of desired bytes
		int want = CHUNK_LENGTH + (__sz <= 4 ? 4 : ((__sz + 3) & (~3)));
		
		// Negative size or too big?
		if (__sz < 0 || want > CHUNK_SIZE_LIMIT)
			return 0;
		
		// Go through the memory chunks to locate a free chunk
		int seeker = Allocator._rambase;
		while (seeker != 0)
		{
			// Read chunk properties
			int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
			
			// Is this a free block? And can we fit in it?
			if ((csz & CHUNK_TAG_MASK) == CHUNK_TAG_FREE &&
				want <= (csz & CHUNK_SIZE_MASK))
				return Allocator.__claim(__tag, want, seeker, csz, cnx);
			
			// Go to the next chunk
			seeker = cnx;
		}
		
		// Did not find a free chunk
		return 0;
	}
	
	/**
	 * Frees the specified memory pointer, making it available for later use.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/10/19
	 */
	public static final void free(int __p)
	{
		// Determine the special locking key to use, never let this be zero!
		int key = Allocator.__giveLockKey();
		
		// Try locking the pointer
		int lp = Allocator._lockptr;
		try
		{
			// Lock using our special key, which will never be zero!
			// Spin-lock so this is executed as fast as possible!
			while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
				continue;
			
			// Fall into the free without lock
			Allocator.freeWithoutLock(__p);
		}
		
		// Clear the lock always
		finally
		{
			// Clear out lock, if not matched then something is wrong!
			int old;
			if (key != (old = Assembly.atomicCompareGetAndSet(key, 0, lp)))
			{
				// Another free took our lock??
				todo.DEBUG.code('f', 'l', old);
				Assembly.breakpoint();
				
				// {@squirreljme.error SV0k Another free took the lock
				// from us?}
				throw new VirtualMachineError("SV0k");
			}
		}
	}
	
	/**
	 * Frees the specified memory pointer, making it available for later use,
	 * without using a lock.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/05/27
	 */
	public static final void freeWithoutLock(int __p)
	{
		// This should never happen
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Determine the seeker position for this chunk
		int seeker = __p - CHUNK_LENGTH;
		
		// Read chunk properties
		int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
			cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
		
		// Actual logically used space
		int usedspace = (csz & CHUNK_SIZE_MASK);
		
		// Clear out memory with invalid data, that is BAD_MAGIC
		int bm = Constants.BAD_MAGIC;
		Assembly.sysCallP(SystemCallIndex.MEM_SET_INT,
			__p, bm, usedspace - CHUNK_LENGTH);
		if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.MEM_SET_INT) != SystemCallError.NO_ERROR)
		{
			// Fast memsetint() is not supported, so manually wipe
			// all the bytes!
			for (int i = CHUNK_LENGTH; i < usedspace; i += 4)
				Assembly.memWriteInt(seeker, i, bm);
		}
		
		// Make sure the reference count index is zero, to detect uncount
		// after free
		int rci = CHUNK_LENGTH + Constants.OBJECT_COUNT_OFFSET;
		if (rci + 4 <= csz)
			Assembly.memWriteInt(seeker, rci, 0);
		
		// See if we can merge this with the following chunk
		if (cnx != 0)
		{
			// Get properties of the next chunk
			int nsz = Assembly.memReadInt(cnx, CHUNK_SIZE_OFFSET),
				nnx = Assembly.memReadInt(cnx, CHUNK_NEXT_OFFSET);
			
			// Free space? Merge into it!
			if ((nsz & CHUNK_TAG_MASK) == CHUNK_TAG_FREE)
			{
				// Calculate the would be new size
				int newsize = usedspace + (nsz & CHUNK_SIZE_MASK);
				
				// Only merge chunks which are within the size limit, otherwise
				// a large portion of memory will not able to be reclaimed
				// because it would logically have a small size
				if (newsize <= CHUNK_SIZE_LIMIT)
				{
					// New size of our current chunk
					Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
						newsize | CHUNK_TAG_FREE);
					
					// Our chunk's next becomes the right side's next
					Assembly.memWriteInt(seeker, CHUNK_NEXT_OFFSET,
						nnx);
					
					// Do not use normal free set
					return;
				}
			}
		}
		
		// Set chunk as free now, keep the original size
		Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
			csz | CHUNK_TAG_FREE);
	}
	
	/**
	 * Claims the given block and returns it.
	 *
	 * @param __tag The tag to use, only 8-bits are used.
	 * @param __want The wanted size.
	 * @param __seeker The current chunk position.
	 * @param __csz The chunk size.
	 * @param __cnx The chunk next pointer.
	 * @return The allocation pointer.
	 * @since 2019/06/21
	 */
	private static final int __claim(int __tag, int __want, int __seeker,
		int __csz, int __cnx)
	{
		// Calculate free space in this chunk
		int freespace = (__csz & CHUNK_SIZE_MASK);
		
		// This chunk will be split into a used and free chunk
		if (__want + SPLIT_REQUIREMENT <= freespace)
		{
			// The size of the right side chunk is cut by our wanted
			// size
			int nextsize = freespace - __want;
			
			// The position of the next chunk
			int nextpos = __seeker + __want;
			
			// Setup new chunk
			Assembly.memWriteInt(__seeker, CHUNK_SIZE_OFFSET,
				(__want & CHUNK_SIZE_MASK) | (__tag << CHUNK_TAG_SHIFT));
			Assembly.memWriteInt(__seeker, CHUNK_NEXT_OFFSET,
				nextpos);
			
			// Setup the split chunk, points to the original next
			Assembly.memWriteInt(nextpos, CHUNK_SIZE_OFFSET,
				(nextsize & CHUNK_SIZE_MASK) | CHUNK_TAG_FREE);
			Assembly.memWriteInt(nextpos, CHUNK_NEXT_OFFSET,
				__cnx);
		}
		
		// Not being split, so the block gets claimed
		else
		{
			// Keep the originally passed size, but set the tag
			Assembly.memWriteInt(__seeker, CHUNK_SIZE_OFFSET,
				freespace | (__tag << CHUNK_TAG_SHIFT));
		}
		
		// The returning pointer
		int rv = __seeker + CHUNK_LENGTH;
		
		// Clear out memory since Java expects the data to be
		// initialized to zero always
		Assembly.sysCallP(SystemCallIndex.MEM_SET,
			rv, 0, __want - CHUNK_LENGTH);
		if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.MEM_SET) != SystemCallError.NO_ERROR)
		{
			// Fast memset() is not supported, so manually wipe
			// all the bytes!
			for (int i = CHUNK_LENGTH; i < __want; i += 4)
				Assembly.memWriteInt(__seeker, i, 0);
		}
		
		// Return the used pointer
		return rv;
	}
	
	/**
	 * Returns a locking key.
	 *
	 * @return The locking key.
	 * @since 2019/11/22
	 */
	static final int __giveLockKey()
	{
		// Use the thread register so we know the thread that is performing
		// the allocation/free, but never allow it to be zero
		int rv = Assembly.specialGetThreadRegister();
		if (rv == 0)
			return 0x506F4C79;
		return rv;
	}
	
	/**
	 * Initializes the RAM links.
	 *
	 * @param __rambase The base of RAM.
	 * @param __ramsize The amount of RAM available.
	 * @since 2019/05/26
	 */
	static final void __initRamLinks(int __rambase, int __ramsize)
	{
		// Loops through all blocks
		for (int seeker = __rambase;;)
		{
			// Read current and next offset
			int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
			
			// Reached the terminator which has been initialized to zero by
			// the BootROM, so this block and whatever is left becomes free
			// allocation space
			if (csz == 0 || cnx == 0)
			{
				// Since there is an allocation limit of 16MiB, if there is
				// more than 16MiB of memory available then there will be the
				// problem of having one gigantic chunk that is too small, or
				// keeping total memory capped at 16MiB. So to avoid this,
				// this will create as many chunks as needed to fill the
				// remainder of memory!
				
				// Create chunks as big as possible across a span
				int sizeleft = __ramsize - seeker;
				while (sizeleft > 0)
				{
					// Determine how big this chunk becomes
					int usesize = (sizeleft > CHUNK_SIZE_LIMIT ?
						CHUNK_SIZE_LIMIT : sizeleft);
					
					// Reduce used size
					sizeleft -= usesize;
					
					// Create free block here
					Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
						usesize | CHUNK_TAG_FREE);
					
					// Set pointer and seeker to the next block
					if (sizeleft > SPLIT_REQUIREMENT)
					{
						// Where is this located?
						int nextp = seeker + usesize;
						
						// Write next block position
						Assembly.memWriteInt(seeker, CHUNK_NEXT_OFFSET,
							nextp);
						
						// Go here next
						seeker = nextp;
					}
					
					// Too small to really be considered a block, so just
					// drop the next one
					else
					{
						// Always ensure the next block is zero!
						Assembly.memWriteInt(seeker, CHUNK_NEXT_OFFSET,
							0);
						
						// Stop
						break;
					}
				}
				
				// Stop
				break;
			}
			
			// Go to the next block in memory
			seeker = cnx;
		}
		
		// Set memory parameters
		Allocator._rambase = __rambase;
		
		// Set pointer used to control the lock state of memory
		Allocator._lockptr = Allocator.allocateWithoutLock(0, 4);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Assembly.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 class is used special by the compiler to transform all the various
 * operations into regular instructions rather than method calls.
 *
 * The compiler will take all of the method arguments and instead use their
 * inputs and outputs from the values of registers instead. However due to
 * this, this means that these instructions are purely primitive in that
 * they must not depend on any aspect of the virtual machine.
 *
 * @since 2019/04/20
 */
public final class Assembly
{
	/**
	 * Not used.
	 *
	 * @since 2019/04/20
	 */
	private Assembly()
	{
	}
	
	/**
	 * Returns the array length of the given object.
	 *
	 * @param __o The object to get the length of.
	 * @return The length of the array.
	 * @since 2019/05/24
	 */
	public static native int arrayLength(Object __o);
	
	/**
	 * Atomic comparison and set.
	 *
	 * @param __comp The value to compare and if matches, {@code __set} is
	 * written.
	 * @param __set The value to set if matched.
	 * @param __addr The address to write to.
	 * @return The value that was read before the set.
	 * @since 2019/07/01
	 */
	public static native int atomicCompareGetAndSet(int __comp, int __set,
		int __addr);
	
	/**
	 * Atomically decrements a value and returns the result.
	 *
	 * @param __addr The address to decrement.
	 * @return The get value.
	 * @since 2019/07/01
	 */
	public static native int atomicDecrementAndGet(int __addr);
	
	/**
	 * Atomically increments a value.
	 *
	 * @param __addr The address to increment.
	 * @since 2019/07/01
	 */
	public static native void atomicIncrement(int __addr);
	
	/**
	 * Trigger breakpoint within the virtual machine.
	 *
	 * @since 2019/04/21
	 */
	public static native void breakpoint();
	
	/**
	 * Returns the class info pointer of {@code boolean}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfBoolean();
	
	/**
	 * Returns the class info pointer of {@code byte}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfByte();
	
	/**
	 * Returns the class info pointer of {@code char}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfCharacter();
	
	/**
	 * Returns the class info pointer of {@code double}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfDouble();
	
	/**
	 * Returns the class info pointer of {@code float}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfFloat();
	
	/**
	 * Returns the class info pointer of {@code int}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfInteger();
	
	/**
	 * Returns the class info pointer of {@code long}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfLong();
	
	/**
	 * Returns the class info pointer of {@code short}.
	 *
	 * @return The class info pointer.
	 * @since 2020/01/19
	 */
	public static native int classInfoOfShort();
	
	/**
	 * Packs the given two integers to a double value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The double value.
	 * @since 2019/06/21
	 */
	public static native double doublePack(int __hi, int __lo);
	
	/**
	 * Double to raw long bits.
	 *
	 * @param __d The input double.
	 * @return The raw long bits.
	 * @since 2018/11/03
	 */
	public static native long doubleToRawLongBits(double __d);
	
	/**
	 * Performs explicit exception handling.
	 *
	 * @since 2019/04/28
	 */
	public static native void exceptionHandle();
	
	/**
	 * Float to raw int bits.
	 *
	 * @param __d The input float.
	 * @return The raw int bits.
	 * @since 2018/11/04
	 */
	public static native int floatToRawIntBits(float __f);
	
	/**
	 * Integer bits to float.
	 *
	 * @param __b The input bits.
	 * @return The resulting float.
	 * @since 2018/11/04
	 */
	public static native float intBitsToFloat(int __b);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/04/28
	 */
	public static native void invoke(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/04/28
	 */
	public static native int invokeV(int __addr, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke method at pointer.
	 *
	 * @param __addr The address to invoke.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a,
		int __b);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a,
		int __b, int __c);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke method at pointer, with arguments.
	 *
	 * @param __addr The address to invoke.
	 * @param __pool The pool pointer to load.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/12/08
	 */
	public static native long invokeVL(int __addr, int __pool, int __a, 
		int __b, int __c, int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Loads a value from the constant pool at the given index.
	 *
	 * @return The index of the value in the constant pool.
	 * @since 2019/04/28
	 */
	public static native int loadPool(int __i);
	
	/**
	 * Long bits to double.
	 *
	 * @param __b The input bits.
	 * @return The resulting double.
	 * @since 2018/11/03
	 */
	public static native double longBitsToDouble(long __b);
	
	/**
	 * Packs the given two integers to a long value.
	 *
	 * @param __hi The high value.
	 * @param __lo The low value.
	 * @return The long value.
	 * @since 2019/06/21
	 */
	public static native long longPack(int __hi, int __lo);
	
	/**
	 * Unpack high value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackHigh(long __v);
	
	/**
	 * Unpack low value from long.
	 *
	 * @param __v The long value.
	 * @return The unpacked fragment.
	 * @since 2019/06/21
	 */
	public static native int longUnpackLow(long __v);
	
	/**
	 * Reads byte from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadByte(int __p, int __o);
	
	/**
	 * Reads integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/21
	 */
	public static native int memReadInt(int __p, int __o);
	
	/**
	 * Reads big endian Java integer from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaInt(int __p, int __o);
	
	/**
	 * Reads big endian Java short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/05/29
	 */
	public static native int memReadJavaShort(int __p, int __o);
	
	/**
	 * Reads short from address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The result of the read.
	 * @since 2019/04/22
	 */
	public static native int memReadShort(int __p, int __o);
	
	/**
	 * Writes byte to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteByte(int __p, int __o, int __v);
	
	/**
	 * Writes integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteInt(int __p, int __o, int __v);
	
	/**
	 * Writes big endian Java integer to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaInt(int __p, int __o, int __v);
	
	/**
	 * Writes big endian Java short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/05/29
	 */
	public static native void memWriteJavaShort(int __p, int __o, int __v);
	
	/**
	 * Writes short to address.
	 *
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public static native void memWriteShort(int __p, int __o, int __v);
	
	/**
	 * Used to convert an object to a pointer.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native int objectToPointer(Object __o);
	
	/**
	 * Used to convert an object to a pointer, do use reference queing for it
	 * so that if the object is a candidate for reference counting it will
	 * be uncounted.
	 *
	 * @param __o The object.
	 * @return The pointer of the object.
	 * @since 2019/04/21
	 */
	public static native int objectToPointerRefQueue(Object __o);
	
	/**
	 * Used to convert a pointer to an object.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native Object pointerToObject(int __p);
	
	/**
	 * Used to convert a pointer to a class info type.
	 *
	 * @param __p The pointer.
	 * @return The object of the pointer.
	 * @since 2019/04/21
	 */
	public static native ClassInfo pointerToClassInfo(int __p);
	
	/**
	 * Perform reference counting logic on object.
	 *
	 * @param __p The object to count up.
	 * @since 2019/05/25
	 */
	public static native void refCount(int __p);
	
	/**
	 * Perform reference uncounting logic on object.
	 *
	 * @param __p The object to count down.
	 * @since 2019/05/25
	 */
	public static native void refUncount(int __p);
	
	/**
	 * Return from the current frame.
	 *
	 * @since 2019/04/21
	 */
	public static native void returnFrame();
	
	/**
	 * Returns from the current frame, returning the given value.
	 *
	 * @param __v The value to return.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __v);
	
	/**
	 * Returns from the current frame, returning both values.
	 *
	 * @param __h The high value.
	 * @param __l The low value.
	 * @since 2019/04/28
	 */
	public static native void returnFrame(int __h, int __l);
	
	/**
	 * Returns the exception register.
	 *
	 * @return The exception register.
	 * @since 2019/04/28
	 */
	public static native int specialGetExceptionRegister();
	
	/**
	 * Returns the value of the current pool register.
	 *
	 * @return The value of the pool register.
	 * @since 2019/05/01
	 */
	public static native int specialGetPoolRegister();
	
	/**
	 * Returns the value of the return register, for long return values this
	 * is the first high register.
	 *
	 * @return The value of the return register.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnRegister();
	
	/**
	 * Returns the value of the return register, the first high value.
	 *
	 * @return The value of the return register, the first high value.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnHighRegister();
	
	/**
	 * Returns the value of the return register, the second low value.
	 *
	 * @return The value of the return register, the second low value.
	 * @since 2019/04/28
	 */
	public static native int specialGetReturnLowRegister();
	
	/**
	 * Reads the value of the static field register.
	 *
	 * @return The value of the static field register.
	 * @since 2019/04/22
	 */
	public static native int specialGetStaticFieldRegister();
	
	/**
	 * Returns the register representing the current thread.
	 *
	 * @return The current thread register.
	 * @since 2019/04/22
	 */
	public static native int specialGetThreadRegister();
	
	/**
	 * Sets the value of the exception register.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/28
	 */
	public static native void specialSetExceptionRegister(int __v);
	
	/**
	 * Sets the value of the constant pool register.
	 *
	 * @param __v The new value of the constant pool register.
	 * @since 2019/05/01
	 */
	public static native void specialSetPoolRegister(int __v);
	
	/**
	 * Sets the value of the static field register.
	 *
	 * @param __v The new value of the static field register.
	 * @since 2019/04/22
	 */
	public static native void specialSetStaticFieldRegister(int __v);
	
	/**
	 * Sets the current thread pointer.
	 *
	 * @param __v The value to use.
	 * @since 2019/04/27
	 */
	public static native void specialSetThreadRegister(int __v);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/23
	 */
	public static native void sysCall(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __addr The address to invoke.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @since 2019/05/27
	 */
	public static native void sysCallP(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native int sysCallPV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke pure system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke pure system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/27
	 */
	public static native long sysCallPVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
	
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native int sysCallV(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
		
	/**
	 * Invoke system call at the given index.
	 *
	 * @param __si System call index.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g);
	
	/**
	 * Invoke system call at the given index, with arguments.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result of the invocation.
	 * @since 2019/05/23
	 */
	public static native long sysCallVL(short __si, int __a, int __b, int __c,
		int __d, int __e, int __f, int __g, int __h);
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Bootstrap.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
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














































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.jvm.lib.BootRom;
import cc.squirreljme.jvm.lib.BootRomLibrary;
import cc.squirreljme.jvm.task.Task;
import cc.squirreljme.jvm.task.TaskCreateResult;
import cc.squirreljme.jvm.task.TaskManager;
import cc.squirreljme.jvm.task.TaskSysCallHandler;
import cc.squirreljme.jvm.task.TaskThread;
import cc.squirreljme.jvm.task.ThreadManager;

/**
 * This is the bootstrap entry point for the supervisor.
 *
 * @since 2019/05/25
 */
public final class Bootstrap
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/25
	 */
	private Bootstrap()
	{
	}
	
	/**
	 * Entry point for the bootstrap.
	 *
	 * @param __rambase The base RAM address.
	 * @param __ramsize The size of RAM.
	 * @param __rombase Base address of the ROM (for offset calculation).
	 * @param __romsize The size of ROM.
	 * @param __confbase The configuration memory base.
	 * @param __confsize The configuration memory size.
	 * @since 2019/05/25
	 */
	static final void __start(int __rambase, int __ramsize,
		int __rombase, int __romsize, int __confbase, int __confsize)
	{
		// Initialize the RAM links to setup dirty bits and initialize the
		// last block of memory with anything that remains. This makes it so
		// the RAM is actually useable.
		Allocator.__initRamLinks(__rambase, __ramsize);
		
		// Could crash!
		try
		{
			// Initialize kernel thread, since there has to be a thread
			// reference for classes to work!
			ThreadManager thm = Globals.getThreadManager();
			Assembly.specialSetThreadRegister(Assembly.objectToPointer(
				thm.BOOT_THREAD));
			
			// Initialize config reader
			ConfigReader config = new ConfigReader(__confbase);
			
			// Basic SquirrelJME Banner
			todo.DEBUG.note("SquirrelJME Run-Time 0.3.0");
			todo.DEBUG.note("VM: %s %s",
				config.loadString(ConfigRomType.JAVA_VM_NAME),
				config.loadString(ConfigRomType.JAVA_VM_VERSION));
			todo.DEBUG.note("(C) %s",
				config.loadString(ConfigRomType.JAVA_VM_VENDOR));
			todo.DEBUG.note("RAM/ROM (bytes): %d/%d", __ramsize, __romsize);
			
			// Spacer
			todo.DEBUG.note("");
			
			// Load system call handler
			TaskSysCallHandler.initTaskHandler(config);
			
			// Get the task manager
			TaskManager ctm = Globals.getTaskManager();
			
			// Start the initial task
			todo.DEBUG.note("Creating initial task...");
			TaskCreateResult boot = ctm.newTask(
				BootRom.initialClasspath(__rombase, config),
				BootRom.initialMain(__rombase, config),
				BootRom.initialIsMidlet(__rombase, config),
				config.loadStrings(ConfigRomType.MAIN_ARGUMENTS),
				config.loadKeyValueMap(ConfigRomType.DEFINE_PROPERTY));
			todo.DEBUG.note("Okay.");
			
			// Set the kernel as booted okay!
			todo.DEBUG.note("Appears things are going well?");
			Assembly.sysCall(SystemCallIndex.SUPERVISOR_BOOT_OKAY);
			
			// Enter the main task now, since we can do that!
			todo.DEBUG.note("Entering main method!");
			boot.thread.execute(boot.mainclass, boot.mainmethodname,
				boot.mainmethodtype, boot.callargs);
			
			// Finished? Just terminate then
			todo.DEBUG.note("Main program finished execution, terminating!");
			Assembly.sysCallP(SystemCallIndex.EXIT, 0);
		}
		
		// It crashes
		catch (Throwable t)
		{
			// Put code in saying this happened
			todo.DEBUG.code('X', 'X');
			
			// Print the trace
			try
			{
				// Print stack trace for this class
				t.printStackTrace();
			}
			
			// Double fault?!?!?! SOMETHING IS VERY WRONG!
			catch (Throwable u)
			{
				// Show double fault info
				todo.DEBUG.code('D', 'F',
					Assembly.specialGetExceptionRegister());
				todo.DEBUG.code('x', 'T',
					Assembly.objectToPointer(t));
			}
			
			// Try to exit the VM
			Assembly.sysCallP(SystemCallIndex.EXIT, 1);
			
			// If that did not work, just break and return!
			Assembly.breakpoint();
			return;
		}
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/CallStackItem.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 single item within the call stack request.
 *
 * @since 2019/06/16
 */
public interface CallStackItem
{
	/** The class name. */
	public static final byte CLASS_NAME =
		0;
	
	/** The method name. */
	public static final byte METHOD_NAME =
		1;
	
	/** The method type. */
	public static final byte METHOD_TYPE =
		2;
	
	/** The current file. */
	public static final byte SOURCE_FILE =
		3;
	
	/** Source line. */
	public static final byte SOURCE_LINE =
		4;
	
	/** The PC address. */
	public static final byte PC_ADDRESS =
		5;
	
	/** Java operation. */
	public static final byte JAVA_OPERATION =
		6;
	
	/** Java PC address. */
	public static final byte JAVA_PC_ADDRESS =
		7;
	
	/** The current task ID. */
	public static final byte TASK_ID =
		8;
	
	/** The number of supported items. */
	public static final byte NUM_ITEMS =
		9;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/ClassInfo.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 contains class information which is used to define the information
 * that is needed to parse it properly.
 *
 * @since 2019/05/25
 */
public final class ClassInfo
{
	/** The magic number which should be used. */
	public static final int MAGIC_NUMBER =
		0x4C6F7665;
	
	/** Self pointer. */
	public final int selfptr;
	
	/** Magic number used to detect corruption. */
	public final int magic;
	
	/** Class information flags. */
	public final int flags;
	
	/** The pointer to the minimized class file. */
	public final int miniptr;
	
	/** The pointer to the class name. */
	public final int namep;
	
	/** The allocation size of this class. */
	public final int size;
	
	/** The base offset for fields in this class. */
	public final int base;
	
	/** The number of objects in the instance fields, for GC. */
	public final int numobjects;
	
	/** The dimensions this class uses, if it is an array. */
	public final int dimensions;
	
	/** The cell size of components if this is an array. */
	public final int cellsize;
	
	/** The super class data. */
	public final ClassInfo superclass;
	
	/** Interfaces. */
	public final ClassInfo[] interfaceclasses;
	
	/** The component class. */
	public final ClassInfo componentclass;
	
	/** Pointer to the class object. */
	public final Class<?> classobjptr;
	
	/** Virtual invoke VTable. */
	public final int[] vtablevirtual;
	
	/** Virtual invoke VTable pool entries. */
	public final int[] vtablepool;
	
	/** The pointer to the constant pool of this class. */
	public final int pool;
	
	/** The JAR this class is a part of. */
	public final int jardx;
	
	/** The total method count. */
	public final int nummethods;
	
	/** The depth of this class. */
	public final int classdepth;
	
	/** The static field pointer offset for the class. */
	public final int sfoffset;
	
	/** The pointer of the default constructor. */
	public final int defaultnew;
	
	/**
	 * Class information constructor.
	 *
	 * @param __sp Self pointer.
	 * @param __fl Class information flags.
	 * @param __minip Pointer to the hardware class data in ROM.
	 * @param __namep The name pointer.
	 * @param __sz The size of this class.
	 * @param __bz The base offset for fields.
	 * @param __no The number of objects in the field instance.
	 * @param __dim Dimensions.
	 * @param __csz Cell size.
	 * @param __scl The super class data.
	 * @param __icl Interface classes.
	 * @param __ccl Component class.
	 * @param __cop Pointer to the class object.
	 * @param __vtv Virtual invoke VTable address.
	 * @param __vtp Virtual invoke VTable pool addresses.
	 * @param __pool The pointer to the class constant pool.
	 * @param __jardx The JAR Index.
	 * @param __nm The number of methods that are used.
	 * @param __cd The class depth.
	 * @param __sfp The static field offset.
	 * @param __dn The default constructor.
	 * @since 2019/04/26
	 */
	public ClassInfo(int __sp, int __fl, int __minip, int __namep, int __sz,
		int __bz, int __no, int __dim, int __csz, ClassInfo __scl,
		ClassInfo[] __icl, ClassInfo __ccl, Class<?> __cop, int[] __vtv,
		int[] __vtp, int __pool, int __jardx, int __nm, int __cd, int __sfp,
		int __dn)
	{
		// Always implicitly set magic
		this.magic = MAGIC_NUMBER;
		
		// Set
		this.selfptr = __sp;
		this.flags = __fl;
		this.miniptr = __minip;
		this.namep = __namep;
		this.size = __sz;
		this.base = __bz;
		this.numobjects = __no;
		this.dimensions = __dim;
		this.cellsize = __csz;
		this.superclass = __scl;
		this.interfaceclasses = (__icl == null ? new ClassInfo[0] : __icl);
		this.componentclass = __ccl;
		this.classobjptr = __cop;
		this.vtablevirtual = (__vtv == null ? new int[0] : __vtv);
		this.vtablepool = (__vtp == null ? new int[0] : __vtp);
		this.pool = __pool;
		this.jardx = __jardx;
		this.nummethods = __nm;
		this.classdepth = __cd;
		this.sfoffset = __sfp;
		this.defaultnew = __dn;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/ClassLoadingAdjustments.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Adjustments to class loading.
 *
 * @since 2019/12/15
 */
public final class ClassLoadingAdjustments
{
	/**
	 * Is this class deferred loaded?
	 *
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __cl)
		throws NullPointerException
	{
		switch (__cl)
		{
				// Primitive types
			case "boolean":
			case "byte":
			case "short":
			case "char":
			case "int":
			case "float":
			case "long":
			case "double":
			
				// Primitive array types
			case "[Z":
			case "[B":
			case "[S":
			case "[C":
			case "[I":
			case "[F":
			case "[J":
			case "[D":
				
				// Common Java objects
			case "java/io/IOException":
			case "java/io/PrintStream":
			case "java/lang/Appendable":
			case "java/lang/ArithmeticException":
			case "java/lang/ArrayIndexOutOfBoundsException":
			case "java/lang/AssertionError":
			case "java/lang/AutoCloseable":
			case "java/lang/Boolean":
			case "java/lang/Byte":
			case "java/lang/Character":
			case "java/lang/Class":
			case "java/lang/ClassCastException":
			case "java/lang/Cloneable":
			case "java/lang/Closeable":
			case "java/lang/Comparable":
			case "java/lang/Double":
			case "java/lang/Enum":
			case "java/lang/Error":
			case "java/lang/Float":
			case "java/lang/IllegalArgumentException":
			case "java/lang/IllegalMonitorStateException":
			case "java/lang/IllegalStateException":
			case "java/lang/IllegalThreadStateException":
			case "java/lang/IndexOutOfBoundsException":
			case "java/lang/Integer":
			case "java/lang/InterruptedException":
			case "java/lang/Long":
			case "java/lang/Math":
			case "java/lang/NegativeArraySizeException":
			case "java/lang/NoClassDefFoundError":
			case "java/lang/NoSuchElementException":
			case "java/lang/NullPointerException":
			case "java/lang/Number":
			case "java/lang/Object":
			case "java/lang/OutOfMemoryError":
			case "java/lang/Runtime":
			case "java/lang/RuntimeException":
			case "java/lang/Short":
			case "java/lang/String":
			case "java/lang/StringBuffer":
			case "java/lang/StringBuilder":
			case "java/lang/StringIndexOutOfBoundsException":
			case "java/lang/System":
			case "java/lang/Thread":
			case "java/lang/Throwable":
			case "java/lang/VirtualMachineError":
			case "java/lang/ref/Reference":
			case "java/lang/ref/ReferenceQueue":
			case "java/lang/ref/WeakReference":
			case "java/util/Deque":
			case "java/util/Formatter":
			case "java/util/Iterable":
			case "java/util/Iterator":
			case "java/util/List":
			case "java/util/Map":
			case "java/util/Objects":
			case "java/util/Queue":
			case "java/util/Random":
			case "java/util/Set":
			
				// SquirrelJME special classes
			case "cc/squirreljme/jvm/Assembly":
			case "cc/squirreljme/jvm/ClassInfo":
			case "cc/squirreljme/jvm/Constants":
			case "cc/squirreljme/jvm/IPCCallback":
			case "cc/squirreljme/jvm/IPCException":
			case "cc/squirreljme/jvm/IPCManager":
			case "cc/squirreljme/jvm/JVMFunction":
			case "cc/squirreljme/jvm/SoftDouble":
			case "cc/squirreljme/jvm/SoftFloat":
			case "cc/squirreljme/jvm/SoftInteger":
			case "cc/squirreljme/jvm/SoftLong":
			case "cc/squirreljme/jvm/SystemCallError":
			case "cc/squirreljme/jvm/SystemCallIndex":
			
				// Common array classes
			case "[Lcc/squirreljme/jvm/ClassInfo;":
			case "[Ljava/lang/String;":
				return false;
				
			default:
				return true;
		}
	}
	
	/**
	 * Is this class deferred loaded in relation to the current class?
	 *
	 * @param __self The current class.
	 * @param __cl The class to check.
	 * @return If the class is deferred loaded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public static final boolean isDeferredLoad(String __self, String __cl)
		throws NullPointerException
	{
		if (__self == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Same class is never deferred
		if (__self.equals(__cl))
			return false;
		
		// Is within the same package?
		int ls = __self.lastIndexOf('/');
		if (ls >= 0 && __self.regionMatches(0, __cl, 0, ls))
			return false;
		
		// Use default defer logic
		return ClassLoadingAdjustments.isDeferredLoad(__cl);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/ConfigReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233









































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is a helper class used to read the configuration.
 *
 * @since 2019/06/22
 */
public final class ConfigReader
{
	/** The configuration base. */
	protected final int configbase;
	
	/**
	 * Initializes the configuration reader.
	 *
	 * @param __configbase The configuration base.
	 * @since 2019/06/22
	 */
	public ConfigReader(int __configbase)
	{
		this.configbase = __configbase;
	}
	
	/**
	 * Loads a key/value mapping of the given key, the resulting array will
	 * always be even and be key/value pairs.
	 *
	 * @param __key The key to locate.
	 * @return The resulting map, will be an empty array if no values were
	 * found.
	 * @since 2019/06/22
	 */
	public final String[] loadKeyValueMap(int __key)
	{
		// Configuration scanner
		int scanner = 0;
		
		// Count the number of key/values used
		int n = 0;
		while ((scanner = this.scan(__key, scanner)) != 0)
			n++;
		
		// Setup resulting array to store twice the values!
		n *= 2;
		String[] rv = new String[n];
		
		// Load in all values
		scanner = 0;
		for (int i = 0; i < n; i += 2)
		{
			// Scan for next item
			scanner = this.scan(__key, scanner);
			
			// Copy data pointer
			int dp = scanner;
			
			// Load the key
			int kl = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
			rv[i] = JVMFunction.jvmLoadString(dp);
			
			// Skip
			dp += kl + 2;
			
			// Load the value
			rv[i + 1] = JVMFunction.jvmLoadString(dp);
		}
		
		// Done!
		return rv;
	}
	
	/**
	 * Loads the given integer.
	 *
	 * @param __key The key to load.
	 * @return The resulting value or {@code 0} if not set.
	 * @since 2019/10/05
	 */
	public final int loadInteger(int __key)
	{
		int addr = this.search(__key);
		return (addr == 0 ? 0 : Assembly.memReadJavaInt(addr, 0));
	}
	
	/**
	 * Loads the given string for the given key.
	 *
	 * @param __key The key to load.
	 * @return The resulting string or {@code null} if it is not set.
	 * @since 2019/06/22
	 */
	public final String loadString(int __key)
	{
		return JVMFunction.jvmLoadString(this.search(__key));
	}
	
	/**
	 * Loads multiple string values.
	 *
	 * @param __key The key to locate.
	 * @return The resulting string values or {@code null} if there are none.
	 * @since 2019/06/22
	 */
	public final String[] loadStrings(int __key)
	{
		// Locate the key pointer
		int dp = this.search(__key);
		if (dp == 0)
			return null;
		
		// Read string count
		int n = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
		dp += 2;
		
		// Build resulting array
		String[] rv = new String[n];
		for (int i = 0; i < n; i++)
		{
			// Need to read the string length for skipping
			int strlen = Assembly.memReadJavaShort(dp, 0) & 0xFFFF;
			
			// Decode and store string
			rv[i] = JVMFunction.jvmLoadString(dp);
			
			// Skip
			dp += strlen + 2;
		}
		
		// Use this
		return rv;
	}
	
	/**
	 * Scans through the configuration space.
	 *
	 * @param __key The key to locate.
	 * @param __at The current at position of the scanner, {@code 0} will
	 * start a new search.
	 * @return The value pointer of the given item, or {@code 0} if there are
	 * no more entries.
	 * @since 2019/06/22
	 */
	public final int scan(int __key, int __at)
	{
		// Where do we start the search from? From the start?
		int seeker;
		if (__at == 0)
			seeker = this.configbase;
		
		// Otherwise, since we parked on a currently found item, we have to
		// go back and skip over it
		else
		{
			// Place the seeker at the config slot base
			seeker = __at - Constants.CONFIG_HEADER_SIZE;
			
			// If we just happened to be planted at the end, just stop
			if (Assembly.memReadJavaShort(seeker,
				Constants.CONFIG_KEY_OFFSET) == ConfigRomType.END)
				return 0;
			
			// Otherwise, skip to the next entry start
			seeker += Constants.CONFIG_HEADER_SIZE + Assembly.memReadJavaShort(
				seeker, Constants.CONFIG_SIZE_OFFSET);
		}
		
		// Constant scanning loop for the next item
		for (;;)
		{
			// Read the key
			int key = Assembly.memReadJavaShort(seeker,
				Constants.CONFIG_KEY_OFFSET);
			
			// Stop at the end
			if (key == ConfigRomType.END)
				return 0;
			
			// If the key matches then return the value
			if (key == __key)
				return seeker + Constants.CONFIG_HEADER_SIZE;
			
			// Otherwise skip to the next entry
			seeker += Constants.CONFIG_HEADER_SIZE + Assembly.memReadJavaShort(
				seeker, Constants.CONFIG_SIZE_OFFSET);
		}
	}
	
	/**
	 * Searches the configuration space for the given key and returns it's
	 * value.
	 *
	 * @param __key The key to search for.
	 * @return The pointer to the configuration value or {@code 0} if it was
	 * not found.
	 * @since 2019/06/19
	 */
	public final int search(int __key)
	{
		// Seek through items
		for (int seeker = this.configbase;;)
		{
			// Read key and size
			int key = Assembly.memReadJavaShort(seeker,
					Constants.CONFIG_KEY_OFFSET),
				len = Assembly.memReadJavaShort(seeker,
					Constants.CONFIG_SIZE_OFFSET) & 0xFFFF;
			
			// Stop?
			if (key == ConfigRomType.END)
				break;
			
			// Found here?
			if (key == __key)
				return seeker + Constants.CONFIG_HEADER_SIZE;
			
			// Skip otherwise
			seeker += Constants.CONFIG_HEADER_SIZE + len;
		}
		
		// Not found
		return 0;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/ConfigRomType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 an option in the configuration ROM.
 *
 * @since 2019/06/14
 */
public interface ConfigRomType
{
	/** End of configuration. */
	public static final byte END =
		0;
	
	/** Java VM Version. */
	public static final byte JAVA_VM_VERSION =
		1;
	
	/** Java VM Name. */
	public static final byte JAVA_VM_NAME =
		2;
	
	/** Java VM Vendor. */
	public static final byte JAVA_VM_VENDOR =
		3;
	
	/** Java VM E-Mail. */
	public static final byte JAVA_VM_EMAIL =
		4;
	
	/** Java VM URL. */
	public static final byte JAVA_VM_URL =
		5;
	
	/** The guest depth. */
	public static final byte GUEST_DEPTH =
		6;
	
	/** Main class. */
	public static final byte MAIN_CLASS =
		7;
	
	/** Main program arguments. */
	public static final byte MAIN_ARGUMENTS =
		8;
	
	/** Is this a MIDlet? */
	public static final byte IS_MIDLET =
		9;
	
	/** Define system propertly. */
	public static final byte DEFINE_PROPERTY =
		10;
	
	/** Classpath to use. */
	public static final byte CLASS_PATH =
		11;
	
	/** System call static field pointer. */
	public static final byte SYSCALL_STATIC_FIELD_POINTER =
		12;
	
	/** System call method pointer. */
	public static final byte SYSCALL_CODE_POINTER =
		13;
	
	/** System call pool pointer. */
	public static final byte SYSCALL_POOL_POINTER =
		14;
	
	/** Number of available options. */
	public static final byte NUM_OPTIONS =
		15;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Constants.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Virtual machine constants.
 *
 * @since 2019/05/26
 */
public interface Constants
{
	/** The offset for the object's class type. */
	public static final byte OBJECT_CLASS_OFFSET =
		0;
	
	/** The offset for the object's reference count. */
	public static final byte OBJECT_COUNT_OFFSET =
		4;
	
	/** Object monitor owner offset. */
	public static final byte OBJECT_MONITOR_OFFSET =
		8;
	
	/** Object monitor count offset. */
	public static final byte OBJECT_MONITOR_COUNT_OFFSET =
		12;
	
	/** Base size for object types. */
	public static final byte OBJECT_BASE_SIZE =
		16;
	
	/** The offset for array length. */
	public static final byte ARRAY_LENGTH_OFFSET =
		16;
	
	/** The base size for arrays. */
	public static final byte ARRAY_BASE_SIZE =
		20;
	
	/** Constant pool cell size. */
	public static final byte POOL_CELL_SIZE =
		4;
	
	/** Bad magic number. */
	public static final int BAD_MAGIC =
		0xE7E5E7E4;
	
	/** Class info flag: Is array type? */
	public static final short CIF_IS_ARRAY =
		0x0001;
	
	/** Class info flag: Is array of objects? */
	public static final short CIF_IS_ARRAY_OF_OBJECTS =
		0x0002;
	
	/** Is this a primitive type? */
	public static final short CIF_IS_PRIMITIVE =
		0x0004;
	
	/** Offset for the configuration key. */
	public static final byte CONFIG_KEY_OFFSET =
		0;
	
	/** Offset for the configuration size. */
	public static final byte CONFIG_SIZE_OFFSET =
		2;
	
	/** Size of the header for configuration items. */
	public static final byte CONFIG_HEADER_SIZE =
		4;
	
	/** The thread ID for out-of-bound IPC events. */
	public static final int OOB_IPC_THREAD =
		0xFFFFFFFF;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/DeviceFeedbackType.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 the type of feedback to perform for a device.
 *
 * @since 2019/10/05
 */
public interface DeviceFeedbackType
{
	/** Vibrate. */
	public static final byte VIBRATE =
		1;
	
	/** Blink/Pulse LED, be aware of conditions such as epilepsy. */
	public static final byte BLINK_LED =
		2;
	
	/** The number of feedback types. */
	public static final byte NUM_FEEDBACK_TYPES =
		3;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Framebuffer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is used to get/set the property of the framebuffer.
 *
 * @since 2019/06/20
 */
public interface Framebuffer
{
	/**
	 * Returns the address of the framebuffer.
	 *
	 * @return The framebuffer address.
	 */
	public static final byte CONTROL_ADDRESS =
		1;
	
	/**
	 * Returns the width of the framebuffer.
	 *
	 * @return The framebuffer width.
	 */
	public static final byte CONTROL_WIDTH =
		2;
	
	/**
	 * Returns the height of the framebuffer.
	 *
	 * @return The framebuffer height.
	 */
	public static final byte CONTROL_HEIGHT =
		3;
	
	/**
	 * Returns the scanline length.
	 *
	 * @return The framebuffer scanline length.
	 */
	public static final byte CONTROL_SCANLEN =
		4;
	
	/**
	 * Flush the display because it has been drawn.
	 */
	public static final byte CONTROL_FLUSH =
		5;
	
	/**
	 * Returns the pixel format of the screen.
	 *
	 * @return The pixel format of the screen.
	 */
	public static final byte CONTROL_FORMAT =
		6;
	
	/**
	 * Returns the scanline length in bytes.
	 *
	 * @return The scanline length in bytes.
	 */
	public static final byte CONTROL_SCANLEN_BYTES =
		7;
	
	/**
	 * Returns the number of bytes per pixel.
	 *
	 * @return The bytes per pixel.
	 */
	public static final byte CONTROL_BYTES_PER_PIXEL =
		8;
	
	/**
	 * Returns the number of available pixels.
	 *
	 * @return The number of pixels.
	 */
	public static final byte CONTROL_NUM_PIXELS =
		9;
	
	/**
	 * Bits per pixel.
	 *
	 * @return The bits per pixel.
	 */
	public static final byte CONTROL_BITS_PER_PIXEL =
		10;
	
	/**
	 * Get backlight level.
	 *
	 * @return The current backlight level.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_GET =
		11;
	
	/**
	 * Set backlight level.
	 *
	 * @param 1 The level to set.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_SET =
		12;
	
	/**
	 * Maximum backlight level.
	 *
	 * @return The maximum backlight level.
	 */
	public static final byte CONTROL_BACKLIGHT_LEVEL_MAX =
		13;
	
	/**
	 * Uploads an integer array of pixel data to the framebuffer.
	 *
	 * @param 1 The address of the array to upload.
	 * @since 2019/12/21
	 */
	public static final byte CONTROL_UPLOAD_ARRAY_INT =
		14;
	
	/**
	 * The array which backs the framebuffer, if there is one.
	 *
	 * @return The backing array object, if there is one.
	 * @since 2019/12/28
	 */
	public static final byte CONTROL_BACKING_ARRAY_OBJECT =
		15;
		
	/**
	 * Returns the capabilities of the display.
	 *
	 * @return The display capabilities.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_GET_CAPABILITIES =
		16;
	
	/**
	 * Query acceleration function.
	 *
	 * @param 1 The graphics function.
	 * @return A non-zero value if this is supported.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_ACCEL_FUNC_QUERY =
		17;
	
	/**
	 * Perform acceleration function.
	 *
	 * @param 1 The graphics function.
	 * @param ... Parameters to the function.
	 * @return A value that is according to the invoked function, if it is
	 * supported or possible.
	 * @since 2020/01/10
	 */
	public static final byte CONTROL_ACCEL_FUNC_INVOKE =
		18;
	
	/**
	 * Requests that the framebuffer be repainted.
	 *
	 * @param 1 The X coordinate.
	 * @param 2 The Y coordinate.
	 * @param 3 The width.
	 * @param 4 The height.
	 * @return Returns {@code 0} if the repaint was not queued and it must be
	 * handled by the code running the application, 
	 * @since 2020/01/15
	 */
	public static final byte CONTROL_REPAINT_REQUEST =
		19;
	
	/**
	 * Sets the title of the framebuffer if applicable.
	 *
	 * @param 1 Character array buffer pointer.
	 * @since 2020/01/15
	 */
	public static final byte CONTROL_SET_TITLE =
		20;
	
	/** The number of framebuffer controls. */
	public static final byte NUM_CONTROLS =
		21;
	
	/** Screen is RGB 32-bit. */
	public static final byte FORMAT_INTEGER_RGB888 =
		0;
	
	/** Screen is 8-bit indexed. */
	public static final byte FORMAT_BYTE_INDEXED =
		1;
	
	/** Screen is 16-bit RGB565. */
	public static final byte FORMAT_SHORT_RGB565 =
		2;
	
	/** Screen is packed 1 bit values. */
	public static final byte FORMAT_PACKED_ONE =
		3;
	
	/** Screen is packed 2 bit values. */
	public static final byte FORMAT_PACKED_TWO =
		4;
	
	/** Screen is packed 4 bit values. */
	public static final byte FORMAT_PACKED_FOUR =
		5;
	
	/** Has touch-screen. */
	public static final byte CAPABILITY_TOUCH =
		0x01;
	
	/** Has keyboard. */
	public static final byte CAPABILITY_KEYBOARD =
		0x02;
	
	/** The JVM pushes to the IPC handler when events happen. */
	public static final byte CAPABILITY_IPC_EVENTS =
		0x04;
	
	/** Has screen flipping? */
	public static final byte CAPABILITY_SCREEN_FLIP =
		0x08;
	
	/** Screen has color that is not just a single shade. */
	public static final byte CAPABILITY_COLOR =
		0x10;
	
	/** Set color. */
	public static final byte ACCEL_FUNC_SET_COLOR =
		0;
	
	/** Draw line. */
	public static final byte ACCEL_FUNC_DRAW_LINE =
		1;
	
	/** Get the X clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_X =
		2;
	
	/** Get the Y clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_Y =
		3;
	
	/** Get the width clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_WIDTH =
		4;
	
	/** Get the height clip. */
	public static final byte ACCEL_FUNC_GET_CLIP_HEIGHT =
		5;
	
	/** Set the clip. */
	public static final byte ACCEL_FUNC_SET_CLIP =
		6;
	
	/** Draw rectangle. */
	public static final byte ACCEL_FUNC_DRAW_RECT =
		7;
	
	/** Get the alpha color. */
	public static final byte ACCEL_FUNC_GET_ALPHA_COLOR =
		8;
	
	/** Set the alpha color. */
	public static final byte ACCEL_FUNC_SET_ALPHA_COLOR =
		9;
	
	/** Fill rectangle. */
	public static final byte ACCEL_FUNC_FILL_RECT =
		10;
	
	/** Sets the fonts for the graphics. */
	public static final byte ACCEL_FUNC_SET_FONT =
		11;
	
	/** Gets the font to use for drawing. */
	public static final byte ACCEL_FUNC_GET_FONT =
		12;
	
	/** Draw sub-characters. */
	public static final byte ACCEL_FUNC_DRAW_SUB_CHARS =
		13;
	
	/** Draw text. */
	public static final byte ACCEL_FUNC_DRAW_TEXT =
		14;
	
	/** Get stroke style. */
	public static final byte ACCEL_FUNC_GET_STROKE_STYLE =
		15;
	
	/** Set stroke style. */
	public static final byte ACCEL_FUNC_SET_STROKE_STYLE =
		16;
	
	/** Copy area. */
	public static final byte ACCEL_FUNC_COPY_AREA =
		17;
	
	/** Draw arc. */
	public static final byte ACCEL_FUNC_DRAW_ARC =
		18;
	
	/** Draw ARGB16. */
	public static final byte ACCEL_FUNC_DRAW_ARGB16 =
		19;
	
	/** Draw character. */
	public static final byte ACCEL_FUNC_DRAW_CHAR =
		20;
	
	/** Draw characters. */
	public static final byte ACCEL_FUNC_DRAW_CHARS =
		21;
	
	/** Draw RGB. */
	public static final byte ACCEL_FUNC_DRAW_RGB =
		22;
	
	/** Draw RGB16. */
	public static final byte ACCEL_FUNC_DRAW_RGB16 =
		23;
	
	/** Draw round rectangle. */
	public static final byte ACCEL_FUNC_DRAW_ROUND_RECT =
		24;
	
	/** Fill arc. */
	public static final byte ACCEL_FUNC_FILL_ARC =
		25;
	
	/** Fill round rectangle. */
	public static final byte ACCEL_FUNC_FILL_ROUND_RECT =
		26;
	
	/** Fill triangle. */
	public static final byte ACCEL_FUNC_FILL_TRIANGLE =
		27;
	
	/** Get blending mode. */
	public static final byte ACCEL_FUNC_GET_BLENDING_MODE =
		28;
	
	/** Get display color. */
	public static final byte ACCEL_FUNC_GET_DISPLAY_COLOR =
		29;
	
	/** Set blending mode. */
	public static final byte ACCEL_FUNC_SET_BLENDING_MODE =
		30;
	
	/** Draw region. */
	public static final byte ACCEL_FUNC_DRAW_REGION =
		31;
	
	/** Number of acceleration functions. */
	public static final byte NUM_ACCEL_FUNC =
		32;
	
	/** The IPC ID for the graphics callbacks. */
	public static final int IPC_ID =
		0x47665821;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/Globals.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.jvm.task.TaskManager;
import cc.squirreljme.jvm.task.ThreadManager;

/**
 * This class contains all of the globals which are used by the supervisor.
 *
 * @since 2019/10/06
 */
public final class Globals
{
	/** Manager for tasks. */
	private static TaskManager _TASK_MANAGER;
	
	/** The thread manager. */
	private static ThreadManager _THREAD_MANAGER;
	
	/**
	 * Not used.
	 *
	 * @since 2019/10/06
	 */
	private Globals()
	{
	}
	
	/**
	 * Gets the task manager.
	 *
	 * @return The task manager.
	 * @since 2019/10/06
	 */
	public static final TaskManager getTaskManager()
	{
		TaskManager rv = Globals._TASK_MANAGER;
		if (rv == null)
			Globals._TASK_MANAGER = (rv = new TaskManager());
		return rv;
	}
	
	/**
	 * Gets the thread manager.
	 *
	 * @return The thread manager.
	 * @since 2019/10/13
	 */
	public static final ThreadManager getThreadManager()
	{
		ThreadManager rv = Globals._THREAD_MANAGER;
		if (rv == null)
			Globals._THREAD_MANAGER = (rv = new ThreadManager());
		return rv;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/IPCException.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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 is an exception which was thrown in a cross RPC call.
 *
 * @since 2019/12/28
 */
public class IPCException
	extends RuntimeException
{
	/** The class name note pointer. */
	protected final int classnotepointer;
	
	/**
	 * Initializes the exception with an unknown type.
	 *
	 * @since 2019/12/28
	 */
	public IPCException()
	{
		this.classnotepointer = 0;
	}
	
	/**
	 * Initializes the IPC Exception.
	 *
	 * @param __cnp The class note pointer which was used.
	 * @since 2019/12/28
	 */
	public IPCException(int __cnp)
	{
		this.classnotepointer = __cnp;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/JVMFunction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 class contains the functions of the virtual machine.
 *
 * @since 2019/05/25
 */
public final class JVMFunction
{
	/** The task ID. */
	static final byte _TASK_ID =
		0;
	
	/** Last error state. */
	static volatile int _LAST_ERROR;
	
	/**
	 * 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
	 * be returned, otherwise {@code 0} will.
	 * @since 2019/04/27
	 */
	public static final int jvmCanArrayStore(int __p, int __v)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC || __v == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Can always store null values
		if (__v == 0)
			return 1;
		
		// Get array class info
		int aip = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		ClassInfo aicl = Assembly.pointerToClassInfo(aip);
		
		// Check if the value we are putting in is an instance of the given
		// class component type
		return JVMFunction.jvmIsInstance(__v, aicl.componentclass.selfptr);
	}
	
	/**
	 * Returns the component type of the array
	 *
	 * @param __clid The class ID
	 * @return The component type of the array or {@code 0} if it is not an
	 * array.
	 * @since 2019/04/27
	 */
	public static final int jvmComponentType(int __clid)
	{
		// Access of invalid class?
		if (__clid == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Performs aggressive garbage collection of the JVM heap to free as much
	 * memory as possible.
	 *
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollect()
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Garbage collects a single object.
	 *
	 * @param __p The object to garbage collect.
	 * @since 2019/04/25
	 */
	public static final void jvmGarbageCollectObject(int __p)
	{
		// Access of invalid object?
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Report this code!
		int nref = Assembly.memReadInt(__p, Constants.OBJECT_COUNT_OFFSET);
		if (nref < 0)
		{
			// Report to the console this happened
			todo.DEBUG.code('G', 'C', __p);
			todo.DEBUG.code('G', '#', nref);
			
			// Break here, since this is not good
			Assembly.breakpoint();
			
			// Stop here
			return;
		}
		
		// Attempt to garbage collect object with no class or is invalid
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// {@squirreljme.error SV0i Garbage collecting an object which is
		// currently locked by a thread.}
		if (0 != Assembly.atomicCompareGetAndSet(0, 0,
			__p + Constants.OBJECT_MONITOR_OFFSET))
			throw new VirtualMachineError("SV0i");
		
		// Get class info for this type
		ClassInfo pinfo = Assembly.pointerToClassInfo(pcl);
		
		// If this is an array, elements have to be uncounted
		// Instance fields can be skipped for non-object arrays
		if ((pinfo.flags & Constants.CIF_IS_ARRAY) != 0)
		{
			// This only needs to be done for objects
			if ((pinfo.flags & Constants.CIF_IS_ARRAY_OF_OBJECTS) != 0)
			{
				// Go through all elements and uncount them
				int n = Assembly.memReadInt(__p,
					Constants.ARRAY_LENGTH_OFFSET);
				for (int i = 0, bp = __p + Constants.ARRAY_BASE_SIZE, xp = 0;
					i < n; i++, xp += 4)
					Assembly.refUncount(Assembly.memReadInt(bp, xp));
			}
		}
		
		// Otherwise uncount the instance field information
		else
		{
			// Go through all classes in the class chain
			for (ClassInfo ro = pinfo; ro != null; ro = ro.superclass)
			{
				// Actual base position for the objects in the instances
				int rbase = __p + ro.base;
				
				// Clear all offsets in the object
				int rnobj = ro.numobjects;
				for (int i = 0, px = 0; i < rnobj; i++, px += 4)
					Assembly.refUncount(Assembly.memReadInt(rbase, px));
			}
		}
		
		// Free this memory
		Allocator.free(__p);
	}
	
	/**
	 * Initializes the given class.
	 *
	 * @param __ns The noted string.
	 * @return The loaded class info.
	 * @since 2019/12/15
	 */
	public static final ClassInfo jvmInitClass(int __ns)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Searches the interface vtables for the class of object {@code __p}
	 * and searches for an interface implementation of class {@code __icl} and
	 * if one is found then the pointer for index {@code __mdx} is returned.
	 *
	 * @param __p The object to do a interface lookup on.
	 * @param __icl The interface class to find.
	 * @param __mdx The method index to relate to, of the interface class.
	 * @return The pointer to the code to be invoked in the low-word and the
	 * pool of the target class in the high-word.
	 * @since 2019/04/30
	 */
	public static final long jvmInterfacePointer(int __p, int __icl, int __mdx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		Assembly.breakpoint();
		throw new todo.TODO();
		// Assembly.longPack(hi, lo)
	}
	
	/**
	 * Checks whether the given pointer is an array.
	 *
	 * @param __p The pointer to check.
	 * @return Either {@code 1} if it is an array or {@code 0} if it is not.
	 * @since 2019/04/27
	 */
	public static final int jvmIsArray(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Checks whether the given pointer is an instance of the given class.
	 *
	 * @param __p The pointer to check.
	 * @param __cldx The class type to check.
	 * @return Either {@code 1} if the class is an instance or {@code 0} if
	 * it is not.
	 * @since 2019/04/22
	 */
	public static final int jvmIsInstance(int __p, int __cldx)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Not instance of null class
		if (__p == 0)
			return 0;
		
		// If the object's class type is a direct match then quickly return
		int pcl = Assembly.memReadInt(__p, Constants.OBJECT_CLASS_OFFSET);
		if (pcl == __cldx)
			return 1;
		
		// Corrupted object?
		if (pcl == 0 || pcl == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Scan through super classes and check
		ClassInfo mine = Assembly.pointerToClassInfo(pcl);
		for (ClassInfo seek = mine; seek != null; seek = seek.superclass)
		{
			// Get self pointer
			int selfptr = seek.selfptr;
			
			// Make sure we are not reading bad memory
			if (selfptr == Constants.BAD_MAGIC)
			{
				Assembly.breakpoint();
				throw new VirtualMachineError();
			}
			
			// Same as this one?
			if (selfptr == __cldx)
				return 1;
			
			// See if our class or any of our super class implemented
			// interfaces matches the target class
			for (ClassInfo xface : mine.interfaceclasses)
			{
				int ifaceptr = xface.selfptr;
				
				// Make sure we are not reading bad memory
				if (ifaceptr == Constants.BAD_MAGIC)
				{
					Assembly.breakpoint();
					throw new VirtualMachineError();
				}
				
				// Is a match?
				if (ifaceptr == __cldx)
					return 1;
			}
		}
		
		// Not a match
		return 0;
	}
	
	/**
	 * Returns the {@link Class} instance for the given class info pointer,
	 * if none has been created yet then it will be created as needed.
	 *
	 * @param <T> The class type.
	 * @param __cldx The class index pointer.
	 * @return The resulting class.
	 * @since 2019/05/26
	 */
	public static final <T> Class<T> jvmLoadClass(int __cldx)
	{
		// Access of invalid class?
		if (__cldx == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Loads a string from memory and returns an `intern()` string value.
	 *
	 * @param __p The pointer to load the string bytes from.
	 * @return The resulting and interned string.
	 * @since 2019/05/26
	 */
	public static final String jvmLoadString(int __p)
	{
		// If a null pointer was just requested, then treat as null
		if (__p == 0)
			return null;
		
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Read length of the raw bytes
		int rawlen = Assembly.memReadJavaShort(__p, 0) & 0xFFFF;
		
		// Load the string data into bytes
		byte[] bytes = new byte[rawlen];
		for (int i = 0, base = __p + 2; i < rawlen; i++)
			bytes[i] = (byte)Assembly.memReadByte(base, i);
		
		// Initialize, but do not intern the string even though that is the
		// expected result of the JVM. It just keeps the strings sticking
		// around in the supervisor when they could be freed.
		return new String(bytes);
	}
	
	/**
	 * Reads a long value from the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @return The read value.
	 * @since 2019/05/29
	 */
	public static final long jvmMemReadLong(int __addr, int __off)
	{
		// Big endian!
		if (Assembly.sysCallPV(SystemCallIndex.BYTE_ORDER_LITTLE) == 0)
			return Assembly.longPack(
				Assembly.memReadInt(__addr, __off),
				Assembly.memReadInt(__addr + 4, __off));
		
		// Little endian!
		else
			return Assembly.longPack(
				Assembly.memReadInt(__addr + 4, __off),
				Assembly.memReadInt(__addr, __off));
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __hv The high value.
	 * @param __lv The low value.
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, int __hv,
		int __lv)
	{
		// Big endian!
		if (Assembly.sysCallPV(SystemCallIndex.BYTE_ORDER_LITTLE) == 0)
		{
			Assembly.memWriteInt(__addr, __off, __hv);
			Assembly.memWriteInt(__addr + 4, __off, __lv);
		}
		
		// Little endian!
		else
		{
			Assembly.memWriteInt(__addr + 4, __off, __hv);
			Assembly.memWriteInt(__addr, __off, __lv);
		}
	}
	
	/**
	 * Writes a long value to the given address
	 *
	 * @param __addr The address to access.
	 * @param __off The address offset.
	 * @param __v The value
	 * @since 2019/05/29
	 */
	public static final void jvmMemWriteLong(int __addr, int __off, long __v)
	{
		JVMFunction.jvmMemWriteLong(__addr, __off,
			Assembly.longUnpackHigh(__v), Assembly.longUnpackLow(__v));
	}
	
	/**
	 * Enters the monitor for the given object.
	 *
	 * @param __p The object to enter.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorEnter(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// {@squirreljme.error SV0b Cannot enter the monitor of a null object.}
		if (__p == 0)
			throw new NullPointerException("SV0b");
		
		// Get our own thread ID
		int ourtid = Assembly.specialGetThreadRegister();
		
		// {@squirreljme.error SV0d Current thread does not have a thread
		// identifier?}
		if (ourtid == 0)
			throw new VirtualMachineError("SV0d");
		
		// Wait for the lock to happen, we spin-lock in the supervisor so
		// that locking actions are a bit more responsive since they should
		// not be locked for long
		for (int lockp = __p + Constants.OBJECT_MONITOR_OFFSET;;)
		{
			// If we try to set the value and it happens to be 0 (nobody was
			// locking this object) or our thread ID (we already own it) then
			// stop and leave the loop
			int oldv = Assembly.atomicCompareGetAndSet(0, ourtid, lockp);
			if (oldv == 0 || oldv == ourtid)
				break;
		}
		
		// Since we own this lock, count the lock count up
		Assembly.atomicIncrement(__p + Constants.OBJECT_MONITOR_COUNT_OFFSET);
	}
	
	/**
	 * Exits the monitor for the given object.
	 *
	 * @param __p The object to exit.
	 * @since 2019/04/26
	 */
	public static final void jvmMonitorExit(int __p)
	{
		// Access of invalid object?
		if (__p == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// {@squirreljme.error SV0c Cannot exit the monitor of a null object.}
		if (__p == 0)
			throw new NullPointerException("SV0c");
			
		// Get our own thread ID
		int ourtid = Assembly.specialGetThreadRegister();
		
		// {@squirreljme.error SV0e Current thread does not have a thread
		// identifier?}
		if (ourtid == 0)
			throw new VirtualMachineError("SV0e");
		
		// We can only mess with our counter if we own the lock itself, so
		// compare against our own thread and only allow this to be done if
		// it matches our own
		int lkp = __p + Constants.OBJECT_MONITOR_OFFSET;
		int oldv = Assembly.atomicCompareGetAndSet(ourtid, ourtid, lkp);
		
		// {@squirreljme.error SV0f Current thread does not own the monitor
		// for this object, so it cannot be unlocked.}
		if (oldv != ourtid)
			throw new IllegalMonitorStateException("SV0f");
		
		// Pointer to the lock count
		int countp = __p + Constants.OBJECT_MONITOR_COUNT_OFFSET;
		
		// We can read our current count by comparing and setting zero
		int curcount = Assembly.atomicCompareGetAndSet(0, 0, countp);
		
		// {@squirreljme.error SV0g Too many monitor exits on objects.}
		if (curcount <= 0)
			throw new IllegalMonitorStateException("SV0g");
		
		// Reduce the count accordingly, if we reach zero we clear the lock
		if (Assembly.atomicDecrementAndGet(countp) == 0)
			if (ourtid != Assembly.atomicCompareGetAndSet(ourtid, 0, lkp))
			{
				// {@squirreljme.error SV0h The owning thread for the object
				// was changed during unlock?}
				throw new IllegalMonitorStateException("SV0h");
			}
	}
	
	/**
	 * Allocates a new object.
	 *
	 * @param __cl The class type.
	 * @return The resulting class pointer.
	 * @since 2019/05/24
	 */
	public static final int jvmNew(int __cl)
	{
		// Access of invalid class?
		if (__cl == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Cannot allocate a null class
		if (__cl == 0)
			Assembly.breakpoint();
		
		// Get the class information for the object to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__cl);
		
		// Allocate the memory
		int rv = Allocator.allocate(
			_TASK_ID | Allocator.CHUNK_BIT_IS_OBJECT, info.size);
		if (rv == 0)
			return 0;
		
		// Write class information with an initial count of one
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl);
		Assembly.memWriteInt(rv, Constants.OBJECT_COUNT_OFFSET,
			1);
		
		// Use this pointer
		return rv;
	}
	
	/**
	 * Allocates a new array.
	 *
	 * @param __at The array type.
	 * @param __len The length of the array.
	 * @return The resulting array pointer.
	 * @throws NegativeArraySizeException If an attempt is made to allocate
	 * an array of a negative size.
	 * @throws OutOfMemoryError If there is not enough memory left.
	 * @since 2019/04/24
	 */
	public static final int jvmNewArray(int __at, int __len)
		throws NegativeArraySizeException, OutOfMemoryError
	{
		// Access of invalid class?
		if (__at == Constants.BAD_MAGIC)
			Assembly.breakpoint();
		
		// Do not initialize null class
		if (__at == 0)
			Assembly.breakpoint();
		
		// Cannot allocate negative length
		if (__len < 0)
			return 0;
		
		// Get the class information for the array we want to allocate
		ClassInfo info = Assembly.pointerToClassInfo(__at);
		
		// Determine the actual size of allocation
		int allocsize = info.size + (info.cellsize * __len);
		
		// Allocate the memory
		int rv = Allocator.allocate(
			_TASK_ID | Allocator.CHUNK_BIT_IS_OBJECT, allocsize);
		if (rv == 0)
			return 0;
		
		// Write class information with an initial count of one
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__at);
		Assembly.memWriteInt(rv, Constants.OBJECT_COUNT_OFFSET,
			1);
		
		// Write length of array
		Assembly.memWriteInt(rv, Constants.ARRAY_LENGTH_OFFSET,
			__len);
		
		// Use this pointer
		return rv;
	}
	
	/**
	 * If this is an invoked then it just throws an exception to indicate that
	 * an illegal abstract method or unlinked method was called.
	 *
	 * @since 2019/05/26
	 */
	public static final void jvmPureVirtualCall()
	{
		Assembly.breakpoint();
		throw new VirtualMachineError();
	}
	
	/**
	 * This handles an unpure system call which may modify the behavior of
	 * any system call which needs to be done. Some system calls might not be
	 * supported by the host machine or they might not make sense (such as
	 * garbage collection), so as such this allows their behavior to modified.
	 *
	 * @param __si System call index.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static final long jvmSystemCall(short __si, int __a, int __b,
		int __c, int __d, int __e, int __f, int __g, int __h)
	{
		// Override the behavior of system calls?
		switch (__si)
		{
				// Query index, this allows system calls to be replaced
				// and implemented if the native system lacks it or there is
				// a deprecation/enhancement or otherwise
			case SystemCallIndex.QUERY_INDEX:
				switch (__a)
				{
					case SystemCallIndex.GARBAGE_COLLECT:
					case SystemCallIndex.LOAD_STRING:
						return 1;
					
						// Otherwise, check if the native system supports
					default:
						return Assembly.sysCallPVL(__si, __a);
				}
				
				// Built-in system calls may set an error state
			case SystemCallIndex.ERROR_GET:
				switch (__a)
				{
						// Use last error state
					case SystemCallIndex.LOAD_STRING:
						return JVMFunction._LAST_ERROR;
					
						// Forward otherwise
					default:
						return Assembly.sysCallPV(__si, __a);
				}
			
				// Perform garbage collection
			case SystemCallIndex.GARBAGE_COLLECT:
				JVMFunction.jvmGarbageCollect();
				return 0;
				
				// Load string
			case SystemCallIndex.LOAD_STRING:
				JVMFunction._LAST_ERROR = 0;
				return Assembly.objectToPointer(
					JVMFunction.jvmLoadString(__a));
				
				// Use native handler
			default:
				return Assembly.sysCallPVL(__si, __a, __b, __c, __d, __e, __f,
					__g, __h);
		}
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SoftDouble.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211



















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Software math operations on 64-bit double.
 *
 * @since 2019/05/24
 */
public class SoftDouble
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftDouble()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double add(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double div(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double neg(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * ORs value, used for constants.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/27
	 */
	public static double or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.doublePack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double rem(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double sub(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SoftFloat.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
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
191































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Software math operations on 32-bit floats.
 *
 * @since 2019/05/24
 */
public class SoftFloat
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftFloat()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float add(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpl(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmpg(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float div(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float mul(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float neg(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Ors a value, used for constant loading.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float or(int __a, int __b)
	{
		return Assembly.intBitsToFloat(__a | __b);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float rem(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __a A.
	 * @param __b B.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float sub(int __a, int __b)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SoftInteger.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Software integer operations.
 *
 * @since 2019/05/27
 */
public class SoftInteger
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/27
	 */
	private SoftInteger()
	{
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __a)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to long.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long toLong(int __a)
	{
		// If the integer has the sign bit, then it will be sign extended
		// meaning all the upper bits get set
		if ((__a & 0x80000000) != 0)
			return Assembly.longPack(0xFFFFFFFF, __a);
		
		// Otherwise the top is just zero
		else
			return Assembly.longPack(0, __a);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SoftLong.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407























































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Software math operations on 64-bit integer types.
 *
 * @since 2019/05/24
 */
public final class SoftLong
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/24
	 */
	private SoftLong()
	{
	}
	
	/**
	 * Adds two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long add(int __ah, int __al, int __bh, int __bl)
	{
		// Add the higher/lower parts
		int ch = __ah + __bh,
			cl = __al + __bl;
		
		// If the low addition carried a bit over, then set that bit in the
		// high part
		if ((cl + 0x80000000) < (__al + 0x80000000))
			ch++;
		
		// Return result
		return Assembly.longPack(ch, cl);
	}
	
	/**
	 * Ands two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long and(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah & __bh, __al & __bl);
	}
	
	/**
	 * Compares two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int cmp(int __ah, int __al, int __bh, int __bl)
	{
		// Compare high values firsts
		if (__ah < __bh)
			return -1;
		else if (__ah > __bh)
			return 1;
		
		// Compare low values with unsigned comparison
		__al += Integer.MIN_VALUE;
		__bl += Integer.MIN_VALUE;
		if (__al < __bl)
			return -1;
		else if (__al > __bl)
			return 1;
		return 0;
	}
	
	/**
	 * Divides two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long div(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(false, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Multiplies two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long mul(int __ah, int __al, int __bh, int __bl)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Negates a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long neg(int __ah, int __al)
	{
		// Negate and check for overflow
		int nh = (~__ah),
			nl = (~__al + 1);
		if (nl == 0)
			nh++;
		
		// Return result
		return Assembly.longPack(nh, nl);
	}
	
	/**
	 * Ors a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long or(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah | __bh, __al | __bl);
	}
	
	/**
	 * Remainders a value.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long rem(int __ah, int __al, int __bh, int __bl)
	{
		// Dividing by zero?
		if (__bh == 0 && __bl == 0)
			throw new ArithmeticException();
		
		return SoftLong.__div(true, Assembly.longPack(__ah, __al),
			Assembly.longPack(__bh, __bl));
	}
	
	/**
	 * Shifts value left by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shl(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the low bits to the high bits
		else if (__s >= 32)
			return Assembly.longPack(__al << (__s - 32), 0);
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah << __s) | (__al >>> (32 - __s)),
				(__al << __s));
	}
	
	/**
	 * Shifts value right by bits.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long shr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack((__ah & 0x80000000) >> 31,
				__ah >> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Subtracts values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long sub(int __ah, int __al, int __bh, int __bl)
	{
		// The same as add, but the second operand is negated
		long nb = SoftLong.neg(__bh, __bl);
		return SoftLong.add(__ah, __al,
			Assembly.longUnpackHigh(nb), Assembly.longUnpackLow(nb));
	}
	
	/**
	 * Converts to double.
	 *
	 * @param __a A.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static double toDouble(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to float.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static float toFloat(int __ah, int __al)
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Converts to integer.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static int toInteger(int __ah, int __al)
	{
		// Just return the low order bits
		return __al;
	}
	
	/**
	 * Shifts value bits right unsigned.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __s Shift amount.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long ushr(int __ah, int __al, int __s)
	{
		// Mask the shift amount
		__s &= 0x3F;
		
		// Doing nothing?
		if (__s == 0)
			return Assembly.longPack(__ah, __al);
		
		// Shifting all the high bits low
		else if (__s >= 32)
			return Assembly.longPack(0, __ah >>> (__s - 32));
		
		// Merge of bits (shift in range of 1-31)
		else
			return Assembly.longPack((__ah >>> __s),
				(__ah << (32 - __s)) | (__al >>> __s));
	}
	
	/**
	 * Xors two values.
	 *
	 * @param __ah A high.
	 * @param __al A low.
	 * @param __bh B high.
	 * @param __bl B low.
	 * @return The result.
	 * @since 2019/05/24
	 */
	public static long xor(int __ah, int __al, int __bh, int __bl)
	{
		return Assembly.longPack(__ah ^ __bh, __al ^ __bl);
	}
	
	/**
	 * Divides and remainders two values.
	 *
	 * @param __dorem Return the remainder?
	 * @param __num The numerator.
	 * @param __den The denominator.
	 * @return The result.
	 * @since 2019/05/24
	 */
	private static long __div(boolean __dorem, long __num, long __den)
	{
		// Wikipedia (http://en.wikipedia.org/wiki/Division_%28digital%29)
		// if D == 0 then throw DivisionByZeroException end
		// Q := 0 # initialize quotient and remainder to zero
		// R := 0
		// for i = n-1...0 do  # " where n is no of bits "
		//   R := R << 1       # left-shift R by 1 bit
		//   R(0) := N(i)      # set the least-significant bit
		//              # of R equal to bit i of the numerator
		//   if R >= D then
		//     R = R - D
		//     Q(i) := 1
		//   end
		// end
		long inquot = 0, inrem = 0;
		boolean isneg;
		
		// Disallow division by zero
		if (__den == 0)
			return 0;
		
		// Negative?
		isneg = ((__num < 0 && __den >= 0) || (__num >= 0 && __den < 0));
		
		// Force Positive
		__num = (__num < 0 ? -__num : __num);
		__den = (__den < 0 ? -__den : __den);
		
		// Perform Math
		for (int i = 63; i >= 0; i--)
		{
			inrem <<= 1;
			inrem &= 0xFFFFFFFFFFFFFFFEL;
			inrem |= ((__num >>> i) & 1L);
			
			// Unsigned comparison
			if ((inrem + Long.MIN_VALUE) >= (__den + Long.MIN_VALUE))
			{
				inrem -= __den;
				inquot |= (1L << i);
			}
		}
		
		// Make Negative
		if (isneg)
			inquot = -inquot;
		
		// Return
		return (__dorem ? inrem : inquot);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SupervisorPropertyIndex.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 indicates an index for a supervisor register which is controlled and
 * only settable by the supervisor. It is used in system call handling and
 * otherwise.
 *
 * @since 2019/10/04
 */
public interface SupervisorPropertyIndex
{
	/** The static field register of the task syscall handler. */
	public static final byte TASK_SYSCALL_STATIC_FIELD_POINTER =
		1;
	
	/** The method pointer of the task syscall method. */
	public static final byte TASK_SYSCALL_METHOD_HANDLER =
		2;
	
	/** The pool pointer of the task syscall method. */
	public static final byte TASK_SYSCALL_METHOD_POOL_POINTER =
		3;
	
	/** The number of available properties. */
	public static final byte NUM_PROPERTIES =
		4;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SystemCallError.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
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
































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 interface contains the various error codes for all of the system calls.
 *
 * @since 2019/05/23
 */
public final class SystemCallError
{
	/** No error, or success. */
	public static final byte NO_ERROR =
		0;
	
	/** The system call is not supported. */
	public static final byte UNSUPPORTED_SYSTEM_CALL =
		-1;
	
	/** The pipe descriptor is not valid. */
	public static final byte PIPE_DESCRIPTOR_INVALID =
		-2;
	
	/** Write error when writing to the pipe. */
	public static final byte PIPE_DESCRIPTOR_BAD_WRITE =
		-3;
	
	/** Value out of range. */
	public static final byte VALUE_OUT_OF_RANGE =
		-4;
	
	/** No frame buffer exists. */
	public static final byte NO_FRAMEBUFFER =
		-5;
	
	/** Permission denied. */
	public static final byte PERMISSION_DENIED =
		-6;
	
	/** Interrupted. */
	public static final byte INTERRUPTED =
		-7;
	
	/** Unknown error. */
	public static final byte UNKNOWN =
		-8;
	
	/** End of file reached. */
	public static final byte END_OF_FILE =
		-9;
	
	/** Error with IPC Call. */
	public static final byte IPC_ERROR =
		-10;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}
	
	/**
	 * Checks if an error was set, if it was an exception is thrown.
	 *
	 * @param __si The system call to check.
	 * @throws SystemCallException If there was an error.
	 * @since 2020/01/12
	 */
	public static final void checkError(short __si)
		throws SystemCallException
	{
		int code = SystemCallError.getError(__si);
		if (code != NO_ERROR)
			throw new SystemCallException(__si, code);
	}
	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
	
	/**
	 * Converts the error to a string.
	 *
	 * @param __err The input error.
	 * @return The resulting string.
	 * @since 2020/01/12
	 */
	public static final String toString(int __err)
	{
		switch (__err)
		{
			case NO_ERROR:					return "NoError";
			case UNSUPPORTED_SYSTEM_CALL:	return "UnsupportedSystemCall";
			case PIPE_DESCRIPTOR_INVALID:	return "PDInvalid";
			case PIPE_DESCRIPTOR_BAD_WRITE:	return "PDBadWrite";
			case VALUE_OUT_OF_RANGE:		return "ValueOutOfRange";
			case NO_FRAMEBUFFER:			return "NoFramebuffer";
			case PERMISSION_DENIED:			return "PermissionDenied";
			case INTERRUPTED:				return "Interrupted";
			case UNKNOWN:					return "Unknown";
			case END_OF_FILE:				return "EndOfFile";
			case IPC_ERROR:					return "IPCError";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SystemCallException.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
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



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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;

/**
 * Exception that may be thrown by {@link SystemCallError.checkError(int)}.
 *
 * @since 2020/01/12
 */
public class SystemCallException
	extends RuntimeException
{
	/** The system call ID. */
	public final int callid;
	
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec)
	{
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m)
	{
		super(__m);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m, Throwable __t)
	{
		super(__m, __t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, Throwable __t)
	{
		super(__t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/12
	 */
	@Override
	public String getMessage()
	{
		return "[SID=" + this.callid + ", ERR=" + this.code + "]: " +
			super.getMessage();
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/SystemCallIndex.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 contains the index of system calls.
 *
 * @since 2019/05/23
 */
public interface SystemCallIndex
{
	/**
	 * Checks if the system call is supported.
	 *
	 * @param 1 The system call index to query.
	 * @return Zero if not supported, otherwise a non-zero value.
	 */
	public static final byte QUERY_INDEX =
		0;
	
	/**
	 * Gets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @param 1 The system call index to query.
	 * @return The last error code, will be zero if the last command succeeded.
	 */
	public static final byte ERROR_GET =
		1;
	
	/**
	 * Sets the last error code.
	 *
	 * This value that stores the error state is thread-local and it may be
	 * stored with a precision of at least 16-bits.
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @param 1 The system call index to query.
	 * @param 2 The value to set error register to.
	 * @return Zero on success
	 */
	public static final byte ERROR_SET =
		2;
	
	/**
	 * Current wall clock milliseconds.
	 *
	 * @return The current milliseconds time.
	 */
	public static final byte TIME_MILLI_WALL =
		3;
	
	/**
	 * Returns the cross-IPC exception class which has been stored.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @return The exception which has been stored.
	 */
	public static final byte EXCEPTION_LOAD =
		4;
	
	/**
	 * Current monotonic clock nanoseconds (low).
	 *
	 * @return The monotonic nanoseconds time.
	 */
	public static final byte TIME_NANO_MONO =
		5;
	
	/**
	 * Stores the cross-IPC exception class for system call errors.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @param 1 The exception to store.
	 * @return The old value that was stored in the register.
	 */
	public static final byte EXCEPTION_STORE =
		6;
	
	/**
	 * VM Information: Free memory in bytes.
	 *
	 * @return The free memory amount in bytes.
	 */
	public static final byte VMI_MEM_FREE =
		7;
	
	/**
	 * VM Information: Used memory in bytes.
	 *
	 * @return The used memory amount in bytes.
	 */
	public static final byte VMI_MEM_USED =
		8;
	
	/**
	 * VM Information: Max memory in bytes.
	 *
	 * @return The max memory amount in bytes.
	 */
	public static final byte VMI_MEM_MAX =
		9;
	
	/**
	 * Suggests that the garbage collector should run, note that this may be
	 * a deferred operation and might not be immediate.
	 *
	 * @return Generally zero although any other value could be returned.
	 */
	public static final byte GARBAGE_COLLECT =
		10;
	
	/**
	 * Exits the VM with the given exit code.
	 *
	 * @param 1 The exit code to exit the process with.
	 * @return This generally does not return, if it does then the error code
	 * will likely specify why this failed.
	 */
	public static final byte EXIT =
		11;
	
	/**
	 * The API Level of the VM, this has been deprecated since the current
	 * SquirrelJME API specified in these system calls better handles various
	 * features.
	 *
	 * @return The API level of the virtual machine.
	 */
	@Deprecated
	public static final byte API_LEVEL =
		12;
	
	/**
	 * The pipe descriptor for stdin.
	 *
	 * @return The pipe descriptor for standard input.
	 */
	public static final byte PD_OF_STDIN =
		13;
	
	/**
	 * The pipe descriptor for stdout.
	 *
	 * @return The pipe descriptor for standard output.
	 */
	public static final byte PD_OF_STDOUT =
		14;
	
	/**
	 * The pipe descriptor for stderr.
	 *
	 * @return The pipe descriptor for standard error.
	 */
	public static final byte PD_OF_STDERR =
		15;
	
	/**
	 * Pipe descriptor: Write single byte.
	 *
	 * @param 1 The pipe descriptor.
	 * @param 2 The value of the byte to write, only the lowest 8-bits is used.
	 * @return The number of bytes written to the output, if this returns
	 * a value lower than zero then it indicates an error.
	 */
	public static final byte PD_WRITE_BYTE =
		16;
	
	/**
	 * Bulk sets the memory inside of a region, this follows the same pattern
	 * as C's {@code memset()} operation.
	 *
	 * @param 1 The address to set.
	 * @param 2 The value to set the region with.
	 * @param 3 The number of bytes to set.
	 * @return The number of bytes actually written, if this is zero then
	 * it is likely the system call is not supported.
	 */
	public static final byte MEM_SET =
		17;
	
	/**
	 * Bulk sets the memory inside of a region writing full integer values at
	 * a time which is generally faster, this follows the same pattern as C's
	 * {@code memset()} operation.
	 *
	 * @param 1 The address to set.
	 * @param 2 The value to set the region with.
	 * @param 3 The number of bytes to set, the lower 2-bits ({@code 0x3}) will
	 * be masked off so the length is always a multiple of four.
	 * @return The number of bytes actually written, if this is zero then
	 * it is likely the system call is not supported.
	 */
	public static final byte MEM_SET_INT =
		18;
	
	/**
	 * Get the height of the call stack.
	 *
	 * @return The height of the call stack.
	 */
	public static final byte CALL_STACK_HEIGHT =
		19;
	
	/**
	 * Gets the specified call stack item.
	 *
	 * @param 1 The number of frames from the top of the call stack to get the
	 * items for, zero will be the top-most item.
	 * @param 2 The item to obtain as specified in {@link CallStackItem}.
	 * @return The value of the item, if it is undefined or not supported
	 * then zero will be returned.
	 */
	public static final byte CALL_STACK_ITEM =
		20;
	
	/**
	 * Returns the string of the given pointer.
	 *
	 * @param 1 The pointer to the modified UTF encoded string.
	 * @return An instance of {@link String}.
	 */
	public static final byte LOAD_STRING =
		21;
	
	/**
	 * Fatal ToDo hit.
	 *
	 * @param 1 The code to use for the To Do.
	 * @return This should not return unless it is not supported.
	 */
	public static final byte FATAL_TODO =
		22;
	
	/**
	 * This is used to indicate that the supervisor booted correctly and that
	 * execution control is normal.
	 *
	 * @return Generally zero as no value is intended to be returned.
	 */
	public static final byte SUPERVISOR_BOOT_OKAY =
		23;
	
	/**
	 * Get, set, or change a property of the framebuffer, the properties which
	 * are defined are specified in {@link Framebuffer}.
	 *
	 * @param 1 The frame buffer property to select.
	 * @param ... Undefined, this depends on the property selected.
	 * @return Whatever value the frame buffer property will return.
	 */
	public static final byte FRAMEBUFFER =
		24;
	
	/**
	 * Returns the native byte order of the system the virtual machine is
	 * running on.
	 *
	 * @return Non-zero if little endian, otherwise zero will be big endian.
	 */
	public static final byte BYTE_ORDER_LITTLE =
		25;
	
	/**
	 * Returns the pointer to the option JAR data.
	 *
	 * @param 1 The option JAR slot to request.
	 * @return A pointer to the data or zero if there is no option JAR defined
	 * in the requested slot.
	 */
	public static final byte OPTION_JAR_DATA =
		26;
	
	/**
	 * Returns the size of the option JAR data.
	 *
	 * @param 1 The option JAR slot to request.
	 * @return The size of the specified option JAR or zero if there is no
	 * option JAR defined in the requested slot.
	 */
	public static final byte OPTION_JAR_SIZE =
		27;
	
	/**
	 * Loads the specified class.
	 *
	 * @param 1 The Modified UTF specifying the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_UTF =
		28;
	
	/**
	 * Loads the specified class.
	 *
	 * @param 1 A byte array encoded in UTF-8 which contains the class name.
	 * @return The pointer to the loaded class info, will be zero on failure.
	 */
	public static final byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @param 1 The supervisor property to set.
	 * @param 2 The new value of the property.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @param 1 The supervisor property to get.
	 * @return The value of that property, error should be checked to ensure
	 * that it did not fail.
	 */
	public static final byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
	 *
	 * Only the supervisor is allowed to set tihus.
	 *
	 * @param 1 The task ID to set.
	 * @return A non-zero value if this was successful.
	 */
	public static final byte FRAME_TASK_ID_SET =
		32;
	
	/**
	 * Gets the value of a thread register.
	 *
	 * @return The value of the task ID.
	 */
	public static final byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @param 1 The type of feedback to perform.
	 * @param 2 The duration of the feedback.
	 * @return Non-zero on success.
	 */
	public static final byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * @param 1 The number of milliseconds to sleep for.
	 * @param 2 The number of nanoseconds to sleep for.
	 * @return Returns zero unless sleep was interrupted.
	 */
	public static final byte SLEEP =
		35;
	
	/**
	 * If the framebuffer is shared with the console, this tells the console
	 * printer to not send messages to the screen as it will corrupt the
	 * display on the screen.
	 */
	public static final byte SQUELCH_FB_CONSOLE =
		36;
	
	/**
	 * Perform IPC call.
	 *
	 * @param 1 The task to call, {@code 0} is the supervisor.
	 * @param 2 The IPC identifier which specifies which service this was
	 * associated with.
	 * @param ... Any arguments to the call.
	 * @return The value returned from the remote call.
	 */
	public static final byte IPC_CALL =
		37;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	public static final byte NUM_SYSCALLS =
		38;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/io/BinaryBlob.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
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









































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.io;

/**
 * This is a binary blob which provides memory and I/O access.
 *
 * Sub-classes only need to implement reading of a single byte, however
 * implementing the other methods will result in faster code.
 *
 * @since 2019/09/22
 */
public abstract class BinaryBlob
{
	/**
	 * Reads a single byte.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public abstract byte readByte(int __o);
	
	/**
	 * Returns the size of this blob.
	 *
	 * @return The size of this blob.
	 * @since 2019/11/17
	 */
	public abstract int size();
	
	/**
	 * Reads in multiple bytes.
	 *
	 * @param __i The read index.
	 * @param __b The bytes to read.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the index is out of bounds, or
	 * the offset and/or length are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/24
	 */
	public void readBytes(int __i, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __o < 0 || (__o + __l) > __b.length)
			throw new NullPointerException("IOOB");
		
		for (int i = 0; i < __l; i++)
			__b[__o + i] = (byte)this.readByte(__i + i);
	}
	
	/**
	 * Reads a Java integer.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public int readJavaInt(int __o)
		throws IndexOutOfBoundsException
	{
		return ((this.readByte(__o) & 0xFF) << 24) |
			((this.readByte(__o + 1) & 0xFF) << 16) |
			((this.readByte(__o + 2) & 0xFF) << 8) |
			((this.readByte(__o + 3) & 0xFF));
	}
	
	/**
	 * Reads a Java short.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/11/17
	 */
	public short readJavaShort(int __o)
		throws IndexOutOfBoundsException
	{
		return (short)(((this.readByte(__o + 1) & 0xFF) << 8) |
			((this.readByte(__o) & 0xFF)));
	}
	
	/**
	 * Reads an unsigned Java short.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/11/17
	 */
	public int readJavaUnsignedShort(int __o)
		throws IndexOutOfBoundsException
	{
		return this.readJavaShort(__o) & 0xFFFF;
	}
	
	/**
	 * Reads a single unsigned byte.
	 *
	 * @param __o The offset.
	 * @return The read data.
	 * @throws IndexOutOfBoundsException If the index is outside of bounds.
	 * @since 2019/09/22
	 */
	public int readUnsignedByte(int __o)
		throws IndexOutOfBoundsException
	{
		return this.readByte(__o) & 0xFF;
	}
	
	/**
	 * Reads a Modified UTF encoded string.
	 *
	 * @param __o The offset.
	 * @return The read string.
	 * @throws IndexOutOfBoundsException If the string is outside of bounds.
	 * @since 2019/09/24
	 */
	public final String readUTF(int __o)
		throws IndexOutOfBoundsException
	{
		// Read length of data first
		int len = this.readJavaUnsignedShort(__o);
		
		// Read in data to byte array
		byte[] data = new byte[len];
		this.readBytes(__o + 2, data, 0, len);
		
		// Initialize string with it
		return new String(data);
	}
	
	/**
	 * Returns a blob which is a sub-section of the given blob.
	 *
	 * It is recommended to replace this class with a more efficient one if
	 * possible, as otherwise it will use a less-efficient sub-section
	 * implementation for this blob.
	 *
	 * @param __base The base of this blob within this one.
	 * @param __len The length of the section.
	 * @return The sub-section.
	 * @throws IndexOutOfBoundsException If the base or length are negative
	 * or exceed the bounds of this blob.
	 * @since 2019/11/17
	 */
	public BinaryBlob subSection(int __base, int __len)
		throws IndexOutOfBoundsException
	{
		if (__base < 0 || __len < 0 || (__base + __len) > this.size())
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/io/MemoryBlob.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
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
191
192
193

































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.io;

import cc.squirreljme.jvm.Assembly;

/**
 * This is a blob of data which is sourced from memory.
 *
 * @since 2019/09/22
 */
public final class MemoryBlob
	extends BinaryBlob
{
	/** The base address. */
	protected final int base;
	
	/** The size. */
	protected final int size;
	
	/**
	 * Initializes the memory blob.
	 *
	 * @param __base The base address of the blob.
	 * @param __size The size of the blob.
	 * @throws IllegalArgumentException If the size is negative.
	 * @since 2019/09/22
	 */
	public MemoryBlob(int __base, int __size)
		throws IllegalArgumentException
	{
		// {@squirreljme.error SV06 Negative memory blob size.}
		if (__size < 0)
			throw new IllegalArgumentException("SV06");
		
		this.base = __base;
		this.size = __size;
	}
	
	/**
	 * Returns the base address of this blob.
	 *
	 * @return The base address of this blob.
	 * @since 2019/12/01
	 */
	public final int baseAddress()
	{
		return this.base;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/01
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MemoryBlob))
			return false;
		
		MemoryBlob o = (MemoryBlob)__o;
		return this.base == o.base &&
			this.size == o.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/01
	 */
	@Override
	public final int hashCode()
	{
		return this.base ^ (-this.size);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public byte readByte(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || __o >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return (byte)Assembly.memReadByte(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public void readBytes(int __i, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__i < 0 || __o < 0 || (__o + __l) > __b.length)
			throw new NullPointerException("IOOB");
			
		// {@squirreljme.error SV0u Out of range region read.}
		if (__i < 0 || (__i + __l) > this.size)
			throw new IndexOutOfBoundsException("SV0u");
		
		for (int i = 0, bp = this.base + __i; i < __l; i++)
			__b[__o + i] = (byte)Assembly.memReadByte(bp, i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int readJavaInt(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 3) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return Assembly.memReadJavaInt(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public short readJavaShort(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 1) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return (short)Assembly.memReadJavaShort(this.base, __o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int readJavaUnsignedShort(int __o)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV09 Out of range region read.}
		if (__o < 0 || (__o + 1) >= this.size)
			throw new IndexOutOfBoundsException("SV09");
		
		return Assembly.memReadJavaShort(this.base, __o) & 0xFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public int size()
	{
		return this.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/17
	 */
	@Override
	public BinaryBlob subSection(int __base, int __len)
		throws IndexOutOfBoundsException
	{
		int size = this.size;
		if (__base < 0 || __len < 0 || (__base + __len) > size)
			throw new IndexOutOfBoundsException("IOOB " + __base + " "
				+ __len);
		
		return new MemoryBlob(this.base + __base, __len);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/io/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains extra utilities for input/output.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.io;

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/AbstractPoolParser.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
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































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This is the base class for a pool parser.
 *
 * @since 2019/10/13
 */
public abstract class AbstractPoolParser
{
	/**
	 * Returns the number of pool entries that exist.
	 *
	 * @param __ft Does this fall through to the actually backed pool?
	 * @return The pool entry count.
	 * @since 2019/11/25
	 */
	public abstract int count(boolean __ft)
		throws InvalidClassFormatException;
	
	/**
	 * Returns a blob to the entry's data for parsing.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The blob to the entry data.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public abstract BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Returns the number of parts this entry has.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The read parts
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public abstract short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Return the type a pool entry is.
	 *
	 * @param __dx The index of the entry to get.
	 * @param __ft Does this get fall through to the actually backed pool?
	 * @return The entry type.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public abstract int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException;
	
	/**
	 * Returns the number of pool entries that exist.
	 *
	 * @return The pool entry count.
	 * @since 2019/11/25
	 */
	public final int count()
		throws InvalidClassFormatException
	{
		return this.count(false);
	}
		
	/**
	 * Returns a blob to the entry's data for parsing.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The blob to the entry data.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final BinaryBlob entryData(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryData(__dx, false);
	}
	
	/**
	 * Returns the number of parts this entry has.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The read parts
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final short[] entryParts(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryParts(__dx, false);
	}
	
	/**
	 * Return the type a pool entry is.
	 *
	 * @param __dx The index of the entry to get.
	 * @return The entry type.
	 * @throws IndexOutOfBoundsException If it is outside of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final int entryType(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryType(__dx, false);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/AliasedPoolParser.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
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












































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This class is used to provide access to the aliased pool where entries are.
 *
 * @since 2019/10/13
 */
public final class AliasedPoolParser
	extends AbstractPoolParser
{
	/** The blob. */
	protected final BinaryBlob blob;
	
	/** The inherited pool data. */
	protected final AbstractPoolParser inherited;
	
	/** The count of this aliased pool. */
	private int _count =
		-1;
	
	/**
	 * Initializes the aliased pool parser.
	 *
	 * @param __b The blob for aliased data.
	 * @param __inh The inherited pool to source real data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public AliasedPoolParser(BinaryBlob __b, AbstractPoolParser __inh)
		throws NullPointerException
	{
		if (__b == null || __inh == null)
			throw new NullPointerException("NARG");
		
		this.blob = __b;
		this.inherited = __inh;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final int count(boolean __ft)
		throws InvalidClassFormatException
	{
		// If falling through use the inherited pool count
		if (__ft)
			return this.inherited.count();
		
		// Already cached the count?
		int rv = this._count;
		if (rv >= 0)
			return rv;
		
		// {@squirreljme.error SV0w Aliased pool has a count of zero.}
		rv = this.blob.readJavaInt(0);
		if (rv < 0)
			throw new InvalidClassFormatException("SV0w");
		
		// Cache and return
		this._count = rv;
		return rv;
	}
	
	/**
	 * Returns the entry this was aliased to.
	 *
	 * @param __dx The index to get.
	 * @return The index this was aliased to.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @since 2019/11/24
	 */
	public final int entryAliasedIndex(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		// The size is stored in the zero index, so this ensures that
		// zero always maps to zero!
		if (__dx == 0)
			return 0;
		
		// Read size of this pool and check the bounds
		BinaryBlob blob = this.blob;
		int count = blob.readJavaInt(0);
		if (__dx < 0 || __dx >= this.count())
			throw new IndexOutOfBoundsException("IOOB");
		
		// Read the entry index now
		return blob.readJavaInt(__dx * 4);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryData((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryParts((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.inherited.entryType((__ft ? __dx :
			this.entryAliasedIndex(__dx)));
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/BootRom.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286






























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigReader;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.JVMFunction;

/**
 * This contains boot ROM information.
 *
 * @since 2019/06/23
 */
public final class BootRom
{
	/** Boot libraries which have been loaded. */
	public static volatile BootRomLibrary[] BOOT_LIBRARIES;
	
	/** The offset to the jar count. */
	public static final byte ROM_NUMJARS_OFFSET =
		4;
	
	/** Offset to the table of contents offset. */
	public static final byte ROM_TOCOFFSET_OFFSET =
		8;
		
	/** The index of the JAR which should be the boot point. */
	public static final byte ROM_BOOTJARINDEX_OFFSET =
		12;
	
	/** The offset into the packfile where the boot entry is. */
	public static final byte ROM_BOOTJAROFFSET_OFFSET =
		16;
	
	/** The size of the boot jar. */
	public static final byte ROM_BOOTJARSIZE_OFFSET =
		20;
	
	/** Initial class path library indexes. */
	public static final byte ROM_BOOTICPOFFSET_OFFSET =
		24;
	
	/** Initial class path library index count. */
	public static final byte ROM_BOOTICPSIZE_OFFSET =
		28;
	
	/** Initial main class. */
	public static final byte ROM_BOOTMAINCLASS_OFFSET =
		32;
	
	/** Is the boot class a MIDlet? */
	public static final byte ROM_BOOTMAINMIDLET_OFFSET =
		36;
	
	/** Static constant pool offset. */
	public static final byte ROM_STATICPOOLOFF_OFFSET =
		40;
	
	/** Static constant pool size. */
	public static final byte ROM_STATICPOOLSIZE_OFFSET =
		44;
	
	/** Runtime constant pool offset. */
	public static final byte ROM_RUNTIMEPOOLOFF_OFFSET =
		48;
	
	/** Runtime constant pool size. */
	public static final byte ROM_RUNTIMEPOOLSIZE_OFFSET =
		52;
	
	/** Table of contents size. */
	public static final byte TOC_ENTRY_SIZE =
		20;
	
	/** Table of contents name offset. */
	public static final byte TOC_NAME_OFFSET =
		0;
	
	/** Table of contents JAR data offset. */
	public static final byte TOC_JAR_OFFSET =
		4;
	
	/** Table of contents size of the JAR. */
	public static final byte TOC_JARLEN_OFFSET =
		8;
	
	/** Table of contents manifest offset. */
	public static final byte TOC_MANIFEST_OFFSET =
		12;
	
	/** Table of contents length of manifest. */
	public static final byte TOC_MANIFEST_LENGTH_OFFSET =
		16;
	
	/**
	 * Returns the boot libraries which make up the initial classpath.
	 *
	 * @param __rombase The ROM base.
	 * @param __config The configuration system to use.
	 * @return The libraries to set for the initial classpath.
	 * @since 2019/06/20
	 */
	public static final ClassLibrary[] initialClasspath(int __rombase,
		ConfigReader __config)
	{
		// Load all libraries
		BootRomLibrary[] bootlibs = BootRom.bootLibraries(__rombase);
		if (bootlibs == null)
			Assembly.breakpoint();
		int numboot = bootlibs.length;
		
		// The initial class path to use
		ClassLibrary[] usecp;
		
		// Use the passed class-path if one was specified.
		String[] usercp = __config.loadStrings(ConfigRomType.CLASS_PATH);
		if (usercp != null)
		{
			// Debug
			todo.DEBUG.note("Using user class path!");
			
			// Scan for libraries
			int n = usercp.length;
			usecp = new ClassLibrary[n];
			for (int i = 0; i < n; i++)
			{
				String libname = usercp[i];
				
				// Find library
				for (int j = 0; j < numboot; j++)
				{
					BootRomLibrary bl = bootlibs[j];
					
					// Is this library?
					if (libname.equals(bl.name))
					{
						usecp[i] = bl;
						break;
					}
				}
			}
		}
		
		// Use class-path built into the ROM
		else
		{
			// Debug
			todo.DEBUG.note("Using firmware class path!");
			
			// Get offset to the table and its length
			int icpoff = __rombase + Assembly.memReadJavaInt(__rombase,
					ROM_BOOTICPOFFSET_OFFSET),
				icpsize = Assembly.memReadJavaInt(__rombase,
					ROM_BOOTICPSIZE_OFFSET);
			
			// Read all of them
			usecp = new ClassLibrary[icpsize];
			for (int i = 0; i < icpsize; i++)
				usecp[i] = bootlibs[Assembly.memReadJavaInt(icpoff,
					i * 4)];
		}
		
		// Use them!
		return usecp;
	}
	
	/**
	 * Returns if the initial class is a MIDlet.
	 *
	 * @param __rombase The base of the ROM.
	 * @param __config The configuration to use.
	 * @return Is this initial program a MIDlet?
	 * @since 2019/12/14
	 */
	public static final boolean initialIsMidlet(int __rombase,
		ConfigReader __config)
	{
		// Get from configuration first
		int rv = __config.loadInteger(ConfigRomType.IS_MIDLET);
		if (rv != 0)
			return (rv > 0);
		
		return Assembly.memReadJavaInt(
			__rombase, ROM_BOOTMAINMIDLET_OFFSET) > 0;
	}
	
	/**
	 * Returns the initial main class.
	 *
	 * @param __rombase The base of the ROM.
	 * @param __config The configuration to use.
	 * @return The initial main class.
	 * @since 2019/06/23
	 */
	public static final String initialMain(int __rombase,
		ConfigReader __config)
	{
		// Use main user class
		String usermain = __config.loadString(ConfigRomType.MAIN_CLASS);
		if (usermain != null)
			return usermain;
		
		// Otherwise read it from the boot ROM
		return JVMFunction.jvmLoadString(__rombase +
			Assembly.memReadJavaInt(__rombase, ROM_BOOTMAINCLASS_OFFSET));
	}
	
	/**
	 * Returns all of the libraries which are available to the bootstrap.
	 *
	 * @param __rombase The ROM base.
	 * @return The available bootstrap libraries.
	 * @since 2019/06/14
	 */
	public static final BootRomLibrary[] bootLibraries(int __rombase)
	{
		// Already exists?
		BootRomLibrary[] bootlibs = BOOT_LIBRARIES;
		if (bootlibs != null)
			return bootlibs;
		
		// Number of JARs in the ROM
		int numjars = Assembly.memReadJavaInt(__rombase, ROM_NUMJARS_OFFSET);
		
		// Offset to table of contents
		int tocoff = Assembly.memReadJavaInt(__rombase, ROM_TOCOFFSET_OFFSET);
		
		// Debug
		todo.DEBUG.note("Scanning %d libraries...", numjars);
		
		// Seeker for the table of contents
		int seeker = __rombase + tocoff;
		
		// This is used to contain the constant pool data offset and size which
		// is then used when we initialize classes
		BootRomPoolInfo brpi = new BootRomPoolInfo(
			__rombase + Assembly.memReadJavaInt(__rombase,
				ROM_STATICPOOLOFF_OFFSET),
			Assembly.memReadJavaInt(__rombase, ROM_STATICPOOLSIZE_OFFSET),
			__rombase + Assembly.memReadJavaInt(__rombase,
				ROM_RUNTIMEPOOLOFF_OFFSET),
			Assembly.memReadJavaInt(__rombase, ROM_RUNTIMEPOOLSIZE_OFFSET));
		
		// Load all the JAR informations
		bootlibs = new BootRomLibrary[numjars];
		for (int i = 0; i < numjars; i++)
		{
			// Manifest address is optional
			int ma = Assembly.memReadJavaInt(seeker,
				TOC_MANIFEST_LENGTH_OFFSET);
			
			// Load library info
			BootRomLibrary bl = new BootRomLibrary(JVMFunction.jvmLoadString(
				__rombase + Assembly.memReadJavaInt(seeker, TOC_NAME_OFFSET)),
				__rombase + Assembly.memReadJavaInt(seeker, TOC_JAR_OFFSET),
				Assembly.memReadJavaInt(seeker, TOC_JARLEN_OFFSET),
				(ma == 0 ? 0 : __rombase + ma),
				Assembly.memReadJavaInt(seeker, TOC_MANIFEST_LENGTH_OFFSET),
				brpi);
			
			// Store it
			bootlibs[i] = bl;
			
			// Go to the next entry
			seeker += TOC_ENTRY_SIZE;
		}
		
		// Store for later usage
		BOOT_LIBRARIES = bootlibs;
		
		// Debug
		todo.DEBUG.note("Okay.");
		
		// Return the libraries
		return bootlibs;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/BootRomLibrary.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285





























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.io.BinaryBlob;
import cc.squirreljme.jvm.io.MemoryBlob;
import cc.squirreljme.jvm.JVMFunction;

/**
 * This represents a single boot library.
 *
 * @since 2019/06/14
 */
public final class BootRomLibrary
	extends ClassLibrary
{
	/** Offset of the resource count. */
	public static final byte JAR_NUMRC_OFFSET =
		4;
		
	/** Offset of the table of contents. */
	public static final byte JAR_TOC_OFFSET_OFFSET =
		8;
		
	/** Manifest offset. */
	public static final byte JAR_MANIFESTOFF_OFFSET =
		12;
	
	/** Manifest length. */
	public static final byte JAR_MANIFESTLEN_OFFSET =
		16;
	
	/** Boot initializer offset. */
	public static final byte JAR_BOOTOFFSET_OFFSET =
		20;
	
	/** Boot initializer size. */
	public static final byte JAR_BOOTSIZE_OFFSET =
		24;
	
	/** The boot pool offset. */
	public static final byte JAR_BOOTPOOL_OFFSET =
		28;
	
	/** Static field basein RAM. */
	public static final byte JAR_BOOTSFIELDBASE_OFFSET =
		32;
	
	/** The start method offset. */
	public static final byte JAR_BOOTSTART_OFFSET =
		36;
	
	/** System call static field pointer. */
	public static final byte JAR_SYSCALLSFP_OFFSET =
		40;
	
	/** System call handler code address .*/
	public static final byte JAR_SYSCALLHANDLER_OFFSET =
		44;
	
	/** System call pool address. */
	public static final byte JAR_SYSCALLPOOL_OFFSET =
		48;
	
	/** The ClassInfo for {@code byte[]}. */
	public static final byte JAR_BOOTCLASSIDBA_OFFSET =
		52;
	
	/** The ClassInfo for {@code byte[][]}. */
	public static final byte JAR_BOOTCLASSIDBAA_OFFSET =
		56;
	
	/** Static constant pool offset. */
	public static final byte JAR_STATICPOOLOFF_OFFSET =
		60;
	
	/** Static constant pool size. */
	public static final byte JAR_STATICPOOLSIZE_OFFSET =
		64;
	
	/** Runtime constant pool offset. */
	public static final byte JAR_RUNTIMEPOOLOFF_OFFSET =
		68;
	
	/** Runtime constant pool size. */
	public static final byte JAR_RUNTIMEPOOLSIZE_OFFSET =
		72;
	
	/** TOC hashcode offset. */
	public static final int TOC_HASHCODE_OFFSET =
		0;
	
	/** TOC name offset. */
	public static final int TOC_NAME_OFFSET =
		4;
	
	/** TOC Data offset. */
	public static final int TOC_DATA_OFFSET =
		8;
	
	/** TOC Size offset. */
	public static final int TOC_SIZE_OFFSET =
		12;
	
	/** Size of table of contents entries. */
	public static final int TOC_ENTRY_SIZE =
		16;
	
	/** The name of this library. */
	protected final String name;
	
	/** The absolute address of the JAR. */
	@Deprecated
	protected final int address;
	
	/** The length of the JAR. */
	@Deprecated
	protected final int length;
	
	/** Manifest address. */
	protected final int manifestaddress;
	
	/** Manifest length. */
	protected final int manifestlength;
	
	/** Boot pool information. */
	protected final BootRomPoolInfo bootrompool;
	
	/** The blob for this JAR. */
	protected final BinaryBlob blob;
	
	/**
	 * Initializes the boot library.
	 *
	 * @param __name The name of the library.
	 * @param __addr The JAR address.
	 * @param __len The JAR length.
	 * @param __maddr The manifest address.
	 * @param __mlen The manifest length.
	 * @param __brpi The boot pool information from the ROM.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/19
	 */
	public BootRomLibrary(String __name, int __addr, int __len, int __maddr,
		int __mlen, BootRomPoolInfo __brpi)
		throws NullPointerException
	{
		if (__name == null || __brpi == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.address = __addr;
		this.length = __len;
		this.manifestaddress = __maddr;
		this.manifestlength = __mlen;
		this.bootrompool = __brpi;
		
		// Initializes the blob
		this.blob = new MemoryBlob(__addr, __len);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/23
	 */
	@Override
	public final int indexOf(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Hash code for this string
		int hash = __name.hashCode();
		
		// Scan through the table of contents
		int bp = this.address,
			sp = bp + Assembly.memReadJavaInt(bp, JAR_TOC_OFFSET_OFFSET);
		for (int i = 0, n = Assembly.memReadJavaInt(bp, JAR_NUMRC_OFFSET); i < n;
			i++, sp += TOC_ENTRY_SIZE)
		{
			// Hash code does not match
			if (hash != Assembly.memReadJavaInt(sp, TOC_HASHCODE_OFFSET))
				continue;
			
			// Is at this index
			if (__name.equals(JVMFunction.jvmLoadString(
				bp + Assembly.memReadJavaInt(sp, TOC_NAME_OFFSET))))
				return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final String libraryName()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/11
	 */
	@Override
	public final BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException
	{
		// Get base address of the library
		int bp = this.address;
		
		// {@squirreljme.error SV07 Attempt to access resource which was not
		// in range of the boot library.}
		if (__dx < 0 || __dx >= Assembly.memReadJavaInt(bp, JAR_NUMRC_OFFSET))
			throw new IndexOutOfBoundsException("SV07");
		
		// Read from the table of contents, the offset to the data.
		int tocoffset = bp + Assembly.memReadJavaInt(bp,
			JAR_TOC_OFFSET_OFFSET);
		return new MemoryBlob(bp + Assembly.memReadJavaInt(tocoffset,
				(TOC_ENTRY_SIZE * __dx) + TOC_DATA_OFFSET),
			Assembly.memReadJavaInt(tocoffset,
				(TOC_ENTRY_SIZE * __dx) + TOC_SIZE_OFFSET));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/18
	 */
	@Override
	public AbstractPoolParser splitPool(boolean __rt)
	{
		BinaryBlob blob = this.blob;
		
		// Static
		int jpo, jps;
		if (__rt)
		{
			jpo = blob.readJavaInt(JAR_RUNTIMEPOOLOFF_OFFSET);
			jps = blob.readJavaInt(JAR_RUNTIMEPOOLSIZE_OFFSET);
		}
		
		// Run-time
		else
		{
			jpo = blob.readJavaInt(JAR_STATICPOOLOFF_OFFSET);
			jps = blob.readJavaInt(JAR_STATICPOOLSIZE_OFFSET);
		}
		
		// This JAR has a pool in it
		AbstractPoolParser rv;
		if (jpo >= 0 && jps >= 0)
			rv = new ClassPoolParser(blob.subSection(jpo, jps));
		
		// Possibly using JAR pool
		else
		{
			BootRomPoolInfo bootrompool = this.bootrompool;
			if (bootrompool.isDefined(__rt))
				rv = new ClassPoolParser(
					new MemoryBlob(bootrompool.address(__rt),
						bootrompool.size(__rt)));
			
			// Not using any pool
			else
				rv = null;
		}
		
		return rv;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/BootRomPoolInfo.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
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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This class contains the information on the boot pool addresses.
 *
 * @since 2019/11/17
 */
public final class BootRomPoolInfo
{
	/** This is the static constant pool offset. */
	protected final int staticpooladdress;
	
	/** This is the static constant pool size. */
	protected final int staticpoolsize;
	
	/** This is the run-time constant pool address. */
	protected final int runtimepooladdress;
	
	/** This is the run-time constant pool size. */
	protected final int runtimepoolsize;
	
	/**
	 * Initializes the boot ROM pool information.
	 *
	 * @param __so Static pool address.
	 * @param __ss Static pool size.
	 * @param __ro Run-time pool address.
	 * @param __rs Run-time pool size.
	 * @since 2019/11/18
	 */
	public BootRomPoolInfo(int __so, int __ss, int __ro, int __rs)
	{
		this.staticpooladdress = __so;
		this.staticpoolsize = __ss;
		this.runtimepooladdress = __ro;
		this.runtimepoolsize = __rs;
	}
	
	/**
	 * Returns the address of the pool.
	 *
	 * @param __rt The run-time pool.
	 * @return The address.
	 * @since 2019/11/18
	 */
	public final int address(boolean __rt)
	{
		return (__rt ? this.runtimepooladdress : this.staticpooladdress);
	}
	
	/**
	 * Is this pool valid?
	 *
	 * @param __rt The run-time pool.
	 * @return If it is valid.
	 * @since 2019/11/18
	 */
	public final boolean isDefined(boolean __rt)
	{
		// The address is not considered because it may be negative
		return (__rt ? this.runtimepoolsize : this.staticpoolsize) > 0;
	}
	
	/**
	 * Returns the size of the pool.
	 *
	 * @param __rt The run-time pool.
	 * @return The size.
	 * @since 2019/11/18
	 */
	public final int size(boolean __rt)
	{
		return (__rt ? this.runtimepoolsize : this.staticpoolsize);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final String toString()
	{
		return "Pools{st=(@" + Integer.toString(this.staticpooladdress, 16) +
			" len=" + this.staticpoolsize + "), rt=(@" +
			Integer.toString(this.runtimepooladdress, 16) +
			" len=" + this.runtimepoolsize + ")}";
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassDualPoolParser.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355



































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This class manages the parsing of the standard individual constant pools
 * to the combined run-time and static dual-pool setup.
 *
 * @see ClassPoolParser
 * @since 2019/10/12
 */
public final class ClassDualPoolParser
{
	/** The class level static pool. */
	protected final AbstractPoolParser classpool;
	
	/** The run-time pool. */
	protected final AbstractPoolParser runtimepool;
	
	/**
	 * Initializes the dual class pool parser.
	 *
	 * @param __cl The static class pool.
	 * @param __rt The run-time class pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/12
	 */
	public ClassDualPoolParser(AbstractPoolParser __cl,
		AbstractPoolParser __rt)
		throws NullPointerException
	{
		if (__cl == null || __rt == null)
			throw new NullPointerException("NARG");
		
		this.classpool = __cl;
		this.runtimepool = __rt;
	}
	
	/**
	 * Returns the given pool count.
	 *
	 * @param __rt Use the run-time pool?
	 * @return The given pool count.
	 * @since 2019/12/14
	 */
	public final int count(boolean __rt)
	{
		return this.count(__rt, false);
	}
	
	/**
	 * Returns the given pool count.
	 *
	 * @param __rt Use the run-time pool?
	 * @param __ft Forward?
	 * @return The given pool count.
	 * @since 2019/12/14
	 */
	public final int count(boolean __rt, boolean __ft)
	{
		return this.pool(__rt).count(__ft);
	}
	
	/**
	 * Returns the decoded entry as any object.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final Object entry(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entry(__rt, __dx, false);
	}
	
	/**
	 * Returns the decoded entry as any object.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final Object entry(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		// The zero index is always null!
		if (__dx == 0)
			return null;
		
		// Need these pools
		AbstractPoolParser sp = this.classpool,
			rp = this.runtimepool,
			ap = (__rt ? rp : sp);
		
		// Get pool entry properties
		int etype = ap.entryType(__dx, __ft);
		short[] eparts = ap.entryParts(__dx, __ft);
		int enumparts = eparts.length;
		BinaryBlob eblob = ap.entryData(__dx, __ft);
		
		// Depends on the entry type
		switch (etype)
		{
				// String, skip hash and length copies
			case ClassPoolConstants.TYPE_STRING:
				return eblob.readUTF(4);
				
				// Name of class
			case ClassPoolConstants.TYPE_CLASSNAME:
				return new PoolClassName(
					(String)this.entry(false, eparts[0] & 0xFFFF, true),
					(PoolClassName)this.entry(false, eparts[1] & 0xFFFF,
						true));
					
				// Names of multiple classes
			case ClassPoolConstants.TYPE_CLASSNAMES:
				PoolClassName[] rvpn = new PoolClassName[enumparts];
				for (int i = 0; i < enumparts; i++)
					rvpn[i] = (PoolClassName)this.entry(false,
						eparts[i] & 0xFFFF, true);
				return rvpn;
				
				// Method descriptor
			case ClassPoolConstants.TYPE_METHOD_DESCRIPTOR:
				PoolClassName[] mdargs = new PoolClassName[enumparts - 3];
				for (int i = 0, n = enumparts - 3; i < n; i++)
					mdargs[i] = (PoolClassName)this.entry(false,
						eparts[i + 3] & 0xFFFF, true);
				return new PoolMethodDescriptor(
					(String)this.entry(false, eparts[0] & 0xFFFF, true),
					(PoolClassName)this.entry(false, eparts[2] & 0xFFFF, true),
					mdargs);
				
				// Class information pointer
			case ClassPoolConstants.TYPE_CLASS_INFO_POINTER:
				return new PoolClassInfoPointer(
					((PoolClassName)this.entry(false, eparts[0] & 0xFFFF,
						true)).toString());
					
				// Class pool pointer
			case ClassPoolConstants.TYPE_CLASS_POOL_POINTER:
				return new PoolClassPoolPointer(
					((PoolClassName)this.entry(false, eparts[0] & 0xFFFF,
						true)).toString());
				
				// Noted string
			case ClassPoolConstants.TYPE_NOTED_STRING:
				return new PoolNotedString(
					this.entryData(false, eparts[0] & 0xFFFF, true));
			
				// Unknown
			default:
				throw new todo.TODO("Pool " + etype);
		}
	}
	
	/**
	 * Returns the decoded entry as a class name.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/25
	 */
	public final PoolClassName entryAsClassName(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassName)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as class names.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final PoolClassName[] entryAsClassNames(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassName[])this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a method descriptor.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final PoolMethodDescriptor entryAsMethodDescriptor(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolMethodDescriptor)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a noted string.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final PoolNotedString entryAsNotedString(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolNotedString)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a class info pointer.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/15
	 */
	public final PoolClassInfoPointer entryAsClassInfoPointer(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassInfoPointer)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a class pool pointer.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/15
	 */
	public final PoolClassPoolPointer entryAsClassPoolPointer(boolean __rt,
		int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (PoolClassPoolPointer)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the decoded entry as a string.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The value.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/11/24
	 */
	public final String entryAsString(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return (String)this.entry(__rt, __dx);
	}
	
	/**
	 * Returns the data to the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The data to the entry.
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final BinaryBlob entryData(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool(__rt).entryData(__dx, __ft);
	}
	
	/**
	 * Returns the type of the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The type of the entry
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/14
	 */
	public final int entryType(boolean __rt, int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.entryType(__rt, __dx, false);
	}
	
	/**
	 * Returns the type of the given entry.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @param __ft Would the entry be forwarded through to the actual
	 * pool implementation?
	 * @return The type of the entry
	 * @throws IndexOutOfBoundsException If the given entry is out of bounds.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @since 2019/12/01
	 */
	public final int entryType(boolean __rt, int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool(__rt).entryType(__dx, __ft);
	}
	
	/**
	 * Returns the given pool.
	 *
	 * @param __rt Use the run-time pool?
	 * @return The given pool.
	 * @since 2019/12/14
	 */
	public final AbstractPoolParser pool(boolean __rt)
	{
		return (__rt ? this.runtimepool : this.classpool); 
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassFieldsParser.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
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
191
192
































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This class is used to parse the fields of a class.
 *
 * @since 2019/11/17
 */
public final class ClassFieldsParser
{
	/** The size of entries in the field list. */
	public static final byte ENTRY_SIZE =
		16;
	
	/** Offset to field flags. */
	public static final byte FLAGS_INT_OFFSET =
		0;
		
	/** Offset to offset within class base. */
	public static final byte OFFSET_USHORT_OFFSET =
		4;
	
	/** Offset to field size. */
	public static final byte SIZE_USHORT_OFFSET =
		6;
		
	/** Offset to field name. */
	public static final byte NAME_USHORT_OFFSET =
		8;
	
	/** Offset to field type. */
	public static final byte TYPE_USHORT_OFFSET =
		10;
		
	/** Offset to constant value. */
	public static final byte CVALUE_USHORT_OFFSET =
		12;
		
	/** Offset to the data type. */
	public static final byte DATATYPE_BYTE_OFFSET =
		14;
	
	/** The constant pool for the class. */
	protected final ClassDualPoolParser pool;
	
	/** The blob for the field data. */
	protected final BinaryBlob blob;
	
	/** The number of fields available. */
	protected final int count;
	
	/**
	 * Initializes the class fields parser.
	 *
	 * @param __cp The dual pool parser.
	 * @param __b The binary blob.
	 * @param __n The field count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public ClassFieldsParser(ClassDualPoolParser __cp, BinaryBlob __b, int __n)
		throws NullPointerException
	{
		if (__cp == null || __b == null)
			throw new NullPointerException("NARG");
		
		this.pool = __cp;
		this.blob = __b;
		this.count = __n;
	}
	
	/**
	 * Returns the number of fields.
	 *
	 * @return The number of fields.
	 * @since 2019/11/17
	 */
	public final int count()
	{
		return this.count;
	}
	
	/**
	 * Returns the flags for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The field flags.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int flags(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaInt(this.tocOffset(__dx) +
			FLAGS_INT_OFFSET);
	}
	
	/**
	 * Returns the name of the field.
	 *
	 * @param __dx The index of the field.
	 * @return The name of the field.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final String name(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsString(false, this.blob.readJavaUnsignedShort(
			this.tocOffset(__dx) + NAME_USHORT_OFFSET));
	}
	
	/**
	 * Returns the offset for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The field offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int offset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaUnsignedShort(this.tocOffset(__dx) +
			OFFSET_USHORT_OFFSET);
	}
	
	/**
	 * Returns the size for the field.
	 *
	 * @param __dx The index of the field.
	 * @return The size offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int size(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readJavaUnsignedShort(this.tocOffset(__dx) +
			SIZE_USHORT_OFFSET);
	}
	
	/**
	 * Index of the entry in the table of contents.
	 *
	 * @param __dx The index.
	 * @return The table of contents offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/24
	 */
	public final int tocOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx > this.count)
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ENTRY_SIZE;
	}
	
	/**
	 * Returns the type of the field.
	 *
	 * @param __dx The index of the field.
	 * @return The type of the field.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/11/25
	 */
	public final PoolClassName type(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsClassName(false,
			this.blob.readJavaUnsignedShort(this.tocOffset(__dx) +
				TYPE_USHORT_OFFSET));
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassFileConstants.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This interface defines all of the class file constants which is used to
 * remove the usages of magic numbers.
 *
 * @since 2019/10/12
 */
public interface ClassFileConstants
{
	/** The magic number for the header. */
	public static final int MAGIC_NUMBER =
		0x00586572;
	
	/** Magic number for the end of file. */
	public static final int END_MAGIC_NUMBER =
		0x42796521;
	
	/** The size of the header without the magic number. */
	public static final byte HEADER_SIZE_WITHOUT_MAGIC =
		108;
	
	/** The size of the header with the magic number. */
	public static final byte HEADER_SIZE_WITH_MAGIC =
		112;
		
	/** Unused A. */
	public static final byte OFFSET_OF_USHORT_UNUSEDA =
		4;
	
	/** The index of the method which is __start. */
	public static final byte OFFSET_OF_UBYTE_STARTMETHODINDEX =
		6;
	
	/** The data type of the class. */
	public static final byte OFFSET_OF_UBYTE_DATATYPE =
		7;
	
	/** Not used. */
	public static final byte OFFSET_OF_USHORT_UNUSEDB =
		8;
	
	/** Class flags. */
	public static final byte OFFSET_OF_INT_CLASSFLAGS =
		10;
	
	/** Name of class. */
	public static final byte OFFSET_OF_USHORT_CLASSNAME =
		14;
	
	/** Super class name. */
	public static final byte OFFSET_OF_USHORT_CLASSSUPER =
		16;
	
	/** Interfaces in class. */
	public static final byte OFFSET_OF_USHORT_CLASSINTS =
		18;
	
	/** Class type. */
	public static final byte OFFSET_OF_UBYTE_CLASSTYPE =
		20;
	
	/** Class version. */
	public static final byte OFFSET_OF_UBYTE_CLASSVERS =
		21;
	
	/** Class source filename. */
	public static final byte OFFSET_OF_USHORT_CLASSSFN =
		22;
	
	/** Static field count. */
	public static final byte OFFSET_OF_USHORT_SFCOUNT =
		24;
	
	/** Static field bytes. */
	public static final byte OFFSET_OF_USHORT_SFBYTES =
		26;
	
	/** Static field objects. */
	public static final byte OFFSET_OF_USHORT_SFOBJS =
		28;
	
	/** Instance field count. */
	public static final byte OFFSET_OF_USHORT_IFCOUNT =
		30;
	
	/** Instance field bytes. */
	public static final byte OFFSET_OF_USHORT_IFBYTES =
		32;
	
	/** Instance field objects. */
	public static final byte OFFSET_OF_USHORT_IFOBJS =
		34;
	
	/** Static method count. */
	public static final byte OFFSET_OF_USHORT_SMCOUNT =
		36;
	
	/** Instance method count. */
	public static final byte OFFSET_OF_USHORT_IMCOUNT =
		38;
	
	/** Not used. */
	public static final byte OFFSET_OF_INT_UNUSEDC =
		40;
	
	/** Not used. */
	public static final byte OFFSET_OF_INT_UNUSEDD =
		44;
	
	/** Static field data offset. */
	public static final byte OFFSET_OF_INT_SFOFF =
		48;
	
	/** Static field data size. */
	public static final byte OFFSET_OF_INT_SFSIZE =
		52;
	
	/** Interface field data offset. */
	public static final byte OFFSET_OF_INT_IFOFF =
		56;
	
	/** Interface field data size. */
	public static final byte OFFSET_OF_INT_IFSIZE =
		60;
	
	/** Static method data offset. */
	public static final byte OFFSET_OF_INT_SMOFF =
		64;
	
	/** Static method data size. */
	public static final byte OFFSET_OF_INT_SMSIZE =
		68;
	
	/** Instance method data offset. */
	public static final byte OFFSET_OF_INT_IMOFF =
		72;
	
	/** Instance method data size. */
	public static final byte OFFSET_OF_INT_IMSIZE =
		76;
	
	/** High bits for UUID. */
	public static final byte OFFSET_OF_INT_UUIDHI =
		80;
	
	/** Low bits for UUID. */
	public static final byte OFFSET_OF_INT_UUIDLO =
		84;
	
	/** File size. */
	public static final byte OFFSET_OF_INT_FILESIZE =
		88;
	
	/** Not used. */
	public static final byte OFFSET_OF_INT_UNUSEDE =
		92;
	
	/** Static constant pool offset. */
	public static final byte OFFSET_OF_INT_STATICPOOLOFF =
		96;
	
	/** Static constant pool size. */
	public static final byte OFFSET_OF_INT_STATICPOOLSIZE =
		100;
	
	/** Runtime constant pool offset. */
	public static final byte OFFSET_OF_INT_RUNTIMEPOOLOFF =
		104;
	
	/** Runtime constant pool size. */
	public static final byte OFFSET_OF_INT_RUNTIMEPOOLSIZE =
		108;
	
	/** Public class. */
	public static final short FLAG_PUBLIC =
		0x0001;
	
	/** Final class. */
	public static final short FLAG_FINAL =
		0x0010;
	
	/** Super class. */
	public static final short FLAG_SUPER =
		0x0020;
	
	/** Interface class. */
	public static final short FLAG_INTERFACE =
		0x0200;
	
	/** Abstract. */
	public static final short FLAG_ABSTRACT =
		0x0400;
	
	/** Synthetic. */
	public static final short FLAG_SYNTHETIC =
		0x1000;
	
	/** Annotation. */
	public static final short FLAG_ANNOTATION =
		0x2000;
	
	/** Enum. */
	public static final short FLAG_ENUM =
		0x4000;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassFileParser.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
















































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;
import cc.squirreljme.jvm.io.MemoryBlob;

/**
 * This utility exists for the parsing of SquirrelJME's class files and allows
 * the bootstrap and class loaders the ability to read them.
 *
 * @since 2019/10/06
 */
public final class ClassFileParser
{
	/** The blob of the class. */
	public final BinaryBlob blob;
	
	/** Root static split pool, when aliased. */
	protected final AbstractPoolParser rootstaticpool;
	
	/** Root runtime split pool, when aliased. */
	protected final AbstractPoolParser rootruntimepool;
	
	/**
	 * Initializes the class file parser.
	 *
	 * @param __blob The ROM blob.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public ClassFileParser(BinaryBlob __blob)
		throws NullPointerException
	{
		this(__blob, null, null);
	}
	
	/**
	 * Initializes the class file parser.
	 *
	 * @param __blob The ROM blob.
	 * @param __sp Static pool, may be {@code null}.
	 * @param __rp Run-time pool, may be {@code null}.
	 * @throws NullPointerException On null arguments, except for the pools.
	 * @since 2019/10/06
	 */
	public ClassFileParser(BinaryBlob __blob, AbstractPoolParser __sp,
		AbstractPoolParser __rp)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
		this.rootstaticpool = __sp;
		this.rootruntimepool = __rp;
	}
	
	/**
	 * Returns the base address of the class if it is known.
	 *
	 * @return The base address or {@code 0} if it is not known.
	 * @since 2019/12/01
	 */
	public final int baseAddress()
	{
		BinaryBlob blob = this.blob;
		if (blob instanceof MemoryBlob)
			return ((MemoryBlob)blob).baseAddress();
		return 0;
	}
	
	/**
	 * Returns the number of fields in the class.
	 *
	 * @param __is Get the static field count.
	 * @return The number of fields in the class.
	 * @since 2019/10/26
	 */
	public final int fieldCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFCOUNT :
			ClassFileConstants.OFFSET_OF_USHORT_IFCOUNT));
	}
	
	/**
	 * Returns the field data offset.
	 *
	 * @param __is Get the static field data offset.
	 * @return The field data offset.
	 * @since 2019/11/17
	 */
	public final int fieldDataOffset(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SFOFF :
			ClassFileConstants.OFFSET_OF_INT_IFOFF));
	}
	
	/**
	 * Returns the field data size.
	 *
	 * @param __is Get the static field data size.
	 * @return The field data size.
	 * @since 2019/11/17
	 */
	public final int fieldDataSize(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SFSIZE :
			ClassFileConstants.OFFSET_OF_INT_IFSIZE));
	}
	
	/**
	 * Returns a parser for class fields.
	 *
	 * @param __is Get static fields?
	 * @return The parser for fields.
	 * @since 2019/11/17
	 */
	public final ClassFieldsParser fields(boolean __is)
	{
		BinaryBlob blob = this.blob;
		return new ClassFieldsParser(this.pool(),
			this.blob.subSection(this.fieldDataOffset(__is),
				this.fieldDataSize(__is)), this.fieldCount(__is));
	}
	
	/**
	 * Returns the size of all of the fields in bytes.
	 *
	 * @param __is Get the size of static fields?
	 * @return The number of bytes the field requires for consumption.
	 * @since 2019/10/21
	 */
	public final int fieldSize(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFBYTES :
			ClassFileConstants.OFFSET_OF_USHORT_IFBYTES));
	}
	
	/**
	 * Returns the raw class flags.
	 *
	 * @return The class flags.
	 * @since 2019/12/01
	 */
	public final int flags()
	{
		return this.blob.readJavaInt(
			ClassFileConstants.OFFSET_OF_INT_CLASSFLAGS);
	}
	
	/**
	 * Returns the names of the interfaces that this class implements.
	 *
	 * @return The names of the implemented interfaces.
	 * @since 2019/12/01
	 */
	public final PoolClassName[] interfaceNames()
	{
		PoolClassName[] rv = this.pool().entryAsClassNames(false, this.blob.
			readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSINTS));
		return (rv == null ? new PoolClassName[0] : rv);
	}
	
	/**
	 * Gets the code bytes which represent the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @return The blob for the method, or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final BinaryBlob methodCodeBytes(String __mn, String __mt)
		throws NullPointerException
	{
		if (__mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// Search static methods first
		for (boolean dostatic = true;; dostatic = false)
		{
			// Get methods parser
			ClassMethodsParser methods = this.methods(dostatic);
			
			// See if method is a match
			for (int i = 0, n = methods.count; i < n; i++)
				if (__mn.equals(methods.name(i)) &&
					__mt.equals(methods.type(i).toString()))
					return methods.code(i);
			
			// End?
			if (!dostatic)
				break;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Returns the number of methods in the class.
	 *
	 * @param __is Get the static method count.
	 * @return The number of methods in the class.
	 * @since 2019/11/29
	 */
	public final int methodCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SMCOUNT :
			ClassFileConstants.OFFSET_OF_USHORT_IMCOUNT));
	}
	
	/**
	 * Returns the method data offset.
	 *
	 * @param __is Get the static method data offset.
	 * @return The method data offset.
	 * @since 2019/11/29
	 */
	public final int methodDataOffset(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SMOFF :
			ClassFileConstants.OFFSET_OF_INT_IMOFF));
	}
	
	/**
	 * Returns the method data size.
	 *
	 * @param __is Get the static method data size.
	 * @return The method data size.
	 * @since 2019/11/29
	 */
	public final int methodDataSize(boolean __is)
	{
		return this.blob.readJavaInt(
			(__is ? ClassFileConstants.OFFSET_OF_INT_SMSIZE :
			ClassFileConstants.OFFSET_OF_INT_IMSIZE));
	}
	
	/**
	 * Returns a parser for class methods.
	 *
	 * @param __is Get static methods?
	 * @return The parser for methods.
	 * @since 2019/11/29
	 */
	public final ClassMethodsParser methods(boolean __is)
	{
		BinaryBlob blob = this.blob;
		return new ClassMethodsParser(this.pool(),
			this.blob.subSection(this.methodDataOffset(__is),
				this.methodDataSize(__is)), this.methodCount(__is));
	}
	
	/**
	 * Returns the number of objects in the class.
	 *
	 * @param __is Get the static object count.
	 * @return The number of objects in the class.
	 * @since 2019/11/29
	 */
	public final int objectCount(boolean __is)
	{
		return this.blob.readJavaUnsignedShort(
			(__is ? ClassFileConstants.OFFSET_OF_USHORT_SFOBJS :
			ClassFileConstants.OFFSET_OF_USHORT_IFOBJS));
	}
	
	/**
	 * Returns a dual pool parser for this class.
	 *
	 * @return The dual pool parser.
	 * @since 2019/10/13
	 */
	public final ClassDualPoolParser pool()
	{
		return new ClassDualPoolParser(this.splitPool(false),
			this.splitPool(true));
	}
	
	/**
	 * Returns the appropriate pool parser.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @throws InvalidClassFormatException If the pool is virtual and no
	 * root pool was specified.
	 * @since 2019/11/17
	 */
	public final AbstractPoolParser splitPool(boolean __rt)
		throws InvalidClassFormatException
	{
		int off = this.splitPoolOffset(__rt),
			len = this.splitPoolSize(__rt);
		
		// Blob needed to read any pool type from
		BinaryBlob blob = this.blob;
		
		// Is a virtually aliased pool and relies on a higher up ROM pool
		// for this to be decoded. Use the static pool because the run-time
		// pool can be empty if the class has no methods
		if (this.splitPoolSize(false) < 0)
		{
			// {@squirreljme.error SV0t No root pool was specified and the
			// class pool is purely virtual.}
			AbstractPoolParser rootp = (__rt ? this.rootruntimepool :
				this.rootstaticpool);
			if (rootp == null)
				throw new InvalidClassFormatException("SV0t");
			
			// Initialize aliased pool
			return new AliasedPoolParser(blob.subSection(off, -len), rootp);
		}
		
		// Otherwise read the data straight from the class
		return new ClassPoolParser(blob.subSection(off, len));
	}
	
	/**
	 * Returns the offset of the split pool.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @return The offset of the pool.
	 * @since 2019/11/17
	 */
	public final int splitPoolOffset(boolean __rt)
	{
		return this.blob.readJavaInt(
			(__rt ? ClassFileConstants.OFFSET_OF_INT_RUNTIMEPOOLOFF :
			ClassFileConstants.OFFSET_OF_INT_STATICPOOLOFF));
	}
	
	/**
	 * Returns the size of the split pool.
	 *
	 * @param __rt Obtain the run-time pool?
	 * @return The size of the pool.
	 * @since 2019/11/17
	 */
	public final int splitPoolSize(boolean __rt)
	{
		return this.blob.readJavaInt(
			(__rt ? ClassFileConstants.OFFSET_OF_INT_RUNTIMEPOOLSIZE :
			ClassFileConstants.OFFSET_OF_INT_STATICPOOLSIZE));
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super-class of this class.
	 * @since 2019/11/25
	 */
	public final PoolClassName superClassName()
	{
		return this.pool().entryAsClassName(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSSUPER));
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/11/25
	 */
	public final PoolClassName thisName()
	{
		return this.pool().entryAsClassName(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSNAME));
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/11/25
	 */
	public final BinaryBlob thisNameAsBinaryBlob()
	{
		return this.pool().entryData(false,
			this.blob.readJavaUnsignedShort(
				ClassFileConstants.OFFSET_OF_USHORT_CLASSNAME), false);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassInfoProperty.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This contains properties of class info.
 *
 * @since 2019/11/30
 */
public interface ClassInfoProperty
{
	/** Self pointer. */
	public static final byte INT_SELFPTR =
		0;
	
	/** Magic number used to detect corruption. */
	public static final byte INT_MAGIC =
		1;
	
	/** Class information flags. */
	public static final byte INT_FLAGS =
		2;
	
	/** The pointer to the minimized class file. */
	public static final byte INT_MINIPTR =
		3;
	
	/** The pointer to the class name. */
	public static final byte INT_NAMEP =
		4;
	
	/** The allocation size of this class. */
	public static final byte INT_SIZE =
		5;
	
	/** The base offset for fields in this class. */
	public static final byte INT_BASE =
		6;
	
	/** The number of objects in the instance fields, for GC. */
	public static final byte INT_NUMOBJECTS =
		7;
	
	/** The dimensions this class uses, if it is an array. */
	public static final byte INT_DIMENSIONS =
		8;
	
	/** The cell size of components if this is an array. */
	public static final byte INT_CELLSIZE =
		9;
	
	/** The super class data. */
	public static final byte CLASSINFO_SUPERCLASS =
		10;
	
	/** Interfaces. */
	public static final byte CLASSINFO_ARRAY_INTERFACECLASSES =
		11;
	
	/** The component class. */
	public static final byte CLASSINFO_COMPONENTCLASS =
		12;
	
	/** Pointer to the class object. */
	public static final byte CLASS_CLASSOBJPTR =
		13;
	
	/** Virtual invoke VTable. */
	public static final byte INT_ARRAY_VTABLEVIRTUAL =
		14;
	
	/** Virtual invoke VTable pool entries. */
	public static final byte INT_ARRAY_VTABLEPOOL =
		15;
	
	/** The pointer to the constant pool of this class. */
	public static final byte INT_POOL =
		16;
	
	/** The JAR Index. */
	public static final byte INT_JARDX =
		17;
	
	/** The number of methods the class has. */
	public static final byte INT_NUMMETHODS =
		18;
	
	/** The depth of this class. */
	public static final byte INT_CLASSDEPTH =
		19;
	
	/** Static field offset. */
	public static final byte INT_SFOFFSET =
		20;
	
	/** New instance method. */
	public static final byte INT_DEFAULTNEW =
		21;
	
	/** The number of properties available. */
	public static final byte NUM_PROPERTIES =
		22;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassInfoUtility.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699



























































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.task.TaskClass;

/**
 * This is a utility which allows access to the various fields within
 * {@link cc.squirreljme.jvm.ClassInfo}.
 *
 * @since 2019/11/30
 */
public final class ClassInfoUtility
{
	/** The allocation size. */
	protected final int allocationsize;
	
	/** Class info properties. */
	protected final int[] properties;
	
	/**
	 * Initializes the class info utility.
	 *
	 * @param __as The allocation size.
	 * @param __props Class info properties.
	 * @since 2019/11/30
	 */
	public ClassInfoUtility(int __as, int[] __props)
	{
		this.allocationsize = __as;
		
		int[] properties = new int[ClassInfoProperty.NUM_PROPERTIES];
		for (int i = 0, lim = Math.min(__props.length,
			ClassInfoProperty.NUM_PROPERTIES); i < lim; i++)
			properties[i] = __props[i];
		this.properties = properties;
	}
	
	/**
	 * Returns the class allocation size.
	 *
	 * @param __cl The class.
	 * @return The class allocation size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int classAllocationSize(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_SIZE);
	}
	
	/**
	 * Returns the class depth.
	 *
	 * @param __cl The class.
	 * @return The class depth.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int classDepth(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_CLASSDEPTH);
	}
	
	/**
	 * Returns the allocation size of instances of this class.
	 *
	 * @return The allocation size of this.
	 * @since 2019/11/30
	 */
	public final int classInfoAllocationSize()
	{
		return this.allocationsize;
	}
	
	/**
	 * Returns the default constructor pointer.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final int defaultNew(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_DEFAULTNEW);
	}
	
	/**
	 * Returns the ClassInfo flags.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int flags(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_FLAGS);
	}
	
	/**
	 * Returns the JAR Index.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int jarIndex(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_JARDX);
	}
	
	/**
	 * Returns the method count of the class.
	 *
	 * @param __cl The class.
	 * @return The class method count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int methodCount(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_NUMMETHODS);
	}
	
	/**
	 * Returns the object count of the class.
	 *
	 * @param __cl The class.
	 * @return The class object count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int objectCount(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_NUMOBJECTS);
	}
	
	/**
	 * Returns the pool pointer.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int poolPointer(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_POOL);
	}
	
	/**
	 * Returns the specified property.
	 *
	 * @param __cl The class.
	 * @param __prop The property to return.
	 * @return The property value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int property(TaskClass __cl, int __prop)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return Assembly.memReadInt(__cl.infoPointer(),
			this.properties[__prop]);
	}
	
	/**
	 * Sets the base of the class.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setBaseSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_BASE,
			__v);
	}
	
	/**
	 * Sets the cell size.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setCellSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_CELLSIZE,
			__v);
	}
	
	/**
	 * Sets the allocation size.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setClassAllocationSize(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_SIZE,
			__v);
	}
	
	/**
	 * Sets the class depth, the number of super classes ahead of this.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setClassDepth(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_CLASSDEPTH,
			__v);
	}
	
	/**
	 * Sets the component type class.
	 *
	 * @param __cl The class.
	 * @param __co The component type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setComponentType(TaskClass __cl, TaskClass __co)
		throws NullPointerException
	{
		if (__co == null)
			throw new NullPointerException("NARG");
		
		this.setProperty(__cl, ClassInfoProperty.CLASSINFO_COMPONENTCLASS,
			__co.infoPointer());
	}
	
	/**
	 * Sets the default constructor to use.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public final void setDefaultNew(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_DEFAULTNEW,
			__v);
	}
	
	/**
	 * Sets the number of dimensions the class has.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final void setDimensions(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_DIMENSIONS,
			__v);
	}
	
	/**
	 * Sets the flags.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setFlags(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_FLAGS,
			__v);
	}
	
	/**
	 * Sets the interfaces array of the class.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setInterfaces(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl,
			ClassInfoProperty.CLASSINFO_ARRAY_INTERFACECLASSES, __v);
	}
	
	/**
	 * Sets the JAR index.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setJarIndex(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_JARDX,
			__v);
	}
	
	/**
	 * Sets the class magic number.
	 *
	 * @param __cl The class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMagicNumber(TaskClass __cl)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_MAGIC,
			ClassFileConstants.MAGIC_NUMBER);
	}
	
	/**
	 * Sets the method count.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMethodCount(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NUMMETHODS,
			__v);
	}
	
	/**
	 * Sets the mini class pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setMiniClassPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_MINIPTR,
			__v);
	}
	
	/**
	 * Sets the name pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setNamePointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NAMEP,
			__v);
	}
	
	/**
	 * Sets the object count.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setObjectCount(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_NUMOBJECTS,
			__v);
	}
	
	/**
	 * Sets the pool pointer.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setPoolPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_POOL,
			__v);
	}
	
	/**
	 * Sets the value of the given property.
	 *
	 * @param __cl The class to set.
	 * @param __prop The property to set.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setProperty(TaskClass __cl, int __prop, int __v)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Write value
		Assembly.memWriteInt(__cl.infoPointer(),
			this.properties[__prop], __v);
	}
	
	/**
	 * Sets the self pointer value.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setSelfPointer(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_SELFPTR,
			__v);
	}
	
	/**
	 * Sets the super class.
	 *
	 * @param __cl The class.
	 * @param __su The super class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setSuperClass(TaskClass __cl, TaskClass __su)
		throws NullPointerException
	{
		if (__su == null)
			throw new NullPointerException("NARG");
		
		this.setProperty(__cl, ClassInfoProperty.CLASSINFO_SUPERCLASS,
			__su.infoPointer());
	}
	
	/**
	 * Sets the VTable pool array.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setVTablePool(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_ARRAY_VTABLEPOOL,
			__v);
	}
	
	/**
	 * Sets the VTable method array.
	 *
	 * @param __cl The class.
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final void setVTableVirtual(TaskClass __cl, int __v)
		throws NullPointerException
	{
		this.setProperty(__cl, ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL,
			__v);
	}
	
	/**
	 * Returns the VTable for pools.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int vTablePool(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_ARRAY_VTABLEPOOL);
	}
	
	/**
	 * Returns the VTable for method pointers.
	 *
	 * @param __cl The class to get.
	 * @return The resulting value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public final int vTableVirtual(TaskClass __cl)
		throws NullPointerException
	{
		return this.property(__cl, ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL);
	}
	
	/**
	 * Initializes the {@code ClassInfo} utility.
	 *
	 * @param __cfp The class info parser to use.
	 * @return The utility for {@code ClassInfo}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	public static final ClassInfoUtility of(ClassFileParser __cfp)
		throws NullPointerException
	{
		if (__cfp == null)
			throw new NullPointerException("NARG");
		
		// Allocation size
		int as = Constants.OBJECT_BASE_SIZE + __cfp.fieldSize(false);
		
		// Properties
		int[] props = new int[ClassInfoProperty.NUM_PROPERTIES];
		
		// Extract properties from fields
		ClassFieldsParser cifs = __cfp.fields(false);
		for (int cif = 0, cifn = cifs.count(); cif < cifn; cif++)
		{
			// Determine actual offset of this property
			int offset = Constants.OBJECT_BASE_SIZE + cifs.offset(cif);
			
			// The property index
			int pdx;
			
			// Depends on the field name and type
			String nat = cifs.name(cif) + ":" + cifs.type(cif);
			switch (nat)
			{
					// Self pointer.
				case "selfptr:int":
					pdx = ClassInfoProperty.INT_SELFPTR;
					break;

					// Magic number used to detect corruption.
				case "magic:int":
					pdx = ClassInfoProperty.INT_MAGIC;
					break;

					// Class information flags.
				case "flags:int":
					pdx = ClassInfoProperty.INT_FLAGS;
					break;

					// The pointer to the minimized class file.
				case "miniptr:int":
					pdx = ClassInfoProperty.INT_MINIPTR;
					break;

					// The pointer to the class name.
				case "namep:int":
					pdx = ClassInfoProperty.INT_NAMEP;
					break;

					// The allocation size of this class.
				case "size:int":
					pdx = ClassInfoProperty.INT_SIZE;
					break;

					// The base offset for fields in this class.
				case "base:int":
					pdx = ClassInfoProperty.INT_BASE;
					break;

					// The number of objects in the instance fields, for GC.
				case "numobjects:int":
					pdx = ClassInfoProperty.INT_NUMOBJECTS;
					break;

					// The dimensions this class uses, if it is an array.
				case "dimensions:int":
					pdx = ClassInfoProperty.INT_DIMENSIONS;
					break;

					// The cell size of components if this is an array.
				case "cellsize:int":
					pdx = ClassInfoProperty.INT_CELLSIZE;
					break;

					// The super class data.
				case "superclass:cc/squirreljme/jvm/ClassInfo":
					pdx = ClassInfoProperty.CLASSINFO_SUPERCLASS;
					break;

					// Interfaces.
				case "interfaceclasses:[Lcc/squirreljme/jvm/ClassInfo;":
					pdx = ClassInfoProperty.CLASSINFO_ARRAY_INTERFACECLASSES;
					break;

					// The component class.
				case "componentclass:cc/squirreljme/jvm/ClassInfo":
					pdx = ClassInfoProperty.CLASSINFO_COMPONENTCLASS;
					break;

					// Pointer to the class object.
				case "classobjptr:java/lang/Class":
					pdx = ClassInfoProperty.CLASS_CLASSOBJPTR;
					break;

					// Virtual invoke VTable.
				case "vtablevirtual:[I":
					pdx = ClassInfoProperty.INT_ARRAY_VTABLEVIRTUAL;
					break;

					// Virtual invoke VTable pool entries.
				case "vtablepool:[I":
					pdx = ClassInfoProperty.INT_ARRAY_VTABLEPOOL;
					break;

					// The pointer to the constant pool of this class.
				case "pool:int":
					pdx = ClassInfoProperty.INT_POOL;
					break;
					
					// The JAR Index
				case "jardx:int":
					pdx = ClassInfoProperty.INT_JARDX;
					break;
					
					// The number of methods in the class
				case "nummethods:int":
					pdx = ClassInfoProperty.INT_NUMMETHODS;
					break;
					
					// The class depth
				case "classdepth:int":
					pdx = ClassInfoProperty.INT_CLASSDEPTH;
					break;
					
					// The static field offset
				case "sfoffset:int":
					pdx = ClassInfoProperty.INT_SFOFFSET;
					break;
					
					// Default new constructor
				case "defaultnew:int":
					pdx = ClassInfoProperty.INT_DEFAULTNEW;
					break;
				
				default:
					throw new todo.TODO(nat);
			}
			
			// Store
			props[pdx] = offset;
		}
		
		// Initialize now
		return new ClassInfoUtility(as, props);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassLibrary.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This class represents a class library which makes classes available for
 * usage and such. It allows one to obtain class library information and
 * pointers.
 *
 * @since 2019/09/22
 */
public abstract class ClassLibrary
{
	/**
	 * Locates the given resource.
	 *
	 * @param __name The name of the resource to get.
	 * @return The index of the resource or {@code -1} if it was not found.
	 * @since 2019/09/22
	 */
	public abstract int indexOf(String __name)
		throws NullPointerException;
	
	/**
	 * Returns the name of the library.
	 *
	 * @return The library name.
	 * @since 2019/09/22
	 */
	public abstract String libraryName();
	
	/**
	 * Returns the data pointer of the given index.
	 *
	 * @param __dx The index to get the data for.
	 * @return The binary blob data.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2019/07/11
	 */
	public abstract BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException;
	
	/**
	 * Returns the split pool for this library, if one is available.
	 *
	 * @param __rt Access the run-time pool?
	 * @return The split pool or {@code null} if there is none.
	 * @since 2019/11/17
	 */
	public AbstractPoolParser splitPool(boolean __rt)
	{
		return null;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassMethodsParser.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
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























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This is a parser for methods within a class.
 *
 * @since 2019/11/29
 */
public final class ClassMethodsParser
{
	/** The size of entries in the field list. */
	public static final byte ENTRY_SIZE =
		20;
	
	/** Flags offset. */
	public static final byte FLAGS_INT_OFFSET =
		0;
	
	/** Index of method. */
	public static final byte INDEX_USHORT_OFFSET =
		4;
	
	/** Name of method. */
	public static final byte NAME_USHORT_OFFSET =
		6;
	
	/** Type of method. */
	public static final byte TYPE_USHORT_OFFSET =
		8;
	
	/** Address of the code. */
	public static final byte CODE_ADDRESS_INT_OFFSET =
		10;
	
	/** Size of the code. */
	public static final byte CODE_SIZE_INT_OFFSET =
		14;
	
	/** The constant pool for the class. */
	protected final ClassDualPoolParser pool;
	
	/** The blob for the method data. */
	protected final BinaryBlob blob;
	
	/** The number of fields available. */
	protected final int count;
	
	/**
	 * Initializes the class method parser.
	 *
	 * @param __cp The dual pool parser.
	 * @param __b The binary blob.
	 * @param __n The method count.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/29
	 */
	public ClassMethodsParser(ClassDualPoolParser __cp, BinaryBlob __b,
		int __n)
		throws NullPointerException
	{
		if (__cp == null || __b == null)
			throw new NullPointerException("NARG");
		
		this.pool = __cp;
		this.blob = __b;
		this.count = __n;
	}
	
	/**
	 * Returns the blob to the method code.
	 *
	 * @param __dx The index of the method.
	 * @return The blob for the method.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final BinaryBlob code(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		BinaryBlob blob = this.blob;
		int offset = this.tocOffset(__dx);
		
		return blob.subSection(
			blob.readJavaInt(offset + CODE_ADDRESS_INT_OFFSET),
			blob.readJavaInt(offset + CODE_SIZE_INT_OFFSET));
	}
	
	/**
	 * Finds the given method and returns the index of it.
	 *
	 * @param __name The method name.
	 * @param __type The method type, may be {@code null} if not needed.
	 * @return The found index or {@code -1} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/27
	 */
	public final int findMethod(String __name, String __type)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Locate
		for (int i = 0, n = this.count; i < n; i++)
		{
			// Name does not match
			if (!__name.equals(this.name(i)))
				continue;
			
			// Type does not match
			if (__type != null && __type.equals(this.type(i)))
				continue;
			
			return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @param __dx The index of the method.
	 * @return The method name.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final String name(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsString(false, this.blob.readJavaUnsignedShort(
			this.tocOffset(__dx) + NAME_USHORT_OFFSET));
	}
	
	/**
	 * Index of the entry in the table of contents.
	 *
	 * @param __dx The index.
	 * @return The table of contents offset.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final int tocOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx > this.count)
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ENTRY_SIZE;
	}
	
	/**
	 * Returns the tyoe of the method.
	 *
	 * @param __dx The index of the method.
	 * @return The method type.
	 * @throws IndexOutOfBoundsException If the method is out of bounds.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @since 2019/12/14
	 */
	public final PoolMethodDescriptor type(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.pool.entryAsMethodDescriptor(false,
			this.blob.readJavaUnsignedShort(this.tocOffset(__dx) +
				TYPE_USHORT_OFFSET));
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassNameUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * Utilities for working with class names.
 *
 * @since 2019/11/04
 */
public final class ClassNameUtils
{
	/**
	 * Not used.
	 *
	 * @since 2019/11/04
	 */
	private ClassNameUtils()
	{
	}
	
	/**
	 * Returns the component type of the given array class.
	 *
	 * @param __cl The class to check.
	 * @return The component type of the class.
	 * @throws IllegalArgumentException If this is not an array.
	 * @throws InvalidClassFormatException If the component type is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final String componentType(String __cl)
		throws IllegalArgumentException, InvalidClassFormatException,
			NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV0o Cannot get component type of empty
		// class name.}
		int len = __cl.length();
		if (len <= 0)
			throw new IllegalArgumentException("SV0o");
		
		// {@squirreljme.error SV0p The class name is not an array.}
		if (__cl.charAt(0) != '[')
			throw new IllegalArgumentException("SV0p");
		
		switch (__cl.charAt(1))
		{
				// Primitive types
			case 'Z':	return "boolean";
			case 'B':	return "byte";
			case 'S':	return "short";
			case 'C':	return "char";
			case 'I':	return "int";
			case 'J':	return "long";
			case 'F':	return "float";
			case 'D':	return "double";
			
				// Another array
			case '[':
				return __cl.substring(1);
				
				// Class
			case 'L':
				// {@squirreljme.error SV0r Expected class name of array type
				// to end in semi-colon.}
				if (__cl.charAt(len - 1) != ';')
					throw new IllegalArgumentException("SV0r");
				return __cl.substring(2, len - 1);
			
				// {@squirreljme.error SV0q Unknown component type.}
			default:
				throw new InvalidClassFormatException("SV0q");
		}
	}
	
	/**
	 * Returns the number of dimensions the class name has.
	 *
	 * @param __cl The class name to check.
	 * @return The dimension count.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public static final int dimensions(String __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Non-array types have no dimensions ever
		if (!ClassNameUtils.isArray(__cl))
			return 0;
		
		// Count up to the last one
		for (int i = 0, n = __cl.length(); i < n; i++)
			if (__cl.charAt(i) != '[')
				return i - 1;
		
		// {@squirreljme.error SV0y Malformed array class name.}
		throw new InvalidClassFormatException("SV0y");
	}
	
	/**
	 * Checks whether the given class name is an array.
	 *
	 * @param __cl The class name to check.
	 * @return If it is an array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isArray(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return (__cl.length() >= 1 && __cl.charAt(0) == '[');
	}
	
	/**
	 * Is this the class info class?
	 *
	 * @param __cl The class name to check.
	 * @return If this is for class info.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	public static final boolean isClassInfo(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return "cc/squirreljme/jvm/ClassInfo".equals(__cl);
	}
	
	/**
	 * Checks whether the specified class is object.
	 *
	 * @param __cl The class name to check.
	 * @return If this is the object class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/29
	 */
	public static final boolean isObject(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return "java/lang/Object".equals(__cl);
	}
	
	/**
	 * Checks whether the given class name is a primitive type.
	 *
	 * @param __cl The class name to check.
	 * @return If it is a primitive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isPrimitiveType(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		switch (__cl)
		{
			case "boolean":
			case "byte":
			case "short":
			case "char":
			case "int":
			case "long":
			case "float":
			case "double":
				return true;
		}
		
		return false;
	}
	
	/**
	 * Is this an array or primitive type?
	 *
	 * @param __cl The class name to check.
	 * @return If it is an array or primitive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	public static final boolean isSpecial(String __cl)
		throws NullPointerException
	{
		return ClassNameUtils.isArray(__cl) ||
			ClassNameUtils.isPrimitiveType(__cl);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassPath.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252




























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This represents a class path which contains multiple class libraries.
 *
 * @since 2019/09/22
 */
public final class ClassPath
{
	/** The shift for index access. */
	private static final int _INDEX_SHIFT =
		24;
	
	/** The mask for the index. */
	private static final int _INDEX_MASK =
		0x00FFFFFF;
	
	/** Mask for JAR index. */
	private static final int _JAR_MASK =
		0x7F000000;
	
	/** The classpath. */
	public final ClassLibrary[] classpath;
	
	/**
	 * Initializes the classpath.
	 *
	 * @param __cp The class path to use.
	 * @throws IllegalArgumentException If the number of class path libraries
	 * exceeds the absolute limit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/22
	 */
	public ClassPath(ClassLibrary... __cp)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV0a Too many entries on the class path.}
		int n = __cp.length;
		if (n > (_JAR_MASK >>> _INDEX_SHIFT))
			throw new IllegalArgumentException("SV0a");
		
		// Defensive copy and check
		ClassLibrary[] classpath = new ClassLibrary[n];
		for (int i = 0; i < n; i++)
		{
			// Make sure this is not null!
			ClassLibrary cl = __cp[i];
			if (cl == null)
				throw new NullPointerException("NARG");
			
			classpath[i] = cl;
		}
		
		// Use this
		this.classpath = classpath;
	}
	
	/**
	 * Returns the class library of the given index.
	 *
	 * @param __rcdx The class library to get the index of.
	 * @return The class library of the given index.
	 * @throws IndexOutOfBoundsException If the resource index is outside
	 * of bounds.
	 * @since 2019/11/17
	 */
	public final ClassLibrary classLibrary(int __rcdx)
		throws IndexOutOfBoundsException
	{
		return this.classpath[ClassPath.resourceIndexToJarIndex(__rcdx)];
	}
	
	/**
	 * Returns a class file parser for the given index.
	 *
	 * @param __rcdx The index to load.
	 * @return The class file parser.
	 * @throws IndexOutOfBoundsException If the resource is not valid.
	 * @since 2019/11/17
	 */
	public final ClassFileParser classParser(int __rcdx)
		throws IndexOutOfBoundsException
	{
		// We need to take the pools from the class library, if it has any
		ClassLibrary clib = this.classLibrary(__rcdx);
		
		return new ClassFileParser(this.resourceData(__rcdx),
			clib.splitPool(false), clib.splitPool(true));
	}
	
	/**
	 * Searches for the given class name resource for the given class
	 *
	 * @param __name The name of the class.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceClassFind(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		return this.resourceFind(__name + ".class");
	}
	
	/**
	 * Returns the data pointer for the given resource.
	 *
	 * @param __dx The index to get the data pointer for.
	 * @return The data pointer of the resource.
	 * @throws IndexOutOfBoundsException If the index is not found in any
	 * library.
	 * @since 2019/07/11
	 */
	public final BinaryBlob resourceData(int __dx)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV08 Out of range resource.}
		int cpdx = __dx >>> _INDEX_SHIFT;
		ClassLibrary[] classpath = this.classpath;
		if (cpdx < 0 || cpdx >= classpath.length)
			throw new IndexOutOfBoundsException("SV08");
		
		// Get resource pointer from this
		return classpath[cpdx].resourceData(__dx & _INDEX_MASK);
	}
	
	/**
	 * Searches for the given resource in this client task.
	 *
	 * @param __name The name of the resource.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFind(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Scan the classpath
		ClassLibrary[] classpath = this.classpath;
		for (int i = 0, n = classpath.length; i < n; i++)
		{
			// Locate resource
			int rv = classpath[i].indexOf(__name);
			
			// Was found?
			if (rv >= 0)
				return (i << _INDEX_SHIFT) | rv;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Searches for the given resource in this client task in the given
	 * specified classpath library.
	 *
	 * @param __name The name of the resource.
	 * @param __in The class path library to look in.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFindIn(String __name, int __in)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Out of range values are always not found
		ClassLibrary[] classpath = this.classpath;
		if (__in < 0 || __in >= classpath.length)
			return -1;
		
		// Locate resource
		int rv = classpath[__in].indexOf(__name);
		
		// If it was found shift in
		if (rv >= 0)
			return (__in << _INDEX_SHIFT) | rv;
		
		// Otherwise does not exist
		return -1;
	}
	
	/**
	 * Searches for the given resource in this client task in the given
	 * specified classpath library, if it is not found in that library then
	 * all libraries on the classpath are searched.
	 *
	 * @param __name The name of the resource.
	 * @param __in The class path library to look in.
	 * @return A negative value if not found, otherwise the class path index
	 * will be shifted up by {@link #_INDEX_SHIFT} and the resource index will
	 * be on the lower mask.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/11
	 */
	public final int resourceFindInOtherwise(String __name, int __in)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Search in this specific library first
		int rv = this.resourceFindIn(__name, __in);
		if (rv >= 0)
			return rv;
		
		// Then locate it in any class library
		return this.resourceFind(__name);
	}
	
	/** 
	 * Returns the JAR index of the given resource index.
	 *
	 * @param __rcid The resource index.
	 * @return The JAR index of the given resource.
	 * @since 2019/10/27
	 */
	public static final int resourceIndexToJarIndex(int __rcid)
	{
		return (__rcid & _JAR_MASK) >>> _INDEX_SHIFT;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassPoolConstants.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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * Constants used when parsing the constant pool and such.
 *
 * @since 2019/10/13
 */
public interface ClassPoolConstants
{
	/** Offset to the tag type. */
	public static final byte OFFSET_OF_BYTE_ENTRY_TAG =
		0;
	
	/** Offset to the number of parts. */
	public static final byte OFFSET_OF_BYTE_ENTRY_NUMPARTS =
		1;
	
	/** Offset to the length of the data. */
	public static final byte OFFSET_OF_USHORT_ENTRY_LENGTH =
		2;
	
	/** Offset to the entry. */
	public static final byte OFFSET_OF_INT_ENTRY_OFFSET =
		4;
	
	/** Size of entries. */
	public static final byte ENTRY_SIZE =
		8;
	
	/** String type. */
	public static final byte TYPE_STRING =
		1;
	
	/** Class name. */
	public static final byte TYPE_CLASSNAME =
		2;
	
	/** Class names. */
	public static final byte TYPE_CLASSNAMES =
		3;
	
	/** Class pool pointer. */
	public static final byte TYPE_CLASS_POOL_POINTER =
		4;
	
	/** Method descriptor. */
	public static final byte TYPE_METHOD_DESCRIPTOR =
		7;
	
	/** A string that is used as a constant (cached). */
	public static final byte TYPE_USED_STRING =
		12;
	
	/** Class information pointer. */
	public static final byte TYPE_CLASS_INFO_POINTER =
		14;
	
	/** Noted string. */
	public static final byte TYPE_NOTED_STRING =
		15;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/ClassPoolParser.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
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




























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This class is used to parse individual pool treads.
 *
 * @see ClassDualPoolParser
 * @since 2019/10/12
 */
public final class ClassPoolParser
	extends AbstractPoolParser
{
	/** The blob for this pool. */
	protected final BinaryBlob blob;
	
	/** The size of this pool. */
	private int _size =
		-1;
	
	/**
	 * Initializes the constant pool parser.
	 *
	 * @param __b The blob data for the pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/12
	 */
	public ClassPoolParser(BinaryBlob __blob)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final int count(boolean __ft)
		throws InvalidClassFormatException
	{
		// If the size is negative, it has never been read before
		int rv = this._size;
		if (rv < 0)
			this._size = (rv = this.blob.readJavaInt(
				ClassPoolConstants.OFFSET_OF_INT_ENTRY_OFFSET));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final BinaryBlob entryData(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		int tocoff = this.entryTableOffset(__dx);
		
		// Return blob to just the data area
		BinaryBlob blob = this.blob;
		return blob.subSection(blob.readJavaInt(tocoff +
			ClassPoolConstants.OFFSET_OF_INT_ENTRY_OFFSET),
			blob.readJavaUnsignedShort(tocoff +
				ClassPoolConstants.OFFSET_OF_USHORT_ENTRY_LENGTH));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final short[] entryParts(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		int tocoff = this.entryTableOffset(__dx);
		
		// We need the part count, since these values may be wide or not
		BinaryBlob blob = this.blob;
		int numparts = blob.readByte(tocoff +
			ClassPoolConstants.OFFSET_OF_BYTE_ENTRY_NUMPARTS);
		
		// The parts is actually in the data, so we have to access it!
		BinaryBlob data = this.entryData(__dx);
		
		// Wide
		short[] rv;
		if (numparts < 0)
		{
			// Setup array
			rv = new short[-numparts];
			
			// Read in parts
			for (int i = 0, p = 0; i > numparts; i--, p += 2)
				rv[-i] = data.readJavaShort(p);
		}
		
		// Narrow
		else
		{
			// Setup array
			rv = new short[numparts];
			
			// Read in parts
			for (int i = 0, p = 0; i < numparts; i++, p++)
				rv[i] = data.readByte(p);
		}
		
		// Use whatever values were read
		return rv;
	}
	
	/**
	 * Returns the offset of the pool entry in the table of contents.
	 *
	 * @param __dx The index to get.
	 * @return The offset in the table of contents.
	 * @throws IndexOutOfBoundsException If the index is out of bounds.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @since 2019/11/24
	 */
	public final int entryTableOffset(int __dx)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		if (__dx < 0 || __dx >= this.count())
			throw new IndexOutOfBoundsException("IOOB");
		
		return __dx * ClassPoolConstants.ENTRY_SIZE;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/24
	 */
	@Override
	public final int entryType(int __dx, boolean __ft)
		throws IndexOutOfBoundsException, InvalidClassFormatException
	{
		return this.blob.readUnsignedByte(this.entryTableOffset(__dx) +
			ClassPoolConstants.OFFSET_OF_BYTE_ENTRY_TAG);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/DataType.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This contains the various data types classes and fields may be.
 *
 * @since 2019/10/12
 */
public interface DataType
{
	/** Object. */
	public static final byte OBJECT =
		0;
	
	/** Byte. */
	public static final byte BYTE =
		1;
	
	/** Short. */
	public static final byte SHORT =
		2;
	
	/** Character. */
	public static final byte CHARACTER =
		3;
	
	/** Integer. */
	public static final byte INTEGER =
		4;
	
	/** Float. */
	public static final byte FLOAT =
		5;
	
	/** Long. */
	public static final byte LONG =
		6;
	
	/** Double. */
	public static final byte DOUBLE =
		7;
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/InvalidClassFormatException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This is thrown when a class is not valid.
 *
 * @since 2019/11/17
 */
public class InvalidClassFormatException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/11/17
	 */
	public InvalidClassFormatException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/PoolClassInfoPointer.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This is a reference to a Class's information pointer.
 *
 * @since 2019/12/15
 */
public final class PoolClassInfoPointer
{
	/** The name of the class. */
	protected final String name;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __n The name of the class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public PoolClassInfoPointer(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/15
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/PoolClassName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import java.util.Objects;

/**
 * This represents a class name within the constant pool.
 *
 * @since 2019/11/25
 */
public final class PoolClassName
{
	/** The class name. */
	protected final String name;
	
	/** The component type. */
	protected final PoolClassName componenttype;
	
	/**
	 * Initializes the pool class name.
	 *
	 * @param __n The name of the class.
	 * @param __cp The component type, this is optional.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/25
	 */
	public PoolClassName(String __n, PoolClassName __cp)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.componenttype = __cp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (!(__o instanceof PoolClassName))
			return false;
		
		PoolClassName o = (PoolClassName)__o;
		return this.name.equals(o.name) &&
			Objects.equals(this.componenttype, o.componenttype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^
			Objects.hashCode(this.componenttype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/11/25
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/PoolClassPoolPointer.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This is a reference to a Class's pool pointer.
 *
 * @since 2019/12/15
 */
public final class PoolClassPoolPointer
{
	/** The name of the class. */
	protected final String name;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __n The name of the class.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public PoolClassPoolPointer(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/15
	 */
	@Override
	public final String toString()
	{
		return this.name;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/PoolMethodDescriptor.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

/**
 * This represents a method descriptor.
 *
 * @since 2019/12/14
 */
public final class PoolMethodDescriptor
{
	/** The descriptor. */
	protected final String descriptor;
	
	/** The return value. */
	protected final PoolClassName returnvalue;
	
	/** Arguments. */
	private final PoolClassName[] _args;
	
	/**
	 * Initializes the descriptor.
	 *
	 * @param __str The string to use.
	 * @param __rv The return value.
	 * @param __args The arguments.
	 * @throws NullPointerException If no string or arguments were specified.
	 * @since 2019/12/14
	 */
	public PoolMethodDescriptor(String __str, PoolClassName __rv,
		PoolClassName... __args)
		throws NullPointerException
	{
		if (__str == null || __args == null)
			throw new NullPointerException("NARG");
		
		this.descriptor = __str;
		this.returnvalue = __rv;
		
		// Copy arguments
		int numargs = __args.length;
		PoolClassName[] args = new PoolClassName[numargs];
		for (int i = 0; i < numargs; i++)
		{
			PoolClassName a = __args[i];
			if (a == null)
				throw new NullPointerException("NARG");
			
			args[i] = a;
		}
		
		this._args = args;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public final String toString()
	{
		return this.descriptor;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/PoolNotedString.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.lib;

import cc.squirreljme.jvm.io.BinaryBlob;

/**
 * This represents a noted string.
 *
 * @since 2019/12/14
 */
public final class PoolNotedString
{
	/** The blob for the string data. */
	protected final BinaryBlob blob;
	
	/**
	 * Initializes the noted string.
	 *
	 * @param __blob The blob for this string.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/14
	 */
	public PoolNotedString(BinaryBlob __blob)
		throws NullPointerException
	{
		if (__blob == null)
			throw new NullPointerException("NARG");
		
		this.blob = __blob;
	}
	
	/**
	 * Returns the blob for this string.
	 *
	 * @return The used blob.
	 * @since 2019/12/14
	 */
	public final BinaryBlob blob()
	{
		return this.blob;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/lib/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the information and classes for handling the class
 * library within the SquirrelJME JVM instance.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.lib;

Deleted runt/klib/supervisor/cc/squirreljme/jvm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This contains JVM specific implementation details along with the supervisor.
 *
 * @since 2019/05/25
 */

package cc.squirreljme.jvm;

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/NoSuchMethodTaskException.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when there is no such method.
 *
 * @since 2019/12/14
 */
public class NoSuchMethodTaskException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchMethodTaskException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/NoSuchTaskException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when there is no such given task.
 *
 * @since 2019/12/14
 */
public class NoSuchTaskException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public NoSuchTaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public NoSuchTaskException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/Task.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245





















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Allocator;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.io.BinaryBlob;
import cc.squirreljme.jvm.Globals;
import cc.squirreljme.jvm.lib.ClassFileParser;
import cc.squirreljme.jvm.lib.ClassInfoUtility;
import cc.squirreljme.jvm.lib.ClassLibrary;
import cc.squirreljme.jvm.lib.ClassNameUtils;
import cc.squirreljme.jvm.lib.ClassPath;
import java.util.HashMap;

/**
 * This represents a single task which has information on what it is running
 * along with its ID and such.
 *
 * @since 2019/06/22
 */
public final class Task
{
	/** The physical task ID. */
	public final int pid;
	
	/** The logical task ID. */
	public final int lid;
	
	/** Allocator for this task. */
	public final TaskAllocator allocator;
	
	/** The classpath. */
	public final ClassPath classpath;
	
	/** Classes which have been read and initialized. */
	private final HashMap<String, TaskClass> _classes =
		new HashMap<>();
	
	/** Class info parser utility. */
	private ClassInfoUtility _ciutil;
	
	/**
	 * Initializes the client task.
	 *
	 * @param __pid The PID.
	 * @param __lid The LID.
	 * @param __cp The classpath used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/22
	 */
	public Task(int __pid, int __lid, ClassPath __cp)
		throws NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		this.pid = __pid;
		this.lid = __lid;
		this.classpath = __cp;
		
		// Initialize allocator for memory grabbing
		this.allocator = new TaskAllocator(__pid);
	}
	
	/**
	 * Since {@link cc.squirreljme.jvm.ClassInfo} is an important and often
	 * used part of loading classes within tasks, this is used to quickly
	 * cache and obtain a class information utility without requiring a search
	 * be done for it every time.
	 *
	 * @return The utility for {@code ClassInfo}.
	 * @since 2019/11/17
	 */
	public final ClassInfoUtility classInfoUtility()
	{
		ClassInfoUtility rv = this._ciutil;
		if (rv != null)
			return rv;
		
		// Create utility
		ClassPath classpath = this.classpath;
		this._ciutil = (rv = ClassInfoUtility.of(classpath.classParser(
			classpath.resourceClassFind("cc/squirreljme/jvm/ClassInfo"))));
		
		return rv;
	}
	
	/**
	 * Returns the current context thread of execution.
	 *
	 * @return The current context thread.
	 * @since 2019/12/14
	 */
	public final TaskThread contextThread()
	{
		todo.DEBUG.note("TODO -- Implement better contextThread(), lid=%d.",
			this.lid);
		
		// Could not determine the context thread, use fallback by calling
		// any thread and hoping it works
		return Globals.getThreadManager().anyThreadOwnedByTask(this.lid);
	}
	
	/**
	 * Creates a new thread
	 *
	 * @return The resulting thread.
	 * @since 2019/10/13
	 */
	public final TaskThread createThread()
	{
		return Globals.getThreadManager().createThread(this.lid);
	}
	
	/**
	 * Loads the given class.
	 *
	 * @param __cl The class to load.
	 * @return The pointer to the class information.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskNoSuchClassException If the task does not have the specified
	 * class.
	 * @throws TaskVirtualMachineError If there is something wrong with the
	 * task virtual machine.
	 * @since 2019/10/13
	 */
	public final TaskClass loadClass(String __cl)
		throws NullPointerException, TaskNoSuchClassException,
			TaskVirtualMachineError
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Needed to search for classes
		TaskClass rv;
		
		// Try to find already initialized class
		HashMap<String, TaskClass> classes = this._classes;
		synchronized (this)
		{
			// Already made?
			rv = classes.get(__cl);
			if (rv != null)
				return rv;
			
			// {@squirreljme.error SV0m The specified class does not exist
			// and it is not a special class. (The class which does not exist)}
			int cldx = this.classpath.resourceClassFind(__cl);
			if (cldx < 0 && !ClassNameUtils.isSpecial(__cl))
				throw new TaskNoSuchClassException("SV0m " + __cl);
			
			// Setup new one and store it
			classes.put(__cl, (rv = new TaskClass(cldx)));
			
			// Pre-initialize the class
			rv.initializeClassInfoSetup(this, __cl);
		}
		
		// Perform post initialization as needed
		return rv.initializeClassInfo(this, __cl);
	}
	
	/**
	 * Loads an object array with the given values and class type.
	 *
	 * @param __cl The class type.
	 * @param __vs The values to store.
	 * @return The resulting object array.
	 * @since 2019/10/13
	 */
	public final int loadObjectArray(TaskClass __cl, int... __vs)
	{
		return this.allocator.allocateArrayInt(__cl, __vs);
	}
	
	/**
	 * Loads a string in the target virtual machine instance.
	 *
	 * @param __s The string to load.
	 * @return The resulting string pointer.
	 * @since 2019/10/13
	 */
	public final int loadString(String __s)
	{
		if (__s == null)
			return 0;
		
		throw new todo.TODO();
	}
	
	/**
	 * Allocates and initializes a new instance of the given class target.
	 *
	 * @param __cl The class to allocate.
	 * @return The pointer to the instance of the given object.
	 * @throws NoSuchMethodTaskException If there is no default constructor.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/13
	 */
	public final int newInstance(TaskClass __cl)
		throws NoSuchMethodTaskException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Need this to load from the class info
		ClassInfoUtility ciutil = this.classInfoUtility();
		
		// {@squirreljme.error SV13 Class has no default constructor.}
		int defnew = ciutil.defaultNew(__cl);
		if (defnew == 0)
			throw new NoSuchMethodTaskException("SV13");
		
		// Allocate memory here
		int rv = this.allocator.allocateObject(__cl,
			ciutil.classAllocationSize(__cl));
		
		// Invoke the default constructor
		this.contextThread().execute(defnew, ciutil.poolPointer(__cl), rv);
		
		// Return the allocated pointer
		return rv;
	}
	
	/**
	 * Returns the physical ID of the task.
	 *
	 * @return The task physical ID.
	 * @since 2019/12/14
	 */
	public final int physicalProcessId()
	{
		return this.pid;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskAllocator.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Allocator;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;

/**
 * This is an allocator which uses a pre-set tag value for any allocations.
 *
 * @since 2019/09/23
 */
public final class TaskAllocator
{
	/** The size of the static field area. */
	public static final short STATIC_FIELD_SIZE =
		8192;
	
	/** The extra tag bits to use. */
	protected final int tagbits;
	
	/** The static field pointer. */
	private int _staticfieldptr;
	
	/**
	 * Initializes the tagged allocator.
	 *
	 * @param __pid The PID to allocate for.
	 * @since 2019/09/23
	 */
	public TaskAllocator(int __pid)
	{
		// The tag bits are just the PID shifted up a bit
		this.tagbits = __pid << 4;
	}
	
	/**
	 * Allocates memory for this tag.
	 *
	 * @param __tag The tag used.
	 * @param __sz The number of bytes to allocate.
	 * @return The allocated bytes.
	 * @since 2019/06/23
	 */
	public final int allocate(int __tag, int __sz)
	{
		// Just perform the allocation with our PID as part of the tag and
		// whatever was passed, masked correctly
		int rv = Allocator.allocate(
			this.tagbits | (__tag & Allocator.CHUNK_BITS_VALUE_MASK), __sz);
		
		// Ran out of memory?
		if (rv == 0)
			throw new TaskOutOfMemoryError();
		
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values, no class type
	 * is set.
	 *
	 * @param __v The values to store.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayInt(int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Initialize base array
		int count = __v.length;
		int rv = this.allocateArrayIntEmpty(count);
		
		// Copy pointer values to the array
		int bp = rv + Constants.ARRAY_BASE_SIZE;
		for (int i = 0, wp = 0; i < count; i++, wp += 4)
			Assembly.memWriteInt(bp, wp, __v[i]);
		
		// Return the result of it
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values.
	 *
	 * @param __cl The class to set it as.
	 * @param __v The values to store.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayInt(TaskClass __cl, int... __v)
		throws NullPointerException
	{
		if (__cl == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Allocate using the base form
		int rv = this.allocateArrayInt(__v);
		
		// Store object type
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl.infoPointer());
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values, no class type
	 * is set here.
	 *
	 * @param __n The number of elements in the array.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayIntEmpty(int __n)
		throws NullPointerException
	{
		// Allocate array pointer
		int rv = this.allocateObject(Constants.ARRAY_BASE_SIZE + (__n * 4));
		
		// Write array size
		Assembly.memWriteInt(rv, Constants.ARRAY_LENGTH_OFFSET, __n);
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an integer sized array with the given values.
	 *
	 * @param __cl The class to set it as.
	 * @param __n The number of elements in the array.
	 * @return The pointer to the allocated array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/01
	 */
	public final int allocateArrayIntEmpty(TaskClass __cl, int __n)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Allocate array pointer
		int rv = this.allocateObject(__cl,
			Constants.ARRAY_BASE_SIZE + (__n * 4));
		
		// Write array size
		Assembly.memWriteInt(rv, Constants.ARRAY_LENGTH_OFFSET, __n);
		
		// Use this
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @throws IllegalArgumentException If the allocation size is smaller
	 * than the object base size.
	 * @since 2019/10/26
	 */
	public final int allocateObject(int __sz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error SV0x Object allocation is less than the object
		// base size.}
		if (__sz < Constants.OBJECT_BASE_SIZE)
			throw new IllegalArgumentException("SV0x");
		
		// Allocate
		int rv = this.allocate(Allocator.CHUNK_BIT_IS_OBJECT, __sz);
		
		// Set initial count to one, to match new
		Assembly.memWriteInt(rv, Constants.OBJECT_COUNT_OFFSET,
			1);
		
		return rv;
	}
	
	/**
	 * Allocates an object type.
	 *
	 * @param __cl The class type.
	 * @param __sz The size of the object.
	 * @return The allocated bytes.
	 * @since 2019/12/01
	 */
	public final int allocateObject(TaskClass __cl, int __sz)
	{
		int rv = this.allocateObject(__sz);
		
		// Store class type here
		Assembly.memWriteInt(rv, Constants.OBJECT_CLASS_OFFSET,
			__cl.infoPointer());
		
		return rv;
	}
	
	/**
	 * Allocates a region that can fit a constant pool with the given number
	 * of entries.
	 *
	 * @param __n The number of entries to use.
	 * @return The pointer to the allocation.
	 * @since 2019/11/25
	 */
	public final int allocatePool(int __n)
	{
		return this.allocate(Allocator.CHUNK_BIT_IS_POOL, 4 * __n);
	}
	
	/**
	 * Frees the given pointer, this is just a helper method.
	 *
	 * @param __p The pointer to free.
	 * @since 2019/10/19
	 */
	public final void free(int __p)
	{
		Allocator.free(__p);
	}
	
	/**
	 * Returns the static field pointer.
	 *
	 * @return The static field pointer.
	 * @since 2019/10/13
	 */
	public final int getStaticFieldPointer()
	{
		// If this has already been initialized then use it!
		int rv = this._staticfieldptr;
		if (rv != 0)
			return rv;
		
		// We need to allocate this data region
		synchronized (this)
		{
			// Double-get in case we ran into this twice!
			rv = this._staticfieldptr;
			if (rv != 0)
				return rv;
			
			// Allocate and store this space
			this._staticfieldptr = (rv = this.allocate(0, STATIC_FIELD_SIZE));
			
			// Could not allocate for this task!
			if (rv == 0)
				throw new TaskOutOfMemoryError();
			
			// And use it
			return rv;
		}
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskClass.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605





























































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ClassLoadingAdjustments;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.io.BinaryBlob;
import cc.squirreljme.jvm.io.MemoryBlob;
import cc.squirreljme.jvm.lib.ClassDualPoolParser;
import cc.squirreljme.jvm.lib.ClassFieldsParser;
import cc.squirreljme.jvm.lib.ClassFileParser;
import cc.squirreljme.jvm.lib.ClassInfoProperty;
import cc.squirreljme.jvm.lib.ClassInfoUtility;
import cc.squirreljme.jvm.lib.ClassMethodsParser;
import cc.squirreljme.jvm.lib.ClassNameUtils;
import cc.squirreljme.jvm.lib.ClassPath;
import cc.squirreljme.jvm.lib.ClassPoolConstants;
import cc.squirreljme.jvm.lib.PoolClassName;
import java.util.Objects;

/**
 * This represents a class of a task.
 *
 * @since 2019/10/19
 */
public final class TaskClass
{
	/** The index of the class in the resource table. */
	protected final int resourceindex;
	
	/** The allocated class information. */
	private int _infopointer;
	
	/**
	 * Initializes the class container.
	 *
	 * @param __cldx The class path resource index.
	 * @since 2019/10/19
	 */
	public TaskClass(int __cldx)
	{
		this.resourceindex = __cldx;
	}
	
	/**
	 * Returns the info pointer.
	 *
	 * @return The info pointer.
	 * @throws TaskVirtualMachineError If the info pointer was not set.
	 * @since 2019/10/27
	 */
	public final int infoPointer()
		throws TaskVirtualMachineError
	{
		int rv = this._infopointer;
		
		// {@squirreljme.error SV0n Class information pointer not set.}
		if (rv == 0)
			throw new TaskVirtualMachineError("SV0n");
		
		return rv;
	}
	
	/**
	 * Performs the main initialization of this class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @param __cip The parser for {@code ClassInfo}.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final TaskClass initializeClassInfo(Task __task, String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Right now nothing needs to actually be done here
		return this;
	}
	
	/**
	 * Performs enough setup of the class info to rever to it when the
	 * class table is not locked.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final TaskClass initializeClassInfoSetup(Task __task, String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Debug
		todo.DEBUG.note("Loading class `%s`...", __cl);
		
		// We need the parser for class info so that we can initialize the
		// classes, however every variant of the loader can use this.
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// All branches require the info
		int infopointer = __task.allocator.allocateObject(
			ciutil.classInfoAllocationSize());
		this._infopointer = infopointer;
		
		// This object has the class type of ClassInfo so it must always point
		// to the ClassInfo instance of ClassInfo, however if we are loading
		// ClassInfo then we just use our own pointer
		Assembly.memWriteInt(infopointer, Constants.OBJECT_CLASS_OFFSET,
			(ClassNameUtils.isClassInfo(__cl) ? infopointer :
			__task.loadClass("cc/squirreljme/jvm/ClassInfo")._infopointer));
		
		// These objects should never be garbage collected because they
		// contain important class information!
		Assembly.memWriteInt(infopointer, Constants.OBJECT_COUNT_OFFSET,
			9999999);
		
		// If these are special classes, we need to handle them unique because
		// arrays and primitive types do not exist in any form as a class
		if (ClassNameUtils.isArray(__cl))
			return this.__initializeClassInfoArray(__task, __cl);
		else if (ClassNameUtils.isPrimitiveType(__cl))
			return this.__initializeClassInfoPrimitive(__task, __cl);
		
		// Otherwise initialize a standard class
		return this.__initializeClassInfoClass(__task, __cl);
	}

	/**
	 * Builds the constant pool for the given class.
	 *
	 * @param __task The owning task.
	 * @param __ciu The class info utility.
	 * @param __cfp The class file parser for this class.
	 * @param __poolp The pool pointer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	private final void __buildPool(Task __task, ClassInfoUtility __ciu,
		ClassFileParser __cfp, int __poolp)
		throws NullPointerException
	{
		if (__task == null || __ciu == null || __cfp == null)
			throw new NullPointerException("NARG");
		
		// The name of this class
		String self = __cfp.thisName().toString();
		
		// Initialize individual entries
		ClassDualPoolParser pool = __cfp.pool();
		for (int i = 1, n = pool.count(true); i < n; i++)
		{
			// The value to write into the slot
			int slotv;
			
			// Depends on the type
			int type = pool.entryType(true, i);
			switch (type)
			{
					// A class information pointer
				case ClassPoolConstants.TYPE_CLASS_INFO_POINTER:
					String cip = pool.entryAsClassInfoPointer(true, i).
						toString();
					
					// The given class may be deferred loaded in which case
					// we do not really care about it right now
					slotv = (ClassLoadingAdjustments.isDeferredLoad(self, cip)
						? 0 : __task.loadClass(cip)._infopointer);
					break;
					
					// A class pool pointer
				case ClassPoolConstants.TYPE_CLASS_POOL_POINTER:
					String pip = pool.entryAsClassPoolPointer(true, i).
						toString();
					
					// The pool may be deferred
					slotv = (ClassLoadingAdjustments.isDeferredLoad(self, pip)
						? 0 : __task.classInfoUtility().
							poolPointer(__task.loadClass(pip)));
					break;
					
					// A string which as been noted, not interned
				case ClassPoolConstants.TYPE_NOTED_STRING:
					slotv = ((MemoryBlob)pool.entryAsNotedString(true, i).
						blob()).baseAddress() + 4;
					break;
					
					// Cached string, these are loaded at run-time so there
					// value here is always null!
				case ClassPoolConstants.TYPE_USED_STRING:
					slotv = 0;
					break;
				
				default:
					todo.DEBUG.note("TODO -- Load of pool type %d?", type);
					continue;
			}
			
			// Store slot value
			Assembly.memWriteInt(__poolp, i * Constants.POOL_CELL_SIZE, slotv);
		}
	}
	
	/**
	 * Builds the VTable for this class.
	 *
	 * @param __task The owning task.
	 * @param __ciu The class info utility.
	 * @param __cfp The class file parser for this class.
	 * @param __vtvirtual The virtual method pointer table.
	 * @param __vtpool The pool used for that method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/28
	 */
	private final void __buildVTable(Task __task, ClassInfoUtility __ciu,
		ClassFileParser __cfp, int __vtvirtual, int __vtpool)
		throws NullPointerException
	{
		if (__task == null || __ciu == null || __cfp == null)
			throw new NullPointerException("NARG");
		
		todo.DEBUG.note("TODO -- Build VTables.");
		//throw new todo.TODO();
	}
	
	/**
	 * Initializes an array class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	private final TaskClass __initializeClassInfoArray(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We just need the utility to access the class info
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// Always points to self
		ciutil.setSelfPointer(this, this._infopointer);
		
		// The size is always the base array size
		ciutil.setClassAllocationSize(this, Constants.ARRAY_BASE_SIZE);
		
		// The base of this class is always after object
		ciutil.setBaseSize(this, Constants.OBJECT_BASE_SIZE);
		
		// The number of dimensions this class has
		ciutil.setDimensions(this, ClassNameUtils.dimensions(__cl));
		
		// Set name of our class
		ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// The class depth is always one because this extends object
		ciutil.setClassDepth(this, 1);
		
		// The super-class is always object, so load that and set
		TaskClass object = __task.loadClass("java/lang/Object");
		ciutil.setSuperClass(this, object);
		
		// The VTables, pools, and method counts always use Object's
		ciutil.setVTableVirtual(this, ciutil.vTableVirtual(object));
		ciutil.setVTablePool(this, ciutil.vTablePool(object));
		ciutil.setPoolPointer(this, ciutil.poolPointer(object));
		ciutil.setMethodCount(this, ciutil.methodCount(object));
		
		// We need to handle the component type
		TaskClass comptype = __task.loadClass(
			ClassNameUtils.componentType(__cl));
		
		// Is this component type a primitive?
		boolean compisprim =
			(ciutil.flags(comptype) & Constants.CIF_IS_PRIMITIVE) != 0;
		
		// Set our own flags, note that if our component type is not primitive
		// it is a bunch of objects which is needed for garbage collection
		// of object arrays
		ciutil.setFlags(this, Constants.CIF_IS_ARRAY |
			(compisprim ? 0 : Constants.CIF_IS_ARRAY_OF_OBJECTS));
		
		// The component class is set here
		ciutil.setComponentType(this, comptype);
		
		// The JAR this came from is always the component's JAR
		ciutil.setJarIndex(this, ciutil.jarIndex(comptype));
		
		// The cell size is always 4 unless this is a primitive
		ciutil.setCellSize(this, (compisprim ?
			ciutil.classAllocationSize(comptype) : 4));
		
		// Done
		return this;
	}
	
	/**
	 * Initializes a standard type class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/17
	 */
	private final TaskClass __initializeClassInfoClass(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We need the parser for class info so that we can initialize the
		// classes
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// First we load the base class because it will contain information
		// about the class that we need
		ClassFileParser thisparser = __task.classpath.classParser(
			this.resourceindex);
		
		// Pointer to self
		int infopointer = this._infopointer;
		ciutil.setSelfPointer(this, infopointer);
		
		// Set the JAR index
		ciutil.setJarIndex(this, ClassPath.resourceIndexToJarIndex(
			this.resourceindex));
		
		// Set pointer to the mini-class which may or may not be valid at all
		ciutil.setMiniClassPointer(this, thisparser.baseAddress());
		
		// Set magic number
		ciutil.setMagicNumber(this);
		
		// Set flags, note that these are not class flags but VM flags
		ciutil.setFlags(this, 0);
		
		// Set self name
		BinaryBlob name = thisparser.thisNameAsBinaryBlob();
		if (name instanceof MemoryBlob)
			ciutil.setNamePointer(this, ((MemoryBlob)name).baseAddress() + 4);
		
		// Need to store the name elsewhere, since we do not have a direct
		// pointer to the name
		else
			ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// The run-time pool is initialized later, but we need to allocate it
		// now!
		int poolpointer = __task.allocator.allocatePool(
			thisparser.splitPool(true).count());
		ciutil.setPoolPointer(this, poolpointer);
		
		// Allocate static field space
		todo.DEBUG.note("TODO -- Allocate static field space.");
		
		// Set default constructor
		BinaryBlob defnew = thisparser.methodCodeBytes("<init>", "()V");
		if (defnew != null)
			ciutil.setDefaultNew(this, ((MemoryBlob)defnew).baseAddress());
		
		// Load super class if there is one
		String superclassname = Objects.toString(thisparser.superClassName(),
			null);
		TaskClass superclass = (superclassname == null ? null :
			__task.loadClass(superclassname));
		if (superclass != null)
			ciutil.setSuperClass(this, superclass);
		
		// Set the class depth
		int classdepth = (superclass == null ? 0 :
			ciutil.classDepth(superclass) + 1);
		ciutil.setClassDepth(this, classdepth);
		
		// The base for this class
		int basesize = (superclass == null ? 0 :
			ciutil.classAllocationSize(superclass));
		ciutil.setBaseSize(this, basesize);
		
		// Number of methods the class has
		int methodcount = (superclass != null ? ciutil.
			methodCount(superclass) : 0) + thisparser.methodCount(false);
		ciutil.setMethodCount(this, methodcount);
		
		// Pre-allocate the class VTables since we may need to refer to them!
		int vtvirtual = __task.allocator.allocateArrayIntEmpty(methodcount),
			vtpool = __task.allocator.allocateArrayIntEmpty(methodcount);
		ciutil.setVTableVirtual(this, vtvirtual);
		ciutil.setVTablePool(this, vtpool);
		
		// Allocation size of this class
		ciutil.setClassAllocationSize(this,
			basesize + thisparser.fieldSize(false));
		
		// Set number of objects this has, for garbage collection
		ciutil.setObjectCount(this, thisparser.objectCount(false));
		
		// Initialize interfaces
		PoolClassName[] interfacenames = thisparser.interfaceNames();
		int numints = interfacenames.length;
		int[] ifps = new int[numints];
		for (int i = 0; i < numints; i++)
			ifps[i] = __task.loadClass(interfacenames[i].toString()).
				infoPointer();
		
		// Allocate and store
		int ifacespointer = __task.allocator.allocateArrayInt(ifps);
		ciutil.setInterfaces(this, ifacespointer);
		
		// Initialize the VTables for the class now, it is a bit complicated
		// so it is in another method
		this.__buildVTable(__task, ciutil, thisparser, vtvirtual, vtpool);
		
		// Initialize the actual pool constants now
		this.__buildPool(__task, ciutil, thisparser, poolpointer);
		
		// Load static field constant values
		todo.DEBUG.note("TODO -- Load static field constant values.");
		
		// Set interfaces array type
		Assembly.memWriteInt(ifacespointer, Constants.OBJECT_CLASS_OFFSET,
			__task.loadClass("[Lcc/squirreljme/jvm/ClassInfo;").infoPointer());
		
		// Set the class type for the vtable array last, since everything
		// is now setup with it!
		TaskClass intarrayclass = __task.loadClass("[I");
		Assembly.memWriteInt(vtvirtual, Constants.OBJECT_CLASS_OFFSET,
			intarrayclass.infoPointer());
		Assembly.memWriteInt(vtpool, Constants.OBJECT_CLASS_OFFSET,
			intarrayclass.infoPointer());
		
		// Call static initializer for class, if one exists
		BinaryBlob clinit = thisparser.methodCodeBytes("<clinit>", "()V");
		if (clinit != null)
			__task.contextThread().execute(((MemoryBlob)clinit).baseAddress(),
				poolpointer);
		
		// All done! This class should hopefully work!
		return this;
	}
	
	/**
	 * Initializes a primitive type class.
	 *
	 * @param __task The creating task.
	 * @param __cl The class name being initialized.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/09
	 */
	private final TaskClass __initializeClassInfoPrimitive(Task __task,
		String __cl)
		throws NullPointerException
	{
		if (__task == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// We just need the utility to access the class info
		ClassInfoUtility ciutil = __task.classInfoUtility();
		
		// Always points to self
		ciutil.setSelfPointer(this, this._infopointer);
		
		// Determine the size of this type
		int size;
		switch (__cl)
		{
			case "boolean":
			case "byte":
				size = 1;
				break;
			
			case "short":
			case "char":
				size = 2;
				break;
			
			case "int":
			case "float":
				size = 4;
				break;
			
			case "long":
			case "double":
				size = 8;
				break;
			
				// {@squirreljme.error SV0z Invalid primitive type.}
			default:
				throw new RuntimeException("SV0z");
		}
		
		// Set as primitive
		ciutil.setFlags(this, Constants.CIF_IS_PRIMITIVE);
		
		// Set size of type
		ciutil.setClassAllocationSize(this, size);
		ciutil.setCellSize(this, size);
		
		// Set name of our class
		ciutil.setNamePointer(this, this.__makeString(__task, __cl));
		
		// Comes from no JAR so is invalid
		ciutil.setJarIndex(this, -1);
		
		// The VTables, pools, and method counts always use Object's, even
		// if it is not the super-class of object
		TaskClass object = __task.loadClass("java/lang/Object");
		ciutil.setVTableVirtual(this, ciutil.vTableVirtual(object));
		ciutil.setVTablePool(this, ciutil.vTablePool(object));
		ciutil.setPoolPointer(this, ciutil.poolPointer(object));
		ciutil.setMethodCount(this, ciutil.methodCount(object));
		
		// Done
		return this;
	}
	
	/**
	 * Makes a UTF-8 string of the given string.
	 *
	 * @param __task The task.
	 * @param __s The string to encode.
	 * @return The raw string pointer.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	private final int __makeString(Task __task, String __s)
		throws NullPointerException
	{
		if (__task == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Count the number of bytes this will take up
		int bytes = 2;
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			if (c >= 0x0001 && c <= 0x007F)
				bytes += 1;
			else if (c == 0x0000 || (c >= 0x0080 && c <= 0x07FF))
				bytes += 2;
			else
				bytes += 3;
		}
		
		// Allocate and set the length of the string
		int rv = __task.allocator.allocate(0, bytes);
		Assembly.memWriteJavaShort(rv, 0, bytes);
		
		// Write character data within
		int base = rv + 2;
		for (int i = 0, o = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Single byte
			if (c >= 0x0001 && c <= 0x007F)
				Assembly.memWriteByte(base, o++, c);
			
			// Two byte
			else if (c == 0x0000 || (c >= 0x0080 && c <= 0x07FF))
			{
				Assembly.memWriteByte(base, o++, 0b110_00000 |
					((c >>> 6) & 0b11111));
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					(c & 0b111111));
			}
			
			// Three byte
			else
			{
				Assembly.memWriteByte(base, o++, 0b1110_0000 |
					(c >>> 12) & 0b1111);
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					((c >>> 6) & 0b111111));
				Assembly.memWriteByte(base, o++, 0b10_000000 |
					(c & 0b111111));
			}
		}
		
		// All done!
		return rv;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskCreateResult.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.task;

/**
 * This is the result of a created task
 *
 * @since 2019/12/08
 */
public final class TaskCreateResult
{
	/** The resulting task. */
	public final Task task;
	
	/** The initial thread. */
	public final TaskThread thread;
	
	/** The main entry class. */
	public final String mainclass;
	
	/** The main entry method name. */
	public final String mainmethodname;
	
	/** The main entry method type. */
	public final String mainmethodtype;
	
	/** The arguments to call. */
	public final int[] callargs;
	
	/**
	 * Initializes the task creation result.
	 *
	 * @param __task The created task.
	 * @param __thread The created task.
	 * @param __mcl The main class.
	 * @param __mname The method name.
	 * @param __mtype The method type.
	 * @param __callargs The arguments to the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/08
	 */
	public TaskCreateResult(Task __task, TaskThread __thread, String __mcl,
		String __mname, String __mtype, int[] __callargs)
		throws NullPointerException
	{
		if (__task == null || __thread == null || __mcl == null ||
			__mname == null || __mtype == null || __callargs == null)
			throw new NullPointerException("NARG");
		
		this.task = __task;
		this.thread = __thread;
		this.mainclass = __mcl;
		this.mainmethodname = __mname;
		this.mainmethodtype = __mtype;
		this.callargs = __callargs;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is the base for any exception thrown when processing tasks.
 *
 * @since 2019/10/21
 */
public class TaskException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public TaskException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskManager.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.lib.ClassLibrary;
import cc.squirreljme.jvm.lib.ClassPath;

/**
 * This manages multiple tasks.
 *
 * @since 2019/06/22
 */
public final class TaskManager
{
	/** The maximum number of permitted tasks. */
	public static final byte MAX_TASKS =
		15;
	
	/** The shift for tasks. */
	private static final byte _TASK_SHIFT =
		4;
	
	/** The low mask for tasks. */
	private static final byte _TASK_MASK =
		0xF;
	
	/** The tasks which are available. */
	public final Task[] tasks =
		new Task[MAX_TASKS];
	
	/** The next logical task ID. */
	private volatile int _nextlid =
		1;
	
	/**
	 * Initializes the client task manager.
	 *
	 * @since 2019/06/22
	 */
	public TaskManager()
	{
		// Setup a system task, it has no classpath and is always zero
		this.tasks[0] = new Task(0, 0, new ClassPath());
	}
	
	/**
	 * Returns the task by the given logical ID.
	 *
	 * @param __lid The logical ID of the task.
	 * @return The given task.
	 * @throws NoSuchTaskException If the given task does not exist.
	 * @since 2019/12/14
	 */
	public final Task getTask(int __lid)
		throws NoSuchTaskException
	{
		synchronized (this)
		{
			// The lower bits are used to quickly obtain the PID slot
			Task rv = this.tasks[__lid & _TASK_MASK];
			if (rv != null && rv.lid == __lid)
				return rv;
		}
		
		// {@squirreljme.error SV10 No such task exists. (The task)}
		throw new NoSuchTaskException("SV10 " + __lid);
	}
	
	/**
	 * Creates a new task.
	 *
	 * @param __cp The class path to use.
	 * @param __im Is the initial class a MIDlet?
	 * @param __mcl The main class.
	 * @param __args The arguments to the task.
	 * @param __sp System properties.
	 * @return The resulting task.
	 * @throws NullPointerException On null arguments.
	 * @throws TooManyTasksException If the task could not be created.
	 * @since 2019/06/22
	 */
	public TaskCreateResult newTask(ClassLibrary[] __cp, String __mcl,
		boolean __im, String[] __args, String[] __sp)
		throws NullPointerException, TooManyTasksException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		// Tasks that are currently active
		Task[] tasks = this.tasks;
		
		// The resulting new task and its PID
		Task rv;
		int pid;
		
		// One a single process may make tasks at a time, so we need to lock
		// here to prevent the entire system from collapsing
		synchronized (this)
		{
			// Find a free task spot
			for (pid = 1; pid < MAX_TASKS; pid++)
				if (tasks[pid] == null)
					break;
			
			// {@squirreljme.error SV01 Task limit reached.}
			if (pid >= MAX_TASKS)
				throw new TooManyTasksException("SV01");
			
			// Setup and store task now
			rv = new Task(pid, ((this._nextlid++) << _TASK_SHIFT) | pid,
				new ClassPath(__cp));
			tasks[pid] = rv;
		}
		
		// Create main thread to initialize
		TaskThread thread = rv.createThread();
		
		// Set static field pointer of this thread, this is so that static
		// field areas can be executed properly
		thread.setStaticFieldPointer(rv.allocator.getStaticFieldPointer());
		
		// The method and arguments to use for the entry call
		String mname, mtype;
		int[] callargs;
		
		// Loading a MIDlet, so initialize MIDlet class
		if (__im)
		{
			// Load instance of main MIDlet class
			TaskClass mainclass = rv.loadClass(__mcl);
			
			// Create instance of the MIDlet class
			int midinstance = rv.newInstance(mainclass);
			
			// Setup call information
			mname = "startApp";
			mtype = "()V";
			callargs = new int[]{midinstance};
		}
		
		// Start from static main() entry point
		else
		{
			// Load arguments for main class into array
			int numargs = (__args == null ? 0 : __args.length);
			int[] mainargs = new int[numargs];
			for (int i = 0; i < numargs; i++)
				mainargs[i] = rv.loadString(__args[i]);
			
			// Load main arguments into string array
			int argsarray = rv.loadObjectArray(
				rv.loadClass("[Ljava/lang/String;"), mainargs);
			
			// Setup call information
			mname = "main";
			mtype = "([Ljava/lang/String;)V";
			callargs = new int[]{argsarray};
		}
		
		// Create result
		return new TaskCreateResult(rv, thread, __mcl, mname, mtype, callargs);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskNoSuchClassException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when a class does not exist for a task.
 *
 * @since 2019/10/27
 */
public class TaskNoSuchClassException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskNoSuchClassException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/27
	 */
	public TaskNoSuchClassException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskOutOfMemoryError.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when a task has ran out of memory.
 *
 * @since 2019/11/25
 */
public class TaskOutOfMemoryError
	extends TaskVirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/11/25
	 */
	public TaskOutOfMemoryError(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskSysCallHandler.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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigReader;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.SupervisorPropertyIndex;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is the handler for system calls within tasks.
 *
 * @since 2019/10/06
 */
public final class TaskSysCallHandler
{
	/**
	 * Not used.
	 *
	 * @since 2019/10/06
	 */
	private TaskSysCallHandler()
	{
	}
	
	/**
	 * Initializes and sets the task handler for system calls.
	 *
	 * @param __cr The configuration to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/06
	 */
	public static final void initTaskHandler(ConfigReader __cr)
		throws NullPointerException
	{
		if (__cr == null)
			throw new NullPointerException("NARG");
			
		// Message
		todo.DEBUG.note("Setting task system call handler...");
		
		// Set handlers
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_STATIC_FIELD_POINTER,
			__cr.loadInteger(ConfigRomType.SYSCALL_STATIC_FIELD_POINTER));
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_METHOD_HANDLER,
			__cr.loadInteger(ConfigRomType.SYSCALL_CODE_POINTER));
		Assembly.sysCallP(SystemCallIndex.SUPERVISOR_PROPERTY_SET,
			SupervisorPropertyIndex.TASK_SYSCALL_METHOD_POOL_POINTER,
			__cr.loadInteger(ConfigRomType.SYSCALL_POOL_POINTER));
		
		// Message
		todo.DEBUG.note("Okay.");
	}
	
	/**
	 * Handler for task system calls.
	 *
	 * @param __tid The task ID.
	 * @param __oldsfp The old static field pointer.
	 * @param __si The system call that was made.
	 * @param __a Argument.
	 * @param __b Argument.
	 * @param __c Argument.
	 * @param __d Argument.
	 * @param __e Argument.
	 * @param __f Argument.
	 * @param __g Argument.
	 * @param __h Argument.
	 * @return The result.
	 * @since 2019/10/05
	 */
	public static final long taskSysCall(int __tid, int __oldsfp, short __si,
		int __a, int __b, int __c, int __d, int __e, int __f, int __g, int __h)
	{
		todo.DEBUG.code('H', 't', __tid);
		todo.DEBUG.code('H', 's', __oldsfp);
		todo.DEBUG.code('H', 'd', __si);
		
		return Assembly.sysCallPVL(__si, __a, __b, __c, __d, __e, __f, __g,
			__h);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267











































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Globals;
import cc.squirreljme.jvm.io.BinaryBlob;
import cc.squirreljme.jvm.io.MemoryBlob;
import cc.squirreljme.jvm.lib.ClassFileParser;
import cc.squirreljme.jvm.lib.ClassInfoUtility;
import cc.squirreljme.jvm.lib.ClassNameUtils;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This represents a single thread, which is associated with a task.
 *
 * Every thread has a controller thread, this is the thread which is
 * actually executing the given thread even if the IDs are different. This
 * allows other threads to execute within the contexts of other threads
 * accordingly.
 *
 * @since 2019/10/13
 */
public final class TaskThread
{
	/** Maximum number of arguments to methods. */
	public static final byte MAX_CALL_ARGUMENTS =
		8;
	
	/** The owning process ID. */
	protected final int pid;
	
	/** The thread ID. */
	protected final int tid;
	
	/** The logical ID of this thread. */
	protected final int lid;
	
	/** The static field pointer for this thread. */
	private int _staticfieldptr;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __pid The owning process ID.
	 * @param __tid The task ID.
	 * @param __lid The logical thread ID.
	 * @since 2019/10/19
	 */
	public TaskThread(int __pid, int __tid, int __lid)
	{
		this.pid = __pid;
		this.tid = __tid;
		this.lid = __lid;
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * This searches for the method and loads any classes as needed.
	 *
	 * @param __cl The class to execute.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call.
	 * @throws IllegalArgumentException If the argument count is too high or
	 * the requested class is an array or primitive type.
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/10/13
	 */
	public final long execute(String __cl, String __mn, String __mt,
		int... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException, TaskThrownException
	{
		if (__cl == null || __mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV12 Cannot execute into a special class type
		// such as an array or primitive type.}
		if (ClassNameUtils.isSpecial(__cl))
			throw new IllegalArgumentException("SV12");
		
		// Get the owning task
		Task task = Globals.getTaskManager().getTask(this.pid);
		
		// Load our class
		TaskClass eclass = task.loadClass(__cl);
		
		// Execute the resultant method (use the pool of the target class)
		return this.execute(((MemoryBlob)task.classpath.classParser(eclass.
				resourceindex).methodCodeBytes(__mn, __mt)).baseAddress(),
			task.classInfoUtility().poolPointer(eclass), __args);
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * @param __methpool The combined method pointer to invoke and the
	 * constant pool pointer to load, the method pointer is in the low word
	 * while the pool is in the high word.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/12/08
	 */
	public final long execute(long __methpool, int... __args)
		throws IllegalStateException, NullPointerException, TaskThrownException
	{
		return this.execute(Assembly.longUnpackLow(__methpool),
			Assembly.longUnpackHigh(__methpool), __args);
	}
	
	/**
	 * Enters the given frame on the thread. Note that this can only be
	 * done from the current thread where it will be executed.
	 *
	 * @param __meth The method pointer to invoke.
	 * @param __pool The constant pool pointer to load.
	 * @param __args The arguments to the thread.
	 * @return The return values of the method call
	 * @throws IllegalArgumentException If too many method arguments were
	 * passed.
	 * @throws IllegalStateException If the current thread is being executed
	 * and the current controller thread is not the current thread of
	 * execution.
	 * @throws NullPointerException On null arguments.
	 * @throws TaskThrownException If the task threw an exception.
	 * @since 2019/12/08
	 */
	public final long execute(int __meth, int __pool, int... __args)
		throws IllegalArgumentException, IllegalStateException,
			NullPointerException, TaskThrownException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV11 Cannot execute method with the given
		// number of arguments.}
		if (__args.length > MAX_CALL_ARGUMENTS)
			throw new IllegalArgumentException("SV11");
		
		// Get the owning task
		Task task = Globals.getTaskManager().getTask(this.pid);
		
		// Set the task and enter user mode now
		Assembly.sysCallP(SystemCallIndex.FRAME_TASK_ID_SET, task.lid);
		
		// Set new static field register
		int oldsfp = Assembly.specialGetStaticFieldRegister();
		Assembly.specialSetStaticFieldRegister(this._staticfieldptr);
		
		// The number of pass arguments varies!
		int exception = 0;
		long rv = 0;
		try
		{
			switch (__args.length)
			{
				case 0:
				default:
					rv = Assembly.invokeVL(__meth, __pool);
					break;
				
				case 1:
					rv = Assembly.invokeVL(__meth, __pool, __args[0]);
					break;
				
				case 2:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1]);
					break;
				
				case 3:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2]);
					break;
				
				case 4:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3]);
					break;
				
				case 5:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4]);
					break;
				
				case 6:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5]);
					break;
				
				case 7:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5],
						__args[6]);
					break;
				
				case 8:
					rv = Assembly.invokeVL(__meth, __pool, __args[0],
						__args[1], __args[2], __args[3], __args[4], __args[5],
						__args[6], __args[7]);
					break;
			}
		}
		
		// Wrap the exception value
		catch (Throwable t)
		{
			exception = Assembly.objectToPointer(t);
		}
		
		// Restore some of our state
		finally
		{
			// The static field register space
			Assembly.specialSetStaticFieldRegister(oldsfp);
		}
		
		// Return the result or throw exception
		if (exception != 0)
			throw new TaskThrownException(exception);
		return rv;
	}
	
	/**
	 * Returns the process ID of this task.
	 *
	 * @return The process ID.
	 * @since 2019/12/14
	 */
	public final int processId()
	{
		return this.pid;
	}
	
	/**
	 * Sets the static field pointer for this thread.
	 *
	 * @param __d The static field pointer.
	 * @since 2019/10/13
	 */
	public final void setStaticFieldPointer(int __d)
	{
		this._staticfieldptr = __d;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskThrownException.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This exception is thrown when a task throws an exception, it just points
 * to the exception register pointer itself.
 *
 * @since 2019/10/13
 */
public class TaskThrownException
	extends TaskException
{
	/** The thrown exception value. */
	protected final int pointer;
	
	/**
	 * Initializes the exception with the given pointer.
	 *
	 * @param __p The pointer value to set.
	 * @since 2019/10/13
	 */
	public TaskThrownException(int __p)
	{
		this.pointer = __p;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TaskVirtualMachineError.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when there is something wrong with the task's virtual
 * machine.
 *
 * @since 2019/10/21
 */
public class TaskVirtualMachineError
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public TaskVirtualMachineError(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/ThreadManager.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
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



































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This class manages threads within the system.
 *
 * @since 2019/10/13
 */
public final class ThreadManager
{
	/** Default number of threads. */
	private static final int _DEFAULT_THREAD_COUNT =
		16;
	
	/** The number of slots to grow by when out of threads. */
	private static final int _GROW_SIZE =
		8;
	
	/** This is the bootstrap main thread. */
	public final TaskThread BOOT_THREAD =
		new TaskThread(0, 0, 0);
	
	/** Threads that currently exist. */
	private TaskThread[] _threads =
		new TaskThread[_DEFAULT_THREAD_COUNT];
	
	/** The next logical thread id. */
	private int _nextlid;
	
	/**
	 * Always fills in the boot thread.
	 *
	 * @since 2019/10/19
	 */
	{
		this._threads[0] = BOOT_THREAD;
	}
	
	/**
	 * Returns any thread that is owned by the given task.
	 *
	 * @param __pid The process ID.
	 * @return The thread owned by the given task or {@code null}.
	 * @since 2019/12/14
	 */
	public final TaskThread anyThreadOwnedByTask(int __pid)
	{
		// Lock self to inspect threads
		TaskThread[] threads = this._threads;
		synchronized (this)
		{
			// The array may be dynamically resized
			int n = threads.length;
			
			// Search for a thread
			for (int i = 0; i < n; i++)
			{
				TaskThread thread = threads[i];
				
				if (thread == null || thread.processId() != __pid)
					continue;
				
				return thread;
			}
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Creates the specified thread owned by the given task.
	 *
	 * @param __pid The owning PID.
	 * @return The thread which was created.
	 * @since 2019/10/13
	 */
	public final TaskThread createThread(int __pid)
	{
		TaskThread rv;
		
		// Need to lock on our own manager, since only a single thread an
		// request a new thread
		TaskThread[] threads = this._threads;
		synchronized (this)
		{
			// The array may be dynamically resized
			int n = threads.length;
			
			// Find free spot in physical thread list
			int freespot = -1;
			for (int i = 0; i < n; i++)
				if (threads[i] == null)
				{
					freespot = i;
					break;
				}
			
			// If we ran out of free spots then we need to grow the array to
			// fit more threads
			if (freespot < 0)
			{
				// Setup and copy source
				TaskThread[] newthreads = new TaskThread[n + _GROW_SIZE];
				for (int i = 0; i < n; i++)
					newthreads[i] = threads[i];
				
				// Set as new
				this._threads = (threads = newthreads);
				
				// Use the old size as the end point
				freespot = n;
			}
			
			// Setup thread object itself and store
			rv = new TaskThread(__pid, freespot, ++this._nextlid);
			threads[freespot] = rv;
		}
		
		return rv;
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/TooManyTasksException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.task;

/**
 * This is thrown when there are too many tasks remaining..
 *
 * @since 2019/12/14
 */
public class TooManyTasksException
	extends TaskException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/12/14
	 */
	public TooManyTasksException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/12/14
	 */
	public TooManyTasksException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/cc/squirreljme/jvm/task/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes and utilities regarding client tasks.
 *
 * @since 2019/09/22
 */

package cc.squirreljme.jvm.task;

Deleted runt/klib/supervisor/java/lang/ArithmeticException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when there is a divide by zero.
 *
 * @since 2018/12/04
 */
public class ArithmeticException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public ArithmeticException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public ArithmeticException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/ArrayIndexOutOfBoundsException.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when there is an out of bounds array access.
 *
 * @since 2019/05/26
 */
public class ArrayIndexOutOfBoundsException
	extends IndexOutOfBoundsException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/26
	 */
	public ArrayIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public ArrayIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public ArrayIndexOutOfBoundsException(int __m)
	{
		super(Integer.valueOf(__m).toString());
	}
}

Deleted runt/klib/supervisor/java/lang/ArrayStoreException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when an attempt is made to store into an array of a
 * mismatched type.
 *
 * @since 2019/06/11
 */
public class ArrayStoreException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/06/11
	 */
	public ArrayStoreException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/06/11
	 */
	public ArrayStoreException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/AutoCloseable.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface is used with the classes which are initialized in the
 * {@code try-with-resources} block, after the entire block has been finished
 * the {@link #close()} method is called automatically. This makes it much
 * simpler to free resources and no longer requires a {@code finally} with a
 * local variable mess to handle closing of streams.
 *
 * {@code
 *
 * try (FileInputStream fis = new FileInputStream("foo"))
 * {
 *     // fis is VISIBLE here.
 *     // Do stuff with file.
 * }
 * catch (IOException ioe)
 * {
 *     // fis is NOT VISIBLE here.
 *     // Handle exception or rethrow as needed
 * }
 * finally
 * {
 *     // fis is NOT VISIBLE here.
 *     // Other things to do regardless of success or an exception.
 * }
 * // The variable fis is NOT VISIBLE here and when this point of code has
 * // been reached, fis.close() would have been called.
 * 
 * }
 *
 * @see Closeable
 * @since 2015/03/23
 */
public interface AutoCloseable
{
	/**
	 * This releases all (or most) of the resources associated with
	 * an implementing class. When used with a try-with-resources block, this
	 * is automatically called after the scope of block has been left (it is
	 * executed after {@code finally}).
	 *
	 * It is recommended that a resource is actually closed (or at least
	 * marked as such) before an exception is thrown.
	 *
	 * Unlike {@link java.io.Closeable#close()} (and provided the class does
	 * not extend {@link java.io.Closeable}), calling this multiple times may
	 * produce side effects rather than doing nothing on a closed resource.
	 * However, it is stronly recommended and encouraged to follow the "do
	 * nothing when closed" behavior of {@link java.io.Closeable}.
	 *
	 * @throws Exception If there was an error closing the specified object.
	 * @since 2015/03/23
	 */
	public abstract void close()
		throws Exception;
}

Deleted runt/klib/supervisor/java/lang/Boolean.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents a boxed boolean value.
 *
 * @since 2019/05/25
 */
public final class Boolean
{
	/** The boolean value. */
	private final boolean _value;
	
	/**
	 * Initializes the boolean value.
	 *
	 * @param __v The value to use.
	 * @since 2019/09/22
	 */
	public Boolean(boolean __v)
	{
		this._value = __v;
	}
	
	/**
	 * Returns the value of the boolean.
	 *
	 * @return The boolean value.
	 * @since 2019/09/22.
	 */
	public final boolean booleanValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof Boolean))
			return false;
		
		return this._value == ((Boolean)__o)._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final int hashCode()
	{
		return (this._value ? 1 : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final String toString()
	{
		return (this._value ? "true" : "false");
	}
	
	/**
	 * Boxes the given boolean.
	 *
	 * @param __v The boolean to box.
	 * @return The boxed boolean value.
	 * @since 2019/09/22
	 */
	public static final Boolean valueOf(boolean __v)
	{
		return new Boolean(__v);
	}
}

Deleted runt/klib/supervisor/java/lang/Byte.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents a boxed byte.
 *
 * @since 2019/05/25
 */
public final class Byte
	extends Number
{
	/** The value of this byte. */
	private final byte _value;
	
	/**
	 * Initializes the byte.
	 *
	 * @param __v The value.
	 * @since 2019/12/14
	 */
	public Byte(byte __v)
	{
		this._value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/14
	 */
	@Override
	public String toString()
	{
		return Integer.toString(this._value, 10);
	}
	
	/**
	 * Wraps the given byte value.
	 *
	 * @param __v The value to wrap.
	 * @return The wrapped byte.
	 * @since 2019/12/14
	 */
	public static final Byte valueOf(byte __v)
	{
		return new Byte(__v);
	}
}

Deleted runt/klib/supervisor/java/lang/Character.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents a boxed character.
 *
 * @since 2019/05/25
 */
public final class Character
{
	/** The maximum radix for digit conversions. */
	public static final int MAX_RADIX =
		36;
	
	/** The maximum value for characters. */
	public static final char MAX_VALUE =
		65535;
	
	/** The minimum radix for digit conversions. */
	public static final int MIN_RADIX =
		2;
	
	/**
	 * Returns the character for the given digit and radix.
	 *
	 * @param __dig The digit to convert to a character.
	 * @param __r The radix to use for conversion.
	 * @return The character for the digit or NUL if the digit is out of range
	 * or the radix is out of range.
	 * @since 2018/10/13
	 */
	public static char forDigit(int __dig, int __r)
	{
		if (__dig < 0 || __dig >= __r || __r < Character.MIN_RADIX ||
			__r > Character.MAX_RADIX)
			return '\0';
		
		if (__dig < 10)
			return (char)('0' + __dig);
		return (char)('a' + (__dig - 10));
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @return The converted character.
	 * @since 2020/01/18
	 */
	public static char toLowerCase(char __c)
	{
		if (__c >= 'A' && __c <= 'Z')
			return (char)(__c + ('a' + (__c - 'A')));
		return __c;
	}
	
	/**
	 * Converts the specified character to lower case without considering
	 * locale.
	 *
	 * @param __c The character to convert.
	 * @return The converted character.
	 * @since 2020/01/18
	 */
	public static char toUpperCase(char __c)
	{
		if (__c >= 'a' && __c <= 'z')
			return (char)(__c + ('A' + (__c - 'a')));
		return __c;
	}
}

Deleted runt/klib/supervisor/java/lang/Class.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;

/**
 * This represents the Java accessible class object which describes this
 * class.
 *
 * @param <C> The class type.
 * @since 2019/05/26
 */
public final class Class<C>
{
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super class of this class.
	 * @since 2019/05/26
	 */
	public final Class<?> getSuperclass()
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
}

Deleted runt/klib/supervisor/java/lang/ClassCastException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when the class is not the correct type.
 *
 * @since 2019/05/25
 */
public class ClassCastException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public ClassCastException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public ClassCastException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/CloneNotSupportedException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when cloning is not supported for the given object.
 *
 * @since 2018/12/04
 */
public class CloneNotSupportedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/Comparable.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface is used to set two classes as being comparable to other
 * classes.
 *
 * It is not required to but comparisons performed by this interface should
 * be comparable to {@link Object#equals(Object)} so that
 * {@code a.equals(b) == (a.compareTo(b) == 0)}.
 *
 * It is recommended to implement this class so that
 * {@code a.compareTo(b) == -b.compareTo(a)} is true, this makes the
 * comparisons consistent. However this might not be feasible for speed
 * purposes so it is highly recommended to at least have comparible negative,
 * zero, and positive.
 *
 * @param <T> The type to compare.
 * @since 2018/09/19
 */
public interface Comparable<T>
{
	/**
	 * Compares this instance to the argument passed, 
	 *
	 * Note that {@code NullPointerException} should be thrown for {@code __b}
	 * since {@code __b.compareTo(this)} would thrown an exception.
	 *
	 * @param __b The object to compare against.
	 * @return The result of the comparison, negative values mean
	 * {@code this < __b}, zero means {@code this == __b}, and positive values
	 * mean {@code this > __b}.
	 * @since 2018/09/19
	 */
	public abstract int compareTo(T __b);
}


Deleted runt/klib/supervisor/java/lang/Deprecated.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which may be attached to classes, fields,
 * and methods to indicate that it should no longer be used in the future and
 * alternatives should be searched for and used instead.
 *
 * @since 2016/04/12
 */
@Documented
@Retention(value=RetentionPolicy.RUNTIME)
@Target(value={ElementType.CONSTRUCTOR, ElementType.FIELD,
	ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE,
	ElementType.PARAMETER, ElementType.TYPE})
public @interface Deprecated
{
}

Deleted runt/klib/supervisor/java/lang/Enum.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
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
191
192
193
194
195
196
197





































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.jvm.Assembly;

/**
 * This is the base class for enum types.
 *
 * @param <E> The enum type.
 * @since 2018/09/24
 */
public abstract class Enum<E extends Enum<E>>
	implements Comparable<E>
{
	/** The name of the enum. */
	private final String _name;
	
	/** The ordinal of the enumeration. */
	private final int _ordinal;
	
	/**
	 * Initializes the enum properties.
	 *
	 * @param __s The enum name.
	 * @param __o The enum ordinal.
	 * @throws IllegalArgumentException If the ordinal is negative.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/24
	 */
	protected Enum(String __s, int __o)
		throws IllegalArgumentException, NullPointerException
	{
		// Enum has no string
		if (__s == null)
			throw new NullPointerException();
		
		// Enum has negative ordinal
		if (__o < 0)
			throw new IllegalArgumentException();
		
		this._name = __s;
		this._ordinal = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	protected final Object clone()
		throws CloneNotSupportedException
	{
		// Enums cannot be cloned.
		throw new CloneNotSupportedException();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int compareTo(E __o)
		throws ClassCastException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException();
		
		// Cannot compare enums of a different type.
		if (this.getDeclaringClass() != __o.getDeclaringClass())
			throw new ClassCastException();
		
		// Just ordinal subtraction
		return this.ordinal() - __o.ordinal();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class that declares this enum, this may be different from
	 * {@link Object#getClass()}.
	 *
	 * @return The declaring class of this enum.
	 * @since 2018/09/24
	 */
	@SuppressWarnings({"unchecked"})
	public final Class<E> getDeclaringClass()
	{
		// Enums are either directly extending or extending a base class which
		// then extends this class, so we just need to look a few places up
		// the tree
		Class<?> me = this.getClass(),
			ext = me.getSuperclass();
		if (ext == Enum.class)
			return (Class<E>)((Object)me);
		return (Class<E>)((Object)ext);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int hashCode()
	{
		return super.hashCode();
	}
	
	/**
	 * Returns the name of the constant.
	 *
	 * @return The constant name.
	 * @since 2018/09/24
	 */
	public final String name()
	{
		return this._name;
	}
	
	/**
	 * Returns the ordinal of the constant.
	 *
	 * @return The ordinal constant.
	 * @since 2018/09/24
	 */
	public final int ordinal()
	{
		return this._ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public String toString()
	{
		return this._name;
	}
	
	/**
	 * From the given enumeration, find a value which matches the given name.
	 *
	 * @param <T> The enumeration type to search in.
	 * @param __cl The class to lookup.
	 * @param __s The string to search for.
	 * @return The enumeration value.
	 * @throws IllegalArgumentException If the value was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static <T extends Enum<T>> T valueOf(Class<T> __cl, String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null || __s == null)
			throw new NullPointerException("NARG");
		
		Assembly.breakpoint();
		throw new todo.TODO();
		/*
		// Get the data for this class because the enum information will be
		// in here somewhere
		ClassData data = ObjectAccess.classData(__cl);
		
		// {@squirreljme.error SV02 Cannot get the value of a non-enumeration
		// type or it has no implicit {@code values()} method.}
		StaticMethod getvalues = data.enumValues();
		if (getvalues == null)
			throw new ClassCastException("SV02");
		
		// Go through and check all the names
		for (Enum e : (Enum[])ObjectAccess.invokeStatic(getvalues))
			if (__s.equals(e.name()))
				return __cl.cast(e);
		
		// {@squirreljme.error SV03 Not an enumeration value. (The value)}
		throw new IllegalArgumentException(String.format("SV03 %s", __s));
		*/
	}
}

Deleted runt/klib/supervisor/java/lang/Error.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents an error which should not be caught.
 *
 * @since 2019/05/25
 */
public class Error
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public Error()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public Error(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Error(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Error(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/java/lang/Exception.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * For any exceptions which extend this class and not {@link RuntimeException}
 * they will act as checked exceptions by the compiler, thus they will need
 * to be handled accordingly.
 *
 * @since 2018/09/16
 */
public class Exception
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Exception()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public Exception(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/java/lang/IllegalArgumentException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the argument of a method is not correct.
 *
 * @since 2018/10/12
 */
public class IllegalArgumentException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public IllegalArgumentException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/java/lang/IllegalMonitorStateException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is usually thrown when an attempt is made to use a monitor which is
 * not owned by the current thread.
 *
 * @since 2018/12/04
 */
public class IllegalMonitorStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalMonitorStateException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/IllegalStateException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a certain state is invalid.
 *
 * @since 2018/12/04
 */
public class IllegalStateException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public IllegalStateException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/12/04
	 */
	public IllegalStateException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/java/lang/IndexOutOfBoundsException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when an index access was out of bounds.
 *
 * @since 2019/05/26
 */
public class IndexOutOfBoundsException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/26
	 */
	public IndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public IndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/Integer.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
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


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;

/**
 * This represents a boxed integer.
 *
 * @since 2019/05/25
 */
public final class Integer
	extends Number
{
	/** Minimum value. */
	public static final int MIN_VALUE =
		0x80000000;
	
	/** Maximum value. */
	public static final int MAX_VALUE =
		0x7FFFFFFF;
	
	/** The value of this integer. */
	private transient int _value;
	
	/**
	 * Initializes this integer.
	 *
	 * @param __v The value used.
	 * @since 2019/06/14
	 */
	public Integer(int __v)
	{
		this._value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/18
	 */
	@Override
	public String toString()
	{
		return Integer.toString(this._value, 10);
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(int __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Returns a boxed value.
	 *
	 * @param __v The value to use.
	 * @return The boxed value.
	 * @since 2019/05/26
	 */
	public static final Integer valueOf(int __v)
	{
		return new Integer(__v);
	}
}

Deleted runt/klib/supervisor/java/lang/InterruptedException.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when a thread is interrupted.
 *
 * Note that this does not clear the interrupt status of a thread.
 *
 * @since 2018/11/21
 */
public class InterruptedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/11/21
	 */
	public InterruptedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/21
	 */
	public InterruptedException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/Long.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
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









































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;

/**
 * This represents a boxed long value.
 *
 * @since 2019/05/25
 */
public final class Long
	extends Number
{
	/** The maximum value. */
	public static final long MAX_VALUE =
		9223372036854775807L;
	
	/** The minimum value. */
	public static final long MIN_VALUE =
		-9223372036854775808L;
	
	/** The size of the type in bits. */
	public static final int SIZE =
		64;
	
	/** The value of this long. */
	private transient long _value;
	
	/**
	 * Initializes this long.
	 *
	 * @param __v The value used.
	 * @since 2019/06/20
	 */
	public Long(long __v)
	{
		this._value = __v;
	}
	
	/**
	 * Returns the long value.
	 *
	 * @return The long value.
	 * @since 2019/06/21
	 */
	public long longValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/20
	 */
	@Override
	public String toString()
	{
		return Long.toString(this._value, 10);
	}
	
	/**
	 * Converts the value to a string using the given radix.
	 *
	 * @param __v The input value.
	 * @param __r The radix of the string, if it exceeds the maximum
	 * permitted radix specified in {@link Character} then this is set to 10.
	 * @return The resulting string.
	 * @since 2018/09/23
	 */
	public static String toString(long __v, int __r)
	{
		// If the radix is not valid, then just force to 10
		if (__r < Character.MIN_RADIX || __r > Character.MAX_RADIX)
			__r = 10;
		
		StringBuilder sb = new StringBuilder();
		
		// Negative? Remember it but we need to swap the sign
		boolean negative;
		if ((negative = (__v < 0)))
			__v = -__v;
		
		// Insert characters at the end of the string, they will be reversed
		// later, it is easier this way
		for (boolean digit = false;;)
		{
			// Determine the current place
			int mod = (int)(__v % __r);
			
			// Do not print if any other digit was stored
			if (__v == 0 && digit)
				break;
			
			// Print character
			sb.append((char)(mod < 10 ? '0' + mod : 'a' + (mod - 10)));
			digit = true;
			
			// Stop printing characters
			if (__v == 0)
				break;
			
			// Use the remaining division
			else
				__v = __v / __r;
		}
		
		// Add the sign in
		if (negative)
			sb.append('-');
			
		// Because the values are added in the opposite order, reverse it
		sb.reverse();
		
		return sb.toString();
	}
	
	/**
	 * Returns a boxed value.
	 *
	 * @param __v The value to use.
	 * @return The boxed value.
	 * @since 2019/06/20
	 */
	public static final Long valueOf(long __v)
	{
		return new Long(__v);
	}
}

Deleted runt/klib/supervisor/java/lang/Math.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * Math functions.
 *
 * @since 2019/11/30
 */
public class Math
{
	/**
	 * Returns the higher of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The higher value.
	 * @since 2018/09/29
	 */
	public static int max(int __a, int __b)
	{
		if (__a > __b)
			return __a;
		return __b;
	}
	
	/**
	 * Returns the lower of the two values.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The lower value.
	 * @since 2018/09/29
	 */
	public static int min(int __a, int __b)
	{
		if (__a < __b)
			return __a;
		return __b;
	}
}

Deleted runt/klib/supervisor/java/lang/NegativeArraySizeException.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when there was an attempt to create an array of a negative
 * size.
 *
 * @since 2019/05/26
 */
public class NegativeArraySizeException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/26
	 */
	public NegativeArraySizeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public NegativeArraySizeException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/NullPointerException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when there is a null pointer.
 *
 * @since 2019/05/25
 */
public class NullPointerException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public NullPointerException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public NullPointerException(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/Number.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is the base class for number types.
 *
 * @since 2019/05/25
 */
public abstract class Number
{
}

Deleted runt/klib/supervisor/java/lang/Object.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This class defines the base class for every class which exists.
 *
 * @since 2019/05/25
 */
public class Object
{
	/**
	 * Clones this object.
	 *
	 * @return The clone of this object.
	 * @since 2019/05/26
	 */
	protected Object clone()
		throws CloneNotSupportedException
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the class type for this object.
	 *
	 * @return The class type.
	 * @since 2019/05/26
	 */
	public final Class<?> getClass()
	{
		Assembly.breakpoint();
		throw new todo.TODO();
	}
	
	/**
	 * Returns the hash code for this object.
	 *
	 * @return The object hash code.
	 * @since 2019/05/25
	 */
	public int hashCode()
	{
		return Assembly.objectToPointer(this);
	}
	
	/**
	 * Checks if this object is equal to another object.
	 *
	 * @param __o The object to check.
	 * @return If the objects are equal.
	 * @since 2019/05/25
	 */
	public boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the string representation of this object.
	 *
	 * @return The string representation.
	 * @since 2019/05/25
	 */
	public String toString()
	{
		return JVMFunction.jvmLoadString(Assembly.pointerToClassInfo(
			Assembly.memReadInt(Assembly.objectToPointer(this),
			Constants.OBJECT_CLASS_OFFSET)).namep) +
			"@" + Integer.toString(this.hashCode(), 16);
	}
}

Deleted runt/klib/supervisor/java/lang/OutOfMemoryError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when the virtual machine has ran out of memory.
 *
 * @since 2019/05/26
 */
public class OutOfMemoryError
	extends VirtualMachineError
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/26
	 */
	public OutOfMemoryError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public OutOfMemoryError(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/Override.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which is attached to a method to indicate that
 * it overrides a method in the super class. When the compiler encounters
 * this, it makes sure that it actually overrides a method. If it does not
 * then a compilation error occurs. Using this all the time is recommended when
 * a method is intended to be overidden.
 *
 * As an example, if the base class has the following method:
 *
 * {@code
 * public static int foo(long __a);
 * }
 *
 * And a class which extends the base class has the following method:
 *
 * {@code
 * public static int foo(int __a);
 * }
 *
 * If it is intended to add a new {@code foo} which handles {@code int} instead
 * of {@code long} then this annotation should not be used, however it it is
 * intended to replace it (and specifying {@code int} was a mistake) then this
 * should be used.
 *
 * @since 2016/04/12
 */
@Target(value={ElementType.METHOD})
@Retention(value=RetentionPolicy.SOURCE)
public @interface Override
{
}


Deleted runt/klib/supervisor/java/lang/RuntimeException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is the base for any exception which is unchecked.
 *
 * @since 2019/05/25
 */
public class RuntimeException
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public RuntimeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public RuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public RuntimeException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public RuntimeException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/klib/supervisor/java/lang/Short.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents a boxed short.
 *
 * @since 2019/05/25
 */
public final class Short
	extends Number
{
}

Deleted runt/klib/supervisor/java/lang/String.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;

/**
 * This represents a string.
 *
 * @since 2019/05/25
 */
public final class String
{
	/** The first interned string. */
	private static volatile String _FIRST_INTERN;
	
	/** The backing array. */
	transient final char[] _chars;
	
	/** The hashcode for this string. */
	transient int _hashcode;
	
	/** The next intern string in the chain. */
	private transient volatile String _nextintern;
	
	/**
	 * Initializes an empty string.
	 *
	 * @since 2019/05/26
	 */
	public String()
	{
		this._chars = new char[0];
	}
	
	/**
	 * Initializes a string which uses characters which are a copy of the given
	 * character array, using the offset and length.
	 *
	 * @param __c The characters to copy.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/22
	 */
	public String(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Copy characters
		char[] copy = new char[__l];
		for (int i = __o, o = 0; o < __l; i++, o++)
			copy[o] = __c[i];
		
		// Just use the copied buffer
		this._chars = copy;
	}
	
	/**
	 * Initializes string decoded from the given UTF-8 byte.
	 *
	 * @param __b The UTF-8 bytes to decode.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/26
	 */
	public String(byte[] __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Create temporary output which has the input characters and such so
		// this will be the maximum used
		int bn = __b.length;
		char[] temp = new char[bn];
		
		// Translate UTF-8 sequences
		int nc = 0;
		for (int i = 0; i < bn;)
		{
			// Get character
			int c = __b[i++] & 0xFF;
			
			// Single byte
			if ((c & 0b1000_0000) == 0)
				temp[nc++] = (char)c;
			
			// Double byte
			else if ((c & 0b1110_0000) == 0b1100_0000)
			{
				c = ((c & 0b0001_1111) << 6);
				c |= (__b[i++] & 0b111111);
				temp[nc++] = (char)c;
			}
			
			// Triple byte
			else if ((c & 0b1111_0000) == 0b1110_0000)
			{
				c = ((c & 0b0000_1111) << 12);
				c |= ((__b[i++] & 0b111111) << 6);
				c |= (__b[i++] & 0b111111);
				temp[nc++] = (char)c;
			}
		}
		
		// Use direct array if the same length
		if (nc == bn)
			this._chars = temp;
		
		// Too short, copy only used chars
		else
		{
			char[] chars = new char[nc];
			for (int i = 0; i < nc; i++)
				chars[i] = temp[i];
			this._chars = chars;
		}
	}
	
	/**
	 * Returns the character at the given index.
	 *
	 * @param __i The index to get.
	 * @return The character here.
	 * @throws IndexOutOfBoundsException If it is not within bounds.
	 * @since 2019/05/27
	 */
	public final char charAt(int __i)
		throws IndexOutOfBoundsException
	{
		char[] chars = this._chars;
		if (__i < 0 || __i >= chars.length)
			throw new IndexOutOfBoundsException();
		return chars[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/26
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof String))
			return false;
		
		String o = (String)__o;
		if (this.hashCode() != o.hashCode())
			return false;
			
		// Character data
		char[] ac = this._chars,
			bc = o._chars;
		
		// If the length differs, they are not equal
		int n = ac.length;
		if (n != bc.length)
			return false;
		
		// Compare individual characters
		for (int i = 0; i < n; i++)
			if (ac[i] != bc[i])
				return false;
		
		// Would be a match!
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/26
	 */
	@Override
	public final int hashCode()
	{
		// If the hashcode was already determined before then use that
		// cache
		int rv = this._hashcode;
		if (rv != 0)
			return rv;
		
		// Calculate the hashCode(), the JavaDoc gives the following formula:
		// == s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] .... yikes!
		char[] ch = this._chars;
		for (int i = 0, n = ch.length; i < n; i++)
			rv = ((rv << 5) - rv) + ch[i];
		
		// Cache hashcode for later
		this._hashcode = rv;
		return rv;
	}
	
	/**
	 * Returns a string which is a unique internal representation of a string.
	 *
	 * @return The unique interned string.
	 * @since 2019/05/26
	 */
	public final String intern()
	{
		// If no strings have ever been interned before, make this intern
		String first = _FIRST_INTERN;
		if (first == null)
		{
			_FIRST_INTERN = this;
			return this;
		}
		
		// Go through the linked list chain finding our string
		String at = first;
		while (at != null)
		{
			// Use the target string if it is the same
			if (this.equals(at))
				return at;
			
			// Go to the next link
			at = at._nextintern;
		}
		
		// Next intern is the first and the first becomes this one
		this._nextintern = first;
		_FIRST_INTERN = this;
		
		// Return our string since it was not in the chain
		return this;
	}
	
	/**
	 * Returns the last occurance of the given character.
	 *
	 * @param __c The character to find.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c)
	{
		return this.lastIndexOf(__c, Integer.MAX_VALUE);
	}
	
	/**
	 * Returns the last occurance of the given character going backwards from
	 * the given index.
	 *
	 * @param __c The character to find.
	 * @param __dx The index to start at, this is clipped to within the
	 * string bounds accordingly although if it is negative no searching is
	 * done.
	 * @return The last occurance of the character or {@code -1} if it was
	 * not found.
	 * @since 2018/09/29
	 */
	public int lastIndexOf(int __c, int __dx)
	{
		// Never going to find anything at all
		if (__dx < 0)
			return -1;
		
		// Cap index
		char[] ch = this._chars;
		int n = ch.length;
		if (__dx >= n)
			__dx = n - 1;
		
		for (; __dx >= 0; __dx--)
			if (__c == ch[__dx])
				return __dx;
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns the string length.
	 *
	 * @return The string length.
	 * @since 2019/05/27
	 */
	public final int length()
	{
		return this._chars.length;
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __toff The offset for this string.
	 * @param __o The other string to compare against.
	 * @param __ooff The offset of the target string.
	 * @param __len The number of characters to compare.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(int __toff, String __o, int __ooff, int __len)
	{
		return this.regionMatches(false, __toff, __o, __ooff, __len);
	}
	
	/**
	 * Compares the given string regions to see if they match.
	 *
	 * @param __igncase Is case to be ignored?
	 * @param __toff The offset for this string.
	 * @param __b The other string to compare against.
	 * @param __boff The offset of the target string.
	 * @param __len The number of characters to compare.
	 * @return If the region matches or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/18
	 */
	public boolean regionMatches(boolean __igncase, int __toff, String __b,
		int __boff, int __len)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Automatically false
		if (__toff < 0 || __boff < 0 ||
			__toff + __len > this.length() || __boff + __len > __b.length())
			return false;
		
		// A quirk of the standard is that negative lengths are not an error
		// but are treated as matches
		if (__len < 0)
			return true;
		
		// Disregarding case
		if (__igncase)
			for (int i = 0; i < __len; i++, __toff++, __boff++)
			{
				char a = this.charAt(__toff),
					b = __b.charAt(__boff);
				
				if (Character.toLowerCase(a) != Character.toLowerCase(b) &&
					Character.toUpperCase(a) != Character.toUpperCase(b))
					return false;
			}
		
		// Regarding case
		else
			for (int i = 0; i < __len; i++, __toff++, __boff++)
				if (this.charAt(__toff) != __b.charAt(__boff))
					return false;
		
		// Matches
		return true;
	}
	
	/**
	 * Returns a substring of this string starting at the given index.
	 *
	 * @param __s The index to start at.
	 * @return The sub-string for that index.
	 * @throws IndexOutOfBoundsException If the start is outside of the bounds.
	 * @since 2019/11/15
	 */
	public String substring(int __s)
		throws IndexOutOfBoundsException
	{
		// A substring starting at the zero character is the same
		if (__s == 0)
			return this;
		
		// Call other
		return this.substring(__s, this.length());
	}
	
	/**
	 * Returns a substring of this string.
	 *
	 * @param __s The starting index.
	 * @param __e The ending index.
	 * @throws IndexOutOfBoundsException If the string region is outside of
	 * bounds.
	 * @since 2019/11/15
	 */
	public String substring(int __s, int __e)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error SV0s String substring is outside of bounds.}
		if (__s < 0 || __s > __e || __e > this.length())
			throw new IndexOutOfBoundsException("SV0s");
		
		return new String(this._chars, __s, (__e - __s));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/26
	 */
	@Override
	public final String toString()
	{
		return this;
	}
}

Deleted runt/klib/supervisor/java/lang/StringBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This class is used to build instances of string.
 *
 * @since 2019/05/25
 */
public final class StringBuilder
{
	/** Default capacity of the internal array. */
	private static final int _DEFAULT_CAPACITY =
		16;
	
	/** The internal buffer for storing characters. */
	private char[] _buffer;
	
	/** The characters which are in the buffer. */
	private int _at;
	
	/** The limit of the string buffer. */
	private int _limit;
	
	/**
	 * Initializes with the default capacity.
	 *
	 * @since 2018/09/22
	 */
	public StringBuilder()
	{
		this(StringBuilder._DEFAULT_CAPACITY);
	}
	
	/**
	 * Initailizes with the given capacity.
	 *
	 * @param __c The initial capacity.
	 * @throws NegativeArraySizeException If the capacity is negative.
	 * @since 2018/09/22
	 */
	public StringBuilder(int __c)
		throws NegativeArraySizeException
	{
		if (__c < 0)
			throw new NegativeArraySizeException();
		
		// Initialize buffer
		this._buffer = new char[__c];
		this._limit = __c;
	}
	
	/**
	 * Appends a character into this one.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2019/06/18
	 */
	public final StringBuilder append(char __v)
	{
		// Before we go deeper check if the buffer needs to grow
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + 1 > limit ? this.__buffer(1) : this._buffer);
		
		// Add to the end
		buffer[at] = __v;
		this._at = at + 1;
		
		// Self
		return this;
	}
	
	/**
	 * Appends an integer into this one.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2019/11/24
	 */
	public final StringBuilder append(int __v)
	{
		return this.append(Integer.toString(__v, 10));
	}
	
	/**
	 * Appends an object into this one.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2019/11/25
	 */
	public final StringBuilder append(Object __v)
	{
		return this.append((__v == null ? "null" : __v.toString()));
	}
	
	/**
	 * Appends a string into this one.
	 *
	 * @param __v The value to append.
	 * @return {@code this}.
	 * @since 2019/05/25
	 */
	public final StringBuilder append(String __v)
	{
		// Print null?
		if (__v == null)
			__v = "null";
		
		// Length to append
		int len = __v.length();
		
		// Get buffer properties
		int limit = this._limit,
			at = this._at;
		char[] buffer = (at + len > limit ? this.__buffer(len) : this._buffer);
		
		// Place input characters at this point
		for (int i = 0; i < len; i++)
			buffer[at++] = __v.charAt(i);
		
		// Set new size
		this._at = at;
		
		return this;
	}
	
	/**
	 * Reverses all of the characters in the string.
	 *
	 * @return {@code this}.
	 * @since 2018/09/23
	 */
	public StringBuilder reverse()
	{
		// Get the buffer
		char[] buffer = this._buffer;
		int at = this._at;
		
		// Swap all the characters, a less than be because if it reaches the
		// center there will be no need to swap anything
		for (int a = 0, b = at - 1; a < b; a++, b--)
		{
			char x = buffer[a];
			buffer[a] = buffer[b];
			buffer[b] = x;
		}
		
		// Self
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/18
	 */
	@Override
	public final String toString()
	{
		return new String(this._buffer, 0, this._at);
	}
	
	/**
	 * Obtains the buffer, potentially resizing it to fit the given amount
	 * of characters.
	 *
	 * @param __l The number of characters to add.
	 * @return The buffer.
	 * @since 2018/09/23
	 */
	private final char[] __buffer(int __l)
	{
		// Get buffer properties
		char[] buffer = this._buffer;
		int limit = this._limit,
			at = this._at;
		
		// Need to resize the buffer to fit this?
		int nextat = at + __l;
		if (nextat > limit)
		{
			int newcapacity = nextat + StringBuilder._DEFAULT_CAPACITY;
			
			// Copy characters over
			char[] extra = new char[newcapacity];
			for (int i = 0; i < at; i++)
				extra[i] = buffer[i];
			
			this._buffer = (buffer = extra);
			this._limit = newcapacity;
		}
		
		return buffer;
	}
}

Deleted runt/klib/supervisor/java/lang/SuppressWarnings.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Suppresses warnings that are generated by the compiler so that they do not
 * appear for the given method. Duplicates are permitted and values which are
 * unknown are ignored.
 *
 * The following warnings may have support to be disabled, although it is not
 * required: {@code all}, {@code boxing}, {@code cast}, {@code dep-ann},
 * {@code deprecation}, {@code fallthrough}, {@code finally}, {@code hiding},
 * {@code incomplete-switch}, {@code nls}, {@code null}, {@code rawtypes},
 * {@code restriction}, {@code serial}, {@code static-access},
 * {@code synthetic-access}, {@code unchecked},
 * {@code unqualified-field-access}, and {@code unused}.
 *
 * @since 2018/09/19
 */
@Target(value={ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
	ElementType.PARAMETER, ElementType.CONSTRUCTOR,
	ElementType.LOCAL_VARIABLE})
@Retention(value=RetentionPolicy.SOURCE)
public @interface SuppressWarnings
{
	/** The warnings that should be suppressed. */
	String[] value();
}

Deleted runt/klib/supervisor/java/lang/System.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This contains some basic system functions.
 *
 * @since 2019/06/20
 */
public final class System
{
	/**
	 * Returns the current time on the system's clock in UTC since the epoch
	 * (January 1, 1970 UTC).
	 *
	 * Note that this clock is not monotonic in that if a system adjusts the
	 * system clock this method may return values lower than previous calls
	 * which are made.
	 *
	 * Depending on the host hardware and operating system, the granularity of
	 * this clock may or may not be accurate.
	 *
	 * @return The number of milliseconds since the epoch.
	 * @since 2017/11/10
	 */
	public static long currentTimeMillis()
	{
		// Returns the current time in UTC, not local time zone.
		return Assembly.sysCallPVL(SystemCallIndex.TIME_MILLI_WALL);
	}
	
	/**
	 * Returns the number of nanoseconds which have passed from a previously
	 * unspecified time. The returned value might not be accurate to the
	 * nanosecond. This clock is monotonic and does not suffer from time
	 * shifts caused by clock adjustments.
	 *
	 * The value returned here is specific to the current virtual machine and
	 * cannot be used elsewhere. Even two virtual machines running on the
	 * same system can use completely different values.
	 *
	 * After about 292 years (2 to the 63rd power nanoseconds) using signed
	 * comparison to calculate the amount of time that has passed will no
	 * longer function properly. For extremely long running processes it is
	 * recommended to treat the values as unsigned to extend past this limit
	 * or handle the overflow of the time value to represent any time
	 * quantity, this of course requires that time be checked every 292 or
	 * 584 years).
	 *
	 * @return The number of nanoseconds which have passed.
	 * @since 2016/06/16
	 */
	public static long nanoTime()
	{
		// Returns the current monotonic clock time
		return Assembly.sysCallPVL(SystemCallIndex.TIME_NANO_MONO);
	}
}

Deleted runt/klib/supervisor/java/lang/Throwable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326






































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is the base class for all throwable types.
 *
 * @since 2019/05/25
 */
public class Throwable
{
	/** The message to use. */
	transient final String _message;
	
	/** The cause of this exception. */
	transient final Throwable _cause;
	
	/** The call trace. */
	transient final int[] _rawtrace;
	
	/** Suppressed exceptions. */
	transient volatile Throwable[] _suppressed;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public Throwable()
	{
		this(null, null);
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public Throwable(String __m)
	{
		this(__m, null);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Throwable(String __m, Throwable __t)
	{
		// Hit a breakpoint if this is OOM
		if (this instanceof OutOfMemoryError)
			Assembly.breakpoint();
		
		this._message = __m;
		this._cause = __t;
		
		// Get the trace
		this._rawtrace = Throwable.__trace();
		
		// Print this trace
		this.printStackTrace();
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Throwable(Throwable __t)
	{
		this(null, __t);
	}
	
	/**
	 * Adds a suppressed throwable which will be thrown alongside this
	 * throwable. This is mainly used with try-with-resources although a
	 * programmer may wish to add related throwables that additionally
	 * happened.
	 *
	 * @param __t The throwable to suppress.
	 * @throws IllegalArgumentException If the passed throwable is this.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final void addSuppressed(Throwable __t)
		throws IllegalArgumentException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error SV05 Cannot add a suppressed exception which
		// is this exception.}
		if (__t == this)
			throw new IllegalArgumentException("SV05");
		
		// No suppressed exceptions were set, initialize
		Throwable[] suppressed = this._suppressed;
		if (suppressed == null)
			this._suppressed = new Throwable[]{__t};
		
		// Otherwise rebuild the array and add it
		else
		{
			int n = suppressed.length;
			Throwable[] copy = new Throwable[n + 1];
			for (int i = 0; i < n; i++)
				copy[i] = suppressed[i];
			copy[n] = __t;
			
			// Use this instead
			this._suppressed = copy;
		}
	}
	
	/**
	 * Returns the message.
	 *
	 * @return The message used.
	 * @since 2019/06/16
	 */
	public String getMessage()
	{
		return this._message;
	}
	
	/**
	 * Prints the nicely formatted stack trace.
	 *
	 * @since 2019/06/17
	 */
	public void printStackTrace()
	{
		// This could fail in the event something is very wrong!
		try
		{
			// Print this and any causes!
			for (Throwable rover = this; rover != null; rover = rover._cause)
			{
				// Is this the main trace or a caused by?
				todo.DEBUG.note("%s Stack Trace: (%s) %s", (rover == this ?
					"Supervisor" : "Caused By"), JVMFunction.jvmLoadString(
						Assembly.pointerToClassInfo( Assembly.memReadInt(
						Assembly.objectToPointer(this),
						Constants.OBJECT_CLASS_OFFSET)).namep),
						rover.toString());
				
				// Obtain the raw trace that was captured on construction
				int[] rawtrace = this._rawtrace;
				int rawn = rawtrace.length;
				
				// Print all the items in it
				StringBuilder sb = new StringBuilder();
				for (int b = 0; b < rawn; b += CallStackItem.NUM_ITEMS)
				{
					// Print it out
					todo.DEBUG.note("    %s::%s:%s T%d (%s:%d) A@%d J@%d/%d",
						JVMFunction.jvmLoadString(
							rawtrace[b + CallStackItem.CLASS_NAME]),
						JVMFunction.jvmLoadString(
							rawtrace[b + CallStackItem.METHOD_NAME]),
						JVMFunction.jvmLoadString(
							rawtrace[b + CallStackItem.METHOD_TYPE]),
						rawtrace[b + CallStackItem.TASK_ID],
						JVMFunction.jvmLoadString(
							rawtrace[b + CallStackItem.SOURCE_FILE]),
						rawtrace[b + CallStackItem.SOURCE_LINE],
						Integer.toString(
							rawtrace[b + CallStackItem.PC_ADDRESS], 16),
						rawtrace[b + CallStackItem.JAVA_OPERATION],
						rawtrace[b + CallStackItem.JAVA_PC_ADDRESS]);
				}
			}
		}
		
		// If printing out this trace failed then use the backup mechanism!
		catch (Throwable t)
		{
			// Print the original trace
			this.printStackTraceBackup();
			
			// Print the raw backup trace for the trace we tried to print
			// to figure out what potentially went wrong?
			todo.DEBUG.codeBarrier('p', 'T');
			t.printStackTraceBackup();
			todo.DEBUG.codeBarrier('P', 't');
		}
	}
	
	/**
	 * Print a stack trace using only codes so that it may still be used
	 * accordingly as such.
	 *
	 * @since 2019/09/22
	 */
	public void printStackTraceBackup()
	{
		// Print this and any causes!
		for (Throwable rover = this; rover != null; rover = rover._cause)
		{
			// Supervisor or caused by?
			todo.DEBUG.code('T', (rover == this ? 'S' : 'C'),
				Assembly.objectToPointer(rover));
			
			// The thrown type
			todo.DEBUG.code('T', 'Y', Assembly.memReadInt(
				Assembly.objectToPointer(this),
				Constants.OBJECT_CLASS_OFFSET));
			
			// Obtain the raw trace that was captured on construction
			int[] rawtrace = this._rawtrace;
			int rawn = rawtrace.length;
			
			// Print all the items in it
			for (int base = 0; base < rawn; base += CallStackItem.NUM_ITEMS)
				try
				{
					// Indicate start of element
					todo.DEBUG.code('T', '-');
					
					// Print out the raw details
					todo.DEBUG.codeUtf('T', 'c',
						rawtrace[base + CallStackItem.CLASS_NAME]);
					todo.DEBUG.codeUtf('T', 'n',
						rawtrace[base + CallStackItem.METHOD_NAME]);
					todo.DEBUG.codeUtf('T', 'y',
						rawtrace[base + CallStackItem.METHOD_TYPE]);
					todo.DEBUG.codeUtf('T', '#',
						rawtrace[base + CallStackItem.TASK_ID]);
					todo.DEBUG.codeUtf('T', 'f',
						rawtrace[base + CallStackItem.SOURCE_FILE]);
					todo.DEBUG.code('T', 'l',
						rawtrace[base + CallStackItem.SOURCE_LINE]);
					todo.DEBUG.code('T', 'a',
						rawtrace[base + CallStackItem.PC_ADDRESS]);
					todo.DEBUG.code('T', 'j',
						rawtrace[base + CallStackItem.JAVA_PC_ADDRESS]);
					todo.DEBUG.code('T', 'o',
						rawtrace[base + CallStackItem.JAVA_OPERATION]);
				}
				
				// Error getting stack trace element
				catch (Throwable t)
				{
					todo.DEBUG.code('X', 'T', base);
				}
			
			// Indicate end of current set
			todo.DEBUG.code('T', '<');
		}
		
		// Indicate end of trace log
		todo.DEBUG.code('T', '_');
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/24
	 */
	@Override
	public String toString()
	{
		return this._message;
	}
	
	/**
	 * Returns the call stack.
	 *
	 * @return The resulting call stack.
	 * @since 2019/06/17
	 */
	private static final int[] __trace()
	{
		// Get the call height, ignore if not supported!
		int callheight = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_HEIGHT);
		if (callheight <= 0 || Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.CALL_STACK_HEIGHT) != SystemCallError.NO_ERROR)
			return new int[0];
		
		// Remove the top-most frame because it will be this method
		callheight--;
		
		// Get the call parameters
		int[] rv = new int[callheight * CallStackItem.NUM_ITEMS];
		for (int z = 0, base = 0; z < callheight; z++,
			base += CallStackItem.NUM_ITEMS)
			for (int i = 0; i < CallStackItem.NUM_ITEMS; i++)
			{
				// Get parameter
				int vx = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_ITEM,
					1 + z, i);
				
				// Nullify unknown or invalid parameters
				if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
					SystemCallIndex.CALL_STACK_ITEM) !=
					SystemCallError.NO_ERROR)
					vx = 0;
				
				// Fill in
				rv[base + i] = vx;
			}
		
		// Return the raw parameters
		return rv;
	}
}

Deleted runt/klib/supervisor/java/lang/VirtualMachineError.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when there is a problem with the virtual machine.
 *
 * @since 2019/05/26
 */
public class VirtualMachineError
	extends Error
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/26
	 */
	public VirtualMachineError()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/26
	 */
	public VirtualMachineError(String __m)
	{
		super(__m);
	}
}

Deleted runt/klib/supervisor/java/lang/annotation/Annotation.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is the common interface in which all annotation types are inherited
 * from.
 *
 * If a random class or interface implements this interface and it is not an
 * annotation type, then it is not an annotation.
 *
 * @since 2014/10/13
 */
public interface Annotation
{
	/**
	 * Returns the annotation type used for this annotation.
	 *
	 * @return The annotation type.
	 * @since 2014/10/13
	 */
	public abstract Class<? extends Annotation> annotationType();
	
	/**
	 * Checks the logical equality to another annotation type, they are both
	 * considered to be equal when all of their members are equal and they are
	 * of the same type.
	 *
	 * Primitive types are checked directly except for floating point types
	 * which are equality checked through their wrapper classes.
	 *
	 * Floating point NaN values are considered to be equal, that is the
	 * {@code ==} operator is not used.
	 *
	 * {@link String}, {@link Class}, and enumerations are considered equal if
	 * their normal {@code equals()} evaluates to true.
	 *
	 * Two arrays are equal if {@code Arrays.equals(a, b)} evaluates to
	 * {@code true}.
	 *
	 * @param __o The other object to check against.
	 * @return {@code true} if they are logically equivalent.
	 * @since 2014/10/13
	 */
	public abstract boolean equals(Object __o);
	
	/**
	 * Calculates the hash code which is a sum of the hash codes of its members
	 * in a specifically defined pattern.
	 *
	 * The base hash code for a member is {@code (127 *
	 * ((String)memberName).hashCode()) ^ specialValue}. The variable
	 * {@code specialValue} is defined depending on the
	 * context. If it is a primitive type, then the hash code that would be
	 * returned if they were object types (their wrapper classes) is used. If
	 * an array then {@code Arrays.hashCode()} is used. Otherwise, it is the
	 * normal hashCode of the specified value.
	 *
	 * @return The hash code for this annotation.
	 * @since 2014/10/13
	 */
	public abstract int hashCode();
	
	/**
	 * Returns an implementation dependent string which represents the
	 * annotation and all of its values.
	 *
	 * @return The string representation of this annotation.
	 * @since 2014/10/13
	 */
	public abstract String toString();
}

Deleted runt/klib/supervisor/java/lang/annotation/Documented.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This indicates that the specified annotation should be documented by the
 * Java documentation tool whenever it is used.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Documented
{
}

Deleted runt/klib/supervisor/java/lang/annotation/ElementType.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the type of element that the annotation is permitted to be
 * attached to in the source code.
 *
 * @since 2014/10/13
 */
public enum ElementType
{
	/** Annotation types). */
	ANNOTATION_TYPE(),
	
	/** Constructors. */
	CONSTRUCTOR(),
	
	/** Fields. */
	FIELD(),
	
	/** Local variables. */
	LOCAL_VARIABLE(),
	
	/** Methods. */
	METHOD(),
	
	/** Packages. */
	PACKAGE(),
	
	/** Parameter of a method. */
	PARAMETER(),
	
	/** A class, interface, or enumeration. */
	TYPE(),
	
	/** End. */
	;
}

Deleted runt/klib/supervisor/java/lang/annotation/Inherited.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Indicates that the annotation type should automatically be inherited so that
 * the subclass type appears to have this annotation when it is requested. That
 * is, if an annotation with this annotation is requested it will keep going up
 * the superclasses until it is found.
 *
 * This only affects classes which use an annotation with this annotation, as
 * such interfaces are excluded.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Inherited
{
}

Deleted runt/klib/supervisor/java/lang/annotation/Retention.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is used to indicate how far into the compilation and runtime process
 * should keep a visible mark on an annotation.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Retention
{
	/**
	 * Specifies where the annotation exists during and after compilation of
	 * source code.
	 *
	 * @return The storage of the annotation.
	 * @see RetentionPolicy
	 * @since 2014/10/13
	 */
	RetentionPolicy value();
}

Deleted runt/klib/supervisor/java/lang/annotation/RetentionPolicy.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies how far through compilation and running of code that an annotation
 * should be visible.
 *
 * @since 2014/10/13
 */
public enum RetentionPolicy
{
	/** Kept after compilation, but not visible at runtime. */
	CLASS(),
	
	/** Kept after compilation and visible at runtime. */
	RUNTIME(),
	
	/** Removed after compilation, does not appear in the class file. */
	SOURCE(),
	
	/** End. */
	;
}

Deleted runt/klib/supervisor/java/lang/annotation/Target.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the context in which the annotation is valid.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Target
{
	/**
	 * A list of valid contexts where the annotation may be used.
	 *
	 * @return An array of permitted targets.
	 * @since 2014/10/13
	 */
	ElementType[] value();
}

Deleted runt/klib/supervisor/java/lang/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Base Java language support.
 *
 * @since 2019/05/25
 */

package java.lang;

Deleted runt/klib/supervisor/java/util/HashMap.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
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
191
192
193
194
195
196
197
198
199
200
201









































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

import cc.squirreljme.jvm.Assembly;

/**
 * This represents a standard hash map.
 *
 * @since 2019/06/24
 */
public class HashMap<K, V>
{
	/** The number of buckets to use. */
	private static final int _BUCKET_COUNT =
		16;
	
	/** Mask for buckets. */
	private static final int _BUCKET_MASK =
		0xF;
	
	/** Buckets available. */
	private final __Bucket__[] _buckets =
		new __Bucket__[_BUCKET_COUNT];
	
	/**
	 * Checks if the map contains the given key.
	 *
	 * @param __k The key to check.
	 * @return If a key is contained in it.
	 * @since 2019/06/24
	 */
	public boolean containsKey(Object __k)
	{
		// Calculate hash code
		int hash = __k.hashCode();
		
		// Find existing bucket
		__Bucket__ bucket = this._buckets[hash & _BUCKET_MASK];
		if (bucket == null)
			return false;
		
		// Go through items
		for (__Item__ i : bucket._items)
			if (i != null && i._hash == hash && HashMap.__equals(__k, i._key))
				return true;
		
		// Not found
		return false;
	}
	
	/**
	 * Gets a value from the map.
	 *
	 * @param __k The key to get.
	 * @return The value.
	 * @since 2019/06/24
	 */
	@SuppressWarnings({"unchecked"})
	public V get(K __k)
	{
		// Calculate hash code
		int hash = __k.hashCode();
		
		// Find existing bucket
		__Bucket__ bucket = this._buckets[hash & _BUCKET_MASK];
		if (bucket == null)
			return null;
		
		// Go through items
		for (__Item__ i : bucket._items)
			if (i != null && i._hash == hash && HashMap.__equals(__k, i._key))
				return (V)i._value;
		
		// Not found
		return null;
	}
	
	/**
	 * Puts an item into the map.
	 *
	 * @param __k The key.
	 * @param __v The value.
	 * @return The old item, if any.
	 * @since 2019/06/24
	 */
	@SuppressWarnings({"unchecked"})
	public V put(K __k, V __v)
	{
		// Calculate hash code
		int hash = __k.hashCode(),
			bkid = hash & _BUCKET_MASK;
		
		// Find existing bucket, create if missing
		__Bucket__ bucket = this._buckets[bkid];
		if (bucket == null)
			this._buckets[bkid] = (bucket = new __Bucket__());
		
		// Check if it already exists in the map
		__Item__[] items = bucket._items;
		int n = items.length,
			empty = -1;
		for (int i = 0; i < n; i++)
		{
			__Item__ it = items[i];
			
			// Is empty slot, use it
			if (it == null)
				empty = i;
			
			// Matching key, replace
			else if (it._hash == hash && HashMap.__equals(__k, it._key))
			{
				V rv = (V)it._value;
				it._value = __v;
				return rv;
			}
		}
		
		// Add new item at the end
		__Item__[] newitems = new __Item__[n + 1];
		for (int i = 0; i < n; i++)
			newitems[i] = items[i];
		__Item__ it = new __Item__(hash, __k);
		newitems[n] = it;
		it._value = __v;
		
		// Store new items
		bucket._items = newitems;
		
		// There was no previous old value
		return null;
	}
	
	/**
	 * Returns if two objects are equal to each other.
	 *
	 * @param __a The first object.
	 * @param __b The second object.
	 * @return If they are equal or not.
	 * @since 2019/06/24
	 */
	private static final boolean __equals(Object __a, Object __b)
	{
		// Either side is null
		if (__a == null || __b == null)
			return (__a == __b);
		
		// Use equality check
		return __a.equals(__b);
	}
	
	/**
	 * This represents a single bucket within the map.
	 *
	 * @since 2019/06/24
	 */
	private static final class __Bucket__
	{
		/** Items within the bucket. */
		__Item__[] _items =
			new __Item__[_BUCKET_COUNT];
	}
	
	/**
	 * A single item within a bucket.
	 *
	 * @since 2019/06/24
	 */
	private static final class __Item__
	{
		/** The hashcode. */
		final int _hash;
		
		/** The key. */
		final Object _key;
		
		/** The value. */
		Object _value;
		
		/**
		 * Initializes the item.
		 *
		 * @param __h The hash.
		 * @param __k The key.
		 */
		__Item__(int __h, Object __k)
		{
			this._hash = __h;
			this._key = __k;
		}
	}
}

Deleted runt/klib/supervisor/java/util/Objects.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * Object utilties.
 *
 * @since 2019/11/25
 */
public class Objects
{
	/**
	 * Checks whether two objects are equal to each other, if one of the
	 * values is {@code null} then this returns {@code false}, otherwise
	 * equality is checked. If both values are {@code null} then {@code true}
	 * is returned.
	 *
	 * @param __a The object which gets {@link Object#equals(Object)} called.
	 * @param __b The parameter to that call.
	 * @return {@code true} if they are both equal or both {@code null}.
	 * @since 2016/04/12
	 */
	public static boolean equals(Object __a, Object __b)
	{
		// Which sides are null
		boolean na = (__a == null);
		boolean nb = (__b == null);
		
		// One side is null, but the other is not
		if (na != nb)
			return false;
		
		// Both sides are null (just need to check one)
		else if (na)
			return true;
		
		// Standard equals
		return __a.equals(__b);
	}
	
	/**
	 * Returns the hash code of the given object or {@code 0} if it is
	 * {@code null}.
	 *
	 * @param __a The object to get the hashcode of.
	 * @return The object's hash code or {@code 0} if it is {@code null}.
	 * @since 2016/04/12
	 */
	public static int hashCode(Object __a)
	{
		if (__a == null)
			return 0;
		return __a.hashCode();
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code "null"} is returned.
	 *
	 * @param __a The value to get the string of.
	 * @return The string of the given value or {@code "null"} if the input is
	 * {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a)
	{
		if (__a == null)
			return "null";
		return __a.toString();
	}
	
	/**
	 * Converts the specified object to a string, if the input value is
	 * {@code null} then {@code __b} is returned.
	 *
	 * @param __a The object to get the string of.
	 * @param __b The value to return if {@code __a} is {@code null}.
	 * @return The string represention of {@code __a} or else {@code __b} if
	 * the input is {@code null}.
	 * @since 2016/04/12
	 */
	public static String toString(Object __a, String __b)
	{
		if (__a == null)
			return __b;
		return __a.toString();
	}
}

Deleted runt/klib/supervisor/java/util/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Standard Java utility classes.
 *
 * @since 2019/06/24
 */

package java.util;

Deleted runt/klib/supervisor/todo/DEBUG.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282


























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * Contains basic debug output printing.
 *
 * @since 2019/05/26
 */
public final class DEBUG
{
	/**
	 * Not used.
	 *
	 * @since 2019/05/26
	 */
	private DEBUG()
	{
	}
	
	/**
	 * Prints a very basic debug code.
	 *
	 * @param __a First character.
	 * @param __b Second character.
	 * @since 2019/09/22
	 */
	public static final void code(char __a, char __b)
	{
		// Get the pipe descriptor for standard error, ignore if it fails
		int fd = Assembly.sysCallV(SystemCallIndex.PD_OF_STDERR);
		if (SystemCallError.getError(SystemCallIndex.PD_OF_STDERR) != 0)
			return;
		
		// Pipe characters
		DEBUG.__pipe(fd, __a);
		DEBUG.__pipe(fd, __b);
		
		// Ending newline
		DEBUG.__pipe(fd, '\n');
	}
	
	/**
	 * Prints a very basic debug code.
	 *
	 * @param __a First character.
	 * @param __b Second character.
	 * @param __v Value.
	 * @since 2019/06/13
	 */
	public static final void code(char __a, char __b, int __v)
	{
		// Get the pipe descriptor for standard error, ignore if it fails
		int fd = Assembly.sysCallV(SystemCallIndex.PD_OF_STDERR);
		if (SystemCallError.getError(SystemCallIndex.PD_OF_STDERR) != 0)
			return;
		
		// Pipe characters
		DEBUG.__pipe(fd, __a);
		DEBUG.__pipe(fd, __b);
		DEBUG.__pipe(fd, ' ');
		
		// Print digit as hex, this should print all 8 digits
		for (int i = 28; i >= 0; i -= 4)
		{
			// Get upper most hex
			int h = ((__v >>> i) & 0xF);
			
			// Print letter or number?
			DEBUG.__pipe(fd, (char)(h >= 10 ? 'a' + (h - 10) : '0' + h));
		}
		
		// Ending newline
		DEBUG.__pipe(fd, '\n');
	}
	
	/**
	 * Prints a barrier in printing!
	 *
	 * @param __a First character.
	 * @param __b Second character.
	 * @since 2019/09/22
	 */
	public static final void codeBarrier(char __a, char __b)
	{
		// Get the pipe descriptor for standard error, ignore if it fails
		int fd = Assembly.sysCallV(SystemCallIndex.PD_OF_STDERR);
		if (SystemCallError.getError(SystemCallIndex.PD_OF_STDERR) != 0)
			return;
		
		// Pipe characters
		DEBUG.__pipe(fd, __a);
		DEBUG.__pipe(fd, __b);
		DEBUG.__pipe(fd, ' ' );
		
		// Print barrier
		for (int i = 0; i < 20; i++)
			DEBUG.__pipe(fd, '*');
		
		// Ending newline
		DEBUG.__pipe(fd, '\n');
	}
	
	/**
	 * Prints a very basic debug code with a String Utf pointer.
	 *
	 * @param __a First character.
	 * @param __b Second character.
	 * @param __v UTF String pointer.
	 * @since 2019/09/22
	 */
	public static final void codeUtf(char __a, char __b, int __v)
	{
		// Get the pipe descriptor for standard error, ignore if it fails
		int fd = Assembly.sysCallV(SystemCallIndex.PD_OF_STDERR);
		if (SystemCallError.getError(SystemCallIndex.PD_OF_STDERR) != 0)
			return;
		
		// Pipe characters
		DEBUG.__pipe(fd, __a);
		DEBUG.__pipe(fd, __b);
		DEBUG.__pipe(fd, ' ');
		
		// If there is no string, then print null
		if (__v == 0)
		{
			DEBUG.__pipe(fd, 'n');
			DEBUG.__pipe(fd, 'u');
			DEBUG.__pipe(fd, 'l');
			DEBUG.__pipe(fd, 'l');
		}
		
		// Otherwise decode and print the string out
		else
		{
			// Read string length
			int len = Assembly.memReadJavaShort(__v, 0) & 0xFFFF;
			
			// Print string characters out
			for (int i = 0; i < len; i++)
			{
				// Read character
				char c = (char)(Assembly.memReadByte(__v, 2 + i) & 0xFF);
				
				// Special handling according to input character
				boolean slash = false;
				switch (c)
				{
					case '\t': c = 't'; break;
					case '\r': c = 'r'; break;
					case '\n': c = 'n'; break;
					case '\b': c = 'b'; break;
				}
				
				// Print it out
				if (slash)
					DEBUG.__pipe(fd, '\\');
				DEBUG.__pipe(fd, c);
			}
		}
		
		// Ending newline
		DEBUG.__pipe(fd, '\n');
	}
	
	/**
	 * Prints a debug note.
	 *
	 * @param __fmt The string format, compatible with Java except that it
	 * is very limited in the formats it supports.
	 * @param __args Arguments to the note.
	 * @since 2019/05/26
	 */
	public static final void note(String __fmt, Object... __args)
	{
		// Get the pipe descriptor for standard error, ignore if it fails
		int fd = Assembly.sysCallV(SystemCallIndex.PD_OF_STDERR);
		if (SystemCallError.getError(SystemCallIndex.PD_OF_STDERR) != 0)
			return;
		
		// Debug
		/*DEBUG.code('N', 'f', Assembly.objectToPointer(__fmt));
		DEBUG.code('N', 'a', Assembly.objectToPointer(__args));*/
		
		// Argument pointer
		int argp = 0;
		
		// Print char by char to the console
		boolean percent = false;
		for (int i = 0, n = __fmt.length(); i < n; i++)
		{
			// Read character here
			char c = __fmt.charAt(i);
			
			// Handle percent
			if (percent)
			{
				// Clear flag
				percent = false;
				
				// Plain percent
				if (c == '%')
					DEBUG.__pipe(fd, '%');
				
				// Newline
				else if (c == 'n')
					DEBUG.__pipe(fd, '\n');
				
				// Just treat as string
				else if (argp < __args.length)
				{
					// Get string form of it
					Object av = __args[argp++];
					String sv = (av == null ? "null" : av.toString());
					
					// Pipe through all string characters
					for (int j = 0, q = sv.length(); j < q; j++)
						DEBUG.__pipe(fd, sv.charAt(j));
				}
				
				// Unknown sequence?
				else
					DEBUG.__pipe(fd, '?');
			}
			
			// Flag percent
			else if (c == '%')
				percent = true;
			
			// Plain character
			else
				DEBUG.__pipe(fd, c);
		}
		
		// End with newline sequence
		DEBUG.__pipe(fd, '\n');
	}
	
	/**
	 * Pipes out the given character.
	 *
	 * @param __fd The pipe descriptor.
	 * @param __c The character to pipe.
	 * @since 2019/06/11
	 */
	private static final void __pipe(int __fd, char __c)
	{
		// This uses non-wrapped calls since because this is the supervisor
		// we want to print out the bytes without performing wrapping and
		// virtualization of call IDs
		
		// Single byte sequence
		if (__c <= 0x7F)
		{
			// Forward
			Assembly.sysCallPV(SystemCallIndex.PD_WRITE_BYTE,
				__fd, __c & 0xFF);
		}
		
		// Double byte sequence
		else
		{
			// Forward
			Assembly.sysCallPV(SystemCallIndex.PD_WRITE_BYTE,
				__fd, (__c >>> 6) | 0b1100_0000);
			Assembly.sysCallPV(SystemCallIndex.PD_WRITE_BYTE,
				__fd, (__c & 0b111111));
		}
	}
}

Deleted runt/klib/supervisor/todo/TODO.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 todo;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * This is a class which when constructed indicates that stuff needs to be
 * done.
 *
 * @since 2019/05/25
 */
public class TODO
	extends Error
{
	/**
	 * Initializes the ToDo.
	 *
	 * @since 2019/05/25
	 */
	public TODO()
	{
		this(null);
	}
	
	/**
	 * Initializes the ToDo.
	 *
	 * @param __m The exception message.
	 * @since 2019/11/25
	 */
	public TODO(String __m)
	{
		super(__m);
		
		// Print stack trace
		todo.DEBUG.note("****** TODO HIT! ******");
		this.printStackTrace();
		todo.DEBUG.note("****** TODO HIT! ******");
		
		// Stop now
		Assembly.sysCallPV(SystemCallIndex.FATAL_TODO);
		Assembly.breakpoint();
		Assembly.sysCallPV(SystemCallIndex.EXIT, 1);
	}
}

Deleted runt/klib/supervisor/todo/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the debugging and stuff to be done.
 *
 * @since 2019/05/25
 */

package todo;

Deleted runt/kmid/NAMESPACE.MF.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Kernel MIDlets
X-SquirrelJME-Namespace-Type: midlet
X-SquirrelJME-Namespace-Description: These are applications which are 
 ran like normal applications but are intended to only be executed by 
 the kernel itself.

Deleted runt/kmid/launcher/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: SquirrelJME Launcher (Graphical)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the graphical launcher 
 that SquirrelJME uses to act as a front end interface to running user p
 rograms.
X-SquirrelJME-Depends: midp-lcdui meep-midlet meep-swm
X-SquirrelJME-Error: EP
X-SquirrelJME-UUID: 2ec9b1c4-3adb-4dd0-acfa-48f878dd6cdd
MIDlet-1: SquirrelJME Launcher (Graphical), ,
 cc.squirreljme.runtime.launcher.ui.MidletMain
X-SquirrelJME-NoLauncher: true
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/MidletMain.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412




























































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import java.util.ArrayList;
import java.util.Timer;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteManager;
import javax.microedition.swm.SuiteType;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskManager;
import javax.microedition.swm.TaskStatus;

/**
 * This is the main midlet for the LCDUI based launcher interface.
 *
 * @since 2016/10/11
 */
public class MidletMain
	extends MIDlet
{
	/**
	 * {@squirreljme.property cc.squirreljme.autolaunch=program This specifies
	 * the program that should be auto-launched once the program list has been
	 * processed.}
	 */
	public static final String AUTOLAUNCH_PROPERTY =
		"cc.squirreljme.autolaunch";
	
	/** Command used to exit the launcher and terminate. */
	public static final Command EXIT_COMMAND =
		new Command("Exit", Command.EXIT, 1);
	
	/** The about command. */
	public static final Command ABOUT_COMMAND =
		new Command("About", Command.HELP, 2);
	
	/** Timer used to reschedule things. */
	static final Timer _TIMER =
		new Timer("LauncherRecoverThread");
	
	/** The display that is being used. */
	static volatile Display _MAIN_DISPLAY;
	
	/** The list which contains all of the programs we can run. */
	protected final List programlist =
		new List("SquirrelJME Launcher", Choice.IMPLICIT);
	
	/** The active task. */
	private final __ActiveTask__ _activetask =
		new __ActiveTask__();
	
	/** The programs which are mapped to the list. */
	private volatile __Program__[] _programs;
	
	/** Automatic launch program. */
	private volatile String _autolaunch;
	
	/**
	 * Initializes the launcher.
	 *
	 * @since 2019/04/14
	 */
	{
		// Do not crash if we cannot read properties
		String al = null;
		try
		{
			al = System.getProperty(AUTOLAUNCH_PROPERTY);
		}
		catch (SecurityException e)
		{
		}
		
		this._autolaunch = al;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/11
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
		// This is not used at all
	}
	
	/**
	 * Refreshes the list.
	 *
	 * @since 2018/11/16
	 */
	public void refresh()
	{
		// When a refresh is happening, change the title so that is
		// indicated
		List programlist = this.programlist;
		programlist.setTitle("Loading (Querying Suites)...");
		
		// Used for checking and such
		__ActiveTask__ activetask = this._activetask;
		
		// The list was previously not used
		if (programlist.size() <= 0)
		{
			// Add a message saying what is going on
			programlist.append("Loading available programs...", null);
			programlist.append("This might take awhile!", null);
			programlist.append("UP/DOWN -- Adjust focused item", null);
			programlist.append("FIRE    -- Select item", null);
			programlist.append("The SPACEBAR key is the FIRE key", null);
			
			// Re-flip on this display
			if (_MAIN_DISPLAY.getCurrent() == programlist)
				_MAIN_DISPLAY.setCurrent(programlist);
		}
		
		// Go through all of the available application suites and build the
		// program list
		boolean queried = false;
		int foundcount = 0;
		ArrayList<__Program__> programs = new ArrayList<>();
		for (Suite suite : ManagerFactory.getSuiteManager().getSuites(
			SuiteType.APPLICATION))
		{
			// Hide this on the SquirrelJME launcher?
			if (Boolean.valueOf(suite.getAttributeValue(
				"X-SquirrelJME-NoLauncher")))
				continue;
			
			// Query is done, scan suites
			if (!queried)
			{
				programlist.setTitle("Loading (Scanning Suites)...");
				queried = true;
			}
			
			// Since we need the program name AND the entry point we need
			// to decode the parts that make it up!
			for (int i = 1; i >= 1; i++)
			{
				// No more programs in this suite
				String value = suite.getAttributeValue("MIDlet-" + i);
				if (value == null)
					break;
				
				// There will be two commas and the format is in:
				// title, icon-resource, mainclass
				int fc = value.indexOf(','),
					sc = value.lastIndexOf(',');
				if (fc < 0 || sc < 0)
					continue;
				
				// Split off
				String title = value.substring(0, fc).trim(),
					iconrc = value.substring(fc + 1, sc).trim(),
					main = value.substring(sc + 1).trim();
				
				// Build program
				programs.add(new __Program__(suite, main, title, activetask,
					iconrc));
				
				// Say it was found via the title
				programlist.setTitle(String.format(
					"Loading (%d Found)...", ++foundcount));
			}
		}
		
		// Indicate that the program list is being built
		programlist.setTitle(String.format(
			"Building List (%d Found)...", foundcount));
		
		// Build program array
		__Program__[] arrprogs = programs.<__Program__>toArray(
			new __Program__[programs.size()]);
		
		// Clear the program list
		programlist.deleteAll();
		
		// Build the list in the program order
		for (__Program__ p : arrprogs)
			programlist.append(p.displayName(), p.displayImage());
		
		// Use this list
		this._programs = arrprogs;
		
		// All done so, return the title back
		programlist.setTitle("SquirrelJME Launcher");
		
		// Make sure the program list is showing
		Displayable current = _MAIN_DISPLAY.getCurrent();
		if (current == null || (current instanceof SplashScreen))
			_MAIN_DISPLAY.setCurrent(programlist);
		
		// Automatically launch a program?
		String autolaunch = this._autolaunch;
		if (autolaunch != null)
		{
			this._autolaunch = null;
			
			// Launch it
			System.err.println("Auto-launching " + autolaunch + "...");
			this.__launch(autolaunch);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/16
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// We will need to access our own display to build the list of
		// MIDlets that could actually be ran
		Display disp = Display.getDisplay(this);
		_MAIN_DISPLAY = disp;
		
		// Add commands to the list so things can be done with them
		List programlist = this.programlist;
		programlist.addCommand(EXIT_COMMAND);
		programlist.addCommand(ABOUT_COMMAND);
		
		// Need to handle commands and such
		__CommandHandler__ ch = new __CommandHandler__();
		programlist.setCommandListener(ch);
		
		// Used to ensure the splash screen is visible for at least a second
		long endtime = System.nanoTime() + 1_000_000_000L;
		
		// Refresh the list in another thread
		Thread refresher = new Thread("LauncherRefresh")
			{
				/**
				 * {@inheritDoc}
				 * @since 2019/05/19
				 */
				public final void run()
				{
					MidletMain.this.refresh();
				}
			};
		refresher.start();
		
		// Instead of showing the program list early, just show a splash screen
		// with a handsome Lex and the version information
		SplashScreen spl = new SplashScreen(disp.getWidth(), disp.getHeight());
		if (disp.getCurrent() == null)
			disp.setCurrent(spl);
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __launch(__Program__ __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Indication that something is happening
		this.programlist.setTitle("Launching " + __p.displayname + "...");
		
		// Launch this program
		__p.__launch();
		
		// All done so, return the title back
		this.programlist.setTitle("SquirrelJME Launcher");
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @since 2019/04/14
	 */
	private void __launch(int __p)
	{
		__Program__[] programs = this._programs;
		
		// Do nothing if out of bounds
		if (programs == null || __p < 0 || __p >= programs.length)
			return;
		
		// Launch
		this.__launch(programs[__p]);
	}
	
	/**
	 * Launches the specified program.
	 *
	 * @param __p The program to launch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	private void __launch(String __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// This will use multiple matches, with less priority following
		__Program__ bysj = null,
			bydn = null,
			bysn = null,
			bymc = null;
		
		// Find all the possible matches for a program
		for (__Program__ p : this._programs)
			if (bysj == null && __p.equalsIgnoreCase(p.squirreljmename))
				bysj = p;
			else if (bydn == null && __p.equalsIgnoreCase(p.displayname))
				bydn = p;
			else if (bysn == null && __p.equalsIgnoreCase(p.suitename))
				bysn = p;
			else if (bymc == null && __p.equalsIgnoreCase(p.main))
				bymc = p;
		
		// Use a priority based order
		__Program__ p = (bysj != null ? bysj :
			(bydn != null ? bydn :
			(bysn != null ? bysn :
			(bymc != null ? bymc : null))));
		if (p != null)
		{
			this.__launch(p);
			return;
		}
		
		// If everything fails, just assume it is an index to a program on the
		// program list
		try
		{
			this.__launch(Integer.parseInt(__p));
		}
		catch (NumberFormatException e)
		{
		}
	}
	
	/**
	 * This is the handler for commands.
	 *
	 * @since 2018/11/16
	 */
	private final class __CommandHandler__
		implements CommandListener
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/16
		 */
		@Override
		public final void commandAction(Command __c, Displayable __d)
		{
			// Launching a program?
			if (__c == List.SELECT_COMMAND)
			{
				// If the list is empty then do nothing because it will NPE
				// or out of bounds if the selection is off
				List list = (List)__d;
				int seldx = list.getSelectedIndex();
				if (list.size() <= 0 || seldx < 0)
					return;
				
				// Call other launcher
				MidletMain.this.__launch(seldx);
			}
			
			// Exiting the VM?
			else if (__c == EXIT_COMMAND)
			{
				// Indication that something is happening
				MidletMain.this.programlist.setTitle("Exiting...");
				
				System.exit(0);
			}
			
			// About SquirrelJME
			else if (__c == ABOUT_COMMAND)
			{
			}
		}
	}
}

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/SplashScreen.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
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
191
192
193
194


































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.runtime.launcher.ui;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.lcdui.gfx.AdvancedGraphics;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This is the splash screen for the launcher which always shows.
 *
 * @since 2019/05/19
 */
public final class SplashScreen
	extends Canvas
	implements Runnable
{
	/** The copyright string. */
	public static final String COPYRIGHT =
		"https://squirreljme.cc/\n" +
		"(C) 2013-2019 Stephanie Gawroriski\n" +
		"Licensed under the GPLv3!\nDonate to me on Patreon:\n" +
		"*** https://www.patreon.com/SquirrelJME! ***";
	
	/** The splash image width. */
	public static final int WIDTH =
		240;
	
	/** The splash image height. */
	public static final int HEIGHT =
		320;
	
	/** The image data to draw. */
	volatile int[] _image;
	
	/**
	 * Initializes the splash screen with a precached image.
	 *
	 * @param __sw The screen width.
	 * @param __sh The screen height.
	 * @since 2019/05/19
	 */
	public SplashScreen(int __sw, int __sh)
	{
		// Full-screen mode for the entire image
		this.setFullScreenMode(true);
		
		// Load the launcher image in a background thread so the splash screen
		// can still display the copyright notice
		new Thread(this, "LauncherImageLoader").start();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/19
	 */
	@Override
	public final void paint(Graphics __g)
	{
		// Draw the raw image data, is the fastest
		int[] image = this._image;
		if (image != null)
			__g.drawRGB(image, 0, WIDTH, 0, 0, WIDTH, HEIGHT, false);
		
		// The image is not fully loaded yet, so draw the copyright at least
		else
			SplashScreen.__copyright(__g, true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/29
	 */
	@Override
	public final void run()
	{
		// Image is completely operated with using raw data
		int np = WIDTH * HEIGHT;
		int[] image = new int[np];
		
		// Load splash image onto the data
		try (InputStream in = SplashScreen.class.
			getResourceAsStream("splash.raw"))
		{
			// If it exists, use it
			if (in != null)
			{
				// Input raw pixels
				int nr = WIDTH * HEIGHT * 3;
				byte[] raw = new byte[nr];
				
				// Read in raw data
				for (int read = 0; read < nr;)
				{
					int rc = in.read(raw, read, nr - read);
					
					if (rc < 0)
						break;
					
					read += rc;
				}
				
				// Translate RGB byte pixels to RGB int pixels
				for (int o = 0, i = 0; o < np; o++)
					image[o] = ((raw[i++] & 0xFF) << 16) |
						((raw[i++] & 0xFF) << 8) |
						(raw[i++] & 0xFF);
			}
		}
		catch (IOException e)
		{
		}
		
		// Text will be drawn using the advanced graphics since it can
		// operate on integer buffers directly
		Graphics g = new AdvancedGraphics(image, false, null, WIDTH, HEIGHT,
			WIDTH, 0, 0, 0);
		
		// Draw copyright at the bottom
		SplashScreen.__copyright(g, false);
		
		// Use this image
		this._image = image;
		
		// Perform a repaint before we return so the better looking splash
		// screen is used
		this.repaint();
	}
	
	/**
	 * Draws the copyright text onto the given graphics.
	 *
	 * @param __g The graphics to draw onto.
	 * @param __swip Should "SquirrelJME Loading..." be drawn?
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/29
	 */
	private static final void __copyright(Graphics __g, boolean __swip)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Draw version number
		__g.setFont(Font.getFont("sansserif", 0, 16));
		__g.drawString(SquirrelJME.RUNTIME_VERSION, 238, 48,
			Graphics.RIGHT | Graphics.TOP);
		
		// Draw loading and the SquirrelJME string?
		if (__swip)
		{
			// SquirrelJME String
			__g.drawString("SquirrelJME", 2, 2, Graphics.TOP | Graphics.LEFT);
			
			// Loading...
			__g.drawString("Loading...", 120, 160,
				Graphics.VCENTER | Graphics.HCENTER);
		}
		
		// Set properties
		__g.setFont(Font.getFont("sansserif", 0, 12));
		
		// Draw a black drop-shadow, this makes the lighter front easier to
		// see regardless of what is on the background
		__g.setColor(0x000000);
		__g.drawString(COPYRIGHT, 1, 318,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(COPYRIGHT, 3, 318,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(COPYRIGHT, 2, 317,
			Graphics.BOTTOM | Graphics.LEFT);
		__g.drawString(COPYRIGHT, 2, 319,
			Graphics.BOTTOM | Graphics.LEFT);
		
		// Then draw the frontal white text
		__g.setColor(0xFFFFFF);
		__g.drawString(COPYRIGHT, 2, 318,
			Graphics.BOTTOM | Graphics.LEFT);
	}
}

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/__ActiveTask__.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import javax.microedition.swm.Task;

/**
 * The currently active task.
 *
 * @since 2018/12/10
 */
final class __ActiveTask__
{
	/** The current task. */
	volatile Task _task;
}

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/__Program__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228




































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import cc.squirreljme.runtime.cldc.io.ResourceInputStream;
import java.io.InputStream;
import java.io.IOException;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Image;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * Stores the program information which is mapped to what is displayed.
 *
 * @since 2018/11/16
 */
final class __Program__
{
	/** The suite that is used. */
	protected final Suite suite;
	
	/** The name of the suite. */
	protected final String suitename;
	
	/** The main entry point. */
	protected final String main;
	
	/** The display name of this suite. */
	protected final String displayname;
	
	/** The SquirrelJME name. */
	protected final String squirreljmename;
	
	/** The name of the JAR (SquirrelJME specific). */
	protected final String jarfile;
	
	/** The icon resource to use. */
	protected final String iconrc;
	
	/** The active task. */
	final __ActiveTask__ _activetask;
	
	/** The icon to show for this program. */
	Image _icon;
	
	/**
	 * Initializes the program.
	 *
	 * @param __suite The suite used.
	 * @param __main The main class.
	 * @param __dn The display name of this suite.
	 * @param __at The active task.
	 * @param __iconrc The icon resource used, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/16
	 */
	__Program__(Suite __suite, String __main, String __dn,
		__ActiveTask__ __at, String __iconrc)
		throws NullPointerException
	{
		if (__suite == null || __main == null || __at == null)
			throw new NullPointerException("NARG");
		
		this.suite = __suite;
		this.main = __main;
		this.iconrc = __iconrc;
		
		String suitename = __suite.getName();
		this.suitename = suitename;
		
		String displayname;
		this.displayname = (displayname = (__dn != null ? __dn :
			suitename + " " + __main));
		this._activetask = __at;
		
		// Try to get the internal project name for SquirrelJME, this is used
		// for quick launching
		String sjn = __suite.getAttributeValue(
			"X-SquirrelJME-InternalProjectName");
		if (sjn == null)
		{
			// Only add normal characters
			StringBuilder sb = new StringBuilder();
			for (int i = 0, n = displayname.length(); i < n; i++)
			{
				char c = displayname.charAt(i);
				if (Character.isDigit(c) || Character.isLowerCase(c) ||
					Character.isUpperCase(c))
					sb.append(c);
			}
			
			sjn = sb.toString();
		}
		
		// SquirrelJME special name
		String squirreljmename = sjn.toLowerCase();
		this.squirreljmename = squirreljmename;
		
		// SquirrelJME specific name for the JAR file this belongs to,
		// note that this is only valid within SquirrelJME itself as the
		// property is set from the launcher
		String jarfile = __suite.getAttributeValue("x-squirreljme-jarfile");
		this.jarfile = (jarfile == null ? squirreljmename : jarfile);
	}
	
	/**
	 * The display image for this suite.
	 *
	 * @return The display image.
	 * @since 2018/11/16
	 */
	public final Image displayImage()
	{
		// Image already known?
		Image rv = this._icon;
		if (rv != null)
			return rv;
		
		// No image is here at all
		String iconrc = this.iconrc;
		if (iconrc == null || iconrc.isEmpty())
			return null;
		
		// Load image from JAR resource
		try (InputStream in = ResourceInputStream.open(this.jarfile, iconrc))
		{
			// No resource exists
			if (in == null)
				return null;
			
			// Load image data
			rv = Image.createImage(in);
		}
		
		// Not a valid image, ignore
		catch (IOException e)
		{
			return null;
		}
		
		// Cache and use
		this._icon = rv;
		return rv;
	}
	
	/**
	 * The display name for this suite.
	 *
	 * @return The display name.
	 * @since 2018/11/16
	 */
	public final String displayName()
	{
		return this.displayname;
	}
	
	/**
	 * Launches this program.
	 *
	 * @since 2018/11/16
	 */
	final void __launch()
	{
		// Need these
		Suite suite = this.suite;
		String main = this.main;
		
		// Make it so only a single thing can be launched
		__ActiveTask__ activetask = this._activetask;
		synchronized (activetask)
		{
			// Do not start another task until the current one has finished
			Task oldtask = activetask._task;
			if (oldtask != null)
			{
				TaskStatus status = oldtask.getStatus();
				if (status == TaskStatus.RUNNING ||
					status == TaskStatus.STARTING)
				{
					todo.DEBUG.note("Other task has not finished yet!");
					return;
				}
				
				// Not running, so we can forget it
				activetask._task = null;
			}
			
			// Start the task
			try
			{
				Task task = ManagerFactory.getTaskManager().
					startTask(suite, main);
				activetask._task = task;
			}
			
			// Could not launch so, oh well!
			catch (IllegalArgumentException|IllegalStateException e)
			{
				// Debug to the system console
				e.printStackTrace();
				
				// Then pop up a nasty message!
				String msg = e.getMessage();
				MidletMain._MAIN_DISPLAY.setCurrent(
					new Alert("Oopsie!", (msg == null ? String.format(
						"Could not launch %s:%s.", suite, main): msg),
						null, AlertType.ERROR));
			}
			
			// Setup timer to recover our display on termination
			MidletMain._TIMER.schedule(new __ReControlTask__(
				MidletMain._MAIN_DISPLAY, activetask), 500, 500);
		}
	}
}

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/__ReControlTask__.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.launcher.ui;

import java.util.TimerTask;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskStatus;

/**
 * This is used to regain control of tasks and make it so the launcher is
 * brought back up after it has lost hardware control.
 *
 * @since 2018/12/11
 */
final class __ReControlTask__
	extends TimerTask
{
	/** The display used. */
	protected final Display display;
	
	/** The task information. */
	private final __ActiveTask__ _active;
	
	/**
	 * Initializes the re-control task.
	 *
	 * @param __display The display used.
	 * @param __task The task to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/11
	 */
	__ReControlTask__(Display __display, __ActiveTask__ __task)
		throws NullPointerException
	{
		if (__display == null || __task == null)
			throw new NullPointerException("NARG");
		
		this.display = __display;
		this._active = __task;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/11
	 */
	@Override
	public final void run()
	{
		Display display = this.display;
		__ActiveTask__ active = this._active;
		
		// Need to check the task status
		boolean recover = false;
		synchronized (active)
		{
			Task task = active._task;
			
			// If null, then we should recover because it was cleared
			if (task == null)
				recover = true;
			
			// If the task has stopped for any reason, we recover
			if (!recover)
			{
				TaskStatus status = task.getStatus();
				recover = (status != TaskStatus.RUNNING &&
					status != TaskStatus.STARTING);
			}
			
			// Recover our display?
			if (recover)
			{
				// Note it
				todo.DEBUG.note("Recovering %s...", task);
				
				// Make it current which takes the display over again, we
				// do not need to specify which displayable it was because the
				// display remembers it
				display.setCurrent(display.getCurrent());
				
				// Cancel self since we did it!
				this.cancel();
			}
		}
	}
}

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the LCDUI based launcher interface.
 *
 * @since 2016/10/11
 */

package cc.squirreljme.runtime.launcher.ui;

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/splash.raw.__mime.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 750 splash.raw
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4
W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3
W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3a8v1qLvTvLW/qrzPcMrzZcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3gMjq7ppu/4wA/4wA/4wA75lrjcXj
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4
Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4W8/4Zcz3
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4ZMn0YsbwYsbwWMnxYsbw
WMnxWMnxYsbwYsbwWMnxWMnxYsbwWMnxWMnxWMnxWcv0W8/4W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3
W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3XM/46pt5/4wA/4wA/4wA/4wA/4wA9JVa
as3zZcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4Y8nzYsbwWMnxWMnxWMnxWMnx
Wcv0Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4
W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4ULneO32YG0FQAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3W8/4W8/4
W8/4W8/4W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4
W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4
Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4ksLi/4wA/4wA/4wA/4wA/4wA/4wA/4wA
rrnOW8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YW8/4W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4
W8/4W8/4W8/4W8/4W8/4Zcz3TqDDQZe2W8/4W8/4Zcz3Zcz3TLDUAAAATJ2/
Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4VMHnAw8VOomlZcz3
W8/4Zcz3Zcz3RaHBDygzFDlHFDlHFzlGFzlGFDlHFzlGFzlGFDlHFzlGFDlH
FzlGFzlGFzlGFDlHFDlHFzlGFzlGFDlHFDlHFzlGU6rOW8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3SJa2AggMAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4
W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4m8Lb/4wA/4wA/4wA/4wA/4wA/4wA/4wA
vrO+Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TMWmBIFRm
ZMv2Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Q4upMWqCOomlZcz3
W8/4W8/4Zcz3RaHBSZe3Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4
W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3
Zcz3W8/4W8/4Zcz3Zcz3SarMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPI6rW8/4W8/4W8/4W8/4
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4W8/4W8/4
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3d8nw/o0V/4wA/4wA/4wA/4wA/4wA/4wA
pL7UW8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4W8/4W8/4
Zcz3W8/4Zcz3W8/4W8/4Zcz3RqPDSJW1W8/4Zcz3W8/4W8/4TLDUOIaiOXiS
TK7RW8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3WMnxHkZXSKjJQIekW8/4
Zcz3Zcz3W8/4TZ7AQZm4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
Zcz3Zcz3W8/4Zcz3ZMv1IEpbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3W8/4
W8/4W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz30qul/4wA/4wA/4wA/4wA/4wA7Jpz
asv1Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
NX+ZW8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4
Zcz3W8/4Zcz3Zcz3W8/4Zcz3RqPDSJW1W8/4Zcz3Zcz3Zcz3Va7TP4ShWLPZ
MmuDZcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Q529RI6tS67RQIekW8/4
W8/4Zcz3Zcz3TZ7AQZm4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4
W8/4Zcz3Zcz3W8/4WLPZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3ZMv1Zcv2Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3csry1qig/4wA/4wA/4wA5p+De8ns
W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3W8/4W8/4W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4Zcz3
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3W8/4Zcz3Zcz3TLDUOIaiZcz3
KGR5UbvgW8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3ZMv2JVJlVcLpVKvQQIekZcz3
Zcz3W8/4W8/4RaHBSZe3W8/4W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3Zcz3Zcz3RaDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqW8/4Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4T7bbQIajW8/4W8/4WbbdX8Hp
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3Zcz3W8/4W8/4
W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4dsrumMLce8nsZcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YW8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3RqPDQZe2Zcz3Zcz3W8/4Zcz3Va7TOIaiZcz3
UabJPoGdZcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4S63POnuWZcz3S67ROomlZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4RpGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPI6rZcz3W8/4Zcz3W8/4
W8/4W8/4W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3SJW1Aw8VXbzkVKzRUqjMAAAA
IldqQIekW7rhZcz3Zcz3ZMv2Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3
W8/4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4QYmmAAAAAAAAAAAAAAAAAAAA
NX+ZZcz3Zcz3W8/4W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4
W8/4Zcz3W8/4Zcz3W8/4W8/4TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TP4ShZcz3
ZMr0IEpbYMLrZcz3W8/4W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4W8/4Zcz3MGh/WbXcZcz3VKvQQIekW8/4
Zcz3W8/4Zcz3TZ7ASZe3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAIEpbUrvhYsbwYsbw
YsbwWMnxYsbwYsbwYsbwWMnxWMnxYsbwYsbwYsbwY8jzZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4YsbwWLTaWcvzZcz3Zcz3M26HAAAALGyCGUNSX8HqAw8V
AAAAAAAAFDNAVsTrW8/4U6vPY8n0Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4W8/4Zcz3W8/4W8/4Zcz3Zcz3W8/4
Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3W8/4QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3W8/4Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TOIaiZcz3
Zcz3QZm4QJa1Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W7ngLWF3W8/4Zcz3VKvQQIekW8/4
Zcz3Zcz3W8/4TZ7AQZm4W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3W8/4Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAPpGvZcz3Zcz3W8/4
W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3NnOMCiApMniRW7ngDygzAAAAAAAAAAAARpKxHEJS
AAAAAAAAAAAAP4ShZcz3O4yoWrfdZcz3Zcz3Zcz3Zcz3Zcz3Zcz3V7LXH1Fj
JFBjJFBjH1FjJFBjK15zW8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4YMPsJFBjH1Fj
JFBjJFBjJFBjJFBjX8DpZcz3Zcz3Zcz3RJ+/KFhsKFhsI1lsKFhsKFhsOoml
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Y8n0UKXIPX+bKmd9J1drJFBjJFBjJFBjPpGv
Zcz3Zcz3W8/4Zcz3Y8jyT6LEO32YKWd8J1ZpH1FjJFBjJFBjSZi4W8/4Zcz3
Zcz3Zcz3YsXvTJy+OHaQLWF3H1FjJFBjJFBjH1FjJFBjJFBjH1FjJFBjKFhs
MGd+QIekWLPZZcz3Zcz3Zcz3Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3RqPDQZe2Zcz3Zcz3W8/4W8/4TLDUP4ShW8/4
W8/4YcTuIEpbY8nzZcz3W8/4Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3W8/4W8/4
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3PH+aSqrNZcz3Zcz3S67RQIekZcz3
Zcz3W8/4Zcz3RaHBSZe3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3W8/4Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3
Zcz3W8/4W8/4Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAR5OzW8/4Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3YMLsZcz3Zcz3Zcz3QIWiAAAAAAAACBwlAAAAAAAAAAAAAAAAAggMAggM
AAAAAAAAAAAAES04Y8fxMWmBPpOxZcz3Zcz3W8/4W8/4W8/4W8/4Va3SAAAA
AAAAAAAAAAAAAAAAFTVCW8/4W8/4W8/4W8/4Zcz3Zcz3W8/4X8HqAAAAAAAA
AAAAAAAAAAAAAAAAVMHnW8/4Zcz3Zcz3PpOxAAAAAAAAAAAAAAAAAAAANXKL
W8/4Zcz3Zcz3Zcz3Zcz3XLvjH1BiAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
W8/4Zcz3Zcz3UbrfHkZXAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
W8/4WLPZGj1MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAOISgZMv2Zcz3Zcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3W8/4Zcz3TqDDSJW1W8/4Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3QIWiR6bHZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4W8/4Zcz3Zcz3Zcz3Zcz3Zcz3VsXtIk1eZMr0W8/4Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3W8/4Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4PpKwAAAAAAAAAAAAAAAAAAAAAAAAR5OzZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3W8/4Zcz3Zcz3
W8/4QoqoZcz3Zcv2TqDDDCMsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAATqHDFDNAECs2YMLrZcz3Zcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3YsfwIEpbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3YMPsGz9OAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tW8/4W8/4
X8HqFTVCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAASZe3Zcz3W8/4Zcz3Zcz3O4unAAAAAAAAAAAAAAAAAAAA
O32YZcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4Zcz3
Zcz3Zcz3Zcz3W8/4Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3W8/4U7/lKVtvZcz3Zcz3Zcz3W8/4Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3W8/4W8/4Zcz3Zcz3RpKxSpm6Zcz3Zcz3Zcz3VKvQQIekW8/4
Zcz3Zcz3Zcz3TZ7ASZe3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3W8/4
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAPoGdZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4W8/4Zcz3
XLzkK190W8/4QIWiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAABxkgAAAAAAAAOYijZcz3Zcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
W8/4Zcz3W8/4Zcz3Q529AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3RpKxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
QoqoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAFDlHY8n0Zcz3W8/4Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3W8/4Va7TP4ShW8/4
Zcz3Zcz3Zcz3NHCIV7LXZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Y8jzIEpbWMjwZcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAABRQbRpKxWLLYW7ng
W7ngW7ngW7ngW7ngW7nhYcTuW8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
TJ2+K190Va3SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAACBwlX8DpZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3M22FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3K15zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Zcz3
IElaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAWLTaW8/4Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3
Zcz3W8/4Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3W8/4Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3Zcz3TbHVN3WPZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqHEQYimZcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3a8vwZcz3Zcz3R5OzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAJlVoTZ7AZMv1Zcz3a8vwZcz3Zcz3Zcz3Zcz3
PoKeK15zOHaQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQoqoZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3H0hYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPoKf
Zcz3Zcz3DSs2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARI6tZcz3Y8jz
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUKTHZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3a8vwZcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3Zcz3Va7TQ4Sda8vw
Zcz3Zcz3Zcz3Zcz3JFpuXb3lZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3KVpuYrzeZcz3Zcz3W8/4Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3W8/4Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3UKXIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANXCJY8n0Zcz3Zcz3Zcz3a8vwZcz3
K190LVxuIElaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIUtdZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3FDNAAAAAAAAAAAAAAAAAAAAAFDNAQ4yqSpq7Spq7Va/U
Zcz3ZMv2AAAAAAAAAAAAAAAAAAAAAAAAGTxKRY6tSpq7Spq7WLLYZcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAHUNTM22GOG+ENHCIOG+EMmuDDCMsAAAA
AAAAAAAAAAAAAAAAAAAATqHDa8vwZcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3W8/4
a8vwZcz3Zcz3Zcz3Zcz3Zcz3TqDDTJSwa8vwZcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3a8vwZcz3TqDDQomnZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3a8vwZcz3W6/PNnONZcz3Zcz3Zcz3Zcz3Zcz3VKvQRYafZcz3
Zcz3Zcz3Zcz3Up67SZe3Zcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3a8vwZcz3
Zcz3Zcz3Zcz3a8vwY73fBA8UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARpGxa8vwZcz3Zcz3Zcz3a8vw
H0hYKVtvCBgfAAAAAAAAAAAAAAAAAAAACRwjOnOJO3yXP3uTO3yXO3yXMmV5
Aw8VAAAAAAAAAAAAAAAAAAAAAAAAAAAAJlVoZcz3Zcz3Zcz3a8vwVa3SAAAA
AAAAAAAAAAAAAAAAFTVCa8vwa8vwZcz3a8vwa8vwa8vwa8vwZcDkAAAAAAAA
AAAAAAAAAAAAAAAAY73gZcz3a8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAAOXGH
a8vwZcz3a8vwa8vwEi87AAAAAAAAAAAAAAAAAAAAVaTCa8vwa8vwZcz3a8vw
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWavLa8vwa8vwa8vwa8vwa8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAAQomna8vwZcz3Zcz3Zcz3Zcz3Zcz3Xr/nCBwl
AAAAAAAAAAAAAAAAAAAATqHDa8vwZcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32Ya8vwa8vwZcz3a8vwZcz3a8vwa8vwa8vwZcz3Zcz3a8vwa8vwZcz3Zcz3
a8vwa8vwZcz3Zcz3a8vwa8vwTqDDSJW1Zcz3a8vwa8vwa8vwVa7TP4ShZcz3
a8vwZcz3Zcz3Zcz3Y8jzI0pZYcXvZcz3Zcz3a8vwa8vwZcz3Zcz3a8vwa8vw
a8vwZcz3Zcz3a8vwZcz3OXGHV7HWa8vwa8vwZcz3a8vwZcz3VKvQRYafa8vw
a8vwZcz3Zcz3TZ7AJFFkOG+EOG+ENHCINHCINHCIOG+ENHCINHCINHCIOG+E
NHCIOG+EOG+ENHCINHCIOG+ENHCIOG+ENHCIYcTtZcz3a8vwZcz3a8vwZcz3
Zcz3a8vwa8vwZcz3Zcz3OnuWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAES04Ysfwa8vwZcz3Zcz3Zcz3
GDRCECs2AAAAAAAAAAAAAAAAAAAAAAAAVa3SZcz3Zcz3Zcz3a8vwZcz3b8n1
Spm6AAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4Sda8vwZcz3a8vwb8n1WqzMAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3ab7oAAAAAAAA
AAAAAAAAAAAAAAAAXr7ma8vwZcz3Zcz3SpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3a8vwZcz3Zcz3FC85AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3Zcz3
Zcz3bsfzAAAAAAAAAAAAAAAAAAAAAAAAYrPaZcz3Zcz3b8n1Zcz3Zcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAV7HXZcz3Zcz3Zcz3Zcz3Z8PnUZy5Kl1yAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3a8vwa8vwQYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3
Zcz3Zcz3Zcz3a8vwZcz3Zcz3TqDDSJW1a8vwZcz3Zcz3Zcz3Va7TP4Sha8vw
Zcz3Zcz3Zcz3a8vwa8vwRpGwT5q2a8vwa8vwZcz3Zcz3a8vwb8n1Zcz3Zcz3
Zcz3a8vwZcz3Zcz3Xb3mKVtvZcz3Zcz3Zcz3a8vwZcz3a8vwVKvQQIekZcz3
Zcz3a8vwZcz3Up67RYehW7ngW7ngYLjZW7ngW7ngW7ngYLjZW7ngW7ngW7ng
YLjZW7ngW7ngW7ngW7ngW7ngYLjZW7ngW7ngZMr0Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3YMLsH0hYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVKvQZcz3a8vwZcz3Zcz3
ESo0AAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTuZcz3Zcz3Zcz3Zcz3Zcz3Zcz3
YcXvAAAAAAAAAAAAAAAAAAAAAAAAAAAAUabJa8vwZcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3a8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3b8n1Zcz3b8n1Ei87AAAAAAAAAAAAAAAAAAAAVa7TZcz3a8vwZcz3Zcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXcZcz3Zcz3Zcz3Zcz3b8n1YcTt
AAAAAAAAAAAAAAAAAAAAAAAAWLLYZcz3asntVa7TO3yXCBwlAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3b8n1b8n1Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3TqDDSJW1Zcz3Zcz3Zcz3a8vwWq3NP4ShZcz3
Zcz3a8vwZcz3Zcz3Zcz3YMLrI09hZMr1Zcz3Zcz3Zcz3Zcz3b8n1Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3QIekVKLAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3Zcz3Zcz3TZ7ASZe4Zcz3b8n1b8n1Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3
Zcz3Zcz3Zcz3Zcz3b8n1Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3dMnvXbzkKVpuAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASZe3a8vwZcz3Zcz3Zcz3
FDNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTua8vwb8n1Zcz3Zcz3Zcz3a8vw
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAFDNAY8fxZcz3Zcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFTVCZcz3dMnvZcz3Zcz3Zcz3b8n1Zcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3FC85AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3Zcz3
Zcz3ZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPaZcz3Zcz3Zcz3Zcz3Zcz3asHr
AAAAAAAAAAAAAAAAAAAAAAAATJ2+Q4upGTxKAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAATqHDZcz3Zcz3Zcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwb8n1Zcz3Zcz3dMnvZcz3
Zcz3a8vwZcz3Zcz3Zcz3Zcz3U5+9SJW1b8n1Zcz3Zcz3Zcz3Va7TP4ShZcz3
Zcz3Zcz3b8n1Zcz3Zcz3Zcz3PH6aU6nNZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
Zcz3Zcz3Zcz3YsXvIEpbbcXxZcz3Zcz3Zcz3Zcz3Zcz3Zcz3VKvQQIekZcz3
Zcz3a8vwZcz3TZ7ASZe4Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3b8n1
Zcz3Zcz3a8vwa8vwZcz3Zcz3Zcz3b8n1a8vwZcz3Zcz3a8vwZcz3a8vwZcz3
a8vwdMnvdMnva8vwZcz3b8n1a8vwacjtUabJOXiTLl1wJFBjKk9fKk9fJlBg
JFBjJlBgDCMsAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3b8n1a8vwZcz3
HkVVAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTua8vwZcz3a8vwZcz3b8n1Zcz3
Y8nzAAAAAAAAAAAAAAAAAAAAAAAARomjb8n1W7jfZcz3Zcz3a8vwVa3SAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3a8vwX8HqAAAAAAAA
AAAAAAAAAAAAAAAAY73gZcz3Zcz3dMnvSpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3a8vwZcz3b8n1Fi45AAAAAAAAAAAAAAAAAAAAWq3Nb8n1a8vwZcz3Zcz3
Zcz3asnuAAAAAAAAAAAAAAAAAAAAAAAAZrPVZcz3a8vwa8vwa8vwa8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAMmB2VKG/Y8jyZcz3a8vwZcz3QYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3b8n1Zcz3b8n1dMnvZcz3b8n1a8vwZcz3Zcz3Zcz3dMnva8vw
Zcz3a8vwa8vwa8vwa8vwZcz3U5+9SJW1b8n1a8vwb8n1b8n1XqvRP4ShdMnv
Zcz3Zcz3b8n1a8vwZcz3Zcz3W7jfMWN2a8vwZcz3a8vwa8vwa8vwa8vwb8n1
dMnva8vwa8vwSpi5R5Oza8vwa8vwZcz3a8vwZcz3a8vwa8vwWavKRYafZcz3
Zcz3b8n1b8n1TZ7ASZe4Zcz3a8vwa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3
a8vwZcz3b8n1a8vwZcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3a8vwZcz3Zcz3Zcz3
Zcz3Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3a8vwdMnvZcz3a8vwZcz3Zcz3Zcz3
Zcz3b8n1a8PuKlxxAAAAAAAAAAAAAAAAAAAAAAAAQ4yqdMnva8vwZcz3a8vw
LWF3AAAAAAAAAAAAAAAAAAAAAAAAAAAAa8HsZcz3a8vwb8n1Zcz3Zcz3a8vw
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAVa7TZMr1QH6Wa8vwZcz3b8n1XarQAAAA
AAAAAAAAAAAAAAAAFTVCZcz3dMnvdMnvdMnva8vwa8vwZcz3ZcDkAAAAAAAA
AAAAAAAAAAAAAAAAXr7ma8vwa8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAAOXGH
a8vwZcz3a8vwZcz3Ei87AAAAAAAAAAAAAAAAAAAAVa7Ta8vwZcz3dMnvZcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXca8vwZcz3Zcz3Zcz3Zcz3ZsPm
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
HkVVRpGwXr7mZcz3b8n1a8vwa8vwb8n1a8vwQYmmAAAAAAAAAAAAAAAAAAAA
QXuXdMnva8vwa8vwa8vwa8vwZcz3Zcz3Zcz3Zcz3a8vwa8vwZcz3Zcz3b8n1
b8n1Zcz3Zcz3Zcz3Zcz3b8n1TqDDTJSwa8vwb8n1Zcz3Zcz3Wq3NSYKcZcz3
Zcz3a8vwa8vwZcz3b8n1dMnvZcz3MGd+Wrfda8vwZcz3Zcz3b8n1Zcz3a8vw
Zcz3Zcz3bsfzKU5eYMLrZcz3Zcz3dMnvZcz3dMnvZcz3Zcz3XKnOQIeka8vw
Zcz3a8vwa8vwWZy6VJWya8vwZcz3b8n1Zcz3a8vwb8n1a8vwZcz3a8vwa8vw
Zcz3Zcz3Zcz3Zcz3a8vwa8vwa8vwZcz3a8vwb8n1b8n1Zcz3b8n1dMnvZcz3
Zcz3Zcz3b8n1Zcz3Zcz3Zcz3b8n1b8n1Zcz3Zcz3Zcz3Zcz3Zcz3a8vwa8vw
Zcz3a8vwa8vwRY+uAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3Zcz3Zcz3dMnv
Q4upAAAAAAAAAAAAAAAAAAAAAAAAAAAAYcTuZcz3Zcz3dMnvZcz3b8n1a8vw
acjsAAAAAAAAAAAAAAAAAAAAAAAAYLfZVJu+MWqCdMnvZcz3Zcz3XarQAAAA
AAAAAAAAAAAAAAAAFzVAZcz3Zcz3Zcz3Zcz3Zcz3Zcz3b8n1br7jAAAAAAAA
AAAAAAAAAAAAAAAAXr7mb8n1Zcz3Zcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
Zcz3Zcz3Zcz3Zcz3Ei87AAAAAAAAAAAAAAAAAAAAVa7TZcz3Zcz3Zcz3b8n1
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAWbXca8vwZcz3Zcz3Zcz3Zcz3ZsPm
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABRQbOm6HWKnJ
ZMv1Zcz3a8vwZcz3b8n1b8n1Zcz3b8n1a8vwQYmmAAAAAAAAAAAAAAAAAAAA
O32YZcz3Zcz3b8n1Zcz3Zcz3dMnva8vwZcz3Zcz3Zcz3Zcz3Zcz3Zcz3Zcz3
b8n1Zcz3Zcz3Zcz3Zcz3b8n1TqDDSJW1Zcz3a8vwa8vwZcz3Va7TP4Sha8vw
Zcz3Zcz3b8n1a8vwZcz3a8vwZcz3U6rOQnyYb8n1Zcz3Zcz3a8vwZcz3Zcz3
b8n1Zcz3UqfLQYGZdMnvb8n1Zcz3Zcz3Zcz3a8vwZcz3Zcz3WavKR4Wjb8n1
Zcz3Zcz3Zcz3TZ7ASZe4Zcz3Zcz3Zcz3b8n1a8vwZcz3Zcz3Zcz3b8n1Zcz3
a8vwa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3Zcz3a8vwa8vwZcz3Zcz3dMnvZcz3
a8vwa8vwZcz3b8n1Zcz3a8vwa8vwZcz3Zcz3a8vwb8n1Zcz3a8vwb8n1Zcz3
a8vwZcz3Zcz3S5GsAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3a8vwa8vwZcz3
bLvfAw8VAAAAAAAAAAAAAAAAAAAAAAAAb8Hmb8n1a8vwZcz3a8vwa8vwb8n1
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAVq/VFjdEPW+FZcz3a8vwa8vwWqzMAAAA
AAAAAAAAAAAAAAAAFTVCZcz3Zcz3Zcz3dMnva8vwdMnvZcz3X8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3a8vwUY6qAAAAAAAAAAAAAAAAAAAAOXGH
dMnva8vwa8vwa8vwFC85AAAAAAAAAAAAAAAAAAAAVa7TdMnvZcz3dMnva8vw
Zcz3ZMr1AAAAAAAAAAAAAAAAAAAAAAAAXrTWZcz3a8vwdMnva8vwa8vwasHr
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ1drT5m1Z8Pna8vwZcz3
Zcz3a8vwZcz3a8vwa8vwZcz3a8vwa8vwb8n1RoihAAAAAAAAAAAAAAAAAAAA
O32YdMnvZcz3a8vwZ8PnX7XXZcz3Zcz3a8vwa8vwb8n1a8vwZcz3Zcz3Zcz3
a8vwa8vwdMnvdMnvZcz3a8vwWp68TJSwa8vwZcz3Zcz3Zcz3Va7TQ4Sdb8n1
a8vwZcz3a8vwZcz3Zcz3b8n1a8vwbsj0KFNkX8HqdMnva8vwZcz3a8vwa8vw
a8vwZcz3LmR7WrjfZcz3a8vwZcz3a8vwZcz3b8n1dMnvZcz3XKnOQIeka8vw
Zcz3Zcz3Zcz3TZ7ASZe4a8vwa8vwdMnvZcz3Zcz3dMnvdMnvZcz3a8vwa8vw
Zcz3Zcz3Zcz3b8n1dMnva8vwZcz3b8n1Zcz3Zcz3Zcz3a8vwZcz3Zcz3a8vw
Zcz3a8vwa8vwdMnvZcz3Zcz3a8vwZcz3b8n1a8vwdMnvZcz3a8vwb8n1Zcz3
a8vwdMnvZcz3SpGsAAAAAAAAAAAAAAAAAAAAAAAATomkb8n1Zcz3Zcz3X8Hp
asjtOnqVAAAAAAAAAAAAAAAAAAAAAAAAZ8PnZcz3a8vwb8n1Zcz3a8vwZcz3
Y8nzAAAAAAAAAAAAAAAAAAAAAAAAGDZCAAAANHCIZcz3Zcz3Zcz3Va3SAAAA
AAAAAAAAAAAAAAAAFzVAa8vwa8vwZcz3Zcz3Zcz3a8vwZcz3ab7oAAAAAAAA
AAAAAAAAAAAAAAAAY73gdMnvb8n1Zcz3SpCrAAAAAAAAAAAAAAAAAAAANXKL
Zcz3b8n1Zcz3b8n1Ei87AAAAAAAAAAAAAAAAAAAAVa7Tb8n1Zcz3Zcz3b8n1
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPab8n1Zcz3b8n1Zcz3Zcz3YcTt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAFjM+PoGdZK/QZcz3b8n1Zcz3b8n1dMnv
b8n1b8n1Zcz3Zcz3a8vwZcz3Zcz3a8vwZcz3SIelAAAAAAAAAAAAAAAAAAAA
O32YdMnvZcz3Zcz3WLTaOnuVa8vwZcz3Zcz3a8vwb8n1a8vwa8vwa8vwZcz3
b8n1Zcz3Zcz3a8vwZcz3Zcz3TqDCSJW1b8n1dMnvdMnva8vwVa7TQ4SdZcz3
a8vwZcz3a8vwZcz3Zcz3b8n1a8vwZcz3UJq3RpGwZcz3dMnvZcz3Zcz3Zcz3
a8vwXrTVOml+Zcz3Zcz3Zcz3b8n1a8vwa8vwZcz3a8vwa8vwWavKQIekdMnv
a8vwa8vwa8vwWZy6SZe4b8n1Zcz3a8vwa8vwZcz3Zcz3dMnvZcz3Zcz3b8n1
b8n1Zcz3a8vwZcz3b8n1dMnva8vwa8vwa8vwa8vwZcz3a8vwZcz3Zcz3Zcz3
a8vwZcz3Zcz3Zcz3dMnva8vwZcz3dMnva8vwZcz3Zcz3dMnvZcz3a8vwb8n1
b8n1Zcz3a8vwO32YAAAAAAAAAAAAAAAAAAAAAAAAQ4yqa8vwdMnva8vwYLjZ
S4urZ7PVAAAAAAAAAAAAAAAAAAAAAAAAYcTudMnvZcz3acjsaMXpZcz3dMnv
dMnvXr/nUI6qGDpIAAAAAAAAAAAAAAAAAAAANm2CdMnvdMnva8vwWqzMAAAA
AAAAAAAAAAAAAAAAGDRCZcz3b8n1Zcz3a8vwa8vwZcz3a8vwX8HqAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3a8vwa8vwTY6vAAAAAAAAAAAAAAAAAAAAOXGH
a8vwa8vwdMnva8vwFC85AAAAAAAAAAAAAAAAAAAAWq3Na8vwZcz3a8vwa8vw
b8n1asnuAAAAAAAAAAAAAAAAAAAAAAAAXrTWZcz3Zcz3a8vwdMnva8vwYcTt
AAAAAAAAAAAAAAAAAAAAAAAASZa2Y8jzZcz3Zcz3a8vwZcz3a8vwa8vwZcz3
a8vwa8vwdMnva8vwZcz3dMnva8vwZcz3dMnvRoihAAAAAAAAAAAAAAAAAAAA
O32YZcz3a8vwdMnvZrLUPXmQb8n1b8n1dMnvZcz3a8vwb8n1b8n1b8n1dMnv
Zcz3a8vwZcz3b8n1a8vwZcz3Vpe0VJWya8vwZcz3Zcz3b8n1YqvMP4ShdMnv
b8n1a8vwZcz3dMnva8vwa8vwZcz3a8vwYsfxIk1ecsXqZcz3dMnvdMnvb8n1
b8n1QXmVVKzRa8vwa8vwdMnva8vwZcz3Zcz3a8vwb8n1Zcz3VKvQRYafZcz3
b8n1b8n1b8n1TZ7AVJWyZcz3a8vwZcz3Zcz3Zcz3a8vwZcz3a8vwdMnva8vw
a8vwdMnvZcz3Zcz3a8vwZcz3Zcz3b8n1Zcz3b8n1a8vwb8n1a8vwdMnvdMnv
dMnva8vwZcz3Zcz3Z7vlZK/QV7LXV7LXXLHRXLHRV7LXYK/WV7LXXLHRXLHR
V7LXYK/WSpCrBA4UAAAAAAAAAAAAAAAAAAAAAAAAQ4yqZcz3b8n1Zcz3YcTt
AggMWKnIAAAAAAAAAAAAAAAAAAAAAAAAYcTudMnvZcz3bsjzNmN2HUNTNnON
T5O0XLvia8vwZ8PnQXqWAAAAAAAAAAAAAAAANHCIZcz3b8n1b8n1Va3SAAAA
AAAAAAAAAAAAAAAACBggZ8TodMnvb8n1b8n1dMnvb8n1a8vwVrDVAAAAAAAA
AAAAAAAAAAAAAAAAXr7mZcz3Zcz3a8vwUY6qAAAAAAAAAAAAAAAAAAAAO3CK
Zcz3Zcz3Zcz3Zcz3FS46AAAAAAAAAAAAAAAAAAAAVa7TdMnvb8n1Zcz3a8vw
b8n1bsfzAAAAAAAAAAAAAAAAAAAAAAAAXrTWa8vwZcz3Zcz3Zcz3dMnvYcTt
AAAAAAAAAAAAAAAAAAAAAAAAV6jHa8vwZcz3b8n1a8vwb8n1Zcz3a8vwZcz3
Zcz3Zcz3b8n1dMnvZcz3b8n1b8n1Zcz3Zcz3SIelAAAAAAAAAAAAAAAAAAAA
O32Yb8n1Zcz3Zcz3ZbffNXCJa8vwZcz3a8vwZcz3a8vwa8vwa8vwZcz3dMnv
Zcz3dMnva8vwb8n1a8vwZcz3RpKxTZ/Ba8vwZcz3a8vwZcz3XqvRP4Sha8vw
b8n1dMnvZcz3Zcz3Zcz3a8vwb8n1dMnvdMnvQoqoTqHDZcz3Zcz3a8vwa8vw
ZcDjJ1Fhbsj0b8n1Zcz3Zcz3dMnva8vwZcz3a8vwb8n1dMnvXKnOQIeka8vw
a8vwa8vwZcz3TZ7ATpayb8n1dMnvb8n1dMnvZcz3a8vwb8n1Zcz3Zcz3Zcz3
Zcz3dMnva8vwZcz3a8vwdMnva8vwdMnva8vwb8n1a8vwb8n1Zcz3Zcz3Zcz3
Zcz3b8n1dMnvZcz3RZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUpGtZcz3a8vwdMnva8vw
JlVoEi87AAAAAAAAAAAAAAAAAAAAAAAAZbjgZcz3dMnvZcz3W7ngBA8UAAAA
AAAAAAAAOWyFXb3la8vwSYKbAAAAAAAAAAAAOHaQa8vwa8vwa8vwWqzMAAAA
AAAAAAAAAAAAAAAAAAAAKFhsSJW1T5m1T5m1Spq7T5m1TI2tHT9MAAAAAAAA
AAAAAAAAAAAAAAAAbLvfdMnvdMnvb8n1RpGwAAAAAAAAAAAAAAAAAAAANXKL
a8vwZcz3dMnvdMnvFC85AAAAAAAAAAAAAAAAAAAAYqzMZcz3a8vwdMnvZcz3
a8vwZMr1AAAAAAAAAAAAAAAAAAAAAAAAYrPab8n1a8vwZcz3dMnvZcz3YcXv
AAAAAAAAAAAAAAAAAAAAAAAAKVFlUZW3T5m1T5m1Spq7Spq7Vpe1Upe5Vpe1
Vpe1T5m1Spq7Spq7Spq7Yrvda8vwa8vwb8n1RoihAAAAAAAAAAAAAAAAAAAA
RXuTa8vwZcz3Zcz3ZcHkLl5xZcz3Zcz3b8n1dMnvb8n1b8n1Zcz3b8n1Zcz3
b8n1Zcz3Zcz3a8vwb8n1Zcz3O32YYKjJZcz3dMnvZcz3Zcz3Wq3NRoKgb8n1
Zcz3Zcz3b8n1dMnvdMnvb8n1Zcz3Zcz3Zcz3ZL7gLlVnZcv2Zcz3Zcz3Zcz3
RY6tVJu+a8vwa8vwZcz3b8n1Zcz3b8n1dMnvZcz3a8vwZcz3VKvQS4WfZcz3
Zcz3Zcz3dMnvVZy/UZW2Zcz3Zcz3a8vwZcz3dMnvZcz3a8vwZcz3dMnvdMnv
Zcz3Zcz3b8n1a8vwZcz3Zcz3b8n1Zcz3Zcz3Zcz3Zcz3a8vwZcz3Zcz3dMnv
Zcz3Zcz3dMnvdMnvRZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWp28b8n1Zcz3b8n1dMnv
T4yoAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ01fRI6tUY6qWKHFb8n1Q4SdAAAA
AAAAAAAAAAAAEi87W7jfbcXxIk5gAAAAAAAARoOhZcz3b8n1b8n1XbHSAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAYMPsZcz3Zcz3b8n1UY6qAAAAAAAAAAAAAAAAAAAAO3CK
dMnvZcz3Zcz3Zcz3Fi45AAAAAAAAAAAAAAAAAAAAXqzRZcz3Zcz3dMnvZcz3
dMnvbsfzAAAAAAAAAAAAAAAAAAAAAAAAXrTWb8n1a8vwZcz3Zcz3dMnva8vw
CiApAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUabKb8n1a8vwZcz3SIelAAAAAAAAAAAAAAAAAAAA
O32Ya8vwdMnvb8n1b8n1JkhXcsbra8vwZcz3Zcz3Zcz3dMnvZcz3Zcz3a8vw
Zcz3dMnvZcz3a8vwdMnva8vwJFBjbb3hZcz3dMnvdMnvb8n1Wq3NP4ShdMnv
b8n1a8vwZcz3Zcz3a8vwdMnvdMnvb8n1b8n1Zcz3QXWMY6zNdMnvdMnvccXq
I0pZbMTvZcz3dMnva8vwb8n1a8vwZcz3dMnvb8n1b8n1a8vwVKvQS4Wfb8n1
dMnvZcz3a8vwUp67VJWyb8n1b8n1Zcz3Zcz3dMnvZcz3dMnvZcz3Zcz3dMnv
dMnva8vwb8n1dMnvZcz3Zcz3dMnva8vwdMnva8vwb8n1dMnvdMnvZcz3a8vw
dMnvdMnvZcz3Zcz3UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXLvja8vwb8n1a8vwZcz3
Xr7mBA8UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx8nZcDkZrniAggM
AAAAAAAAAAAAAAAALFlra8rvVZazAAAAAAAAU5+9dMnva8vwa8vwaL3mAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAFjM+bsj0dMnvdMnva8vwRpGwAAAAAAAAAAAAAAAAAAAAOXGH
Zcz3b8n1a8vwdMnvEi87AAAAAAAAAAAAAAAAAAAAWq3NdMnvb8n1Zcz3dMnv
Zcz3asnuAAAAAAAAAAAAAAAAAAAAAAAAZrPVa8vwb8n1b8n1dMnvZcz3b8n1
LllvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAXqTDZcz3Zcz3dMnvRoihAAAAAAAAAAAAAAAAAAAA
QXuXb8n1Zcz3Zcz3a8vwPoGdVKzRb8n1b8n1dMnvdMnvZcz3dMnvdMnvdMnv
dMnvZcz3dMnvb8n1Zcz3ZLbeL1ZoZcz3dMnvZcz3Zcz3a8vwVa7TSYKcZcz3
a8vwZcz3dMnvb8n1dMnvZcz3Zcz3a8vwa8vwb8n1WLLYNXCJZcz3Zcz3TZ/B
S4ura8vwdMnvZcz3Zcz3a8vwZcz3b8n1Zcz3Zcz3a8vwdMnvWavKQIeka8vw
Zcz3dMnvb8n1VZy/SZe4a8vwa8vwdMnvb8n1Zcz3dMnvZcz3b8n1dMnvZcz3
Zcz3b8n1Zcz3Zcz3dMnva8vwZcz3b8n1Zcz3b8n1a8vwZcz3Zcz3b8n1b8n1
Zcz3dMnvdMnvZcz3UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOWd7Zcz3a8vwb8n1b8n1dMnv
b8n1SoOdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASY2odMnvNmiA
AAAAAAAAAAAAAAAAAAAAXLriW7jfAAAAAAAAWrfddMnvb8n1a8vwZcz3K1Fi
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAPXmQZcz3Zcz3b8n1dMnvUY6qAAAAAAAAAAAAAAAAAAAAPnCG
a8vwb8n1Zcz3b8n1FS46AAAAAAAAAAAAAAAAAAAAVa7Ta8vwdMnvZcz3dMnv
b8n1asnuAAAAAAAAAAAAAAAAAAAAAAAAYrPaa8vwdMnvZcz3b8n1a8vwa8vw
VZWyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAXqTDdMnvZcz3b8n1RoihAAAAAAAAAAAAAAAAAAAA
RXuTdMnvdMnvb8n1dMnvZ7PWM2Z6a8rvZcz3Zcz3dMnvZcz3Zcz3Zcz3Zcz3
b8n1Zcz3b8n1dMnva8vwPH6aWZ27Zcz3b8n1b8n1b8n1dMnvVa7TSYKcb8n1
dMnvZcz3a8vwZcz3dMnvZcz3dMnvb8n1a8vwdMnvb8n1M11warjbb8n1Kldp
bLzgZcz3dMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1b8n1XKnOR4WjdMnv
Zcz3a8vwa8vwUp67UZW2b8n1Zcz3a8vwdMnvZcz3b8n1a8vwZcz3dMnvb8n1
a8vwdMnvdMnvZcz3dMnvdMnva8vwdMnva8vwb8n1b8n1b8n1a8vwa8vwZcz3
b8n1Zcz3b8n1dMnvRZCvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjA9XLzkdMnvb8n1a8vwa8vwZcz3
a8vwa8LsIkhXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHj5OZMr1Up+8
AAAAAAAAAAAAAAAAAAAAXaPCbcXwAAAAAggMccTpZcz3a8vwb8n1b8n1UKTH
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAABA8UY7Tcb8n1dMnva8vwZcz3RpGwAAAAAAAAAAAAAAAAAAAANXKL
b8n1a8vwdMnva8vwFi45AAAAAAAAAAAAAAAAAAAAYqzMb8n1b8n1dMnvZcz3
a8vwc8ftAAAAAAAAAAAAAAAAAAAAAAAAXrTWb8n1Zcz3dMnva8vwb8n1dMnv
Y8jyJ1drAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAUabKb8n1dMnva8vwSIelAAAAAAAAAAAAAAAAAAAA
O32YZcz3a8vwa8vwZcz3Zcz3SIWkTY+vdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvdMnva8vwZcz3WaPHNmJ1ZMv1b8n1dMnvdMnva8vwb8n1YqvMP4Sha8vw
Zcz3b8n1b8n1b8n1Zcz3dMnvZcz3a8vwb8n1Zcz3a8vwUKXIQIajWqzMQ3iQ
Zcz3dMnvZcz3Zcz3a8vwZcz3Zcz3a8vwZcz3Zcz3Zcz3a8vwWavKRYafZcz3
dMnvb8n1dMnvVZy/Tpaya8vwdMnvdMnvZcz3dMnva8vwdMnvdMnva8vwa8vw
dMnvb8n1b8n1dMnvZcz3Zcz3b8n1Zcz3dMnva8vwa8vwa8vwb8n1dMnvdMnv
dMnvZcz3b8n1b8n1UI6qAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAKVRlabfZb8n1dMnvdMnvb8n1dMnvb8n1
a8vwdMnvYrPbEicxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZrHTYrvd
AAAAAAAAAAAAAAAAAAAAT5i0a8vwDB8oGDpIWKLGb8Dka8vwdMnvdMnvb8n1
TIysAggMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAADR8nVKLAdMnvZcz3dMnvdMnvdMnvSpCrAAAAAAAAAAAAAAAAAAAAOXGH
b8n1b8n1dMnvZcz3FS46AAAAAAAAAAAAAAAAAAAAWq3NZcz3Zcz3dMnvb8n1
b8n1bsfzAAAAAAAAAAAAAAAAAAAAAAAAZrPVdMnvZcz3dMnva8vwZcz3dMnv
dMnvbLzfM11wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAVqbEZcz3dMnvdMnvTIehAAAAAAAAAAAAAAAAAAAA
RXuTb8n1dMnvdMnvdMnvdMnvasjtO32YPH+aX8HqZcz3Zcz3a8vwb8n1Zcz3
Zcz3b8n1bMTvUY+rMV91b8Dka8vwZcz3a8vwdMnva8vwZcz3YqvMRoKgdMnv
dMnva8vwdMnvdMnvb8n1b8n1dMnva8vwdMnvdMnvdMnvc8fsJ01fLWJ5YbHZ
b8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1XKnOS4WfZcz3
dMnvb8n1a8vwVZy/UpGtYsbwYsbwcMPoa8PucMPoYsbwYsbwa8PucMPoa8Pu
aMXpYsbwaMXpcMPocMPocMPocMPoa8PucMPocMPocsbrdMnvb8n1b8n1b8n1
b8n1dMnvb8n1dMnvSpq7Kk9fKE9iJFBjJlBgKE9iKE9iKk9fKE9iKk9fKk9f
Kk9fKk9fKE9iK1NnNWV9RYCeYKfHc8jtZcz3a8vwb8n1b8n1dMnvb8n1dMnv
b8n1Zcz3dMnvVa3SBxkgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXKjNbLzg
AAAAAAAAAAAAAAAAAAAAUpCsb8n1IkFPAAAAL1dpZcz3dMnvZcz3b8n1dMnv
dMnvZ7TXSYemMGd+J1ZpKk9fKE9iKE9iJFBjKk9fKk9fJlBgKk9fK1hqOGqD
UY6qZ7vldMnvZcz3dMnvb8n1b8n1Zcz3U5m8LFJjKFNkLFJjKlJmLFJjSoOd
dMnva8vwb8n1dMnvMVlsKE9iJFBjJFBjKk9fKk9fZbDRdMnvdMnvb8n1dMnv
b8n1asruKE9iKk9fKE9iJFBjJFBjKE9iYLjZb8n1dMnvb8n1b8n1b8n1Zcz3
b8n1b8n1ZMn0UqnNRn2WNWp+KFhsKE9iJFBjKk9fKk9fKk9fJFBjKk9fKE9i
JFBjJFBjKE9iJlBgKE9iYarKdMnvb8n1Zcz3UJO0KlJmKFNkLFJjJVRnKFNk
S4uqdMnvb8n1b8n1b8n1Zcz3dMnvb8j0XaTDLVRmPHGLUZW2XaPCWKnJXaPC
Vpi1Q3mQKEtbSpi5acfrb8n1b8n1dMnvb8n1Zcz3b8n1dMnvWLLYSpCrZcz3
Zcz3dMnva8vwb8n1a8vwdMnvb8n1dMnvb8n1b8n1Zcz3Zcz3UJq3PnCGdMnv
a8vwb8n1b8n1b8n1b8n1Zcz3Zcz3a8vwZcz3b8n1b8n1a8vwY67PTpCwdMnv
Zcz3a8vwb8n1XaPCKE9iKk9fKk9fKE9iJlBgKE9iKk9fKk9fKk9fJFBjJFBj
KE9iKk9fKE9iKE9iJFBjJFBjJFBjJlBgJFBjJFBjUZa3Zcz3Zcz3dMnva8vw
dMnva8vwdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnva8vwa8vwb8n1b8n1Zcz3
b8n1dMnvdMnvdMnvdMnvZcz3b8n1dMnvdMnva8vwa8vwb8n1a8vwZcz3dMnv
dMnvb8n1dMnvdMnvV6fGID5LV5m2S4agRYafOXiTAAAAOXKIJU1dZrniX7bY
AAAAAAAAAAAAAAAAAAAATomka8vwKVFlAAAAXKLBZcz3dMnva8vwbsfzZcz3
dMnvdMnvdMnvdMnvb8n1a8vwa8vwdMnvZcz3b8n1b8n1b8n1dMnva8vwb8n1
a8vwb8n1dMnvdMnva8vwdMnvdMnvdMnvZcz3b8n1Zcz3dMnvb8n1b8n1a8vw
b8n1a8vwb8n1b8n1dMnvdMnvdMnvb8n1Zcz3b8n1b8n1b8n1a8vwZcz3a8vw
b8n1dMnvdMnva8vwdMnvdMnva8vwb8n1a8vwb8n1a8vwdMnvdMnvdMnva8vw
a8vwdMnvdMnvb8n1dMnvdMnva8vwdMnvb8n1a8vwdMnvdMnvb8n1a8vwdMnv
dMnvi6W2iqW5a8vwb8n1b8n1Zcz3b8n1dMnvdMnvb8n1Zcz3dMnvdMnva8vw
Zcz3Zcz3dMnva8vwdMnvb8n1dMnvb8n1b8n1dMnvarncV6DDUZW2RpGwUJS2
Wp+9YLfYc8jub8n1a8vwdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnv
b8n1b8n1dMnvdMnvZcz3a8vwb8n1dMnva8vwdMnvdMnvdMnvZcz3Zcz3b8n1
a8vwa8vwa8vwa8vwb8n1dMnvb8n1dMnva8vwa8vwdMnvb8n1dMnvb8n1dMnv
b8n1dMnva8vwdMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1Zcz3dMnvdMnvdMnv
b8n1dMnva8vwdMnvdMnvdMnvb8n1dMnvdMnva8vwdMnvdMnvZcz3dMnvdMnv
b8n1dMnvZcz3b8n1Zcz3a8vwb8n1b8n1a8vwZcz3b8n1b8n1a8vwdMnvdMnv
dMnvdMnvZcz3Zcz3Zcz3dMnva8vwb8n1b8n1b8n1b8n1a8vwdMnvdMnva8vw
b8n1a8vwdMnvb8n1dMnvW6fMbsjzZcz3dMnvdMnvPm+GVJSxZrrjdMnvU5Kv
AAAAAAAAAAAAAAAAAAAAQ4Sdb8n1M15xKVRlc8jtdMnvb8n1b8n1ZcHkZK/Q
b8n1Zcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1a8vw
b8n1a8vwb8n1b8n1dMnvZcz3b8n1dMnvdMnvdMnvdMnvZcz3a8vwdMnvb8n1
dMnvb8n1a8vwa8vwZcz3b8n1b8n1a8vwdMnvdMnvdMnva8vwb8n1dMnvdMnv
dMnvb8n1b8n1b8n1dMnvmIZ/dMnvdMnvb8n1a8vwb8n1dMnvb8n1b8n1dMnv
iqS4mIZ/b8n1b8n1b8n1dMnvb8n1dMnva8vwb8n1Zcz3b8n1a8vwb8n1b8n1
mIZ/mIZ/mIZ/mIZ/k5KWjKKydMnvdMnvZcz3Zcz3dMnvdMnvb8n1b8n1b8n1
dMnvdMnvZcz3dMnvb8n1a8vwdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
Zcz3b8n1b8n1dMnvb8n1dMnvdMnvZcz3b8n1b8n1Zcz3dMnvb8n1b8n1dMnv
a8vwdMnvZcz3b8n1dMnvdMnvdMnvZcz3b8n1b8n1b8n1b8n1dMnvdMnvdMnv
b8n1dMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1b8n1b8n1a8vwZcz3dMnvb8n1
dMnvb8n1b8n1Zcz3Zcz3a8vwZcz3dMnvZcz3a8vwa8vwdMnvb8n1b8n1a8vw
dMnvb8n1dMnvb8n1b8n1b8n1dMnvb8n1b8n1b8n1dMnvb8n1dMnvb8n1Zcz3
b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvdMnvZcz3b8n1Zcz3
Zcz3dMnvdMnvdMnvb8n1dMnvdMnva8vwdMnvdMnvdMnvb8n1dMnvb8n1a8vw
dMnvZcz3dMnvb8n1dMnva8vwdMnvb8n1b8n1b8n1asDqRXuUZcz3bsfyH0hY
AAAAAAAAAAAAAAAAAAAAQHKJZcz3P3GHW6fMdMnvdMnvdMnvdMnvb8HlLl1w
dMjub8n1dMnva8vwb8n1b8n1Zcz3dMnva8vwb8n1Zcz3a8vwdMnvdMnvdMnv
dMnvdMnva8vwb8n1dMnvdMnvZcz3dMnvZcz3b8n1dMnvb8n1Zcz3dMnvdMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1Zcz3a8vwdMnvdMnvb8n1b8n1b8n1
a8vwa8vwdMnvZcz3mIZ/mIZ/dMnvdMnvdMnvdMnvZcz3a8vwdMnvb8n1gbfT
mIZ/mIZ/a8vwdMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/l4qHdMnvdMnvZcz3b8n1a8vwdMnvdMnvdMnv
b8n1dMnvb8n1dMnvdMnvZcz3a8vwZcz3Zcz3a8vwZcz3b8n1dMnva8vwdMnv
dMnvdMnvb8n1dMnvZcz3Zcz3dMnvdMnva8vwdMnvb8n1dMnvdMnvb8n1dMnv
b8n1dMnvb8n1dMnvb8n1Zcz3dMnvdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnv
b8n1b8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvZcz3b8n1Zcz3
a8vwdMnvb8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvb8n1Zcz3
a8vwb8n1dMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnv
dMnvb8n1a8vwb8n1dMnva8vwZcz3dMnvb8n1b8n1b8n1b8n1dMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnv
b8n1dMnva8vwdMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvccTpdMnvV6DEAAAA
AAAAAAAAAAAAAAAAAAAAMltudMnvVJq9a8vwb8n1a8vwdMnvdMnvasDrAAAA
XKjNa8vwb8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1
b8n1a8vwb8n1b8n1dMnvZcz3dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1
b8n1b8n1dMnvb8n1a8vwZcz3b8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnva8vw
dMnvdMnvdsnvmIZ/mIZ/mIZ/Zcz3dMnvb8n1b8n1dMnvdMnvZcz3g83tmYiB
mIZ/mIZ/dMnvZcz3dMnvdMnva8vwb8n1b8n1b8n1a8vwb8n1mIZ/mIZ/mIZ/
//fX//fX//fX3dG6momBmIZ/mIZ/mIZ/dMnvdMnvdMnvb8n1Zcz3dMnvb8n1
dMnvb8n1a8vwZcz3b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1b8n1
a8vwb8n1a8vwb8n1b8n1dMnvdMnvb8n1dMnvb8n1b8n1a8vwZcz3a8vwb8n1
a8vwb8n1dMnvb8n1dMnvdMnvdMnvb8n1Zcz3a8vwZcz3b8n1b8n1dMnvb8n1
dMnvdMnvb8n1a8vwa8vwa8vwb8n1b8n1dMnvZcz3b8n1b8n1dMnva8vwdMnv
dMnvdMnvdMnvb8n1b8n1b8n1a8vwb8n1dMnvb8n1dMnvZcz3Zcz3dMnvdMnv
b8n1dMnvZcz3a8vwZcz3a8vwZcz3Zcz3dMnva8vwa8vwdMnvb8n1b8n1Zcz3
dMnvb8n1dMnvb8n1b8n1dMnvb8n1dMnva8vwdMnvdMnvdMnva8vwdMnvdMnv
b8n1dMnvb8n1Zcz3dMnvdMnvb8n1a8vwdMnvdMnva8vwa8vwdMnvdMnvdMnv
b8n1b8n1a8vwdMnvb8n1b8n1a8vwZcz3a8vwZcz3Zcz3b8n1c8jtKE9iAAAA
AAAAAAAAAAAAAAAAAAAAHjtIdMnvbsfza8vwb8n1Zcz3b8n1a8vwkH54AAAA
TUM/mIZ/mIZ/b8n1b8n1b8n1a8vwdMnvZcz3dMnvb8n1Zcz3dMnva8vwa8vw
b8n1dMnva8vwb8n1dMnvb8n1a8vwb8n1Zcz3b8n1dMnvb8n1dMnva8vwa8vw
dMnvdMnvdMnvb8n1dMnvdMnvZcz3b8n1dMnvdMnvZcz3Zcz3Zcz3dMnvb8n1
d8v1acz3mIZ/mIZ/mIZ/2szKmIZ/dsnvdMnvb8n1dMnveMnvZcz3mIZ/mIZ/
3dfamIZ/m9LrdMnvZcz3dMnvdMnvdMnvdMnvb8n1dMnvmIZ/mIZ///fX//fX
//fX//fX//fX//fX/vbWx7mnmIZ/mIZ/dMnvZcz3dMnvdMnvZcz3dMnvZcz3
dMnvdMnvdMnvdMnvb8n1dMnvb8n1b8n1b8n1dMnvZcz3a8vwdMnvdMnvb8n1
a8vwdMnvdMnvdMnvdMnvb8n1a8vwb8n1dMnva8vwb8n1dMnvb8n1dMnvdMnv
dMnvZcz3a8vwZcz3b8n1b8n1dMnvdMnvdMnvdMnvdMnva8vwdMnva8vwa8vw
b8n1a8vwdMnvb8n1dMnva8vwdMnvZcz3dMnvdMnvdMnvdMnvdMnvdMnvb8n1
b8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvZcz3dMnvdMnvdMnvdMnvdMnv
a8vwdMnvb8n1dMnvdMnvdMnvdMnvZcz3dMnvb8n1b8n1a8vwdMnvdMnvdMnv
b8n1dMnvb8n1a8vwdMnvb8n1dMnvdMnvdMnvb8n1Zcz3b8n1b8n1b8n1b8n1
dMnvdMnvdMnvdMnvZcz3b8n1dMnvdMnva8vwb8n1b8n1b8n1Zcz3b8n1a8vw
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvWKjHAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAasDqdMnvdMnvdMnvdMnvX6bGmIZ/iHhxAAAA
AAAA2824mIZ/dMnva8vwdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnv
dMnvb8n1dMnva8vwdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnva8vwb8n1dMnv
a8vwb8n1b8n1dMnvb8n1a8vwdMnvdMnvdMnvZcz3dMnvdMnvdMnvdMnvdMnv
dsnvmIZ/mIZ/mIZ/7t/I2szKmIZ/cc3wa8vwdMnvb8n1fcvzmIZ/mIZ/mIZ/
2szKmIZ/eMnvb8n1dMnvb8n1b8n1a8vwZcz3dMnvmIZ/mIZ///fX//fX//fX
//fX//fX//fX//fX//fX//fX3tO7mYeAmIZ/dMnvdMnvb8n1dMnvb8n1dMnv
Zcz3b8n1dMnvZcz3dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvZcz3dMnv
dMnvb8n1a8vwb8n1b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1b8n1
Zcz3dMnvdMnvdMnvdMnva8vwZcz3dMnvdMnvdMnvZcz3b8n1b8n1dMnvdMnv
a8vwdMnvdMnvdMnvb8n1b8n1Zcz3dMnvb8n1Zcz3Zcz3b8n1b8n1b8n1dMnv
a8vwZcz3a8vwb8n1a8vwdMnvZcz3b8n1a8vwdMnvdMnvdMnvb8n1b8n1b8n1
dMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvb8n1dMnvdMnvb8n1a8vwb8n1Zcz3
dMnvdMnvdMnvdMnvdMnvb8n1b8n1b8n1a8vwdMnvdMnvdMnvdMnvdMnvb8n1
b8n1a8vwb8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnva8vw
dMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1b8n1P3aRAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAXaTDdMnvdMnvb8n1dcv1O2uDkYB5eWpkAAAA
AAAAsaaUmIZ/dMnvdMnvb8n1Zcz3dMnvdMnvdMnvdMnva8vwb8n1b8n1dMnv
dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1b8n1dMnvb8n1b8n1dMnvdMnvb8n1
dMnva8vwdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvb8n1b8n1b8n1
ccn1mIZ/mIZ/mIZ/7t/I2szKmIZ/ccn1ccn1dMnvmIZ/mIZ/mIZ/mIZ/2szK
3dfamIZ/dMnvb8n1f8vtdMnvb8n1dMnvdMnvmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/dMnvb8n1dMnvdMnvdMnv
dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvdMnv
dMnvb8n1dMnvdMnvb8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnv
b8n1b8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1
dMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1Zcz3dMnvb8n1dMnvdMnvdMnv
b8n1b8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1a8vwdMnvdMnvdMnvdMnv
a8vwdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnv
b8n1dMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1b8n1dMnvcsXqDyIrAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAO3CKb8n1b8n1fsvviHhxBAMDhnZwjoV3AAAA
AAAAe3Nm7t/ImIZ/b8n1dMnvdMnvb8n1b8n1b8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnv
a8vwdMnvb8n1b8n1b8n1b8n1b8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnv
mIZ/mIZ/7t/I7t/I7t/I2szKmIZ/s9nnesvvj9DxmIZ/mIZ/mIZ/7t/I3dfa
3dfamIZ/dMnvdMnvdMnvdMnvdMnvdMnvmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXtqeZmIZ/mIZ/dMnvb8n1b8n1dMnv
dMnvb8n1b8n1dMnva8vwb8n1b8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnv
dMnvdMnvdMnvb8n1dMnvdMnvdMnva8vwdMnvb8n1b8n1dMnvb8n1a8vwdMnv
dMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1
b8n1dMnva8vwdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnva8vwa8vwdMnv
dMnvdMnva8vwb8n1dMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnv
b8n1Zcz3dMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1
dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1b8n1b8n1dMnvdMnv
b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1b8n1b8n1b8n1dMnvb8n1b8n1dMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvYrPbAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAXaPCdMnva7faNy8tAAAAuq6cGhcUAAAA
AAAAOTQu7d7H7t/ImIZ/dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvfsvvmIZ/
mIZ/7t/I//fX//fX//fX3dfamIZ/mIZ/jM/tmIZ/mIZ/mIZ/7t/I7t/I3dfa
3dfamIZ/dsnvb8n1ccn1dMnvmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXp5aLmIZ/mIZ/dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvb8n1dMnv
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1b8n1dMnvb8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnv
dMnvfMbub8n1b8n1dMnvdMnvdMnvb8n1b8n1b8n1b8n1b8n1b8n1dMnvb8n1
dMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvdMnv
dMnvb8n1dMnvb8n1dMnvb8n1b8n1dMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvfMbub8n1dMnvdMnvdMnvdMnvdMnv
dMnvb8n1dMnvdMnvdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvdMnvfMbudMnv
b8n1dMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvb8n1b8n1W5++AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAggMNGBzCAYFAAAAAAAAJyQfAAAAAAAA
AAAAAAAA4tS+7t/ImIZ/dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvb8n1dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvdMnvb8n1b8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvb8n1dMnvmIZ/mIZ/
7t/I//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX3dfa
3dfamIZ/b8n1dMnvf8vtb8n1mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX59zCqZiNmIZ/b8n1b8n1dMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1
dMnvb8n1dMnvb8n1b8n1b8n1b8n1fMbub8n1dMnvdMnvdMnvb8n1b8n1dMnv
b8n1dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnv
b8n1b8n1dMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnv
dMnvb8n1dMnvb8n1fMbudMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnv
fMbudMnvdMnvdMnvb8n1a8vwdMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1
fMbudMnvb8n1b8n1dMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvb8n1fMbub8n1
fMbudMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvdMnvb8n1dMnvb8n1dMnvb8n1dMnvdMnvfMbudMnvUpi6AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA3c+57t/ImIZ/u8HKdMnvb8n1b8n1dMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1
b8n1dMnvb8n1b8n1dMnvdMnvdMnvfMbub8n1dMnvdMnvb8n1mIZ/mIZ/mIZ/
7t/I//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/7t/I7t/I7t/I//fX//fX3dfa
3dfamIZ/dMnvdMnvp9bpmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbW7ePHmIZ/mIZ/dMnvb8n1
dMnvdMnvfMbub8n1b8n1b8n1dMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1
dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
dMnvb8n1dMnvdMnvb8n1dMnvb8n1fMbudMnvb8n1b8n1dMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvb8n1
fMbufMbudMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnv
dMnvb8n1b8n1dMnvdMnvdMnvdMnvdMnvfMbufMbudMnvdMnvdMnvdMnvdMnv
dMnvdMnvfMbudMnvdMnvfMbudMnvdMnvdMnvb8n1dMnvdMnvdMnvb8n1dMnv
dMnvfMbub8n1dMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvYJWvAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA3tC67t/ImIZ/mIZ/dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvfMbu
b8n1fMbub8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1b8n1gcbodMnvfMbufMbu
dMnvb8n1fMbudMnvb8n1dMnvb8n1b8n1dMnvb8n1dMnvmIZ/mIZ/mIZ/7uPf
//////fX//fX3dfa3dfa3dfamIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX3dfa
3dfamIZ/js/tmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXu5SNmYZ///fX+/LTwLKhmIZ/b8n1dMnv
dMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvfMbufMbudMnv
b8n1dMnvb8n1dMnvdMnvdMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvb8n1b8n1dMnvdMnvdMnvb8n1fMbudMnvb8n1dMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvb8n1b8n1dMnvdMnvdMnvb8n1
dMnvdMnvdMnvdMnvfMbub8n1dMnvfMbub8n1b8n1b8n1fMbub8n1dMnvdMnv
dMnvdMnvdMnvb8n1b8n1b8n1b8n1dMnvdMnvb8n1b8n1dMnvdMnvfMbudMnv
b8n1dMnvdMnvdMnvfMbub8n1b8n1dMnvb8n1dMnvdMnvb8n1dMnvdMnvfMbu
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1b8n1XqXFAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAADQwJ+vLT7t/I7t/ImIZ/mIZ/fMbufMbufMbudMnvdMnvb8n1dMnvdMnv
a8vwdMnvb8n1dMnvdMnvdMnvb8n1dMnvfMbumIZ/mIZ/fMbudMnvdMnvfMbu
dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvgcbob8n1mIZ/mIZ/mIZ/7uPf7uPf
////////3dfa3dfa3dfamIZ/7t/I7uPf//fX//fX//fX//fX//fX//fX3dfa
z8fImIZ/mIZ/mIZ/9PLa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXtZGLoImC1p6Y//fX//fXmIZ/mIZ/dMnv
dMnvdMnvdMnvdMnvdMnvb8n1fMbufMbub8n1fMbudMnvb8n1b8n1fMbudMnv
dMnvdMnvfMbub8n1fMbudMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvb8n1b8n1b8n1dMnv
dMnvfMbudMnvb8n1b8n1dMnvdMnvdMnvgcbob8n1dMnvfMbudMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvgcbob8n1dMnvdMnvdMnvb8n1
dMnvdMnvfMbub8n1gcbodMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnv
fMbudMnvdMnvgcbodMnvdMnvdMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnv
fMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvfMbudMnva7rdAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAdXFh//fX//fX7t/I7t/ImIZ/mIZ/dMnvb8n1dMnvdMnvfMbub8n1dMnv
fMbudMnvfMbub8n1fMbub8n1dMnvdMnvmIZ/mIZ/mIZ/mIZ/is/xdMnvdMnv
dMnvb8n1dMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvmIZ/mIZ/xbSl7uPf////
////////3dfamIZ/mIZ/7uPf7uPf7uPf//fX//fX//fX//fX//fX3dfa3dfa
zsXGmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXqYyGmIZ///fX//fXmIZ/mIZ/b8n1
b8n1dMnvdMnvdMnvb8n1dMnvdMnvb8n1dMnvdMnvdMnvdMnvgcbodMnvdMnv
dMnvdMnvb8n1fMbub8n1dMnvb8n1fMbudMnvfMbudMnvb8n1dMnvdMnvdMnv
dMnvfMbub8n1dMnvdMnvdMnvdMnvfMbufMbub8n1fMbugcbodMnvdMnvb8n1
dMnvdMnvfMbudMnvdMnvfMbub8n1b8n1dMnvdMnvfMbub8n1fMbudMnvb8n1
dMnvb8n1dMnvdMnvfMbudMnvdMnvfMbua8vwb8n1dMnvdMnvdMnvdMnvfMbu
fMbufMbudMnvdMnva8vwb8n1b8n1dMnvdMnvdMnvdMnvfMbudMnvdMnvdMnv
dMnvb8n1a8vwdMnvdMnvfMbub8n1dMnvdMnvdMnvfMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbufMbudMnvfMbudMnvb8n1b8n1dMnvdMnv
b8n1fMbudMnvb8n1fMbufMbub8n1b8n1dMnvdMnvdMnvb8n1MlVoAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAubOb//fX//fX7t/I7t/I7t/ImIZ/mIZ/dMnvdMnvdMnvdMnvdMnvdMnv
fMbudMnvdMnvdMnvgcbodMnvfcvzeMnvmIZ/7t/I7t/ImIZ/mIZ/f8vtfMvv
dMnvfMbudMnvdMnvfMbufMbudMnvb8n1fMbudMnvmIZ/taSY7t/I//////fX
////3dfamIZ/mIZ/7t/I7uPf7uPf//////////fX//fX//fX//fX3dfa3dfa
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXw7WkmIZ/1p6Y//fXs6SWmIZ/mIZ/
dMnvdMnvdMnvfMbudMnvdMnvfMbudMnvdMnvdMnvfMbua8vwdMnvb8n1b8n1
b8n1dMnvdMnvgcbob8n1fMbudMnvdMnvdMnvdMnvdMnvdMnvfMbufMbufMbu
dMnvdMnvb8n1dMnvdMnvdMnvdMnvb8n1dMnvb8n1dMnvfMbufMbugcbodMnv
dMnvdMnvdMnvfMbudMnvgcbodMnvb8n1fMbudMnvdMnvb8n1fMbufMbudMnv
gcbofMbub8n1dMnvdMnvfMbugcbodMnvdMnvfMbufMbudMnvdMnvdMnvdMnv
dMnvb8n1dMnvfMbufMbudMnvdMnvb8n1fMbudMnvdMnvdMnvdMnvb8n1dMnv
fMbudMnvfMbudMnvdMnvdMnvdMnvdMnvfMbufMbub8n1b8n1b8n1b8n1dMnv
fMbub8n1b8n1dMnvdMnvdMnvdMnvdMnvb8n1b8n1dMnvfMbugcbodMnvb8n1
fMbudMnvfMbudMnvb8n1dMnvdMnvgcbodMnvdMnvb8n1dMnvXaPCAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
MjAo8uvM//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/fMbudMnvdMnvdMnvdMnv
b8n1dMnvdMnvdMnvdMnvfMbufMbumIZ/mIZ/7t/I7t/ImIZ/mIZ/ccn1fMbu
fMbudMnvb8n1dMnvdMnvdMnvb8n1dMnvdMnvmIZ/mIZ/y7ur7t/I//////fX
//fX3dfamIZ/mIZ/7uPf7uPf//fX//////////////fX//fX3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXnIuDmIZ/1p6Y1p6YmIZ/mIZ/
fMbufMbudMnvdMnvfMbub8n1dMnvdMnvdMnvfMbudMnvfMbub8n1fMbufMbu
dMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbufMbudMnvdMnvdMnvb8n1
dMnvdMnvgcbofMbudMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnv
dMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvb8n1dMnvdMnvdMnvdMnvdMnv
dMnvdMnvdMnvb8n1dMnvb8n1dMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvb8n1
dMnvdMnvfMbudMnvdMnvdMnvdMnvgcbob8n1fMbub8n1dMnvfMbufMbudMnv
fMbudMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnvfMbufMbufMbufMbub8n1
gcbofMbufMbufMbudMnvdMnvdMnvdMnvdMnvfMbugcboa8vwdMnvdMnvgcbo
b8n1dMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnve8XtOmh9AAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
v7mh//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/dMnvfMbufMbudMnvdMnv
fMbufMbub8n1b8n1dMnvdMnvmIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/mIZ/dMnv
ccn1fMbufMbub8n1b8n1dMnvdMnvdMnvdMnvmIZ/mIZ/7t/I7t/I//fX//fX
//fXmIZ/mIZ/7t/I7uPf//////////////////////fX//fX3dfamIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXp5aLmIZ/1p6Y1p6YmIZ/mIZ/
b8n1fMbudMnvfMbudMnvfMbub8n1fMbub8n1dMnvdMnvdMnvdMnvfMbudMnv
fMbudMnvb8n1fMbudMnvfMbufMbudMnvdMnvdMnvb8n1fMbudMnvgcbodMnv
fMbudMnvdMnvfMbufMbub8n1dMnvfMbufMbugcbob8n1dMnvb8n1fMbudMnv
dMnvdMnvdMnvdMnvb8n1fMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvdMnvb8n1
b8n1fMbudMnvfMbudMnvb8n1fMbudMnvdMnvb8n1dMnvfMbufMbufMbudMnv
dMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvdMnvdMnvfMbudMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbudMnvb8n1dMnvgcbodMnvdMnvdMnvdMnv
dMnvdMnvdMnvdMnvdMnvfMbufMbufMbudMnvdMnvdMnvfMbufMbufMbudMnv
dMnvb8n1gcbodMnvb8n1fMbub8n1fMbufMbudMnvfMbufMbudMnvdr3jK0lZ
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmZSA
/vbW//fX//fX//fX//fX7t/I//fX7t/I7t/ImIZ/mIZ/dMnvdMnvfMbudMnv
a8vwfMbudMnvgcbodMnvmIZ/mIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/
j8rmdMnvdMnvgcbogcbodMnvfMbudMnvfMbumIZ/wrSj7t/I7t/I//fX//fX
//fXmIZ/mIZ/7t/I7uPf//////fX//fX////////3dfa3dfa3dfamIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXq5uPmIZ/1p6Y1p6YmIeBmIZ/
dMnvb8n1fMbufMbufMbudMnvgcbodMnvdMnvfMbub8n1fMbudMnvgcbofMbu
dMnvdMnvdMnvfMbufMbua8vwfMbub8n1fMbufMbufMbudMnvb8n1fMbub8n1
dMnvb8n1dMnvb8n1dMnvgcbofMbudMnvdMnvdMnvdMnvb8n1gcbodMnvfMbu
dMnvdMnvdMnvb8n1dMnvdMnvfMbudMnvdMnvfMbufMbub8n1dMnvfMbudMnv
fMbudMnvfMbub8n1dMnvdMnvdMnvfMbub8n1fMbub8n1dMnva8vwfMbufMbu
fMbudMnvb8n1dMnvfMbub8n1b8n1dMnvdMnvfMbufMbudMnvdMnvdMnvdMnv
dMnvdMnvdMnvfMbudMnvdMnvfMbugcbofMbudMnvdMnvfMbudMnvfMbub8n1
dMnvdMnvdMnvfMbudMnvdMnvdMnvfMbudMnvdMnvdMnvdMnvdMnvb8n1fMbu
gcbodMnvdMnvfMbudMnvgcbodMnvb8n1dMnvdMnvdMnvdMnvdMnvdMnvbr/j
OV90AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApqCL/PTV
//fX//fX//fX//fX//fX//fX7t/I//fX7t/I7t/ImIZ/fMbufMbudMnvfMbu
dMnvfMbudMnvdMnvdMnvmIZ/mIZ/7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/
fsbudMnvdMnvdMnvfMbudMnvfMbudMnvdMnvmIZ/wrSj7t/I7t/I//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fX//fX////3dfa3dfamIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6YsZCJmIZ/
mIZ/dMnvfMbua8vwdMnvfMbudMnvdMnvfMbufMbudMnvdMnvfMbua8vwdMnv
fMbufMbufMbua8vwfMbudMnvdMnvfMbua8vwgcbofMbua8vwfMbufMbufMbu
gcbofMbugcbob8n1fMbudMnvdMnvdMnvfMbufMbufMbudMnvb8n1b8n1fMbu
fMbufMbufMbufMbudMnvfMbufMbufMbufMbudMnvfMbufMbudMnvdMnvdMnv
dMnvdMnvgcbodMnvfMbudMnvfMbugcbodMnvgcbodMnvfMbufMbua8vwdMnv
dMnvfMbufMbudMnvfMbufMbufMbufMbudMnvdMnvfMbudMnvb8n1fMbudMnv
fMbufMbub8n1fMbufMbudMnvdMnvdMnvfMbub8n1dMnvdMnvfMbudMnvgcbo
dMnvfMbufMbudMnvfMbudMnvdMnvgcbodMnvdMnvfMbudMnvdMnvfMbudMnv
dMnvdMnvdMnvgcbodMnvdMnvdMnvgcbofMbudMnvfMbufMbufMbudMnvdMnv
c8jtV5m2ID5LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZmNV1c6z//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/fMbufMbudMnv
dMnvgcbofMbufMbumIZ/p5aL7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/
mIZ/nM/qic3tg83tdMnvdMnvb8n1dMnveMnvmIZ/wbOi7t/I7t/I//fX//fX
//fXmIZ/3M257t/I//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6YmIZ/
mIZ/fMbudMnvfMbufMbua8vwfMbufMbudMnvgcbodMnvfMbufMbugcbofMbu
dMnvdMnvfMbudMnvfMbub8n1fMbufMbufMbufMbudMnvfMbua8vwgcbodMnv
dMnvdMnvdMnvfMbudMnvdMnvfMbufMbudMnva8vwgcbodMnvfMbugcbob8n1
dMnvdMnvgcbofMbudMnvdMnvdMnvgcbodMnvdMnvgcbodMnvb8n1fMbufMbu
fMbudMnvdMnvfMbudMnvfMbua8vwfMbudMnva8vwfMbudMnvgcbofMbufMbu
dMnvgcbofMbudMnvdMnvdMnvdMnvdMnvfMbufMbudMnvfMbufMbudMnvfMbu
dMnvfMbudMnvdMnvfMbudMnvfMbudMnvfMbufMbufMbufMbudMnvfMbudMnv
dMnvdMnvfMbudMnvfMbudMnvdMnvfMbufMbudMnvfMbufMbugcbodMnvdMnv
fMbufMbudMnvfMbufMbub8n1fMbudMnvfMbufMbudMnvfMbudMnvfMbufMbu
fMbudMnvcsXrZaLDRHmRQDg0IBsZNjIsa2RZpqCL2tO3/fXV//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/lMzsfMbu
a8vwdMnvdMnvmIZ/m4qDyrqp7t/I7t/I//fX//fX//fX//fX//fX//fX7t/I
7t/ImIZ/gcvtfsbufsbug8bopNHqfMbufMbumIZ/wLKi7t/I//fX//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fX//fX3dfamIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6YmIZ/
mIZ/a8vwdMnvfMbufMbufMbudMnvfMbudMnvfMbudMnva8vwdMnvdMnvb8n1
gcboa8vwfMbudMnvgcbodMnvdMnvfMbua8vwfMbufMbufMbudMnvfMbudMnv
b8n1fMbugcbofMbufMbub8n1fMbudMnvgcbodMnvdMnvgcbodMnvfMbub8n1
b8n1dMnva8vwfMbudMnvfMbudMnvdMnvfMbudMnvfMbugcbodMnvdMnvdMnv
fMbudMnvfMbudMnvfMbugcbodMnvfMbufMbudMnvdMnvfMbua8vwdMnvfMbu
fMbua8vwfMbufMbudMnvfMbub8n1fMbub8n1fMbudMnvdMnvdMnvdMnvdMnv
fMbugcbodMnvfMbudMnvfMbudMnvdMnvgcbogcbofMbudMnvfMbudMnvfMbu
fMbudMnvdMnvdMnvdMnvfMbudMnvdMnvdMnvfMbudMnvdMnvdMnvfMbufMbu
b8n1dMnvb8n1fMbudMnvgcbodMnvfMbudMnvfMbub8n1gcbofMbudMnvdMnv
dMnvfMbub8n1dMnvfMbumIZ/pZOK7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/esvv
fMbufMbudMnvmIZ/u6ufzb2s7t/I//fX//fX//fX//fX//fX//fX//fX7t/I
7t/ImIZ/mIZ/mIZ/fsvvdMnvdMnvk8vmdsnvmIZ/wbOi7t/I//fX//fX//fX
//fXmIZ/7t/I7t/I//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/fMbufMbudMnvdMnva8vwfMbufMbufMbufMbufMbufMbufMbufMbufMbu
dMnvfMbudMnvfMbufMbufMbufMbufMbufMbua8vwgcbodMnvfMbudMnvfMbu
gcbodMnvdMnvdMnvfMbugcbodMnvfMbudMnvfMbufMbudMnvdMnvdMnvfMbu
gcbodMnvfMbudMnvfMbudMnvfMbufMbudMnvdMnvdMnvfMbugcbofMbufMbu
fMbufMbudMnvfMbudMnvfMbudMnvdMnvfMbub8n1b8n1dMnvfMbufMbudMnv
dMnvfMbudMnvfMbufMbufMbugcbodMnvgcbodMnvfMbufMbufMbudMnvfMbu
dMnvfMbudMnvfMbufMbufMbudMnvfMbudMnvgcbodMnvdMnvdMnvfMbufMbu
fMbufMbufMbufMbufMbufMbufMbufMbufMbufMbufMbudMnvdMnvdMnvgcbo
fMbugcbodMnvdMnvfMbufMbufMbufMbudMnvgcbofMbudMnvfMbufMbufMbu
gcbogcbofMbufMbufMbumIZ/t6aZ7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I4dXGmIZ/
eMnvkMzsmIZ/n4+Kzr2t7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/IpJOJnYuDmYeAmIZ/mIZ/mIZ/mIZ/t6ia7t/I7t/I//fX//fX
//fX3dfa7t/I7t/I//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/dMnvfMbufMbufMbugcboa8vwdMnvdMnvdMnvgcbodMnvdMnvgcbofMbu
fMbufMbufMbua8vwdMnvdMnvdMnvfMbufMbudMnvfMbudMnvfMbudMnvfMbu
fMbufMbufMbudMnvfMbudMnvfMbudMnvfMbudMnvb8n1fMbugcbogcbofMbu
fMbugcbofMbudMnvdMnvfMbudMnvfMbufMbufMbudMnvfMbudMnvfMbudMnv
dMnvfMbufMbudMnvdMnvfMbufMbudMnvfMbugcbofMbudMnvdMnvfMbub8n1
fMbufMbugcbogcbodMnvfMbudMnvfMbudMnvgcbodMnvdMnvfMbudMnvfMbu
dMnvdMnvfMbufMbudMnvfMbufMbudMnvdMnvfMbudMnvfMbufMbudMnvgcbo
dMnvdMnvdMnvfMbudMnvfMbufMbudMnvdMnvdMnvdMnvfMbufMbufMbufMbu
dMnvfMbufMbudMnvdMnvdMnvdMnvdMnvdMnvfMbudMnvdMnvgcbodMnvdMnv
dMnvdMnvdMnvdMnvkpynmIZ/wrKj7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7d7HmIZ/
mIZ/esvvmIZ/qqGh7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/IvK2dtqWY7t/IsaCUoY+GmIZ/pJOJ7t/I7t/I//fX//fX
//fX//fX7t/I7t/I//fX//fX3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/dMnvgcbodMnvdMnvfMbufMbufMbudMnvfMbudMnvdMnvfMbudMnv
gcbodMnvdMnvfMbufMbufMbudMnvgcbodMnvfMbugcbofMbudMnvfMbudMnv
dMnvdMnvdMnvfMbudMnvfMbudMnvfMbudMnvfMbugcbodMnvdMnvdMnvdMnv
dMnvdMnvfMbufMbufMbudMnvfMbudMnvdMnvfMbudMnvdMnvfMbudMnvfMbu
dMnvgcbogcbofMbudMnvdMnvdMnvfMbugcbodMnvdMnvfMbufMbudMnvgcbo
dMnvdMnvdMnvfMbudMnvdMnvfMbudMnvfMbudMnvfMbufMbudMnvfMbugcbo
fMbudMnvdMnvfMbudMnvfMbudMnvfMbudMnvfMbufMbufMbudMnvdMnvfMbu
fMbufMbufMbufMbudMnvdMnvfMbufMbufMbufMbufMbudMnvdMnvdMnvfMbu
fMbudMnvfMbudMnvfMbufMbufMbufMbudMnvfMbufMbufMbufMbufMbufMbu
fMbufMbufMbudMnvkZyomIZ/ybmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/mIZ/rpyR7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/7t/I7t/I//fX//fX
//fX//fX//fX7t/I//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/dMnvfMbufMbugcbodMnvdMnvfMbudMnvfMbufMbudMnvdMnvfMbu
dMnvfMbufMbudMnvdMnvfMbufMbudMnvfMbudMnvdMnvfMbufMbufMbufMbu
dMnvfMbugcbodMnvdMnvfMbufMbufMbufMbufMbufMbudMnvdMnvfMbufMbu
fMbudMnvgcbodMnvfMbufMbufMbufMbugcbofMbufMbudMnvfMbudMnvfMbu
dMnvdMnvgcbofMbufMbudMnvdMnvdMnvfMbufMbudMnvdMnvfMbufMbufMbu
fMbudMnvdMnvfMbufMbudMnvfMbufMbufMbugcbofMbufMbudMnvdMnvfMbu
fMbufMbufMbudMnvfMbufMbufMbudMnvfMbufMbugcbodMnvfMbufMbufMbu
fMbufMbudMnvgcbofMbufMbudMnvdMnvfMbugcbodMnvfMbufMbufMbugcbo
dMnvfMbufMbufMbudMnvgcbogcbodMnvfMbudMnvdMnvdMnvdMnvgcbodMnv
fMbufMbugcbofMbuj52pmIZ/yrmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
3dfamIZ/zLyr7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/7t/I7t/I//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/fMbugcbodMnvdMnvfMbufMbugcbofMbudMnvfMbufMbufMbudMnv
dMnvgcbogcbofMbufMbugcbodMnvfMbudMnvfMbufMbugcbodMnvdMnvfMbu
fMbudMnvdMnvfMbufMbudMnvdMnvfMbudMnvdMnvfMbufMbufMbufMbufMbu
fMbufMbudMnvfMbugcbogcbodMnvdMnvdMnvdMnvdMnvfMbufMbufMbugcbo
fMbufMbudMnvfMbufMbufMbufMbufMbufMbudMnvfMbufMbugcbofMbugcbo
fMbufMbufMbugcbofMbufMbudMnvgcbofMbudMnvdMnvgcbofMbufMbudMnv
gcbogcbofMbugcbogcbofMbufMbugcbofMbudMnvfMbugcbofMbugcbofMbu
fMbufMbudMnvgcbogcbofMbufMbugcbofMbufMbugcbofMbufMbufMbufMbu
fMbugcbogcbofMbudMnvdMnvfMbufMbufMbufMbufMbufMbudMnvfMbugcbo
gcbodMnvfMbufMbugcbomIZ/yrqp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mIZ/qZiO7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/xbWl7t/I//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/esHifMbufMbufMbugcbofMbudMnvfMbugcbofMbugcbofMbufMbu
dMnvdMnvgcbogcbodMnvfMbugcbofMbufMbufMbudMnvfMbufMbudMnvfMbu
fMbufMbufMbufMbugcbofMbugcbofMbufMbudMnvfMbugcbogcbofMbugcbo
gcbofMbufMbudMnvdMnvfMbufMbufMbufMbufMbugcbogcbogcbodMnvfMbu
dMnvfMbufMbugcbogcbofMbufMbugcbogcbofMbugcbodMnvdMnvdMnvgcbo
fMbufMbudMnvgcbogcbogcbodMnvdMnvfMbugcbodMnvfMbudMnvfMbufMbu
fMbufMbugcbodMnvdMnvgcbogcbodMnvgcbofMbufMbufMbudMnvfMbudMnv
gcbogcbofMbufMbufMbugcbogcbodMnvdMnvgcbofMbugcbogcbodMnvgcbo
gcbodMnvfMbugcbofMbufMbugcbogcbogcbogcbogcbogcbofMbufMbudMnv
dMnvfMbugcbogcbodMnvmIZ/yrqp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mYeAzLyr7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IxLel7t/I//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7uTImIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/gb7hfMbugcbogcbodMnvdMnvfMbugcbofMbugcbodMnvfMbugcbo
fMbufMbudMnvfMbufMbugcbodMnvgcbogcbodMnvfMbugcbogcbofMbugcbo
fMbufMbufMbugcbofMbufMbudMnvgcbofMbufMbugcbofMbufMbugcbodMnv
fMbufMbugcbofMbufMbugcbogcbofMbugcbofMbufMbudMnvdMnvfMbufMbu
fMbufMbugcbodMnvfMbugcbogcbofMbufMbugcbodMnvfMbufMbufMbudMnv
fMbugcbofMbudMnvfMbufMbufMbugcbofMbufMbufMbugcbofMbugcbofMbu
fMbufMbufMbufMbudMnvfMbufMbudMnvfMbugcbofMbugcbodMnvfMbudMnv
fMbufMbugcbodMnvfMbufMbufMbufMbufMbugcbofMbudMnvfMbufMbufMbu
fMbufMbufMbufMbufMbufMbudMnvfMbufMbudMnvfMbufMbugcbofMbufMbu
fMbudMnvfMbufMbugcbomIZ/ybmp7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
qJaMzr6t7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I//fX//fX//fX
//fX//fX//fXmIZ/nIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFmIZ/mIZ/1p6Y1p6Y1p6Y
noiBmIZ/hrzZfMbudMnvfMbufMbugcbofMbufMbudMnvfMbugcbofMbufMbu
fMbufMbugcbofMbufMbufMbufMbudMnvgcbofMbufMbufMbugcbodMnvgcbo
gcbogcbodMnvfMbugcbofMbufMbugcbogcbodMnvfMbufMbufMbufMbufMbu
fMbudMnvfMbufMbufMbufMbugcbofMbugcbofMbufMbufMbufMbugcbofMbu
fMbudMnvfMbugcbodMnvdMnvfMbufMbudMnvfMbufMbugcbofMbufMbugcbo
dMnvfMbufMbudMnvfMbufMbufMbugcbofMbugcbofMbugcbofMbugcbofMbu
gcbofMbugcbogcbogcbogcbogcbofMbugcbofMbugcbofMbufMbugcbofMbu
gcbogcbodMnvgcbogcbogcbogcbogcbogcbodMnvfMbufMbugcbogcbogcbo
fMbugcbogcbogcbogcbofMbufMbudMnvfMbufMbugcbogcbofMbufMbufMbu
gcbofMbufMbugcbofMbumIZ/yrmp7t/I//fX//fX//fX//fX//fX3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
yLen7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXxLalmIZ/sqSh3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
sI+JmIZ/g7rbgcbofMbugcbogcbofMbugcbogcbofMbugcbofMbugcbogcbo
gcbofMbudMnvgcbofMbugcbofMbufMbufMbugcbofMbugcbofMbufMbudMnv
fMbudMnvfMbugcbofMbugcbofMbudMnvfMbufMbugcbogcbodMnvgcbofMbu
gcbofMbufMbugcbofMbufMbufMbufMbufMbugcbofMbugcbogcbodMnvgcbo
gcbofMbugcbofMbufMbufMbugcbogcbofMbufMbugcbofMbugcbofMbufMbu
fMbugcbogcbogcbogcbogcbogcbofMbugcbofMbugcbofMbufMbudMnvgcbo
gcbofMbufMbufMbudMnvfMbugcbofMbugcbodMnvgcbogcbofMbugcbofMbu
dMnvgcbofMbufMbufMbufMbufMbudMnvfMbugcbogcbofMbufMbudMnvgcbo
fMbufMbufMbufMbugcbogcbogcbogcbogcbodMnvfMbufMbugcbogcbofMbu
gcbogcbofMbudMnvgcbomIZ/yrqp7t/I//fX//fX//fX//fX3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfazsXG3dfam4mB
zr6t7uPf//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7OXZ//fX3dfa//fX//fX//fX
//fX//fXxrmnmIZ/saGUtqeZmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
o5KImIZ/grzegcbofMbufMbugcbofMbufMbugcbofMbugcbofMbufMbufMbu
gcbofMbufMbugcbofMbugcbogcbogcbofMbugcbofMbugcbogcbogcbogcbo
gcbogcbodMnvgcbofMbugcbogcbogcbogcbodMnvdMnvgcbofMbugcbofMbu
gcbogcbofMbugcbogcbogcbogcbofMbudMnvgcbofMbufMbugcbofMbufMbu
gcbofMbugcbogcbogcbodMnvfMbugcbogcbofMbufMbufMbugcbogcbogcbo
fMbufMbufMbufMbufMbufMbufMbudMnvgcbodMnvfMbugcbofMbufMbufMbu
fMbugcbogcbogcbofMbugcbofMbugcbofMbufMbufMbufMbugcbofMbugcbo
gcbofMbugcbogcbogcbogcbogcbogcbogcbofMbufMbugcbogcbogcbofMbu
gcbogcbogcbogcbofMbufMbufMbufMbufMbufMbugcbogcbofMbufMbugcbo
fMbufMbugcbogcbofMbumIZ/y7qq7t/I//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/t6aa
3M25//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6ePZ3dfa3dfa//fX//fX//fX
//fX//fXx7mnmIZ/mIZ/mIZ/mIZ/mIZ///fX//fXt6iZnIuDmIZ/mIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/1p6Y1p6Y1p6Y
mIZ/mIZ/hb3afMbugcbogcbofMbugcbogcbofMbugcbofMbugcbogcbogcbo
fMbugcbogcbofMbugcbodMnvfMbufMbugcbofMbugcbofMbufMbufMbufMbu
fMbufMbugcbofMbugcbodMnvfMbufMbufMbugcbofMbufMbugcbofMbugcbo
fMbufMbugcbofMbufMbufMbufMbugcbogcbofMbugcbogcbofMbugcbogcbo
fMbugcbofMbufMbufMbugcbogcbofMbufMbugcbogcbogcbofMbufMbufMbu
gcbogcbogcbogcbogcbogcbogcbogcbofMbugcbogcbofMbugcbogcbogcbo
fMbufMbuiMTogcbofMbugcbofMbugcbogcbogcboiMTofMbugcbofMbuiMTo
fMbufMbudMnvfMbufMbufMbufMbufMbugcbogcboiMTofMbufMbugcbofMbu
fMbufMbufMbugcbogcbogcbogcbogcbogcbofMbufMbugcbogcbofMbugcbo
gcbofMbufMbugcbogcbomIZ/vq6g7t/I//fX3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ///fXmIZ/nIqCzL+5
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX5N7Z3dfa3dfa3dfa//fX//fX
//fX//fXsaGUmIZ/mIZ/mIZ///fX//fX//fX//fX//fX1Miy//fXp5aMmIZ/
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/1p6Y1p6Y1p6Y1p6Y
mIZ/mIZ/hb7cfMbufMbugcbofMbufMbugcbogcbogcbofMbufMbufMbugcbo
fMbufMbugcbofMbugcbogcbogcbogcbogcbofMbugcbogcbogcbogcbogcbo
gcbofMbugcbofMbugcbogcbogcbogcbofMbugcbogcbodMnvgcbofMbugcbo
gcbofMbugcbogcbogcbogcbofMbufMbugcbofMbufMbugcbofMbufMbugcbo
fMbugcbogcbogcbofMbufMbugcbogcbofMbufMbufMbugcbogcbogcbofMbu
fMbufMbufMbufMbufMbufMbufMbugcbofMbufMbugcbofMbugcbofMbufMbu
gcbogcbofMbufMbuiMTofMbugcbofMbufMbufMbufMbugcbofMbugcbofMbu
gcboiMToiMTogcbogcboiMTogcbogcbofMbuiMTofMbufMbugcboiMTogcbo
gcbogcbogcbofMbufMbufMbufMbufMbuiMTogcbogcbofMbufMbugcbofMbu
fMbugcbogcbofMbufMbumIZ/n42F7t/I3dfa3dfa3dfa3dfa3dfamIZ/nIqC
qpqPsaGUtqeZ//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fXmIZ/tKOX0sXA
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX39na3dfa3dfa3dfa//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX0sWw
xLelp5eMmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/wI6I1p6Y1p6Y1p6Y
mIZ/mIZ/gb7hgcbogcbofMbugcbogcboiMTofMbufMbugcbogcbogcbofMbu
gcbogcbofMbugcbofMbuiMTofMbufMbufMbugcbofMbufMbufMbufMbufMbu
fMbugcbofMbugcbofMbufMbufMbuiMTogcbogcbofMbugcbofMbugcbofMbu
fMbugcbofMbufMbufMbufMbuiMTogcbofMbuiMTogcbofMbugcbogcbofMbu
gcbofMbufMbufMbugcbogcbofMbufMbugcbogcbogcbofMbufMbufMbugcbo
gcbogcbogcbogcbogcbogcboiMTofMbugcbogcbofMbugcbodMnvgcbogcbo
fMbufMbuiMTofMbugcbofMbugcbogcbogcbogcbofMbugcbofMbufMbufMbu
fMbufMbufMbufMbufMbufMbufMbugcbofMbufMbugcbofMbufMbufMbufMbu
fMbufMbugcboiMTogcbogcboiMTofMbufMbufMbugcboiMTofMbugcbogcbo
fMbufMbugcbogcboiMTomIZ/7t/I2szK3dfa3dfa3dfamIZ/oI+Gq5uPs6OW
vrCfyr2q//fX//fX//fX//fXmIZ///fX//fX//fX//fX7OLHmIZ/vaye59vX
7uPf//////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX2c22zsGtn46FmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6I1p6Y1p6Y1p6Y
mIZ/mIZ/grzffMbugcbofMbufMbufMbugcbogcbofMbufMbufMbuiMTofMbu
fMbugcbofMbugcbofMbuiMTogcbogcbofMbugcbogcbogcbogcbogcbogcbo
iMTogcbofMbuiMToiMTogcbofMbufMbuiMToiMToiMTogcbofMbugcbogcbo
fMbugcbogcbogcbogcbofMbufMbugcbofMbufMbufMbufMbufMbuiMToiMTo
fMbugcbogcboiMTofMbugcbogcbofMbufMbufMbugcbogcboiMTofMbufMbu
fMbufMbufMbufMbufMbufMbugcboiMToiMTogcbofMbuiMTofMbufMbufMbu
gcbogcbofMbugcbofMbugcbofMbuiMToiMTofMbugcboiMTogcbogcboiMTo
fMbugcbogcbogcbogcboiMToiMTofMbufMbugcboiMToiMTofMbugcbogcbo
iMTogcboiMTofMbuiMTogcbofMbufMbugcbogcbofMbufMbuiMTofMbufMbu
gcboiMTogcbofMbufMbumIZ/mIZ/2szK3dfamIZ/mIZ/saGUt6iau6yd//fX
//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX0sWwmIZ/7uPf7uPf
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX1sq0tqeZopGImIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6I1p6Y1p6Y1p6Y
1p6YmIZ/hrvYgcbofMbugcbogcbofMbufMbufMbugcbogcbogcbofMbuiMTo
gcbofMbuiMToiMTofMbufMbufMbuiMTogcbofMbuiMToiMTofMbuiMTofMbu
fMbufMbugcbofMbufMbuiMTofMbugcbofMbufMbufMbufMbugcbofMbufMbu
gcboiMTogcbofMbufMbugcbogcbofMbugcbogcboiMTogcbogcbogcbofMbu
gcboiMTofMbufMbufMbuiMToiMTogcboiMTogcbofMbufMbufMbugcbogcbo
gcbogcboiMTogcbogcbogcbofMbufMbufMbuiMTogcbofMbugcbogcbogcbo
gcbogcbofMbuiMTofMbugcbofMbufMbugcboiMTofMbufMbugcbofMbugcbo
fMbufMbuiMTofMbufMbufMbugcbogcbogcbofMbufMbugcbofMbufMbufMbu
fMbufMbugcbofMbufMbugcbogcbogcboiMTogcbogcbofMbuiMTogcboiMTo
fMbuiMTofMbugcboiMTomIZ/mIZ/2szK3dfamIZ/rJyQ//fX//fX//fX//fX
//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fXtaaYmIZ/7uPf7uPf
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX18y12c22x7mnnIqCmIZ/3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/wI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/hrvXiMToiMTogcbogcbogcbogcboiMTofMbuiMTogcbofMbuiMTo
gcbofMbufMbugcbogcbogcbofMbufMbugcbofMbufMbugcbofMbuiMTogcbo
gcbofMbugcbofMbufMbugcboiMTofMbugcbogcbogcbogcboiMTogcboiMTo
fMbufMbugcboiMToiMToiMToiMTofMbuiMTofMbuiMTofMbufMbufMbufMbu
fMbuiMTofMbuiMTofMbufMbufMbufMbufMbugcbogcbogcbogcboiMToiMTo
iMTofMbufMbugcbofMbugcbofMbufMbufMbugcbogcboiMTogcboiMTogcbo
iMTofMbugcbogcboiMToiMTogcbogcbogcbofMbugcboiMToiMTogcboiMTo
iMToiMTofMbugcbogcbogcboiMToiMToiMTogcbogcbogcboiMTogcbogcbo
iMTogcbogcbogcboiMTogcbogcboiMTofMbuiMTofMbugcbofMbuiMTofMbu
gcbofMbugcbogcbogcbomIZ/mIZ/2szKmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fXnIqCsZ+U7uPf////
//////////////fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX8uvY3dfa3dfa3dfa3dfamIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX2c2218u0taaYmIZ/3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/jLnXgcbofMbufMbuiMTofMbugcbofMbugcbofMbufMbugcbofMbu
iMTogcbogcbogcbofMbuiMTogcboiMTogcbogcbofMbuiMToiMTogcbofMbu
iMTogcbogcbogcbogcbofMbufMbugcbofMbufMbugcboiMTogcboiMTofMbu
gcboiMToiMTogcbofMbufMbugcboiMTofMbugcbofMbuiMTogcbogcbogcbo
gcbogcbogcbofMbugcbogcboiMTogcbogcboiMToiMTogcbofMbufMbufMbu
fMbugcboiMToiMTogcboiMTogcbogcbogcboiMTofMbufMbufMbufMbuiMTo
iMToiMTofMbugcbofMbufMbuiMToiMTogcbogcbofMbufMbugcbofMbugcbo
gcbogcboiMToiMTogcbofMbufMbufMbufMbugcbofMbugcbogcbogcbogcbo
fMbuiMTofMbugcbogcboiMTofMbugcbogcboiMTogcbogcbofMbugcbogcbo
gcboiMTofMbufMbugcbomIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fXmIZ/u6ud7t/I////
//////////////fX//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX6+XZ3dfa3dfa3dfamIZ/mIZ///fX
//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXybypoI+GmIZ/3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/grzeiMToiMTofMbuiMToiMTogcboiMTogcboiMTogcbogcbogcbo
gcbofMbuiMToiMTofMbufMbugcboiMTofMbuiMTofMbufMbugcboiMTofMbu
gcbofMbuiMTogcboiMTogcboiMToiMToiMTofMbufMbugcbogcbogcbofMbu
fMbufMbufMbugcbogcbofMbugcbogcbogcbogcbogcbogcboiMToiMTofMbu
fMbuiMTogcbogcbofMbugcbogcboiMTofMbufMbuiMToiMTogcbogcbogcbo
iMTogcbofMbuiMTofMbuiMToiMToiMTofMbuiMTogcboiMTogcbofMbugcbo
gcbofMbugcbofMbuiMToiMTofMbufMbufMbuiMTogcboiMToiMToiMToiMTo
gcbogcbofMbufMbuiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMTofMbu
iMTofMbuiMTogcboiMTofMbugcboiMTofMbugcboiMToiMTogcboiMTofMbu
gcbogcboiMToiMToiMTofMbumIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fXmIZ/wrGi7t/I////
//////////////fX//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX+vLX493Z3dfa3dfa3dfamIZ/mIZ///fX
//fXm4mB2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX1cmz0cSwpZWKmIZ/3dfa3dfa
3dfa//fX//fX//fX//fXmIZ/mIZ/mIZ/t4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/iMTofMbugcboiMTogcbofMbuiMTogcbogcbogcboiMToiMTofMbu
fMbuiMTofMbugcbogcboiMToiMTofMbuiMTogcboiMTogcboiMTogcbogcbo
iMToiMTogcbofMbugcboiMTofMbugcbogcboiMTogcboiMTofMbugcboiMTo
iMTogcboiMTogcboiMTogcbogcbogcboiMTogcboiMToiMTogcbogcboiMTo
iMTofMbugcboiMToiMToiMToiMTofMbugcboiMTofMbugcboiMToiMToiMTo
fMbugcbogcbofMbugcbogcbofMbufMbugcbogcboiMTogcboiMTogcboiMTo
iMToiMToiMTogcbogcboiMTogcboiMTofMbuiMTogcbofMbugcbofMbuiMTo
iMToiMTogcbofMbuiMTogcboiMTogcbofMbugcboiMTofMbufMbugcbogcbo
gcbogcboiMTofMbuiMToiMTofMbuiMTogcbofMbugcboiMTofMbuiMToiMTo
iMTogcbogcbogcboiMTofMbumIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/xrWm7t/I////
//////////////////fX//fX//////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+fLY+fLX3tja3dfa3dfa3dfamIZ/3dfa//fX
//fXmYeA18nH3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXqpmOmIZ/mIZ/
//fX//fX//fX//fXmIZ/mIZ/mIZ/t4eCt4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/gcbofMbuiMToiMTogcbofMbufMbuiMToiMTo
gcboiMToiMToiMTogcbofMbuiMTogcbofMbufMbuiMTofMbuiMToiMTofMbu
gcbofMbuiMTogcbofMbugcbogcbogcbogcboiMTofMbuiMToiMTogcbogcbo
iMTogcboiMTofMbuiMToiMToiMTofMbuiMTofMbufMbuiMTofMbugcbogcbo
iMToiMTofMbugcbofMbufMbuiMToiMTogcbogcbogcbogcbogcbofMbugcbo
iMToiMToiMToiMToiMToiMToiMToiMTogcbofMbugcbofMbuiMTofMbugcbo
gcbogcbogcboiMToiMTogcboiMTogcbogcbogcboiMToiMTogcbogcbofMbu
fMbugcboiMToiMTogcboiMTofMbuiMTogcboiMTogcboiMToiMToiMToiMTo
iMToiMTofMbugcbogcbofMbugcbogcboiMToiMToiMTogcbogcbogcbofMbu
fMbuiMToiMTofMbugcbomIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9+7QmIZ/wrGi7t/I////
////////7uPfmIZ///////////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+vLX3dfa3tja3dfa3dfa3dfamomCmIZ///fX//fX
//fXmIZ/6drE2szK//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//////////fX//////fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/pHl0t4eCt4eCwI6IwI6IwI6I1p6Y1p6Y1p6Y
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/k8jmfMbufMbuiMToiMToiMTogcbogcbo
gcbogcbofMbufMbuiMTogcbofMbuiMToiMToiMTofMbuiMTofMbufMbuiMTo
gcboiMTogcboiMTogcboiMToiMToiMToiMTogcboiMTogcbofMbuiMToiMTo
fMbuiMTofMbuiMTogcbofMbufMbuiMTofMbuiMTogcbofMbugcboiMTofMbu
gcbogcbogcboiMToiMTogcbogcbogcboiMToiMToiMToiMToiMTogcboiMTo
fMbugcbogcbogcbofMbugcbogcbogcboiMToiMToiMTogcbogcboiMToiMTo
iMToiMTofMbugcboiMTogcboiMToiMToiMTofMbugcboiMToiMTogcboiMTo
iMTogcbogcboiMTofMbuiMTogcboiMTogcboiMTogcbogcbogcbogcbogcbo
gcboiMToiMToiMToiMToiMToiMTofMbugcbofMbuiMToiMToiMToiMToiMTo
gcbofMbuiMToiMTogcbomIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/uqmc//fX////
//fX////283LmIZ///////////////////////fX//fX//fX//fX////////
//////fX//fX//fX//fX4Nra3dfa3dfa3dfa3dfanYyFmIZ/mIZ///fX//fX
//fXmIZ/xre02szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//////////fX//fX//////fX//////////////fX
mIZ/mIZ/mIZ/mIZ/mIZ/pHl0pHl0t4eCt4eCwI6IwI6IwI6I1p6Y1p6YmIZ/
mIZ/momBmIZ/mIZ///fXmIZ/mIZ/mIZ/isTofMbugcbogcboiMTogcboiMTo
gcboiMToiMTogcboiMToiMTofMbugcbogcboiMTogcboiMToiMTogcboiMTo
gcboiMTofMbuiMTogcbofMbufMbufMbuiMTogcboiMToiMTogcbogcboiMTo
fMbuiMTogcboiMToiMToiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMTo
iMToiMTofMbugcboiMTofMbuiMTofMbufMbufMbufMbufMbuiMTogcboiMTo
iMToiMToiMToiMToiMToiMToiMTofMbugcbofMbuiMToiMTogcbofMbugcbo
fMbugcboiMToiMTogcboiMTogcbofMbugcboiMToiMTofMbugcboiMToiMTo
gcboiMToiMToiMToiMTogcboiMTogcboiMTogcboiMToiMToiMToiMToiMTo
iMTogcbofMbugcbogcbogcbogcboiMToiMToiMTofMbugcbogcboiMTogcbo
iMToiMToiMTomIZ/jsbomIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/pZSK//fX//fX
//fX2szKmIZ///////////////////////////fX//fX//fX////////////
//fX//fX//fX//fX493Z3dfa3dfa3dfa3dfarqCcmIZ/mIZ///fX//fX//fX
//fXmIZ/opGK2szK3dfa//fX//fX//fX//fX//fX//fX//fX////////////
//fX//fX//fX//fX//fX//fX//fX//////////////////fX//fX////////
////////mIZ/mIZ/pHl0pHl0pHl0t4eCt4eCwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/6eLZ/PTX+vLX/vbX//fXmIZ/mIZ/mIZ/mIZ/mIZ/iMTogcboiMTogcbo
iMTogcbogcboiMToiMTogcboiMToiMToiMTogcboiMTogcbogcboiMTofMbu
iMTogcboiMTogcboiMToiMToiMToiMTogcboiMTogcbogcboiMToiMTogcbo
iMTogcboiMTofMbugcbogcboiMTogcboiMTogcbogcbogcboiMToiMTogcbo
gcbogcboiMToiMTogcboiMTofMbuiMToiMToiMToiMToiMTogcboiMTogcbo
fMbufMbufMbugcbogcbogcbofMbuiMToiMToiMToiMToiMToiMToiMToiMTo
iMTogcbogcboiMTogcboiMToiMToiMTogcbogcboiMToiMTogcbofMbuiMTo
gcbogcbofMbugcboiMTofMbuiMToiMToiMTogcboiMTogcbofMbuiMToiMTo
iMToiMToiMToiMToiMToiMToiMTogcbogcboiMToiMToiMTofMbuiMTogcbo
gcbogcboiMTomIZ/mIZ/mIZ///fX//fX//////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9OzYmIZ/saCb//fX//fX
3dfa2szKmIZ///////////////////////////fX////////////7uPf7uPf
//fX//fX//fX8OnY3dfa3dfa3dfa3dfatKajmIZ/mIZ///fX//fX//fX//fX
//fXmIZ/mIZ/2cvJ2szK//fX//fX//fX//fX//fX//fX//fX//fX////////
//////////fX//fX//fX//fX//fX//fX//////////////fX//fX////////
////////////mIZ/mIZ/pHl0pHl0t4eCwI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/3dfa5t/Z9e3Y/vbX+vLX//fX/vbXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/iMTo
iMToiMTogcbogcboiMTogcbogcbogcboiMTofMbuiMToiMToiMToiMTogcbo
iMToiMToiMToiMTogcbogcbogcboiMTogcboiMToiMToiMTofMbuiMToiMTo
iMTogcboiMToiMToiMTogcboiMTogcboiMToiMToiMTogcbogcboiMToiMTo
iMTogcbogcboiMToiMToiMTogcboiMTogcbogcbogcboiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMTogcbogcbogcbofMbufMbuiMTogcbogcbogcbo
iMToiMToiMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMTogcboiMToiMTofMbuiMToiMTogcboiMToiMTofMbufMbu
iMToiMTogcboiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToiMToiMTo
iMToiMTogcbomIZ/n46F7t/I//fX//////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6OHZmIZ/tqah3dfa//fX
287KmIZ/////////////////////////////////////////////7uPf3c/N
mIZ///fX+fLX3tja3dfa3dfa3dfatqqnnIqCmIZ///fX//fX//fX//fX//fX
//fX//fXmIZ/y7y52szK3dfa//fX//fX//fX//fX//fX//fX//fX////////
//////////fX//fX//fX//fX//fX//fX//fX////////////////////////
////////////////mIZ/mIZ/mIZ/t4eCwI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
mIZ/3dfa3dfa5N3Z+vLX/vbX9e7Y//fX/vbX/fXXmIZ/mIZ/mIZ/mIZ/mIZ/
gcboiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMTofMbuiMToiMTo
iMTogcboiMTofMbuiMToiMToiMTogcboiMToiMToiMTofMbuiMToiMTogcbo
gcboiMToiMToiMTogcboiMToiMTomIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/pdHklcjmisTogcboiMToiMToiMToiMTofMbugcbogcbo
gcboiMTogcbogcbogcboiMToiMToiMToiMToiMToiMTofMbuiMToiMToiMTo
iMToiMToiMTogcbogcboiMTogcboiMToiMTogcbogcboiMTogcbogcboiMTo
gcboiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMToiMToiMTogcbo
iMToiMTogcbogcbogcboiMToiMToiMTogcbofMbuiMToiMToiMToiMTogcbo
iMToiMToiMTomIZ/0MCu7t/I//fX//////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX8uvY3tjamIZ/tKSf3dfa3dfa
59jImIZ/////////////////////////////////////////7uPf7uPfmIZ/
8u/w8+zY4tva3dfa3dfa3dfas6ajmIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fXmIZ/pJON2szK3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//////////////fX//fX//fX//fX//fX//fX//fX////////////////////
//////////////////fX//fXmIZ/mIZ/wI6IwI6IwI6I1p6Y1p6Y1p6YmIZ/
3dfa3dfa3dfa3dfa3dfa9u/Y//fX9/DY/vbX//fX//fXmIZ/mIZ/mIZ/mIZ/
mIZ/iMToiMTogcboiMToiMToiMTogcboiMToiMToiMToiMTogcboiMTogcbo
iMTogcboiMToiMTogcboiMToiMTogcbogcbogcboiMToiMTogcboiMToiMTo
iMTogcbogcboiMToiMTomIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I7t/I
7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/o83mmcrmiMTofMbuiMToiMToiMToiMTo
gcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMTofMbuiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMTogcboiMToiMToiMToiMToiMToiMTogcboiMTogcboiMTo
gcboiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTofMbuiMToiMTo
gcboiMToiMTomIZ/zr6t//////////fX//////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX/PTX4Nra3dfamIZ/s6Oe3dfa2szK
mIZ/7uPf////////7uPf////////////////////////////7uPfmIZ/9PLz
7uzt3tja3dfa3dfa3dfa3dfamIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//////////////////fX//fX//////fX//fX////////////////////////
//////////////////////fXwI6ImIZ/mIZ/wI6I1p6Y1p6Y1p6Y1p6YmIZ/
3dfa3dfa3dfa3dfa3dfa3tja8OnY/vbX+/PX/vbX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/gcboiMToiMToiMTofMbuiMToiMToiMTogcboiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
gcbomIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/ImIZ/mIZ/oI6GmIZ/mIZ/mIZ/icjonszmiMToiMToiMToiMTo
iMToiMToiMTogcbogcbogcboiMTogcboiMTogcboiMTogcboiMTogcboiMTo
iMToiMToiMToiMTogcboiMTofMbufMbuiMToiMTogcboiMToiMToiMToiMTo
gcboiMToiMToiMTofMbuiMToiMToiMToiMTofMbuiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMTogcboiMToiMToiMTofMbuiMToiMTofMbuiMToiMTo
iMTogcbomIZ/mIZ/1se0//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX6OHZ3dfa2szKmIZ/q5uV3dfa2szK
mIZ//Pz8////////7uPf//fX////////////////////7uPf7eLemIZ/7uvs
3dfa3dfa3dfa3dfa3dfamYeAmIZ///fX//fX//fX//fX6+HG6d/EqJiNqJeM
mYeAmIZ/mIZ/mIZ/vK2o2szK3dfa3dfa//fX//////////fX//fX//fX//fX
//fX//////////////////fX//fX////////////////////////////////
//////////////////////fX//fXmIZ/mIZ/mIZ/1p6Y1p6Y1p6YmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa8erY+/PX/PTX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/mIZ/mIZ/iMToiMTogcboiMToiMTogcboiMTogcboiMToiMTo
iMToiMToiMToiMTofMbuiMToiMToiMToiMTokqKxkqGwlJqjl4uImIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/Iy7ur7t/ImIZ/mIZ/mIZ/mIZ/ksrmiMTogcboiMTo
iMToiMToiMToiMToiMTogcboiMTogcboiMToiMToiMTofMbuiMToiMToiMTo
iMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMTofMbuiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbok8HhiMToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTo
gcboiMTomIZ/mIZ/5NjT//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7ebZ3dfa2szK2szKmIZ/oZCK3dfa2szK
mIZ///////fX////7t/ImIZ/////////////////////7uPf7ePfmIZ/3dfa
3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX+O/Rrp6SmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mYeAm4mD2szK2szK3dfa3dfa//////////////fX//////fX
//////fX//////////////////////fX////////////////////////////
//////////////////fX//////fX//fXmIZ/mIZ/mIZ/1p6Y1p6YmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja8OnY9u/Y/vbX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/jbXRjLrYiMLmk8HhiMLmiMLm
iMLmiMTogcboiMTok8HhisDhjLrZibXOkqO1mIiCmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/IoI6GmIZ/mIZ/mIZ/mIZ/lsjmiMToiMTo
gcbogcboiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMTo
iMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToiMTogcbo
iMToiMToiMToiMTok8HhiMToiMToiMToiMToiMToiMTok8HhiMToiMToiMTo
iMToiMTomIZ/mYeA7uPf//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3tja3dfa2szKmIZ/3dfamIZ/3dfa3dfa
mIZ///fX//fX7t/I7t/ImIZ///fX////////////////7uPf6NnImIZ/3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX8ejLqZmNmIZ/mIZ/mIZ/mIZ/mIZ/rp6S
oZCHmIZ/mIZ/mIZ/mIZ/uKej2szK2szK3dfa//fX//////////////fX////
//////////fX////////////////////////////////////////////////
//////////////////fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa7+jY+fHY//fX//fX//fX//fX
//fX//fX//fX//fX/vbX+/PXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/isToiMTo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMToiMTok8HhiMToiMToiMToiMToiMTogcboiMToiMTo
iMToiMToiMToiMToiMToiMToiMTogcboiMToiMToiMToiMTogcboiMToj8Hn
gcboiMToiMTogcbogcboiMToiMToiMToiMToiMToiMTogcbogcboiMToiMTo
iMToiMTomIZ/rJ2Y7t/I//////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa2szK2szKmIZ/3dfaqJaMz8C92szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////////fX7t/I7t/ImIZ/3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ///fX29C5wLGhmIZ/mIZ/mIZ///fXmIZ/saGU/fTV
oI6GmIZ///fX//fXmIZ/mIZ/39PP2NHU2szK3dfa//fX////////////////
////////////////////////////////////////////////////////////
//fX//////////////fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja8OnY//fX//fX//fX//fX
//fX/vbX//fX//fX//fX/PTX/vbX//fX//fX//fXmIZ/nYuDoI6Gn46FnIqC
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/jMbo
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMTok8HhiMToiMToiMToiMTo
iMToiMToiMToiMTok8HhgcboiMToiMToiMToiMToiMToiMToiMToiMTok8Hh
iMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTok8Hh
iMToiMTok8HhiMTok8HhgcboiMToiMToiMToiMToiMToiMToiMToiMToiMTo
k8HhiMTomIZ/3tjW//////////////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX4Nra3dfa3dfa2szK2szKmIZ/3dfaqJaM08TC2szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////fX//fX7t/I69zImIZ/3dfa3dfa
3dfa3dfamIZ/mIZ///fX/vbWw7WkmIZ/mIZ//vbW//fX//fXmIZ///fX+vLT
mIZ///fX/fXW/fXV/vbWmIZ/r52S0cK/2szK3dfa3dfa////////////////
//////////////////////////////////////////////////////////fX
//////////////////fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na/fXX/vbX//fX//fX
//fX//fX//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/mIZ/
isToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
k8HhiMToiMToiMTogcboiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbo
iMToiMToiMToiMToiMToiMToiMToiMTok8HhiMToj8Hnk8HhiMToiMToiMTo
iMToiMTogcboiMTogcboiMTok8Hhj8HniMToiMToiMToj8HniMTok8Hhk8Hh
gcbomIZ/mIZ//fz8//////////////////////fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/3dfamIZ/2su32szK
mIZ///fX//fX7t/I7t/ImIZ///fX//////fX7t/I7t/ImIZ/3dfa3dfa3dfa
3dfamIZ/mIZ///fX//fXu62dmoiAmIZ/mIZ//PTV//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/s6Od0MG+2szK3dfa3dfa////////////
//////////////////////////////////////////////////////fX//fX
//fX//////////////fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+/PX/PTX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
isTok8HhiMToiMToiMTok8HhiMTok8HhiMToiMToiMToiMToiMToiMToiMTo
iMToj8HniMToiMToiMTok8Hhgcbok8HhiMToj8Hnj8Hnk8HhiMToj8HniMTo
j8Hnk8HhiMToiMToiMTok8HhiMTogcboiMToiMTogcboiMToiMToiMToiMTo
iMToj8HniMToiMToiMToiMTogcbok8HhiMToj8HniMToiMTogcbogcboiMTo
iMTomIZ/mIZ////+//////////////////////////fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa2szK2szKmIZ/3dfa3dfamIZ/z7+txLOk
mIZ///fX//fX7t/I7t/ImIZ///fX//fX//fX7t/I6tvIpZSO3dfa3dfa3dfa
mIZ/mIZ/mIZ///fXu6ydmIZ/mIZ///fXmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/nIqE08XC2szK3dfa////////////
//////////////////////////////////////////////////////////fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9e7Y/vbX/vbX//fX
//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/
mIZ/iMToiMToiMToiMToiMTogcboiMToiMToiMTok8HhiMTok8Hhk8Hhgcbo
k8HhiMToiMToj8HniMToiMTok8HhiMToiMTok8HhgcbogcboiMToiMToj8Hn
iMToiMTok8HhiMToj8HniMToj8Hnj8HniMToiMToj8HniMToiMToiMToiMTo
iMTogcbok8HhiMToj8HniMTok8HhgcboiMToiMToiMToiMToj8Hnj8HniMTo
iMTomIZ/rZ2R//////////////////////////////fX//fX//fX//////fX
//fX//fX//fX3dfa3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/wbCiw7Kj
mIZ///fX//fX7t/I7t/ImIZ///fX//fX//fX7d7I4dTJuKik3dfamIZ/mIZ/
mIZ/mIZ///fX//fXnIuDmIZ///fX//fXmIZ///fX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fXmIZ/opGM2szK3dfa3dfa////////
////////////////////////////////////////////////////////////
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+vLX/PTX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/j8HniMToiMToiMToj8HniMToiMToiMTogcbok8Hhgcbogcbok8Hh
iMTok8HhiMTok8HhiMToiMToiMTok8HhiMTok8Hhj8Hnk8HhiMTok8Hhgcbo
iMToiMToiMToiMToiMToiMTok8HhiMTok8HhiMToiMToiMToiMTok8HhiMTo
j8Hngcboj8Hnk8HhiMToiMToj8Hnk8Hhk8Hhk8HhiMToiMToiMToj8HniMTo
mIZ/mYeB9vTz//////////////////////////////fX//////////////fX
//fX4Nve3tja3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/sqGVzb2s
mIZ///fX//fX//fX7t/ImIZ///fX//fX//fX7d7I287KpZaQ3dfamIZ/m4qD
nYuD//fXrJyQ3NG5mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/qpuWmoiB2szK3dfa3dfa////
//////////////////////////////////////////////fX////////////
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa8enY+/PX//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImoiA
mIZ/mIZ/mIZ/iMToj8HniMToiMToiMToiMToiMToiMToiMToj8HniMToiMTo
k8HhiMTok8HhiMToiMToiMToiMToiMToiMToiMToiMToiMToiMTogcbok8Hh
k8HhiMToj8HniMToiMTok8HhiMTok8HhiMToiMTok8HhiMTok8HhiMToj8Hn
iMToj8HniMToiMToiMToiMToiMToiMToiMToiMToiMTok8HhiMTok8HhiMTo
mIZ/pZSN////////////////////////////////////////////////////
3dfa3dfa3dfa3dfa3dfa2szKmIZ/mIZ/3dfa3dfa3dfa3dfamIZ/oI+I1cWz
mIZ///fX//fX//fX7t/ImIZ///fX//fX//fX59nIrZyX3dfa3dfamIZ/4te+
//fX//fXy76qx7mn//fX29C5//fX//fX//fX//fXmIZ/o5ONz8bH19DS3dfa
3dfa3dfa3dfa3dfa3dfa3dfaxry7y8HCmIZ/mIZ/mIZ/opCK2szK3dfa3dfa
//////////////////////////////////////////////////fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ/fXX//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/Ix7en
n46FmIZ/mIZ/mIZ/iMToiMTok8HhiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToiMToiMTok8HhiMToiMToiMTok8HhiMToiMToj8HniMToiMTo
iMTok8Hhk8Hhk8HhgcboiMToiMToiMToiMToiMTok8HhiMToiMTok8HhiMTo
iMTok8HhiMToiMToiMTok8HhiMToiMToiMTok8HhiMToiMToiMTok8HhiMTo
mIZ/7uPf//////////////////////////////fX////////////////3dfa
3dfa3dfa3dfa3dfa2szKmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamYeAw7Ok
mIZ/3dfa//fX//fX7t/ImIZ///fX//fX7ebZ2szKmoiC3dfamIZ/n4+J9ezP
//fX//fXpZSKoZCH//fX//fX//fX//fX//fXmIZ/wLW02NLU3dfa3dfa3dfa
1c3P0srL19DT2tTW19DS9+7Q3dfa3dfa3NbZmIZ/mIZ/mIZ/wLGs2szK3dfa
//////////////////////////fX//////////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z+fHY//fX
//fX//fX//fX/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
zLyrp5aMm4iBmIZ/iMToiMTok8Hhk8Hhj8HniMTok8Hhk8HhiMTok8HhiMTo
iMToiMToiMTok8Hhj8HniMToiMTok8Hhj8HniMToiMTok8Hhk8HhiMToiMTo
j8HniMTogcboiMToj8HniMToiMToiMToiMToiMToiMToiMToiMToiMToiMTo
iMToiMToiMToj8Hnk8Hhgcbok8Hhk8Hhk8HhiMToiMToiMToiMToiMTomIZ/
mIZ///////////fX//////////////////////fX////////9OzY3dfa3dfa
3dfa3dfa3dfa2szK2szKmIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfamIZ/
mIZ/mIZ///fX//fX7t/ImIZ///fX//fX4tza2szKmIZ/3dfamYiB29C5//fX
//fX//fXmIZ/mIZ///fX//fX//fX//fXmIZ/t6uo3NXY3NXYq52ZmIZ/moiB
nYyKmomEno2NmoiBmIZ/mIZ/pZWKz8Kuu6+t2NLUuqucmIZ/mIZ/wrOv2szK
3dfa//////////fX//////////////fX//////////fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na+PDY/vbX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
y7urx7ano5GKmIZ/mIZ/mIZ/iMToiMTok8Hhk8HhiMTogcbok8HhiMToj8Hn
k8Hhk8HhiMTok8Hhk8Hhk8HhiMTok8HhiMTok8HhiMToiMTok8Hhj8Hnk8Hh
iMTok8HhiMToiMTok8Hhk8Hhk8Hhk8Hhj8HniMToj8Hnk8HhiMTok8Hhk8Hh
iMTok8Hhk8HhiMTok8HhiMTogcboiMToiMToiMTok8Hhk8HhiMToj8HnmIZ/
t6eh//////////fX//////////////////fX////////+/r74dze3dfa3dfa
3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/3dfa//fX7t/ImIZ///fX//fX2szK2szKmIZ/3dfaycDA//fX//fX
//fXmIZ/mIZ///fX//fX//fX//fXmIZ/vK2d3NbZ2dLVtqeZmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/1M3P2tTWzMPEnIqCmIZ/wLCs
2szK3dfa3dfa//////////////////fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXwrWj
mIZ/no2H3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+PHY/PTX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/I7t/IwrGjopCHmIaAmIZ/j8HniMToiMToiMToj8HniMToiMTok8HhiMTo
iMToiMToiMToiMToiMTogcbok8HhiMToiMToiMToiMToiMTogcbok8HhiMTo
iMToiMToj8Hnk8HhiMToiMToiMToiMTok8Hhj8Hnk8HhiMToj8HniMToiMTo
k8HhiMToiMToiMToiMToiMToj8HniMTok8Hhk8HhiMToiMToiMTomIZ/mIZ/
69/b//////fX/////////////////////////////v7+5+DZ3dfa3dfa3dfa
3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/3dfa3dfa7t/I7t/ImIZ///fX2szK2szK3dfam4qC+O/R//fX//fX
//fXmIZ/mIZ//fTV//fX//fXmIZ/p5eM2tTW2tTWv7GhmIZ/mIZ/jCBHixxB
ixxBjCBHjCBHjCBHoCVKoCVKjCBHm2NsmYN9mIZ/q5yY3dfa0MjJoJCKmIZ/
ybq32szK2szK//fX//////////////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX8+rN
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9+/Y/PTX
/PTX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/IyrmpxLSlmoiBmIZ/mIZ/iMToiMTok8HhiMToiMTok8HhiMTok8Hh
iMTok8HhiMToiMToj8HniMTok8Hhk8Hhj8Hnk8Hhk8Hhk8HhiMToj8Hnk8Hh
k8Hhk8HhiMToj8HniMTok8HhiMToiMTok8HhiMToj8Hnk8Hhk8Hhj8HniMTo
j8HniMTok8HhiMToj8HniMToj8HniMToiMTok8HhiMTok8HhiMTomIZ/moiB
///+//////fX//////////////fX////////////9PLz3dfa3dfa3dfa3dfa
2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/3dfa3dfa7t/I7t/ImIZ///fX2szK2szKmIZ/uKmb//fX//fX//fX
mIZ/mIZ///fX//fX//fX//fXn46F8OfL3NbZzL+rmIZ/1NH3jCBHjCBHixxB
jCBHjCBHjCBHkRxEmRdBrxpDrxpDmRdBmRdBmRdBmIZ/oI+JzsXGwba1m4mD
sqOV2szK2szK2szK//fX//fX//////////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX/f39
pJOJmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9u7Y/fXX
9u/Y//fX//fX//fX//fX//fXmIZ/opGH//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/IyLiorZyRmIZ/mIZ/k8HhiMTok8Hhk8HhiMTok8HhiMToiMTo
k8Hhj8Hnk8Hhk8Hhk8Hhk8HhiMToiMTok8HhiMToj8HniMTok8Hhk8HhiMTo
iMToiMTok8Hhk8Hhk8HhiMTok8HhiMToiMTok8Hhk8HhiMToiMTok8Hhk8Hh
k8Hhk8HhiMTok8Hhk8Hhk8Hhk8Hhk8Hhk8HhiMTok8HhiMTok8HhmIZ/xLSl
//////fX//fX//fX//////////fX////////+/r73dfa3dfa3dfa3dfa2szK
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfamIZ/
mIZ/mIZ/mIZ/3dfa2szK7t/ImIZ/3dfa2szK2szKmIZ/6+HG//fX//fX//fX
mIZ///fX//fX//fX//fX//fX+/PU/vbW6uDFmYeB1NH31NH3oCVKoCVKixxB
kRxEkRxEkRxEnBQ/nBQ/nxI9nxI9txQ/txQ/nxI9nBQ/mIZ/n4+J2tPW6OPi
mIZ/o5KNwbKu2szK2szK2szK//fX//////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX7t/I7eLe
ysG9mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9O3Y/vbX
/PXX//fX//fX//fX//fXmIZ/mIZ/5dvB//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/Izr6twbGimIZ/mIZ/mIZ/k8HhiMToiMTok8HhiMToj8Hnk8Hh
k8HhiMToj8HniMToiMTok8Hhk8HhiMTok8Hhk8Hhk8HhiMToiMToj8Hnk8Hh
k8HhiMToiMToj8Hnk8Hhj8Hnk8Hhk8HhiMToiMTok8HhiMToiMToiMToiMTo
j8Hnk8HhiMToiMToj8HniMToiMToiMTok8Hhj8Hnk8HhiMToiMTomIZ/3c66
//////fX//fX//fX//fX//fX//fX//fX+/PX5eHj3dfa3dfa3dfa2szKmIZ/
mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/mIZ/1NH3oCVKoCVKoCVKmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/2szK3dfa2szKmIZ/3dfa2szK2szKmIZ/x7qn//fX//fX//fX
//fX//fX//fX//fX//fX/fTV//fX5tzCmIZ/mIZ/1NH3oCVKoCVKoCVKpiFH
kRxEkRxElRpCohA8ohA8////////////vRA9uhI+sxdBmRdBmIZ/m4qE2tTW
19DS3dfapJOJwrOv2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX7t/I
7uzqmIZ/1M3O3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa8+zY/vbX
/vbX//fX//fX//fX//fXmIZ/vrCg//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/IzLyrp5WMmIZ/mIZ/k8Hhk8HhiMTok8Hhk8HhiMToj8Hn
iMTok8Hhk8Hhk8Hhk8HhiMToj8Hnk8Hhj8HniMToj8Hnk8Hhk8Hhk8HhiMTo
iMTok8Hhk8Hhk8HhiMTok8Hhj8HniMTok8Hhk8HhiMTok8Hhk8Hhk8Hhk8Hh
k8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8HhiMTok8HhiMTok8Hhk8HhmIZ/28u4
//fX//fX//fX//fX//fX//fX//fX//fX7ebZ3dfa3dfa3dfa2szK2szKmIZ/
mIZ/3dfa3dfamIZ/mIZ/1NH31NH31NH3oCVKoCVKoCVKoCVKmIZ/mIZ/mIZ/
3dfa3dfamIZ/2szK2szK2szKmIZ/3dfa2szK2szKmIZ/9OvO//fX//fX//fX
//fX//fX//fX//fX//fX//fX9OvOno2JmIZ/1NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5FvRA9////////////////////vw88vRA9sxdBkRxEmIZ/tKek
3NbZ19DS7t/InoyE3dfa2szK2szK3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX//fX//fX//fX7t/I
/Pv7mIZ/08vN3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9O3Y/PTX
+fHY//fX//fX//fXmIZ/mIZ/+vLT//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/Izr6twbGimIZ/mIZ/j8HniMTok8HhiMToiMTok8Hhk8Hh
j8HniMTok8HhiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhj8HniMToj8Hnk8Hhk8Hh
j8HniMToiMTok8HhiMTok8Hhk8HhiMToiMTok8Hhj8HniMToj8Hnj8HniMTo
k8Hhj8Hnk8HhiMToj8Hnj8HniMTok8HhiMTok8Hhj8HniMTok8HhmIZ///fX
//fX//fX//fX//fX//fX//fX//fX/PTX39na3dfa3dfa2szK2szKmIZ/mIZ/
//fX3dfamIZ/mIZ/mIZ/1NH31NH31NH3oCVKoCVKoCVKoCVKoCVKmIZ/mIZ/
mIZ/4b/ImIZ/mIZ/mIZ/2szKmIZ/3dfa2szK2szKmIZ//PPU//fX//fX//fX
//fX//fX//fX//fX//fX9ezPmoiB1NH31NH31NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5Fvw88////////////////////wQ07vw88txQ/kRxEmIZ/mIZ/
pmZs2dLV//fX7t/Im4mCy8HC2szK2szK2szK//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX////mIZ///fX//fX//fX//fX7t/I
7eLenIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa9u7Y+fLX
+fHY//fX//fX//fXmIZ/+fDR//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/I7t/IzbysopCHmIZ/mIZ/iMTok8Hhk8HhiMToiMToj8Hn
k8Hhk8HhiMTok8Hhj8HniMTok8HhiMToj8HniMTok8Hhk8Hhk8Hhj8HniMTo
k8Hhk8Hhk8Hhj8Hnk8HhiMToiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hh
iMTok8HhiMTok8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhj8HnmIZ///fX
//fX//fX//fX//fX//fX//fX//fX5+DZ3dfa3dfa3dfa2szK2szKmIZ/mIZ/
//fX2szKmIZ/mIZ/1NH31NH31NH31NH3oCVKoCVKqx5Fqx5Fqx5FrxpDmIZ/
mIZ/4b/I4b/ImIZ/mIZ/2szKmIZ/3dfa2szK2szKmIZ/+fDS//fX//fX//fX
//fX//fX//fX//fX+/PUq5uPmIZ/1NH31NH31NH31NH3oCVKoCVKoCVKpiFH
piFHqx5Fqx5Fpg06////////////////////qQs5vw88txQ/piFHoCVKmIZ/
mIZ/18u1//fX7t/ImIZ/momCvrOx29TX2szK2szK//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX////mIZ///////fX//fX7t/I//fX
7uPfopGLmoiB3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa+PDY+fHY
+fLY//fX//fXmIZ/sKCT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/Ivq6gmIZ/mIZ/k8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
j8Hnk8Hhj8Hnk8Hhk8HhiMTok8Hhk8Hhk8HhiMToj8HniMTok8Hhk8HhiMTo
j8Hnj8Hnk8Hhj8Hnk8Hhk8Hhj8Hnj8Hnk8HhiMToj8HniMToiMToj8Hnk8Hh
iMTok8HhiMToiMToj8Hnj8HniMToj8Hnk8HhiMToj8Hnk8HhmIZ/rpyR//fX
//fX//fX//fX//fX//fX//fX//fX3tja3dfa3dfa2szK2szKmIZ///fX//fX
//fX2szKmIZ/mIZ/1NH31NH31NH31NH3oCVKqx5FsxdBtxQ/////////uhI+
mIZ/mIZ/4b/ImIZ/mIZ/2szK2szKmIZ/2szK2szKmIZ/+/LT//fX//fX//fX
//fX//fX//fX//fXx7qnmIZ/1NH31NH31NH31NH31NH3oCVKoCVKpCZKsSNH
syNIuSBGuSBGwA88////////////////////6RA9vw88txQ/oCVKoCVKoCFE
mIZ/nYyG3dfa7t/I7t/ImIZ/mIZ/r6Gd3dfa2szK2szK7t/I//fX7t/I//fX
//fX//fX//fX//fX//fX//fX////////////mIZ///////////fX7uPf//fX
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3tja+vLX+PDY
+fHY//fXmIZ/w7Wk+O/R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/Izr6tmIZ/mIZ/k8HhiMToj8Hnj8HniMToj8Hn
k8Hhj8Hnk8HhiMToj8Hnk8Hhj8HniMToj8Hnk8Hhj8Hnk8Hhj8Hnj8Hnk8Hh
k8Hhk8HhiMTok8Hhj8Hnj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hn
k8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8HhiMTomIZ/6NnD//fX
//fX//fX//fX//fX//fX//fX8uvY3dfa3dfa2szK2szKmIZ/mIZ///fX//fX
//fX2szKmIZ/1NH32NX47Ov78O/87+78sypLvCFGwxY/txU/////////////
uhI+mIZ/4b/I4b/ImIZ/mIZ/2szKmIZ/2szK3dfamIZ//fXW//fX//fX//fX
//fX//fX//fX//fXm4qCmIZ/1NH31NH31NH31NH31NH3qSdKtytLvSxMxSdJ
xyhJ////////4xQ/4xQ/////////////6RA95hI+4BZAziRHoCVKoCVKoCFE
mIZ/mIZ/3dfa//fX7t/I7t/ImIZ/mIZ/3dfa3dfa2szK2szK7t/I//fX7t/I
//fX//fX//fX//fX//fX//fX////////////mIZ/////////////7uPf7uPf
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa4tza9+/Y+PDY
+fLY/vbXmYeA9OvN//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/IzLyrmIeBmIZ/j8Hnk8Hhk8Hhk8Hhk8Hhk8Hh
k8HhiMTok8Hhk8Hhj8Hnk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhj8HniMTo
iMTok8Hhj8Hnk8Hhk8HhiMToj8Hnj8Hnk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8HhiMTok8Hhj8Hnk8Hhk8Hhj8Hnj8Hnk8HhiMTomIZ/6tvF//fX
//fX//fX//fXmIZ///fX//fX5t/Z3dfa3dfa2szK2szKmIZ/mIZ///fX//fX
//fX2szKmIZ/3Nn4/f3/////////////wS1MziRH3BlB1hhB////////////
uhI+mIZ/mIZ/4b/I3dfamIZ/2szK2szKmIZ/2szKmIZ//PPU//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/1NH31NH32tj46Of79PT99/f+vSxMvixMyChJ
yChJ////////4BZA4xQ/4xQ/5hI+5hI+5hI+4BZA2BxDziRHwS1MwChG1NH3
r6KsmIZ/mIZ/3dfa//fX//fX7t/I7t/ImIZ/mIZ/mIZ/3dfa2szK2szK7t/I
7t/I//fX//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5t/Z9OzY+vLX
+vLXmIZ/r6CT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IybmpmIZ/mIZ/k8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hh
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnj8Hnk8Hhj8Hnj8Hnk8Hhj8Hn
j8Hnk8Hhj8Hnk8Hhj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/7t/I//fX
//fX//fX//fXmIZ///fX//fX3tja3dfa3dfa2szKmIZ/k8Hhj8Hn//fX//fX
//fX7t/ImIZ/mIZ//f3/////////////wS1MyChJ3BlB3BlB3BlB////xhM+
uhI+uhI+mIZ/w6fP3dfamIZ/mIZ/2szKmIZ/2szKmIZ//fXW//fX//fX//fX
//fX//fX//fXmIZ/mIZ/1NH319X46un78fH89fT9/Pz//v7/wS1MwS1MwS1M
////////////3BlB3BlB3BlB4BZA4BZA3BlB0yBFziRHyChJwS1MwS1M////
+/r5mIZ/mIZ///fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/2szK2szK2szK
7t/I//fX//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfn4+ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ8erY+PDY
/vbXmIZ/1sq0/vbW//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IyrmpmIZ/mIZ/j8Hnj8Hnj8Hnk8HhiMToj8Hn
k8Hhk8Hhj8Hnj8Hnj8Hnj8Hnj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hh
j8Hnk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/7t/I//fX
//fX//fX//fXmIZ///fX+fLX3dfa3dfa2szK2szKmIZ/mr/hk8Hh//fX//fX
//fX7t/ImIZ/mIZ/////////////////wS1MwS1M2BxD////3BlB3BlB3BlB
txQ/txQ/mIZ/mIZ/3dfa//fXmIZ/mIZ/mIZ/2szKmomB/PTV//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dv59vb9+fn+/v7/////////////wS1MwS1MwS1M
////////////0yBF0yBF////////2BxD0yBFziRHziRHwS1MwS1MwS1M////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfrZ6ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+HZ8erY3tja
mIZ/mIZ//PPU//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/r5+SnoyEmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImoiBmIZ/k8Hhk8Hhj8Hnmr/hk8Hhk8Hh
mr/hmr/hk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhmr/hj8Hnk8Hhj8Hnk8Hhk8Hh
j8Hnj8Hnj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnmr/hk8HhmIZ/7uPf////
//fX//fXmIZ///fX//fX7ufZ3dfa2szK2szKmIZ/k8Hhk8Hhk8Hh//fX//fX
//fX7t/ImIZ/mIZ/////////////////////wS1M////////2BxD3BlB3BlB
3BlBsxdBmIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ/nIqE//fX//fX//fX//fX
//fX//fX//fXmIZ/4+H6+fj+////////////////////////wS1MwS1MwS1M
wS1MwS1MziRHziRHziRH////////ziRHyChJyChJwS1MwS1MwS1M////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/
mIZ/7t/I//fX//fX//fX//fX////////////////mIZ/////////7uPf7uPf
7uPfq52ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+HZ8erY3dfa
mIZ/p5eM//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/no2H3dfaxLm5uqycmIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Ino2FmIZ/k8Hhj8Hnk8Hhk8Hhk8Hhj8Hn
iMTok8Hhmr/hk8Hhk8Hhk8Hhj8Hnmr/hk8Hhk8Hhmr/hk8Hhj8Hnmr/hmr/h
k8Hhk8Hhmr/hj8Hnk8Hhj8Hnk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hhk8Hhk8Hh
k8Hhj8Hnk8Hhj8Hnk8Hhk8Hhmr/hj8Hnk8Hhj8Hnj8Hnk8HhmIZ/7uPf////
//////fXmIZ///fX//fX4Nra3dfa3dfarp6YmIZ/k8Hhk8Hhj8Hn//fX//fX
//fX//fX2szKmIZ/////////////////////wS1MwS1MyChJyChJ2BxD////
0yBF0yBFmIZ/mIZ///fX//fX//fXmIZ/mIZ/mIZ/mIZ//vbW//fX//fX//fX
//fX//fX//fXmIZ/////////////////////////////////////wS1MwS1M
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fXmIZ/
mIZ///fX7t/I//fX//fX//fX//fX////////////mIZ/////////7uPf7uPf
7uPf3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa5+DZ8uvY7ufZ
mIZ/5NnA//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfazMPE0srLuKupno2FmIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Io5GJmIZ/pMfgk8Hhk8Hhk8Hhk8Hhk8Hh
mr/hk8Hhk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhmr/hj8Hnk8Hh
mr/hk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnj8Hnk8Hhmr/hmr/hk8Hhmr/hk8Hhmr/h
mr/hk8Hhj8Hnmr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhmr/hmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfa2szKm4mDmIZ/j8Hnj8Hnk8Hhk8Hh//fX
//fX//fX7t/ImIZ/mIZ/////////////////////wS1MwS1MwS1MwS1MwS1M
yChJyChJmIZ/mIZ///fX//fX//fX//fXmIZ/mIZ/mIZ/+vHT//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////wS1M
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////////////
////mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ///fX//fXmIZ/mIZ/
//fX////////7uPf//fX////////////////////mIZ/7uPf7uPf7uPf7uPf
7t/IsaShmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z9O3YmIZ/
mIZ/7uXJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfap5eSmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/Ip5aMmIZ/rcjfk8Hhj8Hnj8Hnmr/hj8Hn
mr/hj8Hnmr/hj8Hnmr/hmr/hk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hh
k8Hhk8Hhk8Hhmr/hk8Hhk8Hhmr/hk8Hhj8Hnk8Hhk8Hhk8Hhmr/hk8Hhj8Hn
k8Hhk8Hhk8Hhj8Hnmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8HhmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfawrOvmIZ/k8Hhmr/hmIZ/mIZ/k8Hh//fX
//fX//fX7t/ImIZ/mIZ/////////////////////////wS1MwS1MwS1MwS1M
yChJyChJmIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/08ex//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
wS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1MwS1M////////////////
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ///fXmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/7uPf//fX//////////////////fXmIZ/7uPf7t/I7t/I7t/I
7uPf3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/+vLT//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX/PTXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfarZ6amIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IqJaMmIZ/nsHhk8Hhk8Hhk8Hhmr/hk8Hh
j8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhmr/hk8Hhk8Hhk8Hhk8Hh
mr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhj8Hnk8Hhj8Hnk8Hhk8Hh
k8Hhmr/hk8Hhmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hmIZ/7uPf////
////////mIZ///fX//fX3dfa3dfasKCbmIZ/mr/hmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX7t/I7t/ImIZ/mIZ/////////////////////////////////wS1M
wS1MyChJmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX6N7D//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////wS1MwS1MwS1MwS1MwS1MuwIU////////////////////mIZ/
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ///fX//fXmIZ///fX7t/I
mIZ/mIZ/mIZ/////7uPf//////////////fX//fXmIZ/7uPf7t/I7t/I7t/I
2szKt6uomIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa493ZmIZ/
oZCH//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+fDSnYyEmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IoI6GmIZ/lcHhk8Hhmr/hk8Hhk8Hhj8Hn
mr/hk8Hhmr/hk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhk8Hh
k8Hhmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8Hhmr/hj8Hnk8Hhk8Hhk8Hhmr/h
k8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8HhmIZ/5NjU////
////////mIZ/////////3dfa3dfan46HmIZ/k8Hhmr/hmIZ/mIZ/mIZ/mIZ/
mIZ///fX//fX7t/I7t/ImIZ/////////////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
///////////////////9////////////////////////////////mIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/3dfa////7uPfmIZ/////////7t/I7t/ImIZ/7uPf7t/I7t/I7t/I
2szKtqmmmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/9OzYmIZ/
q5uQ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXx7qnmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/nsHhk8Hhk8Hhk8Hhmr/hk8Hh
k8Hhmr/hk8Hhk8Hhmr/hmr/hk8Hhk8Hhmr/hk8Hhmr/hj8Hnj8Hnmr/hk8Hh
mr/hk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/hmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hh
k8Hhmr/hk8Hhmr/hmr/hmr/hj8Hnk8Hhk8Hhk8Hhk8Hhk8HhmIZ/xrWm////
////////mIZ///////fX3dfa2dPVmIZ/lcLhmr/hk8Hhmr/hlcHhmIZ/mIZ/
//fX//fX//fX//fX7t/ImIZ/mIZ/////////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////////////////////////////////////////mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/2szK2szK7uPfmIZ/7uPf7uPf7t/I7t/ImIZ/7uPf7uPf7t/I7uPf
2szKq52YmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
y76q//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
9OvNmYiAmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhj8Hnmr/hmr/hk8Hhmr/h
k8Hhmr/hmr/hk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hj8Hn
k8Hhmr/hmr/hmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhmr/hj8Hnj8Hnmr/hmr/h
k8Hhmr/hk8Hhk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hmr/hmr/hmIZ/pJOJ//fX
//fX////mIZ///////fX3dfa08vNmIZ/k8Hhmr/hmIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/////////////////////////////
////////////mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/////////////////////////////////////////////
////////////////////////////////////////m4mDmIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/2szK7t/I7uPfmIZ/7uPf7t/I7t/ImIZ/7uPf7uPf7uPf7t/I
2szKnIqE3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
8OfL//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
/vbXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mr/hk8Hhk8Hhmr/hj8Hnmr/h
k8Hhk8Hhj8Hnk8Hhmr/hmr/hmr/hmr/hk8Hhk8Hhmr/hmr/hmr/hk8Hhmr/h
mr/hk8Hhj8Hnk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/hmr/hj8Hnk8Hh
mr/hk8Hhk8Hhmr/hk8Hhmr/hk8Hhk8Hhmr/hk8Hhk8Hhk8HhmIZ/mIZ//vbW
//fX//fXmIZ///fX//fX3dfaxrazmIZ/mr/hmIZ/mIZ///fX//fX//fXmIZ/
//fX//fX//fX//fX//fX//fX7t/I//fX////////////////////////////
////////7uPf7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/////////////////////////////////////////
////////////////////////////////+/r5////mIZ/mIZ///fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ///fXmIZ/2szK////7uPfmIZ/7uPf7t/I7t/ImIZ/7uPf7uPf7t/I7t/I
2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbX
n46GmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhmr/hmr/hk8Hho77bj8Hn
mr/hmr/hmr/hj8Hnk8Hhk8Hhk8Hhmr/hmr/hk8Hhk8Hhj8Hnmr/hk8Hhk8Hh
mr/hmr/hmr/hmr/hk8Hhmr/hmr/hmr/hk8Hho77bk8Hhk8Hhmr/hmr/hk8Hh
mr/hmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hhmr/hmr/hmr/hmr/hk8HhmIZ/29C5
//fX//fXmIZ///fX//fX3dfavKyomIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX////////////////////
////mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/////////////////////////////////////
////////////////////////////////mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fXwbOiw7Wk0MOvoI+GmIZ///fX//fX//fX//fXmIZ/mIZ/nYuD
xrmnmIZ/mIZ/mIZ/3dfa7uPfmIZ/////7t/I7t/ImIZ/7t/I7t/I7t/I7t/I
w7SwmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/moiB
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PTXmIZ/
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhk8Hhk8Hhk8Hhmr/hk8Hh
k8Hhk8Hhj8Hno77bmr/hmr/hmr/hk8Hhk8Hho77bmr/hmr/hk8Hhmr/hmr/h
k8Hhk8Hhk8Hhmr/hmr/hmr/hk8Hhk8Hhk8Hhk8Hhk8Hhk8Hhmr/hk8Hhmr/h
k8Hhk8Hhmr/hk8Hhmr/hk8Hhmr/hmr/hk8Hhk8Hhk8Hhk8Hhmr/hmIZ/saCU
//fX//fXmIZ///fX//fX3dfaxbWymIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX
//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX////////////////
mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa//fX//fX//fX//fX//fX//fX////////////////////////////
///////////+//75mIZ/mIZ/mIZ/mIZ///fY//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXvrCfnIuEmIZ///fX//fX//fX//fX//fXnIuFxry7
//fXn46ImIZ/mIZ/2szK7t/I7t/ImIZ/7t/I7t/ImIZ/7t/I7t/I7t/I7t/I
uqqmmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/rp6S3NC5mIZ/oI+G
//fX/vbW//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/IrJuQmIZ/mr/hmr/hmr/hmr/hk8Hhmr/h
mr/hmr/hk8Hhk8Hhmr/hk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/h
o77bmr/hk8Hhk8Hhk8Hhmr/hmr/ho77bmr/hmr/hmr/hk8Hhmr/hmr/hmr/h
mr/hk8Hhmr/ho77bk8Hhk8Hhmr/hmr/hmr/hmr/hmr/hmr/hmr/hw73EmYeA
//fX//fXmIZ///fX4tza3dfa2szKmIZ/mIZ/mIZ/mIZ/mIZ///fX3dfa//fX
//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
oY+H7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//vs//zw//3z//74
//30//jc//fY//fY//ng//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXr5+SmIZ/mIZ/3dfa//fX//fX//fXmIZ///fX3dfatKek
18/Ry8LDmIZ/mIZ/3dfa7t/I7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I7t/I2szK
r56ZmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/7eTI//fXmIZ/p5aL
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbXmIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/IrJuQmIZ/k8Hhk8Hhk8Hhmr/hmr/hmr/h
k8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8Hhmr/hmr/ho77bk8Hhk8Hhmr/hk8Hh
k8Hhk8Hhk8Hho77bo77bk8Hhk8Hhk8Hhk8Hhk8Hho77bmr/hmr/hk8Hhk8Hh
mr/hmr/hk8Hhk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hw73Ew73E
6trE//fXm4mBmIZ/4tza3dfa2szKmIZ/mIZ/mIZ/mIZ/mIZ/3dfa//fX//fX
//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
3c257t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//////fX//fX//////////fX//////////fX
//fX//fX//fX//fX//fXtqeZmIZ/mIZ///fX//fX//fXmYeAmIZ///fXm4qD
0cnL2NHTqZmN3dfa3dfa2szK7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I7t/I2szK
n46ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/o5ON+/LT//fX//fXrp6S
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9O3YmIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa39na5+DZ//fX//fX//fX39na3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mr/ho77bmr/hk8Hhk8Hhk8Hh
o77bk8Hhmr/ho77bk8Hhmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hhmr/hmr/h
mr/ho77bk8Hhk8Hho77bmr/hmr/hmr/hmr/hk8Hhk8Hhk8Hhmr/hmr/hk8Hh
k8Hhmr/hmr/hmr/hk8Hhmr/hmr/hmr/hk8Hhk8Hhmr/hk8Hhk8Hhmr/hwb7E
wrKj3dfa3dfamIZ/493Z3dfa2szKycnJycnJycnJycnJycnJycnJycnJycnJ
ycnJycnJycnJmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fXmoiAz7+u
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJ
ycnJ//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fXmIZ/mIZ///fX
ua2r29XYrZ2R3dfa3dfa2szK7t/ImIZ/7t/I7t/I7t/ImIZ/7t/I2szK1sjG
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/uayq/PTV//fX//fXxbim
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/vbXmIZ/mIZ/
mIZ/3dfa3dfa3dfa3dfa3tja//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3My5mIZ/mIZ/k8Hhmr/ho77bo77bmr/hmr/h
k8Hhmr/hk8Hhk8Hho77bmr/hk8Hhmr/ho77bmr/ho77bk8Hho77bmr/hmr/h
k8Hhk8Hhmr/hmr/hk8Hhmr/hk8Hhk8Hho77bmr/ho77bo77bmr/hk8Hho77b
mr/ho77bmr/hk8Hhmr/hk8Hhmr/hmr/hmr/hmr/hk8Hhmr/ho77bk8Hhxr3B
moiB1s/R3dfamYeAycnJycnJycnJmIZ/k8Hhmr/hmIZ/3dfa3dfamIZ///fX
//fX//fXmIZ/ycnJycnJycnJ//fX//fX//fX//fX//fX//fX//fXx7an7N3G
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX////ycnJycnJ
ycnJycnJycnJycnJ//////////////////////////fX//fX//fX//fX//fX
////ycnJycnJycnJpZWK//fXmIZ/3dfa//fX//fX//fX//fX//fXmIZ///fX
pJWP2dLUoZCHmIZ/3dfa3dfa2szKmIZ/2szK7t/ImIZ/7t/I7t/I2szK3dfa
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/7+XJ//fX//fX//fX2c22
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7ufYmIZ/mIZ/
3dfa3dfa3dfa3dfa6uPZ//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX28u4mIZ/mIZ/mr/hk8Hhk8Hhk8Hhk8Hhk8Hh
mr/ho77bmr/hk8Hhk8Hho77bo77bk8Hhk8Hhk8Hho77bk8Hhmr/hk8Hho77b
mr/hmr/hk8Hhmr/hk8Hho77bmr/hk8Hhk8Hhk8Hhk8Hhk8Hho77bk8Hhk8Hh
k8Hhk8Hho77bo77bo77bmr/hk8Hho77bmr/ho77bk8Hhk8Hhk8Hhk8Hhwb7E
mIZ/x7enycnJycnJ6eLZ3dfa2szKmIZ/mr/ho77bmIZ/3dfamIZ/mIZ/3dfa
//fX//fXmIZ/mIZ/mIZ///fXycnJycnJ//fX//fX//fXmIZ/pZSK7N3H//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa//fX//fX//fX//fX//fX//fX//fXycnJycnJycnJ//fX////
//////////////////////fX//////////fX//////fX//fX//fX//fX//fX
//fX//////fX//fXycnJycnJycnJ3dfa//fX//fX//fX//fX9+7QmIZ/mIZ/
qZmN19DTopKMmIZ/3dfa3dfa2szKmIZ/2szK7t/ImIZ/7t/I2szK2szKn46I
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamYeA/fXW//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3dfa5t/Z//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX5NnA
mIZ/mYeA7OLH//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I1MSymIZ/mIZ/o77bmr/hmr/hmr/ho77bmr/h
mr/hk8Hhmr/hmr/ho77bk8Hhk8Hhmr/ho77bmr/hk8Hhmr/ho77bo77bk8Hh
o77bk8Hhmr/hmr/ho77bk8Hho77bmr/hmr/hmr/hmr/ho77bk8Hhmr/ho77b
mr/ho77bk8Hhk8Hhk8Hhk8Hho77bk8Hho77bk8Hho77bmr/ho77bmr/hmr/h
ycnJycnJ2cvJ7ebZmIZ/3dfa2szKmIZ/k8Hhk8HhmIZ/mIZ/mIZ/mIZ/3dfa
//fX//fX//fX//fXmIZ/mIZ///fX//fXycnJ//fXmIZ/mIZ/zb2s7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fX
//fX//////////fX//////fX//fX//////fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fXmIZ/mIZ/ycnJycnJycnJmIZ///fX//fXmIZ/mIZ/
q5yY19DSpZSKmIZ/mIZ/3dfa2szKmIZ/2szK7t/ImIZ/7t/I2szKwre2mIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfaqpmO//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa
3dfa3dfa3tja/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX49i/
mIZ/nYyD7OLG//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IzbysmIZ/mIZ/k8Hhmr/hmr/ho77bk8Hhk8Hh
mr/hk8Hhmr/hmr/hmr/hmr/ho77bk8Hho77bmr/hmr/hk8Hhk8Hhmr/hk8Hh
o77bo77bk8Hhk8Hhmr/hk8Hho77bk8Hho77bmr/hk8Hhmr/hmr/hk8Hho77b
k8Hho77bmr/hmr/ho77bk8Hhmr/hk8Hho77bk8Hhmr/hk8Hho77bmr/hycnJ
k8HhmIZ/ybq36OLZpZWM3dfa2szKqpuXo77bo77bmIZ/mIZ/mIZ/mIZ/3dfa
//fX//fX//fX//fXmIZ/mIZ///fX//fX//fXycnJycnJvKud7t/I//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa//fX//fX//fX//fX//fXycnJ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fXmIZ/3dfa//fX//fXmIZ/ycnJycnJycnJmIZ/mIZ/
3dfa1c7QmYeAmIZ/mIZ/3dfa3dfa2szKmIZ/7t/ImIZ/3dfa2szKrqCcmIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/uquc/fXV//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa
3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX29C5
mIZ/o5KJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IxrWmmIZ/mIZ/k8Hhk8Hhk8Hhmr/ho77bmr/h
o77bo77bo77bk8Hho77bo77bk8Hhmr/hk8Hho77bo77boL3gmr/ho77boL3g
k8Hhmr/ho77boL3gmr/hmr/hk8Hho77bk8Hhk8Hhmr/ho77bo77bmr/hmr/h
mr/hk8Hhmr/ho77bmr/hmr/hmr/hmr/hmr/hmr/hk8HhoL3gmr/hycnJo77b
o77bxr3Br56S3c/Jx7uu3dfa2szKsJ+amIZ/k8HhycnJycnJycnJycnJycnJ
ycnJycnJycnJycnJycnJycnJycnJ//fXycnJmIZ/sqGV7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa//fX//fX//fX//fX//fXycnJ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/3dfa//fX//fXmIZ/mIZ///fXmIZ/ycnJycnJ
ycnJ3dfamIZ/mIZ/mIZ/3dfa3dfa2szKmIZ/7t/ImIZ/3dfa3dfam4qDmIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/noyE8+rN//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa
3dfa5d7Z//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXy76q
mIZ/qJeM//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/IoI6ImIZ/o77bo77bo77bo77bo77bmr/hmr/h
mr/hmr/ho77bk8Hhk8HhoL3gmr/hmr/hk8Hhk8Hho77bk8Hhmr/hk8HhoL3g
mr/hmr/ho77bo77bmr/hoL3gmr/ho77bo77bo77bk8Hhk8Hhmr/hmr/ho77b
mr/ho77bk8Hhmr/ho77bo77bk8Hhmr/ho77bo77bo77bk8HhycnJmr/hmr/h
mr/hoL3gmIZ/69zF19DS3dfa2szKu6unycnJycnJo77bk8Hho77bmIZ/3dfa
3dfa//fX//fX//fX//fX//fX//fXycnJycnJmIZ/6dnD//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/3dfamIZ/mIZ/3dfa//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfaycnJycnJmIZ/mIZ/3dfa3dfa2szKmIZ/2szKmIZ/3dfa3dfamIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFsqKV
mIZ/rJyQ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I2sq3mIZ/mIZ/mr/hmr/hmr/hk8Hhmr/ho77bmr/h
mr/hmr/hmr/hoL3gmr/ho77bo77bo77bo77bmr/hk8Hho77bo77bo77bk8Hh
o77bmr/hk8Hhk8Hho77bk8Hho77bmr/hmr/hmr/hoL3goL3go77bk8Hhk8Hh
o77bmr/hmr/ho77bk8Hhk8Hho77bo77bmr/hk8Hhmr/hycnJmr/hmr/hk8Hh
mr/ho77bmr/huqmc3dfaopKNycnJycnJmIZ/o77bmr/hmr/hmr/hmIZ/mIZ/
3dfa3dfaycnJycnJycnJycnJycnJycnJycnJuqmc7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXo5KImIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/3dfa//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/3dfa3dfa3dfa
3dfa3dfamIZ/ycnJmIZ/3dfa3dfamIZ/2szK2szKmIZ/3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX6uDFnIqC
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/Ivq2fmIZ/mIZ/o77bmr/hmr/ho77bk8Hhmr/hmr/h
o77bk8Hho77bo77bk8Hhk8Hhmr/hmr/ho77bo77bmr/hk8Hhmr/ho77bmr/h
k8Hho77bo77bmr/ho77bmr/hmr/ho77bk8Hho77bo77bk8Hho77boL3gmr/h
mr/ho77bk8Hho77bo77bmr/hmr/hk8Hho77bo77bk8Hho77bk8Hho77bo77b
k8Hhk8Hho77bmIZ/1cfEycnJmYeA2MrImIZ/o77bo77bk8Hho77bo77bycnJ
ycnJycnJ//fX//fX//fX//fX//fXmIZ/mIZ/r56S7t/I//fX//fX//fX3dfa
mIZ/mIZ/xrim//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fXycnJycnJycnJycnJycnJycnJycnJycnJ
//fXmoiAmIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX3dfa
mIZ/mIZ///fX//fX//fX//fX//fX4dK9uqqcmIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfamIZ/3dfaycnJycnJ3dfamIZ/2szKmIZ/3dfa3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3tja
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/InYuEmIZ/mIZ/o77bk8Hho77bo77bo77bk8Hhmr/h
mr/ho77bk8Hhmr/ho77bo77bmr/ho77bmr/hmr/hk8Hho77bo77bk8Hho77b
o77bmr/hk8Hho77bk8Hho77bk8Hho77bo77bmr/hk8Hho77bo77bo77bk8Hh
o77bmr/ho77bk8Hho77bk8Hho77bo77bo77bmr/ho77bk8Hho77bo77bmr/h
o77bo77bmr/hycnJycnJ2szKoJCK2szKnYyFk8Hhmr/ho77bycnJycnJmIZ/
mIZ/3dfa3dfa//fX//fX//fX//fX//fXmIZ/7t/I7t/I//fX//fX//fX3dfa
3dfamIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fXrJuQmIZ/
ycnJycnJycnJmIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX3dfamIZ/
//fX//fX//fX//fX//fX7t/I7t/I4dG9oI+GmIZ/3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/mIZ/3dfa3dfamIZ/ycnJmIZ/2szKmIZ/3dfamIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/ImIZ/mIZ/k8Hhk8Hho77bmr/hk8Hhmr/ho77bo77b
mr/ho77bo77bmr/hmr/ho77bk8Hho77bo77bo77bo77bk8Hho77bmr/hmr/h
o77bo77bmr/ho77bo77bo77bk8Hhk8Hho77bo77bmr/hk8Hhk8Hho77bo77b
k8Hho77bo77bmr/ho77bo77bk8Hhmr/ho77bmr/ho77bmr/hk8Hhk8Hhmr/h
mr/ho77bycnJmr/hmIZ/2szKyb+/0cnKnoyFo77bmr/hycnJo77bk8Hhmr/h
mIZ/3dfa3dfa//fX//fX//fX//fX//fXmIZ/2Mm27t/I//fX//fX//fX//fX
3dfa3dfamIZ/mIZ/mIZ///fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/InYuD
mIZ/mIZ/7t/IycnJycnJ7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/IrZyRmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfa3dfamIZ/3dfaycnJ3dfamIZ/3dfamIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/IpZaSmIZ/mIZ/o77bmr/ho77bo77bo77bk8Hhmr/hmr/h
o77bmr/hmr/ho77bo77bmr/ho77bmr/hmr/hmr/hmr/ho77bmr/ho77bmr/h
mr/hmr/ho77bmr/hmr/hmr/ho77bo77bmr/hmr/ho77bo77bo77bmr/hmr/h
o77bmr/hmr/ho77bmr/hmr/ho77bo77bmr/ho77bmr/ho77bo77bo77bo77b
o77bmr/hmr/ho77bmIZ/mIZ/tqah3dfamIZ/ycnJycnJmr/hmr/ho77bo77b
mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fXmIZ/y7uq7t/I//fX//fX//fX//fX
//fX//fX3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IpJOK
mIZ/7t/I7t/I7t/I//fXycnJycnJ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/IxrmnmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfa3dfamIZ/3dfamIZ/ycnJycnJmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/6N3D//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX2su3m4mDmIZ/mIZ/mr/ho77bmr/hk8Hhmr/ho77bo77bo77b
o77bo77bmr/hmr/ho77bmr/ho77bo77bo77bo77bmr/ho77bmr/ho77bo77b
o77bk8Hho77bmr/ho77bmr/hmr/ho77bo77bk8Hhmr/hmr/ho77bo77bmr/h
mr/ho77bmr/ho77bk8Hho77bmr/ho77bk8Hho77bk8HhoL3gmr/hmr/hmr/h
o77bo77bmr/hmr/ho77bmIZ/mIZ/mIZ/ycnJmIZ/o77bk8Hhmr/hmr/hmr/h
o77bmIZ/mIZ/3dfa3dfa3dfa3dfa//fX3dfam4mC6tvF7t/I//fX//fX//fX
//fX//fX//fX3dfa3dfamIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IoI6G
mIZ/7t/I7t/I//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/Is6OWmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/
mIZ/3dfa3dfa3dfa3dfamIZ/3dfamIZ/mIZ/2szKycnJycnJ3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/5dvB//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa6uPZ//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/IrqGhmIZ/mIZ/o77bmr/ho77bo77bo77bmr/hmr/hmr/ho77b
mr/hmr/ho77bk8Hho77bo77bmr/hk8Hho77bk8Hho77bo77bo77bo77bk8Hh
o77bo77bo77bo77bmr/ho77bo77bo77bmr/ho77bo77bo77bo77bmr/ho77b
o77bmr/ho77bmr/ho77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77b
mr/hk8Hho77bo77bmr/ho77bmIZ/ycnJmIZ/mIZ/o77bo77bo77bo77bo77b
mr/ho77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/uqqc7t/I//fX//fX//fX
//fX//fX//fX//fX3dfamIZ/2szK2szK//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I0MCumIZ/
mIZ/7t/I//fX//fX//fX//fX//fX//fX//fXycnJycnJ//fX//fX//fX//fX
//fX7t/I7t/I//fXr6CTmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/
3dfa3dfa3dfa3dfa3dfamIZ/3dfamIZ/mIZ/mIZ/2szK3dfaycnJ3dfa3dfa
3dfa29TX3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/u6yd//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa/fXX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX28+4taWYmIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3My5oZCLmIZ/mr/ho77bo77bmr/ho77bo77bo77bo77bo77bmr/h
o77bo77bo77bmr/hmr/ho77bo77bmr/ho77bmr/hmr/ho77bk8Hho77bmr/h
o77bk8Hhmr/ho77bmr/ho77bk8Hho77bo77bo77bo77bmr/ho77bo77bo77b
o77bmr/ho77bo77bo77bk8Hho77bo77bo77bo77bo77bmr/ho77bo77bk8Hh
o77bmr/hmr/ho77bo77bmr/hycnJmr/hmIZ/mIZ/mIZ/o77bk8Hhmr/ho77b
o77bk8Hhmr/hmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/o5KI7t/I7t/I//fX
//fX//fX7t/I7t/I7t/ImIZ/2szK2szK7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXycnJycnJycnJ//fX//fX//fX7t/Iq5qPmIZ/
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXycnJ//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfaycnJ3dfa
3dfaua2rwLSzyL+/zcTF3dfa3dfa3dfa3dfamIZ/p5eM//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa6OLZ//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXv7GgmIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I1cWzmoeAmIZ/mr/ho77bk8Hho77bmr/ho77bo77bk8Hho77bmr/h
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
mr/ho77bo77bo77bo77bo77bo77bo77bmr/hmr/hmr/ho77bo77bk8Hho77b
o77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/hmr/ho77bmr/ho77bo77b
o77bo77bo77bmr/hmr/hycnJo77bo77bo77bmIZ/mIZ/mr/ho77bo77bo77b
mr/ho77bo77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfamIZ/saCU7t/I7t/I
7t/I7t/I7t/IxbWlmIZ/mIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXycnJycnJ7t/I7t/ImIZ///fX
7t/I//fX//fX//fX//fX//fX//fX//fX//fX9OfN7t/I7t/IycnJ//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/3dfa2szK3dfa3dfa3dfaycnJ
mIZ/mIZ/mIZ/oJCKoJCKmIZ/3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa/PTX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXx7qnn46FopGI//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/Iv6+gmIZ/mIZ/o77bo77bo77bmr/ho77bmr/hmr/ho77bo77bo77b
o77bo77bo77bo77bmr/hmr/hmr/hmr/ho77bo77bmr/ho77bmr/hmr/ho77b
o77bo77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77bo77bmr/hoL3g
o77bk8Hho77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/ho77bo77b
o77bo77bo77bo77bycnJo77bo77bo77bo77bo77bo77bo77bo77bmr/ho77b
o77bo77bmr/ho77bo77bmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/taSYy7ur
0sKw7t/Ip5WMmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/IycnJmYeAmIZ///fX
//fX//fX//fX//fX//fX//fX+e7R9+vQ8eTL7t/I7t/I7t/ImIZ/ycnJ//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa2szK3dfa3dfa3dfa3dfa
ycnJmIZ/mIZ/uKmanoyEmIZ/mIZ/mIZ/3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/3dfa5+HZ//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX6d/EqZiNpZWK//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/InYuDmIZ/xr3Bmr/ho77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bk8Hho77bo77bo77bo77bo77bo77bmr/hmr/ho77bo77bo77bo77bo77b
o77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bmr/hmr/ho77bo77bo77b
mr/ho77bo77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77b
mr/hmr/hmr/hycnJo77bo77bo77bmr/ho77bmr/ho77bo77bmr/ho77bo77b
mr/ho77bo77bo77bmr/ho77bmIZ/mIZ/mIZ/3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/7uPfmIZ/mIZ/7uPfmIZ/mIZ/mIZ/7t/I7t/I7t/I7t/I
7t/I7t/I//fX//fX//fX//fX//fX//fX//fX7t/IqZiOmIZ/ycnJ//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R9+zQ7t/ImIZ/mIZ/mIZ/3dfaycnJ
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa2szK3dfa3dfa3dfa3dfa
3dfaycnJmoiB19DS/fXW//fX//fXmIZ/mIZ/mIZ/mIZ/5NrA//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa+fLX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXuKmbppaLzsGt//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/IsJ+TmIZ/xr3Bmr/ho77bo77bo77bo77bo77bo77bmr/ho77bo77bmr/h
o77bmr/ho77bo77bo77bo77bo77bo77bo77bmr/hmr/ho77bmr/hmr/hmr/h
mr/ho77bo77bo77bo77bmr/ho77bmr/ho77bo77bo77bmr/ho77bo77bo77b
o77bo77bo77bmr/ho77bo77bo77bo77bo77bmr/hmr/ho77bmr/hmr/ho77b
o77bo77bo77bo77bmr/hmr/ho77bmr/ho77bo77bmr/ho77bo77bo77bo77b
o77bo77bmr/ho77bo77bmr/ho77bpcDbmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfamIZ/7uPf7uPf7uPfmIZ/mIZ/7uPf7uPf7uPfmIZ/mIZ/mIZ/mIZ/mIZ/
7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ///fX//fXycnJ//fX
//fX//fX//fX+e7R+e7R+O7R9+zQ8+bN7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/xLal/fTV//fX//fXw7WkmIZ/mIZ/sqOV//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/49za//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7uTJmoiA1Miy//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I
7t/InYuDmIZ/xr3Bo77bmr/ho77bmr/ho77bmr/ho77bmr/hmr/ho77bo77b
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bmr/ho77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bo77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77b
oL3go77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
mr/hmr/ho77bo77bo77bo77bo77bmr/ho77bmIZ/mIZ/3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/////////////mIZ/////////7uPf7uPf7uPfmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/7t/I//fX//fX//fXycnJ//fX
//fX//fX//fX+e7R9uvP8uXMmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3NbZ3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/uaqb//fX/vbW9+7Q//fXmIZ/nYyD/fXV//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX493ZmIZ/mIZ/3dfa8uvY//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXqZmO//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/ImIZ/mIZ/o77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77b
o77bmr/ho77bmr/ho77bmr/ho77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bmr/hmr/ho77bo77bo77bo77boL3go77bo77bo77bo77boL3go77bo77b
o77bo77bo77bo77bmr/ho77bo77bo77bo77bo77bo77bo77bo77boL3go77b
oL3go77bo77bo77bo77bo77bo77bmr/ho77bo77bo77bo77bmr/ho77bo77b
o77bo77boL3gmr/ho77bo77bo77bo77bo77bo77bmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfamIZ/////////////mIZ/mIZ/////////////////////////7uPf
mIZ///fX//fX//fX//fX//fX//fX7t/I//fX//fX//fX//fX//fX//fXycnJ
//fX//fX//fX8+bM7t/ImIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/mIZ/uaqb//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX/vbXmIZ/mIZ/3dfa4Nra//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7uTJno2E//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/ImIZ/o77bmr/ho77bmr/ho77bo77bo77boL3go77bo77bo77boL3go77b
o77bo77bo77bo77bo77bo77bo77boL3go77bo77bo77bo77boL3go77bo77b
o77bo77bo77boL3go77bo77bo77bo77bo77boL3go77bo77bo77bo77bo77b
oL3go77bo77bmr/ho77bo77bo77bmr/ho77bo77bmr/ho77bo77bo77bo77b
o77bo77boL3go77bo77bo77bo77bo77boL3go77bo77bmr/ho77bo77bo77b
o77bo77bo77bo77bo77boL3go77boL3go77bo77bo77bmIZ/mIZ/3dfa3dfa
3dfa3dfamIZ/mIZ/////////////mIZ/////////////////////mIZ/mIZ/
//fX//fX//fX//fX//fX//fX7t/I//fX//fX//fX//fX//fX//fX//fX//fX
ycnJ//fX8OLK7t/ImIZ/mIZ/2szKmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa29XY3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfawbSrmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+/TXmIZ/mIZ/3dfa7ebZ//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
7t/ImIZ/o77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bo77b
o77boL3go77bo77bo77bo77bo77bo77bqrvboL3go77bqrvbo77bo77bo77b
o77bo77bo77boL3go77bo77bo77bo77bo77bo77boL3go77bo77boL3go77b
oL3go77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bqrvbo77b
oL3go77bo77bo77boL3go77bo77bo77bo77bo77bo77bqrvbo77bo77bo77b
o77bo77bo77bo77bo77bo77bo77boL3go77boL3go77bo77bmIZ/mIZ/3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/////////////////////////mIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
9+zQycnJmIZ/mIZ/3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfano2HmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX/vbXmIZ/mIZ/3dfa+vLX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/mIZ/o77boL3go77bo77bo77boL3go77bo77bo77bo77bo77boL3go77b
o77bo77bo77bo77bo77bo77bo77boL3goL3go77bo77bo77bo77bo77bo77b
o77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77brbzVo77b
o77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvboL3go77bqrvbo77bo77b
o77bo77bo77bo77bo77bo77bo77bo77bo77boL3gqrvbo77bo77bo77bqrvb
o77bo77bqrvbo77bo77bo77bo77bqrvboL3go77bo77bo77boL3gmIZ/mIZ/
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/////////////mIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R9urP9urP
7+HJycnJmIZ/3dfa3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szK3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfauq6smIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/o77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bqrvbo77bo77bqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77boL3go77bo77b
o77bo77bo77bo77bo77bqrvbqrvbo77bo77bo77bqrvbo77bo77bqrvbo77b
o77bo77bo77bo77bqrvbqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77b
o77bo77bo77bo77bo77bo77bo77bqrvbo77bqrvbo77bo77bo77bo77bmIZ/
mIZ/3dfa3dfa3dfa3dfa//fXmIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX9+zQ7t/I7uDImIZ/
mIZ/mIZ/ycnJ3dfa3dfa3dfa2szKmIZ/3dfa3dfa3dfa3dfa3dfa3dfa4tza
8+zY//fX//fX39HJmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfappeSmIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/o77bqrvbqrvbo77bo77bo77bqrvbqrvbqrvbqrvbo77bqrvbqrvbo77b
qrvbo77bo77bo77bo77bqrvbo77bo77bqrvbqrvbo77bo77bqrvbo77bo77b
o77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77b
o77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bo77b
qrvbqrvbqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
qrvbo77bqrvbo77bqrvbo77bo77bo77bo77bo77bo77bo77bpcDbsb/bqcLb
mIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
mIZ/3dfa3dfa3dfa3dfa3dfa7t/ImIZ/3dfa3dfa3dfa3dfa3dfa5d7Z/vbX
//fX//fX//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfawba1moiAmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/vbXmIZ/mIZ/mIZ/3tja//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
mIZ/qrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bo77bo77b
qrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77bo77b
qrvbo77bo77bqrvbo77bqrvbqrvbqrvbqrvbqrvbo77bo77bo77bqrvbqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77b
o77bo77bqrvbo77bo77bqrvbqrvbo77bo77bo77bo77bo77bo77bqrvbo77b
o77bo77bo77bo77bo77bo77bo77bqrvbo77bo77bssDbo77bpcDbo77btMHb
qcLbmIZ/mIZ/mIZ/3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa//fX7t/ImIZ/3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa0cnKtKWXmIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/PTXmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/
o77bo77bo77bo77bo77bqrvbo77bo77bo77bo77bqrvbo77bo77bqrvbo77b
rbzVqrvbo77bo77bo77brbzVqrvbo77bo77bqrvbqrvbo77bo77bo77bqrvb
o77bo77bo77bo77bo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77bo77b
qrvbo77bqrvbo77brbzVo77bqrvbqrvbo77bo77bqrvbo77bqrvbo77brbzV
o77bo77brbzVo77bo77bo77bo77bqrvbqrvbqrvbqrvbo77bqrvbo77bo77b
o77bo77bqrvbo77bqrvbqrvbo77bo77bqrvbrL3bo77brL3bo77bqrvbp8Db
qrvbxNDamIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX7t/ImIZ/3dfa3dfa4Nra//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa1s/Rwri3mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+fHYmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
o77bo77bo77bo77bqrvbo77bo77bqrvbo77bo77bo77bo77bo77bo77bqrvb
o77bqrvbo77bqrvbo77bo77bqrvbo77bo77bo77bqrvbrbzVqrvbo77bo77b
o77bqrvbo77bqrvbo77bo77bo77bo77bo77bo77brbzVqrvbrbzVo77bo77b
o77bo77bqrvbo77bqrvbo77bo77brbzVqrvbo77bqrvbo77brbzVoL3go77b
o77boL3go77bqrvbo77bo77bo77bo77bo77bo77bqrvbo77bo77bo77brbzV
qrvbo77bqrvbo77bo77bqrvbo77brbzVo77brbzVo77brr3bo77bo77bo77b
o77bmIZ/mIZ/3dfamIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX7t/ImIZ/3dfa5uDZ+/PX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa1MzO08vMnYyDmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+PDYmIZ/mIZ/3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
rbzVqrvbqrvbo77bo77bqrvbo77bqrvbqrvbrbzVqrvbqrvbo77bo77bo77b
o77brbzVqrvbo77bo77brbzVrbzVqrvbqrvbqrvbo77bo77brbzVqrvbrbzV
rbzVo77bqrvbo77brbzVrbzVqrvbqrvbqrvbrbzVo77brbzVo77bqrvbqrvb
qrvbo77bo77bo77bo77bo77bo77boL3grbzVqrvbo77bo77bo77brbzVqrvb
qrvbrbzVqrvbo77bqrvbrbzVrbzVqrvbqrvbo77bo77bqrvbqrvbqrvbqrvb
o77bo77bo77brbzVo77brbzVqrvbo77bo77bo77brr3bpcDbrbzVqrvbqrvb
vcjbmIZ/mIZ/3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX7t/ImIZ/3tja//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfas6SWmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+vLXmIZ/xLm53dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/o77b
o77brbzVo77bo77brbzVo77bqrvbo77brbzVo77bo77bo77bqrvbo77bqrvb
o77brbzVo77bqrvbo77bo77brbzVrbzVo77brbzVo77bo77bo77bqrvbqrvb
qrvbo77bo77boL3gqrvbo77brbzVo77bo77bqrvbo77bqrvbo77brbzVrbzV
qrvbqrvbqrvbqrvbqrvbqrvbrbzVo77brbzVqrvbqrvbo77bo77bo77bo77b
o77bo77bqrvbrbzVqrvbo77brbzVo77bqrvbo77bo77bo77bo77bo77bqrvb
qrvbrbzVo77bqrvboL3grbzVo77bqrvbqrvbpcDbr77VpcDbrbzVo77brr3b
mIZ/mIZ/3dfa3dfa2szK2szKmIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa//fX//fX//fX//fX7t/ImIZ/7OXZ//fX//fX7t/I//fX//fX//fX
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfawLSzmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/w7i33dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/qrvb
o77bo77brbzVo77bqrvbo77bqrvbo77bo77brbzVo77bo77bqrvbrbzVo77b
o77bo77brbzVqrvbqrvbqrvbo77bo77brbzVqrvbqrvbqrvbrbzVo77bo77b
o77bo77brbzVrbzVo77bqrvbo77bqrvbo77bo77bqrvbo77brbzVo77bo77b
o77bo77bo77bo77bqrvbrbzVo77bqrvbo77brbzVo77bqrvbqrvbqrvbrbzV
qrvbrbzVrbzVo77bo77bqrvbo77bqrvbqrvbrbzVqrvbqrvbqrvbqrvbrbzV
rbzVo77bqrvbrbzVrbzVo77bqrvbo77bo77bsb7Vo77bqrvbo77bpcDbmIZ/
mIZ/mIZ/3dfa2szK2szK2szK7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX7t/ImIZ/+fLY//fX//fX7t/I7t/I7t/I7t/I
//fX//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfay8LCmIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvb
qrvbqrvbqrvbqrvbo77bqrvbo77bqrvbqrvbo77bqrvbrbzVqrvbo77bqrvb
qrvbqrvbrbzVo77bo77bo77bqrvbo77bo77bo77bo77bo77bqrvbqrvbrbzV
rbzVqrvbqrvbqrvbrbzVo77brbzVqrvbqrvbo77bqrvbo77bqrvbqrvbqrvb
rbzVrbzVrbzVrbzVo77bqrvbo77bqrvbo77brbzVo77bo77bo77bo77bo77b
qrvbo77bqrvbqrvbo77bqrvbrbzVrbzVo77brbzVrbzVrbzVo77bo77bo77b
qrvbo77bo77bqrvbqrvbo77brbzVqrvbqrvbtcLbpcDbqrvbmIZ/mIZ/mIZ/
//fX//fX//fX3dfa2szK3dfa3dfamIZ/2szK3dfamIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX7t/ImIZ/7d7I7t/I//fX//fX7t/I7t/I7t/I
//fX7t/I//fX7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfaz8bHmIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/ImIZ/xr3Bo77b
o77bo77bo77brbzVo77brbzVo77bqrvbqrvbrbzVqrvbrbzVqrvbrbzVqrvb
o77bo77bo77bqrvbqrvbqrvbo77bqrvbqrvbrbzVqrvbqrvbqrvbrbzVo77b
qrvbo77bo77bo77bo77bqrvbo77bo77brbzVrbzVrbzVqrvbo77bo77brbzV
qrvbqrvbqrvbo77bqrvbo77bqrvbo77bqrvbqrvbrbzVrbzVrbzVqrvbqrvb
o77bqrvbo77bo77bqrvbo77bo77bo77bqrvbo77bo77bo77brbzVqrvbqrvb
o77brbzVqrvbOV41Qmw9Qmw9OV41OV41OV41o77brL3bq8LbmIZ///fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfamIZ/3dfa3dfa3dfa2szK2szK2szK2szK
2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ//vbXmIZ/7t/I7t/I7t/I7t/ImIZ/
7t/I7t/I//fX7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfazcXFmIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/qrvbqrvb
rbzVqrvbrbzVqrvbrbzVqrvbqrvbrbzVo77bqrvbo77bo77bo77bo77bo77b
qrvbqrvbrbzVrbzVqrvbrbzVqrvbrbzVqrvbrbzVqrvbrbzVo77bqrvbo77b
qrvbqrvbrbzVqrvbrbzVqrvbrbzVo77bo77bo77bqrvbrbzVqrvbo77bo77b
o77bo77bqrvbo77bqrvbrbzVrbzVo77bo77bqrvbqrvbqrvbo77brbzVqrvb
o77brbzVrbzVrbzVrbzVqrvbqrvbqrvbqrvbqrvbqrvbqrvbo77bo77bqbvR
prvXQmw9Qmw9UJhVUJhVUJhVUJhVQmw9Qmw9Qmw9OV41OV41OV41OV41//fX
//fXz9Kw//fX//fX3dfa3dfa6+TZmIZ/6uPZ3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa493Z7ufZ//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/7t/I7t/I7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/rbzVqrvb
rbzVqrvbo77bqrvbo77brbzVo77brbzVo77bqrvbqrvbqrvbqrvbrbzVqrvb
rbzVqrvbo77bo77brbzVo77brbzVqrvbqrvbo77brbzVo77bqrvbqrvbqrvb
rbzVrbzVqrvbqrvbqrvbqrvbqrvbqrvbqrvbqrvbo77bqrvbrbzVqrvbqrvb
rbzVqrvbqrvbrbzVrbzVo77bqrvbrbzVrbzVo77bo77bqrvbrbzVqrvbqrvb
qrvbqrvbqrvbo77bo77brbzVrbzVrbzVqrvbrbzVrbzVo77brbzTOV41OV41
Qmw9Qmw9UJhVUJhVUJhVUJhVUJhVUJhVUJhVUJhVQmw9Qmw9Qmw9Qmw9OV41
SmtDtr+bZTwhZTwhZTwhZTwhZTwhZTwh//fX5tjI3tja3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa39na5d7Z7ebZ9O3Y//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/o77bqrvbo77b
o77bo77brbzVo77bqrvbo77bqrvbqrvbqrvbqrvbqrvbrbzVrbzVqrvbrbzV
rbzVqrvbqrvbo77brbzVo77bo77brbzVqrvbo77brbzVo77brbzVrbzVqrvb
qrvbqrvbrbzVo77brbzVqrvbrbzVqrvbrbzVrbzVo77bqrvbrbzVqrvbqrvb
rbzVrbzVqrvbo77bqrvbo77bqrvbqrvbrbzVrbzVrbzVqrvbo77brbzVrbzV
qrvbqrvbqrvbqrvbo77bo77bo77brbzVo77bo77bq7zROV41OV41Qmw9Qmw9
UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVUJhVUJhV
UJhVOV41O1gyTSobXDQjXDQjXDQjZTwhZTwh7t/I7t/I/PTX+PDY9e3Y8+vY
8erY8OnY7+jY8erY9e3Y+PDY+vLX+fHY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/ZTwhmIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVqrvb
rbzVqrvbrbzVrbzVqrvbqrvbo77brbzVrbzVrbzVo77bqrvbo77bo77bqrvb
o77brbzVrbzVrbzVqrvbrbzVsrnVo77brbzVqrvbqrvbrbzVqrvbqrvbqrvb
qrvbrbzVo77bqrvbo77bo77bqrvbrbzVqrvbqrvbrbzVrbzVqrvbrbzVqrvb
qrvbqrvbrbzVqrvbqrvbsrnVqrvbqrvbqrvbqrvbo77bqrvbrbzVo77bqrvb
o77brbzVrbzVrbzVqrvbqrvbqrvbqrvbqrvbOV41OV41Qmw9Qmw9UJhVUJhV
UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVOV41OV41TSobXDQjXDQjZTwhZTwhZTwh7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/Ik3FdZTwhZTwhZTwhZTwhZTwhmIZ/mIZ/mIZ/
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/rbzVqrvbrbzV
qrvbqrvbqrvbqrvbrbzVrbzVrbzVqrvbqrvbo77brbzVqrvbrbzVqrvbrbzV
qrvbqrvbqrvbqrvbqrvbo77bqrvbqrvbrbzVrbzVqrvbqrvbqrvbrbzVrbzV
qrvbsrnVrbzVqrvbsrnVrbzVqrvbo77brbzVsrnVoL3gqrvbqrvbrbzVrbzV
o77bqrvbrbzVrbzVo77brbzVrbzVqrvbrbzVsrnVrbzVqrvbqrvbqrvbrbzV
qrvbqrvbqrvbrbzVrbzVrbzVo77brbzVOV41Qmw9UJhVUJhVUJhVUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjZTwhZTwhk3Fd7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/Ik3Fdk3Fdk3FdZTwhZTwhTSobTSobTSobZTwhZTwhZTwh3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/fXXmIZ/2szK3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/o77brbzVqrvbqrvb
o77brbzVo77bqrvbqrvbqrvbrbzVo77bsrnVsrnVrbzVqrvbqrvbqrvbqrvb
qrvbrbzVqrvbrbzVqrvbqrvbrbzVqrvbsrnVqrvbrbzVqrvbrbzVqrvbqrvb
o77bqrvbqrvbrbzVqrvbqrvbo77bsrnVqrvbqrvbsrnVrbzVrbzVqrvbqrvb
srnVqrvbsrnVqrvbsrnVqrvbqrvbrbzVqrvbo77bqrvbrbzVrbzVrbzVsrnV
rbzVrbzVqrvbqrvbqrvbqrvbsrnVOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVOV41OV41OV41TSobXDQjXDQjXDQjXDQjZTwhZTwhk3Fd7t/I
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/IZTwhZTwhZTwhXTYkXTYkVDIiTSobTSobTSobTSobXDQjXDQjOV41OV41
OV41OV41OV41OV41OV41OV41OV41OV41OV41OV41SWpCQHRBRYJJO2M4OV41
OV41Qmw9OV41OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/fXXmIZ/2szK3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVqrvbqrvbrbzV
rbzVqrvbrbzVrbzVqrvbrbzVo77brbzVqrvbqrvbqrvbqrvbrbzVo77brbzV
qrvbrbzVqrvbrbzVrbzVqrvbrbzVqrvbqrvbqrvbrbzVqrvbrbzVqrvbsrnV
qrvbrbzVsrnVqrvbqrvbsrnVqrvbqrvbqrvbqrvbqrvbqrvbrbzVqrvbqrvb
rbzVqrvbqrvbqrvbqrvbrbzVqrvbrbzVsrnVqrvbqrvbrbzVqrvbqrvbqrvb
qrvbrbzVqrvbrbzVqrvbo77bOV41OV41UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQjZTwhZTwhk3Fd
k3Fd7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fXZTwh
ZTwhZTwhYzwrXjYlZj8uXDQjTSobTSobTSobTSobTSobOV41OV41UaheOV41
OV41OV41OV41OV41PWw9O2U5QHNBSY9QS5VUT6FaT6JaTJlWSI1PUaheUahe
UaheUJhVUJhVQmw9OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX/vbXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVsrnVqrvb
qrvbrbzVqrvbrbzVqrvbrbzVsrnVqrvbqrvbrbzVrbzVqrvbsrnVqrvbqrvb
rbzVqrvbrbzVqrvbqrvbrbzVqrvbqrvbrbzVrbzVrbzVrbzVqrvbrbzVqrvb
rbzVqrvbo77brbzVrbzVqrvbrbzVrbzVrbzVrbzVqrvbrbzVqrvbrbzVrbzV
qrvbqrvbrbzVqrvbrbzVo77brbzVqrvbqrvbrbzVrbzVqrvbrbzVqrvbqrvb
qrvbqrvbrbzVqrvbrbzVsrnVOV41Qmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQjZTwhZTwh
ZTwhZTwhk3Fdk3Fd7t/I7t/I7t/I//fX7t/Ik3Fdk3FdZTwhZTwhZTwhZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobOV41OV41OV41UaheUahe
UaheUaheUaheUaheUaheUaheT6JbT6NbUadeUadeUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQmw9Qmw93dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/rbzVqrvbqrvbrbzV
rbzVsrnVrbzVqrvbqrvbsrnVqrvbrbzVrbzVqrvbsrnVrbzVqrvbrbzVrbzV
srnVqrvbrbzVrbzVsrnVqrvbrbzVqrvbsrnVqrvbqrvbrbzVqrvbrbzVqrvb
qrvbsrnVqrvbqrvbrbzVqrvbqrvbqrvbqrvbrbzVqrvbqrvbqrvbqrvbqrvb
rbzVsrnVrbzVqrvbsrnVqrvbsrnVrbzVqrvbsrnVqrvbqrvbrbzVrbzVrbzV
rbzVsrnVsrnVqrvbqrvbqrvbOV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhZTwhXDQjXDQj
XDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobOV41OV41OV41UaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9Qmw93dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/2szK2szK3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbqrvbsrnVqrvb
qrvbqrvbqrvbrbzVqrvbqrvbqrvbqrvbqrvbqrvbsrnVrbzVqrvbqrvbqrvb
rbzVrbzVqrvbqrvbqrvbrbzVqrvbrbzVqrvbqrvbqrvbsrnVrbzVqrvbrbzV
rbzVqrvbrbzVrbzVqrvbrbzVsrnVqrvbqrvbqrvbqrvbrbzVrbzVrbzVrbzV
qrvbqrvbqrvbrbzVqrvbrbzVqrvbqrvbqrvbqrvbrbzVrbzVqrvbqrvbsrnV
qrvbqrvbqrvbrbzVqrvbrbzVOV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjTSobTSobTSobTSobOV41OV41OV41UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9Qmw9OV413dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/rbzVrbzVqrvbqrvb
rbzVsrnVrbzVsrnVqrvbrbzVrbzVrbzVrbzVqrvbqrvbqrvbrbzVsrnVrbzV
srnVsrnVsrnVrbzVsrnVrbzVsrnVrbzVrbzVsrnVqrvbsrnVsrnVsrnVsrnV
rbzVsrnVsrnVrbzVsrnVqrvbrbzVsrnVsrnVsrnVsrnVqrvbqrvbsrnVrbzV
rbzVsrnVsrnVrbzVsrnVrbzVrbzVrbzVqrvbsrnVsrnVrbzVsrnVqrvbsrnV
rbzVrbzVsrnVrbzVqrvbOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVUJhVOV41OV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSob
TSobTSobTSobTSobTSobTSobOV41OV41OV41UaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9Qmw9OV413dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVrbzVrbzVqrvb
qrvbsrnVqrvbrbzVqrvbqrvbqrvbsrnVrbzVrbzVsrnVsrnVqrvbsrnVqrvb
qrvbqrvbqrvbsrnVqrvbsrnVqrvbqrvbsrnVrbzVrbzVqrvbqrvbqrvbqrvb
srnVqrvbqrvbsrnVqrvbrbzVsrnVrbzVqrvbrbzVqrvbsrnVsrnVqrvbsrnV
qrvbrbzVqrvbsrnVqrvbqrvbsrnVsrnVsrnVqrvbqrvbsrnVqrvbrbzVrbzV
qrvbsrnVqrvbsrnVrbzVOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUaheOV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobOV41OV41OV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVUJhVQmw9OV41OV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVsrnVsrnV
rbzVqrvbqrvbsrnVsrnVrbzVrbzVqrvbsrnVqrvbrbzVqrvbrbzVqrvbsrnV
rbzVrbzVqrvbrbzVqrvbsrnVsrnVqrvbsrnVsrnVrbzVrbzVrbzVsrnVqrvb
srnVrbzVqrvbrbzVqrvbqrvbsrnVrbzVsrnVsrnVrbzVrbzVrbzVqrvbsrnV
qrvbrbzVsrnVrbzVsrnVqrvbqrvbrbzVqrvbsrnVqrvbrbzVsrnVsrnVrbzV
qrvbsrnVqrvbsrnVqrvbOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9OV41TSobXDQjXDQjXDQjXDQjXDQj
XDQjTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobOV41OV41TSobOV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheQmw9Qmw9
Qmw9Qmw9UJhVUJhVUaheUaheUaheUaheUJhVUJhVQmw9OV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbrbzVrbzVsrnV
srnVsrnVqrvbrbzVsrnVsrnVrbzVqrvbsrnVqrvbrbzVsrnVrbzVrbzVsrnV
srnVsrnVsrnVsrnVrbzVrbzVqrvbsrnVqrvbqrvbsrnVsrnVsrnVqrvbsrnV
rbzVsrnVsrnVsrnVsrnVrbzVqrvbsrnVqrvbrbzVsrnVsrnVsrnVrbzVrbzV
srnVqrvbqrvbsrnVqrvbrbzVrbzVsrnVsrnVrbzVsrnVsrnVsrnVqrvbsrnV
srnVqrvbrbzVqrvbsrnVOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQj
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobOV41OV41OV41OV41
OV41OV41OV41OV41OV41PGc6UaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9Qmw9UJhVQmw9
UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUJhVUJhVUJhVOV41OV413dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnVsrnVqrvb
qrvbrbzVrbzVsrnVqrvbqrvbsrnVrbzVrbzVsrnVsrnVqrvbsrnVsrnVqrvb
srnVqrvbsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnV
qrvbrbzVqrvbrbzVsrnVsrnVqrvbrbzVsrnVqrvbqrvbrbzVsrnVsrnVrbzV
srnVsrnVqrvbsrnVsrnVsrnVqrvbrbzVsrnVrbzVqrvbqrvbsrnVqrvbrbzV
rbzVsrnVsrnVqrvbqrvbOV41OV41UJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVOV41OV41TSobTSobXDQjXDQjXDQjXDQj
TSobTSobTSobTSobOV41OV41OV41OV41OV41OV41OV41OV41OV41UaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVSYVLO2U5OV41
OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVqrvbsrnVrbzV
srnVsrnVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnVrbzVsrnVqrvbrbzVsrnV
qrvbsrnVqrvbsrnVqrvbsrnVsrnVqrvbqrvbqrvbsrnVqrvbrbzVsrnVqrvb
srnVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVsrnVrbzVrbzVsrnV
rbzVrbzVsrnVrbzVsrnVqrvbsrnVsrnVqrvbsrnVsrnVrbzVrbzVsrnVsrnV
srnVqrvbrbzVsrnVsrnVOV41OV41UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41TSobTSobXDQjXDQjXDQjXDQjTSob
TSobTSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVUJhVT5ZUOmE3
OV41OV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVrbzVsrnV
qrvbsrnVqrvbrbzVrbzVsrnVsrnVqrvbsrnVqrvbsrnVqrvbsrnVsrnVrbzV
rbzVsrnVqrvbsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVqrvbsrnVrbzV
qrvbrbzVqrvbsrnVsrnVrbzVsrnVqrvbrbzVrbzVsrnVsrnVsrnVsrnVsrnV
srnVrbzVsrnVqrvbsrnVrbzVsrnVsrnVqrvbrbzVsrnVsrnVsrnVqrvbsrnV
srnVsrnVrbzVrbzVmrfGOV41Qmw9UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41TSobTSobXDQjXDQjXDQjXDQjTSob
TSobTSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUJhVQ4xfQ31P
OV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/qrvbsrnVsrnVsrnV
qrvbsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnV
srnVrbzVsrnVrbzVqrvbqrvbsrnVsrnVrbzVsrnVrbzVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVqrvbsrnVsrnVrbzVsrnV
srnVsrnVsrnVsrnVrbzVsrnVsrnVrbzVsrnVsrnVsrnVsrnVrbzVsrnVrbzV
srnVsrnVsrnVsrnVsLnTQmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9TSobTSobTSobXDQjXDQjXDQjTSobTSob
TSobTSobTSobOV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheQ4xfQ4xf
OmxEOV41OV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/yru/qrvbrbzVrbzV
srnVrbzVrbzVsrnVsrnVsrnVrbzVsrnVsrnVsrnVrbzVsrnVrbzVsrnVsrnV
srnVrbzVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnV
srnVsrnVqrvbsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVqrvbsrnVsrnVsrnV
srnVrbzVsrnVsrnVsrnVqrvbsrnVsrnVsrnVsrnVqrvbsrnVsrnVsrnVrbzV
srnVsrnVsrnVrbzVsLnRQmw9UJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41TSobTSobTSobXDQjXDQjXDQjTSobTSob
TSobTSobOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheQmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvQ4xf
Q4pcOV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnVrbzV
srnVsrnVsrnVsrnVsrnVsrnVrbzVrbzVqrvbsrnVsrnVsrnVqrvbrbzVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVrbzVrbzVsrnVsrnVsrnV
rbzVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVqrvbsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnV
rbzVsrnVsrnVsrnVQmw9Qmw9UaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41TSobTSobTSobXDQjXDQjTSobTSobTSob
TSobOV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
Q4xfQ31QOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/yru/srnVsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVrbzVsrnVsrnVsrnVuLjVsrnVuLjVuLjVsrnVsrnVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnV
srnVsrnVrLfPQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUJhVOV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobTSobXDQjXDQjTSobTSobTSobTSob
OV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheOV41UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
Q4xfQ4xfQnBBOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/srnVsrnV
srnVuLjVqrvbsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnV
srnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnV
rbzVu7jQsrnVrbzVsrnVuLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVrbzVu7jQsrnVrbzVrbzVsrnVsrnVsrnVu7jQrbzVu7jQsrnV
rbzVsLnTQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UJhVUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobTSobXDQjTSobTSobTSobTSobTSob
OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvQ4xfQ4xfOV41OV413dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQsrnV
srnVsrnVu7jQrbzVsrnVsrnVsrnVsrnVsrnVrbzVrbzVsrnVsrnVsrnVsrnV
rbzVu7jQu7jQu7jQrbzVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnV
srnVqrvbsrnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVrbzVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVrbzVuLjVuLjVsrnVu7jQrbzVsrnVuLjVsrnVsrnVuLjV
srnVP2M/Qmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUJhVUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobTSobTSobTSobOV41
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheOV41Qmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa5d/Z+fLX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/rbzVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVu7jQsrnVsrnVsrnVsrnV
srnVuLjVuLjVsrnVsrnVsrnVsrnVuLjVsrnVsrnVuLjVuLjVsrnVsrnVsrnV
srnVu7jQsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnV
gJOaQmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUJhVQmw9OV41Qmw9UJhVUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobTSobTSobOV41OV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQ4xfOV413dfa3dfa9/DY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/srnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVu7jQrbzVsrnVsrnVuLjVuLjVsrnV
u7jQsrnVuLjVu7jQsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVu7jQuLjVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVipej
Qm0/Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVOV41OV41UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobTSobOV41OV41OV41Uahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV413dfa3dfa9O3Y/PTX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/
srnVuLjVsrnVsrnVsrnVu7jQsrnVuLjVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnV
srnVsrnVsrnVsrnVsrnVrbzVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVu7jQ
srnVuLjVsrnVsrnVsrnVuLjVsrnVsrnVsrnVsrnVsrnVsrnVsrnVuLjVQmw9
Qmw9Qmw9UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVQmw9OV41UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41TSobTSobTSobOV41OV41UaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV413dfa3dfa8OnY/fXX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
mIZ/mIZ/srnVsrnVu7jQrbzVu7jQsrnVsrnVsrnVrbzVu7jQu7jQu7jQsrnV
srnVsrnVsrnVuLjVsrnVu7jQsrnVsrnVsrnVsrnVu7jQu7jQsrnVu7jQsrnV
srnVsrnVsrnVuLjVu7jQsrnVuLjVu7jQsrnVu7jQu7jQuLjVsrnVsrnVsrnV
srnVsrnVsrnVu7jQsrnVu7jQsrnVuLjVu7jQsrnVsrnVu7jQsrnViq+hQmw9
Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVQmw9OV41UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41TSobOV41OV41OV41UaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheQmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa7OXZ/vbX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/7t/I
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+PHY//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/mIZ/mIZ/srnVuLjVsrnVsrnVsrnVsrnVuLjVsrnVsrnVsrnVu7jQsrnV
uLjVuLjVu7jQu7jQu7jQsrnVuLjVsrnVuLjVuLjVsrnVsrnVu7jQsrnVsrnV
u7jQuLjVsrnVu7jQsrnVsrnVsrnVsrnVu7jQsrnVsrnVu7jQsrnVsrnVu7jQ
u7jQu7jQu7jQsrnVu7jQsrnVu7jQu7jQsrnVuLjVu7jQsrnVQmw9Qmw9UJhV
UJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVQmw9OV41Q4xfUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUJhVUJhVOV41OV41OV41OV41UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUJhVUJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa6OLZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/
7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa6+TZ+fHY/vbX/vbX/fXX//fX//fX7t/I7t/I
7t/ImIZ/mIZ/mIZ/uLjVsrnVu7jQuLjVsrnVu7jQsrnVsrnVsrnVsrnVuLjV
u7jQsrnVsrnVsrnVsrnVu7jQu7jQu7jQu7jQsrnVsrnVsrnVsrnVu7jQsrnV
srnVu7jQsrnVuLjVuLjVuLjVsrnVsrnVsrnVsrnVsrnVu7jQuLjVsrnVsrnV
srnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVsrnVOV41Qmw9Qmw9UJdVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQ4xfQmw9OV41Q4xfUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVOV41OV41UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa5uDZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7+bK//fXmIZ/mIZ/
7N3I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa4dva7OXZ8+zY+PDY+vLX+/PX7N3I
7t/I7t/ImIZ/mIZ/mIZ/tLnVu7jQsrnVsrnVu7jQsrnVsrnVsrnVsrnVsrnV
srnVu7jQsrnVu7jQu7jQsrnVsrnVsrnVsrnVuLjVu7jQuLjVu7jQsrnVuLjV
u7jQsrnVu7jQu7jQu7jQu7jQu7jQuLjVu7jQuLjVuLjVsrnVu7jQuLjVuLjV
u7jQsrnVu7jQuLjVsrnVu7jQu7jQuLjVu7jQQmw9Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUJhVQmw9OV41PJRvQ4xfUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvUaheUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa493Z//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PPUpJOJmIZ/mIZ/
4dPJ7d7I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3tja4dra5N7Z4NHJ
4tTJ5NbI5dfImIZ/mIZ/m4mEpJ+rsqu9uLjVsrnVs62/s62/u7jQu7jQu7jQ
srnVu7jQuLjVsrnVuLjVu7jQuLjVu7jQu7jQsrnVu7jQuLjVuLjVsrnVsrnV
uLjVsrnVsrnVsrnVsrnVuLjVu7jQsrnVu7jQu7jQuLjVsrnVu7jQu7jQsrnV
u7jQuLjVu7jQu7jQsrnVsrnVu7jQOV41OV41Qmw9Qmw9UJhVUJhVUJhVUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheQ4xfQmw9PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvUaheUaheUJhVUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa5t/Z//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/5NbI/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/4dva
8+zY+/PX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
3dfa2szK2szK2szKmIZ/mIZ/mYiDmomEnI2Nq6S2q6zAq63CuLjVuLjVuLjV
u7jQsrnVu7jQu7jQu7jQsrnVu7jQuLjVuLjVu7jQsrnVu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQu7jQuLjVu7jQsrnVu7jQsrnVsrnVu7jQu7jQsrnVsrnVu7jQ
uLjVu7jQsrnVuLjVuLjVu7jQuLjVOV41Qmw9UJhVUJhVUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVQ4xfQmw9PJRvPJRvUaheUaheUaheUaheUaheUahemIZ/Uahe
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa6+XZ//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/2szK8erY//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
3dfa5d7Z9O3Y//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mYeBu7jQu7jQsrnVu7jQ
u7jQuLjVuLjVuLjVu7jQsrnVu7jQu7jQsrnVu7jQsrnVuLjVuLjVuLjVsrnV
uLjVuLjVuLjVu7jQsrnVu7jQuLjVu7jQu7jQuLjVuLjVu7jQu7jQuLjVu7jQ
srnVu7jQu7jQu7jQuLjVu7jQuLjVQmw9UJhVUJhVUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUJhVQmw9OV41PJRvPJRvUaheUaheUaheUahemIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQ4xfOV41OV413dfa8erY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/3dfa8erY+vPX//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/
opGM3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/uLjVsrnVu7jQsrnVuLjV
uLjVu7jQu7jQu7jQuLjVu7jQu7jQsrnVu7jQuLjVu7jQu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQuLjVu7jQuLjVu7jQu7jQuLjVu7jQu7jQu7jQuLjVu7jQuLjV
u7jQuLjVu7jQuLjVu7jQsrnVu7jQQmw9Q4xfQ4xfPJRvPJRvUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUJhVUJhVQmw9PJRvPJRvUaheUaheUahemIZ/mIZ/mIZ/mIZ/mIZ///fX
//fX//fX//fX//fX//fX//fX//fXmIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvOV41PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV41OV413dfa+PDY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
mIZ/mIZ/3dfa3tja6uTZ9u/Y//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/va2p2cvJ3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/uLjVu7jQu7jQuLjVu7jQu7jQ
uLjVsrnVuLjVu7jQu7jQuLjVu7jQuLjVu7jQu7jQu7jQu7jQsrnVu7jQu7jQ
uLjVu7jQu7jQu7jQu7jQu7jQuLjVu7jQu7jQuLjVuLjVu7jQsrnVu7jQu7jQ
u7jQsrnVu7jQuLjVu7jQuLjVu7jQQmw9Qmw9Q4xfPJRvPJRvUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUJhVQ4xfOV41PJRvPJRvUaheUahemIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/UaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvOV41PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV41OV414Nna+vLX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
mIZ/mIZ/3dfa3dfa3dfa5d/Z+vLX/fXX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/m4mCyLm22szK3dfa3dfa3dfa3dfa//fX3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/u7jQu7jQuLjVu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQu7jQuLjVu7jQu7jQuLjVuLjVuLjVu7jQuLjVuLjV
u7jQuLjVuLjVuLjVu7jQuLjVu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQuLjV
uLjVu7jQuLjVu7jQu7jQu7jQu7jQOV41Qmw9Q4xfQ4xfPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVQmw9OV41PJRvPJRvUahemIZ/mIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/Y7BqUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvOV82PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvQmw9OV413dfa5uDZ9+/Y//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/ImIZ/mIZ/3dfa3dfa3dfa3tja7+jY+fHY//fX//fX//fX//fX//fX//fX
mIZ/mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/uLjVu7jQuLjVu7jQu7jQu7jQuLjVuLjV
u7jQu7jQu7jQuLjVu7jQwbbQu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQu7jQ
u7jQu7jQu7jQuLjVu7jQuLjVuLjVuLjVu7jQu7jQuLjVu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQwbbQu7jQuLjVu7jQOV41OV41Q4xfQ4xfQ4xfPJRvPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UJhVUJhVOV41OV41PJRvUahemIZ/mIZ///fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvOnFJUKZdUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQmw9OV413dfa7OXZ9u7Y//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fXmIZ/mIZ/7t/I2szK2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/mIZ/u7jQu7jQu7jQuLjVu7jQu7jQuLjVu7jQu7jQu7jQu7jQ
wbbQu7jQuLjVu7jQu7jQu7jQwbbQuLjVwbbQu7jQu7jQwbbQu7jQu7jQuLjV
u7jQu7jQu7jQwbbQu7jQwbbQu7jQu7jQu7jQuLjVu7jQuLjVu7jQu7jQuLjV
u7jQu7jQuLjVuLjVuLjVu7jQuLjVu7jQOV41Qmw9Qmw9Qmw9Q4xfPJRvPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
Q4xfQmw9OV41PJRvmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvO3pTUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfQmw9OV413dfa7+jY/fXX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ/7t/I2szK2szK2szK2szK2szK2szK2szK3dfamIZ/
mIZ/mIZ/u7jQu7jQu7jQu7jQu7jQu7jQu7jQuLjVu7jQuLjVuLjVu7jQuLjV
uLjVwbbQu7jQuLjVuLjVuLjVu7jQuLjVwbbQuLjVuLjVwbbQuLjVu7jQuLjV
u7jQu7jQu7jQuLjVuLjVu7jQwbbQuLjVu7jQu7jQu7jQu7jQuLjVwbbQwbbQ
uLjVu7jQu7jQu7jQu7jQwbbQwbbQwbbQuLjVOV41Qmw9Qmw9Qmw9Q4xfPJRv
PJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
Q4xfQmw9OV41mIZ/mIZ/3dfa+vLX/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/ImIZ/mIZ/mIZ/m4mD3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
uLjVu7jQu7jQwbbQwbbQwbbQwbbQu7jQu7jQwbbQu7jQwbbQuLjVwbbQu7jQ
wbbQu7jQuLjVu7jQwbbQu7jQu7jQu7jQuLjVwbbQu7jQuLjVwbbQwbbQwbbQ
wbbQuLjVuLjVu7jQu7jQwbbQuLjVu7jQwbbQwbbQwbbQuLjVu7jQu7jQuLjV
wbbQu7jQwbbQu7jQwbbQu7jQuLjVuLjVwbbQwbbQOV41Qmw9Qmw9Q4xfQ4xf
PJRvPJRvPJRvPJRvPJRvUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
Q4xfOV41mIZ/mIZ/3dfa3dfa8+zY/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvOV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
7t/I7t/I7t/ImIZ/mIZ/mIZ/2NHT18/R3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/u7jQu7jQwbbQu7jQu7jQwbbQu7jQuLjVwbbQ
u7jQwbbQwbbQuLjVuLjVuLjVu7jQwbbQu7jQu7jQwbbQuLjVwbbQu7jQuLjV
uLjVwbbQwbbQu7jQu7jQwbbQwbbQu7jQu7jQwbbQu7jQu7jQu7jQu7jQuLjV
wbbQwbbQwbbQwbbQuLjVu7jQwbbQuLjVuLjVu7jQwbbQwbbQuLjVu7jQu7jQ
wbbQuLjVwbbQuLjVuLjVu7jQu7jQu7jQuLjVuLjVuLjVOV41Qmw9Q4xfQ4xf
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
Q4xfOV41mIZ/3dfa3dfa3dfa5d/Z/vbX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV413dfa8OjY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/ImIZ/mIZ/mIZ/rqCczcTF2NHT3dfa3dfa3dfa3dfa3dfa3dfa
mIZ/mIZ/3dfa3dfamIZ/mIZ/mIZ/uLjVu7jQuLjVuLjVwbbQwbbQu7jQu7jQ
uLjVuLjVu7jQu7jQu7jQu7jQuLjVwbbQu7jQu7jQu7jQu7jQuLjVwbbQu7jQ
wbbQu7jQu7jQuLjVwbbQu7jQuLjVwbbQu7jQuLjVwbbQu7jQuLjVu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQwbbQu7jQu7jQu7jQu7jQu7jQu7jQwbbQwbbQwbbQ
uLjVu7jQuLjVu7jQwbbQu7jQwbbQuLjVu7jQu7jQu7jQwbbQOV41Qmw9Q4xf
Q4xfPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
TpFlmIZ/mIZ/3dfa3dfa3dfa3dfa9O3Y/PTX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41OV41UaheUaheUaheUaheVqZgU6dfVqZgWqRiUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4ZZOV41OV413dfa7+jY//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/pJSPsaShwLW01M3P3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/3dfa3dfamIZ/mIZ/wbbQu7jQwbbQu7jQu7jQu7jQwbbQwbbQ
u7jQu7jQwbbQu7jQu7jQwbbQu7jQu7jQuLjVu7jQwbbQu7jQwbbQu7jQwbbQ
wbbQwbbQwbbQu7jQwbbQu7jQuLjVu7jQu7jQu7jQwbbQwbbQwbbQwbbQwbbQ
uLjVwbbQu7jQwbbQu7jQu7jQwbbQwbbQwbbQu7jQu7jQu7jQuLjVuLjVwbbQ
wbbQwbbQwbbQu7jQwbbQuLjVwbbQwbbQwbbQwbbQu7jQu7jQwbbQeYVoQmw9
Q4xfRIxfPpVwP5ZxRZl0PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xf
mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa8+zY8+zY6OLZ6uPZ8uvYmIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/2szK6uPZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
OV41OV41UaheUaheUaheUahemIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
VaphUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4teOV41OV413dfa7ufZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/ImIZ/mIZ/u7jQmIZ/mIZ/mIZ/mIZ/oI+Jxry72NLU3NbZ
3NbZ2NHUmIZ/mIZ/mIZ/3dfamIZ/mIZ/u7jQwbbQu7jQu7jQuLjVu7jQwbbQ
wbbQuLjVwbbQwbbQuLjVu7jQwbbQwbbQwbbQu7jQwbbQu7jQwbbQuLjVu7jQ
u7jQuLjVu7jQwbbQuLjVwbbQwbbQwbbQwbbQwbbQuLjVu7jQuLjVu7jQu7jQ
wbbQuLjVwbbQu7jQwbbQwbbQu7jQu7jQu7jQwbbQwbbQu7jQwbbQu7jQu7jQ
u7jQu7jQu7jQu7jQu7jQwbbQu7jQu7jQu7jQu7jQwbbQwbbQu7jQe6SLeYVo
OV41U5RoQ4xfQ4xfPJRvPZRvPpVwPJRvPJRvPJRvPJRvPJRvPJRvPJRvRIxf
mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa39na7ebZ9e3YmIZ/mIZ/mIZ///fX
//fX//fX//fXmIZ/mIZ/3dfa2szK8uvY//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/UaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41
OV41OV41Y7BrmIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fXmIZ/
mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4xfOV41OV41OV416+TZ//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/ImIZ/wbbQuLjVu7jQmIZ/mIZ/mIZ/mIZ/mIZ/oZCL
3dfa3dfarqCcmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQu7jQwbbQu7jQ
u7jQwbbQu7jQu7jQu7jQwbbQuLjVu7jQuLjVwbbQuLjVu7jQuLjVwbbQwbbQ
wbbQwbbQu7jQwbbQu7jQu7jQuLjVu7jQu7jQwbbQwbbQwbbQwbbQu7jQu7jQ
wbbQwbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQu7jQu7jQwbbQwbbQu7jQmIZ/
2szKeYVoQmw9PZRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfmIZ/
mIZ/3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa//fX
//fX//fX//fX//fXmIZ/mIZ/3dfa2szK6eLZ//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/UaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41
OV41OV41mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvQ4pcOV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQu7jQmIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQuLjVwbbQwbbQ
u7jQu7jQwbbQwbbQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQu7jQuLjVu7jQ
u7jQu7jQwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQ
u7jQuLjVu7jQwbbQwbbQu7jQwbbQu7jQwbbQu7jQwbbQwbbQwbbQu7jQwbbQ
u7jQwbbQu7jQu7jQwbbQu7jQwbbQwbbQu7jQwbbQwbbQu7jQu7jQxbvQmIZ/
2szK2szKeYVoOV41OV41P5ZxPJRvPJRvPJRvPJRvPJRvPJRvQ4xfRIxfmIZ/
3dfamIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK5N3Z/vbX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
UqlfUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvQZNwPJRvPJRvWZ58SGRB
OV41mIZ/mIZ///fX//fXmIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX
mIZ/mIZ/WKtjUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4ZYOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/ImIZ/u7jQu7jQwbbQwbbQwbbQmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/wbbQwbbQwbbQwbbQu7jQ
wbbQwbbQu7jQwbbQwbbQu7jQwbbQu7jQwbbQu7jQwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQu7jQwbbQwbbQu7jQwbbQ
wbbQwbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQu7jQu7jQu7jQwbbQu7jQwbbQ
u7jQwbbQwbbQu7jQwbbQu7jQu7jQwbbQwbbQu7jQwbbQwbbQu7jQmIZ/mIZ/
2szK2szK2szK2szKOV41OV41OV41RJhzPJRvPJRvPJRvP5ZxQ4xfcKN3mIZ/
mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK2szK+fHY//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/d7l4PJRvPJRvPJRvPJRvPJRvmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX
//fXmIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQwbbQwbbQu7jQwbbQu7jQ
wbbQwbbQwbbQu7jQu7jQu7jQu7jQwbbQwbbQwbbQu7jQwbbQu7jQwbbQu7jQ
wbbQwbbQu7jQwbbQwbbQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQ
wbbQu7jQwbbQu7jQybTKwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQwbbQu7jQ
wbbQwbbQu7jQu7jQwbbQwbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQwbbQwbbQ
wbbQwbbQu7jQybTKwbbQwbbQwbbQwbbQu7jQwbbQwbbQwbbQz7q9mIZ/2szK
2szK3dfa2szK2szK2szKrr6mOV41Qmw9Qmw9Qmw9Qmw9Qmw9Qmw9OV41mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3c7K+PDY//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX/PXVmIZ/mIZ/PJRvPJRvmIZ/mIZ/mIZ///fX8vHO/vfX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/+O3R//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX
//fX//fXmIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/u7jQu7jQu7jQwbbQwbbQwbbQwbbQ
wbbQwbbQu7jQwbbQwbbQwbbQwbbQwbbQu7jQu7jQwbbQu7jQwbbQwbbQwbbQ
u7jQwbbQwbbQwbbQu7jQwbbQwbbQu7jQybTKu7jQybTKwbbQu7jQu7jQu7jQ
wbbQu7jQwbbQu7jQwbbQwbbQu7jQu7jQwbbQwbbQu7jQwbbQwbbQybTKu7jQ
wbbQwbbQwbbQu7jQwbbQu7jQwbbQwbbQwbbQwbbQwbbQwbbQwbbQu7jQybTK
u7jQwbbQu7jQu7jQwbbQwbbQwbbQwbbQwbbQu7jQu7jQwbbQmIZ/mIZ/2szK
2szK3dfa3dfa3dfa3dfa2szK2szKeYVoQmw9Y51wQmw9Qmw9OV41OV41OV41
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa6uPZ//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R//fX//fX//fXmIZ/mIZ///fX//fX
//fXmIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfOV41OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQu7jQwbbQwbbQwbbQu7jQ
u7jQwbbQwbbQwbbQwbbQwbbQu7jQybTKwbbQu7jQwbbQwbbQwbbQybTKwbbQ
wbbQu7jQu7jQwbbQwbbQwbbQwbbQu7jQwbbQu7jQu7jQwbbQwbbQwbbQwbbQ
u7jQybTKybTKxrTQu7jQwbbQwbbQwbbQu7jQybTKwbbQwbbQu7jQu7jQybTK
wbbQwbbQwbbQwbbQwbbQxrTQwbbQwbbQwbbQybTKwbbQu7jQwbbQwbbQwbbQ
wbbQwbbQwbbQybTKu7jQwbbQu7jQwbbQwbbQxrTQwbbQu7jQmIZ/2szK2szK
3dfa3dfa3dfa4tza5N7Z5d7Z5d7Z5+HZ2c7EOV41OV41OV41OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3tja//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvQ4xfQmw9OV41Q4xfOV41OV41//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQu7jQu7jQxrTQ
wbbQwbbQu7jQwbbQu7jQu7jQwbbQu7jQwbbQwbbQybTKybTKu7jQwbbQu7jQ
u7jQxrTQwbbQwbbQu7jQybTKwbbQwbbQwbbQwbbQwbbQwbbQwbbQwbbQwbbQ
u7jQu7jQu7jQybTKwbbQwbbQybTKybTKu7jQwbbQwbbQybTKxrTQwbbQwbbQ
wbbQwbbQybTKu7jQybTKwbbQu7jQwbbQwbbQu7jQybTKu7jQybTKu7jQwbbQ
wbbQwbbQwbbQybTKu7jQybTKybTKu7jQybTKwbbQwbbQu7jQmIZ/2szK2szK
3dfa3dfa6uPZ9O3Y8uvY8uvY+PDY//fX/vbX/vbX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK3dfa3dfa
//fX//fX//fX//fX//fXmIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ/W61l
VqpiUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvQ4xfQmw9OV41Q4xfOV41OV41OV41//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQwbbQybTKu7jQwbbQ
ybTKybTKu7jQybTKybTKwbbQxrTQu7jQwbbQu7jQu7jQwbbQu7jQybTKybTK
u7jQwbbQybTKybTKu7jQu7jQwbbQybTKu7jQybTKybTKu7jQwbbQwbbQwbbQ
xrTQxrTQwbbQu7jQybTKu7jQu7jQwbbQwbbQybTKwbbQu7jQwbbQwbbQu7jQ
ybTKu7jQu7jQybTKwbbQu7jQybTKwbbQwbbQybTKwbbQwbbQwbbQwbbQybTK
wbbQwbbQwbbQu7jQybTKu7jQu7jQwbbQu7jQybTKwbbQmIZ/mIZ/2szK2szK
3dfa7ufZ//fX8+zY9u/Y+/PX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/2szK2szK3dfa
//fX//fX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R+O3R+O3R
//fX//fX//fX//fX//fX//fX//fXmIZ/+O3R+O3R//fX//fX//fXmIZ/V6ti
WqxkUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvQmw9OV41PJRvQ4xfQmw9OV41//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQwbbQybTK
u7jQwbbQybTKwbbQwbbQwbbQu7jQybTKybTKwbbQwbbQybTKxrTQu7jQu7jQ
ybTKybTKu7jQwbbQwbbQwbbQybTKwbbQwbbQu7jQu7jQwbbQybTKybTKwbbQ
wbbQybTKwbbQwbbQybTKwbbQwbbQwbbQwbbQu7jQxrTQybTKu7jQybTKu7jQ
ybTKwbbQwbbQwbbQybTKwbbQwbbQwbbQwbbQwbbQybTKu7jQybTKu7jQybTK
u7jQwbbQxrTQwbbQwbbQwbbQybTKwbbQwbbQybTKu7jQmIZ/mIZ/2szK2szK
6uPZ+PDY//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/2szK2szK
3dfa//fX//fX//fX//fX7t/ImIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/+O3R+O3R
+O3R+O3R//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX+fDSnZOFmIZ/
U6lfUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvQ4BSQmw9PJRvQ4xfQmw9Qmw9//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQu7jQybTKu7jQwbbQ
wbbQwbbQwbbQwbbQwbbQxrTQwbbQwbbQwbbQybTKu7jQu7jQybTKwbbQwbbQ
wbbQwbbQwbbQybTKu7jQwbbQwbbQwbbQxrTQxrTQybTKu7jQu7jQu7jQwbbQ
ybTKwbbQwbbQwbbQwbbQybTKwbbQwbbQwbbQybTKu7jQu7jQybTKwbbQybTK
wbbQwbbQu7jQybTKwbbQu7jQybTKu7jQybTKu7jQwbbQxrTQwbbQwbbQu7jQ
ybTKybTKwbbQwbbQybTKwbbQu7jQybTKwbbQwbbQybbKmIZ/2szK2szK4Nna
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/2szK
3dfa3dfa//fX//fX//fX//fXmIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/+O3R+O3R+O3R//fX//fX//fXmIZ/mIZ/mIZ/+O3R//fX//fXm4mBmIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvQ4teQm4/OV41PJRvQ4xfQmw9OV41//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/wbbQwbbQwbbQybTK
wbbQu7jQybTKu7jQybTKybTKwbbQu7jQybTKwbbQxrTQybTKwbbQybTKwbbQ
u7jQybTKu7jQu7jQybTKu7jQybTKu7jQybTKu7jQwbbQxrTQxrTQybTKybTK
wbbQybTKybTKu7jQwbbQybTKybTKu7jQwbbQybTKybTKwbbQybTKu7jQwbbQ
ybTKybTKu7jQwbbQxrTQwbbQybTKu7jQybTKwbbQybTKu7jQybTKwbbQwbbQ
u7jQybTKu7jQwbbQybTKybTKu7jQwbbQwbbQwbbQ0rq7mIZ/2szK3dfa4tza
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX/PXX3tjamIZ/mIZ/
2szK2szK7ebZ//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/
mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fXmIZ/mIZ/+O3R//fX//fX//fXmIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJJtQnlLQmw9PJRvPJRvQ4xfQmw9OV41//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/u7jQybTKwbbQybTK
wbbQwbbQybTKu7jQu7jQu7jQybTKu7jQwbbQu7jQwbbQwbbQwbbQybTKybTK
wbbQybTKybTKwbbQybTKwbbQybTKu7jQybTKwbbQybTKu7jQwbbQwbbQwbbQ
ybTKwbbQu7jQybTKybTKu7jQwbbQybTKybTKwbbQu7jQybTKwbbQwbbQybTK
wbbQwbbQwbbQybTKu7jQybTKwbbQybTKybTKu7jQwbbQybTKwbbQwbbQwbbQ
ybTKu7jQybTKwbbQwbbQwbbQybTKybTKu7jQwbbQvbrQmIZ/2szK3dfa49za
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX8OnY3dfa3dfamIZ/
mIZ/2szK2szK5uDZ/PXX/vbX//fXmIZ/mIZ/mIZ/mIZ/7N3G//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/+O3R+O3R+O3R//fX//fXmIZ/mIZ/+O3R//fX//fXmIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJRvQ4xfQ4xfPJRvPJRvPJRvQmw9Qmw9OV41//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/ybTKwbbQwbbQwbbQ
u7jQybTKwbbQxrTQybTKybTKybTKybTKybTKybTKwbbQybTKu7jQwbbQwbbQ
wbbQwbbQu7jQybTKu7jQybTKwbbQybTKu7jQybTKwbbQybTKybTKybTKxrTQ
u7jQybTKwbbQu7jQybTKwbbQwbbQwbbQybTKybTKu7jQybTKybTKwbbQwbbQ
ybTKybTKwbbQybTKwbbQybTKu7jQu7jQybTKybTKwbbQwbbQybTKybTKwbbQ
ybTKybTKybTKwbbQwbbQwbbQwbbQybTKybTKxrTQw7rQmIZ/2szK3dfa49za
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX5t/Z3tja3dfa3dfamIZ/
mIZ/mIZ/2szK2szK5d/Z/fXX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/7t/I//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/+O3R+O3R+O3R//fXmIZ/mIZ///fX+O3RmIZ/mIZ/mIZ/
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvQ4xfPJRvPJRvPJRvOV41Q4xfOV41OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/ybTKybTKu7jQybTK
wbbQybTKu7jQwbbQwbbQwbbQwbbQu7jQwbbQybTKu7jQybTKybTKwbbQwbbQ
ybTKybTKwbbQxrTQwbbQybTKu7jQybTKwbbQybTKu7jQu7jQwbbQybTKwbbQ
ybTKwbbQybTKybTKwbbQybTKybTKwbbQwbbQwbbQybTKwbbQwbbQybTKybTK
wbbQu7jQybTKu7jQybTKwbbQybTKybTKwbbQu7jQybTKybTKwbbQwbbQybTK
wbbQwbbQu7jQybTKybTKybTKybTKwbbQwbbQybTKy7bKmIZ/2szK3dfa4dva
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX8uvY4Nra3dfa3dfa3dfa3dfamIZ/
mIZ/mIZ/mIZ/2szK2szK3dfa+PDY//fX//fX//fXmIZ/mIZ/mIZ/7t/ImIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fXmIZ/mIZ/+O3R+O3R//fX//fXmIZ/mIZ///fXUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQmw9OV41//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/wbbQwbbQybTKybTK
u7jQybTKybTKybTKybTKybTKybTKybTKybTKwbbQxrTQwbbQu7jQybTKybTK
wbbQwbbQu7jQybTKybTKwbbQybTKwbbQybTKwbbQybTKybTKybTKwbbQybTK
ybTKwbbQwbbQybTKwbbQwbbQybTKybTKybTKu7jQybTKybTKu7jQybTKu7jQ
ybTKybTKybTKybTKybTKwbbQwbbQybTKybTKybTKu7jQybTKybTKwbbQybTK
ybTKybTKwbbQwbbQu7jQwbbQybTKybTKwbbQwbbQybTKmIZ/2szK3dfa3tja
mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX6ePZ3dfa3dfa3dfa3dfa3dfamIZ/PJRv
RJZkmIZ/mIZ/mIZ/2szK2szK2szK8+zY/vbW//fX//fX//fXmIZ/mIZ/mIZ/
7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/+O3R+O3R//fXmIZ/mIZ///fXUJhVUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQmw9Uahe//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/wbbQwbbQybTK
ybTKu7jQu7jQybTKu7jQwbbQwbbQwbbQybTKybTKybTKybTKwbbQwbbQybTK
ybTKybTKybTKu7jQybTKwbbQybTKwbbQybTKwbbQybTKu7jQybTKwbbQwbbQ
wbbQybTKybTKwbbQybTKybTKwbbQwbbQwbbQybTKwbbQybTKybTKwbbQybTK
ybTKwbbQwbbQwbbQwbbQybTKybTKwbbQwbbQwbbQybTKwbbQwbbQybTKwbbQ
wbbQwbbQybTKybTKybTKybTKwbbQwbbQybTKybTKwbbQmIZ/2szK3dfa3dfa
mIZ/7t/I7t/I//fX//fX//fX//fX//fX//fX//fXmIZ/7t/I7t/I7t/I7t/I
7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX
//fX/vbX+/PX//fX9/DY9O3Y5t/Z3dfa3dfa3dfa3dfamIZ/mIZ/ValhPJRv
RJZkRpdlSJdnmIZ/mIZ/2szK2szK2szK6eLZ/vbX/vbX//fX//fXmIZ/mIZ/
mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ/+O3R+O3RmIZ/mIZ/3dfaQmw9UJhVUJhV
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQmw9Qmw9zM6x
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/ybTKybTKybTK
wbbQybTKybTKwbbQybTKybTKybTKybTKwbbQu7jQybTKwbbQybTKybTKwbbQ
wbbQwbbQwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKybTK
wbbQwbbQybTKwbbQwbbQybTKybTKybTKwbbQybTKwbbQwbbQybTKwbbQwbbQ
ybTKybTKybTKybTKwbbQwbbQybTKybTKybTKybTKybTKybTKwbbQybTKybTK
ybTKwbbQwbbQwbbQwbbQybTKybTKwbbQwbbQybTKy8HRmIZ/2szK3dfa3dfa
mIZ/mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX7t/ImIZ/7t/ImIZ/mIZ/
7t/ImIZ/7t/I7t/I7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ///fX+fLX
9+/Y9u/Y8uvY6uPZ4tza2szK2szK3dfa3dfamIZ/mIZ/WKpkUaheUahePJRv
PJRvRJZkRZZlRZZkmIZ/mIZ/no2F2szK2szK2szK8uvY8OnY//fX//fXmIZ/
mIZ/7d7I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fXmIZ/mIZ///fX+O3RmIZ/mIZ/orSeQmw9UJhVUJhV
UJhVUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvQ4xfQ4xfQ4xfQ4xfR45haJ9zQm0+5uLJ
9vDP//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/wbbQwbbQybTK
wbbQwbbQybTKwbbQwbbQwbbQwbbQybTKybTKwbbQybTKwbbQybTKybTKybTK
ybTKybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKwbbQwbbQxrTQ
ybTKybTKybTKybTKybTKwbbQwbbQwbbQybTKybTKybTKybTKwbbQybTKybTK
ybTKwbbQwbbQwbbQybTKybTKybTKwbbQwbbQwbbQwbbQwbbQybTKwbbQwbbQ
ybTKybTKybTKybTKybTKwbbQwbbQybTKybTKwbbQzbjKmIZ/2szK2szK3dfa
mIZ/mIZ/mIZ/7t/I//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/6OHZ5t/Z493Z4dva39na
3tja3tja3dfa3dfa2szK3dfa3dfa3dfamIZ/UaheUaheUaheUaheUahePJRv
PJRvPJRvRJZkRJZkRJZkRZZlmIZ/nIuF18jG2szK3dfa3dfa7OXZ//fX//fX
//fXmIZ/mIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/nYyG3dfaorSeQmw9UJhV
UJhVUJhVUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvQ4xfQ4xfQ4xfQ4xfQ4xfQWw9OV41OV41OV41OV41//fX//fX
9e/P//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTKwbbQ
ybTKybTKwbbQybTKybTKybTKybTKwbbQwbbQybTKwbbQybTKu7jQybTKwbbQ
wbbQwbbQwbbQybTKybTKwbbQybTKwbbQybTKwbbQybTKwbbQybTKybTKybTK
xrTQwbbQybTKu7jQybTKybTKybTKwbbQwbbQwbbQybTKybTKybTKybTKwbbQ
ybTKybTKybTKybTKwbbQxrTQybTKybTKybTKybTKybTKwbbQybTKybTKwbbQ
wbbQybTKwbbQybTKybTKybTKybTKwbbQybTKwbbQwbbQmIZ/mIZ/2szK3dfa
mIZ/2szKmIZ/mIZ///fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa2szK2szK2szK2szK2szK
2szK2szK2szK2szK3dfamIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvRJZkRJZkRJZkmIZ/mIZ/mIZ/yLm22szK2szK3dfa8erY+fDR
//fX//fX/vbXmIZ/mIZ/7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX4trQ3dfaorSeorSeQmw9
Qmw9UJhVUJhVUJhVUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvQ4xfQ4xfQ4xfOV41OV41OV41OV41OV41//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/wbbQybTKybTK
ybTKybTKxrTQwbbQybTKybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKybTK
ybTKybTKwbbQxrTQybTKybTKybTKwbbQybTKxrTQybTKybTKybTKybTKybTK
ybTKybTKwbbQybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKwbbQybTK
ybTKybTKybTKwbbQybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTK
ybTKwbbQybTKwbbQybTKwbbQybTKybTKxrTQybTKybTKybTKmIZ/2szK3dfa
3dfa3dfamIZ/mIZ/mIZ/7t/I//fX//fX//fX3dfa//fX3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK3dfa2szK2szKmIZ/
3dfamIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvRJZkU5xuRZZkmIZ/mIZ/2szK2szK2szK3dfa6OHZ
9OvQ//fX//fX//fX//fXmIZ/mIZ/7t/I7t/I7t/I7t/I7t/I//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfaorSeQmw9
Qmw9Qmw9UJhVUJhVUJhVQ4xfQ4xfQ4xfQ4xfQ4xfQ4xfPJRvPJRvPJRvPJRv
PJRvPJRvQ4xfQmw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTKwbbQ
xrTQwbbQybTKybTKybTKwbbQybTKybTKybTKwbbQybTKybTKybTKybTKybTK
ybTKwbbQybTKybTKybTKwbbQybTKybTKybTKybTKybTKwbbQwbbQwbbQwbbQ
ybTKybTKybTKwbbQybTKybTKybTKybTKybTKwbbQybTKwbbQybTKybTKybTK
wbbQybTKybTKybTKybTKwbbQxrTQwbbQybTKwbbQybTKybTKybTKybTKybTK
ybTKybTKybTKxrTQybTKwbbQybTKybTKybTKybTKwbbQybTKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szK2szK2szK2szK3dfa
3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szKmIZ/2szKmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/WatjW6xlUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvRZZkSZdnmIZ/mIZ/mIZ/2szK2szK2szK3dfa
4dva9u/Y/fXX//fX//fX//fX/vbXmIZ/mIZ/7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX+vHT//fX5N3Z3dfa3dfa3dfa
OV41Qmw9Qmw9OV41OV41Qmw9Qmw9Qmw9Q4xfQ4xfQ4xfQ4xfQ4xfQ4xfQ4xf
Q4xfTpFlQWw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/ybTKybTKybTK
ybTKybTKybTKwbbQybTKwbbQwbbQybTKybTKybTKwbbQybTKwbbQwbbQwbbQ
ybTKybTKybTKwbbQybTKwbbQybTKwbbQybTKybTKybTKybTKybTKybTKxrTQ
ybTKybTKwbbQybTKwbbQwbbQybTKybTKwbbQybTKybTKybTKybTKybTKwbbQ
ybTKwbbQybTKwbbQxrTQybTKybTKybTKwbbQybTKybTKwbbQybTKybTKxrTQ
ybTKwbbQybTKybTKybTKybTKwbbQybTKxrTQwbbQybTKy7jKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK3dfa3dfa2szK2szK2szK
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/Uahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvRJZkRpZlmIZ/mIZ/mIZ/3dfa2szK2szK
3dfa3tja6+TZ+PHY/vbX//fX//fX//fXmIZ/mIZ///fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX/fTV//fX/vbW39na3dfa3dfa
3dfaOV41OV41OV41OV41OV41OV41mIZ/OV41OV41OV41OV41Qmw9Qmw9TJBj
Qmw9OV41OV41OV41//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/ybTKybTK
ybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKwbbQybTKybTKybTK
ybTKybTKxrTQybTKybTKybTKxrTQybTKybTKxrTQybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKxrTQxrTQybTKybTKybTKybTKybTKwbbQybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/UaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvRZZlVJxvmIZ/mIZ/mIZ/2szK
2szK3dfa3dfa4tva8erY+fHY/vbX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfaOV41OV413dfamIZ/mIZ/OV41OV41OV41OV41OV41OV41PWE4
SmtDn62J//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKwbbQybTKybTKybTKybTKybTKybTK
xrTQybTKybTKxrTQybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTK
xrTQybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTK
ybTKxrTQybTKxrTQybTKybTKybTKybTKybTKybTKybTKybTKyrnQmIZ/3dfa
3dfa3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTK
ybTKOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkmIZ/mIZ/mIZ/
2szK2szK2szK3dfa3dfa5d/Z9u/Y+/PX/vbX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa5NrT3dfamIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
6+fG//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/wbbQ
ybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTK
ybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTK
ybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKzrPLybTKz7zMmIZ/2szK
2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTKybTKzrPL
ybTKOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkmIZ/mIZ/
mIZ/o72j2szK2szK3dfa3dfa3dfa6eLZ+fHY/PTX/vbX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX8OnY3dfa5NrT5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/ybTK
xrTQybTKybTKzrPLzrPLybTKybTKzrPLybTKybTKxrTQybTKybTKxrTQybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTK
zrPLzrPLybTKybTKybTKybTKzrPLybTKybTKybTKybTKzrPLzrPLybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKzrPL
ybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKybTKz7zMmIZ/2szK
2szKmIZ/mIZ/mIZ/mIZ/mIZ/ybTKybTKybTKybTKybTKybTKzrPLybTKxrTQ
ybTKOV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkRJZk
mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa39na6uTZ9/DY/fXX/vbX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R+O3R//fXmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/xrTQ
ybTKybTKxrTQybTKybTKybTKybTKybTKxrTQybTKybTKybTKybTKybTKybTK
ybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKybTKybTKybTKxrTQ
ybTKzrPLzrPLybTKybTKybTKzrPLybTKzrPLybTKybTKybTKybTKzrPLybTK
ybTKybTKybTKybTKybTKzrPLybTKybTKybTKybTKybTKybTKybTKxrTQzrPL
ybTKzrPLybTKzrPLybTKybTKybTKzrPLybTKybTKybTKybTKybTKmIZ/2szK
mIZ/mIZ/mIZ/ybTKybTKzrPLybTKybTKzrPLybTKybTKybTKybTKybTKOV41
OV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
RJZkmIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa4Nra6+TZ+vLX/vbX/vbX
/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/ybTK
zrPLybTKybTKybTKybTKybTKybTKzrPLzrPLybTKzrPLybTKybTKybTKybTK
ybTKybTKybTKybTKybTKybTKybTKybTKybTKzrPLybTKybTKzrPLzrPLybTK
ybTKybTKybTKzrPLzrPLybTKybTKybTKybTKybTKybTKybTKzrPLybTKzrPL
ybTKzrPLybTKybTKzrPLybTKybTKzrPLzrPLybTKybTKybTKybTK0bPFybTK
zrPLybTKzrPLybTKybTKybTKzrPLybTKzrPLzrPLzrPLzrPLybTKmIZ/mIZ/
mIZ/mIZ/zrPLzrPLzrPLybTKybTKzrPLybTKybTKybTKzrPLzrPLOV41Qmw9
Qmw9OV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3tja6uTZ/fXX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX+O3R5NrTmIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/zrPL
ybTKzrPLzrPLzrPLybTK0bPFzrPLybTKybTKzrPLybTKybTKzrPLzrPLzrPL
ybTKzrPLybTKzrPLzrPLybTKybTKzrPLybTKybTKzrPLybTKybTKybTKzrPL
zrPLzrPL0bPFybTKzrPLzrPLzrPLybTKzrPLzrPLzrPLybTKybTKzrPLzrPL
ybTKzrPLzrPLybTKzrPLzrPLybTKybTKzrPLzrPLzrPLzrPLybTKzrPLybTK
zrPLybTKybTKzrPLzrPLybTKzrPLybTKybTKybTKybTKzrPLxrTQmIZ/mIZ/
mIZ/ybTKybTKybTKybTKzrPLybTK0bPFzrPLzrPLybTKybTKOV41OV41Qmw9
Q4xfOV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
7ebZ/vbX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX+O3R5NrTmIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/
ybTKybTKybTKzrPLxrTQybTKzrPLzrPLybTKzrPLzrPL0bPFybTKybTKzrPL
ybTKzrPLybTKybTKzrPLzrPLybTKzrPLzrPLybTKzrPLzrPLybTKybTKzrPL
ybTKybTKxrTQzrPLybTKybTK0bPFzrPLybTKzrPLybTKzrPLzrPLybTKybTK
0bPF0bPFybTKzrPLybTKybTKzrPLzrPLzrPLzrPLybTKybTKybTKybTKybTK
ybTKzrPL0bPFzrPLybTK0bPFybTKzrPLzrPLzrPLzrPLzrPL0bPFmIZ/mIZ/
ybTKzrPLzrPLybTKzrPLzrPLzrPLxrTQybTKzrPLzrPLzrPLOV41Qmw9Q4xf
Q4xfOV41OV41Q4xfUJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvRJZkRJZkmIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa
3dfa3tja9O3Y//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/mIZ/3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/
0bPFzrPLzrPLybTKzrPLzrPLzrPLybTKzrPLybTKybTKybTK0bPFybTKybTK
0bPFybTKzrPLzrPLybTKybTKzrPLybTK0bPFzrPLybTKzrPL0bPFzrPLybTK
ybTK0bPF0bPF0bPFzrPLybTK0bPF0bPFybTKzrPLzrPLzrPLzrPLybTKxrTQ
ybTK0bPF0bPFzrPL0bPFzrPL0bPFzrPLybTKzrPLzrPLzrPL0bPFzrPL0bPF
0bPFybTK0bPFybTKybTKzrPLzrPLybTK0bPFybTK0bPFybTK0bPFzrPLzrPL
zrPLzrPLzrPLzrPLybTKzrPLzrPLzrPLzrPL0bPFybTKybTKOV41Qmw9Q4xf
PJRvOV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvRJZkRJZkRJZkmIZ/mIZ/2szK2szK2szK3dfa3dfa
3dfa3dfa3dfa4tza+vLX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/
0bPFybTKzrPL0bPFybTK0bPFzrPL0bPFybTKybTKybTKybTK0bPFzrPLybTK
0bPF0bPFzrPL0bPF0bPFybTK0bPFxrTQybTKzrPLybTKybTKybTKzrPLybTK
zrPLzrPLybTKybTKzrPLzrPLybTKybTK0bPF0bPFybTKybTKzrPL0bPF0bPF
zrPLybTKybTK0bPFybTKybTKzrPLybTKzrPL0bPFzrPLzrPLybTK0bPFzrPL
ybTKzrPLybTK0bPFzrPLybTKybTK0bPFybTKzrPLybTKybTKybTK0bPF0bPF
zrPL0bPF0bPF0bPF0bPF0bPF0bPF0bPFybTKybTK0bPFzrPLOV41Qmw9Q4xf
PJRvOV41OV41Qmw9UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvRJZkmIZ/mIZ/mIZ/mIZ/o72j2szK2szK
3dfa3dfa3dfa3dfa493Z9OzY//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
ybTK0bPFybTKybTK0bPFybTK0bPFybTKzrPLzrPLzrPLzrPLzrPLybTKzrPL
ybTKybTK0bPFybTKybTKzrPLybTK0bPFzrPL0bPFzrPLzrPL0bPFzrPLzrPL
zrPLzrPLybTK0bPFzrPLzrPLzrPLzrPLybTK0bPF0bPFzrPLzrPLybTKzrPL
zrPLzrPLybTKzrPL0bPFybTK0bPF0bPFybTKzrPL0bPFzrPLzrPLzrPLzrPL
zrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPL0bPFzrPLzrPLzrPLybTKybTK0bPF
ybTKybTKybTKybTKybTKybTKybTK0bPFzrPLzrPLzrPLybTKOV41Q4xfQ4xf
PJRvPJRvPJRvOV41UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvRJZkmIZ/mIZ/mIZ/mIZ/2szK
2szK2szK2szK49TJ//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R
+O3RmIZ/mIZ/3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX69/GmYeA//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPL0bPFzrPLybTKzrPLybTKzrPL0bPF0bPFzrPLzrPLzrPL0bPFzrPLzrPL
zrPLybTKzrPLzrPL0bPFzrPLzrPLzrPLybTKzrPLzrPLybTK0bPF0bPFzrPL
zrPLzrPLzrPLybTKzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPLybTK
ybTKzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL
0bPFzrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLybTK
zrPLzrPLzrPLzrPLzrPLzrPLzrPLybTKzrPLybTKzrPLzrPLOV41Q4xfQ4xf
PJRvPJRvPJRvOV41UJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvmIZ/mIZ/mIZ/mIZ/
3dfa5NrT3dfa5NXI//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3Rm4qCmIZ/
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLybTK0bPFzrPLzrPLzrPLzrPLzrPL
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPF0bPFzrPLybTKybTK0bPF
0bPF0bPFzrPL0bPF0bPF0bPFzrPLzrPLzrPLzrPLybTK0bPFzrPL0bPFzrPL
0bPF0bPF0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPL0bPF0bPF0bPF0bPFybTK
0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPL0bPF0bPF0bPF0bPFzrPLzrPLzrPL
zrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPFzrPL0bPFzrPL0bPF0bPFOV41Q4xf
PJRvPJRvPJRvPJRvUJhVUJhVUJhVUaheUaheUaheUaheUaheUaheUaheOV41
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvVqF9mIZ/mIZ/
mIZ/mIZ/3dfa8OnY//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3RmIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
zrPL0bPF0bPF0bPF0bPF0bPFzrPLzrPLzrPL0bPF0bPFzrPL0bPF0bPFzrPL
zrPL0bPFzrPLzrPL0bPFzrPLzrPLzrPLzrPLybTK0bPFzrPLzrPLzrPLzrPL
ybTKzrPL0bPFzrPLybTKzrPL0bPF0bPF0bPF0bPFzrPLzrPL0bPFzrPL1rHG
zrPLzrPLzrPLzrPLzrPL0bPF0bPF0bPFybTK0bPFzrPLybTKzrPLzrPLzrPL
ybTK0bPFybTK0bPF0bPF0bPFzrPL0bPFzrPLzrPLzrPLzrPL0bPFzrPL0bPF
0bPF0bPF0bPF0bPFzrPL0bPF0bPFybTK0bPFzrPL0bPFybTKzrPLOV41Q4xf
Q4xfPJRvPJRvPJRvPJRvUaheUJhVUaheUaheUaheUaheUaheUaheUaheUahe
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV41//fX
mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
mIZ/3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
0bPFzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPF
0bPFzrPL0bPFzrPLzrPL0bPF0bPF0bPFzrPLzrPLzrPL0bPFzrPLzrPL0bPF
zrPLzrPLzrPL0bPF0bPFzrPLzrPLzrPLzrPL1rHGzrPLzrPLzrPLzrPL0bPF
zrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPL0bPFzrPLzrPL0bPF0bPFzrPL
zrPL0bPFzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPFzrPL0bPFzrPLzrPL
zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLOV41
OV41Q4xfPJRvOV41PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUahe
OV41UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV413dfa
3dfa3dfamIZ/mIZ/+vLX+/PX//fX//fX//fX//fX//fX//fX+O3RmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/0bPFzrPLzrPLzrPLzrPL0bPF0bPF0bPFzrPLzrPL0bPFzrPLzrPLzrPL
0bPFzrPL0bPFzrPLzrPLzrPLzrPL0bPF1rHGzrPLzrPL0bPF0bPFzrPLzrPL
zrPLzrPL0bPFzrPLybTKzrPLzrPLzrPLzrPLybTKzrPL1rHG0bPF0bPFzrPL
0bPF0bPF0bPF1rHGzrPLzrPLzrPL1rHGzrPLybTK1rHG0bPFzrPLzrPL0bPF
0bPFzrPL0bPFzrPLzrPL0bPFzrPLzrPL0bPF0bPFzrPLzrPLzrPLzrPL1rHG
0bPF0bPFzrPL0bPFzrPLzrPL1rHG0bPFzrPL1rHG0bPF1rHGzrPLzrPLOV41
OV41OV41PJRvOV41Qmw9PJRvUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV413dfa
3dfa3dfamIZ/mIZ///fX/fXX/vbX//fX//fX//fX3dfa//fX+O3RmIZ/mIZ/
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/mIZ/
3dfamIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL1rHG0bPF0bPFzrPL1rHGzrPLzrPL0bPFzrPLzrPL1rHGzrPLzrPL
zrPL0bPFzrPL0bPFzrPL0bPFzrPLzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPF
0bPFzrPL0bPFzrPL1rHG0bPF0bPF0bPF1rHG0bPFzrPLzrPLzrPLzrPLzrPL
zrPLzrPLzrPL0bPF0bPF1rHGzrPL1rHG1rHGzrPLzrPL0bPFzrPLzrPLzrPL
0bPFzrPL1rHG1rHG1rHG1rHGzrPLzrPLzrPLzrPL1rHG1rHG0bPFzrPLzrPL
zrPL1rHGzrPL1rHG1rHGzrPLzrPL0bPFzrPLzrPLzrPLzrPL1rHG0bPF1rHG
OV41OV41OV41OV41Qmw9Q4xfUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPZRvOV413dfa
3dfa3dfa3dfamIZ/mIZ/+vPX9e3Y//fX//fX3dfa3dfa+O3RmIZ/mIZ/3dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ///fXmIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/zrPLzrPLzrPLzrPLzrPLzrPLzrPLzrPL0bPFzrPLzrPL0bPF0bPFzrPL
zrPLzrPLzrPL0bPFzrPL1rHG1rHGzrPLzrPL1rHG1rHGzrPL0bPFzrPLzrPL
1rHGzrPLzrPL1rHGzrPLzrPLzrPLzrPLzrPLzrPLzrPL1rHG0bPF1rHG1rHG
0bPF1rHG0bPFzrPLzrPLzrPLzrPLzrPLzrPL0bPF1rHGzrPL1rHG1rHG1rHG
zrPL1rHGzrPLzrPLzrPLzrPL0bPF1rHG1rHG1rHGzrPLzrPL1rHG0bPF0bPF
0bPF0bPF0bPFzrPLzrPL0bPF1rHGzrPLzrPL1rHG0bPF1rHG0bPFzrPLzrPL
0bPFZTwhZTwhOV41OV41Qmw9UJhVUJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfamIZ/5dvT3tja5d/Z//fX3dfa5NrT+O3RmIZ/3dfa3dfa
3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3RmIZ/mIZ/mIZ/3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/1rHG0bPF0bPF1rHG0bPF1rHG0bPF0bPFzrPL1rHG0bPF1rHG1rHG1rHG
1rHG1rHG1rHGzrPL1rHGzrPLzrPL0bPF0bPFzrPLzrPLzrPL1rHG1rHG1rHG
1rHG1rHGzrPL0bPF1rHG1rHG1rHG0bPF1rHG1rHGzrPLzrPLzrPLzrPLzrPL
zrPLzrPL1rHG1rHG0bPF1rHGzrPL0bPFzrPLzrPL1rHGzrPLzrPLzrPL1rHG
zrPL0bPFzrPLzrPL0bPFzrPLzrPLzrPLzrPL0bPF0bPFzrPLzrPL1rHG1rHG
zrPL1rHG0bPFzrPLzrPLzrPL1rHG1rHGzrPLzrPLzrPLzrPL1rHG0bPFzrPL
ZTwhZTwhXDQjXDQjXDQjOV41Qmw9UJhVUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfamIZ/mIZ/3dfamIZ/3dfa5NrT3dfamIZ/3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/
mIZ/1rHGzrPLzrPLzrPLzrPL1rHG1rHG1rHGzrPLzrPLzrPLzrPLzrPLzrPL
0bPFzrPL1rHGzrPLzrPLzrPL1rHGzrPL0bPF1rHG1rHGzrPLzrPL0bPF0bPF
0bPFzrPL1rHGzrPL0bPFzrPLzrPLzrPL0bPFzrPL1rHG1rHG0bPF1rHG1rHG
0bPF1rHGzrPLzrPLzrPLzrPL1rHGzrPL1rHG0bPFzrPL0bPFzrPL0bPFzrPL
0bPFzrPL1rHG1rHGzrPL1rHG0bPF0bPF0bPFzrPLzrPL0bPF1rHGzrPLzrPL
zrPLzrPLzrPL1rHG1rHG1rHGzrPLzrPL0bPF1rHG1rHG0bPFzrPLzrPL1rHG
ZTwhXDQjXDQjXDQjXDQjXDQjOV41Qmw9UJhVUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/3dfamIZ/5NrT5NrTmIZ/mIZ/3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX//fX3dfamIZ/
3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
mIZ/zrPL1rHG0bPF1rHG0bPFzrPLzrPLzrPL1rHG1rHG0bPF0bPF0bPFzrPL
zrPL0bPFzrPL0bPF1rHG1rHGzrPL1rHGzrPLzrPLzrPL0bPFzrPLzrPLzrPL
1rHG0bPF1rHGzrPL0bPF0bPF1rHGzrPL0bPF0bPFzrPL1rHGzrPLzrPLzrPL
0bPF1rHG0bPF1rHG1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHGzrPL1rHG1rHG
1rHG0bPF0bPF1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHGzrPL0bPF0bPF1rHG
0bPF1rHG0bPFzrPLzrPL0bPF1rHG1rHGzrPL0bPF1rHG0bPF1rHG0bPFZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjOV41Qmw9Qmw9UJhVPJRvPJRvPJRvPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/+O3RmIZ/3dfa3dfamIZ/3dfa3dfa3dfa3dfa
3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+O3R+O3R+O3RmIZ/mIZ/mIZ///fX//fX3dfamIZ/3dfa
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL0bPFzrPL1rHG0bPF0bPF1rHG0bPFzrPL1rHGzrPL1rHG1rHG0bPF
1rHG0bPF1rHGzrPL0bPF0bPF0bPF1rHG0bPF0bPF1rHG1rHG0bPF1rHG0bPF
0bPFzrPL0bPF1rHG1rHG1rHG0bPF1rHG1rHGzrPL0bPFzrPL1rHG1rHG1rHG
zrPLzrPL1rHG0bPFzrPL1rHGzrPL1rHGzrPL0bPFzrPL0bPF1rHG0bPFzrPL
zrPL1rHGzrPL0bPFzrPLzrPL1rHGzrPL0bPF0bPFzrPL0bPF1rHG1rHG0bPF
1rHG0bPFzrPL0bPF1rHG0bPF0bPFzrPL1rHGzrPLzrPL1rHG0bPF1rHGZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41UJhVQ4xfRJZkRJZkPJRvUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV413dfa
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa
3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R
+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ///fX//fX//fX//fXmIZ/3dfa3dfa
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/1rHG1rHG0bPFzrPL1rHG1rHG0bPFzrPL1rHGzrPL1rHGzrPL0bPF1rHG
zrPL1rHGzrPL1rHGzrPL1rHGzrPL0bPF1rHG1rHGzrPL0bPF1rHGzrPL1rHG
1rHG1rHG1rHGzrPLzrPL1rHGzrPLzrPL1rHG1rHG1rHG0bPF0bPF1rHG1rHG
1rHG1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
zrPL1rHG1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHGzrPLzrPL1rHGzrPL
zrPL1rHG1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHGzrPLzrPLzrPL1rHGZTwh
ZTwhXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41OV41Q4xfRJZkRJZkRJZkPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3Ro5GI
rZ2RtaaYsJ+TmIZ/mIZ/mIZ///fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa
mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/
mIZ/zrPL1rHG1rHGzrPLzrPL1rHG1rHG0bPF1rHG1rHG1rHG1rHGzrPL1rHG
zrPL1rHG1rHG1rHGzrPL1rHG1rHGzrPLzrPL1rHG1rHGzrPL1rHGzrPL1rHG
1rHGzrPLzrPL1rHG1rHGzrPL1rHG1rHG1rHGzrPL0bPF1rHG1rHG0bPF1rHG
0bPFzrPL1rHG0bPF1rHG1rHG1rHG0bPFzrPL0bPFzrPL0bPFzrPLzrPL1rHG
1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHGzrPL1rHGzrPL1rHG1rHGzrPL1rHG
1rHG1rHGzrPL1rHGzrPLzrPLzrPLzrPL1rHG0bPF1rHG1rHG1rHG1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41OV41QnZCRJZkRJZkPJRv
PJRvUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R6d3E
+O3R69/G+O3R//fX//fX//fX//fX//fX//fX//fXmIZ/3dfa3dfa3dfamIZ/
mIZ/mIZ/+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
1rHG1rHG0bPFzrPL1rHG1rHGzrPL1rHG1rHG0bPFzrPL0bPFzrPL1rHG0bPF
1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG1rHG0bPFzrPL1rHG1rHG1rHGzrPL
1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG0bPF1rHG1rHG0bPF1rHG
1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG
0bPF1rHGzrPL1rHG0bPF0bPF1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG
0bPF1rHGzrPL1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPFzrPL1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41QnZCRJZkRJZk
RJZkPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfamIZ/
mIZ/+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
1rHG1rHG1rHG0bPF0bPF1rHG1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHG
0bPF1rHG0bPF1rHG0bPF1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG0bPF0bPF1rHG1rHGzrPL1rHGzrPL1rHG1rHG1rHG
1rHG1rHG1rHG0bPFzrPL0bPFzrPL1rHGzrPL1rHG1rHG1rHG1rHG1rHGzrPL
1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41OV41QnZCRJZk
RJZkPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFaUaFaUaFa
RJZkRJZkPJRvPJRvPJRvUaheUaheUaheUaheUahePJRvPJRvPJRvOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/
0bPFzrPL1rHG1rHG1rHG1rHGzrPL1rHG0bPF1rHGzrPL1rHG1rHGzrPL0bPF
1rHG1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG0bPF
1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHGzrPL0bPF
1rHGzrPL1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG1rHG1rHG0bPF
0bPF1rHGzrPL1rHG1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG1rHG1rHG0bPF
1rHG1rHG1rHG0bPF1rHG1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHGZTwhZTwh
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjOV41QnZCQnZC
RJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZCQnZC
QnZCOV41OV41OV41OV41OV41OV41OV41OV41OV41OV41OV41QnZCQnZCUaFa
RJZkRJZkRJZkRJZkRJZkRJZkRJZkPJRvUaheUahePJRvPJRvPJRvQnZCQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfamIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG
zrPL1rHG1rHG0bPF1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG0bPF1rHG1rHG
1rHG1rHGzrPL0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL26/G1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG26/G1rHG1rHG1rHG1rHGzrPL0bPF1rHG26/G1rHG1rHG1rHG1rHG
1rHG1rHGzrPL1rHG0bPF0bPF1rHG26/G1rHG1rHG1rHG1rHGOV41ZTwhOV41
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjQnZC
QnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZCQnZCQnZCQnZCQnZCQnZC
QnZCOV41OV41OV41OV41OV41OV41TSobTSobTSobTSobTSobOV41OV41OV41
QnZCQnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkRJZkPJRvPJRvPJRvRZZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/
1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHGzrPL1rHG0bPF1rHG1rHG1rHG1rHG
26/GzrPL1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHGzrPL1rHG1rHG1rHG1rHG
1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG26/G1rHG1rHG1rHG
3rDA1rHG1rHG1rHG1rHG1rHG1rHG0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHGzrPL1rHG1rHG
1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHGOV41OV41OV41QnZCQnZCQnZC
QnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
OV41QnZCRJZkRJZkRJZkRJZkRJZkOV41OV41OV41OV41OV41OV41OV41TSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
OV41OV41OV41OV41QnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkR5dlRJZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
5NrTmIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHGzrPL26/G1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHGOV41OV41QnZCQnZCUaFaUaFaUaFaUaFaUaFa
QnZCQnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
OV41OV41QnZCQnZCQnZCQnZCQnZCOV41OV41OV41OV41OV41XDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobOV41OV41QnZCQnZCRJZkRJZkRJZkRJZkRJZkRJZkRJZkQnZC
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/mIZ/mIZ/3dfa3dfa
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG
3rDA1rHG1rHG1rHGzrPLOV41OV41OV41UaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaQnZCQnZCXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjOV41OV41OV41OV41OV41OV41OV41XDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobOV41OV41OV41OV41OV41PJRvRJZkRZZlQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX3dfamIZ/mIZ/3dfa3dfa3dfamIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/1rHG
1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA
0bPF1rHG1rHG1rHG1rHG1rHG1rHG3rDA0bPF1rHG1rHG1rHG1rHG1rHG1rHG
3rDA26/G1rHG1rHG1rHG1rHG26/G1rHG1rHG3rDA0bPF3rDA1rHG3rDA1rHG
1rHG3rDA1rHG1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG3rDA
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG
1rHG1rHG26/G1rHGTWRFQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaRJZkOV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjOV41OV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobXDQjOV41OV41OV41OV41OV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/1rHG1rHG
1rHG1rHG1rHG3rDA1rHG1rHG3rDA1rHG1rHG26/G3rDA1rHG1rHG1rHG1rHG
1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG26/G26/G1rHG1rHG1rHG
1rHG3rDA3rDA3rDA3rDA0bPF26/G1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG
1rHG1rHG3rDA0bPF1rHG1rHG1rHG3rDA1rHG1rHG3rDA1rHG3rDA0bPF1rHG
26/G1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA3rDA3rDA1rHG3rDA1rHG1rHG
3rDA1rHG1rHGVmlQQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaPJRvOV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobUzAhZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/1rHG3rDA
1rHG3rDAzrPL1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG3rDA1rHG26/G
1rHG1rHG26/G3rDA1rHG1rHG1rHG1rHG1rHG3rDA0bPF3rDA3rDA1rHG1rHG
3rDA1rHG1rHG0bPF1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG1rHG1rHG3rDA
1rHG26/G1rHG26/G26/G3rDA1rHG0bPF3rDA26/G1rHG1rHG1rHG26/G1rHG
1rHG1rHG1rHG3rDA1rHG1rHG3rDA26/G1rHG1rHG1rHG1rHG0bPF3rDA1rHG
0bPFy6SwP3A/QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UahePJRvPJRvPJRvOV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTiwcZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/+O3R
+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/3rDA1rHG
1rHG1rHG3rDA3rDA1rHG1rHG1rHG26/G1rHG1rHG26/G1rHG1rHG1rHG1rHG
26/G3rDA1rHG1rHG26/G26/G1rHG26/G1rHG1rHG1rHG1rHG1rHG26/G26/G
1rHG1rHG26/G1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA1rHG26/G1rHG1rHG
1rHG1rHG3rDA1rHG1rHG1rHG26/G1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA
26/G26/G1rHG1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG26/G1rHG1rHG26/G
1rHGP3JAQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvOV41XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscUC0eZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/26/G26/G
1rHG1rHG1rHG26/G1rHG1rHG1rHG3rDA26/G3rDA1rHG1rHG26/G1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHG1rHG26/G1rHG3rDA1rHG1rHG3rDA3rDA1rHG
1rHG1rHG1rHG26/G26/G3rDA3rDA3rDA26/G3rDA1rHG3rDA3rDA1rHG26/G
3rDA26/G1rHG3rDA26/G3rDA1rHG1rHG3rDA1rHG3rDA26/G1rHG3rDA1rHG
3rDA3rDA1rHG3rDA1rHG26/G26/G26/G26/G26/G3rDA1rHG1rHG3rDA1rHG
RX5HQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvOV41OV41OV41XDQjXDQjXDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiwcTiscZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/26/G1rHG3rDA
26/G26/G26/G1rHG26/G26/G26/G1rHG1rHG1rHG3rDA3rDA3rDA3rDA3rDA
1rHG1rHG1rHG3rDA1rHG3rDA3rDA3rDA26/G1rHG1rHG1rHG1rHG1rHG1rHG
3rDA3rDA3rDA1rHG1rHG1rHG1rHG3rDA1rHG1rHG1rHG1rHG3rDA3rDA1rHG
3rDA1rHG1rHG1rHG1rHG3rDA26/G1rHG3rDA1rHG3rDA3rDA1rHG1rHG1rHG
1rHG1rHG1rHG26/G1rHG3rDA3rDA3rDA3rDA1rHG3rDA26/G1rHGlKCKQnZC
QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvOV41OV41OV41OV41XDQjXDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscTiscZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/3rDA1rHG3rDA
3rDA3rDA3rDA3rDA1rHG3rDA1rHG3rDA1rHG1rHG1rHG1rHG1rHG1rHG3rDA
3rDA3rDA1rHG26/G1rHG1rHG1rHG3rDA1rHG3rDA3rDA1rHG26/G3rDA26/G
1rHG1rHG1rHG3rDA3rDA26/G26/G1rHG3rDA3rDA26/G26/G1rHG1rHG3rDA
1rHG26/G26/G3rDA3rDA1rHG3rDA3rDA1rHG1rHG1rHG1rHG26/G3rDA26/G
26/G3rDA26/G3rDA3rDA1rHG1rHG1rHG1rHG26/G1rHG3rDA3rDAQnZCQnZC
QnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvOV41OV41OV41OV41XDQjXDQjXDQjXDQj
XDQjXDQjXDQjXDQjXDQjXDQjXDQjTSobTSobTSobTSobSzAeSzAeSzAeTSob
TSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSobTSob
TSobTSobTSobTSobTSobTSobTSobTiscTSobZTwh3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/3rDA1rHG1rHG1rHG
1rHG1rHG1rHG1rHG3rDA1rHG3rDA1rHG1rHG26/G1rHG26/G1rHG26/G1rHG
1rHG1rHG1rHG3rDA26/G26/G3rDA1rHG3rDA1rHG26/G3rDA3rDA1rHG3rDA
26/G3rDA1rHG1rHG3rDA3rDA1rHG1rHG1rHG3rDA3rDA3rDA1rHG1rHG26/G
3rDA3rDA1rHG1rHG26/G1rHG26/G26/G3rDA26/G26/G1rHG1rHG3rDA3rDA
1rHG3rDA1rHG1rHG3rDA1rHG26/G3rDA3rDA1rHG1rHG1rHGQnZCQnZCUaFa
UaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41XDQjXDQjXDQj
XDQjOV41OV41OV41OV41OV41OV41OV41OV41QnZCQnZCQnZCQnZCQnZCQnZC
QnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCOV41OV41OV41
OV41OV41OV41OV41OV41OV41OV41OV41OV41/vbX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/26/G26/G1rHG26/G
26/G3rDA1rHG1rHG26/G26/G26/G3rDA3rDA3rDA3rDA3rDA3rDA26/G3rDA
26/G3rDA1rHG3rDA3rDA1rHG26/G26/G26/G3rDA1rHG1rHG26/G1rHG26/G
3rDA26/G3rDA26/G1rHG1rHG3rDA26/G26/G1rHG1rHG1rHG3rDA26/G3rDA
1rHG1rHG3rDA26/G3rDA3rDA26/G3rDA26/G3rDA3rDA3rDA3rDA1rHG26/G
3rDA1rHG26/G26/G1rHG3rDA3rDA26/G1rHG3rDAlKCKQnZCUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41QnZC
QnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCQnZCUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaQnZCQnZC
QnZCQnZCQnZCOV41OV41QnZCQnZCRJZkQnZCQnZCOV413dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/26/G3rDA3rDA3rDA3rDA
3rDA1rHG3rDA3rDA3rDA1rHG3rDA26/G1rHG26/G1rHG26/G1rHG3rDA26/G
3rDA26/G26/G1rHG1rHG26/G3rDA3rDA3rDA1rHG3rDA3rDA3rDA3rDA3rDA
3rDA26/G3rDA3rDA26/G26/G3rDA3rDA3rDA3rDA26/G26/G3rDA1rHG3rDA
26/G26/G3rDA3rDA26/G1rHG26/G3rDA1rHG1rHG26/G26/G26/G1rHG26/G
3rDA3rDA3rDA3rDA3rDA1rHG3rDA26/G26/GlqGHQnZCUaFaUaFaUaFaUaFa
UaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41QnZCQnZC
QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaRJZkRJZkRJZkVZ5tQnZCQnZCOV413dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/mIZ/+O3R//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G1rHGmIZ/mIZ/1rHG
26/G26/G26/G1rHG3rDA26/G3rDA26/G3rDA3rDA26/G3rDA1rHG26/G26/G
26/G3rDA3rDA26/G3rDA26/G1rHG1rHG3rDA26/G26/G1rHG26/G1rHG26/G
26/G3rDA26/G26/G3rDA3rDA26/G26/G1rHG26/G3rDA3rDA26/G26/G26/G
3rDA3rDA1rHG1rHG3rDA3rDA3rDA1rHG3rDA3rDA3rDA26/G3rDA3rDA3rDA
26/G26/G26/G26/G26/G26/G1rHG3rDAaaFpQnZCUaFaUaFaUaFaUaFaUaFa
UaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41QnZCQnZCQnZCUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaFaUaFaUaFaUaFaRJZkPJRvPJRvRJZkRpdlTZppQnZC3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa
3dfamIZ/mIZ/mIZ/mIZ/+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G26/G3rDAmIZ/mIZ/26/G
3rDA3rDA3rDA3rDA26/G3rDA26/G3rDA1rHG1rHG3rDA26/G3rDA3rDA3rDA
3rDA26/G26/G3rDA26/G3rDA26/G3rDA26/G26/G3rDA3rDA26/G26/G3rDA
26/G3rDA3rDA3rDA26/G3rDA3rDA3rDA3rDA26/G26/G3rDA3rDA3rDA26/G
26/G3rDA3rDA3rDA3rDA26/G3rDA26/G26/G26/G3rDA26/G26/G26/G3rDA
3rDA3rDA26/G26/G3rDA3rDA3rDAOV41QnZCUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvOV41OV41QnZCRJZkUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaFaUaFaPJRvPJRvRJZkRJZkRJZkQnZCQnZC3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ/+O3R5NrTmIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/3rDA26/GmIZ/mIZ/mIZ/26/G
26/G1rHG26/G3rDA26/G3rDA3rDA3rDA3rDA26/G3rDA26/G1rHG26/G3rDA
3rDA3rDA26/G3rDA26/G3rDA26/G26/G3rDA1rHG26/G3rDA3rDA26/G26/G
3rDA3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA3rDA26/G26/G26/G3rDA
3rDA26/G26/G26/G26/G3rDA26/G3rDA3rDA3rDA3rDA3rDA3rDA3rDA26/G
26/G26/G3rDA3rDAOV41OV41QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvPJRvOV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkQnZCQnZCOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/3rDA3rDAmIZ/mIZ/mIZ/mIZ/3rDA
3rDA3rDA3rDA3rDA3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA3rDA26/G
3rDA3rDA3rDA3rDA3rDA26/G3rDA3rDA3rDA3rDA3rDA26/G3rDA3rDA3rDA
26/G3rDA3rDA26/G3rDA26/G3rDA26/G26/G26/G3rDA3rDA3rDA3rDA26/G
467B3rDA3rDA3rDA26/G3rDA3rDA467B26/G26/G3rDA3rDA26/G3rDA3rDA
3rDA3rDA3rDAOV41OV41UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvOV41QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZCOV413dfa
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa
3dfa3dfa3dfamIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/3rDA26/GmIZ/uqmcmIZ/q5uPmIZ/26/G
467B26/G26/G26/G3rDA3rDA26/G467B3rDA3rDA467B3rDA26/G3rDA26/G
26/G3rDA26/G26/G467B26/G467B26/G26/G26/G3rDA26/G3rDA3rDA3rDA
3rDA467B26/G3rDA26/G3rDA467B467B467B3rDA26/G467B3rDA26/G3rDA
26/G26/G26/G26/G3rDA467B26/G26/G3rDA3rDA26/G26/G3rDA26/G3rDA
3rDAOV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvOV41OV41QnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRZZkQnZCOV41OV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa
3dfamIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I
7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/26/G3rDAmIZ/5tbBmIZ/qJeMmIZ/3rDA
26/G467B467B3rDA3rDA26/G467B3rDA26/G26/G26/G26/G3rDA26/G3rDA
3rDA26/G3rDA3rDA3rDA3rDA26/G3rDA467B467B3rDA467B26/G26/G26/G
26/G467B467B467B3rDA26/G3rDA3rDA467B3rDA26/G26/G467B3rDA3rDA
467B467B467B3rDA26/G3rDA3rDA467B3rDA3rDA467B26/G467B26/GOV41
QnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUKZdUaheOV41
QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
7t/I7t/I7d7HmIZ/mIZ/mIZ/3rDA4LLAmIZ/uqmc5NW/mIZ/m4mBmIZ/3rDA
3rDA26/G3rDA26/G3rDA26/G26/G3rDA3rDA3rDA467B26/G3rDA3rDA3rDA
467B3rDA3rDA26/G467B3rDA3rDA26/G3rDA26/G3rDA3rDA467B467B3rDA
3rDA3rDA26/G3rDA26/G3rDA26/G26/G26/G467B3rDA467B3rDA26/G467B
3rDA3rDA3rDA26/G3rDA467B26/G3rDA26/G467B3rDA467BOV41QnZCUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUKZdP3E/RJZk
RJZkRJZkUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZkQnZCOV41
3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I
7t/ImIZ/mIZ/mIZ/mIZ/467BmIZ/mIZ/m4mC69zF6tvFmIZ/mIZ/mIZ/3rDA
3rDA3rDA467B3rDA3rDA467B3rDA467B467B26/G3rDA467B467B26/G26/G
3rDA26/G26/G3rDA26/G3rDA26/G3rDA3rDA467B26/G3rDA3rDA3rDA467B
3rDA3rDA3rDA467B467B467B467B3rDA3rDA467B3rDA26/G467B26/G467B
26/G3rDA467B467B26/G467B26/G467B3rDAOV41OV41QnZCUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaFa
UaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkQnZCQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/3rDAmIZ/mIZ/mIZ/yrqq7N3GmIZ/qpuXmIZ/27HG26/G
467B26/G467B467B3rDA467B26/G3rDA467B3rDA3rDA3rDA467B467B26/G
467B467B467B3rDA26/G467B467B26/G26/G467B26/G26/G3rDA26/G3rDA
467B467B26/G3rDA3rDA3rDA3rDA467B26/G26/G467B467B3rDA3rDA26/G
467B467B467B3rDA3rDA3rDAOV41OV41OV41OV41UaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRpdlQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/
mIZ/mIZ/3bTGmIZ/mIZ/mIZ/mYeAyrmp7t/ImIZ/1c3PmYeAmIZ/467B467B
26/G467B3rDA26/G26/G3rDA467B26/G467B26/G467B26/G3rDA467B467B
467B3rDA3rDA467B467B467B3rDA467B467B3rDA467B467B26/G467B467B
467B467B467B26/G467B467B26/G467B3rDA26/G3rDA26/G467B3rDA467B
26/GmaqROV41OV41QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRZZkQnZC
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ///fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/7t/I5dXA7t/I7t/ImIZ/sqShmIZ/47DB467B467B
3rDA467B467B467B26/G3rDA467B3rDA467B26/G467B467B3rDA3rDA3rDA
467B26/G3rDA467B3rDA26/G467B3rDA467B3rDA467B467B3rDA3rDA467B
3rDA467B3rDA467B467B26/G6qy8467B467B467B467BQnZCQnZCQnZCQnZC
QnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvRJZkRZZkXqNy
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ///fX//fX
//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/7t/I7t/I7t/I7t/I7t/I2szKmIZ/z8C9mIZ/mIZ/3rLA467B47DB
467B26/G3rDA467B6qy8467B467B467B3rDA467B3rDA3rDA467B467B26/G
3rDA467B26/G3rDA26/G6qy8467B467B26/G467B3rDA467B467B26/G3rDA
OV41467B467B3rDA467BOV41OV41QnZCQnZCQnZCQnZCUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvRJZkRZZkRZZl
OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fXmIZ/mIZ/
mIZ/mIZ///fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfamIZ/mIZ/
mIZ/+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/I
7t/I7t/I7t/I7t/I7t/I//fXmIZ/mIZ/3dfarJyWmIZ/mIZ/3rDA47DB3rDA
467B467B3rDA3rDA3rDA467B3rDA467B467B467B26/G26/G467B6qy8467B
467B467B26/G6qy83rDA3rDA467B467B26/G467B467B467B467B467B467B
QnZCQnZCQnZCQnZCQnZCQnZCUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvR5dmR5dl
QnZC3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R5NrT3dfa//fX//fX//fX//fX//fX
//fX//fXmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/7t/I7t/I7t/I7t/I7t/I7t/I
7t/I//fX//fX//fX//fXmIZ/3dfa3dfawri3mIZ/mIZ/47DB26/G47DB26/G
467B467B467B467B467B3rDA467B467B467B467B467B6qy8467B3rDA3rDA
467B467B6qy8467B26/G467B26/G467B6qy8467B3rDA467B467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRZZkRJFf
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX+O3R+O3R+O3R5NrT5NrT5NrT5NrT3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/mIZ/5NrT+O3R+O3R
+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX
//fX//fX//fX//fXmIZ/3dfa3dfa3dfanoyGmIZ/3bjI6qy847DB5bPD467B
3rDA467B26/G467B467B467B3rDA3rDA467B467B3rDA26/G467B467B3rDA
467B3rDA3rDA467B26/G6qy8467B467B3rDA467B26/G467B3rDA467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJZkRJZk
Q3ZDOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa5NrTmIZ/mIZ/mIZ/mIZ/mIZ/5NrT5NrT5NrT5NrT
3dfa3dfa3dfa3dfa3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R+O3R5NrT+O3R
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX7t/I7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX
//fXmIZ/mIZ/mIZ/3dfa3dfa3dfamIZ/mIZ/5MfN6rC+467B47DB467B467B
467B467B6qy8467B467B467B467B467B467B467B467B6qy8467B467B467B
467B467B467B467B6qy8467B467B467B467B467B6qy8467B467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaFaUaFaUaFaUaFaUaFaUaFaUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwPJRvRJZkRZZl
Q3ZDOV413dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/5NrT
5NrT5NrT3dfa3dfa3dfamIZ/mIZ/mIZ/+O3R+O3R+O3R+O3R+O3R+O3R//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/477K47DB467B5bbD467B467B
467B467B467B467B467B467B467B467B467B467B467B467B467B467B467B
467B467B467B467B467B467B467B467B467B467B467B6KzB467B467B467B
UaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFaUaFa
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheP5ZxPJRvRJZkRZZk
QnZDOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3RmIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/+O3R+O3R+O3R//fX+O3R+O3R//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX3dfa3dfa3dfa2szKmIZ/mIZ/477K47DB47DB5bTD467B467B467B
467B467B467B467B467B6KzB6KzB467B467B467B467B467B467B6KzB467B
467B467B467B467B467B467B467B6KzB467B467B467B467B467B467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwQZdyQJZxRJZkRJZk
QnZDOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3R+O3R+O3R
+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX7t/I7t/I7t/I7t/I//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa2szK2szKmIZ/5bvG467B5bXD57jD6KzB467B467B467B
467B467B467B467B467B467B467B467B467B467B467B467B467B467B6KzB
6KzB467B467B467B467B467B467B6KzB467B467B467B467B467B467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPpVwQJZxRJZkRZZl
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R+O3R+O3R+O3R
+O3R+O3R+O3R+O3R+O3R+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szKmIZ/mIZ/6q68467B467B467B467B6KzB6KzB467B
467B467B467B467B467B467B6KzB6qy86KzB467B467B6KzB467B6qy8467B
467B6qy8467B467B467B467B467B467B467B467B467B467B467B6qy8467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePpVwPJRvPJRvRJZkRJZk
QnZCOV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX+O3R+O3R
+O3R+O3R+O3R+O3R//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfamIZ/mIZ/mIZ/467B6K7B5bTD6KzB6qy8467B6qy8467B467B
467B467B6KzB467B467B467B467B467B6qy8467B467B467B467B467B467B
467B467B6KzB6qy8467B467B6qy86qy8467B467B467B6qy8467B6qy8467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvQJZxPJRvPpVwRJZkRZZk
QnZCOV41OV413dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa
2szK2szKmIZ/mIZ/mIZ/mIZ/467B6qy8467B6qy8467B6qy8467B6qy86qy8
6KzB6KzB467B6KzB467B6KzB467B467B467B467B467B6qy8467B467B6qy8
467B6qy86qy8467B6KzB6KzB467B467B6qy86KzB467B467B467B467B6qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvRJhzPJRvPZRvRJZkRJZk
RZZkOV41OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK
3dfamIZ/mIZ/mIZ/mIZ/6qy8467B6qy8467B467B467B467B467B6qy86qy8
6qy8467B6qy86KzB6qy86KzB6KzB467B6qy86qy8467B6KzB6qy8467B6qy8
467B467B467B6qy86qy8467B6KzB467B6qy86qy8467B6KzB467B467B6KzB
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPZRvPJRvPZRvRJZk
RZZlOV41OV413dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szKmIZ/
mIZ/mIZ/mIZ/6q686qy8467B6KzB467B6qy86qy86qy86qy8467B467B467B
467B6qy8467B6qy8467B6qy8467B6qy8467B467B6KzB6qy8467B6qy8467B
6KzB6qy86KzB467B467B6qy86qy8467B6qy8467B6qy86qy86qy8467B6qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPZRvPJRvPZRvRJZk
RZZkOV413dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/
mIZ/6q++47DD47DB6qy86qy86qy8467B467B467B467B6qy8467B467B6qy8
467B6qy8467B6qy86qy86qy8467B6qy86qy86qy8467B6qy8467B467B6qy8
467B6qy86qy8467B467B6qy86qy8467B6qy8467B467B467B6qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPZRvRJZk
RJZkOV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK287K5tfImIZ/mIZ/mIZ/48bO
47DB467B6q686q6+467B6qy8467B6qy8467B6qy86qy86qy86qy86qy8467B
6qy8467B6qy8467B467B6qy86qy8467B6qy86qy86qy8467B6qy86qy8467B
6qy8467B467B6qy86qy8467B467B6qy8467B6qy86qy86qy86qy8467B467B
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkOV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa2szK2szK2szK2szK4NLJmIZ/mIZ/mIZ/4cLN6LLA6q6+
6q686qy86qy86qy8467B6qy8467B6qy86qy8467B467B467B6KzB6qy8467B
6qy8467B6qy86qy8467B6qy86qy8467B467B6qy86qy8467B467B6qy8467B
6qy86qy86qy8467B6qy86qy8467B6qy8467B6qy86qy8467B6qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRZZk
RJZkOV41OV413dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
3dfa3dfa2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/6LC/6qy86qy847DB6LXC
467B467B467B467B6qy86qy86qy86qy8467B6qy86qy86qy86qy86qy86qy8
6KzB6qy86KzB6qy86qy86qy86qy86qy86qy8467B6qy86qy86qy86qy86qy8
467B6qy8467B6qy86qy86qy86qy86qy86qy8467B467B6qy86qy86qy86KzB
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkeYVoeYVo2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK
2szK2szK2szK2szK2szK2szK2szK2szK2szK3dfa2szK2szK2szK2szK2szK
2szK287KmIZ/mIZ/mIZ/mIZ/6rG+6K7B6rjF6qy8467B6qy86qy8467B6qy8
6qy86qy86qy86qy8467B6qy86KzB6qy86qy86qy86qy86qy86KzB6qy86qy8
6qy86qy86KzB6qy86KzB467B6qy86qy86qy86qy86qy86KzB6KzB6qy86qy8
6qy86qy86qy86qy86KzB6qy86KzB6qy86qy86qy86qy86KzB467B6qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRZZk
RZZlOV41eYVo2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/48TN6q6+6q686q686qy86KzB6q686qy86qy86qy86qy8
6qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86KzB6KzB6qy86qy86qy8
6qy86qy86qy86KzB6qy86qy86qy86qy86qy86KzB6KzB6qy86qy86qy86qy8
6KzB6qy8467B6qy86qy86KzB6qy86qy86qy86qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
SplnOV41OV41mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX7t/ImIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/6LbD6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86KzB6qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86KzB6KzB6qy86qy86qy86qy86qy86KzB6qy86qy8
6qy88Kq96qy86qy86qy86qy86qy86qy86qy86KzB6qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV41OV41mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX//fX
//fX3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX7t/I7t/ImIZ/mIZ/mIZ/7LK+6rC+6qy86LTC
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy8
6qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZk
RJZkOV41OV41mIZ/mIZ/mIZ/2szK3dfa3dfa3dfa3dfa3dfa3dfa//fX7t/I
//fX3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/mIZ/8Kq9
8Kq96qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy88Kq96qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy8
6qy86qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy8
6qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq96qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV41OV41mIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa//fX7t/I
7t/I2szK3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/ImIZ/mIZ/mIZ/
mIZ/mIZ/6q+86qy86q686qy87LjA7LK+6qy86qy86qy86qy86qy86qy86qy8
6qy88Kq96qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy86qy8
8Kq96qy86qy88Kq96qy86qy86qy86qy86qy86qy86qy86qy86qy86qy88Kq9
6qy86qy86qy88Kq98Kq96qy88Kq96qy86qy86qy86qy88Kq96qy86qy86qy8
6qy86qy86qy86qy86qy88Kq96qy88Kq98Kq96qy86qy86qy86qy88Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
RJZkOV416qy88Kq98rO/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa//fX7t/I
7t/I7t/I2szKmIZ/2szK3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX
//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/ImIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/6qy88Kq98Kq98Kq98Kq96qy86qy88Kq96qy88Kq96qy8
6qy88Kq98Kq96qy88Kq96qy88Kq98Kq96qy86qy86qy86qy88Kq96qy86qy8
6qy88Kq96qy88Kq96qy88Kq98Kq96qy88qu38qu36qy86qy88Kq96qy88Kq9
8Kq96qy86qy86qy88Kq96qy86qy88Kq98qu36qy86qy88Kq96qy86qy86qy8
8Kq98Kq98Kq98Kq96qy88Kq96qy86qy88Kq96qy88Kq98Kq96qy86qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV41OV418Kq97rrA6qy8mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa//fX
7t/I7t/ImIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I7t/I7t/I
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/6qy86qy86qy88Kq98Kq96qy88Kq96qy88Kq9
6qy86qy86qy86qy86qy88qu36qy88qu38Kq98Kq98Kq98Kq96qy88qu38qu3
8Kq96qy88qu36qy88Kq96qy86qy88Kq96qy86qy88Kq98Kq96qy88Kq96qy8
6qy88Kq96qy86qy88qu36qy86qy88qu36qy88qu36qy88qu38Kq98Kq98qu3
6qy86qy86qy86qy86qy88qu38Kq96qy88qu36qy86qy86qy86qy86qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV41OV418qu36qy88Kq98Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa
//fX7t/ImIZ/mIZ/mIZ/mIZ/2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa//fX//fX//fX//fX//fX//fX//fX//fX7t/I7t/I
7t/I2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
8Kq96qy88Kq96qy86qy86qy86qy86qy88qu36qy86qy86qy86qy86qy86qy8
8qu36qy86qy88qu38Kq96qy86qy86qy86qy86qy88qu36qy86qy88qu38qu3
8qu36qy86qy86qy88qu38qu36qy86qy86qy88qu36qy88qu36qy86qy88Kq9
8Kq96qy88qu36qy86qy86qy88qu36qy88Kq96qy88Kq96qy88qu36qy86qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZk
OV418qu36qy88Kq96qy86qy88Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa
3dfa7t/I7t/ImIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
2szK2szK2szK2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/8Kq98qu38qu36qy88qu36qy88qu36qy88Kq96qy88qu38Kq98Kq96qy8
6qy86qy88qu36qy88qu38qu38qu38Kq98Kq98qu36qy86qy88Kq96qy86qy8
6qy86qy88qu38Kq96qy86qy88Kq96qy86qy86qy86qy86qy88qu36qy86qy8
8qu38qu36qy88Kq98Kq96qy86qy86qy88qu38Kq96qy88Kq96qy88Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkQnZC
OV418Kq98qu38Kq98qu36qy86qy88Kq9mIZ/mIZ/2szK2szK2szK3dfa3dfa
3dfa3dfa7t/I7t/ImIZ/6qy8mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK3dfa
3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa2szK3dfa3dfa2szK2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/8Kq98Kq9
8qu36qy86qy88Kq96qy88Kq96qy88Kq96qy88qu36qy86qy86qy88Kq98Kq9
8Kq96qy88Kq96qy86qy86qy86qy88qu36qy88Kq98Kq96qy86qy88Kq98Kq9
8qu36qy86qy88Kq98Kq96qy88qu38qu38Kq98Kq98Kq96qy88Kq98qu36qy8
6qy88Kq96qy88Kq98qu38Kq98qu36qy88qu38qu38qu36qy88qu38qu36qy8
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkQnZC
OV416qy86qy88qu38Kq98Kq98Kq98qu38Kq9mIZ/mIZ/3dfa2szK2szK3dfa
3dfa2szK2szK7t/ImIZ/mIZ/8Kq96qy8mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK
2szK2szK2szK2szK3dfa2szK2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa3dfa3dfa2szK2szK2szK2szKmIZ/mIZ/37i28q238qu38qu3
6qy88Kq98Kq98qu38Kq96qy88Kq98Kq98qu38Kq98Kq98Kq98qu38qu36qy8
8qu38Kq96qy88Kq98Kq98Kq98qu36qy86qy88Kq98qu38Kq98Kq98qu38Kq9
8Kq98Kq98Kq98qu38Kq98qu36qy86qy88Kq98qu36qy88Kq98qu36qy88Kq9
6qy88Kq98qu38qu36qy86qy86qy88Kq96qy86qy86qy88qu36qy86qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV416qy86qy88Kq98qu38qu36qy88qu38qu38qu3mIZ/mIZ/mIZ/2szK2szK
2szK3dfa2szK2szK7t/ImIZ/mIZ/6qy86qy8mIZ/mIZ/mIZ/mIZ/mIZ/3dfa
3dfa3dfa3dfa2szK2szK2szK2szK3dfa3dfa3dfa3dfa3dfa3dfa3dfa3dfa
3dfa3dfa3dfa2szK2szK2szK283JmIZ/mIZ/4Le06q687LS+6qy86qy88qu3
8qu38qu36qy88qu38qu38qu38qu38Kq96qy88qu38qu38Kq98Kq98qu38Kq9
8qu38qu38qu38qu38qu36qy88Kq98Kq98qu38Kq98qu38qu36qy88qu36qy8
8qu38qu36qy88qu36qy88Kq98Kq98qu36qy88qu36qy86qy88Kq98qu38Kq9
8Kq98Kq96qy88Kq98qu38Kq98qu38Kq98Kq98qu38Kq98Kq98Kq98qu38Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV418qu38qu38qu36qy88Kq98Kq98Kq98Kq96qy8mIZ/mIZ/mIZ/mIZ/2szK
2szK2szK3dfa2szK2szK7t/ImIZ/8qu38Kq98Kq98Ky9mIZ/mIZ/mIZ/mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK2szK2szK2szK2szK2szK2szK
2szK2szK2szK2szK2szKmIZ/mIZ/mIZ/8q238LC/8qu38Ky98Kq98Kq98Kq9
6qy86qy88Kq98Kq98Kq96qy86qy86qy88qu36qy86qy88Kq96qy88Kq96qy8
8Kq98Kq96qy86qy86qy88Kq98Kq98qu36qy86qy88Kq96qy88Kq96qy88Kq9
6qy86qy88Kq98Kq98Kq98qu38qu36qy88Kq98Kq98qu38Kq98qu36qy88Kq9
8qu38qu38Kq98qu38Kq98qu36qy88qu38qu38Kq96qy88qu38qu38Kq98qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkOV41
OV418Kq98Kq98qu36qy88qu36qy88qu38qu38Kq98Kq9mIZ/mIZ/mIZ/mIZ/
2szK2szK2szK2szK2szK2szKmIZ/mIZ/8Kq98qu38qu37LS+8rG/8qu3mIZ/
mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szK
mIZ/mIZ/mIZ/mIZ/mIZ/7MDF8q237LK+8qu38Ky98qu38qu38qu38Kq98Kq9
8Kq98qu38Kq98Kq98Kq98Kq98qu38Kq98Kq98qu38qu38qu38Kq98qu36qy8
8qu38Kq98qu38Kq98qu38qu38Kq98qu38qu38qu38Kq98Kq98Kq98qu38Kq9
8qu38qu38Kq98qu38Kq96qy88qu38qu38qu38Kq98qu38Kq98Kq98qu36qy8
6qy88qu38Kq96qy88Kq98Kq98Kq98Kq98qu38qu36qy86qy88qu36qy88Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRv
OV418Kq98Kq98Kq98qu38Kq98qu36qy88Kq98qu38qu38Kq98Kq9mIZ/mIZ/
mIZ/2szK2szK2szK3dfa2szK2szKmIZ/mIZ/6q686qy88qu38q+58Kq98qu3
8Kq98Kq996m48Kq98Kq98Kq9mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/+NHG8q+58q236q688Kq98Kq98qu36qy88Kq98Kq98Kq98Kq98qu38qu3
8qu38Kq98qu38qu38qu38qu38Kq98Kq98qu38Kq96qy88Kq98qu38Kq996m4
8Kq98qu38Kq98qu38Kq96qy88qu38Kq98Kq96qy88qu38qu38qu38Kq98qu3
8Kq98Kq98qu38Kq98qu38qu38Kq98Kq96qy88qu38Kq98qu38qu36qy88qu3
8Kq98Kq98Kq98qu38qu38qu38qu38Kq96qy88Kq98qu38qu38Kq98qu38qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkRJZkOV41
OV418qu38Kq98Kq98qu38Kq98Kq98Kq98Kq98Kq98Kq98qu38Kq98qu3mIZ/
mIZ/mIZ/mIZ/2szK2szK2szK2szK2szKmIZ/mIZ/8K6/8Kq98qu38Kq98qu3
8qu38Kq98qu38Kq98Kq98Kq98Kq98Kq98qu38Kq98qu38Kq98qu38Kq98qu3
8Kq98Kq98Kq98qu38qu38qu38Kq996m48qu38Kq98qu38qu38Kq96qy88Kq9
8Kq98Kq96qy88Kq98Kq98qu38qu38Kq98qu38qu38qu38Kq98qu38Kq98qu3
8Kq98Kq98Kq98qu38qu38Kq98Kq98qu38qu38Kq98Kq98qu38qu38Kq98Kq9
8qu38Kq98qu38Kq98Kq98Kq98Kq98qu38Kq98qu38Kq98Kq996m48Kq98qu3
8qu38qu38Kq98Kq98Kq98Kq98qu396m48qu38Kq98Kq98Kq98Kq98Kq98Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
OV418Kq996m48qu38Kq98qu396m48qu38qu38qu38qu38Kq98Kq98Kq98qu3
8qu3mIZ/mIZ/mIZ/2szK2szK2szK2szK2szKmIZ/mIZ/9L6+8Kq98qu38qu3
8Kq98qu38Kq98qu38qu38qu38qu38qu38Kq98qu38Kq98qu38Kq98qu38Kq9
8qu38qu38qu38Kq98Kq98Kq98qu38Kq98Kq98qu38Kq98Kq98qu396m496m4
8qu38qu396m48qu396m48Kq996m48qu38Kq996m48Kq98qu38Kq98qu38Kq9
8Kq98qu38qu38Kq98Kq98qu396m48Kq98Kq98qu38qu38Kq98Kq98qu396m4
8Kq98qu38Kq98qu38qu396m48qu38Kq98Kq98Kq98qu38qu38Kq98qu38Kq9
8Kq98Kq98qu38qu38qu38qu38Kq98Kq996m48qu38Kq98qu38qu38qu38qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38Kq98Kq996m48Kq98Kq98Kq98Kq98Kq98Kq98qu396m48qu38Kq98Kq9
8Kq98Kq9mIZ/mIZ/mIZ/mIZ/mIZ/2szK2szK2szKmIZ/mIZ/9cbG8Kq98qu3
8Kq98qu38qu38Kq98Kq98Kq98Kq98qu38Kq98qu396m496m48Kq98qu38Kq9
8Kq98Kq98qu38qu38qu396m48qu38qu38Kq98qu38qu38qu38Kq98Kq98Kq9
8Kq98Kq98Kq98Kq98qu38Kq98Kq98qu38Kq996m48Kq996m48Kq98qu38qu3
8Kq996m48qu396m48Kq98qu396m48qu38Kq98Kq98qu38qu38Kq98Kq98qu3
8qu38qu38qu396m48Kq98Kq98qu38qu38qu38Kq98Kq98qu38Kq98qu38Kq9
8qu38qu38Kq98Kq98Kq98qu38Kq98Kq996m496m48qu38Kq98Kq98Kq98qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8Kq98qu396m48Kq996m48qu396m48qu38qu396m48Kq98qu38Kq98qu396m4
96m496m48qu396m4mIZ/mIZ/mIZ/mIZ/mIZ/2szKmIZ/mIZ/mIZ/mIZ/8Kq9
8qu396m48Kq996m496m496m48qu38qu396m48qu38Kq98Kq98qu38Kq996m4
8qu38qu396m496m48Kq98Kq996m496m48qu396m48Kq98Kq98qu38qu396m4
8qu38qu38qu38qu38Kq98qu38qu38Kq98qu38Kq98qu38Kq98qu38Kq996m4
96m48Kq98Kq98Kq98qu38Kq98Kq98Kq996m48qu396m48Kq996m48qu38Kq9
8Kq98Kq98Kq98Kq98qu396m496m496m48qu38qu38qu38Kq996m496m48qu3
8Kq996m496m496m48qu38qu38qu38qu38Kq98Kq98Kq996m48qu396m48Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38qu38qu38Kq98qu38qu38qu38qu38qu396m48Kq996m496m48Kq98qu3
8qu38Kq996m48qu396m48q65mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
8Kq98qu38qu38Kq98Kq996m496m48Kq98Kq98qu396m496m48qu38Kq996m4
96m48Kq98Kq98qu38qu38Kq98Kq996m48Kq996m496m48Kq996m48qu396m4
96m496m496m496m48Kq98qu396m48Kq98qu396m48qu396m496m48Kq98Kq9
8qu396m48qu396m48qu38qu38qu38qu396m48Kq98qu38Kq98qu396m496m4
96m48qu396m48qu38Kq98Kq98Kq98Kq98Kq996m48qu38Kq98Kq996m48qu3
8Kq98qu38qu38qu396m48Kq98Kq98qu38qu38qu38qu396m496m496m48qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8Kq98Kq996m496m48Kq98qu396m48Kq98Kq98Kq996m48qu38Kq996m48Kq9
8qu396m48Kq98Kq98qu38qu38Kq99626mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/mIZ/
mIZ/96m48Kq996m48qu38Kq98Kq98qu396m496m48qu38Kq996m496m48Kq9
8Kq996m48qu38Kq996m48qu396m48Kq996m48qu38qu396m48Kq996m48Kq9
8Kq98Kq98Kq98qu38qu396m48Kq996m496m48Kq996m48Kq98Kq996m48qu3
96m48qu396m48Kq996m48Kq996m496m48Kq98qu396m48qu38Kq98qu38Kq9
8qu38qu38Kq996m496m48qu38qu396m496m48Kq996m496m496m48Kq996m4
8qu38Kq996m496m48Kq996m496m496m496m48Kq98Kq98Kq98Kq996m48Kq9
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
96m48Kq98qu396m48Kq98Kq996m496m496m496m48Kq98qu38qu396m48Kq9
96m496m496m496m48Kq996m48K6996u496m496m496m496m48Kq9mIZ/mIZ/
mIZ/mIZ/8qu396m496m496m496m48qu38Kq996m496m48Kq98qu396m48qu3
8qu396m496m48Kq996m48Kq996m48qu396m48Kq98qu396m48Kq98qu396m4
96m496m496m496m48Kq996m48qu38Kq996m48Kq996m496m48qu396m48Kq9
96m48Kq996m48Kq996m48Kq98Kq996m496m48qu396m496m48Kq996m496m4
96m496m48Kq98qu396m496m48qu38qu396m48Kq98qu38qu396m48Kq996m4
96m48Kq98Kq98qu38qu38Kq98Kq996m496m496m48qu396m48Kq996m496m4
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu396m496m48qu396m496m48qu396m48qu38Kq996m496m496m48qu396m4
8qu38qu396m48Kq996m496m496m496m48qu38Kq98qu38qu396m48qu38Kq9
96m496m48Kq98qu38qu38qu38Kq996m496m48Kq98Kq996m496m48qu396m4
96m48Kq98qu396m48Kq996m48qu396m48Kq996m48Kq98qu396m496m48qu3
8qu38qu38Kq98Kq996m48qu396m496m48qu396m496m48qu396m48Kq996m4
8Kq996m48qu396m48qu396m496m496m48Kq996m48qu38qu396m48qu38Kq9
8Kq98qu396m496m48qu38Kq996m496m48qu396m496m496m48qu396m48Kq9
8Kq996m496m496m496m496m496m48Kq996m48qu396m48qu396m496m48qu3
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvOV41
8qu38Kq996m496m48qu396m48qu396m496m496m48qu38Kq996m496m48Kq9
96m48Kq996m496m48qu396m48Kq996m496m48Kq98Kq996m496m496m48qu3
8qu396m48Kq996m496m496m48Kq98qu396m496m496m48Kq996m48Kq98Kq9
96m496m48qu396m48qu396m48Kq996m48qu396m496m48qu396m496m496m4
96m496m496m48qu396m496m48qu396m48qu38qu396m48Kq996m48qu396m4
96m496m496m496m48qu38qu38Kq996m496m496m496m48Kq996m496m496m4
96m48Kq98Kq996m496m496m496m496m48Kq996m48Kq996m496m496m496m4
8qu38qu38qu38Kq98qu38qu396m48Kq996m496m496m48qu38qu38Kq996m4
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUaheUahe
UaheUaheUaheUaheUahePJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRv
PJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvPJRvRJZkRJZkPJRvPJRv
96m496m48Kq98qu396m48Kq996m48Kq98qu396m48Kq996m48Kq98qu396m4
96m496m496m48qu396m496m496m48qu396m496m496m48qu38Kq996m496m4
96m496m496m496m496m496m496m496m496m496m48qu396m496m496m496m4
96m496m496m48qu396m48qu396m496m496m496m496m496m48Kq996m48Kq9
8Kq996m496m496m48Kq98Kq996m496m496m496m48qu396m496m496m48Kq9
96m48qu38Kq996m496m496m496m496m48Kq98Kq996m496m496m48qu396m4
96m496m496m496m48Kq996m48Kq996m496m48qu396m48Kq996m48qu396m4
96m496m496m496m496m496m496m496m496m48Kq98Kq996m48Kq996m496m4
====

Deleted runt/kmid/launcher/cc/squirreljme/runtime/launcher/ui/splash.xpm.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\kmid\launcher\cc\squirreljme\runtime\launcher\ui\splash_xpm[] = {
"240 320 1631 2",
"  	c None",
". 	c #5BCFF8",
"+ 	c #65CCF7",
"@ 	c #6BCBF5",
"# 	c #A8BBD3",
"$ 	c #BCB5BF",
"% 	c #AABCCF",
"& 	c #70CAF3",
"* 	c #80C8EA",
"= 	c #EE9A6E",
"- 	c #FF8C00",
"; 	c #EF996B",
"> 	c #8DC5E3",
", 	c #64C9F4",
"' 	c #62C6F0",
") 	c #58C9F1",
"! 	c #59CBF4",
"~ 	c #5CCFF8",
"{ 	c #EA9B79",
"] 	c #F4955A",
"^ 	c #6ACDF3",
"/ 	c #63C9F3",
"( 	c #50B9DE",
"_ 	c #3B7D98",
": 	c #1B4150",
"< 	c #000000",
"[ 	c #438CAA",
"} 	c #92C2E2",
"| 	c #AEB9CE",
"1 	c #3B8BA7",
"2 	c #4EA0C3",
"3 	c #4197B6",
"4 	c #4CB0D4",
"5 	c #4C9DBF",
"6 	c #54C1E7",
"7 	c #030F15",
"8 	c #3A89A5",
"9 	c #45A1C1",
"0 	c #0F2833",
"a 	c #143947",
"b 	c #173946",
"c 	c #53AACE",
"d 	c #4896B6",
"e 	c #02080C",
"f 	c #9BC2DB",
"g 	c #BEB3BE",
"h 	c #4189A6",
"i 	c #4895B5",
"j 	c #55AED3",
"k 	c #316981",
"l 	c #205466",
"m 	c #64CBF6",
"n 	c #438BA9",
"o 	c #316A82",
"p 	c #4997B7",
"q 	c #49AACC",
"r 	c #3C8EAB",
"s 	c #77C9F0",
"t 	c #FE8D15",
"u 	c #A4BED4",
"v 	c #46A3C3",
"w 	c #3886A2",
"x 	c #397892",
"y 	c #4CAED1",
"z 	c #1E4657",
"A 	c #48A8C9",
"B 	c #4087A4",
"C 	c #4D9EC0",
"D 	c #4199B8",
"E 	c #64CBF5",
"F 	c #204A5B",
"G 	c #D2ABA5",
"H 	c #EC9A73",
"I 	c #6ACBF5",
"J 	c #357F99",
"K 	c #3F84A1",
"L 	c #58B3D9",
"M 	c #326B83",
"N 	c #439DBD",
"O 	c #448EAD",
"P 	c #4BAED1",
"Q 	c #65CBF6",
"R 	c #72CAF2",
"S 	c #D6A8A0",
"T 	c #E69F83",
"U 	c #7BC9EC",
"V 	c #286479",
"W 	c #51BBE0",
"X 	c #255265",
"Y 	c #55C2E9",
"Z 	c #54ABD0",
"` 	c #45A0C0",
" .	c #4FB6DB",
"..	c #4086A3",
"+.	c #59B6DD",
"@.	c #5FC1E9",
"#.	c #76CAEE",
"$.	c #98C2DC",
"%.	c #51A6C9",
"&.	c #3E819D",
"*.	c #4BADCF",
"=.	c #3A7B96",
"-.	c #4691B1",
";.	c #5DBCE4",
">.	c #54ACD1",
",.	c #52A8CC",
"'.	c #22576A",
").	c #5BBAE1",
"!.	c #64CAF4",
"~.	c #60C2EB",
"{.	c #30687F",
"].	c #59B5DC",
"^.	c #4590AF",
"/.	c #52BBE1",
"(.	c #63C8F3",
"_.	c #58B4DA",
":.	c #59CBF3",
"<.	c #336E87",
"[.	c #2C6C82",
"}.	c #194352",
"|.	c #5FC1EA",
"1.	c #143340",
"2.	c #56C4EB",
"3.	c #53ABCF",
"4.	c #63C9F4",
"5.	c #4096B5",
"6.	c #5BB9E0",
"7.	c #2D6177",
"8.	c #3E91AF",
"9.	c #36738C",
"0.	c #0A2029",
"a.	c #327891",
"b.	c #4692B1",
"c.	c #1C4252",
"d.	c #3B8CA8",
"e.	c #5AB7DD",
"f.	c #57B2D7",
"g.	c #1F5163",
"h.	c #245063",
"i.	c #2B5E73",
"j.	c #60C3EC",
"k.	c #5FC0E9",
"l.	c #449FBF",
"m.	c #28586C",
"n.	c #23596C",
"o.	c #50A5C8",
"p.	c #3D7F9B",
"q.	c #2A677D",
"r.	c #27576B",
"s.	c #63C8F2",
"t.	c #4FA2C4",
"u.	c #29677C",
"v.	c #275669",
"w.	c #4998B8",
"x.	c #62C5EF",
"y.	c #4C9CBE",
"z.	c #387690",
"A.	c #30677E",
"B.	c #61C4EE",
"C.	c #3C7F9A",
"D.	c #4AAACD",
"E.	c #4793B3",
"F.	c #60C2EC",
"G.	c #4085A2",
"H.	c #081C25",
"I.	c #112D38",
"J.	c #63C7F1",
"K.	c #3E93B1",
"L.	c #55ADD2",
"M.	c #153542",
"N.	c #35728B",
"O.	c #5CBBE3",
"P.	c #1F5062",
"Q.	c #3E829F",
"R.	c #51BADF",
"S.	c #1A3D4C",
"T.	c #3884A0",
"U.	c #47A6C7",
"V.	c #56C5ED",
"W.	c #224D5E",
"X.	c #3E92B0",
"Y.	c #428AA8",
"Z.	c #0C232C",
"`.	c #4EA1C3",
" +	c #102B36",
".+	c #5EBEE6",
"++	c #4691B0",
"@+	c #62C7F0",
"#+	c #1B3F4E",
"$+	c #53BFE5",
"%+	c #295B6F",
"&+	c #4A99BA",
"*+	c #5CBCE4",
"=+	c #2B5F74",
"-+	c #071920",
";+	c #3988A3",
">+	c #347088",
",+	c #58C8F0",
"'+	c #05141B",
")+	c #58B2D8",
"!+	c #5BB9E1",
"~+	c #4C9DBE",
"{+	c #336D85",
"]+	c #20495A",
"^+	c #4DB1D5",
"/+	c #37758F",
"(+	c #4EA1C4",
"_+	c #4188A6",
":+	c #6BCBF0",
"<+	c #265568",
"[+	c #3E829E",
"}+	c #1F4858",
"|+	c #0D2B36",
"1+	c #50A4C7",
"2+	c #43849D",
"3+	c #245A6E",
"4+	c #5DBDE5",
"5+	c #295A6E",
"6+	c #62BCDE",
"7+	c #357089",
"8+	c #2D5C6E",
"9+	c #214B5D",
"0+	c #4A9ABB",
"a+	c #55AFD4",
"b+	c #193C4A",
"c+	c #458EAD",
"d+	c #61C4ED",
"e+	c #1D4353",
"f+	c #336D86",
"g+	c #386F84",
"h+	c #4C94B0",
"i+	c #4289A7",
"j+	c #5BAFCF",
"k+	c #36738D",
"l+	c #45869F",
"m+	c #529EBB",
"n+	c #63BDDF",
"o+	c #040F14",
"p+	c #08181F",
"q+	c #091C23",
"r+	c #3A7389",
"s+	c #3B7C97",
"t+	c #3F7B93",
"u+	c #326579",
"v+	c #65C0E4",
"w+	c #63BDE0",
"x+	c #397187",
"y+	c #122F3B",
"z+	c #55A4C2",
"A+	c #64CAF5",
"B+	c #59ABCB",
"C+	c #5EBFE7",
"D+	c #234A59",
"E+	c #61C5EF",
"F+	c #57B1D6",
"G+	c #245164",
"H+	c #183442",
"I+	c #6FC9F5",
"J+	c #5AACCC",
"K+	c #173540",
"L+	c #69BEE8",
"M+	c #4A90AB",
"N+	c #142F39",
"O+	c #6EC7F3",
"P+	c #62B3DA",
"Q+	c #57B1D7",
"R+	c #67C3E7",
"S+	c #519CB9",
"T+	c #2A5D72",
"U+	c #4F9AB6",
"V+	c #5DBDE6",
"W+	c #4587A1",
"X+	c #60B8D9",
"Y+	c #112A34",
"Z+	c #6AC9ED",
"`+	c #5AADCD",
" @	c #234F61",
".@	c #54A2C0",
"+@	c #4997B8",
"@@	c #74C9EF",
"#@	c #6AC1EB",
"$@	c #539FBD",
"%@	c #3C7E9A",
"&@	c #53A9CD",
"*@	c #6DC5F1",
"=@	c #69C8ED",
"-@	c #397893",
";@	c #2E5D70",
">@	c #2A4F5F",
",@	c #265060",
"'@	c #1E4555",
")@	c #4689A3",
"!@	c #5BB8DF",
"~@	c #162E39",
"{@	c #6AC9EE",
"]@	c #66B3D5",
"^@	c #326076",
"/@	c #54A1BF",
"(@	c #5EABD1",
"_@	c #316376",
":@	c #4A98B9",
"<@	c #59ABCA",
"[@	c #6BC3EE",
"}@	c #2A5C71",
"|@	c #6BC1EC",
"1@	c #407E96",
"2@	c #5DAAD0",
"3@	c #66C3E6",
"4@	c #417B97",
"5@	c #49829C",
"6@	c #294E5E",
"7@	c #5CA9CE",
"8@	c #599CBA",
"9@	c #5495B2",
"0@	c #458FAE",
"a@	c #69C8EC",
"b@	c #60B7D9",
"c@	c #549BBE",
"d@	c #6EBEE3",
"e@	c #3A6E87",
"f@	c #58A9C9",
"g@	c #427C98",
"h@	c #52A7CB",
"i@	c #418199",
"j@	c #4785A3",
"k@	c #4B91AC",
"l@	c #6CBBDF",
"m@	c #6FC1E6",
"n@	c #56AFD5",
"o@	c #163744",
"p@	c #3D6F85",
"q@	c #518EAA",
"r@	c #5EB4D6",
"s@	c #4F99B5",
"t@	c #4688A1",
"u@	c #5FB5D7",
"v@	c #5A9EBC",
"w@	c #6EC8F4",
"x@	c #285364",
"y@	c #2E647B",
"z@	c #5AB8DF",
"A@	c #4A91AC",
"B@	c #4E89A4",
"C@	c #6AC8ED",
"D@	c #3A7A95",
"E@	c #183642",
"F@	c #16333E",
"G@	c #64AFD0",
"H@	c #4887A5",
"I@	c #3A7B95",
"J@	c #4EA0C2",
"K@	c #509AB7",
"L@	c #5EB4D5",
"M@	c #3A697E",
"N@	c #4B8BAB",
"O@	c #67B3D5",
"P@	c #68C5E9",
"Q@	c #508EAA",
"R@	c #183A48",
"S@	c #366D82",
"T@	c #4D8EAF",
"U@	c #4996B6",
"V@	c #66B2D4",
"W@	c #3D7990",
"X@	c #5697B4",
"Y@	c #62ABCC",
"Z@	c #62C7F1",
"`@	c #72C5EA",
" #	c #417995",
".#	c #67BBE5",
"+#	c #5CB1D1",
"@#	c #60AFD6",
"##	c #040E14",
"$#	c #58A9C8",
"%#	c #6EC8F3",
"&#	c #366376",
"*#	c #4F93B4",
"=#	c #5CBBE2",
"-#	c #417A96",
";#	c #081820",
">#	c #67C4E8",
",#	c #56B0D5",
"'#	c #3B708A",
")#	c #152E3A",
"!#	c #57A8C7",
"~#	c #65B7DF",
"{#	c #4D9FC1",
"]#	c #65C0E3",
"^#	c #275161",
"/#	c #4E96B2",
"(#	c #5291AD",
"_#	c #65B8E0",
":#	c #396C85",
"<#	c #49829B",
"[#	c #4C8DAD",
"}#	c #1D3F4C",
"|#	c #62ACCC",
"1#	c #295165",
"2#	c #5195B7",
"3#	c #5697B5",
"4#	c #5297B9",
"5#	c #62BBDD",
"6#	c #457B93",
"7#	c #65C1E4",
"8#	c #2E5E71",
"9#	c #60A8C9",
"0#	c #4682A0",
"a#	c #64BEE0",
"b#	c #2E5567",
"c#	c #4B859F",
"d#	c #559CBF",
"e#	c #5195B6",
"f#	c #5A9DBC",
"g#	c #4F8CA8",
"h#	c #274D5F",
"i#	c #58A1C5",
"j#	c #224E60",
"k#	c #4683A1",
"l#	c #5DB1D2",
"m#	c #5EACD1",
"n#	c #51A6CA",
"o#	c #264857",
"p#	c #72C6EB",
"q#	c #6DBDE1",
"r#	c #41758C",
"s#	c #63ACCD",
"t#	c #71C5EA",
"u#	c #6CC4EF",
"v#	c #0B1F27",
"w#	c #66B9E2",
"x#	c #2C596B",
"y#	c #6BCAEF",
"z#	c #5596B3",
"A#	c #68BDE6",
"B#	c #2E596F",
"C#	c #5EA4C3",
"D#	c #64B6DE",
"E#	c #2F5668",
"F#	c #39677B",
"G#	c #4A839D",
"H#	c #498DA8",
"I#	c #366880",
"J#	c #5CBAE2",
"K#	c #2B5162",
"L#	c #3E7086",
"M#	c #5595B2",
"N#	c #67B3D6",
"O#	c #33667A",
"P#	c #599DBB",
"Q#	c #335D70",
"R#	c #6AB8DB",
"S#	c #2A5769",
"T#	c #6CBCE0",
"U#	c #16303D",
"V#	c #6BC2EC",
"W#	c #224857",
"X#	c #1E3E4E",
"Y#	c #529FBC",
"Z#	c #5DA3C2",
"`#	c #6DC5F0",
" $	c #71C4E9",
".$	c #63B4DC",
"+$	c #73C7ED",
"@$	c #4885A4",
"#$	c #4D8FAF",
"$$	c #59A3C7",
"%$	c #366275",
"&$	c #437890",
"*$	c #295465",
"=$	c #69B7D9",
"-$	c #62B3DB",
";$	c #122731",
">$	c #66B1D3",
",$	c #4F98B4",
"'$	c #0C1F28",
")$	c #58A2C6",
"!$	c #6FC0E4",
"~$	c #4C8CAC",
"{$	c #0D1F27",
"]$	c #6CBCDF",
"^$	c #56A6C4",
"/$	c #4C87A1",
"($	c #518FAB",
"_$	c #315F75",
":$	c #73C7EC",
"<$	c #2D6279",
"[$	c #61B1D9",
"}$	c #70C3E8",
"|$	c #284F62",
"1$	c #2B5367",
"2$	c #35657D",
"3$	c #45809E",
"4$	c #60A7C7",
"5$	c #73C8ED",
"6$	c #5CA8CD",
"7$	c #5290AC",
"8$	c #22414F",
"9$	c #2F5769",
"0$	c #67B4D7",
"a$	c #4987A6",
"b$	c #2B586A",
"c$	c #386A83",
"d$	c #5399BC",
"e$	c #2C5263",
"f$	c #2A5266",
"g$	c #31596C",
"h$	c #65B0D1",
"i$	c #6ACAEE",
"j$	c #52A9CD",
"k$	c #467D96",
"l$	c #356A7E",
"m$	c #61AACA",
"n$	c #5093B4",
"o$	c #255467",
"p$	c #4B8BAA",
"q$	c #6FC8F4",
"r$	c #5DA4C3",
"s$	c #2D5466",
"t$	c #3C718B",
"u$	c #5698B5",
"v$	c #437990",
"w$	c #284B5B",
"x$	c #69C7EB",
"y$	c #63AECF",
"z$	c #4E90B0",
"A$	c #5196B7",
"B$	c #57A7C6",
"C$	c #203E4B",
"D$	c #5799B6",
"E$	c #4B86A0",
"F$	c #397288",
"G$	c #254D5D",
"H$	c #5FB6D8",
"I$	c #5CA2C1",
"J$	c #8BA5B6",
"K$	c #8AA5B9",
"L$	c #6AB9DC",
"M$	c #57A0C3",
"N$	c #5094B6",
"O$	c #5A9FBD",
"P$	c #60B7D8",
"Q$	c #73C8EE",
"R$	c #5BA7CC",
"S$	c #3E6F86",
"T$	c #5494B1",
"U$	c #66BAE3",
"V$	c #5392AF",
"W$	c #335E71",
"X$	c #98867F",
"Y$	c #8AA4B8",
"Z$	c #939296",
"`$	c #8CA2B2",
" %	c #6AC0EA",
".%	c #457B94",
"+%	c #6EC7F2",
"@%	c #407289",
"#%	c #3F7187",
"$%	c #6FC1E5",
"%%	c #74C8EE",
"&%	c #81B7D3",
"*%	c #978A87",
"=%	c #57A0C4",
"-%	c #325B6E",
";%	c #549ABD",
">%	c #6AC0EB",
",%	c #76C9EF",
"'%	c #83CDED",
")%	c #998881",
"!%	c #FFF7D7",
"~%	c #DDD1BA",
"{%	c #9A8981",
"]%	c #1E3B48",
"^%	c #907E78",
"/%	c #4D433F",
"(%	c #77CBF5",
"_%	c #69CCF7",
":%	c #DACCCA",
"<%	c #78C9EF",
"[%	c #DDD7DA",
"}%	c #9BD2EB",
"|%	c #FEF6D6",
"1%	c #C7B9A7",
"2%	c #58A8C7",
"3%	c #5FA6C6",
"4%	c #887871",
"5%	c #DBCDB8",
"6%	c #EEDFC8",
"7%	c #71CDF0",
"8%	c #7DCBF3",
"9%	c #DED3BB",
"0%	c #998780",
"a%	c #3F7691",
"b%	c #75CBF5",
"c%	c #3B6B83",
"d%	c #918079",
"e%	c #796A64",
"f%	c #B1A694",
"g%	c #71C9F5",
"h%	c #7FCBED",
"i%	c #0F222B",
"j%	c #7ECBEF",
"k%	c #040303",
"l%	c #867670",
"m%	c #8E8577",
"n%	c #7B7366",
"o%	c #B3D9E7",
"p%	c #7ACBEF",
"q%	c #8FD0F1",
"r%	c #B6A799",
"s%	c #6BB7DA",
"t%	c #372F2D",
"u%	c #BAAE9C",
"v%	c #1A1714",
"w%	c #39342E",
"x%	c #EDDEC7",
"y%	c #8CCFED",
"z%	c #A7968B",
"A%	c #7CC6EE",
"B%	c #5B9FBE",
"C%	c #346073",
"D%	c #080605",
"E%	c #27241F",
"F%	c #E2D4BE",
"G%	c #E7DCC2",
"H%	c #A9988D",
"I%	c #5298BA",
"J%	c #DDCFB9",
"K%	c #BBC1CA",
"L%	c #A7D6E9",
"M%	c #EDE3C7",
"N%	c #6095AF",
"O%	c #DED0BA",
"P%	c #81C6E8",
"Q%	c #EEE3DF",
"R%	c #FFFFFF",
"S%	c #8ECFED",
"T%	c #BB948D",
"U%	c #99867F",
"V%	c #FBF2D3",
"W%	c #C0B2A1",
"X%	c #5EA5C5",
"Y%	c #0D0C09",
"Z%	c #FAF2D3",
"`%	c #CFC7C8",
" &	c #F4F2DA",
".&	c #B5918B",
"+&	c #A08982",
"@&	c #D69E98",
"#&	c #6BBADD",
"$&	c #757161",
"%&	c #8ACFF1",
"&&	c #C5B4A5",
"*&	c #CEC5C6",
"=&	c #A98C86",
"-&	c #325568",
";&	c #B9B39B",
">&	c #7CCBEF",
",&	c #B5A498",
"'&	c #C3B5A4",
")&	c #B3A496",
"!&	c #323028",
"~&	c #F2EBCC",
"{&	c #CBBBAB",
"]&	c #9C8B83",
"^&	c #7BC5ED",
"/&	c #3A687D",
"(&	c #BFB9A1",
"_&	c #76BDE3",
":&	c #2B4959",
"<&	c #999480",
"[&	c #8FCAE6",
"}&	c #C2B4A3",
"|&	c #AB9B8F",
"1&	c #988781",
"2&	c #6EBFE3",
"3&	c #395F74",
"4&	c #A6A08B",
"5&	c #FCF4D5",
"6&	c #7EC6EE",
"7&	c #B19089",
"8&	c #666355",
"9&	c #D5CEB3",
"0&	c #9CCFEA",
"a&	c #89CDED",
"b&	c #C1B3A2",
"c&	c #DCCDB9",
"d&	c #72C5EB",
"e&	c #65A2C3",
"f&	c #447991",
"g&	c #403834",
"h&	c #201B19",
"i&	c #36322C",
"j&	c #6B6459",
"k&	c #DAD3B7",
"l&	c #FDF5D5",
"m&	c #94CCEC",
"n&	c #9B8A83",
"o&	c #CABAA9",
"p&	c #81CBED",
"q&	c #83C6E8",
"r&	c #A4D1EA",
"s&	c #C0B2A2",
"t&	c #A5938A",
"u&	c #BBAB9F",
"v&	c #CDBDAC",
"w&	c #93CBE6",
"x&	c #B7A699",
"y&	c #E1D5C6",
"z&	c #90CCEC",
"A&	c #9F8F8A",
"B&	c #CEBDAD",
"C&	c #A49389",
"D&	c #9D8B83",
"E&	c #B7A89A",
"F&	c #929CA7",
"G&	c #C2B2A3",
"H&	c #AAA1A1",
"I&	c #BCAD9D",
"J&	c #B6A598",
"K&	c #B1A094",
"L&	c #A18F86",
"M&	c #919CA8",
"N&	c #C9B9A9",
"O&	c #AE9C91",
"P&	c #8F9DA9",
"Q&	c #CAB9A9",
"R&	c #CCBCAB",
"S&	c #A9988E",
"T&	c #C5B5A5",
"U&	c #EAE0C5",
"V&	c #7AC1E2",
"W&	c #C4B7A5",
"X&	c #EEE4C8",
"Y&	c #81BEE1",
"Z&	c #A8968C",
"`&	c #CEBEAD",
" *	c #9C8A84",
".*	c #9E8881",
"+*	c #86BCD9",
"@*	c #C8B7A7",
"#*	c #C4B6A5",
"$*	c #B2A4A1",
"%*	c #B08F89",
"&*	c #83BADB",
"**	c #9B8981",
"=*	c #ECE5D9",
"-*	c #C6B9A7",
";*	c #B1A194",
">*	c #A39288",
",*	c #82BCDE",
"'*	c #CBBAAA",
")*	c #B7A69A",
"!*	c #E9E3D9",
"~*	c #B7A899",
"{*	c #85BDDA",
"]*	c #88C4E8",
"^*	c #BEAEA0",
"/*	c #9C8A82",
"(*	c #CCBFB9",
"_*	c #E4DED9",
":*	c #D4C8B2",
"<*	c #A7968C",
"[*	c #85BEDC",
"}*	c #9F8D85",
"|*	c #AA9A8F",
"1*	c #B4A397",
"2*	c #D2C5C0",
"3*	c #DFD9DA",
"4*	c #D2C5B0",
"5*	c #A7978C",
"6*	c #C08E88",
"7*	c #A08F86",
"8*	c #B3A396",
"9*	c #BEB09F",
"0*	c #CABDAA",
"a*	c #ECE2C7",
"b*	c #BDAC9E",
"c*	c #E7DBD7",
"d*	c #D9CDB6",
"e*	c #CEC1AD",
"f*	c #9F8E85",
"g*	c #82BCDF",
"h*	c #BBAC9D",
"i*	c #D6CAB4",
"j*	c #A29188",
"k*	c #86BBD8",
"l*	c #AC9C90",
"m*	c #B5A698",
"n*	c #D7CCB5",
"o*	c #86BBD7",
"p*	c #B19F94",
"q*	c #F2EBD8",
"r*	c #D7CBB4",
"s*	c #8CB9D7",
"t*	c #BBAB9D",
"u*	c #EBE5D9",
"v*	c #C9BCA9",
"w*	c #C2B1A2",
"x*	c #FAF2D7",
"y*	c #E3DDD9",
"z*	c #D5C9B3",
"A*	c #D1C4B0",
"B*	c #A5958A",
"C*	c #B78782",
"D*	c #C6B5A6",
"E*	c #F9F2D8",
"F*	c #F9F2D7",
"G*	c #DED8DA",
"H*	c #D7C9C7",
"I*	c #AA998E",
"J*	c #F7EED0",
"K*	c #9A8982",
"L*	c #E9DAC4",
"M*	c #A47974",
"N*	c #93C8E6",
"O*	c #BAA99C",
"P*	c #DBCDCB",
"Q*	c #E0DADA",
"R*	c #9D8C85",
"S*	c #C6B7B4",
"T*	c #8AC4E8",
"U*	c #8EC6E8",
"V*	c #A5948A",
"W*	c #AEA09C",
"X*	c #A2918A",
"Y*	c #E9E2D9",
"Z*	c #FCF4D7",
"`*	c #FEF6D7",
" =	c #F4ECD8",
".=	c #B1A09B",
"+=	c #F0E9D8",
"@=	c #B4A6A3",
"#=	c #D9CBC9",
"$=	c #E6DFD9",
"%=	c #F5EDD8",
"&=	c #E8E1D9",
"*=	c #B6A6A1",
"==	c #DBCECA",
"-=	c #DDCFCD",
";=	c #B6AAA7",
">=	c #CBBCB9",
",=	c #E4DDD9",
"'=	c #F5EED8",
")=	c #FDF5D7",
"!=	c #A5D1E4",
"~=	c #95C8E6",
"{=	c #D0C0AE",
"]=	c #B4A49F",
"^=	c #E7D8C8",
"/=	c #F2EFF0",
"(=	c #F3ECD8",
"_=	c #E2DBDA",
":=	c #B3A6A3",
"<=	c #A4938D",
"[=	c #F6EFD8",
"}=	c #F7F0D8",
"|=	c #A3CDE6",
"1=	c #99CAE6",
"2=	c #B3A39E",
"3=	c #F4F2F3",
"4=	c #EEECED",
"5=	c #FBF3D7",
"6=	c #A08E86",
"7=	c #89C8E8",
"8=	c #9ECCE6",
"9=	c #D6C7B4",
"0=	c #AB9B95",
"a=	c #FCFCFC",
"b=	c #EDE2DE",
"c=	c #EEEBEC",
"d=	c #EBE1C6",
"e=	c #E9DFC4",
"f=	c #A8988D",
"g=	c #A8978C",
"h=	c #BCADA8",
"i=	c #F1EAD8",
"j=	c #92A2B1",
"k=	c #92A1B0",
"l=	c #949AA3",
"m=	c #978B88",
"n=	c #92CAE6",
"o=	c #93C1E1",
"p=	c #E4D8D3",
"q=	c #EDE6D9",
"r=	c #A1908A",
"s=	c #EDE3DF",
"t=	c #F8EFD1",
"u=	c #AE9E92",
"v=	c #9B8983",
"w=	c #8DB5D1",
"x=	c #8CBAD8",
"y=	c #88C2E6",
"z=	c #8AC0E1",
"A=	c #8CBAD9",
"B=	c #89B5CE",
"C=	c #92A3B5",
"D=	c #988882",
"E=	c #96C8E6",
"F=	c #E8D9C8",
"G=	c #F1E8CB",
"H=	c #A9998D",
"I=	c #A19087",
"J=	c #B8A7A3",
"K=	c #EFE8D8",
"L=	c #F9F1D8",
"M=	c #8FC1E7",
"N=	c #AC9D98",
"O=	c #CFC0BD",
"P=	c #DBD0B9",
"Q=	c #C0B1A1",
"R=	c #FDF4D5",
"S=	c #DFD3CF",
"T=	c #D8D1D4",
"U=	c #8CC6E8",
"V=	c #DED8D6",
"W=	c #D3C4C2",
"X=	c #EBDCC8",
"Y=	c #FDF5D6",
"Z=	c #AF9D92",
"`=	c #D1C2BF",
" -	c #FDFCFC",
".-	c #DACBB7",
"+-	c #BBAD9D",
"@-	c #9A8880",
"#-	c #B3A39D",
"$-	c #D0C1BE",
"%-	c #FFFFFE",
"&-	c #CFBFAD",
"*-	c #C4B3A4",
"=-	c #EADBC8",
"--	c #A5948E",
";-	c #D3C5C2",
">-	c #AD9D91",
",-	c #C1B0A2",
"'-	c #C3B2A3",
")-	c #EDDEC8",
"!-	c #E1D4C9",
"~-	c #B8A8A4",
"{-	c #A2918C",
"]-	c #998781",
"^-	c #F6F4F3",
"/-	c #E0DBDE",
"(-	c #B2A195",
"_-	c #A59690",
":-	c #DCD1B9",
"<-	c #AA9B96",
"[-	c #9A8881",
"}-	c #F1E9D8",
"|-	c #A5948D",
"1-	c #A08F88",
"2-	c #D5C5B3",
"3-	c #E7D9C8",
"4-	c #AD9C97",
"5-	c #E2D7BE",
"6-	c #CBBEAA",
"7-	c #A3938D",
"8-	c #CFC6C7",
"9-	c #D7D0D2",
"0-	c #C6BCBB",
"a-	c #CBC1C2",
"b-	c #A2908A",
"c-	c #E7E0D9",
"d-	c #C7B7A7",
"e-	c #C3B3A4",
"f-	c #9A8882",
"g-	c #9F8F89",
"h-	c #F5ECCF",
"i-	c #C0B5B4",
"j-	c #D8D2D4",
"k-	c #D5CDCF",
"l-	c #D2CACB",
"m-	c #D7D0D3",
"n-	c #DAD4D6",
"o-	c #DCD6D9",
"p-	c #C0B1AC",
"q-	c #9B8881",
"r-	c #E2DCDA",
"s-	c #B7ABA8",
"t-	c #DCD5D8",
"u-	c #AB9D99",
"v-	c #9D8C8A",
"w-	c #9A8984",
"x-	c #9E8D8D",
"y-	c #CFC2AE",
"z-	c #BBAFAD",
"A-	c #BAAB9C",
"B-	c #C2B3AF",
"C-	c #F8F0D8",
"D-	c #C7B6A7",
"E-	c #A3918A",
"F-	c #B7A7A1",
"G-	c #FBFAFB",
"H-	c #E1DCDE",
"I-	c #C9C0C0",
"J-	c #D9D2D5",
"K-	c #D4CDCF",
"L-	c #CCC3C4",
"M-	c #C0B0AC",
"N-	c #C2B5A3",
"O-	c #9E8D87",
"P-	c #F8F1D8",
"Q-	c #C2B1A3",
"R-	c #A29087",
"S-	c #988680",
"T-	c #EBDFDB",
"U-	c #FEFEFE",
"V-	c #9B8A82",
"W-	c #BFB1A1",
"X-	c #8C2047",
"Y-	c #8B1C41",
"Z-	c #A0254A",
"`-	c #9B636C",
" ;	c #99837D",
".;	c #AB9C98",
"+;	c #D0C8C9",
"@;	c #A0908A",
"#;	c #C9BAB7",
"$;	c #F3EACD",
"%;	c #F7EFD8",
"&;	c #C4B4A5",
"*;	c #B8A99B",
"=;	c #F0E7CB",
"-;	c #CCBFAB",
";;	c #D4D1F7",
">;	c #911C44",
",;	c #991741",
"';	c #AF1A43",
");	c #A08F89",
"!;	c #C1B6B5",
"~;	c #B2A395",
"{;	c #FDFDFD",
"];	c #F6EED8",
"^;	c #A29187",
"/;	c #C8B8A8",
"(;	c #AD9C91",
"_;	c #FBF3D4",
":;	c #9C143F",
"<;	c #9F123D",
"[;	c #B7143F",
"};	c #DAD3D6",
"|;	c #E8E3E2",
"1;	c #A3928D",
"2;	c #C1B2AE",
"3;	c #CAC1BD",
"4;	c #F4EDD8",
"5;	c #FCF5D7",
"6;	c #E5DBC1",
"7;	c #C1B1A2",
"8;	c #DDCEBA",
"9;	c #E5E1E3",
"0;	c #C7BAA7",
"a;	c #E6DCC2",
"b;	c #A62147",
"c;	c #951A42",
"d;	c #A2103C",
"e;	c #BD103D",
"f;	c #BA123E",
"g;	c #B31741",
"h;	c #9B8A84",
"i;	c #EEECEA",
"j;	c #D4CDCE",
"k;	c #BEB0A0",
"l;	c #A7958C",
"m;	c #DBCBB8",
"n;	c #F4EBCE",
"o;	c #9E8D89",
"p;	c #AB1E45",
"q;	c #BF0F3C",
"r;	c #B4A7A4",
"s;	c #9E8C84",
"t;	c #FCFBFB",
"u;	c #D3CBCD",
"v;	c #E1BFC8",
"w;	c #FCF3D4",
"x;	c #C10D3B",
"y;	c #A6666C",
"z;	c #9B8982",
"A;	c #F9F0D1",
"B;	c #CDBCAC",
"C;	c #F9F0D2",
"D;	c #A60D3A",
"E;	c #A90B39",
"F;	c #D7CBB5",
"G;	c #BEB3B1",
"H;	c #DBD4D7",
"I;	c #A2918B",
"J;	c #B0A093",
"K;	c #A4264A",
"L;	c #B12347",
"M;	c #B32348",
"N;	c #B92046",
"O;	c #C00F3C",
"P;	c #E9103D",
"Q;	c #A02144",
"R;	c #9D8C86",
"S;	c #AFA19D",
"T;	c #E8D9C3",
"U;	c #D8D5F8",
"V;	c #ECEBFB",
"W;	c #F0EFFC",
"X;	c #EFEEFC",
"Y;	c #B32A4B",
"Z;	c #BC2146",
"`;	c #C3163F",
" >	c #B7153F",
".>	c #A9274A",
"+>	c #B72B4B",
"@>	c #BD2C4C",
"#>	c #C52749",
"$>	c #C72849",
"%>	c #E3143F",
"&>	c #E6123E",
"*>	c #E01640",
"=>	c #CE2447",
"->	c #F4EBCD",
";>	c #EADBC5",
">>	c #DCD9F8",
",>	c #FDFDFF",
"'>	c #C12D4C",
")>	c #DC1941",
"!>	c #D61841",
"~>	c #DAD8F8",
"{>	c #E8E7FB",
"]>	c #F4F4FD",
"^>	c #F7F7FE",
"/>	c #BE2C4C",
"(>	c #C82849",
"_>	c #D81C43",
":>	c #C02846",
"<>	c #AFA2AC",
"[>	c #AFA093",
"}>	c #C6133E",
"|>	c #C3A7CF",
"1>	c #D7D5F8",
"2>	c #EAE9FB",
"3>	c #F1F1FC",
"4>	c #F5F4FD",
"5>	c #FCFCFF",
"6>	c #FEFEFF",
"7>	c #D32045",
"8>	c #FBFAF9",
"9>	c #9F8F88",
"0>	c #9ABFE1",
"a>	c #DDDBF9",
"b>	c #F6F6FD",
"c>	c #F9F9FE",
"d>	c #AD9E99",
"e>	c #E7E1D9",
"f>	c #AF9F92",
"g>	c #EEE7D9",
"h>	c #E3E1FA",
"i>	c #F9F8FE",
"j>	c #C4B9B9",
"k>	c #BAAC9C",
"l>	c #9E8D85",
"m>	c #AE9E98",
"n>	c #E4D9C0",
"o>	c #B8ABA9",
"p>	c #A39189",
"q>	c #A4C7E0",
"r>	c #FAF1D3",
"s>	c #B1A4A1",
"t>	c #EEE5C9",
"u>	c #A79792",
"v>	c #ADC8DF",
"w>	c #D3C7B1",
"x>	c #AD9E9A",
"y>	c #9EC1E1",
"z>	c #B0A09B",
"A>	c #E8DEC3",
"B>	c #BB0214",
"C>	c #9D8C84",
"D>	c #95C1E1",
"E>	c #E4D8D4",
"F>	c #9F8E87",
"G>	c #FFFFFD",
"H>	c #B6A9A6",
"I>	c #AB9B90",
"J>	c #D9D3D5",
"K>	c #95C2E1",
"L>	c #AB9D98",
"M>	c #998880",
"N>	c #C6B6B3",
"O>	c #9F8E86",
"P>	c #A3BEDB",
"Q>	c #BCACA8",
"R>	c #D0C3AF",
"S>	c #C3B4B0",
"T>	c #C5B5B2",
"U>	c #FFFEF9",
"V>	c #FFF7D8",
"W>	c #9C8B84",
"X>	c #9C8B85",
"Y>	c #9F8E88",
"Z>	c #BAAAA6",
"`>	c #DCD0B9",
" ,	c #AC9B90",
".,	c #C3BDC4",
"+,	c #A18F87",
"@,	c #FFFBEC",
"#,	c #FFFCF0",
"$,	c #FFFDF3",
"%,	c #FFFEF8",
"&,	c #FFFDF4",
"*,	c #FFF8DC",
"=,	c #FFF9E0",
"-,	c #D7CFD1",
";,	c #CBC2C3",
">,	c #AF9E99",
",,	c #EDE4C8",
"',	c #EADAC4",
"),	c #DDCDB9",
"!,	c #D1C9CB",
"~,	c #D8D1D3",
"{,	c #C1BEC4",
"],	c #C9C9C9",
"^,	c #CFBFAE",
"/,	c #B9ADAB",
"(,	c #DBD5D8",
"_,	c #D6C8C6",
":,	c #B9ACAA",
"<,	c #C5B8A6",
"[,	c #DCCCB9",
"},	c #C6BDC1",
"|,	c #D6CFD1",
"1,	c #ECDDC6",
"2,	c #A4958F",
"3,	c #D9D2D4",
"4,	c #EFE5C9",
"5,	c #EEE7D8",
"6,	c #EAE3D9",
"7,	c #ECDDC7",
"8,	c #A2928C",
"9,	c #D4C4B2",
"0,	c #C2B7B6",
"a,	c #E3D8BF",
"b,	c #9D8C83",
"c,	c #ECE2C6",
"d,	c #E8E2D9",
"e,	c #A5958C",
"f,	c #AA9B97",
"g,	c #BCAB9D",
"h,	c #D5CED0",
"i,	c #A39289",
"j,	c #A0BDE0",
"k,	c #AF9E92",
"l,	c #DDCFC9",
"m,	c #C7BBAE",
"n,	c #B09F9A",
"o,	c #E5DED9",
"p,	c #A08E88",
"q,	c #EBDCC5",
"r,	c #BBABA7",
"s,	c #E9D9C3",
"t,	c #B2A295",
"u,	c #DACAB7",
"v,	c #A2928D",
"w,	c #BEAD9F",
"x,	c #D5C7C4",
"y,	c #D8CAC8",
"z,	c #C6B8A6",
"A,	c #E1D2BD",
"B,	c #BAAA9C",
"C,	c #9D8B84",
"D,	c #E1D1BD",
"E,	c #C9BFBF",
"F,	c #D1C9CA",
"G,	c #9E8C85",
"H,	c #D8C9B6",
"I,	c #A59692",
"J,	c #CBBBAA",
"K,	c #A4938A",
"L,	c #E8DDC3",
"M,	c #AEA1A1",
"N,	c #DBCFB8",
"O,	c #B5A598",
"P,	c #A1908B",
"Q,	c #AB9A8F",
"R,	c #C0B4B3",
"S,	c #C8BFBF",
"T,	c #CDC4C5",
"U,	c #BFB1A0",
"V,	c #9A8780",
"W,	c #F4E7CD",
"X,	c #BFAFA0",
"Y,	c #D2C2B0",
"Z,	c #F9EED1",
"`,	c #F7EBD0",
" '	c #F1E4CB",
".'	c #B8A99A",
"+'	c #F8EDD1",
"@'	c #F7ECD0",
"#'	c #E4DAC0",
"$'	c #A6968B",
"%'	c #B09F93",
"&'	c #A5C0DB",
"*'	c #F8EED1",
"='	c #F3E6CD",
"-'	c #E3DCDA",
";'	c #EEE4C9",
">'	c #F6EBCF",
",'	c #F2E5CC",
"''	c #B9AA9B",
")'	c #A9998E",
"!'	c #F3E6CC",
"~'	c #9E8D84",
"{'	c #F0E2CA",
"]'	c #C1B4AB",
"^'	c #FBF4D7",
"/'	c #AABBDB",
"('	c #ADBCD5",
"_'	c #F6EACF",
":'	c #EFE1C9",
"<'	c #BAAEAC",
"['	c #EEE0C8",
"}'	c #DFD1C9",
"|'	c #A69792",
"1'	c #B1BFDB",
"2'	c #A9C2DB",
"3'	c #B2C0DB",
"4'	c #B4C1DB",
"5'	c #B4A597",
"6'	c #ACBDDB",
"7'	c #A7C0DB",
"8'	c #C4D0DA",
"9'	c #C2B8B7",
"0'	c #AEBDDB",
"a'	c #E6E0D9",
"b'	c #D4CCCE",
"c'	c #D3CBCC",
"d'	c #BDC8DB",
"e'	c #AFBED5",
"f'	c #C3B8B7",
"g'	c #B1BED5",
"h'	c #CBC2C2",
"i'	c #B5C2DB",
"j'	c #395E35",
"k'	c #426C3D",
"l'	c #ABC2DB",
"m'	c #CDC5C5",
"n'	c #A9BBD1",
"o'	c #A6BBD7",
"p'	c #509855",
"q'	c #CFD2B0",
"r'	c #EBE4D9",
"s'	c #ADBCD3",
"t'	c #4A6B43",
"u'	c #B6BF9B",
"v'	c #653C21",
"w'	c #E6D8C8",
"x'	c #ABBCD1",
"y'	c #51A85E",
"z'	c #3B5832",
"A'	c #4D2A1B",
"B'	c #5C3423",
"C'	c #F3EBD8",
"D'	c #B2B9D5",
"E'	c #93715D",
"F'	c #5D3624",
"G'	c #543222",
"H'	c #496A42",
"I'	c #407441",
"J'	c #458249",
"K'	c #3B6338",
"L'	c #633C2B",
"M'	c #5E3625",
"N'	c #663F2E",
"O'	c #3D6C3D",
"P'	c #3B6539",
"Q'	c #407341",
"R'	c #498F50",
"S'	c #4B9554",
"T'	c #4FA15A",
"U'	c #4FA25A",
"V'	c #4C9956",
"W'	c #488D4F",
"X'	c #4FA25B",
"Y'	c #4FA35B",
"Z'	c #51A75E",
"`'	c #3C673A",
" )	c #49854B",
".)	c #4F9654",
"+)	c #3A6137",
"@)	c #9AB7C6",
"#)	c #438C5F",
"$)	c #437D4F",
"%)	c #B0B9D3",
"&)	c #3A6C44",
"*)	c #CABBBF",
"=)	c #B0B9D1",
"-)	c #3C946F",
";)	c #438A5C",
">)	c #437D50",
",)	c #B8B8D5",
"')	c #ACB7CF",
"))	c #427041",
"!)	c #BBB8D0",
"~)	c #3F633F",
"{)	c #E5DFD9",
"])	c #80939A",
"^)	c #8A97A3",
"/)	c #426D3F",
"()	c #8AAFA1",
"_)	c #509755",
":)	c #EFE6CA",
"<)	c #ECDDC8",
"[)	c #E1DBDA",
"})	c #B4B9D5",
"|)	c #E1D3C9",
"1)	c #E1DADA",
"2)	c #E0D1C9",
"3)	c #E2D4C9",
"4)	c #E4D6C8",
"5)	c #E5D7C8",
"6)	c #9B8984",
"7)	c #A49FAB",
"8)	c #B2ABBD",
"9)	c #B3ADBF",
"0)	c #998883",
"a)	c #9C8D8D",
"b)	c #ABA4B6",
"c)	c #ABACC0",
"d)	c #ABADC2",
"e)	c #FAF3D7",
"f)	c #EAE4D9",
"g)	c #BDADA9",
"h)	c #E0D9DA",
"i)	c #C8B9B6",
"j)	c #63B06A",
"k)	c #395F36",
"l)	c #C1B6D0",
"m)	c #3A7149",
"n)	c #50A65D",
"o)	c #3B7A53",
"p)	c #F0E8D8",
"q)	c #4E9165",
"r)	c #56A660",
"s)	c #53A75F",
"t)	c #5AA462",
"u)	c #438659",
"v)	c #A4948F",
"w)	c #798568",
"x)	c #448C5F",
"y)	c #3E9570",
"z)	c #3F9671",
"A)	c #459974",
"B)	c #55AA61",
"C)	c #438B5E",
"D)	c #7BA48B",
"E)	c #539468",
"F)	c #3D946F",
"G)	c #63B06B",
"H)	c #C5BBD0",
"I)	c #52A95F",
"J)	c #419370",
"K)	c #599E7C",
"L)	c #486441",
"M)	c #58AB63",
"N)	c #438658",
"O)	c #449873",
"P)	c #70A377",
"Q)	c #77B978",
"R)	c #C9B4CA",
"S)	c #CFBABD",
"T)	c #AEBEA6",
"U)	c #DDCECA",
"V)	c #FCF5D5",
"W)	c #F2F1CE",
"X)	c #FEF7D7",
"Y)	c #639D70",
"Z)	c #C6B4D0",
"`)	c #D9CEC4",
" !	c #5BAD65",
".!	c #56AA62",
"+!	c #57AB62",
"@!	c #5AAC64",
"#!	c #9D9385",
"$!	c #53A95F",
"%!	c #438052",
"&!	c #C9B6CA",
"*!	c #426E3F",
"=!	c #D2BABB",
"-!	c #3C926D",
";!	c #42794B",
">!	c #BDBAD0",
",!	c #C3BAD0",
"'!	c #CBB6CA",
")!	c #449664",
"!!	c #55A961",
"~!	c #469765",
"{!	c #489767",
"]!	c #CCCEB1",
"^!	c #CBC1D1",
"/!	c #58AA64",
"(!	c #459665",
"_!	c #459664",
":!	c #A2B49E",
"<!	c #478E61",
"[!	c #689F73",
"}!	c #426D3E",
"|!	c #E6E2C9",
"1!	c #F6F0CF",
"2!	c #CDB8CA",
"3!	c #D7C8C6",
"4!	c #416C3D",
"5!	c #F5EFCF",
"6!	c #E2DAD0",
"7!	c #539C6E",
"8!	c #F4EBD0",
"9!	c #59AB63",
"0!	c #5BAC65",
"a!	c #499767",
"b!	c #CBB8CA",
"c!	c #469665",
"d!	c #4C9063",
"e!	c #549C6F",
"f!	c #3D6138",
"g!	c #9FAD89",
"h!	c #CAB9D0",
"i!	c #E4DAD3",
"j!	c #EBE7C6",
"k!	c #CEB3CB",
"l!	c #CFBCCC",
"m!	c #A3BDA3",
"n!	c #D1B3C5",
"o!	c #E3D4C9",
"p!	c #EBDFC6",
"q!	c #E4D5C8",
"r!	c #56A17D",
"s!	c #D6B1C6",
"t!	c #E5DBD3",
"u!	c #A39188",
"v!	c #427642",
"w!	c #E9DDC4",
"x!	c #51A15A",
"y!	c #DBAFC6",
"z!	c #DEB0C0",
"A!	c #479765",
"B!	c #4D6445",
"C!	c #566950",
"D!	c #533021",
"E!	c #CBA4B0",
"F!	c #3F703F",
"G!	c #4E2C1C",
"H!	c #3F7240",
"I!	c #4E2B1C",
"J!	c #502D1E",
"K!	c #457E47",
"L!	c #94A08A",
"M!	c #4B301E",
"N!	c #96A187",
"O!	c #559E6D",
"P!	c #69A169",
"Q!	c #4D9A69",
"R!	c #E3AEC1",
"S!	c #E6D6C1",
"T!	c #E0B2C0",
"U!	c #E4D5BF",
"V!	c #3F713F",
"W!	c #CABAAA",
"X!	c #DBB1C6",
"Y!	c #DDB4C6",
"Z!	c #99AA91",
"`!	c #E5D5C0",
" ~	c #E3B0C1",
".~	c #EAACBC",
"+~	c #5EA372",
"@~	c #DEB2C0",
"#~	c #AC9C96",
"$~	c #479766",
"%~	c #44915F",
"&~	c #9E8C86",
"*~	c #DDB8C8",
"=~	c #E5B3C3",
"-~	c #437643",
";~	c #E4C7CD",
">~	c #EAB0BE",
",~	c #E3BECA",
"'~	c #E5B6C3",
")~	c #E8ACC1",
"!~	c #427643",
"~~	c #E5B4C3",
"{~	c #419772",
"]~	c #409671",
"^~	c #E5BBC6",
"/~	c #E5B5C3",
"(~	c #E7B8C3",
"_~	c #EAAEBC",
":~	c #E8AEC1",
"<~	c #EAAFBE",
"[~	c #E3B0C3",
"}~	c #E6D7C8",
"|~	c #E3C6CE",
"1~	c #EAAEBE",
"2~	c #E0D2C9",
"3~	c #E1C2CD",
"4~	c #E8B2C0",
"5~	c #E8B0BF",
"6~	c #E8B5C2",
"7~	c #EAB1BE",
"8~	c #EAB8C5",
"9~	c #E3C4CD",
"0~	c #4A9967",
"a~	c #E8B6C3",
"b~	c #F0AABD",
"c~	c #ECB2BE",
"d~	c #E8B4C2",
"e~	c #EAAFBC",
"f~	c #ECB8C0",
"g~	c #F2B3BF",
"h~	c #F2ABB7",
"i~	c #EEBAC0",
"j~	c #DFB8B6",
"k~	c #F2ADB7",
"l~	c #DBCDC9",
"m~	c #E0B7B4",
"n~	c #ECB4BE",
"o~	c #F0ACBD",
"p~	c #F0B0BF",
"q~	c #F2B1BF",
"r~	c #ECC0C5",
"s~	c #F2AFB9",
"t~	c #F7A9B8",
"u~	c #F8D1C6",
"v~	c #F0AEBF",
"w~	c #F4BEBE",
"x~	c #F5C6C6",
"y~	c #F2AEB9",
"z~	c #F7ADBA",
"A~	c #F0AEBD",
"B~	c #F7ABB8",
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
"+ . . . . . . + . + . . . + . . . . . . . . . . . + . . . . . . + + + . + + + + . . . . . . . + . + . . . + + . + + + + . + . . + . . . + . + + . . . . . + . . + . . . . + . + . . . + . . + . . . . + + + . + . . . . . + + + + + . . . . . . . + . + . . . . . . . + + . + . + . . . + . + . + + + . . . + . . + + . . + . . + . . . . . . . . + . + . . + . . + . . . + . . . . . . . + + . + . . . + . . + + . . . . . + . + . + . . . . . + + + + . . + . . + . . . + . . . + . . . . + . ",
"+ + + + + + . + . + + + . + . + + + + + . + + + . + + + + + + . . . + . . . . + + + + + + + . + . + + . . . + . . . . + . + + . + + + . + . . + + + + + . + + . + + + + . + . + + + . + + . + + + + . . . + . + + + + + . . . . . + + + + + . + . + . + + + + + + + . . + . + . + + + . + . + . . . + + + . + . . . + + . + + . + + + + + + + + . + . + + . + + . + + + . + + + + + + + . . + . + + + . + + . . + + + + + . + . + . + + + + + . . . . + + . + + . + + + . + + + . + + + + . + . ",
". . . . . . . . + . . . + . + . . . . . + . . . + . . . . . . + + + . + . . . . . . . . . . + . . . . + . . . + . + + . . . . . . . . . . + . . . . . . + . . + . . . . . . . . . . . . . + . . . . . . . . + . . . . . + + + + . . . . . . + . . . . . . . . . . . . + . + . . . . . . . + . . . . . . . + . + . + . . . . . . . . . . . . . . + . . . . . . . . . . . + . . . . . . . . . . . . . . + . . . . . . . . . + . + . . . . . . . . . . . . . . . . + . . . . . . . + . . . . + . + ",
"+ + . + + + . . + + . . + . . + + + + . + + . . . . . . + + . . . + . + + + + . . . + + + . + . + . . + + + . + . . . + . . . + + . + . . + + . . + + . . + . . . + . + @ # $ % & + + + . + + . . + . + + . + + + . . . . . . + + + . + + . + + + + + + . . . + . + . . . + + . + + + + . . + + + + + + . + . + . . + + + + + . . . . + + + + . . + . . + + + + . . . . + . . + + + + + + . + . + . . . . + + + . + + + . + . + + + . + + + + + + + + + + + + . . + + + + + + . . + + . . + . . ",
". . + . . . + . . . + . . . + . . . . . . . . + + + + + . . . . . . . . . . . + + + . . . . . + . + . . . . + . . . + . + + + . . + . + . . . + + . . . + . + + . . + * = - - - ; > . . . . . + + . + . . + . . . + . . + + . . . . . . . . . . . . . . . + + . + . + + + . . + . . . . . + . . . . . . + . + . . + . . . . . + + + + . . . . . . . + + . . . . + + . . . + + . . . . . . . . + . + . + + . . . + . . . . . . . . . + . . . . . . . . . . . . . + . . . . . . + + . . + + . + . ",
". . + + + . + + . . , ' ' ) ' ) ) ' ' ) ) ' ) ) ) ! . . + + + + + + + + + + . . . + + . + + . + . + . + + . + + . . + . . . + + . + . + + . . . + + + . + . . + . + ~ { - - - - - ] ^ + + . . . + . + . . . + . . + + . . + + + . + . + + + + + + + . + . . . . + . . . . + . + + + . + . + . . / ' ) ) ) ) ! + . + + + + . . . . . + + + + + + + . . . + + + . . + + . . . + . . . + + + . . . . + . . . + + . + . . + + + + + + . + . . + . + + . . + . . + . + . . . + + . . + + . . + . + . ",
"+ + . . . + . ( _ : < < < < < < < < < < < < < < < [ . + . . . . . . . . + . + + + . . + . . . . + . + . . + . . + . . + + + + . . . + . . + + + . . . + . + + . + . } - - - - - - - | . . + + + . + . + + + . + + . . + . . . . + . + . . . . . . . + . . + + + . + + + + . . . . . + . . . + + 1 < < < < < _ . . . . . . + + . + + . . . . . . . . + 2 3 . . + + 4 < 5 + . . + + + . + . + + + + . + + + . . + . + + . . . 6 7 8 + . + + 9 0 a a b b a b b a b a b b b a a b b a a b c . + . + ",
". + + + . + d e < < < < < < < < < < < < < < < < < [ + + + + + + + + + . + . + . + + + + + + + . + . + + . + + + + + . . . . + + + . . + . . . + + + . + . . + . + . f - - - - - - - g + . . . + . + . . . + + . + + . + + + + . + . + + + + + + + . + + . . . + . . . . + + + + + + + + + . . + h < < < < < _ + + + + + + + + . . + + + + + + + + + . 2 i + . + + j k l m + . . . + . + + . . . + . + . + + . + + . + + + + n o 8 + . . + 9 p + . . + . . + + + . . . + + . . + + . . + . + . + ",
"+ . . + + q < < < < < < < < < < < < < < < < < < < r . . . . + + + + . + + + . + . . . . . + . + + + . . + . . . . . + + + + . + + + + . + + . . . + + . + + . + . + s t - - - - - - u . + + + . + + + + + . . + + + + . . . . + . + + . . . . . . + . + + + + . + + + + . + . . . . + + . + + + 1 < < < < < _ + + . . . + . + + + . . . . + . + . . + v i . + . . 4 w x y . + + + . + + . + + + . + . + . . + . . + + . + ) z A B . + + . C D + + + . + + . . . + + + . . + + . . + + . + . + . ",
"+ + . + E F < < < < < < < < < < < < < < < < < < < [ + + + . . . . + . . + + . + + + + + . + . . . + + . + + + + + . . + + + . . + + + + . + + + . + + . + + + + . + + G - - - - - H I + + . + + . + . + + + . . + . + + + + + + . . + + + + + + + + . + . . + . + . + + . + + + + . . + . + . + h < < < < < J . + + + . + . . . + + + + . + . + + . + v i . + + + j K L M + + . + . . + . . . + + + + + + . + + . . + . + N O P B . . + + C D + + + . . + + + . . . + + . + + + . + + . + . + . ",
". + + . L < < < < < < < < < < < < < < < < < < < < [ . + + + + + + + + + . + + E Q + + + + + + + + + . + . + + + + + + + + + + + . + + . + + . + + + + + . + . + + . + R S - - - T U . . . + + . + + + . + . + + . + + . . . . + + + + . + + + . . + + . + + + + . + . . + . + . . + + + + + + . 1 < < < < < _ + + + + + + + + + + . . + + + + + + + + 2 i + . + + 4 w + V W . + + + + + + + + . + + . . . + + + + + + + m X Y Z B + + . . 9 p . . . + + . + . + + + + . + . + + + . + + + + . + ",
". + + + ` < < < < < < < < < < < < < < < < < < < < [ . + . + + + + + + + . + .  .... . +.@.+ + + . + + + + . . . + + . . . + + + . . + + . + . + . . + + . + + + + . . + . #.$.U + + + + + + + + . + + . + + + + + . + + + + + + + . + . + + + + + + + + + . + + + + + + + . + + + + . + . + + + h < < < < < _ . . + + . + + + . + + + + + + . + + + + v 3 + + . + j w + %.&.+ . + + . + + + + . + + + + + . . + + + + . *.=.+ P 8 + + + + C p + + + + + . + . + + + + + + + . . + . + + + + + + ",
"+ . + . -.< < < < < < < < < < < < < < < < < < < < r + . + . . . . . + . + + + i 7 ;.>.,.< '.B ).+ + m + . + + + . . + + + . . + + + + . + . + . + + . + + + . + + + + . + + + + + + + + . . + . + + + + + . . + + + . + + + . . + + + + . . . + . . + + . + + + + + + + + + + + . + + . + + + . h < < < < < J + + . . + . + + + + + . . . . + . + . . 2 i + . + + j K + !.F ~.+ . . + + + . + + . + + + + + + + . . . + {.].+ Z B . + . + C p + + . . + + + + + + . + . + . + + + + + . . + + . ",
"+ + + + ^.< < < < < < F /.' ' ' ) ' ' ' ) ) ' ' ' (.+ + + + + + + . ' _.:.+ + <.< [.}.|.7 < < 1.2.. 3.4.+ + . + + + + + + + + + + + + + + + + + + + + + . + . . + + + + + + + + . + . + + . + + . + + + + + . . + + + + . + + . + . + + + + + + + + . + + . + . . + . . + + . + . + + + . . + . h < < < < < _ + + + + + . . + + + + + + + + + . + + + 2 i + + + + j w + + D 5.+ + + . . + + + + . + + . + + . + + + . 6.7.. + Z B . + + . C D . + + . + + + . . + + + + + + + . + . + + + . + . ",
"+ . + + ^.< < < < < < 8.+ + . . + + . + + + + + + + + . + + + + + + + 9.0.a.6.0 < < < b.c.< < < K + d.e.+ + + + + + f.g.h.h.g.h.i.. + + + + + . j.h.g.h.h.h.h.k.+ + + l.m.m.n.m.m.8 + + + + + + 4.o.p.q.r.h.h.h.8.+ + . + s.t._ u.v.g.h.h.w.. + + + x.y.z.7.g.h.h.g.h.h.g.h.m.A.B L + + + + + + h < < < < < _ + + + . + + + . + . + + + + + + + + + + v 3 + + . . 4 K . . B.F / + . + + + . . + + . . + + + + + + + + C.D.+ + P B + + . + 9 p + + + + + + + + + + . + . + + . + . + + + . + + + ",
"+ . . + ^.< < < < < < E.. + + + + + . + + . + + . + + + + + + F.+ + + G.< < H.< < < < e e < < < I.J.k K.+ + . . . . L.< < < < < M.. . . . + + . |.< < < < < < 6 . + + K.< < < < < N.. + + + + O.P.< < < < < < < Q.. + + R.z < < < < < < < O + + . L S.< < < < < < < < < < < < < < < T.m + + + + h < < < < < _ + + + . + + + . + . + + + + . + + + . + 2 i . + + + j K + + + G.U.+ + + + + + + + + + + . . + + + + + V.W.!.. + Z B + + + + C p + . + . + + + + . + + + + . + + + + + . + + + + + ",
"+ + + . X.< < < < < < E.+ + + + + + + + + + + . + . + . + + . Y.+ Q 2 Z.< < < < < < < < < < < < < `.1. +~.+ + + + + L.< < < < < M.+ + + + . + + |.< < < < < < .++ + + ++< < < < < N.+ + + + @+F < < < < < < < < Q.+ + j.#+< < < < < < < < O . . |.M.< < < < < < < < < < < < < < < < < p + . + + 1 < < < < < _ + . + + + . + + + + . + . + + + + . + + 2 i + + + + j K + + . $+%++ + + . + + . + + + + + + + . . + + b.&++ + + Z B . + + + C p . + + + + + + + + + . + + + + + + + + + + + . + . ",
"+ + + + ^.< < < < < < &.+ + + + + + + + + + + + + + + . . + *+=+. G.< < < < < < < < < < < < < < < -+< < ;++ + + + + L.< < < < < M.+ + + + . + + |.< < < < < < .++ + + ++< < < < < N.. + . + N < < < < < < < < < Q.+ + b.< < < < < < < < < O + + Y.< < < < < < < < < < < < < < < < < < a 4.+ . + h < < < < < _ + + + + + + + + + + + + + + + + + + + + 2 i + + + . j K . + + + >+f.+ + + + + + + + + + + + + + . + (.F ,++ + + Z B + + + + C p + . + + + . + + + + + . + + + + . + + + . + + + + ",
"+ + + + ^.< < < < < < '+b.)+6.6.6.6.6.!+B.. + + + + + + + + ~+=+L.< < < < < < < < < < < < < < < < < < < H.k.+ + + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ + + ++< < < < < N.+ + + + {+< < < < < < < < < Q.+ + i.< < < < < < < < < O + + ]+< < < < < < < < < < < < < < < < < < < _.. + + h < < < < < _ + + + + + + + + + + + + . + + . + + + + 2 i + . + + j K + + + + ^+/++ + + + + + + + + + + + + + + + (+_++ + + + Z B + + + + C p + + + + + + + + + + + + + + + + + + + + + + + + + ",
"+ :++ + E.< < < < < < < < < < < < < < < < <+C E + :++ + + + [+i.z.< < < < < < < < < < < < < < < < < < < < Y.+ + + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ + + ++< < < < < N.+ + + + }+< < < < < < < < < Q.+ + |+< < < < < < < < < O + (.< < < < < < < < < < < < < < < < < < < < 1++ + + h < < < < < _ + + + + + + + + + :++ + + + + + + :++ + 2 i + + + + j 2+:++ + + + 3+4++ + + + + + + + + + + + + + + 5+6++ + . + Z B + + + + C p + + + . + + + + + + + + + + + + . + + + + :++ + + ",
"+ + + + o.< < < < < < < < < < < < < < < < < < 7+4.+ + + :++ =+8+]+< < < < < < < < < < < < < < < < < < < < 9++ + + + L.< < < < < M.+ + + :++ + + |.< < < < < < .++ + + ++< < < < < N.+ + + + 1.< < < < < 1.[ 0+0+a++ m < < < < < < b+c+0+0+)++ d+< < < < < < < e+f+g+>+g+M Z.< < < < < < `.:++ + h < < < < < _ + + + + + + + + + + :++ + . :++ + + + + 2 h+:++ + + j K + + + :++ 2 i++ + + + + + + + + + + + :++ j+k++ + + + + Z l++ + + + m+p + + + + :+:++ + + + + + + + :+:++ + + :+:++ + :++ ",
"+ + + :+n+o+< < < < < < < < < < < < < < < < < < -.:++ + + :+}+%+p+< < < < < q+r+s+t+s+s+u+7 < < < < < < < <++ + + :+L.< < < < < M.:+:++ :+:+:+:+v+< < < < < < w++ :++ ++< < < < < x+:++ :+:+y+< < < < < z+:+:++ :+:+A+< < < < < < B+:+:+:+:+:+d+< < < < < < i+:++ + + + + C+H.< < < < < `.:++ + h < < < < < _ :+:++ :++ :+:+:++ + :+:++ + :+:++ + :+:+2 i + :+:+:+j K + :++ + + (.D+E++ + :+:++ + :+:+:++ + :++ x+F+:+:++ :++ Z l+:+:++ + C G+g+g+>+>+>+g+>+>+>+g+>+g+g+>+>+g+>+g+>+d++ :++ :++ ",
"+ :+:++ + =.< < < < < < < < < < < < < < < < < < I.@+:++ + + H+ +< < < < < < L.+ + + :++ I+&+< < < < < < < 2+:++ :+I+J+< < < < < K++ + + + + + + L+< < < < < < .+:++ + M+< < < < < N.+ :++ + N+< < < < < j + + + + + O+< < < < < < P++ + I++ + d+< < < < < < Q++ + + + R+S+T+< < < < < < `.+ :+:+h < < < < < _ + + :++ + + + + + + + + :++ + + + :++ + 2 i :++ + + j K :++ + + :+:+++U+:+:++ + :+I++ + + :++ + V+%++ + + :++ :+Z B + + :++ m+W+6.6.X+6.6.6.X+6.6.6.X+6.6.6.6.6.X+6.6.!.+ + + + + ",
"+ + + + + F.}+< < < < < < < < < < < < < < < < < < Z + :++ + Y+< < < < < < < B.+ + + + + + E+< < < < < < < %.:++ + + L.< < < < < M.+ + + + + + + |.< < < < < < .++ :++ ++< < < < < N.+ I++ I+y+< < < < < j + :++ + :+A+< < < < < < ].+ + + + I+d+< < < < < < )++ Z+j s+H.< < < < < < < < `.+ + + h < < < < < _ + + + :++ + + :++ + I+I++ + + + + + + + 2 i + + + :+`+K + + :++ + + ~. @A++ + + + I++ + + + + + B .@+ + + + + + Z B + + + + C +@+ I+I++ + + :+:++ + + + + + I++ + + + :++ + + + + ",
"+ + + + + @@;.5+< < < < < < < < < < < < < < < < < p :++ + + 1.< < < < < < < B.:+I++ + + :+/ < < < < < < 1.J.+ + + + L.< < < < < M.+ @@+ + + I++ |.< < < < < < .++ + + ++< < < < < N.+ + + + N+< < < < < j + + + + + A+< < < < < < P++ + + + + #@< < < < < < ~+n b+< < < < < < < < < < < `.+ + + h < < < < < _ + + + + + + + + :+I++ + @@+ + :++ + + + $@i I++ + + j K + + + I++ + + %@&@+ + + + + + + + + + x.F *@+ + + + + + Z B + + :++ C +@+ + + + + + + + + I++ + :+:++ + + I+:++ + :++ :++ ",
":+@@@@:++ I+:+=@%.-@;@h.>@>@,@h.,@Z.< < < < < < < [ + I+:++ '@< < < < < < < B.:++ :++ I++ / < < < < < < )@I+!@+ + :+L.< < < < < K++ + + + + + :+|.< < < < < < w++ + @@M+< < < < < N.+ :++ I+~@< < < < < `+I+:++ + + {@< < < < < < ]@+ :+:+:+:+d+< < < < < < < < < < < < < < < < < < ^@/@s.+ :++ h < < < < < _ + + I++ I+@@+ I+:++ + + @@:++ :+:+:+:++ $@i I+:+I+I+(@K @@+ + I+:++ + !@_@:++ :+:+:+:+I+@@:+:+:@E.:+:++ :++ :+:+<@l++ + I+I+C +@+ :+:+:++ + + :++ + :++ I+:++ + + + + :++ :++ + + ",
"+ + + + + :++ + :+@@+ :++ + + + I+[@}@< < < < < < [ @@:++ :+7.< < < < < < < |@+ :+I++ + :+/ < < < < < < j A+1@:++ I+2@< < < < < M.+ @@@@@@:+:++ v+< < < < < < .+:+:++ ++< < < < < x+:++ :++ y+< < < < < j :++ @@+ :+A+< < < < < < ].:++ + + + 3@< < < < < < < < < < < < < < < '@++.++ I+:+:+I+:+h < < < < < 4@@@:+:+:+:++ + + + :+:++ + I+I++ + + + I+2 h+:+I++ + `+5@+ + :+:++ I+@@+ A.e.:++ + I++ :++ + O+6@~.+ + @@+ @@+ + 7@B :++ :+:+8@9@:++ I++ :+I+:++ :+:++ + + + :+:+:++ :+I+I++ I+@@+ ",
"+ + I++ + + I+I++ + + + + :+:++ :+:+0@< < < < < < [ + + + @@n < < < < < < < B.+ + @@+ I+:+a@< < < < < < b@c@o @@+ + 2@< < < < < K++ + + + + + I+d@< < < < < < .+I++ + ++< < < < < N.+ + + + y+< < < < < j + + + I+:+A+< < < < < < ].:++ + + + 3@< < < < < < < < < < < < '+e@f@E + :++ I+I++ I+:+h < < < < < _ + + I++ + @@:++ + + + + + + I++ + + + I+2 i + :+:++ j K :++ + I+:++ :++ c g@I++ + :++ + I++ h@i@@@I++ + + :++ + <@j@I++ + + C +@+ + + I+:++ + + I++ :+:+:++ + + :++ + :+:++ + @@+ ",
":+:++ I++ :+:++ + :+I++ :+I++ :++ + k@< < < < < < [ + :+:++ l@7 < < < < < < m@I+:++ :+:+I+/ < < < < < < n@o@p@+ :+:+J+< < < < < M.+ + + @@:+@@+ |.< < < < < < .++ + :+q@< < < < < x+@@:+:+:+N+< < < < < j @@+ @@:++ A+< < < < < < r@+ :+@@:+:+#@< < < < < < < < < < r.s@R+:++ + :++ :+:++ :+:+I+t@< < < < < _ @@+ :+R+u@+ + :+:+I+:++ + + :+:+@@@@+ :+v@h+:++ + + j 2+I+:++ :++ + I+:+w@x@|.@@:++ :+:+:++ y@z@+ :++ :++ I+@@+ 7@B :++ + + C +@:+:+@@+ + @@@@+ :+:++ + + I+@@:++ I++ + + :++ + :+",
"+ :+:+@@+ + :++ I+:+@@+ :+I++ :+@@+ A@< < < < < < B@I++ + @.C@D@< < < < < < R++ :+I++ :++ / < < < < < < E@< >++ + + L.< < < < < K+:+:++ + + :++ L+< < < < < < w+@@I++ M+< < < < < N.+ I++ I+y+< < < < < j I++ + I+:+A+< < < < < < P+I++ I++ + d+< < < < < < < F@&.G@+ I++ I+@@I+I++ + :++ + :++ H@< < < < < _ @@+ + _.I@:++ + :+I+:+:+:++ I++ + :++ + J@i I+@@@@:+j 2++ :++ :++ + I+:++ K@+++ @@+ + + :+L@M@+ + + I+:+:++ :+:+<@B @@:+:+:+8@+@I++ :+:++ + @@+ + I+I++ :++ I+@@:+:+:+:++ :++ + + ",
":++ + + @@:++ @@:++ + @@+ :+I+I++ :+_ < < < < < < [ :+@@:+X+N@O@< < < < < < B.@@+ a@P@+ @@@@C+Q@R@< < < < < S@@@@@:+J+< < < < < H++ I++ :+:++ :+|.< < < < < < .++ :+:+T@< < < < < x+:+:+@@:+N+< < < < < `+:++ :+:+I+{@< < < < < < r@+ + :+@@:+d+< < < < < < U@(.+ + :++ :+:++ :+:+@@:++ @@:++ @@t@< < < < < _ + :+@@V@W@I+I+@@+ :+I+I+I+@@+ :++ I+:++ X@9@:++ + I+Y@K @@I+:++ @@:+:++ :+Z@W.`@+ @@@@I+I+ #>.:+:+@@:++ + :+I++ Z l++ I+I+I+C 9@+ :++ + + :++ :+@@:+:+@@+ + :++ + I++ I+:+I+:+@@@@",
"@@:++ + .#G@f.f.+#+#f.@#f.+#+#f.@#M+##< < < < < < [ + I++ d+e $#< < < < < < B.@@+ %#&#e+k+*#=#:+R+-#< < < < >++ I+I+L.< < < < < ;#>#@@I+I+@@I+:+,#< < < < < < .++ + :+q@< < < < < '#+ + + + )#< < < < < j @@I++ :+I+O+< < < < < < r@:++ + + @@d+< < < < < < !#:++ I+:+I++ :++ + + I+@@+ I+I++ + H@< < < < < _ I++ + ~#7+:++ :++ :+:+:++ @@+ @@:+I+:++ b.{#:++ :++ (@K :+I+@@+ + + :+I+@@@@Y.`.+ + :+:+]#^#w@I++ + @@:++ :+I+@@7@B :+:+:++ C /#I+@@I+@@+ :+I++ + + + @@:++ :+@@:+@@:+I+:+I++ + + ",
"+ I+@@+ ^.< < < < < < < < < < < < < < < < < < < < (#+ :+@@:+<+y+< < < < < < _#+ @@+ 6.o+< < < :#4+:+<#< < < z.:+:+:+J+< < < < < < m.i s@s@0+s@[#}#< < < < < < l@@@@@I+++< < < < < N.:++ @@@@N+< < < < < |#+ :+@@+ :+A+< < < < < < P+I+:++ @@+ E+< < < < < < 1#2#s@s@0+0+3#4#3#3#s@0+0+0+5#:+:+I+t@< < < < < 6#:++ + 7#8#+ + I+@@I+I++ I++ I++ + :+I++ _ 9#+ @@+ + `+0#I++ + I+@@@@I++ + + a#b#Q + + + c+c@:+:++ I++ I+@@+ :++ Z c#+ + + @@d#e#+ + :++ @@+ :++ @@@@+ + I+:++ + I++ + + + :++ + @@",
"+ + @@@@^.< < < < < < < < < < < < < < < < < < < < f#I++ I+@@g#< < < < < < < h#O q@i#I+2+< < < < y+!@*@j#< < k#+ I+I+l#< < < < < < < < < < < < < < < < < < < < j.+ + I+q@< < < < < '#@@+ + + ~@< < < < < m#+ + @@+ @@O+< < < < < < r@I+:++ + @@:+0.< < < < < < < < < < < < < < < < < < < n#I+:++ H@< < < < < _ :+@@I+I+o#p#:++ + + @@+ + :++ @@+ :+@@:+h.q#+ @@@@I+`+K @@I+:++ + :+@@@@I+I++ r#s#@@@@t#D+u#+ @@:+I+:++ @@I+I+:+Z c#I+@@+ :+m+9@I+I++ + @@+ @@+ + @@@@:+I+@@+ + @@:+@@:+I+@@@@+ :+",
"@@@@+ + Q@< < < < < < < < < < < < < < < < < < < < O.:+I+:++ .+o+< < < < < < < < < v#v+w#e < < < < x#y#z#< < $@@@:+:+A#< < < < < < < < < < < < < < < < < < < F@w@@@@@:+++< < < < < x++ I+:+@@y+< < < < < `+@@I++ @@+ {@< < < < < < ]@:+I+I+@@+ I+B#< < < < < < < < < < < < < < < < < < < C#+ + @@t@< < < < < 4@I++ + :+&.>.I+I+@@@@+ @@@@@@@@+ @@I++ D#E#+ @@+ + :+j 5@+ :++ @@I+@@+ + :+:+I+)+7++ + {#N@:+@@+ + :++ I++ + :+@@<@B :++ @@I+d#+@:+:+@@I++ @@+ I+@@+ + I++ + @@:++ I++ I+:++ + I+I+",
"+ @@@@+ Q@< < < < < < < < < < < < < < < < < < < F#+ :+I+I+@@I+G#< < < < < < < < < < H#@@I#< < < < < J#!@< < e.@@I+:++ K#< < < < < < < < < < < < < < < < < < W@+ + I+@@q@< < < < < L#:+I++ I+)#< < < < < j :+@@+ @@I+{@< < < < < < P+:+@@+ I+:+:+M#< < < < < < < < < < < < < < < < < < < C#@@+ I+t@< < < < < 6#@@@@I+@@N#O#y#+ + @@+ + + + I++ I+@@:+%@P#+ I+I+I+@@j 5@I+@@+ :++ @@+ @@I+:+@@I+Q#R#I+S#T#+ @@@@I+@@@@I+@@@@I+I+7@j@@@+ :+:+m+e#I++ :+@@+ I+:++ @@I+:+@@@@+ @@@@:+@@:+I+I+I+:+:++ ",
"I++ I+@@^.< < < < < < < < < < < < < < < < < < U#*+@@I+:+:++ :+V#W#< < < < < < < < < X#A+Y#< < < < < Z#`#< e  $+ :+I+I+1+< < < < < < < < < < < < < < < < < o+.$I+@@:++ ++< < < < < N.I+:+@@:+~@< < < < < |#I+I+@@+ :++$< < < < < < r@I++ @@:+I+@@s.r.< < < < < < < < < < < < < < < < < < n#I+@@:+H@< < < < < _ + :+:++ + @$#$@@@@I+@@@@I+@@@@@@:++ $$%$E I+@@@@:+I+Y@K :++ I+I+I++ @@+ :+I++ :+o...J+&$+ @@+ + :++ + :++ + + :+<@l++ @@I+@@d#/#:+@@@@+ @@:+@@@@:+:+@@I+I+@@+ + I++ @@:+:+:+I+@@@@",
"@@+ I+I+Q@< < < < < < < < < < < < < < < < < *$=$I+@@@@I+@@I+:+@@-$;$< < < < < < < < < >$5#< < < < < ,$:+'$R@)$!$:+@@@@I+~$e < < < < < < < < < < < < < < {$.@@@+ @@@@@@M+< < < < < x+I+I+@@+ )#< < < < < `++ + @@I+I+O+< < < < < < ]@@@+ @@:++ @@@@]$Q#< < < < < < < < < < < < < < < < < ^$+ @@@@/$< < < < < 6#I+@@@@@@@@C@_ C.|.+ + :+I++ + I+u#($_$!$:++ :+@@:++ Y@0#@@@@:+@@@@I+I+@@:+@@@@@@:$h#<$[$I+@@@@@@@@@@@@@@@@@@@@I+7@c#+ @@I+:+d#(#' ' }$[@}$' ' [@}$[@P@' P@}$}$}$}$[@}$}$p#@@I+I+I+",
"I+@@I+@@0+>@|$h.,@|$|$>@|$>@>@>@>@|$1$2$3$4$5$+ :+I+I+@@I+@@I++ @@L.-+< < < < < < < < 6$T#< < < < < 7$I+8$< 9$+ @@+ I+@@@@0$a$A.v.>@|$|$h.>@>@,@>@b$c$q@.#@@+ @@I+I++ d$e$x@e$f$e$G#@@:+I+@@g$|$h.h.>@>@h$@@@@I+@@I+i$|$>@|$h.h.|$X+I+@@I+I+I++ I+I+, j$k$l$m.|$h.>@>@>@h.>@|$h.h.|$,@|$m$@@I++ n$f$x@e$o$x@p$@@I+I+I++ @@q$r$s$t$e#Z#f@Z#u$v$w$:@x$I+I+@@I++ I+@@)+M++ + @@:+I+:+@@I+@@I+I++ + K@L#@@:+I+I+I+I++ + :++ I+I+:+y$z$@@+ :+I+Z#|$>@>@|$,@|$>@>@>@h.h.|$>@|$|$h.h.h.,@h.h.A$+ + @@:+",
"@@:+@@@@@@@@@@@@@@@@:+:+I+I++ I+@@@@@@@@+ I+@@@@:+:+I+:++ @@@@I+@@@@B$C$D$E$l+-@< F$G$w#H$< < < < < B@:+1#< I$+ @@:+O++ @@@@@@@@I+:+:+@@+ I+I+I+@@:+I+:+I+@@@@:+@@@@@@+ I++ @@I+I+:+I+:+I+I+@@@@@@I++ I+I+I+:++ :+I+@@@@:+@@@@:+I+:+I+:+@@@@@@:+:+@@@@I+@@@@:+@@I+:+@@@@I+:+@@@@J$K$:+I+I++ I+@@@@I++ @@@@:++ + @@:+@@I+@@I+I+@@L$M$e#++N$O$P$Q$I+:+@@I+@@@@@@@@@@@@@@@@I+I+@@@@+ :+I+@@:+@@@@@@+ + I+:+:+:+:+I+@@I+@@:+:+@@I+@@I+@@I+@@:+@@@@I+@@I+@@I+I++ @@@@@@I+@@:+@@@@@@I+@@@@:+@@@@+ @@@@",
"I+@@+ I++ :+I+I+:++ I+I+:+@@@@@@@@+ + + @@:+I+I+I+I+:+@@@@:+I+:+@@I+@@R$%#+ @@@@S$T$U$@@V$< < < < < 2+I+W$*$5$@@I+I+7#G@I++ @@I+@@@@@@@@@@@@@@@@I+I+:+I+:+I+I+@@+ I+@@@@@@@@+ :+@@I+@@I+:+:++ I+I+:+@@@@@@:+I+@@@@@@I+I+I+@@X$@@@@I+:+I+@@I+I+@@Y$X$I+I+I+@@I+@@:+I++ I+:+I+I+X$X$X$X$Z$`$@@@@+ + @@@@I+I+I+@@@@+ @@I+:+@@@@@@@@I+@@@@@@@@+ I+I+@@I+@@@@+ I+I++ @@I+I+@@:+@@+ I+@@@@@@+ I+I+I+I+@@@@@@I+@@@@I+@@I+@@I+I+I+I+:++ @@I+@@I+I++ + :++ @@+ :+:+@@I+I+:+@@I+@@I+I+I+@@I+I+I+@@I+@@I++ ",
"I+@@@@@@I+@@@@I+@@@@@@@@+ I++ + @@@@@@I+@@@@:+@@@@@@I+@@I+:+@@+ @@I+@@:+@@I+I+I+ %.%+ +%}+< < < < < @%+ #%R$@@@@@@@@$%;@%%I+@@:+I+I++ @@:+I++ :+@@@@@@@@@@:+I+@@@@+ @@+ I+@@I++ @@@@@@@@I+@@@@@@@@I++ :+@@@@I+I+I+:+:+@@+ X$X$@@@@@@@@+ :+@@I+&%X$X$:+@@+ @@I+@@@@@@@@@@@@X$X$X$X$X$X$X$X$*%@@@@+ I+:+@@@@@@I+@@I+@@@@+ :++ + :++ I+@@:+@@@@@@I+@@+ + @@@@:+@@I+@@@@I+@@I+@@I+@@I++ @@@@@@I+@@@@@@+ @@I+I+@@I+@@I+@@@@@@@@@@@@+ I++ :+@@I+@@@@@@I+@@I+@@I+@@@@I++ :+I+@@@@@@I+@@@@@@I+@@I+@@@@@@",
"@@I+:+I+@@:++ @@I+I+I+I+@@@@@@@@@@I+@@@@I+I+@@I+I+I+@@I+@@@@I+@@:+@@+ @@I+@@@@@@@@ $@@=%< < < < < < -%@@;%:+I+:+@@@@>%< 6$:+I+I+@@@@@@I+I+@@@@@@@@I+I+I+:+I+I+@@+ @@I+@@@@@@@@@@I+I+I+I+@@I+:++ I+@@@@I+I+@@@@@@:+@@@@,%X$X$X$+ @@I+I+@@@@+ '%)%X$X$@@+ @@@@:+I+I+I+:+I+X$X$X$!%!%!%~%{%X$X$X$@@@@@@I++ @@I+@@I+:++ I+@@I+@@@@@@@@@@I+I+I+:+I+:+I+I+@@@@I+@@I+I+:++ :+I+:+I+@@I+@@@@@@I++ :++ I+I+@@I+@@@@I+:+:+:+I+I+@@+ I+I+@@:+@@@@@@@@I+I+I+:+I+@@I+@@+ + @@@@I+@@+ :++ :++ + @@:+:+@@I+I++ ",
"@@I+@@I+I+@@I+@@:+@@@@@@:+@@@@I+@@I++ @@@@I+:+@@@@:+:+@@@@@@I+I+:+@@I+I+:++ :++ + I+5$|$< < < < < < ]%@@O+:+I++ I+:+^%< /%X$X$I+I+I+:+@@+ @@I++ @@:+:+I+@@:+I+@@I+:+I++ I+@@I+@@:+:+@@@@@@I+@@@@+ I+@@@@+ + + @@I+(%_%X$X$X$:%X$,%@@I+@@<%+ X$X$[%X$}%@@+ @@@@@@@@I+@@X$X$!%!%!%!%!%!%|%1%X$X$@@+ @@@@+ @@+ @@@@@@@@I+@@I+I+I+@@+ :+@@@@I+:+@@@@@@@@I+:+I+@@:+I+@@I+@@@@@@+ :++ I+I+@@@@@@@@@@:+@@:+:+I+:+@@I+@@:+@@+ @@@@@@@@@@@@I+I+@@@@@@@@@@@@@@@@+ @@@@@@@@@@:+@@I+@@@@@@@@+ @@I+I+:+@@@@@@",
"I+@@I+:+@@I+@@@@@@I++ I+I+I+I+@@@@@@@@+ I+@@@@:+I+I+I++ I+:+@@@@@@@@@@@@@@@@I+@@@@@@2%< < < < < < < <  %@@@@@@@@3%X$4%< < 5%X$@@:+@@@@@@@@I+@@@@I+@@@@@@I+@@:+@@@@I+@@@@@@+ @@:+I+@@:+I+I+@@I+:+@@@@@@+ @@@@@@@@@@,%X$X$X$6%:%X$7%:+@@I+8%X$X$X$:%X$<%I+@@I+I+:++ @@X$X$!%!%!%!%!%!%!%!%!%9%0%X$@@@@I+@@I+@@+ I+@@+ @@@@@@@@@@I+@@@@@@+ @@@@I+:+I+I+@@@@@@I+@@@@I+@@I+I++ @@@@@@@@:++ @@@@@@+ I+I+@@@@:+@@@@@@I+I++ @@I++ + I+I+I+@@:++ :+I+:+@@+ I+:+@@@@@@I+I+I+@@@@@@I+I+I+@@@@I+@@@@I+:+I++ ",
"@@@@@@@@@@I+I+I+:+@@@@@@@@@@I+I+:+I+@@@@@@I+I+@@@@@@@@@@@@:+@@I+I+I+@@I+@@@@@@@@I+I+a%< < < < < < < < r$@@@@I+b%c%d%e%< < f%X$@@@@I++ @@@@@@@@:+I+I+@@@@I+@@I+@@@@@@I+I+@@I+I+@@@@I+@@:+@@@@@@@@@@I+@@I+@@@@I+I+I+g%X$X$X$6%:%X$g%g%@@X$X$X$X$:%[%X$@@I+h%@@I+@@@@X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@@I+@@@@@@@@@@@@I+I+@@@@@@@@I+I+I+@@@@@@@@I+@@@@I+I+I+@@I+@@@@@@@@@@@@I+I+@@@@@@@@I+I+I+@@@@@@I+I+@@@@I+@@@@@@@@@@@@@@@@@@@@@@@@I+@@I+@@@@I+@@@@I+@@I+I+@@@@@@I+@@@@@@@@@@@@@@@@I++ @@I+@@@@@@",
"I+I+@@I+@@@@@@@@@@I+:+@@@@@@@@:+@@@@@@I+I+@@@@@@@@@@@@I+@@@@I+@@@@@@I+@@I+@@I+I+@@`@i%< < < < < < < < '#I+I+j%4%k%l%m%< < n%6%X$I+@@@@I+I+I+I+@@@@@@I+@@@@I+@@I+@@I+@@@@@@@@@@@@I+@@:+@@I+I+I+I+I+@@@@@@I+I+@@@@@@X$X$6%6%6%:%X$o%p%q%X$X$X$6%[%[%X$@@@@@@@@@@@@X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%r%X$X$@@I+I+@@@@I+I+@@:+I+I+I+@@@@@@@@@@I+@@@@@@@@I+@@@@@@:+@@I+I+@@I+:+@@@@@@I+I+@@@@@@@@@@I+@@@@@@@@I+I+@@:+@@@@@@I+@@@@@@@@@@:+:+@@@@@@:+I+@@@@@@@@I+@@@@I+@@@@@@I++ @@I+@@I+@@@@@@@@@@@@@@I+I+",
"@@I+@@I+@@@@@@I+@@@@I+I+I+@@@@I+@@I+@@@@@@@@I+I+I+I+@@I+I+@@@@I+@@@@@@@@@@@@@@@@@@-$< < < < < < < < < < Z#@@s%t%< u%v%< < w%x%6%X$@@@@@@@@@@@@I+@@@@I+@@@@@@@@I+@@@@@@I+@@@@I+@@@@@@@@@@@@@@@@@@I+I+@@@@@@@@@@j%X$X$6%!%!%!%[%X$X$y%X$X$X$6%6%[%[%X$,%I+g%@@X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z%X$X$@@@@I+@@@@@@@@@@@@@@I+@@I+@@I+@@I+@@@@@@@@@@@@@@@@@@@@@@I+@@@@@@@@@@@@@@I+I+@@I+@@@@I+I+@@@@@@@@@@A%I+I+@@@@@@I+I+I+I+I+I+@@I+@@@@@@@@I+I+@@@@@@@@@@I+I+@@@@@@I+@@I+@@I+I+@@@@I+@@I+@@@@@@",
"@@@@I+@@@@I+I+@@A%I+@@@@@@@@@@@@I+@@@@@@I+I+@@@@@@@@@@@@A%@@I+@@I+@@I+@@I+@@@@I+I+B%< < < < < < < < < < e C%D%< < E%< < < < F%6%X$@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@I+@@I+@@I+@@@@@@I+I+@@@@@@@@@@@@@@A%@@@@@@I+@@X$X$6%!%!%!%[%[%[%X$X$X$X$6%6%!%[%[%X$I+@@h%I+X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%G%H%X$I+I+@@@@@@I+@@@@@@@@@@@@@@I+@@@@@@I+@@I+@@I+I+I+I+A%I+@@@@@@I+I+@@I+@@@@@@A%@@@@@@@@@@@@@@I+@@@@I+I+@@@@I+@@I+@@@@@@@@@@@@@@@@@@I+@@I+A%@@I+@@@@I+@@@@@@I+@@A%@@@@@@I+:+@@I+I+@@@@@@@@@@I+",
"A%@@I+I+@@@@A%@@@@@@@@@@I+A%I+A%@@@@I+@@@@@@@@@@@@I+@@@@I+@@@@@@I+@@I+@@I+@@@@A%@@I%< < < < < < < < < < < < < < < < < < < < J%6%X$K%@@I+I+@@@@I+@@@@I+@@@@@@@@@@@@@@@@@@@@@@I+@@@@I+I+@@I+I+@@@@@@A%I+@@@@I+X$X$X$6%!%!%[%[%[%[%X$X$6%6%6%!%!%[%[%X$@@@@L%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%|%M%X$X$@@I+@@@@A%I+I+I+@@I+@@@@@@I+@@@@I+@@@@@@@@@@@@I+@@@@@@I+@@@@I+@@@@I+@@@@I+@@I+A%@@I+I+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@I+@@I+A%A%@@@@@@@@@@I+@@@@@@@@@@I+@@@@I+I+@@@@@@@@@@A%A%@@@@@@@@@@",
"@@@@A%@@@@A%@@@@@@I+@@@@@@I+@@@@A%I+@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@@@@@@@@@I+@@@@@@N%< < < < < < < < < < < < < < < < < < < < O%6%X$X$@@@@@@@@@@@@I+@@A%I+A%I+@@@@I+@@@@@@I+I+P%@@A%A%@@I+A%@@I+@@I+I+@@I+@@X$X$X$Q%R%!%!%[%[%[%X$X$6%6%6%!%!%!%[%[%X$S%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%T%U%!%V%W%X$I+@@@@@@I+@@@@@@@@@@@@@@I+@@@@@@@@@@I+@@@@@@@@@@@@@@I+@@@@A%A%@@I+@@I+@@@@@@@@I+@@@@A%@@@@@@@@@@I+I+@@@@@@I+A%@@I+@@@@@@@@@@@@@@@@I+@@@@I+@@@@I+I+@@@@@@I+@@@@@@@@A%I+@@A%I+I+I+A%I+@@@@",
"@@@@@@I+I+I+I+@@@@I+I+@@@@A%@@I+@@@@@@A%I+I+@@I+@@@@I+@@@@A%@@@@@@@@@@@@@@@@@@I+I+X%< < < < < < < < < < < < < < < < < < < Y%Z%6%6%X$X$A%A%A%@@@@I+@@@@:+@@I+@@@@@@I+@@A%X$X$A%@@@@A%@@@@@@A%@@@@@@@@P%I+X$X$X$Q%Q%R%R%[%[%[%X$6%Q%!%!%!%!%!%!%[%`%X$X$X$ &!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%.&+&@&!%!%X$X$@@@@@@@@@@@@I+A%A%I+A%@@I+I+A%@@@@@@A%I+A%@@@@I+@@@@A%@@@@@@@@@@@@@@@@I+@@@@I+@@@@@@I+I+I+@@@@A%@@I+I+@@@@@@P%I+@@A%@@@@@@I+@@@@@@@@@@@@I+@@P%I+@@@@@@I+@@@@A%I+P%@@@@@@@@@@I+@@@@I+@@",
"A%@@@@P%@@@@@@A%A%@@@@@@@@@@@@@@@@@@@@I+@@@@@@@@A%@@@@@@@@@@A%@@@@@@@@@@@@A%@@A%@@#&< < < < < < < < < < < < < < < < < < < $&!%!%6%6%X$X$@@I+@@@@A%I+@@A%@@A%I+A%I+@@@@X$X$X$X$%&@@@@@@I+@@@@I+@@@@A%@@@@X$X$&&Q%R%R%R%[%X$X$Q%Q%Q%!%!%!%!%!%[%[%*&X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%=&X$!%!%X$X$I+I+@@@@@@I+@@@@I+@@@@@@@@P%@@@@@@@@I+A%I+@@I+A%@@A%@@I+@@@@@@@@A%I+@@@@@@@@A%A%I+A%P%@@@@I+@@@@A%@@@@A%I+I+@@@@A%I+A%@@I+@@I+@@@@A%@@@@A%:+I+@@@@@@@@A%A%A%@@@@:+I+I+@@@@@@@@A%@@@@@@",
"@@I+:+@@@@A%I+@@@@@@A%@@@@@@@@@@@@@@@@@@A%A%A%@@A%@@I+I+@@@@I+A%@@I+A%A%I+I+@@@@@@I+-&< < < < < < < < < < < < < < < < < < ;&!%!%6%6%6%X$X$@@@@@@@@@@@@A%@@@@@@P%@@8%<%X$6%6%X$X$h%>&@@A%@@@@A%A%@@I+A%@@X$,&6%R%!%R%[%X$X$6%Q%Q%R%R%!%!%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%'&X$@&!%)&X$X$@@@@@@A%@@@@A%@@@@@@A%:+@@I+I+I+@@@@P%I+A%@@@@@@@@@@@@A%A%A%@@@@I+@@@@@@@@I+@@I+@@A%A%P%@@@@@@@@A%@@P%@@I+A%@@@@I+A%A%@@P%A%I+@@@@A%P%@@@@A%A%@@@@@@@@@@I+@@A%A%@@@@I+A%@@@@@@@@I+@@",
"A%@@A%@@@@@@@@@@A%A%I+I+I+I+@@A%I+I+@@@@@@@@@@I+I+@@A%P%@@I+A%@@A%@@I+@@@@P%@@@@I+@@Z#< < < < < < < < < < < < < < < < < !&~&!%!%!%6%6%6%X$X$A%@@@@@@@@I+@@@@@@@@A%A%X$X$6%6%X$X$g%A%A%@@I+@@@@@@I+@@@@X$X${&6%R%!%!%[%X$X$Q%Q%!%R%R%R%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%]&X$@&@&X$X$A%A%@@@@A%I+@@@@@@A%@@A%I+A%A%@@@@@@@@@@@@@@@@@@A%A%@@@@@@I+@@@@P%A%@@@@@@@@@@@@I+@@@@@@@@@@@@A%@@@@@@@@@@@@I+@@@@@@@@@@@@@@@@I+@@I+@@@@@@@@@@A%@@@@I+@@@@A%@@@@@@@@P%I+A%I+@@A%A%@@",
"A%@@A%A%@@@@@@@@@@@@A%A%A%A%I+P%A%A%A%@@@@@@@@@@A%P%:+@@@@P%I+@@A%@@@@@@@@@@@@A%@@@@^&/&< < < < < < < < < < < < < < < < (&!%!%!%!%6%6%6%X$X$@@A%A%@@@@A%A%I+I+@@@@X$X$6%6%6%6%X$X$@@g%A%A%I+I+@@@@@@@@X$X$6%6%!%!%!%X$X$6%Q%R%R%R%R%R%!%!%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z%X$@&@&X$X$I+A%@@A%@@A%I+A%I+@@@@@@@@A%@@A%@@I+A%@@A%A%@@@@@@I+A%@@P%@@A%@@@@A%A%I+@@A%A%P%I+@@I+A%@@@@@@@@@@I+A%@@@@@@@@@@@@@@@@I+I+A%@@A%@@I+A%@@@@I+@@A%A%A%@@@@@@@@@@@@A%@@@@@@@@@@@@@@A%@@",
"@@@@@@@@@@A%A%@@I+@@P%@@@@@@@@@@@@@@@@@@A%A%A%@@@@@@A%A%A%@@@@I+P%@@I+A%I+A%A%@@A%A%@@_&:&< < < < < < < < < < < < < < <&|%!%!%!%!%6%!%6%6%X$X$@@@@A%@@:+A%@@P%@@X$X$X$6%6%6%6%X$X$X$[&@@@@P%P%@@A%@@A%X$}&6%6%!%!%!%X$X$6%Q%R%!%!%R%R%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%|&X$@&@&1&X$@@I+A%A%A%@@P%@@@@A%I+A%@@P%A%@@@@@@A%A%:+A%I+A%A%A%@@I+A%I+@@I+@@I+@@P%A%@@@@@@@@I+P%@@A%@@@@@@I+@@@@A%@@@@A%A%I+@@A%@@A%@@A%I+@@@@@@A%I+A%I+@@:+A%A%A%@@I+@@A%I+I+@@@@A%A%@@@@@@@@",
"@@@@@@A%@@@@A%P%A%@@@@A%@@A%I+@@@@@@A%@@@@@@A%@@@@@@@@@@I+A%P%@@@@A%@@P%@@I+@@@@@@@@@@@@2&3&< < < < < < < < < < < < 4&5&!%!%!%!%!%!%6%!%6%6%X$A%A%@@A%@@A%@@@@@@X$X$6%6%6%6%6%6%X$X$6&@@@@@@A%@@A%@@@@X$}&6%6%!%!%!%X$6%6%!%!%!%!%!%R%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&7&X$X$@@A%:+@@A%@@@@A%A%@@@@A%:+@@A%A%A%:+A%@@@@A%:+P%A%:+A%A%A%P%A%P%I+A%@@@@@@A%A%A%@@I+I+A%A%A%A%A%@@A%A%A%A%@@A%A%@@@@@@@@@@P%@@A%@@A%P%@@P%@@A%A%:+@@@@A%A%@@A%A%A%A%@@@@A%@@I+A%@@",
"A%A%I+A%A%@@@@@@A%I+@@@@A%@@P%@@A%A%@@A%@@@@P%@@@@A%@@@@A%@@@@@@@@P%@@@@@@P%A%@@A%A%A%@@@@5$D$C$< < < < < < < < 8&9&!%!%!%!%!%!%!%!%!%!%!%6%X$X$A%A%@@@@P%A%A%X$z%6%6%6%6%6%6%6%6%X$X$0&a&'%@@@@I+@@<%X$b&6%6%!%!%!%X$c&6%!%!%!%!%!%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&X$X$A%@@A%A%:+A%A%@@P%@@A%A%P%A%@@@@A%@@A%I+A%A%A%A%@@A%:+P%@@@@@@@@A%@@@@A%A%@@:+P%@@A%P%I+@@@@P%A%@@@@@@P%@@@@P%@@I+A%A%A%@@@@A%@@A%:+A%@@:+A%@@P%A%A%@@P%A%@@@@@@@@@@A%A%@@A%A%@@A%",
"@@A%@@@@A%@@A%@@A%A%A%A%@@A%@@@@@@A%@@A%@@@@A%A%@@A%A%P%@@@@A%A%@@A%A%I+A%@@A%A%@@A%@@A%A%A%@@d&e&f&g&h&i&j&4&k&l&!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$m&A%:+@@@@X$n&o&6%6%!%!%!%!%!%!%6%6%X$p&6&6&q&r&A%A%X$s&6%!%!%!%!%X$6%6%!%!%!%!%!%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&X$X$:+@@A%A%A%@@A%@@A%@@:+@@@@I+P%:+A%@@P%@@@@A%:+A%A%A%@@A%@@I+A%P%A%A%I+A%@@P%@@@@P%@@A%I+I+@@:+A%@@A%@@@@A%@@A%P%@@@@@@A%@@A%@@A%P%@@A%A%@@@@A%:+@@A%A%:+A%A%@@A%I+A%I+A%@@@@@@@@@@",
"A%P%@@A%@@A%@@@@P%P%A%@@A%@@A%A%@@@@@@@@A%@@@@@@A%@@@@@@A%A%I+@@I+A%@@P%@@A%@@A%I+P%A%@@@@@@A%I+@@A%X$t&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$p%A%A%@@X$u&v&6%!%!%!%!%!%!%!%6%6%X$X$X$j%@@@@w&,%X$b&6%!%!%!%!%X$6%6%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$A%A%@@@@:+A%A%A%A%A%A%A%A%A%@@A%@@A%A%A%A%A%A%:+P%@@A%@@A%P%@@@@@@A%P%@@A%@@A%A%@@@@@@A%P%@@A%@@A%@@A%A%@@@@@@A%P%A%A%A%A%@@A%@@A%@@@@A%I+I+@@A%A%@@@@A%@@A%A%A%P%@@P%@@A%A%A%@@A%",
"@@A%@@A%A%A%@@A%@@P%@@@@@@A%A%A%A%A%A%A%A%A%A%A%A%A%@@@@@@P%A%P%@@@@A%A%A%A%@@P%A%@@A%A%A%P%P%A%A%A%X$x&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%y&X$<%z&X$A&B&6%!%!%!%!%!%!%!%!%!%6%6%6%C&D&0%X$X$X$X$E&6%6%!%!%!%[%6%6%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$@@A%A%A%P%:+@@@@@@P%@@@@P%A%A%A%A%:+@@@@@@A%A%@@A%@@A%@@A%A%A%A%@@A%@@A%@@A%@@I+A%P%P%A%A%P%A%@@@@A%@@A%A%A%@@A%@@A%@@@@A%A%@@@@A%A%@@A%P%A%@@@@A%I+A%A%P%P%@@A%@@A%@@P%@@@@A%@@A%",
"@@@@A%A%@@A%A%@@@@A%@@A%A%@@P%@@@@@@A%@@A%A%@@@@@@@@A%A%A%A%@@A%A%@@@@@@@@@@@@A%@@@@P%@@@@@@@@@@@@F&X$G&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%x%X$X$p%X$H&6%!%!%!%!%!%!%!%!%!%!%!%6%6%6%I&J&6%K&L&X$C&6%6%!%!%!%!%6%6%!%!%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$@@P%@@@@A%A%A%@@A%@@@@A%@@P%@@@@A%A%A%@@P%@@A%P%A%@@A%@@@@@@@@A%@@A%@@A%@@A%P%@@@@@@@@@@@@A%A%A%@@A%@@@@A%@@@@A%@@A%@@P%P%A%@@@@@@A%P%@@@@A%A%@@P%@@@@@@A%@@@@A%@@A%@@A%A%@@A%P%",
"A%@@@@A%@@A%@@A%@@A%A%A%@@@@A%A%A%A%A%@@@@A%A%A%A%A%@@@@@@A%A%@@A%@@A%A%A%A%@@A%A%A%A%A%A%A%A%A%@@M&X$N&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$O&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$6%6%!%!%!%!%!%6%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$@@A%A%P%@@@@A%@@A%A%@@@@A%@@A%A%@@@@A%A%@@A%@@@@A%A%A%A%@@A%P%@@@@A%A%A%A%A%A%@@@@A%A%A%@@P%@@A%A%A%A%P%A%A%@@A%@@A%@@@@P%A%A%@@@@@@A%A%@@@@A%A%A%A%@@@@A%A%@@A%A%A%P%A%A%@@@@A%",
"A%A%A%@@A%A%A%@@A%A%P%@@A%A%A%A%A%@@P%A%A%@@@@A%P%@@A%A%A%P%@@A%A%A%@@P%P%@@A%@@@@@@@@P%@@A%A%P%A%P&X$Q&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$R&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$6%6%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X$A%P%@@@@A%A%P%A%@@A%A%A%@@@@P%P%A%A%P%@@A%@@A%A%P%@@@@A%A%@@@@A%A%@@@@A%@@@@A%A%A%A%A%A%A%@@A%P%P%@@@@@@@@@@A%A%A%P%A%A%@@A%A%A%A%A%A%@@A%A%P%A%P%A%A%A%P%A%A%@@P%A%@@@@P%A%A%@@",
"P%P%A%P%P%A%A%P%A%@@A%P%A%P%A%A%A%@@P%P%A%A%P%A%A%P%A%A%A%A%A%P%P%A%@@@@A%A%A%A%A%A%@@A%P%P%@@A%A%P%X$o&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$S&6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$T&6%!%!%!%!%!%!%X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%U&X$X$@&@&@&X$X$V&A%A%A%P%A%@@A%P%A%P%A%A%@@@@P%P%@@A%P%A%A%A%@@A%A%@@A%A%A%A%A%P%A%P%A%A%@@A%P%P%A%P%P%A%A%@@@@A%A%A%A%A%P%P%P%@@A%@@A%A%P%P%A%A%P%P%A%P%@@@@@@P%A%A%@@P%P%P%@@@@A%P%@@A%@@A%A%",
"A%A%P%@@@@P%P%@@P%A%A%A%@@A%@@P%P%A%A%A%P%P%@@@@P%A%P%P%@@P%P%@@A%P%A%A%P%P%P%P%P%P%A%A%@@@@A%P%P%@@X$o&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%0%R&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%W&6%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X&X$X$@&@&@&X$X$Y&A%P%P%@@@@A%P%A%P%@@A%P%A%A%@@A%A%P%@@P%P%@@A%P%P%A%P%A%A%A%P%A%A%@@P%A%A%P%A%A%P%@@A%A%P%A%A%P%P%A%P%A%A%@@@@A%A%A%A%P%@@A%P%P%A%A%P%@@A%A%A%@@A%P%A%@@A%A%A%P%A%A%A%P%A%P%A%",
"A%A%A%A%@@A%A%@@A%P%A%P%@@A%@@A%A%P%@@A%A%A%A%A%P%A%@@A%A%A%A%A%A%A%A%A%@@A%A%@@A%A%P%A%A%A%@@A%A%P%X$N&6%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%X$Z&`&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%!%!%!%!%!%!%X$ *[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%U&X$X$@&@&@&.*X$+*A%@@A%A%P%A%A%@@A%P%A%A%A%A%P%A%A%A%A%@@P%A%A%A%P%@@P%P%P%@@A%P%A%A%P%P%@@A%A%A%A%A%A%@@A%A%A%A%P%A%P%A%A%A%A%P%A%A%@@A%P%@@@@A%A%@@A%A%P%A%A%P%@@A%A%@@A%A%A%P%A%P%A%P%A%P%A%",
"P%A%P%P%P%P%P%A%P%A%P%A%A%P%A%P%P%@@P%P%P%P%P%P%@@A%A%P%P%P%A%P%P%P%P%A%A%@@A%A%P%P%A%A%A%P%A%A%P%A%X$Q&6%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$@*6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%#*X$$*[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&%*X$&*P%A%P%P%A%P%P%A%P%A%P%P%P%A%@@P%A%P%A%A%A%P%A%P%A%A%@@A%@@A%P%A%P%A%@@A%A%P%P%@@P%A%P%A%A%P%A%A%A%A%A%P%A%P%P%@@P%P%A%P%A%A%A%P%P%A%A%P%A%P%A%A%A%P%P%P%P%P%P%A%P%A%P%A%A%@@P%",
"P%A%A%A%@@A%P%A%P%@@P%P%A%P%A%@@P%A%A%A%A%A%@@A%P%P%A%A%@@P%A%A%A%A%P%P%P%P%P%@@A%A%P%P%A%P%P%A%@@P%X$o&6%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%*&[%**`&Q%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%=*!%[%!%!%!%!%!%-*X$;*r%X$X$X$X$X$X$X$[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&>*X$,*P%A%A%P%A%A%P%A%P%A%A%A%P%A%A%P%A%P%P%P%A%P%A%P%P%P%P%P%P%@@P%A%P%P%P%P%@@@@P%A%P%A%P%P%A%P%P%P%P%A%@@P%A%A%P%A%A%P%A%P%P%P%@@A%P%P%A%A%A%P%P%P%A%A%A%A%A%A%A%@@P%@@A%P%A%A%A%",
"A%P%P%P%A%P%A%P%A%A%A%A%P%A%P%P%A%P%P%P%P%P%P%P%A%A%P%P%P%A%P%P%P%P%A%A%A%A%A%A%P%P%A%A%P%A%A%P%P%A%X$'*6%!%!%[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$X$X$X$X$)*c&R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!*[%[%!%!%!%!%!%1%X$X$X$X$X$!%!%~*]&X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$@&@&@&X$X${*A%P%P%A%P%P%A%P%A%P%P%P%A%P%P%A%P%@@A%A%P%A%P%A%A%A%A%A%A%P%A%P%@@A%A%A%P%A%A%P%A%P%A%A%P%A%A%A%A%P%P%A%P%P%A%P%P%A%P%A%A%A%P%P%A%A%P%P%P%A%A%A%P%P%P%P%P%P%P%P%A%P%P%A%P%P%P%",
"A%A%]*P%A%P%A%P%P%P%]*A%P%A%]*A%A%@@A%A%A%A%A%P%P%]*A%A%P%A%A%A%A%P%P%P%P%P%P%A%A%P%P%A%P%P%A%A%P%P%X$^*6%!%[%[%[%[%[%[%[%[%[%X$X$!%!%!%X$X$X$!%X$/*(*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%_*[%[%[%!%!%!%!%;*X$X$X$!%!%!%!%!%:*!%<*X$X$X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$@&@&@&@&X$X$[*A%A%P%A%A%P%P%P%A%A%A%P%A%A%P%A%P%P%P%P%P%A%P%P%P%P%P%P%A%P%A%P%P%P%P%A%P%P%@@P%A%P%P%A%P%P%P%P%A%A%P%A%A%P%A%A%P%A%P%P%P%A%A%P%P%A%A%A%P%P%P%A%A%A%A%A%A%A%A%P%A%A%P%A%P%A%A%",
"P%P%A%A%]*A%P%A%A%A%A%P%A%P%A%P%]*]*P%P%]*P%P%A%]*A%A%P%]*P%P%P%P%A%A%A%A%A%]*P%P%A%A%P%A%A%P%P%A%A%X$}*6%[%[%[%[%[%X$/*|*;*r%!%!%!%X$X$X$!%!%!%X$1*2*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%3*[%[%[%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%4*W&5*X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6*@&@&@&X$X$Y&P%P%A%P%P%]*A%A%P%P%P%A%P%P%A%P%A%]*A%A%A%P%A%A%A%A%A%A%P%A%P%A%A%A%]*P%P%A%P%A%P%A%A%P%A%A%A%A%]*P%A%]*P%A%P%P%A%P%A%A%A%P%P%A%A%P%P%P%A%A%A%P%P%P%P%P%P%P%]*A%P%P%A%P%@@P%P%",
"A%A%]*A%P%A%P%P%P%P%A%P%A%A%A%A%A%A%A%A%A%A%P%A%A%P%A%A%A%A%A%A%P%]*P%P%]*A%A%A%P%]*A%P%P%A%A%P%P%]*X$6%:%[%[%[%X$7*|&8*9*0*!%!%!%!%X$!%!%!%!%a*X$b*c*Q%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%d*e*f*X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6*@&@&@&X$X$g*A%P%A%A%A%P%P%A%A%A%]*A%A%P%A%P%A%]*P%P%A%P%P%P%P%P%P%]*P%A%]*]*P%A%A%]*]*]*P%A%P%P%A%P%P%P%P%A%A%P%A%A%A%A%A%]*]*A%P%P%]*A%P%P%A%A%A%P%P%]*A%A%A%A%A%A%A%A%P%]*]*P%A%]*A%A%A%",
"P%P%A%P%A%P%A%]*]*A%P%]*P%P%]*A%P%P%P%P%]*]*A%A%P%]*]*A%P%P%]*P%]*A%]*P%A%A%P%P%A%A%]*A%A%P%]*P%A%A%X$X$:%[%X$X$;*E&h*!%!%!%!%!%X$X$!%!%!%!%!%4*X$Q%Q%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%i*r%j*X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%X$X$X$6*@&@&@&@&X$k*P%A%P%P%A%A%A%P%P%P%A%]*P%A%]*]*A%A%A%]*P%A%]*]*A%]*A%A%A%P%A%A%]*A%P%A%A%A%A%P%A%A%P%]*P%A%A%P%P%A%P%P%]*P%P%P%A%P%]*A%A%A%]*]*P%]*P%A%A%A%P%P%P%P%]*P%P%P%A%A%A%]*P%A%P%P%P%",
"P%P%A%]*A%P%A%A%P%]*A%A%P%A%P%A%A%]*A%A%A%P%P%P%A%A%P%A%A%A%A%A%P%A%A%P%P%P%]*P%P%A%]*P%]*A%]*A%P%]*X$X$:%[%X$l*!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%m*X$Q%Q%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%n*d*1%/*X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%X$X$6*6*@&@&@&X$X$o*]*]*P%P%P%P%]*A%]*P%A%]*P%A%A%P%P%P%A%A%P%A%A%P%A%]*P%P%A%P%A%A%P%]*A%P%P%P%P%]*P%]*A%A%P%]*]*]*]*A%]*A%]*A%A%A%A%A%]*A%]*A%A%A%A%A%P%P%P%P%]*]*]*A%A%P%A%P%A%A%A%P%P%]*P%]*P%",
"]*A%P%P%]*]*P%P%P%A%P%]*]*P%]*]*]*A%P%P%P%]*]*]*P%P%P%]*P%P%]*P%P%P%]*P%P%]*A%]*A%P%A%]*A%P%A%P%P%P%X$X$:%X$!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%/*p*Q%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%d*r*m*X$[%[%[%[%[%!%!%!%!%!%!%!%X$X$6*6*6*@&@&@&X$X$s*P%A%A%]*A%P%A%P%A%A%P%A%]*P%P%P%A%]*P%]*P%P%A%]*]*P%A%]*P%P%P%P%A%A%P%A%A%P%]*P%]*A%P%]*]*P%A%A%P%]*A%P%A%]*P%P%P%P%P%P%A%P%P%]*P%P%]*]*P%A%A%A%A%P%]*]*P%]*P%P%P%]*A%A%A%A%]*",
"]*]*A%P%A%A%]*]*P%P%A%A%P%A%P%P%P%]*]*P%A%A%A%A%P%A%P%P%P%P%A%]*A%P%P%]*A%P%P%]*P%P%A%P%P%P%]*A%A%P%X$X$X$X$!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%X$t*6%R%R%R%R%!%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%u*[%[%[%X$X$!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%v*7*X$[%[%[%[%!%!%!%!%!%X$X$X$6*6*6*@&@&@&X$X$,*]*]*A%]*]*P%]*P%]*P%P%P%P%A%]*]*A%A%P%]*A%]*A%A%P%]*A%P%A%]*P%]*P%]*]*]*A%A%P%P%P%A%A%A%A%P%P%A%P%P%P%P%P%P%]*]*A%A%]*P%P%A%P%P%]*A%A%]*]*P%P%P%]*P%A%]*A%]*]*]*A%]*P%]*P%A%P%",
"P%A%P%A%]*]*A%A%A%]*P%]*]*]*]*P%P%A%A%]*P%]*P%]*]*]*A%]*]*A%]*A%]*P%]*A%P%]*A%P%]*]*P%]*A%P%P%]*]*]*A%X$X$!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%X$w*6%R%R%R%R%!%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%x*y*[%[%[%X$X$!%!%**:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%z*A*B*X$[%[%[%!%!%!%!%X$X$X$C*6*6*6*@&@&@&X$X$]*A%P%]*P%A%]*P%P%P%]*]*A%A%]*A%P%P%]*]*A%]*P%]*P%]*P%P%]*]*P%A%P%]*A%P%P%]*P%]*A%P%]*]*P%]*P%]*P%P%P%]*P%]*]*P%P%]*]*A%P%]*]*]*]*A%P%]*A%P%]*]*]*A%P%P%A%P%P%A%A%P%P%]*P%]*P%]*",
"]*]*]*P%P%]*P%]*A%]*P%A%P%A%]*]*]*P%A%]*P%]*P%A%P%]*A%A%P%P%P%P%]*A%]*]*A%]*P%A%P%]*A%]*]*]*P%P%P%]*A%X$X$!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%X$D*6%R%R%R%R%R%!%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%E*F*G*[%[%[%X$[%!%!%0%H*[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%I*X$X$!%!%!%!%X$X$X$C*C*6*6*6*@&@&@&X$X$X$X$X$X$P%A%]*]*P%A%A%]*]*P%]*]*]*P%A%]*P%A%A%]*A%]*]*A%P%A%]*P%A%P%P%P%P%]*A%]*]*P%P%]*P%]*A%]*]*]*A%]*A%A%]*A%P%P%]*]*A%P%A%A%]*]*P%P%P%P%P%A%P%]*]*]*]*]*]*]*]*P%A%P%A%]*A%P%",
"P%P%P%]*]*P%]*P%P%P%]*]*P%P%A%A%P%]*]*P%]*A%]*P%]*P%]*]*]*]*]*]*A%P%P%A%P%P%]*]*]*P%P%P%A%A%]*]*A%P%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%J*X$w*6%R%R%R%Q%X$R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%x*[%G*[%[%[%K*X$!%!%!%X$L*:%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%!%R%!%!%!%!%!%X$X$X$X$X$X$X$M*C*C*6*6*6*@&@&@&X$X$X$X$X$X$X$N*A%A%]*]*]*P%P%P%P%A%A%]*P%A%]*]*]*A%]*A%A%]*P%]*P%]*P%]*]*]*]*P%]*P%A%]*]*A%]*A%]*P%A%A%]*A%]*P%A%P%]*A%P%P%P%]*]*P%P%P%]*]*]*]*]*P%]*A%P%P%P%A%P%P%P%]*]*]*P%P%]*]*",
"]*]*A%P%]*P%]*]*]*A%P%]*]*P%]*]*P%P%]*A%]*P%]*P%]*P%P%P%P%P%P%]*]*]*]*]*]*A%P%A%]*]*]*]*]*P%A%]*]*P%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$O*!%R%!%R%P*X$R%R%R%R%R%!%!%!%!%R%R%R%!%!%!%!%Q*[%[%[%[%R*X$X$!%!%!%X$S*:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%!%!%R%!%R%R%R%!%X$X$X$X$X$M*M*C*C*6*6*6*@&@&X$X${%X$X$!%X$X$X$T*A%P%P%]*P%]*P%]*]*P%]*]*A%P%P%]*P%]*]*P%]*P%]*A%]*P%A%A%A%]*P%]*]*P%P%]*A%]*P%]*]*]*P%]*P%]*]*]*A%]*]*]*]*A%P%]*A%]*A%A%A%A%A%]*P%]*]*]*]*]*]*]*]*A%P%A%]*]*P%A%P%",
"A%P%]*]*P%]*P%A%P%]*]*A%P%]*]*P%]*]*]*]*P%]*P%]*P%]*]*]*]*]*]*P%A%P%P%P%P%]*]*]*A%P%P%]*P%]*]*]*X$U*X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$V*!%!%!%:%X$R%R%R%R%R%R%!%!%!%R%R%R%!%!%!%!%y*[%[%[%[%W*X$X$!%!%!%!%X$X*:%[%!%!%!%!%!%!%!%R%R%R%!%!%!%!%!%!%!%R%R%R%R%!%!%R%R%R%R%X$X$M*M*M*C*C*6*6*@&@&@&X$X$Y*Z*x*`*!%X$X$X$X$X$]*P%]*P%]*P%P%]*]*P%]*]*]*P%]*P%P%]*A%]*P%]*P%]*]*]*]*P%]*P%P%]*]*P%]*P%]*A%P%P%]*P%]*P%P%P%]*]*P%P%P%]*]*P%]*A%]*]*]*]*]*P%]*P%A%A%A%P%P%P%A%]*]*]*]*]*]*]*]*",
"]*P%P%]*P%]*]*]*P%P%]*]*P%A%]*P%P%A%P%]*A%]*]*]*P%]*P%A%]*]*]*]*]*]*]*]*]*P%P%]*]*]*A%]*P%P%P%]*X$X$X$!%!%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!% =X$.=!%!%[%:%X$R%R%R%R%R%R%!%R%R%R%Q%Q%!%!%!%+=[%[%[%[%@=X$X$!%!%!%!%!%X$X$#=:%!%!%!%!%!%!%!%!%R%R%R%R%!%!%!%!%!%!%R%R%R%!%!%R%R%R%R%R%X$X$M*M*C*6*6*6*@&@&@&X$X$[%$=%=`*x*!%`*X$X$X$X$X$X$]*]*]*P%P%]*P%P%P%]*A%]*]*]*]*P%]*]*]*]*P%P%P%]*P%]*]*]*A%]*]*]*P%]*]*]*P%]*P%]*]*]*P%P%]*]*]*P%P%]*]*]*P%]*P%P%P%]*]*]*]*]*]*]*]*]*]*P%P%P%A%A%]*P%P%P%",
"]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*A%]*]*P%]*]*A%A%]*]*P%]*]*]*P%]*]*]*]*P%]*]*]*]*]*P%X$f*6%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%&=X$*=[%!%==X$R%R%R%R%R%R%R%R%R%R%R%Q%-=X$!%F*G*[%[%[%;=/*X$!%!%!%!%!%!%!%X$>=:%[%!%!%!%!%!%!%!%R%R%R%R%!%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%R%X$X$X$C*6*6*6*@&@&@&X$X$[%[%,=x*`*'=!%`*)=X$X$X$X$X$P%]*]*]*]*]*]*]*]*]*P%]*A%]*]*]*P%]*A%]*]*]*P%]*]*]*A%]*]*P%P%]*]*]*P%]*]*X$X$X$X$X$X$X$X$X$X$X$X$!=~=T*P%]*]*]*]*A%P%P%P%]*P%P%P%]*]*]*]*]*]*A%]*]*]*",
"]*]*]*P%P%]*P%]*]*P%P%]*P%P%]*P%]*]*]*]*]*]*P%]*]*]*]*]*]*P%]*]*P%P%P%]*]*]*P%A%]*]*]*]*P%]*]*]*X${=6%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*G*X$]=[%[%^=X$R%R%R%R%R%R%R%R%R%R%Q%Q%X$/=(=_=[%[%[%:=X$X$!%!%!%!%!%!%!%!%X$<=:%[%[%!%!%!%!%!%!%!%!%R%R%R%!%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%!%!%X$X$6*6*6*@&@&@&X$[%[%[%[%[%[=!%}=`*!%!%X$X$X$X$X$]*]*P%]*]*]*P%]*]*]*]*P%]*P%]*P%]*]*P%]*]*P%P%P%]*]*P%]*]*]*P%P%]*]*X$X$X$X$X$X$X$X$6%6%6%6%6%X$X$X$X$|=1=]*A%]*]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*P%",
"]*A%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*P%]*P%]*P%]*]*]*]*]*]*P%]*]*]*]*A%]*]*P%]*]*X$`&R%R%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*Q*[%X$2=[%:%X$Q%R%R%Q%R%R%R%R%R%R%R%Q%X$3=4=G*[%[%[%[%X$X$[%!%!%!%!%!%!%!%!%X$X$:%:%[%!%!%!%!%!%!%!%!%R%R%R%R%!%!%R%!%!%R%R%R%R%R%R%R%R%R%R%R%!%6*X$X$6*@&@&@&@&X$[%[%[%[%[%G*+=`*5=`*!%!%!%X$X$X$X$P%]*]*]*A%]*]*]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*P%X$X$X$X$X$X$!%!%!%!%!%!%!%!%6%6%6%X$X$6=X$X$X$7=8=]*]*]*]*]*]*]*P%P%P%]*P%]*P%]*P%]*P%]*",
"]*]*]*]*P%]*A%A%]*]*P%]*]*]*]*P%]*]*]*A%]*]*]*]*A%]*]*]*]*]*]*]*]*]*]*P%]*]*]*A%]*]*A%]*]*]*P%X$X$9=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%&=[%:%X$0=[%:%X$a=R%R%Q%!%R%R%R%R%R%Q%b=X$c=[%[%[%[%[%0%X$!%!%!%!%d=e=f=g=0%X$X$X$h=:%[%[%!%R%R%!%!%!%!%!%R%R%R%R%!%!%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%X$X$X$@&@&@&X$X$[%[%[%[%[%[%[%i=5=Z*!%!%!%!%!%X$X$X$X$X$]*]*P%]*]*P%]*P%]*]*]*]*]*]*A%]*]*]*]*j=k=l=m=X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%{&6%X$X$X$X$n=]*P%]*]*]*]*]*]*P%]*P%]*]*]*A%]*]*]*",
"]*P%]*]*]*]*]*]*]*]*]*]*]*]*]*]*A%]*]*]*]*]*]*]*]*]*P%o=]*]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*X$X$p=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%q=[%:%:%X$r=[%:%X$R%!%R%6%X$R%R%R%R%R%Q%s=X$[%[%[%[%[%X$X$!%!%!%t=u=X$X$X$X$X$X$X$0%v=:%:%[%[%R%R%R%!%R%!%R%!%R%R%R%R%R%!%R%R%R%R%R%R%R%R%R%R%R%!%R%!%!%X$X$X$@&@&X$X$[%[%[%[%[%[%[%G*+=[=`*!%!%!%!%!%!%X$X$X$X$X$X$X$w=x=y=o=y=y=y=]*P%]*o=z=A=B=C=D=X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6=X$X$X$X$E=]*]*P%P%]*]*]*]*]*]*]*]*]*]*]*]*P%",
"]*]*]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*]*P%]*]*]*]*o=]*]*]*]*]*]*o=]*]*]*]*]*X$0%Q%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%G*[%:%X$[%X$[%[%X$!%!%6%6%X$!%R%R%R%R%Q%F=X$[%[%[%[%X$X$!%!%G=H=X$X$X$X$X$u=I=X$X$X$X$J=:%:%[%!%R%R%R%!%R%R%R%!%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%K=L=!%!%!%!%!%!%!%!%`*5=X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$T*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*]*",
"]*]*]*]*]*]*o=]*]*]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*P%]*M=P%]*]*P%P%]*]*]*]*]*]*P%P%]*]*]*]*X$N=6%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%[%[%:%:%X$[%Z&O=:%X$!%!%6%6%X$!%R%R%!%6%6%X$[%[%[%[%X$X$X$!%P=Q=X$X$X$!%X$;*R=6=X$!%!%X$X$S=T=:%[%!%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%G*+=!%!%!%!%!%`*!%!%!%Z*`*!%!%!%X$D&6=f*/*X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$U=]*]*]*]*]*]*]*]*]*]*o=]*]*]*]*",
"]*]*]*]*o=P%]*]*]*]*]*]*]*]*o=]*]*]*]*]*]*]*]*]*]*]*]*]*]*o=]*]*o=]*o=P%]*]*]*]*]*]*]*]*]*o=]*X$V=R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%Q*[%[%:%:%X$[%Z&W=:%X$!%!%6%6%X$!%R%!%!%6%X=X$[%[%[%[%X$X$!%|%'&X$X$|%!%!%X$!%Z%X$!%Y=l&|%X$Z=`=:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%R%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%3*)=`*!%!%!%!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$X$T*]*]*]*]*]*]*]*]*]*]*]*]*]*]*",
"o=]*]*]*P%]*]*]*]*]*]*]*]*]*P%]*]*]*]*]*]*]*]*o=]*M=o=]*]*]*]*]*P%]*P%]*o=M=]*]*]*M=]*o=o=P%X$X$ -R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$[%X$.-:%X$!%!%6%6%X$!%R%!%6%6%X$[%[%[%[%X$X$!%!%+-@-X$X$5&!%!%!%!%!%!%!%!%!%!%!%X$#-$-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%R%R%R%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%5=Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$T*o=]*]*]*o=]*o=]*]*]*]*]*]*]*",
"]*M=]*]*]*o=P%o=]*M=M=o=]*M=]*M=o=]*]*]*o=]*P%]*]*P%]*]*]*]*]*M=]*]*]*]*P%o=]*M=]*]*P%P%]*]*X$X$%-R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%[%[%[%:%:%X$[%[%X$&-*-X$!%!%6%6%X$!%!%!%6%=---[%[%[%X$X$X$!%h*X$X$!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$ *;-:%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%'=`*`*!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$]*]*]*]*]*P%]*]*]*o=]*o=o=P%",
"o=]*]*M=]*]*o=]*]*o=P%P%]*]*M=]*]*o=]*M=]*M=M=]*]*M=]*]*]*]*]*P%o=]*M=]*o=P%]*]*]*]*M=M=]*]*X$>-R%R%R%R%R%R%R%!%!%!%R%!%!%!%!%[%[%[%:%:%X$X$X$X$X$,-'-X$!%!%6%6%X$!%!%!%)-!-~-[%X$X$X$X$!%!%]&X$!%!%X$!%!%!%!%!%!%X$X$X$X$X$!%!%!%X${-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%x*Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$M=]*]*]*M=]*]*]*P%o=P%P%o=",
"]*o=]*o=]*]*]*o=]*o=M=o=]*o=P%]*]*]*]*]*]*o=]*o=]*]*]*]*o=]*M=P%M=o=]*]*M=o=o=o=]*]*]*M=]*X$]-^-R%R%R%R%R%R%R%!%R%R%R%!%!%/-G*[%[%:%:%X$X$X$X$X$X$(-v&X$!%!%!%6%X$!%!%!%)-==_-[%X$n&D&!%l*:-X$X$!%!%!%!%!%!%X$X$X$X$X$[%X$X$X$X$X$X$<-[-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%[%}-5=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%@-X$X$X$]*M=]*]*]*]*]*]*]*M=]*]*",
"o=]*o=]*]*]*]*]*]*]*]*]*]*P%o=o=]*M=]*]*o=]*o=]*]*o=]*o=]*M=]*M=]*]*]*]*]*]*]*]*]*o=]*o=]*X$|-R%R%R%R%R%R%R%R%R%R%R%R%R%[%[%[%[%[%:%X$X$[%[%[%[%X$1-2-X$!%!%!%6%X$!%!%!%3-4-[%[%X$5-!%!%6-1%!%P=!%!%!%!%X$7-8-9-[%[%[%[%[%[%[%0-a-X$X$X$b-:%[%[%R%R%R%R%R%R%R%R%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%c-)=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%d-f*X$X$X$]*]*o=]*]*]*]*]*]*]*]*",
"]*]*]*]*]*o=]*]*]*o=]*]*M=]*]*]*o=o=o=P%]*]*]*]*]*o=]*]*o=]*]*o=]*]*]*o=]*]*]*o=]*]*]*o=]*X$Q%R%R%R%R%R%R%R%!%R%R%R%R%[%[%[%[%[%:%X$X$[%[%[%[%[%[%0%e-X$[%!%!%6%X$!%!%q=:%f-[%X$g-h-!%!%V*I=!%!%!%!%!%X$i-j-[%[%[%k-l-m-n-9-J*[%[%o-X$X$X$p-:%[%R%R%R%R%R%R%!%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%y*L=!%!%!%!%`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%R&<*q-X$]*]*o=o=M=]*o=o=]*o=]*",
"]*]*]*o=M=]*]*o=M=]*]*o=o=]*]*M=]*P%]*M=]*]*]*]*]*]*]*]*]*]*]*]*]*M=o=P%o=o=o=]*]*]*]*]*X$X$R%R%!%R%R%R%R%R%!%R%R% =[%[%[%[%[%:%:%X$X$[%X$X$X$X$[%[%X$X$X$!%!%6%X$!%!%r-:%X$[%)%P=!%!%!%X$X$!%!%!%!%X$s-t-t-u-X$[-v-w-x-[-X$X$B*y-z-j-A-X$X$B-:%[%R%R%!%R%R%R%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%[%3*C-`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%{&D-E-X$X$X$]*]*o=o=]*P%o=]*M=",
"o=o=]*o=o=o=]*o=]*o=]*]*o=M=o=]*o=]*]*o=o=o=o=M=]*M=o=]*o=o=]*o=o=]*o=]*P%]*]*]*o=o=]*M=X$F-R%R%!%R%R%R%R%!%R%R%G-H-[%[%[%[%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$[%!%6%X$!%!%:%:%X$[%I-!%!%!%X$X$!%!%!%!%X$I&o-J-r%X$X$X$X$X$X$X$X$X$X$X$X$K-n-L-/*X$M-:%[%[%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%N-X$O-[%[%[%[%[%[%[%[%[%[%[%P-Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%Q-R-S-X$M=]*]*]*M=]*]*o=]*",
"]*]*]*]*]*P%o=]*]*]*]*]*P%o=]*]*]*M=o=]*]*]*]*o=M=o=]*M=]*]*o=]*]*]*]*]*M=]*o=o=]*]*]*X$X$T-R%!%R%R%R%R%R%R%R%U-c-[%[%[%[%:%:%X$X$X$X$[%[%[%[%[%[%X$X$X$X$[%[%6%6%X$!%:%:%[%V-t=!%!%!%X$X$R=!%!%X$5*n-n-W-X$X$X-Y-Y-X-X-X-Z-Z-X-`- ;X$.;[%+;@;X$#;:%:%!%R%R%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%$;X$X$[%[%[%[%[%[%[%[%[%[%[%%;Z*Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Q&&;[-X$X$]*]*o=]*]*o=]*o=",
"]*o=]*]*M=]*o=o=M=o=o=o=]*M=o=o=o=]*M=]*o=]*]*o=]*M=o=o=M=]*M=]*o=]*M=]*M=]*]*o=]*o=]*X$[-%-R%!%R%R%R%!%R%R%R%3=[%[%[%[%:%X$X$X$X$[%[%X$X$X$[%[%[%X$X$X$X$[%[%6%6%X$!%:%:%X$*;!%!%!%X$X$!%!%!%!%f*=;o--;X$;;X-X-Y-X-X-X->;,;';';,;,;,;X$);*&!;v=~;:%:%:%!%!%R%R%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%{;C&X$[%[%[%[%[%[%[%[%[%[%[%];)=[=!%!%!%!%!%X$^;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%/;(;X$X$o=]*o=o=]*o=]*]*",
"o=M=o=o=o=o=]*]*o=]*M=]*o=o=]*]*]*o=o=o=]*o=]*]*o=o=]*]*o=o=o=o=]*o=o=o=o=o=o=]*o=]*o=X$&;R%!%!%!%R%R%!%R%R%G-[%[%[%[%:%X$X$X$X$X$X$X$X$X$X$X$X$X$[%X$X$X$X$[%:%6%X$[%:%:%X$d=!%!%!%X$!%!%!%!%!%_;|%U&]-;;;;Z-Z-Y->;>;>;:;:;<;<;[;[;<;:;X$g-};|;X$1;2;:%:%:%!%R%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%6%b=3;X$[%[%[%[%[%[%[%[%[%[%[%4;`*5;!%!%!%!%X$X$6;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%`&7;X$X$X$o=]*]*o=]*M=o=",
"o=]*M=]*]*o=o=]*o=o=o=]*]*M=o=o=]*]*M=o=M=o=o=]*]*o=]*]*]*]*M=o=]*]*M=]*]*]*o=M=o=]*]*X$8;R%!%!%!%!%!%!%!%5=9;[%[%[%:%X$X$X$[%X$X$X$X$X$;;Z-Z-Z-X$X$X$X$X$X$:%[%:%X$[%:%:%X$0;!%!%!%!%!%!%!%!%R=!%a;X$X$;;Z-Z-Z-b;>;>;c;d;d;R%R%R%e;f;g;,;X$h;n-9-[%C&B-:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%6%i;X$j;[%[%[%[%[%[%[%[%[%[%(=`*`*!%!%!%!%X$k;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%R&l;X$X$o=o=]*o=o=]*M=",
"]*o=o=o=o=]*M=o=M=]*M=o=o=o=]*]*o=o=o=]*o=M=]*o=o=]*o=o=o=o=o=M=o=o=o=o=o=o=]*o=]*o=o=X$m;!%!%!%!%!%!%!%!%q=[%[%[%:%:%X$X$[%[%X$X$;;;;;;Z-Z-Z-Z-X$X$X$[%[%X$:%:%:%X$[%:%:%X$n;!%!%!%!%!%!%!%!%!%n;o;X$;;;;Z-Z-Z-b;b;p;p;e;R%R%R%R%R%q;e;g;>;X$r;o-9-6%s;[%:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%6%t;X$u;[%[%[%[%[%[%[%[%[%[%4;Z*L=!%!%!%X$X$Z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%`&7;X$X$M=]*o=]*]*o=o=",
"M=]*o=]*o=o=M=o=o=o=M=]*M=o=o=M=]*]*o=]*o=o=]*]*o=M=]*M=M=]*o=M=o=]*M=M=]*o=]*o=M=]*o=X$!%!%!%!%!%!%!%!%Z*3*[%[%:%:%X$X$!%[%X$X$X$;;;;;;Z-Z-Z-Z-Z-X$X$X$v;X$X$X$:%X$[%:%:%X$w;!%!%!%!%!%!%!%!%h-[-;;;;;;;;Z-Z-Z-b;b;p;p;q;R%R%R%R%R%x;q;[;>;X$X$y;J-!%6%z;a-:%:%:%!%!%!%!%!%!%!%!%!%!%!%!%R%!%R%X$!%!%!%!%6%b= *[%[%[%[%[%[%[%[%[%[%[%];F*L=!%!%!%X$A;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%B;R-X$X$]*o=o=]*]*M=",
"o=o=]*o=M=]*o=]*M=]*o=o=o=M=]*o=o=o=M=o=]*]*o=o=M=o=o=o=o=o=]*o=]*o=o=o=o=o=o=M=o=o=M=X$!%!%!%!%!%!%!%!%c-[%[%[%:%:%X$X$!%:%X$X$;;;;;;;;Z-Z-p;p;p;';X$X$v;v;X$X$:%X$[%:%:%X$C;!%!%!%!%!%!%!%_;|&X$;;;;;;;;Z-Z-Z-b;b;p;p;D;R%R%R%R%R%E;q;[;b;Z-X$X$F;!%6%X$K*G;H;:%:%!%!%!%!%!%!%!%!%!%!%!%R%!%R%X$R%!%!%6%!%Q%I;[-[%[%[%[%[%[%[%[%[%[%C-L=E*!%!%X$J;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%^*X$X$o=M=o=o=o=o=",
"M=o=M=o=o=]*o=o=o=]*M=]*o=o=]*M=M=o=M=o=o=M=M=o=]*M=]*]*M=o=]*o=]*]*M=M=]*M=o=]*M=o=X$O&!%!%!%!%!%!%!%!%G*[%[%:%:%X$!%!%!%:%X$X$;;;;;;;;Z-p;g;[;R%R%f;X$X$v;X$X$:%:%X$:%:%X$V%!%!%!%!%!%!%!%0;X$;;;;;;;;;;Z-Z-K;L;M;N;N;O;R%R%R%R%R%P;q;[;Z-Z-Q;X$R;[%6%6%X$X$S;[%:%:%6%!%6%!%!%!%!%!%!%!%R%R%R%X$R%R%!%Q%!%Q%X$X$[%[%[%[%[%[%[%[%[%G*x*C-L=!%X$'&t=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%`&X$X$o=]*M=M=]*M=",
"o=M=o=]*M=o=M=]*M=o=M=o=M=M=o=o=o=]*o=M=M=o=o=o=o=o=o=o=o=M=o=M=o=o=o=o=o=o=M=o=o=]*X$T;!%!%!%!%!%!%!%q*[%[%:%:%X$X$!%!%!%:%X$;;U;V;W;X;Y;Z;`; >R%R%R%f;X$v;v;X$X$:%X$:%[%X$Y=!%!%!%!%!%!%!%V-X$;;;;;;;;;;.>+>@>#>$>R%R%%>%>R%R%R%P;&>*>=>Z-Z-Q;X$X$[%!%6%6%X$X$[%[%:%:%6%!%6%!%!%!%!%!%!%R%R%R%X$R%R%R%Q%Q%Q%X$X$[%[%[%[%[%[%[%[%[%r-%;C-E*`*0%->!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%R&1&X$M=o=o=o=o=o=",
"o=]*o=o=M=o=o=o=M=o=o=o=o=M=]*]*o=M=o=o=]*M=M=o=o=M=o=o=o=o=o=o=o=]*o=M=o=o=M=M=o=]*X$;>!%!%!%!%X$!%!%$=[%[%:%:%X$X$!%!%!%:%X$>>,>R%R%R%'>=>)>!>R%R%R%f;X$X$v;[%X$:%:%X$:%X$w;!%!%!%!%!%!%!%X$X$;;;;~>{>]>^>@>/>(>(>R%R%*>%>%>&>&>&>*>_>=>'>:>;;<>X$X$[%!%!%6%6%X$X$X$[%:%:%6%6%!%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%X$X$[%[%[%[%[%[%[%[%[%$= =x*x*X$[>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%N&X$X$o=o=o=o=o=o=",
"o=o=o=o=o=o=o=o=o=o=M=o=M=o=o=o=o=o=o=o=o=o=o=M=M=o=M=M=o=M=M=o=M=o=M=o=M=o=o=o=o=o=X$6%!%!%!%!%X$!%!%G*[%[%:%X$o=M=!%!%!%6%X$X$,>R%R%R%'>(>)>)>)>R%}>f;f;X$|>[%X$X$:%X$:%X$Y=!%!%!%!%!%!%X$X$;;1>2>3>4>5>6>'>'>'>R%R%R%)>)>)>*>*>)>7>=>(>'>'>R%8>X$X$!%!%!%!%6%6%6%X$X$:%:%:%6%!%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%9>X$[%[%[%[%[%[%[%[%[%c-i=C-`*X$i*|%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Q&X$X$M=M=M=o=]*M=",
"o=o=M=M=M=M=M=o=M=o=o=o=o=o=o=o=o=o=M=o=M=o=0>o=o=o=o=M=o=o=M=o=o=o=o=o=M=o=o=o=o=o=X$6%!%!%!%!%X$!%F*[%[%:%:%X$0>o=!%!%!%6%X$X$R%R%R%R%'>'>_>R%)>)>)>[;[;X$X$[%!%X$X$X$:%{%5&!%!%!%!%!%!%X$X$a>b>c>6>R%R%R%'>'>'>R%R%R%7>7>R%R%_>7>=>=>'>'>'>R%R%X$X$!%!%!%!%!%!%6%6%6%X$X$X$X$X$!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%d>X$[%[%[%[%[%[%[%[%[%e>i=G*X$X$w;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$f>s;X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%[-X$o=o=M=0>o=o=",
"0>0>o=o=o=0>o=o=o=0>M=o=M=o=o=M=M=M=o=0>o=o=o=o=0>o=o=o=o=o=o=o=0>o=o=o=o=M=o=M=0>o=X$Q%R%!%!%X$!%!%g>[%:%:%X$o=o=o=!%!%!%6%X$X$R%R%R%R%R%'>R%R%_>)>)>)>g;X$X$!%!%!%X$X$X$ *!%!%!%!%!%!%!%X$h>i>R%R%R%R%R%R%'>'>'>'>'>=>=>=>R%R%=>(>(>'>'>'>R%R%R%X$X$!%!%!%!%!%!%!%6%X$X$X$X$X$6%!%!%!%!%R%R%R%R%X$R%R%Q%Q%Q%u-X$[%[%[%[%[%[%[%[%[%e>i=[%X$5*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$O-[%j>k>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%l>X$o=M=o=o=o=M=",
"]*o=0>o=o=o=M=0>o=o=0>o=M=0>0>o=o=0>M=o=M=o=o=M=o=M=o=o=o=o=o=M=o=M=o=o=0>M=o=M=M=o=X$Q%R%R%!%X$!%!%Q*[%[%m>X$o=o=M=!%!%!%!%:%X$R%R%R%R%R%'>'>(>(>_>R%7>7>X$X$!%!%!%X$X$X$X$|%!%!%!%!%!%!%X$R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>'>'>'>'>R%R%R%X$X$!%!%!%!%!%!%!%X$X$X$!%X$X$!%6%!%!%!%!%R%R%R%X$R%R%Q%Q%Q%[%X$[%[%[%[%[%[%[%[%[%c-q*g>X$n>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%L-l-o>l>X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%p>X$q>o=o=o=o=o=",
"0>o=o=M=o=o=o=o=M=o=M=o=0>M=o=0>o=o=o=M=o=M=M=o=0>0>o=0>o=0>0>o=M=0>o=o=o=o=0>o=o=0>X$Q%R%R%R%X$!%!%[%[%:%v=X$M=M=o=o=!%!%!%6%X$X$R%R%R%R%R%'>'>'>'>'>(>(>X$X$!%!%!%!%X$X$X$r>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>'>R%R%R%R%R%X$X$!%!%!%!%!%!%X$X$!%!%X$X$!%R%R%Q%!%R%R%R%R%R%X$Q%Q%Q%Q%6%s>X$[%[%[%[%[%[%[%[%[%y*4;X$X$t>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%u>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%<*X$v>o=M=M=0>M=",
"0>M=0>M=0>0>o=o=0>o=o=o=o=o=o=o=o=o=0>o=o=0>o=M=o=o=o=0>o=M=o=o=o=M=0>o=0>o=o=0>o=o=X$Q%R%R%R%X$!%!%[%[%B-X$o=0>X$X$o=!%!%!%6%X$X$R%R%R%R%R%R%'>'>'>'>(>(>X$X$!%!%!%!%!%X$X$w>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>'>'>'>'>'>'>R%R%R%R%X$X$X$!%!%!%!%!%!%X$X$!%X$X$X$X$X$X$Q%!%R%R%R%R%!%X$Q%6%6%6%Q%[%X$[%[%[%[%[%[%[%[%[%[%[%X$X$Z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$X$[%[%[%[%[%[%[%x>X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%Z&X$y>o=o=o=0>o=",
"M=o=o=o=o=o=o=o=M=o=0>o=o=o=o=0>o=o=o=o=0>o=o=o=o=M=o=M=o=o=o=0>o=0>o=o=o=o=o=o=o=0>X$Q%R%R%R%X$!%!%[%[%z>X$0>X$X$X$X$X$!%!%6%6%X$X$R%R%R%R%R%R%R%R%'>'>(>X$X$!%!%!%!%!%!%!%A>!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%'>'>'>'>'>B>R%R%R%R%R%X$X$X$X$!%!%!%!%!%!%X$!%!%X$!%6%X$X$X$R%Q%R%R%R%!%!%X$Q%6%6%6%:%s-X$[%[%[%[%[%[%[%[%X$[%y*X$I=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%C;C>X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6=X$D>o=0>o=o=M=",
"0>o=0>o=o=o=0>o=o=o=o=0>0>o=o=o=0>o=0>o=o=0>o=o=0>M=o=o=o=0>o=o=o=o=o=o=0>0>o=0>o=o=X$E>R%R%R%X$R%R%[%[%F>X$o=0>X$X$X$X$X$!%!%6%6%X$R%R%R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%G>R%R%R%R%R%R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$[%R%Q%X$R%R%6%6%X$Q%6%6%6%:%H>X$[%[%[%[%[%[%[%[%X$X$ =X$I>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%0;X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$y>o=o=o=0>o=",
"o=0>o=o=0>0>o=o=0>o=0>M=M=0>o=0>o=o=o=o=0>o=0>0>o=0>o=0>0>o=o=0>o=0>0>0>M=o=o=o=o=o=X$D*R%R%R%X$R%!%[%J>X$K>0>o=0>D>X$X$!%!%!%!%6%X$X$R%R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$:%:%Q%X$Q%Q%6%6%X$Q%Q%6%Q%:%L>X$[%[%[%[%[%[%[%[%X$X$X$X$6-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%->M>X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=M=0>0>o=0>",
"o=0>0>o=o=o=o=o=0>o=o=o=o=0>M=o=0>0>0>o=0>o=o=0>o=0>M=M=0>0>o=0>o=o=o=o=0>0>o=0>0>0>X$C&!%!%R%X$R%!%[%u;X$o=0>X$X$X$X$X$!%!%!%!%!%6%X$X$R%R%R%R%R%R%R%R%R%R%X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%v=X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%6%Q%X$Q%6%6%X$Q%Q%Q%6%:% *[%[%[%[%[%[%[%[%[%X$X$X$X$=;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$0>o=o=0>M=0>",
"o=o=M=o=0>0>0>0>o=o=0>0>0>o=0>0>o=M=o=o=o=o=o=o=0>o=0>0>M=o=0>o=o=0>o=0>o=o=0>o=o=o=X$X$|%!%!%X$!%!%[%N>X$0>X$X$!%!%!%X$!%!%!%!%!%!%6%!%R%R%R%R%R%R%R%R%R%Q%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%8>R%X$X$!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%X$X$X$!%X$:%R%Q%X$Q%6%6%X$Q%Q%6%6%:%X$[%[%[%[%[%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*O>X$X$[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=0>0>o=P>M=",
"0>0>0>M=o=o=o=0>0>o=o=M=0>o=o=0>0>0>0>o=0>0>0>o=P>o=o=0>0>o=0>0>o=0>o=0>0>o=0>0>0>0>o=X$P=!%!%X$!%!%[%Q>X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%R%R%R%R%R%X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%R%X$X$!%!%!%!%!%!%!%!%b&'&R>7*X$!%!%!%!%X$X$D&-*X$X$X$[%Q%X$R%6%6%X$6%6%6%6%S>X$[%[%[%[%[%[%[%[%X$X$X$X$[-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=o=o=o=0>o=",
"o=o=M=P>0>0>0>o=o=P>0>0>o=0>0>o=o=o=0>0>0>o=o=o=o=o=o=0>o=0>o=o=0>o=0>o=0>0>o=o=o=o=0>X$K&!%!%X$!%!%[%T>X$X$[%[%[%[%[%!%!%!%X$!%!%!%!%!%!%!%!%R%R%R%R%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%R%R%R%R%R%R%R%R%R%%-U>X$X$X$X$V>!%!%!%!%!%!%!%!%!%!%!%9*W>X$!%!%!%!%!%X>0-!%Y>X$X$:%6%6%X$6%6%X$6%6%6%6%Z>X$[%[%[%[%[%[%[%[%X$u=`>X$7*!%|%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6% ,X$0>0>0>0>o=0>",
"0>0>o=o=0>o=0>0>o=o=o=0>0>o=0>P>0>o=o=o=0>0>P>0>0>0>o=0>0>0>0>o=0>P>o=o=0>0>0>0>0>0>0>.,0%!%!%X$!%r-[%:%X$X$X$X$X$!%[%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%+,6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%!%!%!%!%!%!%!%@,#,$,%,&,*,V>V>=,!%!%!%!%!%!%!%!%!%!%!%!%!%!%f>X$X$[%!%!%!%X$!%[%r;-,;,X$X$[%6%6%X$6%6%6%X$6%6%:%>,X$[%[%[%[%[%[%[%[%X$,,!%X$z%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6% ,X$o=o=o=0>0>0>",
"o=o=0>0>o=0>o=o=0>0>P>o=o=0>o=o=o=o=P>P>o=o=o=o=o=P>0>0>o=o=0>0>o=o=0>0>o=o=o=0>0>o=0>.,.,',!%**X$r-[%:%X$X$X$X$X$[%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%X$),6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%R%!%!%R%R%!%R%R%!%!%!%!%!%!%r%X$X$!%!%!%0%X$!%n&!,~,H=[%[%:%6%X$6%6%6%X$6%6%:%Y>X$[%[%[%[%[%[%[%X$7-V%!%!%u=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%4;X$X$[%[%[%[%[%3*c-!%!%!%3*[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$0>P>0>o=o=o=",
"P>o=0>P>o=0>0>o=o=o=0>0>o=0>0>0>P>o=o=P>0>0>0>0>o=o=o=0>0>o=o=0>0>0>o=0>0>0>o=o=0>o=o=0>{,G&[%[%X$y*[%:%],],],],],],],],],],],X$!%!%!%!%!%!%!%!%!%@-^,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%],],],],],],],],],],],],!%!%!%!%!%X$X$!%!%!%!%X$X$!%/,(,>-[%[%:%6%X$6%6%6%X$6%:%_,X$[%[%[%[%[%[%[%[%X$:,5&!%!%<,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$[%[%[%[%G*!%!%!%!%!%!%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[,X$X$o=0>P>P>0>0>",
"o=0>o=o=P>0>o=0>P>0>P>o=P>0>0>o=o=0>0>o=0>o=o=P>0>P>P>0>o=P>0>P>0>o=0>o=0>0>0>0>o=0>P>o=},[-|,[%0%],],],X$o=0>X$[%[%X$!%!%!%X$],],],!%!%!%!%!%!%!%D-1,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%!%!%!%R%],],],],],],R%R%R%R%R%R%!%!%!%!%!%R%],],],B*!%X$[%!%!%!%!%!%X$!%2,3,I=X$[%[%:%X$:%6%X$6%6%:%[%X$[%[%[%[%[%[%[%[%X$4,!%!%!%d*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%5,X$X$[%[%[%[%6,!%!%!%!%!%!%!%!%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%m;X$X$0>o=o=o=o=o=",
"0>P>0>o=o=P>P>o=o=o=P>o=0>o=P>0>0>o=0>o=P>0>o=o=o=o=o=P>o=o=o=o=P>P>P>0>o=P>0>P>o=o=o=o={,X$d-],],Y*[%:%X$0>P>X$[%X$X$[%!%!%X$X$X$!%],],!%!%!%X$V*7,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%!%],],],!%R%R%R%R%R%R%!%R%R%!%R%!%!%!%!%!%!%R%!%!%],],],[%!%!%!%!%J*X$X$H=m-8,X$[%[%:%X$:%6%X$6%:%:%Y>X$[%[%[%[%[%[%[%[%0%Y=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%$=!%!%!%!%!%!%!%!%!%!%n>X$0%a*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%9,X$X$P>0>0>0>P>0>",
"0>o=0>0>P>o=o=0>P>0>o=0>P>P>o=P>o=0>0>P>o=P>0>0>0>0>P>o=0>P>0>P>o=o=o=o=P>o=P>o=P>0>P>0>0>],],#=q=X$[%:%X$o=o=X$X$X$X$[%!%!%!%!%X$X$!%!%],!%X$X$v&6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%!%],],!%!%!%!%!%!%R%R%!%R%!%!%R%!%!%!%!%!%!%!%!%!%!%X$!%X$X$],],],X$!%!%X$X$.;9-V*X$X$[%:%X$:%6%X$6%:%0,X$X$[%[%[%[%[%[%[%[%I*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%G*`*!%!%!%!%!%!%!%!%!%!%a,X$b,c,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%B;X$X$o=0>0>P>o=o=",
"0>o=0>0>0>0>P>o=P>0>0>o=o=0>o=P>P>o=o=0>o=P>o=P>0>o=0>0>o=P>o=P>0>0>P>o=0>o=P>o=0>o=P>0>],o=X$#;d,e,[%:%f,P>P>X$X$X$X$[%!%!%!%!%X$X$!%!%!%],],g,6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%!%!%!%!%!%],!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%X$[%!%!%X$],],],X$X$[%h,0%X$X$[%[%:%X$6%X$[%:%W*X$[%[%[%[%[%[%[%[%X$A-l&!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%P=X$i,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%D*X$X$o=o=o=0>P>0>",
"P>P>P>o=P>P>o=0>o=P>P>j,0>P>j,o=0>P>j,0>0>o=P>o=o=0>P>P>0>0>0>o=0>P>0>0>0>0>0>0>o=j,0>],P>P>},k,l,m,[%:%n,X$o=],],],],],],],],],],],],!%],X$(-6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%],!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$[%!%!%X$X$!%X$],],],[%X$X$X$[%[%:%X$6%X$[%[%n&X$[%[%[%[%[%[%[%[%X$s;$;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%o,!%!%!%!%!%!%!%!%!%!%!%!%6-X$g=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%p,X$P>P>P>P>P>0>0>",
"0>0>P>o=o=j,0>0>o=o=P>o=0>o=j,0>0>P>P>0>j,0>P>P>P>o=o=0>0>P>0>P>o=0>P>P>o=0>P>P>P>o=],0>0>0>j,X$q,9-[%:%r,],],P>o=P>X$[%[%!%!%!%!%!%!%],],X$s,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$[%X$X$[%!%!%6%X$X$X$X$X$[%[%],],X$X$[%[%:%X$:%X$[%[%X$X$[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%U&t,X$l*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%u,X$X$0>0>0>o=0>P>0>",
"0>0>0>j,0>P>P>P>P>0>o=P>P>P>o=P>0>o=o=P>o=P>0>0>0>j,j,P>o=o=P>0>0>P>o=o=P>P>0>o=0>],0>0>o=0>P>0>O*[%v,],],X$P>0>0>0>X$X$[%[%],],],],],],],O*6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%>*X$X$X$X$!%!%!%!%!%!%!%X$X$[%!%!%!%!%6%X$X$X$[%[%[%[%[%X$],X$[%[%X$:%:%X$[%X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%U&/*X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%w,X$X$P>0>0>P>o=0>0>",
"P>o=P>P>o=o=0>0>P>P>0>o=0>P>0>o=P>P>0>P>0>0>P>o=P>P>o=P>j,0>0>P>o=P>P>0>0>o=P>P>o=P>o=P>P>o=o=P>X$x,],0%y,X$P>P>o=P>P>],],],!%!%!%!%!%X$X$k,6%!%!%!%[%X$X$z,!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%],],],],],],],],!%@-X$X$X$X$6%6%!%!%!%!%!%!%[%X$X$!%!%!%!%!%A,B,X$X$[%[%[%[%[%[%X$[%],],[%X$:%X$[%[%X$X$[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%C,X$X$P>o=P>P>P>o=0>",
"0>P>o=0>P>P>0>P>0>0>o=P>P>o=P>P>0>o=P>o=P>o=P>P>0>o=P>P>P>o=P>0>P>o=P>o=P>P>P>0>P>o=P>P>0>P>P>0>],],:%@;:%R*o=0>P>],],X$X$[%[%!%!%!%!%!%X$6%6%!%!%!%[%[%X$X$!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%],],!%!%!%!%!% ,X$],],],X$6%6%6%!%!%!%!%!%!%[%X$!%!%!%!%!%6%6%D,7*X$[%[%[%[%[%X$X$X$[%[%X$],X$:%X$[%X$X$[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$o=o=P>0>o=0>P>P>",
"0>P>P>0>0>P>o=P>P>P>P>o=P>0>0>P>P>0>P>P>P>o=o=P>P>0>o=o=P>P>o=P>P>0>P>P>o=0>P>0>P>0>o=o=0>0>P>],0>X$:%E,F,G,P>0>],P>o=0>X$[%[%!%!%!%!%!%X$H,6%!%!%!%!%[%[%X$X$X$!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%D&X$X$6%],],6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%(;X$X$[%[%[%[%[%X$X$[%[%[%X$[%],[%X$[%X$[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%I,X$X$P>0>P>P>P>o=0>0>",
"P>0>0>P>P>0>P>0>0>0>0>P>0>P>0>0>0>P>0>0>0>P>P>0>0>P>P>P>0>0>P>0>0>P>0>0>P>P>0>P>0>P>P>P>P>P>0>0>P>X$X$*=[%X$],],0>0>P>P>X$X$[%[%[%!%!%!%X$J,6%!%!%!%!%!%!%[%[%X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%K,X$6%6%6%!%],],!%!%!%!%!%!%!%!%!%!%!%!%6%6%-*X$X$[%[%[%[%[%[%X$X$[%[%[%X$[%X$],],X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$L,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%.-v=X$X$0>P>0>o=0>P>P>P>",
"P>P>0>0>P>0>P>P>P>P>0>P>0>P>P>P>o=P>0>P>0>0>P>P>o=0>0>P>P>0>0>P>0>P>o=P>0>P>o=P>o=j,0>0>0>P>P>0>0>P>X$X$X$],X$P>o=0>0>0>P>X$X$[%[%[%[%!%[%z;;>6%!%!%!%!%!%!%[%[%X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6=X$6%6%!%!%!%!%],],!%!%!%!%!%!%!%!%!%6%6%8*X$X$X$[%[%[%[%[%X$X$[%[%[%[%X$[%X$X$:%],],[%[%[%[%[%[%[%[%[%[%[%X$X$6;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%M,X$X$P>0>P>P>P>0>0>0>P>",
"0>0>P>o=P>P>0>o=P>o=P>P>P>P>o=P>P>P>P>0>P>P>P>0>P>P>P>P>0>P>P>0>P>0>P>0>P>0>P>0>P>P>P>P>P>0>o=P>P>0>P>X$],X$X$P>P>P>P>P>0>P>X$X$[%[%[%[%[%X$B,6%!%!%!%!%!%!%!%[%X$:%:%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%{=X$X$6%!%!%!%!%!%!%!%],],!%!%!%!%!%6%6%!%[>X$X$[%[%[%[%[%[%[%X$[%[%[%[%[%X$[%X$X$X$:%[%],[%[%[%H;[%[%[%[%[%[%[%X$h*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%)=!%!%!%!%!%!%!%!%!%!%!%!%!%N,O,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[,P,X$0>P>P>0>P>P>P>P>P>0>",
"P>P>P>0>0>P>P>0>P>0>0>P>o=P>0>P>o=0>P>0>P>o=P>P>P>P>0>P>P>P>P>0>P>P>P>o=P>P>P>P>P>0>P>P>o=P>0>0>P>P>0>],0>X$X$X$P>o=0>P>P>o=0>X$X$[%[%[%[%[%X$>*6%6%!%!%!%6%6%6%X$:%:%6%!%!%!%!%!%!%!%!%!%!%!%!%],],],!%!%!%6%Q,X$6%!%!%!%!%!%!%!%!%!%!%],!%!%!%!%!%X$X$X$[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%X$X$X$X$X$:%[%[%],[%[%/,R,S,T,[%[%[%[%X$5*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%d,!%!%!%!%!%!%!%!%!%!%!%!%!%!%U,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%2-V,X$0>P>o=P>0>P>P>o=P>0>",
"P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>P>P>P>0>0>0>P>P>o=P>P>P>P>0>P>P>P>P>P>0>0>P>0>P>P>P>P>P>0>0>],P>P>P>X$X$0>P>P>P>0>P>P>X$X$[%[%[%[%[%[%X$K&6%6%6%6%6%T&X$X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%],],6%6%X$!%6%!%!%!%!%!%!%!%!%W,6%6%],!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%X$X$X$X$[%:%[%[%[%],X$X$X$@;@;X$[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%Z*!%!%!%!%!%!%!%!%!%!%!%!%!%0;f*j*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X,X$X$P>P>P>0>P>0>0>P>P>P>",
"P>P>P>P>0>0>0>0>P>P>0>P>0>0>P>P>P>0>P>0>P>P>P>P>P>P>P>P>0>j,P>o=P>P>P>P>0>P>P>P>P>P>0>P>P>P>P>P>P>],P>P>P>P>P>P>P>P>0>P>P>P>0>P>P>X$X$[%[%[%[%[%X$,&{&Y,6%l;X$X$X$X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%6%],0%X$!%!%!%!%!%!%!%Z,`, '6%6%6%X$],!%!%!%!%[%[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%X$X$X$[%[%:%[%[%[%[%],X$X$.'s;X$X$X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$[%e>!%!%!%!%!%!%!%!%!%!%!%!%!%e=H%B*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%D&X$},0>P>P>P>P>P>P>P>P>P>",
"P>o=P>P>P>P>P>P>0>0>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>0>0>P>P>P>0>P>P>0>P>0>P>0>P>P>P>P>P>P>P>0>0>0>],P>P>P>0>P>0>P>P>0>P>P>0>P>P>P>0>P>X$X$X$[%[%[%[%X$X$X$X$X$X$Q%X$X$Q%X$X$X$6%6%6%6%6%6%!%!%!%!%!%!%!%6%S&X$],!%!%!%!%!%!%!%!%+'+'@'6%X$X$X$[%],[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%X$X$[%[%[%:%[%[%[%[%[%],[-9-Y=!%!%X$X$X$X$#'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%F*!%!%!%!%!%!%!%!%!%!%!%!%!%*;$'e*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%%'X$},0>P>P>P>P>P>P>0>P>P>0>",
"P>0>P>P>P>P>P>P>P>0>0>P>0>0>0>0>P>P>P>P>0>P>0>P>P>P>0>P>P>P>P>P>P>0>P>P>P>P>P>0>0>P>0>0>P>P>P>P>P>0>0>P>0>P>P>0>P>P>P>P>P>P>0>P>P>0>P>&'X$X$[%[%[%[%[%[%X$Q%Q%Q%X$X$Q%Q%Q%X$X$X$X$X$6%6%6%6%6%6%6%X$X$X$X$!%!%],!%!%!%!%Z,Z,*'@'='6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%[%[%[%[%[%X$#*R=!%!%'&X$X$~;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$-'!%!%!%!%!%!%!%!%!%!%!%!%!%;'@-:*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%D&X$},P>0>P>0>P>0>P>0>0>P>P>",
"P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>0>P>P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>P>P>P>P>P>P>P>j,P>P>P>P>P>P>P>P>P>P>P>P>P>P>0>0>P>P>P>P>P>0>P>X$X$[%[%[%[%[%X$X$R%R%R%X$R%R%Q%Q%Q%X$X$X$X$X$X$X$X$X$X$X$X$6%!%!%!%],!%!%!%!%Z,>','X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%[%[%o-[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$''!%|%J*!%X$b,l&!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%y*X$X$[%q*!%!%!%!%!%!%!%!%!%!%!%!%!%)'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$P>P>P>P>P>0>P>P>P>P>P>P>",
"P>0>P>0>P>0>P>P>P>P>P>P>P>P>P>P>0>0>P>P>P>P>j,P>P>P>P>j,P>P>P>P>P>P>0>P>P>P>P>P>P>P>P>j,P>j,P>P>P>P>P>P>0>P>P>P>P>0>P>P>P>P>j,0>P>P>P>P>P>P>X$X$[%[%[%[%[%X$R%R%R%X$X$R%R%R%R%R%R%Q%X$!%!%!%!%!%!%6%!%!%!%!%!%!%],!%!%!%!'6%X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$''!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%Q*!%!%!%!%!%!%!%!%!%!%!%!%!%;'~'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>0>P>0>P>P>P>j,P>P>P>j,P>",
"P>P>P>P>P>P>P>j,P>P>P>P>j,P>P>P>P>P>j,P>P>P>P>P>j,P>P>P>P>P>j,P>P>0>P>P>P>0>P>P>0>P>P>P>P>P>P>j,P>P>P>P>P>j,P>P>0>P>P>P>P>P>P>P>P>j,P>j,P>P>P>X$X$[%[%[%[%X$X$R%R%R%X$R%R%R%R%R%X$X$!%!%!%!%!%!%6%!%!%!%!%!%!%!%!%],!%{'6%X$X$:%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$[%[%[%[%[%[%[%[%[%(,[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%]'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%^'X$X$[%q=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%X$P>P>P>P>P>P>P>P>P>P>j,P>P>",
"P>j,P>P>P>P>P>P>/'j,P>/'P>P>P>P>P>P>j,P>P>P>P>P>P>j,P>P>j,P>j,P>P>P>P>P>P>P>P>P>P>j,P>/'P>j,P>P>P>j,P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>P>P>j,P>j,P>P>X$X$[%[%[%[%X$X$X$R%R%R%R%R%R%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%@'],X$X$[%[%:%X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%O-X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$[%x*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>j,P>P>P>j,P>P>P>P>P>j,P>",
"P>P>P>P>P>P>P>j,j,P>P>P>P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>('P>P>P>/'P>P>P>P>P>P>/'j,P>/'P>P>P>P>P>P>P>P>P>P>P>j,/'P>P>P>/'P>P>/'P>P>P>P>/'j,P>P>P>j,X$X$[%[%[%[%X$X$X$R%R%R%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'_'_':'],X$[%[%[%:%X$[%[%[%[%[%[%[%[%[%[%[%:%[%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%<'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>P>P>P>/'P>P>P>P>P>P>P>P>",
"P>P>P>/'P>P>/'P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>P>P>P>P>j,P>P>P>P>P>P>P>/'/'P>P>P>/'P>P>/'P>P>P>P>P>/'/'P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>P>/'P>/'P>P>P>P>X$X$[%[%[%[%!%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%@'6%['X$X$X$],[%[%[%:%X$[%[%[%[%[%[%r-(=!%!%}'X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%|'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>/'/'P>P>P>/'/'/'/'P>/'/'P>",
"/'P>P>P>P>/'P>P>/'/'P>P>/'P>P>P>P>/'P>P>/'P>P>P>P>P>P>P>P>P>P>P>/'P>P>P>P>P>P>/'P>P>P>P>P>/'/'/'P>P>P>P>P>P>P>P>P>P>P>P>/'P>/'P>/'P>P>P>P>P>P>P>&'1'2'X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$[%[%[%[%[%6%X$[%[%[%[%[%o,`*!%!%!%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%!;@-X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$X$G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'P>P>/'P>P>P>P>P>P>P>P>P>P>",
"/'P>P>/'P>P>P>P>P>P>P>P>/'P>P>/'P>P>/'P>/'/'/'/'/'P>P>P>/'/'P>P>P>P>P>P>P>P>P>P>P>P>P>/'P>P>P>/'P>P>/'/'P>P>P>P>P>P>/'P>P>P>P>P>P>P>P>/'P>P>3'P>&'P>4'2'X$X$X$[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$[%[%[%[%[%[%!%6%X$[%[%[%[%!%!%!%!%!%!%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%F,5'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%Z*X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>P>P>P>/'P>P>P>P>/'P>P>/'P>",
"('/'P>P>P>('/'P>P>/'/'P>P>P>/'P>P>P>P>P>P>P>P>P>P>/'P>P>P>P>/'P>/'P>('P>/'/'P>P>/'P>/'P>('P>P>('P>P>P>P>/'/'/'/'P>/'P>P>P>P>/'P>/'/'P>P>/'6'P>6'P>/'7'/'8'X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$[%[%[%[%[%[%!%!%6%X$[%[%Q*!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%|,9'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%L=X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>P>P>P>/'P>P>/'P>P>P>P>P>P>/'",
"P>/'P>/'P>P>/'P>P>P>/'('/'P>P>P>/'P>/'P>P>P>P>P>P>('/'('P>P>P>P>/'P>/'P>P>('/'P>/'P>('j,P>P>j,P>/'P>P>P>P>P>P>/'P>P>P>('/'P>/'P>P>/'P>('P>('P>0'P>P>P>P>X$X$[%X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$[%[%[%[%[%[%[%[%!%!%6%X$[%a'5=!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%b'c'b,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%C-X$X$[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'/'P>P>/'P>/'/'('/'/'P>P>P>",
"P>('/'P>P>('('/'/'/'P>P>('/'('('P>/'P>('('/'/'/'('P>('P>/'/'/'P>P>P>P>P>P>j,('/'P>P>P>('/'/'('/'P>/'('('/'/'P>P>/'/'/'/'P>P>P>('P>('/'P>P>P>0'&'('/'/'d'X$X$[%X$X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%[%X$X$X$[%[%[%[%[%[%[%[%!%!%!%6%X$G*!%!%!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%)&X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%x*X$j>[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>P>('P>P>('P>/'P>('P>P>P>/'P>/'",
"P>('P>/'P>P>('('P>('P>P>P>/'/'/'P>P>j,/'P>('P>P>/'P>/'P>('('/'/'/'/'/'/'('P>('/'/'P>P>P>P>P>P>/'('/'P>('P>/'P>P>P>P>P>/'/'('P>/'j,('P>/'/'&'e'&'('P>0'X$X$[%[%:%:%X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%X$X$[%[%[%[%[%[%[%[%[%!%!%!%!%6%X$=*!%!%6%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%R,X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$f'[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$/'P>P>('P>/'P>/'P>P>('P>P>/'('P>",
"P>P>('/'/'/'P>P>('/'/'/'('P>P>P>P>('('P>/'P>/'P>P>/'P>('P>P>P>P>P>P>/'('P>/'P>('P>/'/'/'('/'('('P>P>/'P>/'/'('/'/'/'/'('('P>/'('('P>/'P>P>g'P>/'P>&'X$X$X$[%:%:%:%6%X$X$X$X$X$X$X$X$X$X$X$X$X$X$:%[%[%[%[%[%[%[%[%!%!%!%!%!%!%6%X$E*!%!%6%6%6%6%!%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%h'X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'/'/'/'/'P>/'P>/'/'P>/'('/'P>/'",
"/'/'('P>P>P>/'P>P>P>P>P>/'/'('('/'/'/'('P>('/'/'P>/'P>/'/'/'('('('('P>/'P>/'P>('P>P>P>P>P>/'P>/'/'P>/'('('P>('('('P>P>P>/'P>P>/'/'P>('/'/'i'&'/'X$X$X$!%!%!%[%:%[%[%X$:%[%X$X$X$X$X$X$X$X$X$:%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%6%X$)-6%!%!%6%6%6%!%6%!%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%8-X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%X$},P>P>P>P>('P>('P>/'/'('/'('/'('/'",
"P>P>P>/'/'/'P>/'/'('/'/'/'('P>/'P>P>P>P>/'P>P>('('('/'P>P>('/'/'/'P>/'P>/'P>/'/'('('('/'/'P>/'P>P>/'P>P>P>/'P>P>P>('/'/'P>('/'j'k'k'j'j'j'P>6'l'X$!%!%!%!%!%[%[%[%[%X$[%[%[%:%:%:%:%:%:%:%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%6%X$`*X$6%6%6%6%X$6%6%!%6%6%X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%m'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'/'('/'('/'('/'/'('P>/'P>P>P>P>P>",
"/'/'('('/'('/'('/'('/'('P>/'P>/'/'('/'('/'('P>P>P>/'('/'P>P>P>P>/'P>/'('('P>P>/'/'/'P>('/'P>('('('('/'/'/'/'/'/'/'P>P>n'o'k'k'p'p'p'p'k'k'k'j'j'j'j'!%!%q'!%!%[%[%r'X$6,[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%y*g>!%!%!%!%!%!%!%!%!%6%6%X$X$6%6%6%6%X$X$X$6%6%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'('/'P>/'P>('P>('P>/'/'/'/'('/'",
"('/'P>P>('P>('/'/'P>('P>/'/'/'('('/'/'/'/'/'/'/'/'P>/'('/'/'('/'/'('('P>/'('('P>P>/'('/'/'/'/'/'P>P>('('('/'('('P>s'j'j'k'k'p'p'p'p'p'p'p'p'k'k'k'k'j't'u'v'v'v'v'v'v'!%w'G*[%[%[%[%[%[%[%[%[%[%3*o,q=4;!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$6%6%6%X$X$X$X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$P>/'P>P>P>('P>/'P>/'/'/'/'/'('('/'('",
"('/'/'P>('P>P>('/'P>('P>('('/'/'/'('P>('/'('/'('('P>/'('/'/'('('/'P>/'P>/'/'('('('/'P>('('/'/'/'/'P>P>P>('P>P>x'j'j'k'k'p'p'y'y'y'y'y'y'y'y'y'p'p'p'p'p'j'z'A'B'B'B'v'v'6%6%Z*C-%=C'i=+=K=i=%=C-x*L=!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$v'X$X$X$X$X$X$X$X$[%X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$/'('/'('/'('('/'/'P>('('('P>/'P>P>/'",
"P>('('('/'('D'P>('/'/'('/'/'/'/'('P>/'P>P>/'('/'/'('('/'('/'/'/'('/'/'D'/'/'/'/'P>/'('P>/'P>('('('/'/'/'/'/'j'j'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'B'B'v'v'v'6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%E'v'v'v'v'v'X$X$X$X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$('/'('/'/'/'/'('('('/'/'P>('/'('/'('",
"/'/'/'/'/'P>/'/'('('/'/'/'('('/'D'('/'D'('/'P>('D'j,/'/'('('P>/'('('P>('('/'('D'('/'/'/'('/'/'/'('('('P>('j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'v'v'E'6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%E'E'E'v'v'A'A'A'v'v'v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%)=X$:%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$P>('/'/'P>('P>/'/'/'('P>D'D'('/'/'/'/'",
"/'('/'('/'/'('/'D'/'('/'('/'/'P>/'/'('/'/'P>D'/'/'D'('('/'/'D'/'D'/'D'/'/'('/'P>/'('('('D'('('/'/'/'/'D'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'j'A'B'B'B'B'v'v'E'6%6%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%v'v'v'F'F'G'A'A'A'A'B'B'j'j'j'j'j'j'j'j'j'j'j'j'H'I'J'K'j'j'k'j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%)=X$:%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'/'/'('('/'('('/'('P>('/'/'/'/'('P>('",
"/'('/'('('/'('/'/'/'('/'('/'D'/'('D'/'/'D'/'/'/'/'/'/'('/'/'('/'/'/'/'('/'('D'/'/'('/'/'/'/'('/'('/'P>j'j'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'A'B'B'B'B'v'v'E'E'6%6%6%6%6%6%6%6%6%6%6%6%!%v'v'v'L'M'N'B'A'A'A'A'A'j'j'y'j'j'j'j'j'O'P'Q'R'S'T'U'V'W'y'y'y'p'p'k'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%`*X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'('D'/'/'('/'('/'('D'/'/'('('/'D'/'/'",
"('/'('/'/'('/'/'('('('('/'('/'('/'P>('('/'('('('('/'('/'('('/'/'('/'('P>('/'/'('('/'('/'/'/'/'('/'('D'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'A'B'B'B'B'v'v'v'v'E'E'6%6%6%!%6%E'E'v'v'v'v'v'B'B'B'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'X'Y'Z'Z'y'y'y'y'y'y'y'y'p'k'k'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$('/'/'('('D'('/'/'D'/'('('/'D'('/'('('",
"D'/'('('D'/'('/'D'/'/'('/'('/'/'D'/'/'('/'/'/'/'('/'/'/'/'/'('D'('/'D'/'D'('/'D'/'/'('('('('D'D'/'/'/'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'B'B'B'B'B'v'v'v'v'v'v'v'v'v'v'v'B'B'B'B'B'B'A'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'/'D'/'/'/'/'('/'/'/'/'/'/'D'('/'/'/'",
"('('/'/'/'('/'('/'/'/'D'('/'('('/'('('/'('D'/'/'/'/'('('('('/'/'/'('/'('/'/'/'/'('('/'/'D'/'/'/'('/'('j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'A'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'j'[%[%[%[%[%[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$('('/'/'('D'('D'/'('('('('/'/'/'('D'('",
"D'D'D'('D'('D'('('D'/'D'D'D'D'('D'D'('D'/'('D'D'D'D'/'/'D'('('D'D'('D'('('('/'D'D'('D'/'D'('('D'('/'j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'j'j'A'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'j'[%[%[%[%[%[%[%[%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'('('/'/'D'/'('/'/'/'D'('('D'D'/'D'/'",
"/'/'/'D'/'D'/'/'D'('('/'/'/'/'D'/'/'D'/'('D'('/'('/'D'D'/'D'/'('/'D'/'/'D'D'D'/'/'D'/'('('/'D'/'D'('j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'y'j'A'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'j'[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'D'D'('/'/'D'D'('('/'D'/'('/'('/'D'",
"('('/'('/'D'D'/'D'D'('('('D'/'D'('/'('/'/'D'('D'D'('('('/'D'/'('D'('D'/'/'('/'D'/'('D'D'('/'D'/'D'/'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'A'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'k'k'k'p'p'y'y'y'y'p'p'k'j'[%[%[%[%[%[%[%[%[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'('('D'D'D'/'('D'D'('/'D'/'('D'('('D'",
"D'D'D'D'('('/'D'/'/'D'D'D'/'D'('D'D'D'D'('/'D'/'('D'D'D'('('D'/'/'D'/'('('D'D'('D'D'D'/'D'D'/'('/'D'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'A'A'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'j'j'j'j'j'`'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'k'p'k'p'p'p'y'y'y'y'y'y'p'p'p'j'j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'D'/'/'('('D'/'/'D'('('D'D'/'D'D'/'",
"D'/'D'D'D'('('D'D'D'/'D'D'('D'/'('/'('D'D'/'('D'/'/'('D'D'('D'D'/'D'D'D'/'('D'('/'/'D'/'('('D'D'/'/'j'j'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'A'A'B'B'B'B'A'A'A'A'j'j'j'j'j'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'p'p' )P'j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'/'D'('D'D'D'D'D'/'D'D'('D'('D'/'('D'",
"/'D'/'D'/'D'D'/'/'/'D'/'('D'/'D'D'D'D'('('D'D'D'D'D'D'('('D'('('D'('D'/'D'D'/'D'D'('('D'D'D'/'('D'D'j'j'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'y'y'y'y'y'y'y'y'y'y'p'k'j'A'A'B'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'p'p'.)+)j'j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'('D'/'D'/'('('D'D'/'D'/'D'/'D'D'('",
"('D'/'D'D'D'D'D'D'('D'D'/'D'('/'('/'D'D'('D'/'('('D'D'D'D'D'D'('D'/'D'('D'D'/'('D'D'D'/'D'D'D'('('@)j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'y'y'y'y'y'y'y'y'y'p'k'j'A'A'B'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)$)j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$/'D'D'D'/'D'D'D'('('D'D'D'D'D'('D'D'D'",
"D'('D'('/'/'D'D'('D'('D'D'D'D'D'D'D'D'D'D'('D'D'D'/'D'D'('D'D'D'D'D'('D'D'('D'D'D'D'('D'('D'D'D'D'%)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'y'y'y'y'y'y'y'y'p'k'A'A'A'B'B'B'A'A'A'A'A'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'#)#)&)j'j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$*)/'('('D'('('D'D'D'('D'D'D'('D'('D'D'",
"D'('D'D'D'('('D'D'D'D'D'('D'D'D'D'/'D'D'D'D'D'D'D'D'/'D'D'D'D'('D'D'D'/'D'D'D'D'/'D'D'D'('D'D'D'('=)k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'y'y'y'y'y'y'y'y'p'j'A'A'A'B'B'B'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#);)j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'('D'D'D'D'D'D'('('/'D'D'D'/'('D'",
"D'D'D'D'D'D'D'D'('D'('('D'D'D'('('D'D'D'D'D'D'D'D'D'D'D'/'D'D'D'('D'D'D'D'D'D'('D'D'D'D'D'('D'D'D'k'k'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'y'y'y'y'y'y'y'y'p'j'A'A'A'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)>)j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$*)D'D'D'D'('D'D'D'D'D'D'D'D'D'D'D'D'",
"D'D'D'('D'D'D',)D',),)D'D'D'D',)D'D'D'D'('D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'D'('D'D'D'D'D'')k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'j'k'p'y'y'y'y'y'y'y'p'p'j'A'A'B'B'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#)#)))j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D'D'D',)/'D'D'D'D'D'D'D'D'D'D'('D'",
"D'D'('D'D'D'D'D'D'D'D'D'('D'D'('!)D'('D',)D'D'D'D'D'D'D'D'D'D'D'D'('!)D'('('D'D'D'!)('!)D'('%)k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'p'y'y'y'y'y'y'y'p'p'j'A'A'B'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)#)#)j'j'[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)D'D'D'!)('D'D'D'D'D'('('D'D'D'D'",
"('!)!)!)('D'D'D'D'D'D',)D'D'D'D'/'D'D'D'D'D'('D'D'('D'D'D'D'D'D'D'D'(',),)D'!)('D',)D'D',)D'~)k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'p'y'y'y'y'y'y'y'p'k'j'A'A'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%{)F*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$('D'D'D'D'D'D'D'D'D'D'D'D'D',)D'D'",
",)D'D'D'D'D'D'D'D'D'!)D'D'D'D'D',),)D'D'D'D',)D'D',),)D'D'D'D'!)D'D'D'D'D'D'D',)D'D'D'D'D'])k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'k'p'y'y'y'y'y'y'y'y'p'k'j'A'A'A'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)#)j'[%[%}=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$D'D'D'D'D'D'D'D'D'D'!)D'D'D'D'D'",
"D'D'D',)D'D'D'D'!)('D'D',),)D'!)D',)!)D'D'!)D'D'D'D'D'D'D'D'D'D'D'!),)D'D'D'D'D',)D'D'D'^)/)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'p'p'y'y'y'y'y'y'y'y'p'k'j'A'A'A'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'[%[%4;Z*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$D',)D'D'D'!)D',)D'!)D'D'D'D'D'",
"D'D'D'D'D'D'D'D'D',)D'D'D'D'D'D'D'D'D'D'('D'D'D'D'D'D'D',)!)D',)D'D'D',)D'D'D'D'D'D'D',)k'k'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'p'p'y'y'y'y'y'y'y'y'y'p'k'j'A'A'A'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'[%[%+=)=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$D'D'!)('!)D'D'D'('!)!)!)D'",
"D'D'D',)D'!)D'D'D'D'!)!)D'!)D'D'D'D',)!)D',)!)D'!)!),)D'D'D'D'D'D'!)D'!)D',)!)D'D'!)D'()k'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'p'p'y'y'y'y'y'y'y'y'y'p'p'j'A'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%=*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%P-!%!%!%!%!%!%6%6%6%X$X$X$D',)D'D'D'D',)D'D'D'!)D'",
",),)!)!)!)D',)D',),)D'D'!)D'D'!),)D'!)D'D'D'D'!)D'D'!)D'D'!)!)!)!)D'!)D'!)!)D',)!)D'k'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'#)p'y'y'y'y'y'y'y'y'y'y'p'p'j'j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%d,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%r'L=`*`*)=!%!%6%6%6%X$X$X$,)D'!),)D'!)D'D'D'D',)",
"!)D'D'D'D'!)!)!)!)D'D'D'D'!)D'D'!)D',),),)D'D'D'D'D'!),)D'D'D'D'D'D'D'D'D'D'D'D'j'k'k'_)p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)k'j'#)y'y'y'y'y'y'y'y'y'y'y'y'p'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%a'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%:)!%X$X$<)6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[)=*(=C-x*5=<)6%6%X$X$X$})!)D'D'!)D'D'D'D'D'",
"D'!)D'!)!)D'D'D'D',)!),)!)D',)!)D'!)!)!)!)!),)!),),)D'!),),)!)D'!),)D'!)!),)!)k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'-)#)y'y'y'y'y'y'y'y'y'y'y'y'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)y'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%y*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%w;C&X$X$|))-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%G*1)_*2)3)4)5)X$X$6)7)8),)D'9)9)!)!)!)",
"D'!),)D',)!),)!)!)D'!),),)D'D',)D'D'D'D',)!)D'!)!),)D'!)!)D'!),)!)!)D'D'!)j'j'k'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'#)k'-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%$=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$4)`*!%!%!%!%!%!%!%!%!%!%X$[)(=5=!%!%!%!%!%X$X$[%[%[%[%[%[%[%:%:%:%X$X$0)w-a)b)c)d),),),)",
"!)D'!)!)!)D'!),),)!)D'!)!)!)!)!)!)!)!),)!)D'!)D'D'!)!)D'D'!),)!)D',),)!),)j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)k'-)-)y'y'y'y'y'y'X$y'X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%u*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%i=!%!%!%!%!%!%!%!%!%!%X$X$[%o,4;!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$]-!)!)D'!)",
"!),),),)!)D'!)!)D'!)D',),),)D',),),)!)D'!),)!)!),),)!)!),)!)D'!)!)!),)!),)k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'k'j'-)-)y'y'y'y'X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'[%i=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%i=e)!%!%!%!%!%!%!%!%[%X${-[%[%[%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$,)D'!)D',)",
",)!)!)!),)!)!)D'!),)!)!)!)!)!)!)!)!),)!),)!)!),)!)!)!),)!),)!),)!),)!)D'!)k'#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'-)-)y'y'y'X$X$X$X$X$!%!%!%!%!%!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'j'[%C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%G*f)[=!%!%!%!%!%!%!%!%X$X$g)#=[%[%[%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$,)!)!),)!)!)",
",)D',)!)!),)!),)!)!)!)!)D'!)!),)!)!)!)!)!),)!)!),),)!)D'!)!)!)D'!),)!),)!)k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'#)j'-)-)y'y'X$X$X$!%!%!%!%!%!%!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'j'h)x*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%{)x*)=!%!%!%!%!%!%X$X$z;i):%[%[%[%[%!%[%[%[%[%[%[%[%[%[%[%[%X$X$X$!)!),)!),)!)!)",
"!)!)!)!)!)!),)!)!),),),)!),),)!),),),)!),)!)!)!)!)!)!)!)!),),)!),)!)!)!)!)j'k'#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'k'j'-)-)y'X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$j)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)k)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)k'j'[%a'%;!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$[%[%[%G*K=L=!%!%!%!%!%!%X$X$X$:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$X$,)!),)!)!)!),),)",
"!)!)!),)!)l)!)!)!)!)!)!)!)!)!)!)!)!),)!),),),)!)!),)!),)!)!)!)!)!)l)!),)!)j'j'#)#)#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'p'p'j'j'-)y'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)m)n)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'[%=*];!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$[%[%[%[%[%[%[%!%!%!%!%!%!%X$X$6%:%:%:%:%:%[%[%[%[%[%[%[%X$X$X$!)!)!),)!)!),)!)!)!)!)",
"l)!),)!)!)!)l),)l)!)!)l)!)!),)!)!)!)l)!)l)!)!)!),)!),)!)!),)!)!),),),)!),)!)j'k'k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'-)X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)o)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)k'j'[%K=)=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$[%[%[%[%[%[%[%[%[%[%[%[%[%X$X$X$6%:%:%:%:%:%:%:%[%X$X$X$!)!)!)!)!)!)!),)!),),)!),)",
",)l)!),),),)!),)l),),)l),)!),)!)!)!),),)!)l),)!)!)!)!),)l)l),)!)!)!)!)l)l)l),)j'k'k'k'#)-)-)y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)k'j'X$X$[%x*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%+=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$v=[%[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$X$X$X$X$X$X$X$X$,)!)!)l)l)l)l)!)!)l)!)l),)l)!)",
"l)!),)!)l)!)!)!),)l)!),)l)l)l)l),),)!)!)l),)!)l)l)l),)!)!),)l)!)l)!)l)!),),)l)l)j'k'k'#)#)-)-)-)-)-)y'-)-)-)-)-)-)-)-)-)#)j'X$X$[%[%(=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%+=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$~,-,[%[%[%[%[%[%[%[%[%[%X$X$X$!)!)l)!)!)l)!),)l)!)l)l),),),)!)l)!)!)l),)l)!),)",
",)l)l)!)!)l)l)!)!)l)!)!)!)!),)l)l)l)l),)!)l),),)!)l)l),)!)!)l),)l),),)!)!)!),),),)j'k'#)#)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)j'X$[%[%[%{)`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'j'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'[%p)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$W*T,~,[%[%[%[%[%[%X$X$[%[%X$X$X$,)!),),)l)l)!)!),),)!)!)!)!),)l)!)!)!)!),)l)!)",
"l)!)!),)l)!),)l)!),)l)!),)!)!)!)!)!)!)!)l)!)!)!)!)!)!)l)l)l),)!),)!)l)!)l),)!)!)!)l)j'k'#)#)-)-)-)-)-)-)-)-)-)-)-)-)-)#)q)X$X$[%[%[%[%4;Z*!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)j'j'j'y'y'y'y'r)s)r)t)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)u)j'j'[%K=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$v)s>i-K-[%[%[%[%[%X$X$[%[%X$X$l)!)l)!)!)!)l)l)!)!)l)!)!)l)!)!),)!)l)!)l)!)l)",
"l)l)l)!)l)!),)!)!)!)l)l)l)l)l),)l)!)l)!)!)l)l)l)!)!)!),),)l)l)l)l)!)l),)l)l)l)l)!)!)l)w)k'#)x)y)z)A)-)-)-)-)-)-)-)-)-)#)X$X$X$[%[%[%[%[%(=(=d,6,q*X$X$X$X$X$X$X$:%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'y'y'y'y'X$X$X$X$X$X$X$X$X$B)y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)C)j'j'[%g>!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)X$X$X$X$);0-j-o-o-T=X$X$X$[%X$X$!)l)!)!),)!)l)l),)l)l),)!)l)l)l)!)l)!)l),)!)",
"!),)!)l),)l)l)l)l)l),)!),)!)!)l),)l)!)l)l)!)!)!)l)l)!)l)!)!)!)!)!)!)!)l)!)!)!)!)l)l)!)D)w)j'E)#)#)-)F)y)-)-)-)-)-)-)-)x)X$[%[%[%[%[%[%[%3*q=%=X$X$X$!%!%!%!%X$X$[%:%q*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'j'G)X$X$X$X$X$X$!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)#)j'j'j'r'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l),)!)X$X$X$X$X$P,[%[%W*X$X$X$X$X$X$X$X$l)!)l)!)!)l)!)!)!)l),)!),)l),)!),)l)l)",
"l)l)!)l)!)!),)!)!)l)l)l)l)!)!)l)l)l)!)!)l)l)l)!)l)l)!)l)l)l)l)l)l)l)!)l)l)l)l)!)!)l)l)!)X$:%w)k'F)-)-)-)-)-)-)-)-)-)#)X$X$[%[%[%[%X$X$X$X$X$X$X$[%[%!%!%!%!%!%X$X$[%:%Y*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)j'j'j'X$X$X$X$!%!%!%!%!%!%!%!%X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'-)-);)j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)!)X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$l),)l)l)!)!)l)l)!)l)l)l)!)l)l)l)!),)!)",
"!)!)l)!)l)l)l)l)l)!)l)l)!)l)l)!),)!)l)l)!)l)!)l)!)l)l)l)!)l)!)l)!)!)l)!)l)l)!)l)l)!)!)H)X$:%:%w)j'j'z)-)-)-)-)-)-)#)x)X$[%X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%,=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$I)y'y'y'y'-)-)-)-)-)J)-)-)K)L)j'X$X$!%!%X$X$X$X$X$!%!%!%!%!%X$X$M)y'y'y'y'y'y'y'y'y'y'y'-)-)-)N)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$!)!)l)l)l)X$X$X$X$X$X$X$X$X$X$X$X$X$l)l)l)l)!)l)l)!)l)l)!)l)!)l)!)l)!)l)l)l)",
"l)l)l)l)!)!)l)l)l)!)!)l)l)!)l)l)l)l)l)l)!)l)l)l)!)!)!)l)!)l)!)l)l)!)l)!)!)l)l)!)l)l)!)X$X$:%:%:%:%j'j'j'O)-)-)-)z)#)P)X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%:%L=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$Q)-)-)-)-)-)X$X$X$X$X$X$X$X$X$X$X$+'!%!%!%X$X$X$!%!%!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)l)l)!)l)!)l)l)l)!)!)!)!)l)l)l)!)l)!)l)!)l)l)!)l)l)!)l)l)l)!)l)l)l)l)l)",
"l)!)l)!)R)l)!)l)l)l)l)l)!)l)!)l)l)!)!)l)l)l)!)l)l)l)l)l)l)l)l)l)!)R)l)l)l)l)!)l)l)l)S)X$:%:%[%:%:%:%T)j'k'k'k'k'k'k'j'X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%U)C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%V)X$X$-)-)X$X$X$!%W)X)!%!%!%!%!%X$X$X$+'!%!%!%!%X$X$!%!%!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$!)!)!)l)l)l)l)l)l)!)l)l)l)l)l)!)!)l)!)l)l)l)!)l)l)l)!)l)l)!)R)!)R)l)!)!)!)",
"l)!)l)!)l)l)!)!)l)l)!)l)l)R)!)l)l)l)!)l)!)l)l)l)l)l)l)l)!)R)!)l)!)!)l)l)l)l)l)!)!)l)X$X$:%:%[%[%[%[%:%:%w)k'Y)k'k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%6,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'!%!%!%X$X$!%!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)!)l)l)l)!)!)l)l)l)l)l)!)R)l)!)l)l)l)R)l)l)!)!)l)l)l)l)!)l)!)!)l)l)l)l)",
"!)R)R)Z)!)l)l)l)!)R)l)l)!)!)R)l)l)l)l)l)Z)l)l)l)R)l)!)l)l)l)l)l)l)R)!)l)!)l)l)Z)l)!)X$:%:%[%[%[%r-_*o,o,e>`)j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%G*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)#)k'j'#)j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)!)!)Z)l)l)!)l)!)!)l)!)l)l)R)R)!)l)!)!)Z)l)l)!)R)l)l)l)l)l)l)l)l)l)",
"!)!)!)R)l)l)R)R)!)l)l)R)Z)l)l)l)l)R)!)R)l)!)l)l)!)R)!)R)!)l)l)l)l)R)!)R)R)!)R)l)l)!)X$:%:%[%[%6,4;q*q*C-!%`*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%!%X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'!%!%!%!%!%!%!%!%X$X$X$+'+'!%!%X$X$ !.!y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)#)k'j'#)j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)l)R)!)l)R)R)!)R)R)l)Z)!)l)!)!)l)!)R)R)!)l)R)R)!)!)l)R)!)R)R)!)l)l)l)",
"Z)Z)l)!)R)!)!)l)l)R)l)!)l)l)!)R)!)!)R)l)!)R)l)l)R)l)l)l)l)R)l)l)l)!)R)!)!)l)!)R)l)X$X$:%:%[%g>!%(=[=5=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$:%:%[%!%!%!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'+'!%!%!%!%!%!%!%X$+'+'!%!%!%X$+!@!y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)k'j'-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)l)R)!)l)R)l)l)l)!)R)R)l)l)R)Z)!)!)R)R)!)l)l)l)R)l)l)!)!)l)R)R)l)",
"l)R)l)l)R)l)l)l)l)!)Z)R)!)R)!)R)l)l)l)R)l)l)l)l)l)R)!)R)!)R)!)l)Z)l)l)l)R)l)l)R)!)X$X$:%:%6,C-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$:%:%[%!%!%!%!%6%X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'+'!%!%!%!%!%X$X$+'+'!%C;#!X$$!y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)%!k'-)#)k'k'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)!)R)!)l)l)l)l)l)l)Z)l)l)l)R)!)!)R)l)l)l)l)l)R)!)l)l)l)Z)Z)R)!)!)!)l)",
"R)l)l)l)l)R)l)l)l)R)!)!)R)l)R)l)l)!)R)l)!)R)!)R)!)l)Z)l)l)!)R)R)l)l)R)l)!)R)l)l)&!X$:%:%h)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$:%[%[%!%!%!%!%X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$+'+'+'!%!%!%X$X$X$+'!%!%**X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)C)*!j'-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$l)l)l)R)l)!)R)!)R)R)l)!)R)l)Z)R)l)R)l)!)R)!)!)R)!)R)!)R)!)l)Z)Z)R)R)",
"l)R)R)!)l)R)R)!)l)R)R)l)R)!)l)R)R)!)l)Z)l)R)!)R)l)R)!)R)l)l)!)R)!)l)R)R)!)l)l)l)=!X$:%[%r-!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%5;G*X$X$:%:%q=!%!%!%!%X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$+'+'+'!%!%!%X$X$+'!%!%!%X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-!;!k'-)-)#)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$!)R)l)R)l)l)R)!)!)!)R)!)l)!)l)l)l)R)R)l)R)R)l)R)l)R)!)R)l)R)!)l)l)l)",
"R)l)!)R)R)!)l)R)R)l)!)R)l)l)R)l)l)l)R)!)R)l)R)R)!)l)R)l)l)l)R)!)R)l)l)l)R)R)!)l)>!X$:%[%-'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+=[%[%X$X$:%:%a'5;`*!%X$X$X$X$1,!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'+'!%!%X$X$+'!%!%X$X$y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)#)#)-)-)-)k'k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)l)l)l)!)R)l)Z)R)R)R)R)R)R)l)R)!)l)l)l)l)!)R)!)R)l)R)!)R)l)R)R)R)Z)",
"!)R)l)!)R)l)l)l)R)R)!)R)R)l)l)R)R)l)R)l)R)!)!)R)R)l)l)R)R)l)R)R)R)l)l)l)l)R)R)Z),!X$:%[%-'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%$=G*[%[%X$X$X$:%:%{))=!%!%!%X$X$X$X$6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'+'!%X$X$!%+'X$X$X$y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)#)-)-)-)j'#)j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$R)R)!)R)l)R)!)l)l)l)l)!)l)R)!)R)R)l)l)R)R)l)Z)l)R)!)R)l)R)!)!)l)R)l)",
"R)l)R)R)l)R)R)l)l)l)R)l)l)R)R)l)!)R)!)R)l)R)R)l)!)R)R)l)l)R)l)l)!)R)R)R)R)l)l)R)'!X$:%[%[)!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%q*Q*[%[%[%[%X$X$X$X$:%:%[%C-!%!%!%X$X$X$6%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%!%X$X$!%y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)k'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l)l)R)R)!)R)R)R)R)R)R)R)R)l)Z)l)!)R)R)l)l)!)R)R)l)R)l)R)l)R)R)R)l)R)",
"R)l)l)R)l)l)R)R)R)!)R)R)!)R)!)R)R)R)R)R)l)l)R)R)R)!)R)R)l)R)R)R)l)l)!)l)R)R)l)l)R)X$:%[%G*X$6%6%!%!%!%!%!%!%6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!*[%[%[%[%[%X$-))!X$X$X$:%:%:%(=|%!%!%!%X$X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'!%X$X$!%p'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)k'y'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$l)l)R)R)!)!)R)!)l)l)l)R)R)R)R)l)l)R)R)R)R)!)R)l)R)l)R)l)R)!)R)l)l)",
"l)R)R)l)R)R)l)l)l)R)l)R)R)l)R)R)l)l)l)l)R)R)l)l)l)R)l)l)R)l)l)l)R)R)R)R)l)l)R)R)l)X$:%[%[%X$6%6%!%!%!%!%!%!%!%X$6%6%6%6%6%6%6%6%6%6%6%6%6%!%!%!%!%!%!%!%`*5=!%}=4;$=[%[%[%[%X$X$!!-))!~!{!X$X$:%:%:%Y*`*`*!%!%X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$+'+'X$X$[%k'p'p'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)k'k']!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)R)R)l)R)R)l)R)R)R)R)l)!)R)l)R)R)l)l)l)l)R)l)R)l)R)l)R)l)R)l)R)R)",
"l)l)R)l)l)R)R)R)l)R)l)l)R)l)l)R)R)R)R)l)l)R)R)R)R)R)R)l)R)R)R)l)l)l)l)R)R)l)l)R)^!X$:%[%[%X$X$X$6%!%!%!%!%!%!%6%X$6%X$X$6%X$6%6%6%6%6%6%6%6%X$X$X$!%F*%;[=q*6,r-:%:%[%[%X$X$/!y'y'-)-))!(!_!X$X$l>:%:%:%q*+=!%!%X$X$)-6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$!%+'X$X$:!k'p'p'p'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)#)<![!}!|!1!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$l)l)R)l)l)R)l)l)l)l)R)R)l)R)l)R)R)R)R)R)R)R)l)R)l)R)l)R)l)R)l)l)Z)",
"R)R)R)R)R)l)l)l)R)R)R)R)l)R)R)R)l)l)l)R)R)R)l)l)l)l)l)R)l)l)R)R)R)R)R)l)l)R)R)l)2!X$:%:%[%X$X$X$6%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$&=$=y*[)3*G*G*[%[%:%[%[%[%X$y'y'y'y'y'-)-)-))!)!)!(!X$X>3!:%[%[%=*!%!%!%X$X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$R;[%:!k'p'p'p'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)#)#)4!j'j'j'j'!%!%5!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)l)R)R)l)R)R)R)R)l)l)R)l)R)!)R)l)l)l)l)R)R)l)R)l)R)l)R)l)R)R)R)",
"Z)l)R)!)R)R)R)l)l)l)R)R)R)R)l)R)R)R)R)l)Z)R)R)R)R)R)l)R)R)l)l)R)l)R)R)R)R)l)R)l)l)X$X$:%[%X$:%X$X$!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%X$X$X$[%[%[%:%:%:%:%:%:%:%:%:%[%X$X$X$y'y'y'y'y'y'y'-)-)-))!)!)!X$X$X$i):%:%[%i=A;!%!%`*X$X$6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6![%:!:!k'k'p'p'p'y'-)-)-)-)-)-)-)-)-)-)-)-)#)#)#)j'j'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$l)R)R)R)R)Z)l)R)R)R)R)l)R)l)R)l)R)R)R)R)l)Z)R)R)R)l)R)Z)R)R)R)R)R)",
"R)R)l)R)R)R)R)R)R)R)R)l)R)l)R)R)R)R)l)R)R)R)R)R)R)R)R)R)Z)R)R)l)R)l)R)l)R)R)Z)R)R)R)X$:%[%[%[%X$X$X$6%!%!%!%[%!%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%[%:%:%X$[%X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'-)-)-)-))!7!_!X$X$:%:%:%[%&=8!!%!%!%!%X$X$6%6%6%6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%:!k'k'k'p'p'p'#)#)#)#)#)#)-)-)-)-)-)-)#)k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)l)Z)l)R)R)R)l)R)R)R)l)R)R)R)R)R)R)l)R)R)R)l)R)R)R)R)R)l)l)l)l)",
"R)R)R)l)R)R)R)R)R)l)R)l)R)R)R)l)R)R)R)R)l)Z)l)R)l)R)R)R)R)R)R)R)R)Z)R)l)R)R)R)R)l)R)X$X$[%[%[%[%[%[%[%:%:%:%:%:%:%:%:%[%[%[%[%[%:%:%:%:%:%X$:%X$X$X$X$X$X$9!0!y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)_!a!X$X$X$:%:%:%[%[)[=)=!%!%!%`*X$X$6%6%!%!%!%!%!%!%!%!%!%!%!%!%!%r>!%,=[%[%[%j'k'k'j'j'k'k'k'#)#)#)#)#)#)#)#)q)4!j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$R)R)R)R)R)R)l)R)l)l)R)R)R)l)R)l)l)l)R)R)R)l)R)l)R)l)R)R)R)R)R)R)Z)",
"R)R)l)R)l)l)R)R)l)R)R)R)R)R)l)R)l)R)l)Z)R)R)R)l)R)R)l)R)R)Z)R)l)R)R)R)R)l)R)Z)l)R)b!X$X$[%[%[%[%[%[%[%[%:%:%:%[%[%:%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!c!X$X$X$[%:%:%[%G*r'P-`*!%!%!%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%R=!%|%3*[%[%[%j'j'j'j'j'j'X$j'j'j'j'k'k'd!k'j'j'j'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$R)R)R)R)R)R)R)R)R)Z)R)R)R)l)R)R)R)R)R)Z)R)R)R)Z)R)R)Z)R)R)R)R)R)",
"R)R)R)R)R)Z)Z)R)R)R)R)R)l)R)R)R)R)R)R)R)R)R)R)R)l)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)X$X$[%[%[%[%[%[%:%:%:%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)(!e!X$X$X$:%:%[%[%_=i=L=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%j'j'[%X$X$j'j'j'j'j'j'f!t'g!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)R)R)R)R)R)R)R)R)R)l)R)R)R)R)R)R)Z)R)R)Z)R)R)R)Z)R)R)R)R)R)R)R)",
"Z)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)Z)R)R)R)R)R)R)R)R)h!X$[%[%[%[%:%:%:%X$X$X$X$X$X$X$R)R)R)j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!X$X$X$:%:%:%[%[%{)[=5=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%i![%X$[%[%[%!%!%!%!%!%j!!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$l)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)",
"R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)k!R)l!X$:%:%:%:%X$X$X$X$X$X$X$X$R)R)R)k!R)j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!X$X$X$m!:%:%[%[%[%Y*L=Z*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+=[%i!i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$R)Z)R)R)k!k!R)R)k!R)R)Z)R)R)Z)R)R)R)R)R)R)R)R)R)R)R)Z)R)R)R)R)",
"k!k!R)R)R)R)k!R)R)R)R)k!k!R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)R)k!R)R)R)k!R)R)R)R)R)R)R)R)l!X$:%:%X$X$X$X$X$R)R)R)R)R)R)k!R)Z)R)j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!)!X$X$:%:%:%[%[%[%3*f)}=)=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'!%X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$Z)R)R)Z)R)R)R)R)R)Z)R)R)R)R)R)R)R)R)R)k!R)R)R)R)R)R)R)R)R)R)Z)",
"R)k!k!R)R)R)k!R)k!R)R)R)R)k!R)R)R)R)R)R)k!R)R)R)R)R)R)R)Z)k!R)k!R)k!R)R)R)k!R)R)R)R)R)X$:%X$X$X$R)R)k!R)R)k!R)R)R)R)R)j'j'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!X$X$X$:%:%[%[%[%[%Q*r'x*`*`*`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$R)k!R)R)R)R)R)R)k!k!R)k!R)R)R)R)R)R)R)R)R)R)R)R)R)k!R)R)k!k!R)",
"R)R)R)k!k!R)R)R)R)R)R)R)k!R)k!R)k!R)R)k!R)R)k!k!R)R)R)R)n!R)k!R)k!R)R)R)k!R)k!k!k!k!R)X$X$X$X$k!k!k!R)R)k!R)R)R)k!k!j'k'k'j'k'p'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!X$X$:%:%:%[%[%[%[%G*f))=!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$k!R)k!k!k!R)n!k!R)R)k!R)R)k!k!k!R)k!R)k!k!R)R)k!R)R)k!R)R)R)k!",
"k!k!n!R)k!k!k!R)k!k!k!R)R)k!k!R)k!k!R)k!k!R)R)k!k!k!k!R)k!R)k!R)R)k!k!R)k!R)R)R)R)k!Z)X$X$X$R)R)R)R)k!R)n!k!k!R)R)j'j'k'#)j'k'p'p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!X$X$:%:%:%[%[%[%[%[%q=`*!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'i!X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$R)R)R)k!Z)R)k!k!R)k!k!n!R)R)k!R)k!R)R)k!k!R)k!k!R)k!k!R)R)k!",
"R)R)Z)k!R)R)n!k!R)k!R)k!k!R)R)n!n!R)k!R)R)k!k!k!k!R)R)R)R)R)R)k!n!k!R)n!R)k!k!k!k!k!n!X$X$R)k!k!R)k!k!k!Z)R)k!k!k!j'k'#)#)j'j'#)p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!)!X$X$X$:%:%[%[%[%[%[%G*4;!%!%!%!%!%!%!%!%!%!%!%!%!%+'X$X$X$[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$n!k!k!R)k!k!k!R)k!R)R)R)n!R)R)n!R)k!k!R)R)k!R)n!k!R)k!n!k!R)",
"R)n!n!n!k!R)n!n!R)k!k!k!k!R)Z)R)n!n!k!n!k!n!k!R)k!k!k!n!k!n!n!R)n!R)R)k!k!R)n!R)n!R)n!k!k!k!k!k!k!R)k!k!k!k!n!R)R)j'k'#)-)j'j'k'p'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!)!)!X$X$:%:%:%[%[%[%[%[%r-x*!%!%!%!%!%!%!%!%!%!%!%+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$n!R)k!n!R)n!k!n!R)R)R)R)n!k!R)n!n!k!n!n!R)n!Z)R)k!R)R)R)k!R)",
"k!k!R)R)k!k!R)R)n!n!R)R)k!n!n!k!R)R)n!R)R)k!R)k!n!k!k!R)n!k!R)k!R)n!k!R)R)n!R)k!R)R)R)n!n!k!n!n!n!n!n!n!n!R)R)n!k!j'k'#)-)j'j'k'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-))!X$X$X$X$m!:%:%[%[%[%[%y* =!%!%!%!%!%!%!%!%!%!%+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$R)n!R)R)n!R)n!R)k!k!k!k!k!R)k!R)R)n!R)R)k!R)n!k!n!k!k!n!k!k!",
"k!k!R)n!k!k!k!k!R)n!n!k!k!R)k!k!k!R)k!n!R)n!n!R)k!n!k!k!k!k!k!k!k!k!n!k!k!k!n!k!k!k!R)R)n!R)R)R)R)R)R)R)n!k!k!k!R)j'#)#)-)-)-)j'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-))!X$X$X$X$:%:%:%:%o!!%!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%p!0%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!k!R)k!R)k!n!n!k!k!k!n!k!k!k!R)k!k!n!k!k!k!R)k!k!R)n!n!k!",
"k!k!k!R)k!k!k!k!k!k!k!n!k!k!R)R)k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!k!k!k!k!n!k!k!k!k!k!k!k!k!R)k!k!k!k!k!k!k!R)k!R)k!k!j'#)#)-)-)-)j'p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)X$X$X$X$[%i![%q!!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'V-X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!k!k!k!k!k!k!k!R)n!k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!n!k!R)R)n!",
"n!n!k!n!n!n!k!k!k!k!R)n!k!n!k!n!n!n!k!n!k!k!k!n!k!n!n!n!n!R)n!k!n!k!k!k!n!k!n!n!n!n!k!k!k!k!k!k!k!n!k!k!n!k!n!k!n!n!j'#)-)-)-)-)p'p'p'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)r!X$X$X$X$[%+=!%!%!%!%!%!%!%!%!%+'+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!n!n!n!n!k!k!k!n!n!k!n!n!k!k!n!k!k!n!k!k!k!k!R)n!k!k!k!k!",
"R)k!n!k!R)k!n!n!n!n!k!k!n!k!s!k!k!k!k!k!n!n!n!R)n!k!R)k!k!k!R)n!R)n!n!n!k!n!k!k!k!k!n!k!n!n!n!n!n!k!n!n!R)n!k!n!R)k!j'#)#)-)-)-)-)y'p'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'!%X$X$X$X$X$!%!%!%!%!%!%!%!%+'+'X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$n!k!k!k!k!k!n!k!k!k!k!n!k!k!n!n!k!n!k!k!n!n!n!k!k!k!n!k!k!n!",
"k!k!k!n!n!k!k!k!k!s!k!k!k!k!n!k!k!k!k!k!k!k!n!k!n!k!k!n!n!k!k!n!k!k!k!k!k!n!k!k!n!k!n!k!k!k!k!k!k!k!k!k!k!k!k!k!k!n!k!j'j'#)-)j'-)-)y'y'y'y'y'y'y'y'y'j'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'[%[%[%X$X$x*5=!%!%!%!%!%!%+'X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$n!k!k!k!k!n!n!n!k!k!n!k!k!k!n!k!n!k!k!k!k!n!s!k!k!n!n!k!k!",
"k!k!n!k!R)k!k!k!k!R)k!s!n!n!k!n!n!n!s!k!k!k!s!k!R)s!n!k!k!n!n!k!n!k!k!n!k!k!n!n!k!k!k!k!s!n!n!k!n!k!k!s!n!k!s!n!s!k!k!j'j'j'-)j'k'-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'[%[%[%X$X$!%)=`*!%!%!%[%!%+'X$X$[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$[%X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!s!n!n!k!s!k!k!n!k!k!s!k!k!k!n!k!n!k!n!k!k!k!n!k!k!k!k!n!",
"n!k!n!k!s!n!n!n!s!n!k!k!k!k!k!k!k!k!n!n!s!k!s!s!k!k!n!k!k!k!n!k!s!s!s!s!k!k!k!k!s!s!n!k!k!k!s!k!s!s!k!k!n!k!k!k!k!s!n!s!j'j'j'j'k'#)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)F)j'[%[%[%[%X$X$e)%=!%!%[%[%+'X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$!%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$k!k!k!k!k!k!k!k!n!k!k!n!n!k!k!k!k!n!k!s!s!k!k!s!s!k!n!k!k!",
"s!k!k!s!k!k!k!k!k!k!k!s!n!s!s!n!s!n!k!k!k!k!k!k!n!s!k!s!s!s!k!s!k!k!k!k!n!s!s!s!k!k!s!n!n!n!n!n!k!k!n!s!k!k!s!n!s!n!k!k!n!v'v'j'j'k'p'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)j'j'[%[%[%[%[%X$t!G*{)!%[%i!+'X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'X$X$X$[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!n!n!s!n!s!n!n!k!s!n!s!s!s!s!s!s!k!s!k!k!n!n!k!k!k!s!s!s!",
"s!s!k!n!s!s!s!n!s!s!k!k!k!k!k!k!k!s!s!n!s!k!n!k!k!s!k!k!k!s!k!n!k!k!n!k!k!k!k!n!n!k!k!s!s!k!s!n!k!k!k!s!s!k!k!k!k!s!n!k!v'v'B'B'B'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%X$X$[%X$[%i![%X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!k!k!k!k!s!s!s!k!k!k!k!k!k!n!k!s!k!k!k!s!k!n!s!s!k!k!n!n!",
"n!k!s!k!n!k!k!k!n!k!s!s!n!s!s!n!s!k!k!k!k!s!k!s!n!k!n!k!n!k!n!k!s!s!k!s!n!n!n!k!k!n!s!k!k!k!k!k!s!s!s!k!k!n!s!s!n!k!k!s!v'B'B'B'B'B'j'k'p'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$[%X$i!i!X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%!%[%X$[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$k!s!n!s!n!k!k!k!s!s!n!n!n!k!k!n!k!n!s!s!k!s!k!k!k!n!k!k!k!",
"s!n!s!k!n!n!s!k!n!n!k!s!k!k!k!n!s!n!s!s!n!s!n!s!s!s!s!k!s!s!s!n!n!s!n!s!n!s!s!s!s!k!n!n!s!n!s!n!k!k!n!s!s!k!n!s!n!s!n!v'v'B'B'B'B'B'j'k'k'p'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$+'X$[%[%X$[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'X$X$X$!%!%[%X$[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!n!k!s!n!n!s!n!k!s!k!s!s!n!s!n!s!k!n!n!n!s!n!n!s!s!n!s!n!",
"n!k!n!s!s!s!n!s!s!k!n!k!s!s!s!k!k!s!n!k!s!k!s!k!n!k!n!s!n!k!k!s!k!n!k!k!s!k!n!n!k!n!s!s!n!s!n!k!n!s!n!n!k!s!k!k!s!n!s!v'v'B'B'B'B'B'B'j'j'p'#))!)!-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%X$X$X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'X$X$X$X$!%!%!%!%X$[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!n!k!s!s!n!k!s!k!s!k!n!s!k!s!k!s!k!s!k!n!s!s!k!n!s!k!s!",
"s!s!s!k!k!s!k!k!s!s!s!n!n!s!s!s!s!s!s!k!s!k!s!s!s!s!s!s!s!s!k!s!s!s!s!k!s!k!s!s!s!k!k!s!k!k!s!s!n!s!s!s!s!s!s!k!k!k!s!v'v'B'B'B'B'B'B'j'j'j'#))!)!)!-)y'y'y'y'y'y'y'y'y'-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'[%[%[%[%[%[%[%X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'u!>-m*%'X$X$X$!%!%!%!%!%X$X$[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$k!s!s!k!k!s!s!n!s!s!s!s!k!s!k!s!s!s!k!s!s!k!k!s!s!k!s!k!s!",
"s!k!k!s!s!k!s!s!s!k!n!s!s!n!s!n!k!s!n!s!s!s!n!k!n!k!n!k!k!s!s!s!k!s!n!s!s!s!k!s!k!s!s!k!s!s!s!k!s!k!k!k!k!s!n!s!s!s!s!v'B'B'B'B'B'B'B'B'j'j'j'v!)!)!-)-)y'y'y'y'y'y'y'-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'j'[%[%[%[%[%X$X$X$[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'w!+'p!+'!%!%!%!%!%!%!%X$[%[%[%X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$s!s!n!k!s!s!k!s!s!n!k!n!k!s!n!s!s!n!s!s!s!k!s!s!n!k!s!s!s!k!",
"s!s!s!s!s!s!s!k!s!s!n!s!s!n!s!s!k!s!s!s!s!s!s!s!s!s!s!s!n!s!n!s!k!s!n!n!s!s!n!s!s!s!s!n!s!n!s!k!s!s!s!s!n!s!s!s!n!k!s!v'B'B'B'B'B'B'B'B'B'B'j'j'v!)!)!)!-)-)-)-)-)-)-)-)-)-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$s!s!s!n!n!s!s!k!s!s!s!s!s!s!s!n!s!n!s!n!s!n!s!s!s!s!n!s!s!s!",
"s!s!s!s!s!n!n!s!s!k!s!k!s!s!s!s!s!s!n!k!n!k!s!k!s!s!s!s!s!k!s!s!s!s!s!s!n!s!s!s!n!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!v'B'B'B'B'B'B'B'B'B'B'B'j'j'v!)!)!-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)y'y'y'y'y'y'y'y'y'y'x!x!x!)!)!-)-)-)y'y'y'y'y'-)-)-)j'j'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$n!k!s!s!s!s!k!s!n!s!k!s!s!k!n!s!s!s!n!s!s!s!n!s!s!s!s!n!s!n!",
"s!n!s!s!s!s!s!s!s!s!s!k!s!k!n!s!k!s!s!s!s!s!s!s!k!s!s!s!s!n!n!s!k!s!s!s!n!s!s!s!k!s!s!s!n!s!s!s!n!s!s!s!k!s!n!s!s!s!v'v'B'B'B'B'B'B'B'B'B'B'B'B'j'v!v!)!)!)!)!)!)!)!)!)!)!)!)!)!v!v!v!j'j'j'j'j'j'j'j'j'j'j'v!v!x!)!)!)!)!)!)!)!-)y'y'-)-)-)v!v![%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!n!s!s!s!k!s!s!n!s!s!s!n!s!s!s!s!n!s!s!",
"s!s!k!n!s!s!s!s!s!s!s!s!k!y!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!k!n!s!y!s!s!s!s!s!s!k!s!n!n!s!y!s!s!s!s!j'v'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'v!v!)!)!)!)!)!)!)!)!v!v!v!v!v!v!v!j'j'j'j'j'j'A'A'A'A'A'j'j'j'v!v!)!)!)!)!)!)!)!)!-)-)-)_!v![%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!n!s!s!s!s!s!s!k!s!n!s!s!s!s!y!k!s!s!s!s!s!s!n!s!k!s!s!s!s!",
"s!y!s!s!s!s!s!s!n!s!s!y!s!s!s!z!s!s!s!s!s!s!n!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!k!s!s!s!y!s!s!s!s!s!s!s!j'j'j'v!v!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'v!)!)!)!)!)!j'j'j'j'j'j'j'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'v!)!)!)!)!)!)!)!A!)!v![%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$X$i!X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!k!y!s!s!s!s!s!",
"s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!s!s!s!s!s!s!z!s!s!s!s!s!y!s!s!s!s!s!s!z!s!j'j'v!v!x!x!x!x!x!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'v!v!v!v!v!j'j'j'j'j'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'v!v!)!)!)!)!)!)!)!v![%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$X$X$[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!",
"s!s!s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!z!n!s!s!s!s!s!z!s!s!s!k!j'j'j'x!x!x!x!x!x!x!x!v!v!B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'j'j'j'j'j'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'j'j'j'j'j'-))!(!v!j'[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%X$X$[%[%[%X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!s!s!s!s!s!s!y!s!s!s!s!s!s!s!z!n!s!s!s!s!s!s!z!n!s!s!s!s!s!s!",
"z!y!s!s!s!s!y!s!s!z!n!z!s!z!s!s!z!s!s!s!s!s!z!s!s!s!s!s!s!z!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!s!B!v!v!x!x!x!x!x!x!x!x!x!x!)!j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'j'j'j'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'B'j'j'j'j'j'[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$s!s!s!s!s!z!s!s!z!s!s!y!z!s!s!s!s!s!s!s!s!s!s!s!s!s!s!y!y!s!s!s!",
"s!z!z!z!z!n!y!s!s!z!s!s!s!s!s!s!s!z!n!s!s!s!z!s!s!z!s!z!n!s!y!s!s!s!s!s!s!s!z!z!z!s!z!s!s!z!s!s!C!v!v!x!x!x!x!x!x!x!x!x!x!x!-)j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'D!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$s!z!s!z!k!s!s!s!z!s!s!s!s!s!z!s!y!s!s!y!z!s!s!s!s!s!z!n!z!z!s!s!",
"z!s!s!n!s!z!s!s!s!s!s!s!s!s!z!s!y!s!y!y!z!s!n!z!y!s!s!s!y!s!s!s!s!z!s!s!z!y!s!s!s!s!n!z!s!n!E!F!v!v!x!x!x!x!x!x!y'y'y'y'y'-)-)-)j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'G!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$z!s!s!s!z!z!s!s!s!y!s!s!y!s!s!s!s!y!z!s!s!y!y!s!y!s!s!s!s!s!y!y!",
"s!s!y!s!s!s!y!s!s!s!z!s!y!s!s!s!s!z!s!s!s!y!s!s!s!y!s!s!s!z!y!y!s!s!z!s!s!s!s!s!s!y!s!s!y!s!H!v!v!x!x!x!x!x!x!y'y'y'y'y'y'-)-)-)-)j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!J!v'[%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$y!y!s!s!s!y!s!s!s!z!y!z!s!s!y!s!s!s!s!s!s!z!s!s!y!s!z!s!s!z!z!s!",
"s!s!s!y!y!z!z!z!y!z!s!z!z!s!y!z!y!s!z!y!z!s!s!z!s!z!y!s!z!s!z!z!s!z!s!y!y!y!y!y!z!s!s!z!s!K!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'-)-)-)-)j'j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'G!I!v'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$y!s!z!y!y!y!s!y!y!y!s!s!s!z!z!z!z!z!s!s!s!z!s!z!z!z!y!s!s!s!s!s!s!",
"z!z!z!s!s!s!s!z!s!s!s!s!z!z!s!z!s!s!s!s!z!y!s!z!s!z!z!s!s!s!s!s!s!y!s!z!z!z!z!s!z!y!s!L!v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'-)-)-)-)j'j'j'j'B'B'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!I!v'[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$z!s!z!z!z!z!z!s!z!s!z!s!s!s!s!s!s!z!z!z!s!y!s!s!s!z!s!z!z!s!y!z!y!",
"s!s!s!z!z!y!y!s!z!z!y!y!s!s!z!s!y!y!z!z!s!z!z!s!s!s!s!y!z!y!y!z!y!z!z!s!s!s!s!y!s!z!z!v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)j'j'j'j'B'B'B'B'B'B'B'B'B'B'B'A'A'A'A'M!M!M!A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'A'I!A'v'[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$z!s!s!s!s!s!s!s!z!s!z!s!s!y!s!y!s!y!s!s!s!s!z!y!y!z!s!z!s!y!z!z!s!z!",
"y!z!s!s!z!z!s!s!s!z!z!z!s!s!y!z!z!s!s!y!s!y!y!z!y!y!s!s!z!z!s!z!s!s!z!s!y!z!z!s!s!s!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'j'B'B'B'B'j'j'j'j'j'j'j'j'v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!v!j'j'j'j'j'j'j'j'j'j'j'j'`*[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$y!y!s!y!y!z!s!s!y!y!y!z!z!z!z!z!z!y!z!y!z!s!z!z!s!y!y!y!z!s!s!y!s!y!",
"z!y!z!y!s!s!z!y!y!s!s!s!z!y!z!s!s!z!y!z!z!y!z!y!z!z!z!z!s!y!z!s!y!y!s!z!z!y!s!z!L!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)j'j'v!v!v!v!v!v!v!v!v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!v!v!v!v!v!j'j'v!v!)!v!v!j'[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$y!z!z!z!z!z!s!z!z!z!s!z!y!s!y!s!y!s!z!y!z!y!y!s!s!y!z!z!z!s!z!z!z!z!z!",
"z!y!z!z!y!y!z!z!z!z!y!y!z!s!z!y!y!z!z!y!s!y!z!s!s!y!y!y!s!y!z!z!z!z!z!s!z!y!y!N!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)j'v!v!v!v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!x!x!x!x!x!x!x!)!)!)!O!v!v!j'[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$y!s!X$X$s!y!y!y!s!z!y!z!y!z!z!y!z!s!y!y!y!z!z!y!z!y!s!s!z!y!y!s!y!s!y!",
"y!z!y!y!z!z!y!y!s!y!z!z!y!y!y!z!z!s!s!z!z!z!s!z!z!z!y!z!z!z!y!y!y!y!y!y!s!z!P!v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)j'v!v!v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!x!)!-)-))!~!Q!v![%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%[%[%[%[%[%X$X$X$X$+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$y!y!z!X$X$y!z!z!z!z!y!z!y!z!s!s!z!y!z!z!z!z!y!y!z!y!z!y!z!y!y!z!z!y!y!z!",
"y!z!z!z!y!z!z!z!z!y!y!z!z!z!y!y!z!z!z!z!y!z!y!y!y!z!y!y!y!z!z!z!y!y!z!z!z!j'v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)j'j'v!)!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!-)-))!)!)!v!v![%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%X$X$X$X$X$+'i!X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$z!y!X$X$X$y!y!s!y!z!y!z!z!z!z!y!z!y!s!y!z!z!z!y!z!y!z!y!y!z!s!y!z!z!y!y!",
"z!z!y!y!z!y!z!y!z!z!z!y!y!y!z!z!y!y!y!y!z!y!z!z!z!z!z!z!z!y!y!y!z!z!j'j'v!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)j'v!v!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!v!v!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$z!z!X$X$X$X$z!z!z!z!z!z!y!y!z!y!z!y!z!z!z!y!z!z!z!z!z!y!z!z!z!z!z!y!z!z!z!",
"y!z!z!y!z!y!z!y!y!y!z!z!z!z!y!R!z!z!z!y!z!z!R!y!y!z!z!y!z!z!z!z!z!j'j'x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)j'v!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$z!y!X$O*X$|&X$y!R!y!y!y!z!z!y!R!z!z!R!z!y!z!y!y!z!y!y!R!y!R!y!y!y!z!y!z!z!z!",
"z!R!y!z!y!z!R!R!R!z!y!R!z!y!z!y!y!y!y!z!R!y!y!z!z!y!y!z!y!z!z!j'v!v!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)j'j'v!v!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)_!v!j'j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%!%!%!%!%!%!%!%!%!%!%[%[%[%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$y!z!X$S!X$g=X$z!y!R!R!z!z!y!R!z!y!y!y!y!z!y!z!z!y!z!z!z!z!y!z!R!R!z!R!y!y!y!",
"y!R!R!R!z!y!z!z!R!z!y!y!R!z!z!R!R!R!z!y!z!z!R!z!z!R!y!R!y!j'v!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'n)y'j'v!v!v!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$[%[%[%[%[%[%[%[%[%[%X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%x%X$X$X$z!T!X$O*U!X$**X$z!z!y!z!y!z!y!y!z!z!z!R!y!z!z!z!R!z!z!y!R!z!z!y!z!y!z!z!R!R!z!",
"z!z!y!z!y!z!y!y!y!R!z!R!z!y!R!z!z!z!y!z!R!y!z!y!R!z!R!j'v!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'n)V!)!)!)!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!v!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$X$R!X$X$z;q,;>X$X$X$z!z!z!R!z!z!R!z!R!R!y!z!R!R!y!y!z!y!y!z!y!z!y!z!z!R!y!z!z!z!R!",
"z!z!z!R!R!R!R!z!z!R!z!y!R!y!R!y!z!R!R!y!R!y!R!z!j'j'v!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!v!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%X$X$X$X$z!X$X$X$W!1,X$f,X$X!y!R!y!R!R!z!R!y!z!R!z!z!z!R!R!y!R!R!R!z!y!R!R!y!y!R!y!y!z!y!z!",
"R!R!y!z!z!z!z!R!y!y!R!R!z!z!y!R!R!R!z!z!z!j'j'j'j'x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!~!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$X$X$Y!X$X$X$0%Q&6%X$k-0%X$R!R!y!R!z!y!y!z!R!y!R!y!R!y!z!R!R!R!z!z!R!R!R!z!R!R!z!R!R!y!R!R!",
"R!R!R!y!R!R!y!R!z!y!z!y!R!z!R!y!Z!j'j'v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!_!v!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%X$X$X$X$X$X$X$X$6%`!6%6%X$$*X$ ~R!R!z!R!R!R!y!z!R!z!R!y!R!R!z!z!z!R!y!z!R!z!y!R!z!R!z!R!R!z!z!R!",
"z!R!z!R!R!y!.~R!R!R!R!v!v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-))!_!+~j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$!%!%!%!%!%!%!%!%!%!%X$X$X$X$X$X$X$X$X$!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$X$6%6%6%6%6%:%X$O=X$X$@~R! ~R!y!z!R!.~R!R!R!z!R!z!z!R!R!y!z!R!y!z!y!.~R!R!y!R!z!R!R!y!z!",
"j'R!R!z!R!j'j'v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-))!_!(!j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%X$X$X$X$!%!%!%!%!%!%[%[%[%[%[%X$X$X$+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$6%6%6%6%6%6%6%6%6%!%X$X$[%#~X$X$z! ~z!R!R!z!z!z!R!z!R!R!R!y!y!R!.~R!R!R!y!.~z!z!R!R!y!R!R!R!R!R!R!",
"v!v!v!v!v!v!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)$~A!v![%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'i![%!%!%!%!%!%!%!%X$X$X$X$X$X$[%[%[%X$X$X$X$+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$6%6%6%6%6%6%6%!%!%!%!%X$[%[%9'X$X$ ~y! ~y!R!R!R!R!R!z!R!R!R!R!R!.~R!z!z!R!R!.~R!y!R!y!R!.~R!z!R!R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)_!%~v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'i!i!i!i![%[%[%[%[%[%[%[%[%[%[%X$X$X$X$i!+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%6%!%!%!%!%!%!%!%!%X$[%[%[%&~X$*~.~ ~=~R!z!R!y!R!R!R!z!z!R!R!z!y!R!R!z!R!z!z!R!y!.~R!R!z!R!y!R!z!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-))!)!-~j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%i!X$X$X$X$X$i!i!i!i![%[%[%[%[%[%[%X$X$X$+'+'+'i!+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%6%!%!%!%!%!%!%X$X$X$[%[%[%X$X$;~>~R! ~R!R!R!R!.~R!R!R!R!R!R!R!R!.~R!R!R!R!R!R!R!.~R!R!R!R!R!.~R!R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y)-))!(!-~j'[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'X$X$X$X$X$X$i!i!i![%[%[%X$X$X$+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%6%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$,~ ~R!'~R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!)~R!R!R!",
"x!x!x!x!x!x!x!x!x!x!x!x!x!x!x!y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'z)-))!_!!~j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'X$X$X$X$X$X$X$X$X$X$+'+'+'!%+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%!%!%!%!%!%!%!%!%!%!%[%[%[%:%X$X$,~ ~ ~~~R!R!R!R!R!R!R!R!)~)~R!R!R!R!R!R!)~R!R!R!R!R!R!R!R!)~R!R!R!R!R!R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y){~]~)!)!!~j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%!%!%!%!%!%!%!%!%[%[%[%[%:%:%X$^~R!/~(~)~R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!R!)~)~R!R!R!R!R!R!)~R!R!R!R!R!R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)y)]~)!(!v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'+'+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%:%X$X$_~R!R!R!R!)~)~R!R!R!R!R!R!R!)~.~)~R!R!)~R!.~R!R!.~R!R!R!R!R!R!R!R!R!R!R!.~R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y)-)-))!)!v!j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%+'+'+'+'+'+'!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%X$X$X$R!:~~~)~.~R!.~R!R!R!R!)~R!R!R!R!R!.~R!R!R!R!R!R!R!R!)~.~R!R!.~.~R!R!R!.~R!.~R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)]~-)y))!_!v!j'j'[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%:%:%X$X$X$X$R!.~R!.~R!.~R!.~.~)~)~R!)~R!)~R!R!R!R!R!.~R!R!.~R!.~.~R!)~)~R!R!.~)~R!R!R!R!.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)O)-)F))!)!_!j'j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%:%[%X$X$X$X$.~R!.~R!R!R!R!R!.~.~.~R!.~)~.~)~)~R!.~.~R!)~.~R!.~R!R!R!.~.~R!)~R!.~.~R!)~R!R!)~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)F)-)F))!(!j'j'[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%:%:%:%X$X$X$X$_~.~R!)~R!.~.~.~.~R!R!R!R!.~R!.~R!.~R!.~R!R!)~.~R!.~R!)~.~)~R!R!.~.~R!.~R!.~.~.~R!.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)F)-)F))!_!j'[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%:%:%:%:%:%:%X$X$X$X$<~[~ ~.~.~.~R!R!R!R!.~R!R!.~R!.~R!.~.~.~R!.~.~.~R!.~R!R!.~R!.~.~R!R!.~.~R!.~R!R!R!.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)F))!)!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%:%:%:%==}~X$X$X$|~ ~R!_~1~R!.~R!.~R!.~.~.~.~.~R!.~R!.~R!R!.~.~R!.~.~.~R!.~.~R!.~R!R!.~.~R!R!.~R!.~.~.~.~R!R!",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-))!)!j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%2~X$X$X$3~4~1~_~.~.~.~R!.~R!.~.~R!R!R!)~.~R!.~R!.~.~R!.~.~R!R!.~.~R!R!.~R!.~.~.~R!.~.~R!.~R!.~.~R!.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)_!)!j'j'[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%[%[%[%[%[%[%[%:%:%:%X$X$X$X$X$5~.~.~ ~6~R!R!R!R!.~.~.~.~R!.~.~.~.~.~.~)~.~)~.~.~.~.~.~.~R!.~.~.~.~.~R!.~R!.~.~.~.~.~.~R!R!.~.~.~)~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-))!)!w)w):%:%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$:%:%:%:%:%:%:%:%:%:%:%:%:%[%:%:%:%:%:%:%==X$X$X$X$7~:~8~.~R!.~.~R!.~.~.~.~.~R!.~)~.~.~.~.~.~)~.~.~.~.~)~.~)~R!.~.~.~.~.~)~)~.~.~.~.~.~.~)~.~)~.~.~.~.~)~R!.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-))!_!(!j'w):%:%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$X$X$X$X$X$X$X$X$X$:%:%:%:%:%:%:%:%X$X$X$X$X$X$X$9~1~_~_~.~)~_~.~.~.~.~.~.~.~.~.~)~.~.~.~.~)~)~.~.~.~.~.~.~)~.~.~.~.~.~)~)~.~.~.~.~)~.~R!.~.~)~.~.~.~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!0~j'j'X$:%:%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$X$a~.~.~.~.~.~.~.~.~.~.~.~.~)~.~.~.~.~.~)~.~.~.~.~.~.~.~.~.~.~.~.~)~)~.~.~.~.~.~)~.~.~.~b~.~.~.~.~.~.~.~)~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'X$X$:%:%[%[%[%[%[%[%!%!%!%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%X$X$X$c~>~.~d~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'X$X$X$:%[%[%[%[%[%[%!%6%!%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$b~b~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~b~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~b~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'X$X$X$:%:%[%[%[%[%[%!%6%6%:%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%X$X$X$X$X$e~.~_~.~f~c~.~.~.~.~.~.~.~.~b~.~.~b~.~.~.~.~.~.~.~.~.~.~b~.~.~b~.~.~.~.~.~.~.~.~.~.~b~.~.~.~b~b~.~b~.~.~.~.~b~.~.~.~.~.~.~.~.~b~.~b~b~.~.~.~.~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'.~b~g~X$X$:%:%[%[%[%[%!%6%6%6%:%X$:%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$.~b~b~b~b~.~.~b~.~b~.~.~b~b~.~b~.~b~b~.~.~.~.~b~.~.~.~b~.~b~.~b~b~.~h~h~.~.~b~.~b~b~.~.~.~b~.~.~b~h~.~.~b~.~.~.~b~b~b~b~.~b~.~.~b~.~b~b~.~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'b~i~.~X$X$:%:%:%[%[%[%[%!%6%6%X$X$X$:%:%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%!%!%!%6%6%6%6%X$X$X$X$X$X$.~.~.~b~b~.~b~.~b~.~.~.~.~.~h~.~h~b~b~b~b~.~h~h~b~.~h~.~b~.~.~b~.~.~b~b~.~b~.~.~b~.~.~h~.~.~h~.~h~.~h~b~b~h~.~.~.~.~.~h~b~.~h~.~.~.~.~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'h~.~b~b~X$X$:%:%:%[%[%[%[%!%6%X$X$X$X$:%:%[%[%[%[%[%[%[%[%[%[%[%[%!%!%!%!%!%!%!%!%6%6%6%:%X$X$X$X$X$X$X$X$X$X$X$X$X$b~.~b~.~.~.~.~.~h~.~.~.~.~.~.~h~.~.~h~b~.~.~.~.~.~h~.~.~h~h~h~.~.~.~h~h~.~.~.~h~.~h~.~.~b~b~.~h~.~.~.~h~.~b~.~b~.~h~.~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'h~.~b~.~.~b~X$X$:%:%:%[%[%[%[%6%6%X$X$X$X$X$:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%:%:%:%:%:%:%:%:%X$X$X$X$X$X$X$b~h~h~.~h~.~h~.~b~.~h~b~b~.~.~.~h~.~h~h~h~b~b~h~.~.~b~.~.~.~.~h~b~.~.~b~.~.~.~.~.~h~.~.~h~h~.~b~b~.~.~.~h~b~.~b~.~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!v!j'b~h~b~h~.~.~b~X$X$:%:%:%[%[%[%[%6%6%X$.~X$X$X$X$:%:%:%:%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%[%:%[%[%:%:%:%:%:%:%X$X$X$b~b~h~.~.~b~.~b~.~b~.~h~.~.~.~b~b~b~.~b~.~.~.~.~h~.~b~b~.~.~b~b~h~.~.~b~b~.~h~h~b~b~b~.~b~h~.~.~b~.~b~h~b~h~.~h~h~h~.~h~h~.~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!v!j'.~.~h~b~b~b~h~b~X$X$[%:%:%[%[%:%:%6%X$X$b~.~X$X$X$X$X$:%:%:%:%:%:%[%:%:%:%:%:%[%[%[%[%[%[%[%[%[%[%:%:%:%:%X$X$j~k~h~h~.~b~b~h~b~.~b~b~h~b~b~b~h~h~.~h~b~.~b~b~b~h~.~.~b~h~b~b~h~b~b~b~b~h~b~h~.~.~b~h~.~b~h~.~b~.~b~h~h~.~.~.~b~.~.~.~h~.~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'.~.~b~h~h~.~h~h~h~X$X$X$:%:%:%[%:%:%6%X$X$.~.~X$X$X$X$X$[%[%[%[%:%:%:%:%[%[%[%[%[%[%[%[%[%[%[%:%:%:%l~X$X$m~_~n~.~.~h~h~h~.~h~h~h~h~b~.~h~h~b~b~h~b~h~h~h~h~h~.~b~b~h~b~h~h~.~h~.~h~h~.~h~.~b~b~h~.~h~.~.~b~h~b~b~b~.~b~h~b~h~b~b~h~b~b~b~h~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'h~h~h~.~b~b~b~b~.~X$X$X$X$:%:%:%[%:%:%6%X$h~b~b~o~X$X$X$X$X$X$X$X$X$X$:%:%:%:%:%:%:%:%:%:%:%:%:%:%X$X$X$k~p~h~o~b~b~b~.~.~b~b~b~.~.~.~h~.~.~b~.~b~.~b~b~.~.~.~b~b~h~.~.~b~.~b~.~b~.~.~b~b~b~h~h~.~b~b~h~b~h~.~b~h~h~b~h~b~h~.~h~h~b~.~h~h~b~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!j'j'b~b~h~.~h~.~h~h~b~b~X$X$X$X$:%:%:%:%:%:%X$X$b~h~h~n~q~h~X$X$X$X$X$X$X$X$X$X$X$X$X$:%:%:%X$X$X$X$X$r~k~c~h~o~h~h~h~b~b~b~h~b~b~b~b~h~b~b~h~h~h~b~h~.~h~b~h~b~h~h~b~h~h~h~b~b~b~h~b~h~h~b~h~b~.~h~h~h~b~h~b~b~h~.~.~h~b~.~b~b~b~b~h~h~.~.~h~.~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~b~b~h~b~h~.~b~h~h~b~b~X$X$X$:%:%:%[%:%:%X$X$_~.~h~s~b~h~b~b~t~b~b~b~X$X$X$X$X$X$X$X$X$X$u~s~k~_~b~b~h~.~b~b~b~b~h~h~h~b~h~h~h~h~b~b~h~b~.~b~h~b~t~b~h~b~h~b~.~h~b~b~.~h~h~h~b~h~b~b~h~b~h~h~b~b~.~h~b~h~h~.~h~b~b~b~h~h~h~h~b~.~b~h~h~b~h~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!)!j'j'h~b~b~h~b~b~b~b~b~b~h~b~h~X$X$X$X$:%:%:%:%:%X$X$v~b~h~b~h~h~b~h~b~b~b~b~b~h~b~h~b~h~b~h~b~b~b~h~h~h~b~t~h~b~h~h~b~.~b~b~b~.~b~b~h~h~b~h~h~h~b~h~b~h~b~b~b~h~h~b~b~h~h~b~b~h~h~b~b~h~b~h~b~b~b~b~h~b~h~b~b~t~b~h~h~h~b~b~b~b~h~t~h~b~b~b~b~b~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'j'b~t~h~b~h~t~h~h~h~h~b~b~b~h~h~X$X$X$:%:%:%:%:%X$X$w~b~h~h~b~h~b~h~h~h~h~h~b~h~b~h~b~h~b~h~h~h~b~b~b~h~b~b~h~b~b~h~t~t~h~h~t~h~t~b~t~h~b~t~b~h~b~h~b~b~h~h~b~b~h~t~b~b~h~h~b~b~h~t~b~h~b~h~h~t~h~b~b~b~h~h~b~h~b~b~b~h~h~h~h~b~b~t~h~b~h~h~h~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~b~b~t~b~b~b~b~b~b~h~t~h~b~b~b~b~X$X$X$X$X$:%:%:%X$X$x~b~h~b~h~h~b~b~b~b~h~b~h~t~t~b~h~b~b~b~h~h~h~t~h~h~b~h~h~h~b~b~b~b~b~b~b~h~b~b~h~b~t~b~t~b~h~h~b~t~h~t~b~h~t~h~b~b~h~h~b~b~h~h~h~h~t~b~b~h~h~h~b~b~h~b~h~b~h~h~b~b~b~h~b~b~t~t~h~b~b~b~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~h~t~b~t~h~t~h~h~t~b~h~b~h~t~t~t~h~t~X$X$X$X$X$:%X$X$X$X$b~h~t~b~t~t~t~h~h~t~h~b~b~h~b~t~h~h~t~t~b~b~t~t~h~t~b~b~h~h~t~h~h~h~h~b~h~h~b~h~b~h~b~h~b~t~t~b~b~b~h~b~b~b~t~h~t~b~t~h~b~b~b~b~b~h~t~t~t~h~h~h~b~t~t~h~b~t~t~t~h~h~h~h~b~b~b~t~h~t~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~h~h~b~h~h~h~h~h~t~b~t~t~b~h~h~b~t~h~t~y~X$X$X$X$X$X$X$X$X$b~h~h~b~b~t~t~b~b~h~t~t~h~b~t~t~b~b~h~h~b~b~t~b~t~t~b~t~h~t~t~t~t~t~b~h~t~b~h~t~h~t~t~b~b~h~t~h~t~h~h~h~h~t~b~h~b~h~t~t~t~h~t~h~b~b~b~b~b~t~h~b~b~t~h~b~h~h~h~t~b~b~h~h~h~h~t~t~t~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'b~b~t~t~b~h~t~b~b~b~t~h~b~t~b~h~t~b~b~h~h~b~z~X$X$X$X$X$X$X$X$t~b~t~h~b~b~h~t~t~h~b~t~t~b~b~t~h~b~t~h~t~b~t~h~h~t~b~t~b~b~b~b~h~h~t~b~t~t~b~t~b~b~t~h~t~h~t~b~t~b~t~t~b~h~t~h~b~h~b~h~h~b~t~t~h~h~t~t~b~t~t~t~b~t~h~b~t~t~b~t~t~t~t~b~b~b~b~t~b~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j't~b~h~t~b~b~t~t~t~t~b~h~h~t~b~t~t~t~t~b~t~A~B~t~t~t~t~b~X$X$X$X$h~t~t~t~t~h~b~t~t~b~h~t~h~h~t~t~b~t~b~t~h~t~b~h~t~b~h~t~t~t~t~t~b~t~h~b~t~b~t~t~h~t~b~t~b~t~b~t~b~b~t~t~h~t~t~b~t~t~t~t~b~h~t~t~h~h~t~b~h~h~t~b~t~t~b~b~h~h~b~b~t~t~t~h~t~b~t~t~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~t~t~h~t~t~h~t~h~b~t~t~t~h~t~h~h~t~b~t~t~t~t~h~b~h~h~t~h~b~t~t~b~h~h~h~b~t~t~b~b~t~t~h~t~t~b~h~t~b~t~h~t~b~t~b~h~t~t~h~h~h~b~b~t~h~t~t~h~t~t~h~t~b~t~b~t~h~t~h~t~t~t~b~t~h~h~t~h~b~b~h~t~t~h~b~t~t~h~t~t~t~h~t~b~b~t~t~t~t~t~t~b~t~h~t~h~t~t~h~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)j'h~b~t~t~h~t~h~t~t~t~h~b~t~t~b~t~b~t~t~h~t~b~t~t~b~b~t~t~t~h~h~t~b~t~t~t~b~h~t~t~t~b~t~b~b~t~t~h~t~h~t~b~t~h~t~t~h~t~t~t~t~t~t~h~t~t~h~t~h~h~t~b~t~h~t~t~t~t~t~h~h~b~t~t~t~t~b~t~t~t~t~b~b~t~t~t~t~t~b~t~b~t~t~t~t~h~h~h~b~h~h~t~b~t~t~t~h~h~b~t~",
"y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'y'-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-)-))!)!-)-)t~t~b~h~t~b~t~b~h~t~b~t~b~h~t~t~t~t~h~t~t~t~h~t~t~t~h~b~t~t~t~t~t~t~t~t~t~t~t~t~h~t~t~t~t~t~t~t~h~t~h~t~t~t~t~t~t~b~t~b~b~t~t~t~b~b~t~t~t~t~h~t~t~t~b~t~h~b~t~t~t~t~t~b~b~t~t~t~h~t~t~t~t~t~b~t~b~t~t~h~t~b~t~h~t~t~t~t~t~t~t~t~t~t~b~b~t~b~t~t~"};

Deleted runt/libs/NAMESPACE.MF.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Run-time Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: This namespace contains the extra 
 run-time libraries which could be used by user applications and 
 system applications/libraries as needed.

Deleted runt/libs/all-vms/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: b1e1bc61-6e1f-43be-ac98-cdcb66dbeb02
X-SquirrelJME-Error: AL
X-SquirrelJME-Name: All Virtual Machines
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This is a virtual package which depends on 
 all the virtual machines which are available.
X-SquirrelJME-Depends: springcoat-vm summercoat-vm
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/collections/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: f119ce1b-cd4f-4c7b-a229-5f12448f5d1c
X-SquirrelJME-Error: AC
X-SquirrelJME-Name: Collections
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This class contains various collections 
 which can be used to store objects.
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/collections/net/multiphasicapps/collections/ArrayUtils.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;

/**
 * This contains some utilities for arrays.
 *
 * @since 2017/11/30
 */
public final class ArrayUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/30
	 */
	private ArrayUtils()
	{
	}
	
	/**
	 * Returns an unmodifiable list over the given array.
	 *
	 * @param <T> The type of list to return.
	 * @param __e The array to wrap.
	 * @return The unmodifiable list.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	@SuppressWarnings({"unchecked"})
	public static final <T> List<T> unmodifiableList(T... __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayList<T>(__e, 0, __e.length);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/CloseableList.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
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



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;

/**
 * This is based on top of {@link ArrayList} and is the same interface except
 * that it is {@link Closeable} and on close will attempt to close all
 * elements within the list.
 *
 * @since 2017/11/28
 */
public class CloseableList<T extends Closeable>
	extends ArrayList<T>
	implements Closeable
{
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
		throws IOException
	{
		int count = 0;
		IOException defer = null;
		for (int i = 0, n = this.size(); i < n; i++)
			try
			{
				T v = this.get(i);
				if (v != null)
					v.close();
			}
			catch (IOException e)
			{
				if (defer == null)
					defer = e;
				count++;
			}
		
		// {@squirreljme.error AC01 There was at least one exception which
		// occurred while closing the list. (The number of exceptions thrown)}
		if (defer != null)
			throw new IOException(String.format("AC01 %d", count), defer);
	}
	
	/**
	 * Adds the specified item to the list and returns it.
	 *
	 * @param __t The element to add.
	 * @return {@code __t}.
	 * @since 2017/11/28
	 */
	public final T addThis(T __t)
	{
		this.add(__t);
		return __t;
	}
	
	/**
	 * Adds the specified item to the list and returns it.
	 *
	 * @param <E> The class to cast to.
	 * @param __t The element to add.
	 * @param __cl The class to cast to on return.
	 * @return {@code __t} cast to {@code E}.
	 * @throws NullPointerException If no class was specified.
	 * @since 2017/11/28
	 */
	public final <E extends T> E addThis(E __t, Class<E> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.add(__t);
		return __cl.cast(__t);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/EmptyIterator.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
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






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator which is empty.
 *
 * @since 2016/04/10
 */
public final class EmptyIterator
	implements Iterator
{
	/** The empty iterator. */
	private static Reference<Iterator> _EMPTY_ITERATOR;
	
	/**
	 * Initializes the empty iterator.
	 *
	 * @since 2016/04/10
	 */
	private EmptyIterator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public boolean hasNext()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Object next()
	{
		// {@squirreljme.error AC02 The empty iterator contains no elements.}
		throw new NoSuchElementException("AC02");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public void remove()
	{
		// {@squirreljme.error AC03 Cannot remove elements from the empty
		// iterator.}
		throw new UnsupportedOperationException("AC03");
	}
	
	/**
	 * This returns an iterator which contains nothing.
	 *
	 * @param <V> The type of values to iterate over.
	 * @return The empty iterator.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> Iterator<V> empty()
	{
		// Get reference
		Reference<Iterator> ref = _EMPTY_ITERATOR;
		Iterator rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			_EMPTY_ITERATOR = new WeakReference<>(
				(rv = new EmptyIterator()));
		
		// Return it
		return (Iterator<V>)rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/EmptyList.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

/**
 * This is a list which contains no elements.
 *
 * @since 2016/04/10
 */
public final class EmptyList
	extends AbstractList
	implements RandomAccess
{
	/** The empty list. */
	private static Reference<List> _EMPTY_LIST;
	
	/**
	 * Initializes the empty list.
	 *
	 * @since 2016/04/10
	 */
	private EmptyList()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsAll(Collection __c)
	{
		return __c.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Object get(int __i)
	{
		// {@squirreljme.error AC04 The empty list contains no elements.}
		throw new IndexOutOfBoundsException("AC04");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int indexOf(Object __o)
	{
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/01
	 */
	@Override
	public Iterator iterator()
	{
		return EmptyIterator.empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int lastIndexOf(Object __o)
	{
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * This returns a list which contains nothing.
	 *
	 * @param <V> The type of values the list contains.
	 * @return The empty list.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> List<V> empty()
	{
		// Get reference
		Reference<List> ref = _EMPTY_LIST;
		List rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			_EMPTY_LIST = new WeakReference<>(
				(rv = new EmptyList()));
		
		// Return it
		return (List<V>)rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/EmptyMap.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * This is a map which contains no entries.
 *
 * @since 2016/05/12
 */
public class EmptyMap
	extends AbstractMap
{
	/** The empty map. */
	private static Reference<Map> _EMPTY_MAP;
	
	/**
	 * Initializes the empty map.
	 *
	 * @since 2016/05/12
	 */
	private EmptyMap()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsValue(Object __v)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Set<Map.Entry> entrySet()
	{
		return EmptySet.<Map.Entry>empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Object get(Object __k)
	{
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Set keySet()
	{
		return EmptySet.<Object>empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public Collection values()
	{
		return EmptySet.<Object>empty();
	}
	
	/**
	 * This returns an empty and unmodifiable map.
	 *
	 * @param <K> The key type to use.
	 * @param <V> The value type to use.
	 * @return The unmodifiable and empty map.
	 * @since 2016/05/12
	 */
	@SuppressWarnings({"unchecked"})
	public static <K, V> Map<K, V> empty()
	{
		// Get reference
		Reference<Map> ref = _EMPTY_MAP;
		Map rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			_EMPTY_MAP = new WeakReference<>((rv = new EmptyMap()));
		
		// Return it
		return (Map<K, V>)rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/EmptySet.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
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
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which cannot be changed and has no entries.
 *
 * @since 2016/04/10
 */
public final class EmptySet
	extends AbstractSet
{
	/** The empty set. */
	private static Reference<Set> _EMPTY_SET;
	
	/**
	 * Initializes the empty set.
	 *
	 * @since 2016/04/10
	 */
	private EmptySet()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsAll(Collection __c)
	{
		return __c.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public Iterator iterator()
	{
		return EmptyIterator.empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/10
	 */
	@Override
	public int size()
	{
		return 0;
	}
	
	/**
	 * This returns an empty and unmodifiable set.
	 *
	 * @param <V> The element type used by the set.
	 * @return The unmodifiable and empty set.
	 * @since 2016/04/10
	 */
	@SuppressWarnings({"unchecked"})
	public static <V> Set<V> empty()
	{
		// Get reference
		Reference<Set> ref = _EMPTY_SET;
		Set rv;
		
		// Needs creation?
		if (ref == null || null == (rv = ref.get()))
			_EMPTY_SET = new WeakReference<>((rv = new EmptySet()));
		
		// Return it
		return (Set<V>)rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/EnumSet.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
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














































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which allows enumeration values to be stored in it efficiently
 * using only a bit field.
 *
 * @since 2018/03/21
 */
public final class EnumSet<T extends Enum<T>>
	extends AbstractSet<T>
{
	/** The type of class being stored. */
	protected final Class<T> type;
	
	/** The number of used bits so far. */
	protected final int numbits;
	
	/** The number of ints in use. */
	protected final int numints;
	
	/** The values which are in the set, split into fields. */
	private int[] _bits;
	
	/** Is the null element in this set? */
	private boolean _hasnull;
	
	/**
	 * Initializes an empty enumeration set.
	 *
	 * @param __cl The class type to store.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/21
	 */
	public EnumSet(Class<T> __cl)
		throws NullPointerException
	{
		this(__cl, EmptySet.<T>empty());
	}
	
	/**
	 * Initializes an enumeration set with the given initial values.
	 *
	 * @param __cl The class type to store.
	 * @param __v The initial values to store.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/21
	 */
	public EnumSet(Class<T> __cl, Collection<? extends T> __v)
		throws NullPointerException
	{
		if (__cl == null || __v == null)
			throw new NullPointerException("NARG");
		
		this.type = __cl;
		
		// Setup storage bits
		this.numbits = 0;
		this.numints = 0;
		this._bits = new int[0];
		
		// Add values
		for (T v : __v)
			this.add(v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean add(T __v)
	{
		// Adding null element?
		if (__v == null)
		{
			boolean hasnull = this._hasnull;
			if (hasnull)
				return false;
			else
			{
				this._hasnull = true;
				return true;
			}
		}
		
		// Need a place to store
		if (true)
			throw new todo.TODO();
		
		// Determine bit position
		int bit = __v.ordinal(),
			high = bit >>> 5;
		bit &= 0x1F;
		int flag = (1 << bit);
		
		// Did it have it before?
		int[] bits = this._bits;
		boolean had = ((bits[high] & flag) != 0);
		
		// Set it
		bits[high] |= flag;
		
		// The collection only changes if it did not have the bit
		return !had;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean contains(Object __o)
	{
		// Only has null if it was explicitely added
		if (__o == null)
			return this._hasnull;
		
		if (!this.type.isInstance(__o))
			return false;
		
		// Determine bit position
		int bit = ((Enum)__o).ordinal(),
			high = bit >>> 5;
		bit &= 0x1F;
		
		return 0 != (this._bits[high] & (1 << bit));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final Iterator<T> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final boolean remove(Object __v)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/21
	 */
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/IdentityHashSet.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Collection;
import java.util.HashSet;

/**
 * This is a set which uses the identity of objects for comparison rather than
 * the actual equality of said objects.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
public final class IdentityHashSet<T>
	extends __IdentityBaseSet__<T>
{
	/**
	 * Initializes an empty set.
	 *
	 * @since 2017/12/28
	 */
	public IdentityHashSet()
	{
		super(new HashSet<__IdentityWrapper__<T>>());
	}
	
	/**
	 * Initializes a set copied from the other collection.
	 *
	 * @param __from The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public IdentityHashSet(Collection<? extends T> __from)
		throws NullPointerException
	{
		super(new HashSet<__IdentityWrapper__<T>>(), __from);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/IdentityLinkedHashSet.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Collection;
import java.util.LinkedHashSet;

/**
 * This is a set which uses the identity of objects for comparison rather than
 * the actual equality of said objects. The order of elements in the set is
 * linked according to {@link java.util.LinkedHashSet}.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
public final class IdentityLinkedHashSet<T>
	extends __IdentityBaseSet__<T>
{
	/**
	 * Initializes an empty set.
	 *
	 * @since 2017/12/28
	 */
	public IdentityLinkedHashSet()
	{
		super(new LinkedHashSet<__IdentityWrapper__<T>>());
	}
	
	/**
	 * Initializes a set copied from the other collection.
	 *
	 * @param __from The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	public IdentityLinkedHashSet(Collection<? extends T> __from)
		throws NullPointerException
	{
		super(new LinkedHashSet<__IdentityWrapper__<T>>(), __from);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/IntegerList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411



























































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

/**
 * This is a list of integers which is backed by a primitive array rather than
 * boxed types.
 *
 * @since 2017/11/26
 */
public final class IntegerList
	extends AbstractList<Integer>
	implements RandomAccess
{
	/** The array growing size. */
	private static final int _GROW_SIZE =
		8;
	
	/** The internal integer list. */
	private volatile int[] _values;
	
	/** The number of values in the list. */
	private volatile int _size;
	
	/**
	 * Initializes an empty list.
	 *
	 * @since 2017/11/26
	 */
	public IntegerList()
	{
	}
	
	/**
	 * Initializes a list using the given collection of integers.
	 *
	 * @param __v The collection to source values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(Collection<Integer> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Iterate through collections
		int n = __v.size(), i = 0;
		int[] values = new int[n];
		for (Integer v : __v)
			values[i++] = v;
		
		// Set
		this._values = values;
		this._size = n;
	}
	
	/**
	 * Initializes a list using the given integer values from an array.
	 *
	 * @param __v The array of integers to use for values.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public IntegerList(int... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Defensive copy
		__v = __v.clone();
		
		// Simple set
		this._values = __v;
		this._size = __v.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean add(Integer __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return this.addInteger(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void add(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.addInteger(__i, __v);
	}
	
	/**
	 * Adds the specified integer to the list.
	 *
	 * @param __v The value to add.
	 * @return {@code true} if the list has changed.
	 * @since 2017/11/26
	 */
	public boolean addInteger(int __v)
	{
		this.addInteger(this._size, __v);
		return true;
	}
	
	/**
	 * Adds the specified integer to the list at the specified position.
	 *
	 * @param __i The index to add the value at.
	 * @param __v The value to add.
	 * @throws IndexOutOfBoundsException If the index to add it outside of
	 * the array bounds.
	 * @since 2017/11/26
	 */
	public void addInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i > this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Existing values
		boolean realloced = false;
		int[] values = this._values;
		int nvalues = (values == null ? 0 : values.length),
			size = this._size;
		
		// Need a larger array?
		if ((realloced = (size + 1 > nvalues)))
			if (values == null)
				values = new int[_GROW_SIZE];
			else
				values = Arrays.copyOf(values, nvalues + _GROW_SIZE);
		
		// Move all values up
		for (int o = size; o > __i; o++)
			values[o] = values[o - 1];
		
		// Set this index
		values[__i] = __v;
		size++;
		
		// Store new values
		if (realloced)
			this._values = values;
		this._size = size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public void clear()
	{
		this._values = null;
		this._size = 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean contains(Object __a)
	{
		// Only contains integers
		if (!(__a instanceof Integer))
			return false;
		
		return this.containsInteger((Integer)__a);
	}
	
	/**
	 * Checks if the list contains the specified integer.
	 *
	 * @param __v The value to check.
	 * @return {@code true} if the list contains the given integer.
	 * @since 2017/11/26
	 */
	public boolean containsInteger(int __v)
	{
		return this.indexOfInteger(__v) >= 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer get(int __i)
		throws IndexOutOfBoundsException
	{
		return this.getInteger(__i);
	}
	
	/**
	 * Obtains the integer at the given index.
	 *
	 * @param __i The index to get.
	 * @return The integer at the given index.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int getInteger(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		return this._values[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int indexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.indexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int indexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int i = 0, n = values.length; i < n; i++)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean isEmpty()
	{
		return this._size == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int lastIndexOf(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return -1;
		
		return this.lastIndexOfInteger((Integer)__a);
	}
	
	/**
	 * Returns the index which contains the specified integer starting from
	 * the end of the list.
	 *
	 * @param __v The value to search for.
	 * @return The index of the specified integer or {@code -1} if the list
	 * contains no such value.
	 * @since 2017/11/26
	 */
	public int lastIndexOfInteger(int __v)
	{
		int[] values = this._values;
		for (int n = values.length, i = n - 1; i >= 0; i--)
			if (values[i] == __v)
				return i;
		return -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public boolean remove(Object __a)
	{
		// Will never contain non-integers
		if (!(__a instanceof Integer))
			return false;
		
		int dx = this.indexOf(__a);
		if (dx < 0)
			return false;
		
		this.remove(dx);
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer remove(int __a)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public Integer set(int __i, Integer __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return this.setInteger(__i, __v);
	}
	
	/**
	 * Sets the integer at the specified index to the given value.
	 *
	 * @param __i The index to set.
	 * @param __v The value to set.
	 * @return The old value.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @since 2017/11/26
	 */
	public int setInteger(int __i, int __v)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this._size)
			throw new IndexOutOfBoundsException("IOOB");
		
		int[] values = this._values;
		int rv = values[__i];
		values[__i] = __v;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/26
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	/**
	 * Converts the integer list to an integer array.
	 *
	 * @return This list as an integer array.
	 * @since 2017/11/26
	 */
	public int[] toIntegerArray()
	{
		int[] values = this._values;
		int size = this._size;
		
		// Values would not be allocated
		if (size == 0)
			return new int[0];
		
		// Copy values
		int[] rv = new int[size];
		for (int i = 0; i < size; i++)
			rv[i] = values[i];
		return rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/MultiSetDeque.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * This is a class which provides a multiple {@link Deque} compatible interface
 * where every element within the queue is unique as if it were a member of
 * a {@link Set}. Note that the subdeques can be given elements that are shared
 * in multiple deques.
 *
 * In the returned {@link Deque}, elements which are removed will be removed
 * from the other {@link Deque}s. As such, clearing of one {@link Deque} may
 * result in other ones getting smaller in size.
 *
 * {@code null} elements are not permitted.
 *
 * This class is not thread safe.
 *
 * @param <V> The type of value to store in the dequeues.
 * @since 2016/09/03
 */
public class MultiSetDeque<V>
{
	/** Sub-queue list. */
	private final List<__Sub__<V>> _subs =
		new ArrayList<>();
	
	/** The master set of added elements. */
	final Set<V> _master =
		new HashSet<>();
	
	/**
	 * Initializes the multi set deque with the specified number of internal
	 * queues.
	 *
	 * @since 2016/09/03
	 */
	public MultiSetDeque()
	{
	}
	
	/**
	 * Clears the multi-set deque and every sub-deque so that all are empty.
	 *
	 * @since 2017/03/25
	 */
	public final void clear()
	{
		// Clear the master set
		this._master.clear();
		
		// And all the subsets
		for (__Sub__<V> s : this._subs)
			s.__clear();
	}
	
	/**
	 * Checks if the any of the sub-deques contain the specified element.
	 *
	 * @param __v The element to check.
	 * @return {@code true} if the element is any in deque.
	 * @since 2017/04/25
	 */
	public final boolean contains(V __v)
	{
		return this._master.contains(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (!(__o instanceof MultiSetDeque))
			return false;
		
		return this._subs.equals(((MultiSetDeque<?>)__o)._subs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final int hashCode()
	{
		return this._subs.hashCode();
	}
	
	/**
	 * Removes the given element from any of the sub-{@link Deque}s that are
	 * a part of the multi-set.
	 *
	 * @param __v The value to remove.
	 * @return {@code true} if it was in any {@link Deque}.
	 * @since 2016/09/03
	 */
	public final boolean remove(V __v)
	{
		// Null will never be in this deque
		if (__v == null)
			return false;
		
		// If not in the master set then it will not be in any deque
		Set<V> master = this._master;
		if (!master.contains(__v))
			return false;
		
		// Remove in all
		List<__Sub__<V>> subs = this._subs;
		int n = subs.size();
		boolean rv = false;
		for (int i = 0; i < n; i++)
			rv |= subs.get(i).__remove(__v);
		
		// Remove from the master set because it will be no sub-deque
		master.remove(__v);
		
		// Was it removed?
		return rv;
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque.
	 *
	 * @return A new deque which shares the set restrictions.
	 * @since 2016/09/03
	 */
	public final Deque<V> subDeque()
	{
		return subDeque(Integer.MAX_VALUE);
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque
	 * which is initialized using the given collection.
	 *
	 * @param __c The collection to add to the resulting {@link Deque}.
	 * @return A new deque which shares the set restrictions.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/15
	 */
	public final Deque<V> subDeque(Collection<V> __c)
		throws NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Create
		Deque<V> rv = subDeque();
		rv.addAll(__c);
		return rv;
	}
	
	/**
	 * Returns a new sub-{@link Deque} which acts as part of the multi-deque
	 * which is limited to the given number of elements.
	 *
	 * @param __l The number of elements to limit to.
	 * @return A new deque which shares the set restrictions.
	 * @throws IllegalArgumentException If the limit is zero or negative.
	 * @since 2016/09/03
	 */
	public final Deque<V> subDeque(int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AC05 The sub-deque limit is zero or negative.}
		if (__l <= 0)
			throw new IllegalArgumentException("AC05");
		
		// Create it
		__Sub__<V> rv = new __Sub__<>(this, __l);
		this._subs.add(rv);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public final String toString()
	{
		return this._subs.toString();
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/NaturalComparator.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Comparator;

/**
 * This is used to compare two values using their natural comparison.
 *
 * @since 2016/09/06
 */
public final class NaturalComparator<V>
	implements Comparator<V>
{
	/** The single instance. */
	private static Reference<NaturalComparator> _REF;
	
	/**
	 * Only one is ever needed.
	 *
	 * @since 2017/11/30
	 */
	private NaturalComparator()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public int compare(V __a, V __b)
	{
		// Consider two nulls to be equal
		boolean na = (__a == null), nb = (__b == null);
		if (na && nb)
			return 0;
		
		// Nulls before non-null
		else if (na && !nb)
			return -1;
		else if (!na && nb)
			return 1;
		
		// Use standard comparison
		return ((Comparable<V>)__a).compareTo(__b);
	}
	
	/**
	 * Returns the natural comparator instance.
	 *
	 * @param <V> The type of value to compare.
	 * @return The instance of the natural comparator.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public static final <V> NaturalComparator<V> instance()
	{
		Reference<NaturalComparator> ref = _REF;
		NaturalComparator rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			_REF = new WeakReference<>((rv = new NaturalComparator()));
		
		// Return it
		return (NaturalComparator<V>)rv;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/SortedTreeMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713









































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;

/**
 * This is a sorted map which is internally implemented by using
 * {@link SortedTreeSet} and special handlers.
 *
 * This class is not thread safe.
 *
 * @param <K> The type of key to store.
 * @param <V> The type of value to store.
 * @since 2016/09/06
 */
public class SortedTreeMap<K, V>
	extends AbstractMap<K, V>
{
	/** Rotate left. */
	private static final boolean _LEFT =
		false;
	
	/** Rotate right. */
	private static final boolean _RIGHT =
		true;
	
	/** The comparison method to use. */
	final Comparator<K> _compare;
	
	/** The entry set. */
	private Reference<Set<Map.Entry<K, V>>> _entryset;
	
	/** The root node. */
	__Node__<K, V> _root;
	
	/** The minimum value. */
	__Data__<K, V> _min;
	
	/** The size of the tree. */
	int _size;
	
	/**
	 * Initializes a new empty map using the natural comparator.
	 *
	 * @since 2016/09/06
	 */
	public SortedTreeMap()
	{
		this(NaturalComparator.<K>instance());
	}
	
	/**
	 * Initializes a map using the natural comparator where values are copied
	 * from the specified map.
	 *
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Map<? extends Comparable<K>, ? extends V> __m)
		throws NullPointerException
	{
		this(NaturalComparator.<K>instance(), (Map<? extends K, ? extends V>)__m);
	}
	
	/**
	 * Initializes a new empty map using the given comparator.
	 *
	 * @param __comp The comparator to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Comparator<? extends K> __comp)
		throws NullPointerException
	{
		// Check
		if (__comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._compare = (Comparator<K>)__comp;
	}
	
	/**
	 * Initializes a map using the given comparator where values are copied
	 * from the specified map.
	 *
	 * @param __comp The comparator to use for key sorts.
	 * @param __m The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeMap(Comparator<? extends K> __comp,
		Map<? extends K, ? extends V> __m)
		throws NullPointerException
	{
		// Check
		if (__comp == null || __m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._compare = (Comparator<K>)__comp;
		
		// Put everything
		putAll(__m);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public void clear()
	{
		this._root = null;
		this._min = null;
		this._size = 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return (null != __findNode(__o));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		// Get
		Reference<Set<Map.Entry<K, V>>> ref = this._entryset;
		Set<Map.Entry<K, V>> rv;
		
		// Check
		if (ref == null || null == (rv = ref.get()))
			this._entryset = new WeakReference<>(
				(rv = new __EntrySet__<>(this)));
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V get(Object __k)
	{
		__Node__<K, V> node = __findNode(__k);
		if (node == null)
			return null;
		return node._data._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public V put(K __k, V __v)
	{
		// Insert node
		__Found__ found = new __Found__();
		__Node__<K, V> now = __insert(null, this._root, found, __k, __v);
		
		// The root of the tree always becomes black
		now.__makeBlack();
		this._root = now;
		
		// Old value
		return found._oldvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/29
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public V remove(Object __k)
	{
		// Delete node
		__Found__ found = new __Found__();
		__Node__<K, V> newroot = __remove(this._root, found, (K)__k);
		
		// The root of the tree is always black
		this._root = newroot;
		if (newroot != null)
			newroot._isred = false;
		
		// Old value
		return found._oldvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public int size()
	{
		return this._size;
	}
	
	/**
	 * Corrects nodes going back up the tree.
	 *
	 * @param __at The node to potentially correct.
	 * @return The parent node and not a side node.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/30
	 */
	private __Node__<K, V> __correctNodes(__Node__<K, V> __at)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Rotate right side value to the left
		if (__isRed(__at._right))
			__at = __rotate(__at, _LEFT);
		
		// If there are a bunch of dangling red nodes on the left balance
		// them
		if (__isRed(__at._left) && __isRed(__at._left._left))
			__at = __rotate(__at, _RIGHT);
		
		// If both side nodes are red then flip the color of this node
		if (__isRed(__at._left) && __isRed(__at._right))
			__flipColor(__at);
		
		// Return current node
		return __at;
	}
	
	/**
	 * Finds the node with the given value.
	 *
	 * @param __o The object to find.
	 * @return The node for the given object or {@code null} if it was not
	 * found.
	 * @since 2016/09/06
	 */
	final __Node__<K, V> __findNode(Object __o)
	{
		// If there are no nodes then the tree is empty
		__Node__<K, V> rover = this._root;
		if (rover == null)
			return null;
		
		return __findNode(rover, __o);
	}
	
	/**
	 * Finds the node with the given key starting at the specified node.
	 *
	 * @param __at The node to start at.
	 * @param __k The key to find.
	 * @return The specified node or {@code null} if not found.
	 * @since 2017/03/30
	 */
	@SuppressWarnings({"unchecked"})
	final __Node__<K, V> __findNode(__Node__<K, V> __at, Object __k)
	{	
		// Constant search
		Comparator<K> compare = this._compare;
		while (__at != null)
		{
			// Compare
			K against = __at._data._key;
			int res = compare.compare((K)__k, against);
			
			// The same? stop here
			if (res == 0)
				return __at;
			
			// Go left
			else if (res < 0)
				__at = __at._left;
			
			// Otherwise go right
			else
				__at = __at._right;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Flips the color of the specified node.
	 *
	 * @param __at The node to flip colors for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/30
	 */
	private final void __flipColor(__Node__<K, V> __at)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Flip node colors
		__at._isred = !__at._isred;
		__at._left._isred = !__at._left._isred;
		__at._right._isred = !__at._right._isred;
	}
	
	/**
	 * Inserts the given node into the tree
	 *
	 * @param __from The node this iterated from.
	 * @param __at The current node iteration.
	 * @param __found The value information when a value is discovered.
	 * @param __k The key to use.
	 * @param __v The value to use.
	 * @return The root of the local segment, the first iteration of this call
	 * will always return the root of the tree.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __insert(__Node__<K, V> __from,
		__Node__<K, V> __at, __Found__ __found, K __k, V __v)
	{
		// No root of the tree?
		if (__at == null)
		{
			// Setup data
			__Data__<K, V> data = new __Data__<>(this, __k, __v);
			
			// Create new node
			__at = new __Node__<>();
			__at._data = data;
			data._node = __at;
			
			// Need to link the data in with the source nodes data chain
			if (__from != null)
			{
				// Need to directly modify the from data links
				__Data__<K, V> fd = __from._data;
				
				// Link before the from node?
				if (data.__compare(fd) < 0)
				{
					// The from's previous data needs to point to this node
					// and not the from data
					__Data__<K, V> pp = fd._prev;
					if (pp != null)
						pp._next = data;
					
					// This links back to that from data
					data._prev = pp;
					
					// and then links to the from data
					data._next = fd;
					
					// Then the from's previous becomes this data
					fd._prev = data;
				}
				
				// Link after
				else
				{
					// The from's next has to point back to this data
					__Data__<K, V> nn = fd._next;
					if (nn != null)
						nn._prev = data;
					
					// This links back into the from node
					data._prev = fd;
					
					// And links to the original next in the from
					data._next = nn;
					
					// Then the from next links to this data
					fd._next = data;
				}
			}
			
			// If the tree has no minimum use this node as it
			// Otherwise always use the smaller value
			__Data__<K, V> oldmin = this._min;
			if (oldmin == null || data.__compare(oldmin) < 0)
				this._min = data;
			
			// Size of the tree increased
			this._size++;
			
			// Use this new node
			return __at;
		}
		
		// Matched key, set its value
		int comp = this._compare.compare(__k, __at._data._key);
		if (comp == 0)
		{
			__found._oldvalue = __at._data._value;
			__at._data._value = __v;
		}
		
		// Less than
		else if (comp < 0)
			__at._left = __insert(__at, __at._left, __found, __k, __v);
		
		// Greater
		else
			__at._right = __insert(__at, __at._right, __found, __k, __v);
		
		// Correct nodes going back up
		return __correctNodes(__at);
	}
	
	/**
	 * Returns {@code true} if the given node is red.
	 *
	 * @param __n The node to see if it is red.
	 * @return {@code true} if the node is red.
	 * @since 2017/03/30
	 */
	private final boolean __isRed(__Node__<K, V> __n)
	{
		if (__n == null)
			return false;
		return __n._isred;
	}
	
	/**
	 * Returns the minimum node.
	 *
	 * @return The minimum node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __min(__Node__<K, V> __at)
	{
		while (__at._left != null)
			__at = __at._left;
		return __at;
	}
	
	/**
	 * Moves the specified red node.
	 *
	 * @param __at The node to move.
	 * @return The node that is not a side node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __moveRed(__Node__<K, V> __at, boolean __r)
	{
		// Flip the node color
		__flipColor(__at);
		
		// Move to the right
		if (__r)
		{
			if (__isRed(__at._left._left))
			{
				__at = __rotate(__at, _RIGHT);
			
				__flipColor(__at);
			}
		}
		
		// Move to the left
		else
		{
			if (__isRed(__at._right._left))
			{
				__at._right = __rotate(__at._right, _RIGHT);
				__at = __rotate(__at, _LEFT);
				
				__flipColor(__at);
			}
		}
		
		// This would be the node at the top
		return __at;
	}
	
	/**
	 * Recursive node removal based on the given key.
	 *
	 * @param __at The current node being traversed.
	 * @param __found Node searching information.
	 * @param __k The key to remove the value from.
	 * @return The node at the top (will not be a leaf)
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __remove(__Node__<K, V> __at,
		__Found__ __found, K __k)
	{
		// Key is lower?
		Comparator<K> compare = this._compare;
		int comp = compare.compare(__k, __at._data._key);
		if (comp < 0)
		{
			// Move red node to the left
			if (!__isRed(__at._left) && !__isRed(__at._left._left))
				__at = __moveRed(__at, _LEFT);
			
			// Delete left side
			__at._left = __remove(__at._left, __found, __k);
		}
		
		// Equal or higher
		else
		{
			// If the left is red then rotate it to the right
			if (__isRed(__at._left))
			{
				__at = __rotate(__at, _RIGHT);
				
				// Compare value is trashed, recompute
				comp = compare.compare(__k, __at._data._key);
			}
			
			// If this is the key and there is no right then no values need
			// to be shifted in
			if (comp == 0 && __at._right == null)
			{
				__unlink(__at, __found);
				
				// Return no key
				return null;
			}
			
			// If the red side contains a black chain move red nodes to the
			// right
			if (!__isRed(__at._right) && !__isRed(__at._right._left))
			{
				__at = __moveRed(__at, _RIGHT);
				
				// Comparison is trashed
				comp = compare.compare(__k, __at._data._key);
			}
			
			// Keys are the same
			if (comp == 0)
			{
				// Get the node with the minimum value on the right side
				__Node__<K, V> right = __at._right;
				__Node__<K, V> minright = __min(right);
				
				// Unlink the current data because that is getting destroyed
				__unlink(__at, __found);
				
				// The current node gets the data for that key
				__at._data = minright._data;
				
				// Remove the minimum without unlinking (because it gets
				// re-associated)
				__removeMin(right, null, false);
			}
			
			// Delete right side of the tree
			else
				__at._right = __remove(__at._right, __found, __k);
		}
		
		// Correct tree on the way up
		return __correctNodes(__at);
	}
	
	/**
	 * Removes the minimum node.
	 *
	 * @param __at Current node.
	 * @param __found The found node information.
	 * @param __unlink If {@code true} the node is unlinked.
	 * @return The top node.
	 * @since 2017/03/30
	 */
	private final __Node__<K, V> __removeMin(__Node__<K, V> __at,
		__Found__ __found, boolean __unlink)
	{
		// If there is no left, remove the left node
		if (__at._left == null)
		{
			// Unlink our node
			if (__unlink)
				__unlink(__at, __found);
			
			// No left node
			return null;
		}
		
		// If the left side is black move red to the left
		if (!__isRed(__at._left) && !__isRed(__at._left._left))
			__at = __moveRed(__at, _LEFT);
		
		// Continue deleting the minimum
		__at._left = __removeMin(__at, __found, __unlink);
		
		// Correct nodes back up the tree
		return __correctNodes(__at);
	}
	
	/**
	 * Rotates the nodes in the given direction.
	 *
	 * @param __at The node to rotate.
	 * @param __r If {@code true} then rotation is to the right, otherwise it
	 * is to the left.
	 * @return The center node.
	 * @since 2017/03/27
	 */
	private final __Node__<K, V> __rotate(__Node__<K, V> __at, boolean __r)
		throws NullPointerException
	{
		// Check
		if (__at == null)
			throw new NullPointerException("NARG");
		
		// Rotate right
		if (__r)
		{
			__Node__<K, V> x = __at._left;
			__at._left = x._right;
			x._right = __at;
			x._isred = x._right._isred;
			x._right._isred = true;
			return x;
		}
		
		// Rotate left
		else
		{
			__Node__<K, V> x = __at._right;
			__at._right = x._left;
			x._left = __at;
			x._isred = x._left._isred;
			x._left._isred = true;
			return x;
		}
	}
	
	/**
	 * Unlinks the specified node.
	 *
	 * @param __at The node to unlink.
	 * @param __found The found node data.
	 * @since 2017/03/30
	 */
	private final void __unlink(__Node__<K, V> __at, __Found__ __found)
	{
		// Get the data to unlink
		__Data__<K, V> unlink = __at._data;
		if (__found != null)
			__found._oldvalue = unlink._value;
		
		// Link next node with the previous
		__Data__<K, V> prev = unlink._prev,
			next = unlink._next;
		if (next != null)
			next._prev = prev;
		
		// Link previous node with the next one
		if (prev != null)
			prev._next = next;
		
		// If this is the minimum node then the next one will be the
		// new minimum
		if (this._min == unlink)
			this._min = next;
		
		// Destroy chains
		unlink._value = null;
		unlink._node = null;
		unlink._prev = null;
		unlink._next = null;
		
		// Reduce count
		this._size--;
	}
	
	/**
	 * The data which used to be at the given position.
	 *
	 * @since 2017/03/30
	 */
	private final class __Found__
	{
		V _oldvalue;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/SortedTreeSet.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
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












































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Comparator;
import java.util.Deque;
import java.util.Iterator;
import java.util.Objects;
import java.util.Set;

/**
 * This is a sorted {@link Set} which internally uses a red-black tree to sort
 * the entries.
 *
 * The algorithm is derived from Robert Sedgewick's (of Princeton University)
 * 2008 variant of Red-Black Trees called Left Leaning Red-Black Trees.
 *
 * @param <V> The type of value stored in the set.
 * @since 2016/09/06
 */
public class SortedTreeSet<V>
	extends AbstractSet<V>
{
	/** Marker object to indicate that a value is set. */
	private static final Object _HAS_VALUE =
		new Object();
	
	/** The backing map. */
	private final SortedTreeMap<V, Object> _map;
	
	/**
	 * Initializes an empty red/black set using the natural comparator.
	 *
	 * @since 2016/09/06
	 */
	public SortedTreeSet()
	{
		this(NaturalComparator.<V>instance());
	}
	
	/**
	 * Initializes a red/black set using the natural comparator which is
	 * initialized with the given values.
	 *
	 * @param __s The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Collection<? extends Comparable<V>> __s)
		throws NullPointerException
	{
		this(NaturalComparator.<V>instance(), (Collection<? extends V>)__s);
	}
	
	/**
	 * Initializes an empty red/black set using the given comparator.
	 *
	 * @param __comp The comparator to use for values.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Comparator<? extends V> __comp)
		throws NullPointerException
	{
		// Check
		if (__comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = new SortedTreeMap<>(__comp);
	}
	
	/**
	 * Initializes a red/black set using the given comparator which is
	 * initialized with the given values.
	 *
	 * @param __comp The comparator to use for values.
	 * @param __s The collection to copy values from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/06
	 */
	@SuppressWarnings({"unchecked"})
	public SortedTreeSet(Comparator<? extends V> __comp,
		Collection<? extends V> __s)
		throws NullPointerException
	{
		// Check
		if (__comp == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = new SortedTreeMap<>(__comp);
		
		// Just call add all from collection
		addAll(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean add(V __v)
	{
		return (_HAS_VALUE != this._map.put(__v, _HAS_VALUE));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public void clear()
	{
		this._map.clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean contains(Object __o)
	{
		return this._map.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Iterator<V> iterator()
	{
		return this._map.keySet().iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean remove(Object __o)
	{
		Object q = this._map.remove(__o);
		return (q == _HAS_VALUE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableArrayIterator.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
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














































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is an iterator where elements cannot be removed and where it iterates
 * over an array.
 *
 * @param <T> The type to use.
 * @since 2018/05/13
 */
public final class UnmodifiableArrayIterator<T>
	implements Iterator<T>
{
	/** The element limit. */
	protected final int limit;
	
	/** The source elements, cleared when empty. */
	private T[] _source;
	
	/** The current element. */
	private int _at;
	
	/**
	 * Initializes the iterator.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableArrayIterator(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this.limit = __o + __l;
		this._source = __a;
		this._at = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final boolean hasNext()
	{	
		return (this._at < this.limit);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final T next()
		throws NoSuchElementException
	{
		// Is at the end?
		int at = this._at;
		if (at >= this.limit)
		{
			this._source = null;
			throw new NoSuchElementException("NSEE");
		}
		
		this._at = at + 1;
		return this._source[at];
	}
	
	/**
	 * {@inheritDoc}
	 * @throws UnsupportedOperationException Always.
	 * @since 2108/05/13
	 */
	@Override
	public final void remove()
		throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Iterator<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayIterator<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayIterator<T>(__a, __o, __l);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableArrayList.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
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





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.RandomAccess;
import java.util.List;

/**
 * This is a list representation of an array which cannot be modified.
 *
 * @param <T> The type of values to store.
 * @since 2018/05/13
 */
public final class UnmodifiableArrayList<T>
	extends AbstractList<T>
	implements RandomAccess
{
	/** The element offset. */
	protected final int offset;
	
	/** The element length. */
	protected final int length;
	
	/** The source elements. */
	private final T[] _source;
	
	/**
	 * Initializes the list.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableArrayList(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this._source = __a;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/13
	 */
	@Override
	public final T get(int __i)
		throws IndexOutOfBoundsException
	{
		if (__i < 0 || __i >= this.length)
			throw new IndexOutOfBoundsException(String.format("IOOB %d", __i));
		
		return this._source[this.offset + __i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/13
	 */
	@Override
	public final int size()
	{
		return this.length;
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> List<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayList<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> List<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayList<T>(__a, __o, __l);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableCollection.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
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























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * This class represents a collection which cannot be modified.
 *
 * @since 2017/10/09
 */
public final class UnmodifiableCollection<T>
	extends AbstractCollection<T>
{
	/** The collection to wrap. */
	protected final Collection<T> wrapped;
	
	/**
	 * Initializes a collection view which cannot be modified.
	 *
	 * @param __w The collection to wrap a view for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	private UnmodifiableCollection(Collection<T> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public boolean contains(Object __o)
	{
		return wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public boolean isEmpty()
	{
		return wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public Iterator<T> iterator()
	{
		return new Iterator<T>()
			{
				/** The base iterator. */
				final Iterator<T> _base =
					wrapped.iterator();
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public boolean hasNext()
				{
					return _base.hasNext();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public T next()
				{
					return _base.next();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2017/10/09
				 */
				@Override
				public void remove()
				{
					throw new UnsupportedOperationException("RORO");
				}
			};
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public int size()
	{
		return wrapped.size();
	}
	
	/**
	 * This creates a view of the specified collection which cannot be
	 * modified.
	 *
	 * @param <T> The type of value the set stores.
	 * @param __c The collection to wrap to disable modifications of.
	 * @return An unmodifiable view of the collection.
	 * @since 2017/10/09
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Collection<T> of(Collection<T> __c)
	{
		// If already one, return that collection
		if (__c instanceof UnmodifiableCollection)
			return __c;
		
		// Use List instead
		else if (__c instanceof List)
			return UnmodifiableList.<T>of((List<T>)__c);
		
		// Use Set instead
		else if (__c instanceof Set)
			return UnmodifiableSet.<T>of((Set<T>)__c);
		
		// Otherwise wrap as a collection
		return new UnmodifiableCollection<T>(__c);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableIterator.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
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
























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This creates an unmodifiable iterator over an existing iterator.
 *
 * @param <T> The type to use.
 * @since 2018/05/13
 */
public final class UnmodifiableIterator<T>
	implements Iterator<T>
{
	/** The source iterator. */
	protected final Iterator<T> source;
	
	/**
	 * Initializes the iterator.
	 *
	 * @param __it The source iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	UnmodifiableIterator(Iterator<T> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		this.source = __it;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final boolean hasNext()
	{
		return this.source.hasNext();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2108/05/13
	 */
	@Override
	public final T next()
		throws NoSuchElementException
	{
		return this.source.next();
	}
	
	/**
	 * {@inheritDoc}
	 * @throws UnsupportedOperationException Always.
	 * @since 2108/05/13
	 */
	@Override
	public final void remove()
		throws UnsupportedOperationException
	{
		throw new UnsupportedOperationException("RORO");
	}
	
	/**
	 * Wraps the given iterable.
	 *
	 * @param __i The iterable to wrap.
	 * @return The wrapped iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(Iterable<T> __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableIterator<T>(__i.iterator());
	}
	
	/**
	 * Wraps the given iterator.
	 *
	 * @param __i The iterator to wrap.
	 * @return The wrapped iterator.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(Iterator<T> __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableIterator<T>(__i);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The array to wrap.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	@SuppressWarnings({"unchecked"})
	public static <T> Iterator<T> of(T... __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		return new UnmodifiableArrayIterator<T>(__a, 0, __a.length);
	}
	
	/**
	 * Wraps the given array.
	 *
	 * @param __a The input array.
	 * @param __o The offset into the array.
	 * @param __l The number of elements to read.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @return The iterator for the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/13
	 */
	public static <T> Iterator<T> of(T[] __a, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __a.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		return new UnmodifiableArrayIterator<T>(__a, __o, __l);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327







































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/**
 * This is a list which cannot be modified.
 *
 * @param <V> The type of value the list stores.
 * @since 2016/03/03
 */
public abstract class UnmodifiableList<V>
	extends AbstractList<V>
{
	/** The list to wrap. */
	protected final List<V> wrapped;	
	
	/**
	 * Initializes the list which cannot be modified.
	 *
	 * @param __l The list to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/03
	 */
	private UnmodifiableList(List<V> __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		// Set
		wrapped = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean contains(Object __o)
	{
		return wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/03
	 */
	@Override
	public final V get(int __i)
	{
		return wrapped.get(__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int indexOf(Object __o)
	{
		return wrapped.indexOf(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public int lastIndexOf(Object __o)
	{
		return wrapped.lastIndexOf(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/03
	 */
	@Override
	public final int size()
	{
		return wrapped.size();
	}
	
	/**
	 * This creates a view of the specified list which cannot be modified.
	 *
	 * @param <V> The type of value stored in the list.
	 * @return An unmodifiable view of the list.
	 * @since 2016/03/03
	 */
	public static <V> List<V> of(List<V> __l)
	{
		// If already one, return it
		if (__l instanceof UnmodifiableList)
			return __l;
		
		// Wrap, make sure that if the list being wrapped can be randomly
		// accessed that it also carries the RandomAccess interface.
		if (__l instanceof RandomAccess)
			return new UnmodifiableList.__Random__<V>(__l);
		return new UnmodifiableList.__Sequential__<V>(__l);
	}
	
	/**
	 * Wraps a list iterator so that it cannot have modifications.
	 *
	 * @param <V> The type of value in the list.
	 * @since 2016/05/12
	 */
	private static final class __ListIterator__<V>
		implements ListIterator<V>
	{
		/** The list iterator to wrap. */
		protected final ListIterator<V> li;
		
		/**
		 * Initializes the wrapped list iterator.
		 *
		 * @param __li The iterator to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/05/12
		 */
		private __ListIterator__(ListIterator<V> __li)
			throws NullPointerException
		{
			// Check
			if (__li == null)
				throw new NullPointerException("NARG");
			
			// Set
			li = __li;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void add(V __e)
		{
			throw new UnsupportedOperationException("RORO");
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public boolean hasNext()
		{
			return li.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public boolean hasPrevious()
		{
			return li.hasPrevious();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public V next()
		{
			return li.next();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public int nextIndex()
		{
			return li.nextIndex();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public V previous()
		{
			return li.previous();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public int previousIndex()
		{
			return li.previousIndex();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public void set(V __v)
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * This is a list which implements {@link RandomAccess} so that the sort
	 * and search operations do not result in an entire copy of the list
	 * before the operation is performed.
	 *
	 * @param <V> The type to contain.
	 * @since 2016/04/28
	 */
	private static final class __Random__<V>
		extends UnmodifiableList<V>
		implements RandomAccess
	{
		/**
		 * Initializes the random access list.
		 *
		 * @param __l The list to wrap.
		 * @since 2016/04/28
		 */
		private __Random__(List<V> __l)
		{
			super(__l);
		}
	}
	
	/**
	 * This is a list which does not implement {@link RandomAccess} and as
	 * such when sort or binary search is done, an intermediate array is used
	 * in place.
	 *
	 * @param <V> The type to contain.
	 * @since 2016/04/28
	 */
	private static final class __Sequential__<V>
		extends UnmodifiableList<V>
	{
		/**
		 * Initializes the sequential access list.
		 *
		 * @param __l The list to wrap.
		 * @since 2016/04/28
		 */
		private __Sequential__(List<V> __l)
		{
			super(__l);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public Iterator<V> iterator()
		{
			return listIterator();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public ListIterator<V> listIterator()
		{
			return listIterator(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/05/12
		 */
		@Override
		public ListIterator<V> listIterator(int __i)
		{
			return new __ListIterator__<V>(wrapped.listIterator(__i));
		}
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableMap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328








































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This is a map which cannot be modified.
 *
 * @param <K> Key type to use.
 * @param <V> Value type to store.
 * @since 2016/02/29
 */
public final class UnmodifiableMap<K, V>
	extends AbstractMap<K, V>
{
	/** The existing map to wrap. */
	protected final Map<K, V> wrapped;
	
	/** Entry set cache, since it is not always needed. */
	private Reference<Set<Map.Entry<K, V>>> _escache;
	
	/**
	 * Initializes the unmodifiable wrapped map.
	 *
	 * @param __w The map to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/29
	 */
	private UnmodifiableMap(Map<K, V> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Set
		wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return wrapped.containsKey(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean containsValue(Object __o)
	{
		return wrapped.containsValue(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public Set<Map.Entry<K, V>> entrySet()
	{
		// Get reference to the map
		Reference<Set<Map.Entry<K, V>>> ref = _escache;
		Set<Map.Entry<K, V>> rv = null;
		
		// In reference?
		if (ref != null)
			rv = ref.get();
		
		// Needs initialization?
		if (rv == null)
			_escache = new WeakReference<>((rv = new __SetView__()));
		
		// Return it
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public V get(Object __k)
	{
		return wrapped.get(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/29
	 */
	@Override
	public int size()
	{
		return wrapped.size();
	}
	
	/**
	 * This creates a view of the specified map which cannot be modified.
	 *
	 * @param <K> The map key.
	 * @param <V> The map value.
	 * @param __m The map to wrap.
	 * @return An unmodifiable view of the map.
	 * @since 2016/02/28
	 */
	public static <K, V> Map<K, V> of(Map<K, V> __m)
	{
		// If already one, return it
		if (__m instanceof UnmodifiableMap)
			return __m;
		
		// Wrap
		return new UnmodifiableMap<K, V>(__m);
	}
	
	/**
	 * This is the iterator over the entry set of the map.
	 *
	 * @since 2016/02/29
	 */
	private final class __SetIterator__
		implements Iterator<Map.Entry<K, V>>
	{
		/** The base iterator. */
		protected final Iterator<Map.Entry<K, V>> from =
			wrapped.entrySet().iterator();
		
		/**
		 * Initializes the iterator.
		 *
		 * @since 2016/02/29
		 */
		private __SetIterator__()
		{
		}
	
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public boolean hasNext()
		{
			return from.hasNext();
		}
	
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public Map.Entry<K, V> next()
		{
			// Get the next entry
			Map.Entry<K, V> ent = from.next();
			
			// If null, this is a bad map but possibly might be valid
			if (ent == null)
				return null;
			
			// Wrap it
			return new __SetEntry__<K, V>(ent);
		}
		
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
	
	/**
	 * This implements the unmodifiable set view.
	 *
	 * @since 2016/02/29
	 */
	private final class __SetView__
		extends AbstractSet<Map.Entry<K, V>>
	{
		/**
		 * Initializes the set view.
		 *
		 * @since 2016/02/29
		 */
		private __SetView__()
		{
		}
	
		/**	
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public Iterator<Map.Entry<K, V>> iterator()
		{
			return new __SetIterator__();
		}
	
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public int size()
		{
			return wrapped.size();
		}
	}
	
	/**
	 * This is a single entry in the set.
	 *
	 * @param <K> The key type.
	 * @param <V> The value type.
	 * @since 2016/02/29
	 */
	private static final class __SetEntry__<K, V>
		implements Map.Entry<K, V>
	{
		/** The base entry. */
		protected final Map.Entry<K, V> base;
		
		/**
		 * Initializes the set entry.
		 *
		 * @param __e The entry to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/02/29
		 */
		private __SetEntry__(Map.Entry<K, V> __e)
			throws NullPointerException
		{
			// Check
			if (__e == null)
				throw new NullPointerException("NARG");
			
			// Set
			base = __e;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public boolean equals(Object __a)
		{
			return base.equals(__a);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public K getKey()
		{
			return base.getKey();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public V getValue()
		{
			return base.getValue();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public int hashCode()
		{
			return base.hashCode();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/02/29
		 */
		@Override
		public V setValue(V __a)
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/UnmodifiableSet.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
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












































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a set which cannot be modified.
 *
 * @param <T> The value to store in the set.
 * @since 2016/02/28
 */
public final class UnmodifiableSet<T>
	extends AbstractSet<T>
{
	/** The set to wrap. */
	protected final Set<T> wrapped;
	
	/**
	 * Initializes a set view which cannot be modified.
	 *
	 * @param __w The set to wrap a view for.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/02/28
	 */
	private UnmodifiableSet(Set<T> __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Wrap it
		wrapped = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public boolean contains(Object __o)
	{
		return wrapped.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public boolean isEmpty()
	{
		return wrapped.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public Iterator<T> iterator()
	{
		return new Iterator<T>()
			{
				/** The base iterator. */
				final Iterator<T> _base =
					wrapped.iterator();
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public boolean hasNext()
				{
					return _base.hasNext();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public T next()
				{
					return _base.next();
				}
				
				/**
				 * {@inheritDoc}
				 * @since 2016/02/28
				 */
				@Override
				public void remove()
				{
					throw new UnsupportedOperationException("RORO");
				}
			};
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/02/28
	 */
	@Override
	public int size()
	{
		return wrapped.size();
	}
	
	/**
	 * This creates a view of the specified set which cannot be modified.
	 *
	 * @param <T> The type of value the set stores.
	 * @param __s The set to wrap to disable modifications of.
	 * @return An unmodifiable view of the set.
	 * @since 2016/02/28
	 */
	public static <T> Set<T> of(Set<T> __s)
	{
		// If already one, return that set
		if (__s instanceof UnmodifiableSet)
			return __s;
		
		// Otherwise create a new one
		return new UnmodifiableSet<T>(__s);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__Data__.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
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









































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.Comparator;
import java.util.Map;
import java.util.Objects;

/**
 * This stores a key and value pair which is referenced by a node.
 *
 * @since 2017/03/30
 */
class __Data__<K, V>
	implements Map.Entry<K, V>
{
	/** The comparison method to use. */
	final Comparator<K> _compare;
	
	/** The key for this data. */
	final K _key;
	
	/** The value of the data. */
	volatile V _value;
	
	/** The node owning this data (used only to detect modification). */
	volatile __Node__<K, V> _node;
	
	/** The data before this one. */
	volatile __Data__<K, V> _prev;
	
	/** The data after this one. */
	volatile __Data__<K, V> _next;
	
	/**
	 * Initializes the data.
	 *
	 * @param __m The owning map.
	 * @param __k The key used for this data.
	 * @param __v The value to initially store.
	 * @throws NullPointerException If no map was specified.
	 * @since 2017/03/30
	 */
	__Data__(SortedTreeMap<K, V> __m, K __k, V __v)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this._compare = __m._compare;
		this._key = __k;
		this._value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Must be another entry
		if (!(__o instanceof Map.Entry))
			return false;
		
		// Compare
		Map.Entry<?, ?> o = (Map.Entry<?, ?>)__o;
		return Objects.equals(this._key, o.getKey()) &&
			Objects.equals(this._value, o.getValue());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public K getKey()
	{
		return this._key;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V getValue()
	{
		return this._value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public int hashCode()
	{
		return Objects.hashCode(this._key) ^ Objects.hashCode(this._value);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public V setValue(V __a)
	{
		V rv = this._value;
		this._value = __a;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public String toString()
	{
		return String.format("[%s, %s]", this._key, this._value);
	}
	
	/**
	 * Compares this data against the given key.
	 *
	 * @param __n The key to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(K __k)
	{
		return this._compare.compare(this._key, __k);
	}
	
	/**
	 * Compares this data against the given data.
	 *
	 * @param __n The data to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Data__<K, V> __d)
	{
		return __compare(__d._key);
	}
	
	/**
	 * Compares this data against the given node.
	 *
	 * @param __n The node to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Node__<K, V> __n)
	{
		return __compare(__n._data);
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__EntrySet__.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;

/**
 * This represents the entry set of the map.
 *
 * @param <K> The keys to use.
 * @param <V> The values to use.
 * @since 2016/09/07
 */
final class __EntrySet__<K, V>
	extends AbstractSet<Map.Entry<K, V>>
{
	/** The owning map. */
	private final SortedTreeMap<K, V> _map;
	
	/**
	 * Initializes the entry set.
	 *
	 * @param __m The owning map.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/07
	 */
	__EntrySet__(SortedTreeMap<K, V> __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._map = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public Iterator<Map.Entry<K, V>> iterator()
	{
		return new __MapIterator__<K, V>(this._map);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/07
	 */
	@Override
	public int size()
	{
		return this._map.size();
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__IdentityBaseSet__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231







































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is the base class for the identity set.
 *
 * @param <T> The type of element to store in the set.
 * @since 2017/12/28
 */
abstract class __IdentityBaseSet__<T>
	extends AbstractSet<T>
{
	/** The set to use as a backing storage. */
	private final Set<__IdentityWrapper__<T>> _backing;
	
	/**
	 * Initializes the base set using the given backing set.
	 *
	 * @param __back The set to back with.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityBaseSet__(Set<__IdentityWrapper__<T>> __back)
		throws NullPointerException
	{
		if (__back == null)
			throw new NullPointerException("NARG");
		
		this._backing = __back;
	}
	
	/**
	 * Initializes the base set using the given backing set.
	 *
	 * @param __back The set to back with.
	 * @param __from The collection to source data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityBaseSet__(Set<__IdentityWrapper__<T>> __back,
		Collection<? extends T> __from)
		throws NullPointerException
	{
		if (__back == null || __from == null)
			throw new NullPointerException("NARG");
		
		this._backing = __back;
		this.addAll(__from);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean add(T __t)
	{
		if (__t == null)
			return this._backing.add(null);
		return this._backing.add(new __IdentityWrapper__<T>(__t));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final void clear()
	{
		this._backing.clear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean contains(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean containsAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Set))
			return false;
		
		Set<?> o = (Set<?>)__o;
		return this.size() == o.size() &&
			this.containsAll(o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean isEmpty()
	{
		return this._backing.isEmpty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final Iterator<T> iterator()
	{
		return new __Iterator__();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean remove(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean removeAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final boolean retainAll(Collection<?> __c)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public final int size()
	{
		return this._backing.size();
	}
	
	/**
	 * Iterates over wrapped entries.
	 *
	 * @since 2017/12/28
	 */
	private final class __Iterator__
		implements Iterator<T>
	{
		/** The boxed iterator. */
		protected final Iterator<__IdentityWrapper__<T>> boxed =
			__IdentityBaseSet__.this._backing.iterator();
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public boolean hasNext()
		{
			return this.boxed.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public T next()
		{
			__IdentityWrapper__<T> rv = this.boxed.next();
			if (rv == null)
				return null;
			return rv.get();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/12/28
		 */
		@Override
		public void remove()
		{
			this.boxed.remove();
		}
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__IdentityWrapper__.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
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

/**
 * This wraps an object and allows comparison of the object by value only.
 *
 * @param <T> The type of value to wrap.
 * @since 2017/12/28
 */
final class __IdentityWrapper__<T>
{
	/** The wrapped object. */
	protected final T value;
	
	/**
	 * Initializes the wrapped object.
	 *
	 * @param __v The value to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/28
	 */
	__IdentityWrapper__(T __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof __IdentityWrapper__))
			return false;
		
		return this.value == ((__IdentityWrapper__<?>)__o).value;
	}
	
	/**
	 * Returns the wrapped object.
	 *
	 * @return The wrapped object.
	 * @since 2017/12/28
	 */
	public T get()
	{
		return this.value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/12/28
	 */
	@Override
	public int hashCode()
	{
		return this.value.hashCode();
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__MapIterator__.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
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
































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * This iterates over the sorted set.
 *
 * @since 2016/09/06
 */
class __MapIterator__<K, V>
	implements Iterator<Map.Entry<K, V>>
{
	/** The owning map. */
	protected final SortedTreeMap<K, V> map;
	
	/** The current node position. */
	private volatile __Data__<K, V> _at;
	
	/** The last visited node (for deletion). */
	private volatile __Data__<K, V> _last;
	
	/**
	 * Iterates over the given map.
	 *
	 * @param __m The map to iterate over.
	 * @since 2016/09/06
	 */
	__MapIterator__(SortedTreeMap<K, V> __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.map = __m;
		this._at = __m._min;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public boolean hasNext()
	{
		__Data__<K, V> at = this._at;
		if (at == null)
			return false;
		return (__detect(at) != null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/06
	 */
	@Override
	public Map.Entry<K, V> next()
	{
		// {@squirreljme.error AC06 No more elements to iterate over.}
		__Data__<K, V> rv = this._at;
		if (rv == null)
			throw new NoSuchElementException("AC06");
		
		// Make sure the value was not removed
		rv = __detect(rv);
		
		// Store last node (for removal) and iterate to the next node value
		this._last = rv;
		this._at = rv._next;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public void remove()
	{
		// {@squirreljme.error AC07 No last entry exists for deletion.}
		__Data__<K, V> last = this._last;
		if (last == null)
			throw new IllegalStateException("AC07");
		
		// Remove the entry
		this._last = null;
		this.map.remove(last._key);
	}
	
	/**
	 * Detects if concurrent modification has occured.
	 *
	 * @param __data The data to check.
	 * @return {@code __data}.
	 * @throws ConcurrentModificationException If modification was detected.
	 * @throws NullPointerException On null arguments. 
	 * @since 2017/03/30
	 */
	private final __Data__<K, V> __detect(__Data__<K, V> __data)
		throws ConcurrentModificationException, NullPointerException
	{
		// Check
		if (__data == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AC08 Referenced node was deleted.}
		if (__data._node == null)
			throw new ConcurrentModificationException("AC08");
		
		return __data;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__Node__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

/**
 * This represents a single node within the tree.
 *
 * @param <K> The key used.
 * @param <V> The value used.
 * @since 2016/09/06
 */
class __Node__<K, V>
{
	/** The color, defaults to red. */
	volatile boolean _isred =
		true;
	
	/** The currently associated data for this node. */
	volatile __Data__<K, V> _data;
	
	/** The node to the left. */
	volatile __Node__<K, V> _left;
	
	/** The node to the right. */
	volatile __Node__<K, V> _right;
	
	/**
	 * Compares this node against the given key.
	 *
	 * @param __n The key to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(K __k)
	{
		return this._data.__compare(__k);
	}
	
	/**
	 * Compares this node against the given data.
	 *
	 * @param __n The data to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Data__<K, V> __d)
	{
		return this._data.__compare(__d);
	}
	
	/**
	 * Compares this node against the given node.
	 *
	 * @param __n The node to compare against.
	 * @return The comparison result.
	 * @since 2017/03/30
	 */
	final int __compare(__Node__<K, V> __n)
	{
		return this._data.__compare(__n);
	}
	
	/**
	 * Makes the node black.
	 *
	 * @since 2017/03/30
	 */
	final void __makeBlack()
	{
		this._isred = false;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/__Sub__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601

























































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.collections;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This is a sub-deque which is given access to the {@link MultiSetDeque}.
 *
 * @since 2016/09/03
 */
final class __Sub__<V>
	implements Deque<V>
{
	/** The owning multi-set. */
	final MultiSetDeque<V> _msd;
	
	/** The list which acts as a queue. */
	final List<V> _deque;
	
	/** The items which are in this queue. */
	final Set<V> _set =
		new HashSet<>();
	
	/** The capacity limit. */
	final int _limit;
	
	/**
	 * Initializes the sub-queue.
	 *
	 * @param __msd The owning queue.
	 * @param __l The size limit of this queue.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/03
	 */
	__Sub__(MultiSetDeque<V> __msd, int __l)
		throws NullPointerException
	{
		// Check
		if (__msd == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._msd = __msd;
		this._limit = __l;
		
		// Base on a list
		this._deque = new ArrayList<>();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean add(V __a)
		throws NullPointerException
	{
		// Remember old size
		List<V> deque = this._deque;
		int was = deque.size();
		
		// Add it
		addLast(__a);
		
		// If the size changed then it was added
		return deque.size() != was;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean addAll(Collection<? extends V> __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Add everything
		boolean rv = false;
		for (V v : __a)
			rv |= add(v);
		
		// Has this changed?
		return rv;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void addFirst(V __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void addLast(V __a)
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AC09 Deque capacity would be exceeded.}
		List<V> deque = this._deque;
		if (deque.size() + 1 >= this._limit)
			throw new IllegalStateException("AC09");
		
		// Do not add the element if it is already in this queue.
		Set<V> set = this._set;
		if (set.contains(__a))
			return;
		
		// Otherwise add it
		deque.add(__a);
		set.add(__a);
		this._msd._master.add(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void clear()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean contains(Object __a)
	{
		return this._deque.contains(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean containsAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Iterator<V> descendingIterator()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V element()
	{
		return getFirst();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean equals(Object __a)
	{
		
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V getFirst()
	{
		// {@squirreljme.error AC0a The deque is empty.}
		List<V> deque = this._deque;
		if (deque.size() <= 0)
			throw new NoSuchElementException("AC0a");
		
		// Just get it
		return deque.get(0);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V getLast()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public int hashCode()
	{
		return this._deque.hashCode();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean isEmpty()
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Iterator<V> iterator()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offer(V __a)
	{
		return offerLast(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offerFirst(V __a)
	{
		try
		{
			addFirst(__a);
			return true;
		}
		
		// Exceeds capacity
		catch (IllegalStateException e)
		{
			return false;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean offerLast(V __a)
	{
		try
		{
			addLast(__a);
			return true;
		}
		
		// Exceeds capacity
		catch (IllegalStateException e)
		{
			return false;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peek()
	{
		return peekFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peekFirst()
	{
		try
		{
			return getFirst();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V peekLast()
	{
		try
		{
			return getLast();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V poll()
	{
		return pollFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pollFirst()
	{
		try
		{
			return removeFirst();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pollLast()
	{
		try
		{
			return removeLast();
		}
		
		// Empty
		catch (NoSuchElementException e)
		{
			return null;
		}
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V pop()
	{
		return removeFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public void push(V __a)
	{
		addFirst(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean remove(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V remove()
	{
		return removeFirst();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V removeFirst()
		throws NoSuchElementException
	{
		// {@squirreljme.error AC0b The deque is empty.}
		List<V> deque = this._deque;
		if (deque.size() <= 0)
			throw new NoSuchElementException("AC0b");
		
		// Remove it
		V rv = deque.remove(0);
		
		// The value is gone from this collection now so remove it
		Set<V> set = this._set;
		set.remove(rv);
		
		// Remove from all over queues
		this._msd.remove(rv);
		
		// Return
		return rv;
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeFirstOccurrence(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public V removeLast()
		throws NoSuchElementException
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean removeLastOccurrence(Object __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public boolean retainAll(Collection<?> __a)
	{
		throw new todo.TODO();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public int size()
	{
		return this._deque.size();
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public <T> T[] toArray(T[] __a)
	{
		return this._deque.<T>toArray(__a);
	}

	/**
	 * {@inheritDoc}
	 * @since 2016/09/03
	 */
	@Override
	public Object[] toArray()
	{
		return this._deque.toArray();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/25
	 */
	@Override
	public String toString()
	{
		return this._deque.toString();
	}
	
	/**
	 * Quick clear of the queue.
	 *
	 * @since 2017/03/25
	 */
	final void __clear()
	{
		this._deque.clear();
		this._set.clear();
	}
	
	/**
	 * Removes the item if it is in this deque.
	 *
	 * @param __v The item to remove.
	 * @return {@code true} if it was removed.
	 * @since 2016/09/03
	 */
	final boolean __remove(V __v)
	{
		// Not in this deque
		Set<V> set = this._set;
		if (!set.contains(__v))
			return false;
		
		// Otherwise remove it
		if (!this._deque.remove(__v))
			throw new todo.OOPS();
		
		// Remove from set
		set.remove(__v);
		
		// Did remove
		return true;
	}
}

Deleted runt/libs/collections/net/multiphasicapps/collections/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains a number of collections.
 *
 * @since 2017/10/26
 */

package net.multiphasicapps.collections;

Deleted runt/libs/common-vm-stubs/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 101f95b0-320f-44c8-a26a-e60343fefb76
X-SquirrelJME-Error: AJ
X-SquirrelJME-Name: SpringCoat VM Java ME Stubs
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the stubs which are 
 needed by non-SquirrelJME Java ME systems, since internal SquirrelJME 
 APIs are used in some classes.
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/AtomicOperation.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class contains utilities for atomic operations.
 *
 * @since 2018/09/08
 */
public final class AtomicOperation
{
	/**
	 * Not used.
	 *
	 * @since 2018/09/08
	 */
	private AtomicOperation()
	{
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/ConsoleOutput.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
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

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import java.io.IOException;

/**
 * Used for printing to the console.
 *
 * @since 2018/09/21
 */
public final class ConsoleOutput
{
	/** Standard output. */
	public static final int OUTPUT =
		1;
	
	/** Standard error. */
	public static final int ERROR =
		2;
	
	/** End of file. */
	public static final int ERROR_EOF =
		-1;
	
	/** Invalid file descriptor. */
	public static final int ERROR_INVALIDFD =
		-2;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/21
	 */
	private ConsoleOutput()
	{
	}
	
	/**
	 * Reads the display console, that is anything which was output to the
	 * console itself.
	 *
	 * @param __dim The output dimensions of the console, columns and rows.
	 * This array must always have a length of at least two.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes which were read, this will be the minimum
	 * of either {@code __dim[0] * __dim[1]} or {@code __l}. Zero may be
	 * returned if this is not supported.
	 * @since 2018/12/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int displayRead(int[] __dim,
		byte[] __b, int __o, int __l)
	{
		// Not supported so always returns zero as nothing read
		return 0;
	}
	
	/**
	 * Flushes the stream.
	 *
	 * @param __fd The file descriptor to flush.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int flush(int __fd)
	{
		if (__fd == OUTPUT)
			System.out.flush();
		
		else if (__fd == ERROR)
			System.err.flush();
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
	
	/**
	 * Writes the character to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __c The byte to write, only the lowest 8-bits are used.
	 * @return Zero on success, negative values for EOF.
	 * @since 2018/09/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int write(int __fd, int __c)
	{
		if (__fd == OUTPUT)
			System.out.write(__c);
		
		else if (__fd == ERROR)
			System.err.write(__c);
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
	
	/**
	 * Writes the given bytes to the console output.
	 *
	 * @param __fd The file descriptor to write to.
	 * @param __b The bytes to write.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return Zero on success, negative values for failure.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int write(int __fd,
		byte[] __b, int __o, int __l)
	{
		if (__fd == OUTPUT)
			System.out.write(__b, __o, __l);
		
		else if (__fd == ERROR)
			System.err.write(__b, __o, __l);
		
		// Unknown
		else
			return ERROR_INVALIDFD;
		
		return 0;
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235











































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to the native display system that is used by the
 * LCDUI code to display widgets and such to the screen. Any application may
 * access the screen directly and must manage exclusivity by itself if such a
 * thing is applicable for a single shared screen resource.
 *
 * @since 2018/11/09
 */
@Deprecated
public final class NativeDisplayAccess
{
	/** The number of parameters available. */
	public static final int NUM_PARAMETERS =
		8;
	
	/** The pixel format. */
	public static final int PARAMETER_PIXELFORMAT =
		0;
	
	/** The buffer width. */
	public static final int PARAMETER_BUFFERWIDTH =
		1;
	
	/** The buffer height. */
	public static final int PARAMETER_BUFFERHEIGHT =
		2;
	
	/** Alpha channel is used? */
	public static final int PARAMETER_ALPHA =
		3;
	
	/** Buffer pitch. */
	public static final int PARAMETER_PITCH =
		4;
	
	/** Buffer offset. */
	public static final int PARAMETER_OFFSET =
		5;
	
	/** Virtual X offset. */
	public static final int PARAMETER_VIRTXOFF =
		6;
	
	/** Virtual Y offset. */
	public static final int PARAMETER_VIRTYOFF =
		7;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/09
	 */
	private NativeDisplayAccess()
	{
	}
	
	/**
	 * Initialize and/or reset accelerated graphics operations.
	 *
	 * @param __id The display to initialize for.
	 * @return {@code true} if acceleration is supported.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean accelGfx(int __id)
	{
		return false;
	}
	
	/**
	 * Performs accelerated graphics operation.
	 *
	 * @param __id The display ID.
	 * @param __func The function to call.
	 * @param __args Arguments to the operation.
	 * @return The result of the operation.
	 * @since 2018/11/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object accelGfxFunc(int __id, int __func,
		Object... __args)
	{
		return null;
	}
	
	/**
	 * Returns the capabilities of the display.
	 *
	 * @param __id The display ID.
	 * @return The capabilities of the display.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int capabilities(int __id)
	{
		return -1;
	}
	
	/**
	 * Requests that the display should be repainted.
	 *
	 * @param __id The display ID.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void displayRepaint(int __id,
		int __x, int __y, int __w, int __h)
	{
	}
	
	/**
	 * Returns the object representing the framebuffer data.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer array.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object framebufferObject(int __id)
	{
		return null;
	}
	
	/**
	 * Returns the palette of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The palette of the framebuffer.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int[] framebufferPalette(int __id)
	{
		return null;
	}
	
	/**
	 * Returns the parameters of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer parameters.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int[] framebufferParameters(int __id)
	{
		return new int[0];
	}
	
	/**
	 * Returns the state count of this framebuffer which is used to detect
	 * when the parameters have changed, where they must all be recalculated
	 * (that is the framebuffer wrapper must be recreated).
	 *
	 * @param __id The display ID.
	 * @return The state count for the framebuffer.
	 * @since 2018/12/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int framebufferStateCount(int __id)
	{
		return 0;
	}
	
	/**
	 * Is the specified display upsidedown?
	 *
	 * @param __id The ID of the display.
	 * @return If the display is upsidedown.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean isUpsideDown(int __id)
	{
		return false;
	}
	
	/**
	 * Returns the number of permanent displays which are currently attached to
	 * the system.
	 *
	 * @return The number of displays attached to the system.
	 * @since 2018/11/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int numDisplays()
	{
		return 0;
	}
	
	/**
	 * Registers the class to be called for when display events are to be
	 * called.
	 *
	 * @param __cb The callback.
	 * @since 2018/12/03
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void registerEventCallback(
		NativeDisplayEventCallback __cb)
	{
	}
	
	/**
	 * Sets the title of the display.
	 *
	 * @param __id The display ID.
	 * @param __t The title to use.
	 * @since 2018/11/18
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void setDisplayTitle(int __id, String __t)
	{
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/ObjectAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322


































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.ClassData;
import cc.squirreljme.runtime.cldc.ref.PrimitiveReference;
import cc.squirreljme.runtime.cldc.ref.PrimitiveWeakReference;

/**
 * This contains accessors for object information.
 *
 * @since 2018/09/22
 */
public final class ObjectAccess
{
	/** Monitor is not owned by this thread. */
	public static final int MONITOR_NOT_OWNED =
		-1;
	
	/** Monitor did not interrupt. */
	public static final int MONITOR_NOT_INTERRUPTED =
		0;
	
	/** Monitor did interrupt. */
	public static final int MONITOR_INTERRUPTED =
		1;
	
	/**
	 * Not used.
	 *
	 * @since 2018/09/22
	 */
	private ObjectAccess()
	{
	}
	
	/**
	 * Allocates an object but does not construct it
	 *
	 * @param __cl The class to allocate.
	 * @return An object for the class, it is not initialized with a
	 * constructor. Returns {@code null} if no more memory is available.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object allocateObject(String __cl)
	{
		return null;
	}
	
	/**
	 * Returns the length of the given array.
	 *
	 * @param __a The array to get the length of.
	 * @return The length of the array or {@code -1} if it is not an
	 * array.
	 * @since 2018/09/25
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int arrayLength(Object __a)
	{
		if (__a instanceof Object[])
			return ((Object[])__a).length;
		else if (__a instanceof boolean[])
			return ((boolean[])__a).length;
		else if (__a instanceof byte[])
			return ((byte[])__a).length;
		else if (__a instanceof short[])
			return ((short[])__a).length;
		else if (__a instanceof char[])
			return ((char[])__a).length;
		else if (__a instanceof int[])
			return ((int[])__a).length;
		else if (__a instanceof long[])
			return ((long[])__a).length;
		else if (__a instanceof float[])
			return ((float[])__a).length;
		else if (__a instanceof double[])
			return ((double[])__a).length;
		return -1;
	}
	
	/**
	 * Creates a new array of the given type, this is the actual array and
	 * not the component.
	 *
	 * @param __t The array type, not the component type.
	 * @param __l The array length.
	 * @return An array allocated to the given length.
	 * @since 2018/09/25
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object arrayNew(Class<?> __t, int __l)
	{
		return null;
	}
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Class<?> classByName(String __s)
	{
		try
		{
			return Class.forName(__s.replace('/', '.'));
		}
		catch (ClassNotFoundException e)
		{
			return null;
		}
	}
	
	/**
	 * Returns the class data which is attached to the given class object.
	 *
	 * @param __cl The class to get the data from.
	 * @return The resulting class data.
	 * @since 2018/12/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final ClassData classData(Class<?> __cl)
	{
		// {@squirreljme.error AJ01 Cannot obtain class data.}
		throw new Error("AJ01");
	}
	
	/**
	 * Returns the class object for the given object.
	 *
	 * @param __v The object to get the class of.
	 * @return The class of the given object, or {@code null} if it has no
	 * class.
	 * @since 2018/09/22
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Class<?> classOf(Object __v)
	{
		if (__v == null)
			return null;
		return __v.getClass();
	}
	
	/**
	 * Checks if the given thread holds the given object in a lock.
	 *
	 * @param __ntid The native thread ID.
	 * @param __o The object to check.
	 * @return If the lock is held.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean holdsLock(int __ntid, Object __o)
	{
		if (__ntid == Thread.currentThread().getId())
			Thread.holdsLock(__o);
		
		// {@squirreljme.error AJ02 Cannot check if another thread holds
		// a lock for an object.}
		throw new Error("AJ02");
	}
	
	/**
	 * Returns the identity hashcode of the object.
	 *
	 * @return The identity hashcode.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int identityHashCode(Object __o)
	{
		return System.identityHashCode(__o);
	}
	
	/**
	 * Invokes the specified static method.
	 *
	 * @param __m The method to invoke.
	 * @param __args Arguments to the method, the parameters will be passed
	 * as-is and will not be unboxed, so the method must accept boxed values.
	 * @return The value to return from the method, {@code void} will return
	 * {@code null}.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object invokeStatic(StaticMethod __m, Object... __args)
	{
		// {@squirreljme.error AJ03 Cannot invoke static method.}
		throw new Error("AJ03");
	}
	
	/**
	 * Notifies threads waiting on the monitor.
	 *
	 * @param __o The object to notify.
	 * @param __all Notify all threads?
	 * @return If the monitor was a success or not.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int monitorNotify(Object __o, boolean __all)
	{
		try
		{
			if (__all)
				__o.notifyAll();
			else
				__o.notify();
			
			return MONITOR_NOT_INTERRUPTED;
		}
		catch (IllegalMonitorStateException e)
		{
			return MONITOR_NOT_OWNED;
		}
	}
	
	/**
	 * Waits for a notification on a monitor.
	 *
	 * @param __o The object to wait on.
	 * @param __ms The milliseconds.
	 * @param __ns The nanoseconds.
	 * @return The wait status.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int monitorWait(Object __o, long __ms,
		int __ns)
	{
		try
		{
			if (__ms == 0 && __ns == 0)
				__o.wait();
			else
				__o.wait(__ms, __ns);
			
			return MONITOR_NOT_INTERRUPTED;
		}
		catch (IllegalMonitorStateException e)
		{
			return MONITOR_NOT_OWNED;
		}
		catch (InterruptedException e)
		{
			return MONITOR_INTERRUPTED;
		}
	}
	
	/**
	 * Creates a new primitive weak reference. Note that it is not valid to
	 * operate on this object as a normal object, it is a special
	 * representation.
	 *
	 * @return The primitive weak reference.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final PrimitiveReference newWeakReference()
	{
		return new __WeakRef__();
	}
	
	/**
	 * Gets the given reference.
	 *
	 * @param __r The reference to read from.
	 * @return The reference value, may be {@code null} if the input reference
	 * is not valid, it was garbage collected, or it was never set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final Object referenceGet(PrimitiveReference __r)
	{
		return ((__WeakRef__)__r).__get();
	}
	
	/**
	 * Sets the given reference to the given value.
	 *
	 * @param __r The reference to set.
	 * @param __v The value to set.
	 * @since 2018/09/23
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void referenceSet(PrimitiveReference __r,
		Object __v)
	{
		((__WeakRef__)__r).__set(__v);
	}
	
	/**
	 * Returns the class object for the specified class by its binary name.
	 *
	 * @param <C> The class to type this as.
	 * @param __s The class to lookup, the binary name is used.
	 * @return The class for the given binary name, or {@code null} if it
	 * does not exist.
	 * @since 2018/09/23 
	 */
	@SuppressWarnings({"unchecked"})
	public static final <C> Class<C> classByNameType(String __s)
	{
		return (Class<C>)((Object)ObjectAccess.classByName(__s));
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/ResourceAccess.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
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




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to resources and their raw data streams.
 *
 * Access to resources relies on the suites, so the correct suite must be
 * specified. {@link Class#getResourceAsStream(String)} should handle this.
 *
 * @since 2018/10/07
 */
public final class ResourceAccess
{
	/** Resource does not exist. */
	public static final int OPEN_STATUS_NO_RESOURCE =
		-1;
	
	/** JAR does not exist. */
	public static final int OPEN_STATUS_NO_JAR =
		-2;
	
	/** IOException. */
	public static final int OPEN_STATUS_IOEXCEPTION =
		-3;
	
	/** Read returned EOF. */
	public static final int READ_STATUS_EOF =
		-1;
	
	/** Read returned unknown file descriptor. */
	public static final int READ_STATUS_UNKNOWN_FD =
		-2;
	
	/** Read returned IOException. */
	public static final int READ_STATUS_IOEXCEPTION =
		-3;
	
	/** Descriptor was not found. */
	public static final int CLOSE_STATUS_UNKNOWN_FD =
		-2;
	
	/** Close resulted in any IOException. */
	public static final int CLOSE_STATUS_IOEXCEPTION =
		-3;
	
	/**
	 * Returns the number of bytes which are known to be available. This is
	 * not required to be supported but is available for usage if it would
	 * result in optimization.
	 *
	 * If this is not supported by a resource then zero or a negative value
	 * may be returned.
	 *
	 * @param __fd The file descriptor to check.
	 * @return The number of available bytes.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int available(int __fd)
	{
		return READ_STATUS_UNKNOWN_FD;
	}
	
	/**
	 * Closes the given resource.
	 *
	 * @param __fd The resource descriptor to close.
	 * @return A negative value indicating the reason for the failure.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int close(int __fd)
	{
		return CLOSE_STATUS_UNKNOWN_FD;
	}
	
	/**
	 * Opens the specified resource in the given JAR.
	 *
	 * @param __jar The JAR the resource is in, this specifies the name of a
	 * suite.
	 * @param __res The name of the resource to load.
	 * @return The file descriptor or a negative value if it does not exist.
	 * If {@code -2} is returned that means there was an exception trying to
	 * load the resource.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int open(String __jar, String __res)
	{
		return OPEN_STATUS_NO_JAR;
	}
	
	/**
	 * Reads data from the given resource.
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output byte array.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative value if the end of
	 * stream was reached.
	 * @since 2018/10/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int read(int __fd, byte[] __b, int __o,
		int __l)
	{
		return READ_STATUS_UNKNOWN_FD;
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/SuiteAccess.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to suites and other suites which are available for usage.
 *
 * @since 2018/10/26
 */
public class SuiteAccess
{
	/**
	 * Returns the suites which are available for usage.
	 *
	 * @return The suites which are available for usage.
	 * @since 2018/10/26
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String[] availableSuites()
	{
		return new String[0];
	}
	
	/**
	 * Returns the current classpath that is being used.
	 *
	 * @return The current classpath.
	 * @since 2018/12/06
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String[] currentClassPath()
	{
		return new String[0];
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/SystemAccess.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * Access to system related details.
 *
 * @since 2018/10/13
 */
public final class SystemAccess
{
	/**
	 * Not used.
	 *
	 * @since 2018/10/13
	 */
	private SystemAccess()
	{
	}
	
	/**
	 * Exits the process with the system exit code.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void exit(int __code)
	{
		System.exit(__code);
	}
	
	/**
	 * Returns the specified environment variable, it is unspecified and
	 * system dependent if variables are case sensitive or not. Locale may
	 * be considered by the host system additionally. If environment variables
	 * do not exist in the environment then only {@code null} will be
	 * returned.
	 *
	 * @param __e The environment variable to get.
	 * @return The value of that variable or {@code null} if it is not set.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String getEnv(String __e)
	{
		return null;
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/SystemProperties.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
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























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import cc.squirreljme.runtime.cldc.SquirrelJME;

/**
 * Access to system properties.
 *
 * @since 2018/09/20
 */
public final class SystemProperties
{
	/**
	 * Not used.
	 *
	 * @since 2018/09/20
	 */
	private SystemProperties()
	{
	}
	
	/**
	 * Returns the API level of the virtual machine.
	 *
	 * @return The API level.
	 * @since 2018/12/05
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static int apiLevel()
	{
		return ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225;
	}
	
	/**
	 * Returns the approximated path where the VM's executable exists. This
	 * will be the actual JVM's JAR or EXE file.
	 *
	 * @return The approximated executable path or {@code null} if it is not
	 * known.
	 * @since 2018/12/08
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String executablePath()
	{
		return null;
	}
	
	/**
	 * Returns the depth of the guests within the virtual machine.
	 *
	 * @return The number of guests.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int guestDepth()
	{
		return 0;
	}
	
	/**
	 * The class to use for a given implementation of something.
	 *
	 * @param __n The class name to lookup.
	 * @return The class that should get its instance created or {@code null}
	 * if there is no implementation.
	 * @since 2018/12/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final String implementationClass(String __n)
	{
		return null;
	}
	
	/**
	 * Returns the e-mail to contact for the virtual machine.
	 *
	 * @return The contact e-mail for the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMEmail()
	{
		return "xer@multiphasicapps.net";
	}
	
	/**
	 * Returns the name of the Java virtual machine.
	 *
	 * @return The name of the virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMName()
	{
		return "Common VM Stub Environment";
	}
	
	/**
	 * Returns the URL to the virtual machine's vendor's URL.
	 *
	 * @return The URL of the JVM's virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMURL()
	{
		return "http://multiphasicapps.net/";
	}
	
	/**
	 * Returns the vendor of the Java virtual machine.
	 *
	 * @return The vendor of the Java virtual machine.
	 * @since 2017/10/02
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMVendor()
	{
		return "Stephanie Gawroriski";
	}
	
	/**
	 * Returns the full version of the Java virtual machine.
	 *
	 * @return The full Java virtual machine version.
	 * @since 2017/08/13
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String javaVMVersion()
	{
		return "0.3.0";
	}
	
	/**
	 * Returns the type of operating SquirrelJME is running on.
	 *
	 * @return The type of operating system SquirrelJME is running on.
	 * @since 2018/10/14
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int operatingSystemType()
	{
		return OperatingSystemType.UNKNOWN;
	}
	
	/**
	 * Returns a system property for the given value.
	 *
	 * @param __k The key to get.
	 * @return The value of the property, will be {@code null} if it is not
	 * valid.
	 * @since 2018/09/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static String systemProperty(String __k)
	{
		return System.getProperty(__k);
	}
	
	/**
	 * Returns the version of the class libraries.
	 *
	 * @return The class library version.
	 * @since 2017/10/02
	 */
	public static String javaRuntimeVersion()
	{
		return SquirrelJME.RUNTIME_VERSION;
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/TaskAccess.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
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





























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.annotation.Api;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;

/**
 * This class provides access to tasks which are running.
 *
 * @since 2018/11/04
 */
public final class TaskAccess
{
	/** The entry point is not valid. */
	public static final int ERROR_INVALID_ENTRY =
		-2;
	
	/** Library in the classpath is missing. */
	public static final int ERROR_MISSING_LIBRARY =
		-3;
	
	/** Exit code indicating bad task things. */
	public static final int EXIT_CODE_FATAL_EXCEPTION =
		127;
	
	/**
	 * Not used.
	 *
	 * @since 2018/11/04
	 */
	private TaskAccess()
	{
	}
	
	/**
	 * Returns the ID of the current thread.
	 *
	 * @return The current thread ID.
	 * @since 2018/11/20
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int currentThread()
	{
		return (int)Thread.currentThread().getId();
	}
	
	/**
	 * Sets the priority of the thread.
	 *
	 * @param __tid The thread ID.
	 * @param __p The priority.
	 * @since 2018/12/07
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void setThreadPriority(int __tid, int __p)
	{
	}
	
	/**
	 * Signals a hardware interrupt on the given thread.
	 *
	 * @param __tid The thread to signal.
	 * @since 2018/11/21
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final void signalInterrupt(int __tid)
	{
		// {@squirreljme.error AJ04 Cannot interrupt threads using this method
		// as it is not implemented.}
		throw new Error("AJ04");
	}
	
	/**
	 * Causes the thread to sleep for the given milliseconds and nanoseconds.
	 *
	 * If both values are zero this means to yield instead.
	 *
	 * @param __ms The milliseconds to sleep for.
	 * @param __ns The nanoseconds to sleep for, in the range of 0-999999.
	 * @return {@code true} if the thread was interrupted, otherwise
	 * {@code false}.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final boolean sleep(long __ms, int __ns)
	{
		try
		{
			if (__ms == 0 && __ns == 0)
				Thread.yield();
			else
				Thread.sleep(__ms, __ns);
			
			return true;
		}
		catch (InterruptedException e)
		{
			return false;
		}
	}
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The classpath used.
	 * @param __main The main entry point.
	 * @param __args Arguments to start the task with.
	 * @return The task identifier or a negative number if the task could
	 * not start.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int startTask(String[] __cp, String __main,
		String[] __args)
	{
		return -1;
	}
	
	/**
	 * Starts the given thread.
	 *
	 * @param __t The thread which is to run, the execution point of the
	 * thread is the {@link Thread#__start()} method.
	 * @param __n The name hint of this thread.
	 * @return The thread ID.
	 * @since 2018/11/17
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int startThread(Thread __t, String __n)
	{
		__t.start();
		return (int)__t.getId();
	}
	
	/**
	 * Returns the status of the target task.
	 *
	 * @param __tid The task to get the status of.
	 * @return The status for the given task.
	 * @since 2018/11/04
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	public static final int taskStatus(int __tid)
	{
		return -1;
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/__WeakRef__.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.asm;

import cc.squirreljme.runtime.cldc.ref.PrimitiveWeakReference;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * Primitive weak reference.
 *
 * @since 2018/12/05
 */
class __WeakRef__
	implements PrimitiveWeakReference
{
	/** The reference. */
	volatile Reference<Object> _ref;
	
	/**
	 * Gets the value.
	 *
	 * @return The value.
	 * @since 2018/12/05
	 */
	final Object __get()
	{
		synchronized (this)
		{
			Reference<Object> ref = this._ref;
			if (ref == null)
				return null;
			return ref.get();
		}
	}
	
	/**
	 * Sets the value.
	 *
	 * @param __v The value.
	 * @since 2018/12/05
	 */
	final void __set(Object __v)
	{
		synchronized (this)
		{
			Reference<Object> ref = this._ref;
			
			// {@squirreljme.error AJ05 Cannot set weak reference which has
			// already been set.}
			if (__v == null)
				if (ref == null)
				{
					// Do nothing
				}
				else
					ref.clear();
			else
				if (ref == null)
					this._ref = new WeakReference<>(__v);
				else
					throw new Error("AJ05");
		}
	}
}

Deleted runt/libs/common-vm-stubs/cc/squirreljme/runtime/cldc/asm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains static methods which in which invocations of methods
 * in the package are replaced by the compiler using native means.
 *
 * @since 2017/12/27
 */

package cc.squirreljme.runtime.cldc.asm;

Deleted runt/libs/common-vm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: d8b70873-cf2b-4a8b-9cb4-a0a6cb1412fd
X-SquirrelJME-Error: AK
X-SquirrelJME-Name: Common Virtual Machine Classes
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains classes which are common across 
 the various SquirrelJME VMs, and these only need to be written once 
 as such.
X-SquirrelJME-Depends: midp-lcdui meep-swm meep-midlet tool-profiler 
 tool-manifest-reader zip
Microedition-Configuration: CLDC-1.8

Deleted runt/libs/common-vm/cc/squirreljme/vm/InMemoryClassLibrary.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
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















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This represents a class library which has been read into memory.
 *
 * @since 2018/12/08
 */
public final class InMemoryClassLibrary
	implements VMClassLibrary
{
	/** The name of this library. */
	protected final String name;
	
	/** The cache. */
	private final Map<String, byte[]> _cache;
	
	/**
	 * Internally initializes the library.
	 *
	 * @param __n The name.
	 * @param __m The internal mapping.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	private InMemoryClassLibrary(String __n, Map<String, byte[]> __m)
		throws NullPointerException
	{
		if (__n == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this._cache = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final String[] listResources()
	{
		Collection<String> names = this._cache.keySet();
		return names.<String>toArray(new String[names.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		// See if the byte data exists
		byte[] rv = this._cache.get(__rc);
		if (rv == null)
			return null;
		
		// Then use a byte array on it
		return new ByteArrayInputStream(rv);
	}
	
	/**
	 * Loads ZIP file data.
	 *
	 * @param __n The library name.
	 * @param __in The input stream.
	 * @return The class library.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	public static final InMemoryClassLibrary loadZip(String __n,
		ZipStreamReader __in)
		throws IOException, NullPointerException
	{
		if (__n == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Target map
		Map<String, byte[]> rv = new HashMap<>();
		
		ZipStreamEntry zse;
		while (null != (zse = __in.nextEntry()))
		{
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
			{
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = zse.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Cache
				rv.put(zse.name(), baos.toByteArray());
			}
			
			// Close
			zse.close();
		}
		
		return new InMemoryClassLibrary(__n, rv);
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/MergedSuiteManager.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
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


























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This is a suite manager which merges multiple suite managers into one so
 * that more libraries from different sources may be included.
 *
 * @since 2018/12/08
 */
public final class MergedSuiteManager
	implements VMSuiteManager
{
	/** The source managers. */
	private final VMSuiteManager[] _sources;
	
	/**
	 * Initializes the merged suite manager.
	 *
	 * @param __s The sources to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	public MergedSuiteManager(VMSuiteManager... __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Defensive copy and check for nulls
		__s = __s.clone();
		for (VMSuiteManager s : __s)
			if (s == null)
				throw new NullPointerException("NARG");
		
		this._sources = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String[] listLibraryNames()
	{
		Set<String> rv = new LinkedHashSet<>();
		
		// Add libraries that exist, but do not duplicate them!
		for (VMSuiteManager m : this._sources)
			for (String s : m.listLibraryNames())
				rv.add(s);
		
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Go through the libraries and see if any exist
		for (VMSuiteManager m : this._sources)
		{
			VMClassLibrary rv = m.loadLibrary(__s);
			if (rv != null)
				return rv;
		}
		
		// Not found
		return null;
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/PathSuiteManager.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.InputStream;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This is a suite manager which uses the filesystem.
 *
 * @since 2018/12/08
 */
public final class PathSuiteManager
	implements VMSuiteManager
{
	/** The base lib directory. */
	protected final Path libpath;
	
	/** Cache of loaded libraries. */
	private final Map<String, VMClassLibrary> _cache =
		new HashMap<>();
	
	/**
	 * Initializes the suite manager.
	 *
	 * @param __lp The library path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/09
	 */
	public PathSuiteManager(Path __lp)
		throws NullPointerException
	{
		if (__lp == null)
			throw new NullPointerException("NARG");
		
		this.libpath = __lp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final String[] listLibraryNames()
	{
		// Could fail
		try
		{
			Set<String> rv = new LinkedHashSet<>();
			
			// Go through directory entries
			try (DirectoryStream<Path> dir = Files.newDirectoryStream(
				this.libpath))
			{
				for (Path p : dir)
				{
					// Ignore directories
					if (Files.isDirectory(p))
						continue;
					
					String fn = p.getFileName().toString();
					if (fn.endsWith(".jar") || fn.endsWith(".JAR"))
						rv.add(fn);
				}
			}
			
			return rv.<String>toArray(new String[rv.size()]);
		}
		
		// Was not found, ignore
		catch (NoSuchFileException e)
		{
			return new String[0];
		}
		
		// Could not load!
		catch (IOException e)
		{
			e.printStackTrace();
			
			return new String[0];
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/08
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, VMClassLibrary> cache = this._cache;
		synchronized (cache)
		{
			VMClassLibrary rv = cache.get(__s);
			if (rv != null)
				return rv;
			
			// Pre-cached to not exist
			if (cache.containsKey(__s))
				return null;
			
			// Open file and stream the ZIP
			try (InputStream in = Files.newInputStream(
				this.libpath.resolve(__s), StandardOpenOption.READ);
				ZipStreamReader zsr = new ZipStreamReader(in))
			{
				cache.put(__s, (rv = InMemoryClassLibrary.loadZip(__s, zsr)));
				return rv;
			}
			
			// Does not exist, stop
			catch (NoSuchFileException e)
			{
				cache.put(__s, null);
				return null;
			}
			
			// Exists but it is not valid, verbosely fail
			catch (IOException e)
			{
				e.printStackTrace();
				
				cache.put(__s, null);
				return null;
			}
		}
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/ResourceBasedClassLibrary.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
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

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.List;

/**
 * This is a class library resource which is based on class resources.
 *
 * @since 2018/11/14
 */
public final class ResourceBasedClassLibrary
	implements VMClassLibrary
{
	/** The class to get resources from. */
	protected final Class<?> actingclass;
	
	/** The prefix for entries. */
	protected final String prefix;
	
	/** The name of this library. */
	protected final String name;
	
	/** Resources in this class. */
	private String[] _resources;
	
	/**
	 * Initializes the resource based class library.
	 *
	 * @param __act The class to act on.
	 * @param __pre The prefix for lookup.
	 * @param __name The name of the library.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/15
	 */
	public ResourceBasedClassLibrary(Class<?> __act, String __pre,
		String __name)
		throws NullPointerException
	{
		if (__act == null || __pre == null || __name == null)
			throw new NullPointerException("NARG");
		
		this.actingclass = __act;
		this.prefix = __pre;
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final String[] listResources()
	{
		// Pre-cached?
		String[] rv = this._resources;
		if (rv != null)
			return rv.clone();
		
		// Load in the resource list
		List<String> list = new LinkedList<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
			this.resourceAsStream("META-INF/squirreljme/resources.list"),
			"utf-8")))
		{
			String ln;
			while ((ln = br.readLine()) != null)
			{
				// Blank lines are not resources
				if (ln.isEmpty())
					continue;
				
				// Add otherwise
				list.add(ln);
			}
		}
		
		// {@squirreljme.error AK09 Could not load resource list.}
		catch (IOException e)
		{
			throw new VMException("AK09");
		}
		
		// Cache it and return
		this._resources = (rv = list.<String>toArray(new String[list.size()]));
		return rv.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		return this.actingclass.getResourceAsStream(
			this.prefix + __rc);
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/ResourceBasedSuiteManager.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
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








































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This is a suite manager which is based on resources for accessing various
 * classes and other resources.
 *
 * @since 2018/11/14
 */
public final class ResourceBasedSuiteManager
	implements VMSuiteManager
{
	/** The class to get resources from. */
	protected final Class<?> actingclass;
	
	/** The prefix for libraries. */
	protected final String prefix;
	
	/** Cache of libraries. */
	private final Map<String, VMClassLibrary> _cache =
		new HashMap<>();
	
	/** Cache of all available suites. */
	private String[] _libs;
	
	/**
	 * Initializes the suite manager.
	 *
	 * @param __act The class to source resources from.
	 * @param __prefix The prefix for library lookup.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/14
	 */
	public ResourceBasedSuiteManager(Class<?> __act, String __prefix)
		throws NullPointerException
	{
		if (__act == null || __prefix == null)
			throw new NullPointerException("NARG");
		
		this.actingclass = __act;
		this.prefix = __prefix;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final String[] listLibraryNames()
	{
		// Resources are fixed, so if this was done already use the cached
		// form instead
		String[] libs = this._libs;
		if (libs != null)
			return libs.clone();
		
		// There should be a suite list
		try (InputStream in = this.actingclass.getResourceAsStream(
			this.prefix + "suites.list"))
		{
			// Does not exist, so there is no known library list
			if (in == null)
			{
				this._libs = (libs = new String[0]);
				return libs;
			}
			
			// Will just be a normal list
			List<String> rv = new ArrayList<>();
			try (BufferedReader br = new BufferedReader(
				new InputStreamReader(in, "utf-8")))
			{
				for (;;)
				{
					String ln = br.readLine();
					
					// EOF
					if (ln == null)
						break;
					
					// Trim and ignore empty lines
					ln = ln.trim();
					if (ln.isEmpty())
						continue;
					
					// Add otherwise
					rv.add(ln);
				}
			}
			
			// Cache and return
			this._libs = (libs = rv.<String>toArray(new String[rv.size()]));
			return libs;
		}
		
		// {@squirreljme.error AK01 Could not read the library list.}
		catch (IOException e)
		{
			throw new RuntimeException("AK01", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final VMClassLibrary loadLibrary(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		Map<String, VMClassLibrary> cache = this._cache;
		synchronized (cache)
		{
			// Already got?
			VMClassLibrary rv = cache.get(__s);
			if (rv != null)
				return rv;
			
			// Pre-cached to not exist
			if (cache.containsKey(__s))
				return null;
			
			// Make sure it is actually valid
			boolean found = false;
			for (String q : this.listLibraryNames())
				if ((found |= q.equals(__s)))
					break;
			
			// If it was not found, it does not exist so cache it and fail
			if (!found)
			{
				cache.put(__s, null);
				return null;
			}
			
			// Load and store it
			cache.put(__s,
				(rv = new ResourceBasedClassLibrary(this.actingclass,
					this.prefix + __s + '/', __s)));
			
			return rv;
		}
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMClassLibrary.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.InputStream;
import java.io.IOException;

/**
 * This class represents a class library which represents a single JAR file
 * whether it exists on the disk or is virtually provided.
 *
 * @since 2018/09/13
 */
public interface VMClassLibrary
{
	/**
	 * Lists the names of the resources in this library.
	 *
	 * @return The resource names.
	 * @since 2019/04/21
	 */
	public abstract String[] listResources();
	
	/**
	 * Returns the name of this library.
	 *
	 * @return The library name.
	 * @since 2018/09/13
	 */
	public abstract String name();
	
	/**
	 * Opens the specified resource as a stream.
	 *
	 * @param __rc The name of the resource to open.
	 * @return The stream to the resource data or {@code null} if it is not
	 * valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/13
	 */
	public abstract InputStream resourceAsStream(String __rc)
		throws IOException, NullPointerException;
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMEntryShadedMIDlet.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is the main entry point for MIDlets to the VM.
 *
 * @since 2018/11/16
 */
public class VMEntryShadedMIDlet
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/16
	 */
	@Override
	protected final void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
		// Not used
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/16
	 */
	@Override
	protected final void startApp()
		throws MIDletStateChangeException
	{
		VMFactory.shadedMain();
	}
}


Deleted runt/libs/common-vm/cc/squirreljme/vm/VMEntryShadedMain.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

/**
 * Shaded main entry point for the virtual machine.
 *
 * @since 2018/11/17
 */
public class VMEntryShadedMain
{
	/**
	 * Main entry class.
	 *
	 * @param __args Program arguments.
	 * @since 2018/11/16
	 */
	public static void main(String... __args)
	{
		VMFactory.shadedMain(__args);
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

/**
 * Base class for exceptions in the virtual machine.
 *
 * @since 2018/11/17
 */
public class VMException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/11/17
	 */
	public VMException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/11/17
	 */
	public VMException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/11/17
	 */
	public VMException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/11/17
	 */
	public VMException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470






















































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This class is used to initialize virtual machines based on a set of factory
 * classes.
 *
 * This was added because there were many cases where tons of code was
 * duplicated to initialize the virtual machine, which were effectively
 * copy and pasted to each other so this will remove that.
 *
 * This uses the service loader to locate factories which are available.
 *
 * @since 2018/11/17
 */
public abstract class VMFactory
{
	/** The name of the VM implementation. */
	protected final String name;
	
	/**
	 * Initializes the factory.
	 *
	 * @param __name The name of the virtual machine.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/17
	 */
	public VMFactory(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
	}
	
	/**
	 * Creates the virtual machine using the given parameters.
	 *
	 * @param __ps The profiler snapshot to write to.
	 * @param __sm The suite manager.
	 * @param __cp The classpath to initialize with.
	 * @param __maincl The main class to start executing.
	 * @param __ismid Is the main class a MIDlet?
	 * @param __gd The guest depth of the virtual machine.
	 * @param __sprops System properties for the running program.
	 * @param __args Arguments for the running program.
	 * @return An instance of the virtual machine.
	 * @throws IllegalArgumentException If an input argument is not valid.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If the virtual machine could not be created.
	 * @since 2018/11/17
	 */
	protected abstract VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException;
	
	/**
	 * Main entry point for the virtual machine using the given properties.
	 *
	 * @param __vm The name of the virtual machine to use, if {@code null}
	 * then this is automatically determined.
	 * @param __ps The profiler snapshot to use.
	 * @param __sm The suite manager used.
	 * @param __cp The starting class path.
	 * @param __bootcl The booting class, if {@code null} then {@code __bootid}
	 * is used instead.
	 * @param __bootid The booting index, if negative then {@code __bootcl}
	 * is used instead. This value takes priority.
	 * @param __gd The guest depth of the virtual machine, if negative this
	 * is automatically determined.
	 * @param __sprops System properties to pass to the target VM.
	 * @param __args Arguments to the program which is running.
	 * @throws IllegalArgumentException If neither a boot class or boot ID
	 * were specified.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If the virtual machine failed to initialize.
	 * @since 2018/11/17
	 */
	public static final VirtualMachine main(String __vm, ProfilerSnapshot __ps,
		VMSuiteManager __sm, String[] __cp, String __bootcl, int __bootid,
		int __gd, Map<String, String> __sprops, String... __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		if (__sm == null || __cp == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AK02 Neither the boot class or boot ID was
		// specified, one must be specified.}
		if (__bootcl == null && __bootid < 0)
			throw new IllegalArgumentException("AK02");
		
		// Always exists
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// If not specified, check the system property that specifies the VM
		if (__vm == null)
			try
			{
				// {@squirreljme.property cc.squirreljme.vm.name Specifies the
				// name of the virtual machine to use.}
				__vm = VMFactory.__getProperty(__sprops,
					"cc.squirreljme.vm.name");
			}
			catch (SecurityException e)
			{
			}
		
		// If none specified, default to SpringCoat
		if (__vm == null)
			__vm = "springcoat";
		
		// Determine the virtual machine to use
		VMFactory factory = null;
		for (VMFactory f : ServiceLoader.<VMFactory>load(VMFactory.class))
		{
			// If no name was specified then use the first one, otherwise
			// use the one which matches the name
			if (__vm == null || __vm.equalsIgnoreCase(f.name))
			{
				factory = f;
				break;
			}
		}
		
		// {@squirreljme.error AK03 The specified virtual machine does not
		// exist. (The virtual machine name)}
		if (factory == null)
			throw new VMException("AK03 " + __vm);
		
		// Automatically determined guest depth? This is always deeper!
		if (__gd < 0)
			__gd = GuestDepth.guestDepth() + 1;
		
		// Always make a profiler snapshot exist
		if (__ps == null)
			__ps = new ProfilerSnapshot();
		
		// Go through the suites and load the classpath that we are using
		int numlibs = __cp.length;
		VMClassLibrary[] classpath = new VMClassLibrary[numlibs];
		for (int i = 0; i < numlibs; i++)
			classpath[i] = __sm.loadLibrary(__cp[i]);
		
		// Need to load the manifest where the entry points will be
		VMClassLibrary bl = classpath[numlibs - 1];
		EntryPoints entries;
		try (InputStream in = bl.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// {@squirreljme.error AK04 Entry point JAR has no manifest.}
			if (in == null)
				throw new VMException("AK04");
			
			entries = new EntryPoints(new JavaManifest(in));
		}
		
		// {@squirreljme.error AK05 Failed to read the manifest.}
		catch (IOException e)
		{
			throw new VMException("AK05", e);
		}
		
		// Print them out for debug
		System.err.println("Entry points:");
		for (int i = 0, n = entries.size(); i < n; i++)
			System.err.printf("    %d: %s%n", i, entries.get(i));
		
		// If a class was specified and not a boot ID, we must search through
		// the boot JAR's (the last one) entry points for a match
		if (__bootid < 0)
		{
			// Determine the entry point used
			for (int i = 0, n = entries.size(); i < n; i++)
				if (__bootcl.equals(entries.get(i).entryPoint()))
				{
					__bootid = i;
					break;
				}
			
			// {@squirreljme.error AK06 Could not find the specified main
			// class in the entry point list. (The main class)}
			if (__bootid < 0)
				throw new VMException("AK06 " + __bootcl);
		}
		
		// Do not use an entry point which is outside of the bounds
		__bootid = Math.max(0, Math.min(entries.size(), __bootid));
		
		// Is this entry point a MIDlet? Used as a hint
		EntryPoint entry = entries.get(__bootid);
		boolean ismidlet = entry.isMidlet();
		
		// Create the virtual machine now that everything is available
		return factory.createVM(__ps, __sm, classpath, entry.entryPoint(),
			ismidlet, __gd, __sprops, __args);
	}
	
	/**
	 * Shaded main entry point.
	 *
	 * @param __args Arguments to the program.
	 * @since 2018/11/17
	 */
	public static final void shadedMain(String... __args)
	{
		VMFactory.shadedMain((Map<String, String>)null, __args);
	}
	
	/**
	 * Shaded main entry point, with extra properties map.
	 *
	 * @param __sprops Properties map to use.
	 * @param __args Arguments to the program.
	 * @since 2018/11/17
	 */
	public static final void shadedMain(Map<String, String> __sprops,
		String... __args)
	{
		// Defensive copy and force to exist
		__args = (__args == null ? new String[0] : __args.clone());
		__sprops = (__sprops == null ? new HashMap<String, String>() :
			new HashMap<String, String>(__sprops));
		
		// We may be able to grab some properties from the shaded manifest
		// information, if one is even available
		JavaManifest man;
		try (InputStream in = VMFactory.class.getResourceAsStream(
			"/META-INF/SQUIRRELJME-SHADED.MF"))
		{
			man = (in == null ? new JavaManifest() : new JavaManifest(in));
		}
		
		// {@squirreljme.error AK07 Could not read the manifest to load the
		// launcher's classpath.}
		catch (IOException e)
		{
			throw new RuntimeException("AK07", e);
		}
		
		// These are parameters which will be parsed to handle how to start
		// the shaded process
		String useactiveclass = null,
			useprefix = null,
			usecp = null,
			usemain = null;
		int bootid = -1;
		
		// Profiler snapshot to generate to
		ProfilerSnapshot psnap = null;
		
		// Try loading these from properties first, to take more priority
		try
		{
			// {@squirreljme.property cc.squirreljme.vm.shadeactiveclass=class
			// The class to use to load resources from.}
			useactiveclass = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeactiveclass");
			
			// {@squirreljme.property cc.squirreljme.vm.shadeprefix=prefix
			// The resource lookup prefix for the classes.}
			useprefix = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeprefix");
			
			// {@squirreljme.property cc.squirreljme.vm.shadeclasspath=[class:]
			// The classes which make up the class path for execution.}
			usecp = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadeclasspath");
			
			// {@squirreljme.property cc.squirreljme.vm.shademain=class
			// The class to use as the main entry point for the VM.}
			usemain = VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shademain");
			
			// {@squirreljme.property cc.squirreljme.vm.shadebootid=id
			// The MIDlet or Main class number to use for entering the JAR.}
			bootid = Integer.valueOf(VMFactory.__getProperty(__sprops,
				"cc.squirreljme.vm.shadebootid", "-1"));
		}
		catch (SecurityException e)
		{
			// Ignore
		}
		
		// If properties were not defined in the system, then they should be
		// in the manifest
		JavaManifestAttributes attr = man.getMainAttributes();
		if (useactiveclass == null)
			useactiveclass = attr.getValue("ActiveClass");
		if (useprefix == null)
			useprefix = attr.getValue("Prefix");
		if (usecp == null)
			usecp = attr.getValue("ClassPath");
		if (usemain == null)
			usemain = attr.getValue("Main-Class");
		
		// Otherwise, if anything is missing use defaults
		if (useactiveclass == null)
			useactiveclass = VMFactory.class.getName();
		if (useprefix == null)
			useprefix = "/__-squirreljme/";
		if (bootid < 0)
			bootid = 0;
		
		// Load the resource based suite manager
		VMSuiteManager sm;
		try
		{
			sm = new ResourceBasedSuiteManager(Class.forName(useactiveclass),
				useprefix);
		}
		
		// {@squirreljme.error AK08 Could not locate the class to use for
		// resource lookup. (The class which was not found)}
		catch (ClassNotFoundException e)
		{
			throw new VMException("AK08 " + useactiveclass, e);
		}
		
		// Split the classpath accordingly using ' ', ';', and ':', allow
		// for multiple forms due to manifests and classpaths used in Windows
		// and UNIX
		List<String> classpath = new ArrayList<>();
		for (int i = 0, n = usecp.length(); i < n;)
		{
			// Find end clip position
			int sp;
			if ((sp = usecp.indexOf(' ', i)) < 0)
				if ((sp = usecp.indexOf(';', i)) < 0)
					if ((sp = usecp.indexOf(':', i)) < 0)
						sp = n;
			
			// Clip string
			String clip = usecp.substring(i, sp).trim();
			if (!clip.isEmpty())
				classpath.add(clip);
			
			// Skip the split character
			i = sp + 1;
		}
		
		// Since we are shaded, we might want to load some extra suites from
		// some directory
		List<VMSuiteManager> mergesm = new ArrayList<>();
		mergesm.add(sm);
		
		// Check our working directory
		String workdir = VMFactory.__getProperty(__sprops, "user.dir");
		if (workdir != null)
			try
			{
				mergesm.add(new PathSuiteManager(
					Paths.get(workdir).resolve("lib")));
			}
			catch (InvalidPathException e)
			{
			}
		
		// Check our executable path
		String execpath = SystemProperties.executablePath();
		if (execpath != null)
			try
			{
				mergesm.add(new PathSuiteManager(
					Paths.get(execpath).getParent().resolve("lib")));
			}
			catch (InvalidPathException|NullPointerException e)
			{
			}
		
		// Do the merge?
		if (mergesm.size() > 1)
			sm = new MergedSuiteManager(mergesm.<VMSuiteManager>toArray(
				new VMSuiteManager[mergesm.size()]));
		
		// Create the VM
		VirtualMachine vm = VMFactory.main(null, null,
			sm, classpath.<String>toArray(new String[classpath.size()]),
			usemain, bootid, -1, null, __args);
		
		// Run the VM and exit with the code it generates
		System.exit(vm.runVm());
	}
	
	/**
	 * Tries to get a property from a passed map otherwise reads from the
	 * system properties used.
	 *
	 * @param __props The properties to check first.
	 * @param __key The key to get.
	 * @return The value for the given key, {@code null} means it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	private static final String __getProperty(Map<String, String> __props,
		String __key)
		throws NullPointerException
	{
		return VMFactory.__getProperty(__props, __key, null);
	}
	
	/**
	 * Tries to get a property from a passed map otherwise reads from the
	 * system properties used.
	 *
	 * @param __props The properties to check first.
	 * @param __key The key to get.
	 * @param __def Default value.
	 * @return The value for the given key, {@code __def} means it is not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	private static final String __getProperty(Map<String, String> __props,
		String __key, String __def)
		throws NullPointerException
	{
		if (__props == null || __key == null)
			throw new NullPointerException("NARG");
		
		// Grab from these properties first
		String rv = __props.get(__key);
		if (rv != null)
			return rv;
		
		// Otherwise try a property instead
		try
		{
			rv = System.getProperty(__key);
			if (rv != null)
				return rv;
			return __def;
		}
		catch (SecurityException e)
		{
			return __def;
		}
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMNativeDisplayAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689

















































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.GraphicsFunction;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import cc.squirreljme.runtime.lcdui.gfx.SerializedGraphics;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;

/**
 * This class provides the framebuffer needed by SquirrelJME which is backed
 * on top of LCDUI itself. This just provides a single display.
 *
 * @since 2018/11/17
 */
@Deprecated
public class VMNativeDisplayAccess
{
	/** The pixel format to use for the framebuffer. */
	public static final PixelFormat FRAMEBUFFER_PIXELFORMAT =
		PixelFormat.INTEGER_RGB888;
	
	/** The display to back on, lazily initialized to prevent crashing. */
	Display _usedisplay;
	
	/** The framebuffer RGB data. */
	volatile int[] _fbrgb;
	
	/** The framebuffer width. */
	volatile int _fbw =
		-1;
	
	/** The framebuffer height. */
	volatile int _fbh =
		-1;
	
	/** The canvas for display. */
	volatile VMCanvas _canvas;
	
	/** Doing a repaint? */
	volatile boolean _repaint;
	
	/** Repaint parameters. */
	volatile int _repaintx,
		_repainty,
		_repaintw,
		_repainth;
	
	/** Accelerated graphics instance. */
	volatile Graphics _accelgfx;
	
	/** The state count of the framebuffer. */
	volatile int _statecount;
	
	/** Event callback. */
	volatile NativeDisplayEventCallback _callback;
	
	/**
	 * Initialize and/or reset accelerated graphics operations.
	 *
	 * @param __id The display to initialize for.
	 * @return {@code true} if acceleration is supported.
	 * @since 2018/11/19
	 */
	public final boolean accelGfx(int __id)
	{
		if (__id != 0)
			return false;
		
		// Check for framebuffer update
		this.__checkFramebuffer();
		
		// Setup instance
		int fbw = this._fbw;
		this._accelgfx = FRAMEBUFFER_PIXELFORMAT.createGraphics(
			this._fbrgb, null, fbw, this._fbh, false, fbw, 0, 0, 0);
		return true;
	}
	
	/**
	 * Performs accelerated graphics operation.
	 *
	 * @param __id The display ID.
	 * @param __func The function to call.
	 * @param __args Arguments to the operation.
	 * @return The result of the operation.
	 * @since 2018/11/19
	 */
	public final Object accelGfxFunc(int __id, int __func, Object... __args)
	{
		if (__id != 0)
			return null;
		
		// Deserialize and forward
		return SerializedGraphics.deserialize(this._accelgfx,
			GraphicsFunction.of(__func), __args);
	}

	/**
	 * Returns the capabilities of the display.
	 *
	 * @param __id The display ID.
	 * @return The capabilities of the display.
	 * @since 2018/11/17
	 */
	public final int capabilities(int __id)
	{
		// Only a single display is supported
		if (__id != 0)
			return 0;
		
		// Just directly pass the capabilities of this display
		return this.__display().getCapabilities();
	}
	
	/**
	 * Requests that the display should be repainted.
	 *
	 * @param __id The display ID.
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/12/03
	 */
	public final void displayRepaint(int __id,
		int __x, int __y, int __w, int __h)
	{
		if (__id != 0)
			return;
		
		this.__checkFramebuffer().repaint(__x, __y, __w, __h);
	}
	
	/**
	 * Returns the object representing the framebuffer data.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer array.
	 * @since 2018/11/18
	 */
	public final Object framebufferObject(int __id)
	{
		if (__id != 0)
			return null;
		
		// Check for framebuffer update
		this.__checkFramebuffer();
		
		// Return the raw RGB array
		return this._fbrgb;
	}
	
	/**
	 * Specifies that the framebuffer has been painted.
	 *
	 * @param __id The display ID.
	 * @since 2018/11/18
	 */
	public final void framebufferPainted(int __id)
	{
		if (__id != 0)
			return;
		
		this.__checkFramebuffer().repaint();
	}
	
	/**
	 * Returns the palette of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The palette of the framebuffer.
	 * @since 2018/11/18
	 */
	public final int[] framebufferPalette(int __id)
	{
		if (__id != 0)
			return null;
		
		// No palette is used
		return null;
	}
	
	/**
	 * Returns the parameters of the framebuffer.
	 *
	 * @param __id The display ID.
	 * @return The framebuffer parameters.
	 * @since 2018/11/18
	 */
	public final int[] framebufferParameters(int __id)
	{
		if (__id != 0)
			return null;
		
		// Check for framebuffer update
		this.__checkFramebuffer();
		
		// Fill in basic parameters
		int[] rv = new int[NativeDisplayAccess.NUM_PARAMETERS];
		
		// These are the only used fields
		int fbw = this._fbw,
			fbh = this._fbh;
		
		// Build parameters
		rv[NativeDisplayAccess.PARAMETER_PIXELFORMAT] =
			FRAMEBUFFER_PIXELFORMAT.ordinal();
		rv[NativeDisplayAccess.PARAMETER_BUFFERWIDTH] = fbw;
		rv[NativeDisplayAccess.PARAMETER_BUFFERHEIGHT] = fbh;
		rv[NativeDisplayAccess.PARAMETER_ALPHA] = 0;
		rv[NativeDisplayAccess.PARAMETER_PITCH] = fbw;
		rv[NativeDisplayAccess.PARAMETER_OFFSET] = 0;
		rv[NativeDisplayAccess.PARAMETER_VIRTXOFF] = 0;
		rv[NativeDisplayAccess.PARAMETER_VIRTYOFF] = 0;
		
		return rv;
	}
	
	/**
	 * Returns the state count of this framebuffer which is used to detect
	 * when the parameters have changed, where they must all be recalculated
	 * (that is the framebuffer wrapper must be recreated).
	 *
	 * @param __id The display ID.
	 * @return The state count for the framebuffer.
	 * @since 2018/12/02
	 */
	public final int framebufferStateCount(int __id)
	{
		if (__id != 0)
			return -1;
		
		// Check for framebuffer update
		this.__checkFramebuffer();
		
		return this._statecount;
	}
	
	/**
	 * Is the specified display upsidedown?
	 *
	 * @param __id The ID of the display.
	 * @return If the display is upsidedown.
	 * @since 2018/11/17
	 */
	public final boolean isUpsideDown(int __id)
	{
		if (__id != 0)
			return false;
		
		// Only certain orientations are considered upside-down
		switch (this.__display().getOrientation())
		{
			case Display.ORIENTATION_LANDSCAPE_180:
			case Display.ORIENTATION_PORTRAIT_180:
				return true;
			
				// Not upsidedown
			default:
				return false;
		}
	}
	
	/**
	 * Returns the number of displays which are available.
	 *
	 * @return The number of available displays.
	 * @since 2018/11/17
	 */
	public final int numDisplays()
	{
		return 1;
	}
	
	/**
	 * Registers the event callback.
	 *
	 * @param __e The event to call.
	 * @since 2018/12/03
	 */
	public final void registerEventCallback(NativeDisplayEventCallback __e)
	{
		// Do not change to self!
		NativeDisplayEventCallback old = this._callback;
		if (old == __e)
			return;	
		
		// Tell the old handler that the callback is now gone
		if (old != null)
			try
			{
				old.lostCallback();
			}
			catch (Throwable e)
			{
				e.printStackTrace();
			}
		
		// Set new
		this._callback = __e;
	}
	
	/**
	 * Sets the title of the display.
	 *
	 * @param __id The display ID.
	 * @param __t The title to use.
	 * @since 2018/11/18
	 */
	public final void setDisplayTitle(int __id, String __t)
	{
		if (__id != 0)
			return;
		
		this.__checkFramebuffer().setTitle(__t);
	}
	
	/**
	 * Checks if the framebuffer needs updating.
	 *
	 * @return The canvas used.
	 * @since 2018/11/18
	 */
	private final VMCanvas __checkFramebuffer()
	{
		// Need to create the canvas?
		VMCanvas canvas = this._canvas;
		if (canvas == null)
		{
			// Setup canvas to use
			this._canvas = (canvas = new VMCanvas());
			
			// Listener for function commands
			canvas.setCommandListener(new __CommandListener__());
			
			// Add function key wrappers to forward commands which have
			// occurred
			for (int i = 1; i <= 24; i++)
				canvas.addCommand(new Command("F" + i, Command.SCREEN,
					i - 1));
			
			// Add exit command
			canvas.addCommand(new Command("Exit", Command.EXIT,
				Integer.MAX_VALUE));
			
			// Make this canvas full screen so that the commands go away
			canvas.setFullScreenMode(true);
			
			// Assume that the client will draw over every pixel, note that
			// if the client has this done with a false, then the client will
			// clear the framebuffer while drawing over it.
			canvas.setPaintMode(true);
			
			// Display the canvas now that all the properties are known
			this.__display().setCurrent(canvas);
		}
		
		// Properties have changed? Recreate the buffer data
		int cw = canvas.getWidth(),
			ch = canvas.getHeight();
		if (this._fbrgb == null || cw != this._fbw || ch != this._fbh)
		{
			int n = cw * ch;
			int[] fbrgb;
			this._fbrgb = (fbrgb = new int[n]);
			this._fbw = cw;
			this._fbh = ch;
			
			// Initialize the framebuffer to white
			for (int i = 0; i < n; i++)
				fbrgb[i] = 0xFFFFFF;
			
			// Increase the state count
			this._statecount++;
		}
		
		return canvas;
	}
	
	/**
	 * Returns the display this is currently using.
	 *
	 * @return The currently backed display.
	 * @since 2018/11/17
	 */
	private final Display __display()
	{
		Display rv = this._usedisplay;
		if (rv == null)
			this._usedisplay = (rv = Display.getDisplays(0)[0]);
		return rv;
	}
	
	/**
	 * Listens for commands.
	 *
	 * @since 2018/11/18
	 */
	final class __CommandListener__
		implements CommandListener
	{
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void commandAction(Command __c, Displayable __d)
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			// Exiting the VM?
			if (__c.getCommandType() == Command.EXIT)
				cb.exitRequest(0);
			
			// Function menu key
			else if (__c.getLabel().startsWith("F"))
				cb.command(0, __c.getPriority());
		}
	}
	
	/**
	 * Contains the canvas which is drawn on.
	 *
	 * @since 2018/11/18
	 */
	@Deprecated
	public final class VMCanvas
		extends Canvas
	{
		/** Key time index tracking. */
		private volatile int _keyindex;
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void hideNotify()
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			cb.shown(0, 0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyPressed(int __code)
		{
			this.__postKey(NativeDisplayEventCallback.KEY_PRESSED, __code);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyReleased(int __code)
		{
			this.__postKey(NativeDisplayEventCallback.KEY_RELEASED, __code);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyRepeated(int __code)
		{
			this.__postKey(NativeDisplayEventCallback.KEY_REPEATED, __code);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void paint(Graphics __g)
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			int x = __g.getClipX(),
				y = __g.getClipY(),
				w = __g.getClipWidth(),
				h = __g.getClipHeight();
			
			// Call paint code
			cb.paintDisplay(0, x, y, w, h);
			
			// Just draw the raw RGB data
			int fbw = VMNativeDisplayAccess.this._fbw;
			__g.drawRGB(VMNativeDisplayAccess.this._fbrgb,
				0,
				fbw,
				0,
				0,
				fbw,
				VMNativeDisplayAccess.this._fbh,
				false);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void pointerDragged(int __x, int __y)
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			cb.pointerEvent(0,
				NativeDisplayEventCallback.POINTER_DRAGGED, __x, __y,
				++this._keyindex);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void pointerPressed(int __x, int __y)
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			cb.pointerEvent(0,
				NativeDisplayEventCallback.POINTER_PRESSED, __x, __y,
				++this._keyindex);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/02
		 */
		@Override
		public void pointerReleased(int __x, int __y)
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			cb.pointerEvent(0,
				NativeDisplayEventCallback.POINTER_RELEASED, __x, __y,
				++this._keyindex);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void showNotify()
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			cb.shown(0, 1);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/18
		 */
		@Override
		public void sizeChanged(int __w, int __h)
		{
			// The framebuffer will need to be redone
			VMNativeDisplayAccess.this.__checkFramebuffer();
			
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			// Post
			cb.sizeChanged(0, __w, __h);
		}
		
		/**
		 * Post key event.
		 *
		 * @param __et The event type to post.
		 * @param __kc The keycode used.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/12/01
		 */
		final void __postKey(int __et, int __kc)
			throws NullPointerException
		{
			NativeDisplayEventCallback cb =
				VMNativeDisplayAccess.this._callback;
			if (cb == null)
				return;
			
			// Try to map to a game key if possible
			/*
			try
			{
				switch (this.getGameAction(__kc))
				{
					case Canvas.UP:
						__kc = NonStandardKey.VGAME_UP;
						break;
						
					case Canvas.DOWN:
						__kc = NonStandardKey.VGAME_DOWN;
						break;
						
					case Canvas.LEFT:
						__kc = NonStandardKey.VGAME_LEFT;
						break;
						
					case Canvas.RIGHT:
						__kc = NonStandardKey.VGAME_RIGHT;
						break;
					
					case Canvas.FIRE:
						__kc = NonStandardKey.VGAME_FIRE;
						break;
					
					case Canvas.GAME_A:
						__kc = NonStandardKey.VGAME_A;
						break;
					
					case Canvas.GAME_B:
						__kc = NonStandardKey.VGAME_B;
						break;
					
					case Canvas.GAME_C:
						__kc = NonStandardKey.VGAME_C;
						break;
					
					case Canvas.GAME_D:
						__kc = NonStandardKey.VGAME_D;
						break;
					
						// Unknown, do not remap!
					default:
						break;
				}
			}
			
			// Ignore unknown game keys
			catch (IllegalArgumentException e)
			{
			}*/
			
			// Post event
			cb.keyEvent(0, __et, __kc, 0, ++this._keyindex);
		}
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMResourceAccess.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

import java.io.InputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * This class manages access to resources within the virtual machine.
 *
 * @since 2018/10/07
 */
public final class VMResourceAccess
{
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** Opened resources. */
	private final Map<Integer, InputStream> _streams =
		new HashMap<>();
	
	/** The next resource ID to use. */
	private volatile int _next;
	
	/**
	 * Initializes the resource access.
	 *
	 * @param __sm The suite manager.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public VMResourceAccess(VMSuiteManager __sm)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
	}
	
	/**
	 * Checks how many bytes are quickly available for read within a resource.
	 *
	 * @param __fd The file descriptor.
	 * @return The number of bytes available quickly or negative on failure.
	 * @since 2018/12/05
	 */
	public int available(int __fd)
	{
		// Locate the stream to read from
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Do the check
		try
		{
			return in.available();
		}
		
		// Failed so just pass that some exception happened
		catch (IOException e)
		{
			return -3;
		}
	}
	
	/**
	 * Closes the open resource.
	 *
	 * @param __fd The file descriptor.
	 * @return Zero on success or a negative value on failure.
	 * @since 2018/10/13
	 */
	public int close(int __fd)
	{
		// Locate the stream to close
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
			
			// Remove it
			if (in != null)
				streams.remove(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Close it
		try
		{
			in.close();
			return 0;
		}
		catch (IOException e)
		{
			return -3;
		}
	}
	
	/**
	 * Opens the given resource in the given JAR.
	 *
	 * @param __jar The source JAR.
	 * @param __rc The resource to load.
	 * @return The resource file descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public int open(String __jar, String __rc)
		throws NullPointerException
	{
		if (__jar == null || __rc == null)
			throw new NullPointerException("NARG");
		
		// Load the library to access its resources
		VMClassLibrary lib = this.suites.loadLibrary(__jar);
		if (lib == null)
			return -2;
		
		// Open input stream, if it even exists
		InputStream rv;
		try
		{
			rv = lib.resourceAsStream(__rc);
			
			// Debug
			todo.DEBUG.note("rAS(%s, %s) = %b", __jar, __rc, rv != null);
			
			if (rv == null)
				return -1;
		}
		catch (IOException e)
		{
			return -3;
		}
		
		// It does exist so it needs to be registered
		int id;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			streams.put((id = ++this._next), rv);
		}
		
		// Only the ID is used
		return id;
	}
	
	/**
	 * Reads from the 
	 *
	 * @param __fd The file descriptor to read from.
	 * @param __b The output bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return The number of bytes read or a negative status code.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	public int read(int __fd, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Locate the stream to read from
		InputStream in;
		Map<Integer, InputStream> streams = this._streams;
		synchronized (streams)
		{
			in = streams.get(__fd);
		}
		
		// No stream was found, so fail
		if (in == null)
			return -2;
		
		// Do the read
		try
		{
			int rv = in.read(__b, __o, __l);
			
			// Normalize the return value because negative values mean special
			// values, while we just want EOF
			if (rv < 0)
				return -1;
			return rv;
		}
		
		// Failed so just pass that some exception happened
		catch (IOException e)
		{
			return -3;
		}
	}
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VMSuiteManager.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

/**
 * This is the suite manager which represents the.
 *
 * @since 2018/10/26
 */
public interface VMSuiteManager
{
	/**
	 * Lists the names of libraries which are available for usage.
	 *
	 * @return The list of available libraries.
	 * @since 2018/10/26
	 */
	public abstract String[] listLibraryNames();
	
	/**
	 * Loads the specified library by the given string.
	 *
	 * It is recommended that this caches the library internally so that it may
	 * be reused accordingly as such.
	 *
	 * @param __s The name of the library to load.
	 * @return The loaded library, or {@code null} if it does not exist.
	 * @since 2018/10/16
	 */
	public abstract VMClassLibrary loadLibrary(String __s)
		throws NullPointerException;
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/VirtualMachine.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm;

/**
 * This interface represents the virtual machine which may be executed
 * accordingly.
 *
 * @since 2018/11/17
 */
public interface VirtualMachine
{
	/**
	 * Runs the virtual machine.
	 *
	 * @return The exit code of the virtual machine.
	 * @throws VMException If the VM threw an exception.
	 * @since 2018/11/17
	 */
	public abstract int runVm()
		throws VMException;
}

Deleted runt/libs/common-vm/cc/squirreljme/vm/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes and utilities which are common to all
 * the virtual machine implementations.
 *
 * @since 2018/11/17
 */

package cc.squirreljme.vm;

Deleted runt/libs/common-vm/squirreljme-vm.png.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 squirreljme-vm.png
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/
AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4gwXESMJRfeU
jAAAAcBJREFUOMutkzFoU1EYhb+mFUM7hSIUUXApETuISAeRi2OvUG4Hh+fg
oOLwsgQJLhEeBiLPrUihvAySgK3QOoaC7VwwdHAQQlW6dGqQQoJiVWz1d3i9
lzxfxMW33HPP/5/Duf+9D/7XF5U9GcT9jbc4Y4mZi7OJQlT2RBmNMjrF9/eO
2ML3rwf41QjANU+cPcP4xOVYeMz71Yh3z1+SSACQHR2jFhTwiiUAlNFOPDU9
h1+NUEZTCwpkR8ecgUuw8XYNr1gid2rSFX98+0g9rKCMZrO5bhOy0VxLJ/CK
JfZ2t+nt77hiPaxw92HF7Xv7OwmjhMHe7janz11gdWE+MfGDL58dXl2Yx69G
1IJC+ghWfOtBQDY7wrPHj1zTZnMdZTRT03PUgkLCJNPvfidc4tWl6/x608MP
Vxw//uI1k4fnYTiXSuAMlNGc5EQ8vGtXYbnOvXARZXTcMKNhuQ7DOXdTqdfV
bjVEDjsiPz9JHhE56oocdWN8zOURicqewwNNbEO71ZB2q5EQ2RUgj0jmzyR2
YBbfuHKb++WbidgfGBpKzaDb2ZJ+IcDTJyu8l3g+9nqV0XQ7W/LPvzN1vgFc
HpHfHmPowBfRG4IAAAAASUVORK5CYII=
====

Deleted runt/libs/io.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/libs/io.test/TestBase64Decoder.in.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
argument-1: string:SSBsb3ZlIHNxdWlycmVscyE=
argument-2: string:SSBsb3ZlIExlYWggYW5kIEppbmV0dGUsIEkgcmVhbGx5IGRvIQ==
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:I\_love\_squirrels!
secondary-b: string:I\_love\_Leah\_and\_Jinette,\_I\_really\_do!

Deleted runt/libs/io.test/TestBase64Decoder.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestBiConsumer;
import net.multiphasicapps.io.Base64Alphabet;
import net.multiphasicapps.io.Base64Decoder;

/**
 * This tests the base 64 decoder.
 *
 * @since 2018/03/06
 */
public class TestBase64Decoder
	extends TestBiConsumer<String, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06	
	 */
	@Override
	public void test(String __a, String __b)
		throws Throwable
	{
		this.secondary("a", new String(Base64Decoder.decode(__a,
			Base64Alphabet.BASIC), "utf-8"));
		this.secondary("b", new String(Base64Decoder.decode(__b,
			Base64Alphabet.BASIC), "utf-8"));
	}
}

Deleted runt/libs/io.test/TestDeflaterInflater.in.

1
2
3



-
-
-
result: int:6
thrown: NoExceptionThrown

Deleted runt/libs/io.test/TestDeflaterInflater.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestSupplier;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.InflaterInputStream;
import net.multiphasicapps.io.DeflaterOutputStream;

/**
 * Tests the deflater and then the inflater, making sure that compressed
 * data ends up the same when decompressed.
 *
 * @since 2018/11/10
 */
public class TestDeflaterInflater
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		// Read in the message first
		byte[] message;
		try (InputStream in = TestDeflaterInflater.class.getResourceAsStream(
			"message");
			ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Copy in data
			byte[] buf = new byte[128];
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Finalize
			message = baos.toByteArray();
		}
		
		// Original message as a string for comparison
		String original = new String(message, "iso-8859-1");
		
		// Compression is hopefully smaller so use a buffer size matching this
		int gn = message.length;
		
		// For each compression level since they vary
		int rv = 0;
		for (CompressionLevel cl : CompressionLevel.values())
		{
			// Compress the data with my compression code first
			byte[] compressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Compress the input message
				try (DeflaterOutputStream dos = new DeflaterOutputStream(baos))
				{
					dos.write(message);
				}
				
				// Need to keep this message
				compressed = baos.toByteArray();
			}
			
			// Then it will be decompressed accordingly
			byte[] decompressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Decompress the message
				try (InflaterInputStream iis = new InflaterInputStream(
					new ByteArrayInputStream(compressed)))
				{
					byte[] buf = new byte[128];
					for (;;)
					{
						int rc = iis.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Store decompressed message
				decompressed = baos.toByteArray();
			}
			
			// Return string as processed through the algorithm
			String result = new String(decompressed, "iso-8859-1");
			
			// If the strings are the same then it is okay!
			if (original.equals(result))
				rv++;
			
			// Otherwise flag it and note it
			else
				this.secondary("failed-" + cl, result);
		}
		
		return rv;
	}
}

Deleted runt/libs/io.test/TestMIMEFileDecoder.in.

1
2
3



-
-
-
result: true
thrown: NoExceptionThrown

Deleted runt/libs/io.test/TestMIMEFileDecoder.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import net.multiphasicapps.tac.TestSupplier;
import net.multiphasicapps.io.MIMEFileDecoder;

/**
 * Tests decoding of MIME files.
 *
 * @since 2018/11/25
 */
public class TestMIMEFileDecoder
	extends TestSupplier<Boolean>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public Boolean test()
		throws Throwable
	{
		byte[] buf = new byte[512];
		
		// Read the expected message
		byte[] expected;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream in = this.getClass().getResourceAsStream("message"))
		{
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Read it
			expected = baos.toByteArray();
		}
		
		// Decode
		byte[] decoded;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream in = new MIMEFileDecoder(new InputStreamReader(
			this.getClass().getResourceAsStream("mimemessage"), "utf-8")))
		{
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Read it
			decoded = baos.toByteArray();
		}
		
		// They must be the same
		return Arrays.equals(expected, decoded);
	}
}

Deleted runt/libs/io.test/TestZlibCompressorDecompressor.in.

1
2
3



-
-
-
result: int:6
thrown: NoExceptionThrown

Deleted runt/libs/io.test/TestZlibCompressorDecompressor.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
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


























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestSupplier;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.ZLibCompressor;
import net.multiphasicapps.io.ZLibDecompressor;

/**
 * Tests the deflater and then the inflater, making sure that compressed
 * data ends up the same when decompressed.
 *
 * @since 2018/11/11
 */
public class TestZlibCompressorDecompressor
	extends TestSupplier<Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public Integer test()
		throws Throwable
	{
		// Read in the message first
		byte[] message;
		try (InputStream in = TestDeflaterInflater.class.getResourceAsStream(
			"message");
			ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Copy in data
			byte[] buf = new byte[128];
			for (;;)
			{
				int rc = in.read(buf);
				
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
			}
			
			// Finalize
			message = baos.toByteArray();
		}
		
		// Original message as a string for comparison
		String original = new String(message, "iso-8859-1");
		
		// Compression is hopefully smaller so use a buffer size matching this
		int gn = message.length;
		
		// For each compression level since they vary
		int rv = 0;
		for (CompressionLevel cl : CompressionLevel.values())
		{
			// Compress the data with my compression code first
			byte[] compressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Compress the input message
				try (ZLibCompressor dos = new ZLibCompressor(baos))
				{
					dos.write(message);
				}
				
				// Need to keep this message
				compressed = baos.toByteArray();
			}
			
			// Then it will be decompressed accordingly
			byte[] decompressed;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(gn))
			{
				// Decompress the message
				try (ZLibDecompressor iis = new ZLibDecompressor(
					new ByteArrayInputStream(compressed)))
				{
					byte[] buf = new byte[128];
					for (;;)
					{
						int rc = iis.read(buf);
						
						if (rc < 0)
							break;
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Store decompressed message
				decompressed = baos.toByteArray();
			}
			
			// Return string as processed through the algorithm
			String result = new String(decompressed, "iso-8859-1");
			
			// If the strings are the same then it is okay!
			if (original.equals(result))
				rv++;
			
			// Otherwise flag it and note it
			else
				this.secondary("failed-" + cl, result);
		}
		
		return rv;
	}
}

Deleted runt/libs/io.test/message.

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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From the Encyclopedia Britannica 11th Edition, Volume 25
This is under the public domain.

SQUIRREL, properly the name of the well known red, bushy-tailed British
arboreal mammal, Sciurus vulgaris, typifying the genus Sciurus and the family
Sciuridae, but in a wider sense embracing all the rodents included in this and
a few nearly allied genera. For the characteristics of the family Sciuridae and
the different squirrel-like genera by which it is represented, see RODENTIA.

What may be called typical, that is so arboreal, squirrels are found throughout
the greater part of the tropical and temperate regions of both hemispheres,
although they are absent both from Madagascar and Australasia. The species are
both largest and most numerous in the tropics, and reach their greatest
development in the Malay countries. Squirrels vary in size from animals no
larger than a mouse, such as the Nannosciurus soricirius of Borneo, or N.
ininulus of West Africa, to others as large as a cat, such as the black and
yellow Ratufa bi-color of Burma and the Malay area. The larger species, as
might be expected from their heavier build, are somewhat less strictly arboreal
in their habits than the smaller ones. The common squirrel, whose habits are
too well known to need special description, ranges over the whole of Europe and
Norther Asia, from Ireland to Japan, and from Lapland to North Italy; but
specimens from different parts of this wide range differ so much in color as to
constitute distinct races. Thus, while the squirrels of north and west Europe
are of the bright red color of the British animal, those of the mountainous
regions of southern Europe are of a deep blackish gray; while those from
Siberia are a clear pale grey colour, with scarcely a tinge of rufous. There is
also a great seasonal change in appearance and color in this squirrel, owing to
the ears losing their tufts of hair and the bleaching of the tail. The pairing
time of the squirrel is from February to April; and after a period of gestation
of about thirty days the female brings forth from three to nine young. In
addition to all sorts of vegetables and fruits, the squirrel is exceedingly
fond of animal food, greedily devouring mice, small birds and eggs. The
squirrels of the typical genus Sciurus are unknown in Africa south of the
Sahara, but otherwise have a distribution co-extensive with the rest of the
family.

Although the English squirrel is a beautiful little animal, it is surpassed by
the many of the tropical members of the group, and especially by those of the
Malay countries, where nearly all the species are brilliantly marked, and many
are ornamented with variously colored longitudinal stripes along their bodies.
Every one who has visited India is familiar with the pretty little striped
palm-squirrel, which is to a considerable extent a partially domesticated
animal, or, rather, and animal which has taken to quarter itself in the
immediate neighborhood of human habitations. It has been generally supposed
that there is only one palm-squirrel throughout India, but there are really
two distinct types, each with local modifications. The first or typical
palm-squirrel, Funambulus palmaraum, inhabits Madras, has but three light
stripes on the back, and shows a rufous hand on the under-side of the base of
the tail. In Pennant's palm-squirrel, F. pennanti, on the other hand, there is
a pair of faint additional lateral white stripes, making five in all, and the
under-surface of the tail is uniformly whitish olive. As this species has been
obtained in Surat and the Punjab, it is believed to be the northern type. One
Oriental species (Sciurus caniceps) presents almost the only known instance
among mammals of the assumption during the breeding season of a distinctly
ornamental coat, corresponding to the breeding plumage of birds. For the
greater part of the tear the animal is of a uniform gray color, but about
December its back becomes a brilliant orange-yellow, which lasts until about
March, when it is again replaced by gray. The squirrel shown in the
illustration is a native of Burma and Tenasserim, and is closely allied to S.
caniceps, but goes through no seasonal change of color. Another Burmese
squirrel, S. haringtoni, differs as regards in a remarkabale manner from all
other known members of the group. It is a medium-sized species of a pale creamy
buff color above, lighter beneath, and with a whitish tail, while it is further
characterized by the absence of the first upper premolar, which shows that it
is not an albino or pale variety. Two examples were obtains by Captain H. H.
Harington, of one of the Punjabu regiments, on the Upper Chindwin river. It may
also be added that generic subdivisions of the squirrels are based mainly on
the characters of the skull and teeth. That they are essential is evident from
the circumstances that the African spiny squirrels Xerus (see SPINY SQUIRREL)
come between Sciurus and some of the other African genera.

Deleted runt/libs/io.test/mimemessage.

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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 message
RnJvbSB0aGUgRW5jeWNsb3BlZGlhIEJyaXRhbm5pY2EgMTF0aCBFZGl0aW9u
LCBWb2x1bWUgMjUKVGhpcyBpcyB1bmRlciB0aGUgcHVibGljIGRvbWFpbi4K
ClNRVUlSUkVMLCBwcm9wZXJseSB0aGUgbmFtZSBvZiB0aGUgd2VsbCBrbm93
biByZWQsIGJ1c2h5LXRhaWxlZCBCcml0aXNoCmFyYm9yZWFsIG1hbW1hbCwg
U2NpdXJ1cyB2dWxnYXJpcywgdHlwaWZ5aW5nIHRoZSBnZW51cyBTY2l1cnVz
IGFuZCB0aGUgZmFtaWx5ClNjaXVyaWRhZSwgYnV0IGluIGEgd2lkZXIgc2Vu
c2UgZW1icmFjaW5nIGFsbCB0aGUgcm9kZW50cyBpbmNsdWRlZCBpbiB0aGlz
IGFuZAphIGZldyBuZWFybHkgYWxsaWVkIGdlbmVyYS4gRm9yIHRoZSBjaGFy
YWN0ZXJpc3RpY3Mgb2YgdGhlIGZhbWlseSBTY2l1cmlkYWUgYW5kCnRoZSBk
aWZmZXJlbnQgc3F1aXJyZWwtbGlrZSBnZW5lcmEgYnkgd2hpY2ggaXQgaXMg
cmVwcmVzZW50ZWQsIHNlZSBST0RFTlRJQS4KCldoYXQgbWF5IGJlIGNhbGxl
ZCB0eXBpY2FsLCB0aGF0IGlzIHNvIGFyYm9yZWFsLCBzcXVpcnJlbHMgYXJl
IGZvdW5kIHRocm91Z2hvdXQKdGhlIGdyZWF0ZXIgcGFydCBvZiB0aGUgdHJv
cGljYWwgYW5kIHRlbXBlcmF0ZSByZWdpb25zIG9mIGJvdGggaGVtaXNwaGVy
ZXMsCmFsdGhvdWdoIHRoZXkgYXJlIGFic2VudCBib3RoIGZyb20gTWFkYWdh
c2NhciBhbmQgQXVzdHJhbGFzaWEuIFRoZSBzcGVjaWVzIGFyZQpib3RoIGxh
cmdlc3QgYW5kIG1vc3QgbnVtZXJvdXMgaW4gdGhlIHRyb3BpY3MsIGFuZCBy
ZWFjaCB0aGVpciBncmVhdGVzdApkZXZlbG9wbWVudCBpbiB0aGUgTWFsYXkg
Y291bnRyaWVzLiBTcXVpcnJlbHMgdmFyeSBpbiBzaXplIGZyb20gYW5pbWFs
cyBubwpsYXJnZXIgdGhhbiBhIG1vdXNlLCBzdWNoIGFzIHRoZSBOYW5ub3Nj
aXVydXMgc29yaWNpcml1cyBvZiBCb3JuZW8sIG9yIE4uCmluaW51bHVzIG9m
IFdlc3QgQWZyaWNhLCB0byBvdGhlcnMgYXMgbGFyZ2UgYXMgYSBjYXQsIHN1
Y2ggYXMgdGhlIGJsYWNrIGFuZAp5ZWxsb3cgUmF0dWZhIGJpLWNvbG9yIG9m
IEJ1cm1hIGFuZCB0aGUgTWFsYXkgYXJlYS4gVGhlIGxhcmdlciBzcGVjaWVz
LCBhcwptaWdodCBiZSBleHBlY3RlZCBmcm9tIHRoZWlyIGhlYXZpZXIgYnVp
bGQsIGFyZSBzb21ld2hhdCBsZXNzIHN0cmljdGx5IGFyYm9yZWFsCmluIHRo
ZWlyIGhhYml0cyB0aGFuIHRoZSBzbWFsbGVyIG9uZXMuIFRoZSBjb21tb24g
c3F1aXJyZWwsIHdob3NlIGhhYml0cyBhcmUKdG9vIHdlbGwga25vd24gdG8g
bmVlZCBzcGVjaWFsIGRlc2NyaXB0aW9uLCByYW5nZXMgb3ZlciB0aGUgd2hv
bGUgb2YgRXVyb3BlIGFuZApOb3J0aGVyIEFzaWEsIGZyb20gSXJlbGFuZCB0
byBKYXBhbiwgYW5kIGZyb20gTGFwbGFuZCB0byBOb3J0aCBJdGFseTsgYnV0
CnNwZWNpbWVucyBmcm9tIGRpZmZlcmVudCBwYXJ0cyBvZiB0aGlzIHdpZGUg
cmFuZ2UgZGlmZmVyIHNvIG11Y2ggaW4gY29sb3IgYXMgdG8KY29uc3RpdHV0
ZSBkaXN0aW5jdCByYWNlcy4gVGh1cywgd2hpbGUgdGhlIHNxdWlycmVscyBv
ZiBub3J0aCBhbmQgd2VzdCBFdXJvcGUKYXJlIG9mIHRoZSBicmlnaHQgcmVk
IGNvbG9yIG9mIHRoZSBCcml0aXNoIGFuaW1hbCwgdGhvc2Ugb2YgdGhlIG1v
dW50YWlub3VzCnJlZ2lvbnMgb2Ygc291dGhlcm4gRXVyb3BlIGFyZSBvZiBh
IGRlZXAgYmxhY2tpc2ggZ3JheTsgd2hpbGUgdGhvc2UgZnJvbQpTaWJlcmlh
IGFyZSBhIGNsZWFyIHBhbGUgZ3JleSBjb2xvdXIsIHdpdGggc2NhcmNlbHkg
YSB0aW5nZSBvZiBydWZvdXMuIFRoZXJlIGlzCmFsc28gYSBncmVhdCBzZWFz
b25hbCBjaGFuZ2UgaW4gYXBwZWFyYW5jZSBhbmQgY29sb3IgaW4gdGhpcyBz
cXVpcnJlbCwgb3dpbmcgdG8KdGhlIGVhcnMgbG9zaW5nIHRoZWlyIHR1ZnRz
IG9mIGhhaXIgYW5kIHRoZSBibGVhY2hpbmcgb2YgdGhlIHRhaWwuIFRoZSBw
YWlyaW5nCnRpbWUgb2YgdGhlIHNxdWlycmVsIGlzIGZyb20gRmVicnVhcnkg
dG8gQXByaWw7IGFuZCBhZnRlciBhIHBlcmlvZCBvZiBnZXN0YXRpb24Kb2Yg
YWJvdXQgdGhpcnR5IGRheXMgdGhlIGZlbWFsZSBicmluZ3MgZm9ydGggZnJv
bSB0aHJlZSB0byBuaW5lIHlvdW5nLiBJbgphZGRpdGlvbiB0byBhbGwgc29y
dHMgb2YgdmVnZXRhYmxlcyBhbmQgZnJ1aXRzLCB0aGUgc3F1aXJyZWwgaXMg
ZXhjZWVkaW5nbHkKZm9uZCBvZiBhbmltYWwgZm9vZCwgZ3JlZWRpbHkgZGV2
b3VyaW5nIG1pY2UsIHNtYWxsIGJpcmRzIGFuZCBlZ2dzLiBUaGUKc3F1aXJy
ZWxzIG9mIHRoZSB0eXBpY2FsIGdlbnVzIFNjaXVydXMgYXJlIHVua25vd24g
aW4gQWZyaWNhIHNvdXRoIG9mIHRoZQpTYWhhcmEsIGJ1dCBvdGhlcndpc2Ug
aGF2ZSBhIGRpc3RyaWJ1dGlvbiBjby1leHRlbnNpdmUgd2l0aCB0aGUgcmVz
dCBvZiB0aGUKZmFtaWx5LgoKQWx0aG91Z2ggdGhlIEVuZ2xpc2ggc3F1aXJy
ZWwgaXMgYSBiZWF1dGlmdWwgbGl0dGxlIGFuaW1hbCwgaXQgaXMgc3VycGFz
c2VkIGJ5CnRoZSBtYW55IG9mIHRoZSB0cm9waWNhbCBtZW1iZXJzIG9mIHRo
ZSBncm91cCwgYW5kIGVzcGVjaWFsbHkgYnkgdGhvc2Ugb2YgdGhlCk1hbGF5
IGNvdW50cmllcywgd2hlcmUgbmVhcmx5IGFsbCB0aGUgc3BlY2llcyBhcmUg
YnJpbGxpYW50bHkgbWFya2VkLCBhbmQgbWFueQphcmUgb3JuYW1lbnRlZCB3
aXRoIHZhcmlvdXNseSBjb2xvcmVkIGxvbmdpdHVkaW5hbCBzdHJpcGVzIGFs
b25nIHRoZWlyIGJvZGllcy4KRXZlcnkgb25lIHdobyBoYXMgdmlzaXRlZCBJ
bmRpYSBpcyBmYW1pbGlhciB3aXRoIHRoZSBwcmV0dHkgbGl0dGxlIHN0cmlw
ZWQKcGFsbS1zcXVpcnJlbCwgd2hpY2ggaXMgdG8gYSBjb25zaWRlcmFibGUg
ZXh0ZW50IGEgcGFydGlhbGx5IGRvbWVzdGljYXRlZAphbmltYWwsIG9yLCBy
YXRoZXIsIGFuZCBhbmltYWwgd2hpY2ggaGFzIHRha2VuIHRvIHF1YXJ0ZXIg
aXRzZWxmIGluIHRoZQppbW1lZGlhdGUgbmVpZ2hib3Job29kIG9mIGh1bWFu
IGhhYml0YXRpb25zLiBJdCBoYXMgYmVlbiBnZW5lcmFsbHkgc3VwcG9zZWQK
dGhhdCB0aGVyZSBpcyBvbmx5IG9uZSBwYWxtLXNxdWlycmVsIHRocm91Z2hv
dXQgSW5kaWEsIGJ1dCB0aGVyZSBhcmUgcmVhbGx5CnR3byBkaXN0aW5jdCB0
eXBlcywgZWFjaCB3aXRoIGxvY2FsIG1vZGlmaWNhdGlvbnMuIFRoZSBmaXJz
dCBvciB0eXBpY2FsCnBhbG0tc3F1aXJyZWwsIEZ1bmFtYnVsdXMgcGFsbWFy
YXVtLCBpbmhhYml0cyBNYWRyYXMsIGhhcyBidXQgdGhyZWUgbGlnaHQKc3Ry
aXBlcyBvbiB0aGUgYmFjaywgYW5kIHNob3dzIGEgcnVmb3VzIGhhbmQgb24g
dGhlIHVuZGVyLXNpZGUgb2YgdGhlIGJhc2Ugb2YKdGhlIHRhaWwuIEluIFBl
bm5hbnQncyBwYWxtLXNxdWlycmVsLCBGLiBwZW5uYW50aSwgb24gdGhlIG90
aGVyIGhhbmQsIHRoZXJlIGlzCmEgcGFpciBvZiBmYWludCBhZGRpdGlvbmFs
IGxhdGVyYWwgd2hpdGUgc3RyaXBlcywgbWFraW5nIGZpdmUgaW4gYWxsLCBh
bmQgdGhlCnVuZGVyLXN1cmZhY2Ugb2YgdGhlIHRhaWwgaXMgdW5pZm9ybWx5
IHdoaXRpc2ggb2xpdmUuIEFzIHRoaXMgc3BlY2llcyBoYXMgYmVlbgpvYnRh
aW5lZCBpbiBTdXJhdCBhbmQgdGhlIFB1bmphYiwgaXQgaXMgYmVsaWV2ZWQg
dG8gYmUgdGhlIG5vcnRoZXJuIHR5cGUuIE9uZQpPcmllbnRhbCBzcGVjaWVz
IChTY2l1cnVzIGNhbmljZXBzKSBwcmVzZW50cyBhbG1vc3QgdGhlIG9ubHkg
a25vd24gaW5zdGFuY2UKYW1vbmcgbWFtbWFscyBvZiB0aGUgYXNzdW1wdGlv
biBkdXJpbmcgdGhlIGJyZWVkaW5nIHNlYXNvbiBvZiBhIGRpc3RpbmN0bHkK
b3JuYW1lbnRhbCBjb2F0LCBjb3JyZXNwb25kaW5nIHRvIHRoZSBicmVlZGlu
ZyBwbHVtYWdlIG9mIGJpcmRzLiBGb3IgdGhlCmdyZWF0ZXIgcGFydCBvZiB0
aGUgdGVhciB0aGUgYW5pbWFsIGlzIG9mIGEgdW5pZm9ybSBncmF5IGNvbG9y
LCBidXQgYWJvdXQKRGVjZW1iZXIgaXRzIGJhY2sgYmVjb21lcyBhIGJyaWxs
aWFudCBvcmFuZ2UteWVsbG93LCB3aGljaCBsYXN0cyB1bnRpbCBhYm91dApN
YXJjaCwgd2hlbiBpdCBpcyBhZ2FpbiByZXBsYWNlZCBieSBncmF5LiBUaGUg
c3F1aXJyZWwgc2hvd24gaW4gdGhlCmlsbHVzdHJhdGlvbiBpcyBhIG5hdGl2
ZSBvZiBCdXJtYSBhbmQgVGVuYXNzZXJpbSwgYW5kIGlzIGNsb3NlbHkgYWxs
aWVkIHRvIFMuCmNhbmljZXBzLCBidXQgZ29lcyB0aHJvdWdoIG5vIHNlYXNv
bmFsIGNoYW5nZSBvZiBjb2xvci4gQW5vdGhlciBCdXJtZXNlCnNxdWlycmVs
LCBTLiBoYXJpbmd0b25pLCBkaWZmZXJzIGFzIHJlZ2FyZHMgaW4gYSByZW1h
cmthYmFsZSBtYW5uZXIgZnJvbSBhbGwKb3RoZXIga25vd24gbWVtYmVycyBv
ZiB0aGUgZ3JvdXAuIEl0IGlzIGEgbWVkaXVtLXNpemVkIHNwZWNpZXMgb2Yg
YSBwYWxlIGNyZWFteQpidWZmIGNvbG9yIGFib3ZlLCBsaWdodGVyIGJlbmVh
dGgsIGFuZCB3aXRoIGEgd2hpdGlzaCB0YWlsLCB3aGlsZSBpdCBpcyBmdXJ0
aGVyCmNoYXJhY3Rlcml6ZWQgYnkgdGhlIGFic2VuY2Ugb2YgdGhlIGZpcnN0
IHVwcGVyIHByZW1vbGFyLCB3aGljaCBzaG93cyB0aGF0IGl0CmlzIG5vdCBh
biBhbGJpbm8gb3IgcGFsZSB2YXJpZXR5LiBUd28gZXhhbXBsZXMgd2VyZSBv
YnRhaW5zIGJ5IENhcHRhaW4gSC4gSC4KSGFyaW5ndG9uLCBvZiBvbmUgb2Yg
dGhlIFB1bmphYnUgcmVnaW1lbnRzLCBvbiB0aGUgVXBwZXIgQ2hpbmR3aW4g
cml2ZXIuIEl0IG1heQphbHNvIGJlIGFkZGVkIHRoYXQgZ2VuZXJpYyBzdWJk
aXZpc2lvbnMgb2YgdGhlIHNxdWlycmVscyBhcmUgYmFzZWQgbWFpbmx5IG9u
CnRoZSBjaGFyYWN0ZXJzIG9mIHRoZSBza3VsbCBhbmQgdGVldGguIFRoYXQg
dGhleSBhcmUgZXNzZW50aWFsIGlzIGV2aWRlbnQgZnJvbQp0aGUgY2lyY3Vt
c3RhbmNlcyB0aGF0IHRoZSBBZnJpY2FuIHNwaW55IHNxdWlycmVscyBYZXJ1
cyAoc2VlIFNQSU5ZIFNRVUlSUkVMKQpjb21lIGJldHdlZW4gU2NpdXJ1cyBh
bmQgc29tZSBvZiB0aGUgb3RoZXIgQWZyaWNhbiBnZW5lcmEuCgo=
====

Deleted runt/libs/io/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9









-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Name: Generic Input/Output
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides slightly more powerful data 
 input and output streams which can be used to read and write data.
X-SquirrelJME-Error: BD
X-SquirrelJME-UUID: 6897c4e3-8267-4438-949c-b6242cd1b3a8
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/io/net/multiphasicapps/io/Adler32Calculator.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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This class calculates the Adler32 checksum.
 *
 * This class is not thread safe.
 *
 * @since 2017/03/05
 */
public class Adler32Calculator
	implements Checksum
{
	/** The modulo for adler values. */
	private static final int _ADLER_MODULO =
		65521;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** The A value. */
	private volatile int _a =
		1;
	
	/** The B value. */
	private volatile int _b;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final int checksum()
	{
		return (this._b << 16) | this._a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		offer(solo, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte[] __b)
		throws NullPointerException
	{
		offer(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("BAOB");
		
		// Get parameters
		int a = this._a,
			b = this._b;
		
		// Calculate
		for (int p = __o, e = __o + __l; p < e; p++)
		{
			a = (a + (__b[p] & 0xFF)) % _ADLER_MODULO;
			b = (b + a) % _ADLER_MODULO;
		}
		
		// Set parameters
		this._a = a;
		this._b = b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void reset()
	{
		// Reset both parameters
		this._a = 1;
		this._b = 0;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/Base64Alphabet.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This represents the alphabet that is used for Base64.
 *
 * @since 2018/03/05
 */
public enum Base64Alphabet
{
	/** The basic and MIME alphabet. */
	BASIC('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='),
	
	/** The URL alphabet. */
	URL('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '='),
	
	/** End. */
	;
	
	/** The alphabet for the characters. */
	final char[] _alphabet;
	
	/**
	 * Initializes the alphabet.
	 *
	 * @param __alphabet The alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	private Base64Alphabet(char... __alphabet)
		throws NullPointerException
	{
		if (__alphabet == null)
			throw new NullPointerException("NARG");
		
		this._alphabet = __alphabet;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/Base64Decoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527















































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;

/**
 * This decodes the base64 character set, ignoring invalid characters, and
 * provides the binary data for the input. If the padding character is reached
 * or if the input stream runs out of characters then EOF is triggered.
 *
 * @since 2018/03/05
 */
public final class Base64Decoder
	extends InputStream
{
	/** The source reader. */
	protected final Reader in;
	
	/** Ignore padding characters. */
	protected final boolean ignorepadding;
	
	/** The alphabet to use for decoding. */
	private final char[] _alphabet;
	
	/** The ASCII map for quick lookup. */
	private final byte[] _ascii;
	
	/** Output bytes to drain. */
	private final byte[] _drain =
		new byte[3];
	
	/** The current fill buffer. */
	private volatile int _buffer;
	
	/** The number of bits which are in the buffer. */
	private volatile int _bits;
	
	/** Has EOF been reached if the pad has been detected? */
	private volatile boolean _readeof;
	
	/** The current output drain position. */
	private volatile int _drained =
		-1;
	
	/** The maximum value for drained values. */
	private volatile int _drainedmax =
		-1;
	
	/**
	 * Initializes the decode the default MIME alphabet.
	 *
	 * @param __in The input set of characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/23
	 */
	public Base64Decoder(Reader __in)
	{
		this(__in, Base64Alphabet.BASIC);
	}
	
	/**
	 * Initializes the decoder using the specified alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars, false);
	}
	
	/**
	 * Initializes the decoder using the default alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, Base64Alphabet __chars, boolean __ip)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, String __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the end
	 * of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public Base64Decoder(Reader __in, char[] __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __chars == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.erorr BD0g The alphabet to use for the base64
		// decoder must be 64 characters plus one padding character.
		// (The character count)}
		int n;
		if ((n = __chars.length) != 65)
			throw new IllegalArgumentException(String.format("BD0g %d", n));
		
		// Set
		this.in = __in;
		this.ignorepadding = __ip;
		this._alphabet = (__chars = __chars.clone());
		
		// Build ASCII map for quick in-range character lookup
		byte[] ascii = new byte[128];
		for (int i = 0; i < 128; i++)
			ascii[i] = -1;
		for (int i = 0; i < 65; i++)
		{
			int dx = __chars[i];
			if (dx < 128)
				ascii[dx] = (byte)i;
		}
		this._ascii = ascii;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		int drained = this._drained;
		
		// There are bytes which are ready and in the drain that we do not
		// need to block reading them?
		if (drained != -1)
			return this._drainedmax - drained;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		// If there is stuff to be drained, quickly drain that so we do not
		// need to go deeper into the heavier method
		int drained = this._drained;
		if (drained != -1)
		{
			// Read in drained character
			int rv = this._drain[drained++] & 0xFF;
			
			// Reached the drain limit?
			if (drained == this._drainedmax)
			{
				this._drained = -1;
				this._drainedmax = -1;
			}
			
			// Would still be drain
			else
				this._drained = drained;
			
			// Return the value
			return rv;
		}
		
		// Previously read EOF, so this will just return EOF
		if (this._readeof)
			return -1;
		
		// Otherwise decode and read
		byte[] next = new byte[1];
		for (;;)
		{
			int rc = this.read(next, 0, 1);
			
			// EOF?
			if (rc < 0)
				return -1;
			
			// Missed read
			else if (rc == 0)
				continue;
			
			return (next[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Did a previous read cause a padded EOF?
		boolean readeof = this._readeof;
		
		// Need lookups
		Reader in = this.in;
		boolean ignorepadding = this.ignorepadding;
		char[] alphabet = this._alphabet;
		byte[] ascii = this._ascii;
		byte[] drain = this._drain;
		
		// This buffer is filled into as needed when input characters are read
		int buffer = this._buffer,
			bits = this._bits,
			drained = this._drained,
			drainedmax = this._drainedmax;
		
		// Keep trying to fill bytes in
		int rv = 0;
		while (rv < __l)
		{
			// Still need to drain bytes away
			if (drained != -1 && drained < drainedmax)
			{
				// Drain it
				__b[__o++] = drain[drained++];
				rv++;
				
				// Drained all the characters
				if (drained == drainedmax)
					drained = drainedmax = -1;
				
				// Try again
				else
					continue;
			}
			
			// EOF was reached
			if (readeof)
				break;
			
			// Read in character and decode it
			int ch = in.read();
			
			// Is EOF?
			if (ch < 0)
			{
				// {@squirreljme.error BD01 Read EOF from input when there
				// were expected to be more characters or the ending padding
				// character. (The bits in the buffer)}
				if (bits != 0)
					throw new IOException("BD01 " + bits);
				
				// Did read EOF
				readeof = true;
				break;
			}
			
			// Determine the value of the character
			if (ch < 128)
				ch = ascii[ch];
			else
			{
				ch = -1;
				for (int i = 0; i < 65; i++)
					if (i == alphabet[i])
					{
						ch = i;
						break;
					}
			}
			
			// Invalid, ignore and continue
			if (ch == -1 || (ignorepadding && ch == 64))
				continue;
			
			// Decoded padding character
			else if (ch == 64)
			{
				// {@squirreljme.error BD02 Did not expect a padding character.
				// (The number of decoded bits in queue)}
				if (bits == 0 || bits == 24)
					throw new IOException("BD02 " + bits);
				
				// Only want to store a single extra byte since that is
				// all that is valid
				else if (bits < 16)
				{
					// {@squirreljme.error BD03 Expected another padding
					// character.}
					if (in.read() != alphabet[64])
						throw new IOException("BD03");
					
					drain[0] = (byte)(buffer >>> 4);
					
					drainedmax = 1;
				}
				
				// Otherwise there will be two characters to drain
				else
				{
					drain[0] = (byte)(buffer >>> 10);
					drain[1] = (byte)(buffer >>> 2);
					
					drainedmax = 2;
				}
				
				// Need to drain all
				drained = 0;
					
				// Clear the buffer
				buffer = bits = 0;
				
				// Did read EOF
				readeof = true;
			}
			
			// Normal data
			else
			{
				// Shift in six bits
				buffer <<= 6;
				buffer |= ch;
				bits += 6;
				
				// Drain and empty the buffer
				if (bits == 24)
				{
					// Fill the drain
					drain[0] = (byte)(buffer >>> 16);
					drain[1] = (byte)(buffer >>> 8);
					drain[2] = (byte)buffer;
					
					// Set these to drain
					drained = 0;
					drainedmax = 3;
					
					// Clear the buffer
					buffer = bits = 0;
				}
			}
		}
		
		// Store state for next run
		this._buffer = buffer;
		this._bits = bits;
		this._readeof = readeof;
		this._drained = drained;
		this._drainedmax = drainedmax;
		
		// Return the read count
		if (readeof && rv == 0)
			return -1;
		return rv;
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab)
		throws IllegalArgumentException, NullPointerException
	{
		return Base64Decoder.decode(__in, __ab, false);
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @param __ip Is padding ignored?
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public static final byte[] decode(String __in, Base64Alphabet __ab,
		boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __ab == null)
			throw new NullPointerException("NARG");
		
		// Wrap in a reader to decode
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			byte[] buf = new byte[32];
			
			// Loop handle bytes
			try (InputStream in = new Base64Decoder(
				new StringReader(__in), __ab, __ip))
			{
				for (;;)
				{
					int rc = in.read(buf);
					
					// EOF?
					if (rc < 0)
						break;
					
					// Copy
					baos.write(buf, 0, rc);
				}
			}
			
			// Return resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BD04 Could not decode the input string.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("BD04", e);
		}
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/BitSource.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;

/**
 * This is used for huffman tree traversal.
 *
 * @since 2016/08/16
 */
public interface BitSource
{
	/**
	 * Returns the next bit.
	 *
	 * @return The next bit.
	 * @throws IOException On read errors.
	 * @since 2016/08/16
	 */
	public abstract boolean nextBit()
		throws IOException;
}

Deleted runt/libs/io/net/multiphasicapps/io/ByteArrayData.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
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

























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This provides random access to data in the given byte array.
 *
 * @since 2016/08/11
 */
public class ByteArrayData
	implements RandomAccessData
{
	/** The starting offset. */
	protected final int offset;
	
	/** The number of bytes to access. */
	protected final int length;
	
	/** The endianess of the data to read. */
	protected final DataEndianess endianess;
	
	/** The backing array. */
	final byte[] _array;
	
	/**
	 * This wraps the given set of bytes.
	 *
	 * @param __end The endianess of the data.
	 * @param __b The bytes to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/11
	 */
	public ByteArrayData(DataEndianess __end, byte... __b)
		throws NullPointerException
	{
		this(__end, __b, 0, __b.length);
	}	
	
	/**
	 * This wraps the given set of bytes.
	 *
	 * @param __end The endianess of the data.
	 * @param __b The bytes to wrap.
	 * @param __o The starting offset.
	 * @param __l The length of bytes to wrap.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array size.
	 * @throws NullPointerException On null arguments
	 * @since 2016/08/11
	 */
	public ByteArrayData(DataEndianess __end, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__end == null || __b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("AIOB");
		
		// Set
		this.endianess = __end;
		this._array = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public DataEndianess getEndianess()
	{
		return this.endianess;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public void read(int __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readByte(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public double readDouble(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public double readFloat(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readInt(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public long readLong(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readShort(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readUnsignedByte(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/11
	 */
	@Override
	public int readUnsignedShort(int __p)
		throws IndexOutOfBoundsException
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/ByteDeque.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;

/**
 * This is a byte buffer which provides bytes for input and output as a
 * double ended queue.
 *
 * If the queue reaches full capacity then it is increased in size.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/11
 */
public class ByteDeque
{
	/**
	 * {@squirreljme.property net.multiphasicapps.util.datadeque.blocksize=n
	 * The block size of individual arrays that make up the {@link ByteDeque}
	 * class. The value must be a power of two.}
	 */
	private static final int _BLOCK_SIZE =
		Math.max(8, Integer.getInteger(
			"net.multiphasicapps.util.datadeque.blocksize", 128));
	
	/** The block size mask. */
	private static final int _BLOCK_MASK =
		_BLOCK_SIZE - 1;
	
	/** The shift to convert block based values. */
	private static final int _BLOCK_SHIFT =
		Integer.numberOfTrailingZeros(_BLOCK_SIZE);
	
	/** The maximum permitted capacity. */
	protected final int capacity;
	
	/** Blocks which make up the queue. */
	private final LinkedList<byte[]> _blocks =
		new LinkedList<>();
	
	/** Single byte (since it is synchronized). */
	private final byte[] _solo =
		new byte[1];
	
	/** The number of bytes in the queue. */
	private volatile int _total;
	
	/** The relative position of the head in relation to the first block. */
	private volatile int _head;
	
	/** The relative position of the tail in relation to the last block. */
	private volatile int _tail;
	
	/**
	 * Sets the default block size.
	 *
	 * @since 2016/05/01
	 */
	static
	{
		// {@squirreljme.error BD21 The block size of the data deque is not
		// a power of two. (The specified block size)}
		if (Integer.bitCount(_BLOCK_SIZE) != 1)
			throw new RuntimeException(String.format("BD21 %d", _BLOCK_SIZE));
	}
	
	/**
	 * Initializes a byte deque with a 2GiB buffer size limit.
	 *
	 * @since 2016/03/11
	 */
	public ByteDeque()
	{
		this(Integer.MAX_VALUE);
	}
	
	/**
	 * Initializes a byte deque with the given capacity.
	 *
	 * @param __cap The maximum deque capacity.
	 * @throws IllegalArgumentException If the capacity is negative.
	 * @since 2016/05/01
	 */
	public ByteDeque(int __cap)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD22 Negative deque capacity specified.}
		if (__cap < 0)
			throw new IllegalArgumentException("BD22");
		
		// Set
		capacity = __cap;
	}
	
	/**
	 * Attempts to add a single byte to the start of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The byte to add.
	 * @throws IllegalStateException If the capacity is violated.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte __b)
		throws IllegalStateException
	{
		byte[] solo = _solo;
		solo[0] = __b;
		addFirst(solo, 0, 1);
	}
	
	/**
	 * Attempts to add multiple bytes to the start of the queue, if the
	 * capacity would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte[] __b)
		throws IllegalStateException, NullPointerException
	{
		addFirst(__b, 0, __b.length);
	}
	
	/**
	 * Attempts to add multiple bytes to the start of the queue, if the
	 * capacity would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addFirst(byte[] __b, int __o, int __l)
		throws IllegalStateException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// No bytes to add, do nothing
		if (__l == 0)
			return;
		
		// {@squirreljme.error BD23 Adding bytes to the start would exceed
		// the capacity of the queue.}
		int total = this._total;
		int newtotal = total + __l;
		if (newtotal < 0 || newtotal > this.capacity)
			throw new IllegalStateException("BD23");
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		throw new todo.TODO();
	}
	
	/**
	 * Attempts to add a single byte to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The byte to add.
	 * @throws IllegalStateException If the capacity is violated.
	 * @since 2016/05/01
	 */
	public final void addLast(byte __b)
		throws IllegalStateException
	{
		byte[] solo = _solo;
		solo[0] = __b;
		addLast(solo, 0, 1);
	}
	
	/**
	 * Attempts to add multiple bytes to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addLast(byte[] __b)
		throws IllegalStateException, NullPointerException
	{
		addLast(__b, 0, __b.length);
	}
	
	/**
	 * Attempts to add multiple bytes to the end of the queue, if the capacity
	 * would be violated then an exception is thrown.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @throws IllegalStateException If the capacity is violated.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final void addLast(byte[] __b, int __o, int __l)
		throws IllegalStateException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// No bytes to add, do nothing
		if (__l == 0)
			return;
		
		// {@squirreljme.error BD24 Adding bytes to the end would exceed
		// the capacity of the queue.}
		int total = this._total;
		int newtotal = total + __l;
		if (newtotal < 0 || newtotal > this.capacity)
			throw new IllegalStateException("BD24");
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		// Keep adding in data
		int bs = _BLOCK_SIZE;
		int bm = _BLOCK_MASK;
		int left = __l;
		int at = __o;
		while (left > 0)
		{
			// If the tail is at the start of the block then a new one
			// must be created
			byte[] bl;
			if (tail == 0)
			{
				bl = new byte[bs];
				blocks.addLast(bl);
			}
			
			// Otherwise get the last one
			else
				bl = blocks.getLast();
			
			// Only can fit a single block
			int limit = bs - tail;
			if (left < limit)
				limit = left;
			
			// Write data
			for (int i = 0; i < limit; i++)
				bl[tail++] = __b[at++];
			
			// Masking is only needed after the write
			tail &= bm;
			
			// Consumed bytes
			left -= limit;
		}
		
		// Set new details
		this._total = newtotal;
		this._tail = tail;
	}
	
	/**
	 * Returns the number of available bytes inside of the queue.
	 *
	 * @return The number of bytes in the queue.
	 * @since 2016/05/01
	 */
	public final int available()
	{
		return this._total;
	}
	
	/**
	 * Clears the queue and every associated byte.
	 *
	 * @since 2016/08/02
	 */
	public final void clear()
	{
		// Reset variables
		this._total = 0;
		this._head = 0;
		this._tail = 0;
	
		// Zero out all blocks (for security and better compression)
		LinkedList<byte[]> blocks = this._blocks;
		for (byte[] bl : blocks)
			Arrays.fill(bl, (byte)0);
		blocks.clear();
	}
	
	/**
	 * Deletes the specified number of bytes at the start of the deque.
	 *
	 * @param __l The number of bytes to delete.
	 * @return The number of deleted bytes.
	 * @throws IndexOutOfBoundsException If the number of bytes is negative.
	 * @since 2016/08/04
	 */
	public final int deleteFirst(int __l)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD25 Attempt to delete starting from a negative
		// address.}
		if (__l < 0)
			throw new IndexOutOfBoundsException("BD25");
		
		// Do nothing
		if (__l == 0)
			return 0;
		
		// If the queue is empty do nothing
		int total = this._total;
		if (total == 0)
			return 0;
		
		// Do not remove more bytes than there are available
		int limit = (__l < total ? __l : total);
		int newtotal = total - limit;
		
		// Get some things
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		
		// Write bytes into the target
		int left = limit;
		int bs = _BLOCK_SIZE;
		int bm = _BLOCK_MASK;
		while (left > 0)
		{
			// Get the first block
			byte[] bl = blocks.getFirst();
			boolean lastbl = (nb == 1);
			
			// Determine the max number of bytes to delete
			int rc = (lastbl ? (tail == 0 ? bs : tail) - head : bs - head);
			if (left < rc)
				rc = left;
			
			// Should never occur, because that means the end is lower
			// than the start
			if (rc < 0)
				throw new todo.OOPS();
			
			// Erase data
			for (int i = 0; i < rc; i++)
				bl[head++] = 0;
			
			// Mask the head to detect overflow
			head &= bm;
			
			// If cycled, remove the first block
			if (head == 0 || (lastbl && head == tail))
			{
				blocks.removeFirst();
				nb--;
			}
			
			// Bytes were removed
			left -= rc;
		}
		
		// Emptied? Clear head/tail pointers
		if (newtotal == 0)
			head = tail = 0;
		
		// Set details
		this._total = newtotal;
		this._head = head;
		this._tail = tail;
		
		// Return the erase count
		return limit;
	}
	
	/**
	 * Gets a single byte offset from the start of the deque as if it were an
	 * array.
	 *
	 * @param __a The index to get the byte value of.
	 * @return The byte at the given position.
	 * @throws IndexOutOfBoundsException If the address is not within bounds.
	 * @since 2016/08/03
	 */
	public final byte get(int __a)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD26 Request get at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD26");
		
		byte[] solo = this._solo;
		int rv = get(__a, solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD27 Could not get the byte at the
		// given position because it exceeds the deque bounds. (The index)}
		throw new IndexOutOfBoundsException(String.format("BD27 %d", __a));
	}
	
	/**
	 * Gets multiple bytes offset from the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start reading values from.
	 * @param __b The destination array for values.
	 * @return The number of bytes read.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/03
	 */
	public final int get(int __a, byte[] __b)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return this.get(__a, __b, 0, __b.length);
	}
	
	/**
	 * Gets multiple bytes offset from the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start reading values from.
	 * @param __b The destination array for values.
	 * @param __o Where to start writing destination values.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque, the offset and/or length are negative, or the
	 * offset and length exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/03
	 */
	public final int get(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// {@squirreljme.error BD28 Request get at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD28");
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD29 The requested address is outside of
		// the bounds of the queue. (The requested address; The number of
		// bytes in the queue)}
		int total = this._total;
		if (__a < 0 || __a >= total)
			throw new IndexOutOfBoundsException(String.format("BD29 %d %d",
				__a, total));
		
		// If there are no bytes, all reads do nothing
		if (total <= 0)
			return 0;
		
		// If the address is within the starting half then seek from the
		// start, otherwise start from the trailing end
		return __getOrSetVia((__a < (total >> 1)), __a, __b, __o, __l, false);
	}
	
	/**
	 * Obtains but does not remove the first byte.
	 *
	 * @return The value of the first byte.
	 * @throws NoSuchElementException If the deque is empty.
	 * @since 2016/05/01
	 */
	public final byte getFirst()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = getFirst(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2a Could not get the first byte
		// because the deque is empty.}
		throw new NoSuchElementException("BD2a");
	}
	
	/**
	 * Obtains but does not remove the first set of bytes.
	 *
	 * @param __b The destination array to obtain the first bytes for.
	 * @return The number of read bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getFirst(byte[] __b)
		throws NullPointerException
	{
		return getFirst(__b, 0, __b.length);
	}
	
	/**
	 * Obtains but does not remove the first set of bytes.
	 *
	 * @param __b The destination array to obtain the first bytes for.
	 * @param __o The offset in the destination array to start reading bytes
	 * into.
	 * @param __l The number of bytes to read.
	 * @return The number of read bytes.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the bounds of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// This is the same of an any position get at the start
		return this.get(0, __b, __o, __l);
	}
	
	/**
	 * Obtains but does not remove the last byte.
	 *
	 * @return The value of the last byte.
	 * @throws NoSuchElementException If the deque is empty.
	 * @since 2016/05/01
	 */
	public final byte getLast()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = getLast(solo, 0, 1);
		if (rv == 0)
			return solo[0];
		
		// {@squirreljme.error BD2b Could not remove the last byte because
		// the deque is empty.}
		throw new NoSuchElementException("BD2b");
	}
	
	/**
	 * Obtains but does not remove the last set of bytes.
	 *
	 * @param __b The destination array to obtain the last bytes for.
	 * @return The number of read bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getLast(byte[] __b)
		throws NullPointerException
	{
		return getLast(__b, 0, __b.length);
	}
	
	/**
	 * Obtains but does not remove the last set of bytes.
	 *
	 * @param __b The destination array to obtain the last bytes for.
	 * @param __o The offset in the destination array to start reading bytes
	 * into.
	 * @param __l The number of bytes to read.
	 * @return The number of read bytes.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the bounds of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int getLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check, the length is used so make sure it is positive
		if (__l < 0)
			throw new IndexOutOfBoundsException("BAOB");
		
		// This is the same of an any position get from the end
		int total = this._total;
		return this.get(Math.max(0, total - __l), __b, __o, __l);
	}
	
	/**
	 * Returns whether or not this deque is empty.
	 *
	 * @return Whether it is empty or not.
	 * @since 2017/08/22
	 */
	public final boolean isEmpty()
	{
		return available() == 0;
	}
	
	/**
	 * Offers a single byte to the start of the deque and returns {@code true}
	 * if it was added to the deque.
	 *
	 * @param __b The byte to add to the start.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte __b)
	{
		// May violate the capacity
		try
		{
			addFirst(__b);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers multiple bytes to the start of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte[] __b)
		throws NullPointerException
	{
		return offerFirst(__b, 0, __b.length);
	}
	
	/**
	 * Offers multiple bytes to the start of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		// May violate the capacity
		try
		{
			addFirst(__b, __o, __l);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers a single byte to the end of the deque and returns {@code true} if
	 * it was added to the deque.
	 *
	 * @param __b The byte to add to the end.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte __b)
	{
		// May violate the capacity
		try
		{
			addLast(__b);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Offers multiple bytes to the end of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @return {@code true} if the capacity was not violated and the bytes were
	 * added.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte[] __b)
		throws NullPointerException
	{
		return offerLast(__b, 0, __b.length);
	}
	
	/**
	 * Offers multiple bytes to the end of the deque and returns {@code true}
	 * if they were added to the deque.
	 *
	 * @param __b The array to source bytes from.
	 * @param __o The offset to start reading from.
	 * @param __l The number of bytes to write.
	 * @return {@code this}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final boolean offerLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException
	{
		// May violate the capacity
		try
		{
			addLast(__b, __o, __l);
			return true;
		}
		
		// Violates capacity
		catch (IllegalStateException ise)
		{
			return false;
		}
	}
	
	/**
	 * Obtains but does not remove the first byte, returning a special value
	 * if the deque is empty.
	 *
	 * @return The value of the first byte or a negative value if the deque is
	 * empty.
	 * @since 2016/05/01
	 */
	public final int peekFirst()
		throws NoSuchElementException
	{
		// The deque could be empty
		try
		{
			return ((int)getFirst()) & 0xFF;
		}
		
		// Does not exist.
		catch (NoSuchElementException e)
		{
			return -1;
		}
	}
	
	/**
	 * Obtains but does not remove the last byte, returning a special value
	 * if the deque is empty.
	 *
	 * @return The value of the last byte or a negative value if the deque is
	 * empty.
	 * @since 2016/05/01
	 */
	public final int peekLast()
		throws NoSuchElementException
	{
		// The deque could be empty
		try
		{
			return ((int)getLast()) & 0xFF;
		}
		
		// Does not exist.
		catch (NoSuchElementException e)
		{
			return -1;
		}
	}
	
	/**
	 * Removes a single byte from the from of the deque.
	 *
	 * @return The next input byte.
	 * @throws NoSuchElementException If not a single byte is available.
	 * @since 2016/05/01
	 */
	public final byte removeFirst()
		throws NoSuchElementException
	{
		byte[] solo = this._solo;
		int rv = removeFirst(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2c Could not remove the first byte
		// because the deque is empty.}
		throw new NoSuchElementException("BD2c");
	}
	
	/**
	 * Removes multiple bytes from the front of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeFirst(byte[] __b)
		throws NullPointerException
	{
		return removeFirst(__b, 0, __b.length);
	}
	
	/**
	 * Removes multiple bytes from the front of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @param __o The offset to start writing into.
	 * @param __l The number of bytes to remove.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeFirst(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// If nothing to remove, do nothing
		if (__l == 0)
			return 0;
		
		// If the queue is empty do nothing
		int total = this._total;
		if (total == 0)
			return 0;
		
		// A remove is a get followed by a delete
		int rva = get(0, __b, __o, __l);
		int rvb = deleteFirst(__l);
		
		// If this occurs then the number of bytes deleted was not the
		// same as the number of bytes which were read.
		if (rva != rvb)
			throw new todo.OOPS();
		
		// Return the read count
		return rva;
	}
	
	/**
	 * Removes a single byte from the from of the deque.
	 *
	 * @return The next input byte.
	 * @throws NoSuchElementException If not a single byte is available.
	 * @since 2016/05/01
	 */
	public final byte removeLast()
		throws NoSuchElementException
	{
		byte[] solo = _solo;
		int rv = removeLast(solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2d Could not remove the last byte because
		// the deque is empty.}
		throw new NoSuchElementException("BD2d");
	}
	
	/**
	 * Removes multiple bytes from the end of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeLast(byte[] __b)
		throws NullPointerException
	{
		return removeLast(__b, 0, __b.length);
	}
	
	/**
	 * Removes multiple bytes from the end of the deque.
	 *
	 * @param __b The array to read bytes into.
	 * @param __o The offset to start writing into.
	 * @param __l The number of bytes to remove.
	 * @return The number of removed bytes, may be {@code 0}.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/01
	 */
	public final int removeLast(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets a single byte offset to the start of the deque as if it were an
	 * array.
	 *
	 * @param __a The index to set the byte value of.
	 * @return The byte at the given position.
	 * @throws IndexOutOfBoundsException If the address is not within bounds.
	 * @since 2017/02/04
	 */
	public final byte set(int __a)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BD2e Request set at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD2e");
		
		byte[] solo = this._solo;
		int rv = set(__a, solo, 0, 1);
		if (rv == 1)
			return solo[0];
		
		// {@squirreljme.error BD2f Could not set the byte at the
		// given position because it exceeds the deque bounds. (The index)}
		throw new IndexOutOfBoundsException(String.format("BD2f %d", __a));
	}
	
	/**
	 * Sets multiple bytes offset to the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start writing values to.
	 * @param __b The source array for values.
	 * @return The number of bytes write.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/04
	 */
	public final int set(int __a, byte[] __b)
		throws IndexOutOfBoundsException, NullPointerException
	{
		return this.set(__a, __b, 0, __b.length);
	}
	
	/**
	 * Sets multiple bytes offset to the start of the deque as if it were
	 * and array.
	 *
	 * @param __a The index to start writing values to.
	 * @param __b The source array for values.
	 * @param __o Where to start writing source values.
	 * @param __l The number of bytes to write.
	 * @return The number of bytes write.
	 * @throws IndexOutOfBoundsException If the address is not within the
	 * bounds of the deque, the offset and/or length are negative, or the
	 * offset and length exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/04
	 */
	public final int set(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// {@squirreljme.error BD2g Request set at a negative index.}
		if (__a < 0)
			throw new IndexOutOfBoundsException("BD2g");
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD2h The requested address is outside of
		// the bounds of the queue. (The requested address; The number of
		// bytes in the queue)}
		int total = this._total;
		if (__a < 0 || __a >= total)
			throw new IndexOutOfBoundsException(String.format("BD2h %d %d",
				__a, total));
		
		// If there are no bytes, all writes do nothing
		if (total <= 0)
			return 0;
		
		// If the address is within the starting half then seek to the
		// start, otherwise start to the trailing end
		return __getOrSetVia((__a < (total >> 1)), __a, __b, __o, __l, true);
	}
	
	/**
	 * Returns the number of bytes which are in this deque.
	 *
	 * @return The total number of bytes in this deque.
	 * @since 2017/08/14
	 */
	public final int size()
	{
		return this._total;
	}
	
	/**
	 * Returns all of the data in this deque as a single byte array.
	 *
	 * @return The data contained within this deque.
	 * @since 2017/02/04
	 */
	public final byte[] toByteArray()
	{
		int sz = available();
		byte[] rv = new byte[sz];
		get(0, rv, 0, sz);
		return rv;
	}
	
	/**
	 * Writes the entire deque into the specified output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/25
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Obtains or reads bytes starting from the head or tail side.
	 *
	 * @param __last If {@code true} then initial block traversal is done
	 * from the tail end rather than the head end.
	 * @param __a The address to read.
	 * @param __b The destination or source array.
	 * @param __o The output offset into the array.
	 * @param __l The number of bytes to read or write.
	 * @param __set If {@code true} then bytes will be read from the input
	 * array for writing.
	 * @return The number of bytes read.
	 * @since 2016/08/04
	 */
	private final int __getOrSetVia(boolean __last, int __a, byte[] __b,
		int __o, int __l, boolean __set)
	{
		// Get some things
		int total = this._total;
		LinkedList<byte[]> blocks = this._blocks;
		int nb = blocks.size();
		int head = this._head, tail = this._tail;
		int bs = _BLOCK_SIZE;
		int bm = _BLOCK_MASK;
		
		// The number of bytes to read
		int limit = total - __a;
		if (__l < limit)
			limit = __l;
		
		// Skip through the starting set of blocks since they are not
		// needed at all
		Iterator<byte[]> it;
		int blskip = (head + __a) >> _BLOCK_SHIFT;
		if (__last && nb > 1)
		{
			// Start from the back and then go to the index where we are
			// supposed to be at
			ListIterator<byte[]> lit = blocks.listIterator(nb);
			it = lit;
			int backskip = nb - blskip;
			for (int i = 0; i < backskip; i++)
				lit.previous();
		}
		
		// Start from the head size (the front)
		else
		{
			it = blocks.iterator();
			for (int i = 0; i < blskip; i++)
				it.next();
		}
		
		// The initial read head starts where the actual data starts
		// logicall in the buffer (if the head is 2 then address 42 is
		// 44 within the buffer).
		int rhead = (head + __a) & bm;
		
		// Read these bytes
		int left = limit;
		int at = __o;
		while (left > 0)
		{
			// Get the block data
			byte[] bl = it.next();
			
			// Is this the last block?
			boolean lastbl = !it.hasNext();
			
			// Determine the number of bytes to read
			int rc = (lastbl && tail != 0 ? tail : bs) - rhead;
			if (left < rc)
				rc = left;
			
			// Write the data
			if (__set)
				for (int i = 0; i < rc; i++)
					bl[rhead++] = __b[at++];
		
			// Read the data
			else
				for (int i = 0; i < rc; i++)
					__b[at++] = bl[rhead++];
			
			// Reset head to zero for the next block read
			rhead = 0;
			
			// Read this many bytes
			left -= rc;
		}
		
		// Return the nymber of bytes read
		return limit;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/CRC32Calculator.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
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



































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This is a data sink which supports the CRC 32 algorithm.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/16
 */
public class CRC32Calculator
	implements Checksum
{
	/** Working buffer size. */
	private static final int _WORK_BUFFER =
		32;
	
	/** The polynomial to use. */
	protected final int polynomial;
	
	/** The final XOR value. */
	protected final int finalxor;
	
	/** Reflect the data? */
	protected final boolean reflectdata;
	
	/** Reflect the remainder? */
	protected final boolean reflectremainder;
	
	/** The initial remainder. */
	protected final int initremainder;
	
	/** The CRC Table. */
	final __CRC32Table__ _table;
	
	/** Solo buffer. */
	private final byte[] _solo =
		new byte[1];
	
	/** The work buffer. */
	private final byte[] _work =
		new byte[_WORK_BUFFER];
	
	/** The current CRC value (remainder). */
	private volatile int _remainder;
	
	/**
	 * Initializes the CRC-32 data sink.
	 *
	 * @param __rdata Reflect the data?
	 * @param __rrem Reflect the remainder?
	 * @param __poly The polynomial.
	 * @param __initrem The initial remainder.
	 * @param __fxor The value to XOR the remainder with on return.
	 * @since 2016/07/16
	 */
	public CRC32Calculator(boolean __rdata, boolean __rrem, int __poly,
		int __initrem, int __fxor)
	{
		// Set
		this.reflectdata = __rdata;
		this.reflectremainder = __rrem;
		this.polynomial = __poly;
		this.finalxor = __fxor;
		this.initremainder = __initrem;
		this._remainder = __initrem;
		
		// Setup table
		this._table = __CRC32Table__.__table(__poly);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/16
	 */
	@Override
	public final int checksum()
	{
		// Return the current CRC
		int rem = this._remainder;
		return (this.reflectremainder ? Integer.reverse(rem) : rem) ^
			this.finalxor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		offer(solo, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte[] __b)
		throws NullPointerException
	{
		offer(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/20
	 */
	@Override
	public final void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("BAOB");
		
		// Read data into the work buffer
		boolean reflectdata = this.reflectdata;
		int remainder = this._remainder;
		int[] table = this._table._table;
		for (int i = __o, end = __o + __l; i < end; i++)
		{
			// Read in data value
			int val = __b[i] & 0xFF;
		
			// Reflect the data?
			if (reflectdata)
				val = Integer.reverse(val) >>> 24;
		
			int d = (val ^ (remainder >>> 24));
			remainder = table[d] ^ (remainder << 8);
		}
		
		// Set new remainder
		this._remainder = remainder;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/05
	 */
	@Override
	public final void reset()
	{
		// Only the remainder has to be updated
		this._remainder = this.initremainder;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/Checksum.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This interface is implemented by checksum calculators and may be used to
 * assist in the calculation of checksums.
 *
 * @since 2017/03/05
 */
public interface Checksum
{
	/**
	 * Returns the currently calculated checksum value.
	 *
	 * @return The current checksum value.
	 * @since 2017/03/05
	 */
	public abstract int checksum();
	
	/**
	 * Offers a single byte for checksum calcualtion.
	 *
	 * @param __b The byte to offer.
	 * @since 2017/03/05
	 */
	public abstract void offer(byte __b);
	
	/**
	 * Offers multiple byte for checksum calculation.
	 *
	 * @param __b The bytes to offer.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/05
	 */
	public abstract void offer(byte[] __b)
		throws NullPointerException;
	
	/**
	 * Offers multiple byte for checksum calculation.
	 *
	 * @param __b The bytes to offer.
	 * @param __o The starting offset to read bytes from.
	 * @param __l The number of bytes to buffer.
	 * @throws ArrayIndexOutOfBoundsException If the offset or length are
	 * negative or they exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/05
	 */
	public abstract void offer(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Resets the checksum calculator to its initial state.
	 *
	 * @since 2017/03/05
	 */
	public abstract void reset();
}

Deleted runt/libs/io/net/multiphasicapps/io/ChecksumInputStream.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
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




















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.IOException;

/**
 * The forwards data from an input stream and calculates the checksum for that
 * data stream.
 *
 * @since 2017/03/05
 */
public class ChecksumInputStream
	extends InputStream
{
	/** The checksum Calculator used. */
	protected final Checksum checksum;
	
	/** Input stream. */
	protected final InputStream in;
	
	/**
	 * Initializes the calculator.
	 *
	 * @param __checksum The checksum calculator to write to.
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/28
	 */
	public ChecksumInputStream(Checksum __calc, InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__calc == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.checksum = __calc;
		this.in = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.in.read();
		
		// EOF?
		if (rv < 0)
			return rv;
		
		// Calculate checksum
		this.checksum.offer((byte)rv);
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/28
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Read data
		int rv = this.in.read(__b, __o, __l);
		
		// EOF?
		if (rv < 0)
			return rv;
		
		// Calculate checksum
		this.checksum.offer(__b, __o, rv);
		
		// Read count
		return rv;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/CompressionLevel.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This represents the compression level, which is based on how fast things
 * are.
 *
 * @since 2018/11/10
 */
public enum CompressionLevel
{
	/** Fast compression level. */
	FASTEST,
	
	/** Faster compression. */
	FASTER,
	
	/** Fast compression. */
	FAST,
	
	/** Slow compression. */
	SLOW,
	
	/** Slower compression. */
	SLOWER,
	
	/** Slowest compression. */
	SLOWEST,
	
	/** End. */
	;
	
	/** The default compression level. */
	public static final CompressionLevel DEFAULT =
		SLOW;
	
	/** The best compression level. */
	public static final CompressionLevel BEST =
		SLOWEST;
	
	/**
	 * The number of symbols to look at as a single unit with a given
	 * dictionary before attempting with another dictionary.
	 *
	 * @return The block size to use for compression.
	 * @since 2018/11/10
	 */
	public final int blockSize()
	{
		switch (this)
		{
				// Fast has no sliding window
			case FASTEST:	return 64;
			case FASTER:	return 128;
			case FAST:		return 256;
			
				// Slow algorithms compress in more chunks
			case SLOW:		return 256;
			case SLOWER:	return 512;
			case SLOWEST:	return 1024;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Converts a ZIP compression 1-10 scale index to compression level.
	 *
	 * @param __i The input scale.
	 * @return The compression level for the scale.
	 * @since 2018/11/10
	 */
	public static final CompressionLevel ofLevel(int __i)
	{
		switch (__i)
		{
			case 1:		return FASTEST;
			
			case 2:
			case 3:		return FASTER;
			
			case 4:
			case 5:		return FAST;
			
			case 6:
			case 7:		return SLOW;
			
			case 8:
			case 9:		return SLOWER;
			
			case 10:	return SLOWEST;
			
				// Out of range, so just treat as capped
			default:
				return (__i <= 0 ? FASTEST : SLOWEST);
		}
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/CompressionStream.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.Closeable;
import java.io.IOException;

/**
 * This interface is used for compressed streams.
 *
 * @since 2017/08/22
 */
public interface CompressionStream
	extends Closeable
{
	/**
	 * Returns the number of compressed bytes which were read.
	 *
	 * @return The number of compressed bytes which were read.
	 * @since 2017/08/22
	 */
	public abstract long compressedBytes();
	
	/**
	 * Returns the number of uncompressed bytes which have been read.
	 *
	 * @return The number of read uncompressed bytes.
	 * @since 2017/08/22
	 */
	public abstract long uncompressedBytes();
}

Deleted runt/libs/io/net/multiphasicapps/io/DataEndianess.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This can be set on a stream which sets the default endianess on methods
 * that do not read using a specified endianess.
 *
 * @since 2016/07/10
 */
public enum DataEndianess
{
	/** Big endian. */
	BIG,
	
	/** Little endian. */
	LITTLE,
	
	/** End. */
	;
}

Deleted runt/libs/io/net/multiphasicapps/io/DecompressionInputStream.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.IOException;

/**
 * This interface is used to describe a compression stream which is used as
 * input.
 *
 * @since 2017/08/22
 */
public abstract class DecompressionInputStream
	extends InputStream
	implements CompressionStream
{
	/**
	 * If the decompression algorithm has a means or flag to indicate that
	 * there is no more compressed data and that the end of stream has been
	 * reached then this should return {@code true}.
	 *
	 * If it is unknown whether it can be detected or not, then {@code false}
	 * should be returned.
	 *
	 * @return {@code true} if this algorithm detects the end of file before
	 * the end of the actual input source, otherwise if only the end of the
	 * file causes EOF to be returned then this returns {@code false}. If it
	 * is not known then {@code false} must be returned.
	 * @since 2017/08/22
	 */
	public abstract boolean detectsEOF();
}

Deleted runt/libs/io/net/multiphasicapps/io/DeflaterOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403



















































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is used to compress to standard deflate streams.
 *
 * Associated standards:
 * {@link https://www.ietf.org/rfc/rfc1951.txt}.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/10
 */
public class DeflaterOutputStream
	extends OutputStream
	implements CompressionStream
{
	/** Stream to write compressed data to. */
	protected final OutputStream out;
	
	/** The block size to compress for. */
	private final int _blocksize;
	
	/** The bytes to process first. */
	private final byte[] _fill;
	
	/** The number of bytes in the fill. */
	private int _fillbytes;
	
	/** Has this been closed? */
	private boolean _closed;
	
	/** Compressed bytes. */
	private long _ncompressed;
	
	/** Uncompressed bytes. */
	private long _nuncompressed;
	
	/** The temporary bits for output. */
	private int _wout;
	
	/** The number to bits available to the output. */
	private int _wbits;
	
	/**
	 * Initializes the deflation stream.
	 *
	 * @param __os The output stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public DeflaterOutputStream(OutputStream __os)
		throws NullPointerException
	{
		this(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Initializes the deflation stream.
	 *
	 * @param __os The output stream.
	 * @param __cl The compression level to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public DeflaterOutputStream(OutputStream __os, CompressionLevel __cl)
		throws NullPointerException
	{
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		this.out = __os;
		
		// Process data by blocks for efficiency
		int blocksize = __cl.blockSize();
		this._fill = new byte[blocksize];
		this._blocksize = blocksize;
		
		// Since compression is not actually implemented, say it should
		// actually be done here!
		todo.TODO.note("Implement fixed and dynamic huffman!");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Only close once!
		if (!this._closed)
		{
			// Is closed
			this._closed = true;
			
			// Process any fill remaining so it gets compressed
			if (this._fillbytes > 0)
				this.__processFill();
			
			// Mark final block
			this.__bitOut(1, 1, false);
			
			// Fixed huffman
			this.__bitOut(InflaterInputStream._TYPE_FIXED_HUFFMAN, 2, false);
			
			// Write code 256 which means to end processing the data, this
			// is just 0b000 + 0b0000 for the offset value
			this.__bitOut(0b000_0000, 7, true);
			
			// Pad to 8 bytes so partial bits for the end are not lost
			this.__bitPad(8);
			
			// Perform final flushing before closing to make sure everything
			// is written
			this.__bitFlush();
			this.flush();
		}
		
		// We need to pass close to the wrapped stream
		this.out.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final long compressedBytes()
	{
		return this._ncompressed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// Flush all the bits
		this.__bitFlush();
		
		// Then flush the stream itself
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final long uncompressedBytes()
	{
		return this._nuncompressed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Just forward write call since it is easier
		this.write(new byte[]{(byte)__b}, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/10
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		byte[] fill = this._fill;
		int blocksize = this._blocksize,
			fillbytes = this._fillbytes;
		
		// Write into the fill buffer, but do fill in chunks since that is
		// more optimized
		boolean addedfill = false;
		while (__l > 0)
		{
			// We can only fit so many bytes in the fill before it is full
			int leftinfill = blocksize - fillbytes;
			if (__l < leftinfill)
				leftinfill = __l;
			
			// Copy bytes into the fill
			for (int i = 0; i < leftinfill; i++)
				fill[fillbytes++] = __b[__o++];
			
			// Length is dropped by the fill
			__l -= leftinfill;
			
			// Process entire block of bytes
			if (fillbytes == blocksize)
			{
				// Need to store the number of bytes written before we
				// continue
				this._fillbytes = fillbytes;
				this.__processFill();
				
				// Since the entire fill was drained, this would have been
				// reset
				fillbytes = 0;
			}
			
			// Fill would have been added, so need to say that there are
			// bytes in here currently
			else
				addedfill = true;
		}
		
		// These original bytes were added
		this._nuncompressed += __l;
		
		// Bytes were added to the fill, record those
		if (addedfill)
			this._fillbytes = fillbytes;
	}
	
	/**
	 * Flushes the input bits to the output stream.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/11/01
	 */
	final void __bitFlush()
		throws IOException
	{
		// Only write if there are enough bits to write
		int wbits = this._wbits;
		if (wbits >= 8)
		{
			OutputStream out = this.out;
			int wout = this._wout;
			long ncompressed = this._ncompressed;
			
			// Send to the output
			while (wbits >= 8)
			{
				// Send to output
				out.write(wout & 0xFF);
				
				// Clip down
				wout >>>= 8;
				wbits -= 8;
				
				// Single byte was written
				ncompressed++;
			}
			
			// Store new values
			this._wbits = wbits;
			this._wout = wout;
			this._ncompressed = ncompressed;
		}
	}
	
	/**
	 * Writes the specified bits to the output.
	 *
	 * @param __v The value to write.
	 * @param __n The number of bits to store.
	 * @param __msb Is the most significant bit first?
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __bitOut(int __v, int __n, boolean __msb)
		throws IOException
	{
		// If writing with the most significant bit first, flip
		if (__msb)
			__v = Integer.reverse(__v) >>> (32 - __n);
		
		// Bit storage
		int wout = this._wout,
			wbits = this._wbits;
		
		// Need to mask off so sign values do not mess anything up above
		int mask = (1 << __n) - 1;
		
		// Add the new value to the top of the bits
		wout |= (__v & mask) << wbits;
		wbits += __n;
		
		// Store for next cycle (or out flush)
		this._wout = wout;
		this._wbits = wbits;
		
		// There are too many bits in the output, so send them to the stream
		// accordingly
		if (wbits >= 24)
			this.__bitFlush();
	}
	
	/**
	 * Pads the output bits the given number.
	 *
	 * @param __n The number of bits to pad to.
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __bitPad(int __n)
		throws IOException
	{
		// If we have two bits 0b00 and we pad to 8 we want 0b00000000 then
		// we add six extra bits. But if we are at 8 already we just keep
		// it as is. In this code wbits is 2, pad is 8... 2 % 8 is 2, then
		// we just take 2 from 8 and we get 6.
		int wbits = this._wbits,
			rem = wbits % __n;
		this._wbits = wbits + (__n - rem);
	}
	
	/**
	 * Processes the bytes which are in the fill buffer.
	 *
	 * @throws IOException On write errors.
	 * @since 2018/11/10
	 */
	final void __processFill()
		throws IOException
	{
		// Get fill parameters
		byte[] fill = this._fill;
		int fillbytes = this._fillbytes;
		
		// Determine the best way to handle this block
		int hufftype = 0;
		
		// Compress with fixed table
		if (hufftype == 1)
		{
			throw new todo.TODO();
		}
		
		// Compress with dynamically generated table
		else if (hufftype == 2)
		{
			throw new todo.TODO();
		}
		
		// No compression used
		else
		{
			// Write all the bytes with no compression at all
			// Write no-compression marker, stream not ended yet
			this.__bitOut(0, 1, false);
			this.__bitOut(InflaterInputStream._TYPE_NO_COMPRESSION, 2, false);
			
			// Pad because byte boundary
			this.__bitPad(8);
			
			// Length and complement of that
			this.__bitOut(fillbytes, 16, false);
			this.__bitOut(fillbytes ^ 0xFFFF, 16, false);
			
			// Then write every individual byte
			for (int i = 0; i < fillbytes; i++)
				this.__bitOut(fill[i], 8, false);
		}
		
		// Remove the fill
		this._fillbytes = 0;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/DynamicHistoryInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is an input stream which allows any future data in the stream to be
 * cached for later actual reading. This class should be used in situations
 * where it is needed to read future bytes in the stream and react to those
 * bytes.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public class DynamicHistoryInputStream
	extends InputStream
{
	/** The backing buffer. */
	protected final ByteDeque buffer;
	
	/** The source input stream. */
	protected final InputStream input;
	
	/** Closed? */
	private volatile boolean _closed;
	
	/** EOF reached? */
	private volatile boolean _eof;
	
	/**
	 * Initializes a dynamic history stream which sources data from the given
	 * input stream.
	 *
	 * @param __is The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public DynamicHistoryInputStream(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.input = __is;
		this.buffer = new ByteDeque();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public void close()
		throws IOException
	{
		// Close
		this._closed = true;
		
		// Clear the buffer since it is not needed
		this.buffer.clear();
		
		// Close wrapped stream
		this.input.close();
	}
	
	/**
	 * Grabs the specified number of bytes and loads them into an internal
	 * queue where they may then be obtained using another method. 
	 *
	 * @param __i The number of bytes to read ahead and buffer.
	 * @return The number of bytes which are available for input, this may
	 * be less than or greater than the input parameter.
	 * @throws IndexOutOfBoundsException If the count is negative.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public int grab(int __i)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0m A negative number of bytes cannot be
		// grabbed. (The number of bytes to grab)}
		if (__i < 0)
			throw new IndexOutOfBoundsException(String.format("BD0m %s", __i));
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0n Cannot grab bytes because the stream
		// is closed.}
		if (this._closed)
			throw new IOException("BD0n");
		
		// Already have this number of bytes grabbed
		int cursize = buffer.available();
		if (__i <= cursize)
			return cursize;
		
		// The number of bytes that need to be read
		int diff = __i - cursize;
		
		// Read them from the input
		byte[] qq = new byte[diff];
		int total = 0;
		while (total < diff)
		{
			// Read in bytes
			int rc = this.input.read(qq);
		
			// If EOF was read, stop
			if (rc < 0)
				break;
		
			// Add them to the end of the buffer
			buffer.addLast(qq, 0, rc);
		
			// The number of available bytes is the current and the read
			// count
			total += rc;
		}
		
		// Read total
		return cursize + total;
	}
	
	/**
	 * Reads a single byte that is ahead of the current read position.
	 *
	 * @param __a The position of the byte ahead of the current read position
	 * to read.
	 * @return The read value or a negative value if the byte to be read
	 * exceeds the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public int peek(int __a)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0o Cannot a peek byte which have already been
		// read. (The requested index)}
		if (__a < 0)
			throw new IndexOutOfBoundsException(String.format("BD0o %d", __a));
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0p Cannot peek a single byte because the
		// stream is closed.}
		if (this._closed)
			throw new IOException("BD0p");
		
		// Grab bytes, stop if none are available
		int avail = grab(__a + 1);
		if (avail < __a)
			return -1;
		
		throw new todo.TODO();
	}
	
	/**
	 * Reads multiple bytes which are ahead of the current read position.
	 *
	 * @param __a The start position of the bytes ahead of the current read
	 * position.
	 * @param __b The array which receives the bytes being read.
	 * @return The number of bytes read or a negative value if there are no
	 * bytes to be read because they exceed the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public int peek(int __a, byte[] __b)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.peek(__a, __b, 0, __b.length);
	}
	
	/**
	 * Reads multiple bytes which are ahead of the current read position.
	 *
	 * @param __a The start position of the bytes ahead of the current read
	 * position.
	 * @param __b The array which receives the bytes being read.
	 * @param __o The starting offset into the array to write into.
	 * @param __l The number of bytes to read.
	 * @return The number of bytes read or a negative value if there are no
	 * bytes to be read because they exceed the end of the stream.
	 * @throws IndexOutOfBoundsException If the requested read ahead position
	 * is negative; or the offset and or length exceed the array size.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public int peek(int __a, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// {@squirreljme.error BD0q Cannot peek bytes which have already been
		// read. (The requested index)}
		if (__a < 0)
			throw new IndexOutOfBoundsException(String.format("BD0q %d", __a));
		
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme.error BD0r Cannot peek multiple bytes because
		// the stream is closed.}
		if (this._closed)
			throw new IOException("BD0r");
		
		// Grab bytes, stop if none are available
		int avail = grab(__a + __l);
		if (avail < __a)
			return -1;
		
		// Not reading anything?
		int rc = Math.min(__l, avail);
		if (rc < 0)
			return 0;
		
		// Read from the buffer
		buffer.get(__a, __b, __o, rc);
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read()
		throws IOException
	{
		// {@squirreljme.error BD0s Cannot read a single byte because the
		// stream has been closed.}
		if (this._closed)
			throw new IOException("BD0s");
		
		// Grab a single byte
		int gc = grab(1);
		
		// Nothing left
		if (gc <= 0)
			return -1;
		
		// Read single byte
		return (this.buffer.removeFirst() & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Lock
		ByteDeque buffer = this.buffer;
		
		// {@squirreljme BI08 Cannot read multiple bytes because the
		// stream is closed.}
		if (this._closed)
			throw new IOException("BI08");
		
		// Grab multiple bytes
		int gc = grab(__l);
		
		// Nothing left?
		if (gc <= 0)
			return -1;
		
		// No bytes to read?
		int dc = Math.min(gc, __l);
		if (dc <= 0)
			return 0;
		
		// Remove the early bytes
		buffer.removeFirst(__b, __o, dc);
		return dc;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/ExtendedDataInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469





















































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;

/**
 * This is an extended input stream which is better suited for general binary
 * data file reading compared to the standard {@link DataInputStream}.
 *
 * Streams default to big endian.
 *
 * @since 2016/07/10
 */
public class ExtendedDataInputStream
	extends InputStream
	implements DataInput, SettableEndianess, SizedStream
{
	/** The original input stream. */
	protected final DataInputStream input;
	
	/** Is mark supported? */
	protected final boolean canmark;
	
	/** The target endianess. */
	private volatile DataEndianess _endian =
		DataEndianess.BIG;
	
	/** The number of bytes read. */
	private volatile long _count;
	
	/** The mark start position. */
	private volatile long _markstart =
		-1L;
	
	/** The mark end position. */
	private volatile long _markend =
		-1L;
	
	/**
	 * Initializes the extended input stream.
	 *
	 * @param __is The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/10
	 */
	public ExtendedDataInputStream(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		DataInputStream w;
		this.input = (w = ((__is instanceof DataInputStream) ?
			(DataInputStream)__is : new DataInputStream(__is)));
		
		// Need to know if marking is supported
		this.canmark = w.markSupported();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int available()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void close()
		throws IOException
	{
		this.input.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public DataEndianess getEndianess()
	{
		return this._endian;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void mark(int __rl)
	{
		// Nothing to mark or not supported? Do nothing
		if (__rl <= 0 || !this.canmark)
			return;
		
		// Mark the sub-stream
		this.input.mark(__rl);
		
		// Start marker count
		long count = this._count;
		this._markstart = count;
		this._markend = count + __rl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public boolean markSupported()
	{
		return this.canmark;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.input.read();
		
		// Increase count if not EOF
		if (rv >= 0)
			this._count++;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read(byte[] __b)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public boolean readBoolean()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public byte readByte()
		throws IOException
	{
		// Read value
		int rv = read();
		
		// {@squirreljme.error BD0t End of file reached.}
		if (rv < 0)
			throw new EOFException("BD0t");
		
		// Cast
		return (byte)rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public char readChar()
		throws IOException
	{
		return (char)readShort();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public double readDouble()
		throws IOException
	{
		return Double.longBitsToDouble(readLong());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public float readFloat()
		throws IOException
	{
		return Float.intBitsToFloat(readInt());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void readFully(byte[] __b)
		throws IOException
	{
		readFully(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void readFully(byte[] __b, int __o, int __l)
		throws IOException
	{
		this.input.readFully(__b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readInt()
		throws IOException
	{
		// Read
		int val = this.input.readInt();
		
		// Increase read count
		this._count += 4; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Integer.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Reads the next line of bytes, treating them as characters (0-255).
	 *
	 * Reading stops when a newline is encountered, which is discarded from
	 * the input.
	 *
	 * If a carriage return is read then if the next character is a newline,
	 * they are both discarded, otherwise the carriage return is discarded.
	 * Reading stops in either case.
	 *
	 * @return The read line or {@code null} if the end of file was reached
	 * before any bytes were read.
	 * @throws IOException On read errors.
	 * @since 2016/09/18
	 */
	public String readLine()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long readLong()
		throws IOException
	{
		// Read
		long val = this.input.readLong();
		
		// Increase read count
		this._count += 8; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Long.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public short readShort()
		throws IOException
	{
		// Read
		short val = this.input.readShort();
		
		// Increase read count
		this._count += 2; 
		
		// Swap?
		switch (this._endian)
		{
			case BIG: return val;
			case LITTLE: return Short.reverseBytes(val);
			
				// Unknown
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readUnsignedByte()
		throws IOException
	{
		return readByte() & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int readUnsignedShort()
		throws IOException
	{
		return readShort() & 0xFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public String readUTF()
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void reset()
		throws IOException
	{
		// {@squirreljme.error BD0u The stream has not been marked.}
		long markstart = this._markstart;
		if (markstart < 0)
			throw new IOException("BD0u");
		
		// {@squirreljme.error BD0v Exceeded the number of bytes specified by
		// mark.}
		long count = this._count;
		long markend = this._markend;
		if (count > markend)
			throw new IOException("BD0v");
		
		// Call reset
		this.input.reset();
		
		// Reset the current count to the start of the mark
		this._count = markstart;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public DataEndianess setEndianess(DataEndianess __end)
	{
		// Check
		if (__end == null)
			throw new NullPointerException("NARG");
		
		// Get and set
		DataEndianess rv = this._endian;
		this._endian = __end;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long size()
	{
		return this._count;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public long skip(long __n)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public int skipBytes(int __n)
		throws IOException
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/ExtendedDataOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459











































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an extended output stream which is better suited to writing
 * general binaries compared to the standard {@link DataOutputStream}.
 *
 * Streams default to big endian.
 *
 * This class is not thread safe.
 *
 * {@squirreljme.error BD0w Unhandled endianess. (The endianess)}
 *
 * @since 2016/07/10
 */
public class ExtendedDataOutputStream
	extends OutputStream
	implements DataOutput, SettableEndianess, SizedStream
{
	/** The output data stream. */
	protected final DataOutputStream output;
	
	/** The target endianess. */
	private volatile DataEndianess _endian =
		DataEndianess.BIG;
	
	/** The current file size. */
	private volatile long _size;
	
	/**
	 * Initializes the extended data output stream.
	 *
	 * @param __os The stream to write data to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/10
	 */
	public ExtendedDataOutputStream(OutputStream __os)
		throws NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = ((__os instanceof DataOutputStream) ?
			(DataOutputStream)__os : new DataOutputStream(__os));
	}
	
	/**
	 * Aligns the output to the given number of bytes.
	 *
	 * @param __n The number of bytes to align to.
	 * @throws IndexOutOfBoundsException If the alignment amount is zero or
	 * negative.
	 * @throws IOException On write errors.
	 * @since 2016/09/11
	 */
	public void align(int __n)
		throws IndexOutOfBoundsException, IOException
	{
		// {@squirreljme.error BD0x Cannot align to zero or a negative
		// amount.}
		if (__n <= 0)
			throw new IndexOutOfBoundsException("BD0x");
		
		// Pad
		while ((size() % __n) != 0)
			write(0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void close()
		throws IOException
	{
		this.output.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public void flush()
		throws IOException
	{
		this.output.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final DataEndianess getEndianess()
	{
		return this._endian;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final DataEndianess setEndianess(DataEndianess __end)
		throws NullPointerException
	{
		// Check
		if (__end == null)
			throw new NullPointerException("NARG");
		
		// Get and set
		DataEndianess rv = this._endian;
		this._endian = __end;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final long size()
	{
		return this._size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Forward
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Write
		this.output.write(__b, __o, __l);
		
		// Add size
		this._size += __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		this.output.write(__b);
		this._size++;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeBoolean(boolean __v)
		throws IOException
	{
		writeByte((__v ? 1 : 0));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeByte(int __v)
		throws IOException
	{
		this.output.write(__v);
		this._size++;
	}
	
	/**
	 * Writes a single byte, if its value is out of range then a write error
	 * occurs.
	 *
	 * @param __v The byte to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeByteExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD0y Byte value out of range.}
		if (__v < -128 || __v > 127)
			throw new IOException("BD0y");
		
		writeByte(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeBytes(String __s)
		throws IOException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeChar(int __v)
		throws IOException
	{
		writeShort(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeChars(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Write all characters
		int n = __s.length();
		for (int i = 0; i < n; i++)
			writeShort(__s.charAt(i));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeDouble(double __v)
		throws IOException
	{
		writeLong(Double.doubleToRawLongBits(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeFloat(float __v)
		throws IOException
	{
		writeInt(Float.floatToRawIntBits(__v));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeInt(int __v)
		throws IOException
	{
		// Depends on the endian
		DataOutputStream output = this.output;
		DataEndianess endian = this._endian;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeInt(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeInt(Integer.reverseBytes(__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04", endian));
		}
		
		// Increase
		this._size += 4;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeLong(long __v)
		throws IOException
	{
		// Depends on the endianess
		DataEndianess endian = this._endian;
		DataOutputStream output = this.output;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeLong(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeLong(Long.reverseBytes(__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04", endian));
		}
		
		// Increase
		this._size += 8;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeShort(int __v)
		throws IOException
	{
		// Depends on the endian
		DataEndianess endian = this._endian;
		DataOutputStream output = this.output;
		switch (endian)
		{
				// Big
			case BIG:
				output.writeShort(__v);
				break;
				
				// Little
			case LITTLE:
				output.writeShort(Short.reverseBytes((short)__v));
				break;
			
				// Unknown
			default:
				throw new IOException(String.format("BD04", endian));
		}
		
		// Increase
		this._size += 2;
	}
	
	/**
	 * Writes a single short, if its value is out of range then a write error
	 * occurs.
	 *
	 * @param __v The short to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeShortExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD0z Short value out of range.}
		if (__v < -32768 || __v > 32767)
			throw new IOException("BD0z");
		
		writeShort(__v);
	}
	
	/**
	 * Writes a single unsigned byte, if its value is out of range then a
	 * write error occurs.
	 *
	 * @param __v The unsigned byte to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeUnsignedByteExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD10 Unsigned byte value out of range.}
		if (__v < 0 || __v > 255)
			throw new IOException("BD10");
		
		writeByte(__v);
	}
	
	/**
	 * Writes a single unsigned byte, if its value is out of range then a
	 * write error occurs.
	 *
	 * @param __v The unsigned short to write.
	 * @throws IOException On out of range or other write errors.
	 * @since 2016/09/14
	 */
	public final void writeUnsignedShortExact(int __v)
		throws IOException
	{
		// {@squirreljme.error BD11 Unsigned short value out of range.}
		if (__v < 0 || __v > 65535)
			throw new IOException("BD11");
		
		writeShort(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/10
	 */
	@Override
	public final void writeUTF(String __s)
		throws IOException
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/GettableEndianess.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This interface is used for classes which can get their endianess obtained.
 *
 * @since 2016/08/11
 */
public interface GettableEndianess
{
	/**
	 * Obtains the current default endianess of the data.
	 *
	 * @return The current endianess.
	 * @since 2016/07/10
	 */
	public abstract DataEndianess getEndianess();
}

Deleted runt/libs/io/net/multiphasicapps/io/HexDumpOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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





























































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.Closeable;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Writer;

/**
 * This contains a stream which when given bytes hexadecimal bytes will
 * output to the given stream.
 *
 * Closing this stream does not close the dumping stream, it only closes the
 * piped stream if one is used.
 *
 * @since 2016/08/12
 */
public class HexDumpOutputStream
	extends OutputStream
{
	/** The number of columns to print. */
	private static final int _COLUMNS =
		16;
	
	/** Where to pipe data to. */
	protected final OutputStream pipe;
	
	/** Where to write characters to. */
	protected final Writer dump;
	
	/** The write queue. */
	private final byte[] _queue =
		new byte[_COLUMNS];
	
	/** The current write position. */
	private volatile int _at;
	
	/**
	 * Initializes dumping to the given stream.
	 *
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(PrintStream __dump)
		throws NullPointerException
	{
		this(new PrintStreamWriter(__dump));
	}
	
	/**
	 * Initializes dumping to the given stream.
	 *
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(Writer __dump)
		throws NullPointerException
	{
		// Check
		if (__dump == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.pipe = null;
		this.dump = __dump;
	}
	
	/**
	 * Initializes dumping to the given stream and also copying them to
	 * another stream to act as a pipe.
	 *
	 * @param __pipe The stream to copy bytes to.
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(OutputStream __pipe, PrintStream __dump)
		throws NullPointerException
	{
		this(__pipe, new PrintStreamWriter(__dump));
	}
	
	/**
	 * Initializes dumping to the given stream and also copying them to
	 * another stream to act as a pipe.
	 *
	 * @param __pipe The stream to copy bytes to.
	 * @param __dump The stream to dump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/12
	 */
	public HexDumpOutputStream(OutputStream __pipe, Writer __dump)
		throws NullPointerException
	{
		// Check
		if (__pipe == null || __dump == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.pipe = __pipe;
		this.dump = __dump;
	}
	
	/**
	 * {@inheritDoc}
	 *
	 * The stream to dump to is not closed.
	 *
	 * @since 2016/08/12
	 */
	@Override
	public void close()
		throws IOException
	{
		// Force printing of bytes
		__printLine();
		
		// Only close the pipe and not the dump
		Closeable c = this.pipe;
		if (c != null)
			c.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void flush()
		throws IOException
	{
		// Flush the forward pipe
		this.pipe.flush();
		
		// And the dump
		this.dump.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(int __b)
		throws IOException
	{
		// Write a single byte
		int cols = _COLUMNS;
		byte b = (byte)__b;
		byte[] queue = this._queue;
		int at = this._at;
		try
		{
			// Write to the queue
			queue[at++] = b;
			this._at = at;
			
			// Send to the output
			OutputStream pipe = this.pipe;
			if (pipe != null)
				pipe.write(__b);
		}
		
		// Check if a row is to be printed
		finally
		{
			// Print entire row
			if (at == cols)
				__printLine();
		}
	}
	
	/**
	 * Prints a hexdumpped line.
	 *
	 * @throws IOException If it could not be written.
	 * @since 2016/08/12
	 */
	private void __printLine()
		throws IOException
	{
		// Might not always work
		int cols = _COLUMNS;
		byte[] queue = this._queue;
		int at = this._at;
		try
		{
			Writer w = this.dump;
			
			// Print starting hex data
			for (int i = 0; i < cols; i++)
			{
				// Padding
				if (i > 0)
				{
					w.write(' ');
				
					// Extra space?
					if ((i & 3) == 0)
						w.write(' ');
				}
				
				// No data?
				if (i >= at)
				{
					w.write("  ");
					continue;
				}
				
				// Write both bytes
				int x = queue[i] & 0xFF;
				w.write(Character.forDigit(((x >>> 4) & 0xF), 16));
				w.write(Character.forDigit((x & 0xF), 16));
			}
			
			// Print ASCII version of it
			w.write("  |");
			for (int i = 0; i < cols; i++)
			{
				// No data?
				if (i >= at)
					break;	
				
				// Only print in the range of ASCII
				char c = (char)(queue[i] & 0xFF);
				if (c < ' ' || c > 0x7E)
					c = '.';
				
				w.write(c);
			}
			w.write('|');
			w.write('\n');
		}
	
		// Always clear the position
		finally
		{
			this._at = 0;
		}
	}
	
	/**
	 * Dumps the resulting input stream to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __in The stream to dump.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/021
	 */
	public static final boolean dump(PrintStream __dump, InputStream __in)
		throws NullPointerException
	{
		if (__dump == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Open dump output
		try (HexDumpOutputStream hdos = new HexDumpOutputStream(__dump))
		{
			byte[] buf = new byte[24];
			for (;;)
			{
				int rc = __in.read(buf);
				
				if (rc < 0)
					break;
				
				hdos.write(buf, 0, rc);
			}
		}
		
		// Failed
		catch (IOException e)
		{
			return false;
		}
		
		// Okay
		return true;
	}
	
	/**
	 * Dumps the resulting byte array to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __b The byte array to dump.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/26
	 */
	public static final boolean dump(PrintStream __dump, byte[] __b)
		throws NullPointerException
	{
		if (__dump == null || __b == null)
			throw new NullPointerException("NARG");
		
		return HexDumpOutputStream.dump(__dump, __b, 0, __b.length);
	}	
	
	/**
	 * Dumps the resulting byte array to the given stream.
	 *
	 * @param __dump The target stream.
	 * @param __b The byte array to dump.
	 * @param __o The offset.
	 * @param __l The length.
	 * @return If the dump completed without an {@link IOException}.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/26
	 */
	public static final boolean dump(PrintStream __dump, byte[] __b, int __o,
		int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__dump == null || __b == null)
			throw new NullPointerException("NARG");
		
		// Open dump output
		try (HexDumpOutputStream hdos = new HexDumpOutputStream(__dump))
		{
			hdos.write(__b, __o, __l);
		}
		
		// Failed
		catch (IOException e)
		{
			return false;
		}
		
		// Okay
		return true;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/HexInputStream.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
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












































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;

/**
 * This reads a stream of hexadecimal characters and converts it to a binary
 * input.
 *
 * @since 2016/05/15
 */
public class HexInputStream
	extends InputStream
{
	/** The source stream. */
	protected final Reader source;
	
	/** EOF? */
	private volatile boolean _eof;
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __s The source hex bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/15
	 */
	public HexInputStream(Reader __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set
		source = __s;
	}
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __is The source hex bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/25
	 */
	public HexInputStream(InputStream __is)
		throws NullPointerException
	{
		this(new InputStreamReader(__is));
	}
	
	/**
	 * Initializes the hex based input stream.
	 *
	 * @param __is The source hex bytes.
	 * @param __cs The character set used.
	 * @throws IOException If the character set is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/25
	 */
	public HexInputStream(InputStream __is, String __cs)
		throws IOException, NullPointerException
	{
		this(new InputStreamReader(__is, __cs));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/15
	 */
	@Override
	public void close()
		throws IOException
	{
		// Always set EOF
		_eof = true;
		
		// Close it
		source.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/15
	 */
	@Override
	public int read()
		throws IOException
	{
		// EOF?
		if (_eof)
			return -1;
		
		// Read the high value
		int hi = -1;
		while (hi < 0)
		{
			// Read 
			int c = source.read();
			
			// EOF?
			if (c < 0)
				return -1;
			
			// Try a digit
			hi = Character.digit((char)c, 16);
		}
		
		// Read the low value
		int lo = -1;
		while (lo < 0)
		{
			// Read 
			int c = source.read();
			
			// EOF?
			if (c < 0)
				return -1;
			
			// Try a digit
			lo = Character.digit((char)c, 16);
		}
		
		// Merge together
		return (hi << 4) | lo;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/HuffmanTreeInt.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This represents a mutable huffman tree.
 * 
 * This class is not thread safe.
 *
 * Iteration of values goes through the internal value table in no particular
 * order. The iterator is fail-fast.
 *
 * {@squirreljme.error BD12 The huffman tree was modified in the middle of
 * iteration.}
 *
 * @param <int> The type of values to store in the tree.
 * @since 2016/03/10
 */
public class HuffmanTreeInt
{
	/** The huffman table. */
	private volatile int[] _table;
	
	/** Stored tree values. */
	private volatile int[] _values;
	
	/** Modification count. */
	private volatile int _modcount;
	
	/** Maximum used bits. */
	private volatile int _maxbits;
	
	/**
	 * Initializes a basic blank huffman tree.
	 *
	 * @since 2016/03/10
	 */
	public HuffmanTreeInt()
	{
		// Initially add table space so that it is always initially valid but
		// points to nothing.
		__addTableSpace();
	}
	
	/**
	 * Adds the specified object which is associated with the given symbol
	 * and mask.
	 *
	 * @param __v The value to add.
	 * @param __sym The bit representation of the symbol.
	 * @param __mask The mask of the symbol for its valid bits.
	 * @return The old value, or {@code null} if it is not set.
	 * @throws IllegalArgumentException If the specified symbol contains a bit
	 * which is outside of the mask or the mask does not start at shift zero
	 * or has zero gaps.
	 * @since 2016/03/28
	 */
	public final int add(int __v, int __sym, int __mask)
		throws IllegalArgumentException
	{
		// Number of bits in the mask
		int ibm = Integer.bitCount(__mask);
		
		// Check mask and representation
		// {@squirreljme.error BD13 The symbol exceeds the range of the mask.
		// (The value; The mask)}
		if ((__sym & (~__mask)) != 0)
			throw new IllegalArgumentException(String.format("BD13 %x %x",
				__sym, __mask));
		// {@squirreljme.error BD14 The mask has a zero gap between bits or
		// at the least significant end. (The value; The mask)}
		if (ibm != (32 - Integer.numberOfLeadingZeros(__mask)) ||
			(__mask & 1) == 0)
			throw new IllegalArgumentException(String.format("BD14 %x %x",
				__sym, __mask));
		
		// Get the table
		int[] table = _table;
		int n = table.length;
		
		// Increase max bit count
		_maxbits = Math.max(_maxbits, ibm);
		
		// Find the spot to add it based on the bit depth
		int at = 0;
		for (int sh = (1 << (ibm - 1)); sh != 0; sh >>>= 1)
		{
			// Last bit set?
			boolean last = (sh == 1);
			
			// The array index to look at for the current position depends
			// on which bit is set
			int q = (((__sym & sh) != 0) ? 1 : 0);
			
			// Get the jump value
			int jump = table[at + q];
			
			// If this points to a constant area but this is not the last
			// bit, then trash it.
			if (!last && jump < 0)
			{
				jump = Integer.MAX_VALUE;
				table[at + q] = jump;
			}
			
			// Jumps off the table end? Needs more values to be added for
			// the tree to be built
			if (jump == Integer.MAX_VALUE)
			{
				// If this is the last entry then a value index needs to
				// be created to store the value
				if (last)
				{
					// Add space for a new variable
					int vat = __addValueSpace();
					
					// Place value there
					_values[vat] = __v;
					
					// Set table index to point there
					table[at + q] = -(vat + 1);
					
					// Modified
					_modcount++;
					
					// No old value exists
					return 0;
				}
				
				// Otherwise, add some table space and jump to that
				// instead on the next run.
				else
				{
					// Add new location info
					int jat = __addTableSpace();
				
					// Correct vars
					table = _table;
					n = table.length;
				
					// Set jump to that position
					// Use that position instead on the next read
					table[at + q] = at = jat;
				}
			}
			
			// Points to a constant area, return a value
			else if (jump < 0)
			{
				// Calculate actual placement
				int vat = (-jump) - 1;
				
				// Get old value
				int[] vals = _values;
				int old = vals[vat];
				
				// Set new value
				vals[vat] = __v;
				
				// Modified
				_modcount++;
				
				// Return the old value
				return old;
			}
			
			// Points to another location in the array
			else
				at = jump;
		}
		
		// Should not occur
		throw new todo.OOPS();
	}
	
	/**
	 * Clears the huffman tree.
	 *
	 * @since 2017/02/25
	 */
	public void clear()
	{
		// Reset parameters
		this._table = null;
		this._values = null;
		this._modcount = 0;
		this._maxbits = 0;
		
		// Setup initial tree
		__addTableSpace();
	}
	
	/**
	 * Finds the bit sequence associated with the given value.
	 *
	 * @param __i The value to find the sequence for the given bit pattern.
	 * @return A {@code long} where the upper 32-bits is the bit mask while
	 * the lower 32-bits are the symbol.
	 * @throws NoSuchElementException If no sequence was found.
	 * @since 2016/08/24
	 */
	public final long findSequence(int __i)
		throws NoSuchElementException
	{
		// Get values
		int[] vals = this._values;
		
		// No values? nothing will ever be found
		if (vals == null)
			throw new NoSuchElementException("NSEE");
		
		// Look through all values
		int n = vals.length;
		for (int i = 0; i < n; i++)
			if (vals[i] == __i)
				return __recursiveMatch(0, 0, 0, -(i + 1));
		
		// Not found
		throw new NoSuchElementException("NSEE");
	}
	
	/**
	 * Returns the value obtained via the given bit source.
	 *
	 * @param __bs The source for bits.
	 * @return The value.
	 * @thorws IOException On read errors.
	 * @throws NoSuchElementException If no value was found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/16
	 */
	public final int getValue(BitSource __bs)
		throws IOException, NoSuchElementException, NullPointerException
	{
		// Check
		if (__bs == null)
			throw new NullPointerException("NARG");
		
		// Get the jump table
		int[] table = this._table;
		if (table == null)
			throw new NoSuchElementException("NSEE");
		
		// Try to find a value
		for (int at = 0;;)
		{
			// A value has been read?
			if (at < 0)
				return this._values[(-at) - 1];
			
			// {@squirreljme.error BD15 Key not found in tree.}
			else if (at == Integer.MAX_VALUE)
				throw new NoSuchElementException("BD15");
			
			// Set the new position to the table position
			at = table[at + (__bs.nextBit() ? 1 : 0)];
		}
	}
	
	/**
	 * Returns the maximum number of bits entries use.
	 *
	 * @return The maximum number of used bits.
	 * @since 2016/03/28
	 */
	public final int maximumBits()
	{
		return _maxbits;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/10
	 */
	@Override
	public final String toString()
	{
		// Setup
		StringBuilder sb = new StringBuilder("[");
		
		// Add elements in no particular order
		int[] vals = _values;
		if (vals != null)
		{
			int n = vals.length;
			for (int i = 0; i < n; i++)
			{
				// Comma?
				if (i > 0)
					sb.append(", ");
				
				// Begin sequence data
				sb.append('<');
				
				// Get the sequence of it
				int v = vals[i];
				int seq = -1;
				
				// Not found?
				if (seq == -1L)
					sb.append('?');
				
				// Print bit pattern otherwise
				else
				{
					// Get mask and value
					int msk = (int)(seq >>> 32L);
					int val = (int)(seq);
					
					// Start from the highest bit first
					int hib = Integer.bitCount(msk);
					for (int b = hib - 1; b >= 0; b--)
						sb.append(((0 == (val & (1 << b))) ? '0' : '1'));
				}
				
				// End sequence data
				sb.append(">=");
				
				// Add the value
				sb.append(v);
			}
		}
		
		// Build it
		sb.append(']');
		return sb.toString();
	}
	
	/**
	 * Adds more table space for a branch.
	 *
	 * @return The base index of the newly added space.
	 * @since 2016/03/28
	 */
	private int __addTableSpace()
	{
		// The returned value is the end of the table
		int[] table = _table;
		int rv = (table == null ? 0 : table.length);
		
		// Allocate some extra space
		int[] becomes = new int[rv + 2];
		
		// Copy the old array over
		for (int i = 0; i < rv; i++)
			becomes[i] = table[i];
		
		// The end bits become invalidated
		becomes[rv] = Integer.MAX_VALUE;
		becomes[rv + 1] = Integer.MAX_VALUE;
		
		// Set new table
		_table = becomes;
		
		// Return it
		return rv;
	}
	
	/**
	 * Adds more value space to add a new value.
	 *
	 * @return The index where the value space was increased.
	 * @since 2016/03/28
	 */
	private int __addValueSpace()
	{
		// The returned value is the end of the table
		int[] values = _values;
		int rv = (values == null ? 0 : values.length);
		
		// Allocate some extra space
		int[] becomes = new int[rv + 1];
		
		// Copy the old array over
		for (int i = 0; i < rv; i++)
			becomes[i] = values[i];
		
		// Set new table
		_values = becomes;
		
		// Return it
		return rv;
	}
	
	/**
	 * Searches the huffman tree for the given raw match value.
	 *
	 * @param __at The index to look at.
	 * @param __huf The huffman index.
	 * @param __mask The mask of the input value.
	 * @param __match The value to match.
	 * @return The bit mask and the value for the given entry or {@code -1L} if
	 * not found.
	 * @since 2016/03/28
	 */
	private long __recursiveMatch(int __at, int __huf, int __mask, int __match)
	{
		// Get tree
		int[] table = _table;
		
		// Get the left and right side jump values
		int jl = table[__at];
		int jr = table[__at + 1];
		
		// Matches left or right side?
		boolean left = (jl == __match);
		if (left || jr == __match)
			return (((long)((__mask << 1) | 1)) << 32L) |
				((long)((__huf << 1) | (left ? 0 : 1)));
		
		// Traverse left side
		long rv;
		if (jl >= 0 && jl != Integer.MAX_VALUE)
		{
			rv = __recursiveMatch(jl, __huf << 1, (__mask << 1) | 1,
				__match);
			if (rv != -1L)
				return rv;
		}
		
		// Traverse right side
		if (jr >= 0 && jr != Integer.MAX_VALUE)
		{
			rv = __recursiveMatch(jr, (__huf << 1) | 1, (__mask << 1) | 1,
				__match);
			if (rv != 1L)
				return rv;
		}
		
		// Not found
		return -1L;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/IndentedOutputStream.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which is able to be indented on each new line.
 *
 * This class cannot handle indentation characters which are beyond the
 * standard ASCII range.
 *
 * @since 2018/05/14
 */
public final class IndentedOutputStream
	extends OutputStream
{
	/** The output stream to write to. */
	protected final OutputStream out;
	
	/** The indentation character. */
	private char _char;
	
	/** The indentation level. */
	private int _level;
	
	/** On a new line? */
	private boolean _newline =
		true;
	
	/**
	 * Initializes the indented output stream using tab as the indentation
	 * character.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public IndentedOutputStream(OutputStream __out)
		throws NullPointerException
	{
		this(__out, '\t');
	}
	
	/**
	 * Initializes the indented output stream.
	 *
	 * @param __out The stream to write to.
	 * @param __c The character to indent with.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public IndentedOutputStream(OutputStream __out, char __c)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
		this._char = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.out.close();
	}
	
	/**
	 * Decrements the indentation level.
	 *
	 * @since 2018/05/14
	 */
	public final void decrement()
	{
		int level = this._level;
		if (level > 0)
			this._level = level - 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void flush()
		throws IOException
	{
		this.out.flush();
	}
	
	/**
	 * Increments the indentation level.
	 *
	 * @since 2018/05/14
	 */
	public final void increment()
	{
		int level = this._level;
		if (level < Integer.MAX_VALUE)
			this._level = level + 1;
	}
	
	/**
	 * Sets the level of indentation.
	 *
	 * @param __i The indentation level.
	 * @throws IllegalArgumentException If the level is negative.
	 * @since 2018/05/14
	 */
	public final void setLevel(int __i)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD16 Cannot set the indentation level to a
		// negative value.}
		if (__i < 0)
			throw new IllegalArgumentException("BD16");
		
		this._level = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		OutputStream out = this.out;
		
		// New-line will set the newline flag
		int actb = (__b & 0xFF);
		if (actb == '\r' || actb == '\n')
			this._newline = true;
		
		// Every other character will indent, if on a newline
		else if (this._newline)
		{
			// Clear flag to not indent again
			this._newline = false;
			
			// Indent using the given character
			char indentchar = this._char;
			for (int i = 0, n = this._level; i < n; i++)
				out.write(indentchar);
		}
		
		// Forward always, but use the original input
		out.write(__b);
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/InflaterInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.NoSuchElementException;

/**
 * This is used to decompress standard deflate compressed stream.
 *
 * Associated standards:
 * {@link https://www.ietf.org/rfc/rfc1951.txt}.
 *
 * This class is not thread safe.
 *
 * @since 2017/02/24
 */
public class InflaterInputStream
	extends DecompressionInputStream
{
	/** The size of the sliding window. */
	private static final int _DEFAULT_SLIDING_WINDOW_SIZE =
		32768;
	
	/** No compression. */
	static final int _TYPE_NO_COMPRESSION =
		0b00;
	
	/** Fixed huffman table compression. */
	static final int _TYPE_FIXED_HUFFMAN =
		0b01;
	
	/** Dynamic huffman table compression. */
	static final int _TYPE_DYNAMIC_HUFFMAN =
		0b10;
	
	/** An error. */
	static final int _TYPE_ERROR =
		0b11;
	
	/** The maximum number of bits in the code length tree. */
	private static final int _MAX_BITS =
		15;
	
	/** Shuffled bit values when reading values. */
	private static final int[] _SHUFFLE_BITS =
		new int[]
		{
			16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
		};
	
	/** The deflated compressed stream to be decompressed. */
	protected final InputStream in;
	
	/** Sliding window for accessing old bytes. */
	protected final SlidingByteWindow window;
	
	/** If the output cannot be filled, bytes are written here instead. */
	protected final ByteDeque overflow =
		new ByteDeque();
	
	/** When bytes are read, a checkum will be calculated for it, optional. */
	protected final Checksum checksum;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** The read-in buffer which is used to bulk read input bytes. */
	private final byte[] _readin =
		new byte[4];
	
	/** The bit source for reading. */
	private final BitSource _bitsource =
		new __BitSource__();
	
	/**
	 * Raw code lengths (allocated once), the size is the max code length
	 * count.
	 */
	private final int[] _rawcodelens =
		new int[19];
	
	/**
	 * Raw literal and distances (allocated once), the size is the total of
	 * both the maximum length count and distance count.
	 */
	private final int[] _rawlitdistlens =
		new int[322];
	
	/** Used to store bit length counts. */
	private final int[] _blcount =
		new int[_MAX_BITS + 1];
	
	/** Used to store the next code. */
	private final int[] _nextcode =
		new int[_MAX_BITS + 1];
	
	/** The number of compressed bytes. */
	private long _compressedsize;
	
	/** The number of uncompressed bytes. */
	private long _uncompressedsize;
	
	/** The code length tree. */
	private Reference<HuffmanTreeInt> _codelentree;
	
	/** The literal tree. */
	private Reference<HuffmanTreeInt> _literaltree;
	
	/** The distance tree. */
	private Reference<HuffmanTreeInt> _distancetree;
	
	/** Window reader. */
	private Reference<byte[]> _readwindow;
	
	/**
	 * The miniature read window, it stores a 32-bit value and is given input
	 * bytes to read along with being used as output. This is an int because it
	 * is faster to work with integer values rather than bytes. It also means
	 * that it is much simpler to work with.
	 */
	private int _miniwindow;
	
	/** Represents the number of bits in the mini window. */
	private int _minisize;
	
	/** The output write window, this is used to shift out writes as needed. */
	private int _writewindow;
	
	/** The number of bits in the write window. */
	private int _writesize;
	
	/** EOF has been reached? */
	private boolean _eof;
	
	/** The target byte array for writes. */
	private byte[] _targ;
	
	/** The target offset for writes. */
	private int _targoff;
	
	/** The target end offset for writes. */
	private int _targend;
	
	/**
	 * Initializes the deflate compression stream inflater.
	 *
	 * @param __in The stream to inflate.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/24
	 */
	public InflaterInputStream(InputStream __in)
		throws NullPointerException
	{
		this(__in, _DEFAULT_SLIDING_WINDOW_SIZE);
	}
	
	/**
	 * Initializes the deflate compression stream inflater, an optional
	 * checksum calculator may be specified also.
	 *
	 * @param __in The stream to inflate.
	 * @param __cs
	 * @throws NullPointerException On null arguments, except for {@code __cs}.
	 * @since 2017/02/24
	 */
	public InflaterInputStream(InputStream __in, Checksum __cs)
		throws NullPointerException
	{
		this(__in, _DEFAULT_SLIDING_WINDOW_SIZE, __cs);
	}
	
	/**
	 * Initializes the deflate compression stream inflater with a custom
	 * size specified for the sliding window.
	 *
	 * @param __in The stream to inflate.
	 * @param __sls Custom size to the sliding window.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/04
	 */
	public InflaterInputStream(InputStream __in, int __sls)
	{
		this(__in, __sls, null);
	}
	
	/**
	 * Initializes the deflate compression stream inflater with a custom
	 * size specified for the sliding window, an optional checksum calculator
	 * may be specified also.
	 *
	 * @param __in The stream to inflate.
	 * @param __sls Custom size to the sliding window.
	 * @param __checksum If not {@code null} then when bytes are read from this
	 * stream they will have their checksum calculated. The checksum is
	 * calculated on the uncompressed bytes.
	 * @throws NullPointerException On null arguments, except for
	 * {@code __checksum}.
	 * @since 2017/08/22
	 */
	public InflaterInputStream(InputStream __in, int __sls,
		Checksum __checksum)
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __in;
		this.window = new SlidingByteWindow(__sls);
		this.checksum = __checksum;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int available()
		throws IOException
	{
		// Use the number of bytes that are able to be read quickly without
		// requiring decompression
		return this.overflow.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public void close()
		throws IOException
	{
		// Close input
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		return this._compressedsize;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/24
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int bl = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > bl)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// If there are bytes in the overflow buffer, read them first into the
		// output because they are the result of previous decompression.
		ByteDeque overflow = this.overflow;
		int ovn = overflow.available(),
			ovr = (ovn < __l ? ovn : __l);
		int c = overflow.removeFirst(__b, __o, __l);
		
		// More bytes can be read from the input compressed data because the
		// overflow buffer has been emptied
		boolean eof = this._eof;
		if (!eof && c < __l)
		{
			// Store write information
			this._targ = __b;
		
			// Try to fit as many bytes as possible into the output
			while (c < __l)
			{
				// Decompress
				int base;
				this._targoff = (base = __o + c);
				this._targend = base + (__l - c);
				int rv = __decompress();
			
				// Ended?
				if (rv < 0)
				{
					this._eof = true;
					break;
				}
			
				// Otherwise add those bytes
				c += rv;
			}
		}
		
		// Calculate CRC for this output data
		Checksum checksum = this.checksum;
		if (checksum != null)
			checksum.offer(__b, __o, c);
		
		// Count uncompressed size
		if (c > 0)
			this._uncompressedsize += c;
		
		// Return the read count or end of file if the end of the stream has
		// been reached
		// But never leave bytes waiting in the overflow buffer ever
		return (c == 0 && eof && overflow.isEmpty() ? -1 : c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._uncompressedsize;
	}
	
	/**
	 * Reads the input and performs decompression on the data.
	 *
	 * @return The number of stored bytes or a negative value if the stream
	 * has terminated.
	 * @throws IOException On read or decompression errors.
	 * @since 2017/02/25
	 */
	private int __decompress()
		throws IOException
	{
		// Do nothing on EOF
		if (this._eof)
			return -1;
		
		// The target offset on entry
		int enteroff = this._targoff;
		
		// Read the final bit which determines if this is the last block
		int finalhit = __readBits(1, false);
		
		// Read the window type
		int type = __readBits(2, false);
		switch (type)
		{
				// None
			case _TYPE_NO_COMPRESSION:
				__decompressNone();
				break;
				
				// Fixed huffman
			case _TYPE_FIXED_HUFFMAN:
				__decompressFixed();
				break;
				
				// Dynamic huffman
			case _TYPE_DYNAMIC_HUFFMAN:
				__decompressDynamic();
				break;
			
				// Error or unknown
			case _TYPE_ERROR:
			default:
				// {@squirreljme.error BD17 Unknown type or the error type
				// was reached. (The type code used in the stream)}
				throw new IOException(String.format("BD17 %d", type));
		}
		
		// If this was the last block to read, then return EOF if no data
		// was actually read, but mark EOF otherwise
		int rv = (this._targoff - enteroff);
		if (finalhit != 0)
		{
			this._eof = true;
			return (rv == 0 ? -1 : rv);
		}
		
		// Just the read count
		else
			return rv;
	}
	
	/**
	 * Decompress dynamic huffman code.
	 *
	 * @throws On read or decompression errors.
	 * @since 2017/02/25
	 */
	private void __decompressDynamic()
		throws IOException
	{
		// Read the code length parameters
		int dhlit = __readBits(5, false) + 257;
		int dhdist = __readBits(5, false) + 1;
		int dhclen = __readBits(4, false) + 4;
		
		// Read the code length tree
		HuffmanTreeInt codelentree = __decompressDynamicLoadLenTree(dhclen);
		
		// Read the literal and distance trees
		HuffmanTreeInt literaltree = __obtainLiteralTree(),
			distancetree = __obtainDistanceTree();
		__decompressDynamicLoadLitDistTree(codelentree, dhlit, dhdist,
			literaltree, distancetree);
		
		// Decode input
		for (;;)
		{
			// Read code
			int code = literaltree.getValue(this._bitsource);
			
			// Literal byte value
			if (code >= 0 && code <= 255)
				__write(code, 8, false);
		
			// Stop processing
			else if (code == 256)
				return;
		
			// Window based result
			else if (code >= 257 && code <= 285)
				__decompressWindow(__handleLength(code),
					distancetree.getValue(this._bitsource));
			
			// {@squirreljme.error BD18 Illegal dynamic huffman code. (The
			// code.)}
			else
				throw new IOException(String.format("BD18 %d", code));
		}
	}
	
	/**
	 * Reads the literal and distance trees.
	 *
	 * @param __cltree The code length tree.
	 * @param __dhlit The literal count.
	 * @param __dhdist The distance count.
	 * @param __ltree The literal tree.
	 * @param __dtree The distance tree.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressDynamicLoadLitDistTree(HuffmanTreeInt __cltree,
		int __dhlit, int __dhdist, HuffmanTreeInt __ltree,
		HuffmanTreeInt __dtree)
		throws IOException
	{
		// Determine the maximum bit count that is used when reading values
		int total = __dhlit + __dhdist;
		
		// Cached, erase the data because later reads may have less
		int[] rawlitdistlens = this._rawlitdistlens;
		for (int i = 0, n = rawlitdistlens.length; i < n; i++)
			rawlitdistlens[i] = 0;
		
		// Read every code
		try
		{
			for (int next = 0; next < total;)
				next += __readCodeBits(__cltree, rawlitdistlens, next);
		}

		// {@squirreljme.error BD19 The compressed stream is
		// damaged by being too short or having an illegal tree
		// access.}				
		catch (NoSuchElementException e)
		{
			throw new IOException("BD19", e);
		}
		
		// Initialize both trees
		__thunkCodeLengthTree(__ltree, rawlitdistlens, 0, __dhlit);
		__thunkCodeLengthTree(__dtree, rawlitdistlens, __dhlit, __dhdist);
	}
	
	/**
	 * Reads the code length tree.
	 *
	 * @param __dhclen The code length size.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private HuffmanTreeInt __decompressDynamicLoadLenTree(int __dhclen)
		throws IOException
	{
		// Target tree
		HuffmanTreeInt codelentree = __obtainCodeLenTree();
		
		// {@squirreljme.error BD1a There may only be at most 19 used
		// code lengths. (The number of code lengths)}
		if (__dhclen > 19)
			throw new IOException(String.format("BD1a %d", __dhclen));
		
		// The same array is used for reading code lengths but the next time
		// around it is possible that less code lengths are read, so if the
		// higher elements have previously been set they will be used
		int[] rawcodelens = this._rawcodelens;
		for (int i = 0, n = rawcodelens.length; i < n; i++)
			rawcodelens[i] = 0;
		
		// Read lengths, they are just 3 bits but their placement values are
		// shuffled since some sequences are more common than others
		int[] hsbits = _SHUFFLE_BITS;
		for (int next = 0; next < __dhclen; next++)
			rawcodelens[hsbits[next]] = __readBits(3, false);
		
		// Thunk the tree and return it
		return __thunkCodeLengthTree(codelentree, rawcodelens, 0,
			rawcodelens.length);
	}
	
	/**
	 * Decodes decompressed data stored with the fixed huffman table and
	 * decompresses it.
	 *
	 * @throws IOException On read or decompression errors.
	 * @since 2017/02/25
	 */
	private void __decompressFixed()
		throws IOException
	{
		// Read until the sequence has ended
		for (;;)
		{
			// Read code
			int code = __readFixedHuffman();
				
			// Literal byte value
			if (code >= 0 && code <= 255)
				__write(code, 8, false);
		
			// Stop processing
			else if (code == 256)
				return;
		
			// Window based result
			else if (code >= 257 && code <= 285)
				__decompressWindow(__handleLength(code), Integer.MIN_VALUE);
		
			// {@squirreljme.error BD1b Illegal fixed huffman code. (The
			// code.)}
			else
				throw new IOException(String.format("BD1b %d", code));
		}
	}
	
	/**
	 * Decompresses uncompressed data.
	 *
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressNone()
		throws IOException
	{
		// Throw out bits that have been read so that the following reads are
		// aligned to byte boundaries
		int minisub = this._minisize & 7;
		if (minisub > 0)
			__readBits(minisub, false);
		
		// Read length and the one's complement of it
		int len = __readBits(16, false);
		int com = __readBits(16, false);
		
		// The complemented length must be equal to the complement
		// {@squirreljme.error BD1c Value mismatch reading the number of
		// uncompressed symbols that exist. (The length; The complement;
		// The complemented input length; The complemented input complement)}
		if ((len ^ 0xFFFF) != com)
			throw new IOException(String.format("BD1c %04x %04x %04x %04x",
				len, com, len ^ 0xFFFF, com ^ 0xFFFF));
		
		// Read all bytes
		for (int i = 0; i < len; i++)
			__write(__readBits(8, false), 8, false);
	}
	
	/**
	 * Handles decompressing window data.
	 *
	 * @param __len The length to read, must be prehandled.
	 * @param __dist The distance to read.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private void __decompressWindow(int __len, int __dist)
		throws IOException
	{
		// Handle distance
		__dist = __handleDistance(__dist);
	
		// Get the maximum valid length, so for example if the length
		// is 5 and the distance is two, then only read two bytes.
		int maxlen;
		if (__dist < __len)
			maxlen = __dist;
		else
			maxlen = __len;
		
		// Create a byte array from the sliding window data
		byte[] winb = new byte[maxlen];
		try
		{
			this.window.get(__dist, winb, 0, maxlen);
		}
	
		// Bad window read
		catch (IndexOutOfBoundsException ioobe)
		{
			// {@squirreljme.error BD1d Window access out of range.
			// (The distance; The length)}
			throw new IOException(String.format(
				"BD1d %d %d", __dist, __len), ioobe);
		}
	
		// Add those bytes to the output, handle wrapping around if the
		// length is greater than the current position
		for (int i = 0, v = 0; i < __len; i++)
		{
			// Write byte
			__write(winb[v], 8, false);
		
			// Wrap around
			if ((++v) >= maxlen)
				v = 0;
		}
	}
	
	/**
	 * Handles fixed huffman distance.
	 *
	 * @param __code The input code.
	 * @return The ditsance read.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	private int __handleDistance(int __code)
		throws IOException
	{
		// Read distance
		if (__code == Integer.MIN_VALUE)
			__code = __readBits(5, true);
		
		// {@squirreljme.error BD1e Illegal fixed distance code. (The distance
		// code)}
		if (__code > 29)
			throw new IOException(String.format("BD1e %d", __code));
		
		// Calculate the required distance to use
		int rv = 1;
		for (int i = 0; i < __code; i++)
		{
			// This uses a similar pattern to the length code, however the
			// division is half the size (so there are groups of 2 now).
			int v = ((i / 2) - 1);
			if (v >= 0)
				rv += (1 << v);
			else
				rv++;
		}
		
		// Determine the number of extra bits that make up the distance which
		// is used as an additional distance value
		int extrabits = ((__code / 2) - 1);
		if (extrabits > 0)
			rv += __readBits(extrabits, false);
		
		// Return it
		return rv;
	}
	
	/**
	 * Reads length codes from the input.
	 *
	 * @param __c Input code value.
	 * @throws IOException On read/write errors.
	 * @since 2016/03/12
	 */
	private int __handleLength(int __c)
		throws IOException
	{
		// The maximum length that can ever be used is 258, it has no bits also
		if (__c == 285)
			return 258;
		
		// Get the base code
		int base = __c - 257;
		
		// {@squirreljme.error BD1f Illegal length code. (The length code)}
		if (base < 0)
			throw new IOException(String.format("BD1f %d", __c));
		
		// Calculate the required length to use
		int rv = 3;
		for (int i = 0; i < base; i++)
		{
			// Determine how many groups of 4 the code is long. Since zero
			// appears as items then subtract 1 to make it longer. However
			// after the first 8 it goes up in a standard pattern.
			int v = ((i / 4) - 1);
			if (v > 0)
				rv += (1 << v);
			else
				rv++;
		}
		
		// Add extra bits which are used to modify the amount of data read
		int extrabits = (base / 4) - 1;
		if (extrabits > 0)
			rv += (extrabits = __readBits(extrabits, false));
		
		// Return the length
		return rv;
	}
	
	/**
	 * Obtains the code length tree.
	 *
	 * @return The code length tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainCodeLenTree()
	{
		Reference<HuffmanTreeInt> ref = this._codelentree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._codelentree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the distance tree.
	 *
	 * @return The distance tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainDistanceTree()
	{
		Reference<HuffmanTreeInt> ref = this._distancetree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._distancetree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the literal tree.
	 *
	 * @return The literal tree.
	 * @since 2017/02/27
	 */
	private HuffmanTreeInt __obtainLiteralTree()
	{
		Reference<HuffmanTreeInt> ref = this._literaltree;
		HuffmanTreeInt rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._literaltree = new WeakReference<>(
				(rv = new HuffmanTreeInt()));
		
		// Clear before return
		rv.clear();
		return rv;
	}
	
	/**
	 * Obtains the read window.
	 *
	 * @return The read window.
	 * @since 2017/02/26
	 */
	private byte[] __obtainReadWindow()
	{
		Reference<byte[]> ref = this._readwindow;
		byte[] rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._readwindow = new WeakReference<>(
				(rv = new byte[128]));
		
		return rv;
	}
	
	/**
	 * Reads bits from the input stream.
	 *
	 * @param __n The number of bits to read.
	 * @param __msb If {@code true} the most significant bits are first
	 * @return The read data.
	 * @throws IOException On read errors.
	 * @since 2017/02/25
	 */
	int __readBits(int __n, boolean __msb)
		throws IOException
	{
		// Nothing to read
		if (__n == 0)
			return 0;
		
		// Get the mini window information
		int miniwindow = this._miniwindow,
			minisize = this._minisize;
		
		// Not enough bits to read the value
		while (minisize < __n)
		{
			// The number of bytes to be read
			int bc = (__n - minisize) / 8;
			if (bc == 0)
				bc = 1;
			
			// Read input bytes
			byte[] readin = this._readin;
			int rc = this.in.read(readin, 0, bc);
			
			// {@squirreljme.error BD1g Reached EOF while reading bytes to
			// decompress. (Bits in the queue; Requested number of bits)}
			if (rc < 0)
				throw new IOException(String.format("BD1g %d %d", minisize,
					__n));
			
			// Shift in the read bytes to the higher positions
			for (int i = 0; i < rc; i++)
			{
				miniwindow |= ((readin[i] & 0xFF) << minisize);
				minisize += 8;
			}
			
			// Count the number of compressed bytes
			this._compressedsize += rc;
		}
		
		// Mask in the value, which is always at the lower bits
		int rv = miniwindow & ((1 << __n) - 1);
		
		// Shift down the mini window for the next read
		// Make sure the shift down is unsigned so that zeroes are in the
		// higher bits for the filling OR operation.
		miniwindow >>>= __n;
		minisize -= __n;
		
		// Store for next run
		this._miniwindow = miniwindow;
		this._minisize = minisize;
		
		// Want MSB to be first, need to swap all the bits so the lowest ones
		// are at the highest positions
		// Luckily such a method already exists and it could potentially be
		// inlined by the JVM or converted to native code if such an
		// instruction exists.
		if (__msb)
			return Integer.reverse(rv) >>> (32 - __n);
		
		// Return read result
		return rv;
	}
	
	/**
	 * Reads code bits using the given huffman tree and into the specified
	 * array.
	 *
	 * @param __codes The huffman tree which contains the length codes which
	 * the values being read are encoded with.
	 * @param __out The output array.
	 * @param __next The next value to read.
	 * @throws IOException On read or decompression errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/28
	 */
	private int __readCodeBits(HuffmanTreeInt __codes, int[] __out,
		int __next)
		throws IOException, NullPointerException
	{
		// Check
		if (__codes == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Read in code based on an input huffman tree
		int basenext = __next;
		int code = __codes.getValue(this._bitsource);
		
		// Literal length, the input is used
		if (code >= 0 && code < 16)
			__out[__next++] = code;
		
		// Repeating
		else
		{
			// Repeat this value and for this many lengths
			int repval;
			int repfor;
			
			// Repeat the previous length 3-6 times
			if (code == 16)
			{
				// {@squirreljme.error BD1h A repeat code was specified,
				// however this is the first entry. (The last length index)}
				int lastlendx = __next - 1;
				if (lastlendx < 0)
					throw new IOException(String.format("BD1h %d",
						lastlendx));
				
				// Read the last
				repval = __out[lastlendx];
				
				// Read the repeat count
				repfor = 3 + __readBits(2, false);
			}
			
			// Repeat zero for 3-10 times
			else if (code == 17)
			{
				// Use zero
				repval = 0;
				
				// Read 3 bits
				repfor = 3 + __readBits(3, false);
			}
			
			// Repeat zero for 11-138 times
			else if (code == 18)
			{
				// Use zero
				repval = 0;
				
				// Read 7 bits
				repfor = 11 + __readBits(7, false);
			}
			
			// {@squirreljme.error BD1i Illegal code. (The code)}
			else
				throw new IOException(String.format("BD1i %d", code));
			
			// Could fail
			try
			{
				// Place in repeated values
				for (int i = 0; i < repfor; i++)
					__out[__next++] = repval;
			}
			
			// Out of bounds entry
			catch (IndexOutOfBoundsException ioobe)
			{
				// {@squirreljme.error BD1j Out of bounds index read.}
				throw new IOException("BD1j", ioobe);
			}
		}
		
		// Skip count
		return __next - basenext;
	}
	
	/**
	 * Reads a fixed huffman code for use by the {@code _TYPE_FIXED_HUFFMAN}
	 * state. This method does not traverse a huffman tree so to speak, but it
	 * instead uses many if statements. Initially every consideration was made
	 * but now instead it uses ranges once it keeps deep enough into the tree.
	 * This method is faster and provides a built-in huffman tree while not
	 * taking up too many bytes in the byte code.
	 *
	 * @return The read value.
	 * @throws IOException On read errors.
	 * @since 2016/03/10
	 */
	private int __readFixedHuffman()
		throws IOException
	{
		// The long if statement block
		if (__readBits(1, true) != 0)
			if (__readBits(1, true) != 0)
				if (__readBits(1, true) != 0)
					return 192 + __readBits(6, true);
				else
					if (__readBits(1, true) != 0)
						return 160 + __readBits(5, true);
					else
						if (__readBits(1, true) != 0)
							return 144 + __readBits(4, true);
						else
							return 280 + __readBits(3, true);
			else
				return 80 + __readBits(6, true);
		else
			if (__readBits(1, true) != 0)
				return 16 + __readBits(6, true);
			else
				if (__readBits(1, true) != 0)
					if (__readBits(1, true) != 0)
						return 0 + __readBits(4, true);
					else
						return 272 + __readBits(3, true);
				else
					return 256 + __readBits(4, true);
	}
	
	/**
	 * Creates a huffman tree from the given code lengths. These generate
	 * symbols which are used to determine how the dynamic huffman data is to
	 * be decoded.
	 *
	 * @param __rv The tree to output.
	 * @param __lens The input code lengths.
	 * @param __o The starting offset.
	 * @param __l The number of lengths to decode.
	 * @return A huffman tree from the code length input.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/28
	 */
	private HuffmanTreeInt __thunkCodeLengthTree(HuffmanTreeInt __tree,
		int[] __lens, int __o, int __l)
		throws NullPointerException
	{
		// Check
		if (__lens == null)
			throw new NullPointerException("NARG");
		
		// Initialize both arrays with zero
		int[] bl_count = this._blcount;
		int[] next_code = this._nextcode;
		for (int i = 0, n = bl_count.length; i < n; i++)
		{
			bl_count[i] = 0;
			next_code[i] = 0;
		}
		
		// Determine the bitlength count for all of the inputs
		for (int i = 0, p = __o; i < __l; i++, p++)
			bl_count[__lens[p]]++;
		bl_count[0] = 0;
		
		// Find the numerical value of the smallest code for each code
		// length.
		int code = 0;
		for (int bits = 1; bits <= _MAX_BITS; bits++)
		{
			code = (code + bl_count[bits - 1]) << 1;
			next_code[bits] = code;
		}
	
		// Assign values to all codes
		__tree.clear();
		for (int q = 0, p = __o; q < __l; q++, p++)
		{
			// Get length
			int len = __lens[p];
		
			// Add code length to the huffman tree
			if (len != 0)
				__tree.add(q, (next_code[len])++, (1 << len) - 1);
		}
		
		// Return it
		return __tree;
	}
	
	/**
	 * Writes the specified value to the output.
	 *
	 * @param __v The value to write.
	 * @param __bits The number of bits to write.
	 * @param __msb Most significant bits first?
	 * @throws IOException On write errors.
	 * @since 2017/02/25
	 */
	private void __write(int __v, int __bits, boolean __msb)
		throws IOException
	{
		// Calculate the mask
		int mask = (1 << __bits) - 1;
		
		// Write LSB value, need to swap bits if writing MSB
		__v &= mask;
		if (__msb)
			__v = Integer.reverse(__v) >>> (32 - __bits);
		
		// Get the current write window
		int writewindow = this._writewindow,
			writesize = this._writesize;
		
		// Add bits to write
		writewindow |= (__v & mask) << writesize;
		writesize += __bits;
		
		// Enough bytes to write to the output?
		if (writesize >= 8)
		{
			// Write to a byte array first
			byte[] targ = this._targ;
			int targoff = this._targoff,
				targend = this._targend;
			
			// But if writes overflow then add to the overflow buffer
			ByteDeque overflow = this.overflow;
			
			// Any bytes written are appended to the sliding window
			SlidingByteWindow window = this.window;
			
			// Write bytes
			do
			{
				// Read input byte
				byte b = (byte)writewindow;
				writewindow >>>= 8;
				writesize -= 8;
				
				// Can fit in the output buffer
				if (targoff < targend)
					targ[targoff++] = b;
				
				// Overflows
				else
					overflow.offerLast(b);
				
				// Append to the window
				window.append(b);
			} while (writesize >= 8);
			
			// Store new position
			this._targoff = targoff;
		}
		
		// Store the write window info
		this._writewindow = writewindow;
		this._writesize = writesize;
	}
	
	/**
	 * Bit source for huffman reads.
	 *
	 * @since 2017/02/25
	 */
	private final class __BitSource__
		implements BitSource
	{
		/**
		 * {@inheritDoc}
		 * @since 2017/02/25
		 */
		@Override
		public boolean nextBit()
			throws IOException
		{
			return 0 != InflaterInputStream.this.__readBits(1, true);
		}
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/MIMEFileDecoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

























































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

/**
 * This class is used to decode input streams which have been encoded in the
 * MIME Base64 format. This file format is genearted by {@code uuencode -m}.
 * This format usually begins with {@code begin-base64 mode filename} and
 * ends with the padding sequence {@code ====}.
 *
 * This class is not thread safe.
 *
 * @since 2018/03/05
 */
public final class MIMEFileDecoder
	extends InputStream
{
	/** The input base64 data. */
	protected Base64Decoder mime;
	
	/** The read mode. */
	private int _mode =
		Integer.MIN_VALUE;
	
	/** The read filename. */
	private String _filename;
	
	/**
	 * Initializes the MIME file decoder using the default encoding.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in)
		throws NullPointerException
	{
		this(new InputStreamReader(__in));
	}
	
	/**
	 * Initializes the MIME file decoder using the given encoding.
	 *
	 * @param __in The input source.
	 * @param __enc The encoding used.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not supported.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(new InputStreamReader(__in, __enc));
	}
	
	/**
	 * Initializes the MIME file decoder from the given set of characters.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMEFileDecoder(Reader __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Directly wrap the reader with the MIME decoder which reads from
		// a source reader that is internally maintained
		this.mime = new Base64Decoder(new __SubReader__(__in));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		return this.mime.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.mime.close();
	}
	
	/**
	 * Returns the filename which was read.
	 *
	 * @return The read filename, {@code null} will be returned if it has not
	 * been read yet or has not been specified.
	 * @since 2018/03/05
	 */
	public final String filename()
	{
		return this._filename;
	}
	
	/**
	 * Returns the UNIX mode of the stream.
	 *
	 * @return The UNIX mode, a negative value will be returned if it has not
	 * been read yet.
	 * @since 2018/03/05
	 */
	public final int mode()
	{
		return this._mode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.mime.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.mime.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.mime.read(__b, __o, __l);
	}
	
	/**
	 * This is a sub-reader which handles parsing of the MIME header and
	 * otherwise just passing the data to the Base64Decoder instance.
	 *
	 * @since 2018/11/25
	 */
	private final class __SubReader__
		extends Reader
	{
		/** The line-by-line reader for data. */
		protected final BufferedReader in;
		
		/** The input character buffer. */
		private final StringBuilder _sb =
			new StringBuilder(80);
		
		/** The current read in the buffer. */
		private int _at;
		
		/** The current limit of the buffer. */
		private int _limit;
		
		/** Did we read the header? */
		private boolean _didheader;
		
		/** Did we read the footer? */
		private boolean _didfooter;
		
		/**
		 * Initializes the sub-reader for the MIME data.
		 *
		 * @param __in The source reader.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/24
		 */
		__SubReader__(Reader __in)
			throws NullPointerException
		{
			if (__in == null)
				throw new NullPointerException("NARG");
			
			this.in = new BufferedReader(__in, 80);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public void close()
			throws IOException
		{
			this.in.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read()
			throws IOException
		{
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Need to read more from the buffer
			int at = this._at,
				limit = this._limit;
			if (at >= limit)
			{
				// Read line next
				if (!this.__readNext())
					return -1;
				
				// Re-read
				at = this._at;
				limit = this._limit;
			}
			
			// Read the next character
			int rv = this._sb.charAt(at);
			this._at = at + 1;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			
			return this.read(__c, 0, __c.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c, int __o, int __l)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Where to read from
			StringBuilder sb = this._sb;
			int at = this._at,
				limit = this._limit;
			
			// Read in all characters
			int rv = 0;
			while (rv < __l)
			{
				// Need to read more?
				if (at >= limit)
				{
					// EOF?
					if (!this.__readNext())
						return (rv == 0 ? -1 : rv);
					
					// Re-read
					at = this._at;
					limit = this._limit;
				}
				
				// Read the next character
				__c[__o++] = sb.charAt(at++);
			}
			
			// Store new at position
			this._at = at;
			
			return rv;
		}
		
		/**
		 * Reads the header information.
		 *
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final void __readHeader()
			throws IOException
		{
			BufferedReader in = this.in;
			
			// {@squirreljme.error BD1k Unexpected end of file while trying
			// to read MIME header.}
			String ln = in.readLine();
			if (ln == null)
				throw new IOException("BD1k");
			
			// The header is in this format:
			// begin-base64 <unixmode> <filename>
			// {@squirreljme.error BD1l MIME encoded does not start with
			// MIME header.}
			if (!ln.startsWith("begin-base64"))
				throw new IOException("BD1l");
			
			// UNIX mode?
			int fs = ln.indexOf(' ');
			if (fs >= 0)
			{
				int ss = ln.indexOf(' ', fs + 1);
				
				// Decode octal mode bits
				MIMEFileDecoder.this._mode = Integer.parseInt(
					ln.substring(fs + 1, (ss < 0 ? ln.length() : ss)), 8);
				
				// Filename?
				if (ss >= 0)
					MIMEFileDecoder.this._filename =
						ln.substring(ss + 1);
			}
			
			// Set as read
			this._didheader = true;
		}
		
		/**
		 * Reads the next line into the character.
		 *
		 * @return If a line was read.
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final boolean __readNext()
			throws IOException
		{
			// {@squirreljme.error BD1m Unexpected EOF while read the MIME
			// file data.}
			String ln = this.in.readLine();
			if (ln == null)
				throw new IOException("BD1m");
			
			// End of MIME data?
			if (ln.equals("===="))
			{
				// Footer was read, so EOF now
				this._didfooter = true;
				
				// Was EOF
				return false;
			}
			
			// Fill buffer
			StringBuilder sb = this._sb;
			sb.setLength(0);
			sb.append(ln);
			
			// Set properties
			this._at = 0;
			this._limit = ln.length();
			
			// Was not EOF
			return true;
		}
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/NullOutputStream.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.io;

import java.io.OutputStream;

/**
 * This is an output stream which does nothing.
 *
 * @since 2019/06/30
 */
public final class NullOutputStream
	extends OutputStream
{
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void flush()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(int __b)
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(byte[] __b)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/PrintStreamWriter.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.Closeable;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Writer;

/**
 * This is a class which takes input characters and writes to the given
 * print stream.
 *
 * This class is thread safe.
 *
 * @since 2016/08/12
 */
public class PrintStreamWriter
	extends Writer
	implements Closeable
{
	/** The stream to write to. */
	protected final PrintStream output;
	
	/**
	 * Initializes the wrapped print stream writer.
	 *
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/12
	 */
	public PrintStreamWriter(PrintStream __ps)
		throws NullPointerException
	{
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = __ps;
	}
	
	/**
	 * Initializes the wrapped print stream writer and using the given lock.
	 *
	 * @param __lock The lock to use.
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/12
	 */
	public PrintStreamWriter(Object __lock, PrintStream __ps)
		throws NullPointerException
	{
		super(__lock);
		
		// Check
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.output = __ps;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void close()
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.close();
			__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void flush()
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.flush();
			__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(int __c)
		throws IOException
	{
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			output.print((char)__c);
			__checkError();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/12
	 */
	@Override
	public void write(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		int n = __c.length;
		int end = __o + __l;
		if (__o < 0 || __l < 0 || end > n)
			throw new IndexOutOfBoundsException("IOOB");
	
		// Lock
		PrintStream output = this.output;
		synchronized (this.lock)
		{
			// Print characters
			for (int i = __o; i < end; i++)
				output.print((char)__c[i]);
			
			// Check
			__checkError();
		}
	}
	
	/**
	 * Checks if the given stream has reported an error.
	 *
	 * @throws IOException If the stream has entered the error state.
	 * @since 2016/08/12
	 */
	private void __checkError()
		throws IOException
	{
		// {@squirreljme.error BD1n The underlying stream has entered the
		// error state.}
		if (this.output.checkError())
			throw new IOException("BD1n");
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/RandomAccessData.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
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





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This interface is used to describe classes which allow access to data via
 * a specific position.
 *
 * @since 2016/08/11
 */
public interface RandomAccessData
	extends GettableEndianess
{
	/**
	 * Reads multiple bytes.
	 *
	 * @param __p The position to read from.
	 * @param __b The byte array to place values at.
	 * @param __o The offset to read from.
	 * @param __l The number of bytes to read.
	 * @throws IndexOutOfBoundsException If the position is not within bounds;
	 * the offset and/or length are negative; or the offset and length exceed
	 * the array bounds.
	 * @since 2016/08/11
	 */
	public abstract void read(int __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a byte at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract int readByte(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a double at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract double readDouble(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a float at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract double readFloat(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an integer at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract int readInt(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a long at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract long readLong(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads a short at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract int readShort(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an unsigned byte at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract int readUnsignedByte(int __p)
		throws IndexOutOfBoundsException;
	
	/**
	 * Reads an unsigned short at the given position.
	 *
	 * @param __p The position to read from.
	 * @return The read value.
	 * @throws IndexOutOfBoundsException If the position is not within bounds.
	 * @since 2016/08/11
	 */
	public abstract int readUnsignedShort(int __p)
		throws IndexOutOfBoundsException;
}

Deleted runt/libs/io/net/multiphasicapps/io/SettableEndianess.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This is used by both data streams to indicate that they allow their default
 * endianess to be set and obtained.
 *
 * @since 2016/07/10
 */
public interface SettableEndianess
	extends GettableEndianess
{
	/**
	 * Sets the endianess of the data.
	 *
	 * @param __end The new default endianess to use.
	 * @return The old endianess.
	 * @throws NullPointerException If no endianess was specified.
	 * @since 2016/07/10
	 */
	public abstract DataEndianess setEndianess(DataEndianess __end)
		throws NullPointerException;
}

Deleted runt/libs/io/net/multiphasicapps/io/SizeLimitedInputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250


























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// For more information see license.mkd.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is an input stream in which the size of the input stream is maximally
 * bound to a given size or fixed to a specific size.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/09
 */
public class SizeLimitedInputStream
	extends InputStream
{
	/** The wrapped stream. */
	protected final InputStream wrapped;
	
	/** Exact size? */
	protected final boolean exact;
	
	/** The read limit. */
	protected final long limit;
	
	/** If {@code true} then close propogates to the wrapped stream. */
	protected final boolean propogate;
	
	/** The current read size. */
	private volatile long _current;
	
	/** Was this closed? */	
	private volatile boolean _closed;
	
	/**
	 * Initializes the size limited input stream. The close operation in this
	 * stream propogates to the wrapped stream.
	 *
	 * @param __is Input stream to wrap.
	 * @param __li The length of data to limit to.
	 * @param __ex If {@code true} then the stream must end at least at the
	 * limit and not before it, otherwise if {@code false} then it is only
	 * limited to either the limit or the number of bytes in the stream. If
	 * {@code true} then closing the stream will read the remaining number of
	 * bytes.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/09
	 */
	public SizeLimitedInputStream(InputStream __is, long __li, boolean __ex)
		throws IllegalArgumentException, NullPointerException
	{
		this(__is, __li, __ex, true);
	}
	
	/**
	 * Initializes the size limited input stream.
	 *
	 * @param __is Input stream to wrap.
	 * @param __li The length of data to limit to.
	 * @param __ex If {@code true} then the stream must end at least at the
	 * limit and not before it, otherwise if {@code false} then it is only
	 * limited to either the limit or the number of bytes in the stream. If
	 * {@code true} then closing the stream will read the remaining number of
	 * bytes.
	 * @param __prop If {@code true} then when this stream is closed, it will
	 * forward the close to the wrapped stream. Otherwise if {@code false}.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/08/28
	 */
	public SizeLimitedInputStream(InputStream __is, long __li, boolean __ex,
		boolean __prop)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BD1o The limit is negative. (The negative
		// limit)}
		if (__li < 0)
			throw new IllegalArgumentException(String.format("BD1o %d", __li));
		
		// Set
		this.wrapped = __is;
		this.limit = __li;
		this.exact = __ex;
		this.propogate = __prop;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public int available()
		throws IOException
	{
		// Get the count for the wrapped stream
		long wav = wrapped.available();
	
		// Either limited to the max integer size, the number of available
		// bytes, or the remaining stream count.
		return (int)Math.min(Integer.MAX_VALUE,
			Math.min(wav, (limit - _current)));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public void close()
		throws IOException
	{
		// Read in?
		if (!this._closed)
		{
			// Set
			this._closed = true;
			
			// Read in remaining bytes if doing so
			if (this.exact)
			{
				// {@squirreljme.error BD1p Reached EOF on wrapped stream when
				// requesting an exact number of bytes. (The current read
				// count; The read limit)}
				long limit = this.limit;
				long at;
				while ((at = this._current) < limit)
					if (read() < 0)
						throw new IOException(String.format("BD1p %d %d",
							at, limit));
			}
		}
		
		// Close the underlying stream, but only if propogating
		if (this.propogate)
			wrapped.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/09
	 */
	@Override
	public int read()
		throws IOException
	{
		// Current position
		long limit = this.limit;
		long cur = this._current;
		
		// Reached the limit?
		if (cur >= limit)
			return -1;
		
		// Read next byte
		int next = wrapped.read();
		
		// EOF?
		if (next < 0)
		{
			// {@squirreljme.error BD1q Required an exact number of bytes
			// however the limit was not yet reached, the input stream is too
			// short. (The limit; The current position)}
			if (exact && cur != limit)
				throw new IOException(String.format("BD1q %d %d",
					limit, cur));
			
			// Return original negative
			return next;
		}
		
		// Increase current location
		this._current = cur + 1L;
		
		// Return it
		return next;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/08/05
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// If the limit was reached, stop
		long current = this._current;
		long limit = this.limit;
		if (current >= limit)
		{
			// {@squirreljme.error BD1r Required an exact number of bytes
			// however the limit was not yet reached, the file is too short.
			// (The limit; The current position)}
			if (exact && current != limit)
				throw new IOException(String.format("BD1r %d %d",
					limit, current));
			
			return -1;
		}
		
		// Do not read more bytes after the limit
		int cc = (int)Math.min(limit - current, __l);
		
		// Read the next few bytes
		InputStream wrapped = this.wrapped;
		int rc = wrapped.read(__b, __o, cc);
		
		// EOF?
		if (rc < 0)
		{
			// {@squirreljme.error BD1s Required an exact number of bytes
			// however the limit was not yet reached. (The limit; The
			// current position)}
			if (exact && current != limit)
				throw new IOException(String.format("BD1s %d %d",
					limit, current));
			
			// Just EOF
			return -1;
		}
		
		// Set the new current
		this._current = current + rc;
		
		// Return the read count
		return rc;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/SizedStream.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This is used to obtain the number of bytes which were read from or written
 * to a given stream.
 *
 * @since 2016/07/10
 */
public interface SizedStream
{
	/**
	 * Returns the number of written or read bytes.
	 *
	 * @return The number of read or written bytes.
	 * @since 2016/07/10
	 */
	public abstract long size();
}

Deleted runt/libs/io/net/multiphasicapps/io/SlidingByteWindow.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

/**
 * This represents a sliding byte window.
 *
 * It is allocated in chunks of a given fragment size so that the entire window
 * is not allocated in its entirety until it is actually used.
 *
 * In the future this class may support a kind of compression so that older
 * bytes in the sliding window may be compacted when they are not used.
 *
 * This class is not thread safe.
 *
 * @since 2016/03/10
 */
public class SlidingByteWindow
{
	/** The backing byte buffer. */
	protected final ByteDeque deque;
	
	/** The window size. */
	protected final int windowsize;
	
	/** Single byte for forcing bulk operations. */
	private final byte[] _solo =
		new byte[1];
	
	/** The total number of written bytes. */
	private volatile int _total;
	
	/**
	 * This initializes the sliding byte window.
	 *
	 * @param __wsz The size of the sliding window.
	 * @since 2016/03/10
	 */
	public SlidingByteWindow(int __wsz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD1t Zero or negative window size specified.
		// (The window size)}
		if (__wsz <= 0)
			throw new IllegalArgumentException(String.format("BD1t %d",
				__wsz));
		
		// Set
		windowsize = __wsz;
		
		// Setup backing store
		deque = new ByteDeque(__wsz);
	}
	
	/**
	 * Appends a single byte to the sliding window.
	 *
	 * @param __b The byte to add to the window.
	 * @since 2016/03/10
	 */
	public void append(byte __b)
	{
		byte[] solo = this._solo;
		solo[0] = __b;
		append(solo, 0, 1);
	}
	
	/**
	 * Appends multiple bytes to the sliding window.
	 *
	 * @param __b Bytes to add to the sliding window.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/10
	 */
	public void append(byte[] __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Call other
		this.append(__b, 0, __b.length);
	}
	
	/**
	 * Appends the bytes from the input array in the given range to the sliding
	 * window.
	 *
	 * @param __b Bytes to add to the sliding window.
	 * @param __o Offset into the byte array.
	 * @param __l The number of bytes to add.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or the offset and the length exceeds the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/10
	 */
	public void append(byte __b[], int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l > __b.length))
			throw new IndexOutOfBoundsException("BAOB");
		
		// Get
		ByteDeque deque = this.deque;
		int windowsize = this.windowsize;
		int total = this._total;
		
		// Check if the new amount will overflow
		int newtotal = total + __l;
		int overflow = 0;
		if (newtotal < 0 || newtotal > windowsize)
		{
			overflow = (newtotal - windowsize);
			newtotal = windowsize;
		}
		
		// Will overflow, delete last bytes
		if (overflow > 0)
			deque.deleteFirst(overflow);
		
		// Add data to the end so that the single-byte insertion order
		// would be the same as the multi-byte insertion.
		// And so no shuffling is required
		deque.addLast(__b, __o, __l);
		this._total = newtotal;
	}
	
	/**
	 * Obtains a single byte at the specified position in the past.
	 *
	 * @param __ago The number of positions ago to get the value for.
	 * @return The byte value at the given position.
	 * @throws IndexOutOfBoundsException If the position is not within the
	 * bounds of the sliding window.
	 * @since 2017/03/04
	 */
	public byte get(int __ago)
		throws IndexOutOfBoundsException
	{
		byte[] solo = this._solo;
		get(__ago, solo, 0, 1);
		return solo[0];
	}
	
	/**
	 * This reads bytes from the sliding window at a given historical index
	 * and writes them to the input array.
	 *
	 * @param __ago How many bytes in the past to read.
	 * @param __b The output array of bytes to write.
	 * @param __o The offset into the array where to start writing bytes to.
	 * @param __l The number of bytes to read from history to write into the
	 * array.
	 * @throws IndexOutOfBoundsException If the offset or length are negative
	 * or the offset and the length exceeds the array bounds; {@code __ago}
	 * is zero or negative; the distance back and the length exceeds the
	 * amount of available history; the distance back exceeds the maximum
	 * window size; or the distance back exceeds the total amount of history.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/13
	 */
	public void get(int __ago, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l > __b.length))
			throw new IndexOutOfBoundsException("BAOB");
		
		// {@squirreljme.error BD1u Bulk read of window bytes would exceed
		// the bounds of the window. (The bytes in the past to start the
		// copy from; The number of bytes to read; The total number of
		// bytes in the window)}
		int windowsize = this.windowsize;
		int total = this._total;
		if (__ago <= 0 || ((total - __ago) + __l) > total)
			throw new IndexOutOfBoundsException(String.format(
				"BD1u %d %d %d", __ago, __l, total));
		
		// {@squirreljme.error BD1v Get of a sliding window read did not
		// read the expected number of bytes. (The expected number of bytes
		// to read; The actual number read)}
		int rv;
		if ((rv = this.deque.get(total - __ago, __b, __o,
			__l)) != __l)
			throw new IndexOutOfBoundsException(String.format(
				"BD1v %d %d", __l, rv));
	}
	
	/**
	 * Returns the total number of bytes in the sliding window.
	 *
	 * @return The total number of bytes in the window.
	 * @since 2016/03/28
	 */
	public int size()
	{
		return this._total;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/StringReader.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.Reader;

/**
 * This is a reader which can read from a string.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/04
 */
public class StringReader
	extends Reader
{
	/** The string to read from. */
	protected final String string;
	
	/** The string length. */
	protected final int length;
	
	/** The current position. */
	private int _at;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __s The input string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public StringReader(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
		this.length = __s.length();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Determine the current position and string length
		int at = this._at,
			length = this.length,
			left = length - at;
		
		// EOF?
		if (at >= length)
			return -1;
		
		// Can only read so many characters
		String string = this.string;
		int max = Math.min(__l, left),
			limit = at + max;
		for (int o = __o; at < limit; at++, o++)
			__c[o] = string.charAt(at);
		
		// Set position for next time
		this._at = at;
		
		return max;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/TableSectionOutputStream.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.io;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.lang.ref.Reference;
import java.io.DataOutput;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * This is an output stream which writes to section tables, essentially a
 * number of various data chunks in the stream. All sections are ordered in
 * the order that they are created.
 *
 * This class is not thread safe.
 *
 * @since 2019/08/11
 */
public final class TableSectionOutputStream
{
	/** This represents a variable sized section. */
	public static final int VARIABLE_SIZE =
		Integer.MIN_VALUE;
	
	/** The sections which are available in the output. */
	private final List<Section> _sections =
		new LinkedList<>();
	
	/** Are the section informations dirty? */
	private final __Dirty__ _dirty =
		new __Dirty__();
	
	/** The current file size. */
	private int _filesize;
	
	/**
	 * Adds a section which is of a variable size.
	 *
	 * @return The resulting section.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection()
	{
		return this.addSection(VARIABLE_SIZE, 1);
	}
	
	/**
	 * Adds a section which consists of the given byte array.
	 *
	 * @param __bytes The byte array to initialize as.
	 * @return The resulting section.
	 * @throws IOException If the section could not be written.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(byte[] __bytes)
		throws IOException, NullPointerException
	{
		return this.addSection(__bytes, 1);
	}
	
	/**
	 * Adds a section which consists of the given byte array using the given
	 * alignment.
	 *
	 * @param __bytes The byte array to initialize as.
	 * @param __align The alignment to use.
	 * @return The resulting section.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @throws IOException If the section could not be written.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(byte[] __bytes,
		int __align)
		throws IllegalArgumentException, IOException, NullPointerException
	{
		if (__bytes == null)
			throw new NullPointerException("NARG");
		
		// Add new section
		Section rv = this.addSection(__bytes.length, __align);
		
		// Write all the bytes into it
		rv.write(__bytes);
		
		// Use this section
		return rv;
	}
	
	/**
	 * Adds a section which is either of a variable size of a fixed size.
	 *
	 * @param __size The size of the section to use, if {@link #VARIABLE_SIZE}
	 * then the section will have a variable size.
	 * @return The section which was created for writing.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(int __size)
		throws IllegalArgumentException
	{
		return this.addSection(__size, 1);
	}
	
	/**
	 * Adds a section which is either of a variable size of a fixed size and
	 * one which has an alignment.
	 *
	 * @param __size The size of the section to use, if {@link #VARIABLE_SIZE}
	 * then the section will have a variable size.
	 * @param __align The alignment of the section, if the value is lower than
	 * {@code 1} it will be set to {@code 1}.
	 * @return The section which was created for writing.
	 * @throws IllegalArgumentException If the size is zero or negative and
	 * is not the variable size, or the alignment is below one.
	 * @since 2019/08/11
	 */
	public final TableSectionOutputStream.Section addSection(int __size,
		int __align)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BD3h Zero or negative size section. (The size)}
		if (__size != VARIABLE_SIZE && __size <= 0)
			throw new IllegalArgumentException("BD3h " + __size);
		
		// {@squirreljme.error BD3q Zero or negative alignment.
		// (The alignment)}
		if (__align < 1)
			throw new IllegalArgumentException("BD3q " + __align);
		
		// Create section
		Section rv = new Section(__size, __align, this._dirty);
		
		// Add to our section list
		this._sections.add(rv);
		
		// Becomes dirty because new section was added
		this._dirty._dirty = true;
		
		// And return this section
		return rv;
	}
	
	/**
	 * Returns the current size of the file.
	 *
	 * @return The file size.
	 * @since 2019/08/25
	 */
	public final int fileSize()
	{
		this.__undirty();
		return this._filesize;
	}
	
	/**
	 * Returns the address of the given section.
	 *
	 * @param __s The section.
	 * @return The address of the section.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final int sectionAddress(Section __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__undirty();
		return __s._writeaddress;
	}
	
	/**
	 * Returns the size of the given section.
	 *
	 * @param __s The section.
	 * @return The size of the section.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final int sectionSize(Section __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.__undirty();
		return __s._writesize;
	}
	
	/**
	 * Returns a byte array representing the table file.
	 *
	 * @return The resulting byte array.
	 * @since 2019/08/11
	 */
	public final byte[] toByteArray()
	{
		// Setup output byte array which has a base size for the size of the
		// file
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			this.fileSize()))
		{
			// Record everything in
			this.writeTo(baos);
			
			// Return the resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BD3i Could not create the byte array.}
		catch (IOException e)
		{
			throw new RuntimeException("BD3i", e);
		}
	}
	
	/**
	 * Writes the table file to the given output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// The current write pointer
		int writeptr = 0;
		
		// Undirty and get the file size
		this.__undirty();
		int filesize = this._filesize;
		
		// Write each individual section to the output stream
		List<Section> sections = this._sections;
		for (int i = 0, n = sections.size(); i < n; i++)
		{
			Section section = sections.get(i);
			
			// Get properties of the section
			byte[] data = section._data;
			int cursize = section._size,
				writeaddress = section._writeaddress,
				writesize = section._writesize,
				writeendaddress = writeaddress + writesize,
				actualwrite = (cursize < writesize ? cursize : writesize);
			
			// Write padding until we reach our needed address
			while (writeptr < writeaddress)
			{
				__os.write(0);
				writeptr++;
			}
			
			// Rewrites must be processed to figure out how to refer to
			// other section aliases!
			for (__Rewrite__ rewrite : section._rewrites)
			{
				// The target section if any
				Reference<TableSectionOutputStream.Section> refsection =
					rewrite._section;
				
				// Determine the value that is to be written
				int value = 0;
				switch (rewrite._value)
				{
						// Address of section
					case ADDRESS:
						if (refsection != null)
							value = refsection.get()._writeaddress;
						break;
						
						// Size of section or file.
					case SIZE:
						if (refsection == null)
							value = filesize;
						else
							value = refsection.get()._writesize;
						break;
				}
				
				// Add offset of value
				value += rewrite._offset;
				
				// Perform the actual rewrite
				int paddr = rewrite._address;
				switch (rewrite._type)
				{
					case SHORT:
						data[paddr] = (byte)(value >>> 8);
						data[paddr + 1] = (byte)(value);
						break;
					
					case INTEGER:
						data[paddr] = (byte)(value >>> 24);
						data[paddr + 1] = (byte)(value >>> 16);
						data[paddr + 2] = (byte)(value >>> 8);
						data[paddr + 3] = (byte)(value);
						break;
				}
			}
			
			// Write the section data as an entire chunk, note that this
			// could be a fixed size section with a short buffer!
			__os.write(data, 0, actualwrite);
			writeptr += actualwrite;
			
			// Write padding until we reach our ending address
			while (writeptr < writeendaddress)
			{
				__os.write(0);
				writeptr++;
			}
		}
	}
	
	/**
	 * Undirties and calculations all the section layout and information.
	 *
	 * @since 2019/08/25
	 */
	private final void __undirty()
	{
		// There is no need to calculate if this is not dirty at all
		__Dirty__ dirty = this._dirty;
		if (!dirty._dirty)
			return;
		
		// Our current file size
		int filesize = 0;
		
		// We must go through all of the sections, perform their required
		// alignment while additionally calculating their addresses within
		// the file for section references.
		List<Section> sections = this._sections;
		for (int i = 0, n = sections.size(); i < n; i++)
		{
			Section section = sections.get(i);
			
			// Perform alignment of this section
			if ((filesize % section.alignment) != 0)
				filesize += section.alignment - (filesize % section.alignment);
			
			// Section is addressed here
			section._writeaddress = filesize;
			
			// Move the current file size up by the section's size
			int writesize = (section.isvariable ?
				section._size : section.fixedsize);
			filesize += writesize;
			section._writesize = writesize;
		}
		
		// Store file size
		this._filesize = filesize;
		
		// Clear dirty flag
		dirty._dirty = false;
	}
	
	/**
	 * This represents a single section within the output.
	 *
	 * @since 2019/08/11
	 */
	public static final class Section
		extends OutputStream
		implements DataOutput
	{
		/** The size of the bufer. */
		private static final int _BUFFER_SIZE =
			512;
		
		/** The fixed size of this section. */
		protected final int fixedsize;
		
		/** The alignment of this section. */
		protected final int alignment;
		
		/** Is this a variable size section? */
		protected final boolean isvariable;
		
		/** Data rewrites which are possible. */
		private final List<__Rewrite__> _rewrites =
			new LinkedList<>();
		
		/** The tracker for the dirtiness. */
		private final __Dirty__ _dirty;
		
		/** The byte buffer data. */
		private byte[] _data;
		
		/** The current size of the section. */
		private int _size;
		
		/** The write address of this section. */
		private int _writeaddress =
			-1;
		
		/** The write size of this section. */
		private int _writesize =
			-1;
		
		/**
		 * Initializes the written section.
		 *
		 * @param __size The size to use.
		 * @param __align The alignment to use.
		 * @param __d The dirty flag.
		 * @throws IllegalArgumentException If the size is zero or negative.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		private Section(int __size, int __align, __Dirty__ __d)
			throws IllegalArgumentException, NullPointerException
		{
			if (__d == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error BD3l Zero or negative size. (The size)}
			if (__size != VARIABLE_SIZE && __size <= 0)
				throw new IllegalArgumentException("BD3l " + __size);
			
			// Set
			this.fixedsize = __size;
			this.alignment = (__align >= 1 ? __align : 1);
			this.isvariable = (__size == VARIABLE_SIZE);
			
			// Dirty flag storage
			this._dirty = __d;
			
			// If this is a fixed size section, we never have to expand it
			// so we can allocate all the needed data!
			if (__size != VARIABLE_SIZE)
				this._data = new byte[__size];
			else
				this._data = new byte[_BUFFER_SIZE];
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void close()
		{
			// Do nothing
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void flush()
		{
			// Do nothing
		}
		
		/**
		 * Returns the current written size of the section.
		 *
		 * @return The current section size.
		 * @since 2019/08/11
		 */
		public final int size()
		{
			return this._size;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(int __b)
			throws IOException
		{
			// {@squirreljme.error BD3m Size of section exceeded. (The size
			// of the section)}
			int size = this._size;
			if (!this.isvariable && size + 1 > this.fixedsize)
				throw new IOException("BD3m " + size);
			
			// Possibly resize the data array, only when variable
			byte[] data = this._data;
			if (this.isvariable && size >= data.length)
			{
				data = Arrays.copyOf(data, size + _BUFFER_SIZE);
				this._data = data;
			}
			
			// Write into the data
			data[size] = (byte)__b;
			
			// Size up
			this._size = size + 1;
			
			// Becomes dirty
			this._dirty._dirty = true;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(byte[] __b)
			throws IOException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			
			this.write(__b, 0, __b.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			if (__b == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BD3p Size of section exceeded.}
			int size = this._size;
			if (!this.isvariable && size + __l > this.fixedsize)
				throw new IOException("BD3p");
			
			// Possibly resize the data array (only when variable)
			byte[] data = this._data;
			if (this.isvariable && size + __l >= data.length)
			{
				data = Arrays.copyOf(data,
					size + (__l < _BUFFER_SIZE ? _BUFFER_SIZE : __l));
				this._data = data;
			}
			
			// Write into the data
			for (int i = 0; i < __l; i++)
				data[size++] = __b[__o++];
			
			// Size up
			this._size = size;
			
			// Becomes dirty
			this._dirty._dirty = true;
		}
		
		/**
		 * Writes padding which aligns to a given amount from within the
		 * data stream as itself.
		 *
		 * @param __n The number of bytes to align to.
		 * @return The number of alignment bytes written.
		 * @throws IllegalArgumentException If the requested alignment is
		 * negative.
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final int writeAlignment(int __n)
			throws IllegalArgumentException, IOException
		{
			// {@squirreljme.error BD3k Cannot align to a negative amount.
			// (The alignment)}
			if (__n < 1)
				throw new IllegalArgumentException("BD3k " + __n);
			
			// Not point aligning to a byte
			if (__n == 1)
				return 0;
			
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeBoolean(boolean __v)
			throws IOException
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeByte(int __v)
			throws IOException
		{
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeBytes(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			for (int i = 0, n = __v.length(); i < n; i++)
				this.write(__v.charAt(i));
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeChar(int __v)
			throws IOException
		{
			this.writeShort(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeChars(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			for (int i = 0, n = __v.length(); i < n; i++)
			{
				char c = __v.charAt(i);
				
				this.write(c >> 8);
				this.write(c);
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeDouble(double __v)
			throws IOException
		{
			this.writeLong(Double.doubleToLongBits(__v));
		}
		
		/**
		 * Writes the size of the file as an integer.
		 *
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writeFileSizeInt()
			throws IOException
		{
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.SIZE, 0, null));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the size of the file as a short.
		 *
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writeFileSizeShort()
			throws IOException
		{
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.SIZE, 0, null));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeFloat(float __v)
			throws IOException
		{
			this.writeInt(Float.floatToIntBits(__v));
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeInt(int __v)
			throws IOException
		{
			this.write(__v >> 24);
			this.write(__v >> 16);
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeLong(long __v)
			throws IOException
		{
			this.write((int)(__v >> 56));
			this.write((int)(__v >> 48));
			this.write((int)(__v >> 40));
			this.write((int)(__v >> 32));
			this.write((int)(__v >> 24));
			this.write((int)(__v >> 16));
			this.write((int)(__v >> 8));
			this.write((int)(__v));
		}
		
		/**
		 * Writes the specified number of bytes as padding, the padding
		 * value is zero.
		 *
		 * @param __n The number of bytes to pad with.
		 * @since 2019/08/11
		 */
		public final void writePadding(int __n)
			throws IOException
		{
			this.writePadding(__n, 0);
		}
		
		/**
		 * Writes the specified number of bytes as padding.
		 *
		 * @param __n The number of bytes to pad with.
		 * @param __v The padding value to write.
		 * @throws IllegalArgumentException If the padding amount is negative.
		 * @throws IOException On write errors.
		 * @since 2019/08/11
		 */
		public final void writePadding(int __n, int __v)
			throws IllegalArgumentException, IOException
		{
			// {@squirreljme.error BD3j Negative padding. (The padding)}
			if (__n < 0)
				throw new IllegalArgumentException("BD3j " + __n);
			
			// Not writing anything, so ignore
			if (__n == 0)
				return;
			
			// Write the padding
			for (int i = 0; i < __n; i++)
				this.write(__v);
		}
		
		/**
		 * Writes the address of the given section as an integer.
		 *
		 * @param __s The section to write the address of.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/24
		 */
		public final void writeSectionAddressInt(Section __s)
			throws IOException, NullPointerException
		{
			this.writeSectionAddressInt(__s, 0);
		}
		
		/**
		 * Writes the address of the given section as an integer.
		 *
		 * @param __s The section to write the address of.
		 * @param __o The offset to use.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionAddressInt(Section __s, int __o)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.ADDRESS, __o, __s));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the address of the given section as a short.
		 *
		 * @param __s The section to write the address of.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/24
		 */
		public final void writeSectionAddressShort(Section __s)
			throws IOException, NullPointerException
		{
			this.writeSectionAddressShort(__s, 0);
		}
		
		/**
		 * Writes the address of the given section as a short.
		 *
		 * @param __s The section to write the address of.
		 * @param __o The offset value.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionAddressShort(Section __s, int __o)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.ADDRESS, __o, __s));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * Writes the size of the given section as an integer.
		 *
		 * @param __s The section and its size to write.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionSizeInt(Section __s)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.INTEGER, __RewriteValue__.SIZE, 0, __s));
				
			// Place padding
			this.writeInt(0);
		}
		
		/**
		 * Writes the size of the given section as a short.
		 *
		 * @param __s The section and its size to write.
		 * @throws IOException On write errors.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/08/11
		 */
		public final void writeSectionSizeShort(Section __s)
			throws IOException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Record rewrite
			this._rewrites.add(new __Rewrite__(this._size,
				__RewriteType__.SHORT, __RewriteValue__.SIZE, 0, __s));
				
			// Place padding
			this.writeShort(0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeShort(int __v)
			throws IOException
		{
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * Writes the specified short value and checks to make sure it is
		 * within the range of a short.
		 *
		 * @param __v The value to write.
		 * @throws IOException If the short could not be written or it
		 * exceeds the range of a short value.
		 * @since 2019/08/11
		 */
		public final void writeShortChecked(int __v)
			throws IOException
		{
			// {@squirreljme.error BD3o Signed short value out of range.
			// (The value)}
			if (__v < -32768 || __v > 32767)
				throw new IOException("BD3o " + __v);
			
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * Writes the specified unsigned short value and checks to make sure it
		 * is within the range of an unsigned short.
		 *
		 * @param __v The value to write.
		 * @throws IOException If the unsigned short could not be written or it
		 * exceeds the range of an unsigned short value.
		 * @since 2019/08/11
		 */
		public final void writeUnsignedShortChecked(int __v)
			throws IOException
		{
			// {@squirreljme.error BD3n Unsigned short value out of range.
			// (The value)}
			if (__v < 0 || __v > 65535)
				throw new IOException("BD3n " + __v);
			
			this.write(__v >> 8);
			this.write(__v);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
		public final void writeUTF(String __v)
			throws IOException, NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			// Write into a buffer
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
				2 + (__v.length() * 2));
				DataOutputStream dos = new DataOutputStream(baos))
			{
				// Write data
				dos.writeUTF(__v);
				
				// Dump to this internally
				baos.writeTo(this);
			}
		}
	}
	
	/**
	 * Are the addresses and sizes considered dirty?
	 *
	 * @since 2019/08/25
	 */
	static final class __Dirty__
	{
		/** Flag used to store the dirty state. */
		volatile boolean _dirty;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/ZLibCompressor.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
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
191
192
193
194
195
196
197
198
199
200
201









































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This class supports compressing data to ZLib streams.
 *
 * Associated standards:
 * {@link https://www.ietf.org/rfc/rfc1950.txt}.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/11
 */
public final class ZLibCompressor
	extends OutputStream
	implements CompressionStream
{
	/** The stream to forward to. */
	protected final OutputStream out;
	
	/** The deflater used. */
	private final DeflaterOutputStream _dos;
	
	/** Adler checksum of uncompressed stream. */
	private final Adler32Calculator _adler =
		new Adler32Calculator();
	
	/** Has this been closed? */
	private boolean _closed;
	
	/** Initialized with Zlib header? */
	private boolean _init;
	
	/**
	 * Initializes the compressor.
	 *
	 * @param __os The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ZLibCompressor(OutputStream __os)
		throws NullPointerException
	{
		this(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Initializes the compressor with the given compression level.
	 *
	 * @param __os The stream to write to.
	 * @param __cl The compression level to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ZLibCompressor(OutputStream __os, CompressionLevel __cl)
		throws NullPointerException
	{
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		this.out = __os;
		this._dos = new DeflaterOutputStream(__os);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final long compressedBytes()
	{
		return this._dos.compressedBytes() +
			(this._init ? 2 + (this._closed ? 4 : 0) : 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void close()
		throws IOException
	{
		// Close only once
		if (!this._closed)
		{
			this._closed = true;
			
			// Flush and close the other compression stream
			DeflaterOutputStream dos = this._dos;
			dos.flush();
			dos.close();
			
			// Write the checksum
			OutputStream out = this.out;
			int checksum = this._adler.checksum();
			out.write(checksum >> 24);
			out.write(checksum >> 16);
			out.write(checksum >> 8);
			out.write(checksum);
			
			// Flush the output
			out.flush();
		}
		
		// Forward close to output
		this.out.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void flush()
		throws IOException
	{
		// Flush to the output
		this.out.flush();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final long uncompressedBytes()
	{
		return this._dos.uncompressedBytes();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// Just forward write call since it is easier
		this.write(new byte[]{(byte)__b}, 0, 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		OutputStream out = this.out;
		
		// If the stream has not been initialized, we need to set a flag
		// and such
		if (!this._init)
		{
			this._init = true;
			
			// DEFLATE compression with no flags
			out.write(0x78);
			out.write(1);
		}
		
		// Write to data
		this._dos.write(__b, __o, __l);
		
		// Checksum that
		this._adler.offer(__b, __o, __l);
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/ZLibDecompressor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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




















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;

/**
 * This class supports decompressing ZLib streams.
 *
 * Associated standards:
 * {@link https://www.ietf.org/rfc/rfc1950.txt}.
 *
 * This class is not thread safe.
 *
 * @since 2017/03/04
 */
public class ZLibDecompressor
	extends DecompressionInputStream
{
	/** Compression method mask. */
	private static final int _CMF_COMPRESSION_METHOD_MASK =
		0b00001111;
	
	/** Compression info mask. */
	private static final int _CMF_COMPRESSION_INFO_MASK =
		0b11110000;
	
	/** Compression info shift. */
	private static final int _CMF_COMPRESSION_INFO_SHIFT =
		4;
	
	/** Deflate compression method. */
	private static final int _CMF_METHOD_DEFLATE =
		8;
	
	/** Is a preset dictionary being used? */
	private static final int _FLAG_PRESET_DICTIONARY =
		1 << 5;
	
	/** The source stream. */
	protected final DataInputStream in;
	
	/** Single byte array to be shared for single reads. */
	private final byte[] _solo =
		new byte[1];
	
	/** The current checksum being calculated. */
	private final Adler32Calculator _checksum =
		new Adler32Calculator();
	
	/** Current stream to read data from, will change for blocks. */
	private volatile DecompressionInputStream _current;
	
	/** Has EOF been read? */
	private volatile boolean _eof;
	
	/** The number of uncompressed bytes. */
	private volatile long _uncomp;
	
	/** The base number of compressed bytes. */
	private volatile long _basecomp;
	
	/**
	 * Initializes the ZLib decompressor.
	 *
	 * @param __in The stream to read data from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/03/04
	 */
	public ZLibDecompressor(InputStream __in)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = new DataInputStream(__in);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int available()
		throws IOException
	{
		// If the current stream is known, it is possible that the number
		// of available bytes will be known from it
		InputStream current = this._current;
		if (current != null)
			return current.available();
		
		// Otherwise no amount is known
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
		
		// Close the current stream also
		InputStream current = this._current;
		if (current != null)
			current.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		// It is really hard to tell how many compressed bytes were read so
		// if there is a current stream then use it from the base because
		// otherwise it would be really unknown how many bytes were truly
		// read from the compressed stream
		long basecomp = this._basecomp;
		DecompressionInputStream current = this._current;
		if (current != null)
			return basecomp + current.compressedBytes();
		return basecomp;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/04
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("BAOB");
		
		// Read EOF?
		if (this._eof)
			return -1;
		
		// Try to fill the buffer up as much as possible
		int rv = 0;
		boolean eof = false;
		DataInputStream in = this.in;
		DecompressionInputStream current = this._current;
		Adler32Calculator checksum = this._checksum;
		for (int at = __o, rest = __l; rv < __l;)
		{
			// There is a current stream being read
			if (current != null)
			{
				int rc = current.read(__b, at, rest);
				
				// If EOF is reached then the checksum must be checked
				if (rc < 0)
				{
					// The number of compressed bytes always acts as a base
					// since it is unknown how many bytes were read by the
					// decompression stream. So when it has ended it a new base
					// must be set for every byte which was read.
					this._basecomp += current.compressedBytes();
					
					// {@squirreljme.error BD1w The checksum for the ZLib
					// stream is not valid. (The desired checksum; The actual
					// checksum)}
					int want = in.readInt(),
						was = checksum.checksum();
					if (want != was)
						throw new IOException(String.format("BD1w %08x %08x",
							want, was));
					
					// This is the checksum
					this._basecomp += 4;
					
					// Clear current because no more data can be read from
					// it
					current = null;
					this._current = null;
				}
				
				// Otherwise consume those bytes
				else
				{
					at += rc;
					rv += rc;
					rest -= rc;
					
					// Count those bytes as uncompressed
					this._uncomp += rc;
				}
			}
			
			// Otherwise try to see if there is data to be read
			else
			{
				// Compression method and flags
				int cmf = in.read();
				
				// The end of stream could be at this point at which point it
				// is acceptable to stop reading data
				if (cmf < 0)
				{
					eof = true;
					this._eof = true;
					break;
				}
				
				// Count single compressed byte
				this._basecomp++;
				
				// {@squirreljme.error BD1x Only deflate compressed ZLib
				// streams are supported. (The compression method used)}
				int method = (cmf & _CMF_COMPRESSION_METHOD_MASK);
				if (_CMF_METHOD_DEFLATE != method)
					throw new IOException(String.format("BD1x %d", method));
				
				// {@squirreljme.error BD1y The specified binary logarithm
				// specified for the sliding window is not valid. (The binary
				// logarithm of the sliding window)}
				// The specification says that higher sliding windows are not
				// allowed, but skirt that requirement
				int slwin = ((cmf & _CMF_COMPRESSION_INFO_MASK) >>>
					_CMF_COMPRESSION_INFO_SHIFT) + 8;
				if (slwin < 0 || slwin > 30)
					throw new IOException(String.format("BD1y %d", slwin));
				
				// Shift up
				slwin = 1 << slwin;
				
				// Read more flags
				int mf = in.readUnsignedByte();
				
				// Count single compressed byte
				this._basecomp++;
				
				// {@squirreljme.error BD1z The checksum for the starting
				// ZLib header is not a multiple of 31. (The checksum
				// remainder)}
				// This is a basic check to ensure that in most cases that the
				// header of the ZLib chunk is not corrupt.
				int was = ((cmf * 256) + mf) % 31;
				if (was != 0)
					throw new IOException(String.format("BD1z %d", was));
				
				// {@squirreljme.error BD20 Preset dictionaries in ZLib
				// streams are not supported.}
				if ((mf & _FLAG_PRESET_DICTIONARY) != 0)
					throw new IOException("BD20");
				
				// Setup inflate stream
				checksum.reset();
				current = new InflaterInputStream(in, slwin, checksum);
				this._current = current;
			}
		}
		
		// Return EOF or the read count
		return (eof && rv == 0 ? -1 : rv);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._uncomp;
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/__CRC32Table__.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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.io;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
 * This contains the table used for calculation of the CRC.
 *
 * @since 2016/07/16
 */
final class __CRC32Table__
{
	/** Static table reference. */
	private static final Map<Integer, Reference<__CRC32Table__>> _TABLES =
		new HashMap<>();
	
	/** CRC table data. */
	final int[] _table;
	
	/**
	 * Initializes the table data.
	 *
	 * @param __poly The polynomial.
	 * @since 2016/07/16
	 */
	private __CRC32Table__(int __poly)
	{
		// Setup table;
		int[] table = new int[256];
		for (int i = 0; i < 256; i++)
		{
			int remainder = i << 24;
			
			// Divide all bits possibly
			for (int b = 0; b < 8; b++)
			{
				int oldrem = remainder;
				remainder <<= 1;
				
				// XOR in polynomial
				if (0 != (oldrem & 0x8000_0000))
					remainder ^= __poly;
			}
			
			// Store
			table[i] = remainder;
		}
		
		// Store
		this._table = table;
	}
	
	/**
	 * Obtains the CRC table.
	 *
	 * @parma __poly The polynomial.
	 * @return The CRC table.
	 * @since 2016/07/16
	 */
	static final __CRC32Table__ __table(int __poly)
	{
		// Lock
		Map<Integer, Reference<__CRC32Table__>> tables = _TABLES;
		synchronized (tables)
		{
			// Get
			Integer i = Integer.valueOf(__poly);
			Reference<__CRC32Table__> ref = tables.get(i);
			__CRC32Table__ rv;
		
			// Cache?
			if (ref == null || null == (rv = ref.get()))
				tables.put(i,
					new WeakReference<>((rv = new __CRC32Table__(__poly))));
		
			// Return
			return rv;
		}
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/__RewriteType__.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.io;

/**
 * The type of data to write in.
 *
 * @since 2019/08/17
 */
enum __RewriteType__
{
	/** Short. */
	SHORT,
	
	/** Integer. */
	INTEGER,
	
	/** End. */
	;
}

Deleted runt/libs/io/net/multiphasicapps/io/__RewriteValue__.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.io;

/**
 * This is the value to be written.
 *
 * @since 2019/08/17
 */
enum __RewriteValue__
{
	/** Address. */
	ADDRESS,
	
	/** Size. */
	SIZE,
	
	/** End. */
	;
}

Deleted runt/libs/io/net/multiphasicapps/io/__Rewrite__.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.io;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This stores a single rewrite.
 *
 * @since 2019/08/17
 */
final class __Rewrite__
{
	/** The address. */
	final int _address;
	
	/** The type. */
	final __RewriteType__ _type;
	
	/** The value. */
	final __RewriteValue__ _value;
	
	/** Value offset. */
	final int _offset;
	
	/** The target section to use. */
	final Reference<TableSectionOutputStream.Section> _section;
	
	/**
	 * Initializes the rewrite info.
	 *
	 * @param __addr The address to replace.
	 * @param __type The value type to rewrite.
	 * @param __value The value of the information.
	 * @param __offset The value offset.
	 * @param __section The section being targeted, may be {@code null}.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/17
	 */
	__Rewrite__(int __addr, __RewriteType__ __type, __RewriteValue__ __value,
		int __offset, TableSectionOutputStream.Section __section)
		throws NullPointerException
	{
		if (__type == null || __value == null)
			throw new NullPointerException("NARG");
		
		this._address = __addr;
		this._type = __type;
		this._value = __value;
		this._offset = __offset;
		this._section = (__section == null ? null :
			new WeakReference<>(__section));
	}
}

Deleted runt/libs/io/net/multiphasicapps/io/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the data related input and output streams.
 *
 * @since 2016/07/09
 */

package net.multiphasicapps.io;

Deleted runt/libs/markdown-writer/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: Markdown Writer
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains a formatted markdown 
 writer which allows documents to be written to a standard stream yet 
 have state on which properties to apply to the output.
X-SquirrelJME-Error: CG
X-SquirrelJME-UUID: df4c851d-8e50-4efb-bd60-e4e8e5a2f7a3
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/MarkdownTextStyle.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

/**
 * This describes the type of text style that may be chosen for output.
 *
 * @since 2016/09/13
 */
public enum MarkdownTextStyle
{
	/** Normal style. */
	NORMAL(true),
	
	/** Strong. */
	STRONG(true),
	
	/** Emphasis. */
	EMPHASIS(true),
	
	/** Strong Emphasis. */
	STRONG_EMPHASIS(true),
	
	/** Source code. */
	CODE(false),
	
	/** End. */
	;
	
	/** Is this a normal text style? */
	protected final boolean normal;
	
	/**
	 * Initializes the style information.
	 *
	 * @param __n Is this style considered for non-code text.
	 * @since 2016/09/13
	 */
	private MarkdownTextStyle(boolean __n)
	{
		this.normal = __n;
	}
	
	/**
	 * Is this style for normal text?
	 *
	 * @return {@code true} if the style is for normal text.
	 * @since 2016/09/13
	 */
	public final boolean isNormal()
	{
		return this.normal;
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/MarkdownWriter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530


















































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Writer;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Formatter;
import java.util.Objects;

/**
 * This is a class which writes markdown formatted text to the specified
 * {@link Appendable} which may be any implentation of one. This handle all
 * of the standard formatting details that markdown supports.
 *
 * This writer supports closing and flushing, however those operations will
 * only be performed on the wrapped {@link Appendable} if those also implement
 * such things.
 *
 * This class is not thread safe.
 *
 * @since 2016/09/13
 */
public class MarkdownWriter
	implements Appendable, Closeable
{
	/** Markdown right column limit. */
	public static final int RIGHT_COLUMN =
		76;
	
	/** Where text may be written to. */
	protected final Appendable append;
	
	/** Formatter to write output text. */
	protected final Formatter formatter;
	
	/** The current section being written. */
	volatile __Section__ _section;
	
	/** The current text column. */
	volatile int _column;
	
	/**
	 * Initializes the markdown writer.
	 *
	 * @param __a The appendable to send characters to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public MarkdownWriter(Appendable __a)
		throws NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.append = __a;
		
		// Setup formatter
		this.formatter = new Formatter(this);
	}
	
	/**
	 * {@inheritDoc}
	 * @sicne 2016/09/13
	 */
	@Override
	public MarkdownWriter append(char __c)
		throws IOException
	{
		__put(__c, false);
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @sicne 2016/09/13
	 */
	@Override
	public MarkdownWriter append(CharSequence __cs)
		throws IOException
	{
		return this.append(__cs, 0, __cs.length());
	}
	
	/**
	 * {@inheritDoc}
	 * @sicne 2016/09/13
	 */
	@Override
	public MarkdownWriter append(CharSequence __cs, int __s, int __e)
		throws IOException
	{
		for (int i = __s; i < __e; i++)
			__put(__cs.charAt(i), false);
		return this;
	}
	
	/**
	 * {@inheritDoc}
	 * @sicne 2016/09/13
	 */
	@Override
	public void close()
		throws IOException
	{
		// Flush before close
		try
		{
			flush();
		}
		
		// Ignore
		catch (IOException e)
		{
		}
		
		// Only close if it is closeable
		Appendable append = this.append;
		if (append instanceof Closeable)
			((Closeable)append).close();
	}
	
	/**
	 * Flushes this writer.
	 *
	 * @throws IOException If it could not be flushed.
	 * @since 2016/09/13
	 */
	public void flush()
		throws IOException
	{
		// Java ME has no Flushable so we only know of these two classes
		Appendable append = this.append;
		if (append instanceof OutputStream)
			((OutputStream)append).flush();
		else if (append instanceof Writer)
			((Writer)append).flush();
	}
	
	/**
	 * Prints the specified header into the output document.
	 *
	 * @param __abs If {@code true} then the header is at the specified level,
	 * otherwise if {@code false} it will be relative to the existing header
	 * level.
	 * @param __level If absolute then this level is set where the level is
	 * based on an index of one, otherwise this will be the relative header
	 * level adjustment from the current header level.
	 * @param __s The text to print.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public void header(boolean __abs, int __level, String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Setup section
		__SectionHeader__ header = new __SectionHeader__(this, __abs, __level);
		
		// Print header text
		append(__s);
		
		// Enter paragraph mode
		paragraph();
	}
	
	/**
	 * End a list.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void listEnd()
		throws IOException
	{
		// End the list by 
		__Section__ section = this._section;
		if (section instanceof __SectionList__)
		{
			// Manual end of section
			section.__endSection();
			
			// Go back to the section before this
			this._section = section._sectionbefore;
		}
	}
	
	/**
	 * Go the next item in the list.
	 *
	 * @throws IOException On write errros.
	 * @since 2016/10/01
	 */
	public void listNext()
		throws IOException
	{
		// Set new item on the list
		__Section__ section = this._section;
		if (section instanceof __SectionList__)
			((__SectionList__)section)._newitem = true;
	}
	
	/**
	 * Start a list.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void listStart()
		throws IOException
	{
		// Start section
		new __SectionUnorderedList__(this);
	}
	
	/**
	 * Enters paragraph mode which may be used .
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	public void paragraph()
		throws IOException
	{
		new __SectionParagraph__(this);
	}
	
	/**
	 * Prints a single character.
	 *
	 * @param __c The character to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	public void print(char __c)
		throws IOException
	{
		append(__c);
	}
	
	/**
	 * Prints the specified object.
	 *
	 * @param __o The object to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void print(Object __o)
		throws IOException
	{
		append(Objects.toString(__o));
	}
	
	/**
	 * Prints formatted text to the output.
	 *
	 * @param __f The format specifier.
	 * @param __args The format arguments.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/13
	 */
	public void printf(String __f, Object... __args)
		throws IOException, NullPointerException
	{
		// Check
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Format
		this.formatter.format(__f, __args);
	}
	
	/**
	 * Prints the end of the line.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void println()
		throws IOException
	{
		append('\n');
	}
	
	/**
	 * Prints the specified object followed by a new line.
	 *
	 * @param __o The object to print.
	 * @throws IOException On write errors.
	 * @since 2016/10/01
	 */
	public void println(Object __o)
		throws IOException
	{
		print(__o);
		println();
	}
	
	/**
	 * Prints a URI to the output document.
	 *
	 * @param __uri The URI to print.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null)
			throw new NullPointerException("NARG");
		
		// Prime
		__put('\0', false);
		
		// Print it out
		__put('<', true);
		append(__uri);
		__put('>', true);
	}
	
	/**
	 * Prints a URI to the output document with the given display text.
	 *
	 * @param __uri The URI to point to.
	 * @param __text The display text for the URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri, String __text)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null || __text == null)
			throw new NullPointerException("NARG");
		
		// Prime
		__put('\0', false);
		
		// Print it out
		__put('[', true);
		append(__text);
		__put(']', true);
		__put('(', true);
		__unescapedURI(__uri);
		__put(')', true);
	}
	
	/**
	 * Prints a URI to the output document with the given display text.
	 *
	 * @param __uri The URI to point to.
	 * @param __text The display text for the URI.
	 * @param __title The text text for the URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/01
	 */
	public void uri(String __uri, String __text, String __title)
		throws IOException, NullPointerException
	{
		// Check
		if (__uri == null || __text == null || __title == null)
			throw new NullPointerException("NARG");
		
		// Prime
		__put('\0', false);
		
		// Print it out
		__put('[', true);
		append(__text);
		__put(']', true);
		__put('(', true);
		__unescapedURI(__uri);
		__put(' ', true);
		__put('"', true);
		append(__title);
		__put('"', true);
		__put(')', true);
	}
	
	/**
	 * Returns {@code true} if the specified character is to be escaped.
	 *
	 * @return {@code true} if the character must be escaped.
	 * @since 2016/10/02
	 */
	boolean __escaped(char __c)
	{
		return (__c == '[' || __c == '(' || __c == '*' || __c == '_' ||
			__c == '\\' || __c == '<' || (__c == '#' && this._column == 0));
	}
	
	/**
	 * Places a single character into the output sending the character to
	 * be printed to the currently being written to section.
	 *
	 * @param __c The character to put.
	 * @param __nospec If {@code true} then the character is not given
	 * special handling.
	 * @throws IOException On write errors.
	 * @since 2016/09/13
	 */
	void __put(char __c, boolean __nospec)
		throws IOException
	{
		// Ignore CR
		if (__c == '\r')
			return;
		
		// Direct place if no special handling
		if (__nospec)
		{
			// Ignore null
			if (__c == 0)
				return;
			
			// Add it
			this.append.append(__c);
			
			// Newline resets column
			int column = this._column;
			if (__c == '\n')
				this._column = (column = 0);
			
			// Otherwise it goes up
			else
				this._column = (++column);
			
			// If at the end, go to the next line
			if (column >= RIGHT_COLUMN)
				__put('\n', true);
			
			// Done
			return;
		}
		
		// Need section to always exist
		__Section__ section = this._section;
		if (section == null)
			section = new __SectionParagraph__(this);
		
		// Character needs escaping?
		if (__escaped(__c))
			section.__process('\\');
		
		// Place character
		section.__process(__c);
	}
	
	/**
	 * Performs special handling for writing URI parts.
	 *
	 * @param __s The input URI.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/02
	 */
	void __unescapedURI(String __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Go through all
		int n = __s.length();
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Never escape underscore
			if (__escaped(c) || c == '"' || MarkdownWriter.__isWhitespace(c))
				if (c == '_')
					__put(c, true);
				
				// Percent encode anything else
				else
				{
					byte[] b = Character.toString(c).getBytes("utf-8");
					int q = b.length;
					__put('%', false);
					for (int l = 0; l < q; l++)
					{
						byte d = b[l];
						__put(Character.forDigit((d >>> 4) & 0xF, 16), false);
						__put(Character.forDigit(d & 0xF, 16), false);
					}
				}
			
			// Otherwise normal print
			else
				__put(c, false);
		}
	}
	
	/**
	 * Is this a whitespace character?
	 *
	 * @param __c The character to check.
	 * @return {@code true} if it is whitespace.
	 * @since 2016/10/02
	 */
	static boolean __isWhitespace(char __c)
	{
		return __c == ' ' || __c == '\t' || __c == '\n';
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/__SectionHeader__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This section is used for the printing of headers.
 *
 * @since 2016/10/02
 */
class __SectionHeader__
	extends __Section__
{
	/**
	 * Initializes the section header.
	 *
	 * @param __mkd The owning writer.
	 * @param __abs Absolutely set the specified level if {@code true},
	 * otherwise level adjustment will be relative.
	 * @param __level The level to set to if absolute or relative from a
	 * previous level.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionHeader__(MarkdownWriter __mdw, boolean __abs, int __level)
		throws IOException
	{
		super(__mdw);
		
		// Modify level
		int level = this._level;
		level = (__abs ? Math.max(1, __level) : Math.max(1, level + __level));
		this._level = level;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __endSection()
		throws IOException
	{
		super.__endSection();
		
		// Add newline after the first column
		MarkdownWriter writer = this.writer;
		if (writer._column > 0)
			writer.__put('\n', true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If on column zero, add the header bits
		MarkdownWriter writer = this.writer;
		int level = this._level;
		if (writer._column == 0)
		{
			for (int i = 0; i < level; i++)
				writer.__put('#', true);
			writer.__put(' ', true);
		}
		
		// Add character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/__SectionList__.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
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














































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is the base section for numerical values.
 *
 * @since 2016/10/02
 */
abstract class __SectionList__
	extends __Section__
{
	/** The current indentation level. */
	volatile int _indent;
	
	/** The character depth (characters used for the bullet). */
	volatile int _cdepth;
	
	/** Create new item entry? */
	volatile boolean _newitem =
		true;
	
	/**
	 * Initializes the base for lists.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionList__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
		
		// If the section before this one is a list then
		__Section__ sectionbefore = this._sectionbefore;
		if (sectionbefore instanceof __SectionList__)
		{
			__SectionList__ was = (__SectionList__)sectionbefore;
			this._indent = was._indent + 1 + was._cdepth;
		}
		
		// Otherwise, start a new list
		else
			this._indent = 1;
	}
	
	/**
	 * Prints the list characters.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	abstract void __listCharacters()
		throws IOException;
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If writing a new item, write it
		MarkdownWriter writer = this.writer;
		if (this._newitem)
		{
			// Add new line
			writer.__put('\n', true);
			
			// Indent with spaces first
			int indent = this._indent;
			for (int i = 0; i < indent; i++)
				writer.__put(' ', true);
			
			// Add list characters
			__listCharacters();
			
			// Add sapce
			writer.__put(' ', true);
			
			// Do not write any more new items
			this._newitem = false;
		}
		
		// Indent?
		if (writer._column == 0)
		{
			int indent = this._indent + 1 + this._cdepth;
			for (int i = 0; i < indent; i++)
				writer.__put(' ', true);
		}
		
		// Write normal character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/__SectionParagraph__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is for writing normal text that exists within a paragraph.
 *
 * @since 2016/10/02
 */
class __SectionParagraph__
	extends __Section__
{
	/** Just started the paragraph? */
	volatile boolean _juststarted =
		true;
	
	/**
	 * Initializes the paragraph.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionParagraph__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __endSection()
		throws IOException
	{
		super.__endSection();
		
		// Add newline after the first column
		MarkdownWriter writer = this.writer;
		if (writer._column > 0)
			writer.__put('\n', true);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __process(char __c)
		throws IOException
	{
		// If the paragraph just started then add a spacing newline before
		// its content
		MarkdownWriter writer = this.writer;
		if (this._juststarted)
		{
			// Write line
			writer.__put('\n', true);
			
			// No longer started
			this._juststarted = false;
		}
		
		// If this is whitespace then do not print it on the first column ever
		if (MarkdownWriter.__isWhitespace(__c) && writer._column == 0)
			return;
		
		// Write character
		if (__c > 0)
			writer.__put(__c, true);
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/__SectionUnorderedList__.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;

/**
 * This is the unordered list section which is used to place non-numbered
 * bullet point lists.
 *
 * @since 2016/10/02
 */
class __SectionUnorderedList__
	extends __SectionList__
{
	/**
	 * Initializes the unordered list section.
	 *
	 * @param __mkd The owning writer.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/02
	 */
	__SectionUnorderedList__(MarkdownWriter __mdw)
		throws IOException
	{
		super(__mdw);
		
		// Single character is used
		this._cdepth = 1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/10/02
	 */
	@Override
	void __listCharacters()
		throws IOException
	{
		this.writer.__put('*', true);
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/__Section__.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.markdownwriter;

import java.io.IOException;
import java.util.Deque;

/**
 * This is the base class for all sections within the markdown writer, this is
 * used to modify how data is written to the output file when it is written.
 *
 * The constructor for a section will automatically set itself as the newest
 * section and initialize it from a previous one.
 *
 * @since 2016/10/02
 */
abstract class __Section__
{
	/** The target writer. */
	protected final MarkdownWriter writer;
	
	/** The section that was at the top. */
	final __Section__ _sectionbefore;
	
	/** The current text style to use. */
	volatile MarkdownTextStyle _style =
		MarkdownTextStyle.NORMAL;
	
	/** The section header level. */
	volatile int _level;
	
	/**
	 * Initializes a new section.
	 *
	 * @param __mdw The writer where characters are placed.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/02
	 */
	__Section__(MarkdownWriter __mdw)
		throws IOException, NullPointerException
	{
		// Check
		if (__mdw == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.writer = __mdw;
		
		// Is there anything above this?
		__Section__ _sectionbefore = __mdw._section;
		this._sectionbefore = _sectionbefore;
		
		// If there is a section before this then end this
		if (_sectionbefore != null)
			_sectionbefore.__endSection();
		
		// Set new section
		__mdw._section = this;
		
		// Set some basic details
		this._level = (_sectionbefore == null ? 1 : _sectionbefore._level);
	}
	
	/**
	 * Puts the specified character into the section as if it were written.
	 *
	 * @param __c The character to place.
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	abstract void __process(char __c)
		throws IOException;
	
	/**
	 * This may be replaced by sub-classes to end the specified section.
	 *
	 * Classes should always call the super-class method first.
	 *
	 * @throws IOException On write errors.
	 * @since 2016/10/02
	 */
	void __endSection()
		throws IOException
	{
	}
}

Deleted runt/libs/markdown-writer/net/multiphasicapps/markdownwriter/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the markdown writer.
 *
 * @since 2016/09/13
 */

package net.multiphasicapps.markdownwriter;

Deleted runt/libs/springcoat-vm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 82dcdfbb-27da-48a6-87f7-7a0a8810360f
X-SquirrelJME-Error: BK
X-SquirrelJME-Name: SpringCoat Virtual Machine
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.2.0
X-SquirrelJME-Depends: tool-classfile tool-manifest-reader meep-swm 
 tool-profiler meep-midlet common-vm
X-SquirrelJME-Description: This is a SpringCoat virtual machine which 
 is an unoptimized pure interpreter aimed for the purpose of being an 
 educational stepping stone to other future virtual machines.
Microedition-Configuration: CLDC-1.8

Deleted runt/libs/springcoat-vm/META-INF/services/cc.squirreljme.vm.VMFactory.

1

-
cc.squirreljme.vm.springcoat.SpringCoatFactory

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArithmeticException.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a divide by zero occurs.
 *
 * @since 2018/12/04
 */
public class SpringArithmeticException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public SpringArithmeticException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/12/04
	 */
	public SpringArithmeticException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArithmeticException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayIndexOutOfBoundsException.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an invalid out of bounds index was accessed in an
 * array.
 *
 * @since 2018/09/16
 */
public class SpringArrayIndexOutOfBoundsException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayIndexOutOfBoundsException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArrayIndexOutOfBoundsException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObject.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * This is an object which acts as an array, which stores some kind of data.
 *
 * @since 2018/09/15
 */
public abstract class SpringArrayObject
	implements SpringObject
{
	/** The monitor for this array. */
	protected final SpringMonitor monitor =
		new SpringMonitor();
	
	/** The type of this object itself. */
	protected final SpringClass selftype;
	
	/** The component type. */
	protected final SpringClass component;
	
	/** The length of the array. */
	protected final int length;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public SpringArrayObject(SpringClass __self, SpringClass __cl, int __l)
		throws NullPointerException
	{
		if (__self == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK01 Attempt to allocate an array of a
		// negative size. (The length requested)}
		if (__l < 0)
			throw new SpringNegativeArraySizeException(
				String.format("BK01 %d", __l));
		
		this.selftype = __self;
		this.component = __cl;
		this.length = __l;
	}
	
	/**
	 * Returns the raw backing array.
	 *
	 * @return The array.
	 * @since 2018/11/19
	 */
	public abstract Object array();
	
	/**
	 * Sets the index to the specified value.
	 *
	 * @param <C> The type of value to get.
	 * @param __cl The type of value to get.
	 * @param __dx The index to set.
	 * @return The contained value.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringArrayStoreException If the array cannot store the given
	 * type.
	 * @throws SpringArrayIndexOutOfBoundsException If the index is not within
	 * bounds.
	 * @since 2018/09/16
	 */
	public abstract <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException;
	
	/**
	 * Sets the index to the specified value.
	 *
	 * @param __dx The index to set.
	 * @param __v The value to set.
	 * @throws SpringArrayStoreException If the array cannot store the given
	 * type.
	 * @throws SpringArrayIndexOutOfBoundsException If the index is not within
	 * bounds.
	 * @since 2018/09/16
	 */
	public abstract void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		return this.monitor;
	}
	
	/**
	 * Returns the length of this array.
	 *
	 * @return The array length.
	 * @since 2018/09/16
	 */
	public final int length()
	{
		return this.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s@%08x", this.selftype.name(),
				System.identityHashCode(this))));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringClass type()
	{
		return this.selftype;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectBoolean.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
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































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a boolean array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectBoolean
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final boolean[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectBoolean(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new boolean[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectBoolean(SpringClass __self, SpringClass __cl,
		boolean[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf((this._elements[__dx] ? 1 : 0));
		}
		
		// {@squirreljme.error BK02 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK02 %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] =
				((((((Integer)__v).intValue()) & 0x1) != 0) ? true : false);
		}
		
		// {@squirreljme.error BK03 Could not set the index in the boolean
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK03", e);
		}
		
		// {@squirreljme.error BK04 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK04 %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectByte.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a byte array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectByte
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final byte[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectByte(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new byte[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectByte(SpringClass __self, SpringClass __cl,
		byte[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK05 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK05 %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).byteValue();
		}
		
		// {@squirreljme.error BK06 Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK06", e);
		}
		
		// {@squirreljme.error BK07 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK07 %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectChar.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a char array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectChar
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final char[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectChar(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new char[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectChar(SpringClass __self, SpringClass __cl,
		char[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK08 Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK08 %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = (char)((Integer)__v).intValue();
		}
		
		// {@squirreljme.error BK09 Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK09", e);
		}
		
		// {@squirreljme.error BK0a Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0a %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectDouble.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a double array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectDouble
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final double[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectDouble(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new double[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectDouble(SpringClass __self, SpringClass __cl,
		double[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Double.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0b Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0b %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Double)__v).doubleValue();
		}
		
		// {@squirreljme.error BK0c Could not set the index in the double
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0c", e);
		}
		
		// {@squirreljme.error BK0d Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0d %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectFloat.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a float array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectFloat
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final float[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectFloat(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new float[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectFloat(SpringClass __self, SpringClass __cl,
		float[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Float.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0e Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0e %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Float)__v).floatValue();
		}
		
		// {@squirreljme.error BK0f Could not set the index in the float
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0f", e);
		}
		
		// {@squirreljme.error BK0g Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0g %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectGeneric.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
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
























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.PrimitiveType;

/**
 * Generic array that can store any type.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectGeneric
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final Object[] _elements;
	
	/** The last class which was checked for compatibility. */
	private SpringClass _lastvalid;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public SpringArrayObjectGeneric(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		Object[] elements;
		this._elements = (elements = new Object[__l]);
		
		// Determine the initial value to use
		PrimitiveType type = __cl.name().primitiveType();
		Object v;
		if (type == null)
			v = SpringNullObject.NULL;
		else
			switch (type)
			{
				case BOOLEAN:
				case BYTE:
				case SHORT:
				case CHARACTER:
				case INTEGER:
					v = Integer.valueOf(0);
					break;
				
				case LONG:
					v = Long.valueOf(0);
					break;
				
				case FLOAT:
					v = Float.valueOf(0);
					break;
				
				case DOUBLE:
					v = Double.valueOf(0);
					break;
				
				default:
					throw new todo.OOPS();
			}
		
		// Set all elements to an initial value depending on the type
		// Set all 
		for (int i = 0; i < __l; i++)
			elements[i] = v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Faster to just have the host VM do bounds check
		try
		{
			return __cl.cast(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0h Out of bounds access to array.
		// (The index; The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0h %d %d", __dx, this.length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		try
		{
			// This is a cached type for setting because an array of one type
			// will usually in most cases set with objects which are compatible
			// so the rather involved instanceof check will take awhile and
			// compound for setting single elements.
			SpringClass lastvalid = this._lastvalid,
				wouldset = null;
			
			// If the input value is an object
			boolean docheck;
			if (__v instanceof SpringObject)
			{
				// If a check is done, then 
				wouldset = ((SpringObject)__v).type();
				
				// Only if the types differ would we actually check
				docheck = (wouldset != lastvalid);
			}
			
			// Otherwise always do a check since we do not really know the
			// class type here
			else
				docheck = true;
			
			// Performing the check for cache?
			if (docheck)
			{
				// {@squirreljme.error BK0i The specified type is not
				// compatible with the values this array stores. (The input
				// value; The component type)}
				SpringClass component = this.component;
				if (!component.isCompatible(__v))
					throw new SpringArrayStoreException(String.format(
						"BK0i %s %s", __v, component));
				
				// Next validity check would be set if done on an object
				// Ignore setting it back to null, if one was previously
				// valid
				if (wouldset != null)
					this._lastvalid = wouldset;
			}
			
			// Set
			this._elements[__dx] = __v;
		}
		
		// {@squirreljme.error BK0j Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0j %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectInteger.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by an int array.
 *
 * @since 2018/11/04
 */
public final class SpringArrayObjectInteger
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final int[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/04
	 */
	public SpringArrayObjectInteger(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new int[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectInteger(SpringClass __self, SpringClass __cl,
		int[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0k Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0k %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).intValue();
		}
		
		// {@squirreljme.error BK0l Could not set the index in the char
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0l", e);
		}
		
		// {@squirreljme.error BK0m Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0m %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectLong.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a long array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectLong
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final long[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectLong(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new long[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectLong(SpringClass __self, SpringClass __cl,
		long[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Long.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0n Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0n %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Long)__v).longValue();
		}
		
		// {@squirreljme.error BK0o Could not set the index in the long
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0o", e);
		}
		
		// {@squirreljme.error BK0p Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0p %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayObjectShort.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
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






























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Array backed by a short array.
 *
 * @since 2018/11/14
 */
public final class SpringArrayObjectShort
	extends SpringArrayObject
{
	/** Elements in the array. */
	private final short[] _elements;
	
	/**
	 * Initializes the array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __l The array length.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/11/14
	 */
	public SpringArrayObjectShort(SpringClass __self, SpringClass __cl,
		int __l)
		throws NullPointerException
	{
		super(__self, __cl, __l);
		
		// Initialize elements
		this._elements = new short[__l];
	}
	
	/**
	 * Wraps the native array.
	 *
	 * @param __self The self type.
	 * @param __cl The component type.
	 * @param __a The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/18
	 */
	public SpringArrayObjectShort(SpringClass __self, SpringClass __cl,
		short[] __a)
		throws NullPointerException
	{
		super(__self, __cl, __a.length);
		
		this._elements = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/19
	 */
	@Override
	public final Object array()
	{
		return this._elements;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	public final <C> C get(Class<C> __cl, int __dx)
		throws NullPointerException, SpringArrayIndexOutOfBoundsException
	{
		// Read value
		try
		{
			return (C)Integer.valueOf(this._elements[__dx]);
		}
		
		// {@squirreljme.error BK0q Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0q %d %d", __dx, length), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/14
	 */
	@Override
	public final void set(int __dx, Object __v)
		throws SpringArrayStoreException, SpringArrayIndexOutOfBoundsException
	{
		// Try setting
		try
		{
			this._elements[__dx] = ((Integer)__v).shortValue();
		}
		
		// {@squirreljme.error BK0r Could not set the index in the short
		// array.}
		catch (ClassCastException e)
		{
			throw new SpringArrayStoreException("BK0r", e);
		}
		
		// {@squirreljme.error BK0s Out of bounds access to array. (The index;
		// The length of the array)}
		catch (IndexOutOfBoundsException e)
		{
			throw new SpringArrayIndexOutOfBoundsException(
				String.format("BK0s %d %d", __dx, this.length), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringArrayStoreException.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an invalid value was attempted to be stored into an
 * array.
 *
 * @since 2018/09/16
 */
public class SpringArrayStoreException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/16
	 */
	public SpringArrayStoreException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ArrayStoreException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringClass.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795



























































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.Constants;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.HasAccessibleFlags;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This is a representation of a class file as it is seen by the virtual
 * machine, it is intended to remain simple and only refer to what is needed
 * for the machine to run.
 *
 * @since 2018/07/21
 */
public final class SpringClass
	implements HasAccessibleFlags
{
	/** The name of this class. */
	protected final ClassName name;
	
	/** The class file data. */
	protected final ClassFile file;
	
	/** The super class. */
	protected final SpringClass superclass;
	
	/** The number of instance fields that exist. */
	protected final int instancefieldcount;
	
	/** The special class index. */
	protected final int specialindex;
	
	/** The dimentions of this class. */
	protected final int dimensions;
	
	/** The component type. */
	protected final SpringClass component;
	
	/** The JAR this class is in. */
	protected final String injar;
	
	/** The virtualized size of instances for this class. */
	protected final int instancesize;
	
	/** Interface classes. */
	private final SpringClass[] _interfaceclasses;
	
	/** Methods which exist in this class, includes statics for this only. */
	private final Map<MethodNameAndType, SpringMethod> _methods =
		new HashMap<>();
	
	/** Non-virtual instance methods. */
	private final Map<MethodNameAndType, SpringMethod> _nonvirtmethods =
		new HashMap<>();
	
	/** Fields which exist in this class, only includes this class fields */
	private final Map<FieldNameAndType, SpringField> _fields =
		new HashMap<>();
	
	/** The table of fields defined in this class, includes super classes. */
	private final SpringField[] _fieldtable;
	
	/** Has this class been initialized? */
	private volatile boolean _initialized;
	
	/**
	 * Initializes the spring class.
	 *
	 * @param __super The super class of this class.
	 * @param __interfaces The the interfaces this class implements.
	 * @param __cf The class file for this class.
	 * @param __si The special class index.
	 * @param __ct The component type.
	 * @param __injar The JAR this class is in.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/07/21
	 */
	SpringClass(SpringClass __super, SpringClass[] __interfaces,
		ClassFile __cf, int __si, SpringClass __ct, String __injar)
		throws NullPointerException
	{
		if (__interfaces == null || __cf == null)
			throw new NullPointerException("NARG");
		
		ClassName name = __cf.thisName();
		this.name = name;
		this.specialindex = __si;
		this.injar = __injar;
		this.file = __cf;
		this.superclass = __super;
		this.component = __ct;
		this.dimensions = name.dimensions();
		
		// Check
		this._interfaceclasses = (__interfaces = __interfaces.clone());
		for (SpringClass x : __interfaces)
			if (x == null)
				throw new NullPointerException("NARG");
		
		// Used for method location
		String filename = __cf.sourceFile();
		
		// Go through and initialize methods declared in this class
		Map<MethodNameAndType, SpringMethod> nvmeths = this._nonvirtmethods;
		Map<MethodNameAndType, SpringMethod> methods = this._methods;
		for (Method m : __cf.methods())
		{
			SpringMethod sm;
			if (null != methods.put(m.nameAndType(),
				(sm = new SpringMethod(name, m, filename))))
			{
				// {@squirreljme.error BK0t Duplicated method in class. (The
				// method)}
				throw new SpringClassFormatException(name, String.format(
					"BK0t %s", m.nameAndType()));
			}
			
			// Store only instance methods which are not static
			if (!m.flags().isStatic())
				nvmeths.put(m.nameAndType(), sm);
		}
		
		// Fields that are defined in super classes must be allocated, stored,
		// and indexed appropriately so that way casting between types and
		// accessing other fields is actually valid
		int superfieldcount = (__super == null ? 0 :
			__super.instancefieldcount);
		int instancefieldcount = superfieldcount;
		
		// Calculate the instance size
		this.instancesize = (__super == null ? Constants.OBJECT_BASE_SIZE :
			(name.dimensions() > 0 ? Constants.ARRAY_BASE_SIZE :
			__super.instancesize + (instancefieldcount * 4)));
		
		// Initialize all of the fields as needed
		Map<FieldNameAndType, SpringField> fields = this._fields;
		List<SpringField> instfields = new ArrayList<>(fields.size());
		for (Field f : __cf.fields())
		{
			boolean isinstance = f.flags().isInstance();
			
			// {@squirreljme.error BK0u Duplicated field in class. (The field)}
			SpringField sf;
			if (null != fields.put(f.nameAndType(),
				(sf = new SpringField(name, f,
					(isinstance ? instancefieldcount++ : -1)))))
				throw new SpringClassFormatException(name, String.format(
					"BK0u %s", f.nameAndType()));
			
			// Used to build our part of the field table
			if (isinstance)
				instfields.add(sf);
		}
		
		// Each field is referenced by an index rather than a map, this is
		// more efficient for instances and additionally still allows for
		// sub-classes to declare fields as needed.
		SpringField[] fieldtable = new SpringField[instancefieldcount];
		this._fieldtable = fieldtable;
		
		// Copy the super class field table, since technically all of the
		// fields in the super class are a part of this class.
		if (__super != null)
		{
			SpringField[] supertable = __super._fieldtable;
			for (int i = 0; i < superfieldcount; i++)
				fieldtable[i] = supertable[i];
		}
		
		// Store all of the instance fields
		for (int i = superfieldcount, p = 0, pn = instfields.size();
			p < pn; i++, p++)
			fieldtable[i] = instfields.get(p);
		
		// Used to quickly determine how big to set storage for a class
		this.instancefieldcount = instancefieldcount;
		
		// Go through super and interfaces and add non-static methods which
		// exist in sub-classes
		for (int i = 0, n = __interfaces.length; i <= n; i++)
		{
			// The class to look within
			SpringClass lookin = (i == 0 ? __super : __interfaces[i - 1]);
			if (lookin == null)
				continue;
			
			// Go through class methods
			for (Map.Entry<MethodNameAndType, SpringMethod> e :
				lookin._methods.entrySet())
			{
				MethodNameAndType k = e.getKey();
				SpringMethod v = e.getValue();
				
				// Ignore initializer methods, and private methods
				if (v.isInstanceInitializer() ||
					v.isStaticInitializer() || v.flags().isPrivate())
					continue;
				
				// If the method does not exist in the table then it gets added
				// otherwise it is effectively replaced
				if (!methods.containsKey(k))
					methods.put(k, v);
			}
		}
		
		// Debug
		/*todo.DEBUG.note("Class %s (size=%d, fields=%d, methods=%d).", name,
			instancefieldcount,
			fields.size(),
			methods.size());*/
	}
	
	/**
	 * Returns the component type of this class.
	 *
	 * @return The component type.
	 * @since 2018/09/27
	 */
	public final SpringClass componentType()
	{
		return this.component;
	}
	
	/**
	 * Returns the number of array dimensions.
	 *
	 * @return The number of dimensions.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		return this.name.dimensions();
	}
	
	/**
	 * Returns the fields which are only declared in this class.
	 *
	 * @return The fields only declared in this class.
	 * @since 2018/09/09
	 */
	public final SpringField[] fieldsOnlyThisClass()
	{
		Map<FieldNameAndType, SpringField> fields = this._fields;
		return fields.values().<SpringField>toArray(
			new SpringField[fields.size()]);
	}
	
	/**
	 * Returns the table of fields used for this class.
	 *
	 * @return The field table used for this class.
	 * @since 2018/09/16
	 */
	public final SpringField[] fieldTable()
	{
		return this._fieldtable.clone();
	}
	
	/**
	 * Returns the associated class file.
	 *
	 * @return The class file.
	 * @since 2018/09/08
	 */
	public final ClassFile file()
	{
		return this.file;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final ClassFlags flags()
	{
		return this.file.flags();
	}
	
	/**
	 * Returns the JAR this class is in.
	 *
	 * @return The JAR this class is in.
	 * @since 2018/10/07
	 */
	public final String inJar()
	{
		return this.injar;
	}
	
	/**
	 * Returns the number of instance fields this class stores. This is for
	 * the most part the size of the given class.
	 *
	 * @return The number of instance fields this class stores.
	 * @since 2018/09/08
	 */
	public final int instanceFieldCount()
	{
		return this.instancefieldcount;
	}
	
	/**
	 * Returns the interfaces that this class implements.
	 *
	 * @return The implemented interfaces.
	 * @since 2018/09/08
	 */
	public final SpringClass[] interfaceClasses()
	{
		return this._interfaceclasses.clone();
	}
	
	/**
	 * Is this an array?
	 *
	 * @return If this is an array.
	 * @since 2018/09/27
	 */
	public final boolean isArray()
	{
		return this.name.isArray();
	}
	
	/**
	 * Checks if this class can be assigned from the target class, that is
	 * {@code this = (ThisClass)__o}.
	 *
	 * This is the same as {@link Class#isInstance(Object)} except it works
	 * only on class representations.
	 *
	 * @param __o The other class to check.
	 * @return If the other class can be assigned as this class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final boolean isAssignableFrom(SpringClass __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Go through target superclasses to find this class
		for (SpringClass r = __o; r != null; r = r.superclass)
		{
			if (r == this)
				return true;
		
			// Go through interfaces for the class to find this class
			for (SpringClass i : r._interfaceclasses)
				if (this.isAssignableFrom(i))
					return true;
		}
		
		// Need to cast from one array type to another
		int thisdims = this.dimensions(),
			otherdims = __o.dimensions();
		if (thisdims > 0)
		{
			// If this is an array and the other type is an array with the same
			// number of dimensions, then compare the base type so that say
			// Number[] is assignable from Integer[].
			if (otherdims == thisdims)
				if (this.__rootType().isAssignableFrom(__o.__rootType()))
					return true;
			
			// We can cast down to Object array types if there are less
			// dimensions ([[[[Integer -> [Object)
			if (this.__rootType().isObjectClass() && thisdims < otherdims)
				return true;
		}
		
		return false;
	}
	
	/**
	 * Checks if the given value is compatible with this class.
	 *
	 * @param __v The value to check.
	 * @return If it is compatible or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final boolean isCompatible(Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Primitive must match standard promoted type
		ClassName name = this.name;
		if (name.isPrimitive())
			switch (name.toString())
			{
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
					return (__v instanceof Integer);
				
				case "long":
					return (__v instanceof Long);
				
				case "float":
					return (__v instanceof Float);
					
				case "double":
					return (__v instanceof Double);
				
				default:
					throw new todo.OOPS();
			}
			
		// Would be an assignable reference
		else if (__v instanceof SpringNullObject)
			return true;
		
		// Not primitive type, must be assignable
		else if (__v instanceof SpringObject)
			return this.isAssignableFrom(((SpringObject)__v).type());
		
		// Unknown
		else
			throw new todo.OOPS();
	}
	
	/**
	 * Has this class been initialized?
	 *
	 * @return If the class has been initialized.
	 * @since 2018/09/08
	 */
	public final boolean isInitialized()
	{
		return this._initialized;
	}
	
	/**
	 * Is this the object class?
	 *
	 * @return If this is the object class.
	 * @since 2018/11/04
	 */
	public final boolean isObjectClass()
	{
		return this.name.toString().equals("java/lang/Object");
	}
	
	/**
	 * Checks if the given class is a super class of the this class.
	 *
	 * @param __cl The class to check.
	 * @return {@code true} if it is a superclass.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean isSuperClass(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		for (SpringClass r = this.superclass; r != null; r = r.superClass())
			if (r == __cl)
				return true;
		
		return true;
	}
	
	/**
	 * Looks up the method which acts as the default constructor for instance
	 * objects.
	 *
	 * @return The default constructor for the object or {@code null} if there
	 * is none.
	 * @since 2018/09/08
	 */
	public final SpringMethod lookupDefaultConstructor()
	{
		try
		{
			return this.lookupMethodNonVirtual(new MethodNameAndType("<init>",
				"()V"));
		}
		catch (SpringNoSuchMethodException e)
		{
			return null;
		}
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __name The name of the field.
	 * @param __desc The type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/11/19
	 */
	public final SpringField lookupField(boolean __static, String __name,
		String __desc)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupField(__static,
			new FieldName(__name), new FieldDescriptor(__desc));
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __name The name of the field.
	 * @param __desc The type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringField lookupField(boolean __static, FieldName __name,
		FieldDescriptor __desc)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupField(__static,
			new FieldNameAndType(__name, __desc));
	}
	
	/**
	 * Locates the given field in this class.
	 *
	 * @param __static Is the field static?
	 * @param __nat The name and type of the field.
	 * @return The field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringField lookupField(boolean __static,
		FieldNameAndType __nat)
		throws NullPointerException, SpringNoSuchFieldException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up field %s::%s (static=%b)", this.name,
			__nat, __static);*/
		
		// Field lookup starts at the current class, but also goes to the
		// super class for non-statics
		SpringField rv = this._fields.get(__nat);
		if (rv == null)
		{
			// Lookup non-static fields in super class
			if (!__static)
			{
				SpringClass sc = this.superclass;
				if (sc != null)
					return sc.lookupField(__static, __nat);
			}
			
			// {@squirreljme.error BK0v The specified field does not exist.
			// (The class which was looked in; The name and type of the field)}
			throw new SpringNoSuchFieldException(String.format("BK0v %s %s",
				this.name, __nat));
		}
		
		// {@squirreljme.error BK0w The specified field exists in the class
		// however it does not match being static. (The class the field is in;
		// The name and type of the method; If a static field was requested)}
		if (rv.isStatic() != __static)
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK0w %s %s", this.name, __nat, __static));
		
		return rv;
	}
	
	/**
	 * Locates the given method in the class.
	 *
	 * @param __static Is the method static?
	 * @param __name The name of the method.
	 * @param __desc The descriptor of the method.
	 * @return The method which was found.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * does not match staticness.
	 * @throws SpringNoSuchMethodException If the specified method does not
	 * exist.
	 * @since 2018/09/03
	 */
	public final SpringMethod lookupMethod(boolean __static, MethodName __name,
		MethodDescriptor __desc)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__name == null || __desc == null)
			throw new NullPointerException("NARG");
		
		return this.lookupMethod(__static, new MethodNameAndType(__name,
			__desc));
	}
	
	/**
	 * Locates the given method in the class.
	 *
	 * @param __static Is the method static?
	 * @param __nat The name and type of the method.
	 * @return The method which was found.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * does not match staticness.
	 * @throws SpringNoSuchMethodException If the specified method does not
	 * exist.
	 * @since 2018/09/03
	 */
	public final SpringMethod lookupMethod(boolean __static,
		MethodNameAndType __nat)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up method %s::%s (static=%b)", this.name,
			__nat, __static);*/
		
		// {@squirreljme.error BK0x The specified method does not exist.
		// (The class which was looked in; The name and type of the method)} 
		SpringMethod rv = this._methods.get(__nat);
		if (rv == null)
			throw new SpringNoSuchMethodException(String.format("BK0x %s %s",
				this.name, __nat));
		
		// {@squirreljme.error BK0y The specified method exists in the class
		// however it does not match being static. (The class the method is in;
		// The name and type of the method; If a static method was requested)}
		if (rv.isStatic() != __static)
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK0y %s %s %b", this.name, __nat, __static));
		
		return rv;
	}
	
	/**
	 * Looks up the specified method non-virtually.
	 *
	 * @param __nat The name and type.
	 * @return The target method.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target method
	 * is static.
	 * @throws SpringNoSuchMethodException If no method exists.
	 * @since 2018/09/09
	 */
	public final SpringMethod lookupMethodNonVirtual(MethodNameAndType __nat)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchMethodException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Looking up non-virtual method %s::%s.", this.name,
			__nat);*/
		
		// {@squirreljme.error BK0z The specified method does not exist, when
		// non-virtual lookup is used. (The class which was looked in; The
		// name and type of the method)} 
		SpringMethod rv = this._nonvirtmethods.get(__nat);
		if (rv == null)
			throw new SpringNoSuchMethodException(String.format("BK0z %s %s",
				this.name, __nat));
		
		// {@squirreljme.error BK10 Non-virtual method lookup found a static
		// method. (The class being looked in; The name and type requested)}
		if (rv.flags().isStatic())
			throw new SpringIncompatibleClassChangeException(String.format(
				"BK10 %s %s", this.name, __nat));
		
		return rv;
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2018/09/08
	 */
	public final ClassName name()
	{
		return this.name;
	}
	
	/**
	 * Sets the class as initialized.
	 *
	 * @throws SpringVirtualMachineException If the class has already been
	 * initialized.
	 * @since 2018/09/08
	 */
	public final void setInitialized()
		throws SpringVirtualMachineException
	{
		// {@squirreljme.error BK11 Class attempted to be initialized twice.
		// (This class)}
		if (this._initialized)
			throw new SpringVirtualMachineException(String.format(
				"BK11 %s", this.name));
		
		this._initialized = true;
	}
	
	/**
	 * Returns the special class index.
	 *
	 * @return The special class index.
	 * @since 2018/09/20
	 */
	public final int specialIndex()
	{
		return this.specialindex;
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super class of this class.
	 * @since 2018/09/08
	 */
	public final SpringClass superClass()
	{
		return this.superclass;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
	
	/**
	 * Returns the root type, the base of the component.
	 *
	 * @return The root type of this type.
	 * @since 2018/09/27
	 */
	private final SpringClass __rootType()
	{
		SpringClass rv = this;
		for (SpringClass r = this; r != null; r = r.component)
			rv = r;
		return rv;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringClassCastException.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an attempt is made to cast from one class type to
 * another.
 *
 * @since 2018/09/15
 */
public class SpringClassCastException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringClassCastException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringClassCastException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/ClassCastException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringClassFormatException.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
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
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;

/**
 * This is thrown when the format of a class is not correct, it is invalid.
 *
 * @since 2018/08/05
 */
public class SpringClassFormatException
	extends SpringException
{
	/** The name of the class. */
	protected final ClassName name;
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __cn The class which was not valid.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __m The message.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, String __m)
		throws NullPointerException
	{
		super(__m);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __m The message.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, String __m,
		Throwable __c)
		throws NullPointerException
	{
		super(__m, __c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __cn The class which was not valid.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassFormatException(ClassName __cn, Throwable __c)
		throws NullPointerException
	{
		super(__c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Returns the name of the class.
	 *
	 * @return The class name.
	 * @since 2018/08/05
	 */
	public final ClassName name()
	{
		return this.name;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringClassLoader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294






































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.vm.VMClassLibrary;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This class acts as the equivalent to {@code ClassLoader} in that it manages
 * the class path and the eventual loading of classes.
 *
 * @since 2018/09/01
 */
public final class SpringClassLoader
{
	/** Class loading lock. */
	protected final Object loaderlock =
		new Object();
	
	/** The class path for the machine. */
	private final VMClassLibrary[] _classpath;
	
	/** The classes which have been loaded by the virtual machine. */
	private final Map<ClassName, SpringClass> _classes =
		new HashMap<>();
	
	/** Next special class index. */
	private int _nexcsi =
		1;
	
	/**
	 * Initializes the class loader.
	 *
	 * @param __classpath The classpath.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	public SpringClassLoader(VMClassLibrary... __classpath)
		throws NullPointerException
	{
		for (VMClassLibrary b : __classpath = (__classpath == null ?
			new VMClassLibrary[0] : __classpath.clone()))
			if (b == null)
				throw new NullPointerException("NARG");
		this._classpath = __classpath;
	}
	
	/**
	 * Returns the library that is used for booting, the main entry JAR.
	 *
	 * @return The boot library.
	 * @since 2018/09/13
	 */
	public final VMClassLibrary bootLibrary()
	{
		VMClassLibrary[] classpath = this._classpath;
		return classpath[classpath.length - 1];
	}
	
	/**
	 * Returns the class loading lock.
	 *
	 * @return The class loading lock.
	 * @since 2018/09/08
	 */
	public final Object classLoadingLock()
	{
		return this.loaderlock;
	}
	
	/**
	 * Returns the class path.
	 *
	 * @return The classpath.
	 * @since 2018/12/06
	 */
	public final VMClassLibrary[] classPath()
	{
		return this._classpath.clone();
	}
	
	/**
	 * Finds the specified library.
	 *
	 * @param __n The library to find.
	 * @return The given library or {@code null} if it was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	public final VMClassLibrary findLibrary(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		for (VMClassLibrary lib : this._classpath)
			if (__n.equals(lib.name()))
				return lib;
		
		return null;
	}
	
	/**
	 * Loads the specified class.
	 *
	 * @param __cn The name of the class to load.
	 * @return The loaded class.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringClassFormatException If the class is not formatted
	 * properly.
	 * @throws SpringClassNotFoundException If the class was not found.
	 * @since 2018/09/01
	 */
	public final SpringClass loadClass(ClassName __cn)
		throws NullPointerException, SpringClassFormatException,
			SpringClassNotFoundException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Lock on classes
		Map<ClassName, SpringClass> classes = this._classes;
		synchronized (this.loaderlock)
		{
			// If the class has already been initialized, use that
			SpringClass rv = classes.get(__cn);
			if (rv != null)
				return rv;
			
			// Debug
			/*todo.DEBUG.note("Loading class `%s`...", __cn);*/
			
			// Load class file for this class
			ClassFile cf;
			String[] injar = new String[1];
			try
			{
				cf = this.loadClassFile(__cn, injar);
			}
			catch (InvalidClassFormatException e)
			{
				// {@squirreljme.error BK12 Could not load class. (The class
				// to load)}
				throw new InvalidClassFormatException(
					String.format("BK12 %s", __cn), e);
			}
			
			// Load the super class
			ClassName supername = cf.superName();
			SpringClass superclass = (supername == null ? null :
				this.loadClass(supername));
			
			// Load any interfaces
			ClassName[] interfacenames = cf.interfaceNames().toArray();
			int numinterfaces = interfacenames.length;
			SpringClass[] interfaceclasses = new SpringClass[numinterfaces];
			for (int i = 0; i < numinterfaces; i++)
				interfaceclasses[i] = this.loadClass(interfacenames[i]);
			
			// Component?
			SpringClass component = null;
			if (__cn.isArray())
				component = this.loadClass(__cn.componentType());
			
			// Load class information
			rv = new SpringClass(superclass, interfaceclasses, cf,
				this._nexcsi++, component, injar[0]);
			
			// Store for later use
			classes.put(__cn, rv);
			
			return rv;
		}
	}
	
	/**
	 * This goes through the classpath and loads the specified class file for
	 * the given class.
	 *
	 * @param __cn The class to load.
	 * @param __ij The input JAR file for the class.
	 * @return The loaded class file data.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringClassFormatException If the class is not formatted
	 * properly.
	 * @throws SpringClassNotFoundException If the class was not found.
	 * @since 2018/09/01
	 */
	public final ClassFile loadClassFile(ClassName __cn, String[] __ij)
		throws NullPointerException, SpringClassFormatException,
			SpringClassNotFoundException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Loading class file `%s`...", __cn);*/
		
		// If this is an array type use virtual class representation
		if (__cn.isPrimitive() || __cn.isArray())
			return ClassFile.special(__cn.field());
		
		// This is the class that is read, in binary form
		String fileform = __cn.toString() + ".class";
		
		// Otherwise we need to go through every single binary to find
		// the class we want, which can take awhile
		byte[] data = null;
		for (VMClassLibrary b : this._classpath)
			try (InputStream in = b.resourceAsStream(fileform))
			{
				// Class or file does not exist
				if (in == null)
					continue;
				
				// Read in the data
				byte[] buf = new byte[512];
				try (ByteArrayOutputStream baos =
					new ByteArrayOutputStream(1024))
				{
					for (;;)
					{
						int rc = in.read(buf);
						
						if (rc < 0)
						{
							baos.flush();
							data = baos.toByteArray();
							break;
						}
						
						baos.write(buf, 0, rc);
					}
				}
				
				// Record the binary
				if (__ij != null && __ij.length > 0)
					__ij[0] = b.name();
				
				break;
			}
			catch (IOException e)
			{
				// {@squirreljme.error BK13 Failed to read from the class
				// path.}
				throw new SpringException("BK13", e);
			}
		
		// {@squirreljme.error BK14 Could not locate the specified class.
		// (The class which was not found; The class file which was
		// attempted to be located)}
		if (data == null)
			throw new SpringClassNotFoundException(__cn, String.format(
				"BK14 %s %s", __cn, fileform));
		
		// Decode class file
		ClassFile cf;
		try (ByteArrayInputStream bais = new ByteArrayInputStream(data))
		{
			return ClassFile.decode(bais);
		}
		catch (IOException e)
		{
			// {@squirreljme.error BK15 Could not read from the source
			// class file. (The class being read)}
			throw new SpringVirtualMachineException(String.format(
				"BK15 %s", __cn), e);
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error BK16 The class is not formatted
			// correctly. (The class being read)}
			throw new SpringClassFormatException(__cn, String.format(
				"BK16 %s", __cn), e);
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringClassNotFoundException.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
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
















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;

/**
 * This is thrown when the specified class could not be found.
 *
 * @since 2018/08/05
 */
public class SpringClassNotFoundException
	extends SpringException
{
	/** The name of the class. */
	protected final ClassName name;
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __cn The class which was not found.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __m The message.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, String __m)
		throws NullPointerException
	{
		super(__m);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __m The message.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, String __m,
		Throwable __c)
		throws NullPointerException
	{
		super(__m, __c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __cn The class which was not found.
	 * @param __c The cause.
	 * @throws NullPointerException If no class was specified.
	 * @since 2018/08/05
	 */
	public SpringClassNotFoundException(ClassName __cn, Throwable __c)
		throws NullPointerException
	{
		super(__c);
		
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.name = __cn;
	}
	
	/**
	 * Returns the name of the class.
	 *
	 * @return The class name.
	 * @since 2018/08/05
	 */
	public final ClassName name()
	{
		return this.name;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringCoatFactory.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


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.vm.VirtualMachine;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMException;
import cc.squirreljme.vm.VMFactory;
import cc.squirreljme.vm.VMSuiteManager;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.profiler.ProfilerSnapshot;

/**
 * Factory which creates instances of the SpringCoat virtual machine.
 *
 * @since 2018/11/17
 */
public class SpringCoatFactory
	extends VMFactory
{
	/**
	 * Initializes the factory.
	 *
	 * @since 2018/11/17
	 */
	public SpringCoatFactory()
	{
		super("springcoat");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	protected VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Create a new instance of the VM
		SpringTaskManager tm = new SpringTaskManager(__sm, __ps, __sprops);
		return new SpringMachine(__sm, new SpringClassLoader(__cp),
			tm, __maincl, __ismid, -1,
			__gd, __ps, tm.nativedisplay, __sprops, __args);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringConvertableThrowable.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This interface describes any throwable which may be converted.
 *
 * @since 2018/12/04
 */
public interface SpringConvertableThrowable
{
	/**
	 * Returns the message.
	 *
	 * @return The message.
	 * @since 2018/12/04
	 */
	public abstract String getMessage();
	
	/**
	 * Returns the class this throwable converts to.
	 *
	 * @return The target class this converts to.
	 * @since 2018/12/04
	 */
	public abstract String targetClass();
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringDisplayEventCallback.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.NativeDisplayEventCallback;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This is the callback to use which calls the given spring object, this is
 * needed by the native display.
 *
 * @since 2018/12/03
 */
public final class SpringDisplayEventCallback
	implements NativeDisplayEventCallback
{
	/** The class used for callback. */
	private static final ClassName _CALLBACK_CLASS =
		new ClassName("cc/squirreljme/runtime/cldc/asm/" +
			"NativeDisplayEventCallback");
	
	/** The object to call into. */
	protected final SpringObject object;
	
	/** The thread to use. */
	protected final SpringThread thread;
	
	/** The worker for threads. */
	protected final SpringThreadWorker worker;
	
	/**
	 * Initializes the callback to call the given object.
	 *
	 * @param __m The machine owning this.
	 * @param __o The object to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/03
	 */
	public SpringDisplayEventCallback(SpringMachine __m, SpringObject __o)
		throws NullPointerException
	{
		if (__m == null || __o == null)
			throw new NullPointerException("NARG");
		
		// Set object to call
		this.object = __o;
		
		// Setup thread
		SpringThread thread = __m.createThread("SpringCoat-LCDUIThread");
		SpringThreadWorker worker = new SpringThreadWorker(__m, thread, false);
		
		// Need to initialize a thread object because this thread has to be
		// registered with the runtime in order for programs to operate
		// correctly on it, even though it is a weird thread
		// This is always registered until it is explicitely not registered
		SpringObject fakethread = worker.newInstance(
			new ClassName("java/lang/Thread"), new MethodDescriptor(
				"(ILjava/lang/String;)V"), thread.id,
				worker.asVMObject(thread.name));
		
		// Store
		this.thread = thread;
		this.worker = worker;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void command(int __d, int __c)
	{
		this.__exec("command", "(II)V", __d, __c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void exitRequest(int __d)
	{
		this.__exec("exitRequest", "(I)V", __d);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void keyEvent(int __d, int __ty, int __kc, int __ch,
		int __time)
	{
		this.__exec("keyEvent", "(IIIII)V", __d, __ty, __kc, __ch, __time);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/10
	 */
	@Override
	public final void lostCallback()
	{
		this.__exec("lostCallback", "()V");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void paintDisplay(int __d, int __x, int __y,
		int __w, int __h)
	{
		this.__exec("paintDisplay", "(IIIII)V", __d, __x, __y, __w, __h);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void pointerEvent(int __d, int __ty, int __x, int __y,
		int __time)
	{
		this.__exec("pointerEvent", "(IIIII)V", __d, __ty, __x, __y, __time);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void shown(int __d, int __shown)
	{
		this.__exec("shown", "(II)V", __d, __shown);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/03
	 */
	@Override
	public final void sizeChanged(int __d, int __w, int __h)
	{
		this.__exec("sizeChanged", "(III)V", __d, __w, __h);
	}
	
	/**
	 * Executes the given function in the callback.
	 *
	 * @param __func The function to call.
	 * @param __desc The descriptor.
	 * @param __args The arguments to call.
	 * @return The object value.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/03
	 */
	private final Object __exec(String __func, String __desc, Object... __args)
		throws NullPointerException
	{
		if (__func == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Need object and our class
		SpringObject object = this.object;
		
		// Copy arguments to seed our object
		int n = __args.length;
		Object[] args = new Object[n + 1];
		args[0] = object;
		for (int i = 0, o = 1; i < n; i++, o++)
			args[o] = __args[i];
		
		// Call method
		SpringThreadWorker worker = this.worker;
		Object rv;
		try
		{
			// Only allow a single call to be performed at a time
			synchronized (this)
			{
				rv = worker.invokeMethod(false, _CALLBACK_CLASS,
					new MethodNameAndType(__func, __desc), args);
			}
		}
		
		// The VM is exiting from the method, we cannot propogate the method
		// up we could just do nothing, just cancel what has happened.
		catch (SpringMachineExitException e)
		{
			// Debug it
			todo.DEBUG.note("VM in exit state, canceling display function.");
			
			return null;
		}
		
		// Handle return value or keep it as void
		if (rv != null)
			return worker.asNativeObject(rv);
		return null;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringException.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.vm.VMException;

/**
 * This is the base class for all exceptions within the spring machine.
 *
 * @since 2018/08/05
 */
public class SpringException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/08/05
	 */
	public SpringException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/08/05
	 */
	public SpringException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/08/05
	 */
	public SpringException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/08/05
	 */
	public SpringException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringFatalException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is an exception which describes something that is very fatal within
 * the virtual machine.
 *
 * @since 2018/09/20
 */
public class SpringFatalException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/20
	 */
	public SpringFatalException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/20
	 */
	public SpringFatalException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/20
	 */
	public SpringFatalException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/20
	 */
	public SpringFatalException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringField.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
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




























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldNameAndType;

/**
 * This contains and stores the definition of a single field.
 *
 * @since 2018/07/22
 */
public final class SpringField
	implements SpringMember
{
	/** The class this technically belongs to. */
	protected final ClassName inclass;
	
	/** The field definition. */
	protected final Field field;
	
	/** The field index. */
	protected final int index;
	
	/**
	 * Initializes the field.
	 *
	 * @param __cn The class this field is in.
	 * @param __f The field definition.
	 * @param __dx The field index, this is ignored for statics and cannot be
	 * negative for instances.
	 * @throws IllegalArgumentException If the field index is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	SpringField(ClassName __cl, Field __f, int __dx)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.field = __f;
		
		// Instance fields require an index
		if (__f.flags().isInstance())
		{
			// {@squirreljme.error BK17 Negative field index.}
			if (__dx < 0)
				throw new IllegalArgumentException("BK17");	
			
			this.index = __dx;
		}
		
		// Not used for statics
		else
			this.index = -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldFlags flags()
	{
		return this.field.flags();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final ClassName inClass()
	{
		return this.inclass;
	}
	
	/**
	 * Returns the index of this field.
	 *
	 * @return The field index.
	 * @since 2018/09/16
	 */
	public final int index()
	{
		return this.index;
	}
	
	/**
	 * Is this a static field?
	 *
	 * @return If this is a static field.
	 * @since 2018/09/09
	 */
	public final boolean isStatic()
	{
		return this.field.flags().isStatic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldNameAndType nameAndType()
	{
		return this.field.nameAndType();
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringFieldStorage.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
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








































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldNameAndType;

/**
 * Contains storage and other information for fields.
 *
 * @since 2018/09/09
 */
public final class SpringFieldStorage
{
	/** The class this is in. */
	protected final ClassName inclass;
	
	/** Name and type of the field. */
	protected final FieldNameAndType nameandtype;
	
	/** Is this volatile? */
	protected final boolean isvolatile;
	
	/** Is this final? */
	protected final boolean isfinal;
	
	/** The value of the field. */
	private Object _normalvalue;
	
	/** The volatile value of the field. */
	private volatile Object _volatilevalue;
	
	/**
	 * Initializes the static field.
	 *
	 * @param __f The field to store for.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/09/09
	 */
	SpringFieldStorage(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Used for debug
		FieldNameAndType nameandtype;
		this.inclass = __f.inClass();
		this.nameandtype = (nameandtype = __f.nameAndType());
		
		// Initialize value depending on the field type
		Object init;
		switch (nameandtype.type().simpleStorageType())
		{
			case OBJECT:
				init = SpringNullObject.NULL;
				break;
			
			case INTEGER:
				init = Integer.valueOf(0);
				break;
			
			case LONG:
				init = Long.valueOf(0);
				break;
			
			case FLOAT:
				init = Float.valueOf(0);
				break;
			
			case DOUBLE:
				init = Double.valueOf(0);
				break;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
		
		// If the field starts with a constant, it must be initialized
		ConstantValue cv = __f.field.constantValue();
		if (cv != null)
			init = cv.boxedValue();
		
		// Set initial value
		if ((this.isvolatile = __f.flags().isVolatile()))
			this._volatilevalue = init;
		else
			this._normalvalue = init;
		
		this.isfinal = __f.flags().isFinal();
	}
	
	/**
	 * Returns the value of the field.
	 *
	 * @return The field value.
	 * @since 2018/09/15
	 */
	public final Object get()
	{
		// Volatile field, use volatile field instead
		if (this.isvolatile)
			return this._volatilevalue;
		
		// Otherwise just set thread without worrying about any contention
		else
			return this._normalvalue;
	}
	 
	/**
	 * Sets the static field to the given value.
	 *
	 * @param __v The value to set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final void set(Object __v)
		throws NullPointerException
	{
		this.set(__v, false);
	}
	
	/**
	 * Sets the static field to the given value, final may be overridden
	 * potentially.
	 *
	 * @param __v The value to set.
	 * @param __writetofinal If true then final is overridden.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the field is final
	 * and we are not allowed to write to final fields.
	 * @since 2018/09/09
	 */
	public final void set(Object __v, boolean __writetofinal)
		throws SpringIncompatibleClassChangeException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("%s::%s = %s", this.inclass, this.nameandtype,
			__v);*/
		
		// {@squirreljme.error BK18 Attempt to write to final field.}
		if (this.isfinal && !__writetofinal)
			throw new SpringIllegalAccessException("BK18");
		
		// Volatile field, use volatile field instead
		if (this.isvolatile)
			this._volatilevalue = __v;
		
		// Otherwise just set thread without worrying about any contention
		else
			this._normalvalue = __v;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringIllegalAccessException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a class or member of a class cannot be accessed.
 *
 * @since 2018/09/15
 */
public class SpringIllegalAccessException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalAccessException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringIllegalMonitorStateException.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the state of a monitor is not valid.
 *
 * @since 2018/09/15
 */
public class SpringIllegalMonitorStateException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringIllegalMonitorStateException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/IllegalMonitorStateException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringIncompatibleClassChangeException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a class refers to another reference and it differs
 * than what was expected at run-time.
 *
 * @since 2018/09/09
 */
public class SpringIncompatibleClassChangeException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringIncompatibleClassChangeException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringInstance.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This represents an instance of an object which has a class and defined
 * fields.
 *
 * @since 2018/07/22
 */
public final class SpringInstance
{
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringMachine.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711







































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.TaskAccess;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VirtualMachine;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMNativeDisplayAccess;
import cc.squirreljme.vm.VMResourceAccess;
import cc.squirreljme.vm.VMSuiteManager;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValueString;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This class contains the instance of the SpringCoat virtual machine and has
 * a classpath along with all the needed storage for variables and such.
 *
 * @since 2018/07/29
 */
public final class SpringMachine
	implements Runnable, VirtualMachine
{
	/** Lock. */
	public final Object strlock =
		new Object();
	
	/** The class loader. */
	protected final SpringClassLoader classloader;
	
	/** Resources accessor. */
	protected final VMResourceAccess resourceaccessor;
	
	/** The boot class. */
	protected final String bootcl;
	
	/** Is the boot a midlet? */
	protected final boolean bootmid;
	
	/** The boot index. */
	protected final int bootdx;
	
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** Task manager. */
	protected final SpringTaskManager tasks;
	
	/** The depth of this machine. */
	protected final int guestdepth;
	
	/** The profiling information. */
	protected final ProfilerSnapshot profiler;
	
	/** Access to the native display. */
	protected final VMNativeDisplayAccess nativedisplay;
	
	/** Pointer manager. */
	protected final SpringPointerManager pointers =
		new SpringPointerManager();
	
	/** Threads which are available. */
	private final List<SpringThread> _threads =
		new ArrayList<>();
	
	/** Static fields which exist within the virtual machine. */
	private final Map<SpringField, SpringFieldStorage> _staticfields =
		new HashMap<>();
	
	/** Global strings representing singular constants. */
	private final Map<ConstantValueString, SpringObject> _strings =
		new HashMap<>();
	
	/** Class objects which represent a given class. */
	private final Map<ClassName, SpringObject> _classobjects =
		new HashMap<>();
	
	/** Class names by their objects. */
	private final Map<SpringObject, ClassName> _namesbyclass =
		new HashMap<>();
	
	/** Main entry point arguments. */
	private final String[] _args;
	
	/** Long to string map. */
	private final Map<Long, String> _strlongtostring =
		new HashMap<>();
	
	/** String to long map. */
	private final Map<String, Long> _strstringtolong =
		new HashMap<>();
	
	/** System properties. */
	final Map<String, String> _sysproperties;
	
	/** The next thread ID to use. */
	private volatile int _nextthreadid;
	
	/** The next long to choose. */
	private long _strnextlong;
	
	/** Is the VM exiting? */
	private volatile boolean _exiting;
	
	/** Exit code of the VM. */
	volatile int _exitcode;
	
	/**
	 * Initializes the virtual machine.
	 *
	 * @param __sm The manager for suites.
	 * @param __cl The class loader.
	 * @param __tm Task manager.
	 * @param __bootcl The boot class.
	 * @param __bootmid The boot class a midlet.
	 * @param __bootdx The entry point which should be booted when the VM
	 * runs.
	 * @param __gd Guest depth.
	 * @param __profiler The profiler to use.
	 * @param __nda The native display provider.
	 * @param __sprops System properties.
	 * @param __args Main entry point arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public SpringMachine(VMSuiteManager __sm, SpringClassLoader __cl,
		SpringTaskManager __tm, String __bootcl, boolean __bootmid,
		int __bootdx, int __gd, ProfilerSnapshot __profiler,
		VMNativeDisplayAccess __nda, Map<String, String> __sprops,
		String... __args)
		throws NullPointerException
	{
		if (__cl == null || __sm == null || __nda == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.classloader = __cl;
		this.tasks = __tm;
		this.bootcl = __bootcl;
		this.bootmid = __bootmid;
		this.bootdx = __bootdx;
		this.guestdepth = __gd;
		this.nativedisplay = __nda;
		this._args = (__args == null ? new String[0] : __args.clone());
		this.profiler = (__profiler != null ? __profiler :
			new ProfilerSnapshot());
		this._sysproperties = (__sprops == null ?
			new HashMap<String, String>() : new HashMap<>(__sprops));
		
		// Setup resource accessor
		this.resourceaccessor = new VMResourceAccess(__sm);
	}
	
	/**
	 * Returns the class loader.
	 *
	 * @return The class loader.
	 * @since 2018/09/08
	 */
	public final SpringClassLoader classLoader()
	{
		return this.classloader;
	}
	
	/**
	 * Creates a new thread within the virtual machine.
	 *
	 * @param __n The name of the thread.
	 * @return The newly created thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	public final SpringThread createThread(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Store thread
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			// Initialize new thread
			int v;
			SpringThread rv = new SpringThread((v = ++this._nextthreadid), __n,
				this.profiler.measureThread(String.format("%s-vm%08x-%d-%s",
				this.classloader.bootLibrary().name(),
				System.identityHashCode(this), v, __n)));
			
			// Store thread
			threads.add(rv);
			return rv;
		}
	}
	
	/**
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */
	public final String debugResolveString(long __p)
	{
		if (__p == -1L)
			return null;
		
		synchronized (this.strlock)
		{
			return this._strlongtostring.get(__p);
		}
	}
	
	/**
	 * Unresolves the given string.
	 *
	 * @param __s The string to unresolve.
	 * @return The pointer to the string.
	 * @since 2018/09/29
	 */
	public final long debugUnresolveString(String __s)
	{
		if (__s == null)
			return -1L;
		
		synchronized (this.strlock)
		{
			Long rv = this._strstringtolong.get(__s);
			if (rv != null)
				return rv.longValue();
			
			Long next = Long.valueOf(++this._strnextlong);
			this._strstringtolong.put(__s, next);
			this._strlongtostring.put(next, __s);
			
			return next;
		}
	}
	
	/**
	 * Exits the virtual machine.
	 *
	 * @param __code The exit code.
	 * @throws SpringMachineExitException To signal virtual machine exit.
	 * @since 2018/10/13
	 */
	public final void exit(int __code)
		throws SpringMachineExitException
	{
		// Set as exiting
		this._exitcode = __code;
		this._exiting = true;
		
		// Now signal exit
		throw new SpringMachineExitException(__code);
	}
	
	/**
	 * Checks whether the virtual machine is exiting.
	 *
	 * @throws SpringMachineExitException If the VM is exiting.
	 * @since 2018/10/13
	 */
	public final void exitCheck()
		throws SpringMachineExitException
	{
		// Only if exiting
		if (this._exiting)
			throw new SpringMachineExitException(this._exitcode);
	}
	
	/**
	 * Exits the virtual machine without throwing an exception.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	public final void exitNoException(int __code)
		throws SpringMachineExitException
	{
		// Set as exiting
		this._exitcode = __code;
		this._exiting = true;
	}
	
	/**
	 * Gets the thread by the given ID.
	 *
	 * @param __id The ID of the thread.
	 * @return The thread by this ID or {@code null} if it was not found.
	 * @since 2018/11/21
	 */
	public final SpringThread getThread(int __id)
	{
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			for (SpringThread t : threads)
				if (t.id == __id)
					return t;
		}
		
		return null;
	}
	
	/**
	 * Returns the static field for the given field.
	 *
	 * @param __f The field to get the static field for.
	 * @return The static field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringVirtualMachineException If the field does not exist.
	 * @since 2018/09/09
	 */
	public final SpringFieldStorage lookupStaticField(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Static fields may be added to when class loading is happening and
		// as such there must be a lock to be given safe access
		Map<SpringField, SpringFieldStorage> sfm = this._staticfields;
		synchronized (this.classloader.classLoadingLock())
		{
			SpringFieldStorage rv = sfm.get(__f);
			
			// {@squirreljme.error BK19 Could not locate the static field
			// storage?}
			if (rv == null)
				throw new SpringVirtualMachineException("BK19");
			
			return rv;
		}
	}
	
	/**
	 * Returns the number of threads which are currently alive and active.
	 *
	 * @return The number of active and alive threads.
	 * @since 2018/09/03
	 */
	public final int numThreads()
	{
		// Store thread
		List<SpringThread> threads = this._threads;
		synchronized (threads)
		{
			return threads.size();
		}
	}
	
	/**
	 * Returns the access for resources.
	 *
	 * @return The resource access.
	 * @since 2018/10/07
	 */
	public final VMResourceAccess resourceAccess()
	{
		return this.resourceaccessor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/13
	 */
	@Override
	public final void run()
	{
		// Obtain the boot library to read entry points from
		SpringClassLoader classloader = this.classloader;
		VMClassLibrary bootbin = classloader.bootLibrary();
		
		// May be specified or not
		String entryclass = this.bootcl;
		boolean ismidlet = this.bootmid;
		int launchid = this.bootdx;
		
		// Lookup the entry class via the manifest
		if (entryclass == null)
		{
			// Need to load the manifest where the entry points will be
			EntryPoints entries;
			try (InputStream in = bootbin.resourceAsStream(
				"META-INF/MANIFEST.MF"))
			{
				// {@squirreljme.error BK1a Entry point JAR has no manifest.
				// (The name of the boot binary)}
				if (in == null)
					throw new SpringVirtualMachineException("BK1a " +
						bootbin.name());
				
				entries = new EntryPoints(new JavaManifest(in));
			}
			
			// {@squirreljme.error BK1b Failed to read the manifest.}
			catch (IOException e)
			{
				throw new SpringVirtualMachineException("BK1b", e);
			}
			
			int n = entries.size();
			
			// Print entry points out out for debug, but only for the first
			// guest because this is annoying!
			if (GuestDepth.guestDepth() + 1 == this.guestdepth)
			{
				todo.DEBUG.note("Entry points:");
				for (int i = 0; i < n; i++)
					todo.DEBUG.note("    %d: %s", i, entries.get(i));
			}
			
			// Use the first program if the ID is not valid
			if (launchid < 0 || launchid >= n)
				launchid = 0;
			
			// Needed to enter the machine
			EntryPoint entry = entries.get(launchid);
			entryclass = entry.entryPoint().toString();
			ismidlet = entry.isMidlet();
		}
		
		// Thread that will be used as the main thread of execution, also used
		// to initialize classes when they are requested
		SpringThread mainthread = this.createThread("main");
		
		// We will be using the same logic in the thread worker if we need to
		// initialize any objects or arguments
		SpringThreadWorker worker = new SpringThreadWorker(this,
			mainthread, true);
		mainthread._worker = worker;
		
		// Load the entry point class
		SpringClass entrycl = worker.loadClass(new ClassName(
			entryclass.replace('.', '/')));
		
		// Find the method to be entered in
		SpringMethod mainmethod;
		if (ismidlet)
			mainmethod = entrycl.lookupMethod(false,
				new MethodNameAndType("startApp", "()V"));
		else
			mainmethod = entrycl.lookupMethod(true,
				new MethodNameAndType("main", "([Ljava/lang/String;)V"));
		
		// Setup object to initialize with for thread
		SpringVMStaticMethod vmsm = new SpringVMStaticMethod(mainmethod);
		
		// Determine the entry argument, midlets is just the class to run
		Object entryarg;
		if (ismidlet)
			entryarg = worker.asVMObject(entryclass.replace('.', '/'));
		else
		{
			String[] inargs = this._args;
			int inlen = inargs.length;
			
			// Setup array
			SpringArrayObject outargs = worker.allocateArray(
				worker.resolveClass(new ClassName("java/lang/String")), inlen);
			
			// Initialize the argument array
			for (int i = 0; i < inlen; i++)
				outargs.set(i, worker.asVMObject(inargs[i]));
			
			entryarg = outargs;
		}
		
		// Setup new thread object
		SpringObject threadobj = worker.newInstance(worker.loadClass(
			new ClassName("java/lang/Thread")), new MethodDescriptor(
			"(Ljava/lang/String;ILcc/squirreljme/runtime/cldc/asm/" +
			"StaticMethod;Ljava/lang/Object;)V"), worker.asVMObject("Main"),
			(ismidlet ? 3 : 4), vmsm, entryarg);
		
		// Enter the frame for that method using the arguments we passed (in
		// a static fashion)
		mainthread.enterFrame(worker.loadClass(
			new ClassName("java/lang/Thread")).lookupMethod(false,
			new MethodNameAndType("__start", "()V")), threadobj);
		
		// The main although it executes in this context will always have the
		// same exact logic as other threads running apart from this main
		// thread, so no code is needed to be duplicated at all.
		try
		{
			worker.run();
		}
		
		// Virtual machine exited, do not print fatal trace just exit here
		catch (SpringMachineExitException e)
		{
			throw e;
		}
		
		// Ooopsie!
		catch (RuntimeException e)
		{
			/*PrintStream err = System.err;
			
			err.println("****************************");
			
			// Print the real stack trace
			err.println("*** EXTERNAL STACK TRACE ***");
			e.printStackTrace(err);
			err.println();
			
			// Print the VM seen stack trace
			err.println("*** INTERNAL STACK TRACE ***");
			mainthread.printStackTrace(err);
			err.println();
			
			err.println("****************************");*/
			
			// Retoss
			throw e;
		}
		
		// Wait until all threads have terminated before actually leaving
		for (;;)
		{
			// Check if the VM is exiting, this would have happen if another
			// thread called exit
			// If we do not check, then the VM will never exit even after
			// another thread has exited
			this.exitCheck();
			
			// No more threads left?
			int okay = 0,
				notokay = 0;
			List<SpringThread> threads = this._threads;
			synchronized (threads)
			{
				for (SpringThread t : threads)
					if (t.isExitOkay())
						okay++;
					else
						notokay++;
			}
			
			// Okay to exit?
			if (notokay == 0)
				return;
			
			// Wait a short duration before checking again
			try
			{
				Thread.sleep(500);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/17
	 */
	@Override
	public final int runVm()
	{
		// Run until the VM terminates
		try
		{
			this.run();
			
			// Success, maybe
			return this._exitcode;
		}
		
		// Exit VM with given code
		catch (SpringMachineExitException e)
		{
			return e.code();
		}
		
		// Ignore these exceptions, just fatal exit
		catch (SpringFatalException e)
		{
			return TaskAccess.EXIT_CODE_FATAL_EXCEPTION;
		}
		
		// Any other exception is fatal and the task must be made to exit
		// with the error code otherwise the VM will stick trying to wait
		// to exit
		catch (RuntimeException|Error e)
		{
			PrintStream err = System.err;
			
			err.println("****************************");
			
			// Print the real stack trace
			err.println("*** EXTERNAL STACK TRACE ***");
			e.printStackTrace(err);
			err.println();
			
			err.println("****************************");
			
			return TaskAccess.EXIT_CODE_FATAL_EXCEPTION;
		}
	}
	
	/**
	 * Returns the suite manager which is available.
	 *
	 * @return The suite manager that is available.
	 * @since 2018/10/26
	 */
	public final VMSuiteManager suiteManager()
	{
		return this.suites;
	}
	
	/**
	 * Returns the task manager which is used.
	 *
	 * @return The task manager.
	 * @since 2018/11/04
	 */
	public final SpringTaskManager taskManager()
	{
		return this.tasks;
	}
	
	/**
	 * Splits long to integers.
	 *
	 * @param __dx The index.
	 * @param __v The output integers.
	 * @param __l The input long.
	 * @since 2018/09/29
	 */
	public static final void longToInt(int __dx, int[] __v, long __l)
	{
		__v[__dx] = (int)(__l >>> 32);
		__v[__dx + 1] = (int)__l;
	}
	
	/**
	 * Returns the mapping of class names to {@link Class} instances.
	 *
	 * @return The mapping of class names to object instances.
	 * @since 2018/09/19
	 */
	final Map<ClassName, SpringObject> __classObjectMap()
	{
		return this._classobjects;
	}
	
	/**
	 * Returns the mapping for objects to class names.
	 *
	 * @return The mapping of class objects to names.
	 * @since 2018/09/29
	 */
	final Map<SpringObject, ClassName> __classObjectToNameMap()
	{
		return this._namesbyclass;
	}
	
	/**
	 * Returns the map of static fields.
	 *
	 * @return The static field map.
	 * @since 2018/09/08
	 */
	final Map<SpringField, SpringFieldStorage> __staticFieldMap()
	{
		return this._staticfields;
	}
	
	/**
	 * Returns the global string map.
	 *
	 * @return The global string map.
	 * @since 2018/09/16
	 */
	final Map<ConstantValueString, SpringObject> __stringMap()
	{
		return this._strings;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringMachineExitException.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the virtual machine is exiting.
 *
 * @since 2018/10/13
 */
public class SpringMachineExitException
	extends SpringException
{
	/** The exit code. */
	protected final int code;
	
	/**
	 * Initializes the exception with the given exit code.
	 *
	 * @param __code The exit code.
	 * @since 2018/10/13
	 */
	public SpringMachineExitException(int __code)
	{
		super("" + __code);
		
		this.code = __code;
	}
	
	/**
	 * Returns the exit code.
	 *
	 * @return The exit code.
	 * @since 2018/10/33
	 */
	public final int code()
	{
		return this.code;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringMember.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.HasMemberFlags;
import net.multiphasicapps.classfile.MemberNameAndType;

/**
 * This represents a member.
 *
 * @since 2018/09/09
 */
public interface SpringMember
	extends HasMemberFlags
{
	/**
	 * Returns the class this is a member of.
	 *
	 * @return The class which owns the method.
	 * @since 2018/09/09
	 */
	public abstract ClassName inClass();
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	public abstract MemberNameAndType nameAndType();
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringMethod.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This contains and stores the definition of a single method.
 *
 * @since 2018/07/22
 */
public final class SpringMethod
	implements SpringMember
{
	/** The class this technically belongs to. */
	protected final ClassName inclass;
	
	/** The backing method and its information. */
	protected final Method method;
	
	/** The file this method is in. */
	protected final String infile;
	
	/**
	 * Initializes the method representation.
	 *
	 * @param __ic The class this belongs to.
	 * @param __m The method to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	SpringMethod(ClassName __ic, Method __m, String __if)
		throws NullPointerException
	{
		if (__ic == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __ic;
		this.method = __m;
		this.infile = __if;
	}
	
	/**
	 * Returns the byte code of the method.
	 *
	 * @return The method byte code.
	 * @since 2018/09/03
	 */
	public final ByteCode byteCode()
	{
		return this.method.byteCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodFlags flags()
	{
		return this.method.flags();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/03
	 */
	@Override
	public final ClassName inClass()
	{
		return this.inclass;
	}
	
	/**
	 * Returns the file this method is in.
	 *
	 * @return The file this method is in, may be {@code null}.
	 * @since 2018/09/20
	 */
	public final String inFile()
	{
		return this.infile;
	}
	
	/**
	 * Returns whether this method is abstract.
	 *
	 * @return Whether this method is abstract.
	 * @since 2018/09/03
	 */
	public final boolean isAbstract()
	{
		return this.method.flags().isAbstract();
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2018/09/03
	 */
	public final boolean isInstanceInitializer()
	{
		return this.method.isInstanceInitializer();
	}
	
	/**
	 * Returns if this method is static.
	 *
	 * @return {@code true} if the method is static.
	 * @since 2018/09/03
	 */
	public final boolean isStatic()
	{
		return this.method.flags().isStatic();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2018/09/03
	 */
	public final boolean isStaticInitializer()
	{
		return this.method.isStaticInitializer();
	}
	
	/**
	 * Returns the name of this method.
	 *
	 * @return The name of this method.
	 * @since 2018/09/09
	 */
	public final MethodName name()
	{
		return this.method.name();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodNameAndType nameAndType()
	{
		return this.method.nameAndType();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/06
	 */
	@Override
	public final String toString()
	{
		return this.inclass + "::" + this.method.nameAndType().toString();
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringMonitor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293





































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.ObjectAccess;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This is a monitor which is associated with an object.
 *
 * @since 2018/09/15
 */
public final class SpringMonitor
{
	/** The monitor lock. */
	protected final Object lock =
		new Object();
	
	/** The thread which owns this monitor. */
	volatile SpringThread _owner;
	
	/** Number of threads which are waiting on this monitor. */
	volatile int _waitcount;
	
	/** The number of notifications happening. */
	volatile int _notifycount;
	
	/** The entry count on the monitor. */
	private int _count;
	
	/**
	 * Enters the monitor.
	 *
	 * @param __t The thread trying to lock the monitor.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	public final void enter(SpringThread __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		for (;;)
			synchronized (lock)
			{
				// We take possession of this monitor
				SpringThread owner = this._owner;
				if (owner == null)
				{
					this._owner = __t;
					this._count = 1;
					return;
				}
				
				// We own the monitor, so increase the count
				else if (owner == __t)
				{
					this._count++;
					return;
				}
				
				// Need to wait for it to be cleared
				else
				{
					// Wait for lock to be freed
					try
					{
						lock.wait();
					}
					catch (InterruptedException e)
					{
						// Ignore
					}
				}
			}
	}
	
	/**
	 * Exits the monitor.
	 *
	 * @param __t The thread exiting the monitor.
	 * @param __notify Should threads be notified that an unlock happened?
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIllegalMonitorStateException If the monitor is not owned
	 * by this thread.
	 * @since 2018/09/15
	 */
	public final void exit(SpringThread __t, boolean __notify)
		throws NullPointerException, SpringIllegalMonitorStateException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// {@squirreljme.error BK1c This thread does not own the
			// monitor.}
			if (this._owner != __t)
				throw new SpringIllegalMonitorStateException("BK1c");	
			
			// {@squirreljme.error BK1d No previous entry call was made.
			// (The monitor entry count)}
			int count = this._count;
			if (count <= 0)
				throw new SpringIllegalMonitorStateException(
					String.format("BK1d %d", count));
			
			// If the count reaches zero, no thread owns this now
			this._count = --count;
			if (count <= 0)
			{
				this._owner = null;
				
				// Wake up all threads so that they try and lock on the lock
				// so whoever gets that chance
				if (__notify)
					lock.notifyAll();
			}
		}
	}
	
	/**
	 * Notifies on this monitor and returns the status.
	 *
	 * @param __by The thread that is doing the notify.
	 * @param __all Notify all threads?
	 * @return The notification status.
	 * @throws NullPointerException
	 * @since 2018/11/20
	 */
	public final int monitorNotify(SpringThread __by, boolean __all)
		throws NullPointerException
	{
		if (__by == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// Wrong thread?
			if (this._owner != __by)
				return ObjectAccess.MONITOR_NOT_OWNED;
			
			// Nothing is waiting, do not bother at all!
			int waitcount = this._waitcount;
			if (waitcount == 0)
				return 0;
			
			// Notify all threads or just one?
			// Never let the notify count exceed the wait count as well
			int notifycount = this._notifycount;
			this._notifycount = Math.min(waitcount,
				(__all ? waitcount : notifycount + 1));
			
			// Notify all threads that something happened with the lock
			lock.notifyAll();
			
			return 0;
		}
	}
	
	/**
	 * Waits on the monitor.
	 *
	 * @param __by The thread doing the wait.
	 * @param __ms The milliseconds to wait.
	 * @param __ns The nanoseconds to wait.
	 * @return The wait result.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/21
	 */
	public final int monitorWait(SpringThread __by, long __ms, int __ns)
		throws NullPointerException
	{
		if (__by == null)
			throw new NullPointerException("NARG");
		
		// Lock on the monitor lock
		Object lock = this.lock;
		synchronized (lock)
		{
			// Wrong thread?
			if (this._owner != __by)
				return ObjectAccess.MONITOR_NOT_OWNED;
			
			// Increase our wait count
			this._waitcount++;
			
			// Relinquish control of this monitor, so that way when we actually
			// internally do the wait we check notify counts and such.
			this.exit(__by, true);
			
			// Do looped wait, but it may be timed
			boolean waitforever = (__ms == 0 && __ns == 0),
				interrupted = false,
				expired = false;
			long end = (waitforever ? Long.MAX_VALUE :
				System.nanoTime() + (__ms * 1_000_000L) + __ns);
			for (;;)
			{
				// read our wait and notify counts to determine if we
				// should take control here
				int nownotifycount = this._notifycount,
					nowwaitcount = this._waitcount;
				
				// We were notified, interrupted, or expired, take it and leave
				if (interrupted || expired || nownotifycount > 0)
				{
					// Reduce the notify count, but not when interrupted or
					// expired
					if (!interrupted && !expired)
						this._notifycount--;
					
					// Reduce wait count
					int waitcount = this._waitcount;
					this._waitcount = --waitcount;
					
					// Never let the notification count exceed the wait count
					if (this._notifycount > waitcount)
						this._notifycount = waitcount;
					
					// Re-enter the monitor
					this.enter(__by);
					
					// Whatever state we ended up in
					if (interrupted)
						return ObjectAccess.MONITOR_INTERRUPTED;
					return ObjectAccess.MONITOR_NOT_INTERRUPTED;
				}
				
				// Otherwise wait for notification to happen
				else
				{
					// Could be interrupted
					try
					{
						// Check if time expired
						if (!waitforever)
						{
							long rem = end - System.nanoTime();
							if (rem <= 0)
							{
								expired = true;
								continue;
							}
							
							// Wait for this time
							lock.wait(rem / 1_000_000L,
								(int)(rem % 1_000_000L));
						}
						
						// Wait forever
						else
						{
							lock.wait();
						}
					}
					
					// Was interrupted
					catch (InterruptedException e)
					{
						interrupted = true;
					}
				}
			}
		}
	}
	
	/**
	 * Waiting information on this monitor.
	 *
	 * @since 2018/11/20
	 */
	private static final class __Waiting__
	{
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringNegativeArraySizeException.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when an attempt was made to allocate an array of a negative
 * size.
 *
 * @since 2018/09/15
 */
public class SpringNegativeArraySizeException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/15
	 */
	public SpringNegativeArraySizeException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/NegativeArraySizeException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringNoSuchFieldException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a field in a class does not exist.
 *
 * @since 2018/09/09
 */
public class SpringNoSuchFieldException
	extends SpringIncompatibleClassChangeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNoSuchFieldException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringNoSuchMethodException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a method in a class does not exist.
 *
 * @since 2018/09/03
 */
public class SpringNoSuchMethodException
	extends SpringIncompatibleClassChangeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/03
	 */
	public SpringNoSuchMethodException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringNullObject.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Represents the null object.
 *
 * @since 2018/09/08
 */
public final class SpringNullObject
	implements SpringObject
{
	/** Single null object reference. */
	public static final SpringNullObject NULL =
		new SpringNullObject();
	
	/**
	 * Only used once.
	 *
	 * @since 2018/09/08
	 */
	private SpringNullObject()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK1e Cannot obtain the monitor of an object
		// that is null.}
		throw new SpringNullPointerException("BK1e");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		return SpringPointerArea.NULL;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final SpringClass type()
	{
		return null;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringNullPointerException.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when a null reference has been detected.
 *
 * @since 2018/09/09
 */
public class SpringNullPointerException
	extends SpringException
	implements SpringConvertableThrowable
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/09
	 */
	public SpringNullPointerException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/09
	 */
	public SpringNullPointerException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/04
	 */
	@Override
	public String targetClass()
	{
		return "java/lang/NullPointerException";
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringObject.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This represents anything that is treated by the virtual machine as a kind
 * of object reference. This is needed for SquirrelJME since it exposes a
 * pointer logic which is magically handled by the virtual machine.
 *
 * @since 2018/09/08
 */
public interface SpringObject
{
	/**
	 * Returns the monitor for this object.
	 *
	 * @return This object's monitor.
	 * @since 2018/09/15
	 */
	public abstract SpringMonitor monitor();
	
	/**
	 * Returns the pointer area for this object.
	 *
	 * @return The pointer area for this object.
	 * @since 2019/12/21
	 */
	public abstract SpringPointerArea pointerArea();
	
	/**
	 * Returns the object type.
	 *
	 * @return The object type.
	 * @since 2018/09/09
	 */
	public abstract SpringClass type();
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringPointerArea.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
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


























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.springcoat;

/**
 * This represents a new area where pointers can go.
 *
 * @since 2019/12/21
 */
public final class SpringPointerArea
	implements Comparable<SpringPointerArea>
{
	/** Null pointer. */
	public static final SpringPointerArea NULL =
		new SpringPointerArea(0, 0);
	
	/** The base address. */
	public final int base;
	
	/** The length of the area. */
	public final int length;
	
	/**
	 * Initializes the pointer area.
	 *
	 * @param __b The basee.
	 * @param __l The length.
	 * @throws IllegalArgumentException If the length is negative.
	 * @since 2019/12/21
	 */
	public SpringPointerArea(int __b, int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BK3f Cannot have a negative length pointer
		// area.}
		if (__l < 0)
			throw new IllegalArgumentException("BK3f");
		
		this.base = __b;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final int compareTo(SpringPointerArea __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringPointerManager.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.springcoat;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This is used to manage pointers within SpringCoat.
 *
 * @since 2019/12/21
 */
public final class SpringPointerManager
{
	/** Queue for cleared references. */
	private final ReferenceQueue<SpringObject> _queue =
		new ReferenceQueue<>();
	
	/** Reference to integer. */
	private final Map<Reference<SpringObject>, Integer> _rtoi =
		new HashMap<>();
	
	/** Integer to reference. */
	private final Map<Integer, Reference<SpringObject>> _itor =
		new HashMap<>();
	
	/** The next allocation address. */
	private int _next =
		4;
	
	/**
	 * Allocates and returns a new pointer area.
	 *
	 * @param __l The length to allocate.
	 * @return The resulting pointer.
	 * @throws IllegalArgumentException If the length is negative.
	 * @since 2019/12/21
	 */
	public final SpringPointerArea allocate(int __l)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BK3g Cannot allocate negative pointer space.}
		if (__l < 0)
			throw new IllegalArgumentException("BK3g");
		
		// Determine base pointer
		int base = this._next;
		
		// {@squirreljme.error BK3h Ran out of address space allocating
		// object. (The requested length)}
		if (base < 0)
			throw new SpringVirtualMachineException("BK3h " + __l);
		
		// Set next position
		this._next = base + ((__l + 3) & ~3);
		
		// Build pointer here
		return new SpringPointerArea(base, __l);
	}
	
	/**
	 * Allocates a pointer of the given length and binds the specified object
	 * to that pointer.
	 *
	 * @param __l The length to allocate.
	 * @param __o The object to bind.
	 * @return The resulting pointer.
	 * @throws IllegalArgumentException If the length is negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public final SpringPointerArea allocateAndBind(int __l, SpringObject __o)
		throws IllegalArgumentException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Allocate pointer
		SpringPointerArea rv = this.allocate(__l);
		
		// Setup reference
		Reference<SpringObject> ref = new WeakReference(__o, this._queue);
		
		// Bind it
		synchronized (this)
		{
			Integer ibase = rv.base;
			
			// Store into both referencing maps
			this._rtoi.put(ref, ibase);
			this._itor.put(ibase, ref);
		}
		
		// Return the result
		return rv;
	}
	
	/**
	 * Locates the object at the given address.
	 *
	 * @param __p The object to find.
	 * @return The object which was found.
	 * @since 2019/12/22
	 */
	public final SpringObject findObject(int __p)
	{
		// Zero address always returns null pointers!
		if (__p == 0)
			return SpringNullObject.NULL;
		
		// Need to use both maps
		Map<Reference<SpringObject>, Integer> rtoi = this._rtoi;
		Map<Integer, Reference<SpringObject>> itor = this._itor;
		
		// Lock on self
		synchronized (this)
		{
			// First try to cleanup anything that was cleared reference
			// wise
			ReferenceQueue<SpringObject> queue = this._queue;
			for (;;)
			{
				// Any new ones appeared?
				Reference<? extends SpringObject> polled = queue.poll();
				if (polled == null)
					break;
				
				// Read integer base
				Integer ibase = rtoi.get(polled);
				
				// Clear from both maps
				rtoi.remove(polled);
				itor.remove(ibase);
			}
			
			// Try to find object reference
			Reference<SpringObject> ref = itor.get(__p);
			
			// {@squirreljme.error BK3i Could not find object referenced at
			// the given pointer. (The requested address)}
			SpringObject rv = (ref != null ? ref.get() : null);
			if (rv == null)
				throw new SpringVirtualMachineException(
					String.format("BK3i @%08x", __p));
			
			return rv;
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringPrimitiveReference.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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This interface represents a base reference.
 *
 * @since 2018/09/23
 */
public abstract class SpringPrimitiveReference
	implements SpringObject
{
	/**
	 * Gets the object from this reference.
	 *
	 * @return The value of the reference.
	 * @since 2018/09/23
	 */
	public abstract SpringObject get();
	
	/**
	 * Sets the reference to the given object.
	 *
	 * @param __o The object to set.
	 * @since 2018/09/23
	 */
	public abstract void set(SpringObject __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK1f Reference types are special and have no
		// monitor.}
		throw new SpringVirtualMachineException("BK1f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringClass type()
	{
		// {@squirreljme.error BK1g Reference types are special and have no
		// class.}
		throw new SpringVirtualMachineException("BK1g");
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringPrimitiveWeakReference.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This class stores information for weak references.
 *
 * @since 2018/09/23
 */
public final class SpringPrimitiveWeakReference
	extends SpringPrimitiveReference
{
	/** The reference used. */
	private Reference<SpringObject> _ref;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final SpringObject get()
	{
		Reference<SpringObject> ref = this._ref;
		if (ref != null)
			return ref.get();
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/23
	 */
	@Override
	public final void set(SpringObject __o)
	{
		this._ref = new WeakReference<>(__o);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringSimpleObject.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
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



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is a representation of an object within the virtual machine.
 *
 * @since 2018/09/08
 */
public final class SpringSimpleObject
	implements SpringObject
{
	/** The type of object this is. */
	protected final SpringClass type;
	
	/** The monitor for this object, every object has one. */
	protected final SpringMonitor monitor =
		new SpringMonitor();
	
	/** The pointer for this object. */
	protected final SpringPointerArea pointer;
	
	/** Field storage in the class. */
	private final SpringFieldStorage[] _fields;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the object.
	 *
	 * @param __cl The class of the object.
	 * @param __spm The manager for pointers.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public SpringSimpleObject(SpringClass __cl, SpringPointerManager __spm)
		throws NullPointerException
	{
		if (__cl == null || __spm == null)
			throw new NullPointerException("NARG");
		
		this.type = __cl;
		
		// Setup field array
		int n;
		SpringFieldStorage[] fields;
		this._fields = (fields =
			new SpringFieldStorage[(n = __cl.instanceFieldCount())]);
		
		// Initialize variable for all fields
		int i = 0;
		for (SpringField f : __cl.fieldTable())
			fields[i++] = new SpringFieldStorage(f);
		
		// Allocate pointer
		this.pointer = __spm.allocateAndBind(__cl.instancesize, this);
	}
	
	/**
	 * Returns the field by the given field.
	 *
	 * @param __f The field to get.
	 * @return The storage for the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public final SpringFieldStorage fieldByField(SpringField __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return this.fieldByIndex(__f.index());
	}
	
	/**
	 * Returns the field by the given index.
	 *
	 * @param __dx The field to get.
	 * @return The storage for the field by the specified index.
	 * @since 2018/09/16
	 */
	public final SpringFieldStorage fieldByIndex(int __dx)
	{
		return this._fields[__dx];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final SpringMonitor monitor()
	{
		return this.monitor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		return this.pointer;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s@%08x", this.type.name(), System.identityHashCode(this))));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final SpringClass type()
	{
		return this.type;
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringStackTop.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * Represents the top of a long or double.
 *
 * @since 2018/09/09
 */
public final class SpringStackTop
{
	/** The top element representation. */
	public static final SpringStackTop TOP =
		new SpringStackTop();
	
	/**
	 * Internally used.
	 *
	 * @since 2018/09/09
	 */
	private SpringStackTop()
	{
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringTask.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
66
67
68
69





































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.TaskAccess;
import java.io.PrintStream;

/**
 * This represents a task which can be run.
 *
 * @since 2018/11/04
 */
public final class SpringTask
	implements Runnable
{
	/** The machine for this task. */
	protected final SpringMachine machine;
	
	/** The ID. */
	protected final int tid;
	
	/** Exit code. */
	volatile int _exitcode =
		Integer.MIN_VALUE;
	
	/** Is this terminated? */
	volatile boolean _isterminated;
	
	/**
	 * Initializes the task.
	 *
	 * @param __tid The task ID.
	 * @param __m The machine.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public SpringTask(int __tid, SpringMachine __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.machine = __m;
		this.tid = __tid;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public final void run()
	{
		this._exitcode = this.machine.runVm();
		this._isterminated = true;
		
		// Debug
		todo.DEBUG.note("Task is terminated!");
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringTaskManager.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.asm.TaskAccess;
import cc.squirreljme.runtime.swm.EntryPoint;
import cc.squirreljme.runtime.swm.EntryPoints;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMNativeDisplayAccess;
import cc.squirreljme.vm.VMSuiteManager;
import java.io.InputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.swm.TaskStatus;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * This class manages tasks within SpringCoat and is used to launch and
 * provide access to those that are running.
 *
 * @since 2018/11/04
 */
public final class SpringTaskManager
{
	/** The manager for suites. */
	protected final VMSuiteManager suites;
	
	/** The profiling information. */
	protected final ProfilerSnapshot profiler;
	
	/** Tasks that are used. */
	private final Map<Integer, SpringTask> _tasks =
		new HashMap<>();
	
	/** System properties. */
	private final Map<String, String> _sysprops;
	
	/** Access to the native display. */
	protected final VMNativeDisplayAccess nativedisplay =
		new VMNativeDisplayAccess();
	
	/** Next task ID. */
	private int _nextid;
	
	/**
	 * Initializes the task manager.
	 *
	 * @param __sm The suite manager.
	 * @param __ps The snapshot for profiling.
	 * @param __sp System properties.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public SpringTaskManager(VMSuiteManager __sm, ProfilerSnapshot __ps,
		Map<String, String> __sp)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.profiler = (__ps == null ? new ProfilerSnapshot() : __ps);
		this._sysprops = (__sp == null ? new HashMap<String, String>() :
			new HashMap<>(__sp));
	}
	
	/**
	 * Starts the specified task.
	 *
	 * @param __cp The class path to use.
	 * @param __entry The entry point.
	 * @param __args Arguments used.
	 * @param __gd The current guest depth.
	 * @return The ID of the created task.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public final int startTask(String[] __cp, String __entry, String[] __args,
		int __gd)
		throws NullPointerException
	{
		if (__cp == null || __entry == null || __args == null)
			throw new NullPointerException("NARG");
		
		VMSuiteManager suites = this.suites;
		
		// Load classpath libraries
		int cpn = __cp.length;
		VMClassLibrary[] scl = new VMClassLibrary[cpn];
		for (int i = 0; i < cpn; i++)
		{
			VMClassLibrary lib = suites.loadLibrary(__cp[i]);
			
			// If missing, cannot continue
			if (lib == null)
			{
				todo.DEBUG.note("Could not find library: `%s`", __cp[i]);
				return TaskAccess.ERROR_MISSING_LIBRARY;
			}
			
			scl[i] = lib;
		}
		
		// Get the boot library since we need to look at the entry points
		VMClassLibrary boot = scl[cpn - 1];
		
		// Need to load the manifest where the entry points will be
		EntryPoints entries;
		try (InputStream in = boot.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// {@squirreljme.error BK1h Entry point JAR has no manifest.}
			if (in == null)
				throw new SpringVirtualMachineException("BK1h");
			
			entries = new EntryPoints(new JavaManifest(in));
		}
		
		// {@squirreljme.error BK1i Failed to read the manifest.}
		catch (IOException e)
		{
			throw new SpringVirtualMachineException("BK1i", e);
		}
		
		// Determine the entry point used
		int bootdx = -1;
		for (int i = 0, n = entries.size(); i < n; i++)
			if (__entry.equals(entries.get(i).entryPoint()))
			{
				bootdx = i;
				break;
			}
		
		// Could not find the boot point
		if (bootdx < 0)
			return TaskAccess.ERROR_INVALID_ENTRY;
		
		// Build machine for the task
		SpringMachine machine = new SpringMachine(suites,
			new SpringClassLoader(scl), this, null, false, bootdx, __gd + 1,
			this.profiler, this.nativedisplay, this._sysprops, __args);
		
		// Lock on tasks
		Map<Integer, SpringTask> tasks = this._tasks;
		synchronized (tasks)
		{
			// Next task ID
			int tid = ++this._nextid;
			
			// Setup task in a new thread to run and such
			SpringTask rv = new SpringTask(tid, machine);
			
			// Store task in active set
			tasks.put(tid, rv);
			
			// Start a thread for this task, which is that task's main thread
			new Thread(rv, "MainTask-" + tid + "-" + __entry).start();
			
			// The task ID is our handle
			return tid;
		}
	}
	
	/**
	 * Returns the status for a task.
	 *
	 * @param __tid The task ID.
	 * @return The status.
	 * @since 2018/11/04
	 */
	public final int taskStatus(int __tid)
	{
		// Lock on tasks
		Map<Integer, SpringTask> tasks = this._tasks;
		synchronized (tasks)
		{
			// Must be a valid task
			SpringTask rv = tasks.get(__tid);
			if (rv == null)
				return -1;
			
			// Get the exit code
			int exitcode = rv._exitcode;
			
			// Still running
			if (exitcode == Integer.MIN_VALUE)
				return TaskStatus.RUNNING.ordinal();
			
			// Terminated with success
			else if (exitcode == 0)
				return TaskStatus.EXITED_REGULAR.ordinal();
			
			// Terminate with something else
			else
				return TaskStatus.EXITED_FATAL.ordinal();
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881

















































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.SystemCallIndex;
import java.io.PrintStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.profiler.ProfiledThread;

/**
 * This class contains information about a thread within the virtual machine.
 *
 * @since 2018/09/01
 */
public final class SpringThread
{
	/** Maximum depth of the stack. */
	public static final int MAX_STACK_DEPTH =
		64;
	
	/** The thread ID. */
	protected final int id;
	
	/** The name of this thread. */
	protected final String name;
	
	/** Profiler information. */
	protected final ProfiledThread profiler;
	
	/** System call errors. */
	final int[] _syscallerrors =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/** The stack frames. */
	private final List<SpringThread.Frame> _frames =
		new ArrayList<>();
		
	/** String representation. */
	private Reference<String> _string;
	
	/** Ran at least one frame (was started)? */
	private volatile boolean _hadoneframe;
	
	/** Is this a daemon thread? */
	volatile boolean _daemon;
	
	/** Terminate the thread? */
	volatile boolean _terminate;
	
	/** Did we signal exit? */
	volatile boolean _signaledexit;
	
	/** The current worker for the thread. */
	volatile SpringThreadWorker _worker;
	
	/**
	 * Initializes the thread.
	 *
	 * @param __id The thread ID.
	 * @param __n The name of the thread.
	 * @param __profiler Profiled storage.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/01
	 */
	SpringThread(int __id, String __n, ProfiledThread __profiler)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.id = __id;
		this.name = __n;
		this.profiler = __profiler;
	}
	
	/**
	 * Returns the current frame of execution or {@code null} if there is none.
	 *
	 * @return The current frame of execution or {@code null} if there is none.
	 * @since 2018/09/03
	 */
	public final SpringThread.Frame currentFrame()
	{
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			if (frames.isEmpty())
				return null;
			return frames.get(frames.size() - 1);
		}
	}
	
	/**
	 * Enters a blank frame to store data.
	 *
	 * @return The
	 * @since 2018/09/20
	 */
	public final SpringThread.Frame enterBlankFrame()
	{
		// Setup blank frame
		SpringThread.Frame rv = new SpringThread.Frame();
		
		// {@squirreljme.error BK1j Stack overflow.}
		List<SpringThread.Frame> frames = this._frames;
		if (frames.size() >= MAX_STACK_DEPTH)
			throw new SpringVirtualMachineException("BK1j");
		
		// Lock on frames as a new one is added
		synchronized (frames)
		{
			frames.add(rv);
		}
		
		// Profile for this frame
		this.profiler.enterFrame("<blank>", "<blank>", "()V",
			System.nanoTime());
		
		// Had one frame (started)
		this._hadoneframe = true;
		
		// Undo termination
		this._terminate = false;
		
		return rv;
	}
	
	/**
	 * Enters the specified method and sets up a stack frame for it.
	 *
	 * @param __m The method to enter.
	 * @param __args Arguments to the frame entry (method arguments).
	 * @return The used stack frame.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringVirtualMachineException If the method is abstract.
	 * @since 2018/09/03
	 */
	public final SpringThread.Frame enterFrame(SpringMethod __m,
		Object... __args)
		throws NullPointerException, SpringVirtualMachineException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		if (__args == null)
			__args = new Object[0];
		
		// Debug
		/*todo.DEBUG.note("enterFrame(%s::%s, %s)", __m.inClass(),
			__m.nameAndType(), Arrays.<Object>asList(__args));*/
		
		// {@squirreljme.error BK1k Cannot enter the frame for a method which
		// is abstract. (The class the method is in; The method name and type)}
		if (__m.isAbstract())
			throw new SpringVirtualMachineException(String.format("BK1k %s %s",
				__m.inClass(), __m.nameAndType()));
		
		// Create new frame
		Frame rv = new Frame(__m, __args);
		
		// Profile for this frame
		this.profiler.enterFrame(__m.inClass().toString(),
			__m.nameAndType().name().toString(),
			__m.nameAndType().type().toString(), System.nanoTime());
		
		// Lock on frames as a new one is added
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			frames.add(rv);
		}
		
		// Had one frame (started)
		this._hadoneframe = true;
		
		// Undo termination
		this._terminate = false;
		
		// Handle synchronized method
		if (__m.flags().isSynchronized())
		{
			SpringObject monitor;
			
			// Monitor on the class object, needs the worker since we need to
			// load a class
			if (__m.flags().isStatic())
			{
				// {@squirreljme.error BK1l Cannot enter a synchronized static
				// method without a thread working, since we need to load
				// the class object.}
				SpringThreadWorker worker = this._worker;
				if (worker == null)
					throw new SpringVirtualMachineException("BK1l");
				
				// Use the class object
				monitor = (SpringObject)worker.asVMObject(__m.inClass(), true);
			}
			
			// On this object
			else
			{
				// {@squirreljme.error BK1m Cannot enter a synchronized
				// instance method with no arguments passed.}
				if (__args.length <= 0)
					throw new SpringVirtualMachineException("BK1m");
				
				// {@squirreljme.error BK1n Cannot enter a monitor of nothing
				// or a non-object.}
				Object argzero = __args[0];
				if (argzero == null || !(argzero instanceof SpringObject))
					throw new SpringVirtualMachineException("BK1n");
				
				// Use this as the monitor
				monitor = (SpringObject)argzero;
			}
			
			// Set to unlock later on
			rv._monitor = monitor;
			
			// Enter the monitor and just wait around
			monitor.monitor().enter(this);
		}
		
		return rv;
	}
	
	/**
	 * Exits all frames in the stack.
	 *
	 * @since 2018/11/17
	 */
	public final void exitAllFrames()
	{
		// Lock on frames as a new one is added
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			frames.clear();
		}
	}
	
	/**
	 * Returns all of the frames which are available.
	 *
	 * @return All of the available stack frames.
	 * @since 2018/09/16
	 */
	public final SpringThread.Frame[] frames()
	{
		// Lock on frames
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			return frames.<SpringThread.Frame>toArray(
				new SpringThread.Frame[frames.size()]);
		}
	}
	
	/**
	 * Is exiting the virtual machine okay?
	 *
	 * @return If it is okay to exit.
	 * @since 2018/11/17
	 */
	public final boolean isExitOkay()
	{
		return this._daemon || this._terminate;
	}
	
	/**
	 * Returns the name of the thread.
	 *
	 * @return The name of the thread.
	 * @since 2018/09/03
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Returns the number of frames that are available in this thread.
	 *
	 * @return The number of available frames.
	 * @since 2018/09/03
	 */
	public final int numFrames()
	{
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			return frames.size();
		}
	}
	
	/**
	 * Pops a frame from the thread stack.
	 *
	 * @return The frame which was popped.
	 * @throws SpringVirtualMachineException If there are no stack frames.
	 * @since 2018/09/09
	 */
	public final SpringThread.Frame popFrame()
		throws SpringVirtualMachineException
	{
		// Exit the frame
		this.profiler.exitFrame(System.nanoTime());
		
		// Pop from the stack
		SpringThread.Frame rv;
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			// {@squirreljme.error BK1o No frames to pop.}
			int n;
			if ((n = frames.size()) <= 0)
				throw new SpringVirtualMachineException("BK1o");	
			
			rv = frames.remove(n - 1);
		}
		
		// If there is a monitor associated with this then leave it
		SpringObject monitor = rv._monitor;
		if (monitor != null)
			monitor.monitor().exit(this, true);
		
		return rv;
	}
	
	/**
	 * Prints this thread's stack trace.
	 *
	 * @param __ps The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public final void printStackTrace(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// Note the thread
		__ps.printf("Thread #%d: %s%n", this.id, this.name);
		
		// Lock since the frames may change!
		List<SpringThread.Frame> frames = this._frames;
		synchronized (frames)
		{
			// The frames at the end are at the top
			for (int n = frames.size(), i = n - 1; i >= 0; i--)
			{
				SpringThread.Frame frame = frames.get(i);
				
				// Do not print traces for blank frames
				if (frame.isBlank())
				{
					__ps.printf("    at <guard frame>%n");
					continue;
				}
				
				SpringMethod inmethod = frame.method();
				int pc = frame.lastExecutedPc();
				
				// Print information
				__ps.printf("    at %s.%s @ %d [%s] (%s:%d)%n",
					inmethod.inClass(),
					inmethod.nameAndType(),
					pc,
					inmethod.byteCode().getByAddress(pc).mnemonic(),
					inmethod.inFile(),
					inmethod.byteCode().lineOfAddress(pc));
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Thread-%d: %s", this.id, this.name)));
		
		return rv;
	}
	
	/**
	 * This class represents the stack frame and is used to store local
	 * variables and other such things.
	 *
	 * @since 2018/09/03
	 */
	public static class Frame
	{
		/** The current method in this frame. */
		protected final SpringMethod method;
		
		/** The method code for execution. */
		protected final ByteCode code;
		
		/** The current object of the current frame. */
		protected final SpringObject thisobject;
		
		/** Is this frame blank? */
		protected final boolean isblank;
		
		/** Local variables. */
		private final Object[] _locals;
		
		/** The stack. */
		private final Object[] _stack;
		
		/** The top of the stack. */
		private volatile int _stacktop;
		
		/** The current program counter. */
		private volatile int _pc;
		
		/** Last executed PC address. */
		private volatile int _lastexecpc;
		
		/** Frame execution count. */
		private volatile int _execcount;
		
		/** Exception which was tossed into this frame. */
		private SpringObject _tossedexception;
		
		/** Object which has a monitor for quicker unlock. */
		private volatile SpringObject _monitor;
		
		/**
		 * Initializes a blank guard frame.
		 *
		 * @since 2018/09/20
		 */
		private Frame()
		{
			this.method = null;
			this.code = null;
			this.thisobject = null;
			this.isblank = true;
			this._locals = new Object[0];
			this._stack = new Object[2];
		}
		
		/**
		 * Initializes the frame.
		 *
		 * @param __m The method used for the frame.
		 * @param __args The frame arguments.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/03
		 */
		private Frame(SpringMethod __m, Object... __args)
			throws NullPointerException
		{
			if (__m == null)
				throw new NullPointerException("NARG");
			
			__args = (__args == null ? new Object[0] : __args.clone());
			
			this.isblank = false;
			this.method = __m;
			
			// We will need to initialize the local and stack data from the
			// information the byte code gives
			ByteCode code;
			this.code = (code = __m.byteCode());
			
			// Initialize variable storage
			Object[] locals;
			this._locals = (locals = new Object[code.maxLocals()]);
			this._stack = new Object[code.maxStack()];
			
			// Copy arguments passed to the method
			for (int i = 0, n = __args.length, o = 0; i < n; i++)
			{
				Object av;
				locals[o++] = (av = __args[i]);
				
				// Add additional top for long/double
				if (av instanceof Long || av instanceof Double)
					locals[o++] = SpringStackTop.TOP;
			}
			
			// Store the this object, if needed
			this.thisobject = (__m.flags().isStatic() ? null :
				(SpringObject)__args[0]);
			
			// Debug
			/*todo.DEBUG.note("Frame has %d locals, %d stack", locals.length,
				this._stack.length);*/
		}
		
		/**
		 * Returns the byte code to execute.
		 *
		 * @return The byte code to execute.
		 * @since 2018/09/03
		 */
		public final ByteCode byteCode()
		{
			return this.code;
		}
		
		/**
		 * Clears the stack.
		 *
		 * @since 2018/10/13
		 */
		public final void clearStack()
		{
			this._stacktop = 0;
		}
		
		/**
		 * Increments the execution counter for this frame.
		 *
		 * @since 2018/10/12
		 */
		public final int incrementExecCount()
		{
			return this._execcount++;
		}
		
		/**
		 * Is this a blank frame?
		 *
		 * @return If this is a blank frame.
		 * @since 2018/09/20
		 */
		public final boolean isBlank()
		{
			return this.isblank;
		}
		
		/**
		 * Returns the last executed PC address.
		 *
		 * @return The last executed PC address.
		 * @since 2018/09/20
		 */
		public final int lastExecutedPc()
		{
			return this._lastexecpc;
		}
		
		/**
		 * Returns the source line of the last executed address.
		 *
		 * @return The source line for the last executed address.
		 * @since 2018/09/24
		 */
		public final int lastExecutedPcSourceLine()
		{
			ByteCode code = this.code;
			if (code == null)
				return -1;
			return code.lineOfAddress(this._lastexecpc);
		}
		
		/**
		 * Loads a value from local variables.
		 *
		 * @param <C> The type to return.
		 * @param __cl The type to return.
		 * @param __dx The index to load from.
		 * @return The read value.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/16
		 */
		public final <C> C loadLocal(Class<C> __cl, int __dx)
			throws NullPointerException
		{
			return __cl.cast(this._locals[__dx]);
		}
		
		/**
		 * Loads the specified value from a local variable and pushes it to
		 * the stack.
		 *
		 * @param __cl The expected class type.
		 * @param __dx The index to load from.
		 * @since 2018/09/08
		 */
		public final void loadToStack(Class<?> __cl, int __dx)
		{
			Object[] locals = this._locals;
			
			// {@squirreljme.error BK1p Cannot push local variable to the stack
			// because it of the incorrect type. (The varible to push; The
			// index to load from; The expected class; The value to push;
			// The type of value to push)}
			Object pushy = locals[__dx];
			if (!__cl.isInstance(pushy))
				throw new SpringVirtualMachineException(String.format(
					"BK1p %s %d %s %s %s", pushy, __dx, __cl, pushy,
					(pushy == null ? "null" : pushy.getClass())));
			
			// Just copy to the stack
			this.pushToStack(pushy);
		}
		
		/**
		 * Returns the method that this frame represents.
		 *
		 * @return The current method the frame is in.
		 * @since 2018/09/08
		 */
		public final SpringMethod method()
		{
			return this.method;
		}
		
		/**
		 * Returns the instruction counter.
		 *
		 * @return The instruction counter.
		 * @since 2018/09/03
		 */
		public final int pc()
		{
			return this._pc;
		}
		
		/**
		 * Returns the line of code the program counter is on.
		 *
		 * @return The program counter line of code.
		 * @since 2018/09/16
		 */
		public final int pcSourceLine()
		{
			return this.code.lineOfAddress(this._pc);
		}
		
		/**
		 * Pops from the stack.
		 *
		 * @return The popped value.
		 * @throws SpringVirtualMachineException If the stack underflows.
		 * @since 2018/09/09
		 */
		public final Object popFromStack()
			throws SpringVirtualMachineException
		{
			Object[] stack = this._stack;
			int stacktop = this._stacktop;
			
			// {@squirreljme.error BK1q Stack underflow. (The current top of
			// the stack; The stack limit)}
			if (stacktop <= 0)
				throw new SpringVirtualMachineException(String.format(
					"BK1q %d %d", stacktop, stack.length));
			
			// Read value and clear the value that was there
			Object rv = stack[--stacktop];
			stack[stacktop] = null;
			this._stacktop = stacktop;
			
			// {@squirreljme.error BK1r Popped a null value of the stack, which
			// should not occur.}
			if (rv == null)
				throw new SpringVirtualMachineException("BK1r");
			
			// Is top, so pop again to read the actual desired value
			if (rv == SpringStackTop.TOP)
			{
				rv = this.popFromStack();
				
				// {@squirreljme.error BK1s Expected long or double below
				// top entry in stack. (The current top of the stack; The
				// stack limit)}
				if (!(rv instanceof Long || rv instanceof Double))
					throw new SpringVirtualMachineException(String.format(
						"BK1s %d %d", stacktop, stack.length));
			}
			
			// Debug
			/*todo.DEBUG.note("popped(%s) <- %d", rv, stacktop);*/
			
			return rv;
		}
		
		/**
		 * Pops from the stack, checking the type.
		 *
		 * @param <C> The type to pop.
		 * @param __cl The type to pop.
		 * @return The popped data.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringVirtualMachineException If the type does not match or
		 * the stack underflows.
		 * @since 2018/09/15
		 */
		public final <C> C popFromStack(Class<C> __cl)
			throws NullPointerException, SpringVirtualMachineException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error BK1t Popped the wrong kind of value from the
			// stack. (The popped type; The expected type)}
			Object rv = this.popFromStack();
			if (!__cl.isInstance(rv))
				throw new SpringVirtualMachineException(
					String.format("BK1t %s %s",
						(rv == null ? null : rv.getClass()), __cl));
			
			return __cl.cast(rv);
		}
		
		/**
		 * Pops the given class from the stack and throws an exception if it
		 * is null.
		 *
		 * @param <C> The type to pop.
		 * @param __cl The type to pop.
		 * @return The popped data.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringNullPointerException If the popped item is null.
		 * @throws SpringVirtualMachineException If the type does not match or
		 * the stack underflows.
		 * @since 2018/12/11
		 */
		public final <C> C popFromStackNotNull(Class<C> __cl)
			throws NullPointerException, SpringNullPointerException,
				SpringVirtualMachineException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			// Pop from the stack
			Object rv = this.popFromStack();
			
			// {@squirreljme.error BK1u Did not expect a null value to be
			// popped from the stack.}
			if (rv == SpringNullObject.NULL ||
				(rv instanceof SpringNullObject))
				throw new SpringNullPointerException("BK1u");
			
			// {@squirreljme.error BK1v Popped the wrong kind of value from the
			// stack. (The popped type; The expected type)}
			if (!__cl.isInstance(rv))
				throw new SpringVirtualMachineException(
					String.format("BK1v %s %s",
						(rv == null ? null : rv.getClass()), __cl));
			
			return __cl.cast(rv);
		}
		
		/**
		 * Pushes the specified value to the stack.
		 *
		 * @param __v The value to push.
		 * @throws NullPointerException On null arguments.
		 * @throws SpringVirtualMachineException If the stack overflows or is
		 * not valid.
		 * @since 2018/09/08
		 */
		public final void pushToStack(Object __v)
			throws NullPointerException, SpringVirtualMachineException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			Object[] stack = this._stack;
			int stacktop = this._stacktop;
			
			// Debug
			/*todo.DEBUG.note("push(%s) -> %d", __v, stacktop);*/
			
			// {@squirreljme.error BK1w Stack overflow pushing value. (The
			// value; The current top of the stack; The stack limit)}
			if (stacktop >= stack.length)
				throw new SpringVirtualMachineException(String.format(
					"BK1w %s %d %d", __v, stacktop, stack.length));
			
			// Store
			stack[stacktop++] = __v;
			this._stacktop = stacktop;
			
			// Push an extra top for long and double
			if (__v instanceof Long || __v instanceof Double)
				this.pushToStack(SpringStackTop.TOP);
		}
		
		/**
		 * Sets the last executed PC address.
		 *
		 * @param __pc The last executed PC address.
		 * @since 2018/09/20
		 */
		public final void setLastExecutedPc(int __pc)
		{
			this._lastexecpc = __pc;
		}
		
		/**
		 * Sets the program counter.
		 *
		 * @param __pc The program counter to set.
		 * @since 2018/09/03
		 */
		public final void setPc(int __pc)
		{
			this._pc = __pc;
		}
		
		/**
		 * Stores the specified value at the given local variable index.
		 *
		 * @param __dx The index to store into.
		 * @param __v The value to store.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/09/15
		 */
		public final void storeLocal(int __dx, Object __v)
			throws NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			this._locals[__dx] = __v;
		}
		
		/**
		 * Returns the {@code this} of the current frame.
		 *
		 * @return The current this,
		 * @since 2018/09/09
		 */
		public final SpringObject thisObject()
		{
			return this.thisobject;
		}
		
		/**
		 * Returns the tossed exception.
		 *
		 * @return The exception being tossed.
		 * @since 2018/10/13
		 */
		public final SpringObject tossedException()
		{
			return this._tossedexception;
		}
		
		/**
		 * Sets the tossed exception for this frame.
		 *
		 * @param __o The exception tossed for this frame.
		 * @since 2018/10/13
		 */
		public final void tossException(SpringObject __o)
		{
			this._tossedexception = __o;
		}
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringThreadWorker.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// 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.jvm.CallStackItem;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.asm.ConsoleOutput;
import cc.squirreljme.runtime.cldc.asm.SystemAccess;
import cc.squirreljme.runtime.cldc.asm.SystemProperties;
import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import cc.squirreljme.runtime.cldc.lang.GuestDepth;
import cc.squirreljme.runtime.cldc.lang.OperatingSystemType;
import cc.squirreljme.vm.VMClassLibrary;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.ConstantValueClass;
import net.multiphasicapps.classfile.ConstantValueString;
import net.multiphasicapps.classfile.ExceptionHandler;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.IntMatchingJumpTable;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MemberFlags;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.classfile.MethodReference;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * A worker which runs the actual thread code in single-step fashion.
 *
 * @since 2018/09/03
 */
public final class SpringThreadWorker
	extends Thread
{
	/** Number of instructions which can be executed before warning. */
	private static final int _EXECUTION_THRESHOLD =
		200000;
	
	/** The owning machine. */
	protected final SpringMachine machine;
	
	/** The thread being run. */
	protected final SpringThread thread;
	
	/** The thread to signal instead for interrupt. */
	protected final Thread signalinstead;
	
	/** The current step count. */
	private volatile int _stepcount;
	
	/**
	 * Initialize the worker.
	 *
	 * @param __m The executing machine.
	 * @param __t The running thread.
	 * @param __main Is this the main thread? Used for interrupt hacking.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public SpringThreadWorker(SpringMachine __m, SpringThread __t,
		boolean __main)
		throws NullPointerException
	{
		if (__m == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.machine = __m;
		this.thread = __t;
		this.signalinstead = (__main ? Thread.currentThread() : null);
		
		// Set the thread's worker to this
		if (__t._worker == null)
			__t._worker = this;
		
		// {@squirreljme.error BK1x Thread already has a worker associated
		// with it.}
		else
			throw new SpringVirtualMachineException("BK1x");
	}
	
	/**
	 * Allocates the memory needed to store an array of the given class and
	 * of the given length.
	 *
	 * @param __cl The component type.
	 * @param __l The length of the array.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringNegativeArraySizeException If the array size is negative.
	 * @since 2018/09/15
	 */
	public final SpringArrayObject allocateArray(SpringClass __cl, int __l)
		throws NullPointerException, SpringNegativeArraySizeException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		SpringClass dim = this.resolveClass(__cl.name().addDimensions(1));
		switch (__cl.name().toString())
		{
				// Boolean
			case "boolean":
				return new SpringArrayObjectBoolean(dim, __cl, __l);
			
				// Byte
			case "byte":
				return new SpringArrayObjectByte(dim, __cl, __l);
				
				// Short
			case "short":
				return new SpringArrayObjectShort(dim, __cl, __l);
				
				// Char
			case "char":
				return new SpringArrayObjectChar(dim, __cl, __l);
				
				// Int
			case "int":
				return new SpringArrayObjectInteger(dim, __cl, __l);
				
				// Long
			case "long":
				return new SpringArrayObjectLong(dim, __cl, __l);
				
				// Float
			case "float":
				return new SpringArrayObjectFloat(dim, __cl, __l);
				
				// Float
			case "double":
				return new SpringArrayObjectDouble(dim, __cl, __l);
			
				// Generic array
			default:
				return new SpringArrayObjectGeneric(dim, __cl, __l);
		}
		
	}
	
	/**
	 * Allocates the memory needed to store an object of the given class.
	 *
	 * @param __cl The object to allocate.
	 * @return The allocated instance of the object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringObject allocateObject(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// The called constructor will allocate the space needed to store
		// this object
		return new SpringSimpleObject(__cl, this.machine.pointers);
	}
	
	/**
	 * Converts the specified virtual machine object to a native object.
	 *
	 * @param __in The input object.
	 * @return The resulting native object.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringFatalException If the object cannot be translated.
	 * @since 2018/09/20
	 */
	public final Object asNativeObject(Object __in)
		throws NullPointerException, SpringFatalException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Is null refernece
		else if (__in == SpringNullObject.NULL)
			return null;
		
		// Boxed types remain the same
		else if (__in instanceof Integer || __in instanceof Long ||
			__in instanceof Float || __in instanceof Double)
			return __in;
		
		// Array type
		else if (__in instanceof SpringArrayObject)
		{
			SpringArrayObject sao = (SpringArrayObject)__in;
			
			int len = sao.length();
			
			// Depends on the array type
			SpringClass sscl = sao.type();
			ClassName type = sscl.name();
			switch (type.toString())
			{
					// Char array
				case "[C":
					{
						char[] rv = new char[len];
						
						for (int i = 0; i < len; i++)
							rv[i] = (char)(sao.<Integer>get(Integer.class, i).
								intValue());
						
						return rv;
					}
					
					// String
				case "[Ljava/lang/String;":
					{
						String[] rv = new String[len];
						
						for (int i = 0; i < len; i++)
							rv[i] = this.<String>asNativeObject(String.class,
								sao.<SpringObject>get(SpringObject.class, i));
						
						return rv;
					}
				
					// {@squirreljme.error BK1y Do not know how to convert the
					// given virtual machine array to a native machine array.
					// (The input class)}
				default:
					throw new RuntimeException(
						String.format("BK1y %s", type));
			}
		}
		
		// Class type
		else if (__in instanceof SpringSimpleObject)
		{
			SpringSimpleObject sso = (SpringSimpleObject)__in;
			
			// Depends on the class type
			SpringClass sscl = sso.type();
			ClassName type = sscl.name();
			switch (type.toString())
			{
				case "java/lang/Integer":
					return Integer.valueOf((Integer)
						sso.fieldByField(sscl.lookupField(false,
						"_value", "I")).get());
				
				case "java/lang/String":
					return new String(this.<char[]>asNativeObject(
						char[].class, this.invokeMethod(false,
							new ClassName("java/lang/String"),
							new MethodNameAndType("toCharArray", "()[C"),
							sso)));
				
					// {@squirreljme.error BK1z Do not know how to convert the
					// given virtual machine class to a native machine object.
					// (The input class)}
				default:
					throw new RuntimeException(
						String.format("BK1z %s", type));
			}
		}
		
		// {@squirreljme.error BK20 Do not know how to convert the given class
		// to a native machine object. (The input class)}
		else
			throw new SpringFatalException(
				String.format("BK20 %s", __in.getClass()));
	}
	
	/**
	 * Converts the specified object to a native object or unwraps an array
	 * for direct access.
	 *
	 * @param <C> The resulting class type.
	 * @param __cl The class to cast to.
	 * @param __in The input object.
	 * @return The resulting object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/19
	 */
	public final <C> C asNativeObjectUnwrapArray(Class<C> __cl, Object __in)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException();
		
		if (__in instanceof SpringArrayObject)
			return __cl.cast(((SpringArrayObject)__in).array());
		return this.<C>asNativeObject(__cl, __in);
	}
	
	/**
	 * Converts the specified virtual machine object to a native object.
	 *
	 * @param <C> The class type.
	 * @param __cl The class type.
	 * @param __in The input object.
	 * @return The resulting native object.
	 * @throw NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public final <C> C asNativeObject(Class<C> __cl, Object __in)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this.asNativeObject(__in));
	}
	
	/**
	 * Converts the specified native object to a virtual machine object.
	 *
	 * @param __in The input object.
	 * @return The resulting VM object.
	 * @since 2018/09/16
	 */
	public final Object asVMObject(Object __in)
	{
		return this.asVMObject(__in, false);
	}
	
	/**
	 * Converts the specified native object to a virtual machine object.
	 *
	 * @param __in The input object.
	 * @param __noclassres Do not use class resolution? Just load the class?
	 * @return The resulting VM object.
	 * @since 2018/09/16
	 */
	public final Object asVMObject(Object __in, boolean __noclassres)
	{
		// Null is converted to null
		if (__in == null)
			return SpringNullObject.NULL;
		
		// As-is
		else if (__in instanceof Integer || __in instanceof Long ||
			__in instanceof Float || __in instanceof Double ||
			__in instanceof SpringObject)
			return __in;
		
		// Boolean to integer
		else if (__in instanceof Boolean)
			return Integer.valueOf((Boolean.TRUE.equals(__in) ? 1 : 0));
		
		// Character to Integer
		else if (__in instanceof Character)
			return Integer.valueOf(((Character)__in).charValue());
		
		// Promoted to integer
		else if (__in instanceof Byte || __in instanceof Short)
			return Integer.valueOf(((Number)__in).intValue());
		
		// Character array
		else if (__in instanceof char[])
		{
			char[] in = (char[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("char")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, (int)in[i]);
			
			return rv;
		}
		
		// Integer array
		else if (__in instanceof int[])
		{
			int[] in = (int[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("int")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, (int)in[i]);
			
			return rv;
		}
		
		// String array
		else if (__in instanceof String[])
		{
			String[] in = (String[])__in;
			
			// Setup return array
			int n = in.length;
			SpringArrayObject rv = this.allocateArray(
				this.loadClass(new ClassName("java/lang/String")), n);
			
			// Copy array values
			for (int i = 0; i < n; i++)
				rv.set(i, this.asVMObject(in[i]));
			
			return rv;
		}
		
		// Convertable exception
		else if (__in instanceof SpringConvertableThrowable)
		{
			SpringConvertableThrowable e = (SpringConvertableThrowable)__in;
			
			// Initialize new instance with this type, use the input message
			return this.newInstance(new ClassName(e.targetClass()),
				new MethodDescriptor("(Ljava/lang/String;)V"),
				this.asVMObject(e.getMessage()));
		}
		
		// String object
		else if (__in instanceof String)
		{
			String s = (String)__in;
			
			// Locate the string class
			SpringClass strclass = this.loadClass(
				new ClassName("java/lang/String"));
				
			// Setup an array of characters to represent the string data,
			// this is the simplest thing to do right now
			SpringObject array = (SpringObject)this.asVMObject(
				s.toString().toCharArray());
			
			// Setup string which uses this sequence
			SpringObject rv = this.newInstance(
				new ClassName("java/lang/String"),
				new MethodDescriptor("([CS)V"),
				array, 0);
			
			return rv;
		}
		
		// Constant string from the constant pool, which shared a global pool
		// of string objects! This must be made so that "aaa" == "aaa" is true
		// even across different classes!
		else if (__in instanceof ConstantValueString)
		{
			ConstantValueString cvs = (ConstantValueString)__in;
			
			// Get the string map but lock on the class loader because a class
			// might want a string but then another thread might be
			// initializing some class, and it will just deadlock as they wait
			// on each other
			SpringMachine machine = this.machine;
			Map<ConstantValueString, SpringObject> stringmap =
				machine.__stringMap();
			synchronized (machine.classLoader().classLoadingLock())
			{
				// Pre-cached object already exists?
				SpringObject rv = stringmap.get(cvs);
				if (rv != null)
					return rv;
				
				// Setup an array of characters to represent the string data,
				// this is the simplest thing to do right now
				SpringObject array = (SpringObject)this.asVMObject(
					cvs.toString().toCharArray());
				
				// Setup string which uses this sequence, but it also needs
				// to be interned!
				ClassName strclass = new ClassName("java/lang/String");
				rv = (SpringObject)this.invokeMethod(false, strclass,
					new MethodNameAndType("intern", "()Ljava/lang/String;"),
					this.newInstance(strclass, new MethodDescriptor("([CS)V"),
						array, 0));
				
				// Cache
				stringmap.put(cvs, rv);
				
				// Use it
				return rv;
			}
		}
		
		// A class object, as needed
		else if (__in instanceof ClassName ||
			__in instanceof ConstantValueClass ||
			__in instanceof SpringClass)
		{
			ClassName name = ((__in instanceof SpringClass) ?
				((SpringClass)__in).name() : ((__in instanceof ClassName) ?
				(ClassName)__in : ((ConstantValueClass)__in).className()));
			
			// Get the class object map but lock on the class loader since we
			// might end up just initializing classes and such
			SpringMachine machine = this.machine;
			Map<ClassName, SpringObject> com = machine.__classObjectMap();
			Map<SpringObject, ClassName> ocm = machine.
				__classObjectToNameMap();
			synchronized (machine.classLoader().classLoadingLock())
			{
				// Pre-cached object already exists?
				SpringObject rv = com.get(name);
				if (rv != null)
					return rv;
				
				// Resolve the input class, so it is initialized
				SpringClass resclass = (__noclassres ? this.loadClass(name) :
					this.resolveClass(name));
				
				// Resolve the class object
				SpringClass classobj = this.resolveClass(
					new ClassName("java/lang/Class"));
				
				// Copy interfaces into a class array
				SpringClass[] interfaces = resclass.interfaceClasses();
				int ni = interfaces.length;
				SpringArrayObject ints = this.allocateArray(classobj, ni);
				for (int i = 0; i < ni; i++)
					ints.set(i, this.asVMObject(interfaces[i]));
				
				// See if there is a default constructor
				SpringMethod defconmeth = resclass.lookupDefaultConstructor();
				
				// Get static method for this constructor
				int defconflags;
				SpringObject defconsm;
				if (defconmeth != null)
				{
					defconflags = defconmeth.flags().toJavaBits();
					defconsm = new SpringVMStaticMethod(defconmeth);
				}
				
				// There is none
				else
				{
					defconflags = 0;
					defconsm = SpringNullObject.NULL;
				}
				
				// Get the static method for enumeration values
				ClassFlags classflags = resclass.flags();
				SpringObject enumsm;
				if (classflags.isEnum())
					try
					{
						enumsm = new SpringVMStaticMethod(
							resclass.lookupMethod(true,
							new MethodName("values"),
							new MethodDescriptor(name.addDimensions(1).
							field())));
					}
					catch (SpringIncompatibleClassChangeException e)
					{
						enumsm = SpringNullObject.NULL;
					}
				else
					enumsm = SpringNullObject.NULL;
				
				// Initialize V1 class data which is initialized with class
				// data
				SpringObject cdata = this.newInstance(new ClassName(
					"cc/squirreljme/runtime/cldc/lang/ClassDataV1"),
					new MethodDescriptor("(ILjava/lang/String;" +
						"Ljava/lang/Class;[Ljava/lang/Class;" +
						"Ljava/lang/Class;Ljava/lang/String;II" +
						"Lcc/squirreljme/runtime/cldc/asm/StaticMethod;" +
						"Lcc/squirreljme/runtime/cldc/asm/StaticMethod;)V"),
					resclass.specialIndex(),
					this.asVMObject(name.toString(), true),
					this.asVMObject(resclass.superClass(), true),
					ints,
					(!resclass.isArray() ? SpringNullObject.NULL :
						this.asVMObject(resclass.componentType(), true)),
					this.asVMObject(resclass.inJar()),
					classflags.toJavaBits(),
					defconflags, defconsm, enumsm);
				
				// Initialize class with special class index and some class
				// information
				rv = this.newInstance(classobj.name(),
					new MethodDescriptor(
					"(Lcc/squirreljme/runtime/cldc/lang/ClassData;)V"), cdata);
				
				// Cache and use it
				com.put(name, rv);
				ocm.put(rv, name);
				return rv;
			}
		}
		
		// {@squirreljme.error BK21 Do not know how to convert the given class
		// to a virtual machine object. (The input class)}
		else
			throw new RuntimeException(
				String.format("BK21 %s", __in.getClass()));
	}
	
	/**
	 * As VM object, but boxed if a primitive.
	 *
	 * @param __in The object to convert.
	 * @return The converted object.
	 * @since 2018/11/19
	 */
	public final Object asVMObjectBoxed(Object __in)
	{
		// Null is converted to null
		if (__in == null)
			return SpringNullObject.NULL;
		
		// Box these
		else if (__in instanceof Integer)
			return this.newInstance(new ClassName("java/lang/Integer"),
				new MethodDescriptor("(I)V"), __in);
		else if (__in instanceof Long)
			return this.newInstance(new ClassName("java/lang/Long"),
				new MethodDescriptor("(J)V"), __in);
		else if (__in instanceof Float)
			return this.newInstance(new ClassName("java/lang/Float"),
				new MethodDescriptor("(F)V"), __in);
		else if (__in instanceof Double)
			return this.newInstance(new ClassName("java/lang/Double"),
				new MethodDescriptor("(D)V"), __in);
		
		// As-is
		else if (__in instanceof SpringObject)
			return __in;
		
		else
			return this.asVMObject(__in);
	}
	
	/**
	 * As VM object, if it is an array it is wrapped otherwise if the object is
	 * a primitive type it becomes boxed.
	 *
	 * @param __in The object to convert.
	 * @return The converted object.
	 * @since 2018/12/03
	 */
	public final Object asVMObjectBoxedOrWrappedArray(Object __in)
	{
		if (__in == null)
			return SpringNullObject.NULL;
		
		// Array types
		else if (__in instanceof boolean[] ||
			__in instanceof byte[] ||
			__in instanceof short[] ||
			__in instanceof char[] ||
			__in instanceof int[] ||
			__in instanceof long[] ||
			__in instanceof float[] ||
			__in instanceof double[])
			return this.asWrappedArray(__in);
		
		// As boxed type instead
		else
			return this.asVMObjectBoxed(__in);
	}
	
	/**
	 * Wraps the native array so that it is directly read and written in
	 * the VM code.
	 *
	 * @param __a The object to convert.
	 * @return The object representing the array.
	 * @throws RuntimeException If the type is not an array.
	 * @since 2018/11/18
	 */
	public final SpringObject asWrappedArray(Object __a)
		throws RuntimeException
	{
		if (__a == null)
			return SpringNullObject.NULL;
		
		// Boolean
		else if (__a instanceof boolean[])
			return new SpringArrayObjectBoolean(
				this.loadClass(new ClassName("[Z")),
				this.loadClass(new ClassName("boolean")),
				(boolean[])__a);
		
		// Byte
		else if (__a instanceof byte[])
			return new SpringArrayObjectByte(
				this.loadClass(new ClassName("[B")),
				this.loadClass(new ClassName("byte")),
				(byte[])__a);
		
		// Short
		else if (__a instanceof short[])
			return new SpringArrayObjectShort(
				this.loadClass(new ClassName("[S")),
				this.loadClass(new ClassName("short")),
				(short[])__a);
		
		// Character
		else if (__a instanceof char[])
			return new SpringArrayObjectChar(
				this.loadClass(new ClassName("[C")),
				this.loadClass(new ClassName("char")),
				(char[])__a);
		
		// Integer
		else if (__a instanceof int[])
			return new SpringArrayObjectInteger(
				this.loadClass(new ClassName("[I")),
				this.loadClass(new ClassName("int")),
				(int[])__a);
		
		// Long
		else if (__a instanceof long[])
			return new SpringArrayObjectLong(
				this.loadClass(new ClassName("[J")),
				this.loadClass(new ClassName("long")),
				(long[])__a);
		
		// Float
		else if (__a instanceof float[])
			return new SpringArrayObjectFloat(
				this.loadClass(new ClassName("[F")),
				this.loadClass(new ClassName("float")),
				(float[])__a);
		
		// Double
		else if (__a instanceof double[])
			return new SpringArrayObjectDouble(
				this.loadClass(new ClassName("[D")),
				this.loadClass(new ClassName("double")),
				(double[])__a);
		
		// {@squirreljme.error BK22 Cannot wrap this as a native array.
		// (The input class type)}
		else
			throw new RuntimeException("BK22 " + __a.getClass());
	}
	
	/**
	 * Checks if the given class may be accessed.
	 *
	 * @param __cl The class to access.
	 * @return {@code true} if it may be accessed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean checkAccess(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// If the target class is public then we can access it
		ClassFlags targetflags = __cl.flags();
		if (targetflags.isPublic())
			return true;
		
		// Get our current class
		SpringClass self = this.contextClass();
		
		// No current class, treat as always valid
		if (self == null)
			return true;
		
		// Allow object and class unlimited access to anything
		ClassName cn = self.name();
		if (cn.toString().equals("java/lang/Object") ||
			cn.toString().equals("java/lang/Class"))
			return true;
		
		// This is ourself so access is always granted
		else if (__cl == self)
			return true;
		
		// Protected class, we must be a super class
		else if (targetflags.isProtected())
		{
			for (SpringClass r = self; r != null; r = r.superClass())
				if (__cl == r)
					return true;
		}
		
		// Must be in the same package
		else if (targetflags.isPackagePrivate())
		{
			if (self.name().inPackage().equals(__cl.name().inPackage()))
				return true;
		}
		
		// This should not occur
		else
			throw new todo.OOPS();
		
		// No access permitted
		return false;
	}
	
	/**
	 * Checks if the given member can be accessed.
	 *
	 * @param __m The member to check.
	 * @return If the member can be accessed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/09
	 */
	public final boolean checkAccess(SpringMember __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Need the current and the target class to check permissions
		SpringClass self = this.contextClass(),
			target = this.loadClass(__m.inClass());
		
		// No current class, treat as always valid
		if (self == null)
			return true;
		
		// If in the same class all access is permitted
		if (self == target)
			return true;
		
		// Public has full access
		MemberFlags flags = __m.flags();
		if (flags.isPublic())
			return true;
		
		// Protected class, we must be a super class
		else if (flags.isProtected())
		{
			for (SpringClass r = self; r != null; r = r.superClass())
				if (target == r)
					return true;
			
			// Otherwise it has to be in the same package
			if (self.name().inPackage().equals(target.name().inPackage()))
				return true;
		}
		
		// Classes must be in the same package
		else if (flags.isPackagePrivate())
		{
			if (self.name().inPackage().equals(target.name().inPackage()))
				return true;
		}
		
		// Access not permitted
		return false;
	}
	
	/**
	 * Returns the current class context, if any.
	 *
	 * @return The current class context or {@code null} if there is none.
	 * @since 2018/09/09
	 */
	public final SpringClass contextClass()
	{
		SpringThread thread = this.thread;
		SpringThread.Frame[] frames = thread.frames();
		
		// Go through frames
		for (int n = frames.length, i = n - 1; i >= 0; i--)
		{
			SpringThread.Frame frame = frames[i];
			
			// No method, could be a blank frame
			SpringMethod m = frame.method();
			if (m == null)
				continue;
			
			// If this is the assembly classes, treat it as if the caller were
			// doing things rather than the asm classes itself
			ClassName icl = frame.method().inClass();
			if (icl.toString().startsWith("cc/squirreljme/runtime/cldc/asm/"))
				continue;
			
			return this.machine.classLoader().loadClass(icl);
		}
		
		return null;
	}
	
	/**
	 * Invokes the given method.
	 *
	 * @param __static Is the method static?
	 * @param __cl The class name.
	 * @param __nat The name and type.
	 * @param __args The arguments.
	 * @return The return value, if any.
	 * @since 2018/09/20
	 */
	public final Object invokeMethod(boolean __static, ClassName __cl,
		MethodNameAndType __nat, Object... __args)
		throws NullPointerException
	{
		if (__cl == null || __nat == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Lookup class and method for the static method
		SpringClass cl;
		SpringMethod method;
		if (__static)
		{
			cl = this.resolveClass(__cl);
			method = cl.lookupMethod(__static, __nat);
		}
		
		// Call it based on the object instead
		else
		{
			cl = ((SpringObject)__args[0]).type();
			method = cl.lookupMethod(false, __nat);
		} 
		
		// Overflow or exceptions might occur
		int framelimit;
		SpringThread.Frame blank, execframe;
		SpringThread thread = this.thread;
		try
		{
			// Add blank frame for protection, this is used to hold the return
			// value on the stack
			blank = thread.enterBlankFrame();
			
			// Enter the method we really want to execute
			framelimit = thread.numFrames();
			execframe = thread.enterFrame(method, __args);
			
			// Execute this method
			this.run(framelimit);
		}
		
		// Exception when running which was not caught
		catch (SpringVirtualMachineException e)
		{
			// Print the thread trace
			thread.printStackTrace(System.err);
			
			// Propogate up
			throw e;
		}
		
		// This is an error unless the thread signaled exit
		SpringThread.Frame currentframe = thread.currentFrame();
		if (currentframe != blank)
		{
			// If our thread just happened to signal an exit of the VM, then
			// the current frame will be invalid anyway, so since the
			// exception or otherwise might be signaled we must make an
			// exception for exit here so it continues going down.
			if (thread._signaledexit)
				throw new SpringMachineExitException(this.machine._exitcode);
			
			// {@squirreljme.error BK23 Current frame is not our blank frame.}
			throw new SpringVirtualMachineException("BK23");
		}
		
		// Read return value from the blank frame
		Object rv;
		if (__nat.type().hasReturnValue())
			rv = blank.popFromStack();
		else
			rv = null;
		
		// Pop the blank frame, we do not need it anymore
		thread.popFrame();
		
		// Return the popped value
		return rv;
	}
	
	/**
	 * Loads the specified class, potentially performing initialization on it
	 * if it has not been initialized.
	 *
	 * @param __cn The class to load.
	 * @return The loaded class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringClass loadClass(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// Use the class loading lock to prevent other threads from loading or
		// initializing classes while this thread does such things
		SpringClassLoader classloader = this.machine.classLoader();
		synchronized (classloader.classLoadingLock())
		{
			// Load the class from the class loader
			return this.loadClass(classloader.loadClass(__cn));
		}
	}
	
	/**
	 * Loads the specified class.
	 *
	 * @param __cl The class to load.
	 * @return {@code __cl}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	public final SpringClass loadClass(SpringClass __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Use the class loading lock to prevent other threads from loading or
		// initializing classes while this thread does such things
		SpringMachine machine = this.machine;
		SpringClassLoader classloader = machine.classLoader();
		synchronized (classloader.classLoadingLock())
		{
			// If the class has already been initialized then the class is
			// ready to be used
			if (__cl.isInitialized())
				return __cl;
			
			// Debug
			/*todo.DEBUG.note("Need to initialize %s.", __cl.name());*/
			
			// Set the class as initialized early to prevent loops, because
			// a super class might call something from the base class which
			// might be seen as initialized when it should not be. So this is
			// to prevent bad things from happening.
			__cl.setInitialized();
			
			// Initialize the static field map
			Map<SpringField, SpringFieldStorage> sfm =
				machine.__staticFieldMap();
			for (SpringField f : __cl.fieldsOnlyThisClass())
				if (f.isStatic())
					sfm.put(f, new SpringFieldStorage(f));
			
			// Recursively call self to load the super class before this class
			// is handled
			SpringClass clsuper = __cl.superClass();
			if (clsuper != null)
				this.loadClass(clsuper);
			
			// Go through interfaces and do the same
			for (SpringClass iface : __cl.interfaceClasses())
				this.loadClass(iface);
			
			// Look for static constructor for this class to initialize it as
			// needed
			SpringMethod init;
			try
			{
				init = __cl.lookupMethod(true,
					new MethodNameAndType("<clinit>", "()V"));
			}
			
			// No static initializer exists
			catch (SpringNoSuchMethodException e)
			{
				init = null;
				
				// Debug
				/*todo.DEBUG.note("Class %s has no static initializer.",
					__cl.name());*/
			}
			
			// Static initializer exists, setup a frame and call it
			if (init != null)
			{
				// Stop execution when the initializer exits
				SpringThread thread = this.thread;
				int framelimit = thread.numFrames();
				
				// Enter the static initializer
				thread.enterFrame(init);
				
				// Execute until it finishes
				this.run(framelimit);
			}
		}
		
		// Return the input class
		return __cl;
	}
	
	/**
	 * Handles a native action within the VM.
	 *
	 * Note that the return value should be a native type, it is translated
	 * as needed.
	 *
	 * @param __func The function to call.
	 * @param __args The arguments to the function.
	 * @return The result from the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final Object nativeMethod(String __func, Object... __args)
		throws NullPointerException
	{
		if (__func == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Debug
		/*todo.DEBUG.note("Call native %s", __func);*/
		
		// Depends on the function
		switch (__func)
		{
				// Return the length of the array
			case "cc/squirreljme/jvm/Assembly::" +
				"arrayLength:(Ljava/lang/Object;)I":
				return ((SpringArrayObject)__args[0]).length();
				
				// Pack double together
			case "cc/squirreljme/jvm/Assembly::" +
				"doublePack:(II)D":
				return Double.longBitsToDouble(
					((((Integer)__args[0]).longValue() << 32L) |
					((((Integer)__args[1]).longValue()) & 0xFFFFFFFFL)));
				
				// Gets the raw bits for the given double value
			case "cc/squirreljme/jvm/Assembly::" +
				"doubleToRawLongBits:(D)J":
				return Double.doubleToRawLongBits((Double)__args[0]);
				
				// Float to raw int bits
			case "cc/squirreljme/jvm/Assembly::" +
				"floatToRawIntBits:(F)I":
				return Float.floatToRawIntBits((Float)__args[0]);
				
				// Int bits to float
			case "cc/squirreljme/jvm/Assembly::" +
				"intBitsToFloat:(I)F":
				return Float.intBitsToFloat((Integer)__args[0]);
				
				// Convert long bits to double
			case "cc/squirreljme/jvm/Assembly::" +
				"longBitsToDouble:(J)D":
				return Double.longBitsToDouble((Long)__args[0]);
				
				// Pack long together
			case "cc/squirreljme/jvm/Assembly::" +
				"longPack:(II)J":
				return ((((Integer)__args[0]).longValue() << 32L) |
					((((Integer)__args[1]).longValue()) & 0xFFFFFFFFL));
				
				// Unpack high long
			case "cc/squirreljme/jvm/Assembly::" +
				"longUnpackHigh:(L)I":
				return (int)((((Long)__args[0]).longValue()) >>> 32L);
				
				// Unpack low long
			case "cc/squirreljme/jvm/Assembly::" +
				"longUnpackLow:(L)I":
				return (int)(((Long)__args[0]).longValue());
				
				// Object to pointer
			case "cc/squirreljme/jvm/Assembly::" +
				"objectToPointer:(Ljava/lang/Object;)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"objectToPointerRefQueue:(Ljava/lang/Object;)I":
				return this.uniqueObjectToPointer((SpringObject)__args[0]);
				
				// Pointer to object
			case "cc/squirreljme/jvm/Assembly::" +
				"pointerToObject:(I)Ljava/lang/Object;":
				return this.uniquePointerToObject((Integer)__args[0]);
				
				// System calls (no return value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(S)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SI)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCall:(SIIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(S)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SI)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIIII)V":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallP:(SIIIIIIII)V":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					this.systemCall((short)si, ta);
					return null;
				}
				
				// System calls (returns value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(S)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SI)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallV:(SIIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(S)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SI)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIIII)I":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPV:(SIIIIIIII)I":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					return (int)this.systemCall((short)si, ta);
				}
				
				// System calls (returns long value)
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(S)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SI)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallVL:(SIIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(S)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SI)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIIII)J":
			case "cc/squirreljme/jvm/Assembly::" +
				"sysCallPVL:(SIIIIIIII)J":
				{
					// System call index and number of arguments used
					int si = (Integer)__args[0],
						na = __args.length - 1;
					
					// Copy argument values to integers
					int[] ta = new int[na];
					for (int i = 1, o = 0; o < na; i++, o++)
						ta[o] = (Integer)__args[i];
					
					// Do system call handler
					return (long)this.systemCall((short)si, ta);
				}
			
				// Read console buffer
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"displayRead:([I[BII)I":
				return 0;
				
				// Flush the console
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"flush:(I)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Flush if valid
					if (to != null)
					{
						to.flush();
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
			
				// Write to the console
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"write:(II)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Write if it exists
					if (to != null)
					{
						to.write((Integer)__args[1]);
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
				
				// Write to the console (bulk)
			case "cc/squirreljme/runtime/cldc/asm/ConsoleOutput::" +
				"write:(I[BII)I":
				{
					int fd = (Integer)__args[0];
					PrintStream to = (fd == ConsoleOutput.OUTPUT ?
						System.out : (fd == ConsoleOutput.ERROR ?
						System.err : null));
					
					// Write if it exists
					if (to != null)
					{
						to.write(
							(byte[])((SpringArrayObjectByte)__args[1]).array(),
							(Integer)__args[2],
							(Integer)__args[3]);
						return 0;
					}
					else
						return ConsoleOutput.ERROR_INVALIDFD;
				}
				
				// Accelerated graphics
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"accelGfx:(I)Z":
				return this.machine.nativedisplay.accelGfx(
					(Integer)__args[0]);
				
				// Accelerated graphics operation
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"accelGfxFunc:(II[Ljava/lang/Object;)Ljava/lang/Object;":
				{
					// The original array to be adapted
					SpringArrayObject sao = (SpringArrayObject)__args[2];
					int n = sao.length();
					
					// Wrap arrays or convert to native
					Object[] rawr = new Object[n];
					for (int i = 0; i < n; i++)
						rawr[i] = this.<Object>asNativeObjectUnwrapArray(
							Object.class, sao.<Object>get(Object.class, i));
					
					// Forward
					return this.asVMObjectBoxedOrWrappedArray(
						this.machine.nativedisplay.
						accelGfxFunc((Integer)__args[0], (Integer)__args[1],
						rawr));
				}
				
				// Capabilities of a display
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"capabilities:(I)I":
				return this.machine.nativedisplay.capabilities(
					(Integer)__args[0]);
					
				// Repaint display
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"displayRepaint:(IIIII)V":
				this.machine.nativedisplay.displayRepaint(
					(Integer)__args[0],
					(Integer)__args[1],
					(Integer)__args[2],
					(Integer)__args[3],
					(Integer)__args[4]);
				return null;
			
				// Framebuffer object
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"framebufferObject:(I)Ljava/lang/Object;":
				return this.asWrappedArray(this.machine.nativedisplay.
					framebufferObject((Integer)__args[0]));
				
				// Framebuffer palette
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"framebufferPalette:(I)[I":
				return this.asWrappedArray(this.machine.nativedisplay.
					framebufferPalette((Integer)__args[0]));
					
				// Framebuffer parameters
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"framebufferParameters:(I)[I":
				return this.asWrappedArray(this.machine.nativedisplay.
					framebufferParameters((Integer)__args[0]));
					
				// Framebuffer state count
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"framebufferStateCount:(I)I":
				return this.machine.nativedisplay.
					framebufferStateCount((Integer)__args[0]);
				
				// Capabilities of a display
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"isUpsideDown:(I)Z":
				return this.machine.nativedisplay.isUpsideDown(
					(Integer)__args[0]);
				
				// Number of displays
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"numDisplays:()I":
				return this.machine.nativedisplay.numDisplays();
				
				// Register event callback
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"registerEventCallback:(Lcc/squirreljme/runtime/cldc/" +
				"asm/NativeDisplayEventCallback;)V":
				this.machine.nativedisplay.registerEventCallback(
					new SpringDisplayEventCallback(this.machine,
					(SpringObject)__args[0]));
				return null;
				
				// Sets the display title
			case "cc/squirreljme/runtime/cldc/asm/NativeDisplayAccess::" +
				"setDisplayTitle:(ILjava/lang/String;)V":
				this.machine.nativedisplay.setDisplayTitle(
					((Integer)__args[0]).intValue(),
					this.<String>asNativeObject(String.class, __args[1]));
				return null;
				
				// Allocate object but do not construct it
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"allocateObject:(Ljava/lang/String;)Ljava/lang/Object;":
				return this.allocateObject(this.loadClass(
					new ClassName(this.<String>asNativeObject(
					String.class, ((SpringObject)__args[0])))));
			
				// Allocate array of a given class
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"arrayNew:(Ljava/lang/Class;I)Ljava/lang/Object;":
				{
					// Cannot do a reverse lookup
					SpringMachine machine = this.machine;
					Map<SpringObject, ClassName> ocm = machine.
						__classObjectToNameMap();
					synchronized (machine.classLoader().classLoadingLock())
					{
						// {@squirreljme.error BK24 Could not reverse class
						// object to class name.}
						ClassName cn = ocm.get((SpringObject)__args[0]);
						if (cn == null)
							throw new SpringVirtualMachineException("BK24");
						
						// Lookup class for the component type, we need it
						SpringClass cl = this.loadClass(cn.componentType());
						
						// Allocate array for the component type
						return this.allocateArray(cl,
							(Integer)__args[1]);
					}
				}
			
				// Get the class by the name of whatever is input
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classByName:(Ljava/lang/String;)Ljava/lang/Class;":
				try
				{
					return this.asVMObject(new ClassName(
						this.<String>asNativeObject(String.class,
						(SpringObject)__args[0])), true);
				}
				catch (SpringClassNotFoundException e)
				{
					return this.asVMObject(null);
				}
				
				// Returns the class data for a class object
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classData:(Ljava/lang/Class;)Lcc/squirreljme/" +
				"runtime/cldc/lang/ClassData;":
				return this.invokeMethod(false,
					new ClassName("java/lang/Class"),
					new MethodNameAndType("__classData",
					"()Lcc/squirreljme/runtime/cldc/lang/ClassData;"),
					(SpringObject)__args[0]);
				
				// Get the class object for an object
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"classOf:(Ljava/lang/Object;)Ljava/lang/Class;":
				{
					// Just use the input class of the type
					SpringObject so = (SpringObject)__args[0];
					return so.type();
				}
				
				// Check if thread holds the given lock
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"holdsLock:(ILjava/lang/Object;)Z":
				{
					SpringThread owner =
						((SpringObject)__args[1]).monitor()._owner;
					return (owner == null ? false :
						((Integer)__args[0]).intValue() == owner.id);
				}
				
				// Identity hash code
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"identityHashCode:(Ljava/lang/Object;)I":
				return System.identityHashCode(((SpringObject)__args[0]));
				
				// Invoke static method
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"invokeStatic:(Lcc/squirreljme/runtime/cldc/asm/" +
				"StaticMethod;[Ljava/lang/Object;)Ljava/lang/Object;":
				{
					// We will need this to pass object arguments
					SpringArrayObject vargs = (SpringArrayObject)__args[1];
					
					// Copy object values
					int n = vargs.length();
					Object[] xargs = new Object[n];
					for (int i = 0; i < n; i++)
						xargs[i] = vargs.get(Object.class, i);
					
					// The method to execute
					SpringMethod m = ((SpringVMStaticMethod)__args[0]).method;
					
					// Enter the frame for this method
					this.thread.enterFrame(m, xargs);
					
					// If the method has no return value, just push a null to
					// the stack
					if (!m.nameAndType().type().hasReturnValue())
						return SpringNullObject.NULL;
					
					// No return value, sort of
					return null;
				}
				
				// Monitor notify
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"monitorNotify:(Ljava/lang/Object;Z)I":
				return ((SpringObject)__args[0]).monitor().
					monitorNotify(this.thread,
					((Integer)__args[1]).intValue() != 0);
			
				// Monitor notify
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"monitorWait:(Ljava/lang/Object;JI)I":
				return ((SpringObject)__args[0]).monitor().
					monitorWait(this.thread, (Long)__args[1],
						(Integer)__args[2]);
				
				// Create new primitive weak reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"newWeakReference:" +
				"()Lcc/squirreljme/runtime/cldc/ref/PrimitiveReference;":
				{
					return new SpringPrimitiveWeakReference();
				}
				
				// Get reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"referenceGet:(Lcc/squirreljme/runtime/cldc/ref/" +
				"PrimitiveReference;)Ljava/lang/Object;":
				return ((SpringPrimitiveReference)__args[0]).get();
				
				// Set reference
			case "cc/squirreljme/runtime/cldc/asm/ObjectAccess::" +
				"referenceSet:(Lcc/squirreljme/runtime/cldc/ref/" +
				"PrimitiveReference;Ljava/lang/Object;)V":
				((SpringPrimitiveReference)__args[0]).set(
					(SpringObject)__args[1]);
				return null;
				
				// Returns the number of bytes available in the resource.
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"available:(I)I":
				return this.machine.resourceAccess().available(
					(Integer)__args[0]);
				
				// Close resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"close:(I)I":
				return this.machine.resourceAccess().close(
					(Integer)__args[0]);
				
				// Open resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"open:(Ljava/lang/String;Ljava/lang/String;)I":
				return this.machine.resourceAccess().open(
					this.<String>asNativeObject(String.class, __args[0]),
					this.<String>asNativeObject(String.class, __args[1]));
				
				// Read resource in JAR
			case "cc/squirreljme/runtime/cldc/asm/ResourceAccess::" +
				"read:(I[BII)I":
				return this.machine.resourceAccess().read(
					(Integer)__args[0],
					(byte[])((SpringArrayObjectByte)__args[1]).array(),
					(Integer)__args[2],
					(Integer)__args[3]);
			
				// List suites that are available
			case "cc/squirreljme/runtime/cldc/asm/SuiteAccess::" +
				"availableSuites:()[Ljava/lang/String;":
				return this.machine.suiteManager().listLibraryNames();
			
				// List current class path
			case "cc/squirreljme/runtime/cldc/asm/SuiteAccess::" +
				"currentClassPath:()[Ljava/lang/String;":
				{
					VMClassLibrary[] vp = this.machine.classloader.classPath();
					int n = vp.length;
					String[] rv = new String[n];
					for (int i = 0; i < n; i++)
						rv[i] = vp[i].name();
					return this.asVMObject(rv);
				}
				
				// Get environment variable
			case "cc/squirreljme/runtime/cldc/asm/SystemAccess::" +
				"getEnv:(Ljava/lang/String;)Ljava/lang/String;":
				return this.asVMObject(SystemAccess.getEnv(
					this.<String>asNativeObject(String.class, __args[0])));
			
				// Approximated executable path
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"executablePath:()Ljava/lang/String;":
				// Just use the one of the host VM, if it is known anyway
				return this.asVMObject(SystemProperties.executablePath());
				
				// The guest depth of this virtual machine
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"guestDepth:()I":
				return this.machine.guestdepth;
				
				// The class to use for an implementation of something, by
				// default
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"implementationClass:(Ljava/lang/String;)Ljava/lang/String;":
				return SpringNullObject.NULL;
				
				// VM e-mail
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMEmail:()Ljava/lang/String;":
				return "xerthesquirrel@gmail.com";
				
				// VM name
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMName:()Ljava/lang/String;":
				return "SquirrelJME SpringCoat";
				
				// VM URL
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMURL:()Ljava/lang/String;":
				return "http://squirreljme.cc/";
				
				// VM vendor
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMVendor:()Ljava/lang/String;":
				return "Stephanie Gawroriski";
				
				// VM Version
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"javaVMVersion:()Ljava/lang/String;":
				return "0.2.0";
				
				// Get the operating system type
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"operatingSystemType:()I":
				return OperatingSystemType.UNKNOWN;
				
				// Get system property
			case "cc/squirreljme/runtime/cldc/asm/SystemProperties::" +
				"systemProperty:(Ljava/lang/String;)Ljava/lang/String;":
				String pk = this.<String>asNativeObject(String.class,
					__args[0]),
					pv = this.machine._sysproperties.get(pk);
				if (pv != null)
					return pv;
				return System.getProperty(pk);
				
				// Current thread ID
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"currentThread:()I":
				return this.thread.id;
				
				// Set thread priority
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"setThreadPriority:(II)V":
				{
					SpringThread st = this.machine.getThread(
						(Integer)__args[0]);
					if (st != null)
					{
						SpringThreadWorker stw = st._worker;
						if (stw != null)
						{
							Thread signal = stw.signalinstead;
							if (signal != null)
								signal.setPriority((Integer)__args[1]);
							else
								stw.setPriority((Integer)__args[1]);
						}
					}
					
					return null;
				}
				
				// Interrupt the given thread
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"signalInterrupt:(I)V":
				{
					SpringThread st = this.machine.getThread(
						(Integer)__args[0]);
					if (st != null)
					{
						SpringThreadWorker stw = st._worker;
						if (stw != null)
						{
							Thread signal = stw.signalinstead;
							if (signal != null)
								signal.interrupt();
							else
								stw.interrupt();
						}
					}
					
					return null;
				}
				
				// Sleep
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"sleep:(JI)Z":
				try
				{
					long ms = (Long)__args[0];
					int ns = (Integer)__args[1];
					
					// Zero time is a yield
					if (ms == 0 && ns == 0)
						Thread.yield();
					
					// Otherwise sleep for given time
					else
						Thread.sleep(ms, ns);
					return 0;
				}
				catch (InterruptedException e)
				{
					return 1;
				}
				
				// Start Task
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startTask:([Ljava/lang/String;Ljava/lang/String;" +
				"[Ljava/lang/String;)I":
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startTask:([Ljava/lang/String;Ljava/lang/String;" +
				"[Ljava/lang/String;[Ljava/lang/String;" +
				"Lcc/squirreljme/runtime/cldc/asm/ConsoleCallback;" +
				"Lcc/squirreljme/runtime/cldc/asm/ConsoleCallback;)I":
				return this.machine.taskManager().startTask(
					this.<String[]>asNativeObject(String[].class, __args[0]),
					this.<String>asNativeObject(String.class, __args[1]),
					this.<String[]>asNativeObject(String[].class, __args[2]),
					this.machine.guestdepth);
				
				// Start Thread
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"startThread:(Ljava/lang/Thread;Ljava/lang/String;)I":
				{
					// Create thread
					String name;
					SpringThread thread = this.machine.createThread(
						(name = this.<String>asNativeObject(String.class,
							__args[1])));
					
					// Enter Thread's `__start()`
					SpringObject throbj = (SpringObject)__args[0];
					thread.enterFrame(this.resolveClass(
						new ClassName("java/lang/Thread")).lookupMethod(false,
						new MethodNameAndType("__start", "()V")), throbj);
					
					// Create worker for this thread
					SpringThreadWorker worker = new SpringThreadWorker(
						this.machine, thread, false);
					worker.start();
					
					// Return this thread ID
					return thread.id;
				}
				
				// Task status
			case "cc/squirreljme/runtime/cldc/asm/TaskAccess::" +
				"taskStatus:(I)I":
				return this.machine.taskManager().taskStatus(
					(Integer)__args[0]);
				
				// {@squirreljme.error BK25 Unknown native function. (The
				// native function)}
			default:
				throw new SpringVirtualMachineException(
					String.format("BK25 %s", __func));
		}
	}
	
	/**
	 * Creates a new instance of the given class and initializes it using the
	 * given arguments. Access checks are ignored.
	 *
	 * @param __cl The class to initialize.
	 * @param __desc The descriptor of the constructor.
	 * @param __args The arguments to the constructor.
	 * @return The newly created and setup object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final SpringObject newInstance(ClassName __cl,
		MethodDescriptor __desc, Object... __args)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.newInstance(this.loadClass(__cl), __desc, __args);
	}
	
	/**
	 * Creates a new instance of the given class and initializes it using the
	 * given arguments. Access checks are ignored.
	 *
	 * @param __cl The class to initialize.
	 * @param __desc The descriptor of the constructor.
	 * @param __args The arguments to the constructor.
	 * @return The newly created and setup object.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public final SpringObject newInstance(SpringClass __cl,
		MethodDescriptor __desc, Object... __args)
		throws NullPointerException
	{
		if (__cl == null || __desc == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Make sure this class is loaded
		__cl = this.loadClass(__cl);
		
		// Lookup constructor to this method
		SpringMethod cons = __cl.lookupMethod(false, new MethodName("<init>"),
			__desc);
		
		// Allocate the object
		SpringObject rv = this.allocateObject(__cl);
			
		// Stop execution when the constructor exits
		SpringThread thread = this.thread;
		int framelimit = thread.numFrames();
		
		// Need to pass the allocated object as the first argument
		int nargs = __args.length;
		Object[] callargs = new Object[nargs + 1];
		callargs[0] = rv;
		for (int i = 0, o = 1; i < nargs; i++, o++)
			callargs[o] = __args[i];
		
		// Enter the constructor
		thread.enterFrame(cons, callargs);
		
		// Execute until it finishes
		this.run(framelimit);
		
		// Return the resulting object
		return rv;
	}
	
	/**
	 * Resolves the given class, checking access.
	 *
	 * @param __cl The class to resolve.
	 * @return The resolved class.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIllegalAccessException If the class cannot be accessed.
	 * @since 2018/09/15
	 */
	public final SpringClass resolveClass(ClassName __cl)
		throws NullPointerException, SpringIllegalAccessException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK26 Could not access the specified class.
		// (The class to access; The context class)}
		SpringClass rv = this.loadClass(__cl);
		if (!this.checkAccess(rv))
			throw new SpringIllegalAccessException(String.format("BK26 %s %s",
				__cl, this.contextClass()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/03
	 */
	@Override
	public final void run()
	{
		// Run until there are no frames left
		this.run(0);
	}
	
	/**
	 * Runs the worker with a limit on the lowest frame that may be reached
	 * when execution finishes. This is needed in some cases to invoke methods
	 * and static initializers in auxiliary code without needing complex state
	 * or otherwise to handle such things.
	 *
	 * @param __framelimit The current frame depth execution will stop at.
	 * @throws IllegalArgumentException If the frame limit is negative.
	 * @since 2018/09/08
	 */
	public final void run(int __framelimit)
		throws IllegalArgumentException
	{
		SpringThread thread = this.thread;
		try
		{
			// {@squirreljme.error BK27 Cannot have a negative frame limit.
			// (The frame limit)}
			if (__framelimit < 0)
				throw new IllegalArgumentException(String.format("BK27 %d",
					__framelimit));
			
			// The thread is alive as long as there are still frames of
			// execution
			while (thread.numFrames() > __framelimit)
			{
				// Single step executing the top frame
				this.__singleStep();
			}
		}
		
		// If the VM is exiting then clear the execution stack before we go
		// away
		catch (SpringMachineExitException e)
		{
			// Thread is okay to exit!
			thread._terminate = true;
			thread._signaledexit = true;
			
			// Exit all frames
			thread.exitAllFrames();
			
			// Exit profiler stack
			thread.profiler.exitAll(System.nanoTime());
			
			// Do not rethrow though
			return;
		}
		
		// Caught exception
		catch (RuntimeException e)
		{
			// Frame limit is zero, so kill the thread
			if (__framelimit == 0)
			{
				PrintStream err = System.err;
				
				err.println("****************************");
				
				// Print the real stack trace
				err.println("*** EXTERNAL STACK TRACE ***");
				e.printStackTrace(err);
				err.println();
				
				// Print the VM seen stack trace
				err.println("*** INTERNAL STACK TRACE ***");
				thread.printStackTrace(err);
				err.println();
				
				err.println("****************************");
				
				// Terminate the thread
				thread._terminate = true;
				
				// Exit all frames
				thread.exitAllFrames();
				
				// Exit from all profiler threads
				thread.profiler.exitAll(System.nanoTime());
			}
			
			// Re-toss
			throw e;
		}
		
		// Terminate if the last frame
		finally
		{
			if (__framelimit == 0)
				thread._terminate = true;
		}
	}
	
	/**
	 * Checks if an exception is being thrown and sets up the state from it.
	 *
	 * @return True if an exception was detected.
	 * @since 2018/12/06
	 */
	boolean __checkException()
	{
		// Are we exiting in the middle of an exception throwing?
		this.machine.exitCheck();
		
		// Check if this frame handles the exception
		SpringThread.Frame frame = this.thread.currentFrame();
		SpringObject tossing = frame.tossedException();
		if (tossing != null)
		{
			// Handling the tossed exception, so do not try handling it again
			frame.tossException(null);
			
			// Handle it
			int pc = this.__handleException(tossing);
			if (pc < 0)
				return true;
			
			// Put it on an empty stack
			frame.clearStack();
			frame.pushToStack(tossing);
			
			// Execute at the handler address now
			frame.setPc(pc);
			return true;
		}
		
		// No exception thrown
		return false;
	}
	
	/**
	 * Handles the exception, if it is in this frame to be handled then it
	 * will say that the instruction is to be moved elsewhere. Otherwise it
	 * will flag the frame above that an exception occurred and should be
	 * handled.
	 *
	 * @param __o The object being thrown.
	 * @return The next PC address of the handler or a negative value if it
	 * is to proprogate to the above frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/13
	 */
	int __handleException(SpringObject __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
			
		// Are we exiting in the middle of an exception throwing?
		this.machine.exitCheck();
		
		// Need the current frame and its byte code
		SpringThread thread = this.thread;
		SpringThread.Frame frame = thread.currentFrame();
		ByteCode code = frame.byteCode();
		int pc = frame.lastExecutedPc();
		
		// Get the handler for the given exception at the
		// given address
		ExceptionHandler useeh = null;
		for (ExceptionHandler eh : code.exceptions().at(pc))
		{
			// Is this handler compatible for the thrown
			// exception?
			SpringClass ehcl = this.loadClass(eh.type());
			
			if (ehcl.isCompatible(__o))
			{
				useeh = eh;
				break;
			}
		}
		
		// No handler for this exception, so just go up the
		// stack and find a handler recursively up every frame
		if (useeh == null)
		{
			// Pop our current frame from the call stack
			thread.popFrame();
			
			// Did we run out of stack frames?
			SpringThread.Frame cf = thread.currentFrame();
			if (cf == null)
			{
				// Send our throwable to a special handler
				this.invokeMethod(true, new ClassName("cc/squirreljme/" +
					"runtime/cldc/lang/UncaughtExceptionHandler"),
					new MethodNameAndType("handle",
					"(Ljava/lang/Throwable;)V"), __o);
				
				// Just stop execution here
				return -1;
			}
			
			// Toss onto the new current frame
			cf.tossException(__o);
			
			// Stop executing here and let it continue on the
			// other top frame
			return -1;
		}
		
		// Otherwise jump to that address
		else
		{
			// Clear the stack frame and then push our
			// exception back onto the stack
			frame.clearStack();
			frame.pushToStack(__o);
			
			// Handle at this address
			return useeh.handlerAddress();
		}
	}
	
	/**
	 * Looks up the specified instance field specifier and returns the
	 * information for it.
	 *
	 * @param __f The field to lookup.
	 * @return The specified for the field.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the field is static.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/16
	 */
	private final SpringField __lookupInstanceField(FieldReference __f)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchFieldException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
			
		// {@squirreljme.error BK28 Could not access the target class for
		// instance field access. (The field reference)}
		SpringClass inclass = this.loadClass(__f.className());
		if (!this.checkAccess(inclass))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK28 %s", __f));
		
		// {@squirreljme.error BK29 Could not access the target field for
		// instance field access. (The field reference; The field flags)}
		SpringField field = inclass.lookupField(false,
			__f.memberNameAndType());
		if (!this.checkAccess(field))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK29 %s %s", __f, field.flags()));
		
		return field;
	}
	
	/**
	 * Looks up the specified static field and returns the storage for it.
	 *
	 * @param __f The field to lookup.
	 * @return The static field storage.
	 * @throws NullPointerException On null arguments.
	 * @throws SpringIncompatibleClassChangeException If the target field is
	 * not static.
	 * @throws SpringNoSuchFieldException If the field does not exist.
	 * @since 2018/09/09
	 */
	private final SpringFieldStorage __lookupStaticField(FieldReference __f)
		throws NullPointerException, SpringIncompatibleClassChangeException,
			SpringNoSuchFieldException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BK2a Could not access the target class for
		// static field access. (The field reference)}
		SpringClass inclass = this.loadClass(__f.className());
		if (!this.checkAccess(inclass))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK2a %s", __f));
		
		// {@squirreljme.error BK2b Could not access the target field for
		// static field access. (The field reference)}
		SpringField field = inclass.lookupField(true, __f.memberNameAndType());
		if (!this.checkAccess(field))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK2b %s", __f));
		
		// Lookup the global static field
		return this.machine.lookupStaticField(field);
	}
	
	/**
	 * Single step through handling a single instruction.
	 *
	 * This method uses strict floating point to make operations consistent.
	 *
	 * @since 2018/09/03
	 */
	private final strictfp void __singleStep()
	{
		// Need the current frame and its byte code
		SpringThread thread = this.thread;
		
		// Check if the VM is exiting, to discontinue execution if it has been
		// requested by any thread
		SpringMachine machine = this.machine;
		try
		{
			machine.exitCheck();
		}
		
		// If the VM is exiting then clear the execution stack before we go
		// away
		catch (SpringMachineExitException e)
		{
			// Thread is okay to exit!
			thread._terminate = true;
			
			// Exit profiler stack
			thread.profiler.exitAll(System.nanoTime());
			
			throw e;
		}
		
		// Increase the step count
		this._stepcount++;
		
		SpringThread.Frame frame = thread.currentFrame();
		ByteCode code = frame.byteCode();
		
		// Frame is execution
		int iec = frame.incrementExecCount();
		if (iec > 0 && (iec % _EXECUTION_THRESHOLD) == 0)
		{
			// {@squirreljme.error BK2c Execution seems to be stuck in this
			// method.}
			System.err.println("BK2c");
			this.thread.printStackTrace(System.err);
		}
		
		// Are these certain kinds of initializers? Because final fields are
		// writable during initialization accordingly
		SpringClass currentclass = this.contextClass();
		SpringMethod method = frame.method();
		boolean isstaticinit = method.isStaticInitializer(),
			isinstanceinit = method.isInstanceInitializer();
		
		// Determine the current instruction of execution
		int pc = frame.pc();
		Instruction inst = code.getByAddress(pc);
		
		// If we are tossing an exception, we need to handle it
		if (this.__checkException())
			return;
		
		// This PC is about to be executed, so set it as executed since if an
		// exception is thrown this could change potentially
		frame.setLastExecutedPc(pc);
		
		// Debug
		/*todo.DEBUG.note("step(%s %s::%s) -> %s", thread.name(),
			method.inClass(), method.nameAndType(), inst);*/
		
		// Used to detect the next instruction of execution following this,
		// may be set accordingly in the frame manually
		int nextpc = code.addressFollowing(pc),
			orignextpc = nextpc;
		
		// Handle individual instructions
		int opid;
		try
		{
			// Handle it
			switch ((opid = inst.operation()))
			{
					// Do absolutely nothing!
				case InstructionIndex.NOP:
					break;
					
					// Load object from array
				case InstructionIndex.AALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<SpringObject>get(
							SpringObject.class, dx));
					}
					break;
					
					// Store object to array
				case InstructionIndex.AASTORE:
					{
						SpringObject value = frame.<SpringObject>popFromStack(
							SpringObject.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Push null reference
				case InstructionIndex.ACONST_NULL:
					frame.pushToStack(SpringNullObject.NULL);
					break;
					
					// Load reference from local
				case InstructionIndex.ALOAD:
				case InstructionIndex.WIDE_ALOAD:
					frame.loadToStack(SpringObject.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load reference from local (short)
				case InstructionIndex.ALOAD_0:
				case InstructionIndex.ALOAD_1:
				case InstructionIndex.ALOAD_2:
				case InstructionIndex.ALOAD_3:
					frame.loadToStack(SpringObject.class,
						opid - InstructionIndex.ALOAD_0);
					break;
				
					// Allocate new array
				case InstructionIndex.ANEWARRAY:
					frame.pushToStack(this.allocateArray(this.resolveClass(
						inst.<ClassName>argument(0, ClassName.class)),
						frame.<Integer>popFromStack(Integer.class)));
					break;
					
					// Return reference
				case InstructionIndex.ARETURN:
					this.__vmReturn(thread,
						frame.<SpringObject>popFromStack(SpringObject.class));
					nextpc = Integer.MIN_VALUE;
					break;
					
					// Length of array
				case InstructionIndex.ARRAYLENGTH:
					frame.pushToStack(
						frame.<SpringArrayObject>popFromStackNotNull(
						SpringArrayObject.class).length());
					break;
					
					// Store reference to local variable
				case InstructionIndex.ASTORE:
				case InstructionIndex.WIDE_ASTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<SpringObject>popFromStack(SpringObject.class));
					break;
					
					// Store reference to local varibale
				case InstructionIndex.ASTORE_0:
				case InstructionIndex.ASTORE_1:
				case InstructionIndex.ASTORE_2:
				case InstructionIndex.ASTORE_3:
					{
						frame.storeLocal(opid - InstructionIndex.ASTORE_0,
							frame.<SpringObject>popFromStack(
								SpringObject.class));
					}
					break;
					
					// Throwing of an exception
				case InstructionIndex.ATHROW:
					nextpc = this.__handleException(
						frame.<SpringObject>popFromStack(SpringObject.class));
					if (nextpc < 0)
						return;
					break;
					
					// Push value
				case InstructionIndex.BIPUSH:
				case InstructionIndex.SIPUSH:
					frame.pushToStack(inst.<Integer>argument(
						0, Integer.class));
					break;
					
					// Checks casting from a type to another
				case InstructionIndex.CHECKCAST:
					{
						SpringClass as = this.resolveClass(inst.
							<ClassName>argument(0, ClassName.class));
						
						// This is just popped back on if it passes
						SpringObject pop = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2d Cannot cast object to the
						// target type. (The type to cast to; The type of the
						// object)}
						if (pop != SpringNullObject.NULL &&
							!as.isAssignableFrom(pop.type()))
							throw new SpringClassCastException(String.format(
								"BK2d %s %s", as, pop.type()));
						
						// Return the popped value
						else
							frame.pushToStack(pop);
					}
					break;
					
					// Double to float
				case InstructionIndex.D2F:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Float.valueOf((float)value));
					}
					break;
					
					// Double to int
				case InstructionIndex.D2I:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Double to long
				case InstructionIndex.D2L:
					{
						double value = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(Long.valueOf((long)value));
					}
					break;
				
					// Addiply double
				case InstructionIndex.DADD:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a + b);
					}
					break;
					
					// Compare double, NaN is positive
				case InstructionIndex.DCMPG:
					{
						double b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Double.isNaN(a) || Double.isNaN(b))
							frame.pushToStack(1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
				
					// Compare double, NaN is negative
				case InstructionIndex.DCMPL:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						
						if (Double.isNaN(a) || Double.isNaN(b))
							frame.pushToStack(-1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Double constant
				case InstructionIndex.DCONST_0:
				case InstructionIndex.DCONST_1:
					frame.pushToStack(
						Double.valueOf(opid - InstructionIndex.DCONST_0));
					break;
				
					// Divide double
				case InstructionIndex.DDIV:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load double from local variable
				case InstructionIndex.DLOAD:
				case InstructionIndex.WIDE_DLOAD:
					frame.loadToStack(Double.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load double from local variable
				case InstructionIndex.DLOAD_0:
				case InstructionIndex.DLOAD_1:
				case InstructionIndex.DLOAD_2:
				case InstructionIndex.DLOAD_3:
					frame.loadToStack(Double.class,
						opid - InstructionIndex.DLOAD_0);
					break;
				
					// Multiply double
				case InstructionIndex.DMUL:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate double
				case InstructionIndex.DNEG:
					{
						double a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(-a);
					}
					break;
				
					// Remainder double
				case InstructionIndex.DREM:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return double
				case InstructionIndex.DRETURN:
					this.__vmReturn(thread,
						frame.<Double>popFromStack(Double.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Subtract double
				case InstructionIndex.DSUB:
					{
						double b = frame.<Double>popFromStack(Double.class),
							a = frame.<Double>popFromStack(Double.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Store double to local variable
				case InstructionIndex.DSTORE:
				case InstructionIndex.WIDE_DSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Double>popFromStack(Double.class));
					break;
					
					// Store long to double variable
				case InstructionIndex.DSTORE_0:
				case InstructionIndex.DSTORE_1:
				case InstructionIndex.DSTORE_2:
				case InstructionIndex.DSTORE_3:
					frame.storeLocal(opid - InstructionIndex.DSTORE_0,
						frame.<Double>popFromStack(Double.class));
					break;
					
					// Duplicate top-most stack entry
				case InstructionIndex.DUP:
					{
						Object copy = frame.popFromStack();
						
						// {@squirreljme.error BK2e Cannot duplicate category
						// two type.}
						if (copy instanceof Long || copy instanceof Double)
							throw new SpringVirtualMachineException("BK2e");
						
						// Push twice!
						frame.pushToStack(copy);
						frame.pushToStack(copy);
					}
					break;
					
					// Duplicate top and place two down
				case InstructionIndex.DUP_X1:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2f Cannot duplicate and place
						// down below with two type.}
						if (a instanceof Long || a instanceof Double ||
							b instanceof Long || b instanceof Double)
							throw new SpringVirtualMachineException("BK2f");
						
						frame.pushToStack(a);
						frame.pushToStack(b);
						frame.pushToStack(a);
					}
					break;
					
					// Dup[licate top entry and place two or three down
				case InstructionIndex.DUP_X2:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2g Cannot duplicate cat2
						// type.}
						if (a instanceof Long || a instanceof Double)
							throw new SpringVirtualMachineException("BK2g");
						
						// Insert A below C
						if (b instanceof Long || b instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
						
						// Grab C as well and push below that
						else
						{
							Object c = frame.popFromStack();
							
							// {@squirreljme.error BK2h Cannot duplicate top
							// most entry and place two down because a cat2
							// type is in the way.}
							if (c instanceof Long || c instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2h");
									
							frame.pushToStack(a);
							frame.pushToStack(c);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
					
					// Duplicate top two cat1s or single cat2
				case InstructionIndex.DUP2:
					{
						Object a = frame.popFromStack();
						
						// Just cat two
						if (a instanceof Long || a instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(a);
						}
						
						// Double values
						else
						{
							Object b = frame.popFromStack();
							
							// {@squirreljme.error BK2i Cannot duplicate top
							// two values.}
							if (b instanceof Long || b instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2i");
							
							frame.pushToStack(b);
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
					
					// Duplicate top one or two operand values and insert two
					// or three values down
				case InstructionIndex.DUP2_X1:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// {@squirreljme.error BK2j Expected category one
						// type.}
						if (b instanceof Long || b instanceof Double)
							throw new SpringVirtualMachineException(
								"BK2j");
						
						// Insert this below b
						if (a instanceof Long || a instanceof Double)
						{
							frame.pushToStack(a);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
						
						// Three cat1 values
						else
						{
							Object c = frame.popFromStack();
							
							// {@squirreljme.error BK2k Cannot duplicate value
							// below category two type.}
							if (c instanceof Long || c instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2k");
							
							frame.pushToStack(b);
							frame.pushToStack(a);
							frame.pushToStack(c);
							frame.pushToStack(b);
							frame.pushToStack(a);
						}
					}
					break;
				
					// Duplicate top one or two stack entries and insert
					// two, three, or four down
				case InstructionIndex.DUP2_X2:
					{
						Object a = frame.popFromStack(),
							b = frame.popFromStack();
						
						// Category two is on top
						if (a instanceof Long || a instanceof Double)
						{
							// Category two is on bottom (form 4)
							if (b instanceof Long || b instanceof Double)
							{
								frame.pushToStack(a);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
							
							// Category ones on bottom (form 2)
							else
							{
								Object c = frame.popFromStack();
								
								// {@squirreljme.error BK2l Cannot pop cat2
								// type for dup.}
								if (c instanceof Long || c instanceof Double)
									throw new SpringVirtualMachineException(
										"BK2l");
								
								frame.pushToStack(a);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
						}
						
						// Category one is on top
						else
						{
							// {@squirreljme.error BK2m Category two type
							// cannot be on the bottom.}
							if (b instanceof Long || b instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2m");
							
							Object c = frame.popFromStack();
							
							// C is category two (Form 3)
							if (c instanceof Long || c instanceof Double)
							{
								frame.pushToStack(b);
								frame.pushToStack(a);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
							
							// Category one on bottom (Form 1)
							else
							{
								Object d = frame.popFromStack();
								
								// {@squirreljme.error BK2n Bottommost entry
								// cannot be cat2 type.}
								if (d instanceof Long || d instanceof Double)
									throw new SpringVirtualMachineException(
										"BK2n");
								
								frame.pushToStack(b);
								frame.pushToStack(a);
								frame.pushToStack(d);
								frame.pushToStack(c);
								frame.pushToStack(b);
								frame.pushToStack(a);
							}
						}
					}
					break;
					
					// Float to double
				case InstructionIndex.F2D:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Double.valueOf((double)value));
					}
					break;
					
					// Float to integer
				case InstructionIndex.F2I:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Float to long
				case InstructionIndex.F2L:
					{
						float value = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(Long.valueOf((long)value));
					}
					break;
				
					// Add float
				case InstructionIndex.FADD:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// Compare float, NaN is positive
				case InstructionIndex.FCMPG:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Float.isNaN(a) || Float.isNaN(b))
							frame.pushToStack(1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
				
					// Compare float, NaN is negative
				case InstructionIndex.FCMPL:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						
						if (Float.isNaN(a) || Float.isNaN(b))
							frame.pushToStack(-1);
						else
							frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Float constant
				case InstructionIndex.FCONST_0:
				case InstructionIndex.FCONST_1:
				case InstructionIndex.FCONST_2:
					frame.pushToStack(
						Float.valueOf(opid - InstructionIndex.FCONST_0));
					break;
				
					// Divide float
				case InstructionIndex.FDIV:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load float from local variable
				case InstructionIndex.FLOAD:
				case InstructionIndex.WIDE_FLOAD:
					frame.loadToStack(Float.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load float from local variable
				case InstructionIndex.FLOAD_0:
				case InstructionIndex.FLOAD_1:
				case InstructionIndex.FLOAD_2:
				case InstructionIndex.FLOAD_3:
					frame.loadToStack(Float.class,
						opid - InstructionIndex.FLOAD_0);
					break;
				
					// Multiply float
				case InstructionIndex.FMUL:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate float
				case InstructionIndex.FNEG:
					{
						float a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(-a);
					}
					break;
				
					// Remainder float
				case InstructionIndex.FREM:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return float
				case InstructionIndex.FRETURN:
					this.__vmReturn(thread,
						frame.<Float>popFromStack(Float.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Subtract float
				case InstructionIndex.FSUB:
					{
						float b = frame.<Float>popFromStack(Float.class),
							a = frame.<Float>popFromStack(Float.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Store float to local variable
				case InstructionIndex.FSTORE:
				case InstructionIndex.WIDE_FSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Float>popFromStack(Float.class));
					break;
					
					// Store float to local variable
				case InstructionIndex.FSTORE_0:
				case InstructionIndex.FSTORE_1:
				case InstructionIndex.FSTORE_2:
				case InstructionIndex.FSTORE_3:
					frame.storeLocal(opid - InstructionIndex.FSTORE_0,
						frame.<Float>popFromStack(Float.class));
					break;
					
					// Read from instance field
				case InstructionIndex.GETFIELD:
					{
						// Lookup field
						SpringField ssf = this.__lookupInstanceField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Pop the object to read from
						SpringObject ref = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2o Cannot read value from
						// null reference.}
						if (ref == SpringNullObject.NULL)
							throw new SpringNullPointerException("BK2o");
						
						// {@squirreljme.error BK2p Cannot read value from
						// this instance because it not a simple object.}
						if (!(ref instanceof SpringSimpleObject))
							throw new SpringIncompatibleClassChangeException(
								"BK2p");
						SpringSimpleObject sso = (SpringSimpleObject)ref;
						
						// Read and push to the stack
						frame.pushToStack(this.asVMObject(
							sso.fieldByIndex(ssf.index()).get()));
					}
					break;
					
					// Read static variable
				case InstructionIndex.GETSTATIC:
					{
						// Lookup field
						SpringFieldStorage ssf = this.__lookupStaticField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Push read value to stack
						frame.pushToStack(this.asVMObject(ssf.get()));
					}
					break;
					
					// Go to address
				case InstructionIndex.GOTO:
				case InstructionIndex.GOTO_W:
					nextpc = inst.<InstructionJumpTarget>argument(0,
						InstructionJumpTarget.class).target();
					break;
					
					// Load integer from array
				case InstructionIndex.BALOAD:
				case InstructionIndex.CALOAD:
				case InstructionIndex.SALOAD:
				case InstructionIndex.IALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Integer>get(Integer.class, dx));
					}
					break;
					
					// Load double from array
				case InstructionIndex.DALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Double>get(Double.class, dx));
					}
					break;
					
					// Load float from array
				case InstructionIndex.FALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Float>get(Float.class, dx));
					}
					break;
					
					
					// Load long from array
				case InstructionIndex.LALOAD:
					{
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						frame.pushToStack(obj.<Long>get(Long.class, dx));
					}
					break;
					
					// Store integer to array (compatible)
				case InstructionIndex.BASTORE:
				case InstructionIndex.CASTORE:
				case InstructionIndex.SASTORE:
				case InstructionIndex.IASTORE:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store double to array
				case InstructionIndex.DASTORE:
					{
						double value = frame.<Double>popFromStack(
							Double.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store float to array
				case InstructionIndex.FASTORE:
					{
						float value = frame.<Float>popFromStack(Float.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Store long to array
				case InstructionIndex.LASTORE:
					{
						long value = frame.<Long>popFromStack(Long.class);
						int dx = frame.<Integer>popFromStack(Integer.class);
						SpringArrayObject obj = frame.<SpringArrayObject>
							popFromStackNotNull(SpringArrayObject.class);
						
						obj.set(dx, value);
					}
					break;
					
					// Integer to byte
				case InstructionIndex.I2B:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Byte.valueOf((byte)value).
							intValue());
					}
					break;
					
					// Integer to double
				case InstructionIndex.I2D:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Double.valueOf(value));
					}
					break;
					
					// Integer to long
				case InstructionIndex.I2L:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Long.valueOf(value));
					}
					break;
					
					// Integer to character
				case InstructionIndex.I2C:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Integer.valueOf((char)value));
					}
					break;
					
					// Integer to short
				case InstructionIndex.I2S:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Integer.valueOf((short)value));
					}
					break;
					
					// Integer to float
				case InstructionIndex.I2F:
					{
						int value = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(Float.valueOf(value));
					}
					break;
					
					// Integer constant
				case InstructionIndex.ICONST_M1:
				case InstructionIndex.ICONST_0:
				case InstructionIndex.ICONST_1:
				case InstructionIndex.ICONST_2:
				case InstructionIndex.ICONST_3:
				case InstructionIndex.ICONST_4:
				case InstructionIndex.ICONST_5:
					frame.pushToStack(Integer.valueOf(
						-1 + (opid - InstructionIndex.ICONST_M1)));
					break;
					
					// Object a == b
				case InstructionIndex.IF_ACMPEQ:
					{
						SpringObject b = frame.<SpringObject>popFromStack(
								SpringObject.class),
							a = frame.<SpringObject>popFromStack(
								SpringObject.class);
						
						if (a == b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// Object a != b
				case InstructionIndex.IF_ACMPNE:
					{
						SpringObject b = frame.<SpringObject>popFromStack(
								SpringObject.class),
							a = frame.<SpringObject>popFromStack(
								SpringObject.class);
						
						if (a != b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a == b
				case InstructionIndex.IF_ICMPEQ:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a == b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a >= b
				case InstructionIndex.IF_ICMPGE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a >= b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a > b
				case InstructionIndex.IF_ICMPGT:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a > b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a <= b
				case InstructionIndex.IF_ICMPLE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a <= b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a < b
				case InstructionIndex.IF_ICMPLT:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a < b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a != b
				case InstructionIndex.IF_ICMPNE:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						
						if (a != b)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// int a == 0
				case InstructionIndex.IFEQ:
					if (frame.<Integer>popFromStack(Integer.class) == 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a >= 0
				case InstructionIndex.IFGE:
					if (frame.<Integer>popFromStack(Integer.class) >= 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a > 0
				case InstructionIndex.IFGT:
					if (frame.<Integer>popFromStack(Integer.class) > 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a <= 0
				case InstructionIndex.IFLE:
					if (frame.<Integer>popFromStack(Integer.class) <= 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a < 0
				case InstructionIndex.IFLT:
					if (frame.<Integer>popFromStack(Integer.class) < 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// int a != 0
				case InstructionIndex.IFNE:
					if (frame.<Integer>popFromStack(Integer.class) != 0)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// If reference is not null
				case InstructionIndex.IFNONNULL:
					if (frame.<SpringObject>popFromStack(
						SpringObject.class) != SpringNullObject.NULL)
						nextpc = inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class).target();
					break;
					
					// If reference is null
				case InstructionIndex.IFNULL:
					{
						SpringObject a = frame.<SpringObject>popFromStack(
							SpringObject.class);
						if (a == SpringNullObject.NULL)
							nextpc = inst.<InstructionJumpTarget>argument(0,
								InstructionJumpTarget.class).target();
					}
					break;
					
					// Increment local variable
				case InstructionIndex.IINC:
				case InstructionIndex.WIDE_IINC:
					{
						int dx = inst.<Integer>argument(0, Integer.class);
						frame.storeLocal(dx, frame.<Integer>loadLocal(
							Integer.class, dx) + inst.<Integer>argument(1,
							Integer.class));
					}
					break;
					
					// Load integer from local variable
				case InstructionIndex.ILOAD:
				case InstructionIndex.WIDE_ILOAD:
					frame.loadToStack(Integer.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load integer from local variable
				case InstructionIndex.ILOAD_0:
				case InstructionIndex.ILOAD_1:
				case InstructionIndex.ILOAD_2:
				case InstructionIndex.ILOAD_3:
					frame.loadToStack(Integer.class,
						opid - InstructionIndex.ILOAD_0);
					break;
				
					// Addly integer
				case InstructionIndex.IADD:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// AND integer
				case InstructionIndex.IAND:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a & b);
					}
					break;
				
					// Divide integer
				case InstructionIndex.IDIV:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a / b);
					}
					break;
				
					// Multiply integer
				case InstructionIndex.IMUL:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate integer
				case InstructionIndex.INEG:
					{
						int a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(-a);
					}
					break;
					
					// Is the given object an instance of the given class?
				case InstructionIndex.INSTANCEOF:
					{
						// Check against this
						SpringClass as = this.resolveClass(inst.
							<ClassName>argument(0, ClassName.class));
						
						SpringClass vtype = frame.<SpringObject>popFromStack(
							SpringObject.class).type();
						frame.pushToStack((vtype != null &&
							as.isAssignableFrom(vtype) ? 1 : 0));
					}
					break;
					
					// Invoke interface method
				case InstructionIndex.INVOKEINTERFACE:
					this.__vmInvokeInterface(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke special method (constructor, superclass,
					// or private)
				case InstructionIndex.INVOKESPECIAL:
					this.__vmInvokeSpecial(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke static method
				case InstructionIndex.INVOKESTATIC:
					this.__vmInvokeStatic(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
					
					// Invoke virtual method
				case InstructionIndex.INVOKEVIRTUAL:
					this.__vmInvokeVirtual(inst, thread, frame);
					
					// Exception to be handled?
					if (this.__checkException())
						return;
					break;
				
					// OR integer
				case InstructionIndex.IOR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a | b);
					}
					break;
				
					// Remainder integer
				case InstructionIndex.IREM:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return integer
				case InstructionIndex.IRETURN:
					this.__vmReturn(thread,
						frame.<Integer>popFromStack(Integer.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Shift left integer
				case InstructionIndex.ISHL:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a << (b & 0x1F));
					}
					break;
				
					// Shift right integer
				case InstructionIndex.ISHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a >> (b & 0x1F));
					}
					break;
					
					// Store integer to local variable
				case InstructionIndex.ISTORE:
				case InstructionIndex.WIDE_ISTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Integer>popFromStack(Integer.class));
					break;
					
					// Store integer to local variable
				case InstructionIndex.ISTORE_0:
				case InstructionIndex.ISTORE_1:
				case InstructionIndex.ISTORE_2:
				case InstructionIndex.ISTORE_3:
					frame.storeLocal(opid - InstructionIndex.ISTORE_0,
						frame.<Integer>popFromStack(Integer.class));
					break;
				
					// Subtract integer
				case InstructionIndex.ISUB:
					{
						Integer b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a - b);
					}
					break;
				
					// Unsigned shift right integer
				case InstructionIndex.IUSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a >>> (b & 0x1F));
					}
					break;
				
					// XOR integer
				case InstructionIndex.IXOR:
					{
						int b = frame.<Integer>popFromStack(Integer.class),
							a = frame.<Integer>popFromStack(Integer.class);
						frame.pushToStack(a ^ b);
					}
					break;
					
					// Long to double
				case InstructionIndex.L2D:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Double.valueOf((double)value));
					}
					break;
					
					// Long to float
				case InstructionIndex.L2F:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Float.valueOf((float)value));
					}
					break;
					
					// Long to integer
				case InstructionIndex.L2I:
					{
						long value = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(Integer.valueOf((int)value));
					}
					break;
					
					// Add long
				case InstructionIndex.LADD:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a + b);
					}
					break;
				
					// And long
				case InstructionIndex.LAND:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a & b);
					}
					break;
				
					// Compare long
				case InstructionIndex.LCMP:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack((a < b ? -1 : (a > b ? 1 : 0)));
					}
					break;
					
					// Long constant
				case InstructionIndex.LCONST_0:
				case InstructionIndex.LCONST_1:
					frame.pushToStack(Long.valueOf(
						(opid - InstructionIndex.LCONST_0)));
					break;
					
					// Load from constant pool, push to the stack
				case InstructionIndex.LDC:
				case InstructionIndex.LDC_W:
					{
						ConstantValue value = inst.<ConstantValue>argument(0,
							ConstantValue.class);
						
						// Pushing a string, which due to the rules of Java
						// there must always be an equality (==) between two
						// strings, so "foo" == "foo" must be true even if it
						// is in different parts of the code
						// Additionally internall class objects are adapted
						// too as needed
						if (value instanceof ConstantValueString ||
							value instanceof ConstantValueClass)
							frame.pushToStack(this.asVMObject(value));
						
						// This will be pre-boxed so push it to the stack
						else
							frame.pushToStack(value.boxedValue());
					}
					break;
					
					// Load long or double from constant pool, to the stack
				case InstructionIndex.LDC2_W:
					frame.pushToStack(inst.<ConstantValue>argument(0,
						ConstantValue.class).boxedValue());
					break;
				
					// Divide long
				case InstructionIndex.LDIV:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a / b);
					}
					break;
					
					// Load integer from local variable
				case InstructionIndex.LLOAD:
				case InstructionIndex.WIDE_LLOAD:
					frame.loadToStack(Long.class,
						inst.<Integer>argument(0, Integer.class));
					break;
					
					// Load integer from local variable
				case InstructionIndex.LLOAD_0:
				case InstructionIndex.LLOAD_1:
				case InstructionIndex.LLOAD_2:
				case InstructionIndex.LLOAD_3:
					frame.loadToStack(Long.class,
						opid - InstructionIndex.LLOAD_0);
					break;
					
					// Multiply long
				case InstructionIndex.LMUL:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a * b);
					}
					break;
				
					// Negate long
				case InstructionIndex.LNEG:
					{
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(-a);
					}
					break;
					
					// OR long
				case InstructionIndex.LOR:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a | b);
					}
					break;
					
					// Subtract long
				case InstructionIndex.LSUB:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a - b);
					}
					break;
					
					// Lookup in a jump table
				case InstructionIndex.LOOKUPSWITCH:
				case InstructionIndex.TABLESWITCH:
					nextpc = inst.<IntMatchingJumpTable>argument(0,
						IntMatchingJumpTable.class).match(
						frame.<Integer>popFromStack(Integer.class)).target();
					break;
				
					// Remainder long
				case InstructionIndex.LREM:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a % b);
					}
					break;
					
					// Return long
				case InstructionIndex.LRETURN:
					this.__vmReturn(thread,
						frame.<Long>popFromStack(Long.class));
					nextpc = Integer.MIN_VALUE;
					break;
				
					// Shift left long
				case InstructionIndex.LSHL:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a << (((long)b) & 0x3F));
					}
					break;
				
					// Shift right long
				case InstructionIndex.LSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a >> (((long)b) & 0x3F));
					}
					break;
					
					// Store long to local variable
				case InstructionIndex.LSTORE:
				case InstructionIndex.WIDE_LSTORE:
					frame.storeLocal(inst.<Integer>argument(0, Integer.class),
						frame.<Long>popFromStack(Long.class));
					break;
					
					// Store long to local variable
				case InstructionIndex.LSTORE_0:
				case InstructionIndex.LSTORE_1:
				case InstructionIndex.LSTORE_2:
				case InstructionIndex.LSTORE_3:
					frame.storeLocal(opid - InstructionIndex.LSTORE_0,
						frame.<Long>popFromStack(Long.class));
					break;
				
					// Unsigned shift right long
				case InstructionIndex.LUSHR:
					{
						int b = frame.<Integer>popFromStack(Integer.class);
						long a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a >>> (((long)b) & 0x3F));
					}
					break;
					
					// XOR long
				case InstructionIndex.LXOR:
					{
						long b = frame.<Long>popFromStack(Long.class),
							a = frame.<Long>popFromStack(Long.class);
						frame.pushToStack(a ^ b);
					}
					break;
					
					// Enter monitor
				case InstructionIndex.MONITORENTER:
					frame.<SpringObject>popFromStack(SpringObject.class).
						monitor().enter(thread);
					break;
					
					// Exit monitor
				case InstructionIndex.MONITOREXIT:
					frame.<SpringObject>popFromStack(SpringObject.class).
						monitor().exit(thread, true);
					break;
					
					// Allocate multi-dimensional array
				case InstructionIndex.MULTIANEWARRAY:
					{
						// Determine component type and dimension count
						SpringClass ccl = this.resolveClass(
							inst.<ClassName>argument(0, ClassName.class));
						int n = inst.<Integer>argument(1, Integer.class);
						
						// Pop values into array
						int[] pops = new int[n];
						for (int i = n - 1; i >= 0; i--)
							pops[i] = frame.<Integer>popFromStack(
								Integer.class);
						
						// Call method within the class library since it is
						// easier, becuse this is one super complex
						// instruction
						frame.pushToStack(
							this.invokeMethod(true, new ClassName(
							"cc/squirreljme/runtime/cldc/lang/ArrayUtils"),
							new MethodNameAndType("multiANewArray",
								"(Ljava/lang/Class;I[I)Ljava/lang/Object;"),
							this.asVMObject(ccl), 0, this.asVMObject(pops)));
						
						// Exception to be handled?
						if (this.__checkException())
							return;
					}
					break;
					
					// Allocate new object
				case InstructionIndex.NEW:
					this.__vmNew(inst, frame);
					break;
				
					// Allocate new primitive array
				case InstructionIndex.NEWARRAY:
					frame.pushToStack(this.allocateArray(this.resolveClass(
						ClassName.fromPrimitiveType(
						inst.<PrimitiveType>argument(0, PrimitiveType.class))),
						frame.<Integer>popFromStack(Integer.class)));
					break;
					
					// Return from method with no return value
				case InstructionIndex.RETURN:
					thread.popFrame();
					break;
					
					// Pop category 1 value
				case InstructionIndex.POP:
					{
						// {@squirreljme.error BK2q Cannot pop category two
						// value from stack.}
						Object val = frame.popFromStack();
						if (val instanceof Long || val instanceof Double)
							throw new SpringVirtualMachineException("BK2q");
					}
					break;
					
					// Pop two cat1s or one cat2
				case InstructionIndex.POP2:
					{
						// Pop one value, if it is a long or double then only
						// pop one
						Object val = frame.popFromStack();
						if (!(val instanceof Long || val instanceof Double))
						{
							// {@squirreljme.error BK2r Cannot pop a category
							// one then category two type.}
							val = frame.popFromStack();
							if (val instanceof Long || val instanceof Double)
								throw new SpringVirtualMachineException(
									"BK2r");
						}
					}
					break;
					
					// Put to instance field
				case InstructionIndex.PUTFIELD:
					{
						// Lookup field
						SpringField ssf = this.__lookupInstanceField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Pop the value and the object to mess with
						Object value = frame.popFromStack();
						SpringObject ref = frame.<SpringObject>popFromStack(
							SpringObject.class);
						
						// {@squirreljme.error BK2s Cannot store value into
						// null reference.}
						if (ref == SpringNullObject.NULL)
							throw new SpringNullPointerException("BK2s");
						
						// {@squirreljme.error BK2t Cannot store value into
						// this instance because it not a simple object.}
						if (!(ref instanceof SpringSimpleObject))
							throw new SpringIncompatibleClassChangeException(
								"BK2t");
						SpringSimpleObject sso = (SpringSimpleObject)ref;
						
						// {@squirreljme.error BK2u Cannot store value into
						// a field which belongs to another class.}
						if (!this.loadClass(ssf.inClass()).isAssignableFrom(
							sso.type()))
							throw new SpringClassCastException("BK2u");
						
						// Set
						sso.fieldByIndex(ssf.index()).set(value,
							isinstanceinit);
					}
					break;
				
					// Put to static field
				case InstructionIndex.PUTSTATIC:
					{
						// Lookup field
						SpringFieldStorage ssf = this.__lookupStaticField(
							inst.<FieldReference>argument(0,
							FieldReference.class));
						
						// Set value, note that static initializers can set
						// static field values even if they are final
						ssf.set(frame.popFromStack(), isstaticinit);
					}
					break;
					
					// Swap top two cat1 stack entries
				case InstructionIndex.SWAP:
					{
						Object v1 = frame.popFromStack(),
							v2 = frame.popFromStack();
						
						// {@squirreljme.error BK2v Cannot swap category
						// two types.}
						if (v1 instanceof Long || v1 instanceof Double ||
							v2 instanceof Long || v2 instanceof Double)
							throw new SpringClassCastException("BK2v");
						
						frame.pushToStack(v1);
						frame.pushToStack(v2);
					}
					break;
				
					// {@squirreljme.error BK2w Reserved instruction. (The
					// instruction)}
				case InstructionIndex.BREAKPOINT:
				case InstructionIndex.IMPDEP1:
				case InstructionIndex.IMPDEP2:
					throw new SpringVirtualMachineException(String.format(
						"BK2w %s", inst));
					
					// {@squirreljme.error BK2x Unimplemented operation.
					// (The instruction)}
				default:
					throw new SpringVirtualMachineException(String.format(
						"BK2x %s", inst));
			}
		}
		
		// Arithmetic exception, a divide by zero happened somewhere
		catch (ArithmeticException e)
		{
			// PC converts?
			nextpc = this.__handleException(
				(SpringObject)this.asVMObject(new SpringArithmeticException(
				e.getMessage())));
			
			// Do not set PC address?
			if (nextpc < 0)
				return;
		}
		
		// Use the original exception, just add a suppression note on it since
		// that is the simplest action
		catch (SpringException e)
		{
			// Do not add causes or do anything if this was already thrown
			if ((e instanceof SpringFatalException) ||
				(e instanceof SpringMachineExitException))
				throw e;
			
			// Now the exception is either converted or tossed for failure
			// Is this a convertable exception on the VM?
			if (e instanceof SpringConvertableThrowable)
			{
				// PC converts?
				nextpc = this.__handleException(
					(SpringObject)this.asVMObject(e));
				
				// Do not set PC address?
				if (nextpc < 0)
					return;
			}
			
			// Not a wrapped exception, kill the VM
			else
			{
				// Kill the VM
				this.machine.exitNoException(127);
				
				// Print the stack trace
				thread.printStackTrace(System.err);
				
				// Where is this located?
				SpringMethod inmethod = frame.method();
				ClassName inclassname = inmethod.inClass();
				SpringClass inclass = machine.classLoader().loadClass(
					inclassname);
				
				// Location information if debugging is used, this makes it
				// easier to see exactly where failed code happened
				String onfile = inclass.file().sourceFile();
				int online = code.lineOfAddress(pc);
				
				// {@squirreljme.error BK2y An exception was thrown in the
				// virtual machine while executing the specified location.
				// (The class; The method; The program counter; The file in
				// source code, null means it is unknown; The line in source
				// code, negative values are unknown; The instruction)}
				e.addSuppressed(new SpringVirtualMachineException(
					String.format("BK2y %s %s %d %s %d %s", inclassname,
					inmethod.nameAndType(), pc, onfile, online, inst)));
				
				// {@squirreljme.error BK2z Fatal VM exception.}
				throw new SpringFatalException("BK2z", e);
			}
		}
		
		// Set implicit next PC address, if it has not been set or the next
		// address was actually changed
		if (nextpc != orignextpc || pc == frame.pc())
			frame.setPc(nextpc);
	}
	
	/**
	 * Invokes a method in an interface.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	private final void __vmInvokeInterface(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK30 Could not access the target
		// method for interface invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK30 %s", ref));
		
		// Load arguments, includes the instance it acts on
		int nargs = refmethod.nameAndType().type().argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
			
		// {@squirreljme.error BK31 Instance object for interface invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK31");
			
		// {@squirreljme.error BK32 Cannot invoke the method in the object
		// because it is of the wrong type. (The reference class; The class
		// of the target object; The first argument)}
		SpringClass objclass = onthis.type();
		if (objclass == null || !refclass.isAssignableFrom(objclass))
			throw new SpringClassCastException(
				String.format("BK32 %s %s %s", refclass, objclass, args[0]));
		
		// Relookup the method since we need to the right one! Then invoke it
		__t.enterFrame(objclass.lookupMethod(false, ref.memberNameAndType()),
			args);
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	public final long systemCall(short __si, int... __args)
	{
		// Make at least 8!
		if (__args == null)
			__args = new int[8];
		if (__args.length < 8)
			__args = Arrays.copyOf(__args, 8);
		
		// Error state for the last call of this type
		int[] errors = this.thread._syscallerrors;
		
		// Return value with error value, to set if any
		long rv;
		int err;
		
		// Depends on the system call type
		switch (__si)
		{
				// Check if system call is supported
			case SystemCallIndex.QUERY_INDEX:
				{
					err = 0;
					switch (__args[0])
					{
						case SystemCallIndex.API_LEVEL:
						case SystemCallIndex.CALL_STACK_HEIGHT:
						case SystemCallIndex.CALL_STACK_ITEM:
						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.EXIT:
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.GARBAGE_COLLECT:
						case SystemCallIndex.LOAD_STRING:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
							rv = 1;
							break;
						
						default:
							rv = 0;
							break;
					}
				}
				break;
				
				// Returns the height of the call stack
			case SystemCallIndex.CALL_STACK_HEIGHT:
				{
					rv = this.thread.frames().length;
					err = 0;
				}
				break;
				
				// Returns the given call stack item
			case SystemCallIndex.CALL_STACK_ITEM:
				{
					// Need to get all the stack frames first
					SpringThread.Frame[] frames = this.thread.frames();
					int numframes = frames.length;
					int curf = (numframes - __args[0]) - 1;
					
					// Out of range item
					if (curf < 0 || curf >= numframes)
					{
						rv = -1;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Depends on the item
					else
					{
						// Reset
						rv = err = 0;
						
						// Get method we are in
						SpringMethod inmethod = frames[curf].method();
						
						// Depends on the item
						switch (__args[1])
						{
								// Class name
							case CallStackItem.CLASS_NAME:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(
										inmethod.inClass().toString());
								break;

								// The method name.
							case CallStackItem.METHOD_NAME:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(inmethod.
										nameAndType().name().toString());
								break;

								// The method type.
							case CallStackItem.METHOD_TYPE:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(inmethod.
										nameAndType().type().toString());
								break;

								// The current file.
							case CallStackItem.SOURCE_FILE:
								if (inmethod == null)
									err = SystemCallError.VALUE_OUT_OF_RANGE;
								else
									rv = this.uniqueStringId(
										inmethod.inFile());
								break;

								// Source line.
							case CallStackItem.SOURCE_LINE:
								rv = frames[curf].lastExecutedPcSourceLine();
								break;

								// The PC address.
							case CallStackItem.PC_ADDRESS:
							case CallStackItem.JAVA_PC_ADDRESS:
								rv = frames[curf].lastExecutedPc();
								break;

							default:
								err = SystemCallError.VALUE_OUT_OF_RANGE;
								break;
						}
					}
				}
				break;
				
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return the stored error code
					synchronized (errors)
					{
						rv = errors[dx];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return last error code, and set new one
					synchronized (errors)
					{
						rv = errors[dx];
						errors[dx] = __args[0];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Exit the VM
			case SystemCallIndex.EXIT:
				{
					// Tell everything to cleanup and exit
					this.thread.profiler.exitAll(System.nanoTime());
					this.machine.exit((Integer)__args[0]);
					
					rv = 0;
					err = 0;
				}
				break;
				
				// Fatal ToDo
			case SystemCallIndex.FATAL_TODO:
				// {@squirreljme.error BK33 Virtual machine code executed
				// a fatal Todo. (The To Do code)}
				rv = err = 0;
				throw new SpringVirtualMachineException("BK33 " + __args[1]);
				
				// Invoke the garbage collector
			case SystemCallIndex.GARBAGE_COLLECT:
				{
					Runtime.getRuntime().gc();
					
					rv = 0;
					err = 0;
				}
				break;
				
				// Loads a string
			case SystemCallIndex.LOAD_STRING:
				{
					rv = (__args[0] == 0 ? 0 :
						this.uniqueObjectToPointer((SpringObject)
						this.asVMObject(new ConstantValueString(
						this.uniqueString(__args[0])))));
					err = 0;
				}
				break;
			
				// Current wall clock milliseconds (low).
			case SystemCallIndex.TIME_MILLI_WALL:
				{
					rv = System.currentTimeMillis();
					err = 0;
				}
				break;

				// Current monotonic clock nanoseconds (low).
			case SystemCallIndex.TIME_NANO_MONO:
				{
					rv = System.nanoTime();
					err = 0;
				}
				break;
			
				// VM information: Memory free bytes
			case SystemCallIndex.VMI_MEM_FREE:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().freeMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory used bytes
			case SystemCallIndex.VMI_MEM_USED:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().totalMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory max bytes
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
				// API level
			case SystemCallIndex.API_LEVEL:
				{
					rv = ApiLevel.LEVEL_SQUIRRELJME_0_3_0_DEV;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard input
			case SystemCallIndex.PD_OF_STDIN:
				{
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Write single byte to PD
			case SystemCallIndex.PD_WRITE_BYTE:
				{
					// Depends on the stream
					int pd = __args[0];
					OutputStream os = (pd == 1 ? System.out :
						(pd == 2 ? System.err : null));
					
					// Write
					if (os != null)
					{
						try
						{
							os.write(__args[1]);
							
							// Okay
							rv = 1;
							err = 0;
						}
						
						// Failed
						catch (IOException e)
						{
							rv = -1;
							err = SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE;
						}
					}
					
					// Failed
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
			
			default:
				// Returns no value but sets an error
				rv = -1;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used
				if (__si < 0 || __si >= SystemCallIndex.NUM_SYSCALLS)
					__si = SystemCallIndex.QUERY_INDEX;
				break;
		}
		
		// Set error state as needed
		synchronized (errors)
		{
			errors[__si] = err;
		}
		
		// Use returning value
		return rv;
	}
	
	/**
	 * Converts an object to a unique pointer.
	 *
	 * @param __p The object to convert.
	 * @return The resulting pointer.
	 * @since 2019/06/16
	 */
	public final int uniqueObjectToPointer(SpringObject __p)
	{
		// Null reference?
		if (__p == SpringNullObject.NULL)
			return 0;
		
		// Return the base of the pointer area
		return __p.pointerArea().base;
	}
	
	/**
	 * Converts an object to a unique pointer.
	 *
	 * @param __p The object to convert.
	 * @return The resulting pointer.
	 * @since 2019/06/16
	 */
	public final SpringObject uniquePointerToObject(int __p)
	{
		// Null reference?
		if (__p == 0)
			return SpringNullObject.NULL;
		
		return this.machine.pointers.findObject(__p);
	}
	
	/**
	 * Returns the string of the given ID.
	 *
	 * @param __id The ID to get.
	 * @return The resulting string.
	 * @since 2019/06/16
	 */
	public final String uniqueString(int __id)
	{
		if (__id == 0)
			return null;
		return this.machine.debugResolveString((int)__id);
	}
	
	/**
	 * Returns a unique ID for the given string.
	 *
	 * @param __s The String to get the ID od.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	public final int uniqueStringId(String __s)
		throws NullPointerException
	{
		if (__s == null)
			return 0;
		
		return (int)this.machine.debugUnresolveString(__s);
	}
	
	/**
	 * Performs a special invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmInvokeSpecial(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK34 Could not access the target
		// method for special invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK34 %s", ref));
		
		// Load arguments
		int nargs = refmethod.nameAndType().type().
			argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// Get the class of the current method being executed, lookup depends
		// on it
		SpringClass currentclass = this.loadClass(
			this.thread.currentFrame().method().inClass());
		
		// {@squirreljme.error BK35 Instance object for special invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK35");
		
		// These modify the action to be performed
		boolean insame = (currentclass == refclass),
			insuper = currentclass.isSuperClass(refclass),
			isinit = refmethod.name().isInstanceInitializer(),
			isprivate = refmethod.flags().isPrivate();
		
		// {@squirreljme.error BK36 Cannot call private method that is not
		// in the same class. (The method reference)}
		if (isprivate && !insame)
			throw new SpringIncompatibleClassChangeException(
				String.format("BK36 %s", ref));
		
		// Call superclass method instead?
		else if (!isprivate && insuper && !isinit)
			refmethod = currentclass.superClass().lookupMethod(false,
				ref.memberNameAndType());
		
		// Invoke this method
		__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Performs a static invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmInvokeStatic(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(true,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK37 Could not access the target
		// method for static invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK37 %s", ref));
		
		// Load arguments
		int nargs = refmethod.nameAndType().type().
			argumentCount();
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// Virtualized native call, depends on what it is
		if (refmethod.flags().isNative())
		{
			// Calculate result of method
			MethodDescriptor type = ref.memberType();
			Object rv = this.nativeMethod(ref.className() + "::" +
				ref.memberName() + ":" + type, args);
			
			// Push native object to the stack
			if (type.hasReturnValue())
				__f.pushToStack(this.asVMObject(rv, true));
		}
		
		// Real code that exists in class file format
		else
			__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Performs a virtual invoke.
	 *
	 * @param __i The instruction.
	 * @param __t The current thread.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	private final void __vmInvokeVirtual(Instruction __i, SpringThread __t,
		SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __t == null || __f == null)
			throw new NullPointerException("NARG");
		
		MethodReference ref = __i.<MethodReference>argument(
			0, MethodReference.class);
		
		// Resolve the method reference
		SpringClass refclass = this.loadClass(ref.className());
		SpringMethod refmethod = refclass.lookupMethod(false,
			ref.memberNameAndType());
		
		// {@squirreljme.error BK38 Could not access the target
		// method for virtual invoke. (The target method)}
		if (!this.checkAccess(refmethod))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK38 %s", ref));
		
		// Load arguments, includes the instance it acts on
		int nargs = refmethod.nameAndType().type().argumentCount() + 1;
		Object[] args = new Object[nargs];
		for (int i = nargs - 1; i >= 0; i--)
			args[i] = __f.popFromStack();
		
		// {@squirreljme.error BK39 Instance object for virtual invoke is
		// null.}
		SpringObject onthis = (SpringObject)args[0];
		if (onthis == null || onthis == SpringNullObject.NULL)
			throw new SpringNullPointerException("BK39");
		
		// Re-resolve method for this object's class
		refmethod = onthis.type().lookupMethod(false,
			ref.memberNameAndType());
		
		// Enter frame for static method
		__t.enterFrame(refmethod, args);
	}
	
	/**
	 * Allocates a new instance of the given object, it is not initialized just
	 * allocated.
	 *
	 * @param __i The instruction.
	 * @param __f The current frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	private final void __vmNew(Instruction __i, SpringThread.Frame __f)
		throws NullPointerException
	{
		if (__i == null || __f == null)
			throw new NullPointerException("NARG");
		
		// Lookup class we want to allocate
		ClassName allocname;
		SpringClass toalloc = this.loadClass((allocname =
			__i.<ClassName>argument(0, ClassName.class)));
		
		// {@squirreljme.error BK3a Cannot allocate an instance of the given
		// class because it cannot be accessed. (The class to allocate)}
		if (!this.checkAccess(toalloc))
			throw new SpringIncompatibleClassChangeException(
				String.format("BK3a %s", allocname));
		
		// Push a new allocation to the stack
		__f.pushToStack(this.allocateObject(toalloc));
	}
	
	/**
	 * Returns from the top-most frame then pushes the return value to the
	 * parent frame's stack (if any).
	 *
	 * @param __thread The thread to return in.
	 * @param __value The value to push.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	private final void __vmReturn(SpringThread __thread, Object __value)
		throws NullPointerException
	{
		if (__thread == null || __value == null)
			throw new NullPointerException("NARG");
		
		// Pop our current frame
		SpringThread.Frame old = __thread.popFrame();
		old.setPc(Integer.MIN_VALUE);
		
		// Push the value to the current frame
		SpringThread.Frame cur = __thread.currentFrame();
		if (cur != null)
			cur.pushToStack(__value);
		
		/*System.err.printf("+++RETURN: %s%n", __value);
		__thread.printStackTrace(System.err);*/
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringVMStaticMethod.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is a virtual machine representation of a static method.
 *
 * @since 2018/11/20
 */
@Deprecated
public final class SpringVMStaticMethod
	implements SpringObject
{
	/** The method to execute. */
	protected final SpringMethod method;
	
	/**
	 * Initializes the static method.
	 *
	 * @param __m The method to execute.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/20
	 */
	public SpringVMStaticMethod(SpringMethod __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		this.method = __m;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public final SpringMonitor monitor()
	{
		// {@squirreljme.error BK3b StaticMethod does not have a monitor.}
		throw new SpringFatalException("BK3b");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/21
	 */
	@Override
	public final SpringPointerArea pointerArea()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/20
	 */
	@Override
	public final SpringClass type()
	{
		// {@squirreljme.error BK3c StaticMethod does not have a type.}
		throw new SpringFatalException("BK3c");
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/SpringVirtualMachineException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

/**
 * This is thrown when the virtual machine has been detected to not be
 * operating properly, this is an error.
 *
 * @since 2018/09/01
 */
public class SpringVirtualMachineException
	extends SpringException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/09/01
	 */
	public SpringVirtualMachineException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/springcoat-vm/cc/squirreljme/vm/springcoat/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SpringCoat virtual machine which is capable of
 * running SpringCoat binaries.
 *
 * @since 2018/07/21
 */

package cc.squirreljme.vm.springcoat;

Deleted runt/libs/strings/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: abb9b55c-8519-404f-bbf8-e8d449111d13
X-SquirrelJME-Error: AM
X-SquirrelJME-Name: Basic String Utilities
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains basic string utilities 
 which are useful when parsing strings.
X-SquirrelJME-Depends: collections
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/strings/net/multiphasicapps/strings/CharSequenceUtils.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
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
191
192
































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.strings;

import java.util.Arrays;
import net.multiphasicapps.collections.IntegerList;

/**
 * This contains utilities which operate on character sequences.
 *
 * @since 2017/11/30
 */
public final class CharSequenceUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/30
	 */
	private CharSequenceUtils()
	{
	}
	
	/**
	 * Splits the specified character sequence using the given delimeter and
	 * returns all of the fields which are contained within. Extra whitespace
	 * within fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The sequence to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final CharSequence[] fieldSplit(char __delim,
		CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Get all indexes of that given character
		int[] ind = CharSequenceUtils.multipleIndexOf(__delim, __s);
		int delcount = ind.length;
		
		int n = delcount + 1;
		CharSequence[] rv = new CharSequence[n];
		for (int l = -1, r = 0, i = 0; i < n; i++, l++, r++)
			rv[i] = __s.subSequence((l >= 0 ? ind[l] + 1 : 0),
				(r < delcount ? ind[r] : __s.length()));
		
		return rv;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __s.length(); i < n; i++)
			if (__c == __s.charAt(i))
				return i;
		return -1;
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// For optimization sort the input array to find characters faster
		__c = __c.clone();
		Arrays.sort(__c);
		
		// Forward to one which assumes sorted input
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		return CharSequenceUtils.firstIndex(__c.toCharArray(), __s);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, CharSequence __s)
		throws NullPointerException
	{
		if (__c == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Go through ever character
		for (int i = 0, n = __s.length(), y = __c.length; i < n; i++)
		{
			// Use binary search because it is faster than checking each
			// and every element
			char c = __s.charAt(i);
			if (Arrays.binarySearch(__c, c) >= 0)
				return i;
		}
		
		// Not found
		return -1;
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given sequence.
	 *
	 * @parma __c The character to get the indexes for.
	 * @param __s The sequence to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, CharSequence __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		IntegerList list = new IntegerList();
		
		// Find every character index
		for (int i = 0, n = __s.length(), lastdx = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Add index to list if found
			if (c == __c)
				list.addInteger(i);
		}
		
		// Finish
		return list.toIntegerArray();
	}
}

Deleted runt/libs/strings/net/multiphasicapps/strings/StringUtils.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369

















































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.strings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * This class contains static methods which can be used for manipulating
 * strings.
 *
 * @since 2017/11/23
 */
public final class StringUtils
{
	/**
	 * Not used.
	 *
	 * @since 2017/11/23
	 */
	private StringUtils()
	{
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(char[] __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Parse string
		boolean dows = true;
		int lastdelim = -2;
		for (int i = 0, n = __s.length(), mark = 0; i <= n; i++)
		{
			// -1 is a special delimeter for the end of string because
			// otherwise if the string does not end in a delimeter it will not
			// be found
			int c = (i == n ? -1 : __s.charAt(i));
			
			// Is this a delimeter
			if (c == lastdelim || c == -1 || __indexOf(__delim, (char)c) >= 0)
			{
				// Remember last delimeter for potential speed
				lastdelim = c;
				
				// If reading delimeters, clear flag and mark
				// to remember the current index
				if (dows)
				{
					dows = false;
					mark = i;
				}
				
				// Otherwise end of sequence, generate string
				else
				{
					// Split out
					__out.add(__s.substring(mark, i));
					
					// Switch to handling delimeters
					dows = true;
				}
			}
			
			// If reading delimeters, clear flag and mark
			// to remember the current index, is not delimeters
			// here
			else if (dows)
			{
				dows = false;
				mark = i;
			}
		}
		
		// Return output always
		return __out;
	}
	
	/**
	 * Splits the given string using the specified delimeters and outputs it
	 * to the given collection.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @param __out The collection to place split strings into.
	 * @return {@code __out}
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final Collection<String> basicSplit(String __delim,
		String __s, Collection<String> __out)
		throws NullPointerException
	{
		if (__delim == null || __s == null || __out == null)
			throw new NullPointerException("NARG");
		
		return basicSplit(__delim.toCharArray(), __s, __out);
	}
	
	/**
	 * Splits the given string using the specified delimeter.
	 *
	 * @param __delim The delimeter to use.
	 * @param __s The string to split.
	 * @return The split string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/23
	 */
	public static final String[] basicSplit(char __delim, String __s)
	{
		return StringUtils.basicSplit(new char[]{__delim}, __s);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(char[] __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		Collection<String> rv = basicSplit(__delim, __s,
			new ArrayList<String>());
		return rv.<String>toArray(new String[rv.size()]);
	}
	
	/**
	 * Splits the given string using the specified delimeters.
	 *
	 * @param __delim The delimeters to use.
	 * @param __s The string to split.
	 * @return The split sequence of strings.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	public static final String[] basicSplit(String __delim, String __s)
		throws NullPointerException
	{
		if (__delim == null || __s == null)
			throw new NullPointerException("NARG");
		
		return basicSplit(__delim.toCharArray(), __s);
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within, any leading and trailing
	 * whitespace is trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplitAndTrim(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Split and trim
		String[] rv = StringUtils.fieldSplit(__delim, __s);
		for (int i = 0, n = rv.length; i < n; i++)
			rv[i] = rv[i].trim();
		return rv;
	}
	
	/**
	 * Splits the specified string using the given delimeter and returns all
	 * of the fields which are contained within. Extra whitespace within
	 * fields are not trimmed.
	 *
	 * @param __delim The delimeter to split fields by.
	 * @param __s The string to split.
	 * @return An array containing all of the fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String[] fieldSplit(char __delim, String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		CharSequence[] xrv = CharSequenceUtils.fieldSplit(__delim, __s);
		return Arrays.<String, CharSequence>copyOf(xrv, xrv.length,
			String[].class);
	}
	
	/**
	 * Searches the given sequence for the first occurrence of the specified
	 * character.
	 *
	 * @param __c The character to locate.
	 * @param __s The sequence to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters.
	 *
	 * @param __c The characters to locate.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndex(String __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndex(__c, __s);
	}
	
	/**
	 * Searches the given string for the first occurrence of the specified
	 * characters. This assumes that the character set has already been
	 * sorted.
	 *
	 * @param __c The characters to locate, this is required to be sorted.
	 * @param __s The string to look inside.
	 * @return The index of the first occurrence.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final int firstIndexSorted(char[] __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.firstIndexSorted(__c, __s);
	}
	
	/**
	 * Returns an array containing all of the indexes that the specified
	 * character appears in the given string.
	 *
	 * @parma __c The character to get the indexes for.
	 * @param __s The string to check in.
	 * @return An array containing the array indexes for the given character,
	 * if there are none then the array will be empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/26
	 */
	public static final int[] multipleIndexOf(char __c, String __s)
		throws NullPointerException
	{
		return CharSequenceUtils.multipleIndexOf(__c, __s);
	}
	
	/**
	 * Converts the specified string to lowercase ignoring locale, this uses
	 * {@link Character#toLowerCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The lowercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toLowerCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toLowerCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Converts the specified string to uppercase ignoring locale, this uses
	 * {@link Character#toUpperCase(char)}.
	 *
	 * @param __s The string to convert.
	 * @return The uppercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/30
	 */
	public static final String toUpperCaseNoLocale(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
			sb.append(Character.toUpperCase(__s.charAt(i)));
		return sb.toString();
	}
	
	/**
	 * Searches the input array to see if the given character is within the
	 * array.
	 *
	 * @param __a The array to check.
	 * @param __c The character to find in the array.
	 * @return The index of the character or {@code -1} if it was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/23
	 */
	private static final int __indexOf(char[] __a, char __c)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		for (int i = 0, n = __a.length; i < n; i++)
			if (__c == __a[i])
				return i;
		return -1;
	}
}

Deleted runt/libs/strings/net/multiphasicapps/strings/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes for manipulating strings.
 *
 * @since 2017/11/23
 */

package net.multiphasicapps.strings;

Deleted runt/libs/summercoat-vm/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 217c48ac-ed98-48ea-9f61-aceb3175baa0
X-SquirrelJME-Error: AE
X-SquirrelJME-Name: SummerCoat Virtual Machine
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: tool-classfile tool-manifest-reader meep-swm 
 tool-profiler meep-midlet common-vm tool-jarfile tool-packfile
X-SquirrelJME-Description: This is the SummerCoat VM which is a more 
 optimized register based virtual machine which should result in faster 
 code execution.
Microedition-Configuration: CLDC-1.8

Deleted runt/libs/summercoat-vm/META-INF/services/cc.squirreljme.vm.VMFactory.

1

-
cc.squirreljme.vm.summercoat.SummerCoatFactory

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/AbstractReadableMemory.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This is a class which handles reading of memory by using pure integers
 * instead of forcing all implementations to implement short and byte
 * readers.
 *
 * @since 2019/04/21
 */
public abstract class AbstractReadableMemory
	implements ReadableMemory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		for (int i = 0; i < __l; i++)
			__b[__o++] = (byte)this.memReadByte(__addr++);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		return (this.memReadByte(__addr++) << 24) |
			(this.memReadByte(__addr++) << 16) |
			(this.memReadByte(__addr++) << 8) |
			this.memReadByte(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		return (this.memReadByte(__addr++) << 8) |
			this.memReadByte(__addr);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/AbstractWritableMemory.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This class is used to provide simple writing for types other than integers
 * into memory.
 *
 * @since 2019/04/21
 */
public abstract class AbstractWritableMemory
	extends AbstractReadableMemory
	implements WritableMemory
{
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteBytes(int __a, byte[] __b, int __o, int __l)
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		for (int i = 0; i < __l; i++)
			this.memWriteByte(__a++, __b[__o++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteInt(int __addr, int __v)
	{
		this.memWriteByte(__addr++, __v >>> 24);
		this.memWriteByte(__addr++, __v >>> 16);
		this.memWriteByte(__addr++, __v >>> 8);
		this.memWriteByte(__addr++, __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteShort(int __addr, int __v)
	{
		this.memWriteByte(__addr++, __v >>> 8);
		this.memWriteByte(__addr++, __v);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ByteArrayMemory.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
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



















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This is a region of memory which uses a read-only byte array.
 *
 * @since 2019/04/21
 */
public final class ByteArrayMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** The offset to this address. */
	protected final int offset;
	
	/** The size of the byte array. */
	protected final int size;
	
	/** Offset into the byte array. */
	protected final int boff;
	
	/** The backing byte array. */
	private final byte[] _bytes;
	
	/**
	 * Initializes the byte array memory.
	 *
	 * @param __mo The memory offset.
	 * @param __b The memory bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ByteArrayMemory(int __mo, byte[] __b)
		throws NullPointerException
	{
		this(__mo, __b, 0, __b.length);
	}
	
	/**
	 * Initializes the byte array memory.
	 *
	 * @param __mo The memory offset.
	 * @param __b The memory bytes.
	 * @param __o The array offset.
	 * @param __l The number of bytes to access.
	 * @throws IndexOutOfBoundsException If the byte array offset and/or
	 * length exceeds the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ByteArrayMemory(int __mo, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		this.offset = __mo;
		this._bytes = __b;
		this.boff = __o;
		this.size = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size)
			return -1;
		
		return this._bytes[this.boff + __addr] & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Get properties
		byte[] bytes = this._bytes;
		int offset = this.offset,
			size = this.size;
		
		// The end index where we are reading
		int enddx = __addr + __l;
		
		// The limiting index, which never exceeds the size
		int limdx = (enddx > size ? size : enddx);
		
		// The real address to read from
		int ai = this.boff + __addr;
		
		// Copy all data
		while (ai < limdx)
			__b[__o++] = bytes[ai++];
		
		// If there is anything left over, pour in -1s
		while ((ai++) < enddx)
			__b[__o++] = -1;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 3)
			return -1;
		
		byte[] bytes = this._bytes;
		int rp = this.boff + __addr;
		return ((bytes[rp++] & 0xFF) << 24) |
			((bytes[rp++] & 0xFF) << 16) |
			((bytes[rp++] & 0xFF) << 8) |
			(bytes[rp++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 1)
			return -1;
		
		byte[] bytes = this._bytes;
		int rp = this.boff + __addr;
		return (short)(((bytes[rp++] & 0xFF) << 8) |
			(bytes[rp++] & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ConfigRomWriter.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
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




























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * These are utility methods to write to config space.
 *
 * @since 2019/06/14
 */
public final class ConfigRomWriter
{
	/**
	 * Not used.
	 *
	 * @since 2019/06/14
	 */
	private ConfigRomWriter()
	{
	}
	
	/**
	 * Writes raw byte data.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __b The value.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeData(DataOutputStream __dos, int __opt,
		byte[] __b)
		throws IOException, NullPointerException
	{
		if (__dos == null || __b == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AE01 Attempt to write very large configuration
		// item. (The length)}
		int len = __b.length;
		if (len >= 65536)
			throw new IOException("AE01 " + len);
		
		// Round to make data aligned
		int rlen = (len + 3) & (~3);
		
		// Key, value, and the data
		__dos.writeShort(__opt);
		__dos.writeShort(rlen);
		__dos.write(__b, 0, len);
		
		// Align?
		for (int i = len; i < rlen; i++)
			__dos.write(0);
	}
	
	/**
	 * Writes the specified integer.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeInteger(DataOutputStream __dos, int __opt,
		int __v)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeInt(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes key/value.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __k The key.
	 * @param __v The value.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeKeyValue(DataOutputStream __dos, int __opt,
		String __k, String __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeUTF(__k);
			xdos.writeUTF(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes the specified string.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The string to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeString(DataOutputStream __dos, int __opt,
		String __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			xdos.writeUTF(__v);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
	
	/**
	 * Writes the specified strings.
	 *
	 * @param __dos The output stream.
	 * @param __opt The option to write.
	 * @param __v The strings to write.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public static final void writeStrings(DataOutputStream __dos, int __opt,
		String... __v)
		throws IOException, NullPointerException
	{
		if (__dos == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write data area
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream xdos = new DataOutputStream(baos))
		{
			// Write string length
			int n = __v.length;
			xdos.writeShort(n);
			
			// Write actual strings
			for (int i = 0; i < n; i++)
				xdos.writeUTF(__v[i]);
			
			// Write in
			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
		}
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ExecutionSlice.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389





































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import java.io.PrintStream;
import net.multiphasicapps.classfile.InstructionMnemonics;

/**
 * This represents a single slice of execution.
 *
 * @since 2019/10/27
 */
public final class ExecutionSlice
{
	/** The tracing information. */
	protected final CallTraceElement trace;
	
	/** The operand executed. */
	protected final int op;
	
	/** Operand arguments. */
	private final int[] _opargs;
	
	/** CPU registers. */
	private final int[] _cpuregs;
	
	/** Method call arguments (optional). */
	private final int[] _callargs;
	
	/**
	 * Creates an execution slice of the given frame information.
	 *
	 * @param __cte Call trace information.
	 * @param __rreg CPU registers stored here.
	 * @param __op The operand.
	 * @param __args The arguments.
	 * @param __argslen Number of arguments available.
	 * @param __reglist The register list for method calls.
	 * @return The execution slice.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/03
	 */
	public ExecutionSlice(CallTraceElement __cte, int[] __rreg,
		int __op, int[] __args, int __argslen, int[] __reglist)
		throws NullPointerException
	{
		if (__cte == null || __rreg == null || __args == null)
			throw new NullPointerException("NARG");
		
		this.trace = __cte;
		this._cpuregs = __rreg.clone();
		this.op = __op;
		this._callargs = (__reglist != null ? __reglist.clone() : null);
		
		int[] args = new int[__argslen];
		for (int i = 0; i < __argslen; i++)
			args[i] = __args[i];
		this._opargs = args;
	}
	
	/**
	 * Prints the information about this slice.
	 *
	 * @since 2019/10/27
	 */
	public final void print()
	{
		this.print(System.err);
	}
	
	/**
	 * Prints the information about this slice.
	 *
	 * @param __ps The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public final void print(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		// We need all of these!
		CallTraceElement trace = this.trace;
		int op = this.op;
		int[] opargs = this._opargs,
			cpuregs = this._cpuregs,
			callargs = this._callargs;
		
		// Print CPU operation state
		__ps.printf("$$$$$$$$ @%08x (%s/%s)%n", trace.address(),
			NativeInstruction.mnemonic(op),
			InstructionMnemonics.toString(trace.byteCodeInstruction()));
		
		// Print normal trace info
		__ps.printf("  - InFrm: %s%n", trace.toString());
		
		// Print instruction arguments
		__ps.print("  - OpArg: (");
		for (int i = 0, n = opargs.length; i < n; i++)
		{
			if (i > 0)
				__ps.print(", ");
			
			__ps.printf("%d [%xh]", opargs[i], opargs[i]);
		}
		__ps.println(")");
		
		// Do not print the large number of final registers that are zero
		int maxregister = cpuregs.length - 1;
		while (maxregister > 0 && cpuregs[maxregister] == 0)
			maxregister--;
		
		// Print CPU registers
		__ps.print("  - CPU+g:[");
		int didonline = 0;
		for (int i = 0; i <= maxregister; i++)
		{
			// Put local registers on a new line
			if (i == NativeCode.LOCAL_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+l:[");
				didonline = 0;
			}
			
			// Start the arguments as well
			else if (i == NativeCode.ARGUMENT_REGISTER_BASE)
			{
				__ps.printf("]%n  - CPU+a:[");
				didonline = 0;
			}
			
			// Other formatting
			else if (i > 0)
			{
				// Comma these
				if (didonline < 6)
					__ps.print(", ");
					
				// Reset count
				else
				{
					__ps.printf("%n  -   ...:.");
					didonline = 0;
				}
			}
			
			// Known register name?
			String knownreg = null;
			switch (i)
			{
				case NativeCode.ZERO_REGISTER:
					knownreg = "zer";
					break;
				
				case NativeCode.RETURN_REGISTER:
					knownreg = "rv1";
					break;
				
				case NativeCode.RETURN_REGISTER + 1:
					knownreg = "rv2";
					break;
				
				case NativeCode.EXCEPTION_REGISTER:
					knownreg = "exc";
					break;
				
				case NativeCode.STATIC_FIELD_REGISTER:
					knownreg = "sfp";
					break;
				
				case NativeCode.THREAD_REGISTER:
					knownreg = "thr";
					break;
				
				case NativeCode.POOL_REGISTER:
					knownreg = "cpl";
					break;
				
				case NativeCode.NEXT_POOL_REGISTER:
					knownreg = "npl";
					break;
				
				case NativeCode.ARGUMENT_REGISTER_BASE:
					knownreg = "a0t";
					break;
			}
			
			// Show a value
			int val = cpuregs[i];
			
			// Print out
			__ps.printf("%3s=%8xh", (knownreg != null ? knownreg :
			String.format("r%02d", i)), cpuregs[i]);
			
			// Count line up
			didonline++;
		}
		__ps.println("]");
		
		// Print call arguments, if any
		if (callargs != null)
		{
			__ps.print("  - CallA: (");
			for (int i = 0, n = callargs.length; i < n; i++)
			{
				if (i > 0)
					__ps.print(", ");
				
				__ps.printf("%xh", callargs[i]);
			}
			__ps.println(")");
		}
		
		/*
		PrintStream out = System.err;
		
		// Limit class name
		CallTraceElement trace = this.trace(__nf);
		String cname = "" + trace.className();
		int nl;
		if ((nl = cname.length()) > 20)
			cname = cname.substring(nl - 20, nl);
		
		// Print Header (with location info)
		out.printf("***** @%08x %-19.19s/%10.10s | L%-4d/J%-3d %20.20s::%s %n",
			__nf._pc,
			NativeInstruction.mnemonic(__op),
			InstructionMnemonics.toString(trace.byteCodeInstruction()),
			trace.line(),
			trace.byteCodeAddress(),
			cname,
			trace.methodName() + ":" + trace.methodDescriptor());
		
		// Is this an invoke?
		boolean isinvoke = (__op == NativeInstructionType.INVOKE ||
			__op == NativeInstructionType.SYSTEM_CALL);
		
		// Arguments to print, invocations get 1 (pc) + register list
		int naf = (isinvoke ? 1 + __reglist.length:
			__af.length);
		
		// Used to modify some calls
		int encoding = NativeInstruction.encoding(__op);
		
		// Print out arguments to the call
		out.printf("  A:[");
		for (int i = 0, n = naf; i < n; i++)
		{
			int iv = (isinvoke ? (i == 0 ? __args[i] : __reglist[i - 1]) :
				__args[i]);
			
			// Comma
			if (i > 0)
				out.print(", ");
			
			// Can be special?
			boolean canspec = true;
			if (encoding == NativeInstructionType.DEBUG_ENTRY ||
				encoding == NativeInstructionType.DEBUG_POINT ||
				(encoding == NativeInstructionType.IF_ICMP &&
					i == 2) ||
				(encoding == NativeInstructionType.MATH_CONST_INT &&
					i == 1) ||
				(encoding == NativeInstructionType.IFEQ_CONST &&
					i == 1) ||
				(encoding == NativeInstructionType.ATOMIC_INT_INCREMENT &&
					i == 1) ||
				(encoding == NativeInstructionType.
					ATOMIC_INT_DECREMENT_AND_GET && i == 2) ||
				(encoding == NativeInstructionType.MEMORY_OFF_ICONST &&
					i == 2) ||
				(encoding == NativeInstructionType.LOAD_POOL && i == 0))
				canspec = false;
			
			// Is this a special register?
			String spec = null;
			if (canspec)
				switch (iv)
				{
					case NativeCode.ZERO_REGISTER:
						spec = "zero";
						break;
					
					case NativeCode.RETURN_REGISTER:
						spec = "return1";
						break;
					
					case NativeCode.RETURN_REGISTER + 1:
						spec = "return2";
						break;
					
					case NativeCode.EXCEPTION_REGISTER:
						spec = "exception";
						break;
					
					case NativeCode.STATIC_FIELD_REGISTER:
						spec = "sfieldptr";
						break;
					
					case NativeCode.THREAD_REGISTER:
						spec = "thread";
						break;
					
					case NativeCode.POOL_REGISTER:
						spec = "pool";
						break;
					
					case NativeCode.NEXT_POOL_REGISTER:
						spec = "nextpool";
						break;
					
					case NativeCode.ARGUMENT_REGISTER_BASE:
						spec = "a0/this";
						break;
				}
			
			// Print special register
			if (spec != null)
				out.printf("%10.10s", spec);
			else
				out.printf("%10d", iv);
		}
		out.print("] | ");
		
		// And register value
		out.printf("V:[");
		int[] registers = __nf._registers;
		for (int i = 0, n = naf; i < n; i++)
		{
			int iv = (isinvoke ? (i == 0 ? __args[i] : __reglist[i - 1]) :
				__args[i]);
				
			if (i > 0)
				out.print(", ");
			
			// Load register value
			if (iv < 0 || iv >= registers.length)
				out.print("----------");
			else
				out.printf("%+10d", registers[iv]);
		}
		out.println("]");
		*/
	}
	
	/**
	 * Creates an execution slice of the given frame information.
	 *
	 * @param __cte The call trace information.
	 * @param __nf The native frame.
	 * @param __op The operand.
	 * @param __args The arguments.
	 * @param __argslen Arguments available.
	 * @param __reglist The register list for method calls.
	 * @return The execution slice.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/10/27
	 */
	public static final ExecutionSlice of(CallTraceElement __cte,
		NativeCPU.Frame __nf, int __op, int[] __args, int __argslen,
		int[] __reglist)
		throws NullPointerException
	{
		if (__nf == null || __args == null)
			throw new NullPointerException("NARG");
		
		return new ExecutionSlice(__cte,
			__nf._registers,
			__op,
			__args,
			__argslen,
			__reglist);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/MachineState.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import net.multiphasicapps.profiler.ProfilerSnapshot;

/**
 * This contains the machine state.
 *
 * @since 2019/06/19
 */
public final class MachineState
{
	/** The virtual machine memory. */
	protected final WritableMemory memory;
	
	/** The profiler snapshot to write to. */
	protected final ProfilerSnapshot profiler;
	
	/** Was the supervisor okay? */
	private volatile boolean _supervisorokay;
	
	/**
	 * Initializes the machine state.
	 *
	 * @param __mem The memory state.
	 * @param __pf The profiler, this is optional.
	 * @throws NullPointerException If no memory was specified.
	 * @since 2019/12/28
	 */
	public MachineState(WritableMemory __mem, ProfilerSnapshot __pf)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.profiler = __pf;
	}
	
	/**
	 * Flags that the supervisor booted okay.
	 *
	 * @since 2019/06/19
	 */
	public final void flagSupervisorOkay()
	{
		synchronized (this)
		{
			this._supervisorokay = true;
		}
	}
	
	/**
	 * Has the supervisor initialized correctly?
	 *
	 * @return If the supervisor initialized it was okay.
	 * @since 2019/06/19
	 */
	public final boolean isSupervisorOkay()
	{
		synchronized (this)
		{
			return this._supervisorokay;
		}
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/Memory.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This represents the starting region of memory.
 *
 * @since 2019/04/21
 */
public interface Memory
{
	/**
	 * The starting region of this memory.
	 *
	 * @return The starting region of this memory.
	 * @since 2019/04/21
	 */
	public abstract int memRegionOffset();
	
	/**
	 * The length of this memory region.
	 *
	 * @return The memory region length.
	 * @since 2019/04/21
	 */
	public abstract int memRegionSize();
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/NativeCPU.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import cc.squirreljme.jvm.CallStackItem;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SupervisorPropertyIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import cc.squirreljme.vm.VMException;
import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.InvalidInstructionException;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.collections.IntegerList;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.profiler.ProfilerSnapshot;
import net.multiphasicapps.profiler.ProfiledThread;

/**
 * This represents a native CPU which may run within its own thread to
 * execute code that is running from within the virtual machine.
 *
 * @since 2019/04/21
 */
public final class NativeCPU
	implements Runnable
{
	/**
	 * {@squirreljme.properly cc.squirreljme.summercoat.debug=boolean
	 * Should SummerCoat print lots of debugging information?}
	 */
	public static final boolean ENABLE_DEBUG =
		Boolean.getBoolean("cc.squirreljme.summercoat.debug");
	
	/** Maximum amount of CPU registers. */
	public static final int MAX_REGISTERS =
		64;
	
	/** The size of the method cache. */
	public static final int METHOD_CACHE =
		2048;
	
	/** Spill over protection for the cache. */
	public static final int METHOD_CACHE_SPILL =
		1024;
	
	/** The number of execution slices to store. */
	public static final int MAX_EXECUTION_SLICES =
		32;
	
	/** The maximum number of popped slices to store. */
	public static final int MAX_POPPED_SLICE_STORE =
		8;
	
	/** Threshhold for too many debug points */
	private static final int _POINT_THRESHOLD =
		65536;
	
	/** The machine state. */
	protected final MachineState state;
	
	/** The memory to read/write from. */
	protected final WritableMemory memory;
	
	/** The profiler to use. */
	protected final ProfiledThread profiler;
	
	/** Virtual CPU id. */
	protected final int vcpuid;
	
	/** Stack frames. */
	private final LinkedList<Frame> _frames =
		new LinkedList<>();
	
	/** System call error states for this CPU. */
	private final int[] _syscallerrors =
		new int[SystemCallIndex.NUM_SYSCALLS];
	
	/** Super visor properties. */
	private final int[] _supervisorproperties =
		new int[SupervisorPropertyIndex.NUM_PROPERTIES];
	
	/** Execution slices which came from the popped frame. */
	private final Deque<Deque<ExecutionSlice>> _sopf =
		(ENABLE_DEBUG ? new LinkedList<Deque<ExecutionSlice>>() : null);
	
	/** IPC Exception register. */
	private int _ipcexception;
	
	/**
	 * Initializes the native CPU.
	 *
	 * @param __ms The machine state.
	 * @param __mem The memory space.
	 * @param __ps The profiler to use.
	 * @param __vcid Virtual CPU id.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public NativeCPU(MachineState __ms, WritableMemory __mem, int __vcid,
		ProfilerSnapshot __ps)
		throws NullPointerException
	{
		if (__ms == null || __mem == null)
			throw new NullPointerException("NARG");
		
		this.state = __ms;
		this.memory = __mem;
		this.vcpuid = __vcid;
		this.profiler = (__ps == null ? null :
			__ps.measureThread("cpu-" + __vcid));
	}
	
	/**
	 * Enters the given frame for the given address.
	 *
	 * @param __pc The address of the frame.
	 * @param __args Arguments to the frame
	 * @return The newly created frame.
	 * @since 2019/04/21
	 */
	public final Frame enterFrame(int __pc, int... __args)
	{
		// Old frame, to source globals from
		LinkedList<Frame> frames = this._frames;
		Frame lastframe = frames.peekLast();
		
		// Setup new frame
		Frame rv = new Frame();
		rv._pc = __pc;
		rv._entrypc = __pc;
		rv._lastpc = __pc;
		
		// Add to frame list
		frames.addLast(rv);
		
		// Seed initial registers, if valid
		int[] dest = rv._registers;
		if (lastframe != null)
		{
			// Copy globals
			int[] src = lastframe._registers;
			for (int i = 0; i < NativeCode.LOCAL_REGISTER_BASE; i++)
				dest[i] = src[i];
			
			// Set the pool register to the next pool register value
			dest[NativeCode.POOL_REGISTER] =
				src[NativeCode.NEXT_POOL_REGISTER];
			
			// Copy task register.
			rv._taskid = lastframe._taskid;
		}
		
		// Copy the arguments to the argument slots
		for (int i = 0, o = NativeCode.ARGUMENT_REGISTER_BASE,
			n = __args.length; i < n; i++, o++)
			dest[o] = __args[i];
		
		// Clear zero
		dest[0] = 0;
		
		// Use this frame
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void run()
	{
		this.run(0);
	}
	
	/**
	 * Runs anything after this frame.
	 *
	 * @param __fl The frame limit.
	 * @since 2019/06/13
	 */
	public final void run(int __fl)
	{
		try
		{
			this.runWithoutCatch(0);
		}
		
		// Failed
		catch (VMException|InvalidInstructionException e)
		{
			// Spacer
			System.err.println("********************************************");
			
			// Only print execution slices if debugging is enabled
			if (ENABLE_DEBUG)
			{
				// Each frame has its own slices
				for (Frame l : this._frames)
				{
					// Traces for this frame
					System.err.print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
					System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
					System.err.printf(">>>>>>>>>>>> %s%n", this.trace(l));
					
					// Print all the various execution slices
					Deque<ExecutionSlice> execslices = l._execslices;
					System.err.printf("Printing the last %d instructions:%n",
						execslices.size());
					while (!execslices.isEmpty())
						execslices.removeFirst().print(System.err);
					
					// Spacer
					System.err.println();
				}
				
				// Spacer
				System.err.println();
				
				// If there were any execution slices that came from the
				// method we called, print them out.
				Deque<Deque<ExecutionSlice>> sopf = this._sopf;
				if (sopf != null)
				{
					// Traces for this frame
					System.err.print("++++++++++++++++++++++++++++++++++++");
					System.err.println("++++++++++++++++++++++++++++++++++++");
					
					// Print all of them
					while (!sopf.isEmpty())
					{
						// Spacer
						System.err.println(
							"++++++++++++++++++++++++++++++++++++++++++++");
						System.err.println("Slices of a popped frame:");
						
						// Print out
						Deque<ExecutionSlice> qq = sopf.removeFirst();
						while (!qq.isEmpty())
							qq.removeFirst().print(System.err);
						
						// Spacer
						System.err.println();
					}
				}
					
				// Spacer
				System.err.println(
					"--------------------------------------------");
			}
			
			// Print the call trace
			CallTraceElement[] calltrace = this.trace();
			System.err.println("Call trace:");
			for (CallTraceElement l : calltrace)
				System.err.printf("    %s%n", l);
			System.err.println();
			
			// Spacer
			System.err.println("********************************************");
			
			// {@squirreljme.error AE02 Virtual machine exception. (The failing
			// instruction)}
			throw new VMException(
				String.format("AE02 %s", this.traceTop()), e);
		}
	}
	
	/**
	 * Runs anything after this frame, no catching is performed.
	 *
	 * @param __fl The frame limit.
	 * @since 2019/04/21
	 */
	public final void runWithoutCatch(int __fl)
	{
		// Read the CPU stuff
		final WritableMemory memory = this.memory;
		boolean reload = true;
		ProfiledThread profiler = this.profiler;
		
		// Frame specific info
		Frame nowframe = null;
		int[] lr = null;
		int pc = -1;
		
		// Per operation handling
		final int[] args = new int[6];
		
		// Method cache to reduce tons of method reads
		final byte[] icache = new byte[METHOD_CACHE];
		int lasticache = -(METHOD_CACHE_SPILL + 1);
		
		// Debug point counter
		int pointcounter = 0;
		
		// Execution is effectively an infinite loop
		LinkedList<Frame> frames = this._frames;
		for (int frameat = frames.size(), lastframe = -1; frameat >= __fl;
			frameat = frames.size())
		{
			// Reload parameters?
			if ((reload |= (lastframe != frameat)))
			{
				// Before dumping this frame, store old info
				if (nowframe != null)
					nowframe._pc = pc;
				
				// Get current frame, stop execution if there is nothing
				// left to execute
				nowframe = frames.peekLast();
				if (nowframe == null)
					return;
				
				// Load stuff needed for execution
				lr = nowframe._registers;
				pc = nowframe._pc;
				
				// Used to auto-detect frame change
				lastframe = frameat;
				
				// No longer reload information
				reload = false;
			}
			
			// For a bit faster execution of the method, cache a bunch of
			// the code that is being executed in memory. Constantly performing
			// the method calls to read single bytes of memory is a bit so, so
			// this should hopefully improve performance slightly.
			int pcdiff = pc - lasticache;
			if (pcdiff < 0 || pcdiff >= METHOD_CACHE_SPILL)
			{
				memory.memReadBytes(pc, icache, 0, METHOD_CACHE);
				lasticache = pc;
			}
			
			// Calculate last PC base address
			int bpc = pc - lasticache;
			
			// Always set PC address for debugging frames
			nowframe._pc = pc;
			
			// Read operation
			nowframe._lastpc = pc;
			int op = icache[bpc] & 0xFF;
			
			// Reset all input arguments
			for (int i = 0, n = args.length; i < n; i++)
				args[i] = 0;
			
			// Register list, just one is used everywhere
			int[] reglist = null;
			
			// Load arguments for this instruction
			ArgumentFormat[] af = NativeInstruction.argumentFormat(op);
			int rargp = bpc + 1;
			for (int i = 0, n = af.length; i < n; i++)
				switch (af[i])
				{
					// Variable sized entries, may be pool values
					case VUINT:
					case VUREG:
					case VPOOL:
					case VJUMP:
						{
							// Long value?
							int base = (icache[rargp++] & 0xFF);
							if ((base & 0x80) != 0)
							{
								base = ((base & 0x7F) << 8);
								base |= (icache[rargp++] & 0xFF);
							}
							
							// Set
							if (af[i] == ArgumentFormat.VJUMP)
								args[i] = (short)(base |
									((base & 0x4000) << 1));
							else
								args[i] = base;
							
							// {@squirreljme.error AE03 Reference to register
							// which is out of range of maximum number of
							// registers. (The register index)}
							if (af[i] == ArgumentFormat.VUREG &&
								(base < 0 || base >= NativeCode.MAX_REGISTERS))
								throw new VMException("AE03 " + base);
						}
						break;
					
					// Register list.
					case REGLIST:
						{
							// Wide
							int count = (icache[rargp++] & 0xFF);
							if ((count & 0x80) != 0)
							{
								count = ((count & 0x7F) << 8) |
									(icache[rargp++] & 0xFF);
								
								// Read values
								reglist = new int[count];
								for (int r = 0; r < count; r++)
									reglist[r] =
										((icache[rargp++] & 0xFF) << 8) |
										(icache[rargp++] & 0xFF);
							}
							// Narrow
							else
							{
								reglist = new int[count];
								
								// Read values
								for (int r = 0; r < count; r++)
									reglist[r] = (icache[rargp++] & 0xFF);
							}
						}
						break;
					
					// 32-bit integer/float
					case INT32:
					case FLOAT32:
						args[i] = ((icache[rargp++] & 0xFF) << 24) |
							((icache[rargp++] & 0xFF) << 16) |
							((icache[rargp++] & 0xFF) << 8) |
							((icache[rargp++] & 0xFF));
						break;
					
					default:
						throw new todo.OOPS(af[i].name());
				}
			
			// Determine the encoding
			int encoding = NativeInstruction.encoding(op);
			
			// Set first point flag
			if (encoding == NativeInstructionType.DEBUG_ENTRY)
				pointcounter = 0;
			
			// Only track slices if we are debugging
			if (ENABLE_DEBUG)
			{
				// Get slice for this instruction
				ExecutionSlice el = ExecutionSlice.of(this.trace(nowframe),
					nowframe, op, args, af.length, reglist);
				
				// Add to previous instructions, do not exceed slice limits
				Deque<ExecutionSlice> execslices = nowframe._execslices;
				if (execslices.size() >= MAX_EXECUTION_SLICES)
					execslices.removeFirst();
				execslices.addLast(el);
			
				// In debug points check to see if the execution seems to
				// be stuck in here (really long methods)
				if (encoding == NativeInstructionType.DEBUG_POINT)
				{
					// Seems to be stuck?
					boolean doprint = false;
					if (pointcounter++ >= _POINT_THRESHOLD)
					{
						doprint = true;
						pointcounter = 0;
					}
					
					// Print the point?
					if (doprint)
						el.print();
				}
			}
			
			// By default the next instruction is the address after all
			// arguments have been read
			int nextpc = lasticache + rargp;
			
			// Handle the operation
			switch (encoding)
			{
					// CPU Breakpoint
				case NativeInstructionType.BREAKPOINT:
					// Breakpoints only function when debugging is enabled
					if (ENABLE_DEBUG)
					{
						// If profiling, immediately enter the frame to signal
						// a break point then exit it
						if (profiler != null)
						{
							profiler.enterFrame("<breakpoint>", "<breakpoint>",
								"<breakpoint>");
							profiler.exitFrame();
						}
						
						// {@squirreljme.error AE04 CPU breakpoint hit.}
						throw new VMException("AE04");
					}
					break;
				
					// Debug entry point of method
				case NativeInstructionType.DEBUG_ENTRY:
					this.__debugEntry(nowframe, args[0], args[1], args[2],
						args[3]);
					break;
					
					// Debug exit of method
				case NativeInstructionType.DEBUG_EXIT:
					this.__debugExit(nowframe);
					break;
					
					// Debug point in method.
				case NativeInstructionType.DEBUG_POINT:
					this.__debugPoint(nowframe, args[0], args[1], args[2]);
					break;
					
					// Atomic compare, get, and set
				case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
					synchronized (memory)
					{
						// Read parameters
						int check = lr[args[0]],
							set = lr[args[2]],
							addr = lr[args[3]],
							off = args[4];
						
						// Read value here
						int read = memory.memReadInt(addr + off);
						
						// Is the value the same?
						if (read == check)
							memory.memWriteInt(addr + off, set);
						
						// Set the read value before check
						lr[args[1]] = read;
						
						// Debug
						/*if (ENABLE_DEBUG)
							todo.DEBUG.note("%08x(%d) = %d ? %d = %d",
								addr, off, read, check, set);*/
					}
					break;
				
					// Atomic decrement and get
				case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
					synchronized (memory)
					{
						// The address to load from/store to
						int addr = lr[args[1]],
							off = args[2];
						
						// Read, increment, and store
						int newval;
						memory.memWriteInt(addr + off,
							(newval = memory.memReadInt(addr + off) - 1));
						
						// Store the value after the decrement
						lr[args[0]] = newval;
					}
					break;
					
					// Atomic increment
				case NativeInstructionType.ATOMIC_INT_INCREMENT:
					synchronized (memory)
					{
						// The address to load from/store to
						int addr = lr[args[0]],
							off = args[1];
						
						// Read, increment, and store
						int oldv;
						memory.memWriteInt(addr + off,
							(oldv = memory.memReadInt(addr + off)) + 1);
						
						// Debug
						/*if (ENABLE_DEBUG)
							todo.DEBUG.note("%08x(%d) += %d + 1 = %d",
								addr, off, oldv, oldv + 1);*/
					}
					break;
				
					// Copy
				case NativeInstructionType.COPY:
					lr[args[1]] = lr[args[0]];
					break;
					
					// Compare integers and possibly jump
				case NativeInstructionType.IF_ICMP:
					{
						// Parts
						int a = lr[args[0]],
							b = lr[args[1]];
						
						// Compare
						boolean branch;
						CompareType ct;
						switch ((ct = CompareType.of(op & 0b111)))
						{
							case EQUALS:
								branch = (a == b); break;
							case NOT_EQUALS:
								branch = (a != b); break;
							case LESS_THAN:
								branch = (a < b); break;
							case LESS_THAN_OR_EQUALS:
								branch = (a <= b); break;
							case GREATER_THAN:
								branch = (a > b); break;
							case GREATER_THAN_OR_EQUALS:
								branch = (a >= b); break;
							case TRUE:
								branch = true; break;
							case FALSE:
								branch = false; break;
							
							default:
								throw new todo.OOPS();
						}
						
						// Branching?
						if (branch)
							nextpc = pc + args[2];
					}
					break;
					
					// If value equal to constant
				case NativeInstructionType.IFEQ_CONST:
					{
						// Branching? Remember that jumps are relative
						if (lr[args[0]] == args[1])
							nextpc = pc + args[2];
					}
					break;
					
					// Invoke a pointer
				case NativeInstructionType.INVOKE:
					{
						// Load values into the register list
						for (int i = 0, n = reglist.length; i < n; i++)
							reglist[i] = lr[reglist[i]];
						
						// Enter the frame
						this.enterFrame(lr[args[0]], reglist);
						
						// Entering some other frame
						reload = true;
						
						// Clear point counter
						pointcounter = 0;
					}
					break;
					
					// Load value from int array
				case NativeInstructionType.LOAD_FROM_INTARRAY:
					{
						// Get arguments
						int addr = lr[args[1]],
							indx = lr[args[2]],
							rout = args[0];
						
						// Calculate array index offset
						int ioff = Constants.ARRAY_BASE_SIZE + (indx * 4);
						
						// Read value
						lr[rout] = memory.memReadInt(addr + ioff);
					}
					break;
					
					// Load from constant pool
				case NativeInstructionType.LOAD_POOL:
					lr[args[1]] = memory.memReadInt(
						lr[NativeCode.POOL_REGISTER] + (args[0] * 4));
					break;
					
					// Integer math
				case NativeInstructionType.MATH_CONST_INT:
				case NativeInstructionType.MATH_REG_INT:
					{
						// Parts
						int a = lr[args[0]],
							b = (((op & 0x80) != 0) ? args[1] : lr[args[1]]),
							c;
						
						// Operation to execute
						MathType mt;
						switch ((mt = MathType.of(op & 0xF)))
						{
							case ADD:		c = a + b; break;
							case SUB:		c = a - b; break;
							case MUL:		c = a * b; break;
							case DIV:		c = a / b; break;
							case REM:		c = a % b; break;
							case NEG:		c = -a; break;
							case SHL:		c = a << b; break;
							case SHR:		c = a >> b; break;
							case USHR:		c = a >>> b; break;
							case AND:		c = a & b; break;
							case OR:		c = a | b; break;
							case XOR:		c = a ^ b; break;
							case SIGNX8:	c = (byte)a; break;
							case SIGNX16:	c = (short)a; break;
							
							case CMPL:
							case CMPG:
								c = (a < b ? -1 : (a == b ? 0 : 1));
								break;
							
							default:
								throw new todo.OOPS();
						}
						
						// Set result
						lr[args[2]] = c;
					}
					break;
				
					// Read off memory
				case NativeInstructionType.MEMORY_OFF_REG:
				case NativeInstructionType.MEMORY_OFF_REG_JAVA:
				case NativeInstructionType.MEMORY_OFF_ICONST:
				case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
					{
						// Is this Java?
						boolean isjava = (encoding == NativeInstructionType.
							MEMORY_OFF_REG_JAVA || encoding ==
							NativeInstructionType.MEMORY_OFF_ICONST_JAVA);
						
						// Is this a load operation?
						boolean load = ((op & 0b1000) != 0);
						
						// The address to load from/store to
						int base = lr[args[1]],
							offs = (((op & 0x80) != 0) ? args[2] :
								lr[args[2]]),
							addr = base + offs;
						
						// Loads
						DataType dt = DataType.of(op & 0b0111);
						if (load)
						{
							// Load value
							int v;
							switch (dt)
							{
								case BYTE:
									v = (byte)memory.memReadByte(addr);
									break;
									
								case SHORT:
									v = (short)memory.memReadShort(addr);
									break;
									
								case CHARACTER:
									v = memory.memReadShort(addr) & 0xFFFF;
									break;
									
								case OBJECT:
								case INTEGER:
								case FLOAT:
									v = memory.memReadInt(addr);
									break;
									
									// Unknown
								default:
									throw new todo.OOPS(dt.name());
							}
							
							// Set value
							lr[args[0]] = v;
							
							// Debug
							/*if (ENABLE_DEBUG)
								todo.DEBUG.note(
									"%c %08x+%d (%08x) -> %d (%08x)",
									(isjava ? 'J' : 'N'),
									base, offs, addr, v, v);*/
						}
						
						// Stores
						else
						{
							// Value to store
							int v = lr[args[0]];
							
							// Store
							switch (dt)
							{
								case BYTE:
									memory.memWriteByte(addr, v);
									break;
									
								case SHORT:
									memory.memWriteShort(addr, v);
									break;
									
								case CHARACTER:
									memory.memWriteShort(addr, v);
									break;
								
								case OBJECT:
								case INTEGER:
								case FLOAT:
									memory.memWriteInt(addr, v);
									break;
									
									// Unknown
								default:
									throw new todo.OOPS(dt.name());
							}
							
							// Debug
							/*if (ENABLE_DEBUG)
								todo.DEBUG.note(
									"%c %08x+%d (%08x) <- %d (%08x)",
									(isjava ? 'J' : 'N'),
									base, offs, addr, v, v);*/
						}
					}
					break;
					
					// Return from method call
				case NativeInstructionType.RETURN:
					{
						// Go up frame
						Frame was = frames.removeLast(),
							now = frames.peekLast();
						
						// {@squirreljme.error AE0m Return from the main frame
						// without using a system call to exit.
						// (The return value pair; The exception register)}
						if (now == null)
							throw new VMException(String.format(
								"AE0m [%d, %d] @%08x",
								was._registers[NativeCode.RETURN_REGISTER],
								was._registers[NativeCode.RETURN_REGISTER + 1],
								was._registers[
									NativeCode.EXCEPTION_REGISTER]));
						
						// Capture the execution slices of this popped frame
						Deque<Deque<ExecutionSlice>> sopf = this._sopf;
						if (sopf != null)
						{
							// Add these slices
							sopf.addLast(was._execslices);
							
							// If there are too many, remove them
							if (sopf.size() > MAX_POPPED_SLICE_STORE)
								sopf.removeFirst();
						}
						
						// We are going back onto a frame so copy all
						// the globals which were set since they are meant to
						// be global!
						int[] wr = was._registers,
							nr = now._registers;
						
						// Copy globals
						for (int i = 0; i < NativeCode.LOCAL_REGISTER_BASE;
							i++)
						{
							// Ignore the pool register because if it is
							// replaced then it will just explode and
							// cause issues for the parent method
							if (i == NativeCode.POOL_REGISTER)
								continue;
							
							// Reset the next pool register
							else if (i == NativeCode.NEXT_POOL_REGISTER)
							{
								nr[i] = 0;
								break;
							}
							
							// Copy otherwise
							else
								nr[i] = wr[i];
						}
						
						// A reload is done as the frame has changed
						reload = true;
						
						// Clear point counter
						pointcounter = 0;
						
						// Debug
						/*if (ENABLE_DEBUG)
							System.err.printf(
								"<<<< %08x <<<<<<<<<<<<<<<<<<<<<<%n",
								(now != null ? now._pc : 0));*/
					}
					break;
					
					// Store to constant pool
				case NativeInstructionType.STORE_POOL:
					memory.memWriteInt(lr[NativeCode.POOL_REGISTER] +
						(args[0] * 4), lr[args[1]]);
					break;
					
					// Store value into integer array
				case NativeInstructionType.STORE_TO_INTARRAY:
					{
						// Get arguments
						int addr = lr[args[1]],
							indx = lr[args[2]],
							rinn = args[0];
						
						// Calculate array index offset
						int ioff = Constants.ARRAY_BASE_SIZE + (indx * 4);
						
						// Read value
						memory.memWriteInt(addr + ioff, lr[rinn]);
					}
					break;
				
					// System call
				case NativeInstructionType.SYSTEM_CALL:
					{
						// The arguments to the system calls are in registers
						// so they must be extracted first before they can be
						// known
						int nrl = reglist.length;
						int[] sargs = new int[nrl];
						for (int i = 0; i < nrl; i++)
							sargs[i] = lr[reglist[i]];
						
						// Get the system call ID
						short syscallid = (short)lr[args[0]];
						
						// Handle system call as is from the supervisor
						// IPC Exception load/store is not included
						// IPC Calls are always virtualized even in supervisor.
						Frame was = frames.getLast();
						if ((was._taskid == 0 ||
							syscallid == SystemCallIndex.EXCEPTION_LOAD ||
							syscallid == SystemCallIndex.EXCEPTION_STORE) &&
							syscallid != SystemCallIndex.IPC_CALL)
						{
							// If profiling, profile the handling of the
							// system call in a sub-frame
							if (profiler != null)
								profiler.enterFrame("<syscall>",
									Integer.toString(syscallid),
									"(IIIIIIII)I");
							
							// Set the return register to whatever system call
							// was used
							try
							{
								long rv = this.__sysCall(syscallid, sargs);
								
								lr[NativeCode.RETURN_REGISTER] = (int)rv;
								lr[NativeCode.RETURN_REGISTER + 1] =
									(int)(rv >>> 32);
							}
							
							// If profiling, that frame needs to exit always!
							finally
							{
								if (profiler != null)
									profiler.exitFrame();
							}
						}
						
						// Otherwise jump into supervisor and handle the
						// system call on behalf of the task
						else
						{
							// Enter the frame
							int[] svp = this._supervisorproperties;
							Frame f = this.enterFrame(
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_METHOD_HANDLER]);
							
							// Set frame's task ID to zero
							f._taskid = 0;
							
							// Set required registers
							f._registers[NativeCode.POOL_REGISTER] =
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_METHOD_POOL_POINTER];
							f._registers[NativeCode.STATIC_FIELD_REGISTER] =
								svp[SupervisorPropertyIndex.
									TASK_SYSCALL_STATIC_FIELD_POINTER];
							
							// Setup call: taskid + oldsfp + sysid + 8 syscall
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 0] =
								was._taskid;
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 1] =
								was._registers[
									NativeCode.STATIC_FIELD_REGISTER];
							f._registers[
								NativeCode.ARGUMENT_REGISTER_BASE + 2] =
								syscallid;
							
							// Forward system call arguments
							for (int x = 0, xn = sargs.length; x < xn; x++)
								f._registers[NativeCode.ARGUMENT_REGISTER_BASE
									+ 3 + x] = sargs[x];
							
							// Setup for frame enter
							reload = true;
							pointcounter = 0;
						}
					}
					break;
					
					// {@squirreljme.error AE0n Invalid instruction.}
				default:
					throw new VMException("AE0n " +
						NativeInstruction.mnemonic(op));
			}
			
			// Set next PC address
			pc = nextpc;
		}
	}
	
	/**
	 * Returns the trace of the current execution.
	 *
	 * @return The current trace.
	 * @since 2019/04/22
	 */
	public final CallTraceElement[] trace()
	{
		LinkedList<Frame> frames = this._frames;
		
		// Need to store all the frames
		int numframes = frames.size();
		CallTraceElement[] rv = new CallTraceElement[numframes];
		
		// Make the newest frame first!
		for (int i = numframes - 1, o = 0; i >= 0; i--, o++)
			rv[o] = this.trace(frames.get(i));
		
		return rv;
	}
	
	/**
	 * Returns the trace for the given frame.
	 *
	 * @param __f The frame to trace.
	 * @return The trace of this frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	public final CallTraceElement trace(Frame __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Build trace
		return new CallTraceElement(
			__f._inclass,
			__f._inmethodname,
			__f._inmethodtype,
			__f._pc, __f._insourcefile,
			__f._inline,
			__f._injop,
			__f._injpc,
			__f._taskid);
	}
	
	/**
	 * Traces the top most frame.
	 *
	 * @return The top most frame.
	 * @since 2019/06/13
	 */
	public final CallTraceElement traceTop()
	{
		LinkedList<Frame> frames = this._frames;
		
		// Only look at the top most frame
		Frame top = frames.peekLast();
		if (top == null)
			return new CallTraceElement();
		return this.trace(top);
	}
	
	/**
	 * Sets the frame information string from the given pool entries.
	 *
	 * @param __f The frame.
	 * @param __pcl The class string from the pool.
	 * @param __pmn The method name from the pool.
	 * @param __pmt The method type from the pool.
	 * @param __psf The current source file.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	private final void __debugEntry(Frame __f, int __pcl, int __pmn, int __pmt,
		int __psf)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Get the pool address
		int pooladdr = __f._registers[NativeCode.POOL_REGISTER];
		
		int icl = memory.memReadInt(pooladdr + (__pcl * 4)),
			imn = memory.memReadInt(pooladdr + (__pmn * 4)),
			imt = memory.memReadInt(pooladdr + (__pmt * 4)),
			isf = memory.memReadInt(pooladdr + (__psf * 4));
		
		// Store in state
		__f._inclassp = icl;
		__f._inmethodnamep = imn;
		__f._inmethodtypep = imt;
		__f._insourcefilep = isf;
		
		// Load strings
		String scl, smn, smt, ssf;
		WritableMemory memory = this.memory;
		__f._inclass = 
			(scl = (icl == 0 ? null : this.__loadUtfString(icl)));
		__f._inmethodname = 
			(smn = (imn == 0 ? null : this.__loadUtfString(imn)));
		__f._inmethodtype = 
			(smt = (imt == 0 ? null : this.__loadUtfString(imt)));
		__f._insourcefile = 
			(ssf = (isf == 0 ? null : this.__loadUtfString(isf)));
		
		// Enter it on the profiler
		ProfiledThread profiler = this.profiler;
		if (profiler != null)
			profiler.enterFrame(
				(scl == null ? "<AClass>" : scl),
				(smn == null ? "<AMethod>" : smn),
				(smt == null ? "<AType>" : smt));
	}
	
	/**
	 * Debugs the exit of a frame.
	 *
	 * @param __f The frame to exit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	private final void __debugExit(Frame __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Exit the frame, but if we extra exited then it is very possible
		// that the state can be messed up so do not absolutely destroy the
		// VM stuff
		ProfiledThread profiler = this.profiler;
		if (profiler != null)
			try
			{
				profiler.exitFrame();
			}
			catch (IllegalStateException e)
			{
			}
	}
	
	/**
	 * Sets the debug point in the frame.
	 *
	 * @param __f The frame.
	 * @param __sln The source line.
	 * @param __jop The Java operation.
	 * @param __jpc The Java address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/15
	 */
	private final void __debugPoint(Frame __f, int __sln, int __jop, int __jpc)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		__f._inline = __sln;
		__f._injop = __jop;
		__f._injpc = __jpc;
	}
	
	/**
	 * Loads a UTF string from the given memory address.
	 *
	 * @param __addr The address to read from.
	 * @return The resulting string.
	 * @since 2019/05/15
	 */
	private final String __loadUtfString(int __addr)
	{
		// Read length to figure out how long the string is
		WritableMemory memory = this.memory;
		int strlen = memory.memReadShort(__addr) & 0xFFFF;
		
		// Decode string data
		try (DataInputStream dis = new DataInputStream(
			new ReadableMemoryInputStream(memory, __addr, strlen + 2)))
		{
			return dis.readUTF();
		}
		
		// Could not read string, use some other string form
		catch (IOException e)
		{
			return String.format("??? @%08x (len=%d)", __addr, strlen);
		}
	}
	
	/**
	 * Internal system call handling.
	 *
	 * @param __si System call index.
	 * @param __args Arguments.
	 * @return The result.
	 * @since 2019/05/23
	 */
	private final long __sysCall(short __si, int... __args)
	{
		// Error state for the last call of this type
		int[] errors = this._syscallerrors;
		
		// Return value with error value, to set if any
		long rv;
		int err;
		
		// Depends on the system call type
		switch (__si)
		{
				// Check if system call is supported
			case SystemCallIndex.QUERY_INDEX:
				{
					err = 0;
					switch (__args[0])
					{
						case SystemCallIndex.BYTE_ORDER_LITTLE:
						case SystemCallIndex.ERROR_GET:
						case SystemCallIndex.ERROR_SET:
						case SystemCallIndex.EXCEPTION_LOAD:
						case SystemCallIndex.EXCEPTION_STORE:
						case SystemCallIndex.FATAL_TODO:
						case SystemCallIndex.FRAME_TASK_ID_GET:
						case SystemCallIndex.FRAME_TASK_ID_SET:
						case SystemCallIndex.CALL_STACK_HEIGHT:
						case SystemCallIndex.CALL_STACK_ITEM:
						case SystemCallIndex.MEM_SET:
						case SystemCallIndex.PD_OF_STDERR:
						case SystemCallIndex.PD_OF_STDIN:
						case SystemCallIndex.PD_OF_STDOUT:
						case SystemCallIndex.PD_WRITE_BYTE:
						case SystemCallIndex.SLEEP:
						case SystemCallIndex.SUPERVISOR_BOOT_OKAY:
						case SystemCallIndex.SUPERVISOR_PROPERTY_GET:
						case SystemCallIndex.SUPERVISOR_PROPERTY_SET:
						case SystemCallIndex.TIME_MILLI_WALL:
						case SystemCallIndex.TIME_NANO_MONO:
						case SystemCallIndex.VMI_MEM_FREE:
						case SystemCallIndex.VMI_MEM_MAX:
						case SystemCallIndex.VMI_MEM_USED:
							rv = 1;
							break;
						
						default:
							rv = 0;
							break;
					}
				}
				break;
				
				// Is this little endian?
			case SystemCallIndex.BYTE_ORDER_LITTLE:
				rv = 0;
				err = 0;
				break;
			
				// Get the height of the call stack
			case SystemCallIndex.CALL_STACK_HEIGHT:
				{
					rv = this._frames.size();
					err = 0;
				}
				break;
				
				// Get item on the call stack
			case SystemCallIndex.CALL_STACK_ITEM:
				{
					// Locate frame
					int fr = __args[0];
					LinkedList<Frame> frames = this._frames;
					int numframes = frames.size();
					Frame frame = ((fr < 0 || fr >= numframes) ? null :
						frames.get((numframes - 1) - fr));
					
					// Depends on the ID
					int dx = (frame == null ? -1 : __args[1]);
					switch (dx)
					{
						case CallStackItem.CLASS_NAME:
							err = 0;
							rv = frame._inclassp;
							break;
							
						case CallStackItem.METHOD_NAME:
							err = 0;
							rv = frame._inmethodnamep;
							break;
							
						case CallStackItem.METHOD_TYPE:
							err = 0;
							rv = frame._inmethodtypep;
							break;
						
						case CallStackItem.SOURCE_FILE:
							err = 0;
							rv = frame._insourcefilep;
							break;
							
						case CallStackItem.SOURCE_LINE:
							err = 0;
							rv = frame._inline;
							break;
							
						case CallStackItem.PC_ADDRESS:
							err = 0;
							rv = frame._lastpc;
							break;
							
						case CallStackItem.JAVA_OPERATION:
							err = 0;
							rv = frame._injop;
							break;
							
						case CallStackItem.JAVA_PC_ADDRESS:
							err = 0;
							rv = frame._injpc;
							break;
						
						case CallStackItem.TASK_ID:
							err = 0;
							rv = frame._taskid;
						
							// Not valid
						default:
							rv = 0;
							err = SystemCallError.VALUE_OUT_OF_RANGE;
							break;
					}
				}
				break;
				
				// Get error
			case SystemCallIndex.ERROR_GET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return the stored error code
					synchronized (errors)
					{
						rv = errors[dx];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// Set error
			case SystemCallIndex.ERROR_SET:
				{
					// If the ID is valid then a bad array access will be used
					int dx = __args[0];
					if (dx < 0 || dx >= SystemCallIndex.NUM_SYSCALLS)
						dx = SystemCallIndex.QUERY_INDEX;
					
					// Return last error code, and set new one
					synchronized (errors)
					{
						rv = errors[dx];
						errors[dx] = __args[0];
					}
					
					// Always succeeds
					err = 0;
				}
				break;
				
				// IPC Exception load
			case SystemCallIndex.EXCEPTION_LOAD:
				rv = this._ipcexception;
				err = 0;
				break;
				
				// IPC Exception store
			case SystemCallIndex.EXCEPTION_STORE:
				rv = this._ipcexception;
				this._ipcexception = __args[0];
				err = 0;
				break;
				
				// Fatal exit because of incomplete code
			case SystemCallIndex.FATAL_TODO:
				// {@squirreljme.error AE0o Fatal ToDo system call executed.}
				throw new VMToDoException("AE0o");
				
				// Gets the frame task ID
			case SystemCallIndex.FRAME_TASK_ID_GET:
				{
					LinkedList<Frame> frames = this._frames;
					Frame frame = frames.getLast();
					
					// Is fine
					rv = frame._taskid;
					err = 0;
				}
				break;
				
				// Sets the frame task ID
			case SystemCallIndex.FRAME_TASK_ID_SET:
				{
					LinkedList<Frame> frames = this._frames;
					Frame frame = frames.getLast();
					
					// Set
					frame._taskid = __args[0];
					
					// Is fine
					rv = 1;
					err = 0;
				}
				break;
				
				// Sets memory to byte value
			case SystemCallIndex.MEM_SET:
				{
					// Set memory
					WritableMemory memory = this.memory;
					
					// Get parameters
					int addr = __args[0],
						valu = __args[1],
						lens = __args[2];
					
					// Wipe
					for (int i = 0; i < lens; i++)
						memory.memWriteByte(addr + i, valu);
					
					// Is okay
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard error
			case SystemCallIndex.PD_OF_STDERR:
				{
					rv = 2;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard input
			case SystemCallIndex.PD_OF_STDIN:
				{
					rv = 0;
					err = 0;
				}
				break;
				
				// Pipe descriptor of standard output
			case SystemCallIndex.PD_OF_STDOUT:
				{
					rv = 1;
					err = 0;
				}
				break;
				
				// Write single byte to PD
			case SystemCallIndex.PD_WRITE_BYTE:
				{
					// Depends on the stream
					int pd = __args[0];
					OutputStream os = (pd == 1 ? System.out :
						(pd == 2 ? System.err : null));
					
					// Write
					if (os != null)
					{
						try
						{
							os.write(__args[1]);
							
							// Okay
							rv = 1;
							err = 0;
						}
						
						// Failed
						catch (IOException e)
						{
							rv = -1;
							err = SystemCallError.PIPE_DESCRIPTOR_BAD_WRITE;
						}
					}
					
					// Failed
					else
					{
						rv = -1;
						err = SystemCallError.PIPE_DESCRIPTOR_INVALID;
					}
				}
				break;
				
				// Sleep
			case SystemCallIndex.SLEEP:
				try
				{
					// Sleep
					Thread.sleep(__args[0], __args[1]);
					
					rv = 0;
					err = SystemCallError.NO_ERROR;
				}
				catch (InterruptedException e)
				{
					rv = 1;
					err = SystemCallError.INTERRUPTED;
				}
				break;
				
				// Supervisor booted okay!
			case SystemCallIndex.SUPERVISOR_BOOT_OKAY:
				// Flag that this happened!
				this.state.flagSupervisorOkay();
				
				// Is fine
				rv = 0;
				err = 0;
				break;
				
				// Get supervisor property
			case SystemCallIndex.SUPERVISOR_PROPERTY_GET:
				{
					int dx = __args[0];
					
					// Out of range?
					if (dx < 0 || dx >= SupervisorPropertyIndex.NUM_PROPERTIES)
					{
						rv = 0;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Valid
					else
					{
						rv = this._supervisorproperties[dx];
						err = SystemCallError.NO_ERROR;
					}
				}
				break;
				
				// Set supervisor property
			case SystemCallIndex.SUPERVISOR_PROPERTY_SET:
				{
					int dx = __args[0];
					
					// Out of range?
					if (dx < 0 || dx >= SupervisorPropertyIndex.NUM_PROPERTIES)
					{
						rv = 0;
						err = SystemCallError.VALUE_OUT_OF_RANGE;
					}
					
					// Valid
					else
					{
						this._supervisorproperties[dx] = __args[1];
						
						rv = 0;
						err = SystemCallError.NO_ERROR;
					}
				}
				break;

				// Current wall clock milliseconds.
			case SystemCallIndex.TIME_MILLI_WALL:
				{
					rv = System.currentTimeMillis();
					err = 0;
				}
				break;

				// Current monotonic clock nanoseconds.
			case SystemCallIndex.TIME_NANO_MONO:
				{
					rv = System.nanoTime();
					err = 0;
				}
				break;
				
				// VM information: Memory free bytes
			case SystemCallIndex.VMI_MEM_FREE:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().freeMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory used bytes
			case SystemCallIndex.VMI_MEM_USED:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().totalMemory());
					err = 0;
				}
				break;
			
				// VM information: Memory max bytes
			case SystemCallIndex.VMI_MEM_MAX:
				{
					rv = (int)Math.min(Integer.MAX_VALUE,
						Runtime.getRuntime().maxMemory());
					err = 0;
				}
				break;
				
			default:
				// Returns no value but sets an error
				rv = 0;
				err = SystemCallError.UNSUPPORTED_SYSTEM_CALL;
				
				// If the ID is valid then a bad array access will be used
				if (__si < 0 || __si >= SystemCallIndex.NUM_SYSCALLS)
					__si = SystemCallIndex.QUERY_INDEX;
				break;
		}
		
		// Set error state as needed
		synchronized (errors)
		{
			errors[__si] = err;
		}
		
		// Use returning value
		return rv;
	}
	
	/**
	 * This represents a single frame in the execution stack.
	 *
	 * @since 2019/04/21
	 */
	public static final class Frame
	{
		/** Execution slices. */
		final Deque<ExecutionSlice> _execslices;
		
		/** Registers for this frame. */
		final int[] _registers =
			new int[MAX_REGISTERS];
		
		/** The entry PC address. */
		int _entrypc;
		
		/** The PC address for this frame. */
		volatile int _pc;
		
		/** Last executed address. */
		int _lastpc;
		
		/** The executing class. */
		String _inclass;
		
		/** Executing class name pointer. */
		int _inclassp;
		
		/** The executing method name. */
		String _inmethodname;
		
		/** Executing method name pointer. */
		int _inmethodnamep;
		
		/** The executing method type. */
		String _inmethodtype;
		
		/** Executing method type pointer. */
		int _inmethodtypep;
		
		/** Source file. */
		String _insourcefile;
		
		/** Source file pointer. */
		int _insourcefilep;
		
		/** The current line. */
		int _inline;
		
		/** The current Java operation. */
		int _injop;
		
		/** The current Java address. */
		int _injpc;
		
		/** The current task ID. */
		int _taskid;
		
		/**
		 * Potential initialization.
		 */
		{
			this._execslices = (ENABLE_DEBUG ?
				new LinkedList<ExecutionSlice>() :
				(Deque<ExecutionSlice>)null);
		}
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/RawMemory.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * Raw memory access.
 *
 * @since 2019/04/21
 */
public final class RawMemory
	extends AbstractWritableMemory
{
	/** The memory offset. */
	protected final int offset;
	
	/** The memory size. */
	protected final int size;
	
	/** The memory data. */
	protected final byte[] bytes;
	
	/**
	 * Raw memory space.
	 *
	 * @param __off The offset.
	 * @param __sz The size of this region.
	 * @since 2019/04/21
	 */
	public RawMemory(int __off, int __sz)
	{
		this.offset = __off;
		this.size = __sz;
		this.bytes = new byte[__sz];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadByte(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size)
			return -1;
		
		return (this.bytes[__addr] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadInt(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 3)
			return -1;
		
		byte[] bytes = this.bytes;
		return ((bytes[__addr++] & 0xFF) << 24) |
			((bytes[__addr++] & 0xFF) << 16) |
			((bytes[__addr++] & 0xFF) << 8) |
			(bytes[__addr++] & 0xFF);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadShort(int __addr)
	{
		// Treat out of region reads as invalid data
		if (__addr < 0 || __addr >= this.size - 1)
			return -1;
		
		byte[] bytes = this.bytes;
		return (((bytes[__addr++] & 0xFF) << 8) |
			(bytes[__addr++] & 0xFF));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memWriteByte(int __addr, int __v)
	{
		// {@squirreljme.error AE06 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 1)
			throw new VMRuntimeException(String.format("AE06 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteInt(int __addr, int __v)
	{
		// {@squirreljme.error AE07 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 3)
			throw new VMRuntimeException(String.format("AE07 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v >>> 24);
		bytes[__addr++] = (byte)(__v >>> 16);
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteShort(int __addr, int __v)
	{
		// {@squirreljme.error AE08 Cannot write to the specified address.
		// (The address to write to)}
		if (__addr < 0 || __addr >= this.size - 2)
			throw new VMRuntimeException(String.format("AE08 %08x",
				this.offset + __addr));
		
		byte[] bytes = this.bytes;
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ReadableMemory.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This interface is used to represent anything which provides memory which
 * can be read.
 *
 * @since 2019/04/21
 */
public interface ReadableMemory
	extends Memory
{
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	public abstract int memReadByte(int __addr);
	
	/**
	 * Bulk read of memory bytes.
	 *
	 * @param __ad The address to read from.
	 * @param __b The output bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public abstract void memReadBytes(int __ad, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException;
	
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	public abstract int memReadInt(int __addr);
	
	/**
	 * Reads the memory at the specified address.
	 *
	 * @param __addr The address to read from.
	 * @return The read value.
	 * @since 2019/04/21
	 */
	public abstract int memReadShort(int __addr);
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ReadableMemoryInputStream.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
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











































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import java.io.InputStream;

/**
 * This is an input stream which can read from readable memory.
 *
 * @since 2019/04/21
 */
public final class ReadableMemoryInputStream
	extends InputStream
{
	/** The input memory. */
	protected final ReadableMemory memory;
	
	/** The base read address. */
	protected final int address;
	
	/** The number of bytes that can be read. */
	protected final int length;
	
	/** The current read offset. */
	private int _at;
	
	/**
	 * Initializes the stream.
	 *
	 * @param __mem The memory.
	 * @param __ad The start address.
	 * @param __ln The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public ReadableMemoryInputStream(ReadableMemory __mem, int __ad, int __ln)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.address = __ad;
		this.length = __ln;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int available()
	{
		return this.length - this._at;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read()
	{
		// EOF?
		int at = this._at;
		if (at >= this.length)
			return -1;
		
		// Read
		this._at = at + 1;
		return this.memory.memReadByte(this.address + at) & 0xFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read(byte[] __b)
		throws NullPointerException
	{
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Used to check bounds
		int at = this._at,
			length = this.length,
			address = this.address;
		
		// Read in all bytes
		ReadableMemory memory = this.memory;
		for (int i = 0; i < __l; i++)
		{
			// EOF?
			if (at >= length)
			{
				this._at = at + i;
				return (i == 0 ? -1 : i);
			}
			
			// Read in
			__b[__o++] = (byte)memory.memReadByte(address + at + i);
		}
		
		// Count
		this._at = at + __l;
		return __l;
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/StaticAllocator.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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This class is used to assist in static allocation of data.
 *
 * @since 2019/04/24
 */
@Deprecated
public final class StaticAllocator
{
	/** Start address. */
	protected final int base;
	
	/** The current size. */
	private int _size;
	
	/**
	 * Initializes the static allocator.
	 *
	 * @param __ba The allocation size.
	 * @since 2019/04/24
	 */
	public StaticAllocator(int __ba)
	{
		this.base = __ba;
	}
	
	/**
	 * Allocates the given number of bytes.
	 *
	 * @param __sz The number of bytes to allocate.
	 * @return The allocation pointer.
	 * @since 2019/04/24
	 */
	public final int allocate(int __sz)
	{
		// Round up
		__sz = (__sz + 3) & (~3);
		
		// Determine new size
		int oldsize = this._size;
		this._size = oldsize + __sz;
		
		// Return pointer
		return this.base + oldsize;
	}
	
	/**
	 * Returns the current size of the allocator.
	 *
	 * @return The allocation size.
	 * @since 2019/04/24
	 */
	public final int size()
	{
		return this._size;
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SuiteMemory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261





































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import dev.shadowtail.classfile.mini.Minimizer;
import dev.shadowtail.jarfile.JarMinimizer;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMException;
import cc.squirreljme.vm.VMSuiteManager;
import net.multiphasicapps.classfile.ClassFile;

/**
 * This represents the single virtual memory space for suite memory.
 *
 * @since 2019/04/21
 */
public final class SuiteMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** The suite manager. */
	protected final VMSuiteManager suites;
	
	/** The library this uses. */
	protected final String libname;
	
	/** The offset to this memory region. */
	protected final int offset;
	
	/** Was this initialized? */
	private volatile boolean _didinit;
	
	/** Memory for this suite. */
	private volatile ReadableMemory _memory;
	
	/** Header for this JAR. */
	volatile MinimizedJarHeader _jarheader;
	
	/**
	 * Initializes the suite memory.
	 *
	 * @param __off The memory offset for this suite.
	 * @param __sm The suite manager.
	 * @param __ln The library name.
	 * @throws NullPointerException On null arguments.
	 */
	public SuiteMemory(int __off, VMSuiteManager __sm, String __ln)
		throws NullPointerException
	{
		if (__sm == null || __ln == null)
			throw new NullPointerException("NARG");
		
		this.suites = __sm;
		this.libname = __ln;
		this.offset = __off;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadByte(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public void memReadBytes(int __addr, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		this._memory.memReadBytes(__addr, __b, __o, __l);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadInt(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadInt(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadShort(int __addr)
	{
		// Initialize?
		if (!this._didinit)
			try
			{
				this.__init();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		
		// Forward
		return this._memory.memReadShort(__addr);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return SuitesMemory.SUITE_CHUNK_SIZE;
	}
	
	/**
	 * Initializes all the memory and suites here.
	 *
	 * @throws IOException On read/write errors.
	 * @since 2019/04/21
	 */
	final void __init()
		throws IOException
	{
		// Do not initialize twice!
		if (this._didinit)
			return;
		this._didinit = true;
		
		// Load the class library
		String libname = this.libname;
		VMClassLibrary clib = this.__loadLibrary(libname);
		
		// Debug
		todo.DEBUG.note("Initialize suite %s @%08d", libname, this.offset);
		
		// Minimize and format the JAR
		byte[] jf = JarMinimizer.minimize((libname.equals("supervisor") ||
			libname.equals("supervisor.jar")), clib);
		
		// {@squirreljme.error AE09 Suite chunk size limit was exceeded.
		// (The required chunk size; The limit; More space that is needed)}
		if (jf.length > SuitesMemory.SUITE_CHUNK_SIZE)
			throw new RuntimeException("AE09 " + jf.length + " " +
				SuitesMemory.SUITE_CHUNK_SIZE + " " +
				(jf.length - SuitesMemory.SUITE_CHUNK_SIZE));
		
		// Set memory using this byte array
		ReadableMemory rm;
		this._memory = (rm = new ByteArrayMemory(this.offset, jf));
		
		// Load the JAR header
		this._jarheader = MinimizedJarHeader.decode(
			new ReadableMemoryInputStream(rm, 0,
				MinimizedJarHeader.HEADER_SIZE_WITH_MAGIC));
	}
	
	/**
	 * Attempts to load the given library.
	 *
	 * @param __libname The library to load.
	 * @return The loaded library.
	 * @throws NullPointerException On null arguments.
	 * @throws VMException If it was not found.
	 * @since 2019/11/28
	 */
	private final VMClassLibrary __loadLibrary(String __libname)
		throws NullPointerException, VMException
	{
		if (__libname == null)
			throw new NullPointerException("NARG");
			
		VMSuiteManager suites = this.suites;
		
		// Try as it is requested
		VMClassLibrary rv = suites.loadLibrary(__libname);
		if (rv != null)
			return rv;
		
		// Try with an extension added
		rv = suites.loadLibrary(__libname + ".jar");
		if (rv != null)
			return rv;
		
		// Try to remove the JAR extension
		if (__libname.endsWith(".jar"))
		{
			rv = suites.loadLibrary(__libname.substring(0,
				__libname.length() - 4));
			if (rv != null)
				return rv;
		}
		
		// {@squirreljme.error AE0p Could not find library. (The library)}
		throw new VMException("AE0p " + __libname);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SuitesMemory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275



















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMException;
import cc.squirreljme.vm.VMSuiteManager;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import dev.shadowtail.packfile.MinimizedPackHeader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.classfile.MethodFlags;

/**
 * This class contains the memory information for every single suite which
 * exists within the VM.
 *
 * @since 2019/04/21
 */
public final class SuitesMemory
	extends AbstractReadableMemory
	implements ReadableMemory
{
	/** Configuration and table space size. */
	public static final int CONFIG_TABLE_SIZE =
		1048576;
	
	/** The suite chunk size. */
	public static final int SUITE_CHUNK_SIZE =
		25_165_824;
	
	/** The suite manage to base from. */
	protected final VMSuiteManager suites;
	
	/** Offset. */
	protected final int offset;
	
	/** The size of this memory region. */
	protected final int size;
	
	/** The individual regions of suite memory. */
	private final SuiteMemory[] _suitemem;
	
	/** This is the mapping of suite names to memory. */
	private final Map<String, SuiteMemory> _suitemap;
	
	/** The suite configuration table (addresses of suites). */
	private volatile ReadableMemory _configtable;
	
	/** Was the config table initialized? */
	private volatile boolean _didconfiginit;
	
	/**
	 * Initializes the suites memory.
	 *
	 * @param __off The offset of suite memory.
	 * @param __sm The suite manager.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public SuitesMemory(int __off, VMSuiteManager __sm)
		throws NullPointerException
	{
		if (__sm == null)
			throw new NullPointerException("NARG");
		
		// Set suites
		this.suites = __sm;
		
		// All the libraries which are available for usage
		String[] libnames = __sm.listLibraryNames();
		int n = libnames.length;
		
		// Setup suite memory area
		SuiteMemory[] suitemem = new SuiteMemory[n];
		Map<String, SuiteMemory> suitemap = new LinkedHashMap<>();
		
		// Setup memory regions for the various suites
		int off = CONFIG_TABLE_SIZE;
		for (int i = 0; i < n; i++, off += SUITE_CHUNK_SIZE)
		{
			// Need the suite name for later lookup on init
			String libname = libnames[i];
			
			// Normalize and add JAR
			if (!libname.endsWith(".jar"))
				libname = libname + ".jar";
			
			// Map suite
			SuiteMemory sm;
			suitemem[i] = (sm = new SuiteMemory(off, __sm, libname));
			
			// Also use map for quick access
			suitemap.put(libname, sm);
		}
		
		// {@squirreljme.error AE0q Suite space has exceeded size limit of
		// 2GiB. (The current size; The amount of bytes over)}
		if (off < 0)
			throw new VMException("AE0q " + (((long)off) & 0xFFFFFFFFL) + " " +
				(off - 0x7FFFFFFF));
		
		// Store all the various suite memories
		this._suitemem = suitemem;
		this._suitemap = suitemap;
		
		// Store final memory parameters
		this.offset = __off;
		this.size = off;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memReadByte(int __addr)
	{
		// Needs to be initialized?
		if (!this._didconfiginit)
			this.__init();
		
		// Reading from the config table?
		if (__addr < CONFIG_TABLE_SIZE)
			return this._configtable.memReadByte(__addr);
		
		// Determine the suite index we are wanting to look in memory
		int si = (__addr - CONFIG_TABLE_SIZE) / SUITE_CHUNK_SIZE;
		
		// Instead of failing, return some invalid values
		SuiteMemory[] suitemem = this._suitemem;
		if (si < 0 || si >= suitemem.length)
			return 0xFF;
		
		// Read from suite memory
		return suitemem[si].memReadByte(__addr - suitemem[si].offset);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return this.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return this.size;
	}
	
	/**
	 * Initializes the configuration space.
	 *
	 * @since 2019/04/21
	 */
	final void __init()
	{
		// Do not initialize twice!
		if (this._didconfiginit)
			return;
		this._didconfiginit = true;
		
		// Initialize the bootstrap
		SuiteMemory superv = this._suitemap.get("supervisor.jar");
		try
		{
			superv.__init();
		}
		
		// {@squirreljme.error AE0a Could not initialize the supervisor.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0a", e);
		}
		
		// Get suites and the number of them for processing
		SuiteMemory[] suitemem = this._suitemem;
		int numsuites = suitemem.length;
		
		// Build a virtualized pack header which works with SummerCoat and
		// matches the ROM format (just appears as a larger ROM)
		int packoffset = this.offset;
		try (ByteArrayOutputStream pbaos = new ByteArrayOutputStream(4096);
			DataOutputStream dos = new DataOutputStream(pbaos))
		{
			// Relative offset for names
			int reloff = MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC +
				(MinimizedPackHeader.TOC_ENTRY_SIZE * numsuites);
			
			// Write pack header
			dos.writeInt(MinimizedPackHeader.MAGIC_NUMBER);
			
			// Count and table of contents position
			dos.writeInt(numsuites);
			dos.writeInt(MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC);
			
			// Boot properties
			dos.writeInt(Arrays.asList(suitemem).indexOf(superv));
			dos.writeInt(superv.offset);
			dos.writeInt(SUITE_CHUNK_SIZE);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			
			// Class and run-time constant pools
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			dos.writeInt(0);
			
			// Name table output
			ByteArrayOutputStream nbaos = new ByteArrayOutputStream(4096);
			DataOutputStream ndos = new DataOutputStream(nbaos);
			
			// Write TOC
			for (int i = 0; i < numsuites; i++)
			{
				SuiteMemory suite = suitemem[i];
				
				// Align name
				while (((reloff + ndos.size()) & 1) != 0)
					ndos.write(0);
				
				// Name position
				dos.writeInt(reloff + ndos.size());
				
				// Write name
				ndos.writeUTF(suite.libname);
				
				// Offset and size of the chunk
				dos.writeInt(suite.offset);
				dos.writeInt(SUITE_CHUNK_SIZE);
				
				// The manifest is not known, must be searched
				dos.writeInt(0);
				dos.writeInt(0);
			}
			
			// Write name table
			nbaos.writeTo(dos);
			
			// Store written configuration table
			ReadableMemory configtable = new ByteArrayMemory(packoffset,
				pbaos.toByteArray());
			this._configtable = configtable;
		}
		
		// {@squirreljme.error AE0b Could not write the virtual packfile.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0b", e);
		}
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SummerCoatFactory.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;

import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.Constants;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.MinimizedField;
import dev.shadowtail.classfile.mini.MinimizedMethod;
import dev.shadowtail.classfile.mini.MinimizedPool;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import dev.shadowtail.packfile.MinimizedPackHeader;
import cc.squirreljme.vm.VirtualMachine;
import cc.squirreljme.vm.VMClassLibrary;
import cc.squirreljme.vm.VMException;
import cc.squirreljme.vm.VMFactory;
import cc.squirreljme.vm.VMSuiteManager;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.profiler.ProfilerSnapshot;

/**
 * This is the factory which is capable of creating instances of the
 * SummerCoat virtual machine.
 *
 * @since 2018/12/29
 */
public class SummerCoatFactory
	extends VMFactory
{
	/** The starting address for RAM. */
	public static final int RAM_START_ADDRESS =
		0x0010_0000;
	
	/** Default size of RAM. */
	public static final int DEFAULT_RAM_SIZE =
		33554432;
	
	/** Base address for configuration data. */
	public static final int CONFIG_BASE_ADDR =
		0x1000_0000;
	
	/** The base address for suites. */
	public static final int SUITE_BASE_ADDR =
		0x2000_0000;
	
	/** Size of the configuration area. */
	public static final int CONFIG_SIZE =
		65536;
	
	/**
	 * Initializes the factory.
	 *
	 * @since 2018/12/29
	 */
	public SummerCoatFactory()
	{
		super("summercoat");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/29
	 */
	@Override
	protected VirtualMachine createVM(ProfilerSnapshot __ps,
		VMSuiteManager __sm, VMClassLibrary[] __cp, String __maincl,
		boolean __ismid, int __gd, Map<String, String> __sprops,
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Virtual memory which provides access to many parts of memory
		VirtualMemory vmem = new VirtualMemory();
		
		// The ROM always starts here
		int rombase = SUITE_BASE_ADDR,
			romsize = 0;
		
		// Try to load a specific ROM file instead of the dynamically
		// generate one?
		String romfile = __sprops.get("cc.squirreljme.romfile");
		if (romfile == null)
			try
			{
				romfile = System.getProperty("cc.squirreljme.romfile");
			}
			catch (SecurityException e)
			{
			}
		
		// Load existing ROM file
		if (romfile != null)
		{
			// Debug
			todo.DEBUG.note("Using ROM %s", romfile);
			
			// Copy all of the file data
			Path p = Paths.get(romfile);
			try (InputStream in = Files.newInputStream(p,
					StandardOpenOption.READ);
				ByteArrayOutputStream baos = new ByteArrayOutputStream(
					(int)Files.size(p)))
			{
				// Read data
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					baos.write(buf, 0, rc);
				}
				
				// Initialize memory with the ROM data
				ReadableMemory sm = new ByteArrayMemory(rombase,
					baos.toByteArray());
				vmem.mapRegion(sm);
				
				// Record size of ROM
				romsize = baos.size();
			}
			
			// {@squirreljme.error AE0c Could not load SummerCoat ROM. (File)}
			catch (IOException e)
			{
				throw new RuntimeException("AE0c " + romfile, e);
			}
		}
		
		// Dynamically initialized suite memory
		else
		{
			// Create and map dynamic suite region
			SuitesMemory sm = new SuitesMemory(rombase, __sm);
			vmem.mapRegion(sm);
			
			// Initialize suite memory explicitly since we need it!
			sm.__init();
			
			// Rom size is derived from the chunk size
			romsize = sm.size;
		}
		
		// Initialize RAM
		int ramsize = SummerCoatFactory.DEFAULT_RAM_SIZE,
			ramstart = RAM_START_ADDRESS;
		vmem.mapRegion(new RawMemory(ramstart, ramsize));
		
		// Initialize configuration memory
		WritableMemory cmem = new RawMemory(CONFIG_BASE_ADDR, CONFIG_SIZE);
		vmem.mapRegion(cmem);
		
		// Read the boot JAR offset of this packfile
		int bootjaroff = rombase + vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJAROFFSET),
			bootjarsize = vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJARSIZE);
		
		// Load the bootstrap JAR header
		MinimizedJarHeader bjh;
		try (InputStream bin = new ReadableMemoryInputStream(vmem,
			bootjaroff, bootjarsize))
		{
			bjh = MinimizedJarHeader.decode(bin);
		}
		
		// {@squirreljme.error AE0e Could not read the boot JAR header.}
		catch (IOException e)
		{
			throw new RuntimeException("AE0e", e);
		}
		
		// Write configuration information
		try (DataOutputStream dos = new DataOutputStream(
			new WritableMemoryOutputStream(cmem, 0, CONFIG_SIZE)))
		{
			// Version
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_VERSION,
				"0.3.0");
			
			// Name
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_NAME,
				"SquirrelJME SummerCoat");
			
			// Vendor
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_VENDOR,
				"Stephanie Gawroriski");
			
			// E-Mail
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_EMAIL,
				"xerthesquirrel@gmail.com");
			
			// URL
			ConfigRomWriter.writeString(dos, ConfigRomType.JAVA_VM_URL,
				"https://squirreljme.cc/");
			
			// Guest depth
			ConfigRomWriter.writeInteger(dos, ConfigRomType.GUEST_DEPTH,
				__gd);
			
			// Main class
			if (__maincl != null)
				ConfigRomWriter.writeString(dos, ConfigRomType.MAIN_CLASS,
					__maincl.replace('.', '/'));
			
			// Is midlet?
			ConfigRomWriter.writeInteger(dos, ConfigRomType.IS_MIDLET,
				(__ismid ? 1 : -1));
			
			// System properties
			if (__sprops != null)
				for (Map.Entry<String, String> e : __sprops.entrySet())
				{
					ConfigRomWriter.writeKeyValue(dos,
						ConfigRomType.DEFINE_PROPERTY,
						e.getKey(), e.getValue());
				}
			
			// Class path
			ConfigRomWriter.writeStrings(dos, ConfigRomType.CLASS_PATH,
				SummerCoatFactory.classPathToStringArray(__cp));
			
			// System call handler
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_STATIC_FIELD_POINTER,
				ramstart + bjh.syscallsfp);
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_CODE_POINTER,
				bootjaroff + bjh.syscallhandler);
			ConfigRomWriter.writeInteger(
				dos, ConfigRomType.SYSCALL_POOL_POINTER,
				ramstart + bjh.syscallpool);
			
			// End
			dos.writeShort(ConfigRomType.END);
		}
		
		// {@squirreljme.error AE0d Could not write to configuration ROM.}
		catch (IOException e)
		{
			throw new VMException("AE0d", e);
		}
		
		// Load the bootstrap JAR header
		int bra = bootjaroff + bjh.bootoffset,
			lram;
		
		// Debug
		if (NativeCPU.ENABLE_DEBUG)
			todo.DEBUG.note("Unpacking BootRAM!");
		
		// Load the boot RAM
		try (DataInputStream dis = new DataInputStream(
			new ReadableMemoryInputStream(vmem, bra, bjh.bootsize)))
		{
			// Read entire RAM space
			lram = dis.readInt();
			byte[] bram = new byte[lram];
			dis.readFully(bram);
			
			// Write into memory
			vmem.memWriteBytes(ramstart, bram, 0, lram);
			
			// Handle RAM initializers
			int n = dis.readInt();
			for (int i = 0; i < n; i++)
			{
				int key = dis.readUnsignedByte(),
					addr = dis.readInt() + ramstart,
					mod = (key & 0x0F),
					siz = ((key & 0xF0) >>> 4);
				
				// Which offset is used?
				int off;
				switch (mod)
				{
						// Nothing
					case 0:
						off = 0;
						break;
						
						// RAM
					case 1:
						off = ramstart;
						break;
					
						// JAR
					case 2:
						off = bootjaroff;
						break;
					
						// {@squirreljme.error AE0f Corrupt Boot RAM with
						// invalid value modifier. (Modifier)}
					default:
						throw new VMException("AE0f " + mod);
				}
				
				// Depends on operation size
				switch (siz)
				{
						// Byte
					case 1:
						vmem.memWriteByte(addr, dis.readByte() + off);
						break;
					
						// Short
					case 2:
						vmem.memWriteShort(addr, dis.readShort() + off);
						break;
					
						// Integer
					case 4:
						vmem.memWriteInt(addr, dis.readInt() + off);
						break;
						
						// Long
					case 8:
						{
							long v = dis.readLong() + off;
							vmem.memWriteInt(addr, (int)(v >>> 32));
							vmem.memWriteInt(addr + 4, (int)(v));
						}
						break;
					
						// {@squirreljme.error AE0g Corrupt Boot RAM with
						// invalid size. (Size)}
					default:
						throw new VMException("AE0g " + siz);
				}
			}
			
			// {@squirreljme.AE04 Expected value at end of initializer
			// memory, the Boot RAM is corrupt. (Key value)}
			int key;
			if (-1 != (key = dis.readInt()))
				throw new VMException("AE04 " + key);
				
			// Debug
			if (NativeCPU.ENABLE_DEBUG)
				todo.DEBUG.note("BootRAM unpacked at %08x (size %d)!",
					ramstart, lram);
		}
		
		// {@squirreljme.error AE0h Could not initialize the boot RAM for
		// the virtual machine.}
		catch (IOException e)
		{
			throw new VMException("AE0h", e);
		}
		
		// Setup non-cpu VM state
		MachineState ms = new MachineState(vmem, __ps);
		
		// Setup virtual execution CPU
		NativeCPU cpu = new NativeCPU(ms, vmem, 0, __ps);
		NativeCPU.Frame iframe = cpu.enterFrame(bootjaroff + bjh.bootstart,
			ramstart, ramsize, rombase, romsize,
			CONFIG_BASE_ADDR, CONFIG_SIZE);
		
		// Seed initial frame registers
		iframe._registers[NativeCode.POOL_REGISTER] =
			ramstart + bjh.bootpool;
		iframe._registers[NativeCode.STATIC_FIELD_REGISTER] =
			ramstart + bjh.bootsfieldbase;
		
		// Setup virtual machine with initial thread
		return new SummerCoatVirtualMachine(cpu);
	}
	
	/**
	 * Converts a class path to a string array.
	 *
	 * @param __cp The class path to convert.
	 * @return The resulting string array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public static final String[] classPathToStringArray(VMClassLibrary... __cp)
		throws NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		int n = __cp.length;
		String[] rv = new String[n];
		for (int i = 0; i < n; i++)
		{
			String name = __cp[i].name();
			rv[i] = (name.endsWith(".jar") ? name : name + ".jar");
		}
		
		return rv;
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SummerCoatVirtualMachine.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import cc.squirreljme.vm.VirtualMachine;
import cc.squirreljme.vm.VMException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * This represents a virtual machine within SummerCoat.
 *
 * @since 2019/06/30
 */
public class SummerCoatVirtualMachine
	implements VirtualMachine
{
	/** Threads currently running. */
	private final List<Thread> _threads =
		new ArrayList<>();
	
	/**
	 * Initializes the virtual machine.
	 *
	 * @param __bootcpu The boot CPU.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public SummerCoatVirtualMachine(NativeCPU __bootcpu)
		throws NullPointerException
	{
		if (__bootcpu == null)
			throw new NullPointerException("NARG");
		
		// Add initial thread
		this._threads.add(new Thread(__bootcpu, "BootCPU"));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final int runVm()
		throws VMException
	{
		// Start all threads
		List<Thread> threads = this._threads;
		synchronized (threads)
		{
			// Run threads
			for (int i = 0, n = threads.size(); i < n; i++)
				try
				{
					// Start the thread
					threads.get(i).start();
				}
				
				// Ignore, in the event this was called multiple times!
				catch (IllegalThreadStateException e)
				{
				}
		} 
		
		// Wait for all threads to stop
		for (;;)
		{
			// Available threads
			int count = 0;
			
			// Lock!
			synchronized (threads)
			{
				// Get iterator
				Iterator<Thread> it = threads.iterator();
				
				// Ask about all the threads
				while (it.hasNext())
				{
					// Get the thread
					Thread t = it.next();
					
					// If thread is alive, count it
					if (t.isAlive())
						count++;
					
					// Otherwise remove it
					else
						it.remove();
				}
				
				// If there are many threads alive, just wait around to not
				// waste CPU and poll periodically for the thread states
				if (count > 0)
					try
					{
						threads.wait(1000L);
					}
					catch (InterruptedException e)
					{
					}
			}
			
			// Return error for now
			if (count == 0)
			{
				todo.TODO.note("Actual return value!");
				return 1;
			}
		}
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/VMRuntimeException.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.summercoat;

import cc.squirreljme.vm.VMException;

/**
 * This is an exception in SummerCoat which is translated to an exception
 * for the virtual machine itself when it has a chance to do so.
 *
 * @since 2019/01/11
 */
public class VMRuntimeException
	extends VMException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/01/11
	 */
	public VMRuntimeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/01/11
	 */
	public VMRuntimeException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/VMToDoException.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.vm.summercoat;

import cc.squirreljme.vm.VMException;

/**
 * This is thrown when incomplete code has been reached.
 *
 * @since 2019/11/09
 */
public class VMToDoException
	extends VMException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/11/09
	 */
	public VMToDoException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/11/09
	 */
	public VMToDoException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/11/09
	 */
	public VMToDoException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/11/09
	 */
	public VMToDoException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/VirtualMemory.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
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







































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import cc.squirreljme.jvm.Constants;
import cc.squirreljme.vm.VMException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * This class contains the entirety of virtual memory, this includes access
 * to the various on-demand minification of suites and classes.
 *
 * @since 2019/04/21
 */
public final class VirtualMemory
	extends AbstractWritableMemory
{
	/** Memory map. */
	private final List<Memory> _memories =
		new ArrayList<>();
	
	/** Active cache map. */
	private volatile Memory[] _cache =
		new Memory[0];
	
	/**
	 * Maps the given region of memory.
	 *
	 * @param __mem The region to map.
	 * @param __off The region offset.
	 * @param __len Th
	 * @since 2019/04/21
	 */
	public final void mapRegion(Memory __mem)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		// Add memory
		List<Memory> memories = this._memories;
		synchronized (memories)
		{
			memories.add(__mem);
			
			// Redo cache
			this._cache = memories.<Memory>toArray(
				new Memory[memories.size()]);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memReadByte(int __addr)
	{
		// Find memory to read from
		Memory[] cache = this._cache;
		for (Memory c : cache)
		{
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
				return ((ReadableMemory)c).memReadByte(vaddr);
		}
		
		// {@squirreljme.error AE0i Invalid read from unmapped or non-writable
		// memory! (The address)}
		throw new VMException(String.format("AE0i %08x", __addr));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public int memRegionOffset()
	{
		return 0x00000000;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final int memRegionSize()
	{
		return 0x7FFFFFFF;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/21
	 */
	@Override
	public final void memWriteByte(int __addr, int __v)
	{
		// Find memory to write to
		Memory[] cache = this._cache;
		for (Memory c : cache)
		{
			int cbase = c.memRegionOffset(),
				csize = c.memRegionSize(),
				vaddr = __addr - cbase;
			
			if (vaddr >= 0 && vaddr < csize)
			{
				if (c instanceof WritableMemory)
				{
					((WritableMemory)c).memWriteByte(vaddr, __v);
					return;
				}
			}
		}
		
		// {@squirreljme.error AE0j Invalid write to unmapped or non-writable
		// memory! (The address; The value to write)}
		throw new VMException(String.format("AE0j %08x %d", __addr, __v));
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/WritableMemory.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

/**
 * This is used to provide an interface for reading memory.
 *
 * @since 2019/04/21
 */
public interface WritableMemory
	extends ReadableMemory
{
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public abstract void memWriteByte(int __addr, int __v);
	
	/**
	 * Writes multiple bytes to memory
	 *
	 * @param __a The address to write to.
	 * @param __b The input bytes.
	 * @param __o The offset.
	 * @param __l The length.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public abstract void memWriteBytes(int __a, byte[] __b, int __o, int __l);
	
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public abstract void memWriteInt(int __addr, int __v);
	
	/**
	 * Writes a value to memory.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/21
	 */
	public abstract void memWriteShort(int __addr, int __v);
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/WritableMemoryOutputStream.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
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










































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.vm.summercoat;

import java.io.EOFException;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This is an output stream which can directly write to memory areas.
 *
 * @since 2019/06/14
 */
public final class WritableMemoryOutputStream
	extends OutputStream
{
	/** The output memory. */
	protected final WritableMemory memory;
	
	/** The base write address. */
	protected final int address;
	
	/** The number of bytes that can be written. */
	protected final int length;
	
	/** The current write offset. */
	private int _at;
	
	/**
	 * Initializes the stream.
	 *
	 * @param __mem The memory.
	 * @param __ad The start address.
	 * @param __ln The length.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/14
	 */
	public WritableMemoryOutputStream(WritableMemory __mem, int __ad, int __ln)
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
		this.address = __ad;
		this.length = __ln;
	}
	
	/**
	 * {@inheritDoc)
	 * @since 2019/06/14
	 */
	@Override
	public final void close()
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc)
	 * @since 2019/06/14
	 */
	@Override
	public final void flush()
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc)
	 * @since 2019/06/14
	 */
	@Override
	public final void write(int __b)
		throws IOException
	{
		// {@squirreljme.error AE0k Reached end of memory.}
		int at = this._at;
		if (at >= this.length)
			throw new EOFException("AE0k");
		
		// Write
		this.memory.memWriteByte(this.address + at, __b);
		this._at = at + 1;
	}
	
	/**
	 * {@inheritDoc)
	 * @since 2019/06/14
	 */
	@Override
	public final void write(byte[] __b)
		throws IOException, NullPointerException
	{
		this.write(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc)
	 * @since 2019/06/14
	 */
	@Override
	public final void write(byte[] __b, int __o, int __l)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Needed to check bounds.
		int memlen = this.length,
			at = this._at,
			left = memlen - at;
		
		// {@squirreljme.error AE0l Reached end of memory.}
		if (left <= 0)
			throw new EOFException("AE0l");
		
		// Do not write past the bounds
		if (__l > left)
			__l = left;
		
		// Write to memory
		this.memory.memWriteBytes(address + at, __b, __o, __l);
		
		// Increase pointer
		this._at = at + __l;
	}
}

Deleted runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the SummerCoat virtual machine which is a virtual
 * machine which has register based optimizations.
 *
 * @since 2018/12/29
 */

package cc.squirreljme.vm.summercoat;

Deleted runt/libs/tool-classfile.test/ByteDeque.data.__mime.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251



























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 640 ByteDeque.class
yv66vgAAADMBPAcAzAN/////CgBaAM0KADEAzgcAzwoABQDOCQBaANAJAFoA
0QcA0ggA0woACQDUCQBaANUKAFoA1gcA1wgA2AoADgDUBwDZCADaCgARANQJ
AFoA2wcA3AgA3QoAFQDUCgAFAN4JAFoA3wkAWgDgBwDhCgAbAM4KAFoA4ggA
4wkAWgDkCQBaAOUKAAUA5goABQDnBwBlCgAFAOgLAI8A6QsAjwDqCgDrAOwK
AAUA7QgA7goABQDvBwDwCgArAM4KAAUA8QgA8goAWgDzCAD0BwD1CgABAPYK
APcA+AgA+QgA+goAWgD7CgBaAPwHAP0IAP4KADgA1AoAWgD/CAEACgEBAQIK
AFoBAwoAWgEECgBaAQUKAFoBBgoAWgEHCgBaAQgKAFoBCQoAWgEKCAELCgBa
AQwKAFoBDQgBDggBDwoAWgEQCAERCAESCAETCQBaARQKAAUBFQsAyAEWCAEX
CgABARgKAAEBGQoAAQEaCgABARsHARwIAR0KAFcA1AcBHgEAC19CTE9DS19T
SVpFAQABSQEAC19CTE9DS19NQVNLAQAMX0JMT0NLX1NISUZUAQAIY2FwYWNp
dHkBAAdfYmxvY2tzAQAWTGphdmEvdXRpbC9MaW5rZWRMaXN0OwEACVNpZ25h
dHVyZQEAGkxqYXZhL3V0aWwvTGlua2VkTGlzdDxbQj47AQAFX3NvbG8BAAJb
QgEABl90b3RhbAEABV9oZWFkAQAFX3RhaWwBAAY8aW5pdD4BAAMoKVYBAARD
b2RlAQAPTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAE
dGhpcwEAIkxuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0J5dGVEZXF1ZTsBAAQo
SSlWAQAFX19jYXABAA1TdGFja01hcFRhYmxlAQAKRXhjZXB0aW9ucwEACGFk
ZEZpcnN0AQAEKEIpVgEAA19fYgEAAUIBAARzb2xvAQAFKFtCKVYBAAcoW0JJ
SSlWAQADX19vAQADX19sAQAFdG90YWwBAAhuZXd0b3RhbAEABmJsb2NrcwEA
Am5iAQAEaGVhZAEABHRhaWwBABZMb2NhbFZhcmlhYmxlVHlwZVRhYmxlAQAH
YWRkTGFzdAEAAmJsAQABaQEABWxpbWl0AQACYnMBAAJibQEABGxlZnQBAAJh
dAEACWF2YWlsYWJsZQEAAygpSQEABWNsZWFyBwEfAQALZGVsZXRlRmlyc3QB
AAQoSSlJAQAGbGFzdGJsAQABWgEAAnJjAQADZ2V0AQAEKEkpQgEAA19fYQEA
AnJ2AQAGKElbQilJAQAIKElbQklJKUkBAAhnZXRGaXJzdAEAAygpQgEABShb
QilJAQAHKFtCSUkpSQEAB2dldExhc3QBAAdpc0VtcHR5AQADKClaAQAKb2Zm
ZXJGaXJzdAEABChCKVoBAANpc2UBACFMamF2YS9sYW5nL0lsbGVnYWxTdGF0
ZUV4Y2VwdGlvbjsBAAUoW0IpWgEAByhbQklJKVoBAAlvZmZlckxhc3QBAAlw
ZWVrRmlyc3QBAAFlAQAiTGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0
aW9uOwEACHBlZWtMYXN0AQALcmVtb3ZlRmlyc3QBAANydmEBAANydmIBAApy
ZW1vdmVMYXN0AQADc2V0AQAEc2l6ZQEAC3RvQnl0ZUFycmF5AQAEKClbQgEA
AnN6AQAHd3JpdGVUbwEAGShMamF2YS9pby9PdXRwdXRTdHJlYW07KVYBAARf
X29zAQAWTGphdmEvaW8vT3V0cHV0U3RyZWFtOwcBIAEADV9fZ2V0T3JTZXRW
aWEBAAooWklbQklJWilJAQADbGl0AQAYTGphdmEvdXRpbC9MaXN0SXRlcmF0
b3I7AQAIYmFja3NraXABAAJpdAEAFExqYXZhL3V0aWwvSXRlcmF0b3I7AQAG
X19sYXN0AQAFX19zZXQBAAZibHNraXABAAVyaGVhZAEAHExqYXZhL3V0aWwv
TGlzdEl0ZXJhdG9yPFtCPjsBABhMamF2YS91dGlsL0l0ZXJhdG9yPFtCPjsH
ASEBAAg8Y2xpbml0PgEAClNvdXJjZUZpbGUBAA5CeXRlRGVxdWUuamF2YQEA
EWphdmEvbGFuZy9JbnRlZ2VyDABpAHAMAGkAagEAFGphdmEvdXRpbC9MaW5r
ZWRMaXN0DABgAGEMAGQAZQEAImphdmEvbGFuZy9JbGxlZ2FsQXJndW1lbnRF
eGNlcHRpb24BAARBRTAyDABpASIMAF8AXAwAdAB6AQAeamF2YS9sYW5nL051
bGxQb2ludGVyRXhjZXB0aW9uAQAETkFSRwEAI2phdmEvbGFuZy9JbmRleE91
dE9mQm91bmRzRXhjZXB0aW9uAQAEQkFPQgwAZgBcAQAfamF2YS9sYW5nL0ls
bGVnYWxTdGF0ZUV4Y2VwdGlvbgEABEFFMDMMALIAjQwAZwBcDABoAFwBAAl0
b2RvL1RPRE8MAIQAegEABEFFMDQMAFsAXAwAXQBcDACEASMMAJ8BJAwBJQEm
DAEnAKEMASgBJAcBKQwBKgErDACOAGoBAARBRTA1DACbASQBAAl0b2RvL09P
UFMMAK0BJAEABEFFMDYMAJUAmgEAB0FFMDcgJWQBABBqYXZhL2xhbmcvT2Jq
ZWN0DAEsAS0HAS4MAS8BMAEABEFFMDgBAApBRTA5ICVkICVkDAC7ALwMAJsA
ngEAIGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0aW9uAQAEQUUwYQwA
nwCeAQAEQUUwYgcBMQwBMgEzDACMAI0MAHQAdQwAogCnDACEAHUMAKgApwwA
mwCcDACfAJwMAK0AngEABEFFMGMMAJAAkQwAsACeAQAEQUUwZAEABEFFMGUM
ALEAmgEAB0FFMGYgJWQBAARBRTBnAQAKQUUwaCAlZCAlZAwAXgBcDAE0ATUM
ATYBJAEALG5ldC5tdWx0aXBoYXNpY2FwcHMudXRpbC5kYXRhZGVxdWUuYmxv
Y2tzaXplDAE3ATgMATkAjQwBOgCRDAE7AJEBABpqYXZhL2xhbmcvUnVudGlt
ZUV4Y2VwdGlvbgEAB0FFMDEgJWQBACBuZXQvbXVsdGlwaGFzaWNhcHBzL2lv
L0J5dGVEZXF1ZQEAEmphdmEvdXRpbC9JdGVyYXRvcgEAE2phdmEvaW8vSU9F
eGNlcHRpb24BABZqYXZhL3V0aWwvTGlzdEl0ZXJhdG9yAQAVKExqYXZhL2xh
bmcvU3RyaW5nOylWAQAVKExqYXZhL2xhbmcvT2JqZWN0OylWAQAUKClMamF2
YS9sYW5nL09iamVjdDsBAAhpdGVyYXRvcgEAFigpTGphdmEvdXRpbC9JdGVy
YXRvcjsBAAdoYXNOZXh0AQAEbmV4dAEAEGphdmEvdXRpbC9BcnJheXMBAARm
aWxsAQAGKFtCQilWAQAHdmFsdWVPZgEAFihJKUxqYXZhL2xhbmcvSW50ZWdl
cjsBABBqYXZhL2xhbmcvU3RyaW5nAQAGZm9ybWF0AQA5KExqYXZhL2xhbmcv
U3RyaW5nO1tMamF2YS9sYW5nL09iamVjdDspTGphdmEvbGFuZy9TdHJpbmc7
AQAOamF2YS9sYW5nL01hdGgBAANtYXgBAAUoSUkpSQEADGxpc3RJdGVyYXRv
cgEAGyhJKUxqYXZhL3V0aWwvTGlzdEl0ZXJhdG9yOwEACHByZXZpb3VzAQAK
Z2V0SW50ZWdlcgEAKChMamF2YS9sYW5nL1N0cmluZztJKUxqYXZhL2xhbmcv
SW50ZWdlcjsBAAhpbnRWYWx1ZQEAFW51bWJlck9mVHJhaWxpbmdaZXJvcwEA
CGJpdENvdW50ACEAWgAxAAAACQAaAFsAXAAAABoAXQBcAAAAGgBeAFwAAAAU
AF8AXAAAABIAYABhAAEAYgAAAAIAYwASAGQAZQAAAEIAZgBcAAAAQgBnAFwA
AABCAGgAXAAAACsAAQBpAGoAAQBrAAAANQACAAEAAAAHKhICtwADsQAAAAIA
bAAAAAoAAgAAAFsABgBcAG0AAAAMAAEAAAAHAG4AbwAAAAEAaQBwAAIAawAA
AIkAAwACAAAAKiq3AAQquwAFWbcABrUAByoEvAi1AAgbnAANuwAJWRIKtwAL
vyobtQAMsQAAAAMAbAAAAB4ABwAAAGcABAA3AA8AOwAWAGkAGgBqACQAbQAp
AG4AbQAAABYAAgAAACoAbgBvAAAAAAAqAHEAXAABAHIAAAANAAH/ACQAAgcA
WgEAAABzAAAABAABAAkAEQB0AHUAAgBrAAAAWwAEAAMAAAARKrQACE0sAxtU
KiwDBLYADbEAAAACAGwAAAASAAQAAAB7AAUAfAAJAH0AEAB+AG0AAAAgAAMA
AAARAG4AbwAAAAAAEQB2AHcAAQAFAAwAeABlAAIAcwAAAAQAAQAVABEAdAB5
AAIAawAAAEEABAACAAAACSorAyu+tgANsQAAAAIAbAAAAAoAAgAAAIwACACN
AG0AAAAWAAIAAAAJAG4AbwAAAAAACQB2AGUAAQBzAAAABgACABUADgARAHQA
egACAGsAAAFOAAMACgAAAHIrxwANuwAOWRIPtwAQvxybAA8dmwALHB1gK76k
AA27ABFZEhK3ABO/HZoABLEqtAAUNgQVBB1gNgUVBZsADBUFKrQADKQADbsA
FVkSFrcAF78qtAAHOgYZBrYAGDYHKrQAGTYIKrQAGjYJuwAbWbcAHL8AAAAE
AGwAAAA6AA4AAAChAAQAogAOAKMAHgCkACgApwAsAKgALQCsADMArQA5AK4A
RwCvAFEAsgBXALMAXgC0AGoAtgBtAAAAZgAKAAAAcgBuAG8AAAAAAHIAdgBl
AAEAAAByAHsAXAACAAAAcgB8AFwAAwAzAD8AfQBcAAQAOQA5AH4AXAAFAFcA
GwB/AGEABgBeABQAgABcAAcAZAAOAIEAXAAIAGoACACCAFwACQCDAAAADAAB
AFcAGwB/AGMABgByAAAADAAGDg8JBP0AGQEBCQBzAAAACAADABUAEQAOABEA
hAB1AAIAawAAAFsABAADAAAAESq0AAhNLAMbVCosAwS2AB2xAAAAAgBsAAAA
EgAEAAAAxAAFAMUACQDGABAAxwBtAAAAIAADAAAAEQBuAG8AAAAAABEAdgB3
AAEABQAMAHgAZQACAHMAAAAEAAEAFQARAIQAeQACAGsAAABBAAQAAgAAAAkq
KwMrvrYAHbEAAAACAGwAAAAKAAIAAADVAAgA1gBtAAAAFgACAAAACQBuAG8A
AAAAAAkAdgBlAAEAcwAAAAYAAgAVAA4AEQCEAHoAAgBrAAACmQAEABEAAADt
K8cADbsADlkSD7cAEL8cmwAPHZsACxwdYCu+pAANuwARWRIStwATvx2aAASx
KrQAFDYEFQQdYDYFFQWbAAwVBSq0AAykAA27ABVZEh63ABe/KrQABzoGGQa2
ABg2Byq0ABk2CCq0ABo2CbIAHzYKsgAgNgsdNgwcNg0VDJ4AZBUJmgATFQq8
CDoOGQYZDrYAIacADRkGtgAiwAAjOg4VChUJZDYPFQwVD6IABxUMNg8DNhAV
EBUPogAYGQ4VCYQJASsVDYQNATNUhBABp//nFQkVC342CRUMFQ9kNgyn/50q
FQW1ABQqFQm1ABqxAAAABABsAAAAigAiAAAA6gAEAOsADgDsAB4A7QAoAPAA
LADxAC0A9QAzAPYAOQD3AEcA+ABRAPsAVwD8AF4A/QBqAQAAbwEBAHQBAgB3
AQMAegEEAH8BCQCEAQsAigEMAJQBEQCeARQApQEVAKwBFgCwARkAugEaAMkB
GQDPAR0A1gEgAN0BIQDgASQA5gElAOwBJgBtAAAAtgASAIoACgCFAGUADgCz
ABwAhgBcABAAngA/AIUAZQAOAKUAOACHAFwADwAAAO0AbgBvAAAAAADtAHYA
ZQABAAAA7QB7AFwAAgAAAO0AfABcAAMAMwC6AH0AXAAEADkAtAB+AFwABQBX
AJYAfwBhAAYAXgCPAIAAXAAHAGQAiQCBAFwACABqAIMAggBcAAkAbwB+AIgA
XAAKAHQAeQCJAFwACwB3AHYAigBcAAwAegBzAIsAXAANAIMAAAAMAAEAVwCW
AH8AYwAGAHIAAAA8AA0ODwkE/QAZAQEJ/wAoAA4HAFoHACMBAQEBBwAFAQEB
AQEBAQAAGfwACQcAI/wAEQH8AAIB+gAb+QAQAHMAAAAIAAMAFQARAA4AEQCM
AI0AAQBrAAAALwABAAEAAAAFKrQAFKwAAAACAGwAAAAGAAEAAAEwAG0AAAAM
AAEAAAAFAG4AbwAAABEAjgBqAAEAawAAALkAAgAEAAAAOSoDtQAUKgO1ABkq
A7UAGiq0AAdMK7YAJE0suQAlAQCZABUsuQAmAQDAACNOLQO4ACen/+grtgAo
sQAAAAQAbAAAACIACAAAATsABQE8AAoBPQAPAUAAFAFBACwBQgA0AUMAOAFE
AG0AAAAgAAMALAAFAIUAZQADAAAAOQBuAG8AAAAUACUAfwBhAAEAgwAAAAwA
AQAUACUAfwBjAAEAcgAAAA4AAv0AGQcABQcAj/oAGgARAJAAkQACAGsAAAK7
AAMAEAAAAQobnAANuwARWRIptwATvxuaAAUDrCq0ABQ9HJoABQOsGxyiAAcb
pwAEHD4cHWQ2BCq0AAc6BRkFtgAYNgYqtAAZNgcqtAAaNggdNgmyAB82CrIA
IDYLFQmeAJQZBbYAKsAAIzoMFQYEoAAHBKcABAM2DRUNmQAVFQiaAAgVCqcA
BRUIFQdkpwAIFQoVB2Q2DhUJFQ6iAAcVCTYOFQ6cAAu7ACtZtwAsvwM2DxUP
FQ6iABIZDBUHhAcBA1SEDwGn/+0VBxULfjYHFQeZAA8VDZkAExUHFQigAAwZ
BbYALVeEBv8VCRUOZDYJp/9tFQSaAAkDWTYINgcqFQS1ABQqFQe1ABkqFQi1
ABodrAAAAAQAbAAAAJoAJgAAAVMABAFUAA4BVwASAVgAFAFbABkBXAAdAV0A
HwFgACoBYQAvAWQANQFlADwBZgBIAWkASwFqAFABawBVAWwAWgFvAGQBcABx
AXMAjwF0AJYBdQCaAXkAnwF6AKcBfQCxAX4AugF9AMABgQDHAYQA2AGGAN4B
hwDhAYsA6AGMAOsBjwDwAZAA9gGTAPwBlAECAZUBCAGYAG0AAACiABAAqgAW
AIYAXAAPAGQAhACFAGUADABxAHcAkgCTAA0AjwBZAJQAXAAOAAABCgBuAG8A
AAAAAQoAfABcAAEAGQDxAH0AXAACACoA4ACHAFwAAwAvANsAfgBcAAQANQDV
AH8AYQAFADwAzgCAAFwABgBCAMgAgQBcAAcASADCAIIAXAAIAEsAvwCKAFwA
CQBQALoAiABcAAoAVQC1AIkAXAALAIMAAAAMAAEANQDVAH8AYwAFAHIAAABF
ABQOBfwACgEIQAH/ACsADAcAWgEBAQEHAAUBAQEBAQEAAPwAGAcAI0AB/AAQ
AUEBBUQB/AAMAQz8AAIB+gAVFwj4AAkKAHMAAAAEAAEAEQARAJUAlgACAGsA
AACtAAcABAAAAD0bnAANuwARWRIutwATvyq0AAhNKhssAwS2AC8+HQSgAAcs
AzOsuwARWRIwBL0AMVkDG7gAMlO4ADO3ABO/AAAAAwBsAAAAHgAHAAABqAAE
AakADgGrABMBrAAcAa0AIQGuACUBsgBtAAAAKgAEAAAAPQBuAG8AAAAAAD0A
lwBcAAEAEwAqAHgAZQACABwAIQCYAFwAAwByAAAACgACDv0AFgcAIwEAcwAA
AAQAAQARABEAlQCZAAIAawAAAEgABQADAAAACiobLAMsvrYAL6wAAAACAGwA
AAAGAAEAAAHEAG0AAAAgAAMAAAAKAG4AbwAAAAAACgCXAFwAAQAAAAoAdgBl
AAIAcwAAAAYAAgARAA4AEQCVAJoAAgBrAAABQgAHAAYAAACHG5wADbsAEVkS
NLcAE78sxwANuwAOWRIPtwAQvx2bABEVBJsADB0VBGAsvqQADbsAEVkSErcA
E78qtAAUNgUbmwAJGxUFoQAjuwARWRI1Bb0AMVkDG7gAMlNZBBUFuAAyU7gA
M7cAE78VBZ0ABQOsKhsVBQR6ogAHBKcABAMbLB0VBAO3ADasAAAAAwBsAAAA
OgAOAAAB2gAEAdsADgHeABIB3wAcAeAALgHhADgB5gA+AecASAHoAFUB6QBh
AegAaAHsAG0B7QBvAfEAbQAAAD4ABgAAAIcAbgBvAAAAAACHAJcAXAABAAAA
hwB2AGUAAgAAAIcAewBcAAMAAACHAHwAXAAEAD4ASQB9AFwABQByAAAAJQAJ
Dg0RCfwADwEfBkwHAFr/AAAABgcAWgEHACMBAQEAAgcAWgEAcwAAAAYAAgAR
AA4AEQCbAJwAAgBrAAAAfQAEAAMAAAAgKrQACEwqKwMEtgA3PRwEoAAHKwMz
rLsAOFkSObcAOr8AAAADAGwAAAAWAAUAAAH+AAUB/wANAgAAEgIBABYCBQBt
AAAAIAADAAAAIABuAG8AAAAFABsAeABlAAEADQATAJgAXAACAHIAAAAJAAH9
ABYHACMBAHMAAAAEAAEAOAARAJsAnQACAGsAAAA9AAQAAgAAAAkqKwMrvrYA
N6wAAAACAGwAAAAGAAEAAAITAG0AAAAWAAIAAAAJAG4AbwAAAAAACQB2AGUA
AQBzAAAABAABAA4AEQCbAJ4AAgBrAAAAUQAFAAQAAAAJKgMrHB22AC+sAAAA
AgBsAAAABgABAAACJwBtAAAAKgAEAAAACQBuAG8AAAAAAAkAdgBlAAEAAAAJ
AHsAXAACAAAACQB8AFwAAwBzAAAABgACABEADgARAJ8AnAACAGsAAAB8AAQA
AwAAAB8qtAAITCorAwS2ADs9HJoABysDM6y7ADhZEjy3ADq/AAAAAwBsAAAA
FgAFAAACNAAFAjUADQI2ABECNwAVAjsAbQAAACAAAwAAAB8AbgBvAAAABQAa
AHgAZQABAA0AEgCYAFwAAgByAAAACQAB/QAVBwAjAQBzAAAABAABADgAEQCf
AJ0AAgBrAAAAPQAEAAIAAAAJKisDK762ADusAAAAAgBsAAAABgABAAACSQBt
AAAAFgACAAAACQBuAG8AAAAAAAkAdgBlAAEAcwAAAAQAAQAOABEAnwCeAAIA
awAAAIsABQAFAAAAJB2cAA27ABFZEhK3ABO/KrQAFDYEKgMVBB1kuAA9Kxwd
tgAvrAAAAAMAbAAAABIABAAAAl0ABAJeAA4CYQAUAmIAbQAAADQABQAAACQA
bgBvAAAAAAAkAHYAZQABAAAAJAB7AFwAAgAAACQAfABcAAMAFAAQAH0AXAAE
AHIAAAADAAEOAHMAAAAGAAIAEQAOABEAoAChAAEAawAAAEIAAQABAAAADSq2
AD6aAAcEpwAEA6wAAAADAGwAAAAGAAEAAAJtAG0AAAAMAAEAAAANAG4AbwAA
AHIAAAAFAAILQAEAEQCiAKMAAQBrAAAAaAACAAMAAAAKKhu2AD8ErE0DrAAB
AAAABgAHABUAAwBsAAAAEgAEAAACfgAFAn8ABwKDAAgChQBtAAAAIAADAAgA
AgCkAKUAAgAAAAoAbgBvAAAAAAAKAHYAdwABAHIAAAAGAAFHBwAVABEAogCm
AAIAawAAAD0ABAACAAAACSorAyu+tgBArAAAAAIAbAAAAAYAAQAAApYAbQAA
ABYAAgAAAAkAbgBvAAAAAAAJAHYAZQABAHMAAAAEAAEADgARAKIApwACAGsA
AAB/AAQABQAAAA0qKxwdtgANBKw6BAOsAAEAAAAIAAkAFQADAGwAAAASAAQA
AAKsAAcCrQAJArEACwKzAG0AAAA0AAUACwACAKQApQAEAAAADQBuAG8AAAAA
AA0AdgBlAAEAAAANAHsAXAACAAAADQB8AFwAAwByAAAABgABSQcAFQBzAAAA
BAABABEAEQCoAKMAAQBrAAAAaAACAAMAAAAKKhu2AEEErE0DrAABAAAABgAH
ABUAAwBsAAAAEgAEAAACxQAFAsYABwLKAAgCzABtAAAAIAADAAgAAgCkAKUA
AgAAAAoAbgBvAAAAAAAKAHYAdwABAHIAAAAGAAFHBwAVABEAqACmAAIAawAA
AD0ABAACAAAACSorAyu+tgBCrAAAAAIAbAAAAAYAAQAAAt0AbQAAABYAAgAA
AAkAbgBvAAAAAAAJAHYAZQABAHMAAAAEAAEADgARAKgApwACAGsAAAB/AAQA
BQAAAA0qKxwdtgAdBKw6BAOsAAEAAAAIAAkAFQADAGwAAAASAAQAAALzAAcC
9AAJAvgACwL6AG0AAAA0AAUACwACAKQApQAEAAAADQBuAG8AAAAAAA0AdgBl
AAEAAAANAHsAXAACAAAADQB8AFwAAwByAAAABgABSQcAFQBzAAAABAABABEA
EQCpAI0AAgBrAAAAXAACAAIAAAAMKrYAQxEA/36sTAKsAAEAAAAIAAkAOAAD
AGwAAAAOAAMAAAMMAAkDEAAKAxIAbQAAABYAAgAKAAIAqgCrAAEAAAAMAG4A
bwAAAHIAAAAGAAFJBwA4AHMAAAAEAAEAOAARAKwAjQACAGsAAABcAAIAAgAA
AAwqtgBEEQD/fqxMAqwAAQAAAAgACQA4AAMAbAAAAA4AAwAAAyQACQMoAAoD
KgBtAAAAFgACAAoAAgCqAKsAAQAAAAwAbgBvAAAAcgAAAAYAAUkHADgAcwAA
AAQAAQA4ABEArQCcAAIAawAAAH0ABAADAAAAICq0AAhMKisDBLYART0cBKAA
BysDM6y7ADhZEka3ADq/AAAAAwBsAAAAFgAFAAADOAAFAzkADQM6ABIDOwAW
Az8AbQAAACAAAwAAACAAbgBvAAAABQAbAHgAZQABAA0AEwCYAFwAAgByAAAA
CQAB/QAWBwAjAQBzAAAABAABADgAEQCtAJ0AAgBrAAAAPQAEAAIAAAAJKisD
K762AEWsAAAAAgBsAAAABgABAAADTQBtAAAAFgACAAAACQBuAG8AAAAAAAkA
dgBlAAEAcwAAAAQAAQAOABEArQCeAAIAawAAAQ0ABQAHAAAAXivHAA27AA5Z
Eg+3ABC/HJsADx2bAAscHWArvqQADbsAEVkSErcAE78dmgAFA6wqtAAUNgQV
BJoABQOsKgMrHB22AC82BSodtgBHNgYVBRUGnwALuwArWbcALL8VBawAAAAD
AGwAAAA6AA4AAANgAAQDYQAOA2IAHgNjACgDZgAsA2cALgNqADQDawA5A2wA
OwNvAEUDcABMA3QAUwN1AFsDeABtAAAASAAHAAAAXgBuAG8AAAAAAF4AdgBl
AAEAAABeAHsAXAACAAAAXgB8AFwAAwA0ACoAfQBcAAQARQAZAK4AXAAFAEwA
EgCvAFwABgByAAAADwAGDg8JBfwADAH9AB8BAQBzAAAABgACABEADgARALAA
nAACAGsAAAB9AAQAAwAAACAqtAAITCorAwS2AEg9HASgAAcrAzOsuwA4WRJJ
twA6vwAAAAMAbAAAABYABQAAA4UABQOGAA0DhwASA4gAFgOMAG0AAAAgAAMA
AAAgAG4AbwAAAAUAGwB4AGUAAQANABMAmABcAAIAcgAAAAkAAf0AFgcAIwEA
cwAAAAQAAQA4ABEAsACdAAIAawAAAD0ABAACAAAACSorAyu+tgBIrAAAAAIA
bAAAAAYAAQAAA5oAbQAAABYAAgAAAAkAbgBvAAAAAAAJAHYAZQABAHMAAAAE
AAEADgARALAAngACAGsAAACTAAMABAAAADArxwANuwAOWRIPtwAQvxybAA8d
mwALHB1gK76kAA27ABFZEhK3ABO/uwAbWbcAHL8AAAADAGwAAAAWAAUAAAOt
AAQDrgAOA68AHgOwACgDsgBtAAAAKgAEAAAAMABuAG8AAAAAADAAdgBlAAEA
AAAwAHsAXAACAAAAMAB8AFwAAwByAAAABQADDg8JAHMAAAAGAAIAEQAOABEA
sQCWAAIAawAAAK0ABwAEAAAAPRucAA27ABFZEkq3ABO/KrQACE0qGywDBLYA
Sz4dBKAABywDM6y7ABFZEkwEvQAxWQMbuAAyU7gAM7cAE78AAAADAGwAAAAe
AAcAAAPCAAQDwwAOA8UAEwPGABwDxwAhA8gAJQPMAG0AAAAqAAQAAAA9AG4A
bwAAAAAAPQCXAFwAAQATACoAeABlAAIAHAAhAJgAXAADAHIAAAAKAAIO/QAW
BwAjAQBzAAAABAABABEAEQCxAJkAAgBrAAAASAAFAAMAAAAKKhssAyy+tgBL
rAAAAAIAbAAAAAYAAQAAA94AbQAAACAAAwAAAAoAbgBvAAAAAAAKAJcAXAAB
AAAACgB2AGUAAgBzAAAABgACABEADgARALEAmgACAGsAAAFCAAcABgAAAIcb
nAANuwARWRJNtwATvyzHAA27AA5ZEg+3ABC/HZsAERUEmwAMHRUEYCy+pAAN
uwARWRIStwATvyq0ABQ2BRubAAkbFQWhACO7ABFZEk4FvQAxWQMbuAAyU1kE
FQW4ADJTuAAztwATvxUFnQAFA6wqGxUFBHqiAAcEpwAEAxssHRUEBLcANqwA
AAADAGwAAAA6AA4AAAP0AAQD9QAOA/gAEgP5ABwD+gAuA/sAOAQAAD4EAQBI
BAIAVQQDAGEEAgBoBAYAbQQHAG8ECwBtAAAAPgAGAAAAhwBuAG8AAAAAAIcA
lwBcAAEAAACHAHYAZQACAAAAhwB7AFwAAwAAAIcAfABcAAQAPgBJAH0AXAAF
AHIAAAAlAAkODREJ/AAPAR8GTAcAWv8AAAAGBwBaAQcAIwEBAQACBwBaAQBz
AAAABgACABEADgARALIAjQABAGsAAAAvAAEAAQAAAAUqtAAUrAAAAAIAbAAA
AAYAAQAABBYAbQAAAAwAAQAAAAUAbgBvAAAAEQCzALQAAQBrAAAAXgAFAAMA
AAAUKrYAPjwbvAhNKgMsAxu2AC9XLLAAAAACAGwAAAASAAQAAAQhAAUEIgAJ
BCMAEgQkAG0AAAAgAAMAAAAUAG4AbwAAAAUADwC1AFwAAQAJAAsAmABlAAIA
EQC2ALcAAgBrAAAAWwADAAIAAAAWK8cADbsADlkSD7cAEL+7ABtZtwAcvwAA
AAMAbAAAAA4AAwAABDMABAQ0AA4ENgBtAAAAFgACAAAAFgBuAG8AAAAAABYA
uAC5AAEAcgAAAAMAAQ4AcwAAAAYAAgC6AA4AEgC7ALwAAQBrAAAEHgAEABgA
AAFGKrQAFDYHKrQABzoIGQi2ABg2CSq0ABk2Ciq0ABo2C7IAHzYMsgAgNg0V
BxxkNg4VBRUOogAHFQU2DhUKHGCyAE96NhAbmQA4FQkEpAAyGQgVCbYAUDoR
GRE6DxUJFRBkNhIDNhMVExUSogARGRG5AFEBAFeEEwGn/+6nACIZCLYAJDoP
AzYRFREVEKIAERkPuQAmAQBXhBEBp//uFQocYBUNfjYRFQ42EhUENhMVEp4A
lBkPuQAmAQDAACM6FBkPuQAlAQCaAAcEpwAEAzYVFRWZAA0VC5kACBULpwAF
FQwVEWQ2FhUSFRaiAAcVEjYWFQaZACUDNhcVFxUWogAYGRQVEYQRAS0VE4QT
ATNUhBcBp//npwAiAzYXFRcVFqIAGC0VE4QTARkUFRGEEQEzVIQXAaf/5wM2
ERUSFRZkNhKn/20VDqwAAAAEAGwAAACqACoAAARLAAYETAAMBE0AEwROAB8E
TwAkBFAAKQRTAC8EVAA2BFUAOgRaAEQEWwBOBF8AVwRgAFsEYQBiBGIAbARj
AHQEYgB6BGQAfQRpAIQEagCOBGsAlgRqAJwEcQClBHQAqQR1AK0EdgCyBHkA
vgR8AM8EfwDlBIAA7ASBAPAEhAD1BIUA/wSGAQ4EhQEXBIoBIQSLATAEigE2
BI4BOQSRAUAEkgFDBJUAbQAAAS4AHgBlABUAhgBcABMAVwAjAL0AvgARAGIA
GAC/AFwAEgBbACIAwADBAA8AhwAVAIYAXAARAPgAHACGAFwAFwEaABwAhgBc
ABcAvgCCAIUAZQAUAM8AcQCSAJMAFQDlAFsAlABcABYAAAFGAG4AbwAAAAAB
RgDCAJMAAQAAAUYAlwBcAAIAAAFGAHYAZQADAAABRgB7AFwABAAAAUYAfABc
AAUAAAFGAMMAkwAGAAYBQAB9AFwABwAMAToAfwBhAAgAEwEzAIAAXAAJABkB
LQCBAFwACgAfAScAggBcAAsAJAEiAIgAXAAMACkBHQCJAFwADQAvARcAhwBc
AA4AhADCAMAAwQAPAEQBAgDEAFwAEAClAKEAxQBcABEAqQCdAIoAXAASAK0A
mQCLAFwAEwCDAAAAKgAEAFcAIwC9AMYAEQBbACIAwADHAA8ADAE6AH8AYwAI
AIQAwgDAAMcADwByAAAAsgAS/wA6AA8HAFoBAQcAIwEBAQEHAAUBAQEBAQEA
AP8AKgAUBwBaAQEHACMBAQEBBwAFAQEBAQEBBwCPAQcAyAEBAAD4ABT/AAIA
EQcAWgEBBwAjAQEBAQcABQEBAQEBAQABAAD/AAkAEgcAWgEBBwAjAQEBAQcA
BQEBAQEBAQcAjwEBAAD6ABT+ABABAQH8AB4HACNAAfwAEAFBAfwADwH8AAcB
+gAbAvwAAgH6ABv4AAwACADJAGoAAQBrAAAAiAAHAAAAAABJEAgSUhEAgLgA
U7YAVLgAPbMAH7IAHwRkswAgsgAfuABVswBPsgAfuABWBJ8AHbsAV1kSWAS9
ADFZA7IAH7gAMlO4ADO3AFm/sQAAAAIAbAAAACIACAAAACcABwAoABMALAAb
ADAAHgAxACQAUAAuAFEASABSAHIAAAAFAAH7AEgAAQDKAAAAAgDL
====

Deleted runt/libs/tool-classfile.test/InflaterInputStream.data.__mime.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305

















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 640 InflaterInputStream.class
yv66vgAAADMBswcBMwMAAIAACgABATQKAAEBNQoAaQE2BwE3CgAGATYJAAEB
OAkAAQE5CQABAToHATsKAAsBPAkAAQE9CQABAT4JAAEBPwkAAQFACQABAUEH
AUIIAUMKABIBRAkAAQFFBwFGCgAWAUcJAAEBSAkAAQFJCgAGAUoKALEBSwkA
AQFMCgABAU0HAU4IAU8KAB4BRAoABgFQCQABAVEJAAEBUgkAAQFTCQABAVQK
AAEBVQsAsgFWCQABAVcKAAYBWAoAAQFZCgABAVoKAAEBWwoAAQFcBwFdCAFe
BwFfCgBGAWAKAWEBYgoALgFECgABAWMKAAEBZAoAAQFlCgABAWYKAFQBZwoA
AQFoCgABAWkKAAEBaggBawoAAQFsBwFtCAFuCgAuAW8KAAEBcAoAAQFxCAFy
CQABAXMKAAEBdAcBdQOAAAAACAF2CQABAXcDAAD//wgBeAoAAQF5CgAWAXoH
AXsIAXwIAX0IAX4JAAEBfwoBAwGABwGBBwGCCgBUATYKAFUBgwoAVAGECQAB
AYUJAAEBhgkAAQGHBwCFCQABAYgKALEBTQgBiQoARgGKCAGLCAGMCAGNCgBU
AY4JAAEBjwkAAQGQCgAGAZEKABYBkgcBkwcBlAEADElubmVyQ2xhc3NlcwEA
DV9fQml0U291cmNlX18BABxfREVGQVVMVF9TTElESU5HX1dJTkRPV19TSVpF
AQABSQEADUNvbnN0YW50VmFsdWUBABRfVFlQRV9OT19DT01QUkVTU0lPTgMA
AAAAAQATX1RZUEVfRklYRURfSFVGRk1BTgMAAAABAQAVX1RZUEVfRFlOQU1J
Q19IVUZGTUFOAwAAAAIBAAtfVFlQRV9FUlJPUgMAAAADAQAJX01BWF9CSVRT
AwAAAA8BAA1fU0hVRkZMRV9CSVRTAQACW0kBAAJpbgEAFUxqYXZhL2lvL0lu
cHV0U3RyZWFtOwEABndpbmRvdwEAKkxuZXQvbXVsdGlwaGFzaWNhcHBzL2lv
L1NsaWRpbmdCeXRlV2luZG93OwEACG92ZXJmbG93AQAiTG5ldC9tdWx0aXBo
YXNpY2FwcHMvaW8vQnl0ZURlcXVlOwEACGNoZWNrc3VtAQAhTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vQ2hlY2tzdW07AQAFX3NvbG8BAAJbQgEAB19yZWFk
aW4BAApfYml0c291cmNlAQAiTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vQml0
U291cmNlOwEADF9yYXdjb2RlbGVucwEAD19yYXdsaXRkaXN0bGVucwEACF9i
bGNvdW50AQAJX25leHRjb2RlAQAPX2NvbXByZXNzZWRzaXplAQABSgEAEV91
bmNvbXByZXNzZWRzaXplAQAMX2NvZGVsZW50cmVlAQAZTGphdmEvbGFuZy9y
ZWYvUmVmZXJlbmNlOwEACVNpZ25hdHVyZQEAQkxqYXZhL2xhbmcvcmVmL1Jl
ZmVyZW5jZTxMbmV0L211bHRpcGhhc2ljYXBwcy9pby9IdWZmbWFuVHJlZUlu
dDs+OwEADF9saXRlcmFsdHJlZQEADV9kaXN0YW5jZXRyZWUBAAtfcmVhZHdp
bmRvdwEAHUxqYXZhL2xhbmcvcmVmL1JlZmVyZW5jZTxbQj47AQALX21pbml3
aW5kb3cBAAlfbWluaXNpemUBAAxfd3JpdGV3aW5kb3cBAApfd3JpdGVzaXpl
AQAEX2VvZgEAAVoBAAVfdGFyZwEACF90YXJnb2ZmAQAIX3RhcmdlbmQBAAY8
aW5pdD4BABgoTGphdmEvaW8vSW5wdXRTdHJlYW07KVYBAARDb2RlAQAPTGlu
ZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEALExu
ZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0luZmxhdGVySW5wdXRTdHJlYW07AQAE
X19pbgEACkV4Y2VwdGlvbnMBADkoTGphdmEvaW8vSW5wdXRTdHJlYW07TG5l
dC9tdWx0aXBoYXNpY2FwcHMvaW8vQ2hlY2tzdW07KVYBAARfX2NzAQAZKExq
YXZhL2lvL0lucHV0U3RyZWFtO0kpVgEABV9fc2xzAQA6KExqYXZhL2lvL0lu
cHV0U3RyZWFtO0lMbmV0L211bHRpcGhhc2ljYXBwcy9pby9DaGVja3N1bTsp
VgEACl9fY2hlY2tzdW0BAA1TdGFja01hcFRhYmxlBwGVBwGWAQAJYXZhaWxh
YmxlAQADKClJAQAFY2xvc2UBAAMoKVYBAA9jb21wcmVzc2VkQnl0ZXMBAAMo
KUoBAApkZXRlY3RzRU9GAQADKClaAQAEcmVhZAEAAnJ2AQAEc29sbwEABShb
QilJAQADX19iAQAHKFtCSUkpSQEABGJhc2UBAANfX28BAANfX2wBAAJibAEA
A292bgEAA292cgEAAWMBAANlb2YBABF1bmNvbXByZXNzZWRCeXRlcwEADF9f
ZGVjb21wcmVzcwEACGVudGVyb2ZmAQAIZmluYWxoaXQBAAR0eXBlAQATX19k
ZWNvbXByZXNzRHluYW1pYwEABGNvZGUBAAVkaGxpdAEABmRoZGlzdAEABmRo
Y2xlbgEAC2NvZGVsZW50cmVlAQAnTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8v
SHVmZm1hblRyZWVJbnQ7AQALbGl0ZXJhbHRyZWUBAAxkaXN0YW5jZXRyZWUB
ACJfX2RlY29tcHJlc3NEeW5hbWljTG9hZExpdERpc3RUcmVlAQB6KExuZXQv
bXVsdGlwaGFzaWNhcHBzL2lvL0h1ZmZtYW5UcmVlSW50O0lJTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7TG5ldC9tdWx0aXBoYXNp
Y2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7KVYBAAFpAQABbgEABG5leHQBAAFl
AQAiTGphdmEvdXRpbC9Ob1N1Y2hFbGVtZW50RXhjZXB0aW9uOwEACF9fY2x0
cmVlAQAHX19kaGxpdAEACF9fZGhkaXN0AQAHX19sdHJlZQEAB19fZHRyZWUB
AAV0b3RhbAEADnJhd2xpdGRpc3RsZW5zBwB7AQAeX19kZWNvbXByZXNzRHlu
YW1pY0xvYWRMZW5UcmVlAQAqKEkpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8v
SHVmZm1hblRyZWVJbnQ7AQAIX19kaGNsZW4BAAtyYXdjb2RlbGVucwEABmhz
Yml0cwEAEV9fZGVjb21wcmVzc0ZpeGVkAQAQX19kZWNvbXByZXNzTm9uZQEA
B21pbmlzdWIBAANsZW4BAANjb20BABJfX2RlY29tcHJlc3NXaW5kb3cBAAUo
SUkpVgEABm1heGxlbgEABWlvb2JlAQAlTGphdmEvbGFuZy9JbmRleE91dE9m
Qm91bmRzRXhjZXB0aW9uOwEAAXYBAAVfX2xlbgEABl9fZGlzdAEABHdpbmIB
ABBfX2hhbmRsZURpc3RhbmNlAQAEKEkpSQEABl9fY29kZQEACWV4dHJhYml0
cwEADl9faGFuZGxlTGVuZ3RoAQADX19jAQATX19vYnRhaW5Db2RlTGVuVHJl
ZQEAKSgpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7
AQADcmVmAQAWTG9jYWxWYXJpYWJsZVR5cGVUYWJsZQcBlwEAFF9fb2J0YWlu
RGlzdGFuY2VUcmVlAQATX19vYnRhaW5MaXRlcmFsVHJlZQEAEl9fb2J0YWlu
UmVhZFdpbmRvdwEABCgpW0IBAApfX3JlYWRCaXRzAQAFKElaKUkBAAJiYwEA
BnJlYWRpbgEAAnJjAQADX19uAQAFX19tc2IBAAptaW5pd2luZG93AQAIbWlu
aXNpemUBAA5fX3JlYWRDb2RlQml0cwEALShMbmV0L211bHRpcGhhc2ljYXBw
cy9pby9IdWZmbWFuVHJlZUludDtbSUkpSQEACWxhc3RsZW5keAEABnJlcHZh
bAEABnJlcGZvcgEAB19fY29kZXMBAAVfX291dAEABl9fbmV4dAEACGJhc2Vu
ZXh0AQASX19yZWFkRml4ZWRIdWZmbWFuAQAVX190aHVua0NvZGVMZW5ndGhU
cmVlAQBUKExuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0h1ZmZtYW5UcmVlSW50
O1tJSUkpTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRyZWVJbnQ7
AQABcAEABGJpdHMBAAFxAQAGX190cmVlAQAGX19sZW5zAQAIYmxfY291bnQB
AAluZXh0X2NvZGUBAAdfX3dyaXRlAQAGKElJWilWAQABYgEAAUIBAAR0YXJn
AQAHdGFyZ29mZgEAB3RhcmdlbmQBAANfX3YBAAZfX2JpdHMBAARtYXNrAQAL
d3JpdGV3aW5kb3cBAAl3cml0ZXNpemUBAAg8Y2xpbml0PgEAClNvdXJjZUZp
bGUBABhJbmZsYXRlcklucHV0U3RyZWFtLmphdmEBACpuZXQvbXVsdGlwaGFz
aWNhcHBzL2lvL0luZmxhdGVySW5wdXRTdHJlYW0MAKEArAwAoQCuDAChALYB
ACBuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0J5dGVEZXF1ZQwAgACBDACEAIUM
AIYAhQEAOG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSW5mbGF0ZXJJbnB1dFN0
cmVhbSRfX0JpdFNvdXJjZV9fDAChAZgMAIcAiAwAiQB7DACKAHsMAIsAewwA
jAB7AQAeamF2YS9sYW5nL051bGxQb2ludGVyRXhjZXB0aW9uAQAETkFSRwwA
oQGZDAB8AH0BAChuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL1NsaWRpbmdCeXRl
V2luZG93DAChAZoMAH4AfwwAggCDDACzALQMALUAtgwAjQCODAC7AMABAChq
YXZhL2xhbmcvQXJyYXlJbmRleE91dE9mQm91bmRzRXhjZXB0aW9uAQAEQUlP
QgwBmwDADACcAJ0MAJ4AhQwAnwBuDACgAG4MAMoAtAwBnAGdDACPAI4MAZ4A
ugwBCAEJDADsALYMAOsAtgwAzgC2AQATamF2YS9pby9JT0V4Y2VwdGlvbgEA
B0JEMTUgJWQBABBqYXZhL2xhbmcvT2JqZWN0DAGfAaAHAaEMAaIBowwA5gDn
DAEFAQAMAQQBAAwA1wDYDAGkAaUMASQBJQwA/QD6DADwAPEBAAdCRDE2ICVk
DAERARIBACBqYXZhL3V0aWwvTm9TdWNoRWxlbWVudEV4Y2VwdGlvbgEABEJE
MTcMAKEBpgwBGwEcDAD/AQABAAdCRDE4ICVkDAB6AHsMARoAtAEAEWphdmEv
bGFuZy9JbnRlZ2VyAQAHQkQxOSAlZAwAmQBuAQAYQkQxYSAlMDR4ICUwNHgg
JTA0eCAlMDR4DAD5APoMAacBqAEAI2phdmEvbGFuZy9JbmRleE91dE9mQm91
bmRzRXhjZXB0aW9uAQAKQkQxYiAlZCAlZAEAB0JEMWMgJWQBAAdCRDFkICVk
DACQAJEMAacBqQEAJW5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSHVmZm1hblRy
ZWVJbnQBABtqYXZhL2xhbmcvcmVmL1dlYWtSZWZlcmVuY2UMAKEBqgwBqwC2
DACVAJEMAJQAkQwAlgCRDACYAG4BAApCRDFlICVkICVkDAGsAPoBAAdCRDFm
ICVkAQAHQkQxZyAlZAEABEJEMWgMAa0BrgwAmgBuDACbAG4MAa8BsAwBsQGy
AQAvbmV0L211bHRpcGhhc2ljYXBwcy9pby9EZWNvbXByZXNzaW9uSW5wdXRT
dHJlYW0BACxuZXQvbXVsdGlwaGFzaWNhcHBzL2lvL0luZmxhdGVySW5wdXRT
dHJlYW0kMQEAE2phdmEvaW8vSW5wdXRTdHJlYW0BAB9uZXQvbXVsdGlwaGFz
aWNhcHBzL2lvL0NoZWNrc3VtAQAXamF2YS9sYW5nL3JlZi9SZWZlcmVuY2UB
AF0oTG5ldC9tdWx0aXBoYXNpY2FwcHMvaW8vSW5mbGF0ZXJJbnB1dFN0cmVh
bTtMbmV0L211bHRpcGhhc2ljYXBwcy9pby9JbmZsYXRlcklucHV0U3RyZWFt
JDE7KVYBABUoTGphdmEvbGFuZy9TdHJpbmc7KVYBAAQoSSlWAQALcmVtb3Zl
Rmlyc3QBAAVvZmZlcgEAByhbQklJKVYBAAdpc0VtcHR5AQAHdmFsdWVPZgEA
FihJKUxqYXZhL2xhbmcvSW50ZWdlcjsBABBqYXZhL2xhbmcvU3RyaW5nAQAG
Zm9ybWF0AQA5KExqYXZhL2xhbmcvU3RyaW5nO1tMamF2YS9sYW5nL09iamVj
dDspTGphdmEvbGFuZy9TdHJpbmc7AQAIZ2V0VmFsdWUBACUoTG5ldC9tdWx0
aXBoYXNpY2FwcHMvaW8vQml0U291cmNlOylJAQAqKExqYXZhL2xhbmcvU3Ry
aW5nO0xqYXZhL2xhbmcvVGhyb3dhYmxlOylWAQADZ2V0AQAIKElbQklJKVYB
ABQoKUxqYXZhL2xhbmcvT2JqZWN0OwEAFShMamF2YS9sYW5nL09iamVjdDsp
VgEABWNsZWFyAQAHcmV2ZXJzZQEAA2FkZAEABihJSUkpSQEACW9mZmVyTGFz
dAEABChCKVoBAAZhcHBlbmQBAAQoQilWACEAAQBpAAAAIAAaAG0AbgABAG8A
AAACAAIAGABwAG4AAQBvAAAAAgBxABgAcgBuAAEAbwAAAAIAcwAYAHQAbgAB
AG8AAAACAHUAGAB2AG4AAQBvAAAAAgB3ABoAeABuAAEAbwAAAAIAeQAaAHoA
ewAAABQAfAB9AAAAFAB+AH8AAAAUAIAAgQAAABQAggCDAAAAEgCEAIUAAAAS
AIYAhQAAABIAhwCIAAAAEgCJAHsAAAASAIoAewAAABIAiwB7AAAAEgCMAHsA
AAACAI0AjgAAAAIAjwCOAAAAAgCQAJEAAQCSAAAAAgCTAAIAlACRAAEAkgAA
AAIAkwACAJUAkQABAJIAAAACAJMAAgCWAJEAAQCSAAAAAgCXAAIAmABuAAAA
AgCZAG4AAAACAJoAbgAAAAIAmwBuAAAAAgCcAJ0AAAACAJ4AhQAAAAIAnwBu
AAAAAgCgAG4AAAAfAAEAoQCiAAIAowAAAEAAAwACAAAACCorEgK3AAOxAAAA
AgCkAAAACgACAAAApwAHAKgApQAAABYAAgAAAAgApgCnAAAAAAAIAKgAfQAB
AKkAAAAEAAEAEgABAKEAqgACAKMAAABLAAQAAwAAAAkqKxICLLcABLEAAAAC
AKQAAAAKAAIAAAC2AAgAtwClAAAAIAADAAAACQCmAKcAAAAAAAkAqAB9AAEA
AAAJAKsAgwACAKkAAAAEAAEAEgABAKEArAABAKMAAABKAAQAAwAAAAgqKxwB
twAEsQAAAAIApAAAAAoAAgAAAMQABwDFAKUAAAAgAAMAAAAIAKYApwAAAAAA
CACoAH0AAQAAAAgArQBuAAIAAQChAK4AAQCjAAABCQAFAAQAAABwKrcABSq7
AAZZtwAHtQAIKgS8CLUACSoHvAi1AAoquwALWSoBtwAMtQANKhATvAq1AA4q
EQFCvAq1AA8qEBC8CrUAECoQELwKtQARK8cADbsAElkSE7cAFL8qK7UAFSq7
ABZZHLcAF7UAGCottQAZsQAAAAMApAAAAD4ADwAAANcABABGAA8ATQAWAFEA
HQBVACoAXAAyAGMAOwBnAEMAawBLANkATwDaAFkA3QBeAN4AagDfAG8A4ACl
AAAAKgAEAAAAcACmAKcAAAAAAHAAqAB9AAEAAABwAK0AbgACAAAAcACvAIMA
AwCwAAAAEwAB/wBZAAQHAAEHALEBBwCyAAAAAQCzALQAAgCjAAAAMgABAAEA
AAAIKrQACLYAGqwAAAACAKQAAAAGAAEAAADsAKUAAAAMAAEAAAAIAKYApwAA
AKkAAAAEAAEALgABALUAtgACAKMAAAA2AAEAAQAAAAgqtAAVtgAbsQAAAAIA
pAAAAAoAAgAAAPgABwD5AKUAAAAMAAEAAAAIAKYApwAAAKkAAAAEAAEALgAB
ALcAuAABAKMAAAAvAAIAAQAAAAUqtAAcrQAAAAIApAAAAAYAAQAAAQIApQAA
AAwAAQAAAAUApgCnAAAAAQC5ALoAAQCjAAAALAABAAEAAAACBKwAAAACAKQA
AAAGAAEAAAEMAKUAAAAMAAEAAAACAKYApwAAAAEAuwC0AAIAowAAAIsABAAD
AAAAIiq0AAlMKisDBLYAHT0cnAAFHKwcmgAGp//uKwMzEQD/fqwAAAADAKQA
AAAeAAcAAAEYAAUBGwANAR4AEQEfABMBIgAXASMAGgEnAKUAAAAgAAMADQAV
ALwAbgACAAAAIgCmAKcAAAAFAB0AvQCFAAEAsAAAAA0AA/wABQcAXPwADQEG
AKkAAAAEAAEALgABALsAvgACAKMAAAA9AAQAAgAAAAkqKwMrvrYAHawAAAAC
AKQAAAAGAAEAAAEzAKUAAAAWAAIAAAAJAKYApwAAAAAACQC/AIUAAQCpAAAA
BgACAC4AEgABALsAwAACAKMAAAIZAAUADAAAAOArxwANuwASWRITtwAUvyu+
NgQcmwAPHZsACxwdYBUEpAANuwAeWRIftwAgvyq0AAg6BRkFtgAaNgYVBh2i
AAgVBqcABB02BxkFKxwdtgAhNggqtAAiNgkVCZoARxUIHaIAQSortQAjFQgd
ogA2KhwVCGBZNgq1ACQqFQodFQhkYLUAJSq3ACY2CxULnAALKgS1ACKnAA0V
CBULYDYIp//KKrQAGToKGQrGAA4ZCiscFQi5ACcEABUIngAPKlm0ACgVCIVh
tQAoFQiaABQVCZkADxkFtgApmQAHAqcABRUIrAAAAAMApAAAAG4AGwAAAUAA
BAFBAA4BQgASAUMAIgFEACwBSAAyAUkAOQFKAEcBSwBRAU8AVwFQAGIBUwBn
AVYAbQFaAHgBWwCDAVwAiQFfAI4BYQCTAWIAlgFmAJ0BZwCgAWsApgFsAKsB
bQC2AXAAuwFxAMcBdgClAAAAhAANAHUAKADBAG4ACgCJABQAvABuAAsAAADg
AKYApwAAAAAA4AC/AIUAAQAAAOAAwgBuAAIAAADgAMMAbgADABIAzgDEAG4A
BAAyAK4AgACBAAUAOQCnAMUAbgAGAEcAmQDGAG4ABwBRAI8AxwBuAAgAVwCJ
AMgAnQAJAKYAOgCCAIMACgCwAAAAKQAMDvwAEwEJ/QAXBwAGAUAB/gAhAQEB
/QAuAQH5AAn8ABUHALIQFUEBAKkAAAAIAAMAHgAuABIAAQDJALgAAQCjAAAA
LwACAAEAAAAFKrQAKK0AAAACAKQAAAAGAAEAAAGAAKUAAAAMAAEAAAAFAKYA
pwAAAAIAygC0AAIAowAAATkABwAFAAAAiSq0ACKZAAUCrCq0ACQ8KgQDtgAq
PSoFA7YAKj4dqgAAAAAANAAAAAAAAAADAAAAHwAAACYAAAAtAAAANCq3ACun
ACkqtwAspwAiKrcALacAG7sALlkSLwS9ADBZAx24ADFTuAAytwAzvyq0ACQb
ZDYEHJkAFCoEtQAiFQSaAAcCpwAFFQSsFQSsAAAAAwCkAAAASgASAAABjwAH
AZAACQGTAA4BlgAVAZkAHAGaADwBngBAAZ8AQwGjAEcBpABKAagATgGpAFEB
sABpAbUAcQG2AHUBuAB6AbkAhgG+AKUAAAA0AAUAAACJAKYApwAAAA4AewDL
AG4AAQAVAHQAzABuAAIAHABtAM0AbgADAHEAGAC8AG4ABACwAAAAFAAJCf4A
MgEBAQYGBhf8ABkBQQEAAKkAAAAEAAEALgACAM4AtgACAKMAAAGGAAcACAAA
AKsqCAO2ACoRAQFgPCoIA7YAKgRgPSoHA7YAKgdgPiodtwA0OgQqtwA1OgUq
twA2OgYqGQQbHBkFGQa3ADcZBSq0AA22ADg2BxUHmwAXFQcRAP+jAA8qFQcQ
CAO3ADmnAEsVBxEBAKAABLEVBxEBAaEAIRUHEQEdowAZKioVB7cAOhkGKrQA
DbYAOLcAO6cAHLsALlkSPAS9ADBZAxUHuAAxU7gAMrcAM7+n/5QAAAADAKQA
AABKABIAAAHLAAsBzAAUAc0AHQHQACQB0wAqAdQAMAHVADwB3ABHAd8AVAHg
AGAB4wBoAeQAaQHnAHkB6ACGAekAiQHoAI8B7gCoAe8ApQAAAFIACABHAGEA
zwBuAAcAAACrAKYApwAAAAsAoADQAG4AAQAUAJcA0QBuAAIAHQCOANIAbgAD
ACQAhwDTANQABAAqAIEA1QDUAAUAMAB7ANYA1AAGALAAAAAhAAX/ADwABwcA
AQEBAQcAVAcAVAcAVAAA/AAjAQgl+gAYAKkAAAAEAAEALgACANcA2AACAKMA
AAFrAAUACgAAAGkcHWA2Biq0AA86BwM2CBkHvjYJFQgVCaIADxkHFQgDT4QI
Aaf/8AM2CBUIFQaiABQVCCorGQcVCLcAPWA2CKf/66cAEToIuwAuWRI/GQi3
AEC/KhkEGQcDHLcAQVcqGQUZBxwdtwBBV7EAAQAmAEEARAA+AAMApAAAADYA
DQAAAgMABQIGAAsCBwAaAggAIAIHACYCDQAwAg4AQQIXAEQCFABGAhYAUgIa
AF0CGwBoAhwApQAAAHoADAAOABgA2QBuAAgAEwATANoAbgAJACkAGADbAG4A
CABGAAwA3ADdAAgAAABpAKYApwAAAAAAaQDeANQAAQAAAGkA3wBuAAIAAABp
AOAAbgADAAAAaQDhANQABAAAAGkA4gDUAAUABQBkAOMAbgAGAAsAXgDkAHsA
BwCwAAAALAAG/wATAAoHAAEHAFQBAQcAVAcAVAEHAOUBAQAA+QAS/AACAfoA
F0IHAD4NAKkAAAAEAAEALgACAOYA5wACAKMAAAErAAcABgAAAGwqtwBCTRsQ
E6QAG7sALlkSQwS9ADBZAxu4ADFTuAAytwAzvyq0AA5OAzYELb42BRUEFQWi
AA4tFQQDT4QEAaf/8bIARDoEAzYFFQUbogAWLRkEFQUuKgYDtgAqT4QFAaf/
6iosLQMtvrcAQbAAAAADAKQAAAAyAAwAAAIpAAUCLQALAi4AIwIzACgCNAA2
AjUAOwI0AEECOQBGAjoATwI7AFwCOgBiAj4ApQAAAFIACAArABYA2QBuAAQA
LwASANoAbgAFAEkAGQDbAG4ABQAAAGwApgCnAAAAAABsAOgAbgABAAUAZwDT
ANQAAgAoAEQA6QB7AAMARgAmAOoAewAEALAAAAAdAAX8ACMHAFT+AAsHAOUB
AfkAEf0ABwcA5QH6ABgAqQAAAAQAAQAuAAIA6wC2AAIAowAAAMAABwACAAAA
Wiq3AEU8G5sAFRsRAP+jAA4qGxAIA7cAOacAPxsRAQCgAASxGxEBAaEAGBsR
AR2jABEqKhu3ADoSR7cAO6cAG7sALlkSSAS9ADBZAxu4ADFTuAAytwAzv6f/
qQAAAAMApAAAACYACQAAAlAABQJTABACVAAbAlcAIgJYACMCWwAxAlwAPwJh
AFcCYgClAAAAFgACAAUAUgDPAG4AAQAAAFoApgCnAAAAsAAAAAwABQD8ABoB
Bxv6ABcAqQAAAAQAAQAuAAIA7AC2AAIAowAAARYACAAFAAAAfCq0AEkQB348
G54ACiobA7YAKlcqEBADtgAqPSoQEAO2ACo+HBJKgh2fADa7AC5ZEksHvQAw
WQMcuAAxU1kEHbgAMVNZBRwSSoK4ADFTWQYdEkqCuAAxU7gAMrcAM78DNgQV
BByiABcqKhAIA7YAKhAIA7cAOYQEAaf/6bEAAAADAKQAAAA2AA0AAAJwAAgC
cQAMAnIAEwJ1ABsCdgAjAnwAKwJ9ADgCfgBXAn0AXgKBAGcCggB1AoEAewKD
AKUAAAA0AAUAYQAaANkAbgAEAAAAfACmAKcAAAAIAHQA7QBuAAEAGwBhAO4A
bgACACMAWQDvAG4AAwCwAAAAEgAE/AATAf0ASgEB/AACAfoAGQCpAAAABAAB
AC4AAgDwAPEAAgCjAAABYAAHAAcAAAB0Khy3AEw9HBuiAAgcPqcABRs+HbwI
OgQqtAAYHBkEAx22AE2nACY6BbsALlkSTwW9ADBZAxy4ADFTWQQbuAAxU7gA
MhkFtwBAvwM2BQM2BhUFG6IAISoZBBUGMxAIA7cAOYQGARUGHaEABgM2BoQF
Aaf/37EAAQAXACMAJgBOAAMApAAAAEYAEQAAApEABgKWAAsClwAQApkAEgKc
ABcCnwAjAqkAJgKjACgCpwA1AqgAQAKnAEkCrQBVArAAYQKzAGoCtABtAq0A
cwK2AKUAAABcAAkADQADAPIAbgADACgAIQDzAPQABQBMACcA2QBuAAUATwAk
APUAbgAGAAAAdACmAKcAAAAAAHQA9gBuAAEAAAB0APcAbgACABIAYgDyAG4A
AwAXAF0A+ACFAAQAsAAAACQABxD8AAEB/wATAAUHAAEBAQEHAFwAAQcATiL9
AAUBAR35AAUAqQAAAAQAAQAuAAIA+QD6AAIAowAAARkABwAFAAAAaBsSR6AA
CioIBLYAKjwbEB2kABu7AC5ZElAEvQAwWQMbuAAxU7gAMrcAM78EPQM+HRui
ACIdBWwEZDYEFQSbAA0cBBUEeGA9pwAGhAIBhAMBp//fGwVsBGQ+HZ4ADBwq
HQO2ACpgPRysAAAAAwCkAAAAPgAPAAACxAAGAsUADQLJABMCygArAs0ALQLO
ADQC0gA7AtMAQALUAEoC1gBNAs4AUwLbAFkC3ABdAt0AZgLgAKUAAAA+AAYA
OwASAPUAbgAEAC8AJADZAG4AAwAAAGgApgCnAAAAAABoAPsAbgABAC0AOwC8
AG4AAgBZAA8A/ABuAAMAsAAAABcABw0d/QADAQH8ABoB+gAC+gAF/AASAQCp
AAAABAABAC4AAgD9APoAAgCjAAABNQAHAAYAAABzGxEBHaAABxEBAqwbEQEB
ZD0cnAAbuwAuWRJRBL0AMFkDG7gAMVO4ADK3ADO/Bj4DNgQVBByiACMVBAds
BGQ2BRUFngANHQQVBXhgPqcABoQDAYQEAaf/3RwHbARkNgQVBJ4AEB0qFQQD
tgAqWTYEYD4drAAAAAMApAAAAEIAEAAAAu4ABwLvAAsC8gARAvUAFQL2AC0C
+QAvAvoAOAL/AEADAABFAwEATwMDAFIC+gBYAwcAXwMIAGQDCQBxAwwApQAA
AEgABwBAABIA9QBuAAUAMgAmANkAbgAEAAAAcwCmAKcAAAAAAHMA/gBuAAEA
EQBiAMEAbgACAC8ARAC8AG4AAwBfABQA/ABuAAQAsAAAABoABwv8ACEB/QAE
AQH8ABwB+gAC+gAF/AAYAQCpAAAABAABAC4AAgD/AQAAAQCjAAAArgAFAAMA
AAAwKrQAUkwrxgAQASu2AFPAAFRZTaYAFyq7AFVZuwBUWbcAVllNtwBXtQBS
LLYAWCywAAAABACkAAAAFgAFAAADFwAFAxoAFgMbACoDHwAuAyAApQAAACoA
BAATAAMAvADUAAIAAAAwAKYApwAAAAUAKwEBAJEAAQAkAAwAvADUAAIBAgAA
AAwAAQAFACsBAQCTAAEAsAAAAA4AAvwAFgcBA/wAEwcAVAACAQQBAAABAKMA
AACuAAUAAwAAADAqtABZTCvGABABK7YAU8AAVFlNpgAXKrsAVVm7AFRZtwBW
WU23AFe1AFkstgBYLLAAAAAEAKQAAAAWAAUAAAMrAAUDLgAWAy8AKgMzAC4D
NAClAAAAKgAEABMAAwC8ANQAAgAAADAApgCnAAAABQArAQEAkQABACQADAC8
ANQAAgECAAAADAABAAUAKwEBAJMAAQCwAAAADgAC/AAWBwED/AATBwBUAAIB
BQEAAAEAowAAAK4ABQADAAAAMCq0AFpMK8YAEAErtgBTwABUWU2mABcquwBV
WbsAVFm3AFZZTbcAV7UAWiy2AFgssAAAAAQApAAAABYABQAAAz8ABQNCABYD
QwAqA0cALgNIAKUAAAAqAAQAEwADALwA1AACAAAAMACmAKcAAAAFACsBAQCR
AAEAJAAMALwA1AACAQIAAAAMAAEABQArAQEAkwABALAAAAAOAAL8ABYHAQP8
ABMHAFQAAgEGAQcAAQCjAAAApAAFAAMAAAAqKrQAW0wrxgAQASu2AFPAAFxZ
TaYAFSq7AFVZEQCAvAhZTbcAV7UAWyywAAAABACkAAAAEgAEAAADUwAFA1YA
FgNXACgDWgClAAAAKgAEABMAAwC8AIUAAgAAACoApgCnAAAABQAlAQEAkQAB
ACIACAC8AIUAAgECAAAADAABAAUAJQEBAJcAAQCwAAAADgAC/AAWBwED/AAR
BwBcAAABCAEJAAIAowAAAdkABwAJAAAAwhuaAAUDrCq0AF0+KrQASTYEFQQb
ogB+GxUEZBAIbDYFFQWaAAYENgUqtAAKOgYqtAAVGQYDFQW2AF42BxUHnAAj
uwAuWRJfBb0AMFkDFQS4ADFTWQQbuAAxU7gAMrcAM78DNggVCBUHogAbHRkG
FQgzEQD/fhUEeIA+hAQIhAgBp//kKlm0ABwVB4VhtQAcp/+CHQQbeARkfjYF
HRt8PhUEG2Q2BCodtQBdKhUEtQBJHJkADhUFuABgECAbZHysFQWsAAAAAwCk
AAAAcgAcAAADagAEA2sABgNuAAsDbwARA3IAFwN1ACADdgAlA3cAKAN6AC4D
ewA8A38AQQOAAFYDgQBaA4AAYQOEAGsDhgB6A4cAfQOEAIMDiwCPA4wAkgOP
AJsDlACfA5UApQOYAKoDmQCwA6AAtAOhAL8DpAClAAAAZgAKAGQAHwDZAG4A
CAAgAG8BCgBuAAUALgBhAQsAhQAGADwAUwEMAG4ABwAAAMIApgCnAAAAAADC
AQ0AbgABAAAAwgEOAJ0AAgALALcBDwBuAAMAEQCxARAAbgAEAJsAJwC8AG4A
BQCwAAAAIQAIBv0ACgEB/AAWAf0AOAcAXAH8AAIB+gAe+AAO/AAsAQCpAAAA
BAABAC4AAgERARIAAgCjAAACWQAHAAkAAADqK8YAByzHAA27ABJZEhO3ABS/
HTYEKyq0AA22ADg2BRUFmwAVFQUQEKIADiwdhAMBFQVPpwCyFQUQEKAAOR0E
ZDYIFQicABy7AC5ZEmEEvQAwWQMVCLgAMVO4ADK3ADO/LBUILjYGBioFA7YA
KmA2B6cATBUFEBGgABMDNgYGKgYDtgAqYDYHpwA1FQUQEqAAFQM2BhALKhAH
A7YAKmA2B6cAHLsALlkSYgS9ADBZAxUFuAAxU7gAMrcAM78DNggVCBUHogAR
LB2EAwEVBk+ECAGn/+6nABE6CLsALlkSYxkItwBAvx0VBGSsAAEAvADUANcA
TgADAKQAAAB2AB0AAAO4AAgDuQASA7wAFQO9AB8DwAArA8EANgPLAD0DzwBC
A9AARwPRAFUD0gBZA9EAYAPVAGYD2ABwA9kAcwPcAHoD3wB9A+IAigPmAJED
6QCUA+wAowPxALwD9wDGA/gAzgP3ANQEAADXA/wA2QP/AOUEBAClAAAArAAR
AEIALgETAG4ACABmAA0BFABuAAYAcAADARUAbgAHAH0ADQEUAG4ABgCHAAMB
FQBuAAcAlAAPARQAbgAGAKAAAwEVAG4ABwC/ABUA2QBuAAgA2QAMAPMA9AAI
ALwAKQEUAG4ABgC8ACkBFQBuAAcAAADqAKYApwAAAAAA6gEWANQAAQAAAOoB
FwB7AAIAAADqARgAbgADABUA1QEZAG4ABAAfAMsAzwBuAAUAsAAAACcADAgJ
/QAjAQH+ACkAAAH4ABIWGP0AGAEB/AACAfoAFEIHAE75AA0AqQAAAAYAAgAu
ABIAAgEaALQAAgCjAAABJAAEAAEAAACqKgQEtgAqmQBfKgQEtgAqmQBLKgQE
tgAqmQAPEQDAKhAGBLYAKmCsKgQEtgAqmQAOEQCgKggEtgAqYKwqBAS2ACqZ
AA4RAJAqBwS2ACpgrBEBGCoGBLYAKmCsEFAqEAYEtgAqYKwqBAS2ACqZAA4Q
ECoQBgS2ACpgrCoEBLYAKpkAICoEBLYAKpkADAMqBwS2ACpgrBEBECoGBLYA
KmCsEQEAKgcEtgAqYKwAAAADAKQAAABGABEAAAQXAAkEGAASBBkAGwQaACcE
HAAwBB0AOwQfAEQEIABPBCIAWgQkAGUEJgBuBCcAeQQpAIIEKgCLBCsAlAQt
AJ8ELwClAAAADAABAAAAqgCmAKcAAACwAAAACgAIJxMTCgoTGgoAqQAAAAQA
AQAuAAIBGwEcAAIAowAAAiIABwALAAAAxyzHAA27ABJZEhO3ABS/KrQAEDoF
KrQAEToGAzYHGQW+NggVBxUIogAVGQUVBwNPGQYVBwNPhAcBp//qAzYHHTYI
FQcVBKIAFxkFLBUILlwuBGBPhAcBhAgBp//oGQUDA08DNgcENggVCBAPowAe
FQcZBRUIBGQuYAR4NgcZBhUIFQdPhAgBp//hK7YAWAM2CB02CRUIFQSiAC4s
FQkuNgoVCpkAGisVCBkGFQpcLlsEYE8EFQp4BGS2AGRXhAgBhAkBp//RK7AA
AAADAKQAAABiABgAAAREAAQERQAOBEgAFARJABoESgApBEwALwRNADUESgA7
BFEASARSAFMEUQBcBFMAYQRXAGQEWABuBFoAfARbAIMEWACJBF8AjQRgAJoE
YwCgBGYApQRnALwEYADFBGsApQAAAKIAEAAdAB4A2QBuAAcAIgAZANoAbgAI
AD4AHgDZAG4ABwBBABsBHQBuAAgAZwAiAR4AbgAIAKAAHADuAG4ACgCQADUB
HwBuAAgAkwAyAR0AbgAJAAAAxwCmAKcAAAAAAMcBIADUAAEAAADHASEAewAC
AAAAxwDCAG4AAwAAAMcAwwBuAAQAFACzASIAewAFABoArQEjAHsABgBkAGMA
zwBuAAcAsAAAADkACg7/ABMACQcAAQcAVAcA5QEBBwDlBwDlAQEAAPkAGP0A
BQEB+QAa/QAKAQH6ACH9AAkBASj5AAgAqQAAAAQAAQASAAIBJAElAAIAowAA
AesAAwANAAAAqQQceARkNgQbFQR+PB2ZAA0buABgECAcZHw8KrQAZTYFKrQA
ZjYGFQUbFQR+FQZ4gDYFFQYcYDYGFQYQCKEAYCq0ACM6Byq0ACQ2CCq0ACU2
CSq0AAg6Ciq0ABg6CxUFkTYMFQUQCHw2BYQG+BUIFQmiABAZBxUIhAgBFQxU
pwALGQoVDLYAZ1cZCxUMtgBoFQYQCKL/yioVCLUAJCoVBbUAZSoVBrUAZrEA
AAADAKQAAABqABoAAAR7AAcEfgAMBH8AEASAABoEgwAgBIQAJgSHADIEiAA4
BIsAPwSOAEUEjwBLBJAAUQSTAFcElgBdBJwAYgSdAGkEngBsBKEAcwSiAIAE
pgCIBKkAjwSqAJYErQCcBLEAogSyAKgEswClAAAAhAANAGIALQEmAScADABF
AFcBKACFAAcASwBRASkAbgAIAFEASwEqAG4ACQBXAEUAgACBAAoAXQA/AH4A
fwALAAAAqQCmAKcAAAAAAKkBKwBuAAEAAACpASwAbgACAAAAqQEOAJ0AAwAH
AKIBLQBuAAQAIACJAS4AbgAFACYAgwEvAG4ABgCwAAAANgAF/AAaAf8AQgAM
BwABAQEBAQEBBwBcAQEHAAYHABYAAPwAIgEH/wATAAcHAAEBAQEBAQEAAACp
AAAABAABAC4ACAEwALYAAQCjAAAAhgAEAAAAAABuEBO8ClkDEBBPWQQQEU9Z
BRAST1kGA09ZBxAIT1kIEAdPWRAGEAlPWRAHEAZPWRAIEApPWRAJCE9ZEAoQ
C09ZEAsHT1kQDBAMT1kQDQZPWRAOEA1PWRAPBU9ZEBAQDk9ZEBEET1kQEhAP
T7MARLEAAAABAKQAAAAGAAEAAAA5AAIBMQAAAAIBMgBrAAAAEgACAGoAAAAA
EAgACwABAGwAEg==
====

Deleted runt/libs/tool-classfile.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/libs/tool-classfile.test/TestClassLoad.in.

1
2


-
-
result: NoResult
thrown: NoExceptionThrown

Deleted runt/libs/tool-classfile.test/TestClassLoad.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that classes load properly.
 *
 * @since 2019/03/10
 */
public class TestClassLoad
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x))
			{
				ClassFile.decode(in);
			}
	}
}

Deleted runt/libs/tool-classfile.test/TestMinimizedLoad.in.

1
2


-
-
result: NoResult
thrown: NoExceptionThrown

Deleted runt/libs/tool-classfile.test/TestMinimizedLoad.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.Minimizer;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that minimizing is performed properly and loading minimized classes
 * works as well.
 *
 * @since 2019/03/10
 */
public class TestMinimizedLoad
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x))
			{
				Minimizer.minimize(ClassFile.decode(in));
			}
	}
}

Deleted runt/libs/tool-classfile.test/TestMinimizer.in.

1
2


-
-
result: NoResult
thrown: NoExceptionThrown

Deleted runt/libs/tool-classfile.test/TestMinimizer.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.Minimizer;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests that minimizing is performed properly.
 *
 * @since 2019/03/10
 */
public class TestMinimizer
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2019/03/10
	 */
	@Override
	public void test()
		throws Throwable
	{
		for (String x : new String[]{"ByteDeque.data",
			"InflaterInputStream.data"})
			try (InputStream in = TestClassLoad.class.getResourceAsStream(x);
				ByteArrayOutputStream out = new ByteArrayOutputStream())
			{
				Minimizer.minimize(ClassFile.decode(in), out);
			}
	}
}

Deleted runt/libs/tool-classfile/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 8d3e10bc-91f3-411d-a89e-db7397afab58
X-SquirrelJME-Error: JC
X-SquirrelJME-Name: Class File Reader
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains support for reading class files.
X-SquirrelJME-Depends: collections io
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/DualPoolEncodeResult.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This contains the result of an encoded dual-pool.
 *
 * @since 2019/07/17
 */
public final class DualPoolEncodeResult
{
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the result of the dual-encoder.
	 *
	 * @param __spo The static pool offset.
	 * @param __spz The static pool size.
	 * @param __rpo The run-time pool offset.
	 * @param __rpz The run-time pool size.
	 * @since 2019/07/17
	 */
	public DualPoolEncodeResult(int __spo, int __spz, int __rpo, int __rpz)
	{
		this.staticpooloff = __spo;
		this.staticpoolsize = __spz;
		this.runtimepooloff = __rpo;
		this.runtimepoolsize = __rpz;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/DualPoolEncoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
















































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.NotedString;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
 * @since 2019/07/17
 */
public final class DualPoolEncoder
{
	/** The size of the table entries. */
	public static final int TABLE_ENTRY_SIZE =
		8;
	
	/**
	 * Not used.
	 *
	 * @since 2019/07/17
	 */
	private DualPoolEncoder()
	{
	}
	
	/**
	 * Decodes the specified pool.
	 *
	 * @param __b The input byte array.
	 * @param __co The class pool offset.
	 * @param __cl The class pool length.
	 * @param __ro The run-time pool offset.
	 * @param __rl The run-time pool length.
	 * @return The resulting dual pool.
	 * @throws InvalidClassFormatException If the pool is not valid.
	 * @throws IOException If the pool could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final DualClassRuntimePool decode(byte[] __b,
		int __co, int __cl, int __ro, int __rl)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// The resulting pool
		BasicPool classpool = null,
			runpool = null;
			
		// Read of both pools
		for (boolean isruntime = false;; isruntime = true)
		{
			// The base offset and length used, used to read entry data
			int baseoff = (isruntime ? __ro : __co);
			
			// Which stream to read main entries from?
			DataInputStream dis = new DataInputStream(
				new ByteArrayInputStream(__b, baseoff,
					(isruntime ? __rl : __cl)));
			
			// Read the entry count (first null entry), ignore padding
			dis.readByte();
			dis.readByte();
			dis.readShort();
			int poolsize = dis.readInt();
			
			// Target entries
			List<BasicPoolEntry> entries = new ArrayList<>(poolsize);
			
			// Initialize null entry
			entries.add(new BasicPoolEntry(0, null, new int[0]));
			
			// Read in every entry
			for (int i = 1; i < poolsize; i++)
			{
				// Read entry properties
				int tag = dis.readByte() & 0xFF,
					numparts = dis.readByte(),
					elen = dis.readUnsignedShort(),
					eoff = dis.readInt();
				
				// Read type information
				MinimizedPoolEntryType etype;
				try
				{
					etype = MinimizedPoolEntryType.of(tag);
				}
				catch (IllegalArgumentException e)
				{
					// {@squirreljme.error JC4i Invalid constant pool entry.}
					throw new InvalidClassFormatException("JC4i", e);
				}
				
				// {@squirreljme.error JC4j The specified type cannot be within
				// the current pool section. (The type; If this is the run-time
				// pool)}
				if (etype.isRuntime() != isruntime)
					throw new InvalidClassFormatException("JC4j " + etype +
						" " + isruntime);
				
				// Get reader for the entry data
				DataInputStream xd = new DataInputStream(
					new ByteArrayInputStream(__b, baseoff + eoff, elen));
				
				// Is this wide?
				boolean iswide = (numparts < 0);
				if (iswide)
					numparts = -numparts;
				
				// Resulting parts and value
				Object value;
				int[] parts = new int[numparts];
				
				// Depends on the type
				switch (etype)
				{
						// String
					case STRING:
						// Read hash code and length
						parts[0] = xd.readUnsignedShort();
						parts[1] = xd.readUnsignedShort();
						
						// Decode actual string
						value = xd.readUTF();
						break;
						
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_INFO_POINTER:
					case CLASS_NAME:
					case CLASS_NAMES:
					case CLASS_POOL:
					case INTEGER:
					case FLOAT:
					case LONG:
					case DOUBLE:
					case INVOKED_METHOD:
					case METHOD_DESCRIPTOR:
					case METHOD_INDEX:
					case NOTED_STRING:
					case USED_STRING:
						// Read parts
						if (iswide)
							for (int p = 0; p < numparts; p++)
								parts[p] = xd.readUnsignedShort();
						else
							for (int p = 0; p < numparts; p++)
								parts[p] = xd.readByte() & 0xFF;
						
						// Build value depending on the parts used
						switch (etype)
						{
								// Name of class, has extra meta-data
							case CLASS_NAME:
								value = new ClassName(entries.get(parts[0]).
									<String>value(String.class));
								break;
							
								// A list of class names
							case CLASS_NAMES:
								ClassName[] cnn = new ClassName[numparts];
								
								for (int j = 0; j < numparts; j++)
									cnn[j] = entries.get(parts[j]).
										<ClassName>value(ClassName.class);
								
								value = new ClassNames(cnn);
								break;
								
								// Raw integer value
							case INTEGER:
								value = ((parts[0] & 0xFFFF) << 16) |
									(parts[1] & 0xFFFF);
								break;
								
								// Raw float value
							case FLOAT:
								value = Float.intBitsToFloat(
									((parts[0] & 0xFFFF) << 16) |
									(parts[1] & 0xFFFF));
								break;
								
								// Raw long value
							case LONG:
								value = (((long)(((parts[0] & 0xFFFF) << 16) |
									((parts[1] & 0xFFFF))) &
										0xFFFFFFFFL) << 32L) |
									((long)(((parts[2] & 0xFFFF) << 16) |
									((parts[3] & 0xFFFF))) & 0xFFFFFFFFL);
								break;
								
								// Raw double value
							case DOUBLE:
								value = Double.longBitsToDouble(
									(((long)(((parts[0] & 0xFFFF) << 16) |
									((parts[1] & 0xFFFF))) &
										0xFFFFFFFFL) << 32L) |
									((long)(((parts[2] & 0xFFFF) << 16) |
									((parts[3] & 0xFFFF))) & 0xFFFFFFFFL));
								break;
								
								// Method descriptor, has extra meta-data
							case METHOD_DESCRIPTOR:
								value = new MethodDescriptor(
									entries.get(parts[0]).
									<String>value(String.class));
								break;
								
								// A field which has been accessed
							case ACCESSED_FIELD:
								value = new AccessedField(
									FieldAccessTime.of(parts[0]),
									FieldAccessType.of(parts[1]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[2]),
									classpool.<String>byIndex(
										String.class, parts[3]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[4]).field());
								break;
							
								// Class information point
							case CLASS_INFO_POINTER:
								value = new ClassInfoPointer(
									classpool.byIndex(parts[0]).
									<ClassName>value(ClassName.class));
								break;
								
								// Class run-time pool reference
							case CLASS_POOL:
								value = new ClassPool(
									classpool.byIndex(parts[0]).
									<ClassName>value(ClassName.class));
								break;
								
								// A method which has been invoked
							case INVOKED_METHOD:
								value = new InvokedMethod(
									InvokeType.of(parts[0]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[1]),
									classpool.<String>byIndex(String.class,
										parts[2]),
									classpool.<MethodDescriptor>byIndex(
										MethodDescriptor.class, parts[3]));
								break;
								
								// Method index in vtable
							case METHOD_INDEX:
								value = new MethodIndex(
									classpool.<ClassName>byIndex(
										ClassName.class, parts[1]),
									classpool.<String>byIndex(
										String.class, parts[2]),
									classpool.<MethodDescriptor>byIndex(
										MethodDescriptor.class, parts[3]));
								break;
								
								// Noted string
							case NOTED_STRING:
								value = new NotedString(
									classpool.byIndex(parts[0]).
									<String>value(String.class));
								break;
								
								// Used string
							case USED_STRING:
								value = new UsedString(
									classpool.byIndex(parts[0]).
									<String>value(String.class));
								break;
								
								// Unknown
							default:
								throw new todo.OOPS(etype.name());
						}
						break;
						
						// Unknown
					default:
						throw new todo.OOPS(etype.name());
				}
				
				// Record entry
				entries.add(new BasicPoolEntry(i, value, parts, eoff));
			}
			
			// Build pool
			BasicPool result = new BasicPool(entries);
			
			// Store pool in the right spot
			if (isruntime)
				runpool = result;
			else
				classpool = result;
			
			// Stop processing after the run-time is done
			if (isruntime)
				break;
		}
		
		// Finalize pool
		return new DualClassRuntimePool(classpool, runpool);
	}
	
	/**
	 * Encodes the dual pool to the given output stream and returns the
	 * result.
	 *
	 * @param __dp The dual-pool to encode.
	 * @param __out The stream to write to.
	 * @return The result with size information.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final DualPoolEncodeResult encode(
		DualClassRuntimePoolBuilder __dp, OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__dp == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Table sections are used for output
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Build sections for output
		TableSectionOutputStream.Section clssection = output.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		TableSectionOutputStream.Section runsection = output.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		
		// Write both of the pools
		for (boolean isruntime = false;; isruntime = true)
		{
			// Sub output which writes to the section
			TableSectionOutputStream sub = new TableSectionOutputStream();
			
			// Section containing the table of contents
			TableSectionOutputStream.Section toc = sub.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Are we encoding the static or run-time pool?
			BasicPoolBuilder pool = (isruntime ? __dp.runtimePool() :
				__dp.classPool());
			
			// The size of the pool, used for the first entry
			int poolsize = pool.size();
			
			// Write individual pool entries
			for (BasicPoolEntry e : pool)
			{
				// The first is always null and just contains some pool
				// information
				Object ev = e.value;
				if (e.index == 0)
				{
					// No tag, no parts, no size, entry count (offset)
					toc.write(0);
					toc.write(0);
					toc.writeShort(0);
					toc.writeInt(poolsize);
					
					// Skip
					continue;
				}
				
				// Determine the type of entry this is
				MinimizedPoolEntryType et =
					MinimizedPoolEntryType.ofClass(ev.getClass());
				
				// {@squirreljme.error JC4d Cannot store the given entry
				// because it not compatible with the static/run-time
				// state. (The pool type; The value type; Is the run-time
				// pool being processed?)}
				if (isruntime != et.isRuntime())
					throw new IllegalStateException("JC4d " +
						et + " " + ev + " " + isruntime);
				
				// Determine if the parts need to be wide
				short[] ep = e.parts();
				int epn = ep.length;
				boolean iswide = false;
				for (int j = 0; j < epn; j++)
				{
					int v = ep[j];
					if (v < 0 || v > 127)
						iswide = true;
				}
				
				// Encode the data into a section somewhere in this
				// sub-section
				TableSectionOutputStream.Section data = sub.addSection(
					TableSectionOutputStream.VARIABLE_SIZE, 4);
				data.write(DualPoolEncoder.encodeValue(et, ep, iswide, ev));
				
				// Write pool table entry
				toc.writeByte(et.ordinal());
				toc.writeByte((iswide ? -epn : epn));
				toc.writeSectionSizeShort(data);
				toc.writeSectionAddressInt(data);
			}
			
			// Write entire sub-section data to the target
			sub.writeTo((isruntime ? runsection : clssection));
			
			// Stop processing after the run-time is done
			if (isruntime)
				break;
		}
		
		// Write to the target stream
		output.writeTo(__out);
		
		// Return the location of the data, note that the addresses and
		// sizes would have been realized already
		return new DualPoolEncodeResult(
			output.sectionAddress(clssection), output.sectionSize(clssection),
			output.sectionAddress(runsection), output.sectionSize(runsection));
	}
	
	/**
	 * Encodes a layered pool from one class to another.
	 *
	 * @param __src The source pool.
	 * @param __onto The pool to layer on top of.
	 * @param __out The stream to write to.
	 * @return The result of the encoded pool data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public static final DualPoolEncodeResult encodeLayered(
		DualClassRuntimePoolBuilder __src, DualClassRuntimePoolBuilder __onto,
		OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__src == null || __onto == null || __out == null)
			throw new NullPointerException("NARG");
		
		// The resulting table
		TableSectionOutputStream table = new TableSectionOutputStream();
		
		// Process static entries
		TableSectionOutputStream.Section sl = table.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (BasicPoolEntry e : __src.classPool())
		{
			if (e.index == 0)
				sl.writeInt(__src.classPool().size());
			else
				sl.writeInt(__onto.add(false, e.value).index);
		}
		
		// Process run-time entries
		TableSectionOutputStream.Section rl = table.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (BasicPoolEntry e : __src.runtimePool())
		{
			if (e.index == 0)
				rl.writeInt(__src.runtimePool().size());
			else
				rl.writeInt(__onto.add(true, e.value).index);
		}
		
		// Write the encoded pool
		table.writeTo(__out);
		
		// Return the positions of everything
		return new DualPoolEncodeResult(
			table.sectionAddress(sl), -table.sectionSize(sl),
			table.sectionAddress(rl), -table.sectionSize(rl));
	}
	
	/**
	 * Encodes the pool value.
	 *
	 * @param __t The type to encode.
	 * @param __p The parts.
	 * @param __wide Are the parts wide?
	 * @param __v The value.
	 * @return The encoded value data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/20
	 */
	public static final byte[] encodeValue(MinimizedPoolEntryType __t,
		short[] __p, boolean __wide, Object __v)
		throws IOException, NullPointerException
	{
		if (__t == null || __p == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Output for this data
		TableSectionOutputStream output = new TableSectionOutputStream();
		TableSectionOutputStream.Section dos = output.addSection();
		
		// Depends on the type
		switch (__t)
		{
				// Encode strings into the pool
			case STRING:
				{
					// Record hashCode and the String size as simple
					// fields to read. Note that even though there is
					// the UTF length, the length of the actual string
					// could be useful. But only keep the lowest part
					// as that will be "good enough"
					dos.writeShort((short)__p[0]);
					dos.writeUnsignedShortChecked(__p[1]);
					
					// Write string UTF data
					dos.writeUTF((String)__v);
					
					// Write NUL terminator so it can be directly used
					// as a UTF-8 C pointer
					dos.writeByte(0);
				}
				break;
				
				// Everything else just consists of parts which are
				// either values to other indexes or an ordinal
			case ACCESSED_FIELD:
			case CLASS_INFO_POINTER:
			case CLASS_NAME:
			case CLASS_NAMES:
			case CLASS_POOL:
			case INTEGER:
			case FLOAT:
			case DOUBLE:
			case LONG:
			case INVOKED_METHOD:
			case METHOD_DESCRIPTOR:
			case METHOD_INDEX:
			case NOTED_STRING:
			case USED_STRING:
				if (__wide)
					for (int i = 0, n = __p.length; i < n; i++)
						dos.writeShortChecked(__p[i]);
				else
					for (int i = 0, n = __p.length; i < n; i++)
						dos.writeByte(__p[i]);
				break;
			
			default:
				throw new todo.OOPS(__t.name());
		}
		
		return output.toByteArray();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedClassFile.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassFlags;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This contains the minimized class file which is a smaller format of the
 * {@link net.multiphasicapps.classfile.ClassFile} that is more optimized to
 * virtual machines for usage.
 *
 * @since 2019/03/10
 */
public final class MinimizedClassFile
{
	/** Header. */
	public final MinimizedClassHeader header;
	
	/** Pool. */
	public final DualClassRuntimePool pool;
	
	/** Static fields. */
	private final MinimizedField[] _sfields;
	
	/** Instance fields. */
	private final MinimizedField[] _ifields;
	
	/** Static methods. */
	private final MinimizedMethod[] _smethods;
	
	/** Instance methods. */
	private final MinimizedMethod[] _imethods;
	
	/** Class flags. */
	private Reference<ClassFlags> _flags;
	
	/**
	 * Initializes the minimized class file.
	 *
	 * @param __h The header.
	 * @param __p The pool.
	 * @param __sf Static fields.
	 * @param __if Instance fields.
	 * @param __sm Static methods.
	 * @param __im Instance methods.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public MinimizedClassFile(MinimizedClassHeader __h,
		DualClassRuntimePool __p,
		MinimizedField[] __sf, MinimizedField[] __if,
		MinimizedMethod[] __sm, MinimizedMethod[] __im)
		throws NullPointerException
	{
		if (__h == null || __p == null || __sf == null || __if == null ||
			__sm == null || __im == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.header = __h;
		this.pool = __p;
		this._sfields = (__sf = __sf.clone());
		this._ifields = (__if = __if.clone());
		this._smethods = (__sm = __sm.clone());
		this._imethods = (__im = __im.clone());
		
		// Check for nulls
		for (Object[] va : new Object[][]{__sf, __if, __sm, __im})
			for (Object v : va)
				if (v == null)
					throw new NullPointerException("NARG");
	}
	
	/**
	 * Searches for a field by the given name and type.
	 *
	 * @param __is Search for static field?
	 * @param __n The name.
	 * @param __t The type.
	 * @return The field or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedField field(boolean __is, FieldName __n,
		FieldDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		return this.field(__is, new FieldNameAndType(__n, __t));
	}
	
	/**
	 * Searches for a field by the given name and type.
	 *
	 * @param __is Search for static field?
	 * @param __nat The name and type.
	 * @return The field or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedField field(boolean __is, FieldNameAndType __nat)
		throws NullPointerException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedField mf : (__is ? this._sfields : this._ifields))
			if (mf.name.equals(__nat.name()) && mf.type.equals(__nat.type()))
				return mf;
		
		return null;
	}
	
	/**
	 * Returns the fields in the class.
	 *
	 * @param __is If true then static fields are returned.
	 * @return The fields.
	 * @since 2019/04/17
	 */
	public final MinimizedField[] fields(boolean __is)
	{
		return (__is ? this._sfields.clone() : this._ifields.clone());
	}
	
	/**
	 * The class flags.
	 *
	 * @return The class flags.
	 * @since 2019/04/17
	 */
	public final ClassFlags flags()
	{
		Reference<ClassFlags> ref = this._flags;
		ClassFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new ClassFlags(this.header.classflags)));
		
		return rv;
	}
	
	/**
	 * Returns the names of all the interfaces.
	 *
	 * @return The interface names.
	 * @since 2019/04/17
	 */
	public final ClassNames interfaceNames()
	{
		int idx = this.header.classints;
		if (idx == 0)
			return new ClassNames();
		return this.pool.getByIndex(false, idx).
			<ClassNames>value(ClassNames.class);
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __n The name.
	 * @param __t The type, if {@code null} the type is ignored.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Static first, then instance methods
		MinimizedMethod rv = this.method(true, __n, __t);
		return (rv == null ? this.method(false, __n, __t) : rv);
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __is Search for static method?
	 * @param __n The name.
	 * @param __t The type, if {@code null} the type is ignored.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(boolean __is, MethodName __n,
		MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedMethod mm : (__is ? this._smethods : this._imethods))
			if (mm.name.equals(__n) && (__t == null || mm.type.equals(__t)))
				return mm;
		
		// Not found
		return null;
	}
	
	/**
	 * Searches for a method by the given name and type.
	 *
	 * @param __is Search for static method?
	 * @param __nat The name and type.
	 * @return The method or {@code null} if not found.
	 * @since 2019/04/22
	 */
	public final MinimizedMethod method(boolean __is, MethodNameAndType __nat)
		throws NullPointerException
	{
		if (__nat == null)
			throw new NullPointerException("NARG");
		
		for (MinimizedMethod mm : (__is ? this._smethods : this._imethods))
			if (mm.name.equals(__nat.name()) && mm.type.equals(__nat.type()))
				return mm;
		
		return null;
	}
	
	/**
	 * Returns the methods in the class.
	 *
	 * @param __is If true then static methods are returned.
	 * @return The methods.
	 * @since 2019/04/17
	 */
	public final MinimizedMethod[] methods(boolean __is)
	{
		return (__is ? this._smethods.clone() : this._imethods.clone());
	}
	
	/**
	 * Returns the minimized constant pool.
	 *
	 * @return The minimized constant pool.
	 * @since 2019/04/17
	 */
	public final DualClassRuntimePool pool()
	{
		return this.pool;
	}
	
	/**
	 * Returns the super name of the current class.
	 *
	 * @return The class super name or {@code null} if there is none.
	 * @since 2019/04/17
	 */
	public final ClassName superName()
	{
		int sdx = this.header.classsuper;
		if (sdx == 0)
			return null;
		return this.pool.getByIndex(false, sdx).
			<ClassName>value(ClassName.class);
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The name of the current class.
	 * @since 2019/04/17
	 */
	public final ClassName thisName()
	{
		return this.pool.getByIndex(false, this.header.classname).
			<ClassName>value(ClassName.class);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The stream to decode from.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final MinimizedClassFile decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return MinimizedClassFile.decode(__is, null);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The stream to decode from.
	 * @param __ppool The parent pool, may be {@code null}.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final MinimizedClassFile decode(InputStream __is,
		DualClassRuntimePool __ppool)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Initialize byte array with guess to how many bytes can be read
		byte[] mcdata;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(
			Math.min(1048576, __is.available())))
		{
			// Read the entire header for the class
			for (int i = 0; i < MinimizedClassHeader.HEADER_SIZE_WITH_MAGIC;
				i++)
				baos.write(__is.read());
			
			// Read the data size to determine how much to read
			byte[] xhead = baos.toByteArray();
			int datasize = ((xhead[92] & 0xFF) << 24) |
				((xhead[93] & 0xFF) << 16) |
				((xhead[94] & 0xFF) << 8) |
				((xhead[95] & 0xFF));
			
			// Read all the data size bytes
			byte[] buf = new byte[512];
			for (int left = datasize; left > 0;)
			{
				int rc = __is.read(buf, 0, (512 < left ? 512 : left));
				
				// EOF?
				if (rc < 0)
					break;
				
				baos.write(buf, 0, rc);
				left -= rc;
			}
			
			// Finish off
			mcdata = baos.toByteArray();
		}
		
		// Decode now
		return MinimizedClassFile.decode(mcdata, __ppool);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The bytes to decode from.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public static final MinimizedClassFile decode(byte[] __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return MinimizedClassFile.decode(__is, null);
	}
	
	/**
	 * Decodes and returns the minimized representation of the class file.
	 *
	 * @param __is The bytes to decode from.
	 * @param __ppool The parent pool, may be {@code null}.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedClassFile decode(byte[] __is,
		DualClassRuntimePool __ppool)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Reading could fail
		try
		{
			// Read class header
			MinimizedClassHeader header = MinimizedClassHeader.decode(
				new ByteArrayInputStream(__is));
			
			// {@squirreljme.error JC01 Length of class file does not match
			// length of array. (The file length; The array length)}
			int fsz = header.filesize;
			if (fsz != __is.length)
				throw new InvalidClassFormatException("JC01 " + fsz +
					" " + __is.length);
			
			// {@squirreljme.error JC02 End of file magic number is invalid.
			// (The read magic number)}
			int endmagic;
			if (MinimizedClassHeader.END_MAGIC_NUMBER !=
				(endmagic = (((__is[fsz - 4] & 0xFF) << 24) |
				((__is[fsz - 3] & 0xFF) << 16) |
				((__is[fsz - 2] & 0xFF) << 8) |
				(__is[fsz - 1] & 0xFF))))
				throw new InvalidClassFormatException(
					String.format("JC02 %08x", endmagic));
			
			// Virtual constant pool which relies on a parent one
			DualClassRuntimePool pool;
			if (header.staticpoolsize < 0 || header.runtimepoolsize < 0)
			{
				// {@squirreljme.error JC4h No parent pool was specified.}
				if (__ppool == null)
					throw new NullPointerException("JC4h");
				
				throw new todo.TODO();
			}
			
			// Decode physical pool within the class
			else
			{
				pool = DualPoolEncoder.decode(__is,
					header.staticpooloff, header.staticpoolsize,
					header.runtimepooloff, header.runtimepoolsize);
			}
			
			// Read static and instance fields
			MinimizedField[] sfields = MinimizedField.decodeFields(
					header.sfcount, pool, __is, header.sfoff, header.sfsize),
				ifields = MinimizedField.decodeFields(
					header.ifcount, pool, __is, header.ifoff, header.ifsize);
			
			// Read static and instance methods
			MinimizedMethod[] smethods = MinimizedMethod.decodeMethods(
					header.smcount, pool, __is, header.smoff, header.smsize),
				imethods = MinimizedMethod.decodeMethods(
					header.imcount, pool, __is, header.imoff, header.imsize);
			
			// Build final class
			return new MinimizedClassFile(header, pool,
				sfields, ifields, smethods, imethods);
		}
		
		// {@squirreljme.error JC03 End of file reached before parsing the
		// file.}
		catch (EOFException e)
		{
			throw new InvalidClassFormatException("JC03", e); 
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedClassHeader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323



































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents the raw minimized header of a class.
 *
 * @since 2019/04/16
 */
public final class MinimizedClassHeader
{
	/** The magic number for the header. */
	public static final int MAGIC_NUMBER =
		0x00586572;
	
	/** Magic number for the end of file. */
	public static final int END_MAGIC_NUMBER =
		0x42796521;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		108;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		HEADER_SIZE_WITHOUT_MAGIC + 4;
	
	/** Unused A. */
	public final int unuseda;
	
	/** The index of the method which is __start. */
	public final int startmethodindex;
	
	/** The data type of the class. */
	public final DataType datatype;
	
	/** Not used. */
	public final int unusedb;
	
	/** Class flags. */
	public final int classflags;
	
	/** Name of class. */
	public final int classname;
	
	/** Super class name. */
	public final int classsuper;
	
	/** Interfaces in class. */
	public final int classints;
	
	/** Class type. */
	public final int classtype;
	
	/** Class version. */
	public final int classvers;
	
	/** Class source filename. */
	public final int classsfn;
	
	/** Static field count. */
	public final int sfcount;
	
	/** Static field bytes. */
	public final int sfbytes;
	
	/** Static field objects. */
	public final int sfobjs;
	
	/** Instance field count. */
	public final int ifcount;
	
	/** Instance field bytes. */
	public final int ifbytes;
	
	/** Instance field objects. */
	public final int ifobjs;
	
	/** Static method count. */
	public final int smcount;
	
	/** Instance method count. */
	public final int imcount;
	
	/** Not used. */
	public final int unusedc;
	
	/** Not used. */
	public final int unusedd;
	
	/** Static field data offset. */
	public final int sfoff;
	
	/** Static field data size. */
	public final int sfsize;
	
	/** Instance field data offset. */
	public final int ifoff;
	
	/** Instance field data size. */
	public final int ifsize;
	
	/** Static method data offset. */
	public final int smoff;
	
	/** Static method data size. */
	public final int smsize;
	
	/** Instance method data offset. */
	public final int imoff;
	
	/** Instance method data size. */
	public final int imsize;
	
	/** High bits for UUID. */
	public final int uuidhi;
	
	/** Low bits for UUID. */
	public final int uuidlo;
	
	/** File size. */
	public final int filesize;
	
	/** Not used. */
	public final int unusede;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the class header.
	 *
	 * @param __vx The raw values.
	 * @since 2019/04/16
	 */
	public MinimizedClassHeader(int... __vx)
	{
		int at = 0;
		
		// Unused
		this.unuseda = __vx[at++];
		
		// Start method index
		this.startmethodindex = __vx[at++];
		
		// Data Type
		this.datatype = DataType.of(__vx[at++]);
		
		// Constant pool
		this.unusedb = __vx[at++];
		
		// Class information
		this.classflags = __vx[at++];
		this.classname = __vx[at++];
		this.classsuper = __vx[at++];
		this.classints = __vx[at++];
		this.classtype = __vx[at++];
		this.classvers = __vx[at++];
		this.classsfn = __vx[at++];

		// Static and instance fields
		this.sfcount = __vx[at++];
		this.sfbytes = __vx[at++];
		this.sfobjs = __vx[at++];
		this.ifcount = __vx[at++];
		this.ifbytes = __vx[at++];
		this.ifobjs = __vx[at++];

		// Static and instance methods
		this.smcount = __vx[at++];
		this.imcount = __vx[at++];

		// Not used
		this.unusedc = __vx[at++];
		this.unusedd = __vx[at++];
		
		// Static and instance field data
		this.sfoff = __vx[at++];
		this.sfsize = __vx[at++];
		this.ifoff = __vx[at++];
		this.ifsize = __vx[at++];
			
		// Static and instance method data
		this.smoff = __vx[at++];
		this.smsize = __vx[at++];
		this.imoff = __vx[at++];
		this.imsize = __vx[at++];
		
		// UUID
		this.uuidhi = __vx[at++];
		this.uuidlo = __vx[at++];
			
		// File size
		this.filesize = __vx[at++];
		
		// Not used
		this.unusede = __vx[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __vx[at++];
		this.staticpoolsize = __vx[at++];
		this.runtimepooloff = __vx[at++];
		this.runtimepoolsize = __vx[at++];
	}
	
	/**
	 * Decodes the minimized class header.
	 *
	 * @param __is The bytes to decode from.
	 * @return The resulting minimized class header.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedClassHeader decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		DataInputStream dis = new DataInputStream(__is);
		
		// {@squirreljme.error JC04 Invalid minimized class magic number.
		// (The magic number)}
		int readmagic;
		if (MAGIC_NUMBER != (readmagic = dis.readInt()))
			throw new InvalidClassFormatException(String.format("JC04 %08x",
				readmagic));
		
		// Read in all the data
		return new MinimizedClassHeader(
			// Unused
			/* unuseda */ dis.readUnsignedShort(),
			
			// Start method index
			/* startmethodindex */ dis.readUnsignedByte(),
			
			// Data Type
			/* datatype */ dis.readUnsignedByte(),
			
			// Not used
			/* NOT USED */ dis.readUnsignedShort(),
			
			// Class header
			/* classflags */ dis.readInt(),
			/* classname */ dis.readUnsignedShort(),
			/* classsuper */ dis.readUnsignedShort(),
			/* classints */ dis.readUnsignedShort(),
			/* classtype */ dis.readUnsignedByte(),
			/* classvers */ dis.readUnsignedByte(),
			/* classsfn */ dis.readUnsignedShort(),
	
			// Static and instance fields
			/* sfcount */ dis.readUnsignedShort(),
			/* sfbytes */ dis.readUnsignedShort(),
			/* sfobjs */ dis.readUnsignedShort(),
			/* ifcount */ dis.readUnsignedShort(),
			/* ifbytes */ dis.readUnsignedShort(),
			/* ifobjs */ dis.readUnsignedShort(),
	
			// Static and instance methods
			/* smcount */ dis.readUnsignedShort(),
			/* imcount */ dis.readUnsignedShort(),
	
			// Not used
			/* NOT USED */ dis.readInt(),
			/* NOT USED */ dis.readInt(),
		
			// Static and instance field data
			/* sfoff */ dis.readInt(),
			/* sfbytes */ dis.readInt(),
			/* ifoff */ dis.readInt(),
			/* ifbytes */ dis.readInt(),
			
			// Static and instance method data
			/* smoff */ dis.readInt(),
			/* smbytes */ dis.readInt(),
			/* imoff */ dis.readInt(),
			/* imbytes */ dis.readInt(),
			
			// UUID
			/* uuidhi */ dis.readInt(),
			/* uuidlo */ dis.readInt(),
			
			// File size
			/* filesize */ dis.readInt(),
			
			// Not used
			/* NOT USED */ dis.readInt(),
			
			// Static and runtime pool
			/* staticpooloff */ dis.readInt(),
			/* staticpoolsize */ dis.readInt(),
			/* runtimepooloff */ dis.readInt(),
			/* runtimepoolsize */ dis.readInt());
	}	
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedField.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldNameAndType;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents a field which has been minimized.
 *
 * @since 2019/03/11
 */
public final class MinimizedField
{
	/** The flags for this field. */
	public final int flags;
	
	/** Offset to the field data. */
	public final int offset;
	
	/** The size of this field. */
	public final int size;
	
	/** The field name. */
	public final FieldName name;
	
	/** The field type. */
	public final FieldDescriptor type;
	
	/** The field value. */
	public final Object value;
	
	/** The data type. */
	public final DataType datatype;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Field flags. */
	private Reference<FieldFlags> _flags;
	
	/** Name and type. */
	private Reference<FieldNameAndType> _nat;
	
	/**
	 * Initializes the minimized field.
	 *
	 * @param __f The field flags.
	 * @param __o The offset.
	 * @param __s The size.
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @param __v The value of this field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/11
	 */
	public MinimizedField(int __f, int __o, int __s, FieldName __n,
		FieldDescriptor __t, Object __v)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.flags = __f;
		this.offset = __o;
		this.size = __s;
		this.name = __n;
		this.type = __t;
		this.value = __v;
		this.datatype = DataType.of(__t);
	}
	
	/**
	 * Returns the flags for this field.
	 *
	 * @return The flags for the field.
	 * @since 2019/04/18
	 */
	public final FieldFlags flags()
	{
		Reference<FieldFlags> ref = this._flags;
		FieldFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new FieldFlags(this.flags)));
		
		return rv;
	}
	
	/**
	 * Returns the name and type for this field.
	 *
	 * @return The name and type for this field.
	 * @since 2019/09/21
	 */
	public final FieldNameAndType nameAndType()
	{
		Reference<FieldNameAndType> ref = this._nat;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new FieldNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Field %s:%s @ %d (%d bytes), flags=%x, value=%s", this.name,
				this.type, this.offset, this.size, this.flags, this.value)));
		
		return rv;
	}
	
	/**
	 * Decodes the field data.
	 *
	 * @param __n The number of fields.
	 * @param __p The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded fields.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the fields could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedField[] decodeFields(int __n,
		DualClassRuntimePool __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedField[] rv = new MinimizedField[__n];
		
		// Read field data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				rv[i] = new MinimizedField(
					dis.readInt(),
					dis.readUnsignedShort(),
					dis.readUnsignedShort(),
					new FieldName(__p.getByIndex(false,
						dis.readUnsignedShort()).<String>value(String.class)),
					__p.getByIndex(false, dis.readUnsignedShort()).
						<ClassName>value(ClassName.class).field(),
					__p.getByIndex(false, dis.readUnsignedShort()).value);
				
				// Data type and padding, the data type here is determined by
				// the field so we do not need to use this pre-calculated
				// value
				dis.readUnsignedByte();
				dis.readUnsignedByte();
			}
		}
		
		// {@squirreljme.error JC05 Could not read field data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC05");
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedMethod.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * This represents a method which has been mimized.
 *
 * @since 2019/03/14
 */
public final class MinimizedMethod
{
	/** The size of encoded entries. */
	public static final int ENCODE_ENTRY_SIZE =
		20;
	
	/** Flags that are used for the method. */
	public final int flags;
	
	/** The index of this method in the instance table. */
	public final int index;
	
	/** The name of the method. */
	public final MethodName name;
	
	/** The type of the method. */
	public final MethodDescriptor type;
	
	/** The code offset. */
	public final int codeoffset;
	
	/** Translated method code. */
	final byte[] _code;
	
	/** Method flags. */
	private Reference<MethodFlags> _flags;
	
	/** Name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the minimized method.
	 *
	 * @param __f The method flags.
	 * @param __o Index in the method table for instances.
	 * @param __n The method name.
	 * @param __t The method type.
	 * @param __tc Transcoded instructions.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/21
	 */
	public MinimizedMethod(int __f, int __o,
		MethodName __n, MethodDescriptor __t, byte[] __tc)
		throws NullPointerException
	{
		this(__f, __o, __n, __t, __tc, 0);
	}
	
	/**
	 * Initializes the minimized method.
	 *
	 * @param __f The method flags.
	 * @param __o Index in the method table for instances.
	 * @param __n The method name.
	 * @param __t The method type.
	 * @param __tc Transcoded instructions.
	 * @param __co The code offset.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/14
	 */
	public MinimizedMethod(int __f, int __o,
		MethodName __n, MethodDescriptor __t, byte[] __tc, int __co)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.flags = __f;
		this.index = __o;
		this.name = __n;
		this.type = __t;
		this._code = (__tc == null ? new byte[0] : __tc.clone());
		this.codeoffset = __co;
	}
	
	/**
	 * Returns the method code.
	 *
	 * @return The method code.
	 * @since 2019/04/19
	 */
	public final byte[] code()
	{
		return this._code.clone();
	}
	
	/**
	 * Returns the flags for this method.
	 *
	 * @return The flags for the method.
	 * @since 2019/04/17
	 */
	public final MethodFlags flags()
	{
		Reference<MethodFlags> ref = this._flags;
		MethodFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._flags = new WeakReference<>((rv =
				new MethodFlags(this.flags)));
		
		return rv;
	}
	
	/**
	 * Returns the name and type for this method.
	 *
	 * @return The name and type for this method.
	 * @since 2019/05/26
	 */
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new MethodNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/24
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s:%s{flags=%x, dx=%d, co=%d}",
				this.name, this.type, this.flags, this.index,
				this.codeoffset)));
		
		return rv;
	}
	
	/**
	 * Decodes the method data.
	 *
	 * @param __n The number of methods.
	 * @param __p The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded methods.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the methods could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedMethod[] decodeMethods(int __n,
		DualClassRuntimePool __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedMethod[] rv = new MinimizedMethod[__n];
		
		// Read method data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				// Read in method information
				int flags = dis.readInt(),
					offset = dis.readUnsignedShort();
				MethodName name = new MethodName(
					__p.getByIndex(false, dis.readUnsignedShort()).
						<String>value(String.class));
				MethodDescriptor type =
					__p.getByIndex(false, dis.readUnsignedShort()).
						<MethodDescriptor>value(MethodDescriptor.class);
				int offcode = dis.readInt(), 
					lencode = dis.readInt();
				
				// Unused padding
				dis.readShort();
				
				// Read code?
				byte[] code = null;
				if (offcode > 0)
				{
					code = new byte[lencode];
					System.arraycopy(__b, __o + offcode, code, 0, lencode);
				}
				
				// Build method
				rv[i] = new MinimizedMethod(flags, offset, name, type,
					code, offcode);
			}
		}
		
		// {@squirreljme.error JC06 Could not read method data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC06");
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPool.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486






































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;

/**
 * This represents the minimized constant pool.
 *
 * @since 2019/04/16
 */
@Deprecated
public final class MinimizedPool
{
	/** Pool value offsets. */
	private final int[] _offsets;
	
	/** Entry types. */
	private final byte[] _types;
	
	/** Parts. */
	private final int[][] _parts;
	
	/** Values. */
	final Object[] _values;
	
	/**
	 * Initializes the minimized pool.
	 *
	 * @param __os Offsets to the individual pool entries.
	 * @param __ts Types.
	 * @param __ps Parts.
	 * @param __vs Values.
	 * @throws IllegalArgumentException If the arrays are of a different size.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public MinimizedPool(int[] __os, byte[] __ts, int[][] __ps, Object[] __vs)
		throws IllegalArgumentException, NullPointerException
	{
		if (__os == null || __ts == null || __ps == null || __vs == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC07  Input arrays are of a different length.
		// (The expected length)}
		int n = __ts.length;
		if (__os.length != n || __ps.length != n || __vs.length != n)
			throw new IllegalArgumentException("JC07 " + n);
		
		// Defensive copy each
		__os = __os.clone();
		__ts = __ts.clone();
		__ps = __ps.clone();
		__vs = __vs.clone();
		
		// Clone all elements in the parts
		for (int i = 0; i < n; i++)
		{
			int[] p = __ps[i];
			
			if (p == null)
				throw new NullPointerException("NARG");
			
			__ps[i] = p.clone();
		}
		
		// Check values for null, skip entry 0
		for (int i = 1; i < n; i++)
			if (__vs[i] == null)
				throw new NullPointerException("NARG");
		
		// Set
		this._offsets = __os;
		this._types = __ts;
		this._parts = __ps;
		this._values = __vs;
	}
	
	/**
	 * Gets the specified pool entry.
	 *
	 * @param __i The entry to get.
	 * @since 2019/04/17
	 */
	public final Object get(int __i)
	{
		return this._values[__i];
	}
	
	/**
	 * Gets the specified pool entry.
	 *
	 * @param <V> The type to get.
	 * @param __i The index of the entry.
	 * @param __cl The type to get.
	 * @return The pool entry value.
	 * @throws ClassCastException If the class is not compatible.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public final <V> V get(int __i, Class<V> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._values[__i]);
	}
	
	/**
	 * Returns the offset to the value of the entry within the pool.
	 *
	 * @param __i The index.
	 * @return The offset.
	 * @since 2019/05/01
	 */
	public final int offset(int __i)
	{
		return this._offsets[__i];
	}
	
	/**
	 * Returns the part at the given index.
	 *
	 * @param __i The pool entry to get.
	 * @param __p The part index.
	 * @return The part for this index.
	 * @since 2019/04/22
	 */
	public final int part(int __i, int __p)
	{
		return this._parts[__i][__p];
	}
	
	/**
	 * Returns the number of used parts.
	 *
	 * @param __i The index.
	 * @return The number of used parts.
	 * @since 2019/04/27
	 */
	public final int partCount(int __i)
	{
		return this._parts[__i].length;
	}
	
	/**
	 * Returns all of the available parts.
	 *
	 * @param __i The index.
	 * @return The parts for this index.
	 * @since 2019/04/30
	 */
	public final int[] parts(int __i)
	{
		return this._parts[__i].clone();
	}
	
	/**
	 * Returns the number of entries in the pool.
	 *
	 * @return The number of pool entries.
	 * @since 2019/04/17
	 */
	public final int size()
	{
		return this._types.length;
	}
	
	/**
	 * Returns the constant pool type.
	 *
	 * @param __i The index of the entry.
	 * @return The pool type.
	 * @since 2019/04/17
	 */
	public final MinimizedPoolEntryType type(int __i)
	{
		return MinimizedPoolEntryType.of(this._types[__i]);
	}
	
	/**
	 * Decodes the minimized constant pool.
	 *
	 * @param __n Number of entries in the pool.
	 * @param __is The bytes to decode from.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @return The resulting minimized pool.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	@Deprecated
	public static final MinimizedPool decode(int __n, byte[] __is, int __o,
		int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __is.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Types and offsets
		byte[] types = new byte[__n];
		int[] offsets = new int[__n];
		
		// Read the type and offset table
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__is, __o, __l)))
		{
			// Read type table
			for (int i = 0; i < __n; i++)
				types[i] = dis.readByte();
			
			// {@squirreljme.error JC08 First pool entry type is not zero.
			// (The type that was read)}
			if (types[0] != 0)
				throw new InvalidClassFormatException("JC08 " + types[0]);
			
			// {@squirreljme.error JC09 Pool uneven padding byte was not
			// 255. (The value it was; The following byte)}
			if ((__n & 1) != 0)
			{
				int val;
				if ((val = dis.readUnsignedByte()) != 0xFF)
					throw new InvalidClassFormatException("JC09 " + val + " " +
						dis.read());
			}
			
			// Read offsets into the structure
			for (int i = 0; i < __n; i++)
				offsets[i] = dis.readUnsignedShort();
		}
		
		// {@squirreljme.error JC0a Invalid read of pool data.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC0a", e);
		}
		
		// Output pool entry types, values, and parts
		int[][] parts = new int[__n][];
		Object[] values = new Object[__n];
		
		// Zero int for empty parts
		int[] nopart = new int[0];
		
		// Re-build individual pool entries
		Object[] entries = new Object[__n];
		for (int i = 0; i < __n; i++)
		{
			// Get type and pointer
			int rtype = types[i],
				ptr = offsets[i];
			
			// Is this wide?
			boolean iswide;
			if ((iswide = ((rtype & 0x80) != 0)))
			{
				rtype &= 0x7F;
				
				// Re-adjust type array since we use this for the type list
				types[i] = (byte)rtype;
			}
			
			// Read info
			int[] part = null;
			Object v = null;
			
			// It is easier to handle this as a stream of bytes
			try (DataInputStream dis = new DataInputStream(
				new ByteArrayInputStream(__is, __o + ptr, __l - ptr)))
			{
				// Depends on the type
				MinimizedPoolEntryType type = MinimizedPoolEntryType.of(rtype);
				switch (type)
				{
						// Null is nothing, so do not bother
					case NULL:
						// {@squirreljme.error JC0b NULL pool entry is only
						// permitted as the first type, the class file is
						// corrupt.}
						if (i != 0)
							throw new InvalidClassFormatException("JC0b");
						break;
						
						// Strings
					case STRING:
						part = new int[]{
								dis.readUnsignedShort(),
								dis.readUnsignedShort(),
							};
						v = dis.readUTF();
						break;
						
						// Integer
					case INTEGER:
						v = dis.readInt();
						break;
						
						// Float
					case FLOAT:
						v = Float.intBitsToFloat(dis.readInt());
						break;
						
						// Types which consist of parts
					case CLASS_NAME:
					case CLASS_NAMES:
					case CLASS_POOL:
					case ACCESSED_FIELD:
					case INVOKED_METHOD:
					case METHOD_DESCRIPTOR:
					case LONG:
					case DOUBLE:
					case USED_STRING:
					case METHOD_INDEX:
						// Wide parts
						if (iswide)
						{
							// Read length
							int np = dis.readUnsignedShort();
							
							// Read values
							part = new int[np];
							for (int j = 0; j < np; j++)
								part[j] = dis.readUnsignedShort();
						}
						
						// Narrow parts
						else
						{
							// Read length
							int np = dis.readUnsignedByte();
							
							// Read values
							part = new int[np];
							for (int j = 0; j < np; j++)
								part[j] = dis.readUnsignedByte();
						}
						
						// Now that the parts were read, we can build the
						// actual value
						switch (type)
						{
								// Class name
							case CLASS_NAME:
								v = new ClassName((String)values[part[0]]);
								break;
								
								// Names of classes
							case CLASS_NAMES:
								{
									// Number of class names
									int ncn = part.length;
									
									// Read class names
									ClassName[] names = new ClassName[ncn];
									for (int j = 0; j < ncn; j++)
										names[j] = (ClassName)values[part[j]];
									
									// Build names
									v = new ClassNames(names);
								}
								break;
							
								// The constant pool of a class
							case CLASS_POOL:
								v = new ClassPool((ClassName)values[part[0]]);
								break;
								
								// Field which was accessed
							case ACCESSED_FIELD:
								v = new AccessedField(
									FieldAccessTime.of(part[0]),
									FieldAccessType.of(part[1]),
									new FieldReference(
										(ClassName)values[part[2]],
										new FieldName((String)values[part[3]]),
										((ClassName)values[part[4]]).field()));
								break;
								
								// Invoked method
							case INVOKED_METHOD:
								v = new InvokedMethod(
									InvokeType.of(part[0]),
									new MethodHandle(
										(ClassName)values[part[1]],
										new MethodName(
											(String)values[part[2]]),
										(MethodDescriptor)values[part[3]]));
								break;
							
								// Method descriptor
							case METHOD_DESCRIPTOR:
								v = new MethodDescriptor(
									(String)values[part[0]]);
								break;
								
								// The method index
							case METHOD_INDEX:
								v = new MethodIndex(
									(ClassName)values[part[1]],
									new MethodName((String)values[part[2]]),
									(MethodDescriptor)values[part[3]]);
								break;
								
								// Long
							case LONG:
								v = (((long)(((Integer)values[part[0]])
										<< 32L)) |
									(((long)(((Integer)values[part[1]]) &
										0xFFFFFFFFL))));
								break;
								
								// Double
							case DOUBLE:
								v = Double.longBitsToDouble(
									(((long)(((Integer)values[part[0]])
										<< 32L)) |
									(((long)(((Integer)values[part[1]]) &
										0xFFFFFFFFL)))));
								break;
								
								// Used string
							case USED_STRING:
								v = new UsedString((String)values[part[0]]);
								break;
								
							default:
								throw new todo.OOPS(type.name());
						}
						break;
					
					default:
						throw new todo.OOPS(type.name());
				}
			}
			
			// {@squirreljme.error JC0c Invalid read of pool data.}
			catch (IllegalArgumentException|IOException e)
			{
				throw new InvalidClassFormatException("JC0c", e);
			}
			
			// Set data
			parts[i] = (part == null ? nopart : part);
			values[i] = v;
		}
		
		// Build
		return new MinimizedPool(offsets, types, parts, values);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPoolBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487







































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.collections.IntegerList;
import net.multiphasicapps.collections.UnmodifiableList;

/**
 * This class is used to build the constant pool for a minimized class.
 *
 * @since 2019/03/11
 */
@Deprecated
public final class MinimizedPoolBuilder
{
	/** Constant pool. */
	private final Map<Object, Integer> _pool =
		new LinkedHashMap<>();
	
	/** Parts list. */
	private final List<int[]> _parts =
		new ArrayList<>();
	
	/**
	 * Initializes the base pool.
	 *
	 * @since 2019/04/14
	 */
	{
		// Add null entry to mean nothing
		this._pool.put(null, 0);
		this._parts.add(new int[0]);
	}
	
	/**
	 * Adds the constant pool entry and returns the index to it.
	 *
	 * @param __v The entry to add.
	 * @return The index the entry is at.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public final int add(Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Field access
		if (__v instanceof AccessedField)
		{
			AccessedField af = (AccessedField)__v;
			FieldReference fr = af.field();
			return this.__add(__v,
				af.time().ordinal(),
				af.type().ordinal(),
				this.add(fr.className()),
				this.add(fr.memberName().toString()),
				this.add(fr.memberType().className()));
		}
		
		// Class name
		else if (__v instanceof ClassName)
		{
			// Write representation of array type and its component type to
			// make sure they are always added
			ClassName cn = (ClassName)__v;
			if (cn.isArray())
				return this.__add(__v,
					this.add(__v.toString()), this.add(cn.componentType()));
			
			// Not an array
			else
				return this.__add(__v,
					this.add(__v.toString()), 0);
		}
		
		// Class names
		else if (__v instanceof ClassNames)
		{
			// Adjust the value to map correctly
			ClassNames names = (ClassNames)__v;
			
			// Fill into indexes
			int n = names.size();
			int[] indexes = new int[n];
			for (int i = 0; i < n; i++)
				indexes[i] = this.add(names.get(i));
			
			// Add it now
			return this.__add(names, indexes);
		}
		
		// Record handle for the method
		else if (__v instanceof InvokedMethod)
		{
			InvokedMethod iv = (InvokedMethod)__v;
			MethodHandle mh = iv.handle();
			
			return this.__add(__v,
				iv.type().ordinal(),
				this.add(mh.outerClass()),
				this.add(mh.name().toString()),
				this.add(mh.descriptor()));
		}
		
		// Method descriptor, add parts of the descriptor naturally
		else if (__v instanceof MethodDescriptor)
		{
			MethodDescriptor md = (MethodDescriptor)__v;
			
			// Setup with initial string
			List<Integer> sub = new ArrayList<>();
			sub.add(this.add(__v.toString()));
			
			// Put in argument count
			FieldDescriptor[] args = md.arguments();
			sub.add(args.length);
			
			// Add return value
			FieldDescriptor rv = md.returnValue();
			sub.add((rv == null ? 0 : this.add(rv.className())));
			
			// Fill in arguments
			FieldDescriptor[] margs = md.arguments();
			for (FieldDescriptor marg : margs)
				sub.add(this.add(marg.className()));
			
			// Convert to integer
			int n = sub.size();
			int[] isubs = new int[n];
			for (int i = 0; i < n; i++)
				isubs[i] = sub.get(i);
			
			// Put in descriptor with all the pieces
			return this.__add(__v,
				isubs);
		}
		
		// Index of method
		else if (__v instanceof MethodIndex)
		{
			MethodIndex v = (MethodIndex)__v;
			return this.__add(__v,
				0x7FFF,
				this.add(v.inclass),
				this.add(v.name.toString()),
				this.add(v.type));
		}
		
		// Reference to constant pool table
		else if (__v instanceof ClassPool)
			return this.__add(__v,
				this.add(((ClassPool)__v).name));
		
		// String
		else if (__v instanceof String)
			return this.__add(__v,
				__v.hashCode() & 0xFFFF,
				((String)__v).length());
		
		// Primitives
		else if (__v instanceof Integer ||
			__v instanceof Float)
			return this.__add(__v);
		
		// Long
		else if (__v instanceof Long)
		{
			long v = (Long)__v;
			return this.__add(__v,
				this.add((int)(v >>> 32)),
				this.add((int)(v & 0xFFFFFFFF)));
		}
		
		// Double
		else if (__v instanceof Double)
		{
			long v = Double.doubleToRawLongBits((Double)__v);
			return this.__add(__v,
				this.add((int)(v >>> 32)),
				this.add((int)(v & 0xFFFFFFFF)));
		}
		
		// Used String
		else if (__v instanceof UsedString)
			return this.__add(__v,
				this.add(__v.toString()));
		
		// {@squirreljme.error JC0d Cannot add the specified entry to the
		// constant pool. (The class type)}
		else
			throw new IllegalArgumentException("JC0d " + __v.getClass());
	}
	
	/**
	 * Adds the entry to the pool and returns the passed value.
	 *
	 * @param __v The value to add.
	 * @return {@code __v}.
	 * @since 2019/04/14
	 */
	public final <V> V addSelf(V __v)
	{
		this.add(__v);
		return __v;
	}
	
	/**
	 * Gets the index of where the entry is stored in the pool.
	 *
	 * @param __v The entry to get.
	 * @return The index of the entry.
	 * @throws IllegalStateException If the entry is not in the pool.
	 * @since 2019/04/14
	 */
	public final int get(Object __v)
		throws IllegalStateException
	{
		Integer rv = this._pool.get(__v);
		if (rv == null)
			throw new IllegalStateException("JC3q " + __v);
		return rv;
	}
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @return The byte data representation.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes()
	{
		Map<Object, Integer> pool = this._pool;
		List<int[]> parts = this._parts;
		
		// Write data
		try
		{
			// Table type information
			ByteArrayOutputStream tbytes = new ByteArrayOutputStream();
			DataOutputStream tdos = new DataOutputStream(tbytes);
			
			// Table offset information
			ByteArrayOutputStream obytes = new ByteArrayOutputStream();
			DataOutputStream odos = new DataOutputStream(obytes);
			
			// Actual table data
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Guess where all the data will be written in the pool
			// tbytes + tdospadding + obytes
			int poolcount = pool.size();
			int reloff = poolcount + (poolcount & 1) + (poolcount * 2);
			
			// Write all the values in the pool, the value in the map is
			// ignored because that just stores the index identifier
			int pdx = 0;
			for (Map.Entry<Object, Integer> e: pool.entrySet())
			{
				Object value = e.getKey();
				
				// Get type and part information
				MinimizedPoolEntryType et = (pdx == 0 ?
					MinimizedPoolEntryType.NULL :
					MinimizedPoolEntryType.ofClass(value.getClass()));
				int[] part = parts.get(pdx++);
				
				// Have two pool entry formats, a wide one and a narrow one
				// This is to reduce the size of the constant pool in classes
				// where small values can be used instead
				// This adds extra types for parsing because otherwise having
				// variable ints and such will be very confusing and
				// complicated!
				int faketype = et.ordinal();
				switch (et)
				{
						// These are always fixed types and as such are never
						// wide
					case STRING:
					case INTEGER:
					case FLOAT:
						break;
					
						// If any reference part is outside of this basic
						// range then use wide values here
					default:
						// If there are lots of parts then this needs to take
						// up a larger area
						if (part.length > 127)
							faketype |= 0x80;
						
						// Scan parts
						for (int i : part)
							if (i < 0 || i > 127)
							{
								faketype |= 0x80;
								break;
							}
						break;
				}
				
				// Write entry type
				tdos.writeByte(faketype);
				
				// Align the data table to the nearest 4-byte boundary
				while (((reloff + ddos.size()) & 3) != 0)
					ddos.write(0);
				
				// Write position of the pool entry
				int dxo = reloff + ddos.size();
				odos.writeShort(Minimizer.__checkUShort(dxo));
				
				// Depends on the type used
				boolean iswide = ((faketype & 0x80) != 0);
				switch (et)
				{
					// This value should not be read
					case NULL:
						ddos.writeInt(0xFEFEFEFE);
						break;
					
						// String are special because they have actual
						// string data stored
					case STRING:
						{
							// Record hashCode and the String size as simple
							// fields to read. Note that even though there is
							// the UTF length, the length of the actual string
							// could be useful. But only keep the lowest part
							// as that will be "good enough"
							ddos.writeShort((short)part[0]);
							ddos.writeShort(Minimizer.__checkUShort(part[1]));
							
							// Write string UTF data
							ddos.writeUTF((String)value);
							
							// Write NUL terminator to make it C-like as
							// well
							ddos.write(0);
						}
						break;
						
						// Integer
					case INTEGER:
						ddos.writeInt((Integer)value);
						break;
						
						// Float
					case FLOAT:
						ddos.writeInt(
							Float.floatToRawIntBits((Float)value));
						break;
						
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_NAME:
					case CLASS_NAMES:
					case INVOKED_METHOD:
					case CLASS_POOL:
					case METHOD_DESCRIPTOR:
					case LONG:
					case DOUBLE:
					case USED_STRING:
					case METHOD_INDEX:
						{
							// Write number of parts
							int npart = part.length;
							if (iswide)
								ddos.writeShort(
									Minimizer.__checkUShort(npart));
							else
								ddos.writeByte(npart);
							
							// Write all the parts
							for (int i = 0; i < npart; i++)
								if (iswide)
									ddos.writeShort(Minimizer.__checkUShort(
										part[i]));
								else
									ddos.writeByte(part[i]);
						}
						break;
						
						// Should not occur
					default:
						throw new todo.OOPS(et.name());
				}
				
				// Round positions
				Minimizer.__dosRound(ddos);
			}
			
			// End of table padding for the type table?
			if ((poolcount & 1) != 0)
				tdos.writeByte(0xFF);
			
			// Merge the data bytes into the table then use the completed
			// table
			obytes.writeTo(tdos);
			dbytes.writeTo(tdos);
			return tbytes.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * Returns the pool size.
	 *
	 * @return The pool size.
	 * @since 2019/04/14
	 */
	public final int size()
	{
		return this._pool.size();
	}
	
	/**
	 * Internal add logic.
	 *
	 * @param __v The entry to add.
	 * @param __parts Parts which make up the entry.
	 * @return The index the entry is at.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	private final int __add(Object __v, int... __parts)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		Map<Object, Integer> pool = this._pool;
		
		// Does this entry pre-exist in the pool already?
		Integer pre = pool.get(__v);
		if (pre != null)
			return pre;
		
		// Otherwise it gets added at the end
		int rv = pool.size();
		pool.put(__v, rv);
		this._parts.add((__parts == null ? new int[0] : __parts.clone()));
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPoolEntryType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This represents the entry type in the pool.
 *
 * @since 2019/04/14
 */
public enum MinimizedPoolEntryType
{
	/** Nothing. */
	NULL,
	
	/** String. */
	STRING,
	
	/** Name of class. */
	CLASS_NAME,
	
	/** Class names (used for interfaces). */
	CLASS_NAMES,
	
	/** The constant pool for the given class. */
	CLASS_POOL,
	
	/** Accessed Field. */
	ACCESSED_FIELD,
	
	/** Invoked Method. */
	INVOKED_METHOD,
	
	/** Method Descriptor. */
	METHOD_DESCRIPTOR,
	
	/** Integer. */
	INTEGER,
	
	/** Float. */
	FLOAT,
	
	/** Long. */
	LONG,
	
	/** Double. */
	DOUBLE,
	
	/** A plain string that was used. */
	USED_STRING,
	
	/** The index of a method. */
	METHOD_INDEX,
	
	/** Class information. */
	CLASS_INFO_POINTER,
	
	/** A string which has been noted for debug purposes. */
	NOTED_STRING,
	
	/** End. */
	;
	
	/**
	 * Can this be in the runtime pool?
	 *
	 * @return If this can be in the runtime pool.
	 * @since 2019/07/20
	 */
	public final boolean isRuntime()
	{
		switch (this)
		{
			case NULL:
			case CLASS_INFO_POINTER:
			case CLASS_POOL:
			case ACCESSED_FIELD:
			case INVOKED_METHOD:
			case USED_STRING:
			case METHOD_INDEX:
			case NOTED_STRING:
				return true;
		}
		
		return false;
	}
	
	/**
	 * Can this be in the static pool?
	 *
	 * @return If this can be in the static pool.
	 * @since 2019/07/20
	 */
	public final boolean isStatic()
	{
		switch (this)
		{
			case NULL:
			case STRING:
			case CLASS_NAME:
			case CLASS_NAMES:
			case METHOD_DESCRIPTOR:
			case INTEGER:
			case FLOAT:
			case LONG:
			case DOUBLE:
				return true;
		}
		
		return false;
	}
	
	/**
	 * Returns the type for the specified index.
	 *
	 * @param __i The index to get.
	 * @return The type for this index.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @since 2019/04/17
	 */
	public static final MinimizedPoolEntryType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:		return NULL;
			case 1:		return STRING;
			case 2:		return CLASS_NAME;
			case 3:		return CLASS_NAMES;
			case 4:		return CLASS_POOL;
			case 5:		return ACCESSED_FIELD;
			case 6:		return INVOKED_METHOD;
			case 7:		return METHOD_DESCRIPTOR;
			case 8:		return INTEGER;
			case 9:		return FLOAT;
			case 10:	return LONG;
			case 11:	return DOUBLE;
			case 12:	return USED_STRING;
			case 13:	return METHOD_INDEX;
			case 14:	return CLASS_INFO_POINTER;
			case 15:	return NOTED_STRING;
		}
		
		// {@squirreljme.error JC0e Unknown pool type. (The type)}
		throw new IllegalArgumentException("JC0e " + __i);
	}
	
	/**
	 * Returns the entry type that is used for the specified class.
	 *
	 * @param __cl The class to check.
	 * @return The entry type for the class.
	 * @throws IllegalArgumentException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final MinimizedPoolEntryType ofClass(Class<?> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Easier to do it just by name
		switch (__cl.getName())
		{
			case "java.lang.String":
				return STRING;
			case "java.lang.Integer":
				return INTEGER;
			case "java.lang.Float":
				return FLOAT;
			case "java.lang.Long":
				return LONG;
			case "java.lang.Double":
				return DOUBLE;
			case "dev.shadowtail.classfile.pool.AccessedField":
				return ACCESSED_FIELD;
			case "dev.shadowtail.classfile.pool.ClassPool":
				return CLASS_POOL;
			case "dev.shadowtail.classfile.pool.InvokedMethod":
				return INVOKED_METHOD;
			case "net.multiphasicapps.classfile.ClassName":
				return CLASS_NAME;
			case "net.multiphasicapps.classfile.ClassNames":
				return CLASS_NAMES;
			case "List net.multiphasicapps.classfile.ClassName":
				return CLASS_NAMES;
			case "net.multiphasicapps.classfile.MethodDescriptor":
				return METHOD_DESCRIPTOR;
			case "dev.shadowtail.classfile.pool.UsedString":
				return USED_STRING;
			case "dev.shadowtail.classfile.pool.MethodIndex":
				return METHOD_INDEX;
			case "dev.shadowtail.classfile.pool.ClassInfoPointer":
				return CLASS_INFO_POINTER;
			case "dev.shadowtail.classfile.pool.NotedString":
				return NOTED_STRING;
			case "dev.shadowtail.classfile.pool.NullPoolEntry":
				return NULL;
		}
		
		// {@squirreljme.error JC0f Class does not map to a pool entry
		// type. (The class)}
		throw new IllegalArgumentException("JC0f " + __cl);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/Minimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.nncc.ArgumentFormat;
import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import dev.shadowtail.classfile.nncc.NativeInstructionType;
import dev.shadowtail.classfile.nncc.RegisterList;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldFlags;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodFlags;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This takes an input class file and translates it to the minimized format
 * which is easier to use.
 *
 * @since 2019/03/10
 */
public final class Minimizer
{
	/** Counter for UUIDs. */
	private static volatile int _UUID_COUNTER =
		17;
	
	/** The class file to minimize. */
	protected final ClassFile input;
	
	/** The Jar or ROM backed pool, is optional. */
	protected final DualClassRuntimePoolBuilder jarpool;
	
	/** The local constant pool. */
	protected final DualClassRuntimePoolBuilder localpool =
		new DualClassRuntimePoolBuilder();
	
	/**
	 * Initializes the minimizer.
	 *
	 * @param __dp The dual constant pool to use, may be null.
	 * @param __cf The class to minimize.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	private Minimizer(DualClassRuntimePoolBuilder __dp, ClassFile __cf)
		throws NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		this.input = __cf;
		
		// This is the packing JAR/ROM pool, this may be null
		this.jarpool = __dp;
	}
	
	/**
	 * Performs the minimization process.
	 *
	 * @param __os The stream to write the result to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	private final void __run(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
			
		// The input class
		ClassFile input = this.input;
		
		// The output section
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// This is the relative pool that the class file uses
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Process all fields and methods
		__TempFields__[] fields = this.__doFields();
		__TempMethods__[] methods = this.__doMethods();
		
		// Initialize header section
		TableSectionOutputStream.Section header =
			output.addSection(MinimizedClassHeader.HEADER_SIZE_WITH_MAGIC);
		
		// Write magic number to specify this format
		header.writeInt(MinimizedClassHeader.MAGIC_NUMBER);
		
		// Unused, may be used later when needed
		header.writeShort(0);
		
		// The index of the instance method named __start
		header.writeByte(methods[1].findMethodIndex("__start"));
		
		// Data type of the class
		header.writeByte(DataType.of(input.thisName().field()).ordinal());
		
		// This may be null for Object
		ClassName supernamecn = input.superName();
		
		// Unused
		header.writeShort(0);
		
		// Store class information, such as the flags, name, superclass,
		// interfaces, class type, and version
		header.writeInt(input.flags().toJavaBits());
		header.writeUnsignedShortChecked(
			localpool.add(false, input.thisName()).index);
		header.writeUnsignedShortChecked((supernamecn == null ? 0 :
			localpool.add(false, supernamecn).index));
		header.writeUnsignedShortChecked(
			localpool.add(false, input.interfaceNames()).index);
		header.writeByte(input.type().ordinal());
		header.writeByte(input.version().ordinal());
		
		// Needed for debugging to figure out what file the class is in,
		// will be very useful
		String sfn = input.sourceFile();
		header.writeUnsignedShortChecked((sfn == null ? 0 :
			localpool.add(false, sfn).index));
		
		// Write static and instance field counts
		for (int i = 0; i < 2; i++)
		{
			__TempFields__ tf = fields[i];
			
			header.writeUnsignedShortChecked(tf._count);
			header.writeUnsignedShortChecked((tf._bytes + 3) & (~3));
			header.writeUnsignedShortChecked(tf._objects);
		}
		
		// Write static and instance method counts
		for (int i = 0; i < 2; i++)
		{
			__TempMethods__ tm = methods[i];
			
			header.writeUnsignedShortChecked(tm._count);
		}
		
		// Unused, the pool was here
		header.writeInt(0);
		header.writeInt(0);
		
		// Field locator
		for (int i = 0; i < 2; i++)
		{
			// Generate section
			TableSectionOutputStream.Section subsection =
				output.addSection(fields[i].getBytes(localpool), 4);
			
			// Write section details
			header.writeSectionAddressInt(subsection);
			header.writeSectionSizeInt(subsection);
		}
		
		// Method locator
		for (int i = 0; i < 2; i++)
		{
			// Generate section
			TableSectionOutputStream.Section subsection =
				output.addSection(methods[i].getBytes(localpool), 4);
			
			// Write section details
			header.writeSectionAddressInt(subsection);
			header.writeSectionSizeInt(subsection);
		}
		
		// Generate a UUID and write it
		long uuid = Minimizer.generateUUID();
		header.writeInt((int)(uuid >>> 32));
		header.writeInt((int)uuid);
		
		// Write absolute file size! This saves time in calculating how big
		// a file we have and we can just read that many bytes for all the
		// data areas or similar if needed
		header.writeFileSizeInt();
		
		// Not used anymore
		header.writeInt(0);
		
		// Where our pools are going
		TableSectionOutputStream.Section lpd = output.addSection();
		
		// Encode the local pool or the local pool on top of the JAR pool
		DualClassRuntimePoolBuilder jarpool = this.jarpool;
		DualPoolEncodeResult der = (jarpool == null ?
			DualPoolEncoder.encode(localpool, lpd) :
			DualPoolEncoder.encodeLayered(localpool, jarpool, lpd));
		
		// Static pool
		header.writeSectionAddressInt(lpd, der.staticpooloff);
		header.writeInt(der.staticpoolsize);
		
		// Run-time pool
		header.writeSectionAddressInt(lpd, der.runtimepooloff);
		header.writeInt(der.runtimepoolsize);
		
		// Write end magic number, which is at the end of the file
		TableSectionOutputStream.Section eofmagic = output.addSection(4);
		eofmagic.writeInt(MinimizedClassHeader.END_MAGIC_NUMBER);
		
		// Write resulting file
		output.writeTo(__os);
	}
	
	/**
	 * Process fields.
	 *
	 * @return The resulting fields, static and instance split into each.
	 * @since 2019/03/11
	 */
	private final __TempFields__[] __doFields()
	{
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Static and instance fields are split because they are stored
		// in different places
		__TempFields__[] rv = new __TempFields__[]{
			new __TempFields__(), new __TempFields__()};
		
		// Check if this is object or an array, so that special fields are
		// added
		boolean isobject = this.input.thisName().toString().
				equals("java/lang/Object"),
			isarray = this.input.thisName().isArray();
		
		// Perform some sorting to optimize slightly and make the layout a
		// bit friendlier
		List<Field> sorted = new ArrayList<>(this.input.fields());
		Collections.sort(sorted, new __MinimizerFieldSort__());
		
		// If this is an object, add the special class type (internal class
		// pointer) and the reference count. These are always in a fixed
		// order.
		if (isobject)
		{
			// (ClassInfo) Synthetic + Transient + Final
			sorted.add(0, new Field(new FieldFlags(0x1090),
				new FieldName("_class"),
				FieldDescriptor.INTEGER, null, null));
			
			// (Reference count) Synthetic + Transient + Volatile
			sorted.add(1, new Field(new FieldFlags(0x10c0),
				new FieldName("_refcount"),
				FieldDescriptor.INTEGER, null, null));
			
			// (monitor owning thread) Synthetic + Transient + Volatile
			sorted.add(2, new Field(new FieldFlags(0x10c0),
				new FieldName("_monitor"),
				FieldDescriptor.INTEGER, null, null));
			
			// (monitor enter count) Synthetic + Transient + Volatile
			sorted.add(3, new Field(new FieldFlags(0x10c0),
				new FieldName("_moncount"),
				FieldDescriptor.INTEGER, null, null));
		}
		
		// If an array, add the length of the array
		else if (isarray)
		{
			// Synthetic + Transient + Final
			sorted.add(0, new Field(new FieldFlags(0x1090),
				new FieldName("_length"),
				FieldDescriptor.INTEGER, null, null));
		}
		
		// Process each field
		for (Field f : sorted)
		{
			// These are stored in their own rows
			__TempFields__ temp = rv[(f.flags().isStatic() ? 0 : 1)];
			
			// Determine the size of this entry (and its alignment)
			PrimitiveType pt = f.type().primitiveType();
			int fsz = (pt == null ? 4 : pt.bytes());
			
			// If this is an object increase the object count, this is needed
			// by the garbage collector to determine the addresses to scan
			// However, the object class always has no objects in it
			if (!isobject && pt == null)
				temp._objects++;
			
			// Determine the base position and check if any alignment is needed
			// assuming types of a given size are always aligned
			int basep = (temp._bytes + (fsz - 1)) & ~(fsz - 1);
			
			// Constant value may be null, but if it is not then add it
			// to the pool
			ConstantValue cval = f.constantValue();
			
			// Add field properties
			localpool.add(false, f.name().toString());
			localpool.add(false, f.type().className());
			
			// Boxed value, if used
			if (cval != null)
				localpool.add(false, cval.boxedValue());
			
			// Build field information
			MinimizedField q;
			temp._fields.add((q = new MinimizedField(
				f.flags().toJavaBits(),
				basep,
				fsz,
				f.name(),
				f.type(),
				(cval == null ? null : cval.boxedValue()))));
			
			// Handle table sizes
			temp._bytes = basep + fsz;
			temp._count++;
		}
		
		// Align fields sizes to 4-bytes always so that the next class on
		// top of this has aligned field data
		for (__TempFields__ temp : rv)
			temp._bytes = (temp._bytes + 3) & ~3;
		
		// Return static and instance fields
		return rv;
	}
	
	/**
	 * Processes all methods within the class.
	 *
	 * @return The processed static and instance methods.
	 * @since 2019/03/13
	 */
	private final __TempMethods__[] __doMethods()
	{
		DualClassRuntimePoolBuilder localpool = this.localpool;
		ClassFile input = this.input;
		
		// Split static and instance methods to make them easier to locate
		// accordingly
		__TempMethods__[] rv = new __TempMethods__[]{
			new __TempMethods__(input.thisName()),
			new __TempMethods__(input.thisName())};
		
		// Process each method
		for (Method m : input.methods())
		{
			// These are stored in their own rows
			__TempMethods__ temp = rv[(m.flags().isStatic() ? 0 : 1)];
			
			// Need to translate and serialize the byte code into a register
			// form and remap any used references.
			MethodFlags mf = m.flags();
			byte[] transcode = null;
			if (!mf.isAbstract() && !mf.isNative())
			{
				// The minified classes use register code since it is easier
				// to handle by the VM
				NativeCode rc = m.nativeCode();
				
				// Encode data to bytes
				try
				{
					// Translate code
					transcode = this.__translateCode(rc);
				}
				
				// {@squirreljme.error JC0j Error during translation of the
				// specified method. (The current class; The method)}
				catch (InvalidClassFormatException e)
				{
					throw new InvalidClassFormatException("JC4s " +
						input.thisName() + " " + m.nameAndType(), e);
				}
				
				// {@squirreljme.error JC0k IOException translating code.}
				catch (IOException e)
				{
					throw new RuntimeException("JC0k", e);
				}
			}
			
			// Add name and type to the pool
			localpool.add(false, m.name().toString());
			localpool.add(false, m.type());
			
			// Add method
			MinimizedMethod q;
			temp._methods.add((q = new MinimizedMethod(mf.toJavaBits(),
				temp._count,
				m.name(),
				m.type(),
				transcode)));
			
			// Quick count for used methods
			temp._count++;
		}
		
		return rv;
	}
	
	/**
	 * Translates code.
	 *
	 * @param __rc The register code used.
	 * @param __dos The stream to write to.
	 * @return The resulting stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/23
	 */
	private final byte[] __translateCode(NativeCode __rc)
		throws IOException, NullPointerException
	{
		if (__rc == null)
			throw new NullPointerException("NARG");
		
		// Where stuff gets written to
		ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
		DataOutputStream dos = new DataOutputStream(baos);
		
		// Positions where all the instructions are in the byte array
		int cdn = __rc.length();
		int[] indexpos = new int[cdn];
		
		// Locations which have jump targets to be replaced
		List<__Jump__> jumpreps = new LinkedList<>();
		
		// Operations will reference this constant pool
		DualClassRuntimePoolBuilder localpool = this.localpool;
		
		// Go through each instruction
		for (int cdx = 0; cdx < cdn; cdx++)
		{
			// Get instruction here
			NativeInstruction i = __rc.get(cdx);
			
			// Record that the instruction is at this position
			int baseaddr;
			indexpos[cdx] = (baseaddr = dos.size());
			
			// Operation to handle
			int op = i.operation();
			
			// Write operation
			dos.write(op);
			
			// Encode arguments
			ArgumentFormat[] format = i.argumentFormat();
			for (int a = 0, an = i.argumentCount(),
				afn = format.length; a < an; a++)
			{
				// Read argument
				Object v = i.argument(a);
				
				// Write the format
				switch (format[a])
				{
						// Variable 16-bit unsigned integer
					case VUINT:
					case VUREG:
					case VPOOL:
					case VJUMP:
						// Remap value
						int vm = 0;
						switch (format[a])
						{
							case VPOOL:
								try
								{
									vm = localpool.add(true, v).index;
								}
								catch (IllegalArgumentException e)
								{
									// {@squirreljme.error JC4g Could not add
									// pool entry because it is not valid.
									// (The current instruction)}
									throw new InvalidClassFormatException(
										"JC4g " + i, e);
								}
								break;
								
							case VJUMP:
								{
									// Store for later modification
									jumpreps.add(new __Jump__(cdx, dos.size(),
										((InstructionJumpTarget)v).target()));
									
									// Do not know if the full address can fit
									vm = 32767;
								}
								break;
							
							case VUINT:
							case VUREG:
								vm = ((Number)v).intValue();
								break;
						}
						
						// Fits in 7-bit value
						if (vm >= 0 && vm <= 127)
							dos.write(vm);
						
						// Fits in 15-bit value
						else if (vm >= 128 && vm <= 32767)
						{
							dos.write(0x80 | (vm >> 8));
							dos.write(vm & 0xFF);
						}
						
						// {@squirreljme.error JC0l 15-bit integer out of
						// range. (The value; The instruction index; The
						// invalid instruction)}
						else
							throw new InvalidClassFormatException(
								"JC0l " + vm + " " + cdx + " " + i);
						break;
						
						// Register List
					case REGLIST:
						{
							// Scan register list to see if it is "wide", if
							// it is then the wide format is used
							RegisterList rl = (RegisterList)v;
							int rn = rl.size();
							boolean wide = (rn > 127);
							for (int r = 0; r < rn; r++)
							{
								int rv = rl.get(r);
								if (rv < 0 || rv > 127)
								{
									wide = true;
									break;
								}
							}
							
							// Wide
							if (wide)
							{
								// Count
								dos.write(0x80 | (rn >> 8));
								dos.write(rn & 0xFF);
								
								// Write as shorts
								for (int r = 0; r < rn; r++)
									dos.writeShort(rl.get(r));
							}
							
							// Narrow
							else
							{
								// Count
								dos.write(rn);
								
								// Write as bytes
								for (int r = 0; r < rn; r++)
									dos.write(rl.get(r));
							}
						}
						break;
						
						// 32-bit int
					case INT32:
						dos.writeInt(((Number)v).intValue());
						break;
					
						// 64-bit long
					case INT64:
						dos.writeLong(((Number)v).longValue());
						break;
					
						// 32-bit float
					case FLOAT32:
						dos.writeInt(Float.floatToRawIntBits(
							((Number)v).floatValue()));
						break;
					
						// 64-bit double
					case FLOAT64:
						dos.writeLong(Double.doubleToRawLongBits(
							((Number)v).doubleValue()));
						break;
					
						// Unknown
					default:
						throw new todo.OOPS(i.toString());
				}
			}
		}
		
		// Generate code array
		byte[] rv = baos.toByteArray();
		int codesize = rv.length;
		
		// Replace jumps
		for (__Jump__ j : jumpreps)
		{
			// Calculate target
			int cdx = j.cdx,
				ai = j.dss,
				origjt = j.jt,
				jt = indexpos[origjt] - indexpos[cdx];
			
			// Wide
			if ((rv[ai] & 0x80) != 0)
			{
				rv[ai] = (byte)(0x80 | (jt >> 8));
				rv[ai + 1] = (byte)(jt & 0xFF);
			}
			
			// Narrow
			else
				rv[ai] = (byte)jt;
		}
		
		// Return array
		return rv;
	}
	
	/**
	 * Generates a UUID to identify the minimized class.
	 *
	 * @return The generated UUID.
	 * @since 2019/04/27
	 */
	public static final long generateUUID()
	{
		// Hopefully this seed is good enough?
		Random rand = new Random(System.nanoTime() +
			(System.currentTimeMillis() << 24) + (++_UUID_COUNTER));
		
		// Skip a random amount of values to run it for a bit
		for (int i = 0, n = rand.nextInt(32 + rand.nextInt(32)); i < n; i++)
			rand.nextInt();
		
		// Just use the next long value
		return rand.nextLong();
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class as a byte array.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final byte[] minimize(ClassFile __cf)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		return Minimizer.minimize(null, __cf);
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __dp Dual constant pool, this may be {@code null}.
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class as a byte array.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final byte[] minimize(DualClassRuntimePoolBuilder __dp,
		ClassFile __cf)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		// Minimization is straight to a byte format so just read that in
		// again
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Output minimized code to the byte array
			Minimizer.minimize(__dp, __cf, baos);
			
			// The class data is in the resulting byte array
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the class file so that it is in a more compact format as
	 * needed.
	 *
	 * @param __cf The class file to minimize.
	 * @param __os The stream to write the minimized format to.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final void minimize(ClassFile __cf, OutputStream __os)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		Minimizer.minimize(null, __cf, __os);
	}
	
	/**
	 * Minimizes the class file so that it is in a more compact format as
	 * needed.
	 *
	 * @param __dp Dual constant pool, may be {@code null}.
	 * @param __cf The class file to minimize.
	 * @param __os The stream to write the minimized format to.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final void minimize(DualClassRuntimePoolBuilder __dp,
		ClassFile __cf, OutputStream __os)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__cf == null || __os == null)
			throw new NullPointerException("NARG");
		
		new Minimizer(__dp, __cf).__run(__os);
	}
	
	/**
	 * Minimizes the given class and returns the minimized version of it.
	 *
	 * @param __cf The class to minimize.
	 * @return The resulting minimized class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/10
	 */
	public static final MinimizedClassFile minimizeAndDecode(ClassFile __cf)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cf == null)
			throw new NullPointerException("NARG");
		
		// Minimize raw byte array
		try
		{
			return MinimizedClassFile.decode(Minimizer.minimize(__cf));
		}
		
		// {@squirreljme.error JC0m Could not minimize class due to a read
		// or write error.}
		catch (IOException e)
		{
			throw new RuntimeException("JC0m", e);
		}
	}
	
	/**
	 * Writes variable size unsigned short, only 15-bits are possible to be
	 * written.
	 *
	 * @param __dos The stream to write to.
	 * @param __v The value to write.
	 * @throws IOException ON write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final void writeVUShort(DataOutputStream __dos, int __v)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Single byte form (7-bit)
		if (__v >= 0 && __v < 127)
			__dos.writeByte(__v);
		
		// Double byte form (15-bits)
		else if (__v >= 128 && __v < 32768)
		{
			__dos.writeByte(0x80 | (__v >>> 8));
			__dos.writeByte(__v & 0xFF);
		}
		
		// {@squirreljme.error JC0n Variable unsigned short out of range.
		// (The value)}
		else
			throw new InvalidClassFormatException("JC0n " + __v);
	}
	
	/**
	 * Checks that the unsigned short is in range.
	 *
	 * @param __v The value to check.
	 * @return {@code __v}.
	 * @throws InvalidClassFormatException If the short is out of range.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __checkUShort(int __v)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC0o Unsigned short out of range. (The value)}
		if (__v < 0 || __v > 65535)
			throw new InvalidClassFormatException("JC0o " + __v);
		return __v;
	}
	
	/**
	 * Compacts a table of shorts or bytes to a run-length encoded form.
	 *
	 * @param __st The input table.
	 * @param __bt The byte table.
	 * @return The resulting RLE encoded byte data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	@Deprecated
	private static final byte[] __compact(short[] __st, byte[] __bt)
		throws IOException, NullPointerException
	{
		if (__st == null && __bt == null)
			throw new NullPointerException("NARG");
		
		// Using shorts or bytes
		boolean shorts = (__st != null);
		int len = (shorts ? __st.length : __bt.length);
		
		// Target stream
		ByteArrayOutputStream baos = new ByteArrayOutputStream(len);
		DataOutputStream dos = new DataOutputStream(baos);
		
		// Go through every entry, compacting it accordingly
		int lastline = -1,
			lastpc = 0;
		for (int i = 0, n = len; i < n; i++)
		{
			int nowline = (shorts ? __st[i] : __bt[i]);
			
			// If there is a really long stretch of instructions which point
			// to the same exact data, force it to be reset so that way the
			// number table after this point is not complete garbage
			// Note that 255 is the end of data marker
			boolean force = ((i == 0) || ((i - lastpc) >= 254));
			
			// Line number has changed, need to encode the information
			if (force || nowline != lastline)
			{
				// Since multiple instruction addresses can share data info,
				// to reduce the size of the table just record an offset from
				// the last PC address
				// Just a single byte is used for the difference since in
				// general these ranges will be small
				int diff = i - lastpc;
				dos.write(diff);
				
				// Write data position here, just as a 16-bit value without
				// any different encoding since values can jump all over the
				// place
				if (shorts)
					dos.writeShort(nowline);
				else
					dos.writeByte(nowline);
				
				// For next time
				lastline = nowline;
				lastpc = i;
			}
		}
		
		// A difference of 255 means end of data
		dos.write(0xFF);
		
		// Return result
		return baos.toByteArray();
	}
	
	/**
	 * Pads the output stream.
	 *
	 * @param __dos The stream to pad.
	 * @return The current size of the output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __dosRound(DataOutputStream __dos)
		throws IOException, NullPointerException
	{
		if (__dos == null)
			throw new NullPointerException("NARG");
		
		// Add padding
		while ((__dos.size() & 3) != 0)
			__dos.write(0);
		return __dos.size();
	}
	
	/**
	 * Adds length data to the relative offset.
	 *
	 * @param __rel Current relative offset.
	 * @param __v The offset to add.
	 * @since 2019/04/14
	 */
	@Deprecated
	static final int __relAdd(int __rel, int __v)
	{
		__rel += __v;
		return (__rel + 3) & (~3);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/__Jump__.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.mini;

/**
 * This represents a jump replacement.
 *
 * @since 2019/05/29
 */
final class __Jump__
{
	/** Instruction index. */
	public final int cdx;
	
	/** Data position size. */
	public final int dss;
	
	/** The jump target. */
	public final int jt;
	
	/**
	 * Initializes the jump target.
	 *
	 * @param __cdx The instruction index.
	 * @param __dss The DSS.
	 * @param __jt The jump target.
	 * @since 2019/05/29
	 */
	__Jump__(int __cdx, int __dss, int __jt)
	{
		this.cdx = __cdx;
		this.dss = __dss;
		this.jt = __jt;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/__MinimizerFieldSort__.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import java.util.Comparator;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * This is used to sort the input fields according to their size and type so
 * that they are grouped together and aligned together.
 *
 * Name sorting is used last.
 *
 * @since 2019/03/11
 */
final class __MinimizerFieldSort__
	implements Comparator<Field>
{
	/**
	 * Compares two fields.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @since 2019/03/11
	 */
	public int compare(Field __a, Field __b)
	{
		// Make objects always first so we can quickly scan through objects
		// when clearing references out
		PrimitiveType pa = __a.type().primitiveType(),
			pb = __b.type().primitiveType();
		if (pa == null && pb != null)
			return -1;
		else if (pa != null && pb == null)
			return 1;
		
		// Compare sizes first to force alignables to be close to each other
		// Make it so larger fields are always first since they take up the
		// most room, it is easier to compact smaller fields following because
		// it should take up less room
		int sa = (pa == null ? 4 : pa.bytes()),
			sb = (pb == null ? 4 : pb.bytes());
		int rv = sb - sa;
		if (rv != 0)
			return rv;
		
		// Then sort by the descriptor so like-types are close to each other
		rv = __a.type().compareTo(__b.type());
		if (rv != 0)
			return rv;
		
		// Then fallback to name
		return __a.name().compareTo(__b.name());
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/__TempFields__.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
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




































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * Stores temporary field data as it is processed.
 *
 * @since 2019/03/11
 */
final class __TempFields__
{
	/** The fields in the table. */
	final List<MinimizedField> _fields =
		new ArrayList<>();
	
	/** The number of fields in the table. */
	int _count;
	
	/** The current byte size of the field table. */
	int _bytes;
	
	/** The total number of objects in the table. */
	int _objects;
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @param __pool The constant pool.
	 * @return The byte data representation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes(DualClassRuntimePoolBuilder __pool)
		throws NullPointerException
	{
		if (__pool == null)
			throw new NullPointerException("NARG");
		
		// The resulting table
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Write
		try
		{
			// Table of contents data
			TableSectionOutputStream.Section toc = output.addSection();
			
			// Actual table data
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Write field information
			for (MinimizedField m : this._fields)
			{
				// 16-bytes
				toc.writeInt(m.flags);
				toc.writeUnsignedShortChecked(m.offset);
				toc.writeUnsignedShortChecked(m.size);
				toc.writeUnsignedShortChecked(
					__pool.add(false, m.name.toString()).index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, m.type.className()).index);
				toc.writeUnsignedShortChecked((m.value == null ? 0 :
					__pool.add(false, m.value).index));
				toc.writeByte(m.datatype.ordinal());
				toc.writeByte(0);
			}
			
			// Write end of table
			toc.writeInt(0xFFFFFFFF);
			
			// Build output data
			return output.toByteArray();
		}
		
		// Should not occur
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/__TempMethods__.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
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





































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * Contains temporary method information.
 *
 * @since 2019/03/13
 */
final class __TempMethods__
{
	/** The name of this class. */
	protected final ClassName classname;
	
	/** The methods in this table. */
	final List<MinimizedMethod> _methods =
		new ArrayList<>();
	
	/** The number of methods that are available. */
	int _count;
	
	/**
	 * Initializes.
	 *
	 * @param __cn The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	__TempMethods__(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
	}
	
	/**
	 * Finds the method by the given name.
	 *
	 * @param __name The name to locate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/11
	 */
	public final int findMethodIndex(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		List<MinimizedMethod> methods = this._methods;
		for (int i = 0, n = methods.size(); i < n; i++)
			if (__name.equals(methods.get(i).nameAndType().name().toString()))
				return i;
		
		return -1;
	}
	
	/**
	 * Returns the byte representation of the data here.
	 *
	 * @param __pool The constant pool.
	 * @return The byte data representation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public final byte[] getBytes(DualClassRuntimePoolBuilder __pool)
		throws NullPointerException
	{
		if (__pool == null)
			throw new NullPointerException("NARG");
		
		// Build into sections
		TableSectionOutputStream output = new TableSectionOutputStream();
		
		// Write
		MinimizedMethod current = null;
		try
		{
			// Methods to process
			List<MinimizedMethod> methods = this._methods;
			
			// Table of contents which represents each method
			TableSectionOutputStream.Section toc = output.addSection();
			
			// Format every method
			for (int i = 0, n = methods.size(); i < n; i++)
			{
				// Get the method to process
				current = methods.get(i);
				
				// Write all of the method code into its own section
				TableSectionOutputStream.Section codesection = null;
				byte[] rawcode = current._code;
				if (rawcode != null)
				{
					// Add aligned section for this code
					codesection = output.addSection(
						TableSectionOutputStream.VARIABLE_SIZE, 4);
					
					// Write all of the code here
					codesection.write(rawcode);
				}
				
				// Flags, name, and type
				toc.writeInt(current.flags);
				toc.writeUnsignedShortChecked(current.index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, current.name.toString()).index);
				toc.writeUnsignedShortChecked(
					__pool.add(false, current.type).index);
				
				// Code section if one exists
				if (codesection != null)
				{
					toc.writeSectionAddressInt(codesection);
					toc.writeSectionSizeInt(codesection);
				}
				
				// There is no code
				else
				{
					toc.writeInt(0);
					toc.writeInt(0);
				}
				
				// Padding to align flags to int
				toc.writeShort(0);
			}
			
			// Write end of table
			toc.writeInt(0xFFFFFFFF);
			
			// Output as a byte array
			return output.toByteArray();
		}
		
		// {@squirreljme.error JC0p Could not process the method. (The method
		// this stopped at)}
		catch (InvalidClassFormatException|IOException e)
		{
			throw new InvalidClassFormatException("JC0p " + current, e);
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/mini/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the support for the creation of minitature (compressed)
 * classes which contain easy to read by computer formats and only the
 * required parts of the class that are used to execute code. It is meant to
 * be easier to use for virtual machines without needing to worry too much
 * about the class file format.
 *
 * @since 2019/03/10
 */

package dev.shadowtail.classfile.mini;

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/ArgumentFormat.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * This represents the type of argument that is used.
 *
 * @since 2019/04/16
 */
public enum ArgumentFormat
{
	/** Variable unsigned int. */
	VUINT,
	
	/** Variable register (unsigned int). */
	VUREG,
	
	/** Variable pool entry. */
	VPOOL,
	
	/** Variable jump entry. */
	VJUMP,
	
	/** Register list. */
	REGLIST,
	
	/** 32-bit integer. */
	INT32,
	
	/** 64-bit integer. */
	INT64,
	
	/** 32-bit float. */
	FLOAT32,
	
	/** 64-bit float. */
	FLOAT64,
	
	/** End. */
	;
	
	/**
	 * Returns an array of all the formats.
	 *
	 * @param __a The input formats.
	 * @return {@code __a}.
	 * @since 2019/04/16
	 */
	public static final ArgumentFormat[] of(ArgumentFormat... __a)
	{
		return (__a == null ? new ArgumentFormat[0] : __a);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/ClassAndLabel.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
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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;

/**
 * This stores a class and a label.
 *
 * @since 2019/04/13
 */
public final class ClassAndLabel
{
	/** The name of the class. */
	public final ClassName classname;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The class name.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public ClassAndLabel(ClassName __n, NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.classname = __n;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassAndLabel))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		ClassAndLabel o = (ClassAndLabel)__o;
		return this.classname.equals(o.classname) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.classname.hashCode() ^
				this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/ClassStackAndLabel.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
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










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.JavaStackState;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;

/**
 * This stores a class, a stack state, and a label.
 *
 * @since 2019/04/11
 */
public final class ClassStackAndLabel
{
	/** The name of the class. */
	public final ClassName classname;
	
	/** The state of the resulting stack. */
	public final JavaStackState stack;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The class name.
	 * @param __s The stack state.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public ClassStackAndLabel(ClassName __n, JavaStackState __s,
		NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __s == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.classname = __n;
		this.stack = __s;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassStackAndLabel))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		ClassStackAndLabel o = (ClassStackAndLabel)__o;
		return this.classname.equals(o.classname) &&
			this.stack.equals(o.stack) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.classname.hashCode() ^
				this.stack.hashCode() ^ this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/EnqueueAndLabel.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
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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains an enqueue and a label.
 *
 * @since 2019/04/24
 */
public final class EnqueueAndLabel
{
	/** The enqueue. */
	public final JavaStackEnqueueList enqueue;
	
	/** Label to exception point. */
	public final NativeCodeLabel label;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the class.
	 *
	 * @param __n The enqueue used.
	 * @param __l The label to jump to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	public EnqueueAndLabel(JavaStackEnqueueList __n, NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__n == null || __l == null)
			throw new NullPointerException("NARG");
		
		this.enqueue = __n;
		this.label = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof EnqueueAndLabel))
			return false;
		
		EnqueueAndLabel o = (EnqueueAndLabel)__o;
		return this.enqueue.equals(o.enqueue) &&
			this.label.equals(o.label);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.enqueue.hashCode() ^
				this.label.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/24
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/InvalidInstructionException.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 dev.shadowtail.classfile.nncc;

import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This is thrown when an instruction is not valid.
 *
 * @since 2019/06/13
 */
public class InvalidInstructionException
	extends InvalidClassFormatException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/06/13
	 */
	public InvalidInstructionException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/06/13
	 */
	public InvalidInstructionException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeCode.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
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



















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.nncc.NearNativeByteCodeHandler;
import dev.shadowtail.classfile.xlate.ByteCodeProcessor;
import java.util.Collection;
import java.util.Iterator;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This is similar to {@link ByteCode} except that it instead of using a
 * stack for intermediate Java operations, this instead uses registers. This
 * provides a more concise and easier to use format by virtual machines.
 *
 * @see ByteCode
 * @since 2019/03/09
 */
public final class NativeCode
	implements Iterable<NativeInstruction>
{
	/** The zero register. */
	public static final int ZERO_REGISTER =
		0;
	
	/** The return value register (two slots, 1 + 2). */
	public static final int RETURN_REGISTER =
		1;
	
	/** Second return register. */
	public static final int RETURN_TWO_REGISTER =
		2;
	
	/** The exception register. */
	public static final int EXCEPTION_REGISTER =
		3;
	
	/** The pointer containing static field data. */
	public static final int STATIC_FIELD_REGISTER =
		4;
	
	/** Register which represents the current thread of execution. */
	public static final int THREAD_REGISTER =
		5;
	
	/** Base for local registers (locals start here). */
	public static final int LOCAL_REGISTER_BASE =
		6;
	
	/** The register containing the constant pool. */
	public static final int POOL_REGISTER =
		6;
	
	/** The register which contains the next pool pointer to use. */
	public static final int NEXT_POOL_REGISTER =
		7;
	
	/** The register of the first argument. */
	public static final int ARGUMENT_REGISTER_BASE =
		8;
	
	/** Maximum number of registers possible to use. */
	public static final int MAX_REGISTERS =
		64;
	
	/** This bit XORed NEG bit == set, means memory access is volatile. */
	@Deprecated
	public static final int MEMORY_OFF_VOLATILE_BIT =
		0x80000000;
	
	/**
	 * This bit is just used to signal that the offset is negative. After the
	 * volatility has been determined, the volatile bit is set to the value
	 * of this bit then execution continues.
	 */
	public static final int MEMORY_OFF_NEG_BIT =
		0x40000000;
	
	/** Mask to access the offset value. */
	public static final int MEMORY_OFF_VALUE_MASK =
		0x7FFFFFFF;
	
	/** Instructions for this code. */
	private final NativeInstruction[] _instructions;
	
	/**
	 * Initializes the register code.
	 *
	 * @param __i The associated instructions.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeCode(NativeInstruction[] __i)
		throws NullPointerException
	{
		__i = (__i == null ? new NativeInstruction[0] : __i.clone());
		for (NativeInstruction i : __i)
			if (i == null)
				throw new NullPointerException("NARG");
		
		this._instructions = __i;
	}
	
	/**
	 * Gets the instruction at this index.
	 *
	 * @param __dx The index to get.
	 * @return The register at this index.
	 * @since 2019/03/26
	 */
	public final NativeInstruction get(int __dx)
	{
		return this._instructions[__dx];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/23
	 */
	@Override
	public final Iterator<NativeInstruction> iterator()
	{
		return UnmodifiableIterator.<NativeInstruction>of(
			this._instructions);
	}
	
	/**
	 * Returns the length of the register code.
	 *
	 * @return The register code length.
	 * @since 2019/03/26
	 */
	public final int length()
	{
		return this._instructions.length;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeCodeBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663























































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.JavaStackResult;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InstructionJumpTarget;

/**
 * This is used to build {@link NativeCode} and add instructions to it.
 *
 * @since 2019/03/16
 */
public final class NativeCodeBuilder
{
	/** Label positions. */
	final Map<NativeCodeLabel, Integer> _labels =
		new LinkedHashMap<>();
	
	/** Temporary instruction layout. */
	final Map<Integer, Point> _points =
		new LinkedHashMap<>();
	
	/** Next address to use. */
	int _nextaddr;
	
	/**
	 * Initializes the code builder at the default start address.
	 *
	 * @since 2019/03/22
	 */
	public NativeCodeBuilder()
	{
		this._nextaddr = 0;
	}
	
	/**
	 * Initializes the code builder at the given start address.
	 *
	 * @param __pc The address to start at.
	 * @since 2019/03/22
	 */
	public NativeCodeBuilder(int __pc)
	{
		this._nextaddr = __pc;
	}
	
	/**
	 * Adds a new instruction.
	 *
	 * @param __op The operation to add.
	 * @param __args The arguments to the operation.
	 * @return The resulting temporary instruction.
	 * @throws IllegalArgumentException If the argument count is incorrect.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/16
	 */
	public final NativeInstruction add(int __op, Object... __args)
		throws IllegalArgumentException, NullPointerException
	{
		// Needed for argument format check
		ArgumentFormat[] afmt = NativeInstruction.argumentFormat(__op);
		int fnar = afmt.length;
		
		// Build instruction
		NativeInstruction rv = new NativeInstruction(__op, __args);
		
		// {@squirreljme.error JC0q Operation has an incorrect number of
		// arguments. (The instruction)}
		if (fnar != __args.length)
			throw new IllegalArgumentException("JC0q " + rv);
		
		// Check format
		for (int i = 0; i < fnar; i++)
		{
			// Cannot be null
			Object o = __args[i];
			if (o == null)
				throw new NullPointerException("NARG");
			
			// Integer value?
			int oi = ((o instanceof Number) ? ((Number)o).intValue() : -1);
			
			// Make sure values are good
			switch (afmt[i])
			{
					// {@squirreljme.error JC0r Use of register which is out
					// of range of the maximum register count.
					// (The instruction)}
				case VUREG:
					if (oi < 0 || oi >= NativeCode.MAX_REGISTERS)
						throw new IllegalArgumentException("JC0r " + rv);
					break;
				
					// {@squirreljme.error JC0s Cannot jump to a non-label.
					// (The instruction)}
				case VJUMP:
					if (!(o instanceof NativeCodeLabel))
						throw new IllegalArgumentException("JC0s " + rv);
					break;
			}
		}
		
		// Create instruction
		int atdx = this._nextaddr++;
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("@%d -> %s %s", atdx,
				NativeInstruction.mnemonic(__op), Arrays.asList(__args));
			
		// Store all information
		this._points.put(atdx, new Point(rv));
		return rv;
	}
	
	/**
	 * Adds a copy from one register to another.
	 *
	 * @param __from The source.
	 * @param __to The destination.
	 * @return The resulting instruction.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addCopy(int __from, int __to)
	{
		return this.add(NativeInstructionType.COPY,
			__from, __to);
	}
	
	/**
	 * Adds an integer comparison instruction.
	 *
	 * @param __ct The type of comparison to make
	 * @param __a The first register.
	 * @param __b The register to compare against.
	 * @param __jt The target of the jump.
	 * @return The resulting instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addIfICmp(CompareType __ct, int __a,
		int __b, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__ct == null || __jt == null)
			throw new NullPointerException("NARG");
		
		// Build operation
		return this.add(NativeInstructionType.IF_ICMP |
			__ct.ordinal(), __a, __b, __jt);
	}
	
	/**
	 * Adds a jump if the given register is not zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public final NativeInstruction addIfNonZero(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.NOT_EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is positive.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/11/30
	 */
	public final NativeInstruction addIfPositive(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.GREATER_THAN, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a jump if the given register is zero. No reference clears are
	 * performed by this call.
	 *
	 * @param __a The register to check.
	 * @param __jt The target of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addIfZero(int __a, NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.EQUALS, __a,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a goto which goes to the following location.
	 *
	 * @param __jt The target of the jump.
	 * @return The resulting instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	public final NativeInstruction addGoto(NativeCodeLabel __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		return this.addIfICmp(CompareType.TRUE, NativeCode.ZERO_REGISTER,
			NativeCode.ZERO_REGISTER, __jt);
	}
	
	/**
	 * Adds a math via constant operation.
	 *
	 * @param __jt The Java type.
	 * @param __mf The math function.
	 * @param __a Register A.
	 * @param __b Constant B.
	 * @param __c The result.
	 * @return The resulting register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/08
	 */
	public final NativeInstruction addMathConst(StackJavaType __jt,
		MathType __mf, int __a, Number __b, int __c)
		throws NullPointerException
	{
		if (__jt == null || __mf == null || __b == null)
			throw new NullPointerException("NARG");
		
		int op;
		switch (__jt)
		{
			case INTEGER:
				op = NativeInstructionType.MATH_CONST_INT;
				break;
				
				// {@squirreljme.error JC0t May only do math on integer.}
			case LONG:
			case FLOAT:
			case DOUBLE:
				throw new RuntimeException("JC0t");
			
			default:
				throw new todo.OOPS(__jt.name());
		}
		
		// Build operation
		int rop = op | __mf.ordinal();
		return this.add(rop, __a, __b, __c);
	}
	
	/**
	 * Adds a math via register operation.
	 *
	 * @param __jt The Java type.
	 * @param __mf The math function.
	 * @param __a Register A.
	 * @param __b Register B.
	 * @param __c The result.
	 * @return The resulting register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/08
	 */
	public final NativeInstruction addMathReg(StackJavaType __jt,
		MathType __mf, int __a, int __b, int __c)
		throws NullPointerException
	{
		if (__jt == null || __mf == null)
			throw new NullPointerException("NARG");
		
		int op;
		switch (__jt)
		{
			case INTEGER:
				op = NativeInstructionType.MATH_REG_INT;
				break;
				
				// {@squirreljme.error JC0u May only do math on integer.}
			case LONG:
			case FLOAT:
			case DOUBLE:
				throw new RuntimeException("JC0u");
			
			default:
				throw new todo.OOPS(__jt.name());
		}
		
		// Build operation
		int rop = op | __mf.ordinal();
		return this.add(rop, __a, __b, __c);
	}
	
	/**
	 * Adds memory offset by constant.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addMemoryOffConst(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0v Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0v");
		
		return this.add(NativeInstructionType.MEMORY_OFF_ICONST |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by constant, using Java format.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public final NativeInstruction addMemoryOffConstJava(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0w Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0w");
		
		return this.add(NativeInstructionType.MEMORY_OFF_ICONST_JAVA |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by register.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to load/store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public final NativeInstruction addMemoryOffReg(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0x Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0x");
		
		// Generate
		return this.add(NativeInstructionType.MEMORY_OFF_REG |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Adds memory offset by register, using Java format.
	 *
	 * @param __dt The data type used.
	 * @param __load Is this a load operation?
	 * @param __v The value to store.
	 * @param __p The pointer.
	 * @param __o The offset.
	 * @return The generated instruction.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public final NativeInstruction addMemoryOffRegJava(DataType __dt,
		boolean __load, int __v, int __p, int __o)
		throws NullPointerException
	{
		if (__dt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC0y Cannot access wide memory.}
		if (__dt.isWide())
			throw new IllegalArgumentException("JC0y");
		
		// Generate
		return this.add(NativeInstructionType.MEMORY_OFF_REG_JAVA |
			(__load ? 0b1000 : 0) | __dt.ordinal(), __v, __p, __o);
	}
	
	/**
	 * Builds the register code, all references to other portions in the
	 * code itself are resolved.
	 *
	 * @return The built register code.
	 * @since 2019/03/22
	 */
	public final NativeCode build()
	{
		// Labels which point to addresses
		Map<NativeCodeLabel, Integer> labels = this._labels;
		
		// If there are any jump points which refer to the instruction index
		// directly following it, then remove the jump.
		// Also possibly perform other modifications
		List<Point> in = new ArrayList<>(this._points.values());
		for (int i = in.size() - 1; i >= 0; i--)
		{
			// Get the instruction and its various properties
			Point point = in.get(i);
			NativeInstruction ri = point.instruction;
			int rie = ri.encoding();
			
			NativeCodeLabel jt = null;
			
			// Depends on the encoding
			switch (rie)
			{
				case NativeInstructionType.IF_ICMP:
					jt = (NativeCodeLabel)ri.argument(2);
					break;
					
					// Not a jump
				default:
					continue;
			}
			
			// Check if this points to the instruction directly following this.
			boolean ptonext = (jt != null && (i + 1) == labels.get(jt));
			
			// If it does point to the next instruction, we either delete it
			// or replace the instruction with another depending on ref_clear
			// and such
			if (ptonext)
			{
				// Remove this instruction, it is pointless
				in.remove(i);
				
				// Move all of the label values down
				for (Map.Entry<NativeCodeLabel, Integer> e :
					labels.entrySet())
				{
					int val = e.getValue();
					if (val > i)
						e.setValue(val - 1);
				}
			}
		}
		
		// Resulting tables of instructions
		int n = in.size();
		NativeInstruction[] tabni = new NativeInstruction[n];
		
		// Go through input instructions and map them to real instructions
		for (int i = 0; i < n; i++)
		{
			// Get input point
			Point point = in.get(i);
			
			// The instruction is re-processed potentially
			NativeInstruction inst = point.instruction;
			
			// Used to detect if the instruction actually changed
			boolean didchange = false;
			
			// Arguments may be re-translated if they contain jumps
			Object[] args = inst.arguments();
			for (int j = 0, jn = args.length; j < jn; j++)
			{
				Object a = args[j];
				
				// Map any labels to indexes
				if ((didchange |= (a instanceof NativeCodeLabel)))
				{
					// {@squirreljme.error JC0z The specified label was
					// never defined. (The label)}
					Integer rlp = labels.get((NativeCodeLabel)a);
					if (rlp == null)
						throw new IllegalArgumentException("JC0z " + a);
					
					args[j] = new InstructionJumpTarget(rlp);
				}
			}
			
			// If the instruction changed, use the new one
			tabni[i] = (didchange ? new NativeInstruction(inst.op, args) :
				inst);
		}
		
		// Build
		return new NativeCode(tabni);
	}
	
	/**
	 * Adds a label at the current position.
	 *
	 * @param __lo The locality.
	 * @param __dx The index.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(String __lo, int __dx)
	{
		return this.label(new NativeCodeLabel(__lo, __dx), this._nextaddr);
	}
	
	/**
	 * Adds a label.
	 *
	 * @param __lo The locality.
	 * @param __dx The index.
	 * @param __pc The address to target.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(String __lo, int __dx, int __pc)
	{
		return this.label(new NativeCodeLabel(__lo, __dx), __pc);
	}
	
	/**
	 * Adds a label at the current position.
	 *
	 * @param __l The label to add.
	 * @param __pc The address to target.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(NativeCodeLabel __l)
	{
		return this.label(__l, this._nextaddr);
	}
	
	/**
	 * Adds a label.
	 *
	 * @param __pc The address to target.
	 * @return The added label.
	 * @since 2019/03/22
	 */
	public final NativeCodeLabel label(NativeCodeLabel __l, int __pc)
	{
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("Label %s -> @%d", __l, __pc);
		
		// Add
		this._labels.put(__l, __pc);
		return __l;
	}
	
	/**
	 * Returns the target of the specified label.
	 *
	 * @param __n The label name.
	 * @param __dx The label index.
	 * @return The index of the instruction or {@code -1} if the label is not
	 * valid or the position is not yet known.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	public final int labelTarget(String __n, int __dx)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return this.labelTarget(new NativeCodeLabel(__n, __dx));
	}
	
	/**
	 * Returns the target of the specified label.
	 *
	 * @param __l The label to get the target of.
	 * @return The index of the instruction or {@code -1} if the label is not
	 * valid or the position is not yet known.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final int labelTarget(NativeCodeLabel __l)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		Integer rv = this._labels.get(__l);
		return (rv == null ? -1 : rv);
	}
	
	/**
	 * This stores the information for a single point in the native code.
	 *
	 * @since 2019/04/26
	 */
	public static final class Point
	{
		/** The instruction used. */
		public final NativeInstruction instruction;
		
		/**
		 * Initializes the instruction point.
		 *
		 * @param __i The instruction.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/26
		 */
		public Point(NativeInstruction __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.instruction = __i;
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeCodeLabel.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
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































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * Label which refers to a location in code.
 *
 * @since 2019/03/16
 */
public final class NativeCodeLabel
{
	/** The locality. */
	public final String locality;
	
	/** The associated address. */
	public final int address;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the lable.
	 *
	 * @param __l The locality.
	 * @param __a The address.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/16
	 */
	public NativeCodeLabel(String __l, int __a)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.locality = __l;
		this.address = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof NativeCodeLabel))
			return false;
		
		NativeCodeLabel o = (NativeCodeLabel)__o;
		return this.locality.equals(o.locality) &&
			this.address == o.address;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final int hashCode()
	{
		return (~this.locality.hashCode()) - this.address;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "@" + this.locality +
				":" + this.address));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeInstruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552








































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import java.util.Arrays;
import java.util.Collection;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a single instruction.
 *
 * @since 2019/03/22
 */
public final class NativeInstruction
{
	/** The operation. */
	protected final int op;
	
	/** The arguments. */
	final Object[] _args;
	
	/** String form. */
	private Reference<String> _string;
	
	/** Hash. */
	private int _hash;
	
	/**
	 * Initializes the temporary instruction.
	 *
	 * @param __op The operation.
	 * @param __args The arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeInstruction(int __op, Object... __args)
		throws NullPointerException
	{
		this.op = __op;
		this._args = (__args =
			(__args == null ? new Object[0] : __args.clone()));
		
		for (Object o : __args)
			if (o == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * Initializes the temporary instruction.
	 *
	 * @param __op The operation.
	 * @param __args The arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public NativeInstruction(int __op, Collection<Object> __args)
		throws NullPointerException
	{
		if (__args == null)
			throw new NullPointerException("NARG");
		
		this.op = __op;
		
		Object[] args = __args.<Object>toArray(new Object[__args.size()]);
		this._args = args;
		for (Object o : args)
			if (o == null)
				throw new NullPointerException("NARG");
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param __i The index of the argument.
	 * @return The argument.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @since 2019/03/24
	 */
	public Object argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not of the given type.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/23
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2019/03/23
	 */
	public final int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * Returns the argument format for the instruction.
	 *
	 * @return The argument format.
	 * @since 2018/04/16
	 */
	public final ArgumentFormat[] argumentFormat()
	{
		return NativeInstruction.argumentFormat(this.op);
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * Returns the encoding of this instruction.
	 *
	 * @return The instruction encoding.
	 * @since 2019/03/27
	 */
	public final int encoding()
	{
		return NativeInstruction.encoding(this.op);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(this instanceof NativeInstruction))
			return false;
		
		NativeInstruction o = (NativeInstruction)__o;
		return this.hashCode() == o.hashCode() &&
			this.op == o.op &&
			Arrays.equals(this._args, o._args);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = (this.op ^
				Arrays.asList(this._args).hashCode()));
		return rv;
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2018/03/23
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).intValue();
	}
	
	/**
	 * Returns the operation this instruction performs.
	 *
	 * @return The operation performed.
	 * @since 2019/03/23
	 */
	public final int operation()
	{
		return this.op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not a number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2018/03/23
	 */
	public short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				NativeInstruction.mnemonic(this.op) + ":" +
				Arrays.asList(this._args)));
		
		return rv;
	}
	
	/**
	 * Returns the argument count of the operation.
	 *
	 * @param __op The operation to get the argument count of.
	 * @return The number of used arguments.
	 * @throws InvalidInstructionException If the encoding is not known.
	 * @since 2019/03/27
	 */
	public static final int argumentCount(int __op)
		throws InvalidInstructionException
	{
		// Depends on the encoding
		switch (NativeInstruction.encoding(__op))
		{
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return 0;
			
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
			case NativeInstructionType.COPY:
			case NativeInstructionType.INVOKE:
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.STORE_POOL:
			case NativeInstructionType.SYSTEM_CALL:
				return 2;
					
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
			case NativeInstructionType.DEBUG_POINT:
			case NativeInstructionType.IF_ICMP:
			case NativeInstructionType.IFEQ_CONST:
			case NativeInstructionType.LOAD_FROM_INTARRAY:
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MATH_CONST_INT:
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.MEMORY_OFF_ICONST:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
			case NativeInstructionType.STORE_TO_INTARRAY:
				return 3;
				
			case NativeInstructionType.DEBUG_ENTRY:
				return 4;
			
			case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
				return 5;
				
				// {@squirreljme.error JC10 Unknown instruction argument
				// count.}
			default:
				throw new InvalidInstructionException("JC10 " + __op);
		}
	}
	
	
	/**
	 * Returns the argument format for the instruction.
	 *
	 * @param __op The operation to get the encoding of.
	 * @return The argument format.
	 * @since 2018/04/16
	 */
	public static final ArgumentFormat[] argumentFormat(int __op)
	{
		switch (NativeInstruction.encoding(__op))
		{
				// []
			case NativeInstructionType.BREAKPOINT:
			case NativeInstructionType.DEBUG_EXIT:
			case NativeInstructionType.RETURN:
				return ArgumentFormat.of();
				
				// [r16, reglist]
			case NativeInstructionType.SYSTEM_CALL:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.REGLIST);
				
				// [r16, r16]
			case NativeInstructionType.COPY:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG);
				
				// [r16, u16]
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
				
				// [p16, r16]
			case NativeInstructionType.LOAD_POOL:
			case NativeInstructionType.STORE_POOL:
				return ArgumentFormat.of(
					ArgumentFormat.VPOOL,
					ArgumentFormat.VUREG);
					
				// [p16, p16, p16, p16]
			case NativeInstructionType.DEBUG_ENTRY:
				return ArgumentFormat.of(
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL,
					ArgumentFormat.VPOOL);
				
				// [u16, u16, u16]
			case NativeInstructionType.DEBUG_POINT:
				return ArgumentFormat.of(
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT,
					ArgumentFormat.VUINT);
				
				// [r16, r16, u16]
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
				
				// [r16, r16, r16]
			case NativeInstructionType.LOAD_FROM_INTARRAY:
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.STORE_TO_INTARRAY:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG);
			
				// [r16, i32, r16]
			case NativeInstructionType.MATH_CONST_INT:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32,
					ArgumentFormat.VUREG);
				
				// [r16, r16, i32]
			case NativeInstructionType.MEMORY_OFF_ICONST:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32);
				
				// [r16, r16, j16]
			case NativeInstructionType.IF_ICMP:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VJUMP);
			
				// [r16, i32, j16]
			case NativeInstructionType.IFEQ_CONST:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.INT32,
					ArgumentFormat.VJUMP);
				
				// [reg w/ memaddr, reglist]
			case NativeInstructionType.INVOKE:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.REGLIST);
			
				// [r16 (check), r16 (get), r16 (set), r16 (addr), u16 (off)]
			case NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET:
				return ArgumentFormat.of(
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUREG,
					ArgumentFormat.VUINT);
		}
		
		// {@squirreljme.error JC11 Invalid operation. (The operation)}
		throw new InvalidInstructionException("JC11 " +
			NativeInstruction.mnemonic(__op));
	}
	
	/**
	 * Returns the encoding of the given instruction.
	 *
	 * @param __op The operation to get the encoding of.
	 * @return The encoding for the given operation.
	 * @since 2019/03/24
	 */
	public static final int encoding(int __op)
	{
		// Special operations all use unique encodings so just return their
		// opcode, while all of the other operations use one of the pre-defined
		// encodings.
		int upper = __op & 0xF0;
		if (upper == NativeInstructionType.SPECIAL_A ||
			upper == NativeInstructionType.SPECIAL_B)
			return __op;
		
		// Plain
		return upper;
	}
	
	/**
	 * Returns the mnemonic of the given operation.
	 *
	 * @param __op The operation to get.
	 * @return The mnemonic for the operation.
	 * @since 2019/04/07
	 */
	public static final String mnemonic(int __op)
	{
		switch (NativeInstruction.encoding(__op))
		{
			case NativeInstructionType.MATH_REG_INT:
			case NativeInstructionType.MATH_CONST_INT:
				return StackJavaType.of((__op >> 4) & 0x3).name() +
					"_" +
					MathType.of(__op & 0x0F).name() +
					"_" +
					(((__op & 0x80) != 0) ? "CONST" : "REG");
			
			case NativeInstructionType.IF_ICMP:
				{
					CompareType ct = CompareType.of(__op & 0x07);
					if (ct == CompareType.TRUE)
						return "GOTO";
					else if (ct == CompareType.FALSE)
						return "NOP";
					else
						return "IF_ICMP_" + ct.name();
				}
				
			case NativeInstructionType.MEMORY_OFF_REG:
			case NativeInstructionType.MEMORY_OFF_ICONST:
				return "MEM_" +
					(((__op & 0x08) != 0) ? "LOAD" : "STORE") +
					"_" +
					DataType.of(__op & 0x07).name() +
					"_" +
					(((__op & 0x80) != 0) ? "ICONST" : "REG");
			
			case NativeInstructionType.MEMORY_OFF_REG_JAVA:
			case NativeInstructionType.MEMORY_OFF_ICONST_JAVA:
				return "MEM_" +
					(((__op & 0x08) != 0) ? "LOAD" : "STORE") +
					"_" +
					DataType.of(__op & 0x07).name() +
					"_" +
					(((__op & 0x80) != 0) ? "ICONST" : "REG") +
					"_JAVA";
				
			case NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET:
				return "ATOMIC_INT_DECREMENT_AND_GET";
			case NativeInstructionType.ATOMIC_INT_INCREMENT:
				return "ATOMIC_INT_INCREMENT";
			case NativeInstructionType.BREAKPOINT:		return "BREAKPOINT";
			case NativeInstructionType.COPY:			return "COPY";
			case NativeInstructionType.DEBUG_ENTRY:		return "DEBUG_ENTRY";
			case NativeInstructionType.DEBUG_EXIT:		return "DEBUG_EXIT";
			case NativeInstructionType.DEBUG_POINT:		return "DEBUG_POINT";
			case NativeInstructionType.IFEQ_CONST:		return "IFEQ_CONST";
			case NativeInstructionType.INVOKE:			return "INVOKE";
			case NativeInstructionType.LOAD_POOL:		return "LOAD_POOL";
			case NativeInstructionType.LOAD_FROM_INTARRAY:
				return "LOAD_FROM_INTARRAY";
			case NativeInstructionType.RETURN:			return "RETURN";
			case NativeInstructionType.STORE_POOL:		return "STORE_POOL";
			case NativeInstructionType.STORE_TO_INTARRAY:
				return "STORE_TO_INTARRAY";
			case NativeInstructionType.SYSTEM_CALL:		return "SYSTEM_CALL";
			
			default:
				return String.format("UNKNOWN_%02x", __op);
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NativeInstructionType.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
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


































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * This represents a type of native instruction. Virtually all instructions
 * except for the special instructions are composed of groups.
 *
 * @since 2019/04/06
 */
public interface NativeInstructionType
{
	/**
	 * Math, R=RR, Integer.
	 * {@code iiiiMMMM, r3 = r1 ? r2}.
	 */
	public static final short MATH_REG_INT =
		0x00;
	
	/**
	 * Int comparison, then maybe jump.
	 * {@code iiiiRccc, if (r1 ? r2) jump->j3}.
	 */
	public static final short IF_ICMP =
		0x10;
	
	/**
	 * Memory access, offset is in register.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	public static final short MEMORY_OFF_REG =
		0x20;
	
	/**
	 * Memory access to big endian Java format, offset is in register.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	public static final short MEMORY_OFF_REG_JAVA =
		0x30;
	
	/**
	 * Math, R=RC, Integer.
	 * {@code iiiiMMMM, r3 = r1 ? c2}.
	 */
	public static final short MATH_CONST_INT =
		0x80;
	
	/**
	 * Memory access, offset is a constant.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	public static final short MEMORY_OFF_ICONST =
		0xA0;
	
	/**
	 * Memory access to big endian Java format, offset is a constant.
	 * {@code iiiiLddd, L=T load r1 = *(r2 + r3), L=F set *(r2 + r3) = r1}.
	 */
	public static final short MEMORY_OFF_ICONST_JAVA =
		0xB0;
	
	/**
	 * Special.
	 * {@code iiiixxxx}.
	 */
	public static final short SPECIAL_A =
		0xE0;
	
	/**
	 * Special.
	 * {@code iiiixxxx}.
	 */
	public static final short SPECIAL_B =
		0xF0;
	
	/** If equal to constant. */
	public static final short IFEQ_CONST =
		0xE6;
	
	/** Debug entry to method. */
	public static final short DEBUG_ENTRY =
		0xE8;
	
	/** Debug exit from method. */
	public static final short DEBUG_EXIT =
		0xE9;
	
	/** Debug single point in method. */
	public static final short DEBUG_POINT =
		0xEA;
	
	/**
	 * Return. 
	 * {@code iiiixxxx, return}.
	 */
	public static final short RETURN =
		0xF3;
	
	/**
	 * Store to pool, note that at code gen time this is aliased.
	 * {@code iiiixxxx}.
	 */
	public static final short STORE_POOL =
		0xF4;
	
	/** Store to integer array. */
	public static final short STORE_TO_INTARRAY =
		0xF5;
	
	/**
	 * Invoke. 
	 * {@code iiiixxxx}.
	 */
	public static final short INVOKE =
		0xF7;
	
	/** Copy value in register. */
	public static final short COPY =
		0xF8;
	
	/** Atomically decrements a memory addres and gets the value. */
	public static final short ATOMIC_INT_DECREMENT_AND_GET =
		0xF9;
	
	/** Atomically increments a memory address. */
	public static final short ATOMIC_INT_INCREMENT =
		0xFA;
	
	/** System call. */
	public static final short SYSTEM_CALL =
		0xFB;
	
	/** Atomic compare and set. */
	public static final short ATOMIC_COMPARE_GET_AND_SET =
		0xFC;
	
	/**
	 * Load from pool, note that at code gen time this is aliased.
	 * {@code iiiixxxx}.
	 */
	public static final short LOAD_POOL =
		0xFD;
	
	/** Load from integer array. */
	public static final short LOAD_FROM_INTARRAY =
		0xFE;
	
	/**
	 * Compare and exchange. 
	 * {@code iiiixxxx}.
	 */
	public static final short BREAKPOINT =
		0xFF;
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/NearNativeByteCodeHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import cc.squirreljme.jvm.ClassLoadingAdjustments;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallIndex;
import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.FieldAccessTime;
import dev.shadowtail.classfile.pool.FieldAccessType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.NotedString;
import dev.shadowtail.classfile.pool.NullPoolEntry;
import dev.shadowtail.classfile.pool.UsedString;
import dev.shadowtail.classfile.xlate.ByteCodeHandler;
import dev.shadowtail.classfile.xlate.ByteCodeState;
import dev.shadowtail.classfile.xlate.CompareType;
import dev.shadowtail.classfile.xlate.DataType;
import dev.shadowtail.classfile.xlate.ExceptionClassEnqueueAndTable;
import dev.shadowtail.classfile.xlate.ExceptionHandlerRanges;
import dev.shadowtail.classfile.xlate.ExceptionHandlerTransition;
import dev.shadowtail.classfile.xlate.ExceptionStackAndTable;
import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import dev.shadowtail.classfile.xlate.JavaStackResult;
import dev.shadowtail.classfile.xlate.JavaStackState;
import dev.shadowtail.classfile.xlate.MathType;
import dev.shadowtail.classfile.xlate.StackJavaType;
import dev.shadowtail.classfile.xlate.StateOperation;
import dev.shadowtail.classfile.xlate.StateOperations;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandler;
import net.multiphasicapps.classfile.ExceptionHandlerTable;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodReference;

/**
 * This contains the handler for the near native byte code.
 *
 * @since 2019/04/06
 */
public final class NearNativeByteCodeHandler
	implements ByteCodeHandler
{
	/** The jvm functions class. */
	public static final ClassName JVMFUNC_CLASS =
		new ClassName("cc/squirreljme/jvm/JVMFunction");
	
	/** State of the byte code. */
	public final ByteCodeState state =
		new ByteCodeState();
	
	/** Used to build native code. */
	protected final NativeCodeBuilder codebuilder =
		new NativeCodeBuilder();
	
	/** Default field access type, to determine how fields are accessed. */
	protected final FieldAccessTime defaultfieldaccesstime;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	
	/** Returning value? */
	protected final boolean isreturn;
	
	/** Returning wide value? */
	protected final boolean isreturnwide;
	
	/** Monitor target register used. */
	protected final int monitortarget;
	
	/** Volatile registers to use. */
	protected final VolatileRegisterStack volatiles;
	
	/** Standard exception handler table. */
	private final Map<ExceptionHandlerTransition, __EData__> _ehtable =
		new LinkedHashMap<>();
	
	/** Made exception table. */
	private final Map<ClassAndLabel, __EData__> _metable =
		new LinkedHashMap<>();
	
	/** The returns which have been performed. */
	private final List<JavaStackEnqueueList> _returns =
		new ArrayList<>();
	
	/** Java transition labels. */
	private final Map<StateOperationsAndTarget, __EData__> _transits =
		new LinkedHashMap<>();
	
	/** Reference clearing and jumping to label. */
	private final Map<EnqueueAndLabel, __EData__> _refcljumps =
		new LinkedHashMap<>();
	
	/** Last registers enqueued. */
	private JavaStackEnqueueList _lastenqueue;
	
	/** Next reference count/uncount ID number for jump. */
	private int _refclunk;
	
	/**
	 * Initializes the byte code handler.
	 *
	 * @param __bc The byte code.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public NearNativeByteCodeHandler(ByteCode __bc)
		throws NullPointerException
	{
		if (__bc == null)
			throw new NullPointerException("NARG");
		
		this.defaultfieldaccesstime = ((__bc.isInstanceInitializer() ||
			__bc.isStaticInitializer()) ? FieldAccessTime.INITIALIZER :
			FieldAccessTime.NORMAL);
		this.issynchronized = __bc.isSynchronized();
		this.isinstance = __bc.isInstance();
		
		// Determine monitor target register and the volatile base
		int volbase = NativeCode.ARGUMENT_REGISTER_BASE + 2 +
			__bc.maxLocals() + __bc.maxStack();
		this.monitortarget = volbase;
		this.volatiles = new VolatileRegisterStack(volbase + 1);
		
		// Returning values?
		this.isreturn = (__bc.type().returnValue() != null);
		this.isreturnwide = (isreturn && __bc.type().returnValue().isWide());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayLength(JavaStackResult.Input __in,
		JavaStackResult.Output __len)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// Read length
		codebuilder.addMemoryOffConst(DataType.INTEGER, true,
			__len.register,
			__in.register, Constants.ARRAY_LENGTH_OFFSET);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayLoad(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// Check array bounds
		this.__basicCheckArrayBound(__in.register, __dx.register);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// Grab some volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volaip = volatiles.get();
		
		// Determine array index position
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.MUL,
			__dx.register, __dt.size(), volaip);
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
			volaip, Constants.ARRAY_BASE_SIZE, volaip);
		
		// Use helper function
		if (__dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				__in.register, volaip);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
		}
		
		// Use native read
		else
			codebuilder.addMemoryOffReg(__dt, true,
				__v.register, __in.register, volaip);
		
		// Not used anymore
		volatiles.remove(volaip);
		
		// If reading an object reference count up!
		if (__dt == DataType.OBJECT)
			this.__refCount(__v.register);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doArrayStore(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Must be an array
		if (!__in.isArray())
			this.__basicCheckIsArray(__in.register);
		
		// Check array bounds
		this.__basicCheckArrayBound(__in.register, __dx.register);
		
		// Grab some volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volaip = volatiles.get();
		
		// Determine array index position
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.MUL,
			__dx.register, __dt.size(), volaip);
		codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
			volaip, Constants.ARRAY_BASE_SIZE, volaip);
		
		// If we are storing an object....
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __v.type.isObject()))
		{
			// Check if the array type is compatible
			this.__basicCheckArrayStore(__in.register, __v.register);
			
			// Count the object being stored
			this.__refCount(__v.register);
			
			// Read existing object so it can be uncounted later
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(DataType.INTEGER, true,
				voltemp, __in.register, volaip);
		}
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// Use helper function
		if (__dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.STATIC, JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				__in.register, volaip, __v.register, __v.register + 1);
		}
		
		// Store value
		else
			codebuilder.addMemoryOffReg(__dt, false,
				__v.register, __in.register, volaip);
		
		// Reference uncount old value
		if (isobject)
		{
			// Uncount old
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// No longer used
		volatiles.remove(volaip);
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doCheckCast(ClassName __cl, JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push reference
		this.__refPush();
		
		// If the value to be checked is null then we do not thrown an
		// exception, we just skip
		NativeCodeLabel nullskip = new NativeCodeLabel("checkcastnull",
			this._refclunk++);
		codebuilder.addIfZero(__v.register, nullskip);
		
		// Add cast check
		this.__basicCheckCCE(__v.register, __cl);
		
		// Null jump goes here
		codebuilder.label(nullskip);
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// We do not need to uncount whatever was pushed in because it would
		// be immediately pushed back onto the stack. The counts should only
		// be lowered if ClassCastException is to be thrown. Because otherwise
		// we will just end up collecting things on a normal refclear
		this.__refReset();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/26
	 */
	@Override
	public final void doClassObjectLoad(ClassName __cl,
		JavaStackResult.Output __out)
	{
		this.__loadClassObject(__cl, __out.register);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doConvert(StackJavaType __as,
		JavaStackResult.Input __a, StackJavaType __bs,
		JavaStackResult.Output __b)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Doing just a copy
		if (__as == __bs)
		{
			int a = __a.register,
				b = __b.register;
			
			if (__as.isWide())
			{
				codebuilder.addCopy(a, b);
				codebuilder.addCopy(a + 1, b + 1);
			}
			else
				codebuilder.addCopy(a, b);
		}
		
		// Otherwise a conversion
		else
		{
			// Get the software math class for the source type
			ClassName smc = __as.softwareMathClass();
			
			// Invoke converter method (which might be wide)
			if (__as.isWide())
				this.__invokeStatic(InvokeType.SYSTEM, smc,
					"to" + __bs.boxedType(), "(II)" + __bs.signature(),
					__a.register, __a.register + 1);
			else
				this.__invokeStatic(InvokeType.SYSTEM, smc,
					"to" + __bs.boxedType(), "(I)" + __bs.signature(),
					__a.register);
			
			// Read out return value
			int a = NativeCode.RETURN_REGISTER,
				b = __b.register;
			if (__bs.isWide())
			{
				codebuilder.addCopy(a, b);
				codebuilder.addCopy(a + 1, b + 1);
			}
			else
				codebuilder.addCopy(a, b);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doCopy(JavaStackResult.Input __in,
		JavaStackResult.Output __out)
	{
		// Push references, the dest may be overwritten
		this.__refPush();
		
		// Perform the copy, make sure to correctly handle wide copies!
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__in.type.isWide())
		{
			codebuilder.addCopy(__in.register, __out.register);
			codebuilder.addCopy(__in.register + 1, __out.register + 1);
		}
		else
			codebuilder.addCopy(__in.register, __out.register);
		
		// Clear references in the event it was overwritten
		this.__refClear();
	}
	
	/**
	 * Reads a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The output value.
	 * @since 2019/04/12
	 */
	public final void doFieldGet(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// The instance register
		int ireg = __i.register;
		
		// Cannot be null
		this.__basicCheckNPE(ireg);
		
		// Must be the given class
		if (!__i.isCompatible(__fr.className()))
			this.__basicCheckCCE(ireg, __fr.className());
		
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// Determine volatile registers
		VolatileRegisterStack volatiles = this.volatiles;
		int tempreg = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.INSTANCE, __fr, true), tempreg);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// Use helper function?
		if (dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				ireg, tempreg);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
		}
		
		// Read from memory
		else
			codebuilder.addMemoryOffReg(
				dt, true,
				__v.register, ireg, tempreg);
		
		// Count it up?
		if (__fr.memberType().isObject())
			this.__refCount(__v.register);
		
		// Not used anymore
		volatiles.remove(tempreg);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doFieldPut(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// The instance register
		int ireg = __i.register;
		
		// Cannot be null
		this.__basicCheckNPE(ireg);
		
		// Must be the given class
		if (!__i.isCompatible(__fr.className()))
			this.__basicCheckCCE(ireg, __fr.className());
			
		// We already checked the only valid exceptions, so do not perform
		// later handling!
		state.canexception = false;
		
		// Get volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volfioff = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.INSTANCE, __fr, false),
			volfioff);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// If we are storing an object, we need to uncount the value already
		// in this field
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __fr.memberType().isObject()))
		{
			// Count our own reference up
			this.__refCount(__v.register);
			
			// Read the value of the field for later clear
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(
				dt, true,
				voltemp, ireg, volfioff);
		}
		
		// Use helper function?
		if (dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				ireg, volfioff, __v.register, __v.register + 1);
		}
		
		// Write to memory
		else
			codebuilder.addMemoryOffReg(
				dt, false,
				__v.register, ireg, volfioff);
		
		// If we stored an object, reference count the field after it has
		// been written to
		if (isobject)
		{
			// Uncount
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// No longer used
		volatiles.remove(volfioff);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doIfICmp(CompareType __ct, JavaStackResult.Input __a,
		JavaStackResult.Input __b, InstructionJumpTarget __ijt)
	{
		// Push references if needed
		this.__refPush();
		
		// Add comparison
		this.codebuilder.addIfICmp(__ct, __a.register, __b.register,
			this.__labelJava(__ijt));
		
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doInstanceOf(ClassName __cl,
		JavaStackResult.Input __v, JavaStackResult.Output __o)
	{
		// Push reference
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcldx = volatiles.get();
		
		// Load desired class index type
		this.__loadClassInfo(__cl, volwantcldx);
		
		// Invoke helper method
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmIsInstance", "(II)I", __v.register, volwantcldx);
		
		// Use result
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __o.register);
		
		// No longer needed
		volatiles.remove(volwantcldx);
		
		// Clear references in the event it was overwritten
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/10
	 */
	@Override
	public final void doInvoke(InvokeType __t, MethodReference __r,
		JavaStackResult.Output __out, JavaStackResult.Input... __in)
	{
		// Target class
		ClassName targetclass = __r.handle().outerClass();
		
		// Invocation of assembly method?
		if ("cc/squirreljme/jvm/Assembly".equals(
			targetclass.toString()))
		{
			// Forward
			this.__invokeAssembly(__r.handle().name(),
				__r.handle().descriptor(), __out, __in);
			
			// Do nothing else
			return;
		}
		
		// Code generator
		NativeCodeBuilder codebuilder = this.codebuilder;
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Push references
		this.__refPush();
		
		// Fill in call arguments
		List<Integer> callargs = new ArrayList<>(__in.length * 2);
		for (int i = 0, n = __in.length; i < n; i++)
		{
			// Add the input register
			JavaStackResult.Input in = __in[i];
			callargs.add(in.register);
			
			// But also if it is wide, we need to pass the other one or
			// else the value will be clipped
			if (in.type.isWide())
				callargs.add(in.register + 1);
		}
		
		// Actual arguments to the call
		RegisterList reglist = new RegisterList(callargs);
		
		// If invoking static method, use our helper method
		MethodHandle mh = __r.handle();
		if (__t == InvokeType.STATIC)
		{
			this.__invokeStatic(__t, mh.outerClass(), mh.name(),
				mh.descriptor(), reglist);
		}
		
		// Interface, special, or virtual
		else
		{
			// Check that the object is of the given class type and is not null
			int ireg = __in[0].register;
			this.__basicCheckNPE(ireg);
			
			// Check types if this is not compatible
			if (!__in[0].isCompatible(__r.handle().outerClass()))
				this.__basicCheckCCE(ireg, __r.handle().outerClass());
			
			// Invoking interface method
			if (__t == InvokeType.INTERFACE)
			{
				// Load the interface we are looking in
				int voliclass = volatiles.get();
				this.__loadClassInfo(__r.handle().outerClass(), voliclass);
				
				// Load the method index of the volatile method in question
				int volimethdx = volatiles.get();
				codebuilder.add(NativeInstructionType.LOAD_POOL,
					new MethodIndex(__r.handle().outerClass(),
						__r.handle().name(), __r.handle().descriptor()),
					volimethdx);
				
				// Use helper method to find the method pointer to invoke
				// for this interface (hi=pool, lo=pointer)
				this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
					"jvmInterfacePointer", "(III)J",
					ireg, voliclass, volimethdx);
				
				// We need to extract the pool pointer of the class we
				// are calling in so that nothing is horribly incorrect
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
					NativeCode.NEXT_POOL_REGISTER);
				
				// Invoke the pointer that this method returned
				codebuilder.add(NativeInstructionType.INVOKE,
					NativeCode.RETURN_REGISTER, reglist);
				
				// Cleanup
				volatiles.remove(voliclass);
				volatiles.remove(volimethdx);
			}
			
			// Special or virtual
			else
			{
				// Invoke instance method
				this.__invokeInstance(__t, mh.outerClass(), mh.name(),
					mh.descriptor(), reglist);
			}
		}
		
		// Check if exception occurred, before copying the return value!
		if (state.canexception)
		{
			// Exception check
			codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				this.__labelException());
			
			// We did the exception handling, so do not handle later
			state.canexception = false;
		}
		
		// Read in return value, it is just a copy
		if (__out != null)
		{
			int a = NativeCode.RETURN_REGISTER,
				b = __out.register;
			
			if (__out.type.isWide())
				codebuilder.addCopy(a + 1, b + 1);
			codebuilder.addCopy(a, b);
		}
		
		// Clear references
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doLookupSwitch(JavaStackResult.Input __key,
		LookupSwitch __ls)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// The key register
		int keyreg = __key.register;
		
		// Generate checks for all keys
		int[] keys = __ls.keys();
		InstructionJumpTarget[] jumps = __ls.jumps();
		for (int i = 0, n = keys.length; i < n; i++)
			codebuilder.add(NativeInstructionType.IFEQ_CONST,
				keyreg, keys[i], this.__labelJava(jumps[i]));
		
		// Final case is the default jump
		codebuilder.addGoto(this.__labelJava(__ls.defaultJump()));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, JavaStackResult.Input __b,
		JavaStackResult.Output __c)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Integer math is supported natively
		if (__dt == StackJavaType.INTEGER)
		{
			// Check for division by zero, only the integer type can have this
			// done in code because the long can be handled by the software
			// math library code. Otherwise we would need to add more code to
			// the generator to handle this.
			if (__mt == MathType.DIV || __mt == MathType.REM)
			{
				// Perform divide by zero check
				this.__basicCheckDBZ(__b.register);
				
				// We already checked the only valid exceptions, so do not
				// perform later handling!
				state.canexception = false;
			}
			
			// Add math operation
			codebuilder.addMathReg(__dt, __mt, __a.register, __b.register,
				__c.register);
		}
		
		// Other kinds of math are done in software
		else
		{
			// Get the software math class for the type
			ClassName smc = __dt.softwareMathClass();
			
			// The function to call is just the lowercased enum
			String func = __mt.name().toLowerCase();
			
			// Remove the L/G from compare as that is only for float/double
			if (__dt == StackJavaType.LONG && func.startsWith("cmp"))
				func = "cmp";
			
			// Handling wide math?
			boolean iswide = __dt.isWide();
			
			// A, B, and C register
			int ah = __a.register,
				bh = __b.register,
				ch = __c.register;
			
			// Low registers
			int al = (ah == 0 ? 0 : ah + 1),
				bl = (bh == 0 ? 0 : bh + 1),
				cl = (ch == 0 ? 0 : ch + 1);
			
			// Determine the call signature
			String type = __mt.signature(__dt);
			RegisterList args;
			switch (__mt)
			{
				case NEG:
				case SIGNX8:
				case SIGNX16:
					if (iswide)
						args = new RegisterList(ah, al);
					else
						args = new RegisterList(ah);
					break;
				
				case SHL:
				case SHR:
				case USHR:
					if (iswide)
						args = new RegisterList(ah, al, bh);
					else
						args = new RegisterList(ah, bh);
					break;
				
				default:
					if (iswide)
						args = new RegisterList(ah, al, bh, bl);
					else
						args = new RegisterList(ah, bh);
					break;
			}
			
			// Perform the call
			this.__invokeStatic(InvokeType.SYSTEM, smc.toString(),
				func, type, args);
			
			// Read out return value
			if (iswide)
			{
				codebuilder.addCopy(NativeCode.RETURN_REGISTER, ch);
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, cl);
			}
			else
				codebuilder.addCopy(NativeCode.RETURN_REGISTER, ch);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, Number __b, JavaStackResult.Output __c)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// If we are dividing by zero just throw an exception
		if ((__dt == StackJavaType.INTEGER || __dt == StackJavaType.LONG) &&
			(__mt == MathType.DIV || __mt == MathType.REM))
			if (__b.longValue() == 0)
			{
				// Directly jump to the make exception handler
				codebuilder.addGoto(this.__labelMakeException(
					"java/lang/ArithmeticException"));
				
				// Already handled this
				state.canexception = false;
				
				// Since we are dividing by zero, never actually generate the
				// division code
				return;
			}
		
		// Integer math on constants is natively supported
		if (__dt == StackJavaType.INTEGER)
		{
			codebuilder.addMathConst(__dt, __mt, __a.register, __b,
				__c.register);
		}
		
		// Otherwise store the constant and then do register math on it
		else
		{
			// Need working registers, these must be next to each other!
			VolatileRegisterStack volatiles = this.volatiles;
			int volbh = -1, volbl = -7;
			while (volbl != (volbh + 1))
			{
				volbh = volatiles.get();
				volbl = volatiles.get();
			}
			
			// Read in raw value
			if (__b instanceof Float)
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, Float.floatToRawIntBits(__b.floatValue()), volbh);
			else if (__b instanceof Double)
			{
				long bits = Double.doubleToRawLongBits(__b.doubleValue());
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits >>> 32), volbh);
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits), volbl);
			}
			else
			{
				long bits = __b.longValue();
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits >>> 32), volbh);
				codebuilder.addMathConst(StackJavaType.INTEGER, MathType.OR,
					0, (int)(bits), volbl);
			}
			
			// Same as register math except the constant value is
			// virtualized now
			this.doMath(__dt, __mt,
				__a, new JavaStackResult.Input(volbh, JavaType.INTEGER, true),
				__c);
			
			// Cleanup
			volatiles.remove(volbh);
			volatiles.remove(volbl);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final void doMonitor(boolean __enter, JavaStackResult.Input __o)
	{
		// Push reference
		this.__refPush();
		
		// Generate instruction
		this.__monitor(__enter, __o.register);
		
		// Clear reference
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/04
	 */
	@Override
	public final void doMultiANewArray(ClassName __cl, int __numdims,
		JavaStackResult.Output __o, JavaStackResult.Input... __dims)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassobj = volatiles.get();
		
		// Load the class we want to allocate
		this.__loadClassObject(__cl, volclassobj);
		
		// Determine the number of integer arguments to use, since we
		// are passing multiple arguments to multianewarray
		StringBuilder sb = new StringBuilder(__numdims);
		for (int i = 0; i < __numdims; i++)
			sb.append('I');
			
		// Build arguments to the method call (class, skip, args);
		List<Integer> rl = new ArrayList<>();
		rl.add(volclassobj);
		rl.add(0);
		for (int i = 0; i < __numdims; i++)
			rl.add(__dims[i].register);
		
		// Invoke array utility
		this.__invokeStatic(InvokeType.SYSTEM,
			"cc/squirreljme/runtime/cldc/lang/ArrayUtils", "multiANewArray",
			"(Ljava/lang/Class;I" + sb + ")Ljava/lang/Object;",
			new RegisterList(rl));
		
		// Use this result
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __o.register);
		
		// Not needed anymore
		volatiles.remove(volclassobj);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doNew(ClassName __cn, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need result register
		VolatileRegisterStack volatiles = this.volatiles;
		int volresult = volatiles.get();
		
		// Perform new invocation
		this.__invokeNew(__cn, volresult);
		
		// Check for out of memory
		this.__basicCheckOOM(volresult);
		
		// All the exceptions were checked
		this.state.canexception = false;
		
		// Copy to result
		codebuilder.addCopy(volresult, __out.register);
		
		// Not needed
		volatiles.remove(volresult);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doNewArray(ClassName __at,
		JavaStackResult.Input __len, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Check for negative array size
		this.__basicCheckNAS(__len.register);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassdx = volatiles.get(),
			volresult = volatiles.get();
		
		// Load the class data for the array type
		// If not a fixed class index, then rely on the value in the pool
		this.__loadClassInfo(__at, volclassdx);
		
		// Call internal handler, place into temporary for OOM check
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS, "jvmNewArray",
			"(II)I", volclassdx, __len.register);
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, volresult);
		
		// No longer needed
		volatiles.remove(volclassdx);
		
		// Check for out of memory
		this.__basicCheckOOM(volresult);
		
		// All the exceptions were checked
		this.state.canexception = false;
		
		// Place result in true location
		codebuilder.addCopy(volresult, __out.register);
		
		// Not needed
		volatiles.remove(volresult);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doPoolLoad(Object __v, JavaStackResult.Output __out)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Loading string value?
		if (__v instanceof String)
		{
			// Need volatiles
			VolatileRegisterStack volatiles = this.volatiles;
			
			// Load the potentially cached string pointer
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				new UsedString((String)__v), __out.register);
			
			// Label to jump to if this string is already loaded
			NativeCodeLabel ispresent = new NativeCodeLabel("strloaded",
				this._refclunk++);
			codebuilder.addIfNonZero(__out.register, ispresent);
			
			// Load the noted string
			int volstrptr = volatiles.get();
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				new NotedString((String)__v), volstrptr);
				
			// Call internal string loader
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmLoadString", "(I)Ljava/lang/String;", volstrptr);
			
			// Cleanup
			volatiles.remove(volstrptr);
			
			// Store into the pull and copy the result as well
			codebuilder.add(NativeInstructionType.STORE_POOL,
				new UsedString((String)__v), NativeCode.RETURN_REGISTER);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER, __out.register);
			
			// String is loaded
			codebuilder.label(ispresent);
		}
		
		// Some other value
		else
			codebuilder.add(NativeInstructionType.LOAD_POOL,
				__v, __out.register);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doReturn(JavaStackResult.Input __in)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// If we are returning an object, we need to reference count it up
		// so it does not get garbage collected as a return is happening
		if (__in != null && __in.isObject())
			this.__refCount(__in.register);
		
		// Uncount all references that need to be cleared out as we return
		for (int q : this.state.result.enqueue())
			this.__refUncount(q);
		
		// Copy the returning value at the end to increase it's lifetime
		// as much as possible. Otherwise if we copy too early to the return
		// register then future uncounts can completely trash the value
		if (__in != null)
		{
			int a = __in.register,
				b = NativeCode.RETURN_REGISTER;
			
			// Copy value to return register
			if (__in.type.isWide())
				codebuilder.addCopy(a + 1, b + 1);
			codebuilder.addCopy(a, b);
		}
		
		// Do the return
		this.__generateReturn();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final void doStateOperations(StateOperations __ops)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		// If there are no operations, just do not bother
		if (__ops.isEmpty())
			return;
		
		// Generate code for the operations
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (StateOperation op : __ops)
			switch (op.type)
			{
				case UNCOUNT:
					this.__refUncount(op.a);
					break;
				
				case COUNT:
					this.__refCount(op.a);
					break;
				
				case COPY:
					codebuilder.addCopy(op.a, op.b);
					break;
				
				case WIDE_COPY:
					codebuilder.addCopy(op.a, op.b);
					codebuilder.addCopy(op.a + 1, op.b + 1);
					break;
				
				default:
					throw new todo.OOPS();
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doStaticGet(FieldReference __fr,
		JavaStackResult.Output __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Ignore thrown exceptions because field access is checked at link
		// time
		state.canexception = false;
		
		// Push references
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volsfo = volatiles.get();
		
		// Read static offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.STATIC, __fr, true),
			volsfo);
		
		// The datatype used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// Use helper function?
		if (dt.isWide())
		{
			// Read memory
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmMemReadLong", "(II)J",
				NativeCode.STATIC_FIELD_REGISTER, volsfo);
			
			// Copy return value
			codebuilder.addCopy(NativeCode.RETURN_REGISTER,
				__v.register);
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
				__v.register + 1);
		}
		
		// Read from memory
		else
			codebuilder.addMemoryOffReg(
				dt, true,
				__v.register, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		
		// Count it up?
		if (__fr.memberType().isObject())
			this.__refCount(__v.register);
		
		// Not needed
		volatiles.remove(volsfo);
			
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final void doStaticPut(FieldReference __fr,
		JavaStackResult.Input __v)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Ignore thrown exceptions because field access is checked at link
		// time
		state.canexception = false;

		// Push references
		this.__refPush();
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volsfo = volatiles.get();
		
		// Read field offset
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			this.__fieldAccess(FieldAccessType.STATIC, __fr, false),
			volsfo);
		
		// Data type used
		DataType dt = DataType.of(__fr.memberType().primitiveType());
		
		// If we are storing an object, we need to uncount the value already
		// in this field
		int voltemp = -1;
		boolean isobject;
		if ((isobject = __fr.memberType().isObject()))
		{
			// Count our own reference up
			this.__refCount(__v.register);
			
			// Read the value of the field for later clear
			voltemp = volatiles.get();
			codebuilder.addMemoryOffReg(
				dt, true,
				voltemp, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		}
		
		// Use helper function?
		if (dt.isWide())
		{
			// Write memory
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmMemWriteLong", "(IIII)V",
				NativeCode.STATIC_FIELD_REGISTER, volsfo,
				__v.register, __v.register + 1);
		}
		
		// Write to memory
		else
			codebuilder.addMemoryOffReg(
				dt, false,
				__v.register, NativeCode.STATIC_FIELD_REGISTER, volsfo);
		
		// If we wrote an object, uncount the old destination after it
		// has been overwritten
		if (isobject)
		{
			// Uncount
			this.__refUncount(voltemp);
			
			// Not needed
			volatiles.remove(voltemp);
		}
		
		// Not needed
		volatiles.remove(volsfo);
		
		// Clear references as needed
		this.__refClear();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final void doThrow(JavaStackResult.Input __in)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Push references
		this.__refPush();
		
		// Cannot be null
		this.__basicCheckNPE(__in.register);
		
		// Copy into the exception register
		codebuilder.addCopy(__in.register, NativeCode.EXCEPTION_REGISTER);
		
		// Clear the reference queue because this results in a net reference
		// count if this point is reached, however this is still needed for
		// the NPE check even though null values will never be counted
		this.__refReset();
		
		// Do not jump at this point, just return the exception check will be
		// flagged which will start the exception handling
		return;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public final void instructionFinish()
	{
		ByteCodeState state = this.state;
		
		// {@squirreljme.error JC12 Enqueues were not cleared, this is an
		// internal compiler error.}
		if (this._lastenqueue != null)
			throw new IllegalStateException("JC12");
		
		// An exception check was requested, do a check on the exception
		// register and jump if there is something there
		if (state.canexception)
			codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				this.__labelException());
		
		// If this instruction naturally flows into another, determine we
		// need to transition to that stack state in order to work properly
		// with any cached values
		if (state.instruction.hasNaturalFlow())
		{
			// Get following stack
			int followaddr = state.followaddr;
			JavaStackState nowstack = state.stack,
				followstack = state.stacks.get(followaddr);
			
			// If our current stack is not compatible with the target stack
			// then we need to transition to that state. However the Java label
			// code already handles transition, so do this to remove duplicate
			// code with just a minor jump around.
			// However if the next state is poisoned we do not do this because
			// we will just naturally transition to a pure de-cache at the
			// start of everything anyway.
			if (!nowstack.equals(followstack) &&
				!state.stackpoison.containsKey(followaddr))
				this.codebuilder.addGoto(
					this.__labelJava(new InstructionJumpTarget(followaddr)));
		}
		
		// Clear volatiles
		this.volatiles.clear();
	}
	
	/**
	 * Sets up before processing the instruction.
	 *
	 * @since 2019/04/07
	 */
	public final void instructionSetup()
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		ByteCodeState state = this.state;
		int addr = state.addr;
		
		// Clear volatiles
		this.volatiles.clear();
		
		// Entry point debugging
		if (addr == 0)
		{
			// Debug entry point
			codebuilder.add(NativeInstructionType.DEBUG_ENTRY,
				new NotedString(state.classname.toString()),
				new NotedString(state.methodname.toString()),
				new NotedString(state.methodtype.toString()),
				new NullPoolEntry());
			
			// Setup monitor entry
			if (this.issynchronized)
			{
				// Copy instance to monitor target
				if (this.isinstance)
					codebuilder.addCopy(state.stack.getLocal(0).register,
						this.monitortarget);
				
				// Load class object to monitor
				else
					this.__loadClassObject(state.classname,
						this.monitortarget);
				
				// Enter monitor on this
				this.__refCount(this.monitortarget);
				this.__monitor(true, this.monitortarget);
			}
		}
		
		// Debug single instruction point
		codebuilder.add(NativeInstructionType.DEBUG_POINT,
			state.line & 0x7FFF, state.instruction.operation() & 0xFF,
			state.instruction.address() & 0x7FFF);
		
		// Check if there are operations that need to be performed to make
		// sure the stack state is morphed into correctly
		StateOperations poison = state.stackpoison.get(addr);
		if (poison != null)
			this.doStateOperations(poison);
		
		// Setup a label for this current position, this is done after
		// potential flushing because it is assumed that the current state
		// is always valid even after a flush
		codebuilder.label("java", addr);
	}
	
	/**
	 * Returns the result of the translation.
	 *
	 * @return The translation result.
	 * @since 2019/04/07
	 */
	public final NativeCode result()
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		ByteCodeState state = this.state;
		List<JavaStackEnqueueList> returns = this._returns;
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Was an exception handler generated?
		boolean didehfall = false;
		
		// Generate reference clear jumps
		Map<EnqueueAndLabel, __EData__> refcljumps = this._refcljumps;
		for (Map.Entry<EnqueueAndLabel, __EData__> e : refcljumps.entrySet())
		{
			EnqueueAndLabel eql = e.getKey();
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 256);
			
			// Clear references
			JavaStackEnqueueList enq = eql.enqueue;
			for (int i = 0, n = enq.size(); i < n; i++)
				this.__refUncount(enq.get(i));
			
			// Then go to the target
			codebuilder.addGoto(eql.label);
		}
		
		// Generate make exception code
		Map<ClassAndLabel, __EData__> metable = this._metable;
		for (Map.Entry<ClassAndLabel, __EData__> e : metable.entrySet())
		{
			ClassAndLabel csl = e.getKey();
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 257);
			
			// Allocate class object, make sure it is not done in the exception
			// register because the method we call may end up just clearing it
			// and stopping if a make exception is done (because there is an
			// exception here).
			int exinst = volatiles.get();
			this.__invokeNew(csl.classname, exinst);
			
			// Initialize the exception
			this.__invokeInstance(InvokeType.SPECIAL, csl.classname, "<init>",
				"()V", new RegisterList(exinst));
			
			// Copy result into the exception register
			codebuilder.addCopy(exinst, NativeCode.EXCEPTION_REGISTER);
			
			// Done with this
			volatiles.remove(exinst);
			
			// Generate jump to exception handler
			codebuilder.addGoto(csl.label);
		}
		
		// Generate exception handler tables
		Map<ExceptionHandlerTransition, __EData__> ehtab = this._ehtable;
		for (Map.Entry<ExceptionHandlerTransition, __EData__> e :
			ehtab.entrySet())
		{
			ExceptionHandlerTransition ehtran = e.getKey();
			StateOperations sops = ehtran.handled;
			JavaStackEnqueueList enq = ehtran.nothandled;
			ExceptionHandlerTable ehtable = ehtran.table;
			
			// Label used for the jump target
			NativeCodeLabel lab = this.__useEDataAndGetLabel(e.getValue());
			this.__useEDataDebugPoint(e.getValue(), 258);
			
			// If the table is empty, just return
			if (ehtable.isEmpty())
			{
				// If we never saw a cleanup for this return yet we can
				// generate one here to be used for later points
				int rdx = returns.indexOf(enq);
				if (rdx < 0)
					codebuilder.label(lab,
						codebuilder.labelTarget(this.__generateReturn(enq)));
				
				// We can just alias this exception to the return point to
				// cleanup everything
				else
					codebuilder.label(lab,
						codebuilder.labelTarget("return", rdx));
				
				// Generate the next handler
				continue;
			}
			
			// Set label target for this one
			codebuilder.label(lab);
			
			// Go through and build the exception handler table
			for (ExceptionHandler eh : ehtable)
			{
				// Load the class type for the exception to check against
				int volehclassdx = volatiles.get();
				this.__loadClassInfo(eh.type(), volehclassdx);
				
				// Call instance handler check
				this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
					"jvmIsInstance", "(II)I",
					NativeCode.EXCEPTION_REGISTER, volehclassdx);
				
				// Cleanup
				volatiles.remove(volehclassdx);
				
				// If the return value is non-zero then it is an instance, in
				// which case we jump to the handler address.
				codebuilder.addIfNonZero(NativeCode.RETURN_REGISTER,
					this.__labelJavaTransition(sops,
						new InstructionJumpTarget(eh.handlerAddress())));
			}
			
			// No exception handler is available so, just fall through to the
			// caller as needed
			this.__generateReturn(enq);
			
			// Exception handler was generated
			didehfall = true;
		}
		
		// Generate transition labels
		Map<StateOperationsAndTarget, __EData__> trs = this._transits;
		for (Map.Entry<StateOperationsAndTarget, __EData__> e : trs.entrySet())
		{
			StateOperationsAndTarget sot = e.getKey();
			StateOperations ops = sot.operations;
			InstructionJumpTarget target = sot.target;
			
			// Set label target for this one
			codebuilder.label(this.__useEDataAndGetLabel(e.getValue()));
			this.__useEDataDebugPoint(e.getValue(), 259);
			
			// Generate operations
			this.doStateOperations(ops);
			
			// Then just jump to the Java target
			codebuilder.addGoto(new NativeCodeLabel("java", target.target()));
		}
		
		return codebuilder.build();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/06
	 */
	@Override
	public final ByteCodeState state()
	{
		return this.state;
	}
	
	/**
	 * Checks if an array access is within bounds.
	 *
	 * @param __ir The instance register.
	 * @param __dxr The index register.
	 * @since 2019/04/27
	 */
	private final void __basicCheckArrayBound(int __ir, int __dxr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// This label is shared across many conditions
		NativeCodeLabel lab = this.__labelMakeException(
			"java/lang/ArrayIndexOutOfBoundsException");
		
		// If the index is negative then it is out of bounds
		codebuilder.addIfICmp(CompareType.LESS_THAN, __dxr, 0, lab);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volarraylen = volatiles.get();
		
		// Read length of array
		codebuilder.addMemoryOffConst(DataType.INTEGER, true,
			volarraylen,
			__ir, Constants.ARRAY_LENGTH_OFFSET);
		
		// If the index is greater or equal to the length then the access
		// is invalid
		codebuilder.addIfICmp(CompareType.GREATER_THAN_OR_EQUALS,
			__dxr, volarraylen, lab);
		
		// No longer needed
		volatiles.remove(volarraylen);
	}
	
	/**
	 * Checks if the target array can store this value.
	 *
	 * @param __ir The instance register.
	 * @param __vr The value register.
	 * @since 2019/04/27
	 */
	private final void __basicCheckArrayStore(int __ir, int __vr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Call helper class
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmCanArrayStore", "(II)I", __ir, __vr);
		
		// Was it invalid?
		codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelMakeException("java/lang/ArrayStoreException"));
	}
	
	/**
	 * Basic check if the instance is of the given class.
	 *
	 * @param __ir The register to check.
	 * @param __cl The class to check.
	 * @since 2019/04/22
	 */
	private final void __basicCheckCCE(int __ir, ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
			
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcldx = volatiles.get();
		
		// Load desired target class type
		this.__loadClassInfo(__cl, volwantcldx);
		
		// Call helper class
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmIsInstance", "(II)I", __ir, volwantcldx);
		
		// If the resulting method call returns zero then it is not an instance
		// of the given class. The return register is checked because the
		// value of that method will be placed there.
		codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelRefClearJump(this.__labelMakeException(
			"java/lang/ClassCastException")));
		
		// No longer needed
		volatiles.remove(volwantcldx);
	}
	
	/**
	 * Checks for divide by zero.
	 *
	 * @param __br The B register.
	 * @since 2019/06/24
	 */
	private final void __basicCheckDBZ(int __br)
	{
		// If the B register is zero, then we throw the exception
		codebuilder.addIfZero(__br, this.__labelMakeException(
			"java/lang/ArithmeticException"));
	}
	
	/**
	 * Checks that the given object is an array.
	 *
	 * @param __ir The type to check.
	 * @since 2019/04/27
	 */
	private final void __basicCheckIsArray(int __ir)
	{
		// Call internal helper
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS, "jvmIsArray",
			"(I)I", __ir);
		
		// If this is not an array, throw a class cast exception
		codebuilder.addIfZero(NativeCode.RETURN_REGISTER,
			this.__labelRefClearJump(this.__labelMakeException(
			"java/lang/ClassCastException")));
	}
	
	/**
	 * Checks if the requested array allocation is negative.
	 *
	 * @param __lr The length register.
	 * @since 2019/06/28
	 */
	private final void __basicCheckNAS(int __lr)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Check against less than zero
		codebuilder.addIfICmp(CompareType.LESS_THAN,
			__lr, NativeCode.ZERO_REGISTER, this.__labelRefClearJump(
			this.__labelMakeException(
				"java/lang/NegativeArraySizeException")));
	}
	
	/**
	 * Basic check if the instance is null.
	 *
	 * @param __ir The register to check.
	 * @since 2019/04/22
	 */
	private final void __basicCheckNPE(int __ir)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Just a plain zero check
		codebuilder.addIfZero(__ir, this.__labelRefClearJump(
			this.__labelMakeException("java/lang/NullPointerException")));
	}
	
	/**
	 * Checks if the given allocation ran out of memory.
	 *
	 * @param __ir The register to check.
	 * @since 2019/06/28
	 */
	private final void __basicCheckOOM(int __ir)
	{
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Just a plain zero check
		codebuilder.addIfZero(__ir, this.__labelRefClearJump(
			this.__labelMakeException("java/lang/OutOfMemoryError")));
	}
	
	/**
	 * Makes an EData for the current position and label.
	 *
	 * @param __lab The stored label.
	 * @return The made EData.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/26
	 */
	private final __EData__ __eData(NativeCodeLabel __lab)
		throws NullPointerException
	{
		if (__lab == null)
			throw new NullPointerException("NARG");
		
		ByteCodeState state = this.state;
		return new __EData__(state.addr, state.line,
			state.instruction.address(), state.instruction.operation(), __lab);
	}
	
	/**
	 * Generates an access to a field.
	 *
	 * @param __at The type of access to perform.
	 * @param __fr The reference to the field.
	 * @param __read Is a read being performed?
	 * @return The accessed field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	private final AccessedField __fieldAccess(FieldAccessType __at,
		FieldReference __fr, boolean __read)
		throws NullPointerException
	{
		if (__at == null || __fr == null)
			throw new NullPointerException("NARG");
		
		// Accessing final fields of another class will always be treated as
		// normal despite being in the constructor of a class
		if (!state.classname.equals(__fr.className()))
			return new AccessedField((__read ? FieldAccessTime.READ :
				FieldAccessTime.NORMAL), __at, __fr);
		return new AccessedField((__read ? FieldAccessTime.READ :
			this.defaultfieldaccesstime), __at, __fr);
	}
	
	/**
	 * Generates or jumps to another return point.
	 *
	 * @return The label to this return point.
	 * @since 2019/04/11
	 */
	private final NativeCodeLabel __generateReturn()
	{
		return this.__generateReturn(this.state.stack.possibleEnqueue());
	}
	
	/**
	 * Generates or jumps to another return point for the given enqueue.
	 *
	 * @param __eq The enqueue to return for.
	 * @return The label to this return point.
	 * @throws NullPointerException On null arguments.
	 * @return
	 */
	private final NativeCodeLabel __generateReturn(JavaStackEnqueueList __eq)
		throws NullPointerException
	{
		if (__eq == null)
			throw new NullPointerException("NARG");
		
		// Will be used to generate safe spots
		VolatileRegisterStack volatiles = this.volatiles;
		int ssh = -1,
			ssl = -1;
		
		// Find unique return point
		boolean freshdx;
		List<JavaStackEnqueueList> returns = this._returns;
		int dx = returns.indexOf(__eq);
		if ((freshdx = (dx < 0)))
			returns.add((dx = returns.size()), __eq);
		
		// Label used for return
		NativeCodeLabel lb = new NativeCodeLabel("return", dx);
		
		// If this was never added here, make sure a label exists
		if (freshdx)
			codebuilder.label(lb);
		
		// If the enqueue list is empty then the only thing we need to do
		// is generate a return instruction
		NativeCodeBuilder codebuilder = this.codebuilder;
		if (__eq.isEmpty())
		{
			// If this is synchronized, we need to exit the monitor
			if (this.issynchronized)
			{
				// Protect return value, if there is one
				if (isreturn)
				{
					ssh = volatiles.get();
					codebuilder.addCopy(NativeCode.RETURN_REGISTER, ssh);
				}
				
				// And wide value, if any
				if (isreturnwide)
				{
					ssl = volatiles.get();
					codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, ssl);
				}
				
				// Uncount and clear out
				this.__monitor(false, this.monitortarget);
				this.__refUncount(this.monitortarget);
				
				// Recover value, if any
				if (isreturn)
				{
					codebuilder.addCopy(ssh, NativeCode.RETURN_REGISTER);
					volatiles.remove(ssh);
				}
				
				// Recover wide, if any
				if (isreturnwide)
				{
					codebuilder.addCopy(ssl, NativeCode.RETURN_REGISTER + 1);
					volatiles.remove(ssl);
				}
			}
			
			// Debug exit
			codebuilder.add(NativeInstructionType.DEBUG_EXIT);
			
			// Since there is nothing to uncount, just return
			codebuilder.add(NativeInstructionType.RETURN);
			
			return lb;
		}
		
		// If we are not making a fresh index there more things to clear out
		// then just jump to the pre-existing return point
		if (!freshdx && __eq.size() > 1)
		{
			// Jump to label
			codebuilder.addGoto(lb);
			
			return lb;
		}
		
		// Protect return value, if there is one
		if (isreturn)
		{
			ssh = volatiles.get();
			codebuilder.addCopy(NativeCode.RETURN_REGISTER, ssh);
		}
		
		// And wide value, if any
		if (isreturnwide)
		{
			ssl = volatiles.get();
			codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, ssl);
		}
		
		// Since the enqueue list is not empty, we can just trim a register
		// from the top and recursively go down
		// So uncount the top
		this.__refUncount(__eq.top());
		
		// Recover value, if any
		if (isreturn)
		{
			codebuilder.addCopy(ssh, NativeCode.RETURN_REGISTER);
			volatiles.remove(ssh);
		}
		
		// Recover wide, if any
		if (isreturnwide)
		{
			codebuilder.addCopy(ssl, NativeCode.RETURN_REGISTER + 1);
			volatiles.remove(ssl);
		}
		
		// Recursively go down since the enqueues may possibly be shared, if
		// any of these enqueues were previously made then the recursive
		// call will just make a goto
		this.__generateReturn(__eq.trimTop());
		
		// Note that we do not return the recursive result because that
		// will be for another enqueue state
		return lb;
	}
	
	/**
	 * Invokes an assembly method.
	 *
	 * @param __name The method name.
	 * @param __type The method type.
	 * @param __out The result.
	 * @param __in The input.
	 * @throws NullPointerException If no name or type were specified.
	 * @since 2019/05/24
	 */
	private final void __invokeAssembly(MethodName __name,
		MethodDescriptor __type, JavaStackResult.Output __out,
		JavaStackResult.Input... __in)
		throws NullPointerException
	{
		if (__name == null || __type == null)
			throw new NullPointerException("NARG");
		
		// Code generator
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Force exception cancel for these operations
		this.state.canexception = false;
		
		// Depends on the assembly function
		String asmfunc;
		switch ((asmfunc = __name.toString()))
		{
				// Read lenght of array
			case "arrayLength":
				this.doArrayLength(__in[0], __out);
				break;
				
				// Atomic compare, get and set
			case "atomicCompareGetAndSet":
				codebuilder.add(
					NativeInstructionType.ATOMIC_COMPARE_GET_AND_SET,
						__in[0].register,
						__out.register,
						__in[1].register,
						__in[2].register,
						0);
				break;
				
				// Atomic decrement and get
			case "atomicDecrementAndGet":
				codebuilder.add(
					NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
						__out.register,
						__in[0].register,
						0);
				break;
				
				// Atomic increment
			case "atomicIncrement":
				codebuilder.add(
					NativeInstructionType.ATOMIC_INT_INCREMENT,
						__in[0].register,
						0);
				break;
				
				// Breakpoint
			case "breakpoint":
				codebuilder.add(NativeInstructionType.BREAKPOINT);
				break;
				
				// Load boolean class
			case "classInfoOfBoolean":
				this.__loadClassInfo("boolean", __out.register);
				break;
				
				// Load byte class
			case "classInfoOfByte":
				this.__loadClassInfo("byte", __out.register);
				break;
				
				// Load short class
			case "classInfoOfShort":
				this.__loadClassInfo("short", __out.register);
				break;
				
				// Load character class
			case "classInfoOfCharacter":
				this.__loadClassInfo("char", __out.register);
				break;
				
				// Load int class
			case "classInfoOfInteger":
				this.__loadClassInfo("int", __out.register);
				break;
				
				// Load float class
			case "classInfoOfFloat":
				this.__loadClassInfo("float", __out.register);
				break;
				
				// Load long class
			case "classInfoOfLong":
				this.__loadClassInfo("long", __out.register);
				break;
				
				// Load double class
			case "classInfoOfDouble":
				this.__loadClassInfo("double", __out.register);
				break;
				
				// Long/Double bits
			case "doubleToRawLongBits":
			case "longBitsToDouble":
				if (__in[0].register != __out.register)
				{
					int a = __in[0].register,
						b = __out.register;
					
					codebuilder.addCopy(a, b);
					codebuilder.addCopy(a + 1, b + 1);
				}
				break;
				
				// Exception handling
			case "exceptionHandle":
				// This generates no actual codes to check the exception,
				// it just makes the exception check run so that they are
				// checked
				this.state.canexception = true;
				break;
				
				// Integer/Float bits
			case "floatToRawIntBits":
			case "intBitsToFloat":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// Invoke method (possibly return a value)
			case "invoke":
			case "invokeV":
			case "invokeVL":
				{
					// Invoked methods can thrown an exception, so do
					// checks! Otherwise the behavior we expect might not
					// happen
					this.state.canexception = true;
					
					// Build the register List
					List<Integer> args = new ArrayList<>();
					int n = __in.length;
					for (int i = 2; i < n; i++)
						args.add(__in[i].register);
					
					// Before we invoke we need to set the next pool so
					// execution is correct!
					codebuilder.addCopy(__in[1].register,
						NativeCode.NEXT_POOL_REGISTER);
					
					// Invoke pointer with arguments
					codebuilder.add(NativeInstructionType.INVOKE,
						__in[0].register, new RegisterList(args));
					
					// Copy return value?
					switch (asmfunc)
					{
						case "invokeV":
							codebuilder.addCopy(NativeCode.RETURN_REGISTER,
									__out.register);
							break;
							
						case "invokeVL":
							codebuilder.addCopy(NativeCode.RETURN_REGISTER,
									__out.register);
							codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
								__out.register + 1);
							break;
					}
				}
				break;
				
				// Double/Long pack
			case "doublePack":
			case "longPack":
				if (__in[1].register != __out.register + 1)
					codebuilder.addCopy(__in[1].register, __out.register + 1);
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
			
				// Long unpack high
			case "longUnpackHigh":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// Long unpack low
			case "longUnpackLow":
				if (__in[0].register + 1 != __out.register)
					codebuilder.addCopy(__in[0].register + 1, __out.register);
				break;
				
				// Read byte memory
			case "memReadByte":
				codebuilder.addMemoryOffReg(DataType.BYTE,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read int memory
			case "memReadInt":
				codebuilder.addMemoryOffReg(DataType.INTEGER,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read java int memory
			case "memReadJavaInt":
				codebuilder.addMemoryOffRegJava(DataType.INTEGER,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read short memory
			case "memReadJavaShort":
				codebuilder.addMemoryOffRegJava(DataType.SHORT,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Read short memory
			case "memReadShort":
				codebuilder.addMemoryOffReg(DataType.SHORT,
					true, __out.register,
					__in[0].register, __in[1].register);
				break;
				
				// Write byte memory
			case "memWriteByte":
				codebuilder.addMemoryOffReg(DataType.BYTE,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write int memory
			case "memWriteInt":
				codebuilder.addMemoryOffReg(DataType.INTEGER,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write Java int memory
			case "memWriteJavaInt":
				codebuilder.addMemoryOffRegJava(DataType.INTEGER,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write Java short memory
			case "memWriteJavaShort":
				codebuilder.addMemoryOffRegJava(DataType.SHORT,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
				
				// Write short memory
			case "memWriteShort":
				codebuilder.addMemoryOffReg(DataType.SHORT,
					false, __in[2].register,
					__in[0].register, __in[1].register);
				break;
			
				// object -> pointer
			case "objectToPointer":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				break;
				
				// object -> pointer, with ref clear
			case "objectToPointerRefQueue":
				// Push references
				this.__refPush();
				
				// Do the copy
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				
				// Clear references
				this.__refClear();
				break;
			
				// pointer -> object (and variants)
			case "pointerToObject":
			case "pointerToClassInfo":
				if (__in[0].register != __out.register)
					codebuilder.addCopy(__in[0].register, __out.register);
				
				// The returned object is electable for reference
				// counting so we need to count it up otherwise it will
				// be just freed (this is just a plain copy)
				this.__refCount(__out.register);
				break;
				
				// Reference count up
			case "refCount":
				this.__refCount(__in[0].register);
				break;
				
				// Reference count down
			case "refUncount":
				this.__refUncount(__in[0].register);
				break;
				
				// Return from frame
			case "returnFrame":
				// This may be a variant which returns multiple values
				switch (__type.toString())
				{
					case "(II)V":
						codebuilder.addCopy(__in[0].register,
							NativeCode.RETURN_REGISTER);
						codebuilder.addCopy(__in[1].register,
							NativeCode.RETURN_REGISTER + 1);
						break;
						
					case "(I)V":
						codebuilder.addCopy(__in[0].register,
							NativeCode.RETURN_REGISTER);
						break;
				}
				
				// Always return at the end
				this.__generateReturn();
				break;
				
				// Get the exception register
			case "specialGetExceptionRegister":
				codebuilder.addCopy(NativeCode.EXCEPTION_REGISTER,
					__out.register);
				break;
				
				// Gets the pool register
			case "specialGetPoolRegister":
				codebuilder.addCopy(NativeCode.POOL_REGISTER,
					__out.register);
				break;
				
				// Read return register
			case "specialGetReturnRegister":
			case "specialGetReturnHighRegister":
				codebuilder.addCopy(NativeCode.RETURN_REGISTER,
					__out.register);
				break;
				
				// Read return register (low value)
			case "specialGetReturnLowRegister":
				codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
					__out.register);
				break;
				
				// Get static field register
			case "specialGetStaticFieldRegister":
				codebuilder.addCopy(NativeCode.STATIC_FIELD_REGISTER,
					__out.register);
				break;
				
				// Get thread register
			case "specialGetThreadRegister":
				codebuilder.addCopy(NativeCode.THREAD_REGISTER,
					__out.register);
				break;
				
				// Set the exception register
			case "specialSetExceptionRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.EXCEPTION_REGISTER);
				break;
				
				// Set pool register
			case "specialSetPoolRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.POOL_REGISTER);
				break;
				
				// Set static field register
			case "specialSetStaticFieldRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.STATIC_FIELD_REGISTER);
				break;
				
				// Set thread register
			case "specialSetThreadRegister":
				codebuilder.addCopy(__in[0].register,
					NativeCode.THREAD_REGISTER);
				break;
				
				// System calls
			case "sysCall":
			case "sysCallV":
				this.__invokeSysCall(false, false, __out, __in);
				break;
				
				// System calls (long return value)
			case "sysCallVL":
				this.__invokeSysCall(false, true, __out, __in);
				break;
				
				// Pure system calls
			case "sysCallP":
			case "sysCallPV":
				this.__invokeSysCall(true, false, __out, __in);
				break;
				
				// Pure system calls (long return value)
			case "sysCallPVL":
				this.__invokeSysCall(true, true, __out, __in);
				break;
			
			default:
				throw new todo.OOPS(asmfunc);
		}
	}
	
	/**
	 * Invokes instance method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeInstance(InvokeType __it, ClassName __cl,
		String __mn, String __mt, RegisterList __args)
		throws NullPointerException
	{
		this.__invokeInstance(__it, __cl, new MethodName(__mn),
			new MethodDescriptor(__mt), __args);
	}
	
	/**
	 * Invokes instance method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeInstance(InvokeType __it, ClassName __cl,
		MethodName __mn, MethodDescriptor __mt, RegisterList __args)
		throws NullPointerException
	{
		if (__it == null || __cl == null || __mn == null || __mt == null ||
			__args == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatiles to work with
		VolatileRegisterStack volatiles = this.volatiles;
		int volclassid = volatiles.get(),
			volvtable = volatiles.get(),
			methodptr = volatiles.get(),
			volptable = volatiles.get();
		
		// Special invocation?
		boolean isspecial = (__it == InvokeType.SPECIAL);
		
		// Performing a special invoke which has some modified rules
		if (isspecial)
		{
			// Are we calling a constructor?
			boolean wantcons = __mn.isInstanceInitializer();
			
			// Is the target in this same class?
			boolean sameclass = __cl.equals(this.state.classname);
			
			// Use the exactly specified method if:
			//  * It is an initializer, we want to call that exact one
			//  * The target class is the same class of the current class
			//    being processed (private method)
			if (wantcons || sameclass)
				this.__loadClassInfo(__cl, volclassid);
			
			// Otherwise, we will be calling a super method so we need to load
			// the super class of our current class
			else
			{
				// Read the super class of our current class
				int volscfo = volatiles.get();
				codebuilder.add(NativeInstructionType.LOAD_POOL,
					new AccessedField(FieldAccessTime.NORMAL,
						FieldAccessType.INSTANCE,
					new FieldReference(
						new ClassName("cc/squirreljme/jvm/ClassInfo"),
						new FieldName("superclass"),
						new FieldDescriptor(
							"Lcc/squirreljme/jvm/ClassInfo;"))),
					volvtable);
				codebuilder.addMemoryOffReg(DataType.INTEGER, true,
					volclassid, volclassid, volscfo);
				
				// Cleanup
				volatiles.remove(volscfo);
			}
		}
		
		// Otherwise, we will purely act on the class of the instance type
		else
			codebuilder.addMemoryOffReg(DataType.INTEGER, true,
				volclassid, __args.get(0), Constants.OBJECT_CLASS_OFFSET);
		
		// Load the VTable (from the class we obtained above)
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("vtablevirtual"),
				new FieldDescriptor("[I"))),
			volvtable);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volvtable, volclassid, volvtable);
		
		// Load the pool table which is mapped with the vtable
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("vtablepool"),
				new FieldDescriptor("[I"))),
			volptable);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volptable, volclassid, volptable);
		
		// Method index
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new MethodIndex(__cl, __mn, __mt), methodptr);
			
		// Load from the pool table
		codebuilder.add(NativeInstructionType.LOAD_FROM_INTARRAY,
			NativeCode.NEXT_POOL_REGISTER, volptable, methodptr);
		
		// Load method pointer (from integer based array)
		codebuilder.add(NativeInstructionType.LOAD_FROM_INTARRAY,
			methodptr, volvtable, methodptr);
		
		// Invoke the method pointer
		codebuilder.add(NativeInstructionType.INVOKE,
			methodptr, __args);
		
		// Cleanup volatiles
		volatiles.remove(volclassid);
		volatiles.remove(volvtable);
		volatiles.remove(methodptr);
		volatiles.remove(volptable);
	}
	
	/**
	 * Allocates a new object.
	 *
	 * @param __cl The class to create.
	 * @param __out The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeNew(ClassName __cl, int __out)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need a volatile
		VolatileRegisterStack volatiles = this.volatiles;
		int volwantcl = volatiles.get();
		
		// Load class data
		this.__loadClassInfo(__cl, volwantcl);
		
		// Call allocator, copy to result
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS, "jvmNew",
			"(I)I", volwantcl);
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __out);
		
		// Not needed
		volatiles.remove(volwantcl);
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, String __cl,
		String __mn, String __mt, int... __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, new ClassName(__cl), new MethodName(__mn),
			new MethodDescriptor(__mt), new RegisterList(__args));
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, String __cl,
		String __mn, String __mt, RegisterList __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, new ClassName(__cl), new MethodName(__mn),
			new MethodDescriptor(__mt), __args);
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, ClassName __cl,
		String __mn, String __mt, int... __args)
		throws NullPointerException
	{
		this.__invokeStatic(__it, __cl, new MethodName(__mn),
			new MethodDescriptor(__mt), new RegisterList(__args));
	}
	
	/**
	 * Invokes static method, doing the needed pool loading and all the
	 * complicated stuff in a simple point of code.
	 *
	 * @param __it The invocation type.
	 * @param __cl The class name.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @param __args The arguments to the call.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/24
	 */
	private final void __invokeStatic(InvokeType __it, ClassName __cl,
		MethodName __mn, MethodDescriptor __mt, RegisterList __args)
		throws NullPointerException
	{
		if (__it == null || __cl == null || __mn == null || __mt == null ||
			__args == null)
			throw new NullPointerException("NARG");
		
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Need volatile
		VolatileRegisterStack volatiles = this.volatiles;
		int volsmp = volatiles.get(),
			volexe = volatiles.get();
		
		// Load address of the target method
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new InvokedMethod((__it == InvokeType.SYSTEM ? InvokeType.STATIC :
			__it), new MethodHandle(__cl, __mn, __mt)), volsmp);
		
		// Load constant pool of the target class
		this.__loadClassPool(__cl, NativeCode.NEXT_POOL_REGISTER);
		
		// Create a backup of the exception register (system mode)
		if (__it == InvokeType.SYSTEM)
		{
			codebuilder.addCopy(NativeCode.EXCEPTION_REGISTER, volexe);
			codebuilder.addCopy(NativeCode.ZERO_REGISTER,
				NativeCode.EXCEPTION_REGISTER);
		}
		
		// Invoke the static pointer
		codebuilder.add(NativeInstructionType.INVOKE,
			volsmp, __args);
		
		// If the system invoke (which could be from special code) threw an
		// exception just replace our current exception with that one since
		// it definitely would be worse!
		if (__it == InvokeType.SYSTEM)
		{
			NativeCodeLabel doublefault = new NativeCodeLabel(
				"doublefault", this._refclunk++);
			codebuilder.addIfNonZero(NativeCode.EXCEPTION_REGISTER,
				doublefault);
			
			// Restore our old exception register
			codebuilder.addCopy(volexe, NativeCode.EXCEPTION_REGISTER);
			
			// Target point for double fault
			codebuilder.label(doublefault);
		}
		
		// Not needed
		volatiles.remove(volexe);
		volatiles.remove(volsmp);
	}
	
	/**
	 * Invokes a system call, which can either be pure or unpure.
	 *
	 * @param __pure Is the system call pure?
	 * @param __long Is this a long system call?
	 * @param __out The return register, may be set.
	 * @param __in The input system call arguments.
	 * @since 2109/05/27
	 */
	private final void __invokeSysCall(boolean __pure, boolean __long,
		JavaStackResult.Output __out, JavaStackResult.Input... __in)
	{
		// Invoked methods can thrown an exception, so do
		// checks! Otherwise the behavior we expect might not
		// happen
		this.state.canexception = true;
		
		// Invoke of pure system call?
		if (__pure)
		{
			// Build the register List
			List<Integer> args = new ArrayList<>();
			int n = __in.length;
			for (int i = 1; i < n; i++)
				args.add(__in[i].register);
			
			// Perform the pure call
			codebuilder.add(NativeInstructionType.SYSTEM_CALL,
				__in[0].register, new RegisterList(args));
			
			// Need to store the return value of this call
			VolatileRegisterStack volatiles = this.volatiles;
			int rvlo = volatiles.get(),
				rvhi = volatiles.get();
			
			// Defensive copy of return value
			if (__out != null)
			{
				// Low
				codebuilder.addCopy(NativeCode.RETURN_REGISTER, rvlo);
				
				// High
				if (__long)
					codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1, rvhi);
			}
			
			// Load the system call index for IPC exception store
			int ipcesid = volatiles.get();
			codebuilder.addMathConst(StackJavaType.INTEGER, MathType.ADD,
				NativeCode.ZERO_REGISTER, SystemCallIndex.EXCEPTION_STORE,
				ipcesid);
			
			// Perform system call to clear and read exception
			codebuilder.add(NativeInstructionType.SYSTEM_CALL,
				ipcesid, new RegisterList(NativeCode.ZERO_REGISTER));
			
			// Quickly copy out exception value
			int eval = volatiles.get();
			codebuilder.addCopy(NativeCode.RETURN_REGISTER, eval);
			
			// If this value is set, then we fail
			codebuilder.addIfNonZero(eval,
				this.__labelMakeException("cc/squirreljme/jvm/IPCException"));
			
			// Copy out the moved out return values
			if (__out != null)
			{
				// Low value
				codebuilder.addCopy(rvlo, __out.register);
				
				// Possible high value
				if (__long)
					codebuilder.addCopy(rvhi, __out.register + 1);
			}
			
			// No longer needed
			volatiles.remove(eval);
			volatiles.remove(ipcesid);
			volatiles.remove(rvhi);
			volatiles.remove(rvlo);
		}
		
		// Unpure system call (possibly adapted by our own handler)
		else
		{
			// Since this is a standard invocation, we just pass all the
			// input arguments as is
			int n = __in.length;
			int[] args = new int[n];
			for (int i = 0; i < n; i++)
				args[i] = __in[i].register;
			
			// Perform the unpure call into the JVM helper
			this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
				"jvmSystemCall", "(SIIIIIIII)J", args);
				
			// Copy return value
			if (__out != null)
			{
				// Low value
				codebuilder.addCopy(NativeCode.RETURN_REGISTER,
					__out.register);
				
				// Possible high value
				if (__long)
					codebuilder.addCopy(NativeCode.RETURN_REGISTER + 1,
						__out.register + 1);
			}
		}
	}
	
	/**
	 * Creates and stores an exception.
	 *
	 * @return The label to the exception.
	 * @since 2019/04/09
	 */
	private final NativeCodeLabel __labelException()
	{
		// Get both states for when an exception is handled (transition) and
		// for where it is not handled (full cleanup)
		ByteCodeState state = this.state;
		JavaStackResult handled = state.stack.doExceptionHandler(),
			nothandled = state.stack.doDestroy(false);
		
		// The byte code handler does not know about exception registers so
		// we need to add this operation in so it is handled correctly
		List<StateOperation> newsop = new ArrayList<>();
		for (StateOperation o : handled.operations())
			newsop.add(o);
		newsop.add(StateOperation.copy(false,
			NativeCode.EXCEPTION_REGISTER, handled.out(0).register));
		
		// Clear the exception register when it is handled, otherwise it
		// will just cause an exception fall off when the register is next
		// checked
		newsop.add(StateOperation.copy(false, NativeCode.ZERO_REGISTER,
			NativeCode.EXCEPTION_REGISTER));
		
		// Setup key
		ExceptionHandlerTransition key = new ExceptionHandlerTransition(
			new StateOperations(newsop), nothandled.enqueue(),
			state.exceptionranges.tableOf(state.addr));
		
		// Try to use an already existing point
		Map<ExceptionHandlerTransition, __EData__> ehtable = this._ehtable;
		__EData__ rv = ehtable.get(key);
		if (rv != null)
			return rv.label;
			
		// Build new data to record this point
		rv = this.__eData(new NativeCodeLabel("exception", ehtable.size()));
		ehtable.put(key, rv);
		
		// Return the created label (where the caller jumps to)
		return rv.label;
	}
	
	/**
	 * Makes a lable which goes from this address to the target address. If
	 * the target address is poisoned then the current stack will be adapted
	 * to the target state through a transition method. Otherwise if the target
	 * is not poisoned it will be a normal jump.
	 *
	 * @param __jt The jump target.
	 * @return The label of the jump.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	private final NativeCodeLabel __labelJava(InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		ByteCodeState state = this.state;
		JavaStackState sourcestack = state.stack;
		
		// If the target stack state matches the current state then no
		// adapting is required at all
		int target = __jt.target();
		JavaStackState targetstack = state.stacks.get(target);
		if (sourcestack.equals(targetstack))
			return new NativeCodeLabel("java", target);
		
		// Do a transition to the target stack
		return this.__labelJavaTransition(sourcestack.
			doTransition(targetstack).operations(), __jt);
	}
	
	/**
	 * Creates the actual label which is used for the state transition.
	 *
	 * @param __sops The operation to use.
	 * @param __jt The jump target in the Java address space.
	 * @return The label for this transition.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	private final NativeCodeLabel __labelJavaTransition(StateOperations __sops,
		InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__sops == null || __jt == null)
			throw new NullPointerException("NARG");
		
		// If no operations were generated then just use a normal jump since
		// there is no point in transitioning anyway
		if (__sops.isEmpty())
			return new NativeCodeLabel("java", __jt.target());
		
		// Setup key
		StateOperationsAndTarget key =
			new StateOperationsAndTarget(__sops, __jt);
		
		// Determine if such a transition was already done, since if the
		// transition is exactly the same we do not need to actually do
		// anything
		Map<StateOperationsAndTarget, __EData__> transits = this._transits;
		__EData__ rv = transits.get(key);
		if (rv != null)
			return rv.label;
		
		// Setup transition for later
		ByteCodeState state = this.state;
		rv = this.__eData(new NativeCodeLabel("transit", transits.size()));
		transits.put(key, rv);
		
		return rv.label;
	}
	
	/**
	 * Makes a label which creates the given exception then throws that
	 * exception.
	 *
	 * @param __cl The class to create.
	 * @return The label for that target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/10
	 */
	private final NativeCodeLabel __labelMakeException(String __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Setup key, the label is the target to jump to after the exception
		// has been generated and a throw is performed
		ByteCodeState state = this.state;
		ClassAndLabel key = new ClassAndLabel(new ClassName(__cl),
			this.__labelException());
		
		// Look in the table to see if we made it before
		Map<ClassAndLabel, __EData__> metable = this._metable;
		__EData__ rv = metable.get(key);
		if (rv != null)
			return rv.label;
		
		// Build new data to record this point
		rv = this.__eData(new NativeCodeLabel("makeexception",
			metable.size()));
		metable.put(key, rv);
		
		// Return the created label (where the caller jumps to)
		return rv.label;
	}
	
	/**
	 * Creates a label to potentially reference clear and jumps to the given
	 * label. This uses the current ref queue table.
	 *
	 * @param __tl The target label.
	 * @return The transition label for reference clearing or {@code __tl}
	 * if there are no references to clear.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	private final NativeCodeLabel __labelRefClearJump(NativeCodeLabel __tl)
		throws NullPointerException
	{
		if (__tl == null)
			throw new NullPointerException("NARG");
		
		return this.__labelRefClearJump(this._lastenqueue, __tl);
	}
	
	/**
	 * Creates a label to potentially reference clear and jumps to the given
	 * label.
	 *
	 * @param __eql The reference queue label.
	 * @param __tl The target label.
	 * @return The transition label for reference clearing or {@code __tl}
	 * if there are no references to clear.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	private final NativeCodeLabel __labelRefClearJump(
		JavaStackEnqueueList __eql, NativeCodeLabel __tl)
		throws NullPointerException
	{
		if (__tl == null)
			throw new NullPointerException("NARG");
		
		// If not clearing anything, just return the target label
		if (__eql == null || __eql.isEmpty())
			return __tl;
		
		// Setup key
		EnqueueAndLabel key = new EnqueueAndLabel(__eql, __tl);
		
		// Did we make this before?
		Map<EnqueueAndLabel, __EData__> refcljumps = this._refcljumps;
		__EData__ rv = refcljumps.get(key);
		if (rv != null)
			return rv.label;
		
		// Setup new record
		ByteCodeState state = this.state;
		rv = this.__eData(new NativeCodeLabel("refclear", refcljumps.size()));
		refcljumps.put(key, rv);
		
		// Use the created label
		return rv.label;
	}
	
	/**
	 * Loads the class information for a class.
	 *
	 * @param __cl The class to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/01/19
	 */
	private final void __loadClassInfo(String __cl, int __r)
		throws NullPointerException
	{
		this.__loadClassInfo(new ClassName(__cl), __r);
	}
	
	/**
	 * Loads the class information for a class.
	 *
	 * @param __cl The class to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	private final void __loadClassInfo(ClassName __cl, int __r)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Used for loading code
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Attempt load to the target register
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new ClassInfoPointer(__cl), __r);
		
		// Detect classes which are dynamically initialized or self
		if (!ClassLoadingAdjustments.isDeferredLoad(state.classname.toString(),
			__cl.toString()))
			return;
		
		// If the class is already loaded do not try loading
		NativeCodeLabel isloaded = new NativeCodeLabel("ciisloaded",
			this._refclunk++);
		codebuilder.addIfNonZero(__r, isloaded);
		
		// Need register to load the class info
		VolatileRegisterStack volatiles = this.volatiles;
		int volnoted = volatiles.get();
		
		// Load the noted class name
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new NotedString(__cl.toString()), volnoted);
		
		// Initialize the class
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmInitClass", "(I)Lcc/squirreljme/jvm/ClassInfo;", volnoted);
		
		// Store the result of the init into the pool
		codebuilder.add(NativeInstructionType.STORE_POOL,
			new ClassInfoPointer(__cl), NativeCode.RETURN_REGISTER);
		
		// Use the value of it
		codebuilder.addCopy(NativeCode.RETURN_REGISTER, __r);
		
		// Cleanup
		volatiles.remove(volnoted);
		
		// End point is here
		codebuilder.label(isloaded);
	}
	
	/**
	 * Loads the Class object for the given class into the given register.
	 *
	 * @param __cl The class to load.
	 * @param __r The register to place it in.
	 * @since 2019/04/26
	 */
	private final void __loadClassObject(ClassName __cl, int __r)
	{
		VolatileRegisterStack volatiles = this.volatiles;
		
		// Load the class info for the class
		int volcdvt = volatiles.get();
		this.__loadClassInfo(__cl, volcdvt);
		
		// Call internal class object loader
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmLoadClass", "(I)Ljava/lang/Class;", volcdvt);
		
		// Cleanup
		volatiles.remove(volcdvt);
		
		// Copy return value to the output register
		this.codebuilder.addCopy(NativeCode.RETURN_REGISTER, __r);
	}
	
	/**
	 * Loads the constant pool for the given class.
	 *
	 * @param __cl The class pool to load.
	 * @param __r The output register.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	private final void __loadClassPool(ClassName __cl, int __r)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Used for loading code
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Load class pool which may already be loaded
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new ClassPool(__cl), __r);
		
		// Detect classes which are dynamically initialized
		if (!ClassLoadingAdjustments.isDeferredLoad(state.classname.toString(),
			__cl.toString()))
			return;
		
		// Jump if the pool is already loaded
		NativeCodeLabel isloaded = new NativeCodeLabel("piisloaded",
			this._refclunk++);
		codebuilder.addIfNonZero(__r, isloaded);
		
		// Need volatile to get the class info
		VolatileRegisterStack volatiles = this.volatiles;
		int volcinfo = volatiles.get(),
			volpoolv = volatiles.get(),
			volscfo = volatiles.get();
		
		// Load the ClassInfo for the class we want
		this.__loadClassInfo(__cl, volcinfo);
		
		// Load pool pointer from this ClassInfo
		codebuilder.add(NativeInstructionType.LOAD_POOL,
			new AccessedField(FieldAccessTime.NORMAL,
				FieldAccessType.INSTANCE,
			new FieldReference(
				new ClassName("cc/squirreljme/jvm/ClassInfo"),
				new FieldName("pool"),
				new FieldDescriptor("I"))), volscfo);
		codebuilder.addMemoryOffReg(DataType.INTEGER, true,
			volpoolv, volcinfo, volscfo);
		
		// Store it
		codebuilder.add(NativeInstructionType.STORE_POOL,
			new ClassPool(__cl), volpoolv);
		
		// Cleanup
		volatiles.remove(volcinfo);
		volatiles.remove(volpoolv);
		volatiles.remove(volscfo);
		
		// End point is here
		codebuilder.label(isloaded);
	}
	
	/**
	 * Enters the monitor.
	 *
	 * @param __enter Is the monitor being entered? 
	 * @param __r The register to enter a monitor for.
	 * @since 2019/04/26
	 */
	private final void __monitor(boolean __enter, int __r)
	{
		// Call helper method
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			(__enter ? "jvmMonitorEnter" : "jvmMonitorExit"), "(I)V", __r);
	}
	
	/**
	 * If anything has been previously pushed then generate code to clear it.
	 *
	 * @since 2019/03/30
	 */
	private final void __refClear()
	{
		// Do nothing if nothing has been enqueued
		JavaStackEnqueueList lastenqueue = this._lastenqueue;
		if (lastenqueue == null)
			return;
		
		// No need to clear anymore
		this.__refReset();
		
		// Un-count all of them accordingly
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		for (int i = 0, n = lastenqueue.size(); i < n; i++)
		{
			// Get the volatile to clear
			int v = lastenqueue.get(i);
			
			// Uncount this one
			this.__refUncount(v);
			
			// Free it for later usage
			volatiles.remove(v);
		}
	}
	
	/**
	 * Generates code to reference count the given register.
	 *
	 * @param __r The register to reference to count.
	 * @since 2019/04/25
	 */
	private final void __refCount(int __r)
	{
		// If the object is null then it will not be counted, this is skipped
		NativeCodeLabel ncj = new NativeCodeLabel("refnocount",
			this._refclunk++);
		
		// Do not do any counting if this is zero
		NativeCodeBuilder codebuilder = this.codebuilder;
		codebuilder.addIfZero(__r, ncj);
		
		// Add count
		codebuilder.add(NativeInstructionType.ATOMIC_INT_INCREMENT,
			__r, Constants.OBJECT_COUNT_OFFSET);
		
		// No count is jumped here
		codebuilder.label(ncj);
	}
	
	/**
	 * Generates code to enqueue registers, if there are any. This implicitly
	 * uses the registers from the state.
	 *
	 * @return True if the push list was not empty.
	 * @since 2019/04/10
	 */
	private final boolean __refPush()
		throws NullPointerException
	{
		return this.__refPush(this.state.result.enqueue());
	}
	
	/**
	 * Generates code to enqueue registers, if there are any.
	 *
	 * @param __r The registers to push.
	 * @return True if the push list was not empty.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	private final boolean __refPush(JavaStackEnqueueList __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		// Nothing to enqueue?
		if (__r.isEmpty())
		{
			this.__refReset();
			return false;
		}
		
		// Place anything that is referenced into volatile registers
		VolatileRegisterStack volatiles = this.volatiles;
		NativeCodeBuilder codebuilder = this.codebuilder;
		
		// Get a volatile register and copy into it, store the volatile
		int n = __r.size();
		int[] use = new int[n];
		for (int i = 0; i < n; i++)
		{
			// Get the volatile register to copy into
			int v = volatiles.get();
			
			// Copy to the volatile
			codebuilder.addCopy(__r.get(i), v);
			
			// Use this volatile register
			use[i] = v;
		}
		
		// We completely lose our original registers and instead use our new
		// set of volatiles for later clearing and removing
		// Note that we keep the same stack offset because it will match
		// exactly as the input (needed for exception handlers), even though
		// the registers might be all over the place.
		this._lastenqueue = new JavaStackEnqueueList(__r.stackstart, use);
		
		// Did enqueue something
		return true;
	}
	
	/**
	 * Resets the reference queue so nothing uses it.
	 *
	 * @since 2019/11/24
	 */
	private final void __refReset()
	{
		this._lastenqueue = null;
	}
	
	/**
	 * Generates code to reference uncount the given register.
	 *
	 * @param __r The register to reference to uncount.
	 * @since 2019/04/25
	 */
	private final void __refUncount(int __r)
	{
		// If the object is null then it will not be uncounted, this is skipped
		NativeCodeLabel ncj = new NativeCodeLabel("refnouncount",
			this._refclunk++);
		
		// Need volatiles
		VolatileRegisterStack volatiles = this.volatiles;
		int volnowcount = volatiles.get();
		
		// Do not do any uncounting if this is null
		NativeCodeBuilder codebuilder = this.codebuilder;
		codebuilder.addIfZero(__r, ncj);
		
		// Add uncount
		codebuilder.add(NativeInstructionType.ATOMIC_INT_DECREMENT_AND_GET,
			volnowcount, __r, Constants.OBJECT_COUNT_OFFSET);
		
		// If the count is still positive, we do not GC
		codebuilder.addIfPositive(volnowcount, ncj);
		
		// Call garbage collect on object via helper
		this.__invokeStatic(InvokeType.SYSTEM, JVMFUNC_CLASS,
			"jvmGarbageCollectObject", "(I)V", __r);
		
		// Reset the variable to zero to prevent it from being used again
		codebuilder.addCopy(NativeCode.ZERO_REGISTER, __r);
		
		// No uncount or not GCed are jumped here
		codebuilder.label(ncj);
		
		// No longer needed
		volatiles.remove(volnowcount);
	}
	
	/**
	 * Uses the given EData and returns the used label.
	 *
	 * @param __ed The data to use.
	 * @return The label.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/25
	 */
	private final NativeCodeLabel __useEDataAndGetLabel(__EData__ __ed)
		throws NullPointerException
	{
		if (__ed == null)
			throw new NullPointerException("NARG");
		
		// Setup state
		ByteCodeState state = this.state;
		state.addr = __ed.addr;
		state.line = __ed.line;
		
		// And return the label
		return __ed.label;
	}
	
	/**
	 * Sets debug point information for edata.
	 *
	 * @param __ed The EData used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	private final void __useEDataDebugPoint(__EData__ __ed, int __jop)
		throws NullPointerException
	{
		if (__ed == null)
			throw new NullPointerException("NARG");
		
		// Add debug point (operation becomes debug point 1)
		codebuilder.add(NativeInstructionType.DEBUG_POINT,
			__ed.line & 0x7FFF, __jop,
			__ed.jpc & 0x7FFF);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/RegisterList.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.nncc;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Iterator;

/**
 * This represents a list of registers.
 *
 * @since 2019/03/22
 */
public final class RegisterList
{
	/** The registers used. */
	private final int[] _registers;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the list of registers.
	 *
	 * @param __r The registers to use.
	 * @since 2019/03/22
	 */
	public RegisterList(int... __r)
	{
		this._registers = (__r == null ? new int[0] : __r.clone());
	}
	
	/**
	 * Initializes the list of registers.
	 *
	 * @param __r The registers to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public RegisterList(Collection<Integer> __r)
		throws NullPointerException
	{
		if (__r == null)
			throw new NullPointerException("NARG");
		
		int n = __r.size();
		int[] regs = new int[n];
		Iterator<Integer> it = __r.iterator();
		for (int i = 0; i < n; i++)
			regs[i] = it.next();
		
		this._registers = regs;
	}
	
	/**
	 * Gets the register at the given index.
	 *
	 * @param __i The index to get.
	 * @return The register at the given index.
	 * @since 2019/03/26
	 */
	public final int get(int __i)
	{
		return this._registers[__i];
	}
	
	/**
	 * Returns the size of the list.
	 *
	 * @return The list size.
	 * @since 2019/03/26
	 */
	public final int size()
	{
		return this._registers.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Build list
			StringBuilder sb = new StringBuilder("R[");
			boolean comma = false;
			for (int i : this._registers)
			{
				if (comma)
					sb.append(", ");
				comma = true;
				
				sb.append(i);
			}
			sb.append(']');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/StateOperationsAndTarget.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
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











































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import dev.shadowtail.classfile.xlate.StateOperations;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.InstructionJumpTarget;

/**
 * This represents state operations and a target.
 *
 * @since 2019/04/12
 */
public final class StateOperationsAndTarget
{
	/** State Operations. */
	protected final StateOperations operations;
	
	/** Jump target. */
	protected final InstructionJumpTarget target;
	
	/** Hashcode. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the operations and target.
	 *
	 * @param __ops The operations.
	 * @param __t The target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperationsAndTarget(StateOperations __ops,
		InstructionJumpTarget __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.operations = __ops;
		this.target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof StateOperationsAndTarget))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		StateOperationsAndTarget o = (StateOperationsAndTarget)__o;
		return this.operations.equals(o.operations) &&
			this.target.equals(o.target);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.operations.hashCode() ^
				this.target.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.operations + "+@" +
				this.target));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/VolatileRegisterStack.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
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






























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * This is a stack which is used to manage which volatile registers are used.
 *
 * @since 2019/05/24
 */
public final class VolatileRegisterStack
{
	/** The base register. */
	protected final int base;
	
	/** Registers being used. */
	private final Collection<Integer> _used =
		new ArrayList<>();
	
	/**
	 * Initializes the volatile stack.
	 *
	 * @param __b The base register.
	 * @since 2019/05/25
	 */
	public VolatileRegisterStack(int __b)
	{
		this.base = __b;
	}
	
	/**
	 * Clears all of the used volatile reisters.
	 *
	 * @since 2019/05/25
	 */
	public final void clear()
	{
		this._used.clear();
	}
	
	/**
	 * Returns the next volatile register.
	 *
	 * @return The next volatile register.
	 * @throws IllegalStateException If no registers are available.
	 * @since 2019/05/24
	 */
	public final int get()
		throws IllegalStateException
	{
		// Find next register to use from the base, use any register which
		// was not previously recorded
		int at = this.base;
		Collection<Integer> used = this._used;
		while (used.contains(at))
			at++;
		
		// {@squirreljme.error JC4l Exceeded maximum permitted registers.
		// (The base register)}
		if (at >= NativeCode.MAX_REGISTERS)
			throw new IllegalStateException("JC4l " + this.base);
		
		// Record it
		used.add(at);
		return at;
	}
	
	/**
	 * Removes the given volatile register from usage.
	 *
	 * @param __r The register to remove.
	 * @throws IllegalStateException If it was never used.
	 * @since 2019/05/24
	 */
	public final void remove(int __r)
		throws IllegalStateException
	{
		// {@squirreljme.error JC13 Register to remove was never previously
		// returned or was removed multiple times. (The register)}
		if (!this._used.remove(__r))
			throw new IllegalStateException("JC13 " + __r);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/__Debug__.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * Stores debug enabled flag.
 *
 * @since 2019/04/16
 */
final class __Debug__
{
	/** Debug enabled? */
	public static final boolean ENABLED;
	
	/**
	 * Gets the debug flag.
	 *
	 * @since 2019/04/16
	 */
	static
	{
		// Get property
		boolean en = false;
		try
		{
			// {@squirreljme.property dev.shadowtail.classfile.xlate.debug=pool
			// Sets whether the massive amounts of debug test should be
			// printed in all the native compiler codes.}
			en = Boolean.getBoolean("dev.shadowtail.classfile.nncc.debug");
		}
		catch (SecurityException e)
		{
		}
		
		// Set
		ENABLED = en;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/__EData__.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


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.nncc;

/**
 * Exception storage data.
 *
 * @since 2019/04/11
 */
final class __EData__
{	
	/** The address. */
	public final int addr;
	
	/** The line. */
	public final int line;
	
	/** The Java operation. */
	public final int jop;
	
	/** The Java PC address. */
	public final int jpc;
	
	/** The used label. */
	public final NativeCodeLabel label;
	
	/**
	 * Initializes the data.
	 *
	 * @param __a The address.
	 * @param __ln The line.
	 * @param __jop The Java operation address.
	 * @param __jpc The Java PC address.
	 * @param __lab The label to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	__EData__(int __a, int __ln, int __jop, int __jpc, NativeCodeLabel __lab)
		throws NullPointerException
	{
		if (__lab == null)
			throw new NullPointerException("NARG");
		
		this.addr = __a;
		this.line = __ln;
		this.label = __lab;
		this.jop = __jop;
		this.jpc = __jpc;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/nncc/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the near-native code compiler and all of the
 * associated classes for its handling.
 *
 * @since 2019/04/06
 */

package dev.shadowtail.classfile.nncc;

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/AccessedField.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
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






























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.FieldReference;

/**
 * This represents a field which has been accessed.
 *
 * @since 2019/03/24
 */
public final class AccessedField
{
	/** The field reference. */
	public final FieldReference field;
	
	/** The access time. */
	public final FieldAccessTime time;
	
	/** The access type. */
	public final FieldAccessType type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the accessed field.
	 *
	 * @param __ti The access time.
	 * @param __ty The access type.
	 * @param __cn The class name.
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public AccessedField(FieldAccessTime __ti, FieldAccessType __ty,
		ClassName __cn, String __fn, FieldDescriptor __fd)
		throws NullPointerException
	{
		this(__ti, __ty, new FieldReference(__cn, new FieldName(__fn), __fd));
	}
	
	/**
	 * Initializes the accessed field.
	 *
	 * @param __ti The access time.
	 * @param __ty The access type.
	 * @param __f The field to access.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public AccessedField(FieldAccessTime __ti, FieldAccessType __ty,
		FieldReference __f)
		throws NullPointerException
	{
		if (__ti == null || __ty == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.time = __ti;
		this.type = __ty;
		this.field = __f;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof AccessedField))
			return false;
		
		AccessedField o = (AccessedField)__o;
		return this.field.equals(o.field) &&
			this.time.equals(o.time) &&
			this.type.equals(o.type);
	}
	
	/**
	 * Returns the field reference.
	 *
	 * @return The field reference.
	 * @since 2019/03/26
	 */
	public final FieldReference field()
	{
		return this.field;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final int hashCode()
	{
		return this.field.hashCode() ^ this.time.hashCode() ^
			this.type.hashCode();
	}
	
	/**
	 * Returns the field access time.
	 *
	 * @return The access time.
	 * @since 2019/04/14
	 */
	public final FieldAccessTime time()
	{
		return this.time;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/24
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				this.time + "+" + this.type + "+" + this.field));
		
		return rv;
	}
	
	/**
	 * Returns the field access type.
	 *
	 * @return The access type.
	 * @since 2019/04/14
	 */
	public final FieldAccessType type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/BasicPool.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
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

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This represents a basic constant pool.
 *
 * @since 2019/07/17
 */
public final class BasicPool
{
	/** Entries which exist in the constant pool. */
	private final Map<Object, BasicPoolEntry> _entries;
	
	/** Linear entries within the pool. */
	private final List<BasicPoolEntry> _linear;
	
	/**
	 * Input for the basic pool.
	 *
	 * @param __it The input entries.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public BasicPool(BasicPoolEntry... __it)
		throws NullPointerException
	{
		this(Arrays.<BasicPoolEntry>asList(__it));
	}
	
	/**
	 * Input for the basic pool.
	 *
	 * @param __it The input entries.
	 * @throws IllegalArgumentException If a pool entry was duplicated.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public BasicPool(Iterable<BasicPoolEntry> __it)
		throws IllegalArgumentException, NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		// Initial guessed size?
		int igs = ((__it instanceof Collection) ?
			((Collection)__it).size() : 16);
			
		// Where the entries go
		List<BasicPoolEntry> linear = new ArrayList<>(igs);
		Map<Object, BasicPoolEntry> entries = new LinkedHashMap<>();
		
		// Process entries
		for (BasicPoolEntry e : __it)
		{
			if (e == null)
				throw new NullPointerException("NARG");
			
			// Just add to the end of the list
			linear.add(e);
			
			// {@squirreljme.error JC4k Duplicated pool entry. (The entry)}
			if (null != entries.put(e.value, e))
				throw new IllegalArgumentException("JC4k " + e);
		}
		
		// Set
		this._entries = entries;
		this._linear = linear;
	}
	
	/**
	 * Gets the pool entry by index.
	 *
	 * @param __i The index to get.
	 * @return The index of the given entry.
	 * @throws IndexOutOfBoundsException If the entry is not within bounds.
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byIndex(int __i)
		throws IndexOutOfBoundsException
	{
		return this._linear.get(__i);
	}
	
	/**
	 * Gets the pool value by index.
	 *
	 * @param <T> The class type.
	 * @param __cl The class type.
	 * @param __i The index to get.
	 * @return The index of the given entry.
	 * @throws IndexOutOfBoundsException If the entry is not within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public final <T> T byIndex(Class<T> __cl, int __i)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.byIndex(__i).<T>value(__cl);
	}
	
	/**
	 * Gets the pool entry by value.
	 *
	 * @param __v The value to get.
	 * @return The entry or {@code null} if it was not found.
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byValue(Object __v)
		throws IndexOutOfBoundsException
	{
		return this._entries.get(__v);
	}
	
	/**
	 * Returns the size of the pool.
	 *
	 * @return The pool size.
	 * @since 2019/09/11
	 */
	public final int size()
	{
		return this._entries.size();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/BasicPoolBuilder.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
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




























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This class is used to store and contain the basic constant pool which
 * consists of values, indexes, and parts.
 *
 * This class is thread safe.
 *
 * @since 2019/07/15
 */
public final class BasicPoolBuilder
	implements Iterable<BasicPoolEntry>
{
	/** Entries which exist in the constant pool. */
	protected final Map<Object, BasicPoolEntry> entries =
		new LinkedHashMap<>();
	
	/**
	 * Base pool initialization.
	 *
	 * @since 2019/07/15
	 */
	{
		// The first entry of the constant pool is always null!
		this.entries.put(null, new BasicPoolEntry(0, null, new int[0]));
	}
	
	/**
	 * Adds a basic entry.
	 *
	 * @param __v The value.
	 * @param __parts The parts to use.
	 * @return The entry for this value.
	 * @throws IllegalStateException If the entry already exists within
	 * the pool.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry add(Object __v, int... __parts)
		throws IllegalStateException
	{
		Map<Object, BasicPoolEntry> entries = this.entries;
		
		// Lock on self, since there could be multiple processing of pool
		// entries in the future
		synchronized (this)
		{
			// {@squirreljme.error JC4c The specified entry already exists
			// within the pool. (The entry being added)}
			if (entries.containsKey(__v))
				throw new IllegalStateException("JC4c " + __v);
			
			// Create, store, and use the new entry
			BasicPoolEntry rv;
			entries.put(__v, (rv = new BasicPoolEntry(
				entries.size(), __v, __parts)));
			return rv;
		}
	}
	
	/**
	 * Adds an already existing basic entry to this pool.
	 *
	 * @param __e The entry to add.
	 * @return The resulting basic entry which may be {@code __e} or another
	 * entry.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final BasicPoolEntry addEntry(BasicPoolEntry __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Adds an internal entry or returns the pre-existing value if it is
	 * already in the pool.
	 *
	 * @param __v The value.
	 * @param __parts The parts to use.
	 * @return The entry for this value.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry addOrGet(Object __v, int... __parts)
	{
		synchronized (this)
		{
			// If the entry already exists use it
			BasicPoolEntry rv = this.getByValue(__v);
			if (rv != null)
				return rv;
			
			// Otherwise add it
			return this.add(__v, __parts);
		}
	}
	
	/**
	 * Searches the constant pool and returns the entry at the given index.
	 *
	 * @param __dx The index to get.
	 * @return The entry at the given index or {@code null} if there is none.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry getByIndex(int __dx)
	{
		// Find matching index
		Map<Object, BasicPoolEntry> entries = this.entries;
		synchronized (this)
		{
			for (BasicPoolEntry e : entries.values())
				if (e.index == __dx)
					return e;
		}
		
		// Not found
		return null;
	}
	
	/**
	 * Gets the given entry by the key.
	 *
	 * @param __v The value to get.
	 * @return The entry for the value or {@code null} if it is not in the
	 * pool.
	 * @since 2019/07/15
	 */
	public final BasicPoolEntry getByValue(Object __v)
	{
		synchronized (this)
		{
			return this.entries.get(__v);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/17
	 */
	@Override
	public final Iterator<BasicPoolEntry> iterator()
	{
		// Get elements
		BasicPoolEntry[] elems;
		synchronized (this)
		{
			Map<Object, BasicPoolEntry> entries = this.entries;
			elems = entries.values().toArray(
				new BasicPoolEntry[entries.size()]);
		}
		
		// Iterate over
		return UnmodifiableIterator.<BasicPoolEntry>of(elems);
	}
	
	/**
	 * Returns the size of the constant pool.
	 *
	 * @return The pool size.
	 * @since 2019/07/15
	 */
	public final int size()
	{
		synchronized (this)
		{
			return this.entries.size();
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/BasicPoolEntry.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
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



































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;

/**
 * Represents an entry within the constant pool.
 *
 * @since 2019/07/15
 */
public final class BasicPoolEntry
{
	/** The index of this entry. */
	public final int index;
	
	/** Offset of this entry. */
	public final int offset;
	
	/** The value. */
	public final Object value;
	
	/** The parts. */
	private final short[] _parts;
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @since 2019/09/11
	 */
	public BasicPoolEntry(int __dx, Object __v, short[] __parts)
	{
		this.index = __dx;
		this.value = __v;
		this.offset = -1;
		this._parts = (__parts == null ? new short[0] : __parts.clone());
	}
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @since 2019/07/15
	 */
	public BasicPoolEntry(int __dx, Object __v, int[] __parts)
	{
		this(__dx, __v, __parts, -1);
	}
	
	/**
	 * Initializes a new entry.
	 *
	 * @param __dx The entry index.
	 * @param __v The value.
	 * @param __parts The parts.
	 * @param __eoff The entry offset.
	 * @since 2019/09/14
	 */
	public BasicPoolEntry(int __dx, Object __v, int[] __parts, int __eoff)
	{
		this.index = __dx;
		this.value = __v;
		this.offset = __eoff;
		
		// Reduce parts to shorts
		int n = (__parts == null ? 0 : __parts.length);
		short[] parts = new short[n];
		for (int i = 0; i < n; i++)
			parts[i] = (short)__parts[i];
		this._parts = parts;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/08/25
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/08/25
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns a single part value.
	 *
	 * @param __i The part index.
	 * @return The resulting part.
	 * @throws IndexOutOfBoundsException If the part index is not within
	 * bounds.
	 * @since 2019/09/14
	 */
	public final int part(int __i)
	{
		return this._parts[__i] & 0xFFFF;
	}
	
	/**
	 * Returns the parts used.
	 *
	 * @return The used parts.
	 * @since 2019/07/15
	 */
	public final short[] parts()
	{
		return this._parts.clone();
	}
	
	/**
	 * Returns the type of entry that this is.
	 *
	 * @return The entry type.
	 * @since 2019/09/14
	 */
	public final MinimizedPoolEntryType type()
	{
		Object value = this.value;
		if (value == null)
			return MinimizedPoolEntryType.NULL;
		return MinimizedPoolEntryType.ofClass(value.getClass());
	}
	
	/**
	 * Returns the value of this entry.
	 *
	 * @param <T> The type to use.
	 * @param __cl The class of this type.
	 * @return The resulting type.
	 * @throws ClassCastException If the class type is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/01
	 */
	public final <T> T value(Class<T> __cl)
		throws ClassCastException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this.value);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/ClassInfoPointer.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import net.multiphasicapps.classfile.ClassName;

/**
 * This represents a pointer to the specified class.
 *
 * @since 2019/09/07
 */
public final class ClassInfoPointer
{
	/** The class name to load for. */
	public final ClassName name;
	
	/**
	 * Initializes the class information pointer.
	 *
	 * @param __cl The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public ClassInfoPointer(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.name = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassInfoPointer))
			return false;
		
		return this.name.equals(((ClassInfoPointer)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/07
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/ClassPool.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import net.multiphasicapps.classfile.ClassName;

/**
 * Represents the constant pool of another class, used for loading.
 *
 * @since 2019/04/22
 */
public final class ClassPool
{
	/** The class name to load for. */
	public final ClassName name;
	
	/**
	 * Initializes the class pool.
	 *
	 * @param __cl The class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/22
	 */
	public ClassPool(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		this.name = __cl;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ClassPool))
			return false;
		
		return this.name.equals(((ClassPool)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/22
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/DualClassRuntimePool.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * This contains the dual class and run-time constant pool information, the
 * run-time relies on the main class one, however only the run-time one is
 * needed for execution.
 *
 * @since 2019/07/17
 */
public final class DualClassRuntimePool
{
	/** The class pool. */
	protected final BasicPool classpool;
	
	/** The run-time pool. */
	protected final BasicPool runpool;
	
	/**
	 * Initializes the dual class/run-time pool.
	 *
	 * @param __cl The class pool.
	 * @param __rt The run-time pool.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/07
	 */
	public DualClassRuntimePool(BasicPool __cl, BasicPool __rt)
		throws NullPointerException
	{
		if (__cl == null || __rt == null)
			throw new NullPointerException("NARG");
		
		this.classpool = __cl;
		this.runpool = __rt;
	}
	
	/**
	 * Returns the static class pool.
	 *
	 * @return The pool.
	 * @since 2019/09/14
	 */
	public final BasicPool classPool()
	{
		return this.classpool;
	}
	
	/**
	 * Loads a value from the pool by its index.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __dx The index to read.
	 * @return The entry for the given index.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * pool bounds.
	 * @since 2019/09/07
	 */
	public final BasicPoolEntry getByIndex(boolean __rt, int __dx)
		throws IndexOutOfBoundsException
	{
		return (__rt ? this.runpool : this.classpool).byIndex(__dx);
	}
	
	/**
	 * Loads a value from the pool by its value.
	 *
	 * @param __rt Read from the run-time pool?
	 * @param __v The value to get.
	 * @return The entry for the given value or {@code null} if not found.
	 * @since 2019/09/14
	 */
	public final BasicPoolEntry getByValue(boolean __rt, Object __v)
	{
		return (__rt ? this.runpool : this.classpool).byValue(__v);
	}
	
	/**
	 * Returns the runtime class pool.
	 *
	 * @return The pool.
	 * @since 2019/09/14
	 */
	public final BasicPool runtimePool()
	{
		return this.runpool;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/DualClassRuntimePoolBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300












































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;
import java.util.List;
import java.util.ArrayList;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;

/**
 * This is used as a builder for both class and run-time pools.
 *
 * @since 2019/07/17
 */
public final class DualClassRuntimePoolBuilder
{
	/** The class pool. */
	protected final BasicPoolBuilder classpool =
		new BasicPoolBuilder();
	
	/** The run-time pool. */
	protected final BasicPoolBuilder runpool =
		new BasicPoolBuilder();
	
	/**
	 * Adds the specified pool entry.
	 *
	 * @param __rt Place into the run-time pool?
	 * @param __v The value to store.
	 * @return The resulting pool entry.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/08/25
	 */
	public final BasicPoolEntry add(boolean __rt, Object __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		if (__rt)
			return this.addRuntime(__v);
		return this.addStatic(__v);
	}
	
	/**
	 * Adds an entry to the run-time pool.
	 *
	 * @param __v The value to add.
	 * @return The entry which was created.
	 * @throws IllegalArgumentException If the value cannot be stored into
	 * the specified pool.
	 * @since 2019/09/01
	 */
	public final BasicPoolEntry addRuntime(Object __v)
		throws IllegalArgumentException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// The pool to be added to and the underlying static pool
		BasicPoolBuilder runpool = this.runpool,
			classpool = this.classpool;
		
		// Already within the pool?
		BasicPoolEntry rv = runpool.getByValue(__v);
		if (rv != null)
			return rv;
		
		// Depends on the type to be stored
		MinimizedPoolEntryType type;
		switch ((type = MinimizedPoolEntryType.ofClass(__v.getClass())))
		{
				// Null is always the first entry
			case NULL:
				return runpool.getByValue(null);
			
				// A field which has been accessed
			case ACCESSED_FIELD:
				AccessedField af = (AccessedField)__v;
				FieldReference fr = af.field();
				return runpool.add(__v,
					af.time().ordinal(),
					af.type().ordinal(),
					this.addStatic(fr.className()).index,
					this.addStatic(fr.memberName().toString()).index,
					this.addStatic(fr.memberType().className()).index);
			
				// Class information pointer
			case CLASS_INFO_POINTER:
				return runpool.add(__v,
					this.addStatic(((ClassInfoPointer)__v).name).index);
						
				// The constant pool of another (or current) class
			case CLASS_POOL:
				return runpool.add(__v,
					this.addStatic(((ClassPool)__v).name).index);
				
				// A method which has been invoked
			case INVOKED_METHOD:
				InvokedMethod iv = (InvokedMethod)__v;
				MethodHandle mh = iv.handle();
				
				return runpool.add(__v,
					iv.type().ordinal(),
					this.addStatic(mh.outerClass()).index,
					this.addStatic(mh.name().toString()).index,
					this.addStatic(mh.descriptor()).index);
				
				// The index of a method
			case METHOD_INDEX:
				MethodIndex v = (MethodIndex)__v;
				return runpool.add(__v,
					0x7FFF,
					this.addStatic(v.inclass).index,
					this.addStatic(v.name.toString()).index,
					this.addStatic(v.type).index);
				
				// A string that is noted for its value (debugging)
			case NOTED_STRING:
				return runpool.add(__v,
					this.addStatic(__v.toString()).index);
				
				// A string that is used
			case USED_STRING:
				return runpool.add(__v,
					this.addStatic(__v.toString()).index);
			
				// Unknown
			default:
				// {@squirreljme.error JC4f Invalid type in runtime pool.
				// (The type)}
				if (!type.isRuntime())
					throw new IllegalArgumentException("JC4f " + type);
				throw new todo.OOPS(type.name());
		}
	}
	
	/**
	 * Adds an entry to the static pool.
	 *
	 * @param __v The value to add.
	 * @return The entry which was created.
	 * @throws IllegalArgumentException If the value cannot be stored into
	 * the specified pool.
	 * @since 2019/09/01
	 */
	public final BasicPoolEntry addStatic(Object __v)
		throws IllegalArgumentException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// The pool to be added to
		BasicPoolBuilder classpool = this.classpool;
		
		// Already within the pool?
		BasicPoolEntry rv = classpool.getByValue(__v);
		if (rv != null)
			return rv;
		
		// Depends on the type to be stored
		MinimizedPoolEntryType type;
		switch ((type = MinimizedPoolEntryType.ofClass(__v.getClass())))
		{
			case INTEGER:
				int bi = (Integer)__v;
				return classpool.add(__v,
					(bi >> 16) & 0xFFFF,
					(bi) & 0xFFFF);
				
			case FLOAT:
				int bf = Float.floatToRawIntBits((Float)__v);
				return classpool.add(__v,
					(bf >> 16) & 0xFFFF,
					(bf) & 0xFFFF);
			
			case LONG:
				long l = (Long)__v;
				return classpool.add(__v,
					((int)(l >>> 48)) & 0xFFFF,
					((int)(l >>> 32)) & 0xFFFF,
					((int)(l >>> 16)) & 0xFFFF,
					((int)l) & 0xFFFF);
			
			case DOUBLE:
				long d = Double.doubleToRawLongBits((Double)__v);
				return classpool.add(__v,
					((int)(d >>> 48)) & 0xFFFF,
					((int)(d >>> 32)) & 0xFFFF,
					((int)(d >>> 16)) & 0xFFFF,
					((int)d) & 0xFFFF);
				
				// Name of class (used), the component type is recorded if
				// this is detected to be an array
			case CLASS_NAME:
				ClassName cn = (ClassName)__v;
				return classpool.add(__v,
					this.addStatic(cn.toString()).index,
					(!cn.isArray() ? 0 :
						this.addStatic(cn.componentType()).index));
				
				// List of class names (interfaces)
			case CLASS_NAMES:
				// Adjust the value to map correctly
				ClassNames names = (ClassNames)__v;
				
				// Fill into indexes
				int nn = names.size();
				int[] indexes = new int[nn];
				for (int i = 0; i < nn; i++)
					indexes[i] = this.addStatic(names.get(i)).index;
				
				// Add it now
				return classpool.add(names, indexes);
			
				// Descriptor of a method
			case METHOD_DESCRIPTOR:
				MethodDescriptor md = (MethodDescriptor)__v;
				
				// Need arguments to process them
				FieldDescriptor mrv = md.returnValue();
				FieldDescriptor[] args = md.arguments();
				
				// Argument set
				int[] isubs = new int[3 + args.length];
				
				// String, argument count, and return value
				isubs[0] = this.addStatic(__v.toString()).index;
				isubs[1] = args.length;
				isubs[2] = (mrv == null ? 0 :
					this.addStatic(mrv.className()).index);
				
				// Fill in arguments
				for (int q = 0, n = args.length; q < n; q++)
					isubs[3 + q] = this.addStatic(args[q].className()).index;
				
				// Put in descriptor with all the pieces
				return classpool.add(__v, isubs);
			
			case STRING:
				return classpool.add(__v,
					__v.hashCode() & 0xFFFF,
					((String)__v).length());
			
				// Unknown
			default:
				// {@squirreljme.error JC4e Invalid type in static pool.
				// (The type)}
				if (!type.isStatic())
					throw new IllegalArgumentException("JC4e " + type);
				throw new todo.OOPS(type.name());
		}
	}
	
	/**
	 * Builds this dual pool.
	 *
	 * @return The resulting dual pool.
	 * @since 2019/09/07
	 */
	public final DualClassRuntimePool build()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the static class pool.
	 *
	 * @return The pool.
	 * @since 2019/07/17
	 */
	public final BasicPoolBuilder classPool()
	{
		return this.classpool;
	}
	
	/**
	 * Returns the runtime class pool.
	 *
	 * @return The pool.
	 * @since 2019/07/17
	 */
	public final BasicPoolBuilder runtimePool()
	{
		return this.runpool;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/FieldAccessTime.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

/**
 * This represents when a field is being accessed.
 *
 * @since 2019/03/24
 */
public enum FieldAccessTime
{
	/** Written by constructor or static initializer. */
	INITIALIZER,
	
	/** Written by non-constructor. */
	NORMAL,
	
	/** Read access. */
	READ,
	
	/** End. */
	;
	
	/**
	 * Returns the access time for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The access time.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final FieldAccessTime of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return INITIALIZER;
			case 1: return NORMAL;
			case 2: return READ;
		}
		
		// {@squirreljme.error JC14 Unknown access time. (The index)}
		throw new IllegalArgumentException("JC14 " + __i);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/FieldAccessType.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





























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

/**
 * Represents how a field is being accessed.
 *
 * @since 2019/03/24
 */
public enum FieldAccessType
{
	/** Static. */
	STATIC,
	
	/** Instance. */
	INSTANCE,
	
	/** End. */
	;
	
	/**
	 * Is this field access static?
	 *
	 * @return If this is a static field access.
	 * @since 2019/04/22
	 */
	public final boolean isStatic()
	{
		return this == STATIC;
	}
	
	/**
	 * Returns the access type for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The access type.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final FieldAccessType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return STATIC;
			case 1: return INSTANCE;
		}
		
		// {@squirreljme.error JC15 Unknown access type. (The index)}
		throw new IllegalArgumentException("JC15 " + __i);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/InvokeType.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

/**
 * This represents the type of invocation that is performed.
 *
 * @since 2019/03/20
 */
public enum InvokeType
{
	/** Static invoke. */
	STATIC,
	
	/** Special invoke. */
	SPECIAL,
	
	/** Virtual. */
	VIRTUAL,
	
	/** Interface. */
	INTERFACE,
	
	/** System invocation type. */
	SYSTEM,
	
	/** End. */
	;
	
	/**
	 * Does this use an instance variable?
	 *
	 * @return If there is an instance variable that is used.
	 * @since 2019/03/20
	 */
	public final boolean hasInstance()
	{
		return !this.isStatic();
	}
	
	/**
	 * Is this a static invocation?
	 *
	 * @return If this is a static invocation.
	 * @since 2019/04/22
	 */
	public final boolean isStatic()
	{
		return this == STATIC || this == SYSTEM;
	}
	
	/**
	 * Returns the invocation type for the given ordinal.
	 *
	 * @param __i The ordinal.
	 * @return The invocation type.
	 * @throws IllegalArgumentException If it is not valid.
	 * @since 2019/04/17
	 */
	public static final InvokeType of(int __i)
		throws IllegalArgumentException
	{
		switch (__i)
		{
			case 0:	return STATIC;
			case 1: return SPECIAL;
			case 2: return VIRTUAL;
			case 3: return INTERFACE;
			case 4: return SYSTEM;
		}
		
		// {@squirreljme.error JC16 Unknown invocation type. (The index)}
		throw new IllegalArgumentException("JC16 " + __i);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/InvokedMethod.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
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
191































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;

/**
 * Represents a method to be invoked.
 *
 * @since 2019/03/21
 */
public final class InvokedMethod
{
	/** The type of method to invoke. */
	public final InvokeType type;
	
	/** The handle of the method being invoke. */
	public final MethodHandle handle;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/24
	 */
	public InvokedMethod(InvokeType __t, String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(new ClassName(__cl),
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl, MethodName __mn,
		MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl, __mn, __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __h The handle of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/21
	 */
	public InvokedMethod(InvokeType __t, MethodHandle __h)
		throws NullPointerException
	{
		if (__t == null || __h == null)
			throw new NullPointerException("NARG");
		
		this.type = __t;
		this.handle = __h;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof InvokedMethod))
			return false;
		
		InvokedMethod o = (InvokedMethod)__o;
		return this.type.equals(o.type) &&
			this.handle.equals(o.handle);
	}
	
	/**
	 * Returns the method handle.
	 *
	 * @return The method handle.
	 * @since 2019/03/24
	 */
	public final MethodHandle handle()
	{
		return this.handle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/24
	 */
	@Override
	public final int hashCode()
	{
		return this.type.hashCode() ^ this.handle.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this.type + "+" + this.handle));
		
		return rv;
	}
	
	/**
	 * Returns the invocation type.
	 *
	 * @return The invocation type.
	 * @since 2019/04/14
	 */
	public final InvokeType type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/MethodIndex.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
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

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * Represents an index of a method in the method table of a class.
 *
 * @since 2019/04/30
 */
public final class MethodIndex
{
	/** The name of the class. */
	public final ClassName inclass;
	
	/** The method name. */
	public final MethodName name;
	
	/** The method type. */
	public final MethodDescriptor type;
	
	/** The hashcode. */
	private int _hash;
	
	/** The string form. */
	private Reference<String> _string;
	
	
	/**
	 * Initializes the index holder.
	 *
	 * @param __cl The class this is in.
	 * @param __n The name of the method.
	 * @param __t The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public MethodIndex(ClassName __cl, String __n, MethodDescriptor __t)
		throws NullPointerException
	{
		this(__cl, new MethodName(__n), __t);
	}
	
	/**
	 * Initializes the index holder.
	 *
	 * @param __cl The class this is in.
	 * @param __n The name of the method.
	 * @param __t The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	public MethodIndex(ClassName __cl, MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__cl == null || __n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MethodIndex))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		MethodIndex o = (MethodIndex)__o;
		return this.inclass.equals(o.inclass) &&
			this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.inclass.hashCode() ^
				this.name.hashCode() ^ this.type.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s::%s:%s", this.inclass, this.name, this.type)));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/NotedString.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * Noted string is similar to used string however it means it is just used
 * by its pointer data and not an actual string object which is initialized
 * for it. The noted string is generally used for debug purposes.
 *
 * @since 2019/09/11
 */
public final class NotedString
{
	/** The noted string. */
	public final String string;
	
	/**
	 * Initializes the noted string.
	 *
	 * @param __s The string to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public NotedString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof NotedString))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return this.string.equals(((NotedString)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/11
	 */
	@Override
	public final String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/NullPoolEntry.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * This represents the null pool entry.
 *
 * @since 2019/09/22
 */
public final class NullPoolEntry
{
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		return (__o instanceof NullPoolEntry);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/22
	 */
	@Override
	public final String toString()
	{
		return "null";
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/UsedString.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
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.pool;

/**
 * Represents a string which was used.
 *
 * @since 2019/04/27
 */
public final class UsedString
{
	/** The used string. */
	public final String string;
	
	/**
	 * Initializes the used string.
	 *
	 * @param __s The string to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public UsedString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof UsedString))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return this.string.equals(((UsedString)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/27
	 */
	@Override
	public final String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/pool/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains all of the constant pool and runtime pool related
 * class.
 *
 * @since 2019/05/24
 */

package dev.shadowtail.classfile.pool;

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ByteCodeHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316




























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.pool.InvokeType;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodReference;

/**
 * This class is used by the byte code processor to handle all of the various
 * instructions and such.
 *
 * @since 2019/04/06
 */
public interface ByteCodeHandler
{
	/**
	 * Read length of array.
	 *
	 * @param __in The instance.
	 * @param __len The output length.
	 * @since 2019/04/12
	 */
	public abstract void doArrayLength(JavaStackResult.Input __in,
		JavaStackResult.Output __len);
	
	/**
	 * Load from array.
	 *
	 * @param __dt The type of data to load.
	 * @param __in The instance.
	 * @param __dx The index.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	public abstract void doArrayLoad(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Output __v);
	
	/**
	 * Store into array.
	 *
	 * @param __dt The type of data to store.
	 * @param __in The instance.
	 * @param __dx The index.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	public abstract void doArrayStore(DataType __dt,
		JavaStackResult.Input __in, JavaStackResult.Input __dx,
		JavaStackResult.Input __v);
	
	/**
	 * Check that an object is of a given type or thrown exception.
	 *
	 * @param __cl The class to check.
	 * @param __v The object to check.
	 * @since 2019/04/12
	 */
	public abstract void doCheckCast(ClassName __cl,
		JavaStackResult.Input __v);
	
	/**
	 * Loads the class object of a class.
	 *
	 * @param __cl The class object to load.
	 * @param __out The output register.
	 * @since 2019/04/26
	 */
	public abstract void doClassObjectLoad(ClassName __cl,
		JavaStackResult.Output __out);
	
	/**
	 * Performs convert of value.
	 *
	 * @param __as The source type.
	 * @param __a The input.
	 * @param __bs The output type.
	 * @param __b The output.
	 * @since 2019/04/16
	 */
	public abstract void doConvert(StackJavaType __as,
		JavaStackResult.Input __a, StackJavaType __bs,
		JavaStackResult.Output __b);
	
	/**
	 * Performs a copy operation.
	 *
	 * @param __in The input.
	 * @param __out The output.
	 * @since 2019/04/07
	 */
	public abstract void doCopy(JavaStackResult.Input __in,
		JavaStackResult.Output __out);
	
	/**
	 * Reads a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The output value.
	 * @since 2019/04/12
	 */
	public abstract void doFieldGet(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Output __v);
	
	/**
	 * Puts a field.
	 *
	 * @param __fr The field reference.
	 * @param __i The instance.
	 * @param __v The value.
	 * @since 2019/04/12
	 */
	public abstract void doFieldPut(FieldReference __fr,
		JavaStackResult.Input __i, JavaStackResult.Input __v);
	
	/**
	 * Compares two values and then possibly jumps.
	 *
	 * @param __a The first value.
	 * @param __b The second value.
	 * @param __ijt The jump target.
	 * @since 2019/04/12
	 */
	public abstract void doIfICmp(CompareType __ct, JavaStackResult.Input __a,
		JavaStackResult.Input __b, InstructionJumpTarget __ijt);
	
	/**
	 * Invocation of a method.
	 *
	 * @param __t The type of invoke to be performed.
	 * @param __r The reference to the method.
	 * @param __out The output.
	 * @param __in The arguments to the method.
	 * @since 2019/04/10
	 */
	public abstract void doInvoke(InvokeType __t, MethodReference __r,
		JavaStackResult.Output __out, JavaStackResult.Input... __in);
	
	/**
	 * Check that an object is of a given type and sets the stack if it is.
	 *
	 * @param __cl The class to check.
	 * @param __v The object to check.
	 * @param __o The output.
	 * @since 2019/04/16
	 */
	public abstract void doInstanceOf(ClassName __cl,
		JavaStackResult.Input __v, JavaStackResult.Output __o);
	
	/**
	 * Generates a lookup on a lookup table then jumps to a target.
	 *
	 * @param __key The key to check against.
	 * @param __ls The lookup switch.
	 * @since 2019/04/16
	 */
	public abstract void doLookupSwitch(JavaStackResult.Input __key,
		LookupSwitch __ls);
	
	/**
	 * Performs math operation.
	 *
	 * @param __dt The type to operate on.
	 * @param __mt The math operation to perform.
	 * @param __a Argument A.
	 * @param __b Argument B.
	 * @param __c Output.
	 * @since 2019/04/07
	 */
	public abstract void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, JavaStackResult.Input __b,
		JavaStackResult.Output __c);
	
	/**
	 * Performs math operation.
	 *
	 * @param __dt The type to operate on.
	 * @param __mt The math operation to perform.
	 * @param __a Argument A.
	 * @param __b Constant B.
	 * @param __c Output.
	 * @since 2019/04/07
	 */
	public abstract void doMath(StackJavaType __dt, MathType __mt,
		JavaStackResult.Input __a, Number __b, JavaStackResult.Output __c);
	
	/**
	 * Enter or exit the monitor.
	 *
	 * @param __enter Being entered?
	 * @param __o The object to enter or exit.
	 * @since 2019/04/16
	 */
	public abstract void doMonitor(boolean __enter, JavaStackResult.Input __o);
	
	/**
	 * Allocates multi-dimensional array.
	 *
	 * @param __cl The class name.
	 * @param __numdim The number of dimensions.
	 * @param __o The output value.
	 * @param __dims The input dimensions.
	 * @since 2019/05/04
	 */
	public abstract void doMultiANewArray(ClassName __cl, int __numdims,
		JavaStackResult.Output __o, JavaStackResult.Input... __dims);
	
	/**
	 * Allocates new class.
	 *
	 * @param __cn The class to allocate.
	 * @param __out The output.
	 * @since 2019/04/11
	 */
	public abstract void doNew(ClassName __cn, JavaStackResult.Output __out);
	
	/**
	 * Allocates a new array.
	 *
	 * @param __at The array type with all the needed dimensions.
	 * @param __len The length of the array.
	 * @param __out Where the array is to be stored.
	 * @since 2019/04/12
	 */
	public abstract void doNewArray(ClassName __at,
		JavaStackResult.Input __len, JavaStackResult.Output __out);
	
	/**
	 * Loads pool value.
	 *
	 * @param __v The value to load.
	 * @param __out The output.
	 * @since 2019/04/12
	 */
	public abstract void doPoolLoad(Object __v, JavaStackResult.Output __out);
	
	/**
	 * Return of value.
	 *
	 * @param __rv The return value, {@code null} means no value was returned.
	 * @since 2019/04/11
	 */
	public abstract void doReturn(JavaStackResult.Input __in);
	
	/**
	 * Generates code for state operations.
	 *
	 * @param __ops The operations to perform.
	 * @since 2019/04/11
	 */
	public abstract void doStateOperations(StateOperations __ops);
	
	/**
	 * Reads a static field.
	 *
	 * @param __fr The field to read from.
	 * @param __v The output register.
	 * @since 2019/04/12
	 */
	public abstract void doStaticGet(FieldReference __fr,
		JavaStackResult.Output __v);
	
	/**
	 * Writes a static field.
	 *
	 * @param __fr The field to write to.
	 * @param __v The input register.
	 * @since 2019/04/13
	 */
	public abstract void doStaticPut(FieldReference __fr,
		JavaStackResult.Input __v);
	
	/**
	 * Throws the given object.
	 *
	 * @param __in The object to throw.
	 * @since 2019/04/12
	 */
	public abstract void doThrow(JavaStackResult.Input __in);
	
	/**
	 * Finishes handling the instruction operation.
	 *
	 * @since 2019/04/07
	 */
	public abstract void instructionFinish();
	
	/**
	 * Sets up before processing the instruction.
	 *
	 * @since 2019/04/07
	 */
	public abstract void instructionSetup();
	
	/**
	 * Returns the state of the byte code, this must always return the
	 * same object.
	 *
	 * @return The byte code state.
	 * @since 2019/04/06
	 */
	public abstract ByteCodeState state();
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ByteCodeProcessor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533





























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.pool.InvokeType;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValue;
import net.multiphasicapps.classfile.ConstantValueClass;
import net.multiphasicapps.classfile.ConstantValueNumber;
import net.multiphasicapps.classfile.ExceptionHandler;
import net.multiphasicapps.classfile.ExceptionHandlerTable;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InstructionJumpTargets;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodReference;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;

/**
 * This class goes through the byte code for a method and then performs stack
 * and instruction work on it.
 *
 * @since 2019/04/06
 */
public final class ByteCodeProcessor
{
	/** The input byte code to be read. */
	protected final ByteCode bytecode;
	
	/** Handle for byte-code operations. */
	protected final ByteCodeHandler handler;
	
	/** The state of the byte code. */
	protected final ByteCodeState state;
	
	/** Stack map table, needed for local wiping. */
	protected final StackMapTable stackmaptable;
	
	/** Reverse jump table. */
	private final Map<Integer, InstructionJumpTargets> _revjumps;
	
	/** Jump targets for this instruction. */
	private InstructionJumpTargets _ijt;
	
	/** Flase is the preprocessor state, otherwise run the handler. */
	private boolean _dohandling;
	
	/** Is an exception possible. */
	private boolean _canexception;
	
	/**
	 * Initializes the byte code processor.
	 *
	 * @param __bc The target byte code.
	 * @param __h Handler for the byte code operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public ByteCodeProcessor(ByteCode __bc, ByteCodeHandler __h)
		throws NullPointerException
	{
		if (__bc == null || __h == null)
			throw new NullPointerException("NARG");
		
		this.bytecode = __bc;
		this.handler = __h;
		
		// The state is used to share between the processor and the handler
		ByteCodeState state = __h.state();
		this.state = state;
		
		// Load initial Java stack state from the initial stack map
		JavaStackState s;
		StackMapTable stackmaptable = __bc.stackMapTable();
		this.stackmaptable = stackmaptable;
		state.stack = (s = JavaStackState.of(stackmaptable.get(0),
			__bc.writtenLocals()));
		state.stacks.put(0, s);
		
		// Reverse jump table to detect jump backs
		this._revjumps = __bc.reverseJumpTargets();
		
		// Get details and names of the stuff
		state.classname = __bc.thisType();
		state.methodname = __bc.name();
		state.methodtype = __bc.type();
		
		// Store info
		state.exceptionranges = new ExceptionHandlerRanges(__bc);
	}
	
	/**
	 * Processes the byte code and calls the destination handler.
	 *
	 * @since 2019/04/06
	 */
	public final void process()
	{
		// Run process
		try
		{
			this.__aaaProcess();
		}
		
		// {@squirreljme.error JC17 Failed to process the byte code, this may
		// be due to an invalid class or an internal compiler error. (The
		// last processed instruction)}
		catch (InvalidClassFormatException|IllegalArgumentException|
			 IllegalStateException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC17 " + this.state, e);
		}
	}
	
	/**
	 * Processes the byte code and calls the destination handler.
	 *
	 * @since 2019/04/06
	 */
	private final void __aaaProcess()
	{
		ByteCode bytecode = this.bytecode;
		ByteCodeState state = this.state;
		ByteCodeHandler handler = this.handler;
		StackMapTable stackmaptable = this.stackmaptable;
		Map<Integer, JavaStackState> stacks = state.stacks;
		Map<Integer, StateOperations> stackpoison = state.stackpoison;
		
		// Go through each operation twice, performing pre-processing first
		// to make things a bit simpler and more well known when it comes
		// to caching.
		for (int pp = 0; pp < 2; pp++)
		{
			// Is handling to be done?
			boolean dohandling = (pp != 0);
			this._dohandling = dohandling;
			
			// Since this is the start, the last address needs to be reset
			// because it will be invalid!
			state.lastaddr = -1;
			state.followaddr = -1;
			
			// Process instruction
			Instruction lastinst = null;
			SimplifiedJavaInstruction lastsji = null;
			for (Instruction inst : bytecode)
			{
				// Translate to simple instruction for easier handling
				SimplifiedJavaInstruction sji =
					new SimplifiedJavaInstruction(inst);
				
				// Debug
				if (__Debug__.ENABLED)
					todo.DEBUG.note("%s %s (%s)", (dohandling ? "Handling" :
						"Preprocessing"), sji, inst);
				
				// Current instruction info
				state.instruction = inst;
				state.simplified = sji;
				
				// Store the last processed address
				state.lastaddr = state.addr;
				
				// Current processing this address
				int addr = inst.address();
				state.addr = addr;
				
				// Set line where this code was found
				state.line = bytecode.lineOfAddress(addr);
				
				// Following address, may be used to calculate if the stack
				// needs to be transitioned
				state.followaddr = bytecode.addressFollowing(addr);
				
				// These jump targets are used to map out the state of stacks
				// across various points
				InstructionJumpTargets ijt, rijt;
				this._ijt = (ijt = inst.jumpTargets());
				state.jumptargets = ijt;
				
				// Reverse jump targets are used to detect jumps to previous
				// addresses
				rijt = this._revjumps.get(addr);
				state.reversejumptargets = (rijt != null ? rijt :
					new InstructionJumpTargets());
				
				// Get the stack, which must exist
				JavaStackState stack = stacks.get(addr);
				if (stack == null)
				{
					// Some code generated by the older compilers ends up
					// defining parts of loops or exception handlers which
					// are defined but completely skipped via a goto, but they
					// are then taken back to this point. They should hopefully
					// have a stack map state defined for them, so just
					// initialize a blank state from that instead.
					StackMapTableState smts = stackmaptable.get(addr);
					if (smts != null)
						stack = JavaStackState.of(smts,
							this.bytecode.writtenLocals());
					
					// {@squirreljme.error JC18 No recorded stack state for
					// this position. (The address to check)}
					if (stack == null)
						throw new InvalidClassFormatException("JC18 " + addr);
				}
				
				// Load stack
				state.stack = stack;
				
				// Reset exception possibility, this is used to determine
				// if the stack update should actually accept exception
				// targets even if they are specified
				this._canexception = false;
				state.canexception = false;
				
				// Preprocessing operations
				if (!dohandling)
				{
					// If there is a stack map table, adjust types that are
					// used on the stack along with the removal of locals
					// and such
					StackMapTableState smts = stackmaptable.get(addr);
					if (smts != null)
					{
						// Debug
						if (__Debug__.ENABLED)
							todo.DEBUG.note("SMT BEF: %s", stack);
						
						stack = stack.filterByStackMap(smts);
						
						// Debug
						if (__Debug__.ENABLED)
							todo.DEBUG.note("SMT AFT: %s", stack);
					}
					
					// If we are jumping back to this instruction at any point
					// we need to flush the stack so that nothing is cached on
					// it. The resulting flushed stack is then used instead
					// Note that if we jump to ourselves we might have entered
					// with something cached and might end up using that when
					// we do not want to
					if (state.reversejumptargets.hasSameOrLaterAddress(addr))
					{
						// Perform a flush of the cache
						JavaStackResult fres = stack.doCacheFlush();
						
						// Set natural flow as poisoned, operations have to
						// be done to match the correct state
						StateOperations sops = fres.operations();
						if (!sops.isEmpty())
							stackpoison.put(addr, sops);
						
						// Use the result of the flush as the state instead so
						// that it propagates ahead from now on
						stack = fres.after();
					}
					
					// Was the stack changed?
					if (state.stack != stack)
						state.stack = stack;
				}
				
				// Handle instruction
				else
				{
					// Call pre-handler
					handler.instructionSetup();
					
					// If the stack has been adjusted for any reason, replace
					// the stored stack for this point
					JavaStackState mns = state.stack;
					if (!stack.equals(mns))
						stacks.put(addr, (stack = mns));
				}
				
				// Handle the operation
				switch (sji.operation())
				{
						// Object array load
					case InstructionIndex.AALOAD:
						this.__doArrayLoad(null);
						break;
						
						// Object array store
					case InstructionIndex.AASTORE:
						this.__doArrayStore(null);
						break;
						
						// Null constant
					case InstructionIndex.ACONST_NULL:
						this.__doAConstNull();
						break;
						
						// Allocate new array
					case InstructionIndex.ANEWARRAY:
						this.__doNewArray(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// Length of array
					case InstructionIndex.ARRAYLENGTH:
						this.__doArrayLength();
						break;
						
						// Throw exception
					case InstructionIndex.ATHROW:
						this.__doThrow();
						break;
						
						// Check that object is of a type, or fail
					case InstructionIndex.CHECKCAST:
						this.__doCheckCast(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// Convert data
					case SimplifiedJavaInstruction.CONVERT:
						this.__doConvert(sji.<StackJavaType>argument(0,
								StackJavaType.class),
							sji.<StackJavaType>argument(1,
								StackJavaType.class));
						break;
						
						// Get field
					case InstructionIndex.GETFIELD:
						this.__doFieldGet(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Get static
					case InstructionIndex.GETSTATIC:
						this.__doStaticGet(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Goto
					case InstructionIndex.GOTO:
						this.__doGoto(sji.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class));
						break;
						
						// If comparison against zero
					case SimplifiedJavaInstruction.IF:
						this.__doIf(sji.<DataType>argument(0, DataType.class),
							sji.<CompareType>argument(1, CompareType.class),
							sji.<InstructionJumpTarget>argument(2,
								InstructionJumpTarget.class));
						break;
						
						// Compare two values
					case SimplifiedJavaInstruction.IF_CMP:
						this.__doIfCmp(
							sji.<DataType>argument(0, DataType.class),
							sji.<CompareType>argument(1, CompareType.class),
							sji.<InstructionJumpTarget>argument(2,
								InstructionJumpTarget.class));
						break;
						
						// Increment local
					case InstructionIndex.IINC:
						this.__doIInc(sji.intArgument(0), sji.intArgument(1));
						break;
						
						// Invoke interface
					case InstructionIndex.INVOKEINTERFACE:
						this.__doInvoke(InvokeType.INTERFACE,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
					
						// Invoke special
					case InstructionIndex.INVOKESPECIAL:
						this.__doInvoke(InvokeType.SPECIAL,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
					
						// Invoke static
					case InstructionIndex.INVOKESTATIC:
						this.__doInvoke(InvokeType.STATIC,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
						
						// Invoke virtual
					case InstructionIndex.INVOKEVIRTUAL:
						this.__doInvoke(InvokeType.VIRTUAL,
							sji.<MethodReference>argument(0,
								MethodReference.class));
						break;
						
						// Checks that the given class is an instance of an
						// object.
					case InstructionIndex.INSTANCEOF:
						this.__doInstanceOf(sji.<ClassName>argument(0,
							ClassName.class));
						break;
					
						// Load constant
					case InstructionIndex.LDC:
						this.__doLdc(sji.<ConstantValue>argument(0,
							ConstantValue.class));
						break;
					
						// Load local variable to the stack
					case SimplifiedJavaInstruction.LOAD:
						this.__doLoad(sji.<DataType>argument(0,
							DataType.class), sji.intArgument(1));
						break;
						
						// Lookup switch
					case InstructionIndex.LOOKUPSWITCH:
						this.__doLookupSwitch(sji.<LookupSwitch>argument(0,
							LookupSwitch.class));
						break;
						
						// Math
					case SimplifiedJavaInstruction.MATH:
						this.__doMath(sji.<DataType>argument(0,
							DataType.class), sji.<MathType>argument(1,
								MathType.class));
						break;
						
						// Math with constant
					case SimplifiedJavaInstruction.MATH_CONST:
						this.__doMathConst(sji.<DataType>argument(0,
							DataType.class), sji.<MathType>argument(1,
								MathType.class), sji.<Number>argument(2,
									Number.class));
						break;
						
						// Enter monitor
					case InstructionIndex.MONITORENTER:
						this.__doMonitor(true);
						break;
						
						// Exit monitor
					case InstructionIndex.MONITOREXIT:
						this.__doMonitor(false);
						break;
					
						// Multiple new array
					case InstructionIndex.MULTIANEWARRAY:
						this.__doMultiANewArray(
							sji.<ClassName>argument(0, ClassName.class),
							sji.intArgument(1));
						break;
					
						// Create new instance of something
					case InstructionIndex.NEW:
						this.__doNew(sji.<ClassName>argument(0,
							ClassName.class));
						break;
						
						// This literally does nothing so no output code needs to
						// be generated at all
					case InstructionIndex.NOP:
						this.__doNop();
						break;
						
						// Primitive array load
					case SimplifiedJavaInstruction.PALOAD:
						this.__doArrayLoad(sji.<PrimitiveType>argument(0,
							PrimitiveType.class));
						break;
						
						// Primitive array store
					case SimplifiedJavaInstruction.PASTORE:
						this.__doArrayStore(sji.<PrimitiveType>argument(0,
							PrimitiveType.class));
						break;
					
						// Put of instance field
					case InstructionIndex.PUTFIELD:
						this.__doFieldPut(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
						
						// Put static field
					case InstructionIndex.PUTSTATIC:
						this.__doStaticPut(sji.<FieldReference>argument(0,
							FieldReference.class));
						break;
					
						// Return from method, with no return value
					case InstructionIndex.RETURN:
						this.__doReturn(null);
						break;
					
						// Stack shuffle
					case SimplifiedJavaInstruction.STACKSHUFFLE:
						this.__doStackShuffle(
							sji.<JavaStackShuffleType>argument(0,
								JavaStackShuffleType.class));
						break;
					
						// Place stack variable into local
					case SimplifiedJavaInstruction.STORE:
						this.__doStore(sji.<DataType>argument(0,
							DataType.class), sji.intArgument(1));
						break;
						
						// Return value
					case SimplifiedJavaInstruction.VRETURN:
						this.__doReturn(sji.<DataType>argument(0,
							DataType.class).toJavaType());
						break;
					
						// Not yet implemented
					default:
						throw new todo.OOPS(
							sji.toString() + "/" + inst.toString());
				}
				
				// Call post-handler
				if (dohandling)
					handler.instructionFinish();
				
				// Set last
				lastsji = sji;
				lastinst = inst;
			}
		}
	}
	
	/**
	 * Pushes a null constant to the stack.
	 *
	 * @since 2019/04/16
	 */
	private final void __doAConstNull()
	{
		// -> [ref]
		JavaStackResult result = state.stack.doStack(0, JavaType.OBJECT);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doCopy(JavaStackResult.INPUT_ZERO, result.out(0));
	}
	
	/**
	 * Gets length of array.
	 *
	 * @since 2019/04/06
	 */
	private final void __doArrayLength()
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [array] -> [len]
		JavaStackResult result = state.stack.doStack(1, JavaType.INTEGER);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayLength(result.in(0), result.out(0));
	}
	
	/**
	 * Loads value from value.
	 *
	 * @param __pt The type to load, {@code null} is considered to be an
	 * object.
	 * @since 2019/04/06
	 */
	private final void __doArrayLoad(PrimitiveType __pt)
	{
		// An exception may be thrown
		this._canexception = true;
		
		// This is easily determined from the primitive type
		JavaType faketype;
		if (__pt != null)
			faketype = __pt.stackJavaType();
		
		// Otherwise, pop twice and see what the array is and work from
		// that
		else
		{
			// Pop two
			JavaStackResult wouldbe = state.stack.doStack(2);
			
			// Get the base type
			ClassName maybecl = wouldbe.in(0).type.type().className();
			
			// If this is an array then get the component type and work
			// from it, otherwise just assume it is Object since we could
			// not derive that info at all
			faketype = (maybecl.isArray() ?
				new JavaType(maybecl.componentType()) : JavaType.OBJECT);
		}
		
		// [array, index] -> [value]
		JavaStackResult result = state.stack.doStack(2, faketype);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayLoad(DataType.of(__pt), result.in(0),
			result.in(1), result.out(0));
	}
	
	/**
	 * Stores value into an array.
	 *
	 * @param __pt The type to store, {@code null} is considered to be an
	 * object.
	 * @since 2019/04/06
	 */
	private final void __doArrayStore(PrimitiveType __pt)
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [array, index, value]
		JavaStackResult result = state.stack.doStack(3);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doArrayStore(DataType.of(__pt), result.in(0),
			result.in(1), result.in(2));
	}
	
	/**
	 * Checks that the object on the stack is of the given type.
	 *
	 * @param __cn The name of the class to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doCheckCast(ClassName __cn)
		throws NullPointerException
	{
		// An exception may be thrown
		this._canexception = true;
		
		// [object] -> [object]
		JavaStackResult result = this.state.stack.doCheckCast(
			new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Do check cast
		this.handler.doCheckCast(__cn, result.in(0));
	}
	
	/**
	 * Converts from one Java type to another
	 *
	 * @param __from The source type.
	 * @param __to The destination type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doConvert(StackJavaType __from, StackJavaType __to)
		throws NullPointerException
	{
		if (__from == null || __to == null)
			throw new NullPointerException("NARG");
		
		// [from] -> [to]
		JavaStackResult result = state.stack.doStack(1, __to.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doConvert(__from, result.in(0), __to, result.out(0));
	}
	
	/**
	 * Reads a value from a field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doFieldGet(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [inst] -> [value]
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(1,
			new JavaType(__fr.memberType()));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doFieldGet(__fr, result.in(0), result.out(0));
	}
	
	/**
	 * Puts a value into a field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doFieldPut(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [inst, value] ->
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(2);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doFieldPut(__fr, result.in(0), result.in(1));
	}
	
	/**
	 * Goes to another address.
	 *
	 * @param __jt The target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doGoto(InstructionJumpTarget __jt)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Do nothing!
		this.__update(this.state.stack.doNothing());
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Just do an always true comparison on the zero register
		this.handler.doIfICmp(CompareType.TRUE, JavaStackResult.INPUT_ZERO,
			JavaStackResult.INPUT_ZERO, __jt);
	}
	
	/**
	 * Performs if comparison against zero.
	 *
	 * @param __type The type to work with on the stack.
	 * @param __ct The comparison type.
	 * @param __ijt The instruction jump target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/05
	 */
	private final void __doIf(DataType __type, CompareType __ct,
		InstructionJumpTarget __ijt)
		throws NullPointerException
	{
		if (__type == null || __ct == null || __ijt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC19 Cannot compare float or double.}
		if (__type == DataType.FLOAT || __type == DataType.DOUBLE)
			throw new IllegalArgumentException("JC19");
		
		// [val] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doIfICmp(__ct, result.in(0), JavaStackResult.INPUT_ZERO,
			__ijt);
	}
	
	/**
	 * Performs if comparison of two values against each other.
	 *
	 * @param __type The type to work with on the stack.
	 * @param __ct The comparison type.
	 * @param __ijt The instruction jump target.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doIfCmp(DataType __type, CompareType __ct,
		InstructionJumpTarget __ijt)
		throws NullPointerException
	{
		if (__type == null || __ct == null || __ijt == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC1a Cannot compare float or double.}
		if (__type == DataType.FLOAT || __type == DataType.DOUBLE)
			throw new IllegalArgumentException("JC1a");
		
		// [a, b] ->
		JavaStackResult result = this.state.stack.doStack(2);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doIfICmp(__ct, result.in(0), result.in(1), __ijt);
	}
	
	/**
	 * Increments local variable.
	 *
	 * @param __l The local to increment.
	 * @param __v The value to increment by.
	 * @since 2019/04/06
	 */
	private final void __doIInc(int __l, int __v)
	{
		// Just write an integer to the integer so its state is known
		JavaStackResult result = this.state.stack.
			doLocalSet(JavaType.INTEGER, __l);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
			
		// There might be items on the stack which were cached and now no
		// longer are because they got pulverized, so de-cache those
		ByteCodeHandler handler = this.handler;
		handler.doStateOperations(result.operations());
		
		// Add value
		handler.doMath(StackJavaType.INTEGER, MathType.ADD,
			result.out(0).asInput(), __v,
			result.out(0));
	}
	
	/**
	 * Checks that the class is the given instance.
	 *
	 * @param __cl The class to check.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doInstanceOf(ClassName __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// [object] -> [int]
		JavaStackResult result = this.state.stack.doStack(1, JavaType.INTEGER);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doInstanceOf(__cl, result.in(0), result.out(0));
	}
	
	/**
	 * Handles invocation of other methods.
	 *
	 * @param __t The type of invocation to perform.
	 * @param __r The method to invoke.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doInvoke(InvokeType __t, MethodReference __r)
		throws NullPointerException
	{
		if (__t == null || __r == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Return value type, if any
		MethodHandle mf = __r.handle();
		FieldDescriptor rv = mf.descriptor().returnValue();
		boolean hasrv = (rv != null);
		
		// The number of arguments to pop is the instance (if non-static) and
		// the number of arguments taken
		int popcount = (__t.hasInstance() ? 1 : 0) +
			mf.descriptor().argumentCount();
		
		// Perform stack operation
		ByteCodeState state = this.state;
		JavaStackResult result = (!hasrv ? state.stack.doStack(popcount) :
			state.stack.doStack(popcount, new JavaType(rv)));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doInvoke(__t, __r, (!hasrv ? null :
			result.out(0)), result.in());
	}
	
	/**
	 * Loads constant value onto the stack.
	 *
	 * @param __v The value to push.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doLdc(ConstantValue __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		// Get push properties
		JavaType jt = __v.type().javaType();
		
		// An exception is only throwable on classes, because the class
		// could potentially fail to initialize properly
		this._canexception = (__v instanceof ConstantValueClass);
		
		// Push to the stack this type, the result is always cached
		JavaStackResult result = this.state.stack.doStack(0, true, jt);
		this.__update(result);
		
		// Do not call generator, we just want the stack result
		if (!this._dohandling)
			return;
		
		// Call the appropriate handler
		ByteCodeHandler handler = this.handler;
		switch (__v.type())
		{
			case INTEGER:
				handler.doMath(StackJavaType.INTEGER, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Integer)__v.boxedValue(),
					result.out(0));
				break;
				
			case FLOAT:
				handler.doMath(StackJavaType.FLOAT, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Float)__v.boxedValue(),
					result.out(0));
				break;
			
			case LONG:
				handler.doMath(StackJavaType.LONG, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Long)__v.boxedValue(),
					result.out(0));
				break;
				
			case DOUBLE:
				handler.doMath(StackJavaType.DOUBLE, MathType.OR,
					JavaStackResult.INPUT_ZERO, (Double)__v.boxedValue(),
					result.out(0));
				break;
			
			case STRING:
				handler.doPoolLoad(__v.boxedValue(), result.out(0));
				break;
				
			case CLASS:
				handler.doClassObjectLoad((ClassName)__v.boxedValue(),
					result.out(0));
				break;
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Loads from a local and puts to the stack.
	 *
	 * @param __jt The type to push.
	 * @param __from The source local.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	private final void __doLoad(DataType __jt, int __from)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Load from local variable
		JavaStackResult result = this.state.stack.doLocalLoad(__from);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Only perform the copy if the value is different, because otherwise
		// it would have just been cached
		if (result.in(0).register != result.out(0).register)
			handler.doCopy(result.in(0), result.out(0));
	}
	
	/**
	 * Handles lookup switch.
	 *
	 * @param __ls The switch.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	private final void __doLookupSwitch(LookupSwitch __ls)
		throws NullPointerException
	{
		if (__ls == null)
			throw new NullPointerException("NARG");
		
		// [key] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doLookupSwitch(result.in(0), __ls);
	}
	
	/**
	 * Performs math operation.
	 *
	 * @param __pt The primitive type.
	 * @param __mot The math operation type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doMath(DataType __pt, MathType __mot)
		throws NullPointerException
	{
		if (__pt == null || __mot == null)
			throw new NullPointerException("NARG");
		
		// We may throw an exception here if we divide by zero!
		if (__pt == DataType.INTEGER || __pt == DataType.LONG)
			if (__mot == MathType.DIV || __mot == MathType.REM)
				this._canexception = true;
		
		// [a, b] -> [result]
		JavaStackResult result = this.state.stack.doStack(2,
			__pt.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Perform the math
		this.handler.doMath(__pt.toStackJavaType(), __mot, result.in(0),
			result.in(1), result.out(0));
	}
	
	/**
	 * Performs math operation with constant.
	 *
	 * @param __pt The primitive type.
	 * @param __mot The math operation type.
	 * @param __c The constant.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doMathConst(DataType __pt, MathType __mot, Number __c)
		throws NullPointerException
	{
		if (__pt == null || __mot == null || __c == null)
			throw new NullPointerException("NARG");
		
		// [a, b] -> [result]
		JavaStackResult result = this.state.stack.doStack(1,
			__pt.toJavaType());
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Monitor operation
		this.handler.doMath(__pt.toStackJavaType(), __mot, result.in(0),
			__c, result.out(0));
	}
	
	/**
	 * Enters or exits the monitor.
	 *
	 * @param __enter If the monitor is to be entered.
	 * @since 2019/04/16
	 */
	private final void __doMonitor(boolean __enter)
	{
		// Can toss exception
		this._canexception = true;
		
		// [object] ->
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Monitor operation
		this.handler.doMonitor(__enter, result.in(0));
	}
	
	/**
	 * Allocate multi-dimensional array.
	 *
	 * @param __cl The class to allocate.
	 * @param __dims The number of dimensions to allocate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/04
	 */
	private final void __doMultiANewArray(ClassName __cl, int __dims)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
			
		// Can toss exception
		this._canexception = true;
		
		// [__dims, ...] -> [object]
		JavaStackResult result = this.state.stack.doStack(__dims,
			new JavaType(__cl));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle array creation
		this.handler.doMultiANewArray(__cl, __dims, result.out(0),
			result.in());
	}
	
	/**
	 * Creates a new instance of the given class.
	 *
	 * @param __cn The class to create.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doNew(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Just the type is pushed to the stack
		JavaStackResult result = this.state.stack.
			doStack(0, new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doNew(__cn, result.out(0));
	}
	
	/**
	 * Allocates a new array.
	 *
	 * @param __cn The component type of the array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/05
	 */
	private final void __doNewArray(ClassName __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// Add dimension to the class since it lacks it
		__cn = __cn.addDimensions(1);
		
		// [len] -> [array]
		JavaStackResult result = this.state.stack.
			doStack(1, new JavaType(__cn));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Generate
		this.handler.doNewArray(__cn, result.in(0), result.out(0));
	}
	
	/**
	 * Do nothing.
	 *
	 * @since 2019/04/07
	 */
	private final void __doNop()
	{
		// Just do nothing
		this.__update(this.state.stack.doNothing());
	}
	
	/**
	 * Handles returning.
	 *
	 * @param __rt The type to return, {@code null} means nothing is to be
	 * returned.
	 * @since 2019/04/03
	 */
	private final void __doReturn(JavaType __rt)
	{
		ByteCodeState state = this.state;
		
		// Destroy everything and bring destruction to the method!!!
		JavaStackResult result = state.stack.doDestroy(__rt != null);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Call handler
		this.handler.doReturn((__rt != null ? result.in(0) : null));
	}
	
	/**
	 * Performs shuffling of the stack.
	 *
	 * @param __st The type of shuffle to do.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	private final void __doStackShuffle(JavaStackShuffleType __st)
		throws NullPointerException
	{
		if (__st == null)
			throw new NullPointerException("NARG");
		
		// Shuffle the stack
		JavaStackResult result = this.state.stack.doStackShuffle(__st);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Potentially run state operations as needed
		StateOperations ops = result.operations();
		if (!ops.isEmpty())
			this.handler.doStateOperations(ops);
	}
	
	/**
	 * Reads a value from a static field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doStaticGet(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [] -> [value]
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(0,
			new JavaType(__fr.memberType()));
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doStaticGet(__fr, result.out(0));
	}
	
	/**
	 * Writes to static field.
	 *
	 * @param __fr The field reference.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	private final void __doStaticPut(FieldReference __fr)
		throws NullPointerException
	{
		if (__fr == null)
			throw new NullPointerException("NARG");
		
		// An exception may be thrown
		this._canexception = true;
		
		// [value] ->
		ByteCodeState state = this.state;
		JavaStackResult result = state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Forward
		this.handler.doStaticPut(__fr, result.in(0));
	}
	
	/**
	 * Stores an entry on the stack.
	 *
	 * @param __jt The type to pop.
	 * @param __to The destination local.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	private final void __doStore(DataType __jt, int __to)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
		
		// Store onto the stack, locals are never cached
		JavaStackResult result = this.state.stack.doLocalStore(__to);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// There might be items on the stack which were cached and now no
		// longer are because they got pulverized, so de-cache those
		ByteCodeHandler handler = this.handler;
		handler.doStateOperations(result.operations());
		
		// Perform plain copy
		handler.doCopy(result.in(0), result.out(0));
	}
	
	/**
	 * Performs a throw of an exception on the stack.
	 *
	 * @since 2019/04/05
	 */
	private final void __doThrow()
	{
		// An exception will be thrown
		this._canexception = true;
		
		// Pop item from the stack
		JavaStackResult result = this.state.stack.doStack(1);
		this.__update(result);
		
		// Stop pre-processing here
		if (!this._dohandling)
			return;
		
		// Handle
		this.handler.doThrow(result.in(0));
	}
	
	/**
	 * Updates the stack state and result.
	 *
	 * @param __jsr The stack result.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/07
	 */
	private final void __update(JavaStackResult __jsr)
		throws NullPointerException
	{
		if (__jsr == null)
			throw new NullPointerException("NARG");
		
		// The new stack state
		JavaStackState newstack = __jsr.after();
		
		// Needed for processing
		ByteCodeState state = this.state;
		Map<Integer, JavaStackState> stacks = state.stacks;
		int addr = state.addr;
		
		// Store result and the new stack
		state.result = __jsr;
		state.stack = newstack;
		
		// Can an exception handler be called?
		boolean canexception = this._canexception;
		state.canexception = canexception;
		
		// Target stack states are not touched in the normal handling state
		// because collisions and transitioning of states is handled in the
		// pre-processing step
		if (this._dohandling)
			return;
		
		// The result of the jump calculations may result in the stack
		// being poisoned potentially
		Map<Integer, StateOperations> stackpoison = state.stackpoison;
		Map<Integer, JavaStackEnqueueList> stackcollides = state.stackcollides;
		
		// Set target stack states for destinations of this instruction
		// Calculate the exception state only if it is needed
		JavaStackState hypoex = null;
		InstructionJumpTargets ijt = this._ijt;
		if (ijt != null && !ijt.isEmpty())
			for (int i = 0, n = ijt.size(); i < n; i++)
			{
				int jta = ijt.get(i).target();
				
				// If an exception is never thrown by the instruction being
				// processed then just ignore any exception points which may
				// be defined since they will have no effect
				boolean isexception = ijt.isException(i);
				if (!canexception && isexception)
					continue;
				
				// Lazily calculate the exception handler since it might
				// not always be needed
				if (isexception && hypoex == null)
					hypoex = newstack.doExceptionHandler(new JavaType(
						new ClassName("java/lang/Throwable"))).after();
				
				// The type of stack to target
				JavaStackState use = (isexception ? hypoex : newstack);
				
				// Is empty state, use this state because we defined it first
				JavaStackState dss = stacks.get(jta);
				if (dss == null)
					stacks.put(jta, use);
				
				// For later addresses which do not have an exact stack state
				// match, a partial un-cache will have to be used.
				// Note that jump backs are ignored here since those were
				// processed and we cannot adjust the states anymore
				else if (jta > addr && !use.canTransition(dss))
				{
					// Debug
					if (__Debug__.ENABLED)
					{
						todo.DEBUG.note("Transition is required! %d -> %d",
							addr, jta);
						todo.DEBUG.note("From: %s", use);
						todo.DEBUG.note("To  : %s", dss);
					}
					
					// Get pre-existing collision state here, if any
					JavaStackEnqueueList preq = stackcollides.get(jta);
					if (preq == null)
						preq = new JavaStackEnqueueList(0);
					
					// Merge these two register lists
					JavaStackEnqueueList mcol = JavaStackEnqueueList.merge(
						preq, use.cacheCollision(dss));
					
					// Store the resulting collision
					stacks.put(jta, (dss = dss.cacheClearState(mcol)));
					
					// Debug
					if (__Debug__.ENABLED)
						todo.DEBUG.note("Coll: %s", dss);
				}
			}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ByteCodeState.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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionJumpTargets;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This represents the state of the byte code.
 *
 * @since 2019/04/06
 */
public class ByteCodeState
{
	/** The positions of all the stack information. */
	public final Map<Integer, JavaStackState> stacks =
		new LinkedHashMap<>();
		
	/** Addresses where the natural entry to the operation is poisoned. */
	public final Map<Integer, StateOperations> stackpoison =
		new LinkedHashMap<>();
	
	/** Stack collisions when a jump to the target does collide. */
	public final Map<Integer, JavaStackEnqueueList> stackcollides =
		new LinkedHashMap<>();
	
	/** Java instruction. */
	public Instruction instruction;
	
	/** Simplified instruction. */
	public SimplifiedJavaInstruction simplified;
	
	/** The resulting stack. */
	public JavaStackState stack;
	
	/** The result of the operation. */
	public JavaStackResult result;
	
	/** Can an exception handler be called? */
	public boolean canexception;
	
	/** Class name. */
	public ClassName classname;
	
	/** The method descriptor. */
	public MethodDescriptor methodtype;
	
	/** The method name. */
	public MethodName methodname;
	
	/** Exception ranges. */
	public ExceptionHandlerRanges exceptionranges;
	
	/** The current source line being processed. */
	public int line =
		-1;
	
	/** The last address processed. */
	public int lastaddr =
		-1;
	
	/** The current address being processed. */
	public int addr =
		-1;
	
	/** The address of the following instruction. */
	public int followaddr =
		-1;
	
	/** Jump targets for the instruction. */
	public InstructionJumpTargets jumptargets;
	
	/** Reverse jump targets for this instruction. */
	public InstructionJumpTargets reversejumptargets;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/07
	 */
	@Override
	public String toString()
	{
		return String.format("{i=%s, si=%s, jss=%s, jsr=%s, ce=%b, " +
			"ln=%d, la=%d, a=%d, fa=%d, jt=%s, rjt=%s, cl=%s, mn=%s, mt=%s}",
			this.instruction,
			this.simplified,
			this.stack,
			this.result,
			this.canexception,
			this.line,
			this.lastaddr,
			this.addr,
			this.followaddr,
			this.jumptargets,
			this.reversejumptargets,
			this.classname,
			this.methodname,
			this.methodtype);
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/CompareType.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
66
67
68
69
70
71
72








































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.xlate;

/**
 * This represents the type of comparison to perform.
 *
 * @since 2019/03/26
 */
public enum CompareType
{
	/** Equals. */
	EQUALS,
	
	/** Not equals. */
	NOT_EQUALS,
	
	/** Less than. */
	LESS_THAN,
	
	/** Less or equals. */
	LESS_THAN_OR_EQUALS,
	
	/** Greater than. */
	GREATER_THAN,
	
	/** Greater or equals. */
	GREATER_THAN_OR_EQUALS,
	
	/** Always true. */
	TRUE,
	
	/** Always false. */
	FALSE,
	
	/** End. */
	;
	
	/**
	 * Returns the compare type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting compare type.
	 * @since 2019/04/08
	 */
	public static final CompareType of(int __i)
	{
		switch (__i)
		{
			case 0:		return EQUALS;
			case 1:		return NOT_EQUALS;
			case 2:		return LESS_THAN;
			case 3:		return LESS_THAN_OR_EQUALS;
			case 4:		return GREATER_THAN;
			case 5:		return GREATER_THAN_OR_EQUALS;
			case 6:		return TRUE;
			case 7:		return FALSE;
		}
		
		// {@squirreljme.error JC1b Invalid compare operation.}
		throw new IllegalArgumentException("JC1b");
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/DataType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243



















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.PrimitiveType;

/**
 * Represents the data type to use for read/write.
 *
 * @since 2019/03/24
 */
public enum DataType
{
	/** Object. */
	OBJECT,
	
	/** Byte. */
	BYTE,
	
	/** Short. */
	SHORT,
	
	/** Character. */
	CHARACTER,
	
	/** Integer. */
	INTEGER,
	
	/** Float. */
	FLOAT,
	
	/** Long. */
	LONG,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
	
	/**
	 * Is this a wide data type?
	 *
	 * @return If this is wide.
	 * @since 2019/04/20
	 */
	public final boolean isWide()
	{
		return (this == LONG || this == DOUBLE);
	}
	
	/**
	 * Returns the size of the data type.
	 *
	 * @return The data size type.
	 * @since 2019/04/20
	 */
	public final int size()
	{
		switch (this)
		{
			case BYTE:		return 1;
			case SHORT:
			case CHARACTER:	return 2;
			case INTEGER:
			case FLOAT:
			case OBJECT:	return 4;
			case LONG:
			case DOUBLE:	return 8;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns this as a basic Java type.
	 *
	 * @return The Java type of this.
	 * @since 2019/04/06
	 */
	public final JavaType toJavaType()
	{
		switch (this)
		{
			case OBJECT:	return JavaType.OBJECT;
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the stack Java type for this data type.
	 *
	 * @return The stack type for this Java type.
	 * @since 2019/04/12
	 */
	public final StackJavaType toStackJavaType()
	{
		switch (this)
		{
			case OBJECT:	
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return StackJavaType.INTEGER;
			case FLOAT:		return StackJavaType.FLOAT;
			case LONG:		return StackJavaType.LONG;
			case DOUBLE:	return StackJavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the data type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting compare type.
	 * @since 2019/04/08
	 */
	public static final DataType of(int __i)
	{
		switch (__i)
		{
			case 0:		return OBJECT;
			case 1:		return BYTE;
			case 2:		return SHORT;
			case 3:		return CHARACTER;
			case 4:		return INTEGER;
			case 5:		return FLOAT;
			case 6:		return LONG;
			case 7:		return DOUBLE;
		}
		
		// {@squirreljme.error JC1c Invalid data type.}
		throw new IllegalArgumentException("JC1c");
	}
	
	/**
	 * Returns the data type used for the primitive type.
	 *
	 * @param __t The type to use, {@code null} is treated as a pointer.
	 * @return The data type used.
	 * @since 2019/03/24
	 */
	public static final DataType of(PrimitiveType __t)
	{
		if (__t == null)
			return OBJECT;
		
		switch (__t)
		{
			case BOOLEAN:
			case BYTE:		return BYTE;
			case CHARACTER:	return CHARACTER;
			case SHORT:		return SHORT;
			case INTEGER:	return INTEGER;
			case LONG:		return LONG;
			case FLOAT:		return FLOAT;
			case DOUBLE:	return DOUBLE;
			
			default:
				throw new todo.OOPS(__t.name());
		}
	}
	
	/**
	 * Returns the data type of the given Java type.
	 *
	 * @param __t The type to get.
	 * @return The data type used for this type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/27
	 */
	public static final DataType of(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return DataType.of(__t.type().primitiveType());
	}
	
	/**
	 * Returns the data type of the given field descriptor.
	 *
	 * @param __t The type to get.
	 * @return The data type used for this type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public static final DataType of(FieldDescriptor __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return DataType.of(__t.primitiveType());
	}
	
	/**
	 * Returns the data type of the given stack type.
	 *
	 * @param __t The stack type used.
	 * @return The resulting data type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/27
	 */
	public static final DataType of(StackJavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		switch (__t)
		{
			case INTEGER:	return INTEGER;
			case FLOAT:		return FLOAT;
			case LONG:		return LONG;
			case DOUBLE:	return DOUBLE;
		}
		
		throw new todo.OOPS();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionClassEnqueueAndTable.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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import dev.shadowtail.classfile.xlate.JavaStackState;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * Represents a class, enqueue, and exception table.
 *
 * @since 2019/04/03
 */
public final class ExceptionClassEnqueueAndTable
{
	/** The class name to use. */
	public final ClassName name;
	
	/** The exception combo to target. */
	public final ExceptionEnqueueAndTable enqueueandtable;
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __ops The enqueue.
	 * @param __t The exception table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassEnqueueAndTable(ClassName __n,
		JavaStackEnqueueList __ops, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		this(__n, new ExceptionEnqueueAndTable(__ops, __t));
	}
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __c The target for the exception handler.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassEnqueueAndTable(ClassName __n,
		ExceptionEnqueueAndTable __c)
		throws NullPointerException
	{
		if (__n == null || __c == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.enqueueandtable = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionClassEnqueueAndTable))
			return false;
		
		ExceptionClassEnqueueAndTable o = (ExceptionClassEnqueueAndTable)__o;
		return this.name.equals(o.name) &&
			this.enqueueandtable.equals(o.enqueueandtable);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^ this.enqueueandtable.hashCode();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionClassStackAndTable.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
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



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is used to specify a class which is created along with any associated
 * exception handlers as needed.
 *
 * @since 2019/04/02
 */
public final class ExceptionClassStackAndTable
{
	/** The class name to use. */
	public final ClassName name;
	
	/** The exception combo to target. */
	public final ExceptionStackAndTable stackandtable;
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __ops The stack state.
	 * @param __t The exception table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionClassStackAndTable(ClassName __n,
		JavaStackState __ops, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		this(__n, new ExceptionStackAndTable(__ops, __t));
	}
	
	/**
	 * Initializes the exception information.
	 *
	 * @param __n The class to target.
	 * @param __c The target for the exception handler.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/02
	 */
	public ExceptionClassStackAndTable(ClassName __n,
		ExceptionStackAndTable __c)
		throws NullPointerException
	{
		if (__n == null || __c == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.stackandtable = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/02
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionClassStackAndTable))
			return false;
		
		ExceptionClassStackAndTable o = (ExceptionClassStackAndTable)__o;
		return this.name.equals(o.name) &&
			this.stackandtable.equals(o.stackandtable);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/02
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode() ^ this.stackandtable.hashCode();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionEnqueueAndTable.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.xlate.JavaStackEnqueueList;
import dev.shadowtail.classfile.xlate.JavaStackState;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is a combination of an enqueue and exception handler table.
 *
 * @since 2019/04/03
 */
public final class ExceptionEnqueueAndTable
{
	/** The enqueue of the stack. */
	public final JavaStackEnqueueList enqueue;
	
	/** The exception handle table. */
	public final ExceptionHandlerTable table;
	
	/**
	 * Initializes the exception combo.
	 *
	 * @param __ops The stack state.
	 * @param __t The table used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public ExceptionEnqueueAndTable(JavaStackEnqueueList __ops,
		ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.enqueue = __ops;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionEnqueueAndTable))
			return false;
		
		ExceptionEnqueueAndTable o = (ExceptionEnqueueAndTable)__o;
		return this.enqueue.equals(o.enqueue) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final int hashCode()
	{
		return this.enqueue.hashCode() ^ this.table.hashCode();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionHandlerRanges.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.xlate;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ExceptionHandlerTable;
import net.multiphasicapps.classfile.InstructionAddressRange;
import net.multiphasicapps.classfile.StackMapTable;

/**
 * This class is used to keep track of the exceptions in the methods.
 *
 * @since 2019/03/21
 */
public final class ExceptionHandlerRanges
{
	/** The full table. */
	protected final ExceptionHandlerTable full;
	
	/** Ranges for exceptions mapped to specific ranges. */
	private final Map<InstructionAddressRange, ExceptionHandlerTable> _ranges;
	
	/**
	 * Initializes the exception tracker.
	 *
	 * @param __bc The source byte code.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/21
	 */
	public ExceptionHandlerRanges(ByteCode __bc)
		throws NullPointerException
	{
		if (__bc == null)
			throw new NullPointerException("NARG");
		
		// Get the complete exception handler table
		ExceptionHandlerTable full = __bc.exceptions();
		this.full = full;
		
		// Load the full exception table ranges, this is used to locate
		// which table belongs to what
		this._ranges = full.mappedUniqueRanges();
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("EHRanges: %s", this._ranges);
	}
	
	/**
	 * Creates a class, enqueue, and exception table representation.
	 *
	 * @param __cn The class name.
	 * @param __ops The enqueue state.
	 * @param __pc The address.
	 * @return The class, stack, and exception table
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public final ExceptionClassEnqueueAndTable classEnqueueAndTable(
		ClassName __cn, JavaStackEnqueueList __ops, int __pc)
		throws NullPointerException
	{
		if (__cn == null || __ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionClassEnqueueAndTable(__cn,
			this.enqueueAndTable(__ops, __pc));
	}
	
	/**
	 * Creates a class, stack, and exception table representation.
	 *
	 * @param __cn The class name.
	 * @param __ops The stack state.
	 * @param __pc The address.
	 * @return The class, stack, and exception table
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public final ExceptionClassStackAndTable classStackAndTable(
		ClassName __cn, JavaStackState __ops, int __pc)
		throws NullPointerException
	{
		if (__cn == null || __ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionClassStackAndTable(__cn,
			this.stackAndTable(__ops, __pc));
	}
	
	/**
	 * Creates a enqueue and table representation.
	 *
	 * @param __ops The object positions.
	 * @param __pc The PC address.
	 * @return The stack and table information.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final ExceptionEnqueueAndTable enqueueAndTable(
		JavaStackEnqueueList __ops, int __pc)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionEnqueueAndTable(__ops, this.tableOf(__pc));
	}
	
	/**
	 * Creates a stack and table representation.
	 *
	 * @param __ops The object positions.
	 * @param __pc The PC address.
	 * @return The stack and table information.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public final ExceptionStackAndTable stackAndTable(JavaStackState __ops,
		int __pc)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		return new ExceptionStackAndTable(__ops, this.tableOf(__pc));
	}
	
	/**
	 * Returns the table at the given PC address.
	 *
	 * @param __pc The address to get.
	 * @return The table at the given address.
	 * @since 2019/03/22
	 */
	public final ExceptionHandlerTable tableOf(int __pc)
	{
		ExceptionHandlerTable last = null;
		for (Map.Entry<InstructionAddressRange, ExceptionHandlerTable> e :
			this._ranges.entrySet())
		{
			if (e.getKey().inRange(__pc))
				return e.getValue();
			last = e.getValue();
		}
		
		// Always return the last table because the exception handlers might
		// not cover the entire method (in the case of where there are no
		// handlers, the blank table will be only at address 0 while the
		// remaining instructions are the end)
		return last;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionHandlerTransition.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This contains the information needed to transition into exception handlers.
 *
 * @since 2019/04/13
 */
public final class ExceptionHandlerTransition
{
	/** The operations to perform when the entry is being handled. */
	public final StateOperations handled;
	
	/** Cleanup for when there are no handlers and everything is tossed up. */
	public final JavaStackEnqueueList nothandled;
	
	/** The exception table. */
	public final ExceptionHandlerTable table;
	
	/** Hash code. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the information.
	 *
	 * @param __h The state operations for getting the stack working properly.
	 * @param __q The tossup enqueue table when nothing is handled.
	 * @param __t The exception handler table.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public ExceptionHandlerTransition(StateOperations __h,
		JavaStackEnqueueList __q, ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__h == null || __q == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.handled = __h;
		this.nothandled = __q;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof ExceptionHandlerTransition))
			return false;
		
		ExceptionHandlerTransition o = (ExceptionHandlerTransition)__o;
		return this.handled.equals(o.handled) &&
			this.nothandled.equals(o.nothandled) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.handled.hashCode() ^
				this.nothandled.hashCode() ^ this.table.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/13
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/ExceptionStackAndTable.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ExceptionHandlerTable;

/**
 * This is a combination of a stack and exception handler table.
 *
 * @since 2019/03/22
 */
public final class ExceptionStackAndTable
{
	/** The state of the stack. */
	public final JavaStackState stack;
	
	/** The exception handle table. */
	public final ExceptionHandlerTable table;
	
	/**
	 * Initializes the exception combo.
	 *
	 * @param __ops The stack state.
	 * @param __t The table used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	public ExceptionStackAndTable(JavaStackState __ops,
		ExceptionHandlerTable __t)
		throws NullPointerException
	{
		if (__ops == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.stack = __ops;
		this.table = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ExceptionStackAndTable))
			return false;
		
		ExceptionStackAndTable o = (ExceptionStackAndTable)__o;
		return this.stack.equals(o.stack) &&
			this.table.equals(o.table);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final int hashCode()
	{
		return this.stack.hashCode() ^ this.table.hashCode();
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/JavaStackEnqueueList.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506


























































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * This contains every register which can be cleared after the specified
 * operation completes. Enqueue lists are always sorted from lowest to
 * highest.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackEnqueueList
	implements Iterable<Integer>
{
	/** The index where the stack entries start. */
	public final int stackstart;
	
	/** Registers used. */
	private final int[] _registers;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hashcode. */
	private int _hash;
	
	/**
	 * Initializes the enqueue list.
	 *
	 * @param __ss The start of the stack.
	 * @param __rs The registers to enqueue.
	 * @since 2019/03/31
	 */
	public JavaStackEnqueueList(int __ss, int... __rs)
	{
		// Bin the registers into unique local and stack entries
		__rs = (__rs == null ? new int[0] : __rs.clone());
		Set<Integer> ll = new SortedTreeSet<>(),
			ls = new SortedTreeSet<>();
		for (int i = 0, n = __rs.length; i < n; i++)
		{
			int v = __rs[i];
			
			if (i < __ss)
				ll.add(v);
			else
				ls.add(v);
		}
		
		// Setup new resulting array
		int[] registers = new int[ll.size() + ls.size()];
		int at = 0;
		for (int v : ll)
			registers[at++] = v;
		for (int v : ls)
			registers[at++] = v;
		
		// Set
		this._registers = registers;
		this.stackstart = ll.size();
	}
	
	/**
	 * Initializes the enqueue list.
	 *
	 * @param __ss The start of the stack.
	 * @param __rs The registers to enqueue.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackEnqueueList(int __ss, Iterable<Integer> __rs)
		throws NullPointerException
	{
		if (__rs == null)
			throw new NullPointerException("NARG");
		
		// Copy input list
		List<Integer> inreg = new ArrayList<>();
		for (Integer i : __rs)
			inreg.add(i);
		
		// Bin the registers into unique local and stack entries
		Set<Integer> ll = new SortedTreeSet<>(),
			ls = new SortedTreeSet<>();
		for (int i = 0, n = inreg.size(); i < n; i++)
		{
			int v = inreg.get(i);
			
			if (i < __ss)
				ll.add(v);
			else
				ls.add(v);
		}
		
		// Setup new resulting array
		int[] registers = new int[ll.size() + ls.size()];
		int at = 0;
		for (int v : ll)
			registers[at++] = v;
		for (int v : ls)
			registers[at++] = v;
		
		// Set
		this._registers = registers;
		this.stackstart = ll.size();
	}
	
	/**
	 * Adds a single local variable to this enqueue.
	 *
	 * @param __r The register to add.
	 * @return The resulting enqueue.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList addLocal(int __r)
	{
		int[] orig = this._registers;
		int origss = this.stackstart;
		
		// Add entry to the start of the array
		int n = orig.length;
		int[] now = new int[n + 1];
		now[0] = __r;
		for (int i = 0, o = 1; i < n; i++, o++)
			now[o] = orig[i];
		
		// The stack is offset by one so the local is first
		return new JavaStackEnqueueList(origss + 1, now);
	}
	
	/**
	 * Adds a single local variable to this enqueue.
	 *
	 * @param __r The register to add.
	 * @return The resulting enqueue.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList addStack(int __r)
	{
		// Since stack items are last, the register can just be added at
		// the end
		int[] orig = this._registers;
		int n = orig.length;
		int[] now = Arrays.copyOf(orig, n + 1);
		now[n] = __r;
		
		// Just the new array is used
		return new JavaStackEnqueueList(this.stackstart, now);
	}
	
	/**
	 * Checks if the enqueue contains the given register.
	 *
	 * @param __r The register to check.
	 * @return If it is contained or not.
	 * @since 2019/04/13
	 */
	public final boolean contains(int __r)
	{
		for (int x : this._registers)
			return (x == __r);
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof JavaStackEnqueueList))
			return false;
		
		JavaStackEnqueueList o = (JavaStackEnqueueList)__o;
		if (this.hashCode() != o.hashCode())
			return false;
		
		return this.stackstart == o.stackstart &&
			Arrays.equals(this._registers, o._registers);
	}
	
	/**
	 * Gets the given entry.
	 *
	 * @param __i The index to get.
	 * @return The register at this index.
	 * @since 2019/03/30
	 */
	public final int get(int __i)
	{
		return this._registers[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
		{
			rv = ~this.stackstart;
			for (int i : this._registers)
				rv -= i;
			
			this._hash = rv;
		}
		return rv;
	}
	
	/**
	 * Returns if this is empty.
	 *
	 * @return If this is empty.
	 * @since 2019/03/30
	 */
	public final boolean isEmpty()
	{
		return this._registers.length == 0;
	}
	
	/**
	 * Checks if the given index refers to a local.
	 *
	 * @param __i The index to check.
	 * @return If it refers to a local.
	 * @since 2019/04/17
	 */
	public final boolean isLocal(int __i)
	{
		return __i < this.stackstart;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/06
	 */
	@Override
	public final Iterator<Integer> iterator()
	{
		return new __Iterator__(this._registers);
	}
	
	/**
	 * Returns an enqueue list which contains only locals.
	 *
	 * @return An enqueue list containing only locals.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList onlyLocals()
	{
		// Copy just up to the stack part
		int[] from = this._registers;
		int ss = this.stackstart;
		int[] rv = new int[ss];
		for (int i = 0; i < ss; i++)
			rv[i] = from[i];
		
		return new JavaStackEnqueueList(ss, rv);
	}
	
	/**
	 * Returns an enqueue list which contians only stack registers.
	 *
	 * @return An enqueue with only stack registers.
	 * @since 2019/04/03
	 */
	public final JavaStackEnqueueList onlyStack()
	{
		// Copy just up to the stack part
		int[] from = this._registers;
		int n = from.length,
			ss = this.stackstart;
		int[] rv = new int[n - ss];
		for (int i = ss, o = 0; i < n; i++, o++)
			rv[o] = from[i];
		
		return new JavaStackEnqueueList(0, rv);
	}
	
	/**
	 * Returns all of the registers that have been enqueued.
	 *
	 * @return The enqueued set of registers.
	 * @since 2019/03/30
	 */
	public final int[] registers()
	{
		return this._registers.clone();
	}
	
	/**
	 * Returns the number of entries here.
	 *
	 * @return The number of entries.
	 * @since 2019/03/30
	 */
	public final int size()
	{
		return this._registers.length;
	}
	
	/**
	 * Returns the top-most entry.
	 *
	 * @return The top most entry or {@code -1} if this is empty.
	 * @since 2019/03/30
	 */
	public final int top()
	{
		int[] registers = this._registers;
		int len = registers.length;
		
		if (len == 0)
			return -1;
		return registers[len - 1];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		StringBuilder sb = new StringBuilder("ENQ[");
		
		int stackstart = this.stackstart, dx = 0;
		boolean comma = false;
		for (int v : this._registers)
		{
			if (dx++ == stackstart)
				sb.append("| ");
			else if (comma)
				sb.append(", ");
			comma = true;
			
			sb.append(v);
		}
		if (dx == stackstart)
			sb.append('|');
		sb.append(']');
		
		return sb.toString();
	}
	
	/**
	 * Trims the top entry from the enqueue list and returns the new list
	 * with the top missing.
	 *
	 * @return The resulting list.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList trimTop()
	{
		// Do not trim empty pieces
		int[] from = this._registers;
		int n = from.length - 1;
		if (n < 0)
			return this;
		
		// Copy bits
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = from[i];
		
		return new JavaStackEnqueueList(this.stackstart, rv);
	}
	
	/**
	 * Merges both of these stack enqueue lists into one.
	 *
	 * @param __a The first.
	 * @param __b The second.
	 * @return The merged result.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public static final JavaStackEnqueueList merge(JavaStackEnqueueList __a,
		JavaStackEnqueueList __b)
		throws NullPointerException
	{
		if (__a == null || __b == null)
			throw new NullPointerException("NARG");
		
		// If one side is empty just use the other
		if (__a.isEmpty())
			return __b;
		else if (__b.isEmpty())
			return __a;
		
		// Locals and stack entries
		List<Integer> locals = new ArrayList<>(),
			stack = new ArrayList<>();
		
		// Sort through them all
		for (JavaStackEnqueueList eq : new JavaStackEnqueueList[]{__a, __b})
			for (int i = 0, n = eq.size(); i < n; i++)
			{
				Integer r = eq.get(i);
				if (eq.isLocal(i))
					locals.add(r);
				else
					stack.add(r);
			}
		
		// Append stack entries to the locals
		int numlocals = locals.size();
		locals.addAll(stack);
		return new JavaStackEnqueueList(numlocals, locals);
	}
	
	/**
	 * Iterator over stack slots.
	 *
	 * @since 2019/04/06
	 */
	private static final class __Iterator__
		implements Iterator<Integer>
	{
		/** Input register. */
		private final int[] _registers;
		
		/** Current index. */
		private int _at;
		
		/**
		 * Initializes the iterator.
		 *
		 * @param __r The registers used.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/06
		 */
		private __Iterator__(int[] __r)
			throws NullPointerException
		{
			if (__r == null)
				throw new NullPointerException("NARG");
			
			this._registers = __r;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final boolean hasNext()
		{
			return (this._at < this._registers.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final Integer next()
		{
			int at = this._at;
			int[] registers = this._registers;
			
			if (at >= registers.length)
				throw new NoSuchElementException("NSEE");
			
			this._at = at + 1;
			return registers[at];
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/06
		 */
		@Override
		public final void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/JavaStackEnqueueType.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

/**
 * This represents the type of enqueue to perform.
 *
 * @since 2019/04/06
 */
public enum JavaStackEnqueueType
{
	/** Normal state. */
	NORMAL,
	
	/** Cached state. */
	CACHED,
	
	/** End. */
	;
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/JavaStackResult.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566






















































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.JavaType;

/**
 * This represents the result of operations performed on the Java stack.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackResult
{
	/** Input to the zero register. */
	public static final JavaStackResult.Input INPUT_ZERO =
		new JavaStackResult.Input(0, JavaType.NOTHING, true);
	
	/** Output to the zero register. */
	public static final JavaStackResult.Output OUTPUT_ZERO =
		new JavaStackResult.Output(0, JavaType.NOTHING, true);
	
	/** The stack state before. */
	public final JavaStackState before;
	
	/** The stack state after. */
	public final JavaStackState after;
	
	/** Enqueue list. */
	public final JavaStackEnqueueList enqueue;
	
	/** State operations. */
	public final StateOperations ops;
	
	/** Input. */
	private final JavaStackResult.Input[] _in;
	
	/** Output. */
	private final JavaStackResult.Output[] _out;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the result of the operation
	 *
	 * @param __bs The previous stack state.
	 * @param __as The after (the new) stack state.
	 * @param __eq Enqueue list, may be {@code null}.
	 * @param __io Input/output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackResult(JavaStackState __bs, JavaStackState __as,
		JavaStackEnqueueList __eq, InputOutput... __io)
		throws NullPointerException
	{
		this(__bs, __as, __eq, (StateOperations)null, __io);
	}
	
	/**
	 * Initializes the result of the operation
	 *
	 * @param __bs The previous stack state.
	 * @param __as The after (the new) stack state.
	 * @param __eq Enqueue list, may be {@code null}.
	 * @param __ops State operations.
	 * @param __io Input/output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public JavaStackResult(JavaStackState __bs, JavaStackState __as,
		JavaStackEnqueueList __eq, StateOperations __ops, InputOutput... __io)
		throws NullPointerException
	{
		if (__bs == null || __as == null)
			throw new NullPointerException("NARG");
		
		// Sort through input/output and put into their own pile
		List<Input> in = new ArrayList<>();
		List<Output> out = new ArrayList<>();
		for (InputOutput x : (__io = (__io == null ?
			new InputOutput[0] : __io.clone())))
			if (x == null)
				throw new NullPointerException("NARG");
			else if (x instanceof Input)
				in.add((Input)x);
			else
				out.add((Output)x);
		
		this.before = __bs;
		this.after = __as;
		this.enqueue = (__eq == null ? new JavaStackEnqueueList(0) : __eq);
		this._in = in.<Input>toArray(new Input[in.size()]);
		this._out = out.<Output>toArray(new Output[out.size()]);
		this.ops = (__ops == null ? new StateOperations() : __ops);
		
		// Debug
		if (__Debug__.ENABLED)
		{
			todo.DEBUG.note("*** Stack Result ***");
			todo.DEBUG.note("BEF: %s", __bs);
			todo.DEBUG.note("AFT: %s", __as);
			if (__eq != null && !__eq.isEmpty())
				todo.DEBUG.note("ENQ: %s", __eq);
			todo.DEBUG.note("IN : %s", in);
			todo.DEBUG.note("OUT: %s", out);
			if (__ops != null && !__ops.isEmpty())
				todo.DEBUG.note("OPS: %s", __ops);
			todo.DEBUG.note("********************");
		}
	}
	
	/**
	 * Represents the new state after the operation was performed.
	 *
	 * @return The state that is the result of the operation.
	 * @since 2019/03/30
	 */
	public final JavaStackState after()
	{
		return this.after;
	}
	
	/**
	 * Represents the previous state which this was based off.
	 *
	 * @return The previous state this originated from.
	 * @since 2019/03/30
	 */
	public final JavaStackState before()
	{
		return this.before;
	}
	
	/**
	 * Returns the enqueue list which represents everything that is to be
	 * uncounted after the operation completes.
	 *
	 * @return The enqueue list, will be empty if there is nothing to
	 * enqueue.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList enqueue()
	{
		return this.enqueue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the input.
	 *
	 * @return The input.
	 * @since 2019/04/08
	 */
	public final JavaStackResult.Input[] in()
	{
		return this._in.clone();
	}
	
	/**
	 * Returns the information on the input.
	 *
	 * @param __i The input to get.
	 * @return The information on the input.
	 * @since 2019/03/30
	 */
	public final JavaStackResult.Input in(int __i)
	{
		return this._in[__i];
	}
	
	/**
	 * Returns the number of generated inputs.
	 *
	 * @return The input count.
	 * @since 2019/03/30
	 */
	public final int inCount()
	{
		return this._in.length;
	}
	
	/**
	 * The operations to be performed.
	 *
	 * @return The operations to perform.
	 * @since 2019/04/11
	 */
	public final StateOperations operations()
	{
		return this.ops;
	}
	
	/**
	 * Returns the output.
	 *
	 * @return The output.
	 * @since 2019/04/08
	 */
	public final JavaStackResult.Output[] out()
	{
		return this._out.clone();
	}
	
	/**
	 * Returns the information on the output.
	 *
	 * @param __i The output to get.
	 * @return The information on the output.
	 * @since 2019/03/30
	 */
	public final JavaStackResult.Output out(int __i)
	{
		return this._out[__i];
	}
	
	/**
	 * Returns the number of generated outputs.
	 *
	 * @return The output count.
	 * @since 2019/03/30
	 */
	public final int outCount()
	{
		return this._out.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Result:{bef=%s, aft=%s, enq=%s, in=%s, out=%s, ops=%s}",
				this.before, this.after, this.enqueue,
				Arrays.asList(this._in), Arrays.asList(this._out),
				this.ops)));
		
		return rv;
	}
	
	/**
	 * Makes an input.
	 *
	 * @param __i The info to base from.
	 * @return The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public static final Input makeInput(JavaStackState.Info __i)
		throws NullPointerException
	{
		return new Input(__i);
	}
	
	/**
	 * Makes an output.
	 *
	 * @param __i The info to base from.
	 * @return The output.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public static final Output makeOutput(JavaStackState.Info __i)
		throws NullPointerException
	{
		return new Output(__i);
	}
	
	/**
	 * Input information.
	 *
	 * @since 2019/03/30
	 */
	public static final class Input
		implements InputOutput
	{
		/** The register used for input. */
		public final int register;
		
		/** The type which was read. */
		public final JavaType type;
		
		/** Not counting? */
		public final boolean nocounting;
	
		/** String representation. */
		private Reference<String> _string;
		
		/**
		 * Initializes the input.
		 *
		 * @param __i The info to base off.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Input(JavaStackState.Info __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.register = __i.value;
			this.type = __i.type;
			this.nocounting = __i.nocounting;
		}
		
		/**
		 * Initializes the input.
		 *
		 * @param __r The register used.
		 * @param __t The type used.
		 * @param __nc Is not counting?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/08
		 */
		public Input(int __r, JavaType __t, boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.register = __r;
			this.type = __t;
			this.nocounting = __nc;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final boolean equals(Object __o)
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final int hashCode()
		{
			throw new todo.TODO();
		}
		
		/**
		 * Checks if the type is an array.
		 *
		 * @return True if the type is an array.
		 * @since 2019/05/25
		 */
		public final boolean isArray()
		{
			JavaType type = this.type;
			return type.isObject() && type.isArray();
		}
		
		/**
		 * Checks if this type is quickly compatible with the given class.
		 *
		 * @param __cl If this is compatible with the given class.
		 * @return True if this is quickly compatible.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/05/24
		 */
		public final boolean isCompatible(ClassName __cl)
			throws NullPointerException
		{
			if (__cl == null)
				throw new NullPointerException("NARG");
			
			JavaType type = this.type;
			return (type.isObject() || type.isPrimitive()) &&
				__cl.equals(type.className());
		}
		
		/**
		 * Is this an object?
		 *
		 * @return If this is an object.
		 * @since 2019/06/12
		 */
		public final boolean isObject()
		{
			return this.type.isObject();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv = String.format(
					"In:{r=r%d, type=%s, flags=%s}",
					this.register, this.type, (this.nocounting ? "NC" : ""))));
			
			return rv;
		}
	}
	
	/**
	 * Used to flag input and output.
	 *
	 * @since 2019/03/31
	 */
	public static interface InputOutput
	{
	}
	
	/**
	 * Output information.
	 *
	 * @since 2019/03/30
	 */
	public static final class Output
		implements InputOutput
	{
		/** The register used for output. */
		public final int register;
		
		/** The output type. */
		public final JavaType type;
		
		/** Not counting? */
		public final boolean nocounting;
	
		/** String representation. */
		private Reference<String> _string;
		
		/**
		 * Initializes the output.
		 *
		 * @param __i The info to base off.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Output(JavaStackState.Info __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.register = __i.value;
			this.type = __i.type;
			this.nocounting = __i.nocounting;
		}
		
		/**
		 * Initializes the output.
		 *
		 * @param __r The register used.
		 * @param __t The type used.
		 * @param __nc Is not counting?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/08
		 */
		public Output(int __r, JavaType __t, boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			this.register = __r;
			this.type = __t;
			this.nocounting = __nc;
		}
		
		/**
		 * Returns this output as an input.
		 *
		 * @return The input.
		 * @since 2019/04/12
		 */
		public final Input asInput()
		{
			return new Input(this.register, this.type, this.nocounting);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final boolean equals(Object __o)
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final int hashCode()
		{
			throw new todo.TODO();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/31
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv = String.format(
					"Out:{r=r%d, type=%s, flags=%s}",
					this.register, this.type, (this.nocounting ? "NC" : ""))));
			
			return rv;
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/JavaStackShuffleType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the type of stack shuffle to perform. Since these
 * operations depend on the types on the stack, this is used to contain the
 * information to simplify the operations.
 *
 * @since 2019/03/30
 */
public enum JavaStackShuffleType
{
	/** dup. */
	DUP("a:aa"),
	
	/** dup_x1. */
	DUP_X1("ba:aba"),
	
	/** dup_x2. */
	DUP_X2("cba:acba",
		"Ba:aBa"),
	
	/** dup2. */
	DUP2("ba:baba",
		"A:AA"),
	
	/** dup2_x1. */
	DUP2_X1("cba:bacba",
		"bA:AbA"),
	
	/** dup2_x2. */
	DUP2_X2("dcba:badcba",
		"cbA:AcbA",
		"Cba:baCba",
		"BA:ABA"),
	
	/** pop. */
	POP("a:"),
	
	/** pop2. */
	POP2("ba:",
		"A:"),
	
	/** swap. */
	SWAP("ba:ab"),
	
	/** End. */
	;
	
	/** Forms of this operation. */
	final Function[] _functions;
	
	/**
	 * Initialize the shuffle form information.
	 *
	 * The forms consist of characters for the various items on the stack.
	 * A lowercase letter represents a narrow type while a capital letter
	 * represents a wide type. Input and output is separated by a colon. The
	 * operation is just that whatever is pushed to the stack has the same
	 * value as the items removed from the stack.
	 *
	 * @param __fs The forms.
	 * @since 2019/04/01
	 */
	private JavaStackShuffleType(String... __fs)
	{
		int n = __fs.length;
		Function[] functions = new Function[n];
		for (int i = 0; i < n; i++)
			functions[i] = Function.of(__fs[i]);
		this._functions = functions;
	}
	
	/**
	 * Contains information on how to push or pop operations.
	 *
	 * @since 2019/04/01
	 */
	public static final class Function
	{
		/** Input slots. */
		public final Slots in;
		
		/** Output slots. */
		public final Slots out;
		
		/** String reference. */
		private Reference<String> _string;
		
		/**
		 * Initializes the function.
		 *
		 * @param __in The input.
		 * @param __out The output.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public Function(Slots __in, Slots __out)
			throws NullPointerException
		{
			if (__in == null || __out == null)
				throw new NullPointerException("NARG");
			
			this.in = __in;
			this.out = __out;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/04
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
				this._string = new WeakReference<>((rv =
					"[" + this.in + " -> " + this.out + "]"));
			
			return rv;
		}
		
		/**
		 * Returns the function for the given string.
		 *
		 * @param __s The string to parse.
		 * @throws IllegalArgumentException If the function is not valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public static final Function of(String __s)
			throws IllegalArgumentException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error JC1d Expected colon in function form.}
			int col = __s.indexOf(':');
			if (col < 0)
				throw new IllegalArgumentException("JC1d");
			
			return new Function(new Slots(__s.substring(0, col)),
				new Slots(__s.substring(col + 1)));
		}
	}
	
	/**
	 * Represents the slots used for the stack.
	 *
	 * @since 2019/04/01
	 */
	public static final class Slots
	{
		/** The maximum push/pop count. */
		public final int max;
		
		/** The variable index, negative values mean top types. */
		final byte[] _var;
		
		/** Which slots are considered wide or not. */
		final boolean[] _wide;
		
		/** String reference. */
		private Reference<String> _string;
		
		/**
		 * Initializes the slots.
		 *
		 * @param __s The string source.
		 * @throws IllegalArgumentException If the slots are not valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/01
		 */
		public Slots(String __s)
			throws IllegalArgumentException, NullPointerException
		{
			if (__s == null)
				throw new NullPointerException("NARG");
			
			// Determine the actual popping, with top types and such
			int n = __s.length(),
				max = 0;
			for (int i = 0; i < n; i++)
				if (Character.isUpperCase(__s.charAt(i)))
					max += 2;
				else
					max += 1;
			
			// Stores top and wide states
			byte[] var = new byte[max];
			boolean[] wide = new boolean[max];
			
			// Go through again and fill the output
			for (int i = 0, o = 0; i < n; i++)
			{
				char c = __s.charAt(i);
				boolean iswide = Character.isUpperCase(c);
				
				// Store information here
				var[o] = (byte)(Character.toLowerCase(c) - 'a');
				wide[o++] = iswide;
				
				// The tops of wide types are considered narrow but also have
				// no variable type
				if (iswide)
					var[o++] = -1;
			}
			
			// Store
			this.max = max;
			this._var = var;
			this._wide = wide;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/04/04
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
			{
				StringBuilder sb = new StringBuilder("[");
				
				// Convert back to close to the original form
				byte[] var = this._var;
				boolean[] wide = this._wide;
				for (int i = 0, n = this.max; i < n; i++)
				{
					int v = var[i];
					boolean w = wide[i];
					
					if (v < 0)
						sb.append('+');
					else
					{
						char c = (char)('a' + v);
						sb.append((w ? Character.toUpperCase(c) : c));
					}
				}
				
				// Finish and cache it
				sb.append(']');
				this._string = new WeakReference<>((rv = sb.toString()));
			}
			
			return rv;
		}
		
		/**
		 * Returns the variable to use.
		 *
		 * @param __i The index to get.
		 * @return The variable here, {@code -1} represents a top type.
		 * @since 2019/04/04
		 */
		public final int variable(int __i)
		{
			return this._var[__i];
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/JavaStackState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import dev.shadowtail.classfile.nncc.NativeCode;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.StackMapTableEntry;
import net.multiphasicapps.classfile.StackMapTableState;

/**
 * This class contains the state of the Java stack, it is mostly used in
 * the generation of the register code as it handles caching as well.
 *
 * This class is immutable.
 *
 * @since 2019/03/30
 */
public final class JavaStackState
{
	/** The base register where arguments start. */
	public static final int BASE_REGISTER =
		NativeCode.ARGUMENT_REGISTER_BASE;
	
	/** The top of the stack. */
	public final int stacktop;
	
	/** Number of used registers. */
	public final int usedregisters;
	
	/** The local variables defined. */
	private final Info[] _locals;
	
	/** The stack variables. */
	private final Info[] _stack;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hash code. */
	private int _hash;
	
	/**
	 * Initializes the stack state, the state will be modified to ensure that
	 * it is correct for normalization purposes.
	 *
	 * @param __l The locals.
	 * @param __s The stack.
	 * @param __ss The top of the stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/31
	 */
	public JavaStackState(Info[] __l, Info[] __s, int __ss)
		throws NullPointerException
	{
		if (__l == null || __s == null)
			throw new NullPointerException("NARG");
		
		for (Info i : (__l = __l.clone()))
			if (i == null)
				throw new NullPointerException("NARG");
		
		for (Info i : (__s = __s.clone()))
			if (i == null)
				throw new NullPointerException("NARG");
		
		// Make sure locals are correct
		for (int i = 0, n = __l.length; i < n; i++)
		{
			Info x = __l[i];
			
			// Checks if there is something here
			if (!x.type.isNothing())
			{
				// {@squirreljme.error JC1e Local variables cannot be an alias
				// of another variable. (The local)}
				if (x.value != x.register)
					throw new InvalidClassFormatException("JC1e " + x);
			}
		}
		
		// Correct pre-stack entries?
		for (int i = 0; i < __ss; i++)
		{
			Info x = __s[i];
			if (x.readonly)
				__s[i] = (x = new Info(x.register, x.type, x.value, false,
					x.nocounting));
			
			// Checks if there is something here
			if (!x.type.isNothing())
			{
				// {@squirreljme.error JC1f Stack variables cannot alias
				// variables at higher indexes. (The stack variable)}
				if (x.value > x.register)
					throw new InvalidClassFormatException("JC1f " + x);
			}
		}
		
		// Correct post-stack entries
		for (int i = __ss, n = __s.length; i < n; i++)
		{
			Info x = __s[i];
			if (!x.type.isNothing() || x.value != -1 || x.readonly ||
				x.nocounting)
				__s[i] = (x = new Info(x.register, JavaType.NOTHING, -1, false,
					false));
		}
		
		// Set
		this._locals = __l;
		this._stack = __s;
		this.stacktop = __ss;
		
		// Determine used registers
		int usedregisters = 0;
		for (Info i : __l)
			usedregisters = Math.max(usedregisters, i.register + 1);
		for (Info i : __s)
			usedregisters = Math.max(usedregisters, i.register + 1);
		this.usedregisters = usedregisters + 1;
	}
	
	/**
	 * Compare two stacks and returns a list of registers which have a
	 * compatible or transferable type but collide in their cached value. This
	 * does not check local variables, only stack entries.
	 *
	 * @param __ts The target stack.
	 * @return A list of registers which collide.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackEnqueueList cacheCollision(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// If the two stacks are e
		if (this.equals(__ts))
			return new JavaStackEnqueueList(0);
			
		// {@squirreljme.error JC1g A collision cannot be made where the
		// length of the stack differs. (The length of the source stack; The
		// length of the target stack)}
		int atop = this.stacktop,
			btop = __ts.stacktop;
		if (atop != btop)
			throw new InvalidClassFormatException("JC1g " + atop + " " + btop);
		
		// Registers which collide
		List<Integer> collides = new ArrayList<>();
		
		// Go through and determine which stack entries collide
		Info[] astk = this._stack,
			bstk = __ts._stack;
		for (int i = 0; i < atop; i++)
		{
			Info a = astk[i],
				b = bstk[i];
			
			// Entries which are the same would never collide
			if (a.equals(b))
				continue;
			
			// If either the source or the target or nothing then there can
			// be a transition, one will either be a set to zero or an uncount
			// if an object
			JavaType at = a.type,
				bt = b.type;
			if (at.isNothing() || bt.isNothing())
				continue;
			
			// The target entry is cached, but it has a value which does not
			// map to this register
			if (b.value != b.register && a.register != b.value)
				collides.add(b.register);
		}
		
		return new JavaStackEnqueueList(0, collides);
	}
	
	/**
	 * Returns the state which would be used if the specified registers were
	 * to have their caches cleared. Only the stack is considered as locals
	 * are never cached.
	 *
	 * @param __enq The registers to clear.
	 * @return The resulting stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackState cacheClearState(JavaStackEnqueueList __enq)
		throws NullPointerException
	{
		if (__enq == null)
			throw new NullPointerException("NARG");
		
		// If there is nothing to clear 
		if (__enq.isEmpty())
			return this;
		
		// Clear cache from these
		Info[] stack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Remove any cached slots
		for (int i = 0; i < stacktop; i++)
		{
			Info inf = stack[i];
			
			// This is to be uncached
			if (inf.value != inf.register && __enq.contains(inf.register))
				stack[i] = new Info(inf.register, inf.type, inf.register,
					false, inf.nocounting);
		}
		
		// Build it
		return new JavaStackState(this._locals, stack, stacktop);
	}
	
	/**
	 * Checks if transition can be made to the other state.
	 *
	 * @param __ts The state to check transition to.
	 * @return If it can transition.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final boolean canTransition(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// Transition is possible if there are no collisions
		return this.cacheCollision(__ts).isEmpty();
	}
	
	/**
	 * Performs a flush of the entire state removing all cached values.
	 *
	 * @return The result of the cache flush.
	 * @since 2019/04/11
	 */
	public final JavaStackResult doCacheFlush()
	{
		// This is just a transition to the non-cached state
		return this.doTransition(this.nonCached());
	}
	
	/**
	 * This handles logic used by check cast.
	 *
	 * @param __t The type to cast to.
	 * @return The result of the cast.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/12
	 */
	public final JavaStackResult doCheckCast(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
			
		// This is nearly the same
		Info[] newstack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Get item on the 
		Info topitem = newstack[stacktop - 1];
		
		// Same as the top item, but with a new type instead
		newstack[stacktop - 1] = new Info(
			topitem.register,
			__t,
			topitem.value,
			topitem.readonly,
			topitem.nocounting);
		
		// If the top-most item is counting, then enqueue it in the event
		// exceptions happen
		JavaStackEnqueueList enq;
		if (topitem.nocounting)
			enq = new JavaStackEnqueueList(0);
		else
			enq = new JavaStackEnqueueList(0, topitem.register);
		
		// Create the result
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop),
			enq,
			new StateOperations(),
			JavaStackResult.makeInput(topitem));
	}
	
	/**
	 * Destroys all local variables and stack variables returning the process
	 * that is needed to clear out the entire state.
	 *
	 * Any references that need to be cleared when the code completes will be
	 * placed in the enqueue list.
	 *
	 * @param __rv If true then a return value will be popped before everything
	 * is destroyed, this will be the single input available.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doDestroy(boolean __rv)
	{
		Info inf;
		Info[] locals = this._locals,
			stack = this._stack;
		int stacktop = this.stacktop;
		
		// Setup new locals
		Info[] newlocals = locals.clone();
		
		// Find locals to enqueue
		List<Integer> enqueue = new ArrayList<>();
		List<StateOperation> sops = new ArrayList<>();
		for (int i = 0, n = locals.length; i < n; i++)
		{
			inf = locals[i];
			
			// Enqueue?
			if (inf.canEnqueue())
				enqueue.add(inf.value);
			
			// Clear out
			newlocals[i] = inf.newTypeValue(JavaType.NOTHING, -1, false);
		}
		
		// Return value?
		List<JavaStackResult.InputOutput> io = new ArrayList<>();
		int newstacktop = stacktop;
		Info popped = null;
		if (__rv)
		{
			// Pop top item
			popped = stack[--newstacktop];
			if (popped.type.isTop())
				popped = stack[--newstacktop];
			
			// Add to input
			io.add(JavaStackResult.makeInput(popped));
		}
		
		// Enqueue stack items, they do not need clearing out because setting
		// a limiting top will auto-clear
		// If returning a value do not enqueue what is being returned
		// otherwise it might end up being garbage collected and returned
		int eqss = enqueue.size();
		for (int i = 0; i < newstacktop; i++)
		{
			inf = stack[i];
			
			if (inf.canEnqueue())
				enqueue.add(inf.value);
		}
		
		// If we are popping something, make sure the value that was popped
		// is never enqueued because if it was a cached local or stack entry
		// then it would have been hit by an uncount
		if (popped != null)
			enqueue.remove((Object)popped.value);
		
		// Create result
		return new JavaStackResult(this,
			new JavaStackState(newlocals, stack, 0),
			new JavaStackEnqueueList(eqss, enqueue),
			new StateOperations(sops),
			io.<JavaStackResult.InputOutput>toArray(
				new JavaStackResult.InputOutput[io.size()]));
	}
	
	/**
	 * Removes all stack variables and places a single entry on the stack
	 * for exception handling.
	 *
	 * The input is filled with the entire stack. The output is a single
	 * entry and contains the stack entry to place the value at. The single
	 * stack entry for the exception will never be cached to the exception
	 * register.
	 *
	 * @param __t The type to push.
	 * @since 2019/04/13
	 */
	public final JavaStackResult doExceptionHandler()
	{
		return this.doExceptionHandler(JavaType.THROWABLE);
	}
	
	/**
	 * Removes all stack variables and places a single entry on the stack
	 * for exception handling.
	 *
	 * The input is filled with the entire stack. The output is a single
	 * entry and contains the stack entry to place the value at. The single
	 * stack entry for the exception will never be cached to the exception
	 * register.
	 *
	 * @param __t The type to push.
	 * @return The result of the operation.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doExceptionHandler(JavaType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Enqueues and operations
		List<Integer> enq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Setup new stack
		int oldstacktop = this.stacktop;
		Info[] newstack = this._stack.clone();
		
		// Cleanup everything on the stack!
		for (int i = 0; i < oldstacktop; i++)
		{
			Info sit = newstack[i];
			
			// If there are objects here, then uncount them
			if (sit.canEnqueue())
			{
				enq.add(sit.value);
				ops.add(StateOperation.uncount(sit.value));
			}
		}
		
		// Setup new stack entry
		Info olddest = newstack[0],
			dest = newstack[0].newTypeValue(__t, olddest.register, false);
		newstack[0] = dest;
		
		// Build result, only stack items were enqueued so all entries are
		// stack entries
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, 1),
			new JavaStackEnqueueList(0, enq),
			new StateOperations(ops),
			JavaStackResult.makeOutput(dest));
	}
	
	/**
	 * Loads the specified local variable onto the stack.
	 *
	 * @param __i The local to load from.
	 * @return The result of the operation.
	 * @throws InvalidClassFormatException If the local is not valid or
	 * the stack overflows.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doLocalLoad(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC1h Load of local with no value.
		// (The index; The information about the source)}
		Info from = this._locals[__i];
		if (from.type.isNothing())
			throw new InvalidClassFormatException("JC1h " + __i + " " + from);
		
		// Space needed to be used on the stack
		JavaType type = from.type;
		boolean iswide = type.isWide();
		int space = (iswide ? 2 : 1);
		
		// {@squirreljme.error JC1i Stack would overflow loading local value.}
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		if (stacktop + space > stack.length)
			throw new InvalidClassFormatException("JC1i");
		
		// Setup new stack
		Info[] newstack = stack.clone();
		Info dest;
		newstack[stacktop] = (dest = stack[stacktop].newTypeValue(type,
			from.value, true));
		
		// Add top entry as well
		if (iswide)
			newstack[stacktop + 1] = stack[stacktop + 1].newTypeValue(
				type.topType(), from.value + 1, true);
		
		// Create resulting state
 		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop + space),
			null,
			JavaStackResult.makeInput(from),
			JavaStackResult.makeOutput(dest));
	}
	
	/**
	 * Sets a local variable.
	 *
	 * @param __jt The type of entry to set.
	 * @param __l The local to set.
	 * @return Return the result of the set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/06
	 */
	public final JavaStackResult doLocalSet(JavaType __jt, int __l)
		throws NullPointerException
	{
		if (__jt == null)
			throw new NullPointerException("NARG");
			
		Info[] locals = this._locals;
		
		// {@squirreljme.error JC1j Cannot write over a local variable which
		// is read-only. (The local)}
		Info olddest = locals[__l];
		if (olddest.readonly)
			throw new InvalidClassFormatException("JC1j " + olddest);
		
		// If the target local is an object it could be enqueued and it has
		// to be uncounted
		List<Integer> enq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		if (olddest.canEnqueue())
			enq.add(olddest.value);
		
		// If we are going to be writing over two locals we need to check
		// the other as well
		if (__jt.isWide())
		{
			// {@squirreljme.error JC1k Cannot write over a local variable
			// which is read-only. (The local)}
			Info wolddest = locals[__l + 1];
			if (wolddest.readonly)
				throw new InvalidClassFormatException("JC1k " + wolddest);
			
			// If the target local is an object it could be enqueued
			if (wolddest.canEnqueue())
				enq.add(wolddest.value);
		}
		
		// Go through the stack and uncache anything which refers to the
		// old destination by value
		Info[] newstack = this._stack.clone();
		int bumpreg = olddest.register,
			stacktop = this.stacktop;
		for (int i = 0; i < stacktop; i++)
		{
			Info ss = newstack[i];
			
			// If the value points to the local register then it is going to
			// be destroyed, so make sure the value is correctly restored and
			// the cached state of the stack is removed
			if (ss.value == bumpreg)
			{
				int ssreg = ss.register;
				JavaType sst = ss.type;
				
				// Copy the value from the local to the stack entry's true
				// register
				ops.add(new StateOperation((sst.isWide() ?
					StateOperation.Type.WIDE_COPY : StateOperation.Type.COPY),
					bumpreg, ssreg));
				
				// If the local is counted, then the destination spot on the
				// stack needs to be counted
				if (sst.isObject() && !olddest.nocounting)
					ops.add(new StateOperation(StateOperation.Type.COUNT,
						ssreg));
				
				// Then this slot on the stack becomes just a non-cached direct
				// value
				newstack[i] = new Info(ssreg, sst, ssreg, false,
					olddest.nocounting);
				
				// Also un-cache wide values, remember that longs and doubles
				// are never counted
				if (sst.isWide())
					newstack[i + 1] = new Info(ssreg + 1, sst.topType(),
						ssreg + 1, false, false);
			}
		}
		
		// Setup new base local, remember that locals are never aliased but
		// they might use no counting
		Info[] newlocals = locals.clone();
		Info pushed;
		newlocals[__l] = (pushed = olddest.newTypeValue(__jt,
			olddest.register, false));
		
		// Additionally push top type as well
		if (__jt.isWide())
			newlocals[__l + 1] = newlocals[__l + 1].newTypeValue(
				__jt.topType(), pushed.register + 1, false);
		
		// Create resulting state
 		return new JavaStackResult(this,
			new JavaStackState(newlocals, newstack, stacktop),
			new JavaStackEnqueueList(enq.size(), enq),
			new StateOperations(ops),
			JavaStackResult.makeOutput(pushed));
	}
	
	/**
	 * Writes into the specified local variable from the top-most stack entry.
	 *
	 * Locals which are written to are never cached and are exempt from
	 * any kind caching.
	 *
	 * @param __l The local to store.
	 * @return The result of the store.
	 * @throws InvalidClassFormatException If the local cannot be written to.
	 * @since 2019/04/02
	 */
	public final JavaStackResult doLocalStore(int __l)
		throws InvalidClassFormatException
	{
		// Pop the value to store from the stack
		JavaStackResult stackpop = this.doStack(1);
		JavaStackResult.Input popped = stackpop.in(0);
		
		// Then perform the store from this previous result
		JavaStackResult stacksto = stackpop.after().doLocalSet(
			popped.type, __l);
		
		// Copy old operations over to add more potentially
		List<StateOperation> lsops = new ArrayList<>();
		for (StateOperation sop : stacksto.operations())
			lsops.add(sop);
		
		// If we are storing an object, make sure it is counted
		JavaStackResult.Output out = stacksto.out(0);
		if (popped.isObject() && popped.nocounting)
			lsops.add(0, StateOperation.count(popped.register));
		
		// The two states are nearly combined but most of the result comes
		// from the actual push
		return new JavaStackResult(this,
			stacksto.after,
			stacksto.enqueue,
			new StateOperations(lsops),
			popped, out);
	}
	
	/**
	 * Does nothing, keeping the state exactly the same but producing a
	 * result.
	 *
	 * @return The result of doing nothing.
	 * @since 2019/04/07
	 */
	public final JavaStackResult doNothing()
	{
		return new JavaStackResult(this, this, null);
	}
	
	/**
	 * Pops a certain number of variables and then pushes the given types
	 * to the stack. Note that all results of this operation will treat
	 * all of the target stack operations as new freshly obtained values
	 * with no caching performed on them.
	 *
	 * @param __n The number of locals to pop.
	 * @param __t The types to push.
	 * @return The result of the operation.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStack(int __n, JavaType... __t)
	{
		return this.doStack(__n, false, __t);
	}
	
	/**
	 * Pops a certain number of variables and then pushes the given types
	 * to the stack, this may also force caching on pushed values. Note that
	 * all results of this operation will treat
	 * all of the target stack operations as new freshly obtained values
	 * with no caching performed on them.
	 *
	 * @param __n The number of locals to pop.
	 * @param __nc If true then all the values being pushed will not be
	 * reference countable.
	 * @param __pts The types to push.
	 * @return The result of the operation.
	 * @throws IllegalArgumentException If the local count is negative or an
	 * attempt is made to push a top or nothing type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStack(int __n, boolean __nc,
		JavaType... __pts)
		throws IllegalArgumentException, NullPointerException
	{
		// {@squirreljme.error JC1l Cannot pop a negative number of entries.}
		if (__n < 0)
			throw new IllegalArgumentException("JC1l");
		
		// Force blank types for pushing
		__pts = (__pts == null ? new JavaType[0] : __pts.clone());
		for (JavaType pt : __pts)
			if (pt == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error JC1m Cannot push nothing or top type.}
			else if (pt.isNothing() || pt.isTop())
				throw new IllegalArgumentException("JC1m");
		
		// Only the stack is operated on!
		Info[] stack = this._stack;
		int stacktop = this.stacktop,
			stacklimit = stack.length;
		
		// Enqueues to clear popped entries
		List<Integer> enqs = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Pop entries off the stack first
		List<Info> popped = new ArrayList<>();
		for (int i = 0; i < __n; i++)
		{
			// {@squirreljme.error JC1n Stack underflow.}
			if (stacktop <= 0)
				throw new IllegalArgumentException("JC1n");
			
			// Read top most entry, handle tops accordingly
			Info inf = stack[--stacktop];
			if (inf.type.isTop())
				inf = stack[--stacktop];
			
			// Only enqueue objects which are counting and which do not have
			// values of another register
			if (inf.canEnqueue())
				enqs.add(inf.value);
			
			// Was popped, so add to to the pop list
			popped.add(0, inf);
		}
		
		// Setup new stack for pushing
		Info[] newstack = stack.clone();
		
		// Push new entries to the stack
		List<Info> pushed = new ArrayList<>();
		for (JavaType pt : __pts)
		{
			// {@squirreljme.error JC1o Stack overflow. (Top; Limit)}
			if (stacktop >= stacklimit)
				throw new IllegalArgumentException("JC1o " + stacktop + " " +
					stacklimit);
			
			// Setup entry
			Info inf = newstack[stacktop];
			newstack[stacktop] = (inf = inf.newTypeValue(
				pt, inf.register, __nc));
			stacktop++;
			if (pt.isWide())
			{
				newstack[stacktop] = newstack[stacktop].newTypeValue(
					pt.topType(), inf.value + 1, __nc);
				stacktop++;
			}
			
			// Add to pushed set
			pushed.add(inf);
		}
		
		// Convert infos to I/O, note that there is a rare case in the compiler
		// where it nukes stack entries to nothing.
		List<JavaStackResult.InputOutput> ios = new ArrayList<>();
		for (Info i : popped)
			ios.add((i.isNothing() ? JavaStackResult.INPUT_ZERO :
				JavaStackResult.makeInput(i)));
		for (Info o : pushed)
			ios.add(JavaStackResult.makeOutput(o));
		
		// Build result
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, stacktop),
			new JavaStackEnqueueList(enqs.size(), enqs),
			new StateOperations(ops),
			ios.<JavaStackResult.InputOutput>toArray(
				new JavaStackResult.InputOutput[ios.size()]));
	}
	
	/**
	 * Performs the specified stack shuffling, which may be duplication or
	 * otherwise.
	 *
	 * @param __t The type of shuffle to perform.
	 * @return The result of the shuffle.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public final JavaStackResult doStackShuffle(JavaStackShuffleType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Input stack properties
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		
		// Find function
		JavaStackShuffleType.Function func = this.findShuffleFunction(__t);
		
		// Determine stack properties of the pop
		int maxpop = func.in.max,
			basetop = stacktop - maxpop;
		
		// Load section of stack to be popped
		List<Info> pops = new ArrayList<>(maxpop);
		for (int i = basetop; i < stacktop; i++)
			pops.add(stack[i]);
		
		// Input and output slots
		JavaStackShuffleType.Slots sin = func.in,
			sout = func.out;
		
		// Map virtual variables to entries on the input so we know what is
		// what. Also include the register values are stored at for caching.
		Map<Integer, Info> source = new LinkedHashMap<>();
		Map<Integer, Integer> storedat = new LinkedHashMap<>();
		for (int ldx = 0; ldx < maxpop; ldx++)
		{
			int var = sin._var[ldx];
			if (var >= 0)
			{
				source.put(var, pops.get(ldx));
				storedat.put(var, -1);
			}
		}
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("Source map: %s", source);
		
		// Number of entries to push
		int pushcount = sout.max;
		
		// Initialize new stack
		Info[] newstack = stack.clone();
		int newstacktop = basetop + pushcount;
		
		// Any enqueues and operations to perform
		List<Integer> enqs = new ArrayList<>();
		List<StateOperation> sops = new ArrayList<>();
		
		// For registers which have a value collision, they must be
		// pre-copied to temporary space
		int tempbase = this.usedregisters;
		Map<Integer, Integer> precopy = new LinkedHashMap<>();
		
		// Setup the new stack by pushing around
		for (int at = basetop, ldx = 0; ldx < pushcount; at++, ldx++)
		{
			// Pushing a top type?
			int vardx = sout._var[ldx];
			if (vardx < 0)
			{
				// Set the current to the appropriate top type of the entry
				// before this one
				Info prev = newstack[at - 1];
				newstack[at] = newstack[at].newTypeValue(prev.type.topType(),
					prev.value + 1, false);
				
				continue;
			}
			
			// Get the source info to use for this slot
			// Also the original destination
			Info ssl = source.get(vardx),
				ods = newstack[at];
				
			// Is this type wide?
			boolean iswide = ssl.type.isWide();
			
			// If the value was never used before, try to use the original
			// register for it
			int useval = storedat.get(vardx);
			if (useval < 0)
				useval = ssl.value;
			
			// Using the value position would violate the strict no-aliasing
			// of future registers
			if (useval > ods.register)
			{
				// Try to use an already copied value, if it has not yet had
				// a pre-copy then map it to the copied source instead
				Integer pre = precopy.get(useval);
				if (pre == null)
				{
					precopy.put(useval,
						(pre = (iswide ? -tempbase : tempbase)));
					tempbase += (iswide ? 2 : 1);
				}
				
				// The value to use is the destination register because it
				// will be copied
				useval = ods.register;
				sops.add(StateOperation.copy(iswide, Math.abs(pre), useval));
				
				// Debug
				if (__Debug__.ENABLED)
					todo.DEBUG.note("Pre %d -> %d", pre, useval);
			}
			
			// Set value as being stored here
			storedat.put(vardx, useval);
			
			// Setup slot
			newstack[at] = newstack[at].newTypeValue(ssl.type, useval,
				ssl.nocounting);
		}
		
		// Pre-copies which are needed, but make sure that the original
		// link order is maintained, negative premaps are treated as
		// being wide
		int vdat = 0;
		for (Map.Entry<Integer, Integer> e : precopy.entrySet())
			sops.add(vdat++, StateOperation.copy(
				e.getValue() < 0, e.getKey(), Math.abs(e.getValue())));
		
		// Build
		return new JavaStackResult(this,
			new JavaStackState(this._locals, newstack, newstacktop),
			new JavaStackEnqueueList(enqs.size(), enqs),
			new StateOperations(sops));
	}
	
	/**
	 * Throws a variable from the top of the stack and tosses it.
	 *
	 * @return The result of the throw.
	 * @since 2019/11/30
	 */
	public final JavaStackResult doThrow()
	{
		return this.doStack(1);
	}
	
	/**
	 * Transitions to the given stack state.
	 *
	 * @param __ts The target to transition.
	 * @return The result of the transition and the operations used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/11
	 */
	public final JavaStackResult doTransition(JavaStackState __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// If this state is exactly the same as this one then no actual
		// transition work needs to be done, so no result is generated
		if (this.equals(__ts))
			return new JavaStackResult(this, this, null);
		
		// Debug
		if (__Debug__.ENABLED)
		{
			todo.DEBUG.note("Will transition the stack!");
			todo.DEBUG.note("From: %s", this);
			todo.DEBUG.note("To  : %s", __ts);
		}
		
		// {@squirreljme.error JC1p A transition cannot be made where the
		// length of the stack differs. (The length of the source stack; The
		// length of the target stack)}
		int atop = this.stacktop,
			btop = __ts.stacktop;
		if (atop != btop)
			throw new InvalidClassFormatException("JC1p " + atop + " " + btop);
		
		// Used to store operations and enqueues
		List<Integer> stackenq = new ArrayList<>(),
			localenq = new ArrayList<>();
		List<StateOperation> ops = new ArrayList<>();
		
		// Source and destination stacks
		Info[] asta = this._stack,
			bsta = __ts._stack,
			aloc = this._locals,
			bloc = __ts._locals;
		
		// Transition both the stack and the locals
		for (int z = 0; z < 2; z++)
		{
			Info[] ainf,
				binf;
			int cap;
			
			// Stack transition
			boolean isstack = (z == 0);
			if (isstack)
			{
				ainf = asta;
				binf = bsta;
				cap = atop;
			}
			
			// Local transition
			else
			{
				ainf = aloc;
				binf = bloc;
				cap = aloc.length;
			}
			
			// Go through and transition the locals
			for (int i = 0, n = cap; i < n; i++)
			{
				Info a = ainf[i],
					b = binf[i];
				
				// They are exactly the same, so nothing needs to be done
				if (a.equals(b))
					continue;
				
				// The source is nothing
				JavaType at = a.type,
					bt = b.type;
				if (at.isNothing())
				{
					// Transition to a non-nothing type, just copy zero to it
					if (!bt.isNothing())
						ops.add(StateOperation.copy(
							bt.isWide(), 0, b.value));
				}
				
				// If the target is transitioning to nothing, then it will be
				// removed
				else if (bt.isNothing())
				{
					// If the A local is an object that is countable, then just
					// uncount it
					if (a.canEnqueue())
					{
						localenq.add(a.value);
						ops.add(StateOperation.uncount(a.value));
					}
					
					// If this is a nothing being put on the stack put a
					// zero value there to wipe it!
					if (isstack)
						ops.add(StateOperation.copy(
							false, a.value, b.register));
				}
				
				// Check if the types and values are compatible
				else
				{
					// Transitioning from no-counting to counting means that A
					// was never counted
					if (!a.canEnqueue() && b.canEnqueue())
						ops.add(StateOperation.count(a.value));
					
					// Transition from non-compatible types means that a copy
					// from zero is performed
					if (at.isObject() != bt.isObject() ||
						(!at.isObject() && !at.equals(bt)))
						ops.add(StateOperation.copy(
							bt.isWide(), 0, b.value));
					
					// Copy to destination, if the values differ
					else if (a.value != b.value)
						ops.add(StateOperation.copy(
							at.isWide(), a.value, b.value));
					
					// Going from counting to no counting means we probably
					// have an extra count somewhere
					if (a.canEnqueue() && !b.canEnqueue())
						ops.add(StateOperation.uncount(b.value));
				}
			}
		}
		
		// Merge the enqueues for locals and the stack
		int eqsat = localenq.size();
		localenq.addAll(stackenq);
		
		// The transition results in the target stack so we do not need to
		// initialize it, however we do need enqueues and operations
		return new JavaStackResult(this, __ts,
			new JavaStackEnqueueList(eqsat, localenq),
			new StateOperations(ops));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof JavaStackState))
			return false;
		
		// Faster to compare hashcodes first since there are lots of values
		JavaStackState o = (JavaStackState)__o;
		if (this.hashCode() != o.hashCode())
			return false;
		
		return this.stacktop == o.stacktop &&
			Arrays.equals(this._locals, o._locals) &&
			Arrays.equals(this._stack, o._stack);
	}
	
	/**
	 * Goes through the stack map and filters the locals and types so that
	 * they match what is in the stack map table.
	 *
	 * @param __smts The source stack map.
	 * @return The resulting stack which has been filtered.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public final JavaStackState filterByStackMap(StackMapTableState __smts)
		throws NullPointerException
	{
		if (__smts == null)
			throw new NullPointerException("NARG");
		
		// Debug
		if (__Debug__.ENABLED)
			todo.DEBUG.note("SMTS: %s", __smts);
			
		// Input stack properties
		Info[] locals = this._locals.clone(),
			stack = this._stack.clone();
		int stacktop = this.stacktop;
		
		// Used to just drop any changes if nothing changed
		boolean changed = false;
		
		// Filter local variables
		for (int i = 0, n = locals.length; i < n; i++)
		{
			// Get infos and state
			Info inf = locals[i];
			StackMapTableEntry sme = __smts.getLocal(i);
			
			// Type changed?
			if (!inf.type.equals(sme.type()))
			{
				// The local is being wiped away
				if (sme.type().isNothing())
					inf = new Info(inf.register, JavaType.NOTHING,
						inf.register, false, false);
				
				// Use this type instead
				else if (inf.type.isObject())
					inf = new Info(inf.register, sme.type(),
						inf.value, inf.readonly, inf.nocounting);
			}
			
			// Set if changed
			if (changed |= (locals[i] != inf))
				locals[i] = inf;
		}
		
		// Filter stack variables
		for (int i = 0; i < stacktop; i++)
		{
			// Get infos and state
			Info inf = stack[i];
			StackMapTableEntry sme = __smts.getStack(i);
			
			// Use type if the object is different
			if (!inf.type.equals(sme.type()) && inf.type.isObject())
				inf = new Info(inf.register, sme.type(),
					inf.value, inf.readonly, inf.nocounting);
			
			// Set if changed
			if (changed |= (stack[i] != inf))
				stack[i] = inf;
		}
		
		// Only return a new state if it actually changed
		if (changed)
			return new JavaStackState(locals, stack, stacktop);
		return this;
	}
	
	/**
	 * Locates the shuffle function that is used to pop from the stack
	 * accordingly to this stack state.
	 *
	 * @param __t The type of shuffle to perform.
	 * @return The matching shuffle function.
	 * @throws InvalidClassFormatException If the shuffle function was not
	 * found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/04
	 */
	public final JavaStackShuffleType.Function findShuffleFunction(
		JavaStackShuffleType __t)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Input stack properties
		Info[] stack = this._stack;
		int stacktop = this.stacktop;
		
		// Working pop list when match is found
		int basetop = -1,
			maxpop = -1;
		
		// Search for the matching function to use for this state
		for (JavaStackShuffleType.Function tryf : __t._functions)
		{
			// Clear for run
			basetop = -1;
			
			// Input slots are used
			JavaStackShuffleType.Slots sls = tryf.in;
			
			// Too little on the stack to pop everything?
			maxpop = sls.max;
			basetop = stacktop - maxpop;
			if (basetop < 0)
				continue;
			
			// Go through slots and see if this is a match or not
			int at = basetop;
			for (int ldx = 0; at < stacktop; ldx++, at++)
			{
				Info i = stack[at];
				JavaType it = i.type;
				
				// Top-ness and wide-ness does not match
				if (it.isTop() != (sls._var[ldx] < 0) ||
					it.isWide() != sls._wide[ldx])
					break;
			}
			
			// If this index was reached then everything was valid
			if (at == stacktop)
				return tryf;
		}
		
		// {@squirreljme.error JC1q Could not find a match for performing
		// shuffled stack operations.}
		throw new InvalidClassFormatException("JC1q");
	}
	
	/**
	 * Obtains the given local.
	 *
	 * @param __i The local to obtain.
	 * @return The information for the local.
	 * @since 2019/03/30
	 */
	public final JavaStackState.Info getLocal(int __i)
	{
		return this._locals[__i];
	}
	
	/**
	 * Obtains the given stack entry.
	 *
	 * @param __i The stack entry to obtain.
	 * @return The information for the stack entry.
	 * @since 2019/03/30
	 */
	public final JavaStackState.Info getStack(int __i)
	{
		return this._stack[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		int hash = this._hash;
		if (hash == 0)
			this._hash = (hash = this.stacktop -
				Arrays.asList(this._locals).hashCode() ^
				Arrays.asList(this._stack).hashCode());
		return hash;
	}
	
	/**
	 * Returns the number of local used.
	 *
	 * @return The locals used.
	 * @since 2019/04/06
	 */
	public final int maxLocals()
	{
		return this._locals.length;
	}
	
	/**
	 * Returns the maximum stack size.
	 *
	 * @return The maximum stack size.
	 * @since 2019/04/06
	 */
	public final int maxStack()
	{
		return this._stack.length;
	}
	
	/**
	 * Returns the resulting stack state which would be as if nothing were
	 * cached.
	 *
	 * @return The non-cached stack state.
	 * @since 2019/04/11
	 */
	public final JavaStackState nonCached()
	{
		// Create new copies of the state
		int stacktop = this.stacktop;
		Info[] locals = this._locals.clone(),
			stack = this._stack.clone();
		
		// Un-cache locals
		for (int i = 0, n = locals.length; i < n; i++)
		{
			Info info = locals[i];
			
			// Read-only values are never un-cached
			if (info.readonly)
				continue;
			
			// Map value to the register
			locals[i] = info.newValue(info.register, false);
		}
		
		// Un-cache the stack
		for (int i = 0; i < stacktop; i++)
		{
			Info info = stack[i];
			stack[i] = info.newValue(info.register, false);
		}
		
		// Build, do not return the new object if it ends up being the same
		JavaStackState rv = new JavaStackState(locals, stack, stacktop);
		if (this.equals(rv))
			return this;
		return rv;
	}
	
	/**
	 * Returns all of the enqueues which are possible if the entire stack
	 * and locals were to be flushed.
	 *
	 * @return The maximum possible enqueue list.
	 * @since 2019/03/30
	 */
	public final JavaStackEnqueueList possibleEnqueue()
	{
		// This is the same as a destroy
		return this.doDestroy(false).enqueue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("State:{L=");
			
			// Add locals
			sb.append(Arrays.asList(this._locals));
			
			// Add stack entries
			Info[] stack = this._stack;
			sb.append(", S=[");
			for (int i = 0, n = this.stacktop; i < n; i++)
			{
				if (i > 0)
					sb.append(", ");
				sb.append(stack[i]);
			}
			sb.append("]}");
			
			// Build
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Initializes the stack state based off the given stack map table state,
	 * this should only be used for the initial seed of the stack state.
	 *
	 * @param __s The state to base off.
	 * @param __lw Local variables which have been written, this is used to
	 * set flags where locals are cached and can never be written to.
	 * @return The result stack state.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public static final JavaStackState of(StackMapTableState __s, int... __lw)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Optional, might not be specified, but also sort it for searching
		__lw = (__lw == null ? new int[0] : __lw.clone());
		Arrays.sort(__lw);
		
		// Get size of the entries
		int maxlocals = __s.maxLocals(),
			maxstack = __s.maxStack(),
			stacktop = __s.depth();
		
		// Force the stack to have at least a single entry for exception
		// handlers
		if (maxstack == 0)
			maxstack++;
		
		// Setup output infos
		Info[] locals = new Info[maxlocals],
			stack = new Info[maxstack];
		
		// Register position for the slot
		int rpos = BASE_REGISTER;
		
		// Initialize locals
		for (int i = 0; i < maxlocals; i++)
		{
			StackMapTableEntry from = __s.getLocal(i);
			
			// This local is considered read-only if it is not written to
			boolean ro = !(Arrays.binarySearch(__lw, i) >= 0);
			
			// Is there a type here?
			JavaType t = from.type();
			
			// Setup info here
			locals[i] = new Info(rpos, t, (t.isNothing() ? -1 : rpos), ro, ro);
			rpos++;
		}
		
		// Initialize stack
		for (int i = 0; i < maxstack; i++)
		{
			// Past end of stack?
			if (i >= stacktop)
				stack[i] = new Info(rpos++, JavaType.NOTHING, -1, false,
					false);
			
			// Normal entry
			else
			{
				StackMapTableEntry from = __s.getStack(i);
				
				// Setup info here
				stack[i] = new Info(rpos, from.type(), rpos, false, false);
				rpos++;
			}
		}
		
		// Build it
		return new JavaStackState(locals, stack, stacktop);
	}
	
	/**
	 * Contains information on the individual stack slots.
	 *
	 * @since 2019/03/30
	 */
	public static final class Info
	{
		/** The register position. */
		public final int register;
		
		/** The type. */
		public final JavaType type;
		
		/** The value register. */
		public final int value;
		
		/** Is this read-only? */
		public final boolean readonly;
		
		/** Do not use counting. */
		public final boolean nocounting;
		
		/** String representation. */
		private Reference<String> _string;
		
		/** Hash. */
		private int _hash;
		
		/**
		 * Initializes the information.
		 *
		 * @param __rp The register.
		 * @param __t The type.
		 * @param __rv The value register.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Info(int __rp, JavaType __t, int __rv)
			throws NullPointerException
		{
			this(__rp, __t, __rv, false, false);
		}
		
		/**
		 * Initializes the information.
		 *
		 * @param __rp The register.
		 * @param __t The type.
		 * @param __rv The value register.
		 * @param __ro Is this read-only?
		 * @param __nc Is no counting to be used?
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public Info(int __rp, JavaType __t, int __rv, boolean __ro,
			boolean __nc)
			throws NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			// If no value was set, just set it to the position
			if (!__t.isNothing() && __rv < 0)
				__rv = __rp;
			
			// Set
			this.register = __rp;
			this.type = __t;
			this.value = (__rv = (__t.isNothing() ? -1 : __rv));
			this.readonly = __ro;
			this.nocounting = __t.isObject() &&
				(__nc || __rp != __rv || __rv < 0);
		}
		
		/**
		 * Can this be enqueued?
		 *
		 * @return If this can be enqueued.
		 * @since 2019/03/31
		 */
		public final boolean canEnqueue()
		{
			if (this.nocounting)
				return false;
			
			return this.type.isObject() &&
				this.register == this.value;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final boolean equals(Object __o)
		{
			if (this == __o)
				return true;
			
			if (!(__o instanceof Info))
				return false;
			
			Info o = (Info)__o;
			if (this.hashCode() != o.hashCode())
				return false;
			
			return this.register == o.register &&
				this.type.equals(o.type) &&
				this.value == o.value &&
				this.readonly == o.readonly &&
				this.nocounting == o.nocounting;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final int hashCode()
		{
			int rv = this._hash;
			if (rv == 0)
				this._hash = (rv = this.register + this.type.hashCode() +
					this.value + (this.readonly ? 12873 : -18723) +
					(this.nocounting ? 987214 : -2143));
			return rv;
		}
		
		/**
		 * Is this the nothing type?
		 *
		 * @return If this is the nothing type.
		 * @since 2019/05/29
		 */
		public final boolean isNothing()
		{
			return this.type.isNothing();
		}
		
		/**
		 * Returns information with a new type and value.
		 *
		 * @param __t The type to use.
		 * @param __v The value to use.
		 * @param __nc Do not count this?
		 * @return The new information.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/03/31
		 */
		public final Info newTypeValue(JavaType __t, int __v, boolean __nc)
			throws NullPointerException
		{
			Info rv = new Info(this.register, __t, __v, false, __nc);
			if (this.equals(rv))
				return this;
			return rv;
		}
		
		/**
		 * Sets up info with a new value, using the same type.
		 *
		 * @param __v The new value.
		 * @param __nc Do not count this?
		 * @return The resulting value.
		 * @since 2019/04/11
		 */
		public final Info newValue(int __v, boolean __nc)
		{
			Info rv = new Info(this.register, this.type, __v, false, __nc);
			if (this.equals(rv))
				return this;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/03/30
		 */
		@Override
		public final String toString()
		{
			Reference<String> ref = this._string;
			String rv;
			
			if (ref == null || null == (rv = ref.get()))
			{
				int register = this.register;
				JavaType type = this.type;
				boolean ro = this.readonly,
					nc = this.nocounting;
				
				// Use a compact format for nothing
				if (type.isNothing())
					rv = "--(r" + register + ")";
				
				// Otherwise use a more compact form
				// Previously it was {V=r4 (r4), T=I, F=RONC}, however that
				// takes up too much room and is hard to read
				else
				{
					// If value == register, there is no point in duplicating
					int value = this.value;
					rv = String.format("%s:%s%s%s%s",
						(value != register ?
							("r" + value + "(" + register + ")") :
							("r" + value)),
						this.type, ((ro || nc) ? ":" : ""),
						(ro ? "R" : ""), (nc ? "N" : ""));
				}
				
				this._string = new WeakReference<>(rv);
			}
			
			return rv;
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/MathType.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.PrimitiveType;

/**
 * This represents a math operation to be performed.
 *
 * @since 2019/04/03
 */
public enum MathType
{
	/** Add. */
	ADD,
	
	/** Subtract. */
	SUB,
	
	/** Multiply. */
	MUL,
	
	/** Divide. */
	DIV,
	
	/** Remainder. */
	REM,
	
	/** Negate. */
	NEG,
	
	/** Shift left. */
	SHL,
	
	/** Shift right. */
	SHR,
	
	/** Unsigned shift right. */
	USHR,
	
	/** And. */
	AND,
	
	/** Or. */
	OR,
	
	/** Xor. */
	XOR,
	
	/** Compare (float compare less). */
	CMPL,
	
	/** Compare (float compare greater). */
	CMPG,
	
	/** Sign 8-bit value. */
	SIGNX8,
	
	/** Sign 16-bit value. */
	SIGNX16,
	
	/** End. */
	;
	
	/**
	 * Returns the signature for the given math operation and type.
	 *
	 * @param __jt The type to use.
	 * @return The resulting signature.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/21
	 */
	public final String signature(StackJavaType __jt)
		throws NullPointerException
	{
		switch (this)
		{
			case CMPL:
			case CMPG:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(IIII)I";
					case FLOAT:		return "(II)I";
					case DOUBLE:	return "(IIII)I";
				}
				break;
			
			case NEG:
			case SIGNX8:
			case SIGNX16:
				switch (__jt)
				{
					case INTEGER:	return "(I)I";
					case LONG:		return "(II)J";
					case FLOAT:		return "(I)F";
					case DOUBLE:	return "(II)D";
				}
				break;
			
			case SHL:
			case SHR:
			case USHR:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(III)J";
					case FLOAT:		return "(II)F";
					case DOUBLE:	return "(III)D";
				}
				break;
			
			default:
				switch (__jt)
				{
					case INTEGER:	return "(II)I";
					case LONG:		return "(IIII)J";
					case FLOAT:		return "(II)F";
					case DOUBLE:	return "(IIII)D";
				}
				break;
		}
		
		throw new todo.OOPS(this + " " + __jt);
	}
	
	/**
	 * Returns the math type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting math type.
	 * @since 2019/04/08
	 */
	public static final MathType of(int __i)
	{
		switch (__i)
		{
			case 0:		return ADD;
			case 1:		return SUB;
			case 2:		return MUL;
			case 3:		return DIV;
			case 4:		return REM;
			case 5:		return NEG;
			case 6:		return SHL;
			case 7:		return SHR;
			case 8:		return USHR;
			case 9:		return AND;
			case 10:	return OR;
			case 11:	return XOR;
			case 12:	return CMPL;
			case 13:	return CMPG;
			case 14:	return SIGNX8;
			case 15:	return SIGNX16;
		}
		
		// {@squirreljme.error JC1r Invalid math operation.}
		throw new IllegalArgumentException("JC1r");
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/SimplifiedJavaInstruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ConstantValueDouble;
import net.multiphasicapps.classfile.ConstantValueFloat;
import net.multiphasicapps.classfile.ConstantValueInteger;
import net.multiphasicapps.classfile.ConstantValueLong;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InstructionIndex;
import net.multiphasicapps.classfile.InstructionJumpTarget;
import net.multiphasicapps.classfile.InstructionMnemonics;
import net.multiphasicapps.classfile.LookupSwitch;
import net.multiphasicapps.classfile.JavaType;
import net.multiphasicapps.classfile.PrimitiveType;
import net.multiphasicapps.classfile.TableSwitch;

/**
 * This represents a simplified Java instruction which modifies the operation
 * that was performed to combine and make it more aliased. The primary goal
 * of this class is to simplify the translator code so it does not have to know
 * about every operation.
 *
 * For example {@code ALOAD_2:[]} will become {@code ALOAD:[2]}.
 *
 * @since 2019/04/03
 */
public final class SimplifiedJavaInstruction
{
	/** Store operation. */
	public static final int STORE =
		-2;
	
	/** Load operation. */
	public static final int LOAD =
		-3;
	
	/** Value return operation. */
	public static final int VRETURN =
		-4;
	
	/** Math operation. */
	public static final int MATH =
		-5;
	
	/** If (zero) operation. */
	public static final int IF =
		-6;
	
	/** Value comparison. */
	public static final int IF_CMP =
		-7;
	
	/** Primitive array store. */
	public static final int PASTORE =
		-8;
	
	/** Primitive array load. */
	public static final int PALOAD =
		-9;
	
	/** Stack shuffle. */
	public static final int STACKSHUFFLE =
		-10;
	
	/** Convert. */
	public static final int CONVERT =
		-11;
	
	/** Perform math on constant. */
	public static final int MATH_CONST =
		-12;
	
	/** The operation. */
	protected final int op;
	
	/** The arguments. */
	private final Object[] _args;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Translates a regular instruction to a simplified instruction.
	 *
	 * @param __inst The instruction to translate.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public SimplifiedJavaInstruction(Instruction __inst)
		throws NullPointerException
	{
		if (__inst == null)
			throw new NullPointerException("NARG");
		
		// Start with base operations
		int op = __inst.operation();
		Object[] args = __inst.arguments();
		
		// Possibly map the instruction
		int baseop = op;
		switch (op)
		{
			case InstructionIndex.ALOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.OBJECT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.OBJECT,
						baseop - InstructionIndex.ALOAD_0,
					};
				break;
				
			case InstructionIndex.ARETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.OBJECT,
					};
				break;
			
			case InstructionIndex.ASTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.OBJECT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.OBJECT,
						baseop - InstructionIndex.ASTORE_0,
					};
				break;
				
			case InstructionIndex.BALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.BYTE,
					};
				break;
				
			case InstructionIndex.BASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.BYTE,
					};
				break;
			
			case InstructionIndex.BIPUSH:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(__inst.byteArgument(0)),
					};
				break;
				
			case InstructionIndex.CALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.CHARACTER,
					};
				break;
				
			case InstructionIndex.CASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.CHARACTER,
					};
				break;
			
			case InstructionIndex.D2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.D2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.INTEGER,
					};
				break;
			
			case InstructionIndex.D2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.DOUBLE,
						StackJavaType.LONG,
					};
				break;
			
			case InstructionIndex.DADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.DALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.DOUBLE,
					};
				break;
				
			case InstructionIndex.DASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.DOUBLE,
					};
				break;
			
			case InstructionIndex.DCMPG:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.DCMPL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.CMPL,
					};
				break;
			
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueDouble(
							baseop - InstructionIndex.DCONST_0),
					};
				break;
				
			case InstructionIndex.DDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.DIV,
					};
				break;
			
			
			case InstructionIndex.DLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.DOUBLE,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.DOUBLE,
						baseop - InstructionIndex.DLOAD_0,
					};
				break;
			
			case InstructionIndex.DMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.DNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.NEG,
						Double.valueOf(0),
					};
				break;
				
			case InstructionIndex.DREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.REM,
					};
				break;
			
			case InstructionIndex.DRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.DOUBLE,
					};
				break;
			
			case InstructionIndex.DSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.DOUBLE,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.DOUBLE,
						baseop - InstructionIndex.DSTORE_0,
					};
				break;
			
			case InstructionIndex.DSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.DOUBLE,
						MathType.SUB,
					};
				break;
			
			case InstructionIndex.DUP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP,
					};
				break;
			
			case InstructionIndex.DUP_X1:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP_X1,
					};
				break;
			
			case InstructionIndex.DUP_X2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP_X2,
					};
				break;
			
			case InstructionIndex.DUP2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2,
					};
				break;
			
			case InstructionIndex.DUP2_X1:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2_X1,
					};
				break;
			
			case InstructionIndex.DUP2_X2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.DUP2_X2,
					};
				break;
			
			case InstructionIndex.F2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.F2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.INTEGER,
					};
				break;
			
			case InstructionIndex.F2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.FLOAT,
						StackJavaType.LONG,
					};
				break;
			
			case InstructionIndex.FADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.FALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.FLOAT,
					};
				break;
				
			case InstructionIndex.FASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.FLOAT,
					};
				break;
			
			case InstructionIndex.FCMPG:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.FCMPL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.CMPL,
					};
				break;
			
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueFloat(
							baseop - InstructionIndex.FCONST_0),
					};
				break;
				
			case InstructionIndex.FDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.DIV,
					};
				break;
			
			case InstructionIndex.FLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.FLOAT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.FLOAT,
						baseop - InstructionIndex.FLOAD_0,
					};
				break;
			
			case InstructionIndex.FMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.MUL,
					};
				break;
				
			case InstructionIndex.FREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.REM,
					};
				break;
			
			case InstructionIndex.FNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.NEG,
						Float.valueOf(0),
					};
				break;
				
			case InstructionIndex.FRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.FLOAT,
					};
				break;
			
			case InstructionIndex.FSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.FLOAT,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.FLOAT,
						baseop - InstructionIndex.FSTORE_0,
					};
				break;
			
			case InstructionIndex.FSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.FLOAT,
						MathType.SUB,
					};
				break;
			
			case InstructionIndex.GOTO_W:
				op = InstructionIndex.GOTO;
				break;
				
			case InstructionIndex.I2B:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SIGNX8,
						0,
					};
				break;
				
			case InstructionIndex.I2C:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.AND,
						0xFFFF,
					};
				break;
				
			case InstructionIndex.I2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.I2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.I2L:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.INTEGER,
						StackJavaType.LONG,
					};
				break;
				
			case InstructionIndex.I2S:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SIGNX16,
						0,
					};
				break;
				
			case InstructionIndex.IADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.IALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.INTEGER,
					};
				break;
				
			case InstructionIndex.IAND:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.AND,
					};
				break;
				
			case InstructionIndex.IASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.INTEGER,
					};
				break;
			
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(
							baseop - InstructionIndex.ICONST_0),
					};
				break;
				
			case InstructionIndex.IDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.DIV,
					};
				break;
				
			case InstructionIndex.IFEQ:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFGE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFGT:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IFLE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFLT:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNE:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNONNULL:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.IFNULL:
				op = SimplifiedJavaInstruction.IF;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ACMPEQ:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ACMPNE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.OBJECT,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPEQ:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPGE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPGT:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.GREATER_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPLE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN_OR_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPLT:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.LESS_THAN,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
				
			case InstructionIndex.IF_ICMPNE:
				op = SimplifiedJavaInstruction.IF_CMP;
				args = new Object[]
					{
						DataType.INTEGER,
						CompareType.NOT_EQUALS,
						__inst.<InstructionJumpTarget>argument(0,
							InstructionJumpTarget.class),
					};
				break;
			
			case InstructionIndex.ILOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.INTEGER,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.INTEGER,
						baseop - InstructionIndex.ILOAD_0,
					};
				break;
			
			case InstructionIndex.IMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.INEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.NEG,
						Integer.valueOf(0),
					};
				break;
				
			case InstructionIndex.IOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.OR,
					};
				break;
				
			case InstructionIndex.IREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.REM,
					};
				break;
				
			case InstructionIndex.IRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.INTEGER,
					};
				break;
			
			case InstructionIndex.ISHL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SHL,
					};
				break;
				
			case InstructionIndex.ISHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SHR,
					};
				break;
			
			case InstructionIndex.ISTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.INTEGER,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.INTEGER,
						baseop - InstructionIndex.ISTORE_0,
					};
				break;
			
			case InstructionIndex.ISUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.SUB,
					};
				break;
				
			case InstructionIndex.IUSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.USHR,
					};
				break;
				
			case InstructionIndex.IXOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.INTEGER,
						MathType.XOR,
					};
				break;
				
			case InstructionIndex.L2D:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.DOUBLE,
					};
				break;
			
			case InstructionIndex.L2F:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.FLOAT,
					};
				break;
			
			case InstructionIndex.L2I:
				op = SimplifiedJavaInstruction.CONVERT;
				args = new Object[]
					{
						StackJavaType.LONG,
						StackJavaType.INTEGER,
					};
				break;
				
			case InstructionIndex.LADD:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.ADD,
					};
				break;
				
			case InstructionIndex.LALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.LONG,
					};
				break;
				
			case InstructionIndex.LAND:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.AND,
					};
				break;
				
			case InstructionIndex.LASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.LONG,
					};
				break;
			
			case InstructionIndex.LCMP:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.CMPG,
					};
				break;
			
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueLong(
							baseop - InstructionIndex.LCONST_0),
					};
				break;
			
			case InstructionIndex.LDC2_W:
			case InstructionIndex.LDC_W:
				op = InstructionIndex.LDC;
				break;
				
			case InstructionIndex.LDIV:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.DIV,
					};
				break;
			
			case InstructionIndex.LLOAD:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.LONG,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
				op = SimplifiedJavaInstruction.LOAD;
				args = new Object[]
					{
						DataType.LONG,
						baseop - InstructionIndex.LLOAD_0,
					};
				break;
			
			case InstructionIndex.LMUL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.MUL,
					};
				break;
			
			case InstructionIndex.LNEG:
				op = SimplifiedJavaInstruction.MATH_CONST;
				args = new Object[]
					{
						DataType.LONG,
						MathType.NEG,
						Long.valueOf(0),
					};
				break;
				
			case InstructionIndex.LOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.OR,
					};
				break;
				
			case InstructionIndex.LREM:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.REM,
					};
				break;
				
			case InstructionIndex.LRETURN:
				op = SimplifiedJavaInstruction.VRETURN;
				args = new Object[]
					{
						DataType.LONG,
					};
				break;
				
			case InstructionIndex.LSHL:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SHL,
					};
				break;
				
			case InstructionIndex.LSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SHR,
					};
				break;
			
			case InstructionIndex.LSTORE:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.LONG,
						__inst.intArgument(0),
					};
				break;
			
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
				op = SimplifiedJavaInstruction.STORE;
				args = new Object[]
					{
						DataType.LONG,
						baseop - InstructionIndex.LSTORE_0,
					};
				break;
			
			case InstructionIndex.LSUB:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.SUB,
					};
				break;
				
			case InstructionIndex.LUSHR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.USHR,
					};
				break;
				
			case InstructionIndex.LXOR:
				op = SimplifiedJavaInstruction.MATH;
				args = new Object[]
					{
						DataType.LONG,
						MathType.XOR,
					};
				break;
			
				// Make all array allocations just use the class name
			case InstructionIndex.NEWARRAY:
				op = InstructionIndex.ANEWARRAY;
				args = new Object[]
					{
						ClassName.fromPrimitiveType(__inst.<PrimitiveType>
							argument(0, PrimitiveType.class)),
					};
				break;
			
			case InstructionIndex.POP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.POP,
					};
				break;
			
			case InstructionIndex.POP2:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.POP2,
					};
				break;
				
			case InstructionIndex.SALOAD:
				op = SimplifiedJavaInstruction.PALOAD;
				args = new Object[]
					{
						PrimitiveType.SHORT,
					};
				break;
				
			case InstructionIndex.SASTORE:
				op = SimplifiedJavaInstruction.PASTORE;
				args = new Object[]
					{
						PrimitiveType.SHORT,
					};
				break;
			
			case InstructionIndex.SIPUSH:
				op = InstructionIndex.LDC;
				args = new Object[]
					{
						new ConstantValueInteger(__inst.shortArgument(0)),
					};
				break;
			
			case InstructionIndex.SWAP:
				op = SimplifiedJavaInstruction.STACKSHUFFLE;
				args = new Object[]
					{
						JavaStackShuffleType.SWAP,
					};
				break;
			
				// To reduce the number of handlers, convert table switches
				// to lookup switches
			case InstructionIndex.TABLESWITCH:
				op = InstructionIndex.LOOKUPSWITCH;
				args = new Object[]
					{
						__inst.<TableSwitch>argument(0, TableSwitch.class).
							asLookupSwitch(),
					};
				break;
			
			case InstructionIndex.WIDE_IINC:
				op = InstructionIndex.IINC;
				break;
		}
		
		// Store them
		this.op = op;
		this._args = args;
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param __i The index of the argument.
	 * @return The argument.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @since 2019/03/24
	 */
	public Object argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns the argument for the given index.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not of the given type.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/03
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2019/04/03
	 */
	public final int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).intValue();
	}
	
	/**
	 * Returns the potentially aliased operation.
	 *
	 * @return The operation.
	 * @since 2019/04/03
	 */
	public final int operation()
	{
		return this.op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not a number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/03
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				SimplifiedJavaInstruction.mnemonic(this.op) + ":" +
				Arrays.asList(this._args)));
		
		return rv;
	}
	
	/**
	 * Returns the mnemonic of the operation.
	 *
	 * @param __op The operation to obtain.
	 * @return The mnemonic for the string.
	 * @since 2019/04/03
	 */
	public static final String mnemonic(int __op)
	{
		switch (__op)
		{
			case STORE:			return "STORE";
			case LOAD:			return "LOAD";
			case VRETURN:		return "VRETURN";
			case MATH:			return "MATH";
			case IF:			return "IF";
			case IF_CMP:		return "IF_CMP";
			case PASTORE:		return "PASTORE";
			case PALOAD:		return "PALOAD";
			case STACKSHUFFLE:	return "STACKSHUFFLE";
			case CONVERT:		return "CONVERT";
			case MATH_CONST:	return "MATH_CONST";
			
				// Fallback to standard stuff
			default:
				return InstructionMnemonics.toString(__op);
		}
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/StackJavaType.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.JavaType;

/**
 * This represents a Java type as it would appear on the stack.
 *
 * @since 2019/04/07
 */
public enum StackJavaType
{
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
	
	/**
	 * Returns the boxed type.
	 *
	 * @return The boxed type.
	 * @since 2019/05/27
	 */
	public final String boxedType()
	{
		switch (this)
		{
			case INTEGER:	return "Integer";
			case LONG:		return "Long";
			case FLOAT:		return "Float";
			case DOUBLE:	return "Double";
		}
		
		throw new todo.OOPS();
	}
	
	/**
	 * Returns the signature of this type.
	 *
	 * @return The type signature.
	 * @since 2019/06/21
	 */
	public final String signature()
	{
		switch (this)
		{
			case INTEGER:	return "I";
			case LONG:		return "J";
			case FLOAT:		return "F";
			case DOUBLE:	return "D";
		}
		
		throw new todo.OOPS();
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return If this is wide.
	 * @since 2019/04/20
	 */
	public final boolean isWide()
	{
		return (this == LONG || this == DOUBLE);
	}
	
	/**
	 * Returns the software math class.
	 *
	 * @return The software math class.
	 * @since 2019/05/27
	 */
	public final ClassName softwareMathClass()
	{
		String base;
		switch (this)
		{
			case INTEGER:	base = "SoftInteger"; break;
			case LONG:		base = "SoftLong"; break;
			case FLOAT:		base = "SoftFloat"; break;
			case DOUBLE:	base = "SoftDouble"; break;
			
			default:
				throw new todo.TODO();
		}
		
		return new ClassName("cc/squirreljme/jvm/" + base);
	}
	
	/**
	 * Returns this as a basic Java type.
	 *
	 * @return The Java type of this.
	 * @since 2019/04/16
	 */
	public final JavaType toJavaType()
	{
		switch (this)
		{
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
		}
		
		throw new todo.OOPS(this.name());
	}
	
	/**
	 * Returns the stack type for the given index.
	 *
	 * @param __i The index.
	 * @return The resulting stack type.
	 * @since 2019/04/08
	 */
	public static final StackJavaType of(int __i)
	{
		switch (__i)
		{
			case 0:		return INTEGER;
			case 1:		return LONG;
			case 2:		return FLOAT;
			case 3:		return DOUBLE;
		}
		
		// {@squirreljme.error JC1s Invalid stack Java type.}
		throw new IllegalArgumentException("JC1s");
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/StateOperation.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
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


























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents an operation that needs to be performed during stack
 * transitions.
 *
 * @since 2019/04/11
 */
public final class StateOperation
{
	/** The type of operation to perform. */
	public final StateOperation.Type type;
	
	/** The A register. */
	public final int a;
	
	/** The B register. */
	public final int b;
	
	/** Hashcode. */
	private int _hash;
	
	/** String. */
	private Reference<String> _string;
	
	/**
	 * Initializes the state operation.
	 *
	 * @param __t The type.
	 * @param __a Register A.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public StateOperation(StateOperation.Type __t, int __a)
		throws NullPointerException
	{
		this(__t, __a, __a);
	}
	
	/**
	 * Initializes the state operation.
	 *
	 * @param __t The type.
	 * @param __a Register A.
	 * @param __b Register B.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/13
	 */
	public StateOperation(StateOperation.Type __t, int __a, int __b)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		this.type = __t;
		this.a = __a;
		this.b = __b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		if (!(__o instanceof StateOperation))
			return false;
		
		StateOperation o = (StateOperation)__o;
		return this.type.equals(o.type) &&
			this.a == o.a &&
			this.b == o.b;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.type.hashCode() + this.a + this.b);
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.type + "(" +
				this.a + ", " + this.b + ")"));
		
		return rv;
	}
	
	/**
	 * Creates a copy operation.
	 *
	 * @param __w Is this wide?
	 * @param __s The source.
	 * @param __d The destination.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation copy(boolean __w, int __a, int __b)
	{
		return new StateOperation((__w ? Type.WIDE_COPY : Type.COPY),
			__a, __b);
	}
	
	/**
	 * Creates a counting operation.
	 *
	 * @param __a The register to count.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation count(int __a)
	{
		return new StateOperation(Type.COUNT, __a);
	}
	
	/**
	 * Creates a uncounting operation.
	 *
	 * @param __a The register to uncount.
	 * @return The operation.
	 * @since 2019/04/13
	 */
	public static final StateOperation uncount(int __a)
	{
		return new StateOperation(Type.UNCOUNT, __a);
	}
	
	/**
	 * Represents the type of operation to perform.
	 *
	 * @since 2019/04/11
	 */
	public static enum Type
	{
		/** Count. */
		COUNT,
		
		/** Un-count. */
		UNCOUNT,
		
		/** Copy. */
		COPY,
		
		/** Wide copy. */
		WIDE_COPY,
		
		/** End. */
		;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/StateOperations.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This represents multiple state operations.
 *
 * @since 2019/04/12
 */
public final class StateOperations
	implements Iterable<StateOperation>
{
	/** The operations. */
	private final StateOperation[] _ops;
	
	/** The hash. */
	private int _hash;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the state operations.
	 *
	 * @param __ops The operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperations(StateOperation... __ops)
		throws NullPointerException
	{
		for (StateOperation x : (__ops = (__ops == null ?
			new StateOperation[0] : __ops.clone())))
			if (x == null)
				throw new NullPointerException("NARG");
		
		this._ops = __ops;
	}
	
	/**
	 * Initializes the state operations.
	 *
	 * @param __ops The operations.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/12
	 */
	public StateOperations(Iterable<StateOperation> __ops)
		throws NullPointerException
	{
		if (__ops == null)
			throw new NullPointerException("NARG");
		
		List<StateOperation> out = new ArrayList<>();
		for (StateOperation x : __ops)
			if (x == null)
				throw new NullPointerException("NARG");
			else
				out.add(x);
		
		this._ops = out.<StateOperation>toArray(
			new StateOperation[out.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof StateOperations))
			return false;
		
		if (this.hashCode() != __o.hashCode())
			return false;
		
		return Arrays.equals(this._ops, ((StateOperations)__o)._ops);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = Arrays.asList(this._ops).hashCode());
		return rv;
	}
	
	/**
	 * Returns if this is empty is empty or not.
	 *
	 * @return If this is empty.
	 * @since 2019/04/12
	 */
	public final boolean isEmpty()
	{
		return this._ops.length <= 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final Iterator<StateOperation> iterator()
	{
		return UnmodifiableIterator.<StateOperation>of(this._ops);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/12
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				Arrays.asList(this._ops).toString()));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/__Debug__.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.classfile.xlate;

/**
 * Stores debug enabled flag.
 *
 * @since 2019/04/16
 */
final class __Debug__
{
	/** Debug enabled? */
	public static final boolean ENABLED;
	
	/**
	 * Gets the debug flag.
	 *
	 * @since 2019/04/16
	 */
	static
	{
		// Get property
		boolean en = false;
		try
		{
			// {@squirreljme.property dev.shadowtail.classfile.xlate.debug=pool
			// Sets whether the massive amounts of debug test should be
			// printed in all the translation codes.}
			en = Boolean.getBoolean("dev.shadowtail.classfile.xlate.debug");
		}
		catch (SecurityException e)
		{
		}
		
		// Set
		ENABLED = en;
	}
}

Deleted runt/libs/tool-classfile/dev/shadowtail/classfile/xlate/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains utilities which can be used to translate classes
 * and such. This package is something which hopefully would reduce the
 * complexity and code duplication through various translators and such.
 *
 * @since 2019/04/06
 */

package dev.shadowtail.classfile.xlate;

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AccessibleFlags.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which are associated with accessible objects to determine
 * if they can be accessed from one location to another.
 *
 * @since 2016/05/12
 */
public interface AccessibleFlags
{
	/**
	 * Is the current accessible object package private?
	 *
	 * @return {@code true} if package private.
	 * @since 2016/05/12
	 */
	public abstract boolean isPackagePrivate();
	
	/**
	 * Is the current accessible object private?
	 *
	 * @return {@code true} if private.
	 * @since 2016/05/12
	 */
	public abstract boolean isPrivate();
	
	/**
	 * Is the current accessible object protected?
	 *
	 * @return {@code true} if protected.
	 * @since 2016/05/12
	 */
	public abstract boolean isProtected();
	
	/**
	 * Is the current accessible object public?
	 *
	 * @return {@code true} if public.
	 * @since 2016/05/12
	 */
	public abstract boolean isPublic();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Annotated.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.List;

/**
 * This represents any element which has been annotated.
 *
 * @since 2018/03/06
 */
public interface Annotated
{
	/**
	 * Returns all of the annotations which have been specified for this.
	 *
	 * @return The annotated elements.
	 * @since 2018/03/06
	 */
	public abstract AnnotationTable annotationTable();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Annotation.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261





































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This represents an annotation which has values assigned to keys.
 *
 * @since 2018/06/16
 */
public final class Annotation
	implements AnnotationValue
{
	/** The type name of the annotation. */
	protected final ClassName typename;
	
	/** The values for the annotation. */
	private final Map<MethodName, AnnotationValue> _values =
		new LinkedHashMap<>();
	
	/**
	 * Initializes the annotation.
	 *
	 * @param __tn The type name to use.
	 * @param __vs The value mappings.
	 * @throws InvalidClassFormatException If an annotation key is duplicated.
	 * @throws NullPointerException On null arguments or if the value mappings
	 * contain a null value.
	 * @since 2018/09/01
	 */
	private Annotation(ClassName __tn, Map<MethodName, AnnotationValue> __vs)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__tn == null || __vs == null)
			throw new NullPointerException("NARG");
		
		this.typename = __tn;
		
		// Copy key and values over
		Map<MethodName, AnnotationValue> values = this._values;
		for (Map.Entry<MethodName, AnnotationValue> e : __vs.entrySet())
		{
			MethodName k = e.getKey();
			AnnotationValue v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException();
			
			// {@squirreljme.error JC1t Duplicate key within annotation. (The
			// key)}
			if (null != values.put(k, v))
				throw new InvalidClassFormatException(String.format(
					"JC1t %s", k));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the value for the given method name.
	 *
	 * @param __n The key to get the value for.
	 * @return The value of the given key.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public final AnnotationValue get(MethodName __n)
		throws NullPointerException
	{
		// Will never be found
		if (__n == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the key and value map.
	 *
	 * @return The key and value map.
	 * @since 2018/10/28
	 */
	public final Map<MethodName, AnnotationValue> keyValueMap()
	{
		return UnmodifiableMap.<MethodName, AnnotationValue>of(this._values);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the type of this annotation.
	 *
	 * @return The annotation type.
	 * @since 2018/06/16
	 */
	public final ClassName type()
	{
		return this.typename;
	}
	
	/**
	 * Decodes a single annotation from the input data stream and returns the
	 * parsed annotation.
	 *
	 * @param __pool The constant pool.
	 * @param __in The input stream to read from.
	 * @return The parsed annotation.
	 * @throws InvalidClassFormatException If the annotation is invalid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public static final Annotation parse(Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Read the type name, which is a class
		String rawtypename;
		ClassName typename = new FieldDescriptor((rawtypename = __pool.
			<UTFConstantEntry>get(UTFConstantEntry.class,
			__in.readUnsignedShort()).toString())).className();
		
		// {@squirreljme.error JC1u Annotation type is not correct. (The type)}
		if (typename == null)
			throw new InvalidClassFormatException(String.format("JC1u %s",
				rawtypename));
		
		// Read element table
		Map<MethodName, AnnotationValue> values = new LinkedHashMap<>();
		int n = __in.readUnsignedShort();
		for (int i = 0; i < n; i++)
			values.put(new MethodName(__pool.<UTFConstantEntry>get(
				UTFConstantEntry.class, __in.readUnsignedShort()).toString()),
				Annotation.parseValue(__pool, __in));
		
		return new Annotation(typename, values);
	}
	
	/**
	 * Parses a single annotation value.
	 *
	 * @param __pool The pool to read from.
	 * @param __in The input stream.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the value is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public static final AnnotationValue parseValue(Pool __pool,
		DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Read tag, which represents the type of things
		int tag = __in.readUnsignedByte();
		switch (tag)
		{
			case 'B':
			case 'C':
			case 'I':
			case 'S':
			case 'Z':
			case 'D':
			case 'F':
			case 'J':
				return new AnnotationValuePrimitive(
					__pool.<ConstantValueNumber>get(ConstantValueNumber.class,
					__in.readUnsignedShort()).number());
			
			case 's':
				return new AnnotationValueString(
					__pool.<ConstantValueString>get(ConstantValueString.class,
					__in.readUnsignedShort()).toString());
			
			case 'e':
				return new AnnotationValueEnum(
					new FieldDescriptor(__pool.<UTFConstantEntry>get(
						UTFConstantEntry.class, __in.readUnsignedShort()).
						toString()),
					new FieldName(__pool.<UTFConstantEntry>get(
						UTFConstantEntry.class, __in.readUnsignedShort()).
						toString()));
			
			case 'c':
				return new AnnotationValueClass(new FieldDescriptor(
					__pool.<UTFConstantEntry>get(UTFConstantEntry.class,
					__in.readUnsignedShort()).toString()));
			
			case '@':
				return Annotation.parse(__pool, __in);
			
			case '[':
				{
					// Read length
					int len = __in.readUnsignedShort();
					
					// Read in all values
					AnnotationValue[] values = new AnnotationValue[len];
					for (int i = 0; i < len; i++)
						values[i] = Annotation.parseValue(__pool, __in);
					
					// Build
					return new AnnotationValueArray(values);
				}
			
				// {@squirreljme.error JC1v Invalid tag specified in
				// annotation. (The tag used)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC1v %c", tag));
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationTable.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
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































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This contains the annotation table which stores all of the annotation
 * information. No visibility information is stored because that is not needed
 * in SquirrelJME either by the run-time or the compiler.
 *
 * @since 2018/05/15
 */
public final class AnnotationTable
	implements Iterable<Annotation>
{
	/** The annotations which have been declared. */
	private final Map<ClassName, Annotation> _annotations;
	
	/**
	 * Initializes the annotation table.
	 *
	 * @param __e The input annotations.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AnnotationTable(Annotation... __e)
		throws InvalidClassFormatException, NullPointerException
	{
		this(Arrays.<Annotation>asList((__e != null ? __e :
			new Annotation[0])));
	}
	
	/**
	 * Initializes the annotation table.
	 *
	 * @param __e The input annotations.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AnnotationTable(Iterable<Annotation> __e)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		Map<ClassName, Annotation> rv = new LinkedHashMap<>();
		for (Annotation e : __e)
		{
			// {@squirreljme.error JC1w Duplicate annotation declared. (The
			// declared annotation)}
			ClassName name = e.type();
			if (rv.containsKey(name))
				throw new InvalidClassFormatException(String.format("JC1w %s",
					name));
			
			rv.put(name, e);
		}
		
		this._annotations = rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final Iterator<Annotation> iterator()
	{
		return UnmodifiableIterator.<Annotation>of(
			this._annotations.values());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Decodes the visible and invisible annotations that may exist for a
	 * class, field, or method.
	 *
	 * @param __pool The constant pool.
	 * @param __attrs The input attributes.
	 * @return The parsed annotation values.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static final AnnotationTable parse(Pool __pool,
		AttributeTable __attrs)
		throws IOException, NullPointerException
	{
		if (__pool == null || __attrs == null)
			throw new NullPointerException("NARG");
		
		// Parse visible then invisible annotations
		List<Annotation> rv = new ArrayList<>();
		for (int z = 0; z < 2; z++)
			try (DataInputStream di = __attrs.open((z == 0 ?
				"RuntimeVisibleAnnotations" : "RuntimeInvisibleAnnotations")))
			{
				if (di != null)
				{
					int n = di.readUnsignedShort();
					for (int i = 0; i < n; i++)
						rv.add(Annotation.parse(__pool, di));
				}
			}
		
		return new AnnotationTable(rv);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValue.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface represents any class which is able to be used as a value for
 * a given annotation.
 *
 * @since 2018/06/16
 */
public interface AnnotationValue
{
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValueArray.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.AbstractList;
import java.util.List;
import java.util.RandomAccess;

/**
 * This represents an annotation value that is an array.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueArray
	extends AbstractList<AnnotationValue>
	implements AnnotationValue, List<AnnotationValue>, RandomAccess
{
	/** The elements of the array. */
	private final AnnotationValue[] _values;
	
	/**
	 * Initializes the values.
	 *
	 * @param __vs The input values.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueArray(AnnotationValue... __vs)
		throws NullPointerException
	{
		for (AnnotationValue v : (__vs = (__vs == null ?
			new AnnotationValue[0] : __vs.clone())))
			if (v == null)
				throw new NullPointerException("NARG");
		
		this._values = __vs;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final AnnotationValue get(int __i)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int size()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValueClass.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is an annotation value which represents a class.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueClass
	implements AnnotationValue
{
	/** The class name. */
	protected final FieldDescriptor name;
	
	/**
	 * Initializes the class annotation.
	 *
	 * @param __n The name used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueClass(FieldDescriptor __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValueEnum.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is an annotation value which represents an enumeration.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueEnum
	implements AnnotationValue
{
	/** The type name. */
	protected final FieldDescriptor type;
	
	/** The enum name. */
	protected final FieldName name;
	
	/**
	 * Initializes the annotation enumeration value.
	 *
	 * @param __type The type used.
	 * @param __name The name of the enumeration key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueEnum(FieldDescriptor __type, FieldName __name)
		throws NullPointerException
	{
		if (__type == null || __name == null)
			throw new NullPointerException("NARG");
		
		this.type = __type;
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValuePrimitive.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an annotation value that represents a primitive constant.
 *
 * @since 2018/06/16
 */
public final class AnnotationValuePrimitive
	extends Number
	implements AnnotationValue
{
	/** The represented number value. */
	protected final Number value;
	
	/**
	 * Initializes the primitive value.
	 *
	 * @param __v The value used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValuePrimitive(Number __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final double doubleValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final float floatValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int intValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final long longValue()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AnnotationValueString.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an annotation value which is a string.
 *
 * @since 2018/06/16
 */
public final class AnnotationValueString
	implements AnnotationValue
{
	/** The string value. */
	protected final String value;
	
	/**
	 * Initializes the string value.
	 *
	 * @param __v The value used
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/01
	 */
	public AnnotationValueString(String __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Attribute.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * This represents a single attribute which exists within a class.
 *
 * @since 2018/05/14
 */
public final class Attribute
{
	/** The attribute name. */
	protected final String name;
	
	/** The attribute data. */
	private final byte[] _data;
	
	/**
	 * Initializes the attribute.
	 *
	 * @param __name The name of the attribute.
	 * @param __b The data that makes up the attribute.
	 * @param __o The offset to the attribute data.
	 * @param __l The number of bytes in the attribute.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public Attribute(String __name, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__name == null || __b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
		
		this.name = __name;
		
		// Copy the array
		byte[] clone = new byte[__l];
		System.arraycopy(__b, __o, clone, 0, __l);
		this._data = clone;
	}
	
	/**
	 * Returns a copy of the attribute bytes.
	 *
	 * @return The attribute bytes.
	 * @since 2018/05/15
	 */
	public final byte[] bytes()
	{
		return this._data.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the name of the attribute.
	 *
	 * @return The attribute name.
	 * @since 2018/05/14
	 */
	public final String name()
	{
		return this.name;
	}
	
	/**
	 * Opens the attribute as a stream of bytes.
	 *
	 * @return A stream over the bytes of the attribute.
	 * @since 2018/05/14
	 */
	public final DataInputStream open()
	{
		return new DataInputStream(new ByteArrayInputStream(this._data));
	}
	
	/**
	 * Returns the size of the attribute.
	 *
	 * @return The attribute size.
	 * @since 2018/05/14
	 */
	public final int size()
	{
		return this._data.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/AttributeTable.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
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





























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This represents the attribute table that exists within a class.
 *
 * @since 2018/05/14
 */
public final class AttributeTable
{
	/** The attribute table. */
	private final Map<String, Attribute> _attributes;
	
	/**
	 * Initializes the attribute table.
	 *
	 * @param __a The input attributes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AttributeTable(Attribute... __a)
		throws NullPointerException
	{
		this(Arrays.<Attribute>asList((__a != null ? __a :
			new Attribute[0])));
	}
	
	/**
	 * Initializes the attribute table.
	 *
	 * @param __a The input attributes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public AttributeTable(Iterable<Attribute> __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		Map<String, Attribute> attributes = new LinkedHashMap<>();
		for (Attribute a : __a)
		{
			if (a == null)
				throw new NullPointerException("NARG");
			
			String n = a.name();
			if (!attributes.containsKey(n))
				attributes.put(n, a);
		}
		this._attributes = attributes;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the attribute that uses the specified name.
	 *
	 * @param __n The name of the attribute to get.
	 * @return The specified attribute or {@code null} if it does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public final Attribute get(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		return this._attributes.get(__n);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Opens the attribute by the specified key.
	 *
	 * @param __n The name of the attribute to open.
	 * @return The stream to the given attribute or {@code null} if it is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public final DataInputStream open(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		Attribute a = this.get(__n);
		if (a == null)
			return null;
		return a.open();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the length of the attribute table.
	 *
	 * @return The attribute table length.
	 * @since 2018/05/14
	 */
	public final int size()
	{
		return this._attributes.size();
	}
	
	/**
	 * Parses the attribute table.
	 *
	 * @param __in The input stream.
	 * @param __pool The constant pool.
	 * @return The attribute table.
	 * @throws InvalidClassFormatException If the table is not correct.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static AttributeTable parse(Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__in == null || __pool == null)
			throw new NullPointerException("NARG");
		
		int n = __in.readUnsignedShort();
		Attribute[] rv = new Attribute[n];
		
		// Read each entry
		for (int i = 0; i < n; i++)
		{
			String name = __pool.<UTFConstantEntry>require(
				UTFConstantEntry.class, __in.readUnsignedShort()).toString();
			
			// {@squirreljme.error JC1x Attributes with a size larger than two
			// gigabytes are not supported.}
			int len = __in.readInt();
			if (len < 0)
				throw new InvalidClassFormatException("JC1x");
			
			byte[] data = new byte[len];
			__in.readFully(data);
			
			rv[i] = new Attribute(name, data, 0, len);
		}
		
		return new AttributeTable(rv);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/BinaryName.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
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




























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This represents a binary name which consists of a class which is
 * separted internally by forwarded slashes.
 *
 * @since 2017/09/27
 */
public final class BinaryName
	implements Comparable<BinaryName>
{
	/** The identifiers in the name. */
	private final ClassIdentifier[] _identifiers;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** The package this is in. */
	private Reference<BinaryName> _package;
	
	/**
	 * Initializes the binary name.
	 *
	 * @param __n The name to initialize.
	 * @throws InvalidClassFormatException If the binary name is valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public BinaryName(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Split
		List<ClassIdentifier> id = new ArrayList<>();
		for (int i = 0, n = __n.length(); i < n;)
		{
			// Identifiers are always split by forward slashes like UNIX
			// paths
			int ns = __n.indexOf('/', i);
			if (ns < 0)
				ns = n;
			
			// Split in
			id.add(new ClassIdentifier(__n.substring(i, ns)));
			
			// Skip
			i = ns + 1;
		}
		
		this._identifiers = id.<ClassIdentifier>toArray(
			new ClassIdentifier[id.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int compareTo(BinaryName __o)
	{
		ClassIdentifier[] a = this._identifiers,
			b = __o._identifiers;
		
		// Compare lengths first
		int an = a.length,
			bn = b.length;
		int rv = an - bn;
		if (rv != 0)
			return rv;
		
		// Then individual units
		for (int i = 0; i < an; i++)
		{
			ClassIdentifier x = a[i],
				y = b[i];
			
			rv = x.compareTo(y);
			if (rv != 0)
				return rv;
		}
		
		// Matches
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof BinaryName))
			return false;
		
		BinaryName o = (BinaryName)__o;
		return Arrays.equals(this._identifiers, o._identifiers);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int hashCode()
	{
		int rv = 0;
		for (ClassIdentifier i : this._identifiers)
			rv ^= i.hashCode();
		return rv;
	}
	
	/**
	 * Returns the binary name of the package this class is within.
	 *
	 * @return The binary name of the owning package.
	 * @since 2017/10/09
	 */
	public BinaryName inPackage()
	{
		Reference<BinaryName> ref = this._package;
		BinaryName rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			ClassIdentifier[] identifier = this._identifiers;
			
			for (int i = 0, n = identifier.length - 1; i < n; i++)
			{
				if (i > 0)
					sb.append('/');
				sb.append(identifier[i]);
			}
			
			this._package = new WeakReference<>(
				(rv = new BinaryName(sb.toString())));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			
			for (ClassIdentifier i : this._identifiers)
			{
				if (sb.length() > 0)
					sb.append('/');
				sb.append(i.identifier());
			}
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ByteCode.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This class represents the byte code within a method.
 *
 * @since 2017/10/09
 */
public final class ByteCode
	implements Iterable<Instruction>
{
	/** The code is always at this offset. */
	static final int _CODE_OFFSET =
		8;
	
	/** The maximum number of bytes the byte code may be. */
	private static final int _MAX_CODE_LENGTH =
		65535;
	
	/** The maximum number of stack entries. */
	protected final int maxstack;
	
	/** The maximum number of local entries. */
	protected final int maxlocals;
	
	/** The length of the method code in bytes. */
	protected final int codelen;
	
	/** The constant pool. */
	protected final Pool pool;
	
	/** The exceptions within this method. */
	protected final ExceptionHandlerTable exceptions;
	
	/** This type. */
	protected final ClassName thistype;
	
	/** The name of this method. */
	protected final MethodName methodname;
	
	/** Method type. */
	protected final MethodDescriptor methodtype;
	
	/** Is this method synchronized? */
	protected final boolean issynchronized;
	
	/** Is this an instance method? */
	protected final boolean isinstance;
	
	/** The input attribute code, used for instruction lookup. */
	private final byte[] _rawattributedata;
	
	/** The stack map table data. */
	private final byte[] _smtdata;
	
	/** Is the stack map table data new? */
	private final boolean _newsmtdata;
	
	/** The owning method reference. */
	private final Reference<Method> _methodref;
	
	/** Instruction lengths at each position. */
	private final int[] _lengths;
	
	/** The addresses of every instruction by index. */
	private final int[] _index;
	
	/** The line number table. */
	private final short[] _linenumbertable;
	
	/** The cache of instructions in the byte code. */
	private final Reference<Instruction>[] _icache;
	
	/** String representation of this byte code */
	private Reference<String> _string;
	
	/** The stack map table cache. */
	private Reference<StackMapTable> _smt;
	
	/**
	 * Initializes the byte code.
	 *
	 * @param __mr The owning method reference.
	 * @param __ca The raw code attribute data.
	 * @param __tt The this type.
	 * @param __mf Method flags.
	 * @throws InvalidClassFormatException If the byte code is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	ByteCode(Reference<Method> __mr, byte[] __ca, ClassName __tt,
		MethodFlags __mf)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__mr == null || __ca == null || __tt == null || __mf == null)
			throw new NullPointerException("NARG");
		
		// Needed
		Method method = __mr.get();
		
		// Set
		this._methodref = __mr;
		this._rawattributedata = __ca;
		this.issynchronized = __mf.isSynchronized();
		this.isinstance = !__mf.isStatic();
		
		// Is this an initializer method?
		this.methodname = method.name();
		this.methodtype = method.type();
		
		// If any IOExceptions are generated then the attribute is not valid
		Pool pool = method.pool();
		try (DataInputStream in = new DataInputStream(
			new ByteArrayInputStream(__ca)))
		{
			// The number of variables allocated to the method
			int maxstack = in.readUnsignedShort(),
				maxlocals = in.readUnsignedShort();
				
			// {@squirreljme.error JC1y The specified code length is not valid.
			// (The code length)}
			int codelen = in.readInt();
			if (codelen <= 0 || codelen > _MAX_CODE_LENGTH)
				throw new InvalidClassFormatException(
					String.format("JC1y %d", codelen));
		
			// Ignore that many bytes
			for (int i = 0; i < codelen; i++)
				in.readByte();
			
			// Read exception handler table
			ExceptionHandlerTable eht = ExceptionHandlerTable.decode(in, pool,
				codelen);
			
			// The instruction index is used to lookup using a linear index
			// count rather than the potentially spaced out address lookup
			int[] index = new int[codelen];
			int indexat = 0;
		
			// Set all lengths initially to invalid positions, this used as a
			// quick marker to determine which positions have valid
			// instructions
			int[] lengths = new int[codelen];
			for (int i = 0; i < codelen; i++)
				lengths[i] = -1;
		
			// Determine instruction lengths for each position
			int[] ollastop = new int[]{-1};
			for (int i = 0, li = -1; i < codelen; li = i)
			{
				// Store address of instruction for an index based lookup
				index[indexat++] = i;
			
				// Store length
				int oplen;
				lengths[i] = (oplen = __opLength(__ca, i, ollastop));
			
				// {@squirreljme.error JC1z The operation exceeds the bounds of
				// the method byte code. (The operation pointer; The operation
				// length; The code length; The last operation pointer)}
				if ((i += oplen) > codelen)
					throw new InvalidClassFormatException(
						String.format("JC1z %d %d %d", i, oplen, codelen, li));
			}
			
			// The stack map table is used for verification
			byte[] smt = null;
			boolean smtnew = false;
			
			// Parse the attribute table
			AttributeTable attrs = AttributeTable.parse(pool, in);
			
			// Try using the newer stack map table, if that does not exist
			// then fallback to the old one
			Attribute attr = attrs.get("StackMapTable");
			if (attr != null)
			{
				smt = attr.bytes();
				smtnew = true;
			}
			else
			{
				attr = attrs.get("StackMap");
				if (attr != null)
				{
					smt = attr.bytes();
					smtnew = false;
				}
			}
			
			// If there is no stack map, then use a default one (which has
			// just no entries) which has an assumed state
			if (smt == null)
			{
				smt = new byte[2];
				smtnew = true;
			}
			
			// Initialize a blank line number table
			short[] lnt = new short[codelen];
			for (int i = 0; i < codelen; i++)
				lnt[i] = -1;
			
			// Parse the line number table for debug purposes
			attr = attrs.get("LineNumberTable");
			if (attr != null)
				try (DataInputStream ai = attr.open())
				{
					// Read entry count
					int n = ai.readUnsignedShort();
					
					// Read all the individual entries
					for (int i = 0; i < n; i++)
					{
						int pc = ai.readUnsignedShort(),
							line = ai.readUnsignedShort();
						
						// Failed to read the program address, this could be
						// a failure but instead just ignore it and continue
						// on
						if (pc < 0 || pc >= codelen)
							continue;
						
						// This gets handled later, but if there is more than
						// 65534 lines in a file then what is the programmer
						// even doing
						lnt[pc] = (short)line;
					}
				}
			
			// Can set fields now
			this.maxstack = maxstack;
			this.maxlocals = maxlocals;
			this.codelen = codelen;
			this.exceptions = eht;
			this.pool = pool;
			this.thistype = __tt;
			this._smtdata = smt;
			this._newsmtdata = smtnew;
			this._lengths = lengths;
			this._icache = __newCache(codelen);
			this._linenumbertable = lnt;
			
			// Store addresses for all the indexes
			if (indexat == codelen)
				this._index = index;
			else
				this._index = Arrays.copyOf(index, indexat);
		}
		
		// {@squirreljme.error JC20 Failed to read from the code attribute.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC20", e);
		}
	}
	
	/**
	 * Returns the address of the instruction following the specified one.
	 *
	 * @param __a The following address.
	 * @return The instruction address following the instruction at the
	 * specified address.
	 * @throws JITExcepInvalidClassFormatExceptiontion If the specified address
	 * is not valid.
	 * @since 2017/05/20
	 */
	public int addressFollowing(int __a)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC21 The instruction at the specified address is
		// not valid. (The address)}
		if (!isValidAddress(__a))
			throw new InvalidClassFormatException(
				String.format("JC21 %d", __a));
		
		return __a + this._lengths[__a];
	}
	
	/**
	 * Translates an address to an index.
	 *
	 * @param __a The address to translate.
	 * @return The index of the instruction or {@code -1} if it is not valid,
	 * if the address is the byte code length then the number of indexes is
	 * returned.
	 * @since 2017/08/02
	 */
	public int addressToIndex(int __a)
	{
		// Byte right at the end converts to the last index
		int[] index = this._index;
		if (__a == this.codelen)
			return index.length;
		
		// Not the end
		int rv = Arrays.binarySearch(index, __a);
		if (rv < 0)
			return -1;
		return rv;
	}
	
	/**
	 * Returns the exception handler table.
	 *
	 * @return The exception handler table.
	 * @since 2018/10/13
	 */
	public final ExceptionHandlerTable exceptions()
	{
		return this.exceptions;
	}
	
	/**
	 * Returns the instruction at the specified address.
	 *
	 * @param __a The address to get the instruction for.
	 * @return The represented instruction for the given address.
	 * @throws InvalidClassFormatException If the address is not valid.
	 * @since 2017/05/18
	 */
	public Instruction getByAddress(int __a)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC22 The instruction at the specified address is
		// not valid. (The address)}
		if (!isValidAddress(__a))
			throw new InvalidClassFormatException(
				String.format("JC22 %d", __a));
		
		Reference<Instruction>[] icache = this._icache;
		Reference<Instruction> ref = icache[__a];
		Instruction rv;
		
		if (ref == null || null == (rv = ref.get()))
			icache[__a] = new WeakReference<>((rv = new Instruction(
				this._rawattributedata, this.pool, __a, this.exceptions,
				stackMapTable(), this.addressFollowing(__a))));
		
		return rv;
	}
	
	/**
	 * Returns the instruction based on an index in the order it appears within
	 * the byte code rather than by address.
	 *
	 * @param __i The instruction index to get.
	 * @return The instruction at this index.
	 * @throws IndexOutOfBoundsException If the index is not within bounds.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @since 2017/08/01
	 */
	public Instruction getByIndex(int __i)
		throws IndexOutOfBoundsException
	{
		// Check
		int[] index = this._index;
		if (__i < 0 || __i >= index.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		return getByAddress(index[__i]);
	}
	
	/**
	 * Translates an index to an address.
	 *
	 * @param __i The index to translate.
	 * @return The address of the index or {@code -1} if it is not valid, if
	 * the index is the number of indexes then the length of the byte code in
	 * addresses is returned.
	 * @since 2017/08/02
	 */
	public int indexToAddress(int __i)
	{
		// Last index translates to the length of the byte code
		int[] index = this._index;
		int n = index.length;
		if (__i == n)
			return this.codelen;
		
		// Normal position
		if (__i < 0 || __i >= n)
			return -1;
		return index[__i];
	}
	
	/**
	 * Returns the number of instructions which are within this method.
	 *
	 * @return The number of instructions which are in the method.
	 * @since 2017/08/01
	 */
	public int instructionCount()
	{
		return this._index.length;
	}
	
	/**
	 * This returns an iterator over the instructions which are defined within
	 * this method.
	 *
	 * @return The iterator over byte code instructions.
	 * @since 2017/05/20
	 */
	public Iterator<Instruction> instructionIterator()
	{
		return new __InstructionIterator__();
	}
	
	/**
	 * Returns if this is an instance or not.
	 *
	 * @return If this is an instance.
	 * @since 2019/04/26
	 */
	public final boolean isInstance()
	{
		return this.isinstance;
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2019/03/24
	 */
	public final boolean isInstanceInitializer()
	{
		return this.methodname.isInstanceInitializer();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2019/03/24
	 */
	public final boolean isStaticInitializer()
	{
		return this.methodname.isStaticInitializer();
	}
	
	/**
	 * Is this method synchronized?
	 *
	 * @return If this is synchronized.
	 * @since 2019/04/26
	 */
	public final boolean isSynchronized()
	{
		return this.issynchronized;
	}
	
	/**
	 * Checks whether the given address is a valid instruction address.
	 *
	 * @param __a The address to check.
	 * @return {@code true} if the address is valid.
	 * @since 2017/05/18
	 */
	public boolean isValidAddress(int __a)
	{
		// Out of range
		if (__a < 0 || __a >= this.codelen)
			return false;
		
		// Has to have a positive non-zero length
		return (this._lengths[__a] > 0);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/17
	 */
	@Override
	public final Iterator<Instruction> iterator()
	{
		return this.instructionIterator();
	}
	
	/**
	 * Returns the jump targets for this byte code.
	 *
	 * @return The jump targets.
	 * @since 2019/03/30
	 */
	public final Map<Integer, InstructionJumpTargets> jumpTargets()
	{
		Map<Integer, InstructionJumpTargets> rv = new LinkedHashMap<>();
		
		// Just fill addresses with instruction info
		for (Instruction i : this)
			rv.put(i.address(), i.jumpTargets());
		
		return rv;
	}
	
	/**
	 * Returns the length of the byte code.
	 *
	 * @return The byte code length.
	 * @since 2017/05/20
	 */
	public int length()
	{
		return this.codelen;
	}
	
	/**
	 * Returns the line that the address is on, assuming the address is valid
	 * and there is line number information available.
	 *
	 * @param __a The address to lookup.
	 * @return The line of the address or a negative value if it is not valid
	 * or it is unknown.
	 * @since 2018/09/08
	 */
	public final int lineOfAddress(int __a)
	{
		// Scan through the table and try to find the line number for the given
		// address, the table is negative padded for unknown locations
		int codelen = this.codelen;
		short[] linenumbertable = this._linenumbertable;
		int negscandx = __a;
		for (int pc = __a; pc >= 0 && pc < codelen; pc--)
		{
			// Do not use this value if the line is not valid, scan backwards
			short clip = linenumbertable[pc];
			if (clip == -1)
				continue;
			
			// If the address we started at is not valid then a bunch of source
			// code is probably on the same line for a bunch of area so to
			// prevent any extra backscanning when this information is needed
			// cache it back into the table so it is used
			// Fill the entire table to our PC address so that way the entire
			// section is filled
			while (negscandx > pc)
				linenumbertable[negscandx--] = clip;
			
			// Sign extends to int, then removes the negative part so we can
			// recover the full 0-65534 range of the line table
			return (clip & 0xFFFF);
		}
		
		// Not known
		return -1;
	}
	
	/**
	 * Returns the maximum number of locals.
	 *
	 * @return The maximum number of locals.
	 * @since 2017/05/20
	 */
	public int maxLocals()
	{
		return this.maxlocals;
	}
	
	/**
	 * Returns the maximum size of the stack.
	 *
	 * @return The maximum stack size.
	 * @since 2017/05/20
	 */
	public int maxStack()
	{
		return this.maxstack;
	}
	
	/**
	 * Returns the name of this method.
	 *
	 * @return The method name.
	 * @since 2019/04/22
	 */
	public final MethodName name()
	{
		return this.methodname;
	}
	
	/**
	 * Returns the constant pool being used.
	 *
	 * @return The constant pool the method uses.
	 * @since 2017/05/20
	 */
	public Pool pool()
	{
		return this.pool;
	}
	
	/**
	 * Reads an unsigned short from the raw byte code at the given address.
	 *
	 * @param __addr The address to read from.
	 * @return The read unsigned short.
	 * @throws IndexOutOfBoundsException If the address is out of bounds.
	 * @since 2018/09/28
	 */
	public final int readRawCodeUnsignedShort(int __addr)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error JC23 Out of bounds read of unsigned short from
		// raw byte code. (The address)}
		if (__addr < 0 || __addr >= this.codelen - 1)
			throw new IndexOutOfBoundsException(
				String.format("JC23 %d", __addr));
		
		byte[] rad = this._rawattributedata;
		int d = __addr + ByteCode._CODE_OFFSET;
		return ((rad[d] & 0xFF) << 8) |
			(rad[d + 1] & 0xFF);
	}
	
	/**
	 * Returns the reverse jump targets, this essentially specifies the
	 * instructions and exception handlers at given points jump to the
	 * key addresses.
	 *
	 * @return The reverse jump targets.
	 * @since 2019/03/30
	 */
	public final Map<Integer, InstructionJumpTargets> reverseJumpTargets()
	{
		// Get the original jump table
		Map<Integer, InstructionJumpTargets> jumpmap = this.jumpTargets();
		
		// The target jump table has both normals and exceptions so it must
		// remember that state accordingly
		class Working
		{
			Set<InstructionJumpTarget> normal =
				new LinkedHashSet<>();
			
			Set<InstructionJumpTarget> exception =
				new LinkedHashSet<>();
		}
		Map<Integer, Working> works = new LinkedHashMap<>();
		
		// Go through all the original jump targets and add them
		for (Map.Entry<Integer, InstructionJumpTargets> e : jumpmap.entrySet())
		{
			InstructionJumpTarget addr = new InstructionJumpTarget(e.getKey());
			InstructionJumpTargets jumps = e.getValue();
			
			for (int i = 0, n = jumps.size(); i < n; i++)
			{
				int targ = jumps.get(i).target();
				boolean isex = jumps.isException(i);
				
				// Create work if missing
				Working work = works.get(targ);
				if (work == null)
					works.put(targ, (work = new Working()));
				
				// Add
				if (isex)
					work.exception.add(addr);
				else
					work.normal.add(addr);
			}
		}
		
		// Finalize for returning
		Map<Integer, InstructionJumpTargets> rv = new LinkedHashMap<>();
		for (Map.Entry<Integer, Working> e : works.entrySet())
		{
			Working work = e.getValue();
			Set<InstructionJumpTarget> nrm = work.normal,
				exe = work.exception;
			
			// Convert
			rv.put(e.getKey(), new InstructionJumpTargets(
				nrm.<InstructionJumpTarget>toArray(
					new InstructionJumpTarget[nrm.size()]),
				exe.<InstructionJumpTarget>toArray(
					new InstructionJumpTarget[exe.size()])));
		}
		
		return rv;
	}
	
	/**
	 * Returns the stack map table.
	 *
	 * @return The stack map table.
	 * @since 2017/10/15
	 */
	public StackMapTable stackMapTable()
	{
		Reference<StackMapTable> ref = this._smt;
		StackMapTable rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._smt = new WeakReference<>(rv = new __StackMapParser__(
				this.pool, __method(), this._newsmtdata, this._smtdata,
				this, new JavaType(this.thistype)).get());
		
		return rv;
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The current class name.
	 * @since 2019/03/24
	 */
	public final ClassName thisType()
	{
		return this.thistype;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("[");
			
			// Fill in instructions
			boolean comma = false;
			for (Iterator<Instruction> it = instructionIterator();
				it.hasNext();)
			{
				if (comma)
					sb.append(", ");
				else
					comma = true;
				
				sb.append(it.next());
			}
			
			sb.append(']');
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Returns the method type.
	 *
	 * @return The method type.
	 * @since 2019/04/22
	 */
	public final MethodDescriptor type()
	{
		return this.methodtype;
	}
	
	/**
	 * Returns all of the local variables which are written to.
	 *
	 * @return The local variables which are written to.
	 * @since 2019/03/30
	 */
	public final int[] writtenLocals()
	{
		Set<Integer> written = new LinkedHashSet<>();
		
		// Go through all instructions and count anything which is written to
		for (Instruction inst : this)
		{
			// Anything which is wide hits the adjacent local as well
			boolean wide = false;
			
			// Only specific instructions will do so
			int hit, op;
			switch ((op = inst.operation()))
			{
				case InstructionIndex.ASTORE:
				case InstructionIndex.WIDE_ASTORE:
					hit = inst.intArgument(0);
					break;
				
				case InstructionIndex.ASTORE_0:
				case InstructionIndex.ASTORE_1:
				case InstructionIndex.ASTORE_2:
				case InstructionIndex.ASTORE_3:
					hit = op - InstructionIndex.ASTORE_0;
					break;
				
				case InstructionIndex.DSTORE:
				case InstructionIndex.WIDE_DSTORE:
					hit = inst.intArgument(0);
					wide = true;
					break;
				
				case InstructionIndex.DSTORE_0:
				case InstructionIndex.DSTORE_1:
				case InstructionIndex.DSTORE_2:
				case InstructionIndex.DSTORE_3:
					hit = op - InstructionIndex.DSTORE_0;
					wide = true;
					break;
				
				case InstructionIndex.FSTORE:
				case InstructionIndex.WIDE_FSTORE:
					hit = inst.intArgument(0);
					break;
				
				case InstructionIndex.FSTORE_0:
				case InstructionIndex.FSTORE_1:
				case InstructionIndex.FSTORE_2:
				case InstructionIndex.FSTORE_3:
					hit = op - InstructionIndex.FSTORE_0;
					break;
				
				case InstructionIndex.IINC:
				case InstructionIndex.WIDE_IINC:
					hit = inst.intArgument(0);
					break;
				
				case InstructionIndex.ISTORE:
				case InstructionIndex.WIDE_ISTORE:
					hit = inst.intArgument(0);
					break;
				
				case InstructionIndex.ISTORE_0:
				case InstructionIndex.ISTORE_1:
				case InstructionIndex.ISTORE_2:
				case InstructionIndex.ISTORE_3:
					hit = op - InstructionIndex.ISTORE_0;
					break;
				
				case InstructionIndex.LSTORE:
				case InstructionIndex.WIDE_LSTORE:
					hit = inst.intArgument(0);
					wide = true;
					break;
				
				case InstructionIndex.LSTORE_0:
				case InstructionIndex.LSTORE_1:
				case InstructionIndex.LSTORE_2:
				case InstructionIndex.LSTORE_3:
					hit = op - InstructionIndex.LSTORE_0;
					wide = true;
					break;
				
				default:
					continue;
			}
			
			// Set local as being written to, handle wides as well
			written.add(hit);
			if (wide)
				written.add(hit + 1);
		}
		
		// Convert to array
		Integer[] from = written.<Integer>toArray(new Integer[written.size()]);
		int n = from.length;
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = from[i];
		return rv;
	}
	
	/**
	 * Returns the method which owns this byte code.
	 *
	 * @return The owning method.
	 * @since 2017/10/15
	 */
	private final Method __method()
	{
		// {@squirreljme.error JC24 The method owning this byte code has been
		// garbage collected.}
		Method rv = this._methodref.get();
		if (rv == null)
			throw new IllegalStateException("JC24");
		return rv;
	}
	
	/**
	 * Initializes a new cache array.
	 *
	 * @param __l The length of the array.
	 * @return The cache array.
	 * @since 2017/05/18
	 */
	@SuppressWarnings({"unchecked"})
	private static Reference<Instruction>[] __newCache(int __l)
	{
		return (Reference<Instruction>[])((Object)new Reference[__l]);
	}
	
	/**
	 * Returns the length of the operation at the given address.
	 *
	 * @param __code The method byte code.
	 * @param __a The address of the instruction to get the length of.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/17
	 */
	private static int __opLength(byte[] __code, int __a, int[] __last)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__code == null)
			throw new NullPointerException("NARG");
		
		// Base instruction length is always 1
		int rv = 1;
		
		// Real offset, since the code attribute is offset
		int aa = __a + _CODE_OFFSET;
		
		// Read operation
		int op = (__code[aa] & 0xFF);
		if (op == InstructionIndex.WIDE)
		{
			// {@squirreljme.error JC25 The wide instruction cannot be the
			// last instruction in a method. (The address)}
			if (aa + 1 >= __code.length)
				throw new InvalidClassFormatException(
					String.format("JC25 %d", __a));
			
			op = (op << 8) | (__code[aa + 1] & 0xFF);
			rv = 2;
		}
		
		// Depends on the operation
		switch (op)
		{
				// {@squirreljme.error JC26 Unsupported instruction specified
				// in the method byte code. (The operation; The address)}
			case InstructionIndex.BREAKPOINT:
			case InstructionIndex.IMPDEP1:
			case InstructionIndex.IMPDEP2:
			case InstructionIndex.JSR:
			case InstructionIndex.JSR_W:
			case InstructionIndex.RET:
			case InstructionIndex.WIDE:
				throw new InvalidClassFormatException(
					String.format("JC26 %d %d", op, __a));
			
				// {@squirreljme.error JC27 Invokedynamic is not supported in
				// this virtual machine. (The address)}
			case InstructionIndex.INVOKEDYNAMIC:
				throw new InvalidClassFormatException(
					String.format("JC27 %d", __a));
				
				// Operands with no arguments
			case InstructionIndex.AALOAD:
			case InstructionIndex.AASTORE:
			case InstructionIndex.ACONST_NULL:
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
			case InstructionIndex.ARETURN:
			case InstructionIndex.ARRAYLENGTH:
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
			case InstructionIndex.ATHROW:
			case InstructionIndex.BALOAD:
			case InstructionIndex.BASTORE:
			case InstructionIndex.CALOAD:
			case InstructionIndex.CASTORE:
			case InstructionIndex.D2F:
			case InstructionIndex.D2I:
			case InstructionIndex.D2L:
			case InstructionIndex.DADD:
			case InstructionIndex.DALOAD:
			case InstructionIndex.DASTORE:
			case InstructionIndex.DCMPG:
			case InstructionIndex.DCMPL:
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
			case InstructionIndex.DDIV:
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
			case InstructionIndex.DMUL:
			case InstructionIndex.DNEG:
			case InstructionIndex.DREM:
			case InstructionIndex.DRETURN:
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
			case InstructionIndex.DSUB:
			case InstructionIndex.DUP:
			case InstructionIndex.DUP2:
			case InstructionIndex.DUP2_X1:
			case InstructionIndex.DUP2_X2:
			case InstructionIndex.DUP_X1:
			case InstructionIndex.DUP_X2:
			case InstructionIndex.F2D:
			case InstructionIndex.F2I:
			case InstructionIndex.F2L:
			case InstructionIndex.FADD:
			case InstructionIndex.FALOAD:
			case InstructionIndex.FASTORE:
			case InstructionIndex.FCMPG:
			case InstructionIndex.FCMPL:
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
			case InstructionIndex.FDIV:
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
			case InstructionIndex.FMUL:
			case InstructionIndex.FNEG:
			case InstructionIndex.FREM:
			case InstructionIndex.FRETURN:
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
			case InstructionIndex.FSUB:
			case InstructionIndex.I2B:
			case InstructionIndex.I2C:
			case InstructionIndex.I2D:
			case InstructionIndex.I2F:
			case InstructionIndex.I2L:
			case InstructionIndex.I2S:
			case InstructionIndex.IADD:
			case InstructionIndex.IALOAD:
			case InstructionIndex.IAND:
			case InstructionIndex.IASTORE:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.IDIV:
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
			case InstructionIndex.IMUL:
			case InstructionIndex.INEG:
			case InstructionIndex.IOR:
			case InstructionIndex.IREM:
			case InstructionIndex.IRETURN:
			case InstructionIndex.ISHL:
			case InstructionIndex.ISHR:
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
			case InstructionIndex.ISUB:
			case InstructionIndex.IUSHR:
			case InstructionIndex.IXOR:
			case InstructionIndex.L2D:
			case InstructionIndex.L2F:
			case InstructionIndex.L2I:
			case InstructionIndex.LADD:
			case InstructionIndex.LALOAD:
			case InstructionIndex.LAND:
			case InstructionIndex.LASTORE:
			case InstructionIndex.LCMP:
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
			case InstructionIndex.LDIV:
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
			case InstructionIndex.LMUL:
			case InstructionIndex.LNEG:
			case InstructionIndex.LOR:
			case InstructionIndex.LREM:
			case InstructionIndex.LRETURN:
			case InstructionIndex.LSHL:
			case InstructionIndex.LSHR:
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
			case InstructionIndex.LSUB:
			case InstructionIndex.LUSHR:
			case InstructionIndex.LXOR:
			case InstructionIndex.MONITORENTER:
			case InstructionIndex.MONITOREXIT:
			case InstructionIndex.NOP:
			case InstructionIndex.POP:
			case InstructionIndex.POP2:
			case InstructionIndex.RETURN:
			case InstructionIndex.SALOAD:
			case InstructionIndex.SASTORE:
			case InstructionIndex.SWAP:
				break;
				
				// An additional byte
			case InstructionIndex.ALOAD:
			case InstructionIndex.ASTORE:
			case InstructionIndex.BIPUSH:
			case InstructionIndex.DLOAD:
			case InstructionIndex.DSTORE:
			case InstructionIndex.FLOAD:
			case InstructionIndex.FSTORE:
			case InstructionIndex.ILOAD:
			case InstructionIndex.ISTORE:
			case InstructionIndex.LDC:
			case InstructionIndex.LLOAD:
			case InstructionIndex.LSTORE:
			case InstructionIndex.NEWARRAY:
				rv++;
				break;
				
				// Operations with two bytes following
			case InstructionIndex.ANEWARRAY:
			case InstructionIndex.CHECKCAST:
			case InstructionIndex.GETFIELD:
			case InstructionIndex.GETSTATIC:
			case InstructionIndex.GOTO:
			case InstructionIndex.IF_ACMPEQ:
			case InstructionIndex.IF_ACMPNE:
			case InstructionIndex.IFEQ:
			case InstructionIndex.IFGE:
			case InstructionIndex.IFGT:
			case InstructionIndex.IF_ICMPEQ:
			case InstructionIndex.IF_ICMPGE:
			case InstructionIndex.IF_ICMPGT:
			case InstructionIndex.IF_ICMPLE:
			case InstructionIndex.IF_ICMPLT:
			case InstructionIndex.IF_ICMPNE:
			case InstructionIndex.IFLE:
			case InstructionIndex.IFLT:
			case InstructionIndex.IFNE:
			case InstructionIndex.IFNONNULL:
			case InstructionIndex.IFNULL:
			case InstructionIndex.IINC:
			case InstructionIndex.INSTANCEOF:
			case InstructionIndex.INVOKESPECIAL:
			case InstructionIndex.INVOKESTATIC:
			case InstructionIndex.INVOKEVIRTUAL:
			case InstructionIndex.LDC2_W:
			case InstructionIndex.LDC_W:
			case InstructionIndex.NEW:
			case InstructionIndex.PUTFIELD:
			case InstructionIndex.PUTSTATIC:
			case InstructionIndex.SIPUSH:
			case InstructionIndex.WIDE_ALOAD:
			case InstructionIndex.WIDE_ASTORE:
			case InstructionIndex.WIDE_DLOAD:
			case InstructionIndex.WIDE_DSTORE:
			case InstructionIndex.WIDE_FLOAD:
			case InstructionIndex.WIDE_FSTORE:
			case InstructionIndex.WIDE_ILOAD:
			case InstructionIndex.WIDE_ISTORE:
			case InstructionIndex.WIDE_LLOAD:
			case InstructionIndex.WIDE_LSTORE:
				rv += 2;
				break;
				
				// Three bytes
			case InstructionIndex.INVOKEINTERFACE:
			case InstructionIndex.MULTIANEWARRAY:
				rv += 3;
				break;
				
				// Four bytes
			case InstructionIndex.GOTO_W:
			case InstructionIndex.WIDE_IINC:
				rv += 4;
				break;
			
				// Table switch, the length of this instruction varies due to
				// alignment and the count contained within
			case InstructionIndex.TABLESWITCH:
				//             tusaddr +4    +8
			    // +0          +4      +8    +12    [+16x4         ]...
				// op  x  x  x default lowdx highdx [(highdx-lowdx)]...
				//    op  x  x default lowdx highdx [(highdx-lowdx)]...
				//       op  x default lowdx highdx [(highdx-lowdx)]...
				//          op default lowdx highdx [(highdx-lowdx)]...
				// tuspadlen includes the opcode
				int tusaddr = ((aa + 4) & (~3)),
					tuspadlen = tusaddr - aa;
				rv = tuspadlen + 12 + (4 *
					(Instruction.__readInt(__code, tusaddr + 8) -
					Instruction.__readInt(__code, tusaddr + 4) + 1));
				break;
				
				// Lookup switch, the length of this instruction varies due to
				// alignment and the number of contained entries.
			case InstructionIndex.LOOKUPSWITCH:
				// The instruction is in this format:
				//             lusaddr +4    +8
				// +0          +4      +8    [+12x8       ]...
				// op  x  x  x default count [match offset]...
				//    op  x  x default count [match offset]...
				//       op  x default count [match offset]...
				//          op default count [match offset]...
				// luspadlen includes the opcode
				int lusaddr = ((aa + 4) & (~3)),
					luspadlen = lusaddr - aa;
				rv = luspadlen + 8 + (8 * Instruction.__readInt(__code,
					lusaddr + 4));
				break;
			
				// {@squirreljme.error JC28 Cannot get the length of the
				// specified operation because it is not valid. (The operation;
				// The address; The operation before this one)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC28 %d %d %d", op, __a,
					((__last != null && __last.length > 0) ? __last[0] : -1)));
		}
		
		// Set last
		if (__last != null && __last.length > 0)
			__last[0] = op;
		
		return rv;
	}
	
	/**
	 * This iterates over each byte code instruction.
	 *
	 * @since 2017/05/20
	 */
	private final class __InstructionIterator__
		implements Iterator<Instruction>
	{
		/** The code length. */
		protected final int codelen =
			ByteCode.this.codelen;
		
		/** The read address. */
		private int _at =
			0;
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public boolean hasNext()
		{
			return this._at < this.codelen;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public Instruction next()
			throws NoSuchElementException
		{
			// No more?
			if (!hasNext())
				throw new NoSuchElementException("NSEE");
			
			// Instruction at current pointer
			int at = this._at;
			Instruction rv = ByteCode.this.getByAddress(at);
			
			// Skip length of instruction
			this._at += ByteCode.this._lengths[at];
			
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/05/20
		 */
		@Override
		public void remove()
			throws UnsupportedOperationException
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassFile.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491











































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.io.SizeLimitedInputStream;

/**
 * This represents a class file which was most likely derived from the binary
 * class file format of a class.
 *
 * @since 2017/09/26
 */
public final class ClassFile
	implements Annotated, HasAccessibleFlags
{
	/** The magic number of the class file. */
	private static final int _MAGIC_NUMBER =
		0xCAFEBABE;
	
	/** The version of this class. */
	protected final ClassVersion version;
	
	/** The flags for this class. */
	protected final ClassFlags classflags;
	
	/** The name of this class. */
	protected final ClassName thisname;
	
	/** The class this extends. */
	protected final ClassName supername;
	
	/** The annotation table of the class. */
	protected final AnnotationTable annotations;
	
	/** The referenced inner classes. */
	protected final InnerClasses innerclasses;
	
	/** The source file the class is in. */
	protected final String sourcefilename;
	
	/** The interfaces this class implements. */
	protected final ClassNames interfaces;
	
	/** The fields within this class. */
	private final Field[] _fields;
	
	/** The methods within this class. */
	private final Method[] _methods;
	
	/**
	 * Initializes the class file.
	 *
	 * @param __ver The version of the class.
	 * @param __cf The flags for this class.
	 * @param __tn The name of this class.
	 * @param __sn The class this class extends, may be {@code null}.
	 * @param __in The interfaces this class implements.
	 * @param __fs The fields in this class.
	 * @param __ms The methods in this class.
	 * @param __icl Defined inner classes.
	 * @param __at Annotations that are declared on the class.
	 * @param __sfn Source file name.
	 * @throws InvalidClassFormatException If the class is not valid.
	 * @throws NullPointerException On null arguments, except for {@code __sn}.
	 * @since 2017/09/26
	 */
	ClassFile(ClassVersion __ver, ClassFlags __cf, ClassName __tn,
		ClassName __sn, ClassName[] __in, Field[] __fs, Method[] __ms,
		InnerClasses __icl, AnnotationTable __at, String __sfn)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__ver == null || __cf == null || __tn == null ||
			__in == null || __fs == null || __ms == null || __icl == null ||
			__at == null)
			throw new NullPointerException("NARG");
		
		// Check sub-arrays for null
		for (Object[] foo : new Object[][]{(__in = __in.clone()),
			(__fs = __fs.clone()), (__ms = __ms.clone())})
			for (Object f : foo)
				if (f == null)
					throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC29 Either Object has a superclass which it
		// cannot extend any class or any other class does not have a super
		// class. Additionally primitive types cannot have a super class.
		// (The current class name; The super class name; Object class name;
		// Is this primitive?)}
		ClassName objectcn = new ClassName("java/lang/Object");
		if ((__tn.isPrimitive() ||
			__tn.equals(objectcn)) != (__sn == null))
			throw new InvalidClassFormatException(String.format("JC29 %s %s",
				__tn, __sn, objectcn, __tn.isPrimitive()));
		
		// Set
		this.version = __ver;
		this.classflags = __cf;
		this.thisname = __tn;
		this.supername = __sn;
		this.innerclasses = __icl;
		this.annotations = __at;
		this.interfaces = new ClassNames(__in);
		this._fields = __fs;
		this._methods = __ms;
		this.sourcefilename = __sfn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the fields within this class.
	 *
	 * @return The class fields.
	 * @since 2017/10/12
	 */
	public final List<Field> fields()
	{
		return UnmodifiableArrayList.<Field>of(this._fields);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/09
	 */
	@Override
	public final ClassFlags flags()
	{
		return this.classflags;
	}
	
	/**
	 * Returns the inner classes.
	 *
	 * @return The inner classes.
	 * @since 2018/06/16
	 */
	public final InnerClasses innerClasses()
	{
		return this.innerclasses;
	}
	
	/**
	 * Returns the names of implemented interfaces.
	 *
	 * @return The implemented interface names.
	 * @since 2017/10/09
	 */
	public final ClassNames interfaceNames()
	{
		return this.interfaces;
	}
	
	/**
	 * Methods which exist within this class.
	 *
	 * @return The class methods.
	 * @since 2017/10/09
	 */
	public final Method[] methods()
	{
		return this._methods.clone();
	}
	
	/**
	 * Returns the source file the class is in.
	 *
	 * @return The source file the class is in or {@code null} if it is not
	 * in one.
	 * @since 2018/09/08
	 */
	public final String sourceFile()
	{
		return this.sourcefilename;
	}
	
	/**
	 * Returns the name of the super class.
	 *
	 * @return The name of the super class.
	 * @since 2017/10/09
	 */
	public final ClassName superName()
	{
		return this.supername;
	}
	
	/**
	 * Returns the name of the current class.
	 *
	 * @return The current class name.
	 * @since 2017/10/02
	 */
	public final ClassName thisName()
	{
		return this.thisname;
	}
	
	/**
	 * Returns the type of class this is.
	 *
	 * @return The class type.
	 * @since 2018/05/14
	 */
	public final ClassType type()
	{
		ClassFlags flags = this.classflags;
		if (flags.isEnum())
			return ClassType.ENUM;
		else if (flags.isAnnotation())
			return ClassType.ANNOTATION;
		else if (flags.isInterface())
			return ClassType.INTERFACE;
		return ClassType.CLASS;
	}
	
	/**
	 * Returns the class version.
	 *
	 * @return The class version.
	 * @since 2019/04/14
	 */
	public final ClassVersion version()
	{
		return this.version;
	}
	
	/**
	 * Initializes a class file which is a special representation of the
	 * following field descriptor which is either an array or a primitive
	 * type.
	 *
	 * @param __d The descriptor to create a special class for.
	 * @return The generated class file from the specified descriptor.
	 * @throws IllegalArgumentException If the descriptor is not an array
	 * or a pritimive type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	public static ClassFile special(FieldDescriptor __d)
		throws IllegalArgumentException, NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2a Cannot create a special class because it
		// is not an array or primitive type. (The descriptor)}
		if (!__d.isArray() && !__d.isPrimitive())
			throw new IllegalArgumentException(String.format("JC2a %s", __d));
		
		// Pre-composed parts to fake things
		ClassFlags cflags = new ClassFlags(ClassFlag.PUBLIC, ClassFlag.FINAL,
			ClassFlag.SUPER, ClassFlag.SYNTHETIC);
		Method[] methods = new Method[0];
		
		// Use the names of the types in the language
		ClassName name;
		boolean isprimitive;
		if ((isprimitive = __d.isPrimitive()))
			name = ClassName.fromPrimitiveType(__d.primitiveType());
		
		// Treat array as normal class name
		else
		{
			name = __d.className();
			
			// Create fake constant pool
			Pool fakepool = new Pool(
					null,
					new MethodReference(
						new ClassName("java/lang/Object"),
						new MethodName("clone"),
						new MethodDescriptor("()Ljava/lang/Object;"), false));
			
			// Faked Code attribute for the clone method
			byte[] fakeattr;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
				DataOutputStream dos = new DataOutputStream(baos))
			{
				// Max stack
				dos.writeShort(1);
				
				// Max locals
				dos.writeShort(1);
				
				// Code length
				dos.writeInt(5);
				
				// ALOAD_0
				dos.writeByte(0x2A);
				
				// INVOKESPECIAL : Object.clone()
				dos.writeByte(0xB7);
				dos.writeShort(1);
				
				// ARETURN
				dos.writeByte(0xB0);
				
				// No exceptions
				dos.writeShort(0);
				
				// No attributes
				dos.writeShort(0);
				
				// Build
				fakeattr = baos.toByteArray();
			}
			catch (IOException e)
			{
				throw new RuntimeException(e);
			}
			
			// Need to make virtual method called clone
			methods = new Method[]
				{
					new Method(ClassVersion.CLDC_8, cflags, __d.className(),
						fakepool, new MethodFlags(0x1001),
						new MethodName("clone"),
						new MethodDescriptor("()Ljava/lang/Object;"),
						fakeattr, new AnnotationTable()),
				};
		}
		
		// Build
		return new ClassFile(ClassVersion.MAX_VERSION, cflags, name,
			(isprimitive ? null : new ClassName("java/lang/Object")),
			new ClassName[0], new Field[0], methods, new InnerClasses(),
			new AnnotationTable(), "<special>");
	}
	
	/**
	 * This parses the input stream as a class file and returns the
	 * representation of that class file.
	 *
	 * @param __is The input stream to source classes from.
	 * @return The decoded class file.
	 * @throws InvalidClassFormatException If the class file is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/26
	 */
	public static ClassFile decode(InputStream __is)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2b The magic number for the class is not
		// valid. (The read magic number; The expected magic number)}
		DataInputStream in = new DataInputStream(__is);
		int magic = in.readInt();
		if (magic != _MAGIC_NUMBER)
			throw new InvalidClassFormatException(String.format(
				"JC2b %08x %08x", magic, _MAGIC_NUMBER));
		
		// {@squirreljme.error JC2c The version number of the input class
		// file is not valid. (The version number)}
		int cver = in.readShort() | (in.readShort() << 16);
		ClassVersion version = ClassVersion.findVersion(cver);
		if (version == null)
			throw new InvalidClassFormatException(String.format("JC2c %d.%d",
				cver >>> 16, (cver & 0xFFFF)));
		
		// Decode the constant pool
		Pool pool = Pool.decode(in);
		
		// Decode flags
		ClassFlags classflags = new ClassFlags(in.readUnsignedShort());
		
		// Name of the current class
		ClassName thisname = pool.<ClassName>require(ClassName.class,
			in.readUnsignedShort());
		
		// Read super class
		ClassName supername = pool.<ClassName>get(ClassName.class,
			in.readUnsignedShort());
		
		// Read interfaces
		int icount = in.readUnsignedShort();
		ClassName[] interfaces = new ClassName[icount];
		for (int i = 0; i < icount; i++)
			interfaces[i] = pool.<ClassName>require(ClassName.class,
				in.readUnsignedShort());
		
		// Read fields
		Field[] fields = Field.decode(version, thisname, classflags, pool, in);
		
		// Read methods
		Method[] methods = Method.decode(version, thisname, classflags, pool,
			in);
		
		// Read in attributes
		AttributeTable attrs = AttributeTable.parse(pool, in);
		
		// Read annotation table, if it is valid and exists
		AnnotationTable annotations = AnnotationTable.parse(pool, attrs);
		
		// Parse inner classes
		InnerClasses innerclasses = InnerClasses.parse(pool, attrs);
		
		// {@squirreljme.error JC2d Expected end of the class to follow the
		// attributes in the class. (The name of this class)}
		if (in.read() >= 0)
			throw new InvalidClassFormatException(
				String.format("JC2d %s", thisname));
		
		// Source file name, if any
		Attribute attr = attrs.get("SourceFile");
		String sourcefilename = null;
		if (attr != null)
			try (DataInputStream ai = attr.open())
			{
				sourcefilename = pool.<UTFConstantEntry>require(
					UTFConstantEntry.class, ai.readUnsignedShort()).toString();
			}
		
		// Build
		return new ClassFile(version, classflags, thisname, supername,
			interfaces, fields, methods, innerclasses, annotations,
			sourcefilename);
	}
	
	/**
	 * Reads the next attribute from the class.
	 *
	 * @param __in The input stream where bytes come from.
	 * @param __pool The constant pool.
	 * @param __aname The output name of the attribute which was just read.
	 * @param __alens The length of the attribute.
	 * @return The stream to the attribute which just has been read.
	 * @throws IOException On read errors.
	 * @throws InvalidClassFormatException If the attribute is not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/04/09
	 */
	@Deprecated
	static DataInputStream __nextAttribute(DataInputStream __in,
		Pool __pool, String[] __aname, int[] __alens)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__aname == null || __alens == null)
			throw new NullPointerException("NARG");
		
		// The name is not parsed here
		__aname[0] = __pool.<UTFConstantEntry>require(UTFConstantEntry.class,
			__in.readUnsignedShort()).toString();
		
		// {@squirreljme.error JC2e Attribute exceeds 2GiB in length. (The
		// size of the attribute)}
		int len = __in.readInt();
		if (len < 0)
			throw new InvalidClassFormatException(String.format("JC2e %d",
				len & 0xFFFFFFFFL));
		
		// Used as a hint
		__alens[0] = len;
		
		// Setup reader
		return new DataInputStream(new SizeLimitedInputStream(__in, len, true,
			false));
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassFlag.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which modify how a class is accessed and is behaved.
 *
 * @since 2016/04/23
 */
public enum ClassFlag
	implements Flag
{
	/** Public access. */
	PUBLIC,
	
	/** Final. */
	FINAL,
	
	/** Super. */
	SUPER,
	
	/** Interface. */
	INTERFACE,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Synthetic. */
	SYNTHETIC,
	
	/** Annotation. */
	ANNOTATION,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/13
	 */
	@Override
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case FINAL:			return 0x0010;
			case SUPER:			return 0x0020;
			case INTERFACE:		return 0x0200;
			case ABSTRACT:		return 0x0400;
			case SYNTHETIC:		return 0x1000;
			case ANNOTATION:	return 0x2000;
			case ENUM:			return 0x4000;
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.ArrayList;
import java.util.List;

/**
 * This represents the flags which a class may be.
 *
 * @since 2016/04/23
 */
public class ClassFlags
	extends Flags<ClassFlag>
	implements AccessibleFlags
{
	/**
	 * Initializes the class flags decoding from the specified bit field.
	 *
	 * @param __i The bit field to decode flags from.
	 * @since 2017/06/13
	 */
	public ClassFlags(int __i)
	{
		this(Flags.<ClassFlag>__decode(__i, ClassFlag.values()));
	}
	
	/**
	 * Initializes the class flags.
	 *
	 * @param __fl The class flags.
	 * @since 2016/04/23
	 */
	public ClassFlags(ClassFlag... __fl)
	{
		super(ClassFlag.class, __fl);
		
		__checkFlags();
	}
	
	/**
	 * Initializes the class flags.
	 *
	 * @param __fl The class flags.
	 * @since 2016/04/23
	 */
	public ClassFlags(Iterable<ClassFlag> __fl)
	{
		super(ClassFlag.class, __fl);
		
		__checkFlags();
	}
	
	/**
	 * Is this class abstract?
	 *
	 * @return {@code true} if it is abstract.
	 * @since 2016/03/15
	 */
	public final boolean isAbstract()
	{
		return contains(ClassFlag.ABSTRACT);
	}
	
	/**
	 * Is this an annotation?
	 *
	 * @return {@code true} if it is an annotation.
	 * @since 2016/03/15
	 */
	public final boolean isAnnotation()
	{
		return contains(ClassFlag.ANNOTATION);
	}
	
	/**
	 * Is this an enumeration?
	 *
	 * @return {@code true} if it is an enumeration.
	 * @since 2016/03/15
	 */
	public final boolean isEnum()
	{
		return contains(ClassFlag.ENUM);
	}
	
	/**
	 * Is this class final?
	 *
	 * @return {@code true} if it is final.
	 * @since 2016/03/15
	 */
	public final boolean isFinal()
	{
		return contains(ClassFlag.FINAL);
	}
	
	/**
	 * Is this an interface?
	 *
	 * @return {@code true} if an interface.
	 * @since 2016/03/15
	 */
	public final boolean isInterface()
	{
		return contains(ClassFlag.INTERFACE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/15
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !isPublic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public final boolean isPrivate()
	{
		// Classes are never private
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/12
	 */
	@Override
	public final boolean isProtected()
	{
		// Classes are never protected
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/15
	 */
	@Override
	public final boolean isPublic()
	{
		return contains(ClassFlag.PUBLIC);
	}
	
	/**
	 * Is there special handling for super-class method calls?
	 *
	 * @return {@code true} if the super-class invocation special flag is set.
	 * @since 2016/03/15
	 */
	public final boolean isSpecialInvokeSpecial()
	{
		return contains(ClassFlag.SUPER);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @throws InvalidClassFormatException If they are not valid.
	 * @since 2016/04/23
	 */
	private final void __checkFlags()
		throws InvalidClassFormatException
	{
		// Interface?
		if (isInterface())
		{
			// {@squirreljme.error JC2f An interface must also be abstract.
			// (The class flags)}
			if (!isAbstract())
				throw new InvalidClassFormatException(
					String.format("JC2f %s", this));
			
			// {@squirreljme.error JC2g An interface cannot be {@code final} or
			// {@code enum} and it must not have the special flag set. (The
			// class flags)}
			if (isFinal() || isSpecialInvokeSpecial() || isEnum())
				throw new InvalidClassFormatException(
					String.format("JC2g %s", this));
		}
		
		// Normal class
		else
		{
			// {@squirreljme.error JC2h Annotations must be interfaces. (The
			// class flags)}
			if (isAnnotation())
				throw new InvalidClassFormatException(
					String.format("JC2h %s", this));
				
			// {@squirreljme.error JC2i A class cannot be both {@code abstract}
			// and {@code final}. (The class flags)}
			if (isAbstract() && isFinal())
				throw new InvalidClassFormatException(
					String.format("JC2i %s", this));
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassIdentifier.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is used to identify the fragment of a class or package.
 *
 * @since 2017/09/27
 */
public final class ClassIdentifier
	extends Identifier
	implements Comparable<ClassIdentifier>
{
	/**
	 * Initializes the class name.
	 *
	 * @param __s The class name.
	 * @since 2017/09/27
	 */
	public ClassIdentifier(String __s)
	{
		super(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/02
	 */
	@Override
	public int compareTo(ClassIdentifier __o)
	{
		return toString().compareTo(__o.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof ClassIdentifier) && super.equals(__o);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassName.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392








































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.Objects;

/**
 * This represents the name of a class or array within the virtual machine.
 *
 * This class is immutable.
 *
 * @since 2017/09/27
 */
public class ClassName
	implements Comparable<ClassName>
{
	/** The binary name of the class. */
	protected final BinaryName binary;
	
	/** The field type of the class (for arrays). */
	protected final FieldDescriptor field;
	
	/** Is this considered primitive? */
	protected final boolean isprimitive;
	
	/**
	 * Initializes the class name.
	 *
	 * @param __n The input string.
	 * @throws InvalidClassFormatException If it is not a valid class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public ClassName(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Is an array?
		if (__n.startsWith("["))
		{
			this.binary = null;
			this.field = new FieldDescriptor(__n);
			this.isprimitive = false;
		}
		
		// Not an array
		else
		{
			this.binary = new BinaryName(__n);
			this.field = null;
			
			// Consider this a primitive type
			switch (__n)
			{
				case "boolean":
				case "byte":
				case "short":
				case "char":
				case "int":
				case "long":
				case "float":
				case "double":
					this.isprimitive = true;
					break;
				
				default:
					this.isprimitive = false;
			}
		}
	}
	
	/**
	 * Adds dimensions to the class.
	 *
	 * @param __d The number of dimensions to add.
	 * @return The class with added dimensions.
	 * @throws IllegalArgumentException If the dimensions are negative.
	 * @since 2018/09/15
	 */
	public final ClassName addDimensions(int __d)
		throws IllegalArgumentException
	{
		if (__d == 0)
			return this;
		
		// {@squirreljme.error JC2j Cannot add negative dimensions.}
		if (__d < 0)
			throw new IllegalArgumentException("JC2j");
		
		// Going to be the same here but as a class name instead
		return this.field().addDimensions(__d).className();
	}
	
	/**
	 * Returns the binary name for this class.
	 *
	 * @return The class binary name or {@code null} if this is an array or
	 * primitive type.
	 * @since 2018/03/06
	 */
	public BinaryName binaryName()
	{
		return this.binary;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int compareTo(ClassName __o)
	{
		BinaryName ab = this.binary;
		if (ab != null)
		{
			BinaryName bb = __o.binary;
			if (bb == null)
				return -1;
			return ab.compareTo(bb);
		}
		
		FieldDescriptor af = this.field,
			bf = __o.field;
		if (bf == null)
			return 1;
		return af.compareTo(bf);
	}
	
	/**
	 * Returns the component type of this class name.
	 *
	 * @return The component type.
	 * @throws IllegalStateException If this is not an array.
	 * @since 2018/09/27
	 */
	public final ClassName componentType()
		throws IllegalStateException
	{
		// {@squirreljme.error JC2k This class is not an array, cannot get
		// the component type. (The name of this class)}
		if (!this.isArray())
			throw new IllegalStateException(String.format("JC2k %s", this));
		
		return this.field().componentType().className();
	}
	
	/**
	 * Returns the number of array dimensions that are used.
	 *
	 * @return The array dimensions.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		if (!this.isArray())
			return 0;
		return this.field().dimensions();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof ClassName))
			return false;
		
		ClassName o = (ClassName)__o;
		return Objects.equals(this.binary, o.binary) &&
			Objects.equals(this.field, o.field);
	}
	
	/**
	 * Returns the field descriptor for this class.
	 *
	 * @return The class field descriptor.
	 * @since 2017/10/10
	 */
	public FieldDescriptor field()
	{
		// If this is a primitive type, treat as one
		BinaryName binary = this.binary;
		if (this.isprimitive)
			switch (binary.toString())
			{
				case "boolean":		return new FieldDescriptor("Z");
				case "byte":		return new FieldDescriptor("B");
				case "short":		return new FieldDescriptor("S");
				case "char":		return new FieldDescriptor("C");
				case "int":			return new FieldDescriptor("I");
				case "long":		return new FieldDescriptor("J");
				case "float":		return new FieldDescriptor("F");
				case "double":		return new FieldDescriptor("D");
				default:
					throw new RuntimeException("TODO");
			}
		
		// If just a binary name, convert
		if (binary != null)
			return new FieldDescriptor("L" + binary + ";");
		return this.field;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public int hashCode()
	{
		BinaryName ab = this.binary;
		return (ab != null ? ab.hashCode() : this.field.hashCode());
	}
	
	/**
	 * Returns the package that this class is within. Primitive types and
	 * arrays are not part of any package.
	 *
	 * @return The package or {@code null} if it is not in the package.
	 * @since 2017/10/09
	 */
	public BinaryName inPackage()
	{
		BinaryName b = this.binary;
		if (b != null)
			return b.inPackage();
		return null;
	}
	
	/**
	 * Does this class refer to an array type?
	 *
	 * @return If this is an array type.
	 * @since 2017/10/08
	 */
	public boolean isArray()
	{
		FieldDescriptor field = this.field;
		return field != null && field.isArray();
	}
	
	/**
	 * Is the other class in the same package as this class?
	 *
	 * @param __b The other class to check.
	 * @return If the other class is in this same package.
	 * @since 2017/10/11
	 */
	public boolean isInSamePackage(ClassName __b)
		throws NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return Objects.equals(inPackage(), __b.inPackage());
	}
	
	/**
	 * Does this class refer to a primitive type?
	 *
	 * @return If this is a primitive type.
	 * @since 2017/10/08
	 */
	public boolean isPrimitive()
	{
		FieldDescriptor field = this.field;
		return this.isprimitive || field != null && field.isPrimitive();
	}
	
	/**
	 * Returns the primitive type of this class, if there is one.
	 *
	 * @return The primitive type or {@code null} if it is not one.
	 * @since 2018/09/16
	 */
	public final PrimitiveType primitiveType()
	{
		if (!this.isPrimitive())
			return null;
		
		switch (this.binary.toString())
		{
			case "boolean":		return PrimitiveType.BOOLEAN;
			case "byte":		return PrimitiveType.BYTE;
			case "short":		return PrimitiveType.SHORT;
			case "char":		return PrimitiveType.CHARACTER;
			case "int":			return PrimitiveType.INTEGER;
			case "long":		return PrimitiveType.LONG;
			case "float":		return PrimitiveType.FLOAT;
			case "double":		return PrimitiveType.DOUBLE;
			default:
				throw new RuntimeException("TODO");
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/27
	 */
	@Override
	public String toString()
	{
		BinaryName binary = this.binary;
		if (binary != null)
			return binary.toString();
		return field.toString();
	}
	
	/**
	 * Translates the primitive type to the given class type.
	 *
	 * @param __t The type to convert.
	 * @return The name of the class for this primitive.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	public static final ClassName fromPrimitiveType(PrimitiveType __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Depends on the primitive type
		switch (__t)
		{
			case BOOLEAN:
				return new ClassName("boolean");
			
			case BYTE:
				return new ClassName("byte");
			
			case SHORT:
				return new ClassName("short");
			
			case CHARACTER:
				return new ClassName("char");
			
			case INTEGER:
				return new ClassName("int");
			
			case LONG:
				return new ClassName("long");
			
			case FLOAT:
				return new ClassName("float");
			
			case DOUBLE:
				return new ClassName("double");
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Checks if this class name is valid or not.
	 *
	 * @param __cn The class-name to check.
	 * @return If it is valid or not.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/22
	 */
	public static final boolean isValidClassName(String __cn)
		throws NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		try
		{
			ClassName cn = new ClassName(__cn);
			return true;
		}
		catch (InvalidClassFormatException e)
		{
			return false;
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassNames.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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractList;
import java.util.RandomAccess;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * Represents multiple class names.
 *
 * @since 2019/04/14
 */
public final class ClassNames
	extends AbstractList<ClassName>
	implements RandomAccess
{
	/** Names. */
	private final ClassName[] _names;
	
	/** Hash code. */
	private int _hash;
	
	/** String. */
	private Reference<String> _string;
	
	/**
	 * Initializes the class names.
	 *
	 * @param __n The names.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public ClassNames(ClassName... __n)
		throws NullPointerException
	{
		for (ClassName n : (__n =
			(__n == null ? new ClassName[0] : __n.clone())))
			if (n == null)
				throw new NullPointerException("NARG");
			
		this._names = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = super.hashCode());
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final ClassName get(int __i)
	{
		return this._names[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final int size()
	{
		return this._names.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public ClassName[] toArray()
	{
		return this._names.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/14
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = super.toString()));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassType.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Returns the type of class this is.
 *
 * @since 2018/05/14
 */
public enum ClassType
{
	/** Normal class. */
	CLASS,
	
	/** Interface. */
	INTERFACE,
	
	/** Enumeration. */
	ENUM,
	
	/** Annotation. */
	ANNOTATION,
	
	/** End. */
	;
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ClassVersion.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
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






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the class verion that a class may be.
 *
 * @since 2016/06/29
 */
public enum ClassVersion
{
	/** CLDC 1.0 (JSR 30). */
	CLDC_1((45 << 16) + 3, (47 << 16) - 1, false, false, false),
	
	/** CLDC 1.1 (JSR 139). */
	CLDC_1_1((47 << 16), (51 << 16) - 1, true, false, false),
	
	/** CLDC 8 (aka Java 7). */
	CLDC_8((51 << 16), (52 << 16), true, false, true),
	
	/** End. */
	;
	
	/** The minimum supported version. */
	public static final ClassVersion MIN_VERSION =
		CLDC_1;
	
	/** The maximum supported version. */
	public static final ClassVersion MAX_VERSION =
		CLDC_8;
	
	/** The version ID. */
	protected final int version;
	
	/** The maximum range of the version. */
	protected final int maxversion;
	
	/** Has floating point support? */
	protected final boolean hasfloat;
	
	/** Supports invokedynamic? */
	protected final boolean hasinvokedynamic;
	
	/** Use StackMapTable? */
	protected final boolean usestackmaptable;
	
	/**
	 * Initializes the version data.
	 *
	 * @param __vid The version ID.
	 * @param __vmx The max version identifier.
	 * @param __undef Is this version information undefined?
	 * @param __float Is floating point supported?
	 * @param __hasid Has invoke dynamic support?
	 * @param __usesmt Should the StackMapTable attribute be used?
	 * @since 2016/03/13
	 */
	private ClassVersion(int __vid, int __vmx,
		boolean __float, boolean __hasid, boolean __usesmt)
	{
		// Set
		version = __vid;
		maxversion = __vmx;
		hasfloat = __float;
		hasinvokedynamic = __hasid;
		usestackmaptable = __usesmt;
	}
	
	/**
	 * Returns {@code true} if floating point is supported by the virtual
	 * machine.
	 *
	 * @return {@code true} if it is.
	 * @since 2016/03/13
	 */
	public boolean hasFloatingPoint()
	{
		return hasfloat;
	}
	
	/**
	 * Returns {@code true} if invokedynamic is supported by the virtual
	 * machine.
	 *
	 * @return {@code true} if it is.
	 * @since 2016/03/15
	 */
	public boolean hasInvokeDynamic()
	{
		return hasinvokedynamic;
	}
	
	/**
	 * Should the new StackMapTable attribute be used when veryifying the byte
	 * code of a class?
	 *
	 * @return {@code true} if the "StackMapTable" attribute should be parsed
	 * instead of "StackMap".
	 * @since 2016/03/20
	 */
	public boolean useStackMapTable()
	{
		return usestackmaptable;
	}
	
	/**
	 * Finds the best matching version with the given ID.
	 *
	 * @param __vid The version ID to get a match for.
	 * @return The matching class version or {@code null} if not found.
	 * @since 2016/03/13
	 */
	public static ClassVersion findVersion(int __vid)
	{
		// Go through all versions, find the best
		ClassVersion best = null;
		for (ClassVersion v : values())
			if (__vid >= v.version && __vid <= v.maxversion)
				if (best == null || v.version > best.version)
					best = v;
		
		// Use the best (if any)
		return best;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValue.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
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








































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a constant value.
 *
 * @since 2018/05/16
 */
public abstract class ConstantValue
{
	/** The represented object. */
	protected final Object value;
	
	/** The value type. */
	protected final ConstantValueType type;
	
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @param __t The value type.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValue(Object __v, ConstantValueType __t)
		throws NullPointerException
	{
		if (__v == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
		this.type = __t;
	}
	
	/**
	 * Returns the value of the constant as a boxed object.
	 *
	 * @return The constant value in a boxed type.
	 * @since 2018/09/08
	 */
	public final Object boxedValue()
	{
		return this.value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ConstantValue))
			return false;
		
		ConstantValue o = (ConstantValue)__o;
		return this.value.equals(o.value) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final int hashCode()
	{
		return this.value.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/16
	 */
	@Override
	public final String toString()
	{
		return this.value.toString();
	}
	
	/**
	 * The type of value which is contained here.
	 *
	 * @return The constant value type.
	 * @since 2018/05/16
	 */
	public final ConstantValueType type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueClass.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a constant value which is of a class.
 *
 * @since 2018/09/19
 */
public final class ConstantValueClass
	extends ConstantValue
{
	/**
	 * Initializes the class constant value.
	 *
	 * @param __cn The class constant.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/19
	 */
	public ConstantValueClass(ClassName __cn)
		throws NullPointerException
	{
		super(__cn, ConstantValueType.CLASS);
	}
	
	/**
	 * Returns the class name.
	 *
	 * @return The class name.
	 * @since 2018/09/19
	 */
	public final ClassName className()
	{
		return (ClassName)this.value;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueDouble.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents a double constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueDouble
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueDouble(double __v)
	{
		super(__v, ConstantValueType.DOUBLE);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueFloat.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents a float constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueFloat
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueFloat(float __v)
	{
		super(__v, ConstantValueType.FLOAT);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueInteger.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents a constant integer value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueInteger
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueInteger(int __v)
	{
		super(__v, ConstantValueType.INTEGER);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueLong.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents a long constant value.
 *
 * @since 2018/05/21
 */
public final class ConstantValueLong
	extends ConstantValueNumber
{
	/**
	 * Initializes the constant value.
	 *
	 * @param __v The value.
	 * @since 2018/05/21
	 */
	public ConstantValueLong(long __v)
	{
		super(__v, ConstantValueType.LONG);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueNumber.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
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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a constant value which is a number.
 *
 * @since 2018/05/21
 */
public abstract class ConstantValueNumber
	extends ConstantValue
{
	/** The number used. */
	protected final Number value;
	
	/**
	 * Initializes the constant value that uses a number.
	 *
	 * @param __v The value.
	 * @param __t The type of value used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValueNumber(Number __v, ConstantValueType __t)
		throws NullPointerException
	{
		super(__v, __t);
		
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.value = __v;
	}
	
	/**
	 * Returns the double value.
	 *
	 * @return The double value.
	 * @since 2018/05/16
	 */
	public final double doubleValue()
	{
		return this.value.doubleValue();
	}
	
	/**
	 * Returns the float value.
	 *
	 * @return The float value.
	 * @since 2018/05/16
	 */
	public final float floatValue()
	{
		return this.value.floatValue();
	}
	
	/**
	 * Returns the integer value.
	 *
	 * @return The integer value.
	 * @since 2018/05/16
	 */
	public final int intValue()
	{
		return this.value.intValue();
	}
	
	/**
	 * Returns the long value.
	 *
	 * @return The long value.
	 * @since 2018/05/16
	 */
	public final long longValue()
	{
		return this.value.longValue();
	}
	
	/**
	 * Returns the value as a number.
	 *
	 * @return The number used.
	 * @since 2018/05/21
	 */
	public final Number number()
	{
		return this.value;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueString.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a string constant value.
 *
 * @since 2018/05/21
 */
public class ConstantValueString
	extends ConstantValue
	implements CharSequence
{
	/** The used string. */
	protected final String value;
	
	/**
	 * Initializes the value.
	 *
	 * @param __s The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public ConstantValueString(String __s)
		throws NullPointerException
	{
		super(__s, ConstantValueType.STRING);
		
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.value = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final char charAt(int __i)
	{
		return this.value.charAt(__i);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final int length()
	{
		return this.value.length();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/21
	 */
	@Override
	public final CharSequence subSequence(int __s, int __e)
	{
		// So the same class type is returned
		return new ConstantValueString(this.value.substring(__s, __e));
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ConstantValueType.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
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


































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This indicates the type that a constant value is.
 *
 * @since 2018/05/16
 */
public enum ConstantValueType
{
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** String. */
	STRING,
	
	/** Class. */
	CLASS,
	
	/** End. */
	;
	
	/**
	 * Checks if this value is compatible with the given field descriptor.
	 *
	 * @param __d The descriptor to check.
	 * @return If it is compatible.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public final boolean isCompatibleWith(FieldDescriptor __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		switch (this)
		{
			case INTEGER:
				if (!__d.isPrimitive())
					return false;
				switch (__d.primitiveType())
				{
					case BOOLEAN:
					case BYTE:
					case SHORT:
					case CHARACTER:
					case INTEGER:
						return true;
						
					default:
						return false;
				}
			
			case LONG:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.LONG);
			
			case FLOAT:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.FLOAT);
			
			case DOUBLE:
				return __d.isPrimitive() &&
					__d.primitiveType().equals(PrimitiveType.DOUBLE);
			
			case STRING:
				return __d.isObject() &&
					"Ljava/lang/String;".equals(__d.toString()); 
			
			case CLASS:
				return __d.isObject() &&
					"Ljava/lang/Class;".equals(__d.toString());
			
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is this a narrow constant value?
	 *
	 * @return If this is a narrow constant value.
	 * @since 2108/09/08
	 */
	public final boolean isNarrow()
	{
		switch (this)
		{
			case INTEGER:
			case FLOAT:
			case STRING:
			case CLASS:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a wide constant value?
	 *
	 * @return If this is a wide constant value.
	 * @since 2108/09/08
	 */
	public final boolean isWide()
	{
		switch (this)
		{
			case LONG:
			case DOUBLE:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the Java type for the constant value.
	 *
	 * @return The Java type that is used.
	 * @since 2019/03/17
	 */
	public final JavaType javaType()
	{
		switch (this)
		{
			case INTEGER:	return JavaType.INTEGER;
			case LONG:		return JavaType.LONG;
			case FLOAT:		return JavaType.FLOAT;
			case DOUBLE:	return JavaType.DOUBLE;
			case STRING:	return new JavaType(new FieldDescriptor(
				"Ljava/lang/String;"));
			case CLASS:		return new JavaType(new FieldDescriptor(
				"Ljava/lang/Class;"));
			
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ExceptionHandler.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
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
191
192
































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single exception handler.
 *
 * @since 2017/02/09
 */
public final class ExceptionHandler
{
	/** The start address. */
	protected final int startpc;
	
	/** The end address. */
	protected final int endpc;
	
	/** The handler address. */
	protected final int handlerpc;
	
	/** The class type to handle. */
	protected final ClassName type;
	
	/** The string representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the exception handler.
	 *
	 * @param __spc The start address.
	 * @param __epc The end address.
	 * @param __hpc The handler address.
	 * @param __cn The class to be handled.
	 * @throws InvalidClassFormatException If the addresses are not valid.
	 * @since 2017/02/09
	 */
	ExceptionHandler(int __spc, int __epc, int __hpc, ClassName __cn)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC2l An address is negative. (The start address;
		// The end address; The handler address)}
		if (__spc < 0 || __epc < 0 || __hpc < 0)
			throw new InvalidClassFormatException(
				String.format("JC2l %d %d %d", __spc, __epc, __hpc));
		
		// {@squirreljme.error JC2m The end address is at or before the start
		// address. (The start address; The end address)}
		if (__epc <= __spc)
			throw new InvalidClassFormatException(String.format("JC2m %d %d",
				__spc, __epc));
		
		// Set
		this.startpc = __spc;
		this.endpc = __epc;
		this.handlerpc = __hpc;
		this.type = (__cn == null ? new ClassName("java/lang/Throwable") :
			__cn);
	}
	
	/**
	 * Returns the end address.
	 *
	 * @return The end address.
	 * @since 2017/02/09
	 */
	public int endAddress()
	{
		return this.endpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof ExceptionHandler))
			return false;
		
		if (__o == this)
			return true;
		
		// Compare
		ExceptionHandler o = (ExceptionHandler)__o;
		return this.startpc == o.startpc &&
			this.endpc == o.endpc &&
			this.handlerpc == o.handlerpc &&
			Objects.equals(this.type, o.type);
	}
	
	/**
	 * Returns the handler address.
	 *
	 * @return The handler address.
	 * @since 2017/02/09
	 */
	public int handlerAddress()
	{
		return this.handlerpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public int hashCode()
	{
		return this.startpc ^ this.endpc ^ this.handlerpc ^
			Objects.hashCode(this.type);
	}
	
	/**
	 * Checks whether the address is in range of this exception handler, that
	 * it there is a handler for this instruction.
	 *
	 * @param __i The address to check.
	 * @return {@code true} if the address is in range.
	 * @since 2017/04/01
	 */
	public boolean inRange(int __i)
	{
		return __i >= this.startpc && __i < this.endpc;
	}
	
	/**
	 * Returns the range of this exception handler.
	 *
	 * @return The exception handler range.
	 * @since 2019/03/21
	 */
	public final InstructionAddressRange range()
	{
		return new InstructionAddressRange(this.startpc, this.endpc);
	}
	
	/**
	 * Returns the start address.
	 *
	 * @return The start address.
	 * @since 2017/02/09
	 */
	public int startAddress()
	{
		return this.startpc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/09
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"{%d-%d > %d (%s)}", this.startpc, this.endpc, this.handlerpc,
				this.type)));
		
		return rv;
	}
	
	/**
	 * Returns the type of exception to handle.
	 *
	 * @return The type of exception to handle.
	 * @since 2017/02/09
	 */
	public ClassName type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/ExceptionHandlerTable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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





























































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.RandomAccess;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This represents a every exception that exists within a method.
 *
 * @since 2017/02/09
 */
public final class ExceptionHandlerTable
	implements Iterable<ExceptionHandler>
{
	/** The exception handler table. */
	private final ExceptionHandler[] _table;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the exception handler table.
	 *
	 * @param __t The entries to handle.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/09
	 */
	ExceptionHandlerTable(ExceptionHandler... __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Clone entries
		__t = __t.clone();
		for (ExceptionHandler e : __t)
			if (e == null)
				throw new NullPointerException("NARG");
		
		// Set
		this._table = __t;
	}
	
	/**
	 * Initializes the exception handler table.
	 *
	 * @param __t The entries to handle.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/22
	 */
	ExceptionHandlerTable(Collection<ExceptionHandler> __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Copy array
		ExceptionHandler[] t = __t.<ExceptionHandler>toArray(
			new ExceptionHandler[__t.size()]);
		for (ExceptionHandler e : t)
			if (e == null)
				throw new NullPointerException("NARG");
		
		this._table = t;
	}
	
	/**
	 * Return all of the exception handlers which apply to the given address.
	 *
	 * @param __pc The address to use.
	 * @return An array containing the exceptions which handle for the given
	 * address.
	 * @since 2018/10/13
	 */
	public final ExceptionHandler[] at(int __pc)
	{
		List<ExceptionHandler> rv = new ArrayList<>();
		
		// Add any handlers which are in range
		for (ExceptionHandler e : this._table)
			if (e.inRange(__pc))
				rv.add(e);
		
		return rv.<ExceptionHandler>toArray(new ExceptionHandler[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ExceptionHandlerTable))
			return false;
		
		// The exception handler table has a strict order
		return Arrays.equals(this._table, ((ExceptionHandlerTable)__o)._table);
	}
	
	/**
	 * Returns the exception handler at the given index.
	 *
	 * @return The exception handler at the given index.
	 * @since 2017/02/09
	 */
	public final ExceptionHandler get(int __i)
	{
		return this._table[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int hashCode()
	{
		// Just add up all of the entries quickly
		int rv = 0;
		for (ExceptionHandler e : this._table)
			rv += e.hashCode();
		return rv;
	}
	
	/**
	 * Is this exception table empty?
	 *
	 * @return If the table is empty.
	 * @since 2019/03/22
	 */
	public final boolean isEmpty()
	{
		return this._table.length == 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/22
	 */
	@Override
	public final Iterator<ExceptionHandler> iterator()
	{
		return UnmodifiableIterator.<ExceptionHandler>of(this._table);
	}
	
	/**
	 * Returns a map of all the ranges that exist within the exception table
	 * that are unique to each other.
	 *
	 * @return A mapping of ranges and table entries.
	 * @since 2019/03/21
	 */
	public final Map<InstructionAddressRange, ExceptionHandlerTable>
		mappedUniqueRanges()
	{
		Map<InstructionAddressRange, ExceptionHandlerTable> rv =
			new LinkedHashMap<>();
		
		// Start of range
		int rangestart = 0;
		ExceptionHandlerTable current = this.tableAt(0);
		
		// Go through all addresses in range
		// We include the end address because after that point there would
		// be no exception handlers after that point. This forces a range
		// to be specified where anything after this end point has no handlers
		int ma = this.maximumEndAddress();
		for (int i = 1; i <= ma; i++)
		{
			// Get table at this address
			ExceptionHandlerTable now = this.tableAt(i);
			
			// If the table is different, then a new range is used
			if (!current.equals(now))
			{
				// Store the range
				rv.put(new InstructionAddressRange(rangestart, i), current);
				
				// Set for next scan
				rangestart = i;
				current = now;
			}
		}
		
		// Always store the final range
		rv.put(new InstructionAddressRange(rangestart, ma), current);
		
		return rv;
	}
	
	/**
	 * Returns the maximum end address that is used in the table.
	 *
	 * @return The highest end address used in the table.
	 * @since 2019/03/21
	 */
	public final int maximumEndAddress()
	{
		int rv = 0;
		for (ExceptionHandler e : this._table)
		{
			int epc = e.endpc;
			if (epc > rv)
				rv = epc;
		}
		return rv;
	}
	
	/**
	 * Returns the maximum used start address in the table.
	 *
	 * @return The maximum start address.
	 * @since 2019/04/04
	 */
	public final int maximumStartAddress()
	{
		int rv = 0;
		for (ExceptionHandler e : this._table)
		{
			int spc = e.startpc;
			if (spc > rv)
				rv = spc;
		}
		return rv;
	}
	
	/**
	 * Returns the instruction range.
	 *
	 * @return The instruction range.
	 * @since 2019/03/21
	 */
	public final InstructionAddressRange range()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the number of exception handlers that exist.
	 *
	 * @return The total number of exception handlers.
	 * @since 2017/02/09
	 */
	public final int size()
	{
		return this._table.length;
	}
	
	/**
	 * Returns an exception handler table for the given address.
	 *
	 * @param __pc The address to get an exception handler table from.
	 * @return A table representing only the exceptions at a given address.
	 * @since 2019/03/21
	 */
	public final ExceptionHandlerTable tableAt(int __pc)
	{
		return new ExceptionHandlerTable(this.at(__pc));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/13
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = Arrays.asList(this._table).toString()));
		
		return rv;
	}
	
	/**
	 * Parses the exception handler table.
	 *
	 * @param __in The input stream to read exceptions from.
	 * @param __pool The constant pool for class names.
	 * @param __len The length of the method in byte codes.
	 * @throws InvalidClassFormatException If the exception table is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	public static ExceptionHandlerTable decode(DataInputStream __is,
		Pool __pool, int __len)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__is == null || __pool == null)
			throw new NullPointerException("NARG");
		
		// Read exception table count
		int n = __is.readUnsignedShort();
		ExceptionHandler[] table = new ExceptionHandler[n];
		for (int i = 0; i < n; i++)
		{
			// Read values
			int spc = __is.readUnsignedShort();
			int epc = __is.readUnsignedShort();
			int hpc = __is.readUnsignedShort();
			ClassName type = __pool.<ClassName>get(ClassName.class,
				__is.readUnsignedShort());
			
			// {@squirreljme.error JC2n Address is outside of the bounds of the
			// method. (The start address; The end address; The handler
			// address; The code length)}
			if (spc >= __len || epc > __len || hpc >= __len)
				throw new InvalidClassFormatException(String.format(
					"JC2n %d %d %d %d", spc, epc, hpc, __len));
			
			// Setup exception
			table[i] = new ExceptionHandler(spc, epc, hpc, type);
		}
		
		// Setup
		return new ExceptionHandlerTable(table);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Field.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219



























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableArrayList;

/**
 * This represents a field in a class which is used to store values either as
 * static instances or as instance variables outside of methods.
 *
 * @since 2017/09/30
 */
public final class Field
	extends Member
	implements Annotated, HasMemberFlags
{
	/** The flags for the field. */
	protected final FieldFlags flags;
	
	/** The name of the field. */
	protected final FieldName name;
	
	/** The descriptor of the field. */
	protected final FieldDescriptor type;
	
	/** The constant value, if there is none then this is {@code null}. */
	protected final ConstantValue constval;
	
	/** Annotated values. */
	protected final AnnotationTable annotations;
	
	/** Name and type reference. */
	private Reference<FieldNameAndType> _nameandtype;
	
	/**
	 * Initializes the field.
	 *
	 * @param __f The flags for the field.
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @param __cv The constant value of the field, may be {@code null}.
	 * @param __avs Annotated values.
	 * @throws InvalidClassFormatException If the class format is not valid.
	 * @throws NullPointerException On null arguments, except for {@code __cv}.
	 * @since 2017/10/02
	 */
	public Field(FieldFlags __f, FieldName __n, FieldDescriptor __t,
		ConstantValue __cv, AnnotationTable __avs)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__f == null || __n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2o The constant value is not compatible with
		// the given field type. (The value; The value type; The field type)}
		if (__cv != null && !__cv.type().isCompatibleWith(__t))
			throw new InvalidClassFormatException(String.format(
				"JC2o %s %s %s", __cv, __cv.type(), __t));
		
		this.flags = __f;
		this.name = __n;
		this.type = __t;
		this.constval = __cv;
		this.annotations = (__avs == null ? new AnnotationTable() : __avs);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the constant value of the field.
	 *
	 * @return The field constant value.
	 * @since 2018/05/14
	 */
	public final ConstantValue constantValue()
	{
		return this.constval;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public final FieldFlags flags()
	{
		return this.flags;
	}
	
	/**
	 * Returns the name of the field.
	 *
	 * @return The field name.
	 * @since 2018/05/14
	 */
	public final FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public final FieldNameAndType nameAndType()
	{
		Reference<FieldNameAndType> ref = this._nameandtype;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nameandtype = new WeakReference<>(
				rv = new FieldNameAndType(this.name, this.type));
		
		return rv;
	}
	
	/**
	 * Returns the field type.
	 *
	 * @return The field type.
	 * @since 2018/05/14
	 */
	public final FieldDescriptor type()
	{
		return this.type;
	}
	
	/**
	 * Decodes all fields from the input class data.
	 *
	 * @param __ver The version of the class.
	 * @param __tn The name of the owning class.
	 * @param __cf The flags for the owning class.
	 * @param __pool The constant pool for the class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/30
	 */
	public static Field[] decode(ClassVersion __ver, ClassName __tn,
		ClassFlags __cf, Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__ver == null || __tn == null || __cf == null || __pool == null ||
			__in == null)
			throw new NullPointerException("NARG");
		
		int nf = __in.readUnsignedShort();
		Field[] rv = new Field[nf];
		Set<NameAndType> dup = new HashSet<>();
		
		// Parse fields
		for (int i = 0; i < nf; i++)
		{
			FieldFlags flags = new FieldFlags(__cf, __in.readUnsignedShort());
			FieldName name = new FieldName(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			FieldDescriptor type = new FieldDescriptor(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// {@squirreljme.error JC2p A duplicate method exists within the
			// class. (The method name; The method descriptor)}
			if (!dup.add(new NameAndType(name.toString(), type.toString())))
				throw new InvalidClassFormatException(String.format(
					"JC2p %s %s", name, type));
			
			// Handle attributes
			AttributeTable attrs = AttributeTable.parse(__pool, __in);
			
			// Parse annotations
			AnnotationTable annotations = AnnotationTable.parse(__pool, attrs);
			
			// Parse constant value if there is one
			ConstantValue constval = null;
			Attribute cvalattr = attrs.get("ConstantValue");
			if (cvalattr != null)
				try (DataInputStream ai = cvalattr.open())
				{
					constval = __pool.<ConstantValue>require(
						ConstantValue.class, ai.readUnsignedShort());
				}
			
			// Create field
			rv[i] = new Field(flags, name, type, constval, annotations);
		}
		
		// All done!
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldDescriptor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the type descriptor of a field.
 *
 * @since 2017/06/12
 */
public final class FieldDescriptor
	implements Comparable<FieldDescriptor>, MemberDescriptor
{
	/** The short type. */
	public static final FieldDescriptor SHORT =
		new FieldDescriptor("S");
	
	/** The integer type. */
	public static final FieldDescriptor INTEGER =
		new FieldDescriptor("I");
	
	/** String representation. */
	protected final String string;
	
	/** Is this a primitive type? */
	protected final boolean primitive;
	
	/** Array dimensions. */
	protected final int dimensions;
	
	/** The component type. */
	protected final FieldDescriptor component;
	
	/** The class this refers to. */
	protected final ClassName classname;
	
	/**
	 * Initializes the field descriptor.
	 *
	 * @param __n The field descriptor to decode.
	 * @throws InvalidClassFormatException If it is not a valid field descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public FieldDescriptor(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// {@squirreljme.error JC2q The field descriptor cannot be blank. (The
		// field descriptor)}
		int n = __n.length();
		if (n <= 0)
			throw new InvalidClassFormatException(
				String.format("JC2q %s", __n));
		
		// Depends on the first character
		char c = __n.charAt(0);
		switch (c)
		{
				// Primitive
			case 'B':
			case 'C':
			case 'D':
			case 'F':
			case 'I':
			case 'J':
			case 'S':
			case 'Z':
				this.primitive = true;
				this.dimensions = 0;
				this.component = null;
				this.classname = null;
				break;
			
				// Array
			case '[':
				this.primitive = false;
				this.classname = null;
				
				// Count dimensions
				int dims = 0;
				for (int i = 0; i < n; i++)
					if (__n.charAt(i) != '[')
						break;
					else
						dims++;
				this.dimensions = dims;
				
				// Parse component
				this.component = new FieldDescriptor(__n.substring(1));
				break;
				
				// Class
			case 'L':
				this.primitive = false;
				this.dimensions = 0;
				this.component = null;
				
				// {@squirreljme.error JC2r The field descriptor for a class
				// must end with a semicolon. (The field descriptor)}
				if (';' != __n.charAt(n - 1))
					throw new InvalidClassFormatException(
						String.format("JC2r %s", __n));
				
				// Decode
				this.classname = new ClassName(__n.substring(1, n - 1));
				break;
				
				// {@squirreljme.error JC2s The field descriptor is not valid.
				// (The field descriptor)}
			default:
				throw new InvalidClassFormatException(
					String.format("JC2s %s", __n));
		}
	}
	
	/**
	 * Adds dimensions to the field descriptor.
	 *
	 * @param __d The number of dimensions to add.
	 * @return The field descriptor with added dimensions.
	 * @throws IllegalArgumentException If the dimensions are negative.
	 * @since 2018/09/15
	 */
	public final FieldDescriptor addDimensions(int __d)
		throws IllegalArgumentException
	{
		if (__d == 0)
			return this;
		
		// {@squirreljme.error JC2t Cannot add negative dimensions.}
		if (__d < 0)
			throw new IllegalArgumentException("JC2t");
		
		// Prepend string with brackets, to declare a new array
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < __d; i++)
			sb.append('[');
		
		// Rebuild field
		sb.append(this.toString());
		return new FieldDescriptor(sb.toString());
	}
	
	/**
	 * Returns the name of the used class.
	 *
	 * @return The used class or {@code null} if a class is not referred to and
	 * this is a primitive type.
	 * @since 2018/09/01
	 */
	public final ClassName className()
	{
		// If this is an array then the class name will be the array descriptor
		if (this.dimensions > 0)
			return new ClassName(this.toString());
		
		// Otherwise as normal class (or primitive representation)
		if (this.primitive)
			return ClassName.fromPrimitiveType(this.primitiveType());
		return this.classname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/02
	 */
	@Override
	public int compareTo(FieldDescriptor __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * Returns the component type of the array if this is one.
	 *
	 * @return The component type or {@code null} if this is not one.
	 * @since 2018/09/27
	 */
	public final FieldDescriptor componentType()
	{
		return this.component;
	}
	
	/**
	 * Returns the number of dimensions in this class.
	 *
	 * @return The number of dimensions in the class.
	 * @since 2018/09/28
	 */
	public final int dimensions()
	{
		return this.dimensions;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof FieldDescriptor))
			return false;
		
		return this.string.equals(((FieldDescriptor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Is this an array type?
	 *
	 * @return {@code true} if an array type.
	 * @since 2017/10/08
	 */
	public boolean isArray()
	{
		return this.component != null;
	}
	
	/**
	 * Is this a primitive type?
	 *
	 * @return {@code true} if this is a primitive type.
	 * @since 2017/07/28
	 */
	public boolean isPrimitive()
	{
		return this.primitive;
	}
	
	/**
	 * Is this an object type?
	 *
	 * @return If this is an object type.
	 * @since 2017/09/16
	 */
	public boolean isObject()
	{
		return !isPrimitive();
	}
	
	/**
	 * Returns if this is a wide field or not.
	 *
	 * @return If this is a wide field.
	 * @since 2019/02/05
	 */
	public final boolean isWide()
	{
		if (this.isObject())
			return false;
		switch (this.primitiveType())
		{
			case LONG:
			case DOUBLE:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the primitive type for this field.
	 *
	 * @return The primitive type to use or {@code null} if there is none.
	 * @since 2017/10/16
	 */
	public PrimitiveType primitiveType()
	{
		// Quick detect
		if (!this.primitive)
			return null;
		
		// Depends on the string
		switch (toString())
		{
			case "B": return PrimitiveType.BYTE;
			case "C": return PrimitiveType.CHARACTER;
			case "D": return PrimitiveType.DOUBLE;
			case "F": return PrimitiveType.FLOAT;
			case "I": return PrimitiveType.INTEGER;
			case "J": return PrimitiveType.LONG;
			case "S": return PrimitiveType.SHORT;
			case "Z": return PrimitiveType.BOOLEAN;
			default:
				return null;
		}
	}
	
	/**
	 * Returns the simple storage type of the field.
	 *
	 * @return The simple storage type for this field.
	 * @since 2018/09/15
	 */
	public final SimpleStorageType simpleStorageType()
	{
		// Objects
		if (this.isObject())
			return SimpleStorageType.OBJECT;
		
		// Primitive types, these are promoted
		switch (this.primitiveType())
		{
			case BOOLEAN:
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:
				return SimpleStorageType.INTEGER;
			
			case LONG:
				return SimpleStorageType.LONG;
			
			case FLOAT:
				return SimpleStorageType.FLOAT;
			
			case DOUBLE:
				return SimpleStorageType.DOUBLE;
			
				// Should not occur
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the width of this field on the stack.
	 *
	 * @return The width of the field on the stack.
	 * @since 2019/02/05
	 */
	public final int stackWidth()
	{
		return (this.isWide() ? 2 : 1);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldFlag.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which are associated with class fields.
 *
 * @since 2016/04/23
 */
public enum FieldFlag
	implements MemberFlag
{
	/** Public field. */
	PUBLIC,
	
	/** Private field. */
	PRIVATE,
	
	/** Protected field. */
	PROTECTED,
	
	/** Static field. */
	STATIC,
	
	/** Final field. */
	FINAL,
	
	/** Volatile field. */
	VOLATILE,
	
	/** Transient field. */
	TRANSIENT,
	
	/** Synthetic field. */
	SYNTHETIC,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * Returns the bit mask which is used for this flag.
	 *
	 * @return The bit mask used for the flag.
	 * @since 2017/07/07
	 */
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:	return 0x0001;
			case PRIVATE:	return 0x0002;
			case PROTECTED:	return 0x0004;
			case STATIC:	return 0x0008;
			case FINAL:		return 0x0010;
			case VOLATILE:	return 0x0040;
			case TRANSIENT:	return 0x0080;
			case SYNTHETIC:	return 0x1000;
			case ENUM:		return 0x4000;

			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210


















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represent the set of flags for fields.
 *
 * @since 2016/04/23
 */
public final class FieldFlags
	extends MemberFlags<FieldFlag>
	implements AccessibleFlags
{
	/**
	 * Decodes field flags from the bit field and performs no checking.
	 *
	 * @param __i The bitfield to decode.
	 * @since 2019/04/18
	 */
	public FieldFlags(int __i)
	{
		super(FieldFlag.class,
			Flags.<FieldFlag>__decode(__i, FieldFlag.values()));
	}
	
	/**
	 * Initializes the field flags.
	 *
	 * @param __oc The outer class.
	 * @param __fl The field flags.
	 * @since 2016/04/23
	 */
	public FieldFlags(ClassFlags __oc, FieldFlag... __fl)
	{
		super(FieldFlag.class, __fl);
		
		__checkFlags(__oc);
	}
	
	/**
	 * Initializes the field flags.
	 *
	 * @param __oc The outer class.
	 * @param __fl The field flags.
	 * @since 2016/04/23
	 */
	public FieldFlags(ClassFlags __oc, Iterable<FieldFlag> __fl)
	{
		super(FieldFlag.class, __fl);
		
		__checkFlags(__oc);
	}
	
	/**
	 * Decodes field flags from the bit field.
	 *
	 * @param __oc The outer class flags.
	 * @param __i The bitfield to decode.
	 * @since 2017/07/07
	 */
	public FieldFlags(ClassFlags __oc, int __i)
	{
		this(__oc, Flags.<FieldFlag>__decode(__i, FieldFlag.values()));
	}
	
	/**
	 * Returns {@code true} if this is an enumeration.
	 *
	 * @return {@code true} if an enumeration.
	 * @since 2016/03/20
	 */
	public boolean isEnum()
	{
		return contains(FieldFlag.ENUM);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isFinal()
	{
		return contains(FieldFlag.FINAL);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPrivate()
	{
		return contains(FieldFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isProtected()
	{
		return contains(FieldFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPublic()
	{
		return contains(FieldFlag.PUBLIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isStatic()
	{
		return contains(FieldFlag.STATIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isSynthetic()
	{
		return contains(FieldFlag.SYNTHETIC);
	}
	
	/**
	 * Returns {@code true} if this is transient.
	 *
	 * @return {@code true} if transient.
	 * @since 2016/03/20
	 */
	public boolean isTransient()
	{
		return contains(FieldFlag.TRANSIENT);
	}
	
	/**
	 * Returns {@code true} if this is volatile.
	 *
	 * @return {@code true} if volatile.
	 * @since 2016/03/20
	 */
	public boolean isVolatile()
	{
		return contains(FieldFlag.VOLATILE);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @param __oc The outer class.
	 * @throws InvalidClassFormatException If they are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	private final void __checkFlags(ClassFlags __oc)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__oc == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC2u A field cannot be both {@code final} and
		// {@code volatile}. (The field flags)}
		if (isFinal() && isVolatile())
			throw new InvalidClassFormatException(
				String.format("JC2u %s", this));
		
		// If the class is an interface, some flags cannot be set
		if (__oc.isInterface())
			for (FieldFlag f : FieldFlag.values())
			{
				// Must have these
				boolean must = (f == FieldFlag.PUBLIC ||
					f == FieldFlag.STATIC || f == FieldFlag.FINAL);
				
				// Could have these
				boolean maybe = (f == FieldFlag.SYNTHETIC);
				
				// Is it set?
				boolean has = contains(f);
				
				// {@squirreljme.error JC2v Flags for interface field has an
				// incorrect set of flags. (The field flags)}
				if (must != has && !maybe)
					throw new InvalidClassFormatException(
						String.format("JC2v %s", this));
			}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldName.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the name of a field. It has the same constraints as
 * identifiers.
 *
 * @since 2017/07/07
 */
public final class FieldName
	extends Identifier
	implements Comparable<FieldName>, MemberName
{
	/**
	 * Initializes the field name.
	 *
	 * @param __s The field name.
	 * @since 2017/07/07
	 */
	public FieldName(String __s)
	{
		super(__s);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int compareTo(FieldName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof FieldName) && super.equals(__o);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldNameAndType.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
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































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the name and type for a field.
 *
 * @since 2017/10/12
 */
public final class FieldNameAndType
	implements Comparable<FieldNameAndType>, MemberNameAndType
{
	/** The field name. */
	protected final FieldName name;
	
	/** The field type. */
	protected final FieldDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the field name and type.
	 *
	 * @param __n The name of the field.
	 * @param __t The type of the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/12
	 */
	public FieldNameAndType(FieldName __n, FieldDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int compareTo(FieldNameAndType __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.type.toString().compareTo(__o.type.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof FieldNameAndType))
			return false;
		
		FieldNameAndType o = (FieldNameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s:%s",
				this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/12
	 */
	@Override
	public FieldDescriptor type()
	{
		return this.type;
	}
}


Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FieldReference.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
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


















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This describes a reference to a field.
 *
 * @since 2017/06/12
 */
public final class FieldReference
	extends MemberReference
{
	/** The name of the field. */
	protected final FieldName name;
	
	/** The member type. */
	protected final FieldDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Name and type. */
	private Reference<FieldNameAndType> _nat;
	
	/**
	 * Initializes the field reference.
	 *
	 * @param __c The class the member resides in.
	 * @param __i The name of the member.
	 * @param __t The descriptor of the member.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public FieldReference(ClassName __c, FieldName __i, FieldDescriptor __t)
		throws NullPointerException
	{
		super(__c);
		
		// Check
		if (__t == null || __i == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __i;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof FieldReference))
			return false;
		
		FieldReference o = (FieldReference)__o;
		return this.classname.equals(o.classname) &&
			this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.classname.hashCode() ^
			this.name.hashCode() ^
			this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/08
	 */
	@Override
	public final FieldName memberName()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldNameAndType memberNameAndType()
	{
		Reference<FieldNameAndType> ref = this._nat;
		FieldNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>(
				(rv = new FieldNameAndType(this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final FieldDescriptor memberType()
	{
		return this.type;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"field %s::%s %s", this.classname, this.name,
				this.type)));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Flag.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface is used to flag the types used for flags.
 *
 * @since 2016/04/23
 */
public interface Flag
{
	/**
	 * Returns the bit mask of the given flag.
	 *
	 * @return The bit mask of the given flag.
	 * @since 2017/07/07
	 */
	public abstract int javaBitMask();
	
	/**
	 * Returns the flag ordinal.
	 *
	 * @return The ordinal of the flag.
	 * @since 2016/04/23
	 */
	public abstract int ordinal();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Flags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232








































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * This is the base class for all flag collections.
 *
 * @param <F> The flag type.
 * @since 2016/04/23
 */
public abstract class Flags<F extends Flag>
	extends AbstractSet<F>
{
	/** The class type to use. */
	protected final Class<F> cast;
	
	/** The set ordinals. */
	protected final int setbits;
	
	/** The slower access set. */
	private final Set<F> _flags;
	
	/**
	 * Initializes the flag set.
	 *
	 * @param __cl The class type of the flag.
	 * @param __fl The input flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	Flags(Class<F> __cl, F[] __fl)
		throws NullPointerException
	{
		this(__cl, Arrays.<F>asList(__fl));
	}
	
	/**
	 * Initializes the flag set.
	 *
	 * @param __cl The class type of the flag.
	 * @param __fl The input flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	Flags(Class<F> __cl, Iterable<F> __fl)
	{
		// Check
		if (__cl == null || __fl == null)
			throw new NullPointerException("NARG");
		
		// Set
		cast = __cl;
		
		// Go through all input flags
		Set<F> to = new HashSet<>();
		int bits = 0;
		for (F f : __fl)
		{
			// Get ordinal
			int o = f.ordinal();
			
			// Set it
			bits |= (1 << o);
			
			// Add to flag set
			to.add(f);
		}
		
		// Lock in
		this.setbits = bits;
		this._flags = to;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final boolean contains(Object __o)
	{
		if (!(__o instanceof Flag))
			return false;
		
		// Quick bit check?
		if (cast.isInstance(__o))
			return 0 != (this.setbits & (1 << (((Flag)__o).ordinal())));
		
		// Fallback
		return this._flags.contains(__o);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final Iterator<F> iterator()
	{
		return new __Iterator__<F>(this._flags.iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/04/23
	 */
	@Override
	public final int size()
	{
		return this._flags.size();
	}
	
	/**
	 * Converts the flags to Java bits.
	 *
	 * @return The Java bits.
	 * @since 2018/12/04
	 */
	public final int toJavaBits()
	{
		int rv = 0;
		
		for (Flag f : this)
			rv |= f.javaBitMask();
		
		return rv;
	}
	
	/**
	 * Decodes the specified bitfield and returns the used flags.
	 *
	 * @param <F> The type of flags to decode.
	 * @param __i The input bitfield.
	 * @param __f The flag values to decode.
	 * @return The flags specified in the bitfield.
	 * @throws InvalidClassFormatException If extra flags were specified.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/13
	 */
	static <F extends Flag> Iterable<F> __decode(int __i, F[] __f)
		throws InvalidClassFormatException, NullPointerException
	{
		// Find all matching flags in the bitfield
		List<F> fl = new ArrayList<>(__f.length);
		for (F f : __f)
		{
			int v = f.javaBitMask();
			if (0 != (__i & v))
			{
				fl.add(f);
				__i ^= v;
			}
		}
		
		// {@squirreljme.error JC2w An undefined flag has been specified.
		// (The extra bitfield flags)}
		if (__i != 0)
			throw new InvalidClassFormatException(
				String.format("JC2w %02x", __i));
		
		return fl;
	}
	
	/**
	 * Iterates over flags.
	 *
	 * @since 2017/01/28
	 */
	private static final class __Iterator__<F>
		implements Iterator<F>
	{
		/** The iterator used. */
		protected final Iterator<F> iterator;
		
		/**
		 * Wraps the iterator.
		 *
		 * @param __it The iterator to wrap.
		 * @since 2017/01/28
		 */
		private __Iterator__(Iterator<F> __it)
		{
			this.iterator = __it;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public boolean hasNext()
		{
			return this.iterator.hasNext();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public F next()
		{
			return this.iterator.next();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/01/28
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FormalParameter.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a single formal parameter which is used as input for a
 * method call.
 *
 * @since 2018/05/14
 */
public final class FormalParameter
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/FormalParameters.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This class stores and represents the formal parameters of a method.
 *
 * @since 2018/05/14
 */
public final class FormalParameters
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/HasAccessibleFlags.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface represents anything that has accessible flags.
 *
 * @since 2018/09/09
 */
public interface HasAccessibleFlags
{
	/**
	 * Returns accessible flags.
	 *
	 * @return The accessible flags.
	 * @since 2018/09/09
	 */
	public abstract AccessibleFlags flags();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/HasMemberFlags.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents anything which has member flags.
 *
 * @since 2018/09/09
 */
public interface HasMemberFlags
	extends HasAccessibleFlags
{
	/**
	 * Returns member flags.
	 *
	 * @return The member flags.
	 * @since 2018/09/09
	 */
	@Override
	public abstract MemberFlags flags();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Identifier.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
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




































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an identifier which acts as a name of a fragment of a class
 * or a member of a class.
 *
 * @since 2017/06/12
 */
public abstract class Identifier
{
	/** The string which makes up the identifier. */
	protected final String string;
	
	/**
	 * Initializes the identifier.
	 *
	 * @param __n The input identifier to decode.
	 * @throws InvalidClassFormatException If it is not a valid identifier.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	Identifier(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// Check characters
		for (int i = 0, n = __n.length(); i < n; i++)
		{
			char c = __n.charAt(i);
			
			// {@squirreljme.error JC2x The specified identifier contains an
			// invalid character. (The identifier)}
			if (c == '.' || c == ';' || c == '[' || c == '/')
				throw new InvalidClassFormatException(
					String.format("JC2x %s", __n));
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Identifier))
			return false;
		
		return this.string.equals(((Identifier)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2017/10/02
	 */
	public final String identifier()
	{
		return this.string;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InnerClass.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
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




































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * This represents an inner class that is contained within an outer class, it
 * is used by the compiler to determine how classes are contained within each
 * other.
 *
 * @since 2018/05/15
 */
public final class InnerClass
{
	/** The name of the inner class. */
	protected final ClassName name;
	
	/** The outer class this is contained within. */
	protected final ClassName outerclass;
	
	/** The simple name of the class as defined in the class. */
	protected final ClassIdentifier simplename;
	
	/** The flags for the inner class. */
	protected final InnerClassFlags flags;
	
	/**
	 * Initializes an anonymous inner class.
	 *
	 * @param __n The name of the class.
	 * @param __f The class flags.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/21
	 */
	public InnerClass(ClassName __n, InnerClassFlags __f)
		throws NullPointerException
	{
		if (__n == null || __f == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.outerclass = null;
		this.simplename = null;
		this.flags = __f;
	}
	
	/**
	 * Initializes a standard inner class.
	 *
	 * @param __n The name of the class.
	 * @param __o The class this is a member of. If this is {@code null} then
	 * the class is either: a top-level class/interface, a local class (one
	 * that exists only in a method), or is a member of an anonymous class.
	 * @param __i The identifier used to name the class.
	 * @param __f The class flags.
	 * @since 2018/05/21
	 */
	public InnerClass(ClassName __n, ClassName __o, ClassIdentifier __i,
		InnerClassFlags __f)
	{
		this.name = __n;
		this.outerclass = __o;
		this.simplename = __i;
		this.flags = __f;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the flags for the inner class.
	 *
	 * @return The inner class flags.
	 * @since 2018/06/16
	 */
	public final InnerClassFlags flags()
	{
		return this.flags;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this an anonymous class?
	 *
	 * @return Is this an anonymous class?
	 * @since 2018/06/16
	 */
	public final boolean isAnonymous()
	{
		return this.name != null &&
			this.outerclass == null &&
			this.simplename == null;
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The class name.
	 * @since 2018/06/16
	 */
	public final ClassName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the name of the outer class or {@code null} if it is anonymous.
	 *
	 * @return The name of the outer class or {@code null} if anonymous.
	 * @since 2018/06/16
	 */
	public final ClassName outerClass()
	{
		return this.outerclass;
	}
	
	/**
	 * Returns the simple name of the class.
	 *
	 * @return The simple name of the class.
	 * @since 2018/06/16
	 */
	public final ClassIdentifier simpleName()
	{
		return this.simplename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InnerClassFlag.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a flag which may be associated with an inner class.
 *
 * @since 2018/05/15
 */
public enum InnerClassFlag
	implements Flag
{
	/** Public. */
	PUBLIC,
	
	/** Private. */
	PRIVATE,
	
	/** Protected. */
	PROTECTED,
	
	/** Static. */
	STATIC,
	
	/** Final. */
	FINAL,
	
	/** Interface. */
	INTERFACE,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Synthetic. */
	SYNTHETIC,
	
	/** Annotation. */
	ANNOTATION,
	
	/** Enumeration. */
	ENUM,
	
	/** End. */
	;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case PRIVATE:		return 0x0002;
			case PROTECTED:		return 0x0004;
			case STATIC:		return 0x0008;
			case FINAL:			return 0x0010;
			case INTERFACE:		return 0x0200;
			case ABSTRACT:		return 0x0400;
			case SYNTHETIC:		return 0x1000;
			case ANNOTATION:	return 0x2000;
			case ENUM:			return 0x4000;
			
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InnerClassFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204












































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This represents a set of flags which are used as modifiers to inner classes.
 *
 * @since 2018/05/15
 */
public final class InnerClassFlags
	extends Flags<InnerClassFlag>
	implements AccessibleFlags
{
	/** Standard class flag representation. */
	private Reference<ClassFlags> _cflags;
	
	/**
	 * Initializes the inner class flags decoding from the specified bit field.
	 *
	 * @param __i The bit field to decode flags from.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(int __i)
	{
		this(Flags.<InnerClassFlag>__decode(__i, InnerClassFlag.values()));
	}
	
	/**
	 * Initializes the inner class flags.
	 *
	 * @param __fl The inner class flags.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(InnerClassFlag... __fl)
	{
		super(InnerClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Initializes the inner class flags.
	 *
	 * @param __fl The inner class flags.
	 * @since 2018/05/15
	 */
	public InnerClassFlags(Iterable<InnerClassFlag> __fl)
	{
		super(InnerClassFlag.class, __fl);
		
		this.__checkFlags();
	}
	
	/**
	 * Returns the outer class representation for these flags.
	 *
	 * @return The outer class flag representation.
	 * @since 2018/05/21
	 */
	public final ClassFlags asClassFlags()
	{
		Reference<ClassFlags> ref = this._cflags;
		ClassFlags rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			int mask = 0;
			for (InnerClassFlag i : this)
			{
				ClassFlag v;
				switch (i)
				{
					case PUBLIC:
						v = ClassFlag.PUBLIC;
						break;
						
					case FINAL:
						v = ClassFlag.FINAL;
						break;
						
					case INTERFACE:
						v = ClassFlag.INTERFACE;
						break;
						
					case ABSTRACT:
						v = ClassFlag.ABSTRACT;
						break;
						
					case SYNTHETIC:
						v = ClassFlag.SYNTHETIC;
						break;
						
					case ANNOTATION:
						v = ClassFlag.ANNOTATION;
						break;
						
					case ENUM:
						v = ClassFlag.ENUM;
						break;
					
					default:
						v = null;
						continue;
				}
				
				if (v != null)
					mask |= v.javaBitMask();
			}
			
			this._cflags = new WeakReference<>((rv = new ClassFlags(mask)));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !this.isPrivate() && !this.isProtected() && !this.isPublic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPrivate()
	{
		return this.contains(InnerClassFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isProtected()
	{
		return this.contains(InnerClassFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean isPublic()
	{
		return this.contains(InnerClassFlag.PUBLIC);
	}
	
	/**
	 * Checks that the inner class flags are valid.
	 *
	 * @throws InvalidClassFormatException If the inner class flags are not
	 * valid.
	 * @since 2018/05/15
	 */
	private final void __checkFlags()
		throws InvalidClassFormatException
	{
		// Construct class flags which checks if they are valid
		try
		{
			this.asClassFlags();
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error JC2y Inner class flags are not valid
			// because they would produce invalid standard outer class
			// flags. (The flags)}
			throw new InvalidClassFormatException(String.format("JC2y %s",
				this), e);
		}
		
		// {@squirreljme.error JC2z Multiple access modifiers, inner classes
		// can only be one or none of private, protected, or public.
		// (The flags)}
		int count = (this.isPublic() ? 1 : 0) +
			(this.isProtected() ? 1 : 0) +
			(this.isPrivate() ? 1 : 0);
		if (count > 1)
			throw new InvalidClassFormatException(String.format("JC2z %s",
				this));
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InnerClasses.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
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











































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This contains the table of inner class references.
 *
 * @since 2018/05/15
 */
public final class InnerClasses
	implements Iterable<InnerClass>
{
	/** The declared inner classes. */
	private final InnerClass[] _inners;
	
	/**
	 * Initializes the inner classes.
	 *
	 * @param __i The inner classes.
	 * @throws InvalidClassFormatException If the inner classes are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/16
	 */
	public InnerClasses(InnerClass... __i)
		throws InvalidClassFormatException, NullPointerException
	{
		this(Arrays.<InnerClass>asList((__i != null ? __i :
			new InnerClass[0])));
	}
	
	/**
	 * Initializes the inner classes.
	 *
	 * @param __i The inner classes.
	 * @throws InvalidClassFormatException If the inner classes are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/16
	 */
	public InnerClasses(Iterable<InnerClass> __i)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		List<InnerClass> rv = new ArrayList<>();
		for (InnerClass i : __i)
		{
			if (i == null)
				throw new NullPointerException("NARG");
			
			rv.add(i);
		}
		
		this._inners = rv.<InnerClass>toArray(new InnerClass[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/06/16
	 */
	@Override
	public final Iterator<InnerClass> iterator()
	{
		return UnmodifiableIterator.<InnerClass>of(this._inners);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/15
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses the information which pertains to the inner classes.
	 *
	 * @param __pool The constant pool.
	 * @param __attrs The input attributes.
	 * @return The parsed inner class information.
	 * @throws InvalidClassFormatException If the inner classes are not
	 * correct.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static final InnerClasses parse(Pool __pool,
		AttributeTable __attrs)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__pool == null || __attrs == null)
			throw new NullPointerException("NARG");
		
		// Only if the attribute exists
		Attribute attr = __attrs.get("InnerClasses");
		if (attr == null)
			return new InnerClasses();
		
		List<InnerClass> rv = new ArrayList<>();
		try (DataInputStream in = attr.open())
		{
			// Read each one
			int n = in.readUnsignedShort();
			for (int i = 0; i < n; i++)
			{
				ClassName innerclass = __pool.<ClassName>require(
					ClassName.class, in.readUnsignedShort());
				ClassName outerclass = __pool.<ClassName>get(
					ClassName.class, in.readUnsignedShort());
				
				UTFConstantEntry rawname = __pool.<UTFConstantEntry>get(
					UTFConstantEntry.class, in.readUnsignedShort());
				ClassIdentifier name = (rawname == null ? null :
					new ClassIdentifier(rawname.toString()));
				
				InnerClassFlags flags = new InnerClassFlags(
					in.readUnsignedShort());
				
				// Add them
				if (outerclass == null && name == null)
					rv.add(new InnerClass(innerclass, flags));
				else
				{
					rv.add(new InnerClass(innerclass, outerclass,
						name, flags));
				}
			}
		}
		
		return new InnerClasses(rv);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Instruction.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893





























































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * This represents a single instruction within the byte code.
 *
 * @since 2017/10/15
 */
public final class Instruction
{
	/** The instruction address. */
	protected final int address;
	
	/** The instruction operation. */
	protected final int op;
	
	/** Does this instruction naturally flow? */
	protected final boolean naturalflow;
	
	/** Stack map table entry for this instruction. */
	protected final StackMapTableState smtstate;
	
	/** Jump targets. */
	protected final InstructionJumpTargets jumptargets;
	
	/** Instruction arguments. */
	private final Object[] _args;
	
	/** String representation of the operation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the instruction information.
	 *
	 * @param __code The instruction bytes.
	 * @param __pool The constant pool.
	 * @param __a The instruction address.
	 * @param __eh Exception handler table.
	 * @param __smt The stack map table data.
	 * @param __af Address of the instruction which follows this.
	 * @throws InvalidClassFormatException If the instruction is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/18
	 */
	Instruction(byte[] __code, Pool __pool, int __a,
		ExceptionHandlerTable __eh, StackMapTable __smt, int __af)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__code == null || __pool == null || __smt == null)
			throw new NullPointerException("NARG");
		
		// Get potential stack map entry for this instruction
		this.smtstate = __smt.get(__a);
		
		// Calculate real instruction address
		int aa = __a + ByteCode._CODE_OFFSET;
		
		// Read operation here
		int op = (__code[aa] & 0xFF),
			argbase = aa + 1;
		if (op == InstructionIndex.WIDE)
		{
			op = (op << 8) | (__code[aa + 1] & 0xFF);
			argbase++;
		}
		this.op = op;
		this.address = __a;
		
		// Depends on the operation
		Object[] args;
		boolean naturalflow;
		switch (op)
		{
				// No arguments and does not flow naturally
			case InstructionIndex.ATHROW:
			case InstructionIndex.ARETURN:
			case InstructionIndex.DRETURN:
			case InstructionIndex.FRETURN:
			case InstructionIndex.IRETURN:
			case InstructionIndex.LRETURN:
			case InstructionIndex.RETURN:
				args = new Object[0];
				naturalflow = false;
				break;
			
				// Operands with no arguments, natural flow
			case InstructionIndex.AALOAD:
			case InstructionIndex.AASTORE:
			case InstructionIndex.ACONST_NULL:
			case InstructionIndex.ALOAD_0:
			case InstructionIndex.ALOAD_1:
			case InstructionIndex.ALOAD_2:
			case InstructionIndex.ALOAD_3:
			case InstructionIndex.ARRAYLENGTH:
			case InstructionIndex.ASTORE_0:
			case InstructionIndex.ASTORE_1:
			case InstructionIndex.ASTORE_2:
			case InstructionIndex.ASTORE_3:
			case InstructionIndex.BALOAD:
			case InstructionIndex.BASTORE:
			case InstructionIndex.CALOAD:
			case InstructionIndex.CASTORE:
			case InstructionIndex.D2F:
			case InstructionIndex.D2I:
			case InstructionIndex.D2L:
			case InstructionIndex.DADD:
			case InstructionIndex.DALOAD:
			case InstructionIndex.DASTORE:
			case InstructionIndex.DCMPG:
			case InstructionIndex.DCMPL:
			case InstructionIndex.DCONST_0:
			case InstructionIndex.DCONST_1:
			case InstructionIndex.DDIV:
			case InstructionIndex.DLOAD_0:
			case InstructionIndex.DLOAD_1:
			case InstructionIndex.DLOAD_2:
			case InstructionIndex.DLOAD_3:
			case InstructionIndex.DMUL:
			case InstructionIndex.DNEG:
			case InstructionIndex.DREM:
			case InstructionIndex.DSTORE_0:
			case InstructionIndex.DSTORE_1:
			case InstructionIndex.DSTORE_2:
			case InstructionIndex.DSTORE_3:
			case InstructionIndex.DSUB:
			case InstructionIndex.DUP:
			case InstructionIndex.DUP2:
			case InstructionIndex.DUP2_X1:
			case InstructionIndex.DUP2_X2:
			case InstructionIndex.DUP_X1:
			case InstructionIndex.DUP_X2:
			case InstructionIndex.F2D:
			case InstructionIndex.F2I:
			case InstructionIndex.F2L:
			case InstructionIndex.FADD:
			case InstructionIndex.FALOAD:
			case InstructionIndex.FASTORE:
			case InstructionIndex.FCMPG:
			case InstructionIndex.FCMPL:
			case InstructionIndex.FCONST_0:
			case InstructionIndex.FCONST_1:
			case InstructionIndex.FCONST_2:
			case InstructionIndex.FDIV:
			case InstructionIndex.FLOAD_0:
			case InstructionIndex.FLOAD_1:
			case InstructionIndex.FLOAD_2:
			case InstructionIndex.FLOAD_3:
			case InstructionIndex.FMUL:
			case InstructionIndex.FNEG:
			case InstructionIndex.FREM:
			case InstructionIndex.FSTORE_0:
			case InstructionIndex.FSTORE_1:
			case InstructionIndex.FSTORE_2:
			case InstructionIndex.FSTORE_3:
			case InstructionIndex.FSUB:
			case InstructionIndex.I2B:
			case InstructionIndex.I2C:
			case InstructionIndex.I2D:
			case InstructionIndex.I2F:
			case InstructionIndex.I2L:
			case InstructionIndex.I2S:
			case InstructionIndex.IADD:
			case InstructionIndex.IALOAD:
			case InstructionIndex.IAND:
			case InstructionIndex.IASTORE:
			case InstructionIndex.ICONST_0:
			case InstructionIndex.ICONST_1:
			case InstructionIndex.ICONST_2:
			case InstructionIndex.ICONST_3:
			case InstructionIndex.ICONST_4:
			case InstructionIndex.ICONST_5:
			case InstructionIndex.ICONST_M1:
			case InstructionIndex.IDIV:
			case InstructionIndex.ILOAD_0:
			case InstructionIndex.ILOAD_1:
			case InstructionIndex.ILOAD_2:
			case InstructionIndex.ILOAD_3:
			case InstructionIndex.IMUL:
			case InstructionIndex.INEG:
			case InstructionIndex.IOR:
			case InstructionIndex.IREM:
			case InstructionIndex.ISHL:
			case InstructionIndex.ISHR:
			case InstructionIndex.ISTORE_0:
			case InstructionIndex.ISTORE_1:
			case InstructionIndex.ISTORE_2:
			case InstructionIndex.ISTORE_3:
			case InstructionIndex.ISUB:
			case InstructionIndex.IUSHR:
			case InstructionIndex.IXOR:
			case InstructionIndex.L2D:
			case InstructionIndex.L2F:
			case InstructionIndex.L2I:
			case InstructionIndex.LADD:
			case InstructionIndex.LALOAD:
			case InstructionIndex.LAND:
			case InstructionIndex.LASTORE:
			case InstructionIndex.LCMP:
			case InstructionIndex.LCONST_0:
			case InstructionIndex.LCONST_1:
			case InstructionIndex.LDIV:
			case InstructionIndex.LLOAD_0:
			case InstructionIndex.LLOAD_1:
			case InstructionIndex.LLOAD_2:
			case InstructionIndex.LLOAD_3:
			case InstructionIndex.LMUL:
			case InstructionIndex.LNEG:
			case InstructionIndex.LOR:
			case InstructionIndex.LREM:
			case InstructionIndex.LSHL:
			case InstructionIndex.LSHR:
			case InstructionIndex.LSTORE_0:
			case InstructionIndex.LSTORE_1:
			case InstructionIndex.LSTORE_2:
			case InstructionIndex.LSTORE_3:
			case InstructionIndex.LSUB:
			case InstructionIndex.LUSHR:
			case InstructionIndex.LXOR:
			case InstructionIndex.MONITORENTER:
			case InstructionIndex.MONITOREXIT:
			case InstructionIndex.NOP:
			case InstructionIndex.POP:
			case InstructionIndex.POP2:
			case InstructionIndex.SALOAD:
			case InstructionIndex.SASTORE:
			case InstructionIndex.SWAP:
				args = new Object[0];
				naturalflow = true;
				break;
				
				// Argument is a class
			case InstructionIndex.ANEWARRAY:
			case InstructionIndex.CHECKCAST:
			case InstructionIndex.INSTANCEOF:
			case InstructionIndex.NEW:
				naturalflow = true;
				args = new Object[]{__pool.<ClassName>require(ClassName.class,
					Instruction.__readUnsignedShort(__code, argbase))};
				break;
				
				// First value is a signed byte
			case InstructionIndex.BIPUSH:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readByte(__code, argbase)};
				break;
				
				// First value is an unsigned byte
			case InstructionIndex.ALOAD:
			case InstructionIndex.ILOAD:
			case InstructionIndex.LLOAD:
			case InstructionIndex.FLOAD:
			case InstructionIndex.DLOAD:
			case InstructionIndex.ASTORE:
			case InstructionIndex.ISTORE:
			case InstructionIndex.LSTORE:
			case InstructionIndex.FSTORE:
			case InstructionIndex.DSTORE:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedByte(__code, argbase)};
				break;
				
				// First value is a signed short
			case InstructionIndex.SIPUSH:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readShort(__code, argbase)};
				break;
				
				// Read or write of a field
			case InstructionIndex.GETSTATIC:
			case InstructionIndex.PUTSTATIC:
			case InstructionIndex.GETFIELD:
			case InstructionIndex.PUTFIELD:
				naturalflow = true;
				args = new Object[]{__pool.<FieldReference>require(
					FieldReference.class,
					Instruction.__readUnsignedShort(__code, argbase))};
				break;
				
				// Goto
			case InstructionIndex.GOTO:
				naturalflow = false;
				args = new Object[]{new InstructionJumpTarget(
					__a + Instruction.__readShort(__code, argbase))};
				break;
				
				// Increment local variable
			case InstructionIndex.IINC:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedByte(__code, argbase),
					Instruction.__readByte(__code, argbase + 1)};
				break;
				
				// Increment local variable (wide)
			case InstructionIndex.WIDE_IINC:
				naturalflow = true;
				args = new Object[]{
					Instruction.__readUnsignedShort(__code, argbase),
					Instruction.__readShort(__code, argbase + 2)};
				break;
				
				// Branches
			case InstructionIndex.IFNONNULL:
			case InstructionIndex.IFNULL:
			case InstructionIndex.IF_ACMPEQ:
			case InstructionIndex.IF_ACMPNE:
			case InstructionIndex.IF_ICMPEQ:
			case InstructionIndex.IF_ICMPNE:
			case InstructionIndex.IF_ICMPLT:
			case InstructionIndex.IF_ICMPGE:
			case InstructionIndex.IF_ICMPGT:
			case InstructionIndex.IF_ICMPLE:
			case InstructionIndex.IFEQ:
			case InstructionIndex.IFNE:
			case InstructionIndex.IFLT:
			case InstructionIndex.IFGE:
			case InstructionIndex.IFGT:
			case InstructionIndex.IFLE:
				naturalflow = true;
				args = new Object[]{new InstructionJumpTarget(
					__a + Instruction.__readShort(__code, argbase))};
				break;
				
				// Method invocations
			case InstructionIndex.INVOKEINTERFACE:
			case InstructionIndex.INVOKESPECIAL:
			case InstructionIndex.INVOKESTATIC:
			case InstructionIndex.INVOKEVIRTUAL:
				naturalflow = true;
				
				// Reference is in the constant pool
				MethodReference mr = __pool.<MethodReference>require(
					MethodReference.class,
					Instruction.__readUnsignedShort(__code, argbase));
				
				// {@squirreljme.error JC31 Invocation of method did not
				// have the matching interface/not-interface attribute.
				// (The operation; The address; The method reference)}
				if (mr.isInterface() !=
					(op == InstructionIndex.INVOKEINTERFACE))
					throw new InvalidClassFormatException(String.format(
						"JC31 %d %d %s", op, __a, mr));
				
				args = new Object[]{mr};
				break;
				
				// Load constant value
			case InstructionIndex.LDC:
			case InstructionIndex.LDC_W:
				naturalflow = true;
				
				// Could vary in type
				Object ldcv = __pool.<Object>require(Object.class,
					(op == InstructionIndex.LDC_W ?
					Instruction.__readUnsignedShort(__code, argbase) :
					Instruction.__readUnsignedByte(__code, argbase)));
				
				// Turn into a class value
				ConstantValue cvalue;
				if (ldcv instanceof ClassName)
					cvalue = new ConstantValueClass((ClassName)ldcv);
				else
					cvalue = (ConstantValue)ldcv;
				
				// {@squirreljme.error JC32 Cannot load a constant value which
				// is not of a narrow type. (The operation; The address; The
				// constant value)}
				if (!cvalue.type().isNarrow())
					throw new InvalidClassFormatException(String.format(
						"JC32 %d %d %s", op, __a, cvalue));
				
				// Just use this value
				args = new Object[]{cvalue};
				break;
				
				// Load wide constant value
			case InstructionIndex.LDC2_W:
				naturalflow = true;
				
				// Just will be a constant value type
				cvalue = __pool.<ConstantValue>require(
					ConstantValue.class,
					Instruction.__readUnsignedShort(__code, argbase));
				
				// {@squirreljme.error JC33 Cannot load a constant value which
				// is not of a wide type. (The operation; The address;
				// The constant value)}
				if (!cvalue.type().isWide())
					throw new InvalidClassFormatException(String.format(
						"JC33 %d %d %s", op, __a, cvalue));
				
				// Just use this value
				args = new Object[]{cvalue};
				break;
				
				// Allocate array of primitive type
			case InstructionIndex.NEWARRAY:
				naturalflow = true;
				
				// The primitive type depends
				PrimitiveType pt;
				int pd;
				switch ((pd = Instruction.__readUnsignedByte(__code, argbase)))
				{
					case 4:		pt = PrimitiveType.BOOLEAN; break;
					case 5:		pt = PrimitiveType.CHARACTER; break;
					case 6:		pt = PrimitiveType.FLOAT; break;
					case 7:		pt = PrimitiveType.DOUBLE; break;
					case 8:		pt = PrimitiveType.BYTE; break;
					case 9:		pt = PrimitiveType.SHORT; break;
					case 10:	pt = PrimitiveType.INTEGER; break;
					case 11:	pt = PrimitiveType.LONG; break;
					
						// {@squirreljme.error JC34 Unknown type specified for
						// new primitive array. (The operation; The address;
						// The type specifier)}
					default:
						throw new InvalidClassFormatException(String.format(
							"JC34 %d %d %d", op, __a, pd));
				}
				args = new Object[]{pt};
				break;
				
				// New multi-dimensional array
			case InstructionIndex.MULTIANEWARRAY:
				naturalflow = true;
				
				ClassName cname = __pool.<ClassName>require(ClassName.class,
					Instruction.__readUnsignedShort(__code, argbase));
				int dims = Instruction.__readUnsignedByte(__code,
					argbase + 2);
				
				// {@squirreljme.error JC35 Dimensions represented in type
				// is smaller than the represented dimensions.
				// (The operation; The address; The dimensions)}
				if (cname.dimensions() < dims)
					throw new InvalidClassFormatException(String.format(
						"JC35 %d %d %d", op, __a, dims));
				
				args = new Object[]{cname, dims};
				break;
			
				// Lookup switch lookup table
			case InstructionIndex.LOOKUPSWITCH:
				{
					// Determine the real address of the table
					int pa = ((aa + 4) & (~3));
					
					// Read in the default
					InstructionJumpTarget def = new InstructionJumpTarget(
						__a + Instruction.__readInt(__code, pa));
					
					// {@squirreljme.error JC36 Pair count for lookup switch
					// is negative. (The opcode; The address; The after padded
					// address; The read length)}
					int n = Instruction.__readInt(__code, pa + 4);
					if (n < 0)
						throw new InvalidClassFormatException(String.format(
							"JC36 %d %d %d %d", op, __a, pa, n));
					
					// Setup
					int[] keys = new int[n];
					InstructionJumpTarget[] jumps =
						new InstructionJumpTarget[n];
					
					// Load in tables
					for (int i = 0, ra = pa + 8; i < n; i++, ra += 8)
					{
						keys[i] = Instruction.__readInt(__code, ra);
						jumps[i] = new InstructionJumpTarget(
							__a + Instruction.__readInt(__code, ra + 4));
					}
					
					// Setup instruction properties
					naturalflow = true;
					args = new Object[]{new LookupSwitch(def, keys, jumps)};
				}
				break;
			
				// Table switch lookup table
			case InstructionIndex.TABLESWITCH:
				{
					// Determine the real address of the table
					int pa = ((aa + 4) & (~3));
					
					// Read in the default
					InstructionJumpTarget def = new InstructionJumpTarget(
						__a + Instruction.__readInt(__code, pa));
					
					// Read in low and high
					int lo = Instruction.__readInt(__code, pa + 4),
						hi = Instruction.__readInt(__code, pa + 8);
					
					// Read jump targets
					int n = (hi - lo) + 1;
					InstructionJumpTarget[] jumps =
						new InstructionJumpTarget[n];
					
					// Load in tables
					for (int i = 0, ra = pa + 12; i < n; i++, ra += 4)
						jumps[i] = new InstructionJumpTarget(
							__a + Instruction.__readInt(__code, ra));
					
					// Setup instruction properties
					naturalflow = true;
					args = new Object[]{new TableSwitch(def, lo, hi, jumps)};
				}
				break;
				
				// {@squirreljme.error JC37 The operation at the specified
				// address is not supported yet. (The operation; The name of
				// the operation; The address it is at)}
			default:
				throw new RuntimeException(String.format("JC37 %d %s %d",
					op, InstructionMnemonics.toString(op), __a));
		}
		
		// Set
		this._args = args;
		this.naturalflow = naturalflow;
		
		// Figure out normal jump targets
		Set<InstructionJumpTarget> normal = new LinkedHashSet<>();
		if (naturalflow)
			normal.add(new InstructionJumpTarget(__af));
		for (int i = 0, n = args.length; i < n; i++)
		{
			Object v = args[i];
			
			// Jump
			if (v instanceof InstructionJumpTarget)
				normal.add((InstructionJumpTarget)v);
			
			// A table
			else if (v instanceof IntMatchingJumpTable)
				for (InstructionJumpTarget j :
					((IntMatchingJumpTable)v).targets())
					normal.add(j);
		}
		
		// Determine exceptional jump targets
		Set<InstructionJumpTarget> exception = new LinkedHashSet<>();
		for (ExceptionHandler eh : __eh)
			if (eh.inRange(__a))
				exception.add(new InstructionJumpTarget(eh.handlerAddress()));
		
		// Set jump targets
		this.jumptargets = new InstructionJumpTargets(
			normal.<InstructionJumpTarget>toArray(
				new InstructionJumpTarget[normal.size()]),
			exception.<InstructionJumpTarget>toArray(
				new InstructionJumpTarget[exception.size()]));
	}
	
	/**
	 * Returns the address of this instruction.
	 *
	 * @return The instruction address.
	 * @since 2017/05/20
	 */
	public int address()
	{
		return this.address;
	}
	
	/**
	 * Returns the argument for this given instruction.
	 *
	 * @param <T> The type of argument to get.
	 * @param __i The index of the argument.
	 * @param __cl The class to cast to.
	 * @return The argument as the given class.
	 * @throws ClassCastException If the class is not castable.
	 * @throws IndexOutOfBoundsException If the argument index is not
	 * within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/05/20
	 */
	public <T> T argument(int __i, Class<T> __cl)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return __cl.cast(this._args[__i]);
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/03
	 */
	public final Object[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Obtains the given argument as a byte.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public byte byteArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).byteValue();
	}
	
	/**
	 * The number of arguments the instruction takes.
	 *
	 * @return The argument count.
	 * @since 2017/05/20
	 */
	public int count()
	{
		return this._args.length;
	}
	
	/**
	 * Returns {@code true} if the instruction has natural flow.
	 *
	 * @return The instruction flows to the next naturally.
	 * @since 2017/05/20
	 */
	public boolean hasNaturalFlow()
	{
		return this.naturalflow;
	}
	
	/**
	 * Obtains the given argument as an integer.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an integer.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2017/09/02
	 */
	public int intArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Integer>argument(__i, Integer.class).intValue();
	}
	
	/**
	 * Returns the jump targets for this instruction.
	 *
	 * @return The jump targets for this instruction.
	 * @since 2019/03/30
	 */
	public final InstructionJumpTargets jumpTargets()
	{
		return this.jumptargets;
	}
	
	/**
	 * Returns the mnemonic of this instruction.
	 *
	 * @return The instruction mnemonic.
	 * @since 2018/09/20
	 */
	public final String mnemonic()
	{
		return InstructionMnemonics.toString(this.op);
	}
	
	/**
	 * Returns the operation that this performs.
	 *
	 * @return The operation.
	 * @since 2017/05/20
	 */
	public int operation()
	{
		return op;
	}
	
	/**
	 * Obtains the given argument as a short.
	 *
	 * @param __i The argument to get.
	 * @return The value of the argument.
	 * @throws ClassCastException If the given argument is not an number.
	 * @throws IndexOutOfBoundsException If the index is not within the
	 * bounds of the instruction arguments.
	 * @since 2019/04/03
	 */
	public final short shortArgument(int __i)
		throws ClassCastException, IndexOutOfBoundsException
	{
		return this.<Number>argument(__i, Number.class).shortValue();
	}
	
	/**
	 * Returns the stack map table state for this entry.
	 *
	 * @return The stack map table state.
	 * @since 2017/10/16
	 */
	public StackMapTableState stackMapTableState()
	{
		return this.smtstate;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/05/20
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Address first
			StringBuilder sb = new StringBuilder("@");
			sb.append(this.address);
			
			// Then the operation
			sb.append('#');
			sb.append(InstructionMnemonics.toString(this.op));
			
			// Add marker if it flows naturally
			if (this.naturalflow)
				sb.append('~');
			
			// Then the arguments
			sb.append(":[");
			Object[] args = this._args;
			for (int i = 0, n = args.length; i < n; i++)
			{
				if (i > 0)
					sb.append(", ");
				sb.append(args[i]);
			}
			sb.append(']');
			
			// Cache
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Reads a signed byte from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	static final int __readByte(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		return (byte)Instruction.__readUnsignedByte(__a, __o);
	}
	
	/**
	 * Reads a signed int from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/18
	 */
	static final int __readInt(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC38 Illegal int read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o + 3 >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC38 %d %d", __o, __a.length));
		
		return ((__a[__o] & 0xFF) << 24)  |
			((__a[__o + 1] & 0xFF) << 16)  |
			((__a[__o + 2] & 0xFF) << 8) |
			(__a[__o + 3] & 0xFF);
	}
	
	/**
	 * Reads a signed short from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/15
	 */
	static final int __readShort(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		return (short)Instruction.__readUnsignedShort(__a, __o);
	}
	
	/**
	 * Reads an unsigned byte from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/08
	 */
	static final int __readUnsignedByte(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC39 Illegal byte read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC39 %d %d", __o, __a.length));
		
		return (__a[__o] & 0xFF);
	}
	
	/**
	 * Reads an unsigned short from the specified array.
	 *
	 * @param __a The array to read from.
	 * @param __o The offset to read from.
	 * @return The read value.
	 * @throws InvalidClassFormatException If the offset exceeds the bounds of
	 * the given array.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/15
	 */
	static final int __readUnsignedShort(byte[] __a, int __o)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__a == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3a Illegal short read off the end of the
		// instruction array. (The offset; The length of the code array)}
		if (__o < 0 || __o + 1 >= __a.length)
			throw new InvalidClassFormatException(
				String.format("JC3a %d %d", __o, __a.length));
		
		return ((__a[__o] & 0xFF) << 8) | (__a[__o + 1] & 0xFF);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InstructionAddressRange.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a range of instruction addresses, the start is inclusive
 * and the end is exclusive.
 *
 * @since 2019/03/21
 */
public final class InstructionAddressRange
	implements Comparable<InstructionAddressRange>
{
	/** The start address. */
	protected final int start;
	
	/** The end address. */
	protected final int end;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the address range.
	 *
	 * @param __s The start address.
	 * @param __e The end address.
	 * @since 2019/03/21
	 */
	public InstructionAddressRange(int __s, int __e)
	{
		this.start = __s;
		this.end = __e;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int compareTo(InstructionAddressRange __b)
	{
		int rv = this.start - __b.start;
		if (rv != 0)
			return rv;
		
		return this.end - __b.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof InstructionAddressRange))
			return false;
		
		InstructionAddressRange o = (InstructionAddressRange)__o;
		return this.start == o.start &&
			this.end == o.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final int hashCode()
	{
		return this.start ^ (~this.end);
	}
	
	/**
	 * Checks if the given address is in the range of this range.
	 *
	 * @param __pc The address to check.
	 * @return If the address is in range.
	 * @since 2019/03/22
	 */
	public final boolean inRange(int __pc)
	{
		return __pc >= this.start && __pc < this.end;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = "@[" + this.start +
				"-" + this.end + ")"));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InstructionIndex.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885





















































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface contains instruction identification numbers which identify
 * opcodes based on their opcode ID.
 *
 * @since 2016/08/24
 */
public interface InstructionIndex
{
	/** NOP. */
	public static final int NOP =
		0;

	/** ACONST_NULL. */
	public static final int ACONST_NULL =
		1;

	/** ICONST_M1. */
	public static final int ICONST_M1 =
		2;

	/** ICONST_0. */
	public static final int ICONST_0 =
		3;

	/** ICONST_1. */
	public static final int ICONST_1 =
		4;

	/** ICONST_2. */
	public static final int ICONST_2 =
		5;

	/** ICONST_3. */
	public static final int ICONST_3 =
		6;

	/** ICONST_4. */
	public static final int ICONST_4 =
		7;

	/** ICONST_5. */
	public static final int ICONST_5 =
		8;

	/** LCONST_0. */
	public static final int LCONST_0 =
		9;

	/** LCONST_1. */
	public static final int LCONST_1 =
		10;

	/** FCONST_0. */
	public static final int FCONST_0 =
		11;

	/** FCONST_1. */
	public static final int FCONST_1 =
		12;

	/** FCONST_2. */
	public static final int FCONST_2 =
		13;

	/** DCONST_0. */
	public static final int DCONST_0 =
		14;

	/** DCONST_1. */
	public static final int DCONST_1 =
		15;

	/** BIPUSH. */
	public static final int BIPUSH =
		16;

	/** SIPUSH. */
	public static final int SIPUSH =
		17;

	/** LDC. */
	public static final int LDC =
		18;

	/** LDC_W. */
	public static final int LDC_W =
		19;

	/** LDC2_W. */
	public static final int LDC2_W =
		20;

	/** ILOAD. */
	public static final int ILOAD =
		21;

	/** LLOAD. */
	public static final int LLOAD =
		22;

	/** FLOAD. */
	public static final int FLOAD =
		23;

	/** DLOAD. */
	public static final int DLOAD =
		24;

	/** ALOAD. */
	public static final int ALOAD =
		25;

	/** ILOAD_0. */
	public static final int ILOAD_0 =
		26;

	/** ILOAD_1. */
	public static final int ILOAD_1 =
		27;

	/** ILOAD_2. */
	public static final int ILOAD_2 =
		28;

	/** ILOAD_3. */
	public static final int ILOAD_3 =
		29;

	/** LLOAD_0. */
	public static final int LLOAD_0 =
		30;

	/** LLOAD_1. */
	public static final int LLOAD_1 =
		31;

	/** LLOAD_2. */
	public static final int LLOAD_2 =
		32;

	/** LLOAD_3. */
	public static final int LLOAD_3 =
		33;

	/** FLOAD_0. */
	public static final int FLOAD_0 =
		34;

	/** FLOAD_1. */
	public static final int FLOAD_1 =
		35;

	/** FLOAD_2. */
	public static final int FLOAD_2 =
		36;

	/** FLOAD_3. */
	public static final int FLOAD_3 =
		37;

	/** DLOAD_0. */
	public static final int DLOAD_0 =
		38;

	/** DLOAD_1. */
	public static final int DLOAD_1 =
		39;

	/** DLOAD_2. */
	public static final int DLOAD_2 =
		40;

	/** DLOAD_3. */
	public static final int DLOAD_3 =
		41;

	/** ALOAD_0. */
	public static final int ALOAD_0 =
		42;

	/** ALOAD_1. */
	public static final int ALOAD_1 =
		43;

	/** ALOAD_2. */
	public static final int ALOAD_2 =
		44;

	/** ALOAD_3. */
	public static final int ALOAD_3 =
		45;

	/** IALOAD. */
	public static final int IALOAD =
		46;

	/** LALOAD. */
	public static final int LALOAD =
		47;

	/** FALOAD. */
	public static final int FALOAD =
		48;

	/** DALOAD. */
	public static final int DALOAD =
		49;

	/** AALOAD. */
	public static final int AALOAD =
		50;

	/** BALOAD. */
	public static final int BALOAD =
		51;

	/** CALOAD. */
	public static final int CALOAD =
		52;

	/** SALOAD. */
	public static final int SALOAD =
		53;

	/** ISTORE. */
	public static final int ISTORE =
		54;

	/** LSTORE. */
	public static final int LSTORE =
		55;

	/** FSTORE. */
	public static final int FSTORE =
		56;

	/** DSTORE. */
	public static final int DSTORE =
		57;

	/** ASTORE. */
	public static final int ASTORE =
		58;

	/** ISTORE_0. */
	public static final int ISTORE_0 =
		59;

	/** ISTORE_1. */
	public static final int ISTORE_1 =
		60;

	/** ISTORE_2. */
	public static final int ISTORE_2 =
		61;

	/** ISTORE_3. */
	public static final int ISTORE_3 =
		62;

	/** LSTORE_0. */
	public static final int LSTORE_0 =
		63;

	/** LSTORE_1. */
	public static final int LSTORE_1 =
		64;

	/** LSTORE_2. */
	public static final int LSTORE_2 =
		65;

	/** LSTORE_3. */
	public static final int LSTORE_3 =
		66;

	/** FSTORE_0. */
	public static final int FSTORE_0 =
		67;

	/** FSTORE_1. */
	public static final int FSTORE_1 =
		68;

	/** FSTORE_2. */
	public static final int FSTORE_2 =
		69;

	/** FSTORE_3. */
	public static final int FSTORE_3 =
		70;

	/** DSTORE_0. */
	public static final int DSTORE_0 =
		71;

	/** DSTORE_1. */
	public static final int DSTORE_1 =
		72;

	/** DSTORE_2. */
	public static final int DSTORE_2 =
		73;

	/** DSTORE_3. */
	public static final int DSTORE_3 =
		74;

	/** ASTORE_0. */
	public static final int ASTORE_0 =
		75;

	/** ASTORE_1. */
	public static final int ASTORE_1 =
		76;

	/** ASTORE_2. */
	public static final int ASTORE_2 =
		77;

	/** ASTORE_3. */
	public static final int ASTORE_3 =
		78;

	/** IASTORE. */
	public static final int IASTORE =
		79;

	/** LASTORE. */
	public static final int LASTORE =
		80;

	/** FASTORE. */
	public static final int FASTORE =
		81;

	/** DASTORE. */
	public static final int DASTORE =
		82;

	/** AASTORE. */
	public static final int AASTORE =
		83;

	/** BASTORE. */
	public static final int BASTORE =
		84;

	/** CASTORE. */
	public static final int CASTORE =
		85;

	/** SASTORE. */
	public static final int SASTORE =
		86;

	/** POP. */
	public static final int POP =
		87;

	/** POP2. */
	public static final int POP2 =
		88;

	/** DUP. */
	public static final int DUP =
		89;

	/** DUP_X1. */
	public static final int DUP_X1 =
		90;

	/** DUP_X2. */
	public static final int DUP_X2 =
		91;

	/** DUP2. */
	public static final int DUP2 =
		92;

	/** DUP2_X1. */
	public static final int DUP2_X1 =
		93;

	/** DUP2_X2. */
	public static final int DUP2_X2 =
		94;

	/** SWAP. */
	public static final int SWAP =
		95;

	/** IADD. */
	public static final int IADD =
		96;

	/** LADD. */
	public static final int LADD =
		97;

	/** FADD. */
	public static final int FADD =
		98;

	/** DADD. */
	public static final int DADD =
		99;

	/** ISUB. */
	public static final int ISUB =
		100;

	/** LSUB. */
	public static final int LSUB =
		101;

	/** FSUB. */
	public static final int FSUB =
		102;

	/** DSUB. */
	public static final int DSUB =
		103;

	/** IMUL. */
	public static final int IMUL =
		104;

	/** LMUL. */
	public static final int LMUL =
		105;

	/** FMUL. */
	public static final int FMUL =
		106;

	/** DMUL. */
	public static final int DMUL =
		107;

	/** IDIV. */
	public static final int IDIV =
		108;

	/** LDIV. */
	public static final int LDIV =
		109;

	/** FDIV. */
	public static final int FDIV =
		110;

	/** DDIV. */
	public static final int DDIV =
		111;

	/** IREM. */
	public static final int IREM =
		112;

	/** LREM. */
	public static final int LREM =
		113;

	/** FREM. */
	public static final int FREM =
		114;

	/** DREM. */
	public static final int DREM =
		115;

	/** INEG. */
	public static final int INEG =
		116;

	/** LNEG. */
	public static final int LNEG =
		117;

	/** FNEG. */
	public static final int FNEG =
		118;

	/** DNEG. */
	public static final int DNEG =
		119;

	/** ISHL. */
	public static final int ISHL =
		120;

	/** LSHL. */
	public static final int LSHL =
		121;

	/** ISHR. */
	public static final int ISHR =
		122;

	/** LSHR. */
	public static final int LSHR =
		123;

	/** IUSHR. */
	public static final int IUSHR =
		124;

	/** LUSHR. */
	public static final int LUSHR =
		125;

	/** IAND. */
	public static final int IAND =
		126;

	/** LAND. */
	public static final int LAND =
		127;

	/** IOR. */
	public static final int IOR =
		128;

	/** LOR. */
	public static final int LOR =
		129;

	/** IXOR. */
	public static final int IXOR =
		130;

	/** LXOR. */
	public static final int LXOR =
		131;

	/** IINC. */
	public static final int IINC =
		132;

	/** I2L. */
	public static final int I2L =
		133;

	/** I2F. */
	public static final int I2F =
		134;

	/** I2D. */
	public static final int I2D =
		135;

	/** L2I. */
	public static final int L2I =
		136;

	/** L2F. */
	public static final int L2F =
		137;

	/** L2D. */
	public static final int L2D =
		138;

	/** F2I. */
	public static final int F2I =
		139;

	/** F2L. */
	public static final int F2L =
		140;

	/** F2D. */
	public static final int F2D =
		141;

	/** D2I. */
	public static final int D2I =
		142;

	/** D2L. */
	public static final int D2L =
		143;

	/** D2F. */
	public static final int D2F =
		144;

	/** I2B. */
	public static final int I2B =
		145;

	/** I2C. */
	public static final int I2C =
		146;

	/** I2S. */
	public static final int I2S =
		147;

	/** LCMP. */
	public static final int LCMP =
		148;

	/** FCMPL. */
	public static final int FCMPL =
		149;

	/** FCMPG. */
	public static final int FCMPG =
		150;

	/** DCMPL. */
	public static final int DCMPL =
		151;

	/** DCMPG. */
	public static final int DCMPG =
		152;

	/** IFEQ. */
	public static final int IFEQ =
		153;

	/** IFNE. */
	public static final int IFNE =
		154;

	/** IFLT. */
	public static final int IFLT =
		155;

	/** IFGE. */
	public static final int IFGE =
		156;

	/** IFGT. */
	public static final int IFGT =
		157;

	/** IFLE. */
	public static final int IFLE =
		158;

	/** IF_ICMPEQ. */
	public static final int IF_ICMPEQ =
		159;

	/** IF_ICMPNE. */
	public static final int IF_ICMPNE =
		160;

	/** IF_ICMPLT. */
	public static final int IF_ICMPLT =
		161;

	/** IF_ICMPGE. */
	public static final int IF_ICMPGE =
		162;

	/** IF_ICMPGT. */
	public static final int IF_ICMPGT =
		163;

	/** IF_ICMPLE. */
	public static final int IF_ICMPLE =
		164;

	/** IF_ACMPEQ. */
	public static final int IF_ACMPEQ =
		165;

	/** IF_ACMPNE. */
	public static final int IF_ACMPNE =
		166;

	/** GOTO. */
	public static final int GOTO =
		167;

	/** JSR. */
	public static final int JSR =
		168;

	/** RET. */
	public static final int RET =
		169;

	/** TABLESWITCH. */
	public static final int TABLESWITCH =
		170;

	/** LOOKUPSWITCH. */
	public static final int LOOKUPSWITCH =
		171;

	/** IRETURN. */
	public static final int IRETURN =
		172;

	/** LRETURN. */
	public static final int LRETURN =
		173;

	/** FRETURN. */
	public static final int FRETURN =
		174;

	/** DRETURN. */
	public static final int DRETURN =
		175;

	/** ARETURN. */
	public static final int ARETURN =
		176;

	/** RETURN. */
	public static final int RETURN =
		177;

	/** GETSTATIC. */
	public static final int GETSTATIC =
		178;

	/** PUTSTATIC. */
	public static final int PUTSTATIC =
		179;

	/** GETFIELD. */
	public static final int GETFIELD =
		180;

	/** PUTFIELD. */
	public static final int PUTFIELD =
		181;

	/** INVOKEVIRTUAL. */
	public static final int INVOKEVIRTUAL =
		182;

	/** INVOKESPECIAL. */
	public static final int INVOKESPECIAL =
		183;

	/** INVOKESTATIC. */
	public static final int INVOKESTATIC =
		184;

	/** INVOKEINTERFACE. */
	public static final int INVOKEINTERFACE =
		185;

	/** INVOKEDYNAMIC. */
	public static final int INVOKEDYNAMIC =
		186;

	/** NEW. */
	public static final int NEW =
		187;

	/** NEWARRAY. */
	public static final int NEWARRAY =
		188;

	/** ANEWARRAY. */
	public static final int ANEWARRAY =
		189;

	/** ARRAYLENGTH. */
	public static final int ARRAYLENGTH =
		190;

	/** ATHROW. */
	public static final int ATHROW =
		191;

	/** CHECKCAST. */
	public static final int CHECKCAST =
		192;

	/** INSTANCEOF. */
	public static final int INSTANCEOF =
		193;

	/** MONITORENTER. */
	public static final int MONITORENTER =
		194;

	/** MONITOREXIT. */
	public static final int MONITOREXIT =
		195;

	/** WIDE. */
	public static final int WIDE =
		196;

	/** MULTIANEWARRAY. */
	public static final int MULTIANEWARRAY =
		197;

	/** IFNULL. */
	public static final int IFNULL =
		198;

	/** IFNONNULL. */
	public static final int IFNONNULL =
		199;

	/** GOTO_W. */
	public static final int GOTO_W =
		200;

	/** JSR_W. */
	public static final int JSR_W =
		201;

	/** BREAKPOINT. */
	public static final int BREAKPOINT =
		202;

	/** IMPDEP1. */
	public static final int IMPDEP1 =
		254;

	/** IMPDEP2. */
	public static final int IMPDEP2 =
		255;

	/** Wide ALOAD. */
	public static final int WIDE_ALOAD =
		(WIDE << 8) | ALOAD;

	/** Wide ILOAD. */
	public static final int WIDE_ILOAD =
		(WIDE << 8) | ILOAD;

	/** Wide LLOAD. */
	public static final int WIDE_LLOAD =
		(WIDE << 8) | LLOAD;

	/** Wide FLOAD. */
	public static final int WIDE_FLOAD =
		(WIDE << 8) | FLOAD;

	/** Wide DLOAD. */
	public static final int WIDE_DLOAD =
		(WIDE << 8) | DLOAD;

	/** Wide ASTORE. */
	public static final int WIDE_ASTORE =
		(WIDE << 8) | ASTORE;

	/** Wide ISTORE. */
	public static final int WIDE_ISTORE =
		(WIDE << 8) | ISTORE;

	/** Wide LSTORE. */
	public static final int WIDE_LSTORE =
		(WIDE << 8) | LSTORE;

	/** Wide FSTORE. */
	public static final int WIDE_FSTORE =
		(WIDE << 8) | FSTORE;

	/** Wide DSTORE. */
	public static final int WIDE_DSTORE =
		(WIDE << 8) | DSTORE;
	
	/** Wide IINC. */
	public static final int WIDE_IINC =
		(WIDE << 8) | IINC;
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InstructionJumpTarget.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a branch or jump target that may be used by instructions.
 *
 * @since 2018/09/15
 */
public final class InstructionJumpTarget
	implements Comparable<InstructionJumpTarget>
{
	/** The value. */
	protected final int target;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the jump target.
	 *
	 * @param __t The target.
	 * @throws IllegalArgumentException If the target is negative.
	 * @since 2018/09/15
	 */
	public InstructionJumpTarget(int __t)
		throws IllegalArgumentException
	{
		// {@squirreljme.error JC3b Jump target is negative. (The target)}
		if (__t < 0)
			throw new IllegalArgumentException(String.format("JC3b %d", __t));
		
		this.target = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final int compareTo(InstructionJumpTarget __o)
		throws NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		return this.target - __o.target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof InstructionJumpTarget))
			return false;
		
		return this.target == ((InstructionJumpTarget)__o).target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final int hashCode()
	{
		return this.target;
	}
	
	/**
	 * Returns the target address of the jump.
	 *
	 * @return The jump target address.
	 * @since 2018/09/15
	 */
	public final int target()
	{
		return this.target;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/15
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = String.format("->@%d", this.target)));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InstructionJumpTargets.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * This represents the targets of jumps that an instruction may jump to.
 *
 * @since 2019/03/30
 */
public final class InstructionJumpTargets
{
	/** Normal jumps. */
	private final InstructionJumpTarget[] _normal;
	
	/** Exceptional jumps. */
	private final InstructionJumpTarget[] _exception;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Hashcode. */
	private int _hash;
	
	/**
	 * Initializes empty jump targets.
	 *
	 * @since 2019/04/11
	 */
	public InstructionJumpTargets()
	{
		this._normal = new InstructionJumpTarget[0];
		this._exception = new InstructionJumpTarget[0];
	}
	
	/**
	 * Initializes the jump targets.
	 * @param __n Normal jumps.
	 * @param __e Exceptional jumps.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/30
	 */
	public InstructionJumpTargets(InstructionJumpTarget[] __n,
		InstructionJumpTarget[] __e)
		throws NullPointerException
	{
		if (__n == null || __e == null)
			throw new NullPointerException("NARG");
		
		// Load into sorted sets
		Set<InstructionJumpTarget> nrm = new SortedTreeSet<>(),
			exe = new SortedTreeSet<>();
		
		// Add normals
		for (InstructionJumpTarget i : __n)
			if (i == null)
				throw new NullPointerException("NARG");
			else
				nrm.add(i);
		
		// Add exceptional
		for (InstructionJumpTarget i : __e)
			if (i == null)
				throw new NullPointerException("NARG");
			else
				exe.add(i);
		
		// Set
		this._normal = nrm.<InstructionJumpTarget>toArray(
			new InstructionJumpTarget[nrm.size()]);
		this._exception = exe.<InstructionJumpTarget>toArray(
			new InstructionJumpTarget[exe.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Obtains the given jump target.
	 *
	 * @param __i The index.
	 * @return The target jump target.
	 * @since 2019/03/31
	 */
	public final InstructionJumpTarget get(int __i)
	{
		InstructionJumpTarget[] normal = this._normal;
		int numnormal = normal.length;
		
		// Treat both arrays as a single part
		if (__i >= numnormal)
			return this._exception[__i - numnormal];
		return this._normal[__i];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Checks if any of the jump targets has an address which follows the
	 * given address.
	 *
	 * @param __pc The address to check.
	 * @return True if any address in the jump targets has an address which
	 * is higher than this address.
	 * @since 2019/03/30
	 */
	public final boolean hasLaterAddress(int __pc)
	{
		for (int i = 0, n = this.size(); i < n; i++)
			if (this.get(i).target() > __pc)
				return true;
		
		return false;
	}
	
	/**
	 * Checks if any of the jump targets has an address which is or follows
	 * the given address.
	 *
	 * @param __pc The address to check.
	 * @return True if any address in the jump targets has an address which
	 * is the same or higher than this address.
	 * @since 2019/04/11
	 */
	public final boolean hasSameOrLaterAddress(int __pc)
	{
		for (int i = 0, n = this.size(); i < n; i++)
			if (this.get(i).target() >= __pc)
				return true;
		
		return false;
	}
	
	/**
	 * Returns if this is empty or not.
	 *
	 * @return If this is empty or not.
	 * @since 2019/03/31
	 */
	public final boolean isEmpty()
	{
		return this.size() == 0;
	}
	
	/**
	 * Returns if this is an exception jump.
	 *
	 * @param __i The index to get.
	 * @return If this is an exception index.
	 * @since 2019/03/31
	 */
	public final boolean isException(int __i)
	{
		return __i >= this._normal.length;
	}
	
	/**
	 * Returns the number of jump targets.
	 *
	 * @return The number of jump targets.
	 * @since 2019/03/31
	 */
	public final int size()
	{
		return this._normal.length + this._exception.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/30
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				"[N:" + Arrays.asList(this._normal) +
				", E: " + Arrays.asList(this._exception) + "]"));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InstructionMnemonics.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263







































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This contains instruction mnemonics.
 *
 * @since 2017/05/20
 */
public final class InstructionMnemonics
{
	/**
	 * Not used.
	 *
	 * @since 2017/05/29
	 */
	private InstructionMnemonics()
	{
	}
	
	/**
	 * Returns the instruction mnemonic.
	 *
	 * @param __op The operation to get.
	 * @return The mnemonic for the instruction.
	 * @since 2017/05/20
	 */
	public static String toString(int __op)
	{
		switch (__op)
		{
			case InstructionIndex.NOP: return "NOP";
			case InstructionIndex.ACONST_NULL: return "ACONST_NULL";
			case InstructionIndex.ICONST_M1: return "ICONST_M1";
			case InstructionIndex.ICONST_0: return "ICONST_0";
			case InstructionIndex.ICONST_1: return "ICONST_1";
			case InstructionIndex.ICONST_2: return "ICONST_2";
			case InstructionIndex.ICONST_3: return "ICONST_3";
			case InstructionIndex.ICONST_4: return "ICONST_4";
			case InstructionIndex.ICONST_5: return "ICONST_5";
			case InstructionIndex.LCONST_0: return "LCONST_0";
			case InstructionIndex.LCONST_1: return "LCONST_1";
			case InstructionIndex.FCONST_0: return "FCONST_0";
			case InstructionIndex.FCONST_1: return "FCONST_1";
			case InstructionIndex.FCONST_2: return "FCONST_2";
			case InstructionIndex.DCONST_0: return "DCONST_0";
			case InstructionIndex.DCONST_1: return "DCONST_1";
			case InstructionIndex.BIPUSH: return "BIPUSH";
			case InstructionIndex.SIPUSH: return "SIPUSH";
			case InstructionIndex.LDC: return "LDC";
			case InstructionIndex.LDC_W: return "LDC_W";
			case InstructionIndex.LDC2_W: return "LDC2_W";
			case InstructionIndex.ILOAD: return "ILOAD";
			case InstructionIndex.LLOAD: return "LLOAD";
			case InstructionIndex.FLOAD: return "FLOAD";
			case InstructionIndex.DLOAD: return "DLOAD";
			case InstructionIndex.ALOAD: return "ALOAD";
			case InstructionIndex.ILOAD_0: return "ILOAD_0";
			case InstructionIndex.ILOAD_1: return "ILOAD_1";
			case InstructionIndex.ILOAD_2: return "ILOAD_2";
			case InstructionIndex.ILOAD_3: return "ILOAD_3";
			case InstructionIndex.LLOAD_0: return "LLOAD_0";
			case InstructionIndex.LLOAD_1: return "LLOAD_1";
			case InstructionIndex.LLOAD_2: return "LLOAD_2";
			case InstructionIndex.LLOAD_3: return "LLOAD_3";
			case InstructionIndex.FLOAD_0: return "FLOAD_0";
			case InstructionIndex.FLOAD_1: return "FLOAD_1";
			case InstructionIndex.FLOAD_2: return "FLOAD_2";
			case InstructionIndex.FLOAD_3: return "FLOAD_3";
			case InstructionIndex.DLOAD_0: return "DLOAD_0";
			case InstructionIndex.DLOAD_1: return "DLOAD_1";
			case InstructionIndex.DLOAD_2: return "DLOAD_2";
			case InstructionIndex.DLOAD_3: return "DLOAD_3";
			case InstructionIndex.ALOAD_0: return "ALOAD_0";
			case InstructionIndex.ALOAD_1: return "ALOAD_1";
			case InstructionIndex.ALOAD_2: return "ALOAD_2";
			case InstructionIndex.ALOAD_3: return "ALOAD_3";
			case InstructionIndex.IALOAD: return "IALOAD";
			case InstructionIndex.LALOAD: return "LALOAD";
			case InstructionIndex.FALOAD: return "FALOAD";
			case InstructionIndex.DALOAD: return "DALOAD";
			case InstructionIndex.AALOAD: return "AALOAD";
			case InstructionIndex.BALOAD: return "BALOAD";
			case InstructionIndex.CALOAD: return "CALOAD";
			case InstructionIndex.SALOAD: return "SALOAD";
			case InstructionIndex.ISTORE: return "ISTORE";
			case InstructionIndex.LSTORE: return "LSTORE";
			case InstructionIndex.FSTORE: return "FSTORE";
			case InstructionIndex.DSTORE: return "DSTORE";
			case InstructionIndex.ASTORE: return "ASTORE";
			case InstructionIndex.ISTORE_0: return "ISTORE_0";
			case InstructionIndex.ISTORE_1: return "ISTORE_1";
			case InstructionIndex.ISTORE_2: return "ISTORE_2";
			case InstructionIndex.ISTORE_3: return "ISTORE_3";
			case InstructionIndex.LSTORE_0: return "LSTORE_0";
			case InstructionIndex.LSTORE_1: return "LSTORE_1";
			case InstructionIndex.LSTORE_2: return "LSTORE_2";
			case InstructionIndex.LSTORE_3: return "LSTORE_3";
			case InstructionIndex.FSTORE_0: return "FSTORE_0";
			case InstructionIndex.FSTORE_1: return "FSTORE_1";
			case InstructionIndex.FSTORE_2: return "FSTORE_2";
			case InstructionIndex.FSTORE_3: return "FSTORE_3";
			case InstructionIndex.DSTORE_0: return "DSTORE_0";
			case InstructionIndex.DSTORE_1: return "DSTORE_1";
			case InstructionIndex.DSTORE_2: return "DSTORE_2";
			case InstructionIndex.DSTORE_3: return "DSTORE_3";
			case InstructionIndex.ASTORE_0: return "ASTORE_0";
			case InstructionIndex.ASTORE_1: return "ASTORE_1";
			case InstructionIndex.ASTORE_2: return "ASTORE_2";
			case InstructionIndex.ASTORE_3: return "ASTORE_3";
			case InstructionIndex.IASTORE: return "IASTORE";
			case InstructionIndex.LASTORE: return "LASTORE";
			case InstructionIndex.FASTORE: return "FASTORE";
			case InstructionIndex.DASTORE: return "DASTORE";
			case InstructionIndex.AASTORE: return "AASTORE";
			case InstructionIndex.BASTORE: return "BASTORE";
			case InstructionIndex.CASTORE: return "CASTORE";
			case InstructionIndex.SASTORE: return "SASTORE";
			case InstructionIndex.POP: return "POP";
			case InstructionIndex.POP2: return "POP2";
			case InstructionIndex.DUP: return "DUP";
			case InstructionIndex.DUP_X1: return "DUP_X1";
			case InstructionIndex.DUP_X2: return "DUP_X2";
			case InstructionIndex.DUP2: return "DUP2";
			case InstructionIndex.DUP2_X1: return "DUP2_X1";
			case InstructionIndex.DUP2_X2: return "DUP2_X2";
			case InstructionIndex.SWAP: return "SWAP";
			case InstructionIndex.IADD: return "IADD";
			case InstructionIndex.LADD: return "LADD";
			case InstructionIndex.FADD: return "FADD";
			case InstructionIndex.DADD: return "DADD";
			case InstructionIndex.ISUB: return "ISUB";
			case InstructionIndex.LSUB: return "LSUB";
			case InstructionIndex.FSUB: return "FSUB";
			case InstructionIndex.DSUB: return "DSUB";
			case InstructionIndex.IMUL: return "IMUL";
			case InstructionIndex.LMUL: return "LMUL";
			case InstructionIndex.FMUL: return "FMUL";
			case InstructionIndex.DMUL: return "DMUL";
			case InstructionIndex.IDIV: return "IDIV";
			case InstructionIndex.LDIV: return "LDIV";
			case InstructionIndex.FDIV: return "FDIV";
			case InstructionIndex.DDIV: return "DDIV";
			case InstructionIndex.IREM: return "IREM";
			case InstructionIndex.LREM: return "LREM";
			case InstructionIndex.FREM: return "FREM";
			case InstructionIndex.DREM: return "DREM";
			case InstructionIndex.INEG: return "INEG";
			case InstructionIndex.LNEG: return "LNEG";
			case InstructionIndex.FNEG: return "FNEG";
			case InstructionIndex.DNEG: return "DNEG";
			case InstructionIndex.ISHL: return "ISHL";
			case InstructionIndex.LSHL: return "LSHL";
			case InstructionIndex.ISHR: return "ISHR";
			case InstructionIndex.LSHR: return "LSHR";
			case InstructionIndex.IUSHR: return "IUSHR";
			case InstructionIndex.LUSHR: return "LUSHR";
			case InstructionIndex.IAND: return "IAND";
			case InstructionIndex.LAND: return "LAND";
			case InstructionIndex.IOR: return "IOR";
			case InstructionIndex.LOR: return "LOR";
			case InstructionIndex.IXOR: return "IXOR";
			case InstructionIndex.LXOR: return "LXOR";
			case InstructionIndex.IINC: return "IINC";
			case InstructionIndex.I2L: return "I2L";
			case InstructionIndex.I2F: return "I2F";
			case InstructionIndex.I2D: return "I2D";
			case InstructionIndex.L2I: return "L2I";
			case InstructionIndex.L2F: return "L2F";
			case InstructionIndex.L2D: return "L2D";
			case InstructionIndex.F2I: return "F2I";
			case InstructionIndex.F2L: return "F2L";
			case InstructionIndex.F2D: return "F2D";
			case InstructionIndex.D2I: return "D2I";
			case InstructionIndex.D2L: return "D2L";
			case InstructionIndex.D2F: return "D2F";
			case InstructionIndex.I2B: return "I2B";
			case InstructionIndex.I2C: return "I2C";
			case InstructionIndex.I2S: return "I2S";
			case InstructionIndex.LCMP: return "LCMP";
			case InstructionIndex.FCMPL: return "FCMPL";
			case InstructionIndex.FCMPG: return "FCMPG";
			case InstructionIndex.DCMPL: return "DCMPL";
			case InstructionIndex.DCMPG: return "DCMPG";
			case InstructionIndex.IFEQ: return "IFEQ";
			case InstructionIndex.IFNE: return "IFNE";
			case InstructionIndex.IFLT: return "IFLT";
			case InstructionIndex.IFGE: return "IFGE";
			case InstructionIndex.IFGT: return "IFGT";
			case InstructionIndex.IFLE: return "IFLE";
			case InstructionIndex.IF_ICMPEQ: return "IF_ICMPEQ";
			case InstructionIndex.IF_ICMPNE: return "IF_ICMPNE";
			case InstructionIndex.IF_ICMPLT: return "IF_ICMPLT";
			case InstructionIndex.IF_ICMPGE: return "IF_ICMPGE";
			case InstructionIndex.IF_ICMPGT: return "IF_ICMPGT";
			case InstructionIndex.IF_ICMPLE: return "IF_ICMPLE";
			case InstructionIndex.IF_ACMPEQ: return "IF_ACMPEQ";
			case InstructionIndex.IF_ACMPNE: return "IF_ACMPNE";
			case InstructionIndex.GOTO: return "GOTO";
			case InstructionIndex.JSR: return "JSR";
			case InstructionIndex.RET: return "RET";
			case InstructionIndex.TABLESWITCH: return "TABLESWITCH";
			case InstructionIndex.LOOKUPSWITCH: return "LOOKUPSWITCH";
			case InstructionIndex.IRETURN: return "IRETURN";
			case InstructionIndex.LRETURN: return "LRETURN";
			case InstructionIndex.FRETURN: return "FRETURN";
			case InstructionIndex.DRETURN: return "DRETURN";
			case InstructionIndex.ARETURN: return "ARETURN";
			case InstructionIndex.RETURN: return "RETURN";
			case InstructionIndex.GETSTATIC: return "GETSTATIC";
			case InstructionIndex.PUTSTATIC: return "PUTSTATIC";
			case InstructionIndex.GETFIELD: return "GETFIELD";
			case InstructionIndex.PUTFIELD: return "PUTFIELD";
			case InstructionIndex.INVOKEVIRTUAL: return "INVOKEVIRTUAL";
			case InstructionIndex.INVOKESPECIAL: return "INVOKESPECIAL";
			case InstructionIndex.INVOKESTATIC: return "INVOKESTATIC";
			case InstructionIndex.INVOKEINTERFACE: return "INVOKEINTERFACE";
			case InstructionIndex.INVOKEDYNAMIC: return "INVOKEDYNAMIC";
			case InstructionIndex.NEW: return "NEW";
			case InstructionIndex.NEWARRAY: return "NEWARRAY";
			case InstructionIndex.ANEWARRAY: return "ANEWARRAY";
			case InstructionIndex.ARRAYLENGTH: return "ARRAYLENGTH";
			case InstructionIndex.ATHROW: return "ATHROW";
			case InstructionIndex.CHECKCAST: return "CHECKCAST";
			case InstructionIndex.INSTANCEOF: return "INSTANCEOF";
			case InstructionIndex.MONITORENTER: return "MONITORENTER";
			case InstructionIndex.MONITOREXIT: return "MONITOREXIT";
			case InstructionIndex.WIDE: return "WIDE";
			case InstructionIndex.MULTIANEWARRAY: return "MULTIANEWARRAY";
			case InstructionIndex.IFNULL: return "IFNULL";
			case InstructionIndex.IFNONNULL: return "IFNONNULL";
			case InstructionIndex.GOTO_W: return "GOTO_W";
			case InstructionIndex.JSR_W: return "JSR_W";
			case InstructionIndex.BREAKPOINT: return "BREAKPOINT";
			case InstructionIndex.IMPDEP1: return "IMPDEP1";
			case InstructionIndex.IMPDEP2: return "IMPDEP2";
			case InstructionIndex.WIDE_ALOAD: return "WIDE_ALOAD";
			case InstructionIndex.WIDE_ILOAD: return "WIDE_ILOAD";
			case InstructionIndex.WIDE_LLOAD: return "WIDE_LLOAD";
			case InstructionIndex.WIDE_FLOAD: return "WIDE_FLOAD";
			case InstructionIndex.WIDE_DLOAD: return "WIDE_DLOAD";
			case InstructionIndex.WIDE_ASTORE: return "WIDE_ASTORE";
			case InstructionIndex.WIDE_ISTORE: return "WIDE_ISTORE";
			case InstructionIndex.WIDE_LSTORE: return "WIDE_LSTORE";
			case InstructionIndex.WIDE_FSTORE: return "WIDE_FSTORE";
			case InstructionIndex.WIDE_DSTORE: return "WIDE_DSTORE";
			case InstructionIndex.WIDE_IINC: return "WIDE_IINC";
			
				// Unknown
			default:
				return String.format("UNKNOWN_%04X", __op);
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/IntMatchingJumpTable.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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This interface represents a jump table which matches based on an input
 * integer.
 *
 * @since 2018/09/20
 */
public interface IntMatchingJumpTable
{
	/**
	 * Matches the input key with the given jump target or returns the default.
	 *
	 * @param __k The key to match.
	 * @return The jump target for the match or the default if it was not
	 * found.
	 * @since 2018/09/20
	 */
	public abstract InstructionJumpTarget match(int __k);
	
	/**
	 * Returns all of the used jump targets.
	 *
	 * @return The used jump targets.
	 * @since 2019/03/31
	 */
	public abstract InstructionJumpTarget[] targets();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/InvalidClassFormatException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is thrown when the format of a class is not valid.
 *
 * @since 2017/09/27
 */
public class InvalidClassFormatException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2016/09/27
	 */
	public InvalidClassFormatException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/JavaType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322


































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a type which may be used on the stack or within local
 * variables within the virtual machine.
 *
 * @since 2017/07/26
 */
public final class JavaType
{
	/** The top of a long. */
	public static final JavaType TOP_LONG =
		new JavaType(1);
	
	/** The top of a double. */
	public static final JavaType TOP_DOUBLE =
		new JavaType(2);
	
	/** Top of an undefined type. */
	public static final JavaType TOP_UNDEFINED =
		new JavaType(3);
	
	/** Nothing. */
	public static final JavaType NOTHING =
		new JavaType(4);
	
	/** Integer. */
	public static final JavaType INTEGER =
		new JavaType(new FieldDescriptor("I"));
	
	/** Long. */
	public static final JavaType LONG =
		new JavaType(new FieldDescriptor("J"));
	
	/** Float. */
	public static final JavaType FLOAT =
		new JavaType(new FieldDescriptor("F"));
	
	/** Double. */
	public static final JavaType DOUBLE =
		new JavaType(new FieldDescriptor("D"));
	
	/** Plain object. */
	public static final JavaType OBJECT =
		new JavaType(new FieldDescriptor("Ljava/lang/Object;"));
	
	/** Throwable. */
	public static final JavaType THROWABLE =
		new JavaType(new FieldDescriptor("Ljava/lang/Throwable;"));
	
	/** The type this refers to. */
	protected final FieldDescriptor type;
	
	/** Internal property. */
	private final int _internal;
	
	/** String representation of this table. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map type.
	 *
	 * @param __cn The name of the field.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public JavaType(ClassName __cn)
		throws NullPointerException
	{
		this(new FieldDescriptor((__cn.isArray() ? __cn.toString() :
			"L" + __cn + ";")));
	}
	
	/**
	 * Initializes the stack map type.
	 *
	 * @param __f The field type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public JavaType(FieldDescriptor __f)
		throws IllegalStateException, NullPointerException
	{
		// Check
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// Promote to integer since the VM does not have a representation for
		// types smaller than int
		PrimitiveType p = __f.primitiveType();
		if (p != null && p.promotesToInt())
			__f = new FieldDescriptor("I");
		
		// Set
		this._internal = 0;
		this.type = __f;
	}
	
	/**
	 * Used internally to create special non-comparable types.
	 *
	 * @param __i Internal identifier.
	 * @throws RuntimeException If the internal value is zero.
	 * @since 2017/07/28
	 */
	private JavaType(int __i)
		throws RuntimeException
	{
		// Check
		if (__i == 0)
			throw new todo.OOPS();
		
		this._internal = __i;
		this.type = null;
	}
	
	/**
	 * Returns the class name of the type.
	 *
	 * @return The type class name.
	 * @since 2019/05/24
	 */
	public final ClassName className()
	{
		FieldDescriptor type = this.type;
		if (type == null)
			return null;
		return type.className();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof JavaType))
			return false;
		
		JavaType o = (JavaType)__o;
		return this._internal == o._internal &&
			Objects.equals(this.type, o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public int hashCode()
	{
		return this._internal ^ Objects.hashCode(this.type);
	}
	
	/**
	 * Is this an array type?
	 *
	 * @return True if this is an array.
	 * @since 2019/05/25
	 */
	public final boolean isArray()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isObject() && type.isArray());
	}
	
	/**
	 * Is this an object type?
	 *
	 * @return {@code true} if this is an object type.
	 * @since 2017/08/13
	 */
	public boolean isObject()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isObject());
	}
	
	/**
	 * Is this a primitive type?
	 *
	 * @return {@code true} if this is a primitive type.
	 * @since 2017/08/13
	 */
	public boolean isPrimitive()
	{
		FieldDescriptor type = this.type;
		return (type != null && type.isPrimitive());
	}
	
	/**
	 * Is this the nothing type?
	 *
	 * @return If this is the nothing type.
	 * @since 2017/10/20
	 */
	public boolean isNothing()
	{
		return equals(NOTHING);
	}
	
	/**
	 * Is this a top type?
	 *
	 * @return If this is a top type or not.
	 * @since 2017/09/16
	 */
	public boolean isTop()
	{
		return equals(TOP_LONG) || equals(TOP_DOUBLE) || equals(TOP_UNDEFINED);
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return {@code true} if the type is a wide type.
	 * @since 2017/07/28
	 */
	public boolean isWide()
	{
		FieldDescriptor type = this.type;
		if (type == null)
			return false;
		PrimitiveType pt = type.primitiveType();
		return pt != null && pt.isWide();
	}
	
	/**
	 * Returns the type that is used for the top type.
	 *
	 * @return The associated top type used for this type or {@code null} if
	 * there is none.
	 * @since 2017/07/28
	 */
	public JavaType topType()
	{
		PrimitiveType pt = this.type.primitiveType();
		if (pt == null)
			return null;
		
		switch (pt)
		{
			case LONG:		return TOP_LONG;
			case DOUBLE:	return TOP_DOUBLE;
			default:
				return null;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public String toString()
	{
		// Unknown
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Fixed type
			if (this.equals(TOP_LONG))
				rv = "top-long";
			else if (this.equals(TOP_DOUBLE))
				rv = "top-double";
			else if (this.equals(TOP_UNDEFINED))
				rv = "top-undefined";
			else if (this.equals(NOTHING))
				rv = "nothing";
			
			// Other
			else
				rv = this.type.toString();
			
			// Cache
			this._string = new WeakReference<>(rv);
		}
		
		return rv;
	}
	
	/**
	 * Returns the type for this type.
	 *
	 * @return The type used.
	 * @since 2017/09/19
	 */
	public FieldDescriptor type()
	{
		return this.type;
	}
	
	/**
	 * Returns the width of the type.
	 *
	 * @return The width of the type.
	 * @since 2017/09/03
	 */
	public int width()
	{
		return (isWide() ? 2 : 1);
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/LookupSwitch.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/**
 * This class represents a lookup switch which is used to lookup indexes as a
 * jump table.
 *
 * @since 2018/09/20
 */
public final class LookupSwitch
	implements IntMatchingJumpTable
{
	/** The default target. */
	protected final InstructionJumpTarget defaultjump;
	
	/** The keys. */
	private final int[] _keys;
	
	/** The jump targets. */
	private final InstructionJumpTarget[] _jumps;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the lookup switch.
	 *
	 * @param __def The default address if no values match at all.
	 * @param __keys The keys to check, must be sorted.
	 * @param __jumps The jump targets.
	 * @throws IllegalArgumentException If the key and jump table length are
	 * difference lengths.
	 * @throws InvalidClassFormatException If the key table is not sorted.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public LookupSwitch(InstructionJumpTarget __def,
		int[] __keys, InstructionJumpTarget[] __jumps)
		throws IllegalArgumentException, InvalidClassFormatException,
			NullPointerException
	{
		if (__def == null || __keys == null || __jumps == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3c Key and jump table for lookup switch
		// table is of different lengths.}
		if (__keys.length != __jumps.length)
			throw new IllegalArgumentException("JC3c");
		
		// Defensive copy
		__keys = __keys.clone();
		__jumps = __jumps.clone();
		
		// Check for sorted
		long last = ((long)Integer.MIN_VALUE) - 1;
		for (int i = 0, n = __keys.length; i < n; i++)
		{
			// {@squirreljme.error JC3d Lookup switch key is not in sorted
			// order. (The index; The current key; The last key)}
			int k = __keys[i];
			if (k < last)
				throw new InvalidClassFormatException(
					String.format("JC3d %d %d %d", i, k, last));
			last = k;
			
			if (__jumps[i] == null)
				throw new NullPointerException("NARG");
		}
		
		this.defaultjump = __def;
		this._keys = __keys;
		this._jumps = __jumps;
	}
	
	/**
	 * Returns the default jump.
	 *
	 * @return The default jump.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget defaultJump()
	{
		return this.defaultjump;
	}
	
	/**
	 * Returns the jumps.
	 *
	 * @return The jumps.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget[] jumps()
	{
		return this._jumps.clone();
	}
	
	/**
	 * Returns the keys.
	 *
	 * @return The keys.
	 * @since 2019/04/16
	 */
	public final int[] keys()
	{
		return this._keys.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final InstructionJumpTarget match(int __k)
	{
		// Use binary search since all entries are sorted
		int dx = Arrays.binarySearch(this._keys, __k);
		
		// Match was found, use that result
		if (dx >= 0)
			return this._jumps[dx];
		
		// Not found
		return this.defaultjump;
	}
	
	/**
	 * Returns the size of the switch.
	 *
	 * @return The size.
	 * @since 2019/04/16
	 */
	public final int size()
	{
		return this._jumps.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/31
	 */
	@Override
	public final InstructionJumpTarget[] targets()
	{
		InstructionJumpTarget[] jumps = this._jumps;
		int n = jumps.length;
		
		// Start off array with the default jump
		InstructionJumpTarget[] rv = new InstructionJumpTarget[n + 1];
		rv[0] = this.defaultjump;
		
		// Add all the others
		for (int i = 0, o = 1; i < n; i++, o++)
			rv[o] = jumps[i];
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Set with default first
			StringBuilder sb = new StringBuilder("{default=");
			sb.append(this.defaultjump);
			
			// Add all matches and their targets
			int[] keys = this._keys;
			InstructionJumpTarget[] jumps = this._jumps;
			for (int i = 0, n = keys.length; i < n; i++)
			{
				sb.append(", ");
				
				sb.append(keys[i]);
				sb.append('=');
				sb.append(jumps[i]);
			}
			
			// Cleans
			sb.append('}');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Member.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the base for members within classes.
 *
 * @since 2017/09/30
 */
public abstract class Member
	implements HasMemberFlags
{
	/**
	 * Initializes the base member.
	 *
	 * @since 2017/09/30
	 */
	Member()
	{
	}
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	public abstract MemberNameAndType nameAndType();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberDescriptor.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents the type of the member.
 *
 * @since 2018/09/09
 */
public interface MemberDescriptor
{
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberFlag.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is a flagging interface for flags which are associated with members.
 *
 * @since 2016/04/23
 */
public interface MemberFlag
	extends Flag
{
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberFlags.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
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

















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is the base class for flags which are for member types.
 *
 * @param <F> The flag type.
 * @since 2016/04/23
 */
public abstract class MemberFlags<F extends MemberFlag>
	extends Flags<F>
	implements AccessibleFlags
{
	/**
	 * Initializes the member flags.
	 *
	 * @param __cl The required class type.
	 * @param __fl The flags used.
	 * @since 2016/04/23
	 */
	MemberFlags(Class<F> __cl, F[] __fl)
	{
		super(__cl, __fl);
	}
	
	/**
	 * Initializes the member flags.
	 *
	 * @param __cl The required class type.
	 * @param __fl The flags used.
	 * @since 2016/04/23
	 */
	MemberFlags(Class<F> __cl, Iterable<F> __fl)
	{
		super(__cl, __fl);
	}
	
	/**
	 * Returns {@code true} if this is final.
	 *
	 * @return {@code true} if final.
	 * @since 2016/03/20
	 */
	public abstract boolean isFinal();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isPrivate();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isProtected();
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public abstract boolean isPublic();
	
	/**
	 * Returns {@code true} if this is static.
	 *
	 * @return {@code true} if static.
	 * @since 2016/03/20
	 */
	public abstract boolean isStatic();
	
	/**
	 * Returns {@code true} if this is synthetic.
	 *
	 * @return {@code true} if synthetic.
	 * @since 2016/03/20
	 */
	public abstract boolean isSynthetic();
	
	/**
	 * Is this not static?
	 *
	 * @return If this is not static.
	 * @since 2018/09/09
	 */
	public final boolean isInstance()
	{
		return !this.isStatic();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public final boolean isPackagePrivate()
	{
		return !isPublic() && !isProtected() && !isPrivate();
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberName.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * Represents the name of a member.
 *
 * @since 2018/09/09
 */
public interface MemberName
{
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2018/09/09
	 */
	public abstract String identifier();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberNameAndType.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents something which is a member and has a member name and type.
 *
 * @since 2018/09/09
 */
public interface MemberNameAndType
{
	/**
	 * Returns the name of the member.
	 *
	 * @return The member name.
	 * @since 2018/09/09
	 */
	public abstract MemberName name();
	
	/**
	 * Returns the type of the member.
	 *
	 * @return The member type.
	 * @since 2018/09/09
	 */
	public abstract MemberDescriptor type();
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MemberReference.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This is the base class for field and method references.
 *
 * @since 2017/06/12
 */
public abstract class MemberReference
{
	/** The class this refers to. */
	protected final ClassName classname;
	
	/**
	 * Initializes the base member reference.
	 *
	 * @param __c The class the member resides in.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	MemberReference(ClassName __c)
		throws NullPointerException
	{
		// Check
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.classname = __c;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract boolean equals(Object __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * Returns the name of the member being referenced.
	 *
	 * @return The name of the referenced member.
	 * @since 2017/06/12
	 */
	public abstract Identifier memberName();
	
	/**
	 * Returns the name and type of the member.
	 *
	 * @return The member name and type.
	 * @since 2018/09/09
	 */
	public abstract MemberNameAndType memberNameAndType();
	
	/**
	 * Returns the type of the member.
	 *
	 * @return The member type.
	 * @since 2018/09/09
	 */
	public abstract MemberDescriptor memberType();
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public abstract String toString();
	
	/**
	 * Returns the class the member exists within.
	 *
	 * @return The class containing the member.
	 * @since 2017/06/12
	 */
	public final ClassName className()
	{
		return this.classname;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Method.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387



































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NearNativeByteCodeHandler;
import dev.shadowtail.classfile.xlate.ByteCodeProcessor;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableArrayList;

/**
 * This represents a method which is used to execute byte code.
 *
 * @since 2017/09/30
 */
public final class Method
	extends Member
	implements Annotated, HasMemberFlags
{
	/** The version of the class. */
	protected final ClassVersion version;
	
	/** The flags for class. */
	protected final ClassFlags classflags;
	
	/** The name of the current class. */
	protected final ClassName classname;
	
	/** The constant pool. */
	protected final Pool pool;
	
	/** The flags for the current method. */
	protected final MethodFlags methodflags;
	
	/** The name of the method. */
	protected final MethodName methodname;
	
	/** The type of the method. */
	protected final MethodDescriptor methodtype;
	
	/** Does this method have code? */
	protected final boolean hascode;
	
	/** Annotated values. */
	private final AnnotationTable annotations;
	
	/** The code attribute data, which is optional. */
	private final byte[] _rawcodeattr;
	
	/** The method byte code. */
	private Reference<ByteCode> _bytecode;
	
	/** Native code. */
	private Reference<NativeCode> _regcode;
	
	/** Name and type reference. */
	private Reference<MethodNameAndType> _nameandtype;
	
	/** The method index. */
	private Reference<MethodHandle> _index;
	
	/**
	 * Initializes the method.
	 *
	 * @param __ver The class version.
	 * @param __cf The class flags.
	 * @param __tn The name of the class.
	 * @param __pool The constant pool.
	 * @param __mf The method flags.
	 * @param __mn The name of the method.
	 * @param __mt The method type.
	 * @param __mc An optional byte array representing the code attribute, the
	 * value is used directly.
	 * @param __avs Annotations associated with this method.
	 * @throws NullPointerException On null arguments except for {@code __mc}.
	 * @since 2017/09/30
	 */
	Method(ClassVersion __ver, ClassFlags __cf, ClassName __tn, Pool __pool,
		MethodFlags __mf, MethodName __mn, MethodDescriptor __mt, byte[] __mc,
		AnnotationTable __avs)
		throws NullPointerException
	{
		if (__ver == null || __cf == null || __tn == null || __pool == null ||
			__mf == null || __mn == null || __mt == null || __avs == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.version = __ver;
		this.classflags = __cf;
		this.classname = __tn;
		this.pool = __pool;
		this.methodflags = __mf;
		this.methodname = __mn;
		this.methodtype = __mt;
		this.annotations = __avs;
		this._rawcodeattr = __mc;
		this.hascode = !__mf.isNative() && !__mf.isAbstract();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final AnnotationTable annotationTable()
	{
		return this.annotations;
	}
	
	/**
	 * Returns the byte code for this method.
	 *
	 * @return The byte code for this method or {@code null} if there is none.
	 * @throws InvalidClassFormatException If the byte code is not valid.
	 * @since 2017/10/09
	 */
	public final ByteCode byteCode()
		throws InvalidClassFormatException
	{
		// If there is no code atribute there is no byte code
		byte[] rawcodeattr = this._rawcodeattr;
		if (!this.hascode)
			return null;
		
		// Otherwise load a representation of it
		Reference<ByteCode> ref = this._bytecode;
		ByteCode rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._bytecode = new WeakReference<>((rv = new ByteCode(
				new WeakReference<>(this), this._rawcodeattr,
				this.classname, this.methodflags)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/11
	 */
	@Override
	public final MethodFlags flags()
	{
		return this.methodflags;
	}
	
	/**
	 * Returns the index of the method.
	 *
	 * @return The method index.
	 * @since 2017/10/14
	 */
	public final MethodHandle handle()
	{
		Reference<MethodHandle> ref = this._index;
		MethodHandle rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._index = new WeakReference<>(rv = new MethodHandle(
				this.classname, this.methodname, this.methodtype));
		
		return rv;
	}
	
	/**
	 * Returns if this method is effectively final, meaning that it cannot be
	 * replaced.
	 *
	 * @return If this method is effectively final or not.
	 * @since 2017/10/16
	 */
	public boolean isEffectivelyFinal()
	{
		return this.methodflags.isFinal() || this.classflags.isFinal();
	}
	
	/**
	 * Returns whether this is a constructor or not.
	 *
	 * @return Whether this is a constructor or not.
	 * @since 2018/09/03
	 */
	public final boolean isInstanceInitializer()
	{
		return this.methodname.isInstanceInitializer();
	}
	
	/**
	 * Returns whether this is a static initializer or not.
	 *
	 * @return Whether this is a static initializer or not.
	 * @since 2018/09/03
	 */
	public final boolean isStaticInitializer()
	{
		return this.methodname.isStaticInitializer();
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2017/10/12
	 */
	public final MethodName name()
	{
		return this.methodname;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nameandtype;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nameandtype = new WeakReference<>(
				rv = new MethodNameAndType(this.methodname, this.methodtype));
		
		return rv;
	}
	
	/**
	 * Returns the code of this method in a register based format that is
	 * more efficient than pure Java byte code.
	 *
	 * @return The code of this method in a register based format.
	 * @since 2019/03/09
	 */
	public final NativeCode nativeCode()
	{
		// Abstract and native methods have no code
		if (!this.hascode)
			return null;
		
		// Cache it
		Reference<NativeCode> ref = this._regcode;
		NativeCode rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			ByteCode bc = this.byteCode();
			
			// Process Code
			try
			{
				NearNativeByteCodeHandler nnbc =
					new NearNativeByteCodeHandler(bc);
				new ByteCodeProcessor(bc, nnbc).process();
				
				// Cache the result of it
				this._regcode = new WeakReference<>((rv = nnbc.result()));
			}
			
			// {@squirreljme.error JC3e Could not compile the native code for
			// the given method. (The class; Method name; Method type)}
			catch (InvalidClassFormatException e)
			{
				throw new InvalidClassFormatException(
					String.format("JC3e %s %s %s", this.classname,
						this.methodname, this.methodtype), e);
			}
		}
		
		return rv;
	}
	
	/**
	 * Returns the constant pool this method uses.
	 *
	 * @return The constant pool which is used.
	 * @since 2017/10/09
	 */
	public final Pool pool()
	{
		return this.pool;
	}
	
	/**
	 * Returns the method's type.
	 *
	 * @return The type of the method.
	 * @since 2017/10/16
	 */
	public final MethodDescriptor type()
	{
		return this.methodtype;
	}
	
	/**
	 * Decodes all methods from the input class data.
	 *
	 * @param __ver The version of the class.
	 * @param __tn The name of the owning class.
	 * @param __cf The flags for the owning class.
	 * @param __pool The constant pool for the class.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/30
	 */
	public static Method[] decode(ClassVersion __ver, ClassName __tn,
		ClassFlags __cf, Pool __pool, DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__ver == null || __tn == null || __cf == null || __pool == null ||
			__in == null)
			throw new NullPointerException("NARG");
		
		int nm = __in.readUnsignedShort();
		Method[] rv = new Method[nm];
		Set<NameAndType> dup = new HashSet<>();
		
		// Parse fields
		for (int i = 0; i < nm; i++)
		{
			// Read the flags but do not initialize them yet
			int rawflags = __in.readUnsignedShort();
			
			// Parse name, this is needed to see if it is a constructor
			MethodName name = new MethodName(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// Initialize the flags now that we know the class name, this way
			// we can determine if this is a constructor or not
			MethodFlags flags = new MethodFlags(__cf, name, rawflags);
			
			// Continue reading the type
			MethodDescriptor type = new MethodDescriptor(
				__pool.<UTFConstantEntry>require(UTFConstantEntry.class,
				__in.readUnsignedShort()).toString());
			
			// {@squirreljme.error JC3f A duplicate method exists within the
			// class. (The method name; The method descriptor)}
			if (!dup.add(new NameAndType(name.toString(), type.toString())))
				throw new InvalidClassFormatException(String.format(
					"JC3f %s %s", name, type));
			
			// Handle attributes
			AttributeTable attrs = AttributeTable.parse(__pool, __in);
			
			// Parse annotations
			AnnotationTable annotations = AnnotationTable.parse(__pool, attrs);
			
			// Get copy of the code attribute
			Attribute maybecode = attrs.get("Code");
			byte[] code = (maybecode == null ? null : maybecode.bytes());
			
			// {@squirreljme.error JC3g The specified method does not have
			// the correct matching for abstract and if code exists or not.
			// (The current
			// class; The method name; The method type; The method flags)}
			if ((code == null) != (flags.isAbstract() | flags.isNative()))
				throw new InvalidClassFormatException(String.format(
					"JC3g %s %s %s", __tn, name, type, flags));
			
			// Create
			rv[i] = new Method(__ver, __cf, __tn, __pool, flags, name, type,
				code, annotations);
		}
		
		// All done!
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodDescriptor.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293





































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.util.ArrayList;
import java.util.List;

/**
 * This represents the type descriptor of a method.
 *
 * @since 2017/06/12
 */
public final class MethodDescriptor
	implements MemberDescriptor
{
	/** String representation of the descriptor. */
	protected final String string;
	
	/** The return value, null is void. */
	protected final FieldDescriptor rvalue;
	
	/** The arguments in the method. */
	private final FieldDescriptor[] _args;
	
	/**
	 * Initializes the descriptor with the given descriptors.
	 *
	 * @param __rv The return value.
	 * @param __args Arguments to the descriptor.
	 * @throws InvalidClassFormatException If the descriptor is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/08
	 */
	public MethodDescriptor(FieldDescriptor __rv, FieldDescriptor... __args)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__rv == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Need to build the string representation
		StringBuilder sb = new StringBuilder();
		sb.append('(');
		
		// Check for more nulls and build the string
		__args = __args.clone();
		for (FieldDescriptor f : __args)
		{
			if (f == null)
				throw new NullPointerException("NARG");
			
			sb.append(f.toString());
		}
		
		// Finish with the return value
		sb.append(')');
		sb.append((__rv == null ? "V" : __rv.toString()));
		
		// Set because these are copies
		this.rvalue = __rv;
		this._args = __args;
		this.string = sb.toString();
	}
	
	/**
	 * Initializes the method descriptor.
	 *
	 * @param __n The method descriptor to decode.
	 * @throws InvalidClassFormatException If it is not a valid method
	 * descriptor.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public MethodDescriptor(String __n)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __n;
		
		// {@squirreljme.error JC3h Method descriptors must start with an open
		// parenthesis. (The method descriptor)}
		if (!__n.startsWith("("))
			throw new InvalidClassFormatException(
				String.format("JC3h %s", __n));
		
		// Parse all input arguments
		List<FieldDescriptor> args = new ArrayList<>();
		int i = 1, n = __n.length();
		for (; i < n;)
		{
			char c = __n.charAt(i);
			
			// End of descriptor arguments
			if (c == ')')
				break;
			
			// Skip array markers
			int at = i;
			for (; at < n; at++)
				if ('[' != __n.charAt(at))
					break;
			
			// {@squirreljme.error JC3i Reached end of descriptor parsing
			// arguments. (The method descriptor)}
			if (at >= n)
				throw new InvalidClassFormatException(
					String.format("JC3i %s", __n));
			
			// Find end sequence
			switch (__n.charAt(at))
			{
					// Primitive
				case 'B':
				case 'C':
				case 'D':
				case 'F':
				case 'I':
				case 'J':
				case 'S':
				case 'Z':
					break;
					
					// Class, find ;
				case 'L':
					for (; at < n; at++)
						if (';' == __n.charAt(at))
							break;
					break;
				
					// {@squirreljme.error JC3j Unknown field descriptor in
					// method descriptor argument. (The descriptor)}
				default:
					throw new InvalidClassFormatException(
						String.format("JC3j %s", __n));
			}
			
			// Parse field
			args.add(new FieldDescriptor(__n.substring(i, at + 1)));
			
			// Go to next field
			i = at + 1;
		}
		this._args = args.<FieldDescriptor>toArray(
			new FieldDescriptor[args.size()]);
		
		// Skip the ending parenthesis
		i++;
		
		// {@squirreljme.error JC3k The method descriptor has no return
		// value. (The method descriptor)}
		if (i >= n)
			throw new InvalidClassFormatException(
				String.format("JC3k %s", __n));
		
		// No return value?
		char c = __n.charAt(i);
		if (c == 'V' && (i + 1) == n)
			this.rvalue = null;
		
		// Parse as a field
		else
			this.rvalue = new FieldDescriptor(__n.substring(i));
	}
	
	/**
	 * Returns the argument of the given parameter number.
	 *
	 * @param __i The parameter to get the argument for.
	 * @throws IndexOutOfBoundsException If the argument is not within bounds.
	 * @since 2017/07/28
	 */
	public FieldDescriptor argument(int __i)
		throws IndexOutOfBoundsException
	{
		return this._args[__i];
	}
	
	/**
	 * Returns all of the arguments.
	 *
	 * @return The arguments.
	 * @since 2019/04/14
	 */
	public FieldDescriptor[] arguments()
	{
		return this._args.clone();
	}
	
	/**
	 * Returns the number of arguments this descriptor has.
	 *
	 * @return The number of arguments this descriptor has.
	 * @since 2017/07/28
	 */
	public int argumentCount()
	{
		return this._args.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof MethodDescriptor))
			return false;
		
		return this.string.equals(((MethodDescriptor)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Does this method have a return value?
	 *
	 * @return If the method has a return value.
	 * @since 2018/09/16
	 */
	public final boolean hasReturnValue()
	{
		return null != this.rvalue;
	}
	
	/**
	 * Returns the Java type stack for this descriptor.
	 * 
	 * @return The descriptor as it appears on the Java Stack.
	 * @since 2017/09/16
	 */
	public JavaType[] javaStack()
	{
		// Handle all arguments now
		int n = argumentCount();
		List<JavaType> rv = new ArrayList<>(n * 2);
		for (int i = 0; i < n; i++)
		{
			FieldDescriptor a;
			JavaType j;
			rv.add(j = new JavaType(a = argument(i)));
			
			// Add top of long/double but with unique distinct types
			if (j.isWide())
				rv.add(j.topType());
		}
		
		return rv.<JavaType>toArray(new JavaType[rv.size()]);
	}
	
	/**
	 * Returns the return value of this descriptor.
	 *
	 * @return The value returned in this descriptor or {@code null} if there
	 * is no return value.
	 * @since 2017/09/22
	 */
	public FieldDescriptor returnValue()
	{
		return this.rvalue;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodFlag.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * These are flags which are used by methods.
 *
 * @since 2016/04/23
 */
public enum MethodFlag
	implements MemberFlag
{
	/** Public method. */
	PUBLIC,
	
	/** Private method. */
	PRIVATE,
	
	/** Protected method. */
	PROTECTED,
	
	/** Static method. */
	STATIC,
	
	/** Final method. */
	FINAL,
	
	/** Synchronized method. */
	SYNCHRONIZED,
	
	/** Bridge method. */
	BRIDGE,
	
	/** Variable argument method. */
	VARARGS,
	
	/** Native method. */
	NATIVE,
	
	/** Abstract method. */
	ABSTRACT,
	
	/** Strict floating point method. */
	STRICT,
	
	/** Synthetic method. */
	SYNTHETIC,
	
	/** End. */
	;
	
	/**
	 * Returns the bit mask which is used for this flag.
	 *
	 * @return The bit mask used for the flag.
	 * @since 2017/07/07
	 */
	public final int javaBitMask()
	{
		switch (this)
		{
			case PUBLIC:		return 0x0001;
			case PRIVATE:		return 0x0002;
			case PROTECTED:		return 0x0004;
			case STATIC:		return 0x0008;
			case FINAL:			return 0x0010;
			case SYNCHRONIZED:	return 0x0020;
			case BRIDGE:		return 0x0040;
			case VARARGS:		return 0x0080;
			case NATIVE:		return 0x0100;
			case ABSTRACT:		return 0x0400;
			case STRICT:		return 0x0800;
			case SYNTHETIC:		return 0x1000;

			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodFlags.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the set of flags for methods.
 *
 * @since 2016/04/23
 */
public final class MethodFlags
	extends MemberFlags<MethodFlag>
{
	/**
	 * Initializes the method flags, with no checks performed on them.
	 *
	 * @param __i The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(int __i)
	{
		super(MethodFlag.class,
			Flags.<MethodFlag>__decode(__i, MethodFlag.values()));
	}
	
	/**
	 * Initializes the method flags.
	 *
	 * @param __oc The outer class.
	 * @param __nm The name of the method.
	 * @param __fl The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn, MethodFlag... __fl)
	{
		super(MethodFlag.class, __fl);
		
		__checkFlags(__oc, __mn);
	}
	
	/**
	 * Initializes the method flags.
	 *
	 * @param __oc The outer class.
	 * @param __nm The name of the method.
	 * @param __fl The method flags.
	 * @since 2016/04/23
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn,
		Iterable<MethodFlag> __fl)
	{
		super(MethodFlag.class, __fl);
		
		__checkFlags(__oc, __mn);
	}
	
	/**
	 * Decodes method flags from the bit field.
	 *
	 * @param __oc The outer class flags.
	 * @param __nm The name of the method.
	 * @param __i The bitfield to decode.
	 * @since 2017/07/07
	 */
	public MethodFlags(ClassFlags __oc, MethodName __mn, int __i)
	{
		this(__oc, __mn, Flags.<MethodFlag>__decode(__i, MethodFlag.values()));
	}
	
	/**
	 * Returns {@code true} if this is abstract.
	 *
	 * @return {@code true} if abstract.
	 * @since 2016/03/20
	 */
	public boolean isAbstract()
	{
		return contains(MethodFlag.ABSTRACT);
	}
	
	/**
	 * Returns {@code true} if this is a bridge method.
	 *
	 * @return {@code true} if a bridge method.
	 * @since 2016/03/20
	 */
	public boolean isBridge()
	{
		return contains(MethodFlag.BRIDGE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isFinal()
	{
		return contains(MethodFlag.FINAL);
	}
	
	/**
	 * Returns {@code true} if this is a native method.
	 *
	 * @return {@code true} if it is native.
	 * @since 2016/03/20
	 */
	public boolean isNative()
	{
		return contains(MethodFlag.NATIVE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPrivate()
	{
		return contains(MethodFlag.PRIVATE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isProtected()
	{
		return contains(MethodFlag.PROTECTED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isPublic()
	{
		return contains(MethodFlag.PUBLIC);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isStatic()
	{
		return contains(MethodFlag.STATIC);
	}
	
	/**
	 * Returns {@code true} if this is strict.
	 *
	 * @return {@code true} if strict.
	 * @since 2016/03/20
	 */
	public boolean isStrict()
	{
		return contains(MethodFlag.STRICT);
	}
	
	/**
	 * Returns {@code true} if this is synchronized.
	 *
	 * @return {@code true} if synchronized.
	 * @since 2016/03/20
	 */
	public boolean isSynchronized()
	{
		return contains(MethodFlag.SYNCHRONIZED);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/03/20
	 */
	@Override
	public boolean isSynthetic()
	{
		return contains(MethodFlag.SYNTHETIC);
	}
	
	/**
	 * Returns {@code true} if this uses variable arguments.
	 *
	 * @return {@code true} if it uses variable arguments.
	 * @since 2016/03/20
	 */
	public boolean isVarArgs()
	{
		return contains(MethodFlag.VARARGS);
	}
	
	/**
	 * Checks that the given flags are valid.
	 *
	 * @param __oc The outer class.
	 * @param __mn The name of the method.
	 * @throws InvalidClassFormatException If they are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/04/23
	 */
	private final void __checkFlags(ClassFlags __oc, MethodName __mn)
		throws InvalidClassFormatException
	{
		// Check
		if (__oc == null || __mn == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3l An {@code abstract} method cannot be
		// {@code private}, {@code static}, {@code final},
		// {@code synchronized}, {@code native}, or {@code strictfp}. (The
		// method flags)}
		if (isAbstract())
			if (isPrivate() || isStatic() || isFinal() || isSynchronized() ||
				isNative() || isStrict())
				throw new InvalidClassFormatException(
					String.format("JC3l %s", this));
		
		// If the class is an interface it cannot have specific flags set
		// Ignore checking these interface flags if we are in an interface and
		// this is a static constructor because otherwise the check will fail
		// since there cannot be static items
		if (__oc.isInterface() && !__mn.isStaticInitializer())
			for (MethodFlag f : MethodFlag.values())
			{
				// Must have these
				boolean must = (f == MethodFlag.PUBLIC ||
					f == MethodFlag.ABSTRACT);
				
				// Could have these
				boolean maybe = (f == MethodFlag.SYNTHETIC ||
					f == MethodFlag.VARARGS || f == MethodFlag.BRIDGE);
				
				// Is it set?
				boolean has = contains(f);
				
				// {@squirreljme.error JC3m Flags for interface method has an
				// incorrect set of flags. (The method flags)}
				if (must != has && !maybe)
					throw new InvalidClassFormatException(
						String.format("JC3m %s", this));
			}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodHandle.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a method's class, name, and type.
 *
 * @since 2017/09/16
 */
public final class MethodHandle
	implements Comparable<MethodHandle>
{
	/** The class the method is in. */
	protected final ClassName outerclass;
	
	/** The name of the method. */
	protected final MethodName name;
	
	/** The descriptor of the method. */
	protected final MethodDescriptor descriptor;
	
	/** Method name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the method handle.
	 *
	 * @param __cl The class the method is in.
	 * @param __n The name of the method.
	 * @param __d The descriptor of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/16
	 */
	public MethodHandle(ClassName __cl, MethodName __n, MethodDescriptor __d)
		throws NullPointerException
	{
		// Check
		if (__cl == null || __n == null || __d == null)
			throw new NullPointerException("NARG");
		
		this.outerclass = __cl;
		this.name = __n;
		this.descriptor = __d;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/14
	 */
	@Override
	public int compareTo(MethodHandle __o)
	{
		int rv;
		if ((rv = this.outerclass.compareTo(__o.outerclass)) != 0)
			return rv;
		if ((rv = this.name.compareTo(__o.name)) != 0)
			return rv;
		return this.descriptor.toString().compareTo(__o.descriptor.toString());
	}
	
	/**
	 * Returns the descriptor of the method.
	 *
	 * @return The method descriptor.
	 * @since 2017/09/16
	 */
	public MethodDescriptor descriptor()
	{
		return this.descriptor;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof MethodHandle))
			return false;
		
		MethodHandle o = (MethodHandle)__o;
		return this.outerclass.equals(o.outerclass) &&
			this.name.equals(o.name) &&
			this.descriptor.equals(o.descriptor);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public int hashCode()
	{
		return this.outerclass.hashCode() ^
			this.name.hashCode() ^
			this.descriptor.hashCode();
	}
	
	/**
	 * Returns {@code true} if this represents the instance initializer.
	 *
	 * @return {@code true} if this is the instance initializer.
	 * @since 2017/09/18
	 */
	public boolean isInstanceInitializer()
	{
		return this.name.isInstanceInitializer();
	}
	
	/**
	 * Returns the Java type stack for this handle.
	 * 
	 * @param __i If {@code true} then this is an instance invocation.
	 * @return The handle as it appears on the Java Stack.
	 * @since 2017/09/16
	 */
	public JavaType[] javaStack(boolean __i)
	{
		// No need to add current class type
		JavaType[] djs = this.descriptor.javaStack();
		if (!__i)
			return djs;
		
		// Just copy over
		int dn = djs.length;
		JavaType[] rv = new JavaType[dn + 1];
		rv[0] = new JavaType(this.outerclass);
		for (int i = 0, o = 1; i < dn; i++, o++)
			rv[o] = djs[i];
		
		return rv;
	}
	
	/**
	 * Returns the name of the method.
	 *
	 * @return The method name.
	 * @since 2017/09/16
	 */
	public MethodName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the name and type of the method.
	 *
	 * @return The method name and type.
	 * @since 2019/04/17
	 */
	public final MethodNameAndType nameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._nat = new WeakReference<>((rv = new MethodNameAndType(
				this.name, this.descriptor)));
		
		return rv;
	}
	
	/**
	 * Returns the class this is contained within.
	 *
	 * @return The outer class.
	 * @since 2017/09/16
	 */
	public ClassName outerClass()
	{
		return this.outerclass;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/16
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s::%s%s",
				this.outerclass, this.name, this.descriptor)));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodName.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
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







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents the name of a method. This has the same constraints as the
 * identifier except it cannot contain the {@code <} or {@code >} symbols
 * unless it is {@code <init>} or {@code <clinit>}.
 *
 * @since 2017/07/07
 */
public final class MethodName
	extends Identifier
	implements Comparable<MethodName>, MemberName
{
	/**
	 * Initializes the method name.
	 *
	 * @param __s The method name.
	 * @throws InvalidClassFormatException If the method name is method valid.
	 * @since 2017/07/07
	 */
	public MethodName(String __s)
		throws InvalidClassFormatException
	{
		super(__s);
		
		// Cannot contain < or >
		if (!__s.equals("<init>") && !__s.equals("<clinit>"))
			for (int i = 0, n = __s.length(); i < n; i++)
			{
				char c = __s.charAt(i);
				
				// {@squirreljme.error JC3n Method names cannot contain less
				// than or greater than signs. (The method name)}
				if (c == '<' || c == '>')
					throw new InvalidClassFormatException(
						String.format("JC3n %s", __s));
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int compareTo(MethodName __o)
	{
		return this.string.compareTo(__o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/07
	 */
	@Override
	public boolean equals(Object __o)
	{
		return (__o instanceof MethodName) && super.equals(__o);
	}
	
	/**
	 * Is this any initializer for a method.
	 *
	 * @return If this is any initializer method.
	 * @since 2017/10/12
	 */
	public boolean isAnyInitializer()
	{
		return isInstanceInitializer() || isStaticInitializer();
	}
	
	/**
	 * Returns {@code true} if this represents the instance initializer.
	 *
	 * @return {@code true} if this is the instance initializer.
	 * @since 2017/07/28
	 */
	public boolean isInstanceInitializer()
	{
		return this.string.equals("<init>");
	}
	
	/**
	 * Returns {@code true} if this represents the static initializer.
	 *
	 * @return {@code true} if this is the static initializer.
	 * @since 2017/07/28
	 */
	public boolean isStaticInitializer()
	{
		return this.string.equals("<clinit>");
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodNameAndType.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
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






























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the name and type for a method.
 *
 * @since 2017/10/10
 */
public final class MethodNameAndType
	implements Comparable<MethodNameAndType>, MemberNameAndType
{
	/** The method name. */
	protected final MethodName name;
	
	/** The method type. */
	protected final MethodDescriptor type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the method anme and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws InvalidClassFormatException If the method name and type are not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/03
	 */
	public MethodNameAndType(String __n, String __t)
		throws InvalidClassFormatException, NullPointerException
	{
		this(new MethodName(__n), new MethodDescriptor(__t));
	}
	
	/**
	 * Initializes the method anme and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws InvalidClassFormatException If the method name and type are not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/19
	 */
	public MethodNameAndType(String __n, MethodDescriptor __t)
		throws InvalidClassFormatException, NullPointerException
	{
		this(new MethodName(__n), __t);
	}
	
	/**
	 * Initializes the method name and type.
	 *
	 * @param __n The name of the method.
	 * @param __t The type of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/10
	 */
	public MethodNameAndType(MethodName __n, MethodDescriptor __t)
		throws NullPointerException
	{
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int compareTo(MethodNameAndType __o)
	{
		int rv = this.name.compareTo(__o.name);
		if (rv != 0)
			return rv;
		return this.type.toString().compareTo(__o.type.toString());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof MethodNameAndType))
			return false;
		
		MethodNameAndType o = (MethodNameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public MethodName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s:%s",
				this.name, this.type)));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/10/10
	 */
	@Override
	public MethodDescriptor type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/MethodReference.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
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





















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This describes a reference to a method.
 *
 * @since 2017/06/12
 */
public final class MethodReference
	extends MemberReference
{
	/** The method handle. */
	protected final MethodHandle handle;
	
	/** Is this an interface? */
	protected final boolean isinterface;
	
	/** String representation. */
	private Reference<String> _string;
	
	/** Name and type. */
	private Reference<MethodNameAndType> _nat;
	
	/**
	 * Initializes the method reference.
	 *
	 * @param __h The handle of the class.
	 * @param __int Does this refer to an interface method?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/16
	 */
	public MethodReference(MethodHandle __h, boolean __int)
	{
		super(__h.outerClass());
		
		// Check
		if (__h == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.handle = __h;
		this.isinterface = __int;
	}
	
	/**
	 * Initializes the method reference.
	 *
	 * @param __c The class the member resides in.
	 * @param __i The name of the member.
	 * @param __t The descriptor of the member.
	 * @param __int Does this refer to an interface method?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public MethodReference(ClassName __c, MethodName __i,
		MethodDescriptor __t, boolean __int)
		throws NullPointerException
	{
		this(new MethodHandle(__c, __i, __t), __int);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof MethodReference))
			return false;
		
		MethodReference o = (MethodReference)__o;
		return this.handle.equals(o.handle) &&
			this.isinterface == o.isinterface;
	}
	
	/**
	 * Returns the method handle.
	 *
	 * @return The method handle.
	 * @since 2017/09/16
	 */
	public MethodHandle handle()
	{
		return this.handle;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.handle.hashCode() ^ (this.isinterface ? 1 : 0);
	}
	
	/**
	 * Is this an interface method reference?
	 *
	 * @return {@code true} if a reference to an interface method.
	 * @since 2017/07/15
	 */
	public boolean isInterface()
	{
		return this.isinterface;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/08
	 */
	@Override
	public final MethodName memberName()
	{
		return this.handle.name();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodNameAndType memberNameAndType()
	{
		Reference<MethodNameAndType> ref = this._nat;
		MethodNameAndType rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			MethodHandle handle = this.handle;
			this._nat = new WeakReference<>(
				(rv = new MethodNameAndType(handle.name(),
					handle.descriptor())));
		}
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/09
	 */
	@Override
	public final MethodDescriptor memberType()
	{
		return this.handle.descriptor();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%smethod %s",
				(this.isinterface ? "interface-" : ""), this.handle)));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/NameAndType.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This holds the name and type strings, the type descriptor is not checked.
 *
 * @since 2017/06/12
 */
public final class NameAndType
{
	/** The name. */
	protected final String name;
	
	/** The type. */
	protected final String type;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the name and type information.
	 *
	 * @param __n The name.
	 * @param __t The type.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	public NameAndType(String __n, String __t)
		throws NullPointerException
	{
		// Check
		if (__n == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __n;
		this.type = __t;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof NameAndType))
			return false;
		
		NameAndType o = (NameAndType)__o;
		return this.name.equals(o.name) &&
			this.type.equals(o.type);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public int hashCode()
	{
		return this.name.hashCode() ^ this.type.hashCode();
	}
	
	/**
	 * Returns the identifier.
	 *
	 * @return The identifier.
	 * @since 2017/06/12
	 */
	public String name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/12
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.name + "." +
				this.type));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/06/12
	 */
	public String type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/Pool.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445





























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.UTFDataFormatException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

/**
 * This class decodes the constant pool and provides generic access to the
 * contents of it.
 *
 * @since 2017/06/08
 */
public final class Pool
{
	/** The UTF constant tag. */
	public static final int TAG_UTF8 =
		1;
	
	/** Integer constant. */
	public static final int TAG_INTEGER =
		3;
	
	/** Float constant. */
	public static final int TAG_FLOAT =
		4;
	
	/** Long constant. */
	public static final int TAG_LONG =
		5;
	
	/** Double constant. */
	public static final int TAG_DOUBLE =
		6;
	
	/** Reference to another class. */
	public static final int TAG_CLASS =
		7;
	
	/** String constant. */
	public static final int TAG_STRING =
		8;
	
	/** Field reference. */
	public static final int TAG_FIELDREF =
		9;
	
	/** Method reference. */
	public static final int TAG_METHODREF =
		10;
	
	/** Interface method reference. */
	public static final int TAG_INTERFACEMETHODREF =
		11;
	
	/** Name and type. */
	public static final int TAG_NAMEANDTYPE =
		12;
	
	/** Method handle (illegal). */
	public static final int TAG_METHODHANDLE =
		15;
	
	/** Method type (illegal). */
	public static final int TAG_METHODTYPE =
		16;
	
	/** Invoke dynamic call site (illegal). */
	public static final int TAG_INVOKEDYNAMIC =
		18;
	
	/** The top of a long/double. */
	public static final int TAG_WIDETOP =
		-1;
	
	/** Entries within the constant pool. */
	private final Object[] _entries;
	
	/**
	 * Parses and initializes the constant pool structures.
	 *
	 * @param __e The entries which make up the pool, this is used directly.
	 * @since 2017/06/08
	 */
	Pool(Object... __e)
	{
		this._entries = (__e == null ? new Object[0] : __e);
	}
	
	/**
	 * Obtains the entry at the specified index.
	 *
	 * @param <C> The type of class to get.
	 * @param __cl The type of class to get.
	 * @param __i The index of the entry to get.
	 * @return The entry at the specified position as the given class or
	 * {@code null} if it does not exist.
	 * @throws InvalidClassFormatException If the class type does not match or
	 * the pool index is out of range.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/08
	 */
	public <C> C get(Class<C> __cl, int __i)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Short circuit, the zero entry is always nothing
		if (__i == 0)
			return null;
		
		// {@squirreljme.error JC3o The specified index is not within the bounds
		// of the constant pool. (The index of the entry)}
		Object[] entries = this._entries;
		if (__i < 0 || __i >= entries.length)
			throw new InvalidClassFormatException(
				String.format("JC3o %d", __i));
		
		// {@squirreljme.error JC3p The specified entry's class is not of the
		// expected class. (The index of the entry; The class the entry is; The
		// expected class)}
		Object val = entries[__i];
		if (val != null && !__cl.isInstance(val))
			throw new InvalidClassFormatException(
				String.format("JC3p %d %s %s", __i, val.getClass(), __cl));
		
		return __cl.cast(val);
	}
	
	/**
	 * This is similar to {@link #get(Class, int)} except that it is not valid
	 * if the entry is the {@code null} entry (the first one).
	 *
	 * @param <C> The type of class to get.
	 * @param __cl The type of class to get.
	 * @param __i The index of the entry to get.
	 * @return The entry at the specified position as the given class.
	 * @throws InvalidClassFormatException If the class type does not match,
	 * the pool index is out of range, or the entry is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/14
	 */
	public <C> C require(Class<C> __cl, int __i)
		throws InvalidClassFormatException, NullPointerException
	{
		// {@squirreljme.error JC3q Expected the specified constant pool entry
		// to not be the null entry. (The index; The expected class)}
		C rv = this.<C>get(__cl, __i);
		if (rv == null)
			throw new InvalidClassFormatException(
				String.format("JC3q %d %s", __i, __cl));
		return rv;
	}
	
	/**
	 * Decodes the constant pool.
	 *
	 * @param __in The input stream.
	 * @return The read constant pool.
	 * @throws InvalidClassFormatException If the constant pool is not valid.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/27
	 */
	public static Pool decode(DataInputStream __in)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read the raw constant pool contents first
		int count = __in.readUnsignedShort();
		int[] tags = new int[count];
		Object[] rawdata = new Object[count];
		for (int i = 1; i < count; i++)
		{
			// Read tag
			int tag = __in.readUnsignedByte();
			tags[i] = tag;
			
			// Parse tag data
			Object data;
			switch (tag)
			{
					// UTF-8 String
					// The string is wrapped in a wrapper class so that String
					// constants are actual String references. It is illegal for
					// UTF-8 constants to be directly used by the byte code so
					// this prevents their usage from occuring by causing a
					// class cast exception
				case TAG_UTF8:
					try
					{
						data = new UTFConstantEntry(__in.readUTF());
					}
					
					// {@squirreljme.error JC3r Modified UTF-8 data is not in
					// the correct format.}
					catch (UTFDataFormatException e)
					{
						throw new InvalidClassFormatException("JC3r", e);
					}
					break;
					
					// Reference to two entries
				case TAG_FIELDREF:
				case TAG_METHODREF:
				case TAG_INTERFACEMETHODREF:
				case TAG_NAMEANDTYPE:
					data = new int[]{__in.readUnsignedShort(),
						__in.readUnsignedShort()};
					break;
					
					// References to single entry
				case TAG_CLASS:
				case TAG_STRING:
					data = new int[]{__in.readUnsignedShort()};
					break;
					
					// Integer
				case TAG_INTEGER:
					data = new ConstantValueInteger(
						Integer.valueOf(__in.readInt()));
					break;
					
					// Long
				case TAG_LONG:
					data = new ConstantValueLong(
						Long.valueOf(__in.readLong()));
					break;
					
					// Float
				case TAG_FLOAT:
					data = new ConstantValueFloat(
						Float.valueOf(__in.readFloat()));
					break;
					
					// Double
				case TAG_DOUBLE:
					data = new ConstantValueDouble(
						Double.valueOf(__in.readDouble()));
					break;
					
					// {@squirreljme.error JC3s Java ME does not support
					// dynamic invocation (such as method handles or lambda
					// expressions).}
				case TAG_METHODHANDLE:
				case TAG_METHODTYPE:
				case TAG_INVOKEDYNAMIC:
					throw new InvalidClassFormatException("JC3s");
				
					// {@squirreljme.error JC3t Unknown tag type in the
					// constant pool. (The constant pool tag)}
				default:
					throw new InvalidClassFormatException(
						String.format("JC3t %d", tag));
			}
			rawdata[i] = data;
			
			// Skip long/double?
			if (tag == TAG_LONG || tag == TAG_DOUBLE)
			{
				rawdata[++i] = new WideConstantTopEntry();
				tags[i] = TAG_WIDETOP;
			}
		}
		
		// Go through tags again and initialize their raw data into type-safe
		// classes 
		Object[] entries = new Object[count];
		try
		{
			__initializeEntries(entries, tags, rawdata);
		}
		
		// {@squirreljme.error JC3u The constant pool is not valid.}
		catch (ClassCastException|IndexOutOfBoundsException|
			NullPointerException e)
		{
			throw new InvalidClassFormatException("JC3u", e);
		}
		
		// Setup
		return new Pool(entries);
	}
	
	/**
	 * This initializes the entries in the constant pool.
	 *
	 * @param __entries Output pool entries.
	 * @param __tags Constant pool tags for the entries.
	 * @param __rawdata The raw pool data.
	 * @throws InvalidClassFormatException If the entries are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/12
	 */
	private static void __initializeEntries(Object[] __entries, int[] __tags,
		Object[] __rawdata)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__entries == null || __tags == null || __rawdata == null)
			throw new NullPointerException("NARG");
		
		// Instead of having a nested loop which goes through every entry
		// multiple times, the sequence entries should be parsed in is very
		// known with a direct line of dependencies. Entries with lower
		// sequences are only depended on. This saves an extra loop and makes
		// the code much cleaner for the most part.
		int count = __entries.length;
		int[] order = new int[count];
		for (int i = 0; i < count; i++)
		{
			int tag = __tags[i],
				sequence;
			
			// Determine the sequence based on the tag
			switch (tag)
			{
				case 0:
				case TAG_UTF8:
				case TAG_INTEGER:
				case TAG_FLOAT:
				case TAG_LONG:
				case TAG_DOUBLE:
				case TAG_WIDETOP:
					sequence = 0;
					break;
				
				case TAG_CLASS:
				case TAG_STRING:
					sequence = 1;
					break;
				
				case TAG_NAMEANDTYPE:
					sequence = 2;
					break;
				
				case TAG_FIELDREF:
				case TAG_METHODREF:
				case TAG_INTERFACEMETHODREF:
					sequence = 3;
					break;
					
				default:
					throw new todo.OOPS();
			}
			
			// Add to order
			order[i] = (sequence << 16) | i;
		}
		Arrays.sort(order);
		
		// Go through and process all of the entries now that their major
		// sequence order is known.
		for (int j = 0; j < count; j++)
		{
			int i = order[j] & 0xFFFF,
				tag = __tags[i];
			
			// Process tags
			Object in = __rawdata[i],
				out;
			switch (tag)
			{
					// These are copied directly
				case 0:
				case TAG_UTF8:
				case TAG_INTEGER:
				case TAG_FLOAT:
				case TAG_LONG:
				case TAG_DOUBLE:
				case TAG_WIDETOP:
					out = in;
					break;
					
					// Name of a class
				case TAG_CLASS:
					out = new ClassName(((UTFConstantEntry)
						__entries[((int[])in)[0]]).toString());
					break;
					
					// String constant
				case TAG_STRING:
					out = new ConstantValueString(
						((UTFConstantEntry)__entries[((int[])in)[0]]).
							toString());
					break;
					
					// Name and type information
				case TAG_NAMEANDTYPE:
					{
						int[] ina = (int[])in;
						out = new NameAndType(
							((UTFConstantEntry)__entries[ina[0]]).toString(),
							((UTFConstantEntry)__entries[ina[1]]).toString());
					}
					break;
					
					// Field and method references
				case TAG_FIELDREF:
				case TAG_METHODREF:
				case TAG_INTERFACEMETHODREF:
					{
						int[] ina = (int[])in;
						ClassName cn = (ClassName)__entries[ina[0]];
						NameAndType nat = (NameAndType)__entries[ina[1]];
						
						if (tag == TAG_FIELDREF)
							out = new FieldReference(cn,
								new FieldName(nat.name()),
								new FieldDescriptor(nat.type()));
						else
							out = new MethodReference(cn,
								new MethodName(nat.name()),
								new MethodDescriptor(nat.type()),
								tag == TAG_INTERFACEMETHODREF);
					}
					break;
				
					// Unhandled, should not happen
				default:
					throw new RuntimeException(String.format("OOPS %d", tag));
			}
			
			__entries[i] = out;
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/PrimitiveType.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
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





















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This enumeration represents a primitive type.
 *
 * @since 2017/10/16
 */
public enum PrimitiveType
{
	/** Byte. */
	BYTE,
	
	/** Character. */
	CHARACTER,
	
	/** Double. */
	DOUBLE,
	
	/** Float. */
	FLOAT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Short. */
	SHORT,
	
	/** Boolean. */
	BOOLEAN,
	
	/** End. */
	;
	
	/**
	 * The number of bytes needed to store this type.
	 *
	 * @return The number of bytes required to store data for this type.
	 * @since 2019/03/11
	 */
	public final int bytes()
	{
		switch (this)
		{
			case BOOLEAN:
			case BYTE:		return 1;
			case SHORT:
			case CHARACTER:	return 2;
			case INTEGER:
			case FLOAT:		return 4;
			case LONG:
			case DOUBLE:	return 8;
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Is this a wide type?
	 *
	 * @return If this is a wide type.
	 * @since 2017/10/16
	 */
	public final boolean isWide()
	{
		return this == LONG || this == DOUBLE;
	}
	
	/**
	 * Does this type promote to int?
	 *
	 * @return If this type promotes to int.
	 * @since 2017/10/16
	 */
	public final boolean promotesToInt()
	{
		switch (this)
		{
			case BYTE:
			case CHARACTER:
			case SHORT:
			case BOOLEAN:
				return true;	
			
			default:
				return false;
		}
	}
	
	/**
	 * Returns the Java type this uses on the stack.
	 *
	 * @return The Java type this uses on the stack.
	 * @since 2019/04/02
	 */
	public final JavaType stackJavaType()
	{
		switch (this)
		{
			case BOOLEAN:
			case BYTE:
			case SHORT:
			case CHARACTER:
			case INTEGER:	return JavaType.INTEGER;
			case FLOAT:		return JavaType.FLOAT;
			case LONG:		return JavaType.LONG;
			case DOUBLE:	return JavaType.DOUBLE;
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Returns the class name for the given type.
	 *
	 * @return The type's class name.
	 * @since 2019/03/24
	 */
	public final ClassName toClassName()
	{
		switch (this)
		{
			case BOOLEAN:	return new ClassName("boolean");
			case BYTE:		return new ClassName("byte");
			case SHORT:		return new ClassName("short");
			case CHARACTER:	return new ClassName("char");
			case INTEGER:	return new ClassName("int");
			case LONG:		return new ClassName("long");
			case FLOAT:		return new ClassName("float");
			case DOUBLE:	return new ClassName("double");
			
			default:
				throw new todo.OOPS(this.toString());
		}
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/SimpleStorageType.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * The simple storage type of a field or other type.
 *
 * @since 2018/09/15
 */
public enum SimpleStorageType
{
	/** Object. */
	OBJECT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/StackMapTable.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
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































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableIterator;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This is the stack map table which is used for verification purposes.
 *
 * @since 2017/10/09
 */
public final class StackMapTable
	implements Iterable<Map.Entry<Integer, StackMapTableState>>
{
	/** Stack map states. */
	private final Map<Integer, StackMapTableState> _states;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map table.
	 *
	 * @param __s The input states.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/16
	 */
	StackMapTable(Map<Integer, StackMapTableState> __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this._states = new SortedTreeMap<>(__s);
	}
	
	/**
	 * Returns the stack map table state for the given entry.
	 *
	 * @param __a The address to get.
	 * @return The state for the given address or {@code null} if it there is
	 * no entry.
	 * @since 2017/10/16
	 */
	public StackMapTableState get(int __a)
	{
		return this._states.get(__a);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/16
	 */
	@Override
	public final Iterator<Map.Entry<Integer, StackMapTableState>> iterator()
	{
		return UnmodifiableIterator.<Map.Entry<Integer, StackMapTableState>>of(
			UnmodifiableMap.<Integer, StackMapTableState>of(
				this._states).entrySet().iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this._states.toString()));
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/StackMapTableEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211



















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a single entry within the stack map table which may
 * additionally has a flag indicating if an entry is initialized or not.
 *
 * @since 2017/09/02
 */
public final class StackMapTableEntry
{
	/** The top of a long. */
	public static final StackMapTableEntry TOP_LONG =
		new StackMapTableEntry(JavaType.TOP_LONG, true);
	
	/** The top of a double. */
	public static final StackMapTableEntry TOP_DOUBLE =
		new StackMapTableEntry(JavaType.TOP_DOUBLE, true);
	
	/** Undefined top type. */
	public static final StackMapTableEntry TOP_UNDEFINED =
		new StackMapTableEntry(JavaType.TOP_UNDEFINED, true);
	
	/** Not used. */
	public static final StackMapTableEntry NOTHING =
		new StackMapTableEntry(JavaType.NOTHING, false);
	
	/** Integer. */
	public static final StackMapTableEntry INTEGER =
		new StackMapTableEntry(JavaType.INTEGER, true);
	
	/** Long. */
	public static final StackMapTableEntry LONG =
		new StackMapTableEntry(JavaType.LONG, true);
	
	/** Float. */
	public static final StackMapTableEntry FLOAT =
		new StackMapTableEntry(JavaType.FLOAT, true);
	
	/** Double. */
	public static final StackMapTableEntry DOUBLE =
		new StackMapTableEntry(JavaType.DOUBLE, true);
	
	/** The type. */
	protected final JavaType type;
	
	/** Is this type initialized? */
	protected final boolean isinitialized;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map entry.
	 *
	 * @param __t The type of variable to store.
	 * @param __init If {@code true} this variable is initialized.
	 * @throws InvalidClassFormatException If a non-object is set as not
	 * initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/02
	 */
	public StackMapTableEntry(JavaType __t, boolean __init)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Nothing can never be initialized
		if (__t.equals(JavaType.NOTHING))
		{
			// {@squirreljme.error JC3v The nothing type cannot be initialized.
			// (The type)}
			if (__init && __t.equals(JavaType.NOTHING))
				throw new InvalidClassFormatException(
					String.format("JI3w %s", __t));
		}
		
		// Otherwise only objects may be initialized
		else
		{
			// {@squirreljme.error JC3w Non-object types cannot be.
			// uninitialized (The type)}
			if (!__init && !__t.isObject())
				throw new InvalidClassFormatException(
					String.format("JC3w %s", __t));
		}
		
		// Set
		this.type = __t;
		this.isinitialized = __init;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof StackMapTableEntry))
			return false;
		
		StackMapTableEntry o = (StackMapTableEntry)__o;
		return this.type.equals(o.type) &&
			this.isinitialized == o.isinitialized;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^ (this.isinitialized ? 1 : 0);
	}
	
	/**
	 * Has this type been initialized?
	 *
	 * @return {@code true} if this type was initialized.
	 * @since 2017/08/13
	 */
	public boolean isInitialized()
	{
		return this.isinitialized;
	}
	
	/**
	 * Is this a top type?
	 *
	 * @return If this is a top type.
	 * @since 2018/09/23
	 */
	public final boolean isTop()
	{
		JavaType type = this.type;
		return type != null && type.isTop();
	}
	
	/**
	 * Does this represent a wide type?
	 *
	 * @return If this is a wide type.
	 * @since 2017/10/16
	 */
	public boolean isWide()
	{
		JavaType t = this.type;
		return t != null && t.isWide();
	}
	
	/**
	 * Returns the top type for this entry.
	 *
	 * @return The top type or {@code null} if there is none.
	 * @since 2018/09/22
	 */
	public final StackMapTableEntry topType()
	{
		if (this.equals(StackMapTableEntry.LONG))
			return StackMapTableEntry.TOP_LONG;
		else if (this.equals(StackMapTableEntry.DOUBLE))
			return StackMapTableEntry.TOP_DOUBLE;
		return null;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/02
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s%s",
				(this.isinitialized ? "" : "!"), this.type)));
		
		return rv;
	}
	
	/**
	 * Returns the type.
	 *
	 * @return The type.
	 * @since 2017/09/02
	 */
	public JavaType type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/StackMapTableState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265









































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

/**
 * This represents a single state within the stack map table which contains
 * a listing of all of the types used for local and stack variable along with
 * the current depth of the stack.
 *
 * @since 2017/07/28
 */
public final class StackMapTableState
{
	/** The depth of the stack. */
	protected final int depth;
	
	/** Local variables. */
	private final StackMapTableEntry[] _locals;
	
	/** Stack variables. */
	private final StackMapTableEntry[] _stack;
	
	/** String representation of this table. */
	private Reference<String> _string;
	
	/**
	 * Initializes the stack map table state.
	 *
	 * @param __l Local variables.
	 * @param __s Stack variables.
	 * @param __d The depth of the stack.
	 * @throws InvalidClassFormatException If the state is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	public StackMapTableState(StackMapTableEntry[] __l,
		StackMapTableEntry[] __s, int __d)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__l == null || __s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC3x The depth of the stack is not within the
		// bounds of the stack. (The stack depth; The stack size)}
		int ns = __s.length;
		if (__d < 0 || __d > ns)
			throw new InvalidClassFormatException(
				String.format("JC3x %d %d", __d, ns));
		
		// Duplicate
		__l = __l.clone();
		__s = __s.clone();
		
		// Clear elements above the stack top
		for (int i = __d; i < ns; i++)
			__s[i] = null;
		
		// Verify each state
		__verify(__l);
		__verify(__s);
		
		// Set
		this._locals = __l;
		this._stack = __s;
		this.depth = __d;
	}
	
	/**
	 * Returns the depth of the stack.
	 *
	 * @return The stack depth.
	 * @since 2017/08/12
	 */
	public int depth()
	{
		return this.depth;
	}
	
	/**
	 * Obtains the local at the given index.
	 *
	 * @param __i The index to get.
	 * @return The type for the variable at the given index.
	 * @throws InvalidClassFormatException If the index is out of range.
	 * @since 2017/08/12
	 */
	public StackMapTableEntry getLocal(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC3y The specified local variable is out of
		// range. (The index)}
		StackMapTableEntry[] locals = this._locals;
		if (__i < 0 || __i >= locals.length)
			throw new InvalidClassFormatException(
				String.format("JC3y %d", __i));
		return locals[__i];
	}
	
	/**
	 * Obtains the stack at the given index.
	 *
	 * @param __i The index to get.
	 * @return The type for the variable at the given index.
	 * @throws InvalidClassFormatException If the index is out of range.
	 * @since 2017/08/12
	 */
	public StackMapTableEntry getStack(int __i)
		throws InvalidClassFormatException
	{
		// {@squirreljme.error JC3z The specified stack variable is out of
		// range. (The index)}
		if (__i < 0 || __i >= this.depth)
			throw new InvalidClassFormatException(
				String.format("JC3z %d", __i));
		return this._stack[__i];
	}
	
	/**
	 * Returns the maximum number of local variables.
	 *
	 * @return The local variable count.
	 * @since 2019/02/17
	 */
	public final int maxLocals()
	{
		return this._locals.length;
	}
	
	/**
	 * Returns the maximum number of stack variables.
	 *
	 * @return The stack variable count.
	 * @since 2019/02/17
	 */
	public final int maxStack()
	{
		return this._stack.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/07/28
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder("{locals=");
			__stringize(this._locals, sb);
			sb.append(", stack(");
			sb.append(this.depth);
			sb.append(")=");
			__stringize(this._stack, sb);
			sb.append("}");
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Stringizes the specified type array.
	 *
	 * @param __jt The type array to stringize.
	 * @param __sb The destination string builder.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	private static void __stringize(StackMapTableEntry[] __jt,
		StringBuilder __sb)
		throws NullPointerException
	{
		// Check
		if (__jt == null || __sb == null)
			throw new NullPointerException("NARG");
		
		// Open
		__sb.append('[');
		
		// Add
		for (int i = 0, n = __jt.length; i < n; i++)
		{
			if (i > 0)
				__sb.append(", ");
			
			__sb.append(__jt[i]);
		}
		
		// Close
		__sb.append(']');
	}
	
	/**
	 * Verifies the types within the map.
	 *
	 * @param __t The types to check.
	 * @throws InvalidClassFormatException If the type are not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/07/28
	 */
	private static void __verify(StackMapTableEntry[] __t)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Go through all entries, w acts as a kind of single entry stack which
		// is used to ensure that the tops of long/double are valid
		JavaType w = null;
		for (int i = 0, n = __t.length; i < n; i++)
		{
			StackMapTableEntry ea = __t[i];
			JavaType a = (ea != null ? ea.type() : null);
			
			// A wide type was pushed
			if (w != null)
			{
				// {@squirreljme.error JC40 The type at the read index does
				// not match the expected type following a wide type. (The wide
				// type; The expected type; The actual type; The input map)}
				JavaType t = w.topType();
				if (!t.equals(a))
					throw new InvalidClassFormatException(
						String.format("JC40 %s %s %s %s", w, t, a,
						Arrays.asList(__t)));
				
				// Clear
				w = null;
			}
			
			// No real checking has to be done unless it is a wide type
			else
			{
				if (a != null && a.isWide())
					w = a;
			}
		}
		
		// {@squirreljme.error JC41 Long or double appears at the end of the
		// type array and does not have a top associated with it.}
		if (w != null)
			throw new InvalidClassFormatException("JC41");
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/TableSwitch.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
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
191
192
193
194
195
196




































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents a table switch.
 *
 * @since 2018/09/20
 */
public final class TableSwitch
	implements IntMatchingJumpTable
{
	/** The default jump address. */
	protected final InstructionJumpTarget defaultjump;
	
	/** The low index. */
	protected final int low;
	
	/** The high index. */
	protected final int high;
	
	/** The jump targets. */
	private final InstructionJumpTarget[] _jumps;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the table switch.
	 *
	 * @param __def The default address.
	 * @param __lo The low address.
	 * @param __hi The high address.
	 * @param __jumps The jump offsets.
	 * @throws InvalidClassFormatException If the high is less than or equal
	 * to the low.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/20
	 */
	public TableSwitch(InstructionJumpTarget __def, int __lo, int __hi,
		InstructionJumpTarget[] __jumps)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__def == null || __jumps == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error JC42 Table switch high index is less than or
		// equal to the low index. (The low index; The high index)}
		if (__hi <= __lo)
			throw new InvalidClassFormatException(String.format("JC42 %d %d",
				__lo, __hi));
		
		// Check for null
		__jumps = __jumps.clone();
		for (InstructionJumpTarget j : __jumps)
			if (j == null)
				throw new NullPointerException("NARG");
		
		// Set
		this.low = __lo;
		this.high = __hi;
		this.defaultjump = __def;
		this._jumps = __jumps;
	}
	
	/**
	 * Converts this to a lookup switch.
	 *
	 * @return This table switch as a lookup switch.
	 * @since 2019/04/16
	 */
	public final LookupSwitch asLookupSwitch()
	{
		// These are needed to build keys
		InstructionJumpTarget[] jumps = this._jumps;
		int low = this.low,
			high = this.high,
			n = jumps.length;
		
		// Setup new key map, the jumps do not need to be adjusted because
		// they will map the same!
		int[] newkeys = new int[n];
		for (int o = 0, k = low; k <= high; k++, o++)
			newkeys[o] = k;
		
		// Build
		return new LookupSwitch(this.defaultjump, newkeys, jumps);
	}
	
	/**
	 * Returns the jumps.
	 *
	 * @return The jumps.
	 * @since 2019/04/16
	 */
	public final InstructionJumpTarget[] jumps()
	{
		return this._jumps.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final InstructionJumpTarget match(int __k)
	{
		// Use default if out of bounds
		int low = this.low,
			high = this.high;
		if (__k < low || __k > high)
			return this.defaultjump;
		
		return this._jumps[__k - low];
	}
	
	/**
	 * Returns the size of the switch.
	 *
	 * @return The size.
	 * @since 2019/04/16
	 */
	public final int size()
	{
		return this._jumps.length;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/03/31
	 */
	@Override
	public final InstructionJumpTarget[] targets()
	{
		InstructionJumpTarget[] jumps = this._jumps;
		int n = jumps.length;
		
		// Start off array with the default jump
		InstructionJumpTarget[] rv = new InstructionJumpTarget[n + 1];
		rv[0] = this.defaultjump;
		
		// Add all the others
		for (int i = 0, o = 1; i < n; i++, o++)
			rv[o] = jumps[i];
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/20
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Set with default first
			StringBuilder sb = new StringBuilder("{default=");
			sb.append(this.defaultjump);
			
			// Add all matches and their targets
			InstructionJumpTarget[] jumps = this._jumps;
			for (int i = 0, n = jumps.length, v = this.low; i < n; i++, v++)
			{
				sb.append(", ");
				
				sb.append(v);
				sb.append('=');
				sb.append(jumps[i]);
			}
			
			// Cleans
			sb.append('}');
			
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/UTFConstantEntry.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents a UTF-8 constant pool entry.
 *
 * @since 2017/06/09
 */
public final class UTFConstantEntry
{
	/** The string representation. */
	protected final String string;
	
	/**
	 * Initializes the constant entry.
	 *
	 * @param __s The string used.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/06/09
	 */
	public UTFConstantEntry(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (!(__o instanceof UTFConstantEntry))
			return false;
		
		return this.string.equals(((UTFConstantEntry)__o).string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/06/09
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/WideConstantTopEntry.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

/**
 * This represents an entry which is the top of a long or double so that the
 * space is not treated as {@code null} or the type of the base.
 *
 * @since 2017/06/09
 */
public final class WideConstantTopEntry
{
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/__StackMapParser__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655















































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This class is used to parse the stack map and initialize the initial
 * snapshot states for jump targets within the method.
 *
 * @since 2017/04/16
 */
final class __StackMapParser__
{
	/** The stream to decode from. */
	protected final DataInputStream in;
	
	/** The number of stack entries. */
	protected final int maxstack;
	
	/** The number of local entries. */
	protected final int maxlocals;
	
	/** The method byte code. */
	protected final ByteCode code;
	
	/** Constant pool. */
	protected final Pool pool;
	
	/** This type. */
	protected final JavaType thistype;
		
	/** Verification targets. */
	private final Map<Integer, StackMapTableState> _targets;
	
	/** The next stack state. */
	private final StackMapTableEntry[] _nextstack;
	
	/** The next local variable state. */
	private final StackMapTableEntry[] _nextlocals;
	
	/** The placement address. */
	private int _placeaddr;
	
	/** The top of the stack. */
	private int _stacktop;
	
	/**
	 * Initializes the stack map parser.
	 *
	 * @param __p The constant pool.
	 * @param __m The method this code exists within.
	 * @param __new Should the new stack map table format be used?
	 * @param __in The data for the stack map table.
	 * @param __bc The owning byte code.
	 * @param __tt This type.
	 * @throws InvalidClassFormatException If the stack map table is not
	 * valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/04/16
	 */
	__StackMapParser__(Pool __p, Method __m, boolean __new, byte[] __in,
		ByteCode __bc, JavaType __tt)
		throws InvalidClassFormatException, NullPointerException
	{
		// Check
		if (__p == null || __m == null || __in == null || __bc == null ||
			__tt == null)
			throw new NullPointerException("NARG");
		
		// Set
		DataInputStream xin;
		this.in = (xin = new DataInputStream(
			new ByteArrayInputStream(__in)));
		int maxstack = __bc.maxStack(),
			maxlocals = __bc.maxLocals();
		this.maxstack = maxstack;
		this.maxlocals = maxlocals;
		this.code = __bc;
		this.pool = __p;
		this.thistype = __tt;
		
		// This is used to set which variables appear next before a state is
		// constructed with them
		StackMapTableEntry[] nextstack, nextlocals;
		this._nextstack = (nextstack = new StackMapTableEntry[maxstack]);
		this._nextlocals = (nextlocals = new StackMapTableEntry[maxlocals]);
		
		// Setup initial state
		// {@squirreljme.error JC43 The arguments that are required for the
		// given method exceeds the maximum number of permitted local
		// variables. (The method in question; The required number of local
		// variables; The maximum number of local variables)}
		MethodHandle handle = __m.handle();
		boolean isinstance = !__m.flags().isStatic();
		JavaType[] jis = handle.javaStack(isinstance);
		int jn = jis.length;
		if (jn > maxlocals)
			throw new InvalidClassFormatException(
				String.format("JC43 %s %d %d", handle, jn, maxlocals));
		
		// Setup entries
		// If this is an instance initializer method then only the first
		// argument is not initialized
		boolean isiinit = isinstance && __m.name().isInstanceInitializer();
		for (int i = 0; i < jn; i++)
			nextlocals[i] = new StackMapTableEntry(jis[i],
				(isiinit ? (i != 0) : true));
		
		// Initialize entries with nothing
		for (int i = 0, n = nextstack.length; i < n; i++)
			if (nextstack[i] == null)
				nextstack[i] = StackMapTableEntry.NOTHING;
		for (int i = 0, n = nextlocals.length; i < n; i++)
			if (nextlocals[i] == null)
				nextlocals[i] = StackMapTableEntry.NOTHING;
		
		// Where states go
		Map<Integer, StackMapTableState> targets = new LinkedHashMap<>();
		this._targets = targets;
		
		// Record state
		__next(0, true, -1, -1);
		
		// Parse the stack map table
		try (DataInputStream in = xin)
		{
			// Parsing the class stack map table
			if (!__new)
			{
				// Read the number of entries in the table
				int ne = xin.readUnsignedShort();
			
				// All entries in the table are full frames
				for (int i = 0; i < ne; i++)
					__next(__oldStyle(), true, -1, i);
			}
		
			// The modern stack map table
			else
			{
				// Read the number of entries in the table
				int ne = xin.readUnsignedShort();
			
				// Read them all
				for (int i = 0; i < ne; i++)
				{
					// Read the frame type
					int type = xin.readUnsignedByte();
					int addr;
				
					// Full frame?
					if (type == 255)
						addr = __fullFrame();
				
					// Same frame?
					else if (type >= 0 && type <= 63)
						addr = __sameFrame(type);
				
					// Same locals but a single stack item
					else if (type >= 64 && type <= 127)
						addr = __sameLocalsSingleStack(type - 64);
				
					// Same locals, single stack item, explicit delta
					else if (type == 247)
						addr = __sameLocalsSingleStackExplicit();
				
					// Chopped frame
					else if (type >= 248 && type <= 250)
						addr = __choppedFrame(251 - type);
				
					// Same frame but with a supplied delta
					else if (type == 251)
						addr = __sameFrameDelta();
				
					// Appended frame
					else if (type >= 252 && type <= 254)
						addr = __appendFrame(type - 251);
				
					// {@squirreljme.error JC44 Unknown StackMapTable
					// verification type. (The verification type)}
					else
						throw new InvalidClassFormatException(
							String.format("JC44 %d", type));
					
					// Setup next
					__next(addr, false, type, i);
				}
			}
		}
		
		// {@squirreljme.error JC45 Failed to parse the stack map table.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC45", e);
		}
	}
	
	/**
	 * Returns the stack map table.
	 *
	 * @return The parsed stack map table.
	 * @since 2017/10/16
	 */
	public StackMapTable get()
	{
		return new StackMapTable(this._targets);
	}
	
	/**
	 * Append extra locals to the frame and clear the stack.
	 *
	 * @param __addlocs The number of local variables to add.
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __appendFrame(int __addlocs)
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Stack is cleared
		this._stacktop = 0;
		
		// Read in local variables
		StackMapTableEntry[] nextlocals = this._nextlocals;
		int n = this.maxlocals;
		for (int i = 0; __addlocs > 0 && i < n; i++)
		{
			// Get slot here
			StackMapTableEntry s = nextlocals[i];
			
			// If it is not empty, ignore it
			if (!s.equals(StackMapTableEntry.NOTHING))
				continue;
			
			// Set it
			StackMapTableEntry aa;
			nextlocals[i] = (aa = __loadInfo());
			__addlocs--;
			
			// If a wide element was added, then the next one becomes TOP
			if (aa.isWide())
				nextlocals[++i] = aa.topType();
		}
		
		// Error if added stuff remains
		// {@squirreljme.error JC46 Appending local variables to the frame
		// however there is no room to place them. (The remaining local count)}
		if (__addlocs != 0)
			throw new InvalidClassFormatException(
				String.format("JC46 %d", __addlocs));
		
		return rv;
	}
	
	/**
	 * Similar frame with no stack and the top few locals removed.
	 *
	 * @param __chops The number of variables which get chopped.
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __choppedFrame(int __chops)
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// No stack
		this._stacktop = 0;
		
		// Chop off some locals
		StackMapTableEntry[] nextlocals = this._nextlocals;
		int i, n = this.maxlocals;
		for (i = n - 1; __chops > 0 && i >= 0; i--)
		{
			// Get slot here
			StackMapTableEntry s = nextlocals[i];
			
			// If it is empty, ignore it
			if (s.equals(StackMapTableEntry.NOTHING))
				continue;
			
			// Clear top off, but only if it is not an undefined top
			if (s.isTop() && !s.equals(StackMapTableEntry.TOP_UNDEFINED))
				nextlocals[i--] = StackMapTableEntry.NOTHING;
			
			// Clear it
			nextlocals[i] = StackMapTableEntry.NOTHING;
			__chops--;
		}
		
		// Still chops left?
		// {@squirreljme.error JC47 Could not chop off all local variables
		// because there are no variables remaining to be chopped. (The
		// remaining variables to remove)}
		if (__chops != 0)
			throw new InvalidClassFormatException(
				String.format("JC47 %d", __chops));
		
		return rv;
	}
	
	/**
	 * This reads and parses the full stack frame.
	 *
	 * @return The address offset.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __fullFrame()
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Read in local variables
		int nl = in.readUnsignedShort();
		
		// {@squirreljme.error JC48 The number of specified local variables in
		// the full frame exceeds the maximum permitted local variable
		// count. (The read local variable count; The number of locals the
		// method uses)}
		int maxlocals = this.maxlocals,
			maxstack = this.maxstack;
		if (nl > maxlocals)
			throw new InvalidClassFormatException(
				String.format("JC48 %d %d", nl, maxlocals));
		int i, o;
		StackMapTableEntry[] nextlocals = this._nextlocals;
		for (i = 0, o = 0; i < nl; i++)
		{
			StackMapTableEntry e;
			nextlocals[o++] = (e = __loadInfo());
			
			// Add top?
			if (e.isWide())
				nextlocals[o++] = e.topType();
		}
		for (;o < maxlocals; o++)
			nextlocals[o] = StackMapTableEntry.NOTHING;
		
		// Read in stack variables
		StackMapTableEntry[] nextstack = this._nextstack;
		int ns = in.readUnsignedShort();
		for (i = 0, o = 0; i < ns; i++)
		{
			StackMapTableEntry e;
			nextstack[o++] = (e = __loadInfo());
			
			// Add top?
			if (e.isWide())
				nextstack[o++] = e.topType();
		}
		this._stacktop = o;
		
		return rv;
	}
	
	/**
	 * Loads type information for the stack.
	 *
	 * @return The type which was parsed.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private StackMapTableEntry __loadInfo()
		throws IOException
	{
		// Read the tag
		DataInputStream in = this.in;
		int tag = in.readUnsignedByte();
		
		// Depends on the tag
		switch (tag)
		{
				// Top
			case 0:
				return StackMapTableEntry.TOP_UNDEFINED;
				
				// Integer
			case 1:
				return StackMapTableEntry.INTEGER;
				
				// Float
			case 2:
				return StackMapTableEntry.FLOAT;
				
				// Double
			case 3:
				return StackMapTableEntry.DOUBLE;
				
				// Long
			case 4:
				return StackMapTableEntry.LONG;
				
				// Nothing
			case 5:
				return StackMapTableEntry.NOTHING;
				
				// Uninitialized this
			case 6:
				return new StackMapTableEntry(this.thistype, false);
				
				// Initialized object
			case 7:
				return new StackMapTableEntry(new JavaType(
					this.pool.<ClassName>get(ClassName.class,
					in.readUnsignedShort()).field()), true);
				
				// Uninitialized variable for a new instruction, the pc points
				// to the new instruction so the class must be read from
				// that instruction to determine the type of that actual
				// object
			case 8:
				return new StackMapTableEntry(new JavaType(this.pool.
					<ClassName>get(ClassName.class, this.code.
					readRawCodeUnsignedShort(in.readUnsignedShort() + 1))),
					false);
				
				// Unknown
			default:
				// {@squirreljme.error JC49 The verification tag in the
				// StackMap/StackMapTable attribute is not valid. (The tag)}
				throw new InvalidClassFormatException(
					String.format("JC49 %d", tag));
		}
	}
	
	/**
	 * Initializes the next state.
	 *
	 * @param __au The address offset.
	 * @param __abs Absolute position?
	 * @param __type The type of entry that was just handled, this is for
	 * debug purposes.
	 * @param __ne The entry number of this index.
	 * @return The state for the next address.
	 * @since 2016/05/20
	 */
	StackMapTableState __next(int __au, boolean __abs, int __type, int __ne)
	{
		// Where are we?
		int naddr = this._placeaddr;
		
		// Generate it
		StackMapTableState rv;
		try
		{
			rv = new StackMapTableState(this._nextlocals,
				this._nextstack, this._stacktop);
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error JC4a Invalid stack map table at the
			// specified address. (The address offset; Is the address offset
			// absolute?; The placement address; The type of entry which
			// was just handled, -1 means it was old-style or initial state.)}
			throw new InvalidClassFormatException(String.format(
				"JC4a %d %b %d %d", __au, __abs, naddr, __type), e);
		}
		
		// Set new placement address, the first is always absolute
		int pp = (__abs ? __au :
			naddr + (__au + (__ne == 0 ? 0 : 1)));
		this._placeaddr = pp;
	
		// {@squirreljme.error JC4b A duplicate stack map information for the
		// specified address has already been loaded. (The address; The
		// already existing information; The information to be placed there;
		// Absolute address?; Current address of parse; The address offset;
		// The parsed type)}
		// Note that the first instruction if it is a jump target may have an
		// explicit state even if it one is always defined implicitly, so
		// just ignore it
		Map<Integer, StackMapTableState> targets = this._targets;
		if (pp != 0 && targets.containsKey(pp))
			throw new IllegalStateException(String.format(
				"JC4b %d %s %s %b %d %d %d",
				pp, targets.get(pp), rv, __abs, naddr, __au, __type));
		targets.put(pp, rv);
		
		// Debug
		/*todo.DEBUG.note("Read state @%d: %s%n", pp, rv);*/
	
		// The stored state
		return rv;
	}
	
	/**
	 * Reads in an old style full frame.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __oldStyle()
		throws IOException
	{
		// Get the atom to use
		DataInputStream in = this.in;
		int rv = in.readUnsignedShort();
		
		// Read in local variables
		int nl = in.readUnsignedShort();
		StackMapTableEntry[] inlocals = new StackMapTableEntry[nl];
		for (int i = 0; i < nl; i++)
			inlocals[i] = this.__loadInfo();
		
		// Read in stack variables
		int ns = in.readUnsignedShort();
		StackMapTableEntry[] instack = new StackMapTableEntry[ns];
		for (int i = 0; i < ns; i++)
			instack[i] = this.__loadInfo();
		
		// Assign read local variables
		int lat = 0;
		StackMapTableEntry[] nextlocals = this._nextlocals;
		for (int i = 0; i < nl; i++)
		{
			// Copy in
			StackMapTableEntry e = inlocals[i];
			nextlocals[lat++] = e;
			
			// Handling wide type?
			if (e.isWide())
			{
				// Set top
				nextlocals[lat++] = e.topType();
				
				// If the top is explicit, then skip it
				if (i + 1 < nl && inlocals[i + 1].isTop())
					i++;
			}
		}
		
		// Assign read stack variables
		int sat = 0;
		StackMapTableEntry[] nextstack = this._nextstack;
		for (int i = 0; i < ns; i++)
		{
			// Copy in
			StackMapTableEntry e = instack[i];
			nextstack[sat++] = e;
			
			// Handling wide type?
			if (e.isWide())
			{
				// Set top
				nextstack[sat++] = e.topType();
				
				// If the top is explicit, then skip it
				if (i + 1 < ns && instack[i + 1].isTop())
					i++;
			}
		}
		
		// Stack depth is where the next stack would have been placed
		this._stacktop = sat;
		
		return rv;
	}
	
	/**
	 * The same frame is used with no changes.
	 *
	 * @param __delta The offset from the earlier offset.
	 * @return The address information.
	 * @since 2016/03/26
	 */
	private int __sameFrame(int __delta)
	{
		return __delta;
	}
	
	/**
	 * Same frame but with a supplied delta rather than using it with the type.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameFrameDelta()
		throws IOException
	{
		return this.in.readUnsignedShort();
	}
	
	/**
	 * Same locals but the stack has only a single entry.
	 *
	 * @param __delta The delta offset.
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameLocalsSingleStack(int __delta)
		throws IOException
	{
		// Load single entry
		StackMapTableEntry ent;
		this._nextstack[0] = (ent = __loadInfo());
		
		// If the entry is wide then the top type will not be specified as it
		// will be implicit, so we need to set the according type
		if (ent.isWide())
		{
			this._nextstack[1] = ent.topType();
			this._stacktop = 2;
		}
		
		// Only a single entry exists
		else
			this._stacktop = 1;
		
		return __delta;
	}
	
	/**
	 * Same locals but the stack has only a single entry, the delta offset
	 * is specified.
	 *
	 * @return The address information.
	 * @throws IOException On read errors.
	 * @since 2016/03/26
	 */
	private int __sameLocalsSingleStackExplicit()
		throws IOException
	{
		return __sameLocalsSingleStack(this.in.readUnsignedShort());
	}
}

Deleted runt/libs/tool-classfile/net/multiphasicapps/classfile/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the classes which are used to represent class files
 * in an abstract structure format. None of the classes in this package perform
 * any JIT operation, it is only concerned with loading class files and
 * representing them.
 *
 * Structures are read, then they are compiled by the JIT.
 *
 * @since 2017/09/26
 */

package net.multiphasicapps.classfile;

Deleted runt/libs/tool-compiler.test/CuteCompilerTest.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.
// ---------------------------------------------------------------------------

import net.multiphasicapps.javac.cute.CuteCompilerService;

/**
 * This tests the cute compiler.
 *
 * @since 2019/06/30
 */
public class CuteCompilerTest
	extends __BaseCompiler__
{
	/**
	 * Tests the cute compiler.
	 *
	 * @since 2019/06/30
	 */
	public CuteCompilerTest()
	{
		super(new CuteCompilerService());
	}
}

Deleted runt/libs/tool-compiler.test/DefaultCompilerTest.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.
// ---------------------------------------------------------------------------

import net.multiphasicapps.javac.DefaultCompiler;

/**
 * Tests the default compiler.
 *
 * @since 2019/06/30
 */
public class DefaultCompilerTest
	extends __BaseCompiler__
{
	/**
	 * Tests the default compiler.
	 *
	 * @since 2019/06/30
	 */
	public DefaultCompilerTest()
	{
		super(DefaultCompiler.getService());
	}
}

Deleted runt/libs/tool-compiler.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted runt/libs/tool-compiler.test/__BaseCompiler__.in.

1

-

Deleted runt/libs/tool-compiler.test/__BaseCompiler__.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
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


































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerOptions;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.CompilerService;
import net.multiphasicapps.javac.ResourcePathSet;
import net.multiphasicapps.javac.NullCompilerOutput;
import net.multiphasicapps.tac.TestRunnable;
import net.multiphasicapps.tac.UntestableException;

/**
 * This tests the cute compiler.
 *
 * @since 2019/06/30
 */
abstract class __BaseCompiler__
	extends TestRunnable
{
	/** Class files to compile. */
	static final String[] _JAVA_FILES =
		{"CrossTypeParameter.java", "HelloSquirrels.java",
		"IntAnnotation.java"};
	
	/** The compiler service to use. */
	protected final CompilerService service;
	
	/**
	 * Initializes the compiler.
	 *
	 * @param __cc The compiler to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	__BaseCompiler__(CompilerService __cc)
		throws NullPointerException
	{
		if (__cc == null)
			throw new NullPointerException("NARG");
		
		this.service = __cc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public void test()
	{
		// Not yet implemented!
		if (true)
			throw new UntestableException("Compiler support not implemented!");
		
		// Get service
		CompilerService service = this.service;
		
		// Class library
		CompilerPathSet cldc = new ResourcePathSet(
				this.getClass(), "/mini-cldc/"),
			src = new ResourcePathSet(this.getClass(), "/class-files/");
		
		// Go through sources
		for (String javafile : _JAVA_FILES)
			try
			{
				// Get new compiler
				Compiler compiler = service.createInstance();
				
				// Setup properties
				compiler.setLocation(CompilerInputLocation.CLASS, cldc);
				compiler.setLocation(CompilerInputLocation.SOURCE, src);
				compiler.addInput(src.input(javafile));
				
				// Run the compiler
				compiler.compile(new NullCompilerOutput()).run();
				
				// Okay!
				this.secondary(javafile, true);
			}
			catch (CompilerException e)
			{
				// Did not work!
				this.secondary(javafile, e);
			}
	}
}

Deleted runt/libs/tool-compiler.test/class-files/CrossTypeParameter.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This is used to test where a type parameter is used for another type
 * parameter.
 *
 * @param <T> Type A.
 * @param <E> Type B.
 * @since 2018/05/10
 */
public class CrossTypeParameter<T extends List<E>, E extends List<T>>
{
}

Deleted runt/libs/tool-compiler.test/class-files/HelloSquirrels.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * Just prints a cute message.
 *
 * @since 2018/05/01
 */
@IntAnnotation(2 + 2)
public class HelloSquirrels
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/05/01
	 */
	public static void main(String... __args)
	{
		System.out.println("Hello squirrels! You are so cute!");
	}
}

Deleted runt/libs/tool-compiler.test/class-files/IntAnnotation.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Contains an integer annotation.
 *
 * @since 2018/05/01
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
public @interface IntAnnotation
{
	/**
	 * The value for this annotation.
	 *
	 * @since 2018/05/01
	 */
	public int value() default 0;
}

Deleted runt/libs/tool-compiler.test/class-files/list.

1
2
3
4




-
-
-
-
CrossTypeParameter.java
HelloSquirrels.java
IntAnnotation.java
list

Deleted runt/libs/tool-compiler.test/mini-cldc/compile.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh -e

# Compile sources
javac -source 1.7 -target 1.7 -d . -bootclasspath source-files -classpath source-files \
	source-files/*/*/*.java \
	source-files/*/*/*.java

# UUEncode classes
find | grep '\.class$' | while read __file
do
	uuencode -m "$__file" "$__file" > "$__file.__mime"
	rm "$__file"
done

# Build list
find | sed 's/^\.\///g' | sed 's/\.__mime//g' > list

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Class.class.__mime.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Class.class
yv66vgAAADMAEgoAAwAPBwAQBwARAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA
D0xpbmVOdW1iZXJUYWJsZQEADWdldFN1cGVyY2xhc3MBABMoKUxqYXZhL2xh
bmcvQ2xhc3M7AQAJU2lnbmF0dXJlAQAWKClMamF2YS9sYW5nL0NsYXNzPCo+
OwEAKDxDOkxqYXZhL2xhbmcvT2JqZWN0Oz5MamF2YS9sYW5nL09iamVjdDsB
AApTb3VyY2VGaWxlAQAKQ2xhc3MuamF2YQwABAAFAQAPamF2YS9sYW5nL0Ns
YXNzAQAQamF2YS9sYW5nL09iamVjdAAxAAIAAwAAAAAAAgABAAQABQABAAYA
AAAdAAEAAQAAAAUqtwABsQAAAAEABwAAAAYAAQAAABMAEQAIAAkAAgAGAAAA
GgABAAEAAAACAbAAAAABAAcAAAAGAAEAAAAdAAoAAAACAAsAAgAKAAAAAgAM
AA0AAAACAA4=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/ClassCastException.class.__mime.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/ClassCastException.class
yv66vgAAADMAEAoABAAMCgAEAA0HAA4HAA8BAAY8aW5pdD4BAAMoKVYBAARD
b2RlAQAPTGluZU51bWJlclRhYmxlAQAVKExqYXZhL2xhbmcvU3RyaW5nOylW
AQAKU291cmNlRmlsZQEAF0NsYXNzQ2FzdEV4Y2VwdGlvbi5qYXZhDAAFAAYM
AAUACQEAHGphdmEvbGFuZy9DbGFzc0Nhc3RFeGNlcHRpb24BABpqYXZhL2xh
bmcvUnVudGltZUV4Y2VwdGlvbgAhAAMABAAAAAAAAgABAAUABgABAAcAAAAh
AAEAAQAAAAUqtwABsQAAAAEACAAAAAoAAgAAABoABAAbAAEABQAJAAEABwAA
ACIAAgACAAAABiortwACsQAAAAEACAAAAAoAAgAAACUABQAmAAEACgAAAAIA
Cw==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/CloneNotSupportedException.class.__mime.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/CloneNotSupportedException.class
yv66vgAAADMAEAoABAAMCgAEAA0HAA4HAA8BAAY8aW5pdD4BAAMoKVYBAARD
b2RlAQAPTGluZU51bWJlclRhYmxlAQAVKExqYXZhL2xhbmcvU3RyaW5nOylW
AQAKU291cmNlRmlsZQEAH0Nsb25lTm90U3VwcG9ydGVkRXhjZXB0aW9uLmph
dmEMAAUABgwABQAJAQAkamF2YS9sYW5nL0Nsb25lTm90U3VwcG9ydGVkRXhj
ZXB0aW9uAQATamF2YS9sYW5nL0V4Y2VwdGlvbgAhAAMABAAAAAAAAgABAAUA
BgABAAcAAAAhAAEAAQAAAAUqtwABsQAAAAEACAAAAAoAAgAAABsABAAcAAEA
BQAJAAEABwAAACIAAgACAAAABiortwACsQAAAAEACAAAAAoAAgAAACUABQAm
AAEACgAAAAIACw==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Comparable.class.__mime.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Comparable.class
yv66vgAAADMADAcACgcACwEACWNvbXBhcmVUbwEAFShMamF2YS9sYW5nL09i
amVjdDspSQEACVNpZ25hdHVyZQEABihUVDspSQEAKDxUOkxqYXZhL2xhbmcv
T2JqZWN0Oz5MamF2YS9sYW5nL09iamVjdDsBAApTb3VyY2VGaWxlAQAPQ29t
cGFyYWJsZS5qYXZhAQAUamF2YS9sYW5nL0NvbXBhcmFibGUBABBqYXZhL2xh
bmcvT2JqZWN0BgEAAQACAAAAAAABBAEAAwAEAAEABQAAAAIABgACAAUAAAAC
AAcACAAAAAIACQ==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Enum.class.__mime.

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












































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Enum.class
yv66vgAAADMATgoAFAA5BwA6CgACADkHADsKAAQAOQkAEAA8CQAQAD0HAD4K
AAgAOQoAEAA/BwBACgALADkKABAAQQoAFABCCgARAEMHAEQHAEUKABQARgoA
EABHBwBIBwBJAQAFX25hbWUBABJMamF2YS9sYW5nL1N0cmluZzsBAAhfb3Jk
aW5hbAEAAUkBAAY8aW5pdD4BABYoTGphdmEvbGFuZy9TdHJpbmc7SSlWAQAE
Q29kZQEAD0xpbmVOdW1iZXJUYWJsZQEADVN0YWNrTWFwVGFibGUHAEoBAApF
eGNlcHRpb25zAQAFY2xvbmUBABQoKUxqYXZhL2xhbmcvT2JqZWN0OwEACWNv
bXBhcmVUbwEAEyhMamF2YS9sYW5nL0VudW07KUkBAAlTaWduYXR1cmUBAAYo
VEU7KUkBAAZlcXVhbHMBABUoTGphdmEvbGFuZy9PYmplY3Q7KVoBABFnZXRE
ZWNsYXJpbmdDbGFzcwEAEygpTGphdmEvbGFuZy9DbGFzczsBABgoKUxqYXZh
L2xhbmcvQ2xhc3M8VEU7PjsBAAhoYXNoQ29kZQEAAygpSQEABG5hbWUBABQo
KUxqYXZhL2xhbmcvU3RyaW5nOwEAB29yZGluYWwBAAh0b1N0cmluZwEAB3Zh
bHVlT2YBADUoTGphdmEvbGFuZy9DbGFzcztMamF2YS9sYW5nL1N0cmluZzsp
TGphdmEvbGFuZy9FbnVtOwEARjxUOkxqYXZhL2xhbmcvRW51bTxUVDs+Oz4o
TGphdmEvbGFuZy9DbGFzczxUVDs+O0xqYXZhL2xhbmcvU3RyaW5nOylUVDsB
ABUoTGphdmEvbGFuZy9PYmplY3Q7KUkBAEY8RTpMamF2YS9sYW5nL0VudW08
VEU7Pjs+TGphdmEvbGFuZy9PYmplY3Q7TGphdmEvbGFuZy9Db21wYXJhYmxl
PFRFOz47AQAKU291cmNlRmlsZQEACUVudW0uamF2YQwAGgBLAQAeamF2YS9s
YW5nL051bGxQb2ludGVyRXhjZXB0aW9uAQAiamF2YS9sYW5nL0lsbGVnYWxB
cmd1bWVudEV4Y2VwdGlvbgwAFgAXDAAYABkBACRqYXZhL2xhbmcvQ2xvbmVO
b3RTdXBwb3J0ZWRFeGNlcHRpb24MACkAKgEAHGphdmEvbGFuZy9DbGFzc0Nh
c3RFeGNlcHRpb24MADAALQwATAAqDABNACoBAA5qYXZhL2xhbmcvRW51bQEA
D2phdmEvbGFuZy9DbGFzcwwALAAtDAAjACQBABBqYXZhL2xhbmcvT2JqZWN0
AQAUamF2YS9sYW5nL0NvbXBhcmFibGUBABBqYXZhL2xhbmcvU3RyaW5nAQAD
KClWAQAIZ2V0Q2xhc3MBAA1nZXRTdXBlcmNsYXNzBCEAEAAUAAEAFQACABIA
FgAXAAAAEgAYABkAAAALAAQAGgAbAAIAHAAAAHIAAgADAAAAJyq3AAErxwAL
uwACWbcAA78cnAALuwAEWbcABb8qK7UABioctQAHsQAAAAIAHQAAACIACAAA
ACcABAApAAgAKgAQAC0AFAAuABwAMAAhADEAJgAyAB4AAAARAAL/ABAAAwcA
EAcAHwEAAAsAIAAAAAYAAgAEAAIAFAAhACIAAgAcAAAAIAACAAEAAAAIuwAI
WbcACb8AAAABAB0AAAAGAAEAAAA9ACAAAAAEAAEACAARACMAJAADABwAAABb
AAIAAgAAACkrxwALuwACWbcAA78qtgAKK7YACqUAC7sAC1m3AAy/KrYADSu2
AA1krAAAAAIAHQAAABYABQAAAEgABABJAAwATAAXAE0AHwBQAB4AAAAEAAIM
EgAgAAAABgACAAsAAgAlAAAAAgAmABEAJwAoAAEAHAAAAC4AAgACAAAACyor
pgAHBKcABAOsAAAAAgAdAAAABgABAAAAWgAeAAAABQACCUABABEAKQAqAAIA
HAAAAFMAAgADAAAAGiq2AA5MK7YAD00sEhCmAAgrwAARsCzAABGwAAAAAgAd
AAAAFgAFAAAAagAFAGsACgBsABAAbQAVAG4AHgAAAAsAAf0AFQcAEQcAEQAl
AAAAAgArABEALAAtAAEAHAAAAB0AAQABAAAABSq3ABKsAAAAAQAdAAAABgAB
AAAAeAARAC4ALwABABwAAAAdAAEAAQAAAAUqtAAGsAAAAAEAHQAAAAYAAQAA
AIMAEQAwAC0AAQAcAAAAHQABAAEAAAAFKrQAB6wAAAABAB0AAAAGAAEAAACO
AAEAMQAvAAEAHAAAAB0AAQABAAAABSq0AAawAAAAAQAdAAAABgABAAAAmAAJ
ADIAMwADABwAAAAaAAEAAgAAAAIBsAAAAAEAHQAAAAYAAQAAAKkAIAAAAAYA
AgAEAAIAJQAAAAIANBBBACMANQABABwAAAAhAAIAAgAAAAkqK8AAELYAE6wA
AAABAB0AAAAGAAEAAAATAAIAJQAAAAIANgA3AAAAAgA4
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Error.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Error.class
yv66vgAAADMAFgoABgAQCgAGABEKAAYAEgoABgATBwAUBwAVAQAGPGluaXQ+
AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAFShMamF2YS9sYW5n
L1N0cmluZzspVgEAKihMamF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5nL1Ro
cm93YWJsZTspVgEAGChMamF2YS9sYW5nL1Rocm93YWJsZTspVgEAClNvdXJj
ZUZpbGUBAApFcnJvci5qYXZhDAAHAAgMAAcACwwABwAMDAAHAA0BAA9qYXZh
L2xhbmcvRXJyb3IBABNqYXZhL2xhbmcvVGhyb3dhYmxlACEABQAGAAAAAAAE
AAEABwAIAAEACQAAACEAAQABAAAABSq3AAGxAAAAAQAKAAAACgACAAAAGgAE
ABsAAQAHAAsAAQAJAAAAIgACAAIAAAAGKiu3AAKxAAAAAQAKAAAACgACAAAA
JQAFACYAAQAHAAwAAQAJAAAAIwADAAMAAAAHKisstwADsQAAAAEACgAAAAoA
AgAAADEABgAyAAEABwANAAEACQAAACIAAgACAAAABiortwAEsQAAAAEACgAA
AAoAAgAAADwABQA9AAEADgAAAAIADw==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Exception.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Exception.class
yv66vgAAADMAFgoABgAQCgAGABEKAAYAEgoABgATBwAUBwAVAQAGPGluaXQ+
AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAFShMamF2YS9sYW5n
L1N0cmluZzspVgEAKihMamF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5nL1Ro
cm93YWJsZTspVgEAGChMamF2YS9sYW5nL1Rocm93YWJsZTspVgEAClNvdXJj
ZUZpbGUBAA5FeGNlcHRpb24uamF2YQwABwAIDAAHAAsMAAcADAwABwANAQAT
amF2YS9sYW5nL0V4Y2VwdGlvbgEAE2phdmEvbGFuZy9UaHJvd2FibGUAIQAF
AAYAAAAAAAQAAQAHAAgAAQAJAAAAIQABAAEAAAAFKrcAAbEAAAABAAoAAAAK
AAIAAAAdAAQAHgABAAcACwABAAkAAAAiAAIAAgAAAAYqK7cAArEAAAABAAoA
AAAKAAIAAAAoAAUAKQABAAcADAABAAkAAAAjAAMAAwAAAAcqKyy3AAOxAAAA
AQAKAAAACgACAAAANAAGADUAAQAHAA0AAQAJAAAAIgACAAIAAAAGKiu3AASx
AAAAAQAKAAAACgACAAAAPwAFAEAAAQAOAAAAAgAP
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/IllegalArgumentException.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/IllegalArgumentException.class
yv66vgAAADMAFgoABgAQCgAGABEKAAYAEgoABgATBwAUBwAVAQAGPGluaXQ+
AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAFShMamF2YS9sYW5n
L1N0cmluZzspVgEAKihMamF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5nL1Ro
cm93YWJsZTspVgEAGChMamF2YS9sYW5nL1Rocm93YWJsZTspVgEAClNvdXJj
ZUZpbGUBAB1JbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24uamF2YQwABwAIDAAH
AAsMAAcADAwABwANAQAiamF2YS9sYW5nL0lsbGVnYWxBcmd1bWVudEV4Y2Vw
dGlvbgEAGmphdmEvbGFuZy9SdW50aW1lRXhjZXB0aW9uACEABQAGAAAAAAAE
AAEABwAIAAEACQAAACEAAQABAAAABSq3AAGxAAAAAQAKAAAACgACAAAAGwAE
ABwAAQAHAAsAAQAJAAAAIgACAAIAAAAGKiu3AAKxAAAAAQAKAAAACgACAAAA
JgAFACcAAQAHAAwAAQAJAAAAIwADAAMAAAAHKisstwADsQAAAAEACgAAAAoA
AgAAADIABgAzAAEABwANAAEACQAAACIAAgACAAAABiortwAEsQAAAAEACgAA
AAoAAgAAAD0ABQA+AAEADgAAAAIADw==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/NullPointerException.class.__mime.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/NullPointerException.class
yv66vgAAADMAEAoABAAMCgAEAA0HAA4HAA8BAAY8aW5pdD4BAAMoKVYBAARD
b2RlAQAPTGluZU51bWJlclRhYmxlAQAVKExqYXZhL2xhbmcvU3RyaW5nOylW
AQAKU291cmNlRmlsZQEAGU51bGxQb2ludGVyRXhjZXB0aW9uLmphdmEMAAUA
BgwABQAJAQAeamF2YS9sYW5nL051bGxQb2ludGVyRXhjZXB0aW9uAQAaamF2
YS9sYW5nL1J1bnRpbWVFeGNlcHRpb24AIQADAAQAAAAAAAIAAQAFAAYAAQAH
AAAAIQABAAEAAAAFKrcAAbEAAAABAAgAAAAKAAIAAAAaAAQAGwABAAUACQAB
AAcAAAAiAAIAAgAAAAYqK7cAArEAAAABAAgAAAAKAAIAAAAlAAUAJgABAAoA
AAACAAs=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Object.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Object.class
yv66vgAAADMAGggAFwcAGAEABjxpbml0PgEAAygpVgEABENvZGUBAA9MaW5l
TnVtYmVyVGFibGUBAAVjbG9uZQEAFCgpTGphdmEvbGFuZy9PYmplY3Q7AQAK
RXhjZXB0aW9ucwcAGQEACGdldENsYXNzAQATKClMamF2YS9sYW5nL0NsYXNz
OwEACVNpZ25hdHVyZQEAFigpTGphdmEvbGFuZy9DbGFzczwqPjsBAAZlcXVh
bHMBABUoTGphdmEvbGFuZy9PYmplY3Q7KVoBAAhoYXNoQ29kZQEAAygpSQEA
CHRvU3RyaW5nAQAUKClMamF2YS9sYW5nL1N0cmluZzsBAApTb3VyY2VGaWxl
AQALT2JqZWN0LmphdmEBAAlBZG9yYWJsZSEBABBqYXZhL2xhbmcvT2JqZWN0
AQAkamF2YS9sYW5nL0Nsb25lTm90U3VwcG9ydGVkRXhjZXB0aW9uACEAAgAA
AAAAAAAGAAEAAwAEAAEABQAAABkAAAABAAAAAbEAAAABAAYAAAAGAAEAAAAR
AAQABwAIAAIABQAAABoAAQABAAAAAgGwAAAAAQAGAAAABgABAAAAHAAJAAAA
BAABAAoAEQALAAwAAgAFAAAAGgABAAEAAAACAbAAAAABAAYAAAAGAAEAAAAn
AA0AAAACAA4AAQAPABAAAQAFAAAAGgABAAIAAAACA6wAAAABAAYAAAAGAAEA
AAAyAAEAEQASAAEABQAAABoAAQABAAAAAgOsAAAAAQAGAAAABgABAAAAPQAB
ABMAFAABAAUAAAAbAAEAAQAAAAMSAbAAAAABAAYAAAAGAAEAAABIAAEAFQAA
AAIAFg==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Override.class.__mime.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Override.class
yv66vgAAADMAEQcADgcADwcAEAEAClNvdXJjZUZpbGUBAA1PdmVycmlkZS5q
YXZhAQAZUnVudGltZVZpc2libGVBbm5vdGF0aW9ucwEAHUxqYXZhL2xhbmcv
YW5ub3RhdGlvbi9UYXJnZXQ7AQAFdmFsdWUBACJMamF2YS9sYW5nL2Fubm90
YXRpb24vRWxlbWVudFR5cGU7AQAGTUVUSE9EAQAgTGphdmEvbGFuZy9hbm5v
dGF0aW9uL1JldGVudGlvbjsBACZMamF2YS9sYW5nL2Fubm90YXRpb24vUmV0
ZW50aW9uUG9saWN5OwEABlNPVVJDRQEAEmphdmEvbGFuZy9PdmVycmlkZQEA
EGphdmEvbGFuZy9PYmplY3QBAB9qYXZhL2xhbmcvYW5ub3RhdGlvbi9Bbm5v
dGF0aW9uJgEAAQACAAEAAwAAAAAAAgAEAAAAAgAFAAYAAAAbAAIABwABAAhb
AAFlAAkACgALAAEACGUADAAN
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/RuntimeException.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/RuntimeException.class
yv66vgAAADMAFgoABgAQCgAGABEKAAYAEgoABgATBwAUBwAVAQAGPGluaXQ+
AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAFShMamF2YS9sYW5n
L1N0cmluZzspVgEAKihMamF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5nL1Ro
cm93YWJsZTspVgEAGChMamF2YS9sYW5nL1Rocm93YWJsZTspVgEAClNvdXJj
ZUZpbGUBABVSdW50aW1lRXhjZXB0aW9uLmphdmEMAAcACAwABwALDAAHAAwM
AAcADQEAGmphdmEvbGFuZy9SdW50aW1lRXhjZXB0aW9uAQATamF2YS9sYW5n
L1Rocm93YWJsZQAhAAUABgAAAAAABAABAAcACAABAAkAAAAhAAEAAQAAAAUq
twABsQAAAAEACgAAAAoAAgAAABoABAAbAAEABwALAAEACQAAACIAAgACAAAA
BiortwACsQAAAAEACgAAAAoAAgAAACUABQAmAAEABwAMAAEACQAAACMAAwAD
AAAAByorLLcAA7EAAAABAAoAAAAKAAIAAAAxAAYAMgABAAcADQABAAkAAAAi
AAIAAgAAAAYqK7cABLEAAAABAAoAAAAKAAIAAAA8AAUAPQABAA4AAAACAA8=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/String.class.__mime.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
begin-base64 644 ./java/lang/String.class
yv66vgAAADMADQoAAwAKBwALBwAMAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA
D0xpbmVOdW1iZXJUYWJsZQEAClNvdXJjZUZpbGUBAAtTdHJpbmcuamF2YQwA
BAAFAQAQamF2YS9sYW5nL1N0cmluZwEAEGphdmEvbGFuZy9PYmplY3QAMQAC
AAMAAAAAAAEAAQAEAAUAAQAGAAAAHQABAAEAAAAFKrcAAbEAAAABAAcAAAAG
AAEAAAARAAEACAAAAAIACQ==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/SuppressWarnings.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/SuppressWarnings.class
yv66vgAAADMAFwcAFAcAFQcAFgEABXZhbHVlAQAVKClbTGphdmEvbGFuZy9T
dHJpbmc7AQAKU291cmNlRmlsZQEAFVN1cHByZXNzV2FybmluZ3MuamF2YQEA
GVJ1bnRpbWVWaXNpYmxlQW5ub3RhdGlvbnMBAB1MamF2YS9sYW5nL2Fubm90
YXRpb24vVGFyZ2V0OwEAIkxqYXZhL2xhbmcvYW5ub3RhdGlvbi9FbGVtZW50
VHlwZTsBAARUWVBFAQAFRklFTEQBAAZNRVRIT0QBAAlQQVJBTUVURVIBAAtD
T05TVFJVQ1RPUgEADkxPQ0FMX1ZBUklBQkxFAQAgTGphdmEvbGFuZy9hbm5v
dGF0aW9uL1JldGVudGlvbjsBACZMamF2YS9sYW5nL2Fubm90YXRpb24vUmV0
ZW50aW9uUG9saWN5OwEABlNPVVJDRQEAGmphdmEvbGFuZy9TdXBwcmVzc1dh
cm5pbmdzAQAQamF2YS9sYW5nL09iamVjdAEAH2phdmEvbGFuZy9hbm5vdGF0
aW9uL0Fubm90YXRpb24mAQABAAIAAQADAAAAAQQBAAQABQAAAAIABgAAAAIA
BwAIAAAANAACAAkAAQAEWwAGZQAKAAtlAAoADGUACgANZQAKAA5lAAoAD2UA
CgAQABEAAQAEZQASABM=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/Throwable.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/Throwable.class
yv66vgAAADMAEAoAAwANBwAOBwAPAQAGPGluaXQ+AQADKClWAQAEQ29kZQEA
D0xpbmVOdW1iZXJUYWJsZQEAFShMamF2YS9sYW5nL1N0cmluZzspVgEAKihM
amF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5nL1Rocm93YWJsZTspVgEAGChM
amF2YS9sYW5nL1Rocm93YWJsZTspVgEAClNvdXJjZUZpbGUBAA5UaHJvd2Fi
bGUuamF2YQwABAAFAQATamF2YS9sYW5nL1Rocm93YWJsZQEAEGphdmEvbGFu
Zy9PYmplY3QAIQACAAMAAAAAAAQAAQAEAAUAAQAGAAAAIQABAAEAAAAFKrcA
AbEAAAABAAcAAAAKAAIAAAAZAAQAGgABAAQACAABAAYAAAAhAAEAAgAAAAUq
twABsQAAAAEABwAAAAoAAgAAACMABAAkAAEABAAJAAEABgAAACEAAQADAAAA
BSq3AAGxAAAAAQAHAAAACgACAAAALgAEAC8AAQAEAAoAAQAGAAAAIQABAAIA
AAAFKrcAAbEAAAABAAcAAAAKAAIAAAA4AAQAOQABAAsAAAACAAw=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/annotation/Annotation.class.__mime.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/annotation/Annotation.class
yv66vgAAADMAEQcADwcAEAEADmFubm90YXRpb25UeXBlAQATKClMamF2YS9s
YW5nL0NsYXNzOwEACVNpZ25hdHVyZQEANygpTGphdmEvbGFuZy9DbGFzczwr
TGphdmEvbGFuZy9hbm5vdGF0aW9uL0Fubm90YXRpb247PjsBAAZlcXVhbHMB
ABUoTGphdmEvbGFuZy9PYmplY3Q7KVoBAAhoYXNoQ29kZQEAAygpSQEACHRv
U3RyaW5nAQAUKClMamF2YS9sYW5nL1N0cmluZzsBAApTb3VyY2VGaWxlAQAP
QW5ub3RhdGlvbi5qYXZhAQAfamF2YS9sYW5nL2Fubm90YXRpb24vQW5ub3Rh
dGlvbgEAEGphdmEvbGFuZy9PYmplY3QGAQABAAIAAAAAAAQEAQADAAQAAQAF
AAAAAgAGBAEABwAIAAAEAQAJAAoAAAQBAAsADAAAAAEADQAAAAIADg==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/annotation/ElementType.class.__mime.

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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/annotation/ElementType.class
yv66vgAAADMARAkABAAyCgAzADQHACMHADUKABgANgoAGAA3CAAZCgAEADcJ
AAQAOAgAGwkABAA5CAAcCQAEADoIAB0JAAQAOwgAHgkABAA8CAAfCQAEAD0I
ACAJAAQAPggAIQkABAA/BwBAAQAPQU5OT1RBVElPTl9UWVBFAQAiTGphdmEv
bGFuZy9hbm5vdGF0aW9uL0VsZW1lbnRUeXBlOwEAC0NPTlNUUlVDVE9SAQAF
RklFTEQBAA5MT0NBTF9WQVJJQUJMRQEABk1FVEhPRAEAB1BBQ0tBR0UBAAlQ
QVJBTUVURVIBAARUWVBFAQAHJFZBTFVFUwEAI1tMamF2YS9sYW5nL2Fubm90
YXRpb24vRWxlbWVudFR5cGU7AQAGdmFsdWVzAQAlKClbTGphdmEvbGFuZy9h
bm5vdGF0aW9uL0VsZW1lbnRUeXBlOwEABENvZGUBAA9MaW5lTnVtYmVyVGFi
bGUBAAd2YWx1ZU9mAQA2KExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5n
L2Fubm90YXRpb24vRWxlbWVudFR5cGU7AQAGPGluaXQ+AQAWKExqYXZhL2xh
bmcvU3RyaW5nO0kpVgEACVNpZ25hdHVyZQEAAygpVgEACDxjbGluaXQ+AQA0
TGphdmEvbGFuZy9FbnVtPExqYXZhL2xhbmcvYW5ub3RhdGlvbi9FbGVtZW50
VHlwZTs+OwEAClNvdXJjZUZpbGUBABBFbGVtZW50VHlwZS5qYXZhDAAiACMH
ACMMAEEAQgEAIGphdmEvbGFuZy9hbm5vdGF0aW9uL0VsZW1lbnRUeXBlDAAo
AEMMACoAKwwAGQAaDAAbABoMABwAGgwAHQAaDAAeABoMAB8AGgwAIAAaDAAh
ABoBAA5qYXZhL2xhbmcvRW51bQEABWNsb25lAQAUKClMamF2YS9sYW5nL09i
amVjdDsBADUoTGphdmEvbGFuZy9DbGFzcztMamF2YS9sYW5nL1N0cmluZzsp
TGphdmEvbGFuZy9FbnVtO0AxAAQAGAAAAAlAGQAZABoAAEAZABsAGgAAQBkA
HAAaAABAGQAdABoAAEAZAB4AGgAAQBkAHwAaAABAGQAgABoAAEAZACEAGgAA
EBoAIgAjAAAABAAJACQAJQABACYAAAAiAAEAAAAAAAqyAAG2AALAAAOwAAAA
AQAnAAAABgABAAAAEwAJACgAKQABACYAAAAiAAIAAQAAAAoSBCq4AAXAAASw
AAAAAQAnAAAABgABAAAAEwACACoAKwACACYAAAAfAAMAAwAAAAcqKxy3AAax
AAAAAQAnAAAABgABAAAAEwAsAAAAAgAtAAgALgAtAAEAJgAAAN0ABAAAAAAA
pbsABFkSBwO3AAizAAm7AARZEgoEtwAIswALuwAEWRIMBbcACLMADbsABFkS
Dga3AAizAA+7AARZEhAHtwAIswARuwAEWRISCLcACLMAE7sABFkSFBAGtwAI
swAVuwAEWRIWEAe3AAizABcQCL0ABFkDsgAJU1kEsgALU1kFsgANU1kGsgAP
U1kHsgARU1kIsgATU1kQBrIAFVNZEAeyABdTswABsQAAAAEAJwAAACYACQAA
ABYADQAZABoAHAAnAB8ANAAiAEEAJQBOACgAXAArAGoAEwACACwAAAACAC8A
MAAAAAIAMQ==
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/annotation/Retention.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/annotation/Retention.class
yv66vgAAADMAEgcADwcAEAcAEQEABXZhbHVlAQAoKClMamF2YS9sYW5nL2Fu
bm90YXRpb24vUmV0ZW50aW9uUG9saWN5OwEAClNvdXJjZUZpbGUBAA5SZXRl
bnRpb24uamF2YQEAGVJ1bnRpbWVWaXNpYmxlQW5ub3RhdGlvbnMBACBMamF2
YS9sYW5nL2Fubm90YXRpb24vUmV0ZW50aW9uOwEAJkxqYXZhL2xhbmcvYW5u
b3RhdGlvbi9SZXRlbnRpb25Qb2xpY3k7AQAHUlVOVElNRQEAHUxqYXZhL2xh
bmcvYW5ub3RhdGlvbi9UYXJnZXQ7AQAiTGphdmEvbGFuZy9hbm5vdGF0aW9u
L0VsZW1lbnRUeXBlOwEAD0FOTk9UQVRJT05fVFlQRQEAHmphdmEvbGFuZy9h
bm5vdGF0aW9uL1JldGVudGlvbgEAEGphdmEvbGFuZy9PYmplY3QBAB9qYXZh
L2xhbmcvYW5ub3RhdGlvbi9Bbm5vdGF0aW9uJgEAAQACAAEAAwAAAAEEAQAE
AAUAAAACAAYAAAACAAcACAAAABsAAgAJAAEABGUACgALAAwAAQAEWwABZQAN
AA4=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/annotation/RetentionPolicy.class.__mime.

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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/annotation/RetentionPolicy.class
yv66vgAAADMAMAkABAAjCgAkACUHABQHACYKAA4AJwoADgAoCAAPCgAEACgJ
AAQAKQgAEQkABAAqCAASCQAEACsHACwBAAVDTEFTUwEAJkxqYXZhL2xhbmcv
YW5ub3RhdGlvbi9SZXRlbnRpb25Qb2xpY3k7AQAHUlVOVElNRQEABlNPVVJD
RQEAByRWQUxVRVMBACdbTGphdmEvbGFuZy9hbm5vdGF0aW9uL1JldGVudGlv
blBvbGljeTsBAAZ2YWx1ZXMBACkoKVtMamF2YS9sYW5nL2Fubm90YXRpb24v
UmV0ZW50aW9uUG9saWN5OwEABENvZGUBAA9MaW5lTnVtYmVyVGFibGUBAAd2
YWx1ZU9mAQA6KExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL2Fubm90
YXRpb24vUmV0ZW50aW9uUG9saWN5OwEABjxpbml0PgEAFihMamF2YS9sYW5n
L1N0cmluZztJKVYBAAlTaWduYXR1cmUBAAMoKVYBAAg8Y2xpbml0PgEAOExq
YXZhL2xhbmcvRW51bTxMamF2YS9sYW5nL2Fubm90YXRpb24vUmV0ZW50aW9u
UG9saWN5Oz47AQAKU291cmNlRmlsZQEAFFJldGVudGlvblBvbGljeS5qYXZh
DAATABQHABQMAC0ALgEAJGphdmEvbGFuZy9hbm5vdGF0aW9uL1JldGVudGlv
blBvbGljeQwAGQAvDAAbABwMAA8AEAwAEQAQDAASABABAA5qYXZhL2xhbmcv
RW51bQEABWNsb25lAQAUKClMamF2YS9sYW5nL09iamVjdDsBADUoTGphdmEv
bGFuZy9DbGFzcztMamF2YS9sYW5nL1N0cmluZzspTGphdmEvbGFuZy9FbnVt
O0AxAAQADgAAAARAGQAPABAAAEAZABEAEAAAQBkAEgAQAAAQGgATABQAAAAE
AAkAFQAWAAEAFwAAACIAAQAAAAAACrIAAbYAAsAAA7AAAAABABgAAAAGAAEA
AAATAAkAGQAaAAEAFwAAACIAAgABAAAAChIEKrgABcAABLAAAAABABgAAAAG
AAEAAAATAAIAGwAcAAIAFwAAAB8AAwADAAAAByorHLcABrEAAAABABgAAAAG
AAEAAAATAB0AAAACAB4ACAAfAB4AAQAXAAAAZQAEAAAAAABBuwAEWRIHA7cA
CLMACbsABFkSCgS3AAizAAu7AARZEgwFtwAIswANBr0ABFkDsgAJU1kEsgAL
U1kFsgANU7MAAbEAAAABABgAAAASAAQAAAAWAA0AGQAaABwAJwATAAIAHQAA
AAIAIAAhAAAAAgAi
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/lang/annotation/Target.class.__mime.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 ./java/lang/annotation/Target.class
yv66vgAAADMAEgcADwcAEAcAEQEABXZhbHVlAQAlKClbTGphdmEvbGFuZy9h
bm5vdGF0aW9uL0VsZW1lbnRUeXBlOwEAClNvdXJjZUZpbGUBAAtUYXJnZXQu
amF2YQEAGVJ1bnRpbWVWaXNpYmxlQW5ub3RhdGlvbnMBACBMamF2YS9sYW5n
L2Fubm90YXRpb24vUmV0ZW50aW9uOwEAJkxqYXZhL2xhbmcvYW5ub3RhdGlv
bi9SZXRlbnRpb25Qb2xpY3k7AQAHUlVOVElNRQEAHUxqYXZhL2xhbmcvYW5u
b3RhdGlvbi9UYXJnZXQ7AQAiTGphdmEvbGFuZy9hbm5vdGF0aW9uL0VsZW1l
bnRUeXBlOwEAD0FOTk9UQVRJT05fVFlQRQEAG2phdmEvbGFuZy9hbm5vdGF0
aW9uL1RhcmdldAEAEGphdmEvbGFuZy9PYmplY3QBAB9qYXZhL2xhbmcvYW5u
b3RhdGlvbi9Bbm5vdGF0aW9uJgEAAQACAAEAAwAAAAEEAQAEAAUAAAACAAYA
AAACAAcACAAAABsAAgAJAAEABGUACgALAAwAAQAEWwABZQANAA4=
====

Deleted runt/libs/tool-compiler.test/mini-cldc/java/util/List.class.__mime.

1
2
3
4
5
6






-
-
-
-
-
-
begin-base64 644 ./java/util/List.class
yv66vgAAADMACQcABwcACAEACVNpZ25hdHVyZQEAKDxUOkxqYXZhL2xhbmcv
T2JqZWN0Oz5MamF2YS9sYW5nL09iamVjdDsBAApTb3VyY2VGaWxlAQAJTGlz
dC5qYXZhAQAOamF2YS91dGlsL0xpc3QBABBqYXZhL2xhbmcvT2JqZWN0BgEA
AQACAAAAAAAAAAIAAwAAAAIABAAFAAAAAgAG
====

Deleted runt/libs/tool-compiler.test/mini-cldc/list.

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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
.
source-files
source-files/java
source-files/java/lang
source-files/java/lang/Object.java
source-files/java/lang/Error.java
source-files/java/lang/IllegalArgumentException.java
source-files/java/lang/String.java
source-files/java/lang/Enum.java
source-files/java/lang/Comparable.java
source-files/java/lang/RuntimeException.java
source-files/java/lang/Override.java
source-files/java/lang/Throwable.java
source-files/java/lang/package-info.java
source-files/java/lang/NullPointerException.java
source-files/java/lang/annotation
source-files/java/lang/annotation/Inherited.java
source-files/java/lang/annotation/Retention.java
source-files/java/lang/annotation/Target.java
source-files/java/lang/annotation/Annotation.java
source-files/java/lang/annotation/RetentionPolicy.java
source-files/java/lang/annotation/Documented.java
source-files/java/lang/annotation/ElementType.java
source-files/java/lang/SuppressWarnings.java
source-files/java/lang/Exception.java
source-files/java/lang/Class.java
source-files/java/lang/CloneNotSupportedException.java
source-files/java/lang/ClassCastException.java
source-files/java/util
source-files/java/util/List.java
java
java/lang
java/lang/Error.class
java/lang/Override.class
java/lang/SuppressWarnings.class
java/lang/Class.class
java/lang/Exception.class
java/lang/String.class
java/lang/Throwable.class
java/lang/RuntimeException.class
java/lang/IllegalArgumentException.class
java/lang/ClassCastException.class
java/lang/CloneNotSupportedException.class
java/lang/annotation
java/lang/annotation/RetentionPolicy.class
java/lang/annotation/ElementType.class
java/lang/annotation/Target.class
java/lang/annotation/Retention.class
java/lang/annotation/Annotation.class
java/lang/Enum.class
java/lang/Object.class
java/lang/NullPointerException.class
java/lang/Comparable.class
java/util
java/util/List.class
compile.sh
list

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Class.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents the Java accessible class object which describes this
 * class.
 *
 * @param <C> The class type.
 * @since 2019/05/26
 */
public final class Class<C>
{
	/**
	 * Returns the super class of this class.
	 *
	 * @return The super class of this class.
	 * @since 2019/05/26
	 */
	public final Class<?> getSuperclass()
	{
		return null;
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/ClassCastException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when the class is not the correct type.
 *
 * @since 2019/05/25
 */
public class ClassCastException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public ClassCastException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public ClassCastException(String __m)
	{
		super(__m);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/CloneNotSupportedException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when cloning is not supported for the given object.
 *
 * @since 2018/12/04
 */
public class CloneNotSupportedException
	extends Exception
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @since 2018/12/04
	 */
	public CloneNotSupportedException(String __m)
	{
		super(__m);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Comparable.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This interface is used to set two classes as being comparable to other
 * classes.
 *
 * It is not required to but comparisons performed by this interface should
 * be comparable to {@link Object#equals(Object)} so that
 * {@code a.equals(b) == (a.compareTo(b) == 0)}.
 *
 * It is recommended to implement this class so that
 * {@code a.compareTo(b) == -b.compareTo(a)} is true, this makes the
 * comparisons consistent. However this might not be feasible for speed
 * purposes so it is highly recommended to at least have comparible negative,
 * zero, and positive.
 *
 * @param <T> The type to compare.
 * @since 2018/09/19
 */
public interface Comparable<T>
{
	/**
	 * Compares this instance to the argument passed, 
	 *
	 * Note that {@code NullPointerException} should be thrown for {@code __b}
	 * since {@code __b.compareTo(this)} would thrown an exception.
	 *
	 * @param __b The object to compare against.
	 * @return The result of the comparison, negative values mean
	 * {@code this < __b}, zero means {@code this == __b}, and positive values
	 * mean {@code this > __b}.
	 * @since 2018/09/19
	 */
	public abstract int compareTo(T __b);
}


Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Enum.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
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












































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is the base class for enum types.
 *
 * @param <E> The enum type.
 * @since 2018/09/24
 */
public abstract class Enum<E extends Enum<E>>
	implements Comparable<E>
{
	/** The name of the enum. */
	private final String _name;
	
	/** The ordinal of the enumeration. */
	private final int _ordinal;
	
	/**
	 * Initializes the enum properties.
	 *
	 * @param __s The enum name.
	 * @param __o The enum ordinal.
	 * @throws IllegalArgumentException If the ordinal is negative.
	 * @throws NullPointerException If no name was specified.
	 * @since 2018/09/24
	 */
	protected Enum(String __s, int __o)
		throws IllegalArgumentException, NullPointerException
	{
		// Enum has no string
		if (__s == null)
			throw new NullPointerException();
		
		// Enum has negative ordinal
		if (__o < 0)
			throw new IllegalArgumentException();
		
		this._name = __s;
		this._ordinal = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	protected final Object clone()
		throws CloneNotSupportedException
	{
		// Enums cannot be cloned.
		throw new CloneNotSupportedException();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int compareTo(E __o)
		throws ClassCastException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException();
		
		// Cannot compare enums of a different type.
		if (this.getDeclaringClass() != __o.getDeclaringClass())
			throw new ClassCastException();
		
		// Just ordinal subtraction
		return this.ordinal() - __o.ordinal();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return this == __o;
	}
	
	/**
	 * Returns the class that declares this enum, this may be different from
	 * {@link Object#getClass()}.
	 *
	 * @return The declaring class of this enum.
	 * @since 2018/09/24
	 */
	@SuppressWarnings({"unchecked"})
	public final Class<E> getDeclaringClass()
	{
		// Enums are either directly extending or extending a base class which
		// then extends this class, so we just need to look a few places up
		// the tree
		Class<?> me = this.getClass(),
			ext = me.getSuperclass();
		if (ext == Enum.class)
			return (Class<E>)((Object)me);
		return (Class<E>)((Object)ext);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public final int hashCode()
	{
		return super.hashCode();
	}
	
	/**
	 * Returns the name of the constant.
	 *
	 * @return The constant name.
	 * @since 2018/09/24
	 */
	public final String name()
	{
		return this._name;
	}
	
	/**
	 * Returns the ordinal of the constant.
	 *
	 * @return The ordinal constant.
	 * @since 2018/09/24
	 */
	public final int ordinal()
	{
		return this._ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/09/24
	 */
	@Override
	public String toString()
	{
		return this._name;
	}
	
	/**
	 * From the given enumeration, find a value which matches the given name.
	 *
	 * @param <T> The enumeration type to search in.
	 * @param __cl The class to lookup.
	 * @param __s The string to search for.
	 * @return The enumeration value.
	 * @throws IllegalArgumentException If the value was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/07
	 */
	public static <T extends Enum<T>> T valueOf(Class<T> __cl, String __s)
		throws IllegalArgumentException, NullPointerException
	{
		return null;
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Error.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This represents an error which should not be caught.
 *
 * @since 2019/05/25
 */
public class Error
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public Error()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public Error(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Error(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Error(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Exception.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * For any exceptions which extend this class and not {@link RuntimeException}
 * they will act as checked exceptions by the compiler, thus they will need
 * to be handled accordingly.
 *
 * @since 2018/09/16
 */
public class Exception
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/09/16
	 */
	public Exception()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/09/16
	 */
	public Exception(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/09/16
	 */
	public Exception(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/IllegalArgumentException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

/**
 * This is thrown when the argument of a method is not correct.
 *
 * @since 2018/10/12
 */
public class IllegalArgumentException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2018/10/12
	 */
	public IllegalArgumentException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2018/10/12
	 */
	public IllegalArgumentException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/NullPointerException.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is thrown when there is a null pointer.
 *
 * @since 2019/05/25
 */
public class NullPointerException
	extends RuntimeException
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public NullPointerException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public NullPointerException(String __m)
	{
		super(__m);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Object.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * Object class.
 *
 * @since 2019/06/30
 */
public class Object
{
	/**
	 * Returns null.
	 *
	 * @return null.
	 * @since 2019/06/30
	 */
	protected Object clone()
		throws CloneNotSupportedException
	{
		return null;
	}

	/**
	 * Returns null.
	 *
	 * @return null.
	 * @since 2019/06/30
	 */
	public final Class<?> getClass()
	{
		return null;
	}
	
	/**
	 * Equals.
	 *
	 * @return Always {@code false}.
	 * @since 2019/06/30
	 */
	public boolean equals(Object __o)
	{
		return false;
	}

	/**
	 * Hash code.
	 *
	 * @return The hash code.
	 * @since 2019/06/30
	 */
	public int hashCode()
	{
		return 0;
	}

	/**
	 * String form.
	 *
	 * @return This as a string.
	 * @since 2019/06/30
	 */
	public String toString()
	{
		return "Adorable!";
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Override.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This is a flagging annotation which is attached to a method to indicate that
 * it overrides a method in the super class. When the compiler encounters
 * this, it makes sure that it actually overrides a method. If it does not
 * then a compilation error occurs. Using this all the time is recommended when
 * a method is intended to be overidden.
 *
 * As an example, if the base class has the following method:
 *
 * {@code
 * public static int foo(long __a);
 * }
 *
 * And a class which extends the base class has the following method:
 *
 * {@code
 * public static int foo(int __a);
 * }
 *
 * If it is intended to add a new {@code foo} which handles {@code int} instead
 * of {@code long} then this annotation should not be used, however it it is
 * intended to replace it (and specifying {@code int} was a mistake) then this
 * should be used.
 *
 * @since 2016/04/12
 */
@Target(value={ElementType.METHOD})
@Retention(value=RetentionPolicy.SOURCE)
public @interface Override
{
}


Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/RuntimeException.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is the base for any exception which is unchecked.
 *
 * @since 2019/05/25
 */
public class RuntimeException
	extends Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public RuntimeException()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public RuntimeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public RuntimeException(String __m, Throwable __t)
	{
		super(__m, __t);
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public RuntimeException(Throwable __t)
	{
		super(__t);
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/String.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * String class.
 *
 * @since 2019/06/30
 */
public final class String
{
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/SuppressWarnings.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Suppresses warnings that are generated by the compiler so that they do not
 * appear for the given method. Duplicates are permitted and values which are
 * unknown are ignored.
 *
 * The following warnings may have support to be disabled, although it is not
 * required: {@code all}, {@code boxing}, {@code cast}, {@code dep-ann},
 * {@code deprecation}, {@code fallthrough}, {@code finally}, {@code hiding},
 * {@code incomplete-switch}, {@code nls}, {@code null}, {@code rawtypes},
 * {@code restriction}, {@code serial}, {@code static-access},
 * {@code synthetic-access}, {@code unchecked},
 * {@code unqualified-field-access}, and {@code unused}.
 *
 * @since 2018/09/19
 */
@Target(value={ElementType.TYPE, ElementType.FIELD, ElementType.METHOD,
	ElementType.PARAMETER, ElementType.CONSTRUCTOR,
	ElementType.LOCAL_VARIABLE})
@Retention(value=RetentionPolicy.SOURCE)
public @interface SuppressWarnings
{
	/** The warnings that should be suppressed. */
	String[] value();
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/Throwable.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



























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.lang;

/**
 * This is the base class for all throwable types.
 *
 * @since 2019/05/25
 */
public class Throwable
{
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/05/25
	 */
	public Throwable()
	{
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/05/25
	 */
	public Throwable(String __m)
	{
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Throwable(String __m, Throwable __t)
	{
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/05/25
	 */
	public Throwable(Throwable __t)
	{
	}
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/Annotation.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is the common interface in which all annotation types are inherited
 * from.
 *
 * If a random class or interface implements this interface and it is not an
 * annotation type, then it is not an annotation.
 *
 * @since 2014/10/13
 */
public interface Annotation
{
	/**
	 * Returns the annotation type used for this annotation.
	 *
	 * @return The annotation type.
	 * @since 2014/10/13
	 */
	public abstract Class<? extends Annotation> annotationType();
	
	/**
	 * Checks the logical equality to another annotation type, they are both
	 * considered to be equal when all of their members are equal and they are
	 * of the same type.
	 *
	 * Primitive types are checked directly except for floating point types
	 * which are equality checked through their wrapper classes.
	 *
	 * Floating point NaN values are considered to be equal, that is the
	 * {@code ==} operator is not used.
	 *
	 * {@link String}, {@link Class}, and enumerations are considered equal if
	 * their normal {@code equals()} evaluates to true.
	 *
	 * Two arrays are equal if {@code Arrays.equals(a, b)} evaluates to
	 * {@code true}.
	 *
	 * @param __o The other object to check against.
	 * @return {@code true} if they are logically equivalent.
	 * @since 2014/10/13
	 */
	public abstract boolean equals(Object __o);
	
	/**
	 * Calculates the hash code which is a sum of the hash codes of its members
	 * in a specifically defined pattern.
	 *
	 * The base hash code for a member is {@code (127 *
	 * ((String)memberName).hashCode()) ^ specialValue}. The variable
	 * {@code specialValue} is defined depending on the
	 * context. If it is a primitive type, then the hash code that would be
	 * returned if they were object types (their wrapper classes) is used. If
	 * an array then {@code Arrays.hashCode()} is used. Otherwise, it is the
	 * normal hashCode of the specified value.
	 *
	 * @return The hash code for this annotation.
	 * @since 2014/10/13
	 */
	public abstract int hashCode();
	
	/**
	 * Returns an implementation dependent string which represents the
	 * annotation and all of its values.
	 *
	 * @return The string representation of this annotation.
	 * @since 2014/10/13
	 */
	public abstract String toString();
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/Documented.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This indicates that the specified annotation should be documented by the
 * Java documentation tool whenever it is used.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Documented
{
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/ElementType.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the type of element that the annotation is permitted to be
 * attached to in the source code.
 *
 * @since 2014/10/13
 */
public enum ElementType
{
	/** Annotation types). */
	ANNOTATION_TYPE(),
	
	/** Constructors. */
	CONSTRUCTOR(),
	
	/** Fields. */
	FIELD(),
	
	/** Local variables. */
	LOCAL_VARIABLE(),
	
	/** Methods. */
	METHOD(),
	
	/** Packages. */
	PACKAGE(),
	
	/** Parameter of a method. */
	PARAMETER(),
	
	/** A class, interface, or enumeration. */
	TYPE(),
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/Inherited.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Indicates that the annotation type should automatically be inherited so that
 * the subclass type appears to have this annotation when it is requested. That
 * is, if an annotation with this annotation is requested it will keep going up
 * the superclasses until it is found.
 *
 * This only affects classes which use an annotation with this annotation, as
 * such interfaces are excluded.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Inherited
{
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/Retention.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * This is used to indicate how far into the compilation and runtime process
 * should keep a visible mark on an annotation.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Retention
{
	/**
	 * Specifies where the annotation exists during and after compilation of
	 * source code.
	 *
	 * @return The storage of the annotation.
	 * @see RetentionPolicy
	 * @since 2014/10/13
	 */
	RetentionPolicy value();
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/RetentionPolicy.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies how far through compilation and running of code that an annotation
 * should be visible.
 *
 * @since 2014/10/13
 */
public enum RetentionPolicy
{
	/** Kept after compilation, but not visible at runtime. */
	CLASS(),
	
	/** Kept after compilation and visible at runtime. */
	RUNTIME(),
	
	/** Removed after compilation, does not appear in the class file. */
	SOURCE(),
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/annotation/Target.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang.annotation;

/**
 * Specifies the context in which the annotation is valid.
 *
 * @since 2014/10/13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface Target
{
	/**
	 * A list of valid contexts where the annotation may be used.
	 *
	 * @return An array of permitted targets.
	 * @since 2014/10/13
	 */
	ElementType[] value();
}

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/lang/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Java language package.
 *
 * @since 2019/06/30
 */

package java.lang;

Deleted runt/libs/tool-compiler.test/mini-cldc/source-files/java/util/List.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 java.util;

/**
 * List interface.
 *
 * @param <T> List type.
 * @since 2019/06/30
 */
public interface List<T>
{
}

Deleted runt/libs/tool-compiler/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 8fbf0127-aca6-477f-8220-cde2ce21da48
X-SquirrelJME-Error: AQ
X-SquirrelJME-Name: Java Compiler
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project is used to compile and 
 document Java source code. 
X-SquirrelJME-Depends: collections zip io tool-classfile collections
Microedition-Configuration: CLDC-1.8

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ByteArrayCompilerInput.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
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


































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Arrays;

/**
 * This is input for the compiler which uses the specified byte array as
 * input.
 *
 * @since 2018/03/06
 */
public final class ByteArrayCompilerInput
	implements CompilerInput
{
	/** The name of the input. */
	protected final String name;
	
	/** The last modified time. */
	protected final long lastmodifiedtime;
	
	/** The data for the compiler. */
	private final byte[] _data;
	
	/**
	 * Initializes the compiler input at the current time.
	 *
	 * @param __name The name of the input.
	 * @param __data The data to use for the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public ByteArrayCompilerInput(String __name, byte[] __data)
		throws NullPointerException
	{
		this(__name, System.currentTimeMillis(), __data);
	}
	
	/**
	 * Initializes the compiler input.
	 *
	 * @param __name The name of the input.
	 * @param __lmt The time this input was last modified.
	 * @param __data The data to use for the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public ByteArrayCompilerInput(String __name, long __lmt, byte[] __data)
		throws NullPointerException
	{
		if (__name == null || __data == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.lastmodifiedtime = __lmt;
		this._data = __data.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ByteArrayCompilerInput))
			return false;
		
		ByteArrayCompilerInput o = (ByteArrayCompilerInput)__o;
		return this.name.equals(o.name) &&
			Arrays.equals(this._data, o._data);
	}

	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final String fileName()
		throws CompilerException
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final long lastModifiedTime()
		throws CompilerException
	{
		return this.lastmodifiedtime;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final InputStream open()
		throws CompilerException, NoSuchInputException
	{
		return new ByteArrayInputStream(this._data);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilationFailedException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This is thrown when compilation has failed because of an error.
 *
 * @since 2017/11/29
 */
public class CompilationFailedException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/29
	 */
	public CompilationFailedException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/29
	 */
	public CompilationFailedException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/29
	 */
	public CompilationFailedException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/29
	 */
	public CompilationFailedException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/Compiler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307



















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Writer;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
 * This interface is used to describe a compiler which is used to compile
 * Java source code into Java class files.
 *
 * Where the compilation log is initially output is undefined and unspecified
 * and it may be to standard error, a file on the disk, or not output at all.
 *
 * This class must be thread safe.
 *
 * This class is mutable, when {@link #compile()} is called all the options
 * will be passed to the compiler instance and any instance of this class may
 * be used again or modified as such.
 *
 * There should be a default set of options specified for the compiler.
 *
 * By default all locations should have {@link EmptyPathSet} as their initial
 * instance.
 *
 * @since 2017/11/28
 */
public abstract class Compiler
{
	/** Internal lock. */
	private final Object _lock =
		new Object();
	
	/** Input for the compiler. */
	private final Set<CompilerInput> _input =
		new LinkedHashSet<>();
	
	/** Paths for each location. */
	private final Map<CompilerInputLocation, CompilerPathSet[]> _locations =
		new HashMap<>();
	
	/** Compiler options. */
	private volatile CompilerOptions _options =
		new CompilerOptions();
	
	/** Writer for compilation errors. */
	private volatile PrintStream _writer =
		System.err;
	
	/**
	 * Base initialization.
	 *
	 * @since 2017/11/29
	 */
	{
		// Setup path sets with default locations
		Map<CompilerInputLocation, CompilerPathSet[]> locs = this._locations;
		for (CompilerInputLocation l : CompilerInputLocation.values())
			locs.put(l, new CompilerPathSet[]{EmptyPathSet.instance()});
	}
	
	/**
	 * Creates a new runnable which runs the compiler when it is ran using
	 * the given input.
	 *
	 * @param __out The location where generated files are to be placed.
	 * @param __log Compilation log.
	 * @param __opt The options for compilation.
	 * @param __paths The paths to use for input files.
	 * @param __input The files to implicitly compile.
	 * @return A runnable which when ran calls the actual compiler.
	 * @throws CompilerException If the runnable could not be created because
	 * of an issue with the options or the compiler.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	protected abstract Runnable newCompilerRunnable(CompilerOutput __out,
		PrintStream __log, CompilerOptions __opt,
		CompilerPathSet[][] __paths, CompilerInput[] __input)
		throws CompilerException, NullPointerException;
	
	/**
	 * Adds the specified input to be compiled by the compiler.
	 *
	 * @param __i The input file to add to the compiler.
	 * @return If the input was added and it resulted in the change of the
	 * inputs, that is this follows the same semantics as
	 * {@link java.util.Collection#add(Object)}.
	 * @throws CompilerException If the input could not be added.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final boolean addInput(CompilerInput __i)
		throws CompilerException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		synchronized (this._lock)
		{
			return this._input.add(__i);
		}
	}
	
	/**
	 * Creates an instance of {@link Runnable} which can be used to perform
	 * compilation.
	 *
	 * @param __o The output where the result of compilation is placed.
	 * @return {@code true} if compilation has succeeded.
	 * @throws CompilerException If any parameter used for compilation is
	 * not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final Runnable compile(CompilerOutput __o)
		throws CompilerException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Input for the compiler
		CompilerInput[] rvinput;
		CompilerOptions rvoptions;
		CompilerPathSet[][] rvpathsets;
		PrintStream rvwriter;
		
		// Read input options
		synchronized (this._lock)
		{
			rvoptions = this._options;
			rvwriter = this._writer;
			
			// Copy input
			Set<CompilerInput> input = this._input;
			rvinput = input.<CompilerInput>toArray(
				new CompilerInput[input.size()]);
			
			// {@squirreljme.error AQ01 No input files.}
			if (rvinput.length <= 0)
				throw new CompilerException("AQ01");
			
			// Copy path sets
			Map<CompilerInputLocation, CompilerPathSet[]> locations =
				this._locations;
			CompilerInputLocation[] cils = CompilerInputLocation.values();
			int ncils = cils.length;
			rvpathsets = new CompilerPathSet[ncils][];
			for (CompilerInputLocation cil : cils)
				rvpathsets[cil.ordinal()] = locations.get(cil).clone();
		}
		
		// Setup the compilation thread
		return newCompilerRunnable(__o, rvwriter, rvoptions, rvpathsets,
			rvinput);
	}
	
	/**
	 * Returns all of the input which has been specified for compilation.
	 *
	 * @return An array containing all of the input for the compiler.
	 * @throws CompilerException If this could not be obtained.
	 * @since 2017/11/28
	 */
	public final CompilerInput[] input()
		throws CompilerException
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the path set which is used for the given location.
	 *
	 * @param __l The location to get the path set for.
	 * @return The current path set used for the given location.
	 * @throws CompilerException If there was an error removing it.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final CompilerPathSet[] location(CompilerInputLocation __l)
		throws CompilerException, NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Returns the options which are currently specified for this compiler.
	 *
	 * @return The current compiler options.
	 * @throws CompilerException If the options could not be obtained.
	 * @since 2017/11/28
	 */
	public final CompilerOptions options()
		throws CompilerException
	{
		return this._options;
	}
	
	/**
	 * Removes the specified input file so that it is not compiled.
	 *
	 * @param __i The input to remove.
	 * @return If the input was removed or not.
	 * @throws CompilerException If there was an issue removing the input.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final boolean removeInput(CompilerInput __i)
		throws CompilerException, NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the specified location to the given path set.
	 *
	 * @param __l The locatioin to set.
	 * @param __s The path sets to use.
	 * @return The path set which was previously specified.
	 * @throws CompilerException If it could not be set for some reason.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final CompilerPathSet[] setLocation(CompilerInputLocation __l,
		CompilerPathSet... __s)
		throws CompilerException, NullPointerException
	{
		if (__l == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Defensive check for nulls
		__s = __s.clone();
		for (CompilerPathSet s : __s)
			if (s == null)
				throw new NullPointerException("NARG");
		
		Map<CompilerInputLocation, CompilerPathSet[]> locs = this._locations;
		synchronized (this._lock)
		{
			return locs.put(__l, __s).clone();
		}
	}
	
	/**
	 * Sets the compilation options that are to be used during compilation.
	 *
	 * @param __o The options to set.
	 * @return The old compilation options.
	 * @throws CompilerException If the options are not valid for this
	 * compiler.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public final CompilerOptions setOptions(CompilerOptions __o)
		throws CompilerException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Sets the output stream which is used to output the compilation log.
	 *
	 * @param __o The output stream to write text to.
	 * @throws CompilerException If it could not be set.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public final void setWriter(OutputStream __o)
		throws CompilerException, NullPointerException
	{
		if (__o == null)
			throw new NullPointerException("NARG");
		
		// Normalize
		PrintStream use = (__o instanceof PrintStream ?
			(PrintStream)__o : new PrintStream(__o));
		
		synchronized (this._lock)
		{
			this._writer = use;
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerException.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This is thrown when there is an issue with compilation.
 *
 * @since 2017/09/05
 */
public class CompilerException
	extends RuntimeException
	implements FileNameLineAndColumn
{
	/** The column where the error occured. */
	protected final int column;
	
	/** The line where the error occured. */
	protected final int line;
	
	/** The file being processed. */
	protected final String filename;
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/09/05
	 */
	public CompilerException()
	{
		this.column = -1;
		this.line = -1;
		this.filename = null;
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/09/05
	 */
	public CompilerException(String __m)
	{
		super(__m);
		
		this.column = -1;
		this.line = -1;
		this.filename = null;
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/09/05
	 */
	public CompilerException(String __m, Throwable __c)
	{
		super(__m, __c);
		
		this.column = -1;
		this.line = -1;
		this.filename = null;
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/09/05
	 */
	public CompilerException(Throwable __c)
	{
		super(__c);
		
		this.column = -1;
		this.line = -1;
		this.filename = null;
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2017/03/12
	 */
	public CompilerException(LocationAware __la)
	{
		this.filename = ((__la instanceof FileName) ?
			((FileName)__la).fileName() : null);
		
		if (__la instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__la;
			this.column = lc.column();
			this.line = lc.line();
		}
		else
		{
			this.column = -1;
			this.line = -1;
		}
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2017/03/12
	 */
	public CompilerException(LocationAware __la, String __m)
	{
		super(__m);
		
		this.filename = ((__la instanceof FileName) ?
			((FileName)__la).fileName() : null);
		
		if (__la instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__la;
			this.column = lc.column();
			this.line = lc.line();
		}
		else
		{
			this.column = -1;
			this.line = -1;
		}
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/03/12
	 */
	public CompilerException(LocationAware __la, String __m, Throwable __c)
	{
		super(__m, __c);
		
		this.filename = ((__la instanceof FileName) ?
			((FileName)__la).fileName() : null);
		
		if (__la instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__la;
			this.column = lc.column();
			this.line = lc.line();
		}
		else
		{
			this.column = -1;
			this.line = -1;
		}
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2017/03/12
	 */
	public CompilerException(LocationAware __la, Throwable __c)
	{
		super(__c);
		
		this.filename = ((__la instanceof FileName) ?
			((FileName)__la).fileName() : null);
		
		if (__la instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__la;
			this.column = lc.column();
			this.line = lc.line();
		}
		else
		{
			this.column = -1;
			this.line = -1;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final int column()
	{
		return this.column;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final String fileName()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final int line()
	{
		return this.line;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerInput.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.InputStream;

/**
 * This is used as input for the compiler and is used for source code and/or
 * class binaries.
 *
 * All instances of this class must be thread safe.
 *
 * Inputs which would logically refer to the same file must be equal to each
 * other. As such it is required that {@link #equals(Object)} and
 * {@link #hashCode()} are correctly implemented.
 *
 * @since 2017/11/28
 */
public interface CompilerInput
	extends FileName
{
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public abstract boolean equals(Object __o);
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public abstract int hashCode();
	
	/**
	 * Returns the last modified date of the input file in UTC milliseconds
	 * since the epoch.
	 *
	 * @return The last modfiied date of the input.
	 * @throws CompilerException If it could not be determined.
	 * @since 2018/03/06
	 */
	public abstract long lastModifiedTime()
		throws CompilerException;

	/**
	 * Returns the name of the input file.
	 *
	 * @return The input file name.
	 * @throws CompilerException If the name could not be obtained.
	 * @since 2017/11/28
	 */
	@Override
	public abstract String fileName()
		throws CompilerException;
	
	/**
	 * Opens an input stream for this input.
	 *
	 * @return The stream for the given input.
	 * @throws CompilerException If the stream could not be opened for any
	 * reason.
	 * @throws NoSuchInputException If the input does not exist.
	 * @since 2017/11/28
	 */
	public abstract InputStream open()
		throws CompilerException, NoSuchInputException;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerInputLocation.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This specifies the locations which are used for input and is needed for
 * lookup of classes and source code.
 *
 * @since 2017/11/28
 */
public enum CompilerInputLocation
{
	/**
	 * Source code.
	 *
	 * Note that this location is used for lookup of source code as needed.
	 */
	SOURCE,
	
	/** Classes. */
	CLASS,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerJavaVersion.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * Specifies the version of the Java language which the compiler should target.
 *
 * @since 2017/11/29
 */
public enum CompilerJavaVersion
{
	/** Target Java 7. */
	JAVA_7,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerLogger.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
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












































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.PrintStream;

/**
 * This is used to a class which can easily output messages for the compiler
 * to the given log.
 *
 * @since 2018/03/12
 */
public final class CompilerLogger
{
	/** The stream to print to. */
	protected final PrintStream out;
	
	/**
	 * Initializes the logger.
	 *
	 * @param __out The stream to print to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/12
	 */
	public CompilerLogger(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
	}
	
	/**
	 * Logs the specified message.
	 *
	 * @param __t The type of message to display.
	 * @param __la Location awareness information, this may be {@code null}.
	 * @param __m The formatted message to show.
	 * @param __args The arguments to the formatted message.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public final void message(MessageType __t, LocationAware __la,
		String __m, Object... __args)
		throws NullPointerException
	{
		if (__t == null || __m == null)
			throw new NullPointerException("NARG");
		
		// Force to exist
		if (__args == null)
			__args = new String[0];
		
		// Print specially formatted messages
		PrintStream out = this.out;
		
		// File
		if (__la instanceof FileName)
			out.print(((FileName)__la).fileName());
		
		// Use a fallback name if it is possible
		else
			out.print("<unknown>");
		
		// Use estimate line and column information if it was not specified
		int line = -1,
			column = -1;
		if (__la instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__la;
			
			line = lc.line();
			column = lc.column();
		}
		
		// Printing row?
		if (line >= 0)
		{
			out.print(':');
			out.print(line);
		}
		
		// Printing the column?
		if (column >= 0)
		{
			out.print(',');
			out.print(column);
		}
		
		// Print spacer and the message type
		out.print(": [");
		out.print(__t);
		out.print("] ");
		
		// Print the message itself
		out.println(String.format(__m, __args));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerOptions.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






























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This class is used to specify the options which are used for compilation
 * such as those which would be passed via the command line.
 *
 * This class is immutable.
 *
 * @since 2017/11/28
 */
public final class CompilerOptions
{
	/** Enable debugging output? */
	protected final boolean debug;
	
	/** The version of the Java language to target. */
	protected final CompilerJavaVersion version;
	
	/**
	 * Initializes the compiler with the default set of options.
	 *
	 * @since 2017/11/29
	 */
	public CompilerOptions()
	{
		this.debug = true;
		this.version = CompilerJavaVersion.JAVA_7;
	}
	
	/**
	 * Generate extra debugging information?
	 *
	 * @return If extra debugging information is to be provided.
	 * @since 2017/11/29
	 */
	public final boolean debug()
	{
		return this.debug;
	}
	
	/**
	 * Returns the Java language version to target.
	 *
	 * @return The target language.
	 * @since 2017/11/29
	 */
	public final CompilerJavaVersion version()
	{
		return this.version;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerOutput.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This interface is used to allow classes utilizing the compiler to place
 * output files in a target JAR potentially. It is possible for multiple
 * outputs to be open at the same time, as such cases should be handled where
 * they must sequentially be output.
 *
 * All instances of this class must be thread safe.
 *
 * @since 2017/11/28
 */
public interface CompilerOutput
{
	/**
	 * Flushes the output.
	 *
	 * @throws CompilerException If there was an error flushing.
	 * @since 2017/11/28
	 */
	public abstract void flush()
		throws CompilerException;
	
	/**
	 * This is called when a file has been or is being compiled and it is
	 * required to output the file.
	 *
	 * @param __n The name of the file being written, this should match the
	 * same format that is used in ZIP files.
	 * @return An output stream which writes bytes to the output.
	 * @throws CompilerException If the output could not be created.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/18
	 */
	public abstract OutputStream output(String __n)
		throws CompilerException, NullPointerException;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerPathSet.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.Closeable;

/**
 * A path set represents the contents of a binary JAR file or a tree of
 * source code within a directory.
 *
 * Entries are named according to how they would appear in ZIP files with
 * no distinction of directories being made (so a file would be called for
 * example {@code META-INF/MANIFEST.MF} regardless of the host system).
 *
 * Iteration goes over the contents of the path set.
 *
 * All instances of this class must be thread safe.
 *
 * @since 2017/11/28
 */
public interface CompilerPathSet
	extends Closeable, Iterable<CompilerInput>
{
	/**
	 * {@inheritDoc}
	 * @throws CompilerException If closing the path set has failed.
	 * @since 2017/11/28
	 */
	@Override
	public abstract void close()
		throws CompilerException;
	
	/**
	 * Obtians the specified 
	 *
	 * @param __n The name of the file to open.
	 * @return The input for the given file.
	 * @throws CompilerException If some other error happened while trying to
	 * obtain the input.
	 * @throws NoSuchInputException If the input by the specified name does
	 * not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public abstract CompilerInput input(String __n)
		throws CompilerException, NoSuchInputException, NullPointerException;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/CompilerService.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This is used with {@link java.util.ServiceLoader} and is used to create
 * instances of the Java compiler when needed. This allows multiple compilers
 * to exist at the same time.
 *
 * Creation of the compiler should instead be done by
 * {@link DefaultCompiler#createInstance()}.
 *
 * @see DefaultCompiler
 * @since 2017/11/28
 */
public interface CompilerService
{
	/**
	 * Returns a new instance of the compiler.
	 *
	 * @return A new instance of the compiler, this may return {@code null} if
	 * a compiler cannot be provided.
	 * @since 2017/11/28
	 */
	public abstract Compiler createInstance();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/DefaultCompiler.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
66
67
68
69
70
71
72
73









































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.util.ServiceLoader;
import net.multiphasicapps.javac.cute.CuteCompiler;
import net.multiphasicapps.javac.cute.CuteCompilerService;

/**
 * This creates an instance of a compiler and should be the class which is
 * used to initializes the compiler. If no compiler services are provided then
 * the default internal compiler will be used instead.
 *
 * @since 2017/11/28
 */
public final class DefaultCompiler
{
	/**
	 * {@squirreljme.property net.multiphasicapps.javac.forcedefault=(boolean)
	 * If this is set to {@code true} then the default built-in compiler will
	 * be used.}
	 */
	private static final String _FORCE_DEFAULT_PROPERTY =
		"net.multiphasicapps.javac.forcedefault";
	
	/**
	 * Not used.
	 *
	 * @since 2017/11/28
	 */
	private DefaultCompiler()
	{
	}
	
	/**
	 * Creates a new instance of a compiler.
	 *
	 * @return The new compiler instance.
	 * @since 2017/11/28
	 */
	public static final Compiler createInstance()
	{
		// Create compiler instance
		return DefaultCompiler.getService().createInstance();
	}
	
	/**
	 * Returns the default compiler service, if any.
	 *
	 * @return The default compiler service.
	 * @since 2019/06/30
	 */
	public static final CompilerService getService()
	{
		// Go through services if it is not forced to default
		if (!Boolean.getBoolean(_FORCE_DEFAULT_PROPERTY))
			for (CompilerService cs : ServiceLoader.<CompilerService>load(
				CompilerService.class))
			return cs;
		
		// No services, use the built-in compiler
		return new CuteCompilerService();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/DefaultDocumentation.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac;

/**
 * This creates an instance of the default documentation service.
 *
 * @since 2019/06/30
 */
public class DefaultDocumentation
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/DistinctPathSet.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.util.Arrays;
import java.util.Iterator;

/**
 * This is a path set which uses distinct compiler inputs to provide input
 * for the compiler.
 *
 * @since 2018/03/06
 */
public final class DistinctPathSet
	implements CompilerPathSet
{
	/** The inputs. */
	private final CompilerInput[] _input;
	
	/**
	 * Initializes the distinct path set.
	 *
	 * @param __in The inputs to use for the path set.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public DistinctPathSet(CompilerInput... __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Ensure there are no null values
		__in = __in.clone();
		for (CompilerInput ci : __in)
			if (ci == null)
				throw new NullPointerException("NARG");
		
		this._input = __in;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final void close()
		throws CompilerException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final Iterator<CompilerInput> iterator()
		throws CompilerException
	{
		return Arrays.<CompilerInput>asList(this._input).iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final CompilerInput input(String __n)
		throws CompilerException, NoSuchInputException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		for (CompilerInput ci : this._input)
			if (__n.equals(ci.fileName()))
				return ci;
		
		// {@squirreljme.error AQ02 Could not find the specified input in the
		// distinct path set. (The input)}
		throw new NoSuchInputException(String.format("AQ02 %s", __n));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/DocumentationService.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac;

/**
 * This interface represents a documentation service.
 *
 * @since 2019/06/30
 */
public interface DocumentationService
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/EmptyPathSet.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
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





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import net.multiphasicapps.collections.EmptyIterator;

/**
 * This is the empty path set and is used to provide no actual files, it is
 * the default path set used for input.
 *
 * @since 2017/11/28
 */
public final class EmptyPathSet
	implements CompilerPathSet
{
	/** The cache for the path set. */
	private static Reference<EmptyPathSet> _SET;
	
	/**
	 * Not publically created.
	 *
	 * @since 2017/11/28
	 */
	private EmptyPathSet()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public CompilerInput input(String __n)
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.erorr AQ06 Cannot obtain the specified file from
		// the empty path set. (The name of the file)}
		throw new NoSuchInputException(String.format("AQ06 %s", __n));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public Iterator<CompilerInput> iterator()
	{
		return EmptyIterator.<CompilerInput>empty();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public String toString()
	{
		return "EmptyPathSet";
	}
	
	/**
	 * Returns the same instance of the empty path set.
	 *
	 * @return The same instance of the empty path set.
	 * @since 2017/11/28
	 */
	public static final EmptyPathSet instance()
	{
		Reference<EmptyPathSet> ref = EmptyPathSet._SET;
		EmptyPathSet rv;
		
		if (ref == null || null == (rv = ref.get()))
			EmptyPathSet._SET = new WeakReference<>((rv = new EmptyPathSet()));
		
		return rv;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/FileInput.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
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









































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.attribute.FileTime;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

/**
 * This is input which uses a given file as input.
 *
 * @since 2017/11/28
 */
public final class FileInput
	implements CompilerInput
{
	/** The path to the file. */
	protected final Path path;
	
	/** The name of the file. */
	protected final String name;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the file input.
	 *
	 * @param __p The path to the file.
	 * @param __n The name of the file.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public FileInput(Path __p, String __n)
		throws NullPointerException
	{
		if (__p == null || __n == null)
			throw new NullPointerException("NARG");
		
		this.path = __p;
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof FileInput))
			return false;
		
		FileInput o = (FileInput)__o;
		return this.path.equals(o.path) &&
			this.name.equals(o.name);
	}

	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public final String fileName()
		throws CompilerException
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public final int hashCode()
	{
		return this.path.hashCode() ^
			this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final long lastModifiedTime()
		throws CompilerException
	{
		// Read the file time
		try
		{
			FileTime ft = Files.getLastModifiedTime(this.path);
			if (ft != null)
				return ft.toMillis();
			else
				return Long.MIN_VALUE;
		}
		
		// {@squirreljme.error AQ03 Could not obtain the last modified time.}
		catch (IOException e)
		{
			throw new CompilerException("AQ03", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public final InputStream open()
		throws CompilerException, NoSuchInputException
	{
		Path path = this.path;
		try
		{
			return Files.newInputStream(path, StandardOpenOption.READ);
		}
		
		// {@squirreljme.error AQ04 The specified path does not exist.
		// (The path to the file)}
		catch (NoSuchFileException e)
		{
			throw new NoSuchInputException(String.format("AQ04 %s", path), e);
		}
		
		// {@squirreljme.error AQ05 Could not read from the specified path.
		// (The path to the file)}
		catch (IOException e)
		{
			throw new NoSuchInputException(String.format("AQ05 %s", path), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("%s(%s)",
				this.name, this.path)));
		
		return rv;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/FileName.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This interface represents something which represents the name of a file.
 *
 * @since 2018/03/12
 */
public interface FileName
	extends LocationAware
{
	/**
	 * Returns the file that is input represents or the file being processed.
	 *
	 * @return The file being process or {@code null} if it is not known.
	 * @since 2018/03/12
	 */
	public abstract String fileName();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/FileNameLineAndColumn.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This extends the line and column information and additionally provides
 * file information on top, if it is valid.
 *
 * @since 2018/03/12
 */
public interface FileNameLineAndColumn
	extends FileName, LineAndColumn, LocationAware
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/FilePathSet.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
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
191
192
193
194
195
196
197
198
199
200
201









































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;

/**
 * This is a path set which is used to access files on the file system.
 *
 * @since 2017/11/28
 */
public final class FilePathSet
	implements CompilerPathSet
{
	/** The root directory of the path set. */
	protected final Path root;
	
	/**
	 * Initializes the path set over the given directory.
	 *
	 * @return __root The root directory
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public FilePathSet(Path __root)
		throws NullPointerException
	{
		if (__root == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.root = __root;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
		throws CompilerException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public CompilerInput input(String __n)
		throws CompilerException, NoSuchInputException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Store original name for the exception
		String origname = __n;
		
		// Resolve path elements
		Path path = this.root;
		while (!__n.isEmpty())
		{
			// Get name sub-fragment
			int sl = __n.indexOf('/');
			if (sl < 0)
				sl = __n.length();
			
			// Resolve it
			path = path.resolve(Paths.get(__n.substring(0, sl)));
			
			// Split down
			sl++;
			if (sl < __n.length())
				__n = __n.substring(sl);
			else
				break;
		}
		
		// {@squirreljme.error AQ06 The specified input does not exist in
		// the path set filesystem. (The name; The expected path)}
		if (Files.exists(path) && !Files.isDirectory(path))
			return new FileInput(path, origname);
		throw new NoSuchInputException(String.format("AQ06 %s %s", origname,
			path));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public Iterator<CompilerInput> iterator()
		throws CompilerException
	{
		// First iterate through every sub-directory and build a set of paths
		// from the root
		Deque<Path> queue = new ArrayDeque<>();
		queue.add(this.root);
		
		// Return value will be an array
		List<CompilerInput> rv = new ArrayList<>();
		
		// Process every directory
		while (!queue.isEmpty())
			try (DirectoryStream<Path> ds = Files.newDirectoryStream(
				queue.removeFirst()))
			{
				for (Path p : ds)
				{
					// Handle directories later
					if (Files.isDirectory(p))
					{
						queue.addLast(p);
						continue;
					}
					
					// Add files to input
					rv.add(new FileInput(p,
						FilePathSet.__pathToName(root, p)));
				}
			}
			
			// {@squirreljme.error AQ07 Could not list directory contents.}
			catch (IOException e)
			{
				throw new CompilerException("AQ07", e);
			}
		
		// Return iterator over entries
		return Arrays.<CompilerInput>asList(rv.<CompilerInput>toArray(
			new CompilerInput[rv.size()])).iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public String toString()
	{
		return this.root.toString();
	}
	
	/**
	 * Converts a path found from the walk to a string used for package
	 * contents.
	 *
	 * @param __root Root directory.
	 * @param __sub Sub-path based on the root.
	 * @return The normalized name used for the contents key.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/01/29
	 */
	private static String __pathToName(Path __root, Path __sub)
		throws NullPointerException
	{
		// Check
		if (__root == null || __sub == null)
			throw new NullPointerException("NARG");
		
		// Calculate base
		Path base = __root.relativize(__sub);
		
		// Build it
		StringBuilder sb = new StringBuilder();
		for (Path comp : base)
		{
			// Directory slash
			if (sb.length() > 0)
				sb.append('/');
			
			// Add component
			sb.append(comp.toString());
		}
		
		// Translate it
		return sb.toString();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/LineAndColumn.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This interface specifies that the class provides row and column information
 * which can be used to locate errors and warnings in code.
 *
 * @since 2018/03/06
 */
public interface LineAndColumn
	extends LocationAware
{
	/**
	 * Returns the current column.
	 *
	 * @return The current column.
	 * @since 2018/03/06
	 */
	public abstract int column();
	
	/**
	 * Returns the current line.
	 *
	 * @return The current line.
	 * @since 2018/03/06
	 */
	public abstract int line();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/LocationAware.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This is a base interface which specifies that a given class may implement
 * the file name and/or line and column location information. This is used to
 * reduce the constructor count for some classes.
 *
 * @since 2018/03/12
 */
public interface LocationAware
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/MergedPathSet.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This is a path set which allows multiple path sets to be merged into one
 * so that the later ones replace the earlier ones.
 *
 * @since 2018/03/06
 */
public final class MergedPathSet
	implements CompilerPathSet 
{
	/** The input sets. */
	private final CompilerPathSet[] _sets;
	
	/**
	 * Initializes the merged path set.
	 *
	 * @param __sets The sets to merge together.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public MergedPathSet(CompilerPathSet... __sets)
		throws NullPointerException
	{
		if (__sets == null)
			throw new NullPointerException("NARG");
		
		// Ensure there are no null values
		__sets = __sets.clone();
		for (CompilerPathSet cps : __sets)
			if (cps == null)
				throw new NullPointerException("NARG");
		
		this._sets = __sets;
	}
	
	/**
	 * Initializes a merged path set from an iterable sequence.
	 *
	 * @param __sets The sets to merge together.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/17
	 */
	public MergedPathSet(Iterable<CompilerPathSet> __sets)
		throws NullPointerException
	{
		if (__sets == null)
			throw new NullPointerException("NARG");
		
		// Ensure non-null and store into list for later usage
		List<CompilerPathSet> rv = new ArrayList<>();
		for (CompilerPathSet s : __sets)
			if (s == null)
				throw new NullPointerException("NARG");
			else
				rv.add(s);
		
		this._sets = rv.<CompilerPathSet>toArray(
			new CompilerPathSet[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final void close()
		throws CompilerException
	{
		CompilerException tossed = null;
		for (CompilerPathSet cps : this._sets)
			try
			{
				cps.close();
			}
			catch (CompilerException e)
			{
				// {@squirreljme.error AQ08 Could not close the merged path
				// set.}
				if (tossed == null)
					tossed = new CompilerException("AQ08");
				
				tossed.addSuppressed(tossed);
			}
		
		if (tossed != null)
			throw tossed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final Iterator<CompilerInput> iterator()
		throws CompilerException
	{
		// Use a map since the compiler input might not refer to the same
		// file even if the same name is used
		Map<String, CompilerInput> rv = new LinkedHashMap<>();
		
		// The latest version of an input is returned in the iterator for
		// a given name
		for (CompilerPathSet cps : this._sets)
			for (CompilerInput in : cps)
				rv.put(in.fileName(), in);
		
		// Return view of the map
		Collection<CompilerInput> values = rv.values();
		return Arrays.<CompilerInput>asList(
			values.<CompilerInput>toArray(new CompilerInput[values.size()])).
			iterator();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final CompilerInput input(String __n)
		throws CompilerException, NoSuchInputException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Go through the final sets first because those replace the earlier
		// ones
		CompilerPathSet[] sets = this._sets;
		for (int i = sets.length - 1; i >= 0; i--)
			try
			{
				return sets[i].input(__n);
			}
			catch (NoSuchInputException e)
			{
			}
		
		// {@squirreljme.error AQ09 Could not find the specified input in the
		// merged path set. (The input)}
		throw new NoSuchInputException(String.format("AQ09 %s", __n));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/MessageType.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This indicates the message to display.
 *
 * @since 2018/03/06
 */
public enum MessageType
{
	/** Information. */
	INFO,
	
	/** Warning. */
	WARNING,
	
	/** Error. */
	ERROR,
	
	/** Lint to detect for possible errors. */
	LINT,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/NoSuchInputException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This is thrown when the specified input file does not exists.
 *
 * @since 2017/11/28
 */
public class NoSuchInputException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/11/28
	 */
	public NoSuchInputException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/11/28
	 */
	public NoSuchInputException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/11/28
	 */
	public NoSuchInputException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/11/28
	 */
	public NoSuchInputException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/NullCompilerOutput.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac;

import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.io.NullOutputStream;

/**
 * This is a compiler output which writes to nowhere.
 *
 * @since 2019/06/30
 */
public final class NullCompilerOutput
	implements CompilerOutput
{
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void flush()
		throws CompilerException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final OutputStream output(String __n)
		throws CompilerException, NullPointerException
	{
		return new NullOutputStream();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ResourceCompilerInput.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
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
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is a resource input which uses a class name.
 *
 * @since 2019/06/30
 */
public final class ResourceCompilerInput
	implements CompilerInput
{
	/** The pivot to use. */
	protected final Class<?> pivot;
	
	/** The resource name used. */
	protected final String rcname;
	
	/** The file name used. */
	protected final String filename;
	
	/**
	 * Initializes the resource input.
	 *
	 * @param __pivot The class pivot used.
	 * @param __rc The resource name.
	 * @param __fn The file name.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public ResourceCompilerInput(Class<?> __pivot, String __rc, String __fn)
		throws NullPointerException
	{
		if (__pivot == null || __rc == null || __fn == null)
			throw new NullPointerException("NARG");
		
		this.pivot = __pivot;
		this.rcname = __rc;
		this.filename = __fn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ResourceCompilerInput))
			return false;
		
		ResourceCompilerInput o = (ResourceCompilerInput)__o;
		return this.pivot.equals(o.pivot) &&
			this.rcname.equals(o.rcname) &&
			this.filename.equals(o.filename);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final int hashCode()
	{
		return this.pivot.hashCode() ^
			this.rcname.hashCode() ^
			this.filename.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final long lastModifiedTime()
		throws CompilerException
	{
		return Long.MIN_VALUE;
	}

	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final String fileName()
		throws CompilerException
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final InputStream open()
		throws CompilerException, NoSuchInputException
	{
		// {@squirreljme.error AQ39 No resource input exists. (The filename)}
		InputStream rv = this.pivot.getResourceAsStream(this.rcname);
		if (rv == null)
			throw new NoSuchInputException("AQ39 " + this.filename);
		return rv;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ResourcePathSet.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
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




















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.EmptyIterator;
import net.multiphasicapps.collections.UnmodifiableIterator;

/**
 * This is a path set which uses the class resource area as input.
 *
 * @since 2019/06/30
 */
public class ResourcePathSet
	implements CompilerPathSet
{
	/** The pivot class to lookup resources from. */
	protected final Class<?> pivot;
	
	/** The prefix to use for lookup. */
	protected final String prefix;
	
	/**
	 * Initializes the resource path set.
	 *
	 * @param __cl The class to load resources from.
	 * @param __prefix The resource prefix.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public ResourcePathSet(Class<?> __cl, String __prefix)
		throws NullPointerException
	{
		if (__cl == null || __prefix == null)
			throw new NullPointerException("NARG");
		
		this.pivot = __cl;
		this.prefix = __prefix;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final void close()
		throws CompilerException
	{
		// Does nothing
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final Iterator<CompilerInput> iterator()
	{
		// Try to read the list file
		try (InputStream in = pivot.getResourceAsStream(this.prefix + "list"))
		{
			// If there is none, then just return no files
			if (in == null)
				return EmptyIterator.<CompilerInput>empty();
			
			// Read in lines
			List<CompilerInput> inputs = new ArrayList<>();
			try (BufferedReader br = new BufferedReader(
				new InputStreamReader(in)))
			{
				// Read in
				for (;;)
				{
					String ln = br.readLine();
					
					if (ln == null)
						break;
					
					// Try to see if this even exists
					try
					{
						inputs.add(this.input(ln));
					}
					
					// It does not, so ignore
					catch (NoSuchInputException e)
					{
					}
				}
			}
			
			// Return input list
			return UnmodifiableIterator.<CompilerInput>of(
				inputs.<CompilerInput>toArray(
					new CompilerInput[inputs.size()]));
		}
		
		// {@squirreljme.error AQ3b Could not read list file.}
		catch (IOException e)
		{
			throw new CompilerException("AQ3b", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final CompilerInput input(String __n)
		throws CompilerException, NoSuchInputException, NullPointerException
	{
		// Build full resource name
		Class<?> pivot = this.pivot;
		String rcname = this.prefix + __n;
		
		// Only return if it exists
		try (InputStream in = pivot.getResourceAsStream(rcname))
		{
			// {@squirreljme.error AQ38 No input resource exists. (The name)}
			if (in == null)
				throw new NoSuchInputException("AQ38 " + __n);
			
			// Build it
			return new ResourceCompilerInput(pivot, rcname, __n);
		}
		
		// {@squirreljme.error AQ3a Exception closing class resource.}
		catch (IOException e)
		{
			throw new CompilerException("AQ3a", e);
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/SimpleFileNameLineAndColumn.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234










































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This contains a simple representation of the file, line, and column
 * information.
 *
 * This class is immutable.
 *
 * @since 2018/03/12
 */
public final class SimpleFileNameLineAndColumn
	implements FileNameLineAndColumn
{
	/** The file name. */
	protected final String filename;
	
	/** The line. */
	protected final int line;
	
	/** The column. */
	protected final int column;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes this class with unknown information.
	 *
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn()
	{
		this.filename = null;
		this.line = -1;
		this.column = -1;
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __fn The file name.
	 * @param __lc The line and column information.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(String __fn, LineAndColumn __lc)
	{
		this.filename = __fn;
		this.line = (__lc == null ? -1 : __lc.line());
		this.column = (__lc == null ? -1 : __lc.column());
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __fn The file name.
	 * @param __lc The line and column information.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(FileName __fn, LineAndColumn __lc)
	{
		this.filename = (__fn == null ? null : __fn.fileName());
		this.line = (__lc == null ? -1 : __lc.line());
		this.column = (__lc == null ? -1 : __lc.column());
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __fn The file name.
	 * @param __lin The line.
	 * @param __col The column.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(String __fn, int __lin, int __col)
	{
		this.filename = __fn;
		this.line = __lin;
		this.column = __col;
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __fn The file name.
	 * @param __lin The line.
	 * @param __col The column.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(FileName __fn, int __lin, int __col)
	{
		this.filename = (__fn == null ? null : __fn.fileName());
		this.line = __lin;
		this.column = __col;
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __fn The file name.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(FileName __fn)
	{
		this.filename = (__fn == null ? null : __fn.fileName());
		
		if (__fn instanceof LineAndColumn)
		{
			LineAndColumn lc = (LineAndColumn)__fn;
			this.line = lc.line();
			this.column = lc.column();
		}
		else
		{
			this.line = -1;
			this.column = -1;
		}
	}
	
	/**
	 * Initializes with all of the given information.
	 *
	 * @param __flc The file name, line, and column information.
	 * @since 2018/03/12
	 */
	public SimpleFileNameLineAndColumn(FileNameLineAndColumn __flc)
	{
		if (__flc == null)
		{
			this.filename = null;
			this.line = -1;
			this.column = -1;
		}
		else
		{
			this.filename = __flc.fileName();
			this.line = __flc.line();
			this.column = __flc.column();
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final int column()
	{
		return this.column;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof SimpleFileNameLineAndColumn))
			return false;
		
		SimpleFileNameLineAndColumn o = (SimpleFileNameLineAndColumn)__o;
		return Objects.equals(this.filename, o.filename) &&
			this.line == o.line &&
			this.column == o.column;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final String fileName()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final int hashCode()
	{
		return Objects.hashCode(this.filename) ^
			this.line ^
			(this.column << 16);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final int line()
	{
		return this.line;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				String.format("%s:%d,%d", this.filename, this.line,
					this.column)));
		
		return rv;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/StringFileName.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

/**
 * This represents a file name that represents a string, it is used for
 * location awareness.
 *
 * @since 2018/05/05
 */
public final class StringFileName
	implements FileName
{
	/** The file name that is used. */
	protected final String filename;
	
	/**
	 * Initializes the string file name.
	 *
	 * @param __fn The filename to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/05
	 */
	public StringFileName(String __fn)
		throws NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		this.filename = __fn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final int hashCode()
	{
		return this.filename.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final String fileName()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final String toString()
	{
		return this.filename;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ZipCompilerOutput.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290


































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.zip.streamwriter.ZipStreamWriter;
import net.multiphasicapps.zip.ZipCompressionType;

/**
 * This is used to wrap output to a ZIP file.
 *
 * @since 2017/11/28
 */
public final class ZipCompilerOutput
	implements Closeable, CompilerOutput
{
	/** Lock. */
	protected final Object lock =
		new Object();
	
	/** The output ZIP. */
	protected final ZipStreamWriter zip;
	
	/** Outputs which are currently being written to (not closed). */
	private final Map<String, __Stream__> _waiting =
		new LinkedHashMap<>();
	
	/** Output streams which have been closed, to be written to the ZIP. */
	private final Map<String, __Stream__> _done =
		new LinkedHashMap<>();
	
	/**
	 * Initializes the output which writes to the given output stream which
	 * is wrapped by a ZIP.
	 *
	 * @param __out The output stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/12/24
	 */
	public ZipCompilerOutput(OutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.zip = new ZipStreamWriter(__out);
	}
	
	/**
	 * Initialize the output which writes to the given ZIP file.
	 *
	 * @param __out The output ZIP to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public ZipCompilerOutput(ZipStreamWriter __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.zip = __out;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
		throws IOException
	{
		// Flush self so the contents are written
		this.flush();
		
		// Flush and close the ZIP
		ZipStreamWriter zip = this.zip;
		zip.flush();
		zip.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void flush()
		throws CompilerException
	{
		// Lock
		synchronized (this.lock)
		{
			// Nothing to be done?
			Map<String, __Stream__> done = this._done;
			if (done.isEmpty())
				return;
			
			// Go through all the done files
			Iterator<Map.Entry<String, __Stream__>> it = done.entrySet().
				iterator();
			ZipStreamWriter zip = this.zip;
			while (it.hasNext())
			{
				// Get the details
				Map.Entry<String, __Stream__> e = it.next();
				String k = e.getKey();
				__Stream__ v = e.getValue();
				
				// Never write it again
				it.remove();
				
				// Write to the output
				try (OutputStream os = zip.nextEntry(k))
				{
					v.wrapped.writeTo(os);
				}
				
				// {@squirreljme.error AQ0a Failed to write the specified file
				// to the output stream. (The file name)}
				catch (RuntimeException|IOException f)
				{
					throw new CompilerException(
						String.format("AQ0a %s", k), f);
				}
			}
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public OutputStream output(String __n)
		throws CompilerException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Lock
		synchronized (this.lock)
		{
			// Setup new stream
			__Stream__ rv = new __Stream__(__n);
			
			// Store into the files being written
			Map<String, __Stream__> waiting = this._waiting;
			waiting.put(__n, rv);
			
			// Return it
			return rv;
		}
	}
	
	/**
	 * Wrapped streams for potential flushing.
	 *
	 * @since 2016/09/20
	 */
	private final class __Stream__
		extends OutputStream
	{
		/** The wrapped stream to write to. */
		protected final ByteArrayOutputStream wrapped =
			new ByteArrayOutputStream();
		
		/** The name of this file. */
		protected final String name;
		
		/** Has this been closed? */
		private volatile boolean _closed;
		
		/**
		 * Initializes the stream.
		 *
		 * @param __n The name of this file.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/09/20
		 */
		private __Stream__(String __n)
			throws NullPointerException
		{
			// Check
			if (__n == null)
				throw new NullPointerException("NARG");
			
			// Set
			this.name = __n;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/09/20
		 */
		@Override
		public void close()
			throws IOException
		{
			// Need to lock on the compiler output to prevent race conditions
			// where a file is closed multiple times and placed into the done
			// queue multiple times
			ZipCompilerOutput ccout = ZipCompilerOutput.this;
			synchronized (ccout.lock)
			{
				// Ignore if closed
				if (this._closed)
					return;
			
				// Mark closed
				this._closed = true;
				
				// Get both queues
				Map<String, __Stream__> waiting = ccout._waiting;
				Map<String, __Stream__> done = ccout._done;
				
				// Remove from the waiting queue
				String name = this.name;
				waiting.remove(name);
				
				// And add to the done queue
				done.put(name, this);
				
				// Flush the compiler output early to write as many files as
				// possible so they do not crowd memory
				ccout.flush();
			}
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/09/20
		 */
		@Override
		public void flush()
			throws IOException
		{
			// Flushing a byte array output is pointless
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/09/20
		 */
		@Override
		public void write(int __b)
			throws IOException
		{
			// {@squirreljme.error AQ0b Cannot write a single byte after the
			// output has been closed.}
			if (this._closed)
				throw new IOException("AQ0b");
			
			// Forward
			this.wrapped.write(__b);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/09/20
		 */
		@Override
		public void write(byte[] __b, int __o, int __l)
			throws IOException
		{
			// {@squirreljme.error AQ0c Cannot write multiple bytes after the
			// output has been closed.}
			if (this._closed)
				throw new IOException("AQ0c");
			
			// Forward
			this.wrapped.write(__b, __o, __l);
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ZipInput.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;

/**
 * This wraps a single entry within a ZIP file.
 *
 * @since 2017/11/29
 */
public final class ZipInput
	implements CompilerInput
{
	/** The entry to wrap. */
	protected final ZipBlockEntry entry;
	
	/**
	 * Initializes the ZIP input.
	 *
	 * @param __e The entry to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public ZipInput(ZipBlockEntry __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		this.entry = __e;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof ZipInput))
			return false;
		
		return this.entry.equals(((ZipInput)__o).entry);
	}

	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final String fileName()
		throws CompilerException
	{
		return this.entry.name();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final int hashCode()
	{
		return this.fileName().hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final long lastModifiedTime()
		throws CompilerException
	{
		return this.entry.lastModifiedTime();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public final InputStream open()
		throws CompilerException, NoSuchInputException
	{
		try
		{
			return this.entry.open();
		}
		
		// {@squirreljme.error AQ0d Failed to open the ZIP entry. (The name
		// of the entry)}
		catch (IOException e)
		{
			throw new CompilerException(
				String.format("AQ0d %s", this.fileName()), e);
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ZipPathSet.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
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























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.blockreader.ZipEntryNotFoundException;

/**
 * This is a path set which may be used on top of a ZIP file.
 *
 * @since 2017/11/28
 */
public final class ZipPathSet
	implements CompilerPathSet
{
	/** The ZIP to use as input. */
	protected final ZipBlockReader zip;
	
	/**
	 * Initializes the path set over ZIP files.
	 *
	 * @return __zip The ZIP file to wrap and treat as a path set.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/28
	 */
	public ZipPathSet(ZipBlockReader __zip)
		throws IOException, NullPointerException
	{
		if (__zip == null)
			throw new NullPointerException("NARG");
		
		this.zip = __zip;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public void close()
	{
		// Close the target ZIP
		try
		{
			this.zip.close();
		}
		
		// {@squirreljme.error AQ0e Could not close the source ZIP.}
		catch (IOException e)
		{
			throw new CompilerException("AQ0e", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public CompilerInput input(String __n)
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		try
		{
			return new ZipInput(this.zip.get(__n));
		}
		
		// {@squirreljme.error AQ0f No such entry exists within the ZIP.
		// (The name of the entry)}
		catch (ZipEntryNotFoundException e)
		{
			throw new NoSuchInputException(String.format("AQ0f %s", __n), e);
		}
		
		// {@squirreljme.error AQ0g Read error attempting to open the input
		// entry. (The name of the entry)}
		catch (IOException e)
		{
			throw new NoSuchInputException(String.format("AQ0g %s", __n), e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public Iterator<CompilerInput> iterator()
	{
		return new ZipPathSetIterator(this.zip.iterator());
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/28
	 */
	@Override
	public String toString()
	{
		return this.zip.toString();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/ZipPathSetIterator.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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac;

import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;

/**
 * This iterates over entries in the ZIP and provides input for those entries.
 *
 * @since 2017/11/29
 */
public final class ZipPathSetIterator
	implements Iterator<CompilerInput>
{
	/** The used iterator. */
	protected final Iterator<ZipBlockEntry> iterator;
	
	/**
	 * Initializes the iterator.
	 *
	 * @param __i The entry iterator to iterate over.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public ZipPathSetIterator(Iterator<ZipBlockEntry> __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.iterator = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public boolean hasNext()
	{
		return this.iterator.hasNext();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public CompilerInput next()
	{
		// Go through entries
		for (Iterator<ZipBlockEntry> iterator = this.iterator;;)
		{
			// Ignore directories
			ZipBlockEntry ze = iterator.next();
			try
			{
				if (ze.isDirectory())
					continue;
			}
			catch (IOException e)
			{
				// {@squirreljme.error AQ3c Could not check if entry was
				// a directory or not.}
				throw new CompilerException("AQ3c", e);
			}
			
			return new ZipInput(ze);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	public void remove()
	{
		throw new UnsupportedOperationException("RORO");
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/BinaryUnit.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.classtree;

import net.multiphasicapps.javac.CompilerInput;

/**
 * This represents a unit which is a binary class file.
 *
 * @since 2019/01/17
 */
public final class BinaryUnit
	extends Unit
{
	/** The input unit. */
	protected final CompilerInput input;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __i The input unit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/17
	 */
	public BinaryUnit(CompilerInput __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.input = __i;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/Package.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84




















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.classtree;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This class describes a package which contains a bunch of classes that exist
 * within the package.
 *
 * @since 2019/01/17
 */
public final class Package
{
	/** The name of the package. */
	protected final String name;
	
	/** Units which are in this package. */
	private final Map<String, Unit> _units;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the package with all of the contained units.
	 *
	 * @param __n The name of this package.
	 * @param __m The package and maps.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/18
	 */
	public Package(String __n, Map<String, Unit> __m)
		throws NullPointerException
	{
		if (__n == null || __m == null)
			throw new NullPointerException("NARG");
		
		// Copy values
		Map<String, Unit> units = new SortedTreeMap<>();
		for (Map.Entry<String, Unit> e : __m.entrySet())
		{
			String k = e.getKey();
			Unit v = e.getValue();
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			units.put(k, v);
		}
		
		this.name = __n;
		this._units = units;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/19
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this._units.toString()));
		
		return rv;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/Packages.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
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






















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.classtree;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerPathSet;

/**
 * This is the root of the class hierachy which contains all of the various
 * packages with classes in them.
 *
 * @since 2019/01/17
 */
public final class Packages
{
	/** The mapping of available packages. */
	private final Map<String, Package> _packages;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the package tree.
	 *
	 * @param __m The input map.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/18
	 */
	public Packages(Map<String, Map<String, Unit>> __m)
		throws NullPointerException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Translate everything
		Map<String, Package> packages = new SortedTreeMap<>();
		for (Map.Entry<String, Map<String, Unit>> e : __m.entrySet())
		{
			// Make sure there are no nulls
			String k = e.getKey();
			Map<String, Unit> v = e.getValue();
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			packages.put(k, new Package(k, v));
		}
		
		this._packages = packages;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/19
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				(rv = this._packages.toString()));
		
		return rv;
	}
	
	/**
	 * Loads packages from the input path sets, from classes and sources and
	 * performing resolution of them.
	 *
	 * @param __css The path sets to iterate through and load packages from.
	 * @return The packages and all of the defined classes within the entire
	 * sets of input.
	 * @throws CompilerException If an input could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/17
	 */
	public static final Packages loadPackages(CompilerPathSet... __css)
		throws CompilerException, NullPointerException
	{
		return Packages.loadPackages(Arrays.<CompilerPathSet>asList(__css));
	}
	
	/**
	 * Loads packages from the input path sets, from classes and sources and
	 * performing resolution of them.
	 *
	 * @param __its The path sets to iterate through and load packages from.
	 * @return The packages and all of the defined classes within the entire
	 * sets of input.
	 * @throws CompilerException If an input could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/17
	 */
	public static final Packages loadPackages(
		Iterable<CompilerPathSet>... __its)
		throws CompilerException, NullPointerException
	{
		if (__its == null)
			throw new NullPointerException("NARG");
		
		// Packages and classes in each package
		Map<String, Map<String, Unit>> rv = new HashMap<>();
		
		// Iterate through everything and load accordingly
		for (Iterable<CompilerPathSet> it : __its)
			for (CompilerPathSet s : it)
				for (CompilerInput i : s)
				{
					String fn = i.fileName();
					
					// Extract directory (package) and the base name
					String dirname, basename, ident;
					int ls = fn.lastIndexOf('/');
					if (ls >= 0)
					{
						dirname = fn.substring(0, ls);
						basename = fn.substring(ls + 1);
					}
					else
					{
						dirname = "";
						basename = fn;
					}
					
					// Is source file?
					boolean issource;
					
					// Ignore anything with slashes in it, since those are not
					// valid Java files
					if (fn.indexOf('-') >= 0)
						continue;
					
					// Source code file to parse
					else if (fn.endsWith(".java"))
					{
						issource = true;
						ident = basename.substring(0, basename.length() - 5);
					}
					
					// Class file to parse
					else if (fn.endsWith(".class"))
					{
						issource = false;
						ident = basename.substring(0, basename.length() - 6);
					}
					
					// Unknown, ignore
					else
						continue;
					
					// Determine the package the piece belongs in
					Map<String, Unit> pkg = rv.get(dirname);
					if (pkg == null)
						rv.put(dirname, (pkg = new HashMap<>()));
					
					// Make a unit for the class
					pkg.put(ident, (issource ? new SourceUnit(i) :
						new BinaryUnit(i)));
				}
		
		return new Packages(rv);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/SourceUnit.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.classtree;

import net.multiphasicapps.javac.CompilerInput;

/**
 * This is a unit which represents a source file.
 *
 * @since 2019/01/17
 */
public final class SourceUnit
	extends Unit
{
	/** The input unit. */
	protected final CompilerInput input;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __i The input unit.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/17
	 */
	public SourceUnit(CompilerInput __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.input = __i;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/Unit.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.classtree;

/**
 * This is a base unit which is a source for the class tree structure.
 *
 * @since 2019/01/17
 */
public abstract class Unit
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/classtree/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the class tree which is used to structure classes in a package
 * to class hierarchy.
 *
 * @since 2019/01/17
 */

package net.multiphasicapps.javac.classtree;

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/ClassNode.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.javac.CompilerInput;

/**
 * This represents a class node which is represented by an input file.
 *
 * @since 2018/03/06
 */
@Deprecated
public abstract class ClassNode
{
	/** The file used for input. */
	protected final CompilerInput input;
	
	/** The class this node provides information for. */
	protected final ClassName name;
	
	/**
	 * Initializes the base node.
	 *
	 * @param __name The name of the node.
	 * @param __input The input which contains the node data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	ClassNode(ClassName __name, CompilerInput __input)
		throws NullPointerException
	{
		if (__name == null || __input == null)
			throw new NullPointerException("NARG");
		
		this.name = __name;
		this.input = __input;
	}
	
	/**
	 * Returns the compiler input used as the source for node.
	 *
	 * @return The compiler input used as the source.
	 * @since 2018/03/06
	 */
	public final CompilerInput compilerInput()
	{
		return this.input;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ClassNode))
			return false;
		
		return this.name.equals(((ClassNode)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Returns the name of the node.
	 *
	 * @return The node name.
	 * @since 2018/03/06
	 */
	public final ClassName name()
	{
		return this.name;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/CompilerState.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
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
191
192
193
194
195
196
197
198
199







































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerLogger;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.FileNameLineAndColumn;
import net.multiphasicapps.javac.LineAndColumn;
import net.multiphasicapps.javac.NoSuchInputException;

/**
 * This contains the current state of the compiler.
 *
 * @since 2018/03/06
 */
@Deprecated
public final class CompilerState
{
	/** Logging. */
	protected final CompilerLogger log;
	
	/** The class and source paths. */
	protected final Map<CompilerInputLocation, List<CompilerPathSet>> paths;
	
	/** Class nodes which have been loaded for structuring. */
	final Map<ClassName, ClassNode> _nodes =
		new SortedTreeMap<>();
	
	/** Class nodes which need to be compiled. */
	final Deque<SourcedClassNode> _tocompile =
		new ArrayDeque<>();
	
	/** Last processed input file. */
	volatile CompilerInput _lastinput;
	
	/**
	 * Initializes the compiler state.
	 *
	 * @param __log The logging output.
	 * @param __ps Path sets for the compiler, used to build the class
	 * structure before compilation is performed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public CompilerState(CompilerLogger __log,
		Map<CompilerInputLocation, List<CompilerPathSet>> __ps)
		throws NullPointerException
	{
		if (__log == null || __ps == null)
			throw new NullPointerException("NARG");
		
		this.log = __log;
		this.paths = __ps;
	}
	
	/**
	 * Returns the class node for the given class.
	 *
	 * @param __cn The class node to get.
	 * @return The class node
	 * @throws MissingClassNodeException If the class node does not exist.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public final ClassNode classNode(ClassName __cn)
		throws MissingClassNodeException, NullPointerException
	{
		if (__cn == null)
			throw new NullPointerException("NARG");
		
		// If a node has already been loaded then use it
		Map<ClassName, ClassNode> nodes = this._nodes;
		ClassNode rv = nodes.get(__cn);
		if (rv != null)
			return rv;
		
		// Primitive types and arrays are completely special and are
		// generated by the class code
		if (__cn.isPrimitive() || __cn.isArray())
			throw new todo.TODO();
		
		// Search the class path first before looking for sources to compile
		Map<CompilerInputLocation, List<CompilerPathSet>> paths = this.paths;
		String classfilename = __cn.binaryName() + ".class";
		for (CompilerPathSet ps : paths.get(CompilerInputLocation.CLASS))
			try
			{
				CompilerInput ci = ps.input(classfilename);
				
				throw new todo.TODO();
			}
			catch (NoSuchInputException e)
			{
			}
		
		// It is possible for inner classes to be referred to before the
		// outer class has been seen, so look in the base class instead and see
		// if that exists
		String sourcename = __cn.binaryName().toString(),
			baselookname = sourcename;
		int ls = sourcename.lastIndexOf('/'),
			ld = sourcename.lastIndexOf('$');
		if (ld >= 0 && ld > ls)
			baselookname = sourcename.substring(0, ld);
		
		// Go through source files instead and try to find a node to compile
		boolean badhit = false;
		for (int z = 0; z < 2; z++)
		{
			// The loop goes through things twice because someone could be
			// very evil and name a class a bunch of dollar signs despite not
			// being an actual inner class. To to prevent these evil classes
			// from being missed, go back around and try to find and load them
			// as their normal name
			String trylook = (z == 0 ? baselookname + ".java" :
				sourcename + ".java");
			for (CompilerPathSet ps : paths.get(CompilerInputLocation.SOURCE))
				try
				{
					// Always use the base name because the requested thing
					// could be an inner class and the outer class will need to
					// be loaded before it can properly be used
					CompilerInput ci = ps.input(trylook);
				
					// Load in node, it is automatically added by the
					// constructor
					SourcedClassNode.__loadNodes(ci, this);
				
					// If the source file pertains to the given name then it
					// will be returned here, otherwise it will fail for
					// cases where evil dollar signs are used or if a class
					// is in the wrong file.
					rv = nodes.get(__cn);
					if (rv != null)
						return rv;
					
					// This is used to detect where the wrong class is
					// declared in the wrong file.
					badhit = true;
				}
				catch (NoSuchInputException e)
				{
				}
		}
		
		// {@squirreljme.error AQ0h Could not locate the node for the given
		// class name, the source file where the class should have been located
		// did not actually contain the class. (The class name)}
		if (badhit)
			throw new MissingClassNodeException(
				String.format("AQ0h %s", __cn));
		
		// {@squirreljme.error AQ0i Could not locate the node for the given
		// class name. (The class name)}
		throw new MissingClassNodeException(String.format("AQ0i %s", __cn));
	}
	
	/**
	 * Returns the output for compilation logs.
	 *
	 * @return The compilation log output.
	 * @since 2018/03/12
	 */
	public final CompilerLogger log()
	{
		return this.log;
	}
	
	/**
	 * Returns the next class node to compile.
	 *
	 * @return The next node to compile or {@code null} if there are no
	 * nodes to currently compile.
	 * @since 2018/03/06
	 */
	public final SourcedClassNode nextCompile()
	{
		Deque<SourcedClassNode> tocompile = this._tocompile;
		return tocompile.pollFirst();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/CuteCompiler.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import java.io.PrintStream;
import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerOptions;
import net.multiphasicapps.javac.CompilerOutput;
import net.multiphasicapps.javac.CompilerPathSet;

/**
 * This is used to create instances of the cute compiler.
 *
 * @since 2017/11/28
 */
public class CuteCompiler
	extends Compiler
{
	/**
	 * {@inheritDoc}
	 * @since 2017/11/29
	 */
	@Override
	protected Runnable newCompilerRunnable(CompilerOutput __out,
		PrintStream __log, CompilerOptions __opt,
		CompilerPathSet[][] __paths, CompilerInput[] __input)
		throws CompilerException, NullPointerException
	{
		if (__out == null || __log == null || __opt == null ||
			__paths == null || __input == null)
			throw new NullPointerException("NARG");
		
		return new CuteRunnable(__out, __log, __opt, __paths, __input);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/CuteCompilerService.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.javac.cute;

import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerService;

/**
 * This creates instances of the cute compiler.
 *
 * @since 2019/06/30
 */
public final class CuteCompilerService
	implements CompilerService
{
	/**
	 * {@inheritDoc}
	 * @since 2019/06/30
	 */
	@Override
	public final Compiler createInstance()
	{
		return new CuteCompiler();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/CuteRunnable.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.collections.UnmodifiableList;
import net.multiphasicapps.collections.UnmodifiableMap;
import net.multiphasicapps.collections.UnmodifiableSet;
import net.multiphasicapps.javac.classtree.Packages;
import net.multiphasicapps.javac.Compiler;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerInputLocation;
import net.multiphasicapps.javac.CompilerLogger;
import net.multiphasicapps.javac.CompilerOptions;
import net.multiphasicapps.javac.CompilerOutput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.FileNameLineAndColumn;
import net.multiphasicapps.javac.LineAndColumn;
import net.multiphasicapps.javac.LocationAware;
import net.multiphasicapps.javac.MessageType;
import net.multiphasicapps.javac.structure.RuntimeInput;

/**
 * This is the runnable which performs the actual compilation tasks and
 * generates the output code accordingly as needed.
 *
 * @since 2018/03/06
 */
public class CuteRunnable
	implements Runnable
{
	/** Output for the compiler. */
	protected final CompilerOutput out;
	
	/** Logging for the compiler. */
	protected final CompilerLogger log;
	
	/** Options for the compiler. */
	protected final CompilerOptions options;
	
	/** Paths for the compiler. */
	protected final Map<CompilerInputLocation, List<CompilerPathSet>> paths;
	
	/** Input for the compiler. */
	protected final List<CompilerInput> input;
	
	/**
	 * Initializes the compiler.
	 *
	 * @param __out The output for generated classes.
	 * @param __log The output for console logs.
	 * @param __opt The options for the compiler.
	 * @param __paths Input paths for compiler input, implied source code and
	 * class files.
	 * @param __input The input files to compile.
	 * @throws CompilerException If the input or options are not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	public CuteRunnable(CompilerOutput __out,
		PrintStream __log, CompilerOptions __opt,
		CompilerPathSet[][] __paths, CompilerInput[] __input)
		throws CompilerException, NullPointerException
	{
		if (__out == null || __log == null || __opt == null ||
			__paths == null || __input == null)
			throw new NullPointerException("NARG");
		
		this.out = __out;
		this.log = new CompilerLogger(__log);
		this.options = __opt;
		
		// Copy paths
		Map<CompilerInputLocation, List<CompilerPathSet>> paths =
			new HashMap<>();
		for (CompilerInputLocation cil : CompilerInputLocation.values())
			paths.put(cil, UnmodifiableList.<CompilerPathSet>of(
				Arrays.<CompilerPathSet>asList(
				__paths[cil.ordinal()].clone())));
		this.paths = UnmodifiableMap.<CompilerInputLocation,
			List<CompilerPathSet>>of(paths);
		
		// Copy input
		this.input = UnmodifiableList.<CompilerInput>of(
			Arrays.<CompilerInput>asList(__input.clone()));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public void run()
		throws CompilerException
	{
		CompilerLogger log = this.log;
		
		// Load packages and the classes which belong in each package
		Map<CompilerInputLocation, List<CompilerPathSet>> paths = this.paths;
		Packages packages = Packages.loadPackages(
			paths.get(CompilerInputLocation.CLASS),
			paths.get(CompilerInputLocation.SOURCE));
		todo.DEBUG.note("Packages: %s", packages);
		
		// OLDER CODE BELOW
		if (true)
			throw new todo.TODO();
		
		// Setup input which processes input classes
		RuntimeInput ri = new RuntimeInput(
			paths.get(CompilerInputLocation.CLASS),
			paths.get(CompilerInputLocation.SOURCE));
		
		// Run compilation step
		try
		{
			// Process input files to load their structures
			for (CompilerInput ci : this.input)
				ri.processSourceFiles(ci.fileName());
			
			if (true)
				throw new todo.TODO();
		}
		
		// Caught compiler exception so report it and retoss
		catch (CompilerException|InvalidClassFormatException e)
		{
			// Print the root causes of the exception
			Throwable t = e;
			while (t != null)
			{
				// {@squirreljme.error AQ0j Failed to compile.}
				log.message(MessageType.ERROR,
					((t instanceof LocationAware) ?
						(LocationAware)t : null),
					"AQ0j %s", t.getMessage());
				
				// {@squirreljme.error AQ0k Failed to compile. (An exception
				// or error was suppressed)}
				for (Throwable s : t.getSuppressed())
					log.message(MessageType.ERROR,
						((s instanceof LocationAware) ?
							(LocationAware)s : null),
						"AQ0k %s", s.getMessage());
				
				// Keep going down
				t = t.getCause();
			}
			
			// Print trace
			e.printStackTrace();
			
			// Keep it going
			throw e;
		}
	}
	
	/**
	 * Converts a file name to a class name.
	 *
	 * @param __n The file name to convert.
	 * @return The resulting class name.
	 * @throws CompilerException If the name could not be converted to a
	 * class name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	static final ClassName __fileToClassName(String __n)
		throws CompilerException, NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ0l Cannot determine classname of file because
		// it has an unknown suffix. (The file name)}
		String suffix;
		if (!__n.endsWith(".java"))
			if (!__n.endsWith(".class"))
				throw new CompilerException(String.format("AQ0l %s", __n));
			else
				suffix = ".class";
		else
			suffix = ".java";
		
		// Convert path form to class form
		return new ClassName(__n.substring(0, __n.length() - suffix.length()));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/MissingClassNodeException.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import net.multiphasicapps.javac.CompilerException;

/**
 * This is thrown when a class node is requested and it does not exist.
 *
 * @since 2018/03/06
 */
public class MissingClassNodeException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/06
	 */
	public MissingClassNodeException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/06
	 */
	public MissingClassNodeException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/06
	 */
	public MissingClassNodeException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/06
	 */
	public MissingClassNodeException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/SourcedClassNode.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.cute;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerLogger;
import net.multiphasicapps.javac.MessageType;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;
import net.multiphasicapps.javac.token.BufferedTokenSource;

/**
 * This is a class node which is based on input source code and is compiled
 * by the compiler as it contains instructions to generate.
 *
 * @since 2018/03/06
 */
@Deprecated
public final class SourcedClassNode
	extends ClassNode
{
	/**
	 * Initializes a node which has semi-parsed structure information and
	 * builds a remaining structure from it.
	 *
	 * @param __name The name of the node.
	 * @param __input The input which contains the node data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	private SourcedClassNode(ClassName __name, CompilerInput __input)
		throws NullPointerException
	{
		super(__name, __input);
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the input source file and generates nodes and adds them to the
	 * compiler state, the parsed nodes contain incompletely compiled class
	 * file data.
	 *
	 * @param __input The input which contains the node data.
	 * @param __state The compiler state which is used to initialize more
	 * nodes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/06
	 */
	static final void __loadNodes(CompilerInput __input, CompilerState __state)
		throws NullPointerException
	{
		if (__input == null || __state == null)
			throw new NullPointerException("NARG");
			
		CompilerLogger log = __state.log();
		
		// Store last processed file for debug purposes
		__state._lastinput = __input;
		
		// {@squirreljme.error AQ0m Parsing input source file for classes to
		// compile.}
		log.message(MessageType.INFO, __input, "AQ0m");
		
		// Setup streamlined tokenizers to parse the classes
		CompilationUnitSyntax compunit;
		try (InputStream in = __input.open())
		{
			// Load the structure
			compunit = CompilationUnitSyntax.parse(
				new BufferedTokenSource(__input.fileName(), in));
		}
		
		// {@squirreljme.error AQ0n Could not read the input source file.
		// (The input source file)}
		catch (IOException e)
		{
			throw new CompilerException(__input,
				String.format("AQ0n %s", __input.fileName()), e);
		}
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/cute/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the default compiler which is provided as a default.
 * It is intended to be minimal, small, easy to maintain, and fast.
 *
 * @since 2017/11/28
 */

package net.multiphasicapps.javac.cute;

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/AnnotationModifier.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.syntax.AnnotationSyntax;

/**
 * This represents a modifier which is associated with a package, class,
 * member, or field and it represents the value of an annotation.
 *
 * @since 2018/05/07
 */
@Deprecated
public final class AnnotationModifier
	implements StructureModifier
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses the input annotation and sets the modifier for it.
	 *
	 * @param __syn The input syntax.
	 * @param __nl The name lookup for annotation types.
	 * @return The output modifier.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException On null arguments.
	 * @since 2018/05/12
	 */
	public static AnnotationModifier parse(AnnotationSyntax __syn,
		NameLookup __nl)
		throws NullPointerException, StructureException
	{
		if (__syn == null || __nl == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/BasicModifier.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


























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This represents a basic modifier.
 *
 * @since 2018/05/12
 */
@Deprecated
public enum BasicModifier
	implements StructureModifier
{
	/** Public access. */
	PUBLIC,
	
	/** Protected access. */
	PROTECTED,
	
	/** Private access. */
	PRIVATE,
	
	/** Static access. */
	STATIC,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Final. */
	FINAL,
	
	/** Native. */
	NATIVE,
	
	/** Synchronized. */
	SYNCHRONIZED,
	
	/** Transient. */
	TRANSIENT,
	
	/** Volatile. */
	VOLATILE,
	
	/** Strict floating point. */
	STRICTFP,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassConstructorStructure.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.syntax.UnparsedExpressions;

/**
 * This represents the structure of a class constructor.
 *
 * @since 2018/05/08
 */
@Deprecated
public final class ClassConstructorStructure
	implements ClassMemberStructure
{
	/** The modifiers used for the class. */
	protected final StructureModifiers modifiers;
	
	/** The type parameters. */
	protected final TypeParameters typeparameters;
	
	/** The formal parameters. */
	protected final FormalParameters formalparameters;
	
	/** The unparsed code block, if any. */
	protected final UnparsedExpressions code;
	
	/** The thrown types. */
	private final TypeSymbol[] _thrown;
	
	/**
	 * Initializes the class constructor structure.
	 *
	 * @param __mods The modifiers to the constructor.
	 * @param __tparms The type parameters used.
	 * @param __parms The formal parameters used.
	 * @param __thrown The thrown types.
	 * @param __code Method code that should exist for the constructor.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the sturcture is not valid.
	 * @since 2018/05/10
	 */
	public ClassConstructorStructure(StructureModifiers __mods,
		TypeParameters __tparms, FormalParameters __parms,
		Iterable<TypeSymbol> __thrown, UnparsedExpressions __code)
		throws NullPointerException, StructureException
	{
		if (__mods == null || __tparms == null || __parms == null ||
			__thrown == null || __code == null)
			throw new NullPointerException("NARG");
		
		if (true)
			throw new todo.TODO();
		
		this.modifiers = __mods;
		this.typeparameters = __tparms;
		this.formalparameters = __parms;
		this.code = __code;
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/08
	 */
	@Override
	public final ClassConstructorSymbol symbol()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/14
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassConstructorSymbol.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This symbol represents the constructor of a class.
 *
 * @since 2018/05/08
 */
@Deprecated
public final class ClassConstructorSymbol
	implements StructureSymbol
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassMemberStructure.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This represents a structure which may be the member of a class.
 *
 * @since 2018/05/08
 */
@Deprecated
public interface ClassMemberStructure
	extends Structure
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassNameLookup.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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.syntax.ClassSyntax;
import net.multiphasicapps.javac.syntax.TypeParameterSyntax;
import net.multiphasicapps.javac.syntax.TypeParametersSyntax;
import net.multiphasicapps.javac.syntax.TypeSyntax;

/**
 * This is used to lookup fields, methods, and identifiers within a class
 * scope.
 *
 * @since 2018/05/08
 */
@Deprecated
public final class ClassNameLookup
	implements NameLookup
{
	/** The parent name lookup. */
	protected final NameLookup parent;	
	
	/** The class to name lookup for. */
	protected final ClassSyntax current;
	
	/**
	 * Initializes the class name lookup.
	 *
	 * @param __parent The parent name lookup.
	 * @param __cur The current class.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/08
	 */
	public ClassNameLookup(NameLookup __parent, ClassSyntax __cur)
		throws NullPointerException
	{
		if (__parent == null || __cur == null)
			throw new NullPointerException("NARG");
		
		this.parent = __parent;
		this.current = __cur;
		
		// Determine if there are any type parameters which need their meaning
		// defined
		for (TypeParameterSyntax typeparam : __cur.typeParameters())
			throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final TypeSymbol lookupType(TypeSyntax __ts)
		throws NullPointerException, StructureException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassSymbol.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.BinaryName;

/**
 * This is a symbol which represents the name of a class.
 *
 * @since 2018/05/05
 */
@Deprecated
public class ClassSymbol
	implements StructureSymbol
{
	/** The binary name of the class. */
	protected final BinaryName binaryname;
	
	/**
	 * Initializes the class symbol.
	 *
	 * @param __bn The binary name to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/05
	 */
	public ClassSymbol(BinaryName __bn)
		throws NullPointerException
	{
		if (__bn == null)
			throw new NullPointerException("NARG");
		
		this.binaryname = __bn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Translates this class symbol to the name of the class file this will
	 * belong to.
	 *
	 * @return The class file name.
	 * @since 2018/05/05
	 */
	public final String toClassFileName()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Translates this class symbol to the name of the source code files that
	 * may be used for this class, this results in multiple files potentially
	 * being produced as there may be unknown sub-classes.
	 *
	 * @return The source file names used for this class.
	 * @since 2018/05/05
	 */
	public final String[] toSourceFileNames()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Converts the given file name to the class symbol it should be
	 * associated with.
	 *
	 * @param __fn The filename.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/05
	 */
	public static ClassSymbol fromSourceFileName(String __fn)
		throws NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/ClassSyntaxParser.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.javac.syntax.ClassConstructorSyntax;
import net.multiphasicapps.javac.syntax.ClassSyntax;
import net.multiphasicapps.javac.syntax.MemberSyntax;
import net.multiphasicapps.javac.syntax.QualifiedIdentifierSyntax;
import net.multiphasicapps.javac.syntax.TypeParametersSyntax;
import net.multiphasicapps.javac.syntax.TypeParameterSyntax;
import net.multiphasicapps.javac.syntax.TypeSyntax;

/**
 * This class parses individual classes.
 *
 * @since 2018/05/08
 */
@Deprecated
public final class ClassSyntaxParser
	implements Runnable
{
	/** The parent class, may be {@code null}. */
	protected final ClassSyntax parent;
	
	/** The current class. */
	protected final ClassSyntax current;
	
	/** The run-time input. */
	protected final RuntimeInput runtime;
	
	/** The name lookup for this class. */
	protected final ClassNameLookup namelookup;
	
	/**
	 * Initializes the class syntax parser.
	 *
	 * @param __parent The parent class, may be {@code null}.
	 * @param __cur The current class being parsed.
	 * @param __pnl The parent name lookup.
	 * @param __ri The runtime input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/08
	 */
	public ClassSyntaxParser(ClassSyntax __parent, ClassSyntax __cur,
		NameLookup __pnl, RuntimeInput __ri)
		throws NullPointerException
	{
		if (__cur == null || __pnl == null || __ri == null)
			throw new NullPointerException("NARG");
		
		this.parent = __parent;
		this.current = __cur;
		this.runtime = __ri;
		this.namelookup = new ClassNameLookup(__pnl, __cur);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/08
	 */
	@Override
	public final void run()
	{
		ClassSyntax current = this.current;
		ClassNameLookup namelookup = this.namelookup;
		RuntimeInput runtime = this.runtime;
		
		// Handle extends of the class
		for (TypeSyntax t : current.extending())
			throw new todo.TODO();
		
		// Handle implements of the class
		for (TypeSyntax t : current.implementing())
			throw new todo.TODO();
		
		// Handle class members
		List<ClassMemberStructure> members = new ArrayList<>();
		for (MemberSyntax m : current.members())
		{
			// Is just another class to be parsed
			if (m instanceof ClassSyntax)
			{
				ClassSyntax xm = (ClassSyntax)m;
				
				// Run that class through the processor
				new ClassSyntaxParser(current, xm,
					new ClassNameLookup(namelookup, xm), runtime).run();
				
				throw new todo.TODO();
			}
			
			// Class constructor
			else if (m instanceof ClassConstructorSyntax)
				members.add(this.__parseConstructor(
					(ClassConstructorSyntax)m));
			
			// Unhandled member type
			else
				throw new RuntimeException(String.format("OOPS %s",
					m.getClass()));
		}
		
		// Build class structure
		throw new todo.TODO();
	}
	
	/**
	 * Parses the class constructor syntax and returns a structure for the
	 * class constructor.
	 *
	 * @param __syn The input syntax.
	 * @return The resulting structure.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the structure is not valid.
	 * @since 2018/05/08
	 */
	private final ClassConstructorStructure __parseConstructor(
		ClassConstructorSyntax __syn)
		throws NullPointerException, StructureException
	{
		if (__syn == null)
			throw new NullPointerException("NARG");
		
		ClassSyntax current = this.current;
		ClassNameLookup namelookup = this.namelookup;
		
		// Parse type parameters
		TypeParameters typeparms = TypeParameters.parseSyntax(
			__syn.typeParameters(), namelookup);
		
		// Setup lookup with type parameters because arguments and throwables
		// will need to know the types and such
		TypeParametersNameLookup tpnl = new TypeParametersNameLookup(
			typeparms, namelookup);
		
		// Parse formal parameters and perform name lookup
		FormalParameters fparms = FormalParameters.parseSyntax(
			__syn.formalParameters(), tpnl);
		
		// Parse thrown types
		List<TypeSymbol> thrown = new ArrayList<>();
		for (QualifiedIdentifierSyntax qi : __syn.thrownTypes())
			thrown.add(namelookup.lookupType(new TypeSyntax(qi)));
		
		// Construct class symbol
		return new ClassConstructorStructure(StructureModifiers.parse(
			__syn.modifiers(), namelookup), typeparms, fparms, thrown,
			__syn.code());
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/CompilationUnitNameLookup.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;
import net.multiphasicapps.javac.syntax.TypeSyntax;

/**
 * This is a name lookup which looks within a compilation unit to determine the
 * name symbol of something.
 *
 * The Java language standard at the compilation unit level defines three
 * relevant lookups for ambigious identifiers:
 *
 * Otherwise, if a field of that name is declared in the compilation unit
 * (S7.3) containing the Identifier by a single-static-import declaration
 * (S7.5.3), or by a static-import-on-demand declaration (S7.5.4) then the
 * AmbiguousName is reclassified as an ExpressionName.
 *
 * And then:
 *
 * Otherwise, if a type of that name is declared in the compilation unit (S7.3)
 * containing the Identifier, either by a single-type-import declaration
 * (S7.5.1), or by a type-import-on-demand declaration (S7.5.2), or by a
 * single-static-import declaration (S7.5.3), or by a static-import-on-demand
 * declaration (S7.5.4), then the AmbiguousName is reclassified as a TypeName.
 *
 * And finally:
 *
 * Otherwise, the AmbiguousName is reclassified as a PackageName. A later step
 * determines whether or not a package of that name actually exists.
 *
 * @since 2018/05/08
 */
@Deprecated
public class CompilationUnitNameLookup
	implements NameLookup
{
	/** The run-time to use for class lookup. */
	protected final RuntimeInput runtime;
	
	/**
	 * Initializes the compilation unit name lookup.
	 *
	 * @param __cus The compilation unit to initialize for.
	 * @param __ri The input
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/08
	 */
	public CompilationUnitNameLookup(CompilationUnitSyntax __cus,
		RuntimeInput __ri)
		throws NullPointerException
	{
		if (__cus == null || __ri == null)
			throw new NullPointerException("NARG");
		
		this.runtime = __ri;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final TypeSymbol lookupType(TypeSyntax __ts)
		throws NullPointerException, StructureException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/CompilationUnitParser.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.javac.syntax.ClassSyntax;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;

/**
 * This class is used to parse compilation units.
 *
 * @since 2018/05/07
 */
@Deprecated
public final class CompilationUnitParser
	implements Runnable
{
	/** The compilation unit being parsed. */
	protected final CompilationUnitSyntax input;
	
	/** The runtime information. */
	protected final RuntimeInput runtime;
	
	/** The output where it is to be stored. */
	protected final Structures output;
	
	/**
	 * Initializes the parser.
	 *
	 * @param __in The compilation unit input.
	 * @param __ri The run-time input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/07
	 */
	public CompilationUnitParser(CompilationUnitSyntax __in, RuntimeInput __ri)
		throws NullPointerException
	{
		if (__in == null || __ri == null)
			throw new NullPointerException("NARG");
		
		this.input = __in;
		this.runtime = __ri;
		this.output = __ri.structures();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final void run()
	{
		CompilationUnitSyntax input = this.input;
		RuntimeInput runtime = this.runtime;
		Structures output = this.output;
		
		// Get the package this is in
		BinaryName bninpackage = input.inPackage();
		PackageSymbol inpackage = (bninpackage == null ? null :
			new PackageSymbol(bninpackage));
		
		// Check if the package for this class needs to be processed (searched
		// for annotations and such)
		if (inpackage != null && !output.contains(inpackage))
			runtime.processPackage(inpackage);
		
		// Setup compilation unit name lookup at the top level, which uses
		// import statements, packages, and the classes that exist for
		// identifiers
		CompilationUnitNameLookup nl = new CompilationUnitNameLookup(input,
			runtime);
		
		// Process each individual class
		for (ClassSyntax cs : input.classes())
			new ClassSyntaxParser(null, cs, nl, runtime).run();
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/FormalParameter.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.Arrays;
import net.multiphasicapps.classfile.FieldName;

/**
 * This represents a single formal parameter which is used as input for a
 * method.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class FormalParameter
{
	/** The name of the parameter. */
	protected final FieldName name;
	
	/**
	 * Initializes the single formal parameter.
	 *
	 * @param __ams The annotations which modify the parameter.
	 * @param __final Is this parameter final?
	 * @param __type The type of the parameter.
	 * @param __name The name of the parameter.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the formal parameter is not valid.
	 * @since 2018/05/10
	 */
	public FormalParameter(AnnotationModifier[] __ams, boolean __final,
		TypeSymbol __type, FieldName __name)
		throws NullPointerException, StructureException
	{
		this(Arrays.<AnnotationModifier>asList((__ams == null ?
			new AnnotationModifier[0] : __ams)), __final, __type, __name);
	}
	
	/**
	 * Initializes the single formal parameter.
	 *
	 * @param __ams The annotations which modify the parameter.
	 * @param __final Is this parameter final?
	 * @param __type The type of the parameter.
	 * @param __name The name of the parameter.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the formal parameter is not valid.
	 * @since 2018/05/10
	 */
	public FormalParameter(Iterable<AnnotationModifier> __ams, boolean __final,
		TypeSymbol __type, FieldName __name)
		throws NullPointerException, StructureException
	{
		if (__ams == null || __type == null || __name == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the name of the parameter.
	 *
	 * @return The parameter name.
	 * @since 2018/05/10
	 */
	public final FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/FormalParameters.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.javac.syntax.AnnotationSyntax;
import net.multiphasicapps.javac.syntax.FormalParametersSyntax;
import net.multiphasicapps.javac.syntax.FormalParameterSyntax;
import net.multiphasicapps.javac.syntax.ModifiersSyntax;
import net.multiphasicapps.javac.syntax.ModifierSyntax;

/**
 * This represents a group of formal parameters.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class FormalParameters
{
	/** The formal parameters which are used. */
	private final FormalParameter[] _parameters;
	
	/**
	 * Initializes the formal parameters.
	 *
	 * @param __fp The input formal parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the formal parameters are not valid.
	 * @since 2018/05/10
	 */
	public FormalParameters(FormalParameter... __fp)
		throws NullPointerException, StructureException
	{
		this(Arrays.<FormalParameter>asList((__fp != null ? __fp :
			new FormalParameter[0])));
	}
	
	/**
	 * Initializes the formal parameters.
	 *
	 * @param __tp The input formal parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the formal parameters are not valid.
	 * @since 2018/05/10
	 */
	public FormalParameters(Iterable<FormalParameter> __fp)
		throws NullPointerException, StructureException
	{
		if (__fp == null)
			throw new NullPointerException("NARG");
		
		Set<FieldName> names = new HashSet<>();
		List<FormalParameter> rv = new ArrayList<>();
		for (FormalParameter fp : __fp)
		{
			if (fp == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ0o Duplicate parameter name. (The name
			// of the parameter)}
			FieldName name = fp.name();
			if (names.contains(name))
				throw new StructureException(String.format("AQ0o %s", name));
			names.add(name);
			
			rv.add(fp);
		}
		
		this._parameters = rv.<FormalParameter>toArray(
			new FormalParameter[rv.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses formal parameters.
	 *
	 * @param __syn The syntax used to make up the formal parameters.
	 * @param __nl The name lookup which is used for types and annotations.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the formal parameters are not correct.
	 * @since 2018/05/10
	 */
	public static FormalParameters parseSyntax(FormalParametersSyntax __syn,
		NameLookup __nl)
		throws NullPointerException, StructureException
	{
		if (__syn == null || __nl == null)
			throw new NullPointerException("NARG");
		
		// Parse each one and wrap
		List<FormalParameter> rv = new ArrayList<>();
		for (FormalParameterSyntax syn : __syn)
		{
			// Need to check the modifiers to determine if they are annotated
			// in any way
			ModifiersSyntax modifiers = syn.modifiers();
			List<AnnotationModifier> ams = new ArrayList<>();
			for (ModifierSyntax modifier : modifiers)
				if (modifier instanceof AnnotationSyntax)
				{
					throw new todo.TODO();
				}
			
			// Setup formal parameter
			rv.add(new FormalParameter(ams, modifiers.isFinal(),
				__nl.lookupType(syn.type()), syn.name()));
		}
		
		// Create
		return new FormalParameters(rv);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/NameLookup.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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.syntax.TypeSyntax;

/**
 * This class manages the lookup for names and may recursively lookup what a
 * name means depending on the scope.
 *
 * @since 2018/05/07
 */
@Deprecated
public interface NameLookup
{
	/**
	 * Looks up the specified type syntax and returns the symbol for it.
	 *
	 * @param __ts The type syntax to locate.
	 * @return The symbol for the given type.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If no such symbol exists.
	 * @since 2018/05/10
	 */
	public abstract TypeSymbol lookupType(TypeSyntax __ts)
		throws NullPointerException, StructureException;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/PackageInfoParser.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.javac.syntax.AnnotationSyntax;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;
import net.multiphasicapps.javac.syntax.ModifiersSyntax;
import net.multiphasicapps.javac.syntax.ModifierSyntax;

/**
 * This parses the package information source file and for the most part is
 * used to handle the annotations accordingly if there are any.
 *
 * @since 2018/05/07
 */
@Deprecated
public final class PackageInfoParser
	implements Runnable
{
	/** The compilation unit being parsed. */
	protected final CompilationUnitSyntax input;
	
	/** The runtime information. */
	protected final RuntimeInput runtime;
	
	/** The output where it is to be stored. */
	protected final Structures output;
	
	/**
	 * Initializes the parser.
	 *
	 * @param __in The compilation unit input.
	 * @param __ri The run-time input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/07
	 */
	public PackageInfoParser(CompilationUnitSyntax __in, RuntimeInput __ri)
		throws NullPointerException
	{
		if (__in == null || __ri == null)
			throw new NullPointerException("NARG");
		
		this.input = __in;
		this.runtime = __ri;
		this.output = __ri.structures();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final void run()
	{
		CompilationUnitSyntax input = this.input;
		Structures output = this.output;
		
		// Parse package annotations, if any
		List<AnnotationModifier> annotations = new ArrayList<>();
		for (ModifierSyntax modifier : input.packageModifiers().modifiers())
		{
			// Only annotation are valid for packages
			AnnotationSyntax as = (AnnotationSyntax)modifier;
			
			throw new todo.TODO();
		}
		
		// Store it
		output.put(new PackageStructure(new PackageSymbol(input.inPackage()),
			annotations));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/PackageStructure.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
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






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This structure represents a single package.
 *
 * @since 2018/05/07
 */
@Deprecated
public final class PackageStructure
	implements Structure
{
	/** The symbol used. */
	protected final PackageSymbol symbol;
	
	/** The annotation modifiers. */
	private final AnnotationModifier[] _annotations;
	
	/**
	 * Initializes the package structure.
	 *
	 * @param __sym The symbol for the package.
	 * @param __ams The annotation modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the structure is not valid.
	 * @since 2018/05/07
	 */
	public PackageStructure(PackageSymbol __sym, AnnotationModifier[] __ams)
		throws NullPointerException, StructureException
	{
		this(__sym, Arrays.<AnnotationModifier>asList(
			(__ams == null ? new AnnotationModifier[0] : __ams)));
	}
	
	/**
	 * Initializes the package structure.
	 *
	 * @param __sym The symbol for the package.
	 * @param __ams The annotation modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the structure is not valid.
	 * @since 2018/05/07
	 */
	public PackageStructure(PackageSymbol __sym,
		Iterable<AnnotationModifier> __ams)
		throws NullPointerException, StructureException
	{
		if (__sym == null || __ams == null)
			throw new NullPointerException("NARG");
		
		List<AnnotationModifier> annotations = new ArrayList<>();
		for (AnnotationModifier am : __ams)
			if (am == null)
				throw new NullPointerException("NARG");
			else
				annotations.add(am);
		
		this.symbol = __sym;
		this._annotations = annotations.<AnnotationModifier>toArray(
			new AnnotationModifier[annotations.size()]);
	}
	
	/**
	 * Returns the used annotations.
	 *
	 * @return The used annotations.
	 * @since 2018/05/07
	 */
	public final AnnotationModifier[] annotations()
	{
		return this._annotations;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof PackageStructure))
			return false;
		
		PackageStructure o = (PackageStructure)__o;
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final PackageSymbol symbol()
	{
		return this.symbol;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/PackageSymbol.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.BinaryName;

/**
 * This represents the symbol name of a package, it is mostly intended to
 * handle {@code package-info} files and potentially associate any annotations
 * to the package itself.
 *
 * @since 2018/05/05
 */
@Deprecated
public final class PackageSymbol
	implements StructureSymbol
{
	/** The binary name of the package. */
	protected final BinaryName name;
	
	/**
	 * Initializes the symbol.
	 *
	 * @param __bn The binary name used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/07
	 */
	public PackageSymbol(BinaryName __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof PackageSymbol))
			return false;
		
		PackageSymbol o = (PackageSymbol)__o;
		return this.name.equals(o.name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/05
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/RuntimeInput.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362










































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.classfile.ClassIdentifier;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.javac.CompilerInput;
import net.multiphasicapps.javac.CompilerPathSet;
import net.multiphasicapps.javac.NoSuchInputException;
import net.multiphasicapps.javac.StringFileName;
import net.multiphasicapps.javac.syntax.ClassSyntax;
import net.multiphasicapps.javac.syntax.CompilationUnitSyntax;
import net.multiphasicapps.javac.syntax.ModifiersSyntax;
import net.multiphasicapps.javac.syntax.SyntaxException;
import net.multiphasicapps.javac.token.BufferedTokenSource;

/**
 * This class contians the input for the .
 *
 * @since 2018/05/03
 */
@Deprecated
public final class RuntimeInput
{
	/** Output structure information. */
	protected final Structures structures =
		new Structures();
	
	/** The class path. */
	private final CompilerPathSet[] _classpath;
	
	/** The source path. */
	private final CompilerPathSet[] _sourcepath;
	
	/** Files which have been processed. */
	private final Set<String> _didfiles =
		new HashSet<>();
	
	/**
	 * Initializes the runtime input.
	 *
	 * @param __class The class path.
	 * @param __src The source path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public RuntimeInput(CompilerPathSet[] __class, CompilerPathSet[] __src)
		throws NullPointerException
	{
		this(Arrays.<CompilerPathSet>asList((__class == null ?
			new CompilerPathSet[0] : __class)),
			Arrays.<CompilerPathSet>asList((__src == null ?
			new CompilerPathSet[0] : __src)));
	}
	
	/**
	 * Initializes the runtime input.
	 *
	 * @param __class The class path.
	 * @param __src The source path.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public RuntimeInput(Iterable<CompilerPathSet> __class,
		Iterable<CompilerPathSet> __src)
		throws NullPointerException
	{
		if (__class == null || __src == null)
			throw new NullPointerException("NARG");
		
		// Check classpath
		List<CompilerPathSet> classes = new ArrayList<>();
		for (CompilerPathSet p : __class)
			if (p == null)
				throw new NullPointerException("NARG");
			else
				classes.add(p);
		
		// Check sources
		List<CompilerPathSet> sources = new ArrayList<>();
		for (CompilerPathSet p : __src)
			if (p == null)
				throw new NullPointerException("NARG");
			else
				sources.add(p);
		
		this._classpath = classes.<CompilerPathSet>toArray(
			new CompilerPathSet[classes.size()]);
		this._sourcepath = sources.<CompilerPathSet>toArray(
			new CompilerPathSet[sources.size()]);
	}
	
	/**
	 * Prcoesses a single class file.
	 *
	 * @param __fn The class file name to process.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the class structure is not valid.
	 * @since 2018/05/05
	 */
	public final void processClassFile(String __fn)
		throws NullPointerException, StructureException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Processes the specified package and initializes it from class files
	 * or source code.
	 *
	 * @param __ps The package to initialize.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the specified package does not exist or
	 * is not valid.
	 * @since 2018/05/08
	 */
	public final void processPackage(PackageSymbol __ps)
		throws NullPointerException, StructureException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Processes a single source file.
	 *
	 * @param __fn The input file to process.
	 * @throws StructureException If the source structure is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/05
	 */
	public final void processSourceFile(String __fn)
		throws StructureException, NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		// Only process class files once
		Set<String> didfiles = this._didfiles;
		if (didfiles.contains(__fn))
			return;
		didfiles.add(__fn);
		
		// Used for location awareness
		StringFileName sfn = new StringFileName(__fn);
		
		// {@squirreljme.error AQ0p Cannot process source file which does not
		// end in {@code .java}.}
		if (!__fn.toLowerCase().endsWith(".java"))
			throw new StructureException(sfn, "AQ0p");
		
		// Get basename and package name, used to quickly determine some things
		String basename = __fn.substring(0, __fn.length() - 5);
		int lastslash = basename.lastIndexOf('/');
		String rawinpackage = (lastslash < 0 ? null :
				basename.substring(0, lastslash)),
			baseclassname = (lastslash < 0 ? basename :
				basename.substring(lastslash + 1));
		
		// The package the class is in
		BinaryName inpackage = (rawinpackage == null ? null :
			new BinaryName(rawinpackage));
		
		// This will essentially check that the class is named with valid
		// characters
		BinaryName classname;
		try
		{
			// The package information has no class name
			if (baseclassname.equals("package-info"))
				classname = null;
			else
				classname = new BinaryName(basename);
		}
		catch (InvalidClassFormatException e)
		{
			// {@squirreljme.error AQ0q Cannot parse the source file because
			// it does not have a valid name.}
			throw new StructureException(sfn,
				String.format("AQ0q %s", basename));
		}
		
		// Determine the identifier of the class
		ClassIdentifier classident = (classname == null ? null :
			new ClassIdentifier(baseclassname));
		
		// Search for the source file
		CompilerInput ci = null;
		for (CompilerPathSet ps : this._sourcepath)
			try
			{
				if (null != (ci = ps.input(__fn)))
					break;
			}
			catch (NoSuchInputException e)
			{
			}
		
		// {@squirreljme.error AQ0r The source file does not exist.}
		if (ci == null)
			throw new StructureException(sfn, "AQ0r");
		
		// Parse the syntax for the compilation unit and hope it works
		CompilationUnitSyntax cus;
		try (InputStream in = ci.open();
			BufferedTokenSource bts = new BufferedTokenSource(__fn, in))
		{
			cus = CompilationUnitSyntax.parse(bts);
		}
		
		// {@squirreljme.error AQ0s Could not parse the syntax for the source
		// file because it failed to read or has invalid syntax.}
		catch (IOException|SyntaxException e)
		{
			throw new StructureException(sfn, "AQ0s", e);
		}
		
		// Debug the layout
		todo.DEBUG.note("%s", cus);
		
		// {@squirreljme.error AQ0t Source code file specified a package which
		// does not match the package represented in the source code itself.
		// (The package the source is in; The package the source code actually
		// specified)}
		BinaryName cuspackage = cus.inPackage();
		if (!Objects.equals(inpackage, cuspackage))
			throw new StructureException(sfn, String.format("AQ0t %s %s",
				inpackage, cuspackage));
		
		// Determine if the class was placed in the correct file
		List<ClassSyntax> classes = cus.classes();
		if (classname != null)
		{
			// {@squirreljme.error AQ0u Source file declares no classes.}
			if (classes.size() <= 0)
				throw new StructureException(sfn, "AQ0u");
			
			// Find the public class
			ClassSyntax pubclass = null;
			for (ClassSyntax cs : classes)
			{
				ModifiersSyntax mods = cs.modifiers();
				if (mods.isPublic())
				{
					// {@squirreljme.error AQ0v Class file contains multiple
					// public classes. (The first found public class; The
					// second found public class)}
					if (pubclass != null)
						throw new StructureException(sfn,
							String.format("AQ0v %s %s", pubclass.name(),
							cs.name()));
					
					pubclass = cs;
				}
			}
			
			// If only a single class is declared and no public class exists
			// then the only class which exists there must have a matching
			// name
			if (pubclass == null && classes.size() == 1)
				pubclass = classes.get(0);
			
			// {@squirreljme.error AQ0w The name of the public class in the
			// file does not match the expected name of the source file.
			// (The public class name)}
			if (pubclass != null && !classident.equals(pubclass.name()))
				throw new StructureException(sfn,
					String.format("AQ0w %s", pubclass.name()));
		}
		
		// Is a package-info file
		else
		{
			// {@squirreljme.error AQ0x Source package-info files cannot
			// specify any classes.}
			if (classes.size() != 0)
				throw new StructureException(sfn, "AQ0x");
		}
		
		// So now that the source file has been parsed the resulting syntax
		// needs to be parsed itself to load structure data from it
		if (classname != null)
			new CompilationUnitParser(cus, this).run();
		else
			new PackageInfoParser(cus, this).run();
	}
	
	/**
	 * Processes source code files and loads their required structure
	 * information performing basic compilation of them.
	 *
	 * @param __fn The source file name to process.
	 * @throws StructureException If the parsed structures are not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public final void processSourceFiles(String... __fn)
		throws StructureException, NullPointerException
	{
		this.processSourceFiles(Arrays.<String>asList((__fn == null ?
			new String[0] : __fn)));
	}
	
	/**
	 * Processes source code files and loads their required structure
	 * information performing basic compilation of them.
	 *
	 * @param __fn The source file name to process.
	 * @throws StructureException If the parsed structures are not correct.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public final void processSourceFiles(Iterable<String> __fn)
		throws StructureException, NullPointerException
	{
		if (__fn == null)
			throw new NullPointerException("NARG");
		
		// Process each file
		for (String filename : __fn)
		{
			if (filename == null)
				throw new NullPointerException("NARG");	
			
			this.processSourceFile(filename);
		}
	}
	
	/**
	 * Returns the structures where classes have been read into.
	 *
	 * @return The structures used.
	 * @since 2018/05/05
	 */
	public final Structures structures()
	{
		return this.structures;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/Structure.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This interface represents structure representation.
 *
 * @since 2018/05/07
 */
@Deprecated
public interface Structure
{
	/**
	 * Returns the symbol for the structure.
	 *
	 * @return The structure symbol.
	 * @since 2018/05/07
	 */
	public abstract StructureSymbol symbol();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/StructureException.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.LocationAware;

/**
 * This is thrown when the structure of a class file or source code is not
 * correct.
 *
 * @since 2018/05/03
 */
@Deprecated
public class StructureException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/05/03
	 */
	public StructureException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/05/03
	 */
	public StructureException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/05/03
	 */
	public StructureException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/05/03
	 */
	public StructureException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2018/05/03
	 */
	public StructureException(LocationAware __la)
	{
		super(__la);
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2018/05/03
	 */
	public StructureException(LocationAware __la, String __m)
	{
		super(__la, __m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/05/03
	 */
	public StructureException(LocationAware __la, String __m,
		Throwable __c)
	{
		super(__la, __m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2018/05/03
	 */
	public StructureException(LocationAware __la, Throwable __c)
	{
		super(__la, __c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/StructureModifier.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This interface represents any modifier which may be associated with a class,
 * member, or parameter.
 *
 * @since 2018/05/12
 */
@Deprecated
public interface StructureModifier
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/StructureModifiers.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.javac.syntax.AnnotationSyntax;
import net.multiphasicapps.javac.syntax.BasicModifierSyntax;
import net.multiphasicapps.javac.syntax.ModifiersSyntax;
import net.multiphasicapps.javac.syntax.ModifierSyntax;

/**
 * Represents modifiers that may be associated with a structure.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class StructureModifiers
{
	/** The modifiers which are available. */
	private final Set<StructureModifier> _modifiers;
	
	/**
	 * Initializes the modifiers.
	 *
	 * @param __m The input modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the modifiers are not valid.
	 * @since 2018/05/12
	 */
	public StructureModifiers(StructureModifier... __m)
		throws NullPointerException, StructureException
	{
		this(Arrays.<StructureModifier>asList((__m != null ? __m :
			new StructureModifier[0])));
	}
	
	/**
	 * Initializes the modifiers.
	 *
	 * @param __m The input modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the modifiers are not valid.
	 * @since 2018/05/12
	 */
	public StructureModifiers(Iterable<StructureModifier> __m)
		throws NullPointerException, StructureException
	{
		if (__m == null)
			throw new NullPointerException("NARG");
		
		Set<StructureModifier> rv = new LinkedHashSet<>();
		for (StructureModifier m : __m)
		{
			if (m == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ0y Duplicate modifier. (The modifier)}
			if (rv.contains(m))
				throw new StructureException(String.format("AQ0y %s", m));
			
			rv.add(m);
		}
		
		this._modifiers = rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Is this abstract?
	 *
	 * @return If this is abstract.
	 * @since 2018/05/13
	 */
	public final boolean isAbstract()
	{
		return this._modifiers.contains(BasicModifierSyntax.ABSTRACT);
	}
	
	/**
	 * Is this final?
	 *
	 * @return If this is final.
	 * @since 2018/05/13
	 */
	public final boolean isFinal()
	{
		return this._modifiers.contains(BasicModifierSyntax.FINAL);
	}
	
	/**
	 * Is this native?
	 *
	 * @return If this is native.
	 * @since 2018/05/13
	 */
	public final boolean isNative()
	{
		return this._modifiers.contains(BasicModifierSyntax.NATIVE);
	}
	
	/**
	 * Is this private?
	 *
	 * @return If this is private.
	 * @since 2018/05/13
	 */
	public final boolean isPrivate()
	{
		return this._modifiers.contains(BasicModifierSyntax.PRIVATE);
	}
	
	/**
	 * Is this protected?
	 *
	 * @return If this is protected.
	 * @since 2018/05/13
	 */
	public final boolean isProtected()
	{
		return this._modifiers.contains(BasicModifierSyntax.PROTECTED);
	}
	
	/**
	 * Is this public?
	 *
	 * @return If this is public.
	 * @since 2018/05/13
	 */
	public final boolean isPublic()
	{
		return this._modifiers.contains(BasicModifierSyntax.PUBLIC);
	}
	
	/**
	 * Is this static?
	 *
	 * @return If this is static.
	 * @since 2018/05/13
	 */
	public final boolean isStatic()
	{
		return this._modifiers.contains(BasicModifierSyntax.STATIC);
	}
	
	/**
	 * Is this using strict floating point?
	 *
	 * @return If this is using struct floating point.
	 * @since 2018/05/13
	 */
	public final boolean isStrictFloatingPoint()
	{
		return this._modifiers.contains(BasicModifierSyntax.STRICTFP);
	}
	
	/**
	 * Is this synchronized?
	 *
	 * @return If this is synchronized.
	 * @since 2018/05/13
	 */
	public final boolean isSynchronized()
	{
		return this._modifiers.contains(BasicModifierSyntax.SYNCHRONIZED);
	}
	
	/**
	 * Is this transient?
	 *
	 * @return If this is transient.
	 * @since 2018/05/13
	 */
	public final boolean isTransient()
	{
		return this._modifiers.contains(BasicModifierSyntax.TRANSIENT);
	}
	
	/**
	 * Is this volatile?
	 *
	 * @return If this is volatile.
	 * @since 2018/05/13
	 */
	public final boolean isVolatile()
	{
		return this._modifiers.contains(BasicModifierSyntax.VOLATILE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses the given modifiers syntax and builds modifier structures from
	 * them.
	 *
	 * @param __syn The input syntax.
	 * @param __nl The lookup for names (used for annotation).
	 * @return The parsed modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the modifiers are not valid.
	 * @since 2018/05/10
	 */
	public static StructureModifiers parse(ModifiersSyntax __syn,
		NameLookup __nl)
		throws NullPointerException, StructureException
	{
		if (__syn == null || __nl == null)
			throw new NullPointerException("NARG");
		
		// Go through all modifiers
		Set<StructureModifier> rv = new LinkedHashSet<>();
		for (ModifierSyntax mod : __syn)
		{
			// Is this just an annotation?
			if (mod instanceof AnnotationSyntax)
				rv.add(AnnotationModifier.parse((AnnotationSyntax)mod, __nl));
			
			// Standard modifier
			else if (mod instanceof BasicModifierSyntax)
			{
				BasicModifier got;
				switch ((BasicModifierSyntax)mod)
				{
					case PUBLIC:
						got = BasicModifier.PUBLIC;
						break;
						
					case PROTECTED:
						got = BasicModifier.PROTECTED;
						break;
						
					case PRIVATE:
						got = BasicModifier.PRIVATE;
						break;
						
					case STATIC:
						got = BasicModifier.STATIC;
						break;
						
					case ABSTRACT:
						got = BasicModifier.ABSTRACT;
						break;
						
					case FINAL:
						got = BasicModifier.FINAL;
						break;
						
					case NATIVE:
						got = BasicModifier.NATIVE;
						break;
						
					case SYNCHRONIZED:
						got = BasicModifier.SYNCHRONIZED;
						break;
						
					case TRANSIENT:
						got = BasicModifier.TRANSIENT;
						break;
						
					case VOLATILE:
						got = BasicModifier.VOLATILE;
						break;
						
					case STRICTFP:
						got = BasicModifier.STRICTFP;
						break;
						
					default:
						throw new todo.OOPS();
				}
				
				rv.add(got);
			}
			
			// {@squirreljme.error AQ0z Unsupported modifier type. (The type)}
			else
				throw new RuntimeException(String.format("AQ0z %s",
					mod.getClass()));
		}
		
		return new StructureModifiers(rv);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/StructureSymbol.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This interface represents a symbol which can be used to lookup a class.
 *
 * @since 2018/05/03
 */
@Deprecated
public interface StructureSymbol
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/Structures.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This class contains the structure information.
 *
 * @since 2018/05/05
 */
@Deprecated
public final class Structures
{
	/** Mapping of symbols to structures. */
	private final Map<StructureSymbol, Structure> _structures =
		new LinkedHashMap<>();
	
	/**
	 * Checks if the loaded structure contains a symbol for the given class.
	 *
	 * @param __sym The symbol to lookup.
	 * @return If the symbol exists in the structure.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/05
	 */
	public final boolean contains(StructureSymbol __sym)
		throws NullPointerException
	{
		if (__sym == null)
			throw new NullPointerException("NARG");
		
		return this._structures.containsKey(__sym);
	}
	
	/**
	 * Puts the specified structure into the structure map.
	 *
	 * @param __s The structure to put.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the structure already exists.
	 * @since 2018/05/07
	 */
	public final void put(Structure __s)
		throws NullPointerException, StructureException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ10 Structure has no symbol.}
		StructureSymbol sym = __s.symbol();
		if (sym == null)
			throw new NullPointerException("AQ10");
		
		// {@squirreljme.error AQ11 A structure already exists with the
		// given symbol. (The symbol)}
		Map<StructureSymbol, Structure> structures = this._structures;
		if (structures.containsKey(sym))
			throw new StructureException(String.format("AQ11 %s", sym));
		
		// Associate that structure with this symbol
		structures.put(sym, __s);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/TypeParameter.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.Identifier;

/**
 * This represents a single type parameter which is used to describe generic
 * type information.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class TypeParameter
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the identifier which represents the type.
	 *
	 * @return The symbol identifier.
	 * @since 2018/05/10
	 */
	public final TypeParameterSymbol symbol()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/TypeParameterSymbol.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.classfile.Identifier;

/**
 * This is a symbol which represents the type name of the type parameter.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class TypeParameterSymbol
	implements StructureSymbol
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/TypeParameters.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
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












































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.classfile.Identifier;
import net.multiphasicapps.javac.syntax.TypeParametersSyntax;
import net.multiphasicapps.javac.syntax.TypeParameterSyntax;

/**
 * This represents multiple {@link TypeParameter} and is used to describe
 * all of the type parameters used for methods and classes.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class TypeParameters
{
	/** The type parameters used. */
	private final TypeParameter[] _typeparams;
	
	/**
	 * Initializes the type parameters.
	 *
	 * @param __tp The input type parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the type parameters are not valid.
	 * @since 2018/05/10
	 */
	public TypeParameters(TypeParameter... __tp)
		throws NullPointerException, StructureException
	{
		this(Arrays.<TypeParameter>asList((__tp != null ? __tp :
			new TypeParameter[0])));
	}
	
	/**
	 * Initializes the type parameters.
	 *
	 * @param __tp The input type parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If the type parameters are not valid.
	 * @since 2018/05/10
	 */
	public TypeParameters(Iterable<TypeParameter> __tp)
		throws NullPointerException, StructureException
	{
		if (__tp == null)
			throw new NullPointerException("NARG");
		
		// Find duplicate identifiers
		Set<TypeParameterSymbol> idents = new HashSet<>();
		List<TypeParameter> params = new ArrayList<>();
		for (TypeParameter tp : __tp)
			if (tp == null)
				throw new NullPointerException("NARG");
			else
			{
				params.add(tp);
				
				// {@squirreljme.error AQ12 Duplicate type parameter
				// identifier. (The identifier)}
				TypeParameterSymbol i = tp.symbol();
				if (idents.contains(i))
					throw new StructureException(String.format("AQ12 %s", i));
				idents.add(i);
			}
		
		this._typeparams = params.<TypeParameter>toArray(
			new TypeParameter[params.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses the input type parameters and performs resolution and lookup
	 * of the types.
	 *
	 * @param __syn The syntax to parse.
	 * @param __nl The name lookup for types.
	 * @throws NullPointerException On null arguments.
	 * @throws StructureException If a type is not valid.
	 * @since 2018/05/10
	 */
	public static TypeParameters parseSyntax(TypeParametersSyntax __syn,
		NameLookup __nl)
		throws NullPointerException, StructureException
	{
		if (__syn == null || __nl == null)
			throw new NullPointerException("NARG");
		
		// Parse each one
		List<TypeParameter> rv = new ArrayList<>();
		for (TypeParameterSyntax s : __syn)
			throw new todo.TODO();
		
		return new TypeParameters(rv);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/TypeParametersNameLookup.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

import net.multiphasicapps.javac.syntax.TypeSyntax;

/**
 * This is a name lookup which additionally supports lookup into a set of
 * type parameters.
 *
 * @since 2018/05/10
 */
@Deprecated
public final class TypeParametersNameLookup
	implements NameLookup
{
	/** The type parameters to look within. */
	protected final TypeParameters typeparameters;
	
	/** The parent name lookup. */
	protected final NameLookup parent;
	
	/**
	 * Initializes the type parameter lookup.
	 *
	 * @param __tp The type parameters to look in.
	 * @param __parent The parent name lookup for when no type parameter was
	 * found.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/10
	 */
	public TypeParametersNameLookup(TypeParameters __tp, NameLookup __parent)
		throws NullPointerException
	{
		if (__tp == null || __parent == null)
			throw new NullPointerException("NARG");
		
		this.typeparameters = __tp;
		this.parent = __parent;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final TypeSymbol lookupType(TypeSyntax __ts)
		throws NullPointerException, StructureException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/TypeSymbol.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
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.structure;

/**
 * This is used for any symbol which represents a type such as a class or
 * generic type parameter.
 *
 * @since 2018/05/10
 */
@Deprecated
public interface TypeSymbol
	extends StructureSymbol
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/structure/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the parser and the structure representation of the
 * input class path and source code. This parses class files and source files
 * and enables resolution of the virtual machine state.
 *
 * @since 2018/05/03
 */

@Deprecated
package net.multiphasicapps.javac.structure;

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/AnnotationArrayValueSyntax.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This represents an annotation value that represents multiple values in an
 * array.
 *
 * @since 2018/05/02
 */
public final class AnnotationArrayValueSyntax
	implements AnnotationValueSyntax
{
	/** The value which make up this value. */
	private final AnnotationValueSyntax[] _values;
	
	/**
	 * Initializes the array value annotation.
	 *
	 * @param __v The values which make up the annotation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/02
	 */
	public AnnotationArrayValueSyntax(AnnotationValueSyntax... __v)
		throws NullPointerException
	{
		this(Arrays.<AnnotationValueSyntax>asList((__v == null ?
			new AnnotationValueSyntax[0] : __v)));
	}
	
	/**
	 * Initializes the array value annotation.
	 *
	 * @param __v The values which make up the annotation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/02
	 */
	public AnnotationArrayValueSyntax(Iterable<AnnotationValueSyntax> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		List<AnnotationValueSyntax> values = new ArrayList<>();
		for (AnnotationValueSyntax v : __v)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			values.add(v);
		}
		
		this._values = values.<AnnotationValueSyntax>toArray(
			new AnnotationValueSyntax[values.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/02
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof AnnotationArrayValueSyntax))
			return false;
		
		AnnotationArrayValueSyntax o = (AnnotationArrayValueSyntax)__o;
		return Arrays.equals(this._values, o._values);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/02
	 */
	@Override
	public final int hashCode()
	{
		int hash = 0;
		for (Object v : this._values)
			hash ^= v.hashCode();
		return hash;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/02
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/AnnotationKeyValueSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86






















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.MethodName;

/**
 * This represents an annotation value which is a value assigned to a key.
 *
 * @since 2018/05/03
 */
public final class AnnotationKeyValueSyntax
	implements AnnotationValueSyntax
{
	/** The key. */
	protected final MethodName key;
	
	/** The value. */
	protected final AnnotationValueSyntax value;
	
	/**
	 * Initializes the key/value pair.
	 *
	 * @param __k The key.
	 * @param __v The value.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public AnnotationKeyValueSyntax(MethodName __k, AnnotationValueSyntax __v)
		throws NullPointerException
	{
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		this.key = __k;
		this.value = __v;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof AnnotationKeyValueSyntax))
			return false;
		
		AnnotationKeyValueSyntax o = (AnnotationKeyValueSyntax)__o;
		return this.key.equals(o.key) &&
			this.value.equals(o.value);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.key.hashCode() ^
			this.value.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/AnnotationMethodSyntax.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents the method used in an annotation.
 *
 * @since 2018/04/28
 */
public final class AnnotationMethodSyntax
	implements MethodSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final MethodName name()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses a single annotation method.
	 *
	 * @param __mods The modifiers to the method.
	 * @param __in The input tokens.
	 * @return The parsed annotation method.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid method.
	 * @since 2018/04/28
	 */
	public static AnnotationMethodSyntax parse(ModifiersSyntax __mods,
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/AnnotationSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.javac.syntax.expr.ExpressionSyntax;
import net.multiphasicapps.javac.syntax.expr.ExpressionSyntaxParsers;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a single annotation.
 *
 * @since 2018/04/21
 */
public final class AnnotationSyntax
	implements AnnotationValueSyntax, ModifierSyntax
{
	/** The identifier which identifies the annotation. */
	protected final QualifiedIdentifierSyntax identifier;
	
	/** The parameters to the annotation */
	private final AnnotationValueSyntax[] _values;
	
	/**
	 * Initializes the annotation which is just a marker.
	 *
	 * @param __qi The identifier used to identify the annotation.
	 * @param __values The values to the annotation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/01
	 */
	public AnnotationSyntax(QualifiedIdentifierSyntax __qi,
		AnnotationValueSyntax... __values)
		throws NullPointerException
	{
		this(__qi, Arrays.<AnnotationValueSyntax>asList(
			(__values == null ? new AnnotationValueSyntax[0] : __values)));
	}
	
	/**
	 * Initializes the annotation which contains the given unparsed arguments.
	 *
	 * @param __qi The identifier used to identify the annotation.
	 * @param __values The values to the annotation.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/01
	 */
	public AnnotationSyntax(QualifiedIdentifierSyntax __qi,
		Iterable<AnnotationValueSyntax> __values)
		throws NullPointerException
	{
		if (__qi == null || __values == null)
			throw new NullPointerException("NARG");
		
		// Check values
		List<AnnotationValueSyntax> values = new ArrayList<>();
		for (AnnotationValueSyntax v : __values)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			values.add(v);
		}
		
		this.identifier = __qi;
		this._values = values.<AnnotationValueSyntax>toArray(
			new AnnotationValueSyntax[values.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof AnnotationSyntax))
			return false;
		
		AnnotationSyntax o = (AnnotationSyntax)__o;
		return this.identifier.equals(o.identifier) &&
			Arrays.equals(this._values, o._values);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final int hashCode()
	{
		int hash = 0;
		for (Object v : this._values)
			hash ^= v.hashCode();
		
		return this.identifier.hashCode() ^ hash;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * This parses a single annotation.
	 *
	 * @param __in The input token source.
	 * @return The parsed annotation.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the annotation is not valid.
	 * @since 2018/04/21
	 */
	public static AnnotationSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ13 Expected at symbol at start of annotation.}
		Token token = __in.next();
		if (token.type() != TokenType.SYMBOL_AT)
			throw new SyntaxParseException(token, "AQ13");
		
		// Read qualified identifier which identifies the type used for the
		// annotation
		QualifiedIdentifierSyntax qi = QualifiedIdentifierSyntax.parse(__in);
		
		// If there is no open parenthesis then it is just a marker
		token = __in.peek();
		if (token.type() != TokenType.SYMBOL_OPEN_PARENTHESIS)
			return new AnnotationSyntax(qi);
		
		// Consume token, not needed
		__in.next();
		
		// Quick check to see if there are no values to parse
		token = __in.peek();
		if (token.type() == TokenType.SYMBOL_CLOSED_PARENTHESIS)
		{
			__in.next();
			return new AnnotationSyntax(qi);
		}
		
		// Annotations may now have values so handle them accordingly
		List<AnnotationValueSyntax> values = new ArrayList<>();
		for (;;)
		{
			// Read single annotation value which may be a key
			values.add(AnnotationSyntax.parseKey(__in));
			
			// No more values?
			token = __in.peek();
			if (token.type() == TokenType.SYMBOL_CLOSED_PARENTHESIS)
			{
				__in.next();
				break;
			}
			
			// Reading more of them
			else if (token.type() == TokenType.SYMBOL_COMMA)
			{
				__in.next();
				continue;
			}
			
			// {@squirreljme.error AQ14 Expected comma or closing parenthesis
			// at end of annotation expression.}
			else
				throw new SyntaxParseException(token, "AQ14");
		}
		
		// Build annotation
		return new AnnotationSyntax(qi, values);
	}
	
	/**
	 * Parses either a value or a key and a value.
	 *
	 * @param __in The input token source.
	 * @return The parsed value.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the value is not valid.
	 * @since 2018/05/03
	 */
	public static AnnotationValueSyntax parseKey(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		Token token = __in.peek(),
			after = __in.peek(1);
		
		// Does this contain a key associated with a value?
		if (token.type() == TokenType.IDENTIFIER &&
			after.type() == TokenType.OPERATOR_ASSIGN)
		{
			// Consume identifier and the equals
			token = __in.next();
			after = __in.next();
			
			todo.DEBUG.note("Annotation kv: %s %s", token, after);
			
			// Setup key and parse value too
			return new AnnotationKeyValueSyntax(
				new MethodName(token.characters()),
				AnnotationSyntax.parseValue(__in));
		}
		
		// Just a value
		return AnnotationSyntax.parseValue(__in);
	}
	
	/**
	 * This parses a single value.
	 *
	 * @param __in The input token source.
	 * @return The parsed value.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the value is not valid.
	 * @since 2018/05/02
	 */
	public static AnnotationValueSyntax parseValue(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		Token token = __in.peek();
		
		// Recursive read of annotation argument
		if (token.type() == TokenType.SYMBOL_AT)
			return AnnotationSyntax.parse(__in);
		
		// Is a kind of array
		else if (token.type() == TokenType.SYMBOL_OPEN_BRACE)
		{
			// Consume that
			__in.next();
			
			// Quick end of array value?
			token = __in.peek();
			if (token.type() == TokenType.SYMBOL_CLOSED_BRACE)
			{
				__in.next();
				return new AnnotationArrayValueSyntax();
			}
			
			// Read in values
			List<AnnotationValueSyntax> values = new ArrayList<>();
			for (;;)
			{
				// Read in next value
				values.add(AnnotationSyntax.parseValue(__in));
				
				// Stop parsing?
				token = __in.peek();
				if (token.type() == TokenType.SYMBOL_CLOSED_BRACE)
				{
					__in.next();
					break;
				}
				
				// Continue
				else if (token.type() == TokenType.SYMBOL_COMMA)
				{
					// Consume that
					__in.next();
					
					// There could be a comma before the closing brace
					token = __in.peek();
					if (token.type() == TokenType.SYMBOL_CLOSED_BRACE)
					{
						__in.next();
						break;
					}
					
					// Keep reading more
					continue;
				}
				
				// {@squirreljme.error AQ15 Expected comma or closing brace
				// after annotation value.}
				else
					throw new SyntaxParseException(token, "AQ15");
			}
			
			// Finish values
			return new AnnotationArrayValueSyntax(values);
		}
		
		// Normal expression
		else
			 return ExpressionSyntaxParsers.parseExpression(__in);
	}	
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/AnnotationValueSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This interface is used to represent anything that can be used as a value
 * for an annotation.
 *
 * @since 2018/05/02
 */
public interface AnnotationValueSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/BasicFieldSyntax.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a basic field.
 *
 * @since 2018/04/28
 */
public final class BasicFieldSyntax
	implements FieldSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final FieldName name()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses a basic field that is contained within a class.
	 *
	 * @param __mods The modifiers to the field.
	 * @param __in The input tokens.
	 * @return The parsed field.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid field.
	 * @since 2018/04/28
	 */
	public static BasicFieldSyntax parse(ModifiersSyntax __mods,
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/BasicModifierSyntax.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents a basic modifier.
 *
 * @since 2018/04/21
 */
public enum BasicModifierSyntax
	implements ModifierSyntax
{
	/** Public access. */
	PUBLIC,
	
	/** Protected access. */
	PROTECTED,
	
	/** Private access. */
	PRIVATE,
	
	/** Static access. */
	STATIC,
	
	/** Abstract. */
	ABSTRACT,
	
	/** Final. */
	FINAL,
	
	/** Native. */
	NATIVE,
	
	/** Synchronized. */
	SYNCHRONIZED,
	
	/** Transient. */
	TRANSIENT,
	
	/** Volatile. */
	VOLATILE,
	
	/** Strict floating point. */
	STRICTFP,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/BasicTypeSyntax.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents a basic type.
 *
 * @since 2018/04/30
 */
public enum BasicTypeSyntax
	implements SimpleTypeSyntax
{
	/** Byte. */
	BYTE,
	
	/** Short. */
	SHORT,
	
	/** Character. */
	CHARACTER,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Float. */
	FLOAT,
	
	/** Double. */
	DOUBLE,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ClassConstructorSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282


























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.ClassIdentifier;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a constructor that is available for a class.
 *
 * @since 2018/04/28
 */
public final class ClassConstructorSyntax
	implements MapView, MethodSyntax
{
	/** ModifiersSyntax to the constructor. */
	protected final ModifiersSyntax modifiers;
	
	/** TypeSyntax parameters used. */
	protected final TypeParametersSyntax typeparameters;
	
	/** The identifier of the constructor. */
	protected final MethodName name;
	
	/** The code which makes up the constructor. */
	protected final UnparsedExpressions code;
	
	/** The formal parameters. */
	protected final FormalParametersSyntax parameters;
	
	/** The thrown classes. */
	private final QualifiedIdentifierSyntax[] _thrown;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the constructor information.
	 *
	 * @param __mods Constructor modifiers.
	 * @param __tparms TypeSyntax parameters used.
	 * @param __ident The identifier for the constructor.
	 * @param __params TypeSyntax parameters.
	 * @param __thrown Exceptions which are thrown by the constructor.
	 * @param __code The code which makes up the constructor.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxDefinitionException If the definition is not valid.
	 * @since 2018/04/29
	 */
	public ClassConstructorSyntax(ModifiersSyntax __mods,
		TypeParametersSyntax __tparms, ClassIdentifier __ident,
		FormalParametersSyntax __params, QualifiedIdentifierSyntax[] __thrown,
		UnparsedExpressions __code)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__mods == null || __tparms == null || __ident == null ||
			__params == null || __thrown == null || __code == null)
			throw new NullPointerException("NARG");
		
		// Check throwables for null
		Set<QualifiedIdentifierSyntax> thrown = new LinkedHashSet<>();
		for (QualifiedIdentifierSyntax t : (__thrown = __thrown.clone()))
		{
			if (t == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ16 Duplicated throw statement. (The throw
			// statement which was duplicated)}
			if (thrown.contains(t))
				throw new SyntaxDefinitionException(
					String.format("AQ16 %s", t));
			
			thrown.add(t);
		}
		
		// {@squirreljme.error AQ17 Illegal modifiers specified for class
		// constructor. (The modifiers)}
		if (__mods.isStatic() || __mods.isAbstract() || __mods.isFinal() ||
			__mods.isNative() || __mods.isSynchronized() ||
			__mods.isTransient() || __mods.isVolatile() ||
			__mods.isStrictFloatingPoint())
			throw new SyntaxDefinitionException(
				String.format("AQ17 %s", __mods));
		
		this.modifiers = __mods;
		this.typeparameters = __tparms;
		this.name = new MethodName(__ident.toString());
		this.parameters = __params;
		this.code = __code;
		this._thrown = __thrown;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("modifiers", this.modifiers).
				add("typeparams", this.typeparameters).
				add("name", this.name).
				add("parameters", this.parameters).
				addList("thrown", (Object[])this._thrown).
				add("code", this.code).build()));
		
		return rv;
	}
	
	/**
	 * Returns the code for this constructor if there is any.
	 *
	 * @return The method code, may be {@code null} if there is none.
	 * @since 2018/05/08
	 */
	public final UnparsedExpressions code()
	{
		return this.code;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the formal parameters for the constructor.
	 *
	 * @return The constructor formal parameters.
	 * @since 2018/05/08
	 */
	public final FormalParametersSyntax formalParameters()
	{
		return this.parameters;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		return this.modifiers;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final MethodName name()
	{
		return this.name;
	}
	
	/**
	 * Returns the types which are thrown from this constructor.
	 *
	 * @return The types which are thrown.
	 * @since 2018/05/08
	 */
	public final List<QualifiedIdentifierSyntax> thrownTypes()
	{
		return UnmodifiableArrayList.<QualifiedIdentifierSyntax>of(
			this._thrown);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Returns the type parameters for the constructor.
	 *
	 * @return The constructor type parameters.
	 * @since 2018/05/08
	 */
	public final TypeParametersSyntax typeParameters()
	{
		return this.typeparameters;
	}
	
	/**
	 * Parses a single class constrictor.
	 *
	 * @param __mods The modifiers to the method.
	 * @param __typeparams TypeSyntax parameters.
	 * @param __in The input tokens.
	 * @return The parsed constructor.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid constructor.
	 * @since 2018/04/28
	 */
	public static ClassConstructorSyntax parse(ModifiersSyntax __mods,
		TypeParametersSyntax __typeparams, BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __typeparams == null || __in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ18 Expected identifier at start of
		// constructor.}
		Token token = __in.next();
		if (token.type() != TokenType.IDENTIFIER)
			throw new SyntaxParseException(token, "AQ18");
		ClassIdentifier identifier = new ClassIdentifier(token.characters());
		
		// Parse formal parameters
		FormalParametersSyntax params = FormalParametersSyntax.parse(__in);
		
		// Parse throws
		QualifiedIdentifierSyntax[] thrown;
		token = __in.peek();
		if (token.type() == TokenType.KEYWORD_THROWS)
		{
			__in.next();
			thrown = QualifiedIdentifierSyntax.parseList(__in);
		}
		else
			thrown = new QualifiedIdentifierSyntax[0];
		
		// Parse constructor block and build
		return new ClassConstructorSyntax(__mods, __typeparams, identifier,
			params, thrown, UnparsedExpressions.parseBlock(__in));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ClassInitializerSyntax.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
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

































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents an initializer for a method.
 *
 * @since 2018/04/28
 */
public final class ClassInitializerSyntax
	implements MethodSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final MethodName name()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses a single class initializer.
	 *
	 * @param __mods The modifiers to the method.
	 * @param __in The input tokens.
	 * @return The parsed initializer.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid method.
	 * @since 2018/04/28
	 */
	public static ClassInitializerSyntax parse(ModifiersSyntax __mods,
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ClassSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
















































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.ClassIdentifier;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This class represents the structure of a class, it will contains members
 * such as fields, methods, and other classes.
 *
 * @since 2018/04/21
 */
public final class ClassSyntax
	implements MapView, MemberSyntax
{
	/** The type of class this is. */
	protected final ClassSyntaxType type;
	
	/** The modifiers to the class. */
	protected final ModifiersSyntax modifiers;
	
	/** The name of the class. */
	protected final ClassIdentifier name;
	
	/** The type parameters of the class. */
	protected final TypeParametersSyntax typeparams;
	
	/** The extending types. */
	private final TypeSyntax[] _extends;
	
	/** The implementing types. */
	private final TypeSyntax[] _implements;
	
	/** The members of the class. */
	private final MemberSyntax[] _members;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the class structure information.
	 *
	 * @param __structtype The type of structure used.
	 * @param __mods The modifiers to the class.
	 * @param __name The name of the class.
	 * @param __typeparms The type parameters of the class.
	 * @param __extending The classes this class extends.
	 * @param __implementing The classes this class implements.
	 * @param __members The members of this class.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxDefinitionException If the structure is not valid.
	 * @since 2018/04/27
	 */
	public ClassSyntax(ClassSyntaxType __structtype, ModifiersSyntax __mods,
		ClassIdentifier __name, TypeParametersSyntax __typeparms,
		TypeSyntax[] __extending, TypeSyntax[] __implementing,
		MemberSyntax[] __members)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__structtype == null || __mods == null || __name == null ||
			__typeparms == null || __extending == null ||
			__implementing == null || __members == null)
			throw new NullPointerException();
		
		// {@squirreljme.error AQ19 Illegal class modifiers specified with the
		// the given class type. (The class type; The class modifiers)}
		if (__mods.isNative() || __mods.isVolatile() || __mods.isTransient() ||
			__mods.isSynchronized() ||
			(__structtype == ClassSyntaxType.ENUM &&
				(__mods.isAbstract() || __mods.isFinal())) ||
			(__structtype == ClassSyntaxType.INTERFACE &&
				(__mods.isFinal())))
			throw new SyntaxDefinitionException(String.format("AQ19 %s %s",
				__structtype, __mods));
		
		// Check extends
		Set<TypeSyntax> doext = new LinkedHashSet<>();
		for (TypeSyntax t : __extending)
		{
			if (t == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ1a Duplicate extends specified.
			// (The type)}
			if (doext.contains(t))
				throw new SyntaxDefinitionException(String.format("AQ1a %s",
					t));
			
			doext.add(t);
		}
		
		// {@squirreljme.error AQ1b The specified class of the given type
		// cannot extend the given types. (The class type; The inherited types}
		if (!__structtype.extendsType().isCompatibleCount(doext.size()))
			throw new SyntaxDefinitionException(
				String.format("AQ1b %s %s", __structtype, doext));
		
		// Check implements
		Set<TypeSyntax> doimp = new LinkedHashSet<>();
		for (TypeSyntax t : __implementing)
		{
			if (t == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ1c Duplicate implements specified.
			// (The type)}
			if (doimp.contains(t))
				throw new SyntaxDefinitionException(String.format("AQ1c %s",
					t));
			
			doimp.add(t);
		}
		
		// {@squirreljme.error AQ1d The specified class of the given type
		// cannot implement the given types. (The class type; The inherited
		// types}
		if (!__structtype.implementsType().isCompatibleCount(doimp.size()))
			throw new SyntaxDefinitionException(
				String.format("AQ1d %s %s", __structtype, doext));
		
		// Check members
		List<MemberSyntax> membs = new ArrayList<>();
		for (MemberSyntax member : __members)
		{
			if (member == null)
				throw new NullPointerException("NARG");
			
			// Interfaces
			if (__structtype == ClassSyntaxType.INTERFACE)
			{
				// {@squirreljme.error AQ1e An interface cannot contain a
				// member represented by the given type. (The class type)}
				if (member instanceof ClassInitializerSyntax ||
					member instanceof ClassConstructorSyntax ||
					member instanceof AnnotationMethodSyntax ||
					member instanceof EnumFieldSyntax)
					throw new SyntaxDefinitionException(
						String.format("AQ1e %s", member.getClass()));
			}
			
			// Annotations
			else if (__structtype == ClassSyntaxType.ANNOTATION)
			{
				// {@squirreljme.error AQ1f An annotation cannot contain a
				// member represented by the given type. (The class type)}
				if (!(member instanceof ClassSyntax ||
					member instanceof BasicFieldSyntax ||
					member instanceof AnnotationMethodSyntax))
					throw new SyntaxDefinitionException(
						String.format("AQ1f %s", member.getClass()));
			}
			
			// Normal class or enum
			else
			{
				// {@squirreljme.error AQ1g An class or enum cannot contain a
				// member represented by the given type. (The class type)}
				if (member instanceof AnnotationMethodSyntax)
					throw new SyntaxDefinitionException(
						String.format("AQ1g %s", member.getClass()));
			}
			
			// Check constructor
			if (member instanceof ClassConstructorSyntax)
			{
				ClassConstructorSyntax c = (ClassConstructorSyntax)member;
				
				// {@squirreljme.error AQ1h Class constructor name does not
				// match the name of the class. (This class name; The
				// constructor name)}
				if (!__name.toString().equals(c.name().toString()))
					throw new SyntaxDefinitionException(
						String.format("AQ1h %s %s", __name, c.name()));
			}
			
			// Is valid
			membs.add(member);
		}
		
		// Set
		this.type = __structtype;
		this.modifiers = __mods;
		this.name = __name;
		this.typeparams = __typeparms;
		this._extends = doext.<TypeSyntax>toArray(
			new TypeSyntax[doext.size()]);
		this._implements = doimp.<TypeSyntax>toArray(
			new TypeSyntax[doimp.size()]);
		this._members = membs.<MemberSyntax>toArray(
			new MemberSyntax[membs.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("type", this.type).
				add("modifiers", this.modifiers).
				add("name", this.name).
				add("typeparams", this.typeparams).
				addList("extends", (Object[])this._extends).
				addList("implements", (Object[])this._implements).
				addList("members", (Object[])this._members).build()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/08
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the types this class extends.
	 *
	 * @return The classes which this extends.
	 * @since 2018/05/08
	 */
	public final List<TypeSyntax> extending()
	{
		return UnmodifiableArrayList.<TypeSyntax>of(this._extends);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/08
	 */
	@Override
	public final int hashCode()
	{
		return this.type.hashCode() ^
			this.modifiers.hashCode() ^
			this.name.hashCode() ^
			this.typeparams.hashCode() ^
			Arrays.asList(this._extends).hashCode() ^
			Arrays.asList(this._implements).hashCode() ^
			Arrays.asList(this._members).hashCode();
	}
	
	/**
	 * Returns the types this class implements.
	 *
	 * @return The classes this implements.
	 * @since 2018/05/08
	 */
	public final List<TypeSyntax> implementing()
	{
		return UnmodifiableArrayList.<TypeSyntax>of(this._implements);
	}
	
	/**
	 * Returns the members of this class.
	 *
	 * @return The class members.
	 * @since 2018/05/08
	 */
	public final List<MemberSyntax> members()
	{
		return UnmodifiableArrayList.<MemberSyntax>of(this._members);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		return this.modifiers;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ClassIdentifier name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/08
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Returns the type of class this is.
	 *
	 * @return The class type.
	 * @since 2018/05/08
	 */
	public final ClassSyntaxType type()
	{
		return this.type;
	}
	
	/**
	 * Returns the type parameters for this class.
	 *
	 * @return The type parameters used.
	 * @since 2018/05/08
	 */
	public final TypeParametersSyntax typeParameters()
	{
		return this.typeparams;
	}
	
	/**
	 * Parses the body of the class.
	 *
	 * @param __structtype The structure type of the class.
	 * @param __in The input token source.
	 * @return The parsed members of the class.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the members of the body are not
	 * correct.
	 * @since 2018/04/27
	 */
	public static MemberSyntax[] parseClassBody(
		ClassSyntaxType __structtype, BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ1i Expected opening brace at start of class.}
		Token token = __in.next();
		if (token.type() != TokenType.SYMBOL_OPEN_BRACE)
			throw new SyntaxParseException(token, "AQ1i");
		
		// Parse the enumeration constants, their fields and their class
		// values
		if (__structtype == ClassSyntaxType.ENUM)
		{
			throw new todo.TODO();
		}
		
		// Member parsing loop
		List<MemberSyntax> rv = new ArrayList<>();
		for (;;)
		{
			// End of members?
			token = __in.peek();
			if (token.type() == TokenType.SYMBOL_CLOSED_BRACE)
				return rv.<MemberSyntax>toArray(
					new MemberSyntax[rv.size()]);
			
			// Ignore semi-colons just lying around in the class
			else if (token.type() == TokenType.SYMBOL_SEMICOLON)
				continue;
			
			// Parse modifiers since this will modify how things are parsed
			ModifiersSyntax mods = ModifiersSyntax.parse(__in);
			
			// Always try to parse a class since any kind of class can include
			// classes
			try
			{
				// Parse the class
				__in.mark();
				rv.add(ClassSyntax.parseEntireClass(mods, __in));
				
				// Do not try parsing anything else for now
				__in.commit();
				continue;
			}
			catch (SyntaxParseException e)
			{
				__in.reset();
			}
			
			// Try to parse a method
			try
			{
				// Parse method
				__in.mark();
				rv.add(ClassSyntax.parseMethod(__structtype, mods, __in));
				
				// Valid method
				__in.commit();
				continue;
			}
			catch (SyntaxParseException e)
			{
				__in.reset();
			}
			
			// Try to parse a field
			try
			{
				// Parse field
				__in.mark();
				rv.add(ClassSyntax.parseField(__structtype, mods, __in));
				
				// Valid field
				__in.commit();
				continue;
			}
			catch (SyntaxParseException e)
			{
				__in.reset();
			}
			
			// {@squirreljme.error AQ1j The specified token does not
			// represent a member that is a class, field, or method.}
			throw new SyntaxParseException(__in, "AQ1j");
		}
	}
	
	/**
	 * Attempts to parse an entire class.
	 *
	 * @param __mods Class modifiers.
	 * @param __in The input token source.
	 * @return The parsed class structure.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If this is not a class.
	 * @since 2018/04/22
	 */
	public static ClassSyntax parseEntireClass(ModifiersSyntax __mods,
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		Token token;
		
		// Determine the class type based on the next token
		ClassSyntaxType structtype;
		token = __in.next();
		switch (token.type())
		{
			case KEYWORD_CLASS:
				structtype = ClassSyntaxType.CLASS;
				break;
				
			case KEYWORD_ENUM:
				structtype = ClassSyntaxType.ENUM;
				break;
				
			case KEYWORD_INTERFACE:
				structtype = ClassSyntaxType.INTERFACE;
				break;
			
				// {@squirreljme.error AQ1k Expected interface to follow
				// at symbol for declaring an annotation type.}
			case SYMBOL_AT:
				token = __in.next();
				if (token.type() != TokenType.KEYWORD_INTERFACE)
					throw new SyntaxParseException(token, "AQ1k");
				structtype = ClassSyntaxType.ANNOTATION;
				break;
			
				// {@squirreljme.error AQ1l Unknown token while parsing class.}
			default:
				throw new SyntaxParseException(token, "AQ1l");
		}
		
		// {@squirreljme.error AQ1m Expected identifier to name the class as.}
		token = __in.next();
		if (token.type() != TokenType.IDENTIFIER)
			throw new SyntaxParseException(token, "AQ1m");
		ClassIdentifier name = new ClassIdentifier(token.characters());
		
		// Read type parameters?
		token = __in.peek();
		TypeParametersSyntax typeparms;
		if (structtype.hasTypeParameters() &&
			token.type() == TokenType.COMPARE_LESS_THAN)
			typeparms = TypeParametersSyntax.parse(__in);
		else
			typeparms = new TypeParametersSyntax();
		
		// Read extends
		token = __in.peek();
		TypeSyntax[] extending;
		if (token.type() == TokenType.KEYWORD_EXTENDS)
		{
			// Consume and parse list
			__in.next();
			switch (structtype.extendsType())
			{
				case SINGLE:
					extending = new TypeSyntax[]{TypeSyntax.parseType(__in)};
					break;
					
				case MULTIPLE:
					extending = TypeSyntax.parseTypes(__in);
					break;
					
					// {@squirreljme.error AQ1n This type of class cannot
					// extend other classes.}
				default:
					throw new SyntaxParseException(token, "AQ1n");
			}
		}
		else
			extending = new TypeSyntax[0];
		
		// Read implements
		token = __in.peek();
		TypeSyntax[] implementing;
		if (token.type() == TokenType.KEYWORD_IMPLEMENTS)
		{
			// Consume and parse list
			__in.next();
			switch (structtype.extendsType())
			{
				case MULTIPLE:
					implementing = TypeSyntax.parseTypes(__in);
					break;
					
					// {@squirreljme.error AQ1o This type of class cannot
					// implement interfaces.}
				default:
					throw new SyntaxParseException(token, "AQ1o");
			}
		}
		else
			implementing = new TypeSyntax[0];
		
		// Read class body which contains all the members
		MemberSyntax[] members = ClassSyntax.parseClassBody(structtype,
			__in);
		
		// {@squirreljme.error AQ1p Expected closing brace at end of class.}
		token = __in.next();
		if (token.type() != TokenType.SYMBOL_CLOSED_BRACE)
			throw new SyntaxParseException(token, "AQ1p");
		
		// Build class structure
		return new ClassSyntax(structtype, __mods, name, typeparms,
			extending, implementing, members);
	}
	
	/**
	 * Parses a single field which is appropriate for a given class type.
	 *
	 * @param __ct The structure of the class.
	 * @param __mods The modifiers to the field.
	 * @param __in The input tokens.
	 * @return The parsed field.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid field.
	 * @since 2018/04/28
	 */
	public static FieldSyntax parseField(ClassSyntaxType __ct,
		ModifiersSyntax __mods, BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__ct == null || __mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Always parse basic fields
		return BasicFieldSyntax.parse(__mods, __in);
	}
	
	/**
	 * Parses a single method which is appropriate for a given class type.
	 *
	 * @param __ct The structure of the class.
	 * @param __mods The modifiers to the method.
	 * @param __in The input tokens.
	 * @return The parsed method.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid method.
	 * @since 2018/04/28
	 */
	public static MethodSyntax parseMethod(ClassSyntaxType __ct,
		ModifiersSyntax __mods, BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__ct == null || __mods == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Annotations only have a single format
		if (__ct == ClassSyntaxType.ANNOTATION)
			return AnnotationMethodSyntax.parse(__mods, __in);
		
		// Initializer method?
		Token token = __in.peek();
		if ((__ct == ClassSyntaxType.CLASS ||
			__ct == ClassSyntaxType.ENUM) &&
			token.type() == TokenType.SYMBOL_OPEN_BRACE)
			try
			{
				// Might not be one
				__in.mark();
				ClassInitializerSyntax rv = ClassInitializerSyntax.
					parse(__mods, __in);
				
				// Is one
				__in.commit();
				return rv;
			}
			catch (SyntaxParseException e)
			{
				__in.reset();
			}
		
		// Parse any type parameters which are used
		TypeParametersSyntax typeparams;
		token = __in.peek();
		if (__ct != ClassSyntaxType.ANNOTATION &&
			token.type() == TokenType.COMPARE_LESS_THAN)
			typeparams = TypeParametersSyntax.parse(__in);
		else
			typeparams = new TypeParametersSyntax();
		
		// Constructor?
		token = __in.peek();
		if (__ct != ClassSyntaxType.INTERFACE &&
			token.type() == TokenType.IDENTIFIER &&
			__in.peek(1).type() == TokenType.SYMBOL_OPEN_PARENTHESIS)
			try
			{
				// Could be one
				__in.mark();
				ClassConstructorSyntax rv = ClassConstructorSyntax.
					parse(__mods, typeparams, __in);
				
				// Is one
				__in.commit();
				return rv;
			}
			catch (SyntaxParseException e)
			{
				__in.reset();
			}
		
		// General method
		return SimpleMethodSyntax.parse(__mods, typeparams, __in);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ClassSyntaxType.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
66
67
68
69
70
71
72
73
74










































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents the type of class.
 *
 * @since 2018/04/21
 */
public enum ClassSyntaxType
{
	/** Normal class. */
	CLASS,
	
	/** Interface. */
	INTERFACE,
	
	/** Enumeration. */
	ENUM,
	
	/** Annotation. */
	ANNOTATION,
	
	/** End. */
	;
	
	/**
	 * Returns the type of inheritence that is used for extends.
	 *
	 * @return The inheritence type used for extends.
	 * @since 2018/04/24
	 */
	public final InheritenceTypeSyntax extendsType()
	{
		if (this == CLASS)
			return InheritenceTypeSyntax.SINGLE;
		else if (this == INTERFACE)
			return InheritenceTypeSyntax.MULTIPLE;
		return InheritenceTypeSyntax.NONE;
	}
	
	/**
	 * Does this type have type parameters?
	 *
	 * @return If it has type parameters.
	 * @since 2018/04/24
	 */
	public final boolean hasTypeParameters()
	{
		return this == CLASS || this == INTERFACE;
	}
	
	/**
	 * Returns the inheritence type used for implements.
	 *
	 * @return The inheritence type for implements.
	 * @since 2018/04/24
	 */
	public final InheritenceTypeSyntax implementsType()
	{
		if (this == CLASS || this == ENUM)
			return InheritenceTypeSyntax.MULTIPLE;
		return InheritenceTypeSyntax.NONE;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/CompilationUnitSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362










































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents the compilation unit which contains the package, the
 * import statements, and any declared classes.
 *
 * @since 2018/04/21
 */
public final class CompilationUnitSyntax
	implements MapView
{
	/** The modifiers for the package. */
	protected final ModifiersSyntax modifiers;
	
	/** The package this compilation unit is in. */
	protected final QualifiedIdentifierSyntax inpackage;
	
	/** The imports being performed. */
	private final ImportStatementSyntax[] _imports;
	
	/** The classes being declared. */
	private final ClassSyntax[] _classes;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the compilation unit.
	 *
	 * @param __pmod The modifiers to the package.
	 * @param __pk The owning package.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxDefinitionException If the compilation unit is not
	 * valid.
	 * @since 2018/04/30
	 */
	public CompilationUnitSyntax(ModifiersSyntax __pmod,
		QualifiedIdentifierSyntax __pk)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__pmod == null || __pk == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ1q Only annotation are valid modifiers for
		// packages.}
		if (__pmod.isPublic() || __pmod.isProtected() || __pmod.isPrivate() ||
			__pmod.isStatic() || __pmod.isAbstract() || __pmod.isFinal() ||
			__pmod.isNative() || __pmod.isSynchronized() ||
			__pmod.isTransient() || __pmod.isVolatile() ||
			__pmod.isStrictFloatingPoint())
			throw new SyntaxDefinitionException(
				String.format("AQ1q %s", __pmod));
		
		this.modifiers = __pmod;
		this.inpackage = __pk;
		this._imports = new ImportStatementSyntax[0];
		this._classes = new ClassSyntax[0];
	}
	
	/**
	 * Initializes the compilation unit.
	 *
	 * @param __pk The owning package.
	 * @param __imports Imports that are used.
	 * @param __classes Classes which have been declared.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxDefinitionException If the compilation unit is not
	 * valid.
	 * @since 2018/04/30
	 */
	public CompilationUnitSyntax(QualifiedIdentifierSyntax __pk,
		ImportStatementSyntax[] __imports, ClassSyntax[] __classes)
		throws NullPointerException, SyntaxDefinitionException
	{
		this(__pk, Arrays.<ImportStatementSyntax>asList(
			__imports == null ? new ImportStatementSyntax[0] : __imports),
			Arrays.<ClassSyntax>asList(__classes == null ?
			new ClassSyntax[0] : __classes));
	}
	
	/**
	 * Initializes the compilation unit.
	 *
	 * @param __pk The owning package.
	 * @param __imports Imports that are used.
	 * @param __classes Classes which have been declared.
	 * @throws NullPointerException On null arguments, except for {@code __pk}.
	 * @throws SyntaxDefinitionException If the compilation unit is not
	 * valid.
	 * @since 2018/04/30
	 */
	public CompilationUnitSyntax(QualifiedIdentifierSyntax __pk,
		Iterable<ImportStatementSyntax> __imports,
		Iterable<ClassSyntax> __classes)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__imports == null || __classes == null)
			throw new NullPointerException("NARG");
		
		// Check imports
		Set<ImportStatementSyntax> imports = new LinkedHashSet<>();
		for (ImportStatementSyntax v : __imports)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			imports.add(v);
		}
		
		// Check classes
		List<ClassSyntax> classes = new ArrayList<>();
		for (ClassSyntax v : __classes)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ1r Classes contained within a compilation
			// unit cannot be static, protected, or private. (The modifiers)}
			ModifiersSyntax modifiers = v.modifiers();
			if (modifiers.isStatic() || modifiers.isProtected() ||
				modifiers.isPrivate())
				throw new SyntaxDefinitionException(
					String.format("AQ1r %s", modifiers));
			
			// Is okay to use
			classes.add(v);
		}
		
		this.modifiers = new ModifiersSyntax();
		this.inpackage = __pk;
		this._imports = imports.<ImportStatementSyntax>toArray(
			new ImportStatementSyntax[imports.size()]);
		this._classes = classes.<ClassSyntax>toArray(
			new ClassSyntax[classes.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("packagemodifiers", this.modifiers).
				add("package", this.inpackage).
				addList("imports", (Object[])this._imports).
				addList("classes", (Object[])this._classes).build()));
		
		return rv;
	}
	
	/**
	 * Returns the classes which have been defined.
	 *
	 * @return The defined classes.
	 * @since 2018/05/07
	 */
	public final List<ClassSyntax> classes()
	{
		return UnmodifiableArrayList.<ClassSyntax>of(this._classes);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the package that this compilation unit is within.
	 *
	 * @return The package of the compilation unit or {@code null} if it is
	 * not in one.
	 * @since 2018/05/07
	 */
	public final BinaryName inPackage()
	{
		QualifiedIdentifierSyntax inpackage = this.inpackage;
		return (inpackage == null ? null : inpackage.name());
	}
	
	/**
	 * Returns the modifiers used for the package.
	 *
	 * @return The package modifiers.
	 * @since 2018/05/07
	 */
	public final ModifiersSyntax packageModifiers()
	{
		return this.modifiers;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Parses the compilation unit of the class file.
	 *
	 * @param __in The input token source.
	 * @return The parsed compilation unit.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the syntax is not valid.
	 * @since 2018/04/21
	 */
	public static CompilationUnitSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// This may be set early for class parse
		ModifiersSyntax modifiers = null;
		
		// The package the class is in, if it is in one
		QualifiedIdentifierSyntax inpackage = null;
		
		// This may be a package-info file which contains annotations
		// associated with a package
		// Detect annotation types here in the event they have no modifiers
		Token token = __in.peek();
		if (token.type() == TokenType.SYMBOL_AT &&
			__in.peek(1).type() != TokenType.KEYWORD_INTERFACE)
			modifiers = ModifiersSyntax.parse(__in);
		
		// Read in the package statement, if it is there
		token = __in.peek();
		if (token.type() == TokenType.KEYWORD_PACKAGE)
		{
			// Consume package
			__in.next();
			
			// Read package declaration
			inpackage = QualifiedIdentifierSyntax.parse(__in);
			
			// {@squirreljme.error AQ1s Expected semi-colon to follow the
			// package statement.}
			token = __in.next();
			if (token.type() != TokenType.SYMBOL_SEMICOLON)
				throw new SyntaxParseException(token, "AQ1s");
			
			// Only semi-colons and EOF may follow
			if (modifiers != null)
			{
				// {@squirreljme.error AQ1t Expected end of file or semicolons
				// after an annotated package statement, annotated packages
				// are only valid in package-info.java.}
				while ((token = __in.next()).type() != TokenType.END_OF_FILE)
					if (token.type() != TokenType.SYMBOL_SEMICOLON)
						throw new SyntaxParseException(token, "AQ1t");
				
				return new CompilationUnitSyntax(modifiers, inpackage);
			}
		}
		
		// Read import statements but if there are modifiers then a class
		// must directly follow
		Set<ImportStatementSyntax> imports = new LinkedHashSet<>();
		if (modifiers == null)
			for (;;)
			{
				// Stop when there are no more imports
				token = __in.peek();
				if (token.type() != TokenType.KEYWORD_IMPORT)
					break;
				
				// Parse import statement
				imports.add(ImportStatementSyntax.parse(__in));
			}
		
		// Read in classes
		List<ClassSyntax> classes = new ArrayList<>();
		for (;;)
		{
			// Need to read in the class modifiers
			if (modifiers == null)
			{
				// Ignore semi-colons
				token = __in.peek();
				if (token.type() == TokenType.SYMBOL_SEMICOLON)
					continue;
				
				// But stop parsing on EOF
				else if (token.type() == TokenType.END_OF_FILE)
					break;
				
				// Parse modifiers
				modifiers = ModifiersSyntax.parse(__in);
			}
			
			// Read entire class container
			ClassSyntax struct = ClassSyntax.parseEntireClass(modifiers,
				__in);
			classes.add(struct);
			
			// Clear modifiers so that they are not used again
			modifiers = null;
		}
		
		return new CompilationUnitSyntax(inpackage, imports, classes);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/EnumFieldSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * A field which represents an enumeration.
 *
 * @since 2018/04/30
 */
public final class EnumFieldSyntax
	implements FieldSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final FieldName name()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/FieldSyntax.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a field which may have a value for a class.
 *
 * @since 2018/04/28
 */
public interface FieldSyntax
	extends MemberSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public abstract FieldName name();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/FormalParameterSyntax.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a single formal parameter which may be a part of a class.
 *
 * @since 2018/04/28
 */
public final class FormalParameterSyntax
	implements MapView
{
	/** The modifiers used. */
	protected final ModifiersSyntax modifiers;
	
	/** The type. */
	protected final TypeSyntax type;
	
	/** The name of the field. */
	protected final FieldName name;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the formal parameter.
	 *
	 * @param __mods The modifiers for the parameter.
	 * @param __type The type used.
	 * @param __name The name of the parameter.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxDefinitionException If the definition is not valid.
	 * @since 2018/04/30
	 */
	public FormalParameterSyntax(ModifiersSyntax __mods, TypeSyntax __type,
		FieldName __name)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__mods == null || __type == null || __name == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ1u Illegal modifiers specified for formal
		// parameter. (The modifiers}}
		if (__mods.isPublic() || __mods.isProtected() || __mods.isPrivate() ||
			__mods.isStatic() || __mods.isAbstract() || __mods.isNative() ||
			__mods.isSynchronized() || __mods.isTransient() ||
			__mods.isVolatile() || __mods.isStrictFloatingPoint())
			throw new SyntaxDefinitionException(
				String.format("AQ1u %s", __mods));
		
		this.modifiers = __mods;
		this.type = __type;
		this.name = __name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("modifiers", this.modifiers).
				add("type", this.type).
				add("name", this.name).build()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Returns the modifiers that the formal parameter uses.
	 *
	 * @return The modifies for the formal parameter.
	 * @since 2018/05/10
	 */
	public final ModifiersSyntax modifiers()
	{
		return this.modifiers;
	}
	
	/**
	 * Returns the name of the parameter.
	 *
	 * @return The name of the parameter.
	 * @since 2018/05/10
	 */
	public final FieldName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Returns the type of the formal parameter.
	 *
	 * @return The type used.
	 * @since 2018/05/10
	 */
	public final TypeSyntax type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/FormalParametersSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231







































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.collections.UnmodifiableIterator;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents the formal parameters of a method.
 *
 * @since 2018/04/29
 */
public final class FormalParametersSyntax
	implements Iterable<FormalParameterSyntax>
{
	/** Parameters used. */
	private final FormalParameterSyntax[] _parameters;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the formal parameters.
	 *
	 * @param __p The parameters used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/29
	 */
	public FormalParametersSyntax(FormalParameterSyntax... __p)
		throws NullPointerException
	{
		this(Arrays.<FormalParameterSyntax>asList(
			(__p == null ? new FormalParameterSyntax[0] : __p)));
	}
	
	/**
	 * Initializes the formal parameters.
	 *
	 * @param __p The parameters used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/29
	 */
	public FormalParametersSyntax(Iterable<FormalParameterSyntax> __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		List<FormalParameterSyntax> parms = new ArrayList<>();
		for (FormalParameterSyntax p : __p)
		{
			if (p == null)
				throw new NullPointerException("NARG");
			
			parms.add(p);
		}
		
		this._parameters = parms.<FormalParameterSyntax>toArray(
			new FormalParameterSyntax[parms.size()]);
	}
	
	/**
	 * Returns the descriptor for these parameters.
	 *
	 * @return The method descriptor used.
	 * @since 2018/04/29
	 */
	public final MethodDescriptor descriptor()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/10
	 */
	@Override
	public final Iterator<FormalParameterSyntax> iterator()
	{
		return UnmodifiableIterator.<FormalParameterSyntax>of(
			this._parameters);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				Arrays.asList(this._parameters).toString()));
		
		return rv;
	}
	
	/**
	 * Parses formal parameters which are part of a description of a method.
	 *
	 * @param __in The input tokens.
	 * @return The parsed formal parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If a formal parameter is not correct.
	 * @since 2018/04/28
	 */
	public static FormalParametersSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ1v Expected opening parenthesis when parsing
		// formal parameters.}
		Token token = __in.next();
		if (token.type() != TokenType.SYMBOL_OPEN_PARENTHESIS)
			throw new SyntaxParseException("AQ1v");
		
		// Parse each one
		List<FormalParameterSyntax> rv = new ArrayList<>();
		for (;;)
		{
			token = __in.peek();
			
			// End of parameters
			if (token.type() == TokenType.SYMBOL_CLOSED_PARENTHESIS)
			{
				__in.next();
				break;
			}
			
			// Parse modifiers
			ModifiersSyntax mods = ModifiersSyntax.
				parseForFormalParameter(__in);
			
			// Parse type
			TypeSyntax type = TypeSyntax.parseType(__in);
			
			// Is this a variadic argument?
			boolean isvariadic;
			token = __in.peek();
			if ((isvariadic = (token.type() == TokenType.SYMBOL_ELLIPSES)))
				__in.next();
			
			// {@squirreljme.error AQ1w Expected identifier for the parameter
			// name.}
			token = __in.next();
			if (token.type() != TokenType.IDENTIFIER)
				throw new SyntaxParseException(token, "AQ1w");
			FieldName name = new FieldName(token.characters());
			
			// Add arrays accordingly
			int extradims = 0;
			while ((token = __in.peek()).type() ==
				TokenType.SYMBOL_OPEN_BRACKET)
			{
				// {@squirreljme.error AQ1x Expected closing bracket to follow
				// opening bracket for array declaration.}
				__in.next();
				if (__in.next().type() != TokenType.SYMBOL_CLOSED_BRACKET)
					throw new SyntaxParseException(token, "AQ1x");
				
				extradims++;
			}
			
			// Were there any extra dimensions?
			if (extradims > 0)
				type = type.withDimensions(type.dimensions() + extradims);
			
			// Setup parameter
			rv.add(new FormalParameterSyntax(mods, type, name));
			
			// {@squirreljme.error AQ1y Expected closing parenthesis to follow
			// variadic argument in formal parameter.}
			token = __in.peek();
			if (isvariadic && token.type() !=
				TokenType.SYMBOL_CLOSED_PARENTHESIS)
				throw new SyntaxParseException(token, "AQ1y");
			
			// Consume comma
			if (token.type() == TokenType.SYMBOL_COMMA)
				__in.next();
		}
		
		return new FormalParametersSyntax(rv);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/GenericTypeSyntax.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a generic type with a qualified identifier with potential
 * type bounds.
 *
 * @since 2018/04/30
 */
public final class GenericTypeSyntax
	implements SimpleTypeSyntax
{
	/** The identifier. */
	protected final QualifiedIdentifierSyntax identifier;
	
	/** Is there generic info? */
	protected final boolean hasgenerics;
	
	/**
	 * Initializes the generic type with no generic information.
	 *
	 * @param __id The identifier.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/30
	 */
	public GenericTypeSyntax(QualifiedIdentifierSyntax __id)
		throws NullPointerException
	{
		if (__id == null)
			throw new NullPointerException("NARG");
		
		this.identifier = __id;
		this.hasgenerics = false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/30
	 */
	@Override
	public final String toString()
	{
		if (!this.hasgenerics)
			return this.identifier.toString();
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the generic type.
	 *
	 * @param __in The input token source.
	 * @return The generic type.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the generic type is not valid.
	 * @since 2018/04/30
	 */
	public static GenericTypeSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// There will always be a qualified identifier
		QualifiedIdentifierSyntax ident =
			QualifiedIdentifierSyntax.parse(__in);
		
		// Is there generic type information?
		Token token = __in.peek();
		if (token.type() == TokenType.COMPARE_LESS_THAN)
			throw new todo.TODO();
		
		// Just a plain type
		return new GenericTypeSyntax(ident);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ImportStatementSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260




































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Map;
import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a single import statement.
 *
 * @since 2018/04/21
 */
public final class ImportStatementSyntax
	implements MapView
{
	/** Is this static? */
	protected final boolean isstatic;
	
	/** The imported class. */
	protected final BinaryName what;
	
	/** Is it a wildcard? */
	protected final boolean wildcard;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the import declaration.
	 *
	 * @param __static Is this static?
	 * @param __what What is being imported.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/14
	 */
	public ImportStatementSyntax(boolean __static, BinaryName __what)
		throws NullPointerException
	{
		if (__what == null)
			throw new NullPointerException("NARG");
		
		this.isstatic = __static;
		this.what = __what;
		this.wildcard = __what.toString().endsWith("/*");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("static", this.isstatic).
				add("wildcard", this.wildcard).
				add("what", this.what).build()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof ImportStatementSyntax))
			return false;
		
		ImportStatementSyntax o = (ImportStatementSyntax)__o;
		return this.isstatic == o.isstatic &&
			this.what.equals(o.what);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final int hashCode()
	{
		return this.what.hashCode();
	}
	
	/**
	 * Is this static?
	 *
	 * @return {@code true} if this is static.
	 * @since 2018/04/14
	 */
	public final boolean isStatic()
	{
		return this.isstatic;
	}
	
	/**
	 * Is this a wildcard?
	 *
	 * @return {@code true} if this is a wildcard statement.
	 * @since 2018/04/14
	 */
	public final boolean isWildcard()
	{
		return this.wildcard;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Returns the identifier being imported.
	 *
	 * @return The imported identifier.
	 * @since 2018/04/14
	 */
	public final BinaryName what()
	{
		return this.what;
	}
	
	/**
	 * This parses a single import statement.
	 *
	 * @param __in The input token source.
	 * @return The parsed modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If this is not a valid import statement.
	 * @since 2018/04/21
	 */
	public static ImportStatementSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ1z Expected "import" when parsing an import
		// statement.}
		Token token = __in.next();
		if (token.type() != TokenType.KEYWORD_IMPORT)
			throw new SyntaxParseException(token, "AQ1z");
		
		// Is this static?
		boolean isstatic;
		token = __in.peek();
		if ((isstatic = (token.type() == TokenType.KEYWORD_STATIC)))
			__in.next();
		
		// {@squirreljme.error AQ20 Expected identifier at start of import
		// statement.}
		token = __in.peek();
		if (token.type() != TokenType.IDENTIFIER)
			throw new SyntaxParseException(token, "AQ20");
		
		// Read identifier, due to the wildcard we cannot use
		// QualifiedIdentifierSyntax because an identifier must follow the dot
		StringBuilder sb = new StringBuilder();
		for (;;)
		{
			// {@squirreljme.error AQ21 Expected identifier while parsing the
			// import statement.}
			token = __in.next();
			if (token.type() != TokenType.IDENTIFIER)
				throw new SyntaxParseException(token, "AQ21");
			
			// Build
			sb.append(token.characters());
			
			// Done parsing?
			token = __in.next();
			if (token.type() == TokenType.SYMBOL_SEMICOLON)
				break;
			
			// Parse another statement
			else if (token.type() == TokenType.SYMBOL_DOT)
			{
				// This may be the wildcard statement
				token = __in.peek();
				if (token.type() == TokenType.OPERATOR_MULTIPLY)
				{
					// Consume it
					__in.next();
					
					// {@squirreljme.error AQ22 Expected semicolon to follow
					// the wildcard symbol in the import statement.}
					token = __in.next();
					if (token.type() != TokenType.SYMBOL_SEMICOLON)
						throw new SyntaxParseException(token, "AQ22");
					
					// Add asterisk to make it a wildcard
					sb.append("*");
					break;
				}
				
				// Use slash for binary names
				else
					sb.append("/");
			}
			
			// {@squirreljme.error AQ23 Expected dot or semi-colon to follow
			// the identifier in the import statement.}
			else
				throw new SyntaxParseException(token, "AQ23");
		}
		
		// Attempt to parse binary name
		try
		{
			return new ImportStatementSyntax(isstatic,
				new BinaryName(sb.toString()));
		}
		
		// {@squirreljme.error AQ24 Parsed import declaration is not a valid
		// binary name.}
		catch (InvalidClassFormatException e)
		{
			throw new SyntaxParseException(token, "AQ24");
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/InheritenceTypeSyntax.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

























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents the inheritence type of some class structures.
 *
 * @since 2018/04/24
 */
public enum InheritenceTypeSyntax
{
	/** No inheritence. */
	NONE,
	
	/** Single inheritence. */
	SINGLE,
	
	/** Multiple inheritence. */
	MULTIPLE,
	
	/** End. */
	;
	
	/**
	 * Is the inheritence count valid for the given type?
	 *
	 * @param __n The number of inherited elements.
	 * @return If it is valid or not.
	 * @since 2018/04/30
	 */
	public final boolean isCompatibleCount(int __n)
	{
		switch (this)
		{
			case NONE:
				return __n == 0;
				
			case SINGLE:
				return (__n == 0 || __n == 1);
				
			case MULTIPLE:
				return __n >= 0;
			
			default:
				throw new todo.OOPS();
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/MapView.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.util.Map;

/**
 * This represents syntax which can be represented as a map. This only applies
 * to parts of the syntax tree which have multiple children nodes.
 *
 * @since 2019/01/17
 */
public interface MapView
{
	/**
	 * Returns a representation of this syntax as a map.
	 *
	 * @return The map representing of this syntax.
	 * @since 2019/01/17
	 */
	public abstract Map<String, Object> asMap();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/MemberSyntax.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.Identifier;

/**
 * This interface represents anything which can be a member of a class.
 *
 * @since 2018/04/27
 */
public interface MemberSyntax
{
	/**
	 * Returns the modifiers for the member.
	 *
	 * @return The member modifiers.
	 * @since 2018/04/29
	 */
	public abstract ModifiersSyntax modifiers();
	
	/**
	 * Returns the name of the member.
	 *
	 * @return The name of the member.
	 * @since 2018/04/29
	 */
	public abstract Identifier name();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/MethodSyntax.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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a method which is a member of a class and may contain Java
 * code to be compiled.
 *
 * @since 2018/04/27
 */
public interface MethodSyntax
	extends MemberSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public abstract MethodName name();
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ModifierSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents a modifier which may be associated with a class or member.
 *
 * @since 2018/04/21
 */
public interface ModifierSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/ModifiersSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431















































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents modifiers that are associated with something which may be
 * a basic keyword or an annotation.
 *
 * @since 2018/04/21
 */
public final class ModifiersSyntax
	implements Iterable<ModifierSyntax>
{
	/** The modifiers to use. */
	private final Set<ModifierSyntax> _modifiers;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the modifier set.
	 *
	 * @param __ms The modifiers to use.
	 * @throws NullPointerException If any modifier is null.
	 * @throws SyntaxDefinitionException If a modifier is duplicated or
	 * public, protected, or private are multiply specified.
	 * @since 2018/04/22
	 */
	public ModifiersSyntax(ModifierSyntax... __ms)
		throws NullPointerException, SyntaxDefinitionException
	{
		this(Arrays.<ModifierSyntax>asList(
			(__ms == null ? new ModifierSyntax[0] : __ms)));
	}
	
	/**
	 * Initializes the modifier set.
	 *
	 * @param __ms The modifiers to use.
	 * @throws NullPointerException If any modifier is null.
	 * @throws SyntaxDefinitionException If a modifier is duplicated or
	 * public, protected, or private are multiply specified.
	 * @since 2018/04/22
	 */
	public ModifiersSyntax(Iterable<ModifierSyntax> __ms)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__ms == null)
			throw new NullPointerException("NARG");
		
		// Check modifiers before using them
		Set<ModifierSyntax> modifiers = new LinkedHashSet<>();
		for (ModifierSyntax m : __ms)
		{
			if (m == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ25 Duplicate modifier. (The modifier)}
			if (modifiers.contains(m))
				throw new SyntaxDefinitionException(String.format("AQ25 %s",
					m));
			
			modifiers.add(m);
		}
		
		// {@squirreljme.error AQ26 There may be only one or none specified for
		// public, protected, or private. (The modifiers)}
		boolean a = modifiers.contains(BasicModifierSyntax.PUBLIC),
			b = modifiers.contains(BasicModifierSyntax.PROTECTED),
			c = modifiers.contains(BasicModifierSyntax.PRIVATE);
		if ((a && b) || (a && c) || (b && c))
			throw new SyntaxDefinitionException(String.format("AQ26 %s",
				modifiers));
		
		// Store
		this._modifiers = modifiers;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final Iterator<ModifierSyntax> iterator()
	{
		Set<ModifierSyntax> modifiers = this._modifiers;
		return Arrays.<ModifierSyntax>asList(modifiers.<ModifierSyntax>toArray(
			new ModifierSyntax[modifiers.size()])).iterator();
	}
	
	/**
	 * Is this abstract?
	 *
	 * @return If this is abstract.
	 * @since 2018/04/30
	 */
	public final boolean isAbstract()
	{
		return this._modifiers.contains(BasicModifierSyntax.ABSTRACT);
	}
	
	/**
	 * Is this final?
	 *
	 * @return If this is final.
	 * @since 2018/04/30
	 */
	public final boolean isFinal()
	{
		return this._modifiers.contains(BasicModifierSyntax.FINAL);
	}
	
	/**
	 * Is this native?
	 *
	 * @return If this is native.
	 * @since 2018/04/30
	 */
	public final boolean isNative()
	{
		return this._modifiers.contains(BasicModifierSyntax.NATIVE);
	}
	
	/**
	 * Is this private?
	 *
	 * @return If this is private.
	 * @since 2018/04/30
	 */
	public final boolean isPrivate()
	{
		return this._modifiers.contains(BasicModifierSyntax.PRIVATE);
	}
	
	/**
	 * Is this protected?
	 *
	 * @return If this is protected.
	 * @since 2018/04/30
	 */
	public final boolean isProtected()
	{
		return this._modifiers.contains(BasicModifierSyntax.PROTECTED);
	}
	
	/**
	 * Is this public?
	 *
	 * @return If this is public.
	 * @since 2018/04/30
	 */
	public final boolean isPublic()
	{
		return this._modifiers.contains(BasicModifierSyntax.PUBLIC);
	}
	
	/**
	 * Is this static?
	 *
	 * @return If this is static.
	 * @since 2018/04/30
	 */
	public final boolean isStatic()
	{
		return this._modifiers.contains(BasicModifierSyntax.STATIC);
	}
	
	/**
	 * Is this using strict floating point?
	 *
	 * @return If this is using struct floating point.
	 * @since 2018/04/30
	 */
	public final boolean isStrictFloatingPoint()
	{
		return this._modifiers.contains(BasicModifierSyntax.STRICTFP);
	}
	
	/**
	 * Is this synchronized?
	 *
	 * @return If this is synchronized.
	 * @since 2018/04/30
	 */
	public final boolean isSynchronized()
	{
		return this._modifiers.contains(BasicModifierSyntax.SYNCHRONIZED);
	}
	
	/**
	 * Is this transient?
	 *
	 * @return If this is transient.
	 * @since 2018/04/30
	 */
	public final boolean isTransient()
	{
		return this._modifiers.contains(BasicModifierSyntax.TRANSIENT);
	}
	
	/**
	 * Is this volatile?
	 *
	 * @return If this is volatile.
	 * @since 2018/04/30
	 */
	public final boolean isVolatile()
	{
		return this._modifiers.contains(BasicModifierSyntax.VOLATILE);
	}
	
	/**
	 * Returns the modifiers that have been declared.
	 *
	 * @return The declared modifiers.
	 * @since 2018/05/07
	 */
	public final ModifierSyntax[] modifiers()
	{
		Set<ModifierSyntax> modifiers = this._modifiers;
		return modifiers.<ModifierSyntax>toArray(
			new ModifierSyntax[modifiers.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/21
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				this._modifiers.toString()));
		
		return rv;
	}
	
	/**
	 * This parses modifiers which are associated with something.
	 *
	 * @param __in The input token source.
	 * @return The parsed modifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the modifiers are not valid.
	 * @since 2018/04/21
	 */
	public static ModifiersSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse modifiers
		Set<ModifierSyntax> rv = new LinkedHashSet<>();
		for (;;)
		{
			Token token = __in.peek();
			ModifierSyntax got;
			
			// Is this an annotation? Do not parse @interface as an annotation
			// since that is not valid
			if (token.type() == TokenType.SYMBOL_AT &&
				__in.peek(1).type() != TokenType.KEYWORD_INTERFACE)
				got = AnnotationSyntax.parse(__in);
				
			// Basic modifier?
			else
			{
				// Depends
				switch (token.type())
				{
					case KEYWORD_PUBLIC:
						got = BasicModifierSyntax.PUBLIC;
						break;
						
					case KEYWORD_PROTECTED:
						got = BasicModifierSyntax.PROTECTED;
						break;
						
					case KEYWORD_PRIVATE:
						got = BasicModifierSyntax.PRIVATE;
						break;
						
					case KEYWORD_STATIC:
						got = BasicModifierSyntax.STATIC;
						break;
						
					case KEYWORD_ABSTRACT:
						got = BasicModifierSyntax.ABSTRACT;
						break;
						
					case KEYWORD_FINAL:
						got = BasicModifierSyntax.FINAL;
						break;
						
					case KEYWORD_NATIVE:
						got = BasicModifierSyntax.NATIVE;
						break;
						
					case KEYWORD_SYNCHRONIZED:
						got = BasicModifierSyntax.SYNCHRONIZED;
						break;
						
					case KEYWORD_TRANSIENT:
						got = BasicModifierSyntax.TRANSIENT;
						break;
						
					case KEYWORD_VOLATILE:
						got = BasicModifierSyntax.VOLATILE;
						break;
						
					case KEYWORD_STRICTFP:
						got = BasicModifierSyntax.STRICTFP;
						break;
					
						// No more modifiers to parse
					default:
						return new ModifiersSyntax(rv);
				}
				
				// Consume token to prevent infinite loop
				__in.next();
			}
			
			// {@squirreljme.error AQ27 Duplicate modifier. (The modifier)}
			if (rv.contains(got))
				throw new SyntaxParseException(token,
					String.format("AQ27 %s", got));
			rv.add(got);
		}
	}
	
	/**
	 * This parses modifiers which are associated with formal parameters.
	 *
	 * @param __in The input token source.
	 * @return The parsed modifiers for formal parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the modifiers are not valid.
	 * @since 2018/04/29
	 */
	public static ModifiersSyntax parseForFormalParameter(
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse modifiers
		Set<ModifierSyntax> rv = new LinkedHashSet<>();
		for (;;)
		{
			Token token = __in.peek();
			ModifierSyntax got;
			
			// Annotated formal parameter
			if (token.type() == TokenType.SYMBOL_AT)
				got = AnnotationSyntax.parse(__in);
				
			// Basic modifier?
			else
			{
				// Depends
				switch (token.type())
				{
					case KEYWORD_FINAL:
						got = BasicModifierSyntax.FINAL;
						break;
						
						// No more modifiers to parse
					default:
						return new ModifiersSyntax(rv);
				}
				
				// Consume token to prevent infinite loop
				__in.next();
			}
			
			// {@squirreljme.error AQ28 Duplicate modifier while parsing
			// formal parameter modifiers. (The modifier)}
			if (rv.contains(got))
				throw new SyntaxParseException(token,
					String.format("AQ28 %s", got));
			rv.add(got);
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/QualifiedIdentifierSyntax.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
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

















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a qualified identifier which represents the name of a class.
 *
 * @since 2018/04/10
 */
public final class QualifiedIdentifierSyntax
{
	/** The class this refers to. */
	protected final BinaryName name;
	
	/**
	 * Initializes the qualified identifier.
	 *
	 * @param __bn The identifier name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/13
	 */
	public QualifiedIdentifierSyntax(BinaryName __bn)
		throws NullPointerException
	{
		if (__bn == null)
			throw new NullPointerException("NARG");
		
		this.name = __bn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof QualifiedIdentifierSyntax))
			return false;
		
		return this.name.equals(((QualifiedIdentifierSyntax)__o).name);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final int hashCode()
	{
		return this.name.hashCode();
	}
	
	/**
	 * Returns the binary name of the identifier.
	 *
	 * @return The identifier binary name.
	 * @since 2018/05/07
	 */
	public final BinaryName name()
	{
		return this.name;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/13
	 */
	@Override
	public final String toString()
	{
		return this.name.toString();
	}
	
	/**
	 * Parses a qualified identifier.
	 *
	 * @param __t The input token source.
	 * @return The qualified identifier.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the identifier is not valid.
	 * @since 2018/04/13
	 */
	public static final QualifiedIdentifierSyntax parse(
		BufferedTokenSource __t)
		throws NullPointerException, SyntaxParseException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// The token is always consumed
		Token token = __t.next();
		
		// {@squirreljme.error AQ29 Expected identifier while parsing qualified
		// identifier.
		if (token.type() != TokenType.IDENTIFIER)
			throw new SyntaxParseException(token, "AQ29");
		
		// Start with initial base
		StringBuilder sb = new StringBuilder();
		sb.append(token.characters());
		
		// Try to keep reading identifiers
		for (;;)
		{
			// Parsing no more
			token = __t.peek();
			if (token.type() != TokenType.SYMBOL_DOT)
				break;
			
			// Consume the dot
			__t.next();
			
			// {@squirreljme.error AQ2a Expected identifier to follow
			// dot in qualified identifier.}
			token = __t.next();
			if (token.type() != TokenType.IDENTIFIER)
				throw new SyntaxParseException(token, "AQ2a");
			
			// Add in
			sb.append('/');
			sb.append(token.characters());
		}
		
		// Might not be valid
		try
		{
			return new QualifiedIdentifierSyntax(
				new BinaryName(sb.toString()));
		}
		
		// {@squirreljme.error AQ2b The specified identifier is not a valid
		// binary name. (The identifier)}
		catch (InvalidClassFormatException e)
		{
			throw new SyntaxParseException(token,
				String.format("AQ2b %s", sb), e);
		}
	}
	
	/**
	 * Parses a list of qualified identifiers.
	 *
	 * @param __in The input tokens.
	 * @return The list of qualified identifiers.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the list is not valid.
	 * @since 2018/04/28
	 */
	public static final QualifiedIdentifierSyntax[] parseList(
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/SimpleMethodSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269













































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a simple method.
 *
 * @since 2018/04/28
 */
public final class SimpleMethodSyntax
	implements MapView, MethodSyntax
{
	/** ModifiersSyntax to the constructor. */
	protected final ModifiersSyntax modifiers;
	
	/** TypeSyntax parameters used. */
	protected final TypeParametersSyntax typeparameters;
	
	/** The identifier of the constructor. */
	protected final MethodName name;
	
	/** The code which makes up the constructor. */
	protected final UnparsedExpressions code;
	
	/** The formal parameters. */
	protected final FormalParametersSyntax parameters;
	
	/** The return type. */
	protected final TypeSyntax returntype;
	
	/** The thrown classes. */
	private final QualifiedIdentifierSyntax[] _thrown;
	
	/** Map view. */
	private Reference<Map<String, Object>> _map;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes simple method.
	 *
	 * @param __mods The modifiers.
	 * @param __rtype The return type.
	 * @param __ident The method name.
	 * @param __params The parameters.
	 * @param __thrown The thrown methods.
	 * @param __code The code block, may be {@code null} if abstract or native.
	 * @throws NullPointerException On null arguments except for
	 * {@code __code}.
	 * @throws SyntaxDefinitionException If the structure is not correct.
	 * @since 2018/04/30
	 */
	public SimpleMethodSyntax(ModifiersSyntax __mods,
		TypeParametersSyntax __tparms, TypeSyntax __rtype, MethodName __ident,
		FormalParametersSyntax __params, QualifiedIdentifierSyntax[] __thrown,
		UnparsedExpressions __code)
		throws NullPointerException, SyntaxDefinitionException
	{
		if (__mods == null || __tparms == null || __rtype == null ||
			__ident == null || __params == null || __thrown == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ2c Mismatch between the method having code
		// or not and it being abstract and/or native.}
		if ((__mods.isAbstract() || __mods.isNative()) != (__code == null))
			throw new SyntaxDefinitionException("AQ2c");
		
		// Check throwables for null
		Set<QualifiedIdentifierSyntax> thrown = new LinkedHashSet<>();
		for (QualifiedIdentifierSyntax t : (__thrown = __thrown.clone()))
		{
			if (t == null)
				throw new NullPointerException("NARG");
			
			// {@squirreljme.error AQ2d Duplicated throw statement. (The throw
			// statement which was duplicated)}
			if (thrown.contains(t))
				throw new SyntaxDefinitionException(
					String.format("AQ2d %s", t));
			
			thrown.add(t);
		}
		
		// {@squirreljme.error AQ2e Illegal modifiers specified for simple
		// method. (The modifiers)}
		if ((__mods.isAbstract() && (__mods.isStatic() || __mods.isNative() ||
			__mods.isFinal())) || __mods.isVolatile() || __mods.isTransient())
			throw new SyntaxDefinitionException(
				String.format("AQ2e %s", __mods));
		
		this.modifiers = __mods;
		this.typeparameters = __tparms;
		this.returntype = __rtype;
		this.name = new MethodName(__ident.toString());
		this.parameters = __params;
		this.code = __code;
		this._thrown = __thrown;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/01/17
	 */
	@Override
	public Map<String, Object> asMap()
	{
		Reference<Map<String, Object>> ref = this._map;
		Map<String, Object> rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._map = new WeakReference<>((rv = new __TreeBuilder__().
				add("modifiers", this.modifiers).
				add("typeparams", this.typeparameters).
				add("name", this.name).
				add("return", this.returntype).
				add("parameters", this.parameters).
				addList("thrown", (Object[])this._thrown).
				add("code", this.code).build()));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final ModifiersSyntax modifiers()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/29
	 */
	@Override
	public final MethodName name()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.asMap().toString()));
		
		return rv;
	}
	
	/**
	 * Parses a simple method.
	 *
	 * @param __mods The modifiers to the method.
	 * @param __typeparams TypeSyntax parameters.
	 * @param __in The input tokens.
	 * @return The parsed method.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid method.
	 * @since 2018/04/28
	 */
	public static SimpleMethodSyntax parse(ModifiersSyntax __mods,
		TypeParametersSyntax __typeparams, BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__mods == null || __typeparams == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Read return type
		Token token = __in.peek();
		TypeSyntax returntype;
		if (token.type() == TokenType.KEYWORD_VOID)
		{
			__in.next();
			returntype = TypeSyntax.VOID;
		}
		else
			returntype = TypeSyntax.parseType(__in);
		
		// {@squirreljme.error AQ2f Expected identifier to name the method.}
		token = __in.next();
		if (token.type() != TokenType.IDENTIFIER)
			throw new SyntaxParseException(token, "AQ2f");
		MethodName identifier = new MethodName(token.characters());
		
		// Parse formal parameters
		FormalParametersSyntax params = FormalParametersSyntax.parse(__in);
		
		// Parse throws
		QualifiedIdentifierSyntax[] thrown;
		token = __in.peek();
		if (token.type() == TokenType.KEYWORD_THROWS)
		{
			__in.next();
			thrown = QualifiedIdentifierSyntax.parseList(__in);
		}
		else
			thrown = new QualifiedIdentifierSyntax[0];
		
		// Parse potential code block?
		UnparsedExpressions code;
		if (__mods.isAbstract() || __mods.isNative())
		{
			// No code
			code = null;
			
			// {@squirreljme.error AQ2g Expected semicolon to follow abstract
			// or native method.}
			token = __in.next();
			if (token.type() != TokenType.SYMBOL_SEMICOLON)
				throw new SyntaxParseException(token, "AQ2g");
		}
		else
			code = UnparsedExpressions.parseBlock(__in);
		
		// Initialize simple method
		return new SimpleMethodSyntax(__mods, __typeparams, returntype,
			identifier, params, thrown, code);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/SimpleTypeSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This interface represents a simple type.
 *
 * @since 2018/04/30
 */
public interface SimpleTypeSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/SyntaxDefinitionException.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
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




















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.LocationAware;

/**
 * This is thrown when a structure is not defined correcty.
 *
 * @since 2018/04/30
 */
public class SyntaxDefinitionException
	extends SyntaxException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(LocationAware __la)
	{
		super(__la);
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(LocationAware __la, String __m)
	{
		super(__la, __m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(LocationAware __la, String __m,
		Throwable __c)
	{
		super(__la, __m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2018/04/30
	 */
	public SyntaxDefinitionException(LocationAware __la, Throwable __c)
	{
		super(__la, __c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/SyntaxException.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.LocationAware;

/**
 * This is the base class for exception that occur in the syntax parser.
 *
 * @since 2018/05/05
 */
public class SyntaxException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/05/05
	 */
	public SyntaxException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/05/05
	 */
	public SyntaxException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/05/05
	 */
	public SyntaxException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/05/05
	 */
	public SyntaxException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2018/05/05
	 */
	public SyntaxException(LocationAware __la)
	{
		super(__la);
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2018/05/05
	 */
	public SyntaxException(LocationAware __la, String __m)
	{
		super(__la, __m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/05/05
	 */
	public SyntaxException(LocationAware __la, String __m, Throwable __c)
	{
		super(__la, __m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2018/05/05
	 */
	public SyntaxException(LocationAware __la, Throwable __c)
	{
		super(__la, __c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/SyntaxParseException.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
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





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.LocationAware;

/**
 * This is thrown when there is an issue with the input class structure and
 * that is not valid.
 *
 * @since 2018/04/21
 */
public class SyntaxParseException
	extends SyntaxException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/04/21
	 */
	public SyntaxParseException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(LocationAware __la)
	{
		super(__la);
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(LocationAware __la, String __m)
	{
		super(__la, __m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(LocationAware __la, String __m,
		Throwable __c)
	{
		super(__la, __m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2018/04/21
	 */
	public SyntaxParseException(LocationAware __la, Throwable __c)
	{
		super(__la, __c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/TypeParameterSyntax.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
66
67
68
69
70
71
72
73
74
75











































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents a single type parameter which may be associated with a
 * class or method.
 *
 * @since 2018/04/24
 */
public final class TypeParameterSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Parses a single type parameter.
	 *
	 * @param __in The input tokens.
	 * @return The parsed type parameter.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the type parameter could not be
	 * parsed.
	 * @since 2018/04/24
	 */
	public static TypeParameterSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/TypeParametersSyntax.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
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

















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableIterator;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents multiple type parameters.
 *
 * @since 2018/04/30
 */
public final class TypeParametersSyntax
	implements Iterable<TypeParameterSyntax>
{
	/** Type parameters used. */
	private final TypeParameterSyntax[] _params;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the type parameters.
	 *
	 * @param __t The types to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/30
	 */
	public TypeParametersSyntax(TypeParameterSyntax... __t)
		throws NullPointerException
	{
		this(Arrays.<TypeParameterSyntax>asList(
			(__t == null ? new TypeParameterSyntax[0] : __t)));
	}
	
	/**
	 * Initializes the type parameters.
	 *
	 * @param __t The types to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/30
	 */
	public TypeParametersSyntax(Iterable<TypeParameterSyntax> __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		List<TypeParameterSyntax> params = new ArrayList<>();
		for (TypeParameterSyntax t : __t)
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			params.add(t);
		}
		
		this._params = params.<TypeParameterSyntax>toArray(
			new TypeParameterSyntax[params.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/07
	 */
	@Override
	public final Iterator<TypeParameterSyntax> iterator()
	{
		return UnmodifiableIterator.<TypeParameterSyntax>of(this._params);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				Arrays.asList(this._params).toString()));
		
		return rv;
	}
	
	/**
	 * Parses a list of multiple type parameters.
	 *
	 * @param __in The input tokens.
	 * @return The parsed type parameters.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the type parameters could not be
	 * parsed.
	 * @since 2018/04/24
	 */
	public static TypeParametersSyntax parse(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/TypeSyntax.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253





























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This represents the type that may be used in the language.
 *
 * @since 2018/04/24
 */
public final class TypeSyntax
{
	/** The void type. */
	public static final TypeSyntax VOID =
		new TypeSyntax(VoidTypeSyntax.VOID, 0);
	
	/** The simple type used. */
	protected final SimpleTypeSyntax simpletype;
	
	/** The dimensions. */
	protected final int dimensions;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the type using a basic qualified identifier.
	 *
	 * @param __qi The qualified identifier used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/10
	 */
	public TypeSyntax(QualifiedIdentifierSyntax __qi)
		throws NullPointerException
	{
		if (__qi == null)
			throw new NullPointerException("NARG");
		
		this.simpletype = new GenericTypeSyntax(__qi);
		this.dimensions = 0;
	}
	
	/**
	 * Initializes the type information.
	 *
	 * @param __st The simple type.
	 * @param __dims The dimensions used for the type.
	 * @throws IllegalArgumentException If the number of dimensions is
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/30
	 */
	public TypeSyntax(SimpleTypeSyntax __st, int __dims)
		throws IllegalArgumentException, NullPointerException
	{
		if (__st == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AQ2h Types cannot have negative dimensions.}
		if (__dims < 0)
			throw new IllegalArgumentException("AQ2h");
		
		this.simpletype = __st;
		this.dimensions = __dims;
	}
	
	/**
	 * Returns the number of dimensions associated with the type.
	 *
	 * @return The number of dimensions associated with the type.
	 * @since 2018/04/30
	 */
	public final int dimensions()
	{
		return this.dimensions;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			int dims = this.dimensions;
			this._string = new WeakReference<>(
				(rv = (this.simpletype.toString() +
					(dims <= 0 ? "" : "[" + dims + "]"))));
		}
		
		return rv;
	}
	
	/**
	 * Returns the type with the given number of array dimensions.
	 *
	 * @param __d The number of dimensions to use for the type.
	 * @return The type with the given dimension count.
	 * @throws IllegalArgumentException If the dimension count is negative.
	 * @since 2018/04/29
	 */
	public final TypeSyntax withDimensions(int __d)
		throws IllegalArgumentException
	{
		// {@squirreljme.error AQ2i Cannot initialize type with a negative
		// number of dimensions.}
		if (__d < 0)
			throw new IllegalArgumentException("AQ2i");
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses a single type.
	 *
	 * @param __in The input token source.
	 * @return The parsed type.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the type is not valid.
	 * @since 2018/04/24
	 */
	public static TypeSyntax parseType(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Determine the simple type
		Token token = __in.peek();
		SimpleTypeSyntax simple;
		switch (token.type())
		{
			case KEYWORD_BYTE:
				simple = BasicTypeSyntax.BYTE;
				__in.next();
				break;
				
			case KEYWORD_SHORT:
				simple = BasicTypeSyntax.SHORT;
				__in.next();
				break;
				
			case KEYWORD_CHAR:
				simple = BasicTypeSyntax.CHARACTER;
				__in.next();
				break;
				
			case KEYWORD_INT:
				simple = BasicTypeSyntax.INTEGER;
				__in.next();
				break;
				
			case KEYWORD_LONG:
				simple = BasicTypeSyntax.LONG;
				__in.next();
				break;
				
			case KEYWORD_FLOAT:
				simple = BasicTypeSyntax.FLOAT;
				__in.next();
				break;
				
			case KEYWORD_DOUBLE:
				simple = BasicTypeSyntax.DOUBLE;
				__in.next();
				break;
			
				// Probably class or method handler
			case IDENTIFIER:
				simple = GenericTypeSyntax.parse(__in);
				break;
			
				// {@squirreljme.error AQ2j Invalid type.}
			default:
				throw new SyntaxParseException(token, "AQ2j");
		}
		
		// Handle dimensions
		int dims = 0;
		while ((token = __in.peek()).type() == TokenType.SYMBOL_OPEN_BRACKET)
		{
			__in.next();
			
			// {@squirreljme.error AQ2k Expected closing bracket to follow
			// opening bracket when declaring type.}
			token = __in.next();
			if (token.type() != TokenType.SYMBOL_CLOSED_BRACKET)
				throw new SyntaxParseException(token, "AQ2k");
			dims++;
		}
		
		// Build type
		return new TypeSyntax(simple, dims);
	}
	
	/**
	 * Parses multiple types separated by a comma.
	 *
	 * @param __in The input token source.
	 * @return The parsed types.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the types are not valid.
	 * @since 2018/04/24
	 */
	public static TypeSyntax[] parseTypes(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/UnparsedExpressions.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
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
191
192
193
194
195
196
197
198






































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenSource;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This class represents expressions which have not been parsed and are just
 * a raw set of tokens.
 *
 * @since 2018/04/28
 */
public final class UnparsedExpressions
{
	/** Tokens which make up the expression. */
	private final Token[] _tokens;
	
	/** The hashcode for these expressions. */
	private final int _hashcode;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the unparsed expression.
	 *
	 * @param __t The input tokens.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/29
	 */
	public UnparsedExpressions(Iterable<Token> __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Copy tokens
		List<Token> tokens = new ArrayList<>();
		for (Token t : __t)
		{
			if (t == null)
				throw new NullPointerException("NARG");
			
			tokens.add(t);
		}
		
		// Finalize
		this._tokens = tokens.<Token>toArray(new Token[tokens.size()]);
		this._hashcode = tokens.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final int hashCode()
	{
		return this._hashcode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/28
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv =
				Arrays.asList(this._tokens).toString()));
		
		return rv;
	}
	
	/**
	 * Parses arguments which are included in a block of parenthesis.
	 *
	 * @param __in The input tokens.
	 * @return The unparsed expressions.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it could not be parsed.
	 * @since 2018/05/01
	 */
	public static UnparsedExpressions parseArguments(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		return UnparsedExpressions.stackTypeParse(__in,
			TokenType.SYMBOL_OPEN_PARENTHESIS,
			TokenType.SYMBOL_CLOSED_PARENTHESIS);
	}
	
	/**
	 * Parses a block of expressions to not be parsed.
	 *
	 * @param __in The input tokens.
	 * @return The unparsed expressions.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the block is not valid.
	 * @since 2018/04/28
	 */
	public static UnparsedExpressions parseBlock(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		return UnparsedExpressions.stackTypeParse(__in,
			TokenType.SYMBOL_OPEN_BRACE, TokenType.SYMBOL_CLOSED_BRACE);
	}
	
	/**
	 * Parses expressions keeping a stack of which ones that were opened and
	 * closed.
	 *
	 * @param __in The input tokens.
	 * @param __open The open type.
	 * @param __close The close type.
	 * @return The unparsed expressions.
	 * @since 2018/05/01
	 */
	public static UnparsedExpressions stackTypeParse(BufferedTokenSource __in,
		TokenType __open, TokenType __close)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null || __open == null || __close == null)
			throw new NullPointerException("NARG");
		
		// Input tokens
		List<Token> tokens = new LinkedList<>();
		
		// {@squirreljme.error AQ2l Expected start of expression to start with
		// a given symbol. (The expected symbol)}
		Token token = __in.next(),
			base = token;
		if (token.type() != __open)
			throw new SyntaxParseException(token, String.format("AQ2l %s",
				__open));
		tokens.add(token);
		
		// Just count braces and such
		for (int count = 1; count != 0;)
		{
			token = __in.next();
			
			// {@squirreljme.error AQ2m This token might not have been
			// closed properly as the end of file was reached.}
			if (token.type() == TokenType.END_OF_FILE)
				throw new SyntaxParseException(base, "AQ2m");
			
			// Add or remove braces
			else if (token.type() == __open)
				count++;
			else if (token.type() == __close)
				count--;
			
			// Add token always
			tokens.add(token);
		}
		
		// Build
		return new UnparsedExpressions(tokens);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/VoidTypeSyntax.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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

/**
 * This represents the void type.
 *
 * @since 2018/04/30
 */
public enum VoidTypeSyntax
	implements SimpleTypeSyntax
{
	/** Void. */
	VOID,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/__TreeBuilder__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableList;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This is a utility class which can be used to build a tree from a structure,
 * a tree is essentially just a map of data.
 *
 * @since 2019/01/17
 */
final class __TreeBuilder__
{
	/** Resulting set. */
	private final Map<String, Object> _out =
		new LinkedHashMap<>();
	
	/**
	 * Adds the specified element.
	 *
	 * @param __k The key.
	 * @param __v The value.
	 * @return {@code this}.
	 * @throws NullPointerException If no key was specified.
	 * @since 2019/01/17
	 */
	public final __TreeBuilder__ add(String __k, Object __v)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		this._out.put(__k, __v);
		return this;
	}
	
	/**
	 * Adds the specified element.
	 *
	 * @param __k The key.
	 * @param __l The list.
	 * @return {@code this}.
	 * @throws NullPointerException If no key was specified.
	 * @since 2019/01/17
	 */
	public final __TreeBuilder__ addList(String __k, Object[] __l)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		this._out.put(__k, UnmodifiableList.of(
			Arrays.asList((__l == null ? new Object[0] : __l.clone()))));
		return this;
	}
	
	/**
	 * Builds the resulting map.
	 *
	 * @return The resulting map.
	 * @since 2019/01/17
	 */
	public final Map<String, Object> build()
	{
		return UnmodifiableMap.of(
			new LinkedHashMap<String, Object>(this._out));
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionAssignmentSyntax.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents an expression on the left hand which is potentially operated
 * on an assigned to the value on the right hand.
 *
 * @since 2018/05/03
 */
public final class ExpressionAssignmentSyntax
	implements ExpressionSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionOneSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents one of the upper expression syntax formats and is used as
 * a base to construct ternary operations.
 *
 * @since 2018/05/03
 */
public interface ExpressionOneSyntax
	extends ExpressionSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionSyntax.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

import net.multiphasicapps.javac.syntax.AnnotationValueSyntax;

/**
 * This interface represents the base interface for all expression
 * representations.
 *
 * @since 2018/05/03
 */
public interface ExpressionSyntax
	extends AnnotationValueSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionSyntaxParsers.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374






















































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.multiphasicapps.classfile.BinaryName;
import net.multiphasicapps.javac.syntax.QualifiedIdentifierSyntax;
import net.multiphasicapps.javac.syntax.SyntaxDefinitionException;
import net.multiphasicapps.javac.syntax.SyntaxParseException;
import net.multiphasicapps.javac.token.BufferedTokenSource;
import net.multiphasicapps.javac.token.Token;
import net.multiphasicapps.javac.token.TokenType;

/**
 * This class contains all of the parsers for each of the expression syntax
 * formats which are available.
 *
 * @since 2018/05/03
 */
public final class ExpressionSyntaxParsers
{
	/**
	 * Not used.
	 *
	 * @since 2018/05/03
	 */
	private ExpressionSyntaxParsers()
	{
	}
	
	/**
	 * Parses an expression.
	 *
	 * @param __in The input token source.
	 * @return The resulting expression.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the expression is not valid.
	 * @since 2018/05/03
	 */
	public static ExpressionSyntax parseExpression(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse one expression
		ExpressionOneSyntax one = ExpressionSyntaxParsers.
			parseExpressionOne(__in);
		
		// Check for assignment operation
		Token token = __in.peek();
		if (token.type().isAssignmentOperator())
			throw new todo.TODO();
		
		// Just a plain expression syntax
		else
			return new PlainExpressionSyntax(one);
	}
	
	/**
	 * Parses an expression one.
	 *
	 * @param __in The input token source.
	 * @return The resulting expression.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the expression is not valid.
	 * @since 2018/05/03
	 */
	public static ExpressionOneSyntax parseExpressionOne(
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Parse an expression two
		ExpressionTwoSyntax two = ExpressionSyntaxParsers.
			parseExpressionTwo(__in);
		
		// May contain ternary operation
		Token token = __in.peek();
		if (token.type() == TokenType.SYMBOL_QUESTION)
			throw new todo.TODO();
		
		// Just a plain expression one
		else
			return new PlainExpressionOneSyntax(two);
	}
	
	/**
	 * Parses an expression two.
	 *
	 * @param __in The input token source.
	 * @return The resulting expression.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the expression is not valid.
	 * @since 2018/05/03
	 */
	public static ExpressionTwoSyntax parseExpressionTwo(
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Starts with an expression three
		ExpressionThreeSyntax three = ExpressionSyntaxParsers.
			parseExpressionThree(__in);
		
		// May be followed by instanceof
		Token token = __in.peek();
		if (token.type() == TokenType.KEYWORD_INSTANCEOF)
			throw new todo.TODO();
		
		// Otherwise it might be infix operations stacked on each other
		// Note that expression twos are not included in the same region so
		// a bunch of infix operations will stack on each other
		else if (token.type().isInfixOperation())
			throw new todo.TODO();
		
		// Is just a plain expression two syntax
		else
			return new PlainExpressionTwoSyntax(three);
	}
	
	/**
	 * Parses an expression three.
	 *
	 * @param __in The input token source.
	 * @return The resulting expression.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If the expression is not valid.
	 * @since 2018/05/03
	 */
	public static ExpressionThreeSyntax parseExpressionThree(
		BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// This could be a prefix operation
		Token token = __in.peek();
		PrefixOperatorType prefix;
		switch (token.type())
		{
			case OPERATOR_INCREMENT:
				prefix = PrefixOperatorType.INCREMENT;
				break;
			
			case OPERATOR_DECREMENT:
				prefix = PrefixOperatorType.DECREMENT;
				break;
			
			case OPERATOR_NOT:
				prefix = PrefixOperatorType.NOT;
				break;
			
			case OPERATOR_COMPLEMENT:
				prefix = PrefixOperatorType.ONES_COMPLEMENT;
				break;
			
			case OPERATOR_PLUS:
				prefix = PrefixOperatorType.POSITIVE;
				break;
			
			case OPERATOR_MINUS:
				prefix = PrefixOperatorType.NEGATIVE;
				break;
			
			default:
				prefix = null;
				break;
		}
		
		// This is a prefixed operation
		if (prefix != null)
		{
			__in.next();
			return new PrefixOpExpressionSyntax(prefix,
				ExpressionSyntaxParsers.parseExpressionThree(__in));
		}
		
		// Will be a type cast or an expression in a parenthesis (the latter
		// I am not too sure about as it does not make much sense, it could
		// be a language design decision for future proofing?)
		token = __in.peek();
		if (token.type() == TokenType.SYMBOL_OPEN_PARENTHESIS)
		{
			throw new todo.TODO();
		}
		
		// Parse a primary
		PrimarySyntax primary = ExpressionSyntaxParsers.parsePrimary(__in);
		
		// Read in selectors
		List<SelectorSyntax> selectors = new ArrayList<>();
		for (;;)
		{
			// Is not going to be a selector?
			token = __in.peek();
			if (token.type() != TokenType.SYMBOL_DOT &&
				token.type() != TokenType.SYMBOL_OPEN_BRACE)
				break;
			
			throw new todo.TODO();
		}
		
		// Read in postfix operations, if any
		List<PostfixOperatorType> postfixes = new ArrayList<>();
		for (;;)
		{
			token = __in.peek();
			
			// Increment?
			if (token.type() == TokenType.OPERATOR_INCREMENT)
			{
				__in.next();
				postfixes.add(PostfixOperatorType.INCREMENT);
			}
			
			// Decrement?
			else if (token.type() == TokenType.OPERATOR_DECREMENT)
			{
				__in.next();
				postfixes.add(PostfixOperatorType.DECREMENT);
			}
			
			// Unknown, stop parsing
			else
				break;
		}
		
		// Build expression
		return new PrimarySelectorAndPostfixExpression(primary,
			selectors, postfixes);
	}
	
	/**
	 * Parses a primary syntax.
	 *
	 * @param __in The input token source.
	 * @return The primary token.
	 * @throws NullPointerException On null arguments.
	 * @throws SyntaxParseException If it is not a valid primary syntax.
	 * @since 2018/05/03
	 */
	public static PrimarySyntax parsePrimary(BufferedTokenSource __in)
		throws NullPointerException, SyntaxParseException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// It could be a literal value
		Token token = __in.peek();
		switch (token.type())
		{
			case LITERAL_NULL:
			case LITERAL_FALSE:
			case LITERAL_TRUE:
			case LITERAL_BINARY_INTEGER:
			case LITERAL_OCTAL_INTEGER:
			case LITERAL_DECIMAL_INTEGER:
			case LITERAL_HEXADECIMAL_INTEGER:
			case LITERAL_DECIMAL_FLOAT:
			case LITERAL_HEXADECIMAL_FLOAT:
			case LITERAL_STRING:
			case LITERAL_CHARACTER:
				__in.next();
				return new LiteralSyntax(token.characters());
			
				// Is not one
			default:
				break;
		}
		
		// Parenthesis operation
		token = __in.peek();
		if (token.type() == TokenType.SYMBOL_OPEN_PARENTHESIS)
			throw new todo.TODO();
		
		// This... something potentially
		else if (token.type() == TokenType.KEYWORD_THIS)
			throw new todo.TODO();
		
		// Super something
		else if (token.type() == TokenType.KEYWORD_SUPER)
			throw new todo.TODO();
		
		// New something
		else if (token.type() == TokenType.KEYWORD_NEW)
			throw new todo.TODO();
		
		// void.class
		else if (token.type() == TokenType.KEYWORD_VOID)
			throw new todo.TODO();
		
		// Non-wildcard type arguments
		else if (token.type() == TokenType.COMPARE_LESS_THAN)
			throw new todo.TODO();
		
		// Is a basic type (which could be an array) followed by .class
		else if (token.type().isBasicType())
			throw new todo.TODO();
		
		// Will be an identifier followed by something
		else if (token.type() == TokenType.IDENTIFIER)
		{
			// This is going to be a qualified identifier but modified slightly
			// since .<non-identifier> can appear which would break
			// QualifiedIdentifierSyntax
			StringBuilder sb = new StringBuilder();
			for (;;)
			{
				// {@squirreljme.error AQ2n Expected identifier while parsing
				// a primary expression.}
				token = __in.next();
				if (token.type() != TokenType.IDENTIFIER)
					throw new SyntaxParseException(token, "AQ2n");
				
				// Add that
				sb.append(token.characters());
				
				// Need to peek ahead because it might not be an identifier
				token = __in.peek();
				Token after = __in.peek(1);
				
				// Stop if this is not a .identifier but something else
				if (token.type() != TokenType.SYMBOL_DOT ||
					after.type() != TokenType.IDENTIFIER)
					break;
				
				// Add dot
				sb.append('.');
				__in.next();
			}
			
			// Build that
			IdentifierSyntax qi = new IdentifierSyntax(sb.toString());
			
			// Opening of an array
			token = __in.peek();
			if (token.type() == TokenType.SYMBOL_OPEN_BRACKET)
				throw new todo.TODO();
			
			// Method arguments
			else if (token.type() == TokenType.SYMBOL_OPEN_PARENTHESIS)
				throw new todo.TODO();
			
			// Sub-something on the argument
			else if (token.type() == TokenType.SYMBOL_DOT)
				throw new todo.TODO();
			
			// Is just going to be a plain identifier
			else
				return new PlainIdentifierSyntax(qi);
		}
		
		// {@squirreljme.error AQ2o This is not a valid primary expression.}
		else
			throw new SyntaxParseException(token, "AQ2o");
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionThreeSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * Represents an expression three syntax.
 *
 * @since 2018/05/03
 */
public interface ExpressionThreeSyntax
	extends ExpressionSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/ExpressionTwoSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * DESCRIBE THIS.
 *
 * @since 2018/05/03
 */
public interface ExpressionTwoSyntax
	extends ExpressionSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/IdentifierSyntax.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents an identifier.
 *
 * @since 2018/05/03
 */
public final class IdentifierSyntax
{
	/** The string which makes up the identifier. */
	protected final String string;
	
	/**
	 * Initializes the identifier syntax.
	 *
	 * @param __s The identifier string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public IdentifierSyntax(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof IdentifierSyntax))
			return false;
		
		IdentifierSyntax o = (IdentifierSyntax)__o;
		return this.string.equals(o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/InfixExpressionsSyntax.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This contains multiple infix operations (normal ones such as {@code 2 + 2}).
 *
 * @since 2018/05/03
 */
public final class InfixExpressionsSyntax
	implements ExpressionTwoSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/InstanceOfSyntax.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents the {@code instanceof} operation on an expression.
 *
 * @since 2018/05/03
 */
public final class InstanceOfSyntax
	implements ExpressionTwoSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/LiteralSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents a literal value which may be a {@code boolean}, number,
 * string, or {@code null}.
 *
 * @since 2018/05/03
 */
public final class LiteralSyntax
	implements PrimarySyntax
{
	/** The characters that make up the literal. */
	protected final String string;
	
	/**
	 * Initializes the literal.
	 *
	 * @param __s The characters that make up the literal.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public LiteralSyntax(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof LiteralSyntax))
			return false;
		
		LiteralSyntax o = (LiteralSyntax)__o;
		return this.string.equals(o.string);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PlainExpressionOneSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This is just an expression one syntax which contains a single expression
 * two syntax and has no ternary operation.
 *
 * @since 2018/05/03
 */
public final class PlainExpressionOneSyntax
	implements ExpressionOneSyntax
{
	/** The expression used. */
	protected final ExpressionTwoSyntax expression;
	
	/**
	 * Initializes the plain syntax.
	 *
	 * @param __expr The expression used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PlainExpressionOneSyntax(ExpressionTwoSyntax __expr)
		throws NullPointerException
	{
		if (__expr == null)
			throw new NullPointerException("NARG");
		
		this.expression = __expr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof PlainExpressionOneSyntax))
			return false;
		
		PlainExpressionOneSyntax o = (PlainExpressionOneSyntax)__o;
		return this.expression.equals(o.expression);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.expression.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PlainExpressionSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents an expression is just a plain single expression with no
 * assignments.
 *
 * @since 2018/05/03
 */
public final class PlainExpressionSyntax
	implements ExpressionSyntax
{
	/** The expression used. */
	protected final ExpressionOneSyntax expression;
	
	/**
	 * Initializes the plain syntax.
	 *
	 * @param __expr The expression used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PlainExpressionSyntax(ExpressionOneSyntax __expr)
		throws NullPointerException
	{
		if (__expr == null)
			throw new NullPointerException("NARG");
		
		this.expression = __expr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof PlainExpressionSyntax))
			return false;
		
		PlainExpressionSyntax o = (PlainExpressionSyntax)__o;
		return this.expression.equals(o.expression);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.expression.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PlainExpressionTwoSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77
78














































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents a plain expression two syntax which does not have a block
 * or {@code instanceof}.
 *
 * @since 2018/05/03
 */
public final class PlainExpressionTwoSyntax
	implements ExpressionTwoSyntax
{
	/** The expression used. */
	protected final ExpressionThreeSyntax expression;
	
	/**
	 * Initializes the plain syntax.
	 *
	 * @param __expr The expression used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PlainExpressionTwoSyntax(ExpressionThreeSyntax __expr)
		throws NullPointerException
	{
		if (__expr == null)
			throw new NullPointerException("NARG");
		
		this.expression = __expr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof PlainExpressionTwoSyntax))
			return false;
		
		PlainExpressionTwoSyntax o = (PlainExpressionTwoSyntax)__o;
		return this.expression.equals(o.expression);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.expression.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PlainIdentifierSyntax.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
66
67
68
69
70
71
72
73
74
75
76
77













































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This is just a plain identifier.
 *
 * @since 2018/05/03
 */
public final class PlainIdentifierSyntax
	implements PrimarySyntax
{
	/** The identifier used. */
	protected final IdentifierSyntax identifier;
	
	/**
	 * Initializes the plain identifier.
	 *
	 * @param __i The identifier used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PlainIdentifierSyntax(IdentifierSyntax __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.identifier = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof PlainIdentifierSyntax))
			return false;
		
		PlainIdentifierSyntax o = (PlainIdentifierSyntax)__o;
		return this.identifier.equals(o.identifier);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		return this.identifier.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PostfixOperatorType.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents a postfix operation.
 *
 * @since 2018/05/03
 */
public enum PostfixOperatorType
{
	/** Increment. */
	INCREMENT,
	
	/** Decrement. */
	DECREMENT,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PreEvaluateExpression.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























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This is an expression which has a pre-evaluated within parenthesis which
 * is then performed on. It is in the form of {@code (expression)expression3}.
 *
 * Note that the only probably valid form of this syntax would be parenthesis
 * expressions which follow the expression.
 *
 * @since 2018/05/03
 */
public final class PreEvaluateExpression
	implements ExpressionThreeSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PrefixOpExpressionSyntax.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
66
67
68
69
70
71
72
73
74
75
76












































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents an expression which is prefixed by a prefix operation.
 *
 * @since 2018/05/03
 */
public final class PrefixOpExpressionSyntax
	implements ExpressionThreeSyntax
{
	/** The prefix operator. */
	protected final PrefixOperatorType operator;
	
	/** The expression being operated on. */
	protected final ExpressionThreeSyntax expression;
	
	/**
	 * Initializes the prefix operation.
	 *
	 * @param __op The operation being performed.
	 * @param __expr The expression to be operated on.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PrefixOpExpressionSyntax(PrefixOperatorType __op,
		ExpressionThreeSyntax __expr)
		throws NullPointerException
	{
		if (__op == null || __expr == null)
			throw new NullPointerException("NARG");
		
		this.operator = __op;
		this.expression = __expr;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PrefixOperatorType.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * Represents a prefix operation.
 *
 * @since 2018/05/02
 */
public enum PrefixOperatorType
{
	/** Increment. */
	INCREMENT,
	
	/** Decrement. */
	DECREMENT,
	
	/** Not. */
	NOT,
	
	/** One's complement. */
	ONES_COMPLEMENT,
	
	/** Positive. */
	POSITIVE,
	
	/** Negative. */
	NEGATIVE,
	
	/** End. */
	;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PrimarySelectorAndPostfixExpression.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
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





























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This is an operation which performs selections on a primary value which is
 * then postfixed accordingly.
 *
 * @since 2018/05/03
 */
public final class PrimarySelectorAndPostfixExpression
	implements ExpressionThreeSyntax
{
	/** The primary. */
	protected final PrimarySyntax primary;
	
	/** The selectors. */
	private final SelectorSyntax[] _selectors;
	
	/** The postfix operations. */
	private final PostfixOperatorType[] _postfixes;
	
	/**
	 * Initializes the primary selection with possible selectors and
	 * postfixing.
	 *
	 * @param __primary The primary expression.
	 * @param __selectors The selectors to perform on it.
	 * @param __postfixes Any postfixes to be done.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/03
	 */
	public PrimarySelectorAndPostfixExpression(PrimarySyntax __primary,
		Iterable<SelectorSyntax> __selectors,
		Iterable<PostfixOperatorType> __postfixes)
		throws NullPointerException
	{
		if (__primary == null || __selectors == null || __postfixes == null)
			throw new NullPointerException("NARG");
		
		this.primary = __primary;
		
		// Check selectors
		List<SelectorSyntax> selectors = new ArrayList<>();
		for (SelectorSyntax v : __selectors)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			selectors.add(v);
		}
		this._selectors = selectors.<SelectorSyntax>toArray(
			new SelectorSyntax[selectors.size()]);
		
		// Check postfixes
		List<PostfixOperatorType> postfixes = new ArrayList<>();
		for (PostfixOperatorType v : __postfixes)
		{
			if (v == null)
				throw new NullPointerException("NARG");
			
			postfixes.add(v);
		}
		this._postfixes = postfixes.<PostfixOperatorType>toArray(
			new PostfixOperatorType[postfixes.size()]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof PrimarySelectorAndPostfixExpression))
			return false;
		
		PrimarySelectorAndPostfixExpression o =
			(PrimarySelectorAndPostfixExpression)__o;
		return this.primary.equals(o.primary) &&
			Arrays.equals(this._selectors, o._selectors) &&
			Arrays.equals(this._postfixes, o._postfixes);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		int hash = 0;
		for (Object v : this._selectors)
			hash ^= v.hashCode();
		for (Object v : this._postfixes)
			hash ^= v.hashCode();
		return this.primary.hashCode() ^ hash;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/PrimarySyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This interface represents a primary expression.
 *
 * @since 2018/05/03
 */
public interface PrimarySyntax
	extends ExpressionSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/SelectorSyntax.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents a selector.
 *
 * @since 2018/05/03
 */
public interface SelectorSyntax
	extends ExpressionSyntax
{
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/TernaryOperationSyntax.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This represents an operation which operates potentially on multiple
 * ternary operations.
 *
 * @since 2018/05/03
 */
public final class TernaryOperationSyntax
	implements ExpressionOneSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/TypeCastSyntax.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.syntax.expr;

/**
 * This is an expression which is a type cast.
 *
 * @since 2018/05/03
 */
public final class TypeCastSyntax
	implements ExpressionThreeSyntax
{
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/05/03
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/expr/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This class contains the representation and the parsers for expressions
 * that exist within the language. Expressions for the most part contain
 * actual code that may be executed.
 *
 * @since 2018/05/02
 */

package net.multiphasicapps.javac.syntax.expr;

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/syntax/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the information about classes and members.
 *
 * @since 2018/04/21
 */

package net.multiphasicapps.javac.syntax;

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/BufferedTokenSource.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328








































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import java.io.Closeable;
import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.javac.FileNameLineAndColumn;

/**
 * This is a token source which performs buffering of an input set of tokens
 * enabling token sources and such to be marked, committed, and reset similarly
 * to input streams. It additionally provides peeking functionality.
 *
 * The marking system is stack based and as such multiple marks will push
 * onto other marks, while commits or resets will pop those marks.
 *
 * @since 2018/04/18
 */
public final class BufferedTokenSource
	implements Closeable, FileNameLineAndColumn, TokenSource
{
	/** The input token source to read from. */
	protected final TokenSource input;
	
	/** Marks which have been made. */
	private final Deque<Integer> _marks =
		new ArrayDeque<>();
	
	/** Tokens which are currently being peeked. */
	private final List<Token> _peeked =
		new LinkedList<>();
	
	/** The current position in the peek queue where the token is at. */
	private int _peekedpos;
	
	/** The last token which was returned. */
	private Token _last;
	
	/** The token which was last peeked. */
	private Token _lastpeek;
	
	/**
	 * Initializes the buffered token source from the given stream and input
	 * stream.
	 *
	 * @param __fn The name of the file being read.
	 * @param __in The input file stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/21
	 */
	public BufferedTokenSource(String __fn, InputStream __in)
		throws NullPointerException
	{
		this(new Tokenizer(__fn, __in));
	}
	
	/**
	 * Initializes the buffered token source from the given stream and input
	 * stream.
	 *
	 * @param __fn The name of the file being read.
	 * @param __in The input file stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/21
	 */
	public BufferedTokenSource(String __fn, Reader __in)
		throws NullPointerException
	{
		this(new Tokenizer(__fn, __in));
	}
	
	/**
	 * Initializes the buffered token source.
	 *
	 * @param __t The input token source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/18
	 */
	public BufferedTokenSource(TokenSource __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		this.input = __t;
	}
	
	/**
	 * Closes the input token source.
	 *
	 * @throws TokenizerException If it cannot be closed.
	 * @since 2018/04/18
	 */
	@Override
	public final void close()
		throws TokenizerException
	{
		// Close it if the input is closeable
		TokenSource input = this.input;
		if (input instanceof Closeable)
			try
			{
				((Closeable)this.input).close();
			}
			catch (IOException e)
			{
				// {@squirreljme.error AQ2p Could not close the token source.}
				throw new TokenizerException("AQ2p", e);
			}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/18
	 */
	@Override
	public final int column()
	{
		Token last = this._last;
		if (last != null)
			return last.column();
		return this.input.column();
	}
	
	/**
	 * Commits the current position in the marked set (and internally removes
	 * the mark) so that the token stream is set to the given position rather
	 * than being used as a mark. So a commit being performed later in a
	 * stream will make it so that all the previously read tokens were
	 * actually read from the input so that they cannot be reversed.
	 *
	 * @throws IllegalStateException If there are no marks.
	 * @since 2018/04/18
	 */
	public final void commit()
		throws IllegalStateException
	{
		// {@squirreljme.error AQ2q Cannot reset a mark when there have been
		// no marks which were made.}
		Deque<Integer> marks = this._marks;
		int n = marks.size();
		if (n == 0)
			throw new IllegalStateException("AQ2q");
		
		// Remove the last mark but keep the peek position the
		marks.remove(n - 1);
		
		// If this was the last mark then all tokens which were read before
		// this will just be dropped
		if (n <= 1)
		{
			// Drain all peeked tokens to the current position
			int peekedpos = this._peekedpos;
			List<Token> peeked = this._peeked;
			for (int i = 0; i < peekedpos; i++)
				peeked.remove(0);
			
			// Set the peek position to zero so that the next read position
			// is the first token in the queue
			this._peekedpos = 0;
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/18
	 */
	@Override
	public final String fileName()
	{
		Token last = this._last;
		if (last != null)
			return last.fileName();
		return this.input.fileName();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/18
	 */
	@Override
	public final int line()
	{
		Token last = this._last;
		if (last != null)
			return last.line();
		return this.input.line();
	}
	
	/**
	 * Marks the current position in the token stream and pushes it to the
	 * marking stack so that a future {@link #commit()} or {@link #reset()}
	 * will either set the given position or clear it.
	 *
	 * @since 2018/04/18
	 */
	public final void mark()
	{
		// The current peek position is just stored
		this._marks.addLast(this._peekedpos);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/04/18
	 */
	@Override
	public final Token next()
	{
		// Always peek the first token to be returned
		Token rv = this.peek(0);
		
		// If there are no marks that exist, 
		int peekedpos = this._peekedpos;
		Deque<Integer> marks = this._marks;
		if (marks.isEmpty())
			this._peeked.remove(0);
		
		// Otherwise increase the peek index so that the next token is offset
		// by the peek position
		else
			this._peekedpos = peekedpos + 1;
		
		// Debug
		todo.DEBUG.note("Next (%d, m=%d): %s", peekedpos, marks.size(), rv);
		
		// Store the last token for positioning information
		this._last = rv;
		return rv;
	}
	
	/**
	 * Returns the token that would be returned on the call to {@link #next()}
	 *
	 * @return The next token that would be returned.
	 * @throws TokenizerException On read errors.
	 * @since 2018/03/12
	 */
	public final Token peek()
		throws TokenizerException
	{
		// Just read the first token
		return this.peek(0);
	}
	
	/**
	 * Returns the token which seen in the future from a given token offset.
	 *
	 * @param __o The number of tokens to read into the future.
	 * @return The next token that would be returned.
	 * @throws IndexOutOfBoundsException If a negative index was specified.
	 * @throws TokenizerException On read errors.
	 * @since 2018/03/12
	 */
	public final Token peek(int __o)
		throws IndexOutOfBoundsException, TokenizerException
	{
		// {@squirreljme.error AQ2r Cannot peek a token with a negative
		// offset.}
		if (__o < 0)
			throw new IndexOutOfBoundsException("AQ2r");
		
		TokenSource input = this.input;
		
		// Offset by the peek position because if marking is enabled then peek
		// mode will always be used
		__o += this._peekedpos;
		
		// Need to fill the queue with peeked tokens in order to peek this
		// far ahead?
		List<Token> peeked = this._peeked;
		int n = peeked.size();
		while (__o >= n)
			peeked.add(n++, input.next());
		
		// Return the peeked token here
		Token rv = peeked.get(__o);
		
		// Debug
		Token lastpeek = this._lastpeek;
		if (lastpeek != rv)
		{
			todo.DEBUG.note("Peek (%d, m=%d): %s", __o, this._marks.size(),
				rv);
			this._lastpeek = rv;
		}
		
		// Use that
		return rv;
	}
	
	/**
	 * Resets and clears the last mark and returns the token source stream
	 * to the position it was marked at.
	 *
	 * @throws IllegalStateException If there are no marks.
	 * @since 2018/04/18
	 */
	public final void reset()
		throws IllegalStateException
	{
		// {@squirreljme.error AQ2s Cannot reset a mark when there have been
		// no marks which were made.}
		Deque<Integer> marks = this._marks;
		int n = marks.size();
		if (n == 0)
			throw new IllegalStateException("AQ2s");
		
		// The peek position becomes the index of the last mark
		this._peekedpos = marks.removeLast();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/CharacterTest.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733





























































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

/**
 * This is used for testing of characters so that the {@link Tokenizer} class
 * is not filled with large methods that perform many checks.
 *
 * @since 2017/09/09
 */
public final class CharacterTest
{
	/**
	 * Not used.
	 *
	 * @since 2017/09/09
	 */
	private CharacterTest()
	{
	}
	
	/**
	 * This checks the specified character to determine if it is valid for
	 * being part of an identifier after the first character.
	 *
	 * @param __c The character to check.
	 * @return If this is valid for the part of an identifier.
	 * @since 2017/09/09
	 */
	public static boolean isIdentifierPart(int __c)
	{
		return (isIdentifierStart(__c) ||
			(__c >= 0x0001 && __c < 0x0009) ||
			(__c >= 0x000E && __c < 0x001C) ||
			(__c >= 0x0030 && __c < 0x003A) ||
			(__c >= 0x007F && __c < 0x00A0) ||
			__c == 0x00AD ||
			(__c >= 0x0300 && __c < 0x0370) ||
			(__c >= 0x0483 && __c < 0x0488) ||
			(__c >= 0x0591 && __c < 0x05BE) ||
			__c == 0x05BF ||
			(__c >= 0x05C1 && __c < 0x05C3) ||
			(__c >= 0x05C4 && __c < 0x05C6) ||
			__c == 0x05C7 ||
			(__c >= 0x0600 && __c < 0x0605) ||
			(__c >= 0x0610 && __c < 0x061B) ||
			(__c >= 0x064B && __c < 0x066A) ||
			__c == 0x0670 ||
			(__c >= 0x06D6 && __c < 0x06DE) ||
			(__c >= 0x06DF && __c < 0x06E5) ||
			(__c >= 0x06E7 && __c < 0x06E9) ||
			(__c >= 0x06EA && __c < 0x06EE) ||
			(__c >= 0x06F0 && __c < 0x06FA) ||
			__c == 0x070F ||
			__c == 0x0711 ||
			(__c >= 0x0730 && __c < 0x074B) ||
			(__c >= 0x07A6 && __c < 0x07B1) ||
			(__c >= 0x07C0 && __c < 0x07CA) ||
			(__c >= 0x07EB && __c < 0x07F4) ||
			(__c >= 0x0816 && __c < 0x081A) ||
			(__c >= 0x081B && __c < 0x0824) ||
			(__c >= 0x0825 && __c < 0x0828) ||
			(__c >= 0x0829 && __c < 0x082E) ||
			(__c >= 0x0859 && __c < 0x085C) ||
			(__c >= 0x08E4 && __c < 0x08FF) ||
			(__c >= 0x0900 && __c < 0x0904) ||
			(__c >= 0x093A && __c < 0x093D) ||
			(__c >= 0x093E && __c < 0x0950) ||
			(__c >= 0x0951 && __c < 0x0958) ||
			(__c >= 0x0962 && __c < 0x0964) ||
			(__c >= 0x0966 && __c < 0x0970) ||
			(__c >= 0x0981 && __c < 0x0984) ||
			__c == 0x09BC ||
			(__c >= 0x09BE && __c < 0x09C5) ||
			(__c >= 0x09C7 && __c < 0x09C9) ||
			(__c >= 0x09CB && __c < 0x09CE) ||
			__c == 0x09D7 ||
			(__c >= 0x09E2 && __c < 0x09E4) ||
			(__c >= 0x09E6 && __c < 0x09F0) ||
			(__c >= 0x0A01 && __c < 0x0A04) ||
			__c == 0x0A3C ||
			(__c >= 0x0A3E && __c < 0x0A43) ||
			(__c >= 0x0A47 && __c < 0x0A49) ||
			(__c >= 0x0A4B && __c < 0x0A4E) ||
			__c == 0x0A51 ||
			(__c >= 0x0A66 && __c < 0x0A72) ||
			__c == 0x0A75 ||
			(__c >= 0x0A81 && __c < 0x0A84) ||
			__c == 0x0ABC ||
			(__c >= 0x0ABE && __c < 0x0AC6) ||
			(__c >= 0x0AC7 && __c < 0x0ACA) ||
			(__c >= 0x0ACB && __c < 0x0ACE) ||
			(__c >= 0x0AE2 && __c < 0x0AE4) ||
			(__c >= 0x0AE6 && __c < 0x0AF0) ||
			(__c >= 0x0B01 && __c < 0x0B04) ||
			__c == 0x0B3C ||
			(__c >= 0x0B3E && __c < 0x0B45) ||
			(__c >= 0x0B47 && __c < 0x0B49) ||
			(__c >= 0x0B4B && __c < 0x0B4E) ||
			(__c >= 0x0B56 && __c < 0x0B58) ||
			(__c >= 0x0B62 && __c < 0x0B64) ||
			(__c >= 0x0B66 && __c < 0x0B70) ||
			__c == 0x0B82 ||
			(__c >= 0x0BBE && __c < 0x0BC3) ||
			(__c >= 0x0BC6 && __c < 0x0BC9) ||
			(__c >= 0x0BCA && __c < 0x0BCE) ||
			__c == 0x0BD7 ||
			(__c >= 0x0BE6 && __c < 0x0BF0) ||
			(__c >= 0x0C01 && __c < 0x0C04) ||
			(__c >= 0x0C3E && __c < 0x0C45) ||
			(__c >= 0x0C46 && __c < 0x0C49) ||
			(__c >= 0x0C4A && __c < 0x0C4E) ||
			(__c >= 0x0C55 && __c < 0x0C57) ||
			(__c >= 0x0C62 && __c < 0x0C64) ||
			(__c >= 0x0C66 && __c < 0x0C70) ||
			(__c >= 0x0C82 && __c < 0x0C84) ||
			__c == 0x0CBC ||
			(__c >= 0x0CBE && __c < 0x0CC5) ||
			(__c >= 0x0CC6 && __c < 0x0CC9) ||
			(__c >= 0x0CCA && __c < 0x0CCE) ||
			(__c >= 0x0CD5 && __c < 0x0CD7) ||
			(__c >= 0x0CE2 && __c < 0x0CE4) ||
			(__c >= 0x0CE6 && __c < 0x0CF0) ||
			(__c >= 0x0D02 && __c < 0x0D04) ||
			(__c >= 0x0D3E && __c < 0x0D45) ||
			(__c >= 0x0D46 && __c < 0x0D49) ||
			(__c >= 0x0D4A && __c < 0x0D4E) ||
			__c == 0x0D57 ||
			(__c >= 0x0D62 && __c < 0x0D64) ||
			(__c >= 0x0D66 && __c < 0x0D70) ||
			(__c >= 0x0D82 && __c < 0x0D84) ||
			__c == 0x0DCA ||
			(__c >= 0x0DCF && __c < 0x0DD5) ||
			__c == 0x0DD6 ||
			(__c >= 0x0DD8 && __c < 0x0DE0) ||
			(__c >= 0x0DF2 && __c < 0x0DF4) ||
			__c == 0x0E31 ||
			(__c >= 0x0E34 && __c < 0x0E3B) ||
			(__c >= 0x0E47 && __c < 0x0E4F) ||
			(__c >= 0x0E50 && __c < 0x0E5A) ||
			__c == 0x0EB1 ||
			(__c >= 0x0EB4 && __c < 0x0EBA) ||
			(__c >= 0x0EBB && __c < 0x0EBD) ||
			(__c >= 0x0EC8 && __c < 0x0ECE) ||
			(__c >= 0x0ED0 && __c < 0x0EDA) ||
			(__c >= 0x0F18 && __c < 0x0F1A) ||
			(__c >= 0x0F20 && __c < 0x0F2A) ||
			__c == 0x0F35 ||
			__c == 0x0F37 ||
			__c == 0x0F39 ||
			(__c >= 0x0F3E && __c < 0x0F40) ||
			(__c >= 0x0F71 && __c < 0x0F85) ||
			(__c >= 0x0F86 && __c < 0x0F88) ||
			(__c >= 0x0F8D && __c < 0x0F98) ||
			(__c >= 0x0F99 && __c < 0x0FBD) ||
			__c == 0x0FC6 ||
			(__c >= 0x102B && __c < 0x103F) ||
			(__c >= 0x1040 && __c < 0x104A) ||
			(__c >= 0x1056 && __c < 0x105A) ||
			(__c >= 0x105E && __c < 0x1061) ||
			(__c >= 0x1062 && __c < 0x1065) ||
			(__c >= 0x1067 && __c < 0x106E) ||
			(__c >= 0x1071 && __c < 0x1075) ||
			(__c >= 0x1082 && __c < 0x108E) ||
			(__c >= 0x108F && __c < 0x109E) ||
			(__c >= 0x135D && __c < 0x1360) ||
			(__c >= 0x1712 && __c < 0x1715) ||
			(__c >= 0x1732 && __c < 0x1735) ||
			(__c >= 0x1752 && __c < 0x1754) ||
			(__c >= 0x1772 && __c < 0x1774) ||
			(__c >= 0x17B4 && __c < 0x17D4) ||
			__c == 0x17DD ||
			(__c >= 0x17E0 && __c < 0x17EA) ||
			(__c >= 0x180B && __c < 0x180E) ||
			(__c >= 0x1810 && __c < 0x181A) ||
			__c == 0x18A9 ||
			(__c >= 0x1920 && __c < 0x192C) ||
			(__c >= 0x1930 && __c < 0x193C) ||
			(__c >= 0x1946 && __c < 0x1950) ||
			(__c >= 0x19B0 && __c < 0x19C1) ||
			(__c >= 0x19C8 && __c < 0x19CA) ||
			(__c >= 0x19D0 && __c < 0x19DA) ||
			(__c >= 0x1A17 && __c < 0x1A1C) ||
			(__c >= 0x1A55 && __c < 0x1A5F) ||
			(__c >= 0x1A60 && __c < 0x1A7D) ||
			(__c >= 0x1A7F && __c < 0x1A8A) ||
			(__c >= 0x1A90 && __c < 0x1A9A) ||
			(__c >= 0x1B00 && __c < 0x1B05) ||
			(__c >= 0x1B34 && __c < 0x1B45) ||
			(__c >= 0x1B50 && __c < 0x1B5A) ||
			(__c >= 0x1B6B && __c < 0x1B74) ||
			(__c >= 0x1B80 && __c < 0x1B83) ||
			(__c >= 0x1BA1 && __c < 0x1BAE) ||
			(__c >= 0x1BB0 && __c < 0x1BBA) ||
			(__c >= 0x1BE6 && __c < 0x1BF4) ||
			(__c >= 0x1C24 && __c < 0x1C38) ||
			(__c >= 0x1C40 && __c < 0x1C4A) ||
			(__c >= 0x1C50 && __c < 0x1C5A) ||
			(__c >= 0x1CD0 && __c < 0x1CD3) ||
			(__c >= 0x1CD4 && __c < 0x1CE9) ||
			__c == 0x1CED ||
			(__c >= 0x1CF2 && __c < 0x1CF5) ||
			(__c >= 0x1DC0 && __c < 0x1DE7) ||
			(__c >= 0x1DFC && __c < 0x1E00) ||
			(__c >= 0x200B && __c < 0x2010) ||
			(__c >= 0x202A && __c < 0x202F) ||
			(__c >= 0x2060 && __c < 0x2065) ||
			(__c >= 0x206A && __c < 0x2070) ||
			(__c >= 0x20D0 && __c < 0x20DD) ||
			__c == 0x20E1 ||
			(__c >= 0x20E5 && __c < 0x20F1) ||
			(__c >= 0x2CEF && __c < 0x2CF2) ||
			__c == 0x2D7F ||
			(__c >= 0x2DE0 && __c < 0x2E00) ||
			(__c >= 0x302A && __c < 0x3030) ||
			(__c >= 0x3099 && __c < 0x309B) ||
			(__c >= 0xA620 && __c < 0xA62A) ||
			__c == 0xA66F ||
			(__c >= 0xA674 && __c < 0xA67E) ||
			__c == 0xA69F ||
			(__c >= 0xA6F0 && __c < 0xA6F2) ||
			__c == 0xA802 ||
			__c == 0xA806 ||
			__c == 0xA80B ||
			(__c >= 0xA823 && __c < 0xA828) ||
			(__c >= 0xA880 && __c < 0xA882) ||
			(__c >= 0xA8B4 && __c < 0xA8C5) ||
			(__c >= 0xA8D0 && __c < 0xA8DA) ||
			(__c >= 0xA8E0 && __c < 0xA8F2) ||
			(__c >= 0xA900 && __c < 0xA90A) ||
			(__c >= 0xA926 && __c < 0xA92E) ||
			(__c >= 0xA947 && __c < 0xA954) ||
			(__c >= 0xA980 && __c < 0xA984) ||
			(__c >= 0xA9B3 && __c < 0xA9C1) ||
			(__c >= 0xA9D0 && __c < 0xA9DA) ||
			(__c >= 0xAA29 && __c < 0xAA37) ||
			__c == 0xAA43 ||
			(__c >= 0xAA4C && __c < 0xAA4E) ||
			(__c >= 0xAA50 && __c < 0xAA5A) ||
			__c == 0xAA7B ||
			__c == 0xAAB0 ||
			(__c >= 0xAAB2 && __c < 0xAAB5) ||
			(__c >= 0xAAB7 && __c < 0xAAB9) ||
			(__c >= 0xAABE && __c < 0xAAC0) ||
			__c == 0xAAC1 ||
			(__c >= 0xAAEB && __c < 0xAAF0) ||
			(__c >= 0xAAF5 && __c < 0xAAF7) ||
			(__c >= 0xABE3 && __c < 0xABEB) ||
			(__c >= 0xABEC && __c < 0xABEE) ||
			(__c >= 0xABF0 && __c < 0xABFA) ||
			__c == 0xFB1E ||
			(__c >= 0xFE00 && __c < 0xFE10) ||
			(__c >= 0xFE20 && __c < 0xFE27) ||
			__c == 0xFEFF ||
			(__c >= 0xFF10 && __c < 0xFF1A) ||
			(__c >= 0xFFF9 && __c < 0xFFFC));
	}
	
	/**
	 * This checks the specified character to determine if it is valid for
	 * being used at the start of an identifier.
	 *
	 * @param __c The character to check.
	 * @return If this is valid for the start of an identifier.
	 * @since 2017/09/09
	 */
	public static boolean isIdentifierStart(int __c)
	{
		return (__c == 0x0024 ||
			(__c >= 0x0041 && __c < 0x005B) ||
			__c == 0x005F ||
			(__c >= 0x0061 && __c < 0x007B) ||
			(__c >= 0x00A2 && __c < 0x00A6) ||
			__c == 0x00AA ||
			__c == 0x00B5 ||
			__c == 0x00BA ||
			(__c >= 0x00C0 && __c < 0x00D7) ||
			(__c >= 0x00D8 && __c < 0x00F7) ||
			(__c >= 0x00F8 && __c < 0x02C2) ||
			(__c >= 0x02C6 && __c < 0x02D2) ||
			(__c >= 0x02E0 && __c < 0x02E5) ||
			__c == 0x02EC ||
			__c == 0x02EE ||
			(__c >= 0x0370 && __c < 0x0375) ||
			(__c >= 0x0376 && __c < 0x0378) ||
			(__c >= 0x037A && __c < 0x037E) ||
			__c == 0x0386 ||
			(__c >= 0x0388 && __c < 0x038B) ||
			__c == 0x038C ||
			(__c >= 0x038E && __c < 0x03A2) ||
			(__c >= 0x03A3 && __c < 0x03F6) ||
			(__c >= 0x03F7 && __c < 0x0482) ||
			(__c >= 0x048A && __c < 0x0528) ||
			(__c >= 0x0531 && __c < 0x0557) ||
			__c == 0x0559 ||
			(__c >= 0x0561 && __c < 0x0588) ||
			__c == 0x058F ||
			(__c >= 0x05D0 && __c < 0x05EB) ||
			(__c >= 0x05F0 && __c < 0x05F3) ||
			__c == 0x060B ||
			(__c >= 0x0620 && __c < 0x064B) ||
			(__c >= 0x066E && __c < 0x0670) ||
			(__c >= 0x0671 && __c < 0x06D4) ||
			__c == 0x06D5 ||
			(__c >= 0x06E5 && __c < 0x06E7) ||
			(__c >= 0x06EE && __c < 0x06F0) ||
			(__c >= 0x06FA && __c < 0x06FD) ||
			__c == 0x06FF ||
			__c == 0x0710 ||
			(__c >= 0x0712 && __c < 0x0730) ||
			(__c >= 0x074D && __c < 0x07A6) ||
			__c == 0x07B1 ||
			(__c >= 0x07CA && __c < 0x07EB) ||
			(__c >= 0x07F4 && __c < 0x07F6) ||
			__c == 0x07FA ||
			(__c >= 0x0800 && __c < 0x0816) ||
			__c == 0x081A ||
			__c == 0x0824 ||
			__c == 0x0828 ||
			(__c >= 0x0840 && __c < 0x0859) ||
			__c == 0x08A0 ||
			(__c >= 0x08A2 && __c < 0x08AD) ||
			(__c >= 0x0904 && __c < 0x093A) ||
			__c == 0x093D ||
			__c == 0x0950 ||
			(__c >= 0x0958 && __c < 0x0962) ||
			(__c >= 0x0971 && __c < 0x0978) ||
			(__c >= 0x0979 && __c < 0x0980) ||
			(__c >= 0x0985 && __c < 0x098D) ||
			(__c >= 0x098F && __c < 0x0991) ||
			(__c >= 0x0993 && __c < 0x09A9) ||
			(__c >= 0x09AA && __c < 0x09B1) ||
			__c == 0x09B2 ||
			(__c >= 0x09B6 && __c < 0x09BA) ||
			__c == 0x09BD ||
			__c == 0x09CE ||
			(__c >= 0x09DC && __c < 0x09DE) ||
			(__c >= 0x09DF && __c < 0x09E2) ||
			(__c >= 0x09F0 && __c < 0x09F4) ||
			__c == 0x09FB ||
			(__c >= 0x0A05 && __c < 0x0A0B) ||
			(__c >= 0x0A0F && __c < 0x0A11) ||
			(__c >= 0x0A13 && __c < 0x0A29) ||
			(__c >= 0x0A2A && __c < 0x0A31) ||
			(__c >= 0x0A32 && __c < 0x0A34) ||
			(__c >= 0x0A35 && __c < 0x0A37) ||
			(__c >= 0x0A38 && __c < 0x0A3A) ||
			(__c >= 0x0A59 && __c < 0x0A5D) ||
			__c == 0x0A5E ||
			(__c >= 0x0A72 && __c < 0x0A75) ||
			(__c >= 0x0A85 && __c < 0x0A8E) ||
			(__c >= 0x0A8F && __c < 0x0A92) ||
			(__c >= 0x0A93 && __c < 0x0AA9) ||
			(__c >= 0x0AAA && __c < 0x0AB1) ||
			(__c >= 0x0AB2 && __c < 0x0AB4) ||
			(__c >= 0x0AB5 && __c < 0x0ABA) ||
			__c == 0x0ABD ||
			__c == 0x0AD0 ||
			(__c >= 0x0AE0 && __c < 0x0AE2) ||
			__c == 0x0AF1 ||
			(__c >= 0x0B05 && __c < 0x0B0D) ||
			(__c >= 0x0B0F && __c < 0x0B11) ||
			(__c >= 0x0B13 && __c < 0x0B29) ||
			(__c >= 0x0B2A && __c < 0x0B31) ||
			(__c >= 0x0B32 && __c < 0x0B34) ||
			(__c >= 0x0B35 && __c < 0x0B3A) ||
			__c == 0x0B3D ||
			(__c >= 0x0B5C && __c < 0x0B5E) ||
			(__c >= 0x0B5F && __c < 0x0B62) ||
			__c == 0x0B71 ||
			__c == 0x0B83 ||
			(__c >= 0x0B85 && __c < 0x0B8B) ||
			(__c >= 0x0B8E && __c < 0x0B91) ||
			(__c >= 0x0B92 && __c < 0x0B96) ||
			(__c >= 0x0B99 && __c < 0x0B9B) ||
			__c == 0x0B9C ||
			(__c >= 0x0B9E && __c < 0x0BA0) ||
			(__c >= 0x0BA3 && __c < 0x0BA5) ||
			(__c >= 0x0BA8 && __c < 0x0BAB) ||
			(__c >= 0x0BAE && __c < 0x0BBA) ||
			__c == 0x0BD0 ||
			__c == 0x0BF9 ||
			(__c >= 0x0C05 && __c < 0x0C0D) ||
			(__c >= 0x0C0E && __c < 0x0C11) ||
			(__c >= 0x0C12 && __c < 0x0C29) ||
			(__c >= 0x0C2A && __c < 0x0C34) ||
			(__c >= 0x0C35 && __c < 0x0C3A) ||
			__c == 0x0C3D ||
			(__c >= 0x0C58 && __c < 0x0C5A) ||
			(__c >= 0x0C60 && __c < 0x0C62) ||
			(__c >= 0x0C85 && __c < 0x0C8D) ||
			(__c >= 0x0C8E && __c < 0x0C91) ||
			(__c >= 0x0C92 && __c < 0x0CA9) ||
			(__c >= 0x0CAA && __c < 0x0CB4) ||
			(__c >= 0x0CB5 && __c < 0x0CBA) ||
			__c == 0x0CBD ||
			__c == 0x0CDE ||
			(__c >= 0x0CE0 && __c < 0x0CE2) ||
			(__c >= 0x0CF1 && __c < 0x0CF3) ||
			(__c >= 0x0D05 && __c < 0x0D0D) ||
			(__c >= 0x0D0E && __c < 0x0D11) ||
			(__c >= 0x0D12 && __c < 0x0D3B) ||
			__c == 0x0D3D ||
			__c == 0x0D4E ||
			(__c >= 0x0D60 && __c < 0x0D62) ||
			(__c >= 0x0D7A && __c < 0x0D80) ||
			(__c >= 0x0D85 && __c < 0x0D97) ||
			(__c >= 0x0D9A && __c < 0x0DB2) ||
			(__c >= 0x0DB3 && __c < 0x0DBC) ||
			__c == 0x0DBD ||
			(__c >= 0x0DC0 && __c < 0x0DC7) ||
			(__c >= 0x0E01 && __c < 0x0E31) ||
			(__c >= 0x0E32 && __c < 0x0E34) ||
			(__c >= 0x0E3F && __c < 0x0E47) ||
			(__c >= 0x0E81 && __c < 0x0E83) ||
			__c == 0x0E84 ||
			(__c >= 0x0E87 && __c < 0x0E89) ||
			__c == 0x0E8A ||
			__c == 0x0E8D ||
			(__c >= 0x0E94 && __c < 0x0E98) ||
			(__c >= 0x0E99 && __c < 0x0EA0) ||
			(__c >= 0x0EA1 && __c < 0x0EA4) ||
			__c == 0x0EA5 ||
			__c == 0x0EA7 ||
			(__c >= 0x0EAA && __c < 0x0EAC) ||
			(__c >= 0x0EAD && __c < 0x0EB1) ||
			(__c >= 0x0EB2 && __c < 0x0EB4) ||
			__c == 0x0EBD ||
			(__c >= 0x0EC0 && __c < 0x0EC5) ||
			__c == 0x0EC6 ||
			(__c >= 0x0EDC && __c < 0x0EE0) ||
			__c == 0x0F00 ||
			(__c >= 0x0F40 && __c < 0x0F48) ||
			(__c >= 0x0F49 && __c < 0x0F6D) ||
			(__c >= 0x0F88 && __c < 0x0F8D) ||
			(__c >= 0x1000 && __c < 0x102B) ||
			__c == 0x103F ||
			(__c >= 0x1050 && __c < 0x1056) ||
			(__c >= 0x105A && __c < 0x105E) ||
			__c == 0x1061 ||
			(__c >= 0x1065 && __c < 0x1067) ||
			(__c >= 0x106E && __c < 0x1071) ||
			(__c >= 0x1075 && __c < 0x1082) ||
			__c == 0x108E ||
			(__c >= 0x10A0 && __c < 0x10C6) ||
			__c == 0x10C7 ||
			__c == 0x10CD ||
			(__c >= 0x10D0 && __c < 0x10FB) ||
			(__c >= 0x10FC && __c < 0x1249) ||
			(__c >= 0x124A && __c < 0x124E) ||
			(__c >= 0x1250 && __c < 0x1257) ||
			__c == 0x1258 ||
			(__c >= 0x125A && __c < 0x125E) ||
			(__c >= 0x1260 && __c < 0x1289) ||
			(__c >= 0x128A && __c < 0x128E) ||
			(__c >= 0x1290 && __c < 0x12B1) ||
			(__c >= 0x12B2 && __c < 0x12B6) ||
			(__c >= 0x12B8 && __c < 0x12BF) ||
			__c == 0x12C0 ||
			(__c >= 0x12C2 && __c < 0x12C6) ||
			(__c >= 0x12C8 && __c < 0x12D7) ||
			(__c >= 0x12D8 && __c < 0x1311) ||
			(__c >= 0x1312 && __c < 0x1316) ||
			(__c >= 0x1318 && __c < 0x135B) ||
			(__c >= 0x1380 && __c < 0x1390) ||
			(__c >= 0x13A0 && __c < 0x13F5) ||
			(__c >= 0x1401 && __c < 0x166D) ||
			(__c >= 0x166F && __c < 0x1680) ||
			(__c >= 0x1681 && __c < 0x169B) ||
			(__c >= 0x16A0 && __c < 0x16EB) ||
			(__c >= 0x16EE && __c < 0x16F1) ||
			(__c >= 0x1700 && __c < 0x170D) ||
			(__c >= 0x170E && __c < 0x1712) ||
			(__c >= 0x1720 && __c < 0x1732) ||
			(__c >= 0x1740 && __c < 0x1752) ||
			(__c >= 0x1760 && __c < 0x176D) ||
			(__c >= 0x176E && __c < 0x1771) ||
			(__c >= 0x1780 && __c < 0x17B4) ||
			__c == 0x17D7 ||
			(__c >= 0x17DB && __c < 0x17DD) ||
			(__c >= 0x1820 && __c < 0x1878) ||
			(__c >= 0x1880 && __c < 0x18A9) ||
			__c == 0x18AA ||
			(__c >= 0x18B0 && __c < 0x18F6) ||
			(__c >= 0x1900 && __c < 0x191D) ||
			(__c >= 0x1950 && __c < 0x196E) ||
			(__c >= 0x1970 && __c < 0x1975) ||
			(__c >= 0x1980 && __c < 0x19AC) ||
			(__c >= 0x19C1 && __c < 0x19C8) ||
			(__c >= 0x1A00 && __c < 0x1A17) ||
			(__c >= 0x1A20 && __c < 0x1A55) ||
			__c == 0x1AA7 ||
			(__c >= 0x1B05 && __c < 0x1B34) ||
			(__c >= 0x1B45 && __c < 0x1B4C) ||
			(__c >= 0x1B83 && __c < 0x1BA1) ||
			(__c >= 0x1BAE && __c < 0x1BB0) ||
			(__c >= 0x1BBA && __c < 0x1BE6) ||
			(__c >= 0x1C00 && __c < 0x1C24) ||
			(__c >= 0x1C4D && __c < 0x1C50) ||
			(__c >= 0x1C5A && __c < 0x1C7E) ||
			(__c >= 0x1CE9 && __c < 0x1CED) ||
			(__c >= 0x1CEE && __c < 0x1CF2) ||
			(__c >= 0x1CF5 && __c < 0x1CF7) ||
			(__c >= 0x1D00 && __c < 0x1DC0) ||
			(__c >= 0x1E00 && __c < 0x1F16) ||
			(__c >= 0x1F18 && __c < 0x1F1E) ||
			(__c >= 0x1F20 && __c < 0x1F46) ||
			(__c >= 0x1F48 && __c < 0x1F4E) ||
			(__c >= 0x1F50 && __c < 0x1F58) ||
			__c == 0x1F59 ||
			__c == 0x1F5B ||
			__c == 0x1F5D ||
			(__c >= 0x1F5F && __c < 0x1F7E) ||
			(__c >= 0x1F80 && __c < 0x1FB5) ||
			(__c >= 0x1FB6 && __c < 0x1FBD) ||
			__c == 0x1FBE ||
			(__c >= 0x1FC2 && __c < 0x1FC5) ||
			(__c >= 0x1FC6 && __c < 0x1FCD) ||
			(__c >= 0x1FD0 && __c < 0x1FD4) ||
			(__c >= 0x1FD6 && __c < 0x1FDC) ||
			(__c >= 0x1FE0 && __c < 0x1FED) ||
			(__c >= 0x1FF2 && __c < 0x1FF5) ||
			(__c >= 0x1FF6 && __c < 0x1FFD) ||
			(__c >= 0x203F && __c < 0x2041) ||
			__c == 0x2054 ||
			__c == 0x2071 ||
			__c == 0x207F ||
			(__c >= 0x2090 && __c < 0x209D) ||
			(__c >= 0x20A0 && __c < 0x20BB) ||
			__c == 0x2102 ||
			__c == 0x2107 ||
			(__c >= 0x210A && __c < 0x2114) ||
			__c == 0x2115 ||
			(__c >= 0x2119 && __c < 0x211E) ||
			__c == 0x2124 ||
			__c == 0x2126 ||
			__c == 0x2128 ||
			(__c >= 0x212A && __c < 0x212E) ||
			(__c >= 0x212F && __c < 0x213A) ||
			(__c >= 0x213C && __c < 0x2140) ||
			(__c >= 0x2145 && __c < 0x214A) ||
			__c == 0x214E ||
			(__c >= 0x2160 && __c < 0x2189) ||
			(__c >= 0x2C00 && __c < 0x2C2F) ||
			(__c >= 0x2C30 && __c < 0x2C5F) ||
			(__c >= 0x2C60 && __c < 0x2CE5) ||
			(__c >= 0x2CEB && __c < 0x2CEF) ||
			(__c >= 0x2CF2 && __c < 0x2CF4) ||
			(__c >= 0x2D00 && __c < 0x2D26) ||
			__c == 0x2D27 ||
			__c == 0x2D2D ||
			(__c >= 0x2D30 && __c < 0x2D68) ||
			__c == 0x2D6F ||
			(__c >= 0x2D80 && __c < 0x2D97) ||
			(__c >= 0x2DA0 && __c < 0x2DA7) ||
			(__c >= 0x2DA8 && __c < 0x2DAF) ||
			(__c >= 0x2DB0 && __c < 0x2DB7) ||
			(__c >= 0x2DB8 && __c < 0x2DBF) ||
			(__c >= 0x2DC0 && __c < 0x2DC7) ||
			(__c >= 0x2DC8 && __c < 0x2DCF) ||
			(__c >= 0x2DD0 && __c < 0x2DD7) ||
			(__c >= 0x2DD8 && __c < 0x2DDF) ||
			__c == 0x2E2F ||
			(__c >= 0x3005 && __c < 0x3008) ||
			(__c >= 0x3021 && __c < 0x302A) ||
			(__c >= 0x3031 && __c < 0x3036) ||
			(__c >= 0x3038 && __c < 0x303D) ||
			(__c >= 0x3041 && __c < 0x3097) ||
			(__c >= 0x309D && __c < 0x30A0) ||
			(__c >= 0x30A1 && __c < 0x30FB) ||
			(__c >= 0x30FC && __c < 0x3100) ||
			(__c >= 0x3105 && __c < 0x312E) ||
			(__c >= 0x3131 && __c < 0x318F) ||
			(__c >= 0x31A0 && __c < 0x31BB) ||
			(__c >= 0x31F0 && __c < 0x3200) ||
			(__c >= 0x3400 && __c < 0x4DB6) ||
			(__c >= 0x4E00 && __c < 0x9FCD) ||
			(__c >= 0xA000 && __c < 0xA48D) ||
			(__c >= 0xA4D0 && __c < 0xA4FE) ||
			(__c >= 0xA500 && __c < 0xA60D) ||
			(__c >= 0xA610 && __c < 0xA620) ||
			(__c >= 0xA62A && __c < 0xA62C) ||
			(__c >= 0xA640 && __c < 0xA66F) ||
			(__c >= 0xA67F && __c < 0xA698) ||
			(__c >= 0xA6A0 && __c < 0xA6F0) ||
			(__c >= 0xA717 && __c < 0xA720) ||
			(__c >= 0xA722 && __c < 0xA789) ||
			(__c >= 0xA78B && __c < 0xA78F) ||
			(__c >= 0xA790 && __c < 0xA794) ||
			(__c >= 0xA7A0 && __c < 0xA7AB) ||
			(__c >= 0xA7F8 && __c < 0xA802) ||
			(__c >= 0xA803 && __c < 0xA806) ||
			(__c >= 0xA807 && __c < 0xA80B) ||
			(__c >= 0xA80C && __c < 0xA823) ||
			__c == 0xA838 ||
			(__c >= 0xA840 && __c < 0xA874) ||
			(__c >= 0xA882 && __c < 0xA8B4) ||
			(__c >= 0xA8F2 && __c < 0xA8F8) ||
			__c == 0xA8FB ||
			(__c >= 0xA90A && __c < 0xA926) ||
			(__c >= 0xA930 && __c < 0xA947) ||
			(__c >= 0xA960 && __c < 0xA97D) ||
			(__c >= 0xA984 && __c < 0xA9B3) ||
			__c == 0xA9CF ||
			(__c >= 0xAA00 && __c < 0xAA29) ||
			(__c >= 0xAA40 && __c < 0xAA43) ||
			(__c >= 0xAA44 && __c < 0xAA4C) ||
			(__c >= 0xAA60 && __c < 0xAA77) ||
			__c == 0xAA7A ||
			(__c >= 0xAA80 && __c < 0xAAB0) ||
			__c == 0xAAB1 ||
			(__c >= 0xAAB5 && __c < 0xAAB7) ||
			(__c >= 0xAAB9 && __c < 0xAABE) ||
			__c == 0xAAC0 ||
			__c == 0xAAC2 ||
			(__c >= 0xAADB && __c < 0xAADE) ||
			(__c >= 0xAAE0 && __c < 0xAAEB) ||
			(__c >= 0xAAF2 && __c < 0xAAF5) ||
			(__c >= 0xAB01 && __c < 0xAB07) ||
			(__c >= 0xAB09 && __c < 0xAB0F) ||
			(__c >= 0xAB11 && __c < 0xAB17) ||
			(__c >= 0xAB20 && __c < 0xAB27) ||
			(__c >= 0xAB28 && __c < 0xAB2F) ||
			(__c >= 0xABC0 && __c < 0xABE3) ||
			(__c >= 0xAC00 && __c < 0xD7A4) ||
			(__c >= 0xD7B0 && __c < 0xD7C7) ||
			(__c >= 0xD7CB && __c < 0xD7FC) ||
			(__c >= 0xF900 && __c < 0xFA6E) ||
			(__c >= 0xFA70 && __c < 0xFADA) ||
			(__c >= 0xFB00 && __c < 0xFB07) ||
			(__c >= 0xFB13 && __c < 0xFB18) ||
			__c == 0xFB1D ||
			(__c >= 0xFB1F && __c < 0xFB29) ||
			(__c >= 0xFB2A && __c < 0xFB37) ||
			(__c >= 0xFB38 && __c < 0xFB3D) ||
			__c == 0xFB3E ||
			(__c >= 0xFB40 && __c < 0xFB42) ||
			(__c >= 0xFB43 && __c < 0xFB45) ||
			(__c >= 0xFB46 && __c < 0xFBB2) ||
			(__c >= 0xFBD3 && __c < 0xFD3E) ||
			(__c >= 0xFD50 && __c < 0xFD90) ||
			(__c >= 0xFD92 && __c < 0xFDC8) ||
			(__c >= 0xFDF0 && __c < 0xFDFD) ||
			(__c >= 0xFE33 && __c < 0xFE35) ||
			(__c >= 0xFE4D && __c < 0xFE50) ||
			__c == 0xFE69 ||
			(__c >= 0xFE70 && __c < 0xFE75) ||
			(__c >= 0xFE76 && __c < 0xFEFD) ||
			__c == 0xFF04 ||
			(__c >= 0xFF21 && __c < 0xFF3B) ||
			__c == 0xFF3F ||
			(__c >= 0xFF41 && __c < 0xFF5B) ||
			(__c >= 0xFF66 && __c < 0xFFBF) ||
			(__c >= 0xFFC2 && __c < 0xFFC8) ||
			(__c >= 0xFFCA && __c < 0xFFD0) ||
			(__c >= 0xFFD2 && __c < 0xFFD8) ||
			(__c >= 0xFFDA && __c < 0xFFDD) ||
			(__c >= 0xFFE0 && __c < 0xFFE2) ||
			(__c >= 0xFFE5 && __c < 0xFFE7));
	}
	
	/**
	 * Is the specified character deemed an end of line?
	 *
	 * @param __c The character to check.
	 * @return If it is the end of the line.
	 * @since 2017/09/05
	 */
	public static boolean isNewline(int __c)
	{
		return __c < 0 || __c == '\r' || __c == '\n';
	}
	
	/**
	 * Is this character the start of a symbol.
	 *
	 * @param __c The character to test.
	 * @return If it is the start of a symbol.
	 * @since 2018/03/06
	 */
	public static boolean isSymbolStart(int __c)
	{
		return __c == '^' || __c == '~' || __c == '<' || __c == '=' ||
			__c == '>' || __c == '|' || __c == '-' || __c == ',' ||
			__c == ';' || __c == ':' || __c == '!' || __c == '?' ||
			__c == '/' || __c == '.' || __c == '(' || __c == ')' ||
			__c == '[' || __c == ']' || __c == '{' || __c == '}' ||
			__c == '*' || __c == '&' || __c == '%' || __c == '+' ||
			__c == '@';
	}
	
	/**
	 * Is this a character which is possible being in a number literal.
	 *
	 * @param __c The character check.
	 * @return If the character may be placed in a number literal.
	 * @since 2018/03/06
	 */
	public static boolean isPossibleNumberChar(int __c)
	{
		return __c == 'l' || __c == 'L' ||
			__c == 'x' || __c == 'X' ||
			__c == '+' || __c == '-' ||
			__c == 'p' || __c == 'P' ||
			__c == 'e' || __c == 'E' ||
			__c == '.' || __c == '_' ||
			(__c >= '0' && __c <= '9') ||
			(__c >= 'a' && __c <= 'f') ||	// includes bdf
			(__c >= 'A' && __c <= 'F');		// includes BDF
	}
	
	/**
	 * Is the specified character whitespace?
	 *
	 * @param __c The character to check.
	 * @return If it is whitespace.
	 * @since 2017/09/05
	 */
	public static boolean isWhite(int __c)
	{
		return __c == ' ' || __c == '\t' || __c == '\f' || __c == '\r' ||
			__c == '\n';
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/LogicalReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264








































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import net.multiphasicapps.javac.FileNameLineAndColumn;

/**
 * This is a logical reader which provides line and column position information
 * along with decoding of unicode escape sequences.
 *
 * @since 2017/09/09
 */
public class LogicalReader
	implements Closeable, FileNameLineAndColumn
{
	/** The size of tabs. */
	private static final int _TAB_SIZE =
		4;
	
	/** The reader to source from. */
	protected final Reader in;
	
	/** The file name. */
	protected final String filename;
	
	/** The current line. */
	private volatile int _line =
		1;
	
	/** The current column. */
	private volatile int _column =
		1;
	
	/** Was the last character CR? */
	private volatile boolean _wascr;
	
	/** The character which was in the queue after the slash. */
	private volatile int _slashrem =
		-1;
	
	/**
	 * Initializes the logical reader.
	 *
	 * @param __fn The name of the file.
	 * @param __r The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/09
	 */
	public LogicalReader(String __fn, Reader __r)
		throws NullPointerException
	{
		// Check
		if (__fn == null || __r == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.filename = __fn;
		this.in = __r;
	}
	
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/09
	 */
	@Override
	public void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/09
	 */
	@Override
	public int column()
	{
		return this._column;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/09
	 */
	@Override
	public int line()
	{
		return this._line;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public String fileName()
	{
		return this.filename;
	}
	
	/**
	 * Reads the next character.
	 *
	 * @return The next character or a negative value on EOF.
	 * @throws IOException On read errors.
	 * @since 2017/09/09
	 */
	public int read()
		throws IOException
	{
		// An escape sequence was attempted to be read but it was not a
		// unicode escape sequence
		int slashrem = this._slashrem;
		if (slashrem >= 0)
		{
			this._slashrem = -1;
			return slashrem;
		}
		
		// Usually a single character will be read from the source unless it is
		// a escape sequence for unicode characters
		Reader in = this.in;
		boolean escaped = false,
			unicode = false;
		int unicodeval = 0,
			unicodemask = 0;
		for (;;)
		{
			// Full unicode mask read, return the read value
			if (unicode && unicodemask >= 0xFFFF)
				return unicodeval;
			
			// EOF?
			int c = in.read();
			if (c < 0)
			{
				// {@squirreljme.error AQ2t Unicode sequence truncated at
				// end of file.}
				if (unicode)
					throw new TokenizerException(this, "AQ2t");
				
				// Make sure the escape is returned before EOF
				if (escaped)
					return '\\';
				return -1;
			}
			
			// Reset carriage return check, this is for Windows line endings
			// which consist of CRLF pairs which must not be incremented as
			// if they were two lines
			boolean wascr = this._wascr;
			this._wascr = (c == '\r');
			
			// Do line/column counting now because some characters could end
			// up taking up much more space especially if they are escape
			// sequences. Logically there could be boop\nbap where the \n is
			// unicode escaped. For text editor compatibility that is not
			// treated as a new line when related to the count
			if (c == '\n' || wascr)
			{
				// Go to the next line
				this._line++;
				this._column = 1;
			}
			
			// Tab sets to the tab size
			else if (c == '\t')
			{
				int column = this._column;
				column = column + (_TAB_SIZE - (column % _TAB_SIZE));
				this._column = column;
			}
			
			// Single character increase
			else
				this._column++;
			
			// Reading unicode sequence
			if (unicode)
			{
				// Calculate hex value
				int val = Character.digit((char)c, 16);
				
				// Reading digits
				if (val >= 0 && unicodemask < 0xFFFF)
				{
					// Shift in value
					unicodeval <<= 4;
					unicodeval |= val;
					
					// Move mask up
					unicodemask <<= 4;
					unicodemask |= 0xF;
					
					// Read more of the value
					continue;
				}
				
				// Either another character or something else?
				else
				{
					// {@squirreljme.error AQ2u Invalid unicode escape
					// sequence. (The line; The column)}
					if (unicodemask != 0 || c != 'u')
						throw new TokenizerException(this, 
							String.format("AQ2u %d %d", this._line,
							this._column));
					
					// Just skip the u, there can be tons of them
					continue;
				}
			}
			
			// In escape mode
			else if (escaped)
			{
				// Unicode escape sequence?
				if (c == 'u')
				{
					// Enter unicode mode so that the sequence gets
					// counted properly
					unicode = true;
					continue;
				}
				
				// Not one, recycle it
				else
				{
					this._slashrem = c;
					return '\\';
				}
			}
			
			// not escaped
			else
			{
				// Could be a unicode sequence
				if (c == '\\')
				{
					escaped = true;
					continue;
				}
				
				// Return normal character
				else
					return c;
			}
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/Token.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250


























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;
import net.multiphasicapps.collections.UnmodifiableArrayList;
import net.multiphasicapps.javac.FileNameLineAndColumn;

/**
 * This represents a single token which contains a type and the characters
 * which make up the token.
 *
 * @since 2017/09/04
 */
public final class Token
	implements FileNameLineAndColumn
{
	/** The type of token this is, */
	protected final TokenType type;
	
	/** The token string data. */
	protected final String chars;
	
	/** The file name this token was read from. */
	protected final String filename;
	
	/** The line the token is on. */
	protected final int line;
	
	/** The column the token is on. */
	protected final int column;
	
	/** Token comments. */
	private final Token[] _comments;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the token.
	 *
	 * @param __t The type of token this is.
	 * @param __c The characters which make up the token.
	 * @param __fn The file name this was read from.
	 * @param __l The line the token is on.
	 * @param __o The column the token is on.
	 * @param __comments Comments which are associated with the token.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/06
	 */
	public Token(TokenType __t, String __c, String __fn, int __l, int __o,
		Token... __comments)
		throws NullPointerException
	{
		// Check
		if (__t == null || __c == null || __fn == null)
			throw new NullPointerException("NARG");
		
		this.type = __t;
		this.chars = __c;
		this.filename = __fn;
		this.line = __l;
		this.column = __o;
		
		// Smartly copy comments
		if (__comments == null)
			this._comments = new Token[0];
		else if (__comments.length == 0)
			this._comments = __comments;
		else
		{
			__comments = __comments.clone();
			for (Token t : __comments)
				if (t == null)
					throw new NullPointerException("NARG");
			this._comments = __comments;
		}
	}
	
	/**
	 * Initializes the token based off the other token but with the specified
	 * comments.
	 *
	 * @param __t The base token.
	 * @param __comments The token comments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/04/18
	 */
	public Token(Token __t, Token... __comments)
		throws NullPointerException
	{
		this(__t.type(), __t.characters(), __t.fileName(), __t.line(),
			__t.column(), __comments);
	}
	
	/**
	 * Returns the token characters.
	 *
	 * @return The token characters.
	 * @since 2017/09/06
	 */
	public String characters()
	{
		return this.chars;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/09
	 */
	@Override
	public int column()
	{
		return this.column;
	}
	
	/**
	 * Returns the comments associated with this token.
	 *
	 * @return The token comments.
	 * @since 2018/03/12
	 */
	public final List<Token> comments()
	{
		return UnmodifiableArrayList.<Token>of(this._comments);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/04
	 */
	@Override
	public boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Token))
			return false;
		
		Token o = (Token)__o;
		return this.type.equals(o.type) &&
			this.chars.equals(o.chars) &&
			Objects.equals(this.filename, o.filename) &&
			this.line == o.line &&
			this.column == o.column;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final String fileName()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/04
	 */
	@Override
	public int hashCode()
	{
		return this.type.hashCode() ^ this.chars.hashCode() ^
			Objects.hashCode(this.filename) ^
			this.line ^ (~this.column);
	}
	
	/**
	 * Is this a comment?
	 *
	 * @return If this is a comment or not.
	 * @since 2018/03/07
	 */
	public final boolean isComment()
	{
		return this.type == TokenType.COMMENT;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/09
	 */
	@Override
	public int line()
	{
		return this.line;
	}
	
	/**
	 * Does this token need a space following it to be valid?
	 *
	 * @return If a space is needed to follow to make it valid.
	 * @since 2018/03/07
	 */
	public final boolean needFollowingSpace()
	{
		TokenType type = this.type;
		return type.isIdentifier() ||
			type.isKeyword() ||
			type.isLiteral() ||
			type == TokenType.OPERATOR_PLUS ||
			type == TokenType.OPERATOR_MINUS ||
			type == TokenType.OPERATOR_INCREMENT ||
			type == TokenType.OPERATOR_DECREMENT;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/04
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"%s@%s:%d,%d: %s", this.type, this.filename, this.line,
				this.column, this.chars)));
		
		return rv;
	}
	
	/**
	 * Returns the type of token this is.
	 *
	 * @return The token type.
	 * @since 2017/09/06
	 */
	public TokenType type()
	{
		return this.type;
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/TokenSource.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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import net.multiphasicapps.javac.FileNameLineAndColumn;

/**
 * This interface represents a source for tokens.
 *
 * @since 2018/04/18
 */
public interface TokenSource
	extends FileNameLineAndColumn
{
	/**
	 * Returns the next token from the input source.
	 *
	 * @return The next token, if there are no more tokens left then a special
	 * end of file token should be used instead.
	 * @throws TokenizerException If the read input token is not valid.
	 * @since 2018/04/18
	 */
	public abstract Token next()
		throws TokenizerException;
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/TokenType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

/**
 * This represents the type of token which was parsed.
 *
 * @since 2017/09/04
 */
public enum TokenType
{
	/** End of file. */
	END_OF_FILE,
	
	/** A comment. */
	COMMENT,
	
	/** Identifier. */
	IDENTIFIER,
	
	/** Keyword abstract. */
	KEYWORD_ABSTRACT,
	
	/** Keyword assert. */
	KEYWORD_ASSERT,
	
	/** Keyword boolean. */
	KEYWORD_BOOLEAN,
	
	/** Keyword break. */
	KEYWORD_BREAK,
	
	/** Keyword byte. */
	KEYWORD_BYTE,
	
	/** Keyword case. */
	KEYWORD_CASE,
	
	/** Keyword catch. */
	KEYWORD_CATCH,
	
	/** Keyword char. */
	KEYWORD_CHAR,
	
	/** Keyword class. */
	KEYWORD_CLASS,
	
	/** Keyword continue. */
	KEYWORD_CONTINUE,
	
	/** Keyword default. */
	KEYWORD_DEFAULT,
	
	/** Keyword do. */
	KEYWORD_DO,
	
	/** Keyword double. */
	KEYWORD_DOUBLE,
	
	/** Keyword else. */
	KEYWORD_ELSE,
	
	/** Keyword enum. */
	KEYWORD_ENUM,
	
	/** Keyword extends. */
	KEYWORD_EXTENDS,
	
	/** Keyword final. */
	KEYWORD_FINAL,
	
	/** Keyword finally. */
	KEYWORD_FINALLY,
	
	/** Keyword float. */
	KEYWORD_FLOAT,
	
	/** Keyword for. */
	KEYWORD_FOR,
	
	/** Keyword if. */
	KEYWORD_IF,
	
	/** Keyword implements. */
	KEYWORD_IMPLEMENTS,
	
	/** Keyword import. */
	KEYWORD_IMPORT,
	
	/** Keyword instanceof. */
	KEYWORD_INSTANCEOF,
	
	/** Keyword int. */
	KEYWORD_INT,
	
	/** Keyword interface. */
	KEYWORD_INTERFACE,
	
	/** Keyword long. */
	KEYWORD_LONG,
	
	/** Keyword native. */
	KEYWORD_NATIVE,
	
	/** Keyword new. */
	KEYWORD_NEW,
	
	/** Keyword package. */
	KEYWORD_PACKAGE,
	
	/** Keyword private. */
	KEYWORD_PRIVATE,
	
	/** Keyword protected. */
	KEYWORD_PROTECTED,
	
	/** Keyword public. */
	KEYWORD_PUBLIC,
	
	/** Keyword return. */
	KEYWORD_RETURN,
	
	/** Keyword short. */
	KEYWORD_SHORT,
	
	/** Keyword static. */
	KEYWORD_STATIC,
	
	/** Keyword strictfp. */
	KEYWORD_STRICTFP,
	
	/** Keyword super. */
	KEYWORD_SUPER,
	
	/** Keyword switch. */
	KEYWORD_SWITCH,
	
	/** Keyword synchronized. */
	KEYWORD_SYNCHRONIZED,
	
	/** Keyword this. */
	KEYWORD_THIS,
	
	/** Keyword throw. */
	KEYWORD_THROW,
	
	/** Keyword throws. */
	KEYWORD_THROWS,
	
	/** Keyword transient. */
	KEYWORD_TRANSIENT,
	
	/** Keyword try. */
	KEYWORD_TRY,
	
	/** Keyword void. */
	KEYWORD_VOID,
	
	/** Keyword volatile. */
	KEYWORD_VOLATILE,
	
	/** Keyword while. */
	KEYWORD_WHILE,
	
	/** The null literal. */
	LITERAL_NULL,
	
	/** The false literal. */
	LITERAL_FALSE,
	
	/** The true literal. */
	LITERAL_TRUE,
	
	/** Binary integer literal. */
	LITERAL_BINARY_INTEGER,
	
	/** Octal integer literal. */
	LITERAL_OCTAL_INTEGER,
	
	/** Decimal integer literal. */
	LITERAL_DECIMAL_INTEGER,
	
	/** Hexadecimal integer literal. */
	LITERAL_HEXADECIMAL_INTEGER,
	
	/** Decimal float literal. */
	LITERAL_DECIMAL_FLOAT,
	
	/** Hexadecimal float literal. */
	LITERAL_HEXADECIMAL_FLOAT,
	
	/** String literal. */
	LITERAL_STRING,
	
	/** Character literal. */
	LITERAL_CHARACTER,
	
	/** Compare for equality. */
	COMPARE_EQUALS,
	
	/** Compare for inequality. */
	COMPARE_NOT_EQUALS,
	
	/** Compare less than. */
	COMPARE_LESS_THAN,
	
	/** Compare less than or equals to. */
	COMPARE_LESS_OR_EQUAL,
	
	/** Compare greater than. */
	COMPARE_GREATER_THAN,
	
	/** Compare greater than or equal. */
	COMPARE_GREATER_OR_EQUAL,
	
	/** Compare AND. */
	COMPARE_AND,
	
	/** Compare OR. */
	COMPARE_OR,
	
	/** Assign operator. */
	OPERATOR_ASSIGN,
	
	/** Add operator. */
	OPERATOR_PLUS,
	
	/** Add and assign operator. */
	OPERATOR_PLUS_ASSIGN,
	
	/** Subtract operator. */
	OPERATOR_MINUS,
	
	/** Subtract and assign operator. */
	OPERATOR_MINUS_ASSIGN,
	
	/** Multiply operator. */
	OPERATOR_MULTIPLY,
	
	/** Multiply and assign operator. */
	OPERATOR_MULTIPLY_ASSIGN,
	
	/** Divide operator. */
	OPERATOR_DIVIDE,
	
	/** Divide and assign operator. */
	OPERATOR_DIVIDE_ASSIGN,
	
	/** Remainder operator. */
	OPERATOR_REMAINDER,
	
	/** Remainder and assign operator. */
	OPERATOR_REMAINDER_ASSIGN,
	
	/** Shift left. */
	OPERATOR_SHIFT_LEFT,
	
	/** Shift left and assign. */
	OPERATOR_SHIFT_LEFT_ASSIGN,
	
	/** Signed Shift right. */
	OPERATOR_SSHIFT_RIGHT,
	
	/** Signed Shift right and assign. */
	OPERATOR_SSHIFT_RIGHT_ASSIGN,
	
	/** Unsigned Shift right. */
	OPERATOR_USHIFT_RIGHT,
	
	/** Unsigned Shift right and assign. */
	OPERATOR_USHIFT_RIGHT_ASSIGN,
	
	/** Ternary question operator. */
	SYMBOL_QUESTION,
	
	/** The NOT operator. */
	OPERATOR_NOT,
	
	/** The NOT and assign operator. */
	OPERATOR_NOT_ASSIGN,
	
	/** The AND operator. */
	OPERATOR_AND,
	
	/** The AND and assign operator. */
	OPERATOR_AND_ASSIGN,
	
	/** The XOR operator. */
	OPERATOR_XOR,
	
	/** The XOR and assign operator. */
	OPERATOR_XOR_ASSIGN,
	
	/** The OR operator. */
	OPERATOR_OR,
	
	/** The OR and assign operator. */
	OPERATOR_OR_ASSIGN,
	
	/** Bitwise complement. */
	OPERATOR_COMPLEMENT,
	
	/** Increment. */
	OPERATOR_INCREMENT,
	
	/** Decrement. */
	OPERATOR_DECREMENT,
	
	/** Ternary colon operator or label. */
	SYMBOL_COLON,
	
	/** Double colon. */
	SYMBOL_DOUBLE_COLON,
	
	/** Open parenthesis. */
	SYMBOL_OPEN_PARENTHESIS,
	
	/** Closed parenthesis. */
	SYMBOL_CLOSED_PARENTHESIS,
	
	/** Open brace. */
	SYMBOL_OPEN_BRACE,
	
	/** Closed brace. */
	SYMBOL_CLOSED_BRACE,
	
	/** Open bracket. */
	SYMBOL_OPEN_BRACKET,
	
	/** Closed bracket. */
	SYMBOL_CLOSED_BRACKET,
	
	/** Semicolon. */
	SYMBOL_SEMICOLON,
	
	/** Comma. */
	SYMBOL_COMMA,
	
	/** The dot separator. */
	SYMBOL_DOT,
	
	/** The ellipses. */
	SYMBOL_ELLIPSES,
	
	/** Lambda symbol. */
	SYMBOL_LAMBDA,
	
	/** At symbol for annotations. */
	SYMBOL_AT,
	
	/** End. */
	;
	
	/**
	 * Is this an assignment operator?
	 *
	 * @return If this is an assignment operator.
	 * @since 2018/05/03
	 */
	public final boolean isAssignmentOperator()
	{
		switch (this)
		{
			case OPERATOR_ASSIGN:
			case OPERATOR_PLUS_ASSIGN:
			case OPERATOR_MINUS_ASSIGN:
			case OPERATOR_MULTIPLY_ASSIGN:
			case OPERATOR_DIVIDE_ASSIGN:
			case OPERATOR_REMAINDER_ASSIGN:
			case OPERATOR_SHIFT_LEFT_ASSIGN:
			case OPERATOR_SSHIFT_RIGHT_ASSIGN:
			case OPERATOR_USHIFT_RIGHT_ASSIGN:
			case OPERATOR_NOT_ASSIGN:
			case OPERATOR_AND_ASSIGN:
			case OPERATOR_XOR_ASSIGN:
			case OPERATOR_OR_ASSIGN:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a basic type?
	 *
	 * @return If this is a basic type.
	 * @since 2018/05/03
	 */
	public final boolean isBasicType()
	{
		switch (this)
		{
			case KEYWORD_BYTE:
			case KEYWORD_SHORT:
			case KEYWORD_CHAR:
			case KEYWORD_INT:
			case KEYWORD_LONG:
			case KEYWORD_FLOAT:
			case KEYWORD_DOUBLE:
			case KEYWORD_BOOLEAN:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a modifier to a class?
	 *
	 * @return If this is a class modifier.
	 * @since 2018/03/10
	 */
	public final boolean isClassModifier()
	{
		switch (this)
		{
			case KEYWORD_ABSTRACT:
			case KEYWORD_FINAL:
			case KEYWORD_PRIVATE:
			case KEYWORD_PROTECTED:
			case KEYWORD_PUBLIC:
			case KEYWORD_STATIC:
			case KEYWORD_STRICTFP:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a comment?
	 *
	 * @return If this is a comment or not.
	 * @since 2017/09/06
	 */
	public final boolean isComment()
	{
		switch (this)
		{
				// Comments
			case COMMENT:
				return true;
			
				// Not a comment
			default:
				return false;
		}
	}
	
	/**
	 * Is this an identifier?
	 *
	 * @return If this is an identifier.
	 * @since 2018/03/07
	 */
	public final boolean isIdentifier()
	{
		return this == IDENTIFIER;
	}
	
	/**
	 * Is this a keyword?
	 *
	 * @return If this is a keyword.
	 * @since 2018/03/07
	 */
	public final boolean isKeyword()
	{
		switch (this)
		{
			case KEYWORD_ABSTRACT:
			case KEYWORD_ASSERT:
			case KEYWORD_BOOLEAN:
			case KEYWORD_BREAK:
			case KEYWORD_BYTE:
			case KEYWORD_CASE:
			case KEYWORD_CATCH:
			case KEYWORD_CHAR:
			case KEYWORD_CLASS:
			case KEYWORD_CONTINUE:
			case KEYWORD_DEFAULT:
			case KEYWORD_DO:
			case KEYWORD_DOUBLE:
			case KEYWORD_ELSE:
			case KEYWORD_ENUM:
			case KEYWORD_EXTENDS:
			case KEYWORD_FINAL:
			case KEYWORD_FINALLY:
			case KEYWORD_FLOAT:
			case KEYWORD_FOR:
			case KEYWORD_IF:
			case KEYWORD_IMPLEMENTS:
			case KEYWORD_IMPORT:
			case KEYWORD_INSTANCEOF:
			case KEYWORD_INT:
			case KEYWORD_INTERFACE:
			case KEYWORD_LONG:
			case KEYWORD_NATIVE:
			case KEYWORD_NEW:
			case KEYWORD_PACKAGE:
			case KEYWORD_PRIVATE:
			case KEYWORD_PROTECTED:
			case KEYWORD_PUBLIC:
			case KEYWORD_RETURN:
			case KEYWORD_SHORT:
			case KEYWORD_STATIC:
			case KEYWORD_STRICTFP:
			case KEYWORD_SUPER:
			case KEYWORD_SWITCH:
			case KEYWORD_SYNCHRONIZED:
			case KEYWORD_THIS:
			case KEYWORD_THROW:
			case KEYWORD_THROWS:
			case KEYWORD_TRANSIENT:
			case KEYWORD_TRY:
			case KEYWORD_VOID:
			case KEYWORD_VOLATILE:
			case KEYWORD_WHILE:
				return true;
			
			default:
				return false;
		}	
	}
	
	/**
	 * Is this an infix operation?
	 *
	 * @return If this is an infix operation.
	 * @since 2018/05/03
	 */
	public final boolean isInfixOperation()
	{
		switch (this)
		{
			case COMPARE_OR:
			case COMPARE_AND:
			case COMPARE_EQUALS:
			case COMPARE_NOT_EQUALS:
			case COMPARE_LESS_THAN:
			case COMPARE_GREATER_THAN:
			case COMPARE_LESS_OR_EQUAL:
			case COMPARE_GREATER_OR_EQUAL:
			case OPERATOR_OR:
			case OPERATOR_XOR:
			case OPERATOR_AND:
			case OPERATOR_SHIFT_LEFT:
			case OPERATOR_SSHIFT_RIGHT:
			case OPERATOR_USHIFT_RIGHT:
			case OPERATOR_PLUS:
			case OPERATOR_MINUS:
			case OPERATOR_MULTIPLY:
			case OPERATOR_DIVIDE:
			case OPERATOR_REMAINDER:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a literal?
	 *
	 * @return If this is a literal.
	 * @since 2018/03/07
	 */
	public final boolean isLiteral()
	{
		switch (this)
		{
			case LITERAL_NULL:
			case LITERAL_FALSE:
			case LITERAL_TRUE:
			case LITERAL_BINARY_INTEGER:
			case LITERAL_OCTAL_INTEGER:
			case LITERAL_DECIMAL_INTEGER:
			case LITERAL_HEXADECIMAL_INTEGER:
			case LITERAL_DECIMAL_FLOAT:
			case LITERAL_HEXADECIMAL_FLOAT:
			case LITERAL_STRING:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this the potential start of a class declaration?
	 *
	 * @return If this is the potential start of a class declaration.
	 * @since 2018/03/07
	 */
	public final boolean isPotentialClassStart()
	{
		switch (this)
		{
			case KEYWORD_ABSTRACT:
			case KEYWORD_ENUM:
			case KEYWORD_FINAL:
			case KEYWORD_INTERFACE:
			case KEYWORD_PRIVATE:
			case KEYWORD_PROTECTED:
			case KEYWORD_PUBLIC:
			case KEYWORD_STATIC:
			case KEYWORD_STRICTFP:
			case SYMBOL_AT:
				return true;
			
			default:
				return false;
		}
	}
	
	/**
	 * Is this a word?
	 *
	 * @return If this is a word.
	 * @since 2018/03/07
	 */
	public final boolean isWord()
	{
		return this == IDENTIFIER ||
			this.isKeyword();
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/Tokenizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import java.io.Closeable;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.collections.UnmodifiableList;
import net.multiphasicapps.javac.FileNameLineAndColumn;

/**
 * This class is the tokenizer which is used to provide tokens for the lexical
 * structure parser. This tokenizer does not return any comments and it will
 * perform decoupling of less than and greater than brackets which are used
 * for generic types.
 *
 * @since 2017/09/04
 */
public class Tokenizer
	implements Closeable, FileNameLineAndColumn, TokenSource
{
	/** Operators used. */
	private static final List<String> _OPERATORS =
		UnmodifiableList.<String>of(Arrays.<String>asList("(", ")", "{", "}",
			"[", "]", ";", ",", ".", "=", ">", "<", "!", "~", "?", ":", "::",
			"==", "<=", ">=", "!=", "&&", "||", "++", "--", "+", "-", "*", "/",
			"&", "|", "^", "%", "<<", ">>", ">>>", "+=", "-=", "*=", "/=",
			"&=", "|=", "^=", "%=", "<<=", ">>=", ">>>=", "->", "@"));
	
	/** Operator character code merge. */
	private static final int[] _OPERATOR_MERGE;
	
	/** No comments used. */
	private static final Token[] _NO_COMMENTS =
		new Token[0];
	
	/** The input file name. */
	protected final String filename;
	
	/** Input character source. */
	protected final LogicalReader in;
	
	/** The comments which are waiting in the queue. */
	private final Deque<Token> _comments =
		new LinkedList<>();
	
	/** Is there a character waiting? */
	private boolean _nxwaiting;
	
	/** The next character that is waiting. */
	private int _nxchar;
	
	/** The next line. */
	private int _nxline =
		1;
	
	/** The next column. */
	private int _nxcolumn =
		1;
	
	/** The current line. */
	private int _curline =
		1;
	
	/** The current column. */
	private int _curcolumn =
		1;
	
	/** The current token's line. */
	private int _atline =
		1;
	
	/** The current token's column. */
	private int _atcolumn =
		1;
	
	/** The number of tokens which are waiting to be decomposed. */
	private int _decomposewait;
	
	/** The number of characters which have been decomposed. */
	private int _decomposedid;
	
	/** The number of open angle brackets. */
	private int _opencount;
	
	/** Used for angle bracket decomposition. */
	private TokenType _lasttype;
	
	/**
	 * Initializes the merged operator set.
	 *
	 * @since 2018/03/07
	 */
	static
	{
		List<String> operators = Tokenizer._OPERATORS;
		int numops = operators.size();
		int[] merge = new int[numops];
		for (int i = 0; i < numops; i++)
		{
			// Start with empty space
			int val = 0xFF_FF_FF_FF;
			
			// Go through all characters in the operation and shift them in
			String op = operators.get(i);
			for (int j = 0, opn = op.length(); j < opn; j++)
			{
				val <<= 8;
				val |= ((int)op.charAt(j)) & 0x7F;
			}
			
			merge[i] = val;
		}
		
		_OPERATOR_MERGE = merge;
	}
	
	/**
	 * Initializes the tokenizer for Java source code.
	 *
	 * @param __is The tokenizer input, it is treated as UTF-8.
	 * @throws NullPointerException On null arguments.
	 * @throws RuntimeException If UTF-8 is not supported, but this should
	 * not occur.
	 * @since 2017/09/04
	 */
	public Tokenizer(String __fn, InputStream __is)
		throws NullPointerException, RuntimeException
	{
		this(__fn, __wrap(__is));
	}
	
	/**
	 * Initializes the tokenizer for Java source code.
	 *
	 * @param __r The reader to read characters from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/04
	 */
	public Tokenizer(String __fn, Reader __r)
	{
		// Check
		if (__fn == null || __r == null)
			throw new NullPointerException("NARG");
		
		this.filename = __fn;
		this.in = new LogicalReader(__fn, __r);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public void close()
		throws TokenizerException
	{
		try
		{
			this.in.close();
		}
		catch (IOException e)
		{
			// {@squirreljme.error AQ2v Failed to close the tokenizer.}
			throw new TokenizerException(this, "AQ2v", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final int column()
	{
		return this._atcolumn;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/12
	 */
	@Override
	public final String fileName()
	{
		return this.in.fileName();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/06
	 */
	@Override
	public final int line()
	{
		return this._atline;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/09/05
	 */
	@Override
	public final Token next()
		throws TokenizerException
	{
		int decomposewait = this._decomposewait;
		
		// Push any comment tokens to the comment queue, do not read tokens
		// however if there are tokens waiting to be decomposed
		Deque<Token> comments = this._comments;
		Token rv = null;
		if (decomposewait <= 0)
			for (;;)
			{
				// If it is a comment, it gets commented
				rv = this.__decodeToken();
				if (rv.type() == TokenType.COMMENT)
					comments.addLast(rv);
				
				// Stop on non-comments
				else
					break;
			}
		
		// Any comments which were read will always be drained
		Token[] usecomments;
		int numcomments;
		if ((numcomments = comments.size()) > 0)
		{
			usecomments = comments.<Token>toArray(new Token[numcomments]);
			comments.clear();
		}
		
		// No comments to use
		else
			usecomments = Tokenizer._NO_COMMENTS;
		
		// Are there tokens waiting to be decomposed?
		if (decomposewait > 0)
		{
			// Used for true positioning of characters
			int line = this._atline,
				column = this._atcolumn,
				decomposedid = this._decomposedid;
			
			// Remove a decomposed token
			this._decomposewait = decomposewait - 1;
			this._decomposedid = decomposedid + 1;
			
			// Build a decomposed token
			return new Token(TokenType.COMPARE_GREATER_THAN, ">",
				this.filename, line, column + decomposedid, usecomments);
		}
		
		// Used to determine how many braces have been opened
		int opencount = this._opencount;
		
		// Determine if decomposition is to be performed
		TokenType type = rv.type();
		TokenType lasttype = this._lasttype;
		int maxdecouple = 0;
		switch (type)
		{
				// Count open angle brackets but only if they follow
				// dots or identifiers
				// Foo<Bar>
				// foo.<Bar>boop()
			case COMPARE_LESS_THAN:
				if (lasttype != null &&
					(lasttype == TokenType.IDENTIFIER ||
					lasttype == TokenType.SYMBOL_DOT))
					this._opencount = opencount + 1;
				break;
			
				// Closing bracket, never close it negatively
			case COMPARE_GREATER_THAN:
				if (opencount > 0)
					this._opencount = opencount - 1;
				break;
			
				// Decouple two closers
			case OPERATOR_SSHIFT_RIGHT:
				maxdecouple = 2;
				break;
			
				// Decouple three closers
			case OPERATOR_USHIFT_RIGHT:
				maxdecouple = 3;
				break;
		
				// These may appear in the middle of generic brackets so
				// if they are read do not clear the count
				// Primitive types may be used in arrays such as for
				// Foo<Bar[]>
			case IDENTIFIER:
			case KEYWORD_EXTENDS:
			case KEYWORD_BOOLEAN:
			case KEYWORD_BYTE:
			case KEYWORD_SHORT:
			case KEYWORD_CHAR:
			case KEYWORD_INT:
			case KEYWORD_LONG:
			case KEYWORD_FLOAT:
			case KEYWORD_DOUBLE:
			case SYMBOL_OPEN_BRACKET:
			case SYMBOL_CLOSED_BRACKET:
			case SYMBOL_QUESTION:
			case SYMBOL_DOT:
			case SYMBOL_COMMA:
				break;
			
				// Every other symbol cannot appear in a generic
				// declaration so there is no possible chance that this was
				// meant to be used for generics
			default:
				opencount = 0;
				break;
		}
		
		// Use for later processing
		this._lasttype = type;
		
		// There are tokens which may be decoupled
		if (maxdecouple > 0)
		{
			// If there are more things to decouple than things which are
			// open then it is possible there is something illegal like
			// `Foo<Bar>> 2` or similar, otherwise that illegal bitshift will
			// end up being turned into `> >` logically
			if (maxdecouple > opencount)
				opencount = 0;
			
			// Translate the >> or >>> into multiple tokens according to
			// the decoupling count
			else
			{
				// Set the token to be returned which is initially decoupled
				// Since the original token is being decoupled, just ignore
				// whatever was originally here
				rv = new Token(TokenType.COMPARE_GREATER_THAN, ">",
					this.filename, rv.line(), rv.column(), usecomments);
				
				// Set these initial values because a decoupled token will
				// always be returned
				this._decomposewait = maxdecouple - 1;
				this._decomposedid = 1;
				
				// Treat decoupled tokens as closing statements
				this._opencount = opencount - maxdecouple;
			}
		}
		
		// Use that original token
		return rv;
	}
	
	/**
	 * Returns the next raw token which was read from the input.
	 *
	 * @return The read token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2018/04/18
	 */
	private final Token __decodeToken()
		throws TokenizerException
	{
		// Loop to skip whitespace
		for (;;)
		{
			// Record before read because the read will make the column count
			// and possibly even the row be off by one
			int line = this._curline,
				column = this._curcolumn;
			
			// Stop at EOF
			int c = this.__nextChar();
			if (c < 0)
			{
				// Just keep sending EOF tokens forever
				return __token(TokenType.END_OF_FILE, "");
			}
			
			// Skip whitespace
			if (CharacterTest.isWhite(c))
				continue;
			
			// Token position, used for debugging
			this._atline = line;
			this._atcolumn = column;
			
			// Forward slash: comments, /, or /=.
			if (c == '/')
				return __determineForwardSlash();
			
			// Equal sign
			else if (c == '=')
				return __determineEquals();
			
			// Dot
			else if (c == '.')
			{
				// If the following character is a number then this is a
				// decimal digit
				int p = this.__peekChar();
				if (p >= '0' && p <= '9')
					return this.__getNumberLiteral((char)p);
				
				// If it is a dot then it could be ...
				else if (p == '.')
				{
					// Consume that character
					this.__nextChar();
					
					// {@squirreljme.error AQ2w Invalid elipses, three
					// dots were expected but only two were read.}
					p = this.__nextChar();
					if (p != '.')
						throw new TokenizerException(this, "AQ2w");
					
					return this.__token(TokenType.SYMBOL_ELLIPSES, "...");
				}
				
				// Otherwise just a dot
				return this.__token(TokenType.SYMBOL_DOT, ".");
			}
			
			// Ternary colon, case, label, or method reference
			else if (c == ':')
			{
				// Could be a double colon
				int peek = this.__peekChar();
				if (peek == ':')
				{
					this.__nextChar();
					return this.__token(TokenType.SYMBOL_DOUBLE_COLON, "::");
				}
				
				// Only a single one
				return this.__token(TokenType.SYMBOL_COLON, ":");
			}
			
			// Identifiers
			else if (CharacterTest.isIdentifierStart((char)c))
				return __getIdentifier((char)c);
			
			// Integer/float literals
			else if (c >= '0' && c <= '9')
				return __getNumberLiteral((char)c);
			
			// String
			else if (c == '\"')
				return this.__getString();
			
			// Is start is a potential symbol
			else if (CharacterTest.isSymbolStart(c))
				return this.__determineOperator(c);
			
			// {@squirreljme.error AQ2x Unknown character while tokenizing the
			// Java source code. (The character; The line; The column)}
			else
				throw new TokenizerException(this,
					String.format("AQ2x %c %d %d", (char)c, line, column));
		}
	}
	
	/**
	 * Decides how to parse an equal sign.
	 *
	 * @return The read token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/11
	 */
	private Token __determineEquals()
		throws TokenizerException
	{
		// Checking for equality?
		int d = __peekChar();
		if (d == '=')
		{
			__nextChar();
			return __token(TokenType.COMPARE_EQUALS, "==");
		}
		
		// Just an assignment
		else
			return __token(TokenType.OPERATOR_ASSIGN, "=");
	}
	
	/**
	 * Decides what to do with a forward slash.
	 *
	 * @return The read token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/09
	 */
	private Token __determineForwardSlash()
		throws TokenizerException
	{
		int c = __peekChar();
		
		// Not-divide
		if (c == '*' || c == '/' || c == '=')
		{
			// Eat character
			__nextChar();
			
			// Multi-line comment
			if (c == '*')
				return __getMultiLineComment();
		
			// Single line comment
			else if (c == '/')
				return __getSingleLineComment();
		
			// Divide and assign
			else
				return __token(TokenType.OPERATOR_DIVIDE_ASSIGN,
					"/=");
		}
		
		// Divide otherwise
		else
			return __token(TokenType.OPERATOR_DIVIDE, "/");
	}
	
	/**
	 * Decides how to decode a given sequence to read an operator from it.
	 *
	 * @param __c The starting character.
	 * @return The resulting token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2018/03/06
	 */
	private Token __determineOperator(int __c)
		throws TokenizerException
	{
		List<String> operators = Tokenizer._OPERATORS;
		int numops = operators.size();
		int[] merge = Tokenizer._OPERATOR_MERGE;
		
		// Setup candidate list
		boolean[] candidate = new boolean[numops],
			oldcandidate = new boolean[numops];
		for (int i = 0; i < numops; i++)
		{
			oldcandidate[i] = true;
			candidate[i] = true;
		}
		
		// Setup current fill
		int fill = 0xFF_FF_FF_00 | (__c < 128 ? __c & 0x7F : 0xFE),
			mask = 0x00_00_00_FF;
		
		// Determine which token is used for the character
		boolean needconsume = false;
		int foundop = -1,
			newcandidates = 0,
			tempfoundop = -1;
		for (;;)
		{
			// Get old values which is used to determine a match
			int oldnewcandidates = newcandidates,
				oldtempfoundfop = tempfoundop;
			
			// Clear for a new run;
			newcandidates = 0;
			tempfoundop = -1;
			
			// Determine which characters map
			for (int i = 0; i < numops; i++)
			{
				// Do not check this token
				boolean iscandidate = candidate[i];
				oldcandidate[i] = candidate[i];
				if (!iscandidate)
					continue;
				
				// Cannot be the character
				if ((fill & mask) != (merge[i] & mask))
					candidate[i] = false;
				
				// Could be the characters
				else
				{
					newcandidates++;
					tempfoundop = i;
				}
			}
			
			// Only one character is valid?
			// The check here makes the search for single character sequences
			// and >>>= valid
			if (newcandidates == 1)
			{
				// Need to consume the character?
				if (needconsume)
					this.__nextChar();
				
				foundop = tempfoundop;
				break;
			}
			
			// Nothing is valid, then an old one is valid
			else if (newcandidates == 0)
			{
				// Unmask and unfill
				int unfill = (fill >>> 8) | 0xFF_00_00_00,
					unmask = (mask >>> 8);
				
				// Go through the old candidate list and determine the
				// character to use.
				for (int i = 0; i < numops; i++)
				{
					if (!oldcandidate[i])
						continue;
					
					// Must match the sequence exactly including the upper
					// bits because those are considered invalid
					if (unfill == merge[i])
					{
						foundop = i;
						break;
					}
				}
				
				// {@squirreljme.error AQ2y Could not determine the
				// operator to decode.}
				if (foundop < 0)
					throw new TokenizerException(this, "AQ2y");
				break;
			}
			
			// Need to consume the character before trying again?
			if (needconsume)
				this.__nextChar();
			
			// Peek in next character
			needconsume = true;
			__c = this.__peekChar();
			
			// Fill in character
			fill <<= 8;
			fill |= (__c >= 0 && __c < 128 ? __c & 0x7F : 0xFE);
			
			// Already at the maximum mask, nothing else to try
			if (mask == 0xFF_FF_FF_FF)
				break;
			
			// Increase mask to confirm checking area
			mask <<= 8;
			mask |= 0xFF;
		}
		
		// {@squirreljme.error AQ2z Could not decode an operator.}
		if (foundop < 0)
			throw new TokenizerException(this, "AQ2z");
		
		return this.__tokenOperator(operators.get(foundop));
	}
	
	/**
	 * Reads an identifier.
	 *
	 * @param __ic The initial character.
	 * @return The read identifier.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/10
	 */
	private Token __getIdentifier(char __ic)
		throws TokenizerException
	{
		StringBuilder sb = new StringBuilder();
		sb.append(__ic);
		for (;;)
		{
			// Only consider identifier parts
			int c = __peekChar();
			if (c < 0 || !CharacterTest.isIdentifierPart((char)c))
			{
				String s = sb.toString();
				TokenType t;
				switch (s)
				{
						// {@squirreljme.error AQ30 The specified keywords
						// are reserved and not valid. (The keyword)}
					case "const":
					case "goto":
						throw new TokenizerException(this, String.format(
							"AQ30 %s", __token(TokenType.IDENTIFIER, s)));
					
					case "abstract":	t = TokenType.KEYWORD_ABSTRACT; break;
					case "assert":		t = TokenType.KEYWORD_ASSERT; break;
					case "boolean":		t = TokenType.KEYWORD_BOOLEAN; break;
					case "break":		t = TokenType.KEYWORD_BREAK; break;
					case "byte":		t = TokenType.KEYWORD_BYTE; break;
					case "case":		t = TokenType.KEYWORD_CASE; break;
					case "catch":		t = TokenType.KEYWORD_CATCH; break;
					case "char":		t = TokenType.KEYWORD_CHAR; break;
					case "class":		t = TokenType.KEYWORD_CLASS; break;
					case "continue":	t = TokenType.KEYWORD_CONTINUE; break;
					case "default":		t = TokenType.KEYWORD_DEFAULT; break;
					case "do":			t = TokenType.KEYWORD_DO; break;
					case "double":		t = TokenType.KEYWORD_DOUBLE; break;
					case "else":		t = TokenType.KEYWORD_ELSE; break;
					case "enum":		t = TokenType.KEYWORD_ENUM; break;
					case "extends":		t = TokenType.KEYWORD_EXTENDS; break;
					case "final":		t = TokenType.KEYWORD_FINAL; break;
					case "finally":		t = TokenType.KEYWORD_FINALLY; break;
					case "float":		t = TokenType.KEYWORD_FLOAT; break;
					case "for":			t = TokenType.KEYWORD_FOR; break;
					case "if":			t = TokenType.KEYWORD_IF; break;
					case "implements":
						t = TokenType.KEYWORD_IMPLEMENTS;
						break;
						
					case "import":		t = TokenType.KEYWORD_IMPORT; break;
					case "instanceof":
						t = TokenType.KEYWORD_INSTANCEOF;
						break;
					case "int":			t = TokenType.KEYWORD_INT; break;
					case "interface":	t = TokenType.KEYWORD_INTERFACE; break;
					case "long":		t = TokenType.KEYWORD_LONG; break;
					case "native":		t = TokenType.KEYWORD_NATIVE; break;
					case "new":			t = TokenType.KEYWORD_NEW; break;
					case "package":		t = TokenType.KEYWORD_PACKAGE; break;
					case "private":		t = TokenType.KEYWORD_PRIVATE; break;
					case "protected":	t = TokenType.KEYWORD_PROTECTED; break;
					case "public":		t = TokenType.KEYWORD_PUBLIC; break;
					case "return":		t = TokenType.KEYWORD_RETURN; break;
					case "short":		t = TokenType.KEYWORD_SHORT; break;
					case "static":		t = TokenType.KEYWORD_STATIC; break;
					case "strictfp":	t = TokenType.KEYWORD_STRICTFP; break;
					case "super":		t = TokenType.KEYWORD_SUPER; break;
					case "switch":		t = TokenType.KEYWORD_SWITCH; break;
					case "synchronized":
						t = TokenType.KEYWORD_SYNCHRONIZED;
						break;
						
					case "this":		t = TokenType.KEYWORD_THIS; break;
					case "throw":		t = TokenType.KEYWORD_THROW; break;
					case "throws":		t = TokenType.KEYWORD_THROWS; break;
					case "transient":	t = TokenType.KEYWORD_TRANSIENT; break;
					case "try":			t = TokenType.KEYWORD_TRY; break;
					case "void":		t = TokenType.KEYWORD_VOID; break;
					case "volatile":	t = TokenType.KEYWORD_VOLATILE; break;
					case "while":		t = TokenType.KEYWORD_WHILE; break;
					case "null":		t = TokenType.LITERAL_NULL; break;
					case "false":		t = TokenType.LITERAL_FALSE; break;
					case "true":		t = TokenType.LITERAL_TRUE; break;
					default:			t = TokenType.IDENTIFIER; break;
				}
				
				return __token(t, s); 
			}
			
			// Consume it
			sb.append((char)__nextChar());
		}
	}
	
	/**
	 * Reads a multi-line comment.
	 *
	 * @return The comment token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/11
	 */
	private Token __getMultiLineComment()
		throws TokenizerException
	{
		StringBuilder sb = new StringBuilder();
		for (;;)
		{
			// {@squirreljme.error AQ31 End of file reached while reading a
			// multi-line comment.}
			int c = __peekChar();
			if (c < 0)
				throw new TokenizerException(this, "AQ31");
			
			// Potential end of comment?
			if (c == '*')
			{
				// Need to potentially detect the slash
				c = __nextChar();
				int d = __peekChar();
				
				// Finish it, do not include the */
				if (d == '/')
				{
					// Eat the slash otherwise divide operators will always
					// follow multi-line comments
					__nextChar();
					return __token(TokenType.COMMENT, sb);
				}
				
				// Just some asterisk
				else
					sb.append((char)c);
			}
			
			// Normal
			else
				sb.append((char)__nextChar());
		}
	}
	
	/**
	 * Decodes a number literal which could be an integer or floating point
	 * value.
	 *
	 * @param __c The initial read character.
	 * @return The decoded token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/11
	 */
	private Token __getNumberLiteral(char __c)
		throws TokenizerException
	{
		// Read a decimal point?
		boolean gotdec = (__c == '.');
		
		// All possibilities are available at start
		boolean isbinint = true,
			isoctint = true,
			isdecint = true,
			ishexint = true,
			isdecfloat = true,
			ishexfloat = true;
		
		// Only decimal values
		if (__c >= '1' && __c <= '9')
			isbinint = isoctint = ishexint = ishexfloat = false;
		
		// Otherwise cannot be an integer. Note that it can still be a decimal
		// float because 0009.7 is possible to be decoded still.
		else
			isdecint = false;
		
		// Resulting token
		StringBuilder sb = new StringBuilder();
		sb.append(__c);
		
		// Literal processing is a bit complex and as such there is much
		// handling for state within this loop. One general thing to remember
		// is that something which appears invalid for one state can be
		// completely valid for another state.
		// So this basically just tries to invalidate everything
		for (int inchars = 1;;)
		{
			// If the next character is one of these then it cannot possibly
			// part of a number
			int peek = this.__peekChar();
			if (peek < 0 || CharacterTest.isWhite(peek) ||
				!CharacterTest.isPossibleNumberChar(peek))
			{
				// {@squirreljme.error AQ32 An identifier character cannot
				// follow a numerical literal. (The next character)}
				if (CharacterTest.isIdentifierPart(peek))
					throw new TokenizerException(this, 
						String.format("AQ32 %c", peek));
				break;
			}
			
			// Debug
			todo.DEBUG.note("Literal char: %c", peek);
			
			// {@squirreljme.error AQ33 Number has multiple decimal points,
			// only one is valid.}
			if (peek == '.')
			{
				if (gotdec)
					throw new TokenizerException(this, "AQ33");
				gotdec = true;
			}
			
			// Binary literal?
			if (isbinint)
			{
				throw new todo.TODO();
			}
			
			// Octal literal?
			if (isoctint)
			{
				throw new todo.TODO();
			}
			
			// Decimal literal?
			if (isdecint)
			{
				throw new todo.TODO();
			}
			
			// Hexadecimal literal?
			if (ishexint)
			{
				throw new todo.TODO();
			}
			
			// Float literal?
			if (isdecfloat)
			{
				throw new todo.TODO();
			}
			
			// Hexfloat literal?
			if (ishexfloat)
			{
				throw new todo.TODO();
			}
			
			// If this point is reached then the character is valid
			sb.append((char)this.__nextChar());
			inchars++;
			
			// {@squirreljme.error AQ34 No numberal literals left to put
			// the literal under as they have all been ruled out. (The
			// current string sequence)}
			if (!isbinint && !isbinint && !isoctint && !isdecint &&
				!ishexint && !isdecfloat && !ishexfloat)
				throw new TokenizerException(this, 
					String.format("AQ34 %s", sb));
		}
		
		// Token only had a length of one so these will never be valid
		// because they require prefixes
		int outlen = sb.length();
		if (outlen == 1)
			isbinint = ishexint = ishexfloat = false;
		
		// Determine the best type for the token
		TokenType type;
		if (isbinint)
			type = TokenType.LITERAL_BINARY_INTEGER;
		else if (isoctint)
			type = TokenType.LITERAL_OCTAL_INTEGER;
		else if (isdecint)
			type = TokenType.LITERAL_DECIMAL_INTEGER;
		else if (ishexint)
			type = TokenType.LITERAL_HEXADECIMAL_INTEGER;
		else if (isdecfloat)
			type = TokenType.LITERAL_DECIMAL_FLOAT;
		else if (ishexfloat)
			type = TokenType.LITERAL_HEXADECIMAL_FLOAT;
		
		// {@squirreljme.error AQ35 Could not determine type of number
		// literal is used for the given string. (The token string)}
		else
			throw new TokenizerException(this, 
				String.format("AQ35 %s", sb.toString()));
		
		// Use that!
		return __token(type, sb.toString());
	}
	
	/**
	 * Reads a single line comment.
	 *
	 * @return The decoded token.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2017/09/09
	 */
	private Token __getSingleLineComment()
		throws TokenizerException
	{
		StringBuilder sb = new StringBuilder();
		for (;;)
		{
			// Stop if it is consider the end of line
			int c = __peekChar();
			if (c < 0 || CharacterTest.isNewline(c))
				return __token(TokenType.COMMENT, sb);
			
			// Otherwise consume it
			sb.append((char)__nextChar());
		}
	}
	
	/**
	 * Decodes a string.
	 *
	 * @return The resulting string.
	 * @throws TokenizerException If the token is not valid.
	 * @since 2018/03/06
	 */
	private Token __getString()
		throws TokenizerException
	{
		StringBuilder sb = new StringBuilder("\"");
		boolean escaped = false;
		for (;;)
		{
			int c = __nextChar();
			if (c == '\\')
				escaped = true;
			else if (!escaped && c == '\"')
			{
				sb.append((char)c);
				return __token(TokenType.LITERAL_STRING, sb);
			}
			
			// Consume it
			sb.append((char)c);
		}
	}
	
	/**
	 * Returns the next character.
	 *
	 * @return The next character.
	 * @throws TokenizerException If the next token could not be read.
	 * @since 2017/09/09
	 */
	private int __nextChar()
		throws TokenizerException
	{
		// Peek character so it is in the buffer
		__peekChar();
		
		// Position needed for finding errors
		this._curline = this._nxline;
		this._curcolumn = this._nxcolumn;
		
		// Use the next character
		int rv = this._nxchar;
		this._nxwaiting = false;
		this._nxchar = -1;
		return rv;
	}
	
	/**
	 * Peeks the next character.
	 *
	 * @return The next character.
	 * @throws TokenizerException If the next character could not be peeked.
	 * @since 2017/09/09
	 */
	private int __peekChar()
		throws TokenizerException
	{
		try
		{
			// Use the pre-existing character
			if (this._nxwaiting)
				return this._nxchar;
			
			// Read in next character
			LogicalReader in = this.in;
			int c = in.read(),
				ln = in.line(),
				cl = in.column();
			
			// Set details
			this._nxchar = c;
			this._nxline = ln;
			this._nxcolumn = cl;
			this._nxwaiting = true;
			
			// Need to know the actual character
			return c;
		}
		
		// {@squirreljme.error AQ36 Could not read the next character.}
		catch (IOException e)
		{
			throw new TokenizerException(this, "AQ36", e);
		}
	}
	
	/**
	 * Creates a token and returns it.
	 *
	 * @param __t The type of token to create.
	 * @param __s The string making up the token characters.
	 * @return The created token.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/09
	 */
	private Token __token(TokenType __t, CharSequence __s)
		throws NullPointerException
	{
		// Check
		if (__t == null || __s == null)
			throw new NullPointerException("NARG");
		
		return new Token(__t, __s.toString(), this.in.fileName(), this._atline,
			this._atcolumn);
	}
	
	/**
	 * Parses the specified sequence as an operator.
	 *
	 * @param __s The sequence to decode.
	 * @return The token for the operator.
	 * @throws NullPointerException On null arguments.
	 * @throws TokenizerException If the sequence is not valid.
	 * @since 2018/03/06
	 */
	private Token __tokenOperator(CharSequence __s)
		throws NullPointerException, TokenizerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Depends on the sequence
		String s = __s.toString();
		TokenType type;
		switch (s)
		{
			case "^":	type = TokenType.OPERATOR_XOR; break;
			case "^=":	type = TokenType.OPERATOR_XOR_ASSIGN; break;
			case "~":	type = TokenType.OPERATOR_COMPLEMENT; break;
			case "<":	type = TokenType.COMPARE_LESS_THAN; break;
			case "<<":	type = TokenType.OPERATOR_SHIFT_LEFT; break;
			case "<<=":	type = TokenType.OPERATOR_SHIFT_LEFT_ASSIGN; break;
			case "<=":	type = TokenType.COMPARE_LESS_OR_EQUAL; break;
			case "=":	type = TokenType.OPERATOR_ASSIGN; break;
			case "==":	type = TokenType.COMPARE_EQUALS; break;
			case ">":	type = TokenType.COMPARE_GREATER_THAN; break;
			case ">=":	type = TokenType.COMPARE_GREATER_OR_EQUAL; break;
			case ">>":	type = TokenType.OPERATOR_SSHIFT_RIGHT; break;
			case ">>=":	type = TokenType.OPERATOR_SSHIFT_RIGHT_ASSIGN; break;
			case ">>>":	type = TokenType.OPERATOR_USHIFT_RIGHT; break;
			case ">>>=":type = TokenType.OPERATOR_USHIFT_RIGHT_ASSIGN; break;
			case "|":	type = TokenType.OPERATOR_OR; break;
			case "|=":	type = TokenType.OPERATOR_OR_ASSIGN; break;
			case "||":	type = TokenType.COMPARE_OR; break;
			case "-":	type = TokenType.OPERATOR_MINUS; break;
			case "->":	type = TokenType.SYMBOL_LAMBDA; break;
			case "-=":	type = TokenType.OPERATOR_MINUS_ASSIGN; break;
			case "--":	type = TokenType.OPERATOR_DECREMENT; break;
			case ",":	type = TokenType.SYMBOL_COMMA; break;
			case ";":	type = TokenType.SYMBOL_SEMICOLON; break;
			case ":":	type = TokenType.SYMBOL_COLON; break;
			case "::":	type = TokenType.SYMBOL_DOUBLE_COLON; break;
			case "!":	type = TokenType.OPERATOR_NOT; break;
			case "!=":	type = TokenType.COMPARE_NOT_EQUALS; break;
			case "?":	type = TokenType.SYMBOL_QUESTION; break;
			case "/":	type = TokenType.OPERATOR_DIVIDE; break;
			case "/=":	type = TokenType.OPERATOR_DIVIDE_ASSIGN; break;
			case ".":	type = TokenType.SYMBOL_DOT; break;
			case "(":	type = TokenType.SYMBOL_OPEN_PARENTHESIS; break;
			case ")":	type = TokenType.SYMBOL_CLOSED_PARENTHESIS; break;
			case "[":	type = TokenType.SYMBOL_OPEN_BRACKET; break;
			case "]":	type = TokenType.SYMBOL_CLOSED_BRACKET; break;
			case "{":	type = TokenType.SYMBOL_OPEN_BRACE; break;
			case "}":	type = TokenType.SYMBOL_CLOSED_BRACE; break;
			case "*":	type = TokenType.OPERATOR_MULTIPLY; break;
			case "*=":	type = TokenType.OPERATOR_MULTIPLY_ASSIGN; break;
			case "&":	type = TokenType.OPERATOR_AND; break;
			case "&=":	type = TokenType.OPERATOR_AND_ASSIGN; break;
			case "&&":	type = TokenType.COMPARE_AND; break;
			case "%":	type = TokenType.OPERATOR_REMAINDER; break;
			case "%=":	type = TokenType.OPERATOR_REMAINDER_ASSIGN; break;
			case "+":	type = TokenType.OPERATOR_PLUS; break;
			case "+=":	type = TokenType.OPERATOR_PLUS_ASSIGN; break;
			case "++":	type = TokenType.OPERATOR_INCREMENT; break;
			case "@":	type = TokenType.SYMBOL_AT; break;
			
				// {@squirreljme.error AQ37 Could not determine the used
				// operator for the given sequence. (The sequence)}
			default:
				throw new TokenizerException(this, 
					String.format("AQ37 %s", s));
		}
		
		// Generate
		return this.__token(type, s);
	}

	/**
	 * Wraps the input stream for reading UTF-8.
	 *
	 * @param __is The read to read from.
	 * @return The wrapped reader.
	 * @throws RuntimeException If UTF-8 is not supported but this should
	 * never happen.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/09/04
	 */
	private static Reader __wrap(InputStream __is)
		throws RuntimeException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");

		// Could fail, but it never should
		try
		{
			return new InputStreamReader(__is, "utf-8");
		}

		// Should never happen
		catch (UnsupportedEncodingException e)
		{
			throw new todo.OOPS(e);
		}
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/TokenizerException.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.javac.token;

import net.multiphasicapps.javac.CompilerException;
import net.multiphasicapps.javac.LocationAware;

/**
 * This is thrown when there is an issue with the tokenizer.
 *
 * @since 2017/09/05
 */
public class TokenizerException
	extends CompilerException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/12
	 */
	public TokenizerException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/12
	 */
	public TokenizerException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/12
	 */
	public TokenizerException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/12
	 */
	public TokenizerException(Throwable __c)
	{
		super(__c);
	}
	
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @param __la Location awareness information.
	 * @since 2018/03/12
	 */
	public TokenizerException(LocationAware __la)
	{
		super(__la);
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @since 2018/03/12
	 */
	public TokenizerException(LocationAware __la, String __m)
	{
		super(__la, __m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __la Location awareness information.
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/12
	 */
	public TokenizerException(LocationAware __la, String __m, Throwable __c)
	{
		super(__la, __m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __la Location awareness information.
	 * @param __c The cause.
	 * @since 2018/03/12
	 */
	public TokenizerException(LocationAware __la, Throwable __c)
	{
		super(__la, __c);
	}
}

Deleted runt/libs/tool-compiler/net/multiphasicapps/javac/token/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the tokenizers for Java source code which is needed
 * by the documenter and compiler to parse Java source code.
 *
 * @since 2017/09/04
 */

package net.multiphasicapps.javac.token;

Deleted runt/libs/tool-jarfile/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 7734bfb5-c8e0-678e-2be9-dd49a60664fd
X-SquirrelJME-Error: BC
X-SquirrelJME-Name: Jar File Tools
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project takes input Jar files and 
 compiles/converts them into a format that is more easily used by 
 SummerCoat and RatufaCoat.
X-SquirrelJME-Depends: tool-classfile common-vm
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/BootstrapState.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.Constants;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.Minimizer;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This contains the state of the entire bootstrap, its memory and all of the
 * classes which may be loaded accordingly.
 *
 * @since 2019/09/14
 */
public final class BootstrapState
{
	/** The size of the static field area. */
	public static final int STATIC_FIELD_SIZE =
		8192;
	
	/** The initializer to use. */
	protected final Initializer initializer =
		new Initializer();
	
	/** Class information which has been loaded. */
	private final Map<ClassName, LoadedClassInfo> _classinfos =
		new LinkedHashMap<>();
	
	/** Reference to self. */
	private final Reference<BootstrapState> _selfref =
		new WeakReference<>(this);
	
	/** Intern strings. */
	private final Map<String, Integer> _interns =
		new HashMap<>();
	
	/** Static field pointer area. */
	private int _sfieldarea;
	
	/** Static field area next pointer. */
	private int _sfieldnext;
	
	/**
	 * Allocates static field space.
	 *
	 * @return The pointer to the static field area that was allocated.
	 * @throws IllegalArgumentException If the size is zero or negative.
	 * @since 2019/09/14
	 */
	public final int allocateStaticFieldSpace(int __sz)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BC0e Cannot allocate negative static
		// field space.}
		if (__sz < 0)
			throw new IllegalArgumentException("BC0e");
		
		// Allocate area for static fields, if not done yet
		int sfieldarea = this.staticFieldAreaAddress();
		
		// Determine the space that is needed
		int sfieldnext = this._sfieldnext;
		int snext = sfieldnext + __sz;
		
		// {@squirreljme.error BC03 Ran out of static field space.}
		if (snext >= BootstrapState.STATIC_FIELD_SIZE)
			throw new RuntimeException("BC03");
			
		// Set next pointer area
		this._sfieldnext = snext;
		
		// Pointer is here
		return sfieldnext;
	}
	
	/**
	 * Builds a character array.
	 *
	 * @param __v The characters to build.
	 * @return The pointer to the char array.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public final int buildCharArray(char... __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
			
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// The number of elements to store
		int n = __v.length;
		
		// Return pointer
		int rv = this.reserveCharArray(n);
		
		// Write details of object
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			rv + Constants.OBJECT_CLASS_OFFSET,
			this.findClass("[C").infoPointer());
		initializer.memWriteInt(
			rv + Constants.OBJECT_COUNT_OFFSET,
			999999);
		initializer.memWriteInt(
			rv + Constants.ARRAY_LENGTH_OFFSET,
			n);
		
		// Write values in the array
		for (int i = 0, wp = rv + Constants.ARRAY_BASE_SIZE;
			i < n; i++, wp += 2)
			initializer.memWriteShort(null, wp, (short)__v[i]);
		
		return rv;
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(Modifier __m, int... __v)
		throws NullPointerException
	{
		return this.buildIntArray(new ClassName("[I"), __m, __v);
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(String __t, Modifier __m, int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		return this.buildIntArray(new ClassName(__t), __m, __v);
	}
	
	/**
	 * Allocates an array of integers and stores values.
	 *
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int buildIntArray(ClassName __t, Modifier __m, int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		return this.finalizeIntArray(this.reserveIntArray(__v.length),
			__t, __m, __v);
	}
	
	/**
	 * Returns an info pointer for the given class names.
	 *
	 * @param __cls The class names to get info pointers for.
	 * @return The pointer to the class info pointer list.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int classNamesInfoPointer(ClassNames __cls)
		throws NullPointerException
	{
		if (__cls == null)
			throw new NullPointerException("NARG");
		
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// Fill in values for pointers
		int n = __cls.size();
		int[] values = new int[n];
		for (int i = 0; i < n; i++)
			values[i] = this.findClass(__cls.get(i)).infoPointer();
		
		// Return array of these pointers
		return this.buildIntArray("[I", Modifier.RAM_OFFSET, values);
	}
	
	/**
	 * Finalizes the integer array by writing values over it.
	 *
	 * @param __p The array pointer.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int finalizeIntArray(int __p, Modifier __m, int... __v)
		throws NullPointerException
	{
		return this.finalizeIntArray(__p, new ClassName("[I"), __m, __v);
	}
	
	/**
	 * Finalizes the integer array by writing values over it.
	 *
	 * @param __p The array pointer.
	 * @param __t The type to use.
	 * @param __m The modifier of the values to use.
	 * @param __v The values in the array.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int finalizeIntArray(int __p, ClassName __t, Modifier __m,
		int... __v)
		throws NullPointerException
	{
		if (__t == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Needed for allocations and writes
		Initializer initializer = this.initializer;
		
		// Force a default modifier
		if (__m == null)
			__m = Modifier.NONE;
		
		// The number of elements to store
		int n = __v.length;
		
		// Write details of object
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			__p + Constants.OBJECT_CLASS_OFFSET,
			this.findClass(__t).infoPointer());
		initializer.memWriteInt(
			__p + Constants.OBJECT_COUNT_OFFSET,
			999999);
		initializer.memWriteInt(
			__p + Constants.ARRAY_LENGTH_OFFSET,
			n);
		
		// Write values in the array
		for (int i = 0, wp = __p + Constants.ARRAY_BASE_SIZE;
			i < n; i++, wp += 4)
			initializer.memWriteInt(__m, wp, __v[i]);
		
		return __p;
	}
	
	/**
	 * Finds the class which uses the given name.
	 *
	 * @param __cl The class name to find.
	 * @return The loaded class information.
	 * @throws InvalidClassFormatException If the class was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo findClass(String __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.findClass(new ClassName(__cl));
	}
	
	/**
	 * Finds the class which uses the given name.
	 *
	 * @param __cl The class name to find.
	 * @return The loaded class information.
	 * @throws InvalidClassFormatException If the class was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo findClass(ClassName __cl)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// Locate pre-loaded class
		Map<ClassName, LoadedClassInfo> classinfos = this._classinfos;
		LoadedClassInfo rv = classinfos.get(__cl);
		if (rv == null)
		{
			// Load special primitive and array types magically!
			if (__cl.isPrimitive() || __cl.isArray())
				classinfos.put(__cl, (rv = new LoadedClassInfo(
					Minimizer.minimizeAndDecode(
						ClassFile.special(__cl.field())), 0, this._selfref)));
			
			// {@squirreljme.error BC0c Could not find the specified class.
			// (The class name)}
			else
				throw new InvalidClassFormatException("BC0c " + __cl);
		}
		
		return rv;
	}
	
	/**
	 * Interns the given string.
	 *
	 * @param __s The string to intern.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/15
	 */
	public final int internString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// If it was loaded already, ignore
		Map<String, Integer> interns = this._interns;
		if (interns.containsKey(__s))
			return interns.get(__s);
		
		// Allocate string object
		LoadedClassInfo strci = this.findClass("java/lang/String");
		int strp = initializer.allocate(strci.allocationSize());
		
		// Cache it
		interns.put(__s, strp);
		
		// Setup class information
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			strp + Constants.OBJECT_CLASS_OFFSET,
			strci.infoPointer());
		initializer.memWriteInt(
			strp + Constants.OBJECT_COUNT_OFFSET,
			999999);
		
		// Write pointer to character array data
		initializer.memWriteInt(Modifier.RAM_OFFSET,
			strp + strci.fieldInstanceOffset(
				new FieldName("_chars"),
				new FieldDescriptor("[C")),
			this.buildCharArray(__s.toCharArray()));
		
		// Use the string pointer
		return strp;
	}
	
	/**
	 * Loads the class file information.
	 *
	 * @param __b The class file data.
	 * @param __pos The position of the class file in ROM.
	 * @return The loaded class information
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final LoadedClassInfo loadClassFile(byte[] __b, int __pos)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Decode it
		MinimizedClassFile cf = MinimizedClassFile.decode(__b);
		
		// Store loaded for later boot usage
		LoadedClassInfo rv;
		if (this._classinfos.put(cf.thisName(),
			(rv = new LoadedClassInfo(cf, __pos, this._selfref))) != null)
		{
			// {@squirreljme.error BC0b Class file has already been loaded.
			// (The class name)}
			throw new IllegalStateException("BC0b " + cf.thisName());
		}
		
		return rv;
	}
	
	/**
	 * Reserves a char array that can fit the specified number of characters.
	 *
	 * @param __n The length of the array.
	 * @return The pointer to the array.
	 * @since 2019/12/15
	 */
	public final int reserveCharArray(int __n)
	{
		return this.initializer.allocate(
			Constants.ARRAY_BASE_SIZE + (2 * __n));
	}
	
	/**
	 * Reserves an integer array that can fit the specified number of entries.
	 *
	 * @param __n The number of entries to reserve.
	 * @return The pointer to the integer array.
	 * @since 2019/09/16
	 */
	public final int reserveIntArray(int __n)
	{
		return this.initializer.allocate(
			Constants.ARRAY_BASE_SIZE + (4 * __n));
	}
	
	/**
	 * Returns the address of the static field area.
	 *
	 * @return The static field address area.
	 * @since 2019/09/14
	 */
	public final int staticFieldAreaAddress()
	{
		// Allocate area for static fields, if not done yet
		int sfieldarea = this._sfieldarea;
		if (sfieldarea <= 0)
			this._sfieldarea = (sfieldarea = this.initializer.allocate(
				BootstrapState.STATIC_FIELD_SIZE));
		
		return sfieldarea;
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/ClassNameAndMinimizedField.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import dev.shadowtail.classfile.mini.MinimizedField;
import net.multiphasicapps.classfile.ClassName;

/**
 * This contains a class and a minimized field.
 *
 * @since 2019/09/14
 */
public final class ClassNameAndMinimizedField
{
	/** The class name. */
	public final ClassName classname;
	
	/** The field. */
	public final MinimizedField field;
	
	/**
	 * Initializes the class name and field.
	 *
	 * @param __cn The class name.
	 * @param __mf The minimized field.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public ClassNameAndMinimizedField(ClassName __cn, MinimizedField __mf)
		throws NullPointerException
	{
		if (__cn == null || __mf == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
		this.field = __mf;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/09/21
	 */
	@Override
	public final String toString()
	{
		return this.classname + ":" + this.field.nameAndType();
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/ClassNameAndMinimizedMethod.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













































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import dev.shadowtail.classfile.mini.MinimizedMethod;
import net.multiphasicapps.classfile.ClassName;

/**
 * This contains a class and a minimized method.
 *
 * @since 2019/09/21
 */
public final class ClassNameAndMinimizedMethod
{
	/** The class name. */
	public final ClassName classname;
	
	/** The method. */
	public final MinimizedMethod method;
	
	/**
	 * Initializes the class name and method.
	 *
	 * @param __cn The class name.
	 * @param __mm The minimized method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/21
	 */
	public ClassNameAndMinimizedMethod(ClassName __cn, MinimizedMethod __mm)
		throws NullPointerException
	{
		if (__cn == null || __mm == null)
			throw new NullPointerException("NARG");
		
		this.classname = __cn;
		this.method = __mm;
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/Initializer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318






























































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.Constants;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This is used to build the initialization sequence accordingly. It is used
 * determine the initial amount of memory needed along with all the various
 * actions which need to be performed at this point.
 *
 * The initializer starts with a memory sequence chunk which could later be
 * freed when it is no longer needed potentially.
 *
 * @since 2019/04/30
 */
public final class Initializer
{
	/** Memory chunk size offset. */
	public static final int CHUNK_SIZE_OFFSET =
		0;
	
	/** Next chunk address. */
	public static final int CHUNK_NEXT_OFFSET =
		4;
	
	/** The length of chunks. */
	public static final int CHUNK_LENGTH =
		8;
	
	/** Operations. */
	private final List<Operation> _ops =
		new ArrayList<>();
	
	/** Current allocated temporary space. */
	private byte[] _bytes = new byte[65536];
	
	/** Current size of the initializer. */
	private int _size =
		0;
	
	/**
	 * Allocates memory in the initialization sequence.
	 *
	 * @param __sz The number of bytes to allocate.
	 * @return The pointer address of the allocation.
	 * @since 2019/04/30
	 */
	public final int allocate(int __sz)
	{
		// Force minimum size, otherwise things will get very messed up
		if (__sz < 1)
			__sz = 1;
		
		// Round allocation to 4-bytes
		__sz = (__sz + 3) & (~3);
		
		// Calculate the next size of the boot area
		int nowat = this._size,
			chunksize = __sz + CHUNK_LENGTH,
			nextat = nowat + chunksize;
		
		// If the memory space is too small, grow it
		byte[] bytes = this._bytes;
		if (nextat > bytes.length)
			this._bytes = (bytes = Arrays.copyOf(bytes, nextat + 2048));
		
		// The return address is after the chunk length
		int rv = nowat + CHUNK_LENGTH;
		
		// Record size of chunk and the next chunk position in RAM
		this.memWriteInt(null,
			nowat + CHUNK_SIZE_OFFSET, chunksize);
		this.memWriteInt(Modifier.RAM_OFFSET,
			nowat + CHUNK_NEXT_OFFSET, nextat);
		
		// Continue at the end
		this._size = nextat;
		return rv;
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteByte(int __addr, int __v)
	{
		this.memWriteByte(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteByte(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m != null && __m != Modifier.NONE)
			this._ops.add(new Operation(__m, (byte)1, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr] = (byte)__v;
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteInt(int __addr, int __v)
	{
		this.memWriteInt(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteInt(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)4, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 24);
		bytes[__addr++] = (byte)(__v >>> 16);
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/05/25
	 */
	public final void memWriteLong(int __addr, long __v)
	{
		this.memWriteLong(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/05/25
	 */
	public final void memWriteLong(Modifier __m, int __addr, long __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)8, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 56L);
		bytes[__addr++] = (byte)(__v >>> 48L);
		bytes[__addr++] = (byte)(__v >>> 40L);
		bytes[__addr++] = (byte)(__v >>> 32L);
		bytes[__addr++] = (byte)(__v >>> 24L);
		bytes[__addr++] = (byte)(__v >>> 16L);
		bytes[__addr++] = (byte)(__v >>> 8L);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteShort(int __addr, int __v)
	{
		this.memWriteShort(null, __addr, __v);
	}
	
	/**
	 * Writes a value to the given address.
	 *
	 * @param __m The modifier to use when writing.
	 * @param __addr The address to write to.
	 * @param __v The value to write.
	 * @since 2019/04/30
	 */
	public final void memWriteShort(Modifier __m, int __addr, int __v)
	{
		// Record action?
		if (__m == null)
			__m = Modifier.NONE;
		this._ops.add(new Operation(__m, (byte)2, __addr, __v));
		
		// Write data
		byte[] bytes = this._bytes;
		bytes[__addr++] = (byte)(__v >>> 8);
		bytes[__addr++] = (byte)(__v);
	}
	
	/**
	 * Converts and builds the initializer sequence.
	 *
	 * @return The byte array representing the sequence.
	 * @since 2019/04/30
	 */
	public final byte[] toByteArray()
	{
		List<Operation> ops = this._ops;
		byte[] bytes = this._bytes;
		int size = this._size;
		
		// Round up to prevent uneven sizes
		size = (size + 3) & (~3);
		
		// Give extra bytes for the terminator chunk
		size += CHUNK_LENGTH;
		
		// Write initializer RAM
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
			DataOutputStream dos = new DataOutputStream(baos))
		{
			// Write initializer memory chunk
			dos.writeInt(size);
			dos.write(bytes, 0, size);
			
			// Write out operations
			int n = ops.size();
			dos.writeInt(n);
			for (int i = 0; i < n; i++)
			{
				Operation op = ops.get(i);
				
				// Write operation tag and address offset
				dos.writeByte((op.size << 4) | (op.mod.ordinal()));
				dos.writeInt(op.addr);
				
				// Write the value
				Number v = op.value;
				switch (op.size)
				{
					case 1:
						dos.writeByte(v.byteValue());
						break;
						
					case 2:
						dos.writeShort(v.shortValue());
						break;
						
					case 4:
						dos.writeInt(v.intValue());
						break;
						
					case 8:
						dos.writeLong(v.longValue());
						break;
					
					default:
						throw new todo.OOPS();
				}
				
				// Debug
				if (JarMinimizer._ENABLE_DEBUG)
					todo.DEBUG.note("Op %-5d: %d@0x%08x = %d (%s)",
						i, op.size, op.addr, op.value, op.mod);
			}
			
			// End mark
			dos.writeInt(-1);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Wrote %d bytes, %d ops", dos.size(), n);
			
			// Done!
			return baos.toByteArray();
		}
		
		// {@squirreljme.error BC01 Could not export boot area.}
		catch (IOException e)
		{
			throw new RuntimeException("BC01", e);
		}
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/JarMinimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484




































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.ClassInfo;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.classfile.mini.DualPoolEncoder;
import dev.shadowtail.classfile.mini.DualPoolEncodeResult;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.MinimizedField;
import dev.shadowtail.classfile.mini.MinimizedMethod;
import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;
import dev.shadowtail.classfile.mini.Minimizer;
import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This class is responsible for creating minimized Jar files which will then
 * be built into a ROM and used by SummerCoat and RatufaCoat.
 *
 * @since 2019/04/27
 */
public final class JarMinimizer
{
	/**
	 * {@squirreljme.property dev.shadowtail.jarfile.debug=boolean
	 * Should debugging text be printed for the JAR minimizer?}
	 */
	static final boolean _ENABLE_DEBUG =
		Boolean.getBoolean("dev.shadowtail.jarfile.debug");
	
	/** The state of the bootstrap. */
	protected final BootstrapState bootstrap;
	
	/** Is this a boot JAR? */
	protected final boolean boot;
	
	/** The input JAR. */
	protected final VMClassLibrary input;
	
	/** The dual-combined constant pool. */
	protected final DualClassRuntimePoolBuilder dualpool;
	
	/** Are we using our own dual pool? */
	protected final boolean owndualpool;
	
	/** The resulting JAR header. */
	private MinimizedJarHeader _jheader;
	
	/**
	 * Initializes the minimizer worker.
	 *
	 * @param __dp The global dual constant pool, may be {@code null} to not
	 * use the pack-file global one.
	 * @param __boot Is this a boot JAR?
	 * @param __in The input library.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	private JarMinimizer(DualClassRuntimePoolBuilder __dp, boolean __boot,
		VMClassLibrary __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
			
		this.boot = __boot;
		this.input = __in;
		
		// Use the passed pool if it was passed, but otherwise just use one
		// in the event one was not passed through (uses our own pool)
		boolean owndualpool = (__boot ? false : (__dp == null));
		this.dualpool = (__boot ? null : (owndualpool ?
			new DualClassRuntimePoolBuilder() : __dp));
		this.owndualpool = owndualpool;
		
		// Setup bootstrap, but only if booting
		this.bootstrap = (__boot ? new BootstrapState() : null);
	}
	
	/**
	 * Processes the input JAR.
	 *
	 * @param __out The output.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	private final void __process(OutputStream __sout)
		throws IOException, NullPointerException
	{
		if (__sout == null)
			throw new NullPointerException("NARG");
		
		// The current state of the bootstrap
		BootstrapState bootstrap = this.bootstrap;
		Initializer initializer = (bootstrap == null ? null :
			bootstrap.initializer);
		
		// This is processed for all entries
		VMClassLibrary input = this.input;
		
		// Need list of resources to determine
		String[] rcnames = input.listResources();
		int numrc = rcnames.length;
		
		// Sort all the resources so that it is faster to find the entries
		Arrays.sort(rcnames);
		
		// Manifest offset and length
		int manifestoff = 0,
			manifestlen = 0;
		
		// Table of the entire JAR for writing
		TableSectionOutputStream out = new TableSectionOutputStream();
		
		// Start the header and table of contents
		// These are fixed size because the bootstrapper needs to know the
		// true pointer of the minified class file in the JAR
		TableSectionOutputStream.Section header = out.addSection(
			MinimizedJarHeader.HEADER_SIZE_WITH_MAGIC, 4);
		TableSectionOutputStream.Section toc = out.addSection(
			numrc * 16, 4);
		
		// Write base header and contents information
		header.writeInt(MinimizedJarHeader.MAGIC_NUMBER);
		header.writeInt(numrc);
		header.writeSectionAddressInt(toc);
		
		// The global dual-constant pool if one is available
		DualClassRuntimePoolBuilder dualpool = this.dualpool;
		
		// Buffer for byte copies
		byte[] copybuf = new byte[512];
		
		// Go through and add every resource
		for (int i = 0; i < numrc; i++)
		{
			// Resource to encode/copy
			String rc = rcnames[i];
			
			// Section to contain the data for this resource
			TableSectionOutputStream.Section rcdata = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Process the resource
			try (InputStream in = input.resourceAsStream(rc))
			{
				// Minimizing class file if it is a valid class
				if (rc.endsWith(".class") && ClassName.isValidClassName(
					rc.substring(0, rc.length() - 6)))
				{
					// Minimize the class
					byte[] bytes = Minimizer.minimize(dualpool,
						ClassFile.decode(in));
					
					// Write to ROM!
					rcdata.write(bytes);
					
					// Load class file if booting
					if (bootstrap != null)
						bootstrap.loadClassFile(bytes,
							out.sectionAddress(rcdata));
				}
				
				// Plain resource copy
				else
				{
					for (;;)
					{
						int ll = in.read(copybuf);
						
						// EOF?
						if (ll < 0)
							break;
						
						// Write
						rcdata.write(copybuf);
					}
				}
			}
			
			// Write the hash code of the entry name
			toc.writeInt(rc.hashCode());
			
			// Write name of the resource
			TableSectionOutputStream.Section rcname = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			rcname.writeUTF(rc);
			toc.writeSectionAddressInt(rcname);
			
			// Write position and size of the data
			toc.writeSectionAddressInt(rcdata);
			toc.writeSectionSizeInt(rcdata);
		}
		
		// Uncompressed and copied manifest?
		try (InputStream in = input.resourceAsStream("META-INF/MANIFEST.MF"))
		{
			// There is a manifest
			if (in != null)
			{
				TableSectionOutputStream.Section manifest = out.addSection(
					TableSectionOutputStream.VARIABLE_SIZE, 4);
				
				// Copy the manifest to an uncompressed section
				for (;;)
				{
					int ll = in.read(copybuf);
					
					// EOF?
					if (ll < 0)
						break;
					
					// Write
					manifest.write(copybuf);
				}
				
				// Manifest offset and length
				header.writeSectionAddressInt(manifest);
				header.writeSectionSizeInt(manifest);
			}
			
			// There is none
			else
			{
				header.writeInt(0);
				header.writeInt(0);
			}
		}
		
		// Doing bootstrapping?
		if (bootstrap != null)
		{
			// The class being booted
			LoadedClassInfo booting = bootstrap.findClass(
				"cc/squirreljme/jvm/Bootstrap");
			
			// Get all the bootstrap information before it is written!
			int bootpool = booting.poolPointer();
			int bootsfbp = bootstrap.staticFieldAreaAddress();
			int bootmeth = booting.methodCodeAddress(
				new MethodName("__start"), null);
			int bootidba = bootstrap.findClass("[B").infoPointer();
			int bootidbd = bootstrap.findClass("[[B").infoPointer();
			
			// Get the handler for system calls and such
			LoadedClassInfo tshclass = bootstrap.findClass(
				"cc/squirreljme/jvm/task/TaskSysCallHandler");
			int scmeth = tshclass.methodCodeAddress(
				new MethodName("taskSysCall"), null),
				scpool = tshclass.poolPointer();
			
			// Setup the BootRAM
			TableSectionOutputStream.Section bootram = out.addSection(
				bootstrap.initializer.toByteArray(), 4);
			
			// Boot memory offset, size
			header.writeSectionAddressInt(bootram);
			header.writeSectionSizeInt(bootram);
			
			// Pool, sfa, code
			header.writeInt(bootpool);
			header.writeInt(bootsfbp);
			header.writeInt(bootmeth);
			
			// System call SFP, handler, and pool
			header.writeInt(bootsfbp);
			header.writeInt(scmeth);
			header.writeInt(scpool);
			
			// classidba, classidbaa
			header.writeInt(bootidba);
			header.writeInt(bootidbd);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Boot entry: %d/0x%08x", bootmeth, bootmeth);
		}
		
		// No bootstrapping being done
		else
		{
			// Boot memory offset, size
			header.writeInt(0);
			header.writeInt(0);
			
			// Pool, sfa, code
			header.writeInt(0);
			header.writeInt(0);
			header.writeInt(0);
			
			// System call SFP, handler, and pool
			header.writeInt(0);
			header.writeInt(0);
			header.writeInt(0);
			
			// classidba, classidbaa
			header.writeInt(0);
			header.writeInt(0);
		}
		
		// Debug
		if (JarMinimizer._ENABLE_DEBUG)
			todo.DEBUG.note("Own pool=%s, dualpool=%s",
				this.owndualpool, dualpool);
		
		// We are using our own dual pool, so write it out as if it were
		// in the pack file. It is only local to this JAR.
		if (this.owndualpool && dualpool != null)
		{
			// Where our pools are going
			TableSectionOutputStream.Section lpd = out.addSection();
			
			// Encode the pools
			DualPoolEncodeResult der = DualPoolEncoder.encode(dualpool, lpd);
			
			// Static pool
			header.writeSectionAddressInt(lpd, der.staticpooloff);
			header.writeInt(der.staticpoolsize);
			
			// Run-time pool
			header.writeSectionAddressInt(lpd, der.runtimepooloff);
			header.writeInt(der.runtimepoolsize);
		}
		
		// We are using the global pack pool, so set special indicators
		// that we are doing as such! The minimized class will use special
		// a special aliased pool for the pack file.
		else
		{
			// Static pool offset and size
			header.writeInt(-1);
			header.writeInt(-1);
			
			// Runtime pool offset and size
			header.writeInt(-1);
			header.writeInt(-1);
		}
		
		// Since we need the header we need the byte array for the JAR
		byte[] jardata = out.toByteArray();
		
		// Get header for returning
		this._jheader = MinimizedJarHeader.decode(
			new ByteArrayInputStream(jardata));
		
		// Write to output
		__sout.write(jardata);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @return The resulting byte array of minimization.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final byte[] minimize(boolean __boot, VMClassLibrary __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Write to a temporary byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Perform minimization
			JarMinimizer.minimize(null, __boot, __in, baos, null);
			
			// Return the generated array
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final void minimize(boolean __boot, VMClassLibrary __in,
		OutputStream __out)
		throws IOException, NullPointerException
	{
		JarMinimizer.minimize(null, __boot, __in, __out, null);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @param __mjh The output JAR header.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/17
	 */
	public static final void minimize(boolean __boot, VMClassLibrary __in,
		OutputStream __out, MinimizedJarHeader[] __mjh)
		throws IOException, NullPointerException
	{
		JarMinimizer.minimize(null, __boot, __in, __out, __mjh);
	}
	
	/**
	 * Minimizes the specified Jar file.
	 *
	 * @param __dp The dual-pool.
	 * @param __boot Should pre-created boot memory be created to quickly
	 * initialize the virtual machine?
	 * @param __in The input JAR file.
	 * @param __out The stream where JAR data will be placed.
	 * @param __mjh The output JAR header.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final void minimize(DualClassRuntimePoolBuilder __dp,
		boolean __boot, VMClassLibrary __in, OutputStream __out,
		MinimizedJarHeader[] __mjh)
		throws IOException, NullPointerException
	{
		if (__in == null || __out == null)
			throw new NullPointerException("NARG");
		
		// Use helper class
		JarMinimizer jm = new JarMinimizer(__dp, __boot, __in);
		jm.__process(__out);
		
		// Set header that was generated
		if (__mjh != null && __mjh.length > 0)
			__mjh[0] = jm._jheader;
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/LoadedClassInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import cc.squirreljme.jvm.ClassInfo;
import cc.squirreljme.jvm.Constants;
import dev.shadowtail.classfile.mini.MinimizedClassFile;
import dev.shadowtail.classfile.mini.MinimizedField;
import dev.shadowtail.classfile.mini.MinimizedMethod;
import dev.shadowtail.classfile.mini.MinimizedPoolEntryType;
import dev.shadowtail.classfile.pool.AccessedField;
import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.ClassPool;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.MethodIndex;
import dev.shadowtail.classfile.pool.UsedString;
import java.lang.ref.Reference;
import java.util.Deque;
import java.util.LinkedList;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * Boot information for a class.
 *
 * @since 2019/04/30
 */
public final class LoadedClassInfo
{
	/** The bootstrap reference. */
	private final Reference<BootstrapState> _bootstrap;
	
	/** The minimized class. */
	private final MinimizedClassFile _class;
	
	/** The offset to the class. */
	private final int _classoffset;
	
	/** The offset to the constant pool allocation. */
	private int _pooloffset =
		-1;
	
	/** Static memory offset. */
	private int _smemoff =
		-1;
	
	/** The class data V2 offset. */
	private int _classdata =
		-1;
	
	/** The size of instances for this class. */
	private int _allocsize;
	
	/** The base pointer position for fields. */
	private int _baseoff =
		-1;
	
	/** The VTable for this class. */
	private int _vtable =
		-1;
	
	/** The constant pool references for this class vtable. */
	private int _vtablepool =
		-1;
	
	/** The depth of this class. */
	private int _classdepth =
		-1;
	
	/**
	 * Initializes the boot info.
	 *
	 * @param __cl The class.
	 * @param __co The class offset.
	 * @param __bs The reference to the owning bootstrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	LoadedClassInfo(MinimizedClassFile __cl, int __co,
		Reference<BootstrapState> __bs)
		throws NullPointerException
	{
		if (__cl == null || __bs == null)
			throw new NullPointerException("NARG");
		
		this._class = __cl;
		this._classoffset = __co;
		this._bootstrap = __bs;
	}
	
	/**
	 * The allocated instance size.
	 *
	 * @return The allocated instance size.
	 * @since 2019/09/14
	 */
	public final int allocationSize()
	{
		// Pre-cached already?
		int rv = this._allocsize;
		if (rv > 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// This class is the size of the super class and our size
		ClassName supercl = this._class.superName();
		this._allocsize = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).allocationSize()) +
			this._class.header.ifbytes);
		
		return rv;
	}
	
	/**
	 * Return the base offset of this class.
	 *
	 * @return The base off of this class.
	 * @since 2019/09/14
	 */
	public final int baseOffset()
	{
		// Was already cached?
		int rv = this._baseoff;
		if (rv >= 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The base offset is the allocation size of the super-class
		ClassName supercl = this._class.superName();
		this._baseoff = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).allocationSize()));
		
		return rv;
	}
	
	/**
	 * Returns the depth of this class.
	 *
	 * @return The depth of this class.
	 * @since 2019/12/01
	 */
	public final int classDepth()
	{
		// Was already cached?
		int rv = this._classdepth;
		if (rv >= 0)
			return rv;
		
		// Find the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The class depth is just one added from the super-class
		ClassName supercl = this._class.superName();
		this._classdepth = (rv = (supercl == null ? 0 :
			bootstrap.findClass(supercl).classDepth() + 1));
		
		return rv;
	}
	
	/**
	 * Returns the instance offset of the field.
	 *
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @return The offset of the field.
	 * @throws InvalidClassFormatException If the field was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int fieldInstanceOffset(FieldName __fn, FieldDescriptor __fd)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__fn == null || __fd == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BC02 Could not locate instance field. (Class;
		// Field Name; Field Type)}
		MinimizedField mf = this._class.field(false, __fn, __fd);
		if (mf == null)
			throw new InvalidClassFormatException(
				String.format("BC02 %s %s %s", this._class.thisName(), __fn,
					__fd));
		
		// Determine offset to field
		return this.baseOffset() + mf.offset;
	}
	
	/**
	 * Returns the static offset of the field.
	 *
	 * @param __fn The field name.
	 * @param __fd The field descriptor.
	 * @return The offset of the field.
	 * @throws InvalidClassFormatException If the field was not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/14
	 */
	public final int fieldStaticOffset(FieldName __fn, FieldDescriptor __fd)
		throws InvalidClassFormatException, NullPointerException
	{
		if (__fn == null || __fd == null)
			throw new NullPointerException("NARG");
		
		// Need the static field offset
		int smemoff = this.staticFieldOffset();
		
		// {@squirreljme.error BC04 Could not locate static field. (Class;
		// Field Name; Field Type)}
		MinimizedField mf = this._class.field(true, __fn, __fd);
		if (mf == null)
			throw new InvalidClassFormatException(
				String.format("BC04 %s %s %s", this._class.thisName(),
					__fn, __fd));
		
		// Return offset to it
		return smemoff + mf.offset;
	}
	
	/**
	 * Returns the pointer to the class information.
	 *
	 * @return The pointer to the class information.
	 * @since 2019/09/14
	 */
	public final int infoPointer()
	{
		// If it has already been initialized use it
		int rv = this._classdata;
		if (rv >= 0)
			return rv;
		
		// Get bootstrap and initializer
		BootstrapState bootstrap = this.__bootstrap();
		Initializer initializer = bootstrap.initializer;
		
		// Get the class info for class info
		LoadedClassInfo classinfoci =
			bootstrap.findClass("cc/squirreljme/jvm/ClassInfo");
		
		// Allocate pointer to the class data, then get the base pointer
		this._classdata = (rv = initializer.allocate(
			classinfoci.allocationSize()));
		
		// Load all fields into a queue for useful processing
		Deque<ClassNameAndMinimizedField> fieldq = new LinkedList<>();
		for (LoadedClassInfo atcl = classinfoci; atcl != null;
			atcl = atcl.superClass())
		{
			// Push all fields to queue
			for (MinimizedField mf : atcl._class.fields(false))
				fieldq.push(new ClassNameAndMinimizedField(
					atcl.thisName(), mf));
		}
		
		// This class information
		MinimizedClassFile mcf = this._class;
		ClassName thisname = mcf.thisName();
		
		// Fill in field data
		while (!fieldq.isEmpty())
		{
			// Get entry
			ClassNameAndMinimizedField cnmf = fieldq.pop();
			ClassName cn = cnmf.classname;
			MinimizedField mf = cnmf.field;
			
			// The write pointer of this data
			int wp = rv + bootstrap.findClass(cn).baseOffset() + mf.offset;
			
			// Depends on the key (specified where and its type)
			String key = mf.name + ":" + mf.type;
			switch (key)
			{
					// Base offset for the class
				case "base:I":
					initializer.memWriteInt(wp, this.baseOffset());
					break;
					
					// Cell size
				case "cellsize:I":
					{
						// Determine the cell size
						int cellsize;
						switch (thisname.toString())
						{
							case "byte":
							case "boolean":
							case "[Z":
							case "[B":
								cellsize = 1;
								break;
							
							case "short":
							case "char":
							case "[S":
							case "[C":
								cellsize = 2;
								break;
								
							case "long":
							case "double":
							case "[J":
							case "[D":
								cellsize = 8;
								break;
								
							default:
								cellsize = 4;
								break;
						}
						
						// Write
						initializer.memWriteInt(
							wp, cellsize);
					}
					break;
				
					// Class info reference
				case "_class:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, bootstrap.findClass(
							"cc/squirreljme/jvm/ClassInfo").infoPointer());
					break;
					
					// The depth of this class
				case "classdepth:I":
					initializer.memWriteInt(wp, this.classDepth());
					break;
					
					// Class<?> pointer, starts always at zero since it
					// is generated at run-time
				case "classobjptr:Ljava/lang/Class;":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Component class
				case "componentclass:Lcc/squirreljme/jvm/ClassInfo;":
					// Write class ID of component type
					if (thisname.isArray())
						initializer.memWriteInt(Modifier.RAM_OFFSET,
							wp, bootstrap.findClass(
								thisname.componentType()).infoPointer());
					
					// Write null pointer
					else
						initializer.memWriteInt(wp, 0);
					break;
					
					// Default new constructor
				case "defaultnew:I":
					try
					{
						initializer.memWriteInt(Modifier.JAR_OFFSET,
							wp, this.methodCodeAddress("<init>", "()V"));
					}
					catch (InvalidClassFormatException e)
					{
					}
					break;
					
					// Dimensions
				case "dimensions:I":
					initializer.memWriteInt(
						wp, thisname.dimensions());
					break;
					
					// Class info flags
				case "flags:I":
					{
						int flags = 0;
						
						// Is this array?
						if (thisname.isArray())
						{
							// Flag it
							flags |= Constants.CIF_IS_ARRAY;
							
							// Is its component an object as well?
							if (!thisname.componentType().isPrimitive())
								flags |= Constants.CIF_IS_ARRAY_OF_OBJECTS;
						}
						
						// Is this primitive?
						if (thisname.isPrimitive())
							flags |= Constants.CIF_IS_PRIMITIVE;
						
						// Write flags
						initializer.memWriteInt(wp, flags);
					}
					break;
						
						// Interface class information
					case "interfaceclasses:[Lcc/squirreljme/jvm/ClassInfo;":
						{
							// Get interfaces pointer list
							int xp = bootstrap.classNamesInfoPointer(
								mcf.interfaceNames());
								
							// Write pointer here
							initializer.memWriteInt(Modifier.RAM_OFFSET,
								wp, xp);
							
							// The interface names in the bootstrap is the
							// pointer to the ClassInfo, but as an int array
							// type instead of an object array type. But we
							// can just override it.
							initializer.memWriteInt(Modifier.RAM_OFFSET,
								xp + Constants.OBJECT_CLASS_OFFSET,
								bootstrap.findClass(
								"[Lcc/squirreljme/jvm/ClassInfo;").
								infoPointer());
						}
						break;
					
					// The JAR index, always zero for the bootstrap
				case "jardx:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Magic number
				case "magic:I":
					initializer.memWriteInt(
						wp, ClassInfo.MAGIC_NUMBER);
					break;
					
					// Pointer to the class data in ROM
				case "miniptr:I":
					initializer.memWriteInt(Modifier.JAR_OFFSET,
						wp, this.romOffset());
					break;
					
					// Monitor count
				case "_moncount:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Thread owning the monitor (which there is none)
				case "_monitor:I":
					initializer.memWriteInt(
						wp, 0);
					break;
					
					// Pointer to the class name
				case "namep:I":
					initializer.memWriteInt(Modifier.JAR_OFFSET,
						wp, this.romOffset() + this.poolEntryOffset(
						this._class.thisName().toString()) + 4);
					break;
					
					// The number of available methods
				case "nummethods:I":
					initializer.memWriteInt(wp, this.methodSize());
					break;
					
					// The number of objects in this class
				case "numobjects:I":
					initializer.memWriteInt(
						wp, this._class.header.ifobjs);
					break;
					
				case "pool:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.poolPointer());
					break;
					
					// Reference count for this class data, should never
					// be freed
				case "_refcount:I":
					initializer.memWriteInt(
						wp, 999999);
					break;
					
					// Pointer to our own class info
				case "selfptr:I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, rv);
					break;
					
					// Static field offset
				case "sfoffset:I":
					initializer.memWriteInt(
						wp, this.staticFieldOffset());
					break;
				
					// Allocation size of this class
				case "size:I":
					initializer.memWriteInt(wp, this.allocationSize());
					break;
					
					// Super class info
				case "superclass:Lcc/squirreljme/jvm/ClassInfo;":
					ClassName sn = mcf.superName();
					if (sn == null)
						initializer.memWriteInt(wp, 0);
					else
						initializer.memWriteInt(Modifier.RAM_OFFSET,
							wp, bootstrap.findClass(sn).infoPointer());
					break;
						
					// VTable for virtual calls
				case "vtablevirtual:[I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.vTables()[0]);
					break;
					
					// VTable for pool setting
				case "vtablepool:[I":
					initializer.memWriteInt(Modifier.RAM_OFFSET,
						wp, this.vTables()[1]);
					break;
					
					// Not handled yet!
				default:
					throw new todo.OOPS(key);
			}
		}
		
		// Return pointer to the data now
		return rv;
	}
	
	/**
	 * Returns the method base for the class.
	 *
	 * @return The method base.
	 * @since 2019/05/26
	 */
	public final int methodBase()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// If there is no super class then we just start at zero
		ClassName supername = this._class.superName();
		if (supername == null)
			return 0;
		
		// Otherwise it is the size of the super-class where we start from
		return bootstrap.findClass(supername).methodSize();
	}
	
	/**
	 * Returns the address of the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type, if {@code null} then the type is
	 * disregarded.
	 * @return The address of the given method.
	 * @since 2019/09/20
	 */
	public final int methodCodeAddress(String __mn, String __mt)
		throws NullPointerException
	{
		if (__mn == null)
			throw new NullPointerException("NARG");
		
		return this.methodCodeAddress(new MethodName(__mn),
			(__mt == null ? null : new MethodDescriptor(__mt)));
	}
	
	/**
	 * Returns the address of the given method.
	 *
	 * @param __mn The method name.
	 * @param __mt The method type, if {@code null} then the type is
	 * disregarded.
	 * @return The address of the given method.
	 * @since 2019/04/30
	 */
	public final int methodCodeAddress(MethodName __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		if (__mn == null)
			throw new NullPointerException("NARG");
		
		// Get class information
		MinimizedClassFile mcf = this._class;
		
		// Lookup static first
		MinimizedMethod mm = mcf.method(true, __mn, __mt);
		if (mm != null)
			return this._classoffset + mcf.header.smoff + mm.codeoffset;
		
		// Otherwise fallback to instance methods
		// {@squirreljme.error BC07 Could not locate the given method.
		// (The class; The name; The type)}
		mm = mcf.method(false, __mn, __mt);
		if (mm == null)
			throw new InvalidClassFormatException(
				String.format("BC07 %s %s %s", mcf.thisName(), __mn, __mt));
		return this._classoffset + mcf.header.imoff + mm.codeoffset;
	}
	
	/**
	 * Returns the method index for the given method.
	 *
	 * @param __mn The name of the method.
	 * @param __mt The descriptor of the method.
	 * @return The index of the given method.
	 * @since 2019/05/26
	 */
	public final int methodIndex(MethodName __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		if (__mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		// Try to find the method
		MinimizedClassFile mcf = this._class;
		MinimizedMethod mm = mcf.method(false, __mn, __mt);
		if (mm == null)
		{
			// {@squirreljme.error BC08 Could not find the specified method.
			// (The method name; The method type)}
			ClassName scn = mcf.superName();
			if (scn == null)
				throw new InvalidClassFormatException(
					"BC08 " + __mn + " " + __mt);
			
			// See if the super class has it
			return this.__bootstrap().findClass(scn).methodIndex(__mn, __mt);
		}
		
		// Is the index offset from the method base of this class
		return this.methodBase() + mm.index;
	}
	
	/**
	 * Returns the number of methods to use in the method table.
	 *
	 * @return The method size.
	 * @since 2019/05/26
	 */
	public final int methodSize()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// We are working on this class
		MinimizedClassFile cf = this._class;
		
		// The base method count
		int self = cf.header.imcount;
		
		// If there is no super class it is just the count
		ClassName supername = cf.superName();
		if (supername == null)
			return self;
		
		// Otherwise include the super class count as well
		return bootstrap.findClass(supername).methodSize() + self;
	}
	
	/**
	 * Returns the pointer to the offset of the given pool value.
	 *
	 * @param __v The value to get.
	 * @return The offset of the given value.
	 * @since 2019/09/14
	 */
	public final int poolEntryOffset(Object __v)
	{
		// Need pool for this!
		DualClassRuntimePool pool = this._class.pool;
		
		// Flagged if this is in the runtime pool?
		boolean inruntime;
		
		// Try to find the value from some pool
		BasicPoolEntry entry = pool.getByValue(false, __v);
		if ((inruntime = (entry == null)))
			entry = pool.getByValue(true, __v);
		
		// {@squirreljme.error BC0f Value not found in any pool. (The value)}
		if (entry == null)
			throw new InvalidClassFormatException("BC0f " + __v);
		
		// The offset of this entry is based on where it was found!
		return (inruntime ? this._class.header.runtimepooloff :
			this._class.header.staticpooloff) + entry.offset;
	}
	
	/**
	 * Returns a pointer to the class's constant pool.
	 *
	 * @return The pointer to the class constant pool.
	 * @since 2019/09/14
	 */
	public final int poolPointer()
	{
		// Need the bootstrap!
		BootstrapState bootstrap = this.__bootstrap();
		
		// Name of this class
		ClassName thisname = this.thisName();
		
		// If this is a primitive type or an array then use the pool pointer
		// for Object since they are virtually treated as Object!
		if (thisname.isPrimitive() || thisname.isArray())
			return bootstrap.findClass("java/lang/Object").poolPointer();
		
		// Has this already been cached?
		int rv = this._pooloffset;
		if (rv >= 0)
			return rv;
		
		// Can use the initializer now
		Initializer initializer = bootstrap.initializer;
		
		// Get the constant pool for this class
		MinimizedClassFile miniclass = this._class;
		DualClassRuntimePool pool = miniclass.pool;
		
		// Extract both parts of the pool
		BasicPool clpool = pool.classPool(),
			rtpool = pool.runtimePool();
		
		// Absolute offsets for each pool (in the ROM)
		int classoffset = this._classoffset;
		int clpadd = classoffset + miniclass.header.staticpooloff,
			rtpadd = classoffset + miniclass.header.runtimepooloff;
		
		// We only need space to fit the run-time pool
		int n = rtpool.size();
		this._pooloffset = (rv = initializer.allocate(n * 4));
		
		// Process entries, zero is always null!
		for (int i = 1; i < n; i++)
		{
			// Get the entry here
			BasicPoolEntry entry = rtpool.byIndex(i);
			
			// The value to write in the slot
			Modifier mx;
			int vx;
			
			// Depends on the type of entry we are using
			MinimizedPoolEntryType type = entry.type();
			switch (type)
			{
					// Field which has been accessed
				case ACCESSED_FIELD:
					AccessedField af = entry.<AccessedField>value(
						AccessedField.class);
					
					// Static fields are based on the pointer
					if (af.type().isStatic())
					{
						mx = null;
						vx = bootstrap.findClass(af.field.className()).
							fieldStaticOffset(af.field.memberName(),
								af.field.memberType());
					}
					
					// Instance fields are offset from a class
					else
					{
						mx = null;
						vx = bootstrap.findClass(af.field.className()).
							fieldInstanceOffset(af.field.memberName(),
								af.field.memberType());
					}
					break;
				
					// Pointer to class information
				case CLASS_INFO_POINTER:
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.findClass(entry.<ClassInfoPointer>value(
						ClassInfoPointer.class).name).infoPointer();
					break;
					
					// Pointer to class constant pool
				case CLASS_POOL:
					ClassPool pl = entry.<ClassPool>value(ClassPool.class);
					
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.findClass(pl.name).poolPointer();
					break;
					
					// A method to be invoked, these are always direct pointer
					// references to methods
				case INVOKED_METHOD:
					InvokedMethod im = entry.<InvokedMethod>value(
						InvokedMethod.class);
					
					mx = Modifier.JAR_OFFSET;
					vx = bootstrap.findClass(im.handle.outerClass()).
						methodCodeAddress(im.handle.name(),
							im.handle.descriptor());
					break;
					
					// Index of method
				case METHOD_INDEX:
					MethodIndex mi = entry.<MethodIndex>value(
						MethodIndex.class);
					
					mx = null;
					vx = bootstrap.findClass(mi.inclass).methodIndex(
						mi.name, mi.type);
					break;
					
					// A pointer to a string in memory
				case NOTED_STRING:
					mx = Modifier.JAR_OFFSET;
					vx = clpadd + clpool.byIndex(entry.part(0)).offset + 4;
					break;
					
					// A string that is used, this is loaded at run-time
				case USED_STRING:
					mx = Modifier.RAM_OFFSET;
					vx = bootstrap.internString(entry.<UsedString>value(
						UsedString.class).toString());
					break;
					
				default:
					throw new todo.OOPS(type.name());
			}
			
			// Write value to the in-memory slot
			initializer.memWriteInt(mx, rv + (4 * i), vx);
			
			// Debug
			if (JarMinimizer._ENABLE_DEBUG)
				todo.DEBUG.note("Pool %s -> %08x = %08x", entry.value,
					rv + (4 * i), vx);
		}
		
		// Return the pointer where the pool was allocated
		return rv;
	}
	
	/**
	 * Returns the ROM offset of this class.
	 *
	 * @return The ROM offset of the class.
	 * @since 2019/09/14
	 */
	public final int romOffset()
	{
		return this._classoffset;
	}
	
	/**
	 * Returns the offset of the static field area.
	 *
	 * @return The pointer of this class static field area.
	 * @since 2019/12/14
	 */
	public final int staticFieldOffset()
	{
		// Do we need to allocate static field space for this class?
		int smemoff = this._smemoff;
		if (smemoff < 0)
		{
			// Need the bootstrap here
			BootstrapState bootstrap = this.__bootstrap();
			Initializer initializer = bootstrap.initializer;
			
			// Allocate memory
			smemoff = bootstrap.allocateStaticFieldSpace(
				this._class.header.sfsize);
			
			// Store
			this._smemoff = smemoff;
			
			// Initialize static field values
			int sfieldarea = bootstrap.staticFieldAreaAddress();
			for (MinimizedField mf : this._class.fields(true))
			{
				// No value here?
				Object val = mf.value;
				if (val == null)
					continue;
				
				// Write pointer for this field
				int wp = sfieldarea + smemoff + mf.offset;
				
				// Write constant value
				switch (mf.type.toString())
				{
					case "B":
					case "Z":
						initializer.memWriteByte(wp,
							((Number)val).byteValue());
						break;
					
					case "S":
					case "C":
						initializer.memWriteShort(wp,
							((Number)val).shortValue());
						break;
					
					case "I":
						initializer.memWriteInt(wp,
							((Number)val).intValue());
						break;
					
					case "J":
						initializer.memWriteLong(wp,
							((Number)val).longValue());
						break;
					
					case "F":
						initializer.memWriteInt(wp,
							Float.floatToRawIntBits(
								((Number)val).floatValue()));
						break;
					
					case "D":
						initializer.memWriteLong(wp,
							Double.doubleToRawLongBits(
								((Number)val).doubleValue()));
						break;
					
					case "Ljava/lang/String;":
						throw new todo.TODO("Write string");
					
						// Unknown
					default:
						throw new todo.OOPS(mf.type.toString());
				}
			}
		}
		
		return smemoff;
	}
	
	/**
	 * Returns the super class of this class.
	 *
	 * @return The class super-class.
	 * @since 2019/09/21
	 */
	public final LoadedClassInfo superClass()
	{
		ClassName sn = this._class.superName();
		return (sn == null ? null : this.__bootstrap().findClass(sn));
	}
	
	/**
	 * Returns the name of the super class.
	 *
	 * @return The name of the super class.
	 * @since 2019/09/21
	 */
	public final ClassName superName()
	{
		return this._class.superName();
	}
	
	/**
	 * Returns the name of this class.
	 *
	 * @return The name of this class.
	 * @since 2019/09/14
	 */
	public final ClassName thisName()
	{
		return this._class.thisName();
	}
	
	/**
	 * Returns the pointers to the class method execution pointers along with
	 * the required pool pointers.
	 *
	 * @return The method table pointer and the pool pointer table.
	 * @since 2019/09/14
	 */
	public final int[] vTables()
	{
		// Need the bootstrap
		BootstrapState bootstrap = this.__bootstrap();
		
		// The current class information
		ClassName thisname = this._class.thisName();
		
		// Primitive types and array types do not exist so they just use the
		// same vtables as Object
		if (thisname.isPrimitive() || thisname.isArray())
			return bootstrap.findClass("java/lang/Object").vTables();
		
		// Did we already make the VTable for this? This will happen in the
		// event arrays or primitives are virtualized
		int rv = this._vtable;
		if (rv >= 0)
			return new int[]{rv, this._vtablepool};
		
		// Total methods to put together
		int count = this.methodSize();
		
		// Reserve and cache
		int pmptr = bootstrap.reserveIntArray(count),
			ppool = bootstrap.reserveIntArray(count);
		this._vtable = pmptr;
		this._vtablepool = ppool;
		
		// Resultant arrays
		int[] mptr = new int[count];
		int[] pool = new int[count];
		
		// Initially seed the arrays with pure virtual calls to make them
		// illegal to be called virtually (they could only be called statically
		// or otherwise).
		for (int i = 1,
			jpvc = bootstrap.findClass("cc/squirreljme/jvm/JVMFunction").
				methodCodeAddress("jvmPureVirtualCall", "()V"),
			jpvp = bootstrap.findClass("cc/squirreljme/jvm/JVMFunction").
				poolPointer(); i < count; i++)
		{
			mptr[i] = jpvc;
			pool[i] = jpvp;
		}
		
		// Put every class and method into a queue for processing
		Deque<ClassNameAndMinimizedMethod> process = new LinkedList<>();
		for (LoadedClassInfo at = this; at != null; at = at.superClass())
		{
			// Current class name is needed for object push
			ClassName tn = at.thisName();
			
			// Add all methods in there
			for (MinimizedMethod mm : at._class.methods(false))
				process.push(new ClassNameAndMinimizedMethod(tn, mm));
		}
		
		// Process every method
		while (!process.isEmpty())
		{
			// Take off class and extract pieces
			ClassNameAndMinimizedMethod atcnmm = process.pop();
			ClassName atcn = atcnmm.classname;
			MinimizedMethod atmm = atcnmm.method;
			
			// Is this a private method?
			boolean atmmisprivate = atmm.flags().isPrivate();
			
			// Find the loaded class this refers to
			LoadedClassInfo atci = bootstrap.findClass(atcn);
			
			// Find the index of this method in the method table;
			int mdx = atci.methodIndex(atmm.name, atmm.type);
			
			// For the appropriate method from the top
			for (LoadedClassInfo sc = this; sc != null; sc = sc.superClass())
			{
				// Location method here, if missing skip because it will be
				// in a super class
				MinimizedMethod scmm = sc._class.method(false,
					atmm.name, atmm.type);
				if (scmm == null)
					continue;
				
				// If we hit a private method in another class, stop
				if (scmm.flags().isPrivate() && atci != sc)
					break;
				
				// Link to this method and the pool it is in as well
				mptr[mdx] = sc.methodCodeAddress(atmm.name, atmm.type);
				pool[mdx] = sc.poolPointer();
				
				// Stop
				break;
			}
		}
		
		// Finalize and cache
		bootstrap.finalizeIntArray(pmptr, Modifier.JAR_OFFSET, mptr);
		bootstrap.finalizeIntArray(ppool, Modifier.RAM_OFFSET, pool);
		
		// Return them
		return new int[]{pmptr, ppool};
	}
	
	/**
	 * Returns the bootstrap.
	 *
	 * @return The bootstrap.
	 * @throws IllegalStateException If it was garbage collected.
	 * @since 2019/09/14
	 */
	private final BootstrapState __bootstrap()
		throws IllegalStateException
	{
		Reference<BootstrapState> ref = this._bootstrap;
		
		// {@squirreljme.error BC0d The bootstrap state was garbage collected,
		// therefor this class is no longer valid.}
		BootstrapState rv = ref.get();
		if (rv == null)
			throw new IllegalStateException("BC0d");
		
		return rv;
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/MinimizedJarHeader.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
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





























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents the header for a minimized Jar file.
 *
 * @since 2019/04/27
 */
public final class MinimizedJarHeader
{
	/** Magic number for the JAR. */
	public static final int MAGIC_NUMBER =
		0x00456570;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		72;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		76;
	
	/** Size of table of contents entries. */
	public static final int TOC_ENTRY_SIZE =
		16;
	
	/** Number of resources. */
	public final int numrc;
	
	/** Table of contents offset. */
	public final int tocoffset;
	
	/** Manifest offset. */
	public final int manifestoff;
	
	/** Manifest length. */
	public final int manifestlen;
	
	/** Boot initializer offset. */
	public final int bootoffset;
	
	/** Boot initializer size. */
	public final int bootsize;
	
	/** The boot pool offset. */
	public final int bootpool;
	
	/** Static field basein RAM. */
	public final int bootsfieldbase;
	
	/** The start method offset. */
	public final int bootstart;
	
	/** System call static field pointer. */
	public final int syscallsfp;
	
	/** System call handler code address .*/
	public final int syscallhandler;
	
	/** System call pool address. */
	public final int syscallpool;
	
	/** The ClassInfo for {@code byte[]}. */
	public final int bootclassidba;
	
	/** The ClassInfo for {@code byte[][]}. */
	public final int bootclassidbaa;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the Jar header.
	 *
	 * @param __fs Fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public MinimizedJarHeader(int... __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		int at = 0;
		
		// Table of contents
		this.numrc = __fs[at++];
		this.tocoffset = __fs[at++];
		
		// The offset to the manifest and its length
		this.manifestoff = __fs[at++];
		this.manifestlen = __fs[at++];
		
		// Boot initializer
		this.bootoffset = __fs[at++];
		this.bootsize = __fs[at++];
		this.bootpool = __fs[at++];
		this.bootsfieldbase = __fs[at++];
		this.bootstart = __fs[at++];
		this.syscallsfp = __fs[at++];
		this.syscallhandler = __fs[at++];
		this.syscallpool = __fs[at++];
		this.bootclassidba = __fs[at++];
		this.bootclassidbaa = __fs[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __fs[at++];
		this.staticpoolsize = __fs[at++];
		this.runtimepooloff = __fs[at++];
		this.runtimepoolsize = __fs[at++];
	}
	
	/**
	 * Decodes the JAR header.
	 *
	 * @param __in The input stream.
	 * @return The resulting header.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/27
	 */
	public static final MinimizedJarHeader decode(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need to read fields
		DataInputStream din = new DataInputStream(__in);
		
		// {@squirreljme.error BC0a Invalid minimized Jar magic number.
		// (The read magic number; The expected magic number)}
		int wasmagic;
		if (MAGIC_NUMBER != (wasmagic = din.readInt()))
			throw new InvalidClassFormatException(String.format(
				"BC0a %08x %08x", wasmagic, MAGIC_NUMBER));
		
		// Build
		return new MinimizedJarHeader(
			/* numrc */ din.readInt(),
			/* tocoffset */ din.readInt(),
			
			// Manifest
			/* manifestoff */ din.readInt(),
			/* manifestlen */ din.readInt(),
			
			// Boot initializer
			/* bootoffset */ din.readInt(),
			/* bootsize */ din.readInt(),
			/* bootpool */ din.readInt(),
			/* bootsfieldbase */ din.readInt(),
			/* bootstart */ din.readInt(),
			/* syscallsfp */ din.readInt(),
			/* syscallhandler */ din.readInt(),
			/* syscallpool */ din.readInt(),
			/* bootclassidba */ din.readInt(),
			/* bootclassidbaa */ din.readInt(),
			
			// Static and runtime pool
			/* staticpooloff */ din.readInt(),
			/* staticpoolsize */ din.readInt(),
			/* runtimepooloff */ din.readInt(),
			/* runtimepoolsize */ din.readInt());
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/Modifier.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

/**
 * Represents the action modifier that is available.
 *
 * @since 2019/04/30
 */
public enum Modifier
{
	/** No modification to be done. */
	NONE,
	
	/** Offset by RAM address. */
	RAM_OFFSET,
	
	/** Offset by JAR address. */
	JAR_OFFSET,
	
	/** End. */
	;
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/Operation.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jarfile;

/**
 * Represents a memory operation to do.
 *
 * @since 2019/04/30
 */
public final class Operation
{
	/** The value modifier. */
	public final Modifier mod;
	
	/** Operation size. */
	public final int size;
	
	/** The address. */
	public final int addr;
	
	/** The value. */
	public final Number value;
	
	/**
	 * Initializes the operation.
	 *
	 * @param __m The modifier.
	 * @param __s The operation size.
	 * @param __a The address.
	 * @param __v The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/30
	 */
	public Operation(Modifier __m, byte __s, int __a, Number __v)
		throws NullPointerException
	{
		if (__m == null || __v == null)
			throw new NullPointerException("NARG");
		
		this.mod = __m;
		this.size = __s;
		this.addr = __a;
		this.value = __v;
	}
}

Deleted runt/libs/tool-jarfile/dev/shadowtail/jarfile/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Utilties for minimization and compaction of JARs into single JAR formats.
 *
 * @since 2019/04/27
 */

package dev.shadowtail.jarfile;

Deleted runt/libs/tool-jdwp/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 837556ab-1eda-9b6a-56d1-5386e3c80cd2
X-SquirrelJME-Error: BH
X-SquirrelJME-Name: Java Debug Wire Protocol
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This contains the implementation of the JDWP 
 which enables JDWP-complaint debuggers to connect with SquirrelJME to 
 enable its debugging.
X-SquirrelJME-Depends: gcf
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-jdwp/dev/shadowtail/jdwp/CommandPacket.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jdwp;

/**
 * This represents a command packet which tells the other end that something
 * has happened or something should be done.
 *
 * @since 2019/05/16
 */
public final class CommandPacket
	extends Packet
{
}

Deleted runt/libs/tool-jdwp/dev/shadowtail/jdwp/Packet.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jdwp;

/**
 * This is the base class representing a packet.
 *
 * @since 2019/05/16
 */
public abstract class Packet
{
}

Deleted runt/libs/tool-jdwp/dev/shadowtail/jdwp/ReplyPacket.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.jdwp;

/**
 * This is a packet which represents a reply to a command.
 *
 * @since 2019/05/16
 */
public final class ReplyPacket
	extends Packet
{
}

Deleted runt/libs/tool-jdwp/dev/shadowtail/jdwp/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contians the JDWP implementation which allows for debugging
 * Java applications running on SquirrelJME.
 *
 * @since 2019/05/16
 */

package dev.shadowtail.jdwp;

Deleted runt/libs/tool-manifest-reader/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Name: Manifest File Decoder
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This provides a decoder for standardJava 
 manifest files.
X-SquirrelJME-Error: BB
X-SquirrelJME-UUID: fb9af740-e959-43c5-b405-fb001edd09c5
X-SquirrelJME-Depends: collections
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-manifest-reader/net/multiphasicapps/tool/manifest/JavaManifest.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324




































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.util.AbstractMap;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This contains decoders for the standard Java manifest format.
 *
 * This class is immutable.
 *
 * @since 2016/05/20
 */
public final class JavaManifest
	extends AbstractMap<String, JavaManifestAttributes>
{
	/** Read a key. */
	private static final int _STAGE_KEY =
		0;
	
	/** Read a value (start). */
	private static final int _STAGE_VALUE_START =
		1;
	
	/** Read a value (padding). */
	private static final int _STAGE_VALUE_PADDING =
		2;
	
	/** Read a value (length). */
	private static final int _STAGE_VALUE_LINE =
		3;
	
	/** Potentially may be a continuation of a line. */
	private static final int _STAGE_VALUE_MIGHT_CONTINUE =
		4;
	
	/** The attributes defined in this manifest file. */
	protected final Map<String, JavaManifestAttributes> attributes;
	
	/**
	 * Initializes a blank manifest.
	 *
	 * @since 2018/02/10
	 */
	public JavaManifest()
	{
		// Initialize a blank set of main attributes
		Map<String, JavaManifestAttributes> backing =
			new HashMap<>();
		backing.put("", new JavaManifestAttributes());
		
		// Lock in the backing map
		this.attributes = UnmodifiableMap.<String, JavaManifestAttributes>
			of(backing);
	}
	
	/**
	 * Decodes the manifest from the given input stream, it is treated as
	 * UTF-8 as per the JAR specification.
	 *
	 * @param __is The input stream for the manifest data.
	 * @throws IOException On read errors.
	 * @throws JavaManifestException If the manifest is malformed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/20
	 */
	public JavaManifest(InputStream __is)
		throws IOException, JavaManifestException, NullPointerException
	{
		this(new BufferedReader(new InputStreamReader(__is, "utf-8")));
	}
	
	/**
	 * Decodes the manifest from the given reader.
	 *
	 * @param __r The characters which make up the manifest.
	 * @throws IOException On read errors.
	 * @throws JavaManifestException If the manifest is malformed.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public JavaManifest(Reader __r)
		throws IOException, JavaManifestException, NullPointerException
	{
		// Check
		if (__r == null)
			throw new NullPointerException("NARG");
			
		// The backing map and temporary key/value pairs for each
		// attiribute set
		String curname = "";
		Map<String, JavaManifestAttributes> backing = new HashMap<>();
		Map<JavaManifestKey, String> working = new HashMap<>();
		
		// Read input file line by line, since it is more efficient than
		// character by character
		StringBuilder vsb = new StringBuilder(128);
		BufferedReader br = new BufferedReader(__r);
		for (String pln = null;;)
		{
			// End of EOF
			String ln = (pln != null ? pln : br.readLine());
			pln = null;
			if (ln == null)
				break;
			
			// If the line is blank, it starts a new attribute block
			if (ln.isEmpty())
			{
				// Store the current working set
				if (working != null)
				{
					backing.put(curname, new JavaManifestAttributes(working));
					
					// It was stored in the map, so forget it
					curname = null;
					working = null;
				}
				
				// Skip blank line
				continue;
			}
			
			// This will be a name: value line, so find the colon on it
			// {@squirreljme.error BB01 Expected colon to appear on the
			// manifest line, to split a name/value pair.}
			int col = ln.indexOf(':');
			if (col < 0)
				throw new JavaManifestException("BB01");
			
			// Read key and value
			String key = ln.substring(0, col);
			
			// {@squirreljme.error BB02 Manifest key contains an invalid
			// character.}
			for (int i = 0, n = key.length(); i < n; i++)
				if (!JavaManifest.__isKeyChar(key.charAt(i)))
					throw new JavaManifestException(
						String.format("BB02 %s", key));
			
			// Need to skip the actual colon
			col++;
			
			// Skip spaces at the start of the value line
			int n = ln.length();
			while (col < n && ln.charAt(col) == ' ')
				col++;
			
			// Place value as it is now into a temporary buffer
			vsb.append(ln, col, n);
			
			// Read the next line to determine if it is a continuation
			for (;;)
			{
				// Stop at EOF
				pln = br.readLine();
				if (pln == null)
					break;
				
				// If this is a non-continuation line, it will be a blank
				// line or some other value, so redo the loop
				if (!pln.startsWith(" "))
					break;
				
				// Stop at the first non-space
				int nsp = 1;
				for (n = pln.length(); nsp < n; nsp++)
					if (pln.charAt(nsp) != ' ')
						break;
				
				// Append split into the buffer
				vsb.append(pln, nsp, n);
				
				// Clear the line, so it is not repeated
				pln = null;
			}
			
			// Build key and value
			JavaManifestKey ak = new JavaManifestKey(key);
			String av = vsb.toString();
			
			// Was this the start of a new section?
			if (curname == null)
			{
				// {@squirreljme.error BB03 New section must start with
				// {@code Name: value}. (The input section)}
				if (!"name".equals(ak.string))
					throw new JavaManifestException("BB03 " + ak);
				
				// The current name becomes the value
				curname = av;
				
				// Empty map to store values into
				working = new HashMap<>();
			}
			
			// Otherwise, add to the map
			else
				working.put(ak, av);
			
			// Clear the value
			vsb.setLength(0);
		}
		
		// Make sure the attribute is added to the set
		if (working != null)
			backing.put(curname, new JavaManifestAttributes(working));
		
		// Lock in the backing map
		this.attributes = UnmodifiableMap.<String, JavaManifestAttributes>
			of(backing);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public boolean containsKey(Object __k)
	{
		return this.attributes.containsKey(__k);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public Set<Map.Entry<String, JavaManifestAttributes>> entrySet()
	{
		return this.attributes.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public JavaManifestAttributes get(Object __k)
	{
		return this.attributes.get(__k);
	}
	
	/**
	 * Returns the mapping of main attributes.
	 *
	 * @return The main attribute mapping.
	 * @since 2016/05/29
	 */
	public JavaManifestAttributes getMainAttributes()
	{
		return this.attributes.get("");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public int size()
	{
		return this.attributes.size();
	}
	
	/**
	 * Returns {@code true} if the specified character is an alpha-numeric
	 * character.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if an alpha-numeric character.
	 * @since 2016/05/29
	 */
	private static boolean __isAlphaNum(char __c)
	{
		return (__c >= 'A' && __c <= 'Z') ||
			(__c >= 'a' && __c <= 'z') ||
			(__c >= '0' && __c <= '9');
	}
	
	/**
	 * Returns {@code true} if the character is part of a character which would
	 * be used for key values.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if a key character.
	 * @since 2016/05/29
	 */
	private static boolean __isKeyChar(char __c)
	{
		return __isAlphaNum(__c) || __c == '_' || __c == '-';
	}
	
	/**
	 * Returns {@code true} if the character is specified to be a newline
	 * character.
	 *
	 * @param __c The character to check.
	 * @return {@code true} if the character specifies the next line.
	 * @since 2016/05/29
	 */
	private static boolean __isNewline(char __c)
	{
		return __c == '\r' || __c == '\n';
	}
}

Deleted runt/libs/tool-manifest-reader/net/multiphasicapps/tool/manifest/JavaManifestAttributes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205













































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.EmptyMap;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * This contains the attributes for a single section within the manifest file.
 *
 * This class is immutable.
 *
 * @since 2016/05/20
 */
public final class JavaManifestAttributes
	extends AbstractMap<JavaManifestKey, String>
{
	/** The key value pairs. */
	protected final Map<JavaManifestKey, String> pairs;
	
	/**
	 * Initializes empty manifest attributes.
	 *
	 * @since 2018/02/10
	 */
	JavaManifestAttributes()
	{
		this.pairs = EmptyMap.<JavaManifestKey, String>empty();
	}
	
	/**
	 * Initializes the manifest attributes.
	 *
	 * @param __from The map to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/20
	 */
	JavaManifestAttributes(Map<JavaManifestKey, String> __from)
		throws NullPointerException
	{
		// Check
		if (__from == null)
			throw new NullPointerException("NARG");
		
		// Copy
		this.pairs = UnmodifiableMap.<JavaManifestKey, String>of(
			new HashMap<>(__from));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public boolean containsKey(Object __o)
	{
		return this.pairs.containsKey(__o);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/11/26
	 */
	public boolean definesValue(JavaManifestKey __k)
	{
		return this.containsKey(__k);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/11/26
	 */
	public boolean definesValue(String __k)
	{
		return this.containsKey(__k == null ? null : new JavaManifestKey(__k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public Set<Map.Entry<JavaManifestKey, String>> entrySet()
	{
		return this.pairs.entrySet();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public String get(Object __o)
	{
		return this.pairs.get(__o);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __k The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public String getValue(JavaManifestKey __k)
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this.get(__k);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __s The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/21
	 */
	public String getValue(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Find it
		return this.get(new JavaManifestKey(__s));
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(JavaManifestKey __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(String __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/20
	 */
	@Override
	public int size()
	{
		return this.pairs.size();
	}
}

Deleted runt/libs/tool-manifest-reader/net/multiphasicapps/tool/manifest/JavaManifestException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

/**
 * This is thrown when the manifest is not valid.
 *
 * @since 2016/06/15
 */
public class JavaManifestException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2016/06/15
	 */
	public JavaManifestException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2016/06/15
	 */
	public JavaManifestException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2016/06/15
	 */
	public JavaManifestException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2016/06/15
	 */
	public JavaManifestException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/tool-manifest-reader/net/multiphasicapps/tool/manifest/JavaManifestKey.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
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




















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest;

/**
 * This represents a key which is used in a manifest, it is case insensitive
 * when it comes to ASCII values.
 *
 * @since 2016/05/29
 */
public final class JavaManifestKey
{
	/** The used string. */
	protected final String string;
	
	/** The actual input string. */
	protected final String inputstring;
	
	/**
	 * Initializes the manifest key using the given string.
	 *
	 * @param __s The string to use for the manifest key.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/29
	 */
	public JavaManifestKey(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Lower-case all letters
		StringBuilder sb = new StringBuilder();
		for (int i = 0, n = __s.length(); i < n; i++)
			sb.append(__toLower(__s.charAt(i)));
		this.string = sb.toString();
		
		// Remember input string for case purposes
		this.inputstring = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Is another key?
		if (__o instanceof JavaManifestKey)
			return __equals(((JavaManifestKey)__o).string);
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public int hashCode()
	{
		return this.string.hashCode();
	}
	
	/**
	 * Returns the input string which was passed to this key, this string
	 * cannot be used for comparative purposes and it intended to be used
	 * for case matching in the output manifest.
	 *
	 * @return The input string.
	 * @since 2017/11/26
	 */
	public String inputString()
	{
		return this.inputstring;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/05/29
	 */
	@Override
	public String toString()
	{
		return this.string;
	}
	
	/**
	 * Compares two strings checking for case insensitivity in the basic
	 * ASCII range.
	 *
	 * @param __b The other string to compare against.
	 * @return {@code true} if the strings are equal.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/05/29
	 */
	private boolean __equals(String __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Cache
		String a = this.string;
		
		// Get their lengths
		int na = a.length(),
			nb = __b.length();
		
		// Would not be equal
		if (na != nb)
			return false;
		
		// Check characters
		for (int i = 0; i < na; i++)
			if (__toLower(a.charAt(i)) != __toLower(__b.charAt(i)))
				return false;
		
		// Matches
		return true;
	}
	
	/**
	 * Converts the specified character to lower case.
	 *
	 * @param __c The character to lower case.
	 * @return The lowercased character or {@code __c} if it cannot be
	 * lowercased.
	 * @since 2016/05/29
	 */
	private static char __toLower(char __c)
	{
		if (__c >= 'A' && __c <= 'Z')
			return (char)('a' + (__c - 'A'));
		return __c;
	}
}

Deleted runt/libs/tool-manifest-reader/net/multiphasicapps/tool/manifest/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the manifest decoder.
 *
 * @since 2016/05/20
 */

package net.multiphasicapps.tool.manifest;

Deleted runt/libs/tool-manifest-writer/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 890370ee-0c73-4552-a49e-b38c6c2c9bd1
X-SquirrelJME-Error: AB
X-SquirrelJME-Name: Mutable Java Manifest
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: tool-manifest-reader
X-SquirrelJME-Description: This project allows for creating standard 
 Java manifest files using a mutable class.
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-manifest-writer/net/multiphasicapps/tool/manifest/writer/MutableJavaManifest.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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






























































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest.writer;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestException;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This is a mutable version of {@link JavaManifest}.
 *
 * This class is not thread safe.
 *
 * @since 2016/09/19
 */
public class MutableJavaManifest
	extends AbstractMap<String, MutableJavaManifestAttributes>
{
	/** The maximum number of columns a manifest may have. */
	private static final int _COLUMN_LIMIT =
		71;
	
	/** Main attributes. */
	protected final Map<String, MutableJavaManifestAttributes> attributes =
		new LinkedHashMap<>();
	
	/**
	 * This initializes a new empty manifest.
	 *
	 * @since 2016/09/19
	 */
	public MutableJavaManifest()
	{
		// Always add a main attribute
		this.attributes.put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Initializes the mutable manifest using a copy of the data from an
	 * immutable manifest.
	 *
	 * @param __man The immutable manifest.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/26
	 */
	public MutableJavaManifest(JavaManifest __man)
		throws NullPointerException
	{
		// Check
		if (__man == null)
			throw new NullPointerException("NARG");
		
		// Go through and add
		for (Map.Entry<String, JavaManifestAttributes> e :
			__man.entrySet())
		{
			// Create new attribute set
			MutableJavaManifestAttributes attr;
			put(e.getKey(), (attr = new MutableJavaManifestAttributes()));
			
			// Copy values
			for (Map.Entry<JavaManifestKey, String> f :
				e.getValue().entrySet())
				attr.put(f.getKey(), f.getValue());
		}
		
		// If no main attributes were set then make sure they exist
		if (!containsKey(""))
			put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Initializes the mutable manifest using a copy of the data from the
	 * given mutable manifest.
	 *
	 * @param __man The mutable manifest to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/26
	 */
	public MutableJavaManifest(MutableJavaManifest __man)
		throws NullPointerException
	{
		// Check
		if (__man == null)
			throw new NullPointerException("NARG");
		
		// Go through and add
		for (Map.Entry<String, MutableJavaManifestAttributes> e :
			__man.entrySet())
		{
			// Create new attribute set
			MutableJavaManifestAttributes attr;
			put(e.getKey(), (attr = new MutableJavaManifestAttributes()));
			
			// Copy values
			for (Map.Entry<JavaManifestKey, String> f :
				e.getValue().entrySet())
				attr.put(f.getKey(), f.getValue());
		}
		
		// If no main attributes were set then make sure they exist
		if (!containsKey(""))
			put("", new MutableJavaManifestAttributes());
	}
	
	/**
	 * Builds the specified manifest.
	 *
	 * @return The built manifest.
	 * @throws RuntimeException If the manifest could not be built.
	 * @since 2017/11/17
	 */
	public final JavaManifest build()
		throws RuntimeException
	{
		try
		{
			byte[] bytes;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
			{
				// Write to output
				this.write(baos);
			
				// Extract array
				bytes = baos.toByteArray();
			}
		
			// Read in manifest
			try (InputStream is = new ByteArrayInputStream(bytes))
			{
				return new JavaManifest(is);
			}
		}
		
		// {@squirreljme.error AB01 Failed to build the immutable manifest
		// from the mutable one.}
		catch (IOException e)
		{
			throw new JavaManifestException("AB01", e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final Set<Map.Entry<String, MutableJavaManifestAttributes>>
		entrySet()
	{
		return this.attributes.entrySet();
	}
	
	/**
	 * Returns the mapping of main attributes.
	 *
	 * @return The main attribute mapping.
	 * @since 2016/09/19
	 */
	public final MutableJavaManifestAttributes getMainAttributes()
	{
		return get("");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final MutableJavaManifestAttributes put(String __k,
		MutableJavaManifestAttributes __v)
		throws NullPointerException
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AB02 The specified value is of the wrong
		// class type.}
		if (!(__v instanceof MutableJavaManifestAttributes))
			throw new ClassCastException("AB02");
		
		// Put
		return this.attributes.put(__k, __v);
	}
	
	/**
	 * Writes the manifest data to the given output stream.
	 *
	 * @param __os The stream to get the manifest data written to.
	 * @return {@code __os}.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	public final OutputStream write(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		this.write(new OutputStreamWriter(__os, "utf-8"));
		
		return __os;
	}
	
	/**
	 * Writes the manifest data to the given output stream.
	 *
	 * @param __os The stream to get the manifest data written to.
	 * @return {@code __os}.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	public final Appendable write(Appendable __os)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Write main attribute first
		__write(__os, getMainAttributes());
		
		// Write other attributes
		for (Map.Entry<String, MutableJavaManifestAttributes> e :
			this.attributes.entrySet())
		{
			// Ignore the main attribute
			String k = e.getKey();
			if (k.equals(""))
				continue;
			
			// Sub-attributes are always spaced after the previous one
			__os.append("\r\n");
			
			// Write the name
			__write(__os, "Name", k);
			
			// Write values
			__write(__os, e.getValue());
		}
		
		// Java ME has no flushable so we only know two classes which are
		if (__os instanceof OutputStream)
			((OutputStream)__os).flush();
		else if (__os instanceof Writer)
			((Writer)__os).flush();
		
		return __os;
	}
	
	/**
	 * Writes attributes to the output.
	 *
	 * @param __w The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	private void __write(Appendable __w, MutableJavaManifestAttributes __a)
		throws IOException, NullPointerException
	{
		// Check
		if (__w == null || __a == null)
			throw new NullPointerException("NARG");
		
		// The attribute version is always first
		JavaManifestKey verk = new JavaManifestKey("MANIFEST-VERSION");
		String ver = __a.get(verk);
		if (ver != null)
			__write(__w, "MANIFEST-VERSION", ver);
		else
			__write(__w, "MANIFEST-VERSION", "1.0");
		
		// Write all value
		for (Map.Entry<JavaManifestKey, String> e : __a.entrySet())
		{
			// Do not write the version twice
			JavaManifestKey k = e.getKey();
			if (verk.equals(k))
				continue;
			
			// Write pair
			__write(__w, k.inputString(), e.getValue());
		}
	}
	
	/**
	 * Writes the given key and value to the output.
	 *
	 * @param __w The stream to write to.
	 * @param __k The key to write.
	 * @param __v The value to write.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/09/19
	 */
	private void __write(Appendable __w, String __k, String __v)
		throws IOException, NullPointerException
	{
		// Check
		if (__w == null || __k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Write pair
		int col = 0;
		for (int z = 0; z < 2; z++)
		{
			String s = (z == 0 ? __k : __v);
			
			// Print it
			int n = s.length();
			for (int i = 0; i < n; i++)
			{
				// Ignore out of range characters
				char c = s.charAt(i);
				if (c < ' ')
					continue;
				
				// Would be on a new line?
				int nextcol = col + 1;
				boolean newline = false;
				if (nextcol >= _COLUMN_LIMIT)
				{
					// If the current character is a space then it will
					// be lost on the following line.
					if (c == ' ')
						__w.append(' ');
					__w.append("\r\n");
					newline = true;
					
					// Indent next line with space as long as this is not
					// the last character being written
					__w.append(' ');
					
					// Set next column
					nextcol = 1;
				}
				
				// Write the character, but if a space was written early then
				// do not write it
				if ((c == ' ' && !newline) || c != ' ')
					__w.append(c);
				
				// Set new column
				col = nextcol;
			}
			
			// Add spacer
			if (z == 0)
			{
				__w.append(": ");
				col += 2;
			}
		}
		
		// Write newline
		__w.append("\r\n");
	}
}

Deleted runt/libs/tool-manifest-writer/net/multiphasicapps/tool/manifest/writer/MutableJavaManifestAttributes.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tool.manifest.writer;

import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.JavaManifestKey;

/**
 * This is a mutable set of attributes which exist within a manifest.
 *
 * @since 2016/09/19
 */
public class MutableJavaManifestAttributes
	extends AbstractMap<JavaManifestKey, String>
{
	/** The manifest values. */
	protected final Map<JavaManifestKey, String> values =
		new LinkedHashMap<>();
	
	/**
	 * Initializes empty manifest attributes.
	 *
	 * @since 2017/11/19
	 */
	public MutableJavaManifestAttributes()
	{
	}
	
	/**
	 * Initializes the attributes with a copy of the other attributes.
	 *
	 * @param __a The attributes to copy from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/19
	 */
	public MutableJavaManifestAttributes(JavaManifestAttributes __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		this.values.putAll(__a);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/12/04
	 */
	public boolean definesValue(JavaManifestKey __k)
	{
		return this.containsKey(__k);
	}
	
	/**
	 * Checks whether the specified key has a value defined for it.
	 *
	 * @param __k The key to check.
	 * @return {@code true} if a value is defined.
	 * @since 2017/12/04
	 */
	public boolean definesValue(String __k)
	{
		return this.containsKey(__k == null ? null : new JavaManifestKey(__k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public final Set<Map.Entry<JavaManifestKey, String>> entrySet()
	{
		return this.values.entrySet();
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __k The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/12/04
	 */
	public String getValue(JavaManifestKey __k)
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		return this.get(__k);
	}
	
	/**
	 * Returns the value used by the given key.
	 *
	 * @param __s The key to get the value for.
	 * @return The value for the given key or {@code null} if not found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/21
	 */
	public String getValue(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Find it
		return this.get(new JavaManifestKey(__s));
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(JavaManifestKey __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * Returns the value in the attributes or the specified value if it is not
	 * set.
	 *
	 * @param __k The key to get.
	 * @param __dv The default value to use.
	 * @return The value for the given key or {@code __dv}.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public String getValue(String __k, String __dv)
		throws NullPointerException
	{
		if (__k == null)
			throw new NullPointerException("NARG");
		
		String rv = this.getValue(__k);
		if (rv == null)
			return __dv;
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/19
	 */
	@Override
	public String put(JavaManifestKey __k, String __v)
		throws NullPointerException
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Forward
		return this.values.put(__k, __v);
	}
	
	/**
	 * Places the specified key with the given value into the manifest.
	 *
	 * @param __k The key to use.
	 * @param __v The value for that key.
	 * @return The old value.
	 * @since 2016/12/27
	 */
	public String putValue(String __k, String __v)
	{
		// Check
		if (__k == null || __v == null)
			throw new NullPointerException("NARG");
		
		// Forward
		return put(new JavaManifestKey(__k), __v);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/09/29
	 */
	@Override
	public String remove(Object __k)
	{
		return this.values.remove(__k);
	}
}

Deleted runt/libs/tool-manifest-writer/net/multiphasicapps/tool/manifest/writer/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This packages contains the classes to provide mutable manifests which may
 * be generated.
 *
 * @since 2016/12/26
 */

package net.multiphasicapps.tool.manifest.writer;

Deleted runt/libs/tool-packfile/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 7bb22625-48a1-4abc-8764-96c48b829bc1
X-SquirrelJME-Error: BI
X-SquirrelJME-Name: Compiled JAR Packfile Support
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Depends: tool-jarfile
X-SquirrelJME-Description: This project is used to build the packed ROM 
 files needed by SummerCoat and RatufaCoat to function.
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-packfile/dev/shadowtail/packfile/MinimizedPackHeader.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.packfile;

/**
 * This represents the header for a minimized pack file, it mostly just
 * represents a number of JAR files which are combined into one.
 *
 * @since 2019/05/28
 */
public final class MinimizedPackHeader
{
	/** Magic number for the pack file. */
	public static final int MAGIC_NUMBER =
		0x58455223;
	
	/** The size of the header without the magic number. */
	public static final int HEADER_SIZE_WITHOUT_MAGIC =
		52;
	
	/** The size of the header with the magic number. */
	public static final int HEADER_SIZE_WITH_MAGIC =
		56;
	
	/** The offset to the BootJAR offset (which has BootRAM), with magic. */
	public static final int OFFSET_OF_BOOTJAROFFSET =
		16;
	
	/** The offset to the BootJAR size, with magic. */
	public static final int OFFSET_OF_BOOTJARSIZE =
		20;
	
	/** Size of individual table of contents entry. */
	public static final int TOC_ENTRY_SIZE =
		20;
	
	/** The number of jars in this packfile. (4) */
	public final int numjars;
	
	/** The offset to the table of contents. (8) */
	public final int tocoffset;
	
	/** The index of the JAR which should be the boot point. (12) */
	public final int bootjarindex;
	
	/** The offset into the packfile where the boot entry is. (16) */
	public final int bootjaroffset;
	
	/** The size of the boot jar. (20) */
	public final int bootjarsize;
	
	/** Initial class path library indexes. (24) */
	public final int booticpoffset;
	
	/** Initial class path library index count. (28) */
	public final int booticpsize;
	
	/** Initial main class to boot. (32) */
	public final int bootmainclass;
	
	/** Initial main entry type. (36) */
	public final int bootmaintype;
	
	/** Static constant pool offset. */
	public final int staticpooloff;
	
	/** Static constant pool size. */
	public final int staticpoolsize;
	
	/** Runtime constant pool offset. */
	public final int runtimepooloff;
	
	/** Runtime constant pool size. */
	public final int runtimepoolsize;
	
	/**
	 * Initializes the pack header.
	 *
	 * @param __fs Fields.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/28
	 */
	public MinimizedPackHeader(int... __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		int at = 0;
		
		// Jar and table of contents
		this.numjars = __fs[at++];
		this.tocoffset = __fs[at++];
		
		// Boot JAR that may be specified
		this.bootjarindex = __fs[at++];
		this.bootjaroffset = __fs[at++];
		this.bootjarsize = __fs[at++];
		this.booticpoffset = __fs[at++];
		this.booticpsize = __fs[at++];
		this.bootmainclass = __fs[at++];
		this.bootmaintype = __fs[at++];
		
		// Static and run-time constant pool
		this.staticpooloff = __fs[at++];
		this.staticpoolsize = __fs[at++];
		this.runtimepooloff = __fs[at++];
		this.runtimepoolsize = __fs[at++];
	}
}

Deleted runt/libs/tool-packfile/dev/shadowtail/packfile/PackMinimizer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279























































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.packfile;

import cc.squirreljme.jvm.Constants;
import cc.squirreljme.vm.VMClassLibrary;
import dev.shadowtail.classfile.mini.DualPoolEncoder;
import dev.shadowtail.classfile.mini.DualPoolEncodeResult;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.jarfile.JarMinimizer;
import dev.shadowtail.jarfile.MinimizedJarHeader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This class is used to pack multiple JAR files into a single packed ROM, so
 * that it is all contained within a single unit.
 *
 * @since 2019/05/29
 */
public class PackMinimizer
{
	/**
	 * Minimizes the class library.
	 *
	 * @param __boot The boot class used for the entry point.
	 * @param __initcp The initial classpath, if any.
	 * @param __mainbc Main boot class.
	 * @param __libs The libraries to minimize.
	 * @return The resulting minimized pack file.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final byte[] minimize(String __boot,
		String[] __initcp, String __mainbc, boolean __ismid,
		VMClassLibrary... __libs)
		throws IOException, NullPointerException
	{
		if (__libs == null)
			throw new NullPointerException("NARG");
		
		// Write into resulting array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1048576))
		{
			// Minimize
			PackMinimizer.minimize(baos, __boot, __initcp, __mainbc, __ismid,
				__libs);
			
			// Return result
			return baos.toByteArray();
		}
	}
	
	/**
	 * Minimizes the class library.
	 *
	 * @param __os The stream to write the minimized file to.
	 * @param __boot The boot class used for the entry point.
	 * @param __initcp Initial classpath.
	 * @param __mainbc Main boot class.
	 * @param __ismid Is this a MIDlet?
	 * @param __libs The libraries to minimize.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/29
	 */
	public static final void minimize(OutputStream __os, String __boot,
		String[] __initcp, String __mainbc, boolean __ismid,
		VMClassLibrary... __libs)
		throws IOException, NullPointerException
	{
		if (__os == null || __libs == null ||
			(__boot != null && (__initcp == null || __mainbc == null)))
			throw new NullPointerException("NARG");
		
		// Defensive copy and check for nulls
		__initcp = (__initcp == null ? new String[0] : __initcp.clone());
		for (int i = 0, n = __initcp.length; i < n; i++)
		{
			String vx = __initcp[i];
			
			if (vx == null)
				throw new NullPointerException("NARG");
			
			// Append JAR always
			if (!vx.endsWith(".jar"))
				__initcp[i] = vx + ".jar";
		}
		
		// Make sure it ends in JAR
		if (!__boot.endsWith(".jar"))
			__boot = __boot + ".jar";
		
		// Write ROM sections
		TableSectionOutputStream out = new TableSectionOutputStream();
		
		// Number of libraries to process
		int numlibs = __libs.length;
		
		// Initialize classpath indexes
		int numinitcp = __initcp.length;
		int[] cpdx = new int[numinitcp];
		
		// Header and table of contents sections
		TableSectionOutputStream.Section header = out.addSection(
			MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC, 4);
		TableSectionOutputStream.Section toc = out.addSection(
			MinimizedPackHeader.TOC_ENTRY_SIZE * numlibs, 4);
		
		// Setup dual-pool where all combined values are stored as needed
		DualClassRuntimePoolBuilder dualpool =
			new DualClassRuntimePoolBuilder();
		
		// Section of the boot JAR
		int bootjarindex = -1;
		TableSectionOutputStream.Section bootjarsection = null;
		
		// Go through each library, minimize and write!
		for (int i = 0; i < numlibs; i++)
		{
			VMClassLibrary lib = __libs[i];
			String name = lib.name();
			
			// Normalize extension
			if (!name.endsWith(".jar"))
				name = name + ".jar";
			
			// Find library used in the initial classpath
			for (int j = 0; j < numinitcp; j++)
				if (name.equals(__initcp[j]))
				{
					cpdx[j] = i;
					break;
				}
			
			// Write name of JAR
			TableSectionOutputStream.Section jname = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			jname.writeUTF(name);
			
			// Output JAR data
			TableSectionOutputStream.Section jdata = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Is this a boot library?
			boolean isboot;
			if ((isboot = name.equals(__boot)))
			{
				bootjarindex = i;
				bootjarsection = jdata;
			}
			
			// Writing could fail however, so this makes it easier to find
			// the location of that failure
			MinimizedJarHeader mjh;
			try
			{
				// Used to get the header
				MinimizedJarHeader[] mjha = new MinimizedJarHeader[1];
				
				// The boot JAR is completely stand-alone, so do not use
				// a global JAR pool for it.
				JarMinimizer.minimize((isboot ? null : dualpool), isboot, lib,
					jdata, mjha);
				
				// Get the generated header
				mjh = mjha[0];
			}
			
			// {@squirreljme.error BI01 Could not minimize the JAR due to
			// an invalid class file. (The name)}
			catch (InvalidClassFormatException e)
			{
				throw new InvalidClassFormatException("BI01 " + name, e);
			}
			
			// Write TOC details
			toc.writeSectionAddressInt(jname);
			toc.writeSectionAddressInt(jdata);
			toc.writeSectionSizeInt(jdata);
			
			// Write manifest details if it is valid
			if (mjh.manifestlen > 0)
			{
				toc.writeSectionAddressInt(jdata, mjh.manifestoff);
				toc.writeInt(mjh.manifestlen);
			}
			else
			{
				toc.writeInt(0);
				toc.writeInt(0);
			}
		}
		
		// Write header details
		header.writeInt(MinimizedPackHeader.MAGIC_NUMBER);
		header.writeInt(numlibs);
		header.writeInt(MinimizedPackHeader.HEADER_SIZE_WITH_MAGIC);
		
		// Optional BootJAR information
		header.writeInt(bootjarindex);
		if (bootjarsection != null)
		{
			header.writeSectionAddressInt(bootjarsection);
			header.writeSectionSizeInt(bootjarsection);
		}
		else
		{
			header.writeInt(0);
			header.writeInt(0);
		}
		
		// Write initial classpath
		TableSectionOutputStream.Section icp = out.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		for (int i = 0; i < numinitcp; i++)
			icp.writeInt(cpdx[i]);
		
		// More boot information
		header.writeSectionAddressInt(icp);
		header.writeInt(numinitcp);
		
		// Main entry point name
		if (__mainbc == null)
		{
			header.writeInt(0);
			header.writeInt(0);
		}
		else
		{
			TableSectionOutputStream.Section mcl = out.addSection(
				TableSectionOutputStream.VARIABLE_SIZE, 4);
			
			// Main class
			mcl.writeUTF(__mainbc.replace('.', '/'));
			header.writeSectionAddressInt(mcl);
			
			// Is this a MIDlet?
			header.writeInt((__ismid ? 1 : -1));
		}
		
		// Encode the constant pools
		TableSectionOutputStream.Section lpd = out.addSection(
			TableSectionOutputStream.VARIABLE_SIZE, 4);
		DualPoolEncodeResult der = DualPoolEncoder.encode(dualpool, lpd);
		
		// Static pool
		header.writeSectionAddressInt(lpd, der.staticpooloff);
		header.writeInt(der.staticpoolsize);
		
		// Run-time pool
		header.writeSectionAddressInt(lpd, der.runtimepooloff);
		header.writeInt(der.runtimepoolsize);
		
		// Finish off
		out.writeTo(__os);
	}
}

Deleted runt/libs/tool-packfile/dev/shadowtail/packfile/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the utilities for creating pack files which are
 * needed by SummerCoat and RatufaCoat to function.
 *
 * @since 2019/05/28
 */

package dev.shadowtail.packfile;

Deleted runt/libs/tool-profiler/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: f3ffd3f9-32b0-4fe2-8b06-d5d2211ab55a
X-SquirrelJME-Error: AH
X-SquirrelJME-Name: tool-profiler
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: tool-profiler
X-SquirrelJME-Depends: io
Microedition-Configuration: CLDC-1.8-Compact

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/FrameLocation.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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.profiler;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the location of a frame.
 *
 * @since 2018/11/11
 */
public final class FrameLocation
	implements Comparable<FrameLocation>
{
	/** Location which represents the entry point node. */
	public static final FrameLocation ENTRY_POINT =
		new FrameLocation("<entry>", "<entry>", "()V");
	
	/** The class. */
	protected final String inclass;
	
	/** The method name. */
	protected final String methodname;
	
	/** The method type. */
	protected final String methodtype;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the location.
	 *
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public FrameLocation(String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		if (__cl == null || __mn == null || __mt == null)
			throw new NullPointerException("NARG");
		
		this.inclass = __cl;
		this.methodname = __mn;
		this.methodtype = __mt;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int compareTo(FrameLocation __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof FrameLocation))
			return false;
		
		FrameLocation o = (FrameLocation)__o;
		return this.inclass.equals(o.inclass) &&
			this.methodname.equals(o.methodname) &&
			this.methodtype.equals(o.methodtype);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final int hashCode()
	{
		return this.inclass.hashCode() ^
			this.methodname.hashCode() ^
			this.methodtype.hashCode();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/11
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = this.inclass + "::" +
				this.methodname + ":" + this.methodtype));
		
		return rv;
	}
}

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/ProfiledFrame.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
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
191
192
193
194
195



































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.profiler;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * This contains information and statistics for a single frame within the
 * thread stack.
 *
 * @since 2018/11/10
 */
public final class ProfiledFrame
{
	/** Maximum stack depth. */
	public static final int MAX_STACK_DEPTH =
		64;
	
	/** The location of this frame. */
	protected final FrameLocation location;
	
	/** The depth of this frame. */
	final int _depth;
	
	/** The sub-frames of this frame. */
	final Map<FrameLocation, ProfiledFrame> _frames =
		new LinkedHashMap<>();
	
	/** The number of calls made into the frame. */
	int _numcalls;
	
	/** Cumulative time spent in this frame and child frames. */
	long _traceruntime;
	
	/** Cumulative time spent in this frame and child frames without sleep. */
	long _tracecputime;
	
	/** Time only spent in this frame. */
	long _frameruntime;
	
	/** Time only spent in this frame without sleep. */
	long _framecputime;
	
	/** Time to subtract from the measured self times. */
	private long _subtractself;
	
	/** Current frame start time. */
	private long _currentstart =
		Long.MIN_VALUE;
	
	/** Current time sub-frame started execution, to remove self time. */
	private long _currentsubstart =
		Long.MIN_VALUE;
	
	/**
	 * Initializes this frame.
	 *
	 * @param __l The frame location.
	 * @param __d The depth of this frame.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public ProfiledFrame(FrameLocation __l, int __d)
		throws NullPointerException
	{
		if (__l == null)
			throw new NullPointerException("NARG");
		
		this.location = __l;
		this._depth = __d;
	}
	
	/**
	 * Indicates that this frame has been entered.
	 *
	 * @param __ns The starting nanoseconds.
	 * @throws IllegalStateException If the frame is already entered.
	 * @since 2018/11/11
	 */
	public final void enteredFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH01 Cannot enter frame which is in the
		// entered state.}
		long cs = this._currentstart;
		if (cs != Long.MIN_VALUE)
			throw new IllegalStateException("AH01");
			
		// {@squirreljme.error AH02 Cannot enter frame that is in an invoke.}
		if (this._currentsubstart != Long.MIN_VALUE)
			throw new IllegalStateException("AH02");
		
		// Mark time
		this._currentstart = __ns;
	}
	
	/**
	 * Indicates that the frame has been exited.
	 *
	 * @param __ns The time of the exit.
	 * @return The time spent in this frame, in total, self time, and CPU
	 * time.
	 * @throws IllegalStateException If the frame has not been entered.
	 * @since 2018/11/11
	 */
	public final long[] exitedFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH03 Cannot exit frame which is in the
		// exited state.}
		long cs = this._currentstart;
		if (cs == Long.MIN_VALUE)
			throw new IllegalStateException("AH03");
		
		// {@squirreljme.error AH04 Cannot exit frame that is in an invoke.}
		if (this._currentsubstart != Long.MIN_VALUE)
			throw new IllegalStateException("AH04");
		
		// Determine the cumulative and self time spent
		long total = __ns - cs,
			self = total - this._subtractself;
		
		// Increase call count
		this._numcalls++;
		
		// All sub-frames times
		this._traceruntime += total;
		this._tracecputime += total;
		
		// And only this frame time
		this._frameruntime += self;
		this._framecputime += self;
		
		// Clear these for next time
		this._currentstart = Long.MIN_VALUE;
		this._subtractself = 0;
		
		// Return both times since they may be useful
		return new long[]{total, self, total};
	}
	
	/**
	 * Indicates that this frame is no longer invoking some other method.
	 *
	 * @param __ns The ending nanoseconds.
	 * @return The time which has passed.
	 * @throws IllegalStateException If the frame is not in an invoke.
	 * @since 2018/11/11
	 */
	public final long invokeEnd(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH05 Frame is not in an invoke.}
		long css = this._currentsubstart;
		if (css == Long.MIN_VALUE)
			throw new IllegalStateException("AH05");
		
		// Reset
		this._currentsubstart = Long.MIN_VALUE;
		
		// Return the amount of time that was spend in this invocation
		long rv = __ns - css;
		this._subtractself += rv;
		return rv;
	}
	
	/**
	 * Indicates that this frame is invoking some other method.
	 *
	 * @param __ns The starting nanoseconds.
	 * @throws IllegalStateException If the frame is already in an invoke.
	 * @since 2018/11/11
	 */
	public final void invokeStart(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH06 Frame is already invoking another frame.}
		long css = this._currentsubstart;
		if (css != Long.MIN_VALUE)
			throw new IllegalStateException("AH06");
		
		// Mark it
		this._currentsubstart = __ns;
	}
}

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/ProfiledThread.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.profiler;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * This stores information along with the thread information along with the
 * call stack.
 *
 * This class is not thread safe and it is assumed to be called from the same
 * thread each time.
 *
 * @since 2018/11/10
 */
public final class ProfiledThread
{
	/** The name of this thread. */
	protected final String name;
	
	/** The root frames for this thread. */
	final Map<FrameLocation, ProfiledFrame> _frames =
		new LinkedHashMap<>();
	
	/** The stack of currently active frames. */
	private final Deque<ProfiledFrame> _stack =
		new LinkedList<>();
	
	/** Grand invocation total. */
	long _invtotal;
	
	/** Total time. */
	long _totaltime;
	
	/** CPU time. */
	long _cputime;
	
	/**
	 * Initializes the thread information.
	 *
	 * @param __n The name of the thread.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public ProfiledThread(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
	}
	
	/**
	 * Enters the given frame, the enter time is the system time.
	 *
	 * @param __cl The name of the class.
	 * @param __mn The name of the method.
	 * @param __md The type of the method.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/30
	 */
	public ProfiledFrame enterFrame(String __cl, String __mn, String __md)
		throws NullPointerException
	{
		return this.enterFrame(__cl, __mn, __md, System.nanoTime());
	}
	
	/**
	 * Enters the given frame.
	 *
	 * @param __cl The name of the class.
	 * @param __mn The name of the method.
	 * @param __md The type of the method.
	 * @param __ns The The starting time in nanoseconds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public ProfiledFrame enterFrame(String __cl, String __mn, String __md,
		long __ns)
		throws NullPointerException
	{
		if (__cl == null || __mn == null || __md == null)
			throw new NullPointerException("NARG");
		
		// Used as map key
		FrameLocation loc = new FrameLocation(__cl, __mn, __md);
		
		// We need to know the top-most frame because
		Deque<ProfiledFrame> stack = this._stack;
		ProfiledFrame top = stack.peek();
		
		// If the frame was not already recorded in the map then add a new one
		// but we always keep existing frames since their times add up and
		// such. Also remember that there is depth to this, like we cannot
		// just keep adding to the root and such!
		Map<FrameLocation, ProfiledFrame> frames = (top == null ?
			this._frames : top._frames);
		ProfiledFrame rv = frames.get(loc);
		if (rv == null)
			frames.put(loc, (rv = new ProfiledFrame(loc, stack.size() + 1)));
		
		// Tell the top-most frame that we are in an invoke, so this removes
		// self time accordingly
		if (top != null)
			top.invokeStart(__ns);
		
		// Push the frame to the stack since it is active
		this._stack.push(rv);
		
		// Indicate that this frame has been entered
		rv.enteredFrame(__ns);
		
		// Using this frame
		return rv;
	}
	
	/**
	 * Exits all frames as needed, the current time is used.
	 *
	 * @since 2019/06/30
	 */
	public void exitAll()
	{
		this.exitAll(System.nanoTime());
	}
	
	/**
	 * Exits all frames as needed.
	 *
	 * @param __ns The nanoseconds when exit all has happened.
	 * @since 2018/11/11
	 */
	public void exitAll(long __ns)
	{
		// Empty the frame stack
		Deque<ProfiledFrame> stack = this._stack;
		while (!stack.isEmpty())
			this.exitFrame(__ns);
	}
	
	/**
	 * Exits the frame which at the top of the stack, the current time is
	 * used.
	 *
	 * @return The exited frame.
	 * @throws IllegalStateException If there is no frame to exit.
	 * @since 2018/11/10
	 */
	public ProfiledFrame exitFrame()
		throws IllegalStateException
	{
		return this.exitFrame(System.nanoTime());
	}
	
	/**
	 * Exits the frame which at the top of the stack.
	 *
	 * @param __ns The nanoseconds when the frame exited.
	 * @return The exited frame.
	 * @throws IllegalStateException If there is no frame to exit.
	 * @since 2018/11/10
	 */
	public ProfiledFrame exitFrame(long __ns)
		throws IllegalStateException
	{
		// {@squirreljme.error AH07 No frame is in the stack to exit in.}
		Deque<ProfiledFrame> stack = this._stack;
		ProfiledFrame rv = stack.pop();
		if (rv == null)
			throw new IllegalStateException("AH07");
		
		// Tell that popped frame we left
		long[] times = rv.exitedFrame(__ns);
		
		// If we had a frame underneath, say the invocation has ended
		ProfiledFrame newtop = stack.peek();
		if (newtop != null)
			newtop.invokeEnd(__ns);
		
		// If all threads are out, count the times
		else
		{
			this._totaltime += times[0];
			this._cputime += times[2];
			
			// Invocation total goes up after each method ends
			this._invtotal++;
		}
		
		// Return the frame which was popped
		return rv;
	}
}

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/ProfilerSnapshot.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.profiler;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import net.multiphasicapps.io.ZLibCompressor;

/**
 * This represents the main profiler snapshot which contains all of the data
 * within what is to be profiled, it is mutable and accordingly allows for
 * export to NPS formats.
 *
 * @since 2018/11/10
 */
public final class ProfilerSnapshot
{
	/** The start time of the snapshot. */
	protected final long startmillis =
		System.currentTimeMillis();
	
	/** Threads that are being measured. */
	private final Map<String, ProfiledThread> _threads =
		new LinkedHashMap<>();
	
	/**
	 * Starts profiling the given thread.
	 *
	 * @param __name The name of the thread.
	 * @return A class to handle the profiling of threads via the call stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/10
	 */
	public final ProfiledThread measureThread(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		ProfiledThread rv = new ProfiledThread(__name);
		
		// Although the frames are not thread safe, this may be called at
		// any time from any thread although the returned class is only inteded
		// to be used by a single thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			threads.put(__name, rv);
		}
		
		return rv;
	}
	
	/**
	 * Exits all threads and all frames using the current time.
	 *
	 * @since 2019/06/30
	 */
	public final void exitAll()
	{
		this.exitAll(System.nanoTime());
	}
	
	/**
	 * Exits all threads and all frames.
	 *
	 * @param __ns The current time.
	 * @since 2019/04/19
	 */
	public final void exitAll(long __ns)
	{
		// Exit every single thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			for (ProfiledThread thread : threads.values())
				thread.exitAll(__ns);
		}
	}
	
	/**
	 * Writes snapshot information to the given stream.
	 *
	 * @param __ps The resulting stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeDumpTo(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		__ps.println("Profiler snapshot:");
		
		// Dump every thread
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			for (ProfiledThread t : threads.values())
			{
				// Banner
				__ps.print("  Thread ");
				__ps.print(t.name);
				__ps.println(':');
				
				// Dump frame info
				ProfilerSnapshot.__dumpFrames(__ps, 4, t._frames.values());
			}
		}
	}
	
	/**
	 * Writes the snapshot information to the given output stream.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// We write to this because we need the data
		DataOutputStream cont = new DataOutputStream(__os);
		
		// Magic number
		cont.writeBytes("nBpRoFiLeR");
		
		// Version
		cont.write(1);
		cont.write(2);
		
		// Type
		cont.writeInt(1);
		
		// Write compressed snapshot data to the byte array
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(2048))
		{
			// Compress the CPU data
			ZLibCompressor olddefl;
			try (ZLibCompressor defl = new ZLibCompressor(baos);
				DataOutputStream cpu = new DataOutputStream(defl))
			{
				// Used to get compressed size and such
				olddefl = defl;
				
				// Write header
				cpu.writeInt(1);
				
				// Timestamp and duration
				long start = this.startmillis;
				cpu.writeLong(start);
				
				// Threads are needed now
				Map<String, ProfiledThread> threads = this._threads;
				synchronized (threads)
				{
					// The duration of the trace is the maximum time any
					// thread has spent
					long maxtime = 0;
					for (ProfiledThread t : threads.values())
						maxtime = Math.max(maxtime, t._totaltime);
					cpu.writeLong(maxtime);
					
					// Thread time is always measured
					cpu.writeBoolean(true);
					
					// Build and write the instrumented method table
					Map<FrameLocation, Integer> mids = this.__doMethodTable();
					cpu.writeInt(mids.size());
					for (FrameLocation loc : mids.keySet())
					{
						cpu.writeUTF(loc.inclass);
						cpu.writeUTF(loc.methodname);
						cpu.writeUTF(loc.methodtype);
					}
				
					// Write thread data
					cpu.writeInt(threads.size());
				
					// Write individual thread
					for (ProfiledThread t : threads.values())
						this.__doWriteThread(cpu, t, mids);
				}
			}
			
			// Store sizes, which are important
			cont.writeInt(baos.size());
			cont.writeInt((int)Math.min(Integer.MAX_VALUE,
				olddefl.uncompressedBytes()));
			
			// Store the compressed data
			baos.writeTo(cont);
		}
		
		// Write properties of the snapshot
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(2048))
		{
			// Write them all
			try (PrintStream ps = new PrintStream(baos, true))
			{
				// Make sure it is flushed
				ps.flush();
			}
			
			// Store data
			cont.writeInt(baos.size());
			baos.writeTo(cont);
		}
		
		// Write comment
		cont.writeUTF("Generated by SquirrelJME " +
			"<https://multiphasicapps.net/>\n" +
			"Copyright (C) Stephanie Gawroriski 2016-2019\n" +
			"\n" +
			"Record date: " + new Date());
		
		// Make sure everything is flushed
		cont.flush();
	}
	
	/**
	 * Builds the the method table.
	 *
	 * @return The table of instrumented methods.
	 * @since 2018/11/11
	 */
	private final Map<FrameLocation, Integer> __doMethodTable()
	{
		// The table and the ID, which must be passable to sub-builders
		Map<FrameLocation, Integer> rv = new LinkedHashMap<>();
		int[] next = new int[1];
		
		// Need root frame for the entry point, used virtually to refer to
		// multiple initial points in the entry frame since that is a thing
		rv.put(FrameLocation.ENTRY_POINT, next[0]++);
		
		// Have to go through all threads recursively due to all the frames
		// that exist to build IDs
		Map<String, ProfiledThread> threads = this._threads;
		synchronized (threads)
		{
			// Go through all threads
			for (ProfiledThread t : threads.values())
				this.__doMethodTableSub(rv, next, t._frames.values());
		}
		
		return rv;
	}
	
	/**
	 * Builds the method table for frames.
	 *
	 * @param __rv The table to write to.
	 * @param __nid The next ID.
	 * @param __fs The frames to process.
	 * @return The table of instrumented methods.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private final Map<FrameLocation, Integer> __doMethodTableSub(
		Map<FrameLocation, Integer> __rv,
		int[] __nid, Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__rv == null || __nid == null || __fs == null)
			throw new NullPointerException("NARG");
		
		// Handle each frame
		for (ProfiledFrame f : __fs)
		{
			// Ignore if limit has been reached
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH)
				continue;
			
			// If the location is not in the map, set the ID
			FrameLocation loc = f.location;
			if (!__rv.containsKey(loc))
			{
				// Generate new ID
				int id = __nid[0]++;
				
				// Store
				__rv.put(loc, id);
			}
			
			// Go into this frame's sub-frames
			this.__doMethodTableSub(__rv, __nid, f._frames.values());
		}
		
		return __rv;
	}
	
	/**
	 * Writes the thread information to the stream.
	 *
	 * @param __cpu The stream to write to.
	 * @param __t The thread information to write.
	 * @param __mids The method IDs.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private final void __doWriteThread(DataOutputStream __cpu,
		ProfiledThread __t, Map<FrameLocation, Integer> __mids)
		throws IOException, NullPointerException
	{
		if (__cpu == null || __t == null || __mids == null)
			throw new NullPointerException("NARG");
		
		// ID and name
		__cpu.writeInt(__t.name.hashCode());
		__cpu.writeUTF(__t.name);
		
		// Always measure thread time
		__cpu.writeBoolean(true);
		
		// Parse the node table for this thread
		__NodeTable__ nodes = new __NodeTable__();
		nodes.parseThread(__t);
		
		// Write the node table
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024))
		{
			// Write to the temporary buffer
			nodes.writeTo(baos, __mids);
			
			// Store the node table
			__cpu.writeInt(baos.size());
			baos.writeTo(__cpu);
		}
		
		// Node size is always 28
		__cpu.writeInt(28);
		
		// Whole graph time
		__cpu.writeLong(__t._totaltime);
		__cpu.writeLong(__t._cputime);
		
		// No injected methods used
		__cpu.writeLong(0);
		__cpu.writeLong(0);
		
		// Pure time (always seems to be max value)
		__cpu.writeLong(Integer.MAX_VALUE);
		__cpu.writeLong(Integer.MAX_VALUE);
		
		// Net time
		__cpu.writeLong(__t._totaltime);
		__cpu.writeLong(__t._cputime);
		
		// The number of methods invoked
		__cpu.writeLong(__t._invtotal);
		
		// Always display CPU time
		__cpu.writeBoolean(true);
	}
	
	/**
	 * Dumps the frames to the given stream.
	 *
	 * @param __ps The stream to print to.
	 * @param __tab The current tab level.
	 * @param __fs The frames to dump.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	private static final void __dumpFrames(PrintStream __ps, int __tab,
		Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__ps == null || __fs == null)
			throw new NullPointerException("NARG");
		
		// Go through each frame
		for (ProfiledFrame f : __fs)
		{
			// Write tabs first
			for (int i = 0; i < __tab; i++)
				__ps.print(' ');
			
			// Write the frame itself
			__ps.print(f.location);
			
			// Write information on the frame
			__ps.printf(" [n=%d, t=%d, s=%d]",
				f._numcalls,
				f._traceruntime,
				f._frameruntime);
			__ps.println();
			
			// Go into this frame's frames
			ProfilerSnapshot.__dumpFrames(__ps, __tab + 1, f._frames.values());
		}
	}
}

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/__NodeTable__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331











































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.profiler;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This class contains the parsed node table which defines the structure for
 * each entry within the frame tree. A node represents a single frame.
 *
 * @since 2018/11/11
 */
final class __NodeTable__
{
	/** Linear set of frame nodes. */
	private final List<ProfiledFrame> _linear = 
		new ArrayList<>();
	
	/** Offsets for each node. */
	private final Map<ProfiledFrame, __Position__> _offsets =
		new HashMap<>();
	
	/** Current position. */
	private final __Position__ _at =
		new __Position__();
	
	/** Overflowed narrow point? */
	private boolean _overflowed;
	
	/**
	 * Parses the frames and loads into a node table.
	 *
	 * @param __fs The input frames to map.
	 * @param __depth The depth of the stack.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void parse(Iterable<ProfiledFrame> __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
			
		List<ProfiledFrame> linear = this._linear;
		Map<ProfiledFrame, __Position__> offsets = this._offsets;
		
		// Overflow check for wider offsets
		boolean overflowed = false;
		
		// Determine positions for all nodes
		__Position__ at = this._at;
		for (ProfiledFrame f : __fs)
		{
			// Too deep?
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH)
				continue;
			
			// Will need to know how many sub-frames there are
			Collection<ProfiledFrame> sub = f._frames.values();
			
			// Track position of this frame
			linear.add(f);
			offsets.put(f, at.increment(sub.size()));
			
			// Handle sub-frames for this frame
			this.parse(sub);
			
			// If these many bytes were written we overflow now
			if (at._narrow > 16777215)
				overflowed = true;
		}
		
		// Did we overflow?
		if (overflowed)
			this._overflowed = true;
	}
	
	/**
	 * Parses the frames and loads into a node table.
	 *
	 * @param __t The thread to parse.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void parseThread(ProfiledThread __t)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		Iterable<ProfiledFrame> frames = __t._frames.values();
		
		// Create virtual frame since the root actually can have multiple
		// methods forking from it and the profiler format can only handle
		// a single root
		ProfiledFrame vframe = new ProfiledFrame(FrameLocation.ENTRY_POINT,
			0);
		
		// Only ever called once
		vframe._numcalls = 1;
		
		// Initialize frame times with thread times
		vframe._traceruntime = __t._totaltime;
		vframe._tracecputime = __t._cputime;
		
		// There is no self time since this is purely a virtual node
		vframe._frameruntime = 0;
		vframe._framecputime = 0;
		
		// Store the thread sub-frames into this virtual thread
		Map<FrameLocation, ProfiledFrame> vsubf = vframe._frames;
		for (ProfiledFrame f : frames)
			vsubf.put(f.location, f);
		
		// Parse this special frame, which will then parse its sub-frames
		// accordingly
		this.parse(Arrays.<ProfiledFrame>asList(vframe));
	}		
	
	/**
	 * Writes the node table to the given stream.
	 *
	 * @param __os The stream to write to.
	 * @param __mids Node IDs.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/11
	 */
	public final void writeTo(OutputStream __os,
		Map<FrameLocation, Integer> __mids)
		throws IOException, NullPointerException
	{
		if (__os == null || __mids == null)
			throw new NullPointerException("NARG");
		
		DataOutputStream dos = new DataOutputStream(__os);
		
		// If there were a large number of entries written then sub-node
		// offsets use more bytes
		List<ProfiledFrame> linear = this._linear;
		boolean wide = this._overflowed;
		
		// Just go through every frame and write it using a simple linear
		// index
		Map<ProfiledFrame, __Position__> offsets = this._offsets;
		for (ProfiledFrame f : linear)
		{
			// Too deep or missing location ID?
			FrameLocation location = f.location;
			Integer flid = __mids.get(f.location);
			if (f._depth >= ProfiledFrame.MAX_STACK_DEPTH || flid == null)
				continue;
			
			// The frame location ID, this is data stored in a previous table
			dos.writeShort(flid);
			
			// Number of calls
			dos.writeInt((int)Math.min(Integer.MAX_VALUE, f._numcalls));
			
			// Total time and self time
			__NodeTable__.__writeLong40(dos, f._traceruntime);
			__NodeTable__.__writeLong40(dos, f._frameruntime);
			
			// Total time and self time (not sleeping/blocking)
			__NodeTable__.__writeLong40(dos, f._tracecputime);
			__NodeTable__.__writeLong40(dos, f._framecputime);
			
			// Write offsets to the sub-frame nodes
			Collection<ProfiledFrame> sub = f._frames.values();
			
			// Determine and write the actual number of sub-frames used
			int actsubs = 0;
			for (ProfiledFrame sf : sub)
				if (sf._depth >= ProfiledFrame.MAX_STACK_DEPTH)
					continue;
				else
					actsubs++;
			dos.writeShort(actsubs);
			
			// Write sub-frame table
			for (ProfiledFrame sf : sub)
			{
				// Too deep
				if (sf._depth >= ProfiledFrame.MAX_STACK_DEPTH)
					continue;
				
				__Position__ p = offsets.get(sf);
				
				// Nodes will either be wide or narrow
				if (wide)
					dos.writeInt(p._wide);
				else
					__NodeTable__.__writeInt24(dos, p._narrow);
			}
		}
	}
	
	/**
	 * Writes a 24-bit int.
	 *
	 * @param __dos The output stream.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @since 2018/11/11
	 */
	static final void __writeInt24(DataOutputStream __dos, int __v)
		throws IOException
	{
		// Only unsigned
		if (__v < 0)
			__v = 0;
		
		// This is limited to 24 bits, so cap it so there
		else if (__v > 16777215)
			__v = 16777215;
		
		// Write values
		__dos.writeByte((byte)(__v >>> 16));
		__dos.writeByte((byte)(__v >>> 8));
		__dos.writeByte((byte)(__v));
	}
	
	/**
	 * Writes a 40 bit long.
	 *
	 * @param __dos The output stream.
	 * @param __v The value to write.
	 * @throws IOException On write errors.
	 * @since 2018/11/11
	 */
	static final void __writeLong40(DataOutputStream __dos, long __v)
		throws IOException
	{
		// Only unsigned
		if (__v < 0)
			__v = 0;
		
		// This is limited to 40 bits, so cap it so there
		else if (__v > 1099511627775L)
			__v = 1099511627775L;
		
		// Write values
		__dos.writeByte((byte)(__v >>> 32));
		__dos.writeByte((byte)(__v >>> 24));
		__dos.writeByte((byte)(__v >>> 16));
		__dos.writeByte((byte)(__v >>> 8));
		__dos.writeByte((byte)(__v));
	}
	
	/**
	 * Position of a node within the node table.
	 *
	 * @since 2018/11/11
	 */
	private static final class __Position__
	{
		/** Narrow position. */
		int _narrow;
		
		/** Wide position. */
		int _wide;
		
		/**
		 * Initializes default position.
		 *
		 * @since 2018/11/11
		 */
		__Position__()
		{
		}
		
		/**
		 * Initializes for the given positions.
		 *
		 * @param __n The narrow position.
		 * @param __w The wide position.
		 * @since 2018/11/11
		 */
		__Position__(int __n, int __w)
		{
			this._narrow = __n;
			this._wide = __w;
		}
		
		/**
		 * Increments this position by the given number of sub-node units
		 * and returns the old one.
		 *
		 * @param __num The number of sub-node references to increment by.
		 * @return The old position in a new object.
		 * @throws IllegalArgumentException If the number of nodes is negative.
		 * @since 2018/11/11
		 */
		public __Position__ increment(int __num)
			throws IllegalArgumentException
		{
			// {@squirreljme.error AH08 Cannot write negative number of
			// nodes.}
			if (__num < 0)
				throw new IllegalArgumentException("AH08");
			
			// Store the old position first
			int narrow = this._narrow,
				wide = this._wide;
			__Position__ rv = new __Position__(narrow, wide);
			
			// Increment with new offsets
			this._narrow = narrow + 28 + (__num * 3);
			this._wide = wide + 28 + (__num * 4);
			
			return rv;
		}
	}
}

Deleted runt/libs/tool-profiler/net/multiphasicapps/profiler/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the profiler or rather the code which supports the
 * generation of profiling snapshots which can be used to measure performance
 * and such.
 *
 * @since 2018/11/10
 */

package net.multiphasicapps.profiler;

Deleted runt/libs/zip/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Type: liblet
X-SquirrelJME-Name: ZIP Support
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: The library contains the support for ZIP 
 files and any data interfaces needed for ZIP files.
X-SquirrelJME-Depends: io
X-SquirrelJME-Error: BF
X-SquirrelJME-UUID: 34332adb-2c68-4805-8adf-873e3ed6e136
Microedition-Configuration: CLDC-1.8

Deleted runt/libs/zip/net/multiphasicapps/zip/IBM437CodePage.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233









































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This contains methods for converting from the IBM 437 codepage to the UTF-16
 * which Java uses.
 *
 * @since 2016/03/07
 */
public final class IBM437CodePage
{
	/**
	 * Not initializes.
	 *
	 * @since 2016/03/07
	 */
	private IBM437CodePage()
	{
	}
	
	/**
	 * Translates the given byte to a character.
	 *
	 * @param __b Byte to translate.
	 * @return The translated value.
	 * @since 2016/03/07
	 */
	public static char byteToChar(byte __b)
	{
		return byteToChar(((int)__b) & 0xFF);
	}
	
	/**
	 * Translates the given integer to a character.
	 *
	 * @param __b Integer to translate.
	 * @return The translated value.
	 * @throws IllegalArgumentException If the input byte is not in the range
	 * of [0, 255].
	 * @since 2016/03/07
	 */
	public static char byteToChar(int __b)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BF01 Byte index is not within bounds.
		// (The byte)}
		if (__b < 0 || __b > 255)
			throw new IllegalArgumentException(String.format("BF01 %d", __b));
		
		// Lower ASCII is the same
		if (__b <= 127)
			return (char)__b;
		
		// Otherwise specific translation is used
		switch (__b)
		{
			case 128: return (char)0x00C7;
			case 129: return (char)0x00FC;
			case 130: return (char)0x00E9;
			case 131: return (char)0x00E2;
			case 132: return (char)0x00E4;
			case 133: return (char)0x00E0;
			case 134: return (char)0x00E5;
			case 135: return (char)0x00E7;
			case 136: return (char)0x00EA;
			case 137: return (char)0x00EB;
			case 138: return (char)0x00E8;
			case 139: return (char)0x00EF;
			case 140: return (char)0x00EE;
			case 141: return (char)0x00EC;
			case 142: return (char)0x00C4;
			case 143: return (char)0x00C5;
			case 144: return (char)0x00C9;
			case 145: return (char)0x00E6;
			case 146: return (char)0x00C6;
			case 147: return (char)0x00F4;
			case 148: return (char)0x00F6;
			case 149: return (char)0x00F2;
			case 150: return (char)0x00FB;
			case 151: return (char)0x00F9;
			case 152: return (char)0x00FF;
			case 153: return (char)0x00D6;
			case 154: return (char)0x00DC;
			case 155: return (char)0x00A2;
			case 156: return (char)0x00A3;
			case 157: return (char)0x00A5;
			case 158: return (char)0x20A7;
			case 159: return (char)0x0192;
			case 160: return (char)0x00E1;
			case 161: return (char)0x00ED;
			case 162: return (char)0x00F3;
			case 163: return (char)0x00FA;
			case 164: return (char)0x00F1;
			case 165: return (char)0x00D1;
			case 166: return (char)0x00AA;
			case 167: return (char)0x00BA;
			case 168: return (char)0x00BF;
			case 169: return (char)0x2310;
			case 170: return (char)0x00AC;
			case 171: return (char)0x00BD;
			case 172: return (char)0x00BC;
			case 173: return (char)0x00A1;
			case 174: return (char)0x00AB;
			case 175: return (char)0x00BB;
			case 176: return (char)0x2591;
			case 177: return (char)0x2592;
			case 178: return (char)0x2593;
			case 179: return (char)0x2502;
			case 180: return (char)0x2524;
			case 181: return (char)0x2561;
			case 182: return (char)0x2562;
			case 183: return (char)0x2556;
			case 184: return (char)0x2555;
			case 185: return (char)0x2563;
			case 186: return (char)0x2551;
			case 187: return (char)0x2557;
			case 188: return (char)0x255D;
			case 189: return (char)0x255C;
			case 190: return (char)0x255B;
			case 191: return (char)0x2510;
			case 192: return (char)0x2514;
			case 193: return (char)0x2534;
			case 194: return (char)0x252C;
			case 195: return (char)0x251C;
			case 196: return (char)0x2500;
			case 197: return (char)0x253C;
			case 198: return (char)0x255E;
			case 199: return (char)0x255F;
			case 200: return (char)0x255A;
			case 201: return (char)0x2554;
			case 202: return (char)0x2569;
			case 203: return (char)0x2566;
			case 204: return (char)0x2560;
			case 205: return (char)0x2550;
			case 206: return (char)0x256C;
			case 207: return (char)0x2567;
			case 208: return (char)0x2568;
			case 209: return (char)0x2564;
			case 210: return (char)0x2565;
			case 211: return (char)0x2559;
			case 212: return (char)0x2558;
			case 213: return (char)0x2552;
			case 214: return (char)0x2553;
			case 215: return (char)0x256B;
			case 216: return (char)0x256A;
			case 217: return (char)0x2518;
			case 218: return (char)0x250C;
			case 219: return (char)0x2588;
			case 220: return (char)0x2584;
			case 221: return (char)0x258C;
			case 222: return (char)0x2590;
			case 223: return (char)0x2580;
			case 224: return (char)0x03B1;
			case 225: return (char)0x00DF;
			case 226: return (char)0x0393;
			case 227: return (char)0x03C0;
			case 228: return (char)0x03A3;
			case 229: return (char)0x03C3;
			case 230: return (char)0x00B5;
			case 231: return (char)0x03C4;
			case 232: return (char)0x03A6;
			case 233: return (char)0x0398;
			case 234: return (char)0x03A9;
			case 235: return (char)0x03B4;
			case 236: return (char)0x221E;
			case 237: return (char)0x03C6;
			case 238: return (char)0x03B5;
			case 239: return (char)0x2229;
			case 240: return (char)0x2261;
			case 241: return (char)0x00B1;
			case 242: return (char)0x2265;
			case 243: return (char)0x2264;
			case 244: return (char)0x2320;
			case 245: return (char)0x2321;
			case 246: return (char)0x00F7;
			case 247: return (char)0x2248;
			case 248: return (char)0x00B0;
			case 249: return (char)0x2219;
			case 250: return (char)0x00B7;
			case 251: return (char)0x221A;
			case 252: return (char)0x207F;
			case 253: return (char)0x00B2;
			case 254: return (char)0x25A0;
			case 255: return (char)0x00A0;
			
				// Should not occur but in case it does
			default:
				throw new todo.OOPS();
		}
	}
	
	/**
	 * Converts the input byte array to a string.
	 *
	 * @param __arr Input byte array containing IBM 437 characters.
	 * @param __off Offset from the start of the buffer to read from.
	 * @param __len The number of bytes to read.
	 * @throws IllegalArgumentException If the offset or length are negative,
	 * or the offset and the length exceeds the array size.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/07
	 */
	public static String toString(byte[] __arr, int __off, int __len)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__arr == null)
			throw new NullPointerException("NARG");
		if (__off < 0 || __len < 0 || (__off + __len) < 0 ||
			(__off + __len) > __arr.length)
			throw new IllegalArgumentException("BAOB");
		
		// Result is of the same size
		char rv[] = new char[__len];
		
		// Go through it
		for (int i = 0; i < __len; i++)
			rv[i] = byteToChar(__arr[__off + i]);
		
		// Build it
		return new String(rv);
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipAttributeCompatibility.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
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













































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This is used to describe the compatibility that attributes within the ZIP
 * file are compatible with.
 *
 * @since 2016/08/07
 */
public enum ZipAttributeCompatibility
{
	/** DOS. */
	DOS(0),
	
	/** Amiga. */
	AMIGA(1),
	
	/** OpenVMS. */
	OPENVMS(2),
	
	/** UNIX. */
	UNIX(3),
	
	/** VM/CMS. */
	VM_CMS(4),
	
	/** Atari ST. */
	ATARI_ST(5),
	
	/** OS/2. */
	OS_2(6),
	
	/** Mac OS (Classic). */
	MACOS(7),
	
	/** Z-System. */
	Z_SYSTEM(8),
	
	/** CP/M. */
	CP_M(9),
	
	/** NTFS. */
	NTFS(10),
	
	/** MVS. */
	MVS(11),
	
	/** VSE. */
	VSE(12),
	
	/** Acorn RISC. */
	ACORN_RISC(13),
	
	/** VFAT. */
	VFAT(14),
	
	/** MVS (alternate). */
	MVS_ALTERNATIVE(15),
	
	/** BeOS. */
	BEOS(16),
	
	/** Tandem. */
	TANDEM(17),
	
	/** OS/400. */
	OS_400(18),
	
	/** Mac OS X. */
	MACOSX(19),
	
	/** End. */
	;
	
	/** The compatibility identifier. */
	private int id;
	
	/**
	 * Initializes the base compatibility information.
	 *
	 * @param __id The identifier used.
	 * @since 2016/08/07
	 */
	private ZipAttributeCompatibility(int __id)
	{
		this.id = __id;
	}
	
	/**
	 * Returns the version identifier.
	 *
	 * @return The version identifier.
	 * @since 2016/08/07
	 */
	public final int identifier()
	{
		return this.id;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipCRCConstants.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This class constants constants which are used to initialize the CRC
 * algorithm parameters.
 *
 * @since 2016/07/19
 */
public interface ZipCRCConstants
{
	/** The polynomial for the CRC algorithm. */
	public static final int CRC_POLYNOMIAL =
		0x04C11DB7;
	
	/** The initial CRC remainder. */
	public static final int CRC_REMAINDER =
		0xFFFFFFFF;
	
	/** The final XOR value. */
	public static final int CRC_FINALXOR =
		0xFFFFFFFF;
	
	/** Reflect the data? */
	public static final boolean CRC_REFLECT_DATA =
		true;
	
	/** Reflect the remainder? */
	public static final boolean CRC_REFLECT_REMAINDER =
		true;
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipCompressionType.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220




























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.io.Checksum;
import net.multiphasicapps.io.ChecksumInputStream;
import net.multiphasicapps.io.CompressionLevel;
import net.multiphasicapps.io.DecompressionInputStream;
import net.multiphasicapps.io.DeflaterOutputStream;
import net.multiphasicapps.io.InflaterInputStream;

/**
 * This represents the type of compression that is used in a ZIP file.
 *
 * @since 2016/07/15
 */
public enum ZipCompressionType
{
	/** Data is not compressed. */
	NO_COMPRESSION(10, 0),
	
	/** Deflate algorithm. */
	DEFLATE(20, 8),
	
	/** End. */
	;
	
	/** The default compression algorithm to use. */
	public static final ZipCompressionType DEFAULT_COMPRESSION =
		DEFLATE;
	
	/** The version needed to extract. */
	protected final int extractversion;
	
	/** The compression method. */
	protected final int method;
	
	/**
	 * Initializes the enumeration.
	 *
	 * @param __xv The version needed to extract.
	 * @param __m The compression method identifier.
	 * @since 2016/07/15
	 */
	private ZipCompressionType(int __xv, int __m)
	{
		this.extractversion = __xv;
		this.method = __m;
	}
	
	/**
	 * Returns the version which is needed to extract this data.
	 *
	 * @return The required version.
	 * @since 2016/07/15
	 */
	public final int extractVersion()
	{
		return this.extractversion;
	}
	
	/**
	 * Creates an input stream which wraps another for input which is used
	 * to read the associated data.
	 *
	 * @param __is The input stream to read from.
	 * @return An input stream for reading the data for this given
	 * compression method.
	 * @throws IOException If the stream could not be initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public final DecompressionInputStream inputStream(InputStream __is)
		throws IOException, NullPointerException
	{
		return inputStream(__is, null);
	}
	
	/**
	 * Creates an input stream which wraps another for input which is used
	 * to read the associated data.
	 *
	 * @param __is The input stream to read from.
	 * @param __cs An optional target checksum where the CRC for uncompressed
	 * data is stored.
	 * @return An input stream for reading the data for this given
	 * compression method.
	 * @throws IOException If the stream could not be initialized.
	 * @throws NullPointerException If no input stream was specified.
	 * @since 2016/08/22
	 */
	public final DecompressionInputStream inputStream(InputStream __is,
		Checksum __cs)
		throws IOException, NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Depends on the compression
		switch (this)
		{
				// Just use the same stream
			case NO_COMPRESSION:
				return new __NoDecompressionInputStream__((__cs != null ?
					new ChecksumInputStream(__cs, __is) : __is));
			
				// Inflate
			case DEFLATE:
				return new InflaterInputStream(__is, __cs);
				
				// {@squirreljme.error BF02 Decompressing using the given
				// method is not supported. (The current compression method)}
			default:
				throw new IOException(String.format("BF02 %s", this));
		}
	}
	
	/**
	 * Returns the compression method.
	 *
	 * @return The compression method.
	 * @since 2016/07/15
	 */
	public final int method()
	{
		return this.method;
	}
	
	/**
	 * Creates an output stream which wraps another for output which is used
	 * to write the associated data. The default compression level is used.
	 *
	 * @param __os The output stream to write into.
	 * @return An output stream for writing the data for this given compression
	 * method.
	 * @throws IOException If the stream could not be created.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public final OutputStream outputStream(OutputStream __os)
		throws IOException, NullPointerException
	{
		return this.outputStream(__os, CompressionLevel.DEFAULT);
	}
	
	/**
	 * Creates an output stream which wraps another for output which is used
	 * to write the associated data.
	 *
	 * @param __os The output stream to write into.
	 * @param __cl The compression level to use.
	 * @return An output stream for writing the data for this given compression
	 * method.
	 * @throws IOException If the stream could not be created.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public final OutputStream outputStream(OutputStream __os,
		CompressionLevel __cl)
		throws IOException, NullPointerException
	{
		// Check
		if (__os == null || __cl == null)
			throw new NullPointerException("NARG");
		
		// Depends on the compression
		switch (this)
		{
				// No compression, use the same stream
			case NO_COMPRESSION:
				return __os;
				
				// Inflate
			case DEFLATE:
				return new DeflaterOutputStream(__os, __cl);
			
				// {@squirreljme.error BF03 Compressing using the given
				// compression algorithm is not supported. (The compression
				// algorithm)}
			default:
				throw new IOException(String.format("BF03 %s", this));
		}
	}
	
	/**
	 * Returns the compression method identified by the given value.
	 *
	 * @param __m The compression method identifier.
	 * @return The compression type identifier for this method, or {@code null}
	 * if it is unknown.
	 * @since 2016/07/19
	 */
	public static ZipCompressionType forMethod(int __m)
	{
		switch (__m)
		{
			case 0: return ZipCompressionType.NO_COMPRESSION;
			case 8: return ZipCompressionType.DEFLATE;
			
				// Unknown
			default:
				return null;
		}
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipEntryAttribute.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This interface is used to represent an attribute which may be associated
 * with a ZIP entry (such as the creator and/or executable bit).
 *
 * @since 2016/08/07
 */
public interface ZipEntryAttribute
{
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipException.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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

import java.io.IOException;

/**
 * This is thrown when there is a problem with a ZIP file.
 *
 * @since 2016/08/02
 */
public class ZipException
	extends IOException
{
	/**
	 * Initializes exception with no message.
	 *
	 * @since 2016/08/02
	 */
	public ZipException()
	{
		super();
	}
	
	/**
	 * Initializes exception with the given message.
	 *
	 * @param __msg The exception message.
	 * @since 2016/08/02
	 */
	public ZipException(String __msg)
	{
		super(__msg);
	}
	
	/**
	 * Initializes exception with the given message and cause.
	 *
	 * @param __msg The exception message.
	 * @param __c The cause.
	 * @since 2016/08/02
	 */
	public ZipException(String __msg, Throwable __c)
	{
		super(__msg, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/ZipUnixAccessMode.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

/**
 * This represents UNIX access modes which may be declared in the ZIP.
 *
 * @since 2016/08/07
 */
public enum ZipUnixAccessMode
	implements ZipEntryAttribute
{
	/** User read. */
	USER_READ,
	
	/** User write. */
	USER_WRITE,
	
	/** User execute. */
	USER_EXECUTE,
	
	/** Group read. */
	GROUP_READ,
	
	/** Group write. */
	GROUP_WRITE,
	
	/** Group execute. */
	GROUP_EXECUTE,
	
	/** Other read. */
	OTHER_READ,
	
	/** Other write. */
	OTHER_WRITE,
	
	/** Other execute. */
	OTHER_EXECUTE,
	
	/** End. */
	;
}

Deleted runt/libs/zip/net/multiphasicapps/zip/__NoCompressionInputStream__.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
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








































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.io.DecompressionInputStream;

/**
 * This is an input stream which offers no compression but keeps count of
 * the read bytes.
 *
 * @since 2017/08/22
 */
class __NoDecompressionInputStream__
	extends DecompressionInputStream
{
	/** The stream to wrap. */
	protected final InputStream wrap;
	
	/** The number of read bytes. */
	private volatile long _count;
	
	/**
	 * Initializes the wrapping stream.
	 *
	 * @param __w The stream to read bytes from.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/22
	 */
	__NoDecompressionInputStream__(InputStream __w)
		throws NullPointerException
	{
		// Check
		if (__w == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.wrap = __w;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int available()
		throws IOException
	{
		return this.wrap.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long compressedBytes()
	{
		return this._count;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public boolean detectsEOF()
	{
		return false;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read()
		throws IOException
	{
		int rv = this.wrap.read();
		if (rv >= 0)
			this._count++;
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b)
		throws IOException, NullPointerException
	{
		int rc = this.wrap.read(__b);
		if (rc > 0)
			this._count += rc;
		
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		int rc = this.wrap.read(__b, __o, __l);
		if (rc > 0)
			this._count += rc;
		
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public long uncompressedBytes()
	{
		return this._count;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/ArrayBlockAccessor.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
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






















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.EOFException;
import java.io.IOException;

/**
 * This wraps an array and provides it to the block accessor interface so that
 * ZIP files may be read from arrays.
 *
 * @since 2016/12/27
 */
public class ArrayBlockAccessor
	implements BlockAccessor
{
	/** The internal buffer. */
	protected final byte[] buffer;
	
	/** The offset into the buffer. */
	protected final int offset;
	
	/** The number of bytes available. */
	protected final int length;
	
	/**
	 * Initializes the block accessor which uses the entire array.
	 *
	 * @param __b The array to wrap.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ArrayBlockAccessor(byte[] __b)
		throws NullPointerException
	{
		this(__b, 0, __b.length);
	}
	
	/**
	 * Initializes the block accessor which uses the entire array.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to make available.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ArrayBlockAccessor(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// Set
		this.buffer = __b;
		this.offset = __o;
		this.length = __l;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error BF04 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF04");
		
		// {@squirreljme.error BF05 Read past end of the block.}
		if (__addr > this.length)
			throw new EOFException("BF05");
		
		// Get
		return this.buffer[this.offset + (int)__addr];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error BF06 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF06");
		
		// After the end?
		int length = this.length;
		if (__addr >= length)
			return -1;
		
		// Number of bytes to actually read
		int addr = (int)__addr;
		int actual = Math.min(__l, length - addr);
		
		// Read bytes
		byte[] buffer = this.buffer;
		int offset = this.offset;
		for (int i = 0, s = offset + addr, d = __o; i < actual; i++, s++, d++)
			__b[d] = buffer[s];
		
		// Return the actual number of bytes read
		return actual;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
	{
		return this.length;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/BlockAccessor.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;

/**
 * This interface is used to access the data in the ZIP file.
 *
 * @since 2016/12/27
 */
public interface BlockAccessor
	extends Closeable
{
	/**
	 * Reads a single byte.
	 *
	 * @param __addr The address to read from.
	 * @return The read byte.
	 * @throws EOFException If the read is past the end of file.
	 * @throws IOException On read/write errors.
	 * @since 2016/12/29
	 */
	public abstract byte read(long __addr)
		throws EOFException, IOException;
	
	/**
	 * Reads data from the block and writes to the destination array.
	 *
	 * @param __addr The address to start reading from.
	 * @param __b The destination array to write values to.
	 * @param __o The offset into the array.
	 * @param __l The maximum number of bytes to read.
	 * @return The number of bytes read or a negative value if the address
	 * exceeds the bounds of the block.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceeds the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public abstract int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException;
	
	/**
	 * Returns the number of bytes which are available for reading.
	 *
	 * @return The number of bytes in the block.
	 * @throws IOException If it could not be determined.
	 * @since 2016/12/27
	 */
	public abstract long size()
		throws IOException;
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/FileChannelBlockAccessor.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
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
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

/**
 * This wraps a file channel and provides block level access to it.
 *
 * @since 2016/12/27
 */
public class FileChannelBlockAccessor
	implements BlockAccessor
{
	/** The file channel to wrap. */
	protected final FileChannel channel;
	
	/**
	 * Initializes the block accessor for the given path.
	 *
	 * @param __p The path to open.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/11/29
	 */
	public FileChannelBlockAccessor(Path __p)
		throws IOException, NullPointerException
	{
		this(FileChannel.open(__p, StandardOpenOption.READ));
	}
	
	/**
	 * Initializes the block accessor for the file channel.
	 *
	 * @param __fc The channel to access data from.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public FileChannelBlockAccessor(FileChannel __fc)
		throws IOException, NullPointerException
	{
		// Check
		if (__fc == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.channel = __fc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.channel.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error BF07 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF07");
		
		// Just forward to the array variant
		byte[] val = new byte[1];
		int rv = read(__addr, val, 0, 1);
		
		// {@squirreljme.error BF08 Read past end of file.}
		if (rv < 0)
			throw new EOFException("BF08");
		
		return val[0];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error BF09 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("BF09");
		
		// Read until every byte has been read so that partial reads are not
		// returned
		ByteBuffer buf = ByteBuffer.wrap(__b, __o, __l);
		FileChannel channel = this.channel;
		int n;
		while (buf.hasRemaining())
			if (channel.read(buf, __addr + buf.position()) < 0)
				if ((n = buf.position()) <= 0)
					return -1;
				else
					return n;
		
		// Use the read position
		return buf.position();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
		throws IOException
	{
		return this.channel.size();
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/ZipBlockEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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

























































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.zip.IBM437CodePage;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipException;

/**
 * This represents a single entry within a ZIP file which may be opened.
 *
 * @since 2016/12/30
 */
public final class ZipBlockEntry
{
	/** Maximum version. */
	private static final int _MAX_CENTRAL_DIR_VERSION =
		20;
	
	/** The version which made the ZIP */
	private static final int _CENTRAL_DIRECTORY_MADE_BY_VERSION_OFFSET =
		4;
	
	/** The offset to the version needed to extract. */
	private static final int _CENTRAL_DIRECTORY_EXTRACT_VERSION_OFFSET =
		6;
	
	/** The offset of the general purpose flags. */
	private static final int _CENTRAL_DIRECTORY_FLAG_OFFSET =
		8;
	
	/** The offset to the method of compression. */
	private static final int _CENTRAL_DIRECTORY_METHOD_OFFSET =
		10;
	
	/** The offset to the CRC for data integrity. */
	private static final int _CENTRAL_DIRECTORY_CRC_OFFSET =
		16;
	
	/** The offset to the compressed size. */
	private static final int _CENTRAL_DIRECTORY_COMPRESSED_OFFSET =
		20;
	
	/** The offset to the uncompressed size. */
	private static final int _CENTRAL_DIRECTORY_UNCOMPRESSED_OFFSET =
		24;
	
	/** The offset to the file name length. */
	private static final int _CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET =
		28;
	
	/** The offset to the extra data length. */
	private static final int _CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET =
		_CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET + 2;
	
	/** The offset to the comment length. */
	private static final int _CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET =
		_CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET + 2;
	
	/** The relative offset to the local header. */
	private static final int _CENTRAL_DIRECTORY_LOCAL_HEADER_OFFSET =
		42;
	
	/** The minimum length of the central directory entry. */
	private static final int _CENTRAL_DIRECTORY_MIN_LENGTH =
		46;
	
	/** The local file header magic number. */
	private static final int _LOCAL_HEADER_MAGIC_NUMBER =
		0x04034B50;
	
	/** The offset to the file name length in the local header. */
	private static final int _LOCAL_HEADER_NAME_LENGTH_OFFSET =
		26;
	
	/** The offset to the comment length in the local header. */
	private static final int _LOCAL_HEADER_COMMENT_LENGTH_OFFSET =
		28;
	
	/** The local header minimum size. */
	private static final int _LOCAL_HEADER_MIN_LENGTH =
		30;
	
	/** General purpose flag: Is UTF-8 encoded filename/comment? */
	protected static final int GPF_ENCODING_UTF8 =
		(1 << 11);
	
	/** The owning reader. */
	protected final ZipBlockReader owner;
	
	/** The data accessor. */
	protected final BlockAccessor accessor;
	
	/** The position of this entry. */
	protected final long position;
	
	/** The name of this file. */
	private Reference<String> _name;
	
	/**
	 * Initializes the block entry.
	 *
	 * @param __br The owning block reader.
	 * @param __id The entry ID.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/30
	 */
	ZipBlockEntry(ZipBlockReader __br, int __id)
		throws NullPointerException
	{
		// Check
		if (__br == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.owner = __br;
		this.accessor = __br._accessor;
		
		// Get position
		this.position = __br._offsets[__id];
	}
	
	/**
	 * Returns {@code true} if the entry pertains to a directory.
	 *
	 * @return If it is a directory or not.
	 * @throws IOException On read errors.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2017/01/03
	 */
	public boolean isDirectory()
		throws IOException, ZipException
	{
		return __internalToString().endsWith("/");
	}
	
	/**
	 * Returns the time this entry was last modified.
	 *
	 * @return The last modified time or {@code Long.MIN_VALUE} if it is not
	 * valid.
	 * @since 2018/03/06
	 */
	public long lastModifiedTime()
	{
		return Long.MIN_VALUE;
	}
	
	/**
	 * Returns the name of this entry.
	 *
	 * @return The entry name.
	 * @since 2017/03/01
	 */
	public String name()
	{
		return toString();
	}
	
	/**
	 * Opens the input stream for this entry's data.
	 *
	 * @return The entry data.
	 * @throws IOException On read errors.
	 * @throws ZipException If it could not be opened.
	 * @since 2016/12/30
	 */
	public InputStream open()
		throws IOException, ZipException
	{
		// {@squirreljme.error BF0a Cannot open the entry because it is a
		// directory. (The name of the entry)}
		String s;
		if (isDirectory())
			throw new ZipException(String.format("BF0a %s", toString()));
		
		ZipBlockReader owner = this.owner;
		BlockAccessor accessor = this.accessor;
		long position = this.position;
		
		// {@squirreljme.error BF0b Could not read the central
		// directory data.}
		byte[] data = new byte[_CENTRAL_DIRECTORY_MIN_LENGTH];
		if (_CENTRAL_DIRECTORY_MIN_LENGTH != accessor.read(position,
			data, 0, _CENTRAL_DIRECTORY_MIN_LENGTH))
			throw new ZipException("BF0b");
		
		// The version needed to extract should not have the upper byte set
		// but some archive writing software sets the upper byte to match the
		// OS with the version in the made by bit.
		int ver = __ArrayData__.readUnsignedShort(
			_CENTRAL_DIRECTORY_EXTRACT_VERSION_OFFSET, data),
			made = __ArrayData__.readUnsignedShort(
			_CENTRAL_DIRECTORY_MADE_BY_VERSION_OFFSET, data);
		if ((ver & 0xFF00) != 0 && (made & 0xFF00) == (ver & 0xFF00))
			ver &= 0xFF;
		
		// {@squirreljme.error BF0c Cannot open the entry because it uses
		// too new of a version. (The version number)}
		if (_MAX_CENTRAL_DIR_VERSION < ver)
			throw new ZipException(String.format("BF0c %d", ver));
		
		// Need these later to determine how much data is available and how it
		// is stored.
		int method = __ArrayData__.readUnsignedShort(
				_CENTRAL_DIRECTORY_METHOD_OFFSET, data);
		int crc = __ArrayData__.readSignedInt(_CENTRAL_DIRECTORY_CRC_OFFSET,
			data);
		long uncompressed = __ArrayData__.readUnsignedInt(
				_CENTRAL_DIRECTORY_UNCOMPRESSED_OFFSET, data),
			compressed = __ArrayData__.readUnsignedInt(
				_CENTRAL_DIRECTORY_COMPRESSED_OFFSET, data);
			
		// Determine the offset to the local header which precedes the data
		// of the entry
		long lhoffset = owner._zipbaseaddr + __ArrayData__.readUnsignedInt(
			_CENTRAL_DIRECTORY_LOCAL_HEADER_OFFSET, data);
		
		// {@squirreljme.error BF0d Could not read the local file header from
		// the ZIP file.}
		byte[] header = new byte[_LOCAL_HEADER_MIN_LENGTH];
		if (_LOCAL_HEADER_MIN_LENGTH != accessor.read(lhoffset, header, 0,
			_LOCAL_HEADER_MIN_LENGTH))
			throw new ZipException("BF0d");
		
		// {@squirreljme.error BF0e The magic number for the local file header
		// is not valid.}
		if (__ArrayData__.readSignedInt(0, header) !=
			_LOCAL_HEADER_MAGIC_NUMBER)
			throw new ZipException("BF0e");
		
		// Need to know the file name and comment lengths, since they may
		// differ in the local header for some reason
		int lhfnl = __ArrayData__.readUnsignedShort(
				_LOCAL_HEADER_NAME_LENGTH_OFFSET, header), 
			lhcml = __ArrayData__.readUnsignedShort(
				_LOCAL_HEADER_COMMENT_LENGTH_OFFSET, header);
		
		// The base address of the data is after the local header position
		long database = lhoffset + _LOCAL_HEADER_MIN_LENGTH + lhfnl + lhcml;
		
		// Get base stream before compression
		InputStream base = new __BlockAccessorRegionInputStream__(accessor,
			database, compressed);
		
		// {@squirreljme.error BF0f Unknown compression method for entry. (The
		// method identifier)}
		ZipCompressionType ztype = ZipCompressionType.forMethod(method);
		if (ztype == null)
			throw new ZipException(String.format("BF0f %d", method));
		
		// Wrap input so it may be read
		InputStream algo = ztype.inputStream(base);
		
		// Need to calculate the CRC for the stream of data
		return new __CRCInputStream__(algo, crc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/30
	 */
	@Override
	public String toString()
	{
		try
		{
			return __internalToString();
		}
			
		// {@squirreljme.error BF0g Could not read the name of the
		// entry.}
		catch (IOException e)
		{
			throw new RuntimeException("BF0g", e);
		}
	}
	
	/**
	 * Returns the internal representation of the string entry.
	 *
	 * @return The name of this entry.
	 * @throws IOException On read errors.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2017/01/03
	 */
	private final String __internalToString()
		throws IOException, ZipException
	{
		Reference<String> ref = this._name;
		String rv;
		
		// Need to load it?
		if (ref == null || null == (rv = ref.get()))
		{
			BlockAccessor accessor = this.accessor;
			long position = this.position;
			
			// {@squirreljme.error BF0h Could not read the central
			// directory data.}
			byte[] data = new byte[_CENTRAL_DIRECTORY_MIN_LENGTH];
			if (_CENTRAL_DIRECTORY_MIN_LENGTH != accessor.read(position,
				data, 0, _CENTRAL_DIRECTORY_MIN_LENGTH))
				throw new ZipException("BF0h");
			
			// Read file name length
			int fnl = __ArrayData__.readUnsignedShort(
				_CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET, data);
			
			// {@squirreljme.error BF0i Could not read the file name.}
			byte[] rawname = new byte[fnl];
			if (fnl != accessor.read(
				position + _CENTRAL_DIRECTORY_MIN_LENGTH, rawname, 0, fnl))
				throw new ZipException("BF0i");
			
			// UTF-8 Encoded?
			if ((__ArrayData__.readUnsignedShort(
				_CENTRAL_DIRECTORY_FLAG_OFFSET, data) &
				GPF_ENCODING_UTF8) != 0)
				rv = new String(rawname, 0, fnl, "utf-8");
			
			// DOS codepage
			else
				rv = IBM437CodePage.toString(rawname, 0, fnl);
			
			// Store for later
			this._name = new WeakReference<>(rv);
		}
		
		return rv;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/ZipBlockReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494














































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.Closeable;
import java.io.InputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import net.multiphasicapps.zip.ZipException;

/**
 * This class is used to read ZIP files in a random access fashion.
 *
 * @since 2016/12/27
 */
public class ZipBlockReader
	implements Iterable<ZipBlockEntry>, Closeable
{
	/** The magic number for central directory items. */
	private static final int _CENTRAL_DIRECTORY_MAGIC_NUMBER =
		0x02014B50;
	
	/** The offset to the file name length. */
	private static final int _CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET =
		28;
	
	/** The offset to the extra data length. */
	private static final int _CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET =
		_CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET + 2;
	
	/** The offset to the comment length. */
	private static final int _CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET =
		_CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET + 2;
	
	/** The minimum length of the central directory entry. */
	private static final int _CENTRAL_DIRECTORY_MIN_LENGTH =
		46;
	
	/** The magic number for the end directory. */
	private static final int _END_DIRECTORY_MAGIC_NUMBER =
		0x06054B50;
	
	/** The offset to the field for the number of entries in this disk. */
	private static final int _END_DIRECTORY_DISK_ENTRIES_OFFSET =
		8;
	
	/** The offset to the size of the central directory. */
	private static final int _END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET =
		_END_DIRECTORY_DISK_ENTRIES_OFFSET + 4;
	
	/** The offset to the offset of the central directory. */
	private static final int _END_DIRECTORY_CENTRAL_DIR_OFFSET_OFFSET =
		_END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET + 4;
	
	/** The minimum length of the end central directory record. */
	private static final int _END_DIRECTORY_MIN_LENGTH =
		22;
	
	/** The maximum length of the end central directory record. */
	private static final int _END_DIRECTORY_MAX_LENGTH =
		_END_DIRECTORY_MIN_LENGTH + 65535;
	
	/** The accessor to use for ZIP files. */
	protected final BlockAccessor accessor;
	
	/** The number of entries in this ZIP. */
	protected final int numentries;
	
	/** The base address for the central directory. */
	protected final long cdirbase;
	
	/** The actual start position for the ZIP file. */
	final long _zipbaseaddr;
	
	/** The accessor to use for ZIP files. */
	final BlockAccessor _accessor;
	
	/** Central directory entry offsets. */
	final long[] _offsets;
	
	/** Entries within this ZIP file. */
	private final Reference<ZipBlockEntry>[] _entries;
	
	/**
	 * Accesses the given array as a ZIP file.
	 *
	 * @param __b The array to wrap.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(byte[] __b)
		throws IOException, NullPointerException
	{
		this(new ArrayBlockAccessor(__b));
	}
	
	/**
	 * Accesses the given range in the array as a ZIP file.
	 *
	 * @param __b The array to wrap.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to make available.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length
	 * are negative or exceed the array bounds.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		this(new ArrayBlockAccessor(__b, __o, __l));
	}
	
	/**
	 * Accesses the given ZIP file from the block accessor.
	 *
	 * @param __b The accessor to the ZIP data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipException If the ZIP is malformed.
	 * @since 2016/12/27
	 */
	public ZipBlockReader(BlockAccessor __b)
		throws IOException, NullPointerException, ZipException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.accessor = __b;
		this._accessor = __b;
		
		// Locate the end of the central directory
		byte[] dirbytes = new byte[_END_DIRECTORY_MIN_LENGTH];
		long endat = __locateCentralDirEnd(__b, dirbytes);
		
		// Get the number of entries which are in this disk and not in the
		// archive as a whole, since multi-archive ZIP files are not supported
		int numentries = __ArrayData__.readUnsignedShort(
			_END_DIRECTORY_DISK_ENTRIES_OFFSET, dirbytes);
		this.numentries = numentries;
		
		// Need the size of the central directory to determine where it
		// actually starts
		long csz = __b.size();
		long cdirsize = __ArrayData__.readUnsignedInt(
			_END_DIRECTORY_CENTRAL_DIR_SIZE_OFFSET, dirbytes);
		
		// This is the position of the start of the central directory
		long cdirbase = endat - cdirsize;
		this.cdirbase = cdirbase;
		
		// {@squirreljme.error BF0j The central directory is larger than the
		// ZIP file, the ZIP is truncated. (The central directory size; The
		// size of the ZIP file)}
		if (cdirsize > csz)
			throw new ZipException(String.format("BF0j %d %d", cdirsize, csz));
		
		// Determine the base address of the ZIP file since all entries
		// are relative from the start point
		long zipbaseaddr = csz - (__ArrayData__.readUnsignedInt(
			_END_DIRECTORY_CENTRAL_DIR_OFFSET_OFFSET, dirbytes) + cdirsize +
			(csz - endat));
		this._zipbaseaddr = zipbaseaddr;
		
		// {@squirreljme.error BF0k The base address of the ZIP file exceeds
		// the bound of the ZIP file. (The central directory size; The size of
		// the ZIP file)}
		if (zipbaseaddr < 0 || zipbaseaddr > csz)
			throw new ZipException(String.format("BF0k %d %d", zipbaseaddr,
				csz));
		
		// Setup entry list
		this._entries = __newEntryReferenceList(numentries);
		
		// Initialize entry offsets
		this._offsets = __readOffsets();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.accessor.close();
	}
	
	/**
	 * Checks whether the ZIP file contains an entry with the given entry name.
	 *
	 * @param __s The name to check if it is contained within the ZIP.
	 * @return {@code true} If the ZIP contains an entry with this name.
	 * @throws IOException If the ZIP could not be read.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/30
	 */
	public boolean contains(String __s)
		throws IOException, NullPointerException
	{
		try
		{
			return get(__s) != null;
		}
		
		// Does not exist
		catch (ZipEntryNotFoundException e)
		{
			return false;
		}
	}
	
	/**
	 * Returns the entry which is associated with the given name.
	 *
	 * @return The entry for the given name.
	 * @throws IOException If there was an error reading the ZIP.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipEntryNotFoundException If the entry does not exist.
	 * @since 2016/12/30
	 */
	public ZipBlockEntry get(String __s)
		throws IOException, NullPointerException, ZipEntryNotFoundException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Use linear search since entries might be in any order
		for (ZipBlockEntry e : this)
			if (e.toString().equals(__s))
				return e;
		
		// {@squirreljme.error BF0l Could not find the entry with the
		// specified name. (The name of the entry)}
		throw new ZipEntryNotFoundException(String.format("BF0l %s", __s));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/30
	 */
	@Override
	public Iterator<ZipBlockEntry> iterator()
	{
		return new __Iterator__();
	}
	
	/**
	 * Opens the file with the given name from this ZIP file and returns the
	 * input stream for its data.
	 *
	 * @param __s The file to open.
	 * @return The input stream to the file.
	 * @throws IOException If the file could not be opened due to either a
	 * damaged ZIP file, failed read, or if it does not exist.
	 * @throws NullPointerException On null arguments.
	 * @throws ZipEntryNotFoundException If the entry could not be found.
	 * @since 2016/12/30
	 */
	public InputStream open(String __s)
		throws IOException, NullPointerException, ZipEntryNotFoundException
	{
		// {@squirreljme.error BF0m The specified entry does not exist
		// within the ZIP file. (The entry name)}
		ZipBlockEntry ent = get(__s);
		if (ent == null)
			throw new ZipEntryNotFoundException(String.format("BF0m %s", __s));
		
		// Open it
		return ent.open();
	}
	
	/**
	 * Returns the number of entries in this ZIP file.
	 *
	 * @return The number of entries in the ZIP.
	 * @since 2016/12/30
	 */
	public int size()
	{
		return this.numentries;
	}
	
	/**
	 * Reads the offsets within the ZIP file for central directory items.
	 *
	 * @return The array of offsets.
	 * @throws IOException On read errors or the ZIP is not valid.
	 * @since 2016/12/31
	 */
	private long[] __readOffsets()
		throws IOException
	{
		// Setup return value
		int numentries = this.numentries;
		long[] rv = new long[numentries];
		
		// Read in every entry within the ZIP
		BlockAccessor accessor = this.accessor;
		long at = this.cdirbase;
		byte[] cdirent = new byte[_CENTRAL_DIRECTORY_MIN_LENGTH];
		for (int i = 0; i < numentries; i++)
		{
			// Entry is placed at this position
			rv[i] = at;
			
			// {@squirreljme.error BF0n Central directory extends past the end
			// of the file. (The current entry; The current read position; The
			// size of the file)}
			if (accessor.read(at, cdirent, 0, _CENTRAL_DIRECTORY_MIN_LENGTH) !=
				_CENTRAL_DIRECTORY_MIN_LENGTH)
				throw new ZipException(String.format("BF0n %d %d %d", i, at,
					accessor.size()));
			
			// {@squirreljme.error BF0o The entry does not have a valid
			// magic number. (The entry index)}
			if (__ArrayData__.readSignedInt(0, cdirent) !=
				_CENTRAL_DIRECTORY_MAGIC_NUMBER)
				throw new ZipException(String.format("BF0o %d", i));
			
			// Read lengths for file name, comment, and extra data
			int fnl = __ArrayData__.readUnsignedShort(
					_CENTRAL_DIRECTORY_NAME_LENGTH_OFFSET, cdirent),
				cml = __ArrayData__.readUnsignedShort(
					_CENTRAL_DIRECTORY_EXTRA_LENGTH_OFFSET, cdirent),
				edl = __ArrayData__.readUnsignedShort(
					_CENTRAL_DIRECTORY_COMMENT_LENGTH_OFFSET, cdirent);
			
			// Next entry is just after this point
			at += fnl + cml + edl + _CENTRAL_DIRECTORY_MIN_LENGTH;
		}
		
		// Done
		return rv;
	}
	
	/**
	 * Locates the end of the central directory.
	 *
	 * @param __b The block accessor to search.
	 * @param __db The bytes that make up the end of the central directory.
	 * @return The position of the central directory end.
	 * @throws IOException On read errors or if the central directory could
	 * not be found.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/29
	 */
	private static final long __locateCentralDirEnd(BlockAccessor __b,
		byte[] __db)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null || __db == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF0p The file is too small to be a ZIP file.
		// (The size of file)}
		long size = __b.size();
		if (size < _END_DIRECTORY_MIN_LENGTH)
			throw new ZipException(String.format("BF0p %d", size));
		
		// Constantly search for the end of the central directory
		for (long at = size - _END_DIRECTORY_MIN_LENGTH, end =
			Math.max(0, size - _END_DIRECTORY_MAX_LENGTH); at >= end; at--)
		{
			// Read single byte to determine if it might start a header
			byte b = __b.read(at);
			if (b != 0x50)
				continue;
			
			// Read entire buffer (but not the comment in)
			__b.read(at, __db, 0, _END_DIRECTORY_MIN_LENGTH);
			
			// Need to check the magic number
			if (__ArrayData__.readSignedInt(0, __db) !=
				_END_DIRECTORY_MAGIC_NUMBER)
				continue;
			
			// Length must match the end also
			if (__ArrayData__.readUnsignedShort(_END_DIRECTORY_MIN_LENGTH - 2,
				__db) != (size - (at + _END_DIRECTORY_MIN_LENGTH)))
				continue;
			
			// Central directory is here
			return at;
		}
		
		// {@squirreljme.error BF0q Could not find the end of the central
		// directory in the ZIP file.}
		throw new ZipException("BF0q");
	}
	
	/**
	 * Creates a list of references.
	 *
	 * @param __n The number of elements in the list.
	 * @return The list.
	 * @since 2016/12/31
	 */
	@SuppressWarnings({"unchecked"})
	private static Reference<ZipBlockEntry>[] __newEntryReferenceList(
		int __n)
	{
		return (Reference<ZipBlockEntry>[])((Object)new Reference[__n]);
	}
	
	/**
	 * Iterates over entries within the ZIP.
	 *
	 * @since 2016/12/31
	 */
	private class __Iterator__
		implements Iterator<ZipBlockEntry>
	{
		/** Entry count. */
		protected final int numentries =
			ZipBlockReader.this.numentries;
		
		/** The next entry. */
		private volatile int _next =
			0;
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public boolean hasNext()
		{
			return (this._next < this.numentries);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public ZipBlockEntry next()
			throws NoSuchElementException
		{
			// No more entries?
			int next = this._next;
			if (next >= this.numentries)
				throw new NoSuchElementException("NSEE");
			
			// Next entry to read
			this._next = next + 1;
			
			// Parse and return entry
			Reference<ZipBlockEntry>[] entries = ZipBlockReader.this._entries;
			Reference<ZipBlockEntry> ref = entries[next];
			ZipBlockEntry rv;
			
			// Need to load the entry?
			if (ref == null || null == (rv = ref.get()))
				entries[next] = new WeakReference<>(
					(rv = new ZipBlockEntry(ZipBlockReader.this, next)));
			
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/12/31
		 */
		@Override
		public void remove()
		{
			throw new UnsupportedOperationException("RORO");
		}
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/ZipEntryNotFoundException.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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import net.multiphasicapps.zip.ZipException;

/**
 * This is thrown when an entry within a ZIP file is not found.
 *
 * @since 2017/01/22
 */
public class ZipEntryNotFoundException
	extends ZipException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/01/22
	 */
	public ZipEntryNotFoundException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/__ArrayData__.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

/**
 * This class contains methods for reading data from arrays, all read values
 * are little endian.
 *
 * @since 2016/12/28
 */
final class __ArrayData__
{
	/**
	 * Reads a signed integer from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readSignedInt(int __off, byte[] __b)
	{
		return (__b[__off + 3] << 24) |
			((__b[__off + 2] & 0xFF) << 16) |
			((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads a signed short from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readSignedShort(int __off, byte[] __b)
	{
		return (__b[__off + 1] << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads an unsigned integer from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static long readUnsignedInt(int __off, byte[] __b)
	{
		return ((__b[__off + 3] & 0xFF) << 24) |
			((__b[__off + 2] & 0xFF) << 16) |
			((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
	
	/**
	 * Reads an unsigned short from the array.
	 *
	 * @param __off The offset to read from.
	 * @param __b The array to read from.
	 * @return The read value.
	 * @since 2016/12/28
	 */
	static int readUnsignedShort(int __off, byte[] __b)
	{
		return ((__b[__off + 1] & 0xFF) << 8) |
			(__b[__off] & 0xFF);
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/__BlockAccessorRegionInputStream__.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.InputStream;
import java.io.IOException;

/**
 * This is used to read directly from the block accessor.
 *
 * @since 2017/01/03
 */
class __BlockAccessorRegionInputStream__
	extends InputStream
{
	/** The accessor to read from. */
	protected final BlockAccessor accessor;
	
	/** The next position to read from. */
	private volatile long _next;
	
	/** The current number of bytes remaining. */
	private volatile long _rest;
	
	/**
	 * Initializes the block region input.
	 *
	 * @param __ba The block accessor to read data from.
	 * @param __start The start address of the read.
	 * @param __len The number of bytes to read.
	 * @throws IllegalArgumentException If the start and/or length are
	 * negative.
	 * @thorws NullPointerException On null arguments.
	 * @since 2017/01/03
	 */
	__BlockAccessorRegionInputStream__(BlockAccessor __ba, long __start,
		long __len)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__ba == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF0r The start position and length cannot be
		// negative.}
		if (__start < 0 || __len < 0)
			throw new IllegalArgumentException("BF0r");
		
		// Set
		this.accessor = __ba;
		this._next = __start;
		this._rest = __len;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int available()
		throws IOException
	{
		// Never exceed 2GiB
		return (int)Math.min(Math.max(0, this._rest), Integer.MAX_VALUE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/01/03
	 */
	@Override
	public int read()
		throws IOException
	{
		// Forward to multi-byte version
		byte[] b = new byte[1];
		for (;;)
		{
			int rv = read(b, 0, 1);
			
			// EOF?
			if (rv < 0)
				return -1;
			
			// Return value otherwise
			return b[0] & 0xFF;
		}
	}
	
	/**
	 * {@inheritDoc]
	 * @since 2017/01/03
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// EOF?
		long rest = this._rest;
		if (rest <= 0)
			return -1;
		
		// Determine number of bytes to read
		long next = this._next;
		int desired = (int)Math.min(__l, rest);
		
		// Read in the data
		int actual = this.accessor.read(next, __b, __o, desired);
		
		// Set next position
		this._next = next + actual;
		this._rest = rest - actual;
		
		// Return the actual read count
		return actual;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/__CRCInputStream__.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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.blockreader;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.zip.ZipCRCConstants;

/**
 * This is used to check that the CRC is valid.
 *
 * @since 2017/01/03
 */
class __CRCInputStream__
	extends InputStream
{
	/** The stream to source from. */
	protected final InputStream in;
	
	/** The final resulting CRC to use. */
	protected final int crc;
	
	/** CRC calculation. */
	protected final CRC32Calculator crccalc =
		new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
			ZipCRCConstants.CRC_REFLECT_REMAINDER,
			ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
			ZipCRCConstants.CRC_FINALXOR);
	
	/** The number of read bytes. */
	private volatile int _count;
	
	/**
	 * Calcualtes the CRC of another given input stream.
	 *
	 * @param __in The stream to read from.
	 * @param __crc The final CRC to calculate.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/01/03
	 */
	__CRCInputStream__(InputStream __in, int __crc)
		throws NullPointerException
	{
		// Check
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.in = __in;
		this.crc = __crc;
	}
	
	/**
	 * {@inheritDoc]
	 * @since 2017/01/03
	 */
	@Override
	public int available()
		throws IOException
	{
		// Forward as it may be calculable
		return this.in.available();
	}
	
	/**
	 * {@inheritDoc]
	 * @since 2017/01/03
	 */
	@Override
	public void close()
		throws IOException
	{
		// Forward
		this.in.close();
	}
	
	/**
	 * {@inheritDoc]
	 * @since 2017/01/03
	 */
	@Override
	public int read()
		throws IOException
	{
		// Read in
		int rv = this.in.read();
		
		// EOF? Check CRC value
		CRC32Calculator crccalc = this.crccalc;
		if (rv < 0)
		{
			// {@squirreljme.error BF0s CRC mismatch. (The expected CRC; The
			// calculated CRC; The number of read bytes})
			int thiscrc = crccalc.checksum(), wantcrc = this.crc;
			if (thiscrc != wantcrc)
				throw new IOException(String.format("BF0s %08x %08x %d",
					wantcrc, thiscrc, this._count));
			
			// EOF
			return -1;
		}
		
		// Calculate
		crccalc.offer((byte)rv);
		this._count += 1;
		
		// Return
		return rv;
	}
	
	/**
	 * {@inheritDoc]
	 * @since 2017/01/03
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// Read in
		int rv = this.in.read(__b, __o, __l);
		
		// EOF? Check CRC value
		CRC32Calculator crccalc = this.crccalc;
		if (rv < 0)
		{
			// {@squirreljme.error BF0t CRC mismatch. (The expected CRC; The
			// calculated CRC; The number of read bytes})
			int thiscrc = crccalc.checksum(), wantcrc = this.crc;
			if (thiscrc != wantcrc)
				throw new IOException(String.format("BF0t %08x %08x %d",
					wantcrc, thiscrc, this._count));
			
			// EOF
			return -1;
		}
		
		// Calculate
		crccalc.offer(__b, __o, rv);
		this._count += rv;
		
		// Return
		return rv;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/blockreader/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the code which is used to parse ZIP files in a random
 * access fashion.
 *
 * @since 2016/12/27
 */

package net.multiphasicapps.zip.blockreader;

Deleted runt/libs/zip/net/multiphasicapps/zip/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains basic ZIP file support.
 *
 * @since 2016/07/15
 */

package net.multiphasicapps.zip;

Deleted runt/libs/zip/net/multiphasicapps/zip/streamreader/ZipStreamEntry.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446






























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamreader;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.DecompressionInputStream;
import net.multiphasicapps.io.DynamicHistoryInputStream;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipCRCConstants;
import net.multiphasicapps.zip.ZipException;

/**
 * This provides an interface to interact with a single entry within a ZIP
 * stream.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public final class ZipStreamEntry
	extends InputStream
{
	/** The maximum size the data descriptor can be (if there is one). */
	private static final int _MAX_DESCRIPTOR_SIZE =
		16;
	
	/** The descriptor size if there is no header. */
	private static final int _HEADERLESS_DESCRIPTOR_SIZE =
		12;
	
	/** Data descriptor magic number. */
	private static final int _DESCRIPTOR_MAGIC_NUMBER =
		0x08074B50;
	
	/** CRC calculation. */
	protected final CRC32Calculator crc =
		new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
			ZipCRCConstants.CRC_REFLECT_REMAINDER,
			ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
			ZipCRCConstants.CRC_FINALXOR);
	
	/** The owning stream reader. */
	protected final ZipStreamReader zipreader;
	
	/** The name of the file. */
	protected final String filename;
	
	/** The compression method. */
	protected final ZipCompressionType method;
	
	/** The dynamic input stream to read from. */
	protected final DynamicHistoryInputStream dhin;
	
	/** The compressed stream which also has counting. */
	protected final DecompressionInputStream cin;
	
	/** Is the content length undefined? */
	protected final boolean undefined;
	
	/** Is EOF detected? */
	protected final boolean detectseof;
	
	/** The expected CRC. */
	protected final int expectedcrc;
	
	/** The expected file uncompressed size. */
	protected final int expecteduncompsize;
	
	/** The expected file compressed size. */
	protected final int expectedcompsize;
	
	/** Single byte read. */
	private final byte[] _solo =
		new byte[1];
	
	/** Used for peeking bytes to detect EOF. */
	private final byte[] _peeking;
	
	/** Has this been closed? */
	private volatile boolean _closed;
	
	/** The number of uncompressed bytes read. */
	private volatile long _readuncomp;
	
	/** Has EOF been reached? */
	private volatile boolean _eof;
	
	/**
	 * Initializes the entry.
	 *
	 * @param __zsr The owning stream reader.
	 * @param __fn The name of the entry.
	 * @param __undef Is the size and CRC undefined?
	 * @param __crc The expected CRC.
	 * @param __comp The compressed size.
	 * @param __uncomp The uncompressed size.
	 * @param __method The compression method.
	 * @param __ins The input data source.
	 * @throws IOException If the decompressor could not be initialized.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	ZipStreamEntry(ZipStreamReader __zsr, String __fn, boolean __undef,
		int __crc, int __comp, int __uncomp, ZipCompressionType __method,
		DynamicHistoryInputStream __ins)
		throws IOException, NullPointerException
	{
		// Check
		if (__zsr == null || __fn == null || __method == null ||
			__ins == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.zipreader = __zsr;
		this.filename = __fn;
		this.method = __method;
		this.dhin = __ins;
		DecompressionInputStream dis;
		this.cin = (dis = __method.inputStream(__ins, this.crc));
		this.undefined = __undef;
		this.detectseof = dis.detectsEOF();
		this.expectedcrc = __crc;
		this.expecteduncompsize = __uncomp;
		this.expectedcompsize = __comp;
		this._peeking = (__undef ? new byte[_MAX_DESCRIPTOR_SIZE] : null);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public void close()
		throws IOException
	{
		if (!this._closed)
		{
			// Mark closed
			this._closed = true;
			
			// Read all input bytes until EOF, except when EOF was already
			// reached
			if (!this._eof)
			{
				byte[] buf = new byte[512];
				while (read(buf) >= 0)
					;
			}
			
			// Tell the ZIP reader that this entry is gone and the next
			// can be read
			this.zipreader.__closeEntry(this);
		}
	}
	
	/**
	 * Returns the compression type that the entry uses.
	 *
	 * @return The compression type.
	 * @since 2016/07/19
	 */
	public ZipCompressionType compressionType()
	{
		return this.method;
	}
	
	/**
	 * Returns the name of the entry.
	 *
	 * @return The entry name.
	 * @since 2016/07/19
	 */
	public String name()
	{
		return this.filename;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public int read()
		throws IOException
	{
		// Try reading a single byte
		byte[] solo = this._solo;
		for (;;)
		{
			int rv = read(solo, 0, 1);
			
			// EOF?
			if (rv < 0)
				return rv;
			
			// Try again
			else if (rv == 0)
				continue;
			
			// Return that byte
			else
				return (solo[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/08/22
	 */
	@Override
	public int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		int n = __b.length;
		if (__o < 0 || __l < 0 || (__o + __l) > n)
			throw new IndexOutOfBoundsException("IOOB");
		
		// If EOF reached, do nothing
		if (this._eof)
			return -1;
		
		// Reading an undefined number of bytes?
		// If so then a data descriptor will need to be checked
		if (this.undefined)
		{
			// If EOF is detectable then read in the contents until such
			// things occur. Then read the data descriptor to verify that it
			// actually is correct
			if (this.detectseof)
				return __detectedRead(__b, __o, __l);
			
			// Otherwise, the input stream has to be peeked constantly to
			// detect the data descriptor.
			else
				return __probingRead(__b, __o, __l);
		}
		
		// Read of a defined number of bytes
		else
			return __definedRead(__b, __o, __l);
	}
	
	/**
	 * This is a read of input which has a defined size.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __definedRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		// Needed to check things
		DecompressionInputStream cin = this.cin;
		long cinusz = cin.uncompressedBytes(),
			cincsz = cin.compressedBytes();
		
		// Never read more than the maximum in unsigned bytes
		int rest = (int)(this.expecteduncompsize - cinusz);
		if (__l > rest)
			__l = rest;
		
		// Read data
		int rc = this.cin.read(__b, __o, __l);
		
		// EOF reached?
		if (rc < 0)
		{
			// Mark EOF
			this._eof = true;
			
			// {@squirreljme.error BF0u Reached end of file in the entry
			// however the size it consumes and/or its CRC does not match
			// the expected values. (The expected CRC; The actual CRC;
			// The expected uncompressed size; The actual uncompressed
			// size; The expected compressed size; The actual compressed
			// size)}
			CRC32Calculator crc = this.crc;
			int expectedcrc = this.expectedcrc,
				expecteduncompsize = this.expecteduncompsize,
				expectedcompsize = this.expectedcompsize;
			if (expecteduncompsize != cinusz ||
				expectedcompsize != cincsz ||
				expectedcrc != crc.checksum())
				throw new ZipException(String.format(
					"BF0u %08x %08x %d %d %d %d", expectedcrc,
					crc.checksum(), expecteduncompsize, cinusz,
					expectedcompsize, cincsz));
			
			// Nothing read
			return -1;
		}
		
		// Mark as read
		this._readuncomp += rc;
		return rc;
	}
	
	/**
	 * Read of undefined size data, but where the EOF is detectable.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __detectedRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		// This is as simple as reading the input bytes
		DecompressionInputStream cin = this.cin;
		int rc = cin.read(__b, __o, __l);
		
		// If EOF was not reached, then just return with the read bytes
		if (rc >= 0)
			return rc;
		
		// EOF was reached from the compressed stream, so the data descriptor
		// has to immedietly follow
		DynamicHistoryInputStream dhin = this.dhin;
		byte[] peeking = this._peeking;
		
		// Mark EOF so future reads fail
		this._eof = true;
		
		// {@squirreljme.error BF0v Could not find end of entry because the
		// entry exceeds the bounds of the ZIP file. (The number of read
		// bytes)}
		int probed = dhin.peek(0, peeking, 0, _MAX_DESCRIPTOR_SIZE);
		if (probed < _HEADERLESS_DESCRIPTOR_SIZE)
			throw new ZipException(String.format("BF0v %d", probed));
		
		// The specification says the descriptor is optional
		int offset = (_DESCRIPTOR_MAGIC_NUMBER ==
			ZipStreamReader.__readInt(peeking, 0) ? 4 : 0);

		// Read descriptor fields
		int ddcrc = ZipStreamReader.__readInt(peeking, offset),
			ddcomp = ZipStreamReader.__readInt(peeking, offset + 4),
			dduncomp = ZipStreamReader.__readInt(peeking, offset + 8);

		// {@squirreljme.error BF0w Reached end of file in the entry
		// however the size it consumes and/or its CRC does not match
		// the expected values. (The expected CRC; The actual CRC;
		// The expected uncompressed size; The actual uncompressed
		// size; The expected compressed size; The actual compressed
		// size)}
		CRC32Calculator crc = this.crc;
		long cinusz = cin.uncompressedBytes(),
			cincsz = cin.compressedBytes();
		if (dduncomp != cinusz ||
			ddcomp != cincsz ||
			ddcrc != crc.checksum())
			throw new ZipException(String.format(
				"BF0w %08x %08x %d %d %d %d", ddcrc,
				crc.checksum(), dduncomp, cinusz,
				ddcomp, cincsz));
		
		// EOF is OK now
		return -1;
	}
	
	/**
	 * Read of undefined size data, however since the input is not known it
	 * must be probed for the end to be detected.
	 *
	 * @param __b The array to read into.
	 * @param __o The offset into the array.
	 * @param __l The number of bytes to potentially read.
	 * @return The number of bytes read.
	 * @throws IOException On read errors.
	 * @since 2017/08/23
	 */
	private int __probingRead(byte[] __b, int __o, int __l)
		throws IOException
	{
		DynamicHistoryInputStream dhin = this.dhin;
		byte[] peeking = this._peeking;
		CRC32Calculator crc = this.crc;
		DecompressionInputStream cin = this.cin;
		
		// Due to the nature the end of a stream must be detected for this
		// data, the input must be read a single byte at a time which
		// introduces much overhead
		int d = 0;
		for (int i = __o, e = __o + __l; i < e; i++, d++)
		{
			// {@squirreljme.error BF0x Could not find end of entry because the
			// entry exceeds the bounds of the ZIP file. (The number of read
			// bytes)}
			int probed = dhin.peek(0, peeking, 0, _MAX_DESCRIPTOR_SIZE);
			if (probed < _HEADERLESS_DESCRIPTOR_SIZE)
				throw new ZipException(String.format("BF0x %d", probed));
		
			// According to the specification, the magic number is optional and
			// might not be specified
			// Regardless if it is or not, potentially skip it
			int offset = (_DESCRIPTOR_MAGIC_NUMBER ==
				ZipStreamReader.__readInt(peeking, 0) ? 4 : 0);
		
			// Read descriptor fields
			int ddcrc = ZipStreamReader.__readInt(peeking, offset),
				ddcomp = ZipStreamReader.__readInt(peeking, offset + 4),
				dduncomp = ZipStreamReader.__readInt(peeking, offset + 8);
			
			// EOF occurs?
			if (ddcomp == cin.compressedBytes() &&
				dduncomp == cin.uncompressedBytes() &&
				ddcrc == crc.checksum())
			{
				// Mark EOF
				this._eof = true;
				return (d == 0 ? -1 : d);
			}
			
			// {@squirreljme.error BF0y Reached end of file before the end
			// of the ZIP entry could be found.}
			int rc = cin.read();
			if (rc < 0)
				throw new ZipException("BF0y");
			__b[i] = (byte)rc; 
		}
		
		// Read count
		return d;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/streamreader/ZipStreamReader.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399















































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamreader;

import java.io.Closeable;
import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.DataEndianess;
import net.multiphasicapps.io.DynamicHistoryInputStream;
import net.multiphasicapps.io.ExtendedDataInputStream;
import net.multiphasicapps.zip.IBM437CodePage;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipException;

/**
 * This class supports stream based reading of input ZIP files.
 *
 * Only files up to 2GiB in length are supported. If a data descriptor is
 * specified for entries then they must have the optional descriptor magic
 * number included.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/19
 */
public class ZipStreamReader
	implements Closeable
{
	/** The maximum support version for extracting. */
	private static final int _MAX_EXTRACT_VERSION =
		20;
	
	/** The minumum size of the local header. */
	private static final int _MINIMUM_HEADER_SIZE =
		30;
	
	/** The local header magic number. */
	private static final int _LOCAL_HEADER_MAGIC =
		0x04034B50;
	
	/** The dynamic history stream. */
	protected final DynamicHistoryInputStream input;
	
	/** This is used after an input structure is detected. */
	protected final ExtendedDataInputStream data;
	
	/** This can hold the local header except for the comment and filename. */
	private final byte[] _localheader =
		new byte[_MINIMUM_HEADER_SIZE];
	
	/** The current entry being read, cannot next entry if this is the case. */
	private volatile ZipStreamEntry _entry;
	
	/** End of file reached? */
	private volatile boolean _eof;
	
	/** Deferred exceptions, set after an entry read fails. */
	private volatile ZipException _defer;
	
	/**
	 * Initializes the reader for input ZIP file data.
	 *
	 * @param __is The input stream to source bytes from.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/19
	 */
	public ZipStreamReader(InputStream __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Set
		DynamicHistoryInputStream q;
		this.input = (q = new DynamicHistoryInputStream(__is));
		ExtendedDataInputStream d;
		this.data = (d = new ExtendedDataInputStream(q));
		d.setEndianess(DataEndianess.LITTLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/19
	 */
	@Override
	public void close()
		throws IOException
	{
		// Mark EOF
		this._eof = true;
		
		// Close the source
		this.input.close();
		this.data.close();
	}
	
	/**
	 * If an entry is detected and it could not be read, then this exception
	 * may be set to detect such events.
	 *
	 * @return The deferred exception or {@code null} if there is none.
	 * @since 2016/09/11
	 */
	public ZipException deferred()
	{
		ZipException rv = this._defer;
		this._defer = null;
		return rv;
	}
	
	/**
	 * Returns the next entry in the streamed ZIP file for {@code null} if no
	 * such entry exists.
	 *
	 * @return The next entry or {@code null} if there is none.
	 * @throws IOException On read errors.
	 * @since 2016/07/19
	 */
	public ZipStreamEntry nextEntry()
		throws IOException
	{
		// {@squirreljme.error BF0z An entry is currently being read, it
		// must first be closed.}
		if (this._entry != null)
			throw new IOException("BF0z");
		
		// End of file reached?
		if (this._eof)
			return null;
		
		// Read until an entry is found
		DynamicHistoryInputStream input = this.input;
		ExtendedDataInputStream data = this.data;
		byte[] localheader = this._localheader;
		for (; !this._eof;)
		{
			// Peek the magic number
			int rhcount;
			try
			{
				rhcount = input.peek(0, localheader, 0, 4);
			}
			
			// {@squirreljme.error BF10 Could not peek the magic number.}
			catch (IndexOutOfBoundsException e)
			{
				throw new ZipException("BF10", e);
			}
		
			// Could not fit the magic number, treat as EOF
			if (rhcount < 4)
			{
				this._eof = true;
				return null;
			}
		
			// Does not match the magic number for local headers
			int lhskip = __skipLocalHeader(localheader);
			
			// Not one
			if (lhskip > 0)
			{
				// Read
				try
				{
					data.readFully(localheader, 0, lhskip);
				}
				
				// End of file
				catch (EOFException e)
				{
					this._eof = true;
				}
				
				// Return null on the next loop
				continue;
			}
			
			// Read the rest of the header
			rhcount = input.peek(0, localheader);
			
			// EOF reached (cannot fit a local header in this many bytes)
			// Ignore the somewhat malformed ZIP since it could be part of
			// another file structure due to polyglots
			if (rhcount < _MINIMUM_HEADER_SIZE)
			{
				this._eof = true;
				return null;
			}
			
			// Deferred exception?
			ZipException defer = null;
			
			// Check the version needed for extracting
			// Note that some ZIP writing software sets the upper byte when it
			// should not. Since the made by version is not stored in the
			// local file header, the byte will just be stripped.
			int xver = __readUnsignedShort(localheader, 4) & 0xFF;
			boolean deny = false;
			deny |= (xver < 0 || xver > _MAX_EXTRACT_VERSION);
			
			// {@squirreljme.error BF11 Zip version not suppored. (The
			// version)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF11 %d",
					xver));
			
			// Read bit flags
			int gpfs = __readUnsignedShort(localheader, 6);
			boolean utf = (0 != (gpfs & (1 << 11)));
			boolean undefinedsize = (0 != (gpfs & (1 << 3)));
			
			// Cannot read encrypted entries
			deny |= (0 != (gpfs & 1));
			
			// {@squirreljme.error BF12 Encrypted entries not supported.}
			if (defer == null && deny)
				defer = new ZipException("BF12");
			
			// Read the compression method
			ZipCompressionType cmeth = ZipCompressionType.forMethod(
				__readUnsignedShort(localheader, 8));
			deny |= (cmeth == null);
			
			// {@squirreljme.error BF13 Compression method not supported.
			// (The method)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF13 %d", cmeth));
			
			// Read CRC32
			int crc = __readInt(localheader, 14);
			
			// Read Compressed size
			int csz = __readInt(localheader, 18);
			if (!undefinedsize)
				deny |= (csz < 0);
			
			// Uncompressed size
			int usz = __readInt(localheader, 22);
			if (!undefinedsize)
				deny |= (usz < 0);
			
			// {@squirreljme.error BF14 Entry exceeds 2GiB in size.
			// (The compressed size; The uncompressed size)}
			if (defer == null && deny)
				defer = new ZipException(String.format("BF14 %d %d", csz,
					usz));
			
			// File name length
			int fnl = __readUnsignedShort(localheader, 26);
			
			// Comment length
			int cml = __readUnsignedShort(localheader, 28);
			
			// If denying, read a single byte and try again, this could
			// just be very ZIP-like data or the local header number could
			// be a constant in an executable.
			if (deny)
			{
				// Defer the issue, if set
				if (defer != null)
					this._defer = defer;
				
				// Skip 4 bytes because the header was already read
				this.data.readFully(localheader, 0, 4);
				continue;
			}
			
			// Read the local header normally to consume it
			data.readFully(localheader);
			
			// Read the file name, if EOF was reached then ignore
			byte[] rawname = new byte[fnl];
			data.readFully(rawname);
			
			// If UTF-8 then use internal handling
			String filename;
			if (utf)
				filename = new String(rawname, 0, fnl, "utf-8");
		
			// Otherwise use codepage handling, Java ME only has two
			// character sets available
			else
				filename = IBM437CodePage.toString(rawname, 0, fnl);
			
			// Skip the comment
			data.readFully(localheader, 0, Math.min(cml,
				_MINIMUM_HEADER_SIZE));
			
			// Create entry so the data can actually be used
			ZipStreamEntry rv = new ZipStreamEntry(this, filename,
				undefinedsize, crc, csz, usz, cmeth, input);
			this._entry = rv;
			return rv;
		}
		
		// No entry
		this._eof = true;
		return null;
	}
	
	/**
	 * Closes an entry so that the next one can be read.
	 *
	 * @param __ent The entry to close.
	 * @throws IOException If it could not be closed.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/20
	 */
	final void __closeEntry(ZipStreamEntry __ent)
		throws IOException, NullPointerException
	{
		// Check
		if (__ent == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BF15 Close of an incorrect entry.}
		if (this._entry != __ent)
			throw new IOException("BF15");
		
		// Clear it
		this._entry = null;
	}
	
	/**
	 * Reads an unsigned integer value.
	 *
	 * @param __b The byte array to read from.
	 * @param __p The position to read from.
	 * @return The read value.
	 * @since 2016/07/19
	 */
	static int __readInt(byte[] __b, int __p)
	{
		return (__b[__p] & 0xFF) |
			((__b[__p + 1] & 0xFF) << 8) |
			((__b[__p + 2] & 0xFF) << 16) |
			((__b[__p + 3] & 0xFF) << 24);
	}
	
	/**
	 * Reads an unsigned short from the given byte array.
	 *
	 * @param __b The byte array to read from.
	 * @param __p The position to read from.
	 * @return The read value.
	 * @since 2016/07/19
	 */
	static int __readUnsignedShort(byte[] __b, int __p)
	{
		return (__b[__p] & 0xFF) |
			((__b[__p + 1] & 0xFF) << 8);
	}
	
	/**
	 * Checks if the specified buffer starts with the local header magic
	 * number and if not returns the number of bytes to skip.
	 *
	 * @param __b The bytes to check, from the zero index.
	 * @return Zero means this is the local header, otherwise a value up to 4.
	 * @since 2016/07/19
	 */
	private static int __skipLocalHeader(byte[] __b)
	{
		// Read values
		byte lha = __b[0], lhb = __b[1], lhc = __b[2], lhd = __b[3];
		
		// Is this the magic number?
		if (lha == 0x50 && lhb == 0x4B && lhc == 0x03 && lhd == 0x04)
			return 0;
		
		// Next byte over
		else if (lhb == 0x50 && lhc == 0x4B && lhd == 0x03)
			return 1;
		
		// Skip two bytes
		else if (lhc == 0x50 && lhd == 0x4B)
			return 2;
		
		// Last byte could be it
		if (lhd == 0x50)
			return 3;
		
		// None of them
		return 4;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/streamreader/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the class which supports reading and handling streams of ZIP
 * files.
 *
 * @since 2016/07/19
 */

package net.multiphasicapps.zip.streamreader;

Deleted runt/libs/zip/net/multiphasicapps/zip/streamwriter/ZipStreamWriter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648








































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamwriter;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import net.multiphasicapps.io.CRC32Calculator;
import net.multiphasicapps.io.DataEndianess;
import net.multiphasicapps.io.ExtendedDataOutputStream;
import net.multiphasicapps.zip.ZipCompressionType;
import net.multiphasicapps.zip.ZipCRCConstants;

/**
 * This class is used to write to ZIP files in an unknown and stream based
 * manner where the size of the contents is completely unknown.
 *
 * When the stream is closed, the central directory of the ZIP file will be
 * written to the end of the file.
 *
 * This class is not thread safe.
 *
 * @since 2016/07/09
 */
public class ZipStreamWriter
	implements Closeable
{
	/** The magic number for local files. */
	private static final int _LOCAL_FILE_MAGIC_NUMBER =
		0x04034B50;
	
	/** Data descriptor magic. */
	private static final int _DATA_DESCRIPTOR_MAGIC_NUMBER =
		0x08074B50;
	
	/** Central directory entry magic number. */
	private static final int _CENTRAL_DIRECTORY_MAGIC_NUMBER =
		0x02014B50;
	
	/** End of central directory magic number. */
	private static final int _END_DIRECTORY_MAGIC_NUMBER =
		0x06054B50;
	
	/** The maximum permitted file size. */
	private static final long _MAX_FILE_SIZE =
		0xFFFFFFFFL;
	
	/** General purpose flags for entries (use descriptor; UTF-8 names). */
	private static final int _GENERAL_PURPOSE_FLAGS =
		(1 << 3) | (1 << 11);
	
	/** The output stream to write to. */
	protected final ExtendedDataOutputStream output;
	
	/** Table of contents. */
	private final LinkedList<__TOCEntry__> _toc =
		new LinkedList<>();
	
	/** Was this stream closed? */
	private boolean _closed;
	
	/** The current entry output (the inner portion). */
	private __InnerOutputStream__ _inner;
	
	/** The current entry output (the outer portion). */
	private __OuterOutputStream__ _outer;
	
	/** The best version number. */
	private int _bestversion =
		Math.max(20, ZipCompressionType.DEFLATE.extractVersion());
	
	/**
	 * This initializes the stream for writing ZIP file data.
	 *
	 * @param __os The output stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/09
	 */
	public ZipStreamWriter(OutputStream __os)
		throws NullPointerException
	{
		// Check
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Create stream
		ExtendedDataOutputStream output;
		this.output = (output = new ExtendedDataOutputStream(__os));
		
		// Use little endian data by default
		output.setEndianess(DataEndianess.LITTLE);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/07/09
	 */
	@Override
	public void close()
		throws IOException
	{
		// Do nothing if already closed
		if (this._closed)
			return;
		
		// {@squirreljme.error BF16 Cannot close the ZIP writer because
		// an entry is still being written.}
		if (this._inner != null || this._outer != null)
			throw new IOException("BF16");
		
		// Mark closed to prevent failing closes from writing multiple
		// times
		this._closed = true;
		
		// Get output and the TOC entries
		ExtendedDataOutputStream output = this.output;
		LinkedList<__TOCEntry__> toc = this._toc;
		int numtoc = toc.size();
		
		// The position where the central directory starts
		long cdstart = output.size();
		
		// The current time all entries will use for their date
		// 0bhhhhh_mmmmmm_sssss
		// 0byyyyyy_mmmm_ddddd
		todo.TODO.note("Implement correct timestamp.");
		int time = 0b01111_011110_00000,
			date = 0b100110_0011_01000;
		
		// Write all entries
		int bestversion = this._bestversion;
		for (__TOCEntry__ entry : toc)
		{
			// The entry position
			long epos = output.size();
			
			if (epos > _MAX_FILE_SIZE)
				throw new IOException();
			
			// Write directory header
			output.writeInt(_CENTRAL_DIRECTORY_MAGIC_NUMBER);
			
			// The created by version (use the highest version)
			output.writeShort(bestversion);
			
			// Version needed to extract
			ZipCompressionType ecomp = entry._compression;
			output.writeShort(ecomp.extractVersion());
			
			// General purpose flags
			output.writeShort(_GENERAL_PURPOSE_FLAGS);
			
			// Compression method
			output.writeShort(ecomp.method());
			
			// Date/time ZIP was created (closed)
			output.writeShort(time);
			output.writeShort(date);
			
			// CRC and sizes
			output.writeInt(entry._crc);
			output.writeInt((int)entry._compressed);
			output.writeInt((int)entry._uncompressed);
			
			// Write name length
			byte[] efn = entry._name;
			output.writeShort(efn.length);
			
			// No extra data
			output.writeShort(0);
			
			// No comment
			output.writeShort(0);
			
			// Always the first disk
			output.writeShort(0);
			
			// No iternal or external attributes
			output.writeShort(0);
			output.writeInt(0);
			
			// Relative offset to local header
			output.writeInt((int)entry._localposition);
			
			// Write file name
			output.write(efn);
		}
		
		// The position where it ends
		long cdend = output.size();
		
		// Write magic number
		output.writeInt(_END_DIRECTORY_MAGIC_NUMBER);
		
		// Only a single disk is written
		output.writeShort(0);
		output.writeShort(0);
		
		// Number of entries on this disk and in all of them
		output.writeShort(numtoc);
		output.writeShort(numtoc);
		
		// The size of the central directory
		output.writeInt((int)(cdend - cdstart));
		
		// Offset to the central directory
		output.writeInt((int)cdstart);
		
		// No comment
		output.writeShort(0);
	}
	
	/**
	 * Flushes the output.
	 *
	 * @throws IOException If it could not be flushed.
	 * @since 2016/07/09
	 */
	public void flush()
		throws IOException
	{
		this.output.flush();
	}
	
	/**
	 * Starts writing a new entry in the output ZIP using the default
	 * compression.
	 *
	 * @param __name The name of the entry.
	 * @return An {@link OutputStream} which is used to write the ZIP file
	 * data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public OutputStream nextEntry(String __name)
		throws IOException, NullPointerException
	{
		return nextEntry(__name, ZipCompressionType.DEFAULT_COMPRESSION);
	}
	
	/**
	 * Starts writing a new entry in the output ZIP.
	 *
	 * @param __name The name of the entry.
	 * @param __comp The compression method used.
	 * @return An {@link OutputStream} which is used to write the ZIP file
	 * data.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	public OutputStream nextEntry(String __name, ZipCompressionType __comp)
		throws IOException, NullPointerException
	{
		// Check
		if (__name == null || __comp == null)
			throw new NullPointerException("NARG");
		
		// Lock
		LinkedList<__TOCEntry__> toc = this._toc;
		
		// {@squirreljme.error BF17 Cannot write new entry because the ZIP
		// has been closed.}
		if (this._closed)
			throw new IOException("BF17");
		
		// {@squirreljme.error BF18 Cannot create a new entry for output
		// because the previous entry has not be closed.}
		if (this._inner != null || this._outer != null)
			throw new IOException("BF18");
		
		// {@squirreljme.error BF19 A ZIP file cannot have more than
		// 65536 entries.}
		if (toc.size() >= 65535)
			throw new IOException("BF19");
		
		// {@squirreljme.error BF1a The length of the input file exceeds
		// 65535 UTF-8 characters. (The filename length)}
		byte[] utfname = __name.getBytes("utf-8");
		int fnn;
		if ((fnn = utfname.length) > 65535)
			throw new IOException(String.format("BF1a %d", fnn));
		
		// Setup contents
		__TOCEntry__ last = new __TOCEntry__(this.output.size(), utfname,
			__comp);
		toc.addLast(last);
		
		// Write ZIP header data
		ExtendedDataOutputStream output = this.output;
		output.writeInt(_LOCAL_FILE_MAGIC_NUMBER);
		
		// Extract version
		output.writeShort(__comp.extractVersion());
		
		// General purpose flag
		output.writeShort(_GENERAL_PURPOSE_FLAGS);
		
		// Method
		output.writeShort(__comp.method());
		
		// Modification date/time
		output.writeShort(0);
		output.writeShort(0);
		
		// CRC-32 and compress/uncompressed size are unknown
		output.writeInt(0);
		output.writeInt(0);
		output.writeInt(0);
		
		// Write file name bytes
		output.writeShort(fnn);
		
		// No extra field
		output.writeShort(0);
		
		// Write file name
		output.write(utfname);
		
		// Setup inner stream (for compressed size)
		__InnerOutputStream__ inner = new __InnerOutputStream__();
		
		// Wrap inner with the compression algorithm
		OutputStream wrapped = __comp.outputStream(inner);
		
		// Wrap that with the outer stream (uncompressed size)
		__OuterOutputStream__ outer = new __OuterOutputStream__(wrapped);
		
		// Set
		this._inner = inner;
		this._outer = outer;
		
		// Return the outer stream
		return outer;
	}
	
	/**
	 * Closes the current entry.
	 *
	 * @throws IOException If it could not be closed.
	 * @since 2016/07/15
	 */
	private void __closeEntry()
		throws IOException
	{
		// Lock
		LinkedList<__TOCEntry__> toc = this._toc;
		
		__InnerOutputStream__ inner = this._inner;
		__OuterOutputStream__ outer = this._outer;
		
		// {@squirreljme.error BF1b Cannot close entry because a current
		// one is not being used.}
		if (inner == null || outer == null)
			throw new IOException("BF1b");
		
		// Flush both sides
		inner.flush();
		outer.flush();
		
		// Need to fill the size information and CRC for later
		__TOCEntry__ last = toc.getLast();
		
		// Get sizes
		long uncomp = outer._size;
		long comp = inner._size;
		
		// {@squirreljme.error BF1c Either one or both of the compressed
		// or uncompressed file sizes exceeds 4GiB. (The uncompressed size;
		// The compressed size)}
		if (uncomp >= _MAX_FILE_SIZE || comp >= _MAX_FILE_SIZE)
			throw new IOException(String.format("BF1c %d %d", uncomp,
				comp));
		
		// Store sizes
		last._uncompressed = uncomp;
		last._compressed = comp;
		
		// Determine CRC
		int crc = outer.crccalc.checksum();
		last._crc = crc;
		
		// The magic number of the data descriptor is not needed, however
		// it helps prevent some abiguity when the input data stream is
		// not compressed and contains a ZIP file.
		ExtendedDataOutputStream output = this.output;
		output.writeInt(_DATA_DESCRIPTOR_MAGIC_NUMBER);
		
		// Write CRC and sizes
		output.writeInt((int)crc);
		output.writeInt((int)comp);
		output.writeInt((int)uncomp);
		
		// Clear streams to allow for next entry
		this._inner = null;
		this._outer = null;
	}
	
	/**
	 * The inner and outer streams are very similar.
	 *
	 * @since 2016/07/15
	 */
	private abstract class __BaseOutputStream__
		extends OutputStream
	{
		/** The wrapped stream. */
		protected final OutputStream wrapped;
		
		/** Is the outer side finished? */
		protected boolean finished;
		
		/** The decompressed size. */
		volatile int _size;
		
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @param __os The output stream to wrap.
		 * @throws NullPointerException On null arguments.
		 * @since 2016/07/15
		 */
		private __BaseOutputStream__(OutputStream __os)
			throws NullPointerException
		{
			// Check
			if (__os == null)
				throw new NullPointerException("NARG");
			
			// Set
			this.wrapped = __os;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public abstract void close()
			throws IOException;
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void flush()
			throws IOException
		{
			// Ignore if finished since the streams should be disconnected
			// at this time
			if (this.finished)
				return;
			
			// Forward flush
			this.wrapped.flush();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void write(int __b)
			throws IOException
		{
			// {@squirreljme.error BF1d Cannot write a single byte because
			// the stream is closed.}
			if (this.finished)
				throw new IOException("BF1d");
			
			// {@squirreljme.error BF1e Cannot write a single byte because
			// the ZIP entry would exceed 4GiB.}
			int oldsize = this._size, newsize = oldsize + 1;
			if (newsize < 0 || newsize < oldsize)
				throw new IOException("BF1e");
			
			// Write data and increase size
			this.wrapped.write(__b);
			this._size = newsize;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			// Check
			if (__b == null)
				throw new NullPointerException("NARG");
			int n = __b.length;
			if (__o < 0 || __l < 0 || (__o + __l) > n)
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BF1f Cannot write multiple bytes because
			// the stream is closed.}
			if (this.finished)
				throw new IOException("BF1f");
			
			// {@squirreljme.error BF1g Cannot write multiple bytes because
			// the ZIP entry would exceed 4GiB.}
			int oldsize = this._size, newsize = oldsize + __l;
			if (newsize < 0 || newsize < oldsize)
				throw new IOException("BF1g");
			
			// Write data and increase size
			this.wrapped.write(__b, __o, __l);
			this._size = newsize;
		}
	}
	
	/**
	 * This is an output stream which is used when writing an entry.
	 *
	 * @since 2016/07/15
	 */
	private final class __InnerOutputStream__
		extends __BaseOutputStream__
	{
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @since 2016/07/15
		 */
		private __InnerOutputStream__()
		{
			super(ZipStreamWriter.this.output);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public final void close()
			throws IOException
		{
			// Ignore if already finished
			if (this.finished)
				return;
			
			// Close and finish
			this.finished = true;
			ZipStreamWriter.this.__closeEntry();
		}
	}
	
	/**
	 * This is an output stream which is used when writing an entry.
	 *
	 * @since 2016/07/15
	 */
	private final class __OuterOutputStream__
		extends __BaseOutputStream__
	{
		/** CRC calculation. */
		protected final CRC32Calculator crccalc =
			new CRC32Calculator(ZipCRCConstants.CRC_REFLECT_DATA,
				ZipCRCConstants.CRC_REFLECT_REMAINDER,
				ZipCRCConstants.CRC_POLYNOMIAL, ZipCRCConstants.CRC_REMAINDER,
				ZipCRCConstants.CRC_FINALXOR);
		
		/**
		 * Initializes a new output stream for writing an entry.
		 *
		 * @param __os The output stream to wrap.
		 * @since 2016/07/15
		 */
		private __OuterOutputStream__(OutputStream __os)
		{
			super(__os);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public final void close()
			throws IOException
		{
			// Ignore if already finished
			if (this.finished)
				return;
			
			// Close the wrapped stream
			this.finished = true;
			this.wrapped.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/15
		 */
		@Override
		public void flush()
			throws IOException
		{
			super.flush();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/16
		 */
		@Override
		public void write(int __b)
			throws IOException
		{
			// Send to output
			super.write(__b);
			
			// Calculate CRC
			this.crccalc.offer((byte)__b);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2016/07/16
		 */
		@Override
		public void write(byte[] __b, int __o, int __l)
			throws IndexOutOfBoundsException, IOException, NullPointerException
		{
			// Send to output
			super.write(__b, __o, __l);
			
			// Calculate CRC
			this.crccalc.offer(__b, __o, __l);
		}
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/streamwriter/__TOCEntry__.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.zip.streamwriter;

import net.multiphasicapps.zip.ZipCompressionType;

/**
 * This is used to store the temporary information which is used to later
 * write the central directory.
 *
 * @since 2016/07/15
 */
class __TOCEntry__
{
	/** The local file position. */
	final long _localposition;
	
	/** The name of the entry. */
	final byte[] _name;
	
	/** The compression type. */
	final ZipCompressionType _compression;
	
	/** The uncompressed size. */
	volatile long _uncompressed;
	
	/** The compressed size. */
	volatile long _compressed;
	
	/** The CRC32 of the entry. */
	volatile int _crc;
	
	/**
	 * Initializes the table of contents entry.
	 *
	 * @param __lfp The local file position.
	 * @param __name The file name.
	 * @param __comp The compression used.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/07/15
	 */
	__TOCEntry__(long __lfp, byte[] __name, ZipCompressionType __comp)
		throws NullPointerException
	{
		// Check
		if (__name == null || __comp == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._localposition = __lfp;
		this._name = __name;
		this._compression = __comp;
	}
}

Deleted runt/libs/zip/net/multiphasicapps/zip/streamwriter/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes which are used to write to ZIP files in a
 * stream based fashion. Entries are written one at a time and are directly
 * placed in the output stream. When the ZIP is closed the final index is
 * written.
 *
 * @since 2016/07/09
 */

package net.multiphasicapps.zip.streamwriter;

Deleted runt/mids/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Run-time MIDlets
X-SquirrelJME-Namespace-Type: midlet
X-SquirrelJME-Namespace-Description: This contains programs which may be 
 run by the user and are potentially by default provided by SquirrelJME.

Deleted runt/mids/demo-hello/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 076215a5-723a-482e-89e9-08c60ef7f1cb
X-SquirrelJME-Error: BT
X-SquirrelJME-Name: Hello (Demo)
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This is a basic demo which prints a hello 
 message and prints some details about the virtual machine.
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: net.multiphasicapps.demo.hello.Hello

Deleted runt/mids/demo-hello/net/multiphasicapps/demo/hello/Hello.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
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































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.demo.hello;

import java.io.PrintStream;

/**
 * Prints a hello message along with information about the virtual machine.
 *
 * @since 2018/09/22
 */
public class Hello
{
	/** Properties to print. */
	private static final String[] _PROPERTIES =
		new String[]
		{
			"java.version",
			"java.vendor",
			"java.vendor.email",
			"java.vendor.url",
			"java.vm.name",
			"java.vm.version",
			"cc.squirreljme.apilevel",
			"java.vm.vendor",
			"java.vm.vendor.email",
			"java.vm.vendor.url",
			"java.runtime.name",
			"java.runtime.version",
			"os.name",
			"os.arch",
			"os.version",
			"microedition.encoding",
			"microedition.configuration",
			"microedition.locale",
			"microedition.profiles",
			"cc.squirreljme.vm.execpath",
			"cc.squirreljme.vm.freemem",
			"cc.squirreljme.vm.totalmem",
			"cc.squirreljme.vm.maxmem",
		};
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/09/22
	 */
	public static final void main(String... __args)
	{
		PrintStream out = System.out;
		
		// Print input message if used
		int an;
		if (__args != null && (an = __args.length) > 0)
		{
			for (int i = 0; i < an; i++)
			{
				// Add space for nicer formatting
				if (i > 0)
					out.print(' ');
				
				out.print(__args[i]);
			}
			
			// Make it nice
			out.println();
		}
		
		// Just a basic message
		else
			out.println("Hello! Squirrels are so cute!");
		
		// Print some information about the virtual machine itself
		for (String p : Hello._PROPERTIES)
		{
			String v = System.getProperty(p);
			if (v != null)
			{
				out.print(p);
				out.print(": ");
				out.println(v);
			}
		}
	}
}

Deleted runt/mids/demo-hello/net/multiphasicapps/demo/hello/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the hello program.
 *
 * @since 2018/09/22
 */

package net.multiphasicapps.demo.hello;

Deleted runt/mids/lcdui-demo/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 63e1de74-9cde-45e4-878c-ce335f0288db
X-SquirrelJME-Error: AW
X-SquirrelJME-Name: LCDUI Graphics Demo
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This is a demo which is used to demonstrate 
 how the graphic operations operate.
X-SquirrelJME-Depends: midp-lcdui
Microedition-Configuration: CLDC-1.8-Compact
MIDlet-1: Font Demo, fonts.xpm, net.multiphasicapps.lcduidemo.Fonts
MIDlet-2: Mystify Your Squirrels!, mystify.xpm, 
 net.multiphasicapps.lcduidemo.Mystify
MIDlet-3: Events Demo, event.xpm, 
 net.multiphasicapps.lcduidemo.Events
MIDlet-4: List Demo, list.xpm, 
 net.multiphasicapps.lcduidemo.Lists
MIDlet-5: Image Demo (XPM), image.xpm, 
 net.multiphasicapps.lcduidemo.XPMDemo
MIDlet-6: Image Demo (PNG), image.xpm, 
 net.multiphasicapps.lcduidemo.PNGDemo
MIDlet-7: Image Demo (JPEG), image.xpm, 
 net.multiphasicapps.lcduidemo.JPEGDemo

Deleted runt/mids/lcdui-demo/event.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\event_xpm[] = {
"16 16 5 1",
" 	c #FFFFFF",
".	c #000000",
"+	c #FF0000",
"@	c #00FF00",
"#	c #0000FF",
"                ",
"   .....        ",
"   .+++.        ",
"   .+++.        ",
"   .....        ",
"     .          ",
"     .          ",
"  ........      ",
"  .      .      ",
"  .      .      ",
"  .      .      ",
" ....   ...     ",
" .@@.  .###.    ",
" .@@.  .###.    ",
" ....   ...     ",
"                "};

Deleted runt/mids/lcdui-demo/fonts.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\fonts_xpm[] = {
"16 16 2 1",
" 	c #FFFFFF",
".	c #000000",
"                ",
"    .. .....    ",
"   . .  .   .   ",
"  .  .  .   .   ",
"  ....  ....    ",
"  .  .  .   .   ",
"  .  .  .   .   ",
" ..  . .....    ",
"                ",
"                ",
"   .  ..   ..   ",
"  . . . . .     ",
"  ... ..  .     ",
"  . . . . .     ",
"  . . ..   ..   ",
"                "};

Deleted runt/mids/lcdui-demo/image.xpm.

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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\image_xpm[] = {
"16 16 7 1",
" 	c #FFFFFF",
".	c #000000",
"+	c #2ED2D5",
"@	c #FFE142",
"#	c #6FB642",
"$	c #5F2616",
"%	c #00BB00",
"                ",
"                ",
" .............. ",
" .++++++++@++@. ",
" .+++++++++@@+. ",
" .+++###+++@@+. ",
" .++#####+@++@. ",
" .+++###++++++. ",
" .++++$+++++++. ",
" .++++$+++++++. ",
" .++++$+++++++. ",
" .%%%%%%%%%%%%. ",
" .%%%%%%%%%%%%. ",
" .............. ",
"                ",
"                "};

Deleted runt/mids/lcdui-demo/list.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\list_xpm[] = {
"16 16 2 1",
" 	c #FFFFFF",
".	c #000000",
"                ",
"                ",
" .. ..........  ",
" .. ..........  ",
"                ",
" .. ....        ",
" .. ....        ",
"                ",
" .. ......      ",
" .. ......      ",
"                ",
" .. ..          ",
" .. ..          ",
"                ",
"                ",
"                "};

Deleted runt/mids/lcdui-demo/mystify.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * L:\home\stephanie\squirreljme\runt\mids\lcdui_demo\mystify_xpm[] = {
"16 16 4 1",
" 	c #FFFFFF",
".	c #00C0C4",
"+	c #00C484",
"@	c #00C400",
"         .      ",
"        . .     ",
"       .   .    ",
"    ++.++++ ..  ",
"   + .     + ...",
"  +.. @@@@@+   .",
"  .  @    + @ . ",
" .  @     + @.  ",
".+ @      + .   ",
"+.@      +  .   ",
"+@.     +  .@   ",
" +@.    +  .@   ",
"  +@... +  .@   ",
"   +@  .   .@   ",
"    +@+@.@.@@   ",
"     ++  .      "};

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/AbstractImageDemo.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
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






































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.lcduidemo;

import java.io.InputStream;
import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is the base for image demos.
 *
 * @since 2019/04/15
 */
public abstract class AbstractImageDemo
	extends MIDlet
{
	/** No mirrors. */
	private static final int[] _NO_MIRROR =
		new int[]{Sprite.TRANS_NONE, Sprite.TRANS_ROT90,
			Sprite.TRANS_ROT180, Sprite.TRANS_ROT270};
			
	/** Mirrors. */
	private static final int[] _MIRROR =
		new int[]{Sprite.TRANS_MIRROR, Sprite.TRANS_MIRROR_ROT90,
			Sprite.TRANS_MIRROR_ROT180, Sprite.TRANS_MIRROR_ROT270};
	
	/** The image to use. */
	protected final Image image;
	
	/**
	 * Initializes the image demo.
	 *
	 * @param __in Input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/15
	 */
	public AbstractImageDemo(InputStream __in)
		throws NullPointerException
	{
		// Load image data
		try
		{
			this.image = Image.createImage(__in);
		}
		
		// Fail
		catch (IOException e)
		{
			throw new RuntimeException(e);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/04/15
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas(this.image);
		cv.setTitle("Image Demo");
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * The demo canvas which does the drawing.
	 *
	 * @since 2019/04/15
	 */
	static public final class DemoCanvas
		extends Canvas
	{
		/** The image to draw. */
		protected final Image image;
		
		/**
		 * Initializes the demo canvas.
		 *
		 * @param __i The image to use.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/04/15
		 */
		public DemoCanvas(Image __i)
			throws NullPointerException
		{
			if (__i == null)
				throw new NullPointerException("NARG");
			
			this.image = __i;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/22
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Get image
			Image image = this.image;
			int w = image.getWidth(),
				h = image.getHeight();
			
			// Base Y position
			int basey = 0;
			
			// Draw portions of the image
			for (int i = 0; i < 4; i++)
			{
				// Determine x and y offset
				int xoff = (((i & 0b01) == 0) ? 0 : w >>> 1),
					yoff = (((i & 0b10) == 0) ? 0 : h >>> 1);
				
				// Source X and Y dimensions
				int sx = xoff,
					sy = yoff,
					sw = w - xoff,
					sh = h - yoff;
				
				// Non-mirrored rotations
				for (int j = 0; j < _NO_MIRROR.length; j++)
					__g.drawRegion(image, sx, sy, sw, sh, _NO_MIRROR[j],
						(w * j), basey, 0);
				basey += h;
					
				// Mirrored rotations
				for (int j = 0; j < _MIRROR.length; j++)
					__g.drawRegion(image, sx, sy, sw, sh, _MIRROR[j],
						(w * j), basey, 0);
				basey += h;
			}
		}
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/Events.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This example project handles events and allows for some interaction based
 * on buttons and such.
 *
 * @since 2018/12/01
 */
public class Events
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/01
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * Converts the game code to a string.
	 *
	 * @param __gc The game code.
	 * @return The string for this game code.
	 * @since 2018/12/02
	 */
	static final String __gamecodeToString(int __gc)
	{
		switch (__gc)
		{
			case 0:					return "Unknown";
			
			case Canvas.UP:			return "Up";
			case Canvas.DOWN:		return "Down";
			case Canvas.LEFT:		return "Left";
			case Canvas.RIGHT:		return "Right";
			
			case Canvas.FIRE:		return "Fire";
			
			case Canvas.GAME_A:		return "A";
			case Canvas.GAME_B:		return "B";
			case Canvas.GAME_C:		return "C";
			case Canvas.GAME_D:		return "D";
			
			default:				return "Invalid";
		}
	}
	
	/**
	 * The demo canvas which does the event handling and other things.
	 *
	 * @since 2018/12/01
	 */
	static public final class DemoCanvas
		extends Canvas
	{
		/** The number of times this was shown. */
		volatile int _numshown;
		
		/** The number of times this was hidden. */
		volatile int _numhides;
		
		/** Pointer position. */
		volatile int _pointerx,
			_pointery;
		
		/** Pointer event type. */
		volatile PointerType _pointertype;
		
		/** The number of key events which happened. */
		volatile int _numkeys;
		
		/** The last key event. */
		volatile int _keycode;
		
		/** The last key done. */
		volatile KeyboardType _keyboardtype;
		
		/**
		 * Initializes the canvas.
		 *
		 * @since 2018/12/01
		 */
		{
			// Setup title
			this.setTitle("Events");
			
			// Draw as opaque, so we do not need to update everything
			this.setPaintMode(false);
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void hideNotify()
		{
			this._numhides++;
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyPressed(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.PRESSED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Pressed: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyReleased(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.RELEASED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Released: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
			
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void keyRepeated(int __code)
		{
			this._keycode = __code;
			this._keyboardtype = KeyboardType.REPEATED;
			this._numkeys++;
			
			// Report event
			System.err.printf("Key Repeated: %d%n", __code);
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void paint(Graphics __g)
		{
			Font font = __g.getFont();
			int height = font.getHeight(),
				x = 2,
				y = 2 - height,
				keycode = this._keycode,
				gamecode = -1;
			
			// Get the key name, but it might not even be valid
			String keyname = null;
			try
			{
				keyname = this.getKeyName(keycode);
				gamecode = this.getGameAction(keycode);
			}
			catch (IllegalArgumentException e)
			{
			}
			
			// Draw text info
			__g.drawString(String.format("Showns: %d", this._numshown),
				x, y += height, 0);
			__g.drawString(String.format("Hides: %d", this._numhides),
				x, y += height, 0);
			__g.drawString(String.format("Pointer: (%d, %d) %s",
				this._pointerx, this._pointery, this._pointertype),
				x, y += height, 0);
			__g.drawString(String.format(
				"Key: \"%s\" (Code=%d Game=%s) %s [Count=%d]",
				keyname, keycode, Events.__gamecodeToString(gamecode),
				this._keyboardtype, this._numkeys),
				x, y += height, 0);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerDragged(int __x, int __y)
		{
			this._pointertype = PointerType.DRAGGED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerPressed(int __x, int __y)
		{
			this._pointertype = PointerType.PRESSED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void pointerReleased(int __x, int __y)
		{
			this._pointertype = PointerType.RELEASED;
			this._pointerx = __x;
			this._pointery = __y;
			
			// Repaint to update stuff
			this.repaint();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/12/01
		 */
		@Override
		public void showNotify()
		{
			this._numshown++;
			
			// Repaint to update stuff
			this.repaint();
		}
	}
	
	/**
	 * The type of keyboard event which happened.
	 *
	 * @since 2018/12/01
	 */
	static public enum KeyboardType
	{
		/** Pressed. */
		PRESSED,
		
		/** Released. */
		RELEASED,
		
		/** Repeated. */
		REPEATED,
		
		/** End. */
		;
	}
	
	/**
	 * The type of pointer event which happened.
	 *
	 * @since 2018/12/01
	 */
	static public enum PointerType
	{
		/** Pressed. */
		PRESSED,
		
		/** Released. */
		RELEASED,
		
		/** Dragged. */
		DRAGGED,
		
		/** End. */
		;
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/Exit.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * This is an exit command which terminates the application.
 *
 * @since 2018/12/02
 */
public class Exit
	implements CommandListener
{
	/** The command used to exit. */
	public static final Command command =
		new Command("Exit", Command.EXIT, 1);
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	public final void commandAction(Command __c, Displayable __d)
	{
		// Exiting the VM?
		if (__c == Exit.command)
		{
			System.exit(0);
		}
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/Fonts.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
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








































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import java.util.ArrayList;
import java.util.List;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Font demo, this essentially just draws the fonts which are available.
 *
 * @since 2018/11/23
 */
public class Fonts
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/11/23
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/23
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
	}
	
	/**
	 * The demo canvas which does the animation.
	 *
	 * @since 2018/11/23
	 */
	static public final class DemoCanvas
		extends Canvas
	{
		/** Fonts to use. */
		private final Font[] _fonts;
		
		/**
		 * Initializes the canvas.
		 *
		 * @since 2018/11/23
		 */
		{
			this.setTitle("Font Demo");
			
			// Draw as transparent
			this.setPaintMode(false);
			
			// Try to get fonts of various pixel sizes
			List<Font> fonts = new ArrayList<>();
			for (Font f : Font.getAvailableFonts())
				for (int i = 4; i <= 36; i += 4)
					try
					{
						fonts.add(f.deriveFont(i));
					}
					catch (IllegalArgumentException e)
					{
					}
			
			// Set font list
			this._fonts = fonts.<Font>toArray(new Font[fonts.size()]);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/23
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Start position
			int x = 10,
				y = 10;
			
			// Draw a sample for each font, for each size!
			for (Font f : this._fonts)
			{
				// Use this font
				__g.setFont(f);
				
				// Yes I do know buried is spelt wrong, but this is staying
				// here because a transphobe troll searched through all of my
				// images on Twitter and chose to insult me here. So this is
				// here to spite them.
				__g.drawString("The quick gray squirrel Xer burried all of " +
					"her acorns! <3 0123456789",
					x, y, Graphics.BASELINE);
				
				// Move position up
				y += f.getHeight();
				
				// Draw sample
				__g.drawString("abcdefghijklmnopqrstuvwxyz " +
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ 01234567890!@#$%^&*()",
					x, y, Graphics.BASELINE);
					
				// Move position with some more room
				y += f.getHeight() + 3;
			}
		}
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/JPEGDemo.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 net.multiphasicapps.lcduidemo;


/**
 * This is the JPEG demo.
 *
 * @since 2019/05/05
 */
public final class JPEGDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/05/05
	 */
	public JPEGDemo()
	{
		super(JPEGDemo.class.getResourceAsStream("image.jpg"));
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/Lists.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
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










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is a demo for lists.
 *
 * @since 2018/12/02
 */
public class Lists
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/12/02
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup list
		List list = new List("List Demo", List.MULTIPLE);
		
		// Exit command
		list.addCommand(Exit.command);
		list.setCommandListener(new Exit());
		
		// Add things to the list
		list.append("Sciurus aberti", null);
		list.append("Sciurus aestuans", null);
		list.append("Sciurus alleni", null);
		list.append("Sciurus anomalus", null);
		list.append("Sciurus arizonensis", null);
		list.append("Sciurus aureogaster", null);
		list.append("Sciurus carolinensis", null);
		list.append("Sciurus colliaei", null);
		list.append("Sciurus deppei", null);
		list.append("Sciurus flammifer", null);
		list.append("Sciurus gilvigularis", null);
		list.append("Sciurus granatensis", null);
		list.append("Sciurus griseus", null);
		list.append("Sciurus ignitus", null);
		list.append("Sciurus igniventris", null);
		list.append("Sciurus kaibabensis", null);
		list.append("Sciurus lis", null);
		list.append("Sciurus nayaritensis", null);
		list.append("Sciurus niger", null);
		list.append("Sciurus oculatus", null);
		list.append("Sciurus pucheranii", null);
		list.append("Sciurus pyrrhinus", null);
		list.append("Sciurus richmondi", null);
		list.append("Sciurus sanborni", null);
		list.append("Sciurus spadiceus", null);
		list.append("Sciurus stramineus", null);
		list.append("Sciurus variegatoides", null);
		list.append("Sciurus vulgaris", null);
		list.append("Sciurus yucatanensis", null);
		
		// Use a certain font for some items
		list.setFont(2,
			Font.getFont(Font.FACE_SYSTEM, 0, Font.SIZE_SMALL));
		list.setFont(4,
			Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_MEDIUM));
		list.setFont(6,
			Font.getFont(Font.FACE_PROPORTIONAL, 0, Font.SIZE_MEDIUM));
		list.setFont(8,
			Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_SMALL));
		
		// Select some items for us
		list.setSelectedIndex(1, true);
		list.setSelectedIndex(6, true);
		list.setSelectedIndex(12, true);
		
		// Disable some items
		list.setEnabled(8, false);
		list.setEnabled(12, false);
		
		// Display the list
		Display.getDisplay(this).setCurrent(list);
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/Mystify.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439























































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import java.util.Random;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * This is a MIDlet which simulates the old-style Mystify Your Mind
 * screensaver from Windows 3.1.
 *
 * @since 2018/11/22
 */
public class Mystify
	extends MIDlet
{
	/** The number of polygon points. */
	public static final int NUM_POINTS =
		5;
	
	/** The number of shadows to draw. */
	public static final int NUM_SHADOWS =
		7;
	
	/** The maximum line speed. */
	public static final int MAX_SPEED =
		9;
	
	/** Use to detect way off coordinates. */
	public static final int WAY_OFF =
		50;
	
	/** How oftens the colors shift. */
	public static final int COLOR_SHIFT =
		2;
	
	/** The delay time. */
	public static final int DELAY_TIME =
		250;
	
	/** Delay time in nanoseconds. */
	public static final long DELAY_TIME_NS =
		DELAY_TIME * 1_000_000L;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Setup canvas
		DemoCanvas cv = new DemoCanvas();
		
		// Exit command
		cv.addCommand(Exit.command);
		cv.setCommandListener(new Exit());
		
		// Set display to the canvas
		Display.getDisplay(this).setCurrent(cv);
		
		// Setup thread to force repaints on canvas
		new RepaintTimer(cv, DELAY_TIME).start();
	}
	
	/**
	 * The demo canvas which does the animation.
	 *
	 * @since 2018/11/22
	 */
	static public final class DemoCanvas
		extends Canvas
	{
		/** Random number generator for bounces and such. */
		protected final Random random =
			new Random();
		
		/** Points and their shadows. */
		protected final Point[][] points =
			new Point[NUM_SHADOWS][NUM_POINTS];
		
		/** Colors. */
		protected final int[] colors =
			new int[NUM_SHADOWS];
		
		/** The direction of the points. */
		protected final Point[] direction =
			new Point[NUM_POINTS];
		
		/** Update lock to prevent multiple threads updating at once. */
		private volatile boolean _lockflag;
		
		/** The last time an update happened. */
		private volatile long _nextnano =
			Long.MIN_VALUE;
		
		/**
		 * Initializes the canvas state.
		 *
		 * @since 2018/11/22
		 */
		{
			// Setup title
			this.setTitle("Mystify Your Squirrels");
			
			// Draw as transparent
			this.setPaintMode(false);
			
			// Setup points
			Point[][] points = this.points;
			
			// Generate random start points
			Random random = this.random;
			Point[] start = points[0];
			for (int i = 0; i < NUM_POINTS; i++)
				start[i] = new Point(random.nextInt(), random.nextInt());
			
			// Copy all the points to the shadow
			for (int i = 1; i < NUM_SHADOWS; i++)
				for (int j = 0; j < NUM_POINTS; j++)
					points[i][j] = new Point(start[j]);
			
			// Initialize the color cycle
			int[] colors = this.colors;
			for (int i = 0; i < NUM_SHADOWS; i++)
				colors[i] = random.nextInt();
			
			// Determine new directions for all the points
			Point[] direction = this.direction;
			for (int i = 0; i < NUM_POINTS; i++)
				direction[i] = this.__newDirection(new Point(),
					random.nextBoolean(), random.nextBoolean());
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/22
		 */
		@Override
		public void paint(Graphics __g)
		{
			// Get widget bounds
			int w = this.getWidth(),
				h = this.getHeight();
			
			// Needed for cycling	
			Random random = this.random;
			
			// Needed for drawing
			Point[][] points = this.points;
			Point[] direction = this.direction;
			int[] colors = this.colors;
			
			// Used to limit update rate
			long now = System.nanoTime(),
				nextnano = this._nextnano;
			
			// Draw every point, from older shadows to the newer shape
			for (int i = NUM_SHADOWS - 1; i >= 0; i--)
			{
				Point[] draw = points[i];
				
				// Update the state of the demo, but keep it consistent so
				// that it is not always updating
				if (i == 0 && now >= nextnano)
				{
					// Only allow a single run to update this
					boolean lockflag;
					synchronized (this)
					{
						// Set the lock flag
						lockflag = this._lockflag;
						if (!lockflag)
							this._lockflag = true;
					}
					
					// If we did hit a false, we can update
					if (!lockflag)
						try
						{
							// Update the state
							this.__updateState(w, h);
						}
						finally
						{
							// Always clear the flag so another run can
							// have a go
							this._lockflag = false;
							
							// Update some other time in the future
							this._nextnano = System.nanoTime() + DELAY_TIME_NS;
						}
				}
				
				// Set the color for this shadow
				__g.setColor(colors[i]);
				
				// Draw all the points
				for (int j = 0; j < NUM_POINTS; j++)
				{
					// Get A and B points
					Point a = draw[j],
						b = draw[(j + 1) % NUM_POINTS];
					
					// Draw line
					__g.drawLine(a.x, a.y, b.x, b.y);
				}
			}
		}
		
		/**
		 * Gives a new direction for the point.
		 *
		 * @param __p The input point to get a new direction for.
		 * @param __px Positive X?
		 * @param __py Positive Y?
		 * @return {@code __p}
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/22
		 */
		private Point __newDirection(Point __p, boolean __px, boolean __py)
			throws NullPointerException
		{
			if (__p == null)
				throw new NullPointerException("NARG");
			
			// Generate new speeds
			Random random = this.random;
			int x = random.nextInt(MAX_SPEED) + 1,
				y = random.nextInt(MAX_SPEED) + 1;
			
			// Flip signs?
			if (!__px)
				x = -x;
			if (!__py)
				y = -y;
			
			// set
			__p.x = x;
			__p.y = y;
			
			// Use that point
			return __p;
		}
		
		/**
		 * Updates the state of the demo.
		 *
		 * @param __w The width.
		 * @param __h The height.
		 * @since 2018/11/22
		 */
		private void __updateState(int __w, int __h)
		{
			// Needed for cycling	
			Random random = this.random;
			
			// Base points to modify
			Point[] draw = points[0];
			
			// Needed for drawing
			Point[][] points = this.points;
			Point[] direction = this.direction;
			int[] colors = this.colors;
			
			// Move all the old points and colors down
			for (int j = NUM_SHADOWS - 2; j >= 0; j--)
			{
				points[j + 1] = points[j];
				colors[j + 1] = colors[j];
			}
			
			// Allocate a new set of points offset in the directions
			Point[] place = new Point[NUM_POINTS];
			for (int j = 0; j < NUM_POINTS; j++)
			{
				// Get base coordinates
				int newx = draw[j].x,
					newy = draw[j].y;
				
				// Limit to the bounds of the screen. If a point is
				// way off, just choose a random point on the
				// screen instead
				if (newx < 0 || newx >= __w)
				{
					if (newx < -WAY_OFF || newy > __w + WAY_OFF)
						newx = random.nextInt((__w > 0 ? __w : 1));
					else
					{
						if (newx < 0)
							newx = 0;
						else if (newx >= __w)
							newx = __w;
					}
				}
				
				if (newy < 0 || newy >= __h)
				{
					if (newy < -WAY_OFF || newy > __h + WAY_OFF)
						newy = random.nextInt((__h > 0 ? __h : 1));
					else
					{
						if (newy < 0)
							newy = 0;
						else if (newy >= __h)
							newy = __h;
					}
				}
				
				// Move point in the target direction
				newx += direction[j].x;
				newy += direction[j].y;
				
				// Previous positive position?
				boolean ppx = (direction[j].x >= 0),
					ppy = (direction[j].y >= 0);
				
				// Deflect points?
				boolean defx = (newx <= 0 || newx >= __w),
					defy = (newy <= 0 || newy >= __h);
				
				// Deflect direction
				this.__newDirection(direction[j],
					ppx ^ defx, ppy ^ defy);
				
				// Make sure the points are not on a bound!
				if (defx)
					if (ppx)
						newx--;
					else
						newx++;
				if (defy)
					if (ppy)
						newx--;
					else
						newy++;
				
				// Extract the color
				int color = colors[j];
				byte r = (byte)((color & 0xFF0000) >>> 16),
					g = (byte)((color & 0x00FF00) >>> 8),
					b = (byte)((color & 0x0000FF));
				
				// Cycle the colors depending on the direction of travel
				r += (ppx ^ ppy ? +COLOR_SHIFT : -COLOR_SHIFT);
				g += (ppy | ppy ? -COLOR_SHIFT : +COLOR_SHIFT);
				b += (ppx ^ ppy ? -COLOR_SHIFT : +COLOR_SHIFT);
				
				// Recombine the color
				colors[j] = ((r & 0xFF) << 16) |
					((g & 0xFF) << 8) |
					(b & 0xFF);
				
				// Store the point
				place[j] = new Point(newx, newy);
			}
			
			// Use all these points
			points[0] = place;
		}
	}
	
	/**
	 * Volatile point information.
	 *
	 * @since 2018/11/22
	 */
	static public final class Point
	{
		/** X position. */
		public int x;
		
		/** Y position. */
		public int y;
		
		/**
		 * Initializes the point.
		 *
		 * @since 2018/11/22
		 */
		public Point()
		{
		}
		
		/**
		 * Initializes the point from another point.
		 *
		 * @param __p The point to copy.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/22
		 */
		public Point(Point __p)
			throws NullPointerException
		{
			if (__p == null)
				throw new NullPointerException("NARG");
			
			this.x = __p.x;
			this.y = __p.y;
		}
		
		/**
		 * Initializes the point from the given coordinates.
		 *
		 * @param __x The X coordinate.
		 * @param __y The Y coordinate.
		 * @since 2018/11/22
		 */
		public Point(int __x, int __y)
		{
			this.x = __x;
			this.y = __y;
		}
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/PNGDemo.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 net.multiphasicapps.lcduidemo;

/**
 * This is the PNG demo.
 *
 * @since 2019/04/15
 */
public final class PNGDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/04/15
	 */
	public PNGDemo()
	{
		super(PNGDemo.class.getResourceAsStream("image.png"));
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/RepaintTimer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85





















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.lcduidemo;

import javax.microedition.lcdui.Canvas;

/**
 * This is a thread which does timing.
 *
 * @since 2018/11/22
 */
public class RepaintTimer
	extends Thread
{
	/** Canvas to repaint. */
	protected final Canvas canvas;
	
	/** The delay. */
	protected final int delay;
	
	/**
	 * Initialize the timer.
	 *
	 * @param __c The canvas to redraw.
	 * @param __ms The millisecond delay.
	 * @throws IllegalArgumentException If the delay is zero or negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/22
	 */
	public RepaintTimer(Canvas __c, int __ms)
		throws IllegalArgumentException, NullPointerException
	{
		super("LCDUIDemoRepaintTimer");
		
		if (__c == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error AW01 The timer cannot be zero or negative.}
		if (__ms <= 0)
			throw new IllegalArgumentException("AW01");
		
		this.canvas = __c;
		this.delay = __ms;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/22
	 */
	@Override
	public void run()
	{
		Canvas canvas = this.canvas;
		int delay = this.delay;
		
		// Infinite loop
		for (;;)
		{
			// Stop if there is no display
			if (canvas.getCurrentDisplay() == null)
				break;
			
			// Repaint
			canvas.repaint();
			
			// Sleep
			try
			{
				Thread.sleep(delay);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/XPMDemo.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 net.multiphasicapps.lcduidemo;

/**
 * This is the XPM demo.
 *
 * @since 2019/04/15
 */
public final class XPMDemo
	extends AbstractImageDemo
{
	/**
	 * Initializes the demo.
	 *
	 * @since 2019/04/15
	 */
	public XPMDemo()
	{
		super(XPMDemo.class.getResourceAsStream("image.xpm"));
	}
}

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/image.jpg.__mime.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 750 image.jpg
/9j/4AAQSkZJRgABAQEASABIAAD/4iOISUNDX1BST0ZJTEUAAQEAACN4bGNt
cwIQAABtbnRyUkdCIFhZWiAH3wALAAoADAASADhhY3NwKm5peAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAA
ALBjcHJ0AAABuAAAARJ3dHB0AAACzAAAABRjaGFkAAAC4AAAACxyWFlaAAAD
DAAAABRiWFlaAAADIAAAABRnWFlaAAADNAAAABRyVFJDAAADSAAAIAxnVFJD
AAADSAAAIAxiVFJDAAADSAAAIAxjaHJtAAAjVAAAACRkZXNjAAAAAAAAABxz
UkdCLWVsbGUtVjItc3JnYnRyYy5pY2MAAAAAAAAAAAAAAB0AcwBSAEcAQgAt
AGUAbABsAGUALQBWADIALQBzAHIAZwBiAHQAcgBjAC4AaQBjAGMAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0
IDIwMTUsIEVsbGUgU3RvbmUgKHdlYnNpdGU6IGh0dHA6Ly9uaW5lZGVncmVl
c2JlbG93LmNvbS87IGVtYWlsOiBlbGxlc3RvbmVAbmluZWRlZ3JlZXNiZWxv
dy5jb20pLiBUaGlzIElDQyBwcm9maWxlIGlzIGxpY2Vuc2VkIHVuZGVyIGEg
Q3JlYXRpdmUgQ29tbW9ucyBBdHRyaWJ1dGlvbi1TaGFyZUFsaWtlIDMuMCBV
bnBvcnRlZCBMaWNlbnNlIChodHRwczovL2NyZWF0aXZlY29tbW9ucy5vcmcv
bGljZW5zZXMvYnktc2EvMy4wL2xlZ2FsY29kZSkuAAAAAFhZWiAAAAAAAAD2
1gABAAAAANMtc2YzMgAAAAAAAQxCAAAF3v//8yUAAAeTAAD9kP//+6H///2i
AAAD3AAAwG5YWVogAAAAAAAAb6AAADj1AAADkFhZWiAAAAAAAAAknwAAD4QA
ALbEWFlaIAAAAAAAAGKXAAC3hwAAGNljdXJ2AAAAAAAAEAAAAAABAAIABAAF
AAYABwAJAAoACwAMAA4ADwAQABEAEwAUABUAFgAYABkAGgAbABwAHgAfACAA
IQAjACQAJQAmACgAKQAqACsALQAuAC8AMAAyADMANAA1ADcAOAA5ADoAOwA9
AD4APwBAAEIAQwBEAEUARwBIAEkASgBMAE0ATgBPAFEAUgBTAFQAVQBXAFgA
WQBaAFwAXQBeAF8AYQBiAGMAZABmAGcAaABpAGsAbABtAG4AbwBxAHIAcwB0
AHYAdwB4AHkAewB8AH0AfgCAAIEAggCDAIUAhgCHAIgAiQCLAIwAjQCOAJAA
kQCSAJMAlQCWAJcAmACaAJsAnACdAJ8AoAChAKIApAClAKYApwCoAKoAqwCs
AK0ArwCwALEAsgC0ALUAtgC3ALkAugC7ALwAvgC/AMAAwQDCAMQAxQDGAMcA
yQDKAMsAzADOAM8A0ADRANMA1ADVANcA2ADZANoA3ADdAN4A4ADhAOIA5ADl
AOYA6ADpAOoA7ADtAO8A8ADxAPMA9AD2APcA+AD6APsA/QD+AP8BAQECAQQB
BQEHAQgBCgELAQ0BDgEPAREBEgEUARUBFwEYARoBGwEdAR8BIAEiASMBJQEm
ASgBKQErAS0BLgEwATEBMwE0ATYBOAE5ATsBPAE+AUABQQFDAUUBRgFIAUoB
SwFNAU8BUAFSAVQBVQFXAVkBWgFcAV4BYAFhAWMBZQFnAWgBagFsAW4BbwFx
AXMBdQF2AXgBegF8AX4BfwGBAYMBhQGHAYkBigGMAY4BkAGSAZQBlgGXAZkB
mwGdAZ8BoQGjAaUBpwGpAasBrAGuAbABsgG0AbYBuAG6AbwBvgHAAcIBxAHG
AcgBygHMAc4B0AHSAdQB1gHYAdoB3AHeAeEB4wHlAecB6QHrAe0B7wHxAfMB
9QH4AfoB/AH+AgACAgIEAgcCCQILAg0CDwISAhQCFgIYAhoCHQIfAiECIwIl
AigCKgIsAi4CMQIzAjUCOAI6AjwCPgJBAkMCRQJIAkoCTAJPAlECUwJWAlgC
WgJdAl8CYQJkAmYCaQJrAm0CcAJyAnUCdwJ5AnwCfgKBAoMChgKIAosCjQKQ
ApIClQKXApoCnAKfAqECpAKmAqkCqwKuArACswK1ArgCuwK9AsACwgLFAsgC
ygLNAs8C0gLVAtcC2gLdAt8C4gLkAucC6gLsAu8C8gL1AvcC+gL9Av8DAgMF
AwgDCgMNAxADEwMVAxgDGwMeAyADIwMmAykDLAMuAzEDNAM3AzoDPQM/A0ID
RQNIA0sDTgNRA1QDVgNZA1wDXwNiA2UDaANrA24DcQN0A3cDegN9A4ADggOF
A4gDiwOOA5EDlAOYA5sDngOhA6QDpwOqA60DsAOzA7YDuQO8A78DwgPFA8kD
zAPPA9ID1QPYA9sD3wPiA+UD6APrA+4D8gP1A/gD+wP+BAIEBQQIBAsEDwQS
BBUEGAQcBB8EIgQlBCkELAQvBDMENgQ5BD0EQARDBEcESgRNBFEEVARXBFsE
XgRiBGUEaARsBG8EcwR2BHkEfQSABIQEhwSLBI4EkgSVBJkEnASgBKMEpwSq
BK4EsQS1BLgEvAS/BMMExgTKBM4E0QTVBNgE3ATgBOME5wTqBO4E8gT1BPkE
/QUABQQFCAULBQ8FEwUWBRoFHgUiBSUFKQUtBTEFNAU4BTwFQAVDBUcFSwVP
BVIFVgVaBV4FYgVmBWkFbQVxBXUFeQV9BYEFhAWIBYwFkAWUBZgFnAWgBaQF
qAWsBa8FswW3BbsFvwXDBccFywXPBdMF1wXbBd8F4wXnBesF7wX0BfgF/AYA
BgQGCAYMBhAGFAYYBhwGIQYlBikGLQYxBjUGOQY+BkIGRgZKBk4GUwZXBlsG
XwZjBmgGbAZwBnQGeQZ9BoEGhQaKBo4GkgaXBpsGnwakBqgGrAaxBrUGuQa+
BsIGxgbLBs8G1AbYBtwG4QblBuoG7gbyBvcG+wcABwQHCQcNBxIHFgcbBx8H
JAcoBy0HMQc2BzoHPwdDB0gHTQdRB1YHWgdfB2MHaAdtB3EHdgd7B38HhAeJ
B40HkgeXB5sHoAelB6kHrgezB7cHvAfBB8YHygfPB9QH2QfdB+IH5wfsB/EH
9Qf6B/8IBAgJCA0IEggXCBwIIQgmCCsILwg0CDkIPghDCEgITQhSCFcIXAhh
CGYIawhwCHUIegh/CIQIiQiOCJMImAidCKIIpwisCLEItgi7CMAIxQjKCM8I
1AjZCN8I5AjpCO4I8wj4CP0JAwkICQ0JEgkXCR0JIgknCSwJMQk3CTwJQQlG
CUwJUQlWCVsJYQlmCWsJcQl2CXsJgQmGCYsJkQmWCZsJoQmmCasJsQm2CbwJ
wQnGCcwJ0QnXCdwJ4gnnCe0J8gn4Cf0KAgoICg0KEwoZCh4KJAopCi8KNAo6
Cj8KRQpKClAKVgpbCmEKZgpsCnIKdwp9CoMKiAqOCpQKmQqfCqUKqgqwCrYK
vArBCscKzQrTCtgK3grkCuoK7wr1CvsLAQsHCwwLEgsYCx4LJAsqCy8LNQs7
C0ELRwtNC1MLWQtfC2QLagtwC3YLfAuCC4gLjguUC5oLoAumC6wLsgu4C74L
xAvKC9AL1gvcC+IL6QvvC/UL+wwBDAcMDQwTDBkMIAwmDCwMMgw4DD4MRQxL
DFEMVwxdDGQMagxwDHYMfQyDDIkMjwyWDJwMogyoDK8MtQy7DMIMyAzODNUM
2wzhDOgM7gz1DPsNAQ0IDQ4NFQ0bDSENKA0uDTUNOw1CDUgNTw1VDVwNYg1p
DW8Ndg18DYMNiQ2QDZYNnQ2kDaoNsQ23Db4NxQ3LDdIN2Q3fDeYN7A3zDfoO
AQ4HDg4OFQ4bDiIOKQ4vDjYOPQ5EDkoOUQ5YDl8OZg5sDnMOeg6BDogOjg6V
DpwOow6qDrEOuA6+DsUOzA7TDtoO4Q7oDu8O9g79DwQPCw8SDxkPIA8nDy4P
NQ88D0MPSg9RD1gPXw9mD20PdA97D4IPiQ+QD5gPnw+mD60PtA+7D8IPyg/R
D9gP3w/mD+0P9Q/8EAMQChASEBkQIBAnEC8QNhA9EEQQTBBTEFoQYhBpEHAQ
eBB/EIYQjhCVEJ0QpBCrELMQuhDCEMkQ0BDYEN8Q5xDuEPYQ/REFEQwRFBEb
ESMRKhEyETkRQRFIEVARVxFfEWcRbhF2EX0RhRGNEZQRnBGkEasRsxG7EcIR
yhHSEdkR4RHpEfAR+BIAEggSDxIXEh8SJxIuEjYSPhJGEk4SVRJdEmUSbRJ1
En0ShBKMEpQSnBKkEqwStBK8EsQSzBLUEtsS4xLrEvMS+xMDEwsTExMbEyMT
KxMzEzsTRBNME1QTXBNkE2wTdBN8E4QTjBOUE50TpROtE7UTvRPFE80T1hPe
E+YT7hP2E/8UBxQPFBcUIBQoFDAUOBRBFEkUURRaFGIUahRzFHsUgxSMFJQU
nBSlFK0UthS+FMYUzxTXFOAU6BTxFPkVARUKFRIVGxUjFSwVNBU9FUUVThVX
FV8VaBVwFXkVgRWKFZMVmxWkFawVtRW+FcYVzxXYFeAV6RXyFfoWAxYMFhQW
HRYmFi8WNxZAFkkWUhZaFmMWbBZ1Fn4WhhaPFpgWoRaqFrMWuxbEFs0W1hbf
FugW8Rb6FwMXDBcUFx0XJhcvFzgXQRdKF1MXXBdlF24XdxeAF4kXkhecF6UX
rhe3F8AXyRfSF9sX5BftF/cYABgJGBIYGxgkGC4YNxhAGEkYUhhcGGUYbhh3
GIEYihiTGJwYphivGLgYwhjLGNQY3hjnGPAY+hkDGQwZFhkfGSkZMhk7GUUZ
ThlYGWEZaxl0GX4ZhxmRGZoZpBmtGbcZwBnKGdMZ3RnmGfAZ+hoDGg0aFhog
GioaMxo9GkYaUBpaGmMabRp3GoEaihqUGp4apxqxGrsaxRrOGtga4hrsGvUa
/xsJGxMbHRsnGzAbOhtEG04bWBtiG2wbdRt/G4kbkxudG6cbsRu7G8UbzxvZ
G+Mb7Rv3HAEcCxwVHB8cKRwzHD0cRxxRHFscZRxwHHochByOHJgcohysHLYc
wRzLHNUc3xzpHPQc/h0IHRIdHB0nHTEdOx1FHVAdWh1kHW8deR2DHY4dmB2i
Ha0dtx3BHcwd1h3hHesd9R4AHgoeFR4fHioeNB4+HkkeUx5eHmgecx59Hoge
kx6dHqgesh69Hsce0h7cHuce8h78HwcfEh8cHycfMh88H0cfUh9cH2cfch98
H4cfkh+dH6cfsh+9H8gf0h/dH+gf8x/+IAggEyAeICkgNCA/IEogVCBfIGog
dSCAIIsgliChIKwgtyDCIM0g2CDjIO4g+SEEIQ8hGiElITAhOyFGIVEhXCFn
IXIhfiGJIZQhnyGqIbUhwCHMIdch4iHtIfgiBCIPIhoiJSIwIjwiRyJSIl4i
aSJ0In8iiyKWIqEirSK4IsMizyLaIuYi8SL8IwgjEyMfIyojNSNBI0wjWCNj
I28jeiOGI5EjnSOoI7QjvyPLI9Yj4iPuI/kkBSQQJBwkKCQzJD8kSyRWJGIk
biR5JIUkkSScJKgktCS/JMsk1yTjJO4k+iUGJRIlHiUpJTUlQSVNJVklZSVw
JXwliCWUJaAlrCW4JcQl0CXcJecl8yX/JgsmFyYjJi8mOyZHJlMmXyZrJncm
hCaQJpwmqCa0JsAmzCbYJuQm8Cb9JwknFSchJy0nOSdGJ1InXidqJ3YngyeP
J5snpye0J8AnzCfZJ+Un8Sf9KAooFigjKC8oOyhIKFQoYChtKHkohiiSKJ4o
qyi3KMQo0CjdKOko9ikCKQ8pGykoKTQpQSlNKVopZylzKYApjCmZKaYpsim/
Kcwp2CnlKfEp/ioLKhgqJCoxKj4qSipXKmQqcSp9KooqlyqkKrEqvSrKKtcq
5CrxKv4rCisXKyQrMSs+K0srWCtlK3IrfyuMK5krpSuyK78rzCvZK+Yr8ywB
LA4sGywoLDUsQixPLFwsaSx2LIMskCyeLKssuCzFLNIs3yztLPotBy0ULSEt
Ly08LUktVi1kLXEtfi2LLZktpi2zLcEtzi3bLekt9i4ELhEuHi4sLjkuRy5U
LmEuby58Loouly6lLrIuwC7NLtsu6C72LwMvES8eLywvOi9HL1UvYi9wL34v
iy+ZL6cvtC/CL9Av3S/rL/kwBjAUMCIwLzA9MEswWTBnMHQwgjCQMJ4wrDC5
MMcw1TDjMPEw/zENMRoxKDE2MUQxUjFgMW4xfDGKMZgxpjG0McIx0DHeMewx
+jIIMhYyJDIyMkAyTjJcMmoyeTKHMpUyozKxMr8yzTLcMuoy+DMGMxQzIzMx
Mz8zTTNcM2ozeDOGM5UzozOxM8AzzjPcM+sz+TQHNBY0JDQzNEE0TzReNGw0
ezSJNJg0pjS1NMM00jTgNO80/TUMNRo1KTU3NUY1VDVjNXI1gDWPNZ01rDW7
Nck12DXnNfU2BDYTNiE2MDY/Nk42XDZrNno2iTaXNqY2tTbENtM24TbwNv83
DjcdNyw3OzdJN1g3Zzd2N4U3lDejN7I3wTfQN9837jf9OAw4GzgqODk4SDhX
OGY4dTiEOJM4ojixOME40DjfOO44/TkMORs5Kzk6OUk5WDlnOXc5hjmVOaQ5
tDnDOdI54TnxOgA6DzofOi46PTpNOlw6azp7Ooo6mjqpOrg6yDrXOuc69jsG
OxU7JTs0O0Q7UztjO3I7gjuRO6E7sDvAO9A73zvvO/48DjwePC08PTxNPFw8
bDx8PIs8mzyrPLo8yjzaPOo8+T0JPRk9KT05PUg9WD1oPXg9iD2YPac9tz3H
Pdc95z33Pgc+Fz4nPjc+Rz5XPmc+dz6HPpc+pz63Psc+1z7nPvc/Bz8XPyc/
Nz9HP1c/Zz94P4g/mD+oP7g/yD/ZP+k/+UAJQBlAKkA6QEpAWkBrQHtAi0Cc
QKxAvEDNQN1A7UD+QQ5BHkEvQT9BT0FgQXBBgUGRQaJBskHDQdNB5EH0QgVC
FUImQjZCR0JXQmhCeEKJQppCqkK7QstC3ELtQv1DDkMfQy9DQENRQ2FDckOD
Q5RDpEO1Q8ZD10PnQ/hECUQaRCtEO0RMRF1EbkR/RJBEoUSyRMJE00TkRPVF
BkUXRShFOUVKRVtFbEV9RY5Fn0WwRcFF0kXjRfRGBUYXRihGOUZKRltGbEZ9
Ro9GoEaxRsJG00bkRvZHB0cYRylHO0dMR11HbkeAR5FHoke0R8VH1kfoR/lI
CkgcSC1IP0hQSGFIc0iESJZIp0i5SMpI3EjtSP9JEEkiSTNJRUlWSWhJekmL
SZ1JrknASdJJ40n1SgZKGEoqSjtKTUpfSnFKgkqUSqZKt0rJSttK7Ur/SxBL
Iks0S0ZLWEtpS3tLjUufS7FLw0vVS+dL+UwKTBxMLkxATFJMZEx2TIhMmkys
TL5M0EziTPRNBk0ZTStNPU1PTWFNc02FTZdNqU28Tc5N4E3yTgROF04pTjtO
TU5fTnJOhE6WTqlOu07NTt9O8k8ETxZPKU87T05PYE9yT4VPl0+qT7xPzk/h
T/NQBlAYUCtQPVBQUGJQdVCHUJpQrVC/UNJQ5FD3UQlRHFEvUUFRVFFnUXlR
jFGfUbFRxFHXUelR/FIPUiJSNFJHUlpSbVKAUpJSpVK4UstS3lLxUwRTFlMp
UzxTT1NiU3VTiFObU65TwVPUU+dT+lQNVCBUM1RGVFlUbFR/VJJUpVS4VMtU
3lTyVQVVGFUrVT5VUVVlVXhVi1WeVbFVxVXYVetV/lYSViVWOFZLVl9WclaF
VplWrFa/VtNW5lb6Vw1XIFc0V0dXW1duV4JXlVepV7xX0FfjV/dYClgeWDFY
RVhYWGxYgFiTWKdYuljOWOJY9VkJWR1ZMFlEWVhZa1l/WZNZp1m6Wc5Z4ln2
WglaHVoxWkVaWVpsWoBalFqoWrxa0FrkWvhbC1sfWzNbR1tbW29bg1uXW6tb
v1vTW+db+1wPXCNcN1xLXGBcdFyIXJxcsFzEXNhc7F0BXRVdKV09XVFdZV16
XY5dol22Xctd313zXgheHF4wXkReWV5tXoJell6qXr9e017nXvxfEF8lXzlf
Tl9iX3dfi1+gX7RfyV/dX/JgBmAbYC9gRGBYYG1ggmCWYKtgv2DUYOlg/WES
YSdhO2FQYWVhemGOYaNhuGHNYeFh9mILYiBiNWJJYl5ic2KIYp1ismLHYtti
8GMFYxpjL2NEY1ljbmODY5hjrWPCY9dj7GQBZBZkK2RAZFVkamR/ZJVkqmS/
ZNRk6WT+ZRNlKWU+ZVNlaGV9ZZNlqGW9ZdJl6GX9ZhJmJ2Y9ZlJmZ2Z9ZpJm
p2a9ZtJm6Gb9ZxJnKGc9Z1NnaGd+Z5NnqWe+Z9Rn6Wf/aBRoKmg/aFVoamiA
aJZoq2jBaNZo7GkCaRdpLWlDaVhpbmmEaZlpr2nFadtp8GoGahxqMmpIal1q
c2qJap9qtWrKauBq9msMayJrOGtOa2RremuQa6ZrvGvSa+hr/mwUbCpsQGxW
bGxsgmyYbK5sxGzabPBtBm0cbTNtSW1fbXVti22hbbhtzm3kbfpuEW4nbj1u
U25qboBulm6tbsNu2W7wbwZvHG8zb0lvYG92b4xvo2+5b9Bv5m/9cBNwKnBA
cFdwbXCEcJpwsXDHcN5w9HELcSJxOHFPcWZxfHGTcapxwHHXce5yBHIbcjJy
SHJfcnZyjXKkcrpy0XLocv9zFnMsc0NzWnNxc4hzn3O2c81z5HP6dBF0KHQ/
dFZ0bXSEdJt0snTJdOB093UOdSZ1PXVUdWt1gnWZdbB1x3XedfZ2DXYkdjt2
UnZqdoF2mHavdsd23nb1dwx3JHc7d1J3aneBd5h3sHfHd9539ngNeCV4PHhU
eGt4gniaeLF4yXjgePh5D3kneT55VnlueYV5nXm0ecx543n7ehN6KnpCelp6
cXqJeqF6uHrQeuh7AHsXey97R3tfe3Z7jnume7571nvufAV8HXw1fE18ZXx9
fJV8rXzFfNx89H0MfSR9PH1UfWx9hH2cfbR9zX3lff1+FX4tfkV+XX51fo1+
pX6+ftZ+7n8Gfx5/N39Pf2d/f3+Xf7B/yH/gf/mAEYApgEGAWoBygIqAo4C7
gNSA7IEEgR2BNYFOgWaBf4GXgbCByIHhgfmCEoIqgkOCW4J0goyCpYK+gtaC
74MHgyCDOYNRg2qDg4Obg7SDzYPlg/6EF4QwhEiEYYR6hJOErITEhN2E9oUP
hSiFQYVahXKFi4Wkhb2F1oXvhgiGIYY6hlOGbIaFhp6Gt4bQhumHAocbhzSH
TYdnh4CHmYeyh8uH5If9iBeIMIhJiGKIe4iViK6Ix4jgiPqJE4ksiUaJX4l4
iZGJq4nEid6J94oQiiqKQ4pdinaKj4qpisKK3Ir1iw+LKItCi1uLdYuOi6iL
wovbi/WMDowojEKMW4x1jI+MqIzCjNyM9Y0PjSmNQo1cjXaNkI2pjcON3Y33
jhGOK45Ejl6OeI6SjqyOxo7gjvqPE48tj0ePYY97j5WPr4/Jj+OP/ZAXkDGQ
S5BlkH+QmpC0kM6Q6JECkRyRNpFQkWuRhZGfkbmR05HukgiSIpI8kleScZKL
kqaSwJLakvSTD5Mpk0STXpN4k5OTrZPIk+KT/JQXlDGUTJRmlIGUm5S2lNCU
65UFlSCVO5VVlXCVipWllcCV2pX1lg+WKpZFll+WepaVlrCWypbllwCXG5c1
l1CXa5eGl6GXu5fWl/GYDJgnmEKYXZh3mJKYrZjImOOY/pkZmTSZT5lqmYWZ
oJm7mdaZ8ZoMmieaQppemnmalJqvmsqa5ZsAmxybN5tSm22biJukm7+b2pv1
nBGcLJxHnGOcfpyZnLWc0JzrnQedIp09nVmddJ2Qnaudxp3inf2eGZ40nlCe
a56HnqKevp7anvWfEZ8sn0ifY59/n5uftp/Sn+6gCaAloEGgXKB4oJSgsKDL
oOehA6EfoTqhVqFyoY6hqqHGoeGh/aIZojWiUaJtoomipaLBot2i+aMVozGj
TaNpo4WjoaO9o9mj9aQRpC2kSaRlpIGknqS6pNak8qUOpSqlR6VjpX+lm6W4
pdSl8KYMpimmRaZhpn6mmqa2ptOm76cLpyinRKdgp32nmae2p9Kn76gLqCio
RKhhqH2omqi2qNOo76kMqSmpRaliqX6pm6m4qdSp8aoOqiqqR6pkqoCqnaq6
qteq86sQqy2rSqtnq4OroKu9q9qr96wUrDCsTaxqrIespKzBrN6s+60YrTWt
Uq1vrYytqa3GreOuAK4drjquV650rpKur67MrumvBq8jr0CvXq97r5ivta/T
r/CwDbAqsEiwZbCCsJ+wvbDasPexFbEysVCxbbGKsaixxbHjsgCyHrI7slmy
drKUsrGyz7LsswqzJ7NFs2KzgLOes7uz2bP2tBS0MrRPtG20i7SotMa05LUC
tR+1PbVbtXm1lrW0tdK18LYOtiy2SbZntoW2o7bBtt+2/bcbtzm3V7d1t5O3
sbfPt+24C7gpuEe4ZbiDuKG4v7jduPu5Gbk4uVa5dLmSubC5zrntugu6KbpH
uma6hLqiusC637r9uxu7OrtYu3a7lbuzu9G78LwOvC28S7xqvIi8przFvOO9
Ar0gvT+9Xb18vZu9ub3Yvfa+Fb4zvlK+cb6Pvq6+zb7rvwq/Kb9Hv2a/hb+k
v8K/4cAAwB/APsBcwHvAmsC5wNjA98EVwTTBU8FywZHBsMHPwe7CDcIswkvC
asKJwqjCx8LmwwXDJMNDw2LDgcOgw8DD38P+xB3EPMRbxHvEmsS5xNjE98UX
xTbFVcV1xZTFs8XSxfLGEcYwxlDGb8aPxq7GzcbtxwzHLMdLx2vHiseqx8nH
6cgIyCjIR8hnyIbIpsjFyOXJBckkyUTJZMmDyaPJw8niygLKIspBymHKgcqh
ysDK4MsAyyDLQMtfy3/Ln8u/y9/L/8wfzD/MXsx+zJ7MvszezP7NHs0+zV7N
fs2ezb7N3s3+zh/OP85fzn/On86/zt/O/88gz0DPYM+Az6DPwc/h0AHQIdBC
0GLQgtCi0MPQ49ED0STRRNFl0YXRpdHG0ebSB9In0kfSaNKI0qnSydLq0wrT
K9NM02zTjdOt087T7tQP1DDUUNRx1JLUstTT1PTVFNU11VbVd9WX1bjV2dX6
1hrWO9Zc1n3Wnta/1t/XANch10LXY9eE16XXxtfn2AjYKdhK2GvYjNit2M7Y
79kQ2THZUtlz2ZTZtdnW2fjaGdo62lvafNqe2r/a4NsB2yLbRNtl24bbqNvJ
2+rcC9wt3E7cb9yR3LLc1Nz13RbdON1Z3XvdnN2+3d/eAd4i3kTeZd6H3qje
yt7s3w3fL99Q33LflN+139ff+eAa4DzgXuB/4KHgw+Dl4QbhKOFK4WzhjeGv
4dHh8+IV4jfiWeJ64pzivuLg4wLjJONG42jjiuOs487j8OQS5DTkVuR45Jrk
vOTe5QHlI+VF5WflieWr5c3l8OYS5jTmVuZ55pvmvebf5wLnJOdG52nni+et
59Dn8ugU6DfoWeh76J7owOjj6QXpKOlK6W3pj+my6dTp9+oZ6jzqXuqB6qTq
xurp6wvrLutR63Prluu569zr/uwh7ETsZuyJ7Kzsz+zy7RTtN+1a7X3toO3D
7eXuCO4r7k7uce6U7rfu2u797yDvQ+9m74nvrO/P7/LwFfA48FvwfvCh8MXw
6PEL8S7xUfF08Zjxu/He8gHyJPJI8mvyjvKx8tXy+PMb8z/zYvOF86nzzPPw
9BP0NvRa9H30ofTE9Oj1C/Uv9VL1dvWZ9b314PYE9if2S/Zv9pL2tvbZ9v33
IfdE92j3jPew99P39/gb+D74YviG+Kr4zvjx+RX5Ofld+YH5pfnJ+ez6EPo0
+lj6fPqg+sT66PsM+zD7VPt4+5z7wPvk/Aj8LPxQ/HX8mfy9/OH9Bf0p/U39
cv2W/br93v4C/if+S/5v/pT+uP7c/wD/Jf9J/23/kv+2/9v//2Nocm0AAAAA
AAMAAAAAo9cAAFR8AABMzQAAmZoAACZnAAAPXP/bAEMAAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAf/bAEMBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIABgAGAMBEQAC
EQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAAIBwYK/8QAIBAAAgMBAQEAAgMA
AAAAAAAABQYDBAcCAQgUFRYXGP/EABgBAQEAAwAAAAAAAAAAAAAAAAYFAAQH
/8QAIxEAAwEBAAIDAAIDAQAAAAAAAgMEAQUGExESFAcVACEiI//aAAwDAQAC
EQMRAD8A7LNseXMTuKcogBxg3XK5wdsgKomSrX9XX+wRteAW6TqaOPi5HBGH
6Ckqt67EPiVizNLcish5Do0nzryvo0z9dUyGO1489D+WhO5hB0Xu6Cyq0fkQ
MAVOsHlRpIXIVKSz1V0poZcSHmv8f6tVTkprT0IAVjMMzrjIHZXKIifwvM+6
6ff6yIXonUBA1qSzY+6CzWVWxovDAs/sVY21L5BWpEJPVY/7n9o8Hfwo6511
Le6ZrRVZLkxduxVtW1rkDXXZR0UXTmRO6x+TdT6b1GNlScDnSt52MMI7RlAv
3AozzW5VQxR0RtIGFKtCp8WQM6Da5/8AXz4f5fW7ceCmg8hz3K/RgFMZDnwP
pEGgDBzRx2sJv2+cnFU/Wn7QP9D5+pHxRcJbLKzbffLlnmh4KYLVirITWgYa
tVvHa9cAkRDJIARKqXjnJXCLRLcpVDFpo7JZxuta7yCFVhtT0KzePQSWCKWy
/htqmXKsXUK2SJyQWhq2e4W/qJ30dbZ+ipRz+WPi91a3KZWrpxJkR/6Y5Evq
dlNJlvrxx2NJYvDU7+bJ5sw/W2cRL/1J9g2MIuaoyh8yetCcMtoPTBpRYKvN
5ikhICfZsMCcRNxA6vnEgGvQOI5v+vQJZLicBstx+17QMyzml65t0Lp3UM73
QFqy/XLRbjGVFQlSOdE51UdL9BZEvmIm2d4RwL9/WfnsP2vZOu6h4949R2mc
jmQ4Lqe1ZzOZyYVMlW/pdfquTAuRLKnJnS19ZnOXQvaMnPzfj5+oN/NIUH6O
5yz5s1Enrc8TI55Zmn0DqzlKuEFq6Rdl7bDNTT5mIX6u9+Zt4z1zU2nLF1XS
3BkUJi+cXzK053s7Y1RrvHD6GqmIaCW2zE9TaQW1ZZjOqqHTzGpEpWmhjKAZ
+Nj5WFMZzUMlYmg23S/j7pD/ACJL4NM6XKrfI+J43Ba1PXi55tN64edYc/X5
sPksPPsmo53RFXb4PL8gimuGXr8KDszW8tFQyj6/I6A8pqhqgSsE2PvR8rgV
4FebqEE2iNC6rFbTVll+21GKRJQVEpde89+gJkx91HHZ9BV6UecOzuXZfx+L
0ltZ9ThNqJK6X9DlmIT1Ld6v1VBLQMzZ3t0VeuazndNGPoge3E1yHVNaqnTv
l/hzvFOn5DxCdlS+OV0zq9k6ciqBQkKIqvy9nlcfrzj0VWQdLlz9ni8XyCJF
Jxd7kcfpQ2wzvbdgn8MWHbV88WmX3R+AJTq/HlqkvFnZ18tVVsVLY7rX1g94
wtoQIuC4kjstWI1a9sWMHkhxdaiuB5HXlsXrV/Z82Ss+xo6nP66Jb9pUxkgt
K88lcZfnSgcj3TwgZvx62oxwiA5Lta1UdTk5H9w3P2UMWlG5rjzF/Dl+tTGN
PaPp9fkSIhIG6J/4JKBL6MLdpn0QUzjptN4qvzJAxYa80Nquiap7eEnxR3XI
45/klj1HIyxGGtbsFMoz5nLL7DIUo1K7GOohqYrcBi0d0kZ1T5tO1waiJcTu
RX+20GLfhWY/Oew04P8A1rFqqxXzp4w0kSFdFGRcsCbzQqFSrj2g3psSyaTR
NZLj346y5qhzdzAqeoWL+u76z0jOBffNQxje8uQG3Y5X4+7g7JPqDzTkeHNi
8RcOZMhemuwi0RC5Vg9N9VujCfyaC8kwCnMsedR9M3hxqZlnivL2uee3tz2n
0onfadXQlZKubcwgB6w0FhW09H2Y54kcxAn1LWwdrrg9l4IqeiAplytEftsd
H6hITAD1Ov02FmB8/RuLP6NZ7f8Aeq+iU//Z
====

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/image.png.__mime.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 750 image.png
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsS
AAALEgHS3X78AAAB1UlEQVRIx71Vv0tCURS+7xFJUHNjU4PoGljQ3lRT2FgW
YXtLQiIE/gs6WUhDBA222N6QUItgSgTuLTVERFG+Ohc+Pe967vXl0IXL454f
3/n13XeVElbr5jhQY6xIfmQUfD0HNmOX3OXXN2pXytpQMraBQE6b/Lnej1o2
fRMLa6Lc5S8G6FTPh4LMJ1P9MwIBHGfTz1nB/W0tBGYuLidb2EcK0IvHnOBm
INjBzxlAAr++vBqq7vP9SazIDOLbsjIBODjNY3Jq1tm2oQB8YAT+2Gr86ZKZ
MwOezynIwWFYPtyLFICqQut4JaEWjQNONrSpZRSE/Hl7fQkcTsurK3rTqhQL
YkugRxDrDDg4HPfzF2puaVtli2di9u10PqQnX8IgLDDPN8vl4JmHpprufSt1
WtEyqWXQ1+7eQrRGZTpAcnHLg5A2ZVGvV7XBy87uEChnGPSwN5OYcA1wvdsc
cNy4dNmjkkp0w7wnmUlxT/p7cpqRgzQ8mx7Dp65YK8BtBXMoM7N8yGCTyRV0
5gCO9LJ9vHaC0kFaf7FtZ9u74I16aHglOvNfSpZzG/0z2GLLXBRSRuAyAPSg
U5uDNjZOQrSkFsVm4t7I3zWB8zM5gzkAxZfrJN9/WT/5DYY2PNCyJwAAAABJ
RU5ErkJggg==
====

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/image.xpm.

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







































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * head_24x24_xpm[] = {
"24 24 12 1",
" 	c None",
".	c #D4C79F",
"+	c #FFFCEE",
"@	c #D69E98",
"#	c #F9F3D7",
"$	c #977957",
"%	c #48454C",
"&	c #F30102",
"*	c #FFFFFF",
"=	c #AA1E1D",
"-	c #FFA39D",
";	c #EE6365",
"     .             .    ",
"    .+.     .     .+.   ",
"   .@++.   .+.   .++@.  ",
"   .@++.. .++.. ..++@.  ",
"   .@@+...#+++...++@@.  ",
"   .@@..+.#++++....@@.  ",
"   .@..++.#++++.++..@.  ",
"   ...+++$#++.#.+++...  ",
"   ..+#++$#+.#+.++++..  ",
"  ..+#.++$#+.#+.++.++.. ",
" .++#.++$$#+.#+.++#.#+. ",
" .+#.++$$$#+.#+.$$+#.#. ",
" .#.+$$..$$+.#...$$+.#. ",
" ..+$$.%&*$+.#.=&*$$+.$ ",
" ..$$.%=*-.$.#.=*-%$+$. ",
"  $..++=;-.$...=;-+$$$. ",
"  $..++++++.$$++++++#.. ",
"    .+++#+++++++#+++..  ",
"    ..#$$++$$$++$$#.    ",
"      .#$###$###$#.     ",
"      ..#$$$*$$$..      ",
"     #.$...***...$#     ",
"    ##.$$$..*..$$$##    ",
"                        "};

Deleted runt/mids/lcdui-demo/net/multiphasicapps/lcduidemo/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the graphics demonstration which shows graphics
 * rendering and such.
 *
 * @since 2018/03/23
 */

package net.multiphasicapps.lcduidemo;

Deleted runt/mids/squirrel-quarrel/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 00111ef0-e4a8-45e3-a3c7-5a953d183f8f
X-SquirrelJME-Error: BE
X-SquirrelJME-Name: Squirrel Quarrel
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: A turn based strategy involving squirrels and 
 lots of acorns! Keep on your claws and horde them all!
X-SquirrelJME-Depends: tool-manifest-reader midp-lcdui
Microedition-Configuration: CLDC-1.8-Compact
MIDlet-1: Squirrel Quarrel, icon.xpm, 
 dev.shadowtail.squirrelquarrel.MainMidlet

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/AIThinker.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which uses an artificial intelligence to gauge what
 * turns need to be done.
 *
 * @since 2019/07/01
 */
public final class AIThinker
	implements Thinker
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/CommandHandler.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
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










































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

/**
 * This listens to commands within the game.
 *
 * @since 2019/12/25
 */
public final class CommandHandler
	implements CommandListener
{
	/** The command to exit the game. */
	public static final Command EXIT_COMMAND =
		new Command("Quit", Command.EXIT, 10);
	
	/** The game to interact with. */
	protected final Game game;
	
	/**
	 * Initializes the command handler.
	 *
	 * @param __g The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public CommandHandler(Game __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		this.game = __g;
	}
	
	/**
	 * Executes the given command.
	 *
	 * @param __c The command to execute.
	 * @since 2019/12/25
	 */
	public void commandAction(Command __c, Displayable __d)
	{
		// Exit the game?
		if (__c == EXIT_COMMAND)
			System.exit(0);
		
		// The in-game menu was requested
		else if (__c == GameInterface.STATUS_COMMAND)
			__d.getCurrentDisplay().setCurrent(
				this.__makeStatusMenu((GameInterface)__d));
		
		// Returning to the game?
		else if (__c instanceof ReturnToGameCommand)
			__d.getCurrentDisplay().setCurrent(
				((ReturnToGameCommand)__c).gameinterface);
	}
	
	/**
	 * Makes and returns the status menu.
	 *
	 * @param __gi The game interface.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	private final Displayable __makeStatusMenu(GameInterface __gi)
		throws NullPointerException
	{
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		// Make a list to show status items
		List items = new List("Status", Choice.IMPLICIT);
		
		// For now add some dummy items
		items.append("P1: 9999 Acorns", PlayerIndex.of(0).colorBox());
		items.append("P2: 9999 Acorns", PlayerIndex.of(1).colorBox());
		items.append("P3: 9999 Acorns", PlayerIndex.of(2).colorBox());
		items.append("P4: 9999 Acorns", PlayerIndex.of(3).colorBox());
		items.append("Season: Spring Day 1", null);
		
		// Set commands for this list
		items.addCommand(new ReturnToGameCommand(__gi));
		items.addCommand(EXIT_COMMAND);
		
		// Use self as the command listener
		items.setCommandListener(this);
		
		// Return the list
		return items;
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Game.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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.util.Random;

/**
 * This class keeps track of the entire game state, such as active players,
 * artificial intelligence, the tile map, and the units.
 *
 * @since 2019/07/01
 */
public final class Game
{
	/** The random number generator. */
	public final Random random;
	
	/** The world map. */
	public final TileMap tilemap;
	
	/**
	 * Initializes the game.
	 *
	 * @param __seed The seed to use.
	 * @param __mapsize The size of the map.
	 * @param __numpl The number of players to use.
	 * @since 2019/07/01
	 */
	public Game(long __seed, MapSize __mapsize, int __numpl)
	{
		// Initialize RNG
		Random random;
		this.random = (random = new Random(__seed));
		
		// Initialize random map
		TileMap tilemap;
		this.tilemap = (tilemap = new TileMap(random, __mapsize, __numpl));
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/GameBuilder.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
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

























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.io.InputStream;
import java.io.IOException;
import java.util.Random;

/**
 * This is used to build games which can then be run and such.
 *
 * @since 2019/07/01
 */
public final class GameBuilder
{
	/** The game seed. */
	private volatile long _seed;
	
	/** The map size. */
	private volatile MapSize _mapsize;
	
	/** The number of players used. */
	private volatile int _numplayers;
	
	/**
	 * Initializes a base game builder.
	 *
	 * @since 2019/07/01
	 */
	public GameBuilder()
	{
		// Instead of using the time directly, derive it from a seed
		Random initseed = new Random((System.currentTimeMillis() * 37L) +
			System.nanoTime());
		this._seed = ((long)initseed.nextInt() << 32) ^ initseed.nextInt();
		
		// Set default parameters
		this._mapsize = MapSize.DEFAULT;
		this._numplayers = 2;
	}
	
	/**
	 * Builds the actual game.
	 *
	 * @return The resulting game.
	 * @since 2019/07/01
	 */
	public final Game build()
	{
		synchronized (this)
		{
			return new Game(this._seed,
				this._mapsize,
				this._numplayers);
		}
	}
	
	/**
	 * Sets the number of players in the game.
	 *
	 * @param __n The number of players to have.
	 * @return {@code this}.
	 * @throws IllegalArgumentException If the player count is out of range.
	 * @since 2019/07/01
	 */
	public final GameBuilder players(int __n)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE0s Out of range player count. (The count)}
		if (__n < 1 || __n > Players.MAX_PLAYERS)
			throw new IllegalArgumentException("BE0s " + __n);
		
		synchronized (this)
		{
			this._numplayers = __n;
			return this;
		}
	}
	
	/**
	 * Sets the seed to use for the game.
	 *
	 * @param __v The seed to use.
	 * @return {@code this}.
	 * @since 2019/07/01
	 */
	public final GameBuilder seed(long __v)
	{
		synchronized (this)
		{
			this._seed = __v;
			return this;
		}
	}
	
	/**
	 * Builds and plays back a game from a replay.
	 *
	 * @param __in The input stream.
	 * @return The resulting game.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public static final Game fromReplay(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/GameInterface.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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





















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Graphics;

/**
 * This is an interface to the game which allows it to be drawn and interacted
 * with accordingly. This is effectively just a canvas which draws the game
 * and such.
 *
 * @since 2019/07/01
 */
public final class GameInterface
	extends Canvas
{
	/** The menu command. */
	public static final Command STATUS_COMMAND =
		new Command("Status", Command.SCREEN, 0);
	
	/** The game this will be drawing and interacting with. */
	protected final Game game;
	
	/** The current cursor tile. */
	protected final MutablePoint cursor =
		new MutablePoint();
	
	/**
	 * Initializes the game interface.
	 *
	 * @param __g The game to interact with.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public GameInterface(Game __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Initialize variables
		this.game = __g;
		
		// Setup canvas view and such
		this.setTitle("Squirrel Quarrel");
		
		// Add menu command to access the in-game menu
		this.addCommand(STATUS_COMMAND);
		this.setCommandListener(new CommandHandler(__g));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyPressed(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyRepeated(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected final void paint(Graphics __g)
	{
		// Get game details to draw
		Game game = this.game;
		
		// Get the canvas dimensions
		int cw = this.getWidth(),
			ch = this.getHeight();
		
		// Draw the tile map
		this.__drawTiles(__g, cw, ch, game.tilemap);
	}
	
	/**
	 * Draws the underlying tilemap.
	 *
	 * @param __g The graphics to draw to.
	 * @param __cw The canvas width.
	 * @param __ch The canvas height.
	 * @param __tilemap The raw tile data.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/02
	 */
	private final void __drawTiles(Graphics __g, int __cw, int __ch,
		TileMap __tilemap)
		throws NullPointerException
	{
		if (__g == null || __tilemap == null)
			throw new NullPointerException("NARG");
		
		// Size of the map in tiles
		int mtw = __tilemap.tilewidth,
			mth = __tilemap.tileheight;
		
		// Size of the view in tiles, an extra tile is given so that they are
		// not clipped off the right side at all!
		int vtw = (__cw + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS,
			vth = (__ch + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS;
		
		// Half of the view, used for centering and capping
		int vsw = vtw / 2,
			vsh = vth / 2;
		
		// Get the cursor position and determine how that is drawn, the view
		// is always centered on it for simplicity
		MutablePoint cursor = this.cursor;
		int cx = cursor.x,
			cy = cursor.y,
			vtx = cx - vsw,
			vty = cy - vsh;
		
		// Passed bounds on the right side?
		if (vtx + vtw > mtw)
			vtx = mtw - vtw;
		if (vty + mth > mth)
			vty = mth - vth;
		if (vtx < 0)
			vtx = 0;
		if (vty < 0)
			vty = 0;
		
		// End tile positions
		int etx = vtx + vtw,
			ety = vty + vth;
		if (etx > mtw)
			etx = mtw;
		if (ety > mth)
			ety = mth;
		
		// Get the background logical tile data
		byte[] tiles = __tilemap._tiles;
		
		// Draw all tiles in the region
		for (int y = vty; y < ety; y++)
		{
			// Logical tile Y on screen
			int ly = (y - vty) * TileMap.TILE_PIXELS;
			
			// Base byte position in array
			int bbase = y * mtw;
			
			// Scan in row
			for (int x = vtx; x < etx; x++)
			{
				// Determine logical screen position of file
				int lx = (x - vtx) * TileMap.TILE_PIXELS;
				
				// Get the byte code for this tile
				byte b = tiles[bbase + x];
				
				// Draw background tile
				__g.drawImage(TileMap.imageBackground(b), lx, ly, 0);
				
				// Draw a basic grid to make things a bit easier to see
				__g.setStrokeStyle(Graphics.DOTTED);
				__g.setColor(0x000000);
				__g.drawLine(lx, ly,
					lx + TileMap.TILE_PIXELS, ly);
				__g.drawLine(lx, ly,
					lx, ly + TileMap.TILE_PIXELS);
				
				// Draw cursor box?
				if (cx == x && cy == y)
				{
					// Draw solid line
					__g.setStrokeStyle(Graphics.SOLID);
					__g.setColor(0xFFFF00);
					__g.drawRect(lx, ly,
						TileMap.TILE_PIXELS - 2, TileMap.TILE_PIXELS - 2);
					
					// Dotted purple box
					__g.setStrokeStyle(Graphics.DOTTED);
					__g.setColor(0xFF00FF);
					__g.drawRect(lx, ly,
						TileMap.TILE_PIXELS - 2, TileMap.TILE_PIXELS - 2);
					
					// Make it solid again
					__g.setStrokeStyle(Graphics.SOLID);
				}
			}
		}
	}
	
	/**
	 * Handles the specified key.
	 *
	 * @param __kc The key code to handle.
	 * @since 2019/07/02
	 */
	private final void __inputKey(int __kc)
	{
		// Prefer pure game actions, if those are not available fallback to
		// the dial pad. Match traditional SquirrelJME game layout.
		int ga = this.getGameAction(__kc);
		if (ga == 0)
			switch (__kc)
			{
				case Canvas.KEY_NUM1: ga = Canvas.GAME_A; break;
				case Canvas.KEY_NUM2: ga = Canvas.UP; break;
				case Canvas.KEY_NUM3: ga = Canvas.GAME_B; break;
				
				case Canvas.KEY_NUM4: ga = Canvas.LEFT; break;
				case Canvas.KEY_NUM5: ga = Canvas.FIRE; break;
				case Canvas.KEY_NUM6: ga = Canvas.RIGHT; break;
				
				case Canvas.KEY_NUM7: ga = Canvas.GAME_C; break;
				case Canvas.KEY_NUM8: ga = Canvas.DOWN; break;
				case Canvas.KEY_NUM9: ga = Canvas.GAME_D; break;
			}
		
		// Ignore invalid actions
		if (ga == 0)
			return;
		
		// Stuff actions could be performed on
		MutablePoint cursor = this.cursor;
		Game game = this.game;
		TileMap tilemap = game.tilemap;
		
		// Perform the actions
		switch (ga)
		{
				// Cursor up
			case Canvas.UP:
				if (--cursor.y < 0)
					cursor.y = 0;
				break;
				
				// Cursor left
			case Canvas.LEFT:
				if (--cursor.x < 0)
					cursor.x = 0;
				break;
				
				// Cursor Right
			case Canvas.RIGHT:
				if (++cursor.x >= tilemap.tilewidth)
					cursor.x = tilemap.tilewidth - 1;
				break;
				
				// Cursor Down
			case Canvas.DOWN:
				if (++cursor.y >= tilemap.tileheight)
					cursor.y = tilemap.tileheight - 1;
				break;
		}
		
		// Do repaint the view!
		this.repaint();
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/MainMidlet.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
























































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Main entry point for the game.
 *
 * @since 2019/07/01
 */
public class MainMidlet
	extends MIDlet
{
	/** The instance of this MIDlet. */
	public static MIDlet INSTANCE;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Set instance
		MainMidlet.INSTANCE = this;
		
		// Setup base game builder
		GameBuilder gb = new GameBuilder();
		
		// Setup and show the game interface
		GameInterface gi = new GameInterface(gb.build());
		Display.getDisplay(this).setCurrent(gi);
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/MapSize.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































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * DESCRIBE THIS.
 *
 * @since 2019/07/01
 */
public enum MapSize
{
	/** Compact. */
	RIDICULOUSLY_TINY(10, 10),
	
	/** Tiny map size. */
	TINY(20, 20),
	
	/** Small. */
	SMALL(25, 25),
	
	/** Medium. */
	MEDIUM(30, 30),
	
	/** Large. */
	LARGE(40, 40),
	
	/** Ridiculous. */
	RIDICULOUSLY_LARGE(80, 80),
	
	/** End. */
	;
	
	/** The default map size to use. */
	public static final MapSize DEFAULT =
		TINY;
	
	/** The map width. */
	public final int width;
	
	/** The map height. */
	public final int height;
	
	/**
	 * Initializes the map size.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/07/01
	 */
	private MapSize(int __w, int __h)
	{
		this.width = __w;
		this.height = __h;
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/MutablePoint.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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This represents a point which is mutable.
 *
 * @since 2019/07/02
 */
public final class MutablePoint
{
	/** X position. */
	public int x;
	
	/** Y position. */
	public int y;
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Player.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This represents a single player within the game, holding their current state
 * and the resources they have.
 *
 * @since 2019/07/01
 */
public final class Player
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/PlayerIndex.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
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


































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.util.NoSuchElementException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;

/**
 * The represents the color of a player.
 *
 * The colors here are from Electronic Art's Accessibility account which
 * specify the set of colors which are best used for all kinds of color
 * blind users to they can differentiate between all the colors.
 *
 * https://twitter.com/ea_accessible/status/968592657848193024
 * https://twitter.com/ea_accessible/status/968595073184092160
 *
 * @since 2019/12/25
 */
public enum PlayerIndex
{
	/** Red. */
	RED("Red", 0xDE4949),
	
	/** Purple. */
	PURPLE("Purple", 0x533364),
	
	/** Green. */
	GREEN("Green", 0x30B06E),
	
	/** Blue. */
	BLUE("Blue", 0x33521E1),
	
	/** Yellow. */
	YELLOW("Yellow", 0xFFB937),
	
	/** Gray. */
	GRAY("Gray", 0x5A7D8B),
	
	/** End. */
	;
	
	/** The maximum number of players that can play at once. */
	public static final int MAX_PLAYERS =
		4;
	
	/** The number of player colors. */
	public static final int NUM_COLORS =
		6;
	
	/** Player 1. */
	public static final PlayerIndex P1 =
		PlayerIndex.RED;
	
	/** Player 2. */
	public static final PlayerIndex P2 =
		PlayerIndex.PURPLE;
	
	/** Player 3. */
	public static final PlayerIndex P3 =
		PlayerIndex.GREEN;
	
	/** Player 4. */
	public static final PlayerIndex P4 =
		PlayerIndex.BLUE;
	
	/** Creeps that just annoy you. */
	public static final PlayerIndex CREEPS =
		PlayerIndex.YELLOW;
	
	/** The neutral player. */
	public static final PlayerIndex NEUTRAL =
		PlayerIndex.GRAY;
	
	/** The ARGB color code. */
	public final int argb;
	
	/** The RGB color code. */
	public final int rgb;
	
	/** The color name. */
	public final String name;
	
	/** The colorbox. */
	private Image _colorbox;
	
	/**
	 * Initializes the color code.
	 *
	 * @param __name The name of the color.
	 * @param __rgb The RGB used for the player color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	private PlayerIndex(String __name, int __rgb)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.argb = __rgb | 0xFF000000;
		this.rgb = __rgb & 0xFFFFFF;
	}
	
	/**
	 * Returns the color box for this player.
	 *
	 * @return The color box.
	 * @since 2019/12/26
	 */
	public final Image colorBox()
	{
		// Pre-made already?
		Image rv = this._colorbox;
		if (rv != null)
			return rv;
		
		Display d = Display.getDisplay(MainMidlet.INSTANCE);
		this._colorbox = (rv = Image.createImage(
			d.getBestImageWidth(Display.LIST_ELEMENT),
			d.getBestImageHeight(Display.LIST_ELEMENT), false, this.argb));
		return rv;
	}
	
	/**
	 * Returns the player index of the given index.
	 *
	 * @param __i The index.
	 * @return The player index.
	 * @throws NoSuchElementException If it was not found.
	 * @since 2019/12/26
	 */
	public static final PlayerIndex of(int __i)
		throws NoSuchElementException
	{
		switch (__i)
		{
			case 0:	return RED;
			case 1:	return PURPLE;
			case 2:	return GREEN;
			case 3:	return BLUE;
			case 4:	return YELLOW;
			case 5:	return GRAY;
			
				// {@squirreljme.error BE0u Invalid player index.}
			default:
				throw new NoSuchElementException("BE0u");
		}
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/PlayerThinker.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which is completely operated by a player inputting
 * into the phone pad.
 *
 * @since 2019/07/01
 */
public final class PlayerThinker
	implements Thinker
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Players.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This manages all of the players which are in the game and with their
 * associated state.
 *
 * @since 2019/07/01
 */
public final class Players
{
	/** Maximum number of supported players. */
	public static final int MAX_PLAYERS =
		4;
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/RemoteThinker.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which is purely remote based over the network.
 *
 * @since 2019/07/01
 */
public final class RemoteThinker
	implements Thinker
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/ReplayThinker.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a thinker which plays back from a replay or demo.
 *
 * @since 2019/07/01
 */
public final class ReplayThinker
	implements Thinker
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/ReturnToGameCommand.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











































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import javax.microedition.lcdui.Command;

/**
 * Handles returning to the game.
 *
 * @since 2019/12/25
 */
public final class ReturnToGameCommand
	extends Command
{
	/** The game interface. */
	protected final GameInterface gameinterface;
	
	/**
	 * Initializes the return to game.
	 *
	 * @param __gi The game interface.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/12/25
	 */
	public ReturnToGameCommand(GameInterface __gi)
		throws NullPointerException
	{
		super("Resume", Command.SCREEN, 0);
		
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		this.gameinterface = __gi;
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Thinker.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This is a basic thinker which tells units and such to do things.
 *
 * @since 2019/07/01
 */
public interface Thinker
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/TileMap.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
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
















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

import java.io.InputStream;
import java.io.IOException;
import java.util.Random;
import javax.microedition.lcdui.Image;

/**
 * This manages the world map which consists of tiles.
 *
 * @since 2019/07/01
 */
public final class TileMap
{
	/** Each tile is 16x16 pixels. */
	public static final int TILE_PIXELS =
		16;
	
	/** Mask for pixels. */
	public static final int TILE_PIXELS_MASK =
		15;
	
	/** The tile background mask. */
	public static final int TILE_BACKGOUND_MASK =
		0b0000_0011;
	
	/** Background tile images. */
	private static final Image[] _CACHE_BACKGROUND =
		new Image[4];
	
	/** The size of the map. */
	public final MapSize size;
	
	/** The width of the map in tiles. */
	public final int tilewidth;
	
	/** The height of the map in tiles. */
	public final int tileheight;
	
	/** The internal tile data. */
	final byte[] _tiles;
	
	/**
	 * Initializes the tile map.
	 *
	 * @param __rand The random level generator.
	 * @param __size The map size to use.
	 * @param __numpl The number of players to make room for.
	 * @throws IllegalArgumentException If the player count is zero or
	 * negative.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/01
	 */
	public TileMap(Random __rand, MapSize __size, int __numpl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__rand == null || __size == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0r Negative or zero players, there must be
		// at least one player. (The player count)}
		if (__numpl < 1)
			throw new IllegalArgumentException("BE0r " + __numpl);
		
		// Get and store size of the level
		int tilewidth = __size.width,
			tileheight = __size.height,
			tiledens = tilewidth * tileheight;
		this.size = __size;
		this.tilewidth = tilewidth;
		this.tileheight = tileheight;
		
		// Initialize data areas
		byte[] tiles = new byte[tiledens];
		this._tiles = tiles;
		
		for (int i = 0; i < tiledens; i++)
			tiles[i] = (byte)__rand.nextInt();
	}
	
	/**
	 * Looks into the cache and returns the specified image.
	 *
	 * @param __cache The cache to look in.
	 * @param __dx The index to cache.
	 * @param __prefix The resource prefix.
	 * @return The resulting image.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/07/02
	 */
	public static Image cacheImage(Image[] __cache, int __dx, String __prefix)
		throws NullPointerException
	{
		if (__cache == null || __prefix == null)
			throw new NullPointerException("NARG");
		
		// If the cache has the image, use it
		Image rv = __cache[__dx];
		if (rv != null)
			return rv;
		
		// Otherwise load it!
		try (InputStream in = TileMap.class.getResourceAsStream(
			__prefix + __dx + ".xpm"))
		{
			rv = Image.createImage(in);
		}
		
		// {@squirreljme.error BE0t Could not cache the image. (The index;
		// The prefix)}
		catch (IOException e)
		{
			throw new RuntimeException("BE0t " + __dx + " " + __prefix, e);
		}
		
		// Store into the cache then return
		__cache[__dx] = rv;
		return rv;
	}
	
	/**
	 * Gets the image used for the background.
	 *
	 * @param __b The tile data.
	 * @return The image to use.
	 * @since 2019/07/02
	 */
	public static Image imageBackground(byte __b)
	{
		// Read cached image
		return TileMap.cacheImage(_CACHE_BACKGROUND, __b & TILE_BACKGOUND_MASK,
			"tile");
	}
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Unit.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This contains information on a single unit such as an active player moving
 * unit or a player building.
 *
 * @since 2019/07/01
 */
public final class Unit
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/Units.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 dev.shadowtail.squirrelquarrel;

/**
 * This keeps track of all the units that are available in the game.
 *
 * @since 2019/07/01
 */
public final class Units
{
}

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains Squirrel Quarrel, the acorn gathering strategy game!
 *
 * @since 2019/07/01
 */

package dev.shadowtail.squirrelquarrel;

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/tile0.xpm.

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
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
























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char *dummy[]={
"16 16 101 2",
"#d c #00ff35",
".X c #01fc35",
".i c #01ff36",
"#H c #02fe37",
".O c #04f636",
"#I c #04ff38",
"#t c #05f938",
".E c #05ff39",
".N c #07fe3b",
".x c #07ff3b",
".c c #08a72a",
"#j c #08d733",
".Y c #08ff3b",
"#. c #09d534",
".9 c #09fa3b",
".t c #0ad033",
".# c #0bc733",
"#g c #0bcd33",
".F c #0bd936",
".l c #0cc433",
".R c #0cd536",
"#r c #0dbf33",
".y c #0dca34",
"#z c #0dcb34",
"#f c #0df73d",
"#E c #0fc235",
".S c #0fd438",
".Q c #10af32",
".5 c #10b432",
".d c #10b934",
"#c c #10c135",
"#B c #10dd3c",
".Z c #10e63c",
".D c #10ff41",
"#n c #11ad32",
"Qt c #11c137",
"#h c #11e03b",
".3 c #12a632",
"#C c #12a932",
"#a c #12b133",
"#w c #12c137",
".L c #12d23a",
".0 c #12d43b",
".P c #12ef40",
"#D c #12f241",
".W c #13a231",
"#u c #13a632",
".1 c #13c137",
".M c #13dd3d",
"#i c #13fe44",
"#x c #13ff44",
".e c #149d31",
".o c #149e31",
".H c #149f31",
"#y c #14a232",
".p c #14a833",
".h c #14ff45",
".u c #159e32",
"#s c #15a033",
"#m c #15a333",
".I c #15aa34",
".A c #15c43a",
".B c #169f33",
".n c #16a935",
".f c #179f34",
".4 c #17a435",
".w c #17cc3d",
".z c #18d13e",
".j c #1aa036",
"#v c #1ba839",
"#F c #1ca138",
"#q c #1ca238",
".8 c #1dee48",
".q c #1dff4c",
"#p c #21a23c",
"#l c #21e349",
"## c #21f64d",
"#b c #24a43f",
".b c #24aa40",
".v c #26f851",
".k c #28b045",
"#o c #2bd84f",
".K c #31d954",
".U c #32b64e",
".C c #38f05e",
".g c #3dae55",
".s c #41c85d",
".m c #44b15b",
".r c #46ff6c",
"#e c #4ad066",
"#G c #4ccf68",
".T c #4dcf68",
".J c #4ed069",
".7 c #51d46c",
".2 c #53bd6a",
".G c #54ff78",
".a c #59eb78",
".V c #5dca74",
"#A c #5efd7f",
".6 c #6ce485",
"#k c #7cfc97",
"Qt.#.a.a.b.a.a.c.d.e.f.g.a.h.i.j",
".k.l.j.a.a.m.c.a.n.o.p.a.a.q.j.r",
".s.j.t.a.u.a.c.c.c.c.v.j.w.c.x.c",
".j.y.z.A.j.c.j.B.j.C.D.E.j.F.G.c",
".H.I.J.j.K.c.c.L.M.N.O.j.P.j.a.j",
".Q.R.j.c.S.c.a.a.j.T.j.U.j.V.j.W",
".X.c.c.Y.Z.0.1.j.a.j.a.c.2.j.3.c",
".j.c.j.a.j.a.j.4.j.a.j.a.j.c.j.5",
".H.j.6.j.a.j.7.j.a.c.8.j.9.a.a.j",
".j#..j##.j#a.j#b.j#c.j#d.j.a.j#e",
"#f.j#g.j#h.a.a.j#i.j#j.j#k.j.a.j",
".j#l#m.a.a.a.j.a.j#n.j#o.j#p.j.a",
".a.a#q.a.a.j.a.j.i.j#r.a.e.j.a.j",
".j#b#s.a.j.a.j.a.j#t.j.e.o#u.a.a",
".c.j#v.j#w.j#x.j.a.j.a.a#y#z#A.j",
".j#B.a.a#C#D.j#E.j.a.a#F#G#H.j#I"};

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/tile1.xpm.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273

















































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char *dummy[]={
"16 16 254 2",
"bG c #395810",
"#n c #3e5e02",
".P c #415d02",
"b7 c #428114",
".K c #435702",
".Q c #445602",
"aO c #476701",
".u c #477702",
"bl c #4d550f",
".F c #4f5b02",
".G c #4f7402",
"bD c #506f0b",
".J c #516102",
".# c #517d0e",
"#4 c #525c01",
"bt c #526403",
"bp c #537502",
"aM c #554201",
"#S c #556402",
"aK c #584b04",
"bk c #585408",
"ar c #5c6702",
"a1 c #5d2b01",
"ah c #5d3201",
"a0 c #5d3401",
"aL c #5d4203",
"bo c #5d610e",
"#9 c #5d640f",
"a8 c #5d7509",
"bu c #5e5604",
"bI c #5e5c03",
"#. c #5f5d02",
"bE c #605302",
"aw c #605303",
".v c #606a02",
"a2 c #615a01",
"be c #615b01",
"ac c #617002",
"aT c #625103",
"ax c #625a01",
".4 c #625a02",
"#6 c #626b01",
"ai c #633001",
"bU c #637218",
"a7 c #638008",
"#W c #655404",
"#5 c #655f01",
"b2 c #656c03",
"az c #665e01",
"#q c #666402",
".p c #666c06",
"aN c #675d01",
"#H c #675e07",
"#C c #676302",
"#E c #67670c",
"a6 c #677104",
"bs c #684001",
"#m c #685d03",
".V c #686d02",
"bW c #687101",
".U c #687502",
"#0 c #693b02",
"#R c #695d02",
".o c #696412",
"#Z c #6a3802",
"bH c #6a4403",
".5 c #6a5b02",
"#r c #6a6b02",
".a c #6a6b0d",
".I c #6a6d03",
"#B c #6c5b02",
"bS c #6c6304",
"a5 c #6c690b",
"bF c #6d5707",
"aS c #6d670a",
"bA c #6e5f04",
"ay c #6f4701",
"#1 c #6f5403",
"#w c #6f5f02",
"bc c #6f6813",
"bq c #707e0d",
".L c #714a04",
"am c #716f1f",
".H c #718003",
"ak c #723701",
"bV c #727209",
"#Q c #727703",
"aB c #746e1d",
"bf c #749502",
"br c #764706",
"#7 c #766e02",
"ad c #767202",
".A c #775903",
"#G c #775b03",
".T c #77630c",
"bT c #776507",
"#h c #777502",
"#L c #784202",
"bd c #786402",
"#K c #795301",
"bJ c #795405",
"#b c #795e02",
"a9 c #796105",
"#V c #796106",
"bz c #796f05",
"aW c #7a7504",
"#M c #7b640b",
"#T c #7b6606",
"bQ c #7c4c04",
"b1 c #7c5503",
"by c #7c6c08",
"ag c #7c6f0a",
"a3 c #7c7403",
"#i c #7c7f04",
".E c #7d4f04",
"a# c #7d5105",
"ao c #7d5204",
".W c #7d5705",
"#u c #7d6d07",
"aE c #7e4e04",
"bM c #7e5304",
"b5 c #7f4b04",
"bN c #7f5104",
"bP c #7f5e04",
"aj c #7f5f01",
"aQ c #7f6f20",
"bX c #805807",
"as c #805c02",
"bx c #806106",
"aH c #806902",
"ba c #80760e",
"#c c #815e02",
".w c #816805",
"Qt c #816905",
".n c #816d07",
".r c #817813",
"aG c #824503",
".X c #825006",
".c c #825c0a",
"aD c #825d08",
".D c #826307",
"bZ c #82750e",
".Z c #827702",
"bm c #835608",
"av c #836507",
"bO c #836604",
"bj c #846507",
"#8 c #84650b",
"#D c #854702",
"bB c #855305",
"b3 c #855504",
"#x c #857908",
".9 c #863a02",
"at c #865d03",
"#I c #866606",
"bw c #866b09",
"b4 c #875604",
"#P c #875807",
"bi c #876008",
".x c #876706",
".N c #885d08",
"#s c #886505",
"bL c #886b05",
"ae c #895903",
"#A c #8a5405",
"#l c #8a5505",
"#j c #8a6f0d",
".y c #8b5207",
"bC c #8b5505",
"aR c #8b6d03",
".0 c #8b7205",
"#g c #8b7605",
"b# c #8c5608",
"#t c #8c6406",
".Y c #8c7902",
"bn c #8d5606",
"#o c #8e5a06",
"## c #8e6504",
"a. c #8e6f08",
"#p c #904b04",
".g c #906004",
".3 c #906204",
".j c #915c06",
".C c #915d07",
"#d c #916107",
".h c #916804",
".e c #91760d",
".m c #924905",
".l c #925a06",
".2 c #926109",
"bK c #926c12",
"bg c #928003",
"#v c #935e04",
"aa c #936806",
"#a c #936c06",
"aP c #936f03",
".i c #955f05",
"#U c #956c07",
".M c #956d07",
"bY c #956f0d",
".O c #965f05",
"ap c #975106",
"aC c #976309",
"#2 c #986b0c",
"#3 c #98700d",
".8 c #98730b",
"#F c #995805",
"aX c #9a5006",
"aZ c #9a5306",
".f c #9a5d06",
"b6 c #9a6108",
"#X c #9a6406",
".k c #9b5f08",
"a4 c #9b6609",
"al c #9b6b0f",
"bR c #9b6c0c",
"#J c #9b6f07",
".B c #9b750b",
"aU c #9c5d07",
".z c #9c6108",
"aF c #9d5f07",
"aq c #9d6207",
"ab c #9d6508",
"an c #9e6709",
"af c #9e670a",
"#N c #9e6b0b",
"#Y c #9e6d07",
".b c #9f670b",
".q c #9f6b07",
"aI c #9f7303",
".6 c #a06908",
"bh c #a06a0a",
".s c #a06a0b",
".R c #a06e08",
"b0 c #a15a06",
"aA c #a15b06",
"aY c #a2670b",
"bv c #a2680a",
"#f c #a26b0a",
"aJ c #a26c08",
"#k c #a36609",
"#y c #a3690a",
".d c #a36e0e",
"b. c #a46508",
"au c #a46608",
".t c #a4680a",
"aV c #a46d06",
".1 c #a55c09",
"#e c #a57209",
".S c #a57607",
".7 c #a66808",
"#O c #a6690a",
"#z c #a76708",
"bb c #a8780a",
"Qt.#.a.b.c.d.e.f.g.h.i.j.k.l.m.n",
".o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D",
".E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T",
".U.V.W.X.Y.Z.0.1.2.3.4.5.6.7.8.9",
"#.###a#b#c#d#e#f#g#h#i#j#k#l#m#n",
"#o#p#q#r#s#t#u#v#w#x#y#z#A#B#C#D",
"#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#T",
"#U#V#W#X#Y#Z#0#1#2#3#4#5#6#7#8#9",
"a.a#aaabacadaeafagahaiajakalaman",
"aoapaqarasatauavawaxayazaAaBaCaD",
"aEaFaGaHaIaJaKaLaMaNaOaPaQaRaSaT",
"aUaVaWaXaYaZa0a1a2a3a4a5a6a7a8a9",
"b.b#babbbcbdbebfbgbhbibjbkblbmbn",
".sbobpbqbrbsbtbubvbwbxbybzbAbBbC",
"bDbEbFbGbHbIbJafbKbLbMbNbObPbQbR",
"bSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7"};

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/tile2.xpm.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227



































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char *dummy[]={
"16 16 208 2",
"aW c #0019cf",
"a8 c #0019d0",
"aO c #001ad0",
".x c #001bcf",
"aF c #001dcf",
"aD c #001dd0",
".8 c #001ecf",
"bk c #001ed0",
".0 c #001fce",
"a. c #001fcf",
".3 c #001fd0",
"#3 c #0020cf",
"#k c #0020d0",
"#. c #0021ce",
"#r c #0021cf",
"#f c #0021d0",
".E c #0022cc",
"aY c #0022ce",
".O c #0022cf",
"#x c #0022d0",
".U c #0023ce",
"#m c #0023cf",
"#D c #0023d0",
"al c #0024ce",
"aj c #0024cf",
"ar c #0024d0",
".L c #0025cd",
".9 c #0025ce",
".i c #0026cc",
".w c #0026cd",
".Z c #0026cf",
"#P c #0026d0",
"ap c #0027cd",
".G c #0027ce",
"au c #0027cf",
"aX c #0028cc",
".F c #0029ce",
"#y c #0029d0",
".B c #002ace",
"#J c #002ad0",
".p c #002bc9",
"ay c #002bcd",
"#q c #002bcf",
"#2 c #002bd0",
"ah c #002ccf",
"#S c #002cd0",
"aT c #002dc4",
"#I c #002dce",
"#l c #002dcf",
"a5 c #002eb3",
"a# c #002ece",
"#c c #002ecf",
"ab c #002ed0",
".V c #002fc6",
".A c #002fcd",
".P c #002fcf",
".T c #0030cc",
"aL c #0030cd",
"a3 c #0030ce",
"#g c #0030d0",
"aA c #0031ca",
"#9 c #0031cf",
"aQ c #0032cc",
"#H c #0032ce",
"aB c #0032d0",
"#1 c #0033ce",
"#u c #0033cf",
"#C c #0033d0",
".Y c #0034c9",
"bb c #0034ca",
"#p c #0034cf",
"aI c #0035c7",
".K c #0035cb",
"#v c #0035cf",
"ad c #0035d0",
"az c #0036c3",
"a4 c #0036c7",
".j c #0036c8",
"aS c #0036c9",
"aw c #0036cc",
".7 c #0037cc",
"#b c #0037cf",
"aN c #0037d0",
"#e c #0038cd",
"#T c #0038cf",
".4 c #0038d0",
"#0 c #0039ce",
"#O c #0039d0",
"aU c #003ac3",
"b. c #003ac6",
"am c #003ace",
"#h c #003ad0",
".M c #003bc9",
"#t c #003bcd",
".r c #003bce",
"an c #003bcf",
"#Y c #003bd0",
"ax c #003cc9",
"as c #003cd0",
"be c #003dcd",
".c c #003dce",
"#K c #003dd0",
"a1 c #003ec2",
".H c #003ec5",
"#j c #003ecb",
".N c #003ecd",
"#4 c #003ed0",
".f c #003fc7",
"a2 c #003fc9",
".y c #003fcb",
"#Q c #003fcc",
".1 c #0040c7",
"aE c #0040cf",
"af c #0041cb",
"#Z c #0041cd",
"#R c #0041ce",
"aP c #0041cf",
"#o c #0042b9",
".l c #0042c2",
".v c #0042c4",
"aH c #0042c7",
".2 c #0042cb",
"aM c #0042cd",
"ae c #0042ce",
"#6 c #0042cf",
"#7 c #0043c8",
".S c #0043cc",
".5 c #0043cf",
"aR c #0044c2",
"ai c #0044cf",
".o c #0045c6",
"#8 c #0045ce",
"aK c #0046c9",
"#5 c #0046cf",
"aJ c #0047c2",
"aG c #0047c9",
"#w c #0047ce",
"#z c #0047cf",
"#V c #0047d0",
".g c #0048c1",
".h c #0048c4",
".q c #0048cc",
"#U c #0048d0",
"#a c #0049b3",
".m c #0049ca",
"aC c #004acc",
"aq c #004ace",
"aa c #004ad0",
".I c #004bb3",
".z c #004bca",
"#s c #004cc8",
"bg c #004cca",
"#G c #004cce",
"#F c #004ccf",
".X c #004db3",
"#N c #004ecd",
".J c #0050af",
".W c #0050b1",
"#A c #0050cb",
"#i c #0050cc",
".s c #0051cb",
"#W c #0051cf",
"#B c #0052b7",
"## c #0053b7",
"bf c #0053ce",
"bd c #0054c1",
"a9 c #0054c7",
"ak c #0054c9",
"#d c #0054ca",
".C c #0054cd",
"#X c #0055cd",
"av c #0056c6",
".# c #0057bd",
".6 c #0057ca",
"ac c #0057ce",
".k c #0058c5",
".e c #0058cb",
"ag c #0058cc",
".a c #0059a3",
"#n c #0059b2",
"bi c #0059bb",
"ba c #0059cc",
"b# c #0059ce",
"#L c #0059d0",
".b c #005ac0",
"aV c #005ac2",
".t c #005ac8",
"bj c #005acb",
"a7 c #005acd",
"aZ c #005ace",
"#M c #005bc0",
"bl c #005dbf",
"a6 c #005ec0",
".u c #005ec3",
"a0 c #005ec7",
"#E c #005ecb",
".d c #005ece",
"at c #005ecf",
"bn c #0060c1",
".R c #0061ce",
"Qt c #0062c9",
".Q c #0062cd",
".n c #0063cc",
".D c #0063ce",
"ao c #0063cf",
"bh c #0133bf",
"bm c #014ca1",
"bc c #0153b9",
"Qt.#.a.b.c.d.e.f.g.h.i.j.k.l.m.n",
".o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D",
".E.F.G.H.I.J.K.L.x.M.N.O.P.Q.R.S",
".T.U.V.W.X.Y.Z.0.1.2.3.4.5.6.7.8",
".9#.###a#b#c.G#d#e#f#g#h#i#j#k#l",
"#m#n#o#p#q#r#s#t#u.P#v#w.r#x#y#z",
"#A#B#e#C#D#E.r#F#G#H.c#I#J#K#L#y",
"#M#N#O#P#i#Q#R#b#S#T.9#y#J#U#V#W",
"#X#Y#x.N#Z#0#1#2#0#3#l#y#V#4#S#5",
"#6#f.N#7#8#9#q.5a.a#.B.4aa#Cabac",
"adaeafagah#uai.Oajakal#0amajanao",
"#capaqarasataua.avawaxayazaA.5aB",
"#3aCar#kaDaEaFaGaHaI.iaJaKahaFaL",
"aMaN#DaOaPaQaRaSaLaTaUaVaLaWaXaY",
"aZ#Sar#Ja0a1a2a3a4a5a6a7a8.Ga9b.",
"b#babbbcbdbebfbgbhbibj#Dbkblbmbn"};

Deleted runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/tile3.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char *dummy[]={
"16 16 3 1",
". c #4e2e00",
"a c #885000",
"# c #e8dbbb",
"................",
".##############.",
".#aaaaaaaaaaaa#.",
".#a##########a#.",
".#a#aaaaaaaa#a#.",
".#a#a######a#a#.",
".#a#a#aaaa#a#a#.",
".#a#a#a##a#a#a#.",
".#a#a#a##a#a#a#.",
".#a#a#aaaa#a#a#.",
".#a#a######a#a#.",
".#a#aaaaaaaa#a#.",
".#a##########a#.",
".#aaaaaaaaaaaa#.",
".##############.",
"................"};

Deleted runt/mids/squirrel-quarrel/icon.xpm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char *dummy[]={
"16 16 3 1",
"# c None",
". c None",
"a c #000000",
"................",
"#aaaaa###aaaaa##",
"#a######a#####a#",
"#a######a#####a#",
"#a######a#####a#",
"#a######a#####a#",
"#aaaaa##a#####a#",
"#####a##a#####a#",
"#####a##a#####a#",
"#####a##a###a#a#",
"#####a##a####a##",
"#aaaaa###aaaa#a#",
"###.....#######a",
"###......#######",
"................",
"................"};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/graphics/clock.xpm.

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
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

































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * clock_xpm[] = {
"16 16 142 2",
"  	c #FD7FFD",
". 	c #FB7EFB",
"+ 	c #FF87FF",
"@ 	c #F57BF5",
"# 	c #E171E1",
"$ 	c #E573E5",
"% 	c #EF78EF",
"& 	c #F77CF7",
"* 	c #FF86FF",
"= 	c #FF80FF",
"- 	c #ED77ED",
"; 	c #DF70DF",
"> 	c #D56BD5",
", 	c #F37AF3",
"' 	c #FF92FF",
") 	c #FF13FF",
"! 	c #FF0DFF",
"~ 	c #FF03FF",
"{ 	c #FF07FF",
"] 	c #FB00FB",
"^ 	c #FF0BFF",
"/ 	c #FF00FF",
"( 	c #FF05FF",
"_ 	c #E700E7",
": 	c #EB00EB",
"< 	c #E900E9",
"[ 	c #EB76EB",
"} 	c #FF9BFF",
"| 	c #FF3FFF",
"1 	c #C925C9",
"2 	c #CF3DCF",
"3 	c #C927C9",
"4 	c #C821C8",
"5 	c #7F7F7F",
"6 	c #777777",
"7 	c #656666",
"8 	c #545455",
"9 	c #B400B4",
"0 	c #A400A4",
"a 	c #B300B3",
"b 	c #A800A8",
"c 	c #E975E9",
"d 	c #FFADFF",
"e 	c #FF39FF",
"f 	c #D043D0",
"g 	c #777776",
"h 	c #FFFFFF",
"i 	c #444444",
"j 	c #333233",
"k 	c #212221",
"l 	c #BF00BF",
"m 	c #C107C1",
"n 	c #FF84FF",
"o 	c #FFA4FF",
"p 	c #FF3DFF",
"q 	c #CB2FCB",
"r 	c #00FF00",
"s 	c #101110",
"t 	c #000000",
"u 	c #C71DC7",
"v 	c #FF1DFF",
"w 	c #FF95FF",
"x 	c #FFAEFF",
"y 	c #FF73FF",
"z 	c #D041D0",
"A 	c #00F500",
"B 	c #FEFEFF",
"C 	c #C823C8",
"D 	c #FF33FF",
"E 	c #FFABFF",
"F 	c #FF5DFF",
"G 	c #787778",
"H 	c #EEEEED",
"I 	c #FF35FF",
"J 	c #FF9DFF",
"K 	c #FFB3FF",
"L 	c #FF4DFF",
"M 	c #787878",
"N 	c #FB0000",
"O 	c #EB0000",
"P 	c #DDDDDD",
"Q 	c #CCCCCB",
"R 	c #FFA5FF",
"S 	c #FF55FF",
"T 	c #676667",
"U 	c #FF0000",
"V 	c #CCCCCC",
"W 	c #BBBBBB",
"X 	c #FF2DFF",
"Y 	c #FF8FFF",
"Z 	c #FF27FF",
"` 	c #565656",
" .	c #454545",
"..	c #EEEFEE",
"+.	c #DEDDDD",
"@.	c #CCCCCD",
"#.	c #BBBCBB",
"$.	c #FF15FF",
"%.	c #FF8AFF",
"&.	c #FF11FF",
"*.	c #C517C5",
"=.	c #343434",
"-.	c #EEEEEF",
";.	c #DDDDDE",
">.	c #BBBBBC",
",.	c #AAAAAA",
"'.	c #A200A2",
").	c #FF89FF",
"!.	c #F900F9",
"~.	c #232324",
"{.	c #121212",
"].	c #EEEFEF",
"^.	c #DEDEDD",
"/.	c #CDCDCD",
"(.	c #B100B1",
"_.	c #E500E5",
":.	c #C003C0",
"<.	c #010101",
"[.	c #CDCDCC",
"}.	c #BCBCBC",
"|.	c #B000B0",
"1.	c #F97DF9",
"2.	c #FF17FF",
"3.	c #BD00BD",
"4.	c #C515C5",
"5.	c #C105C1",
"6.	c #C71FC7",
"7.	c #C413C4",
"8.	c #C30DC3",
"9.	c #F179F1",
"0.	c #FF8BFF",
"a.	c #FF19FF",
"b.	c #FF29FF",
"c.	c #FF1FFF",
"d.	c #FF21FF",
"e.	c #FF1BFF",
"f.	c #FF8DFF",
"g.	c #FF8CFF",
"h.	c #FF8EFF",
"i.	c #FF90FF",
"j.	c #FF88FF",
"k.	c #FF83FF",
"  . + @ # $ % & * = & - ; # > , ",
"' ) ! ~ { ] ! ! ^ / ( / _ : < [ ",
"} | 1 2 3 4 5 6 7 8 9 0 a b _ c ",
"d e 2 f 5 5 g h h i j k l m / n ",
"o p q 5 5 h h r h h h s t u v w ",
"x y z 5 h h h r A h h B t C D } ",
"E F 5 G h h h r r h h H t t I J ",
"K L M h h h h t t N O P Q t e o ",
"R S T h h h h t t U P V W t X Y ",
"w Z `  .h h h h ..+.@.#.t t $.w ",
"%.&.*.=.h h h -.;.V >.,.t '.! ).",
"% !.a ~.{.h ].^./.W ,.t t (._.c ",
"& / :.a <.t t [.}.t t t |.9 : 1.",
"* 2.3.4.|.5.t t t t 4 6.7.8.!.9.",
"0./ { a.) ! a.&.( &.b.c.d.e.^ & ",
"f.g.h.Y Y i.j.%.f.g.Y Y k.).).* "};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/graphics/globe.xpm.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203











































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * globe_xpm[] = {
"16 16 184 2",
"  	c #7BF5F5",
". 	c #86FFFF",
"+ 	c #82FFFF",
"@ 	c #78EFEF",
"# 	c #7FFDFD",
"$ 	c #7CF7F7",
"% 	c #74E7E7",
"& 	c #89FFFF",
"* 	c #83FFFF",
"= 	c #05FFFF",
"- 	c #03FFFF",
"; 	c #23FFFF",
"> 	c #3DFFFF",
", 	c #2DFFFF",
"' 	c #19FFFF",
") 	c #0FFFFF",
"! 	c #00F3F3",
"~ 	c #00FBFB",
"{ 	c #09FFFF",
"] 	c #98FFFF",
"^ 	c #A6FFFF",
"/ 	c #11C4C4",
"( 	c #09C2C2",
"_ 	c #21C8C8",
": 	c #2BCACA",
"< 	c #1201B0",
"[ 	c #2716C5",
"} 	c #2A19C8",
"| 	c #2817C6",
"1 	c #13C4C4",
"2 	c #03C0C0",
"3 	c #17C5C5",
"4 	c #23C8C8",
"5 	c #2BFFFF",
"6 	c #99FFFF",
"7 	c #AFFFFF",
"8 	c #5BFFFF",
"9 	c #3BCECE",
"0 	c #49D2D2",
"a 	c #52C247",
"b 	c #4FC143",
"c 	c #1E0DBC",
"d 	c #3827D6",
"e 	c #6FCC65",
"f 	c #1706B5",
"g 	c #37A52C",
"h 	c #3EB831",
"i 	c #55D5D5",
"j 	c #4DFFFF",
"k 	c #ABFFFF",
"l 	c #B2FFFF",
"m 	c #5FFFFF",
"n 	c #53D4D4",
"o 	c #39AA2D",
"p 	c #67CA5D",
"q 	c #3524D3",
"r 	c #402FDE",
"s 	c #4231E0",
"t 	c #0D00AB",
"u 	c #1100AF",
"v 	c #54C348",
"w 	c #4EC142",
"x 	c #65FFFF",
"y 	c #A3FFFF",
"z 	c #4FD3D3",
"A 	c #3CB330",
"B 	c #339728",
"C 	c #349C29",
"D 	c #3A29D8",
"E 	c #4C3BEA",
"F 	c #3F2EDD",
"G 	c #78CF6F",
"H 	c #5BC550",
"I 	c #604FFE",
"J 	c #5DD7D7",
"K 	c #B6FFFF",
"L 	c #AAFFFF",
"M 	c #61FFFF",
"N 	c #2B1AC9",
"O 	c #5C4BFA",
"P 	c #4332E1",
"Q 	c #5342F1",
"R 	c #3FBB32",
"S 	c #4635E4",
"T 	c #329628",
"U 	c #53FFFF",
"V 	c #B4FFFF",
"W 	c #A1FFFF",
"X 	c #41FFFF",
"Y 	c #2615C4",
"Z 	c #7160FF",
"` 	c #5F4EFD",
" .	c #2C1BCA",
"..	c #3423D2",
"+.	c #6655FF",
"@.	c #45BD38",
"#.	c #3CB22F",
"$.	c #329527",
"%.	c #59FFFF",
"&.	c #9AFFFF",
"*.	c #8BFFFF",
"=.	c #13FFFF",
"-.	c #0200A0",
";.	c #1605B4",
">.	c #73CE6A",
",.	c #5948F7",
"'.	c #5B4AF9",
").	c #46BE3A",
"!.	c #66C95B",
"~.	c #3BB02F",
"{.	c #63C858",
"].	c #3FFFFF",
"^.	c #9EFFFF",
"/.	c #85FFFF",
"(.	c #0DFFFF",
"_.	c #297A20",
":.	c #287720",
"<.	c #301FCE",
"[.	c #4D3CEB",
"}.	c #6C5BFF",
"|.	c #6251FF",
"1.	c #174412",
"2.	c #12360E",
"3.	c #22661B",
"4.	c #1E5A18",
"5.	c #1BFFFF",
"6.	c #8AFFFF",
"7.	c #77EDED",
"8.	c #00F9F9",
"9.	c #0DC3C3",
"0.	c #36A02A",
"a.	c #1908B7",
"b.	c #1B0AB9",
"c.	c #5E4DFC",
"d.	c #8574FF",
"e.	c #7261FF",
"f.	c #1A4D14",
"g.	c #319227",
"h.	c #11FFFF",
"i.	c #79F1F1",
"j.	c #00BFBF",
"k.	c #37A32B",
"l.	c #3AAD2E",
"m.	c #2110BF",
"n.	c #4E3DEC",
"o.	c #8271FF",
"p.	c #7463FF",
"q.	c #3D2CDB",
"r.	c #200FBE",
"s.	c #48BE3B",
"t.	c #3AAC2E",
"u.	c #00ADAD",
"v.	c #00E1E1",
"w.	c #5DC652",
"x.	c #4CC040",
"y.	c #5A49F8",
"z.	c #6E5DFF",
"A.	c #0900A7",
"B.	c #42BC35",
"C.	c #00B6B6",
"D.	c #00FDFD",
"E.	c #8EFFFF",
"F.	c #29FFFF",
"G.	c #1FC7C7",
"H.	c #00B7B7",
"I.	c #6A59FF",
"J.	c #0F00AD",
"K.	c #1BC6C6",
"L.	c #07C1C1",
"M.	c #0BFFFF",
"N.	c #9FFFFF",
"O.	c #1DFFFF",
"P.	c #17FFFF",
"Q.	c #27FFFF",
"R.	c #2FFFFF",
"S.	c #3BFFFF",
"T.	c #25FFFF",
"U.	c #91FFFF",
"V.	c #90FFFF",
"W.	c #87FFFF",
"X.	c #8DFFFF",
"Y.	c #93FFFF",
"Z.	c #94FFFF",
"`.	c #8CFFFF",
"  . + @ + . # . # $   % % # . & ",
"* = - ; ; > , ' ) = = ! ~ { ; ] ",
"^ ; / ( _ : < [ } | 1 2 3 4 5 6 ",
"7 8 9 0 a b c d e f g h 0 i j k ",
"l m n o p h q r s t u v w i x y ",
"k 8 z A B C D E F v G H I J m K ",
"L M N B O P Q I F R a d S T U V ",
"W X Y D R w Z `  ...+.@.#.$.%.&.",
"*.=.-.;.s >.,.'.s ).!.~.H {.].^.",
"/.(._.:.<.[ [.}.|.1.2.3.g 4.5.6.",
"7.8.9.0.a.b.c.d.e.f.g.0.h 2 h.. ",
"i.! j.k.l.m.n.o.p.q.r.s.t.u.v.i.",
"& - ( 3 w.x.y.z.s A.< B.C.u.D.+ ",
"E.F.G.H.j.j.I.I q J.4 : K.L.M./.",
"N.O.= ~ =.P.' ; Q.R.S.T.P.F.) 6.",
"E.E.U.V.W.E.X.V.Y.Z.Y.&.6 U.*.`."};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/graphics/pepper.xpm.

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
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




































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * pepper_xpm[] = {
"16 16 113 2",
"  	c #FFFF91",
". 	c #FFFF94",
"+ 	c #FFFF8B",
"@ 	c #FFFF88",
"# 	c #FFFF8A",
"$ 	c #FFFF8F",
"% 	c #FFFF92",
"& 	c #FFFF85",
"* 	c #F9F97D",
"= 	c #FFFF82",
"- 	c #FBFB7E",
"; 	c #FFFF86",
"> 	c #FFFF84",
", 	c #FFFF0F",
"' 	c #FFFF09",
") 	c #FFFF21",
"! 	c #FFFF19",
"~ 	c #FFFF1F",
"{ 	c #FFFF27",
"] 	c #FFFF0D",
"^ 	c #FFFF1D",
"/ 	c #FFFF07",
"( 	c #FFFF23",
"_ 	c #FFFF8E",
": 	c #F3F37A",
"< 	c #FFFF17",
"[ 	c #C7C71D",
"} 	c #C6C619",
"| 	c #C8C821",
"1 	c #CACA2B",
"2 	c #CBCB2D",
"3 	c #C5C517",
"4 	c #CACA29",
"5 	c #C6C61B",
"6 	c #C9C925",
"7 	c #FFFF29",
"8 	c #FFFF97",
"9 	c #FFFF2B",
"0 	c #CCCC31",
"a 	c #09DE09",
"b 	c #CFCF3F",
"c 	c #CECE3B",
"d 	c #CECE39",
"e 	c #D1D145",
"f 	c #D7D75D",
"g 	c #D3D34D",
"h 	c #D1D147",
"i 	c #FFFF57",
"j 	c #FFFFA5",
"k 	c #FFFF89",
"l 	c #CBCB2F",
"m 	c #D4D451",
"n 	c #D5D555",
"o 	c #DADA69",
"p 	c #D8D863",
"q 	c #D8D861",
"r 	c #FFFF65",
"s 	c #FFFFAB",
"t 	c #FFFF93",
"u 	c #36DF00",
"v 	c #17E017",
"w 	c #CFCF3D",
"x 	c #D6D65B",
"y 	c #D7D75F",
"z 	c #FFFF71",
"A 	c #FFFFB2",
"B 	c #FFFF2D",
"C 	c #C10000",
"D 	c #DF0000",
"E 	c #D2D249",
"F 	c #D9D967",
"G 	c #FFFF5F",
"H 	c #FFFF99",
"I 	c #FFFF9F",
"J 	c #D3D34F",
"K 	c #D0D043",
"L 	c #FFFF9C",
"M 	c #FFFF45",
"N 	c #D2D24B",
"O 	c #CCCC33",
"P 	c #FFFF2F",
"Q 	c #FFFFA3",
"R 	c #FFFF5D",
"S 	c #A20000",
"T 	c #D0D041",
"U 	c #FFFF3D",
"V 	c #FFFF3F",
"W 	c #C8C823",
"X 	c #FFFF31",
"Y 	c #FFFF90",
"Z 	c #FFFF33",
"` 	c #C4C413",
" .	c #CDCD35",
"..	c #C4C411",
"+.	c #FFFF83",
"@.	c #FFFF13",
"#.	c #BFBF00",
"$.	c #B1B100",
"%.	c #C3C30F",
"&.	c #C5C515",
"*.	c #C2C20B",
"=.	c #C3C30D",
"-.	c #C7C71F",
";.	c #FDFD7F",
">.	c #EFEF78",
",.	c #FFFF00",
"'.	c #FFFF15",
").	c #FFFF0B",
"!.	c #FFFF1B",
"~.	c #FFFF03",
"{.	c #FFFF80",
"].	c #FFFF8C",
"^.	c #FFFF8D",
"  . . + @ # $ % + . & * = - ; > ",
"$ , ' ) ! ~ { ] , ^ / / ^ ] ( _ ",
": < [ [ } | 1 2 | 3 [ 4 5 6 7 8 ",
"@ 9 0 a b b c 6 d 1 e f g h i j ",
"k , 6 a a c l h m n o p q q r s ",
"t ( 2 u u v 0 c w b x m q y z A ",
"8 B e C D D E 0 w w c w n F G H ",
"I B c C D C e w J K d w E f i L ",
"s M N C D D O x b g g w b O P L ",
"Q R J C D D S m e T h d 6 4 U t ",
"8 V O C D D D S W 0 l N J E X + ",
"Y ~ 0 E S S D D D D D D K 0 Z $ ",
"k ) ` 6 1  .| C C C S D C ..' = ",
"+.@.#.$.3 %.&.%.` *.=.| 6 -.^ ;.",
">.,./ '.).).!., @.~.^ !.] < )   ",
"{.> +.; ].$ > k $ $ ^._ %   Y % "};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/graphics/salt.xpm.

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
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















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * salt_xpm[] = {
"16 16 124 2",
"  	c #C8C8C8",
". 	c #C7C7C7",
"+ 	c #BFBFBF",
"@ 	c #C9C9C9",
"# 	c #C5C5C5",
"$ 	c #BEBEBE",
"% 	c #ADADAD",
"& 	c #CBCBCB",
"* 	c #D1D1D1",
"= 	c #CDCDCD",
"- 	c #CFCFCF",
"; 	c #D2D2D2",
"> 	c #D0D0D0",
", 	c #BBBBBB",
"' 	c #808080",
") 	c #858585",
"! 	c #8E8E8E",
"~ 	c #8B8B8B",
"{ 	c #878787",
"] 	c #888888",
"^ 	c #636363",
"/ 	c #747474",
"( 	c #898989",
"_ 	c #8A8A8A",
": 	c #959595",
"< 	c #979797",
"[ 	c #ACACAC",
"} 	c #6F6F6F",
"| 	c #3E3E3E",
"1 	c #434343",
"2 	c #424242",
"3 	c #454545",
"4 	c #F6F6F6",
"5 	c #FFFFFF",
"6 	c #404040",
"7 	c #3F3F3F",
"8 	c #444444",
"9 	c #797979",
"0 	c #B6B6B6",
"a 	c #9B9B9B",
"b 	c #666666",
"c 	c #3B3B3B",
"d 	c #363636",
"e 	c #E0E0E0",
"f 	c #EFEFEF",
"g 	c #F8F8F8",
"h 	c #373737",
"i 	c #3C3C3C",
"j 	c #FEFAFA",
"k 	c #A4A4A4",
"l 	c #7A7A7A",
"m 	c #505050",
"n 	c #565656",
"o 	c #F0F0F0",
"p 	c #F4F3F0",
"q 	c #F5F5F6",
"r 	c #D2D6D1",
"s 	c #C6C6C6",
"t 	c #4D4D4D",
"u 	c #5A5A5A",
"v 	c #FFFFF2",
"w 	c #EDEDED",
"x 	c #FFFFFC",
"y 	c #C1C1C1",
"z 	c #8F8F8F",
"A 	c #D5D5D5",
"B 	c #CACACA",
"C 	c #E6E6E6",
"D 	c #515151",
"E 	c #F8F6F9",
"F 	c #EFEDE9",
"G 	c #838383",
"H 	c #B5B5B5",
"I 	c #7B7B7B",
"J 	c #D9D9D9",
"K 	c #DBDBDB",
"L 	c #D7D7D7",
"M 	c #F5F5F5",
"N 	c #FCFCFC",
"O 	c #E7E8F1",
"P 	c #FBFBFB",
"Q 	c #FDFDFD",
"R 	c #909090",
"S 	c #A6A6A6",
"T 	c #F3F3F3",
"U 	c #E8E8E8",
"V 	c #E9E9E9",
"W 	c #DDDDDD",
"X 	c #FFFFFE",
"Y 	c #FAFAFA",
"Z 	c #575757",
"` 	c #CCCCCC",
" .	c #A9A9A9",
"..	c #7D7D7D",
"+.	c #E4E4E4",
"@.	c #E5E5E5",
"#.	c #EEEEEE",
"$.	c #ECECEC",
"%.	c #7E7E7E",
"&.	c #B9B9B9",
"*.	c #F7F7F7",
"=.	c #F2F2F2",
"-.	c #FAFAFB",
";.	c #4A4A4A",
">.	c #B3B3B3",
",.	c #4C4C4C",
"'.	c #DBEEEC",
").	c #D8D8D8",
"!.	c #8D8D8D",
"~.	c #B2B2B2",
"{.	c #414141",
"].	c #DCDDE7",
"^.	c #C3C3C3",
"/.	c #4E4E4E",
"(.	c #464646",
"_.	c #646464",
":.	c #5D5D5D",
"<.	c #6B6B6B",
"[.	c #949494",
"}.	c #8C8C8C",
"|.	c #989898",
"1.	c #939393",
"2.	c #969696",
"3.	c #CECECE",
"  . + . @ # $ % $ . & * = - ; > ",
", ' ) ! ~ { ] ^ / ) ( _ { : < . ",
"[ } | 1 2 3 4 5 5 6 7 8 3 8 9 0 ",
"a b c d c e f 5 g h i 7 6 j / . ",
"k l 2 i 7 5 5 5 5 m n o p q r s ",
"$ ) t ^ u 5 5 5 5 u 5 v 5 w x s ",
"y z A   B 5 g C 4 D E f g F G 0 ",
"H I J K - L M J N 5 O P Q g R - ",
"S T U V W C 5 L 5 5 X Y 5 Z _ ` ",
" ...T +.@.U w L #.5 5 5 $.m %.. ",
"&...1 o e T 5 *.=.5 -.*.;.m _ . ",
">...D ,.U *.5 5 5 5 '.).;.,.!.` ",
"~./ {.t #.e =.T 5 5 ].3 u b < - ",
"^.] /.(.m +.T T =.K n _.:.<.[.* ",
"& ' I ' ] G T T R }.|.1.2.~ ! 3.",
"s # y s # y . B   @ B 3.= = - > "};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/terrain/dirt.xpm.

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
66
67



































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * dirt_xpm[] = {
"32 32 32 1",
" 	c #733C0C",
".	c #763F0C",
"+	c #70390B",
"@	c #6E370B",
"#	c #743D0C",
"$	c #713A0B",
"%	c #6F380B",
"&	c #723B0B",
"*	c #79420C",
"=	c #7D460D",
"-	c #78410C",
";	c #753E0C",
">	c #7C450C",
",	c #7B440C",
"'	c #77400C",
")	c #7E470D",
"!	c #7A430C",
"~	c #7E470C",
"{	c #7F480D",
"]	c #824B0D",
"^	c #80490D",
"/	c #733C0B",
"(	c #814A0D",
"_	c #7C450D",
":	c #7A430D",
"<	c #79420D",
"[	c #7D460C",
"}	c #743D0B",
"|	c #7B440D",
"1	c #753E0B",
"2	c #834C0D",
"3	c #844D0E",
" .+@@.#$@%&*&@@& @@@=@@@@&@+-%+%",
";.+++>@#;..%&@;;+&%*#@,-.'%.-@'+",
" +++@*)&!&)&'&~++'#{-,;$]@%$*^!$",
"@$-*@/$*%~!,;#=!!!%.#$'#-,..;-@#",
"@$-''-$'+$>$@=#'@##%@@% #$+%$(^&",
"@  '-;!~#&'+$_*:;#$&$'*$@ ++*.*.",
"@@,-#$.#;.%(!';@#;@!+;>;#<[+.^@.",
"&@#@@+&@'<-;.%++;//,%-%.#%.!;=^+",
"#@%}#:&;@&)&[/++_,//,#;+++;&$_@&",
".'+'$$@-![^{># .; #- ;-%}*% $=;#",
"-@@% ,.,*$$&&;+!;'-#$$..})@.$:~@",
".}..$;'@*{@--+$/; $;+@@%&:!#!-)#",
"+-+ }+$+#!{;*$%}!#$@#%#|>'@$!@+;",
"@'@&&#&! '-#;;=,_;_@ &!%-$@@+=!@",
"@'$+@&$*%!+;+>; ,;-*&@;-*.'.!#%@",
"&-/@&&@*.@!-&%+%+$&+@$;+@{;-%%%@",
".@'*%@,!1>!,@@%/-$$$!)#%=;@!'$-%",
";#.@+@!)-)$),#%&_!$..,&''-.%+[{@",
"+.@%@@#<#@]{>#-${=%.~-;'([&+&=@$",
"@@$+@ % &*,($@)!'. =;%<@%',@+,{!",
"@$,%+ %##%(''*!%#|&${,@%+@%|#[*@",
"@@- /$),.--*;&{;;#(% }@%.{!&#=*@",
"@@@/$+'$%,{;'+{(! ...;&@(-!@,@##",
"@@=%%[;*%@;;&.+&.;-**@$)2 $!)+##",
"@;.;|.@$);;~@^#;.@##,,*..^-!,;_%",
"@@_;;!&=;!#;{',*.=,&3);+&.''-=&-",
"@@%%%#}@@#+& ;.@&~,/>@.&+;  +-.+",
"@%%';@;@@$$$+ ,!!=@@^{#,#'='@*!@",
"@!@+,[@+.'%-}.&&$*;  @%@|.*))$=*",
"@-##'&@>';,$*$; % ;++% '>..!@+!*",
"@@#@#% +(#@_@+;*#+$&&!1=!$@{ %++",
"@@@@+#@@$@@;),@@@%%=;;;,!>,,@&%+"};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/terrain/grass.xpm.

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
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






















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * grass_xpm[] = {
"32 32 83 1",
" 	c #02B602",
".	c #02B702",
"+	c #02B302",
"@	c #02A902",
"#	c #02B802",
"$	c #01B601",
"%	c #01B201",
"&	c #01B801",
"*	c #01B701",
"=	c #01B301",
"-	c #01A501",
";	c #01A101",
">	c #02B002",
",	c #01A301",
"'	c #01AC01",
")	c #02AE02",
"!	c #02B502",
"~	c #02A502",
"{	c #009D00",
"]	c #01A801",
"^	c #01B501",
"/	c #01AD01",
"(	c #01B101",
"_	c #01A701",
":	c #01B001",
"<	c #00A200",
"[	c #01A001",
"}	c #009700",
"|	c #019901",
"1	c #01A401",
"2	c #02B102",
"3	c #01A201",
"4	c #02B202",
"5	c #01A901",
"6	c #00A100",
"7	c #019E01",
"8	c #01AE01",
"9	c #02AF02",
"0	c #02A802",
"a	c #019D01",
"b	c #02AB02",
"c	c #02AD02",
"d	c #009E00",
"e	c #02A702",
"f	c #009F00",
"g	c #01B401",
"h	c #02AA02",
"i	c #02AC02",
"j	c #00AB00",
"k	c #00B600",
"l	c #00B800",
"m	c #00B500",
"n	c #00B400",
"o	c #00B300",
"p	c #00B200",
"q	c #00A900",
"r	c #00AD00",
"s	c #00AE00",
"t	c #00AC00",
"u	c #00B100",
"v	c #00A600",
"w	c #00A700",
"x	c #00A800",
"y	c #01AA01",
"z	c #00A000",
"A	c #009A00",
"B	c #00B700",
"C	c #02B402",
"D	c #00AA00",
"E	c #00AF00",
"F	c #01A601",
"G	c #00B000",
"H	c #00A300",
"I	c #00A400",
"J	c #009800",
"K	c #00A500",
"L	c #01AF01",
"M	c #009900",
"N	c #009C00",
"O	c #009B00",
"P	c #009500",
"Q	c #01AB01",
"R	c #019F01",
" .+. @@ #$%&*=-;>,'.#.)@.#+!# @@",
"~ &${]^/$(_:-<;[}|!!!.1>2!34 @@!",
"~ %($^/5,_%{'6)7;; /8 9~0aa9~0@b",
" c-/$3d8{/5]$$*$   ,2 2+3@@1>b;e",
".15'%1%fg*^*&*$*$*552; #  hh!3!i",
"#2[:jjkklmnlmomnp$d=5%.  . .# . ",
" @[5qkrmkrkksnqpmg^<$^92@c2 .+hc",
"# $*kktnsruvm<wtrx^$$y;~;+)_>zA2",
"#^g^sqqkjpvkBqmsjx::_/(];]aC_2!#",
".%8yDkku6kkllBBkruy5;/$53!/ 4.##",
"48(-mlk<mBBllkrrmzv<zuB.  !.c2.#",
".$%8BllonpEBuv<Ekttqqrm*C4+95>F.",
".***lBBuGuum<Hxkrq<6vjsi$*/,/H5$",
"/'^&BGtkuHkwwmjmndnwqIm5$$<'5]F(",
"-C%guuxkqqoJKEdu<vtszGq(*$$*${8_",
"!>(guouBkkufn<GBo{qpKwwtmokmlm6r",
"#. 'mvkBGxIqurBk<stDHKrptksjku<k",
"##.$qplkw{<kuKkGr{IIdrrKKG6qukkB",
"&*LL^BBGMrkkdKkKKwvDDEGHrzDnwukv",
"&mfjGukKDEBBjjm{o{wqxqkGIuodDrKr",
"$6mkxoqwttuujDqvnG6r6wpHqpHsf6ww",
"$GBlkIqmsrDuKI<DrkmoxKu6plmEsqzA",
"(6klBtGKwrrtANE6mBo<xr{6HmEkkqqn",
"]xupokKumvoNOxn6ukqK6mzOuDsklBBB",
"{EIDkqKGrrsOOnqqkuwxvnqtK<rsuokG",
"]wfuBmzukksr6G6kk<jkm<GMOKKswxpv",
"$qKqkDqkBso6Emklmfjkm6Hf{{xqxDBn",
"&kx{kkkkDvmkw{ukwvmu6mkszxpqdrkI",
"&m{wptqtzmlpA<kBnxqrDkk{ptoqqkl$",
" rM66}MDDBBjDkkEq6EK<kkE6kmKtkn'",
"!p6{P{v6uku6mk6HJu6<EtrE<ks/Q-1<",
"8pKdukBkBlksGufmmlkkqqpdnG<$_R_$"};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/units/chlorophid_garden/info.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
name: Garden
hp: 1250
armor: 1
salt-cost: 300
build-time: 1800
supply-provided: 2
sight: 288
score-build: 300
score-destroy: 900
size: large
tile-dimensions: [4, 3]
pixel-dimensions: [99, 65]
pixel-offset: (15, 16)
abilities: regenerates_hp

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/units/start_location/idle0v.xpm.

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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* XPM */
static char * idle0v_xpm[] = {
"64 48 3 1",
" 	c None",
".	c #000000",
"+	c #FF00FF",
"................................................................",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++......................................++++++++++++.",
".++++++++++++.                                    .++++++++++++.",
".++++++++++++..                                  ..++++++++++++.",
".+++++++++++++...                              ...+++++++++++++.",
".+++...+++++++++..                            ..+++++++++...+++.",
".+++. ..+++++++++..                          ..+++++++++.. .+++.",
".+++.  ...++++++++...                      ...++++++++...  .+++.",
".+++.    ..+++++++++..                    ..+++++++++..    .+++.",
".+++.     ..+++++++++..                  ..+++++++++..     .+++.",
".+++.      ...++++++++...              ...++++++++...      .+++.",
".+++.        ..+++++++++..            ..+++++++++..        .+++.",
".+++.         ..+++++++++..          ..+++++++++..         .+++.",
".+++.          ...++++++++...      ...++++++++...          .+++.",
".+++.            ..+++++++++..    ..+++++++++..            .+++.",
".+++.             ..+++++++++..  ..+++++++++..             .+++.",
".+++.              ...++++++++....++++++++...              .+++.",
".+++.                ..++++++++++++++++++..                .+++.",
".+++.                 ..++++++++++++++++..                 .+++.",
".+++.                  ...++++++++++++...                  .+++.",
".+++.                    .++++++++++++.                    .+++.",
".+++.                    .++++++++++++.                    .+++.",
".+++.                  ...++++++++++++...                  .+++.",
".+++.                 ..++++++++++++++++..                 .+++.",
".+++.                ..++++++++++++++++++..                .+++.",
".+++.              ...++++++++....++++++++...              .+++.",
".+++.             ..+++++++++..  ..+++++++++..             .+++.",
".+++.            ..+++++++++..    ..+++++++++..            .+++.",
".+++.          ...++++++++...      ...++++++++...          .+++.",
".+++.         ..+++++++++..          ..+++++++++..         .+++.",
".+++.        ..+++++++++..            ..+++++++++..        .+++.",
".+++.      ...++++++++...              ...++++++++...      .+++.",
".+++.     ..+++++++++..                  ..+++++++++..     .+++.",
".+++.    ..+++++++++..                    ..+++++++++..    .+++.",
".+++.  ...++++++++...                      ...++++++++...  .+++.",
".+++. ..+++++++++..                          ..+++++++++.. .+++.",
".+++...+++++++++..                            ..+++++++++...+++.",
".+++++++++++++...                              ...+++++++++++++.",
".++++++++++++..                                  ..++++++++++++.",
".++++++++++++.                                    .++++++++++++.",
".++++++++++++......................................++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
".++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.",
"................................................................"};

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/data/units/start_location/info.

1
2
3
4
5





-
-
-
-
-
Manifest-Version: 1.0
hp: 1
pixel-dimensions: [97, 65]
pixel-offset: (16, 16)

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/EventSource.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This interface describes a source that is used for game events, that is
 * ones which control the various players including AIs.
 *
 * @since 2019/03/24
 */
public interface EventSource
{
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/Game.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
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

















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.Players;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.units.SpawnPlacementType;
import net.multiphasicapps.squirrelquarrel.units.Unit;
import net.multiphasicapps.squirrelquarrel.units.Units;
import net.multiphasicapps.squirrelquarrel.units.UnitType;
import net.multiphasicapps.squirrelquarrel.util.GameRandom;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This class contains the state for a single game.
 *
 * @since 2017/02/08
 */
public class Game
{
	/** The player manager. */
	protected final Players players;
	
	/** The unit manager. */
	protected final Units units;
	
	/** Random number generator for games. */
	protected final GameRandom random;
	
	/** The level information. */
	protected final World world;
	
	/** The current game frame. */
	private volatile int _framenum;
	
	/** Has the initial game setup been booted? */
	private boolean _booted;
	
	/**
	 * Initializes a game with the default initialization rules.
	 *
	 * @since 2017/02/08
	 */
	public Game()
	{
		this(new InitialSettingsBuilder().build());
	}
	
	/**
	 * Initializes the game with the given initial settings.
	 *
	 * @param __is The settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	public Game(InitialSettings __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Setup random number generator
		this.random = new GameRandom(__is.seed());
		
		// Initialize the level using the initial settings
		this.world = new World(__is);
		
		// Initialize players
		this.players = new Players(__is);
		
		// Initialize units
		this.units = new Units(__is);
	}
	
	/**
	 * Returns the current game frame.
	 *
	 * @return The game frame.
	 * @since 2017/02/10
	 */
	public final int frameCount()
	{
		return this._framenum;
	}
	
	/**
	 * Returns the player manager.
	 *
	 * @return The player manager.
	 * @since 2018/03/19
	 */
	public final Players players()
	{
		return this.players;
	}
	
	/**
	 * Runs a single game frame.
	 *
	 * @since 2017/02/10
	 */
	public final void run()
	{
		// Get current frame
		int framenum = this._framenum;
		
		// On the first frame if the game is not booted, spawn everything
		// as needed so it is all done within the loop
		if (!this._booted)
		{
			this.__boot();
			this._booted = true;
		}
		
		// Run all the sub-logic
		world.run(framenum);
		units.run(framenum);
		players.run(framenum);
		
		// Increase the game frame
		this._framenum = framenum + 1;
	}
	
	/**
	 * Returns the world.
	 *
	 * @since 2017/02/10
	 */
	public World world()
	{
		return this.world;
	}
	
	/**
	 * Boots the game spawning everything as needed.
	 *
	 * @since 2019/03/24
	 */
	private final void __boot()
	{
		Units units = this.units;
		Players players = this.players;
		
		// Create initial game units for players who are playing
		for (int i = 0, n = PlayerColor.NUM_COLORS; i < n; i++)
		{
			// Only if the player is playing
			Player p = players.get(i);
			if (p.isPlaying())
			{
				// Create building
				Unit base = units.createUnit(SpawnPlacementType.BUILDING,
					UnitType.CHLOROPHID_GARDEN, (Unit)null,
					64 + (128 * i), 64);
				
				// Create workers from the building
				todo.TODO.note("Spawn workers!");
			}
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/GameLooper.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203











































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import java.io.InputStream;
import java.io.OutputStream;
import net.multiphasicapps.squirrelquarrel.ui.FrameSync;
import net.multiphasicapps.squirrelquarrel.util.ReplayEventSource;
import net.multiphasicapps.squirrelquarrel.util.ReplayInputStream;
import net.multiphasicapps.squirrelquarrel.util.ReplayOutputStream;

/**
 * This manages and runs the game loop.
 *
 * @since 2018/03/19
 */
public final class GameLooper
{
	/** The output for replay recordings. */
	protected final ReplayOutputStream record;
	
	/** The game to loop for. */
	protected final Game game;
	
	/** The source where events come from. */
	private EventSource _events;
	
	/** The speed the game runs at. */
	private volatile GameSpeed _speed =
		GameSpeed.NORMAL;
	
	/**
	 * Initializes the game looper with the default settings.
	 *
	 * @param __out The stream to write replay data to.
	 * @param __evs The source where events come from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameLooper(OutputStream __out, EventSource __evs)
		throws NullPointerException
	{
		this(__out, __evs, new InitialSettingsBuilder().build());
	}
	
	/**
	 * Initializes the game looper.
	 *
	 * @param __out The stream to write replay data to.
	 * @param __evs The source where events come from.
	 * @param __i The initial settings for the game.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameLooper(OutputStream __out, EventSource __evs,
		InitialSettings __i)
		throws NullPointerException
	{
		if (__out == null || __i == null)
			throw new NullPointerException("NARG");
		
		// Setup replay output for consistent game recording
		ReplayOutputStream record = new ReplayOutputStream(__out);
		this.record = record;
		__i.demoRecord(record);
		
		// Initialize the game with basic settings
		this.game = new Game(__i);
		
		// Set event source which is used per-frame to control players
		this._events = __evs;
	}
	
	/**
	 * Returns the event source in use.
	 *
	 * @return The event source in use.
	 * @since 2019/03/24
	 */
	public final EventSource eventSource()
	{
		return this._events;
	}
	
	/**
	 * Returns the game this provides a loop for.
	 *
	 * @return The game being looped.
	 * @since 2018/03/18
	 */
	public final Game game()
	{
		return this.game;
	}
	
	/**
	 * Runs multiple game frames.
	 *
	 * @param __fs Callback for when game frames are updated.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public void run(FrameSync __fs)
		throws NullPointerException
	{
		if (__fs == null)
			throw new NullPointerException("NARG");
		
		Game game = this.game;
		for (;;)
		{
			// Get the current game speed and entry time
			GameSpeed speed = this._speed;
			long enter = System.nanoTime();
			
			// Run a single game cycle
			int nowframe = game.frameCount();
			game.run();
			
			// Debug
			todo.DEBUG.note("Ran %d", nowframe);
			
			// Request a repaint if there is enough time to draw
			long exit = System.nanoTime();
			if ((exit - enter) < speed.nanoFrameTime())
				__fs.frameRepaintRequest(nowframe);
			
			// Delay thread for the next frame
			exit = System.nanoTime();
			long durr = (speed.nanoFrameTime() - (exit - enter)) / 1_000_000L;
			if (durr > 0)
				try
				{
					Thread.sleep(durr);
				}
				catch (InterruptedException e)
				{
				}
		}
	}
	
	/**
	 * Runs a single game frame.
	 *
	 * @since 2018/03/19
	 */
	public void runFrame()
	{
	}
	
	/**
	 * Sets the event source.
	 *
	 * @param __es The event source to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public final void setEventSource(EventSource __es)
		throws NullPointerException
	{
		if (__es == null)
			throw new NullPointerException("NARG");
		
		this._events = __es;
	}
	
	/**
	 * Initialize a game loop which either resumes the game from the given
	 * point or plays it back in a replay.
	 *
	 * @param __out The output for replay data.
	 * @param __rm How will the game be resumed?
	 * @param __in The input stream for replay/save data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public static final GameLooper resume(OutputStream __out,
		ResumeMode __rm, InputStream __in)
		throws NullPointerException
	{
		if (__out == null || __rm == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Setup input replay strema
		ReplayInputStream replay = new ReplayInputStream(__in);
		
		// Read initial settings from the replay and initialize the game
		InitialSettings init = InitialSettings.demoReplay(replay);
		GameLooper rv = new GameLooper(__out,
			new ReplayEventSource(replay), init);
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/GameSpeed.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
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





































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This represents the game speed which determines the amount of time between
 * frames.
 *
 * @since 2017/02/10
 */
public enum GameSpeed
{
	/** Slowest. */
	SLOWEST(167),
	
	/** Slower. */
	SLOWER(111),
	
	/** Slow. */
	SLOW(83),
	
	/** Normal. */
	NORMAL(67),
	
	/** Fast. */
	FAST(56),
	
	/** Faster. */
	FASTER(48),
	
	/** Fastest. */
	FASTEST(42),	
	
	/** End. */
	;
	
	/** The speed of normal. */
	private static final int _NORMAL_SPEED =
		67;
	
	/** Milliseconds between frames. */
	protected final int msbetweenframes;
	
	/** Nanoseconds between frames. */
	protected final int nsbetweenframes;
	
	/**
	 * Initializes the game speed.
	 *
	 * @param __msbf Milliseconds between frames.
	 * @since 2017/02/10
	 */
	private GameSpeed(int __msbf)
	{
		this.msbetweenframes = __msbf;
		this.nsbetweenframes = __msbf * 1_000_000;
	}
	
	/**
	 * Returns the game speed which is faster than this one.
	 *
	 * @return The faster game speed.
	 * @since 2017/02/12
	 */
	public GameSpeed faster()
	{
		// Depends
		switch (this)
		{
			case SLOWEST:	return SLOWER;
			case SLOWER:	return SLOW;
			case SLOW:		return NORMAL;
			case NORMAL:	return FAST;
			case FAST:		return FASTER;
			case FASTER:	return FASTEST;
			default:
				return this;
		}
	}
	
	/**
	 * Returns the duration of a single frame in nanoseconds.
	 *
	 * @return The frame duration in nanoseconds.
	 * @since 2017/02/10
	 */
	public int nanoFrameTime()
	{
		return this.nsbetweenframes;
	}
	
	/**
	 * Returns the ratio this game speed and the normal game speed.
	 *
	 * @return The ratio between speeds.
	 * @since 2017/02/12
	 */
	public double ratio()
	{
		return (double)this.msbetweenframes / _NORMAL_SPEED;
	}
	
	/**
	 * Returns the game speed which is slower than this one.
	 *
	 * @return The slower game speed.
	 * @since 2017/02/12
	 */
	public GameSpeed slower()
	{
		// Depends
		switch (this)
		{
			case SLOWER:	return SLOWEST;
			case SLOW:		return SLOWER;
			case NORMAL:	return SLOW;
			case FAST:		return NORMAL;
			case FASTER:	return FAST;
			case FASTEST:	return FASTER;
			default:
				return this;
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/InitialSettings.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.util.ReplayInputStream;
import net.multiphasicapps.squirrelquarrel.util.ReplayFormatException;
import net.multiphasicapps.squirrelquarrel.util.ReplayOutputStream;

/**
 * This contains the initial settings which is used to determine how to
 * generate and initialize the initial game.
 *
 * @since 2017/02/09
 */
public final class InitialSettings
{
	/** Magic number for initial settings. */
	private static final long _MAGIC_NUMBER =
		0x53715872FF00FFFFL;
	
	/** The width of the map in tiles. */
	protected final int mapwidth;
	
	/** The height of the map in tiles. */
	protected final int mapheight;
	
	/** The number of players playing the game. */
	protected final int players;
	
	/** The level seed. */
	protected final long seed;
	
	/** The timestamp the game started. */
	protected final long timestamp;
	
	/** How the teams are laid out. */
	private final int[] _teams;
	
	/**
	 * Initializes the initial settings.
	 *
	 * @param __b The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/09
	 */
	InitialSettings(InitialSettingsBuilder __b)
		throws NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.mapwidth = __b._mapwidth;
		this.mapheight = __b._mapheight;
		this.seed = __b._seed;
		this.timestamp = __b._timestamp;
		this.players = __b._players;
		this._teams = __b._teams.clone();
	}
	
	/**
	 * Writes the settings to the given replay output stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public final void demoRecord(ReplayOutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		int players;
		
		__out.writeLong(InitialSettings._MAGIC_NUMBER);
		__out.writeLong(this.timestamp);
		__out.writeLong(this.seed);
		__out.writeInt(this.mapwidth);
		__out.writeInt(this.mapheight);
		__out.writeByte((players = this.players));
		
		// Write team data
		int[] teams = this._teams;
		for (int i = 0; i < players; i++)
			__out.writeByte(teams[i]);
	}
	
	/**
	 * Returns the height of the map.
	 *
	 * @return The height of the map.
	 * @since 2017/02/10
	 */
	public final int mapHeight()
	{
		return this.mapheight;
	}
	
	/**
	 * Returns the width of the map.
	 *
	 * @return The width of the map.
	 * @since 2017/02/10
	 */
	public final int mapWidth()
	{
		return this.mapwidth;
	}
	
	/**
	 * Returns the number of players playing the game.
	 *
	 * @return The players playing the game.
	 * @since 2018/03/19
	 */
	public final int players()
	{
		return this.players;
	}
	
	/**
	 * Returns the seed for the map and game events.
	 *
	 * @return The game seed.
	 * @since 2017/02/10
	 */
	public final long seed()
	{
		return this.seed;
	}
	
	/**
	 * Returns the starting timestamp of the game.
	 *
	 * @return The starting timestamp of the game.
	 * @since 2018/03/19
	 */
	public final long startTimeMillis()
	{
		return this.timestamp;
	}
	
	/**
	 * Returns how the teams are laid out.
	 *
	 * @return The team layout.
	 * @since 2018/03/19
	 */
	public final int[] teams()
	{
		// Copy base teams first
		int[] teams = this._teams,
			rv = new int[PlayerColor.NUM_COLORS];
		for (int i = 0, n = teams.length; i < n; i++)
			rv[i] = teams[i];
		
		// Always place creeps and neutral players on their own team
		rv[PlayerColor.CREEPS.ordinal()] = PlayerColor.CREEPS.ordinal();
		rv[PlayerColor.NEUTRAL.ordinal()] = PlayerColor.NEUTRAL.ordinal();
		
		return rv;
	}
	
	/**
	 * Reads the initial settings from the replay input.
	 *
	 * @param __in The stream to read from.
	 * @return The initial settings.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public static final InitialSettings demoReplay(ReplayInputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE01 Invalid initial settings magic number.
		// (The read magic number)}
		long magic = __in.readLong();
		if (magic != InitialSettings._MAGIC_NUMBER)
			throw new ReplayFormatException(String.format("BE01 %08x", magic));
		
		int players;
		
		InitialSettingsBuilder rv = new InitialSettingsBuilder();
		
		rv.startTimeMillis(__in.readLong());
		rv.seed(__in.readLong());
		rv.mapSize(__in.readInt(), __in.readInt());
		rv.players((players = __in.readByte()));
		
		// Read in teams
		int[] teams = new int[players];
		for (int i = 0; i < players; i++)
			teams[i] = __in.readByte();
		rv.teams(teams);
		
		return rv.build();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/InitialSettingsBuilder.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
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































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;

/**
 * This is used to build the initial settings for the game.
 *
 * This class is not thread safe.
 *
 * @since 2017/02/09
 */
public class InitialSettingsBuilder
{
	/** How the teams are laid out. */
	final int[] _teams =
		new int[PlayerColor.MAX_PLAYERS];
	
	/** The time these settings were created. */
	volatile long _timestamp =
		System.currentTimeMillis();
	
	/** The width of the map in tiles. */
	volatile int _mapwidth =
		64;
	
	/** The height of the map in tiles. */
	volatile int _mapheight =
		64;
	
	/** The players playing in the game. */
	volatile int _players =
		2;
	
	/** The seed to use. */
	volatile long _seed =
		System.currentTimeMillis();
	
	/**
	 * Initializes some more complex settings.
	 *
	 * @since 2018/03/19
	 */
	{
		// Start off all players on their own team (FFA)
		int[] teams = this._teams;
		for (int i = 0, n = teams.length; i < n; i++)
			teams[i] = i;
	}
	
	/**
	 * Builds the settings.
	 *
	 * @return The resulting settings.
	 * @since 2017/02/09
	 */
	public InitialSettings build()
	{
		return new InitialSettings(this);
	}
	
	/**
	 * Sets the map size in tiles. If an input dimension is not valid then it
	 * will be corrected.
	 *
	 * @param __w The width of the map.
	 * @param __h The height of the map.
	 * @since 2017/02/10
	 */
	public void mapSize(int __w, int __h)
	{
		this._mapwidth = Math.max(MegaTile.TILES_PER_MEGA_TILE,
			(__w - (__w % MegaTile.TILES_PER_MEGA_TILE)));
		this._mapheight = Math.max(MegaTile.TILES_PER_MEGA_TILE,
			(__h - (__w % MegaTile.TILES_PER_MEGA_TILE)));
	}
	
	/**
	 * Sets the number of players that are playing in the game.
	 *
	 * @param __p The players that are playing in the game.
	 * @since 2018/03/19
	 */
	public void players(int __p)
	{
		// Allow one player in the event one wants to play alone for any given
		// reason
		this._players = Math.max(1, Math.min(PlayerColor.MAX_PLAYERS, __p));
	}
	
	/**
	 * Sets the seed to use for random generation.
	 *
	 * @param __s The seed to use.
	 * @since 2017/02/10
	 */
	public void seed(long __s)
	{
		this._seed = __s;
	}
	
	/**
	 * Sets the timestamp of the game start time.
	 *
	 * @param __t The time the game started.
	 * @since 2018/03/19
	 */
	public void startTimeMillis(long __t)
	{
		this._timestamp = __t;
	}
	
	/**
	 * Sets how the teams are to be laid out.
	 *
	 * @param __t Array containing the teams to be laid out.
	 * @since 2018/03/19
	 */
	public void teams(int... __t)
	{
		if (__t == null)
			__t = new int[0];
		
		// Store input values first
		int[] teams = this._teams;
		int n = __t.length;
		for (int i = 0; i < n; i++)
			teams[i] = __t[i];
		for (int i = n; i < PlayerColor.MAX_PLAYERS; i++)
			teams[i] = i;
		
		// Store values into a normalization map to correct indexes
		int next = 0;
		Map<Integer, Integer> normalize = new HashMap<>();
		for (int i = 0; i < PlayerColor.MAX_PLAYERS; i++)
		{
			Integer k = teams[i];
			if (!normalize.containsKey(k))
				normalize.put(k, i);
		}
		
		// Map all values to their normalized values
		for (int i = 0; i < PlayerColor.MAX_PLAYERS; i++)
			teams[i] = normalize.get(teams[i]);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/ResumeMode.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.game;

/**
 * This specifies how a game is to be resumed when an input stream is input.
 *
 * @since 2018/03/19
 */
public enum ResumeMode
{
	/** Treat it as a saved game. */
	SAVED_GAME,
	
	/** Treat it as a replay. */
	REPLAY,
	
	/** End. */
	;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/game/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the main game related functions.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.game;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/Automap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228




































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.squirrelquarrel.world.World;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.ui.Viewport;

/**
 * This class is used to draw and update the automap which is used to give the
 * position of terrain and objects around the map. This class handles the
 * drawing aspects of it.
 *
 * @since 2017/02/12
 */
public class Automap
{
	/** The viewport which stores where the screen is looking. */
	protected final Viewport viewport;
	
	/** The level to draw on. */
	protected final World world;
	
	/** The background terrain image. */
	protected final Image terrain;
	
	/** The active image to draw of the automap. */
	protected final Image active;
	
	/** This is used much. */
	protected final Graphics graphics;
	
	/** The automap width. */
	protected final int width;
	
	/** The automap height. */
	protected final int height;
	
	/** The level width in pixels. */
	protected final int levelpxw;
	
	/** The level height in pixels. */
	protected final int levelpxh;
	
	/**
	 * Initializes the automap.
	 *
	 * @param __v The viewport into the game.
	 * @param __w The automap width.
	 * @param __h The automap height.
	 * @throws NullPointerException On null arguments
	 * @since 2017/02/12
	 */
	public Automap(Viewport __v, int __w, int __h)
		throws NullPointerException
	{
		throw new todo.TODO();
		/*
		// Check
		if (__gi == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.gameinterface = __gi;
		this.width = __w;
		this.height = __h;
		
		// Save active image for later
		Image active = Image.createImage(__w, __h);
		this.active = active;
		this.graphics = active.getGraphics();
		
		// Get level size
		Level level = __gi.level();
		this.level = level;
		int levelpxw = level.pixelWidth(),
			levelpxh = level.pixelHeight();
		this.levelpxw = levelpxw;
		this.levelpxh = levelpxh;
		
		// However, initialize the terrain layer now
		Image terrain = Image.createImage(__w, __h);
		this.terrain = terrain;
		__drawLayer(terrain.getGraphics(), false);
		*/
	}
	
	/**
	 * Returns the height of the automap.
	 *
	 * @return The automap height.
	 * @since 2017/02/12
	 */
	public int height()
	{
		return this.height;
	}
	
	/**
	 * Updates the automap and returns it.
	 *
	 * @return The updated automap.
	 * @since 2017/02/12
	 */
	public Image update()
	{
		throw new todo.TODO();
		/*
		GameInterface gameinterface = this.gameinterface;
		Image terrain = this.terrain;
		Image active = this.active;
		Graphics graphics = this.graphics;
		int width = this.width,
			height = this.height,
			levelpxw = this.levelpxw,
			levelpxh = this.levelpxh;
		
		// Full alpha
		graphics.setAlpha(0xFF);
		
		// Draw the terrain over the map
		graphics.drawImage(terrain, 0, 0, 0);
		
		// Draw the fog
		__drawLayer(graphics, true);
		
		// Draw units
		graphics.setAlpha(0xFF);
		
		// Draw where the viewport is in the automap
		graphics.setAlpha(0xFF);
		graphics.setColor(0x00FFFF);
		int viewx = gameinterface.viewportX(),
			viewy = gameinterface.viewportY(),
			vieww = gameinterface.viewportWidth(),
			viewh = gameinterface.viewportHeight();
		double pvx = width * ((double)viewx / (double)levelpxw),
			pvy = height * ((double)viewy / (double)levelpxh),
			pvw = width * ((double)vieww / (double)levelpxw),
			pvh = height * ((double)viewh / (double)levelpxh);
		graphics.drawRect((int)pvx, (int)pvy, (int)pvw, (int)pvh);
		
		// Draw a nice border around the map
		graphics.setColor(0xFFFFFF);
		graphics.drawRect(0, 0, width - 2, height - 2);
		
		// Return the active map
		return this.active;
		*/
	}
	
	/**
	 * Returns the width of the automap.
	 *
	 * @return The automap width.
	 * @since 2017/02/12
	 */
	public int width()
	{
		return this.width;
	}
	
	/**
	 * Draws a layer on the specified graphics.
	 *
	 * @param __g The target graphics to draw on.
	 * @param __fog If {@code true} then fog is drawn instead of tiles.
	 * @since 2017/02/15
	 */
	private void __drawLayer(Graphics __g, boolean __fog)
		throws NullPointerException
	{
		throw new todo.TODO();
		/*
		// Check
		if (__g == null)
			throw new NullPointerException("NARG");
		
		Player player = this.gameinterface.player();
		Level level = this.level;
		int width = this.width,
			height = this.height,
			levelpxw = this.levelpxw,
			levelpxh = this.levelpxh;
		
		// If drawing fog, keep it light
		if (__fog)
			__g.setAlphaColor(0xAF000000);
		
		// Otherwise terrain is always visible
		else
			__g.setAlpha(0xFF);
		
		// Drawing loop
		for (double sy = 0, dy = 0, msx = (double)levelpxw / width,
			msy = (double)levelpxh / height, enddy = height,
			enddx = width; dy < enddy; sy += msy, dy += 1)
			for (double sx = 0, dx = 0; dx < enddx; sx += msx, dx += 1)
			{
				// Do not draw over revealed areas
				if (__fog)
				{
					if (level.pixelRevealed(player, (int)sx, (int)sy))
						continue;
				}
				
				// Use terrain color
				else
					__g.setColor(
						level.pixelTerrain((int)sx, (int)sy).color());
				
				// Draw single pixel as a line
				__g.drawLine((int)dx, (int)dy, (int)dx + 1, (int)dy);
			}
		*/
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/ControllerEventSource.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import net.multiphasicapps.squirrelquarrel.game.EventSource;
import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;

/**
 * Event source which grabs from the player's controller.
 *
 * @since 2019/03/24
 */
public class ControllerEventSource
	implements EventSource
{
	/** Game to control. */
	protected final Game game;
	
	/** Split-screen to determine which player is doing the action. */
	protected final SplitScreen splitscreen;
	
	/**
	 * Initializes the event source.
	 *
	 * @param __g The game used.
	 * @param __ss The split-screen for play.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public ControllerEventSource(Game __g, SplitScreen __ss)
		throws NullPointerException
	{
		if (__g == null || __ss == null)
			throw new NullPointerException("NARG");
		
		this.game = __g;
		this.splitscreen = __ss;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/GameInputHandler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236












































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.KeyListener;
import net.multiphasicapps.squirrelquarrel.world.Tile;

/**
 * This handles the input for the game such as which keys are held down and
 * buttons for perfomring actions.
 *
 * @since 2017/02/12
 */
public class GameInputHandler
	implements KeyListener, Runnable
{
	/** The maximum number of supported game actions. */
	public static final int GAME_ACTION_COUNT =
		16;
	
	/** Level panning speed. */
	private static final int _PANNING_SPEED =
		Tile.PIXEL_SIZE / 2;
	
	/** The game keys which are held down. */
	protected final boolean[] gamekeys =
		new boolean[GAME_ACTION_COUNT];
	
	/** Is on the automap dragging? */
	private volatile boolean _ondragmap;
	
	/** Disable automap drag. */
	private volatile boolean _nomapdrag;
	
	/**
	 * Initializes the input handler for the game.
	 *
	 * @since 2017/02/12
	 */
	public GameInputHandler()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyPressed(int __code, int __mods)
	{
		throw new todo.TODO();
		/*
		// Parse key and set the game action as being pressed
		try
		{
			int ga = this.gameinterface.getGameAction(__code);
			if (ga >= 0 && ga < GAME_ACTION_COUNT)
				this.gamekeys[ga] = true;
		}
		
		// Ignore, not a valid game action
		catch (IllegalArgumentException e)
		{
		}*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyReleased(int __code, int __mods)
	{
		throw new todo.TODO();
		/*
		// Parse key and set the game action as being released
		GameInterface gameinterface = this.gameinterface;
		try
		{
			int ga = gameinterface.getGameAction(__code);
			if (ga >= 0 && ga < GAME_ACTION_COUNT)
				this.gamekeys[ga] = false;
		}
		
		// Ignore, not a valid game action
		catch (IllegalArgumentException e)
		{
		}
		
		// Increase the game speed
		if (__code == '=' || __code == '+')
			gameinterface.setGameSpeed(gameinterface.gameSpeed().faster());
		
		// Lower the game speed
		else if (__code == '-' || __code == '_')
			gameinterface.setGameSpeed(gameinterface.gameSpeed().slower());*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void keyRepeated(int __code, int __mods)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Call when the pointer is dragged.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerDragged(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		__checkAutomapDrag(true, __x, __y);*/
	}
	
	/**
	 * Call when the pointer is pressed.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerPressed(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		__checkAutomapDrag(false, __x, __y);*/
	}
	
	/**
	 * Call when the pointer is released.
	 *
	 * @param __x X position.
	 * @param __y Y position.
	 * @since 2017/02/12
	 */
	protected void pointerReleased(int __x, int __y)
	{
		throw new todo.TODO();
		/*
		// Cannot be dragging on the map
		this._ondragmap = false;
		this._nomapdrag = false;*/
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	public void run()
	{
		throw new todo.TODO();
		/*
		GameInterface gameinterface = this.gameinterface;
		boolean[] gamekeys = this.gamekeys;
		
		// Pan the viewport?
		double gsratio = gameinterface.gameSpeed().ratio();
		double xpan = _PANNING_SPEED * (gamekeys[Canvas.LEFT] ? -gsratio :
			(gamekeys[Canvas.RIGHT] ? gsratio : 0)),
			ypan = _PANNING_SPEED * (gamekeys[Canvas.UP] ? -gsratio :
			(gamekeys[Canvas.DOWN] ? gsratio : 0));
		gameinterface.translateViewport((int)xpan, (int)ypan);*/
	}
	
	/**
	 * Checks for dragging on the automap.
	 *
	 * @param __x The cursor X position.
	 * @param __y The cursor Y position.
	 * @param __drag Is this a drag?
	 * @since 2017/02/13
	 */
	private void __checkAutomapDrag(boolean __drag, int __x, int __y)
	{
		throw new todo.TODO();
		/*
		// Get the automap
		GameInterface gameinterface = this.gameinterface;
		Automap automap = gameinterface.automap();
		int amw = automap.width(),
			amh = automap.height(),
			vw = gameinterface.viewportWidth(),
			vh = gameinterface.viewportHeight(),
			amby = (vh - amh);
		
		// If the cursor is where the automap would be
		// However, if the automap was dragged on, always drag
		if (this._ondragmap ||
			(__x >= 0 && __x < amw && __y >= amby && __y < vh))
		{
			// Press was not on the map, so do not drag even if it enters
			// range
			if (__drag && this._nomapdrag)
				return;
			
			Level level = gameinterface.level();
			int lpxw = level.pixelWidth(),
				lpxh = level.pixelHeight();
			
			// Calculate viewport position
			double vx = (__x) * ((double)lpxw / amw),
				vy = (__y - amby) * ((double)lpxh / amh);
			gameinterface.setViewport(
				((int)vx) - (vw / 2),
				((int)vy) - (vh / 2));
			
			// Keep dragging on the map
			this._ondragmap = true;
		}
		
		// Initial click outside of the map, do not drag on it
		else
		{
			if (!__drag)
				this._nomapdrag = true;
		}*/
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/GameInterface.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
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





































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.KeyListener;
import net.multiphasicapps.squirrelquarrel.game.EventSource;
import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.ui.FrameSync;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;

/**
 * This class provides an interface to the game, allowing for input to be
 * handled along with the game itself.
 *
 * @since 2017/02/08
 */
public final class GameInterface
	extends Canvas
	implements FrameSync
{
	/** The game being played. */
	protected final GameLooper looper;
	
	/** Splitscreen. */
	protected final SplitScreen splitscreen;
	
	/** The renderer for the game. */
	protected final Renderer renderer;
	
	/** Controller input. */
	protected final ControllerEventSource controller;
	
	/**
	 * Initializes the game interface.
	 *
	 * @param __g The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public GameInterface(GameLooper __g)
		throws NullPointerException
	{
		if (__g == null)
			throw new NullPointerException("NARG");
		
		// Setup details
		setTitle("Squirrel Quarrel");
		
		this.looper = __g;
		SplitScreen splitscreen;
		this.splitscreen = (splitscreen = new SplitScreen(__g));
		this.renderer = new Renderer(__g, splitscreen);
		
		// Setup basic controller events
		ControllerEventSource controller = new ControllerEventSource(
			__g.game(), splitscreen);
		this.controller = controller;
		
		// If there is no source for events, just use controller events
		// generated from the user
		EventSource eswas = __g.eventSource();
		if (eswas == null)
			__g.setEventSource(controller);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	public final void frameRepaintRequest(int __framenum)
	{
		// Just have it get repainted
		this.repaint();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/03/18
	 */
	@Override
	public void paint(Graphics __g)
	{
		// Get the canvas size
		int cw = this.getWidth(),
			ch = this.getHeight();
		
		// Configure splitscreens
		SplitScreen splitscreen = this.splitscreen;
		splitscreen.configure(cw, ch);
		
		// Store the original clip
		int ox = __g.getClipX(),
			oy = __g.getClipY(),
			ow = __g.getClipWidth(),
			oh = __g.getClipHeight();
		
		// Draw every screen
		Renderer renderer = this.renderer;
		for (int i = 0, n = splitscreen.count(); i < n; i++)
		{
			// Restore drawing parameters
			__g.translate(-__g.getTranslateX(), -__g.getTranslateY());
			__g.setClip(ox, oy, ow, oh);
			
			// Draw the screen
			renderer.paint(splitscreen.get(i), __g);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerDragged(int __x, int __y)
	{
		todo.DEBUG.note("pointerDragged(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerPressed(int __x, int __y)
	{
		todo.DEBUG.note("pointerPressed(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/12
	 */
	@Override
	protected void pointerReleased(int __x, int __y)
	{
		todo.DEBUG.note("pointerReleased(%d, %d)", __x, __y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	protected void sizeChanged(int __w, int __h)
	{
		// Super-class might do some things
		super.sizeChanged(__w, __h);
		
		// Reconfigure the screens
		this.splitscreen.configure(__w, __h);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/MainMidlet.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
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




























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.game.ResumeMode;

/**
 * This is the main midlet entry point for Squirrel Quarrel.
 *
 * @since 2017/02/08
 */
public class MainMidlet
	extends MIDlet
{
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	protected void destroyApp(boolean __uc)
		throws MIDletStateChangeException
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/08
	 */
	@Override
	protected void startApp()
		throws MIDletStateChangeException
	{
		// Get the display for this MIDlet
		Display disp = Display.getDisplay(this);
		
		// For initial testing purposes, this will setup and play a game
		// then once it finishes it will reload it and allow watching the
		// game which was just played
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			// Setup game with the loop
			GameLooper looper = new GameLooper(baos, null);
			
			// Setup game canvas with an initial game
			GameInterface gi = new GameInterface(looper);
			disp.setCurrent(gi);
			
			// Run the game itself until it terminates
			looper.run(gi);
			
			// When the game finishes just play it back and hope it worked!
			baos.flush();
			try (ByteArrayInputStream bais = new ByteArrayInputStream(
				baos.toByteArray()))
			{
				// Setup new loop resuming from the save game but using it
				// as a replay
				looper = GameLooper.resume(null, ResumeMode.REPLAY, bais);
				
				// Setup new canvas to show that game instead
				gi = new GameInterface(looper);
				disp.setCurrent(gi);
				
				// Run the game logic in that
				looper.run(gi);
			}
		}
		
		// {@squirreljme.error BE02 Failed to rea/write something.}
		catch (IOException e)
		{
			throw new RuntimeException("BE02", e);
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/MegaTileCacher.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import cc.squirreljme.runtime.lcdui.image.XPMReader;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.squirrelquarrel.world.World;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;
import net.multiphasicapps.squirrelquarrel.world.TerrainType;
import net.multiphasicapps.squirrelquarrel.world.Tile;

/**
 * This is used to cache mega tiles as single large images since drawing a
 * large image is faster than drawing many smaller images.
 *
 * @since 2017/02/11
 */
public class MegaTileCacher
{
	/** The cache of terrain tiles. */
	private static final Map<TerrainType, Reference<Image>> _TILE_CACHE =
		new HashMap<>();
	
	/** The level to cache for. */
	protected final World world;
	
	/** The cache of tiles. */
	protected final Map<MegaTile, Reference<Image>> cache =
		new HashMap<>();
	
	/**
	 * Initializes the mega tile cacher.
	 *
	 * @param __l The level to cache for.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public MegaTileCacher(World __l)
		throws NullPointerException
	{
		// Check
		if (__l == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.world = __l;
	}
	
	/**
	 * Caches the image for the given megatile.
	 *
	 * @param __x The X coordinate in megatiles.
	 * @param __y The Y coordinate in megatiles.
	 * @return The cached image for the given mega tile.
	 * @since 2017/02/11
	 */
	public Image cacheMegaTile(int __x, int __y)
	{
		return cacheMegaTile(this.world.megaTile(__x, __y));
	}
	
	/**
	 * Caches the image for the given megatile.
	 *
	 * @param __mt The mega tile to cache.
	 * @return The cached image for the given mega tile.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/11
	 */
	public Image cacheMegaTile(MegaTile __mt)
		throws NullPointerException
	{
		// Check
		if (__mt == null)
			throw new NullPointerException("NARG");
		
		Map<MegaTile, Reference<Image>> cache = this.cache;
		Reference<Image> ref = cache.get(__mt);
		Image rv = null;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
		{
			// Create image to draw on
			rv = Image.createImage(MegaTile.PIXEL_SIZE,
				MegaTile.PIXEL_SIZE);
			
			// Draw on it
			Graphics g = rv.getGraphics();
			
			// Do not need to check cache for the same tile
			TerrainType oldtype = null;
			Image tilepic = null;
			
			// Go through the megatile to draw
			for (int ty = 0, dy = 0; ty < MegaTile.TILES_PER_MEGA_TILE;
				ty++, dy += Tile.PIXEL_SIZE)
				for (int tx = 0, dx = 0; tx < MegaTile.TILES_PER_MEGA_TILE;
					tx++, dx += Tile.PIXEL_SIZE)
				{
					// If the terrain type is the same then use the existing
					// image of it rather than checking the cache every
					// single time
					TerrainType type = __mt.subTileTerrain(tx, ty);
					if (type != oldtype)
					{
						oldtype = type;
						tilepic = __cacheTile(type);
					}
					
					// Draw it
					g.drawImage(tilepic, dx, dy, 0);
				}
			
			// Cache
			this.cache.put(__mt, new WeakReference<>(rv));
		}
		
		return rv;
	}
	
	/**
	 * Caches the specified tile.
	 *
	 * @param __t The terrain to get the image for.
	 * @return The image for the given terrain.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	private static final Image __cacheTile(TerrainType __t)
		throws NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		// Get ref
		Reference<Image> ref = _TILE_CACHE.get(__t);
		Image rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			try
			{
				_TILE_CACHE.put(__t, new WeakReference<>(
					(rv = new XPMReader(__t.imageStream()).parse())));
			}
			
			// {@squirreljme.error BE03 Failed to read the image data for the
			// specified file. (The terrain type)}
			catch (IOException e)
			{
				throw new RuntimeException(String.format("BE03 %s", __t), e);
			}
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/Renderer.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261





































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.lcdui;

import java.util.ArrayList;
import java.util.List;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.ui.FrameSync;
import net.multiphasicapps.squirrelquarrel.ui.GameScreen;
import net.multiphasicapps.squirrelquarrel.ui.SplitScreen;
import net.multiphasicapps.squirrelquarrel.units.UnitReference;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;

/**
 * This contains the renderer for the level and performs the actual drawing
 * of the game to the canvas.
 *
 * @since 2018/03/18
 */
public final class Renderer
{
	/** The game looper to draw. */
	protected final GameLooper looper;
	
	/** The splitscreens to have viewports for. */
	protected final SplitScreen splitscreen;
	
	/**
	 * Initializes the renderer.
	 *
	 * @param __g The game looper to use.
	 * @param __ss The splitscreen to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Renderer(GameLooper __g, SplitScreen __ss)
		throws NullPointerException
	{
		if (__g == null || __ss == null)
			throw new NullPointerException("NARG");
		
		this.looper = __g;
		this.splitscreen = __ss;
	}
	
	/**
	 * Paints the game to the given graphics.
	 *
	 * @param __src The screen to draw for.
	 * @param __g The graphics to draw on.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/08
	 */
	public void paint(GameScreen __scr, Graphics __g)
		throws NullPointerException
	{
		if (__scr == null || __g == null)
			throw new NullPointerException("NARG");
		
		// Get basic information
		Player player = __scr.player();
		PlayerColor playercolor = player.color();
		int sx = __scr.x(),
			sy = __scr.y(),
			sw = __scr.width(),
			sh = __scr.height();
		
		/*
		// If already painting, do not duplicate a paint
		if (this._inpaint)
			return;
		this._inpaint = true;
		
		// Get the current frame the game is on
		Game game = this.game;
		this._renderframe = game.frameCount();
		Level level = game.level();
		int framenum = game.frameCount();
		Player viewplayer = this._viewplayer;
		
		// Get the viewport
		int viewx = this._viewx,
			viewy = this._viewy,
			vieww = this._vieww,
			viewh = this._viewh;
		
		// MegaTiles do not often change
		MegaTileCacher mtcacher = this.mtcacher;
		
		// Megatile draw loop
		int msx = this._msx,
			msy = this._msy,
			mex = this._mex,
			mey = this._mey;
		for (int my = msy,
			sy = mapToScreenY(my * MegaTile.MEGA_TILE_PIXEL_SIZE),
			bsx = mapToScreenX(msx * MegaTile.MEGA_TILE_PIXEL_SIZE);
			my < mey; my++, sy += MegaTile.MEGA_TILE_PIXEL_SIZE)
			for (int mx = msx, sx = bsx; mx < mex; mx++,
				sx += MegaTile.MEGA_TILE_PIXEL_SIZE)
			{
				// Get the megatile here
				MegaTile mt = level.megaTile(mx, my);
				
				// Draw it
				__g.drawImage(mtcacher.cacheMegaTile(mt), sx, sy, 0);
					
				// Draw units in this mega tile
				__drawUnits(__g, mt);
				
				// Setup flags for fog drawing
				__g.setColor(0x000000);
				__g.setStrokeStyle(Graphics.DOTTED);
				
				// Draw fog scanlines
				for (int sty = 0, psy = sy, bpsx = sx;
					sty < MegaTile.TILES_PER_MEGA_TILE;
					sty++, psy += MegaTile.TILE_PIXEL_SIZE)
					for (int stx = 0, psx = bpsx;
						stx < MegaTile.TILES_PER_MEGA_TILE;
						stx++, psx += MegaTile.TILE_PIXEL_SIZE)
					{
						// Ignore revealed tiles
						if (mt.subTileRevealed(viewplayer, stx, sty))
							continue;
						
						// Otherwise find the next revealed tile (or the end)
						int end;
						for (end = stx + 1; end < MegaTile.TILES_PER_MEGA_TILE;
							end++)
							if (mt.subTileRevealed(viewplayer, end, sty))
								break;
						
						// Draw dotted lines for fog
						int endpx = sx + (stx * MegaTile.TILE_PIXEL_SIZE) +
							(end * MegaTile.TILE_PIXEL_SIZE),
							endpy = psy + MegaTile.TILE_PIXEL_SIZE;
						for (int py = psy; py < endpy; py++)
						{
							// Lines off to the side can get clipped where the
							// dot patterns stop being correct
							int bx = (psx < 0 ? 0 : psx);
							__g.drawLine(bx + (py & 1), py, endpx, py);
						}
						
						// Set current spot to the end
						stx = end;
						psx = bpsx + (end * MegaTile.TILE_PIXEL_SIZE);
					}
			}
		
		// Reset translation for the HUD
		__g.translate(-__g.getTranslateX(), -__g.getTranslateY());
		
		// Draw the automap in the bottom left corner
		Image map = this.automap.update();
		__g.setAlpha(160);
		__g.drawImage(map, 0, viewh, Graphics.LEFT | Graphics.BOTTOM);
		
		// Draw debug image
		__g.setAlpha(255);
		Image debugimage = this.debugimage;
		int ww = debugimage.getWidth(), hh = debugimage.getHeight();
		int sx = 50 - 5, sy = 50 - 5,
			ex = sx + ((ww * 3) + 10), ey = sy + ((hh * 3) + 10);
		__g.drawRegion(debugimage, 0, 0, ww, hh, Sprite.TRANS_NONE,
			sx + 5, sy + 5, 0, ww * 3, hh * 3);
		__g.setColor(0xFF0000);
		__g.drawLine(sx, sy, ex, sy);
		__g.setColor(0x00FF00);
		__g.drawLine(ex, sy, ex, ey);
		__g.setColor(0x0000FF);
		__g.drawLine(ex, ey, sx, ey);
		__g.setColor(0xFFFF00);
		__g.drawLine(sx, ey, sx, sy);
		
		// No longer painting
		this._inpaint = false;
		*/
		
		// Draw the player's color around the screen
		__g.setColor(playercolor.rgb());
		__g.drawRect(sx, sy, sw - 2, sh - 2);
	}
	
	/**
	 * Draws units in this megatile.
	 *
	 * @param __g The target graphics.
	 * @param __mt The megatile to source from.
	 * @since 2017/02/17
	 */
	private void __drawUnits(Graphics __g, MegaTile __mt)
	{
		throw new todo.TODO();
		/*
		// Store the old clip
		int oldcx = __g.getClipX(),
			oldcy = __g.getClipY(),
			oldcw = __g.getClipWidth(),
			oldch = __g.getClipHeight();
		
		// Used for selection boxes
		__g.setColor(0xFFFF00);
		__g.setStrokeStyle(Graphics.SOLID);
		
		// Set new clipping so units are not drawn outside of the tile and
		// potentially into other tiles
		int mdx = mapToScreenX(__mt.x() * MegaTile.MEGA_TILE_PIXEL_SIZE),
			mdy = mapToScreenY(__mt.y() * MegaTile.MEGA_TILE_PIXEL_SIZE);
		__g.setClip(mdx, mdy, mdx + MegaTile.MEGA_TILE_PIXEL_SIZE,
			mdy + MegaTile.MEGA_TILE_PIXEL_SIZE);
		
		// Load units
		List<Unit.Pointer> drawunits = this._drawunits;
		drawunits.clear();
		__mt.loadLinkedUnits(drawunits);
		
		// Draw them
		for (int i = 0, n = drawunits.size(); i < n; i++)
			try
			{
				// Get unit, and its information
				Unit unit = drawunits.get(i).get();
				UnitType type = unit.type();
				if (type == null)
					continue;
				UnitInfo info = type.info();
				
				// Get draw position on the screen
				int dx = mapToScreenX(unit.centerX()),
					dy = mapToScreenY(unit.centerY());
				
				// Draw sprite
				__g.drawRect(dx - 10, dy - 10, 20, 20);
			}
			
			// Ignore due to threading potential
			catch (UnitDeletedException e)
			{
			}
		
		// Restore the old clip
		__g.setClip(oldcx, oldcy, oldcw, oldch);
		*/
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/lcdui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the LCDUI front-end for Squirrel Quarrel.
 *
 * @since 2017/02/08
 */

package net.multiphasicapps.squirrelquarrel.lcdui;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the implementation of the game, it is used as a
 * library which is implemented by front-ends.
 *
 * @since 2017/02/08
 */

package net.multiphasicapps.squirrelquarrel;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/player/Player.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
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















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.player;

/**
 * This represents a game player, where actions may be performed and such.
 *
 * @since 2017/02/13
 */
public final class Player
{
	/** The color of this player. */
	protected final PlayerColor color;
	
	/** The team of this player. */
	protected final PlayerColor team;
	
	/** Is this player playing? */
	protected final boolean playing;
	
	/** The vision mask for this player. */
	private volatile int _visionmask;
	
	/**
	 * Initializes the game player.
	 *
	 * @param __c The player color.
	 * @param __team The team this player is on.
	 * @param __playing Is this player playing?
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/14
	 */
	public Player(PlayerColor __c, PlayerColor __team, boolean __playing)
		throws NullPointerException
	{
		// Check
		if (__c == null || __team == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.color = __c;
		this.team = __team;
		this.playing = __playing;
		
		// The player always has vision to self
		this._visionmask = __c.mask();
	}
	
	/**
	 * Returns the player color.
	 *
	 * @return The player color.
	 * @since 2017/02/14
	 */
	public final PlayerColor color()
	{
		return this.color;
	}
	
	/**
	 * Is this player playing?
	 *
	 * @return If this player is playing.
	 * @since 2018/03/19
	 */
	public final boolean isPlaying()
	{
		return this.playing;
	}
	
	/**
	 * Returns the team that this player is on.
	 *
	 * @return The team the player is on.
	 * @since 2018/03/19
	 */
	public final PlayerColor team()
	{
		return this.team;
	}
	
	/**
	 * This returns the mask that is used to check the vision bits.
	 *
	 * @return The bits used for vision.
	 * @since 2017/02/13
	 */
	public final int visionMask()
	{
		return this._visionmask;
	}
	
	/**
	 * Runs the player logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/player/PlayerColor.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
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













































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.player;

/**
 * The represents the color of a player.
 *
 * The colors here are from Electronic Art's Accessibility account which
 * specify the set of colors which are best used for all kinds of color
 * blind users to they can differentiate between all the colors.
 *
 * https://twitter.com/ea_accessible/status/968592657848193024
 * https://twitter.com/ea_accessible/status/968595073184092160
 *
 * @since 2017/02/10
 */
public enum PlayerColor
{
	/** Red. */
	RED("Red", 0xDE4949),
	
	/** Yellow. */
	YELLOW("Yellow", 0xFFB937),
	
	/** Green. */
	GREEN("Green", 0x30B06E),
	
	/** Blue. */
	BLUE("Blue", 0x33521E1),
	
	/** Purple. */
	PURPLE("Purple", 0x533364),
	
	/** Gray. */
	GRAY("Gray", 0x5A7D8B),
	
	/** End. */
	;
	
	/** The maximum number of players that can play at once. */
	public static final int MAX_PLAYERS =
		4;
	
	/** The number of player colors. */
	public static final int NUM_COLORS =
		6;
	
	/** Creeps that just annoy you. */
	public static final PlayerColor CREEPS =
		PlayerColor.PURPLE;
	
	/** The neutral player. */
	public static final PlayerColor NEUTRAL =
		PlayerColor.GRAY;
	
	/** The ARGB color code. */
	protected final int argb;
	
	/** The RGB color code. */
	protected final int rgb;
	
	/** The color name. */
	protected final String name;
	
	/**
	 * Initializes the color code.
	 *
	 * @param __name The name of the color.
	 * @param __rgb The RGB used for the player color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	private PlayerColor(String __name, int __rgb)
		throws NullPointerException
	{
		// Check
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.name = __name;
		this.argb = __rgb | 0xFF000000;
		this.rgb = __rgb & 0xFFFFFF;
	}
	
	/**
	 * The ARGB code for the player.
	 *
	 * @return The ARGB color.
	 * @since 2017/02/10
	 */
	public final int argb()
	{
		return this.argb;
	}
	
	/**
	 * The RGB code for the player.
	 *
	 * @return The RGB color.
	 * @since 2017/02/10
	 */
	public final int rgb()
	{
		return this.rgb;
	}
	
	/**
	 * Returns the mask that is used for the player.
	 *
	 * The mask is used for stuff such as alliances, vision, and detection.
	 *
	 * Players outside of the basic four players have no mask.
	 *
	 * @return The player mask.
	 * @since 2017/02/14
	 */
	public final int mask()
	{
		// Only use mask for players that are in the game
		int i = this.ordinal();
		if (i < PlayerColor.MAX_PLAYERS)
			return 1 << i;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
	
	/**
	 * This converts the player ordinal back into the player color.
	 *
	 * @param __i The ordinal.
	 * @return The player color for that ordinal.
	 * @since 2017/02/14
	 */
	public static final PlayerColor of(int __i)
	{
		// Depends
		switch (__i)
		{
				// Normal colors;
			case 0: return RED;
			case 1: return YELLOW;
			case 2: return GREEN;
			case 3: return BLUE;
			case 4: return PURPLE;
			case 5: return GRAY;
			
				// {@squirreljme.error BE04 Player index out of range. (The
				// player index)}
			default:
				throw new IllegalArgumentException(String.format("BE04 %d",
					__i));
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/player/Players.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
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




































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.player;

import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This manages the players which are in the game.
 *
 * @since 2018/03/18
 */
public final class Players
{
	/** Players in the game. */
	private final Player[] _players =
		new Player[PlayerColor.NUM_COLORS];
	
	/**
	 * Initializes the players.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Players(InitialSettings __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Needed to initialize the team a player is on
		int numplayers = __is.players();
		int[] teams = __is.teams();
		
		// Initialize players
		Player[] players = this._players;
		for (int i = 0, n = players.length; i < n; i++)
			players[i] = new Player(PlayerColor.of(i),
				PlayerColor.of(teams[i]), i < numplayers);
	}
	
	/**
	 * Returns the player by the given index.
	 *
	 * @param __i The index of the player to get.
	 * @return The player for the given index.
	 * @throws IllegalArgumentException If the index is not within bounds.
	 * @since 2017/02/14
	 */
	public Player get(int __i)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE05 Invalid player index. (The index)}
		if (__i < 0 || __i >= PlayerColor.NUM_COLORS)
			throw new IllegalArgumentException(String.format("BE05 %d", __i));
		
		return this._players[__i];
	}
	
	/**
	 * Returns the player by the given color.
	 *
	 * @param __p The color to get the player of.
	 * @return The player for the given color.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/14
	 */
	public Player get(PlayerColor __p)
		throws NullPointerException
	{
		// Check
		if (__p == null)
			throw new NullPointerException("NARG");
		
		return this._players[__p.ordinal()];
	}
	
	/**
	 * Runs each individual player.
	 *
	 * @param __framenum The current game frame.
	 * @since 2018/03/18
	 */
	public void run(int __framenum)
	{
		// Run the player logic for each player
		Player[] players = this._players;
		for (int i = 0, n = players.length; i < n; i++)
			players[i].run(__framenum);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/player/Species.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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.player;

/**
 * The represents the species which are available in the game.
 *
 * @since 2017/02/14
 */
public enum Species
{
	/** Not a major species. */
	NONE,
	
	/** Chlorophids, plant based species. */
	CHLOROPHID,
	
	/** End. */
	;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/player/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains player related classes.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.player;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/ui/FrameSync.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

/**
 * This is implemented by classes that need to perform some actions after
 * a game frame has run.
 *
 * @since 2018/03/19
 */
public interface FrameSync
{
	/**
	 * This is called when the game has finished running the game logic
	 * and is requesting that the game be repainted accordingly.
	 *
	 * @param __framenum The frame which has just finished.
	 * @since 2018/03/19
	 */
	public abstract void frameRepaintRequest(int __framenum);
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/ui/GameScreen.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.world.World;

/**
 * This represents a single game screen which contains a viewport and
 * rendering information.
 *
 * @since 2018/03/19
 */
public final class GameScreen
{
	/** The game being looped. */
	protected final GameLooper looper;
	
	/** The player being drawn. */
	protected final Player player;
	
	/** The viewport for the screen. */
	protected final Viewport viewport;
	
	/** The screen X position. */
	private volatile int _sx;
	
	/** The screen Y position. */
	private volatile int _sy;
	
	/** The screen width. */
	private volatile int _sw;
	
	/** The screen height. */
	private volatile int _sh;
	
	/**
	 * Initializes this game screen.
	 *
	 * @param __g The game to draw.
	 * @param __p The player being drawn.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/03/19
	 */
	public GameScreen(GameLooper __g, Player __p)
		throws NullPointerException
	{
		if (__g == null || __p == null)
			throw new NullPointerException("NARG");
		
		this.looper = __g;
		this.player = __p;
		
		// Initialize the viewport
		World world = __g.game().world();
		this.viewport = new Viewport(world.pixelWidth(),
			world.pixelHeight());
	}
	
	/**
	 * Configures this screen.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2018/03/19
	 */
	public final void configure(int __x, int __y, int __w, int __h)
	{
		this._sx = __x;
		this._sy = __y;
		this._sw = __w;
		this._sh = __h;
		
		// Adjust the viewport accordingly
		this.viewport.setSize(__w, __h);
	}
	
	/**
	 * Returns the height.
	 *
	 * @return The height.
	 * @since 2018/03/22
	 */
	public final int height()
	{
		return this._sh;
	}
	
	/**
	 * Returns the player being drawn.
	 *
	 * @return The player to draw.
	 * @since 2018/03/22
	 */
	public final Player player()
	{
		return this.player;
	}
	
	/**
	 * Returns the viewport of the view.
	 *
	 * @return The game viewport.
	 * @since 2018/03/22
	 */
	public final Viewport viewport()
	{
		return this.viewport;
	}
	
	/**
	 * Returns the width.
	 *
	 * @return The width.
	 * @since 2018/03/22
	 */
	public final int width()
	{
		return this._sw;
	}
	
	/**
	 * Returns the X position.
	 *
	 * @return The X position.
	 * @since 2018/03/22
	 */
	public final int x()
	{
		return this._sx;
	}
	
	/**
	 * Returns the Y position.
	 *
	 * @return The Y position.
	 * @since 2018/03/22
	 */
	public final int y()
	{
		return this._sy;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/ui/SplitScreen.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
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








































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.game.Game;
import net.multiphasicapps.squirrelquarrel.game.GameLooper;
import net.multiphasicapps.squirrelquarrel.player.Player;
import net.multiphasicapps.squirrelquarrel.player.PlayerColor;
import net.multiphasicapps.squirrelquarrel.player.Players;

/**
 * This class is used to manage multiple screen spaces so that multiple players
 * can play on the same screen at once.
 *
 * @since 2018/03/19
 */
public final class SplitScreen
{
	/** Screens that may be visible. */
	private final GameScreen[] _screens =
		new GameScreen[PlayerColor.MAX_PLAYERS];
	
	/** The order of the screens. */
	private final PlayerColor[] _order =
		new PlayerColor[PlayerColor.MAX_PLAYERS];
	
	/** The number of visible screens. */
	private volatile int _numscreens =
		1;
	
	/** The width of the surface. */
	private volatile int _surfacew =
		1;
	
	/** The height of the surface. */
	private volatile int _surfaceh =
		1;
	
	/**
	 * Initializes the split screen.
	 *
	 * @param __loop The game being played.
	 * @throws NullPointerException On null arguments.
	 * @since 2108/03/19
	 */
	public SplitScreen(GameLooper __loop)
		throws NullPointerException
	{
		if (__loop == null)
			throw new NullPointerException("NARG");
		
		Players players = __loop.game().players();
		
		GameScreen[] screens = this._screens;
		PlayerColor[] order = this._order;
		
		// Initialize each screen
		int playercount = 0;
		for (int i = 0, n = screens.length; i < n; i++)
		{
			Player p = players.get(i);
			order[i] = p.color();
			screens[i] = new GameScreen(__loop, p);
			if (p.isPlaying())
				playercount++;
		}
		this._numscreens = playercount;
	}
	
	/**
	 * Configure the screens for the given size.
	 *
	 * @param __w The screen width.
	 * @param __h The screen height.
	 * @since 2018/03/19
	 */
	public final void configure(int __w, int __h)
	{
		int numscreens = this._numscreens;
		GameScreen[] screens = this._screens;
		
		// Just get all the player screens for now
		GameScreen a = screens[0],
			b = screens[1],
			c = screens[2],
			d = screens[3];
		
		// These will be used
		int midx = __w >> 1,
			midy = __h >> 1;
		
		// Depends on the screen space
		switch (numscreens)
		{
				// Single player
			case 1:
				a.configure(0, 0, __w, __h);
				break;
				
				// Two players
			case 2:
				// Split vertically for wider screens
				if (__w > __h)
				{
					a.configure(0, 0, midx, __h);
					b.configure(midx, 0, midx, __h);
				}
				
				// Otherwise split horizontally
				else
				{
					a.configure(0, 0, __w, midy);
					b.configure(0, midy, __w, midy);
				}
				break;
				
				// 3/4 player split
			case 3:
			case 4:
			default:
				a.configure(0, 0, midx, midy);
				b.configure(midx, 0, midx, midy);
				c.configure(0, midy, midx, midy);
				d.configure(midx, midy, midx, midy);
				break;
		}
	}
	
	/**
	 * Returns the number of screens to draw.
	 *
	 * @return The screen count.
	 * @since 2018/03/22
	 */
	public final int count()
	{
		return this._numscreens;
	}
	
	/**
	 * Gets the screen from the given index.
	 *
	 * @param __i The screen to get.
	 * @return The given screen.
	 * @throws IndexOutOfBoundsException If the screen is outside of the
	 * player bounds.
	 * @since 2018/03/22
	 */
	public final GameScreen get(int __i)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE06 The game screen which was requested is
		// outside of the player bounds.}
		if (__i < 0 || __i >= this._numscreens)
			throw new IndexOutOfBoundsException("BE06");
		
		return this._screens[this._order[__i].ordinal()];
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/ui/Viewport.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258


































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.ui;

import net.multiphasicapps.squirrelquarrel.world.MegaTile;
import net.multiphasicapps.squirrelquarrel.world.Tile;

/**
 * This represents a viewport into the level, it does not contain any
 * rendering information.
 *
 * @since 2018/03/18
 */
public final class Viewport
{
	/** The level width in pixels. */
	protected final int levelwidth;
	
	/** The level height in pixels. */
	protected final int levelheight;
	
	/** The viewport X position. */
	private volatile int _viewx;
	
	/** The viewport Y position. */
	private volatile int _viewy;
	
	/** The view width. */
	private volatile int _vieww;
	
	/** The view height. */
	private volatile int _viewh;
	
	/** The starting X megatile. */
	private volatile int _msx;
	
	/** The starting Y megatile. */
	private volatile int _msy;
	
	/** The ending X megatile. */
	private volatile int _mex;
	
	/** The ending Y megatile. */
	private volatile int _mey;
	
	/**
	 * Initializes the viewport information.
	 *
	 * @param __lw The level width.
	 * @param __lh The level height.
	 * @throws IllegalArgumentException If the width and/or height are zero or
	 * negative.
	 * @since 2018/03/18
	 */
	public Viewport(int __lw, int __lh)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE07 The viewport cannot have a negative size.}
		if (__lw <= 0 || __lh <= 0)
			throw new IllegalArgumentException("BE07");
		
		this.levelwidth = __lw;
		this.levelheight = __lh;
		
		// Use a default size for the viewport
		this.setSize(1, 1);
	}
	
	/**
	 * Converts a map X coordinate to a screen X coordinate.
	 *
	 * @param __x The input X coordinate.
	 * @return The output X coordinate.
	 * @since 2017/02/12
	 */
	public int mapToScreenX(int __x)
	{
		return __x - this._viewx;
	}
	
	/**
	 * Converts a map Y coordinate to a screen Y coordinate.
	 *
	 * @param __x The input Y coordinate.
	 * @return The output y coordinate.
	 * @since 2017/02/12
	 */
	public int mapToScreenY(int __y)
	{
		return __y - this._viewy;
	}
	
	/**
	 * Sets the viewport position.
	 *
	 * @param __x The absolute X position.
	 * @param __y The absolute Y position.
	 * @since 2017/02/10
	 */
	public void setViewport(int __x, int __y)
	{
		// Translate the viewport
		int viewx = __x,
			viewy = __y,
			vieww = this._vieww,
			viewh = this._viewh,
			levelpxw = this.levelwidth,
			levelpxh = this.levelheight;
		
		// Cap right side
		if (viewx + vieww >= levelpxw - 1)
			viewx = (levelpxw - vieww) - 1;
		
		// Cop bottom side
		if (viewy + viewh >= levelpxh - 1)
			viewy = (levelpxh - viewh) - 1;
		
		// Cap left side
		if (viewx < 0)
			viewx = 0;
		
		// Cap top
		if (viewy < 0)
			viewy = 0;
		
		// Set new viewport
		this._viewx = viewx;
		this._viewy = viewy;
		
		// Recalculate tiles in view
		int msx = this.screenToMapX(0) / MegaTile.PIXEL_SIZE,
			msy = this.screenToMapY(0) / MegaTile.PIXEL_SIZE,
			mex = (this.screenToMapX(vieww) / MegaTile.PIXEL_SIZE) + 1,
			mey = (this.screenToMapY(viewh) / MegaTile.PIXEL_SIZE) + 1;
		
		// Cap
		mex = Math.min(mex, levelpxw / MegaTile.PIXEL_SIZE);
		mey = Math.min(mey, levelpxh / MegaTile.PIXEL_SIZE);
		
		// Set
		this._msx = msx;
		this._msy = msy;
		this._mex = mex;
		this._mey = mey;
	}
	
	/**
	 * Converts a screen X coordinate to a map X coordinate.
	 *
	 * @param __x The input X coordinate.
	 * @return The output X coordinate.
	 * @since 2017/02/12
	 */
	public int screenToMapX(int __x)
	{
		return this._viewx + __x;
	}
	
	/**
	 * Converts a screen Y coordinate to a map Y coordinate.
	 *
	 * @param __x The input Y coordinate.
	 * @return The output y coordinate.
	 * @since 2017/02/12
	 */
	public int screenToMapY(int __y)
	{
		return this._viewy + __y;
	}
	
	/**
	 * Sets the size of the viewport
	 *
	 * @param __w The new width.
	 * @param __h The new height.
	 * @throws IllegalArgumentException If the width and/or height is zero
	 * or negative.
	 * @since 2017/02/10
	 */
	public void setSize(int __w, int __h)
		throws IllegalArgumentException
	{
		// {@squirreljme.error BE08 Cannot set the viewport size to be zero
		// or negative.}
		if (__w <= 0 || __h <= 0)
			throw new IllegalArgumentException("BE08");
		
		// Correct the viewport
		this._vieww = __w;
		this._viewh = __h;
		this.translateViewport(0, 0);
	}
	
	/**
	 * Translates the viewport.
	 *
	 * @param __x The relative X translation.
	 * @param __y The relative Y translation.
	 * @since 2017/02/10
	 */
	public void translateViewport(int __x, int __y)
	{
		this.setViewport(this._viewx + __x, this._viewy + __y);
	}
	
	/**
	 * Returns the height of the viewport.
	 *
	 * @return The viewport height.
	 * @since 2017/02/12
	 */
	public int viewportHeight()
	{
		return this._viewh;
	}
	
	/**
	 * Returns the width of the viewport.
	 *
	 * @return The viewport width.
	 * @since 2017/02/12
	 */
	public int viewportWidth()
	{
		return this._vieww;
	}
	
	/**
	 * Returns the X position of the viewport.
	 *
	 * @return The viewport X position.
	 * @since 2017/02/12
	 */
	public int viewportX()
	{
		return this._viewx;
	}
	
	/**
	 * Returns the Y position of the viewport.
	 *
	 * @return The viewport Y position.
	 * @since 2017/02/12
	 */
	public int viewportY()
	{
		return this._viewy;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/ui/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains classes which can be used in any UI sense.
 *
 * @since 2018/03/19
 */

package net.multiphasicapps.squirrelquarrel.ui;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/AbilityType.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * The type of abilities available.
 *
 * @since 2019/03/24
 */
public enum AbilityType
{
	/** Regenerates HP. */
	REGENERATES_HP,
	
	/** End. */
	;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/BaseUnitInfo.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204












































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.io.InputStream;
import java.io.IOException;
import java.util.Objects;
import net.multiphasicapps.squirrelquarrel.util.ConstantFixedPoint;
import net.multiphasicapps.squirrelquarrel.util.Dimension;
import net.multiphasicapps.squirrelquarrel.util.FixedPoint;
import net.multiphasicapps.squirrelquarrel.util.Point;
import net.multiphasicapps.squirrelquarrel.util.Rectangle;
import net.multiphasicapps.squirrelquarrel.world.MegaTile;
import net.multiphasicapps.squirrelquarrel.world.Tile;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This contains the base information about a unit which is fixed and never
 * changes.
 *
 * @since 2017/02/14
 */
public final class BaseUnitInfo
{
	/** The type ID of the unit. */
	public final int typeid;
	
	/** The name of the unit. */
	public final String name;
	
	/** Unit hitpoints. */
	public final int hp;
	
	/** Unit shields. */
	public final int shields;
	
	/** Armor. */
	public final int armor;
	
	/** Unit size. */
	public final UnitSize size;
	
	/** The cost in salt. */
	public final int salt;
	
	/** The cost in methane. */
	public final int methane;
	
	/** The build time in frames. */
	public final int buildtime;
	
	/** The supply provided. */
	public final int supplyprovided;
	
	/** The supply cost. */
	public final int supplycost;
	
	/** The dimension of the unit in pixels. */
	public final Dimension pixeldimension;
	
	/** The offset. */
	public final Point offset;
	
	/** Center point offset for the unit. */
	public final Point centerpointoffset;
	
	/** The center point offset used for buildings (based on tile grid). */
	public final Point buildingcenterpointoffset;
	
	/** The unit size in tiles (for buildings). */
	public final Dimension tiledimension;
	
	/** The dimenion of the unit in pixels matching the tiled size. */
	public final Dimension pixeltiledimension;
	
	/** The sight range. */
	public final int sight;
	
	/** The score for creating this unit. */
	public final int scorebuild;
	
	/** The score for destroying this unit. */
	public final int scoredestroy;
	
	/** The speed of this unit, in 16.16 fixed point. */
	public final ConstantFixedPoint speed;
	
	/**
	 * Initializes the unit information from the given manifest.
	 *
	 * @param __tid Unit type ID.
	 * @param __m The input unit manifest.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	BaseUnitInfo(int __tid, JavaManifest __m)
		throws NullPointerException
	{
		// Check
		if (__m == null)
			throw new NullPointerException("NARG");
		
		// Type ID is used to modify unit details
		this.typeid = __tid;
		
		// Need the attributes!
		JavaManifestAttributes attr = __m.getMainAttributes();
		
		// Load these values directly
		this.name = attr.getValue("name", "Squirrels are cute!");
		this.hp = Integer.parseInt(
			attr.getValue("hp", "0"));
		this.shields = Integer.parseInt(
			attr.getValue("shields", "0"));
		this.armor = Integer.parseInt(
			attr.getValue("armor", "0"));
		this.salt = Integer.parseInt(
			attr.getValue("salt-cost", "0"));
		this.methane = Integer.parseInt(
			attr.getValue("methane-cost", "0"));
		this.buildtime = Integer.parseInt(
			attr.getValue("build-time", "0"));
		this.supplyprovided = Integer.parseInt(
			attr.getValue("supply-provided", "0"));
		this.supplycost = Integer.parseInt(
			attr.getValue("supply-cost", "0"));
		this.sight = Integer.parseInt(
			attr.getValue("sight", "0"));
		this.scorebuild = Integer.parseInt(
			attr.getValue("score-build", "0"));
		this.scoredestroy = Integer.parseInt(
			attr.getValue("score-destroy", "0"));
		this.speed = new ConstantFixedPoint(
			attr.getValue("speed", "0"));
		
		// Read dimensions
		Dimension pixeldimension;
		this.pixeldimension = (pixeldimension = new Dimension(
			attr.getValue("pixel-dimensions", "[0, 0]")));
		Point offset;
		this.offset = (offset = new Point(
			attr.getValue("pixel-offset", "(0, 0)")));
		
		// Parse size
		String vsize = attr.getValue("size", "small");
		switch (vsize)
		{
			case "small": this.size = UnitSize.SMALL; break;
			case "medium": this.size = UnitSize.MEDIUM; break;
			case "large": this.size = UnitSize.LARGE; break;
			
				// {@squirreljme.error BE09 Unknown unit size. (Unit size)}
			default:
				throw new RuntimeException(String.format("BE09 %s", vsize));
		}
		
		// Center point is just half the dimension
		this.centerpointoffset = new Point(pixeldimension.width / 2,
			pixeldimension.height / 2);
		
		// Get total size of unit in tiles, rounded up to the tile
		int pxw = (pixeldimension.width + offset.x +
				Tile.PIXEL_SIZE) & ~(Tile.PIXEL_MASK),
			pxh = (pixeldimension.height + offset.y +
				Tile.PIXEL_SIZE) & ~(Tile.PIXEL_MASK);
		
		// Determine tile dimension of unit
		Dimension tiledimension = new Dimension(
			pxw / Tile.PIXEL_SIZE,
			pxh / Tile.PIXEL_SIZE);
		this.tiledimension = tiledimension;
		this.pixeltiledimension = new Dimension(
			tiledimension.width / Tile.PIXEL_SIZE,
			tiledimension.height / Tile.PIXEL_SIZE);
		
		// Offset to the center of the building is in the center of
		// the tile dimensions
		this.buildingcenterpointoffset = new Point(pxw / 2, pxh / 2);
	}
	
	/**
	 * This performs the calculation of determining where a building should be
	 * placed. Building placement is aligned to the grid.
	 *
	 * @param __y If {@code true} then {@code __v} is a Y coordinate.
	 * @param __v The coordinate value.
	 * @return The center position of the building.
	 * @since 2017/02/17
	 */
	public int placeBuilding(boolean __y, int __v)
	{
		return __v;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/ModifiedUnitInfo.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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This class allows for the modification of unit information which is used
 * to manage such stuff as upgrades which happen over the course of the game.
 *
 * @since 2018/03/18
 */
public final class ModifiedUnitInfo
{
	/** Basic unit information. */
	protected final BaseUnitInfo base;
	
	/**
	 * Initializes the modified unit information.
	 *
	 * @param __i The base unit information.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ModifiedUnitInfo(BaseUnitInfo __i)
		throws NullPointerException
	{
		if (__i == null)
			throw new NullPointerException("NARG");
		
		this.base = __i;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/SpawnPlacementType.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This indicates the of placement to be performed when placing a unit.
 *
 * @since 2017/02/16
 */
public enum SpawnPlacementType
{
	/** Forced placement, it is created regardless if it is valid or not. */
	FORCED,
	
	/** Unit should follow building spawn rules, aligned to grid. */
	BUILDING,
	
	/** Normal best fit unit spawning, a creator may be used as a factory. */
	NORMAL,
	
	/** End. */
	;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/Unit.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219



























































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

/**
 * This represents and holds information for a single unit in the game.
 *
 * @since 2017/02/14
 */
public final class Unit
{
	/** The ID of this unit. */
	protected final int id;
	
	/** The current unit type. */
	private UnitType _type;
	
	/** Was this unit deleted? */
	private boolean _deleted;
	
	/** Hitpoints of the current unit. */
	private int _hp;
	
	/** Unit shields. */
	private int _shields;
	
	/** Reference to this unit via pointer. */
	private Reference<UnitReference> _ref;
	
	/** Actual center position. */
	int _cx, _cy;
	
	/** Position of the unit in the map. */
	int _x1, _y1, _x2, _y2;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __id The ID of the unit.
	 * @since 2018/03/19
	 */
	public Unit(int __id)
	{
		this.id = __id;
	}
	
	/**
	 * Returns the center X position.
	 *
	 * @return The center X position.
	 * @since 2017/02/17
	 */
	public int centerX()
	{
		return this._cx;
	}
	
	/**
	 * Returns the center Y position.
	 *
	 * @return The center Y position.
	 * @since 2017/02/17
	 */
	public int centerY()
	{
		return this._cy;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof Unit))
			return false;
		
		return this.id == ((Unit)__o).id;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final int hashCode()
	{
		return this.id;
	}
	
	/**
	 * Returns the ID of this unit.
	 *
	 * @return The unit ID.
	 * @since 2018/03/19
	 */
	public final int id()
	{
		return this.id;
	}
	
	/**
	 * This morphs the current unit so that it is of the specified unit type.
	 * Certain aspects are transferred and translation whiles others may be
	 * reset.
	 *
	 * @param __t The unit type to morph to.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/15
	 */
	public void morph(UnitType __t)
		throws NullPointerException
	{
		// Check
		if (__t == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
		/*
		// {@squirreljme.error BE0a Cannot morph a linked unit.}
		if (this._islinked)
			throw new IllegalStateException("BE0a");
		
		// If the type remains the same, do nothing
		UnitType oldtype = this._type;
		if (oldtype == __t)
			return;
		
		// Get info, needed for some details
		UnitInfo oldinfo = this._info,
			newinfo = __t.info();
		
		// Set new type
		this._type = __t;
		this._info = newinfo;
		
		// No previous type, set details
		if (oldtype == null)
		{
			this._hp = newinfo.hp;
			this._shields = newinfo.shields;
		}
		
		// Average the stats so that the new health is a precentage of the
		// old health
		else
		{
			if (true)
				throw new todo.TODO();
			
			// Recenter
			__move(this._cx, this._cy);
		}
		*/
	}
	
	/**
	 * Returns a reference to this unit.
	 *
	 * @return The reference to this unit.
	 * @since 2018/03/19
	 */
	public final UnitReference reference()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Runs the unit logic.
	 *
	 * @param __framenum The frame number.
	 * @return {@code true} if the unit was deleted.
	 * @since 2017/02/14
	 */
	boolean run(int __framenum)
	{
		// If the unit was deleted, do nothing
		if (this._deleted)
			return true;
		
		throw new todo.TODO();
		/*
		// Do not think for units which are not linked, but do not delete them
		if (!this._islinked)
			return false;
		
		// Not deleted
		return false;*/
	}
	
	/**
	 * Returns the unit type.
	 *
	 * @return The unit type.
	 * @since 2017/02/17
	 */
	public UnitType type()
	{
		return this._type;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/UnitDeletedException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This is thrown when the unit a pointer points to, has been deleted.
 *
 * @since 2017/02/14
 */
public class UnitDeletedException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2017/02/14
	 */
	public UnitDeletedException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2017/02/14
	 */
	public UnitDeletedException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/UnitLinker.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


























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This class is used to keep track of which units are near each other in
 * each of the given megatiles. This increases rendering speed since only units
 * that are linked into megatiles has to be used for the game logic.
 *
 * This does not need actual mega tile references, they just need to be
 * referred to by index.
 *
 * @since 2018/03/18
 */
public final class UnitLinker
{
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/UnitReference.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
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
































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This is a reference which points to a unit, it is used to allow units to
 * refer to other units and having it where they can be referenced without
 * needing to handle unit removal themselves. Since units would be garbage
 * collected, it would be unspecified using references when units actually
 * go away.
 *
 * @since 2018/03/19
 */
public final class UnitReference
{
	/** The unit ID. */
	protected final int id;
	
	/** The referring unit. */
	private volatile Unit _unit;
	
	/**
	 * Initializes the reference to the given unit.
	 *
	 * @param __u The unit to link to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public UnitReference(Unit __u)
		throws NullPointerException
	{
		if (__u == null)
			throw new NullPointerException("NARG");
		
		this.id = __u.id();
		this._unit = __u;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof UnitReference))
			return false;
		
		return this.id == ((UnitReference)__o).id;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final int hashCode()
	{
		return this.id;
	}
	
	/**
	 * Returns the unit this is a reference to or {@code null} if it has been
	 * deleted/killed.
	 *
	 * @return The unit this points to or {@code null} if it has been
	 * deleted/killed.
	 * @since 2018/03/19
	 */
	public final Unit get()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/19
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/UnitSize.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

/**
 * This represents the size of a unit.
 *
 * @since 2017/02/16
 */
public enum UnitSize
{
	/** Small. */
	SMALL,
	
	/** Medium. */
	MEDIUM,
	
	/** Large. */
	LARGE,
	
	/** End. */
	;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/UnitType.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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.tool.manifest.JavaManifest;

/**
 * These are the units which are available in the game and what are actively
 * used within the game.
 *
 * @since 2017/02/14
 */
public enum UnitType
{
	/** Starting location. */
	START_LOCATION,
	
	/** Chlorophid: Garden. */
	CHLOROPHID_GARDEN,
	
	/** End. */
	;
	
	/** Base unit information and its properties. */
	private BaseUnitInfo _info;
	
	/**
	 * Returns the information which is associated with the given unit.
	 *
	 * @return The unit information.
	 * @since 2017/02/14
	 */
	public BaseUnitInfo baseInfo()
	{
		// If the info has not been cached then load it
		BaseUnitInfo rv = this._info;
		if (rv == null)
			try (InputStream in = UnitType.class.getResourceAsStream(
				"/net/multiphasicapps/squirrelquarrel/data/units/" +
				this.name().toLowerCase() + "/info"))
			{
				// {@squirreljme.error BE0b Unit information for the given
				// unit does not exist. (The unit)}
				if (in == null)
					throw new RuntimeException("BE0b " + this);
				
				this._info = (rv = new BaseUnitInfo(this.ordinal(),
					new JavaManifest(in)));
			}
			
			// {@squirreljme.error BE0c Could not load unit information.}
			catch (IOException e)
			{
				throw new RuntimeException("BE0c", e);
			}
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/Units.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
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















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.units;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This class handles and manages all of the units in the game along with
 * their mega tile links.
 *
 * @since 2018/03/18
 */
public final class Units
{
	/** Linked units into mega tiles. */
	protected final UnitLinker linker =
		new UnitLinker();
	
	/** Units in the game. */
	private final List<Unit> _units =
		new ArrayList<>();
	
	/** The ID of the next unit to create. */
	private int _nextid;
	
	/**
	 * Initializes the units.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public Units(InitialSettings __is)
		throws NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
	}
	
	/**
	 * Creates a new unit.
	 *
	 * @param __spt How the unit should be placed on the map.
	 * @param __t The type of unit to spawn.
	 * @param __creator The creating unit, may be {@code null}.
	 * @param __x The target X position.
	 * @param __y The target Y position.
	 * @return The created unit or {@code null} if it could not be created.
	 * @throws NullPointerException If no spawn type or unit type was
	 * specified.
	 * @since 2017/02/16
	 */
	public final Unit createUnit(SpawnPlacementType __spt, UnitType __t,
		Unit __creator, int __x, int __y)
		throws NullPointerException
	{
		return this.createUnit(__spt, __t,
			(UnitReference)(__creator == null ? null : __creator.reference()),
			__x, __y);
	}
	
	/**
	 * Creates a new unit.
	 *
	 * @param __spt How the unit should be placed on the map.
	 * @param __t The type of unit to spawn.
	 * @param __creator The creating unit, may be {@code null}.
	 * @param __x The target center X position.
	 * @param __y The target center Y position.
	 * @return The created unit or {@code null} if it could not be created.
	 * @throws NullPointerException If no spawn type or unit type was
	 * specified.
	 * @since 2017/02/16
	 */
	public final Unit createUnit(SpawnPlacementType __spt, UnitType __t,
		UnitReference __creator, int __x, int __y)
		throws NullPointerException
	{
		// Check
		if (__spt == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Create new unit and add it to the list
		Unit rv;
		this._units.add((rv = new Unit(this._nextid++)));
		
		// Morph this unit to the resulting type
		rv.morph(__t);
		
		throw new todo.TODO();
		/*
		// Setup unit
		Unit rv = new Unit(this);
		UnitInfo info = __t.info();
		
		// Morph to the given unti type
		rv.morph(__t);
		
		// Determine the location where the unit is to be placed
		int px, py;
		switch (__spt)
		{
				// No restriction
			case FORCED:
				px = __x;
				py = __y;
				break;
				
				// Building, 
			case BUILDING:
				px = info.placeBuilding(false, __x);
				py = info.placeBuilding(true, __y);
				break;
				
				// Normal placement
			case NORMAL:
				throw new todo.TODO();
				
				// Unknown
			default:
				throw new todo.OOPS();
		}
		
		// Move unit to the specified position
		rv.__move(px, py);
		
		// Try to replace an existing null with this new unit
		List<Unit> units = this._units;
		boolean didset = false;
		for (int n = units.size(), i = n - 1; i >= 0; i++)
			if (units.get(i) == null)
			{
				units.set(i, rv);
				didset = true;
				break;
			}
		
		// Otherwise place at end
		if (!didset)
			units.add(rv);
		
		// Link unit into the map
		rv.__link(true);
		
		// Return it
		return rv;
		*/
	}
	
	/**
	 * Runs the unit logic.
	 *
	 * @param __frame The current game frame.
	 * @since 2018/03/18
	 */
	public void run(int __frame)
	{
		// Run the unit logic for every unit
		List<Unit> units = this._units;
		for (int i = 0, n = units.size(); i < n; i++)
			if (units.get(i).run(__frame))
				units.set(i, null);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/units/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains unit related resources.
 *
 * @since 2017/02/14
 */

package net.multiphasicapps.squirrelquarrel.units;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ConstantFixedPoint.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
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
































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a constant fixed point number.
 *
 * @since 2018/03/18
 */
public final class ConstantFixedPoint
	implements Comparable<FixedPoint>, FixedPoint
{
	/** Bit shift. */
	public static final int SHIFT =
		16;
	
	/** Mask. */
	public static final int MASK =
		0xFFFF;
	
	/** The value. */
	private int _value;
	
	/**
	 * Initializes the fixed point value with the given whole number.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(int __whole)
	{
		this._value = __whole << SHIFT;
	}
	
	/**
	 * Initializes the fixed point value with the given whole number and
	 * fraction.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @param __frac The fraction, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(int __whole, int __frac)
	{
		this._value = (__whole << SHIFT) | (__frac & MASK);
	}
	
	/**
	 * Initializes the fixed point value with the given fixed point value.
	 *
	 * @param __fp The fixed point number to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(FixedPoint __fp)
		throws NullPointerException
	{
		if (__fp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the given string and reads a fixed point value.
	 *
	 * @param __s The input string
	 * @throws IllegalArgumentException If the string is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public ConstantFixedPoint(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		int value;
		
		// Is a whole number
		int dot = __s.indexOf('.');
		if (dot < 0)
			value = Integer.parseInt(__s, 10) << SHIFT;
		
		// Is fractional value
		else
			throw new todo.TODO();
		
		this._value = value;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(FixedPoint __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int fraction()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int whole()
	{
		throw new todo.TODO();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/Dimension.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
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















































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains immutable dimension information for width and height.
 *
 * @since 2017/02/17
 */
public final class Dimension
	implements Comparable<Dimension>
{
	/** Width. */
	public final int width;
	
	/** Height. */
	public final int height;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the dimension.
	 *
	 * @param __w Width.
	 * @param __h Height.
	 * @since 2017/02/17
	 */
	public Dimension(int __w, int __h)
	{
		this.width = __w;
		this.height = __h;
	}
	
	/**
	 * Parses a dimension from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Dimension(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0d Dimension must start and end with square
		// brackets. (The input string)}
		if (!__s.startsWith("[") || !__s.endsWith("]"))
			throw new IllegalArgumentException("BE0d " + __s);
		
		// Trim those out
		__s = __s.substring(1, __s.length() - 1);
		
		// {@squirreljme.error BE0e Dimension must have a comma between the
		// units. (The input string)}
		int com = __s.indexOf(',');
		if (com < 0)
			throw new IllegalArgumentException("BE0e " + __s);
		
		this.width = Integer.parseInt(__s.substring(0, com).trim(), 10);
		this.height = Integer.parseInt(__s.substring(com + 1).trim(), 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Dimension __o)
	{
		int rv,
			aw = this.width,
			as = aw * this.height,
			bw = __o.width,
			bs = bw * __o.height;
		
		// Compare surface area first
		rv = as - bs;
		if (rv != 0)
			return rv;
		
		// Compare the width
		return aw - bw;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Dimension))
			return false;
		
		Dimension o = (Dimension)__o;
		return this.width == o.width && this.height == o.height;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.width ^ ~(this.height);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("[%d, %d]", this.width, this.height));
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/FixedPoint.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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a fixed point number.
 *
 * @since 2018/03/18
 */
public interface FixedPoint
	extends Comparable<FixedPoint>
{
	/**
	 * Returns the fraction part.
	 *
	 * @return The fraction part.
	 * @since 2018/03/18
	 */
	public abstract int fraction();
	
	/**
	 * Returns the whole number part.
	 *
	 * @return The whole number part.
	 * @since 2018/03/18
	 */
	public abstract int whole();
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/GameRandom.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
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























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.util.Random;

/**
 * This is the random number generator, this allows the seed to be obtained
 * and set so that it is restored properly.
 *
 * {@squirreljme.error BE0f Floating point operations not supported.}
 *
 * @since 2017/02/10
 */
public class GameRandom
	extends Random
{
	/** The current seed. */
	protected volatile long seed;	
	
	/**
	 * Initializes the random number generator with the given seed.
	 *
	 * @param __s The seed to use.
	 * @since 2017/02/10
	 */
	public GameRandom(long __s)
	{
		setSeed(__s);
	}
	
	/**
	 * Returns the current raw seed value.
	 *
	 * @return The current raw seed value.
	 * @since 2017/02/10
	 */
	public long getRawSeed()
	{
		return this.seed;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	protected int next(int __b)
	{
		// Setup new seed value
		long seed = this.seed;
		seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
		this.seed = seed;
		
		// Return from the old seed
		return (int)(seed >>> (48 - __b));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public double nextDouble()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public float nextFloat()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public double nextGaussian()
	{
		throw new UnsupportedOperationException("BE0f");
	}
	
	/**
	 * Sets the current raw seed value.
	 *
	 * @param __s The raw seed value to use.
	 * @since 2017/02/10
	 */
	public void setRawSeed(long __s)
	{
		this.seed = __s;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/10
	 */
	@Override
	public void setSeed(long __s)
	{
		// Update
		this.seed = (__s ^ 0x5DEECE66DL) & ((1L << 48) - 1);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/MutableFixedPoint.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
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









































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This represents a mutable fixed point number.
 *
 * @since 2018/03/18
 */
public final class MutableFixedPoint
	implements Comparable<FixedPoint>, FixedPoint
{
	/**
	 * Initializes the fixed point value with the given whole number.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(int __whole)
	{
		throw new todo.TODO();
	}
	
	/**
	 * Initializes the fixed point value with the given whole number and
	 * fraction.
	 *
	 * @param __whole The whole number, only the lowest 16-bits are used.
	 * @param __frac The fraction, only the lowest 16-bits are used.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(int __whole, int __frac)
	{
	}
	
	/**
	 * Initializes the fixed point value with the given fixed point value.
	 *
	 * @param __fp The fixed point number to copy.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(FixedPoint __fp)
		throws NullPointerException
	{
		if (__fp == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * Parses the given string and reads a fixed point value.
	 *
	 * @param __s The input string
	 * @throws IllegalArgumentException If the string is invalid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public MutableFixedPoint(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(FixedPoint __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int fraction()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int whole()
	{
		throw new todo.TODO();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/Point.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
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











































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This is an immutable class which contains X and Y coordinates.
 *
 * @since 2017/02/17
 */
public final class Point
	implements Comparable<Point>
{
	/** X coordinate. */
	public final int x;
	
	/** Y coordinate. */
	public final int y;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the point.
	 *
	 * @param __x X coordinate.
	 * @param __y Y coordinate.
	 * @since 2017/02/17
	 */
	public Point(int __x, int __y)
	{
		this.x = __x;
		this.y = __y;
	}
	
	/**
	 * Parses a point from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Point(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BE0g Point must start and end with parenthesis.
		// (The input string)}
		if (!__s.startsWith("(") || !__s.endsWith(")"))
			throw new IllegalArgumentException("BE0g " + __s);
		
		// Trim those out
		__s = __s.substring(1, __s.length() - 1);
		
		// {@squirreljme.error BE0h Point must have a comma between the
		// units. (The input string)}
		int com = __s.indexOf(',');
		if (com < 0)
			throw new IllegalArgumentException("BE0h " + __s);
		
		this.x = Integer.parseInt(__s.substring(0, com).trim(), 10);
		this.y = Integer.parseInt(__s.substring(com + 1).trim(), 10);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Point __o)
	{
		int rv;
		
		// Compare x
		rv = this.x - __o.x;
		if (rv != 0)
			return rv;
		
		// Compare y
		return this.y - __o.y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Point))
			return false;
		
		Point o = (Point)__o;
		return this.x == o.x && this.y == o.y;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.x ^ ~(this.y);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("(%d, %d)", this.x, this.y));
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/Rectangle.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213





















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains an immutable rectangle which starts at a given point and has
 * a width and height.
 *
 * @since 2017/02/17
 */
public final class Rectangle
	implements Comparable<Rectangle>
{
	/** X position. */
	public final int x;
	
	/** Y position. */
	public final int y;
	
	/** Width. */
	public final int width;
	
	/** Height. */
	public final int height;
	
	/** String form. */
	private Reference<String> _string;
	
	/** As a point. */
	private Reference<Point> _point;
	
	/** As an end point. */
	private Reference<Point> _endpoint;
	
	/** As a dimension. */
	private Reference<Dimension> _dimension;
	
	/**
	 * Initializes the rectangle.
	 *
	 * @param __x X coordinate.
	 * @param __y Y coordinate.
	 * @param __w Width.
	 * @param __h Height.
	 * @since 2017/02/17
	 */
	public Rectangle(int __x, int __y, int __w, int __h)
	{
		this.x = __x;
		this.y = __y;
		this.width = __w;
		this.height = __h;
	}
	
	/**
	 * Parses a rectanle from the given string.
	 *
	 * @param __s The string to parse.
	 * @throws IllegalArgumentException If the string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/18
	 */
	public Rectangle(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		throw new todo.TODO();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int compareTo(Rectangle __o)
	{
		int rv,
			aw = this.width,
			as = aw * this.height,
			bw = __o.width,
			bs = bw * __o.height;
		
		// Compare x
		rv = this.x - __o.x;
		if (rv != 0)
			return rv;
		
		// Compare y
		rv = this.y - __o.y;
		if (rv != 0)
			return rv;
		
		// Compare surface area
		rv = as - bs;
		if (rv != 0)
			return rv;
		
		// Compare the width
		return aw - bw;
	}
	
	/**
	 * Returns this rectangle as a dimension.
	 *
	 * @return The dimension of this rectangle.
	 * @since 2017/02/17
	 */
	public Dimension dimension()
	{
		Reference<Dimension> ref = this._dimension;
		Dimension rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._dimension = new WeakReference<>(
				rv = new Dimension(this.width, this.height));
		
		return rv;
	}
	
	/**
	 * Returns this tne end point of this rectangle.
	 *
	 * @return The end point of this rectangle.
	 * @since 2017/02/17
	 */
	public Point endPoint()
	{
		Reference<Point> ref = this._endpoint;
		Point rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._endpoint = new WeakReference<>(
				rv = new Point(this.x + this.width, this.y + this.height));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public boolean equals(Object __o)
	{
		// Check
		if (!(__o instanceof Rectangle))
			return false;
		
		Rectangle o = (Rectangle)__o;
		return this.x == o.x && this.y == o.y &&
			this.width == o.width && this.height == o.height;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public int hashCode()
	{
		return this.x ^ ~(this.y) ^ this.width ^ ~(this.height);
	}
	
	/**
	 * Returns this rectangle as a point.
	 *
	 * @return The point of this rectangle.
	 * @since 2017/02/17
	 */
	public Point point()
	{
		Reference<Point> ref = this._point;
		Point rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._point = new WeakReference<>(rv = new Point(this.x, this.y));
		
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/17
	 */
	@Override
	public String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		// Cache?
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>(
				rv = String.format("(%d, %d, %d, %d]", this.x, this.y,
					this.width, this.height));
		
		return rv;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ReplayEventSource.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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import net.multiphasicapps.squirrelquarrel.game.EventSource;

/**
 * This is an event source which reads actions from replay data.
 *
 * @since 2019/03/24
 */
public final class ReplayEventSource
	implements EventSource
{
	/** The input replay stream. */
	protected final ReplayInputStream in;
	
	/**
	 * Initializes the event source.
	 *
	 * @param __in The input stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/03/24
	 */
	public ReplayEventSource(ReplayInputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = __in;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ReplayFormatException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This is thrown when the format of a replay is incorrect.
 *
 * @since 2018/03/19
 */
public class ReplayFormatException
	extends ReplayIOException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/19
	 */
	public ReplayFormatException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayFormatException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ReplayIOException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

/**
 * This is thrown when a replay has failed to be read or written to.
 *
 * @since 2018/03/19
 */
public class ReplayIOException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/03/19
	 */
	public ReplayIOException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/03/19
	 */
	public ReplayIOException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayIOException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/03/19
	 */
	public ReplayIOException(Throwable __c)
	{
		super(__c);
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ReplayInputStream.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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;

/**
 * This allows for easier reading from the replay input without requiring that
 * {@link IOException} be caught each time.
 *
 * @since 2018/03/19
 */
public final class ReplayInputStream
{
	/** The stream to read from. */
	protected final DataInputStream in;
	
	/**
	 * Initializes the input stream.
	 *
	 * @param __in The stream to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ReplayInputStream(InputStream __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		this.in = (__in instanceof DataInputStream ? (DataInputStream)__in :
			new DataInputStream(__in));
	}
	
	/**
	 * Reads a byte value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final int readByte()
		throws ReplayIOException
	{
		try
		{
			return this.in.readByte();
		}
		
		// {@squirreljme.error BE0i Could not read byte from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0i", e);
		}
	}
	
	/**
	 * Reads an integer value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final int readInt()
		throws ReplayIOException
	{
		try
		{
			return this.in.readInt();
		}
		
		// {@squirreljme.error BE0j Could not read integer from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0j", e);
		}
	}
	
	/**
	 * Reads a long value.
	 *
	 * @return The read value.
	 * @throws ReplayIOException On read errors.
	 * @since 2018/03/29
	 */
	public final long readLong()
		throws ReplayIOException
	{
		try
		{
			long rv = this.in.readInt();
			rv <<= 32;
			rv |= (this.in.readInt() & 0xFFFFFFFF);
			return rv;
		}
		
		// {@squirreljme.error BE0k Could not read long from the input.}
		catch (IOException e)
		{
			throw new ReplayIOException("BE0k", e);
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/ReplayOutputStream.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
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



















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.util;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This allows for easier writing to the replay output without requiring that
 * {@link IOException} be caught each time.
 *
 * @since 2018/03/19
 */
public final class ReplayOutputStream
{
	/** The stream to write to. */
	protected final DataOutputStream out;
	
	/**
	 * Initializes the output stream.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/19
	 */
	public ReplayOutputStream(OutputStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		this.out = (__out instanceof DataOutputStream ?
			(DataOutputStream)__out : new DataOutputStream(__out));
	}
	
	/**
	 * Writes a byte value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeByte(int __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeByte(__v);
		}
		
		// {@squirreljme.error BE0l Could not write the byte value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0l %d", __v), e);
		}
	}
	
	/**
	 * Writes an integer value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeInt(int __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeInt(__v);
		}
		
		// {@squirreljme.error BE0m Could not write the integer value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0m %d", __v), e);
		}
	}
	
	/**
	 * Writes a long value.
	 *
	 * @param __v The value to write.
	 * @throws ReplayIOException If it could not be written.
	 * @since 2018/03/19
	 */
	public void writeLong(long __v)
		throws ReplayIOException
	{
		try
		{
			this.out.writeInt((int)(__v >> 32));
			this.out.writeInt((int)__v);
		}
		
		// {@squirreljme.error BE0n Could not write the long value.
		// (The value to write)}
		catch (IOException e)
		{
			throw new ReplayIOException(String.format("BE0n %d", __v), e);
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/util/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains utilities that can be used for the game.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.util;

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/MegaTile.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
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





















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * This represents a single mega tile which represents a small region in the
 * level.
 *
 * @since 2017/02/09
 */
public class MegaTile
{
	/** The number of frames which must pass before fog of war is cycled. */
	private static final int _FOG_OF_WAR_CYCLE_MASK =
		63;
	
	/** The number of tiles per mega tile. */
	public static final int TILES_PER_MEGA_TILE =
		8;
	
	/** The number of tiles in mega tiles. */
	public static final int TILES_IN_MEGA_TILE =
		64;
	
	/** The size of megatiles in pixels. */
	public static final int PIXEL_SIZE =
		256;
	
	/** The megatile index. */
	public final MegaTileIndex index;
	
	/** Megatile X position. */
	public final int megax;
	
	/** Megatile Y position. */
	public final int megay;
	
	/** Mega tile ordinal. */
	public final int megaordinal;
	
	/** Terrain information. */
	private final byte[] _terrain =
		new byte[TILES_IN_MEGA_TILE];
	
	/**
	 * This contains the first cycle for the fog of war. The fog of war acts
	 * in two cycles, so that previously revealed areas go away and new ones
	 * are set. This means that the fog of war does not need to be cleared
	 * every frame by units, only set. The fog is in two cycles because on a
	 * new cycle this array is cleared, and it would be possible for a unit to
	 * be blind while its logic is handled. Also fog of war updates do not need
	 * to be that instant.
	 */
	private final byte[] _fogcyclea =
		new byte[TILES_IN_MEGA_TILE];
	
	/** Fog of war second cycle. */
	private final byte[] _fogcycleb =
		new byte[TILES_IN_MEGA_TILE];
	
	/**
	 * Initializes a basic megatile.
	 *
	 * @param __x Megatile X position.
	 * @param __y Megatile Y position.
	 * @since 2017/02/10
	 */
	public MegaTile(int __mx, int __my, int __mi)
	{
		// Set
		this.megax = __mx;
		this.megay = __my;
		this.megaordinal = __mi;
		this.index = new MegaTileIndex(__mx, __my, __mi);
		
		// Initialize it with some pattern
		byte[] terrain = this._terrain;
		for (int y = 0; y < TILES_PER_MEGA_TILE; y++)
			for (int x = 0; x < TILES_PER_MEGA_TILE; x++)
				terrain[(y * TILES_PER_MEGA_TILE) + x] =
					(byte)(((x + y) / 2) & 1);
	}
	
	/**
	 * Gets the terrain for the given sub-tile.
	 *
	 * @param __x The tile X position.
	 * @param __y The tile Y position.
	 * @return The terrain type for the given tile.
	 * @throws IndexOutOfBoundsException If the position is not in the megatile
	 * bounds.
	 * @since 2017/02/11
	 */
	public TerrainType subTileTerrain(int __x, int __y)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE0o Cannot get terrain because the tile is
		// out of range.}
		if (__x < 0 || __y < 0 || __x >= TILES_PER_MEGA_TILE ||
			__y >= TILES_PER_MEGA_TILE)
			throw new IndexOutOfBoundsException("BE0o");
		
		// Depends
		return TerrainType.of(
			this._terrain[(__y * TILES_PER_MEGA_TILE) + __x]);
	}
	
	/**
	 * Return the megatile X position.
	 *
	 * @return The X position of the megatile.
	 * @since 2017/02/17
	 */
	public int x()
	{
		return this.megax;
	}
	
	/**
	 * Return the megatile Y position.
	 *
	 * @return The Y position of the megatile.
	 * @since 2017/02/17
	 */
	public int y()
	{
		return this.megay;
	}
	
	/**
	 * Runs the megatile logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
		// Cycle the fog of war?
		if ((__frame & _FOG_OF_WAR_CYCLE_MASK) == 0)
			__cycleFog();
	}
	
	/**
	 * This cycles the fog of war.
	 *
	 * @since 2017/02/14
	 */
	void __cycleFog()
	{
		// Transfer all fog state from the first cycle to the second
		byte[] fogcyclea = this._fogcyclea;
		byte[] fogcycleb = this._fogcyclea;
		for (int i = 0, n = TILES_IN_MEGA_TILE; i < n; i++)
		{
			// Set the second cycle to the first
			fogcycleb[i] = fogcyclea[i];
			
			// Clear the first
			fogcyclea[i] = 0;
		}
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/MegaTileIndex.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
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









































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

/**
 * This represents an index into a megatile.
 *
 * @since 2018/03/18
 */
public final class MegaTileIndex
	implements Comparable<MegaTileIndex>
{
	/** The x coordinate. */
	public final int x;
	
	/** The y coordinate. */
	public final int y;
	
	/** The ordinal index. */
	public final int ordinal;
	
	/**
	 * Initializes the mega tile index.
	 *
	 * @param __x The x coordinate.
	 * @param __y The y coordinate.
	 * @param __i The ordinal.
	 * @since 2018/03/18
	 */
	public MegaTileIndex(int __x, int __y, int __i)
	{
		this.x = __x;
		this.y = __y;
		this.ordinal = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int compareTo(MegaTileIndex __o)
	{
		return this.ordinal - __o.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof MegaTileIndex))
			return false;
		
		MegaTileIndex o = (MegaTileIndex)__o;
		return this.ordinal == o.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final int hashCode()
	{
		return this.ordinal;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/18
	 */
	@Override
	public final String toString()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Translates a position to the position ordinal.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
	 * @return The ordinal in the tile map.
	 * @since 2018/03/19
	 */
	public static final int positionToOrdinal(int __x, int __y)
	{
		throw new todo.TODO();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/TerrainType.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
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



























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

import java.io.InputStream;

/**
 * This represents the type of terrain that is available for usage.
 *
 * @since 2017/02/10
 */
public enum TerrainType
{
	/** Grass. */
	GRASS(0x007F00),
	
	/** Dirt. */
	DIRT(0x6E370B),
	
	/** End. */
	;
	
	/** Cache of terrain types. */
	private static final TerrainType[] _VALUES =
		values();
	
	/** The terrain color. */
	protected final int color;
	
	/**
	 * Initializes the terrain type.
	 *
	 * @param __color The color used for this terrain.
	 * @since 2017/09/13
	 */
	private TerrainType(int __color)
	{
		// Set
		this.color = __color;
	}
	
	/**
	 * Returns the color used for the terrain.
	 *
	 * @return The terrain color.
	 * @since 2017/02/13
	 */
	public int color()
	{
		return this.color;
	}
	
	/**
	 * Returns an input stream to the image data.
	 *
	 * @return The image data input stream.
	 * @throws RuntimeException If the data is missing.
	 * @since 2017/02/10
	 */
	public InputStream imageStream()
		throws RuntimeException
	{
		// {@squirreljme.error BE0p Could not get the tile image for the
		// given terrain. (The terrain type)}
		InputStream rv = TerrainType.class.getResourceAsStream(
			"images/terrain/" + __lower(name()) + ".xpm");
		if (rv == null)
			throw new RuntimeException(String.format("BE0p %s", this));
		return rv;
	}
	
	/**
	 * Returns the terrain type of the given ID.
	 *
	 * @param __i The ID of the terrain to return.
	 * @return The terrain type at this position.
	 * @since 2017/02/13
	 */
	public static TerrainType of(int __i)
	{
		return _VALUES[__i];
	}
	
	/**
	 * Lowercases the specified string.
	 *
	 * @param __s The string to lowercase.
	 * @return The lowercased string.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	static final String __lower(String __s)
		throws NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Convert
		int n = __s.length();
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			if (c >= 'A' && c <= 'Z')
				c = (char)((c - 'A') + 'a');
			
			sb.append(c);
		}
		
		return sb.toString();
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/Tile.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

/**
 * This represents a single tile in the world.
 *
 * @since 2018/03/18
 */
public final class Tile
{
	/** The shift for pixels. */
	public static final int PIXEL_SHIFT =
		5;
	
	/** The size of tiles in pixels. */
	public static final int PIXEL_SIZE =
		32;
	
	/** The mas for pixels. */
	public static final int PIXEL_MASK =
		31;
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/World.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227



































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.squirrelquarrel.world;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import net.multiphasicapps.squirrelquarrel.game.InitialSettings;

/**
 * This stores the mega tiles within the level along with storing level related
 * data structures.
 *
 * @since 2017/02/09
 */
public class World
{
	/** The mega tile array. */
	protected final MegaTile[] _tiles;
	
	/** The width of the level in tiles. */
	protected final int tilew;
	
	/** The height of the level in tiles. */
	protected final int tileh;
	
	/** The width of the level in pixels. */
	protected final int pixelw;
	
	/** The height of the level in pixels. */
	protected final int pixelh;
	
	/** The width of the level in megatiles. */
	protected final int megaw;
	
	/** The height of the level in megatiles. */
	protected final int megah;
	
	/**
	 * Initializes the level with the given initial settings.
	 *
	 * @param __is The initial settings to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/10
	 */
	public World(InitialSettings __is)
		throws NullPointerException
	{
		// Check
		if (__is == null)
			throw new NullPointerException("NARG");
		
		// Initialize the tile map
		int mw = __is.mapWidth(),
			mh = __is.mapHeight();
		this._tiles = __initTiles(mw, mh);
		
		// Store sizes
		this.tilew = mw;
		this.tileh = mh;
		this.megaw = mw / MegaTile.TILES_PER_MEGA_TILE;
		this.megah = mh / MegaTile.TILES_PER_MEGA_TILE;
		this.pixelw = mw * Tile.PIXEL_SIZE;
		this.pixelh = mh * Tile.PIXEL_SIZE;
	}
	
	/**
	 * Returns the megatile at the given megatile coordinates.
	 *
	 * @param __x The X coordinate in megatiles.
	 * @param __y The Y coordinate in megatiles.
	 * @return The megatile at the given coordinates.
	 * @throws IndexOutOfBoundsException If the megatile position is not
	 * within bounds.
	 * @since 2017/02/11
	 */
	public MegaTile megaTile(int __x, int __y)
		throws IndexOutOfBoundsException
	{
		// {@squirreljme.error BE0q Megatile not in level range.}
		int megaw = this.megaw,
			megah = this.megah;
		if (__x < 0 || __y < 0 || __x >= megaw || __y >= megah)
			throw new IndexOutOfBoundsException("BE0q");
		
		// Get
		return this._tiles[(__y * megaw) + __x];
	}
	
	/**
	 * Returns the height of the map in megatiles.
	 *
	 * @return The map height in megatiles.
	 * @since 2017/02/12
	 */
	public int megaTileHeight()
	{
		return this.megah;
	}
	
	/**
	 * Returns the width of the map in megatiles.
	 *
	 * @return The map width in megatiles.
	 * @since 2017/02/12
	 */
	public int megaTileWidth()
	{
		return this.megaw;
	}
	
	/**
	 * Returns the height of the level in pixels.
	 *
	 * @return The height of the level in pixels.
	 * @since 2017/02/10
	 */
	public int pixelHeight()
	{
		return this.pixelh;
	}
	
	/**
	 * Returns the width of the level in pixels.
	 *
	 * @return The width of the level in pixels.
	 * @since 2017/02/10
	 */
	public int pixelWidth()
	{
		return this.pixelw;
	}
	
	/**
	 * Returns the terrain type at the given pixel
	 *
	 * @param __x The pixel X position.
	 * @param __y The pixel Y position.
	 * @return The terrain type for the given tile.
	 * @since 2017/02/13
	 */
	public TerrainType pixelTerrain(int __x, int __y)
	{
		return megaTile(pixelCoordToMegaTile(__x), pixelCoordToMegaTile(__y)).
			subTileTerrain(pixelCoordToSubTile(__x), pixelCoordToSubTile(__y));
	}
	
	/**
	 * Initializes the map tiles.
	 *
	 * @param __tw The tile width of the map.
	 * @param __th The tile height of the map.
	 * @return The initialized mega tiles.
	 * @since 2017/02/14
	 */
	private MegaTile[] __initTiles(int __tw, int __th)
	{
		int megaw = __tw / MegaTile.TILES_PER_MEGA_TILE;
		int megah = __th / MegaTile.TILES_PER_MEGA_TILE;
		
		// Initialize
		MegaTile[] tiles = new MegaTile[megaw * megah];
		for (int i = 0, n = tiles.length; i < n; i++)
			tiles[i] = new MegaTile(i % megaw, i / megaw, i);
		
		return tiles;
	}
	
	/**
	 * Runs the level logic.
	 *
	 * @param __frame The current frame.
	 * @since 2017/02/14
	 */
	public void run(int __frame)
	{
		// Run the megatile loop
		MegaTile[] tiles = this._tiles;
		for (int i = 0, n = tiles.length; i < n; i++)
			tiles[i].run(__frame);
	}
	
	/**
	 * Converts a pixel coordinate to a mega tile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToMegaTile(int __c)
	{
		return __c / MegaTile.PIXEL_SIZE;
	}
	
	/**
	 * Converts a pixel coordinate to a tile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToTile(int __c)
	{
		return __c / Tile.PIXEL_SIZE;
	}
	
	/**
	 * Converts a pixel coordinate to a sub tile in a megatile.
	 *
	 * @param __c The coordinate to convert.
	 * @return The converted coordinate.
	 * @since 2017/02/13
	 */
	public static int pixelCoordToSubTile(int __c)
	{
		return (__c / Tile.PIXEL_SIZE) % MegaTile.TILES_PER_MEGA_TILE;
	}
}

Deleted runt/mids/squirrel-quarrel/net/multiphasicapps/squirrelquarrel/world/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains anything which contains the world data.
 *
 * @since 2018/03/18
 */

package net.multiphasicapps.squirrelquarrel.world;

Deleted runt/runtime.mkd.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
# Run-time Projects

This contains all of the projects which are intended to be ran at run-time or
within the run-time environment.

 * `apis/` -- Standard APIs and JSRs.
 * `klib/` -- Libraries which are to be considered part of the system.
 * `kmid/` -- MIDlets which are considered to be part of the system.
 * `libs/` -- Libraries intended to be used by users.
 * `mids/` -- MIDlets intended to be used by users.
 * `test/` -- Test framework.

Added settings.gradle.



































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Modules and available platforms
include "modules"
include "emulators"
include "tools"

// Recursively include all modules
file(rootProject.projectDir.toPath().resolve("modules"))
	.eachDir(
	{ subdir ->
		if (subdir.toPath().resolve("build.gradle").toFile().exists())
		{
			include "modules:" + subdir.name
		}
	})

// Recursively include all emulators
file(rootProject.projectDir.toPath().resolve("emulators"))
	.eachDir(
	{ subdir ->
		if (subdir.toPath().resolve("build.gradle").toFile().exists())
		{
			include "emulators:" + subdir.name
		}
	})

// Recursively include all tools
file(rootProject.projectDir.toPath().resolve("tools"))
	.eachDir(
	{ subdir ->
		if (subdir.toPath().resolve("build.gradle").toFile().exists())
		{
			include "tools:" + subdir.name
		}
	})

Deleted test/TIMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Timespace-Title: Tests
X-SquirrelJME-Timespace-Type: test
X-SquirrelJME-Timespace-Description: The timespace contains all of the
 tests.

Deleted test/libs/NAMESPACE.MF.

1
2
3
4
5





-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Test Libraries
X-SquirrelJME-Namespace-Type: liblet
X-SquirrelJME-Namespace-Description: This contains test libraries.

Deleted test/libs/tac.test/DoBiConsumer.in.

1
2
3
4
5
6
7







-
-
-
-
-
-
-
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
argument-2: int:123456789
result: NoResult
thrown: NoExceptionThrown
secondary-a: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
secondary-b: int:123456789

Deleted test/libs/tac.test/DoBiConsumer.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestBiConsumer;

/**
 * Tests a basic bi consumer.
 *
 * @since 2018/10/06
 */
public class DoBiConsumer
	extends TestBiConsumer<String, Integer>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test(String __s, Integer __i)
	{
		this.secondary("a", __s);
		this.secondary("b", __i);
	}
}

Deleted test/libs/tac.test/DoBiFunction.in.

1
2
3
4
5





-
-
-
-
-
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
argument-2: int:123456789
result: string:987654321...3<\_!etuc\_os\_era\_eW\_!slerriuqs\_olleH
thrown: NoExceptionThrown

Deleted test/libs/tac.test/DoBiFunction.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestBiFunction;

/**
 * Tests a basic bi function.
 *
 * @since 2018/10/06
 */
public class DoBiFunction
	extends TestBiFunction<String, Integer, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test(String __s, Integer __i)
	{
		StringBuilder sb = new StringBuilder(__s + "..." + __i);
		sb.reverse();
		return sb.toString();
	}
}

Deleted test/libs/tac.test/DoConsumer.in.

1
2
3
4




-
-
-
-
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
result: NoResult
thrown: NoExceptionThrown
secondary-input: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3

Deleted test/libs/tac.test/DoConsumer.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestConsumer;

/**
 * Tests a basic consumer.
 *
 * @since 2018/10/06
 */
public class DoConsumer
	extends TestConsumer<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test(String __s)
	{
		this.secondary("input", __s);
	}
}

Deleted test/libs/tac.test/DoException.in.

1
2
3



-
-
-
result: ExceptionThrown
thrown: throwable:RuntimeException

Deleted test/libs/tac.test/DoException.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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests a basic exception.
 *
 * @since 2018/10/06
 */
public class DoException
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test()
	{
		// Expected to fail
		throw new RuntimeException("Oopsie!");
	}
}

Deleted test/libs/tac.test/DoFunction.in.

1
2
3
4




-
-
-
-
argument-1: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
result: string:3<\_!etuc\_os\_era\_eW\_!slerriuqs\_olleH
thrown: NoExceptionThrown

Deleted test/libs/tac.test/DoFunction.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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestFunction;

/**
 * Tests a basic consumer.
 *
 * @since 2018/10/06
 */
public class DoFunction
	extends TestFunction<String, String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test(String __s)
	{
		StringBuilder sb = new StringBuilder(__s);
		sb.reverse();
		return sb.toString();
	}
}

Deleted test/libs/tac.test/DoRunnable.in.

1
2
3



-
-
-
result: NoResult
thrown: NoExceptionThrown

Deleted test/libs/tac.test/DoRunnable.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestRunnable;

/**
 * Tests a basic runnable.
 *
 * @since 2018/10/06
 */
public class DoRunnable
	extends TestRunnable
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public void test()
	{
	}
}

Deleted test/libs/tac.test/DoSupplier.in.

1
2
3



-
-
-
result: string:Hello\_squirrels!\_We\_are\_so\_cute!\_<3
thrown: NoExceptionThrown

Deleted test/libs/tac.test/DoSupplier.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import net.multiphasicapps.tac.TestSupplier;

/**
 * Tests a basic supplier.
 *
 * @since 2018/10/06
 */
public class DoSupplier
	extends TestSupplier<String>
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public String test()
	{
		return "Hello squirrels! We are so cute! <3";
	}
}

Deleted test/libs/tac.test/META-INF/TEST.MF.

1
2


-
-
Manifest-Version: 1.0

Deleted test/libs/tac/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 648f4184-68ee-4cfd-ae8c-99e438246e97
X-SquirrelJME-Error: BU
X-SquirrelJME-Name: Testing, Acceptance, and Comparison
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This project contains the testing, acceptance, 
 and comparison framework which is used to test and compare differring 
 executions of the virtual machine.
Microedition-Configuration: CLDC-1.8-Compact
Microedition-Profile: MEEP-8
X-SquirrelJME-Depends: meep-midlet tool-manifest-reader 
 tool-manifest-writer collections

Deleted test/libs/tac/net/multiphasicapps/tac/DataConversion.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
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







































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This class contains helpers for data conversion.
 *
 * @since 2019/01/20
 */
public final class DataConversion
{
	/**
	 * Converts the character array to a char array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final char[] arrayCharacterToChar(Character[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		char[] rv = new char[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].charValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a byte array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final byte[] arrayNumberToByte(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		byte[] rv = new byte[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].byteValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a double array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final double[] arrayNumberToDouble(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		double[] rv = new double[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].doubleValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a float array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final float[] arrayNumberToFloat(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		float[] rv = new float[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].floatValue();
		return rv;
	}
	
	/**
	 * Converts the number array to an int array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final int[] arrayNumberToInt(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		int[] rv = new int[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].intValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a long array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final long[] arrayNumberToLong(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		long[] rv = new long[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].longValue();
		return rv;
	}
	
	/**
	 * Converts the number array to a short array.
	 *
	 * @param __a The input array.
	 * @return The converted array.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/20
	 */
	public static final short[] arrayNumberToShort(Number[] __a)
		throws NullPointerException
	{
		if (__a == null)
			throw new NullPointerException("NARG");
		
		int n = __a.length;
		short[] rv = new short[n];
		for (int i = 0; i < n; i++)
			rv[i] = __a[i].shortValue();
		return rv;
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/DataDeserialization.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267











































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This class contains deserializers for data.
 *
 * @since 2019/01/20
 */
public final class DataDeserialization
{
	/**
	 * Decodes a key for a given secondary value.
	 *
	 * @param __key The key to decode.
	 * @return The decoded key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static final String decodeKey(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// Go through string and decode it
		int n;
		StringBuilder sb = new StringBuilder((n = __key.length()));
		boolean escaped = false;
		for (int i = 0; i < n; i++)
		{
			char c = __key.charAt(i);
			
			// Escaping?
			if (escaped)
			{
				// Determine replacement character
				switch (c)
				{
					case 'p':	c = '+'; break;
					case 'h':	c = '#'; break;
					case 'd':	c = '.'; break;
					case '-':	c = '-'; break;
				}
				sb.append(c);
				
				// Do not escape anymore
				escaped = false;
			}
			
			// Going to escape?
			else if (c == '-')
				escaped = true;
			
			// Pass as is
			else
				sb.append(c);
		}
		
		return sb.toString();
	}
	
	/**
	 * Decodes the given string from a manifest safe format to a string.
	 *
	 * @param __s The string to decode.
	 * @return The decoded string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static final String decodeString(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		StringBuilder sb = new StringBuilder(__s.length());
		
		// Decode all input characters
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Ignore whitespace, since this could be an artifact of whitespace
			// used in the manifest
			if (c == ' ' || c == '\r' || c == '\n' || c == '\t')
				continue;
			
			// Escaped sequence requires parsing
			else if (c == '\\')
			{
				// Read the next character
				c = __s.charAt(++i);
				
				// Hex sequence for any character
				if (c == '@')
				{
					// Build string to decode hex sequence from
					StringBuilder sub = new StringBuilder(4);
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					sub.append(__s.charAt(++i));
					
					// Decode character
					c = (char)(Integer.valueOf(sub.toString(), 16).intValue());
				}
				
				// Code for specific characters
				else
					switch (c)
					{
							// Unchanged
						case '\\':
						case '\"':
							break;
							
							// Space
						case '_':
							c = ' ';
							break;
							
							// Newline
						case 'n':
							c = '\n';
							break;
							
							// Carriage return
						case 'r':
							c = '\r';
							break;
							
							// Tab
						case 't':
							c = '\t';
							break;
							
							// Delete
						case 'd':
							c = (char)0x7F;
							break;
							
							// Open brace
						case '(':
							c = '{';
							break;
							
							// Closing brace
						case ')':
							c = '}';
							break;
						
							// Used to represent all the other upper
							// sequences
						default:
							if (c >= '0' && c <= '9')
								c = (char)(c - '0');
							else if (c >= 'A' && c <= 'Z')
								c = (char)((c - 'A') + 10);
							break;
					}
				
				// Append normalized
				sb.append(c);
			}
			
			// Not escaped
			else
				sb.append(c);
		}
		
		return sb.toString();
	}
	
	/**
	 * Converts the given string to an object.
	 *
	 * @param __s The object to convert.
	 * @return The converted object.
	 * @throws InvalidTestParameterException If the input could not be
	 * converted.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static final Object deserialize(String __s)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Basic conversions
		switch (__s)
		{
			case "null":
				return null;
			
			case "NoResult":
				return new __NoResult__();
			
			case "UndefinedResult":
				return new __UndefinedResult__();
			
			case "ExceptionThrown":
				return new __ExceptionThrown__();
			
			case "NoExceptionThrown":
				return new __NoExceptionThrown__();
			
			case "true":
				return Boolean.TRUE;
			
			case "false":
				return Boolean.FALSE;
			
			default:
				break;
		}
		
		// A string
		if (__s.startsWith("string:"))
			return DataDeserialization.decodeString(__s.substring(7));
		
		// Byte
		else if (__s.startsWith("byte:"))
			return Byte.valueOf(__s.substring(5));
			
		// Short
		else if (__s.startsWith("short:"))
			return Short.valueOf(__s.substring(6));
			
		// Char
		else if (__s.startsWith("char:"))
			return Character.valueOf(
				(char)Integer.valueOf(__s.substring(5)).intValue());
		
		// Integer
		else if (__s.startsWith("int:"))
			return Integer.valueOf(__s.substring(4));
		
		// Long
		else if (__s.startsWith("long:"))
			return Long.valueOf(__s.substring(5));
		
		// {@squirreljme.error BU01 The specified string cannot be converted
		// to an object because it an unknown representation, the conversion
		// is only one way. (The encoded data)}
		else if (__s.startsWith("other:"))
			throw new InvalidTestParameterException(
				String.format("BU01 %s", __s));
		
		// {@squirreljme.error BU02 The specified object cannot be
		// decoded because it is not known or does not support decoding.
		// (The encoded data)}
		else
			throw new InvalidTestParameterException(
				String.format("BU02 %s", __s));
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/DataSerialization.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458










































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This class contains serializers of data.
 *
 * @since 2019/01/20
 */
public final class DataSerialization
{
	/**
	 * Encodes key value.
	 *
	 * @param __key The key to encode.
	 * @return The resulting key.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public static final String encodeKey(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
			
		// Encode the key to allow for valid characters
		int n;
		StringBuilder sb = new StringBuilder((n = __key.length()));
		for (int i = 0; i < n; i++)
		{
			char c = __key.charAt(i);
			
			// Possibly re-encoded?
			boolean enc = false;
			if (c >= 'A' && c <= 'Z')
				c = Character.toLowerCase(c);
			
			// Re-encode?
			char redo = 0;
			switch (c)
			{
				case '+':	redo = 'p'; break;
				case '#':	redo = 'h'; break;
				case '.':	redo = 'd'; break;
				case '-':	redo = '-'; break;
			}
			
			// Was this value being re-encoded?
			if (redo != 0)
			{
				sb.append('-');
				sb.append(redo);
			}
			else
				sb.append(c);
		}
		
		// Use the encoded key
		return sb.toString();
	}
	
	/**
	 * Encodes the given string to a manifest safe format.
	 *
	 * @param __s The string to encode.
	 * @return The encoded string, {@code null} has a special value.
	 * @since 2018/10/06
	 */
	public static final String encodeString(String __s)
	{
		// Special value for null strings
		if (__s == null)
			return "\\NULL";
		
		// Encode characters to normalize them
		StringBuilder sb = new StringBuilder(__s.length());
		for (int i = 0, n = __s.length(); i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Is the character to be translated?
			boolean escape = false;
			switch (c)
			{
					// Just escape these
				case '\\':
				case '"':
					escape = true;
					break;
					
					// Make spaces just in the form of an underline to make
					// them more spacey but easier to see
				case ' ':
					escape = true;
					c = '_';
					break;
					
					// Newline
				case '\n':
					escape = true;
					c = 'n';
					break;
					
					// Carriage return
				case '\r':
					escape = true;
					c = 'r';
					break;
					
					// Tab
				case '\t':
					escape = true;
					c = 't';
					break;
					
					// Opening brace
				case '{':
					escape = true;
					c = '(';
					break;
					
					// Closing brace
				case '}':
					escape = true;
					c = ')';
					break;
					
					// Delete
				case 0x7F:
					escape = true;
					c = 'd';
					break;
				
				case 0x00:
				case 0x01:
				case 0x02:
				case 0x03:
				case 0x04:
				case 0x05:
				case 0x06:
				case 0x07:
				case 0x08:
				case 0x0b:
				case 0x0c:
				case 0x0e:
				case 0x1f:
				case 0x10:
				case 0x11:
				case 0x12:
				case 0x13:
				case 0x14:
				case 0x15:
				case 0x16:
				case 0x17:
				case 0x18:
				case 0x19:
				case 0x1a:
				case 0x1b:
				case 0x1c:
				case 0x1d:
				case 0x1e:
					escape = true;
					c = (char)((c < 10 ? '0' + c : 'A' + (c - 10)));
					break;
				
					// Not changed
				default:
					break;
			}
			
			// Character is out of range?
			if (c >= 0x7F)
				sb.append(String.format("\\@%04x", (int)c));
			
			// Append printable
			else
			{
				if (escape)
					sb.append('\\');
				sb.append(c);
			}
		}
		
		return sb.toString();
	}
	
	/**
	 * Serialize the given object to a string.
	 *
	 * @param __o The value to serialize.
	 * @return The resulting serialization.
	 * @since 2019/01/20
	 */
	public static final String serialize(Object __o)
	{
		// Null
		if (__o == null)
			return "null";
		
		// No result generated
		else if (__o instanceof __NoResult__)
			return "NoResult";
		
		// Undefined
		else if (__o instanceof __UndefinedResult__)
			return "UndefinedResult";
		
		// Exception was thrown
		else if (__o instanceof __ExceptionThrown__)
			return "ExceptionThrown";
		
		// No exception was thrown
		else if (__o instanceof __NoExceptionThrown__)
			return "NoExceptionThrown";
		
		// Boolean values
		else if (__o instanceof Boolean)
			return __o.toString();
		
		// String
		else if (__o instanceof String)
			return "string:" + DataSerialization.encodeString((String)__o);
		
		// Byte
		else if (__o instanceof Byte)
			return "byte:" + __o;
		
		// Short
		else if (__o instanceof Short)
			return "short:" + __o;
		
		// Character
		else if (__o instanceof Character)
			return "char:" + (int)((Character)__o).charValue();
		
		// Integer
		else if (__o instanceof Integer)
			return "int:" + __o;
		
		// Long
		else if (__o instanceof Long)
			return "long:" + __o;
		
		// Byte array
		else if ((__o instanceof byte[]) || __o instanceof Byte[])
		{
			// Convert first
			if (__o instanceof Byte[])
			{
				Byte[] a = (Byte[])__o;
				int n = a.length;
				byte[] b = new byte[n];
				for (int i = 0; i < n; i++)
				{
					Byte v = a[i];
					b[i] = (v == null ? 0 : v.byteValue());
				}
				__o = b;
			}
			
			// Print values
			byte[] a = (byte[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("byte[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// Short array
		else if ((__o instanceof short[]) || __o instanceof Short[])
		{
			// Convert first
			if (__o instanceof Short[])
			{
				Short[] a = (Short[])__o;
				int n = a.length;
				short[] b = new short[n];
				for (int i = 0; i < n; i++)
				{
					Short v = a[i];
					b[i] = (v == null ? 0 : v.shortValue());
				}
				__o = b;
			}
			
			// Print values
			short[] a = (short[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("short[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// Character array
		else if ((__o instanceof char[]) || __o instanceof Character[])
		{
			// Convert first
			if (__o instanceof Character[])
			{
				Character[] a = (Character[])__o;
				int n = a.length;
				char[] b = new char[n];
				for (int i = 0; i < n; i++)
				{
					Character v = a[i];
					b[i] = (v == null ? 0 : v.charValue());
				}
				__o = b;
			}
			
			// Print values
			char[] a = (char[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("char[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append((int)a[i]);
			}
			return sb.toString();
		}
		
		// Integer array
		else if ((__o instanceof int[]) || __o instanceof Integer[])
		{
			// Convert first
			if (__o instanceof Integer[])
			{
				Integer[] a = (Integer[])__o;
				int n = a.length;
				int[] b = new int[n];
				for (int i = 0; i < n; i++)
				{
					Integer v = a[i];
					b[i] = (v == null ? 0 : v.intValue());
				}
				__o = b;
			}
			
			// Print values
			int[] a = (int[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("int[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(a[i]);
			}
			return sb.toString();
		}
		
		// String array
		else if (__o instanceof String[])
		{
			// Print values
			String[] a = (String[])__o;
			int n = a.length;
			StringBuilder sb = new StringBuilder(
				String.format("string[%d]:", n));
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append(",");
				sb.append(DataSerialization.encodeString(a[i]));
			}
			return sb.toString();
		}
		
		// Throwable, meta data is used
		else if (__o instanceof Throwable)
		{
			Throwable t = (Throwable)__o;
			
			StringBuilder sb = new StringBuilder("throwable:");
			
			// The last package to shorten the classes
			String lastpkg = "java.lang.";
			
			// Throwables may be of multiple class types and it usually is
			// expected that they are some base class. For example a class
			// can thrown some FooIndexOutOfBoundsException which is based
			// off IndexOutOfBoundsException, if the result expects the
			// base class then it must still pass. So store the entire class
			// tree.
			boolean comma = false;
			for (Class<?> x = t.getClass(); x != null && x != Object.class;
				x = x.getSuperclass())
			{
				// Clip off the package if it matches
				String clname = x.getName();
				if (clname.startsWith(lastpkg))
					clname = clname.substring(lastpkg.length());
				
				// Otherwise remember the package used
				else
				{
					int ld = clname.lastIndexOf('.');
					if (ld >= 0)
						lastpkg = clname.substring(0, ld + 1);
					
					// Maybe default package?
					else
						lastpkg = "";
				}
				
				// Split to encode multiple classes
				if (comma)
					sb.append(',');
				comma = true;
				
				// Append class name here
				sb.append(clname);
			}
			
			// For debug purposes, encode the message information
			String msg = t.getMessage();
			if (msg != null)
			{
				sb.append(':');
				sb.append(DataSerialization.encodeString(msg));
			}
			
			// Now metadata is included for this
			return sb.toString();
		}
		
		// Unrepresented object, just use its string representation in an
		// encoded form
		else
			return "other:" + __o.getClass().getName() + ":" +
				DataSerialization.encodeString(__o.toString());
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/DeadlockTimeout.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
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





















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a thread which.
 *
 * @since 2019/05/09
 */
public final class DeadlockTimeout
	extends Thread
{
	/** Default deadlock time in milliseconds. */
	public static final int DEFAULT_TIMEOUT =
		30_000;
	
	/** The timeout time. */
	protected final long timeoutnano;
	
	/** Has this execution expired? */
	private volatile boolean _expired;
	
	/**
	 * Initializes a timeout thread.
	 *
	 * @since 2019/05/09
	 */
	public DeadlockTimeout()
	{
		this(DEFAULT_TIMEOUT);
	}
	
	/**
	 * Initializes a timeout thread for the given duration.
	 *
	 * @param __ms The timeout in milliseconds.
	 * @since 2019/05/09
	 */
	public DeadlockTimeout(int __ms)
	{
		super("TestDeadlockTimeout");
		
		__ms = (__ms <= 0 ? DEFAULT_TIMEOUT : __ms);
		
		this.timeoutnano = System.nanoTime() + (__ms * 1000000L);
	}
	
	/**
	 * Expires this timeout watch.
	 *
	 * @since 2019/05/09
	 */
	public final void expire()
	{
		// Set as expired
		this._expired = true;
		
		// Also interrupt the thread so it resumes
		this.interrupt();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/09
	 */
	@Override
	public final void run()
	{
		// When does this time out?
		long timeoutnano = this.timeoutnano;
		
		// Expiration check loop
		for (;;)
		{
			// Watchdog has expired
			if (this._expired)
				break;
			
			// Has timed out?
			long now = System.nanoTime();
			if (now >= timeoutnano)
			{
				// Print a nasty message
				System.err.println("*** TEST TIMED OUT! ***");
				
				// Exit
				System.exit(-4);
				break;
			}
			
			// Sleep to wait for it
			try
			{
				// Calculate duration
				int durms = (int)((timeoutnano - now) / 1000000L);
				if (durms < 1)
					durms = 1;
				
				// Sleep
				Thread.sleep(durms);
			}
			
			// Ignore any interruptions, just re-run the loop
			catch (InterruptedException e)
			{
			}
		}
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/InvalidTestException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is thrown when a test is not valid.
 *
 * @since 2018/10/06
 */
public class InvalidTestException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestException(Throwable __c)
	{
		super(__c);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/InvalidTestParameterException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is thrown when the parameter of a test is not correct.
 *
 * @since 2018/10/06
 */
public class InvalidTestParameterException
	extends InvalidTestException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestParameterException(Throwable __c)
	{
		super(__c);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/InvalidTestResultException.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
































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is thrown when the result of a test is not valid.
 *
 * @since 2018/10/06
 */
public class InvalidTestResultException
	extends InvalidTestException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2018/10/06
	 */
	public InvalidTestResultException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2018/10/06
	 */
	public InvalidTestResultException(Throwable __c)
	{
		super(__c);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestBiConsumer.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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is a test which takes two parameters and produces no result.
 *
 * @param <A> The first argument type.
 * @param <B> The second argument type.
 * @since 2018/10/06
 */
public abstract class TestBiConsumer<A, B>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @param __b The second parameter.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test(A __a, B __b)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU03 Test takes two parameters.}
		if (__args.length != 2)
			throw new InvalidTestParameterException("BU03");
		
		// Run the test
		this.test((A)__args[0], (B)__args[1]);
		
		// No result is generated
		return new __NoResult__();
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestBiFunction.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This represents a test which takes two parameters and returns a result.
 *
 * @param <A> The first parameter type.
 * @param <B> The second parameter type.
 * @param <R> The result type.
 * @since 2018/10/06
 */
public abstract class TestBiFunction<A, B, R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @param __b The second parameter.
	 * @return The result
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test(A __a, B __b)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU04 Test takes two parameters.}
		if (__args.length != 2)
			throw new InvalidTestParameterException("BU04");
		
		// Run the test
		return this.test((A)__args[0], (B)__args[1]);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestBoolean.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns a boolean.
 *
 * @since 2019/12/25
 */
public abstract class TestBoolean
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/25
	 */
	public abstract boolean test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/25
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0f Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0e");
		
		// Run the test
		return Boolean.valueOf(this.test());
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestConsumer.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




















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is a test which takes a single parameter and has no result.
 *
 * @param <A> The first argument type.
 * @since 2018/10/06
 */
public abstract class TestConsumer<A>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test(A __a)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU05 Test takes one parameter.}
		if (__args.length != 1)
			throw new InvalidTestParameterException("BU05");
		
		// Run the test
		this.test((A)__args[0]);
		
		// No result is generated
		return new __NoResult__();
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestFunction.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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This represents a test which takes one parameter and returns a result.
 *
 * @param <A> The first parameter type.
 * @param <R> The result type.
 * @since 2018/10/06
 */
public abstract class TestFunction<A, R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @param __a The first parameter.
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test(A __a)
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	@SuppressWarnings({"unchecked"})
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU06 Test takes one parameter.}
		if (__args.length != 1)
			throw new InvalidTestParameterException("BU06");
		
		// Run the test
		return this.test((A)__args[0]);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestInteger.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns an integer.
 *
 * @since 2019/12/24
 */
public abstract class TestInteger
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/24
	 */
	public abstract int test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0e Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0e");
		
		// Run the test
		return Integer.valueOf(this.test());
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestLong.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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

/**
 * This is a test which returns a long.
 *
 * @since 2019/12/24
 */
public abstract class TestLong
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2019/12/24
	 */
	public abstract long test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2019/12/24
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU0e Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU0e");
		
		// Run the test
		return Long.valueOf(this.test());
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestResult.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486






































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifest;
import net.multiphasicapps.tool.manifest.writer.MutableJavaManifestAttributes;

/**
 * This class contains an immutable result of the test.
 *
 * @since 2019/05/08
 */
public final class TestResult
{
	/** Return value result. */
	protected final String rvalue;
	
	/** Thrown value, if any. */
	protected final String tvalue;
	
	/** Secondary values. */
	private final Map<String, String> _secondary;
	
	/** Hashcode. */
	private int _hash;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the test result.
	 *
	 * @param __rv Return value.
	 * @param __tv Thrown value, if any.
	 * @param __sec Secondary values.
	 * @throws NullPointerException On null arguments or if any secondary
	 * contains a null value.
	 * @since 2019/05/09
	 */
	public TestResult(String __rv, String __tv, Map<String, String> __sec)
		throws NullPointerException
	{
		if (__rv == null || __tv == null || __sec == null)
			throw new NullPointerException("NARG");
		
		// These are simple
		this.rvalue = __rv;
		this.tvalue = __tv;
		
		// Copy map values over
		Map<String, String> to = new SortedTreeMap<>();
		for (Map.Entry<String, String> e : __sec.entrySet())
		{
			String k = e.getKey(),
				v = e.getValue();
			
			if (k == null || v == null)
				throw new NullPointerException("NARG");
			
			to.put(k, v);
		}
		
		// Just can use a linked map
		this._secondary = new LinkedHashMap<>(to);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (__o == this)
			return true;
		
		if (!(__o instanceof TestResult))
			return false;
		
		TestResult o = (TestResult)__o;
		return TestResult.valueEquals(this.rvalue, o.rvalue) &&
			TestResult.valueEquals(this.tvalue, o.tvalue) &&
			TestResult.__equals(this._secondary, o._secondary);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final int hashCode()
	{
		int rv = this._hash;
		if (rv == 0)
			this._hash = (rv = this.rvalue.hashCode() ^
				this.tvalue.hashCode() ^ this._secondary.hashCode());
		return rv;
	}
	
	/**
	 * Prints the comparison of this result and the other result.
	 *
	 * @param __ps The stream to write to.
	 * @param __o The result to compare against.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void printComparison(PrintStream __ps, TestResult __o)
		throws NullPointerException
	{
		if (__o == null || __ps == null)
			throw new NullPointerException("NARG");
		
		// Return value
		TestResult.__printSingleCompare(__ps, "return",
			this.rvalue, __o.rvalue);
		
		// Thrown exception
		TestResult.__printSingleCompare(__ps, "thrown",
			this.tvalue, __o.tvalue);
		
		// Secondary value comparison, more complex since both maps might not
		// contain the same values
		Map<String, String> as = this._secondary,
			bs = __o._secondary;
		
		// Create merged key set so that all keys from both maps are used
		Set<String> merged = new SortedTreeSet<>();
		merged.addAll(as.keySet());
		merged.addAll(bs.keySet());
		
		// Do comparisons on all values
		for (String k : merged)
			TestResult.__printSingleCompare(__ps, k,
				as.get(k), bs.get(k));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/08
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			StringBuilder sb = new StringBuilder();
			
			// Return value
			sb.append("{rv=");
			sb.append(this.rvalue);
			
			// Thrown values
			sb.append(", tv=");
			sb.append(this.tvalue);
			
			// Only add secondaries if they exist
			Map<String, String> secondary = this._secondary;
			if (!secondary.isEmpty())
			{
				sb.append(", sv=");
				sb.append(secondary);
			}
			
			// Done
			sb.append('}');
			
			// Build and cache
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
	
	/**
	 * Writes the test result as a manifest in SquirrelJME's test format.
	 *
	 * @param __os The stream to write to.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	public final void writeAsManifest(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Setup manifest
		MutableJavaManifest man = new MutableJavaManifest();
		MutableJavaManifestAttributes attr = man.getMainAttributes();
		
		// Add values to it
		attr.putValue("result", this.rvalue);
		attr.putValue("thrown", this.tvalue);
		for (Map.Entry<String, String> e : this._secondary.entrySet())
			attr.putValue(
				"secondary-" + DataSerialization.encodeKey(e.getKey()),
				e.getValue());
		
		// Write it
		man.write(__os);
	}
	
	/**
	 * Loads test results for the specified class.
	 *
	 * @param __cl The results to load.
	 * @return The results of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/08
	 */
	public static final TestResult loadForClass(Class<?> __cl)
		throws NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		// We are going to recursively go up the class chain and load values
		// from the manifest into our result
		TestResultBuilder rv = new TestResultBuilder();
		for (Class<?> at = __cl; at != null; at = at.getSuperclass())
		{
			// Determine base name of the class
			String atname = at.getName();
			int ld = atname.lastIndexOf('.');
			String atbase = (ld < 0 ? atname : atname.substring(ld + 1));
			
			// Parse and handle manifest
			JavaManifest man;
			try (InputStream in = at.getResourceAsStream(atbase + ".in"))
			{
				// No manifest here, ignore
				if (in == null)
					continue;
				
				// Parse
				man = new JavaManifest(in);
			}
			
			// Ignore
			catch (IOException e)
			{
				continue;
			}
			
			// Work with attributes and decode them
			JavaManifestAttributes attr = man.getMainAttributes();
			for (Map.Entry<JavaManifestKey, String> e : attr.entrySet())
			{
				String ekey = e.getKey().toString().toLowerCase(),
					eval = e.getValue();
				
				// Depends on the encoded key
				switch (ekey)
				{
						// Returned value
					case "result":
						if (rv.getReturn() == null)
							rv.setReturnEncoded(eval);
						break;
					
						// Thrown value
					case "thrown":
						if (rv.getThrown() == null)
							rv.setThrownEncoded(eval);
						break;
						
						// Possibly handle secondary values
					default:
						if (ekey.startsWith("secondary-"))
						{
							String skey = DataDeserialization.decodeKey(
								ekey.substring(10));
							
							if (rv.getSecondary(skey) == null)
								rv.putSecondaryEncoded(skey, eval);
						}
						break;
				}
			}
		}
		
		// Done
		return rv.build();
	}
	
	/**
	 * Decodes a list of throwable and returns them.
	 *
	 * @param __ts The throwables to decode.
	 * @return The list of used throwables.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09 
	 */
	public static final List<String> throwableList(String __ts)
		throws NullPointerException
	{
		if (__ts == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.error BU07 Not a throwable.}
		if (!__ts.startsWith("throwable:"))
			throw new IllegalArgumentException("BU07");
		__ts = __ts.substring(10);
		
		// Snip off the optional debug message
		int lm = __ts.indexOf(':');
		if (lm >= 0)
			__ts = __ts.substring(0, lm);
		
		// Snip into string list, note that java.lang is initially implicit
		// and remaining values use a shortened form
		List<String> rv = new ArrayList<>();
		String baseform = "java.lang";
		for (int i = 0, n = __ts.length(); i < n;)
		{
			// Find split or where this ends
			int lc = __ts.indexOf(',', i);
			if (lc < 0)
				lc = n;
			
			// Snip this part out
			String sub = __ts.substring(i, lc);
			
			// Change of base?
			int ld = sub.lastIndexOf('.');
			if (ld >= 0)
			{
				baseform = sub.substring(0, ld);
				sub = sub.substring(ld + 1);
			}
			
			// Add full form
			rv.add(baseform + "." + sub);
			
			// Process next split
			i = lc + 1;
		}
		
		return rv;
	}
	
	/**
	 * Compares two value strings against each other.
	 *
	 * @param __act The actual value.
	 * @param __exp The expected value.
	 * @return If the strings are a match.
	 * @throws InvalidTestParameterException If a throwable is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	public static final boolean valueEquals(String __act, String __exp)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__act == null || __exp == null)
			throw new NullPointerException("NARG");
		
		// Throwables are special cases since they represent multiple classes
		if (__act.startsWith("throwable:") && __exp.startsWith("throwable:"))
		{
			// Get all elements for both
			List<String> la = TestResult.throwableList(__act),
				lb = TestResult.throwableList(__exp);
			
			todo.DEBUG.note("%s ~~= %s", la, lb);
			
			// These are considered equal if they have anything in common
			la.retainAll(lb);
			return !la.isEmpty();
		}
		
		// Use normal string comparison
		return __exp.equals(__act);
	}
	
	/**
	 * Compares the map of strings to see that they are equal.
	 *
	 * @param __act The actual values.
	 * @param __exp The expected values.
	 * @return If the maps are a match.
	 * @throws InvalidTestParameterException If a throwable is not formatted
	 * correctly.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/07
	 */
	private static boolean __equals(Map<String, String> __act,
		Map<String, String> __exp)
		throws InvalidTestParameterException, NullPointerException
	{
		if (__act == null || __exp == null)
			throw new NullPointerException("NARG");
		
		// Compare from the first map
		for (Map.Entry<String, String> a : __act.entrySet())
		{
			String key = a.getKey();
			
			// Second is missing key
			if (!__exp.containsKey(key))
				return false;
			
			// Match value
			if (!TestResult.valueEquals(a.getValue(), __exp.get(key)))
				return false;
		}
		
		// Just scan through the keys in the second map, if any keys are
		// missing then extra keys were added
		for (String k : __exp.keySet())
			if (!__act.containsKey(k))
				return false;
		
		// Is a match
		return true;
	}
	
	/**
	 * Prints single comparison.
	 *
	 * @param __ps The stream to print to.
	 * @param __key The key being printed.
	 * @param __a The first value.
	 * @param __b The second value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	private static final void __printSingleCompare(PrintStream __ps,
		String __key, String __a, String __b)
		throws NullPointerException
	{
		if (__ps == null || __key == null)
			throw new NullPointerException("NARG");
		
		// Not the same?
		boolean equals;
		if (__a == null || (__a == null) != (__b == null))
			equals = Objects.equals(__a, __b);
		
		// Compare values otherwise
		else
			equals = TestResult.valueEquals(__a, __b);
		
		// Do not print null as is because it can be confused for actual null
		// values
		if (__a == null)
			__a = "-???-";
		if (__b == null)
			__b = "-???-";
		
		// Print out
		__ps.printf("\t%-15s %c %s %s%n", __key, (equals ? '=' : '!'),
			__a, __b);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestResultBuilder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214






















































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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 net.multiphasicapps.tac;

import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This is used to build {@link TestResult} and is used by the code which
 * loads expected results and builds results.
 *
 * @since 2019/05/08
 */
public final class TestResultBuilder
{
	/** Secondary test values. */
	private final Map<String, String> _secondary =
		new SortedTreeMap<>();
	
	/** Returned value. */
	private volatile String _rvalue;
	
	/** Thrown value. */
	private volatile String _tvalue;
	
	/**
	 * Builds the actual test result.
	 *
	 * @return The test result.
	 * @since 2019/05/09
	 */
	public final TestResult build()
	{
		// Lock
		synchronized (this)
		{
			// Fallback return value
			String rvalue = this._rvalue;
			if (rvalue == null)
				rvalue = "ResultWasNotSpecified";
				
			// Fallback throw value
			String tvalue = this._tvalue;
			if (tvalue == null)
				tvalue = "ExceptionWasNotSpecified";
			
			// Build result
			return new TestResult(rvalue, tvalue, this._secondary);
		}
	}
	
	/**
	 * Gets the return value.
	 *
	 * @return The return value.
	 * @since 2019/05/09
	 */
	public final String getReturn()
	{
		synchronized (this)
		{
			return this._rvalue;
		}
	}
	
	/**
	 * Returns the secondary value.
	 *
	 * @param __key The key to get.
	 * @return The value of the secondary or {@code null} if it was not set.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final String getSecondary(String __key)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			return this._secondary.get(__key.toLowerCase());
		}
	}
	
	/**
	 * Gets the exception value.
	 *
	 * @return The exception value.
	 * @since 2019/05/09
	 */
	public final String getThrown()
	{
		synchronized (this)
		{
			return this._tvalue;
		}
	}
	
	/**
	 * Stores a secondary test value which has already been encoded.
	 *
	 * @param __key The test key.
	 * @param __val The test value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void putSecondaryEncoded(String __key, String __val)
		throws NullPointerException
	{
		if (__key == null || __val == null)
			throw new NullPointerException("NARG");
		
		// Make it thread safe
		Map<String, String> secondary = this._secondary;
		synchronized (this)
		{
			// Use formatted values
			secondary.put(__key.toLowerCase(), __val);
			
			// Debug
			todo.DEBUG.note("%s=%s", __key, __val);
		}
	}
	
	/**
	 * Adds a secondary test value which is a result of something, the value
	 * is always encoded to a string form.
	 *
	 * @param __key The test key.
	 * @param __val The test value.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void putSecondaryValue(String __key, Object __val)
		throws NullPointerException
	{
		if (__key == null)
			throw new NullPointerException("NARG");
		
		// Encode the values
		this.putSecondaryEncoded(__key, DataSerialization.serialize(__val));
	}
	
	/**
	 * Sets the encoded return value.
	 *
	 * @param __val The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void setReturnEncoded(String __val)
		throws NullPointerException
	{
		if (__val == null)
			throw new NullPointerException("NARG");
		
		// Thread safe!
		synchronized (this)
		{
			this._rvalue = __val;
		}
	}
	
	/**
	 * Sets the return value.
	 *
	 * @param __val The value to use.
	 * @since 2019/05/09
	 */
	public final void setReturnValue(Object __val)
	{
		this.setReturnEncoded(DataSerialization.serialize(__val));
	}
	
	/**
	 * Sets the encoded thrown value.
	 *
	 * @param __val The value to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/09
	 */
	public final void setThrownEncoded(String __val)
		throws NullPointerException
	{
		if (__val == null)
			throw new NullPointerException("NARG");
		
		// Thread safe!
		synchronized (this)
		{
			this._tvalue = __val;
		}
	}
	
	/**
	 * Sets the thrown value.
	 *
	 * @param __val The value to use.
	 * @since 2019/05/09
	 */
	public final void setThrownValue(Object __val)
	{
		this.setThrownEncoded(DataSerialization.serialize(__val));
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestRunnable.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is a test which has no input and produces no output, it just runs.
 *
 * @since 2018/10/06
 */
public abstract class TestRunnable
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract void test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU08 Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU08");
		
		// Run the test
		this.test();
		
		// No result is generated
		return new __NoResult__();
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestStatus.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






































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is that status of a test.
 *
 * @since 2018/10/07
 */
public enum TestStatus
{
	/** Success. */
	SUCCESS,
	
	/** Failed. */
	FAILED,
	
	/** Failed due to test exception. */
	TEST_EXCEPTION,
	
	/** Test was not run yet. */
	NOT_RUN,
	
	/** Untestable. */
	UNTESTABLE,
	
	/** End. */
	;
}

Deleted test/libs/tac/net/multiphasicapps/tac/TestSupplier.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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is a test which returns a result and has no parameters.
 *
 * @param <R> The return type.
 * @since 2018/10/06
 */
public abstract class TestSupplier<R>
	extends __CoreTest__
{
	/**
	 * Runs the specified test.
	 *
	 * @return The result.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	public abstract R test()
		throws Throwable;
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	final Object __runTest(Object... __args)
		throws Throwable
	{
		// {@squirreljme.error BU09 Test does not take any parameters.}
		if (__args.length != 0)
			throw new InvalidTestParameterException("BU09");
		
		// Run the test
		return this.test();
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/UntestableException.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>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is thrown when the test cannot be ran perhaps due to lack of support
 * or otherwise a virtual machine which does not support things.
 *
 * @since 2019/03/04
 */
public class UntestableException
	extends RuntimeException
{
	/**
	 * Initialize the exception with no message or cause.
	 *
	 * @since 2019/03/04
	 */
	public UntestableException()
	{
	}
	
	/**
	 * Initialize the exception with a message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/03/04
	 */
	public UntestableException(String __m)
	{
		super(__m);
	}
	
	/**
	 * Initialize the exception with a message and cause.
	 *
	 * @param __m The message.
	 * @param __c The cause.
	 * @since 2019/03/04
	 */
	public UntestableException(String __m, Throwable __c)
	{
		super(__m, __c);
	}
	
	/**
	 * Initialize the exception with no message and with a cause.
	 *
	 * @param __c The cause.
	 * @since 2019/03/04
	 */
	public UntestableException(Throwable __c)
	{
		super(__c);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/__CoreTest__.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356




































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

import cc.squirreljme.runtime.cldc.lang.ApiLevel;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.microedition.midlet.MIDlet;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.tool.manifest.JavaManifest;
import net.multiphasicapps.tool.manifest.JavaManifestKey;
import net.multiphasicapps.tool.manifest.JavaManifestAttributes;

/**
 * This is the core test framework which handles reading test information and
 * parameters, it forwards internally to other classes which handle
 * parameters and such.
 *
 * @since 2018/10/06
 */
abstract class __CoreTest__
	extends MIDlet
{
	/** {@squirreljme.error test.dump=bool Dump test result manifests?} */
	public static final String DUMP_ACTUAL =
		"test.dump";
	
	/** Final result of the test. */
	final TestResultBuilder _runresult =
		new TestResultBuilder();
	
	/** The status of the test. */
	volatile TestStatus _status =
		TestStatus.NOT_RUN;
	
	/**
	 * Runs the given test with the given arguments and resulting in the
	 * given result.
	 *
	 * @param __args The arguments to the test.
	 * @return The result of the test.
	 * @throws Throwable On any thrown exception.
	 * @since 2018/10/06
	 */
	abstract Object __runTest(Object... __args)
		throws Throwable;
	
	/**
	 * Tests the minimum API level.
	 *
	 * @param __lv The level to test.
	 * @throws InvalidTestException If the API level is not met.
	 * @since 2019/03/14
	 */
	public final void checkApiLevel(int __lv)
		throws InvalidTestException
	{
		// {@squirreljme.error BU0b Minimum API level has not been met.
		// (The required API level)}
		if (!ApiLevel.minimumLevel(__lv))
			throw new InvalidTestException(String.format("BU0b %x", __lv));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	protected final void destroyApp(boolean __u)
	{
		// Not used
	}
	
	/**
	 * Runs the specified test using the given main arguments, if any.
	 *
	 * @param __mainargs The main arguments to the test which allow parameters
	 * to be used accordingly.
	 * @since 2018/10/06
	 */
	public final void runTest(String... __mainargs)
	{
		if (__mainargs == null)
			__mainargs = new String[0];
		
		// Set a watchdog in case our test takes a very long time to execute
		DeadlockTimeout dtimeout = new DeadlockTimeout();
		dtimeout.start();
		
		// Use to name this test
		Class<?> self = this.getClass();
		String classname = self.getName();
		
		// Decode the expected result
		TestResult expected = TestResult.loadForClass(self);
		
		// Read the inputs for the test
		Object[] args = this.__parseInput(self, __mainargs);
		
		// Remember the old output stream because it will be replaced with
		// stderr, this way when tests run they do not inadvertently output
		// to standard output. Standard output being printed to will mess up
		// the test results generated at the end of tac-runner
		PrintStream oldout = System.out;
		
		// This is the result of the test
		TestResultBuilder runresult = this._runresult;
		
		// Run the test, catch any exception to report it
		Object thrown;
		try
		{
			// Set the output stream to standard error as noted above
			try
			{
				System.setOut(System.err);
			}
			catch (SecurityException e)
			{
				// Ignore, oh well
			}
			
			// Run the test
			runresult.setReturnValue(this.__runTest(args));
			runresult.setThrownValue((thrown = new __NoExceptionThrown__()));
		}
		
		// Cannot be tested
		catch (UntestableException e)
		{
			// {@squirreljme.error BU0c Test could not be ran.
			// (The given test)}
			System.err.printf("BU0c %s%n", classname);
			e.printStackTrace(System.err);
			
			// Cannot be tested so it shall fail
			this._status = TestStatus.UNTESTABLE;
			return;
		}
		
		// Test failure
		catch (Throwable t)
		{
			// The test parameter is not valid, so whoops!
			if (t instanceof InvalidTestException)
			{
				// Exception was thrown
				this._status = TestStatus.TEST_EXCEPTION;
				
				// {@squirreljme.error BU0d The test failed to run properly.
				// (The given test)}
				System.err.printf("BU0d %s%n", classname);
				t.printStackTrace(System.err);
				return;
			}
			
			// Indicate an exception was thrown
			runresult.setReturnValue(new __ExceptionThrown__());
			runresult.setThrownValue((thrown = t));
		}
		finally
		{
			// Restore the old output stream
			try
			{
				System.setOut(oldout);
			}
			catch (SecurityException e)
			{
				// Ignore, things happen
			}
		}
		
		// Return actual result
		TestResult actual = runresult.build();
		
		// The test result is exactly the same!
		boolean passed = expected.equals(actual);
		if (passed)
			oldout.printf("%s: PASS %s%n",
				classname, actual);
		
		// Otherwise print information on what has differed within the test
		// so that bugs may potentially be found
		else
		{
			// Failure notice
			oldout.printf("%s: FAIL %s%n",
				classname, actual);
			
			// Print comparison on another stream so it is not used in output
			expected.printComparison(System.err, actual);
		
			// Print the throwable stack since this was not expected
			if (thrown instanceof Throwable)
				((Throwable)thrown).printStackTrace();
		}
		
		// Set test status
		this._status = (passed ? TestStatus.SUCCESS : TestStatus.FAILED);
		
		// Dump test result
		try
		{
			if (Boolean.getBoolean(DUMP_ACTUAL))
				actual.writeAsManifest(System.err);
		}
		catch (IOException|SecurityException e)
		{
		}
		
		// Stop the watchdog so we do not exit
		dtimeout.expire();
	}
	
	/**
	 * Stores a secondary value which can be additionally used as test
	 * comparison.
	 *
	 * @param __key The key to check.
	 * @param __v The value to check.
	 * @throws NullPointerException If no key was specified.
	 * @since 2018/10/07
	 */
	public final void secondary(String __key, Object __v)
		throws NullPointerException
	{
		this._runresult.putSecondaryValue(__key, __v);
	}
	
	/**
	 * Runs the MIDlet, parses input test data then runs the test performing
	 * any test work that is needed.
	 *
	 * @since 2018/10/06
	 */
	protected final void startApp()
	{
		// Just forward to run, no main arguments are used at all
		this.runTest((String[])null);
		
		// There is just a single program, so exit with the test status
		System.exit(this._status.ordinal());
	}
	
	/**
	 * Returns the test status.
	 *
	 * @return The test status.
	 * @since 2018/10/07
	 */
	public final TestStatus status()
	{
		return this._status;
	}
	
	/**
	 * Parses the input file for arguments.
	 *
	 * @param __class The class for this test, used to load off manifests.
	 * @param __mainargs Main program arguments.
	 * @return The input arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/06
	 */
	private Object[] __parseInput(Class<?> __class, String[] __mainargs)
		throws NullPointerException
	{
		if (__class == null)
			throw new NullPointerException("NARG");
		
		__mainargs = (__mainargs == null ? new String[0] : __mainargs.clone());
		
		// This is used to determine the system property prefix along with
		// which class to use
		String classname = __class.getName();
		
		// Determine the base name which is used for resources
		int ld = classname.lastIndexOf('.');
		String basename = (ld < 0 ? classname : classname.substring(ld + 1));
		
		// The system property prefix is just the class name but lowercased
		String sysprefix = classname.toLowerCase();
		
		// Try to see if there are any arguments in the test file
		JavaManifestAttributes attr = null;
		try (InputStream in = __class.getResourceAsStream(basename + ".in"))
		{
			// If the input exists parse and extract the manifest attributes
			if (in != null)
				attr = new JavaManifest(in).getMainAttributes();
		}
		
		// Ignore
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		// Read argument values in this order, to allow new ones to be
		// specified accordingly: main arguments, system properties, the
		// default input manifest
		List<Object> rv = new ArrayList<>();
		for (int i = 1; i >= 1; i++)
		{
			String parse;
			
			// Main arguments first
			if (__mainargs != null && (i - 1) < __mainargs.length)
				parse = __mainargs[i - 1];
			
			// Use other default sources instead
			else
			{
				// System property
				String maybe = System.getProperty(sysprefix + "." + i);
				if (maybe != null)
					parse = maybe;
				
				// Otherwise just read a value from the manifest
				else if (attr != null)
					parse = attr.getValue("argument-" + i);
				
				// Nothing
				else
					parse = null;
			}
			
			// Nothing to parse
			if (parse == null)
				break;
			
			// Deserialize the argument value
			rv.add(DataDeserialization.deserialize(parse));
		}
		
		return rv.<Object>toArray(new Object[rv.size()]);
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/__ExceptionThrown__.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This is an indicator that an exception was thrown.
 *
 * @since 2018/10/06
 */
final class __ExceptionThrown__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __ExceptionThrown__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "ExceptionThrown";
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/__NoExceptionThrown__.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * Indicates that no exception was thrown.
 *
 * @since 2018/10/06
 */
final class __NoExceptionThrown__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __NoExceptionThrown__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "NoExceptionThrown";
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/__NoResult__.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This represents no result.
 *
 * @since 2018/10/06
 */
final class __NoResult__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __NoResult__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "NoResult";
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/__UndefinedResult__.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


















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac;

/**
 * This represents a result which has not been defined.
 *
 * @since 2018/10/06
 */
final class __UndefinedResult__
{
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final boolean equals(Object __o)
	{
		return __o == this || (__o instanceof __UndefinedResult__);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final int hashCode()
	{
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/06
	 */
	@Override
	public final String toString()
	{
		return "UndefinedResult";
	}
}

Deleted test/libs/tac/net/multiphasicapps/tac/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package the the test framework.
 *
 * @since 2018/10/03
 */

package net.multiphasicapps.tac;

Deleted test/mids/NAMESPACE.MF.

1
2
3
4
5
6






-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-Namespace-Title: Test MIDlets
X-SquirrelJME-Namespace-Type: midlet
X-SquirrelJME-Namespace-Description: Programs that can be run to do the 
 actual test stuff.

Deleted test/mids/dump-class/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 54f1baae-2912-41a3-a065-6ed0f881cdf2
X-SquirrelJME-Error: AY
X-SquirrelJME-Name: Class Dumper
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This dumps information about a class file similar to 
 the javap tool.
X-SquirrelJME-Depends: tool-classfile zip
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: net.multiphasicapps.dumpclass.Main

Deleted test/mids/dump-class/net/multiphasicapps/dumpclass/Main.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427











































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpclass;

import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import net.multiphasicapps.classfile.Annotation;
import net.multiphasicapps.classfile.AnnotationTable;
import net.multiphasicapps.classfile.AnnotationValue;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassFlag;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldFlag;
import net.multiphasicapps.classfile.InnerClass;
import net.multiphasicapps.classfile.InnerClasses;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodFlag;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;
import net.multiphasicapps.io.IndentedOutputStream;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * Main entry class for the dumper.
 *
 * @since 2018/05/14
 */
public class Main
{
	/**
	 * Dumps a single annotation.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpAnnotation(IndentedOutputStream __i,
		PrintStream __out, Annotation __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("Type: %s%n", __in.type());
		
		// Print the values of the annotations
		__i.increment();
		for (Map.Entry<MethodName, AnnotationValue> v : __in.keyValueMap().
			entrySet())
			__out.printf("%s=%s%n", v.getKey(), v.getValue());
		__i.decrement();
	}
	
	/**
	 * Dumps the annotation table.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static void dumpAnnotationTable(IndentedOutputStream __i,
		PrintStream __out, AnnotationTable __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		for (Annotation e : __in)
			Main.dumpAnnotation(__i, __out, e);
	}
	
	/**
	 * Dumps byte code.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpByteCode(IndentedOutputStream __i,
		PrintStream __out, ByteCode __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Dump all instructions
		__i.increment();
		for (Instruction v : __in)
			__out.printf("%s%n", v);
		__i.decrement();
	}
		
	/**
	 * Dumps the class information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpClass(IndentedOutputStream __i, PrintStream __out,
		ClassFile __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Base indentation level
		__i.setLevel(0);
		
		__out.printf("*** Class %s ***%n", __in.thisName());
		
		__out.printf("Type:        %s%n", __in.type());
		__out.printf("Extends:     %s%n", __in.superName());
		
		__out.println("Interfaces:");
		__i.increment();
		for (ClassName n : __in.interfaceNames())
			__out.println(n);
		__i.decrement();
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (ClassFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
	
		// Inner classes
		__out.println("Inner Classes:");
		__i.increment();
		Main.dumpInnerClasses(__i, __out, __in.innerClasses());
		__i.decrement();
		
		// Print fields
		__out.println("Fields:");
		__i.increment();
		for (Field m : __in.fields())
			Main.dumpField(__i, __out, m);
		__i.decrement();
		
		// Print fields
		__out.println("Methods:");
		__i.increment();
		for (Method m : __in.methods())
			Main.dumpMethod(__i, __out, m);
		__i.decrement();
		
		// Flush
		__out.println();
		__out.flush();
	}
	
	/**
	 * Dumps field information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpField(IndentedOutputStream __i, PrintStream __out,
		Field __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("--- Field %s ---%n", __in.nameAndType());
		
		__out.printf ("Value:       %s%n", __in.constantValue());
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (FieldFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
	}
	
	/**
	 * Dumps the inner classes.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public static void dumpInnerClasses(IndentedOutputStream __i,
		PrintStream __out, InnerClasses __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Go through each one.
		for (InnerClass ic : __in)
		{
			__out.printf("Class %s%n", ic.name());
			
			__i.increment();
			
			__out.printf("Outer Class: %s%n", ic.outerClass());
			__out.printf("Simple Name: %s%n", ic.simpleName());
			__out.printf("Flags:       %s%n", ic.flags());
			
			__i.decrement();
		}
	}
	
	/**
	 * Dumps method information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpMethod(IndentedOutputStream __i, PrintStream __out,
		Method __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("--- Method %s ---%n", __in.nameAndType());
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (MethodFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
		
		// Print Code
		ByteCode bc = __in.byteCode();
		if (bc != null)
		{
			// Dump byte code
			__out.println("Byte Code:");
			__i.increment();
			Main.dumpByteCode(__i, __out, bc);
			__i.decrement();
			
			// Stack map table
			StackMapTable smt = bc.stackMapTable();
			if (smt != null)
			{
				__out.println("Stack Map Table:");
				__i.increment();
				Main.dumpStackMapTable(__i, __out, smt);
				__i.decrement();
			}
			
			// Dump native code
			__out.println("Native Code:");
			__i.increment();
			Main.dumpNativeCode(__i, __out, __in.nativeCode());
			__i.decrement();
		}
	}
	
	/**
	 * Dumps native code.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpNativeCode(IndentedOutputStream __i,
		PrintStream __out, NativeCode __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Address
		int addr = 0;
		
		// Dump all instructions
		__i.increment();
		for (NativeInstruction v : __in)
			__out.printf("@%d#%s%n", addr++, v);
		__i.decrement();
	}
	
	/**
	 * Dumps stack map table.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpStackMapTable(IndentedOutputStream __i,
		PrintStream __out, StackMapTable __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Dump all instructions
		__i.increment();
		for (Map.Entry<Integer, StackMapTableState> v : __in)
			__out.printf("%d=%s%n", v.getKey(), v.getValue());
		__i.decrement();
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/05/14
	 */
	public static void main(String... __args)
	{
		// Force to exist
		if (__args == null)
			__args = new String[0];
		
		// Indent to make the output nice
		IndentedOutputStream i = new IndentedOutputStream(System.out, ' ');
		PrintStream out = new PrintStream(i, true);
		
		// Dump all of them
		for (String a : __args)
		{
			if (a == null)
				continue;
			
			// Parse the class
			try (InputStream in = Files.newInputStream(Paths.get(a),
				StandardOpenOption.READ))
			{
				// Dump everything in the JAR/ZIP
				if (a.endsWith(".jar") || a.endsWith(".zip"))
					try (ZipStreamReader zip = new ZipStreamReader(in))
					{
						for (;;)
							try (ZipStreamEntry ent = zip.nextEntry())
							{
								if (ent == null)
									break;
								
								if (!ent.name().endsWith(".class"))
									continue;
								
								out.printf(">>> %s <<<%n", ent.name());
								Main.dumpClass(i, out, ClassFile.decode(ent));
							}
							catch (IOException|InvalidClassFormatException e)
							{
								e.printStackTrace();
								continue;
							}
					}
				
				// Treat as class
				else
				{
					out.printf(">>> %s <<<%n", a);
					Main.dumpClass(i, out, ClassFile.decode(in));
				}
			}
			
			// Note it
			catch (IOException|InvalidClassFormatException e)
			{
				e.printStackTrace();
				continue;
			}
		}
	}
}

Deleted test/mids/dump-class/net/multiphasicapps/dumpclass/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the class dumper.
 *
 * @since 2018/05/14
 */

package net.multiphasicapps.dumpclass;

Deleted test/mids/dump-zip/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11











-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 4b20ba4f-4ec6-4b1f-b5c2-738b8b19da60
X-SquirrelJME-Error: AX
X-SquirrelJME-Name: ZIP File Dumper
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This dumps ZIP files.
X-SquirrelJME-Depends: zip io
Microedition-Configuration: CLDC-1.8
Main-Class: net.multiphasicapps.dumpzip.Main

Deleted test/mids/dump-zip/net/multiphasicapps/dumpzip/FileChannelBlockAccessor.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
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

































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpzip;

import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import net.multiphasicapps.zip.blockreader.BlockAccessor;

/**
 * This wraps a file channel and provides block level access to it.
 *
 * @since 2016/12/27
 */
public class FileChannelBlockAccessor
	implements BlockAccessor
{
	/** The file channel to wrap. */
	protected final FileChannel channel;
	
	/**
	 * Initializes the block accessor for the file channel.
	 *
	 * @param __fc The channel to access data from.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public FileChannelBlockAccessor(FileChannel __fc)
		throws IOException, NullPointerException
	{
		// Check
		if (__fc == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.channel = __fc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.channel.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error AX01 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("AX01");
		
		// Just forward to the array variant
		byte[] val = new byte[1];
		int rv = read(__addr, val, 0, 1);
		
		// {@squirreljme.error AX02 Read past end of file.}
		if (rv < 0)
			throw new EOFException("AX02");
		
		return val[0];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error AX03 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("AX03");
		
		// Read until every byte has been read so that partial reads are not
		// returned
		ByteBuffer buf = ByteBuffer.wrap(__b, __o, __l);
		FileChannel channel = this.channel;
		int n;
		while (buf.hasRemaining())
			if (channel.read(buf, __addr + buf.position()) < 0)
				if ((n = buf.position()) <= 0)
					return -1;
				else
					return n;
		
		// Use the read position
		return buf.position();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
		throws IOException
	{
		return this.channel.size();
	}
}

Deleted test/mids/dump-zip/net/multiphasicapps/dumpzip/Main.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
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































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpzip;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This dumps ZIP files to standard output.
 *
 * @since 2017/03/01
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2017/03/01
	 */
	public static void main(String... __args)
	{
		// Nothing can be done
		if (__args == null || __args.length <= 0)
			return;
		
		// Load arguments
		List<String> args = new ArrayList<>();
		for (String s : __args)
			args.add(s);
		
		// Reading by stream rather than by block?
		boolean dostream = "-c".equals(args.get(0));
		if (dostream)
			args.remove(0);
		
		// Nothing to be done?
		if (args.isEmpty())
			return;
		
		// Note the variation
		System.err.println((dostream ? "Dumping by stream." :
			"Dumping by block."));
		
		// Filter files?
		Set<String> filter = new HashSet<>();
		for (int i = 1, n = args.size(); i < n; i++)
			filter.add(args.get(i));
		
		// Open all files and dump entries
		String lastentry = null;
		Path inputzip = Paths.get(args.get(0));
		try (FileChannel fc = FileChannel.open(inputzip,
			StandardOpenOption.READ))
		{
			// As a stream
			if (dostream)
				try (ZipStreamReader zsr = new ZipStreamReader(
					Channels.newInputStream(fc)))
				{
					for (;;)
						try (ZipStreamEntry e = zsr.nextEntry())
						{
							// No more entries
							if (e == null)
								break;
							
							__dump(filter, (lastentry = e.name()), e);
						}
				}
			
			// As a block
			else
				try (ZipBlockReader zsr = new ZipBlockReader(
					new FileChannelBlockAccessor(fc)))
				{
					// Go through all entries
					for (ZipBlockEntry entry : zsr)
						try (InputStream in = entry.open())
						{
							__dump(filter, (lastentry = entry.name()), in);
						}
				}
		}
	
		// {@squirreljme.error AX04 Failed to properly read the specified
		// file. (The file name; The last entry read)}
		catch (IOException e)
		{
			throw new RuntimeException(String.format("AX04 %s %s", inputzip,
				lastentry), e);
		}
	}
	
	/**
	 * Dumps the given stream.
	 *
	 * @param __f The filter used.
	 * @param __n The name of the file.
	 * @param __s The stream to dump.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/22
	 */
	private static void __dump(Set<String> __f, String __n, InputStream __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__f == null || __n == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Filtered?
		if (!__f.isEmpty() && !__f.contains(__n))
			return;
		System.err.printf("> Dumping `%s`...%n", __n);
		
		// Dump bytes
		try (OutputStream os = new HexDumpOutputStream(System.out))
		{
			for (byte[] buf = new byte[512];;)
			{
				int rc = __s.read(buf);
	
				// EOF?
				if (rc < 0)
					break;
		
				// Dump
				os.write(buf, 0, rc);
			}
		}
	}
}

Deleted test/mids/dump-zip/net/multiphasicapps/dumpzip/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the ZIP dumping utility.
 *
 * @since 2017/03/01
 */

package net.multiphasicapps.dumpzip;

Deleted test/mids/javap/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: ca0e8a3e-f97d-aeca-1f61-070d76624d0e
X-SquirrelJME-Error: AV
X-SquirrelJME-Name: Java Class and SquirrelJME Class Dumper
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This utility is used to dump class files 
 and SquirrelJME Minimized classes. This is intended for debugging 
 purposes to inspect various classes and how they look.
X-SquirrelJME-Depends: tool-classfile io
Main-Class: dev.shadowtail.javap.Main
Microedition-Configuration: CLDC-1.8-Compact

Deleted test/mids/javap/dev/shadowtail/javap/Main.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 dev.shadowtail.javap;

/**
 * Main entry class.
 *
 * @since 2019/04/14
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments.
	 * @since 2019/04/14
	 */
	public static final void main(String... __args)
	{
		throw new todo.TODO();
	}
}

Deleted test/mids/javap/dev/shadowtail/javap/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the javap utility.
 *
 * @since 2019/04/14
 */

package dev.shadowtail.javap;

Deleted test/mids/tac-runner/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12
13













-
-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: daf7dd87-8de8-4918-b4b0-c36c42e55688
X-SquirrelJME-Error: AI
X-SquirrelJME-Name: TAC Runner
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This is a system which interacts with 
 SquirrelJME and is able to launch and execute various tests within 
 the environment automatically.
X-SquirrelJME-Depends: meep-swm
Microedition-Configuration: CLDC-1.8-Compact
Main-Class: net.multiphasicapps.tac.runner.Main

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/Database.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
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



































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Suite;
import javax.microedition.swm.SuiteManager;
import javax.microedition.swm.SuiteType;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableCollection;

/**
 * This class loads and stores the database for the test system.
 *
 * @since 2018/10/17
 */
public final class Database
	implements Iterable<SingleUnit>
{
	/** Suite mappings by name. */
	private final Map<String, SingleUnit> _units;
	
	/**
	 * Initializes the database of units.
	 *
	 * @param __it The units to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	public Database(Iterable<SingleUnit> __it)
		throws NullPointerException
	{
		if (__it == null)
			throw new NullPointerException("NARG");
		
		// Map units
		Map<String, SingleUnit> units = new SortedTreeMap<>();
		for (SingleUnit u : __it)
			if (u == null)
				throw new NullPointerException("NARG");
			else
				units.put(u.fullName(), u);
		
		this._units = units;		
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/10/17
	 */
	@Override
	public final Iterator<SingleUnit> iterator()
	{
		return UnmodifiableCollection.<SingleUnit>of(
			this._units.values()).iterator();
	}
	
	/**
	 * Builds the test database.
	 *
	 * @return The built test database.
	 * @since 2018/10/17
	 */
	public static final Database build()
	{
		List<SingleUnit> units = new LinkedList<>();
		
		// Need this to go through all the available suites for testing
		SuiteManager sm = ManagerFactory.getSuiteManager();
		for (Suite s : sm.getSuites(SuiteType.APPLICATION))
		{
			// This is not a test program for SquirrelJME, ignore
			if (!Boolean.valueOf(s.getAttributeValue("x-squirreljme-tests")))
				continue;
			
			// Load single units for tests
			for (Iterator<String> it = s.getMIDlets(); it.hasNext();)
				units.add(new SingleUnit(s, it.next()));
		}
		
		// Build the final database
		return new Database(units);
	}
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/Main.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
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




















































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import java.io.PrintStream;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

/**
 * Main entry class for the TAC runner system.
 *
 * @since 2018/10/17
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments, used to filter tests.
	 * @since 2018/10/17
	 */
	public static void main(String... __args)
	{
		// Load arguments
		if (__args == null)
			__args = new String[0];
		Deque<String> args = new LinkedList<>();
		for (String s : __args)
			if (s != null)
				args.add(s);
		
		// Load the database
		Database db = Database.build();
		
		// List tests?
		if ("-l".equals(args.peekFirst()))
		{
			// Remove it!
			args.pollFirst();
			
			// Banner to standard error
			System.err.println("Available tests:");
			
			// Output the tests to standard output
			PrintStream out = System.out;
			for (SingleUnit u : db)
				out.println(u.fullName());
			
			// Stop
			return;
		}
		
		// Running specific tests? These get crimped accordingly
		Set<String> specific = new HashSet<>(),
			endwild = new HashSet<>(),
			startwild = new HashSet<>();
		while (!args.isEmpty())
		{
			// Ignore nulls
			String s = args.pollFirst();
			if (s == null)
				continue;
			
			// Crimp to simplify it
			s = SingleUnit.__crimpName(s);
			
			// Ending wildcard? Run all tests
			if (s.endsWith("*"))
				endwild.add(s.substring(0, s.length() - 1));
			
			// Starts with wildcard?
			else if (s.startsWith("*"))
				startwild.add(s.substring(1));
			
			// Run specific test
			else
				specific.add(s);
		}
		
		// If there is no specific test, just ignore it
		if (specific.isEmpty())
			specific = null;
		if (endwild.isEmpty())
			endwild = null;
		if (startwild.isEmpty())
			startwild = null;
		
		// Checking for tests?
		boolean check = (specific != null || endwild != null ||
			startwild != null);
		
		// Report for tests to run
		Report report = new Report();
		
		// Run each test
		int total = 0,
			pass = 0,
			fail = 0;
		boolean hasfailed = false;
		for (SingleUnit su : db)
		{
			String fn = su.fullName();
			
			// Check if we want to run this test
			if (check)
			{
				boolean found = false;
				
				// Is this a specific test being run?
				if (specific != null && specific.contains(fn))
					found = true;
				
				// Ends in a wildcard? Run multiple tests?
				if (!found && endwild != null)
					for (String prefix : endwild)
						if (fn.startsWith(prefix))
						{
							found = true;
							break;
						}
				
				// Starts with a wildcard?
				if (!found && startwild != null)
					for (String suffix : startwild)
						if (fn.endsWith(suffix))
						{
							found = true;
							break;
						}
				
				// Not found, ignore!
				if (!found)
					continue;
			}
			
			// Run the test
			System.err.printf("Running %s...%n", fn);
			long startns = System.nanoTime();
			boolean passed = su.run();
			
			// Keep track
			total++;
			if (!passed)
			{
				fail++;
				hasfailed = true;
			}
			else
				pass++;
			
			// How long did this take?
			long durns = System.nanoTime() - startns;
			
			// Send to the report for later usage
			report.add(fn, passed, durns);
		}
		
		// Note it
		System.err.printf("Ran %d tests: %d passed, %d failed.%n",
			total, pass, fail);
		
		// Generate report
		report.generate(System.out, ReportType.JUNIT);
		
		// Exit with failure if there are bad tests
		if (hasfailed)
			System.exit(1);
	}
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/Report.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239















































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import java.io.PrintStream;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;

/**
 * This class contains the partial test report which contains all of the
 * information on which tests have passed and which have failed.
 *
 * @since 2019/01/23
 */
public final class Report
{
	/** Nanoseconds per second. */
	public static final double NANOS_PER_SECOND =
		1_000_000_000D;
		
	/** Properties to print. */
	private static final String[] _PROPERTIES =
		new String[]
		{
			"java.version",
			"java.vendor",
			"java.vendor.email",
			"java.vendor.url",
			"java.vm.name",
			"java.vm.version",
			"cc.squirreljme.apilevel",
			"java.vm.vendor",
			"java.vm.vendor.email",
			"java.vm.vendor.url",
			"java.runtime.name",
			"java.runtime.version",
			"os.name",
			"os.arch",
			"os.version",
			"microedition.locale",
			"microedition.profiles",
			"cc.squirreljme.vm.execpath",
			"cc.squirreljme.vm.freemem",
			"cc.squirreljme.vm.totalmem",
			"cc.squirreljme.vm.maxmem",
			"cc.squirreljme.debug",
		};
	
	/** Report mapping. */
	private final Map<String, ReportItem> _items =
		new SortedTreeMap<>();
	
	/** Number of tests ran. */
	private volatile int _numtests;
	
	/** Number of passes. */
	private volatile int _numpass;
	
	/** Number of failures. */
	private volatile int _numfail;
	
	/** The time spent running tests. */
	private volatile long _totalns;
	
	/**
	 * Adds a single test to the report.
	 *
	 * @param __n The test name.
	 * @param __p Did the test pass?
	 * @param __ns The duration of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void add(String __n, boolean __p, long __ns)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		synchronized (this)
		{
			// Pass/fail counts
			this._numtests++;
			if (__p)
				this._numpass++;
			else
				this._numfail++;
			
			// Time spent in test
			this._totalns += __ns;
			
			// Add item
			this._items.put(__n, new ReportItem(__n, __p, __ns));
		}
	}
	
	/**
	 * Generates the test report.
	 *
	 * @param __out The stream to write to.
	 * @param __t The type to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void generate(PrintStream __out, ReportType __t)
		throws NullPointerException
	{
		if (__out == null || __t == null)
			throw new NullPointerException("NARG");
		
		// Generate report depending on the format
		switch (__t)
		{
				// JUnit test report
			case JUNIT:
				this.generateJUnit(__out);
				break;
			
				// {@squirreljme.error AI01 Unknown report type.}
			default:
				throw new RuntimeException("AI01 " + __t);
		}
	}
	
	/**
	 * Generates a JUnit test report.
	 *
	 * JUnit test reports are XML based, which is quite complex however
	 * the test names and such are simple so we just need to output them
	 * correctly.
	 *
	 * @param __out The stream to write to.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public final void generateJUnit(PrintStream __out)
		throws NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		Map<String, ReportItem> items = this._items;
		int numtests = this._numtests,
			numpass = this._numpass,
			numfail = this._numfail;
		long totalns = this._totalns;
		
		// Lock
		synchronized (this)
		{
			// XML header
			__out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
			
			// Testsuites
			__out.printf("<testsuites failures=\"%d\" " +
				"tests=\"%d\" time=\"%s\">%n",
				numfail, numpass,
				Report.doubleToString(totalns / NANOS_PER_SECOND));
			
			// There is just a single test suite
			__out.printf("<testsuite name=\"SquirrelJME\" " +
				"tests=\"%d\" failures=\"%d\" id=\"0\" time=\"%s\">%n",
				numtests, numfail,
				Report.doubleToString(totalns / NANOS_PER_SECOND));
			
			// Dump environment showing the details of the VM, this is taken
			// from the hello demo. Just used to identify the VM and such.
			__out.println("<properties>");
			for (String p : _PROPERTIES)
				try
				{
					String v = System.getProperty(p);
					if (v != null)
						__out.printf("<property name=\"%s\" value=\"%s\" />%n",
							p, v.replace('"', '\''));
				}
				catch (SecurityException e)
				{
				}
			__out.println("</properties>");
			
			// Print every item
			for (ReportItem i : items.values())
			{
				__out.printf("<testcase name=\"%s\" " +
					"classname=\"%s\" status=\"%s\" time=\"%s\">%n",
					i.name, i.name, (i.passed ? "pass" : "fail"),
					Report.doubleToString(i.duration / NANOS_PER_SECOND));
				
				// Failure gets a note attached
				if (!i.passed)
					__out.println("<failure message=\"Failed.\" />");

				// End
				__out.println("</testcase>");
			}
			
			// End everything
			__out.println("</testsuite>");
			__out.println("</testsuites>");
		}
	}
	
	/**
	 * Converts a double to a string. This is needed because at the time of
	 * this writing doubles are not supported in {@link java.util.Formatter}.
	 *
	 * @param __d The double to convert.
	 * @return The resulting string.
	 * @since 2019/01/23
	 */
	public static final String doubleToString(double __d)
	{
		// Add whole number portion (just cast to number value)
		StringBuilder sb = new StringBuilder();
		sb.append((long)__d);
		
		// Add decimal point
		sb.append(".");
		
		// Add some fraction parts
		long frac = ((long)(__d * 1000.0D)) % 1000L;
		if (frac < 0)
			frac = -frac;
		sb.append(String.format("%03d", frac));
		
		// Build it
		return sb.toString();
	}
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/ReportItem.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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

/**
 * This represents a single report item.
 *
 * @since 2019/01/23
 */
public final class ReportItem
{
	/** The test name. */
	public final String name;
	
	/** Did this test pass? */
	public final boolean passed;
	
	/** Time spent in this test. */
	public final long duration;
	
	/**
	 * Initializes the report item.
	 *
	 * @param __n The test name.
	 * @param __p Did the test pass?
	 * @param __ns The duration of the test.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/01/23
	 */
	public ReportItem(String __n, boolean __p, long __ns)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		this.name = __n;
		this.passed = __p;
		this.duration = __ns;
	}
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/ReportType.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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import java.io.PrintStream;

/**
 * Represents the type of report to make.
 *
 * @since 2019/01/23
 */
public enum ReportType
{
	/** JUnit XML Report. */
	JUNIT,
	
	/** End. */
	;
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/SingleUnit.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
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




































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.tac.runner;

import javax.microedition.swm.Suite;
import javax.microedition.swm.ManagerFactory;
import javax.microedition.swm.Task;
import javax.microedition.swm.TaskManager;
import javax.microedition.swm.TaskStatus;

/**
 * This contains a single test unit which may be run accordingly.
 *
 * @since 2018/10/17
 */
public final class SingleUnit
{
	/** The full name for this suite. */
	protected final String fullname;
	
	/** The suite for this unit. */
	protected final Suite suite;
	
	/** The midlet for this unit. */
	protected final String midlet;
	
	/**
	 * Initializes the unit.
	 *
	 * @param __s The suite of the unit.
	 * @param __m The unit midlet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	public SingleUnit(Suite __s, String __m)
		throws NullPointerException
	{
		if (__s == null || __m == null)
			throw new NullPointerException("NARG");
		
		this.suite = __s;
		this.midlet = __m;
		
		// The MIDlet name can be quite long, so see if there is an internal
		// name for the project used by SquirrelJME
		String sqname = __s.getAttributeValue(
			"X-SquirrelJME-InternalProjectName");
		if (sqname == null)
			sqname = __s.getName();
		else if (sqname.endsWith(".test"))
			sqname = sqname.substring(0, sqname.length() - 5);
		
		// Setup full name
		this.fullname = SingleUnit.__crimpName(sqname) + "." +
			SingleUnit.__crimpName(__m);
	}
	
	/**
	 * The full name for this test.
	 *
	 * @return The full name for this test.
	 * @since 2018/10/29
	 */
	public final String fullName()
	{
		return this.fullname;
	}
	
	/**
	 * Runs the test.
	 *
	 * @return Whether the test was a success or not.
	 * @since 2018/10/17
	 */
	public final boolean run()
	{
		// Start task
		Task task = ManagerFactory.getTaskManager().startTask(
			this.suite, this.midlet);
		
		// Run the task task until it terminates
		for (long mswait = 100;; mswait = Math.min(mswait + 100, 1000))
		{
			// Check status
			TaskStatus status = task.getStatus();
			
			// Depends on the status
			switch (status)
			{
					// Success
				case EXITED_REGULAR:
					return true;
					
					// Failure
				case EXITED_FATAL:
				case EXITED_TERMINATED:
				case START_FAILED:
					return false;
					
					// Unhandled
				default:
					break;
			}
			
			// Wait for the task to do things before checking again
			try
			{
				Thread.sleep(mswait);
			}
			catch (InterruptedException e)
			{
			}
		}
	}
	
	/**
	 * Crimps the name so it fits and is easier to type and such.
	 *
	 * @param __in The input name.
	 * @return The crimped name.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/10/29
	 */
	static final String __crimpName(String __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Strip and lowercase characters
		StringBuilder rv = new StringBuilder();
		for (int i = 0, n = __in.length(); i < n; i++)
		{
			char c = __in.charAt(i);
			
			// Lowercase capitals
			if (c >= 'A' && c <= 'Z')
				c = Character.toLowerCase(c);
			
			// Underscores to hyphens
			else if (c == '_')
				c = '-';
			
			// Ignore anything outside of this range
			else if (!((c >= 'a' && c <= 'z') ||
				(c >= '0' && c <= '9') ||
				c == '.' || c == '-' || c == '*'))
				continue;
			
			rv.append(c);
		}
		
		return rv.toString();
	}
}

Deleted test/mids/tac-runner/net/multiphasicapps/tac/runner/package-info.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the TAC runner which is used to search all of the
 * available suites on the system and be able to execute them as such.
 *
 * @since 2018/10/17
 */

package net.multiphasicapps.tac.runner;

Deleted test/mids/uudecode/META-INF/MANIFEST.MF.

1
2
3
4
5
6
7
8
9
10
11
12












-
-
-
-
-
-
-
-
-
-
-
-
Manifest-Version: 1.0
X-SquirrelJME-UUID: 24c42d7e-8681-4e75-a5fc-0cc7b5117d05
X-SquirrelJME-Error: AZ
X-SquirrelJME-Name: MIME File Decoder
X-SquirrelJME-Vendor: Stephanie Gawroriski
X-SquirrelJME-Version: 0.3.0
X-SquirrelJME-Description: This decodes MIME encoded files (or base64 
 data) and outputs to standard output.
X-SquirrelJME-Depends: io
Microedition-Configuration: CLDC-1.8
Main-Class: net.multiphasicapps.uudecode.Main

Deleted test/mids/uudecode/net/multiphasicapps/uudecode/Main.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.uudecode;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Deque;
import java.util.LinkedList;
import net.multiphasicapps.io.Base64Alphabet;
import net.multiphasicapps.io.Base64Decoder;
import net.multiphasicapps.io.MIMEFileDecoder;

/**
 * Main entry point class.
 *
 * @since 2018/03/05
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/03/05
	 */
	public static void main(String... __args)
		throws IOException
	{
		// Roll into queue
		Deque<String> args = new LinkedList<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.offerLast(a);
		
		// No arguments passed?
		if (args.isEmpty())
		{
			__printHelp();
			System.exit(-1);
		}
		
		// Try to parse command line options
		boolean ignorepadding = false,
			rawdata = false;
__outer:
		for (;;)
		{
			String peek = args.peekFirst();
			switch (peek)
			{
					// Ignore padding
				case "-n":
					ignorepadding = true;
					args.pollFirst();
					break;
					
					// Treat as raw
				case "-r":
					rawdata = true;
					args.pollFirst();
					break;
				
					// Treat rest as files
				case "--":
					args.pollFirst();
					break __outer;
				
					// {@squirreljme.error AZ01 Unknown command line switch.
					// (The switch)}
				default:
					if (peek.startsWith("-"))
						throw new IllegalArgumentException(String.format(
							"AZ01 %d", peek));
					break __outer;
			}
		}
		
		// Go through and handle each file
		OutputStream out = System.out;
		while (!args.isEmpty())
			try (Reader file = new InputStreamReader(Files.newInputStream(
				Paths.get(args.pollFirst()), StandardOpenOption.READ));
				InputStream in = __wrap(file, ignorepadding, rawdata))
			{
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					out.write(buf, 0, rc);
				}
			}
	}
	
	/**
	 * Prints help.
	 *
	 * @since 2018/03/05
	 */
	private static final void __printHelp()
	{
		PrintStream out = System.err;
		
		out.println("Usage: [-n] [-r] [--] (files...)");
		out.println("  -n: Ignore padding.");
		out.println("  -r: Ignore header, treat as raw base64 MIME data.");
	}
	
	/**
	 * Wraps the input stream.
	 *
	 * @param __in The stream to read from.
	 * @param __ip Ignore padding?
	 * @param __rd Treat as raw base64 data.
	 * @return The wrapped input stream.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	private static final InputStream __wrap(Reader __in, boolean __ip,
		boolean __rd)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read of raw data?
		if (__rd)
			return new Base64Decoder(__in, Base64Alphabet.BASIC, __ip);
		
		// Read MIME file
		return new MIMEFileDecoder(__in);
	}
}

Added tools/build.gradle.

Added tools/dump-class/build.gradle.

















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "This dumps information about a class file similar to " +
	"the javap tool."
mainClassName = "net.multiphasicapps.dumpclass.Main"

dependencies
{
	implementation project(":modules:tool-classfile")
	implementation project(":modules:zip")
	implementation project(":modules:io")
}

Added tools/dump-class/src/main/java/net/multiphasicapps/dumpclass/Main.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpclass;

import dev.shadowtail.classfile.nncc.NativeCode;
import dev.shadowtail.classfile.nncc.NativeInstruction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import net.multiphasicapps.classfile.Annotation;
import net.multiphasicapps.classfile.AnnotationTable;
import net.multiphasicapps.classfile.AnnotationValue;
import net.multiphasicapps.classfile.ByteCode;
import net.multiphasicapps.classfile.ClassFile;
import net.multiphasicapps.classfile.ClassFlag;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.Field;
import net.multiphasicapps.classfile.FieldFlag;
import net.multiphasicapps.classfile.InnerClass;
import net.multiphasicapps.classfile.InnerClasses;
import net.multiphasicapps.classfile.Instruction;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.Method;
import net.multiphasicapps.classfile.MethodFlag;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.classfile.StackMapTable;
import net.multiphasicapps.classfile.StackMapTableState;
import net.multiphasicapps.io.IndentedOutputStream;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * Main entry class for the dumper.
 *
 * @since 2018/05/14
 */
public class Main
{
	/**
	 * Dumps a single annotation.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpAnnotation(IndentedOutputStream __i,
		PrintStream __out, Annotation __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("Type: %s%n", __in.type());
		
		// Print the values of the annotations
		__i.increment();
		for (Map.Entry<MethodName, AnnotationValue> v : __in.keyValueMap().
			entrySet())
			__out.printf("%s=%s%n", v.getKey(), v.getValue());
		__i.decrement();
	}
	
	/**
	 * Dumps the annotation table.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/15
	 */
	public static void dumpAnnotationTable(IndentedOutputStream __i,
		PrintStream __out, AnnotationTable __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		for (Annotation e : __in)
			Main.dumpAnnotation(__i, __out, e);
	}
	
	/**
	 * Dumps byte code.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpByteCode(IndentedOutputStream __i,
		PrintStream __out, ByteCode __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Dump all instructions
		__i.increment();
		for (Instruction v : __in)
			__out.printf("%s%n", v);
		__i.decrement();
	}
		
	/**
	 * Dumps the class information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpClass(IndentedOutputStream __i, PrintStream __out,
		ClassFile __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Base indentation level
		__i.setLevel(0);
		
		__out.printf("*** Class %s ***%n", __in.thisName());
		
		__out.printf("Type:        %s%n", __in.type());
		__out.printf("Extends:     %s%n", __in.superName());
		
		__out.println("Interfaces:");
		__i.increment();
		for (ClassName n : __in.interfaceNames())
			__out.println(n);
		__i.decrement();
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (ClassFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
	
		// Inner classes
		__out.println("Inner Classes:");
		__i.increment();
		Main.dumpInnerClasses(__i, __out, __in.innerClasses());
		__i.decrement();
		
		// Print fields
		__out.println("Fields:");
		__i.increment();
		for (Field m : __in.fields())
			Main.dumpField(__i, __out, m);
		__i.decrement();
		
		// Print fields
		__out.println("Methods:");
		__i.increment();
		for (Method m : __in.methods())
			Main.dumpMethod(__i, __out, m);
		__i.decrement();
		
		// Flush
		__out.println();
		__out.flush();
	}
	
	/**
	 * Dumps field information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpField(IndentedOutputStream __i, PrintStream __out,
		Field __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("--- Field %s ---%n", __in.nameAndType());
		
		__out.printf ("Value:       %s%n", __in.constantValue());
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (FieldFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
	}
	
	/**
	 * Dumps the inner classes.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/06/16
	 */
	public static void dumpInnerClasses(IndentedOutputStream __i,
		PrintStream __out, InnerClasses __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Go through each one.
		for (InnerClass ic : __in)
		{
			__out.printf("Class %s%n", ic.name());
			
			__i.increment();
			
			__out.printf("Outer Class: %s%n", ic.outerClass());
			__out.printf("Simple Name: %s%n", ic.simpleName());
			__out.printf("Flags:       %s%n", ic.flags());
			
			__i.decrement();
		}
	}
	
	/**
	 * Dumps method information.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/05/14
	 */
	public static void dumpMethod(IndentedOutputStream __i, PrintStream __out,
		Method __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		__out.printf("--- Method %s ---%n", __in.nameAndType());
		
		// Print flags
		__out.println("Flags:");
		__i.increment();
		for (MethodFlag f : __in.flags())
			__out.println(f);
		__i.decrement();
		
		// Print annotations
		__out.println("Annotations:");
		__i.increment();
		Main.dumpAnnotationTable(__i, __out, __in.annotationTable());
		__i.decrement();
		
		// Print Code
		ByteCode bc = __in.byteCode();
		if (bc != null)
		{
			// Dump byte code
			__out.println("Byte Code:");
			__i.increment();
			Main.dumpByteCode(__i, __out, bc);
			__i.decrement();
			
			// Stack map table
			StackMapTable smt = bc.stackMapTable();
			if (smt != null)
			{
				__out.println("Stack Map Table:");
				__i.increment();
				Main.dumpStackMapTable(__i, __out, smt);
				__i.decrement();
			}
			
			// Dump native code
			__out.println("Native Code:");
			__i.increment();
			Main.dumpNativeCode(__i, __out, __in.nativeCode());
			__i.decrement();
		}
	}
	
	/**
	 * Dumps native code.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpNativeCode(IndentedOutputStream __i,
		PrintStream __out, NativeCode __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Address
		int addr = 0;
		
		// Dump all instructions
		__i.increment();
		for (NativeInstruction v : __in)
			__out.printf("@%d#%s%n", addr++, v);
		__i.decrement();
	}
	
	/**
	 * Dumps stack map table.
	 *
	 * @param __i The controller for indenting.
	 * @param __out The output.
	 * @param __in The input.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static void dumpStackMapTable(IndentedOutputStream __i,
		PrintStream __out, StackMapTable __in)
		throws NullPointerException
	{
		if (__i == null || __out == null || __in == null)
			throw new NullPointerException("NARG");
		
		// Dump all instructions
		__i.increment();
		for (Map.Entry<Integer, StackMapTableState> v : __in)
			__out.printf("%d=%s%n", v.getKey(), v.getValue());
		__i.decrement();
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/05/14
	 */
	public static void main(String... __args)
	{
		// Force to exist
		if (__args == null)
			__args = new String[0];
		
		// Indent to make the output nice
		IndentedOutputStream i = new IndentedOutputStream(System.out, ' ');
		PrintStream out = new PrintStream(i, true);
		
		// Dump all of them
		for (String a : __args)
		{
			if (a == null)
				continue;
			
			// Parse the class
			try (InputStream in = Files.newInputStream(Paths.get(a),
				StandardOpenOption.READ))
			{
				// Dump everything in the JAR/ZIP
				if (a.endsWith(".jar") || a.endsWith(".zip"))
					try (ZipStreamReader zip = new ZipStreamReader(in))
					{
						for (;;)
							try (ZipStreamEntry ent = zip.nextEntry())
							{
								if (ent == null)
									break;
								
								if (!ent.name().endsWith(".class"))
									continue;
								
								out.printf(">>> %s <<<%n", ent.name());
								Main.dumpClass(i, out, ClassFile.decode(ent));
							}
							catch (IOException|InvalidClassFormatException e)
							{
								e.printStackTrace();
								continue;
							}
					}
				
				// Treat as class
				else
				{
					out.printf(">>> %s <<<%n", a);
					Main.dumpClass(i, out, ClassFile.decode(in));
				}
			}
			
			// Note it
			catch (IOException|InvalidClassFormatException e)
			{
				e.printStackTrace();
				continue;
			}
		}
	}
}

Added tools/dump-class/src/main/java/net/multiphasicapps/dumpclass/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the class dumper.
 *
 * @since 2018/05/14
 */

package net.multiphasicapps.dumpclass;

Added tools/dump-zip/build.gradle.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "This dumps ZIP files."
mainClassName = "net.multiphasicapps.dumpzip.Main"

dependencies
{
	implementation project(":modules:io")
	implementation project(":modules:zip")
}

Added tools/dump-zip/src/main/java/net/multiphasicapps/dumpzip/FileChannelBlockAccessor.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpzip;

import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import net.multiphasicapps.zip.blockreader.BlockAccessor;

/**
 * This wraps a file channel and provides block level access to it.
 *
 * @since 2016/12/27
 */
public class FileChannelBlockAccessor
	implements BlockAccessor
{
	/** The file channel to wrap. */
	protected final FileChannel channel;
	
	/**
	 * Initializes the block accessor for the file channel.
	 *
	 * @param __fc The channel to access data from.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/12/27
	 */
	public FileChannelBlockAccessor(FileChannel __fc)
		throws IOException, NullPointerException
	{
		// Check
		if (__fc == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.channel = __fc;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public void close()
		throws IOException
	{
		this.channel.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/29
	 */
	@Override
	public byte read(long __addr)
		throws EOFException, IOException
	{
		// {@squirreljme.error AX01 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("AX01");
		
		// Just forward to the array variant
		byte[] val = new byte[1];
		int rv = this.read(__addr, val, 0, 1);
		
		// {@squirreljme.error AX02 Read past end of file.}
		if (rv < 0)
			throw new EOFException("AX02");
		
		return val[0];
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public int read(long __addr, byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, IOException,
			NullPointerException
	{
		// Check
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("AIOB");
		
		// {@squirreljme.error AX03 Cannot read from a negative offset.}
		if (__addr < 0)
			throw new IOException("AX03");
		
		// Read until every byte has been read so that partial reads are not
		// returned
		ByteBuffer buf = ByteBuffer.wrap(__b, __o, __l);
		FileChannel channel = this.channel;
		int n;
		while (buf.hasRemaining())
			if (channel.read(buf, __addr + buf.position()) < 0)
				if ((n = buf.position()) <= 0)
					return -1;
				else
					return n;
		
		// Use the read position
		return buf.position();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2016/12/27
	 */
	@Override
	public long size()
		throws IOException
	{
		return this.channel.size();
	}
}

Added tools/dump-zip/src/main/java/net/multiphasicapps/dumpzip/Main.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.dumpzip;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.io.HexDumpOutputStream;
import net.multiphasicapps.zip.blockreader.ZipBlockEntry;
import net.multiphasicapps.zip.blockreader.ZipBlockReader;
import net.multiphasicapps.zip.streamreader.ZipStreamEntry;
import net.multiphasicapps.zip.streamreader.ZipStreamReader;

/**
 * This dumps ZIP files to standard output.
 *
 * @since 2017/03/01
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2017/03/01
	 */
	public static void main(String... __args)
	{
		// Nothing can be done
		if (__args == null || __args.length <= 0)
			return;
		
		// Load arguments
		List<String> args = new ArrayList<>();
		for (String s : __args)
			args.add(s);
		
		// Reading by stream rather than by block?
		boolean dostream = "-c".equals(args.get(0));
		if (dostream)
			args.remove(0);
		
		// Nothing to be done?
		if (args.isEmpty())
			return;
		
		// Note the variation
		System.err.println((dostream ? "Dumping by stream." :
			"Dumping by block."));
		
		// Filter files?
		Set<String> filter = new HashSet<>();
		for (int i = 1, n = args.size(); i < n; i++)
			filter.add(args.get(i));
		
		// Open all files and dump entries
		String lastentry = null;
		Path inputzip = Paths.get(args.get(0));
		try (FileChannel fc = FileChannel.open(inputzip,
			StandardOpenOption.READ))
		{
			// As a stream
			if (dostream)
				try (ZipStreamReader zsr = new ZipStreamReader(
					Channels.newInputStream(fc)))
				{
					for (;;)
						try (ZipStreamEntry e = zsr.nextEntry())
						{
							// No more entries
							if (e == null)
								break;
							
							Main.__dump(filter, (lastentry = e.name()), e);
						}
				}
			
			// As a block
			else
				try (ZipBlockReader zsr = new ZipBlockReader(
					new FileChannelBlockAccessor(fc)))
				{
					// Go through all entries
					for (ZipBlockEntry entry : zsr)
						try (InputStream in = entry.open())
						{
							Main.__dump(filter, (lastentry = entry.name()), in);
						}
				}
		}
	
		// {@squirreljme.error AX04 Failed to properly read the specified
		// file. (The file name; The last entry read)}
		catch (IOException e)
		{
			throw new RuntimeException(String.format("AX04 %s %s", inputzip,
				lastentry), e);
		}
	}
	
	/**
	 * Dumps the given stream.
	 *
	 * @param __f The filter used.
	 * @param __n The name of the file.
	 * @param __s The stream to dump.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/08/22
	 */
	private static void __dump(Set<String> __f, String __n, InputStream __s)
		throws IOException, NullPointerException
	{
		// Check
		if (__f == null || __n == null || __s == null)
			throw new NullPointerException("NARG");
		
		// Filtered?
		if (!__f.isEmpty() && !__f.contains(__n))
			return;
		System.err.printf("> Dumping `%s`...%n", __n);
		
		// Dump bytes
		try (OutputStream os = new HexDumpOutputStream(System.out))
		{
			for (byte[] buf = new byte[512];;)
			{
				int rc = __s.read(buf);
	
				// EOF?
				if (rc < 0)
					break;
		
				// Dump
				os.write(buf, 0, rc);
			}
		}
	}
}

Added tools/dump-zip/src/main/java/net/multiphasicapps/dumpzip/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This contains the ZIP dumping utility.
 *
 * @since 2017/03/01
 */

package net.multiphasicapps.dumpzip;

Added tools/pcf-to-sqf/build.gradle.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "This converts PCF font data into SQF fonts " +
	"which are smaller, simpler, and faster to read than supporting PCF " +
	"from within SquirrelJME."
mainClassName = "net.multiphasicapps.pcftosqf.Main"

dependencies
{
	implementation project(":modules:cldc-compact")
	implementation project(":modules:midp-lcdui")
	implementation project(":modules:io")
	implementation project(":modules:collections")
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/GlyphNames.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf;

/**
 * Glyph name conversion.
 *
 * @since 2018/11/28
 */
public class GlyphNames
{
	/**
	 * Converts a glyph name to character index.
	 *
	 * @param __n The name of the glyph.
	 * @return The index of the glyph.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final int toChar(String __n)
		throws NullPointerException
	{
		if (__n == null)
			throw new NullPointerException("NARG");
		
		// Depends
		switch (__n)
		{
			case "uni0000":			return 0;
			case "space":			return ' ';
			case "exclam":			return '!';
			case "quotedbl":		return '"';
			case "numbersign":		return '#';
			case "dollar":			return '$';
			case "percent":			return '%';
			case "ampersand":		return '&';
			case "quotesingle":		return '\'';
			case "parenleft":		return '(';
			case "parenright":		return ')';
			case "asterisk":		return '*';
			case "plus":			return '+';
			case "comma":			return ',';
			case "hyphen":			return '-';
			case "period":			return '.';
			case "slash":			return '/';
			case "zero":			return '0';
			case "one":				return '1';
			case "two":				return '2';
			case "three":			return '3';
			case "four":			return '4';
			case "five":			return '5';
			case "six":				return '6';
			case "seven":			return '7';
			case "eight":			return '8';
			case "nine":			return '9';
			case "colon":			return ':';
			case "semicolon":		return ';';
			case "less":			return '<';
			case "equal":			return '=';
			case "greater":			return '>';
			case "question":		return 63;
			case "at":				return '@';
			case "A":				return 'A';
			case "B":				return 'B';
			case "C":				return 'C';
			case "D":				return 'D';
			case "E":				return 'E';
			case "F":				return 'F';
			case "G":				return 'G';
			case "H":				return 'H';
			case "I":				return 'I';
			case "J":				return 'J';
			case "K":				return 'K';
			case "L":				return 'L';
			case "M":				return 'M';
			case "N":				return 'N';
			case "O":				return 'O';
			case "P":				return 'P';
			case "Q":				return 'Q';
			case "R":				return 'R';
			case "S":				return 'S';
			case "T":				return 'T';
			case "U":				return 'U';
			case "V":				return 'V';
			case "W":				return 'W';
			case "X":				return 'X';
			case "Y":				return 'Y';
			case "Z":				return 'Z';
			case "bracketleft":		return '[';
			case "backslash":		return '\\';
			case "bracketright":	return ']';
			case "asciicircum":		return '^';
			case "underscore":		return '_';
			case "grave":			return '`';
			case "a":				return 'a';
			case "b":				return 'b';
			case "c":				return 'c';
			case "d":				return 'd';
			case "e":				return 'e';
			case "f":				return 'f';
			case "g":				return 'g';
			case "h":				return 'h';
			case "i":				return 'i';
			case "j":				return 'j';
			case "k":				return 'k';
			case "l":				return 'l';
			case "m":				return 'm';
			case "n":				return 'n';
			case "o":				return 'o';
			case "p":				return 'p';
			case "q":				return 'q';
			case "r":				return 'r';
			case "s":				return 's';
			case "t":				return 't';
			case "u":				return 'u';
			case "v":				return 'v';
			case "w":				return 'w';
			case "x":				return 'x';
			case "y":				return 'y';
			case "z":				return 'z';
			case "braceleft":		return '{';
			case "bar":				return '|';
			case "braceright":		return '}';
			case "asciitilde":		return '~';
			case "uni007F":			return 0x7F;
			case "uni00A0":			return 0xA0;
			case "exclamdown":		return 0xA1;
			case "cent":			return 0xA2;
			case "sterling":		return 0xA3;
			case "Euro":			return 0xA4;
			case "yen":				return 0xA5;
			case "Scaron":			return 0xA6;
			case "section":			return 0xA7;
			case "scaron":			return 0xA8;
			case "copyright":		return 0xA9;
			case "ordfeminine":		return 0xAA;
			case "guillemotleft":	return 0xAB;
			case "logicalnot":		return 0xAC;
			case "uni00AD":			return 0xAD;
			case "registered":		return 0xAE;
			case "macron":			return 0xAF;
			case "degree":			return 0xB0;
			case "plusminus":		return 0xB1;
			case "uni00B2":			return 0xB2;
			case "uni00B3":			return 0xB3;
			case "Zcaron":			return 0xB4;
			case "mu":				return 0xB5;
			case "paragraph":		return 0xB6;
			case "periodcentered":	return 0xB7;
			case "zcaron":			return 0xB8;
			case "uni00B9":			return 0xB9;
			case "ordmasculine":	return 0xBA;
			case "guillemotright":	return 0xBB;
			case "OE":				return 0xBC;
			case "oe":				return 0xBD;
			case "Ydieresis":		return 0xBE;
			case "questiondown":	return 0xBF;
			case "Agrave":			return 0xC0;
			case "Aacute":			return 0xC1;
			case "Acircumflex":		return 0xC2;
			case "Atilde":			return 0xC3;
			case "Adieresis":		return 0xC4;
			case "Aring":			return 0xC5;
			case "AE":				return 0xC6;
			case "Ccedilla":		return 0xC7;
			case "Egrave":			return 0xC8;
			case "Eacute":			return 0xC9;
			case "Ecircumflex":		return 0xCA;
			case "Edieresis":		return 0xCB;
			case "Igrave":			return 0xCC;
			case "Iacute":			return 0xCD;
			case "Icircumflex":		return 0xCE;
			case "Idieresis":		return 0xCF;
			case "Eth":				return 0xD0;
			case "Ntilde":			return 0xD1;
			case "Ograve":			return 0xD2;
			case "Oacute":			return 0xD3;
			case "Ocircumflex":		return 0xD4;
			case "Otilde":			return 0xD5;
			case "Odieresis":		return 0xD6;
			case "multiply":		return 0xD7;
			case "Oslash":			return 0xD8;
			case "Ugrave":			return 0xD9;
			case "Uacute":			return 0xDA;
			case "Ucircumflex":		return 0xDB;
			case "Udieresis":		return 0xDC;
			case "Yacute":			return 0xDD;
			case "Thorn":			return 0xDE;
			case "germandbls":		return 0xDF;
			case "agrave":			return 0xE0;
			case "aacute":			return 0xE1;
			case "acircumflex":		return 0xE2;
			case "atilde":			return 0xE3;
			case "adieresis":		return 0xE4;
			case "aring":			return 0xE5;
			case "ae":				return 0xE6;
			case "ccedilla":		return 0xE7;
			case "egrave":			return 0xE8;
			case "eacute":			return 0xE9;
			case "ecircumflex":		return 0xEA;
			case "edieresis":		return 0xEB;
			case "igrave":			return 0xEC;
			case "iacute":			return 0xED;
			case "icircumflex":		return 0xEE;
			case "idieresis":		return 0xEF;
			case "eth":				return 0xF0;
			case "ntilde":			return 0xF1;
			case "ograve":			return 0xF2;
			case "oacute":			return 0xF3;
			case "ocircumflex":		return 0xF4;
			case "otilde":			return 0xF5;
			case "odieresis":		return 0xF6;
			case "divide":			return 0xF7;
			case "oslash":			return 0xF8;
			case "ugrave":			return 0xF9;
			case "uacute":			return 0xFA;
			case "ucircumflex":		return 0xFB;
			case "udieresis":		return 0xFC;
			case "yacute":			return 0xFD;
			case "thorn":			return 0xFE;
			case "ydieresis":		return 0xFF;
			
				// Unknown
			default:
				throw new RuntimeException(__n);
		}
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/Main.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
66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf;

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import net.multiphasicapps.pcftosqf.pcf.PCFFont;

/**
 * This is the main entry point for the font conversion.
 *
 * @since 2018/11/27
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @throws Throwable On any exception.
	 * @since 2018/11/27
	 */
	public static final void main(String... __args)
		throws Throwable
	{
		byte[] sqf;
		try (InputStream in = Files.newInputStream(Paths.get(__args[0])))
		{
			// Read PCF Font
			PCFFont pcf = PCFFont.read(in);
			
			// Convert to SQF
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
			{
				// Convert to SQF
				new SQFConverter(pcf).convertTo(baos);
				
				// Use those bytes
				sqf = baos.toByteArray();
			}
			
			// Check that the font is valid
			try (ByteArrayInputStream bais = new ByteArrayInputStream(sqf))
			{
				SQFFont.read(bais).printGlyphs(System.err);
			}
		}
		
		// Write output SQF
		System.out.write(sqf);
		System.out.flush();
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/SQFConverter.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.pcftosqf.pcf.PCFFont;
import net.multiphasicapps.pcftosqf.pcf.PCFGlyphMap;
import net.multiphasicapps.pcftosqf.pcf.PCFMetric;

/**
 * Converts to SQF format from another font.
 *
 * @since 2018/11/27
 */
public class SQFConverter
{
	/** The input PCF font. */
	protected final PCFFont pcf;
	
	/** The pixel height of the font. */
	protected final int pixelheight;
	
	/** The ascent of the font. */
	protected final int ascent;
	
	/** The descent of the font. */
	protected final int descent;
	
	/** Bytes per scan. */
	protected final int bytesperscan;
	
	/** The character widths. */
	private final byte[] _charwidths =
		new byte[256];
	
	/** Bitmap data. */
	private final byte[] _bitmap;
	
	/** Character to glyph index. */
	private final Map<Integer, Integer> _chartoglyph;
	
	/**
	 * Initializes the converter
	 *
	 * @param __pcf The PCF font to convert.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public SQFConverter(PCFFont __pcf)
		throws NullPointerException
	{
		if (__pcf == null)
			throw new NullPointerException("NARG");
		
		// Set pixels
		this.pcf = __pcf;
		
		// Extract properties
		int ascent = __pcf.accelerators.ascent,
			descent = __pcf.accelerators.descent,
			pixelheight = ascent + descent;
		this.ascent = ascent;
		this.descent = descent;
		this.pixelheight = pixelheight;
		
		// Debug
		todo.DEBUG.note("Asc + Des = PxH: %d + %d = %d",
			ascent, descent, pixelheight);
		
		// Map characters to glyph indexes, that way we can quickly find
		// them as such
		Map<Integer, Integer> chartoglyph = new HashMap<>();
		for (Map.Entry<Integer, String> e : __pcf.glyphnames.names.
			entrySet())
		{
			int ch = GlyphNames.toChar(e.getValue());
			if (ch >= 0)
				chartoglyph.put(ch, e.getKey());
		}
		
		// Store
		this._chartoglyph = chartoglyph;
		
		// Obtain all the widths
		int maxwidth = 0;
		byte[] charwidths = this._charwidths;
		for (int i = 0; i < 256; i++)
		{
			// No glyph here, ignore
			if (!chartoglyph.containsKey(i))
				continue;
			
			// Get the index
			int pcfdx = chartoglyph.get(i);
			
			// The width of this font
			int cw = __pcf.metrics.get(pcfdx).charwidth;
			charwidths[i] = (byte)cw;
			
			// Use greater width
			if (cw > maxwidth)
				maxwidth = cw;
		}
		
		// Bytes per scanline
		int bytesperscan = ((maxwidth - 1) / 8) + 1;
		this.bytesperscan = bytesperscan;
		
		// Setup bitmap
		this._bitmap = new byte[256 * bytesperscan * pixelheight];
	}
	
	/**
	 * Converts the font to SQF.
	 *
	 * @param __os The output stream.
	 * @throws IOException On write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public final void convertTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Get basic details
		int descent = this.descent,
			pixelheight = this.pixelheight,
			bytesperscan = this.bytesperscan;
		
		// Needed to build character data
		byte[] charwidths = this._charwidths;
		byte[] bitmap = this._bitmap;
		
		// Debug
		todo.DEBUG.note("Bitmap size: %d bytes", bitmap.length);
		
		// Used to only map valid characters
		boolean[] isvalidchar = new boolean[256];
		
		// Bits per scan
		int bitsperscan = bytesperscan * 8;
		
		// Draw glyphs
		Map<Integer, Integer> chartoglyph = this._chartoglyph;
		PCFFont pcf = this.pcf;
		for (int i = 0; i < 256; i++)
		{
			// Only draw known characters
			Integer uc = chartoglyph.get(i);
			if (uc == null)
				continue;
			
			// Only draw valid characters
			PCFGlyphMap gm = pcf.bitmap.glyphmaps.get(uc);
			if (gm == null)
				continue;
			
			// Is valid
			isvalidchar[i] = true;
			
			// Get the input glyph data to draw
			byte[] in = gm.data();
			
			// Just print for debugging
			/*for (byte x : in)
				todo.DEBUG.note("%8s", Integer.toString(x & 0xFF, 2));*/
			
			// Determine the output position and where it ends
			int outdx = i * bytesperscan * pixelheight,
				enddx = outdx + bytesperscan;
			
			// Metrics of the PCF are the following
			//  lb v   v rb
			//      ###  | ascent
			//     #   # |
			//     ##### |
			//     #   # |
			//     #   # |
			//        #  + descent
			//       #   |
			PCFMetric metrics = pcf.metrics.get(uc);
			
			// The X position starts at the left side bearing
			// The source X is zero
			int penxstart = metrics.leftsidebearing,
				srcxstart = 0;
			
			// The ending X position is just the right side bearing
			// The source ends at the difference between these
			int penxend = metrics.rightsidebearing,
				srcxend = penxend - penxstart;
			
			// The ascent is the height of the symbol character from the
			// baseline to the top (or top to baseline)
			// The baseline is the font's own ascent
			// The Y position is just the font's ascent minus our ascent
			int baseliney = pcf.accelerators.ascent,
				penystart = baseliney - metrics.charascent,
				srcystart = 0;
			
			// The end Y position is just the ascent and descent of the
			// character
			int srcyend = metrics.charascent + metrics.chardescent,
				penyend = penystart + srcyend;
			
			// The number of bits which make up a single scan of the glyph
			int scanbitlen = (srcxend + 7) & ~7;
			
			// Debug
			/*
			todo.DEBUG.note("src=(%d, %d)->(%d, %d) | pen=(%d, %d)->(%d, %d)",
				srcxstart, srcystart, srcxend, srcyend,
				penxstart, penystart, penxend, penyend);*/
			
			// Go through each pixel in the source glyph and just copy it to
			// the destination
			for (int peny = penystart, srcy = srcystart; peny < penyend;
				peny++, srcy++)
			{
				// Draw each column
				for (int penx = penxstart, srcx = srcxstart; penx < penxend;
					penx++, srcx++)
				{
					// If the pen is outside of the bounds, do not draw
					// anything because it would cause an overflow
					if (penx < 0 || penx >= bitsperscan ||
						peny < 0 || peny >= pixelheight)
						continue;
					
					// Determine the index offset into the input glyph
					// bitmap, additionally map the bit that is used as
					// well which is reversed because it goes from highest
					// to lowest
					int psp = (srcy * scanbitlen) + srcx,
						idx = psp >>> 3,
						sub = 7 - (psp & 7);
					
					/*todo.DEBUG.note("(%d, %d) -> [%d] << %d", srcx, srcy,
						idx, sub);*/
					
					// If the bit is not lit then no pixel is to be drawn
					if ((in[idx] & (1 << sub)) == 0)
						continue;
					
					// Draw into the destination bitmap
					bitmap[outdx + (bytesperscan * peny) + (penx >>> 3)] |=
						(byte)(1 << (penx & 7));
				}
			}
			
			/*
			// Determine the initial pen position. it is based on the bearing
			// and how far down the font is
			// The ascent of the font is length of the font from the baseline
			PCFMetric metrics = pcf.metrics.get(uc);
			int penxstart = metrics.leftsidebearing,
				penystart = (pixelheight - metrics.chardescent) -
					metrics.charascent,
				penxend = penxstart + (metrics.charwidth -
					(metrics.rightsidebearing + metrics.leftsidebearing)),
				penyend = penystart +
					(metrics.charascent + metrics.chardescent),
				py = penystart,
				viswidth = penxend - penxstart;
			
			// Bytes per viswidth
			int bpvw = (viswidth / 8) + 1;
			
			// penystart was (pixelheight - descent) - metrics.charascent
			
			// Draw each line
			for (; py < penyend; py++)
			{
				// Draw each column
				for (int px = penxstart; px < penxend; px++)
				{
					todo.DEBUG.note("Pen=(%d, %d)", px, py);
					
					// Pen outside bounds of destination character?
					if (px < 0 || px >= bitsperscan ||
						py < 0 || py >= pixelheight)
						continue;
					
					// Difference between the pen positions
					int pdiffx = (px - penxstart),
						pdiffy = (py - penystart);
					
					// Glyph pixels are padded to bytes
					int adx = pdiffy * bpvw;
					
					// Outside the array bounds
					if (adx < 0 || adx >= in.length)
						continue;
					
					// Figure out the position to check in the sub-pixel
					// Higher values are higher pixels
					int subpx = 7 - (pdiffx & 0x7);
					
					// If this not lit?
					if ((in[adx] & (1 << subpx)) == 0)
						continue;
					
					bitmap[outdx + (bytesperscan * py) + (px / 8)] |=
						(byte)(1 << (px % 8));
				}
			}
			*/
			/*
			// Draw all input lines
			int sxlimit = (metrics.charwidth + 7) & ~7;
			for (int idx = 0, inn = in.length; idx < inn; idx++, py++)
			{
				// Reset the X position to the starting left side
				px = penxstart;
				
				// Draw for the entire width of the glyph
				for (int sx = 0; sx < sxlimit; sx++, px++)
				{
					// The bitmap is encoded where the higher bits are the
					// left most pixels, so that needs to be swapped
					int subpx = 7 - (sx & 0x7);
					
					// No mark here?
					int uidx = idx + (sx >>> 3);
					if (uidx >= in.length || (in[uidx] & (1 << subpx)) == 0)
						continue;
					
					// Pen outside bounds?
					if (px < 0 || px >= bitsperscan ||
						py < 0 || py >= pixelheight)
						continue;
					
					bitmap[outdx + py + (px / 8)] |= (byte)(1 << (px % 8));
				}
			}*/
		}
		
		// Write font data
		__os.write(pixelheight);
		__os.write(this.ascent);
		__os.write(descent);
		__os.write(bytesperscan);
		__os.write(charwidths);
		
		for (boolean b : isvalidchar)
			__os.write((b ? 1 : 0));
		
		__os.write(bitmap);
		
		// Flush because this might be a buffered output
		__os.flush();
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package is for the conversion of PCFs to SQFs.
 *
 * @since 2018/11/27
 */

package net.multiphasicapps.pcftosqf;

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFAccelerators.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This represents the accelerator table found in PCF fonts, just general
 * information on the font and such.
 *
 * @since 2018/11/27
 */
public final class PCFAccelerators
{
	/** Accelerators with ink bounds. */
	static final int _PCF_ACCEL_W_INKBOUNDS =
		0x00000100;
	
	/** The format. */
	public final int format;
	
	/** No overlap? */
	public final boolean nooverlap;
	
	/** Constant metrics? */
	public final boolean constantmetrics;
	
	/** Terminal font? */
	public final boolean terminalfont;
	
	/** Constant width? */
	public final boolean constantwidth;
	
	/** Ink inside the bounds? */
	public final boolean inkinside;
	
	/** Do the ink metrics differ ever? */
	public final boolean inkmetrics;
	
	/** Draw direction, false=LTR, true=RTL. */
	public final boolean drawdirection;
	
	/** Ascent. */
	public final int ascent;
	
	/** Descent. */
	public final int descent;
	
	/** Maximum overlap. */
	public final int maxoverlap;
	
	/** Minimum bounds. */
	public final PCFMetric minbounds;
	
	/** Maximum bounds. */
	public final PCFMetric maxbounds;
	
	/** Minimum ink bounds, is optional. */
	public final PCFMetric inkminbounds;
	
	/** Maximum ink bounds, is optional. */
	public final PCFMetric inkmaxbounds;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the accelerators.
	 *
	 * @param __format Format
	 * @param __nooverlap No overlap?
	 * @param __constantmetrics Constant metrics?
	 * @param __terminalfont Terminal font?
	 * @param __constantwidth Constant width?
	 * @param __inkinside All inks inside?
	 * @param __inkmetrics Ink metrics?
	 * @param __drawdirection Draw direction LTR or RTL?
	 * @param __ascent Ascent.
	 * @param __descent Descent.
	 * @param __maxoverlap Maximum overlap.
	 * @param __minbounds Minimum bounds.
	 * @param __maxbounds Maximum bounds.
	 * @param __inkminbounds Minimum ink bounds.
	 * @param __inkmaxbounds Maximum ink bounds.
	 * @throws NullPointerException If no min bounds or max bounds were
	 * specified.
	 * @since 2018/11/27
	 */
	PCFAccelerators(int __format, boolean __nooverlap,
		boolean __constantmetrics, boolean __terminalfont,
		boolean __constantwidth, boolean __inkinside, boolean __inkmetrics,
		boolean __drawdirection, int __ascent, int __descent, int __maxoverlap,
		PCFMetric __minbounds, PCFMetric __maxbounds,
		PCFMetric __inkminbounds, PCFMetric __inkmaxbounds)
		throws NullPointerException
	{
		if (__minbounds == null || __maxbounds == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.nooverlap = __nooverlap;
		this.constantmetrics = __constantmetrics;
		this.terminalfont = __terminalfont;
		this.constantwidth = __constantwidth;
		this.inkinside = __inkinside;
		this.inkmetrics = __inkmetrics;
		this.drawdirection = __drawdirection;
		this.ascent = __ascent;
		this.descent = __descent;
		this.maxoverlap = __maxoverlap;
		this.minbounds = __minbounds;
		this.maxbounds = __maxbounds;
		this.inkminbounds = __inkminbounds;
		this.inkmaxbounds = __inkmaxbounds;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/27
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format("{" +
				"format=%x, " +
				"nooverlap=%s, " +
				"constantmetrics=%s, " +
				"terminalfont=%s, " +
				"constantwidth=%s, " +
				"inkinside=%s, " +
				"inkmetrics=%s, " +
				"drawdirection=%s, " +
				"ascent=%s, " +
				"descent=%s, " +
				"maxoverlap=%s, " +
				"minbounds=%s, " +
				"maxbounds=%s, " +
				"inkminbounds=%s, " +
				"inkmaxbounds=%s" +
				"}", this.format,
				this.nooverlap,
				this.constantmetrics,
				this.terminalfont,
				this.constantwidth,
				this.inkinside,
				this.inkmetrics,
				this.drawdirection,
				this.ascent,
				this.descent,
				this.maxoverlap,
				this.minbounds,
				this.maxbounds,
				this.inkminbounds,
				this.inkmaxbounds)));
		
		return rv;
	}
	
	/**
	 * Reads the accelerator data.
	 *
	 * @param __dis The input stream to parse from.
	 * @return The accelerator table.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFAccelerators read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read the format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Fields which might be true for all characters
		boolean nooverlap = (__dis.readByte() != 0);
		boolean constantmetrics = (__dis.readByte() != 0);
		boolean terminalfont = (__dis.readByte() != 0);
		boolean constantwidth = (__dis.readByte() != 0);
		boolean inkinside = (__dis.readByte() != 0);
		boolean inkmetrics = (__dis.readByte() != 0);
		boolean drawdirection = (__dis.readByte() != 0);
		
		// Padding byte
		__dis.readByte();
		
		// Ascent, descent, and max overlap
		int ascent = __dis.readInt();
		int descent = __dis.readInt();
		int maxoverlap = __dis.readInt();
		
		// Read minimum and maximum bounds
		PCFMetric minbounds = PCFMetric.readUncompressed(__dis);
		PCFMetric maxbounds = PCFMetric.readUncompressed(__dis);
		
		// These are optional only if the given format is used
		PCFMetric inkminbounds = null,
			inkmaxbounds = null;
		if ((format & PCFAccelerators._PCF_ACCEL_W_INKBOUNDS) != 0)
		{
			inkminbounds = PCFMetric.readUncompressed(__dis);
			inkmaxbounds = PCFMetric.readUncompressed(__dis);
		}
		
		return new PCFAccelerators(format, nooverlap, constantmetrics,
			terminalfont, constantwidth, inkinside, inkmetrics, drawdirection,
			ascent, descent, maxoverlap, minbounds, maxbounds, inkminbounds,
			inkmaxbounds);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFBitmap.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;

/**
 * This represents the bitmap from within a PCF file.
 *
 * @since 2018/11/28
 */
public final class PCFBitmap
{
	/** The format. */
	public final int format;
	
	/** The number of glyphs. */
	public final int numglyphs;
	
	/** The glyph map. */
	public final Map<Integer, PCFGlyphMap> glyphmaps;
	
	/**
	 * Initializes the bitmap data.
	 *
	 * @param __format The format used.
	 * @param __numglyphs The glyphs used.
	 * @param __offsets The offsets.
	 * @param __data The data.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFBitmap(int __format, int __numglyphs, int[] __offsets,
		byte[] __data)
		throws NullPointerException
	{
		if (__offsets == null || __data == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.numglyphs = __numglyphs;
		
		// This class is used to sort all of the offsets but still keep the
		// original indexes
		final class __Index__
			implements Comparable<__Index__>
		{
			/** The offset. */
			public final int offset;
			
			/** The index. */
			public final int index;
			
			/**
			 * Initializes the index.
			 *
			 * @param __o The offset.
			 * @param __i The index.
			 * @since 2018/11/29
			 */
			__Index__(int __o, int __i)
			{
				this.offset = __o;
				this.index = __i;
			}
			
			/**
			 * {@inheritDoc}
			 * @since 2018/11/29
			 */
			@Override
			public int compareTo(__Index__ __o)
			{
				// Sort by the offset first, but it is possible that some
				// glyphs might share the same offset, so do not lose them!
				int rv = this.offset - __o.offset;
				if (rv != 0)
					return rv;
				return this.index - __o.index;
			}
		}
		
		// Go through all the offsets and determine all of the bounds
		Set<__Index__> index = new SortedTreeSet<>();
		for (int i = 0; i < this.numglyphs; i++)
			index.add(new __Index__(__offsets[i], i));
		
		// Need to determine the bounds for every glyph to extract the data
		// for it, so mark when an index ends and such. So go through
		// and mark where a new glyph starts.
		int datalen = __data.length;
		boolean[] boops = new boolean[datalen];
		for (__Index__ i : index)
			boops[i.offset] = true;
		
		// Build the bitmaps for each map of glyphs so they can be converted
		// accordingly
		Map<Integer, PCFGlyphMap> glyphmaps = new HashMap<>();
		for (__Index__ i : index)
		{
			// Start with a dynamic set of copied byte data
			List<Byte> bm = new ArrayList<>();
			
			// Add all the bits that make up the glyph data there
			for (int o = i.offset; o < datalen;)
			{
				// Add this byte always
				bm.add(__data[o++]);
				
				// Since we are at the next index check for the end or if
				// it signaled a new glyph here
				if (o >= datalen || boops[o])
					break;
			}
			
			// Store the glyph data
			glyphmaps.put(i.index, new PCFGlyphMap(bm));
		}
		
		this.glyphmaps = glyphmaps;
	}
	
	/**
	 * Reads the bitmap data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting bitmap.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFBitmap read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the glyph offsets
		int numglyphs = __dis.readInt();
		int[] offsets = new int[numglyphs];
		for (int i = 0; i < numglyphs; i++)
			offsets[i] = __dis.readInt();
		
		// Read all four bitmap sizes
		int[] bitmapsizes = new int[4];
		for (int i = 0; i < 4; i++)
			bitmapsizes[i] = __dis.readInt();
		
		// The bytes depends on the format
		byte[] data = new byte[bitmapsizes[format & 3]];
		__dis.readFully(data);
		
		// Build bitmap
		return new PCFBitmap(format, numglyphs, offsets, data);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFEncoding.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * This contains the PCF encoding data.
 *
 * @since 2018/11/28
 */
public final class PCFEncoding
{
	/** The format. */
	public final int format;
	
	/** The minimum char or byte 2? */
	public final int mincharorbyte2;
	
	/** The maximum char or byte 2? */
	public final int maxcharorbyte2;
	
	/** Min byte1? */
	public final int minbyte1;
	
	/** Max byte1? */
	public final int maxbyte1;
	
	/** Default character. */
	public final int defaultchar;
	
	/** Glyph indexes. */
	private final int[] _glyphindexes;
	
	/**
	 * Initializes the encoding.
	 *
	 * @param __format Format.
	 * @param __mincharorbyte2 Minimum char or byte2?
	 * @param __maxcharorbyte2 Maximum char or byte2?
	 * @param __minbyte1 Min byte1?
	 * @param __maxbyte1 Max byte1?
	 * @param __defaultchar Default character.
	 * @param __glyphindexes Glyph indexes.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFEncoding(int __format, int __mincharorbyte2,
		int __maxcharorbyte2, int __minbyte1, int __maxbyte1,
		int __defaultchar, int[] __glyphindexes)
		throws NullPointerException
	{
		if (__glyphindexes == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.mincharorbyte2 = __mincharorbyte2;
		this.maxcharorbyte2 = __maxcharorbyte2;
		this.minbyte1 = __minbyte1;
		this.maxbyte1 = __maxbyte1;
		this.defaultchar = __defaultchar;
		this._glyphindexes = __glyphindexes.clone();
	}
	
	/**
	 * Reads the encoding data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting encoding data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFEncoding read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read properties
		int mincharorbyte2 = __dis.readShort(),
			maxcharorbyte2 = __dis.readShort(),
			minbyte1 = __dis.readShort(),
			maxbyte1 = __dis.readShort(),
			defaultchar = __dis.readShort();
		
		// Read index table
		int numglyphindexes = (maxcharorbyte2 - mincharorbyte2 + 1) *
			(maxbyte1 - minbyte1 + 1);
		int[] glyphindexes = new int[numglyphindexes];
		for (int i = 0; i < numglyphindexes; i++)
			glyphindexes[i] = __dis.readShort();
		
		// Build
		return new PCFEncoding(format, mincharorbyte2, maxcharorbyte2,
			minbyte1, maxbyte1, defaultchar, glyphindexes);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFFont.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import net.multiphasicapps.collections.SortedTreeSet;
import net.multiphasicapps.collections.UnmodifiableList;

/**
 * This class is capable of reading PCF formatted fonts and reading all of
 * the information from it.
 *
 * Information on the font is at these locations:
 * * <https://fontforge.github.io/en-US/documentation/reference/pcf-format/>
 * * <https://web.archive.org/web/20020215194039if_/
 *   http://myhome.hananet.net:80/~bumchul/xfont/pcf.txt>
 * * <https://web.archive.org/web/20090205034052/
 *   http://www.tsg.ne.jp:80/GANA/S/pcf2bdf/pcf.pdf>
 *
 * @since 2018/11/25
 */
public class PCFFont
{
	/** Properties. */
	public final PCFProperties properties;
	
	/** Accelerators. */
	public final PCFAccelerators accelerators;
	
	/** Metrics. */
	public final List<PCFMetric> metrics;
	
	/** Bitmap. */
	public final PCFBitmap bitmap;
	
	/** Encoding. */
	public final PCFEncoding encoding;
	
	/** Scalable widths. */
	public final PCFScalableWidths scalablewidths;
	
	/** The glyph names. */
	public final PCFGlyphNames glyphnames;
	
	/**
	 * Initializes the font.
	 *
	 * @param __properties 
	 * @param __accelerators 
	 * @param __metrics 
	 * @param __bitmap 
	 * @param __encoding 
	 * @param __scalablewidths 
	 * @param __glyphnames 
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFFont(PCFProperties __properties, PCFAccelerators __accelerators,
		PCFMetric[] __metrics, PCFBitmap __bitmap, PCFEncoding __encoding,
		PCFScalableWidths __scalablewidths, PCFGlyphNames __glyphnames)
		throws NullPointerException
	{
		if (__properties == null || __accelerators == null ||
			__metrics == null || __bitmap == null || __encoding == null ||
			__scalablewidths == null || __glyphnames == null)
			throw new NullPointerException("NARG");
		
		this.properties = __properties;
		this.accelerators = __accelerators;
		this.metrics = UnmodifiableList.<PCFMetric>of(
			Arrays.<PCFMetric>asList(__metrics.clone()));
		this.bitmap = __bitmap;
		this.encoding = __encoding;
		this.scalablewidths = __scalablewidths;
		this.glyphnames = __glyphnames;
	}
	
	/**
	 * Reads the given stream for PCF font information.
	 *
	 * @param __in The stream to read from.
	 * @return The decoded font information.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/25
	 */
	public static final PCFFont read(InputStream __in)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Need to read in the data!
		DataInputStream dos = new DataInputStream(__in);
		
		// {@squirreljme.error AP01 Invalid PCF magic number.}
		int magic;
		if ((magic = dos.readInt()) != 0x01666370)
			throw new IOException(String.format("AP01 %08x", magic));
		
		// Read each table entry, since they have offsets into the file they
		// could be in any random order which would be bad
		Set<PCFTableEntry> tables = new SortedTreeSet<>();
		int numtables = Integer.reverseBytes(dos.readInt());
		for (int i = 0; i < numtables; i++)
			tables.add(new PCFTableEntry(
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt()),
				Integer.reverseBytes(dos.readInt())));
		
		// Determine the base position of the read pointer
		int readptr = 8 + (numtables * 16);
		
		// Debug
		todo.DEBUG.note("Table: %s, ended at %d", tables, readptr);
		
		// Parsed fields
		PCFProperties pcfp = null;
		PCFAccelerators pcfaccel = null;
		PCFMetric[] metrics = null;
		PCFBitmap bitmap = null;
		PCFEncoding encoding = null;
		PCFScalableWidths scalablewidths = null;
		PCFGlyphNames glyphnames = null;
		
		// Go through all table entries and parse them, they will be sorted
		// by their offset and handled as such
		boolean waseofing = false;
		for (PCFTableEntry te : tables)
		{
			// {@squirreljme.error AP02 Expected EOF to occur on the last
			// entry, this likely means the file was truncated more than
			// what was expected.}
			if (waseofing)
				throw new IOException("AP02");
			
			// Skip bytes needed to reach the destination
			int skippy = te.offset - readptr;
			if (skippy > 0)
				dos.skipBytes(skippy);
			
			// {@squirreljme.error AP03 Negative skip distance.}
			else if (skippy < 0)
				throw new IOException("AP03");
			
			// Debug
			todo.DEBUG.note("Read entry %s", te);
			
			// Read in data that makes up this section, but the entries could
			// be clipped short and have a size larger than the file. So just
			// assume zero padding is used and hope it works
			int tesize;
			byte[] data = new byte[(tesize = te.size)];
			for (int i = 0; i < tesize; i++)
			{
				int rc = dos.read();
				
				// Make sure this is the last entry on EOF!
				if (rc < 0)
				{
					waseofing = true;
					break;
				}
				
				data[i] = (byte)rc;
			}
			
			// Handle the data in the section
			switch (te.type)
			{
					// Properties
				case 1:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						pcfp = PCFProperties.read(dis);
					}
					break;
					
					// Accelerators
				case 2:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						pcfaccel = PCFAccelerators.read(dis);
					}
					break;
					
					// Metrics
				case 4:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						metrics = PCFMetric.readMetrics(dis);
					}
					break;
					
					// Bitmaps
				case 8:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						bitmap = PCFBitmap.read(dis);
					}
					break;
					
					// Ink Metrics (NOT USED???)
				case 16:
					if (true)
						throw new todo.TODO();
					break;
					
					// BDF Encodings
				case 32:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						encoding = PCFEncoding.read(dis);
					}
					break;
					
					// SWidths
				case 64:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						scalablewidths = PCFScalableWidths.read(dis);
					}
					break;
					
					// Glyph Names
				case 128:
					try (DataInputStream dis = new DataInputStream(
						new ByteArrayInputStream(data)))
					{
						glyphnames = PCFGlyphNames.read(dis); 
					}
					break;
					
					// BDF Accelerators
				case 256:
					// Debug
					todo.DEBUG.note("Ignoring BDF Accelerators");
					break;
					
					// {@squirreljme.error AP04 Unknown PCF type. (The type)}
				default:
					throw new IOException("AP04 " + te.type);
			}
			
			// Set pointer for next run
			readptr += te.size;
		}
		
		// Build font
		return new PCFFont(pcfp, pcfaccel, metrics, bitmap,
			encoding, scalablewidths, glyphnames);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFGlyphMap.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.List;

/**
 * This represents the map of a glyph.
 *
 * @since 2018/11/29
 */
public final class PCFGlyphMap
{
	/** The glyph data. */
	private byte[] _data;
	
	/** String form. */
	private Reference<String> _string;
	
	/**
	 * Initializes the glyph map.
	 *
	 * @param __bm The bytes used to make up the map.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public PCFGlyphMap(List<Byte> __bm)
		throws NullPointerException
	{
		if (__bm == null)
			throw new NullPointerException("NARG");
		
		// Copy the data
		int n = __bm.size();
		byte[] data = new byte[n];
		for (int i = 0; i < n; i++)
			data[i] = __bm.get(i);
		
		this._data = data;
	}
	
	/**
	 * Initializes the glyph map.
	 *
	 * @param __bm The bytes used to make up the map.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/29
	 */
	public PCFGlyphMap(byte[] __bm)
		throws NullPointerException
	{
		if (__bm == null)
			throw new NullPointerException("NARG");
		
		this._data = __bm.clone();
	}
	
	/**
	 * Returns a copy of the glyph data.
	 *
	 * @return The glyph data.
	 * @since 2018/11/29
	 */
	public final byte[] data()
	{
		return this._data.clone();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/29
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
		{
			// Setup buffer
			byte[] data = this._data;
			int n = data.length;
			StringBuilder sb = new StringBuilder(16 + (n * 9));
			
			sb.append("glyph[");
			sb.append(n);
			sb.append("]={");
			
			// Build glyph bytes
			for (int i = 0; i < n; i++)
			{
				if (i > 0)
					sb.append('|');
				for (int j = 7; j >= 0; j--)
					sb.append(((data[i] & (1 << j)) != 0 ? '#' : '.'));
			}
			
			sb.append("}");
			
			// Done
			this._string = new WeakReference<>((rv = sb.toString()));
		}
		
		return rv;
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFGlyphNames.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.collections.SortedTreeMap;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * Glyph name table.
 *
 * @since 2018/11/28
 */
public final class PCFGlyphNames
{
	/** The format. */
	public final int format;
	
	/** The glyph names. */
	public final Map<Integer, String> names;
	
	/**
	 * Initializes the glyph names.
	 *
	 * @param __format The format.
	 * @param __names The names.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFGlyphNames(int __format, Map<Integer, String> __names)
		throws NullPointerException
	{
		if (__names == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this.names = UnmodifiableMap.<Integer, String>of(
			new SortedTreeMap<>(__names));
	}
	
	/**
	 * Reads the glyph name data.
	 *
	 * @param __dis The input stream.
	 * @return The resulting glyph names.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFGlyphNames read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the string offsets
		int numglyphs = __dis.readInt();
		int[] offsets = new int[numglyphs];
		for (int i = 0; i < numglyphs; i++)
			offsets[i] = __dis.readInt();
		
		// Read the string table
		int stringsize = __dis.readInt();
		byte[] strings = new byte[stringsize];
		__dis.readFully(strings);
		
		// Map strings to indexes
		Map<Integer, String> names = new HashMap<>();
		for (int i = 0; i < numglyphs; i++)
			names.put(i, PCFProperties.__readString(strings, offsets[i]));
		
		// Build
		return new PCFGlyphNames(format, names);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFMetric.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * This contains a single metric within a PCF file.
 *
 * @since 2018/11/27
 */
public final class PCFMetric
{
	/** Compressed metrics format. */
	static final int _PCF_COMPRESSED_METRICS =
		0x00000100;
	
	/** Left side bearing. */
	public final short leftsidebearing;
	
	/** Right side bearing. */
	public final short rightsidebearing;
	
	/** Character width. */
	public final short charwidth;
	
	/** Character ascent. */
	public final short charascent;
	
	/** Character descent. */
	public final short chardescent;
	
	/** Character attributes. */
	public final int attributes;
	
	/** String representation. */
	private Reference<String> _string;
	
	/**
	 * Initializes the metric.
	 *
	 * @param __lsb Left side bearing.
	 * @param __rsb Right side bearing.
	 * @param __cw Character width.
	 * @param __ca Character ascent.
	 * @param __cd Character descent.
	 * @param __a Attributes.
	 * @since 2018/11/27
	 */
	PCFMetric(short __lsb, short __rsb, short __cw, short __ca,
		short __cd, int __a)
	{
		this.leftsidebearing = __lsb;
		this.rightsidebearing = __rsb;
		this.charwidth = __cw;
		this.charascent = __ca;
		this.chardescent = __cd;
		this.attributes = __a;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/27
	 */
	@Override
	public final String toString()
	{
		Reference<String> ref = this._string;
		String rv;
		
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"{leftsidebearing=%d, rightsidebearing=%d, " +
				"charwidth=%d, charascent=%d, chardescent=%d, " +
				"attributes=%x}", this.leftsidebearing,
				this.rightsidebearing, this.charwidth, this.charascent,
				this.chardescent, this.attributes)));
		
		return rv;
	}
	
	/**
	 * Reads a compressed metric from the input.
	 *
	 * @param __dis The stream to read from.
	 * @return The metric.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric readCompressed(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// All are unsigned bytes with implied attributes of zero
		// All of the values are offset signed
		return new PCFMetric(
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			(short)(__dis.readUnsignedByte() - 0x80),
			0);
	}
	
	/**
	 * Reads the metric table.
	 *
	 * @param __dis The stream to read from.
	 * @return The read metrics.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric[] readMetrics(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		PCFMetric[] rv;
		
		// Are these compressed metrics
		if (((Integer.reverseBytes(__dis.readInt())) & PCFMetric._PCF_COMPRESSED_METRICS) != 0)
		{
			// Read length
			int n = __dis.readUnsignedShort();
			rv = new PCFMetric[n];
			
			// Read all metrics			
			for (int i = 0; i < n; i++)
				rv[i] = PCFMetric.readCompressed(__dis);
		}
		
		// They are uncompressed
		else
		{
			// Read length
			int n = __dis.readInt();
			rv = new PCFMetric[n];
			
			// Read all metrics			
			for (int i = 0; i < n; i++)
				rv[i] = PCFMetric.readUncompressed(__dis);
		}
		
		return rv;
	}
	
	/**
	 * Reads an uncompressed metric from the input.
	 *
	 * @param __dis The stream to read from.
	 * @return The metric.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFMetric readUncompressed(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// All are unsigned bytes with implied attributes of zero
		return new PCFMetric(
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readShort(),
			__dis.readUnsignedShort());
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFProperties.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.multiphasicapps.collections.UnmodifiableMap;

/**
 * Properties which describe the PCF. These properties are the font atoms
 * which X11 provides to the user.
 *
 * @since 2018/11/27
 */
public final class PCFProperties
{
	/** The format of the event table. */
	public final int format;
	
	/** Values within the table. */
	public final Map<String, Object> values;
	
	/**
	 * Initializes the properties.
	 *
	 * @param __f The format.
	 * @param __v The values used.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	private PCFProperties(int __f, Map<String, Object> __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		this.format = __f;
		this.values = UnmodifiableMap.<String, Object>of(__v);
	}
	
	/**
	 * Reads from the input stream and loads the properties.
	 *
	 * @param __dis The input stream to read the properties from.
	 * @return The properties which have been read.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	public static final PCFProperties read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Read the format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read the raw properties which can only be parsed when the string
		// table is actually read
		int nprops = __dis.readInt();
		int[] pnameoff = new int[nprops];
		boolean[] pisstr = new boolean[nprops];
		int[] pvalue = new int[nprops];
		for (int i = 0; i < nprops; i++)
		{
			pnameoff[i] = __dis.readInt();
			pisstr[i] = (__dis.readByte() != 0);
			pvalue[i] = __dis.readInt();
		}
		
		// Since the stream knows nothing of the size, it must be determined
		int eopaddr = 8 + (9 * nprops);
		
		// Skip padding bytes, which is a 4 byte boundary
		if ((eopaddr & 3) != 0)
			__dis.skipBytes(4 - (eopaddr & 3));
		
		// Read the raw string table as a bunch of bytes, these are NUL
		// terminated strings
		int ssn = __dis.readInt();
		byte[] sschars = new byte[ssn];
		__dis.readFully(sschars);
		
		// Parse the input strings and such into property values which are
		// either strings or integers
		Map<String, Object> values = new HashMap<>();
		for (int i = 0; i < nprops; i++)
		{
			String key = PCFProperties.__readString(sschars, pnameoff[i]);
			
			// Store a value into map
			values.put(key, (!pisstr[i] ? Integer.valueOf(pvalue[i]) :
				PCFProperties.__readString(sschars, pvalue[i])));
		}
		
		// Debug
		todo.DEBUG.note("format=%d, props=%s", format, values);
		
		// Finish properties
		return new PCFProperties(format, values);
	}
	
	/**
	 * Reads a string from the byte array, since strings are NUL terminated
	 * they are scanned and read as such accordingly.
	 *
	 * @param __ssc Input bytes for string data.
	 * @param __p The pointer to read from.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/27
	 */
	static final String __readString(byte[] __ssc, int __p)
		throws NullPointerException
	{
		if (__ssc == null)
			throw new NullPointerException("NARG");
		
		// Place into string
		StringBuilder sb = new StringBuilder();
		for (int n = __ssc.length; __p < n; __p++)
		{
			// Stop at any NUL
			byte c = __ssc[__p];
			if (c == 0)
				break;
			
			sb.append((char)(c & 0xFF));
		}
		
		return sb.toString();
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFScalableWidths.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
66
67
68
69
70
71
72
73
74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Scalable widths table, these are postscript em-units at 1/1000th of an em.
 *
 * @since 2018/11/28
 */
public final class PCFScalableWidths
{
	/** The format. */
	public final int format;
	
	/** The scalable widths. */
	private final int[] _swidths;
	
	/**
	 * Initializes the scalable widths.
	 *
	 * @param __format The format used.
	 * @param __swidths The widths.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public PCFScalableWidths(int __format, int[] __swidths)
		throws NullPointerException
	{
		if (__swidths == null)
			throw new NullPointerException("NARG");
		
		this.format = __format;
		this._swidths = __swidths.clone();
	}
	
	/**
	 * Reads the scalable widths.
	 *
	 * @param __dis The input stream.
	 * @return The resulting encoding data.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/28
	 */
	public static final PCFScalableWidths read(DataInputStream __dis)
		throws IOException, NullPointerException
	{
		if (__dis == null)
			throw new NullPointerException("NARG");
		
		// Format
		int format = Integer.reverseBytes(__dis.readInt());
		
		// Read in table
		int n = __dis.readInt();
		int[] swidths = new int[n];
		for (int i = 0; i < n; i++)
			swidths[i] = __dis.readInt();
		
		return new PCFScalableWidths(format, swidths);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/PCFTableEntry.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
66
67
68
69
70
71
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.pcftosqf.pcf;

/**
 * This represents a single table within the PCF.
 *
 * @since 2018/11/25
 */
public final class PCFTableEntry
	implements Comparable<PCFTableEntry>
{
	/** The type of table entry this is. */
	public final int type;
	
	/** The format of the entry. */
	public final int format;
	
	/** The size of the entry. */
	public final int size;
	
	/** The offset to the entry. */
	public final int offset;
	
	/**
	 * Initializes the table entry.
	 *
	 * @param __t The type.
	 * @param __f The format.
	 * @param __s The size.
	 * @param __o The offset.
	 * @since 2018/11/25
	 */
	public PCFTableEntry(int __t, int __f, int __s, int __o)
	{
		this.type = __t;
		this.format = __f;
		this.size = __s;
		this.offset = __o;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public int compareTo(PCFTableEntry __o)
	{
		return this.offset - __o.offset;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public String toString()
	{
		return String.format("(type=%d, format=%d, size=%d, offset=%d)",
			this.type, this.format, this.size, this.offset);
	}
}

Added tools/pcf-to-sqf/src/main/java/net/multiphasicapps/pcftosqf/pcf/package-info.java.



















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

/**
 * This package contains the needed classes to parse and decode PCF fonts.
 *
 * @since 2018/11/28
 */

package net.multiphasicapps.pcftosqf.pcf;

Added tools/sqf-to-c/build.gradle.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "Converts a SQF to a C file, so that RatufaCoat " +
	"can use it to draw a basic console screen and such."
mainClassName = "dev.shadowtail.sqftoc.Main"

dependencies
{
	implementation project(":modules:midp-lcdui")
}

Added tools/sqf-to-c/src/main/java/dev/shadowtail/sqftoc/Main.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.sqftoc;

import cc.squirreljme.runtime.lcdui.font.SQFFont;
import java.io.DataInputStream;
import java.io.PrintStream;

/**
 * Converts SQF to C file.
 *
 * @since 2019/06/20
 */
public class Main
{
	/** Column size. */
	public static final int COLUMNS =
		65;
	
	/**
	 * Main entry for the converter.
	 *
	 * @param __args Arguments, the first one is the resource to use.
	 * @throws Throwable On any exception
	 * @since 2019/06/20
	 */
	public static void main(String... __args)
		throws Throwable
	{
		// Which font to convert?
		String rcname = (__args == null || __args.length == 0 ||
			__args[0] == null ? "monospace-12.sqf" : __args[0]);
		
		// The stream to write to
		PrintStream ps = System.out;
		
		// Load the font data
		try (DataInputStream dis = new DataInputStream(
			SQFFont.class.getResourceAsStream(rcname)))
		{
			// Read fields
			byte pixelheight = dis.readByte(),
				ascent = dis.readByte(),
				descent = dis.readByte(),
				bytesperscan = dis.readByte();
			
			// The character widths
			byte[] charwidths = new byte[256];
			dis.readFully(charwidths);
			ps.println("/** SQF Character Widths. */");
			Main.__dumpBytes(ps, "sjme_fontcharwidths", charwidths);
			ps.println();
			
			// Is the character valid?
			byte[] isvalidchar = new byte[256];
			dis.readFully(isvalidchar);
			ps.println("/** SQF Character validity. */");
			Main.__dumpBytes(ps, "sjme_fontisvalidchar", isvalidchar);
			ps.println();
			
			// Character bitmaps
			byte[] charbmp = new byte[256 * bytesperscan * pixelheight];
			dis.readFully(charbmp);
			ps.println("/** SQF Character Bitmaps. */");
			Main.__dumpBytes(ps, "sjme_fontcharbmp", charbmp);
			ps.println();
			
			// Output structure for the font
			ps.println("/** SQF Defined Font. */");
			ps.println("static sjme_sqf sjme_font =");
			ps.println("{");
			
			// All four fields in the header
			ps.printf("\t%d,%n", pixelheight);
			ps.printf("\t%d,%n", ascent);
			ps.printf("\t%d,%n", descent);
			ps.printf("\t%d,%n", bytesperscan);
			ps.println("\tsjme_fontcharwidths,");
			ps.println("\tsjme_fontisvalidchar,");
			ps.println("\tsjme_fontcharbmp");
			
			ps.println("};");
			ps.println();
		}
	}
	
	/**
	 * Dumps the specified byte array.
	 *
	 * @param __ps The stream to write to.
	 * @param __name The name of the field.
	 * @param __b The input bytes.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/20
	 */
	private static final void __dumpBytes(PrintStream __ps, String __name,
		byte[] __b)
		throws NullPointerException
	{
		if (__ps == null || __name == null || __b == null)
			throw new NullPointerException("NARG");
		
		__ps.printf("static sjme_jbyte %s[] =%n", __name);
		__ps.println("{");
		
		// Used to fill up lines at a time
		StringBuilder sb = new StringBuilder();
		
		// Print every character!
		for (int i = 0, n = __b.length; i < n; i++)
		{
			// Append byte
			sb.append(__b[i]);
			
			// Add comma if this is not the last byte
			if (i < n - 1)
				sb.append(", ");
			
			// Dump if column limit was reached
			if (sb.length() >= Main.COLUMNS)
			{
				// If it ends with a space, remove it (is annoying to have)
				if (sb.charAt(sb.length() - 1) == ' ')
					sb.setLength(sb.length() - 1);
				
				// Print out
				__ps.printf("\t%s%n", sb);
				
				// Reset for next run
				sb.setLength(0);
			}
		}
		
		// Print anything left over!
		if (sb.length() > 0)
			__ps.printf("\t%s%n", sb);
		
		__ps.println("};");
	}
}

Added tools/sqf-to-c/src/main/java/dev/shadowtail/sqftoc/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This converts a SQF to a C file for RatufaCoat.
 *
 * @since 2019/06/20
 */

package dev.shadowtail.sqftoc;

Added tools/txt-to-pbm/build.gradle.














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "Text to PBM"
mainClassName = "dev.shadowtail.txttopbm.Main"

dependencies
{
	implementation project(":modules:midp-lcdui")
}

Added tools/txt-to-pbm/src/main/java/dev/shadowtail/txttopbm/Main.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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 dev.shadowtail.txttopbm;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Deque;
import java.util.LinkedList;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This class is used to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Arguments.
	 * @since 2019/06/15
	 */
	public static final void main(String... __args)
		throws Throwable
	{
		// Read in strings, find maximum length
		int maxstrlen = 0,
			numlines = 0;
		Deque<String> lines = new LinkedList<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
			Files.newInputStream(Paths.get(__args[0]),
			StandardOpenOption.READ))))
		{
			for (;;)
			{
				String ln = br.readLine();
				
				if (ln == null)
					break;
				
				// Add line
				lines.add(ln);
				numlines++;
				
				// Maximum line size
				int strlen = ln.length();
				if (strlen > maxstrlen)
					maxstrlen = strlen;
			}
		}
		
		// Write output graphics file, line by line!
		try (PrintStream ps = new PrintStream(System.out))
		{
			// Get a large monospace font which is easy to read hopefully
			Font font = Font.getFont(Font.FACE_MONOSPACE, 0, Font.SIZE_LARGE);
			
			// Get the size properties of the font
			int fw = (font.charWidth('a') + font.charWidth('w')) >> 1,
				fh = font.getHeight();
				
			// Calculate size of image, width is rounded to 8 because of
			// the pixel packing!
			int iw = ((maxstrlen * fw) + 7) & (~7),
				ih = numlines * fh,
				sa = iw * fh,
				ua = sa / 8;
			
			// Write PBM header, use P4 format
			ps.printf("P4\n");
			ps.printf("%d %d\n", iw, ih);
			
			// Create image to contain a buffer for a single line, it is not
			// important to have an entire image because we can just pipe
			// this out!
			Image image = Image.createImage(iw, fh);
			Graphics g = image.getGraphics();
			
			// Use the monospace font!
			g.setFont(font);
			
			// RGB pixel output for lines
			int[] rgb = new int[sa];
			
			// Bulk byte data, for the fastest possible writing
			byte[] bulk = new byte[ua];
			
			// Used to keep track of the current column since PBM cannot exceed
			// 72 characters
			int col = 1;
			
			// Process each line!
			while (!lines.isEmpty())
			{
				// Read in line
				String ln = lines.removeFirst();
				
				// Clear background with white
				g.setColor(0xFFFFFF);
				g.fillRect(0, 0, iw, fh);
				
				// Draw text in black
				g.setColor(0x000000);
				g.drawString(ln, 0, 0, Graphics.TOP | Graphics.LEFT);
				
				// Get RGB pixel data
				image.getRGB(rgb, 0, iw, 0, 0, iw, fh);
				
				// Go through pixels and export to bulk format
				for (int i = 0, o = 0; i < sa; i += 8, o++)
					bulk[o] = (byte)(((rgb[i + 0] & 1) << 7) |
						((rgb[i + 1] & 1) << 6) |
						((rgb[i + 2] & 1) << 5) |
						((rgb[i + 3] & 1) << 4) |
						((rgb[i + 4] & 1) << 3) |
						((rgb[i + 5] & 1) << 2) |
						((rgb[i + 6] & 1) << 1) |
						((rgb[i + 7] & 1)));
				
				// Write all bytes at once
				ps.write(bulk);
			}
		}
	}
}

Added tools/txt-to-pbm/src/main/java/dev/shadowtail/txttopbm/package-info.java.


















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This package contains the utility to convert a text file to a PBM.
 *
 * @since 2019/06/15
 */

package dev.shadowtail.txttopbm;

Added tools/uudecode/build.gradle.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
plugins
{
	id "java"
	id "application"
}

description = "This decodes MIME encoded files (or base64 " +
	"data) and outputs to standard output."
mainClassName = "net.multiphasicapps.uudecode.Main"

dependencies
{
	implementation project(":modules:io")
}

Added tools/uudecode/src/main/java/net/multiphasicapps/uudecode/Main.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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.uudecode;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Deque;
import java.util.LinkedList;
import net.multiphasicapps.io.Base64Alphabet;
import net.multiphasicapps.io.Base64Decoder;
import net.multiphasicapps.io.MIMEFileDecoder;

/**
 * Main entry point class.
 *
 * @since 2018/03/05
 */
public class Main
{
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/03/05
	 */
	public static void main(String... __args)
		throws IOException
	{
		// Roll into queue
		Deque<String> args = new LinkedList<>();
		if (__args != null)
			for (String a : __args)
				if (a != null)
					args.offerLast(a);
		
		// No arguments passed?
		if (args.isEmpty())
		{
			Main.__printHelp();
			System.exit(-1);
		}
		
		// Try to parse command line options
		boolean ignorepadding = false,
			rawdata = false;
__outer:
		for (;;)
		{
			String peek = args.peekFirst();
			switch (peek)
			{
					// Ignore padding
				case "-n":
					ignorepadding = true;
					args.pollFirst();
					break;
					
					// Treat as raw
				case "-r":
					rawdata = true;
					args.pollFirst();
					break;
				
					// Treat rest as files
				case "--":
					args.pollFirst();
					break __outer;
				
					// {@squirreljme.error AZ01 Unknown command line switch.
					// (The switch)}
				default:
					if (peek.startsWith("-"))
						throw new IllegalArgumentException(String.format(
							"AZ01 %s", peek));
					break __outer;
			}
		}
		
		// Go through and handle each file
		OutputStream out = System.out;
		while (!args.isEmpty())
			try (Reader file = new InputStreamReader(Files.newInputStream(
				Paths.get(args.pollFirst()), StandardOpenOption.READ));
				InputStream in = Main.__wrap(file, ignorepadding, rawdata))
			{
				byte[] buf = new byte[512];
				for (;;)
				{
					int rc = in.read(buf);
					
					if (rc < 0)
						break;
					
					out.write(buf, 0, rc);
				}
			}
	}
	
	/**
	 * Prints help.
	 *
	 * @since 2018/03/05
	 */
	private static final void __printHelp()
	{
		PrintStream out = System.err;
		
		out.println("Usage: [-n] [-r] [--] (files...)");
		out.println("  -n: Ignore padding.");
		out.println("  -r: Ignore header, treat as raw base64 MIME data.");
	}
	
	/**
	 * Wraps the input stream.
	 *
	 * @param __in The stream to read from.
	 * @param __ip Ignore padding?
	 * @param __rd Treat as raw base64 data.
	 * @return The wrapped input stream.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	private static final InputStream __wrap(Reader __in, boolean __ip,
		boolean __rd)
		throws IOException, NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Read of raw data?
		if (__rd)
			return new Base64Decoder(__in, Base64Alphabet.BASIC, __ip);
		
		// Read MIME file
		return new MIMEFileDecoder(__in);
	}
}

Deleted usage.mkd.

1
2
3
4
5
6
7
8








-
-
-
-
-
-
-
-
# SquirrelJME Usage

Specific distributions include their usage document, however you may still
access the usage information for each virtual machine.

 * [JavaME (Shaded)](assets/doc/usage-javame.mkd)
 * [JavaSE (Shaded)](assets/doc/usage-javase.mkd)

Deleted utils-dev/GitHubWikiReformat.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
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























































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.regex.*;

/**
 * Reformats a Wiki page for the GitHub Wiki.
 *
 * This is assumed to be running on Linux.
 *
 * @since 2018/09/02
 */
public class GitHubWikiReformat
{
	/**
	 * Main entry point.
	 *
	 * @param __args The first argument is the file being looked at, a relative
	 * path from the root.
	 * @throws Throwable On any exception.
	 * @since 2018/09/02
	 */
	public static void main(String... __args)
		throws Throwable
	{
		if (__args == null || __args.length != 1 || __args[0] == null)
			throw new IllegalArgumentException("Expected path specifying " +
				"the file being modified.");
		
		// Turn it into a path, make root to simplify it
		Path file = Paths.get("/", __args[0]),
			parent = file.getParent();
		System.err.printf("Reformatting %s (in %s)...%n", file, parent);
		
		// Read original file into string
		String original;
		try (Reader r = new InputStreamReader(System.in, "utf-8"))
		{
			StringBuilder sb = new StringBuilder();
			
			for (;;)
			{
				int c = r.read();
				
				if (c < 0)
					break;
				
				sb.append((char)c);
			}
			
			original = sb.toString();
		}
		
		// Pattern used to search for file sequences
		Pattern want = Pattern.compile("\\([^)]*\\.mkd\\)");
		
		// Output result
		StringBuilder out = new StringBuilder();
		
		// Replace patterns
		Matcher match = want.matcher(original);
		for (int lastdx = 0;;)
		{
			// Try to find it
			if (!match.find())
			{
				// Add everything from the last match to the end
				out.append(original.substring(lastdx));
				
				// Stop
				break;
			}
			
			// Starting and end points, used to sub-sequence
			int start = match.start(),
				end = match.end();
			
			// Add everything from the last index to this match
			out.append(original.substring(lastdx, start));
			
			// Set last index to the end of our match, so it is not picked up
			// again
			lastdx = end;
			
			// The opening parenthesis was lost
			out.append('(');
			
			// Some magic needs to be performed on the path, make it a
			// relative path always
			Path origpath = Paths.get(parent + "/" +
				original.substring(start + 1, end - 1));
			
			// Remove the leading slash
			String storepath = origpath.toString().substring(1);
			
			// Convert characters specially
			out.append("@@gh@" +
				storepath.replaceAll(Pattern.quote("/"), "@d@").
				replaceAll(Pattern.quote("-"), "@h@").
				replaceAll(Pattern.quote(".mkd"), ""));
			
			// The ending parenthesis was lost
			out.append(')');
		}
		
		System.out.print(out);
	}
}

Deleted utils-dev/ReorderErrors.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396












































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.Set;
import java.util.TreeSet;

/**
 * This class goes through all projects and reorders the error codes so that
 * they appear in order. This program should really only be ran when error
 * codes are a complete mess after a refactor and they need to cleaned up.
 *
 * @since 2017/10/26
 */
public class ReorderErrors
{
	/** The error specifier. */
	private static final String _ERROR_SPECIFIER =
		"@squirreljme.error";
	
	/** The path to reorder errors for. */
	protected final Path path;
	
	/** The prefix for this project. */
	protected final String projectprefix;
	
	/** The next available error code. */
	private volatile Code _nextcode;
	
	/**
	 * Initializes the error reordering on the given path.
	 *
	 * @param __p The path to reorder.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/10/26
	 */
	public ReorderErrors(Path __p)
		throws IOException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		this.path = __p;
		
		// Read in manifest
		Manifest man;
		try (InputStream in = Files.newInputStream(path.resolve("META-INF").
			resolve("MANIFEST.MF")))
		{
			man = new Manifest(in);
		}
		
		// Get the error prefix
		Attributes attr = man.getMainAttributes();
		String prefix = attr.getValue("X-SquirrelJME-Error");
		if (prefix == null)
			throw new IOException("No error prefix");
		String projectprefix = prefix.trim();
		this.projectprefix = projectprefix;
		
		// The initial code to work with
		this._nextcode = new Code(projectprefix, 1);
	}
	
	/**
	 * Processes everything.
	 *
	 * @throws IOException On read/write errors.
	 * @since 2017/10/26
	 */
	public void run()
		throws IOException
	{
		Path path = this.path;
		
		// Obtain Java source files
		Set<Path> files = new TreeSet<>();
		Files.walk(path).filter((__p) -> !Files.isDirectory(__p)).
			filter((__p) -> __p.toString().endsWith(".java")).
			forEach(files::add);
		
		// Go through all files since they must be parsed to recode versions
		for (Path file : files)
			__process(file);
	}
	
	/**
	 * Processes the given path.
	 *
	 * @param __p The file to process.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/15
	 */
	private void __process(Path __p)
		throws IOException, NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		// Read in all bytes from the file since they will be managed and
		// handled specially depending on which error codes were found
		// Treat as string to extract all the error codes
		String sdata = new String(Files.readAllBytes(__p), "utf-8");
		
		// The first character of the prefix
		String projectprefix = this.projectprefix;
		char firstchar = projectprefix.charAt(0);
		
		// The output string
		StringBuilder out = new StringBuilder(sdata.length());
		
		// Go through all bytes to find sequences for replacing
		boolean replacedsomething = false,
			replacedthiserrorcode = false,
			firstrun = true;
		Code replaceme = new Code(projectprefix, 0),
			withthis = new Code(projectprefix, 0),
			nextcode = this._nextcode;
		char reallylastchar = 0;
		for (int i = 0, n = sdata.length(); i < n; i++)
		{
			char c = sdata.charAt(i),
				lastchar = reallylastchar;
			reallylastchar = c;
			
			// Potentially a code to be replaced
			if (i + 4 < n && c == firstchar &&
				!Character.isAlphabetic(lastchar) &&
				!Character.isDigit(lastchar) && lastchar != '_')
			{
				// Replacing code
				if (sdata.substring(i, i + 4).
					equalsIgnoreCase(replaceme.toString()))
				{
					replacedsomething = true;
					out.append(withthis.toString());
					i += 3;
					
					// Mark for debugging
					replacedthiserrorcode = true;
				}
				
				// Copy as is
				else
					out.append(c);
			}
			
			// Declaration of a new prefix to replace
			else if (c == '@')
			{
				// This is an error declaration
				if (sdata.substring(i).startsWith(_ERROR_SPECIFIER))
				{
					// Ignore whitespace until the code
					int codepos = -1;
					for (int j = i + _ERROR_SPECIFIER.length(); j < n; j++)
					{
						// Ignore whitespace
						char d = sdata.charAt(j);
						if (Character.isWhitespace(d))
							continue;
						
						codepos = j;
						break;
					}
					
					// Is a valid code position
					if (codepos >= 0)
					{
						// Used to detect potentially misused codes
						if (!firstrun && !replacedthiserrorcode)
							System.err.printf("!!!!! NEVER USED %s in %s?%n",
								replaceme, __p);
						replacedthiserrorcode = false;
						firstrun = false;
						
						replaceme = new Code(
							sdata.substring(codepos, codepos + 4));
						withthis = nextcode;
						nextcode = nextcode.next();
					}
					
					// Always copy the character
					out.append(c);
				}
				
				// Not an error sequence
				else
					out.append(c);
			}
			
			// Unknown, just pass it through
			else
				out.append(c);
		}
		
		if (replacedsomething && !replacedthiserrorcode)
			System.err.printf("!!!!! NEVER USED %s in %s?%n", replaceme, __p);
		
		// Store next code for later
		this._nextcode = nextcode;
		
		// Rewrite to file
		if (replacedsomething)
		{
			if (false)
			{
				System.out.println("----------------------------------");
				System.out.printf("FILE: %s%n", __p);
				System.out.println(out);
			}
			else
				Files.write(__p, out.toString().getBytes("utf-8"),
					StandardOpenOption.WRITE,
					StandardOpenOption.TRUNCATE_EXISTING);
		}
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2017/10/26
	 */
	public static void main(String... __args)
	{
		if (__args == null)
			__args = new String[0];
		
		for (String a : __args)
			try
			{
				new ReorderErrors(Paths.get(a)).run();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
	}
	
	/**
	 * This represents a prefix and an error code.
	 *
	 * @since 2017/10/27
	 */
	public static final class Code
	{
		/** The prefix code. */
		protected final String prefix;
		
		/** The error code number. */
		protected final int number;
		
		/**
		 * Initializes the code.
		 *
		 * @param __full The full code.
		 * @throws IllegalArgumentException If the prefix or number are not
		 * valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2017/10/27
		 */
		public Code(String __full)
			throws IllegalArgumentException, NullPointerException
		{
			this(__full.substring(0, 2), __full.substring(2, 4));
		}
		
		/**
		 * Initializes the code.
		 *
		 * @param __pre The prefix code.
		 * @param __num The error code number.
		 * @throws IllegalArgumentException If the prefix or number are not
		 * valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2017/10/27
		 */
		public Code(String __pre, String __num)
			throws IllegalArgumentException, NullPointerException
		{
			this(__pre, Integer.parseInt(
				Objects.<String>requireNonNull(__num), 36));
		}
		
		/**
		 * Initializes the code.
		 *
		 * @param __pre The prefix code.
		 * @param __num The error code number.
		 * @throws IllegalArgumentException If the prefix is not valid.
		 * @throws NullPointerException On null arguments.
		 * @since 2017/10/27
		 */
		public Code(String __pre, int __num)
			throws IllegalArgumentException, NullPointerException
		{
			if (__pre == null)
				throw new NullPointerException("NARG");
			
			if (__pre.length() != 2)
				throw new IllegalArgumentException(
					"Prefix must have length of two.");
			
			// The high number comes from base 36 encoding
			if (__num < 0 || __num > 1295)
				throw new IllegalArgumentException(String.format(
					"Error code number ouf of range: %d.", __num));
			
			this.prefix = __pre.toUpperCase();
			this.number = __num;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/10/27
		 */
		@Override
		public boolean equals(Object __o)
		{
			if (!(__o instanceof Code))
				return false;
			
			Code o = (Code)__o;
			return this.prefix.equals(o.prefix) &&
				this.number == o.number;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/10/27
		 */
		@Override
		public int hashCode()
		{
			return this.prefix.hashCode() + this.number;
		}
		
		/**
		 * Returns the next index.
		 *
		 * @return The next index.
		 * @since 2018/01/15
		 */
		public Code next()
		{
			return new Code(this.prefix, this.number + 1);
		}
		
		/**
		 * Returns the number as a string.
		 *
		 * @return The numnber as a string.
		 * @since 2017/10/27
		 */
		public String numberAsString()
		{
			String base = Integer.toString(number, 36).toLowerCase();
			if (base.length() == 1)
				return "0" + base;
			return base;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2017/10/27
		 */
		@Override
		public String toString()
		{
			return this.prefix + numberAsString();
		}
	}
}

Deleted utils-dev/SortImports.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
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



























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * This class will read in imports from a file and then sort them so that they
 * are in alphabetical order.
 *
 * @since 2018/01/14
 */
public class SortImports
{
	public static final Comparator<String> INSENSITIVE_COMPARATOR =
		new Comparator<String>()
		{
			/**
			 * {@inheritDoc}
			 * @since 2018/01/04
			 */
			@Override
			public int compare(String __a, String __b)
			{
				// Use case insensitive comparison first
				int rv = __a.compareToIgnoreCase(__b);
				if (rv != 0)
					return rv;
				
				// If two strings are the same case, wise, sort it again
				// using case sensitive, so that two similar strings with
				// the same case still sort accordingly as if there were no
				// case, but capital letters are first.
				return __a.compareTo(__b);
			}
		};
	
	/** The file to sort. */
	protected final Path path;
	
	/**
	 * Initializes the sorter.
	 *
	 * @param __p The path to sort.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/01/14
	 */
	public SortImports(Path __p)
		throws NullPointerException
	{
		if (__p == null)
			throw new NullPointerException("NARG");
		
		this.path = __p;
	}
	
	/**
	 * Runs the sorting script.
	 *
	 * @throws IOException On read/write errors.
	 * @since 2018/01/14
	 */
	public void run()
		throws IOException
	{
		// Read all lines in file, it is unspecified if the list is modifiable
		// so make sure it is
		Path path = this.path;
		List<String> inlines = new ArrayList<>(Files.readAllLines(path,
			Charset.forName("utf-8")));
		
		// Find the lines which are import statements
		int n = inlines.size(),
			start = -1,
			end = -1;
		boolean wasimport = false;
		for (int i = 0; i < n; i++)
		{
			boolean isimport = inlines.get(i).startsWith("import");
			
			// Now is an import
			if (isimport)
			{
				// Ignore
				if (wasimport)
					continue;
				
				// Mark start
				else
				{
					start = i;
					wasimport = true;
				}
			}
			
			// Not an import
			else
			{
				// Was an import? Mark end
				if (wasimport)
				{
					end = i;
					break;
				}
				
				// Otherwise find other lines
				else
					continue;
			}
		}
		
		// No import statements?
		if (start < 0 || end < 0)
			return;
		
		// Get sub-list to sort
		List<String> sub = inlines.subList(start, end);
		
		// Sort that
		Collections.sort(sub, INSENSITIVE_COMPARATOR);
		
		// Write out entire file again
		Files.write(path, inlines, Charset.forName("utf-8"),
			StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Program arguments.
	 * @since 2018/10/14
	 */
	public static void main(String... __args)
		throws IOException
	{
		for (String s : __args)
			new SortImports(Paths.get(s)).run();
	}
}

Deleted utils-dev/TodoProgression.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251



























































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import java.util.Arrays;
import java.util.UUID;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * This program reads standard input and builds a CSV for TODO progression.
 *
 * @since 2018/03/29
 */
public class TodoProgression
{
	/** Project detail. */
	protected final Map<UUID, Project> projects =
		new TreeMap<>();
	
	/** Tags which exist. */
	protected final Set<String> tags =
		new TreeSet<>();
	
	/** The last read tag. */
	protected String lasttag;
	
	/**
	 * Registers data.
	 *
	 * @param __tag The tag the checkout is called.
	 * @param __name The name of the project.
	 * @param __uuid The project UUID.
	 * @param __n The number of TODOs in the project.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/29
	 */
	public void register(String __tag, String __name, UUID __uuid, int __n)
		throws NullPointerException
	{
		if (__tag == null || __name == null || __uuid == null)
			throw new NullPointerException("NARG");
		
		this.lasttag = __tag;
		
		Map<UUID, Project> projects = this.projects;
		Project p = projects.get(__uuid);
		if (p == null)
			projects.put(__uuid, (p = new Project(__uuid)));
		
		// Count for project
		p.count(__tag, __name, __n);
	}
	
	/**
	 * Writes the results to the output stream.
	 *
	 * @param __ps The output stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/29
	 */
	public void write(PrintStream __ps)
		throws NullPointerException
	{
		if (__ps == null)
			throw new NullPointerException("NARG");
		
		Set<String> tags = this.tags;
		
		// Build row one for column headers
		__ps.print("name");
		for (String t : tags)
		{
			__ps.print(',');
			__ps.print(t);
		}
		
		// End with line
		__ps.println();
		
		// Sort projects by their name then UUID so they appear consistent
		// and alphabetically sorted
		Set<Project> sorted = new TreeSet<>(projects.values());
		
		// Go through all projects and dump their data, ignore the UUID and
		// only use the latest name
		for (Project p : sorted)
		{
			// Print name
			__ps.print(p.lastname);
			
			// Print all counts
			Map<String, Integer> counts = p.counts;
			for (String t : tags)
			{
				// Comma before
				__ps.print(',');
				
				// Only print value if it is not null
				Integer i = counts.get(t);
				if (i != null)
					__ps.print(i);
			}
			
			// End line for the column
			__ps.println();
		}
	}
	
	/**
	 * Main entry point.
	 *
	 * @param __args Not used.
	 * @since 2018/03/29
	 */
	public static void main(String... __args)
		throws IOException
	{
		TodoProgression tp = new TodoProgression();
		
		// Read in inputs
		try (BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in)))
		{
			String ln;
			while (null != (ln = br.readLine()))
			{
				// Split forms
				String[] fields = ln.split("[ \t]");
				
				// Extract project name
				String name = fields[1];
				int ls = name.lastIndexOf('/');
				if (ls >= 0)
					name = name.substring(ls + 1);
				
				// Register data
				tp.register(fields[0], name, UUID.fromString(fields[2]),
					Integer.parseInt(fields[3]));
			}
		}
		
		// Write output
		tp.write(System.out);
	}
	
	/**
	 * Generates a hashcode from the UUID.
	 *
	 * @param __uuid The input UUID to hash.
	 * @return The hashcode for the UUID.
	 * @since 2018/03/29
	 */
	static final int __hashUUID(UUID __uuid)
	{
		return Long.hashCode(__uuid.getLeastSignificantBits()) ^
			~Long.hashCode(__uuid.getMostSignificantBits());
	}
	
	/**
	 * Used to keep track of projects.
	 *
	 * @since 2018/03/29
	 */
	public class Project
		implements Comparable<Project>
	{
		/** The project UUID. */
		protected final UUID uuid;
		
		/** Todo counts. */
		protected final Map<String, Integer> counts =
			new TreeMap<>();
		
		/** The last name used. */
		protected volatile String lastname;
		
		/**
		 * Initializes the project information.
		 *
		 * @param __uuid The project UUID.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/03/29
		 */
		public Project(UUID __uuid)
			throws NullPointerException
		{
			if (__uuid == null)
				throw new NullPointerException("NARG");
			
			this.uuid = __uuid;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/03/29
		 */
		@Override
		public int compareTo(Project __p)
		{
			if (this == __p)
				return 0;
			
			// Make it so projects which are alive still appear first
			String lasttag = TodoProgression.this.lasttag;
			int rv = Boolean.compare(this.counts.get(lasttag) == null,
				__p.counts.get(lasttag) == null);
			if (rv != 0)
				return rv;
			
			// Make it so names appear first
			rv = this.lastname.compareTo(__p.lastname);
			if (rv != 0)
				return rv;
			return this.uuid.compareTo(__p.uuid);
		}
		
		/**
		 * Counts TODO for the project at a given state.
		 *
		 * @param __tag The tag of the date.
		 * @param __name The name of the project.
		 * @param __n The number of TODOs.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/03/29
		 */
		public void count(String __tag, String __name, int __n)
			throws NullPointerException
		{
			this.lastname = __name + "@" +
				String.format("%08x", __hashUUID(this.uuid));
			this.counts.put(__tag, __n);
			
			TodoProgression.this.tags.add(__tag);
		}
	}
}

Deleted utils-dev/__reorderallerrors.sh.

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

























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This goes through all projects and reorders all of their errors

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Go through every single project
"$__exedir/lsprojects.sh" | while read __project
do
	echo ">> $__project"
	"$__exedir/reordererrors.sh" "$__exedir/../$__project"
	fossil commit -m "Reorder errors in $__project"
done

Deleted utils-dev/__sortimports.sh.

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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Describe this.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Compile sorting script
if ! javac -d . "$__exedir/SortImports.java"
then
	echo "Failed to compile sorting program!" 1>&2
	exit 1
fi

# Go through all projects
"$__exedir/lsprojects.sh" | while read __project
do
	# Get project base path
	__path="$__exedir/../$__project"
	
	# Go through all Java files to sort imports
	find "$__path" -type f | grep '\.java$' | while read __file
	do
		java SortImports "$__file"
	done
	
	# Commit these changes
	fossil commit -m "Sort imports for $__project."
done

Changes to utils-dev/autobuild.sh.

13
14
15
16
17
18
19



20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+








# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"
__realexedir="$("$__exedir/absolute.sh" "$__exedir")"

echo "This script is deprecated!"
exit 1

# Current build date, for record keeping
__date="$(date --utc +%s) $(date --utc)"

# Directory to place final things instead of in fossil?
__indir=""
if [ ! -z "$1" ]

Deleted utils-dev/binscp.sh.

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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Writes the bins classpath

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Look in the local bins directory
__peg="0"
for __jar in bins/*.jar
do
	if [ "$__peg" -eq "0" ]
	then
		__peg="1"
	else
		printf '%s' ":"
	fi
	printf '%s' "$__jar"
done

# New line
echo ""

Deleted utils-dev/boot/BootstrapCompiler.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565





















































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.List;
import java.util.regex.Pattern;

/**
 * This class contains the ability to call a compiler from the bootstrap.
 *
 * For modern Java systems with a capable class library it will use the
 * internal class libraries.
 *
 * If one is not detected then it will call the host compiler by creating
 * processes as needed to perform the compilation.
 *
 * @since 2019/09/28
 */
public abstract class BootstrapCompiler
{
	/** Pre-cached compiler instance. */
	private static BootstrapCompiler _COMPILER;
	
	/**
	 * Performs the actual compilation step.
	 *
	 * @return {@code true} if compilation is a success.
	 * @since 2019/09/29
	 */
	public abstract boolean compile(Path __srcpath, Path __outpath,
		Iterable<Path> __classpath, Iterable<Path> __sources,
		Iterable<String> __args);
	
	/**
	 * Returns an instance of the compiler needed to build the basic
	 * SquirrelJME system.
	 *
	 * @throws UnsupportedOperationException If no compiler is supported.
	 * @since 2019/09/28
	 */
	public static final BootstrapCompiler getCompiler()
		throws UnsupportedOperationException
	{
		// Use pre-cached compiler
		BootstrapCompiler rv = BootstrapCompiler._COMPILER;
		if (rv != null)
			return rv;
		
		// Try using the standard tool compiler
		try
		{
			rv = StandardToolCompiler.getInstance();
		}
		
		// Is not supported, so try getting the one from the command line
		catch (UnsupportedOperationException e)
		{
			// Print the possible reason the built-in compiler is not
			// available
			e.printStackTrace();
			
			// Try getting command line compiler instead
			rv = CommandLineCompiler.getInstance();
		}
		
		// Cache and return
		BootstrapCompiler._COMPILER = rv;
		return rv;
	}
	
	/**
	 * This is a Java compiler which exists on the command line.
	 *
	 * @since 2019/09/28
	 */
	public static final class CommandLineCompiler
		extends BootstrapCompiler
	{
		/** The executable where the Java compiler lives. */
		protected final Path javac;
		
		/**
		 * Initializes the command line compiler.
		 *
		 * @param __exec The executable location.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/29
		 */
		public CommandLineCompiler(Path __exec)
			throws NullPointerException
		{
			if (__exec == null)
				throw new NullPointerException("NARG");
			
			this.javac = __exec;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/09/29
		 */
		@Override
		public boolean compile(Path __srcpath, Path __outpath,
			Iterable<Path> __classpath, Iterable<Path> __sources,
			Iterable<String> __args)
		{
			// Build commands for the process
			List<String> args = new ArrayList<>();
			
			// The Java executable
			args.add(this.javac.toString());
			
			// Arguments to pass as extra
			if (__args != null)
				for (String arg : __args)
					args.add(arg);
			
			// Add source path
			if (__srcpath != null)
			{
				args.add("-sourcepath");
				args.add(__srcpath.toString());
			}
			
			// Output path
			if (__outpath != null)
			{
				args.add("-d");
				args.add(__outpath.toString());
			}
			
			// Add the class path
			if (__classpath != null)
			{
				StringBuilder cpsb = new StringBuilder();
				
				// Go through the path
				for (Path p : __classpath)
				{
					// Prefix with separator?
					if (cpsb.length() > 0)
						cpsb.append(File.pathSeparator);
					
					// Add otherwise
					cpsb.append(p.toString());
				}
				
				// Set it
				args.add("-classpath");
				args.add(cpsb.toString());
			}
			
			// Add all sources
			if (__sources != null)
				for (Path src : __sources)
					args.add(src.toString());
			
			// Start and wait for the compilation to run
			try
			{
				Process fork = new ProcessBuilder(args).start();
				
				for (;;)
					try
					{
						return fork.waitFor() == 0;
					}
					catch (InterruptedException e)
					{
						// Ignore
					}
			}
			catch (IOException e)
			{
				// {@squirreljme.error NB27 Failed to invoke the compiler.
				// (The compiler arguments)}
				throw new RuntimeException("NB27 " + args, e);
			}
		}
		
		/**
		 * Returns an instance of the compiler.
		 *
		 * @return The compiler instance.
		 * @throws UnsupportedOperationException If it is not a valid compiler.
		 * @since 2019/09/28
		 */
		public static final CommandLineCompiler getInstance()
			throws UnsupportedOperationException
		{
			// The Java compiler executable
			Path javac = null;
			
			// Check environment for the compiler
			String env = System.getenv("JAVAC");
			if (env != null)
				javac = CommandLineCompiler.findInPath(Paths.get(env));
			
			// Standard Java compiler
			if (javac == null)
				javac = CommandLineCompiler.findInPath(Paths.get("javac"));
			
			// Eclipse Java compiler
			if (javac == null)
				javac = CommandLineCompiler.findInPath(Paths.get("ecj"));
			
			// {@squirreljme.error NB26 No Java compiler found.}
			if (javac == null)
				throw new UnsupportedOperationException("NB26");
			
			// Use this
			return new CommandLineCompiler(javac);
		}
		
		/**
		 * Locates the given executable in the PATH variable.
		 *
		 * @param __v The executable to find.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/29
		 */
		public static final Path findInPath(Path __v)
			throws NullPointerException
		{
			if (__v == null)
				throw new NullPointerException("NARG");
			
			// Check path variable
			String pathvar = System.getenv("PATH");
			if (pathvar != null)
				for (String pathseg : pathvar.split(
					Pattern.quote(File.pathSeparator)))
				{
					Path p = Paths.get(pathseg).resolve(__v);
					if (Files.isExecutable(p))
						return p;
				}
			
			// Check if current path is executable
			if (Files.isExecutable(__v))
				return __v;
			
			// Otherwise nothing works
			return null;
		}
	}
	
	/**
	 * This is a Java compiler which uses the standard tool system.
	 *
	 * This uses the following classes:
	 *  - {@code javax.tools.JavaCompiler}.
	 *  - {@code javax.tools.JavaFileManager}.
	 *  - {@code javax.tools.StandardJavaFileManager}.
	 *  - {@code javax.tools.StandardLocation}.
	 *  - {@code javax.tools.ToolProvider}.
	 *
	 * To make this work on systems which do not provide standard tool
	 * interfaces in the compiler this will only access them using
	 * reflection and such.
	 *
	 * @since 2019/09/28
	 */
	public static final class StandardToolCompiler
		extends BootstrapCompiler
	{
		/** The Java compiler instance. */
		protected final Object javac;
		
		/**
		 * Initializes the standard compiler.
		 *
		 * @param __javac The standard Java compiler instance.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/29
		 */
		public StandardToolCompiler(Object __javac)
			throws NullPointerException
		{
			if (__javac == null)
				throw new NullPointerException("NARG");
			
			this.javac = __javac;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/09/29
		 */
		@Override
		public boolean compile(Path __srcpath, Path __outpath,
			Iterable<Path> __classpath, Iterable<Path> __sources,
			Iterable<String> __args)
		{
			// Java compiler instance
			Object javac = this.javac;
			
			// Get stnadard file manager
			Object jfm = __Tool__.JAVA_COMPILER.invoke(
				"getStandardFileManager", javac, null, null, null);
			
			// Set source location
			__Tool__.STANDARD_JAVA_FILE_MANAGER.invoke(
				"setLocation", jfm, 
				__Tool__.STANDARD_LOCATION.enumConstant("SOURCE_PATH"),
				Arrays.<File>asList(__srcpath.toFile()));
			
			// Output to given directory
			__Tool__.STANDARD_JAVA_FILE_MANAGER.invoke(
				"setLocation", jfm,
				__Tool__.STANDARD_LOCATION.enumConstant("CLASS_OUTPUT"),
				Arrays.<File>asList(__outpath.toFile()));
			
			// Translate and set the class path
			List<File> classpath = new ArrayList<>();
			for (Path entry : __classpath)
				classpath.add(entry.toFile());
			__Tool__.STANDARD_JAVA_FILE_MANAGER.invoke(
				"setLocation", jfm,
				__Tool__.STANDARD_LOCATION.enumConstant("CLASS_PATH"),
				classpath);
			
			// Translate source paths to file
			List<File> sources = new ArrayList<>();
			for (Path entry : __sources)
				sources.add(entry.toFile());
			
			// Create compilation task
			Callable task = __Tool__.JAVA_COMPILER.<Callable>invoke(
				Callable.class, "getTask", javac,
				null, jfm, null, __args, null,
				__Tool__.STANDARD_JAVA_FILE_MANAGER.invoke(
					"getJavaFileObjectsFromFiles", jfm, sources));
			
			// Execute the task
			try
			{
				return ((Boolean)task.call()).booleanValue();
			}
			catch (Exception e)
			{
				// {@squirreljme.error NB25 Compiler invocation failed.}
				throw new RuntimeException("NB25", e);
			}
		}
		
		/**
		 * Returns an instance of the compiler.
		 *
		 * @return The compiler instance.
		 * @throws UnsupportedOperationException If it is not a valid compiler.
		 * @since 2019/09/28
		 */
		public static final StandardToolCompiler getInstance()
			throws UnsupportedOperationException
		{
			// {@squirreljme.error NB23 No standard Java compiler exists.}
			Object javac = __Tool__.TOOL_PROVIDER.invoke(
				"getSystemJavaCompiler", null);
			if (javac == null)
				throw new UnsupportedOperationException("NB23");
			
			// Make compiler with this instance
			return new StandardToolCompiler(javac);
		}
	}
	
	/**
	 * Enumeration to represent the standard tool classes.
	 *
	 * @since 2019/09/28
	 */
	static enum __Tool__
	{
		/** Java compiler. */
		JAVA_COMPILER("javax.tools.JavaCompiler"),
		
		/** Java file manager. */
		JAVA_FILE_MANAGER("javax.tools.JavaFileManager"),
		
		/** Standard Java File Manager. */
		STANDARD_JAVA_FILE_MANAGER("javax.tools.StandardJavaFileManager"),
		
		/** Standard location. */
		STANDARD_LOCATION("javax.tools.StandardLocation"),
		
		/** Tool provider. */
		TOOL_PROVIDER("javax.tools.ToolProvider");
		
		/** End. */
		;
		
		/** The class to access. */
		protected final String desireclass;
		
		/** Cached class. */
		private Class<?> _cacheclass;
		
		/**
		 * Initializes the entry.
		 *
		 * @param __dc The desired class.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/28
		 */
		private __Tool__(String __dc)
			throws NullPointerException
		{
			if (__dc == null)
				throw new NullPointerException("NARG");
			
			this.desireclass = __dc;
		}
		
		/**
		 * Returns the enum constant of the given name.
		 *
		 * @param __name The name of the enum constant.
		 * @return The resulting constant.
		 * @throws NullPointerException On null arguments.
		 * @throws UnsupportedOperationException If the constant is not valid.
		 * @since 2019/09/29
		 */
		public final Enum<?> enumConstant(String __name)
			throws NullPointerException, UnsupportedOperationException
		{
			if (__name == null)
				throw new NullPointerException("NARG");
			
			// Working with this class
			Class<?> cl = this.lookupClass();
			
			// If there are no values, then this is likely not an enumeration
			Object[] values = cl.getEnumConstants();
			if (values != null)
			{
				// Find it
				for (Object value : values)
					if (__name.equals(((Enum)value).name()))
						return Enum.class.cast(value);
			}
			
			// {@squirreljme.error NB24 Enumeration constant not found.
			// (The class name; The constant name)}
			throw new UnsupportedOperationException(
				String.format("NB24 %s %s", cl.getName(), __name));
		}
		
		/**
		 * Looks up the specified class.
		 *
		 * @return The resulting class.
		 * @throws UnsupportedOperationException If it does not exist.
		 * @since 2019/09/28
		 */
		public final Class<?> lookupClass()
			throws UnsupportedOperationException
		{
			// Already cached?
			Class<?> rv = this._cacheclass;
			if (rv != null)
				return rv;
			
			// Lookup otherwise
			try
			{
				this._cacheclass = (rv = Class.forName(this.desireclass));
			}
			
			// {@squirreljme.error NB20 Could not lookup compiler class.}
			catch (ClassNotFoundException e)
			{
				throw new UnsupportedOperationException("NB20", e);
			}
			
			// Return it
			return rv;
		}
		
		/**
		 * Invokes the given method and returns the given class type.
		 *
		 * @param <T> The type to return.
		 * @param __t The type to return.
		 * @param __name The name of the method.
		 * @param __v The value to invoke on.
		 * @param __args Arguments to the method.
		 * @return The return value of the method.
		 * @throws ClassCastException If the type is not correct.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/29
		 */
		public final <T> T invoke(Class<T> __t, String __name, Object __v,
			Object... __args)
			throws ClassCastException, NullPointerException
		{
			if (__t == null)
				throw new NullPointerException("NARG");
			
			return __t.cast(this.invoke(__name, __v, __args));
		}
		
		/**
		 * Invokes the given method.
		 *
		 * @param __name The name of the method.
		 * @param __v The value to invoke on.
		 * @param __args Arguments to the method.
		 * @return The return value of the method.
		 * @throws NullPointerException On null arguments.
		 * @since 2019/09/29
		 */
		public final Object invoke(String __name, Object __v, Object... __args)
			throws NullPointerException
		{
			if (__name == null)
				throw new NullPointerException("NARG");
			
			// Lookup our class
			Class<?> cl = this.lookupClass();
			
			// Number of arguments to match against
			int numargs = (__args == null ? 0 : __args.length);
			
			// Find matching according to name and argument count
			for (Method m : cl.getMethods())
				if (__name.equals(m.getName()) &&
					numargs == m.getParameterCount())
				try
				{
					return m.invoke(__v,
						(__args == null ? new Object[0] : __args));
				}
				catch (IllegalAccessException|InvocationTargetException e)
				{
					// {@squirreljme.error NB22 Could not invoke the given
					// method. (The class name; The method name)}
					throw new RuntimeException(String.format("NB22 %s %s",
						cl.getName(), __name), e);
				}
			
			// {@squirreljme.error NB21 Could not find the method with the
			// given name in the given class. (The class name; The method)}
			throw new UnsupportedOperationException(
				String.format("NB21 %s %s", cl.getName(), __name));
		}
	}
}

Deleted utils-dev/boot/BuildProject.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523











































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
 * This represents a single project which may be built.
 *
 * @since 2016/10/27
 */
public class BuildProject
{
	/** The project base path. */
	protected final Path basepath;
	
	/** The project name. */
	protected final String name;
	
	/** The output path for this JAR. */
	protected final Path jarout;
	
	/** Dependencies of this build project. */
	protected final Set<String> depends;
	
	/** Projects that are available. */
	private final Map<String, BuildProject> _projects;
	
	/** In compilation? */
	private volatile boolean _incompile;
	
	/** Was the source date calculated? */
	private volatile long _sourcedate =
		Long.MIN_VALUE;
	
	/**
	 * Initializes the build project.
	 *
	 * @param __b The project base path.
	 * @param __mp The manifest path.
	 * @param __bjo Build JAR output.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/27
	 */
	BuildProject(Path __b, Path __mp, Path __bjo,
		Map<String, BuildProject> __projs)
		throws IOException, NullPointerException
	{
		// Check
		if (__b == null || __mp == null || __bjo == null || __projs == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.basepath = __b;
		this._projects = __projs;
		
		// Load the manifest
		Manifest man;
		try (InputStream in = Files.newInputStream(
			__mp, StandardOpenOption.READ))
		{
			man = new Manifest(in);
		}
		
		// Handle main attributes
		Attributes attr = man.getMainAttributes();
		
		// The project name depends on the uppermost name of the directory
		String name;
		this.name = (name = __correctProjectName(
			__b.getFileName().toString()));
		
		// Where is this output?
		this.jarout = __bjo.resolve(name + ".jar");
		
		// Determine dependencies
		Set<String> depends = new LinkedHashSet<>();
		String rd = attr.getValue("X-SquirrelJME-Depends");
		if (rd != null)
			for (String s : rd.split("[ \t]"))
				depends.add(__correctProjectName(s.trim()));
		
		// Force a dependency on the CLDC Compact library
		if (!name.equals("cldc-compact"))
			depends.add(__correctProjectName("cldc-compact"));
		
		// Set
		this.depends = depends;
	}
	
	/**
	 * Returns the date of the binary.
	 *
	 * The value here is not cached.
	 *
	 * @return The date of the binary.
	 * @since 2016/10/27
	 */
	public long binaryDate()
	{
		// If it does not exist, the date is not valid
		Path jarout = this.jarout;
		if (!Files.exists(jarout))
			return Long.MIN_VALUE;
		
		// Calculate
		try
		{
			Long[] out = new Long[1];
			out[0] = Long.MIN_VALUE;
			NewBootstrap.<Long[]>__walk(jarout, out, NewBootstrap.DATE);
			return out[0];
		}
		
		// Ignore
		catch (IOException e)
		{
			return Long.MIN_VALUE;
		}
	}
	
	/**
	 * Compiles this project and any dependencies it may have.
	 *
	 * @return The set of projects which were compiled.
	 * @throws IOException On read/write errors.
	 * @since 2016/10/27
	 */
	public Set<BuildProject> compile()
		throws IOException
	{
		Set<BuildProject> rv = new LinkedHashSet<>();
		
		// Build loop
		try
		{
			// {@squirreljme.error NB02 The specified project eventually
			// depends on itself. (The project name)}
			if (this._incompile)
				throw new IllegalStateException(String.format(
					"NB02 %s", this.name));
			
			// Currently compiling
			this._incompile = true;
			
			// Compile dependencies first
			Map<String, BuildProject> projects = this._projects;
			for (String dep : this.depends)
			{
				// {@squirreljme.error NB06 The dependency of a given
				// project does not exist. (This project; The project it
				// depends on)}
				BuildProject dp = projects.get(dep);
				if (dp == null)
					throw new IllegalStateException(String.format(
						"NB06 %s %s", this.name, dep));
				
				// Compile the dependency and add it to the merge group
				for (BuildProject bp : dp.compile())
					rv.add(bp);
			}
			
			// Other complation state
			__compileStep(rv);
		}
		
		// Clear compile state
		finally
		{
			this._incompile = false;
		}
		
		// Add self to dependency chain
		rv.add(this);
		
		// Return it
		return rv;
	}
	
	/**
	 * Returns the name of this project.
	 *
	 * @return The project name.
	 * @since 2016/10/27
	 */
	public String projectName()
	{
		return this.name;
	}
	
	/**
	 * Returns the date when the project sources were last touched.
	 *
	 * @return The project sources date.
	 * @since 2016/10/27
	 */
	public long sourcesDate()
	{
		// Use cached value
		long rv = this._sourcedate;
		if (rv != Long.MIN_VALUE)
			return rv;
		
		// Calculate otherwise
		try
		{
			Long[] out = new Long[1];
			out[0] = Long.MIN_VALUE;
			NewBootstrap.<Long[]>__walk(this.basepath, out, NewBootstrap.DATE);
			this._sourcedate = (rv = out[0]);
		}
		
		// Ignore
		catch (IOException e)
		{
		}
		
		// Return it
		return rv;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2017/02/25
	 */
	@Override
	public String toString()
	{
		return this.name;
	}
	
	/**
	 * Secondary compilation step.
	 *
	 * @param __deps Dependencies used.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/27
	 */
	private void __compileStep(Set<BuildProject> __deps)
		throws IOException, NullPointerException
	{
		// Check
		if (__deps == null)
			throw new NullPointerException("NARG");
		
		// Best dependency date
		long depdate = Long.MIN_VALUE;
		for (BuildProject bp : __deps)
			depdate = Math.max(depdate, bp.binaryDate());
		
		// Do not recompile if it is up to date
		long srcdate = sourcesDate(),
			bindate =  binaryDate();
		Path jarout = this.jarout;
		if (Files.exists(jarout) && srcdate <= bindate &&
			bindate > depdate)
			return;
		
		// {@squirreljme.error NB09 Now compiling the specified project.
		// (The name of the project being compiled)}
		String name = this.name;
		System.err.printf("NB09 %s%n", name);
		
		// Try finding the compiler
		BootstrapCompiler javac = BootstrapCompiler.getCompiler();
		
		// Need to clear files
		Path tempdir = null;
		try
		{
			// Create temporary directory
			tempdir = Files.createTempDirectory(
				"squirreljme-build-" + name);
			
			// Source code is just this project
			final Path basepath = this.basepath;
			
			// Get all source code to be compiled
			final Set<Path> fsources = new LinkedHashSet<>();
			NewBootstrap.<Object>__walk(basepath, null,
				new Consumer<Path, Object, IOException>()
				{
					/**
					 * {@inheritDoc}
					 * @since 2016/10/27
					 */
					@Override
					public void accept(Path __p, Object __s)
						throws IOException
					{
						// Ignore directories
						if (Files.isDirectory(__p))
							return;
						
						// Add to sources if it is a source file
						if (__p.getFileName().toString().endsWith(".java"))
							fsources.add(__p);
					}
				});
			
			// If there are no sources to compile, do not bother
			if (!fsources.isEmpty())
			{
				// The class path is just the dependencies
				Set<Path> fdeps = new LinkedHashSet<>();
				for (BuildProject bp : __deps)
					fdeps.add(bp.jarout);
				
				// {@squirreljme.error NB08 Compilation of this project
				// failed. (The name of this project)}
				if (!javac.compile(basepath, tempdir, fdeps, fsources,
					Arrays.<String>asList("-source", "1.7",
					"-target", "1.7", "-g", "-Xlint:deprecation",
					"-Xlint:unchecked")))
					throw new RuntimeException(String.format("NB08 %s",
						name));
			}
			
			// Create directory used for output
			Path jpar = jarout.getParent();
			if (jpar != null)
				Files.createDirectories(jpar);
			
			// Generate JAR output
			Path tempjar = Files.createTempFile("buildjar", "jar");
			try (final ZipOutputStream zos = new ZipOutputStream(Files.
				newOutputStream(tempjar,
				StandardOpenOption.WRITE, StandardOpenOption.CREATE)))
			{
				// Write files in the output and input
				final byte[] buf = new byte[4096];
				Consumer<Path, Path, IOException> func =
					new Consumer<Path, Path, IOException>()
					{
						/**
						 * {@inheritDoc}
						 * @since 2016/10/28
						 */
						@Override
						public void accept(Path __p, Path __s)
							throws IOException
						{
							ZipOutputStream out = zos;
							
							// Ignore directories
							if (Files.isDirectory(__p) || __p.
								getFileName().toString().endsWith("java"))
								return;
							
							// Ignore files ending in .java
							Path fn = __p.getFileName();
							String fns = __p.getFileName().toString();
							if (fns.endsWith(".java"))
								return;
							
							// Detect MIME files?
							boolean ismime = false;
							if (fns.endsWith(".__mime"))
							{
								ismime = true;
								fns = fns.substring(0, fns.length() - 7);
							}
							
							// Create new entry
							out.putNextEntry(
								new ZipEntry(NewBootstrap.__zipName(__s,
									__p.resolveSibling(fns))));
							
							// Copy data
							try (InputStream src = Files.newInputStream(__p,
									StandardOpenOption.READ);
								InputStream is = (!ismime ? src :
									new MIMEFileDecoder(src)))
							{
								for (;;)
								{
									int rc = is.read(buf);
									
									// EOF?
									if (rc < 0)
										break;
									
									// Copy
									out.write(buf, 0, rc);
								}
							}
							
							// Close
							out.closeEntry();
						}
					};
				
				// Add sources and classes
				NewBootstrap.<Path>__walk(basepath, basepath, func);
				NewBootstrap.<Path>__walk(tempdir, tempdir, func);
				
				// Finish it
				zos.finish();
				zos.flush();
				
				// Move JAR
				Files.move(tempjar, jarout,
					StandardCopyOption.REPLACE_EXISTING);
			}
			
			// Failed, delete output JAR
			catch (IOException|RuntimeException|Error e)
			{
				// Delete file
				try
				{
					Files.delete(tempjar);
				}
				catch (IOException f)
				{
					// Ignore
				}
				
				// Rethrow
				throw e;
			}
		}
		
		// Always clear at the end
		finally
		{
			if (tempdir != null)
				try
				{
					NewBootstrap.<Object>__walk(tempdir, null,
						NewBootstrap.DELETE);
				}
				catch (IOException e)
				{
					// Ignore
				}
		}
	}
	
	/**
	 * Lowercases the specified string.
	 *
	 * @param __s The string to check.
	 * @return The string in correct form.
	 * @throws IllegalArgumentException If it is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/27
	 */
	private static String __correctProjectName(String __s)
		throws IllegalArgumentException, NullPointerException
	{
		// Check
		if (__s == null)
			throw new NullPointerException("NARG");
		
		// Check if any characters need lowering first
		int n = __s.length();
		boolean dolower = false;
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Lowercase?
			if (c >= 'A' && c <= 'Z')
				dolower = true;
			
			// Legal character?
			else if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
				c == '-')
				continue;
			
			// {@squirreljme.error NB01 Illegal character used in project
			// name. (The input project name)}
			else
				throw new IllegalArgumentException(String.format("NB01 %s",
					__s));
		}
		
		// Use original string
		if (!dolower)
			return __s;
		
		// Lowercase everything
		StringBuilder sb = new StringBuilder(n);
		for (int i = 0; i < n; i++)
		{
			char c = __s.charAt(i);
			
			// Lowercase?
			if (c >= 'A' && c <= 'Z')
				sb.append((char)((c - 'A') + 'a'));
			
			// Keep
			else
				sb.append(c);
		}
		
		// Use that
		return sb.toString();
	}
}

Deleted utils-dev/boot/Consumer.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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * Consumes a value which may throw an exception.
 *
 * @param <V> The value to consume.
 * @param <S> A secondary value that may be passed.
 * @param <E> The exception to potentially throw.
 * @since 2016/10/27
 */
public interface Consumer<V, S, E extends Exception>
{
	/**
	 * Accepts a value.
	 *
	 * @param __v The value to access.
	 * @param __s An optional secondary value.
	 * @throws E If this given exception type is thrown.
	 * @since 2016/10/27
	 */
	public abstract void accept(V __v, S __s)
		throws E;
}

Deleted utils-dev/boot/MIMECharAlphabet.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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

/**
 * This represents the alphabet that is used for Base64.
 *
 * @since 2018/03/05
 */
public enum MIMECharAlphabet
{
	/** The basic and MIME alphabet. */
	BASIC('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='),
	
	/** The URL alphabet. */
	URL('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
		'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
		'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '='),
	
	/** End. */
	;
	
	/** The alphabet for the characters. */
	final char[] _alphabet;
	
	/**
	 * Initializes the alphabet.
	 *
	 * @param __alphabet The alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	private MIMECharAlphabet(char... __alphabet)
		throws NullPointerException
	{
		if (__alphabet == null)
			throw new NullPointerException("NARG");
		
		this._alphabet = __alphabet;
	}
}

Deleted utils-dev/boot/MIMECharDecoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529

















































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;

/**
 * This decodes the base64 character set, ignoring invalid characters, and
 * provides the binary data for the input. If the padding character is
 * reached or if the input stream runs out of characters then EOF is
 * triggered.
 *
 * @since 2018/03/05
 */
public final class MIMECharDecoder
	extends InputStream
{
	/** The source reader. */
	protected final Reader in;
	
	/** Ignore padding characters. */
	protected final boolean ignorepadding;
	
	/** The alphabet to use for decoding. */
	private final char[] _alphabet;
	
	/** The ASCII map for quick lookup. */
	private final byte[] _ascii;
	
	/** Output bytes to drain. */
	private final byte[] _drain =
		new byte[3];
	
	/** The current fill buffer. */
	private volatile int _buffer;
	
	/** The number of bits which are in the buffer. */
	private volatile int _bits;
	
	/** Has EOF been reached if the pad has been detected? */
	private volatile boolean _readeof;
	
	/** The current output drain position. */
	private volatile int _drained =
		-1;
	
	/** The maximum value for drained values. */
	private volatile int _drainedmax =
		-1;
	
	/**
	 * Initializes the decode the default MIME alphabet.
	 *
	 * @param __in The input set of characters.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/23
	 */
	public MIMECharDecoder(Reader __in)
	{
		this(__in, MIMECharAlphabet.BASIC);
	}
	
	/**
	 * Initializes the decoder using the specified alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the
	 * alphabet.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, MIMECharAlphabet __chars)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, String __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), false);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, char[] __chars)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars, false);
	}
	
	/**
	 * Initializes the decoder using the default alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The pre-defined character set to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the
	 * end of the stream.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, MIMECharAlphabet __chars,
		boolean __ip)
		throws NullPointerException
	{
		this(__in, __chars._alphabet, __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the
	 * end of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, String __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		this(__in, __chars.toCharArray(), __ip);
	}
	
	/**
	 * Initializes the decoder using the specified custom alphabet.
	 *
	 * @param __in The input set of characters.
	 * @param __chars The characters to use for the alphabet.
	 * @param __ip Ignore padding characters and do not treat them as the
	 * end of the stream.
	 * @throws IllegalArgumentException If the alphabet is of the incorrect
	 * size.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMECharDecoder(Reader __in, char[] __chars, boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __chars == null)
			throw new NullPointerException("NARG");
		
		// {@squirreljme.erorr NB8g The alphabet to use for the base64
		// decoder must be 64 characters plus one padding character.
		// (The character count)}
		int n;
		if ((n = __chars.length) != 65)
			throw new IllegalArgumentException(
				String.format("NB8g %d", n));
		
		// Set
		this.in = __in;
		this.ignorepadding = __ip;
		this._alphabet = (__chars = __chars.clone());
		
		// Build ASCII map for quick in-range character lookup
		byte[] ascii = new byte[128];
		for (int i = 0; i < 128; i++)
			ascii[i] = -1;
		for (int i = 0; i < 65; i++)
		{
			int dx = __chars[i];
			if (dx < 128)
				ascii[dx] = (byte)i;
		}
		this._ascii = ascii;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		int drained = this._drained;
		
		// There are bytes which are ready and in the drain that we do not
		// need to block reading them?
		if (drained != -1)
			return this._drainedmax - drained;
		return 0;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.in.close();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		// If there is stuff to be drained, quickly drain that so we do not
		// need to go deeper into the heavier method
		int drained = this._drained;
		if (drained != -1)
		{
			// Read in drained character
			int rv = this._drain[drained++] & 0xFF;
			
			// Reached the drain limit?
			if (drained == this._drainedmax)
			{
				this._drained = -1;
				this._drainedmax = -1;
			}
			
			// Would still be drain
			else
				this._drained = drained;
			
			// Return the value
			return rv;
		}
		
		// Previously read EOF, so this will just return EOF
		if (this._readeof)
			return -1;
		
		// Otherwise decode and read
		byte[] next = new byte[1];
		for (;;)
		{
			int rc = this.read(next, 0, 1);
			
			// EOF?
			if (rc < 0)
				return -1;
			
			// Missed read
			else if (rc == 0)
				continue;
			
			return (next[0] & 0xFF);
		}
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		
		return this.read(__b, 0, __b.length);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Did a previous read cause a padded EOF?
		boolean readeof = this._readeof;
		
		// Need lookups
		Reader in = this.in;
		boolean ignorepadding = this.ignorepadding;
		char[] alphabet = this._alphabet;
		byte[] ascii = this._ascii;
		byte[] drain = this._drain;
		
		// This buffer is filled into as needed when input characters are
		// read
		int buffer = this._buffer,
			bits = this._bits,
			drained = this._drained,
			drainedmax = this._drainedmax;
		
		// Keep trying to fill bytes in
		int rv = 0;
		while (rv < __l)
		{
			// Still need to drain bytes away
			if (drained != -1 && drained < drainedmax)
			{
				// Drain it
				__b[__o++] = drain[drained++];
				rv++;
				
				// Drained all the characters
				if (drained == drainedmax)
					drained = drainedmax = -1;
				
				// Try again
				else
					continue;
			}
			
			// EOF was reached
			if (readeof)
				break;
			
			// Read in character and decode it
			int ch = in.read();
			
			// Is EOF?
			if (ch < 0)
			{
				// {@squirreljme.error BD20 Read EOF from input when there
				// were expected to be more characters or the ending
				// padding character. (The bits in the buffer)}
				if (bits != 0)
					throw new IOException("BD20 " + bits);
				
				// Did read EOF
				readeof = true;
				break;
			}
			
			// Determine the value of the character
			if (ch < 128)
				ch = ascii[ch];
			else
			{
				ch = -1;
				for (int i = 0; i < 65; i++)
					if (i == alphabet[i])
					{
						ch = i;
						break;
					}
			}
			
			// Invalid, ignore and continue
			if (ch == -1 || (ignorepadding && ch == 64))
				continue;
			
			// Decoded padding character
			else if (ch == 64)
			{
				// {@squirreljme.error BD21 Did not expect a padding
				// character.
				// (The number of decoded bits in queue)}
				if (bits == 0 || bits == 24)
					throw new IOException("BD21 " + bits);
				
				// Only want to store a single extra byte since that is
				// all that is valid
				else if (bits < 16)
				{
					// {@squirreljme.error BD22 Expected another padding
					// character.}
					if (in.read() != alphabet[64])
						throw new IOException("BD22");
					
					drain[0] = (byte)(buffer >>> 4);
					
					drainedmax = 1;
				}
				
				// Otherwise there will be two characters to drain
				else
				{
					drain[0] = (byte)(buffer >>> 10);
					drain[1] = (byte)(buffer >>> 2);
					
					drainedmax = 2;
				}
				
				// Need to drain all
				drained = 0;
					
				// Clear the buffer
				buffer = bits = 0;
				
				// Did read EOF
				readeof = true;
			}
			
			// Normal data
			else
			{
				// Shift in six bits
				buffer <<= 6;
				buffer |= ch;
				bits += 6;
				
				// Drain and empty the buffer
				if (bits == 24)
				{
					// Fill the drain
					drain[0] = (byte)(buffer >>> 16);
					drain[1] = (byte)(buffer >>> 8);
					drain[2] = (byte)buffer;
					
					// Set these to drain
					drained = 0;
					drainedmax = 3;
					
					// Clear the buffer
					buffer = bits = 0;
				}
			}
		}
		
		// Store state for next run
		this._buffer = buffer;
		this._bits = bits;
		this._readeof = readeof;
		this._drained = drained;
		this._drainedmax = drainedmax;
		
		// Return the read count
		if (readeof && rv == 0)
			return -1;
		return rv;
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/06
	 */
	public static final byte[] decode(String __in, MIMECharAlphabet __ab)
		throws IllegalArgumentException, NullPointerException
	{
		return MIMECharDecoder.decode(__in, __ab, false);
	}
	
	/**
	 * Decodes the input string to byte values.
	 *
	 * @param __in The string to decode.
	 * @param __ab The alphabet to use.
	 * @param __ip Is padding ignored?
	 * @return The resulting byte array.
	 * @throws IllegalArgumentException If the input string is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public static final byte[] decode(String __in, MIMECharAlphabet __ab,
		boolean __ip)
		throws IllegalArgumentException, NullPointerException
	{
		if (__in == null || __ab == null)
			throw new NullPointerException("NARG");
		
		// Wrap in a reader to decode
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
		{
			byte[] buf = new byte[32];
			
			// Loop handle bytes
			try (InputStream in = new MIMECharDecoder(
				new StringReader(__in), __ab, __ip))
			{
				for (;;)
				{
					int rc = in.read(buf);
					
					// EOF?
					if (rc < 0)
						break;
					
					// Copy
					baos.write(buf, 0, rc);
				}
			}
			
			// Return resulting byte array
			return baos.toByteArray();
		}
		
		// {@squirreljme.error NB82 Could not decode the input string.}
		catch (IOException e)
		{
			throw new IllegalArgumentException("NB82", e);
		}
	}
}

Deleted utils-dev/boot/MIMEFileDecoder.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
























































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

/**
 * This class is used to decode input streams which have been encoded in
 * the MIME Base64 format. This file format is genearted by
 * {@code uuencode -m}.
 * This format usually begins with {@code begin-base64 mode filename} and
 * ends with the padding sequence {@code ====}.
 *
 * This class is not thread safe.
 *
 * @since 2018/03/05
 */
public final class MIMEFileDecoder
	extends InputStream
{
	/** The input base64 data. */
	protected MIMECharDecoder mime;
	
	/** The read mode. */
	private int _mode =
		Integer.MIN_VALUE;
	
	/** The read filename. */
	private String _filename;
	
	/**
	 * Initializes the MIME file decoder using the default encoding.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in)
		throws NullPointerException
	{
		this(new InputStreamReader(__in));
	}
	
	/**
	 * Initializes the MIME file decoder using the given encoding.
	 *
	 * @param __in The input source.
	 * @param __enc The encoding used.
	 * @throws NullPointerException On null arguments.
	 * @throws UnsupportedEncodingException If the encoding is not
	 * supported.
	 * @since 2018/11/30
	 */
	public MIMEFileDecoder(InputStream __in, String __enc)
		throws NullPointerException, UnsupportedEncodingException
	{
		this(new InputStreamReader(__in, __enc));
	}
	
	/**
	 * Initializes the MIME file decoder from the given set of characters.
	 *
	 * @param __in The input source.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/05
	 */
	public MIMEFileDecoder(Reader __in)
		throws NullPointerException
	{
		if (__in == null)
			throw new NullPointerException("NARG");
		
		// Directly wrap the reader with the MIME decoder which reads from
		// a source reader that is internally maintained
		this.mime = new MIMECharDecoder(new __SubReader__(__in));
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int available()
		throws IOException
	{
		return this.mime.available();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final void close()
		throws IOException
	{
		this.mime.close();
	}
	
	/**
	 * Returns the filename which was read.
	 *
	 * @return The read filename, {@code null} will be returned if it has
	 * not been read yet or has not been specified.
	 * @since 2018/03/05
	 */
	public final String filename()
	{
		return this._filename;
	}
	
	/**
	 * Returns the UNIX mode of the stream.
	 *
	 * @return The UNIX mode, a negative value will be returned if it has
	 * not been read yet.
	 * @since 2018/03/05
	 */
	public final int mode()
	{
		return this._mode;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read()
		throws IOException
	{
		return this.mime.read();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/25
	 */
	@Override
	public final int read(byte[] __b)
		throws IOException
	{
		return this.mime.read(__b);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/03/05
	 */
	@Override
	public final int read(byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, IOException, NullPointerException
	{
		return this.mime.read(__b, __o, __l);
	}
	
	/**
	 * This is a sub-reader which handles parsing of the MIME header and
	 * otherwise just passing the data to the MIMECharDecoder instance.
	 *
	 * @since 2018/11/25
	 */
	private final class __SubReader__
		extends Reader
	{
		/** The line-by-line reader for data. */
		protected final BufferedReader in;
		
		/** The input character buffer. */
		private final StringBuilder _sb =
			new StringBuilder(80);
		
		/** The current read in the buffer. */
		private int _at;
		
		/** The current limit of the buffer. */
		private int _limit;
		
		/** Did we read the header? */
		private boolean _didheader;
		
		/** Did we read the footer? */
		private boolean _didfooter;
		
		/**
		 * Initializes the sub-reader for the MIME data.
		 *
		 * @param __in The source reader.
		 * @throws NullPointerException On null arguments.
		 * @since 2018/11/24
		 */
		__SubReader__(Reader __in)
			throws NullPointerException
		{
			if (__in == null)
				throw new NullPointerException("NARG");
			
			this.in = new BufferedReader(__in, 80);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public void close()
			throws IOException
		{
			this.in.close();
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read()
			throws IOException
		{
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Need to read more from the buffer
			int at = this._at,
				limit = this._limit;
			if (at >= limit)
			{
				// Read line next
				if (!this.__readNext())
					return -1;
				
				// Re-read
				at = this._at;
				limit = this._limit;
			}
			
			// Read the next character
			int rv = this._sb.charAt(at);
			this._at = at + 1;
			return rv;
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			
			return this.read(__c, 0, __c.length);
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2018/11/25
		 */
		@Override
		public int read(char[] __c, int __o, int __l)
			throws IOException
		{
			if (__c == null)
				throw new NullPointerException("NARG");
			if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
				throw new IndexOutOfBoundsException("IOOB");
			
			// Read header?
			if (!this._didheader)
				this.__readHeader();
			
			// If the footer was read, this means EOF
			if (this._didfooter)
				return -1;
			
			// Where to read from
			StringBuilder sb = this._sb;
			int at = this._at,
				limit = this._limit;
			
			// Read in all characters
			int rv = 0;
			while (rv < __l)
			{
				// Need to read more?
				if (at >= limit)
				{
					// EOF?
					if (!this.__readNext())
						return (rv == 0 ? -1 : rv);
					
					// Re-read
					at = this._at;
					limit = this._limit;
				}
				
				// Read the next character
				__c[__o++] = sb.charAt(at++);
			}
			
			// Store new at position
			this._at = at;
			
			return rv;
		}
		
		/**
		 * Reads the header information.
		 *
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final void __readHeader()
			throws IOException
		{
			BufferedReader in = this.in;
			
			// {@squirreljme.error BD23 Unexpected end of file while trying
			// to read MIME header.}
			String ln = in.readLine();
			if (ln == null)
				throw new IOException("BD23");
			
			// The header is in this format:
			// begin-base64 <unixmode> <filename>
			// {@squirreljme.error BD24 MIME encoded does not start with
			// MIME header.}
			if (!ln.startsWith("begin-base64"))
				throw new IOException("BD24");
			
			// UNIX mode?
			int fs = ln.indexOf(' ');
			if (fs >= 0)
			{
				int ss = ln.indexOf(' ', fs + 1);
				
				// Decode octal mode bits
				MIMEFileDecoder.this._mode = Integer.parseInt(
					ln.substring(fs + 1, (ss < 0 ? ln.length() : ss)), 8);
				
				// Filename?
				if (ss >= 0)
					MIMEFileDecoder.this._filename =
						ln.substring(ss + 1);
			}
			
			// Set as read
			this._didheader = true;
		}
		
		/**
		 * Reads the next line into the character.
		 *
		 * @return If a line was read.
		 * @throws IOException On read errors.
		 * @since 2018/11/25
		 */
		private final boolean __readNext()
			throws IOException
		{
			// {@squirreljme.error BD25 Unexpected EOF while read the MIME
			// file data.}
			String ln = this.in.readLine();
			if (ln == null)
				throw new IOException("BD25");
			
			// End of MIME data?
			if (ln.equals("===="))
			{
				// Footer was read, so EOF now
				this._didfooter = true;
				
				// Was EOF
				return false;
			}
			
			// Fill buffer
			StringBuilder sb = this._sb;
			sb.setLength(0);
			sb.append(ln);
			
			// Set properties
			this._at = 0;
			this._limit = ln.length();
			
			// Was not EOF
			return true;
		}
	}
}

Deleted utils-dev/boot/NewBootstrap.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
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
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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709





































































































































































































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.file.attribute.FileTime;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

/**
 * This class implements a bootstrap which is capable to build an environment
 * which is capable of building SquirrelJME target binaries.
 *
 * You should only compile and run this class manually if your system is not
 * able to use the pre-existing build scripts. If this is the case then you
 * must set the following system properties:
 *
 * {@code cc.squirreljme.bootstrap.binary} is the location
 * where output binaries are to be placed when they are compiled, along with
 * the bootstrap.
 * {@code cc.squirreljme.builder.root} is the location
 * of the SquirrelJME source tree.
 *
 * @since 2016/10/26
 */
public class NewBootstrap
	implements Runnable
{
	/** Deletes files. */
	public static final Consumer<Path, Object, IOException> DELETE =
		new Consumer<Path, Object, IOException>()
		{
			/**
			 * {@inheritDoc}
			 * @since 2016/10/27
			 */
			@Override
			public void accept(Path __v, Object __s)
				throws IOException
			{
				Files.delete(__v);
			}
		};
	
	/** Returns the latest date. */
	public static final Consumer<Path, Long[], IOException> DATE =
		new Consumer<Path, Long[], IOException>()
		{
			/**
			 * {@inheritDoc}
			 * @since 2016/10/27
			 */
			@Override
			public void accept(Path __v, Long[] __s)
				throws IOException
			{
				// Dates on directories might not truly be valid
				if (Files.isDirectory(__v))
					return;
				
				// Get date
				FileTime ft = Files.getLastModifiedTime(__v);
				long millis = ft.toMillis();
				
				// If it is newer, use that
				if (millis > __s[0])
					__s[0] = millis;
			}
		};
	
	/** Cache of the compiler so it does not need to be read multiple times. */
	private static BootstrapCompiler _javac;
	
	/** The binary path. */
	protected final Path binarypath;
	
	/** The source path. */
	protected final Path sourcepath;
	
	/** The input launch arguments. */
	protected final String[] launchargs;
	
	/** Projects available for usage. */
	protected final Map<String, BuildProject> projects;
	
	/** The output bootstrap binary. */
	protected final Path bootstrapout;
	
	/** The directory where JARs are placed. */
	protected final Path buildjarout;
	
	/**
	 * Initializes the bootstrap base.
	 *
	 * @param __bin The binary output directory.
	 * @param __src The source input namespace directories.
	 * @param __args Arguments to the bootstrap.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/26
	 */
	public NewBootstrap(Path __bin, Path __src, String[] __args)
		throws IOException, NullPointerException
	{
		// Check
		if (__bin == null || __src == null || __args == null)
			throw new NullPointerException("NARG");
		
		// Set
		this.binarypath = __bin;
		this.sourcepath = __src;
		this.launchargs = __args.clone();
		this.buildjarout = __bin.resolve("bootsjme");
		this.bootstrapout = __bin.resolve("sjmeboot.jar");
		
		// Load all projects in the build directory
		Map<String, BuildProject> projects = new LinkedHashMap<>();
		this.projects = projects;
		
		// Java SE special host libraries
		__loadProjects(projects, __src.resolve("bldt/javase/libs"));
		
		// Run-time projects
		__loadProjects(projects, __src.resolve("runt/apis"));
		__loadProjects(projects, __src.resolve("runt/libs"));
		__loadProjects(projects, __src.resolve("runt/mids"));
		__loadProjects(projects, __src.resolve("runt/klib"));
		__loadProjects(projects, __src.resolve("runt/kmid"));
		
		// JIT-time projects
		__loadProjects(projects, __src.resolve("jitt/libs"));
		
		// Build-time projects
		__loadProjects(projects, __src.resolve("bldt/libs"));
		__loadProjects(projects, __src.resolve("bldt/mids"));
	}
		
	/**
	 * {@inheritDoc}
	 * @since 2016/10/26
	 */
	@Override
	public void run()
	{
		// {@squirreljme.error NB03 The entry point project does not exist.}
		Map<String, BuildProject> projects = this.projects;
		BuildProject bp = projects.get("builder");
		if (bp == null)
			throw new IllegalStateException("NB03");
		
		// Could fail
		Path tempjar = null;
		try
		{
			// Compile JARs to be merged together as one
			Set<BuildProject> mergethese = bp.compile();
			
			// Get the time and date for the JARs to merge
			Path bootjar = this.bootstrapout;
			Long[] out = new Long[1];
			out[0] = Long.MIN_VALUE;
			NewBootstrap.<Long[]>__walk(this.buildjarout, out, DATE);
			long depjartime = out[0];
			
			// Get the time of the output JAR
			long bootjartime;
			if (Files.exists(bootjar))
			{
				out[0] = Long.MIN_VALUE;
				NewBootstrap.<Long[]>__walk(bootjar, out, DATE);
				bootjartime = out[0];
			}
			else
				bootjartime = Long.MIN_VALUE;
			
			// Repackage
			if (bootjartime == Long.MIN_VALUE || depjartime > bootjartime)
			{
				// {@squirreljme.error NB0a Merging output JAR file.}
				System.err.println("NB0a");
				
				// {@squirreljme.error NB0b Expected the entry point boot JAR
				// to be within the merge JAR set.}
				List<BuildProject> mergeorder = new ArrayList<>(mergethese);
				if (!mergeorder.remove(bp))
					throw new RuntimeException("NB0b");
				
				// Make the boot JAR always first
				mergeorder.add(0, bp);
				
				// {@squirreljme.error NB0d Expected the CLDC libraries to be
				// present in the build.}
				BuildProject cldccompact = projects.get("cldc-compact");
				if (!mergeorder.remove(cldccompact))
					throw new RuntimeException("NB0d");
				
				// Make the CLDC compact JAR always last, so that its system
				// entries are always shaded last. This is because they need
				// to be replaced accordingly to operate correctly
				mergeorder.add(cldccompact);
				
				// Create temporary JAR
				tempjar = Files.createTempFile("squirreljme-boot-out", ".jar");
				
				// Open output
				Map<String, BuildProject> shaded = new HashMap<>();
				Map<String, Set<String>> services = new LinkedHashMap<>();
				try (ZipOutputStream zos = new ZipOutputStream(Files.
					newOutputStream(tempjar,
					StandardOpenOption.WRITE, StandardOpenOption.CREATE)))
				{
					// Set no compression because the Simulated JVM does
					// not support ZIP compression (compatibility)
					zos.setLevel(0);
					
					// Copy contents from other JARs
					for (BuildProject dp : mergeorder)
						__mergeInto(dp, zos, dp == bp, services, shaded);
					
					// Write services as needed
					byte[] buf = new byte[512];
					for (Map.Entry<String, Set<String>> e :
						services.entrySet())
					{
						// Write service descriptor
						zos.putNextEntry(
							new ZipEntry("META-INF/services/" + e.getKey()));
			
						// Write classes to provide services for 
						for (String v : e.getValue())
						{
							// Write name followed by \r\n pair
							zos.write(v.getBytes("utf-8"));
							zos.write('\r');
							zos.write('\n');
						}
			
						// Always end in a blank line
						zos.write('\r');
						zos.write('\n');
			
						// Done writing it
						zos.closeEntry();
					}
						
					// Finish it
					zos.finish();
					zos.flush();
				}
				
				// Move it
				Files.move(tempjar, bootjar,
					StandardCopyOption.REPLACE_EXISTING);
			}
		}
		
		// {@squirreljme.error NB04 Failed to compile the bootstrap due to
		// a read/write error.}
		catch (IOException e)
		{
			throw new RuntimeException("NB04", e);
		}
		
		// Cleanup temporary JAR if it was created
		finally
		{
			if (tempjar != null)
				try
				{
					Files.delete(tempjar);
				}
				catch (IOException e)
				{
				}
		}
	}
	
	/**
	 * Loads projects in the given directory and places them into the existing
	 * map if they do not exist.
	 *
	 * @param __t The target project mapping.
	 * @param __p The source path.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2017/02/20
	 */
	private void __loadProjects(Map<String, BuildProject> __t, Path __p)
		throws IOException, NullPointerException
	{
		// Check
		if (__t == null || __p == null)
			throw new NullPointerException("NARG");
		
		// Go through files
		try (DirectoryStream<Path> ds = Files.newDirectoryStream(__p))
		{
			// Go through all directories
			for (Path p : ds)
			{
				// Must be a directory
				if (!Files.isDirectory(p))
					continue;
			
				// See if the manifest exists
				Path man = p.resolve("META-INF").resolve("MANIFEST.MF");
				if (!Files.exists(man))
					continue;
			
				// Load project
				BuildProject bp = new BuildProject(p, man, this.buildjarout,
					this.projects);
				
				// Add project, but never replace projects (this way the
				// build directory takes priority)
				String pn = bp.projectName();
				if (!__t.containsKey(pn))
					__t.put(bp.projectName(), bp);
			}
		}
	}
	
	/**
	 * Main entry point for the new bootstrap system.
	 *
	 * @param __args Program arguments.
	 * @throws IOException On any read/write errors.
	 * @since 2016/10/26
	 */
	public static void main(String... __args)
		throws IOException
	{
		// Compiling under JamVM fails because it cannot find a resource
		// bundle for the Java compiler
		if (__args != null && __args.length >= 1 &&
			"--toolsflaw".equals(__args[0]))
		{
			__detectToolsFlaw();
			return;
		}
		
		// Get directories for input and output
		Path bin = Paths.get(System.getProperty(
			"cc.squirreljme.bootstrap.binary")),
			src = Paths
			.get(System.getProperty(
			"cc.squirreljme.builder.root"));
		
		// Only build?
		NewBootstrap nb = new NewBootstrap(bin, src, __args);
		
		// Run it
		nb.run();
	}
	
	/**
	 * This method detects if the virtual machine has a flaw where it cannot
	 * find the javac resource because of odd handling of JARs dynamically
	 * loaded at run-time.
	 *
	 * If the flaw needs to have a work-around then a JAR will be printed
	 * to standard output.
	 *
	 * @sine 2018/01/13
	 */
	private static final void __detectToolsFlaw()
	{
		String vmname = System.getProperty("java.vm.name", "");
		
		// JamVM has an issue where when tools.jar is dynamically loaded it
		// will fail to find the named resource. This will cause all
		// compilation with the system Java compiler to fail.
		if (vmname.equalsIgnoreCase("jamvm"))
		{
			// The JAR to locate will be in the specified location, likely
			// /usr/lib/jvm/java-7-openjdk-powerpc/lib/tools.jar
			Path jhome = Paths.get(System.getProperty("java.home", ""));
			
			// Maybe it is here?
			Path mightbe = jhome.resolve("tools.jar");
			if (Files.exists(mightbe))
			{
				System.out.println(mightbe);
				return;
			}
			
			// Try to see if we can get in the library directory
			jhome = jhome.getParent();
			if (jhome != null)
				jhome = jhome.resolve("lib");
				
			// It could be here
			mightbe = jhome.resolve("tools.jar");
			if (Files.exists(mightbe))
			{
				System.out.println(mightbe);
				return;
			}
			
			// These paths will need to be searched for the tools.jar
			// It will be in a path like:
			String[] bootpaths = System.getProperty("sun.boot.class.path", "").
				split(Pattern.quote(
				System.getProperty("path.separator", ":")));
			
			// Go through each path and try to find tools.jar
			for (String rbp : bootpaths)
			{
				Path p = Paths.get(rbp);
				
				// If this refers to a file then try to its directory
				if (!Files.isDirectory(p))
					p = p.getParent();
				
				// Ignore it because it could not be found
				if (p == null || !Files.isDirectory(p))
					continue;
				
				// If there is a tools.jar here, indicate that
				p = p.resolve("tools.jar");
				if (Files.exists(p))
				{
					System.out.println(p);
					return;
				}
			}
		}
	}
	
	/**
	 * Merges the input JAR into the output JAR.
	 *
	 * @param __bp The source.
	 * @param __zos The destination.
	 * @param __useman Use the manifest?
	 * @param __svs Service list.
	 * @param __shade Used to detect shading.
	 * @throws IOException On read/write errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/10/28
	 */
	private static void __mergeInto(BuildProject __bp, ZipOutputStream __zos,
		boolean __useman, Map<String, Set<String>> __svs,
		Map<String, BuildProject> __shade)
		throws IOException, NullPointerException
	{
		// Check
		if (__bp == null || __zos == null || __svs == null || __shade == null)
			throw new NullPointerException("NARG");
		
		// Go through the input
		try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(
			__bp.jarout, StandardOpenOption.READ)))
		{
			// Copy all entries
			ZipEntry e;
			byte[] buf = new byte[4096];
			while (null != (e = zis.getNextEntry()))
			{
				// If the entry is the manifest, only use it if it was
				// requested
				String name = e.getName();
				boolean ismanifest;
				if ((ismanifest = name.equals("META-INF/MANIFEST.MF")))
					if (!__useman)
					{
						zis.closeEntry();
						continue;
					}
				
				// This is a service, needs to be handled later
				if (name.startsWith("META-INF/services/") &&
					name.length() > "META-INF/services/".length())
				{
					// Record service to write later
					String k = name.substring("META-INF/services/".length());
					Set<String> into = __svs.get(k);
					if (into == null)
						__svs.put(k, (into = new LinkedHashSet<>()));
					
					// Read in services completely
					byte[] data = null;
					try (ByteArrayOutputStream baos =
						new ByteArrayOutputStream())
					{
						// Copy loop
						for (;;)
						{
							int rc = zis.read(buf);
					
							// EOF?
							if (rc < 0)
								break;
					
							// Write
							baos.write(buf, 0, rc);
						}
						
						// Write in
						baos.flush();
						data = baos.toByteArray();
					}
					
					// Parse the data
					try (BufferedReader br = new BufferedReader(
						new InputStreamReader(new ByteArrayInputStream(data))))
					{
						for (;;)
						{
							String ln = br.readLine();
							
							// EOF?
							if (ln == null)
								break;
							
							// Ignore whitespace and empty lines
							ln = ln.trim();
							if (ln.length() <= 0)
								continue;
							
							// Add service
							into.add(ln);
						}
					}
					
					// Do not write this entry
					continue;
				}
				
				// {@squirreljme.error NB0c The specified entry has been
				// shaded out, an earlier file is taking priority. (The entry;
				// The base project; The current project)}
				BuildProject shadeout = __shade.get(name);
				if (shadeout != null)
				{
					System.err.printf("NB0c %s %s %s%n", e, shadeout.name,
						__bp.name);
					continue;
				}
				__shade.put(name, __bp);
				
				// Write to target
				__zos.putNextEntry(e);
				
				// Input source for where to read actual data
				InputStream sourcedata;
				Manifest realman = null;
				if (!ismanifest || !__useman)
					sourcedata = zis;
				
				// Make a fake manifest which is used instead
				else
				{
					Manifest fakeman = new Manifest(zis);
					Attributes fakeattr = fakeman.getMainAttributes();
					
					// Copy the real manifest so that it is placed in the
					// output tree
					realman = new Manifest(fakeman);
					
					// Move the main-class to a fake class
					fakeattr.putValue("X-SquirrelJME-Booted-Main-Class",
						fakeattr.getValue("Main-Class"));
					
					// Use instead a wrapped main which sets up the CLDC stuff
					// as needed so the run-time functions
					fakeattr.putValue("Main-Class",
						"cc.squirreljme.runtime.javase.Main");
					
					// Read from the fake manifest instead
					try (ByteArrayOutputStream baos = 
						new ByteArrayOutputStream())
					{
						fakeman.write(baos);
						baos.flush();
						
						// Use this manifest as the source instead
						sourcedata = new ByteArrayInputStream(
							baos.toByteArray());
					}
				}
				
				// Copy loop
				for (;;)
				{
					int rc = sourcedata.read(buf);
					
					// EOF?
					if (rc < 0)
						break;
					
					// Write
					__zos.write(buf, 0, rc);
				}
				
				// Close
				__zos.closeEntry();
				zis.closeEntry();
				
				// Write real manifest as backup?
				if (realman != null)
				{
					__zos.putNextEntry(
						new ZipEntry("SQUIRRELJME-BOOTSTRAP.MF"));
					realman.write(__zos);
					__zos.closeEntry();
				}
			}
		}
	}
	
	/**
	 * Walks the given path and calls the given consumer for every file and
	 * directory.
	 *
	 * @param <S> The secondary value to pass.
	 * @param __p The path to walk.
	 * @param __s The secondary value.
	 * @param __c The function to call for paths.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments, except for the secondary
	 * value.
	 * @since 2016/09/18
	 */
	static <S> void __walk(Path __p, S __s,
		Consumer<Path, S, IOException> __c)
		throws IOException, NullPointerException
	{
		// Check
		if (__p == null || __c == null)
			throw new NullPointerException("NARG");
		
		// If a directory, walk through all the files
		if (Files.isDirectory(__p))
			try (DirectoryStream<Path> ds = Files.newDirectoryStream(__p))
			{
				for (Path s : ds)
					__walk(s, __s, __c);
			}
		
		// Always accept, directories are accepted last since directories
		// cannot be deleted if they are not empty
		__c.accept(__p, __s);
	}
	
	/**
	 * Calculates the name that a file would appear as inside of a ZIP file.
	 *
	 * @param __root The root path.
	 * @param __p The file to add.
	 * @return The ZIP compatible name.
	 * @throws NullPointerException On null arguments.
	 * @since 2016/03/21
	 */
	static String __zipName(Path __root, Path __p)
		throws NullPointerException
	{
		// Check
		if (__root == null || __p == null)
			throw new NullPointerException();
		
		// Calculate relative name
		Path rel = __root.toAbsolutePath().relativize(__p.toAbsolutePath());
		
		// Build name
		StringBuilder sb = new StringBuilder();
		for (Path comp : rel)
		{
			// Prefix slash
			if (sb.length() > 0)
				sb.append('/');
			
			// Add component
			sb.append(comp);
		}
		
		// Return it
		return sb.toString();
	}
}

Deleted utils-dev/boot/README.

1
2
3



-
-
-
This directory contains the bootstrap classes used to enter the
pseudo-environment used to build SquirrelJME.

Deleted utils-dev/boot/StringReader.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
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



























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- 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.
// ---------------------------------------------------------------------------

import java.io.Reader;

/**
 * This is a reader which can read from a string.
 *
 * This class is not thread safe.
 *
 * @since 2018/11/04
 */
public class StringReader
	extends Reader
{
	/** The string to read from. */
	protected final String string;
	
	/** The string length. */
	protected final int length;
	
	/** The current position. */
	private int _at;
	
	/**
	 * Initializes the reader.
	 *
	 * @param __s The input string.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/11/04
	 */
	public StringReader(String __s)
		throws NullPointerException
	{
		if (__s == null)
			throw new NullPointerException("NARG");
		
		this.string = __s;
		this.length = __s.length();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public void close()
	{
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2018/11/04
	 */
	@Override
	public int read(char[] __c, int __o, int __l)
		throws IndexOutOfBoundsException, NullPointerException
	{
		if (__c == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __c.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Determine the current position and string length
		int at = this._at,
			length = this.length,
			left = length - at;
		
		// EOF?
		if (at >= length)
			return -1;
		
		// Can only read so many characters
		String string = this.string;
		int max = Math.min(__l, left),
			limit = at + max;
		for (int o = __o; at < limit; at++, o++)
			__c[o] = string.charAt(at);
		
		// Set position for next time
		this._at = at;
		
		return max;
	}
}

Deleted utils-dev/builderrors.sh.

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
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





























































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Builds the error file

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Header
echo "# List of Errors"
echo ""
__old="00"

# Process all errors
"$__exedir/listerror.sh" "$__exedir/.." 2> /dev/null | while read __line
do
	# Code prefix
	__pref="$(echo "$__line" | cut -c 1-2)"
	
	# Did the prefix change?
	if [ "$__old" != "$__pref" ]
	then
		
		# Output
		echo ""
		echo "# "'`'"$__pref"'` -- '"_$("$__exedir/prefixerrortoproject.sh" "$__pref")_"
		echo ""
		__old="$__pref"
	fi
	
	# Extract code and description
	__code="$(echo "$__line" | cut -c 1-4)"
	__desc="$(echo "$__line" | cut -c 5- | sed 's/\([_\*<(\`]\)/\\\1/g')"
	
	# Are there parameters?
	if echo "$__desc" | grep '([^)]*)[ \t]\{1,\}\\<' > /dev/null
	then
		# Extract and remove them
		__parm="$(echo "$__desc" |
			sed 's/^.*(\([^)]*\))[ \t]\{1,\}\\<.*$/\1/g' |
			sed 's/[ \t]\{2,\}/ /g')"
		__desc="$(echo "$__desc" |
			sed 's/([^)]*)[ \t]\{1,\}\\</\\</g' |
			sed 's/[ \t]\{2,\}/ /g')"
		
		# Base output
		echo " * ***"'`'"$__code"'`'"***: $__desc"
		
		# No delimeter?
		__nodelim="$(echo "$__parm" | grep '\;' > /dev/null; echo $?)"
		
		# Output all parameters
		__i=1
		while true
		do
			# Extract item
			__item="$(echo "$__parm" | cut -d ';' -f "$__i" |
				sed 's/^[ \t]*//g;s/[ \t]*$//g')"
			
			# Nothing
			if [ -z "$__item" ]
			then
				break
			fi
			
			# Print it
			echo "   * $__item"
			
			# Increase
			__i="$(expr "$__i" + 1)"
			
			# Stop if no delimeters are used
			if [ "$__nodelim" -ne "0" ]
			then
				break;
			fi
		done
		
	# There are none
	else
		echo " * ***"'`'"$__code"'`'"***: $__desc"
	fi
done

Deleted utils-dev/buildwine.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Runs the build system using the Wine version of the compilers
# and run-time instead of one on the native system (used to test cross
# platformness).

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

wine cmd.exe /C "$(winepath -w "$__exedir/../build.cmd")" "$@"

Deleted utils-dev/buildwithcutejavac.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Describe this.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

export JAVA_OPTIONS="-Dnet.multiphasicapps.javac.forcedefault=true \
	-Dcc.squirreljme.builder.output=cute"
"$__exedir/../build.sh" "$@"
exit $?

Deleted utils-dev/check80col.sh.

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






















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# For more information see license.txt.
# ---------------------------------------------------------------------------
# DESCRIPTION: Makes sure that no file exceeds 80 columns

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Base directory of code
__rootdir="."

# Go through all files
echo "The following files exceed 79 characters" 1>&2
find "$__rootdir" -type f | while read -r __file
do
	# Base file name
	__name="$(basename -- "$__file")"	
	
	# Ignore the fossil file
	if [ "$__name" = "_FOSSIL_" ]
	then
		continue
	fi
	
	# Obtain extension
	__ext=""
		
	# Count number of lines past 80
	__nl="$(expand -t 4 < "$__file" | sed 's/^\(.\{0,79\}\)$//;/^$/d' | \
		wc -l)"
	
	# File has lines above 80
	if [ "$__nl" -ge "1" ]
	then
		# For line count cheat on stderr
		printf '%s' "$__file"
		
		# Cheat space on stderr
		printf '%s' " ($__nl)" 1>&2
		
		# Ending line
		echo
	fi
done

Deleted utils-dev/checkascii.sh.

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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# For more information see license.txt.
# ---------------------------------------------------------------------------
# DESCRIPTION: Checks for files which do no contain the valid ASCII range.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Base directory of code
__rootdir="."

# Go through all files
echo "The following files contain non-ascii characters" 1>&2
find "$__rootdir" -type f | while read -r __file
do
	# Base file name
	__name="$(basename -- "$__file")"	
	
	# Ignore the fossil file
	if [ "$__name" = "_FOSSIL_" ] || [ "$__name" = ".fslckout" ]
	then
		continue
	fi
	
	# Grep it
	if grep -E '[^\x0A\x20-\x7E\t\r]' < "$__file" > /dev/null
	then
		echo "$__file"
	fi
done

Deleted utils-dev/clist/cldc.ugz.

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































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 cldc.gz
H4sICMsquVYCA2NsZGMAdVbdcusoDL7nYbavcPI77UxSZ+u0ndk7ipWEEwxe
wOnxPv1KgA1O2xtbSCCEfj7p129+4w/SsGV/OoGF5gV4A3ZavlvpaTl4WFjL
hyfd9b72FnibmVXvM3eljAP+oYCtuedhf6bSHlrHQwWZZJtqu/kjoPPSaLaV
Cg5gW+kcLZ+qLCr1FXSy/0mj2bbvPDTlodlN5SK982ClHsVJ0+txSzZujW25
z5peteu7zli8YKOFaaQ+Z2HS9is4V3F9ZouuA90EtyxQeGnBS5EPJN828AeN
qk5L0+vG3YlrbywUPOfAErWx1li26L3Jrl8ao4DrECK2unBbw789aBEXXJB1
K8Wdi98Vd8XTAiu9N+gOjGfjt2RWuc9oQHY9OWIuCpasTNvhjSEfoLMgOG5k
a9MTZ6N7DHi4o4i5MtyzJ6XgzNVCCHCFJ0a2PfctaP9FsDdaop9qj9d8EX7P
PV4w3M29DGOKhnuJZkYXXTCMEG39OVBP2nmuveQhMAXbw3melYUQecE/O6mv
fLxjZzBr9txf2DMa6eUtllot/yusfDbBtjWcYmjCyWdT9+KylaBGRq/UwUi6
uzjatx9g0+8+uauP3yA8C0/cQ2vsEDVVNzRfNsBeeq2DzUh42U7/rCIxiuKt
QfSY+kPeM3L2XHNyT33BNGJYflhM6RdxaFpI1Uyrn6NACWkxbd651bjRsXpw
HloWI00/8xmsL4o4OPINrJsqqhBWHYZoHtI3aX2P+cbFReoUs1zvD1xr43ks
1EyujQhpixWwUUDUcegA0+IChBgNew6RRujpADEnOBg8bgseHamDUVIM7Mjt
GXx5qYUT7iLcpkqfqL976IG9A79mYTyl8fxSzmraaI2hL1PsxfQejubRlBhx
QL+8anSnuJCZhe+NuMIMJ6/afOr56XT71HbSj9LrpMxn3hj5rxjpewEC23gW
ycpSXgTkSFwstTF3KKsSPV38gHbjS5VDHB20wIzQpncBQOeXrOI+dvd3sc81
y2Gq6Rn6oSjtnDezUU3CnqVCd2GK7k0zK2tNzYcc+0UJyqi7fCsbD5V21wDX
e96ooORlz5wkNSlvWin25vYzwOMT6UWxtsoM6oYqkmuJeI9oPASIQyLvmkSo
ftN2JSpMonFYmK//wkupfdHdC0UFjWel827u6NAtWTaQfWdr5rlAO0ybG1ey
OSDw5m0EzNXo/giuahYuP9lYYCg2/HSItIWPCyGqtBq+swZbEI4Itik8OLIK
ZfNAPXCPYPiBFcqW3EkRvDKy4qOmZVgdCa2jDpfgl8Umi6XvrSnSacZWVGl0
Q4Ho35Ir2isKU3svFVt8OE9zRyEdWTsM3rTY826iI26NqzjBYGtVswM1Qljo
jGuSRzJuIArLlCsavHCIyTdn0o3ziacxx2h0COKjx3KUJynuIB/HQBpi6JqQ
shgccc1iGmZSm2CbG2ohM0Cj38Iq9dTYaimBH7m70HPpT6+gf8T8sVxC4kEz
bswr2h5X4anTZzpI22Oqpj5z39sdjrqmowESJnIo4hl9/4LZZ9r0i+mAgGJv
UgA66yTPfWqLof0lyc6EuZlsDB5K7fporqBxerGMUvAfnA8DEZf2yN2VvYUa
Cp1qfHNOoQdlzmcaDPBmh9PtIxqlIg4EOCj8GgU7uCGu7cx5HC+QfAFhbENU
YpDGckaRbacg64qQM2r8H8yl478tDQAA
====

Deleted utils-dev/debug.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Runs the build command with debugging.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Run it
export JAVA_OPTIONS="-zero -agentlib:jdwp=transport=dt_socket,server=y,address=8000"
"$__exedir/../build.sh" "$@"
exit $?

Deleted utils-dev/debughostedlaunch.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Describe this.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Run it
export HOSTED_JAVA_OPTIONS="-zero -agentlib:jdwp=transport=dt_socket,server=y,address=8000"
"$__exedir/hostedlaunch.sh" "$@"
exit $?

Deleted utils-dev/depends.sh.

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
66


































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the dependencies of a project.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Project to get dependencies for
if [ "$#" -le "0" ]
then
	__name="$("$__exedir/projectname.sh")"
else
	__name="$1"
fi

# Recursive
__recursive_deps()
{
	# Convert manifest data
	__md="$(tr '\n' '\v' < \
		"$("$__exedir/projectwhere.sh" "$1")/META-INF/MANIFEST.MF" | \
		sed 's/\v //g' | tr '\v' '\n')"
	
	# Get dependencies
	__pd="$(echo "$__md" | grep -i 'x-squirreljme-depends' |
		sed 's/^[^:]*:[ \t]*//' | sed 's/,/ /g')"
	
	# If this is not cldc-compact, depend on it
	if [ "$1" != "cldc-compact" ]
	then
		echo "cldc-compact"
		
		# Depend on the normal CLDC
		if [ "$1" != "cldc" ]
		then
			echo "cldc"
		fi
	fi
		
	# Add them all
	(for __dep in $__pd
	do
		# That dependency
		echo "$__dep"
		
		# Recursive run
		__recursive_deps "$__dep"
	done) | sort | uniq | while read __line
	do
		echo "$__line"
	done
}

# Run
__recursive_deps "$__name" | sort | uniq

Deleted utils-dev/dependspath.sh.

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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Depends as classpath

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Project to get dependencies for
if [ "$#" -le "0" ]
then
	__name="$("$__exedir/projectname.sh")"
else
	__name="$1"
fi

# Go through them all
__i="0"
"$__exedir/depends.sh" "$__name" | while read __line
do
	# Separator?
	if [ "$__i" -eq "1" ] 
	then
		printf '%s' ":"
	fi
	__i="1"
	
	# Add line
	printf '%s' "bins/$__line.jar"
done
echo ""

Deleted utils-dev/errorprefixes.sh.

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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This shows the list of error prefixes.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Go through all projects
("$__exedir/lsprojects.sh" | sed 's/\/$//g' | while read __project
do
	__man="$__exedir/../$__project/META-INF/MANIFEST.MF"
	if [ -f "$__man" ]
	then
		__err="$(sed \
			'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
			< "$__man" | grep '^X-SQUIRRELJME-ERROR[ \t]*:' |
			sed 's/^X-SQUIRRELJME-ERROR[ \t]*:[ \t]*\([^ \t]*\)[ \t]*/\1/')"
		if [ -n "$__err" ]
		then
			echo "$__err $__project"
		fi
	fi
done) | sort

Deleted utils-dev/genwebdemo.sh.

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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Generates the web demo.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Demo file location
__demo="webdemo.html"

# Build the web demo
if "$__exedir/../build.sh" "webdemo" "$__demo"
then
	# Go to fossil directory
	cd "$__exedir"
	
	# Update
	fossil uv add "$__demo" --as "webdemo.html"

# Failed
else
	# Fail
	echo "Failed to build the web demo."
	exit 1
fi

Deleted utils-dev/githubwikimap.sh.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Maps a file so that it works and links properly in the wiki
# Operates on standard input

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Newlines to vertical tabs so formatting becomes easier
# Split any markdown kind of looking block to its own line
tr '\n' '\v' | sed 's/(\([^)]*\.mkd\))/(\n@@@@\1\n)/g' |
	sed '/^@@@@.*\.mkd$/s/\//@d@/g' |
	sed '/^@@@@.*\.mkd$/s/-/@h@/g' |
	sed '/^@@@@/s/\.mkd//g' |
	sed 's/^@@@@//g' |
	tr -d '\n' |
	tr '\v' '\n'

Deleted utils-dev/githubwikiunversionsync.sh.

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
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





























































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Pushes everything in the fossil unversioned space to the GitHub
# Wiki.
#
# Note that the GitHub Wiki has severe limitations:
#  * Directories just do not exist in any way when it comes to content.
#  * Links to other Wiki pages are in this format: `
#    `developer-notes_@_stephanie-gawroriski_@_2013_@_12_@_22` which refers to
#    that page, so I believe wiki links need to handle that accordingly.
#    I tested it and that works, so any kind of link to a markdown file must
#    for the most part remove the extension and use the slash form.
#
# So to correct for this, the directory separator is mapped to `_@_` so that
# the given information exists and it can easily be remapped back to
# a directory.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Where the working Wiki is stored
__tmp="/tmp/$$"
__cat="/tmp/$$.cat"
__boop="/tmp/$$.boop"

# Need this to better process files
if ! javac -d . "$__exedir/GitHubWikiReformat.java"
then
	echo "Failed to compile Java helper!"
	exit 1
fi

# Clone the Wiki
if ! git clone git@github.com:XerTheSquirrel/SquirrelJME.wiki.git "$__tmp"
then
	echo "Failed to clone the Wiki."
	exit 1
fi

# Map Fossil filename to Git
__fossil_to_git()
{
	if [ "$(basename "$1" .mkd)" = "$1" ]
	then
		echo "$1"
	else
		echo "@@gh@$1" | sed 's/\.mkd$/.md/' | sed 's/\//@d@/g' |
			sed 's/-/@h@/g'
	fi
}

# Map Git filename to Fossil
__git_to_fossil()
{
	if [ "$(basename "$1" .md)" = "$1" ]
	then
		echo "$1"
	else
		echo "$1" | sed 's/\.md$/.mkd/' | sed 's/@d@/\//g' |
			sed 's/@h@/-/g' | sed 's/^@@gh@//g'
	fi
}

# Determine if any files in the git repository need to be deleted
(cd "$__tmp" && git ls-files) | while read __file
do
	# Names are mapped
	__fossilfile="$(__git_to_fossil "$__file")"	
	
	# Need to actually cat the file	since there is no way to check if it is
	# an actual file, an invalid file is just blank
	fossil unversion cat "$__fossilfile" > "$__cat"
	if [ ! -s "$__cat" ]
	then
		echo "Deleting $__file (as $__fossilfile)..."
		if ! (cd "$__tmp" && git rm "$__file")
		then
			echo "Failed to delete file $__file!"
		fi
	fi
done

# Go through the unversioned set of files and add all of the files that exist
fossil unversion ls | while read __file
do
	echo "Storing $__file..."
	
	# Need to map the fossil filename to git
	__gitfile="$(__fossil_to_git "$__file")"	
	
	# The directory needs to exist first!
	mkdir -p $(dirname "$__tmp/$__gitfile")
	mkdir -p $(dirname "$__tmp/$__file")
	fossil unversion cat "$__file" > "$__boop"
	
	echo "Mapping $__file to $__gitfile..."
	
	# If the file is a markdown file then the extensions need to be remapped
	# so everything works, due to GitHub Wiki limitations
	if echo "$__file" | grep '\.mkd$' > /dev/null
	then
		echo "Remapping $__file for GitHub Wiki..."
		java GitHubWikiReformat "$__file" < "$__boop" > "$__tmp/$__gitfile" 
		
		# Make an original copy of it, for record keeping and so it can
		# potentially be reversed
		mv -f -- "$__boop" "$__tmp/$__file"
		
		# Store the original file
		if ! (cd "$__tmp" && git add "$__gitfile")
		then
			echo "Failed to add file $__file (as $__gitfile)!"
		fi
		
	# Otherwise a 1:1 copy
	else
		mv -f -- "$__boop" "$__tmp/$__file" 
	fi
	
	# Add to the changes
	if ! (cd "$__tmp" && git add "$__file")
	then
		echo "Failed to add file $__file (as $__file)!"
	fi 
done

# Commit changes to the repository
if ! (cd "$__tmp" && git commit -v -m "Synchronize Unversion Space" --author "SquirrelJME <nobody@squirreljme.cc>")
then
	echo "Failed to commit!"
fi

# Push changes
if true
then
	if ! (cd "$__tmp" && git push)
	then
		echo "Failed to push!"
	fi
fi

# Cleanup
rm -rf -- "$__tmp"
rm -f -- "$__cat" "$__boop" "$__boop.1" "$__boop.2"



Deleted utils-dev/hacks/AnInterface.jas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; For more information see license.mkd.
; ---------------------------------------------------------------------------

.interface AnInterface
.super java/lang/Object

; Returns an integer
.method public abstract foo()I
.end method


Deleted utils-dev/hacks/BooleanArrayStore.jas.

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
66
67
68




































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------
; Output:
; 1
; 0
; 1
; 0
; 1
; 0
; 1

.class BooleanArrayStore
.super java/lang/Object

; Returns the input boolean value
.method public static main([Ljava/lang/String;)V
	.limit locals 42
	.limit stack 42
	
	; Storing seven values here
	bipush 7			; 7
	istore 2			; -
	
	; Create boolean array
	bipush 100			; 100
	newarray boolean	; boolean[]

	; Load loop count, stop at zero
__loopcheck:
	iload 2				; boolean[], #2
	ifeq __loopend		; boolean[]
	
	; Keep the array on the stack
	dup					; boolean[], boolean[]
	
	; Store temporary into array
	bipush 7			; boolean[], boolean[], 7
	iload 2				; boolean[], boolean[], 7, #2
	bastore				; boolean[]
	
	; Load back from array
	dup					; boolean[], boolean[]
	bipush 7			; boolean[], boolean[], 7
	baload				; boolean[], [7]
	
	; Print
						; boolean[], [7], PrintStream
	getstatic java/lang/System/out Ljava/io/PrintStream;
	swap				; boolean[], PrintStream, [7]
						; boolean[]
	invokevirtual java/io/PrintStream/println(I)V
	
	; Decrement local and jump back to loop then
	iinc 2 -1			; boolean[]
	goto __loopcheck	; boolean[]
__loopend:

	; End
	return
.end method

Deleted utils-dev/hacks/ImplementsAnInterface.jas.

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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; For more information see license.mkd.
; ---------------------------------------------------------------------------

.class ImplementsAnInterface
.super java/lang/Object
.implements AnInterface

.method public <init>()V
	.limit stack 3
	aload 0
	invokespecial java/lang/Object/<init>()V
	return
.end method

; Just returns 42
.method public foo()I
	ldc 42
	ireturn
.end method

Deleted utils-dev/hacks/IntPrimCall.jas.

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303















































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; For more information see license.mkd.
; ---------------------------------------------------------------------------
; This is a test of the virtual machine where methods of all the int-based
; primitive types are passed to methods using wide values rather than
; correctly narrowed ones

.class IntPrimCall
.super java/lang/Object

; Returns the input boolean value
.method public static callBoolean(Z)Z
	iload_0
	invokestatic IntPrimCall/printIntValue(I)V
	iload_0
	ireturn
.end method

; Returns the input byte value
.method public static callByte(B)B
	iload_0
	invokestatic IntPrimCall/printIntValue(I)V
	iload_0
	ireturn
.end method

; Returns the input short value
.method public static callShort(S)S
	iload_0
	invokestatic IntPrimCall/printIntValue(I)V
	iload_0
	ireturn
.end method

; Returns the input char value
.method public static callCharacter(C)C
	iload_0
	invokestatic IntPrimCall/printIntValue(I)V
	iload_0
	ireturn
.end method

; Returns the input int value
.method public static callInteger(I)I
	iload_0
	invokestatic IntPrimCall/printIntValue(I)V
	iload_0
	ireturn
.end method

; Prints an integer value
.method public static printInt(I)V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	iload_0
	invokevirtual java/io/PrintStream/println(I)V
	return
.end method

; Prints an integer value
.method public static printIntValue(I)V
	.limit stack 7
	getstatic java/lang/System/out Ljava/io/PrintStream;
	; object
	
	ldc "<0x%08X>: "
	; object string
	
	ldc 1
	; object string int
	
	anewarray Ljava/lang/Object;
	; object string array
	
	dup
	; object string array array
	
	ldc 0
	; object string array array int
	
	iload_0
	; object string array array int int
	
	invokestatic java/lang/Integer/valueOf(I)Ljava/lang/Integer;
	; object string array array int object
	
	aastore
	; object string array
	
	invokevirtual java/io/PrintStream/printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
	return
.end method

; Prints a string value
.method public static printString(Ljava/lang/String;)V
	.limit stack 3
	getstatic java/lang/System/out Ljava/io/PrintStream;
	dup
	aload_0
	invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
	ldc ":\t"
	invokevirtual java/io/PrintStream/print(Ljava/lang/String;)V
	return
.end method

; Sends very large values to each method and then prints their resulting
; value
.method public static main([Ljava/lang/String;)V
	; Should be enough, despite lots of waste
	.limit stack 42
	
	; Even
	ldc "boo 0xCAFEBABE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABE
	invokestatic IntPrimCall/callBoolean(Z)Z
	invokestatic IntPrimCall/printInt(I)V
	
	; Odd
	ldc "boo 0xCAFEBABF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABF
	invokestatic IntPrimCall/callBoolean(Z)Z
	invokestatic IntPrimCall/printInt(I)V
	
	; Positive unless masked
	ldc "boo 0x7FFFFFFF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFF
	invokestatic IntPrimCall/callBoolean(Z)Z
	invokestatic IntPrimCall/printInt(I)V
	
	; bool-even
	ldc "boo 0x7FFFFFFE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFE
	invokestatic IntPrimCall/callBoolean(Z)Z
	invokestatic IntPrimCall/printInt(I)V
	
	; byte-pos
	ldc "boo 0x7FFFFF7F"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFF7F
	invokestatic IntPrimCall/callBoolean(Z)Z
	invokestatic IntPrimCall/printInt(I)V
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	; Even
	ldc "byt 0xCAFEBABE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABE
	invokestatic IntPrimCall/callByte(B)B
	invokestatic IntPrimCall/printInt(I)V
	
	; Odd
	ldc "byt 0xCAFEBABF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABF
	invokestatic IntPrimCall/callByte(B)B
	invokestatic IntPrimCall/printInt(I)V
	
	; Positive unless masked
	ldc "byt 0x7FFFFFFF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFF
	invokestatic IntPrimCall/callByte(B)B
	invokestatic IntPrimCall/printInt(I)V
	
	; bool-even
	ldc "byt 0x7FFFFFFE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFE
	invokestatic IntPrimCall/callByte(B)B
	invokestatic IntPrimCall/printInt(I)V
	
	; byte-pos
	ldc "byt 0x7FFFFF7F"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFF7F
	invokestatic IntPrimCall/callByte(B)B
	invokestatic IntPrimCall/printInt(I)V
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	; Even
	ldc "sho 0xCAFEBABE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABE
	invokestatic IntPrimCall/callShort(S)S
	invokestatic IntPrimCall/printInt(I)V
	
	; Odd
	ldc "sho 0xCAFEBABF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABF
	invokestatic IntPrimCall/callShort(S)S
	invokestatic IntPrimCall/printInt(I)V
	
	; Positive unless masked
	ldc "sho 0x7FFFFFFF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFF
	invokestatic IntPrimCall/callShort(S)S
	invokestatic IntPrimCall/printInt(I)V
	
	; bool-even
	ldc "sho 0x7FFFFFFE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFE
	invokestatic IntPrimCall/callShort(S)S
	invokestatic IntPrimCall/printInt(I)V
	
	; byte-pos
	ldc "sho 0x7FFFFF7F"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFF7F
	invokestatic IntPrimCall/callShort(S)S
	invokestatic IntPrimCall/printInt(I)V
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	; Even
	ldc "cha 0xCAFEBABE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABE
	invokestatic IntPrimCall/callCharacter(C)C
	invokestatic IntPrimCall/printInt(I)V
	
	; Odd
	ldc "cha 0xCAFEBABF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABF
	invokestatic IntPrimCall/callCharacter(C)C
	invokestatic IntPrimCall/printInt(I)V
	
	; Positive unless masked
	ldc "cha 0x7FFFFFFF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFF
	invokestatic IntPrimCall/callCharacter(C)C
	invokestatic IntPrimCall/printInt(I)V
	
	; bool-even
	ldc "cha 0x7FFFFFFE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFE
	invokestatic IntPrimCall/callCharacter(C)C
	invokestatic IntPrimCall/printInt(I)V
	
	; byte-pos
	ldc "cha 0x7FFFFF7F"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFF7F
	invokestatic IntPrimCall/callCharacter(C)C
	invokestatic IntPrimCall/printInt(I)V
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	; Even
	ldc "int 0xCAFEBABE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABE
	invokestatic IntPrimCall/callInteger(I)I
	invokestatic IntPrimCall/printInt(I)V
	
	; Odd
	ldc "int 0xCAFEBABF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0xCAFEBABF
	invokestatic IntPrimCall/callInteger(I)I
	invokestatic IntPrimCall/printInt(I)V
	
	; Positive unless masked
	ldc "int 0x7FFFFFFF"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFF
	invokestatic IntPrimCall/callInteger(I)I
	invokestatic IntPrimCall/printInt(I)V
	
	; bool-even
	ldc "int 0x7FFFFFFE"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFFFE
	invokestatic IntPrimCall/callInteger(I)I
	invokestatic IntPrimCall/printInt(I)V
	
	; byte-pos
	ldc "int 0x7FFFFF7F"
	invokestatic IntPrimCall/printString(Ljava/lang/String;)V
	ldc 0x7FFFFF7F
	invokestatic IntPrimCall/callInteger(I)I
	invokestatic IntPrimCall/printInt(I)V
	
	return
.end method

Deleted utils-dev/hacks/InterfaceA.jas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.interface InterfaceA
.super java/lang/Object
.implements InterfaceB

Deleted utils-dev/hacks/InterfaceB.jas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14














-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.interface InterfaceB
.super java/lang/Object
.implements InterfaceA

Deleted utils-dev/hacks/InvokeVirtualAnInterface.jas.

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



































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) 2013-2016 Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) 2013-2016 Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; For more information see license.mkd.
; ---------------------------------------------------------------------------

.class InvokeVirtualAnInterface
.super java/lang/Object

.method public static main([Ljava/lang/String;)V
	.limit stack 42
	
	; Needed for later printing
	getstatic java/lang/System/out Ljava/io/PrintStream;
	
	; Create instance of interface thing
	new ImplementsAnInterface
	dup
	invokespecial ImplementsAnInterface/<init>()V
	
	; Get int value
	invokevirtual AnInterface/foo()I
	;invokeinterface AnInterface/foo()I 1
	
	; Print it
	invokevirtual java/io/PrintStream/println(I)V
	
	; Stop
	return
.end method
	

Deleted utils-dev/hacks/LCDUIChoiceInsert.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









































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import javax.microedition.midlet.MIDlet;

import javax.microedition.lcdui.ChoiceGroup;

/**
 * This tests whether insert for choice allows size() or not.
 *
 * @since 2017/08/21
 */
public class LCDUIChoiceInsert
	extends MIDlet
{
	public void destroyApp(boolean __v)
	{
	}
	
	public void startApp()
	{
		ChoiceGroup cg = new ChoiceGroup("Test", ChoiceGroup.EXCLUSIVE);
		
		System.err.println("A");
		cg.insert(cg.size(), "A", null);
		
		System.err.println("B");
		cg.insert(cg.size(), "B", null);
		
		System.err.println("C");
		cg.insert(cg.size() + 1, "C", null);
	}
}

Deleted utils-dev/hacks/SuperA.jas.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperA
.super java/lang/Object

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial java/lang/Object/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperA"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	return
.end method

Deleted utils-dev/hacks/SuperAA.jas.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperAA
.super java/lang/Object

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial java/lang/Object/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperAA"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	return
.end method

Deleted utils-dev/hacks/SuperAB.jas.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class abstract SuperAB
.super SuperAA

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperAA/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperAB"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	return
.end method

Deleted utils-dev/hacks/SuperAC.jas.

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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperAC
.super SuperAB

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperAB/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperAC"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	
	aload_0
	invokespecial SuperAA/foo()V
	return
.end method

.method public static main([Ljava/lang/String;)V
	.limit stack 2
	new SuperAC
	dup
	invokespecial SuperAC/<init>()V
	invokevirtual SuperAC/foo()V
	return
.end method

Deleted utils-dev/hacks/SuperB.jas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22






















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class abstract SuperB
.super SuperA

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperA/<init>()V
	return
.end method

.method public abstract foo()V
.end method

Deleted utils-dev/hacks/SuperBA.jas.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperBA
.super java/lang/Object

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial java/lang/Object/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperBA"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	return
.end method

Deleted utils-dev/hacks/SuperBB.jas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class abstract SuperBB
.super SuperBA

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperBA/<init>()V
	return
.end method

Deleted utils-dev/hacks/SuperBC.jas.

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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperBC
.super SuperBB

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperBB/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperBC"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	
	aload_0
	invokespecial SuperBA/foo()V
	return
.end method

.method public static main([Ljava/lang/String;)V
	.limit stack 2
	new SuperBC
	dup
	invokespecial SuperBC/<init>()V
	invokevirtual SuperBC/foo()V
	return
.end method

Deleted utils-dev/hacks/SuperC.jas.

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








































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class SuperC
.super SuperB

.method public <init>()V
	.limit stack 2
	aload_0
	invokespecial SuperB/<init>()V
	return
.end method

.method public foo()V
	.limit stack 2
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "SuperC"
	invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
	
	aload_0
	invokespecial SuperA/foo()V
	return
.end method

.method public static main([Ljava/lang/String;)V
	.limit stack 2
	new SuperC
	dup
	invokespecial SuperC/<init>()V
	invokevirtual SuperC/foo()V
	return
.end method

Deleted utils-dev/hacks/a/NewProtected.jas.

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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------
; This constructs a/ProtectedConstructorA and b/ProtectedConstructorB to
; see if running works.

.class a/NewProtected
.super java/lang/Object

.method public static main([Ljava/lang/String;)V
	.limit stack 42
	
	; Use new on a protected class in this package
	getstatic java/lang/System/out Ljava/io/PrintStream;
	new a/ProtectedConstructorA
	dup
	invokespecial a/ProtectedConstructorA/<init>()V
	invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
	
	; Use new on a protected class in another package
	getstatic java/lang/System/out Ljava/io/PrintStream;
	new b/ProtectedConstructorB
	dup
	invokespecial b/ProtectedConstructorB/<init>()V
	invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
	
	; Done
	return
.end method

Deleted utils-dev/hacks/a/ProtectedConstructorA.jas.

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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class a/ProtectedConstructorA
.super java/lang/Object

.method protected <init>()V
	.limit stack 3
	
	; Construct
	aload 0
	invokespecial java/lang/Object/<init>()V
	
	; Note
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "Constructor A"
	invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
	
	; Done
	return
.end method

Deleted utils-dev/hacks/b/ProtectedConstructorB.jas.

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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
; -*- Mode: Jasmin; indent-tabs-mode: t; tab-width: 4 -*-
; ---------------------------------------------------------------------------
; Multi-Phasic Applications: SquirrelJME
;     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
;     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
; ---------------------------------------------------------------------------
; SquirrelJME is under the GNU General Public License v3+, or later.
; See license.mkd for licensing and copyright information.
; ---------------------------------------------------------------------------

.class b/ProtectedConstructorB
.super java/lang/Object

.method protected <init>()V
	.limit stack 3
	
	; Construct
	aload 0
	invokespecial java/lang/Object/<init>()V
	
	; Note
	getstatic java/lang/System/out Ljava/io/PrintStream;
	ldc "Constructor B"
	invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
	
	; Done
	return
.end method

Deleted utils-dev/hacks/jadize.sh.

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
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





































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This compiles the specified program and turns it into a JAD.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Check
if [ "$#" -ne "1" ]
then
	echo "Usage: $0 (file.jas/file.java)" 1>&2
	exit 1
fi

# Determine names
__jav="$(basename "$1" .java)"
__jas="$(basename "$1" .jas)"
__bas="$(basename "$(basename "$1" .java)" .jas)"
__cls="$__bas.class"
__jar="$__bas.jar"
__jad="$__bas.jad"

# Compiling Java source?
if [ "$__bas" = "$__jav" ]
then
	# Compile some base SquirrelJME APIs needed to run some of these
	for __api in midp-lcdui
	do
		if ! "$__exedir/../../build.sh" build "$__api"
		then
			echo "Failed to compile API $__api" 1>&2
			exit 5
		fi
	done
	
	# Compile
	if ! javac -source 1.3 -target 1.3 -d "." \
		-cp "$("$__exedir/../binscp.sh")" "$1"
	then
		echo "Failed to compile $1" 1>&2
		exit 4
	fi

# Assembling byte code
elif [ "$__bas" = "$__jas" ]
then
	if ! jasmin -d . "$1" 
	then
		echo "Failed to assemble $1" 1>&2
		exit 3
	fi

# Unknown?
else
	echo "Do not know how to compile $1" 1>&2
	exit 2
fi

# Create manifest
echo "Manifest-Version: 1.0
MIDlet-1: $__bas,,$__bas
MIDlet-Name: $__bas
MIDlet-Vendor: $__bas
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
" > "$__jad"

# Create JAR file
if ! jar cfm "$__jar" "$__jad" "$__cls"
then
	echo "Failed to create JAR $__jar" 1>&2
	exit 6
fi

# Recreate a valid JAD
echo "Manifest-Version: 1.0
MIDlet-1: $__bas,,$__bas
MIDlet-Name: $__bas
MIDlet-Vendor: $__bas
MIDlet-Version: 1.0
MIDlet-Jar-URL: $__jar
MIDlet-Jar-Size: $(stat -c %s "$__jar")
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
" > "$__jad"

# Note
echo "Built $__jar and $__jad" 1>&2
exit 0

Deleted utils-dev/hostedlaunch.sh.

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
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













































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Runs a target project or JAR in a hosted environment.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# May be replaced
: ${JAVA:=java}

__print_usage()
{
	echo "Usage: $0 [-w] [-p #] (project[:#]|file.jar)" 1>&2
	echo "" 1>&2
	echo "  [-w]   Run with Wine instead" 1>&2
	echo "  [-p #] Can be 0 or greater to specify that an alternative" 1>&2
	echo "         application be used for a given program." 1>&2
}

# Usage
if [ "$#" -lt 1 ]
then
	__print_usage
	exit 1
fi

# Parse arguments
__javacmd="$JAVA"
__sepchar=":"
__numb=-1
while getopts wp: __opt
do
	case "$__opt" in
		w)
			__javacmd="$__exedir/winejava.sh"
			__sepchar=";"
			;;
		
		p)
			__numb="$OPTARG"
			;;
		
		*)
			__print_usage
			exit 1
			;;
	esac
done

# Done
shift $(($OPTIND - 1))

# File is the first one
__file="$1"
shift

__proj="$(basename "$__file" .jar | sed 's/:[0-9]\{1,\}$//')"

# The file to run
if [ -f "$__file" ]
then
	__run="$__file"
elif [ -f "bins/bbld/$__proj.jar" ]
then
	__run="bins/bbld/$__proj.jar"
else
	__run="$__file"
fi

# Attempt building it if it has not been detected to be a normal JAR but a
# standard project
if [ ! -f "$__file" ]
then
	if ! "$__exedir/../build.sh" build -b "$__proj"
	then
		echo "Could not build $__proj." 1>&2
		exit 1
	fi

# Build these projects because they are standard and may be relied upon for
# running a given file
else
	for __maybe in midp-lcdui meep-rms media-api
	do
		if ! "$__exedir/../build.sh" build -b "$__maybe"
		then
			echo "Failed to build $__maybe" 1>&2
			exit 1
		fi
	done
fi

# Generates classpath
__gen_classpath()
{
	__rv=""
	
	# Prepend target if it exists
	if [ -f "$1" ]
	then
		__rv="$1"
	fi
	
	# Build classpath
	for __jar in sjmeboot.jar bins/bbld/*.jar
	do
		if [ "$__rv" != "" ]
		then
			__rv="$__rv$__sepchar"
		fi
		
		# Append
		__rv="$__rv$__jar"
	done
	
	# Use it
	echo "$__rv"
}

# Run the JVM with the bootstrap followed
__main="$("$__exedir/mainclass.sh" "$__run")"
"$__javacmd" -classpath "$(__gen_classpath "$__run")" \
	$HOSTED_JAVA_OPTIONS \
	$JAVA_OPTIONS \
	"-Dcc.squirreljme.builder.root=$__exedir/.." \
	"-Dcc.squirreljme.runtime.javase.servermain=$__main" \
	"-Dcc.squirreljme.runtime.javase.program=$__numb" \
	"-Dcc.squirreljme.runtime.javase.file=$__file" \
	cc.squirreljme.runtime.javase.Main "$@"
exit $?

Deleted utils-dev/listerror.sh.

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





















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This scans all source files for special JavaDoc tags which
# describe what the error codes mean.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Allow a custom directory to be specified
if [ "$#" -ge "1" ]
then
	__dir="$1"
else
	__dir="$(pwd)"
fi

# Get the directory of the project
__base="$("$__exedir/projectbase.sh" "$__dir")"

# Print error code, potentially
echo "******** LIST OF ERRORS *********" 1>&2
if [ -f "$__base/META-INF/MANIFEST.MF" ]
then
	__code="$(grep -i 'x-squirreljme-error' < "$__base/META-INF/MANIFEST.MF" |
		cut -d ':' -f 2 | tr -d ' ')"
	
	echo "Project Error Code: $__code" 1>&2
fi

# List errors
(grep -rl '{@squirreljme\.error[ \t]\{1,\}....' "$__base" | \
	grep -e '\.java$' -e '\.c$' -e '\.h$' | while read __file
do
	tr '\n' '\f' < "$__file" | sed 's/{@code[ \t]\{1,\}\([^}]*\)}/\1/g' |
		sed 's/{@squirreljme\.error[ \t]\{1,\}\([^}]*\)}/\v##ER \1 ##FI\v/g' |
		sed 's/\/\///g' | sed 's/\/\*//g' | tr '\v' '\n' |
		grep '##ER' | sed 's/^##ER[ \t]*//g' |
		sed 's/##FI/<'"$(basename $__file)"'>/g' |
		sed 's/\f[ \t]*\*[ \t]*/ /g' |
		tr '\f' ' '| sed 's/[ \t\f]\{2,\}/ /g'
done) | sort | uniq
echo "*********************************" 1>&2

Deleted utils-dev/longclass.sh.

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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This takes a file and determines the name of the class in its
# full form.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

while [ "$#" -ge "1" ]
do
	echo "$("$__exedir/packageidentifier.sh" "$1").$(
		basename -- "$1" .java)"
	
	# Handle more arguments
	shift
done

Deleted utils-dev/longclasses.sh.

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
































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This scans the directory tree for classes which are really
# long and have really long names, it will list them all.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

find "$__exedir/.." -type f | grep '\.java$' | while read __file
do
	__classname="$("$__exedir/longclass.sh" "$__file")"
	__charlen="$(printf '%s' "$__classname" | wc -c)"
	
	# SquirrelJME forces 79 columns, so this means
	# "import ;" causes a loss of 8 from 79, so characters cannot exceed
	# 71, otherwise it is too long. But for consistency this will be 70
	if [ "$__charlen" -ge "70" ]
	then
		echo "$__classname ($__charlen) <$("$__exedir/projectname.sh" "$__file")>"
	fi
done

Deleted utils-dev/lsall.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: List all files in all namespaces

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Find files in all namespaces
for __ns in $("$__exedir/lsnamespaces.sh")
do
	find "$__exedir/../$__ns" -type f
done

Deleted utils-dev/lsnamespaces.sh.

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










































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This lists the namespaces which are available

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Allow a custom root to be specified
if [ "$#" -ge "1" ]
then
	__root="$1"
else
	__root="$__exedir/.."
fi

# Old SquirrelJME layout which appears before x-date-201611
if [ -d "$__root/src" ]
then
	echo "src"
	
# Modern SquirrelJME
else
	# Scan every directory for namespaces
	(find "$__root" -type d | while read __dir
	do
		if [ -f "$__dir/NAMESPACE.MF" ]
		then
			"$__exedir/relative.sh" "$__root" "$__dir"
		fi
	done) | sort
fi

Deleted utils-dev/lsprojects.sh.

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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: List all relative projects from the base of the source code.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Allow a custom root to be specified
if [ "$#" -ge "1" ]
then
	__root="$1"
else
	__root="$__exedir/.."
fi

# Go through all namespaces
("$__exedir/lsnamespaces.sh" "$__root" | while read __dir
do
	# And directories within the namespaces
	for __file in "$__root/$__dir/"*
	do
		# Ignore non-directories
		if [ ! -d "$__file" ]
		then
			continue
		fi
		
		# If there is a project here, print that directory
		if [ -f "$__file/META-INF/MANIFEST.MF" ] ||
			[ -f "$__file/META-INF/TEST.MF" ]
		then
			"$__exedir/relative.sh" "$__root" "$__file"
		fi
	done
done) | sort

Deleted utils-dev/mainclass.sh.

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














































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the main class for a project.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Print program usage
if [ "$#" -lt "1" ]
then
	echo "Usage: $0 [program]" 1>&2
	exit 1
fi

(if [ -f "$1" ]
then
	unzip -p "$1" META-INF/MANIFEST.MF
else
	__base="$("$__exedir/projectwhere.sh" "$1")"
	if [ -f "$__base/META-INF/TEST.MF" ]
	then
		echo "Main-Class: cc.squirreljme.tests._$(basename -- "$__base" .test |
			sed 's/-/_/g').MainTest"
	else
		cat "$__base/META-INF/MANIFEST.MF"
	fi
fi ) | tr -d '\r' | tr '\n' '|' | sed 's/| //g' | tr '|' '\n' | \
	while read __line
do
	echo "$__line" | grep -i '^ *main-class' | cut -d ':' -f 2 | \
		sed 's/^ *//g;s/ *$//g'
	echo "$__line" | grep -i '^ *midlet-1' | cut -d ':' -f 2 | \
		cut -d ',' -f 3 | sed 's/^ *//g;s/ *$//g'
done | sort | head -n 1


Deleted utils-dev/namespacebase.sh.

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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the base directory of a namespace.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Get the base to use
if [ "$#" -eq "0" ]
then
	__base="$(pwd)"
else
	__base="$1"
fi

# Keep adding .. until the version identifier is found
# Include two sets of .. in the event that we are in a given namespace
# Also try others since we may be in the namespace root.
while true
do
	__base="$("$__exedir/absolute.sh" "$__base")"
	
	# Find the manifest for a project
	__above="$("$__exedir/absolute.sh" "$__base/../")"
	if [ -f "$__base/NAMESPACE.MF" ] ||
		[ -f "$__above/TIMESPACE.MF" ] ||
		[ -f "$__above/squirreljme-version" ] ||
		[ -f "$__base/squirreljme-version" ] ||
		[ "$__base" = "/" ]
	then
		echo "$__base"
		break
	fi
	
	# Otherwise go up
	__base="$__base/.."
done

Deleted utils-dev/namespacename.sh.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the name of the namespace.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Target a given directory or not
if [ "$#" -eq "0" ]
then
	__dir="$(pwd)"
else
	__dir="$1"
fi

# The namespace name is the last component of the base directory
"$__exedir/namespacebase.sh" "$__dir" | sed 's/.*\/\(.*\)$/\1/'

Deleted utils-dev/nexterror.sh.

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
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























































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Find the next error code that is available.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Letter to number
__letter_to_number()
{
	case "$1" in
		A) __num="0";;
		B) __num="1";;
		C) __num="2";;
		D) __num="3";;
		E) __num="4";;
		F) __num="5";;
		G) __num="6";;
		H) __num="7";;
		I) __num="8";;
		J) __num="9";;
		K) __num="10";;
		L) __num="11";;
		M) __num="12";;
		N) __num="13";;
		O) __num="14";;
		P) __num="15";;
		Q) __num="16";;
		R) __num="17";;
		S) __num="18";;
		T) __num="19";;
		U) __num="20";;
		V) __num="21";;
		W) __num="22";;
		X) __num="23";;
		Y) __num="24";;
		Z) __num="25";;
		*) __num="0";;
	esac
	
	# Print it
	echo "$__num"
}

# Converts a number to a letter
__number_to_letter()
{
	case "$1" in
		0) __let="A";;
		1) __let="B";;
		2) __let="C";;
		3) __let="D";;
		4) __let="E";;
		5) __let="F";;
		6) __let="G";;
		7) __let="H";;
		8) __let="I";;
		9) __let="J";;
		10) __let="K";;
		11) __let="L";;
		12) __let="M";;
		13) __let="N";;
		14) __let="O";;
		15) __let="P";;
		16) __let="Q";;
		17) __let="R";;
		18) __let="S";;
		19) __let="T";;
		20) __let="U";;
		21) __let="V";;
		22) __let="W";;
		23) __let="X";;
		24) __let="Y";;
		25) __let="Z";;
		*) __num="A";;
	esac
	
	# Print it
	echo "$__let"
}

# Letter pair to number
__pair_to_number()
{
	__a="$(echo "$1" | cut -c 1)"
	__b="$(echo "$1" | cut -c 2)"
	
	# Convert
	expr $(expr "$(__letter_to_number $__a)" '*' "26") '+' \
		"$(__letter_to_number $__b)"
}

# Pair to number
__number_to_pair()
{
	__hi="$(expr "$1" / 26)"
	__lo="$(expr "$1" % 26)"
	
	# Convert
	echo "$(__number_to_letter $__hi)$(__number_to_letter $__lo)"
}

# Prefixes with banned prefixes
__prefixes()
{
	# Print banned ones
	echo "AN banned"
	echo "AS banned"
	echo "BJ banned"
	echo "BS banned"
	echo "FC banned"
	echo "FK banned"
	echo "FU banned"
	echo "NB banned"
	
	# Reserved for user usage
	echo "UA reserved"
	echo "UB reserved"
	echo "UC reserved"
	echo "UD reserved"
	echo "UE reserved"
	echo "UF reserved"
	echo "UG reserved"
	echo "UH reserved"
	echo "UI reserved"
	echo "UJ reserved"
	echo "UK reserved"
	echo "UL reserved"
	echo "UM reserved"
	echo "UN reserved"
	echo "UO reserved"
	echo "UP reserved"
	echo "UQ reserved"
	echo "UR reserved"
	echo "US reserved"
	echo "UT reserved"
	echo "UU reserved"
	echo "UV reserved"
	echo "UW reserved"
	echo "UX reserved"
	echo "UY reserved"
	echo "UZ reserved"
	
	# Print normals
	"$__exedir/errorprefixes.sh"
}

# The last number used
__last="0"

# Go through error code list
__prefixes | sort | while read __line
do
	# Get code and extract number from it
	__code="$(echo "$__line" | cut -d ' ' -f 1)"
	__numb="$(__pair_to_number $__code)"
	
	echo "$__numb"
done | while read __number
do
	# Difference between this number and the last
	__diff="$(expr "$__number" - "$__last")"	
	__was="$__last"
	__last="$__number"
	
	# If the difference is at least 2 then there is a free slot after the last
	if [ "$__diff" -ge "2" ]
	then
		__number_to_pair "$(expr "$__was" + 1)"
		break
	fi
done

Changes to utils-dev/old/NewManifest.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
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










-
-
+
+
-


-





+







// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.io.InputStream;
import java.io.IOException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.jar.Manifest;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Objects;
import java.util.TreeMap;
import java.util.jar.Manifest;

/**
 * This translates from the old manifest format to the new manifest format.
 *
 * @since 2016/10/22
 */
public class NewManifest

Deleted utils-dev/packageidentifier.sh.

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
66
67
68
69
70
71







































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This returns the identifier of the package a path is in.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Get the base to use
if [ "$#" -eq "0" ]
then
	__dir="$(pwd)"
else
	__dir="$1"
fi

# Java files could be passed and the script is not really that smart enough
# to know if a passed input was really a directory or just a file, so just
# for the most part try to guess
__fn="$(basename -- "$__dir")"
if echo "$__fn" | grep -e '\.java$' -e '\.class$' -e '\.jas$' -e '\.j$' > /dev/null
then
	__dir="$__dir/.."
fi

# Build the package by continually going up until the target directory was
# reached
__base="$("$__exedir/projectbase.sh" "$__dir")"
__at="$("$__exedir/absolute.sh" "$__dir")"
__result=""
while true
do
	# Make sure it is always absolute
	__at="$("$__exedir/absolute.sh" "$__at")"
	
	# Stop if the base was reached
	if [ "$__base" -ef "$__at" ]
	then	
		break
	fi
	
	# Need to prefix with dot?
	if [ ! -z "$__result" ]
	then
		__result=".$__result"
	fi
	
	# Get the base and append it to the root
	__result="$(echo "$__at" | sed 's/.*\/\(.*\)$/\1/')$__result"
	
	# Go back up
	__at="$__at/.."
done

# Always make sure the package is valid somewhat
if [ -z "$__result" ]
then
	echo "unknown.package"
else
	echo "$__result"
fi

Deleted utils-dev/packagepath.sh.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This returns the directory based form for a package.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Target a given directory or not
if [ "$#" -eq "0" ]
then
	__dir="$(pwd)"
else
	__dir="$1"
fi

# Same as the package identifier but with dots instead
"$__exedir/packageidentifier.sh" "$__dir" | tr '.' '/'

Deleted utils-dev/practice/mips-32+i,big.linux.generic.zip.uue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 mips-32+i,big.linux.generic.zip
UEsDBBQAAAAIAPiWBkkLV9KzPQEAAMwRAAAFABwAaGVsbG9VVAkAA/Nqplfz
aqZXdXgLAAEE6AMAAAToAwAA7ZjPSsNAEMa/TdO0qNDQU/EUMQf1sF566EEw
HhSFCkKfIKFpDISmJhvw5iv4CoK+ga/mue5utjWNJ8Hj/GDyZWa+yZ89zsv1
9IZZDFss9OWVIcBI6hhwP3V9DA8dnKAHZwV5BxfSUwe0V4Uto57f7U9MdHW9
7k8QmACGJhzTJwiCIAiCIAiCIAjiX2FgDKxd9W2wiy4C/8Od+A6GvjV4l+UD
qW9Kb+Msy73ZU5UWRZyVR3v1mPj1+OA1uJIySJaVfkvPZuDlYykKEUbg93cP
Mx5G6SILkxK8iJN0ucjBRfwswOehCMHlKA+FKNKoEnH5p5/bXwFnUFuNQKV6
tzBq9PsmP1zp3YP6XpW705bP1gcFHBt1jE95vJZPcWp8nXq/sd1xbNic93m+
Xn/9lN05dhcgrKGdhk+d82Xb9w1QSwMEFAAAAAgA+JYGSXBXTuRwAAAAmgAA
AAcAHABoZWxsby5zVVQJAAPzaqZX82qmV3V4CwABBOgDAAAE6AMAANNLSSxJ
5OLMSM3JyS8uKcrMS7fi1EssTs7MrFJQ8gCJKgQXlmYWFaXmFCvG5ClxcemV
pFaUcHHlJmbmWXFx5iQqqCQa6CgYQpmGOgpIZkEFjYDyFkB2poJKGVCtiYGB
CRdncWVxcmJODheKuCFCHABQSwECHgMUAAAACAD4lgZJC1fSsz0BAADMEQAA
BQAYAAAAAAAAAAAA7YEAAAAAaGVsbG9VVAUAA/Nqpld1eAsAAQToAwAABOgD
AABQSwECHgMUAAAACAD4lgZJcFdO5HAAAACaAAAABwAYAAAAAAABAAAApIF8
AQAAaGVsbG8uc1VUBQAD82qmV3V4CwABBOgDAAAE6AMAAFBLBQYAAAAAAgAC
AJgAAAAtAgAAAAA=
====

Deleted utils-dev/practice/mips-32+i,little.linux.generic.zip.uue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
begin-base64 644 mips-32+i,little.linux.generic.zip
UEsDBBQAAAAIAG+XBkkO9Yy41wAAANgBAAAFABwAaGVsbG9VVAkAA9Frplek
bKZXdXgLAAEE6AMAAAToAwAAq3f1cWNkZGSAASYGDgYQbwODA4MJkBYAcQQY
gGwFBmYGDQZWBhaQsoIpQGIKUA0ISwDZIMwCxQjTHMD4ApAEYVawGCNYHiLm
CMYKQDYIs0HlSxgwwYMGR6gsi4ojA6vNBYalKkIMbCpL+JlUeIDiC6G0R2pO
Tr5CcGFpZlFRak6xIhe6QXrFGcUlRSWJSQx6RanpmXlp+Qx6JakVJQx6KYkl
iVhsxg64Ie4tYIKHAyQMYIAFyheBhgcbNEw3QP0KAwJQWgqqjhkeLtjVwdTA
wAc0dbCwBwBQSwMEFAAAAAgA+JYGSXBXTuRwAAAAmgAAAAcAHABoZWxsby5z
VVQJAAPzaqZX82qmV3V4CwABBOgDAAAE6AMAANNLSSxJ5OLMSM3JyS8uKcrM
S7fi1EssTs7MrFJQ8gCJKgQXlmYWFaXmFCvG5ClxcemVpFaUcHHlJmbmWXFx
5iQqqCQa6CgYQpmGOgpIZkEFjYDyFkB2poJKGVCtiYGBCRdncWVxcmJODheK
uCFCHABQSwECHgMUAAAACABvlwZJDvWMuNcAAADYAQAABQAYAAAAAAAAAAAA
7YEAAAAAaGVsbG9VVAUAA9Frpld1eAsAAQToAwAABOgDAABQSwECHgMUAAAA
CAD4lgZJcFdO5HAAAACaAAAABwAYAAAAAAABAAAApIEWAQAAaGVsbG8uc1VU
BQAD82qmV3V4CwABBOgDAAAE6AMAAFBLBQYAAAAAAgACAJgAAADHAQAAAAA=
====

Deleted utils-dev/practice/practice.mkd.

1
2
3
4
5
6






-
-
-
-
-
-
# Practice Binary ZIPs

This directory contains very minimal and simple binaries which are to
be used on the target system to test the initial setup of the
emulator. These binaries should be in ZIPs and be as simple as
possible. All executables should be named `hello`.

Deleted utils-dev/prefixerrortoproject.sh.

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




































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Gets the project name from the error prefix.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

if [ "$#" -ne "1" ]
then
	echo "Usage: $0 (prefix)" 1>&2
	exit 1
fi

# Go through prefixes and try to find it
"$__exedir/errorprefixes.sh" | while read __line
do
	__co="$(echo "$__line" | cut -d ' ' -f 1)"
	__pr="$(echo "$__line" | cut -d ' ' -f 2)"
	
	if [ "$__co" = "$1" ]
	then
		echo "$__pr"
		break
	fi
done

Deleted utils-dev/projectbase.sh.

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















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Gets the base of the current project

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Get the base to use
if [ "$#" -eq "0" ]
then
	__base="$(pwd)"
else
	__base="$1"
fi

# Keep adding .. until the version identifier is found
# Include two sets of .. in the event that we are in a given project
# Also try others since we may be in the project root.
while true
do
	__base="$("$__exedir/absolute.sh" "$__base")"
	
	# Find the manifest for a project
	if [ -f "$__base/META-INF/MANIFEST.MF" ] ||
		[ -f "$__base/META-INF/TEST.MF" ] ||
		[ -f "$("$__exedir/absolute.sh" "$__base/../NAMESPACE.MF")" ] ||
		[ -f "$__base/squirreljme-version" ] ||
		[ "$__base" = "/" ]
	then
		echo "$__base"
		break
	fi
	
	# Otherwise go up
	__base="$__base/.."
done

Deleted utils-dev/projectname.sh.

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




























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the name of a project.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Target a given directory or not
if [ "$#" -eq "0" ]
then
	__dir="$(pwd)"
else
	__dir="$1"
fi

# The project name is the last component of the base directory
"$__exedir/projectbase.sh" "$__dir" | sed 's/.*\/\(.*\)$/\1/'

Deleted utils-dev/projectuuid.sh.

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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This returns the UUID of the specified project, this is used
# to keep track of which projects were just renames and such and which ones
# are new.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Project to get dependencies for
if [ "$#" -le "0" ]
then
	__now="$(pwd)"
else
	__now="$1"
fi

# Get the base of the project
__base="$("$__exedir/projectbase.sh" "$__now")"


# Go through the manifest which can contain multiple fields for the UUID
# since the field has changed throughout the project
if [ -f "$__base/META-INF/MANIFEST.MF" ]
then
	# Determine Default fallback UUID
	__defl="00000000-0000-0000-0000-$(fossil sha1sum - < \
		"$__base/META-INF/MANIFEST.MF" | cut -c 1-12)"
	
	# Get sum
	echo "X-SquirrelJME-UUID:$__defl" | cat "$__base/META-INF/MANIFEST.MF" - |
	grep -i -e 'X-Hairball-UUID' -e 'X-SquirrelJME-UUID' | \
		cut -d ':' -f 2 | head -n 1 | tr -d ' '

# Not known othewise
else
	echo "00000000-0000-0000-0000-000000000000"
fi



Deleted utils-dev/projectwhere.sh.

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



















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Returns the path where the project is located

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Project to get path for
if [ "$#" -le "0" ]
then
	__name="$("$__exedir/projectname.sh")"
else
	__name="$1"
fi

# Non-name test
__ntname="$(basename -- "$__name" ".test")"

# Go through all namespaces
for __ns in $("$__exedir/lsnamespaces.sh")
do
	# Ignore build
	if [ "$__ns" = "build" ]
	then
		continue
	fi
	
	# Try to find exact project name
	__try="$__exedir/../$__ns/$__name"
	__tst="$__exedir/../$__ns/$__ntname"
	if [ -f "$__try/META-INF/MANIFEST.MF" ] ||
		[ -f "$__try/META-INF/TEST.MF" ]
	then
		echo "$__try"
		exit 0
	fi
done

# Not found
exit 1

Deleted utils-dev/qemuize.sh.

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

















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Likely a Linux only script, run the build to a given ZIP then
# extract it and try running it.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# If no arguments were pass then pass no arguments so that the target list
# and help text is printed
if [ "$#" -eq "0" ]
then
	"$__exedir/../build.sh"
	exit $?
fi

# Perform the build and run it
rm -f "$$.zip"
__jo="$JAVA_OPTIONS"
if JAVA_OPTIONS="-Dcc.squirreljme.builder.dumptarget=true \
	-Dcc.squirreljme.builder.hexdump=true $__jo" \
	"$__exedir/../build.sh" "$@" "$$.zip"
then
	# Unzip then delete the ZIP
	unzip -o "$$.zip" squirreljme
	rm -f "$$.zip"
	
	# Run it
	ls -alh squirreljme
	chmod +x squirreljme
	./squirreljme
	exit $?
else
	# Failed, so fail
	rm -f "$$.zip"
	echo "Failed build..."
	exit 1
fi

Deleted utils-dev/reordererrors.sh.

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





































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This runs the error reordering script.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Need to compile the program
__cls="ReorderErrors"
__src="$__exedir/$__cls.java"
__odr="/tmp"
__out="$__odr/$__cls.class"

# Need to compile?
if [ ! -f "$__out" ] || [ "$__src" -nt "$__out" ]
then
	if ! javac -d "$__odr" "$__src"
	then
		echo "Failed to compile"
		exit 1
	fi
fi

# Execute it
java -classpath "$__odr" "$__cls" "$@"
exit $?

Deleted utils-dev/reportdoc.sh.

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
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


















































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Builds the port index.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

(for __file in *__dev.mkd *__user.mkd
do
	# Must exist
	if [ ! -f "$__file" ]
	then
		continue
	fi
	
	# Get the base before the user or developer marker
	__base="$(echo "$__file" | sed 's/^\(.*\)__[a-zA-Z]*\.mkd$/\1/g')"
	__type="$(echo "$__file" | sed 's/^.*__\([a-zA-Z]*\)\.mkd$/\1/g')"
	
	# Dot form of it
	__dots="$(echo "$__base" | sed 'y/_/./')"
	
	# Extract bits
	__arch="$(echo "$__dots" | cut -d '.' -f 1)"
	__name="$(echo "$__dots" | cut -d '.' -f 2)"
	__vari="$(echo "$__dots" | cut -d '.' -f 3)"
	
	# Rename generic arch so it is first
	if [ "$__arch" = "generic" ]
	then
		__arch="000generic"
	fi
	
	# Rename user so it is first
	if [ "$__type" = "user" ]
	then
		__type="000user"
	fi
	
	# output
	echo "$__arch.$__name.$__vari.$__type"
done) | sort | while read __line
do
	# Extract bits
	__arch="$(echo "$__line" | cut -d '.' -f 1)"
	__name="$(echo "$__line" | cut -d '.' -f 2)"
	__vari="$(echo "$__line" | cut -d '.' -f 3)"
	__type="$(echo "$__line" | cut -d '.' -f 4)"
	
	# Change generic back
	if [ "$__arch" = "000generic" ]
	then
		__arch="generic"
	fi
	
	# Revert user
	if [ "$__type" = "000user" ]
	then
		__type="user"
	fi
	
	# Repass
	echo "$__arch.$__name.$__vari.$__type"
done | while read __line
do
	# Extract bits
	__arch="$(echo "$__line" | cut -d '.' -f 1)"
	__name="$(echo "$__line" | cut -d '.' -f 2)"
	__vari="$(echo "$__line" | cut -d '.' -f 3)"
	__type="$(echo "$__line" | cut -d '.' -f 4)"
	
	# Split triplet
	__trip="$__arch.$__name.$__vari"
	
	# The base file form
	__xfil="${__arch}_${__name}_${__vari}"
	
	# Change generic to an asterisk to represent any
	if [ "$__arch" = "generic" ]
	then
		__disarch="*"
	else
		__disarch="$__arch"
	fi
	
	# New header
	if [ "$__last" != "$__trip" ]
	then
		echo " * _$__disarch.$__name.${__vari}_"
		__last="$__trip"
	fi
	
	# Depends on the type
	case "$__type" in
		"dev")
			echo "   * [Developer](${__xfil}__dev.mkd)"
			;;
		
		"user")
			echo "   * [User](${__xfil}__user.mkd)"
			;;
	esac
done

Deleted utils-dev/simjvm.c.

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
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







































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* ---------------------------------------------------------------------------
// 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.
// --------------------------------------------------------------------------*/

/**
 * Simulated Java Virtual Machine.
 *
 * @since 2019/09/02
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define _DEBUG

/**
 * Arguments which modify the starting state of the JVM.
 *
 * @since 2019/09/29
 */
typedef struct simjvm_arguments
{
} simjvm_arguments;

/**
 * Processes the command line arguments used to start the JVM.
 *
 * @param out Output arguments.
 * @param argc Argument count.
 * @param argv Argument strings.
 * @since 2019/09/29
 */
int simjvm_initialize_arguments(simjvm_arguments* out, int argc, char** argv)
{
	int i, filemode;
	char* arg;
	char* next;
	
	/* The pointer must be valid! */
	if (out == NULL || argv == NULL)
		return 1;
	
	/* Starts not in file mode. */
	filemode = 0;
	
	/* Go through all arguments, first skipped because executable. */
	for (i = 1; i < argc; i++)
	{
		/* Get this argument and the next. */
		arg = argv[i];
		next = (i + 1 < argc ? argv[i + 1] : NULL);
		
		/* Print it for debug. */
		fprintf(stderr, "DEBUG: %s\n", arg);
		
		fprintf(stderr, "TODO!\n");
		exit(EXIT_FAILURE);
	}
	
	return 1;
}

/**
 * Main entry point.
 *
 * @param argc Argument count.
 * @param argv Argument strings.
 * @since 2019/09/02
 */
int main(int argc, char** argv)
{
	simjvm_arguments jvmargs;
	
	/* Show welcome message. */
	fprintf(stderr, "SquirrelJME Simulated JVM 0.1\n");
	fprintf(stderr, "Copyright (C) 2019 Stephanie Gawroriski\n");
	fprintf(stderr, "https://squirreljme.cc/\n");
	fprintf(stderr, "\n");
	
	/* Show a warning message why this JVM is being used instead. */
	fprintf(stderr, "This virtual machine is being used to bootstrap the ");
	fprintf(stderr, "build of SquirrelJME because a Java run-time has not ");
	fprintf(stderr, "detected on the host machine or one which was not ");
	fprintf(stderr, "elected to be used. The purpose of this Simulated JVM ");
	fprintf(stderr, "is to allow for building SquirrelJME on any system.\n");
	fprintf(stderr, "\n");
	
	/* Process arguments. */
	memset(&jvmargs, 0, sizeof(jvmargs));
	if (simjvm_initialize_arguments(&jvmargs, argc, argv) != 0)
	{
		fprintf(stderr, "Could not parse arguments!\n");
		return EXIT_FAILURE;
	}
	
	fprintf(stderr, "TODO!\n");
	return EXIT_FAILURE;
}

Deleted utils-dev/sxp.sh.

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
66
67
68
69
70






































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------
# DESCRIPTION: This creates a PNG image from a text output, so it can be drawn
# into and such.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Calculate hosted launch script location
__hosted="$("$__exedir/absolute.sh" "$__exedir/hostedlaunch.sh")"

# Go to temp dir
__tempdir="/tmp/sx"
if [ ! -d "$__tempdir" ]
then
	mkdir -p "$__tempdir"
fi
cd "$__tempdir"

# Arguments
__pkg="$1"
__cls="$2"

# All methods or a single one?
if [ "$#" -eq "3" ]
then
	__mth=""
	__out="$3"
else
	__mth="$3"
	__out="$4"
fi

# Execute handler, export file first
if "$__hosted" sxs "$__pkg" "$__cls" "$__mth" > "/tmp/$$"
then
	# Then convert it to a PBM
	if "$__hosted" txt-to-pbm "/tmp/$$" > "/tmp/$$.pbm"
	then
		if which pnmtopng > /dev/null
		then
			# Scale it
			pnmscale 2 "/tmp/$$.pbm" > "/tmp/$$.pbm.2"
			mv -f "/tmp/$$.pbm.2" "/tmp/$$.pbm"
			
			# Convert
			pnmtopng "/tmp/$$.pbm" > "$__out"
			
			# Cleanup
			rm -f "/tmp/$$.pbm"
		else
			mv -f "/tmp/$$.pbm" "$__out"
		fi
	else
		# Cleanup
		rm -f "/tmp/$$.pbm"
	fi
fi

# Cleanup
rm -f "/tmp/$$"

Deleted utils-dev/sxs.sh.

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





























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------
# DESCRIPTION: This quickly and easily launches the side by side debug.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Calculate hosted launch script location
__hosted="$("$__exedir/absolute.sh" "$__exedir/hostedlaunch.sh")"

# Go to temp dir
__tempdir="/tmp/sx"
if [ ! -d "$__tempdir" ]
then
	mkdir -p "$__tempdir"
fi
cd "$__tempdir"

# Execute handler
"$__hosted" sxs "$@"

Deleted utils-dev/tagslist.

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



























-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
x-date-201603
x-date-201604
x-date-201605
x-date-201606
x-date-201607
x-date-201608
x-date-201609
x-date-201610
x-date-201611
x-date-201612
x-date-201701
x-date-201702
x-date-201703
x-date-201704
x-date-201705
x-date-201706
x-date-201707
x-date-201708
x-date-201709
x-date-201710
x-date-201711
x-date-201712
x-date-201801
x-date-201802
x-date-201803
x-date-201804
trunk

Changes to utils-dev/test/WeightedDownsample.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
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











-


-
-
+
+






-







// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

import java.awt.Color;
import java.awt.color.ColorSpace;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Graphics2D;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

Deleted utils-dev/todocount.sh.

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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Counts the number of TODOs in the current project

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Allow a custom directory to be specified
if [ "$#" -ge "1" ]
then
	__dir="$1"
else
	__dir="$(pwd)"
fi

# Get the directory of the project
__base="$("$__exedir/projectbase.sh" "$__dir")"

# Keep counts of everything per project
find "$__base" -type f | while read __file
do
	grep -c -e 'todo\.TODO' -e 'Error("TODO")' "$__file"
done | datamash -t ' ' sum 1

Deleted utils-dev/todoprogression.sh.

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

































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: This counts the progression of TODO statements across the
# entire project over the course of the project.
#
# This detects:
#  * 'new Error("TODO")'
#  * 'new todo.TODO()'

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Requires the FUSE root
if [ "$#" -le "0" ]
then
	echo "Usage: $0 [Fossil Fuse Root]"
	exit 1
fi

# Need to compile the program
__cls="TodoProgression"
__src="$__exedir/$__cls.java"
__odr="/tmp"
__out="$__odr/$__cls.class"

# Need to compile?
if [ ! -f "$__out" ] || [ "$__src" -nt "$__out" ]
then
	if ! javac -d "$__odr" "$__src"
	then
		echo "Failed to compile"
		exit 1
	fi
fi

# The root where fuse projects are
__fuse="$1"

# Go through the tag list to get the tags to check for progression
cat "$__exedir/tagslist" | while read __tag
do
	# Get the base directory for that tag
	__base="$__fuse/checkins/$__tag/"
	
	# Go through all projects in the base
	"$__exedir/lsprojects.sh" "$__base" | while read __project
	do
		__uuid="$("$__exedir/projectuuid.sh" "$__base/$__project")"
		__count="$("$__exedir/todocount.sh" "$__base/$__project")"
		
		echo "$__tag" "$__project" "$__uuid" "$__count"
	done
done | java -classpath "$__odr" "$__cls" "$@"
exit $?

Deleted utils-dev/todototals.sh.

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

































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Prints the totals for all namespaces.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Allow a custom root to be specified
if [ "$#" -ge "1" ]
then
	__root="$1"
else
	__root="$__exedir/.."
fi

# Count through all projects
"$__exedir/lsprojects.sh" | while read __project
do
	__count="$("$__exedir/todocount.sh" "$__root/$__project")"
	
	echo "$__project $__count"
done

Deleted utils-dev/updateerror.sh.

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


































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Updates the error script.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Needs to be in a repository
cd "$__exedir"

# Build
"$__exedir/builderrors.sh" > /tmp/$$

# Did the errors actually change?
if [ "$(fossil unversion cat "errors.mkd" | fossil sha1sum - | \
	cut -d ' ' -f 1)" != "$(fossil sha1sum - < /tmp/$$ | cut -d ' ' -f 1)" ]
then
	echo "Errors updated"
	fossil unversion add /tmp/$$ --as "errors.mkd"
else
	echo "Errors untouched"
fi
rm -f /tmp/$$

Deleted utils-dev/updatejavadoc.sh.

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
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


































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Generates the JavaDoc and synchronizes the changes into the
# fossil unversioned space

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Generate JavaDoc
__javadocfailed=0
if true
then
	rm -rf "javadoc"
	if ! "$__exedir/javadoc.sh"
	then
		echo "Failed to generate JavaDoc, will only update errors"
		__javadocfailed=1
	fi
fi

# Remember this point
__docroot="$(pwd)/javadoc"

# Go to the project home directory so fossil works
cd "$__exedir/.."
__srcdir="$__exedir/.."

# Generate and update errors list
echo "Generating error list..."
"$__exedir/updateerror.sh"

# Do not bother updating the docs
if [ "$__javadocfailed" -ne "0" ]
then
	echo "Failed to build the doc generator, cannot update."
	exit 1
fi

# Count the number of documents that should exist
__ad="$("$__exedir/lsall.sh" | grep '\.java$' | wc -l)"
__hd="$(expr "$(expr "$__ad" "/" "2")" "+" "$(expr "$__ad" "/" "4")")"

# If half of the documents fail to generate, then do not generate at all
__nd="$(cd "$__docroot"; find -type f | grep '\.mkd$' | wc -l)"
if [ "$__nd" -lt "$__hd" ]
then
	echo "Not enough documents, not going to update."
	echo "$__nd did not meet threshold of $__hd for $__ad sources."
	exit 1
fi

# Files in javadoc and unversioned space
# Add a line that is different from A and B
(cd "$__docroot"; find -type f | grep '\.mkd$' | sed 's/\.\///g'; \
	echo "@IgnoreA") | sort > /tmp/$$.a
(fossil unversion ls | grep '^javadoc\/' | grep '\.mkd$' | \
	sed 's/^javadoc\///g'; echo "@IgnoreB") | sort > /tmp/$$.b

# Go through all files
# Set the unified diff surrounding change count to a really high value so that
# all changes can possibly be detected. Otherwise, there would need to be a
# second pass for files which were not changed, just to see if they were
# changed (sort, sort, uniq).
diff -U 99999 /tmp/$$.b /tmp/$$.a | grep '^[\-\+ ][^\-\+]' | \
	while read -r __line
do
	# Get the change mode and the file
	__mode="$(echo "$__line" | cut -c 1)"
	__file="$(echo "$__line" | cut -c 2-)"
	
	# Space gone away?
	if [ "$__mode" != "-" ] && [ "$__mode" != "+" ]
	then
		__file="$__mode$__file"
		__mode="="
	fi
	
	# Ignore?
	__fcha="$(echo "$__file" | cut -c 1)"
	if [ "$__fcha" = "@" ]
	then
		continue
	fi
	
	# The unversioned target
	__targ="javadoc/$__file"
	
	# Debug
	echo "$__mode $__file -> $__targ"
	
	# Adding file?
	if [ "$__mode" = "+" ]
	then
		fossil unversion add "$__docroot/$__file" --as "$__targ"
	
	# Removing file?
	elif [ "$__mode" = "-" ]
	then
		fossil unversion rm "$__targ"
	
	# Updating, if changed
	else
		# Get sha1 for both files
		__was="$(fossil unversion cat "$__targ" | fossil sha1sum - | \
			cut -d ' ' -f 1)"
		__now="$(fossil sha1sum - < "$__docroot/$__file" | \
			cut -d ' ' -f 1)"
		
		# Did the file change?
		if [ "$__was" != "$__now" ]
		then
			fossil unversion add "$__docroot/$__file" --as "$__targ"
		fi
	fi
done

# Cleanup
rm -f /tmp/$$.a
rm -f /tmp/$$.b

Deleted utils-dev/vmlaunch.sh.

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79















































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Launches the specified program using a VM.

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# May be replaced
: ${JAVA:=java}

__print_usage()
{
	echo "Usage: $0 [-w] [-p #] (project[:#]|file.jar)" 1>&2
	echo "" 1>&2
	echo "  [-w]   Run with Wine instead" 1>&2
	echo "  [-p #] Can be 0 or greater to specify that an alternative" 1>&2
	echo "         application be used for a given program." 1>&2
}

# Usage
if [ "$#" -lt 1 ]
then
	__print_usage
	exit 1
fi

# Parse arguments
__wine=0
__numb=-1
while getopts wp: __opt
do
	case "$__opt" in
		w)
			__wine=1
			;;
		
		p)
			__numb="$OPTARG"
			;;
		
		*)
			__print_usage
			exit 1
			;;
	esac
done

# Done
shift $(($OPTIND - 1))

# File is the first one
if [ "$__numb" = "-1" ]
then
	__file="$1"
else
	__file="$1:$__numb"
fi
shift

# Forward to the VM launcher
if [ "$__wine" -ne "0" ]
then
	"$__exedir/buildwine.sh" -B launch "$__file" "$@"
	exit $?
else
	"$__exedir/../build.sh" -B launch "$__file" "$@"
	exit $?
fi

Deleted utils-dev/wineemul.sh.

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
















































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# ---------------------------------------------------------------------------
# Multi-Phasic Applications: SquirrelJME
#     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
#     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
# ---------------------------------------------------------------------------
# SquirrelJME is under the GNU General Public License v3+, or later.
# See license.mkd for licensing and copyright information.
# ---------------------------------------------------------------------------
# DESCRIPTION: Runs the specified JAD/JAR in the emulator
#
# !!! IF YOU GET THE FOLLOWING: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Error: Cannot find any soundbank file
# Execution completed.
# ---------------------------------------------------------------------------
# You need to place gm.dls into c:\windows\system32\drivers
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# Force C locale
export LC_ALL=C

# Directory of this script
__exedir="$(dirname -- "$0")"

# Path of the emulator
: ${EMULATOR_PATH:="$HOME/.wine/drive_c/WTK2.5.2_01/bin/emulator.exe"}
#: ${EMULATOR_PATH:="$HOME/.wine/drive_c/Java_ME_platform_SDK_3.4/bin/emulator.exe"}

# Usage
if [ "$#" -ne "1" ]
then
	echo "Usage: $0 (file.jad)"
	exit 1
fi

# Clear all old programs
if ! wine "$EMULATOR_PATH" -Xjam:remove=all
then
	echo "Could not remove all old programs, ignoring" 1>&2
fi

# Run the JAD
if ! wine "$EMULATOR_PATH" "-Xdescriptor:$(winepath -w "$1")" # -Xverbose:calls
then
	echo "Run failed" 1>&2
	exit 1
fi